@lssm/lib.contracts 0.0.0-canary-20251217063201 → 0.0.0-canary-20251217072406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-config/app-config.feature.js +53 -1
- package/dist/app-config/contracts.d.ts +50 -50
- package/dist/app-config/contracts.js +396 -1
- package/dist/app-config/docs/app-config.docblock.js +22 -220
- package/dist/app-config/events.d.ts +27 -27
- package/dist/app-config/events.js +168 -1
- package/dist/app-config/index.js +8 -1
- package/dist/app-config/lifecycle-contracts.d.ts +80 -80
- package/dist/app-config/lifecycle-contracts.js +441 -1
- package/dist/app-config/runtime.js +617 -1
- package/dist/app-config/spec.js +36 -1
- package/dist/app-config/validation.js +538 -1
- package/dist/capabilities/docs/capabilities.docblock.js +22 -1
- package/dist/capabilities/openbanking.js +92 -1
- package/dist/capabilities.js +50 -1
- package/dist/client/index.js +9 -1
- package/dist/client/react/drivers/rn-reusables.js +21 -1
- package/dist/client/react/drivers/shadcn.js +11 -1
- package/dist/client/react/feature-render.js +43 -1
- package/dist/client/react/form-render.js +298 -1
- package/dist/client/react/index.js +8 -1
- package/dist/contract-registry/index.js +3 -1
- package/dist/contract-registry/schemas.js +61 -1
- package/dist/contracts-adapter-hydration.js +41 -1
- package/dist/contracts-adapter-input.js +77 -1
- package/dist/data-views/docs/data-views.docblock.js +22 -1
- package/dist/data-views/query-generator.js +48 -1
- package/dist/data-views/runtime.js +39 -1
- package/dist/data-views.js +35 -1
- package/dist/docs/PUBLISHING.docblock.js +17 -76
- package/dist/docs/accessibility_wcag_compliance_specs.docblock.js +17 -350
- package/dist/docs/index.js +33 -1
- package/dist/docs/meta.docs.js +15 -2
- package/dist/docs/presentations.js +77 -1
- package/dist/docs/registry.js +51 -1
- package/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +17 -383
- package/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +17 -68
- package/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +17 -140
- package/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +17 -86
- package/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +17 -1
- package/dist/docs/tech/auth/better-auth-nextjs.docblock.js +25 -2
- package/dist/docs/tech/contracts/README.docblock.js +21 -1
- package/dist/docs/tech/contracts/create-subscription.docblock.js +21 -1
- package/dist/docs/tech/contracts/graphql-typed-outputs.docblock.js +21 -180
- package/dist/docs/tech/contracts/migrations.docblock.js +21 -1
- package/dist/docs/tech/contracts/openapi-export.docblock.js +22 -2
- package/dist/docs/tech/contracts/ops-to-presentation-linking.docblock.js +19 -60
- package/dist/docs/tech/contracts/overlays.docblock.js +21 -68
- package/dist/docs/tech/contracts/tests.docblock.js +21 -132
- package/dist/docs/tech/contracts/themes.docblock.js +21 -1
- package/dist/docs/tech/contracts/vertical-pocket-family-office.docblock.js +21 -106
- package/dist/docs/tech/lifecycle-stage-system.docblock.js +17 -213
- package/dist/docs/tech/llm/llm-integration.docblock.js +74 -5
- package/dist/docs/tech/mcp-endpoints.docblock.js +38 -1
- package/dist/docs/tech/presentation-runtime.docblock.js +17 -1
- package/dist/docs/tech/schema/README.docblock.js +21 -262
- package/dist/docs/tech/studio/learning-events.docblock.js +49 -1
- package/dist/docs/tech/studio/learning-journeys.docblock.js +25 -2
- package/dist/docs/tech/studio/platform-admin-panel.docblock.js +24 -2
- package/dist/docs/tech/studio/project-access-teams.docblock.js +26 -16
- package/dist/docs/tech/studio/project-routing.docblock.js +68 -1
- package/dist/docs/tech/studio/sandbox-unlogged.docblock.js +23 -2
- package/dist/docs/tech/studio/team-invitations.docblock.js +41 -36
- package/dist/docs/tech/studio/workspace-ops.docblock.js +48 -1
- package/dist/docs/tech/studio/workspaces.docblock.js +24 -2
- package/dist/docs/tech/telemetry-ingest.docblock.js +37 -3
- package/dist/docs/tech/templates/runtime.docblock.js +21 -1
- package/dist/docs/tech/vscode-extension.docblock.js +37 -3
- package/dist/docs/tech/workflows/overview.docblock.js +21 -1
- package/dist/docs/tech-contracts.docs.js +19 -2
- package/dist/events.js +12 -1
- package/dist/experiments/docs/experiments.docblock.js +22 -128
- package/dist/experiments/evaluator.js +101 -1
- package/dist/experiments/spec.js +33 -1
- package/dist/features.js +68 -1
- package/dist/forms/docs/forms.docblock.js +22 -1
- package/dist/forms.js +119 -1
- package/dist/index.js +107 -1
- package/dist/install.js +40 -1
- package/dist/integrations/contracts.d.ts +102 -102
- package/dist/integrations/contracts.js +388 -1
- package/dist/integrations/docs/integrations.docblock.js +95 -1
- package/dist/integrations/health.js +69 -1
- package/dist/integrations/index.js +23 -1
- package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
- package/dist/integrations/openbanking/contracts/accounts.js +237 -1
- package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
- package/dist/integrations/openbanking/contracts/balances.js +167 -1
- package/dist/integrations/openbanking/contracts/index.js +12 -1
- package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
- package/dist/integrations/openbanking/contracts/transactions.js +218 -1
- package/dist/integrations/openbanking/guards.js +32 -1
- package/dist/integrations/openbanking/models.d.ts +55 -55
- package/dist/integrations/openbanking/models.js +242 -1
- package/dist/integrations/openbanking/openbanking.feature.js +68 -1
- package/dist/integrations/openbanking/telemetry.js +39 -1
- package/dist/integrations/providers/elevenlabs.js +56 -1
- package/dist/integrations/providers/gcs-storage.js +79 -1
- package/dist/integrations/providers/gmail.js +91 -1
- package/dist/integrations/providers/google-calendar.js +70 -1
- package/dist/integrations/providers/impls/elevenlabs-voice.js +95 -1
- package/dist/integrations/providers/impls/gcs-storage.js +88 -1
- package/dist/integrations/providers/impls/gmail-inbound.js +200 -1
- package/dist/integrations/providers/impls/gmail-outbound.js +104 -5
- package/dist/integrations/providers/impls/google-calendar.js +154 -1
- package/dist/integrations/providers/impls/index.js +16 -1
- package/dist/integrations/providers/impls/mistral-embedding.js +41 -1
- package/dist/integrations/providers/impls/mistral-llm.js +247 -1
- package/dist/integrations/providers/impls/postmark-email.js +55 -1
- package/dist/integrations/providers/impls/powens-client.js +171 -1
- package/dist/integrations/providers/impls/powens-openbanking.js +218 -1
- package/dist/integrations/providers/impls/provider-factory.js +142 -1
- package/dist/integrations/providers/impls/qdrant-vector.js +69 -1
- package/dist/integrations/providers/impls/stripe-payments.js +202 -1
- package/dist/integrations/providers/impls/twilio-sms.js +58 -1
- package/dist/integrations/providers/index.js +13 -1
- package/dist/integrations/providers/mistral.js +72 -1
- package/dist/integrations/providers/postmark.js +72 -1
- package/dist/integrations/providers/powens.js +120 -1
- package/dist/integrations/providers/qdrant.js +77 -1
- package/dist/integrations/providers/registry.js +34 -1
- package/dist/integrations/providers/stripe.js +87 -1
- package/dist/integrations/providers/twilio-sms.js +65 -1
- package/dist/integrations/runtime.js +186 -1
- package/dist/integrations/secrets/aws-secret-manager.js +231 -1
- package/dist/integrations/secrets/env-secret-provider.js +81 -1
- package/dist/integrations/secrets/gcp-secret-manager.js +229 -1
- package/dist/integrations/secrets/index.js +8 -1
- package/dist/integrations/secrets/manager.js +103 -1
- package/dist/integrations/secrets/provider.js +58 -1
- package/dist/integrations/secrets/scaleway-secret-manager.js +247 -1
- package/dist/integrations/spec.js +39 -1
- package/dist/jobs/define-job.js +16 -1
- package/dist/jobs/gcp-cloud-tasks.js +53 -1
- package/dist/jobs/gcp-pubsub.js +39 -1
- package/dist/jobs/handlers/gmail-sync-handler.js +9 -1
- package/dist/jobs/handlers/index.js +12 -1
- package/dist/jobs/handlers/ping-handler.js +15 -1
- package/dist/jobs/handlers/storage-document-handler.js +14 -1
- package/dist/jobs/index.js +4 -1
- package/dist/jobs/memory-queue.js +71 -1
- package/dist/jobs/queue.js +33 -1
- package/dist/jobs/scaleway-sqs-queue.js +153 -1
- package/dist/jsonschema.d.ts +3 -3
- package/dist/jsonschema.js +32 -1
- package/dist/knowledge/contracts.d.ts +66 -66
- package/dist/knowledge/contracts.js +317 -1
- package/dist/knowledge/docs/knowledge.docblock.js +22 -138
- package/dist/knowledge/index.js +10 -1
- package/dist/knowledge/ingestion/document-processor.js +54 -1
- package/dist/knowledge/ingestion/embedding-service.js +25 -1
- package/dist/knowledge/ingestion/gmail-adapter.js +50 -5
- package/dist/knowledge/ingestion/index.js +7 -1
- package/dist/knowledge/ingestion/storage-adapter.js +26 -1
- package/dist/knowledge/ingestion/vector-indexer.js +32 -1
- package/dist/knowledge/query/index.js +3 -1
- package/dist/knowledge/query/service.js +64 -2
- package/dist/knowledge/runtime.js +49 -1
- package/dist/knowledge/spaces/email-threads.js +38 -1
- package/dist/knowledge/spaces/financial-docs.js +38 -1
- package/dist/knowledge/spaces/financial-overview.js +42 -1
- package/dist/knowledge/spaces/index.js +8 -1
- package/dist/knowledge/spaces/product-canon.js +38 -1
- package/dist/knowledge/spaces/support-faq.js +41 -1
- package/dist/knowledge/spaces/uploaded-docs.js +38 -1
- package/dist/knowledge/spec.js +39 -1
- package/dist/llm/exporters.js +541 -8
- package/dist/llm/index.js +4 -1
- package/dist/llm/prompts.js +246 -56
- package/dist/markdown.js +116 -3
- package/dist/migrations.js +33 -1
- package/dist/onboarding-base.d.ts +29 -29
- package/dist/onboarding-base.js +196 -1
- package/dist/openapi.js +75 -1
- package/dist/openbanking/docs/openbanking.docblock.js +22 -109
- package/dist/ownership.js +40 -1
- package/dist/policy/docs/policy.docblock.js +22 -1
- package/dist/policy/engine.js +223 -1
- package/dist/policy/opa-adapter.js +71 -1
- package/dist/policy/spec.js +33 -1
- package/dist/presentations/docs/presentations-conventions.docblock.js +21 -7
- package/dist/presentations.backcompat.js +47 -1
- package/dist/presentations.d.ts +3 -3
- package/dist/presentations.js +66 -1
- package/dist/presentations.v2.js +278 -6
- package/dist/prompt.js +10 -1
- package/dist/promptRegistry.js +34 -1
- package/dist/regenerator/docs/regenerator.docblock.js +22 -184
- package/dist/regenerator/executor.js +86 -1
- package/dist/regenerator/index.js +6 -1
- package/dist/regenerator/service.js +92 -1
- package/dist/regenerator/sinks.js +32 -1
- package/dist/regenerator/utils.js +51 -1
- package/dist/registry.js +208 -1
- package/dist/resources.js +47 -1
- package/dist/schema/dist/EnumType.js +2 -1
- package/dist/schema/dist/FieldType.js +49 -1
- package/dist/schema/dist/ScalarTypeEnum.js +236 -1
- package/dist/schema/dist/SchemaModel.js +39 -1
- package/dist/schema/dist/entity/defineEntity.js +1 -1
- package/dist/schema/dist/entity/index.js +2 -1
- package/dist/schema/dist/entity/types.js +1 -1
- package/dist/schema/dist/index.js +6 -1
- package/dist/schema-to-markdown.js +214 -10
- package/dist/server/graphql-pothos.js +128 -1
- package/dist/server/index.js +10 -1
- package/dist/server/mcp/createMcpServer.js +28 -1
- package/dist/server/mcp/registerPresentations.js +151 -1
- package/dist/server/mcp/registerPrompts.js +36 -2
- package/dist/server/mcp/registerResources.js +35 -1
- package/dist/server/mcp/registerTools.js +22 -1
- package/dist/server/provider-mcp.js +3 -1
- package/dist/server/rest-elysia.js +20 -1
- package/dist/server/rest-express.js +39 -1
- package/dist/server/rest-generic.js +125 -1
- package/dist/server/rest-next-app.js +38 -1
- package/dist/server/rest-next-mcp.js +45 -1
- package/dist/server/rest-next-pages.js +25 -1
- package/dist/spec.js +35 -1
- package/dist/telemetry/anomaly.js +48 -1
- package/dist/telemetry/docs/telemetry.docblock.js +22 -139
- package/dist/telemetry/index.js +5 -1
- package/dist/telemetry/spec.js +69 -1
- package/dist/telemetry/tracker.js +76 -1
- package/dist/tests/index.js +4 -1
- package/dist/tests/runner.js +150 -1
- package/dist/tests/spec.js +33 -1
- package/dist/themes.js +39 -1
- package/dist/workflow/adapters/db-adapter.js +83 -1
- package/dist/workflow/adapters/file-adapter.js +11 -1
- package/dist/workflow/adapters/index.js +5 -1
- package/dist/workflow/adapters/memory-store.js +58 -1
- package/dist/workflow/expression.js +98 -1
- package/dist/workflow/index.js +9 -1
- package/dist/workflow/runner.js +337 -1
- package/dist/workflow/sla-monitor.js +47 -1
- package/dist/workflow/spec.js +32 -1
- package/dist/workflow/validation.js +175 -1
- package/package.json +11 -4
|
@@ -1 +1,617 @@
|
|
|
1
|
-
function e(e,t,m={}){let g=n(e.capabilities,t.capabilities),_=r(e.features,t.features),v=i(e.dataViews??{},t.dataViewOverrides),y=i(e.workflows??{},t.workflowOverrides),b=a(e.policies??[],t.additionalPolicies??[]),x=o(e.theme,t.themeOverride),S=s(e.telemetry,t.telemetryOverride),C=c(e.experiments,t.experiments),w=d(e.featureFlags??[],t.featureFlags??[]),T=f(e.routes??[],t.routeOverrides??[]),{resolved:E}=p(e.integrationSlots,t.integrations,m.integrationConnections,m.integrationSpecs),D=h(t.knowledge,m.knowledgeSpaces,m.knowledgeSources),O=l(e.branding,t),k=u(e.translationCatalog,t.locales,t.translationOverrides);return{appId:e.meta.appId,tenantId:t.meta.tenantId,environment:t.meta.environment,blueprintName:e.meta.name,blueprintVersion:e.meta.version,configVersion:t.meta.version,capabilities:g,features:_,dataViews:v,workflows:y,policies:b,theme:x,telemetry:S,experiments:C,featureFlags:w,routes:T,integrations:E,knowledge:D,translation:k,branding:O,notes:t.notes??e.notes}}function t(t,n,r,i={}){let a=e(t,n,r),o=[],s=p(t.integrationSlots,n.integrations,r.integrationConnections,r.integrationSpecs);a.integrations=s.resolved,o.push(...s.missing),o.push(...g(n.knowledge??[],r.knowledgeSpaces,r.knowledgeSources));let c=_(a.capabilities.enabled,r.capabilities,o),l=v(a.features.include,r.features,o),u=y(a.dataViews,r.dataViews,`dataView`,o),d=y(a.workflows,r.workflows,`workflow`,o),f=b(a.policies,r.policies,o),{theme:m,fallbacks:h,themeMissing:w}=x(a.theme,r.themes);o.push(...w);let{telemetry:T,telemetryMissing:E}=S(a.telemetry,r.telemetry);o.push(...E);let D=C(a.experiments,r.experiments,o);if(i.strict&&o.length>0){let e=o.map(e=>`${e.type}:${e.identifier}`).join(`, `);throw Error(`composeAppConfig: missing references -> ${e}`)}return{resolved:a,capabilities:c,features:l,dataViews:u,workflows:d,policies:f,theme:m,themeFallbacks:h,telemetry:T,experiments:D,integrations:a.integrations,knowledge:a.knowledge,missing:o}}function n(e,t){let n=k([...e?.enabled??[],...t?.enable??[]],w),r=k([...e?.disabled??[],...t?.disable??[]],w),i=new Set(r.map(w));return{enabled:n.filter(e=>!i.has(w(e))),disabled:r}}function r(e,t){let n=k([...e?.include??[],...t?.include??[]],T),r=k([...e?.exclude??[],...t?.exclude??[]],T),i=new Set(r.map(T));return{include:n.filter(e=>!i.has(T(e))),exclude:r}}function i(e,t){let n={...e};if(!t)return n;for(let e of t)e&&(e.pointer?n[e.slot]=e.pointer:delete n[e.slot]);return n}function a(e,t){return k([...e,...t],D)}function o(e,t){if(!e&&!t)return;let n=t?.primary??e?.primary;if(n)return{primary:n,fallbacks:t?.fallbacks??e?.fallbacks??[]}}function s(e,t){if(!e&&!t)return;let n={spec:e?.spec,disabledEvents:e?.disabledEvents?[...e.disabledEvents]:void 0,samplingOverrides:e?.samplingOverrides?{...e.samplingOverrides}:void 0};if(t?.spec!==void 0&&(n.spec=t.spec??void 0),t?.disabledEvents&&(n.disabledEvents=A([...n.disabledEvents??[],...t.disabledEvents])),t?.samplingOverrides&&(n.samplingOverrides={...n.samplingOverrides??{},...t.samplingOverrides}),!(!n.spec&&!n.disabledEvents?.length))return n}function c(e,t){let n=e?.active??[],r=e?.paused??[],i=t?.active,a=t?.paused,o=i&&i.length>0?i:n,s=a&&a.length>0?a:r,c=k(o,O),l=k(s,O),u=new Set(c.map(O));return l=l.filter(e=>!u.has(O(e))),{catalog:k([...n,...r,...i??[],...a??[]],O),active:c,paused:l}}function l(e,t){let n=t.branding,r=t.meta,i=`app.localhost`,a=n?.customDomain??(n?.subdomain?`${n.subdomain}.${i}`:`${r.tenantId}.${i}`),o=[];t.locales?.defaultLocale&&o.push(t.locales.defaultLocale),n?.appName&&o.push(`default`,`en`);let s;if(n?.appName){for(let e of o){let t=n.appName[e];if(t){s=t;break}}if(!s){let[,e]=Object.entries(n.appName)[0]??[];typeof e==`string`&&(s=e)}}s||=e?.appNameKey??r.appId;let c=new Map,l=e=>{if(e)for(let t of e)t?.type&&`url`in t&&t.url&&c.set(t.type,t.url)};l(e?.assets),l(n?.assets);let u={logo:c.get(`logo`),logoDark:c.get(`logo-dark`),favicon:c.get(`favicon`),ogImage:c.get(`og-image`)},d={primary:n?.colors?.primary??e?.colorTokens?.primary??`#1f2937`,secondary:n?.colors?.secondary??e?.colorTokens?.secondary??`#4b5563`};return{appName:s,assets:u,colors:d,domain:a}}function u(e,t,n){let r=t?.defaultLocale??`en`;return{defaultLocale:r,supportedLocales:A([r,...t?.enabledLocales??[]]),blueprintCatalog:e,tenantOverrides:n?.entries??[]}}function d(e,t){let n=new Map;for(let t of e)n.set(t.key,{...t});for(let e of t)n.set(e.key,{...e});return[...n.values()]}function f(e,t){let n=new Map;for(let t of e)n.set(t.path,{...t});for(let e of t){let t=n.get(e.path)??{path:e.path};e.label!==void 0&&(e.label===null?delete t.label:t.label=e.label),e.dataView!==void 0&&(e.dataView===null?delete t.dataView:t.dataView=e.dataView),e.workflow!==void 0&&(e.workflow===null?delete t.workflow:t.workflow=e.workflow),e.guard!==void 0&&(e.guard===null?delete t.guard:t.guard=e.guard),e.featureFlag!==void 0&&(e.featureFlag===null?delete t.featureFlag:t.featureFlag=e.featureFlag),e.experiment!==void 0&&(e.experiment===null?delete t.experiment:t.experiment=e.experiment),n.set(t.path,t)}return[...n.values()]}function p(e,t,n,r){let i=[],a=[],o=new Set,s=e=>{let t=`${e.type}:${e.identifier}`;o.has(t)||(o.add(t),a.push(e))},c=e??[],l=new Map;for(let e of c)l.set(e.slotId,e);let u=new Map;for(let e of t??[]){if(!l.get(e.slotId)){s({type:`integrationSlot`,identifier:`slot:${e.slotId}`});continue}let t=u.get(e.slotId);t?t.push(e):u.set(e.slotId,[e])}for(let e of c){let t=u.get(e.slotId)??[];e.required&&t.length===0&&s({type:`integrationSlot`,identifier:`slot:${e.slotId}`})}if(!n||!r)return{resolved:i,missing:a};let d=new Map;for(let e of n)d.set(e.meta.id,e);for(let e of c){let t=u.get(e.slotId)??[];if(t.length===0)continue;let n=[...t].sort((e,t)=>{let n=e.priority??2**53-1,r=t.priority??2**53-1;return n===r?0:n<r?-1:1}),a=!1;for(let t of n){let n=d.get(t.connectionId);if(!n){s({type:`integrationConnection`,identifier:`connection:${t.connectionId}`});continue}let o=r.get(n.meta.integrationKey,n.meta.integrationVersion);if(!o){s({type:`integrationSpec`,identifier:`spec:${n.meta.integrationKey}.v${n.meta.integrationVersion}`});continue}if(o.meta.category!==e.requiredCategory){s({type:`integrationSpec`,identifier:`spec:${o.meta.key}.category`});continue}if(!o.supportedModes.includes(n.ownershipMode)){s({type:`integrationSpec`,identifier:`spec:${o.meta.key}.mode:${n.ownershipMode}`});continue}if(e.allowedModes&&e.allowedModes.length>0&&!e.allowedModes.includes(n.ownershipMode)){s({type:`integrationConnection`,identifier:`connection:${n.meta.id}:mode`});continue}if(e.requiredCapabilities&&!e.requiredCapabilities.every(e=>m(o,e))){s({type:`integrationSpec`,identifier:`spec:${o.meta.key}.capabilities`});continue}i.push({slot:e,binding:t,connection:n,spec:o}),a=!0;break}!a&&e.required&&s({type:`integrationSlot`,identifier:`slot:${e.slotId}`})}return{resolved:i,missing:a}}function m(e,t){return e.capabilities.provides.some(e=>e.key===t.key?t.version==null?!0:e.version===t.version:!1)}function h(e,t,n){if(!e?.length||!t)return[];let r=n??[];return e.map(e=>{let n=t.get(e.spaceKey,e.spaceVersion);return n?{binding:e,space:n,sources:r.filter(t=>t.meta.spaceKey===e.spaceKey?e.spaceVersion==null?!0:t.meta.spaceVersion===e.spaceVersion:!1)}:null}).filter(e=>e!==null)}function g(e,t,n){if(!e.length||!t)return[];let r=[],i=n??[];for(let a of e){if(!t.get(a.spaceKey,a.spaceVersion)){r.push({type:`knowledgeSpace`,identifier:a.spaceVersion?`${a.spaceKey}@${a.spaceVersion}`:a.spaceKey});continue}n&&i.filter(e=>e.meta.spaceKey===a.spaceKey?a.spaceVersion==null?!0:e.meta.spaceVersion===a.spaceVersion:!1).length===0&&r.push({type:`knowledgeSource`,identifier:a.spaceVersion?`${a.spaceKey}@${a.spaceVersion}`:a.spaceKey})}return r}function _(e,t,n){if(!t){if(e.length>0)for(let t of e)n.push({type:`capability`,identifier:w(t)});return[]}let r=[];for(let i of e){let e=t.get(i.key,i.version);if(!e){n.push({type:`capability`,identifier:w(i)});continue}r.push(e)}return r}function v(e,t,n){if(!t){if(e.length>0)for(let t of e)n.push({type:`feature`,identifier:t.key});return[]}let r=[];for(let i of e){let e=t.get(i.key);if(!e){n.push({type:`feature`,identifier:i.key});continue}r.push(e)}return r}function y(e,t,n,r){if(!t){if(Object.keys(e).length>0)for(let[t,i]of Object.entries(e))r.push({type:n,identifier:`${t} -> ${E(i)}`});return{}}let i={};for(let[a,o]of Object.entries(e)){let e=t.get(o.name,o.version);if(!e){r.push({type:n,identifier:`${a} -> ${E(o)}`});continue}i[a]=e}return i}function b(e,t,n){if(!t){if(e.length>0)for(let t of e)n.push({type:`policy`,identifier:D(t)});return[]}let r=[];for(let i of e){let e=t.get(i.name,i.version);if(!e){n.push({type:`policy`,identifier:D(i)});continue}r.push(e)}return r}function x(e,t){let n=[];if(!e)return{theme:void 0,fallbacks:[],themeMissing:n};if(!t){n.push({type:`theme`,identifier:`${e.primary.name}.v${e.primary.version}`});for(let t of e.fallbacks??[])n.push({type:`theme`,identifier:`${t.name}.v${t.version}`});return{theme:void 0,fallbacks:[],themeMissing:n}}let r=t.get(e.primary.name,e.primary.version);r||n.push({type:`theme`,identifier:`${e.primary.name}.v${e.primary.version}`});let i=[];for(let r of e.fallbacks??[]){let e=t.get(r.name,r.version);if(!e){n.push({type:`theme`,identifier:`${r.name}.v${r.version}`});continue}i.push(e)}return{theme:r??void 0,fallbacks:i,themeMissing:n}}function S(e,t){let n=[];if(!e?.spec)return{telemetry:void 0,telemetryMissing:n};if(!t)return n.push({type:`telemetry`,identifier:E(e.spec)}),{telemetry:void 0,telemetryMissing:n};let r=t.get(e.spec.name,e.spec.version);return r||n.push({type:`telemetry`,identifier:E(e.spec)}),{telemetry:r??void 0,telemetryMissing:n}}function C(e,t,n){let r=e=>{if(e.length===0)return[];if(!t){for(let t of e)n.push({type:`experiment`,identifier:O(t)});return[]}let r=[];for(let i of e){let e=t.get(i.name,i.version);if(!e){n.push({type:`experiment`,identifier:O(i)});continue}r.push(e)}return r};return{active:r(e.active),paused:r(e.paused)}}function w(e){return`${e.key}${e.version?`.v${e.version}`:``}`}function T(e){return e.key}function E(e){return`${e.name}${e.version?`.v${e.version}`:``}`}function D(e){return`${e.name}${e.version?`.v${e.version}`:``}`}function O(e){return`${e.name}${e.version?`.v${e.version}`:``}`}function k(e,t){let n=new Map;for(let r of e)n.set(t(r),r);return[...n.values()]}function A(e){return[...new Set(e)]}export{t as composeAppConfig,e as resolveAppConfig};
|
|
1
|
+
//#region src/app-config/runtime.ts
|
|
2
|
+
function resolveAppConfig(blueprint, tenant, deps = {}) {
|
|
3
|
+
const capabilities = mergeCapabilities(blueprint.capabilities, tenant.capabilities);
|
|
4
|
+
const features = mergeFeatures(blueprint.features, tenant.features);
|
|
5
|
+
const dataViews = mergeMappings(blueprint.dataViews ?? {}, tenant.dataViewOverrides);
|
|
6
|
+
const workflows = mergeMappings(blueprint.workflows ?? {}, tenant.workflowOverrides);
|
|
7
|
+
const policies = mergePolicies(blueprint.policies ?? [], tenant.additionalPolicies ?? []);
|
|
8
|
+
const theme = mergeTheme(blueprint.theme, tenant.themeOverride);
|
|
9
|
+
const telemetry = mergeTelemetry(blueprint.telemetry, tenant.telemetryOverride);
|
|
10
|
+
const experiments = mergeExperiments(blueprint.experiments, tenant.experiments);
|
|
11
|
+
const featureFlags = mergeFeatureFlags(blueprint.featureFlags ?? [], tenant.featureFlags ?? []);
|
|
12
|
+
const routes = mergeRoutes(blueprint.routes ?? [], tenant.routeOverrides ?? []);
|
|
13
|
+
const { resolved: integrations } = evaluateIntegrationSlots(blueprint.integrationSlots, tenant.integrations, deps.integrationConnections, deps.integrationSpecs);
|
|
14
|
+
const knowledge = resolveKnowledgeBindings(tenant.knowledge, deps.knowledgeSpaces, deps.knowledgeSources);
|
|
15
|
+
const branding = resolveBranding(blueprint.branding, tenant);
|
|
16
|
+
const translation = resolveTranslation(blueprint.translationCatalog, tenant.locales, tenant.translationOverrides);
|
|
17
|
+
return {
|
|
18
|
+
appId: blueprint.meta.appId,
|
|
19
|
+
tenantId: tenant.meta.tenantId,
|
|
20
|
+
environment: tenant.meta.environment,
|
|
21
|
+
blueprintName: blueprint.meta.name,
|
|
22
|
+
blueprintVersion: blueprint.meta.version,
|
|
23
|
+
configVersion: tenant.meta.version,
|
|
24
|
+
capabilities,
|
|
25
|
+
features,
|
|
26
|
+
dataViews,
|
|
27
|
+
workflows,
|
|
28
|
+
policies,
|
|
29
|
+
theme,
|
|
30
|
+
telemetry,
|
|
31
|
+
experiments,
|
|
32
|
+
featureFlags,
|
|
33
|
+
routes,
|
|
34
|
+
integrations,
|
|
35
|
+
knowledge,
|
|
36
|
+
translation,
|
|
37
|
+
branding,
|
|
38
|
+
notes: tenant.notes ?? blueprint.notes
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function composeAppConfig(blueprint, tenant, deps, options = {}) {
|
|
42
|
+
const resolved = resolveAppConfig(blueprint, tenant, deps);
|
|
43
|
+
const missing = [];
|
|
44
|
+
const integrationEvaluation = evaluateIntegrationSlots(blueprint.integrationSlots, tenant.integrations, deps.integrationConnections, deps.integrationSpecs);
|
|
45
|
+
resolved.integrations = integrationEvaluation.resolved;
|
|
46
|
+
missing.push(...integrationEvaluation.missing);
|
|
47
|
+
missing.push(...collectMissingKnowledge(tenant.knowledge ?? [], deps.knowledgeSpaces, deps.knowledgeSources));
|
|
48
|
+
const capabilities = resolveCapabilityRefs(resolved.capabilities.enabled, deps.capabilities, missing);
|
|
49
|
+
const features = resolveFeatureRefs(resolved.features.include, deps.features, missing);
|
|
50
|
+
const dataViews = resolvePointerRecord(resolved.dataViews, deps.dataViews, "dataView", missing);
|
|
51
|
+
const workflows = resolvePointerRecord(resolved.workflows, deps.workflows, "workflow", missing);
|
|
52
|
+
const policies = resolvePolicies(resolved.policies, deps.policies, missing);
|
|
53
|
+
const { theme, fallbacks, themeMissing } = resolveThemeBinding(resolved.theme, deps.themes);
|
|
54
|
+
missing.push(...themeMissing);
|
|
55
|
+
const { telemetry, telemetryMissing } = resolveTelemetryBinding(resolved.telemetry, deps.telemetry);
|
|
56
|
+
missing.push(...telemetryMissing);
|
|
57
|
+
const experiments = resolveExperimentsSpecs(resolved.experiments, deps.experiments, missing);
|
|
58
|
+
if (options.strict && missing.length > 0) {
|
|
59
|
+
const reasons = missing.map((item) => `${item.type}:${item.identifier}`).join(", ");
|
|
60
|
+
throw new Error(`composeAppConfig: missing references -> ${reasons}`);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
resolved,
|
|
64
|
+
capabilities,
|
|
65
|
+
features,
|
|
66
|
+
dataViews,
|
|
67
|
+
workflows,
|
|
68
|
+
policies,
|
|
69
|
+
theme,
|
|
70
|
+
themeFallbacks: fallbacks,
|
|
71
|
+
telemetry,
|
|
72
|
+
experiments,
|
|
73
|
+
integrations: resolved.integrations,
|
|
74
|
+
knowledge: resolved.knowledge,
|
|
75
|
+
missing
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function mergeCapabilities(blueprint, tenant) {
|
|
79
|
+
const enabled = dedupeRefs([...blueprint?.enabled ?? [], ...tenant?.enable ?? []], capabilityKey);
|
|
80
|
+
const disabled = dedupeRefs([...blueprint?.disabled ?? [], ...tenant?.disable ?? []], capabilityKey);
|
|
81
|
+
const disabledKeys = new Set(disabled.map(capabilityKey));
|
|
82
|
+
return {
|
|
83
|
+
enabled: enabled.filter((ref) => !disabledKeys.has(capabilityKey(ref))),
|
|
84
|
+
disabled
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function mergeFeatures(blueprint, tenant) {
|
|
88
|
+
const include = dedupeRefs([...blueprint?.include ?? [], ...tenant?.include ?? []], featureKey);
|
|
89
|
+
const exclude = dedupeRefs([...blueprint?.exclude ?? [], ...tenant?.exclude ?? []], featureKey);
|
|
90
|
+
const excludeSet = new Set(exclude.map(featureKey));
|
|
91
|
+
return {
|
|
92
|
+
include: include.filter((ref) => !excludeSet.has(featureKey(ref))),
|
|
93
|
+
exclude
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function mergeMappings(blueprint, overrides) {
|
|
97
|
+
const merged = { ...blueprint };
|
|
98
|
+
if (!overrides) return merged;
|
|
99
|
+
for (const override of overrides) {
|
|
100
|
+
if (!override) continue;
|
|
101
|
+
if (!override.pointer) delete merged[override.slot];
|
|
102
|
+
else merged[override.slot] = override.pointer;
|
|
103
|
+
}
|
|
104
|
+
return merged;
|
|
105
|
+
}
|
|
106
|
+
function mergePolicies(blueprint, additional) {
|
|
107
|
+
return dedupeRefs([...blueprint, ...additional], policyKey);
|
|
108
|
+
}
|
|
109
|
+
function mergeTheme(blueprint, override) {
|
|
110
|
+
if (!blueprint && !override) return void 0;
|
|
111
|
+
const primary = override?.primary ?? blueprint?.primary;
|
|
112
|
+
if (!primary) return void 0;
|
|
113
|
+
return {
|
|
114
|
+
primary,
|
|
115
|
+
fallbacks: override?.fallbacks ?? blueprint?.fallbacks ?? []
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function mergeTelemetry(blueprint, override) {
|
|
119
|
+
if (!blueprint && !override) return void 0;
|
|
120
|
+
const binding = {
|
|
121
|
+
spec: blueprint?.spec,
|
|
122
|
+
disabledEvents: blueprint?.disabledEvents ? [...blueprint.disabledEvents] : void 0,
|
|
123
|
+
samplingOverrides: blueprint?.samplingOverrides ? { ...blueprint.samplingOverrides } : void 0
|
|
124
|
+
};
|
|
125
|
+
if (override?.spec !== void 0) binding.spec = override.spec ?? void 0;
|
|
126
|
+
if (override?.disabledEvents) binding.disabledEvents = dedupeStrings([...binding.disabledEvents ?? [], ...override.disabledEvents]);
|
|
127
|
+
if (override?.samplingOverrides) binding.samplingOverrides = {
|
|
128
|
+
...binding.samplingOverrides ?? {},
|
|
129
|
+
...override.samplingOverrides
|
|
130
|
+
};
|
|
131
|
+
if (!binding.spec && !binding.disabledEvents?.length) return;
|
|
132
|
+
return binding;
|
|
133
|
+
}
|
|
134
|
+
function mergeExperiments(blueprint, tenant) {
|
|
135
|
+
const defaultActive = blueprint?.active ?? [];
|
|
136
|
+
const defaultPaused = blueprint?.paused ?? [];
|
|
137
|
+
const tenantActive = tenant?.active;
|
|
138
|
+
const tenantPaused = tenant?.paused;
|
|
139
|
+
const activeSource = tenantActive && tenantActive.length > 0 ? tenantActive : defaultActive;
|
|
140
|
+
const pausedSource = tenantPaused && tenantPaused.length > 0 ? tenantPaused : defaultPaused;
|
|
141
|
+
const active = dedupeRefs(activeSource, experimentKey);
|
|
142
|
+
let paused = dedupeRefs(pausedSource, experimentKey);
|
|
143
|
+
const activeKeys = new Set(active.map(experimentKey));
|
|
144
|
+
paused = paused.filter((ref) => !activeKeys.has(experimentKey(ref)));
|
|
145
|
+
return {
|
|
146
|
+
catalog: dedupeRefs([
|
|
147
|
+
...defaultActive,
|
|
148
|
+
...defaultPaused,
|
|
149
|
+
...tenantActive ?? [],
|
|
150
|
+
...tenantPaused ?? []
|
|
151
|
+
], experimentKey),
|
|
152
|
+
active,
|
|
153
|
+
paused
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function resolveBranding(defaults, tenant) {
|
|
157
|
+
const override = tenant.branding;
|
|
158
|
+
const tenantMeta = tenant.meta;
|
|
159
|
+
const baseDomain = "app.localhost";
|
|
160
|
+
const domain = override?.customDomain ?? (override?.subdomain ? `${override.subdomain}.${baseDomain}` : `${tenantMeta.tenantId}.${baseDomain}`);
|
|
161
|
+
const localePreferenceOrder = [];
|
|
162
|
+
if (tenant.locales?.defaultLocale) localePreferenceOrder.push(tenant.locales.defaultLocale);
|
|
163
|
+
if (override?.appName) localePreferenceOrder.push("default", "en");
|
|
164
|
+
let appName;
|
|
165
|
+
if (override?.appName) {
|
|
166
|
+
for (const key of localePreferenceOrder) {
|
|
167
|
+
const candidate = override.appName[key];
|
|
168
|
+
if (candidate) {
|
|
169
|
+
appName = candidate;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!appName) {
|
|
174
|
+
const [, firstValue] = Object.entries(override.appName)[0] ?? [];
|
|
175
|
+
if (typeof firstValue === "string") appName = firstValue;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (!appName) appName = defaults?.appNameKey ?? tenantMeta.appId;
|
|
179
|
+
const assetEntries = /* @__PURE__ */ new Map();
|
|
180
|
+
const applyAssets = (assets$1) => {
|
|
181
|
+
if (!assets$1) return;
|
|
182
|
+
for (const asset of assets$1) {
|
|
183
|
+
if (!asset?.type) continue;
|
|
184
|
+
if ("url" in asset && asset.url) assetEntries.set(asset.type, asset.url);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
applyAssets(defaults?.assets);
|
|
188
|
+
applyAssets(override?.assets);
|
|
189
|
+
const assets = {
|
|
190
|
+
logo: assetEntries.get("logo"),
|
|
191
|
+
logoDark: assetEntries.get("logo-dark"),
|
|
192
|
+
favicon: assetEntries.get("favicon"),
|
|
193
|
+
ogImage: assetEntries.get("og-image")
|
|
194
|
+
};
|
|
195
|
+
const colors = {
|
|
196
|
+
primary: override?.colors?.primary ?? defaults?.colorTokens?.primary ?? "#1f2937",
|
|
197
|
+
secondary: override?.colors?.secondary ?? defaults?.colorTokens?.secondary ?? "#4b5563"
|
|
198
|
+
};
|
|
199
|
+
return {
|
|
200
|
+
appName,
|
|
201
|
+
assets,
|
|
202
|
+
colors,
|
|
203
|
+
domain
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function resolveTranslation(catalogPointer, locales, overrides) {
|
|
207
|
+
const defaultLocale = locales?.defaultLocale ?? "en";
|
|
208
|
+
return {
|
|
209
|
+
defaultLocale,
|
|
210
|
+
supportedLocales: dedupeStrings([defaultLocale, ...locales?.enabledLocales ?? []]),
|
|
211
|
+
blueprintCatalog: catalogPointer,
|
|
212
|
+
tenantOverrides: overrides?.entries ?? []
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function mergeFeatureFlags(blueprint, overrides) {
|
|
216
|
+
const merged = /* @__PURE__ */ new Map();
|
|
217
|
+
for (const flag of blueprint) merged.set(flag.key, { ...flag });
|
|
218
|
+
for (const override of overrides) merged.set(override.key, { ...override });
|
|
219
|
+
return [...merged.values()];
|
|
220
|
+
}
|
|
221
|
+
function mergeRoutes(blueprint, overrides) {
|
|
222
|
+
const routes = /* @__PURE__ */ new Map();
|
|
223
|
+
for (const route of blueprint) routes.set(route.path, { ...route });
|
|
224
|
+
for (const override of overrides) {
|
|
225
|
+
const existing = routes.get(override.path) ?? { path: override.path };
|
|
226
|
+
if (override.label !== void 0) if (override.label === null) delete existing.label;
|
|
227
|
+
else existing.label = override.label;
|
|
228
|
+
if (override.dataView !== void 0) if (override.dataView === null) delete existing.dataView;
|
|
229
|
+
else existing.dataView = override.dataView;
|
|
230
|
+
if (override.workflow !== void 0) if (override.workflow === null) delete existing.workflow;
|
|
231
|
+
else existing.workflow = override.workflow;
|
|
232
|
+
if (override.guard !== void 0) if (override.guard === null) delete existing.guard;
|
|
233
|
+
else existing.guard = override.guard;
|
|
234
|
+
if (override.featureFlag !== void 0) if (override.featureFlag === null) delete existing.featureFlag;
|
|
235
|
+
else existing.featureFlag = override.featureFlag;
|
|
236
|
+
if (override.experiment !== void 0) if (override.experiment === null) delete existing.experiment;
|
|
237
|
+
else existing.experiment = override.experiment;
|
|
238
|
+
routes.set(existing.path, existing);
|
|
239
|
+
}
|
|
240
|
+
return [...routes.values()];
|
|
241
|
+
}
|
|
242
|
+
function evaluateIntegrationSlots(slots, bindings, connections, specs) {
|
|
243
|
+
const resolved = [];
|
|
244
|
+
const missing = [];
|
|
245
|
+
const missingKeys = /* @__PURE__ */ new Set();
|
|
246
|
+
const recordMissing = (entry) => {
|
|
247
|
+
const key = `${entry.type}:${entry.identifier}`;
|
|
248
|
+
if (missingKeys.has(key)) return;
|
|
249
|
+
missingKeys.add(key);
|
|
250
|
+
missing.push(entry);
|
|
251
|
+
};
|
|
252
|
+
const slotList = slots ?? [];
|
|
253
|
+
const slotById = /* @__PURE__ */ new Map();
|
|
254
|
+
for (const slot of slotList) slotById.set(slot.slotId, slot);
|
|
255
|
+
const bindingsBySlot = /* @__PURE__ */ new Map();
|
|
256
|
+
for (const binding of bindings ?? []) {
|
|
257
|
+
if (!slotById.get(binding.slotId)) {
|
|
258
|
+
recordMissing({
|
|
259
|
+
type: "integrationSlot",
|
|
260
|
+
identifier: `slot:${binding.slotId}`
|
|
261
|
+
});
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const entries = bindingsBySlot.get(binding.slotId);
|
|
265
|
+
if (entries) entries.push(binding);
|
|
266
|
+
else bindingsBySlot.set(binding.slotId, [binding]);
|
|
267
|
+
}
|
|
268
|
+
for (const slot of slotList) {
|
|
269
|
+
const slotBindings = bindingsBySlot.get(slot.slotId) ?? [];
|
|
270
|
+
if (slot.required && slotBindings.length === 0) recordMissing({
|
|
271
|
+
type: "integrationSlot",
|
|
272
|
+
identifier: `slot:${slot.slotId}`
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (!connections || !specs) return {
|
|
276
|
+
resolved,
|
|
277
|
+
missing
|
|
278
|
+
};
|
|
279
|
+
const connectionById = /* @__PURE__ */ new Map();
|
|
280
|
+
for (const connection of connections) connectionById.set(connection.meta.id, connection);
|
|
281
|
+
for (const slot of slotList) {
|
|
282
|
+
const slotBindings = bindingsBySlot.get(slot.slotId) ?? [];
|
|
283
|
+
if (slotBindings.length === 0) continue;
|
|
284
|
+
const orderedBindings = [...slotBindings].sort((a, b) => {
|
|
285
|
+
const aPriority = a.priority ?? Number.MAX_SAFE_INTEGER;
|
|
286
|
+
const bPriority = b.priority ?? Number.MAX_SAFE_INTEGER;
|
|
287
|
+
if (aPriority === bPriority) return 0;
|
|
288
|
+
return aPriority < bPriority ? -1 : 1;
|
|
289
|
+
});
|
|
290
|
+
let slotResolved = false;
|
|
291
|
+
for (const binding of orderedBindings) {
|
|
292
|
+
const connection = connectionById.get(binding.connectionId);
|
|
293
|
+
if (!connection) {
|
|
294
|
+
recordMissing({
|
|
295
|
+
type: "integrationConnection",
|
|
296
|
+
identifier: `connection:${binding.connectionId}`
|
|
297
|
+
});
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const spec = specs.get(connection.meta.integrationKey, connection.meta.integrationVersion);
|
|
301
|
+
if (!spec) {
|
|
302
|
+
recordMissing({
|
|
303
|
+
type: "integrationSpec",
|
|
304
|
+
identifier: `spec:${connection.meta.integrationKey}.v${connection.meta.integrationVersion}`
|
|
305
|
+
});
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (spec.meta.category !== slot.requiredCategory) {
|
|
309
|
+
recordMissing({
|
|
310
|
+
type: "integrationSpec",
|
|
311
|
+
identifier: `spec:${spec.meta.key}.category`
|
|
312
|
+
});
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (!spec.supportedModes.includes(connection.ownershipMode)) {
|
|
316
|
+
recordMissing({
|
|
317
|
+
type: "integrationSpec",
|
|
318
|
+
identifier: `spec:${spec.meta.key}.mode:${connection.ownershipMode}`
|
|
319
|
+
});
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (slot.allowedModes && slot.allowedModes.length > 0 && !slot.allowedModes.includes(connection.ownershipMode)) {
|
|
323
|
+
recordMissing({
|
|
324
|
+
type: "integrationConnection",
|
|
325
|
+
identifier: `connection:${connection.meta.id}:mode`
|
|
326
|
+
});
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (slot.requiredCapabilities && !slot.requiredCapabilities.every((requirement) => integrationProvidesCapability(spec, requirement))) {
|
|
330
|
+
recordMissing({
|
|
331
|
+
type: "integrationSpec",
|
|
332
|
+
identifier: `spec:${spec.meta.key}.capabilities`
|
|
333
|
+
});
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
resolved.push({
|
|
337
|
+
slot,
|
|
338
|
+
binding,
|
|
339
|
+
connection,
|
|
340
|
+
spec
|
|
341
|
+
});
|
|
342
|
+
slotResolved = true;
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
if (!slotResolved && slot.required) recordMissing({
|
|
346
|
+
type: "integrationSlot",
|
|
347
|
+
identifier: `slot:${slot.slotId}`
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
resolved,
|
|
352
|
+
missing
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function integrationProvidesCapability(spec, required) {
|
|
356
|
+
return spec.capabilities.provides.some((capability) => {
|
|
357
|
+
if (capability.key !== required.key) return false;
|
|
358
|
+
if (required.version == null) return true;
|
|
359
|
+
return capability.version === required.version;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function resolveKnowledgeBindings(bindings, spaces, sources) {
|
|
363
|
+
if (!bindings?.length || !spaces) return [];
|
|
364
|
+
const sourceList = sources ?? [];
|
|
365
|
+
return bindings.map((binding) => {
|
|
366
|
+
const space = spaces.get(binding.spaceKey, binding.spaceVersion);
|
|
367
|
+
if (!space) return null;
|
|
368
|
+
return {
|
|
369
|
+
binding,
|
|
370
|
+
space,
|
|
371
|
+
sources: sourceList.filter((source) => {
|
|
372
|
+
if (source.meta.spaceKey !== binding.spaceKey) return false;
|
|
373
|
+
if (binding.spaceVersion != null) return source.meta.spaceVersion === binding.spaceVersion;
|
|
374
|
+
return true;
|
|
375
|
+
})
|
|
376
|
+
};
|
|
377
|
+
}).filter((entry) => entry !== null);
|
|
378
|
+
}
|
|
379
|
+
function collectMissingKnowledge(bindings, spaces, sources) {
|
|
380
|
+
if (!bindings.length || !spaces) return [];
|
|
381
|
+
const missing = [];
|
|
382
|
+
const sourceList = sources ?? [];
|
|
383
|
+
for (const binding of bindings) {
|
|
384
|
+
if (!spaces.get(binding.spaceKey, binding.spaceVersion)) {
|
|
385
|
+
missing.push({
|
|
386
|
+
type: "knowledgeSpace",
|
|
387
|
+
identifier: binding.spaceVersion ? `${binding.spaceKey}@${binding.spaceVersion}` : binding.spaceKey
|
|
388
|
+
});
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (sources) {
|
|
392
|
+
if (sourceList.filter((source) => {
|
|
393
|
+
if (source.meta.spaceKey !== binding.spaceKey) return false;
|
|
394
|
+
if (binding.spaceVersion != null) return source.meta.spaceVersion === binding.spaceVersion;
|
|
395
|
+
return true;
|
|
396
|
+
}).length === 0) missing.push({
|
|
397
|
+
type: "knowledgeSource",
|
|
398
|
+
identifier: binding.spaceVersion ? `${binding.spaceKey}@${binding.spaceVersion}` : binding.spaceKey
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return missing;
|
|
403
|
+
}
|
|
404
|
+
function resolveCapabilityRefs(refs, registry, missing) {
|
|
405
|
+
if (!registry) {
|
|
406
|
+
if (refs.length > 0) for (const ref of refs) missing.push({
|
|
407
|
+
type: "capability",
|
|
408
|
+
identifier: capabilityKey(ref)
|
|
409
|
+
});
|
|
410
|
+
return [];
|
|
411
|
+
}
|
|
412
|
+
const resolved = [];
|
|
413
|
+
for (const ref of refs) {
|
|
414
|
+
const spec = registry.get(ref.key, ref.version);
|
|
415
|
+
if (!spec) {
|
|
416
|
+
missing.push({
|
|
417
|
+
type: "capability",
|
|
418
|
+
identifier: capabilityKey(ref)
|
|
419
|
+
});
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
resolved.push(spec);
|
|
423
|
+
}
|
|
424
|
+
return resolved;
|
|
425
|
+
}
|
|
426
|
+
function resolveFeatureRefs(refs, registry, missing) {
|
|
427
|
+
if (!registry) {
|
|
428
|
+
if (refs.length > 0) for (const ref of refs) missing.push({
|
|
429
|
+
type: "feature",
|
|
430
|
+
identifier: ref.key
|
|
431
|
+
});
|
|
432
|
+
return [];
|
|
433
|
+
}
|
|
434
|
+
const resolved = [];
|
|
435
|
+
for (const ref of refs) {
|
|
436
|
+
const spec = registry.get(ref.key);
|
|
437
|
+
if (!spec) {
|
|
438
|
+
missing.push({
|
|
439
|
+
type: "feature",
|
|
440
|
+
identifier: ref.key
|
|
441
|
+
});
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
resolved.push(spec);
|
|
445
|
+
}
|
|
446
|
+
return resolved;
|
|
447
|
+
}
|
|
448
|
+
function resolvePointerRecord(record, registry, type, missing) {
|
|
449
|
+
if (!registry) {
|
|
450
|
+
if (Object.keys(record).length > 0) for (const [slot, pointer] of Object.entries(record)) missing.push({
|
|
451
|
+
type,
|
|
452
|
+
identifier: `${slot} -> ${specPointerKey(pointer)}`
|
|
453
|
+
});
|
|
454
|
+
return {};
|
|
455
|
+
}
|
|
456
|
+
const resolved = {};
|
|
457
|
+
for (const [slot, pointer] of Object.entries(record)) {
|
|
458
|
+
const spec = registry.get(pointer.name, pointer.version);
|
|
459
|
+
if (!spec) {
|
|
460
|
+
missing.push({
|
|
461
|
+
type,
|
|
462
|
+
identifier: `${slot} -> ${specPointerKey(pointer)}`
|
|
463
|
+
});
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
resolved[slot] = spec;
|
|
467
|
+
}
|
|
468
|
+
return resolved;
|
|
469
|
+
}
|
|
470
|
+
function resolvePolicies(policies, registry, missing) {
|
|
471
|
+
if (!registry) {
|
|
472
|
+
if (policies.length > 0) for (const policy of policies) missing.push({
|
|
473
|
+
type: "policy",
|
|
474
|
+
identifier: policyKey(policy)
|
|
475
|
+
});
|
|
476
|
+
return [];
|
|
477
|
+
}
|
|
478
|
+
const resolved = [];
|
|
479
|
+
for (const policy of policies) {
|
|
480
|
+
const spec = registry.get(policy.name, policy.version);
|
|
481
|
+
if (!spec) {
|
|
482
|
+
missing.push({
|
|
483
|
+
type: "policy",
|
|
484
|
+
identifier: policyKey(policy)
|
|
485
|
+
});
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
resolved.push(spec);
|
|
489
|
+
}
|
|
490
|
+
return resolved;
|
|
491
|
+
}
|
|
492
|
+
function resolveThemeBinding(binding, registry) {
|
|
493
|
+
const themeMissing = [];
|
|
494
|
+
if (!binding) return {
|
|
495
|
+
theme: void 0,
|
|
496
|
+
fallbacks: [],
|
|
497
|
+
themeMissing
|
|
498
|
+
};
|
|
499
|
+
if (!registry) {
|
|
500
|
+
themeMissing.push({
|
|
501
|
+
type: "theme",
|
|
502
|
+
identifier: `${binding.primary.name}.v${binding.primary.version}`
|
|
503
|
+
});
|
|
504
|
+
for (const fallback of binding.fallbacks ?? []) themeMissing.push({
|
|
505
|
+
type: "theme",
|
|
506
|
+
identifier: `${fallback.name}.v${fallback.version}`
|
|
507
|
+
});
|
|
508
|
+
return {
|
|
509
|
+
theme: void 0,
|
|
510
|
+
fallbacks: [],
|
|
511
|
+
themeMissing
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
const theme = registry.get(binding.primary.name, binding.primary.version);
|
|
515
|
+
if (!theme) themeMissing.push({
|
|
516
|
+
type: "theme",
|
|
517
|
+
identifier: `${binding.primary.name}.v${binding.primary.version}`
|
|
518
|
+
});
|
|
519
|
+
const fallbacks = [];
|
|
520
|
+
for (const fallback of binding.fallbacks ?? []) {
|
|
521
|
+
const spec = registry.get(fallback.name, fallback.version);
|
|
522
|
+
if (!spec) {
|
|
523
|
+
themeMissing.push({
|
|
524
|
+
type: "theme",
|
|
525
|
+
identifier: `${fallback.name}.v${fallback.version}`
|
|
526
|
+
});
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
fallbacks.push(spec);
|
|
530
|
+
}
|
|
531
|
+
return {
|
|
532
|
+
theme: theme ?? void 0,
|
|
533
|
+
fallbacks,
|
|
534
|
+
themeMissing
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function resolveTelemetryBinding(binding, registry) {
|
|
538
|
+
const telemetryMissing = [];
|
|
539
|
+
if (!binding?.spec) return {
|
|
540
|
+
telemetry: void 0,
|
|
541
|
+
telemetryMissing
|
|
542
|
+
};
|
|
543
|
+
if (!registry) {
|
|
544
|
+
telemetryMissing.push({
|
|
545
|
+
type: "telemetry",
|
|
546
|
+
identifier: specPointerKey(binding.spec)
|
|
547
|
+
});
|
|
548
|
+
return {
|
|
549
|
+
telemetry: void 0,
|
|
550
|
+
telemetryMissing
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
const telemetry = registry.get(binding.spec.name, binding.spec.version);
|
|
554
|
+
if (!telemetry) telemetryMissing.push({
|
|
555
|
+
type: "telemetry",
|
|
556
|
+
identifier: specPointerKey(binding.spec)
|
|
557
|
+
});
|
|
558
|
+
return {
|
|
559
|
+
telemetry: telemetry ?? void 0,
|
|
560
|
+
telemetryMissing
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
function resolveExperimentsSpecs(experiments, registry, missing) {
|
|
564
|
+
const resolveList = (refs) => {
|
|
565
|
+
if (refs.length === 0) return [];
|
|
566
|
+
if (!registry) {
|
|
567
|
+
for (const ref of refs) missing.push({
|
|
568
|
+
type: "experiment",
|
|
569
|
+
identifier: experimentKey(ref)
|
|
570
|
+
});
|
|
571
|
+
return [];
|
|
572
|
+
}
|
|
573
|
+
const resolved = [];
|
|
574
|
+
for (const ref of refs) {
|
|
575
|
+
const spec = registry.get(ref.name, ref.version);
|
|
576
|
+
if (!spec) {
|
|
577
|
+
missing.push({
|
|
578
|
+
type: "experiment",
|
|
579
|
+
identifier: experimentKey(ref)
|
|
580
|
+
});
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
resolved.push(spec);
|
|
584
|
+
}
|
|
585
|
+
return resolved;
|
|
586
|
+
};
|
|
587
|
+
return {
|
|
588
|
+
active: resolveList(experiments.active),
|
|
589
|
+
paused: resolveList(experiments.paused)
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function capabilityKey(ref) {
|
|
593
|
+
return `${ref.key}${ref.version ? `.v${ref.version}` : ""}`;
|
|
594
|
+
}
|
|
595
|
+
function featureKey(ref) {
|
|
596
|
+
return ref.key;
|
|
597
|
+
}
|
|
598
|
+
function specPointerKey(pointer) {
|
|
599
|
+
return `${pointer.name}${pointer.version ? `.v${pointer.version}` : ""}`;
|
|
600
|
+
}
|
|
601
|
+
function policyKey(ref) {
|
|
602
|
+
return `${ref.name}${ref.version ? `.v${ref.version}` : ""}`;
|
|
603
|
+
}
|
|
604
|
+
function experimentKey(ref) {
|
|
605
|
+
return `${ref.name}${ref.version ? `.v${ref.version}` : ""}`;
|
|
606
|
+
}
|
|
607
|
+
function dedupeRefs(refs, keyFn) {
|
|
608
|
+
const map = /* @__PURE__ */ new Map();
|
|
609
|
+
for (const ref of refs) map.set(keyFn(ref), ref);
|
|
610
|
+
return [...map.values()];
|
|
611
|
+
}
|
|
612
|
+
function dedupeStrings(values) {
|
|
613
|
+
return [...new Set(values)];
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
//#endregion
|
|
617
|
+
export { composeAppConfig, resolveAppConfig };
|
package/dist/app-config/spec.js
CHANGED
|
@@ -1 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/app-config/spec.ts
|
|
2
|
+
const blueprintKey = (meta) => `${meta.name}.v${meta.version}`;
|
|
3
|
+
var AppBlueprintRegistry = class {
|
|
4
|
+
items = /* @__PURE__ */ new Map();
|
|
5
|
+
register(spec) {
|
|
6
|
+
const key = blueprintKey(spec.meta);
|
|
7
|
+
if (this.items.has(key)) throw new Error(`Duplicate AppBlueprint ${key}`);
|
|
8
|
+
this.items.set(key, spec);
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
list() {
|
|
12
|
+
return [...this.items.values()];
|
|
13
|
+
}
|
|
14
|
+
get(name, version) {
|
|
15
|
+
if (version != null) return this.items.get(blueprintKey({
|
|
16
|
+
name,
|
|
17
|
+
version
|
|
18
|
+
}));
|
|
19
|
+
let latest;
|
|
20
|
+
let maxVersion = -Infinity;
|
|
21
|
+
for (const spec of this.items.values()) {
|
|
22
|
+
if (spec.meta.name !== name) continue;
|
|
23
|
+
if (spec.meta.version > maxVersion) {
|
|
24
|
+
maxVersion = spec.meta.version;
|
|
25
|
+
latest = spec;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return latest;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
function makeAppBlueprintKey(meta) {
|
|
32
|
+
return blueprintKey(meta);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { AppBlueprintRegistry, makeAppBlueprintKey };
|