@adobe/data 0.9.82 → 0.9.83

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.
Files changed (56) hide show
  1. package/dist/ecs/archetype/archetype.d.ts +23 -0
  2. package/dist/ecs/archetype/archetype.js.map +1 -1
  3. package/dist/ecs/database/create-plugin.d.ts +2 -1
  4. package/dist/ecs/database/create-plugin.js.map +1 -1
  5. package/dist/ecs/database/database.d.ts +6 -5
  6. package/dist/ecs/database/database.js.map +1 -1
  7. package/dist/ecs/database/database.partition.test.d.ts +1 -0
  8. package/dist/ecs/database/database.partition.test.js +45 -0
  9. package/dist/ecs/database/database.partition.test.js.map +1 -0
  10. package/dist/ecs/database/database.partition.type-test.d.ts +1 -0
  11. package/dist/ecs/database/database.partition.type-test.js +41 -0
  12. package/dist/ecs/database/database.partition.type-test.js.map +1 -0
  13. package/dist/ecs/database/deep-extends-chain.type-test.d.ts +255 -255
  14. package/dist/ecs/database/index.d.ts +0 -1
  15. package/dist/ecs/database/index.js +0 -1
  16. package/dist/ecs/database/index.js.map +1 -1
  17. package/dist/ecs/database/transactional-store/transactional-store.d.ts +6 -5
  18. package/dist/ecs/store/core/core.d.ts +33 -8
  19. package/dist/ecs/store/core/create-core.d.ts +12 -2
  20. package/dist/ecs/store/core/create-core.js +141 -22
  21. package/dist/ecs/store/core/create-core.js.map +1 -1
  22. package/dist/ecs/store/core/create-core.partition.test.d.ts +1 -0
  23. package/dist/ecs/store/core/create-core.partition.test.js +229 -0
  24. package/dist/ecs/store/core/create-core.partition.test.js.map +1 -0
  25. package/dist/ecs/store/core/select-entities.js +87 -21
  26. package/dist/ecs/store/core/select-entities.js.map +1 -1
  27. package/dist/ecs/store/core/select-entities.partition.test.d.ts +1 -0
  28. package/dist/ecs/store/core/select-entities.partition.test.js +93 -0
  29. package/dist/ecs/store/core/select-entities.partition.test.js.map +1 -0
  30. package/dist/ecs/store/entity-select-options.d.ts +5 -1
  31. package/dist/ecs/store/partition.d.ts +63 -0
  32. package/dist/ecs/store/partition.js +3 -0
  33. package/dist/ecs/store/partition.js.map +1 -0
  34. package/dist/ecs/store/partition.type-test.d.ts +1 -0
  35. package/dist/ecs/store/partition.type-test.js +15 -0
  36. package/dist/ecs/store/partition.type-test.js.map +1 -0
  37. package/dist/ecs/store/public/create-store.d.ts +3 -1
  38. package/dist/ecs/store/public/create-store.js +19 -50
  39. package/dist/ecs/store/public/create-store.js.map +1 -1
  40. package/dist/ecs/store/public/create-store.partition.test.d.ts +1 -0
  41. package/dist/ecs/store/public/create-store.partition.test.js +111 -0
  42. package/dist/ecs/store/public/create-store.partition.test.js.map +1 -0
  43. package/dist/ecs/store/public/create-store.partition.type-test.d.ts +1 -0
  44. package/dist/ecs/store/public/create-store.partition.type-test.js +61 -0
  45. package/dist/ecs/store/public/create-store.partition.type-test.js.map +1 -0
  46. package/dist/ecs/store/store.d.ts +15 -10
  47. package/dist/ecs/store/store.js.map +1 -1
  48. package/dist/ecs/store/transaction-functions.d.ts +3 -3
  49. package/dist/schema/schema.d.ts +1 -0
  50. package/dist/tsconfig.tsbuildinfo +1 -1
  51. package/package.json +1 -1
  52. package/references/data-lit/package.json +1 -1
  53. package/references/data-lit-tictactoe/package.json +1 -1
  54. package/references/data-react/package.json +1 -1
  55. package/references/data-react-hello/package.json +1 -1
  56. package/references/data-react-pixie/package.json +1 -1
@@ -35,6 +35,29 @@ export interface Archetype<C extends RequiredComponents = RequiredComponents> ex
35
35
  toData: (copy?: boolean) => unknown;
36
36
  fromData: (data: unknown) => void;
37
37
  }
38
+ export declare namespace Archetype {
39
+ /**
40
+ * Write-only handle over a *family* of archetypes that share a component set
41
+ * but differ by the value of one or more `partition` components. `insert`
42
+ * reads the partition value(s) from the row, resolves (creating on first use)
43
+ * the concrete child archetype for that value, and inserts there.
44
+ *
45
+ * A family has no single dense column view, so — unlike {@link Archetype} — a
46
+ * Router exposes no `columns`, `rowCount`, or iteration. Read a family through
47
+ * `queryArchetypes` (optionally filtered by partition value), or narrow to one
48
+ * concrete member by supplying the value to `ensureArchetype`.
49
+ *
50
+ * `insert` is deliberately signature-identical to {@link Archetype.insert}: a
51
+ * discriminated `Archetype<C> | Archetype.Router<C>` (produced when the
52
+ * requested keys are not statically known to include/exclude a partition
53
+ * component) therefore still permits `.insert` with no narrowing — only dense
54
+ * column access requires having resolved to a concrete {@link Archetype}.
55
+ */
56
+ interface Router<C extends RequiredComponents = RequiredComponents> {
57
+ readonly components: ComponentSet<StringKeyof<C>>;
58
+ insert: <T extends EntityInsertValues<C>>(rowData: Exact<EntityInsertValues<C>, T>) => Entity;
59
+ }
60
+ }
38
61
  export type FromArchetype<T> = T extends ReadonlyArchetype<infer C> ? {
39
62
  readonly [K in keyof C]: C[K];
40
63
  } : T extends Archetype<infer C> ? {
@@ -1 +1 @@
1
- {"version":3,"file":"archetype.js","sourceRoot":"","sources":["../../../src/ecs/archetype/archetype.ts"],"names":[],"mappings":"AAsDA,gDAAgD;AAChD,CAAC;IAKG,2BAA2B;IAC3B,MAAM,eAAe,GAAG,CAAC,IAAmB,EAAE,EAAE;QAC5C,MAAM,SAAS,GAAoB,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB;IAC7C,CAAC,CAAC;IAEF,2CAA2C;IAC3C,MAAM,iBAAiB,GAAG,CAAC,IAAmB,EAAE,EAAE;QAC9C,MAAM,WAAW,GAAoB,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAChG,oDAAoD;QACpD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"archetype.js","sourceRoot":"","sources":["../../../src/ecs/archetype/archetype.ts"],"names":[],"mappings":"AA+EA,gDAAgD;AAChD,CAAC;IAKG,2BAA2B;IAC3B,MAAM,eAAe,GAAG,CAAC,IAAmB,EAAE,EAAE;QAC5C,MAAM,SAAS,GAAoB,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB;IAC7C,CAAC,CAAC;IAEF,2CAA2C;IAC3C,MAAM,iBAAiB,GAAG,CAAC,IAAmB,EAAE,EAAE;QAC9C,MAAM,WAAW,GAAoB,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAChG,oDAAoD;QACpD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC,CAAC;AACN,CAAC"}
@@ -5,6 +5,7 @@ import type { ArchetypeComponents } from "../store/archetype-components.js";
5
5
  import type { TransactionDeclarations, ToTransactionFunctions } from "../store/transaction-functions.js";
6
6
  import type { ToActionFunctions } from "../store/action-functions.js";
7
7
  import type { FromSchemas } from "../../schema/index.js";
8
+ import type { PartitionKeysOf } from "../store/partition.js";
8
9
  import type { StringKeyof, NoInfer, RemoveIndex } from "../../types/types.js";
9
10
  import { Store } from "../store/store.js";
10
11
  /**
@@ -83,7 +84,7 @@ type FullDBForPlugin<CS, RS, A, TD, S extends string, AD, XP extends Database.Pl
83
84
  * `& {}` (identity on the object-typed buckets) — no cost or behavior change.
84
85
  */
85
86
  type AmbientPlugin<XP extends Database.Plugin, IP extends Database.Plugin> = Database.Plugin<XP['components'] & IP['components'], XP['resources'] & IP['resources'], XP['archetypes'] & IP['archetypes'], XP['transactions'] & IP['transactions'], StringKeyof<XP['systems']> | StringKeyof<IP['systems']>, XP['actions'] & IP['actions'], XP['services'] & IP['services'], XP['computed'] & IP['computed'], XP['indexes'] & IP['indexes']>;
86
- export declare function createPlugin<const XP extends Database.Plugin<{}, {}, {}, {}, never, {}, {}, {}, {}>, const IP extends Database.Plugin<{}, {}, {}, {}, never, {}, {}, {}, {}>, const CS extends ComponentSchemas, const RS extends ResourceSchemas, const A extends ArchetypeComponents<StringKeyof<RemoveIndex<CS> & XP['components'] & IP['components']>>, const IX extends IndexDeclarations<FromSchemas<RemoveIndex<CS> & XP['components'] & IP['components']>, RemoveIndex<A> & XP['archetypes'] & IP['archetypes']>, const TD extends TransactionDeclarations<FromSchemas<RemoveIndex<CS> & XP['components'] & IP['components']>, FromSchemas<RemoveIndex<RS> & XP['resources'] & IP['resources']>, RemoveIndex<A> & XP['archetypes'] & IP['archetypes'], RemoveIndex<IX> & XP['indexes'] & IP['indexes']>, const AD, const S extends string = never, const SVF extends ServiceFactories<Database.FromPlugin<AmbientPlugin<XP, IP>>> = {}, const CVF extends PluginComputedFactories<FullDBForPlugin<RemoveIndex<CS>, RemoveIndex<RS>, RemoveIndex<A>, RemoveIndex<TD>, S, RemoveIndex<AD> & XP['actions'] & IP['actions'], AmbientPlugin<XP, IP>, RemoveIndex<SVF>, RemoveIndex<IX>>> = {}>(plugins: {
87
+ export declare function createPlugin<const XP extends Database.Plugin<{}, {}, {}, {}, never, {}, {}, {}, {}>, const IP extends Database.Plugin<{}, {}, {}, {}, never, {}, {}, {}, {}>, const CS extends ComponentSchemas, const RS extends ResourceSchemas, const A extends ArchetypeComponents<StringKeyof<RemoveIndex<CS> & XP['components'] & IP['components']>>, const IX extends IndexDeclarations<FromSchemas<RemoveIndex<CS> & XP['components'] & IP['components']>, RemoveIndex<A> & XP['archetypes'] & IP['archetypes']>, const TD extends TransactionDeclarations<FromSchemas<RemoveIndex<CS> & XP['components'] & IP['components']>, FromSchemas<RemoveIndex<RS> & XP['resources'] & IP['resources']>, RemoveIndex<A> & XP['archetypes'] & IP['archetypes'], RemoveIndex<IX> & XP['indexes'] & IP['indexes'], PartitionKeysOf<RemoveIndex<CS> & XP['components'] & IP['components']>>, const AD, const S extends string = never, const SVF extends ServiceFactories<Database.FromPlugin<AmbientPlugin<XP, IP>>> = {}, const CVF extends PluginComputedFactories<FullDBForPlugin<RemoveIndex<CS>, RemoveIndex<RS>, RemoveIndex<A>, RemoveIndex<TD>, S, RemoveIndex<AD> & XP['actions'] & IP['actions'], AmbientPlugin<XP, IP>, RemoveIndex<SVF>, RemoveIndex<IX>>> = {}>(plugins: {
87
88
  imports?: IP;
88
89
  extends?: XP;
89
90
  services?: SVF & {
@@ -1 +1 @@
1
- {"version":3,"file":"create-plugin.js","sourceRoot":"","sources":["../../../src/ecs/database/create-plugin.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAUvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA0CtD,SAAS,qBAAqB,CAAC,OAAgC;IAC3D,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAC/J,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC;IAE7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,GAAG,GAA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AC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE;QAChC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,EAAE;QACxC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;QAC9B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;KACjC,CAAC;IAEF,wEAAwE;IACxE,0EAA0E;IAC1E,qEAAqE;IACrE,6EAA6E;IAC7E,4EAA4E;IAC5E,2EAA2E;IAC3E,0EAA0E;IAC1E,2EAA2E;IAC3E,MAAM,KAAK,GAAsB,EAAE,CAAC;IACpC,IAAI,OAAO,CAAC,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,OAAO,CAAC,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC,GAAG,KAAK,EAAE,MAAM,CAAQ,CAAC;IACnD,CAAC;IACD,OAAO,MAAa,CAAC;AACzB,CAAC"}
@@ -17,6 +17,7 @@ import { createDatabase } from "./public/create-database.js";
17
17
  import type { ConcurrencyStrategy } from "./concurrency/concurrency-strategy.js";
18
18
  import { ResourceSchemas } from "../resource-schemas.js";
19
19
  import { ComponentSchemas } from "../component-schemas.js";
20
+ import { PartitionKeysOf } from "../store/partition.js";
20
21
  import { FromSchemas } from "../../schema/index.js";
21
22
  import type { TransactionDeclarations, TransactionFunctions, ToTransactionFunctions } from "../store/transaction-functions.js";
22
23
  import type { ActionDeclarations, ActionFunctions, ToActionFunctions } from "../store/action-functions.js";
@@ -89,7 +90,7 @@ export type PluginComputedFactories<DB = any> = {
89
90
  */
90
91
  export type { IndexDeclarations } from "../store/index-types.js";
91
92
  import type { IndexDeclarations } from "../store/index-types.js";
92
- export interface Database<C extends Components = {}, R extends ResourceComponents = {}, A extends ArchetypeComponents<StringKeyof<C>> = {}, F extends TransactionFunctions = {}, S extends string = never, AF extends ActionFunctions = {}, SV = {}, CV = unknown, IX extends IndexDeclarations<C> = {}> extends ReadonlyStore<C, R, A, IX>, Service {
93
+ export interface Database<C extends Components = {}, R extends ResourceComponents = {}, A extends ArchetypeComponents<StringKeyof<C>> = {}, F extends TransactionFunctions = {}, S extends string = never, AF extends ActionFunctions = {}, SV = {}, CV = unknown, IX extends IndexDeclarations<C> = {}, PK extends string = never> extends ReadonlyStore<C, R, A, IX, PK>, Service {
93
94
  readonly transactions: F & Service;
94
95
  readonly actions: AF & Service;
95
96
  readonly services: SV;
@@ -240,7 +241,7 @@ export declare namespace Database {
240
241
  * (P extends Plugin<infer CS, ...> ? CS : never) to avoid expensive 8-way type
241
242
  * expansion that amplifies TS7056 serialization overflow in deep extends chains.
242
243
  */
243
- type FromPlugin<P extends Database.Plugin> = Database<FromSchemas<RemoveIndex<P['components']>>, FromSchemas<RemoveIndex<P['resources']>>, RemoveIndex<P['archetypes']>, ToTransactionFunctions<RemoveIndex<P['transactions']>>, StringKeyof<P['systems']>, ToActionFunctions<RemoveIndex<P['actions']>>, FromServiceFactories<RemoveIndex<P['services']>>, FromComputedFactories<RemoveIndex<P['computed']>>, RemoveIndex<P['indexes']>>;
244
+ type FromPlugin<P extends Database.Plugin> = Database<FromSchemas<RemoveIndex<P['components']>>, FromSchemas<RemoveIndex<P['resources']>>, RemoveIndex<P['archetypes']>, ToTransactionFunctions<RemoveIndex<P['transactions']>>, StringKeyof<P['systems']>, ToActionFunctions<RemoveIndex<P['actions']>>, FromServiceFactories<RemoveIndex<P['services']>>, FromComputedFactories<RemoveIndex<P['computed']>>, RemoveIndex<P['indexes']>, PartitionKeysOf<RemoveIndex<P['components']>>>;
244
245
  /**
245
246
  * The read-only projection of a Database that a `db.derive` callback
246
247
  * receives. It exposes only the auto-trackable read surface —
@@ -258,7 +259,7 @@ export declare namespace Database {
258
259
  * Because the surface is narrowed structurally, misuse is a compile error
259
260
  * rather than a value that must be guarded / thrown on at runtime.
260
261
  */
261
- type Read<DB extends Database<any, any, any, any, any, any, any, any, any>> = Pick<DB, "get" | "read" | "resources"> & {
262
+ type Read<DB extends Database<any, any, any, any, any, any, any, any, any, any>> = Pick<DB, "get" | "read" | "resources"> & {
262
263
  select(include: readonly string[] | ReadonlySet<string>, options?: {
263
264
  readonly exclude?: readonly string[];
264
265
  }): readonly Entity[];
@@ -266,7 +267,7 @@ export declare namespace Database {
266
267
  readonly [K in keyof DB["indexes"]]: Omit<DB["indexes"][K], "observe">;
267
268
  };
268
269
  readonly archetypes: {
269
- readonly [K in keyof DB["archetypes"]]: Pick<DB["archetypes"][K], "components" | "id">;
270
+ readonly [K in keyof DB["archetypes"]]: Pick<DB["archetypes"][K], ("components" | "id") & keyof DB["archetypes"][K]>;
270
271
  };
271
272
  };
272
273
  const create: typeof createDatabase;
@@ -322,7 +323,7 @@ export declare namespace Database {
322
323
  * another plugin's transaction declaration; `ToStore<P>` is the bare
323
324
  * store type and does not include `userId`.
324
325
  */
325
- type ToTransactionContext<P extends Database.Plugin> = TransactionContext<FromSchemas<RemoveIndex<P['components']>>, FromSchemas<RemoveIndex<P['resources']>>, RemoveIndex<P['archetypes']>>;
326
+ type ToTransactionContext<P extends Database.Plugin> = TransactionContext<FromSchemas<RemoveIndex<P['components']>>, FromSchemas<RemoveIndex<P['resources']>>, RemoveIndex<P['archetypes']>, RemoveIndex<P['indexes']>, PartitionKeysOf<RemoveIndex<P['components']>>>;
326
327
  type ToSystemDatabase<P extends Database.Plugin> = Database.FromPlugin<P> & {
327
328
  readonly store: Database.Plugin.ToStore<P>;
328
329
  services: {
@@ -1 +1 @@
1
- {"version":3,"file":"database.js","sourceRoot":"","sources":["../../../src/ecs/database/database.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAkBvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,IAAI,kBAAkB,EAAE,MAAM,iCAAi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,IAAI,cAAc,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,QAAQ,IAAI,KAAK,IAAI,QAAQ,IAAI,KAAK,CAAC;IAC1L,CAAC,CAAA;IAEY,0BAAiB,GAAG,kBAAkB,CAAC;IAiEpD,IAAiB,MAAM,CAqBtB;IArBD,WAAiB,MAAM;QACR,aAAM,GAAG,YAAY,CAAC;QACtB,cAAO,GAAG,cAAc,CAAC;IAmBxC,CAAC,EArBgB,MAAM,GAAN,eAAM,KAAN,eAAM,QAqBtB;AAEH,CAAC,EAnKgB,QAAQ,KAAR,QAAQ,QAmKxB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { describe, it, expect } from "vitest";
3
+ import { Database } from "./database.js";
4
+ // A plugin whose `cell` component partitions, with a unique name index. The
5
+ // transactions write through the transaction context `t`, exercising routing
6
+ // and index maintenance on the committed-transaction path.
7
+ const plugin = () => Database.Plugin.create({
8
+ components: {
9
+ cell: { type: "integer", partition: true },
10
+ name: { type: "string" },
11
+ },
12
+ archetypes: { Spatial: ["cell", "name"] },
13
+ indexes: { byName: { key: "name", unique: true } },
14
+ transactions: {
15
+ add: (t, input) => t.archetypes.Spatial.insert(input),
16
+ move: (t, input) => { t.update(input.entity, { cell: input.cell }); },
17
+ },
18
+ });
19
+ describe("Database partition integration (transaction context)", () => {
20
+ it("routes t.archetypes.<PartitionedName> inserts and maintains indexes", () => {
21
+ const db = Database.create(plugin());
22
+ const a = db.transactions.add({ cell: 1, name: "alice" });
23
+ const b = db.transactions.add({ cell: 2, name: "bob" });
24
+ expect(db.indexes.byName.get({ name: "alice" })).toBe(a);
25
+ expect(db.indexes.byName.get({ name: "bob" })).toBe(b);
26
+ // Distinct cells → distinct concrete archetypes.
27
+ expect(db.locate(a).archetype).not.toBe(db.locate(b).archetype);
28
+ expect(db.get(a, "cell")).toBe(1);
29
+ });
30
+ it("migrates on a partition-value change inside a transaction; index follows", () => {
31
+ const db = Database.create(plugin());
32
+ const e = db.transactions.add({ cell: 1, name: "mover" });
33
+ db.transactions.move({ entity: e, cell: 2 });
34
+ expect(db.get(e, "cell")).toBe(2);
35
+ expect(db.indexes.byName.get({ name: "mover" })).toBe(e);
36
+ });
37
+ it("enforces a unique index across value-children inside a transaction (atomic)", () => {
38
+ const db = Database.create(plugin());
39
+ const first = db.transactions.add({ cell: 1, name: "dup" });
40
+ expect(() => db.transactions.add({ cell: 2, name: "dup" })).toThrow(/[Uu]nique/);
41
+ // Original intact — the failed transaction rolled back cleanly.
42
+ expect(db.indexes.byName.get({ name: "dup" })).toBe(first);
43
+ });
44
+ });
45
+ //# sourceMappingURL=database.partition.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.partition.test.js","sourceRoot":"","sources":["../../../src/ecs/database/database.partition.test.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,4EAA4E;AAC5E,6EAA6E;AAC7E,2DAA2D;AAC3D,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACxC,UAAU,EAAE;QACR,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE;QAC1C,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC3B;IACD,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;IACzC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAClD,YAAY,EAAE;QACV,GAAG,EAAE,CAAC,CAAC,EAA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AAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,41 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ //
3
+ // Compile-time (red/green) verification that the transaction context `t`
4
+ // discriminates partition archetypes — both `t.archetypes.<Name>` and
5
+ // `t.ensureArchetype`. Wrapped in a never-called function so the file
6
+ // type-checks without executing the plugin factory.
7
+ import { Database } from "./database.js";
8
+ function _transactionContextDiscrimination() {
9
+ Database.Plugin.create({
10
+ components: {
11
+ cell: { type: "integer", partition: true },
12
+ position: { type: "number" },
13
+ health: { type: "number" },
14
+ },
15
+ archetypes: {
16
+ Spatial: ["cell", "position"], // partition family
17
+ Mob: ["position", "health"], // concrete
18
+ },
19
+ transactions: {
20
+ check: (t) => {
21
+ // A partitioned named archetype is a Router on `t` — write via insert.
22
+ t.archetypes.Spatial.insert({ cell: 1, position: 2 });
23
+ // @ts-expect-error - Spatial is a partition family (Router), not a concrete Archetype
24
+ t.archetypes.Spatial.columns;
25
+ // A non-partition named archetype is a concrete Archetype on `t`.
26
+ t.archetypes.Mob.columns;
27
+ t.archetypes.Mob.insert({ position: 1, health: 100 });
28
+ // ensureArchetype on `t` discriminates just like on the store.
29
+ const router = t.ensureArchetype(["id", "cell", "position"]);
30
+ router.insert({ cell: 1, position: 2 });
31
+ // @ts-expect-error - a partition family (Router) has no columns
32
+ router.columns;
33
+ const concrete = t.ensureArchetype(["id", "cell", "position"], { cell: 7 });
34
+ concrete.columns;
35
+ // @ts-expect-error - partition value must match the component type (cell is number)
36
+ t.ensureArchetype(["id", "cell", "position"], { cell: "nope" });
37
+ },
38
+ },
39
+ });
40
+ }
41
+ //# sourceMappingURL=database.partition.type-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.partition.type-test.js","sourceRoot":"","sources":["../../../src/ecs/database/database.partition.type-test.ts"],"names":[],"mappings":"AAAA,uDA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