@segmentstream/ontology 0.0.0-stage → 0.92.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +2 -0
- package/README.md +1655 -2
- package/dist/action.d.ts +193 -0
- package/dist/action.js +41 -0
- package/dist/agent-chat.d.ts +44 -0
- package/dist/agent-chat.js +91 -0
- package/dist/agent-task-contract.d.ts +64 -0
- package/dist/agent-task-contract.js +15 -0
- package/dist/agent-task.d.ts +39 -0
- package/dist/agent-task.js +112 -0
- package/dist/analyze.d.ts +215 -0
- package/dist/analyze.js +2438 -0
- package/dist/app-feedback.d.ts +167 -0
- package/dist/app-feedback.js +176 -0
- package/dist/authoring-input.d.ts +3 -0
- package/dist/authoring-input.js +107 -0
- package/dist/authoring-names.d.ts +4 -0
- package/dist/authoring-names.js +13 -0
- package/dist/authoring-records.d.ts +35 -0
- package/dist/authoring-records.js +264 -0
- package/dist/authoring.d.ts +15 -0
- package/dist/authoring.js +331 -0
- package/dist/bin/check.d.ts +30 -0
- package/dist/bin/check.js +99 -0
- package/dist/bin/load.d.ts +48 -0
- package/dist/bin/load.js +139 -0
- package/dist/bin/main.d.ts +31 -0
- package/dist/bin/main.js +121 -0
- package/dist/bin/migrate.d.ts +57 -0
- package/dist/bin/migrate.js +170 -0
- package/dist/bin/output.d.ts +31 -0
- package/dist/bin/output.js +84 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +31 -0
- package/dist/blob.d.ts +52 -0
- package/dist/blob.js +87 -0
- package/dist/channel-session.d.ts +16 -0
- package/dist/channel-session.js +16 -0
- package/dist/chat.d.ts +43 -0
- package/dist/chat.js +34 -0
- package/dist/confirmation.d.ts +46 -0
- package/dist/confirmation.js +41 -0
- package/dist/connection.d.ts +213 -0
- package/dist/connection.js +289 -0
- package/dist/deployment.d.ts +35 -0
- package/dist/deployment.js +76 -0
- package/dist/diagnostics.d.ts +27 -0
- package/dist/diagnostics.js +106 -0
- package/dist/emails.d.ts +70 -0
- package/dist/emails.js +221 -0
- package/dist/entity.d.ts +331 -0
- package/dist/entity.js +153 -0
- package/dist/errors.d.ts +154 -0
- package/dist/errors.js +109 -0
- package/dist/feedback-config.d.ts +24 -0
- package/dist/feedback-config.js +126 -0
- package/dist/files.d.ts +39 -0
- package/dist/files.js +4 -0
- package/dist/groups.d.ts +95 -0
- package/dist/groups.js +280 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +70 -0
- package/dist/internal/diagnostics.js +594 -0
- package/dist/legacy.d.ts +160 -0
- package/dist/legacy.js +270 -0
- package/dist/manifest-compatibility.d.ts +8 -0
- package/dist/manifest-compatibility.js +87 -0
- package/dist/manifest.d.ts +3329 -0
- package/dist/manifest.js +757 -0
- package/dist/me.d.ts +46 -0
- package/dist/me.js +109 -0
- package/dist/metric-filters.d.ts +48 -0
- package/dist/metric-filters.js +252 -0
- package/dist/metric-routes.d.ts +132 -0
- package/dist/metric-routes.js +498 -0
- package/dist/metric.d.ts +172 -0
- package/dist/metric.js +132 -0
- package/dist/migrate/apply.d.ts +94 -0
- package/dist/migrate/apply.js +526 -0
- package/dist/migrate/errors.d.ts +46 -0
- package/dist/migrate/errors.js +38 -0
- package/dist/migrate/index.d.ts +10 -0
- package/dist/migrate/index.js +7 -0
- package/dist/migrate/model.d.ts +2311 -0
- package/dist/migrate/model.js +148 -0
- package/dist/migrate/plan.d.ts +51 -0
- package/dist/migrate/plan.js +1856 -0
- package/dist/migrate/preview.d.ts +13 -0
- package/dist/migrate/preview.js +65 -0
- package/dist/migrate/storage.d.ts +226 -0
- package/dist/migrate/storage.js +774 -0
- package/dist/model-metrics.d.ts +22 -0
- package/dist/model-metrics.js +545 -0
- package/dist/names.d.ts +49 -0
- package/dist/names.js +110 -0
- package/dist/navigation-artifact.d.ts +13 -0
- package/dist/navigation-artifact.js +11 -0
- package/dist/navigation-catalog.d.ts +55 -0
- package/dist/navigation-catalog.js +297 -0
- package/dist/nitro-navigation.d.ts +3 -0
- package/dist/nitro-navigation.js +64 -0
- package/dist/nitro-workflows.d.ts +108 -0
- package/dist/nitro-workflows.js +286 -0
- package/dist/nitro.d.ts +40 -0
- package/dist/nitro.js +50 -0
- package/dist/ontology.d.ts +41 -0
- package/dist/ontology.js +46 -0
- package/dist/permissions.d.ts +198 -0
- package/dist/permissions.js +272 -0
- package/dist/property.d.ts +188 -0
- package/dist/property.js +301 -0
- package/dist/query.d.ts +245 -0
- package/dist/query.js +615 -0
- package/dist/relationship.d.ts +99 -0
- package/dist/relationship.js +33 -0
- package/dist/render.d.ts +81 -0
- package/dist/render.js +512 -0
- package/dist/replication/baseline.d.ts +51 -0
- package/dist/replication/baseline.js +215 -0
- package/dist/replication/bigquery.d.ts +37 -0
- package/dist/replication/bigquery.js +211 -0
- package/dist/replication/coverage.d.ts +14 -0
- package/dist/replication/coverage.js +53 -0
- package/dist/replication/evolution.d.ts +25 -0
- package/dist/replication/evolution.js +184 -0
- package/dist/replication/identities.d.ts +6 -0
- package/dist/replication/identities.js +47 -0
- package/dist/replication/legacy-baseline.d.ts +27 -0
- package/dist/replication/legacy-baseline.js +109 -0
- package/dist/replication/legacy-store.d.ts +19 -0
- package/dist/replication/legacy-store.js +63 -0
- package/dist/replication/lineage.d.ts +36 -0
- package/dist/replication/lineage.js +72 -0
- package/dist/replication/migrate.d.ts +21 -0
- package/dist/replication/migrate.js +84 -0
- package/dist/replication/model.d.ts +52 -0
- package/dist/replication/model.js +99 -0
- package/dist/replication/scans.d.ts +34 -0
- package/dist/replication/scans.js +158 -0
- package/dist/replication/schema.d.ts +11 -0
- package/dist/replication/schema.js +226 -0
- package/dist/replication/shadow-schema.d.ts +4 -0
- package/dist/replication/shadow-schema.js +61 -0
- package/dist/replication/shadow.d.ts +127 -0
- package/dist/replication/shadow.js +614 -0
- package/dist/replication/source-replacement.d.ts +33 -0
- package/dist/replication/source-replacement.js +76 -0
- package/dist/replication/store.d.ts +36 -0
- package/dist/replication/store.js +382 -0
- package/dist/replication/transaction.d.ts +23 -0
- package/dist/replication/transaction.js +88 -0
- package/dist/role.d.ts +61 -0
- package/dist/role.js +76 -0
- package/dist/runtime/action-deadlocks.d.ts +21 -0
- package/dist/runtime/action-deadlocks.js +130 -0
- package/dist/runtime/action-transactions.d.ts +35 -0
- package/dist/runtime/action-transactions.js +54 -0
- package/dist/runtime/agent-counters.d.ts +26 -0
- package/dist/runtime/agent-counters.js +98 -0
- package/dist/runtime/agent-tasks.d.ts +63 -0
- package/dist/runtime/agent-tasks.js +120 -0
- package/dist/runtime/agents.d.ts +15 -0
- package/dist/runtime/agents.js +457 -0
- package/dist/runtime/batch-diagnostics.d.ts +22 -0
- package/dist/runtime/batch-diagnostics.js +89 -0
- package/dist/runtime/batch.d.ts +52 -0
- package/dist/runtime/batch.js +534 -0
- package/dist/runtime/channel-session-revocation.d.ts +3 -0
- package/dist/runtime/channel-session-revocation.js +5 -0
- package/dist/runtime/channel-sessions.d.ts +4 -0
- package/dist/runtime/channel-sessions.js +61 -0
- package/dist/runtime/confirmations.d.ts +29 -0
- package/dist/runtime/confirmations.js +57 -0
- package/dist/runtime/cursor.d.ts +23 -0
- package/dist/runtime/cursor.js +100 -0
- package/dist/runtime/deployment.d.ts +7 -0
- package/dist/runtime/deployment.js +4 -0
- package/dist/runtime/errors.d.ts +118 -0
- package/dist/runtime/errors.js +109 -0
- package/dist/runtime/federation-tables.d.ts +2 -0
- package/dist/runtime/federation-tables.js +20 -0
- package/dist/runtime/federation.d.ts +42 -0
- package/dist/runtime/federation.js +222 -0
- package/dist/runtime/files.d.ts +39 -0
- package/dist/runtime/files.js +44 -0
- package/dist/runtime/generated-actions.d.ts +37 -0
- package/dist/runtime/generated-actions.js +307 -0
- package/dist/runtime/history.d.ts +91 -0
- package/dist/runtime/history.js +77 -0
- package/dist/runtime/ids.d.ts +6 -0
- package/dist/runtime/ids.js +39 -0
- package/dist/runtime/member-tables.d.ts +8 -0
- package/dist/runtime/member-tables.js +33 -0
- package/dist/runtime/member-writes.d.ts +78 -0
- package/dist/runtime/member-writes.js +202 -0
- package/dist/runtime/metric-query.d.ts +19 -0
- package/dist/runtime/metric-query.js +411 -0
- package/dist/runtime/model.d.ts +67 -0
- package/dist/runtime/model.js +150 -0
- package/dist/runtime/new-user-hook.d.ts +6 -0
- package/dist/runtime/new-user-hook.js +37 -0
- package/dist/runtime/oauth.d.ts +9 -0
- package/dist/runtime/oauth.js +299 -0
- package/dist/runtime/pipeline.d.ts +155 -0
- package/dist/runtime/pipeline.js +597 -0
- package/dist/runtime/postgres-tls.d.ts +10 -0
- package/dist/runtime/postgres-tls.js +14 -0
- package/dist/runtime/principals.d.ts +302 -0
- package/dist/runtime/principals.js +1307 -0
- package/dist/runtime/reads.d.ts +55 -0
- package/dist/runtime/reads.js +313 -0
- package/dist/runtime/records.d.ts +42 -0
- package/dist/runtime/records.js +245 -0
- package/dist/runtime/resolve-agent-identity.d.ts +6 -0
- package/dist/runtime/resolve-agent-identity.js +181 -0
- package/dist/runtime/service-binding.d.ts +18 -0
- package/dist/runtime/service-binding.js +266 -0
- package/dist/runtime/sign-in-links.d.ts +68 -0
- package/dist/runtime/sign-in-links.js +147 -0
- package/dist/runtime/sql-runtime.d.ts +131 -0
- package/dist/runtime/sql-runtime.js +362 -0
- package/dist/runtime/statement.d.ts +18 -0
- package/dist/runtime/statement.js +31 -0
- package/dist/runtime/user-identities.d.ts +66 -0
- package/dist/runtime/user-identities.js +106 -0
- package/dist/runtime/user-identity-sql.d.ts +86 -0
- package/dist/runtime/user-identity-sql.js +297 -0
- package/dist/runtime/user-roles.d.ts +16 -0
- package/dist/runtime/user-roles.js +32 -0
- package/dist/runtime/validation.d.ts +16 -0
- package/dist/runtime/validation.js +26 -0
- package/dist/runtime/where.d.ts +57 -0
- package/dist/runtime/where.js +404 -0
- package/dist/runtime/workflow-admission.d.ts +49 -0
- package/dist/runtime/workflow-admission.js +92 -0
- package/dist/runtime/workflow-argument-codec.d.ts +10 -0
- package/dist/runtime/workflow-argument-codec.js +120 -0
- package/dist/runtime/workflow-arguments.d.ts +17 -0
- package/dist/runtime/workflow-arguments.js +99 -0
- package/dist/runtime/workflow-starts.d.ts +203 -0
- package/dist/runtime/workflow-starts.js +493 -0
- package/dist/runtime/workflow-users.d.ts +9 -0
- package/dist/runtime/workflow-users.js +17 -0
- package/dist/runtime/workload.d.ts +25 -0
- package/dist/runtime/workload.js +24 -0
- package/dist/runtime/writes.d.ts +108 -0
- package/dist/runtime/writes.js +491 -0
- package/dist/runtime-source.d.ts +22 -0
- package/dist/runtime-source.js +28 -0
- package/dist/runtime.d.ts +310 -0
- package/dist/runtime.js +31 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.js +107 -0
- package/dist/service/agent/attachments.d.ts +33 -0
- package/dist/service/agent/attachments.js +228 -0
- package/dist/service/agent/authentication.d.ts +22 -0
- package/dist/service/agent/authentication.js +58 -0
- package/dist/service/agent/confirmations.d.ts +5 -0
- package/dist/service/agent/confirmations.js +73 -0
- package/dist/service/agent/conversation-routes.d.ts +14 -0
- package/dist/service/agent/conversation-routes.js +45 -0
- package/dist/service/agent/conversations.d.ts +40 -0
- package/dist/service/agent/conversations.js +69 -0
- package/dist/service/agent/files.d.ts +12 -0
- package/dist/service/agent/files.js +69 -0
- package/dist/service/agent/protocol.d.ts +90 -0
- package/dist/service/agent/protocol.js +114 -0
- package/dist/service/agent/server.d.ts +28 -0
- package/dist/service/agent/server.js +374 -0
- package/dist/service/agent/task-caller.d.ts +21 -0
- package/dist/service/agent/task-caller.js +35 -0
- package/dist/service/agent/task-start.d.ts +53 -0
- package/dist/service/agent/task-start.js +161 -0
- package/dist/service/agent/tasks.d.ts +40 -0
- package/dist/service/agent/tasks.js +155 -0
- package/dist/service/api.d.ts +50 -0
- package/dist/service/api.js +288 -0
- package/dist/service/authentication.d.ts +227 -0
- package/dist/service/authentication.js +767 -0
- package/dist/service/caller-context.d.ts +24 -0
- package/dist/service/caller-context.js +6 -0
- package/dist/service/catalog.d.ts +42 -0
- package/dist/service/catalog.js +66 -0
- package/dist/service/channel/provider.d.ts +10 -0
- package/dist/service/channel/provider.js +1 -0
- package/dist/service/channel/providers/telegram.d.ts +18 -0
- package/dist/service/channel/providers/telegram.js +108 -0
- package/dist/service/channel/sessions.d.ts +5 -0
- package/dist/service/channel/sessions.js +53 -0
- package/dist/service/channel/sign-in.d.ts +7 -0
- package/dist/service/channel/sign-in.js +78 -0
- package/dist/service/chat/archive.d.ts +64 -0
- package/dist/service/chat/archive.js +62 -0
- package/dist/service/chat/attribution.d.ts +26 -0
- package/dist/service/chat/attribution.js +28 -0
- package/dist/service/chat/delivery.d.ts +18 -0
- package/dist/service/chat/delivery.js +251 -0
- package/dist/service/chat/diagnostics.d.ts +2 -0
- package/dist/service/chat/diagnostics.js +35 -0
- package/dist/service/chat/envelope.d.ts +96 -0
- package/dist/service/chat/envelope.js +39 -0
- package/dist/service/chat/idempotency.d.ts +19 -0
- package/dist/service/chat/idempotency.js +37 -0
- package/dist/service/chat/providers/telegram.d.ts +36 -0
- package/dist/service/chat/providers/telegram.js +133 -0
- package/dist/service/chat/reads.d.ts +25 -0
- package/dist/service/chat/reads.js +75 -0
- package/dist/service/chat/resolve.d.ts +34 -0
- package/dist/service/chat/resolve.js +150 -0
- package/dist/service/chat/routes.d.ts +23 -0
- package/dist/service/chat/routes.js +75 -0
- package/dist/service/chat/schemas.d.ts +43 -0
- package/dist/service/chat/schemas.js +31 -0
- package/dist/service/config.d.ts +218 -0
- package/dist/service/config.js +265 -0
- package/dist/service/connection-stream.d.ts +10 -0
- package/dist/service/connection-stream.js +191 -0
- package/dist/service/connections.d.ts +60 -0
- package/dist/service/connections.js +271 -0
- package/dist/service/decisions.d.ts +35 -0
- package/dist/service/decisions.js +63 -0
- package/dist/service/descriptions.d.ts +8 -0
- package/dist/service/descriptions.js +20 -0
- package/dist/service/discovery-schemas.d.ts +92 -0
- package/dist/service/discovery-schemas.js +59 -0
- package/dist/service/discovery-search.d.ts +30 -0
- package/dist/service/discovery-search.js +95 -0
- package/dist/service/discovery.d.ts +37 -0
- package/dist/service/discovery.js +436 -0
- package/dist/service/docs.d.ts +9 -0
- package/dist/service/docs.js +197 -0
- package/dist/service/errors.d.ts +145 -0
- package/dist/service/errors.js +704 -0
- package/dist/service/federation-provider.d.ts +36 -0
- package/dist/service/federation-provider.js +110 -0
- package/dist/service/federation-server.d.ts +20 -0
- package/dist/service/federation-server.js +249 -0
- package/dist/service/federation-status.d.ts +40 -0
- package/dist/service/federation-status.js +151 -0
- package/dist/service/handlers.d.ts +18 -0
- package/dist/service/handlers.js +287 -0
- package/dist/service/mcp/confirmation.d.ts +68 -0
- package/dist/service/mcp/confirmation.js +178 -0
- package/dist/service/mcp/find-input.d.ts +12 -0
- package/dist/service/mcp/find-input.js +122 -0
- package/dist/service/mcp/input-schema.d.ts +6 -0
- package/dist/service/mcp/input-schema.js +126 -0
- package/dist/service/mcp/listing.d.ts +26 -0
- package/dist/service/mcp/listing.js +92 -0
- package/dist/service/mcp/metric-tools.d.ts +85 -0
- package/dist/service/mcp/metric-tools.js +258 -0
- package/dist/service/mcp/request-log.d.ts +5 -0
- package/dist/service/mcp/request-log.js +53 -0
- package/dist/service/mcp/runtime-policy.d.ts +27 -0
- package/dist/service/mcp/runtime-policy.js +62 -0
- package/dist/service/mcp/server.d.ts +52 -0
- package/dist/service/mcp/server.js +861 -0
- package/dist/service/mcp/tools.d.ts +99 -0
- package/dist/service/mcp/tools.js +938 -0
- package/dist/service/member-file-routes.d.ts +22 -0
- package/dist/service/member-file-routes.js +52 -0
- package/dist/service/member-files.d.ts +245 -0
- package/dist/service/member-files.js +258 -0
- package/dist/service/metric-query-platform.d.ts +77 -0
- package/dist/service/metric-query-platform.js +198 -0
- package/dist/service/metric-query-scopes.d.ts +43 -0
- package/dist/service/metric-query-scopes.js +147 -0
- package/dist/service/metric-query.d.ts +48 -0
- package/dist/service/metric-query.js +200 -0
- package/dist/service/name-suggestions.d.ts +3 -0
- package/dist/service/name-suggestions.js +38 -0
- package/dist/service/navigation-schemas.d.ts +80 -0
- package/dist/service/navigation-schemas.js +49 -0
- package/dist/service/navigation.d.ts +20 -0
- package/dist/service/navigation.js +165 -0
- package/dist/service/oauth/protocol.d.ts +70 -0
- package/dist/service/oauth/protocol.js +157 -0
- package/dist/service/oauth/refresh-replay.d.ts +2 -0
- package/dist/service/oauth/refresh-replay.js +20 -0
- package/dist/service/oauth/server.d.ts +28 -0
- package/dist/service/oauth/server.js +769 -0
- package/dist/service/operations.d.ts +170 -0
- package/dist/service/operations.js +392 -0
- package/dist/service/plan.d.ts +57 -0
- package/dist/service/plan.js +96 -0
- package/dist/service/rate-limit.d.ts +22 -0
- package/dist/service/rate-limit.js +52 -0
- package/dist/service/record-reads.d.ts +21 -0
- package/dist/service/record-reads.js +155 -0
- package/dist/service/replication.d.ts +5 -0
- package/dist/service/replication.js +39 -0
- package/dist/service/runtime-contract.d.ts +508 -0
- package/dist/service/runtime-contract.js +18 -0
- package/dist/service/runtime-identity.d.ts +71 -0
- package/dist/service/runtime-identity.js +122 -0
- package/dist/service/schemas.d.ts +961 -0
- package/dist/service/schemas.js +639 -0
- package/dist/service/service.d.ts +21 -0
- package/dist/service/service.js +526 -0
- package/dist/service/warehouse-platform.d.ts +17 -0
- package/dist/service/warehouse-platform.js +122 -0
- package/dist/service/warehouse-query.d.ts +24 -0
- package/dist/service/warehouse-query.js +280 -0
- package/dist/service/webhooks.d.ts +106 -0
- package/dist/service/webhooks.js +233 -0
- package/dist/service/workflow-admission-provider.d.ts +31 -0
- package/dist/service/workflow-admission-provider.js +205 -0
- package/dist/service/workflow-argument-serialization.d.ts +2 -0
- package/dist/service/workflow-argument-serialization.js +14 -0
- package/dist/service/workflow-callback.d.ts +22 -0
- package/dist/service/workflow-callback.js +75 -0
- package/dist/service/workflow-deployment.d.ts +8 -0
- package/dist/service/workflow-deployment.js +131 -0
- package/dist/service/workflow-diagnostics.d.ts +23 -0
- package/dist/service/workflow-diagnostics.js +263 -0
- package/dist/service/workflow-errors.d.ts +26 -0
- package/dist/service/workflow-errors.js +181 -0
- package/dist/service/workflow-logging.d.ts +2 -0
- package/dist/service/workflow-logging.js +50 -0
- package/dist/service/workflow-queue-fence.d.ts +6 -0
- package/dist/service/workflow-queue-fence.js +66 -0
- package/dist/service/workflows.d.ts +200 -0
- package/dist/service/workflows.js +1549 -0
- package/dist/sign-in.d.ts +58 -0
- package/dist/sign-in.js +57 -0
- package/dist/source.d.ts +30 -0
- package/dist/source.js +107 -0
- package/dist/start-recovery-contract.d.ts +49 -0
- package/dist/start-recovery-contract.js +26 -0
- package/dist/start-recovery.d.ts +27 -0
- package/dist/start-recovery.js +81 -0
- package/dist/storage/api.d.ts +4 -0
- package/dist/storage/api.js +40 -0
- package/dist/storage/attachments.d.ts +146 -0
- package/dist/storage/attachments.js +733 -0
- package/dist/storage/authorization.d.ts +38 -0
- package/dist/storage/authorization.js +83 -0
- package/dist/storage/file-access.d.ts +17 -0
- package/dist/storage/file-access.js +8 -0
- package/dist/storage/limits.d.ts +12 -0
- package/dist/storage/limits.js +17 -0
- package/dist/storage/maintenance-auth.d.ts +20 -0
- package/dist/storage/maintenance-auth.js +24 -0
- package/dist/storage/maintenance.d.ts +11 -0
- package/dist/storage/maintenance.js +67 -0
- package/dist/storage/neon.d.ts +4 -0
- package/dist/storage/neon.js +318 -0
- package/dist/storage/operator.d.ts +11 -0
- package/dist/storage/operator.js +30 -0
- package/dist/storage/provider.d.ts +93 -0
- package/dist/storage/provider.js +36 -0
- package/dist/storage/sessions.d.ts +184 -0
- package/dist/storage/sessions.js +688 -0
- package/dist/storage/tables.d.ts +54 -0
- package/dist/storage/tables.js +205 -0
- package/dist/storage/transfers.d.ts +16 -0
- package/dist/storage/transfers.js +153 -0
- package/dist/storage/writes.d.ts +7 -0
- package/dist/storage/writes.js +88 -0
- package/dist/telegram.d.ts +35 -0
- package/dist/telegram.js +173 -0
- package/dist/user-identity.d.ts +28 -0
- package/dist/user-identity.js +106 -0
- package/dist/user.d.ts +75 -0
- package/dist/user.js +111 -0
- package/dist/warehouse-backed.d.ts +6 -0
- package/dist/warehouse-backed.js +495 -0
- package/dist/webhook-token.d.ts +11 -0
- package/dist/webhook-token.js +18 -0
- package/dist/webhooks.d.ts +40 -0
- package/dist/webhooks.js +55 -0
- package/dist/wire.d.ts +10 -0
- package/dist/wire.js +35 -0
- package/dist/workflow-runtime.d.ts +116 -0
- package/dist/workflow-runtime.js +109 -0
- package/dist/workflow-topics.d.ts +28 -0
- package/dist/workflow-topics.js +28 -0
- package/dist/workflow.d.ts +284 -0
- package/dist/workflow.js +259 -0
- package/dist/workflows.d.ts +24 -0
- package/dist/workflows.js +18 -0
- package/package.json +127 -4
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Storage metadata lives in the ontology database and is migrated by its SDK. */
|
|
2
|
+
export declare const BLOB_TABLES_DDL: ReadonlyArray<string>;
|
|
3
|
+
/** The agent's temporary attachments, beside the blob tables whose storage they share. */
|
|
4
|
+
export declare const ATTACHMENTS_TABLE = "_agent_attachments";
|
|
5
|
+
/**
|
|
6
|
+
* Where an attachment comes from: a chat message, or a file the agent produced in its sandbox and
|
|
7
|
+
* stores so that an action can keep it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ATTACHMENT_SOURCES: readonly ["telegram", "sandbox"];
|
|
10
|
+
/** The check that limits `source` to {@link ATTACHMENT_SOURCES}; its name is PostgreSQL's default. */
|
|
11
|
+
export declare const ATTACHMENT_SOURCE_CHECK = "_agent_attachments_source_check";
|
|
12
|
+
/**
|
|
13
|
+
* A file a member sent the app's agent: platform metadata, never an ontology record. The bytes are
|
|
14
|
+
* a `_blobs` revision in the same storage as uploads; the row binds them to their owner, the chat
|
|
15
|
+
* and, for private chats, the first agent session that reads them. Group access follows the chat
|
|
16
|
+
* registry's current members. Attachments expire 24 hours after receipt unless promoted.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ATTACHMENT_TABLES_DDL: ReadonlyArray<string>;
|
|
19
|
+
/** The pending and started workflow starts of action triggers, beside the blob action results. */
|
|
20
|
+
export declare const WORKFLOW_STARTS_TABLE = "_workflow_starts";
|
|
21
|
+
/**
|
|
22
|
+
* The nil uuid: `record_id` is null when a trigger fires once for the action, for the record its
|
|
23
|
+
* input names, and the uniqueness index reads null as this value.
|
|
24
|
+
*/
|
|
25
|
+
export declare const NIL_RECORD_ID = "00000000-0000-0000-0000-000000000000";
|
|
26
|
+
/**
|
|
27
|
+
* One row per start an action trigger decided in an action's transaction: the durable decision to
|
|
28
|
+
* start `workflow` with `input`, in its wire form as the cron route receives it. `run_id` is set
|
|
29
|
+
* once the Workflow SDK accepted the run; a row without one is pending, and the sweep starts it.
|
|
30
|
+
*
|
|
31
|
+
* A primary key cannot hold the null `record_id` of a trigger that fires once for the action, so
|
|
32
|
+
* uniqueness per trigger, action and record is a unique index that reads null as the nil uuid.
|
|
33
|
+
*/
|
|
34
|
+
export declare const WORKFLOW_STARTS_DDL: ReadonlyArray<string>;
|
|
35
|
+
/** The prompts workflows hand the app's agent with `agentTask`, beside the workflow starts. */
|
|
36
|
+
export declare const AGENT_TASKS_TABLE = "_agent_tasks";
|
|
37
|
+
/**
|
|
38
|
+
* One row per `agentTask` call, keyed by its Workflow SDK hook token. A task is `pending` until the
|
|
39
|
+
* agent accepts it, then `started`, and ends `completed`, `needs_input`, `failed` or `timed_out`;
|
|
40
|
+
* the first terminal outcome wins. Only the SHA-256 of the task's secret is stored. `result` holds
|
|
41
|
+
* the terminal outcome's fields: the agent's text and whether it was cut, or the failure's reason.
|
|
42
|
+
*/
|
|
43
|
+
export declare const AGENT_TASKS_DDL: ReadonlyArray<string>;
|
|
44
|
+
/** The sign-in links actions asked to send with `User.sendSignInLink`, beside the agent tasks. */
|
|
45
|
+
export declare const SIGN_IN_EMAILS_TABLE = "_sign_in_emails";
|
|
46
|
+
/**
|
|
47
|
+
* One row per `User.sendSignInLink` call, written in the action's transaction. After the commit the
|
|
48
|
+
* ontology service asks the app's Neon Auth for a sign-in link to `return_to`, naming the row in
|
|
49
|
+
* the link's callback; Neon Auth posts the link to the platform's email webhook, which reads the
|
|
50
|
+
* row to send the workspace's `template` with `values`, or the platform's own email when `template`
|
|
51
|
+
* is null. `status` is `pending` until the request is made, then `requested`, or `failed` with the
|
|
52
|
+
* reason in `failure`. `sender_id` is the principal whose action asked, to whom replies go.
|
|
53
|
+
*/
|
|
54
|
+
export declare const SIGN_IN_EMAILS_DDL: ReadonlyArray<string>;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/** Storage metadata lives in the ontology database and is migrated by its SDK. */
|
|
2
|
+
export const BLOB_TABLES_DDL = [
|
|
3
|
+
`CREATE TABLE IF NOT EXISTS "_blobs" (
|
|
4
|
+
"id" uuid PRIMARY KEY,
|
|
5
|
+
"branch_id" text NOT NULL,
|
|
6
|
+
"key" text NOT NULL UNIQUE,
|
|
7
|
+
"filename" text NOT NULL,
|
|
8
|
+
"content_type" text NOT NULL,
|
|
9
|
+
"size" bigint NOT NULL CHECK ("size" > 0),
|
|
10
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
11
|
+
"state" text NOT NULL CHECK ("state" IN ('ready', 'retained', 'deleting', 'deleted')),
|
|
12
|
+
"entity_id" text,
|
|
13
|
+
"property_id" text,
|
|
14
|
+
"record_id" uuid
|
|
15
|
+
)`,
|
|
16
|
+
`CREATE TABLE IF NOT EXISTS "_blob_uploads" (
|
|
17
|
+
"id" uuid PRIMARY KEY,
|
|
18
|
+
"blob_id" uuid NOT NULL UNIQUE REFERENCES "_blobs" ("id"),
|
|
19
|
+
"principal_id" uuid NOT NULL REFERENCES "user" ("id"),
|
|
20
|
+
"branch_id" text NOT NULL,
|
|
21
|
+
"manifest_hash" text NOT NULL,
|
|
22
|
+
"action" text NOT NULL,
|
|
23
|
+
"entity_id" text NOT NULL,
|
|
24
|
+
"property_id" text NOT NULL,
|
|
25
|
+
"record_id" uuid,
|
|
26
|
+
"create_intent" uuid,
|
|
27
|
+
"filename" text NOT NULL,
|
|
28
|
+
"content_type" text NOT NULL,
|
|
29
|
+
"size" bigint NOT NULL CHECK ("size" > 0),
|
|
30
|
+
"provider_upload_id" text,
|
|
31
|
+
"state" text NOT NULL CHECK ("state" IN
|
|
32
|
+
('initializing', 'uploading', 'completing', 'ready', 'consumed', 'canceled', 'deleting', 'deleted')),
|
|
33
|
+
"claim" uuid,
|
|
34
|
+
"claimed_at" timestamptz,
|
|
35
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
36
|
+
"expires_at" timestamptz NOT NULL DEFAULT now() + interval '1 hour',
|
|
37
|
+
CHECK (("record_id" IS NULL) <> ("create_intent" IS NULL))
|
|
38
|
+
)`,
|
|
39
|
+
`CREATE INDEX IF NOT EXISTS "_blob_uploads_expiry_idx" ON "_blob_uploads" ("state", "expires_at")`,
|
|
40
|
+
`CREATE TABLE IF NOT EXISTS "_blob_references" (
|
|
41
|
+
"blob_id" uuid NOT NULL REFERENCES "_blobs" ("id"),
|
|
42
|
+
"entity_id" text NOT NULL,
|
|
43
|
+
"property_id" text NOT NULL,
|
|
44
|
+
"record_id" uuid NOT NULL,
|
|
45
|
+
"action_id" uuid NOT NULL,
|
|
46
|
+
PRIMARY KEY ("blob_id", "entity_id", "property_id", "record_id")
|
|
47
|
+
)`,
|
|
48
|
+
`CREATE TABLE IF NOT EXISTS "_blob_action_results" (
|
|
49
|
+
"principal_id" uuid NOT NULL REFERENCES "user" ("id"),
|
|
50
|
+
"key" text NOT NULL,
|
|
51
|
+
"fingerprint" text NOT NULL,
|
|
52
|
+
"outcome" jsonb,
|
|
53
|
+
PRIMARY KEY ("principal_id", "key")
|
|
54
|
+
)`,
|
|
55
|
+
];
|
|
56
|
+
/** The agent's temporary attachments, beside the blob tables whose storage they share. */
|
|
57
|
+
export const ATTACHMENTS_TABLE = "_agent_attachments";
|
|
58
|
+
/**
|
|
59
|
+
* Where an attachment comes from: a chat message, or a file the agent produced in its sandbox and
|
|
60
|
+
* stores so that an action can keep it.
|
|
61
|
+
*/
|
|
62
|
+
export const ATTACHMENT_SOURCES = ["telegram", "sandbox"];
|
|
63
|
+
/** The check that limits `source` to {@link ATTACHMENT_SOURCES}; its name is PostgreSQL's default. */
|
|
64
|
+
export const ATTACHMENT_SOURCE_CHECK = `${ATTACHMENTS_TABLE}_source_check`;
|
|
65
|
+
const SOURCE_CHECK = `CHECK ("source" IN (${ATTACHMENT_SOURCES.map((source) => `'${source}'`).join(", ")}))`;
|
|
66
|
+
/**
|
|
67
|
+
* A file a member sent the app's agent: platform metadata, never an ontology record. The bytes are
|
|
68
|
+
* a `_blobs` revision in the same storage as uploads; the row binds them to their owner, the chat
|
|
69
|
+
* and, for private chats, the first agent session that reads them. Group access follows the chat
|
|
70
|
+
* registry's current members. Attachments expire 24 hours after receipt unless promoted.
|
|
71
|
+
*/
|
|
72
|
+
export const ATTACHMENT_TABLES_DDL = [
|
|
73
|
+
`CREATE TABLE IF NOT EXISTS "${ATTACHMENTS_TABLE}" (
|
|
74
|
+
"id" uuid PRIMARY KEY,
|
|
75
|
+
"blob_id" uuid NOT NULL UNIQUE REFERENCES "_blobs" ("id"),
|
|
76
|
+
"branch_id" text NOT NULL,
|
|
77
|
+
"owner_id" uuid NOT NULL REFERENCES "user" ("id"),
|
|
78
|
+
"conversation" text NOT NULL,
|
|
79
|
+
"session_id" text,
|
|
80
|
+
"source" text NOT NULL CONSTRAINT "${ATTACHMENT_SOURCE_CHECK}" ${SOURCE_CHECK},
|
|
81
|
+
"source_ref" text NOT NULL,
|
|
82
|
+
"filename" text NOT NULL,
|
|
83
|
+
"content_type" text NOT NULL,
|
|
84
|
+
"size" bigint NOT NULL CHECK ("size" > 0),
|
|
85
|
+
"sha256" text NOT NULL CHECK ("sha256" ~ '^[0-9a-f]{64}$'),
|
|
86
|
+
"state" text NOT NULL CHECK ("state" IN ('received', 'ready', 'promoted', 'discarded', 'expired')),
|
|
87
|
+
"provider_upload_id" text,
|
|
88
|
+
"promotion" jsonb,
|
|
89
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
90
|
+
"expires_at" timestamptz NOT NULL DEFAULT now() + interval '24 hours',
|
|
91
|
+
"removed_at" timestamptz,
|
|
92
|
+
UNIQUE ("owner_id", "conversation", "source_ref")
|
|
93
|
+
)`,
|
|
94
|
+
`CREATE INDEX IF NOT EXISTS "${ATTACHMENTS_TABLE}_expiry_idx" ON "${ATTACHMENTS_TABLE}" ("state", "expires_at")`,
|
|
95
|
+
`CREATE INDEX IF NOT EXISTS "${ATTACHMENTS_TABLE}_sha256_idx" ON "${ATTACHMENTS_TABLE}" ("sha256")`,
|
|
96
|
+
// @legacy ontology.pre-upgrade-database-tolerance
|
|
97
|
+
// A table an earlier SDK created accepts fewer sources; widen its check in place.
|
|
98
|
+
`ALTER TABLE "${ATTACHMENTS_TABLE}" DROP CONSTRAINT IF EXISTS "${ATTACHMENT_SOURCE_CHECK}", ` +
|
|
99
|
+
`ADD CONSTRAINT "${ATTACHMENT_SOURCE_CHECK}" ${SOURCE_CHECK}`,
|
|
100
|
+
];
|
|
101
|
+
/** The pending and started workflow starts of action triggers, beside the blob action results. */
|
|
102
|
+
export const WORKFLOW_STARTS_TABLE = "_workflow_starts";
|
|
103
|
+
/**
|
|
104
|
+
* The nil uuid: `record_id` is null when a trigger fires once for the action, for the record its
|
|
105
|
+
* input names, and the uniqueness index reads null as this value.
|
|
106
|
+
*/
|
|
107
|
+
export const NIL_RECORD_ID = "00000000-0000-0000-0000-000000000000";
|
|
108
|
+
/**
|
|
109
|
+
* One row per start an action trigger decided in an action's transaction: the durable decision to
|
|
110
|
+
* start `workflow` with `input`, in its wire form as the cron route receives it. `run_id` is set
|
|
111
|
+
* once the Workflow SDK accepted the run; a row without one is pending, and the sweep starts it.
|
|
112
|
+
*
|
|
113
|
+
* A primary key cannot hold the null `record_id` of a trigger that fires once for the action, so
|
|
114
|
+
* uniqueness per trigger, action and record is a unique index that reads null as the nil uuid.
|
|
115
|
+
*/
|
|
116
|
+
export const WORKFLOW_STARTS_DDL = [
|
|
117
|
+
`CREATE TABLE IF NOT EXISTS "${WORKFLOW_STARTS_TABLE}" (
|
|
118
|
+
"trigger" text NOT NULL,
|
|
119
|
+
"action_id" uuid NOT NULL,
|
|
120
|
+
"record_id" uuid,
|
|
121
|
+
"workflow" text NOT NULL,
|
|
122
|
+
"input" jsonb NOT NULL,
|
|
123
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
124
|
+
"run_id" text,
|
|
125
|
+
"started_at" timestamptz,
|
|
126
|
+
"attempts" integer NOT NULL DEFAULT 0
|
|
127
|
+
)`,
|
|
128
|
+
`CREATE UNIQUE INDEX IF NOT EXISTS "${WORKFLOW_STARTS_TABLE}_key" ON "${WORKFLOW_STARTS_TABLE}" ` +
|
|
129
|
+
`("trigger", "action_id", COALESCE("record_id", '${NIL_RECORD_ID}'::uuid))`,
|
|
130
|
+
`CREATE INDEX IF NOT EXISTS "${WORKFLOW_STARTS_TABLE}_pending" ON "${WORKFLOW_STARTS_TABLE}" ` +
|
|
131
|
+
`("created_at") WHERE "run_id" IS NULL`,
|
|
132
|
+
`CREATE INDEX IF NOT EXISTS "${WORKFLOW_STARTS_TABLE}_workflow" ON "${WORKFLOW_STARTS_TABLE}" ` +
|
|
133
|
+
`("workflow", "created_at")`,
|
|
134
|
+
// @legacy ontology.workflow-cutover-artifacts
|
|
135
|
+
// Ontology SDKs 0.86.0 to 0.88.0 write this column and read `terminal_at` and the journal below.
|
|
136
|
+
`ALTER TABLE "${WORKFLOW_STARTS_TABLE}" ADD COLUMN IF NOT EXISTS admission_generation bigint`,
|
|
137
|
+
`ALTER TABLE "${WORKFLOW_STARTS_TABLE}" ADD COLUMN IF NOT EXISTS admission_deployment_id text`,
|
|
138
|
+
`ALTER TABLE "${WORKFLOW_STARTS_TABLE}" ADD COLUMN IF NOT EXISTS reservation jsonb`,
|
|
139
|
+
`ALTER TABLE "${WORKFLOW_STARTS_TABLE}" ADD COLUMN IF NOT EXISTS arguments jsonb`,
|
|
140
|
+
`ALTER TABLE "${WORKFLOW_STARTS_TABLE}" ADD COLUMN IF NOT EXISTS admission_attributes jsonb`,
|
|
141
|
+
`ALTER TABLE "${WORKFLOW_STARTS_TABLE}" ADD COLUMN IF NOT EXISTS provider_workflow_id text`,
|
|
142
|
+
`ALTER TABLE "${WORKFLOW_STARTS_TABLE}" ADD COLUMN IF NOT EXISTS terminal_at timestamptz`,
|
|
143
|
+
`ALTER TABLE "${WORKFLOW_STARTS_TABLE}" ADD COLUMN IF NOT EXISTS submission_lease_until timestamptz`,
|
|
144
|
+
// @legacy ontology.workflow-cutover-artifacts
|
|
145
|
+
`CREATE TABLE IF NOT EXISTS _workflow_admission (
|
|
146
|
+
id boolean PRIMARY KEY DEFAULT true CHECK(id),
|
|
147
|
+
generation bigint NOT NULL DEFAULT 1,
|
|
148
|
+
phase text NOT NULL DEFAULT 'open' CHECK(phase IN ('open','fenced','migrated','recovery')),
|
|
149
|
+
contract_hash text NOT NULL,catalog_hash text NOT NULL,
|
|
150
|
+
owner text,target_hash text,deadline timestamptz,drained_generation bigint,resume_phase text
|
|
151
|
+
)`,
|
|
152
|
+
];
|
|
153
|
+
/** The prompts workflows hand the app's agent with `agentTask`, beside the workflow starts. */
|
|
154
|
+
export const AGENT_TASKS_TABLE = "_agent_tasks";
|
|
155
|
+
/**
|
|
156
|
+
* One row per `agentTask` call, keyed by its Workflow SDK hook token. A task is `pending` until the
|
|
157
|
+
* agent accepts it, then `started`, and ends `completed`, `needs_input`, `failed` or `timed_out`;
|
|
158
|
+
* the first terminal outcome wins. Only the SHA-256 of the task's secret is stored. `result` holds
|
|
159
|
+
* the terminal outcome's fields: the agent's text and whether it was cut, or the failure's reason.
|
|
160
|
+
*/
|
|
161
|
+
export const AGENT_TASKS_DDL = [
|
|
162
|
+
`CREATE TABLE IF NOT EXISTS "${AGENT_TASKS_TABLE}" (
|
|
163
|
+
"id" uuid PRIMARY KEY,
|
|
164
|
+
"workflow" text NOT NULL,
|
|
165
|
+
"run_id" text NOT NULL,
|
|
166
|
+
"hook_token" text NOT NULL UNIQUE,
|
|
167
|
+
"secret_sha256" text NOT NULL UNIQUE CHECK ("secret_sha256" ~ '^[0-9a-f]{64}$'),
|
|
168
|
+
"prompt" text NOT NULL,
|
|
169
|
+
"status" text NOT NULL CHECK ("status" IN
|
|
170
|
+
('pending', 'started', 'completed', 'needs_input', 'failed', 'timed_out')),
|
|
171
|
+
"result" jsonb,
|
|
172
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
173
|
+
"started_at" timestamptz,
|
|
174
|
+
"finished_at" timestamptz,
|
|
175
|
+
"deadline_at" timestamptz NOT NULL
|
|
176
|
+
)`,
|
|
177
|
+
`CREATE INDEX IF NOT EXISTS "${AGENT_TASKS_TABLE}_deadline" ON "${AGENT_TASKS_TABLE}" ("deadline_at")`,
|
|
178
|
+
];
|
|
179
|
+
/** The sign-in links actions asked to send with `User.sendSignInLink`, beside the agent tasks. */
|
|
180
|
+
export const SIGN_IN_EMAILS_TABLE = "_sign_in_emails";
|
|
181
|
+
/**
|
|
182
|
+
* One row per `User.sendSignInLink` call, written in the action's transaction. After the commit the
|
|
183
|
+
* ontology service asks the app's Neon Auth for a sign-in link to `return_to`, naming the row in
|
|
184
|
+
* the link's callback; Neon Auth posts the link to the platform's email webhook, which reads the
|
|
185
|
+
* row to send the workspace's `template` with `values`, or the platform's own email when `template`
|
|
186
|
+
* is null. `status` is `pending` until the request is made, then `requested`, or `failed` with the
|
|
187
|
+
* reason in `failure`. `sender_id` is the principal whose action asked, to whom replies go.
|
|
188
|
+
*/
|
|
189
|
+
export const SIGN_IN_EMAILS_DDL = [
|
|
190
|
+
`CREATE TABLE IF NOT EXISTS "${SIGN_IN_EMAILS_TABLE}" (
|
|
191
|
+
"id" uuid PRIMARY KEY,
|
|
192
|
+
"user_id" uuid NOT NULL REFERENCES "user" ("id") ON DELETE CASCADE,
|
|
193
|
+
"email" text NOT NULL,
|
|
194
|
+
"template" text,
|
|
195
|
+
"values" jsonb NOT NULL,
|
|
196
|
+
"return_to" text NOT NULL,
|
|
197
|
+
"action_id" uuid NOT NULL,
|
|
198
|
+
"sender_id" uuid,
|
|
199
|
+
"status" text NOT NULL CHECK ("status" IN ('pending', 'requested', 'failed')),
|
|
200
|
+
"failure" text,
|
|
201
|
+
"created_at" timestamptz NOT NULL DEFAULT now(),
|
|
202
|
+
"requested_at" timestamptz
|
|
203
|
+
)`,
|
|
204
|
+
`CREATE INDEX IF NOT EXISTS "${SIGN_IN_EMAILS_TABLE}_created" ON "${SIGN_IN_EMAILS_TABLE}" ("created_at")`,
|
|
205
|
+
];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Effect, Stream, type Scope } from "effect";
|
|
2
|
+
import { type ActionError } from "../errors.js";
|
|
3
|
+
import type { TransferGrant } from "./provider.js";
|
|
4
|
+
/** The storage grant owns the destination; the source is streamed with bounded backpressure. */
|
|
5
|
+
export declare function uploadFile<E, R>(input: {
|
|
6
|
+
readonly grant: TransferGrant;
|
|
7
|
+
readonly size: number;
|
|
8
|
+
readonly source: Stream.Stream<Uint8Array, E, R>;
|
|
9
|
+
readonly fetch: typeof fetch;
|
|
10
|
+
}): Effect.Effect<void, E | ActionError, R>;
|
|
11
|
+
/** Opens a signed immutable revision; scope closure cancels unread or interrupted downloads. */
|
|
12
|
+
export declare function openFile(input: {
|
|
13
|
+
readonly grant: TransferGrant;
|
|
14
|
+
readonly size: number;
|
|
15
|
+
readonly fetch: typeof fetch;
|
|
16
|
+
}): Effect.Effect<Stream.Stream<Uint8Array, ActionError>, ActionError, Scope.Scope>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Deferred, Effect, Option, Stream } from "effect";
|
|
2
|
+
import { ActionRejected } from "../errors.js";
|
|
3
|
+
const TRANSFER_TIMEOUT_MS = 4 * 60 * 1000;
|
|
4
|
+
/** Keep storage's explanation in diagnostics, redacting the signed grant's credential values. */
|
|
5
|
+
function transferFailure(response, grant) {
|
|
6
|
+
return Effect.gen(function* () {
|
|
7
|
+
let detail = "";
|
|
8
|
+
let readCause;
|
|
9
|
+
const stream = response.body;
|
|
10
|
+
if (stream) {
|
|
11
|
+
yield* Effect.acquireUseRelease(Effect.sync(() => stream.getReader()), (reader) => Effect.tryPromise({
|
|
12
|
+
try: async () => {
|
|
13
|
+
const chunks = [];
|
|
14
|
+
let remaining = 65_536;
|
|
15
|
+
while (remaining > 0) {
|
|
16
|
+
const next = await reader.read();
|
|
17
|
+
if (next.done) {
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
chunks.push(next.value.subarray(0, remaining));
|
|
21
|
+
remaining -= next.value.length;
|
|
22
|
+
}
|
|
23
|
+
detail = Buffer.concat(chunks).toString("utf8");
|
|
24
|
+
},
|
|
25
|
+
catch: (cause) => cause,
|
|
26
|
+
}).pipe(Effect.timeout("5 seconds"), Effect.catch((cause) => Effect.sync(() => {
|
|
27
|
+
readCause = cause;
|
|
28
|
+
}))), (reader) => Effect.tryPromise({ try: () => reader.cancel(), catch: (cause) => cause }).pipe(Effect.timeout("1 second"), Effect.catch((cause) => Effect.logError("ontology.storage.response_cleanup_failed", cause)), Effect.ensuring(Effect.sync(() => reader.releaseLock()))));
|
|
29
|
+
}
|
|
30
|
+
const protectedValues = [grant.url, ...Object.values(grant.headers)];
|
|
31
|
+
for (const [name, value] of new URL(grant.url).searchParams) {
|
|
32
|
+
if (/signature|credential|token|key/i.test(name)) {
|
|
33
|
+
protectedValues.push(value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const value of protectedValues.filter(Boolean)) {
|
|
37
|
+
detail = detail
|
|
38
|
+
.replaceAll(value, "[REDACTED]")
|
|
39
|
+
.replaceAll(encodeURIComponent(value), "[REDACTED]");
|
|
40
|
+
}
|
|
41
|
+
return new ActionRejected({
|
|
42
|
+
message: "file_transfer_failed",
|
|
43
|
+
cause: { status: response.status, detail, ...(readCause === undefined ? {} : { readCause }) },
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** The storage grant owns the destination; the source is streamed with bounded backpressure. */
|
|
48
|
+
export function uploadFile(input) {
|
|
49
|
+
return Effect.scoped(Effect.gen(function* () {
|
|
50
|
+
let size = 0;
|
|
51
|
+
let ended = false;
|
|
52
|
+
let sourceFailure = Option.none();
|
|
53
|
+
const checked = input.source.pipe(Stream.tap((chunk) => Effect.suspend(() => {
|
|
54
|
+
size += chunk.byteLength;
|
|
55
|
+
return size <= input.size
|
|
56
|
+
? Effect.void
|
|
57
|
+
: Effect.fail(new ActionRejected({ message: "file_size_mismatch" }));
|
|
58
|
+
})), Stream.concat(Stream.fromEffect(Effect.suspend(() => {
|
|
59
|
+
if (size !== input.size) {
|
|
60
|
+
return Effect.fail(new ActionRejected({ message: "file_size_mismatch" }));
|
|
61
|
+
}
|
|
62
|
+
ended = true;
|
|
63
|
+
return Effect.void;
|
|
64
|
+
})).pipe(Stream.drain)), Stream.tapError((error) => Effect.sync(() => {
|
|
65
|
+
sourceFailure = Option.some(error);
|
|
66
|
+
})));
|
|
67
|
+
const stopped = yield* Deferred.make();
|
|
68
|
+
const finished = yield* Deferred.make();
|
|
69
|
+
const body = yield* Stream.toReadableStreamEffect(checked.pipe(Stream.interruptWhen(Deferred.await(stopped)), Stream.ensuring(Deferred.succeed(finished, undefined))), {
|
|
70
|
+
strategy: { highWaterMark: 1 },
|
|
71
|
+
});
|
|
72
|
+
yield* Effect.addFinalizer(() => Effect.gen(function* () {
|
|
73
|
+
yield* Deferred.succeed(stopped, undefined);
|
|
74
|
+
yield* Deferred.await(finished).pipe(Effect.timeout("1 second"), Effect.catch((cause) => Effect.logError("ontology.storage.source_cleanup_failed", cause)));
|
|
75
|
+
}));
|
|
76
|
+
const controller = yield* Effect.acquireRelease(Effect.sync(() => new AbortController()), (controller) => Effect.sync(() => controller.abort()));
|
|
77
|
+
const response = yield* Effect.tryPromise({
|
|
78
|
+
try: (signal) => input.fetch(input.grant.url, {
|
|
79
|
+
method: "PUT",
|
|
80
|
+
headers: { ...input.grant.headers, "content-length": String(input.size) },
|
|
81
|
+
body,
|
|
82
|
+
duplex: "half",
|
|
83
|
+
redirect: "error",
|
|
84
|
+
signal: AbortSignal.any([
|
|
85
|
+
signal,
|
|
86
|
+
controller.signal,
|
|
87
|
+
AbortSignal.timeout(TRANSFER_TIMEOUT_MS),
|
|
88
|
+
]),
|
|
89
|
+
}),
|
|
90
|
+
catch: (cause) => new ActionRejected({ message: "file_transfer_failed", cause }),
|
|
91
|
+
}).pipe(Effect.catch((error) => Option.isSome(sourceFailure) ? Effect.fail(sourceFailure.value) : Effect.fail(error)));
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
const error = yield* transferFailure(response, input.grant);
|
|
94
|
+
return yield* error;
|
|
95
|
+
}
|
|
96
|
+
yield* Effect.tryPromise({
|
|
97
|
+
try: () => response.body?.cancel() ?? Promise.resolve(),
|
|
98
|
+
catch: (cause) => cause,
|
|
99
|
+
}).pipe(Effect.catch((cause) => Effect.logError("ontology.storage.response_cleanup_failed", cause)));
|
|
100
|
+
if (!ended) {
|
|
101
|
+
return yield* new ActionRejected({
|
|
102
|
+
message: "file_transfer_failed",
|
|
103
|
+
cause: { status: response.status, ended },
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
/** Opens a signed immutable revision; scope closure cancels unread or interrupted downloads. */
|
|
109
|
+
export function openFile(input) {
|
|
110
|
+
return Effect.gen(function* () {
|
|
111
|
+
const controller = yield* Effect.acquireRelease(Effect.sync(() => new AbortController()), (controller) => Effect.sync(() => controller.abort()));
|
|
112
|
+
const response = yield* Effect.tryPromise({
|
|
113
|
+
try: (signal) => input.fetch(input.grant.url, {
|
|
114
|
+
method: "GET",
|
|
115
|
+
headers: input.grant.headers,
|
|
116
|
+
redirect: "error",
|
|
117
|
+
signal: AbortSignal.any([
|
|
118
|
+
signal,
|
|
119
|
+
controller.signal,
|
|
120
|
+
AbortSignal.timeout(TRANSFER_TIMEOUT_MS),
|
|
121
|
+
]),
|
|
122
|
+
}),
|
|
123
|
+
catch: (cause) => new ActionRejected({ message: "file_transfer_failed", cause }),
|
|
124
|
+
});
|
|
125
|
+
const stream = response.body;
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
const error = yield* transferFailure(response, input.grant);
|
|
128
|
+
return yield* error;
|
|
129
|
+
}
|
|
130
|
+
if (!stream) {
|
|
131
|
+
return yield* new ActionRejected({
|
|
132
|
+
message: "file_transfer_failed",
|
|
133
|
+
cause: { status: response.status },
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
yield* Effect.addFinalizer(() => Effect.tryPromise({
|
|
137
|
+
try: () => (stream.locked ? Promise.resolve() : stream.cancel()),
|
|
138
|
+
catch: (cause) => cause,
|
|
139
|
+
}).pipe(Effect.catch((cause) => Effect.logError("ontology.storage.response_cleanup_failed", cause))));
|
|
140
|
+
let size = 0;
|
|
141
|
+
return Stream.fromReadableStream({
|
|
142
|
+
evaluate: () => stream,
|
|
143
|
+
onError: (cause) => new ActionRejected({ message: "file_transfer_failed", cause }),
|
|
144
|
+
}).pipe(Stream.tap((chunk) => Effect.suspend(() => {
|
|
145
|
+
size += chunk.byteLength;
|
|
146
|
+
return size <= input.size
|
|
147
|
+
? Effect.void
|
|
148
|
+
: Effect.fail(new ActionRejected({ message: "file_size_mismatch" }));
|
|
149
|
+
})), Stream.concat(Stream.fromEffect(Effect.suspend(() => size === input.size
|
|
150
|
+
? Effect.void
|
|
151
|
+
: Effect.fail(new ActionRejected({ message: "file_size_mismatch" })))).pipe(Stream.drain)));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Conflict } from "../errors.js";
|
|
3
|
+
import type { StoredValues } from "../runtime.js";
|
|
4
|
+
import type { EntityModel } from "../runtime/model.js";
|
|
5
|
+
import type { WriteContext } from "../runtime/writes.js";
|
|
6
|
+
/** Resolves tickets in the action's transaction. There is no provider I/O here. */
|
|
7
|
+
export declare function resolveBlobWrites(context: WriteContext, entity: EntityModel, recordId: string, values: StoredValues, creating: boolean): Effect.Effect<Record<string, unknown>, Conflict | import("effect/unstable/sql/SqlError").SqlError, never>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { authorizeBlobOperation } from "./authorization.js";
|
|
3
|
+
import { generatedActionPermissions } from "../permissions.js";
|
|
4
|
+
import { Conflict } from "../errors.js";
|
|
5
|
+
import { isRecordId } from "../runtime/records.js";
|
|
6
|
+
import { Params } from "../runtime/statement.js";
|
|
7
|
+
/** Resolves tickets in the action's transaction. There is no provider I/O here. */
|
|
8
|
+
export function resolveBlobWrites(context, entity, recordId, values, creating) {
|
|
9
|
+
return Effect.gen(function* () {
|
|
10
|
+
const resolved = { ...values };
|
|
11
|
+
for (const property of entity.manifest.properties.filter((field) => field.type === "blob")) {
|
|
12
|
+
const value = values[property.name];
|
|
13
|
+
if (value === undefined || value === null) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const reject = () => new Conflict({
|
|
17
|
+
entity: entity.name,
|
|
18
|
+
property: property.name,
|
|
19
|
+
message: "This upload cannot be attached to this record.",
|
|
20
|
+
});
|
|
21
|
+
const uploadId = typeof value === "object" && "uploadId" in value ? value.uploadId : undefined;
|
|
22
|
+
if (typeof uploadId !== "string" ||
|
|
23
|
+
!isRecordId(uploadId) ||
|
|
24
|
+
!context.scope.branchId ||
|
|
25
|
+
!context.scope.principalId ||
|
|
26
|
+
!context.scope.blobActionKey) {
|
|
27
|
+
return yield* reject();
|
|
28
|
+
}
|
|
29
|
+
const [actionEntity, actionName] = context.scope.action.split(".");
|
|
30
|
+
const authored = context.model.ontology.entities
|
|
31
|
+
.find((item) => item.name === actionEntity)
|
|
32
|
+
?.actions.find((item) => item.name === actionName);
|
|
33
|
+
yield* authorizeBlobOperation(context.model.ontology, {
|
|
34
|
+
unsafe: (statement, args) => {
|
|
35
|
+
const params = new Params();
|
|
36
|
+
// The authorization statements use positional parameters and no dynamic identifiers.
|
|
37
|
+
for (const value of args) {
|
|
38
|
+
params.add(value, "text");
|
|
39
|
+
}
|
|
40
|
+
return context.run(statement, params);
|
|
41
|
+
},
|
|
42
|
+
}, context.scope.principalId, authored ? [authored.permission] : generatedActionPermissions(actionEntity, actionName), context.scope.execution, context.scope.workflow).pipe(Effect.catchTag("PermissionDenied", () => Effect.fail(reject())));
|
|
43
|
+
const params = new Params();
|
|
44
|
+
const rows = yield* context.run(`SELECT u.*, b.id::text AS blob_id, b.filename, b.content_type, b.size::text AS size,
|
|
45
|
+
to_char(b.created_at AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') AS created_at
|
|
46
|
+
FROM "_blob_uploads" u JOIN "_blobs" b ON b.id = u.blob_id
|
|
47
|
+
JOIN "user" p ON p.id = u.principal_id AND p.active = true
|
|
48
|
+
WHERE u.id = ${params.add(uploadId, "uuid")}
|
|
49
|
+
AND u.principal_id = ${params.add(context.scope.principalId, "uuid")}
|
|
50
|
+
AND u.branch_id = ${params.add(context.scope.branchId, "text")}
|
|
51
|
+
AND u.manifest_hash = ${params.add(context.model.ontology.manifest.hash, "text")}
|
|
52
|
+
AND u.action = ${params.add(context.scope.action, "text")}
|
|
53
|
+
AND u.entity_id = ${params.add(entity.manifest.id, "text")}
|
|
54
|
+
AND u.property_id = ${params.add(property.name, "text")}
|
|
55
|
+
AND u.state = 'ready' AND u.expires_at > now() AND b.state = 'ready'
|
|
56
|
+
FOR UPDATE OF u, b FOR SHARE OF p`, params);
|
|
57
|
+
const row = rows[0];
|
|
58
|
+
if (!row ||
|
|
59
|
+
(creating
|
|
60
|
+
? row.create_intent !== context.scope.createIntent
|
|
61
|
+
: row.record_id !== recordId.toLowerCase())) {
|
|
62
|
+
return yield* reject();
|
|
63
|
+
}
|
|
64
|
+
const consume = new Params();
|
|
65
|
+
yield* context.run(`UPDATE "_blob_uploads" SET state = 'consumed'
|
|
66
|
+
WHERE id = ${consume.add(uploadId, "uuid")}`, consume);
|
|
67
|
+
const retain = new Params();
|
|
68
|
+
yield* context.run(`UPDATE "_blobs" SET state = 'retained',
|
|
69
|
+
entity_id = ${retain.add(entity.manifest.id, "text")},
|
|
70
|
+
property_id = ${retain.add(property.name, "text")}, record_id = ${retain.add(recordId, "uuid")}
|
|
71
|
+
WHERE id = ${retain.add(row.blob_id, "uuid")}`, retain);
|
|
72
|
+
const reference = new Params();
|
|
73
|
+
yield* context.run(`INSERT INTO "_blob_references"
|
|
74
|
+
(blob_id, entity_id, property_id, record_id, action_id) VALUES
|
|
75
|
+
(${reference.add(row.blob_id, "uuid")}, ${reference.add(entity.manifest.id, "text")},
|
|
76
|
+
${reference.add(property.name, "text")}, ${reference.add(recordId, "uuid")},
|
|
77
|
+
${reference.add(context.scope.actionId, "uuid")})`, reference);
|
|
78
|
+
resolved[property.name] = {
|
|
79
|
+
id: row.blob_id,
|
|
80
|
+
filename: row.filename,
|
|
81
|
+
contentType: row.content_type,
|
|
82
|
+
size: Number(row.size),
|
|
83
|
+
createdAt: row.created_at,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return resolved;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const TELEGRAM_LINK_PREVIEWS: readonly ["external", "none", "all"];
|
|
2
|
+
export type TelegramLinkPreviews = (typeof TELEGRAM_LINK_PREVIEWS)[number];
|
|
3
|
+
/** Settings belong to the destination connection, independently of the source channel. */
|
|
4
|
+
export interface TelegramPreviewSettings {
|
|
5
|
+
readonly connection: string;
|
|
6
|
+
readonly linkPreviews?: TelegramLinkPreviews;
|
|
7
|
+
readonly additionalOwnOrigins?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export interface TelegramPreviewContext {
|
|
10
|
+
readonly settings?: TelegramPreviewSettings;
|
|
11
|
+
readonly ownOrigins?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export interface TelegramLinkEntity {
|
|
14
|
+
readonly type: string;
|
|
15
|
+
readonly offset: number;
|
|
16
|
+
readonly length: number;
|
|
17
|
+
readonly url?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Normalize HTTP(S) origins only; credential-bearing and non-web destinations are ineligible. */
|
|
20
|
+
export declare function httpOrigin(value: string): string | undefined;
|
|
21
|
+
export declare function isHttpOrigin(value: unknown): value is string;
|
|
22
|
+
/** Also validates programmatic standalone service configuration. */
|
|
23
|
+
export declare function validateTelegramPreviews(settings: TelegramPreviewSettings): void;
|
|
24
|
+
/** Public, non-secret deployment metadata; no request headers or cross-tenant suffix matching. */
|
|
25
|
+
export declare function telegramPreviewEnvironment(environment: Readonly<Record<string, string | undefined>>): {
|
|
26
|
+
readonly channels?: {
|
|
27
|
+
readonly telegram?: TelegramPreviewSettings;
|
|
28
|
+
};
|
|
29
|
+
readonly appOrigins: string[];
|
|
30
|
+
};
|
|
31
|
+
export declare function telegramMarkdownLinks(markdown: string): readonly string[];
|
|
32
|
+
/** Visible URLs and hidden destinations, excluding formatted code and linked-label lookalikes. */
|
|
33
|
+
export declare function telegramTextLinks(text: string, entities?: readonly TelegramLinkEntity[]): readonly string[];
|
|
34
|
+
/** Explicit modern > explicit legacy > channel mode > external default. Never merge caller options. */
|
|
35
|
+
export declare function telegramPreviewOptions(caller: Readonly<Record<string, unknown>>, links: readonly string[], context?: TelegramPreviewContext): Record<string, unknown>;
|