@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,704 @@
|
|
|
1
|
+
import { Cause, Context, Effect, Option, Predicate, Schema, SchemaIssue } from "effect";
|
|
2
|
+
import { HttpServerResponse } from "effect/unstable/http";
|
|
3
|
+
import { HttpApiError } from "effect/unstable/httpapi";
|
|
4
|
+
import { BatchErrorDetails, LimitErrorDetails, } from "../errors.js";
|
|
5
|
+
import { DeploymentAdmissionError } from "../deployment.js";
|
|
6
|
+
import { suggestionDetail } from "./name-suggestions.js";
|
|
7
|
+
/** The correlation id of the current request, in every error body and the `x-request-id` header. */
|
|
8
|
+
export class RequestId extends Context.Service()("@segmentstream/ontology/RequestId") {
|
|
9
|
+
}
|
|
10
|
+
const Issues = Schema.Array(Schema.Struct({
|
|
11
|
+
path: Schema.Array(Schema.Union([Schema.String, Schema.Number])),
|
|
12
|
+
message: Schema.String,
|
|
13
|
+
}));
|
|
14
|
+
/** The action's input failed validation and the request was not `validateOnly`. */
|
|
15
|
+
export class InvalidActionInput extends Schema.TaggedError()("InvalidActionInput", { issues: Issues }) {
|
|
16
|
+
}
|
|
17
|
+
/** The body of an action request is not `{ input, options? }`. */
|
|
18
|
+
export class InvalidRequestBody extends Schema.TaggedError()("InvalidRequestBody", {
|
|
19
|
+
reason: Schema.Literals(["invalid_json", "invalid_request", "unsupported_media_type"]),
|
|
20
|
+
issues: Issues,
|
|
21
|
+
}) {
|
|
22
|
+
}
|
|
23
|
+
/** A client asked `POST /api/ontology/sign-in/check` too often; it may ask again after this. */
|
|
24
|
+
export class SignInCheckLimited extends Schema.TaggedError()("SignInCheckLimited", { retryAfterSeconds: Schema.Number }) {
|
|
25
|
+
}
|
|
26
|
+
/** A metric query the ontology cannot answer; the reason is written for the caller. */
|
|
27
|
+
export class InvalidMetricQuery extends Schema.TaggedError()("InvalidMetricQuery", { reason: Schema.String }) {
|
|
28
|
+
}
|
|
29
|
+
/** The caller lacks `<entity>:read` on entities a metric query reads: every such permission. */
|
|
30
|
+
export class ReadDenied extends Schema.TaggedError()("ReadDenied", {
|
|
31
|
+
permissions: Schema.Array(Schema.String),
|
|
32
|
+
}) {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Why a scope cannot be applied to a metric query: it follows a path from `me` (`me_path`), is too
|
|
36
|
+
* large to send (`too_large`), SegmentStream cannot plan it in the warehouse (`unplannable`), or
|
|
37
|
+
* SegmentStream did not confirm it applied it (`unconfirmed`). A code, so that a workspace words it.
|
|
38
|
+
*/
|
|
39
|
+
export const ScopedMetricQueryReason = Schema.Literals([
|
|
40
|
+
"me_path",
|
|
41
|
+
"too_large",
|
|
42
|
+
"unplannable",
|
|
43
|
+
"unconfirmed",
|
|
44
|
+
]);
|
|
45
|
+
/**
|
|
46
|
+
* The caller reads an entity a metric query touches only within a scope the query cannot apply:
|
|
47
|
+
* answering would count or sum rows the caller's lists leave out. `reason` says why, when known.
|
|
48
|
+
*/
|
|
49
|
+
export class ScopedMetricQueryUnavailable extends Schema.TaggedError()("ScopedMetricQueryUnavailable", { entity: Schema.String, reason: Schema.optional(ScopedMetricQueryReason) }) {
|
|
50
|
+
}
|
|
51
|
+
/** The deployment has no workspace app credential: previews and local development. */
|
|
52
|
+
export class MetricQueriesUnavailable extends Schema.TaggedError()("MetricQueriesUnavailable", {}) {
|
|
53
|
+
}
|
|
54
|
+
/** A warehouse observation could not be read; no database record is substituted. */
|
|
55
|
+
export class WarehouseReadUnavailable extends Schema.TaggedError()("WarehouseReadUnavailable", {
|
|
56
|
+
reason: Schema.Literals(["not_configured", "upstream", "limited"]),
|
|
57
|
+
retryAfterSeconds: Schema.optionalKey(Schema.Number),
|
|
58
|
+
cause: Schema.optionalKey(Schema.Unknown),
|
|
59
|
+
}) {
|
|
60
|
+
}
|
|
61
|
+
/** A principal ran more metric queries than its window allows; it may run more after this. */
|
|
62
|
+
export class MetricQueryLimited extends Schema.TaggedError()("MetricQueryLimited", {
|
|
63
|
+
retryAfterSeconds: Schema.Number,
|
|
64
|
+
}) {
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* SegmentStream did not answer a metric query usably, or its answer faults the deployment rather than
|
|
68
|
+
* the caller. The operator log keeps the details; the caller learns only the reason.
|
|
69
|
+
*/
|
|
70
|
+
export class MetricQueryUpstreamUnavailable extends Schema.TaggedError()("MetricQueryUpstreamUnavailable", {
|
|
71
|
+
reason: Schema.Literals([
|
|
72
|
+
"unreachable",
|
|
73
|
+
"timeout",
|
|
74
|
+
"invalid_response",
|
|
75
|
+
"credential_rejected",
|
|
76
|
+
"upstream_misconfigured",
|
|
77
|
+
]),
|
|
78
|
+
status: Schema.optionalKey(Schema.Number),
|
|
79
|
+
}) {
|
|
80
|
+
}
|
|
81
|
+
const UPSTREAM_DETAILS = {
|
|
82
|
+
unreachable: "SegmentStream could not be reached. Try again shortly.",
|
|
83
|
+
timeout: "SegmentStream did not answer in time. Try again shortly.",
|
|
84
|
+
invalid_response: "SegmentStream answered with an unexpected response.",
|
|
85
|
+
credential_rejected: "SegmentStream refused the deployment's credential.",
|
|
86
|
+
upstream_misconfigured: "SegmentStream does not serve metric queries for this deployment.",
|
|
87
|
+
};
|
|
88
|
+
/** `a`, `a and b`, `a, b and c`. */
|
|
89
|
+
function listed(values) {
|
|
90
|
+
return values.length <= 1
|
|
91
|
+
? values.join("")
|
|
92
|
+
: `${values.slice(0, -1).join(", ")} and ${values.at(-1)}`;
|
|
93
|
+
}
|
|
94
|
+
/** Only the declared safe locations cross a transport, even for structurally tagged failures. */
|
|
95
|
+
function batchDetails(error) {
|
|
96
|
+
const batch = error.batch;
|
|
97
|
+
if (!Schema.is(BatchErrorDetails)(batch)) {
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
batch: {
|
|
102
|
+
indices: batch.indices,
|
|
103
|
+
...(batch.fields === undefined ? {} : { fields: batch.fields }),
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** The refusing limit and its numbers, in wire casing. */
|
|
108
|
+
function limitDetails(error) {
|
|
109
|
+
const limit = error.limit;
|
|
110
|
+
if (!Schema.is(LimitErrorDetails)(limit)) {
|
|
111
|
+
return {};
|
|
112
|
+
}
|
|
113
|
+
switch (limit.kind) {
|
|
114
|
+
case "storage_quota":
|
|
115
|
+
return {
|
|
116
|
+
limit: {
|
|
117
|
+
kind: limit.kind,
|
|
118
|
+
used_bytes: limit.usedBytes,
|
|
119
|
+
requested_bytes: limit.requestedBytes,
|
|
120
|
+
quota_bytes: limit.quotaBytes,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
case "pending_uploads":
|
|
124
|
+
return {
|
|
125
|
+
limit: {
|
|
126
|
+
kind: limit.kind,
|
|
127
|
+
pending: limit.pending,
|
|
128
|
+
max: limit.max,
|
|
129
|
+
...(limit.uploads === undefined
|
|
130
|
+
? {}
|
|
131
|
+
: {
|
|
132
|
+
uploads: limit.uploads.map((upload) => ({
|
|
133
|
+
id: upload.id,
|
|
134
|
+
filename: upload.filename,
|
|
135
|
+
expires_at: upload.expiresAt,
|
|
136
|
+
})),
|
|
137
|
+
}),
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
case "member_attachments":
|
|
141
|
+
return { limit: { kind: limit.kind, live: limit.live, max: limit.max } };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export function toServerResponse(response) {
|
|
145
|
+
return HttpServerResponse.jsonUnsafe(errorBodyForWire(response.body), {
|
|
146
|
+
status: response.status,
|
|
147
|
+
...(response.headers !== undefined ? { headers: response.headers } : {}),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
export function errorBodyForWire(body) {
|
|
151
|
+
const { requestId, ...rest } = body;
|
|
152
|
+
return { ...rest, request_id: requestId };
|
|
153
|
+
}
|
|
154
|
+
/** Issues of a schema failure, as `[{ path, message }]`. */
|
|
155
|
+
export function schemaIssues(issue) {
|
|
156
|
+
const formatted = SchemaIssue.makeFormatterStandardSchemaV1()(issue);
|
|
157
|
+
return formatted.issues.map((candidate) => ({
|
|
158
|
+
path: (candidate.path ?? []).map((segment) => {
|
|
159
|
+
const key = typeof segment === "object" && segment !== null ? segment.key : segment;
|
|
160
|
+
return typeof key === "number" ? key : String(key);
|
|
161
|
+
}),
|
|
162
|
+
message: candidate.message,
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
const REQUEST_PARTS = {
|
|
166
|
+
Params: "The path is invalid.",
|
|
167
|
+
Query: "The query parameters are invalid.",
|
|
168
|
+
Payload: "The request body is invalid.",
|
|
169
|
+
Headers: "The request headers are invalid.",
|
|
170
|
+
};
|
|
171
|
+
function isJsonParseFailure(issue) {
|
|
172
|
+
return (issue._tag === "InvalidValue" && issue.annotations?.message === "Expected a valid JSON body");
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* `challenge` is the `WWW-Authenticate` value; the MCP server's names its OAuth metadata, which is
|
|
176
|
+
* how a client learns where members authorize it.
|
|
177
|
+
*/
|
|
178
|
+
export function unauthorized(requestId, detail, challenge = 'Bearer realm="ontology"') {
|
|
179
|
+
return {
|
|
180
|
+
status: 401,
|
|
181
|
+
body: { error: "unauthorized", detail, requestId },
|
|
182
|
+
headers: { "www-authenticate": challenge },
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The token is valid but the `invited` sign-in policy turns its holder away: nobody invited them.
|
|
187
|
+
* The detail is written for the person, since the app shows it.
|
|
188
|
+
*/
|
|
189
|
+
export function notInvited(requestId) {
|
|
190
|
+
return {
|
|
191
|
+
status: 403,
|
|
192
|
+
body: { error: "not_invited", detail: "Ask your administrator for an invitation.", requestId },
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* A request that changes something came with the session cookie but not from the app's own pages.
|
|
197
|
+
* The cookie rides along with any request to the app's domain, so only its origin can vouch for it.
|
|
198
|
+
*/
|
|
199
|
+
export function crossOriginSession(requestId) {
|
|
200
|
+
return {
|
|
201
|
+
status: 403,
|
|
202
|
+
body: {
|
|
203
|
+
error: "forbidden",
|
|
204
|
+
detail: "The session cookie only authenticates requests from the app's own pages; send a bearer token.",
|
|
205
|
+
requestId,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/** The caller is authenticated but may not do this; the detail says why. */
|
|
210
|
+
export function forbidden(requestId, detail) {
|
|
211
|
+
return { status: 403, body: { error: "forbidden", detail, requestId } };
|
|
212
|
+
}
|
|
213
|
+
/** A client asked too often; it may ask again after `retryAfterSeconds`. */
|
|
214
|
+
export function rateLimited(requestId, detail, retryAfterSeconds) {
|
|
215
|
+
return {
|
|
216
|
+
status: 429,
|
|
217
|
+
body: { error: "rate_limited", detail, requestId },
|
|
218
|
+
headers: { "retry-after": String(retryAfterSeconds) },
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/** The resource does not exist, or not for this caller; the detail says what to do. */
|
|
222
|
+
export function notFound(requestId, detail) {
|
|
223
|
+
return { status: 404, body: { error: "not_found", detail, requestId } };
|
|
224
|
+
}
|
|
225
|
+
export function unavailable(requestId) {
|
|
226
|
+
return {
|
|
227
|
+
status: 503,
|
|
228
|
+
body: {
|
|
229
|
+
error: "service_unavailable",
|
|
230
|
+
detail: "Sign-in could not be verified right now. Try again shortly.",
|
|
231
|
+
requestId,
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/** File storage failed. The caller retries the same request; operators still log the cause. */
|
|
236
|
+
export function storageUnavailable(requestId) {
|
|
237
|
+
return {
|
|
238
|
+
status: 503,
|
|
239
|
+
body: {
|
|
240
|
+
error: "storage_unavailable",
|
|
241
|
+
detail: "File storage did not complete the request. Retry the same request.",
|
|
242
|
+
requestId,
|
|
243
|
+
retryable: true,
|
|
244
|
+
},
|
|
245
|
+
headers: { "retry-after": "5" },
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/** A failure of the file storage provider, which is answered as retryable but still logged. */
|
|
249
|
+
export function isStorageFailure(error) {
|
|
250
|
+
return Predicate.isTagged(error, "BlobStorageError");
|
|
251
|
+
}
|
|
252
|
+
export function internalError(requestId) {
|
|
253
|
+
return {
|
|
254
|
+
status: 500,
|
|
255
|
+
body: {
|
|
256
|
+
error: "internal_error",
|
|
257
|
+
detail: "The request failed. Quote the request id when you report it.",
|
|
258
|
+
requestId,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
export function routeNotFound(requestId, suggestions = []) {
|
|
263
|
+
return {
|
|
264
|
+
status: 404,
|
|
265
|
+
body: {
|
|
266
|
+
error: "not_found",
|
|
267
|
+
detail: suggestionDetail("There is no such ontology route.", suggestions),
|
|
268
|
+
requestId,
|
|
269
|
+
...(suggestions.length === 0 ? {} : { suggestions }),
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* A connection call failed and `prepare` did not handle it; nothing was written. A refusal by the
|
|
275
|
+
* platform (`not_granted`, `invalid_request`) is a fault of the deployment: it is not expected, so
|
|
276
|
+
* it is logged with its cause and answered as a 500. The
|
|
277
|
+
* caller learns which connection failed and why, never the provider's or the proxy's message.
|
|
278
|
+
*/
|
|
279
|
+
function connectionFailure(error, requestId) {
|
|
280
|
+
const connection = error.connection;
|
|
281
|
+
switch (error.reason) {
|
|
282
|
+
case "authorization_required":
|
|
283
|
+
return {
|
|
284
|
+
status: 409,
|
|
285
|
+
body: {
|
|
286
|
+
error: "connection_authorization_required",
|
|
287
|
+
detail: `Configure or authorize the ${connection} connection in SegmentStream.`,
|
|
288
|
+
requestId,
|
|
289
|
+
connection,
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
case "not_deployed":
|
|
293
|
+
return {
|
|
294
|
+
status: 409,
|
|
295
|
+
body: {
|
|
296
|
+
error: "connections_not_deployed",
|
|
297
|
+
detail: `Deploy the workspace connections with the ${connection} connection.`,
|
|
298
|
+
requestId,
|
|
299
|
+
connection,
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
case "unavailable":
|
|
303
|
+
case "timeout":
|
|
304
|
+
return {
|
|
305
|
+
status: 503,
|
|
306
|
+
body: {
|
|
307
|
+
error: "connection_unavailable",
|
|
308
|
+
detail: `The ${connection} connection is temporarily unavailable. Try again.`,
|
|
309
|
+
requestId,
|
|
310
|
+
connection,
|
|
311
|
+
retryable: true,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
case "refused":
|
|
315
|
+
return {
|
|
316
|
+
status: 503,
|
|
317
|
+
body: {
|
|
318
|
+
error: "connection_refused",
|
|
319
|
+
detail: `The ${connection} provider refused the request.`,
|
|
320
|
+
requestId,
|
|
321
|
+
connection,
|
|
322
|
+
retryable: false,
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
case "invalid_response":
|
|
326
|
+
return {
|
|
327
|
+
status: 502,
|
|
328
|
+
body: {
|
|
329
|
+
error: "connection_response_invalid",
|
|
330
|
+
detail: `The ${connection} provider answered with an unexpected response.`,
|
|
331
|
+
requestId,
|
|
332
|
+
connection,
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
default:
|
|
336
|
+
return undefined;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* The response for an expected failure, or `undefined` for anything else. Messages written for the
|
|
341
|
+
* caller (an action's rejection, schema issues about the request) are returned; everything else
|
|
342
|
+
* gets a fixed detail.
|
|
343
|
+
*/
|
|
344
|
+
export function expectedFailure(error, requestId) {
|
|
345
|
+
if (Predicate.isTagged(error, "DeploymentInterrupted")) {
|
|
346
|
+
const failure = error;
|
|
347
|
+
const identifiers = Object.fromEntries(Object.entries({
|
|
348
|
+
served_hash: failure.servedHash,
|
|
349
|
+
applied_hash: failure.appliedHash,
|
|
350
|
+
served_deployment_id: failure.servedDeploymentId,
|
|
351
|
+
applied_deployment_id: failure.appliedDeploymentId,
|
|
352
|
+
}).filter(([, value]) => typeof value === "string" && /^[A-Za-z0-9_.:-]{1,200}$/.test(value)));
|
|
353
|
+
return {
|
|
354
|
+
status: 409,
|
|
355
|
+
body: {
|
|
356
|
+
error: "deployment_interrupted",
|
|
357
|
+
detail: "deployment_interrupted",
|
|
358
|
+
requestId,
|
|
359
|
+
retryable: false,
|
|
360
|
+
...identifiers,
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
if (Predicate.isTagged(error, "DeploymentSwitching")) {
|
|
365
|
+
const failure = error;
|
|
366
|
+
const retryAfter = Number.isFinite(failure.retryAfter)
|
|
367
|
+
? Math.min(30, Math.max(1, Math.ceil(failure.retryAfter)))
|
|
368
|
+
: 5;
|
|
369
|
+
return {
|
|
370
|
+
status: 503,
|
|
371
|
+
body: {
|
|
372
|
+
error: "deployment_switching",
|
|
373
|
+
detail: "deployment_switching",
|
|
374
|
+
requestId,
|
|
375
|
+
retryable: true,
|
|
376
|
+
...(typeof failure.generation === "string" &&
|
|
377
|
+
/^[A-Za-z0-9_.:-]{1,200}$/.test(failure.generation)
|
|
378
|
+
? { generation: failure.generation }
|
|
379
|
+
: {}),
|
|
380
|
+
},
|
|
381
|
+
headers: { "retry-after": String(retryAfter) },
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
if (error instanceof DeploymentAdmissionError) {
|
|
385
|
+
return {
|
|
386
|
+
status: error.status,
|
|
387
|
+
body: {
|
|
388
|
+
error: error.code,
|
|
389
|
+
detail: error.code,
|
|
390
|
+
requestId,
|
|
391
|
+
...(error.capability ? { capability: error.capability } : {}),
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
if (HttpApiError.HttpApiSchemaError.is(error)) {
|
|
396
|
+
const issue = error.cause.issue;
|
|
397
|
+
if (isJsonParseFailure(issue)) {
|
|
398
|
+
return {
|
|
399
|
+
status: 400,
|
|
400
|
+
body: { error: "invalid_json", detail: "The request body is not valid JSON.", requestId },
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
status: 400,
|
|
405
|
+
body: {
|
|
406
|
+
error: "invalid_request",
|
|
407
|
+
detail: REQUEST_PARTS[error.kind] ?? "The request is invalid.",
|
|
408
|
+
requestId,
|
|
409
|
+
issues: schemaIssues(issue),
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
if (Predicate.isTagged(error, "InvalidRequestBody")) {
|
|
414
|
+
const { reason, issues } = error;
|
|
415
|
+
if (reason === "invalid_json") {
|
|
416
|
+
return {
|
|
417
|
+
status: 400,
|
|
418
|
+
body: { error: "invalid_json", detail: "The request body is not valid JSON.", requestId },
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
if (reason === "unsupported_media_type") {
|
|
422
|
+
return {
|
|
423
|
+
status: 415,
|
|
424
|
+
body: { error: "unsupported_media_type", detail: "Send application/json.", requestId },
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
status: 400,
|
|
429
|
+
body: { error: "invalid_request", detail: "The request body is invalid.", requestId, issues },
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
if (Predicate.isTagged(error, "SignInCheckLimited")) {
|
|
433
|
+
const { retryAfterSeconds } = error;
|
|
434
|
+
return {
|
|
435
|
+
status: 429,
|
|
436
|
+
body: {
|
|
437
|
+
error: "rate_limited",
|
|
438
|
+
detail: "Too many sign-in checks. Wait a minute, then try again.",
|
|
439
|
+
requestId,
|
|
440
|
+
},
|
|
441
|
+
headers: { "retry-after": String(retryAfterSeconds) },
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
if (Predicate.isTagged(error, "InvalidQuery")) {
|
|
445
|
+
return {
|
|
446
|
+
status: 400,
|
|
447
|
+
body: {
|
|
448
|
+
error: "invalid_request",
|
|
449
|
+
detail: "The query is invalid.",
|
|
450
|
+
requestId,
|
|
451
|
+
issues: error.issues,
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
if (Predicate.isTagged(error, "InvalidActionInput")) {
|
|
456
|
+
return {
|
|
457
|
+
status: 422,
|
|
458
|
+
body: {
|
|
459
|
+
error: "invalid_input",
|
|
460
|
+
detail: "The action's input is invalid.",
|
|
461
|
+
requestId,
|
|
462
|
+
issues: error.issues,
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
if (Predicate.isTagged(error, "TriggerInputInvalid")) {
|
|
467
|
+
const { trigger, issues } = error;
|
|
468
|
+
return {
|
|
469
|
+
status: 422,
|
|
470
|
+
body: {
|
|
471
|
+
error: "trigger_input_invalid",
|
|
472
|
+
detail: `The input action trigger ${trigger} maps is not one its workflow accepts.`,
|
|
473
|
+
requestId,
|
|
474
|
+
trigger,
|
|
475
|
+
issues,
|
|
476
|
+
},
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
if (Predicate.isTagged(error, "WorkflowRecoveryUnavailable")) {
|
|
480
|
+
return {
|
|
481
|
+
status: 503,
|
|
482
|
+
body: {
|
|
483
|
+
error: "workflow_recovery_unavailable",
|
|
484
|
+
detail: "The action was not run: the recovery run that guarantees its workflow starts could " +
|
|
485
|
+
"not be scheduled. Retry the same request.",
|
|
486
|
+
requestId,
|
|
487
|
+
retryable: true,
|
|
488
|
+
},
|
|
489
|
+
headers: { "retry-after": "5" },
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
if (Predicate.isTagged(error, "ActionRejected")) {
|
|
493
|
+
const message = String(error.message);
|
|
494
|
+
return {
|
|
495
|
+
status: 422,
|
|
496
|
+
body: {
|
|
497
|
+
error: "action_rejected",
|
|
498
|
+
detail: message,
|
|
499
|
+
requestId,
|
|
500
|
+
issues: [{ path: [], message }],
|
|
501
|
+
...batchDetails(error),
|
|
502
|
+
...limitDetails(error),
|
|
503
|
+
},
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
if (Predicate.isTagged(error, "PermissionDenied")) {
|
|
507
|
+
const { permission, updating } = error;
|
|
508
|
+
if (updating === true) {
|
|
509
|
+
return {
|
|
510
|
+
status: 503,
|
|
511
|
+
body: {
|
|
512
|
+
error: "ontology_updating",
|
|
513
|
+
detail: "The app is being updated. Retry the same request shortly.",
|
|
514
|
+
requestId,
|
|
515
|
+
retryable: true,
|
|
516
|
+
},
|
|
517
|
+
headers: { "retry-after": "5" },
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
return {
|
|
521
|
+
status: 403,
|
|
522
|
+
body: {
|
|
523
|
+
error: "forbidden",
|
|
524
|
+
detail: typeof permission === "string"
|
|
525
|
+
? `${permission} is required.`
|
|
526
|
+
: "Your permissions do not allow this.",
|
|
527
|
+
requestId,
|
|
528
|
+
},
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
if (Predicate.isTagged(error, "ScopeViolated")) {
|
|
532
|
+
const { entity, permission } = error;
|
|
533
|
+
return {
|
|
534
|
+
status: 403,
|
|
535
|
+
body: {
|
|
536
|
+
error: "forbidden",
|
|
537
|
+
detail: typeof permission === "string"
|
|
538
|
+
? `${permission} does not cover the record as the change would leave it.`
|
|
539
|
+
: "Your permissions do not cover the record as the change would leave it.",
|
|
540
|
+
requestId,
|
|
541
|
+
...(typeof entity === "string" ? { entity } : {}),
|
|
542
|
+
...(typeof permission === "string" ? { permission } : {}),
|
|
543
|
+
...batchDetails(error),
|
|
544
|
+
},
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
if (Predicate.isTagged(error, "ScopedMetricQueryUnavailable")) {
|
|
548
|
+
const { entity, reason } = error;
|
|
549
|
+
return {
|
|
550
|
+
status: 403,
|
|
551
|
+
body: {
|
|
552
|
+
error: "scoped_aggregate_unavailable",
|
|
553
|
+
detail: `Your read of ${entity} is scoped, and this metric query cannot apply the scope; ` +
|
|
554
|
+
`list ${entity} records instead.`,
|
|
555
|
+
requestId,
|
|
556
|
+
entity,
|
|
557
|
+
...(reason === undefined ? {} : { reason }),
|
|
558
|
+
},
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
if (Predicate.isTagged(error, "ReadDenied")) {
|
|
562
|
+
const { permissions } = error;
|
|
563
|
+
return {
|
|
564
|
+
status: 403,
|
|
565
|
+
body: {
|
|
566
|
+
error: "forbidden",
|
|
567
|
+
detail: `${listed(permissions)} ${permissions.length === 1 ? "is" : "are"} required.`,
|
|
568
|
+
requestId,
|
|
569
|
+
permissions,
|
|
570
|
+
},
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
if (Predicate.isTagged(error, "MetricQueryLimited")) {
|
|
574
|
+
const { retryAfterSeconds } = error;
|
|
575
|
+
return {
|
|
576
|
+
status: 429,
|
|
577
|
+
body: {
|
|
578
|
+
error: "rate_limited",
|
|
579
|
+
detail: `Too many metric queries. Wait ${retryAfterSeconds} seconds, then try again.`,
|
|
580
|
+
requestId,
|
|
581
|
+
retryable: true,
|
|
582
|
+
},
|
|
583
|
+
headers: { "retry-after": String(retryAfterSeconds) },
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
if (Predicate.isTagged(error, "InvalidMetricQuery")) {
|
|
587
|
+
return {
|
|
588
|
+
status: 400,
|
|
589
|
+
body: {
|
|
590
|
+
error: "invalid_aggregate_query",
|
|
591
|
+
detail: error.reason,
|
|
592
|
+
requestId,
|
|
593
|
+
},
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
if (Predicate.isTagged(error, "MetricQueriesUnavailable")) {
|
|
597
|
+
return {
|
|
598
|
+
status: 503,
|
|
599
|
+
body: {
|
|
600
|
+
error: "aggregate_unavailable",
|
|
601
|
+
detail: "Metric queries are available in production deployments.",
|
|
602
|
+
requestId,
|
|
603
|
+
retryable: false,
|
|
604
|
+
},
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
if (Predicate.isTagged(error, "WarehouseReadUnavailable")) {
|
|
608
|
+
const failure = error;
|
|
609
|
+
return failure.reason === "limited"
|
|
610
|
+
? rateLimited(requestId, "Too many warehouse record reads.", failure.retryAfterSeconds ?? 60)
|
|
611
|
+
: {
|
|
612
|
+
status: 503,
|
|
613
|
+
body: {
|
|
614
|
+
error: "warehouse_read_unavailable",
|
|
615
|
+
detail: failure.reason === "not_configured"
|
|
616
|
+
? "Warehouse record reads require a production workspace credential."
|
|
617
|
+
: "The warehouse could not complete this record read. Try again shortly.",
|
|
618
|
+
requestId,
|
|
619
|
+
retryable: failure.reason !== "not_configured",
|
|
620
|
+
},
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
if (Predicate.isTagged(error, "ConversationArchiveUnavailable")) {
|
|
624
|
+
return {
|
|
625
|
+
status: 502,
|
|
626
|
+
body: {
|
|
627
|
+
error: "conversation_archive_unavailable",
|
|
628
|
+
detail: "The conversation archive is unavailable. Try again shortly.",
|
|
629
|
+
requestId,
|
|
630
|
+
retryable: true,
|
|
631
|
+
},
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
if (Predicate.isTagged(error, "MetricQueryUpstreamUnavailable")) {
|
|
635
|
+
const { reason } = error;
|
|
636
|
+
return {
|
|
637
|
+
status: 502,
|
|
638
|
+
body: {
|
|
639
|
+
error: "aggregate_upstream_unavailable",
|
|
640
|
+
detail: UPSTREAM_DETAILS[reason],
|
|
641
|
+
requestId,
|
|
642
|
+
retryable: reason === "unreachable" || reason === "timeout",
|
|
643
|
+
},
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
if (Predicate.isTagged(error, "ConnectionError")) {
|
|
647
|
+
return connectionFailure(error, requestId);
|
|
648
|
+
}
|
|
649
|
+
if (Predicate.isTagged(error, "NotFound")) {
|
|
650
|
+
const { entity, id } = error;
|
|
651
|
+
return {
|
|
652
|
+
status: 404,
|
|
653
|
+
body: {
|
|
654
|
+
error: "not_found",
|
|
655
|
+
detail: "The record was not found.",
|
|
656
|
+
requestId,
|
|
657
|
+
...(typeof entity === "string" ? { entity } : {}),
|
|
658
|
+
...(typeof id === "string" ? { id } : {}),
|
|
659
|
+
...batchDetails(error),
|
|
660
|
+
},
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
if (Predicate.isTagged(error, "Conflict")) {
|
|
664
|
+
const { entity, property, retryAfter } = error;
|
|
665
|
+
const wait = typeof retryAfter === "number" ? retryAfter : undefined;
|
|
666
|
+
return {
|
|
667
|
+
status: 409,
|
|
668
|
+
body: {
|
|
669
|
+
error: "conflict",
|
|
670
|
+
detail: wait === undefined
|
|
671
|
+
? "The change conflicts with existing records."
|
|
672
|
+
: "Another attempt holds the record. Retry the same request after retry_after seconds.",
|
|
673
|
+
requestId,
|
|
674
|
+
...(typeof entity === "string" ? { entity } : {}),
|
|
675
|
+
...(typeof property === "string" ? { property } : {}),
|
|
676
|
+
...(wait === undefined ? {} : { retryable: true, retry_after: wait }),
|
|
677
|
+
...batchDetails(error),
|
|
678
|
+
},
|
|
679
|
+
...(wait === undefined ? {} : { headers: { "retry-after": String(wait) } }),
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
return undefined;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Turns a failed request into a response. Expected failures map to their status; anything else is
|
|
686
|
+
* logged with the full cause and answered with a sanitized 500 that carries only the request id.
|
|
687
|
+
* Interruptions stay interruptions: the client is gone.
|
|
688
|
+
*/
|
|
689
|
+
export function failureResponse(cause, requestId) {
|
|
690
|
+
if (Cause.hasInterruptsOnly(cause)) {
|
|
691
|
+
return Effect.failCause(cause);
|
|
692
|
+
}
|
|
693
|
+
const typedFailure = Option.getOrUndefined(Cause.findErrorOption(cause));
|
|
694
|
+
const defect = typedFailure === undefined ? Cause.squash(cause) : undefined;
|
|
695
|
+
const error = typedFailure ?? (defect instanceof DeploymentAdmissionError ? defect : undefined);
|
|
696
|
+
const expected = error === undefined ? undefined : expectedFailure(error, requestId);
|
|
697
|
+
if (expected !== undefined) {
|
|
698
|
+
return Effect.succeed(toServerResponse(expected));
|
|
699
|
+
}
|
|
700
|
+
if (isStorageFailure(error)) {
|
|
701
|
+
return Effect.logError("ontology.storage.failed", cause).pipe(Effect.annotateLogs({ requestId }), Effect.as(toServerResponse(storageUnavailable(requestId))));
|
|
702
|
+
}
|
|
703
|
+
return Effect.logError("ontology.request.failed", cause).pipe(Effect.annotateLogs({ requestId }), Effect.as(toServerResponse(internalError(requestId))));
|
|
704
|
+
}
|