@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
package/dist/me.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* `me`, the caller, in the `where` of a scoped role permission. `me` alone is the id of the caller's
|
|
4
|
+
* `user` record and is compared with `eq` or `ne` (a bare `owner: me` means `eq`).
|
|
5
|
+
* `me.<relationship>.<relationship>…` is the set of ids a path of relationship names reaches from the
|
|
6
|
+
* built-in `User`, inverse names first, and is compared with `in`:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* { owner: me }
|
|
10
|
+
* { division: { in: me.staffMember.division } }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Paths are untyped, since the inverse names live on the other entities; `check` validates them. On
|
|
14
|
+
* the wire `me` is `{ "$me": [] }` and a path `{ "$me": ["staff_member", "division"] }`, with
|
|
15
|
+
* snake_case relationship names.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MeTypeId: unique symbol;
|
|
18
|
+
/** `me` or a path from it, as authored. Every string property is one more hop. */
|
|
19
|
+
export interface MeReference {
|
|
20
|
+
/** The hops from the caller's `user` record, as authored: none for `me` itself. */
|
|
21
|
+
readonly [MeTypeId]: ReadonlyArray<string>;
|
|
22
|
+
readonly [relationship: string]: MeReference;
|
|
23
|
+
}
|
|
24
|
+
/** The key of the wire form, `{ "$me": [...] }`. */
|
|
25
|
+
export declare const ME_KEY = "$me";
|
|
26
|
+
/** The most hops a path takes from the caller's `user` record. */
|
|
27
|
+
export declare const MAX_ME_HOPS = 3;
|
|
28
|
+
/** `me` or a path on the wire: `{ "$me": [] }`, `{ "$me": ["staff_member", "division"] }`. */
|
|
29
|
+
export declare const MeMarker: Schema.Struct<{
|
|
30
|
+
readonly $me: Schema.$Array<Schema.String>;
|
|
31
|
+
}>;
|
|
32
|
+
export type MeMarker = typeof MeMarker.Type;
|
|
33
|
+
/** The caller. `me.staffMember.division` is the set of divisions of the caller's staff member rows. */
|
|
34
|
+
export declare const me: MeReference;
|
|
35
|
+
/** Whether a value is `me` or a path from it, as authored. */
|
|
36
|
+
export declare function isMe(value: unknown): value is MeReference;
|
|
37
|
+
/** Whether a value is the wire form of `me` or of a path: an object whose only key is `$me`. */
|
|
38
|
+
export declare function isMeMarker(value: unknown): value is MeMarker;
|
|
39
|
+
/**
|
|
40
|
+
* The hops of `me` or of a path, as the value holds them: authored names for an authored
|
|
41
|
+
* reference, wire names for a wire marker. An empty list is `me` itself; `undefined` means the
|
|
42
|
+
* value is neither.
|
|
43
|
+
*/
|
|
44
|
+
export declare function mePathOf(value: unknown): ReadonlyArray<string> | undefined;
|
|
45
|
+
/** The wire form of `me` or of a path, from its hops or an authored reference. */
|
|
46
|
+
export declare function meToWire(value: MeReference | ReadonlyArray<string>): MeMarker;
|
package/dist/me.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { nameToWire } from "./authoring-names.js";
|
|
3
|
+
/**
|
|
4
|
+
* `me`, the caller, in the `where` of a scoped role permission. `me` alone is the id of the caller's
|
|
5
|
+
* `user` record and is compared with `eq` or `ne` (a bare `owner: me` means `eq`).
|
|
6
|
+
* `me.<relationship>.<relationship>…` is the set of ids a path of relationship names reaches from the
|
|
7
|
+
* built-in `User`, inverse names first, and is compared with `in`:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* { owner: me }
|
|
11
|
+
* { division: { in: me.staffMember.division } }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Paths are untyped, since the inverse names live on the other entities; `check` validates them. On
|
|
15
|
+
* the wire `me` is `{ "$me": [] }` and a path `{ "$me": ["staff_member", "division"] }`, with
|
|
16
|
+
* snake_case relationship names.
|
|
17
|
+
*/
|
|
18
|
+
export const MeTypeId = Symbol.for("@segmentstream/ontology/Me");
|
|
19
|
+
/** The key of the wire form, `{ "$me": [...] }`. */
|
|
20
|
+
export const ME_KEY = "$me";
|
|
21
|
+
/** The most hops a path takes from the caller's `user` record. */
|
|
22
|
+
export const MAX_ME_HOPS = 3;
|
|
23
|
+
/** `me` or a path on the wire: `{ "$me": [] }`, `{ "$me": ["staff_member", "division"] }`. */
|
|
24
|
+
export const MeMarker = Schema.Struct({ [ME_KEY]: Schema.Array(Schema.String) }).annotate({
|
|
25
|
+
identifier: "MeMarker",
|
|
26
|
+
description: "The caller: an empty list is the id of the caller's user record; relationship names walk from it " +
|
|
27
|
+
"to the set of ids they reach.",
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Keys a path never takes as a hop, so that runtimes, serializers and test matchers that probe
|
|
31
|
+
* objects for them find nothing: `then` would make `me` look like a promise, `toJSON` writes the
|
|
32
|
+
* wire form.
|
|
33
|
+
*/
|
|
34
|
+
const NOT_HOPS = new Set([
|
|
35
|
+
"then",
|
|
36
|
+
"toJSON",
|
|
37
|
+
"toString",
|
|
38
|
+
"toLocaleString",
|
|
39
|
+
"valueOf",
|
|
40
|
+
"constructor",
|
|
41
|
+
"hasOwnProperty",
|
|
42
|
+
"isPrototypeOf",
|
|
43
|
+
"propertyIsEnumerable",
|
|
44
|
+
"asymmetricMatch",
|
|
45
|
+
"$$typeof",
|
|
46
|
+
"nodeType",
|
|
47
|
+
"tagName",
|
|
48
|
+
"__proto__",
|
|
49
|
+
]);
|
|
50
|
+
/** `JSON.stringify(me.staffMember)` writes the wire form. */
|
|
51
|
+
function toJSON() {
|
|
52
|
+
return meToWire(this);
|
|
53
|
+
}
|
|
54
|
+
function reference(hops) {
|
|
55
|
+
const target = { [MeTypeId]: Object.freeze([...hops]) };
|
|
56
|
+
Object.defineProperty(target, "toJSON", { value: toJSON, enumerable: false });
|
|
57
|
+
Object.freeze(target);
|
|
58
|
+
return new Proxy(target, {
|
|
59
|
+
get(object, key, receiver) {
|
|
60
|
+
if (typeof key === "symbol" || NOT_HOPS.has(key) || key in object) {
|
|
61
|
+
return Reflect.get(object, key, receiver);
|
|
62
|
+
}
|
|
63
|
+
return reference([...hops, key]);
|
|
64
|
+
},
|
|
65
|
+
has(object, key) {
|
|
66
|
+
return key in object;
|
|
67
|
+
},
|
|
68
|
+
set() {
|
|
69
|
+
return false;
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** The caller. `me.staffMember.division` is the set of divisions of the caller's staff member rows. */
|
|
74
|
+
export const me = reference([]);
|
|
75
|
+
/** Whether a value is `me` or a path from it, as authored. */
|
|
76
|
+
export function isMe(value) {
|
|
77
|
+
return (typeof value === "object" &&
|
|
78
|
+
value !== null &&
|
|
79
|
+
MeTypeId in value &&
|
|
80
|
+
Array.isArray(value[MeTypeId]));
|
|
81
|
+
}
|
|
82
|
+
/** Whether a value is the wire form of `me` or of a path: an object whose only key is `$me`. */
|
|
83
|
+
export function isMeMarker(value) {
|
|
84
|
+
if (typeof value !== "object" || value === null || Array.isArray(value) || isMe(value)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const keys = Object.keys(value);
|
|
88
|
+
const hops = value[ME_KEY];
|
|
89
|
+
return (keys.length === 1 &&
|
|
90
|
+
keys[0] === ME_KEY &&
|
|
91
|
+
Array.isArray(hops) &&
|
|
92
|
+
hops.every((hop) => typeof hop === "string"));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The hops of `me` or of a path, as the value holds them: authored names for an authored
|
|
96
|
+
* reference, wire names for a wire marker. An empty list is `me` itself; `undefined` means the
|
|
97
|
+
* value is neither.
|
|
98
|
+
*/
|
|
99
|
+
export function mePathOf(value) {
|
|
100
|
+
if (isMe(value)) {
|
|
101
|
+
return value[MeTypeId];
|
|
102
|
+
}
|
|
103
|
+
return isMeMarker(value) ? value[ME_KEY] : undefined;
|
|
104
|
+
}
|
|
105
|
+
/** The wire form of `me` or of a path, from its hops or an authored reference. */
|
|
106
|
+
export function meToWire(value) {
|
|
107
|
+
const hops = isMe(value) ? value[MeTypeId] : value;
|
|
108
|
+
return { [ME_KEY]: hops.map(nameToWire) };
|
|
109
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The filter operators of metric queries and the values each takes, shared by the service's request
|
|
3
|
+
* schemas and `check`'s metric conditions (docs/ontology-aggregates-release-2-spec.md, "Filters").
|
|
4
|
+
* The rules and messages are SegmentStream's own (backend-next's `semantics/core/predicates.ts`), so
|
|
5
|
+
* the SDK, the service and the platform refuse alike.
|
|
6
|
+
*/
|
|
7
|
+
/** A filter value: a literal. */
|
|
8
|
+
export type MetricQueryValue = string | number | boolean;
|
|
9
|
+
/** The operators of a model-level metric query's filters. */
|
|
10
|
+
export declare const METRIC_QUERY_FILTER_OPERATORS: readonly ["equals", "in", "isNull", "isNotNull", "between", "notEquals", "notIn", "gt", "gte", "lt", "lte", "contains", "startsWith", "endsWith", "inPeriod"];
|
|
11
|
+
/**
|
|
12
|
+
* The operators of the per-entity shorthand, which bounds dates with `dateRange` instead of
|
|
13
|
+
* `between` and `inPeriod`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ENTITY_METRIC_QUERY_FILTER_OPERATORS: readonly ["equals", "in", "isNull", "isNotNull", "notEquals", "notIn", "gt", "gte", "lt", "lte", "contains", "startsWith", "endsWith"];
|
|
16
|
+
/**
|
|
17
|
+
* The operators of a metric condition: a model-level filter's, except `inPeriod`, whose dates would
|
|
18
|
+
* move with the day a request runs.
|
|
19
|
+
*/
|
|
20
|
+
export declare const METRIC_CONDITION_OPERATORS: readonly ["equals", "in", "notEquals", "notIn", "isNull", "isNotNull", "between", "gt", "gte", "lt", "lte", "contains", "startsWith", "endsWith"];
|
|
21
|
+
export type MetricConditionOperator = (typeof METRIC_CONDITION_OPERATORS)[number];
|
|
22
|
+
/** The periods `inPeriod` takes without a count. Weeks start on Monday. */
|
|
23
|
+
export declare const METRIC_QUERY_PERIODS: readonly ["today", "yesterday", "this week", "this month", "this quarter", "this year", "this week to date", "this month to date", "this quarter to date", "this year to date", "last week", "last month", "last quarter", "last year"];
|
|
24
|
+
/**
|
|
25
|
+
* The units of `last N <unit>`, N at least 1: `last N days` ends yesterday; the others are the N
|
|
26
|
+
* whole units before the current one.
|
|
27
|
+
*/
|
|
28
|
+
export declare const METRIC_QUERY_PERIOD_UNITS: readonly ["days", "weeks", "months", "quarters", "years"];
|
|
29
|
+
/** The most values `in` and `notIn` take. */
|
|
30
|
+
export declare const MAXIMUM_FILTER_VALUES = 100;
|
|
31
|
+
/** An operator and the values given to it, before they are known to suit each other. */
|
|
32
|
+
export interface FilterValues {
|
|
33
|
+
readonly operator: string;
|
|
34
|
+
readonly value?: unknown;
|
|
35
|
+
readonly values?: ReadonlyArray<unknown>;
|
|
36
|
+
}
|
|
37
|
+
/** Why an operator does not take the values given, or `undefined` when it does. */
|
|
38
|
+
export declare function filterValuesIssue(filter: FilterValues): string | undefined;
|
|
39
|
+
/** How SegmentStream compares a dimension's values. */
|
|
40
|
+
export type DimensionType = "string" | "decimal" | "boolean" | "date" | "timestamp";
|
|
41
|
+
/** The dimension type of a property type, or `undefined` for JSON and files, which are none. */
|
|
42
|
+
export declare function dimensionTypeOf(propertyType: string): DimensionType | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Why a filter's values do not suit its dimension's type, or `undefined` when they do: the operator
|
|
45
|
+
* must apply to the type and every value must match it. Their count is {@link filterValuesIssue}'s
|
|
46
|
+
* to check first. `inPeriod` values are periods, which SegmentStream resolves.
|
|
47
|
+
*/
|
|
48
|
+
export declare function filterTypeIssue(filter: FilterValues, type: DimensionType): string | undefined;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The filter operators of metric queries and the values each takes, shared by the service's request
|
|
3
|
+
* schemas and `check`'s metric conditions (docs/ontology-aggregates-release-2-spec.md, "Filters").
|
|
4
|
+
* The rules and messages are SegmentStream's own (backend-next's `semantics/core/predicates.ts`), so
|
|
5
|
+
* the SDK, the service and the platform refuse alike.
|
|
6
|
+
*/
|
|
7
|
+
/** The operators of a model-level metric query's filters. */
|
|
8
|
+
export const METRIC_QUERY_FILTER_OPERATORS = [
|
|
9
|
+
"equals",
|
|
10
|
+
"in",
|
|
11
|
+
"isNull",
|
|
12
|
+
"isNotNull",
|
|
13
|
+
"between",
|
|
14
|
+
"notEquals",
|
|
15
|
+
"notIn",
|
|
16
|
+
"gt",
|
|
17
|
+
"gte",
|
|
18
|
+
"lt",
|
|
19
|
+
"lte",
|
|
20
|
+
"contains",
|
|
21
|
+
"startsWith",
|
|
22
|
+
"endsWith",
|
|
23
|
+
"inPeriod",
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* The operators of the per-entity shorthand, which bounds dates with `dateRange` instead of
|
|
27
|
+
* `between` and `inPeriod`.
|
|
28
|
+
*/
|
|
29
|
+
export const ENTITY_METRIC_QUERY_FILTER_OPERATORS = [
|
|
30
|
+
"equals",
|
|
31
|
+
"in",
|
|
32
|
+
"isNull",
|
|
33
|
+
"isNotNull",
|
|
34
|
+
"notEquals",
|
|
35
|
+
"notIn",
|
|
36
|
+
"gt",
|
|
37
|
+
"gte",
|
|
38
|
+
"lt",
|
|
39
|
+
"lte",
|
|
40
|
+
"contains",
|
|
41
|
+
"startsWith",
|
|
42
|
+
"endsWith",
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* The operators of a metric condition: a model-level filter's, except `inPeriod`, whose dates would
|
|
46
|
+
* move with the day a request runs.
|
|
47
|
+
*/
|
|
48
|
+
export const METRIC_CONDITION_OPERATORS = [
|
|
49
|
+
"equals",
|
|
50
|
+
"in",
|
|
51
|
+
"notEquals",
|
|
52
|
+
"notIn",
|
|
53
|
+
"isNull",
|
|
54
|
+
"isNotNull",
|
|
55
|
+
"between",
|
|
56
|
+
"gt",
|
|
57
|
+
"gte",
|
|
58
|
+
"lt",
|
|
59
|
+
"lte",
|
|
60
|
+
"contains",
|
|
61
|
+
"startsWith",
|
|
62
|
+
"endsWith",
|
|
63
|
+
];
|
|
64
|
+
/** The periods `inPeriod` takes without a count. Weeks start on Monday. */
|
|
65
|
+
export const METRIC_QUERY_PERIODS = [
|
|
66
|
+
"today",
|
|
67
|
+
"yesterday",
|
|
68
|
+
"this week",
|
|
69
|
+
"this month",
|
|
70
|
+
"this quarter",
|
|
71
|
+
"this year",
|
|
72
|
+
"this week to date",
|
|
73
|
+
"this month to date",
|
|
74
|
+
"this quarter to date",
|
|
75
|
+
"this year to date",
|
|
76
|
+
"last week",
|
|
77
|
+
"last month",
|
|
78
|
+
"last quarter",
|
|
79
|
+
"last year",
|
|
80
|
+
];
|
|
81
|
+
/**
|
|
82
|
+
* The units of `last N <unit>`, N at least 1: `last N days` ends yesterday; the others are the N
|
|
83
|
+
* whole units before the current one.
|
|
84
|
+
*/
|
|
85
|
+
export const METRIC_QUERY_PERIOD_UNITS = ["days", "weeks", "months", "quarters", "years"];
|
|
86
|
+
/** The most values `in` and `notIn` take. */
|
|
87
|
+
export const MAXIMUM_FILTER_VALUES = 100;
|
|
88
|
+
const COMPARISONS = new Set(["gt", "gte", "lt", "lte"]);
|
|
89
|
+
const TEXT_OPERATORS = new Set(["contains", "startsWith", "endsWith"]);
|
|
90
|
+
function oneValue({ value, values }) {
|
|
91
|
+
return value !== undefined && values === undefined;
|
|
92
|
+
}
|
|
93
|
+
function someValues({ value, values }) {
|
|
94
|
+
return (value === undefined &&
|
|
95
|
+
values !== undefined &&
|
|
96
|
+
values.length > 0 &&
|
|
97
|
+
values.length <= MAXIMUM_FILTER_VALUES);
|
|
98
|
+
}
|
|
99
|
+
/** Why an operator does not take the values given, or `undefined` when it does. */
|
|
100
|
+
export function filterValuesIssue(filter) {
|
|
101
|
+
const { operator, value, values } = filter;
|
|
102
|
+
if (COMPARISONS.has(operator)) {
|
|
103
|
+
return oneValue(filter) ? undefined : "Comparison filters require one value.";
|
|
104
|
+
}
|
|
105
|
+
if (TEXT_OPERATORS.has(operator)) {
|
|
106
|
+
return oneValue(filter) && typeof value === "string" && value !== ""
|
|
107
|
+
? undefined
|
|
108
|
+
: "Text filters require one non-empty string.";
|
|
109
|
+
}
|
|
110
|
+
switch (operator) {
|
|
111
|
+
case "equals":
|
|
112
|
+
case "notEquals":
|
|
113
|
+
return oneValue(filter) ? undefined : "Equality filters require one value.";
|
|
114
|
+
case "in":
|
|
115
|
+
return someValues(filter)
|
|
116
|
+
? undefined
|
|
117
|
+
: "Membership filters require between 1 and 100 values.";
|
|
118
|
+
case "notIn":
|
|
119
|
+
return someValues(filter) ? undefined : "notIn requires between 1 and 100 values.";
|
|
120
|
+
case "between":
|
|
121
|
+
return value === undefined && values?.length === 2
|
|
122
|
+
? undefined
|
|
123
|
+
: "between needs two values in order.";
|
|
124
|
+
case "inPeriod":
|
|
125
|
+
// Whether the value is a period is SegmentStream's to say: it resolves it.
|
|
126
|
+
return oneValue(filter) ? undefined : "inPeriod filters require one period.";
|
|
127
|
+
case "isNull":
|
|
128
|
+
case "isNotNull":
|
|
129
|
+
return value === undefined && values === undefined
|
|
130
|
+
? undefined
|
|
131
|
+
: "Null filters do not accept values.";
|
|
132
|
+
default:
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const DIMENSION_TYPES = {
|
|
137
|
+
text: "string",
|
|
138
|
+
email: "string",
|
|
139
|
+
url: "string",
|
|
140
|
+
select: "string",
|
|
141
|
+
integer: "decimal",
|
|
142
|
+
number: "decimal",
|
|
143
|
+
boolean: "boolean",
|
|
144
|
+
date: "date",
|
|
145
|
+
timestamp: "timestamp",
|
|
146
|
+
};
|
|
147
|
+
/** The dimension type of a property type, or `undefined` for JSON and files, which are none. */
|
|
148
|
+
export function dimensionTypeOf(propertyType) {
|
|
149
|
+
return Object.hasOwn(DIMENSION_TYPES, propertyType) ? DIMENSION_TYPES[propertyType] : undefined;
|
|
150
|
+
}
|
|
151
|
+
function isDate(value) {
|
|
152
|
+
return (typeof value === "string" &&
|
|
153
|
+
/^\d{4}-\d{2}-\d{2}$/.test(value) &&
|
|
154
|
+
!Number.isNaN(Date.parse(value)) &&
|
|
155
|
+
new Date(value).toISOString().slice(0, 10) === value);
|
|
156
|
+
}
|
|
157
|
+
/** Whether a value is a literal of the type, as SegmentStream reads filter values. */
|
|
158
|
+
function matches(value, type) {
|
|
159
|
+
if (type === "boolean") {
|
|
160
|
+
return typeof value === "boolean";
|
|
161
|
+
}
|
|
162
|
+
if (type === "decimal") {
|
|
163
|
+
return ((typeof value === "number" || typeof value === "string") &&
|
|
164
|
+
String(value).length <= 100 &&
|
|
165
|
+
/^[-+]?(?:\d+\.?\d*|\.\d+)$/.test(String(value)) &&
|
|
166
|
+
Number.isFinite(Number(value)));
|
|
167
|
+
}
|
|
168
|
+
if (typeof value !== "string" || value.length > 2048) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
if (type === "timestamp") {
|
|
172
|
+
return (/^\d{4}-\d{2}-\d{2}T/.test(value) &&
|
|
173
|
+
/(?:Z|[+-]\d{2}:\d{2})$/.test(value) &&
|
|
174
|
+
Number.isFinite(Date.parse(value)));
|
|
175
|
+
}
|
|
176
|
+
return type !== "date" || isDate(value);
|
|
177
|
+
}
|
|
178
|
+
/** Bounds of a timestamp may be dates, which cover whole days; then they are compared as dates. */
|
|
179
|
+
function boundType(bounds, type) {
|
|
180
|
+
return type === "timestamp" && bounds.every(isDate) ? "date" : type;
|
|
181
|
+
}
|
|
182
|
+
/** Compares two decimal literals exactly, as their digits say, however many there are. */
|
|
183
|
+
function compareDecimals(left, right) {
|
|
184
|
+
const parse = (value) => {
|
|
185
|
+
const negative = value.startsWith("-");
|
|
186
|
+
const [whole = "", fraction = ""] = value.replace(/^[-+]/, "").split(".");
|
|
187
|
+
const digits = whole.replace(/^0+/, "");
|
|
188
|
+
const decimals = fraction.replace(/0+$/, "");
|
|
189
|
+
const zero = digits === "" && decimals === "";
|
|
190
|
+
return { negative: negative && !zero, digits, decimals };
|
|
191
|
+
};
|
|
192
|
+
const a = parse(left);
|
|
193
|
+
const b = parse(right);
|
|
194
|
+
if (a.negative !== b.negative) {
|
|
195
|
+
return a.negative ? -1 : 1;
|
|
196
|
+
}
|
|
197
|
+
const width = Math.max(a.decimals.length, b.decimals.length);
|
|
198
|
+
const magnitude = (value) => value.digits.padStart(Math.max(a.digits.length, b.digits.length), "0") +
|
|
199
|
+
value.decimals.padEnd(width, "0");
|
|
200
|
+
// Equal-length digit strings order as their values do.
|
|
201
|
+
const [first, second] = [magnitude(a), magnitude(b)];
|
|
202
|
+
if (first === second) {
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
const sign = first < second ? -1 : 1;
|
|
206
|
+
return a.negative ? -sign : sign;
|
|
207
|
+
}
|
|
208
|
+
function inOrder(from, to, type) {
|
|
209
|
+
if (type === "decimal") {
|
|
210
|
+
return compareDecimals(String(from), String(to)) <= 0;
|
|
211
|
+
}
|
|
212
|
+
if (type === "timestamp") {
|
|
213
|
+
return Date.parse(String(from)) <= Date.parse(String(to));
|
|
214
|
+
}
|
|
215
|
+
return String(from) <= String(to);
|
|
216
|
+
}
|
|
217
|
+
const MISMATCH = "Filter value does not match its dimension type.";
|
|
218
|
+
const ORDERED_TYPES = new Set(["date", "timestamp", "decimal"]);
|
|
219
|
+
/**
|
|
220
|
+
* Why a filter's values do not suit its dimension's type, or `undefined` when they do: the operator
|
|
221
|
+
* must apply to the type and every value must match it. Their count is {@link filterValuesIssue}'s
|
|
222
|
+
* to check first. `inPeriod` values are periods, which SegmentStream resolves.
|
|
223
|
+
*/
|
|
224
|
+
export function filterTypeIssue(filter, type) {
|
|
225
|
+
const { operator, value, values = [] } = filter;
|
|
226
|
+
const given = value === undefined ? values : [value];
|
|
227
|
+
if (operator === "between") {
|
|
228
|
+
const [from, to] = given;
|
|
229
|
+
const bounds = boundType([from, to], type);
|
|
230
|
+
if (!ORDERED_TYPES.has(type)) {
|
|
231
|
+
return "between filters date, timestamp and number dimensions.";
|
|
232
|
+
}
|
|
233
|
+
if (!matches(from, bounds) || !matches(to, bounds)) {
|
|
234
|
+
return MISMATCH;
|
|
235
|
+
}
|
|
236
|
+
return inOrder(from, to, bounds) ? undefined : "between needs two values in order.";
|
|
237
|
+
}
|
|
238
|
+
if (operator === "inPeriod") {
|
|
239
|
+
return type === "date" || type === "timestamp"
|
|
240
|
+
? undefined
|
|
241
|
+
: "inPeriod filters date and timestamp dimensions.";
|
|
242
|
+
}
|
|
243
|
+
if (COMPARISONS.has(operator) && !ORDERED_TYPES.has(type)) {
|
|
244
|
+
return `${operator} filters date, timestamp and number dimensions.`;
|
|
245
|
+
}
|
|
246
|
+
if (TEXT_OPERATORS.has(operator) && type !== "string") {
|
|
247
|
+
return `${operator} filters text dimensions.`;
|
|
248
|
+
}
|
|
249
|
+
// A comparison bounds a timestamp by a date or by an exact instant, as `between` does.
|
|
250
|
+
const valueType = COMPARISONS.has(operator) ? boundType(given, type) : type;
|
|
251
|
+
return given.every((candidate) => matches(candidate, valueType)) ? undefined : MISMATCH;
|
|
252
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { ModelMetricManifest, OntologyManifest } from "./manifest.js";
|
|
2
|
+
/**
|
|
3
|
+
* The names of a model-level metric query, as `/api/ontology/query_metrics` and the platform's
|
|
4
|
+
* `POST …/metrics/query` receive them: wire snake_case, `entity.member`.
|
|
5
|
+
*/
|
|
6
|
+
export interface MetricQueryNames {
|
|
7
|
+
/** `entity.metric`, or the bare name of a metric of the model. */
|
|
8
|
+
readonly metrics: readonly string[];
|
|
9
|
+
/** An identity, `entity.property`, or a route, `rootEntity.relationship[.relationship].property`. */
|
|
10
|
+
readonly dimensions?: readonly string[];
|
|
11
|
+
/** The dimension name of every filter, in the same forms as dimensions. */
|
|
12
|
+
readonly filters?: readonly string[];
|
|
13
|
+
/** A requested dimension, by its requested name or its identity. */
|
|
14
|
+
readonly granularityOf?: string;
|
|
15
|
+
}
|
|
16
|
+
/** How one metric entity reads every requested name. Paths are relative to the entity. */
|
|
17
|
+
export interface EntityRoutes {
|
|
18
|
+
readonly entity: string;
|
|
19
|
+
/**
|
|
20
|
+
* The metrics the entity computes, without the entity prefix, each once: its requested metrics
|
|
21
|
+
* in request order, then the hidden inputs of the requested model metrics that read it, in their
|
|
22
|
+
* declaration order.
|
|
23
|
+
*/
|
|
24
|
+
readonly metrics: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* Every requested dimension, in request order: `brand`, `product.brand`, `product.region.name`.
|
|
27
|
+
* A dimension that a requested model metric aligns reads the entity's own member of the group;
|
|
28
|
+
* `null` when the member is `null`, so the entity is broadcast across the dimension's values.
|
|
29
|
+
*/
|
|
30
|
+
readonly dimensions: readonly {
|
|
31
|
+
readonly identity: string;
|
|
32
|
+
readonly path: string | null;
|
|
33
|
+
}[];
|
|
34
|
+
/** The filters that apply to the entity, by their requested dimension name. */
|
|
35
|
+
readonly filters: readonly {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly path: string;
|
|
38
|
+
}[];
|
|
39
|
+
/**
|
|
40
|
+
* The requested filter names that do not apply to the entity: it cannot reach them, or an
|
|
41
|
+
* alignment says it has no counterpart.
|
|
42
|
+
*/
|
|
43
|
+
readonly unappliedFilters: readonly string[];
|
|
44
|
+
/** The path of the bucketed dimension, when the request names one and the entity groups by it. */
|
|
45
|
+
readonly granularityOf?: string;
|
|
46
|
+
}
|
|
47
|
+
/** A requested metric of the model: the entity metrics it reads, and their entities. */
|
|
48
|
+
export interface ModelMetricRoute {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
/** `entity.metric`, in declaration order. */
|
|
51
|
+
readonly inputs: readonly string[];
|
|
52
|
+
/** The entities of the inputs, each once, in the order of the inputs. */
|
|
53
|
+
readonly entities: readonly string[];
|
|
54
|
+
}
|
|
55
|
+
export type MetricRoutes = {
|
|
56
|
+
readonly ok: true;
|
|
57
|
+
/**
|
|
58
|
+
* The metric entities, in the order their first metric was requested: an entity metric's
|
|
59
|
+
* entity, or the entities of a model metric's inputs.
|
|
60
|
+
*/
|
|
61
|
+
readonly entities: readonly EntityRoutes[];
|
|
62
|
+
/**
|
|
63
|
+
* Every entity the request reads, the entities of model metrics' inputs included, sorted:
|
|
64
|
+
* each needs `<entity>:read`.
|
|
65
|
+
*/
|
|
66
|
+
readonly touched: readonly string[];
|
|
67
|
+
/** The requested model metrics, in request order. */
|
|
68
|
+
readonly model: readonly ModelMetricRoute[];
|
|
69
|
+
} | {
|
|
70
|
+
readonly ok: false;
|
|
71
|
+
readonly reason: string;
|
|
72
|
+
};
|
|
73
|
+
/** A route follows at most this many to-one relationships. */
|
|
74
|
+
export declare const MAXIMUM_HOPS = 2;
|
|
75
|
+
/**
|
|
76
|
+
* The JSON Schema pattern of a metric query's name: `entity.member`, or a route of at most
|
|
77
|
+
* {@link MAXIMUM_HOPS} relationships from a metric entity, in snake_case segments.
|
|
78
|
+
*/
|
|
79
|
+
export declare const METRIC_QUERY_NAME_PATTERN = "^[a-z][a-z0-9_]*(?:\\.[a-z][a-z0-9_]*){1,3}$";
|
|
80
|
+
/** To-one relationships followed from an entity, and every entity visited, both ends included. */
|
|
81
|
+
export interface MetricRoute {
|
|
82
|
+
readonly relationships: readonly string[];
|
|
83
|
+
readonly entities: readonly string[];
|
|
84
|
+
}
|
|
85
|
+
/** The built-in User is never replicated, so no route passes through it or ends at it. */
|
|
86
|
+
export declare function isBuiltInUser(entity: string): boolean;
|
|
87
|
+
export declare function hopLimitMessage(): string;
|
|
88
|
+
export declare function userPathMessage(): string;
|
|
89
|
+
export declare function unknownRelationshipMessage(input: {
|
|
90
|
+
readonly entity: string;
|
|
91
|
+
readonly relationship: string;
|
|
92
|
+
}): string;
|
|
93
|
+
/** A `rel.many`, or an inverse, which is to-many from the side that names it. */
|
|
94
|
+
export declare function toManySegmentMessage(input: {
|
|
95
|
+
readonly entity: string;
|
|
96
|
+
readonly relationship: string;
|
|
97
|
+
}): string;
|
|
98
|
+
export declare function unknownPropertyMessage(input: {
|
|
99
|
+
readonly entity: string;
|
|
100
|
+
readonly property: string;
|
|
101
|
+
}): string;
|
|
102
|
+
/** A bare metric name that is not a metric of the model. */
|
|
103
|
+
export declare function unknownModelMetricMessage(name: string): string;
|
|
104
|
+
/** A filter that applies to some entities a model metric reads and cannot reach another. */
|
|
105
|
+
export declare function partialFilterMessage(input: {
|
|
106
|
+
readonly filter: string;
|
|
107
|
+
readonly entity: string;
|
|
108
|
+
readonly metric: string;
|
|
109
|
+
}): string;
|
|
110
|
+
/**
|
|
111
|
+
* Every entity one entity reaches, with the shortest routes there, in the order they are first
|
|
112
|
+
* reached. Routes follow one to {@link MAXIMUM_HOPS} declared `rel.one`s, never inverses, never
|
|
113
|
+
* through User, and never visit an entity twice; several routes to one target are listed in
|
|
114
|
+
* declaration order. These are the routes metric query resolution weighs.
|
|
115
|
+
*/
|
|
116
|
+
export declare function shortestRoutesFrom(manifest: OntologyManifest, from: string): ReadonlyMap<string, readonly MetricRoute[]>;
|
|
117
|
+
/** The shortest routes from one entity to another, under {@link shortestRoutesFrom}'s rules. */
|
|
118
|
+
export declare function shortestRoutes(manifest: OntologyManifest, input: {
|
|
119
|
+
readonly from: string;
|
|
120
|
+
readonly to: string;
|
|
121
|
+
}): readonly MetricRoute[];
|
|
122
|
+
/** The entities a model metric reads, each once, in the order of its inputs. */
|
|
123
|
+
export declare function inputEntities(metric: Pick<ModelMetricManifest, "inputs">): readonly string[];
|
|
124
|
+
/**
|
|
125
|
+
* Resolves the names of a model-level metric query against a manifest
|
|
126
|
+
* (docs/ontology-aggregates-spec.md, "Resolution"). It is the one place names and routes resolve: backend-next plans each metric
|
|
127
|
+
* entity from it, and the ontology service checks `<entity>:read` on every entity it touches.
|
|
128
|
+
*
|
|
129
|
+
* Pure: it reads only the manifest. It does not check partitions, currency, replication or metric
|
|
130
|
+
* operators, nor add scope parents, which the planner adds along the same relative path.
|
|
131
|
+
*/
|
|
132
|
+
export declare function resolveMetricRoutes(manifest: OntologyManifest, names: MetricQueryNames): MetricRoutes;
|