@adobe/data 0.9.59 → 0.9.61
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/dist/ecs/database/combine-plugins.d.ts +5 -1
- package/dist/ecs/database/combine-plugins.js +3 -3
- package/dist/ecs/database/combine-plugins.js.map +1 -1
- package/dist/ecs/database/create-plugin.d.ts +17 -14
- package/dist/ecs/database/create-plugin.js +2 -1
- package/dist/ecs/database/create-plugin.js.map +1 -1
- package/dist/ecs/database/database.d.ts +32 -4
- package/dist/ecs/database/database.index.performance.test.d.ts +1 -0
- package/dist/ecs/database/database.index.performance.test.js +417 -0
- package/dist/ecs/database/database.index.performance.test.js.map +1 -0
- package/dist/ecs/database/database.index.test.d.ts +1 -0
- package/dist/ecs/database/database.index.test.js +762 -0
- package/dist/ecs/database/database.index.test.js.map +1 -0
- package/dist/ecs/database/database.index.type-test.d.ts +1 -0
- package/dist/ecs/database/database.index.type-test.js +275 -0
- package/dist/ecs/database/database.index.type-test.js.map +1 -0
- package/dist/ecs/database/database.js.map +1 -1
- package/dist/ecs/database/deep-extends-chain.type-test.d.ts +256 -256
- package/dist/ecs/database/index-api-proof.type-test.d.ts +1 -0
- package/dist/ecs/database/index-api-proof.type-test.js +88 -0
- package/dist/ecs/database/index-api-proof.type-test.js.map +1 -0
- package/dist/ecs/database/index-registry/create-index-registry.d.ts +53 -0
- package/dist/ecs/database/index-registry/create-index-registry.js +174 -0
- package/dist/ecs/database/index-registry/create-index-registry.js.map +1 -0
- package/dist/ecs/database/index-registry/create-index.d.ts +60 -0
- package/dist/ecs/database/index-registry/create-index.js +539 -0
- package/dist/ecs/database/index-registry/create-index.js.map +1 -0
- package/dist/ecs/database/index-registry/index.d.ts +4 -0
- package/dist/ecs/database/index-registry/index.js +4 -0
- package/dist/ecs/database/index-registry/index.js.map +1 -0
- package/dist/ecs/database/public/create-database.js +146 -0
- package/dist/ecs/database/public/create-database.js.map +1 -1
- package/dist/ecs/database/transactional-store/transactional-store.d.ts +3 -2
- package/dist/ecs/plugins/scheduler/scheduler.d.ts +1 -0
- package/dist/ecs/store/index-types.d.ts +132 -0
- package/dist/ecs/store/index-types.js +3 -0
- package/dist/ecs/store/index-types.js.map +1 -0
- package/dist/ecs/store/public/create-store.js +189 -3
- package/dist/ecs/store/public/create-store.js.map +1 -1
- package/dist/ecs/store/store.d.ts +30 -13
- package/dist/ecs/store/store.js +5 -4
- package/dist/ecs/store/store.js.map +1 -1
- package/dist/ecs/store/transaction-functions.d.ts +4 -3
- package/dist/equals.js +24 -6
- package/dist/equals.js.map +1 -1
- package/dist/math/aabb/face/from-position.d.ts +1 -1
- package/dist/math/aabb/face/from-position.js +4 -3
- package/dist/math/aabb/face/from-position.js.map +1 -1
- package/dist/math/aabb/schema.js +1 -1
- package/dist/math/aabb/schema.js.map +1 -1
- package/dist/schema/fractional-index/between-n.d.ts +2 -0
- package/dist/schema/fractional-index/between-n.js +34 -0
- package/dist/schema/fractional-index/between-n.js.map +1 -0
- package/dist/schema/fractional-index/between-n.test.d.ts +1 -0
- package/dist/schema/fractional-index/between-n.test.js +36 -0
- package/dist/schema/fractional-index/between-n.test.js.map +1 -0
- package/dist/schema/fractional-index/between.d.ts +2 -0
- package/dist/schema/fractional-index/between.js +3 -0
- package/dist/schema/fractional-index/between.js.map +1 -0
- package/dist/schema/fractional-index/between.test.d.ts +1 -0
- package/dist/schema/fractional-index/between.test.js +68 -0
- package/dist/schema/fractional-index/between.test.js.map +1 -0
- package/dist/schema/fractional-index/decrement-integer.d.ts +1 -0
- package/dist/schema/fractional-index/decrement-integer.js +32 -0
- package/dist/schema/fractional-index/decrement-integer.js.map +1 -0
- package/dist/schema/fractional-index/decrement-integer.test.d.ts +1 -0
- package/dist/schema/fractional-index/decrement-integer.test.js +31 -0
- package/dist/schema/fractional-index/decrement-integer.test.js.map +1 -0
- package/dist/schema/fractional-index/digits.d.ts +1 -0
- package/dist/schema/fractional-index/digits.js +3 -0
- package/dist/schema/fractional-index/digits.js.map +1 -0
- package/dist/schema/fractional-index/fractional-index.d.ts +4 -0
- package/dist/schema/fractional-index/fractional-index.js +2 -0
- package/dist/schema/fractional-index/fractional-index.js.map +1 -0
- package/dist/schema/fractional-index/increment-integer.d.ts +1 -0
- package/dist/schema/fractional-index/increment-integer.js +32 -0
- package/dist/schema/fractional-index/increment-integer.js.map +1 -0
- package/dist/schema/fractional-index/increment-integer.test.d.ts +1 -0
- package/dist/schema/fractional-index/increment-integer.test.js +34 -0
- package/dist/schema/fractional-index/increment-integer.test.js.map +1 -0
- package/dist/schema/fractional-index/initial.d.ts +2 -0
- package/dist/schema/fractional-index/initial.js +2 -0
- package/dist/schema/fractional-index/initial.js.map +1 -0
- package/dist/schema/fractional-index/integer-length.d.ts +1 -0
- package/dist/schema/fractional-index/integer-length.js +9 -0
- package/dist/schema/fractional-index/integer-length.js.map +1 -0
- package/dist/schema/fractional-index/integer-part.d.ts +1 -0
- package/dist/schema/fractional-index/integer-part.js +9 -0
- package/dist/schema/fractional-index/integer-part.js.map +1 -0
- package/dist/schema/fractional-index/key-between.d.ts +2 -0
- package/dist/schema/fractional-index/key-between.js +39 -0
- package/dist/schema/fractional-index/key-between.js.map +1 -0
- package/dist/schema/fractional-index/midpoint.d.ts +1 -0
- package/dist/schema/fractional-index/midpoint.js +23 -0
- package/dist/schema/fractional-index/midpoint.js.map +1 -0
- package/dist/schema/fractional-index/midpoint.test.d.ts +1 -0
- package/dist/schema/fractional-index/midpoint.test.js +83 -0
- package/dist/schema/fractional-index/midpoint.test.js.map +1 -0
- package/dist/schema/fractional-index/public.d.ts +4 -0
- package/dist/schema/fractional-index/public.js +6 -0
- package/dist/schema/fractional-index/public.js.map +1 -0
- package/dist/schema/fractional-index/schema.d.ts +4 -0
- package/dist/schema/fractional-index/schema.js +5 -0
- package/dist/schema/fractional-index/schema.js.map +1 -0
- package/dist/schema/fractional-index/smallest-integer.d.ts +1 -0
- package/dist/schema/fractional-index/smallest-integer.js +3 -0
- package/dist/schema/fractional-index/smallest-integer.js.map +1 -0
- package/dist/schema/fractional-index/validate-integer.d.ts +1 -0
- package/dist/schema/fractional-index/validate-integer.js +7 -0
- package/dist/schema/fractional-index/validate-integer.js.map +1 -0
- package/dist/schema/fractional-index/validate-order-key.d.ts +1 -0
- package/dist/schema/fractional-index/validate-order-key.js +11 -0
- package/dist/schema/fractional-index/validate-order-key.js.map +1 -0
- package/dist/schema/guid/create.d.ts +2 -0
- package/dist/schema/guid/create.js +10 -0
- package/dist/schema/guid/create.js.map +1 -0
- package/dist/schema/guid/create.test.d.ts +1 -0
- package/dist/schema/guid/create.test.js +39 -0
- package/dist/schema/guid/create.test.js.map +1 -0
- package/dist/schema/guid/equals.d.ts +2 -0
- package/dist/schema/guid/equals.js +3 -0
- package/dist/schema/guid/equals.js.map +1 -0
- package/dist/schema/guid/equals.test.d.ts +1 -0
- package/dist/schema/guid/equals.test.js +30 -0
- package/dist/schema/guid/equals.test.js.map +1 -0
- package/dist/schema/guid/from-uuid.d.ts +2 -0
- package/dist/schema/guid/from-uuid.js +15 -0
- package/dist/schema/guid/from-uuid.js.map +1 -0
- package/dist/schema/guid/from-uuid.test.d.ts +1 -0
- package/dist/schema/guid/from-uuid.test.js +39 -0
- package/dist/schema/guid/from-uuid.test.js.map +1 -0
- package/dist/schema/guid/guid.performance.test.d.ts +1 -0
- package/dist/schema/guid/guid.performance.test.js +297 -0
- package/dist/schema/guid/guid.performance.test.js.map +1 -0
- package/dist/schema/guid/index.d.ts +4 -0
- package/dist/schema/guid/index.js +3 -0
- package/dist/schema/guid/index.js.map +1 -0
- package/dist/schema/guid/layout.d.ts +1 -0
- package/dist/schema/guid/layout.js +5 -0
- package/dist/schema/guid/layout.js.map +1 -0
- package/dist/schema/guid/nil.d.ts +2 -0
- package/dist/schema/guid/nil.js +3 -0
- package/dist/schema/guid/nil.js.map +1 -0
- package/dist/schema/guid/public.d.ts +8 -0
- package/dist/schema/guid/public.js +10 -0
- package/dist/schema/guid/public.js.map +1 -0
- package/dist/schema/guid/schema.d.ts +12 -0
- package/dist/schema/guid/schema.js +10 -0
- package/dist/schema/guid/schema.js.map +1 -0
- package/dist/schema/guid/schema.test.d.ts +1 -0
- package/dist/schema/guid/schema.test.js +35 -0
- package/dist/schema/guid/schema.test.js.map +1 -0
- package/dist/schema/guid/to-unserializable-key.d.ts +2 -0
- package/dist/schema/guid/to-unserializable-key.js +10 -0
- package/dist/schema/guid/to-unserializable-key.js.map +1 -0
- package/dist/schema/guid/to-uuid.d.ts +2 -0
- package/dist/schema/guid/to-uuid.js +15 -0
- package/dist/schema/guid/to-uuid.js.map +1 -0
- package/dist/schema/guid/to-uuid.test.d.ts +1 -0
- package/dist/schema/guid/to-uuid.test.js +31 -0
- package/dist/schema/guid/to-uuid.test.js.map +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +2 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/table/select-rows.d.ts +7 -4
- package/dist/table/select-rows.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/references/data-lit/package.json +1 -1
- package/references/data-lit-tictactoe/package.json +1 -1
- package/references/data-react/package.json +1 -1
- package/references/data-react-hello/package.json +1 -1
- package/references/data-react-pixie/package.json +1 -1
|
@@ -18,10 +18,12 @@ export type CombinePlugins<Plugins extends readonly Database.Plugin[]> = Databas
|
|
|
18
18
|
[K in keyof Plugins]: Plugins[K]['services'];
|
|
19
19
|
}>, {} & IntersectAll<{
|
|
20
20
|
[K in keyof Plugins]: Plugins[K]['computed'];
|
|
21
|
+
}>, {} & IntersectAll<{
|
|
22
|
+
[K in keyof Plugins]: Plugins[K]['indexes'];
|
|
21
23
|
}>>;
|
|
22
24
|
/**
|
|
23
25
|
* Combines multiple plugins into a single plugin.
|
|
24
|
-
* All plugin properties (components, resources, archetypes, computed, transactions, systems, actions, services)
|
|
26
|
+
* All plugin properties (components, resources, archetypes, indexes, computed, transactions, systems, actions, services)
|
|
25
27
|
* require identity (===) when the same key exists across plugins.
|
|
26
28
|
*
|
|
27
29
|
* IMPORTANT: Services are merged in order, preserving the initialization order
|
|
@@ -43,5 +45,7 @@ export declare function combinePlugins<const Plugins extends readonly Database.P
|
|
|
43
45
|
[K in keyof Plugins]: Plugins[K]['services'];
|
|
44
46
|
}>, {} & IntersectAll<{
|
|
45
47
|
[K in keyof Plugins]: Plugins[K]['computed'];
|
|
48
|
+
}>, {} & IntersectAll<{
|
|
49
|
+
[K in keyof Plugins]: Plugins[K]['indexes'];
|
|
46
50
|
}>>;
|
|
47
51
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
2
|
/**
|
|
3
3
|
* Combines multiple plugins into a single plugin.
|
|
4
|
-
* All plugin properties (components, resources, archetypes, computed, transactions, systems, actions, services)
|
|
4
|
+
* All plugin properties (components, resources, archetypes, indexes, computed, transactions, systems, actions, services)
|
|
5
5
|
* require identity (===) when the same key exists across plugins.
|
|
6
6
|
*
|
|
7
7
|
* IMPORTANT: Services are merged in order, preserving the initialization order
|
|
8
8
|
* so that extended plugin services are initialized before current plugin services.
|
|
9
9
|
*/
|
|
10
10
|
export function combinePlugins(...plugins) {
|
|
11
|
-
const keys = ['services', 'components', 'resources', 'archetypes', 'computed', 'transactions', 'actions', 'systems'];
|
|
11
|
+
const keys = ['services', 'components', 'resources', 'archetypes', 'indexes', 'computed', 'transactions', 'actions', 'systems'];
|
|
12
12
|
const merge = (base, next) => Object.fromEntries(keys.map(key => {
|
|
13
13
|
const baseObj = base[key] ?? {};
|
|
14
14
|
const nextObj = next[key] ?? {};
|
|
@@ -22,7 +22,7 @@ export function combinePlugins(...plugins) {
|
|
|
22
22
|
}
|
|
23
23
|
return [key, merged];
|
|
24
24
|
}));
|
|
25
|
-
const emptyPlugin = { components: {}, resources: {}, archetypes: {}, computed: {}, transactions: {}, actions: {}, systems: {}, services: {} };
|
|
25
|
+
const emptyPlugin = { components: {}, resources: {}, archetypes: {}, indexes: {}, computed: {}, transactions: {}, actions: {}, systems: {}, services: {} };
|
|
26
26
|
// Merge all plugins together
|
|
27
27
|
const result = plugins.reduce(merge, emptyPlugin);
|
|
28
28
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combine-plugins.js","sourceRoot":"","sources":["../../../src/ecs/database/combine-plugins.ts"],"names":[],"mappings":"AAAA,uDAAuD;
|
|
1
|
+
{"version":3,"file":"combine-plugins.js","sourceRoot":"","sources":["../../../src/ecs/database/combine-plugins.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAiCvD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAE5B,GAAG,OAAgB;IAWnB,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;IAEzI,MAAM,KAAK,GAAG,CAAC,IAAS,EAAE,IAAS,EAAE,EAAE,CACrC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAEhC,wCAAwC;QACxC,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;QAC9B,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC,IAAI,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CACb,4BAA4B,GAAG,IAAI,CAAC,yCAAyC,CAC9E,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC,CAAC;IAEN,MAAM,WAAW,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAE3J,6BAA6B;IAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAElD,OAAO,MAAiC,CAAC;AAC3C,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Database, SystemFunction, ServiceFactories, FromServiceFactories, FromComputedFactories, type PluginComputedFactories } from "./database.js";
|
|
1
|
+
import { Database, SystemFunction, ServiceFactories, FromServiceFactories, FromComputedFactories, type PluginComputedFactories, type IndexDeclarations } from "./database.js";
|
|
2
2
|
import type { ComponentSchemas } from "../component-schemas.js";
|
|
3
3
|
import type { ResourceSchemas } from "../resource-schemas.js";
|
|
4
4
|
import type { ArchetypeComponents } from "../store/archetype-components.js";
|
|
@@ -14,7 +14,7 @@ import { Store } from "../store/store.js";
|
|
|
14
14
|
* inference (`CombinePlugins<[XP, ...]>`) to avoid expensive 8-way type
|
|
15
15
|
* expansion that amplifies TS7056 serialization overflow.
|
|
16
16
|
*/
|
|
17
|
-
type CreatePluginResult<XP extends Database.Plugin, CS, RS, A, TD, S extends string, AD, SVF, CVF> = Database.Plugin<XP['components'] & CS, XP['resources'] & RS, XP['archetypes'] & A, XP['transactions'] & TD, S | StringKeyof<XP['systems']>, XP['actions'] & AD, XP['services'] & SVF, XP['computed'] & CVF>;
|
|
17
|
+
type CreatePluginResult<XP extends Database.Plugin, CS, RS, A, TD, S extends string, AD, SVF, CVF, IX> = Database.Plugin<XP['components'] & CS, XP['resources'] & RS, XP['archetypes'] & A, XP['transactions'] & TD, S | StringKeyof<XP['systems']>, XP['actions'] & AD, XP['services'] & SVF, XP['computed'] & CVF, XP['indexes'] & IX>;
|
|
18
18
|
/**
|
|
19
19
|
* Creates a Database.Plugin from a plugin descriptor.
|
|
20
20
|
*
|
|
@@ -26,10 +26,11 @@ type CreatePluginResult<XP extends Database.Plugin, CS, RS, A, TD, S extends str
|
|
|
26
26
|
* 3. components (optional) - Component schema definitions
|
|
27
27
|
* 4. resources (optional) - Resource schema definitions
|
|
28
28
|
* 5. archetypes (optional) - Archetype definitions
|
|
29
|
-
* 6.
|
|
30
|
-
* 7.
|
|
31
|
-
* 8.
|
|
32
|
-
* 9.
|
|
29
|
+
* 6. indexes (optional) - Index declarations over components
|
|
30
|
+
* 7. computed (optional) - Computed observe factories (each returns Observe<unknown>)
|
|
31
|
+
* 8. transactions (optional) - Transaction declarations
|
|
32
|
+
* 9. actions (optional) - Action declarations
|
|
33
|
+
* 10. systems (optional) - System declarations
|
|
33
34
|
*
|
|
34
35
|
* Example:
|
|
35
36
|
* ```ts
|
|
@@ -41,10 +42,11 @@ type CreatePluginResult<XP extends Database.Plugin, CS, RS, A, TD, S extends str
|
|
|
41
42
|
* components: { ... }, // 3. components
|
|
42
43
|
* resources: { ... }, // 4. resources
|
|
43
44
|
* archetypes: { ... }, // 5. archetypes
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* indexes: { ... }, // 6. indexes
|
|
46
|
+
* computed: { ... }, // 7. computed
|
|
47
|
+
* transactions: { ... }, // 8. transactions
|
|
48
|
+
* actions: { ... }, // 9. actions
|
|
49
|
+
* systems: { ... }, // 10. systems
|
|
48
50
|
* })
|
|
49
51
|
* ```
|
|
50
52
|
*
|
|
@@ -60,7 +62,7 @@ type CreatePluginResult<XP extends Database.Plugin, CS, RS, A, TD, S extends str
|
|
|
60
62
|
* @throws Error if properties are not in the correct order
|
|
61
63
|
*/
|
|
62
64
|
type FullDBForPlugin<CS, RS, A, TD, S extends string, AD, XP extends Database.Plugin, SVF extends ServiceFactories<Database.FromPlugin<XP>>> = Database<FromSchemas<CS & XP['components']>, FromSchemas<RS & XP['resources']>, A & XP['archetypes'], ToTransactionFunctions<TD & XP['transactions']>, S | StringKeyof<XP['systems']>, ToActionFunctions<AD & XP['actions']>, FromServiceFactories<RemoveIndex<SVF> & XP['services']>>;
|
|
63
|
-
export declare function createPlugin<const XP extends Database.Plugin<{}, {}, {}, {}, never, {}, {}, {}>, const CS extends ComponentSchemas, const RS extends ResourceSchemas, const A extends ArchetypeComponents<StringKeyof<RemoveIndex<CS> & XP['components']>>, const TD extends TransactionDeclarations<FromSchemas<RemoveIndex<CS> & XP['components']>, FromSchemas<RemoveIndex<RS> & XP['resources']>, RemoveIndex<A> & XP['archetypes']>, const AD, const S extends string = never, const SVF extends ServiceFactories<Database.FromPlugin<XP>> = {}, const CVF extends PluginComputedFactories<FullDBForPlugin<RemoveIndex<CS>, RemoveIndex<RS>, RemoveIndex<A>, RemoveIndex<TD>, S, RemoveIndex<AD> & XP['actions'], XP, RemoveIndex<SVF>>> = {}>(plugins: {
|
|
65
|
+
export declare function createPlugin<const XP extends Database.Plugin<{}, {}, {}, {}, never, {}, {}, {}, {}>, const CS extends ComponentSchemas, const RS extends ResourceSchemas, const A extends ArchetypeComponents<StringKeyof<RemoveIndex<CS> & XP['components']>>, const IX extends IndexDeclarations<FromSchemas<RemoveIndex<CS> & XP['components']>>, const TD extends TransactionDeclarations<FromSchemas<RemoveIndex<CS> & XP['components']>, FromSchemas<RemoveIndex<RS> & XP['resources']>, RemoveIndex<A> & XP['archetypes'], RemoveIndex<IX> & XP['indexes']>, const AD, const S extends string = never, const SVF extends ServiceFactories<Database.FromPlugin<XP>> = {}, const CVF extends PluginComputedFactories<FullDBForPlugin<RemoveIndex<CS>, RemoveIndex<RS>, RemoveIndex<A>, RemoveIndex<TD>, S, RemoveIndex<AD> & XP['actions'], XP, RemoveIndex<SVF>>> = {}>(plugins: {
|
|
64
66
|
extends?: XP;
|
|
65
67
|
services?: SVF & {
|
|
66
68
|
readonly [K: string]: (db: Database.FromPlugin<XP>) => unknown;
|
|
@@ -68,14 +70,15 @@ export declare function createPlugin<const XP extends Database.Plugin<{}, {}, {}
|
|
|
68
70
|
components?: CS;
|
|
69
71
|
resources?: RS;
|
|
70
72
|
archetypes?: A;
|
|
73
|
+
indexes?: IX;
|
|
71
74
|
computed?: CVF & PluginComputedFactories<FullDBForPlugin<RemoveIndex<CS>, RemoveIndex<RS>, RemoveIndex<A>, {}, string, RemoveIndex<AD> & XP['actions'], XP, RemoveIndex<SVF>>>;
|
|
72
75
|
transactions?: TD;
|
|
73
76
|
actions?: AD & {
|
|
74
|
-
readonly [K: string]: (db: Database<FromSchemas<RemoveIndex<CS> & XP['components']>, FromSchemas<RemoveIndex<RS> & XP['resources']>, RemoveIndex<A> & XP['archetypes'], ToTransactionFunctions<RemoveIndex<TD> & XP['transactions']>, S | StringKeyof<XP['systems']>, ToActionFunctions<XP['actions']>, FromServiceFactories<RemoveIndex<SVF> & XP['services']>, FromComputedFactories<RemoveIndex<CVF> & XP['computed']
|
|
77
|
+
readonly [K: string]: (db: Database<FromSchemas<RemoveIndex<CS> & XP['components']>, FromSchemas<RemoveIndex<RS> & XP['resources']>, RemoveIndex<A> & XP['archetypes'], ToTransactionFunctions<RemoveIndex<TD> & XP['transactions']>, S | StringKeyof<XP['systems']>, ToActionFunctions<XP['actions']>, FromServiceFactories<RemoveIndex<SVF> & XP['services']>, FromComputedFactories<RemoveIndex<CVF> & XP['computed']>, RemoveIndex<IX> & XP['indexes']>, input?: any) => any;
|
|
75
78
|
};
|
|
76
79
|
systems?: {
|
|
77
80
|
readonly [K in S]: {
|
|
78
|
-
readonly create: (db: Database<FromSchemas<RemoveIndex<CS> & XP['components']>, FromSchemas<RemoveIndex<RS> & XP['resources']>, RemoveIndex<A> & XP['archetypes'], ToTransactionFunctions<RemoveIndex<TD> & XP['transactions']>, S | StringKeyof<XP['systems']>, ToActionFunctions<RemoveIndex<AD> & XP['actions']>, FromServiceFactories<RemoveIndex<SVF> & XP['services']>, FromComputedFactories<RemoveIndex<CVF> & XP['computed']
|
|
81
|
+
readonly create: (db: Database<FromSchemas<RemoveIndex<CS> & XP['components']>, FromSchemas<RemoveIndex<RS> & XP['resources']>, RemoveIndex<A> & XP['archetypes'], ToTransactionFunctions<RemoveIndex<TD> & XP['transactions']>, S | StringKeyof<XP['systems']>, ToActionFunctions<RemoveIndex<AD> & XP['actions']>, FromServiceFactories<RemoveIndex<SVF> & XP['services']>, FromComputedFactories<RemoveIndex<CVF> & XP['computed']>, RemoveIndex<IX> & XP['indexes']> & {
|
|
79
82
|
readonly store: Store<FromSchemas<RemoveIndex<CS> & XP['components']>, FromSchemas<RemoveIndex<RS> & XP['resources']>, RemoveIndex<A> & XP['archetypes']>;
|
|
80
83
|
services: {
|
|
81
84
|
-readonly [K in keyof FromServiceFactories<RemoveIndex<SVF> & XP['services']>]: FromServiceFactories<RemoveIndex<SVF> & XP['services']>[K];
|
|
@@ -88,5 +91,5 @@ export declare function createPlugin<const XP extends Database.Plugin<{}, {}, {}
|
|
|
88
91
|
};
|
|
89
92
|
};
|
|
90
93
|
};
|
|
91
|
-
}): CreatePluginResult<XP, RemoveIndex<CS>, RemoveIndex<RS>, RemoveIndex<A>, RemoveIndex<TD>, S, AD, RemoveIndex<SVF>, RemoveIndex<CVF>>;
|
|
94
|
+
}): CreatePluginResult<XP, RemoveIndex<CS>, RemoveIndex<RS>, RemoveIndex<A>, RemoveIndex<TD>, S, AD, RemoveIndex<SVF>, RemoveIndex<CVF>, RemoveIndex<IX>>;
|
|
92
95
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
2
|
import { combinePlugins } from "./combine-plugins.js";
|
|
3
3
|
function validatePropertyOrder(plugins) {
|
|
4
|
-
const expectedOrder = ['extends', 'services', 'components', 'resources', 'archetypes', 'computed', 'transactions', 'actions', 'systems'];
|
|
4
|
+
const expectedOrder = ['extends', 'services', 'components', 'resources', 'archetypes', 'indexes', 'computed', 'transactions', 'actions', 'systems'];
|
|
5
5
|
const actualKeys = Object.keys(plugins);
|
|
6
6
|
const definedKeys = actualKeys.filter(key => key in plugins);
|
|
7
7
|
for (let i = 0; i < definedKeys.length; i++) {
|
|
@@ -29,6 +29,7 @@ export function createPlugin(plugins) {
|
|
|
29
29
|
components: plugins.components ?? {},
|
|
30
30
|
resources: plugins.resources ?? {},
|
|
31
31
|
archetypes: plugins.archetypes ?? {},
|
|
32
|
+
indexes: plugins.indexes ?? {},
|
|
32
33
|
computed: plugins.computed ?? {},
|
|
33
34
|
transactions: plugins.transactions ?? {},
|
|
34
35
|
actions: plugins.actions ?? {},
|
|
@@ -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;
|
|
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,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACpJ,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,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,6CAA6C,GAAG,4BAA4B,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5H,CAAC;QACD,uDAAuD;QACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,iBAAiB,GAAG,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACzD,IAAI,iBAAiB,GAAG,aAAa,EAAE,CAAC;gBACpC,MAAM,IAAI,KAAK,CACX,qCAAqC,GAAG,uBAAuB,OAAO,KAAK;oBAC3E,mBAAmB,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrF,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC;AA6DD,MAAM,UAAU,YAAY,CAYxB,OAkDC;IAED,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAE/B,mEAAmE;IACnE,MAAM,MAAM,GAAQ;QAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;QAClC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;QAC9B,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,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAQ,CAAC;IAC1D,CAAC;IACD,OAAO,MAAa,CAAC;AACzB,CAAC"}
|
|
@@ -11,6 +11,7 @@ import { Components } from "../store/components.js";
|
|
|
11
11
|
import { ArchetypeComponents } from "../store/archetype-components.js";
|
|
12
12
|
import { RequiredComponents } from "../required-components.js";
|
|
13
13
|
import { EntitySelectOptions } from "../store/entity-select-options.js";
|
|
14
|
+
import { Index as StoreIndex } from "../store/index-types.js";
|
|
14
15
|
import type { Service } from "../../service/index.js";
|
|
15
16
|
import { createDatabase, type DatabaseSyncOptions } from "./public/create-database.js";
|
|
16
17
|
import { ResourceSchemas } from "../resource-schemas.js";
|
|
@@ -78,11 +79,33 @@ export type PluginComputedValue = Observe<unknown> | ((...args: any[]) => Observ
|
|
|
78
79
|
export type PluginComputedFactories<DB = any> = {
|
|
79
80
|
readonly [K: string]: (db: DB) => PluginComputedValue;
|
|
80
81
|
};
|
|
81
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Plugin-level map of indexes. Re-exported from `store/index-types.ts`
|
|
84
|
+
* where the canonical definition lives — same module that defines the
|
|
85
|
+
* unified `Index` type (raw + computed) so a single source of truth is
|
|
86
|
+
* shared between the Store layer (`store.indexes` typed handle map) and
|
|
87
|
+
* the Database layer (`db.indexes`, plugin descriptor constraint).
|
|
88
|
+
*/
|
|
89
|
+
export type { IndexDeclarations } from "../store/index-types.js";
|
|
90
|
+
import type { IndexDeclarations } from "../store/index-types.js";
|
|
91
|
+
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 {
|
|
82
92
|
readonly transactions: F & Service;
|
|
83
93
|
readonly actions: AF & Service;
|
|
84
94
|
readonly services: SV;
|
|
85
95
|
readonly computed: CV;
|
|
96
|
+
/**
|
|
97
|
+
* Lookup handles for the indexes declared by plugins on this database.
|
|
98
|
+
* Each key in `IX` becomes a `Database.Index.Handle` whose method shape
|
|
99
|
+
* is narrowed by the declared key tuple and unique flag.
|
|
100
|
+
*
|
|
101
|
+
* The handles are also the implementation path used by `db.select` /
|
|
102
|
+
* `db.observe.select` when a `where` / `order` matches a declared
|
|
103
|
+
* index — call sites do not need to be aware of which index served
|
|
104
|
+
* the query, but the same handle is what runs underneath.
|
|
105
|
+
*/
|
|
106
|
+
readonly indexes: {
|
|
107
|
+
readonly [K in keyof IX]: Database.Index.Handle<C, IX[K]>;
|
|
108
|
+
};
|
|
86
109
|
readonly observe: {
|
|
87
110
|
readonly components: {
|
|
88
111
|
readonly [K in StringKeyof<C>]: Observe<void>;
|
|
@@ -154,7 +177,7 @@ export interface Database<C extends Components = {}, R extends ResourceComponent
|
|
|
154
177
|
};
|
|
155
178
|
toData(): unknown;
|
|
156
179
|
fromData(data: unknown): void;
|
|
157
|
-
extend<P extends Database.Plugin>(plugin: P): Database<C & FromSchemas<RemoveIndex<P['components']>>, R & FromSchemas<RemoveIndex<P['resources']>>, A & RemoveIndex<P['archetypes']>, F & ToTransactionFunctions<RemoveIndex<P['transactions']>>, S | StringKeyof<P['systems']>, AF & ToActionFunctions<RemoveIndex<P['actions']>>, SV & FromServiceFactories<RemoveIndex<P['services']>>, CV & FromComputedFactories<RemoveIndex<P['computed']
|
|
180
|
+
extend<P extends Database.Plugin>(plugin: P): Database<C & FromSchemas<RemoveIndex<P['components']>>, R & FromSchemas<RemoveIndex<P['resources']>>, A & RemoveIndex<P['archetypes']>, F & ToTransactionFunctions<RemoveIndex<P['transactions']>>, S | StringKeyof<P['systems']>, AF & ToActionFunctions<RemoveIndex<P['actions']>>, SV & FromServiceFactories<RemoveIndex<P['services']>>, CV & FromComputedFactories<RemoveIndex<P['computed']>>, IX & RemoveIndex<P['indexes']>>;
|
|
158
181
|
}
|
|
159
182
|
export declare namespace Database {
|
|
160
183
|
/**
|
|
@@ -163,11 +186,15 @@ export declare namespace Database {
|
|
|
163
186
|
* (P extends Plugin<infer CS, ...> ? CS : never) to avoid expensive 8-way type
|
|
164
187
|
* expansion that amplifies TS7056 serialization overflow in deep extends chains.
|
|
165
188
|
*/
|
|
166
|
-
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']
|
|
189
|
+
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']>>;
|
|
167
190
|
const create: typeof createDatabase;
|
|
168
191
|
const is: (value: unknown) => value is Database;
|
|
169
192
|
const observeSelectDeep: <C extends Components, Include extends StringKeyof<C>>(db: Database<C, any, any, any, any, any, any, any>, include: readonly Include[] | ReadonlySet<Include | "id">, options?: EntitySelectOptions<C, Pick<C & RequiredComponents, Include>>) => Observe<readonly (RequiredComponents & { readonly [K in Include]: C[K]; })[]>;
|
|
170
|
-
type
|
|
193
|
+
type Index<C extends Components = any> = StoreIndex<C, any, any, any>;
|
|
194
|
+
namespace Index {
|
|
195
|
+
type Handle<C extends Components, I extends StoreIndex<C, any, any, any>> = StoreIndex.Handle<C, I>;
|
|
196
|
+
}
|
|
197
|
+
type Plugin<CS extends ComponentSchemas = any, RS extends ResourceSchemas = any, A extends ArchetypeComponents<StringKeyof<CS>> = any, TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, any> = any, S extends string = any, AD extends ActionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, S> = any, SVF extends ServiceFactories = any, CVF extends ComputedFactories = any, IX extends IndexDeclarations<FromSchemas<CS>> = any> = {
|
|
171
198
|
readonly components: CS;
|
|
172
199
|
readonly resources: RS;
|
|
173
200
|
readonly archetypes: A;
|
|
@@ -176,6 +203,7 @@ export declare namespace Database {
|
|
|
176
203
|
readonly actions: AD;
|
|
177
204
|
readonly services: SVF;
|
|
178
205
|
readonly computed: CVF;
|
|
206
|
+
readonly indexes: IX;
|
|
179
207
|
};
|
|
180
208
|
namespace Plugin {
|
|
181
209
|
const create: typeof createPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|