@githolon/dsl 0.54.0 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/fields.ts +25 -4
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@githolon/dsl",
|
|
3
|
-
"version": "0.54.
|
|
3
|
+
"version": "0.54.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Nomos 2 domain-authoring DSL: aggregates + directives in TS, executed and encoded to the Rust kernel's wire shapes.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/fields.ts
CHANGED
|
@@ -19,6 +19,22 @@ import { Conflict, Counter, LastPosition, Lww, type Driver } from "./drivers.js"
|
|
|
19
19
|
import type { AggregateHandle } from "./aggregate.js";
|
|
20
20
|
import type { FieldFacet } from "./principal_evidence.js";
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* A structured JSON value — the AUTHORING type a `json`-kind field (`t.json()`,
|
|
24
|
+
* `t.jsonObject()`, a value-object field) now accepts on the write path. The kernel
|
|
25
|
+
* stores json leaves as `Value::Json` (RFC 8785/JCS), so a plan may `set(...)` a real
|
|
26
|
+
* object/array/scalar (not just a pre-stringified `string`). TYPE-LEVEL ONLY: the wire +
|
|
27
|
+
* read-model type of a json field is unchanged; this only widens what `set`/`setEntry`
|
|
28
|
+
* ACCEPT. (`string` stays a member, so already-stringified callers keep typechecking.)
|
|
29
|
+
*/
|
|
30
|
+
export type JsonValue =
|
|
31
|
+
| string
|
|
32
|
+
| number
|
|
33
|
+
| boolean
|
|
34
|
+
| null
|
|
35
|
+
| JsonValue[]
|
|
36
|
+
| { readonly [k: string]: JsonValue };
|
|
37
|
+
|
|
22
38
|
export type FieldKind =
|
|
23
39
|
| "string"
|
|
24
40
|
| "int"
|
|
@@ -475,8 +491,11 @@ export const t = {
|
|
|
475
491
|
* JSON leaf — the kernel `Value` is Str|Int only), so the v1-free projection surfaces
|
|
476
492
|
* it as a permissive `Object?`. Use `t.jsonObject()` when the leaf is ALWAYS an OBJECT
|
|
477
493
|
* value-object (e.g. a `location`) to get a strict `Map<String,Object?>` read type. */
|
|
478
|
-
json(): Field<
|
|
479
|
-
|
|
494
|
+
json(): Field<JsonValue, "json"> {
|
|
495
|
+
// AUTHORING type is the structured JsonValue (the kernel stores Value::Json), so a plan may
|
|
496
|
+
// set()/setEntry() a real object/array/scalar. The runtime wire + zod are UNCHANGED (a `Str`
|
|
497
|
+
// leaf at op time — no hash change); only the accepted TS value widens (a `string` stays valid).
|
|
498
|
+
return makeField<string, "json">("json", z.string(), Lww) as unknown as Field<JsonValue, "json">;
|
|
480
499
|
},
|
|
481
500
|
/** A JSON-OBJECT value-object leaf: an arbitrary JSON-string leaf (identical wire +
|
|
482
501
|
* driver to `t.json()` — a `Str` at op time, so NO hash change) whose decoded value is
|
|
@@ -485,8 +504,10 @@ export const t = {
|
|
|
485
504
|
* `Map<String,Object?>` with a STRICT reader (a present-but-non-object value throws —
|
|
486
505
|
* the strict-decode contract), as opposed to a plain `t.json()` (decoded shape unknown
|
|
487
506
|
* → permissive `Object?`). Marks `jsonShape:"object"`; the kind stays `"json"`. */
|
|
488
|
-
jsonObject(): Field<
|
|
489
|
-
|
|
507
|
+
jsonObject(): Field<JsonValue, "json"> {
|
|
508
|
+
// Same JsonValue authoring widening as `t.json()` (structured value in, `Str` wire out — no hash
|
|
509
|
+
// change); the `jsonShape:"object"` marker only steers the read-model to a strict object reader.
|
|
510
|
+
return makeField<string, "json">("json", z.string(), Lww, { jsonShape: "object" }) as unknown as Field<JsonValue, "json">;
|
|
490
511
|
},
|
|
491
512
|
/**
|
|
492
513
|
* Reference to another aggregate (stored as its id string).
|