@happyvertical/smrt-core 0.37.8 → 0.37.10
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/AGENTS.md +10 -0
- package/dist/change-feed.d.ts +261 -0
- package/dist/change-feed.d.ts.map +1 -0
- package/dist/change-feed.js +482 -0
- package/dist/change-feed.js.map +1 -0
- package/dist/class.d.ts.map +1 -1
- package/dist/class.js +4 -2
- package/dist/class.js.map +1 -1
- package/dist/collection.js +2 -2
- package/dist/consumer-plugin/index.d.ts.map +1 -1
- package/dist/consumer-plugin/index.js +24 -19
- package/dist/consumer-plugin/index.js.map +1 -1
- package/dist/dispatch/bus.js +2 -2
- package/dist/dispatch/index.js +1 -1
- package/dist/generated-client-runtime.d.ts +26 -0
- package/dist/generated-client-runtime.d.ts.map +1 -0
- package/dist/generated-client-runtime.js +88 -0
- package/dist/generated-client-runtime.js.map +1 -0
- package/dist/generators/changes-route.d.ts +52 -0
- package/dist/generators/changes-route.d.ts.map +1 -0
- package/dist/generators/changes-route.js +111 -0
- package/dist/generators/changes-route.js.map +1 -0
- package/dist/generators/rest.d.ts +28 -0
- package/dist/generators/rest.d.ts.map +1 -1
- package/dist/generators/rest.js +53 -15
- package/dist/generators/rest.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/manifest/static-manifest.js +2 -2
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest/store.js.map +1 -1
- package/dist/manifest/test-manifest-stub.d.ts.map +1 -1
- package/dist/manifest/test-manifest-stub.js +502 -2
- package/dist/manifest/test-manifest-stub.js.map +1 -1
- package/dist/manifest.json +2 -2
- package/dist/object.js +2 -2
- package/dist/prebuild/index.d.ts.map +1 -1
- package/dist/prebuild/index.js +66 -7
- package/dist/prebuild/index.js.map +1 -1
- package/dist/smrt-knowledge.json +6 -6
- package/dist/system/schema.d.ts +24 -1
- package/dist/system/schema.d.ts.map +1 -1
- package/dist/system/schema.js +45 -3
- package/dist/system/schema.js.map +1 -1
- package/dist/testing/database.js +1 -1
- package/dist/vite-plugin/changes-route.d.ts +10 -0
- package/dist/vite-plugin/changes-route.d.ts.map +1 -0
- package/dist/vite-plugin/changes-route.js +174 -0
- package/dist/vite-plugin/changes-route.js.map +1 -0
- package/dist/vite-plugin/index.d.ts +7 -0
- package/dist/vite-plugin/index.d.ts.map +1 -1
- package/dist/vite-plugin/index.js +148 -21
- package/dist/vite-plugin/index.js.map +1 -1
- package/dist/vite-plugin/route-header.d.ts +10 -0
- package/dist/vite-plugin/route-header.d.ts.map +1 -0
- package/dist/vite-plugin/route-header.js +14 -0
- package/dist/vite-plugin/route-header.js.map +1 -0
- package/dist/vite-plugin/sveltekit-generator.d.ts +7 -0
- package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
- package/dist/vite-plugin/sveltekit-generator.js +5 -3
- package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
- package/dist/vite-plugin/sync-apply-route.d.ts.map +1 -1
- package/dist/vite-plugin/sync-apply-route.js +2 -2
- package/dist/vite-plugin/sync-apply-route.js.map +1 -1
- package/dist/vite-plugin/web-collections.d.ts +73 -0
- package/dist/vite-plugin/web-collections.d.ts.map +1 -0
- package/dist/vite-plugin/web-collections.js +174 -0
- package/dist/vite-plugin/web-collections.js.map +1 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-apply-route.js","names":[],"sources":["../../src/vite-plugin/sync-apply-route.ts"],"sourcesContent":["/**\n * SvelteKit generator for the sync-apply batch write route (#1759).\n *\n * Emits ONE route — `{routesDir}/sync/apply/+server.ts` — implementing the\n * shared web/mobile write contract for every syncable model in the manifest\n * (models whose API config exposes at least one of create/update/delete). The\n * generated file is deliberately thin: it maps `object` segments to\n * collections plus per-model policy data, and delegates all batch processing\n * to `processSyncApplyBatch` from `@happyvertical/smrt-core` — the same\n * engine the runtime REST generator uses, so the two transports cannot drift.\n *\n * This lives in its own module (rather than sveltekit-generator.ts) so the\n * shared generator file only needs a one-line registration hook; sibling\n * work (#1757, #1758) touches the same generator files in parallel.\n *\n * Contract documentation: docs/content/architecture/sync-apply-contract.md\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { ApiConfig } from '../registry/types.js';\nimport type {\n SmartObjectDefinition,\n SmartObjectManifest,\n} from '../scanner/types';\nimport type { SvelteKitOptions } from './sveltekit-generator.js';\n\nconst AUTO_GENERATED_ROUTE_HEADER =\n '// Auto-generated by @smrt/core vite plugin';\n\nconst MUTATING_ACTIONS = ['create', 'update', 'delete'] as const;\n\ntype MutatingAction = (typeof MUTATING_ACTIONS)[number];\n\n/** Per-model data embedded into the generated route. */\ninterface SyncTargetSpec {\n segment: string;\n /**\n * The manifest registry key, passed VERBATIM to `getCollection()` exactly\n * as the generated CRUD routes do. May be package-qualified\n * (`@happyvertical/smrt-ledgers:Account`) — collapsing it to a simple class\n * name would resolve ambiguously when two loaded packages declare the same\n * simple name.\n */\n registryKey: string;\n ops: MutatingAction[];\n readonlyFields: string[];\n writableAllowlist: string[] | null;\n publicAccess: boolean | 'read';\n tenantScoped: boolean;\n}\n\nfunction getApiConfigObject(apiConfig: unknown): ApiConfig | null {\n if (!apiConfig || typeof apiConfig !== 'object') {\n return null;\n }\n return apiConfig as ApiConfig;\n}\n\n/**\n * Mirror of sveltekit-generator.ts `resolveStandardCrudActions`, narrowed to\n * the mutating subset the sync contract can carry. Kept local so this module\n * needs no exports added to the (parallel-edited) shared generator file.\n */\nfunction resolveMutatingActions(apiConfig: unknown): MutatingAction[] {\n if (apiConfig === false) return [];\n if (\n apiConfig === true ||\n apiConfig === undefined ||\n typeof apiConfig !== 'object'\n ) {\n return [...MUTATING_ACTIONS];\n }\n\n const config = apiConfig as { include?: string[]; exclude?: string[] };\n let actions: MutatingAction[] = Array.isArray(config.include)\n ? MUTATING_ACTIONS.filter((action) => config.include?.includes(action))\n : [...MUTATING_ACTIONS];\n if (Array.isArray(config.exclude)) {\n const excluded = config.exclude;\n actions = actions.filter((action) => !excluded.includes(action));\n }\n return actions;\n}\n\n/** Mirror of sveltekit-generator.ts `getApiPublicAccess` (fail-closed). */\nfunction getApiPublicAccess(apiConfig: unknown): boolean | 'read' {\n const config = getApiConfigObject(apiConfig);\n const value = config?.public;\n if (value === true || value === 'read') {\n return value;\n }\n return false;\n}\n\n/** Mirror of sveltekit-generator.ts `collectReadonlyFieldNames` (#1540, 2b). */\nfunction collectReadonlyFieldNames(objectDef: SmartObjectDefinition): string[] {\n const fields = objectDef.fields || {};\n const names: string[] = [];\n for (const [name, def] of Object.entries(fields)) {\n const meta = (def as { _meta?: Record<string, unknown> })._meta;\n if (\n (def as { readonly?: boolean }).readonly === true ||\n meta?.readonly === true\n ) {\n names.push(name);\n }\n }\n return names;\n}\n\n/** Mirror of sveltekit-generator.ts `getApiWritableAllowlist`. */\nfunction getApiWritableAllowlist(apiConfig: unknown): string[] | null {\n const config = getApiConfigObject(apiConfig);\n return Array.isArray(config?.writable) ? config.writable : null;\n}\n\n/** Mirror of sveltekit-generator.ts `isCollectionClass`. */\nfunction isCollectionClass(objectDef: SmartObjectDefinition): boolean {\n return objectDef.extends === 'SmrtCollection' || !!objectDef.extendsTypeArg;\n}\n\n/**\n * Collect the syncable targets from a manifest: non-collection objects whose\n * API config is enabled and exposes at least one mutating action.\n */\nexport function collectSyncApplyTargets(\n manifest: SmartObjectManifest,\n): SyncTargetSpec[] {\n const targets: SyncTargetSpec[] = [];\n\n for (const [className, objectDef] of Object.entries(manifest.objects)) {\n if (isCollectionClass(objectDef)) continue;\n\n const apiConfig = objectDef.decoratorConfig?.api;\n if (apiConfig === false) continue;\n\n const ops = resolveMutatingActions(apiConfig);\n if (ops.length === 0) continue;\n\n if (!objectDef.collection) continue;\n\n targets.push({\n segment: objectDef.collection,\n registryKey: className,\n ops,\n readonlyFields: collectReadonlyFieldNames(objectDef),\n writableAllowlist: getApiWritableAllowlist(apiConfig),\n publicAccess: getApiPublicAccess(apiConfig),\n tenantScoped: !!objectDef.decoratorConfig?.tenantScoped,\n });\n }\n\n return targets.sort((a, b) => a.segment.localeCompare(b.segment));\n}\n\nfunction serializeTargets(targets: SyncTargetSpec[]): string {\n const entries = targets.map((target) => {\n const fields = [\n `registryKey: ${JSON.stringify(target.registryKey)}`,\n `ops: ${JSON.stringify(target.ops)}`,\n `readonlyFields: ${JSON.stringify(target.readonlyFields)}`,\n `writableAllowlist: ${JSON.stringify(target.writableAllowlist)}`,\n `publicAccess: ${JSON.stringify(target.publicAccess)}`,\n ];\n return ` ${JSON.stringify(target.segment)}: {\\n ${fields.join(',\\n ')},\\n },`;\n });\n return `{\\n${entries.join('\\n')}\\n}`;\n}\n\n/**\n * Render the generated `+server.ts` content for the sync-apply route.\n * Exported for tests.\n */\nexport function generateSyncApplyRouteTemplate(\n targets: SyncTargetSpec[],\n): string {\n const anyTenantScoped = targets.some((target) => target.tenantScoped);\n\n const tenantHelper = anyTenantScoped\n ? `\nimport { enterTenantContext, hasTenantContext } from '@happyvertical/smrt-tenancy';\n\nfunction establishTenantContext(locals: unknown): void {\n if (hasTenantContext()) return;\n if (!locals || typeof locals !== 'object') return;\n const l = locals as Record<string, unknown>;\n const user = l.user as Record<string, unknown> | undefined;\n const session = l.session as Record<string, unknown> | undefined;\n const tenantId = l.tenantId ?? user?.tenantId ?? session?.tenantId;\n if (typeof tenantId === 'string' && tenantId) {\n enterTenantContext({ tenantId });\n }\n}\n`\n : '';\n\n return `${AUTO_GENERATED_ROUTE_HEADER}\n// DO NOT EDIT - changes will be overwritten\n//\n// Idempotent sync-apply batch write contract (#1759) — the shared write path\n// for the web offline outbox (#1762) and the KMP mobile write queue (#1739).\n// Contract: docs/content/architecture/sync-apply-contract.md\n\nimport {\n applySyncWritablePolicy,\n processSyncApplyBatch,\n type SyncApplyOp,\n type SyncApplyTarget,\n} from '@happyvertical/smrt-core';\nimport { json } from '@sveltejs/kit';\nimport { getCollection } from '$lib/server/smrt';\nimport type { RequestHandler } from './$types';\n${tenantHelper}\ninterface SyncTargetConfig {\n /** Manifest registry key (may be package-qualified), as CRUD routes use. */\n registryKey: string;\n ops: SyncApplyOp[];\n readonlyFields: string[];\n writableAllowlist: string[] | null;\n publicAccess: boolean | 'read';\n}\n\n// One entry per syncable model, keyed by the collection route segment its\n// generated CRUD routes use.\nconst SYNC_TARGETS: Record<string, SyncTargetConfig> = ${serializeTargets(targets)};\n\n// Fail-closed authorization (#1540): sync mutations require an authenticated\n// principal on \\`locals\\` unless the target model is \\`api: { public: true }\\`.\nfunction hasAuthenticatedPrincipal(locals: unknown): boolean {\n if (!locals || typeof locals !== 'object') return false;\n const l = locals as Record<string, unknown>;\n const isResolvedPrincipal = (v: unknown) =>\n typeof v === 'object' && v !== null;\n return (\n isResolvedPrincipal(l.user) ||\n isResolvedPrincipal(l.session) ||\n l.smrtAuth === true\n );\n}\n\nexport const POST: RequestHandler = async ({ locals, request }) => {\n const authenticated = hasAuthenticatedPrincipal(locals);\n${anyTenantScoped ? ' establishTenantContext(locals);\\n' : ''}\n let body: unknown;\n try {\n body = await request.json();\n } catch {\n return json(\n { error: { code: 'invalid_batch', message: 'Invalid JSON body' } },\n { status: 400 },\n );\n }\n\n const outcome = await processSyncApplyBatch(body, {\n resolveTarget: async (segment: string): Promise<SyncApplyTarget | null> => {\n const target = SYNC_TARGETS[segment];\n if (!target) return null;\n // The verbatim manifest key, exactly as the generated CRUD routes pass\n // it — package-qualified keys stay qualified so same-simple-name\n // classes across packages resolve unambiguously.\n const collection = await getCollection(target.registryKey);\n return {\n objectName: target.registryKey,\n collection,\n isOpAllowed: (op: SyncApplyOp) => target.ops.includes(op),\n authorize: () =>\n authenticated || target.publicAccess === true\n ? ('ok' as const)\n : ('auth_required' as const),\n prepare: (payload: Record<string, unknown>) =>\n applySyncWritablePolicy(payload, {\n readonlyFields: target.readonlyFields,\n writableAllowlist: target.writableAllowlist,\n }),\n };\n },\n });\n\n return json(outcome.body, { status: outcome.status });\n};\n`;\n}\n\n/**\n * Generate `{routesDir}/sync/apply/+server.ts` for the manifest's syncable\n * models. Returns true when a route was written. Skips generation (with a\n * warning) if a non-generated file already occupies the path, and writes\n * nothing when the manifest has no syncable models.\n */\nexport function generateSyncApplyRoute(\n projectRoot: string,\n manifest: SmartObjectManifest,\n options: SvelteKitOptions,\n): boolean {\n const targets = collectSyncApplyTargets(manifest);\n if (targets.length === 0) {\n return false;\n }\n\n const routeDir = join(projectRoot, options.routesDir, 'sync', 'apply');\n const routePath = join(routeDir, '+server.ts');\n\n if (existsSync(routePath)) {\n const existing = readFileSync(routePath, 'utf-8');\n if (!existing.startsWith(AUTO_GENERATED_ROUTE_HEADER)) {\n console.warn(\n `[smrt] Skipping sync-apply route - ${routePath} exists and is not generated`,\n );\n return false;\n }\n }\n\n if (!existsSync(routeDir)) {\n mkdirSync(routeDir, { recursive: true });\n }\n\n writeFileSync(routePath, generateSyncApplyRouteTemplate(targets), 'utf-8');\n console.log(`[smrt] Generated: ${routePath}`);\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,IAAM,8BACJ;AAEF,IAAM,mBAAmB;CAAC;CAAU;CAAU;AAAQ;AAsBtD,SAAS,mBAAmB,WAAsC;CAChE,IAAI,CAAC,aAAa,OAAO,cAAc,UACrC,OAAO;CAET,OAAO;AACT;;;;;;AAOA,SAAS,uBAAuB,WAAsC;CACpE,IAAI,cAAc,OAAO,OAAO,CAAC;CACjC,IACE,cAAc,QACd,cAAc,KAAA,KACd,OAAO,cAAc,UAErB,OAAO,CAAC,GAAG,gBAAgB;CAG7B,MAAM,SAAS;CACf,IAAI,UAA4B,MAAM,QAAQ,OAAO,OAAO,IACxD,iBAAiB,QAAQ,WAAW,OAAO,SAAS,SAAS,MAAM,CAAC,IACpE,CAAC,GAAG,gBAAgB;CACxB,IAAI,MAAM,QAAQ,OAAO,OAAO,GAAG;EACjC,MA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,cAAc,WAAW,+BAA+B,OAAO,GAAG,OAAO;CACzE,QAAQ,IAAI,qBAAqB,WAAW;CAC5C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"sync-apply-route.js","names":[],"sources":["../../src/vite-plugin/sync-apply-route.ts"],"sourcesContent":["/**\n * SvelteKit generator for the sync-apply batch write route (#1759).\n *\n * Emits ONE route — `{routesDir}/sync/apply/+server.ts` — implementing the\n * shared web/mobile write contract for every syncable model in the manifest\n * (models whose API config exposes at least one of create/update/delete). The\n * generated file is deliberately thin: it maps `object` segments to\n * collections plus per-model policy data, and delegates all batch processing\n * to `processSyncApplyBatch` from `@happyvertical/smrt-core` — the same\n * engine the runtime REST generator uses, so the two transports cannot drift.\n *\n * This lives in its own module (rather than sveltekit-generator.ts) so the\n * shared generator file only needs a one-line registration hook; sibling\n * work (#1757, #1758) touches the same generator files in parallel.\n *\n * Contract documentation: docs/content/architecture/sync-apply-contract.md\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { ApiConfig } from '../registry/types.js';\nimport type {\n SmartObjectDefinition,\n SmartObjectManifest,\n} from '../scanner/types';\nimport { AUTO_GENERATED_ROUTE_HEADER } from './route-header.js';\nimport type { SvelteKitOptions } from './sveltekit-generator.js';\n\nconst MUTATING_ACTIONS = ['create', 'update', 'delete'] as const;\n\ntype MutatingAction = (typeof MUTATING_ACTIONS)[number];\n\n/** Per-model data embedded into the generated route. */\ninterface SyncTargetSpec {\n segment: string;\n /**\n * The manifest registry key, passed VERBATIM to `getCollection()` exactly\n * as the generated CRUD routes do. May be package-qualified\n * (`@happyvertical/smrt-ledgers:Account`) — collapsing it to a simple class\n * name would resolve ambiguously when two loaded packages declare the same\n * simple name.\n */\n registryKey: string;\n ops: MutatingAction[];\n readonlyFields: string[];\n writableAllowlist: string[] | null;\n publicAccess: boolean | 'read';\n tenantScoped: boolean;\n}\n\nfunction getApiConfigObject(apiConfig: unknown): ApiConfig | null {\n if (!apiConfig || typeof apiConfig !== 'object') {\n return null;\n }\n return apiConfig as ApiConfig;\n}\n\n/**\n * Mirror of sveltekit-generator.ts `resolveStandardCrudActions`, narrowed to\n * the mutating subset the sync contract can carry. Kept local so this module\n * needs no exports added to the (parallel-edited) shared generator file.\n */\nfunction resolveMutatingActions(apiConfig: unknown): MutatingAction[] {\n if (apiConfig === false) return [];\n if (\n apiConfig === true ||\n apiConfig === undefined ||\n typeof apiConfig !== 'object'\n ) {\n return [...MUTATING_ACTIONS];\n }\n\n const config = apiConfig as { include?: string[]; exclude?: string[] };\n let actions: MutatingAction[] = Array.isArray(config.include)\n ? MUTATING_ACTIONS.filter((action) => config.include?.includes(action))\n : [...MUTATING_ACTIONS];\n if (Array.isArray(config.exclude)) {\n const excluded = config.exclude;\n actions = actions.filter((action) => !excluded.includes(action));\n }\n return actions;\n}\n\n/** Mirror of sveltekit-generator.ts `getApiPublicAccess` (fail-closed). */\nfunction getApiPublicAccess(apiConfig: unknown): boolean | 'read' {\n const config = getApiConfigObject(apiConfig);\n const value = config?.public;\n if (value === true || value === 'read') {\n return value;\n }\n return false;\n}\n\n/** Mirror of sveltekit-generator.ts `collectReadonlyFieldNames` (#1540, 2b). */\nfunction collectReadonlyFieldNames(objectDef: SmartObjectDefinition): string[] {\n const fields = objectDef.fields || {};\n const names: string[] = [];\n for (const [name, def] of Object.entries(fields)) {\n const meta = (def as { _meta?: Record<string, unknown> })._meta;\n if (\n (def as { readonly?: boolean }).readonly === true ||\n meta?.readonly === true\n ) {\n names.push(name);\n }\n }\n return names;\n}\n\n/** Mirror of sveltekit-generator.ts `getApiWritableAllowlist`. */\nfunction getApiWritableAllowlist(apiConfig: unknown): string[] | null {\n const config = getApiConfigObject(apiConfig);\n return Array.isArray(config?.writable) ? config.writable : null;\n}\n\n/** Mirror of sveltekit-generator.ts `isCollectionClass`. */\nfunction isCollectionClass(objectDef: SmartObjectDefinition): boolean {\n return objectDef.extends === 'SmrtCollection' || !!objectDef.extendsTypeArg;\n}\n\n/**\n * Collect the syncable targets from a manifest: non-collection objects whose\n * API config is enabled and exposes at least one mutating action.\n */\nexport function collectSyncApplyTargets(\n manifest: SmartObjectManifest,\n): SyncTargetSpec[] {\n const targets: SyncTargetSpec[] = [];\n\n for (const [className, objectDef] of Object.entries(manifest.objects)) {\n if (isCollectionClass(objectDef)) continue;\n\n const apiConfig = objectDef.decoratorConfig?.api;\n if (apiConfig === false) continue;\n\n const ops = resolveMutatingActions(apiConfig);\n if (ops.length === 0) continue;\n\n if (!objectDef.collection) continue;\n\n targets.push({\n segment: objectDef.collection,\n registryKey: className,\n ops,\n readonlyFields: collectReadonlyFieldNames(objectDef),\n writableAllowlist: getApiWritableAllowlist(apiConfig),\n publicAccess: getApiPublicAccess(apiConfig),\n tenantScoped: !!objectDef.decoratorConfig?.tenantScoped,\n });\n }\n\n return targets.sort((a, b) => a.segment.localeCompare(b.segment));\n}\n\nfunction serializeTargets(targets: SyncTargetSpec[]): string {\n const entries = targets.map((target) => {\n const fields = [\n `registryKey: ${JSON.stringify(target.registryKey)}`,\n `ops: ${JSON.stringify(target.ops)}`,\n `readonlyFields: ${JSON.stringify(target.readonlyFields)}`,\n `writableAllowlist: ${JSON.stringify(target.writableAllowlist)}`,\n `publicAccess: ${JSON.stringify(target.publicAccess)}`,\n ];\n return ` ${JSON.stringify(target.segment)}: {\\n ${fields.join(',\\n ')},\\n },`;\n });\n return `{\\n${entries.join('\\n')}\\n}`;\n}\n\n/**\n * Render the generated `+server.ts` content for the sync-apply route.\n * Exported for tests.\n */\nexport function generateSyncApplyRouteTemplate(\n targets: SyncTargetSpec[],\n): string {\n const anyTenantScoped = targets.some((target) => target.tenantScoped);\n\n const tenantHelper = anyTenantScoped\n ? `\nimport { enterTenantContext, hasTenantContext } from '@happyvertical/smrt-tenancy';\n\nfunction establishTenantContext(locals: unknown): void {\n if (hasTenantContext()) return;\n if (!locals || typeof locals !== 'object') return;\n const l = locals as Record<string, unknown>;\n const user = l.user as Record<string, unknown> | undefined;\n const session = l.session as Record<string, unknown> | undefined;\n const tenantId = l.tenantId ?? user?.tenantId ?? session?.tenantId;\n if (typeof tenantId === 'string' && tenantId) {\n enterTenantContext({ tenantId });\n }\n}\n`\n : '';\n\n return `${AUTO_GENERATED_ROUTE_HEADER}\n// DO NOT EDIT - changes will be overwritten\n//\n// Idempotent sync-apply batch write contract (#1759) — the shared write path\n// for the web offline outbox (#1762) and the KMP mobile write queue (#1739).\n// Contract: docs/content/architecture/sync-apply-contract.md\n\nimport {\n applySyncWritablePolicy,\n processSyncApplyBatch,\n type SyncApplyOp,\n type SyncApplyTarget,\n} from '@happyvertical/smrt-core';\nimport { json } from '@sveltejs/kit';\nimport { getCollection } from '$lib/server/smrt';\nimport type { RequestHandler } from './$types';\n${tenantHelper}\ninterface SyncTargetConfig {\n /** Manifest registry key (may be package-qualified), as CRUD routes use. */\n registryKey: string;\n ops: SyncApplyOp[];\n readonlyFields: string[];\n writableAllowlist: string[] | null;\n publicAccess: boolean | 'read';\n}\n\n// One entry per syncable model, keyed by the collection route segment its\n// generated CRUD routes use.\nconst SYNC_TARGETS: Record<string, SyncTargetConfig> = ${serializeTargets(targets)};\n\n// Fail-closed authorization (#1540): sync mutations require an authenticated\n// principal on \\`locals\\` unless the target model is \\`api: { public: true }\\`.\nfunction hasAuthenticatedPrincipal(locals: unknown): boolean {\n if (!locals || typeof locals !== 'object') return false;\n const l = locals as Record<string, unknown>;\n const isResolvedPrincipal = (v: unknown) =>\n typeof v === 'object' && v !== null;\n return (\n isResolvedPrincipal(l.user) ||\n isResolvedPrincipal(l.session) ||\n l.smrtAuth === true\n );\n}\n\nexport const POST: RequestHandler = async ({ locals, request }) => {\n const authenticated = hasAuthenticatedPrincipal(locals);\n${anyTenantScoped ? ' establishTenantContext(locals);\\n' : ''}\n let body: unknown;\n try {\n body = await request.json();\n } catch {\n return json(\n { error: { code: 'invalid_batch', message: 'Invalid JSON body' } },\n { status: 400 },\n );\n }\n\n const outcome = await processSyncApplyBatch(body, {\n resolveTarget: async (segment: string): Promise<SyncApplyTarget | null> => {\n const target = SYNC_TARGETS[segment];\n if (!target) return null;\n // The verbatim manifest key, exactly as the generated CRUD routes pass\n // it — package-qualified keys stay qualified so same-simple-name\n // classes across packages resolve unambiguously.\n const collection = await getCollection(target.registryKey);\n return {\n objectName: target.registryKey,\n collection,\n isOpAllowed: (op: SyncApplyOp) => target.ops.includes(op),\n authorize: () =>\n authenticated || target.publicAccess === true\n ? ('ok' as const)\n : ('auth_required' as const),\n prepare: (payload: Record<string, unknown>) =>\n applySyncWritablePolicy(payload, {\n readonlyFields: target.readonlyFields,\n writableAllowlist: target.writableAllowlist,\n }),\n };\n },\n });\n\n return json(outcome.body, { status: outcome.status });\n};\n`;\n}\n\n/**\n * Generate `{routesDir}/sync/apply/+server.ts` for the manifest's syncable\n * models. Returns true when a route was written. Skips generation (with a\n * warning) if a non-generated file already occupies the path, and writes\n * nothing when the manifest has no syncable models.\n */\nexport function generateSyncApplyRoute(\n projectRoot: string,\n manifest: SmartObjectManifest,\n options: SvelteKitOptions,\n): boolean {\n const targets = collectSyncApplyTargets(manifest);\n if (targets.length === 0) {\n return false;\n }\n\n const routeDir = join(projectRoot, options.routesDir, 'sync', 'apply');\n const routePath = join(routeDir, '+server.ts');\n\n if (existsSync(routePath)) {\n const existing = readFileSync(routePath, 'utf-8');\n if (!existing.startsWith(AUTO_GENERATED_ROUTE_HEADER)) {\n console.warn(\n `[smrt] Skipping sync-apply route - ${routePath} exists and is not generated`,\n );\n return false;\n }\n }\n\n if (!existsSync(routeDir)) {\n mkdirSync(routeDir, { recursive: true });\n }\n\n writeFileSync(routePath, generateSyncApplyRouteTemplate(targets), 'utf-8');\n console.log(`[smrt] Generated: ${routePath}`);\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4BA,IAAM,mBAAmB;CAAC;CAAU;CAAU;AAAQ;AAsBtD,SAAS,mBAAmB,WAAsC;CAChE,IAAI,CAAC,aAAa,OAA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S;CACT,MAAM,UAAU,wBAAwB,QAAQ;CAChD,IAAI,QAAQ,WAAW,GACrB,OAAO;CAGT,MAAM,WAAW,KAAK,aAAa,QAAQ,WAAW,QAAQ,OAAO;CACrE,MAAM,YAAY,KAAK,UAAU,YAAY;CAE7C,IAAI,WAAW,SAAS;MAElB,CADa,aAAa,WAAW,OACpC,CAAA,CAAS,WAAA,6CAAsC,GAAG;GACrD,QAAQ,KACN,sCAAsC,UAAU,6BAClD;GACA,OAAO;EACT;;CAGF,IAAI,CAAC,WAAW,QAAQ,GACtB,UAAU,UAAU,EAAE,WAAW,KAAK,CAAC;CAGzC,cAAc,WAAW,+BAA+B,OAAO,GAAG,OAAO;CACzE,QAAQ,IAAI,qBAAqB,WAAW;CAC5C,OAAO;AACT"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { FieldDefinition, SmartObjectDefinition, SmartObjectManifest } from '../scanner/types.js';
|
|
2
|
+
/** Informational per-column metadata carried by a collection definition. */
|
|
3
|
+
export interface WebFieldDefinition {
|
|
4
|
+
type: FieldDefinition['type'];
|
|
5
|
+
required?: boolean;
|
|
6
|
+
default?: unknown;
|
|
7
|
+
}
|
|
8
|
+
/** The relationship kinds a web collection edge can describe. */
|
|
9
|
+
export type WebRelationshipKind = 'foreignKey' | 'crossPackageRef' | 'oneToMany' | 'manyToMany';
|
|
10
|
+
/**
|
|
11
|
+
* One manifest-derived relationship edge from a collection to a sibling REST
|
|
12
|
+
* collection. Consumed by the browser client-data runtime to invalidate
|
|
13
|
+
* dependent collection caches when this collection is mutated (#1761) — the
|
|
14
|
+
* cache-invalidation graph is derived entirely from these edges, never
|
|
15
|
+
* hand-wired. SMRT-owned data: no client-engine type appears here.
|
|
16
|
+
*/
|
|
17
|
+
export interface WebRelationship {
|
|
18
|
+
/** The declaring field carrying the relationship (e.g. `groupId`, `items`). */
|
|
19
|
+
field: string;
|
|
20
|
+
/** The relationship kind, mirroring the manifest field type. */
|
|
21
|
+
kind: WebRelationshipKind;
|
|
22
|
+
/** REST collection name the edge resolves to (e.g. `ad_groups`). */
|
|
23
|
+
relatedCollection: string;
|
|
24
|
+
}
|
|
25
|
+
/** One selected REST collection and the model that owns its definition. */
|
|
26
|
+
export interface WebCollectionEntry {
|
|
27
|
+
/** REST collection name (pluralized), e.g. `products`. */
|
|
28
|
+
collection: string;
|
|
29
|
+
/** The manifest object that owns this collection's definition. */
|
|
30
|
+
obj: SmartObjectDefinition;
|
|
31
|
+
/** Sorted set of exposed CRUD + custom actions. */
|
|
32
|
+
actions: string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Select the manifest entries that become web collection definitions: one per
|
|
36
|
+
* REST collection, STI children folding into their base model, collection
|
|
37
|
+
* classes excluded, and only models that expose `list` (a read surface is
|
|
38
|
+
* required to materialize a collection). Uses the canonical
|
|
39
|
+
* {@link resolveApiActionSet} so the exposed-action set matches exactly what
|
|
40
|
+
* the REST/SvelteKit generators actually emit.
|
|
41
|
+
*/
|
|
42
|
+
export declare function selectWebCollectionEntries(manifest: SmartObjectManifest): WebCollectionEntry[];
|
|
43
|
+
/**
|
|
44
|
+
* Build the informational per-field metadata for a web collection definition:
|
|
45
|
+
* the persisted public-DTO columns only. Relationship pseudo-fields, STI meta
|
|
46
|
+
* internals, transient (unpersisted) and sensitive (wire-stripped) fields are
|
|
47
|
+
* excluded — they are not columns a client reads back over the REST surface.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildWebFieldDefinitions(obj: SmartObjectDefinition): Record<string, WebFieldDefinition>;
|
|
50
|
+
/**
|
|
51
|
+
* Build the manifest-derived relationship edges for a web collection
|
|
52
|
+
* definition (#1761): one entry per relationship field (`foreignKey`,
|
|
53
|
+
* `crossPackageRef`, `oneToMany`, `manyToMany`) whose `related` target resolves
|
|
54
|
+
* to another API-exposed REST collection.
|
|
55
|
+
*
|
|
56
|
+
* These edges drive relationship-derived cache invalidation in the browser
|
|
57
|
+
* client-data runtime: mutating this collection invalidates the caches of the
|
|
58
|
+
* collections named here. The invalidation graph is thus derived entirely from
|
|
59
|
+
* the manifest — no hand-wired cache keys.
|
|
60
|
+
*
|
|
61
|
+
* An edge is SKIPPED (not emitted) when:
|
|
62
|
+
* - `related` is missing, or
|
|
63
|
+
* - `related` cannot be resolved to a manifest object (e.g. a cross-package
|
|
64
|
+
* target not present in this package's manifest), or
|
|
65
|
+
* - the resolved target is not itself an API-exposed web collection (no read
|
|
66
|
+
* surface to invalidate — it never appears in {@link selectWebCollectionEntries}).
|
|
67
|
+
*
|
|
68
|
+
* Self-referential edges (a collection related to itself) are kept: the runtime
|
|
69
|
+
* always invalidates the mutated collection anyway, so a self edge is harmless
|
|
70
|
+
* and keeping it avoids a special case.
|
|
71
|
+
*/
|
|
72
|
+
export declare function buildWebRelationships(obj: SmartObjectDefinition, manifest: SmartObjectManifest): WebRelationship[];
|
|
73
|
+
//# sourceMappingURL=web-collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-collections.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/web-collections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAyB7B,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,iEAAiE;AACjE,MAAM,MAAM,mBAAmB,GAC3B,YAAY,GACZ,iBAAiB,GACjB,WAAW,GACX,YAAY,CAAC;AAEjB;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,oEAAoE;IACpE,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,2EAA2E;AAC3E,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,GAAG,EAAE,qBAAqB,CAAC;IAC3B,mDAAmD;IACnD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAiFD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,mBAAmB,GAC5B,kBAAkB,EAAE,CAgCtB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,qBAAqB,GACzB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAcpC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,qBAAqB,EAC1B,QAAQ,EAAE,mBAAmB,GAC5B,eAAe,EAAE,CAiCnB"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { resolveApiActionSet } from "./sveltekit-generator.js";
|
|
2
|
+
//#region src/vite-plugin/web-collections.ts
|
|
3
|
+
/**
|
|
4
|
+
* Field types that are relationship pseudo-columns rather than persisted
|
|
5
|
+
* public-DTO columns — they never appear on the wire as scalar values.
|
|
6
|
+
*/
|
|
7
|
+
var RELATIONSHIP_FIELD_TYPES = /* @__PURE__ */ new Set(["oneToMany", "manyToMany"]);
|
|
8
|
+
/**
|
|
9
|
+
* Field types that describe a relationship to another model. A superset of
|
|
10
|
+
* {@link RELATIONSHIP_FIELD_TYPES}: `foreignKey`/`crossPackageRef` are persisted
|
|
11
|
+
* scalar id columns (they DO appear on the wire), while `oneToMany`/`manyToMany`
|
|
12
|
+
* are pseudo-columns — but all four carry a `related` edge to a sibling model.
|
|
13
|
+
*/
|
|
14
|
+
var RELATIONSHIP_EDGE_TYPES = /* @__PURE__ */ new Set([
|
|
15
|
+
"foreignKey",
|
|
16
|
+
"crossPackageRef",
|
|
17
|
+
"oneToMany",
|
|
18
|
+
"manyToMany"
|
|
19
|
+
]);
|
|
20
|
+
/** Resolve a manifest object by qualified name or simple class name. */
|
|
21
|
+
function findByName(manifest, name) {
|
|
22
|
+
return Object.values(manifest.objects).find((candidate) => candidate.qualifiedName === name || candidate.className === name);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Normalize a relationship field's `related` value to a resolvable class name.
|
|
26
|
+
*
|
|
27
|
+
* Thunk forward-ref decorators — `@foreignKey(() => Scene)`, used heavily in
|
|
28
|
+
* video/voice for models that reference a class declared later — serialize as
|
|
29
|
+
* the RAW arrow-function source string `"() => Scene"` in the manifest, which
|
|
30
|
+
* neither `className` nor `qualifiedName` matches. Extract the target class
|
|
31
|
+
* name from the thunk so the edge resolves. Plain (`"Scene"`) and qualified
|
|
32
|
+
* (`"@happyvertical/smrt-assets:Asset"`) forms contain no `=>` and pass through
|
|
33
|
+
* untouched — the qualified `:` separator is preserved.
|
|
34
|
+
*
|
|
35
|
+
* Kept local to the relationship-edge path on purpose: extends-chain resolution
|
|
36
|
+
* never sees a thunk, so `findByName` and the scanner stay unchanged.
|
|
37
|
+
*/
|
|
38
|
+
function normalizeRelatedName(related) {
|
|
39
|
+
const thunk = related.match(/=>\s*([A-Za-z_$][\w$]*)/);
|
|
40
|
+
return thunk ? thunk[1] : related.trim();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* True when `obj` is (transitively) a SmrtCollection subclass. Collection
|
|
44
|
+
* classes describe access, not row shapes, so they never become web
|
|
45
|
+
* collection definitions.
|
|
46
|
+
*
|
|
47
|
+
* NOTE: deliberately stronger than sveltekit-generator's private
|
|
48
|
+
* `isCollectionClass`, which only inspects the direct base / a type argument.
|
|
49
|
+
* A deeper subclass (`SpecialWidgetCollection extends WidgetCollection`)
|
|
50
|
+
* carries no type argument of its own; without walking the extends chain it
|
|
51
|
+
* would be mistaken for a model and claim its base model's REST collection.
|
|
52
|
+
*/
|
|
53
|
+
function isWebCollectionClass(manifest, obj, seen = /* @__PURE__ */ new Set()) {
|
|
54
|
+
if (obj.extends === "SmrtCollection" || !!obj.extendsTypeArg) return true;
|
|
55
|
+
const parentName = obj.extendsQualified || obj.extends;
|
|
56
|
+
if (!parentName || seen.has(parentName)) return false;
|
|
57
|
+
seen.add(parentName);
|
|
58
|
+
const parent = findByName(manifest, parentName);
|
|
59
|
+
return parent ? isWebCollectionClass(manifest, parent, seen) : false;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* True when some ancestor model maps to the SAME REST collection (a shared STI
|
|
63
|
+
* table). The STI base model owns the shared table's single definition.
|
|
64
|
+
*/
|
|
65
|
+
function isStiChildModel(manifest, obj) {
|
|
66
|
+
const seen = /* @__PURE__ */ new Set();
|
|
67
|
+
let parentName = obj.extendsQualified || obj.extends;
|
|
68
|
+
while (parentName && !seen.has(parentName)) {
|
|
69
|
+
seen.add(parentName);
|
|
70
|
+
const parent = findByName(manifest, parentName);
|
|
71
|
+
if (!parent) return false;
|
|
72
|
+
if (parent.collection === obj.collection) return true;
|
|
73
|
+
parentName = parent.extendsQualified || parent.extends;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Select the manifest entries that become web collection definitions: one per
|
|
79
|
+
* REST collection, STI children folding into their base model, collection
|
|
80
|
+
* classes excluded, and only models that expose `list` (a read surface is
|
|
81
|
+
* required to materialize a collection). Uses the canonical
|
|
82
|
+
* {@link resolveApiActionSet} so the exposed-action set matches exactly what
|
|
83
|
+
* the REST/SvelteKit generators actually emit.
|
|
84
|
+
*/
|
|
85
|
+
function selectWebCollectionEntries(manifest) {
|
|
86
|
+
const byCollection = /* @__PURE__ */ new Map();
|
|
87
|
+
for (const obj of Object.values(manifest.objects)) {
|
|
88
|
+
if (isWebCollectionClass(manifest, obj)) continue;
|
|
89
|
+
const exposedActions = resolveApiActionSet(obj);
|
|
90
|
+
if (!exposedActions.has("list")) continue;
|
|
91
|
+
const isStiChild = isStiChildModel(manifest, obj);
|
|
92
|
+
const existing = byCollection.get(obj.collection);
|
|
93
|
+
if (existing && !(existing.isStiChild && !isStiChild)) continue;
|
|
94
|
+
byCollection.set(obj.collection, {
|
|
95
|
+
collection: obj.collection,
|
|
96
|
+
obj,
|
|
97
|
+
actions: [...exposedActions].sort(),
|
|
98
|
+
isStiChild
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return [...byCollection.values()].map(({ collection, obj, actions }) => ({
|
|
102
|
+
collection,
|
|
103
|
+
obj,
|
|
104
|
+
actions
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Build the informational per-field metadata for a web collection definition:
|
|
109
|
+
* the persisted public-DTO columns only. Relationship pseudo-fields, STI meta
|
|
110
|
+
* internals, transient (unpersisted) and sensitive (wire-stripped) fields are
|
|
111
|
+
* excluded — they are not columns a client reads back over the REST surface.
|
|
112
|
+
*/
|
|
113
|
+
function buildWebFieldDefinitions(obj) {
|
|
114
|
+
const fields = {};
|
|
115
|
+
for (const [fieldName, field] of Object.entries(obj.fields ?? {})) {
|
|
116
|
+
if (RELATIONSHIP_FIELD_TYPES.has(field.type)) continue;
|
|
117
|
+
if (field.type === "meta") continue;
|
|
118
|
+
if (field.transient) continue;
|
|
119
|
+
if (field.sensitive) continue;
|
|
120
|
+
fields[fieldName] = {
|
|
121
|
+
type: field.type,
|
|
122
|
+
...field.required !== void 0 ? { required: field.required } : {},
|
|
123
|
+
...field.default !== void 0 ? { default: field.default } : {}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return fields;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Build the manifest-derived relationship edges for a web collection
|
|
130
|
+
* definition (#1761): one entry per relationship field (`foreignKey`,
|
|
131
|
+
* `crossPackageRef`, `oneToMany`, `manyToMany`) whose `related` target resolves
|
|
132
|
+
* to another API-exposed REST collection.
|
|
133
|
+
*
|
|
134
|
+
* These edges drive relationship-derived cache invalidation in the browser
|
|
135
|
+
* client-data runtime: mutating this collection invalidates the caches of the
|
|
136
|
+
* collections named here. The invalidation graph is thus derived entirely from
|
|
137
|
+
* the manifest — no hand-wired cache keys.
|
|
138
|
+
*
|
|
139
|
+
* An edge is SKIPPED (not emitted) when:
|
|
140
|
+
* - `related` is missing, or
|
|
141
|
+
* - `related` cannot be resolved to a manifest object (e.g. a cross-package
|
|
142
|
+
* target not present in this package's manifest), or
|
|
143
|
+
* - the resolved target is not itself an API-exposed web collection (no read
|
|
144
|
+
* surface to invalidate — it never appears in {@link selectWebCollectionEntries}).
|
|
145
|
+
*
|
|
146
|
+
* Self-referential edges (a collection related to itself) are kept: the runtime
|
|
147
|
+
* always invalidates the mutated collection anyway, so a self edge is harmless
|
|
148
|
+
* and keeping it avoids a special case.
|
|
149
|
+
*/
|
|
150
|
+
function buildWebRelationships(obj, manifest) {
|
|
151
|
+
const exposedCollections = new Set(selectWebCollectionEntries(manifest).map((entry) => entry.collection));
|
|
152
|
+
const relationships = [];
|
|
153
|
+
const seen = /* @__PURE__ */ new Set();
|
|
154
|
+
for (const [fieldName, field] of Object.entries(obj.fields ?? {})) {
|
|
155
|
+
if (!RELATIONSHIP_EDGE_TYPES.has(field.type)) continue;
|
|
156
|
+
if (!field.related) continue;
|
|
157
|
+
const target = findByName(manifest, normalizeRelatedName(field.related));
|
|
158
|
+
if (!target) continue;
|
|
159
|
+
if (!exposedCollections.has(target.collection)) continue;
|
|
160
|
+
const dedupeKey = `${fieldName}:${target.collection}`;
|
|
161
|
+
if (seen.has(dedupeKey)) continue;
|
|
162
|
+
seen.add(dedupeKey);
|
|
163
|
+
relationships.push({
|
|
164
|
+
field: fieldName,
|
|
165
|
+
kind: field.type,
|
|
166
|
+
relatedCollection: target.collection
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return relationships;
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { buildWebFieldDefinitions, buildWebRelationships, selectWebCollectionEntries };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=web-collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-collections.js","names":[],"sources":["../../src/vite-plugin/web-collections.ts"],"sourcesContent":["/**\n * Manifest → web collection selection (single source of truth).\n *\n * The browser client data runtime (`@happyvertical/smrt-web`, #1761) consumes\n * one typed collection definition per API-exposed REST collection. Three\n * emission sites need the SAME selection and field rules, or the emitted\n * runtime values and their declared types drift apart:\n *\n * - the `\\0smrt:web` runtime virtual module (JSON literal — {@link generateWebModule})\n * - the `@happyvertical/smrt-virt-web` ambient d.ts (vite-plugin)\n * - the physical `@smrt/web` d.ts (prebuild, for `tsc`-only consumers)\n *\n * All three import {@link selectWebCollectionEntries} from here so the value\n * emission and the type emission can never disagree.\n */\n\nimport type {\n FieldDefinition,\n SmartObjectDefinition,\n SmartObjectManifest,\n} from '../scanner/types.js';\nimport { resolveApiActionSet } from './sveltekit-generator.js';\n\n/**\n * Field types that are relationship pseudo-columns rather than persisted\n * public-DTO columns — they never appear on the wire as scalar values.\n */\nconst RELATIONSHIP_FIELD_TYPES: ReadonlySet<FieldDefinition['type']> = new Set([\n 'oneToMany',\n 'manyToMany',\n]);\n\n/**\n * Field types that describe a relationship to another model. A superset of\n * {@link RELATIONSHIP_FIELD_TYPES}: `foreignKey`/`crossPackageRef` are persisted\n * scalar id columns (they DO appear on the wire), while `oneToMany`/`manyToMany`\n * are pseudo-columns — but all four carry a `related` edge to a sibling model.\n */\nconst RELATIONSHIP_EDGE_TYPES: ReadonlySet<FieldDefinition['type']> = new Set([\n 'foreignKey',\n 'crossPackageRef',\n 'oneToMany',\n 'manyToMany',\n]);\n\n/** Informational per-column metadata carried by a collection definition. */\nexport interface WebFieldDefinition {\n type: FieldDefinition['type'];\n required?: boolean;\n default?: unknown;\n}\n\n/** The relationship kinds a web collection edge can describe. */\nexport type WebRelationshipKind =\n | 'foreignKey'\n | 'crossPackageRef'\n | 'oneToMany'\n | 'manyToMany';\n\n/**\n * One manifest-derived relationship edge from a collection to a sibling REST\n * collection. Consumed by the browser client-data runtime to invalidate\n * dependent collection caches when this collection is mutated (#1761) — the\n * cache-invalidation graph is derived entirely from these edges, never\n * hand-wired. SMRT-owned data: no client-engine type appears here.\n */\nexport interface WebRelationship {\n /** The declaring field carrying the relationship (e.g. `groupId`, `items`). */\n field: string;\n /** The relationship kind, mirroring the manifest field type. */\n kind: WebRelationshipKind;\n /** REST collection name the edge resolves to (e.g. `ad_groups`). */\n relatedCollection: string;\n}\n\n/** One selected REST collection and the model that owns its definition. */\nexport interface WebCollectionEntry {\n /** REST collection name (pluralized), e.g. `products`. */\n collection: string;\n /** The manifest object that owns this collection's definition. */\n obj: SmartObjectDefinition;\n /** Sorted set of exposed CRUD + custom actions. */\n actions: string[];\n}\n\n/** Resolve a manifest object by qualified name or simple class name. */\nfunction findByName(\n manifest: SmartObjectManifest,\n name: string,\n): SmartObjectDefinition | undefined {\n return Object.values(manifest.objects).find(\n (candidate) =>\n candidate.qualifiedName === name || candidate.className === name,\n );\n}\n\n/**\n * Normalize a relationship field's `related` value to a resolvable class name.\n *\n * Thunk forward-ref decorators — `@foreignKey(() => Scene)`, used heavily in\n * video/voice for models that reference a class declared later — serialize as\n * the RAW arrow-function source string `\"() => Scene\"` in the manifest, which\n * neither `className` nor `qualifiedName` matches. Extract the target class\n * name from the thunk so the edge resolves. Plain (`\"Scene\"`) and qualified\n * (`\"@happyvertical/smrt-assets:Asset\"`) forms contain no `=>` and pass through\n * untouched — the qualified `:` separator is preserved.\n *\n * Kept local to the relationship-edge path on purpose: extends-chain resolution\n * never sees a thunk, so `findByName` and the scanner stay unchanged.\n */\nfunction normalizeRelatedName(related: string): string {\n const thunk = related.match(/=>\\s*([A-Za-z_$][\\w$]*)/);\n return thunk ? thunk[1] : related.trim();\n}\n\n/**\n * True when `obj` is (transitively) a SmrtCollection subclass. Collection\n * classes describe access, not row shapes, so they never become web\n * collection definitions.\n *\n * NOTE: deliberately stronger than sveltekit-generator's private\n * `isCollectionClass`, which only inspects the direct base / a type argument.\n * A deeper subclass (`SpecialWidgetCollection extends WidgetCollection`)\n * carries no type argument of its own; without walking the extends chain it\n * would be mistaken for a model and claim its base model's REST collection.\n */\nfunction isWebCollectionClass(\n manifest: SmartObjectManifest,\n obj: SmartObjectDefinition,\n seen: Set<string> = new Set(),\n): boolean {\n // Truthy check (not `!== undefined`) mirrors the scanner's own\n // manifest-generator: a scanner that emits `extendsTypeArg: null` for a\n // non-generic base must not be misread as a collection.\n if (obj.extends === 'SmrtCollection' || !!obj.extendsTypeArg) {\n return true;\n }\n const parentName = obj.extendsQualified || obj.extends;\n if (!parentName || seen.has(parentName)) return false;\n seen.add(parentName);\n const parent = findByName(manifest, parentName);\n return parent ? isWebCollectionClass(manifest, parent, seen) : false;\n}\n\n/**\n * True when some ancestor model maps to the SAME REST collection (a shared STI\n * table). The STI base model owns the shared table's single definition.\n */\nfunction isStiChildModel(\n manifest: SmartObjectManifest,\n obj: SmartObjectDefinition,\n): boolean {\n const seen = new Set<string>();\n let parentName = obj.extendsQualified || obj.extends;\n while (parentName && !seen.has(parentName)) {\n seen.add(parentName);\n const parent = findByName(manifest, parentName);\n if (!parent) return false;\n if (parent.collection === obj.collection) return true;\n parentName = parent.extendsQualified || parent.extends;\n }\n return false;\n}\n\n/**\n * Select the manifest entries that become web collection definitions: one per\n * REST collection, STI children folding into their base model, collection\n * classes excluded, and only models that expose `list` (a read surface is\n * required to materialize a collection). Uses the canonical\n * {@link resolveApiActionSet} so the exposed-action set matches exactly what\n * the REST/SvelteKit generators actually emit.\n */\nexport function selectWebCollectionEntries(\n manifest: SmartObjectManifest,\n): WebCollectionEntry[] {\n const byCollection = new Map<\n string,\n WebCollectionEntry & { isStiChild: boolean }\n >();\n\n for (const obj of Object.values(manifest.objects)) {\n if (isWebCollectionClass(manifest, obj)) continue;\n\n const exposedActions = resolveApiActionSet(obj);\n if (!exposedActions.has('list')) continue;\n\n const isStiChild = isStiChildModel(manifest, obj);\n const existing = byCollection.get(obj.collection);\n // One definition per REST collection. The STI BASE model owns it: a child\n // only wins while no base has been recorded yet, so the result is\n // independent of declaration / scan order.\n if (existing && !(existing.isStiChild && !isStiChild)) continue;\n\n byCollection.set(obj.collection, {\n collection: obj.collection,\n obj,\n actions: [...exposedActions].sort(),\n isStiChild,\n });\n }\n\n return [...byCollection.values()].map(({ collection, obj, actions }) => ({\n collection,\n obj,\n actions,\n }));\n}\n\n/**\n * Build the informational per-field metadata for a web collection definition:\n * the persisted public-DTO columns only. Relationship pseudo-fields, STI meta\n * internals, transient (unpersisted) and sensitive (wire-stripped) fields are\n * excluded — they are not columns a client reads back over the REST surface.\n */\nexport function buildWebFieldDefinitions(\n obj: SmartObjectDefinition,\n): Record<string, WebFieldDefinition> {\n const fields: Record<string, WebFieldDefinition> = {};\n for (const [fieldName, field] of Object.entries(obj.fields ?? {})) {\n if (RELATIONSHIP_FIELD_TYPES.has(field.type)) continue;\n if (field.type === 'meta') continue;\n if (field.transient) continue;\n if (field.sensitive) continue;\n fields[fieldName] = {\n type: field.type,\n ...(field.required !== undefined ? { required: field.required } : {}),\n ...(field.default !== undefined ? { default: field.default } : {}),\n };\n }\n return fields;\n}\n\n/**\n * Build the manifest-derived relationship edges for a web collection\n * definition (#1761): one entry per relationship field (`foreignKey`,\n * `crossPackageRef`, `oneToMany`, `manyToMany`) whose `related` target resolves\n * to another API-exposed REST collection.\n *\n * These edges drive relationship-derived cache invalidation in the browser\n * client-data runtime: mutating this collection invalidates the caches of the\n * collections named here. The invalidation graph is thus derived entirely from\n * the manifest — no hand-wired cache keys.\n *\n * An edge is SKIPPED (not emitted) when:\n * - `related` is missing, or\n * - `related` cannot be resolved to a manifest object (e.g. a cross-package\n * target not present in this package's manifest), or\n * - the resolved target is not itself an API-exposed web collection (no read\n * surface to invalidate — it never appears in {@link selectWebCollectionEntries}).\n *\n * Self-referential edges (a collection related to itself) are kept: the runtime\n * always invalidates the mutated collection anyway, so a self edge is harmless\n * and keeping it avoids a special case.\n */\nexport function buildWebRelationships(\n obj: SmartObjectDefinition,\n manifest: SmartObjectManifest,\n): WebRelationship[] {\n // The set of REST collections that are actually materialized as web\n // collections. An edge to a model outside this set has no client cache to\n // invalidate, so it is dropped.\n const exposedCollections = new Set(\n selectWebCollectionEntries(manifest).map((entry) => entry.collection),\n );\n\n const relationships: WebRelationship[] = [];\n const seen = new Set<string>();\n for (const [fieldName, field] of Object.entries(obj.fields ?? {})) {\n if (!RELATIONSHIP_EDGE_TYPES.has(field.type)) continue;\n if (!field.related) continue;\n\n // Normalize first: `@foreignKey(() => Scene)` thunks serialize as the raw\n // \"() => Scene\" source, which findByName cannot match on its own.\n const target = findByName(manifest, normalizeRelatedName(field.related));\n if (!target) continue;\n if (!exposedCollections.has(target.collection)) continue;\n\n // De-dupe on (field, relatedCollection): a model never declares the same\n // field twice, but guard anyway so the emitted edge list is stable.\n const dedupeKey = `${fieldName}:${target.collection}`;\n if (seen.has(dedupeKey)) continue;\n seen.add(dedupeKey);\n\n relationships.push({\n field: fieldName,\n kind: field.type as WebRelationshipKind,\n relatedCollection: target.collection,\n });\n }\n return relationships;\n}\n"],"mappings":";;;;;;AA2BA,IAAM,2CAAiE,IAAI,IAAI,CAC7E,aACA,YACF,CAAC;;;;;;;AAQD,IAAM,0CAAgE,IAAI,IAAI;CAC5E;CACA;CACA;CACA;AACF,CAAC;;AA2CD,SAAS,WACP,UACA,MACmC;CACnC,OAAO,OAAO,OAAO,SAAS,OAAO,CAAC,CAAC,MACpC,cACC,UAAU,kBAAkB,QAAQ,UAAU,cAAc,IAChE;AACF;;;;;;;;;;;;;;;AAgBA,SAAS,qBAAqB,SAAyB;CACrD,MAAM,QAAQ,QAAQ,MAAM,yBAAyB;CACrD,OAAO,QAAQ,MAAM,KAAK,QAAQ,KAAK;AACzC;;;;;;;;;;;;AAaA,SAAS,qBACP,UACA,KACA,uBAAoB,IAAI,IAAI,GACnB;CAIT,IAAI,IAAI,YAAY,oBAAoB,CAAC,CAAC,I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
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.10",
|
|
4
4
|
"description": "Core AI agent framework with standardized collections, object-relational mapping, and code generators",
|
|
5
5
|
"author": "HappyVertical",
|
|
6
6
|
"type": "module",
|
|
@@ -154,9 +154,9 @@
|
|
|
154
154
|
"tsx": "^4.22.4",
|
|
155
155
|
"typescript": "^5.9.3",
|
|
156
156
|
"yaml": "^2.9.0",
|
|
157
|
-
"@happyvertical/smrt-
|
|
158
|
-
"@happyvertical/smrt-
|
|
159
|
-
"@happyvertical/smrt-
|
|
157
|
+
"@happyvertical/smrt-scanner": "0.37.10",
|
|
158
|
+
"@happyvertical/smrt-types": "0.37.10",
|
|
159
|
+
"@happyvertical/smrt-config": "0.37.10"
|
|
160
160
|
},
|
|
161
161
|
"peerDependencies": {
|
|
162
162
|
"@huggingface/transformers": ">=3.0.0 <4.0.0",
|