@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,3 @@
|
|
|
1
|
+
import type { SqlClient } from "effect/unstable/sql";
|
|
2
|
+
/** Revocation joins the caller's identity/member transaction, including pairing displacement. */
|
|
3
|
+
export declare function revokeChannelSessions(sql: SqlClient.SqlClient, identityId: string): import("effect/unstable/sql/Statement").Statement<object>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Revocation joins the caller's identity/member transaction, including pairing displacement. */
|
|
2
|
+
export function revokeChannelSessions(sql, identityId) {
|
|
3
|
+
return sql.unsafe(`UPDATE "_oauth_grants" SET "revoked_at" = now()
|
|
4
|
+
WHERE "identity_id" = $1::uuid AND "revoked_at" IS NULL`, [identityId]);
|
|
5
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SqlClient } from "effect/unstable/sql";
|
|
2
|
+
import type { Ontology } from "../ontology.js";
|
|
3
|
+
import type { ChannelSessionStore } from "../service/runtime-contract.js";
|
|
4
|
+
export declare function sqlChannelSessionStore(ontology: Ontology, sql: SqlClient.SqlClient): ChannelSessionStore;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { channelClientId, CHANNEL_SESSION_TTL_SECONDS } from "../channel-session.js";
|
|
4
|
+
import { ACCESS_TOKEN_PREFIX, FULL_SCOPE, newSecret, secretHash, } from "../service/oauth/protocol.js";
|
|
5
|
+
import { revokeChannelSessions } from "./channel-session-revocation.js";
|
|
6
|
+
import { resolveChannelSignIn } from "./agents.js";
|
|
7
|
+
import { isMemberBlocked } from "./principals.js";
|
|
8
|
+
import { sqlOAuthStore } from "./oauth.js";
|
|
9
|
+
import { CHANNEL_IDENTITIES_FROM, LIVE_CHANNEL_IDENTITY } from "./user-identity-sql.js";
|
|
10
|
+
export function sqlChannelSessionStore(ontology, sql) {
|
|
11
|
+
const oauth = sqlOAuthStore(ontology, sql);
|
|
12
|
+
return {
|
|
13
|
+
create: (input) => Effect.gen(function* () {
|
|
14
|
+
// A1 commits admission before running onboarding. Never place this inside the issuer transaction.
|
|
15
|
+
const resolution = yield* resolveChannelSignIn(ontology, sql, input);
|
|
16
|
+
if (resolution.status !== "existing" && resolution.status !== "created") {
|
|
17
|
+
return resolution;
|
|
18
|
+
}
|
|
19
|
+
const userId = resolution.member.principal.id;
|
|
20
|
+
return yield* sql
|
|
21
|
+
.withTransaction(Effect.gen(function* () {
|
|
22
|
+
// Same lock order as A1 lifecycle operations: User, then identity. Prevent resurrection.
|
|
23
|
+
const [member] = yield* sql.unsafe(`SELECT "kind"::text AS "kind", "active" FROM "user" WHERE "id" = $1::uuid FOR SHARE`, [userId]);
|
|
24
|
+
if (member?.kind !== "member" || !member.active) {
|
|
25
|
+
return { status: "refused", reason: "inactive" };
|
|
26
|
+
}
|
|
27
|
+
if (yield* isMemberBlocked(sql, userId)) {
|
|
28
|
+
return { status: "refused", reason: "blocked" };
|
|
29
|
+
}
|
|
30
|
+
// Revocation locks the identity too, so a revoked account never gains a session.
|
|
31
|
+
const [identity] = yield* sql.unsafe(`SELECT "i"."id"::text AS "id", "i"."user_id"::text AS "user_id"
|
|
32
|
+
FROM ${CHANNEL_IDENTITIES_FROM}
|
|
33
|
+
WHERE "i"."provider" = $1 AND "i"."subject" = $2 AND ${LIVE_CHANNEL_IDENTITY}
|
|
34
|
+
FOR UPDATE OF "i"`, [input.provider, input.externalId]);
|
|
35
|
+
if (!identity || identity.user_id !== userId) {
|
|
36
|
+
return { status: "pairing_required" };
|
|
37
|
+
}
|
|
38
|
+
const clientId = channelClientId(input.provider);
|
|
39
|
+
yield* sql.unsafe(`INSERT INTO "_oauth_clients" ("id", "name", "redirect_uris", "auth_method")
|
|
40
|
+
VALUES ($1, $1, '[]'::jsonb, 'none') ON CONFLICT ("id") DO NOTHING`, [clientId]);
|
|
41
|
+
yield* revokeChannelSessions(sql, identity.id);
|
|
42
|
+
const grantId = randomUUID();
|
|
43
|
+
const token = newSecret(ACCESS_TOKEN_PREFIX);
|
|
44
|
+
const expiresAt = new Date(Date.now() + CHANNEL_SESSION_TTL_SECONDS * 1000);
|
|
45
|
+
yield* oauth.saveGrant({
|
|
46
|
+
id: grantId,
|
|
47
|
+
clientId,
|
|
48
|
+
userId,
|
|
49
|
+
scope: FULL_SCOPE,
|
|
50
|
+
resource: input.resource,
|
|
51
|
+
});
|
|
52
|
+
yield* sql.unsafe(`UPDATE "_oauth_grants" SET "identity_id" = $2::uuid WHERE "id" = $1::uuid`, [grantId, identity.id]);
|
|
53
|
+
yield* oauth.saveTokens([
|
|
54
|
+
{ hash: secretHash(token), grantId, kind: "access", expiresAt },
|
|
55
|
+
]);
|
|
56
|
+
return { status: "signed_in", token, expiresAt };
|
|
57
|
+
}))
|
|
58
|
+
.pipe(Effect.orDie);
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { SqlClient } from "effect/unstable/sql";
|
|
3
|
+
/** Private runtime data. Never exposed as an ontology entity or a model tool. */
|
|
4
|
+
export interface DeferredConfirmation {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly key: string;
|
|
7
|
+
readonly memberId: string;
|
|
8
|
+
readonly inputHash: string;
|
|
9
|
+
readonly expiresAt: number;
|
|
10
|
+
readonly status: "pending" | "approved" | "cancelled" | "expired" | "done" | "failed";
|
|
11
|
+
readonly data: Readonly<Record<string, unknown>>;
|
|
12
|
+
}
|
|
13
|
+
export interface ConfirmationStore {
|
|
14
|
+
readonly create: (record: DeferredConfirmation) => Effect.Effect<DeferredConfirmation | undefined>;
|
|
15
|
+
readonly read: (key: string) => Effect.Effect<DeferredConfirmation | undefined>;
|
|
16
|
+
/** Commits before external execution. A lost worker never causes automatic execution again. */
|
|
17
|
+
readonly decide: (input: {
|
|
18
|
+
readonly key: string;
|
|
19
|
+
readonly memberId: string;
|
|
20
|
+
readonly inputHash: string;
|
|
21
|
+
readonly decision: "approve" | "cancel" | "expire";
|
|
22
|
+
}) => Effect.Effect<DeferredConfirmation | undefined>;
|
|
23
|
+
readonly attach: (key: string, messageId: string, address: string) => Effect.Effect<void>;
|
|
24
|
+
readonly finish: (key: string, status: "done" | "failed") => Effect.Effect<void>;
|
|
25
|
+
readonly expired: (chatId?: string) => Effect.Effect<ReadonlyArray<DeferredConfirmation>>;
|
|
26
|
+
}
|
|
27
|
+
export declare const CONFIRMATION_TABLE = "_agent_confirmations";
|
|
28
|
+
export declare const CONFIRMATION_DDL: string[];
|
|
29
|
+
export declare function sqlConfirmationStore(sql: SqlClient.SqlClient): ConfirmationStore;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
// @legacy agent.retired-confirmation-ledger
|
|
3
|
+
export const CONFIRMATION_TABLE = "_agent_confirmations";
|
|
4
|
+
export const CONFIRMATION_DDL = [
|
|
5
|
+
`CREATE TABLE IF NOT EXISTS "${CONFIRMATION_TABLE}" (
|
|
6
|
+
id text PRIMARY KEY, key text NOT NULL UNIQUE,
|
|
7
|
+
member_id uuid NOT NULL REFERENCES "user" (id) ON DELETE CASCADE,
|
|
8
|
+
input_hash text NOT NULL, expires_at timestamptz NOT NULL,
|
|
9
|
+
status text NOT NULL CHECK (status IN ('pending','approved','cancelled','expired','done','failed')),
|
|
10
|
+
data jsonb NOT NULL
|
|
11
|
+
)`,
|
|
12
|
+
`CREATE INDEX IF NOT EXISTS "_agent_confirmations_expiry" ON "${CONFIRMATION_TABLE}" (expires_at)
|
|
13
|
+
WHERE status = 'pending'`,
|
|
14
|
+
];
|
|
15
|
+
export function sqlConfirmationStore(sql) {
|
|
16
|
+
const query = (statement, values = []) => sql.unsafe(statement, values).pipe(Effect.orDie);
|
|
17
|
+
const columns = `id, key, member_id::text AS "memberId", input_hash AS "inputHash",
|
|
18
|
+
(extract(epoch from expires_at) * 1000)::double precision AS "expiresAt", status, data`;
|
|
19
|
+
const read = (key) => query(`SELECT ${columns} FROM "${CONFIRMATION_TABLE}" WHERE key = $1`, [key]).pipe(Effect.map((rows) => rows[0]));
|
|
20
|
+
return {
|
|
21
|
+
read,
|
|
22
|
+
create: (record) => Effect.gen(function* () {
|
|
23
|
+
yield* query(`INSERT INTO "${CONFIRMATION_TABLE}"
|
|
24
|
+
(id, key, member_id, input_hash, expires_at, status, data)
|
|
25
|
+
VALUES ($1, $2, $3::uuid, $4, to_timestamp($5::double precision / 1000), 'pending', $6::jsonb)
|
|
26
|
+
ON CONFLICT DO NOTHING`, [
|
|
27
|
+
record.id,
|
|
28
|
+
record.key,
|
|
29
|
+
record.memberId,
|
|
30
|
+
record.inputHash,
|
|
31
|
+
record.expiresAt,
|
|
32
|
+
JSON.stringify(record.data),
|
|
33
|
+
]);
|
|
34
|
+
const saved = yield* read(record.key);
|
|
35
|
+
return saved?.id === record.id &&
|
|
36
|
+
saved.memberId === record.memberId &&
|
|
37
|
+
saved.inputHash === record.inputHash &&
|
|
38
|
+
["action", "requester", "chatId", "threadId", "sessionId", "callId"].every((field) => saved.data[field] === record.data[field])
|
|
39
|
+
? saved
|
|
40
|
+
: undefined;
|
|
41
|
+
}),
|
|
42
|
+
decide: (input) => query(`UPDATE "${CONFIRMATION_TABLE}" SET status =
|
|
43
|
+
CASE WHEN expires_at <= now() THEN 'expired'
|
|
44
|
+
WHEN $4 = 'approve' THEN 'approved' ELSE 'cancelled' END
|
|
45
|
+
WHERE key = $1 AND member_id = $2::uuid AND input_hash = $3 AND status = 'pending'
|
|
46
|
+
AND ($4 <> 'expire' OR expires_at <= now())
|
|
47
|
+
RETURNING ${columns}`, [input.key, input.memberId, input.inputHash, input.decision]).pipe(Effect.map((rows) => rows[0])),
|
|
48
|
+
attach: (key, messageId, address) => query(`UPDATE "${CONFIRMATION_TABLE}"
|
|
49
|
+
SET data = data || jsonb_build_object('messageId', $2::text, 'address', $3::text)
|
|
50
|
+
WHERE key = $1 AND status = 'pending' AND NOT (data ? 'messageId')`, [key, messageId, address]).pipe(Effect.asVoid),
|
|
51
|
+
finish: (key, status) => query(`UPDATE "${CONFIRMATION_TABLE}" SET status = $2
|
|
52
|
+
WHERE key = $1 AND status = 'approved'`, [key, status]).pipe(Effect.asVoid),
|
|
53
|
+
expired: (chatId) => query(`SELECT ${columns} FROM "${CONFIRMATION_TABLE}"
|
|
54
|
+
WHERE status = 'pending' AND expires_at <= now() AND ($1::text IS NULL OR data->>'chatId' = $1)
|
|
55
|
+
ORDER BY expires_at LIMIT 100`, [chatId ?? null]),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type OrderBy, type SortDirection } from "../query.js";
|
|
2
|
+
import type { StoredRecord } from "../runtime.js";
|
|
3
|
+
import type { EntityModel, FieldModel } from "./model.js";
|
|
4
|
+
import { type Params } from "./statement.js";
|
|
5
|
+
/**
|
|
6
|
+
* Keyset pagination. A cursor carries the sort values of the last record of a page and the order
|
|
7
|
+
* they belong to; the next page starts strictly after them. Ascending keys put empty values last,
|
|
8
|
+
* descending keys first, as PostgreSQL does by default; the id always breaks ties.
|
|
9
|
+
*/
|
|
10
|
+
export interface SortKey {
|
|
11
|
+
readonly field: FieldModel;
|
|
12
|
+
readonly direction: SortDirection;
|
|
13
|
+
}
|
|
14
|
+
export declare function sortKeys(entity: EntityModel, orderBy: ReadonlyArray<OrderBy> | undefined): SortKey[];
|
|
15
|
+
export declare function orderByClause(keys: ReadonlyArray<SortKey>, alias: string): string;
|
|
16
|
+
export declare function encodeCursor(keys: ReadonlyArray<SortKey>, record: StoredRecord): string;
|
|
17
|
+
/** The sort values in a cursor, or `undefined` when it was not issued for this order. */
|
|
18
|
+
export declare function decodeCursor(keys: ReadonlyArray<SortKey>, cursor: string): ReadonlyArray<unknown> | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Rows after the cursor: for some key, every earlier key equals the cursor's value and this one
|
|
21
|
+
* comes after it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function afterCondition(keys: ReadonlyArray<SortKey>, values: ReadonlyArray<unknown>, alias: string, params: Params): string;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { fieldValueSchema } from "../query.js";
|
|
3
|
+
import { bindValue } from "./records.js";
|
|
4
|
+
import { columnOf } from "./statement.js";
|
|
5
|
+
/** The default order: newest first. */
|
|
6
|
+
const DEFAULT_ORDER = [{ field: "created_at", direction: "desc" }];
|
|
7
|
+
export function sortKeys(entity, orderBy) {
|
|
8
|
+
const requested = orderBy === undefined || orderBy.length === 0 ? DEFAULT_ORDER : orderBy;
|
|
9
|
+
const keys = [];
|
|
10
|
+
for (const entry of requested) {
|
|
11
|
+
const field = entity.fieldsByName.get(entry.field);
|
|
12
|
+
if (field === undefined) {
|
|
13
|
+
throw new Error(`${entity.name}.${entry.field} is not a field.`);
|
|
14
|
+
}
|
|
15
|
+
if (!keys.some((key) => key.field === field)) {
|
|
16
|
+
keys.push({ field, direction: entry.direction ?? "asc" });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (!keys.some((key) => key.field.name === "id")) {
|
|
20
|
+
keys.push({ field: entity.fieldsByName.get("id"), direction: "asc" });
|
|
21
|
+
}
|
|
22
|
+
return keys;
|
|
23
|
+
}
|
|
24
|
+
export function orderByClause(keys, alias) {
|
|
25
|
+
return keys
|
|
26
|
+
.map(({ field, direction }) => direction === "asc"
|
|
27
|
+
? `${columnOf(alias, field.column)} ASC NULLS LAST`
|
|
28
|
+
: `${columnOf(alias, field.column)} DESC NULLS FIRST`)
|
|
29
|
+
.join(", ");
|
|
30
|
+
}
|
|
31
|
+
function signature(keys) {
|
|
32
|
+
return keys.map(({ field, direction }) => `${field.name}:${direction}`).join(",");
|
|
33
|
+
}
|
|
34
|
+
const CursorBody = Schema.Struct({
|
|
35
|
+
order: Schema.String,
|
|
36
|
+
values: Schema.Array(Schema.Json),
|
|
37
|
+
});
|
|
38
|
+
export function encodeCursor(keys, record) {
|
|
39
|
+
const body = {
|
|
40
|
+
order: signature(keys),
|
|
41
|
+
values: keys.map(({ field }) => record[field.name] ?? null),
|
|
42
|
+
};
|
|
43
|
+
return Buffer.from(JSON.stringify(body), "utf8").toString("base64url");
|
|
44
|
+
}
|
|
45
|
+
/** The sort values in a cursor, or `undefined` when it was not issued for this order. */
|
|
46
|
+
export function decodeCursor(keys, cursor) {
|
|
47
|
+
let parsed;
|
|
48
|
+
try {
|
|
49
|
+
parsed = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if (!Schema.is(CursorBody)(parsed) || parsed.order !== signature(keys)) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
if (parsed.values.length !== keys.length) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const valid = keys.every(({ field }, index) => {
|
|
61
|
+
const value = parsed.values[index];
|
|
62
|
+
return value === null ? field.nullable : Schema.is(fieldValueSchema(field))(value);
|
|
63
|
+
});
|
|
64
|
+
return valid ? parsed.values : undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Rows after the cursor: for some key, every earlier key equals the cursor's value and this one
|
|
68
|
+
* comes after it.
|
|
69
|
+
*/
|
|
70
|
+
export function afterCondition(keys, values, alias, params) {
|
|
71
|
+
const branches = keys.map((key, index) => {
|
|
72
|
+
const equal = keys
|
|
73
|
+
.slice(0, index)
|
|
74
|
+
.map((earlier, position) => equalTo(earlier, values[position], alias, params));
|
|
75
|
+
return [...equal, after(key, values[index], alias, params)].join(" AND ");
|
|
76
|
+
});
|
|
77
|
+
return branches.map((branch) => `(${branch})`).join(" OR ");
|
|
78
|
+
}
|
|
79
|
+
function equalTo(key, value, alias, params) {
|
|
80
|
+
const column = columnOf(alias, key.field.column);
|
|
81
|
+
return value === null
|
|
82
|
+
? `${column} IS NULL`
|
|
83
|
+
: `${column} = ${params.add(bindValue(key.field, value), key.field.sqlType)}`;
|
|
84
|
+
}
|
|
85
|
+
function after(key, value, alias, params) {
|
|
86
|
+
const column = columnOf(alias, key.field.column);
|
|
87
|
+
if (key.direction === "asc") {
|
|
88
|
+
if (value === null) {
|
|
89
|
+
return "FALSE";
|
|
90
|
+
}
|
|
91
|
+
const bound = params.add(bindValue(key.field, value), key.field.sqlType);
|
|
92
|
+
return key.field.nullable
|
|
93
|
+
? `(${column} > ${bound} OR ${column} IS NULL)`
|
|
94
|
+
: `${column} > ${bound}`;
|
|
95
|
+
}
|
|
96
|
+
if (value === null) {
|
|
97
|
+
return `${column} IS NOT NULL`;
|
|
98
|
+
}
|
|
99
|
+
return `${column} < ${params.add(bindValue(key.field, value), key.field.sqlType)}`;
|
|
100
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Context } from "effect";
|
|
2
|
+
import type { DeploymentObservation } from "../deployment.js";
|
|
3
|
+
declare const RuntimeDeployment_base: Context.ServiceClass<RuntimeDeployment, "@segmentstream/ontology/RuntimeDeployment", DeploymentObservation>;
|
|
4
|
+
/** In-process admission; never selected from an HTTP header or action input. */
|
|
5
|
+
export declare class RuntimeDeployment extends RuntimeDeployment_base {
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Where a value failed validation, and why. Paths are keys and indexes from the input's root. */
|
|
3
|
+
export declare const ValidationIssue: Schema.Struct<{
|
|
4
|
+
readonly path: Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>;
|
|
5
|
+
readonly message: Schema.String;
|
|
6
|
+
}>;
|
|
7
|
+
export type ValidationIssue = typeof ValidationIssue.Type;
|
|
8
|
+
declare const InvalidQuery_base: Schema.Class<InvalidQuery, Schema.TaggedStruct<"InvalidQuery", {
|
|
9
|
+
readonly entity: Schema.String;
|
|
10
|
+
readonly message: Schema.String;
|
|
11
|
+
readonly issues: Schema.$Array<Schema.Struct<{
|
|
12
|
+
readonly path: Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>;
|
|
13
|
+
readonly message: Schema.String;
|
|
14
|
+
}>>;
|
|
15
|
+
}>, import("effect/Cause").YieldableError>;
|
|
16
|
+
/** A query does not fit the entity: an unknown field, an operator its type lacks, a stale cursor. */
|
|
17
|
+
export declare class InvalidQuery extends InvalidQuery_base {
|
|
18
|
+
}
|
|
19
|
+
declare const UnknownAction_base: Schema.Class<UnknownAction, Schema.TaggedStruct<"UnknownAction", {
|
|
20
|
+
readonly entity: Schema.String;
|
|
21
|
+
readonly action: Schema.String;
|
|
22
|
+
readonly message: Schema.String;
|
|
23
|
+
}>, import("effect/Cause").YieldableError>;
|
|
24
|
+
/** The entity has no action with this name, authored or generated. */
|
|
25
|
+
export declare class UnknownAction extends UnknownAction_base {
|
|
26
|
+
}
|
|
27
|
+
export declare const PRINCIPAL_REJECTIONS: readonly ["unknown_api_key", "revoked_api_key", "inactive_user", "identity_conflict", "not_invited", "unknown_workflow", "role_mismatch"];
|
|
28
|
+
declare const UndeclaredWrite_base: Schema.Class<UndeclaredWrite, Schema.TaggedStruct<"UndeclaredWrite", {
|
|
29
|
+
readonly entity: Schema.String;
|
|
30
|
+
readonly action: Schema.String;
|
|
31
|
+
readonly message: Schema.String;
|
|
32
|
+
}>, import("effect/Cause").YieldableError>;
|
|
33
|
+
/**
|
|
34
|
+
* A handler wrote an entity its action's `writes` does not list: a defect in the workspace's code,
|
|
35
|
+
* found by its tests or its first run, never a caller's mistake.
|
|
36
|
+
*/
|
|
37
|
+
export declare class UndeclaredWrite extends UndeclaredWrite_base {
|
|
38
|
+
}
|
|
39
|
+
declare const PrincipalRejected_base: Schema.Class<PrincipalRejected, Schema.TaggedStruct<"PrincipalRejected", {
|
|
40
|
+
readonly reason: Schema.Literals<readonly ["unknown_api_key", "revoked_api_key", "inactive_user", "identity_conflict", "not_invited", "unknown_workflow", "role_mismatch"]>;
|
|
41
|
+
readonly message: Schema.String;
|
|
42
|
+
/** Operator-only API-key failure stage. Never included in the public 401. */
|
|
43
|
+
readonly diagnostic: Schema.optionalKey<Schema.Literals<readonly ["malformed_api_key", "missing_api_key", "invalid_api_key_record", "api_key_secret_mismatch"]>>;
|
|
44
|
+
}>, import("effect/Cause").YieldableError>;
|
|
45
|
+
/**
|
|
46
|
+
* A credential does not resolve to an active principal. `reason` is for operator logs; callers see
|
|
47
|
+
* an authentication failure without it, except `not_invited`: a person the `invited` sign-in policy
|
|
48
|
+
* turns away is told to ask for an invitation.
|
|
49
|
+
*/
|
|
50
|
+
export declare class PrincipalRejected extends PrincipalRejected_base {
|
|
51
|
+
}
|
|
52
|
+
declare const UnknownRole_base: Schema.Class<UnknownRole, Schema.TaggedStruct<"UnknownRole", {
|
|
53
|
+
readonly role: Schema.String;
|
|
54
|
+
readonly message: Schema.String;
|
|
55
|
+
}>, import("effect/Cause").YieldableError>;
|
|
56
|
+
/** Roles given to users are roles of the ontology, `member` included. */
|
|
57
|
+
export declare class UnknownRole extends UnknownRole_base {
|
|
58
|
+
}
|
|
59
|
+
declare const MemberNotFound_base: Schema.Class<MemberNotFound, Schema.TaggedStruct<"MemberNotFound", {
|
|
60
|
+
readonly message: Schema.String;
|
|
61
|
+
}>, import("effect/Cause").YieldableError>;
|
|
62
|
+
/** No member has this email or id. Services are not members: their API keys are managed instead. */
|
|
63
|
+
export declare class MemberNotFound extends MemberNotFound_base {
|
|
64
|
+
}
|
|
65
|
+
declare const InvalidValues_base: Schema.Class<InvalidValues, Schema.TaggedStruct<"InvalidValues", {
|
|
66
|
+
readonly entity: Schema.String;
|
|
67
|
+
readonly message: Schema.String;
|
|
68
|
+
readonly issues: Schema.$Array<Schema.Struct<{
|
|
69
|
+
readonly path: Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>;
|
|
70
|
+
readonly message: Schema.String;
|
|
71
|
+
}>>;
|
|
72
|
+
}>, import("effect/Cause").YieldableError>;
|
|
73
|
+
/**
|
|
74
|
+
* A handler wrote values that do not fit the entity: an unknown field, a missing required property,
|
|
75
|
+
* a value its property rejects. It is a defect in the handler, raised as one, never a typed failure.
|
|
76
|
+
*/
|
|
77
|
+
export declare class InvalidValues extends InvalidValues_base {
|
|
78
|
+
}
|
|
79
|
+
declare const StoredRecordMismatch_base: Schema.Class<StoredRecordMismatch, Schema.TaggedStruct<"StoredRecordMismatch", {
|
|
80
|
+
readonly entity: Schema.String;
|
|
81
|
+
readonly message: Schema.String;
|
|
82
|
+
}>, import("effect/Cause").YieldableError>;
|
|
83
|
+
/** A stored record does not match its entity's definition. A defect: the schema and data diverged. */
|
|
84
|
+
export declare class StoredRecordMismatch extends StoredRecordMismatch_base {
|
|
85
|
+
}
|
|
86
|
+
declare const WriteOutsideAction_base: Schema.Class<WriteOutsideAction, Schema.TaggedStruct<"WriteOutsideAction", {
|
|
87
|
+
readonly entity: Schema.String;
|
|
88
|
+
readonly message: Schema.String;
|
|
89
|
+
}>, import("effect/Cause").YieldableError>;
|
|
90
|
+
/** Writes run inside an action, which names the change for history. */
|
|
91
|
+
export declare class WriteOutsideAction extends WriteOutsideAction_base {
|
|
92
|
+
}
|
|
93
|
+
declare const WorkflowRecoveryUnavailable_base: Schema.Class<WorkflowRecoveryUnavailable, Schema.TaggedStruct<"WorkflowRecoveryUnavailable", {
|
|
94
|
+
readonly message: Schema.String;
|
|
95
|
+
readonly cause: Schema.optionalKey<Schema.Unknown>;
|
|
96
|
+
}>, import("effect/Cause").YieldableError>;
|
|
97
|
+
/**
|
|
98
|
+
* The recovery run that guarantees an action's trigger starts could not be armed, so the action
|
|
99
|
+
* was refused before its transaction opened. Retrying the action is safe.
|
|
100
|
+
*/
|
|
101
|
+
export declare class WorkflowRecoveryUnavailable extends WorkflowRecoveryUnavailable_base {
|
|
102
|
+
}
|
|
103
|
+
declare const TriggerInputInvalid_base: Schema.Class<TriggerInputInvalid, Schema.TaggedStruct<"TriggerInputInvalid", {
|
|
104
|
+
/** `<workflow>.<trigger>`, in wire names. */
|
|
105
|
+
readonly trigger: Schema.String;
|
|
106
|
+
readonly message: Schema.String;
|
|
107
|
+
readonly issues: Schema.$Array<Schema.Struct<{
|
|
108
|
+
readonly path: Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>;
|
|
109
|
+
readonly message: Schema.String;
|
|
110
|
+
}>>;
|
|
111
|
+
}>, import("effect/Cause").YieldableError>;
|
|
112
|
+
/**
|
|
113
|
+
* An action trigger's `input` mapping returned a value its workflow's input does not accept. The
|
|
114
|
+
* action fails before commit, so a broken trigger shows on the first action that would fire it.
|
|
115
|
+
*/
|
|
116
|
+
export declare class TriggerInputInvalid extends TriggerInputInvalid_base {
|
|
117
|
+
}
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/** Where a value failed validation, and why. Paths are keys and indexes from the input's root. */
|
|
3
|
+
export const ValidationIssue = Schema.Struct({
|
|
4
|
+
path: Schema.Array(Schema.Union([Schema.String, Schema.Number])),
|
|
5
|
+
message: Schema.String,
|
|
6
|
+
});
|
|
7
|
+
/** A query does not fit the entity: an unknown field, an operator its type lacks, a stale cursor. */
|
|
8
|
+
export class InvalidQuery extends Schema.TaggedError()("InvalidQuery", {
|
|
9
|
+
entity: Schema.String,
|
|
10
|
+
message: Schema.String,
|
|
11
|
+
issues: Schema.Array(ValidationIssue),
|
|
12
|
+
}) {
|
|
13
|
+
}
|
|
14
|
+
/** The entity has no action with this name, authored or generated. */
|
|
15
|
+
export class UnknownAction extends Schema.TaggedError()("UnknownAction", {
|
|
16
|
+
entity: Schema.String,
|
|
17
|
+
action: Schema.String,
|
|
18
|
+
message: Schema.String,
|
|
19
|
+
}) {
|
|
20
|
+
}
|
|
21
|
+
export const PRINCIPAL_REJECTIONS = [
|
|
22
|
+
"unknown_api_key",
|
|
23
|
+
"revoked_api_key",
|
|
24
|
+
"inactive_user",
|
|
25
|
+
"identity_conflict",
|
|
26
|
+
"not_invited",
|
|
27
|
+
"unknown_workflow",
|
|
28
|
+
"role_mismatch",
|
|
29
|
+
];
|
|
30
|
+
/**
|
|
31
|
+
* A handler wrote an entity its action's `writes` does not list: a defect in the workspace's code,
|
|
32
|
+
* found by its tests or its first run, never a caller's mistake.
|
|
33
|
+
*/
|
|
34
|
+
export class UndeclaredWrite extends Schema.TaggedError()("UndeclaredWrite", {
|
|
35
|
+
entity: Schema.String,
|
|
36
|
+
action: Schema.String,
|
|
37
|
+
message: Schema.String,
|
|
38
|
+
}) {
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A credential does not resolve to an active principal. `reason` is for operator logs; callers see
|
|
42
|
+
* an authentication failure without it, except `not_invited`: a person the `invited` sign-in policy
|
|
43
|
+
* turns away is told to ask for an invitation.
|
|
44
|
+
*/
|
|
45
|
+
export class PrincipalRejected extends Schema.TaggedError()("PrincipalRejected", {
|
|
46
|
+
reason: Schema.Literals(PRINCIPAL_REJECTIONS),
|
|
47
|
+
message: Schema.String,
|
|
48
|
+
/** Operator-only API-key failure stage. Never included in the public 401. */
|
|
49
|
+
diagnostic: Schema.optionalKey(Schema.Literals([
|
|
50
|
+
"malformed_api_key",
|
|
51
|
+
"missing_api_key",
|
|
52
|
+
"invalid_api_key_record",
|
|
53
|
+
"api_key_secret_mismatch",
|
|
54
|
+
])),
|
|
55
|
+
}) {
|
|
56
|
+
}
|
|
57
|
+
/** Roles given to users are roles of the ontology, `member` included. */
|
|
58
|
+
export class UnknownRole extends Schema.TaggedError()("UnknownRole", {
|
|
59
|
+
role: Schema.String,
|
|
60
|
+
message: Schema.String,
|
|
61
|
+
}) {
|
|
62
|
+
}
|
|
63
|
+
/** No member has this email or id. Services are not members: their API keys are managed instead. */
|
|
64
|
+
export class MemberNotFound extends Schema.TaggedError()("MemberNotFound", {
|
|
65
|
+
message: Schema.String,
|
|
66
|
+
}) {
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A handler wrote values that do not fit the entity: an unknown field, a missing required property,
|
|
70
|
+
* a value its property rejects. It is a defect in the handler, raised as one, never a typed failure.
|
|
71
|
+
*/
|
|
72
|
+
export class InvalidValues extends Schema.TaggedError()("InvalidValues", {
|
|
73
|
+
entity: Schema.String,
|
|
74
|
+
message: Schema.String,
|
|
75
|
+
issues: Schema.Array(ValidationIssue),
|
|
76
|
+
}) {
|
|
77
|
+
}
|
|
78
|
+
/** A stored record does not match its entity's definition. A defect: the schema and data diverged. */
|
|
79
|
+
export class StoredRecordMismatch extends Schema.TaggedError()("StoredRecordMismatch", {
|
|
80
|
+
entity: Schema.String,
|
|
81
|
+
message: Schema.String,
|
|
82
|
+
}) {
|
|
83
|
+
}
|
|
84
|
+
/** Writes run inside an action, which names the change for history. */
|
|
85
|
+
export class WriteOutsideAction extends Schema.TaggedError()("WriteOutsideAction", {
|
|
86
|
+
entity: Schema.String,
|
|
87
|
+
message: Schema.String,
|
|
88
|
+
}) {
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The recovery run that guarantees an action's trigger starts could not be armed, so the action
|
|
92
|
+
* was refused before its transaction opened. Retrying the action is safe.
|
|
93
|
+
*/
|
|
94
|
+
export class WorkflowRecoveryUnavailable extends Schema.TaggedError()("WorkflowRecoveryUnavailable", {
|
|
95
|
+
message: Schema.String,
|
|
96
|
+
cause: Schema.optionalKey(Schema.Unknown),
|
|
97
|
+
}) {
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* An action trigger's `input` mapping returned a value its workflow's input does not accept. The
|
|
101
|
+
* action fails before commit, so a broken trigger shows on the first action that would fire it.
|
|
102
|
+
*/
|
|
103
|
+
export class TriggerInputInvalid extends Schema.TaggedError()("TriggerInputInvalid", {
|
|
104
|
+
/** `<workflow>.<trigger>`, in wire names. */
|
|
105
|
+
trigger: Schema.String,
|
|
106
|
+
message: Schema.String,
|
|
107
|
+
issues: Schema.Array(ValidationIssue),
|
|
108
|
+
}) {
|
|
109
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const FEDERATION_TABLES = ["_user_identities", "_federation_sessions"];
|
|
2
|
+
export const FEDERATION_TABLES_DDL = [
|
|
3
|
+
`CREATE TABLE IF NOT EXISTS "_user_identities" (
|
|
4
|
+
issuer text NOT NULL, subject text NOT NULL, user_id uuid NOT NULL REFERENCES "user"(id) ON DELETE CASCADE,
|
|
5
|
+
PRIMARY KEY (issuer, subject)
|
|
6
|
+
)`,
|
|
7
|
+
`CREATE INDEX IF NOT EXISTS "_user_identities_user" ON "_user_identities" (user_id)`,
|
|
8
|
+
`CREATE TABLE IF NOT EXISTS "_federation_sessions" (
|
|
9
|
+
hash text PRIMARY KEY, user_id uuid REFERENCES "user"(id) ON DELETE CASCADE,
|
|
10
|
+
issuer text NOT NULL, subject text NOT NULL, client_id text NOT NULL,
|
|
11
|
+
generation integer NOT NULL, consent_id text NOT NULL, expires_at bigint NOT NULL
|
|
12
|
+
)`,
|
|
13
|
+
`ALTER TABLE "_federation_sessions" ADD COLUMN IF NOT EXISTS session_id text`,
|
|
14
|
+
`ALTER TABLE "_federation_sessions" ADD COLUMN IF NOT EXISTS environment text`,
|
|
15
|
+
`ALTER TABLE "_federation_sessions" ADD COLUMN IF NOT EXISTS deployment_id text`,
|
|
16
|
+
`ALTER TABLE "_federation_sessions" ADD COLUMN IF NOT EXISTS manifest_digest text`,
|
|
17
|
+
`ALTER TABLE "_federation_sessions" ADD COLUMN IF NOT EXISTS link_user_id uuid
|
|
18
|
+
REFERENCES "user"(id) ON DELETE CASCADE`,
|
|
19
|
+
`CREATE INDEX IF NOT EXISTS "_federation_sessions_expiry" ON "_federation_sessions" (expires_at)`,
|
|
20
|
+
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/unstable/sql";
|
|
3
|
+
import type { Ontology } from "../ontology.js";
|
|
4
|
+
import type { Principal } from "../runtime.js";
|
|
5
|
+
export declare const FEDERATION_TOKEN_PREFIX = "ssfs_";
|
|
6
|
+
export declare const federationDigest: (value: string) => string;
|
|
7
|
+
export declare const FederationSession: Schema.Struct<{
|
|
8
|
+
readonly hash: Schema.String;
|
|
9
|
+
readonly userId: Schema.NullOr<Schema.String>;
|
|
10
|
+
readonly linkUserId: Schema.optionalKey<Schema.String>;
|
|
11
|
+
readonly issuer: Schema.String;
|
|
12
|
+
readonly subject: Schema.String;
|
|
13
|
+
readonly clientId: Schema.String;
|
|
14
|
+
readonly generation: Schema.Int;
|
|
15
|
+
readonly consentId: Schema.String;
|
|
16
|
+
readonly sessionId: Schema.optionalKey<Schema.String>;
|
|
17
|
+
readonly environment: Schema.optionalKey<Schema.String>;
|
|
18
|
+
readonly deploymentId: Schema.optionalKey<Schema.String>;
|
|
19
|
+
readonly manifestDigest: Schema.optionalKey<Schema.String>;
|
|
20
|
+
readonly expiresAt: Schema.Number;
|
|
21
|
+
}>;
|
|
22
|
+
export type FederationSession = typeof FederationSession.Type;
|
|
23
|
+
export interface FederationStore {
|
|
24
|
+
readonly identity: (issuer: string, subject: string) => Effect.Effect<Principal | undefined>;
|
|
25
|
+
/** Only the service's authenticated workspace member supplies proofUserId. Never an email. */
|
|
26
|
+
readonly link: (issuer: string, subject: string, proofUserId: string) => Effect.Effect<Principal | undefined>;
|
|
27
|
+
readonly emailIdentity?: (subject: string) => Effect.Effect<Principal | undefined>;
|
|
28
|
+
readonly bindingExists?: (issuer: string, subject: string) => Effect.Effect<boolean>;
|
|
29
|
+
readonly enroll?: (identity: {
|
|
30
|
+
issuer: string;
|
|
31
|
+
subject: string;
|
|
32
|
+
email?: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
}) => Effect.Effect<Principal | undefined>;
|
|
35
|
+
readonly linkEmail?: (userId: string, subject: string, email?: string) => Effect.Effect<Principal | "email_identity_mismatch" | undefined>;
|
|
36
|
+
readonly save: (session: FederationSession) => Effect.Effect<void>;
|
|
37
|
+
readonly read: (hash: string) => Effect.Effect<FederationSession | undefined>;
|
|
38
|
+
readonly consumePending: (hash: string) => Effect.Effect<FederationSession | undefined>;
|
|
39
|
+
readonly remove: (hash: string) => Effect.Effect<void>;
|
|
40
|
+
readonly principal: (id: string) => Effect.Effect<Principal | undefined>;
|
|
41
|
+
}
|
|
42
|
+
export declare function sqlFederationStore(ontology: Ontology, sql: SqlClient.SqlClient): FederationStore;
|