@pwfabric/runtime 1.0.0-rc.2 → 1.1.0

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/README.md CHANGED
@@ -7,7 +7,7 @@ re-exports `@pwfabric/contracts`.
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- pnpm add @pwfabric/runtime@rc zod@3 react react-dom
10
+ pnpm add @pwfabric/runtime zod@3 react react-dom
11
11
  ```
12
12
 
13
13
  ESM only: import it from an ES module (`"type": "module"` or `.mjs`). Node 22+. Peers: `react` and `react-dom` 18 or 19; `next` 14–16 only if you use the
@@ -218,7 +218,12 @@ export class DataService {
218
218
  async executeFetch(source, options) {
219
219
  switch (source.kind) {
220
220
  case 'static':
221
- return source.staticData;
221
+ // The query is applied to static rows like to fetched ones: a static
222
+ // list declared `sort: name asc` or `filter: featured eq true` is
223
+ // bound sorted and filtered (data-protocol §3).
224
+ return source.query && Array.isArray(source.staticData)
225
+ ? applyEntityQuery(source.staticData, source.query).items
226
+ : source.staticData;
222
227
  case 'state': {
223
228
  const context = {
224
229
  params: options?.params ?? {},
@@ -1 +1 @@
1
- {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/data/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AA0B3D,+DAA+D;AAC/D,eAAe;AACf,+DAA+D;AAE/D;;;;;;;;;;;;GAYG;AACH,SAAS,gBAAgB,CAAC,GAAW,EAAE,iBAAqC;IAC1E,IAAI,CAAC,iBAAiB;QAAE,OAAO,KAAK,CAAA;IACpC,IAAI,CAAC;QACH,wEAAwE;QACxE,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAA;QACtD,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC,MAAM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BACP,wDAAwD;YAC1D,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,+DAA+D;AAC/D,oBAAoB;AACpB,+DAA+D;AAE/D;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA0B;IAC1D,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC","sourcesContent":["/**\n * Data Service (formerly Data Capability Manager)\n *\n * Default implementation of the data service\n *\n * Provides data source registration, resolution, fetch with caching,\n * and live data bindings for surfaces.\n *\n * @module @pwfabric/runtime/data/manager\n */\n\nimport { applyEntityQuery } from '../entity/apply-query.js'\nimport type {\n DataServiceInterface,\n DataServiceConfig,\n DataSourceDefinition,\n DataFetchOptions,\n DataFetchResult,\n DataFetchError,\n DataFetchMetadata,\n DataBinding,\n LiveDataBinding,\n DataBindingState,\n DataBindingListener,\n DataResolveContext,\n} from './types.js'\n\n// ============================================================\n// CACHE ENTRY\n// ============================================================\n\ninterface CacheEntry<T> {\n data: T\n timestamp: number\n ttl: number\n}\n\n// ============================================================\n// DATA SERVICE\n// ============================================================\n\n/**\n * The list, out of whatever the endpoint wrapped it in.\n *\n * `returns` names the property holding the array — `data` for ours,\n * `products` for DummyJSON, absent when the body already IS the array. Three\n * shapes were in circulation and the binding context received whichever one\n * came back, so a block bound to a list could not take all three.\n *\n * A named path that is not there THROWS rather than yielding undefined: a\n * silently empty panel is the failure this field exists to end, and \"the\n * endpoint answered, but not with what the plan said\" is a sentence the user\n * can act on.\n */\nfunction isPlatformOrigin(url: string, platformApiOrigin: string | undefined): boolean {\n if (!platformApiOrigin) return false\n try {\n // A relative endpoint is same-document, which is our own by definition.\n if (!/^[a-z][a-z0-9+.-]*:\\/\\//i.test(url)) return true\n return new URL(url).origin === new URL(platformApiOrigin).origin\n } catch {\n return false\n }\n}\n\n/**\n * What a non-OK response says about itself: `{ error: { code, message } }`\n * when it is our API (or anyone keeping the same envelope), nothing when the\n * body is absent, not JSON, or not that shape. Never throws — a refusal\n * without a readable body is still a refusal with a status.\n */\nasync function readRefusal(response: Response): Promise<{ code?: string; message?: string }> {\n try {\n const body = (await response.json()) as { error?: { code?: unknown; message?: unknown } } | null\n const error = body?.error\n if (!error || typeof error !== 'object') return {}\n return {\n ...(typeof error.code === 'string' ? { code: error.code } : {}),\n ...(typeof error.message === 'string' && error.message ? { message: error.message } : {}),\n }\n } catch {\n return {}\n }\n}\n\nfunction pluck(body: unknown, path: string | undefined): unknown {\n if (!path) return body\n let node: unknown = body\n for (const key of path.split('.')) {\n if (!node || typeof node !== 'object' || Array.isArray(node)) {\n throw new Error(`Response has no '${path}' — nothing at '${key}'`)\n }\n node = (node as Record<string, unknown>)[key]\n }\n if (node === undefined) throw new Error(`Response has no '${path}'`)\n return node\n}\n\n/**\n * What `returns` left behind: the body's top-level fields other than the one\n * the rows were plucked from. `{ products, total, skip, limit }` with\n * `returns: \"products\"` → `{ total, skip, limit }`; with `returns: \"data.items\"`\n * every top-level field except `data`.\n */\nfunction envelopeOf(body: unknown, path: string | undefined): Record<string, unknown> | undefined {\n if (!path || !body || typeof body !== 'object' || Array.isArray(body)) return undefined\n const head = path.split('.')[0] ?? path\n const rest: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(body as Record<string, unknown>)) {\n if (k !== head) rest[k] = v\n }\n return rest\n}\n\n/** A REST answer on its way out of `executeFetch`: rows plus what came with them. */\nclass RestAnswer {\n constructor(\n readonly data: unknown,\n readonly status: number,\n readonly envelope: Record<string, unknown> | undefined\n ) {}\n}\n\n/**\n * Default implementation of the DataServiceInterface.\n *\n * Accepts optional DataServiceConfig for default cache TTL, retry, and timeout.\n */\nexport class DataService implements DataServiceInterface {\n private readonly sources = new Map<string, DataSourceDefinition>()\n private readonly cache = new Map<string, CacheEntry<unknown>>()\n private readonly bindings = new Map<string, DefaultLiveDataBinding<unknown>>()\n readonly config: DataServiceConfig\n\n constructor(config?: DataServiceConfig) {\n this.config = config ?? {}\n }\n\n registerSource<T>(definition: DataSourceDefinition<T>): void {\n if (this.sources.has(definition.id)) {\n throw new Error(`Data source '${definition.id}' is already registered`)\n }\n this.sources.set(definition.id, definition as DataSourceDefinition)\n }\n\n resolveDataSource(sourceId: string): DataSourceDefinition | undefined {\n return this.sources.get(sourceId)\n }\n\n hasSource(sourceId: string): boolean {\n return this.sources.has(sourceId)\n }\n\n async fetchData<T>(sourceId: string, options?: DataFetchOptions): Promise<DataFetchResult<T>> {\n const source = this.sources.get(sourceId)\n if (!source) {\n return {\n success: false,\n error: {\n type: 'not_found',\n message: `Data source '${sourceId}' not found`,\n },\n }\n }\n\n // A write is never answered from the read cache, and never fills it: the\n // record a POST returns is not the list a reader asked for.\n const isWrite = (options?.method ?? source.method ?? 'GET') !== 'GET'\n\n // Check cache\n if (!isWrite && !options?.skipCache && source.cache?.enabled) {\n const cacheKey = source.cache.key ?? `data:${sourceId}`\n const cached = this.getFromCache<T>(cacheKey)\n if (cached !== undefined) {\n return {\n success: true,\n data: cached,\n metadata: {\n duration: 0,\n fromCache: true,\n timestamp: Date.now(),\n },\n }\n }\n }\n\n const startTime = Date.now()\n\n try {\n const fetched = await this.executeFetch(source, options)\n // A REST answer carries its status and envelope beside the rows.\n const rawData = fetched instanceof RestAnswer ? fetched.data : fetched\n const data = source.transform ? source.transform(rawData) : rawData\n\n const duration = Date.now() - startTime\n const metadata: DataFetchMetadata = {\n duration,\n fromCache: false,\n timestamp: Date.now(),\n ...(fetched instanceof RestAnswer\n ? { status: fetched.status, ...(fetched.envelope ? { envelope: fetched.envelope } : {}) }\n : {}),\n }\n\n // Store in cache — use source-level TTL, fall back to service config, then default\n if (!isWrite && source.cache?.enabled) {\n const cacheKey = source.cache.key ?? `data:${sourceId}`\n const ttl =\n source.cache.ttl ??\n (this.config.defaultCacheTtl ? this.config.defaultCacheTtl * 1000 : 60_000)\n this.setCache(cacheKey, data, ttl)\n }\n\n return { success: true, data: data as T, metadata }\n } catch (err) {\n const duration = Date.now() - startTime\n const error = this.toFetchError(err, duration)\n return { success: false, error }\n }\n }\n\n bindData<T>(binding: DataBinding<T>): LiveDataBinding<T> {\n const liveBinding = new DefaultLiveDataBinding<T>(binding, this)\n this.bindings.set(binding.id, liveBinding as DefaultLiveDataBinding<unknown>)\n return liveBinding\n }\n\n unregisterSource(sourceId: string): boolean {\n if (!this.sources.has(sourceId)) {\n return false\n }\n this.sources.delete(sourceId)\n // Invalidate cache\n const cacheKey = `data:${sourceId}`\n this.cache.delete(cacheKey)\n return true\n }\n\n getSourceIds(): readonly string[] {\n return Array.from(this.sources.keys())\n }\n\n clear(): void {\n this.sources.clear()\n this.cache.clear()\n for (const binding of this.bindings.values()) {\n binding.dispose()\n }\n this.bindings.clear()\n }\n\n // ============================================================\n // PRIVATE METHODS\n // ============================================================\n\n private async executeFetch(\n source: DataSourceDefinition,\n options?: DataFetchOptions\n ): Promise<unknown> {\n switch (source.kind) {\n case 'static':\n return source.staticData\n\n case 'state': {\n const context: DataResolveContext = {\n params: options?.params ?? {},\n ...(options?.signal ? { signal: options.signal } : {}),\n }\n if (source.compute) {\n return source.compute(context)\n }\n return source.staticData\n }\n\n case 'computed': {\n if (!source.compute) {\n throw new Error(`Computed data source '${source.id}' has no compute function`)\n }\n const context: DataResolveContext = {\n params: options?.params ?? {},\n ...(options?.signal ? { signal: options.signal } : {}),\n }\n return source.compute(context)\n }\n\n case 'rest': {\n if (!source.endpoint) {\n throw new Error(`REST data source '${source.id}' has no endpoint`)\n }\n return this.fetchRest(source, options)\n }\n\n case 'graphql': {\n if (!source.endpoint) {\n throw new Error(`GraphQL data source '${source.id}' has no endpoint`)\n }\n return this.fetchRest(source, options)\n }\n\n default:\n throw new Error(`Unknown data source kind: ${source.kind}`)\n }\n }\n\n private async fetchRest(\n source: DataSourceDefinition,\n options?: DataFetchOptions\n ): Promise<unknown> {\n const collection = source.endpoint as string\n // One record of the collection, when the call names it. The source's\n // address is the collection; `<collection>/<id>` is how the platform (and\n // every REST API worth the name) addresses a row of it.\n const url =\n options?.recordId !== undefined\n ? `${collection.replace(/\\/+$/, '')}/${encodeURIComponent(options.recordId)}`\n : collection\n // A write uses the same address with a different verb — the source says\n // how it is read, the call says what it is doing.\n const method = options?.method ?? source.method ?? 'GET'\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n ...source.headers,\n ...options?.headers,\n }\n\n // call it AS THE SIGNED-IN USER.\n //\n // Resolved per request and never cached: a delegated token expires within\n // the hour, and a value held here would be the beginning of a credential\n // living somewhere it can be serialised. A resolver that answers null\n // sends the request WITHOUT the header — the server's own 401 is a truer\n // error than a client-side guess, and it is what a panel's `errorWhen`\n // already renders.\n if (source.authProviderRef && this.config.getAccessToken) {\n const token = await this.config.getAccessToken(source.authProviderRef)\n if (token) headers['Authorization'] = `Bearer ${token}`\n }\n\n const timeout = options?.timeout ?? this.config.timeout\n\n const requestInit: RequestInit = {\n method,\n headers,\n // Explicit on both sides. Our own API authenticates by cookie and is\n // cross-origin from a published app, so it needs `include`; anyone\n // else's endpoint must never receive one, and leaving this to fetch's\n // `'same-origin'` default would be a decision nobody wrote down.\n credentials: isPlatformOrigin(url, this.config.platformApiOrigin) ? 'include' : 'omit',\n ...(options?.signal ? { signal: options.signal } : {}),\n }\n\n if (options?.body && method !== 'GET') {\n requestInit.body = JSON.stringify(options.body)\n }\n\n // Apply timeout if configured and no external signal provided\n if (timeout && !options?.signal) {\n requestInit.signal = AbortSignal.timeout(timeout)\n }\n\n const response = await fetch(url, requestInit)\n\n if (!response.ok) {\n // The server's own words travel with the refusal. Our API answers\n // `{ error: { code, message } }`; anyone else's body is read the same\n // way and ignored when it is not that shape. Before this the body was\n // dropped, and a form could only report \"it failed\" and guess why.\n const refusal = await readRefusal(response)\n const error = new Error(refusal.message ?? `HTTP ${response.status}: ${response.statusText}`)\n ;(error as Error & { status: number }).status = response.status\n if (refusal.code) (error as Error & { code: string }).code = refusal.code\n throw error\n }\n\n const body: unknown = await response.json()\n const rows = pluck(body, source.returns)\n // Filter / sort / pagination are not sent (the endpoint does not speak\n // them), so they are applied here: otherwise a REST source that declared\n // `filter: status eq open` would show every row.\n const data =\n source.query && Array.isArray(rows) ? applyEntityQuery(rows as Record<string, unknown>[], source.query).items : rows\n return new RestAnswer(data, response.status, envelopeOf(body, source.returns))\n }\n\n private getFromCache<T>(key: string): T | undefined {\n const entry = this.cache.get(key)\n if (!entry) return undefined\n\n const elapsed = Date.now() - entry.timestamp\n if (elapsed > entry.ttl) {\n this.cache.delete(key)\n return undefined\n }\n\n return entry.data as T\n }\n\n private setCache(key: string, data: unknown, ttl: number): void {\n this.cache.set(key, { data, timestamp: Date.now(), ttl })\n }\n\n private toFetchError(err: unknown, _duration?: number): DataFetchError {\n if (err instanceof Error) {\n if (err.name === 'AbortError') {\n return { type: 'timeout', message: 'Request was aborted', cause: err }\n }\n if (err.message.includes('timeout')) {\n return { type: 'timeout', message: err.message, cause: err }\n }\n const status = (err as Error & { status?: number }).status\n if (status) {\n const code = (err as Error & { code?: string }).code\n return {\n type: 'network',\n message: err.message,\n status,\n ...(code ? { code } : {}),\n cause: err,\n }\n }\n return { type: 'unknown', message: err.message, cause: err }\n }\n return { type: 'unknown', message: String(err), cause: err }\n }\n}\n\n// ============================================================\n// DEFAULT LIVE DATA BINDING\n// ============================================================\n\n/**\n * Default live data binding implementation\n */\nclass DefaultLiveDataBinding<T> implements LiveDataBinding<T> {\n readonly binding: DataBinding<T>\n\n private _state: DataBindingState = 'idle'\n private _data: T | undefined = undefined\n private _error: DataFetchError | undefined = undefined\n private readonly listeners = new Set<DataBindingListener<T>>()\n private readonly service: DataService\n\n constructor(binding: DataBinding<T>, service: DataService) {\n this.binding = binding\n this.service = service\n }\n\n get state(): DataBindingState {\n return this._state\n }\n\n get data(): T | undefined {\n return this._data\n }\n\n get error(): DataFetchError | undefined {\n return this._error\n }\n\n async refresh(): Promise<DataFetchResult<T>> {\n this.updateState('loading', this._data, undefined)\n\n const result = await this.service.fetchData<T>(this.binding.sourceId)\n\n if (result.success) {\n const transformed = this.binding.transform\n ? (this.binding.transform(result.data) as T)\n : result.data\n this.updateState('loaded', transformed, undefined)\n } else {\n this.updateState('error', this._data, result.error)\n }\n\n return result\n }\n\n subscribe(listener: DataBindingListener<T>): () => void {\n this.listeners.add(listener)\n return () => {\n this.listeners.delete(listener)\n }\n }\n\n dispose(): void {\n this.listeners.clear()\n this._data = undefined\n this._error = undefined\n this._state = 'idle'\n }\n\n private updateState(\n state: DataBindingState,\n data: T | undefined,\n error: DataFetchError | undefined\n ): void {\n this._state = state\n this._data = data\n this._error = error\n this.notifyListeners()\n }\n\n private notifyListeners(): void {\n for (const listener of this.listeners) {\n try {\n listener(this._data, this._state)\n } catch {\n // Swallow listener errors to prevent cascading failures\n }\n }\n }\n}\n\n// ============================================================\n// FACTORY FUNCTIONS\n// ============================================================\n\n/**\n * Create a DataService instance with optional config\n */\nexport function createDataService(config?: DataServiceConfig): DataServiceInterface {\n return new DataService(config)\n}\n\n"]}
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/data/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AA0B3D,+DAA+D;AAC/D,eAAe;AACf,+DAA+D;AAE/D;;;;;;;;;;;;GAYG;AACH,SAAS,gBAAgB,CAAC,GAAW,EAAE,iBAAqC;IAC1E,IAAI,CAAC,iBAAiB;QAAE,OAAO,KAAK,CAAA;IACpC,IAAI,CAAC;QACH,wEAAwE;QACxE,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAA;QACtD,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAA;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,WAAW,CAAC,QAAkB;IAC3C,IAAI,CAAC;Q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CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;YACnC,CAAC;YAAC,MAAM,CAAC;gBACP,wDAAwD;YAC1D,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,+DAA+D;AAC/D,oBAAoB;AACpB,+DAA+D;AAE/D;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA0B;IAC1D,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC","sourcesContent":["/**\n * Data Service (formerly Data Capability Manager)\n *\n * Default implementation of the data service\n *\n * Provides data source registration, resolution, fetch with caching,\n * and live data bindings for surfaces.\n *\n * @module @pwfabric/runtime/data/manager\n */\n\nimport { applyEntityQuery } from '../entity/apply-query.js'\nimport type {\n DataServiceInterface,\n DataServiceConfig,\n DataSourceDefinition,\n DataFetchOptions,\n DataFetchResult,\n DataFetchError,\n DataFetchMetadata,\n DataBinding,\n LiveDataBinding,\n DataBindingState,\n DataBindingListener,\n DataResolveContext,\n} from './types.js'\n\n// ============================================================\n// CACHE ENTRY\n// ============================================================\n\ninterface CacheEntry<T> {\n data: T\n timestamp: number\n ttl: number\n}\n\n// ============================================================\n// DATA SERVICE\n// ============================================================\n\n/**\n * The list, out of whatever the endpoint wrapped it in.\n *\n * `returns` names the property holding the array — `data` for ours,\n * `products` for DummyJSON, absent when the body already IS the array. Three\n * shapes were in circulation and the binding context received whichever one\n * came back, so a block bound to a list could not take all three.\n *\n * A named path that is not there THROWS rather than yielding undefined: a\n * silently empty panel is the failure this field exists to end, and \"the\n * endpoint answered, but not with what the plan said\" is a sentence the user\n * can act on.\n */\nfunction isPlatformOrigin(url: string, platformApiOrigin: string | undefined): boolean {\n if (!platformApiOrigin) return false\n try {\n // A relative endpoint is same-document, which is our own by definition.\n if (!/^[a-z][a-z0-9+.-]*:\\/\\//i.test(url)) return true\n return new URL(url).origin === new URL(platformApiOrigin).origin\n } catch {\n return false\n }\n}\n\n/**\n * What a non-OK response says about itself: `{ error: { code, message } }`\n * when it is our API (or anyone keeping the same envelope), nothing when the\n * body is absent, not JSON, or not that shape. Never throws — a refusal\n * without a readable body is still a refusal with a status.\n */\nasync function readRefusal(response: Response): Promise<{ code?: string; message?: string }> {\n try {\n const body = (await response.json()) as { error?: { code?: unknown; message?: unknown } } | null\n const error = body?.error\n if (!error || typeof error !== 'object') return {}\n return {\n ...(typeof error.code === 'string' ? { code: error.code } : {}),\n ...(typeof error.message === 'string' && error.message ? { message: error.message } : {}),\n }\n } catch {\n return {}\n }\n}\n\nfunction pluck(body: unknown, path: string | undefined): unknown {\n if (!path) return body\n let node: unknown = body\n for (const key of path.split('.')) {\n if (!node || typeof node !== 'object' || Array.isArray(node)) {\n throw new Error(`Response has no '${path}' — nothing at '${key}'`)\n }\n node = (node as Record<string, unknown>)[key]\n }\n if (node === undefined) throw new Error(`Response has no '${path}'`)\n return node\n}\n\n/**\n * What `returns` left behind: the body's top-level fields other than the one\n * the rows were plucked from. `{ products, total, skip, limit }` with\n * `returns: \"products\"` → `{ total, skip, limit }`; with `returns: \"data.items\"`\n * every top-level field except `data`.\n */\nfunction envelopeOf(body: unknown, path: string | undefined): Record<string, unknown> | undefined {\n if (!path || !body || typeof body !== 'object' || Array.isArray(body)) return undefined\n const head = path.split('.')[0] ?? path\n const rest: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(body as Record<string, unknown>)) {\n if (k !== head) rest[k] = v\n }\n return rest\n}\n\n/** A REST answer on its way out of `executeFetch`: rows plus what came with them. */\nclass RestAnswer {\n constructor(\n readonly data: unknown,\n readonly status: number,\n readonly envelope: Record<string, unknown> | undefined\n ) {}\n}\n\n/**\n * Default implementation of the DataServiceInterface.\n *\n * Accepts optional DataServiceConfig for default cache TTL, retry, and timeout.\n */\nexport class DataService implements DataServiceInterface {\n private readonly sources = new Map<string, DataSourceDefinition>()\n private readonly cache = new Map<string, CacheEntry<unknown>>()\n private readonly bindings = new Map<string, DefaultLiveDataBinding<unknown>>()\n readonly config: DataServiceConfig\n\n constructor(config?: DataServiceConfig) {\n this.config = config ?? {}\n }\n\n registerSource<T>(definition: DataSourceDefinition<T>): void {\n if (this.sources.has(definition.id)) {\n throw new Error(`Data source '${definition.id}' is already registered`)\n }\n this.sources.set(definition.id, definition as DataSourceDefinition)\n }\n\n resolveDataSource(sourceId: string): DataSourceDefinition | undefined {\n return this.sources.get(sourceId)\n }\n\n hasSource(sourceId: string): boolean {\n return this.sources.has(sourceId)\n }\n\n async fetchData<T>(sourceId: string, options?: DataFetchOptions): Promise<DataFetchResult<T>> {\n const source = this.sources.get(sourceId)\n if (!source) {\n return {\n success: false,\n error: {\n type: 'not_found',\n message: `Data source '${sourceId}' not found`,\n },\n }\n }\n\n // A write is never answered from the read cache, and never fills it: the\n // record a POST returns is not the list a reader asked for.\n const isWrite = (options?.method ?? source.method ?? 'GET') !== 'GET'\n\n // Check cache\n if (!isWrite && !options?.skipCache && source.cache?.enabled) {\n const cacheKey = source.cache.key ?? `data:${sourceId}`\n const cached = this.getFromCache<T>(cacheKey)\n if (cached !== undefined) {\n return {\n success: true,\n data: cached,\n metadata: {\n duration: 0,\n fromCache: true,\n timestamp: Date.now(),\n },\n }\n }\n }\n\n const startTime = Date.now()\n\n try {\n const fetched = await this.executeFetch(source, options)\n // A REST answer carries its status and envelope beside the rows.\n const rawData = fetched instanceof RestAnswer ? fetched.data : fetched\n const data = source.transform ? source.transform(rawData) : rawData\n\n const duration = Date.now() - startTime\n const metadata: DataFetchMetadata = {\n duration,\n fromCache: false,\n timestamp: Date.now(),\n ...(fetched instanceof RestAnswer\n ? { status: fetched.status, ...(fetched.envelope ? { envelope: fetched.envelope } : {}) }\n : {}),\n }\n\n // Store in cache — use source-level TTL, fall back to service config, then default\n if (!isWrite && source.cache?.enabled) {\n const cacheKey = source.cache.key ?? `data:${sourceId}`\n const ttl =\n source.cache.ttl ??\n (this.config.defaultCacheTtl ? this.config.defaultCacheTtl * 1000 : 60_000)\n this.setCache(cacheKey, data, ttl)\n }\n\n return { success: true, data: data as T, metadata }\n } catch (err) {\n const duration = Date.now() - startTime\n const error = this.toFetchError(err, duration)\n return { success: false, error }\n }\n }\n\n bindData<T>(binding: DataBinding<T>): LiveDataBinding<T> {\n const liveBinding = new DefaultLiveDataBinding<T>(binding, this)\n this.bindings.set(binding.id, liveBinding as DefaultLiveDataBinding<unknown>)\n return liveBinding\n }\n\n unregisterSource(sourceId: string): boolean {\n if (!this.sources.has(sourceId)) {\n return false\n }\n this.sources.delete(sourceId)\n // Invalidate cache\n const cacheKey = `data:${sourceId}`\n this.cache.delete(cacheKey)\n return true\n }\n\n getSourceIds(): readonly string[] {\n return Array.from(this.sources.keys())\n }\n\n clear(): void {\n this.sources.clear()\n this.cache.clear()\n for (const binding of this.bindings.values()) {\n binding.dispose()\n }\n this.bindings.clear()\n }\n\n // ============================================================\n // PRIVATE METHODS\n // ============================================================\n\n private async executeFetch(\n source: DataSourceDefinition,\n options?: DataFetchOptions\n ): Promise<unknown> {\n switch (source.kind) {\n case 'static':\n // The query is applied to static rows like to fetched ones: a static\n // list declared `sort: name asc` or `filter: featured eq true` is\n // bound sorted and filtered (data-protocol §3).\n return source.query && Array.isArray(source.staticData)\n ? applyEntityQuery(source.staticData as Record<string, unknown>[], source.query).items\n : source.staticData\n\n case 'state': {\n const context: DataResolveContext = {\n params: options?.params ?? {},\n ...(options?.signal ? { signal: options.signal } : {}),\n }\n if (source.compute) {\n return source.compute(context)\n }\n return source.staticData\n }\n\n case 'computed': {\n if (!source.compute) {\n throw new Error(`Computed data source '${source.id}' has no compute function`)\n }\n const context: DataResolveContext = {\n params: options?.params ?? {},\n ...(options?.signal ? { signal: options.signal } : {}),\n }\n return source.compute(context)\n }\n\n case 'rest': {\n if (!source.endpoint) {\n throw new Error(`REST data source '${source.id}' has no endpoint`)\n }\n return this.fetchRest(source, options)\n }\n\n case 'graphql': {\n if (!source.endpoint) {\n throw new Error(`GraphQL data source '${source.id}' has no endpoint`)\n }\n return this.fetchRest(source, options)\n }\n\n default:\n throw new Error(`Unknown data source kind: ${source.kind}`)\n }\n }\n\n private async fetchRest(\n source: DataSourceDefinition,\n options?: DataFetchOptions\n ): Promise<unknown> {\n const collection = source.endpoint as string\n // One record of the collection, when the call names it. The source's\n // address is the collection; `<collection>/<id>` is how the platform (and\n // every REST API worth the name) addresses a row of it.\n const url =\n options?.recordId !== undefined\n ? `${collection.replace(/\\/+$/, '')}/${encodeURIComponent(options.recordId)}`\n : collection\n // A write uses the same address with a different verb — the source says\n // how it is read, the call says what it is doing.\n const method = options?.method ?? source.method ?? 'GET'\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n ...source.headers,\n ...options?.headers,\n }\n\n // call it AS THE SIGNED-IN USER.\n //\n // Resolved per request and never cached: a delegated token expires within\n // the hour, and a value held here would be the beginning of a credential\n // living somewhere it can be serialised. A resolver that answers null\n // sends the request WITHOUT the header — the server's own 401 is a truer\n // error than a client-side guess, and it is what a panel's `errorWhen`\n // already renders.\n if (source.authProviderRef && this.config.getAccessToken) {\n const token = await this.config.getAccessToken(source.authProviderRef)\n if (token) headers['Authorization'] = `Bearer ${token}`\n }\n\n const timeout = options?.timeout ?? this.config.timeout\n\n const requestInit: RequestInit = {\n method,\n headers,\n // Explicit on both sides. Our own API authenticates by cookie and is\n // cross-origin from a published app, so it needs `include`; anyone\n // else's endpoint must never receive one, and leaving this to fetch's\n // `'same-origin'` default would be a decision nobody wrote down.\n credentials: isPlatformOrigin(url, this.config.platformApiOrigin) ? 'include' : 'omit',\n ...(options?.signal ? { signal: options.signal } : {}),\n }\n\n if (options?.body && method !== 'GET') {\n requestInit.body = JSON.stringify(options.body)\n }\n\n // Apply timeout if configured and no external signal provided\n if (timeout && !options?.signal) {\n requestInit.signal = AbortSignal.timeout(timeout)\n }\n\n const response = await fetch(url, requestInit)\n\n if (!response.ok) {\n // The server's own words travel with the refusal. Our API answers\n // `{ error: { code, message } }`; anyone else's body is read the same\n // way and ignored when it is not that shape. Before this the body was\n // dropped, and a form could only report \"it failed\" and guess why.\n const refusal = await readRefusal(response)\n const error = new Error(refusal.message ?? `HTTP ${response.status}: ${response.statusText}`)\n ;(error as Error & { status: number }).status = response.status\n if (refusal.code) (error as Error & { code: string }).code = refusal.code\n throw error\n }\n\n const body: unknown = await response.json()\n const rows = pluck(body, source.returns)\n // Filter / sort / pagination are not sent (the endpoint does not speak\n // them), so they are applied here: otherwise a REST source that declared\n // `filter: status eq open` would show every row.\n const data =\n source.query && Array.isArray(rows) ? applyEntityQuery(rows as Record<string, unknown>[], source.query).items : rows\n return new RestAnswer(data, response.status, envelopeOf(body, source.returns))\n }\n\n private getFromCache<T>(key: string): T | undefined {\n const entry = this.cache.get(key)\n if (!entry) return undefined\n\n const elapsed = Date.now() - entry.timestamp\n if (elapsed > entry.ttl) {\n this.cache.delete(key)\n return undefined\n }\n\n return entry.data as T\n }\n\n private setCache(key: string, data: unknown, ttl: number): void {\n this.cache.set(key, { data, timestamp: Date.now(), ttl })\n }\n\n private toFetchError(err: unknown, _duration?: number): DataFetchError {\n if (err instanceof Error) {\n if (err.name === 'AbortError') {\n return { type: 'timeout', message: 'Request was aborted', cause: err }\n }\n if (err.message.includes('timeout')) {\n return { type: 'timeout', message: err.message, cause: err }\n }\n const status = (err as Error & { status?: number }).status\n if (status) {\n const code = (err as Error & { code?: string }).code\n return {\n type: 'network',\n message: err.message,\n status,\n ...(code ? { code } : {}),\n cause: err,\n }\n }\n return { type: 'unknown', message: err.message, cause: err }\n }\n return { type: 'unknown', message: String(err), cause: err }\n }\n}\n\n// ============================================================\n// DEFAULT LIVE DATA BINDING\n// ============================================================\n\n/**\n * Default live data binding implementation\n */\nclass DefaultLiveDataBinding<T> implements LiveDataBinding<T> {\n readonly binding: DataBinding<T>\n\n private _state: DataBindingState = 'idle'\n private _data: T | undefined = undefined\n private _error: DataFetchError | undefined = undefined\n private readonly listeners = new Set<DataBindingListener<T>>()\n private readonly service: DataService\n\n constructor(binding: DataBinding<T>, service: DataService) {\n this.binding = binding\n this.service = service\n }\n\n get state(): DataBindingState {\n return this._state\n }\n\n get data(): T | undefined {\n return this._data\n }\n\n get error(): DataFetchError | undefined {\n return this._error\n }\n\n async refresh(): Promise<DataFetchResult<T>> {\n this.updateState('loading', this._data, undefined)\n\n const result = await this.service.fetchData<T>(this.binding.sourceId)\n\n if (result.success) {\n const transformed = this.binding.transform\n ? (this.binding.transform(result.data) as T)\n : result.data\n this.updateState('loaded', transformed, undefined)\n } else {\n this.updateState('error', this._data, result.error)\n }\n\n return result\n }\n\n subscribe(listener: DataBindingListener<T>): () => void {\n this.listeners.add(listener)\n return () => {\n this.listeners.delete(listener)\n }\n }\n\n dispose(): void {\n this.listeners.clear()\n this._data = undefined\n this._error = undefined\n this._state = 'idle'\n }\n\n private updateState(\n state: DataBindingState,\n data: T | undefined,\n error: DataFetchError | undefined\n ): void {\n this._state = state\n this._data = data\n this._error = error\n this.notifyListeners()\n }\n\n private notifyListeners(): void {\n for (const listener of this.listeners) {\n try {\n listener(this._data, this._state)\n } catch {\n // Swallow listener errors to prevent cascading failures\n }\n }\n }\n}\n\n// ============================================================\n// FACTORY FUNCTIONS\n// ============================================================\n\n/**\n * Create a DataService instance with optional config\n */\nexport function createDataService(config?: DataServiceConfig): DataServiceInterface {\n return new DataService(config)\n}\n\n"]}
@@ -168,6 +168,11 @@ function mapSurfaceSourceToDefinition(source, currentState) {
168
168
  id: source.id,
169
169
  kind: 'static',
170
170
  staticData: source.staticData,
171
+ // A static source's query was dropped here, so its rows were bound
172
+ // unsorted and unfiltered. Resolved like a rest source's.
173
+ ...(source.query
174
+ ? { query: resolveQueryState(source.query, currentState) }
175
+ : {}),
171
176
  };
172
177
  case 'state':
173
178
  // State sources read from React state, not managed by DataService
@@ -263,6 +268,9 @@ function requestKeyOf(source, state) {
263
268
  }
264
269
  case 'state':
265
270
  return `${def}|${safeJson(state[source.id])}`;
271
+ case 'static':
272
+ // A query reading `{{state.x}}` re-applies when x changes.
273
+ return source.query ? `${def}|${safeJson(resolveQueryState(source.query, state))}` : def;
266
274
  default:
267
275
  return def;
268
276
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DataBoundSurfaceRenderer.js","sourceRoot":"","sources":["../../src/render/DataBoundSurfaceRenderer.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAyB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAe1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAI9D,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,+DAA+D;AAC/D,6DAA6D;AAC7D,+DAA+D;AAE/D;;;GAGG;AACH,SAAS,uBAAuB,CAAC,OAEhC;IAKC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,IAAI,CACxC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,kCAAkC,CAAC,CAC3D,CAAA;IACD,MAAM,GAAG,GAAG,OAAO,EAAE,MAMR,CAAA;IACb,OAAO;QACL,WAAW,EAAE,GAAG,EAAE,WAAW;QAC7B,YAAY,EAAE,GAAG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AC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,MAAM,EAAE,cAAc;QACtB,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxD,CAAA;IACD,OAAO;IACL,wEAAwE;IACxE,qEAAqE;IACrE,iEAAiE;IACjE,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,cAAc,YAChD,KAAC,eAAe,IAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,KAAM,aAAa,GAAI,GAC1D,CAC/B,CAAA;AACH,CAAC;AAED,+DAA+D;AAC/D,UAAU;AACV,+DAA+D;AAE/D;;GAEG;AACH,SAAS,eAAe,CAAC,MAAwB,EAAE,OAAe;IAChE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,KAAK,EAAE,MAAM,CAAA;QAC5B,CAAC;QACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YACtD,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAA;QACvC,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["/**\n * Data-Bound Surface Renderer\n *\n * Wrapper component that resolves dataSources, state, and {{expression}} props\n * before passing concrete values to the existing SurfaceRenderer.\n *\n * Architecture (post-refactor):\n * Surface JSON (dataSources + state + {{expr}} in props)\n * -> DataBoundSurfaceRenderer\n * -> DataCapabilityProvider (creates DataService instance)\n * -> DataBoundInner\n * -> useSurfaceData: maps SurfaceDataSourceDefinition → DataSourceDefinition,\n * registers with DataService, fetches via DataService, manages React state\n * -> SurfaceRenderer (unchanged)\n * -> Block components (unchanged)\n *\n * Backward compatible: if no dataSources, passes through with zero overhead.\n *\n * @module @pwfabric/runtime/render/DataBoundSurfaceRenderer\n */\n\nimport * as React from 'react'\nimport { SurfaceRenderer } from './renderer.js'\nimport { resolveBlockExpressions } from './resolve-expressions.js'\nimport { endpointMissingPathValue, resolveEndpoint } from './endpoint.js'\nimport { resolveQueryState } from './query-state.js'\nimport { dataSourceCacheKey, type SurfaceDataCache } from './data-cache.js'\nimport { DataCapabilityProvider, useDataService } from '../data/DataCapabilityProvider.js'\nimport type {\n DataBoundSurfaceRendererProps,\n SurfaceDataSourceDefinition,\n SurfaceAction,\n RuntimeBehavior,\n} from './data-binding-types.js'\nimport type {\n SurfaceEvent,\n SurfaceRendererProps,\n RenderableSurface,\n BlockInteractionMode,\n} from './types.js'\nimport type { Block } from '@pwfabric/core'\nimport type { DataSourceDefinition } from '../data/types.js'\nimport { createEntityDataSource } from '../entity/entity-datasource.js'\nimport { aggregateThrough } from '../entity/aggregate.js'\nimport { SurfaceDataContext } from './surface-data-context.js'\nimport type { EntityFacade } from '../entity/facade.js'\nimport type { EntityAggregate, EntityQuery, EntityTypeId } from '../entity/types.js'\nimport type { SurfaceConnectionsValue } from '../connectors/types.js'\nimport { PLATFORM_PERSISTENCE_CAPABILITY_ID } from '@pwfabric/contracts'\nimport { isCapability } from '../capability/type-mapping.js'\nimport { writeOnlySourceIds } from './write-only-sources.js'\n\n// ============================================================\n// extract dataSources + initialState from persistence config\n// ============================================================\n\n/**\n * consolidated these two seeds under the platform/persistence\n * capability config. DataBoundSurfaceRenderer is the sole consumer.\n */\nfunction extractPersistenceSeeds(surface: {\n readonly capabilities?: RenderableSurface['capabilities']\n}): {\n dataSources: readonly SurfaceDataSourceDefinition[] | undefined\n initialState: Readonly<Record<string, unknown>> | undefined\n behaviors: readonly RuntimeBehavior[] | undefined\n} {\n const binding = surface.capabilities?.find(\n (c) => isCapability(c, PLATFORM_PERSISTENCE_CAPABILITY_ID)\n )\n const cfg = binding?.config as\n | {\n dataSources?: readonly SurfaceDataSourceDefinition[]\n initialState?: Readonly<Record<string, unknown>>\n behaviors?: readonly RuntimeBehavior[]\n }\n | undefined\n return {\n dataSources: cfg?.dataSources,\n initialState: cfg?.initialState,\n // Declared behaviors (shipped by a pattern / authored in JSON). The\n // renderer merges these with host-provided behaviors (the host's store) so a pack\n // can carry its own controls without the host knowing about them.\n behaviors: cfg?.behaviors,\n }\n}\n\n/**\n * A source that could not be served but declares a `fallback`: the caller\n * binds `data` AND records `message` under `__errors.<id>`, so the surface\n * renders honestly (sample data + error flag) instead of empty or crashed.\n */\nclass SourceFallback extends Error {\n constructor(\n message: string,\n readonly data: unknown\n ) {\n super(message)\n this.name = 'SourceFallback'\n }\n}\n\n/**\n * A surface whose ONLY dynamic behaviour is writing (platform/entities\n * formBindings, no persistence dataSources) still needs the full data-bound\n * path: the form→entity bridge dispatches statusKeys through setState and the\n * success/error UI hangs off `visibleWhen: \"{{state.x}}\"` — both live in\n * DataBoundInner's state machinery. Before this check, such a surface fell\n * into the zero-overhead passthrough where visibleWhen was never evaluated\n * and, worse, submits were silently lost (proven live against a real\n * SharePoint list: two submits on a formBindings-only page never reached the\n * connector; adding any read source made the identical form work).\n */\nfunction hasEntityFormBindings(surface: {\n readonly capabilities?: RenderableSurface['capabilities']\n}): boolean {\n const entityCap = surface.capabilities?.find((c) => isCapability(c, 'platform/entities'))\n const formBindings = (entityCap?.config as { formBindings?: readonly unknown[] } | undefined)\n ?.formBindings\n return Array.isArray(formBindings) && formBindings.length > 0\n}\n\n/**\n * The actions a block's `action` prop names, in order.\n *\n * One action or a list of them (`[setState step, setState stepError '']`) —\n * a wizard's \"Next\" has to move the step AND clear the previous step's error\n * in one click. Anything that is not a surface action (a form's `action` is\n * its submit URL string) names none.\n */\nexport function blockActionsOf(value: unknown): readonly SurfaceAction[] {\n if (Array.isArray(value)) return value.filter(isSurfaceAction)\n return isSurfaceAction(value) ? [value] : []\n}\n\nfunction blockTreeHasAction(blocks: readonly Block[] | undefined): boolean {\n if (!blocks) return false\n for (const block of blocks) {\n if (blockActionsOf(block.props?.action).length > 0) return true\n if (blockTreeHasAction(block.children)) return true\n }\n return false\n}\n\n/**\n * Does any block carry a condition or a repeat the renderer has to evaluate?\n *\n * `visibleWhen`/`if` and `repeat` are resolved ONLY on the data-bound path.\n * A static page — no source, no state, no action — takes this path too: on\n * the passthrough a condition would never be read, so the shell's empty\n * brand logo would draw as \"⊟ <name> logo\", and a thank-you gated on\n * `{{state.submitted}}` would show before anything was submitted.\n * An empty condition string is no condition, as in resolveBlock.\n */\nfunction blockTreeHasCondition(blocks: readonly Block[] | undefined): boolean {\n if (!blocks) return false\n for (const block of blocks) {\n const b = block as { visibleWhen?: unknown; if?: unknown; repeat?: unknown }\n for (const expr of [b.visibleWhen, b.if, b.repeat]) {\n if (typeof expr === 'string' && expr.trim()) return true\n }\n if (blockTreeHasCondition(block.children)) return true\n }\n return false\n}\n\n/**\n * Does this surface need the data-bound path — state, expression resolution,\n * the action dispatcher — or can it go straight to SurfaceRenderer?\n *\n * ONE ANSWER FOR EVERY HOST. The renderer's own passthrough check and embed's\n * `needsDataBoundRenderer` used to disagree: embed counted `initialState`, the\n * renderer did not. So a wizard page carrying nothing but `initialState` and\n * buttons with `action` props reached the renderer, fell into the passthrough,\n * and there `visibleWhen` was never evaluated, `repeat` never expanded and no\n * `action` was ever dispatched — the buttons were dead. A block `action` alone\n * needs the path too: it is dispatched nowhere else. So does a block\n * `visibleWhen`/`if`/`repeat` (see blockTreeHasCondition).\n *\n * Host-provided behaviors are a prop, not part of the surface, and are\n * checked by the renderer on top of this.\n */\nexport function surfaceNeedsDataBinding(surface: {\n readonly blocks?: readonly Block[]\n readonly capabilities?: RenderableSurface['capabilities']\n}): boolean {\n const { dataSources, initialState, behaviors } = extractPersistenceSeeds(surface)\n return (\n Boolean(dataSources && dataSources.length > 0) ||\n initialState !== undefined ||\n Boolean(behaviors && behaviors.length > 0) ||\n hasEntityFormBindings(surface) ||\n blockTreeHasAction(surface.blocks) ||\n blockTreeHasCondition(surface.blocks)\n )\n}\n\n// ============================================================\n// TYPES\n// ============================================================\n\ninterface SourceData {\n readonly data: unknown\n readonly loading: boolean\n readonly error: string | null\n /** HTTP status of the last answer; null for a network failure or a non-HTTP kind. */\n readonly status?: number | null\n /** The envelope `returns` unwrapped the list from (`total`, `skip`, `limit` …). */\n readonly meta?: Readonly<Record<string, unknown>> | null\n /** Not fetched: a required path value of the endpoint is empty. */\n readonly idle?: boolean\n /** The resolved request `data` answered (see requestKeyOf). */\n readonly key?: string\n}\n\n// ============================================================\n// SURFACE → RUNTIME SOURCE MAPPING\n// ============================================================\n\n/**\n * Maps a JSON-safe SurfaceDataSourceDefinition to a runtime DataSourceDefinition.\n * Returns null for 'state' kind (handled locally via React state, not DataService).\n */\nfunction mapSurfaceSourceToDefinition(\n source: SurfaceDataSourceDefinition,\n currentState: Record<string, unknown>\n): DataSourceDefinition | null {\n switch (source.kind) {\n case 'static':\n return {\n id: source.id,\n kind: 'static',\n staticData: source.staticData,\n }\n case 'state':\n // State sources read from React state, not managed by DataService\n return null\n case 'rest': {\n if (!source.endpoint) return null\n // `{{state.x}}` placeholders resolve against current state, each value\n // URL-encoded in a mixed endpoint — see resolveEndpoint for why.\n const endpoint = resolveEndpoint(source.endpoint, currentState)\n return {\n id: source.id,\n kind: 'rest' as const,\n endpoint,\n method: source.method ?? 'GET',\n ...(source.headers ? { headers: source.headers } : {}),\n // carry the identity the source names. This branch\n // copied endpoint/method/headers and stopped, so a rest source could\n // declare an identity the fetch would never see.\n ...(source.authProviderRef ? { authProviderRef: source.authProviderRef } : {}),\n // Same omission class as the line above: the source says where its\n // list is and the definition has to carry it, or `fetchRest` hands the\n // binding context a whole JSON body.\n ...(source.returns !== undefined ? { returns: source.returns } : {}),\n // The entity branch resolves `{{state.x}}` inside the query and hands\n // it to the facade; a rest source declared the same query and lost it\n // here. Resolved the same way, applied by the data service after the\n // fetch.\n ...(source.query\n ? { query: resolveQueryState(source.query, currentState) as EntityQuery }\n : {}),\n }\n }\n default:\n return null\n }\n}\n\n// ============================================================\n// useSurfaceData HOOK\n// ============================================================\n\n/**\n * Manages data source fetching, state, and auto-refresh for a data-bound surface.\n *\n * Delegates fetch mechanics to DataService via context.\n * Keeps React state management and expression resolution locally.\n */\ninterface SurfaceDataResult {\n expressionData: Record<string, unknown>\n surfaceState: Record<string, unknown>\n initialLoaded: boolean\n setStateValue: (key: string, value: unknown) => void\n refreshSource: (sourceId: string) => Promise<void>\n fetchAllSources: () => Promise<void>\n}\n\n/** What one fetch of one source came to. */\ntype FetchOutcome =\n | { readonly kind: 'ok'; readonly data: unknown; readonly status: number | null; readonly meta: Readonly<Record<string, unknown>> | null }\n | { readonly kind: 'error'; readonly message: string; readonly status: number | null; readonly fallback?: { readonly data: unknown } }\n\n/** JSON of a source DEFINITION, computed once per definition object. */\nconst definitionJsonCache = new WeakMap<object, string>()\nlet unserialisable = 0\n\nfunction safeJson(value: unknown): string {\n try {\n return JSON.stringify(value) ?? 'undefined'\n } catch {\n // A value that cannot be serialised can never be proven unchanged.\n return `#unserialisable-${++unserialisable}`\n }\n}\n\nfunction definitionJson(source: SurfaceDataSourceDefinition): string {\n let json = definitionJsonCache.get(source)\n if (json === undefined) {\n json = safeJson(source)\n definitionJsonCache.set(source, json)\n }\n return json\n}\n\n/** A REST source whose required path value is empty is not fetched. */\nfunction isIdleSource(source: SurfaceDataSourceDefinition, state: Readonly<Record<string, unknown>>): boolean {\n return source.kind === 'rest' && Boolean(source.endpoint) && endpointMissingPathValue(source.endpoint as string, state)\n}\n\n/**\n * EVERYTHING THAT DECIDES WHAT A SOURCE FETCHES, AS ONE STRING.\n *\n * The definition itself plus whatever it reads from state, RESOLVED: the REST\n * address, the query with its `{{state.*}}` placeholders filled in, a state\n * source's value. A source is refetched when — and only when — this changes.\n *\n * Refetching every source on every `setState` would make a search box writing\n * `state.searchDraft` on each keystroke refetch the product list AND the\n * cart, flashing both loading states, and a menu toggle refetch the whole\n * page. Dependency tracking on the resolved request is exact where\n * key-name extraction is not: `{{state.a ? state.b : state.c}}` depends on `c`\n * only while `a` is false, and the resolved value knows that.\n */\nfunction requestKeyOf(source: SurfaceDataSourceDefinition, state: Readonly<Record<string, unknown>>): string {\n const def = definitionJson(source)\n switch (source.kind) {\n case 'rest': {\n if (!source.endpoint) return def\n if (isIdleSource(source, state)) return `${def}|idle`\n const query = source.query ? safeJson(resolveQueryState(source.query, state)) : ''\n return `${def}|${resolveEndpoint(source.endpoint, state)}|${query}`\n }\n case 'entity': {\n const query = source.query ? safeJson(resolveQueryState(source.query, state)) : ''\n // The resolved aggregate too: a counter whose filter reads\n // `{{state.status}}` must ask again when the status changes.\n const aggregate = source.aggregate ? safeJson(resolveQueryState(source.aggregate, state)) : ''\n return `${def}|${query}|${aggregate}`\n }\n case 'state':\n return `${def}|${safeJson(state[source.id])}`\n default:\n return def\n }\n}\n\nfunction useSurfaceData(\n dataSources: readonly SurfaceDataSourceDefinition[] | undefined,\n initialState: Readonly<Record<string, unknown>> | undefined,\n interactionMode: BlockInteractionMode = 'live',\n entityFacade?: EntityFacade,\n connections?: SurfaceConnectionsValue,\n dataCache?: SurfaceDataCache,\n /** Sources only a form writes to (see write-only-sources): settled, never fetched. */\n writeOnly?: ReadonlySet<string>\n): SurfaceDataResult {\n const dataService = useDataService()\n const writeOnlyRef = React.useRef(writeOnly)\n writeOnlyRef.current = writeOnly\n const dataCacheRef = React.useRef(dataCache)\n dataCacheRef.current = dataCache\n\n // State store\n const [surfaceState, setSurfaceState] = React.useState<Record<string, unknown>>(() => ({\n ...initialState,\n }))\n\n // Source data store — seeded from the host's cache when it has yesterday's\n // rows for a source, so the first frame is not an empty table. The seed is\n // marked loading: the fetch that follows is what makes it today's.\n const [sourceData, setSourceData] = React.useState<Record<string, SourceData>>(() => {\n if (!dataCache || !dataSources) return {}\n const seeded: Record<string, SourceData> = {}\n for (const source of dataSources) {\n const key = dataSourceCacheKey(source, initialState ?? {})\n if (!key) continue\n const hit = dataCache.get(key)\n if (hit !== undefined) {\n seeded[source.id] = { data: hit, loading: true, error: null, key: requestKeyOf(source, initialState ?? {}) }\n }\n }\n return seeded\n })\n // Track whether initial fetch is complete. A page whose every fetched\n // source came out of the cache counts as loaded: the gate has nothing to\n // wait for that the visitor has not already seen.\n const [initialLoaded, setInitialLoaded] = React.useState(() => {\n if (!dataCache || !dataSources) return false\n const fetched = dataSources.filter((s) => dataSourceCacheKey(s, initialState ?? {}) !== undefined)\n return fetched.length > 0 && fetched.every((s) => dataCache.get(dataSourceCacheKey(s, initialState ?? {})!) !== undefined)\n })\n\n // Stable ref to current state for use in fetch callbacks\n const stateRef = React.useRef(surfaceState)\n stateRef.current = surfaceState\n\n // Stable ref to sources\n const sourcesRef = React.useRef(dataSources)\n sourcesRef.current = dataSources\n\n // Stable ref to the entity facade (kind:'entity' sources query through it)\n const entityFacadeRef = React.useRef(entityFacade)\n entityFacadeRef.current = entityFacade\n\n // Stable ref to the connections context (kind:'entity'\n // sources with a `connector` route through the engine registry)\n const connectionsRef = React.useRef(connections)\n connectionsRef.current = connections\n\n /** The request each source was last fetched (or marked idle) for. */\n const requestKeysRef = React.useRef<Record<string, string>>({})\n /** The in-flight fetch of each source — a newer one aborts it. */\n const controllersRef = React.useRef(new Map<string, AbortController>())\n\n // ---- setState action ----\n // Writing the value a key already holds changes nothing, so it renders\n // nothing and fetches nothing.\n const setStateValue = React.useCallback((key: string, value: unknown) => {\n setSurfaceState((prev) => {\n if (prev[key] === value) return prev\n return { ...prev, [key]: value }\n })\n }, [])\n\n // ---- (Re-)register a source's definition for the current state ----\n // Registered even when the source is idle, so a form or a behavior writing\n // to it through the data service still finds it.\n const registerSource = React.useCallback(\n (source: SurfaceDataSourceDefinition, state: Record<string, unknown>) => {\n if (dataService.hasSource(source.id)) dataService.unregisterSource(source.id)\n const definition = mapSurfaceSourceToDefinition(source, state)\n if (definition) dataService.registerSource(definition)\n },\n [dataService]\n )\n\n // ---- Fetch a single source ----\n const fetchSource = React.useCallback(\n async (\n source: SurfaceDataSourceDefinition,\n state: Record<string, unknown>,\n signal: AbortSignal\n ): Promise<FetchOutcome> => {\n const failed = (err: unknown, status: number | null = null): FetchOutcome => ({\n kind: 'error',\n message: err instanceof Error ? err.message : String(err),\n status,\n // fallback declared → bind it; the error stays visible next to it\n ...(err instanceof SourceFallback ? { fallback: { data: err.data } } : {}),\n })\n\n // State sources read from React state directly\n if (source.kind === 'state') {\n return { kind: 'ok', data: state[source.id], status: null, meta: null }\n }\n\n // Entity sources list records via the platform/entities facade.\n // Returns the items array so {{<id>}} binds directly to the list (e.g. a\n // table's `data`). Refreshed by refreshAll after a form→entity create.\n if (source.kind === 'entity') {\n if (!source.entityType) return { kind: 'ok', data: [], status: null, meta: null }\n\n // A source that names a `connector` routes through the\n // host-provided engine registry when that connection is registered\n // there. Registered-but-failed surfaces the reason as an honest\n // per-source error (`__errors.<id>`), never a crash; an unregistered\n // connection (or no registry at all) falls through to today's\n // default facade path.\n // `{{state.x}}` inside the query resolves against CURRENT state, so\n // a pagination block writing `state.page` or a segmented-control\n // writing `state.severity` reaches `query.pagination` / `query.filter`.\n // Before this, only REST endpoints saw state; connector queries went raw.\n const query = source.query ? (resolveQueryState(source.query, state) as EntityQuery) : undefined\n // An AGGREGATE source asks for one number, never the rows. Its\n // filter resolves against state like `query` does, and the answer\n // binds `{ fn, field?, value, count }` (`{{<id>.value}}`), exempt\n // from the list wrap below. A counter on an intake collection is\n // allowed what a list of it is not, and a public one no longer hands\n // every row to a stranger so the page can count them.\n const aggregate = source.aggregate\n ? (resolveQueryState(source.aggregate, state) as unknown as EntityAggregate)\n : undefined\n const entityType = source.entityType as EntityTypeId\n // Any failure below binds `fallback` (when declared) and still reports\n // the error — see SourceFallback.\n const fail = (message: string): never => {\n if (source.fallback !== undefined) throw new SourceFallback(message, source.fallback)\n throw new Error(message)\n }\n try {\n const engines = connectionsRef.current?.engines\n if (source.connector && engines) {\n const status = engines.getStatus(source.connector)\n if (status.state !== 'unregistered') {\n const engine = await engines.resolve(source.connector)\n if (engine) {\n if (aggregate) {\n const agg = await aggregateThrough(engine, entityType, aggregate)\n if (agg.success) return { kind: 'ok', data: agg.result, status: null, meta: null }\n return fail(agg.error)\n }\n const res = await engine.query(entityType, (query ?? {}) as EntityQuery)\n if (res.success) return { kind: 'ok', data: res.result.items, status: null, meta: null }\n return fail(res.error)\n }\n const failedStatus = engines.getStatus(source.connector)\n return fail(\n failedStatus.state === 'failed'\n ? failedStatus.reason\n : `Connector engine '${source.connector}' unavailable`\n )\n }\n // Declared connector, nothing registered: a pattern shipped without\n // its connection. With a fallback this is the \"sample data\" path;\n // without one, today's facade route stays.\n if (source.fallback !== undefined) {\n return fail(`Connector '${source.connector}' is not connected`)\n }\n }\n\n const facade = entityFacadeRef.current\n if (!facade) {\n return source.fallback !== undefined\n ? fail('No entity facade available')\n : {\n kind: 'ok',\n data: aggregate\n ? { fn: aggregate.fn, ...(aggregate.field ? { field: aggregate.field } : {}), value: null, count: 0 }\n : [],\n status: null,\n meta: null,\n }\n }\n if (aggregate) {\n if (typeof facade.resolveAggregate === 'function') {\n // A count that cannot be served is an error, not a 0: bind\n // `fallback` and report it, same as a failed list.\n try {\n const agg = await facade.resolveAggregate(entityType, aggregate)\n return { kind: 'ok', data: agg, status: null, meta: null }\n } catch (err) {\n return fail(err instanceof Error ? err.message : String(err))\n }\n }\n // A facade from before `resolveAggregate` lists; the rows it\n // returns are reduced here, same as a list-only engine.\n const viaList = await aggregateThrough(\n { query: async (t, q) => ({ success: true, result: await facade.resolveBinding(t, q) }) },\n entityType,\n aggregate\n )\n if (!viaList.success) return fail(viaList.error)\n return { kind: 'ok', data: viaList.result, status: null, meta: null }\n }\n const eds = createEntityDataSource(facade, {\n id: source.id,\n entityType: source.entityType as EntityTypeId,\n ...(query ? { query } : {}),\n })\n try {\n const result = await eds.fetch()\n return { kind: 'ok', data: result.items, status: null, meta: null }\n } catch (err) {\n return fail(err instanceof Error ? err.message : String(err))\n }\n } catch (err) {\n return failed(err)\n }\n }\n\n // Everything else goes through the DataService, registered for THIS state.\n registerSource(source, state)\n const result = await dataService.fetchData(source.id, {\n signal,\n ...(source.headers ? { headers: source.headers } : {}),\n })\n if (result.success) {\n return {\n kind: 'ok',\n data: result.data,\n status: result.metadata.status ?? null,\n meta: result.metadata.envelope ?? null,\n }\n }\n return failed(new Error(result.error.message), result.error.status ?? null)\n },\n [dataService, registerSource]\n )\n\n // ---- Fetch a set of sources for the current state ----\n const fetchSources = React.useCallback(\n async (sources: readonly SurfaceDataSourceDefinition[]) => {\n const state = stateRef.current\n const idle: SurfaceDataSourceDefinition[] = []\n const writeOnlySettled: SurfaceDataSourceDefinition[] = []\n const jobs: { source: SurfaceDataSourceDefinition; controller: AbortController; key: string }[] = []\n for (const source of sources) {\n controllersRef.current.get(source.id)?.abort()\n controllersRef.current.delete(source.id)\n const key = requestKeyOf(source, state)\n requestKeysRef.current[source.id] = key\n if (isIdleSource(source, state)) {\n idle.push(source)\n registerSource(source, state)\n continue\n }\n // A form's write target nothing reads: no list request — not on\n // mount, not after a submit's refreshAll. Still registered, so the\n // form's write through the data service finds it.\n if (writeOnlyRef.current?.has(source.id) === true) {\n writeOnlySettled.push(source)\n registerSource(source, state)\n continue\n }\n const controller = new AbortController()\n controllersRef.current.set(source.id, controller)\n jobs.push({ source, controller, key })\n }\n\n // Idle sources settle at once: no data, not loading, no error. The data\n // of whatever was shown before belongs to another request, so it goes.\n // Fetched sources show their loading flag and keep their data until the\n // answer arrives (a filter change does not blank the list meanwhile).\n setSourceData((prev) => {\n const next = { ...prev }\n for (const source of idle) {\n next[source.id] = { data: null, loading: false, error: null, status: null, meta: null, idle: true, key: requestKeysRef.current[source.id] as string }\n }\n for (const source of writeOnlySettled) {\n next[source.id] = { data: null, loading: false, error: null, status: null, meta: null, key: requestKeysRef.current[source.id] as string }\n }\n for (const { source } of jobs) {\n const p = prev[source.id]\n next[source.id] = {\n data: p?.data ?? null,\n loading: true,\n error: null,\n status: p?.status ?? null,\n meta: p?.meta ?? null,\n ...(p?.key !== undefined ? { key: p.key } : {}),\n }\n }\n return next\n })\n\n await Promise.all(\n jobs.map(async ({ source, controller, key }) => {\n let outcome: FetchOutcome\n try {\n outcome = await fetchSource(source, state, controller.signal)\n } catch (err) {\n outcome = { kind: 'error', message: err instanceof Error ? err.message : String(err), status: null }\n }\n if (controller.signal.aborted) return\n controllersRef.current.delete(source.id)\n setSourceData((prev) => {\n const next = { ...prev }\n if (outcome.kind === 'ok') {\n next[source.id] = { data: outcome.data, loading: false, error: null, status: outcome.status, meta: outcome.meta, key }\n } else {\n const p = prev[source.id]\n // ON ERROR, DATA FROM ANOTHER REQUEST IS CLEARED: a search\n // for cart 999 must not leave cart 1 on screen under the error.\n // The SAME request failing again (a refresh, a poll) keeps its\n // last good answer — that answer is still the right record.\n const keep = p?.key === key\n next[source.id] = {\n data: outcome.fallback ? outcome.fallback.data : keep ? (p?.data ?? null) : null,\n loading: false,\n error: outcome.message,\n status: outcome.status,\n meta: keep ? (p?.meta ?? null) : null,\n ...(keep ? { key } : {}),\n }\n }\n return next\n })\n if (outcome.kind === 'ok') {\n const cacheKey = dataSourceCacheKey(source, state)\n if (cacheKey) dataCacheRef.current?.set(cacheKey, outcome.data)\n }\n })\n )\n\n // A pass whose every fetch was superseded settles nothing; the pass\n // that superseded it will.\n if (jobs.length > 0 && jobs.every((j) => j.controller.signal.aborted)) return\n setInitialLoaded(true)\n },\n [fetchSource, registerSource]\n )\n\n // ---- Fetch every source (refreshAll) ----\n const fetchAllSources = React.useCallback(async () => {\n const sources = sourcesRef.current\n if (!sources || sources.length === 0) {\n setInitialLoaded(true)\n return\n }\n await fetchSources(sources)\n }, [fetchSources])\n\n // ---- Refresh a single source ----\n const refreshSource = React.useCallback(\n async (sourceId: string) => {\n const source = sourcesRef.current?.find((s) => s.id === sourceId)\n if (!source) return\n await fetchSources([source])\n },\n [fetchSources]\n )\n\n // ---- Initial fetch + refetch of the sources whose request changed ----\n React.useEffect(() => {\n const sources = dataSources ?? []\n const present = new Set(sources.map((s) => s.id))\n for (const id of Object.keys(requestKeysRef.current)) {\n if (present.has(id)) continue\n delete requestKeysRef.current[id]\n controllersRef.current.get(id)?.abort()\n controllersRef.current.delete(id)\n if (dataService.hasSource(id)) dataService.unregisterSource(id)\n }\n if (sources.length === 0) {\n setInitialLoaded(true)\n return\n }\n const changed = sources.filter((s) => requestKeyOf(s, surfaceState) !== requestKeysRef.current[s.id])\n if (changed.length > 0) void fetchSources(changed)\n }, [dataSources, surfaceState, fetchSources, dataService])\n\n // ---- Unmount: abort what is in flight, forget what was fetched ----\n // Forgetting matters under StrictMode's mount → unmount → mount: the second\n // mount must fetch again, not believe the aborted first pass succeeded.\n React.useEffect(() => {\n const controllers = controllersRef.current\n return () => {\n for (const controller of controllers.values()) controller.abort()\n controllers.clear()\n requestKeysRef.current = {}\n for (const source of sourcesRef.current ?? []) {\n if (dataService.hasSource(source.id)) dataService.unregisterSource(source.id)\n }\n }\n }, [dataService])\n\n // ---- Auto-refresh intervals ----\n React.useEffect(() => {\n // Inert (editor/preview): never start auto-refresh timers.\n if (!dataSources || interactionMode === 'inert') return\n\n const intervals: ReturnType<typeof setInterval>[] = []\n\n for (const source of dataSources) {\n if (source.refreshInterval && source.refreshInterval > 0) {\n const interval = setInterval(() => {\n void refreshSource(source.id)\n }, source.refreshInterval)\n intervals.push(interval)\n }\n }\n\n return () => {\n for (const interval of intervals) {\n clearInterval(interval)\n }\n }\n }, [dataSources, refreshSource, interactionMode])\n\n // ---- Build expression context ----\n const expressionData = React.useMemo(() => {\n const ctx: Record<string, unknown> = { state: surfaceState }\n // Per-source loading flags for skeleton UIs: `{{__loading.<sourceId>}}` /\n // `{{__anyLoading}}`. A declared source with no sourceData entry yet has\n // not even started its first fetch (the fetch effect runs after first\n // paint) — report it as loading so a skeleton shows from frame one\n // instead of flashing the block's empty state. `state`-kind sources read\n // synchronously from React state and are never \"loading\".\n const loadingMap: Record<string, boolean> = {}\n let anyLoading = false\n // Per-source error messages — `{{__errors.<sourceId>}}` — so a block can\n // distinguish \"fetch failed\" from \"fetched, genuinely empty\" instead of\n // showing a false empty-state. The value is the error MESSAGE string\n // (truthy check + tooltip content in one binding); null when healthy.\n const errorMap: Record<string, string | null> = {}\n let anyError = false\n // `{{__status.<id>}}` — the HTTP status of the last answer (200, 404, …);\n // null for a network failure, an idle source or a non-HTTP kind.\n // `{{__notFound.<id>}}` — status 404, so \"no such order\" and \"connection\n // error\" can be told apart. `{{__idle.<id>}}` — a REST source\n // not fetched because a required path value is empty.\n // `{{__meta.<id>}}` — the envelope `returns` unwrapped the list from\n // (`total`, `skip`, `limit` …); null when there is none.\n const statusMap: Record<string, number | null> = {}\n const notFoundMap: Record<string, boolean> = {}\n const idleMap: Record<string, boolean> = {}\n const metaMap: Record<string, Readonly<Record<string, unknown>> | null> = {}\n for (const source of dataSources ?? []) {\n const entry = sourceData[source.id]\n const loading =\n source.kind === 'state' || writeOnly?.has(source.id) === true ? false : entry ? entry.loading : true\n loadingMap[source.id] = loading\n if (loading) anyLoading = true\n const error = entry?.error ?? null\n errorMap[source.id] = error\n if (error) anyError = true\n const status = entry?.status ?? null\n statusMap[source.id] = status\n notFoundMap[source.id] = status === 404\n idleMap[source.id] = entry?.idle === true\n metaMap[source.id] = entry?.meta ?? null\n }\n /**\n * A LIST SOURCE ALWAYS BINDS AS A LIST.\n *\n * The entity path returns `result.items` — an array. The rest path\n * returned the whole JSON body, or, since `returns` landed, the plucked\n * value. So the same block bound to `{{data.Product}}` received an array\n * from our store and an object from anyone else's, and swapping a model\n * from platform to a connection quietly changed what every bound block\n * got. One shape.\n *\n * `static` and `state` are the documented exceptions and stay untouched:\n * a state source is routinely a scalar, and wrapping it would break every\n * shipped surface that reads one.\n */\n const LIST_KINDS = new Set(['rest', 'entity', 'graphql'])\n const kindById = new Map((dataSources ?? []).map((s) => [s.id, s.kind]))\n // An AGGREGATE source is one number, not a list of one: wrapping\n // `{ value }` into `[{ value }]` would still read through the single-\n // element fallthrough, but `.length` would lie and `count` would hide.\n // Entity-only: that is the one branch that reads `aggregate`; a rest\n // source carrying the key still fetches a list and binds as one.\n const aggregateIds = new Set(\n (dataSources ?? []).filter((s) => s.kind === 'entity' && s.aggregate !== undefined).map((s) => s.id)\n )\n for (const [key, value] of Object.entries(sourceData)) {\n const listy = LIST_KINDS.has(kindById.get(key) ?? '') && !aggregateIds.has(key)\n ctx[key] =\n listy && value.data != null && !Array.isArray(value.data) ? [value.data] : value.data\n }\n ctx['__loading'] = loadingMap\n ctx['__anyLoading'] = anyLoading\n ctx['__errors'] = errorMap\n ctx['__anyError'] = anyError\n ctx['__status'] = statusMap\n ctx['__notFound'] = notFoundMap\n ctx['__idle'] = idleMap\n ctx['__meta'] = metaMap\n return ctx\n }, [surfaceState, sourceData, dataSources, writeOnly])\n\n return {\n expressionData,\n surfaceState,\n initialLoaded,\n setStateValue,\n refreshSource,\n fetchAllSources,\n }\n}\n\n// ============================================================\n// canonicalizeEventType\n// ============================================================\n\n/**\n * Normalize a stored behavior trigger string to canonical colon form.\n * - Already has `:` → return lowercased/trimmed as-is\n * - Has `.` → replace first `.` with `:`\n * - Otherwise → return trimmed lowercased (best-effort; won't match well-formed events)\n */\nexport function canonicalizeEventType(raw: string): string {\n const s = raw.trim().toLowerCase()\n if (s.includes(':')) return s\n if (s.includes('.')) return s.replace('.', ':')\n return s\n}\n\n// ============================================================\n// isSurfaceAction\n// ============================================================\n\nexport function isSurfaceAction(value: unknown): value is SurfaceAction {\n if (!value || typeof value !== 'object') return false\n const obj = value as Record<string, unknown>\n return (\n obj.type === 'setState' ||\n obj.type === 'refresh' ||\n obj.type === 'refreshAll' ||\n obj.type === 'showBlock' ||\n obj.type === 'hideBlock' ||\n obj.type === 'navigate'\n )\n}\n\n/**\n * Guard the `navigate` action against XSS: only http(s) absolute URLs and\n * relative/anchor URLs may be navigated to. A scheme like `javascript:`,\n * `data:`, or `vbscript:` is rejected so a stored behavior cannot execute\n * script in a published-surface visitor's context. Control characters are\n * stripped first to defeat `java\\tscript:`-style scheme smuggling.\n */\nexport function isSafeNavigateUrl(url: unknown): url is string {\n if (typeof url !== 'string') return false\n const stripped = url.replace(/[^!-~]/g, '')\n if (stripped === '') return false\n const scheme = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(stripped)\n if (!scheme) return true // relative path / query / hash / protocol-relative\n const s = (scheme[1] ?? '').toLowerCase()\n return s === 'http' || s === 'https'\n}\n\n// ============================================================\n// DataBoundSurfaceRenderer COMPONENT\n// ============================================================\n\n/**\n * Data-bound surface renderer.\n *\n * If nothing on the surface is dynamic (see surfaceNeedsDataBinding), renders\n * SurfaceRenderer directly (zero overhead).\n * Otherwise, wraps with DataCapabilityProvider for DataService context, then\n * fetches data, manages state, resolves expressions, and intercepts events.\n */\nexport function DataBoundSurfaceRenderer(props: DataBoundSurfaceRendererProps): React.ReactElement {\n const { surface, onEvent, behaviors: hostBehaviors, onNavigateAction, dataServiceConfig, ...rest } = props\n const { blocks, appearance, capabilities } = surface\n // dataSources + initialState + declared behaviors live under platform/persistence config\n const { dataSources, initialState, behaviors: declaredBehaviors } = extractPersistenceSeeds(surface)\n // Declared (JSON) first, host (its store) after — same id in both: host wins.\n const behaviors = React.useMemo<readonly RuntimeBehavior[] | undefined>(() => {\n if (!declaredBehaviors?.length) return hostBehaviors\n if (!hostBehaviors?.length) return declaredBehaviors\n const hostIds = new Set(hostBehaviors.map((b) => b.id))\n return [...declaredBehaviors.filter((b) => !hostIds.has(b.id)), ...hostBehaviors]\n }, [declaredBehaviors, hostBehaviors])\n const hasBehaviors = Boolean(behaviors && behaviors.length > 0)\n\n // Nothing dynamic — no sources, no state, no behaviors, no form bindings, no\n // block action: pass through directly (zero overhead). Write-only surfaces\n // (formBindings without any read source) and state-only wizards must NOT\n // take it — see surfaceNeedsDataBinding() and hasEntityFormBindings().\n if (!hasBehaviors && !surfaceNeedsDataBinding(surface)) {\n const passthrough: RenderableSurface = {\n // `id` FORWARDED, not dropped. SurfaceRenderer derives its scope from\n // `surface.id`: with an id the per-surface rules key off the attribute\n // VALUE (`[data-pw-surface=\"<id>\"]`), without one they fall back to the\n // value-less `[data-pw-surface]` and every surface in a document shares\n // them. Rebuilding the surface object here silently erased the id, so the\n // scoping degraded on this path while looking correct in the source.\n ...(surface.id !== undefined ? { id: surface.id } : {}),\n blocks,\n ...(appearance !== undefined ? { appearance } : {}),\n ...(capabilities !== undefined ? { capabilities } : {}),\n }\n return onEvent ? (\n <SurfaceRenderer surface={passthrough} onEvent={onEvent} {...rest} />\n ) : (\n <SurfaceRenderer surface={passthrough} {...rest} />\n )\n }\n\n // Wrap with DataCapabilityProvider to provide DataService context\n return (\n <DataCapabilityProvider {...(dataServiceConfig ? { config: dataServiceConfig } : {})}>\n {onEvent ? (\n <DataBoundInner\n {...(surface.id !== undefined ? { surfaceId: surface.id } : {})}\n blocks={blocks}\n dataSources={dataSources ?? []}\n initialState={initialState}\n appearance={appearance}\n capabilities={capabilities}\n {...(behaviors !== undefined ? { behaviors } : {})}\n {...(onNavigateAction !== undefined ? { onNavigateAction } : {})}\n onEvent={onEvent}\n rendererProps={rest}\n />\n ) : (\n <DataBoundInner\n {...(surface.id !== undefined ? { surfaceId: surface.id } : {})}\n blocks={blocks}\n dataSources={dataSources ?? []}\n initialState={initialState}\n appearance={appearance}\n capabilities={capabilities}\n {...(behaviors !== undefined ? { behaviors } : {})}\n {...(onNavigateAction !== undefined ? { onNavigateAction } : {})}\n rendererProps={rest}\n />\n )}\n </DataCapabilityProvider>\n )\n}\n\n// ============================================================\n// DataBoundInner (split to allow hooks — needs DataCapabilityProvider ancestor)\n// ============================================================\n\ninterface DataBoundInnerProps {\n /** The surface's scope id — threaded through because this component receives\n * the surface DECOMPOSED into pieces, and `id` was never one of the pieces.\n * Without it the rebuilt surface below has no id and SurfaceRenderer falls\n * back to the value-less `[data-pw-surface]` scope. */\n surfaceId?: string\n blocks: readonly Block[]\n dataSources: readonly SurfaceDataSourceDefinition[]\n initialState: Readonly<Record<string, unknown>> | undefined\n appearance?: RenderableSurface['appearance']\n capabilities?: RenderableSurface['capabilities']\n onEvent?: (event: SurfaceEvent) => void\n behaviors?: readonly RuntimeBehavior[]\n onNavigateAction?: (url: string) => boolean\n rendererProps: Omit<SurfaceRendererProps, 'surface' | 'onEvent'>\n}\n\nfunction DataBoundInner({\n surfaceId,\n blocks,\n dataSources,\n initialState,\n appearance,\n capabilities,\n onEvent,\n behaviors,\n onNavigateAction,\n rendererProps,\n}: DataBoundInnerProps): React.ReactElement {\n const interactionMode = rendererProps.interactionMode ?? 'live'\n const entityFacade = (rendererProps as { entityFacade?: EntityFacade }).entityFacade\n // Same pass-through route as entityFacade: declared on\n // DataBoundSurfaceRendererProps, travels inside rendererProps.\n const loadingStrategy =\n (rendererProps as { loadingStrategy?: 'gate' | 'immediate' }).loadingStrategy ?? 'gate'\n // Connections context travels the same pass-through route\n // (declared on SurfaceRendererProps, so it also reaches SurfaceRenderer's\n // SurfaceConnectionsContext provider via the rendererProps spread below).\n const connections = (rendererProps as { connections?: SurfaceConnectionsValue }).connections\n const dataCache = (rendererProps as { dataCache?: SurfaceDataCache }).dataCache\n // Keyed by the ids, so a re-render that changes nothing hands useSurfaceData\n // the same set (its expression context depends on it).\n const writeOnlyKey = React.useMemo(\n () => [...writeOnlySourceIds({ blocks, dataSources, capabilities, behaviors })].sort().join('\\n'),\n [blocks, dataSources, capabilities, behaviors]\n )\n const writeOnly = React.useMemo<ReadonlySet<string>>(\n () => new Set(writeOnlyKey === '' ? [] : writeOnlyKey.split('\\n')),\n [writeOnlyKey]\n )\n const { expressionData, initialLoaded, setStateValue, refreshSource, fetchAllSources } =\n useSurfaceData(dataSources, initialState, interactionMode, entityFacade, connections, dataCache, writeOnly)\n\n // Resolve expressions in blocks\n const resolvedBlocks = React.useMemo(\n () => resolveBlockExpressions(blocks as Block[], expressionData),\n [blocks, expressionData]\n )\n\n // Shared action dispatcher — handles all six action types\n const dispatchAction = React.useCallback(\n (action: SurfaceAction) => {\n switch (action.type) {\n case 'setState':\n setStateValue(action.key, action.value)\n break\n case 'refresh':\n refreshSource(action.sourceId)\n break\n case 'refreshAll':\n fetchAllSources()\n break\n case 'showBlock':\n setStateValue('__show:' + action.blockId, true)\n break\n case 'hideBlock':\n setStateValue('__show:' + action.blockId, false)\n break\n case 'navigate':\n // Give the host a chance to handle this in place first (e.g. a\n // connected-preview mode swapping to a sibling page) before falling\n // through to a real hard navigation.\n if (onNavigateAction?.(action.url)) break\n if (isSafeNavigateUrl(action.url)) {\n window.location.assign(action.url)\n } else {\n console.warn('[surface] blocked unsafe navigate URL:', action.url)\n }\n break\n }\n },\n [setStateValue, refreshSource, fetchAllSources, onNavigateAction]\n )\n\n // Event interceptor\n const handleEvent = React.useCallback(\n (event: SurfaceEvent) => {\n // Inert (editor/preview): skip block-dispatched surface actions (state\n // mutations / data refreshes) so the surface doesn't mutate its own state\n // while authoring. `onEvent` is a pure notification and STILL fires below\n // — only the real data side-effects are gated.\n if (interactionMode !== 'inert') {\n // Check if the event payload contains a surface action\n const payload = event.payload as Record<string, unknown> | undefined\n const action = payload?.action\n\n if (isSurfaceAction(action)) {\n dispatchAction(action)\n }\n\n // `canonicalType` is normally stamped by the bus bridge (renderer.tsx's\n // busOnEvent), but some deployed block bundles still call\n // `context.onEvent` directly (the pre-bus legacy path) — for those,\n // `canonicalType` is absent. Block-scoped click events reaching here\n // always mean a real click occurred, so treat a canonicalType-less\n // 'click' as 'block:click' rather than silently dropping it.\n const fired = event.canonicalType ?? (event.type === 'click' && event.blockId ? 'block:click' : '')\n\n // A block's own `action` prop (one action or a list, run in order) is\n // what its CLICK does — and only its click. It used to run on every\n // event the block emitted, so a block that also reported hover, focus\n // or a value change would have fired its click action on each of them.\n // Looked up in the RESOLVED tree, so a repeat clone (`id--N`) carries\n // its own row's values.\n if (fired === 'block:click') {\n blockActionsOf(findBlockAction(resolvedBlocks, event.blockId)).forEach(dispatchAction)\n }\n\n // Execute stored behaviors whose trigger matches this canonical event.\n if (behaviors && behaviors.length > 0) {\n for (const b of behaviors) {\n if (canonicalizeEventType(b.event) !== fired) continue\n if (b.targetBlockId && b.targetBlockId !== event.blockId) continue\n b.actions.forEach(dispatchAction)\n }\n }\n }\n\n // Forward to original handler — a pure notification, always fires (the\n // host decides what side-effects, if any, to run).\n onEvent?.(event)\n },\n [interactionMode, onEvent, dispatchAction, resolvedBlocks, behaviors]\n )\n\n // Loading state — 'gate' strategy only (the historical default): the whole\n // block tree is withheld until the first fetch pass settles. 'immediate'\n // skips this and renders the tree at once; unresolved bindings evaluate to\n // undefined and fill in per source (see loadingStrategy prop docs).\n if (!initialLoaded && loadingStrategy !== 'immediate') {\n return (\n <div\n data-surface-loading\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: '48px',\n // Theme-tokened with the old hardcoded values as fallbacks, so the\n // gate no longer paints light-theme blue on a dark-themed surface.\n color: 'var(--pw-color-text-muted, #666)',\n }}\n >\n <div style={{ textAlign: 'center' }}>\n <div\n style={{\n width: '32px',\n height: '32px',\n border: '3px solid var(--pw-color-border, #e5e7eb)',\n borderTopColor: 'var(--pw-color-primary, #3b82f6)',\n borderRadius: '50%',\n animation: 'spin 0.8s linear infinite',\n margin: '0 auto 12px',\n }}\n />\n Loading data...\n </div>\n </div>\n )\n }\n\n const resolvedSurface: RenderableSurface = {\n // See the passthrough branch above — same reason, same one-line omission.\n ...(surfaceId !== undefined ? { id: surfaceId } : {}),\n blocks: resolvedBlocks,\n ...(appearance !== undefined ? { appearance } : {}),\n ...(capabilities !== undefined ? { capabilities } : {}),\n }\n return (\n // What is bound right now, for the providers under SurfaceRenderer that\n // must act on it — the form writer decides create-vs-update from the\n // record a source has loaded, and could not see one before this.\n <SurfaceDataContext.Provider value={expressionData}>\n <SurfaceRenderer surface={resolvedSurface} onEvent={handleEvent} {...rendererProps} />\n </SurfaceDataContext.Provider>\n )\n}\n\n// ============================================================\n// HELPERS\n// ============================================================\n\n/**\n * Find the action prop of a block by ID in the resolved block tree.\n */\nfunction findBlockAction(blocks: readonly Block[], blockId: string): unknown {\n for (const block of blocks) {\n if (block.id === blockId) {\n return block.props?.action\n }\n if (block.children) {\n const found = findBlockAction(block.children, blockId)\n if (found !== undefined) return found\n }\n }\n return undefined\n}\n"]}
1
+ {"version":3,"file":"DataBoundSurfaceRenderer.js","sourceRoot":"","sources":["../../src/render/DataBoundSurfaceRenderer.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAyB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAe1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAI9D,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,+DAA+D;AAC/D,6DAA6D;AAC7D,+DAA+D;AAE/D;;;GAGG;AACH,SAAS,uBAAuB,CAAC,OAEhC;IAKC,MAAM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;GAEG;AACH,SAAS,eAAe,CAAC,MAAwB,EAAE,OAAe;IAChE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,KAAK,EAAE,MAAM,CAAA;QAC5B,CAAC;QACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YACtD,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAA;QACvC,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["/**\n * Data-Bound Surface Renderer\n *\n * Wrapper component that resolves dataSources, state, and {{expression}} props\n * before passing concrete values to the existing SurfaceRenderer.\n *\n * Architecture (post-refactor):\n * Surface JSON (dataSources + state + {{expr}} in props)\n * -> DataBoundSurfaceRenderer\n * -> DataCapabilityProvider (creates DataService instance)\n * -> DataBoundInner\n * -> useSurfaceData: maps SurfaceDataSourceDefinition → DataSourceDefinition,\n * registers with DataService, fetches via DataService, manages React state\n * -> SurfaceRenderer (unchanged)\n * -> Block components (unchanged)\n *\n * Backward compatible: if no dataSources, passes through with zero overhead.\n *\n * @module @pwfabric/runtime/render/DataBoundSurfaceRenderer\n */\n\nimport * as React from 'react'\nimport { SurfaceRenderer } from './renderer.js'\nimport { resolveBlockExpressions } from './resolve-expressions.js'\nimport { endpointMissingPathValue, resolveEndpoint } from './endpoint.js'\nimport { resolveQueryState } from './query-state.js'\nimport { dataSourceCacheKey, type SurfaceDataCache } from './data-cache.js'\nimport { DataCapabilityProvider, useDataService } from '../data/DataCapabilityProvider.js'\nimport type {\n DataBoundSurfaceRendererProps,\n SurfaceDataSourceDefinition,\n SurfaceAction,\n RuntimeBehavior,\n} from './data-binding-types.js'\nimport type {\n SurfaceEvent,\n SurfaceRendererProps,\n RenderableSurface,\n BlockInteractionMode,\n} from './types.js'\nimport type { Block } from '@pwfabric/core'\nimport type { DataSourceDefinition } from '../data/types.js'\nimport { createEntityDataSource } from '../entity/entity-datasource.js'\nimport { aggregateThrough } from '../entity/aggregate.js'\nimport { SurfaceDataContext } from './surface-data-context.js'\nimport type { EntityFacade } from '../entity/facade.js'\nimport type { EntityAggregate, EntityQuery, EntityTypeId } from '../entity/types.js'\nimport type { SurfaceConnectionsValue } from '../connectors/types.js'\nimport { PLATFORM_PERSISTENCE_CAPABILITY_ID } from '@pwfabric/contracts'\nimport { isCapability } from '../capability/type-mapping.js'\nimport { writeOnlySourceIds } from './write-only-sources.js'\n\n// ============================================================\n// extract dataSources + initialState from persistence config\n// ============================================================\n\n/**\n * consolidated these two seeds under the platform/persistence\n * capability config. DataBoundSurfaceRenderer is the sole consumer.\n */\nfunction extractPersistenceSeeds(surface: {\n readonly capabilities?: RenderableSurface['capabilities']\n}): {\n dataSources: readonly SurfaceDataSourceDefinition[] | undefined\n initialState: Readonly<Record<string, unknown>> | undefined\n behaviors: readonly RuntimeBehavior[] | undefined\n} {\n const binding = surface.capabilities?.find(\n (c) => isCapability(c, PLATFORM_PERSISTENCE_CAPABILITY_ID)\n )\n const cfg = binding?.config as\n | {\n dataSources?: readonly SurfaceDataSourceDefinition[]\n initialState?: Readonly<Record<string, unknown>>\n behaviors?: readonly RuntimeBehavior[]\n }\n | undefined\n return {\n dataSources: cfg?.dataSources,\n initialState: cfg?.initialState,\n // Declared behaviors (shipped by a pattern / authored in JSON). The\n // renderer merges these with host-provided behaviors (the host's store) so a pack\n // can carry its own controls without the host knowing about them.\n behaviors: cfg?.behaviors,\n }\n}\n\n/**\n * A source that could not be served but declares a `fallback`: the caller\n * binds `data` AND records `message` under `__errors.<id>`, so the surface\n * renders honestly (sample data + error flag) instead of empty or crashed.\n */\nclass SourceFallback extends Error {\n constructor(\n message: string,\n readonly data: unknown\n ) {\n super(message)\n this.name = 'SourceFallback'\n }\n}\n\n/**\n * A surface whose ONLY dynamic behaviour is writing (platform/entities\n * formBindings, no persistence dataSources) still needs the full data-bound\n * path: the form→entity bridge dispatches statusKeys through setState and the\n * success/error UI hangs off `visibleWhen: \"{{state.x}}\"` — both live in\n * DataBoundInner's state machinery. Before this check, such a surface fell\n * into the zero-overhead passthrough where visibleWhen was never evaluated\n * and, worse, submits were silently lost (proven live against a real\n * SharePoint list: two submits on a formBindings-only page never reached the\n * connector; adding any read source made the identical form work).\n */\nfunction hasEntityFormBindings(surface: {\n readonly capabilities?: RenderableSurface['capabilities']\n}): boolean {\n const entityCap = surface.capabilities?.find((c) => isCapability(c, 'platform/entities'))\n const formBindings = (entityCap?.config as { formBindings?: readonly unknown[] } | undefined)\n ?.formBindings\n return Array.isArray(formBindings) && formBindings.length > 0\n}\n\n/**\n * The actions a block's `action` prop names, in order.\n *\n * One action or a list of them (`[setState step, setState stepError '']`) —\n * a wizard's \"Next\" has to move the step AND clear the previous step's error\n * in one click. Anything that is not a surface action (a form's `action` is\n * its submit URL string) names none.\n */\nexport function blockActionsOf(value: unknown): readonly SurfaceAction[] {\n if (Array.isArray(value)) return value.filter(isSurfaceAction)\n return isSurfaceAction(value) ? [value] : []\n}\n\nfunction blockTreeHasAction(blocks: readonly Block[] | undefined): boolean {\n if (!blocks) return false\n for (const block of blocks) {\n if (blockActionsOf(block.props?.action).length > 0) return true\n if (blockTreeHasAction(block.children)) return true\n }\n return false\n}\n\n/**\n * Does any block carry a condition or a repeat the renderer has to evaluate?\n *\n * `visibleWhen`/`if` and `repeat` are resolved ONLY on the data-bound path.\n * A static page — no source, no state, no action — takes this path too: on\n * the passthrough a condition would never be read, so the shell's empty\n * brand logo would draw as \"⊟ <name> logo\", and a thank-you gated on\n * `{{state.submitted}}` would show before anything was submitted.\n * An empty condition string is no condition, as in resolveBlock.\n */\nfunction blockTreeHasCondition(blocks: readonly Block[] | undefined): boolean {\n if (!blocks) return false\n for (const block of blocks) {\n const b = block as { visibleWhen?: unknown; if?: unknown; repeat?: unknown }\n for (const expr of [b.visibleWhen, b.if, b.repeat]) {\n if (typeof expr === 'string' && expr.trim()) return true\n }\n if (blockTreeHasCondition(block.children)) return true\n }\n return false\n}\n\n/**\n * Does this surface need the data-bound path — state, expression resolution,\n * the action dispatcher — or can it go straight to SurfaceRenderer?\n *\n * ONE ANSWER FOR EVERY HOST. The renderer's own passthrough check and embed's\n * `needsDataBoundRenderer` used to disagree: embed counted `initialState`, the\n * renderer did not. So a wizard page carrying nothing but `initialState` and\n * buttons with `action` props reached the renderer, fell into the passthrough,\n * and there `visibleWhen` was never evaluated, `repeat` never expanded and no\n * `action` was ever dispatched — the buttons were dead. A block `action` alone\n * needs the path too: it is dispatched nowhere else. So does a block\n * `visibleWhen`/`if`/`repeat` (see blockTreeHasCondition).\n *\n * Host-provided behaviors are a prop, not part of the surface, and are\n * checked by the renderer on top of this.\n */\nexport function surfaceNeedsDataBinding(surface: {\n readonly blocks?: readonly Block[]\n readonly capabilities?: RenderableSurface['capabilities']\n}): boolean {\n const { dataSources, initialState, behaviors } = extractPersistenceSeeds(surface)\n return (\n Boolean(dataSources && dataSources.length > 0) ||\n initialState !== undefined ||\n Boolean(behaviors && behaviors.length > 0) ||\n hasEntityFormBindings(surface) ||\n blockTreeHasAction(surface.blocks) ||\n blockTreeHasCondition(surface.blocks)\n )\n}\n\n// ============================================================\n// TYPES\n// ============================================================\n\ninterface SourceData {\n readonly data: unknown\n readonly loading: boolean\n readonly error: string | null\n /** HTTP status of the last answer; null for a network failure or a non-HTTP kind. */\n readonly status?: number | null\n /** The envelope `returns` unwrapped the list from (`total`, `skip`, `limit` …). */\n readonly meta?: Readonly<Record<string, unknown>> | null\n /** Not fetched: a required path value of the endpoint is empty. */\n readonly idle?: boolean\n /** The resolved request `data` answered (see requestKeyOf). */\n readonly key?: string\n}\n\n// ============================================================\n// SURFACE → RUNTIME SOURCE MAPPING\n// ============================================================\n\n/**\n * Maps a JSON-safe SurfaceDataSourceDefinition to a runtime DataSourceDefinition.\n * Returns null for 'state' kind (handled locally via React state, not DataService).\n */\nfunction mapSurfaceSourceToDefinition(\n source: SurfaceDataSourceDefinition,\n currentState: Record<string, unknown>\n): DataSourceDefinition | null {\n switch (source.kind) {\n case 'static':\n return {\n id: source.id,\n kind: 'static',\n staticData: source.staticData,\n // A static source's query was dropped here, so its rows were bound\n // unsorted and unfiltered. Resolved like a rest source's.\n ...(source.query\n ? { query: resolveQueryState(source.query, currentState) as EntityQuery }\n : {}),\n }\n case 'state':\n // State sources read from React state, not managed by DataService\n return null\n case 'rest': {\n if (!source.endpoint) return null\n // `{{state.x}}` placeholders resolve against current state, each value\n // URL-encoded in a mixed endpoint — see resolveEndpoint for why.\n const endpoint = resolveEndpoint(source.endpoint, currentState)\n return {\n id: source.id,\n kind: 'rest' as const,\n endpoint,\n method: source.method ?? 'GET',\n ...(source.headers ? { headers: source.headers } : {}),\n // carry the identity the source names. This branch\n // copied endpoint/method/headers and stopped, so a rest source could\n // declare an identity the fetch would never see.\n ...(source.authProviderRef ? { authProviderRef: source.authProviderRef } : {}),\n // Same omission class as the line above: the source says where its\n // list is and the definition has to carry it, or `fetchRest` hands the\n // binding context a whole JSON body.\n ...(source.returns !== undefined ? { returns: source.returns } : {}),\n // The entity branch resolves `{{state.x}}` inside the query and hands\n // it to the facade; a rest source declared the same query and lost it\n // here. Resolved the same way, applied by the data service after the\n // fetch.\n ...(source.query\n ? { query: resolveQueryState(source.query, currentState) as EntityQuery }\n : {}),\n }\n }\n default:\n return null\n }\n}\n\n// ============================================================\n// useSurfaceData HOOK\n// ============================================================\n\n/**\n * Manages data source fetching, state, and auto-refresh for a data-bound surface.\n *\n * Delegates fetch mechanics to DataService via context.\n * Keeps React state management and expression resolution locally.\n */\ninterface SurfaceDataResult {\n expressionData: Record<string, unknown>\n surfaceState: Record<string, unknown>\n initialLoaded: boolean\n setStateValue: (key: string, value: unknown) => void\n refreshSource: (sourceId: string) => Promise<void>\n fetchAllSources: () => Promise<void>\n}\n\n/** What one fetch of one source came to. */\ntype FetchOutcome =\n | { readonly kind: 'ok'; readonly data: unknown; readonly status: number | null; readonly meta: Readonly<Record<string, unknown>> | null }\n | { readonly kind: 'error'; readonly message: string; readonly status: number | null; readonly fallback?: { readonly data: unknown } }\n\n/** JSON of a source DEFINITION, computed once per definition object. */\nconst definitionJsonCache = new WeakMap<object, string>()\nlet unserialisable = 0\n\nfunction safeJson(value: unknown): string {\n try {\n return JSON.stringify(value) ?? 'undefined'\n } catch {\n // A value that cannot be serialised can never be proven unchanged.\n return `#unserialisable-${++unserialisable}`\n }\n}\n\nfunction definitionJson(source: SurfaceDataSourceDefinition): string {\n let json = definitionJsonCache.get(source)\n if (json === undefined) {\n json = safeJson(source)\n definitionJsonCache.set(source, json)\n }\n return json\n}\n\n/** A REST source whose required path value is empty is not fetched. */\nfunction isIdleSource(source: SurfaceDataSourceDefinition, state: Readonly<Record<string, unknown>>): boolean {\n return source.kind === 'rest' && Boolean(source.endpoint) && endpointMissingPathValue(source.endpoint as string, state)\n}\n\n/**\n * EVERYTHING THAT DECIDES WHAT A SOURCE FETCHES, AS ONE STRING.\n *\n * The definition itself plus whatever it reads from state, RESOLVED: the REST\n * address, the query with its `{{state.*}}` placeholders filled in, a state\n * source's value. A source is refetched when — and only when — this changes.\n *\n * Refetching every source on every `setState` would make a search box writing\n * `state.searchDraft` on each keystroke refetch the product list AND the\n * cart, flashing both loading states, and a menu toggle refetch the whole\n * page. Dependency tracking on the resolved request is exact where\n * key-name extraction is not: `{{state.a ? state.b : state.c}}` depends on `c`\n * only while `a` is false, and the resolved value knows that.\n */\nfunction requestKeyOf(source: SurfaceDataSourceDefinition, state: Readonly<Record<string, unknown>>): string {\n const def = definitionJson(source)\n switch (source.kind) {\n case 'rest': {\n if (!source.endpoint) return def\n if (isIdleSource(source, state)) return `${def}|idle`\n const query = source.query ? safeJson(resolveQueryState(source.query, state)) : ''\n return `${def}|${resolveEndpoint(source.endpoint, state)}|${query}`\n }\n case 'entity': {\n const query = source.query ? safeJson(resolveQueryState(source.query, state)) : ''\n // The resolved aggregate too: a counter whose filter reads\n // `{{state.status}}` must ask again when the status changes.\n const aggregate = source.aggregate ? safeJson(resolveQueryState(source.aggregate, state)) : ''\n return `${def}|${query}|${aggregate}`\n }\n case 'state':\n return `${def}|${safeJson(state[source.id])}`\n case 'static':\n // A query reading `{{state.x}}` re-applies when x changes.\n return source.query ? `${def}|${safeJson(resolveQueryState(source.query, state))}` : def\n default:\n return def\n }\n}\n\nfunction useSurfaceData(\n dataSources: readonly SurfaceDataSourceDefinition[] | undefined,\n initialState: Readonly<Record<string, unknown>> | undefined,\n interactionMode: BlockInteractionMode = 'live',\n entityFacade?: EntityFacade,\n connections?: SurfaceConnectionsValue,\n dataCache?: SurfaceDataCache,\n /** Sources only a form writes to (see write-only-sources): settled, never fetched. */\n writeOnly?: ReadonlySet<string>\n): SurfaceDataResult {\n const dataService = useDataService()\n const writeOnlyRef = React.useRef(writeOnly)\n writeOnlyRef.current = writeOnly\n const dataCacheRef = React.useRef(dataCache)\n dataCacheRef.current = dataCache\n\n // State store\n const [surfaceState, setSurfaceState] = React.useState<Record<string, unknown>>(() => ({\n ...initialState,\n }))\n\n // Source data store — seeded from the host's cache when it has yesterday's\n // rows for a source, so the first frame is not an empty table. The seed is\n // marked loading: the fetch that follows is what makes it today's.\n const [sourceData, setSourceData] = React.useState<Record<string, SourceData>>(() => {\n if (!dataCache || !dataSources) return {}\n const seeded: Record<string, SourceData> = {}\n for (const source of dataSources) {\n const key = dataSourceCacheKey(source, initialState ?? {})\n if (!key) continue\n const hit = dataCache.get(key)\n if (hit !== undefined) {\n seeded[source.id] = { data: hit, loading: true, error: null, key: requestKeyOf(source, initialState ?? {}) }\n }\n }\n return seeded\n })\n // Track whether initial fetch is complete. A page whose every fetched\n // source came out of the cache counts as loaded: the gate has nothing to\n // wait for that the visitor has not already seen.\n const [initialLoaded, setInitialLoaded] = React.useState(() => {\n if (!dataCache || !dataSources) return false\n const fetched = dataSources.filter((s) => dataSourceCacheKey(s, initialState ?? {}) !== undefined)\n return fetched.length > 0 && fetched.every((s) => dataCache.get(dataSourceCacheKey(s, initialState ?? {})!) !== undefined)\n })\n\n // Stable ref to current state for use in fetch callbacks\n const stateRef = React.useRef(surfaceState)\n stateRef.current = surfaceState\n\n // Stable ref to sources\n const sourcesRef = React.useRef(dataSources)\n sourcesRef.current = dataSources\n\n // Stable ref to the entity facade (kind:'entity' sources query through it)\n const entityFacadeRef = React.useRef(entityFacade)\n entityFacadeRef.current = entityFacade\n\n // Stable ref to the connections context (kind:'entity'\n // sources with a `connector` route through the engine registry)\n const connectionsRef = React.useRef(connections)\n connectionsRef.current = connections\n\n /** The request each source was last fetched (or marked idle) for. */\n const requestKeysRef = React.useRef<Record<string, string>>({})\n /** The in-flight fetch of each source — a newer one aborts it. */\n const controllersRef = React.useRef(new Map<string, AbortController>())\n\n // ---- setState action ----\n // Writing the value a key already holds changes nothing, so it renders\n // nothing and fetches nothing.\n const setStateValue = React.useCallback((key: string, value: unknown) => {\n setSurfaceState((prev) => {\n if (prev[key] === value) return prev\n return { ...prev, [key]: value }\n })\n }, [])\n\n // ---- (Re-)register a source's definition for the current state ----\n // Registered even when the source is idle, so a form or a behavior writing\n // to it through the data service still finds it.\n const registerSource = React.useCallback(\n (source: SurfaceDataSourceDefinition, state: Record<string, unknown>) => {\n if (dataService.hasSource(source.id)) dataService.unregisterSource(source.id)\n const definition = mapSurfaceSourceToDefinition(source, state)\n if (definition) dataService.registerSource(definition)\n },\n [dataService]\n )\n\n // ---- Fetch a single source ----\n const fetchSource = React.useCallback(\n async (\n source: SurfaceDataSourceDefinition,\n state: Record<string, unknown>,\n signal: AbortSignal\n ): Promise<FetchOutcome> => {\n const failed = (err: unknown, status: number | null = null): FetchOutcome => ({\n kind: 'error',\n message: err instanceof Error ? err.message : String(err),\n status,\n // fallback declared → bind it; the error stays visible next to it\n ...(err instanceof SourceFallback ? { fallback: { data: err.data } } : {}),\n })\n\n // State sources read from React state directly\n if (source.kind === 'state') {\n return { kind: 'ok', data: state[source.id], status: null, meta: null }\n }\n\n // Entity sources list records via the platform/entities facade.\n // Returns the items array so {{<id>}} binds directly to the list (e.g. a\n // table's `data`). Refreshed by refreshAll after a form→entity create.\n if (source.kind === 'entity') {\n if (!source.entityType) return { kind: 'ok', data: [], status: null, meta: null }\n\n // A source that names a `connector` routes through the\n // host-provided engine registry when that connection is registered\n // there. Registered-but-failed surfaces the reason as an honest\n // per-source error (`__errors.<id>`), never a crash; an unregistered\n // connection (or no registry at all) falls through to today's\n // default facade path.\n // `{{state.x}}` inside the query resolves against CURRENT state, so\n // a pagination block writing `state.page` or a segmented-control\n // writing `state.severity` reaches `query.pagination` / `query.filter`.\n // Before this, only REST endpoints saw state; connector queries went raw.\n const query = source.query ? (resolveQueryState(source.query, state) as EntityQuery) : undefined\n // An AGGREGATE source asks for one number, never the rows. Its\n // filter resolves against state like `query` does, and the answer\n // binds `{ fn, field?, value, count }` (`{{<id>.value}}`), exempt\n // from the list wrap below. A counter on an intake collection is\n // allowed what a list of it is not, and a public one no longer hands\n // every row to a stranger so the page can count them.\n const aggregate = source.aggregate\n ? (resolveQueryState(source.aggregate, state) as unknown as EntityAggregate)\n : undefined\n const entityType = source.entityType as EntityTypeId\n // Any failure below binds `fallback` (when declared) and still reports\n // the error — see SourceFallback.\n const fail = (message: string): never => {\n if (source.fallback !== undefined) throw new SourceFallback(message, source.fallback)\n throw new Error(message)\n }\n try {\n const engines = connectionsRef.current?.engines\n if (source.connector && engines) {\n const status = engines.getStatus(source.connector)\n if (status.state !== 'unregistered') {\n const engine = await engines.resolve(source.connector)\n if (engine) {\n if (aggregate) {\n const agg = await aggregateThrough(engine, entityType, aggregate)\n if (agg.success) return { kind: 'ok', data: agg.result, status: null, meta: null }\n return fail(agg.error)\n }\n const res = await engine.query(entityType, (query ?? {}) as EntityQuery)\n if (res.success) return { kind: 'ok', data: res.result.items, status: null, meta: null }\n return fail(res.error)\n }\n const failedStatus = engines.getStatus(source.connector)\n return fail(\n failedStatus.state === 'failed'\n ? failedStatus.reason\n : `Connector engine '${source.connector}' unavailable`\n )\n }\n // Declared connector, nothing registered: a pattern shipped without\n // its connection. With a fallback this is the \"sample data\" path;\n // without one, today's facade route stays.\n if (source.fallback !== undefined) {\n return fail(`Connector '${source.connector}' is not connected`)\n }\n }\n\n const facade = entityFacadeRef.current\n if (!facade) {\n return source.fallback !== undefined\n ? fail('No entity facade available')\n : {\n kind: 'ok',\n data: aggregate\n ? { fn: aggregate.fn, ...(aggregate.field ? { field: aggregate.field } : {}), value: null, count: 0 }\n : [],\n status: null,\n meta: null,\n }\n }\n if (aggregate) {\n if (typeof facade.resolveAggregate === 'function') {\n // A count that cannot be served is an error, not a 0: bind\n // `fallback` and report it, same as a failed list.\n try {\n const agg = await facade.resolveAggregate(entityType, aggregate)\n return { kind: 'ok', data: agg, status: null, meta: null }\n } catch (err) {\n return fail(err instanceof Error ? err.message : String(err))\n }\n }\n // A facade from before `resolveAggregate` lists; the rows it\n // returns are reduced here, same as a list-only engine.\n const viaList = await aggregateThrough(\n { query: async (t, q) => ({ success: true, result: await facade.resolveBinding(t, q) }) },\n entityType,\n aggregate\n )\n if (!viaList.success) return fail(viaList.error)\n return { kind: 'ok', data: viaList.result, status: null, meta: null }\n }\n const eds = createEntityDataSource(facade, {\n id: source.id,\n entityType: source.entityType as EntityTypeId,\n ...(query ? { query } : {}),\n })\n try {\n const result = await eds.fetch()\n return { kind: 'ok', data: result.items, status: null, meta: null }\n } catch (err) {\n return fail(err instanceof Error ? err.message : String(err))\n }\n } catch (err) {\n return failed(err)\n }\n }\n\n // Everything else goes through the DataService, registered for THIS state.\n registerSource(source, state)\n const result = await dataService.fetchData(source.id, {\n signal,\n ...(source.headers ? { headers: source.headers } : {}),\n })\n if (result.success) {\n return {\n kind: 'ok',\n data: result.data,\n status: result.metadata.status ?? null,\n meta: result.metadata.envelope ?? null,\n }\n }\n return failed(new Error(result.error.message), result.error.status ?? null)\n },\n [dataService, registerSource]\n )\n\n // ---- Fetch a set of sources for the current state ----\n const fetchSources = React.useCallback(\n async (sources: readonly SurfaceDataSourceDefinition[]) => {\n const state = stateRef.current\n const idle: SurfaceDataSourceDefinition[] = []\n const writeOnlySettled: SurfaceDataSourceDefinition[] = []\n const jobs: { source: SurfaceDataSourceDefinition; controller: AbortController; key: string }[] = []\n for (const source of sources) {\n controllersRef.current.get(source.id)?.abort()\n controllersRef.current.delete(source.id)\n const key = requestKeyOf(source, state)\n requestKeysRef.current[source.id] = key\n if (isIdleSource(source, state)) {\n idle.push(source)\n registerSource(source, state)\n continue\n }\n // A form's write target nothing reads: no list request — not on\n // mount, not after a submit's refreshAll. Still registered, so the\n // form's write through the data service finds it.\n if (writeOnlyRef.current?.has(source.id) === true) {\n writeOnlySettled.push(source)\n registerSource(source, state)\n continue\n }\n const controller = new AbortController()\n controllersRef.current.set(source.id, controller)\n jobs.push({ source, controller, key })\n }\n\n // Idle sources settle at once: no data, not loading, no error. The data\n // of whatever was shown before belongs to another request, so it goes.\n // Fetched sources show their loading flag and keep their data until the\n // answer arrives (a filter change does not blank the list meanwhile).\n setSourceData((prev) => {\n const next = { ...prev }\n for (const source of idle) {\n next[source.id] = { data: null, loading: false, error: null, status: null, meta: null, idle: true, key: requestKeysRef.current[source.id] as string }\n }\n for (const source of writeOnlySettled) {\n next[source.id] = { data: null, loading: false, error: null, status: null, meta: null, key: requestKeysRef.current[source.id] as string }\n }\n for (const { source } of jobs) {\n const p = prev[source.id]\n next[source.id] = {\n data: p?.data ?? null,\n loading: true,\n error: null,\n status: p?.status ?? null,\n meta: p?.meta ?? null,\n ...(p?.key !== undefined ? { key: p.key } : {}),\n }\n }\n return next\n })\n\n await Promise.all(\n jobs.map(async ({ source, controller, key }) => {\n let outcome: FetchOutcome\n try {\n outcome = await fetchSource(source, state, controller.signal)\n } catch (err) {\n outcome = { kind: 'error', message: err instanceof Error ? err.message : String(err), status: null }\n }\n if (controller.signal.aborted) return\n controllersRef.current.delete(source.id)\n setSourceData((prev) => {\n const next = { ...prev }\n if (outcome.kind === 'ok') {\n next[source.id] = { data: outcome.data, loading: false, error: null, status: outcome.status, meta: outcome.meta, key }\n } else {\n const p = prev[source.id]\n // ON ERROR, DATA FROM ANOTHER REQUEST IS CLEARED: a search\n // for cart 999 must not leave cart 1 on screen under the error.\n // The SAME request failing again (a refresh, a poll) keeps its\n // last good answer — that answer is still the right record.\n const keep = p?.key === key\n next[source.id] = {\n data: outcome.fallback ? outcome.fallback.data : keep ? (p?.data ?? null) : null,\n loading: false,\n error: outcome.message,\n status: outcome.status,\n meta: keep ? (p?.meta ?? null) : null,\n ...(keep ? { key } : {}),\n }\n }\n return next\n })\n if (outcome.kind === 'ok') {\n const cacheKey = dataSourceCacheKey(source, state)\n if (cacheKey) dataCacheRef.current?.set(cacheKey, outcome.data)\n }\n })\n )\n\n // A pass whose every fetch was superseded settles nothing; the pass\n // that superseded it will.\n if (jobs.length > 0 && jobs.every((j) => j.controller.signal.aborted)) return\n setInitialLoaded(true)\n },\n [fetchSource, registerSource]\n )\n\n // ---- Fetch every source (refreshAll) ----\n const fetchAllSources = React.useCallback(async () => {\n const sources = sourcesRef.current\n if (!sources || sources.length === 0) {\n setInitialLoaded(true)\n return\n }\n await fetchSources(sources)\n }, [fetchSources])\n\n // ---- Refresh a single source ----\n const refreshSource = React.useCallback(\n async (sourceId: string) => {\n const source = sourcesRef.current?.find((s) => s.id === sourceId)\n if (!source) return\n await fetchSources([source])\n },\n [fetchSources]\n )\n\n // ---- Initial fetch + refetch of the sources whose request changed ----\n React.useEffect(() => {\n const sources = dataSources ?? []\n const present = new Set(sources.map((s) => s.id))\n for (const id of Object.keys(requestKeysRef.current)) {\n if (present.has(id)) continue\n delete requestKeysRef.current[id]\n controllersRef.current.get(id)?.abort()\n controllersRef.current.delete(id)\n if (dataService.hasSource(id)) dataService.unregisterSource(id)\n }\n if (sources.length === 0) {\n setInitialLoaded(true)\n return\n }\n const changed = sources.filter((s) => requestKeyOf(s, surfaceState) !== requestKeysRef.current[s.id])\n if (changed.length > 0) void fetchSources(changed)\n }, [dataSources, surfaceState, fetchSources, dataService])\n\n // ---- Unmount: abort what is in flight, forget what was fetched ----\n // Forgetting matters under StrictMode's mount → unmount → mount: the second\n // mount must fetch again, not believe the aborted first pass succeeded.\n React.useEffect(() => {\n const controllers = controllersRef.current\n return () => {\n for (const controller of controllers.values()) controller.abort()\n controllers.clear()\n requestKeysRef.current = {}\n for (const source of sourcesRef.current ?? []) {\n if (dataService.hasSource(source.id)) dataService.unregisterSource(source.id)\n }\n }\n }, [dataService])\n\n // ---- Auto-refresh intervals ----\n React.useEffect(() => {\n // Inert (editor/preview): never start auto-refresh timers.\n if (!dataSources || interactionMode === 'inert') return\n\n const intervals: ReturnType<typeof setInterval>[] = []\n\n for (const source of dataSources) {\n if (source.refreshInterval && source.refreshInterval > 0) {\n const interval = setInterval(() => {\n void refreshSource(source.id)\n }, source.refreshInterval)\n intervals.push(interval)\n }\n }\n\n return () => {\n for (const interval of intervals) {\n clearInterval(interval)\n }\n }\n }, [dataSources, refreshSource, interactionMode])\n\n // ---- Build expression context ----\n const expressionData = React.useMemo(() => {\n const ctx: Record<string, unknown> = { state: surfaceState }\n // Per-source loading flags for skeleton UIs: `{{__loading.<sourceId>}}` /\n // `{{__anyLoading}}`. A declared source with no sourceData entry yet has\n // not even started its first fetch (the fetch effect runs after first\n // paint) — report it as loading so a skeleton shows from frame one\n // instead of flashing the block's empty state. `state`-kind sources read\n // synchronously from React state and are never \"loading\".\n const loadingMap: Record<string, boolean> = {}\n let anyLoading = false\n // Per-source error messages — `{{__errors.<sourceId>}}` — so a block can\n // distinguish \"fetch failed\" from \"fetched, genuinely empty\" instead of\n // showing a false empty-state. The value is the error MESSAGE string\n // (truthy check + tooltip content in one binding); null when healthy.\n const errorMap: Record<string, string | null> = {}\n let anyError = false\n // `{{__status.<id>}}` — the HTTP status of the last answer (200, 404, …);\n // null for a network failure, an idle source or a non-HTTP kind.\n // `{{__notFound.<id>}}` — status 404, so \"no such order\" and \"connection\n // error\" can be told apart. `{{__idle.<id>}}` — a REST source\n // not fetched because a required path value is empty.\n // `{{__meta.<id>}}` — the envelope `returns` unwrapped the list from\n // (`total`, `skip`, `limit` …); null when there is none.\n const statusMap: Record<string, number | null> = {}\n const notFoundMap: Record<string, boolean> = {}\n const idleMap: Record<string, boolean> = {}\n const metaMap: Record<string, Readonly<Record<string, unknown>> | null> = {}\n for (const source of dataSources ?? []) {\n const entry = sourceData[source.id]\n const loading =\n source.kind === 'state' || writeOnly?.has(source.id) === true ? false : entry ? entry.loading : true\n loadingMap[source.id] = loading\n if (loading) anyLoading = true\n const error = entry?.error ?? null\n errorMap[source.id] = error\n if (error) anyError = true\n const status = entry?.status ?? null\n statusMap[source.id] = status\n notFoundMap[source.id] = status === 404\n idleMap[source.id] = entry?.idle === true\n metaMap[source.id] = entry?.meta ?? null\n }\n /**\n * A LIST SOURCE ALWAYS BINDS AS A LIST.\n *\n * The entity path returns `result.items` — an array. The rest path\n * returned the whole JSON body, or, since `returns` landed, the plucked\n * value. So the same block bound to `{{data.Product}}` received an array\n * from our store and an object from anyone else's, and swapping a model\n * from platform to a connection quietly changed what every bound block\n * got. One shape.\n *\n * `static` and `state` are the documented exceptions and stay untouched:\n * a state source is routinely a scalar, and wrapping it would break every\n * shipped surface that reads one.\n */\n const LIST_KINDS = new Set(['rest', 'entity', 'graphql'])\n const kindById = new Map((dataSources ?? []).map((s) => [s.id, s.kind]))\n // An AGGREGATE source is one number, not a list of one: wrapping\n // `{ value }` into `[{ value }]` would still read through the single-\n // element fallthrough, but `.length` would lie and `count` would hide.\n // Entity-only: that is the one branch that reads `aggregate`; a rest\n // source carrying the key still fetches a list and binds as one.\n const aggregateIds = new Set(\n (dataSources ?? []).filter((s) => s.kind === 'entity' && s.aggregate !== undefined).map((s) => s.id)\n )\n for (const [key, value] of Object.entries(sourceData)) {\n const listy = LIST_KINDS.has(kindById.get(key) ?? '') && !aggregateIds.has(key)\n ctx[key] =\n listy && value.data != null && !Array.isArray(value.data) ? [value.data] : value.data\n }\n ctx['__loading'] = loadingMap\n ctx['__anyLoading'] = anyLoading\n ctx['__errors'] = errorMap\n ctx['__anyError'] = anyError\n ctx['__status'] = statusMap\n ctx['__notFound'] = notFoundMap\n ctx['__idle'] = idleMap\n ctx['__meta'] = metaMap\n return ctx\n }, [surfaceState, sourceData, dataSources, writeOnly])\n\n return {\n expressionData,\n surfaceState,\n initialLoaded,\n setStateValue,\n refreshSource,\n fetchAllSources,\n }\n}\n\n// ============================================================\n// canonicalizeEventType\n// ============================================================\n\n/**\n * Normalize a stored behavior trigger string to canonical colon form.\n * - Already has `:` → return lowercased/trimmed as-is\n * - Has `.` → replace first `.` with `:`\n * - Otherwise → return trimmed lowercased (best-effort; won't match well-formed events)\n */\nexport function canonicalizeEventType(raw: string): string {\n const s = raw.trim().toLowerCase()\n if (s.includes(':')) return s\n if (s.includes('.')) return s.replace('.', ':')\n return s\n}\n\n// ============================================================\n// isSurfaceAction\n// ============================================================\n\nexport function isSurfaceAction(value: unknown): value is SurfaceAction {\n if (!value || typeof value !== 'object') return false\n const obj = value as Record<string, unknown>\n return (\n obj.type === 'setState' ||\n obj.type === 'refresh' ||\n obj.type === 'refreshAll' ||\n obj.type === 'showBlock' ||\n obj.type === 'hideBlock' ||\n obj.type === 'navigate'\n )\n}\n\n/**\n * Guard the `navigate` action against XSS: only http(s) absolute URLs and\n * relative/anchor URLs may be navigated to. A scheme like `javascript:`,\n * `data:`, or `vbscript:` is rejected so a stored behavior cannot execute\n * script in a published-surface visitor's context. Control characters are\n * stripped first to defeat `java\\tscript:`-style scheme smuggling.\n */\nexport function isSafeNavigateUrl(url: unknown): url is string {\n if (typeof url !== 'string') return false\n const stripped = url.replace(/[^!-~]/g, '')\n if (stripped === '') return false\n const scheme = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(stripped)\n if (!scheme) return true // relative path / query / hash / protocol-relative\n const s = (scheme[1] ?? '').toLowerCase()\n return s === 'http' || s === 'https'\n}\n\n// ============================================================\n// DataBoundSurfaceRenderer COMPONENT\n// ============================================================\n\n/**\n * Data-bound surface renderer.\n *\n * If nothing on the surface is dynamic (see surfaceNeedsDataBinding), renders\n * SurfaceRenderer directly (zero overhead).\n * Otherwise, wraps with DataCapabilityProvider for DataService context, then\n * fetches data, manages state, resolves expressions, and intercepts events.\n */\nexport function DataBoundSurfaceRenderer(props: DataBoundSurfaceRendererProps): React.ReactElement {\n const { surface, onEvent, behaviors: hostBehaviors, onNavigateAction, dataServiceConfig, ...rest } = props\n const { blocks, appearance, capabilities } = surface\n // dataSources + initialState + declared behaviors live under platform/persistence config\n const { dataSources, initialState, behaviors: declaredBehaviors } = extractPersistenceSeeds(surface)\n // Declared (JSON) first, host (its store) after — same id in both: host wins.\n const behaviors = React.useMemo<readonly RuntimeBehavior[] | undefined>(() => {\n if (!declaredBehaviors?.length) return hostBehaviors\n if (!hostBehaviors?.length) return declaredBehaviors\n const hostIds = new Set(hostBehaviors.map((b) => b.id))\n return [...declaredBehaviors.filter((b) => !hostIds.has(b.id)), ...hostBehaviors]\n }, [declaredBehaviors, hostBehaviors])\n const hasBehaviors = Boolean(behaviors && behaviors.length > 0)\n\n // Nothing dynamic — no sources, no state, no behaviors, no form bindings, no\n // block action: pass through directly (zero overhead). Write-only surfaces\n // (formBindings without any read source) and state-only wizards must NOT\n // take it — see surfaceNeedsDataBinding() and hasEntityFormBindings().\n if (!hasBehaviors && !surfaceNeedsDataBinding(surface)) {\n const passthrough: RenderableSurface = {\n // `id` FORWARDED, not dropped. SurfaceRenderer derives its scope from\n // `surface.id`: with an id the per-surface rules key off the attribute\n // VALUE (`[data-pw-surface=\"<id>\"]`), without one they fall back to the\n // value-less `[data-pw-surface]` and every surface in a document shares\n // them. Rebuilding the surface object here silently erased the id, so the\n // scoping degraded on this path while looking correct in the source.\n ...(surface.id !== undefined ? { id: surface.id } : {}),\n blocks,\n ...(appearance !== undefined ? { appearance } : {}),\n ...(capabilities !== undefined ? { capabilities } : {}),\n }\n return onEvent ? (\n <SurfaceRenderer surface={passthrough} onEvent={onEvent} {...rest} />\n ) : (\n <SurfaceRenderer surface={passthrough} {...rest} />\n )\n }\n\n // Wrap with DataCapabilityProvider to provide DataService context\n return (\n <DataCapabilityProvider {...(dataServiceConfig ? { config: dataServiceConfig } : {})}>\n {onEvent ? (\n <DataBoundInner\n {...(surface.id !== undefined ? { surfaceId: surface.id } : {})}\n blocks={blocks}\n dataSources={dataSources ?? []}\n initialState={initialState}\n appearance={appearance}\n capabilities={capabilities}\n {...(behaviors !== undefined ? { behaviors } : {})}\n {...(onNavigateAction !== undefined ? { onNavigateAction } : {})}\n onEvent={onEvent}\n rendererProps={rest}\n />\n ) : (\n <DataBoundInner\n {...(surface.id !== undefined ? { surfaceId: surface.id } : {})}\n blocks={blocks}\n dataSources={dataSources ?? []}\n initialState={initialState}\n appearance={appearance}\n capabilities={capabilities}\n {...(behaviors !== undefined ? { behaviors } : {})}\n {...(onNavigateAction !== undefined ? { onNavigateAction } : {})}\n rendererProps={rest}\n />\n )}\n </DataCapabilityProvider>\n )\n}\n\n// ============================================================\n// DataBoundInner (split to allow hooks — needs DataCapabilityProvider ancestor)\n// ============================================================\n\ninterface DataBoundInnerProps {\n /** The surface's scope id — threaded through because this component receives\n * the surface DECOMPOSED into pieces, and `id` was never one of the pieces.\n * Without it the rebuilt surface below has no id and SurfaceRenderer falls\n * back to the value-less `[data-pw-surface]` scope. */\n surfaceId?: string\n blocks: readonly Block[]\n dataSources: readonly SurfaceDataSourceDefinition[]\n initialState: Readonly<Record<string, unknown>> | undefined\n appearance?: RenderableSurface['appearance']\n capabilities?: RenderableSurface['capabilities']\n onEvent?: (event: SurfaceEvent) => void\n behaviors?: readonly RuntimeBehavior[]\n onNavigateAction?: (url: string) => boolean\n rendererProps: Omit<SurfaceRendererProps, 'surface' | 'onEvent'>\n}\n\nfunction DataBoundInner({\n surfaceId,\n blocks,\n dataSources,\n initialState,\n appearance,\n capabilities,\n onEvent,\n behaviors,\n onNavigateAction,\n rendererProps,\n}: DataBoundInnerProps): React.ReactElement {\n const interactionMode = rendererProps.interactionMode ?? 'live'\n const entityFacade = (rendererProps as { entityFacade?: EntityFacade }).entityFacade\n // Same pass-through route as entityFacade: declared on\n // DataBoundSurfaceRendererProps, travels inside rendererProps.\n const loadingStrategy =\n (rendererProps as { loadingStrategy?: 'gate' | 'immediate' }).loadingStrategy ?? 'gate'\n // Connections context travels the same pass-through route\n // (declared on SurfaceRendererProps, so it also reaches SurfaceRenderer's\n // SurfaceConnectionsContext provider via the rendererProps spread below).\n const connections = (rendererProps as { connections?: SurfaceConnectionsValue }).connections\n const dataCache = (rendererProps as { dataCache?: SurfaceDataCache }).dataCache\n // Keyed by the ids, so a re-render that changes nothing hands useSurfaceData\n // the same set (its expression context depends on it).\n const writeOnlyKey = React.useMemo(\n () => [...writeOnlySourceIds({ blocks, dataSources, capabilities, behaviors })].sort().join('\\n'),\n [blocks, dataSources, capabilities, behaviors]\n )\n const writeOnly = React.useMemo<ReadonlySet<string>>(\n () => new Set(writeOnlyKey === '' ? [] : writeOnlyKey.split('\\n')),\n [writeOnlyKey]\n )\n const { expressionData, initialLoaded, setStateValue, refreshSource, fetchAllSources } =\n useSurfaceData(dataSources, initialState, interactionMode, entityFacade, connections, dataCache, writeOnly)\n\n // Resolve expressions in blocks\n const resolvedBlocks = React.useMemo(\n () => resolveBlockExpressions(blocks as Block[], expressionData),\n [blocks, expressionData]\n )\n\n // Shared action dispatcher — handles all six action types\n const dispatchAction = React.useCallback(\n (action: SurfaceAction) => {\n switch (action.type) {\n case 'setState':\n setStateValue(action.key, action.value)\n break\n case 'refresh':\n refreshSource(action.sourceId)\n break\n case 'refreshAll':\n fetchAllSources()\n break\n case 'showBlock':\n setStateValue('__show:' + action.blockId, true)\n break\n case 'hideBlock':\n setStateValue('__show:' + action.blockId, false)\n break\n case 'navigate':\n // Give the host a chance to handle this in place first (e.g. a\n // connected-preview mode swapping to a sibling page) before falling\n // through to a real hard navigation.\n if (onNavigateAction?.(action.url)) break\n if (isSafeNavigateUrl(action.url)) {\n window.location.assign(action.url)\n } else {\n console.warn('[surface] blocked unsafe navigate URL:', action.url)\n }\n break\n }\n },\n [setStateValue, refreshSource, fetchAllSources, onNavigateAction]\n )\n\n // Event interceptor\n const handleEvent = React.useCallback(\n (event: SurfaceEvent) => {\n // Inert (editor/preview): skip block-dispatched surface actions (state\n // mutations / data refreshes) so the surface doesn't mutate its own state\n // while authoring. `onEvent` is a pure notification and STILL fires below\n // — only the real data side-effects are gated.\n if (interactionMode !== 'inert') {\n // Check if the event payload contains a surface action\n const payload = event.payload as Record<string, unknown> | undefined\n const action = payload?.action\n\n if (isSurfaceAction(action)) {\n dispatchAction(action)\n }\n\n // `canonicalType` is normally stamped by the bus bridge (renderer.tsx's\n // busOnEvent), but some deployed block bundles still call\n // `context.onEvent` directly (the pre-bus legacy path) — for those,\n // `canonicalType` is absent. Block-scoped click events reaching here\n // always mean a real click occurred, so treat a canonicalType-less\n // 'click' as 'block:click' rather than silently dropping it.\n const fired = event.canonicalType ?? (event.type === 'click' && event.blockId ? 'block:click' : '')\n\n // A block's own `action` prop (one action or a list, run in order) is\n // what its CLICK does — and only its click. It used to run on every\n // event the block emitted, so a block that also reported hover, focus\n // or a value change would have fired its click action on each of them.\n // Looked up in the RESOLVED tree, so a repeat clone (`id--N`) carries\n // its own row's values.\n if (fired === 'block:click') {\n blockActionsOf(findBlockAction(resolvedBlocks, event.blockId)).forEach(dispatchAction)\n }\n\n // Execute stored behaviors whose trigger matches this canonical event.\n if (behaviors && behaviors.length > 0) {\n for (const b of behaviors) {\n if (canonicalizeEventType(b.event) !== fired) continue\n if (b.targetBlockId && b.targetBlockId !== event.blockId) continue\n b.actions.forEach(dispatchAction)\n }\n }\n }\n\n // Forward to original handler — a pure notification, always fires (the\n // host decides what side-effects, if any, to run).\n onEvent?.(event)\n },\n [interactionMode, onEvent, dispatchAction, resolvedBlocks, behaviors]\n )\n\n // Loading state — 'gate' strategy only (the historical default): the whole\n // block tree is withheld until the first fetch pass settles. 'immediate'\n // skips this and renders the tree at once; unresolved bindings evaluate to\n // undefined and fill in per source (see loadingStrategy prop docs).\n if (!initialLoaded && loadingStrategy !== 'immediate') {\n return (\n <div\n data-surface-loading\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n padding: '48px',\n // Theme-tokened with the old hardcoded values as fallbacks, so the\n // gate no longer paints light-theme blue on a dark-themed surface.\n color: 'var(--pw-color-text-muted, #666)',\n }}\n >\n <div style={{ textAlign: 'center' }}>\n <div\n style={{\n width: '32px',\n height: '32px',\n border: '3px solid var(--pw-color-border, #e5e7eb)',\n borderTopColor: 'var(--pw-color-primary, #3b82f6)',\n borderRadius: '50%',\n animation: 'spin 0.8s linear infinite',\n margin: '0 auto 12px',\n }}\n />\n Loading data...\n </div>\n </div>\n )\n }\n\n const resolvedSurface: RenderableSurface = {\n // See the passthrough branch above — same reason, same one-line omission.\n ...(surfaceId !== undefined ? { id: surfaceId } : {}),\n blocks: resolvedBlocks,\n ...(appearance !== undefined ? { appearance } : {}),\n ...(capabilities !== undefined ? { capabilities } : {}),\n }\n return (\n // What is bound right now, for the providers under SurfaceRenderer that\n // must act on it — the form writer decides create-vs-update from the\n // record a source has loaded, and could not see one before this.\n <SurfaceDataContext.Provider value={expressionData}>\n <SurfaceRenderer surface={resolvedSurface} onEvent={handleEvent} {...rendererProps} />\n </SurfaceDataContext.Provider>\n )\n}\n\n// ============================================================\n// HELPERS\n// ============================================================\n\n/**\n * Find the action prop of a block by ID in the resolved block tree.\n */\nfunction findBlockAction(blocks: readonly Block[], blockId: string): unknown {\n for (const block of blocks) {\n if (block.id === blockId) {\n return block.props?.action\n }\n if (block.children) {\n const found = findBlockAction(block.children, blockId)\n if (found !== undefined) return found\n }\n }\n return undefined\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pwfabric/runtime",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.1.0",
4
4
  "description": "PWFabric runtime and execution engine",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
@@ -69,8 +69,8 @@
69
69
  "node": ">=22"
70
70
  },
71
71
  "dependencies": {
72
- "@pwfabric/core": "1.0.0-rc.2",
73
- "@pwfabric/contracts": "1.0.0-rc.2"
72
+ "@pwfabric/contracts": "1.1.0",
73
+ "@pwfabric/core": "1.1.0"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "react": "^18.0.0 || ^19.0.0",