@segmentstream/ontology 0.0.0-stage → 0.92.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 +201 -0
- package/NOTICE +2 -0
- package/README.md +1655 -2
- package/dist/action.d.ts +193 -0
- package/dist/action.js +41 -0
- package/dist/agent-chat.d.ts +44 -0
- package/dist/agent-chat.js +91 -0
- package/dist/agent-task-contract.d.ts +64 -0
- package/dist/agent-task-contract.js +15 -0
- package/dist/agent-task.d.ts +39 -0
- package/dist/agent-task.js +112 -0
- package/dist/analyze.d.ts +215 -0
- package/dist/analyze.js +2438 -0
- package/dist/app-feedback.d.ts +167 -0
- package/dist/app-feedback.js +176 -0
- package/dist/authoring-input.d.ts +3 -0
- package/dist/authoring-input.js +107 -0
- package/dist/authoring-names.d.ts +4 -0
- package/dist/authoring-names.js +13 -0
- package/dist/authoring-records.d.ts +35 -0
- package/dist/authoring-records.js +264 -0
- package/dist/authoring.d.ts +15 -0
- package/dist/authoring.js +331 -0
- package/dist/bin/check.d.ts +30 -0
- package/dist/bin/check.js +99 -0
- package/dist/bin/load.d.ts +48 -0
- package/dist/bin/load.js +139 -0
- package/dist/bin/main.d.ts +31 -0
- package/dist/bin/main.js +121 -0
- package/dist/bin/migrate.d.ts +57 -0
- package/dist/bin/migrate.js +170 -0
- package/dist/bin/output.d.ts +31 -0
- package/dist/bin/output.js +84 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +31 -0
- package/dist/blob.d.ts +52 -0
- package/dist/blob.js +87 -0
- package/dist/channel-session.d.ts +16 -0
- package/dist/channel-session.js +16 -0
- package/dist/chat.d.ts +43 -0
- package/dist/chat.js +34 -0
- package/dist/confirmation.d.ts +46 -0
- package/dist/confirmation.js +41 -0
- package/dist/connection.d.ts +213 -0
- package/dist/connection.js +289 -0
- package/dist/deployment.d.ts +35 -0
- package/dist/deployment.js +76 -0
- package/dist/diagnostics.d.ts +27 -0
- package/dist/diagnostics.js +106 -0
- package/dist/emails.d.ts +70 -0
- package/dist/emails.js +221 -0
- package/dist/entity.d.ts +331 -0
- package/dist/entity.js +153 -0
- package/dist/errors.d.ts +154 -0
- package/dist/errors.js +109 -0
- package/dist/feedback-config.d.ts +24 -0
- package/dist/feedback-config.js +126 -0
- package/dist/files.d.ts +39 -0
- package/dist/files.js +4 -0
- package/dist/groups.d.ts +95 -0
- package/dist/groups.js +280 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +70 -0
- package/dist/internal/diagnostics.js +594 -0
- package/dist/legacy.d.ts +160 -0
- package/dist/legacy.js +270 -0
- package/dist/manifest-compatibility.d.ts +8 -0
- package/dist/manifest-compatibility.js +87 -0
- package/dist/manifest.d.ts +3329 -0
- package/dist/manifest.js +757 -0
- package/dist/me.d.ts +46 -0
- package/dist/me.js +109 -0
- package/dist/metric-filters.d.ts +48 -0
- package/dist/metric-filters.js +252 -0
- package/dist/metric-routes.d.ts +132 -0
- package/dist/metric-routes.js +498 -0
- package/dist/metric.d.ts +172 -0
- package/dist/metric.js +132 -0
- package/dist/migrate/apply.d.ts +94 -0
- package/dist/migrate/apply.js +526 -0
- package/dist/migrate/errors.d.ts +46 -0
- package/dist/migrate/errors.js +38 -0
- package/dist/migrate/index.d.ts +10 -0
- package/dist/migrate/index.js +7 -0
- package/dist/migrate/model.d.ts +2311 -0
- package/dist/migrate/model.js +148 -0
- package/dist/migrate/plan.d.ts +51 -0
- package/dist/migrate/plan.js +1856 -0
- package/dist/migrate/preview.d.ts +13 -0
- package/dist/migrate/preview.js +65 -0
- package/dist/migrate/storage.d.ts +226 -0
- package/dist/migrate/storage.js +774 -0
- package/dist/model-metrics.d.ts +22 -0
- package/dist/model-metrics.js +545 -0
- package/dist/names.d.ts +49 -0
- package/dist/names.js +110 -0
- package/dist/navigation-artifact.d.ts +13 -0
- package/dist/navigation-artifact.js +11 -0
- package/dist/navigation-catalog.d.ts +55 -0
- package/dist/navigation-catalog.js +297 -0
- package/dist/nitro-navigation.d.ts +3 -0
- package/dist/nitro-navigation.js +64 -0
- package/dist/nitro-workflows.d.ts +108 -0
- package/dist/nitro-workflows.js +286 -0
- package/dist/nitro.d.ts +40 -0
- package/dist/nitro.js +50 -0
- package/dist/ontology.d.ts +41 -0
- package/dist/ontology.js +46 -0
- package/dist/permissions.d.ts +198 -0
- package/dist/permissions.js +272 -0
- package/dist/property.d.ts +188 -0
- package/dist/property.js +301 -0
- package/dist/query.d.ts +245 -0
- package/dist/query.js +615 -0
- package/dist/relationship.d.ts +99 -0
- package/dist/relationship.js +33 -0
- package/dist/render.d.ts +81 -0
- package/dist/render.js +512 -0
- package/dist/replication/baseline.d.ts +51 -0
- package/dist/replication/baseline.js +215 -0
- package/dist/replication/bigquery.d.ts +37 -0
- package/dist/replication/bigquery.js +211 -0
- package/dist/replication/coverage.d.ts +14 -0
- package/dist/replication/coverage.js +53 -0
- package/dist/replication/evolution.d.ts +25 -0
- package/dist/replication/evolution.js +184 -0
- package/dist/replication/identities.d.ts +6 -0
- package/dist/replication/identities.js +47 -0
- package/dist/replication/legacy-baseline.d.ts +27 -0
- package/dist/replication/legacy-baseline.js +109 -0
- package/dist/replication/legacy-store.d.ts +19 -0
- package/dist/replication/legacy-store.js +63 -0
- package/dist/replication/lineage.d.ts +36 -0
- package/dist/replication/lineage.js +72 -0
- package/dist/replication/migrate.d.ts +21 -0
- package/dist/replication/migrate.js +84 -0
- package/dist/replication/model.d.ts +52 -0
- package/dist/replication/model.js +99 -0
- package/dist/replication/scans.d.ts +34 -0
- package/dist/replication/scans.js +158 -0
- package/dist/replication/schema.d.ts +11 -0
- package/dist/replication/schema.js +226 -0
- package/dist/replication/shadow-schema.d.ts +4 -0
- package/dist/replication/shadow-schema.js +61 -0
- package/dist/replication/shadow.d.ts +127 -0
- package/dist/replication/shadow.js +614 -0
- package/dist/replication/source-replacement.d.ts +33 -0
- package/dist/replication/source-replacement.js +76 -0
- package/dist/replication/store.d.ts +36 -0
- package/dist/replication/store.js +382 -0
- package/dist/replication/transaction.d.ts +23 -0
- package/dist/replication/transaction.js +88 -0
- package/dist/role.d.ts +61 -0
- package/dist/role.js +76 -0
- package/dist/runtime/action-deadlocks.d.ts +21 -0
- package/dist/runtime/action-deadlocks.js +130 -0
- package/dist/runtime/action-transactions.d.ts +35 -0
- package/dist/runtime/action-transactions.js +54 -0
- package/dist/runtime/agent-counters.d.ts +26 -0
- package/dist/runtime/agent-counters.js +98 -0
- package/dist/runtime/agent-tasks.d.ts +63 -0
- package/dist/runtime/agent-tasks.js +120 -0
- package/dist/runtime/agents.d.ts +15 -0
- package/dist/runtime/agents.js +457 -0
- package/dist/runtime/batch-diagnostics.d.ts +22 -0
- package/dist/runtime/batch-diagnostics.js +89 -0
- package/dist/runtime/batch.d.ts +52 -0
- package/dist/runtime/batch.js +534 -0
- package/dist/runtime/channel-session-revocation.d.ts +3 -0
- package/dist/runtime/channel-session-revocation.js +5 -0
- package/dist/runtime/channel-sessions.d.ts +4 -0
- package/dist/runtime/channel-sessions.js +61 -0
- package/dist/runtime/confirmations.d.ts +29 -0
- package/dist/runtime/confirmations.js +57 -0
- package/dist/runtime/cursor.d.ts +23 -0
- package/dist/runtime/cursor.js +100 -0
- package/dist/runtime/deployment.d.ts +7 -0
- package/dist/runtime/deployment.js +4 -0
- package/dist/runtime/errors.d.ts +118 -0
- package/dist/runtime/errors.js +109 -0
- package/dist/runtime/federation-tables.d.ts +2 -0
- package/dist/runtime/federation-tables.js +20 -0
- package/dist/runtime/federation.d.ts +42 -0
- package/dist/runtime/federation.js +222 -0
- package/dist/runtime/files.d.ts +39 -0
- package/dist/runtime/files.js +44 -0
- package/dist/runtime/generated-actions.d.ts +37 -0
- package/dist/runtime/generated-actions.js +307 -0
- package/dist/runtime/history.d.ts +91 -0
- package/dist/runtime/history.js +77 -0
- package/dist/runtime/ids.d.ts +6 -0
- package/dist/runtime/ids.js +39 -0
- package/dist/runtime/member-tables.d.ts +8 -0
- package/dist/runtime/member-tables.js +33 -0
- package/dist/runtime/member-writes.d.ts +78 -0
- package/dist/runtime/member-writes.js +202 -0
- package/dist/runtime/metric-query.d.ts +19 -0
- package/dist/runtime/metric-query.js +411 -0
- package/dist/runtime/model.d.ts +67 -0
- package/dist/runtime/model.js +150 -0
- package/dist/runtime/new-user-hook.d.ts +6 -0
- package/dist/runtime/new-user-hook.js +37 -0
- package/dist/runtime/oauth.d.ts +9 -0
- package/dist/runtime/oauth.js +299 -0
- package/dist/runtime/pipeline.d.ts +155 -0
- package/dist/runtime/pipeline.js +597 -0
- package/dist/runtime/postgres-tls.d.ts +10 -0
- package/dist/runtime/postgres-tls.js +14 -0
- package/dist/runtime/principals.d.ts +302 -0
- package/dist/runtime/principals.js +1307 -0
- package/dist/runtime/reads.d.ts +55 -0
- package/dist/runtime/reads.js +313 -0
- package/dist/runtime/records.d.ts +42 -0
- package/dist/runtime/records.js +245 -0
- package/dist/runtime/resolve-agent-identity.d.ts +6 -0
- package/dist/runtime/resolve-agent-identity.js +181 -0
- package/dist/runtime/service-binding.d.ts +18 -0
- package/dist/runtime/service-binding.js +266 -0
- package/dist/runtime/sign-in-links.d.ts +68 -0
- package/dist/runtime/sign-in-links.js +147 -0
- package/dist/runtime/sql-runtime.d.ts +131 -0
- package/dist/runtime/sql-runtime.js +362 -0
- package/dist/runtime/statement.d.ts +18 -0
- package/dist/runtime/statement.js +31 -0
- package/dist/runtime/user-identities.d.ts +66 -0
- package/dist/runtime/user-identities.js +106 -0
- package/dist/runtime/user-identity-sql.d.ts +86 -0
- package/dist/runtime/user-identity-sql.js +297 -0
- package/dist/runtime/user-roles.d.ts +16 -0
- package/dist/runtime/user-roles.js +32 -0
- package/dist/runtime/validation.d.ts +16 -0
- package/dist/runtime/validation.js +26 -0
- package/dist/runtime/where.d.ts +57 -0
- package/dist/runtime/where.js +404 -0
- package/dist/runtime/workflow-admission.d.ts +49 -0
- package/dist/runtime/workflow-admission.js +92 -0
- package/dist/runtime/workflow-argument-codec.d.ts +10 -0
- package/dist/runtime/workflow-argument-codec.js +120 -0
- package/dist/runtime/workflow-arguments.d.ts +17 -0
- package/dist/runtime/workflow-arguments.js +99 -0
- package/dist/runtime/workflow-starts.d.ts +203 -0
- package/dist/runtime/workflow-starts.js +493 -0
- package/dist/runtime/workflow-users.d.ts +9 -0
- package/dist/runtime/workflow-users.js +17 -0
- package/dist/runtime/workload.d.ts +25 -0
- package/dist/runtime/workload.js +24 -0
- package/dist/runtime/writes.d.ts +108 -0
- package/dist/runtime/writes.js +491 -0
- package/dist/runtime-source.d.ts +22 -0
- package/dist/runtime-source.js +28 -0
- package/dist/runtime.d.ts +310 -0
- package/dist/runtime.js +31 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.js +107 -0
- package/dist/service/agent/attachments.d.ts +33 -0
- package/dist/service/agent/attachments.js +228 -0
- package/dist/service/agent/authentication.d.ts +22 -0
- package/dist/service/agent/authentication.js +58 -0
- package/dist/service/agent/confirmations.d.ts +5 -0
- package/dist/service/agent/confirmations.js +73 -0
- package/dist/service/agent/conversation-routes.d.ts +14 -0
- package/dist/service/agent/conversation-routes.js +45 -0
- package/dist/service/agent/conversations.d.ts +40 -0
- package/dist/service/agent/conversations.js +69 -0
- package/dist/service/agent/files.d.ts +12 -0
- package/dist/service/agent/files.js +69 -0
- package/dist/service/agent/protocol.d.ts +90 -0
- package/dist/service/agent/protocol.js +114 -0
- package/dist/service/agent/server.d.ts +28 -0
- package/dist/service/agent/server.js +374 -0
- package/dist/service/agent/task-caller.d.ts +21 -0
- package/dist/service/agent/task-caller.js +35 -0
- package/dist/service/agent/task-start.d.ts +53 -0
- package/dist/service/agent/task-start.js +161 -0
- package/dist/service/agent/tasks.d.ts +40 -0
- package/dist/service/agent/tasks.js +155 -0
- package/dist/service/api.d.ts +50 -0
- package/dist/service/api.js +288 -0
- package/dist/service/authentication.d.ts +227 -0
- package/dist/service/authentication.js +767 -0
- package/dist/service/caller-context.d.ts +24 -0
- package/dist/service/caller-context.js +6 -0
- package/dist/service/catalog.d.ts +42 -0
- package/dist/service/catalog.js +66 -0
- package/dist/service/channel/provider.d.ts +10 -0
- package/dist/service/channel/provider.js +1 -0
- package/dist/service/channel/providers/telegram.d.ts +18 -0
- package/dist/service/channel/providers/telegram.js +108 -0
- package/dist/service/channel/sessions.d.ts +5 -0
- package/dist/service/channel/sessions.js +53 -0
- package/dist/service/channel/sign-in.d.ts +7 -0
- package/dist/service/channel/sign-in.js +78 -0
- package/dist/service/chat/archive.d.ts +64 -0
- package/dist/service/chat/archive.js +62 -0
- package/dist/service/chat/attribution.d.ts +26 -0
- package/dist/service/chat/attribution.js +28 -0
- package/dist/service/chat/delivery.d.ts +18 -0
- package/dist/service/chat/delivery.js +251 -0
- package/dist/service/chat/diagnostics.d.ts +2 -0
- package/dist/service/chat/diagnostics.js +35 -0
- package/dist/service/chat/envelope.d.ts +96 -0
- package/dist/service/chat/envelope.js +39 -0
- package/dist/service/chat/idempotency.d.ts +19 -0
- package/dist/service/chat/idempotency.js +37 -0
- package/dist/service/chat/providers/telegram.d.ts +36 -0
- package/dist/service/chat/providers/telegram.js +133 -0
- package/dist/service/chat/reads.d.ts +25 -0
- package/dist/service/chat/reads.js +75 -0
- package/dist/service/chat/resolve.d.ts +34 -0
- package/dist/service/chat/resolve.js +150 -0
- package/dist/service/chat/routes.d.ts +23 -0
- package/dist/service/chat/routes.js +75 -0
- package/dist/service/chat/schemas.d.ts +43 -0
- package/dist/service/chat/schemas.js +31 -0
- package/dist/service/config.d.ts +218 -0
- package/dist/service/config.js +265 -0
- package/dist/service/connection-stream.d.ts +10 -0
- package/dist/service/connection-stream.js +191 -0
- package/dist/service/connections.d.ts +60 -0
- package/dist/service/connections.js +271 -0
- package/dist/service/decisions.d.ts +35 -0
- package/dist/service/decisions.js +63 -0
- package/dist/service/descriptions.d.ts +8 -0
- package/dist/service/descriptions.js +20 -0
- package/dist/service/discovery-schemas.d.ts +92 -0
- package/dist/service/discovery-schemas.js +59 -0
- package/dist/service/discovery-search.d.ts +30 -0
- package/dist/service/discovery-search.js +95 -0
- package/dist/service/discovery.d.ts +37 -0
- package/dist/service/discovery.js +436 -0
- package/dist/service/docs.d.ts +9 -0
- package/dist/service/docs.js +197 -0
- package/dist/service/errors.d.ts +145 -0
- package/dist/service/errors.js +704 -0
- package/dist/service/federation-provider.d.ts +36 -0
- package/dist/service/federation-provider.js +110 -0
- package/dist/service/federation-server.d.ts +20 -0
- package/dist/service/federation-server.js +249 -0
- package/dist/service/federation-status.d.ts +40 -0
- package/dist/service/federation-status.js +151 -0
- package/dist/service/handlers.d.ts +18 -0
- package/dist/service/handlers.js +287 -0
- package/dist/service/mcp/confirmation.d.ts +68 -0
- package/dist/service/mcp/confirmation.js +178 -0
- package/dist/service/mcp/find-input.d.ts +12 -0
- package/dist/service/mcp/find-input.js +122 -0
- package/dist/service/mcp/input-schema.d.ts +6 -0
- package/dist/service/mcp/input-schema.js +126 -0
- package/dist/service/mcp/listing.d.ts +26 -0
- package/dist/service/mcp/listing.js +92 -0
- package/dist/service/mcp/metric-tools.d.ts +85 -0
- package/dist/service/mcp/metric-tools.js +258 -0
- package/dist/service/mcp/request-log.d.ts +5 -0
- package/dist/service/mcp/request-log.js +53 -0
- package/dist/service/mcp/runtime-policy.d.ts +27 -0
- package/dist/service/mcp/runtime-policy.js +62 -0
- package/dist/service/mcp/server.d.ts +52 -0
- package/dist/service/mcp/server.js +861 -0
- package/dist/service/mcp/tools.d.ts +99 -0
- package/dist/service/mcp/tools.js +938 -0
- package/dist/service/member-file-routes.d.ts +22 -0
- package/dist/service/member-file-routes.js +52 -0
- package/dist/service/member-files.d.ts +245 -0
- package/dist/service/member-files.js +258 -0
- package/dist/service/metric-query-platform.d.ts +77 -0
- package/dist/service/metric-query-platform.js +198 -0
- package/dist/service/metric-query-scopes.d.ts +43 -0
- package/dist/service/metric-query-scopes.js +147 -0
- package/dist/service/metric-query.d.ts +48 -0
- package/dist/service/metric-query.js +200 -0
- package/dist/service/name-suggestions.d.ts +3 -0
- package/dist/service/name-suggestions.js +38 -0
- package/dist/service/navigation-schemas.d.ts +80 -0
- package/dist/service/navigation-schemas.js +49 -0
- package/dist/service/navigation.d.ts +20 -0
- package/dist/service/navigation.js +165 -0
- package/dist/service/oauth/protocol.d.ts +70 -0
- package/dist/service/oauth/protocol.js +157 -0
- package/dist/service/oauth/refresh-replay.d.ts +2 -0
- package/dist/service/oauth/refresh-replay.js +20 -0
- package/dist/service/oauth/server.d.ts +28 -0
- package/dist/service/oauth/server.js +769 -0
- package/dist/service/operations.d.ts +170 -0
- package/dist/service/operations.js +392 -0
- package/dist/service/plan.d.ts +57 -0
- package/dist/service/plan.js +96 -0
- package/dist/service/rate-limit.d.ts +22 -0
- package/dist/service/rate-limit.js +52 -0
- package/dist/service/record-reads.d.ts +21 -0
- package/dist/service/record-reads.js +155 -0
- package/dist/service/replication.d.ts +5 -0
- package/dist/service/replication.js +39 -0
- package/dist/service/runtime-contract.d.ts +508 -0
- package/dist/service/runtime-contract.js +18 -0
- package/dist/service/runtime-identity.d.ts +71 -0
- package/dist/service/runtime-identity.js +122 -0
- package/dist/service/schemas.d.ts +961 -0
- package/dist/service/schemas.js +639 -0
- package/dist/service/service.d.ts +21 -0
- package/dist/service/service.js +526 -0
- package/dist/service/warehouse-platform.d.ts +17 -0
- package/dist/service/warehouse-platform.js +122 -0
- package/dist/service/warehouse-query.d.ts +24 -0
- package/dist/service/warehouse-query.js +280 -0
- package/dist/service/webhooks.d.ts +106 -0
- package/dist/service/webhooks.js +233 -0
- package/dist/service/workflow-admission-provider.d.ts +31 -0
- package/dist/service/workflow-admission-provider.js +205 -0
- package/dist/service/workflow-argument-serialization.d.ts +2 -0
- package/dist/service/workflow-argument-serialization.js +14 -0
- package/dist/service/workflow-callback.d.ts +22 -0
- package/dist/service/workflow-callback.js +75 -0
- package/dist/service/workflow-deployment.d.ts +8 -0
- package/dist/service/workflow-deployment.js +131 -0
- package/dist/service/workflow-diagnostics.d.ts +23 -0
- package/dist/service/workflow-diagnostics.js +263 -0
- package/dist/service/workflow-errors.d.ts +26 -0
- package/dist/service/workflow-errors.js +181 -0
- package/dist/service/workflow-logging.d.ts +2 -0
- package/dist/service/workflow-logging.js +50 -0
- package/dist/service/workflow-queue-fence.d.ts +6 -0
- package/dist/service/workflow-queue-fence.js +66 -0
- package/dist/service/workflows.d.ts +200 -0
- package/dist/service/workflows.js +1549 -0
- package/dist/sign-in.d.ts +58 -0
- package/dist/sign-in.js +57 -0
- package/dist/source.d.ts +30 -0
- package/dist/source.js +107 -0
- package/dist/start-recovery-contract.d.ts +49 -0
- package/dist/start-recovery-contract.js +26 -0
- package/dist/start-recovery.d.ts +27 -0
- package/dist/start-recovery.js +81 -0
- package/dist/storage/api.d.ts +4 -0
- package/dist/storage/api.js +40 -0
- package/dist/storage/attachments.d.ts +146 -0
- package/dist/storage/attachments.js +733 -0
- package/dist/storage/authorization.d.ts +38 -0
- package/dist/storage/authorization.js +83 -0
- package/dist/storage/file-access.d.ts +17 -0
- package/dist/storage/file-access.js +8 -0
- package/dist/storage/limits.d.ts +12 -0
- package/dist/storage/limits.js +17 -0
- package/dist/storage/maintenance-auth.d.ts +20 -0
- package/dist/storage/maintenance-auth.js +24 -0
- package/dist/storage/maintenance.d.ts +11 -0
- package/dist/storage/maintenance.js +67 -0
- package/dist/storage/neon.d.ts +4 -0
- package/dist/storage/neon.js +318 -0
- package/dist/storage/operator.d.ts +11 -0
- package/dist/storage/operator.js +30 -0
- package/dist/storage/provider.d.ts +93 -0
- package/dist/storage/provider.js +36 -0
- package/dist/storage/sessions.d.ts +184 -0
- package/dist/storage/sessions.js +688 -0
- package/dist/storage/tables.d.ts +54 -0
- package/dist/storage/tables.js +205 -0
- package/dist/storage/transfers.d.ts +16 -0
- package/dist/storage/transfers.js +153 -0
- package/dist/storage/writes.d.ts +7 -0
- package/dist/storage/writes.js +88 -0
- package/dist/telegram.d.ts +35 -0
- package/dist/telegram.js +173 -0
- package/dist/user-identity.d.ts +28 -0
- package/dist/user-identity.js +106 -0
- package/dist/user.d.ts +75 -0
- package/dist/user.js +111 -0
- package/dist/warehouse-backed.d.ts +6 -0
- package/dist/warehouse-backed.js +495 -0
- package/dist/webhook-token.d.ts +11 -0
- package/dist/webhook-token.js +18 -0
- package/dist/webhooks.d.ts +40 -0
- package/dist/webhooks.js +55 -0
- package/dist/wire.d.ts +10 -0
- package/dist/wire.js +35 -0
- package/dist/workflow-runtime.d.ts +116 -0
- package/dist/workflow-runtime.js +109 -0
- package/dist/workflow-topics.d.ts +28 -0
- package/dist/workflow-topics.js +28 -0
- package/dist/workflow.d.ts +284 -0
- package/dist/workflow.js +259 -0
- package/dist/workflows.d.ts +24 -0
- package/dist/workflows.js +18 -0
- package/package.json +127 -4
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { isEntity } from "./entity.js";
|
|
2
|
+
import { toCamelCase } from "./names.js";
|
|
3
|
+
import { propertyDefinition } from "./property.js";
|
|
4
|
+
import { isIncludeList } from "./query.js";
|
|
5
|
+
import { isRecord, nameToWire } from "./authoring-names.js";
|
|
6
|
+
import { isMe, mePathOf, meToWire } from "./me.js";
|
|
7
|
+
function targetDefinition(target) {
|
|
8
|
+
const resolved = typeof target === "function" ? target() : target;
|
|
9
|
+
return isEntity(resolved) ? resolved.definition : undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A select property's values as stored, the option values' wire names, or as authored when
|
|
13
|
+
* `decode`. Other properties' values are data and stay as they are.
|
|
14
|
+
*/
|
|
15
|
+
export function selectValue(value, property, decode) {
|
|
16
|
+
const definition = propertyDefinition(property);
|
|
17
|
+
if (definition?.type !== "select") {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
const convert = (child) => typeof child !== "string"
|
|
21
|
+
? child
|
|
22
|
+
: decode
|
|
23
|
+
? (definition.options?.find((option) => nameToWire(option.value) === child)?.value ?? child)
|
|
24
|
+
: nameToWire(child);
|
|
25
|
+
return Array.isArray(value) ? value.map(convert) : convert(value);
|
|
26
|
+
}
|
|
27
|
+
/** Only record keys and select identifiers convert; property values remain data. */
|
|
28
|
+
export function recordFromWire(value, definition) {
|
|
29
|
+
if (!isRecord(value)) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
return Object.fromEntries(Object.entries(value).map(([name, child]) => {
|
|
33
|
+
const property = Object.entries(definition?.properties ?? {}).find(([key]) => nameToWire(key) === name);
|
|
34
|
+
if (property !== undefined) {
|
|
35
|
+
return [property[0], selectValue(child, property[1], true)];
|
|
36
|
+
}
|
|
37
|
+
const relationship = Object.entries(definition?.relationships ?? {}).find(([key]) => nameToWire(key) === name);
|
|
38
|
+
if (relationship !== undefined) {
|
|
39
|
+
const target = targetDefinition(relationship[1].target);
|
|
40
|
+
return [
|
|
41
|
+
relationship[0],
|
|
42
|
+
Array.isArray(child)
|
|
43
|
+
? child.map((item) => recordFromWire(item, target))
|
|
44
|
+
: recordFromWire(child, target),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
return [toCamelCase(name), child];
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
export function valuesToWire(values, definition) {
|
|
51
|
+
return Object.fromEntries(Object.entries(values).map(([name, value]) => [
|
|
52
|
+
nameToWire(name),
|
|
53
|
+
selectValue(value, definition.properties[name], false),
|
|
54
|
+
]));
|
|
55
|
+
}
|
|
56
|
+
/** Translate query fields and relationships; operands of JSON filters stay opaque. */
|
|
57
|
+
function whereToWire(where, definition) {
|
|
58
|
+
return Object.fromEntries(Object.entries(where).map(([name, condition]) => {
|
|
59
|
+
if ((name === "and" || name === "or") && Array.isArray(condition)) {
|
|
60
|
+
return [name, condition.map((child) => whereToWire(child, definition))];
|
|
61
|
+
}
|
|
62
|
+
if (name === "not" && isRecord(condition)) {
|
|
63
|
+
return [name, whereToWire(condition, definition)];
|
|
64
|
+
}
|
|
65
|
+
const property = definition?.properties[name];
|
|
66
|
+
const relationship = definition?.relationships?.[name];
|
|
67
|
+
if (relationship !== undefined && isRecord(condition)) {
|
|
68
|
+
const target = targetDefinition(relationship.target);
|
|
69
|
+
return [
|
|
70
|
+
nameToWire(name),
|
|
71
|
+
relationship.cardinality === "many"
|
|
72
|
+
? Object.fromEntries(Object.entries(condition).map(([quantifier, child]) => [
|
|
73
|
+
quantifier,
|
|
74
|
+
isRecord(child) ? whereToWire(child, target) : child,
|
|
75
|
+
]))
|
|
76
|
+
: whereToWire(condition, target),
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
if (isRecord(condition)) {
|
|
80
|
+
const operators = [
|
|
81
|
+
"eq",
|
|
82
|
+
"ne",
|
|
83
|
+
"in",
|
|
84
|
+
"isNull",
|
|
85
|
+
"contains",
|
|
86
|
+
"startsWith",
|
|
87
|
+
"gt",
|
|
88
|
+
"gte",
|
|
89
|
+
"lt",
|
|
90
|
+
"lte",
|
|
91
|
+
"between",
|
|
92
|
+
];
|
|
93
|
+
if (Object.keys(condition).every((key) => operators.includes(key))) {
|
|
94
|
+
return [
|
|
95
|
+
nameToWire(name),
|
|
96
|
+
Object.fromEntries(Object.entries(condition).map(([key, child]) => [
|
|
97
|
+
key,
|
|
98
|
+
selectValue(child, property, false),
|
|
99
|
+
])),
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
if (propertyDefinition(property)?.type !== "json") {
|
|
103
|
+
return [nameToWire(name), whereToWire(condition)];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return [nameToWire(name), selectValue(condition, property, false)];
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
const FIELD_OPERATORS = [
|
|
110
|
+
"eq",
|
|
111
|
+
"ne",
|
|
112
|
+
"in",
|
|
113
|
+
"isNull",
|
|
114
|
+
"contains",
|
|
115
|
+
"startsWith",
|
|
116
|
+
"gt",
|
|
117
|
+
"gte",
|
|
118
|
+
"lt",
|
|
119
|
+
"lte",
|
|
120
|
+
"between",
|
|
121
|
+
];
|
|
122
|
+
/** The operators of a query on the wire, by their authored names. */
|
|
123
|
+
const WIRE_OPERATORS = {
|
|
124
|
+
isNull: "is_null",
|
|
125
|
+
startsWith: "starts_with",
|
|
126
|
+
};
|
|
127
|
+
/** Whether a condition is a field filter: an object of operators, authored or wire names. */
|
|
128
|
+
function isOperators(condition) {
|
|
129
|
+
const keys = Object.keys(condition);
|
|
130
|
+
return (keys.length > 0 &&
|
|
131
|
+
keys.every((key) => FIELD_OPERATORS.includes(key) || Object.values(WIRE_OPERATORS).includes(key)));
|
|
132
|
+
}
|
|
133
|
+
/** The declaration of `name` in a definition's record, by authored or wire name. */
|
|
134
|
+
function declared(declarations, name) {
|
|
135
|
+
if (declarations === undefined) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
if (Object.hasOwn(declarations, name)) {
|
|
139
|
+
return declarations[name];
|
|
140
|
+
}
|
|
141
|
+
return Object.entries(declarations).find(([key]) => nameToWire(key) === name)?.[1];
|
|
142
|
+
}
|
|
143
|
+
/** A value of a scope on the wire: `me` and paths as `{ "$me": [...] }`, select values as stored. */
|
|
144
|
+
function scopeValueToWire(value, property) {
|
|
145
|
+
const hops = mePathOf(value);
|
|
146
|
+
if (hops !== undefined) {
|
|
147
|
+
return meToWire(isMe(value) ? value : hops);
|
|
148
|
+
}
|
|
149
|
+
return selectValue(value, property, false);
|
|
150
|
+
}
|
|
151
|
+
function operatorsToWire(condition, property) {
|
|
152
|
+
return Object.fromEntries(Object.entries(condition).map(([key, child]) => [
|
|
153
|
+
WIRE_OPERATORS[key] ?? key,
|
|
154
|
+
scopeValueToWire(child, property),
|
|
155
|
+
]));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The `where` of a scoped permission as the manifest writes it: the wire form of a query, with
|
|
159
|
+
* snake_case fields, relationships and operators, select values as stored, and `me` and paths as
|
|
160
|
+
* `{ "$me": [...] }` with snake_case hops. A relationship compared with `me`, a path or operators
|
|
161
|
+
* stays under its name. Converting a wire `where` again changes nothing.
|
|
162
|
+
*/
|
|
163
|
+
export function scopeWhereToWire(where, definition) {
|
|
164
|
+
if (!isRecord(where) || mePathOf(where) !== undefined) {
|
|
165
|
+
return where;
|
|
166
|
+
}
|
|
167
|
+
return Object.fromEntries(Object.entries(where).map(([name, condition]) => {
|
|
168
|
+
if ((name === "and" || name === "or") && Array.isArray(condition)) {
|
|
169
|
+
return [name, condition.map((child) => scopeWhereToWire(child, definition))];
|
|
170
|
+
}
|
|
171
|
+
if (name === "not") {
|
|
172
|
+
return [name, scopeWhereToWire(condition, definition)];
|
|
173
|
+
}
|
|
174
|
+
const property = declared(definition?.properties, name);
|
|
175
|
+
const relationship = declared(definition?.relationships, name);
|
|
176
|
+
if (mePathOf(condition) !== undefined) {
|
|
177
|
+
return [nameToWire(name), scopeValueToWire(condition, property)];
|
|
178
|
+
}
|
|
179
|
+
if (isRecord(condition) && isOperators(condition)) {
|
|
180
|
+
return [nameToWire(name), operatorsToWire(condition, property)];
|
|
181
|
+
}
|
|
182
|
+
if (relationship !== undefined && isRecord(condition)) {
|
|
183
|
+
const target = targetDefinition(relationship.target);
|
|
184
|
+
return [
|
|
185
|
+
nameToWire(name),
|
|
186
|
+
relationship.cardinality === "many"
|
|
187
|
+
? Object.fromEntries(Object.entries(condition).map(([quantifier, child]) => [
|
|
188
|
+
quantifier,
|
|
189
|
+
scopeWhereToWire(child, target),
|
|
190
|
+
]))
|
|
191
|
+
: scopeWhereToWire(condition, target),
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
if (isRecord(condition) && propertyDefinition(property)?.type !== "json") {
|
|
195
|
+
return [nameToWire(name), scopeWhereToWire(condition)];
|
|
196
|
+
}
|
|
197
|
+
return [nameToWire(name), selectValue(condition, property, false)];
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
export function findToWire(options, definition) {
|
|
201
|
+
return {
|
|
202
|
+
...options,
|
|
203
|
+
...(options.where === undefined ? {} : { where: whereToWire(options.where, definition) }),
|
|
204
|
+
...(options.orderBy === undefined
|
|
205
|
+
? {}
|
|
206
|
+
: {
|
|
207
|
+
orderBy: options.orderBy.map((order) => ({ ...order, field: nameToWire(order.field) })),
|
|
208
|
+
}),
|
|
209
|
+
...(options.include === undefined ? {} : { include: includeToWire(options.include) }),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/** A fresh metric query's metrics, grouped fields and `where` in wire names. */
|
|
213
|
+
export function metricQueryToWire(options, definition) {
|
|
214
|
+
return {
|
|
215
|
+
...options,
|
|
216
|
+
metrics: options.metrics.map(nameToWire),
|
|
217
|
+
...(options.groupBy === undefined ? {} : { groupBy: options.groupBy.map(nameToWire) }),
|
|
218
|
+
where: whereToWire(options.where, definition),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* A fresh metric query's row in authored names: the grouped fields as a record's, the metrics by the
|
|
223
|
+
* names the handler asked for.
|
|
224
|
+
*/
|
|
225
|
+
export function metricQueryRowFromWire(row, metrics, definition) {
|
|
226
|
+
const byWire = new Map(metrics.map((metric) => [nameToWire(metric), metric]));
|
|
227
|
+
const groups = Object.fromEntries(Object.entries(row).filter(([name]) => !byWire.has(name)));
|
|
228
|
+
return {
|
|
229
|
+
...recordFromWire(groups, definition),
|
|
230
|
+
...Object.fromEntries([...byWire].map(([wire, metric]) => [metric, row[wire] ?? null])),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/** The relationships a find includes, by wire name, in the form the handler gave them. */
|
|
234
|
+
function includeToWire(include) {
|
|
235
|
+
return isIncludeList(include)
|
|
236
|
+
? include.map(nameToWire)
|
|
237
|
+
: Object.fromEntries(Object.entries(include).map(([name, value]) => [nameToWire(name), value]));
|
|
238
|
+
}
|
|
239
|
+
/** Current action edits use the same property names and values as authored entity records. */
|
|
240
|
+
export function editsFromWire(edits, entities) {
|
|
241
|
+
return edits.map((edit) => {
|
|
242
|
+
const definition = entities.find((entity) => nameToWire(entity.name) === edit.entity)?.definition;
|
|
243
|
+
const before = recordFromWire(Object.fromEntries(Object.entries(edit.changes).map(([field, change]) => [field, change.before])), definition);
|
|
244
|
+
const after = recordFromWire(Object.fromEntries(Object.entries(edit.changes).map(([field, change]) => [field, change.after])), definition);
|
|
245
|
+
return {
|
|
246
|
+
...edit,
|
|
247
|
+
entity: toCamelCase(edit.entity),
|
|
248
|
+
changes: Object.fromEntries(Object.keys(before).map((field) => [
|
|
249
|
+
field,
|
|
250
|
+
{ before: before[field], after: after[field] },
|
|
251
|
+
])),
|
|
252
|
+
};
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
/** Generated actions return entity records; authored action results remain application data. */
|
|
256
|
+
export function generatedResultFromWire(value, action, definition) {
|
|
257
|
+
if (action === "create" || action === "update") {
|
|
258
|
+
return recordFromWire(value, definition);
|
|
259
|
+
}
|
|
260
|
+
if (action.startsWith("upsert_by_") && isRecord(value)) {
|
|
261
|
+
return { ...value, record: recordFromWire(value.record, definition) };
|
|
262
|
+
}
|
|
263
|
+
return value;
|
|
264
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OntologyConfig } from "./analyze.js";
|
|
2
|
+
import type { DiagnosticCode } from "./diagnostics.js";
|
|
3
|
+
import { type AnyEntity } from "./entity.js";
|
|
4
|
+
import type { Principal } from "./runtime.js";
|
|
5
|
+
type Report = (code: DiagnosticCode, path: string, message: string) => void;
|
|
6
|
+
export declare function principalFromWire<P extends Principal>(principal: P): P;
|
|
7
|
+
/**
|
|
8
|
+
* Canonical definitions feed REST, storage and future transports; the public config stays camelCase.
|
|
9
|
+
* The built-in entities, which every ontology includes, are normalized with the declared ones.
|
|
10
|
+
*/
|
|
11
|
+
export declare function authoringToWire(config: OntologyConfig, builtIns: ReadonlyArray<AnyEntity>, report: Report): {
|
|
12
|
+
readonly config: OntologyConfig;
|
|
13
|
+
readonly builtIns: ReadonlyArray<AnyEntity>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { isAction } from "./action.js";
|
|
3
|
+
import { actionInputToWire } from "./authoring-input.js";
|
|
4
|
+
import { isRecord, nameToWire, permissionToWire } from "./authoring-names.js";
|
|
5
|
+
import { earlierMetricsFieldProblem, withCurrentDefinitionNames } from "./legacy.js";
|
|
6
|
+
import { scopeWhereToWire, selectValue } from "./authoring-records.js";
|
|
7
|
+
import { isEntity } from "./entity.js";
|
|
8
|
+
import { toCamelCase } from "./names.js";
|
|
9
|
+
import { inheritUnknownOptions, p, propertyDefinition, } from "./property.js";
|
|
10
|
+
import { isRelationship } from "./relationship.js";
|
|
11
|
+
import { isRole, member, roleEntries, rolePermissions, } from "./role.js";
|
|
12
|
+
export function principalFromWire(principal) {
|
|
13
|
+
return {
|
|
14
|
+
...principal,
|
|
15
|
+
roles: principal.roles.map(toCamelCase),
|
|
16
|
+
permissions: principal.permissions.map(toCamelCase),
|
|
17
|
+
...(principal.scopes === undefined
|
|
18
|
+
? {}
|
|
19
|
+
: {
|
|
20
|
+
scopes: principal.scopes.map((scope) => ({
|
|
21
|
+
...scope,
|
|
22
|
+
permission: toCamelCase(scope.permission),
|
|
23
|
+
})),
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function indexToWire(index) {
|
|
28
|
+
if (Array.isArray(index)) {
|
|
29
|
+
return index.map(nameToWire);
|
|
30
|
+
}
|
|
31
|
+
const definition = index;
|
|
32
|
+
return { ...definition, properties: (definition.properties ?? []).map(nameToWire) };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A metric condition with wire names: its property, as `property` or, in a `filtered` expression,
|
|
36
|
+
* `column`, and the values of a select property, which are option values.
|
|
37
|
+
*/
|
|
38
|
+
function conditionToWire(condition, properties) {
|
|
39
|
+
if (!isRecord(condition)) {
|
|
40
|
+
return condition;
|
|
41
|
+
}
|
|
42
|
+
const key = "property" in condition ? "property" : "column";
|
|
43
|
+
const name = condition[key];
|
|
44
|
+
if (typeof name !== "string") {
|
|
45
|
+
return condition;
|
|
46
|
+
}
|
|
47
|
+
const property = isRecord(properties) && Object.hasOwn(properties, name) ? properties[name] : undefined;
|
|
48
|
+
return {
|
|
49
|
+
...condition,
|
|
50
|
+
[key]: nameToWire(name),
|
|
51
|
+
...("value" in condition ? { value: selectValue(condition.value, property, false) } : {}),
|
|
52
|
+
...("values" in condition ? { values: selectValue(condition.values, property, false) } : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** A metric expression with wire names: properties, metric references and conditions. */
|
|
56
|
+
function expressionToWire(value, properties) {
|
|
57
|
+
if (!isRecord(value)) {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
const expression = { ...value };
|
|
61
|
+
if (typeof value.name === "string" && (value.op === "metric" || value.op === "column")) {
|
|
62
|
+
expression.name = nameToWire(value.name);
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(value.args)) {
|
|
65
|
+
expression.args = value.args.map((arg) => expressionToWire(arg, properties));
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(value.where)) {
|
|
68
|
+
expression.where = value.where.map((condition) => conditionToWire(condition, properties));
|
|
69
|
+
}
|
|
70
|
+
if (typeof value.balanceOver === "string") {
|
|
71
|
+
expression.balanceOver = nameToWire(value.balanceOver);
|
|
72
|
+
}
|
|
73
|
+
return expression;
|
|
74
|
+
}
|
|
75
|
+
/** Preserve shared definitions and lazy relationship targets while building the canonical model. */
|
|
76
|
+
class AuthoringEncoder {
|
|
77
|
+
report;
|
|
78
|
+
definitionsByName;
|
|
79
|
+
entities = new WeakMap();
|
|
80
|
+
definitions = new WeakMap();
|
|
81
|
+
properties = new WeakMap();
|
|
82
|
+
roles = new WeakMap();
|
|
83
|
+
constructor(report,
|
|
84
|
+
/** The authored definitions of the entities, by wire name, which scopes are converted with. */
|
|
85
|
+
definitionsByName = new Map()) {
|
|
86
|
+
this.report = report;
|
|
87
|
+
this.definitionsByName = definitionsByName;
|
|
88
|
+
}
|
|
89
|
+
name(name, path) {
|
|
90
|
+
const encoded = nameToWire(name);
|
|
91
|
+
if (typeof name === "string" &&
|
|
92
|
+
/^[a-z][a-zA-Z0-9]*$/.test(name) &&
|
|
93
|
+
name !== toCamelCase(encoded)) {
|
|
94
|
+
this.report("invalid-name", path, `Use lower camelCase ${toCamelCase(encoded)} ` +
|
|
95
|
+
"so the TypeScript and wire names round-trip.");
|
|
96
|
+
}
|
|
97
|
+
return encoded;
|
|
98
|
+
}
|
|
99
|
+
named(values, path, convert) {
|
|
100
|
+
const result = Object.create(null);
|
|
101
|
+
for (const [name, value] of Object.entries(values ?? {})) {
|
|
102
|
+
const fieldPath = `${path}.${name}`;
|
|
103
|
+
const wireName = this.name(name, fieldPath);
|
|
104
|
+
if (Object.hasOwn(result, wireName)) {
|
|
105
|
+
this.report("duplicate-name", fieldPath, `Names collide on ${wireName} after snake_case conversion.`);
|
|
106
|
+
}
|
|
107
|
+
result[wireName] = convert(value, fieldPath);
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
property(value, path) {
|
|
112
|
+
if (!Schema.isSchema(value)) {
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
const cached = this.properties.get(value);
|
|
116
|
+
if (cached !== undefined) {
|
|
117
|
+
return cached;
|
|
118
|
+
}
|
|
119
|
+
let normalized = value;
|
|
120
|
+
const definition = propertyDefinition(value);
|
|
121
|
+
if (definition?.type === "select") {
|
|
122
|
+
const options = (definition.options ?? []).map((option) => ({
|
|
123
|
+
...option,
|
|
124
|
+
description: option.description ?? "",
|
|
125
|
+
value: nameToWire(option.value),
|
|
126
|
+
}));
|
|
127
|
+
for (const option of definition.options ?? []) {
|
|
128
|
+
this.name(option.value, `${path}.options`);
|
|
129
|
+
}
|
|
130
|
+
// The definition's own fields are not options of p.select.
|
|
131
|
+
const settings = { ...definition };
|
|
132
|
+
delete settings.type;
|
|
133
|
+
delete settings.options;
|
|
134
|
+
if (typeof settings.default === "string") {
|
|
135
|
+
settings.default = nameToWire(settings.default);
|
|
136
|
+
}
|
|
137
|
+
normalized = p.select(options, settings);
|
|
138
|
+
inheritUnknownOptions(value, normalized);
|
|
139
|
+
}
|
|
140
|
+
this.properties.set(value, normalized);
|
|
141
|
+
return normalized;
|
|
142
|
+
}
|
|
143
|
+
target(value) {
|
|
144
|
+
if (typeof value === "string") {
|
|
145
|
+
return nameToWire(value);
|
|
146
|
+
}
|
|
147
|
+
if (typeof value === "function") {
|
|
148
|
+
return () => this.entity(value());
|
|
149
|
+
}
|
|
150
|
+
return this.entity(value);
|
|
151
|
+
}
|
|
152
|
+
relationship(value) {
|
|
153
|
+
if (!isRelationship(value)) {
|
|
154
|
+
return value;
|
|
155
|
+
}
|
|
156
|
+
const normalized = {
|
|
157
|
+
...value,
|
|
158
|
+
inverse: nameToWire(value.inverse),
|
|
159
|
+
target: this.target(value.target),
|
|
160
|
+
};
|
|
161
|
+
if ("on" in value && value.on !== undefined) {
|
|
162
|
+
return {
|
|
163
|
+
...normalized,
|
|
164
|
+
on: Object.fromEntries(Object.entries(value.on).map(([property, target]) => [
|
|
165
|
+
nameToWire(property),
|
|
166
|
+
nameToWire(target),
|
|
167
|
+
])),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return normalized;
|
|
171
|
+
}
|
|
172
|
+
definition(entity) {
|
|
173
|
+
const declared = entity.definition;
|
|
174
|
+
const cached = this.definitions.get(declared);
|
|
175
|
+
if (cached !== undefined) {
|
|
176
|
+
return cached;
|
|
177
|
+
}
|
|
178
|
+
const problem = earlierMetricsFieldProblem(declared);
|
|
179
|
+
if (problem !== undefined) {
|
|
180
|
+
this.report("invalid-metric", `${entity.name}.metrics`, problem);
|
|
181
|
+
}
|
|
182
|
+
const original = withCurrentDefinitionNames(declared);
|
|
183
|
+
const normalized = {
|
|
184
|
+
...original,
|
|
185
|
+
title: nameToWire(original.title),
|
|
186
|
+
...(original.source?.currency === undefined
|
|
187
|
+
? {}
|
|
188
|
+
: { source: { ...original.source, currency: nameToWire(original.source.currency) } }),
|
|
189
|
+
properties: this.named(original.properties, `${entity.name}.properties`, (value, path) => this.property(value, path)),
|
|
190
|
+
relationships: this.named(original.relationships ?? {}, `${entity.name}.relationships`, (value) => this.relationship(value)),
|
|
191
|
+
...(original.indexes === undefined ? {} : { indexes: original.indexes.map(indexToWire) }),
|
|
192
|
+
...(original.metrics === undefined
|
|
193
|
+
? {}
|
|
194
|
+
: {
|
|
195
|
+
metrics: this.named(original.metrics, `${entity.name}.metrics`, (value) => expressionToWire(value, original.properties)),
|
|
196
|
+
}),
|
|
197
|
+
};
|
|
198
|
+
this.definitions.set(declared, normalized);
|
|
199
|
+
return normalized;
|
|
200
|
+
}
|
|
201
|
+
action(value, path) {
|
|
202
|
+
if (!isAction(value)) {
|
|
203
|
+
return value;
|
|
204
|
+
}
|
|
205
|
+
let input = value.input;
|
|
206
|
+
try {
|
|
207
|
+
if (Schema.isSchema(input)) {
|
|
208
|
+
input = actionInputToWire(input);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
this.report("invalid-action-input", `${path}.input`, error instanceof Error ? error.message : String(error));
|
|
213
|
+
}
|
|
214
|
+
const normalized = {
|
|
215
|
+
...value,
|
|
216
|
+
input,
|
|
217
|
+
permission: value.permission === undefined ? undefined : permissionToWire(value.permission),
|
|
218
|
+
};
|
|
219
|
+
if (typeof value.handler === "function") {
|
|
220
|
+
normalized.handler = (context) => value.handler({ ...context, principal: principalFromWire(context.principal) });
|
|
221
|
+
}
|
|
222
|
+
if (typeof value.prepare === "function") {
|
|
223
|
+
const prepare = value.prepare;
|
|
224
|
+
normalized.prepare = (context) => prepare({ ...context, principal: principalFromWire(context.principal) });
|
|
225
|
+
}
|
|
226
|
+
return normalized;
|
|
227
|
+
}
|
|
228
|
+
entity(value) {
|
|
229
|
+
if (!isEntity(value)) {
|
|
230
|
+
return value;
|
|
231
|
+
}
|
|
232
|
+
const cached = this.entities.get(value);
|
|
233
|
+
if (cached !== undefined) {
|
|
234
|
+
return cached;
|
|
235
|
+
}
|
|
236
|
+
// Register the handle before resolving relationships, which can point back to it.
|
|
237
|
+
const normalized = { ...value, name: this.name(value.name, value.name) };
|
|
238
|
+
this.entities.set(value, normalized);
|
|
239
|
+
const definition = this.definition(value);
|
|
240
|
+
Object.assign(normalized, {
|
|
241
|
+
definition,
|
|
242
|
+
properties: definition.properties,
|
|
243
|
+
relationships: definition.relationships,
|
|
244
|
+
});
|
|
245
|
+
if (isRecord(value.actions)) {
|
|
246
|
+
Object.assign(normalized, {
|
|
247
|
+
actions: this.named(value.actions, `${value.name}.actions`, (action, path) => this.action(action, path)),
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return normalized;
|
|
251
|
+
}
|
|
252
|
+
role(value) {
|
|
253
|
+
if (!isRole(value) || value === member) {
|
|
254
|
+
return value;
|
|
255
|
+
}
|
|
256
|
+
const cached = this.roles.get(value);
|
|
257
|
+
if (cached !== undefined) {
|
|
258
|
+
return cached;
|
|
259
|
+
}
|
|
260
|
+
const rebuilt = Array.isArray(value.permissions)
|
|
261
|
+
? rolePermissions(roleEntries(value.permissions, value.scopes ?? []).map((entry) => this.permission(entry)))
|
|
262
|
+
: { permissions: value.permissions, scopes: value.scopes ?? [] };
|
|
263
|
+
// The scoped entries `role()` dropped, and those only wire names make duplicates, for `check`.
|
|
264
|
+
const { unusedScopes: dropped = [], ...rest } = value;
|
|
265
|
+
const unusedScopes = [
|
|
266
|
+
...dropped.map((scope) => this.permission(scope)),
|
|
267
|
+
...(rebuilt.unusedScopes ?? []),
|
|
268
|
+
];
|
|
269
|
+
const normalized = {
|
|
270
|
+
...rest,
|
|
271
|
+
name: this.name(value.name, `roles.${value.name}`),
|
|
272
|
+
permissions: rebuilt.permissions,
|
|
273
|
+
scopes: rebuilt.scopes,
|
|
274
|
+
...(unusedScopes.length === 0 ? {} : { unusedScopes }),
|
|
275
|
+
};
|
|
276
|
+
this.roles.set(value, normalized);
|
|
277
|
+
return normalized;
|
|
278
|
+
}
|
|
279
|
+
/** A role or member permission with wire names: its permission and, when scoped, its `where`. */
|
|
280
|
+
permission(value) {
|
|
281
|
+
return typeof value === "string" || !isRecord(value)
|
|
282
|
+
? permissionToWire(value)
|
|
283
|
+
: this.scope(value);
|
|
284
|
+
}
|
|
285
|
+
scope(value) {
|
|
286
|
+
if (!isRecord(value) || typeof value.permission !== "string") {
|
|
287
|
+
return value;
|
|
288
|
+
}
|
|
289
|
+
const permission = permissionToWire(value.permission);
|
|
290
|
+
const definition = this.definitionsByName.get(permission.split(":")[0] ?? "");
|
|
291
|
+
return {
|
|
292
|
+
...value,
|
|
293
|
+
permission,
|
|
294
|
+
where: scopeWhereToWire(value.where, definition),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Canonical definitions feed REST, storage and future transports; the public config stays camelCase.
|
|
300
|
+
* The built-in entities, which every ontology includes, are normalized with the declared ones.
|
|
301
|
+
*/
|
|
302
|
+
export function authoringToWire(config, builtIns, report) {
|
|
303
|
+
const definitionsByName = new Map();
|
|
304
|
+
for (const candidate of [...builtIns, ...(config.entities ?? [])]) {
|
|
305
|
+
if (isEntity(candidate) && typeof candidate.name === "string") {
|
|
306
|
+
definitionsByName.set(nameToWire(candidate.name), candidate.definition);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const encoder = new AuthoringEncoder(report, definitionsByName);
|
|
310
|
+
const problem = earlierMetricsFieldProblem(config);
|
|
311
|
+
if (problem !== undefined) {
|
|
312
|
+
report("invalid-metric", "metrics", problem);
|
|
313
|
+
}
|
|
314
|
+
const normalized = {
|
|
315
|
+
...withCurrentDefinitionNames(config),
|
|
316
|
+
entities: (config.entities ?? []).map((entity) => encoder.entity(entity)),
|
|
317
|
+
...(config.roles === undefined
|
|
318
|
+
? {}
|
|
319
|
+
: { roles: config.roles.map((role) => encoder.role(role)) }),
|
|
320
|
+
};
|
|
321
|
+
if (isRecord(config.signIn) && typeof config.signIn.onNewUser === "string") {
|
|
322
|
+
normalized.signIn = { ...config.signIn, onNewUser: permissionToWire(config.signIn.onNewUser) };
|
|
323
|
+
}
|
|
324
|
+
if (isRecord(config.member) && Array.isArray(config.member.permissions)) {
|
|
325
|
+
normalized.member = {
|
|
326
|
+
...config.member,
|
|
327
|
+
permissions: config.member.permissions.map((permission) => encoder.permission(permission)),
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return { config: normalized, builtIns: builtIns.map((entity) => encoder.entity(entity)) };
|
|
331
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type OntologyManifest } from "../manifest.js";
|
|
2
|
+
import type { LoadResult, OntologyLoader } from "./load.js";
|
|
3
|
+
import { type ExitCode, type Output } from "./output.js";
|
|
4
|
+
/** What `check` prints on success: a summary, the manifest JSON or the catalog as prose. */
|
|
5
|
+
export type CheckFormat = "summary" | "manifest" | "catalog";
|
|
6
|
+
export interface CheckInput {
|
|
7
|
+
readonly entry: string;
|
|
8
|
+
readonly format: CheckFormat;
|
|
9
|
+
}
|
|
10
|
+
export interface CheckDependencies {
|
|
11
|
+
readonly load: OntologyLoader;
|
|
12
|
+
readonly output: Output;
|
|
13
|
+
}
|
|
14
|
+
type Loaded = Extract<LoadResult, {
|
|
15
|
+
readonly _tag: "Loaded";
|
|
16
|
+
}>;
|
|
17
|
+
/** Counts and names of what the manifest declares, the built-in `User` and `member` included. */
|
|
18
|
+
export declare function catalogSummary(manifest: OntologyManifest): string;
|
|
19
|
+
/**
|
|
20
|
+
* Loads the ontology and reports every diagnostic on stderr. Returns the loaded ontology, or
|
|
21
|
+
* undefined when it does not load or has errors.
|
|
22
|
+
*/
|
|
23
|
+
export declare function loadCheckedOntology(entry: string, dependencies: CheckDependencies): Promise<Loaded | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* `segmentstream-ontology check`: loads the ontology as the deploy pipeline does, reports what
|
|
26
|
+
* `check` found and prints the catalog summary, the manifest or the catalog prose. Diagnostics go to
|
|
27
|
+
* stderr; any error fails the command.
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkCommand(input: CheckInput, dependencies: CheckDependencies): Promise<ExitCode>;
|
|
30
|
+
export {};
|