diff --git a/package.json b/package.json index 1e604b8..c42b2df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "data-monorepo", - "version": "0.9.65", + "version": "0.9.66", "private": true, "scripts": { "build": "pnpm -r run build", diff --git a/packages/data-lit-tictactoe/package.json b/packages/data-lit-tictactoe/package.json index c36aae6..0cc9a89 100644 --- a/packages/data-lit-tictactoe/package.json +++ b/packages/data-lit-tictactoe/package.json @@ -1,6 +1,6 @@ { "name": "data-lit-tictactoe", - "version": "0.9.65", + "version": "0.9.66", "description": "Tic-Tac-Toe sample - Lit web components with @adobe/data-lit and AgenticService", "type": "module", "private": true, diff --git a/packages/data-lit-todo/package.json b/packages/data-lit-todo/package.json index 08fecab..5c07efa 100644 --- a/packages/data-lit-todo/package.json +++ b/packages/data-lit-todo/package.json @@ -1,6 +1,6 @@ { "name": "data-lit-todo", - "version": "0.9.65", + "version": "0.9.66", "description": "Todo sample app demonstrating @adobe/data with Lit", "type": "module", "private": true, diff --git a/packages/data-lit/package.json b/packages/data-lit/package.json index 2f4271d..74a49d6 100644 --- a/packages/data-lit/package.json +++ b/packages/data-lit/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/data-lit", - "version": "0.9.65", + "version": "0.9.66", "description": "Adobe data Lit bindings - hooks, elements, decorators", "type": "module", "private": false, diff --git a/packages/data-p2p-tictactoe/package.json b/packages/data-p2p-tictactoe/package.json index a29b85c..d24e23c 100644 --- a/packages/data-p2p-tictactoe/package.json +++ b/packages/data-p2p-tictactoe/package.json @@ -1,6 +1,6 @@ { "name": "data-p2p-tictactoe", - "version": "0.9.65", + "version": "0.9.66", "description": "Serverless P2P tic-tac-toe — WebRTC DataChannel + @adobe/data-sync", "type": "module", "private": true, diff --git a/packages/data-persistence/package.json b/packages/data-persistence/package.json index 689bc70..c19d47b 100644 --- a/packages/data-persistence/package.json +++ b/packages/data-persistence/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/data-persistence", - "version": "0.9.65", + "version": "0.9.66", "description": "Worker-based incremental persistence layer for @adobe/data ECS over OPFS (browser) and node:fs (server).", "type": "module", "sideEffects": false, diff --git a/packages/data-react-hello/package.json b/packages/data-react-hello/package.json index 55248eb..f8e9b28 100644 --- a/packages/data-react-hello/package.json +++ b/packages/data-react-hello/package.json @@ -1,6 +1,6 @@ { "name": "data-react-hello", - "version": "0.9.65", + "version": "0.9.66", "description": "Hello World sample - click counter using @adobe/data-react", "type": "module", "private": true, diff --git a/packages/data-react-pixie/package.json b/packages/data-react-pixie/package.json index 12308c1..7da9c97 100644 --- a/packages/data-react-pixie/package.json +++ b/packages/data-react-pixie/package.json @@ -1,6 +1,6 @@ { "name": "data-react-pixie", - "version": "0.9.65", + "version": "0.9.66", "description": "PixiJS React sample - ECS sprites (bunny, fox) with @adobe/data-react", "type": "module", "private": true, diff --git a/packages/data-react/package.json b/packages/data-react/package.json index fbf1b6a..87f1301 100644 --- a/packages/data-react/package.json +++ b/packages/data-react/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/data-react", - "version": "0.9.65", + "version": "0.9.66", "description": "Adobe data React bindings — hooks and context for ECS database", "type": "module", "private": false, diff --git a/packages/data-solid-dashboard/package.json b/packages/data-solid-dashboard/package.json index 1bd17b6..81e48f5 100644 --- a/packages/data-solid-dashboard/package.json +++ b/packages/data-solid-dashboard/package.json @@ -1,6 +1,6 @@ { "name": "data-solid-dashboard", - "version": "0.9.65", + "version": "0.9.66", "description": "Mini dashboard sample — multiple components sharing one @adobe/data ECS database with SolidJS", "type": "module", "private": true, diff --git a/packages/data-solid/package.json b/packages/data-solid/package.json index 19de146..d93be7a 100644 --- a/packages/data-solid/package.json +++ b/packages/data-solid/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/data-solid", - "version": "0.9.65", + "version": "0.9.66", "description": "Adobe data SolidJS bindings — context and provider for ECS database", "type": "module", "private": false, diff --git a/packages/data-sync/package.json b/packages/data-sync/package.json index 9f0c8df..98dc950 100644 --- a/packages/data-sync/package.json +++ b/packages/data-sync/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/data-sync", - "version": "0.9.65", + "version": "0.9.66", "description": "Multi-user real-time synchronisation for @adobe/data ECS — server, client, and in-process loopback.", "type": "module", "sideEffects": false, diff --git a/packages/data/package.json b/packages/data/package.json index b186331..a2c4fd4 100644 --- a/packages/data/package.json +++ b/packages/data/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/data", - "version": "0.9.65", + "version": "0.9.66", "description": "Adobe data oriented programming library", "type": "module", "sideEffects": false, diff --git a/packages/data/src/ecs/database/create-plugin.ts b/packages/data/src/ecs/database/create-plugin.ts index faf33a6..1b2afd2 100644 --- a/packages/data/src/ecs/database/create-plugin.ts +++ b/packages/data/src/ecs/database/create-plugin.ts @@ -126,7 +126,8 @@ function validatePropertyOrder(plugins: Record): void { */ type FullDBForPlugin< CS, RS, A, TD, S extends string, AD, XP extends Database.Plugin, - SVF extends ServiceFactories> + SVF extends ServiceFactories>, + IX = {} > = Database< FromSchemas, FromSchemas, @@ -134,7 +135,17 @@ type FullDBForPlugin< ToTransactionFunctions, S | StringKeyof, ToActionFunctions, - FromServiceFactories & XP['services']> + FromServiceFactories & XP['services']>, + // 8: CV — placeholder. Kept `unknown` (Database's own default for this slot) + // so a concrete computed-values type never constrains computed-factory + // inference / breaks contravariance. Must be supplied explicitly because + // slot 9 (IX) sits after it. + unknown, + // 9: IX — thread the index declarations so `db.indexes` is populated inside + // computed factories, same as the actions/systems `db` already does. + // XP is AmbientPlugin at the call sites, so XP['indexes'] carries + // both extends-base and imports-dep indexes; `IX` adds the plugin's own. + IX & XP['indexes'] >; /** @@ -177,7 +188,7 @@ export function createPlugin< const AD, const S extends string = never, const SVF extends ServiceFactories>> = {}, - const CVF extends PluginComputedFactories, RemoveIndex, RemoveIndex, RemoveIndex, S, RemoveIndex & XP['actions'] & IP['actions'], AmbientPlugin, RemoveIndex>> = {}, + const CVF extends PluginComputedFactories, RemoveIndex, RemoveIndex, RemoveIndex, S, RemoveIndex & XP['actions'] & IP['actions'], AmbientPlugin, RemoveIndex, RemoveIndex>> = {}, >( plugins: { imports?: IP, @@ -189,7 +200,7 @@ export function createPlugin< resources?: RS, archetypes?: A, indexes?: IX, - computed?: CVF & PluginComputedFactories, RemoveIndex, RemoveIndex, {}, string, RemoveIndex & XP['actions'] & IP['actions'], AmbientPlugin, RemoveIndex>>, + computed?: CVF & PluginComputedFactories, RemoveIndex, RemoveIndex, {}, string, RemoveIndex & XP['actions'] & IP['actions'], AmbientPlugin, RemoveIndex, RemoveIndex>>, transactions?: TD, actions?: AD & { readonly [K: string]: (db: Database< diff --git a/packages/data/src/ecs/database/database.index.type-test.ts b/packages/data/src/ecs/database/database.index.type-test.ts index 6be9d01..ef988d9 100644 --- a/packages/data/src/ecs/database/database.index.type-test.ts +++ b/packages/data/src/ecs/database/database.index.type-test.ts @@ -401,3 +401,53 @@ function invalidUniqueGetWrongType() { db.indexes.uniqueByEmail.get({ email: "x@y.z" }); }; } + +// ============================================================================ +// VALID — computed factories see db.indexes +// +// Regression guard: FullDBForPlugin used to forward only Database slots 1–7, +// so the IX slot (9) fell back to its `{}` default and `db.indexes` was empty +// inside computed factories. The declarations below would not compile if that +// regressed — `db.indexes.` would be an error. +// ============================================================================ + +function computedSeesOwnIndexes() { + createPlugin({ + components: { + email: { type: "string" }, + name: { type: "string" }, + }, + indexes: { + byName: { key: "name" }, + }, + computed: { + probe: (db) => { + type Handle = typeof db.indexes.byName; + type _FindArg = Assert[0], { readonly name: string }>>; + return Observe.fromConstant(db.indexes.byName.find({ name: "x" }).length); + }, + }, + }); +} + +function computedSeesImportedAndExtendedIndexes() { + const base = createPlugin({ + components: { email: { type: "string" } }, + indexes: { uniqueByEmail: { key: "email", unique: true } }, + }); + const dep = createPlugin({ + components: { name: { type: "string" } }, + indexes: { byName: { key: "name" } }, + }); + + createPlugin({ + extends: base, + imports: dep, + computed: { + // Index from `extends` base... + fromExtends: (db) => Observe.fromConstant(db.indexes.uniqueByEmail.get({ email: "x@y.z" })), + // ...and index from `imports` dependency. + fromImports: (db) => Observe.fromConstant(db.indexes.byName.find({ name: "x" }).length), + }, + }); +}