data

package
v0.0.0-...-4afd048 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package data provides helpers for normalizing runtime payload shapes so N.O.R.E. operates on canonical snake_case keys regardless of the casing authors chose at the source (for example camelCase --params for a TypeScript-authored assembly).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalMap

func CanonicalMap(source map[string]any) map[string]any

CanonicalMap returns a canonicalized deep copy of source. A nil source yields an empty map rather than nil, so callers that read from the result never have to distinguish "absent" from "empty".

func CanonicalValue

func CanonicalValue(value any) any

CanonicalValue returns a deep copy of value in the one representation N.O.R.E. uses for every runtime payload.

The engine accepts payloads from several places that each have their own Go types: an HTTP request body decoded into `map[string]any` yields float64 for every number, a CEL expression yields int64 or float64 depending on whether the value was computed or copied out of a native map, and a capability runtime's JSON response yields float64 again. Left alone, the same logical number reaches an in-process capability as `int`, `int64`, or `float64` depending on how the author wrote an expression, and an execution restored from a snapshot observes different types than the same execution before it was persisted.

CanonicalValue removes that ambiguity: on the way in, every JSON number becomes the float64 that `encoding/json` produces, and every container is copied so no caller can mutate engine state through a returned payload.

Values outside the JSON data model are passed through unchanged, because the engine does not own them and rejecting them here would fail a payload that JSON would have carried losslessly.

func DeepSnakeCase

func DeepSnakeCase(v any) any

DeepSnakeCase returns a copy of v with every map key converted to snake_case, applied recursively to nested maps and slices. Non-map values are passed through unchanged, so the operation is idempotent.

func SnakeMap

func SnakeMap(in map[string]any) map[string]any

SnakeMap normalizes a map (or map-shaped value) to snake_case keys without requiring callers to type-assert the result for the common map[string]any case.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL