Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-monorepo",
"version": "0.10.7",
"version": "0.10.8",
"private": true,
"engines": {
"node": ">=24"
Expand Down
2 changes: 1 addition & 1 deletion packages/data-ai/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adobe-data-ai",
"version": "0.10.7",
"version": "0.10.8",
"description": "Architecture skills for @adobe/data — data-oriented modelling, archetype iteration, hot-path performance, and related conventions.",
"author": {
"name": "Adobe"
Expand Down
2 changes: 1 addition & 1 deletion packages/data-ai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/data-ai",
"version": "0.10.7",
"version": "0.10.8",
"description": "Cross-agent architecture skills for @adobe/data — installable as a Claude Code plugin or copied into any Agent-Skills-compatible agent (Cursor, Codex).",
"type": "module",
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/data-gpu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/data-gpu",
"version": "0.10.7",
"version": "0.10.8",
"description": "Adobe data WebGPU plugins and types for graphics and compute",
"type": "module",
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/data-lit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/data-lit",
"version": "0.10.7",
"version": "0.10.8",
"description": "Adobe data Lit bindings - hooks, elements, decorators",
"type": "module",
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/data-persistence/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/data-persistence",
"version": "0.10.7",
"version": "0.10.8",
"description": "Worker-based incremental persistence layer for @adobe/data ECS over OPFS (browser) and node:fs (server).",
"type": "module",
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/data-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/data-react",
"version": "0.10.7",
"version": "0.10.8",
"description": "Adobe data React bindings — hooks and context for ECS database",
"type": "module",
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/data-solid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/data-solid",
"version": "0.10.7",
"version": "0.10.8",
"description": "Adobe data SolidJS bindings — context and provider for ECS database",
"type": "module",
"private": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/data-sync/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/data-sync",
"version": "0.10.7",
"version": "0.10.8",
"description": "Multi-user real-time synchronisation for @adobe/data ECS — server, client, and in-process loopback.",
"type": "module",
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/data-testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/data-testing",
"version": "0.10.7",
"version": "0.10.8",
"description": "Conformance-testing utilities (Match + Conformance runners) for @adobe/data ECS features",
"type": "module",
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/data",
"version": "0.10.7",
"version": "0.10.8",
"description": "Adobe data oriented programming library",
"type": "module",
"sideEffects": false,
Expand Down
22 changes: 14 additions & 8 deletions packages/data/src/schema/to-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ type FromSchemaInternal<T, Depth extends number = 5> = T extends { const: infer
? null
: T extends { type: 'blob' }
? Blob
: T extends { type: 'observe' }
? Observe<ToType<ValueSchema<T>, Decrement<Depth>>>
: T extends { type: 'promise' }
? Promise<ToType<ValueSchema<T>, Decrement<Depth>>>
: T extends { type: 'generator' }
? AsyncGenerator<ToType<ValueSchema<T>, Decrement<Depth>>>
: T extends { type: 'function' }
? FromSchemaFunction<T, Decrement<Depth>>
: T extends { type: 'typed-buffer', items: infer Items }
? TypedBuffer<FromSchemaInternal<Items>>
: T extends { type: 'typed-buffer' }
Expand All @@ -46,6 +38,20 @@ type FromSchemaInternal<T, Depth extends number = 5> = T extends { const: infer
: T extends { type?: undefined, default: infer D } ? D
: T extends { type: 'object' } | { properties: any }
? FromSchemaObject<T, Decrement<Depth>>
// Type-constructor schemas are placed AFTER the data branches on purpose: a
// data schema (every ECS component/resource) must NOT pay extra conditional
// depth for these, because `FromSchemas` runs `ToType` per component across a
// whole plugin `combine` chain, and the added depth tips deep chains past TS's
// stack-depth limit (TS2321). Only observe/promise/generator/function schemas —
// which appear in service schemas, never in the Plugin hot path — fall through.
: T extends { type: 'observe' }
? Observe<ToType<ValueSchema<T>, Decrement<Depth>>>
: T extends { type: 'promise' }
? Promise<ToType<ValueSchema<T>, Decrement<Depth>>>
: T extends { type: 'generator' }
? AsyncGenerator<ToType<ValueSchema<T>, Decrement<Depth>>>
: T extends { type: 'function' }
? FromSchemaFunction<T, Decrement<Depth>>
: any
;

Expand Down
23 changes: 23 additions & 0 deletions packages/data/src/service/async-data-service/create-lazy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,29 @@ const validWithPreload = createLazy({
preload: true
});

// ✅ Test 4c: a service that is NOT a valid AsyncDataService (returns non-Data)
// is still accepted — createLazy gates on schema-match alone, not IsValid.
interface NonConformantService extends Service {
fetch: (id: string) => Promise<Response>; // Response ∉ Data → not IsValid
count: Observe<number | undefined>; // undefined-in-Observe → not IsValid
}
// The service genuinely fails IsValid...
// @ts-expect-error - NonConformantService returns non-Data / undefined-in-Observe
type _NonConformantFailsIsValid = Assert<IsValid<NonConformantService>>;
// ...yet createLazy accepts it because the schema correctly describes the members.
const validNonConformant = createLazy({
load: () => Promise.resolve({} as NonConformantService),
schema: {
type: "object",
properties: {
fetch: { type: "function", signature: { parameters: [{}], returns: { type: "promise", value: {} } } },
count: { type: "observe", value: {} }
},
required: ["fetch", "count"],
additionalProperties: false
}
});

// ============================================================================
// ERROR TESTS (These should produce TypeScript errors)
// ============================================================================
Expand Down
20 changes: 17 additions & 3 deletions packages/data/src/service/async-data-service/create-lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Observe } from "../../observe/index.js";
import { Schema } from "../../schema/index.js";
import { Service } from "../service.js";
import { IsValidWithCompleteSchema } from "./is-valid-with-complete-schema.js";
import { EquivalentTypes } from "../../types/types.js";

// ============================================================================
// TYPE INFERENCE HELPERS
Expand Down Expand Up @@ -38,6 +38,16 @@ type LazyServiceSchema = Schema & {
readonly properties?: { readonly [name: string]: LazyMemberSchema };
};

// createLazy's gate: the schema must completely and correctly describe the loaded
// service's members. This is the actual correctness condition for building the
// wrappers, and it is INTENTIONALLY independent of `AsyncDataService.IsValid` —
// createLazy wraps whatever the schema describes, so a service that returns
// non-`Data` (e.g. a `fetch(): Promise<Response>` port) can still be lazily
// chunk-loaded as long as its schema matches. Enforce `IsValid` separately at the
// service's definition site if you also want async-data-service conformance.
type SchemaMatchesService<T extends Service, S extends Schema> =
EquivalentTypes<Schema.ToType<S>, Omit<T, keyof Service>>;

// ============================================================================
// RUNTIME WRAPPER KIND
// ============================================================================
Expand Down Expand Up @@ -87,7 +97,11 @@ function memberKind(member: Schema): WrapKind {
*
* TypeScript enforces that `schema` describes every member of the loaded service
* with the correct wrapper kind; otherwise the `schema` argument fails to type-check
* with a `__createLazyError` marker. Note: member value/parameter schemas authored as `{}`
* with a `__createLazyError` marker. This is the ONLY requirement — createLazy does
* NOT require the service to be a valid `AsyncDataService`, so a service that returns
* non-`Data` (e.g. `Promise<Response>`) can still be lazily loaded. Enforce
* `AsyncDataService.IsValid` separately at the service definition site if you want it.
* Note: member value/parameter schemas authored as `{}`
* resolve to `any`, so presence and wrapper kind are checked but inner payload
* types are only verified where a precise `value`/parameter schema is supplied.
*
Expand Down Expand Up @@ -117,7 +131,7 @@ export function createLazy<
load: LoadFn,
schema: S,
preload?: boolean
} & (IsValidWithCompleteSchema<InferService<LoadFn>, S> extends true
} & (SchemaMatchesService<InferService<LoadFn>, S> extends true
? unknown
// Inline (not a named type) so the mismatch marker isn't a documented symbol.
: { schema: { readonly __createLazyError: "createLazy: schema must completely and correctly describe the loaded service" } })
Expand Down