toilscript 0.1.37 → 0.1.38

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "imports": {
3
- "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.37/dist/toilscript.js",
4
- "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.37/dist/cli.js",
3
+ "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.38/dist/toilscript.js",
4
+ "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.38/dist/cli.js",
5
5
  "binaryen": "https://cdn.jsdelivr.net/npm/binaryen@130.0.0-nightly.20260609/index.js",
6
6
  "long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
7
7
  }
@@ -4318,11 +4318,31 @@ declare module "types:toilscript/src/dbcatalog" {
4318
4318
  * `schema_version`: a hash over the ORDERED field layout (name, type, is_array),
4319
4319
  * NOT the value-type name. Adding, removing, retyping, or REORDERING a field
4320
4320
  * changes it - so the runtime can tell a compatible (append-only) change from a
4321
- * breaking one, instead of silently misreading old rows. (Flat, like toildb's
4322
- * `SchemaDescriptor::layout_hash`: a change to a NESTED `@data` type's own fields
4323
- * does not bump the parent - that lands with recursive layouts later.)
4321
+ * breaking one, instead of silently misreading old rows.
4322
+ *
4323
+ * RECURSIVE into nested `@data` types: when a field's `typeName` is a KNOWN
4324
+ * `@data` type (a key of `typeMap`) and not already on the `seen` set (cycle
4325
+ * guard), the SAME running hash continues over that nested type's fields - so a
4326
+ * breaking change to a NESTED type bumps the OUTER `schema_version` and can be
4327
+ * `@migrate`d (instead of being refuse-only). This MUST stay byte-identical to
4328
+ * toildb's `SchemaDescriptor::layout_hash` (the runtime side): the algorithm,
4329
+ * the `seen` add/remove, and the declaration-order traversal are pinned in lock
4330
+ * step. A FLAT type (no field whose type is in `typeMap`) hashes to the SAME
4331
+ * value as the old flat hash, so existing pinned vectors stay green; an absent
4332
+ * `typeMap` (undefined) is flat/back-compatible.
4333
+ *
4334
+ * `typeMap` MUST contain the SAME set of `@data` types as the runtime's
4335
+ * `toildb.types` registry (collection value types + their nested types, EXCLUDING
4336
+ * old `*.migration.ts` shapes), or the two hashes diverge: a nested field whose
4337
+ * type is absent from the map on either side is treated as a LEAF on both sides.
4324
4338
  */
4325
- export function layoutHash(fields: FieldLayout[]): number;
4339
+ export function layoutHash(fields: FieldLayout[], typeMap?: Map<string, FieldLayout[]> | null, seen?: Set<string> | null): number;
4340
+ /** The recursion type map for `layoutHash`: every `@data` type the runtime's
4341
+ * `toildb.types` registry also contains (collection value types + their nested
4342
+ * types), EXCLUDING old `*.migration.ts` shapes (which the runtime registry
4343
+ * excludes by design). Both sides must recurse through the SAME set, so a
4344
+ * nested field whose type is NOT here is a leaf on both sides. */
4345
+ export function recursionTypeMap(sources: Source[]): Map<string, FieldLayout[]>;
4326
4346
  /** Extract the encoded field layout of a `@data` class, in declaration order,
4327
4347
  * mirroring `injectDataCodec` (skip static; `Array<T>` -> element + array flag;
4328
4348
  * else scalar/string/`Uint8Array`/nested-`@data` by its type name). */
@@ -4339,10 +4359,14 @@ declare module "types:toilscript/src/dbcatalog" {
4339
4359
  sourceInternalPath: string;
4340
4360
  }
4341
4361
  /** Every `@migrate` function across the (non-library) sources. `layouts` maps a
4342
- * `@data` class name to its field layout, for the old-version hash. A migration
4343
- * whose param/return is not a single named type, or whose old type has no
4344
- * layout, is skipped. */
4345
- export function collectMigrations(sources: Source[], layouts: Map<string, FieldLayout[]>): DataMigration[];
4362
+ * `@data` class name to its field layout, for the old-version hash. `typeMap`
4363
+ * (optional) is the recursion type map (see [`recursionTypeMap`]) so the old
4364
+ * version hashes RECURSIVELY through its nested `@data` fields - matching the
4365
+ * `schema_version` that old layout was deployed under (or the migratable old
4366
+ * version would never match a deployed recursive hash). Absent = flat. A
4367
+ * migration whose param/return is not a single named type, or whose old type
4368
+ * has no layout, is skipped. */
4369
+ export function collectMigrations(sources: Source[], layouts: Map<string, FieldLayout[]>, typeMap?: Map<string, FieldLayout[]> | null): DataMigration[];
4346
4370
  /** A resolved chain that migrates a stored OLD value all the way to a target
4347
4371
  * type: decode `oldType`, then apply `steps` in order (each `@migrate`). For a
4348
4372
  * direct migration `steps` has one entry; a chain `V0 -> V1 -> V2` has two. */