@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,310 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
import type { ActionError, ActionRejected, Conflict, NotFound, ScopeViolated } from "./errors.js";
|
|
3
|
+
import type { ConnectionError } from "./connection.js";
|
|
4
|
+
import type { ScopedPermission } from "./permissions.js";
|
|
5
|
+
import type { Where } from "./query.js";
|
|
6
|
+
import type { WorkloadExecution } from "./runtime/workload.js";
|
|
7
|
+
/** Who runs an action: an app member or a service principal, both `user` records. */
|
|
8
|
+
export interface Principal {
|
|
9
|
+
/** Present only for a verified managed pipeline worker. */
|
|
10
|
+
readonly execution?: WorkloadExecution;
|
|
11
|
+
/**
|
|
12
|
+
* Present only for a workflow's user: the workflow's wire name, whose runs it acts in, and its
|
|
13
|
+
* identity subject, `workflows:<workspace id>:<workflow name>`.
|
|
14
|
+
*/
|
|
15
|
+
readonly workflow?: {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly subject: string;
|
|
18
|
+
};
|
|
19
|
+
/** Verified authentication mechanism for this request; action contexts always expose it. */
|
|
20
|
+
readonly authenticatedVia?: string;
|
|
21
|
+
/** The id of the principal's `user` record. */
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly kind: "member" | "service";
|
|
24
|
+
/** Role names the principal holds. Every active member holds `member`. */
|
|
25
|
+
readonly roles: ReadonlyArray<string>;
|
|
26
|
+
/**
|
|
27
|
+
* What the principal may do: the union of its roles' permissions in the ontology, wildcards
|
|
28
|
+
* included. A role the ontology no longer declares grants nothing.
|
|
29
|
+
*/
|
|
30
|
+
readonly permissions: ReadonlyArray<string>;
|
|
31
|
+
/**
|
|
32
|
+
* The scoped permissions of the held roles, with their `where` in wire form; a permission listed
|
|
33
|
+
* here is held only for the records its scopes match. Absent when no held role scopes one.
|
|
34
|
+
*/
|
|
35
|
+
readonly scopes?: ReadonlyArray<ScopedPermission>;
|
|
36
|
+
}
|
|
37
|
+
/** A record as the runtime returns it, before an entity handle gives it the entity's type. */
|
|
38
|
+
export type StoredRecord = Readonly<Record<string, unknown>>;
|
|
39
|
+
/** Values to write, keyed by property and relationship name. */
|
|
40
|
+
export type StoredValues = Readonly<Record<string, unknown>>;
|
|
41
|
+
export interface GetOptions {
|
|
42
|
+
/** Lock the record until the action's transaction ends. */
|
|
43
|
+
readonly forUpdate?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Conditions on one field of a record whose value has type `V`; see {@link FieldFilter}. A list,
|
|
47
|
+
* the user's `roles`, takes only `has` and `hasAny`.
|
|
48
|
+
*/
|
|
49
|
+
export type FieldCondition<V> = NonNullable<V> extends ReadonlyArray<infer Item> ? {
|
|
50
|
+
readonly has?: Item;
|
|
51
|
+
readonly hasAny?: ReadonlyArray<Item>;
|
|
52
|
+
} : V | null | ScalarCondition<V>;
|
|
53
|
+
type ScalarCondition<V> = {
|
|
54
|
+
readonly eq?: NonNullable<V>;
|
|
55
|
+
readonly ne?: NonNullable<V>;
|
|
56
|
+
readonly in?: ReadonlyArray<NonNullable<V>>;
|
|
57
|
+
readonly isNull?: boolean;
|
|
58
|
+
readonly contains?: string;
|
|
59
|
+
readonly startsWith?: string;
|
|
60
|
+
readonly gt?: NonNullable<V>;
|
|
61
|
+
readonly gte?: NonNullable<V>;
|
|
62
|
+
readonly lt?: NonNullable<V>;
|
|
63
|
+
readonly lte?: NonNullable<V>;
|
|
64
|
+
readonly between?: readonly [NonNullable<V>, NonNullable<V>];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A `where` on records of type `R`, in the query language of `src/query.ts`: conditions by field, a
|
|
68
|
+
* {@link Where} on the target of each relationship `L`, and `and`, `or` and `not`. The runtime checks
|
|
69
|
+
* which operators a field's type takes.
|
|
70
|
+
*/
|
|
71
|
+
export type RecordWhere<R, L extends string = never> = {
|
|
72
|
+
readonly [K in keyof R]?: FieldCondition<R[K]>;
|
|
73
|
+
} & {
|
|
74
|
+
readonly [K in L]?: Where;
|
|
75
|
+
} & {
|
|
76
|
+
readonly and?: ReadonlyArray<RecordWhere<R, L>>;
|
|
77
|
+
readonly or?: ReadonlyArray<RecordWhere<R, L>>;
|
|
78
|
+
readonly not?: RecordWhere<R, L>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* A query from an action handler: the query language, plus `forUpdate`. Included relationships are
|
|
82
|
+
* added to the records under their names, but are not part of the records' type.
|
|
83
|
+
*/
|
|
84
|
+
export interface FindOptions<R = StoredRecord, L extends string = never> {
|
|
85
|
+
readonly where?: RecordWhere<R, L>;
|
|
86
|
+
readonly orderBy?: ReadonlyArray<{
|
|
87
|
+
readonly field: keyof R & string;
|
|
88
|
+
readonly direction?: "asc" | "desc";
|
|
89
|
+
}>;
|
|
90
|
+
/** Relationships to add to each record: `["owner", "tags"]`, or `{ owner: true, tags: true }`. */
|
|
91
|
+
readonly include?: ReadonlyArray<L> | {
|
|
92
|
+
readonly [K in L]?: true;
|
|
93
|
+
};
|
|
94
|
+
readonly after?: string;
|
|
95
|
+
readonly limit?: number;
|
|
96
|
+
/** Lock the matching records until the action's transaction ends. */
|
|
97
|
+
readonly forUpdate?: boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A fresh metric query from an action: metrics the entity declares, computed in the workspace
|
|
101
|
+
* database over the records `where` matches, in the action's transaction. `where` is the query
|
|
102
|
+
* language of `find` and must match an indexed field of the entity with `eq` or `in`; see
|
|
103
|
+
* docs/ontology.md, "Fresh metric queries inside an action".
|
|
104
|
+
*/
|
|
105
|
+
export interface FreshMetricQueryOptions<R = StoredRecord, L extends string = never, Metric extends string = string, Group extends string = string> {
|
|
106
|
+
/** Metrics of the entity, as `defineOntology` declares them. */
|
|
107
|
+
readonly metrics: readonly [Metric, ...Metric[]];
|
|
108
|
+
/** Fields to group by: properties and `<relationship>Id` keys. Without it, one row. */
|
|
109
|
+
readonly groupBy?: ReadonlyArray<Group>;
|
|
110
|
+
readonly where: RecordWhere<R, L>;
|
|
111
|
+
}
|
|
112
|
+
export interface UpsertResult<R = StoredRecord> {
|
|
113
|
+
readonly record: R;
|
|
114
|
+
readonly created: boolean;
|
|
115
|
+
}
|
|
116
|
+
/** Whether a batch returns its records or only outcome counts. Defaults to `records`. */
|
|
117
|
+
export type BatchReturning = "records" | "summary";
|
|
118
|
+
export interface BatchOptions {
|
|
119
|
+
readonly returning?: BatchReturning;
|
|
120
|
+
}
|
|
121
|
+
/** Outcome counts, which together equal the number of inputs in a successful batch. */
|
|
122
|
+
export interface BatchSummaryResult {
|
|
123
|
+
readonly created: number;
|
|
124
|
+
readonly updated: number;
|
|
125
|
+
readonly unchanged: number;
|
|
126
|
+
}
|
|
127
|
+
/** One result per input, in input order, including records whose values did not change. */
|
|
128
|
+
export interface BatchRecordResult<R = StoredRecord> extends BatchSummaryResult {
|
|
129
|
+
readonly items: ReadonlyArray<{
|
|
130
|
+
readonly index: number;
|
|
131
|
+
readonly status: "created" | "updated" | "unchanged";
|
|
132
|
+
readonly record: R;
|
|
133
|
+
}>;
|
|
134
|
+
}
|
|
135
|
+
export type BatchResult<R = StoredRecord> = BatchRecordResult<R> | BatchSummaryResult;
|
|
136
|
+
/** Raw batch inputs use wire entity and field names. */
|
|
137
|
+
export interface CreateManyInput extends BatchOptions {
|
|
138
|
+
readonly entity: string;
|
|
139
|
+
readonly records: ReadonlyArray<StoredValues>;
|
|
140
|
+
}
|
|
141
|
+
export interface UpdateManyInput extends BatchOptions {
|
|
142
|
+
readonly entity: string;
|
|
143
|
+
readonly records: ReadonlyArray<{
|
|
144
|
+
readonly id: string;
|
|
145
|
+
readonly values: StoredValues;
|
|
146
|
+
}>;
|
|
147
|
+
}
|
|
148
|
+
export interface UpsertManyInput extends CreateManyInput {
|
|
149
|
+
readonly on: readonly [string, ...string[]];
|
|
150
|
+
}
|
|
151
|
+
type BatchWriteError = ActionRejected | Conflict | NotFound | ScopeViolated;
|
|
152
|
+
interface BatchWrite<Input extends BatchOptions> {
|
|
153
|
+
(input: Input & {
|
|
154
|
+
readonly returning: "summary";
|
|
155
|
+
}): Effect.Effect<BatchSummaryResult, BatchWriteError>;
|
|
156
|
+
(input: Input & {
|
|
157
|
+
readonly returning?: "records";
|
|
158
|
+
}): Effect.Effect<BatchRecordResult, BatchWriteError>;
|
|
159
|
+
(input: Input): Effect.Effect<BatchResult, BatchWriteError>;
|
|
160
|
+
}
|
|
161
|
+
type ReadsService = {
|
|
162
|
+
readonly get: (input: {
|
|
163
|
+
readonly entity: string;
|
|
164
|
+
readonly id: string;
|
|
165
|
+
readonly forUpdate?: boolean;
|
|
166
|
+
}) => Effect.Effect<StoredRecord, NotFound>;
|
|
167
|
+
readonly find: (input: {
|
|
168
|
+
readonly entity: string;
|
|
169
|
+
readonly options: FindOptions;
|
|
170
|
+
}) => Effect.Effect<ReadonlyArray<StoredRecord>>;
|
|
171
|
+
/**
|
|
172
|
+
* A fresh metric query in wire names: one row per group, keyed by the grouped fields' and the
|
|
173
|
+
* metrics' wire names, metrics as decimal strings or `null`. Without `groupBy`, exactly one row.
|
|
174
|
+
*/
|
|
175
|
+
readonly queryMetrics: (input: {
|
|
176
|
+
readonly entity: string;
|
|
177
|
+
readonly options: FreshMetricQueryOptions;
|
|
178
|
+
}) => Effect.Effect<ReadonlyArray<StoredRecord>>;
|
|
179
|
+
};
|
|
180
|
+
type WritesService = {
|
|
181
|
+
readonly createMany: BatchWrite<CreateManyInput>;
|
|
182
|
+
readonly updateMany: BatchWrite<UpdateManyInput>;
|
|
183
|
+
readonly upsertMany: BatchWrite<UpsertManyInput>;
|
|
184
|
+
readonly create: (input: {
|
|
185
|
+
readonly entity: string;
|
|
186
|
+
readonly values: StoredValues;
|
|
187
|
+
}) => Effect.Effect<StoredRecord, Conflict | NotFound | ScopeViolated>;
|
|
188
|
+
readonly update: (input: {
|
|
189
|
+
readonly entity: string;
|
|
190
|
+
readonly id: string;
|
|
191
|
+
readonly values: StoredValues;
|
|
192
|
+
}) => Effect.Effect<StoredRecord, Conflict | NotFound | ScopeViolated>;
|
|
193
|
+
readonly upsertBy: (input: {
|
|
194
|
+
readonly entity: string;
|
|
195
|
+
readonly property: string;
|
|
196
|
+
readonly values: StoredValues;
|
|
197
|
+
}) => Effect.Effect<UpsertResult, Conflict | NotFound | ScopeViolated>;
|
|
198
|
+
readonly delete: (input: {
|
|
199
|
+
readonly entity: string;
|
|
200
|
+
readonly id: string;
|
|
201
|
+
}) => Effect.Effect<void, Conflict | NotFound | ScopeViolated>;
|
|
202
|
+
readonly link: (input: {
|
|
203
|
+
readonly entity: string;
|
|
204
|
+
readonly relationship: string;
|
|
205
|
+
readonly id: string;
|
|
206
|
+
readonly targetId: string;
|
|
207
|
+
}) => Effect.Effect<void, NotFound | ScopeViolated>;
|
|
208
|
+
readonly unlink: (input: {
|
|
209
|
+
readonly entity: string;
|
|
210
|
+
readonly relationship: string;
|
|
211
|
+
readonly id: string;
|
|
212
|
+
readonly targetId: string;
|
|
213
|
+
}) => Effect.Effect<void, NotFound | ScopeViolated>;
|
|
214
|
+
/**
|
|
215
|
+
* Grants roles the ontology declares to a member, as `user.grant_roles` does. A role that is not
|
|
216
|
+
* declared, or `member`, is ActionRejected; a service or an unknown id is NotFound. Each member
|
|
217
|
+
* write returns the user with its new `roles`; role names are wire names.
|
|
218
|
+
*/
|
|
219
|
+
readonly grantUserRoles: (input: {
|
|
220
|
+
readonly id: string;
|
|
221
|
+
readonly roles: ReadonlyArray<string>;
|
|
222
|
+
}) => Effect.Effect<StoredRecord, ActionRejected | NotFound>;
|
|
223
|
+
/** Revokes roles from a member, or every role, as `user.revoke_roles` does. */
|
|
224
|
+
readonly revokeUserRoles: (input: {
|
|
225
|
+
readonly id: string;
|
|
226
|
+
readonly roles: ReadonlyArray<string> | "all";
|
|
227
|
+
}) => Effect.Effect<StoredRecord, ActionRejected | NotFound>;
|
|
228
|
+
/** Creates a member for an email no user has, as `user.invite` does; a known email is Conflict. */
|
|
229
|
+
readonly inviteUser: (input: {
|
|
230
|
+
readonly email: string;
|
|
231
|
+
readonly name?: string | undefined;
|
|
232
|
+
readonly roles?: ReadonlyArray<string> | undefined;
|
|
233
|
+
}) => Effect.Effect<StoredRecord, ActionRejected | Conflict>;
|
|
234
|
+
/** Deactivates a member, ending their sessions, or reactivates one. */
|
|
235
|
+
readonly setUserActive: (input: {
|
|
236
|
+
readonly id: string;
|
|
237
|
+
readonly active: boolean;
|
|
238
|
+
}) => Effect.Effect<StoredRecord, NotFound>;
|
|
239
|
+
/**
|
|
240
|
+
* Queues an email with a sign-in link for an active member, sent once the action commits: one of
|
|
241
|
+
* the ontology's `emails` by wire name, filled with `values`, or the platform's own email without
|
|
242
|
+
* `template`. The link opens `returnTo`, a path of the app, `/` by default. An inactive member, an
|
|
243
|
+
* unknown email, a missing or unused value, or a path outside the app is ActionRejected; a
|
|
244
|
+
* service or an unknown id is NotFound.
|
|
245
|
+
*/
|
|
246
|
+
readonly sendUserSignInLink: (input: {
|
|
247
|
+
readonly id: string;
|
|
248
|
+
readonly template?: string | undefined;
|
|
249
|
+
readonly returnTo?: string | undefined;
|
|
250
|
+
readonly values?: Readonly<Record<string, string>> | undefined;
|
|
251
|
+
}) => Effect.Effect<void, ActionRejected | NotFound>;
|
|
252
|
+
};
|
|
253
|
+
declare const OntologyReads_base: Context.ServiceClass<OntologyReads, "@segmentstream/ontology/OntologyReads", ReadsService>;
|
|
254
|
+
/**
|
|
255
|
+
* The reads an action runs against: `get`, `find` and `queryMetrics` of entity handles require it. An
|
|
256
|
+
* action's `prepare` has the reads alone, outside any transaction; its `handler` has them inside
|
|
257
|
+
* the transaction, with {@link OntologyWrites}.
|
|
258
|
+
*/
|
|
259
|
+
export declare class OntologyReads extends OntologyReads_base {
|
|
260
|
+
}
|
|
261
|
+
declare const OntologyWrites_base: Context.ServiceClass<OntologyWrites, "@segmentstream/ontology/OntologyWrites", WritesService>;
|
|
262
|
+
/**
|
|
263
|
+
* The writes an action handler runs, inside the action's transaction: `create`, `update`,
|
|
264
|
+
* `upsertBy`, the batch methods, `delete`, `link` and `unlink` of entity handles require it, and the
|
|
265
|
+
* member writes of the `User` handle. `prepare` never has it.
|
|
266
|
+
*/
|
|
267
|
+
export declare class OntologyWrites extends OntologyWrites_base {
|
|
268
|
+
}
|
|
269
|
+
/** Stable invocation and creation identities for actions that attach upload tickets. */
|
|
270
|
+
export interface ActionRunOptions {
|
|
271
|
+
readonly idempotencyKey?: string;
|
|
272
|
+
readonly createIntent?: string;
|
|
273
|
+
}
|
|
274
|
+
declare const OntologyActions_base: Context.ServiceClass<OntologyActions, "@segmentstream/ontology/OntologyActions", {
|
|
275
|
+
readonly run: (input: {
|
|
276
|
+
/** The entity's wire name, `lead`. */
|
|
277
|
+
readonly entity: string;
|
|
278
|
+
/** The action's wire name, `add_note`. */
|
|
279
|
+
readonly action: string;
|
|
280
|
+
/** The input in TypeScript names, as the action's handler receives it decoded. */
|
|
281
|
+
readonly input: unknown;
|
|
282
|
+
readonly options?: ActionRunOptions;
|
|
283
|
+
}) => Effect.Effect<unknown, ActionError | ConnectionError>;
|
|
284
|
+
}>;
|
|
285
|
+
/**
|
|
286
|
+
* Runs an authored action as the current caller, through the same path as the action's HTTP route:
|
|
287
|
+
* its permission check, validation, transaction, history and after-commit hook. What
|
|
288
|
+
* `Lead.actions.addNote(input)` requires. A workflow step's `run` provides it; action handlers do
|
|
289
|
+
* not have it, since an action never runs another action.
|
|
290
|
+
*/
|
|
291
|
+
export declare class OntologyActions extends OntologyActions_base {
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* The data access an action handler runs against, inside the action's transaction: the reads and the
|
|
295
|
+
* writes. The ontology service provides it; this package declares only the contract. Entity handles
|
|
296
|
+
* (`Lead.get`, `Lead.create`, …) call it with their entity's name and type the records it returns, so
|
|
297
|
+
* the runtime must decode every record against that entity's definition before returning it.
|
|
298
|
+
*/
|
|
299
|
+
export type OntologyRuntime = OntologyReads | OntologyWrites;
|
|
300
|
+
/** One implementation of both the reads and the writes, as the SQL runtime provides them. */
|
|
301
|
+
export type OntologyRuntimeService = ReadsService & WritesService;
|
|
302
|
+
export declare const OntologyRuntime: {
|
|
303
|
+
/** Types an implementation of the reads and the writes. */
|
|
304
|
+
of: (service: OntologyRuntimeService) => OntologyRuntimeService;
|
|
305
|
+
/** A context holding the implementation as both {@link OntologyReads} and {@link OntologyWrites}. */
|
|
306
|
+
context: (service: OntologyRuntimeService) => Context.Context<OntologyRuntime>;
|
|
307
|
+
/** Provides the implementation as both {@link OntologyReads} and {@link OntologyWrites}. */
|
|
308
|
+
provide: (service: OntologyRuntimeService) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, OntologyRuntime>>;
|
|
309
|
+
};
|
|
310
|
+
export {};
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* The reads an action runs against: `get`, `find` and `queryMetrics` of entity handles require it. An
|
|
4
|
+
* action's `prepare` has the reads alone, outside any transaction; its `handler` has them inside
|
|
5
|
+
* the transaction, with {@link OntologyWrites}.
|
|
6
|
+
*/
|
|
7
|
+
export class OntologyReads extends Context.Service()("@segmentstream/ontology/OntologyReads") {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The writes an action handler runs, inside the action's transaction: `create`, `update`,
|
|
11
|
+
* `upsertBy`, the batch methods, `delete`, `link` and `unlink` of entity handles require it, and the
|
|
12
|
+
* member writes of the `User` handle. `prepare` never has it.
|
|
13
|
+
*/
|
|
14
|
+
export class OntologyWrites extends Context.Service()("@segmentstream/ontology/OntologyWrites") {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Runs an authored action as the current caller, through the same path as the action's HTTP route:
|
|
18
|
+
* its permission check, validation, transaction, history and after-commit hook. What
|
|
19
|
+
* `Lead.actions.addNote(input)` requires. A workflow step's `run` provides it; action handlers do
|
|
20
|
+
* not have it, since an action never runs another action.
|
|
21
|
+
*/
|
|
22
|
+
export class OntologyActions extends Context.Service()("@segmentstream/ontology/OntologyActions") {
|
|
23
|
+
}
|
|
24
|
+
export const OntologyRuntime = {
|
|
25
|
+
/** Types an implementation of the reads and the writes. */
|
|
26
|
+
of: (service) => service,
|
|
27
|
+
/** A context holding the implementation as both {@link OntologyReads} and {@link OntologyWrites}. */
|
|
28
|
+
context: (service) => Context.make(OntologyReads, service).pipe(Context.add(OntologyWrites, service)),
|
|
29
|
+
/** Provides the implementation as both {@link OntologyReads} and {@link OntologyWrites}. */
|
|
30
|
+
provide: (service) => (effect) => Effect.provideContext(effect, OntologyRuntime.context(service)),
|
|
31
|
+
};
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type PlatformWorkflows } from "./workflow-runtime.js";
|
|
2
|
+
/**
|
|
3
|
+
* Prepares the process for serving the ontology's runs; the starter's `server/plugin.ts` calls it
|
|
4
|
+
* at startup. Until the flow handler loads, which sets the Workflow SDK's base path itself from the
|
|
5
|
+
* build, it sets the base path to `/api/ontology`, so that runs started first call back at
|
|
6
|
+
* `/api/ontology/.well-known/workflow/v1/*`; once a base path is set it changes nothing. It also
|
|
7
|
+
* registers synchronous argument codecs and the Workflow SDK's runtime operations, loaded on
|
|
8
|
+
* first use, for the service's workflow routes, which refuse to serve until registered. Only this
|
|
9
|
+
* entry exports it, so that neither the service nor a workflow file's imports load the Workflow SDK.
|
|
10
|
+
*
|
|
11
|
+
* This process serves the ontology's queue only, so it names the ontology's queue namespace in
|
|
12
|
+
* `WORKFLOW_QUEUE_NAMESPACE`, where the Workflow SDK reads it whenever its API takes none:
|
|
13
|
+
* `resumeHook`, which an agent task's result resumes its workflow with, enqueues the run there.
|
|
14
|
+
* `start` and the flow handler name the namespace themselves.
|
|
15
|
+
*/
|
|
16
|
+
export declare function installWorkflowRuntime(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Registers the platform's workflow functions, compiled by the Workflow SDK in the server build:
|
|
19
|
+
* the plugin `ontologyWorkflows()` generates calls it at startup with the functions of the file it
|
|
20
|
+
* wrote beside the workspace's workflows. Without it, an action whose triggers may fire is refused,
|
|
21
|
+
* since the service could not arm the recovery run that guarantees its starts.
|
|
22
|
+
*/
|
|
23
|
+
export declare function registerPlatformWorkflows(workflows: PlatformWorkflows): void;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ontology service's server-side setup, for the starter's `server/plugin.ts`. This entry loads
|
|
3
|
+
* the Workflow SDK; the package root and the `workflows` entry, which workflow files import and the
|
|
4
|
+
* Workflow SDK bundles for a runtime without Node built-ins, do not.
|
|
5
|
+
*/
|
|
6
|
+
import { setWorkflowBasePath } from "@workflow/utils";
|
|
7
|
+
import { deploymentFromEnv, requireDeploymentCapability } from "./deployment.js";
|
|
8
|
+
import { setPlatformWorkflows, setWorkflowSdk, } from "./workflow-runtime.js";
|
|
9
|
+
import { ONTOLOGY_QUEUE_NAMESPACE, WORKFLOW_BASE_PATH } from "./workflow-topics.js";
|
|
10
|
+
import { installWorkflowArgumentCodecs } from "./service/workflow-argument-serialization.js";
|
|
11
|
+
import { installWorkflowLogging } from "./service/workflow-logging.js";
|
|
12
|
+
import { fenceWorkflowQueue } from "./service/workflow-queue-fence.js";
|
|
13
|
+
const BASE_PATH = Symbol.for("@workflow/core/basePath");
|
|
14
|
+
const globals = globalThis;
|
|
15
|
+
let preparingCallback;
|
|
16
|
+
/**
|
|
17
|
+
* Prepares the process for serving the ontology's runs; the starter's `server/plugin.ts` calls it
|
|
18
|
+
* at startup. Until the flow handler loads, which sets the Workflow SDK's base path itself from the
|
|
19
|
+
* build, it sets the base path to `/api/ontology`, so that runs started first call back at
|
|
20
|
+
* `/api/ontology/.well-known/workflow/v1/*`; once a base path is set it changes nothing. It also
|
|
21
|
+
* registers synchronous argument codecs and the Workflow SDK's runtime operations, loaded on
|
|
22
|
+
* first use, for the service's workflow routes, which refuse to serve until registered. Only this
|
|
23
|
+
* entry exports it, so that neither the service nor a workflow file's imports load the Workflow SDK.
|
|
24
|
+
*
|
|
25
|
+
* This process serves the ontology's queue only, so it names the ontology's queue namespace in
|
|
26
|
+
* `WORKFLOW_QUEUE_NAMESPACE`, where the Workflow SDK reads it whenever its API takes none:
|
|
27
|
+
* `resumeHook`, which an agent task's result resumes its workflow with, enqueues the run there.
|
|
28
|
+
* `start` and the flow handler name the namespace themselves.
|
|
29
|
+
*/
|
|
30
|
+
export function installWorkflowRuntime() {
|
|
31
|
+
installWorkflowArgumentCodecs();
|
|
32
|
+
installWorkflowLogging();
|
|
33
|
+
process.env.WORKFLOW_QUEUE_NAMESPACE = ONTOLOGY_QUEUE_NAMESPACE;
|
|
34
|
+
if (globals[BASE_PATH] === undefined) {
|
|
35
|
+
setWorkflowBasePath(WORKFLOW_BASE_PATH);
|
|
36
|
+
}
|
|
37
|
+
setWorkflowSdk({
|
|
38
|
+
allocateRun: async () => {
|
|
39
|
+
const { getWorld } = await import("workflow/runtime");
|
|
40
|
+
const { allocateWorkflowRun } = await import("./service/workflow-admission-provider.js");
|
|
41
|
+
const world = await getWorld();
|
|
42
|
+
return allocateWorkflowRun(world, {
|
|
43
|
+
deploymentId: await world.getDeploymentId(),
|
|
44
|
+
namespace: ONTOLOGY_QUEUE_NAMESPACE,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
prepareCallback: () => {
|
|
48
|
+
preparingCallback ??= (async () => {
|
|
49
|
+
const { getWorld, setWorld } = await import("workflow/runtime");
|
|
50
|
+
setWorld(fenceWorkflowQueue(await getWorld()));
|
|
51
|
+
})().catch((error) => {
|
|
52
|
+
preparingCallback = undefined;
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
55
|
+
return preparingCallback;
|
|
56
|
+
},
|
|
57
|
+
start: async (workflow, args, options) => {
|
|
58
|
+
requireDeploymentCapability(deploymentFromEnv(), "workflows");
|
|
59
|
+
const { start } = await import("workflow/api");
|
|
60
|
+
if (options.reservation) {
|
|
61
|
+
const { getWorld } = await import("workflow/runtime");
|
|
62
|
+
const { startReservedWorkflowRun } = await import("./service/workflow-admission-provider.js");
|
|
63
|
+
const id = workflow.workflowId;
|
|
64
|
+
if (!id || !options.reservation.admissionId) {
|
|
65
|
+
throw new Error("The durable workflow admission binding is incomplete.");
|
|
66
|
+
}
|
|
67
|
+
return startReservedWorkflowRun(await getWorld(), { workflowId: id }, args, {
|
|
68
|
+
reservation: options.reservation,
|
|
69
|
+
admissionId: options.reservation.admissionId,
|
|
70
|
+
...(options.attributes ? { attributes: options.attributes } : {}),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return start(workflow, args, options);
|
|
74
|
+
},
|
|
75
|
+
world: async () => {
|
|
76
|
+
const { getWorld } = await import("workflow/runtime");
|
|
77
|
+
return getWorld();
|
|
78
|
+
},
|
|
79
|
+
resumeHook: async (token, payload) => {
|
|
80
|
+
requireDeploymentCapability(deploymentFromEnv(), "workflows");
|
|
81
|
+
const { resumeHook } = await import("workflow/api");
|
|
82
|
+
return resumeHook(token, payload);
|
|
83
|
+
},
|
|
84
|
+
hydrateError: async (value, run, kind) => {
|
|
85
|
+
const { getWorld } = await import("workflow/runtime");
|
|
86
|
+
const { hydrateRunError, hydrateStepError } = await import("@workflow/core/serialization");
|
|
87
|
+
const { importKey } = await import("@workflow/core/encryption");
|
|
88
|
+
const world = await getWorld();
|
|
89
|
+
const rawKey = await world.getEncryptionKeyForRun?.(run.runId, {
|
|
90
|
+
deploymentId: run.deploymentId,
|
|
91
|
+
});
|
|
92
|
+
const key = rawKey === undefined ? undefined : await importKey(rawKey);
|
|
93
|
+
return kind === "step"
|
|
94
|
+
? hydrateStepError(value, run.runId, key)
|
|
95
|
+
: hydrateRunError(value, run.runId, key);
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Registers the platform's workflow functions, compiled by the Workflow SDK in the server build:
|
|
101
|
+
* the plugin `ontologyWorkflows()` generates calls it at startup with the functions of the file it
|
|
102
|
+
* wrote beside the workspace's workflows. Without it, an action whose triggers may fire is refused,
|
|
103
|
+
* since the service could not arm the recovery run that guarantees its starts.
|
|
104
|
+
*/
|
|
105
|
+
export function registerPlatformWorkflows(workflows) {
|
|
106
|
+
setPlatformWorkflows(workflows);
|
|
107
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { HttpRouter } from "effect/unstable/http";
|
|
3
|
+
import { type TokenVerifier } from "../authentication.js";
|
|
4
|
+
import type { AfterCommitHook } from "../config.js";
|
|
5
|
+
import type { ConnectionTransportFactory } from "../connections.js";
|
|
6
|
+
import { RequestId } from "../errors.js";
|
|
7
|
+
import type { ApiPlan } from "../plan.js";
|
|
8
|
+
import type { ReplicationKick } from "../replication.js";
|
|
9
|
+
import { OntologyBackend } from "../runtime-contract.js";
|
|
10
|
+
import type { RuntimeTokenVerifier } from "../runtime-identity.js";
|
|
11
|
+
export { CONVERSATION_HEADER, SESSION_HEADER } from "./authentication.js";
|
|
12
|
+
/**
|
|
13
|
+
* The agent's temporary attachments over HTTP (`docs/agent.md`, "Attachments"). Only the
|
|
14
|
+
* deployment's runtime token reaches these routes, acting as the member in `X-SegmentStream-Act-As`
|
|
15
|
+
* while they are active. The chat and the agent session come from the agent's runtime in
|
|
16
|
+
* `X-SegmentStream-Agent-Conversation` and `X-SegmentStream-Agent-Session`, never from the model's
|
|
17
|
+
* tool arguments. Storage checks current group participation or chat administration; private files
|
|
18
|
+
* remain confined to their sender and session.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ATTACHMENTS_PATH = "/api/ontology/agent/attachments";
|
|
21
|
+
export interface AttachmentRoutesOptions {
|
|
22
|
+
readonly plan: ApiPlan;
|
|
23
|
+
readonly hooks: ReadonlyMap<string, AfterCommitHook>;
|
|
24
|
+
readonly connections: ConnectionTransportFactory;
|
|
25
|
+
readonly replicate: ReplicationKick;
|
|
26
|
+
readonly verifyToken: TokenVerifier;
|
|
27
|
+
readonly verifyRuntime: RuntimeTokenVerifier | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The attachment routes. Without file storage or the agent tables, or while runtime authentication
|
|
31
|
+
* is disabled, it serves nothing.
|
|
32
|
+
*/
|
|
33
|
+
export declare function attachmentsLayer(options: AttachmentRoutesOptions): Layer.Layer<never, never, OntologyBackend | HttpRouter.HttpRouter | HttpRouter.Request<"Requires", RequestId>>;
|