@segmentstream/ontology 0.0.0-stage → 0.92.0
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,213 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Schema, Stream, type Scope } from "effect";
|
|
2
|
+
export declare const ConnectionTypeId: unique symbol;
|
|
3
|
+
/** A connection key, as `connections/connections.py` declares it. */
|
|
4
|
+
export declare const CONNECTION_KEY: RegExp;
|
|
5
|
+
export declare const CONNECTION_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
|
|
6
|
+
export type ConnectionMethod = (typeof CONNECTION_METHODS)[number];
|
|
7
|
+
/** The largest request body. */
|
|
8
|
+
export declare const MAXIMUM_CONNECTION_BODY_BYTES: number;
|
|
9
|
+
/**
|
|
10
|
+
* The largest response body `get`, `post` and `request` collect. A larger response fails with
|
|
11
|
+
* `invalid_response`; `stream` reads a response of any size.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MAXIMUM_CONNECTION_RESPONSE_BYTES: number;
|
|
14
|
+
/**
|
|
15
|
+
* Why a connection call failed, as {@link ConnectionError} carries it:
|
|
16
|
+
*
|
|
17
|
+
* - `authorization_required`: the connection is declared but not configured or authorized yet;
|
|
18
|
+
* - `not_deployed`: the workspace's connection declarations are not deployed;
|
|
19
|
+
* - `not_granted`: the platform refused this service the connection, a platform fault;
|
|
20
|
+
* - `unavailable`: the proxy or the provider could not be reached; retrying may succeed;
|
|
21
|
+
* - `refused`: the provider refused the request in a way retrying will not fix;
|
|
22
|
+
* - `timeout`: the call exceeded its deadline;
|
|
23
|
+
* - `invalid_request`: the proxy refused the request itself, such as a forbidden header or path;
|
|
24
|
+
* - `invalid_response`: the response did not match the schema given to `json`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CONNECTION_ERROR_REASONS: readonly ["authorization_required", "not_deployed", "not_granted", "unavailable", "refused", "timeout", "invalid_request", "invalid_response"];
|
|
27
|
+
export type ConnectionErrorReason = (typeof CONNECTION_ERROR_REASONS)[number];
|
|
28
|
+
declare const ConnectionError_base: Schema.Class<ConnectionError, Schema.TaggedStruct<"ConnectionError", {
|
|
29
|
+
/** The connection key. */
|
|
30
|
+
readonly connection: Schema.String;
|
|
31
|
+
readonly reason: Schema.Literals<readonly ["authorization_required", "not_deployed", "not_granted", "unavailable", "refused", "timeout", "invalid_request", "invalid_response"]>;
|
|
32
|
+
readonly message: Schema.String;
|
|
33
|
+
readonly retryable: Schema.Boolean;
|
|
34
|
+
/** The request id SegmentStream answered with, for correlating its logs. */
|
|
35
|
+
readonly requestId: Schema.optionalKey<Schema.String>;
|
|
36
|
+
/** Original internal failure, retained for operator diagnostics only. */
|
|
37
|
+
readonly cause: Schema.optionalKey<Schema.Unknown>;
|
|
38
|
+
}>, import("effect/Cause").YieldableError>;
|
|
39
|
+
/**
|
|
40
|
+
* A connection call failed. A provider's non-2xx status is a response, not this error. `prepare` may
|
|
41
|
+
* catch it; if it escapes, the action responds with the matching status and writes nothing.
|
|
42
|
+
*/
|
|
43
|
+
export declare class ConnectionError extends ConnectionError_base {
|
|
44
|
+
}
|
|
45
|
+
/** One HTTP request through the connection proxy, before it is bound to a connection key. */
|
|
46
|
+
export interface ConnectionCall {
|
|
47
|
+
/** One of the connection's declared APIs; the connection's `default_api` when omitted. */
|
|
48
|
+
readonly api?: string;
|
|
49
|
+
readonly method: ConnectionMethod;
|
|
50
|
+
/** The path and query, relative to the API's base URL, such as `/people/match?reveal=true`. */
|
|
51
|
+
readonly path: string;
|
|
52
|
+
readonly headers: ReadonlyArray<readonly [string, string]>;
|
|
53
|
+
readonly body: Uint8Array;
|
|
54
|
+
}
|
|
55
|
+
/** What the proxy answered: the provider's status, headers and buffered body. */
|
|
56
|
+
export interface ConnectionReply {
|
|
57
|
+
readonly status: number;
|
|
58
|
+
readonly headers: ReadonlyArray<readonly [string, string]>;
|
|
59
|
+
readonly body: Uint8Array;
|
|
60
|
+
}
|
|
61
|
+
/** A provider response whose body is consumed within the caller's scope. */
|
|
62
|
+
export interface ConnectionStreamReply {
|
|
63
|
+
readonly status: number;
|
|
64
|
+
readonly headers: ReadonlyArray<readonly [string, string]>;
|
|
65
|
+
readonly body: Stream.Stream<Uint8Array, ConnectionError>;
|
|
66
|
+
}
|
|
67
|
+
export interface ConnectionStreamResponse extends ConnectionStreamReply {
|
|
68
|
+
readonly ok: boolean;
|
|
69
|
+
header(name: string): string | undefined;
|
|
70
|
+
}
|
|
71
|
+
declare const ConnectionTransport_base: Context.ServiceClass<ConnectionTransport, "@segmentstream/ontology/ConnectionTransport", {
|
|
72
|
+
readonly request: (call: ConnectionCall & {
|
|
73
|
+
readonly connection: string;
|
|
74
|
+
}) => Effect.Effect<ConnectionReply, ConnectionError>;
|
|
75
|
+
/** Optional for transports written before response streaming was introduced. */
|
|
76
|
+
readonly stream?: (call: ConnectionCall & {
|
|
77
|
+
readonly connection: string;
|
|
78
|
+
}) => Effect.Effect<ConnectionStreamReply, ConnectionError, Scope.Scope>;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Sends connection calls: to backend-next from a deployed service, to the local route with a CLI
|
|
82
|
+
* grant in development, or to stubs in tests. The ontology service provides it to actions; tests
|
|
83
|
+
* provide {@link Connections.test}.
|
|
84
|
+
*/
|
|
85
|
+
export declare class ConnectionTransport extends ConnectionTransport_base {
|
|
86
|
+
}
|
|
87
|
+
/** A buffered provider response. */
|
|
88
|
+
export interface ConnectionResponse {
|
|
89
|
+
readonly status: number;
|
|
90
|
+
/** `true` for a 2xx status. */
|
|
91
|
+
readonly ok: boolean;
|
|
92
|
+
readonly headers: ReadonlyArray<readonly [string, string]>;
|
|
93
|
+
readonly body: Uint8Array;
|
|
94
|
+
/** The body as UTF-8 text. */
|
|
95
|
+
readonly text: string;
|
|
96
|
+
/** The first value of a header, by case-insensitive name. */
|
|
97
|
+
header(name: string): string | undefined;
|
|
98
|
+
/** Parses the body as JSON and decodes it; `invalid_response` when either fails. */
|
|
99
|
+
json<S extends Schema.Top>(schema: S): Effect.Effect<S["Type"], ConnectionError, S["DecodingServices"]>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The requirement of a connection handle's calls. `prepare` has exactly the connections its action
|
|
103
|
+
* declares, so calling an undeclared one does not type-check.
|
|
104
|
+
*/
|
|
105
|
+
export interface Connection<Key extends string> {
|
|
106
|
+
readonly "~connection": Key;
|
|
107
|
+
}
|
|
108
|
+
/** The service behind {@link Connection}: the transport, bound to one connection key. */
|
|
109
|
+
export interface ConnectionClient {
|
|
110
|
+
readonly request: (call: ConnectionCall) => Effect.Effect<ConnectionReply, ConnectionError>;
|
|
111
|
+
readonly stream?: (call: ConnectionCall) => Effect.Effect<ConnectionStreamReply, ConnectionError, Scope.Scope>;
|
|
112
|
+
}
|
|
113
|
+
export type ConnectionHeaders = Readonly<Record<string, string>> | ReadonlyArray<readonly [string, string]>;
|
|
114
|
+
export type QueryValue = string | number | boolean | ReadonlyArray<string | number | boolean>;
|
|
115
|
+
/** The options of `request` and the method helpers. */
|
|
116
|
+
export interface ConnectionRequestOptions {
|
|
117
|
+
/** One of the connection's declared APIs; the connection's `default_api` when omitted. */
|
|
118
|
+
readonly api?: string;
|
|
119
|
+
/** Appended to the path as a query string. `undefined` values are skipped. */
|
|
120
|
+
readonly query?: Readonly<Record<string, QueryValue | undefined>>;
|
|
121
|
+
readonly headers?: ConnectionHeaders;
|
|
122
|
+
/** A JSON body, sent with `content-type: application/json`. */
|
|
123
|
+
readonly json?: unknown;
|
|
124
|
+
/** A form body, sent with `content-type: application/x-www-form-urlencoded`. */
|
|
125
|
+
readonly form?: Readonly<Record<string, string>>;
|
|
126
|
+
/** A raw body. Set at most one of `json`, `form` and `body`. */
|
|
127
|
+
readonly body?: string | Uint8Array;
|
|
128
|
+
}
|
|
129
|
+
export interface ConnectionRequest extends ConnectionRequestOptions {
|
|
130
|
+
readonly method: ConnectionMethod;
|
|
131
|
+
readonly path: string;
|
|
132
|
+
}
|
|
133
|
+
type Call<Key extends string> = Effect.Effect<ConnectionResponse, ConnectionError, Connection<Key>>;
|
|
134
|
+
/**
|
|
135
|
+
* A workspace connection an action may call, declared once in `ontology/` with
|
|
136
|
+
* `connection(key, { description })` and listed in the actions that use it. Calls go through
|
|
137
|
+
* SegmentStream's connection proxy, so the provider's credentials never reach the deployment.
|
|
138
|
+
*/
|
|
139
|
+
export interface ConnectionHandle<Key extends string = string> {
|
|
140
|
+
readonly [ConnectionTypeId]: typeof ConnectionTypeId;
|
|
141
|
+
/** The connection's key in `connections/connections.py`. */
|
|
142
|
+
readonly key: Key;
|
|
143
|
+
/** What the ontology uses the connection for, shown in the catalog. */
|
|
144
|
+
readonly description: string;
|
|
145
|
+
/** Whether the ontology sends data out through this connection, such as conversions or messages. */
|
|
146
|
+
readonly delivers: boolean;
|
|
147
|
+
/** The context key of this connection's client. */
|
|
148
|
+
readonly service: Context.Service<Connection<Key>, ConnectionClient>;
|
|
149
|
+
request(request: ConnectionRequest): Call<Key>;
|
|
150
|
+
/** Keeps the provider response open until consumption or scope closure. Requests remain bounded. */
|
|
151
|
+
stream(request: ConnectionRequest): Effect.Effect<ConnectionStreamResponse, ConnectionError, Connection<Key> | Scope.Scope>;
|
|
152
|
+
get(path: string, options?: ConnectionRequestOptions): Call<Key>;
|
|
153
|
+
post(path: string, options?: ConnectionRequestOptions): Call<Key>;
|
|
154
|
+
put(path: string, options?: ConnectionRequestOptions): Call<Key>;
|
|
155
|
+
patch(path: string, options?: ConnectionRequestOptions): Call<Key>;
|
|
156
|
+
delete(path: string, options?: ConnectionRequestOptions): Call<Key>;
|
|
157
|
+
}
|
|
158
|
+
/** Any connection handle. Its context key is invariant in the key, so the key is `any` here. */
|
|
159
|
+
export type AnyConnectionHandle = ConnectionHandle<any>;
|
|
160
|
+
/** The requirements of the handles in a list: `Connection<"apollo"> | Connection<"stripe">`. */
|
|
161
|
+
export type ConnectionsOf<C extends ReadonlyArray<AnyConnectionHandle>> = C[number] extends infer H ? H extends ConnectionHandle<infer Key> ? Connection<Key> : never : never;
|
|
162
|
+
export interface ConnectionOptions {
|
|
163
|
+
/** What the ontology uses the connection for: "Apollo people search. Enriches new leads." */
|
|
164
|
+
readonly description: string;
|
|
165
|
+
/**
|
|
166
|
+
* The ontology sends data out through this connection: offline conversions, a message, an
|
|
167
|
+
* email. The manifest marks it so Cloud can list it as a destination. Default false.
|
|
168
|
+
*/
|
|
169
|
+
readonly delivers?: boolean;
|
|
170
|
+
}
|
|
171
|
+
/** The call a request describes: query appended, body encoded and its content type set. */
|
|
172
|
+
export declare function connectionCall(key: string, request: ConnectionRequest): ConnectionCall;
|
|
173
|
+
/** A buffered response over what the proxy answered. */
|
|
174
|
+
export declare function connectionResponse(key: string, reply: ConnectionReply): ConnectionResponse;
|
|
175
|
+
/**
|
|
176
|
+
* Declares a connection the ontology's actions may call. `key` names a connection in the
|
|
177
|
+
* workspace's `connections/connections.py`. List the handle once in `defineOntology({ connections })`
|
|
178
|
+
* and in the `connections` of each action that calls it.
|
|
179
|
+
*/
|
|
180
|
+
export declare function connection<const Key extends string>(key: Key, options: ConnectionOptions): ConnectionHandle<Key>;
|
|
181
|
+
export declare function isConnection(value: unknown): value is AnyConnectionHandle;
|
|
182
|
+
export declare function bufferedStream(reply: ConnectionReply): ConnectionStreamReply;
|
|
183
|
+
/**
|
|
184
|
+
* The clients of the given handles over one transport: what `prepare` runs with. Only these
|
|
185
|
+
* connections can be called; the transport is never exposed to the action.
|
|
186
|
+
*/
|
|
187
|
+
export declare function connectionContext<const C extends ReadonlyArray<AnyConnectionHandle>>(handles: C, transport: ConnectionTransport["Service"], options?: {
|
|
188
|
+
readonly readOnly?: boolean;
|
|
189
|
+
}): Context.Context<ConnectionsOf<C>>;
|
|
190
|
+
/** A stubbed response for {@link Connections.test}. */
|
|
191
|
+
export interface StubResponse {
|
|
192
|
+
readonly status?: number;
|
|
193
|
+
readonly headers?: ConnectionHeaders;
|
|
194
|
+
/** A JSON body. */
|
|
195
|
+
readonly json?: unknown;
|
|
196
|
+
/** A text body. */
|
|
197
|
+
readonly text?: string;
|
|
198
|
+
}
|
|
199
|
+
/** A call as a stub receives it. */
|
|
200
|
+
export interface StubRequest extends ConnectionCall {
|
|
201
|
+
readonly connection: string;
|
|
202
|
+
/** The request body as UTF-8 text. */
|
|
203
|
+
readonly text: string;
|
|
204
|
+
}
|
|
205
|
+
export type ConnectionStub = (request: StubRequest) => Effect.Effect<StubResponse | ConnectionReply, ConnectionError>;
|
|
206
|
+
export declare const Connections: {
|
|
207
|
+
/**
|
|
208
|
+
* A transport that answers with stubs by connection key, for runtime tests of actions that
|
|
209
|
+
* declare connections. A call to a connection without a stub fails the test.
|
|
210
|
+
*/
|
|
211
|
+
test: (stubs: Readonly<Record<string, ConnectionStub>>) => Layer.Layer<ConnectionTransport>;
|
|
212
|
+
};
|
|
213
|
+
export {};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Schema, Stream } from "effect";
|
|
2
|
+
export const ConnectionTypeId = Symbol.for("@segmentstream/ontology/Connection");
|
|
3
|
+
/** A connection key, as `connections/connections.py` declares it. */
|
|
4
|
+
export const CONNECTION_KEY = /^(?=.{1,64}$)[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
|
|
5
|
+
export const CONNECTION_METHODS = [
|
|
6
|
+
"GET",
|
|
7
|
+
"POST",
|
|
8
|
+
"PUT",
|
|
9
|
+
"PATCH",
|
|
10
|
+
"DELETE",
|
|
11
|
+
"HEAD",
|
|
12
|
+
"OPTIONS",
|
|
13
|
+
];
|
|
14
|
+
/** The largest request body. */
|
|
15
|
+
export const MAXIMUM_CONNECTION_BODY_BYTES = 2 * 1024 * 1024;
|
|
16
|
+
/**
|
|
17
|
+
* The largest response body `get`, `post` and `request` collect. A larger response fails with
|
|
18
|
+
* `invalid_response`; `stream` reads a response of any size.
|
|
19
|
+
*/
|
|
20
|
+
export const MAXIMUM_CONNECTION_RESPONSE_BYTES = 64 * 1024 * 1024;
|
|
21
|
+
/**
|
|
22
|
+
* Why a connection call failed, as {@link ConnectionError} carries it:
|
|
23
|
+
*
|
|
24
|
+
* - `authorization_required`: the connection is declared but not configured or authorized yet;
|
|
25
|
+
* - `not_deployed`: the workspace's connection declarations are not deployed;
|
|
26
|
+
* - `not_granted`: the platform refused this service the connection, a platform fault;
|
|
27
|
+
* - `unavailable`: the proxy or the provider could not be reached; retrying may succeed;
|
|
28
|
+
* - `refused`: the provider refused the request in a way retrying will not fix;
|
|
29
|
+
* - `timeout`: the call exceeded its deadline;
|
|
30
|
+
* - `invalid_request`: the proxy refused the request itself, such as a forbidden header or path;
|
|
31
|
+
* - `invalid_response`: the response did not match the schema given to `json`.
|
|
32
|
+
*/
|
|
33
|
+
export const CONNECTION_ERROR_REASONS = [
|
|
34
|
+
"authorization_required",
|
|
35
|
+
"not_deployed",
|
|
36
|
+
"not_granted",
|
|
37
|
+
"unavailable",
|
|
38
|
+
"refused",
|
|
39
|
+
"timeout",
|
|
40
|
+
"invalid_request",
|
|
41
|
+
"invalid_response",
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* A connection call failed. A provider's non-2xx status is a response, not this error. `prepare` may
|
|
45
|
+
* catch it; if it escapes, the action responds with the matching status and writes nothing.
|
|
46
|
+
*/
|
|
47
|
+
export class ConnectionError extends Schema.TaggedError()("ConnectionError", {
|
|
48
|
+
/** The connection key. */
|
|
49
|
+
connection: Schema.String,
|
|
50
|
+
reason: Schema.Literals(CONNECTION_ERROR_REASONS),
|
|
51
|
+
message: Schema.String,
|
|
52
|
+
retryable: Schema.Boolean,
|
|
53
|
+
/** The request id SegmentStream answered with, for correlating its logs. */
|
|
54
|
+
requestId: Schema.optionalKey(Schema.String),
|
|
55
|
+
/** Original internal failure, retained for operator diagnostics only. */
|
|
56
|
+
cause: Schema.optionalKey(Schema.Unknown),
|
|
57
|
+
}) {
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sends connection calls: to backend-next from a deployed service, to the local route with a CLI
|
|
61
|
+
* grant in development, or to stubs in tests. The ontology service provides it to actions; tests
|
|
62
|
+
* provide {@link Connections.test}.
|
|
63
|
+
*/
|
|
64
|
+
export class ConnectionTransport extends Context.Service()("@segmentstream/ontology/ConnectionTransport") {
|
|
65
|
+
}
|
|
66
|
+
const encoder = new TextEncoder();
|
|
67
|
+
const decoder = new TextDecoder();
|
|
68
|
+
function connectionFailure(connection, reason, message, cause) {
|
|
69
|
+
return new ConnectionError({
|
|
70
|
+
connection,
|
|
71
|
+
reason,
|
|
72
|
+
message,
|
|
73
|
+
retryable: reason === "unavailable" || reason === "timeout",
|
|
74
|
+
...(cause === undefined ? {} : { cause }),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function headerPairs(headers) {
|
|
78
|
+
if (headers === undefined) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return Array.isArray(headers)
|
|
82
|
+
? [...headers]
|
|
83
|
+
: Object.entries(headers);
|
|
84
|
+
}
|
|
85
|
+
function withQuery(path, query) {
|
|
86
|
+
if (query === undefined) {
|
|
87
|
+
return path;
|
|
88
|
+
}
|
|
89
|
+
const parameters = new URLSearchParams();
|
|
90
|
+
for (const [name, value] of Object.entries(query)) {
|
|
91
|
+
if (value === undefined) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
for (const item of Array.isArray(value) ? value : [value]) {
|
|
95
|
+
parameters.append(name, String(item));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const search = parameters.toString();
|
|
99
|
+
if (search === "") {
|
|
100
|
+
return path;
|
|
101
|
+
}
|
|
102
|
+
return `${path}${path.includes("?") ? "&" : "?"}${search}`;
|
|
103
|
+
}
|
|
104
|
+
function hasHeader(headers, name) {
|
|
105
|
+
return headers.some(([candidate]) => candidate.toLowerCase() === name);
|
|
106
|
+
}
|
|
107
|
+
/** The call a request describes: query appended, body encoded and its content type set. */
|
|
108
|
+
export function connectionCall(key, request) {
|
|
109
|
+
const bodies = [request.json, request.form, request.body].filter((body) => body !== undefined);
|
|
110
|
+
if (bodies.length > 1) {
|
|
111
|
+
throw connectionFailure(key, "invalid_request", "Set at most one of json, form and body.");
|
|
112
|
+
}
|
|
113
|
+
const headers = headerPairs(request.headers);
|
|
114
|
+
let body = new Uint8Array();
|
|
115
|
+
let contentType;
|
|
116
|
+
if (request.json !== undefined) {
|
|
117
|
+
body = encoder.encode(JSON.stringify(request.json));
|
|
118
|
+
contentType = "application/json";
|
|
119
|
+
}
|
|
120
|
+
else if (request.form !== undefined) {
|
|
121
|
+
body = encoder.encode(new URLSearchParams(Object.entries(request.form)).toString());
|
|
122
|
+
contentType = "application/x-www-form-urlencoded";
|
|
123
|
+
}
|
|
124
|
+
else if (typeof request.body === "string") {
|
|
125
|
+
body = encoder.encode(request.body);
|
|
126
|
+
}
|
|
127
|
+
else if (request.body !== undefined) {
|
|
128
|
+
body = request.body;
|
|
129
|
+
}
|
|
130
|
+
if (contentType !== undefined && !hasHeader(headers, "content-type")) {
|
|
131
|
+
headers.push(["content-type", contentType]);
|
|
132
|
+
}
|
|
133
|
+
if (body.byteLength > MAXIMUM_CONNECTION_BODY_BYTES) {
|
|
134
|
+
throw connectionFailure(key, "invalid_request", "The request body exceeds 2 MiB.");
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
...(request.api === undefined ? {} : { api: request.api }),
|
|
138
|
+
method: request.method,
|
|
139
|
+
path: withQuery(request.path, request.query),
|
|
140
|
+
headers,
|
|
141
|
+
body,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** A buffered response over what the proxy answered. */
|
|
145
|
+
export function connectionResponse(key, reply) {
|
|
146
|
+
let text;
|
|
147
|
+
const readText = () => (text ??= decoder.decode(reply.body));
|
|
148
|
+
return {
|
|
149
|
+
status: reply.status,
|
|
150
|
+
ok: reply.status >= 200 && reply.status < 300,
|
|
151
|
+
headers: reply.headers,
|
|
152
|
+
body: reply.body,
|
|
153
|
+
get text() {
|
|
154
|
+
return readText();
|
|
155
|
+
},
|
|
156
|
+
header: (name) => reply.headers.find(([candidate]) => candidate.toLowerCase() === name.toLowerCase())?.[1],
|
|
157
|
+
json: (schema) => Effect.try({
|
|
158
|
+
try: () => JSON.parse(readText()),
|
|
159
|
+
catch: () => connectionFailure(key, "invalid_response", "The response body is not JSON."),
|
|
160
|
+
}).pipe(Effect.flatMap((value) => Schema.decodeUnknownEffect(schema)(value)), Effect.mapError((error) => error instanceof ConnectionError
|
|
161
|
+
? error
|
|
162
|
+
: connectionFailure(key, "invalid_response", `The response does not match the expected schema: ${error.message}`))),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Declares a connection the ontology's actions may call. `key` names a connection in the
|
|
167
|
+
* workspace's `connections/connections.py`. List the handle once in `defineOntology({ connections })`
|
|
168
|
+
* and in the `connections` of each action that calls it.
|
|
169
|
+
*/
|
|
170
|
+
export function connection(key, options) {
|
|
171
|
+
const service = Context.Service(`@segmentstream/ontology/Connection/${key}`);
|
|
172
|
+
const request = (input) => Effect.gen(function* () {
|
|
173
|
+
const client = yield* service;
|
|
174
|
+
const call = yield* Effect.try({
|
|
175
|
+
try: () => connectionCall(key, input),
|
|
176
|
+
catch: (error) => error instanceof ConnectionError
|
|
177
|
+
? error
|
|
178
|
+
: connectionFailure(key, "invalid_request", String(error)),
|
|
179
|
+
});
|
|
180
|
+
const reply = yield* client.request(call);
|
|
181
|
+
return connectionResponse(key, reply);
|
|
182
|
+
});
|
|
183
|
+
const method = (verb) => (path, options = {}) => request({ ...options, method: verb, path });
|
|
184
|
+
return {
|
|
185
|
+
[ConnectionTypeId]: ConnectionTypeId,
|
|
186
|
+
key,
|
|
187
|
+
description: options?.description,
|
|
188
|
+
delivers: options?.delivers === true,
|
|
189
|
+
service,
|
|
190
|
+
request,
|
|
191
|
+
stream: (input) => Effect.gen(function* () {
|
|
192
|
+
const client = yield* service;
|
|
193
|
+
const call = yield* Effect.try({
|
|
194
|
+
try: () => connectionCall(key, input),
|
|
195
|
+
catch: (cause) => cause instanceof ConnectionError
|
|
196
|
+
? cause
|
|
197
|
+
: connectionFailure(key, "invalid_request", "invalid_request", cause),
|
|
198
|
+
});
|
|
199
|
+
const reply = client.stream
|
|
200
|
+
? yield* client.stream(call)
|
|
201
|
+
: bufferedStream(yield* client.request(call));
|
|
202
|
+
return {
|
|
203
|
+
...reply,
|
|
204
|
+
ok: reply.status >= 200 && reply.status < 300,
|
|
205
|
+
header: (name) => reply.headers.find(([candidate]) => candidate.toLowerCase() === name.toLowerCase())?.[1],
|
|
206
|
+
};
|
|
207
|
+
}),
|
|
208
|
+
get: method("GET"),
|
|
209
|
+
post: method("POST"),
|
|
210
|
+
put: method("PUT"),
|
|
211
|
+
patch: method("PATCH"),
|
|
212
|
+
delete: method("DELETE"),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
export function isConnection(value) {
|
|
216
|
+
return typeof value === "object" && value !== null && ConnectionTypeId in value;
|
|
217
|
+
}
|
|
218
|
+
export function bufferedStream(reply) {
|
|
219
|
+
return { ...reply, body: Stream.fromIterable([reply.body]) };
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The clients of the given handles over one transport: what `prepare` runs with. Only these
|
|
223
|
+
* connections can be called; the transport is never exposed to the action.
|
|
224
|
+
*/
|
|
225
|
+
export function connectionContext(handles, transport, options = {}) {
|
|
226
|
+
let context = Context.empty();
|
|
227
|
+
for (const handle of handles) {
|
|
228
|
+
const admit = (call) => {
|
|
229
|
+
if (options.readOnly !== true) {
|
|
230
|
+
return Effect.void;
|
|
231
|
+
}
|
|
232
|
+
return Effect.try({
|
|
233
|
+
try: () => new URL(call.path, "https://connection.invalid"),
|
|
234
|
+
catch: (cause) => connectionFailure(handle.key, "invalid_request", "The connection path is invalid.", cause),
|
|
235
|
+
}).pipe(Effect.flatMap((url) => {
|
|
236
|
+
// Match the proxy's policy, including attempts to tunnel writes through GET.
|
|
237
|
+
if (!["GET", "HEAD", "OPTIONS"].includes(call.method) ||
|
|
238
|
+
call.body.byteLength > 0 ||
|
|
239
|
+
call.headers.some(([name]) => name.toLowerCase().includes("method")) ||
|
|
240
|
+
[...url.searchParams.keys()].some((name) => ["method", "_method"].includes(name.toLowerCase()))) {
|
|
241
|
+
return Effect.fail(connectionFailure(handle.key, "invalid_request", "This action's connections are read-only."));
|
|
242
|
+
}
|
|
243
|
+
return Effect.void;
|
|
244
|
+
}));
|
|
245
|
+
};
|
|
246
|
+
context = Context.add(context, handle.service, {
|
|
247
|
+
request: (call) => admit(call).pipe(Effect.andThen(() => transport.request({ ...call, connection: handle.key }))),
|
|
248
|
+
stream: (call) => admit(call).pipe(Effect.andThen(() => transport.stream
|
|
249
|
+
? transport.stream({ ...call, connection: handle.key })
|
|
250
|
+
: transport
|
|
251
|
+
.request({ ...call, connection: handle.key })
|
|
252
|
+
.pipe(Effect.map(bufferedStream)))),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return context;
|
|
256
|
+
}
|
|
257
|
+
function stubReply(response) {
|
|
258
|
+
if ("body" in response && response.body instanceof Uint8Array) {
|
|
259
|
+
return response;
|
|
260
|
+
}
|
|
261
|
+
const stub = response;
|
|
262
|
+
const headers = headerPairs(stub.headers);
|
|
263
|
+
let body = new Uint8Array();
|
|
264
|
+
if (stub.json !== undefined) {
|
|
265
|
+
body = encoder.encode(JSON.stringify(stub.json));
|
|
266
|
+
if (!hasHeader(headers, "content-type")) {
|
|
267
|
+
headers.push(["content-type", "application/json"]);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else if (stub.text !== undefined) {
|
|
271
|
+
body = encoder.encode(stub.text);
|
|
272
|
+
}
|
|
273
|
+
return { status: stub.status ?? 200, headers, body };
|
|
274
|
+
}
|
|
275
|
+
export const Connections = {
|
|
276
|
+
/**
|
|
277
|
+
* A transport that answers with stubs by connection key, for runtime tests of actions that
|
|
278
|
+
* declare connections. A call to a connection without a stub fails the test.
|
|
279
|
+
*/
|
|
280
|
+
test: (stubs) => Layer.succeed(ConnectionTransport, {
|
|
281
|
+
request: (call) => {
|
|
282
|
+
const stub = stubs[call.connection];
|
|
283
|
+
if (stub === undefined) {
|
|
284
|
+
return Effect.die(new Error(`Connections.test has no stub for the connection ${call.connection}.`));
|
|
285
|
+
}
|
|
286
|
+
return stub({ ...call, text: decoder.decode(call.body) }).pipe(Effect.map(stubReply));
|
|
287
|
+
},
|
|
288
|
+
}),
|
|
289
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Runtime observations; authorization of the machine credential remains platform-owned. */
|
|
2
|
+
export interface DeploymentCapabilities {
|
|
3
|
+
readonly warehouseRead: boolean;
|
|
4
|
+
readonly pipelineRuns: boolean;
|
|
5
|
+
readonly connections: boolean;
|
|
6
|
+
readonly agents: boolean;
|
|
7
|
+
readonly workflows: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type DeploymentObservation = {
|
|
10
|
+
readonly target: "production";
|
|
11
|
+
readonly deploymentId?: string;
|
|
12
|
+
readonly capabilities: DeploymentCapabilities;
|
|
13
|
+
} | {
|
|
14
|
+
readonly target: "preview";
|
|
15
|
+
readonly deploymentId: string;
|
|
16
|
+
readonly expiresAt: string;
|
|
17
|
+
/**
|
|
18
|
+
* `local` when the preview runs on a developer's machine (`segmentstream dev`), where the
|
|
19
|
+
* Workflow SDK's local world records runs; absent on a hosted preview.
|
|
20
|
+
*/
|
|
21
|
+
readonly host?: "local";
|
|
22
|
+
readonly capabilities: DeploymentCapabilities;
|
|
23
|
+
};
|
|
24
|
+
export type DeploymentAdmissionCode = "preview_configuration_invalid" | "preview_expired" | "preview_capability_unavailable" | "preview_authentication_unavailable" | "preview_storage_binding_invalid";
|
|
25
|
+
/** Stable codes only: workspace code owns explanations and presentation. */
|
|
26
|
+
export declare class DeploymentAdmissionError extends Error {
|
|
27
|
+
readonly code: DeploymentAdmissionCode;
|
|
28
|
+
readonly capability?: keyof DeploymentCapabilities | undefined;
|
|
29
|
+
readonly _tag = "DeploymentAdmissionError";
|
|
30
|
+
constructor(code: DeploymentAdmissionCode, capability?: keyof DeploymentCapabilities | undefined);
|
|
31
|
+
get status(): number;
|
|
32
|
+
}
|
|
33
|
+
export declare function deploymentFromEnv(environment?: Readonly<Record<string, string | undefined>>): DeploymentObservation;
|
|
34
|
+
/** Recheck the deadline on every admission, including a warm process and cached sessions. */
|
|
35
|
+
export declare function requireDeploymentCapability(deployment: DeploymentObservation, capability?: keyof DeploymentCapabilities, now?: number): void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Stable codes only: workspace code owns explanations and presentation. */
|
|
2
|
+
export class DeploymentAdmissionError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
capability;
|
|
5
|
+
_tag = "DeploymentAdmissionError";
|
|
6
|
+
constructor(code, capability) {
|
|
7
|
+
super(code);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.capability = capability;
|
|
10
|
+
this.name = "DeploymentAdmissionError";
|
|
11
|
+
}
|
|
12
|
+
get status() {
|
|
13
|
+
return this.code === "preview_expired"
|
|
14
|
+
? 410
|
|
15
|
+
: this.code === "preview_configuration_invalid" ||
|
|
16
|
+
this.code === "preview_storage_binding_invalid"
|
|
17
|
+
? 503
|
|
18
|
+
: 403;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function deploymentFromEnv(environment = process.env) {
|
|
22
|
+
const target = environment.SEGMENTSTREAM_DEPLOYMENT_TARGET?.trim() || "production";
|
|
23
|
+
const deploymentId = environment.SEGMENTSTREAM_ONTOLOGY_DEPLOYMENT_ID?.trim();
|
|
24
|
+
if (target === "production") {
|
|
25
|
+
return Object.freeze({
|
|
26
|
+
target,
|
|
27
|
+
...(deploymentId ? { deploymentId } : {}),
|
|
28
|
+
capabilities: Object.freeze({
|
|
29
|
+
warehouseRead: true,
|
|
30
|
+
pipelineRuns: true,
|
|
31
|
+
connections: true,
|
|
32
|
+
agents: true,
|
|
33
|
+
workflows: true,
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const expiresAt = environment.SEGMENTSTREAM_PREVIEW_EXPIRES_AT?.trim();
|
|
38
|
+
const host = environment.SEGMENTSTREAM_PREVIEW_HOST?.trim() || undefined;
|
|
39
|
+
if (target !== "preview" ||
|
|
40
|
+
(host !== undefined && host !== "local") ||
|
|
41
|
+
!deploymentId ||
|
|
42
|
+
!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(deploymentId) ||
|
|
43
|
+
!expiresAt ||
|
|
44
|
+
!/^\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:\d{2})$/.test(expiresAt) ||
|
|
45
|
+
!Number.isFinite(Date.parse(expiresAt))) {
|
|
46
|
+
throw new DeploymentAdmissionError("preview_configuration_invalid");
|
|
47
|
+
}
|
|
48
|
+
return Object.freeze({
|
|
49
|
+
target,
|
|
50
|
+
deploymentId,
|
|
51
|
+
expiresAt,
|
|
52
|
+
...(host === undefined ? {} : { host }),
|
|
53
|
+
capabilities: Object.freeze({
|
|
54
|
+
warehouseRead: true,
|
|
55
|
+
pipelineRuns: false,
|
|
56
|
+
connections: false,
|
|
57
|
+
agents: false,
|
|
58
|
+
workflows: true,
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Recheck the deadline on every admission, including a warm process and cached sessions. */
|
|
63
|
+
export function requireDeploymentCapability(deployment, capability, now = Date.now()) {
|
|
64
|
+
if (deployment.target !== "preview") {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!Number.isFinite(now) ||
|
|
68
|
+
!Number.isFinite(Date.parse(deployment.expiresAt)) ||
|
|
69
|
+
now >= Date.parse(deployment.expiresAt)) {
|
|
70
|
+
throw new DeploymentAdmissionError("preview_expired");
|
|
71
|
+
}
|
|
72
|
+
// The preview profile is fixed; supplied flags cannot enable managed integrations.
|
|
73
|
+
if (capability !== undefined && capability !== "warehouseRead" && capability !== "workflows") {
|
|
74
|
+
throw new DeploymentAdmissionError("preview_capability_unavailable", capability);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const DIAGNOSTIC_CODES: readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"];
|
|
3
|
+
export type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[number];
|
|
4
|
+
/** A problem `check` found in an ontology definition. */
|
|
5
|
+
export declare const Diagnostic: Schema.Struct<{
|
|
6
|
+
readonly severity: Schema.Literals<readonly ["error", "warning", "info"]>;
|
|
7
|
+
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
8
|
+
/** Where the problem is, for example `lead.properties.status.options[1]`. */
|
|
9
|
+
readonly path: Schema.String;
|
|
10
|
+
readonly message: Schema.String;
|
|
11
|
+
}>;
|
|
12
|
+
export type Diagnostic = typeof Diagnostic.Type;
|
|
13
|
+
declare const InvalidOntology_base: Schema.Class<InvalidOntology, Schema.TaggedStruct<"InvalidOntology", {
|
|
14
|
+
readonly message: Schema.String;
|
|
15
|
+
readonly diagnostics: Schema.$Array<Schema.Struct<{
|
|
16
|
+
readonly severity: Schema.Literals<readonly ["error", "warning", "info"]>;
|
|
17
|
+
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
18
|
+
/** Where the problem is, for example `lead.properties.status.options[1]`. */
|
|
19
|
+
readonly path: Schema.String;
|
|
20
|
+
readonly message: Schema.String;
|
|
21
|
+
}>>;
|
|
22
|
+
}>, import("effect/Cause").YieldableError>;
|
|
23
|
+
/** `defineOntology` found errors. Every diagnostic, including warnings, is attached. */
|
|
24
|
+
export declare class InvalidOntology extends InvalidOntology_base {
|
|
25
|
+
}
|
|
26
|
+
export declare function formatDiagnostics(diagnostics: ReadonlyArray<Diagnostic>): string;
|
|
27
|
+
export {};
|