@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,22 @@
|
|
|
1
|
+
import type { ChatDeliveryFactory } from "./chat/delivery.js";
|
|
2
|
+
import { Layer } from "effect";
|
|
3
|
+
import { HttpRouter } from "effect/unstable/http";
|
|
4
|
+
import { type SessionExchange, type TokenVerifier } from "./authentication.js";
|
|
5
|
+
import type { AfterCommitHook } from "./config.js";
|
|
6
|
+
import type { ConnectionTransportFactory } from "./connections.js";
|
|
7
|
+
import type { ApiPlan } from "./plan.js";
|
|
8
|
+
import type { ReplicationKick } from "./replication.js";
|
|
9
|
+
import { RequestId } from "./errors.js";
|
|
10
|
+
import { OntologyBackend } from "./runtime-contract.js";
|
|
11
|
+
interface MemberFileRoutesOptions {
|
|
12
|
+
readonly plan: ApiPlan;
|
|
13
|
+
readonly hooks: ReadonlyMap<string, AfterCommitHook>;
|
|
14
|
+
readonly connections: ConnectionTransportFactory;
|
|
15
|
+
readonly replicate: ReplicationKick;
|
|
16
|
+
readonly chatDelivery?: ChatDeliveryFactory | undefined;
|
|
17
|
+
readonly verifyToken: TokenVerifier;
|
|
18
|
+
readonly exchangeSession?: SessionExchange | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Authenticated users use these routes; the agent's receive/discard routes stay runtime-owned. */
|
|
21
|
+
export declare function memberFileRoutes(options: MemberFileRoutesOptions): Layer.Layer<never, never, OntologyBackend | HttpRouter.HttpRouter | HttpRouter.Request<"Requires", RequestId>>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Cause, Effect, Layer } from "effect";
|
|
2
|
+
import { HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
3
|
+
import { HttpApiBuilder, HttpApiSecurity } from "effect/unstable/httpapi";
|
|
4
|
+
import { withPrincipal } from "./authentication.js";
|
|
5
|
+
import { InvalidRequestBody, RequestId, failureResponse } from "./errors.js";
|
|
6
|
+
import { identityToken, makeOperations } from "./operations.js";
|
|
7
|
+
import { memberFileOperations } from "./member-files.js";
|
|
8
|
+
import { OntologyBackend } from "./runtime-contract.js";
|
|
9
|
+
/** Authenticated users use these routes; the agent's receive/discard routes stay runtime-owned. */
|
|
10
|
+
export function memberFileRoutes(options) {
|
|
11
|
+
return Layer.effectDiscard(Effect.gen(function* () {
|
|
12
|
+
const router = yield* HttpRouter.HttpRouter;
|
|
13
|
+
const backend = yield* OntologyBackend;
|
|
14
|
+
const run = memberFileOperations(backend, options.plan, makeOperations(backend, options.plan, options.hooks, options.connections, options.replicate, options.chatDelivery));
|
|
15
|
+
const route = (kind) => (request) => Effect.gen(function* () {
|
|
16
|
+
const bearer = yield* HttpApiBuilder.securityDecode(HttpApiSecurity.bearer).pipe(Effect.provideService(HttpServerRequest.HttpServerRequest, request));
|
|
17
|
+
const operation = Effect.gen(function* () {
|
|
18
|
+
const params = yield* HttpRouter.params;
|
|
19
|
+
let args = params;
|
|
20
|
+
if (kind === "attachments-list") {
|
|
21
|
+
const query = Object.fromEntries(new URL(request.url, "https://app.invalid").searchParams);
|
|
22
|
+
args = {
|
|
23
|
+
...query,
|
|
24
|
+
...(query.limit === undefined ? {} : { limit: Number(query.limit) }),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else if (kind === "attachments-promote") {
|
|
28
|
+
const body = yield* request.json.pipe(Effect.mapError(() => new InvalidRequestBody({ reason: "invalid_json", issues: [] })));
|
|
29
|
+
args =
|
|
30
|
+
typeof body === "object" && body !== null && !Array.isArray(body)
|
|
31
|
+
? { ...body, id: params.id }
|
|
32
|
+
: body;
|
|
33
|
+
}
|
|
34
|
+
const answer = yield* run(kind, args, identityToken(request));
|
|
35
|
+
return HttpServerResponse.jsonUnsafe(answer, {
|
|
36
|
+
headers: { "cache-control": "private, no-store" },
|
|
37
|
+
});
|
|
38
|
+
}).pipe(Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause)
|
|
39
|
+
? Effect.failCause(cause)
|
|
40
|
+
: Effect.flatMap(RequestId, (id) => failureResponse(cause, id))));
|
|
41
|
+
return yield* withPrincipal(bearer, options.verifyToken, backend, operation, {
|
|
42
|
+
session: { request, exchange: options.exchangeSession },
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
yield* router.add("GET", "/api/ontology/attachments", route("attachments-list"));
|
|
46
|
+
yield* router.add("GET", "/api/ontology/attachments/:id", route("attachments-get"));
|
|
47
|
+
yield* router.add("GET", "/api/ontology/attachments/:id/download", route("attachments-download"));
|
|
48
|
+
yield* router.add("POST", "/api/ontology/attachments/:id/promote", route("attachments-promote"));
|
|
49
|
+
yield* router.add("GET", "/api/ontology/files/:entity/:id/:property", route("files-download"));
|
|
50
|
+
yield* router.add("GET", "/api/ontology/files/:entity/:id", route("files-download"));
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { CurrentPrincipal } from "./authentication.js";
|
|
3
|
+
import { RequestId } from "./errors.js";
|
|
4
|
+
import type { Operations } from "./operations.js";
|
|
5
|
+
import type { ApiPlan } from "./plan.js";
|
|
6
|
+
import type { OntologyBackend } from "./runtime-contract.js";
|
|
7
|
+
export declare const AttachmentFilters: Schema.Struct<{
|
|
8
|
+
readonly conversation: Schema.optionalKey<Schema.String>;
|
|
9
|
+
readonly sender_id: Schema.optionalKey<Schema.String>;
|
|
10
|
+
readonly from: Schema.optionalKey<Schema.String>;
|
|
11
|
+
readonly to: Schema.optionalKey<Schema.String>;
|
|
12
|
+
readonly before: Schema.optionalKey<Schema.String>;
|
|
13
|
+
readonly limit: Schema.optionalKey<Schema.Int>;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const MEMBER_FILE_SCHEMAS: {
|
|
16
|
+
"attachments-list": Schema.Struct<{
|
|
17
|
+
readonly conversation: Schema.optionalKey<Schema.String>;
|
|
18
|
+
readonly sender_id: Schema.optionalKey<Schema.String>;
|
|
19
|
+
readonly from: Schema.optionalKey<Schema.String>;
|
|
20
|
+
readonly to: Schema.optionalKey<Schema.String>;
|
|
21
|
+
readonly before: Schema.optionalKey<Schema.String>;
|
|
22
|
+
readonly limit: Schema.optionalKey<Schema.Int>;
|
|
23
|
+
}>;
|
|
24
|
+
"attachments-get": Schema.Struct<{
|
|
25
|
+
readonly id: Schema.String;
|
|
26
|
+
}>;
|
|
27
|
+
"attachments-download": Schema.Struct<{
|
|
28
|
+
readonly id: Schema.String;
|
|
29
|
+
}>;
|
|
30
|
+
"attachments-promote": Schema.Struct<{
|
|
31
|
+
readonly id: Schema.String;
|
|
32
|
+
readonly entity: Schema.String;
|
|
33
|
+
readonly action: Schema.String;
|
|
34
|
+
readonly input: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>;
|
|
35
|
+
readonly field: Schema.optionalKey<Schema.String>;
|
|
36
|
+
readonly record_id: Schema.optionalKey<Schema.String>;
|
|
37
|
+
}>;
|
|
38
|
+
"files-download": Schema.Struct<{
|
|
39
|
+
readonly entity: Schema.String;
|
|
40
|
+
readonly id: Schema.String;
|
|
41
|
+
readonly property: Schema.optionalKey<Schema.String>;
|
|
42
|
+
}>;
|
|
43
|
+
"files-upload": Schema.Struct<{
|
|
44
|
+
readonly entity: Schema.String;
|
|
45
|
+
readonly action: Schema.String;
|
|
46
|
+
readonly property: Schema.optionalKey<Schema.String>;
|
|
47
|
+
readonly record_id: Schema.optionalKey<Schema.String>;
|
|
48
|
+
readonly create_intent: Schema.optionalKey<Schema.String>;
|
|
49
|
+
readonly idempotency_key: Schema.optionalKey<Schema.String>;
|
|
50
|
+
readonly filename: Schema.String;
|
|
51
|
+
readonly content_type: Schema.String;
|
|
52
|
+
readonly size: Schema.Int;
|
|
53
|
+
}>;
|
|
54
|
+
"files-upload-list": Schema.$Record<Schema.String, Schema.Never>;
|
|
55
|
+
"files-upload-get": Schema.Struct<{
|
|
56
|
+
readonly id: Schema.String;
|
|
57
|
+
}>;
|
|
58
|
+
"files-upload-complete": Schema.Struct<{
|
|
59
|
+
readonly id: Schema.String;
|
|
60
|
+
}>;
|
|
61
|
+
"files-upload-cancel": Schema.Struct<{
|
|
62
|
+
readonly id: Schema.String;
|
|
63
|
+
}>;
|
|
64
|
+
};
|
|
65
|
+
export type MemberFileOperation = keyof typeof MEMBER_FILE_SCHEMAS;
|
|
66
|
+
export declare function grantForWire(grant: {
|
|
67
|
+
url: string;
|
|
68
|
+
method: string;
|
|
69
|
+
headers: Readonly<Record<string, string>>;
|
|
70
|
+
expiresAt: string;
|
|
71
|
+
}): {
|
|
72
|
+
url: string;
|
|
73
|
+
method: string;
|
|
74
|
+
headers: Readonly<Record<string, string>>;
|
|
75
|
+
expires_at: string;
|
|
76
|
+
};
|
|
77
|
+
export declare function attachmentForWire(attachment: import("../storage/attachments.js").AttachmentView): {
|
|
78
|
+
id: string;
|
|
79
|
+
filename: string;
|
|
80
|
+
content_type: string;
|
|
81
|
+
size: number;
|
|
82
|
+
sha256: string;
|
|
83
|
+
state: string;
|
|
84
|
+
created_at: string;
|
|
85
|
+
expires_at: string;
|
|
86
|
+
promotion: unknown;
|
|
87
|
+
conversation: string | undefined;
|
|
88
|
+
sender_id: string | undefined;
|
|
89
|
+
};
|
|
90
|
+
/** The member REST and MCP surfaces run the same runtime operations and action pipeline. */
|
|
91
|
+
export declare function memberFileOperations(backend: OntologyBackend["Service"], plan: ApiPlan, operations: Operations): (kind: MemberFileOperation, args: unknown, identityToken?: string) => Effect.Effect<{
|
|
92
|
+
readonly uploads: readonly {
|
|
93
|
+
readonly id: string;
|
|
94
|
+
readonly state: string;
|
|
95
|
+
readonly filename: string;
|
|
96
|
+
readonly content_type: string;
|
|
97
|
+
readonly size: number;
|
|
98
|
+
readonly entity: string;
|
|
99
|
+
readonly property: string;
|
|
100
|
+
readonly action: string;
|
|
101
|
+
readonly record_id: string | null;
|
|
102
|
+
readonly create_intent: string | null;
|
|
103
|
+
readonly created_at: string;
|
|
104
|
+
readonly expires_at: string;
|
|
105
|
+
readonly awaiting_action: boolean;
|
|
106
|
+
}[];
|
|
107
|
+
readonly pending: number;
|
|
108
|
+
readonly max: number;
|
|
109
|
+
} | {
|
|
110
|
+
download: {
|
|
111
|
+
url: string;
|
|
112
|
+
method: string;
|
|
113
|
+
headers: Readonly<Record<string, string>>;
|
|
114
|
+
expires_at: string;
|
|
115
|
+
};
|
|
116
|
+
file: {
|
|
117
|
+
id: string;
|
|
118
|
+
entity: string;
|
|
119
|
+
property: string;
|
|
120
|
+
revision_id: string;
|
|
121
|
+
filename: string;
|
|
122
|
+
content_type: string;
|
|
123
|
+
size: number;
|
|
124
|
+
sha256: string;
|
|
125
|
+
};
|
|
126
|
+
upload?: undefined;
|
|
127
|
+
attachments?: undefined;
|
|
128
|
+
nextCursor?: undefined;
|
|
129
|
+
attachment?: undefined;
|
|
130
|
+
} | {
|
|
131
|
+
upload: {
|
|
132
|
+
ticket?: {
|
|
133
|
+
upload_id: string;
|
|
134
|
+
} | undefined;
|
|
135
|
+
id: string;
|
|
136
|
+
state: string;
|
|
137
|
+
expires_at: string;
|
|
138
|
+
};
|
|
139
|
+
attachments?: undefined;
|
|
140
|
+
nextCursor?: undefined;
|
|
141
|
+
attachment?: undefined;
|
|
142
|
+
download?: undefined;
|
|
143
|
+
} | {
|
|
144
|
+
options: {
|
|
145
|
+
create_intent?: string | undefined;
|
|
146
|
+
idempotency_key: string;
|
|
147
|
+
};
|
|
148
|
+
transfer?: {
|
|
149
|
+
url: string;
|
|
150
|
+
method: string;
|
|
151
|
+
headers: Readonly<Record<string, string>>;
|
|
152
|
+
expires_at: string;
|
|
153
|
+
} | undefined;
|
|
154
|
+
upload: {
|
|
155
|
+
ticket?: {
|
|
156
|
+
upload_id: string;
|
|
157
|
+
} | undefined;
|
|
158
|
+
id: string;
|
|
159
|
+
state: string;
|
|
160
|
+
expires_at: string;
|
|
161
|
+
};
|
|
162
|
+
attachments?: undefined;
|
|
163
|
+
nextCursor?: undefined;
|
|
164
|
+
attachment?: undefined;
|
|
165
|
+
download?: undefined;
|
|
166
|
+
} | {
|
|
167
|
+
attachments: {
|
|
168
|
+
id: string;
|
|
169
|
+
filename: string;
|
|
170
|
+
content_type: string;
|
|
171
|
+
size: number;
|
|
172
|
+
sha256: string;
|
|
173
|
+
state: string;
|
|
174
|
+
created_at: string;
|
|
175
|
+
expires_at: string;
|
|
176
|
+
promotion: unknown;
|
|
177
|
+
conversation: string | undefined;
|
|
178
|
+
sender_id: string | undefined;
|
|
179
|
+
}[];
|
|
180
|
+
nextCursor: string | null;
|
|
181
|
+
upload?: undefined;
|
|
182
|
+
attachment?: undefined;
|
|
183
|
+
download?: undefined;
|
|
184
|
+
} | {
|
|
185
|
+
attachment: {
|
|
186
|
+
id: string;
|
|
187
|
+
filename: string;
|
|
188
|
+
content_type: string;
|
|
189
|
+
size: number;
|
|
190
|
+
sha256: string;
|
|
191
|
+
state: string;
|
|
192
|
+
created_at: string;
|
|
193
|
+
expires_at: string;
|
|
194
|
+
promotion: unknown;
|
|
195
|
+
conversation: string | undefined;
|
|
196
|
+
sender_id: string | undefined;
|
|
197
|
+
};
|
|
198
|
+
deduplicated: boolean;
|
|
199
|
+
result: {} | null;
|
|
200
|
+
upload?: undefined;
|
|
201
|
+
attachments?: undefined;
|
|
202
|
+
nextCursor?: undefined;
|
|
203
|
+
download?: undefined;
|
|
204
|
+
} | {
|
|
205
|
+
attachment: {
|
|
206
|
+
id: string;
|
|
207
|
+
filename: string;
|
|
208
|
+
content_type: string;
|
|
209
|
+
size: number;
|
|
210
|
+
sha256: string;
|
|
211
|
+
state: string;
|
|
212
|
+
created_at: string;
|
|
213
|
+
expires_at: string;
|
|
214
|
+
promotion: unknown;
|
|
215
|
+
conversation: string | undefined;
|
|
216
|
+
sender_id: string | undefined;
|
|
217
|
+
};
|
|
218
|
+
upload?: undefined;
|
|
219
|
+
attachments?: undefined;
|
|
220
|
+
nextCursor?: undefined;
|
|
221
|
+
download?: undefined;
|
|
222
|
+
} | {
|
|
223
|
+
attachment: {
|
|
224
|
+
id: string;
|
|
225
|
+
filename: string;
|
|
226
|
+
content_type: string;
|
|
227
|
+
size: number;
|
|
228
|
+
sha256: string;
|
|
229
|
+
state: string;
|
|
230
|
+
created_at: string;
|
|
231
|
+
expires_at: string;
|
|
232
|
+
promotion: unknown;
|
|
233
|
+
conversation: string | undefined;
|
|
234
|
+
sender_id: string | undefined;
|
|
235
|
+
};
|
|
236
|
+
download: {
|
|
237
|
+
url: string;
|
|
238
|
+
method: string;
|
|
239
|
+
headers: Readonly<Record<string, string>>;
|
|
240
|
+
expires_at: string;
|
|
241
|
+
};
|
|
242
|
+
upload?: undefined;
|
|
243
|
+
attachments?: undefined;
|
|
244
|
+
nextCursor?: undefined;
|
|
245
|
+
}, unknown, RequestId | CurrentPrincipal>;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import { MAX_BLOB_BYTES } from "../blob.js";
|
|
4
|
+
import { ActionRejected, NotFound } from "../errors.js";
|
|
5
|
+
import { schemaIssues } from "../runtime/validation.js";
|
|
6
|
+
import { uploadFields } from "../storage/attachments.js";
|
|
7
|
+
import { OpenUploads } from "../storage/sessions.js";
|
|
8
|
+
import { CurrentPrincipal } from "./authentication.js";
|
|
9
|
+
import { InvalidRequestBody, RequestId } from "./errors.js";
|
|
10
|
+
const Id = Schema.String.check(Schema.isUUID());
|
|
11
|
+
const DateTime = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/));
|
|
12
|
+
export const AttachmentFilters = Schema.Struct({
|
|
13
|
+
conversation: Schema.optionalKey(Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200))),
|
|
14
|
+
sender_id: Schema.optionalKey(Id),
|
|
15
|
+
from: Schema.optionalKey(DateTime),
|
|
16
|
+
to: Schema.optionalKey(DateTime),
|
|
17
|
+
before: Schema.optionalKey(Id),
|
|
18
|
+
limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 200 }))),
|
|
19
|
+
});
|
|
20
|
+
const AttachmentId = Schema.Struct({ id: Id });
|
|
21
|
+
const Promotion = Schema.Struct({
|
|
22
|
+
id: Id,
|
|
23
|
+
entity: Schema.String,
|
|
24
|
+
action: Schema.String,
|
|
25
|
+
input: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown)),
|
|
26
|
+
field: Schema.optionalKey(Schema.String),
|
|
27
|
+
record_id: Schema.optionalKey(Id),
|
|
28
|
+
});
|
|
29
|
+
const File = Schema.Struct({
|
|
30
|
+
entity: Schema.String,
|
|
31
|
+
id: Id,
|
|
32
|
+
property: Schema.optionalKey(Schema.String),
|
|
33
|
+
});
|
|
34
|
+
/** The REST upload session's begin request; property may be left to the action's upload field. */
|
|
35
|
+
const Upload = Schema.Struct({
|
|
36
|
+
entity: Schema.String,
|
|
37
|
+
action: Schema.String,
|
|
38
|
+
property: Schema.optionalKey(Schema.String),
|
|
39
|
+
record_id: Schema.optionalKey(Id),
|
|
40
|
+
create_intent: Schema.optionalKey(Id),
|
|
41
|
+
idempotency_key: Schema.optionalKey(Id),
|
|
42
|
+
filename: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(255)),
|
|
43
|
+
content_type: Schema.String,
|
|
44
|
+
size: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(MAX_BLOB_BYTES)),
|
|
45
|
+
});
|
|
46
|
+
const UploadId = Schema.Struct({ id: Id });
|
|
47
|
+
export const MEMBER_FILE_SCHEMAS = {
|
|
48
|
+
"attachments-list": AttachmentFilters,
|
|
49
|
+
"attachments-get": AttachmentId,
|
|
50
|
+
"attachments-download": AttachmentId,
|
|
51
|
+
"attachments-promote": Promotion,
|
|
52
|
+
"files-download": File,
|
|
53
|
+
"files-upload": Upload,
|
|
54
|
+
// Exactly `{}`. MCP lists a tool only with an object input schema, and an empty struct
|
|
55
|
+
// encodes as "not null".
|
|
56
|
+
"files-upload-list": Schema.Record(Schema.String, Schema.Never),
|
|
57
|
+
"files-upload-get": UploadId,
|
|
58
|
+
"files-upload-complete": UploadId,
|
|
59
|
+
"files-upload-cancel": UploadId,
|
|
60
|
+
};
|
|
61
|
+
export function grantForWire(grant) {
|
|
62
|
+
return {
|
|
63
|
+
url: grant.url,
|
|
64
|
+
method: grant.method,
|
|
65
|
+
headers: grant.headers,
|
|
66
|
+
expires_at: grant.expiresAt,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function uploadForWire(upload) {
|
|
70
|
+
return {
|
|
71
|
+
id: upload.id,
|
|
72
|
+
state: upload.state,
|
|
73
|
+
expires_at: upload.expiresAt,
|
|
74
|
+
...(upload.ticket ? { ticket: { upload_id: upload.ticket.uploadId } } : {}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function uploadsForWire(uploads) {
|
|
78
|
+
return Schema.encodeSync(OpenUploads)(uploads);
|
|
79
|
+
}
|
|
80
|
+
export function attachmentForWire(attachment) {
|
|
81
|
+
return {
|
|
82
|
+
id: attachment.id,
|
|
83
|
+
filename: attachment.filename,
|
|
84
|
+
content_type: attachment.contentType,
|
|
85
|
+
size: attachment.size,
|
|
86
|
+
sha256: attachment.sha256,
|
|
87
|
+
state: attachment.state,
|
|
88
|
+
created_at: attachment.createdAt,
|
|
89
|
+
expires_at: attachment.expiresAt,
|
|
90
|
+
promotion: attachment.promotion,
|
|
91
|
+
conversation: attachment.conversation,
|
|
92
|
+
sender_id: attachment.senderId,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function decode(schema, input) {
|
|
96
|
+
return Schema.decodeUnknownEffect(schema)(input, { onExcessProperty: "error" }).pipe(Effect.mapError((error) => new InvalidRequestBody({ reason: "invalid_request", issues: schemaIssues(error) })));
|
|
97
|
+
}
|
|
98
|
+
/** The member REST and MCP surfaces run the same runtime operations and action pipeline. */
|
|
99
|
+
export function memberFileOperations(backend, plan, operations) {
|
|
100
|
+
return (kind, args, identityToken) => Effect.gen(function* () {
|
|
101
|
+
const principal = yield* CurrentPrincipal;
|
|
102
|
+
const requestId = yield* RequestId;
|
|
103
|
+
if (kind === "files-download") {
|
|
104
|
+
const input = yield* decode(File, args);
|
|
105
|
+
if (!backend.blobs) {
|
|
106
|
+
return yield* new NotFound({
|
|
107
|
+
entity: input.entity,
|
|
108
|
+
id: input.id,
|
|
109
|
+
message: "File storage is unavailable.",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const result = yield* backend.blobs.downloadFile(input.entity, input.id, input.property ?? "content", {}, principal);
|
|
113
|
+
return { ...result, download: grantForWire(result.download) };
|
|
114
|
+
}
|
|
115
|
+
if (kind === "files-upload" ||
|
|
116
|
+
kind === "files-upload-list" ||
|
|
117
|
+
kind === "files-upload-get" ||
|
|
118
|
+
kind === "files-upload-complete" ||
|
|
119
|
+
kind === "files-upload-cancel") {
|
|
120
|
+
if (!backend.blobs) {
|
|
121
|
+
return yield* new NotFound({
|
|
122
|
+
entity: "upload",
|
|
123
|
+
id: "",
|
|
124
|
+
message: "File storage is unavailable.",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (kind === "files-upload-list") {
|
|
128
|
+
yield* decode(MEMBER_FILE_SCHEMAS[kind], args);
|
|
129
|
+
if (!backend.blobs.list) {
|
|
130
|
+
return yield* new ActionRejected({ message: "file_listing_unavailable" });
|
|
131
|
+
}
|
|
132
|
+
return uploadsForWire(yield* backend.blobs.list(principal));
|
|
133
|
+
}
|
|
134
|
+
if (kind === "files-upload-get") {
|
|
135
|
+
const { id } = yield* decode(UploadId, args);
|
|
136
|
+
return { upload: uploadForWire(yield* backend.blobs.status(id, principal)) };
|
|
137
|
+
}
|
|
138
|
+
if (kind === "files-upload-complete") {
|
|
139
|
+
const { id } = yield* decode(UploadId, args);
|
|
140
|
+
return { upload: uploadForWire(yield* backend.blobs.complete(id, principal)) };
|
|
141
|
+
}
|
|
142
|
+
if (kind === "files-upload-cancel") {
|
|
143
|
+
const { id } = yield* decode(UploadId, args);
|
|
144
|
+
return { upload: uploadForWire(yield* backend.blobs.cancel(id, principal)) };
|
|
145
|
+
}
|
|
146
|
+
const input = yield* decode(Upload, args);
|
|
147
|
+
const property = input.property ?? uploadProperty(plan, input.entity, input.action);
|
|
148
|
+
if (property === undefined) {
|
|
149
|
+
return yield* new ActionRejected({
|
|
150
|
+
message: "Name the property: the action takes no single upload of that entity.",
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
// As the app SDK does: the key is the session's identity and the action's idempotency
|
|
154
|
+
// key, and a record the action creates is bound to the upload by the same create intent.
|
|
155
|
+
const idempotencyKey = input.idempotency_key ?? randomUUID();
|
|
156
|
+
const createIntent = input.record_id === undefined ? (input.create_intent ?? idempotencyKey) : undefined;
|
|
157
|
+
const upload = yield* backend.blobs.begin({
|
|
158
|
+
entity: input.entity,
|
|
159
|
+
property,
|
|
160
|
+
action: input.action,
|
|
161
|
+
...(input.record_id === undefined ? {} : { recordId: input.record_id }),
|
|
162
|
+
...(createIntent === undefined ? {} : { createIntent }),
|
|
163
|
+
idempotencyKey,
|
|
164
|
+
filename: input.filename,
|
|
165
|
+
contentType: input.content_type,
|
|
166
|
+
size: input.size,
|
|
167
|
+
}, principal);
|
|
168
|
+
// A retry of a transfer already done, or completed, needs no new grant.
|
|
169
|
+
const transfer = upload.state === "uploading"
|
|
170
|
+
? yield* backend.blobs.part(upload.id, principal)
|
|
171
|
+
: undefined;
|
|
172
|
+
return {
|
|
173
|
+
upload: uploadForWire(upload),
|
|
174
|
+
...(transfer === undefined ? {} : { transfer: grantForWire(transfer) }),
|
|
175
|
+
options: {
|
|
176
|
+
idempotency_key: idempotencyKey,
|
|
177
|
+
...(createIntent === undefined ? {} : { create_intent: createIntent }),
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (principal.kind !== "member") {
|
|
182
|
+
return yield* new NotFound({
|
|
183
|
+
entity: "attachment",
|
|
184
|
+
id: "",
|
|
185
|
+
message: "Attachment not found.",
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const attachments = backend.attachments;
|
|
189
|
+
if (!attachments) {
|
|
190
|
+
return yield* new NotFound({
|
|
191
|
+
entity: "attachment",
|
|
192
|
+
id: "",
|
|
193
|
+
message: "Attachment storage is unavailable.",
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (kind === "attachments-list") {
|
|
197
|
+
const input = yield* decode(AttachmentFilters, args);
|
|
198
|
+
if ((input.from !== undefined && !Number.isFinite(Date.parse(input.from))) ||
|
|
199
|
+
(input.to !== undefined && !Number.isFinite(Date.parse(input.to))) ||
|
|
200
|
+
(input.from !== undefined &&
|
|
201
|
+
input.to !== undefined &&
|
|
202
|
+
Date.parse(input.from) > Date.parse(input.to))) {
|
|
203
|
+
return yield* new InvalidRequestBody({ reason: "invalid_request", issues: [] });
|
|
204
|
+
}
|
|
205
|
+
const { sender_id, ...rest } = input;
|
|
206
|
+
const result = yield* attachments.listForMember({ ...rest, ...(sender_id === undefined ? {} : { senderId: sender_id }) }, principal);
|
|
207
|
+
return {
|
|
208
|
+
attachments: result.attachments.map(attachmentForWire),
|
|
209
|
+
nextCursor: result.nextCursor,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (kind === "attachments-promote") {
|
|
213
|
+
const input = yield* decode(Promotion, args);
|
|
214
|
+
const promoted = yield* attachments.promoteForMember(input.id, {
|
|
215
|
+
entity: input.entity,
|
|
216
|
+
action: input.action,
|
|
217
|
+
input: input.input ?? {},
|
|
218
|
+
...(input.field === undefined ? {} : { field: input.field }),
|
|
219
|
+
...(input.record_id === undefined ? {} : { recordId: input.record_id }),
|
|
220
|
+
}, principal, (call) => Effect.gen(function* () {
|
|
221
|
+
const entity = plan.entities.find((item) => item.name === call.entity);
|
|
222
|
+
const action = entity?.actions.find((item) => item.name === call.action);
|
|
223
|
+
if (!entity || !action) {
|
|
224
|
+
return yield* Effect.die(new Error("The promotion action was not planned."));
|
|
225
|
+
}
|
|
226
|
+
const answer = yield* operations.runAction(entity, action, {
|
|
227
|
+
input: call.input,
|
|
228
|
+
options: call.options,
|
|
229
|
+
validateOnly: false,
|
|
230
|
+
identityToken,
|
|
231
|
+
});
|
|
232
|
+
return { result: answer.result, edits: answer.edits };
|
|
233
|
+
}).pipe(Effect.provideService(CurrentPrincipal, principal), Effect.provideService(RequestId, requestId)));
|
|
234
|
+
return { ...promoted, attachment: attachmentForWire(promoted.attachment) };
|
|
235
|
+
}
|
|
236
|
+
const { id } = yield* decode(AttachmentId, args);
|
|
237
|
+
if (kind === "attachments-get") {
|
|
238
|
+
return { attachment: attachmentForWire(yield* attachments.getForMember(id, principal)) };
|
|
239
|
+
}
|
|
240
|
+
const result = yield* attachments.readForMember(id, principal);
|
|
241
|
+
return {
|
|
242
|
+
attachment: attachmentForWire(result.attachment),
|
|
243
|
+
download: grantForWire(result.download),
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/** The blob property of the action's only upload field for the entity, if it has exactly one. */
|
|
248
|
+
function uploadProperty(plan, entity, action) {
|
|
249
|
+
const planned = plan.entities
|
|
250
|
+
.find((item) => item.name === entity)
|
|
251
|
+
?.actions.find((item) => item.name === action);
|
|
252
|
+
const properties = new Set(planned === undefined
|
|
253
|
+
? []
|
|
254
|
+
: uploadFields(planned.action.input)
|
|
255
|
+
.filter((field) => field.entity === entity)
|
|
256
|
+
.map((field) => field.property));
|
|
257
|
+
return properties.size === 1 ? [...properties][0] : undefined;
|
|
258
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Effect, Redacted } from "effect";
|
|
2
|
+
import { MetricQueryUpstreamUnavailable } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* How long one metric query may take end to end, the response included. BigQuery answers most within
|
|
5
|
+
* seconds; the margin covers a cold warehouse and the hops to and from SegmentStream.
|
|
6
|
+
*/
|
|
7
|
+
export declare const METRIC_QUERY_TIMEOUT_MS = 60000;
|
|
8
|
+
/**
|
|
9
|
+
* The hash of the manifest the service resolved and checked the request against. SegmentStream
|
|
10
|
+
* answers `409 ontology_version_mismatch` when its deployed manifest differs, so a request checked
|
|
11
|
+
* against one ontology never runs against another.
|
|
12
|
+
*/
|
|
13
|
+
export declare const MANIFEST_HASH_HEADER = "x-ontology-manifest-hash";
|
|
14
|
+
/**
|
|
15
|
+
* The entities the service checked `<entity>:read` on, sorted and comma-separated. SegmentStream
|
|
16
|
+
* answers `409 aggregate_scope_mismatch` when it would read any other, so the service's resolution
|
|
17
|
+
* and SegmentStream's can never drift apart unnoticed.
|
|
18
|
+
*/
|
|
19
|
+
export declare const TOUCHED_HEADER = "x-ontology-touched";
|
|
20
|
+
/**
|
|
21
|
+
* The caller's read scopes of the stored entities the request reads scoped, base64url JSON of entity
|
|
22
|
+
* name to `where`, `me` resolved. SegmentStream keeps only each scope's rows wherever it reads the
|
|
23
|
+
* entity, confirms the scopes in `execution.rowScopes`, and answers `422
|
|
24
|
+
* scoped_aggregate_unavailable` for a scope the warehouse cannot apply.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ROW_SCOPES_HEADER = "x-ontology-row-scopes";
|
|
27
|
+
/** SegmentStream would read beyond what the service checked: this deployment's SDK is behind. */
|
|
28
|
+
export declare const SCOPE_MISMATCH = "aggregate_scope_mismatch";
|
|
29
|
+
/** SegmentStream's answer: its status, its JSON body as sent, and that body parsed. */
|
|
30
|
+
export interface PlatformAnswer {
|
|
31
|
+
readonly status: number;
|
|
32
|
+
readonly text: string;
|
|
33
|
+
readonly body: Readonly<Record<string, unknown>>;
|
|
34
|
+
/** SegmentStream's `Retry-After`, on a 429 or a 503 that sent one. */
|
|
35
|
+
readonly retryAfter?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sends a checked metric query to SegmentStream: model-level, or the per-entity shorthand of `entity`.
|
|
39
|
+
* `touched` is every entity the service required `<entity>:read` on.
|
|
40
|
+
*/
|
|
41
|
+
export type MetricQueryTransport = (input: {
|
|
42
|
+
readonly entity?: string;
|
|
43
|
+
readonly body: unknown;
|
|
44
|
+
readonly requestId: string;
|
|
45
|
+
readonly touched: ReadonlyArray<string>;
|
|
46
|
+
/** {@link ROW_SCOPES_HEADER}'s value, when the caller reads a touched entity scoped. */
|
|
47
|
+
readonly rowScopes?: string;
|
|
48
|
+
}) => Effect.Effect<PlatformAnswer, MetricQueryUpstreamUnavailable>;
|
|
49
|
+
/**
|
|
50
|
+
* Where a deployment sends metric queries: its platform, its workspace and its app credential, with the
|
|
51
|
+
* hash of the manifest it serves.
|
|
52
|
+
*/
|
|
53
|
+
export interface MetricQueryEnvironment {
|
|
54
|
+
readonly segmentstreamUrl: string;
|
|
55
|
+
readonly workspaceId: string;
|
|
56
|
+
readonly appCredential?: Redacted.Redacted<string>;
|
|
57
|
+
readonly manifestHash: string;
|
|
58
|
+
}
|
|
59
|
+
/** The credential travels only to SegmentStream over TLS, or over plain http to this machine. */
|
|
60
|
+
export declare function securePlatform(origin: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* A failed call for the operator: name, message and stack, then each cause, with every occurrence
|
|
63
|
+
* of the credential replaced.
|
|
64
|
+
*/
|
|
65
|
+
export declare function describeError(error: unknown, redact: (text: string) => string, depth?: number): string;
|
|
66
|
+
/**
|
|
67
|
+
* SegmentStream's `POST /api/v1/workspaces/{id}/metrics/query`, and its per-entity
|
|
68
|
+
* `…/entities/{entity}/metrics/query`, called with the workspace app credential. `undefined` when
|
|
69
|
+
* the deployment has none, or when SegmentStream's origin is plain http to another machine, which
|
|
70
|
+
* is logged once. Every request names the manifest it was checked
|
|
71
|
+
* against, and a redirect is refused, so the credential never leaves for another origin.
|
|
72
|
+
*
|
|
73
|
+
* Every answer but a 2xx is logged with both request ids, the status and the start of the body; a
|
|
74
|
+
* failed call with its message, stack and causes. The credential is redacted from all of them. A
|
|
75
|
+
* caller who goes away interrupts the call, which is not SegmentStream's failure.
|
|
76
|
+
*/
|
|
77
|
+
export declare function platformMetricQueries(environment: MetricQueryEnvironment, fetchImpl?: typeof fetch): MetricQueryTransport | undefined;
|