@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,286 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { BaseBuilder, createBaseBuilderConfig } from "@workflow/builders";
|
|
5
|
+
import { workflowTransformPlugin } from "@workflow/rollup";
|
|
6
|
+
/** The directory, inside Nitro's build directory, that holds the generated bundles. */
|
|
7
|
+
export function workflowBuildDir(buildDir) {
|
|
8
|
+
return join(buildDir, "ontology-workflows");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The directory that holds the platform's own workflow files, which the builder writes before
|
|
12
|
+
* every build and compiles with the workspace's. Beside the navigation artifact under the
|
|
13
|
+
* project's `.segmentstream/`, which the starter ignores in Git: the Workflow SDK's builder
|
|
14
|
+
* skips files under Nitro's `.nitro/` build directory, so they cannot live there.
|
|
15
|
+
*/
|
|
16
|
+
export function platformWorkflowDir(rootDir) {
|
|
17
|
+
return join(rootDir, ".segmentstream", "platform-workflows");
|
|
18
|
+
}
|
|
19
|
+
/** The platform workflow file the builder writes, and the name of its workflow function. */
|
|
20
|
+
export const PLATFORM_WORKFLOW_FILE = "recover-starts.ts";
|
|
21
|
+
export const PLATFORM_RECOVERY_WORKFLOW = "recoverStarts";
|
|
22
|
+
/**
|
|
23
|
+
* The platform's start recovery workflow, as a workflow file of the workspace's build: its body is
|
|
24
|
+
* the SDK's, so an SDK upgrade changes what the run does without touching the workspace's code.
|
|
25
|
+
*/
|
|
26
|
+
export function platformWorkflowSource(settings = {}) {
|
|
27
|
+
const from = settings.imports?.workflows ?? "@segmentstream/ontology/workflows";
|
|
28
|
+
const delays = settings.delays === undefined ? "" : JSON.stringify(settings.delays);
|
|
29
|
+
return [
|
|
30
|
+
"// Written by @segmentstream/ontology's ontologyWorkflows() before every build; not part",
|
|
31
|
+
"// of the workspace's code. The platform's start recovery run: an action whose triggers may fire",
|
|
32
|
+
"// arms one before its transaction, and it sleeps, then starts the pending starts the request",
|
|
33
|
+
"// left; see the SDK's start-recovery.ts.",
|
|
34
|
+
`import { recoverWorkflowStarts } from ${JSON.stringify(from)};`,
|
|
35
|
+
...(settings.imports?.steps ?? []).map((module) => `import ${JSON.stringify(module)};`),
|
|
36
|
+
"",
|
|
37
|
+
`export async function ${PLATFORM_RECOVERY_WORKFLOW}() {`,
|
|
38
|
+
' "use workflow";',
|
|
39
|
+
"",
|
|
40
|
+
` return recoverWorkflowStarts(${delays});`,
|
|
41
|
+
"}",
|
|
42
|
+
"",
|
|
43
|
+
].join("\n");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The Nitro plugin that registers the compiled platform workflow with the SDK at startup, so that
|
|
47
|
+
* the service starts it as it starts a declared workflow's `run`. The server build's transform
|
|
48
|
+
* compiles the imported function like the workspace's workflow files.
|
|
49
|
+
*/
|
|
50
|
+
export function platformPluginSource(input) {
|
|
51
|
+
const server = input.server ?? "@segmentstream/ontology/server";
|
|
52
|
+
return [
|
|
53
|
+
`import { registerPlatformWorkflows } from ${JSON.stringify(server)};`,
|
|
54
|
+
`import { ${PLATFORM_RECOVERY_WORKFLOW} } from ${JSON.stringify(pathToFileURL(input.file).href)};`,
|
|
55
|
+
"",
|
|
56
|
+
"export default function registerOntologyPlatformWorkflows() {",
|
|
57
|
+
` registerPlatformWorkflows({ recoverStarts: ${PLATFORM_RECOVERY_WORKFLOW} });`,
|
|
58
|
+
"}",
|
|
59
|
+
"",
|
|
60
|
+
].join("\n");
|
|
61
|
+
}
|
|
62
|
+
/** The generated entrypoint call the builder writes, before the namespace is added to it. */
|
|
63
|
+
const ENTRYPOINT_CALL = "workflowEntrypoint(workflowCode, {";
|
|
64
|
+
/**
|
|
65
|
+
* Bundles a folder's workflows and steps as the ontology service serves them, as the SDK's own
|
|
66
|
+
* Nitro integration does since version 5: `steps.mjs` registers the steps, and `workflows.mjs`
|
|
67
|
+
* imports it and exports the flow handler, `workflowEntrypoint(code, { namespace, basePath })`,
|
|
68
|
+
* which runs the steps. Bundles import the rest of the project and its packages, which the server
|
|
69
|
+
* build resolves.
|
|
70
|
+
*/
|
|
71
|
+
export class OntologyWorkflowBuilder extends BaseBuilder {
|
|
72
|
+
#outDir;
|
|
73
|
+
#namespace;
|
|
74
|
+
#platform;
|
|
75
|
+
constructor(input) {
|
|
76
|
+
super({
|
|
77
|
+
...createBaseBuilderConfig({
|
|
78
|
+
workingDir: input.workingDir,
|
|
79
|
+
...(input.projectRoot === undefined ? {} : { projectRoot: input.projectRoot }),
|
|
80
|
+
watch: input.watch ?? false,
|
|
81
|
+
dirs: input.platform === undefined ? input.dirs : [...input.dirs, input.platform.dir],
|
|
82
|
+
}),
|
|
83
|
+
// The builder only writes files here; no framework integration reads this target.
|
|
84
|
+
buildTarget: "next",
|
|
85
|
+
basePath: input.basePath,
|
|
86
|
+
});
|
|
87
|
+
this.#outDir = input.outDir;
|
|
88
|
+
this.#namespace = input.namespace;
|
|
89
|
+
this.#platform = input.platform;
|
|
90
|
+
}
|
|
91
|
+
get outDir() {
|
|
92
|
+
return this.#outDir;
|
|
93
|
+
}
|
|
94
|
+
/** The platform workflow file this build compiles, when it has one. */
|
|
95
|
+
get platformWorkflowFile() {
|
|
96
|
+
return this.#platform === undefined
|
|
97
|
+
? undefined
|
|
98
|
+
: join(this.#platform.dir, PLATFORM_WORKFLOW_FILE);
|
|
99
|
+
}
|
|
100
|
+
async build() {
|
|
101
|
+
if (this.#platform !== undefined) {
|
|
102
|
+
await mkdir(this.#platform.dir, { recursive: true });
|
|
103
|
+
await writeFile(join(this.#platform.dir, PLATFORM_WORKFLOW_FILE), platformWorkflowSource(this.#platform));
|
|
104
|
+
}
|
|
105
|
+
const inputFiles = await this.getInputFiles();
|
|
106
|
+
const flowFile = join(this.#outDir, "workflows.mjs");
|
|
107
|
+
await mkdir(this.#outDir, { recursive: true });
|
|
108
|
+
const built = (await this.createCombinedBundle({
|
|
109
|
+
inputFiles,
|
|
110
|
+
stepsOutfile: join(this.#outDir, "steps.mjs"),
|
|
111
|
+
flowOutfile: flowFile,
|
|
112
|
+
format: "esm",
|
|
113
|
+
bundleFinalOutput: false,
|
|
114
|
+
externalizeNonSteps: true,
|
|
115
|
+
bundleTransitiveLocalStepDependencies: this.config.watch,
|
|
116
|
+
}));
|
|
117
|
+
await Promise.all([built.stepsContext?.dispose(), built.interimBundleCtx?.dispose()]);
|
|
118
|
+
// The builder takes the namespace only from the environment; it is written here instead, so
|
|
119
|
+
// that no build of the app or the agent in the same project picks it up.
|
|
120
|
+
const flow = await readFile(flowFile, "utf8");
|
|
121
|
+
if (flow.split(ENTRYPOINT_CALL).length !== 2) {
|
|
122
|
+
throw new Error(`The Workflow SDK's generated flow route no longer contains ${ENTRYPOINT_CALL} once; ` +
|
|
123
|
+
"the ontology's queue namespace cannot be set.");
|
|
124
|
+
}
|
|
125
|
+
await writeFile(flowFile, flow.replace(ENTRYPOINT_CALL, `workflowEntrypoint(workflowCode, { namespace: ${JSON.stringify(this.#namespace)},`));
|
|
126
|
+
await this.createManifest({
|
|
127
|
+
workflowBundlePath: flowFile,
|
|
128
|
+
manifestDir: this.#outDir,
|
|
129
|
+
manifest: built.manifest,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** See `addNodeRequireBanner` in `workflow/nitro`: undici loads `node:http2` with `require`. */
|
|
134
|
+
const REQUIRE_BANNER = "import { createRequire as __wkfCreateRequire } from 'node:module'; " +
|
|
135
|
+
"if (typeof globalThis.require === 'undefined') { " +
|
|
136
|
+
"globalThis.require = __wkfCreateRequire(import.meta.url); }";
|
|
137
|
+
function addRequireBanner(config) {
|
|
138
|
+
const outputs = (Array.isArray(config.output) ? config.output : [(config.output ??= {})]);
|
|
139
|
+
for (const output of outputs) {
|
|
140
|
+
const existing = output.banner;
|
|
141
|
+
output.banner =
|
|
142
|
+
existing == null
|
|
143
|
+
? REQUIRE_BANNER
|
|
144
|
+
: typeof existing === "function"
|
|
145
|
+
? async (chunk) => `${REQUIRE_BANNER}\n${await existing(chunk)}`
|
|
146
|
+
: `${REQUIRE_BANNER}\n${String(existing)}`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const DEFAULT_IMPORTS = {
|
|
150
|
+
ontology: "@segmentstream/ontology",
|
|
151
|
+
nitroApp: "nitro/app",
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* The flow handler module. It answers only a queue delivery at its exact route, warms the
|
|
155
|
+
* ontology service of this instance first, through Nitro's own fetch, so that `run(effect)` finds
|
|
156
|
+
* its runtime, and keeps the request's Vercel OIDC token for the steps' connection calls.
|
|
157
|
+
*/
|
|
158
|
+
export function callbackHandlerSource(input) {
|
|
159
|
+
const { file, dev, route, namespace, statusPath } = input;
|
|
160
|
+
const imports = input.imports ?? DEFAULT_IMPORTS;
|
|
161
|
+
const options = JSON.stringify({ route, queuePrefix: `__${namespace}_wkf_workflow_` });
|
|
162
|
+
const head = [
|
|
163
|
+
`import { serverFetch } from ${JSON.stringify(imports.nitroApp)};`,
|
|
164
|
+
`import { serveWorkflowCallback } from ${JSON.stringify(imports.ontology)};`,
|
|
165
|
+
`const options = { ...${options}, warm: () => serverFetch(${JSON.stringify(statusPath)}) };`,
|
|
166
|
+
];
|
|
167
|
+
if (dev) {
|
|
168
|
+
// Load the bundle from disk on each change, outside Nitro's own module graph.
|
|
169
|
+
return [
|
|
170
|
+
'import { statSync } from "node:fs";',
|
|
171
|
+
'import { pathToFileURL } from "node:url";',
|
|
172
|
+
...head,
|
|
173
|
+
`const handlerPath = ${JSON.stringify(file)};`,
|
|
174
|
+
'let version = "";',
|
|
175
|
+
"let loaded;",
|
|
176
|
+
"async function load() {",
|
|
177
|
+
" const current = String(statSync(handlerPath).mtimeMs);",
|
|
178
|
+
" if (current !== version || loaded === undefined) {",
|
|
179
|
+
" version = current;",
|
|
180
|
+
' loaded = (await import(pathToFileURL(handlerPath).href + "?t=" + current)).POST;',
|
|
181
|
+
" }",
|
|
182
|
+
" return loaded;",
|
|
183
|
+
"}",
|
|
184
|
+
"export default async ({ req }) => serveWorkflowCallback(req, await load(), options);",
|
|
185
|
+
"",
|
|
186
|
+
].join("\n");
|
|
187
|
+
}
|
|
188
|
+
return [
|
|
189
|
+
`import { POST } from ${JSON.stringify(file)};`,
|
|
190
|
+
...head,
|
|
191
|
+
"export default async ({ req }) => serveWorkflowCallback(req, POST, options);",
|
|
192
|
+
"",
|
|
193
|
+
].join("\n");
|
|
194
|
+
}
|
|
195
|
+
export async function setupOntologyWorkflows(nitro, settings) {
|
|
196
|
+
const outDir = workflowBuildDir(nitro.options.buildDir);
|
|
197
|
+
const platformDir = platformWorkflowDir(nitro.options.rootDir);
|
|
198
|
+
const builder = new OntologyWorkflowBuilder({
|
|
199
|
+
workingDir: nitro.options.rootDir,
|
|
200
|
+
...(nitro.options.workspaceDir === undefined
|
|
201
|
+
? {}
|
|
202
|
+
: { projectRoot: nitro.options.workspaceDir }),
|
|
203
|
+
dirs: settings.dirs,
|
|
204
|
+
basePath: settings.basePath,
|
|
205
|
+
namespace: settings.namespace,
|
|
206
|
+
outDir,
|
|
207
|
+
watch: nitro.options.dev,
|
|
208
|
+
platform: { dir: platformDir },
|
|
209
|
+
});
|
|
210
|
+
const buildDirPrefix = `${nitro.options.buildDir.replace(/[\\/]+$/, "")}/`;
|
|
211
|
+
nitro.hooks.hook("rollup:before", ((_nitro, config) => {
|
|
212
|
+
// First, before other transforms rename classes; the generated bundles are already transformed.
|
|
213
|
+
// The platform workflow file, outside the build directory, is compiled here like the
|
|
214
|
+
// workspace's.
|
|
215
|
+
config.plugins.unshift(workflowTransformPlugin({ exclude: [buildDirPrefix] }));
|
|
216
|
+
if (!nitro.options.dev) {
|
|
217
|
+
addRequireBanner(config);
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
220
|
+
// The SDK's runtime imports `debug`, which unenv would otherwise mock.
|
|
221
|
+
nitro.options.alias.debug ??= "debug";
|
|
222
|
+
let initial = true;
|
|
223
|
+
// Builds write one directory, and an editor's save can reload Nitro twice in a row: builds run
|
|
224
|
+
// one at a time, and reloads during a build share the one build that follows it.
|
|
225
|
+
let running = Promise.resolve();
|
|
226
|
+
let queued;
|
|
227
|
+
const build = () => {
|
|
228
|
+
queued ??= running
|
|
229
|
+
.catch(() => undefined)
|
|
230
|
+
.then(() => {
|
|
231
|
+
queued = undefined;
|
|
232
|
+
return builder.build();
|
|
233
|
+
});
|
|
234
|
+
running = queued;
|
|
235
|
+
return queued;
|
|
236
|
+
};
|
|
237
|
+
nitro.hooks.hook("build:before", build);
|
|
238
|
+
if (nitro.options.dev) {
|
|
239
|
+
// A failed rebuild is reported once and keeps the server on the previous bundle.
|
|
240
|
+
const reported = new WeakMap();
|
|
241
|
+
nitro.hooks.hook("dev:reload", (async () => {
|
|
242
|
+
if (initial) {
|
|
243
|
+
initial = false;
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const built = build();
|
|
247
|
+
let settled = reported.get(built);
|
|
248
|
+
if (settled === undefined) {
|
|
249
|
+
settled = built.catch((error) => {
|
|
250
|
+
nitro.logger.error("The ontology's workflows failed to build.", error);
|
|
251
|
+
});
|
|
252
|
+
reported.set(built, settled);
|
|
253
|
+
}
|
|
254
|
+
await settled;
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
const id = "#segmentstream-ontology/workflow-flow";
|
|
258
|
+
const platformPlugin = "#segmentstream-ontology/platform-workflows";
|
|
259
|
+
// At startup, before any request: the service refuses an action whose triggers may fire until
|
|
260
|
+
// the platform's recovery workflow is registered.
|
|
261
|
+
(nitro.options.plugins ??= []).push(platformPlugin);
|
|
262
|
+
nitro.options.virtual[platformPlugin] = platformPluginSource({
|
|
263
|
+
file: join(platformDir, PLATFORM_WORKFLOW_FILE),
|
|
264
|
+
});
|
|
265
|
+
nitro.options.handlers.push({ route: settings.route, handler: id, lazy: true });
|
|
266
|
+
nitro.options.virtual[id] = callbackHandlerSource({
|
|
267
|
+
file: join(outDir, "workflows.mjs"),
|
|
268
|
+
dev: nitro.options.dev,
|
|
269
|
+
route: settings.route,
|
|
270
|
+
namespace: settings.namespace,
|
|
271
|
+
statusPath: `${settings.basePath}/status`,
|
|
272
|
+
});
|
|
273
|
+
if (nitro.options.preset.startsWith("vercel")) {
|
|
274
|
+
const vercel = (nitro.options.vercel ??= {});
|
|
275
|
+
const rules = (vercel.functionRules ??= {});
|
|
276
|
+
const existing = rules[settings.route] ?? {};
|
|
277
|
+
rules[settings.route] = {
|
|
278
|
+
...existing,
|
|
279
|
+
maxDuration: "max",
|
|
280
|
+
experimentalTriggers: [
|
|
281
|
+
...(existing.experimentalTriggers ?? []),
|
|
282
|
+
settings.trigger,
|
|
283
|
+
],
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}
|
package/dist/nitro.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The paths the ontology service answers, for the workspace's `ontology/nitro.config.ts`. They come
|
|
3
|
+
* from the SDK, so a path the service adds arrives with an upgrade and the config stays as it is.
|
|
4
|
+
* At its top level this entry imports only Nitro's types and `./workflow-topics.js`, which imports
|
|
5
|
+
* nothing; the build side loads when Nitro runs the module.
|
|
6
|
+
*/
|
|
7
|
+
import type { NitroModule } from "nitro/types";
|
|
8
|
+
export declare const ONTOLOGY_SERVICE_PATHS: readonly ["/api/ontology", "/api/ontology/**", "/mcp", "/.well-known/oauth-protected-resource", "/.well-known/oauth-protected-resource/mcp", "/.well-known/oauth-authorization-server", "/api/webhooks/**"];
|
|
9
|
+
/** A Nitro route to the service's handler, loaded on its first request. */
|
|
10
|
+
export interface OntologyRoute {
|
|
11
|
+
readonly handler: string;
|
|
12
|
+
readonly lazy: true;
|
|
13
|
+
}
|
|
14
|
+
/** The Nitro routes that send every path of the ontology service to one handler. */
|
|
15
|
+
export declare function ontologyRoutes(handler: string): Record<string, OntologyRoute>;
|
|
16
|
+
export { ONTOLOGY_QUEUE_NAMESPACE, WORKFLOW_FLOW_ROUTE, WORKFLOW_QUEUE_TRIGGER, } from "./workflow-topics.js";
|
|
17
|
+
export interface OntologyWorkflowsOptions {
|
|
18
|
+
/** The directories, relative to `ontology/`, that hold workflow files. Default `["./workflows"]`. */
|
|
19
|
+
readonly dirs?: ReadonlyArray<string>;
|
|
20
|
+
}
|
|
21
|
+
/** A Nitro module: `modules: [ontologyWorkflows()]` in `ontology/nitro.config.ts`. */
|
|
22
|
+
export type OntologyWorkflowsModule = NitroModule & {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The Workflow SDK, compiled and served by the ontology service: list it in `modules` of
|
|
27
|
+
* `ontology/nitro.config.ts`, in place of `workflow/nitro`. It
|
|
28
|
+
*
|
|
29
|
+
* - adds the SDK's transform to the server build, so `start` finds the compiled workflows;
|
|
30
|
+
* - before every build, bundles the workflows (`"use workflow"`) and their steps (`"use step"`) of
|
|
31
|
+
* `dirs` into Nitro's build directory, with the callback's base path `/api/ontology` and the
|
|
32
|
+
* queue namespace `ontology` written into the generated entrypoint;
|
|
33
|
+
* - mounts the flow handler, which runs the steps, in the ontology service's own server bundle at
|
|
34
|
+
* `/api/ontology/.well-known/workflow/v1/flow`, refusing anything but a queue delivery;
|
|
35
|
+
* - on Vercel, gives that route its own function with `maxDuration: "max"` and the queue trigger
|
|
36
|
+
* `__ontology_wkf_workflow_*`.
|
|
37
|
+
*
|
|
38
|
+
* It never uses `workflow/nitro`, and it mounts no webhook route.
|
|
39
|
+
*/
|
|
40
|
+
export declare function ontologyWorkflows(options?: OntologyWorkflowsOptions): OntologyWorkflowsModule;
|
package/dist/nitro.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ONTOLOGY_QUEUE_NAMESPACE, WORKFLOW_BASE_PATH, WORKFLOW_FLOW_ROUTE, WORKFLOW_QUEUE_TRIGGER, } from "./workflow-topics.js";
|
|
2
|
+
export const ONTOLOGY_SERVICE_PATHS = [
|
|
3
|
+
"/api/ontology",
|
|
4
|
+
"/api/ontology/**",
|
|
5
|
+
"/mcp",
|
|
6
|
+
// The MCP server's OAuth metadata, on the app's origin.
|
|
7
|
+
"/.well-known/oauth-protected-resource",
|
|
8
|
+
"/.well-known/oauth-protected-resource/mcp",
|
|
9
|
+
"/.well-known/oauth-authorization-server",
|
|
10
|
+
// Webhook deliveries; the deployment routes only the declared names here.
|
|
11
|
+
"/api/webhooks/**",
|
|
12
|
+
];
|
|
13
|
+
/** The Nitro routes that send every path of the ontology service to one handler. */
|
|
14
|
+
export function ontologyRoutes(handler) {
|
|
15
|
+
return Object.fromEntries(ONTOLOGY_SERVICE_PATHS.map((path) => [path, { handler, lazy: true }]));
|
|
16
|
+
}
|
|
17
|
+
export { ONTOLOGY_QUEUE_NAMESPACE, WORKFLOW_FLOW_ROUTE, WORKFLOW_QUEUE_TRIGGER, } from "./workflow-topics.js";
|
|
18
|
+
/**
|
|
19
|
+
* The Workflow SDK, compiled and served by the ontology service: list it in `modules` of
|
|
20
|
+
* `ontology/nitro.config.ts`, in place of `workflow/nitro`. It
|
|
21
|
+
*
|
|
22
|
+
* - adds the SDK's transform to the server build, so `start` finds the compiled workflows;
|
|
23
|
+
* - before every build, bundles the workflows (`"use workflow"`) and their steps (`"use step"`) of
|
|
24
|
+
* `dirs` into Nitro's build directory, with the callback's base path `/api/ontology` and the
|
|
25
|
+
* queue namespace `ontology` written into the generated entrypoint;
|
|
26
|
+
* - mounts the flow handler, which runs the steps, in the ontology service's own server bundle at
|
|
27
|
+
* `/api/ontology/.well-known/workflow/v1/flow`, refusing anything but a queue delivery;
|
|
28
|
+
* - on Vercel, gives that route its own function with `maxDuration: "max"` and the queue trigger
|
|
29
|
+
* `__ontology_wkf_workflow_*`.
|
|
30
|
+
*
|
|
31
|
+
* It never uses `workflow/nitro`, and it mounts no webhook route.
|
|
32
|
+
*/
|
|
33
|
+
export function ontologyWorkflows(options = {}) {
|
|
34
|
+
return {
|
|
35
|
+
name: "segmentstream-ontology-workflows",
|
|
36
|
+
async setup(nitro) {
|
|
37
|
+
const { setupNavigationCatalog } = await import("./nitro-navigation.js");
|
|
38
|
+
await setupNavigationCatalog(nitro);
|
|
39
|
+
// Loaded here, while Nitro builds: this entry imports nothing at its top level.
|
|
40
|
+
const { setupOntologyWorkflows } = await import("./nitro-workflows.js");
|
|
41
|
+
await setupOntologyWorkflows(nitro, {
|
|
42
|
+
dirs: [...(options.dirs ?? ["./workflows"])],
|
|
43
|
+
basePath: WORKFLOW_BASE_PATH,
|
|
44
|
+
namespace: ONTOLOGY_QUEUE_NAMESPACE,
|
|
45
|
+
route: WORKFLOW_FLOW_ROUTE,
|
|
46
|
+
trigger: WORKFLOW_QUEUE_TRIGGER,
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type AnalyzeOptions, type OntologyConfig, type ResolvedConnection, type ResolvedEntity } from "./analyze.js";
|
|
2
|
+
import { type Diagnostic } from "./diagnostics.js";
|
|
3
|
+
import type { AnyEntity } from "./entity.js";
|
|
4
|
+
import { type OntologyManifest, type WorkflowManifest } from "./manifest.js";
|
|
5
|
+
import type { ModelMetrics } from "./metric.js";
|
|
6
|
+
import type { Role } from "./role.js";
|
|
7
|
+
import type { SignInOptions } from "./sign-in.js";
|
|
8
|
+
/** A checked ontology: the resolved definitions and the manifest built from them. */
|
|
9
|
+
export interface Ontology<Entities extends ReadonlyArray<AnyEntity> = ReadonlyArray<AnyEntity>, Metrics extends ModelMetrics = ModelMetrics> {
|
|
10
|
+
/** The definition as given to `defineOntology`. */
|
|
11
|
+
readonly config: OntologyConfig<Entities, Metrics>;
|
|
12
|
+
/** The built-in `User` first, then the declared entities in order. */
|
|
13
|
+
readonly entities: ReadonlyArray<ResolvedEntity>;
|
|
14
|
+
/** The workspace-owned `member` role first, declared roles, then the implicit reporter when enabled. */
|
|
15
|
+
readonly roles: ReadonlyArray<Role>;
|
|
16
|
+
/** Who may become a member by signing in, with the default policy when the definition sets none. */
|
|
17
|
+
readonly signIn: SignInOptions;
|
|
18
|
+
/** The connections the actions call, as `defineOntology({ connections })` lists them. */
|
|
19
|
+
readonly connections: ReadonlyArray<ResolvedConnection>;
|
|
20
|
+
/** The workflows, with wire names and their triggers' input in wire form, as the manifest lists them. */
|
|
21
|
+
readonly workflows: ReadonlyArray<WorkflowManifest>;
|
|
22
|
+
readonly manifest: OntologyManifest;
|
|
23
|
+
/** Warning-level diagnostics; any error makes `defineOntology` throw. */
|
|
24
|
+
readonly warnings: ReadonlyArray<Diagnostic>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Checks an ontology definition and returns every problem found, without throwing. Accepts the
|
|
28
|
+
* input of `defineOntology` or its result.
|
|
29
|
+
*/
|
|
30
|
+
export declare function check(input: OntologyConfig | Ontology, options?: AnalyzeOptions): ReadonlyArray<Diagnostic>;
|
|
31
|
+
/**
|
|
32
|
+
* `defineOntology` with analysis options. The SDK uses it to rebuild an ontology from a deployed
|
|
33
|
+
* manifest's roles, whose permissions name entities the rebuilt ontology does not have, and whose
|
|
34
|
+
* `user` table may predate properties this SDK added to the built-in `User`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildOntology<const Entities extends ReadonlyArray<AnyEntity>, const Metrics extends ModelMetrics = ModelMetrics>(config: OntologyConfig<Entities, Metrics>, options: AnalyzeOptions): Ontology<Entities, Metrics>;
|
|
37
|
+
/**
|
|
38
|
+
* Resolves and checks the ontology and builds its manifest. Throws {@link InvalidOntology}, carrying
|
|
39
|
+
* every diagnostic, when `check` reports an error.
|
|
40
|
+
*/
|
|
41
|
+
export declare function defineOntology<const Entities extends ReadonlyArray<AnyEntity>, const Metrics extends ModelMetrics = ModelMetrics>(config: OntologyConfig<Entities, Metrics>): Ontology<Entities, Metrics>;
|
package/dist/ontology.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { analyze, } from "./analyze.js";
|
|
2
|
+
import { formatDiagnostics, InvalidOntology } from "./diagnostics.js";
|
|
3
|
+
import { buildManifest } from "./manifest.js";
|
|
4
|
+
function isOntology(value) {
|
|
5
|
+
return "manifest" in value && "config" in value;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Checks an ontology definition and returns every problem found, without throwing. Accepts the
|
|
9
|
+
* input of `defineOntology` or its result.
|
|
10
|
+
*/
|
|
11
|
+
export function check(input, options = {}) {
|
|
12
|
+
return analyze(isOntology(input) ? input.config : input, options).diagnostics;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `defineOntology` with analysis options. The SDK uses it to rebuild an ontology from a deployed
|
|
16
|
+
* manifest's roles, whose permissions name entities the rebuilt ontology does not have, and whose
|
|
17
|
+
* `user` table may predate properties this SDK added to the built-in `User`.
|
|
18
|
+
*/
|
|
19
|
+
export function buildOntology(config, options) {
|
|
20
|
+
const analysis = analyze(config, options);
|
|
21
|
+
const errors = analysis.diagnostics.filter((diagnostic) => diagnostic.severity === "error");
|
|
22
|
+
if (errors.length > 0) {
|
|
23
|
+
const noun = errors.length === 1 ? "error" : "errors";
|
|
24
|
+
throw new InvalidOntology({
|
|
25
|
+
message: `The ontology has ${errors.length} ${noun}:\n${formatDiagnostics(analysis.diagnostics)}`,
|
|
26
|
+
diagnostics: analysis.diagnostics,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
config,
|
|
31
|
+
entities: analysis.entities,
|
|
32
|
+
roles: analysis.roles,
|
|
33
|
+
signIn: analysis.signIn,
|
|
34
|
+
connections: analysis.connections,
|
|
35
|
+
workflows: analysis.workflows,
|
|
36
|
+
manifest: buildManifest(analysis),
|
|
37
|
+
warnings: analysis.diagnostics,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves and checks the ontology and builds its manifest. Throws {@link InvalidOntology}, carrying
|
|
42
|
+
* every diagnostic, when `check` reports an error.
|
|
43
|
+
*/
|
|
44
|
+
export function defineOntology(config) {
|
|
45
|
+
return buildOntology(config, {});
|
|
46
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { Schema } from "effect";
|
|
2
|
+
import type { MeReference } from "./me.js";
|
|
3
|
+
/**
|
|
4
|
+
* Permissions are `<entity>:<verb>` strings. The verbs are `read`, the generated `create`, `update`,
|
|
5
|
+
* `delete`, `link` and `unlink`, and the snake_case name of an authored action. A role may use `*` for
|
|
6
|
+
* the entity (`*:read`), the verb (`lead:*`) or both (`*:*`); what an action or a read requires never
|
|
7
|
+
* holds a wildcard. A wildcard entity does not cover the entities in {@link EXPLICIT_GRANT_ENTITIES},
|
|
8
|
+
* and covers only some verbs of those in {@link WILDCARD_ENTITY_VERBS}.
|
|
9
|
+
*/
|
|
10
|
+
/** Any entity or any verb, in a role's permissions. */
|
|
11
|
+
export declare const WILDCARD = "*";
|
|
12
|
+
/** The verb of every read: lists, queries, records, history, traversals and `include`. */
|
|
13
|
+
export declare const READ_VERB = "read";
|
|
14
|
+
/**
|
|
15
|
+
* Entities only a permission that names them covers: `*:read` or `*:*` grant nothing on them. The
|
|
16
|
+
* built-in agent chat is in every ontology, and member's default `*:read` would otherwise show anyone
|
|
17
|
+
* who signs in the workspace's chats and who is in them; `agent_chat:read` or `agent_chat:*` does.
|
|
18
|
+
* App feedback is a member's own message to the builders: a member reads theirs through a scoped
|
|
19
|
+
* `app_feedback:read`, and only the builders' roles name it unscoped. The built-in sign-in
|
|
20
|
+
* identities hold every member's external accounts, such as their Telegram id and username: only a
|
|
21
|
+
* role that names `user_identity` reads them.
|
|
22
|
+
*/
|
|
23
|
+
export declare const EXPLICIT_GRANT_ENTITIES: ReadonlySet<string>;
|
|
24
|
+
/**
|
|
25
|
+
* The verbs of the built-in user's member management: inviting a member, granting and revoking
|
|
26
|
+
* roles, and deactivating and reactivating a member. Like every other verb on `user` but `read` and
|
|
27
|
+
* `update`, only `user:<verb>` or `user:*` grants them.
|
|
28
|
+
*/
|
|
29
|
+
export declare const USER_MEMBER_VERBS: readonly ["invite", "grant_roles", "revoke_roles", "deactivate", "reactivate"];
|
|
30
|
+
export type UserMemberVerb = (typeof USER_MEMBER_VERBS)[number];
|
|
31
|
+
/**
|
|
32
|
+
* Entities of which a wildcard entity (`*:*`, `*:<verb>`) covers only the listed verbs; any other
|
|
33
|
+
* verb needs a permission that names the entity. A role written for business data must not
|
|
34
|
+
* administer members by accident, and an API key holding `*:*` must not grant itself roles, so
|
|
35
|
+
* `*:*` reaches `user:read` and `user:update` but none of {@link USER_MEMBER_VERBS} or an authored
|
|
36
|
+
* action on `user`.
|
|
37
|
+
*/
|
|
38
|
+
export declare const WILDCARD_ENTITY_VERBS: ReadonlyMap<string, ReadonlySet<string>>;
|
|
39
|
+
/** Whether a wildcard entity covers this verb of this entity, both in snake_case. */
|
|
40
|
+
export declare function wildcardEntityCovers(entity: string, verb: string): boolean;
|
|
41
|
+
/** What the built-in `member` role holds when `defineOntology` does not say: reading everything. */
|
|
42
|
+
export declare const DEFAULT_MEMBER_PERMISSIONS: ReadonlyArray<string>;
|
|
43
|
+
export interface ParsedPermission {
|
|
44
|
+
/** An entity name, or `*`. */
|
|
45
|
+
readonly entity: string;
|
|
46
|
+
/** A verb, or `*`. */
|
|
47
|
+
readonly verb: string;
|
|
48
|
+
}
|
|
49
|
+
/** The entity and verb of a permission, or `undefined` when the value is not one. */
|
|
50
|
+
export declare function parsePermission(value: unknown): ParsedPermission | undefined;
|
|
51
|
+
/** The scope of workflow permissions: `workflow:<workflow>:<verb>`. */
|
|
52
|
+
export declare const WORKFLOW_PERMISSION_SCOPE = "workflow";
|
|
53
|
+
/** The verbs of a workflow: starting a run and reading its runs. */
|
|
54
|
+
export declare const WORKFLOW_VERBS: readonly ["start", "read"];
|
|
55
|
+
export type WorkflowVerb = (typeof WORKFLOW_VERBS)[number];
|
|
56
|
+
export interface ParsedWorkflowPermission {
|
|
57
|
+
/** A workflow name, or `*`. */
|
|
58
|
+
readonly workflow: string;
|
|
59
|
+
/** `start`, `read` or `*`. */
|
|
60
|
+
readonly verb: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The workflow and verb of `workflow:<workflow>:<verb>`, or `undefined` when the value is not one.
|
|
64
|
+
* Workflow permissions are a scope of their own: only a permission that starts with `workflow:`
|
|
65
|
+
* grants them, so `*:*` and `*:read` cover none.
|
|
66
|
+
*/
|
|
67
|
+
export declare function parseWorkflowPermission(value: unknown): ParsedWorkflowPermission | undefined;
|
|
68
|
+
/** `workflow:remind_stale_leads:start`. */
|
|
69
|
+
export declare function workflowPermission(workflow: string, verb: WorkflowVerb): string;
|
|
70
|
+
/** `lead:changeStatus`. */
|
|
71
|
+
export declare function permissionOf(entity: string, verb: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Whether a granted permission, which may hold wildcards, covers the required one. A wildcard entity
|
|
74
|
+
* covers every entity but those in {@link EXPLICIT_GRANT_ENTITIES}, and of those in
|
|
75
|
+
* {@link WILDCARD_ENTITY_VERBS} only the listed verbs.
|
|
76
|
+
*/
|
|
77
|
+
export declare function grants(granted: string, required: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* A permission as {@link grants} compares it: entity, workflow and verb names in snake_case,
|
|
80
|
+
* wildcards kept. Two permissions that grant the same thing normalise to the same string; a value
|
|
81
|
+
* that is not a permission is returned as it is.
|
|
82
|
+
*/
|
|
83
|
+
export declare function normalizePermission(value: string): string;
|
|
84
|
+
/** A value in a scope: JSON, as in any `where`, or `me` and paths from it. */
|
|
85
|
+
export type ScopeValue = Schema.Json | MeReference;
|
|
86
|
+
/** Conditions on one field in a scope: a {@link import("./query.js").FieldFilter} that may use `me`. */
|
|
87
|
+
export interface ScopeFilter {
|
|
88
|
+
/** `me`, or a JSON value. */
|
|
89
|
+
readonly eq?: ScopeValue;
|
|
90
|
+
readonly ne?: ScopeValue;
|
|
91
|
+
/** A path from `me`, such as `me.staffMember.division`, or JSON values. */
|
|
92
|
+
readonly in?: ReadonlyArray<Schema.Json> | MeReference;
|
|
93
|
+
readonly isNull?: boolean;
|
|
94
|
+
readonly contains?: string;
|
|
95
|
+
readonly startsWith?: string;
|
|
96
|
+
readonly gt?: number | string;
|
|
97
|
+
readonly gte?: number | string;
|
|
98
|
+
readonly lt?: number | string;
|
|
99
|
+
readonly lte?: number | string;
|
|
100
|
+
readonly between?: readonly [number | string, number | string];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The `where` of a scoped permission: a {@link import("./query.js").Where} of the permission's
|
|
104
|
+
* entity, in which `me` stands for the caller. A relationship compared with `me` or a path compares
|
|
105
|
+
* its key: `{ owner: me }`, `{ division: { in: me.staffMember.division } }`.
|
|
106
|
+
*/
|
|
107
|
+
export interface ScopeWhere {
|
|
108
|
+
readonly and?: ReadonlyArray<ScopeWhere>;
|
|
109
|
+
readonly or?: ReadonlyArray<ScopeWhere>;
|
|
110
|
+
readonly not?: ScopeWhere;
|
|
111
|
+
readonly [field: string]: ScopeFilter | {
|
|
112
|
+
readonly some?: ScopeWhere;
|
|
113
|
+
readonly none?: ScopeWhere;
|
|
114
|
+
readonly every?: ScopeWhere;
|
|
115
|
+
} | ScopeWhere | ReadonlyArray<ScopeWhere> | ScopeValue | undefined;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A role permission limited to the records its `where` matches. A scoped read filters the rows the
|
|
119
|
+
* caller sees; a scoped write checks the record before and after the change.
|
|
120
|
+
*/
|
|
121
|
+
export interface ScopedPermission {
|
|
122
|
+
/** `<entity>:<verb>`, without wildcards. */
|
|
123
|
+
readonly permission: string;
|
|
124
|
+
/** The records the permission covers; it may use `me`. */
|
|
125
|
+
readonly where: ScopeWhere;
|
|
126
|
+
/**
|
|
127
|
+
* The role reads the entity unscoped on purpose, though it scopes a write of it: silences the
|
|
128
|
+
* `scope-reads-all` warning of `check`.
|
|
129
|
+
*/
|
|
130
|
+
readonly readsAll?: true;
|
|
131
|
+
}
|
|
132
|
+
/** Anything that holds permissions: a principal, or the reader of a catalog. */
|
|
133
|
+
export interface PermissionHolder {
|
|
134
|
+
readonly execution?: import("./runtime/workload.js").WorkloadExecution;
|
|
135
|
+
readonly permissions: ReadonlyArray<string>;
|
|
136
|
+
/**
|
|
137
|
+
* The scoped entries of the held roles. A permission in `permissions` that one of them names
|
|
138
|
+
* exactly is held only within the scopes; absent means none is scoped.
|
|
139
|
+
*/
|
|
140
|
+
readonly scopes?: ReadonlyArray<ScopedPermission>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Whether the principal may do what `required` names: one of its permissions equals it, or covers it
|
|
144
|
+
* through a wildcard. Workload wildcards exclude user administration, feedback and writes of sign-in
|
|
145
|
+
* identities.
|
|
146
|
+
*/
|
|
147
|
+
export declare function isAllowed(required: string, principal: PermissionHolder): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Which records of `required` the principal's grants cover, once {@link isAllowed} said it holds
|
|
150
|
+
* it: `undefined` when some grant covers it unscoped, wildcards included; otherwise the `where` of
|
|
151
|
+
* the one scoped grant that names it, or the `or` of several. Without any grant the result is
|
|
152
|
+
* `{ or: [] }`, which matches no record.
|
|
153
|
+
*/
|
|
154
|
+
export declare function effectiveScope(required: string, principal: PermissionHolder): ScopeWhere | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* The records of `entity` a holder reads: `undefined` when it holds no scoped permission or reads
|
|
157
|
+
* the entity unscoped, else the {@link effectiveScope} of `<entity>:read`. A holder without the read
|
|
158
|
+
* permission gets `undefined` too: whether it may read at all is the permission check's decision.
|
|
159
|
+
*/
|
|
160
|
+
export declare function readScope(entity: string, holder: PermissionHolder): ScopeWhere | undefined;
|
|
161
|
+
/** Expand workload authority for permission-only catalog and documentation readers. */
|
|
162
|
+
export declare function effectivePermissions(principal: PermissionHolder): ReadonlyArray<string>;
|
|
163
|
+
/** The first of the required permissions the principal lacks, or `undefined` when it holds all. */
|
|
164
|
+
export declare function missingPermission(required: ReadonlyArray<string>, principal: PermissionHolder): string | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* What a generated action requires: `<entity>:<action>`, except `upsert_by_<property>`, which may
|
|
167
|
+
* create or update and so requires both `<entity>:create` and `<entity>:update`.
|
|
168
|
+
*/
|
|
169
|
+
export declare function generatedActionPermissions(entity: string, action: string): ReadonlyArray<string>;
|
|
170
|
+
/** A role as permissions are computed from it: the declared role or its manifest entry. */
|
|
171
|
+
export interface RolePermissions {
|
|
172
|
+
readonly name: string;
|
|
173
|
+
/** Every permission the role holds, scoped or not. */
|
|
174
|
+
readonly permissions?: ReadonlyArray<string> | undefined;
|
|
175
|
+
/** The scoped ones, with their `where`. A permission none of them names is held unscoped. */
|
|
176
|
+
readonly scopes?: ReadonlyArray<ScopedPermission> | undefined;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The union of the permissions of the roles a principal holds, in the order the ontology declares
|
|
180
|
+
* them. A held role the ontology does not declare grants nothing.
|
|
181
|
+
*/
|
|
182
|
+
export declare function permissionsOf(roles: ReadonlyArray<RolePermissions>, held: ReadonlyArray<string>): ReadonlyArray<string>;
|
|
183
|
+
/**
|
|
184
|
+
* The scoped entries of the roles a principal holds, in the order the ontology declares them,
|
|
185
|
+
* without the dead ones: those a held role grants unscoped, by the same permission or through a
|
|
186
|
+
* wildcard, since an unscoped grant covers every record. With {@link permissionsOf}, what a
|
|
187
|
+
* principal's `scopes` holds; {@link effectiveScope} stays the authority either way.
|
|
188
|
+
*/
|
|
189
|
+
export declare function scopesOf(roles: ReadonlyArray<RolePermissions>, held: ReadonlyArray<string>): ReadonlyArray<ScopedPermission>;
|
|
190
|
+
/**
|
|
191
|
+
* {@link scopesOf} as a principal carries it: absent when no held role scopes a permission, so that
|
|
192
|
+
* a principal of an ontology without scoped permissions is what it was before them.
|
|
193
|
+
*/
|
|
194
|
+
export declare function principalScopes(roles: ReadonlyArray<RolePermissions>, held: ReadonlyArray<string>): {
|
|
195
|
+
readonly scopes?: ReadonlyArray<ScopedPermission>;
|
|
196
|
+
};
|
|
197
|
+
/** The roles whose permissions cover `required`, by name. */
|
|
198
|
+
export declare function rolesGranting(roles: ReadonlyArray<RolePermissions>, required: string): ReadonlyArray<string>;
|