@pwfabric/runtime 0.0.0-stage → 1.0.0-rc.1
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/LICENSE +90 -0
- package/README.md +43 -2
- package/dist/a11y/announcer.d.ts +65 -0
- package/dist/a11y/announcer.js +140 -0
- package/dist/a11y/announcer.js.map +1 -0
- package/dist/a11y/contrast.d.ts +54 -0
- package/dist/a11y/contrast.js +93 -0
- package/dist/a11y/contrast.js.map +1 -0
- package/dist/a11y/focus.d.ts +123 -0
- package/dist/a11y/focus.js +282 -0
- package/dist/a11y/focus.js.map +1 -0
- package/dist/a11y/index.d.ts +21 -0
- package/dist/a11y/index.js +18 -0
- package/dist/a11y/index.js.map +1 -0
- package/dist/a11y/keyboard.d.ts +144 -0
- package/dist/a11y/keyboard.js +317 -0
- package/dist/a11y/keyboard.js.map +1 -0
- package/dist/adapters/default-image.d.ts +25 -0
- package/dist/adapters/default-image.js +37 -0
- package/dist/adapters/default-image.js.map +1 -0
- package/dist/adapters/index.d.ts +27 -0
- package/dist/adapters/index.js +28 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/next-image.d.ts +38 -0
- package/dist/adapters/next-image.js +124 -0
- package/dist/adapters/next-image.js.map +1 -0
- package/dist/adapters/types.d.ts +61 -0
- package/dist/adapters/types.js +11 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/analytics/index.d.ts +14 -0
- package/dist/analytics/index.js +15 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/tracker.d.ts +65 -0
- package/dist/analytics/tracker.js +251 -0
- package/dist/analytics/tracker.js.map +1 -0
- package/dist/analytics/types.d.ts +130 -0
- package/dist/analytics/types.js +11 -0
- package/dist/analytics/types.js.map +1 -0
- package/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.js +14 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/provider.d.ts +132 -0
- package/dist/auth/provider.js +473 -0
- package/dist/auth/provider.js.map +1 -0
- package/dist/auth/types.d.ts +117 -0
- package/dist/auth/types.js +9 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/binding/collection.d.ts +190 -0
- package/dist/binding/collection.js +358 -0
- package/dist/binding/collection.js.map +1 -0
- package/dist/binding/datasource.d.ts +319 -0
- package/dist/binding/datasource.js +556 -0
- package/dist/binding/datasource.js.map +1 -0
- package/dist/binding/engine.d.ts +65 -0
- package/dist/binding/engine.js +268 -0
- package/dist/binding/engine.js.map +1 -0
- package/dist/binding/expression.d.ts +150 -0
- package/dist/binding/expression.js +787 -0
- package/dist/binding/expression.js.map +1 -0
- package/dist/binding/index.d.ts +19 -0
- package/dist/binding/index.js +14 -0
- package/dist/binding/index.js.map +1 -0
- package/dist/binding/two-way.d.ts +149 -0
- package/dist/binding/two-way.js +462 -0
- package/dist/binding/two-way.js.map +1 -0
- package/dist/binding/types.d.ts +119 -0
- package/dist/binding/types.js +9 -0
- package/dist/binding/types.js.map +1 -0
- package/dist/blocks/component-types.d.ts +81 -0
- package/dist/blocks/component-types.js +11 -0
- package/dist/blocks/component-types.js.map +1 -0
- package/dist/blocks/composition-rules.d.ts +168 -0
- package/dist/blocks/composition-rules.js +391 -0
- package/dist/blocks/composition-rules.js.map +1 -0
- package/dist/blocks/hooks.d.ts +31 -0
- package/dist/blocks/hooks.js +42 -0
- package/dist/blocks/hooks.js.map +1 -0
- package/dist/blocks/index.d.ts +14 -0
- package/dist/blocks/index.js +23 -0
- package/dist/blocks/index.js.map +1 -0
- package/dist/blocks/registry.d.ts +84 -0
- package/dist/blocks/registry.js +136 -0
- package/dist/blocks/registry.js.map +1 -0
- package/dist/blocks/rule-engine.d.ts +131 -0
- package/dist/blocks/rule-engine.js +321 -0
- package/dist/blocks/rule-engine.js.map +1 -0
- package/dist/blocks/surface-event-context.d.ts +13 -0
- package/dist/blocks/surface-event-context.js +14 -0
- package/dist/blocks/surface-event-context.js.map +1 -0
- package/dist/blocks/surface-id-context.d.ts +13 -0
- package/dist/blocks/surface-id-context.js +15 -0
- package/dist/blocks/surface-id-context.js.map +1 -0
- package/dist/bus.d.ts +41 -0
- package/dist/bus.js +158 -0
- package/dist/bus.js.map +1 -0
- package/dist/cache/index.d.ts +9 -0
- package/dist/cache/index.js +10 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/memory.d.ts +32 -0
- package/dist/cache/memory.js +138 -0
- package/dist/cache/memory.js.map +1 -0
- package/dist/cache/types.d.ts +62 -0
- package/dist/cache/types.js +9 -0
- package/dist/cache/types.js.map +1 -0
- package/dist/capability/index.d.ts +72 -0
- package/dist/capability/index.js +87 -0
- package/dist/capability/index.js.map +1 -0
- package/dist/capability/kernel-capabilities.d.ts +31 -0
- package/dist/capability/kernel-capabilities.js +36 -0
- package/dist/capability/kernel-capabilities.js.map +1 -0
- package/dist/capability/platform-capabilities.d.ts +71 -0
- package/dist/capability/platform-capabilities.js +267 -0
- package/dist/capability/platform-capabilities.js.map +1 -0
- package/dist/capability/type-mapping.d.ts +70 -0
- package/dist/capability/type-mapping.js +107 -0
- package/dist/capability/type-mapping.js.map +1 -0
- package/dist/capability/validation.d.ts +46 -0
- package/dist/capability/validation.js +54 -0
- package/dist/capability/validation.js.map +1 -0
- package/dist/connectors/declared-connector.d.ts +48 -0
- package/dist/connectors/declared-connector.js +333 -0
- package/dist/connectors/declared-connector.js.map +1 -0
- package/dist/connectors/engine-registry.d.ts +50 -0
- package/dist/connectors/engine-registry.js +135 -0
- package/dist/connectors/engine-registry.js.map +1 -0
- package/dist/connectors/index.d.ts +14 -0
- package/dist/connectors/index.js +14 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/module-loader.d.ts +70 -0
- package/dist/connectors/module-loader.js +143 -0
- package/dist/connectors/module-loader.js.map +1 -0
- package/dist/connectors/types.d.ts +174 -0
- package/dist/connectors/types.js +23 -0
- package/dist/connectors/types.js.map +1 -0
- package/dist/context.d.ts +27 -0
- package/dist/context.js +38 -0
- package/dist/context.js.map +1 -0
- package/dist/data/DataCapabilityProvider.d.ts +39 -0
- package/dist/data/DataCapabilityProvider.js +58 -0
- package/dist/data/DataCapabilityProvider.js.map +1 -0
- package/dist/data/index.d.ts +17 -0
- package/dist/data/index.js +18 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/manager.d.ts +40 -0
- package/dist/data/manager.js +442 -0
- package/dist/data/manager.js.map +1 -0
- package/dist/data/types.d.ts +218 -0
- package/dist/data/types.js +2 -0
- package/dist/data/types.js.map +1 -0
- package/dist/entity/aggregate.d.ts +8 -0
- package/dist/entity/aggregate.js +24 -0
- package/dist/entity/aggregate.js.map +1 -0
- package/dist/entity/apply-query.d.ts +58 -0
- package/dist/entity/apply-query.js +264 -0
- package/dist/entity/apply-query.js.map +1 -0
- package/dist/entity/behavior.d.ts +94 -0
- package/dist/entity/behavior.js +78 -0
- package/dist/entity/behavior.js.map +1 -0
- package/dist/entity/connector.d.ts +141 -0
- package/dist/entity/connector.js +89 -0
- package/dist/entity/connector.js.map +1 -0
- package/dist/entity/connectors/index.d.ts +12 -0
- package/dist/entity/connectors/index.js +11 -0
- package/dist/entity/connectors/index.js.map +1 -0
- package/dist/entity/connectors/static.d.ts +51 -0
- package/dist/entity/connectors/static.js +245 -0
- package/dist/entity/connectors/static.js.map +1 -0
- package/dist/entity/entity-datasource.d.ts +50 -0
- package/dist/entity/entity-datasource.js +33 -0
- package/dist/entity/entity-datasource.js.map +1 -0
- package/dist/entity/facade.d.ts +70 -0
- package/dist/entity/facade.js +70 -0
- package/dist/entity/facade.js.map +1 -0
- package/dist/entity/http-connector.d.ts +123 -0
- package/dist/entity/http-connector.js +295 -0
- package/dist/entity/http-connector.js.map +1 -0
- package/dist/entity/index.d.ts +38 -0
- package/dist/entity/index.js +31 -0
- package/dist/entity/index.js.map +1 -0
- package/dist/entity/postgres-connector.d.ts +64 -0
- package/dist/entity/postgres-connector.js +239 -0
- package/dist/entity/postgres-connector.js.map +1 -0
- package/dist/entity/registry.d.ts +59 -0
- package/dist/entity/registry.js +90 -0
- package/dist/entity/registry.js.map +1 -0
- package/dist/entity/store.d.ts +66 -0
- package/dist/entity/store.js +349 -0
- package/dist/entity/store.js.map +1 -0
- package/dist/entity/types.d.ts +180 -0
- package/dist/entity/types.js +10 -0
- package/dist/entity/types.js.map +1 -0
- package/dist/execution-context.d.ts +88 -0
- package/dist/execution-context.js +146 -0
- package/dist/execution-context.js.map +1 -0
- package/dist/executor.d.ts +27 -0
- package/dist/executor.js +33 -0
- package/dist/executor.js.map +1 -0
- package/dist/forms/form-entity-bridge.d.ts +94 -0
- package/dist/forms/form-entity-bridge.js +96 -0
- package/dist/forms/form-entity-bridge.js.map +1 -0
- package/dist/forms/form-write-target.d.ts +34 -0
- package/dist/forms/form-write-target.js +81 -0
- package/dist/forms/form-write-target.js.map +1 -0
- package/dist/forms/index.d.ts +22 -0
- package/dist/forms/index.js +25 -0
- package/dist/forms/index.js.map +1 -0
- package/dist/forms/named-control-values.d.ts +27 -0
- package/dist/forms/named-control-values.js +42 -0
- package/dist/forms/named-control-values.js.map +1 -0
- package/dist/forms/processor.d.ts +55 -0
- package/dist/forms/processor.js +154 -0
- package/dist/forms/processor.js.map +1 -0
- package/dist/forms/types.d.ts +174 -0
- package/dist/forms/types.js +33 -0
- package/dist/forms/types.js.map +1 -0
- package/dist/forms/validator.d.ts +61 -0
- package/dist/forms/validator.js +218 -0
- package/dist/forms/validator.js.map +1 -0
- package/dist/graph/index.d.ts +10 -0
- package/dist/graph/index.js +9 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/resolver.d.ts +66 -0
- package/dist/graph/resolver.js +243 -0
- package/dist/graph/resolver.js.map +1 -0
- package/dist/graph/types.d.ts +125 -0
- package/dist/graph/types.js +9 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/hooks/useInstalledAtoms.d.ts +96 -0
- package/dist/hooks/useInstalledAtoms.js +92 -0
- package/dist/hooks/useInstalledAtoms.js.map +1 -0
- package/dist/i18n/index.d.ts +15 -0
- package/dist/i18n/index.js +14 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/translator.d.ts +76 -0
- package/dist/i18n/translator.js +357 -0
- package/dist/i18n/translator.js.map +1 -0
- package/dist/i18n/types.d.ts +93 -0
- package/dist/i18n/types.js +9 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel.d.ts +47 -0
- package/dist/kernel.js +258 -0
- package/dist/kernel.js.map +1 -0
- package/dist/perf/budget.d.ts +92 -0
- package/dist/perf/budget.js +122 -0
- package/dist/perf/budget.js.map +1 -0
- package/dist/perf/index.d.ts +16 -0
- package/dist/perf/index.js +13 -0
- package/dist/perf/index.js.map +1 -0
- package/dist/perf/render-timer.d.ts +90 -0
- package/dist/perf/render-timer.js +136 -0
- package/dist/perf/render-timer.js.map +1 -0
- package/dist/perf/reporter.d.ts +126 -0
- package/dist/perf/reporter.js +241 -0
- package/dist/perf/reporter.js.map +1 -0
- package/dist/perf/web-vitals.d.ts +111 -0
- package/dist/perf/web-vitals.js +268 -0
- package/dist/perf/web-vitals.js.map +1 -0
- package/dist/registry.d.ts +63 -0
- package/dist/registry.js +126 -0
- package/dist/registry.js.map +1 -0
- package/dist/render/BehaviorSurfaceProvider.d.ts +65 -0
- package/dist/render/BehaviorSurfaceProvider.js +185 -0
- package/dist/render/BehaviorSurfaceProvider.js.map +1 -0
- package/dist/render/BlockErrorBoundary.d.ts +26 -0
- package/dist/render/BlockErrorBoundary.js +41 -0
- package/dist/render/BlockErrorBoundary.js.map +1 -0
- package/dist/render/DataBoundSurfaceRenderer.d.ts +78 -0
- package/dist/render/DataBoundSurfaceRenderer.js +998 -0
- package/dist/render/DataBoundSurfaceRenderer.js.map +1 -0
- package/dist/render/DynamicBlockWrapper.d.ts +23 -0
- package/dist/render/DynamicBlockWrapper.js +117 -0
- package/dist/render/DynamicBlockWrapper.js.map +1 -0
- package/dist/render/appearance-resolver.d.ts +50 -0
- package/dist/render/appearance-resolver.js +78 -0
- package/dist/render/appearance-resolver.js.map +1 -0
- package/dist/render/capability-gate.d.ts +69 -0
- package/dist/render/capability-gate.js +94 -0
- package/dist/render/capability-gate.js.map +1 -0
- package/dist/render/conditional-states-css.d.ts +41 -0
- package/dist/render/conditional-states-css.js +82 -0
- package/dist/render/conditional-states-css.js.map +1 -0
- package/dist/render/connections-context.d.ts +31 -0
- package/dist/render/connections-context.js +34 -0
- package/dist/render/connections-context.js.map +1 -0
- package/dist/render/dark-theme-css.d.ts +36 -0
- package/dist/render/dark-theme-css.js +67 -0
- package/dist/render/dark-theme-css.js.map +1 -0
- package/dist/render/data-binding-types.d.ts +191 -0
- package/dist/render/data-binding-types.js +11 -0
- package/dist/render/data-binding-types.js.map +1 -0
- package/dist/render/data-cache.d.ts +30 -0
- package/dist/render/data-cache.js +37 -0
- package/dist/render/data-cache.js.map +1 -0
- package/dist/render/derive-dark-theme.d.ts +17 -0
- package/dist/render/derive-dark-theme.js +18 -0
- package/dist/render/derive-dark-theme.js.map +1 -0
- package/dist/render/dynamic-artifact-context.d.ts +77 -0
- package/dist/render/dynamic-artifact-context.js +89 -0
- package/dist/render/dynamic-artifact-context.js.map +1 -0
- package/dist/render/dynamic-block-loader.d.ts +80 -0
- package/dist/render/dynamic-block-loader.js +197 -0
- package/dist/render/dynamic-block-loader.js.map +1 -0
- package/dist/render/endpoint.d.ts +18 -0
- package/dist/render/endpoint.js +109 -0
- package/dist/render/endpoint.js.map +1 -0
- package/dist/render/entity-facade-context.d.ts +34 -0
- package/dist/render/entity-facade-context.js +37 -0
- package/dist/render/entity-facade-context.js.map +1 -0
- package/dist/render/group-states-css.d.ts +41 -0
- package/dist/render/group-states-css.js +73 -0
- package/dist/render/group-states-css.js.map +1 -0
- package/dist/render/hooks/useSurfaceEvents.d.ts +8 -0
- package/dist/render/hooks/useSurfaceEvents.js +9 -0
- package/dist/render/hooks/useSurfaceEvents.js.map +1 -0
- package/dist/render/hooks/useSurfaceId.d.ts +8 -0
- package/dist/render/hooks/useSurfaceId.js +9 -0
- package/dist/render/hooks/useSurfaceId.js.map +1 -0
- package/dist/render/index.d.ts +48 -0
- package/dist/render/index.js +61 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/interaction-rule-engine.d.ts +12 -0
- package/dist/render/interaction-rule-engine.js +47 -0
- package/dist/render/interaction-rule-engine.js.map +1 -0
- package/dist/render/keyframes-css.d.ts +31 -0
- package/dist/render/keyframes-css.js +44 -0
- package/dist/render/keyframes-css.js.map +1 -0
- package/dist/render/query-state.d.ts +3 -0
- package/dist/render/query-state.js +70 -0
- package/dist/render/query-state.js.map +1 -0
- package/dist/render/renderer.d.ts +44 -0
- package/dist/render/renderer.js +937 -0
- package/dist/render/renderer.js.map +1 -0
- package/dist/render/resolve-expressions.d.ts +37 -0
- package/dist/render/resolve-expressions.js +309 -0
- package/dist/render/resolve-expressions.js.map +1 -0
- package/dist/render/responsive-style-css.d.ts +42 -0
- package/dist/render/responsive-style-css.js +123 -0
- package/dist/render/responsive-style-css.js.map +1 -0
- package/dist/render/responsive.d.ts +49 -0
- package/dist/render/responsive.js +99 -0
- package/dist/render/responsive.js.map +1 -0
- package/dist/render/scoped-css.d.ts +71 -0
- package/dist/render/scoped-css.js +102 -0
- package/dist/render/scoped-css.js.map +1 -0
- package/dist/render/shell-selection.d.ts +69 -0
- package/dist/render/shell-selection.js +117 -0
- package/dist/render/shell-selection.js.map +1 -0
- package/dist/render/states-css.d.ts +32 -0
- package/dist/render/states-css.js +63 -0
- package/dist/render/states-css.js.map +1 -0
- package/dist/render/surface-data-context.d.ts +18 -0
- package/dist/render/surface-data-context.js +21 -0
- package/dist/render/surface-data-context.js.map +1 -0
- package/dist/render/surface-event-bus.d.ts +19 -0
- package/dist/render/surface-event-bus.js +68 -0
- package/dist/render/surface-event-bus.js.map +1 -0
- package/dist/render/surface-event-context.d.ts +11 -0
- package/dist/render/surface-event-context.js +12 -0
- package/dist/render/surface-event-context.js.map +1 -0
- package/dist/render/surface-id-context.d.ts +8 -0
- package/dist/render/surface-id-context.js +9 -0
- package/dist/render/surface-id-context.js.map +1 -0
- package/dist/render/theme-utils.d.ts +14 -0
- package/dist/render/theme-utils.js +15 -0
- package/dist/render/theme-utils.js.map +1 -0
- package/dist/render/types.d.ts +282 -0
- package/dist/render/types.js +9 -0
- package/dist/render/types.js.map +1 -0
- package/dist/render/visibility-css.d.ts +42 -0
- package/dist/render/visibility-css.js +119 -0
- package/dist/render/visibility-css.js.map +1 -0
- package/dist/render/width-scope.d.ts +34 -0
- package/dist/render/width-scope.js +44 -0
- package/dist/render/width-scope.js.map +1 -0
- package/dist/render/write-only-sources.d.ts +33 -0
- package/dist/render/write-only-sources.js +99 -0
- package/dist/render/write-only-sources.js.map +1 -0
- package/dist/routing/index.d.ts +14 -0
- package/dist/routing/index.js +15 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/router.d.ts +42 -0
- package/dist/routing/router.js +218 -0
- package/dist/routing/router.js.map +1 -0
- package/dist/routing/types.d.ts +124 -0
- package/dist/routing/types.js +9 -0
- package/dist/routing/types.js.map +1 -0
- package/dist/seo/generator.d.ts +39 -0
- package/dist/seo/generator.js +236 -0
- package/dist/seo/generator.js.map +1 -0
- package/dist/seo/index.d.ts +14 -0
- package/dist/seo/index.js +15 -0
- package/dist/seo/index.js.map +1 -0
- package/dist/seo/types.d.ts +181 -0
- package/dist/seo/types.js +9 -0
- package/dist/seo/types.js.map +1 -0
- package/dist/state/index.d.ts +15 -0
- package/dist/state/index.js +16 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/manager.d.ts +33 -0
- package/dist/state/manager.js +81 -0
- package/dist/state/manager.js.map +1 -0
- package/dist/state/store.d.ts +40 -0
- package/dist/state/store.js +145 -0
- package/dist/state/store.js.map +1 -0
- package/dist/state/types.d.ts +107 -0
- package/dist/state/types.js +9 -0
- package/dist/state/types.js.map +1 -0
- package/dist/surface/expression.d.ts +65 -0
- package/dist/surface/expression.js +179 -0
- package/dist/surface/expression.js.map +1 -0
- package/dist/surface/index.d.ts +32 -0
- package/dist/surface/index.js +25 -0
- package/dist/surface/index.js.map +1 -0
- package/dist/surface/interpreter.d.ts +96 -0
- package/dist/surface/interpreter.js +231 -0
- package/dist/surface/interpreter.js.map +1 -0
- package/dist/surface/layout.d.ts +54 -0
- package/dist/surface/layout.js +288 -0
- package/dist/surface/layout.js.map +1 -0
- package/dist/surface/output.d.ts +90 -0
- package/dist/surface/output.js +104 -0
- package/dist/surface/output.js.map +1 -0
- package/dist/surface/primitives.d.ts +180 -0
- package/dist/surface/primitives.js +339 -0
- package/dist/surface/primitives.js.map +1 -0
- package/dist/surface/renderer.d.ts +96 -0
- package/dist/surface/renderer.js +190 -0
- package/dist/surface/renderer.js.map +1 -0
- package/dist/surface/schemas.d.ts +181 -0
- package/dist/surface/schemas.js +142 -0
- package/dist/surface/schemas.js.map +1 -0
- package/dist/surface/transforms.d.ts +144 -0
- package/dist/surface/transforms.js +120 -0
- package/dist/surface/transforms.js.map +1 -0
- package/dist/surface/types.d.ts +160 -0
- package/dist/surface/types.js +51 -0
- package/dist/surface/types.js.map +1 -0
- package/dist/surface/validation.d.ts +123 -0
- package/dist/surface/validation.js +147 -0
- package/dist/surface/validation.js.map +1 -0
- package/dist/validator.d.ts +55 -0
- package/dist/validator.js +100 -0
- package/dist/validator.js.map +1 -0
- package/package.json +106 -3
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Capability Definitions
|
|
3
|
+
*
|
|
4
|
+
* Canonical capability taxonomy.
|
|
5
|
+
* - persistence replaces data + state (merged)
|
|
6
|
+
* - interaction replaces behaviors (Tier 2)
|
|
7
|
+
* - entities is the canonical form write path
|
|
8
|
+
*
|
|
9
|
+
* platform/auth phantom capability removed — real auth
|
|
10
|
+
* enforcement lives in JWT middleware (requireAuthenticated()), not
|
|
11
|
+
* the capability system.
|
|
12
|
+
*
|
|
13
|
+
* platform/input retired — form submissions flow through
|
|
14
|
+
* platform/entities (entity_records), hard cutover, no fallback.
|
|
15
|
+
*
|
|
16
|
+
* Active capabilities: persistence, entities, navigation, interaction.
|
|
17
|
+
*
|
|
18
|
+
* @module @pwfabric/runtime/capability/platform-capabilities
|
|
19
|
+
*/
|
|
20
|
+
import { defineCapability, defineContract, defineConfigSchema, anySchema, } from '@pwfabric/core';
|
|
21
|
+
import { createDataService } from '../data/manager.js';
|
|
22
|
+
// ============================================================
|
|
23
|
+
// PASSTHROUGH CONTRACT
|
|
24
|
+
// ============================================================
|
|
25
|
+
/**
|
|
26
|
+
* A passthrough contract for declaration-only capabilities.
|
|
27
|
+
* Accepts any input and produces any output with no validation.
|
|
28
|
+
* Used by: persistence, navigation, interaction, entities.
|
|
29
|
+
*/
|
|
30
|
+
const passthroughContract = defineContract()
|
|
31
|
+
.id('platform/passthrough')
|
|
32
|
+
.name('Platform Passthrough')
|
|
33
|
+
.description('Passthrough contract for platform capability declarations')
|
|
34
|
+
.state('stable')
|
|
35
|
+
.input(anySchema())
|
|
36
|
+
.output(anySchema())
|
|
37
|
+
.build();
|
|
38
|
+
// ============================================================
|
|
39
|
+
// CONFIG SCHEMAS
|
|
40
|
+
// ============================================================
|
|
41
|
+
/**
|
|
42
|
+
* persistenceConfigSchema merges former dataConfigSchema and stateConfigSchema.
|
|
43
|
+
* data fields: defaultCacheTtl, maxRetries, timeout
|
|
44
|
+
* state fields: persistenceEnabled, storageKey
|
|
45
|
+
*/
|
|
46
|
+
const persistenceConfigSchema = defineConfigSchema()
|
|
47
|
+
.field('defaultCacheTtl', (f) => f
|
|
48
|
+
.number()
|
|
49
|
+
.default(300)
|
|
50
|
+
.label('Default Cache TTL')
|
|
51
|
+
.description('Default cache time-to-live in seconds')
|
|
52
|
+
.min(0)
|
|
53
|
+
.max(86400))
|
|
54
|
+
.field('maxRetries', (f) => f
|
|
55
|
+
.number()
|
|
56
|
+
.default(3)
|
|
57
|
+
.label('Max Retries')
|
|
58
|
+
.description('Maximum number of retry attempts for failed requests')
|
|
59
|
+
.min(0)
|
|
60
|
+
.max(10))
|
|
61
|
+
.field('timeout', (f) => f
|
|
62
|
+
.number()
|
|
63
|
+
.default(5000)
|
|
64
|
+
.label('Request Timeout')
|
|
65
|
+
.description('Request timeout in milliseconds')
|
|
66
|
+
.min(1000)
|
|
67
|
+
.max(30000))
|
|
68
|
+
.field('persistenceEnabled', (f) => f
|
|
69
|
+
.boolean()
|
|
70
|
+
.default(true)
|
|
71
|
+
.label('Enable Persistence')
|
|
72
|
+
.description('Persist state to local storage'))
|
|
73
|
+
.field('storageKey', (f) => f
|
|
74
|
+
.string()
|
|
75
|
+
.default('pwfabric-state')
|
|
76
|
+
.label('Storage Key')
|
|
77
|
+
.description('Local storage key prefix for persisted state'))
|
|
78
|
+
.build();
|
|
79
|
+
const navigationConfigSchema = defineConfigSchema()
|
|
80
|
+
.field('basePath', (f) => f.string().default('/').label('Base Path').description('Base path prefix for all routes'))
|
|
81
|
+
.field('trailingSlash', (f) => f.boolean().default(false).label('Trailing Slash').description('Append trailing slash to URLs'))
|
|
82
|
+
.build();
|
|
83
|
+
const interactionConfigSchema = defineConfigSchema()
|
|
84
|
+
.field('executionMode', (f) => f
|
|
85
|
+
.select([
|
|
86
|
+
{
|
|
87
|
+
value: 'sync',
|
|
88
|
+
label: 'Synchronous',
|
|
89
|
+
description: 'Actions block the event chain until complete',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: 'async',
|
|
93
|
+
label: 'Asynchronous',
|
|
94
|
+
description: 'Actions run in background without blocking',
|
|
95
|
+
},
|
|
96
|
+
])
|
|
97
|
+
.default('async')
|
|
98
|
+
.label('Execution Mode')
|
|
99
|
+
.description('How behavior actions are executed when a trigger fires'))
|
|
100
|
+
.field('maxConcurrent', (f) => f
|
|
101
|
+
.number()
|
|
102
|
+
.default(5)
|
|
103
|
+
.label('Max Concurrent')
|
|
104
|
+
.description('Maximum number of behaviors that can execute simultaneously')
|
|
105
|
+
.min(1)
|
|
106
|
+
.max(20))
|
|
107
|
+
.field('errorPolicy', (f) => f
|
|
108
|
+
.select([
|
|
109
|
+
{ value: 'ignore', label: 'Ignore', description: 'Silently swallow errors' },
|
|
110
|
+
{
|
|
111
|
+
value: 'log',
|
|
112
|
+
label: 'Log',
|
|
113
|
+
description: 'Log errors to console without stopping execution',
|
|
114
|
+
},
|
|
115
|
+
{ value: 'halt', label: 'Halt', description: 'Stop the behavior chain on first error' },
|
|
116
|
+
])
|
|
117
|
+
.default('log')
|
|
118
|
+
.label('Error Policy')
|
|
119
|
+
.description('How errors in behavior actions are handled'))
|
|
120
|
+
.field('debugMode', (f) => f
|
|
121
|
+
.boolean()
|
|
122
|
+
.default(false)
|
|
123
|
+
.label('Debug Mode')
|
|
124
|
+
.description('Emit detailed trace events for behavior execution'))
|
|
125
|
+
.build();
|
|
126
|
+
// ============================================================
|
|
127
|
+
// PLATFORM CAPABILITY DEFINITIONS
|
|
128
|
+
// ============================================================
|
|
129
|
+
/**
|
|
130
|
+
* Persistence capability
|
|
131
|
+
*
|
|
132
|
+
* Merges former data + state capabilities.
|
|
133
|
+
* Provides data fetching, mutation, persistence operations, and
|
|
134
|
+
* client-side state management with optional local storage persistence.
|
|
135
|
+
*/
|
|
136
|
+
export const persistenceCapability = defineCapability()
|
|
137
|
+
.id('platform/persistence')
|
|
138
|
+
.name('Data & State Persistence')
|
|
139
|
+
.description('Data fetching, mutation, persistence operations, and client-side state management')
|
|
140
|
+
.version('1.0.0')
|
|
141
|
+
.state('stable')
|
|
142
|
+
.tags(['data', 'state', 'persistence', 'api'])
|
|
143
|
+
.contract(passthroughContract)
|
|
144
|
+
.configSchema(persistenceConfigSchema)
|
|
145
|
+
.execute(async (config) => {
|
|
146
|
+
const cfg = config;
|
|
147
|
+
return createDataService({
|
|
148
|
+
...(cfg?.defaultCacheTtl != null ? { defaultCacheTtl: cfg.defaultCacheTtl } : {}),
|
|
149
|
+
...(cfg?.maxRetries != null ? { maxRetries: cfg.maxRetries } : {}),
|
|
150
|
+
...(cfg?.timeout != null ? { timeout: cfg.timeout } : {}),
|
|
151
|
+
});
|
|
152
|
+
})
|
|
153
|
+
.build();
|
|
154
|
+
/**
|
|
155
|
+
* Navigation capability
|
|
156
|
+
*
|
|
157
|
+
* Provides multi-page surface navigation, base path configuration, and route handling.
|
|
158
|
+
* Renamed from routingCapability (platform/routing) to avoid confusion with framework-level routing.
|
|
159
|
+
*/
|
|
160
|
+
export const navigationCapability = defineCapability()
|
|
161
|
+
.id('platform/navigation')
|
|
162
|
+
.name('Navigation')
|
|
163
|
+
.description('Multi-page surface navigation, base path configuration, and route handling')
|
|
164
|
+
.version('1.0.0')
|
|
165
|
+
.state('stable')
|
|
166
|
+
.tags(['navigation', 'routing', 'url'])
|
|
167
|
+
.contract(passthroughContract)
|
|
168
|
+
.configSchema(navigationConfigSchema)
|
|
169
|
+
.execute(async (input) => {
|
|
170
|
+
const data = input;
|
|
171
|
+
const path = data?.path ?? '/';
|
|
172
|
+
const config = data?.config ?? {};
|
|
173
|
+
const basePath = config.basePath ?? '/';
|
|
174
|
+
const trailingSlash = config.trailingSlash ?? false;
|
|
175
|
+
let resolvedPath = path.startsWith(basePath) ? path : `${basePath}${path}`.replace(/\/+/g, '/');
|
|
176
|
+
if (trailingSlash && !resolvedPath.endsWith('/'))
|
|
177
|
+
resolvedPath += '/';
|
|
178
|
+
else if (!trailingSlash && resolvedPath.length > 1 && resolvedPath.endsWith('/'))
|
|
179
|
+
resolvedPath = resolvedPath.slice(0, -1);
|
|
180
|
+
return { resolvedPath, params: {} };
|
|
181
|
+
})
|
|
182
|
+
.build();
|
|
183
|
+
/**
|
|
184
|
+
* Interaction capability
|
|
185
|
+
*
|
|
186
|
+
* Replaces former behaviors capability.
|
|
187
|
+
* Provides event-driven interaction rules for dynamic surfaces.
|
|
188
|
+
*/
|
|
189
|
+
export const interactionCapability = defineCapability()
|
|
190
|
+
.id('platform/interaction')
|
|
191
|
+
.name('Interaction Rules')
|
|
192
|
+
.description('Event-driven interaction rules — attach triggers and actions to surface events for interactive, dynamic surfaces')
|
|
193
|
+
.version('1.0.0')
|
|
194
|
+
.state('stable')
|
|
195
|
+
.tags(['interaction', 'events', 'automation'])
|
|
196
|
+
.contract(passthroughContract)
|
|
197
|
+
.configSchema(interactionConfigSchema)
|
|
198
|
+
.execute(async () => ({ success: true }))
|
|
199
|
+
.build();
|
|
200
|
+
/**
|
|
201
|
+
* Entities capability — NEW Tier 1 capability.
|
|
202
|
+
*
|
|
203
|
+
* Schema-driven entity definitions, CRUD store, and connector abstraction.
|
|
204
|
+
*/
|
|
205
|
+
export const entitiesCapability = defineCapability()
|
|
206
|
+
.id('platform/entities')
|
|
207
|
+
.name('Entity System')
|
|
208
|
+
.description('Schema-driven entity definitions, CRUD store, connector abstraction')
|
|
209
|
+
.version('1.0.0')
|
|
210
|
+
.state('stable')
|
|
211
|
+
.tags(['entities', 'schema', 'crud'])
|
|
212
|
+
.contract(passthroughContract)
|
|
213
|
+
.configSchema(defineConfigSchema()
|
|
214
|
+
.field('enableLifecycleHooks', (f) => f
|
|
215
|
+
.boolean()
|
|
216
|
+
.default(true)
|
|
217
|
+
.label('Enable Lifecycle Hooks')
|
|
218
|
+
.description('Enable entity lifecycle hook callbacks'))
|
|
219
|
+
.field('enableEventBridge', (f) => f
|
|
220
|
+
.boolean()
|
|
221
|
+
.default(false)
|
|
222
|
+
.label('Enable Event Bridge')
|
|
223
|
+
.description('Emit entity events to the platform event bridge'))
|
|
224
|
+
.build())
|
|
225
|
+
.execute(async () => ({ success: true }))
|
|
226
|
+
.build();
|
|
227
|
+
// ============================================================
|
|
228
|
+
// AGGREGATE EXPORTS
|
|
229
|
+
// ============================================================
|
|
230
|
+
/**
|
|
231
|
+
* All platform capabilities as an array.
|
|
232
|
+
*
|
|
233
|
+
* SOURCE OF TRUTH — derive all other lists from this array (see index.ts).
|
|
234
|
+
* platform/auth removed (phantom capability).
|
|
235
|
+
* routing renamed to navigation.
|
|
236
|
+
* platform/input removed — form writes flow through platform/entities.
|
|
237
|
+
*/
|
|
238
|
+
export const platformCapabilities = [
|
|
239
|
+
persistenceCapability,
|
|
240
|
+
entitiesCapability,
|
|
241
|
+
navigationCapability,
|
|
242
|
+
interactionCapability,
|
|
243
|
+
];
|
|
244
|
+
/**
|
|
245
|
+
* Register all platform capabilities with a registry
|
|
246
|
+
*
|
|
247
|
+
* @param registry - The capability registry to register with
|
|
248
|
+
* @returns An object with successfully registered IDs and any errors
|
|
249
|
+
*/
|
|
250
|
+
export function registerPlatformCapabilities(registry) {
|
|
251
|
+
const registered = [];
|
|
252
|
+
const errors = [];
|
|
253
|
+
for (const capability of platformCapabilities) {
|
|
254
|
+
const result = registry.register(capability);
|
|
255
|
+
if (result.success) {
|
|
256
|
+
registered.push(capability.id);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
errors.push({
|
|
260
|
+
id: capability.id,
|
|
261
|
+
error: result.error.type,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return { registered, errors };
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=platform-capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform-capabilities.js","sourceRoot":"","sources":["../../src/capability/platform-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtD,+DAA+D;AAC/D,uBAAuB;AACvB,+DAA+D;AAE/D;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,cAAc,EAAE;KACzC,EAAE,CAAC,sBAAsB,CAAC;KAC1B,IAAI,CAAC,sBAAsB,CAAC;KAC5B,WAAW,CAAC,2DAA2D,CAAC;KACxE,KAAK,CAAC,QAAQ,CAAC;KACf,KAAK,CAAC,SAAS,EAAE,CAA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* Platform Capability Definitions\n *\n * Canonical capability taxonomy.\n * - persistence replaces data + state (merged)\n * - interaction replaces behaviors (Tier 2)\n * - entities is the canonical form write path\n *\n * platform/auth phantom capability removed — real auth\n * enforcement lives in JWT middleware (requireAuthenticated()), not\n * the capability system.\n *\n * platform/input retired — form submissions flow through\n * platform/entities (entity_records), hard cutover, no fallback.\n *\n * Active capabilities: persistence, entities, navigation, interaction.\n *\n * @module @pwfabric/runtime/capability/platform-capabilities\n */\n\nimport {\n defineCapability,\n defineContract,\n defineConfigSchema,\n anySchema,\n} from '@pwfabric/core'\nimport type { Capability } from '@pwfabric/contracts'\nimport type { CapabilityRegistry } from '../registry.js'\nimport { createDataService } from '../data/manager.js'\n\n// ============================================================\n// PASSTHROUGH CONTRACT\n// ============================================================\n\n/**\n * A passthrough contract for declaration-only capabilities.\n * Accepts any input and produces any output with no validation.\n * Used by: persistence, navigation, interaction, entities.\n */\nconst passthroughContract = defineContract()\n .id('platform/passthrough')\n .name('Platform Passthrough')\n .description('Passthrough contract for platform capability declarations')\n .state('stable')\n .input(anySchema())\n .output(anySchema())\n .build()\n\n// ============================================================\n// CONFIG SCHEMAS\n// ============================================================\n\n/**\n * persistenceConfigSchema merges former dataConfigSchema and stateConfigSchema.\n * data fields: defaultCacheTtl, maxRetries, timeout\n * state fields: persistenceEnabled, storageKey\n */\nconst persistenceConfigSchema = defineConfigSchema()\n .field('defaultCacheTtl', (f) =>\n f\n .number()\n .default(300)\n .label('Default Cache TTL')\n .description('Default cache time-to-live in seconds')\n .min(0)\n .max(86400)\n )\n .field('maxRetries', (f) =>\n f\n .number()\n .default(3)\n .label('Max Retries')\n .description('Maximum number of retry attempts for failed requests')\n .min(0)\n .max(10)\n )\n .field('timeout', (f) =>\n f\n .number()\n .default(5000)\n .label('Request Timeout')\n .description('Request timeout in milliseconds')\n .min(1000)\n .max(30000)\n )\n .field('persistenceEnabled', (f) =>\n f\n .boolean()\n .default(true)\n .label('Enable Persistence')\n .description('Persist state to local storage')\n )\n .field('storageKey', (f) =>\n f\n .string()\n .default('pwfabric-state')\n .label('Storage Key')\n .description('Local storage key prefix for persisted state')\n )\n .build()\n\nconst navigationConfigSchema = defineConfigSchema()\n .field('basePath', (f) =>\n f.string().default('/').label('Base Path').description('Base path prefix for all routes')\n )\n .field('trailingSlash', (f) =>\n f.boolean().default(false).label('Trailing Slash').description('Append trailing slash to URLs')\n )\n .build()\n\nconst interactionConfigSchema = defineConfigSchema()\n .field('executionMode', (f) =>\n f\n .select([\n {\n value: 'sync',\n label: 'Synchronous',\n description: 'Actions block the event chain until complete',\n },\n {\n value: 'async',\n label: 'Asynchronous',\n description: 'Actions run in background without blocking',\n },\n ])\n .default('async')\n .label('Execution Mode')\n .description('How behavior actions are executed when a trigger fires')\n )\n .field('maxConcurrent', (f) =>\n f\n .number()\n .default(5)\n .label('Max Concurrent')\n .description('Maximum number of behaviors that can execute simultaneously')\n .min(1)\n .max(20)\n )\n .field('errorPolicy', (f) =>\n f\n .select([\n { value: 'ignore', label: 'Ignore', description: 'Silently swallow errors' },\n {\n value: 'log',\n label: 'Log',\n description: 'Log errors to console without stopping execution',\n },\n { value: 'halt', label: 'Halt', description: 'Stop the behavior chain on first error' },\n ])\n .default('log')\n .label('Error Policy')\n .description('How errors in behavior actions are handled')\n )\n .field('debugMode', (f) =>\n f\n .boolean()\n .default(false)\n .label('Debug Mode')\n .description('Emit detailed trace events for behavior execution')\n )\n .build()\n\n// ============================================================\n// PLATFORM CAPABILITY DEFINITIONS\n// ============================================================\n\n/**\n * Persistence capability\n *\n * Merges former data + state capabilities.\n * Provides data fetching, mutation, persistence operations, and\n * client-side state management with optional local storage persistence.\n */\nexport const persistenceCapability = defineCapability()\n .id('platform/persistence')\n .name('Data & State Persistence')\n .description('Data fetching, mutation, persistence operations, and client-side state management')\n .version('1.0.0')\n .state('stable')\n .tags(['data', 'state', 'persistence', 'api'])\n .contract(passthroughContract)\n .configSchema(persistenceConfigSchema)\n .execute(async (config) => {\n const cfg = config as Record<string, unknown> | undefined\n return createDataService({\n ...(cfg?.defaultCacheTtl != null ? { defaultCacheTtl: cfg.defaultCacheTtl as number } : {}),\n ...(cfg?.maxRetries != null ? { maxRetries: cfg.maxRetries as number } : {}),\n ...(cfg?.timeout != null ? { timeout: cfg.timeout as number } : {}),\n })\n })\n .build()\n\n/**\n * Navigation capability\n *\n * Provides multi-page surface navigation, base path configuration, and route handling.\n * Renamed from routingCapability (platform/routing) to avoid confusion with framework-level routing.\n */\nexport const navigationCapability = defineCapability()\n .id('platform/navigation')\n .name('Navigation')\n .description('Multi-page surface navigation, base path configuration, and route handling')\n .version('1.0.0')\n .state('stable')\n .tags(['navigation', 'routing', 'url'])\n .contract(passthroughContract)\n .configSchema(navigationConfigSchema)\n .execute(async (input) => {\n const data = input as Record<string, unknown> | undefined\n const path = (data?.path as string) ?? '/'\n const config = (data?.config as Record<string, unknown>) ?? {}\n const basePath = (config.basePath as string) ?? '/'\n const trailingSlash = (config.trailingSlash as boolean) ?? false\n let resolvedPath = path.startsWith(basePath) ? path : `${basePath}${path}`.replace(/\\/+/g, '/')\n if (trailingSlash && !resolvedPath.endsWith('/')) resolvedPath += '/'\n else if (!trailingSlash && resolvedPath.length > 1 && resolvedPath.endsWith('/'))\n resolvedPath = resolvedPath.slice(0, -1)\n return { resolvedPath, params: {} }\n })\n .build()\n\n/**\n * Interaction capability\n *\n * Replaces former behaviors capability.\n * Provides event-driven interaction rules for dynamic surfaces.\n */\nexport const interactionCapability = defineCapability()\n .id('platform/interaction')\n .name('Interaction Rules')\n .description(\n 'Event-driven interaction rules — attach triggers and actions to surface events for interactive, dynamic surfaces'\n )\n .version('1.0.0')\n .state('stable')\n .tags(['interaction', 'events', 'automation'])\n .contract(passthroughContract)\n .configSchema(interactionConfigSchema)\n .execute(async () => ({ success: true }))\n .build()\n\n/**\n * Entities capability — NEW Tier 1 capability.\n *\n * Schema-driven entity definitions, CRUD store, and connector abstraction.\n */\nexport const entitiesCapability = defineCapability()\n .id('platform/entities')\n .name('Entity System')\n .description('Schema-driven entity definitions, CRUD store, connector abstraction')\n .version('1.0.0')\n .state('stable')\n .tags(['entities', 'schema', 'crud'])\n .contract(passthroughContract)\n .configSchema(\n defineConfigSchema()\n .field('enableLifecycleHooks', (f) =>\n f\n .boolean()\n .default(true)\n .label('Enable Lifecycle Hooks')\n .description('Enable entity lifecycle hook callbacks')\n )\n .field('enableEventBridge', (f) =>\n f\n .boolean()\n .default(false)\n .label('Enable Event Bridge')\n .description('Emit entity events to the platform event bridge')\n )\n .build()\n )\n .execute(async () => ({ success: true }))\n .build()\n\n// ============================================================\n// AGGREGATE EXPORTS\n// ============================================================\n\n/**\n * All platform capabilities as an array.\n *\n * SOURCE OF TRUTH — derive all other lists from this array (see index.ts).\n * platform/auth removed (phantom capability).\n * routing renamed to navigation.\n * platform/input removed — form writes flow through platform/entities.\n */\nexport const platformCapabilities: readonly Capability[] = [\n persistenceCapability,\n entitiesCapability,\n navigationCapability,\n interactionCapability,\n] as const\n\n/**\n * Register all platform capabilities with a registry\n *\n * @param registry - The capability registry to register with\n * @returns An object with successfully registered IDs and any errors\n */\nexport function registerPlatformCapabilities(registry: CapabilityRegistry): {\n registered: readonly string[]\n errors: readonly { id: string; error: string }[]\n} {\n const registered: string[] = []\n const errors: { id: string; error: string }[] = []\n\n for (const capability of platformCapabilities) {\n const result = registry.register(capability)\n if (result.success) {\n registered.push(capability.id)\n } else {\n errors.push({\n id: capability.id,\n error: result.error.type,\n })\n }\n }\n\n return { registered, errors }\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability Type Mapping
|
|
3
|
+
*
|
|
4
|
+
* Maps short-form CapabilityType strings to their corresponding platform
|
|
5
|
+
* capability IDs used in the registry.
|
|
6
|
+
*
|
|
7
|
+
* @module @pwfabric/runtime/capability/type-mapping
|
|
8
|
+
*/
|
|
9
|
+
import type { CapabilityId } from '@pwfabric/contracts';
|
|
10
|
+
/**
|
|
11
|
+
* Maps short-form CapabilityType strings to registry CapabilityId values.
|
|
12
|
+
*
|
|
13
|
+
* Keys are the short-form types (e.g., 'persistence').
|
|
14
|
+
* Values are the full platform capability IDs (e.g., 'platform/persistence').
|
|
15
|
+
*/
|
|
16
|
+
export declare const CAPABILITY_TYPE_TO_ID: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* All known capability type keys
|
|
19
|
+
*/
|
|
20
|
+
export declare const CAPABILITY_TYPES: readonly string[];
|
|
21
|
+
/**
|
|
22
|
+
* All known capability IDs
|
|
23
|
+
*/
|
|
24
|
+
export declare const CAPABILITY_IDS: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a CapabilityType string to a CapabilityId.
|
|
27
|
+
*
|
|
28
|
+
* @param type - The capability type string (e.g., 'auth')
|
|
29
|
+
* @returns The corresponding CapabilityId, or null if not found
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveCapabilityId(type: string): CapabilityId | null;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve a CapabilityId back to a CapabilityType string.
|
|
34
|
+
*
|
|
35
|
+
* @param id - The capability ID (e.g., 'platform/persistence')
|
|
36
|
+
* @returns The corresponding type string, or null if not found
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveCapabilityType(id: string): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a CapabilityType string is known.
|
|
41
|
+
*
|
|
42
|
+
* @param type - The capability type string to check
|
|
43
|
+
* @returns true if the type is a known platform capability type
|
|
44
|
+
*/
|
|
45
|
+
export declare function isKnownCapabilityType(type: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The canonical id, from EITHER spelling.
|
|
48
|
+
*
|
|
49
|
+
* Every reader that compares a capability id should go through this: a raw
|
|
50
|
+
* comparison against `'platform/…'` misses anything written the short way.
|
|
51
|
+
*
|
|
52
|
+
* Both spellings occur in real documents (`navigation`, `persistence`,
|
|
53
|
+
* `entities` next to `platform/navigation` …). Both are legitimate — the plan
|
|
54
|
+
* layer's contract types the short one, the registry and the pack's atoms use
|
|
55
|
+
* the long one — so a reader that accepts only one is blind to real data.
|
|
56
|
+
*
|
|
57
|
+
* `null` for anything outside the canonical four, which is the answer a caller
|
|
58
|
+
* needs for a retired name (`auth`, `input`) or one that never existed (`seo`):
|
|
59
|
+
* not a silent pass-through that would let a ghost look like a capability.
|
|
60
|
+
*/
|
|
61
|
+
export declare function canonicalCapabilityId(value: string): CapabilityId | null;
|
|
62
|
+
/**
|
|
63
|
+
* Does this capability entry name the given canonical capability?
|
|
64
|
+
*
|
|
65
|
+
* The shape every one of those fourteen sites was hand-rolling:
|
|
66
|
+
* `caps.find((c) => c.capability === 'platform/persistence')`.
|
|
67
|
+
*/
|
|
68
|
+
export declare function isCapability(entry: {
|
|
69
|
+
capability?: string;
|
|
70
|
+
} | null | undefined, id: string): boolean;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability Type Mapping
|
|
3
|
+
*
|
|
4
|
+
* Maps short-form CapabilityType strings to their corresponding platform
|
|
5
|
+
* capability IDs used in the registry.
|
|
6
|
+
*
|
|
7
|
+
* @module @pwfabric/runtime/capability/type-mapping
|
|
8
|
+
*/
|
|
9
|
+
import { capabilityId } from '@pwfabric/contracts';
|
|
10
|
+
// ============================================================
|
|
11
|
+
// TYPE-TO-ID MAPPING
|
|
12
|
+
// ============================================================
|
|
13
|
+
/**
|
|
14
|
+
* Maps short-form CapabilityType strings to registry CapabilityId values.
|
|
15
|
+
*
|
|
16
|
+
* Keys are the short-form types (e.g., 'persistence').
|
|
17
|
+
* Values are the full platform capability IDs (e.g., 'platform/persistence').
|
|
18
|
+
*/
|
|
19
|
+
export const CAPABILITY_TYPE_TO_ID = {
|
|
20
|
+
persistence: 'platform/persistence',
|
|
21
|
+
entities: 'platform/entities',
|
|
22
|
+
navigation: 'platform/navigation',
|
|
23
|
+
interaction: 'platform/interaction',
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* All known capability type keys
|
|
27
|
+
*/
|
|
28
|
+
export const CAPABILITY_TYPES = Object.keys(CAPABILITY_TYPE_TO_ID);
|
|
29
|
+
/**
|
|
30
|
+
* All known capability IDs
|
|
31
|
+
*/
|
|
32
|
+
export const CAPABILITY_IDS = Object.values(CAPABILITY_TYPE_TO_ID);
|
|
33
|
+
// ============================================================
|
|
34
|
+
// LOOKUP FUNCTIONS
|
|
35
|
+
// ============================================================
|
|
36
|
+
/**
|
|
37
|
+
* Resolve a CapabilityType string to a CapabilityId.
|
|
38
|
+
*
|
|
39
|
+
* @param type - The capability type string (e.g., 'auth')
|
|
40
|
+
* @returns The corresponding CapabilityId, or null if not found
|
|
41
|
+
*/
|
|
42
|
+
export function resolveCapabilityId(type) {
|
|
43
|
+
const id = CAPABILITY_TYPE_TO_ID[type];
|
|
44
|
+
if (!id)
|
|
45
|
+
return null;
|
|
46
|
+
return capabilityId(id);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolve a CapabilityId back to a CapabilityType string.
|
|
50
|
+
*
|
|
51
|
+
* @param id - The capability ID (e.g., 'platform/persistence')
|
|
52
|
+
* @returns The corresponding type string, or null if not found
|
|
53
|
+
*/
|
|
54
|
+
export function resolveCapabilityType(id) {
|
|
55
|
+
for (const [type, capId] of Object.entries(CAPABILITY_TYPE_TO_ID)) {
|
|
56
|
+
if (capId === id)
|
|
57
|
+
return type;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if a CapabilityType string is known.
|
|
63
|
+
*
|
|
64
|
+
* @param type - The capability type string to check
|
|
65
|
+
* @returns true if the type is a known platform capability type
|
|
66
|
+
*/
|
|
67
|
+
export function isKnownCapabilityType(type) {
|
|
68
|
+
return type in CAPABILITY_TYPE_TO_ID;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The canonical id, from EITHER spelling.
|
|
72
|
+
*
|
|
73
|
+
* Every reader that compares a capability id should go through this: a raw
|
|
74
|
+
* comparison against `'platform/…'` misses anything written the short way.
|
|
75
|
+
*
|
|
76
|
+
* Both spellings occur in real documents (`navigation`, `persistence`,
|
|
77
|
+
* `entities` next to `platform/navigation` …). Both are legitimate — the plan
|
|
78
|
+
* layer's contract types the short one, the registry and the pack's atoms use
|
|
79
|
+
* the long one — so a reader that accepts only one is blind to real data.
|
|
80
|
+
*
|
|
81
|
+
* `null` for anything outside the canonical four, which is the answer a caller
|
|
82
|
+
* needs for a retired name (`auth`, `input`) or one that never existed (`seo`):
|
|
83
|
+
* not a silent pass-through that would let a ghost look like a capability.
|
|
84
|
+
*/
|
|
85
|
+
export function canonicalCapabilityId(value) {
|
|
86
|
+
const trimmed = value.trim();
|
|
87
|
+
if (trimmed === '')
|
|
88
|
+
return null;
|
|
89
|
+
const mapped = CAPABILITY_TYPE_TO_ID[trimmed];
|
|
90
|
+
if (mapped)
|
|
91
|
+
return capabilityId(mapped);
|
|
92
|
+
return CAPABILITY_IDS.includes(trimmed) ? capabilityId(trimmed) : null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Does this capability entry name the given canonical capability?
|
|
96
|
+
*
|
|
97
|
+
* The shape every one of those fourteen sites was hand-rolling:
|
|
98
|
+
* `caps.find((c) => c.capability === 'platform/persistence')`.
|
|
99
|
+
*/
|
|
100
|
+
export function isCapability(entry, id) {
|
|
101
|
+
const declared = entry?.capability;
|
|
102
|
+
if (typeof declared !== 'string')
|
|
103
|
+
return false;
|
|
104
|
+
const canonical = canonicalCapabilityId(id);
|
|
105
|
+
return canonical !== null && canonicalCapabilityId(declared) === canonical;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=type-mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-mapping.js","sourceRoot":"","sources":["../../src/capability/type-mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGlD,+DAA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qB,CAAC,OAAO,CAAC,CAAA;IAC7C,IAAI,MAAM;QAAE,OAAO,YAAY,CAAC,MAAM,CAAC,CAAA;IACvC,OAAO,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACxE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAiD,EAAE,EAAU;IACxF,MAAM,QAAQ,GAAG,KAAK,EAAE,UAAU,CAAA;IAClC,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC9C,MAAM,SAAS,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAAA;IAC3C,OAAO,SAAS,KAAK,IAAI,IAAI,qBAAqB,CAAC,QAAQ,CAAC,KAAK,SAAS,CAAA;AAC5E,CAAC","sourcesContent":["/**\n * Capability Type Mapping\n *\n * Maps short-form CapabilityType strings to their corresponding platform\n * capability IDs used in the registry.\n *\n * @module @pwfabric/runtime/capability/type-mapping\n */\n\nimport { capabilityId } from '@pwfabric/contracts'\nimport type { CapabilityId } from '@pwfabric/contracts'\n\n// ============================================================\n// TYPE-TO-ID MAPPING\n// ============================================================\n\n/**\n * Maps short-form CapabilityType strings to registry CapabilityId values.\n *\n * Keys are the short-form types (e.g., 'persistence').\n * Values are the full platform capability IDs (e.g., 'platform/persistence').\n */\nexport const CAPABILITY_TYPE_TO_ID: Record<string, string> = {\n persistence: 'platform/persistence',\n entities: 'platform/entities',\n navigation: 'platform/navigation',\n interaction: 'platform/interaction',\n} as const\n\n/**\n * All known capability type keys\n */\nexport const CAPABILITY_TYPES = Object.keys(CAPABILITY_TYPE_TO_ID) as readonly string[]\n\n/**\n * All known capability IDs\n */\nexport const CAPABILITY_IDS = Object.values(CAPABILITY_TYPE_TO_ID) as readonly string[]\n\n// ============================================================\n// LOOKUP FUNCTIONS\n// ============================================================\n\n/**\n * Resolve a CapabilityType string to a CapabilityId.\n *\n * @param type - The capability type string (e.g., 'auth')\n * @returns The corresponding CapabilityId, or null if not found\n */\nexport function resolveCapabilityId(type: string): CapabilityId | null {\n const id = CAPABILITY_TYPE_TO_ID[type]\n if (!id) return null\n return capabilityId(id)\n}\n\n/**\n * Resolve a CapabilityId back to a CapabilityType string.\n *\n * @param id - The capability ID (e.g., 'platform/persistence')\n * @returns The corresponding type string, or null if not found\n */\nexport function resolveCapabilityType(id: string): string | null {\n for (const [type, capId] of Object.entries(CAPABILITY_TYPE_TO_ID)) {\n if (capId === id) return type\n }\n return null\n}\n\n/**\n * Check if a CapabilityType string is known.\n *\n * @param type - The capability type string to check\n * @returns true if the type is a known platform capability type\n */\nexport function isKnownCapabilityType(type: string): boolean {\n return type in CAPABILITY_TYPE_TO_ID\n}\n\n/**\n * The canonical id, from EITHER spelling.\n *\n * Every reader that compares a capability id should go through this: a raw\n * comparison against `'platform/…'` misses anything written the short way.\n *\n * Both spellings occur in real documents (`navigation`, `persistence`,\n * `entities` next to `platform/navigation` …). Both are legitimate — the plan\n * layer's contract types the short one, the registry and the pack's atoms use\n * the long one — so a reader that accepts only one is blind to real data.\n *\n * `null` for anything outside the canonical four, which is the answer a caller\n * needs for a retired name (`auth`, `input`) or one that never existed (`seo`):\n * not a silent pass-through that would let a ghost look like a capability.\n */\nexport function canonicalCapabilityId(value: string): CapabilityId | null {\n const trimmed = value.trim()\n if (trimmed === '') return null\n const mapped = CAPABILITY_TYPE_TO_ID[trimmed]\n if (mapped) return capabilityId(mapped)\n return CAPABILITY_IDS.includes(trimmed) ? capabilityId(trimmed) : null\n}\n\n/**\n * Does this capability entry name the given canonical capability?\n *\n * The shape every one of those fourteen sites was hand-rolling:\n * `caps.find((c) => c.capability === 'platform/persistence')`.\n */\nexport function isCapability(entry: { capability?: string } | null | undefined, id: string): boolean {\n const declared = entry?.capability\n if (typeof declared !== 'string') return false\n const canonical = canonicalCapabilityId(id)\n return canonical !== null && canonicalCapabilityId(declared) === canonical\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface Capability Validation
|
|
3
|
+
*
|
|
4
|
+
* Validates that a surface's capability requirements
|
|
5
|
+
* can be satisfied by the capabilities registered in a registry.
|
|
6
|
+
*
|
|
7
|
+
* @module @pwfabric/runtime/capability/validation
|
|
8
|
+
*/
|
|
9
|
+
import type { CapabilityRegistry } from '../registry.js';
|
|
10
|
+
/**
|
|
11
|
+
* A capability requirement declared by a surface.
|
|
12
|
+
*/
|
|
13
|
+
export interface CapabilityRequirement {
|
|
14
|
+
/** The capability type string (e.g., 'persistence' or 'platform/persistence') */
|
|
15
|
+
readonly capability: string;
|
|
16
|
+
/** Whether this capability is required (true) or optional (false) */
|
|
17
|
+
readonly required: boolean;
|
|
18
|
+
/** Optional configuration for the capability */
|
|
19
|
+
readonly config?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Result of validating surface capabilities against a registry.
|
|
23
|
+
*/
|
|
24
|
+
export interface CapabilityValidationResult {
|
|
25
|
+
/** Whether all required capabilities are satisfied */
|
|
26
|
+
readonly valid: boolean;
|
|
27
|
+
/** IDs of capabilities that are registered and satisfy requirements */
|
|
28
|
+
readonly satisfied: readonly string[];
|
|
29
|
+
/** IDs of required capabilities that are NOT registered */
|
|
30
|
+
readonly missing: readonly string[];
|
|
31
|
+
/** IDs of optional capabilities that are NOT registered */
|
|
32
|
+
readonly optional: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validate that a surface's capability requirements can be met
|
|
36
|
+
* by the capabilities available in the registry.
|
|
37
|
+
*
|
|
38
|
+
* Capability strings can be either:
|
|
39
|
+
* - Short-form types from starters (e.g., 'persistence') which are resolved via type-mapping
|
|
40
|
+
* - Full capability IDs (e.g., 'platform/persistence') used directly
|
|
41
|
+
*
|
|
42
|
+
* @param requirements - The capability requirements declared by a surface
|
|
43
|
+
* @param registry - The capability registry to validate against
|
|
44
|
+
* @returns A ValidationResult indicating which requirements are met
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateSurfaceCapabilities(requirements: readonly CapabilityRequirement[], registry: CapabilityRegistry): CapabilityValidationResult;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface Capability Validation
|
|
3
|
+
*
|
|
4
|
+
* Validates that a surface's capability requirements
|
|
5
|
+
* can be satisfied by the capabilities registered in a registry.
|
|
6
|
+
*
|
|
7
|
+
* @module @pwfabric/runtime/capability/validation
|
|
8
|
+
*/
|
|
9
|
+
import { resolveCapabilityId } from './type-mapping.js';
|
|
10
|
+
// ============================================================
|
|
11
|
+
// VALIDATION
|
|
12
|
+
// ============================================================
|
|
13
|
+
/**
|
|
14
|
+
* Validate that a surface's capability requirements can be met
|
|
15
|
+
* by the capabilities available in the registry.
|
|
16
|
+
*
|
|
17
|
+
* Capability strings can be either:
|
|
18
|
+
* - Short-form types from starters (e.g., 'persistence') which are resolved via type-mapping
|
|
19
|
+
* - Full capability IDs (e.g., 'platform/persistence') used directly
|
|
20
|
+
*
|
|
21
|
+
* @param requirements - The capability requirements declared by a surface
|
|
22
|
+
* @param registry - The capability registry to validate against
|
|
23
|
+
* @returns A ValidationResult indicating which requirements are met
|
|
24
|
+
*/
|
|
25
|
+
export function validateSurfaceCapabilities(requirements, registry) {
|
|
26
|
+
const satisfied = [];
|
|
27
|
+
const missing = [];
|
|
28
|
+
const optional = [];
|
|
29
|
+
for (const requirement of requirements) {
|
|
30
|
+
const { capability, required } = requirement;
|
|
31
|
+
// Try to resolve short-form type to full ID, or use as-is
|
|
32
|
+
const resolvedId = resolveCapabilityId(capability);
|
|
33
|
+
const lookupId = resolvedId ?? capability;
|
|
34
|
+
// Check if the capability is registered
|
|
35
|
+
// Use capabilityId() cast since registry.has() expects a branded CapabilityId
|
|
36
|
+
const isRegistered = registry.has(lookupId);
|
|
37
|
+
if (isRegistered) {
|
|
38
|
+
satisfied.push(capability);
|
|
39
|
+
}
|
|
40
|
+
else if (required) {
|
|
41
|
+
missing.push(capability);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
optional.push(capability);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
valid: missing.length === 0,
|
|
49
|
+
satisfied,
|
|
50
|
+
missing,
|
|
51
|
+
optional,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/capability/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAgCvD,+DAA+D;AAC/D,aAAa;AACb,+DAA+D;AAE/D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,2BAA2B,CACzC,YAA8C,EAC9C,QAA4B;IAE5B,MAAM,SAAS,GAAa,EAAE,CAAA;IAC9B,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAa,EAAE,CAAA;IAE7B,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAA;QAE5C,0DAA0D;QAC1D,MAAM,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAA;QAClD,MAAM,QAAQ,GAAG,UAAU,IAAI,UAAU,CAAA;QAEzC,wCAAwC;QACxC,8EAA8E;QAC9E,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,QAA2D,CAAC,CAAA;QAE9F,IAAI,YAAY,EAAE,CAAC;YACjB,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC5B,CAAC;aAAM,IAAI,QAAQ,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC1B,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAC3B,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC;QAC3B,SAAS;QACT,OAAO;QACP,QAAQ;KACT,CAAA;AACH,CAAC","sourcesContent":["/**\n * Surface Capability Validation\n *\n * Validates that a surface's capability requirements\n * can be satisfied by the capabilities registered in a registry.\n *\n * @module @pwfabric/runtime/capability/validation\n */\n\nimport type { CapabilityRegistry } from '../registry.js'\nimport { resolveCapabilityId } from './type-mapping.js'\n\n// ============================================================\n// TYPES\n// ============================================================\n\n/**\n * A capability requirement declared by a surface.\n */\nexport interface CapabilityRequirement {\n /** The capability type string (e.g., 'persistence' or 'platform/persistence') */\n readonly capability: string\n /** Whether this capability is required (true) or optional (false) */\n readonly required: boolean\n /** Optional configuration for the capability */\n readonly config?: Record<string, unknown>\n}\n\n/**\n * Result of validating surface capabilities against a registry.\n */\nexport interface CapabilityValidationResult {\n /** Whether all required capabilities are satisfied */\n readonly valid: boolean\n /** IDs of capabilities that are registered and satisfy requirements */\n readonly satisfied: readonly string[]\n /** IDs of required capabilities that are NOT registered */\n readonly missing: readonly string[]\n /** IDs of optional capabilities that are NOT registered */\n readonly optional: readonly string[]\n}\n\n// ============================================================\n// VALIDATION\n// ============================================================\n\n/**\n * Validate that a surface's capability requirements can be met\n * by the capabilities available in the registry.\n *\n * Capability strings can be either:\n * - Short-form types from starters (e.g., 'persistence') which are resolved via type-mapping\n * - Full capability IDs (e.g., 'platform/persistence') used directly\n *\n * @param requirements - The capability requirements declared by a surface\n * @param registry - The capability registry to validate against\n * @returns A ValidationResult indicating which requirements are met\n */\nexport function validateSurfaceCapabilities(\n requirements: readonly CapabilityRequirement[],\n registry: CapabilityRegistry\n): CapabilityValidationResult {\n const satisfied: string[] = []\n const missing: string[] = []\n const optional: string[] = []\n\n for (const requirement of requirements) {\n const { capability, required } = requirement\n\n // Try to resolve short-form type to full ID, or use as-is\n const resolvedId = resolveCapabilityId(capability)\n const lookupId = resolvedId ?? capability\n\n // Check if the capability is registered\n // Use capabilityId() cast since registry.has() expects a branded CapabilityId\n const isRegistered = registry.has(lookupId as ReturnType<typeof resolveCapabilityId> & string)\n\n if (isRegistered) {\n satisfied.push(capability)\n } else if (required) {\n missing.push(capability)\n } else {\n optional.push(capability)\n }\n }\n\n return {\n valid: missing.length === 0,\n satisfied,\n missing,\n optional,\n }\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* build an engine from its DECLARATION.
|
|
3
|
+
*
|
|
4
|
+
* A REST engine is not a class. A class has a call signature, and a
|
|
5
|
+
* hand-written engine that takes one options object where the runtime passes
|
|
6
|
+
* two positional arguments ends up asking SharePoint for `lists/undefined`.
|
|
7
|
+
* A declaration has no signature to get wrong.
|
|
8
|
+
*
|
|
9
|
+
* WHAT THIS MODULE IS ALLOWED TO KNOW: how to turn seven declared facts into
|
|
10
|
+
* an `HttpEntityConnector`. It must not know a vendor's name, and the
|
|
11
|
+
* placement test measures exactly that — no provider name anywhere in
|
|
12
|
+
* `packages/runtime`. Everything SharePoint-shaped lives in the declaration,
|
|
13
|
+
* which lives in the pack that ships the connector.
|
|
14
|
+
*
|
|
15
|
+
* WHAT THE BASE DOES NOT LEARN. `entityPathMapper` and `responseMapper` stay
|
|
16
|
+
* plain functions on `HttpConnectorConfig`; this builds them. The pre-flight —
|
|
17
|
+
* Graph cannot address a list before its site id is resolved — is handled by
|
|
18
|
+
* constructing ONE base per resolved binding, so the mapper stays synchronous.
|
|
19
|
+
* Making it asynchronous would teach a shared contract one vendor's
|
|
20
|
+
* addressing dance.
|
|
21
|
+
*
|
|
22
|
+
* @module @pwfabric/runtime/connectors/declared-connector
|
|
23
|
+
*/
|
|
24
|
+
import type { EngineDeclaration } from '@pwfabric/contracts';
|
|
25
|
+
import type { EntityConnector } from '../entity/connector.js';
|
|
26
|
+
/**
|
|
27
|
+
* The only value transforms a declaration may name.
|
|
28
|
+
*
|
|
29
|
+
* CLOSED ON PURPOSE. A declaration carries a NAME, never a function — the
|
|
30
|
+
* moment it could carry a function it would be a class again with extra steps,
|
|
31
|
+
* and an AI-written declaration would regain the power to get something wrong.
|
|
32
|
+
* An unknown name throws at construction (see `resolveTransform`) rather than
|
|
33
|
+
* passing values through unchanged, because a silently skipped transform looks
|
|
34
|
+
* exactly like a field the source never sent.
|
|
35
|
+
*
|
|
36
|
+
* These two are named for what they DO, not for who needs them: the runtime
|
|
37
|
+
* must not learn a vendor's name.
|
|
38
|
+
*/
|
|
39
|
+
export declare const VALUE_TRANSFORMS: Readonly<Record<string, (value: unknown) => unknown>>;
|
|
40
|
+
export interface DeclaredConnectorOptions {
|
|
41
|
+
/** Connection name — the engine reports it, and the registry keys on it. */
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly declaration: EngineDeclaration;
|
|
44
|
+
/** Per-connection config the declaration's templates draw on. */
|
|
45
|
+
readonly config: Readonly<Record<string, unknown>>;
|
|
46
|
+
readonly getAccessToken: () => Promise<string | null>;
|
|
47
|
+
}
|
|
48
|
+
export declare function createDeclaredConnector(options: DeclaredConnectorOptions): EntityConnector;
|