@eloxiv/contracts 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/Agent.d.ts +792 -0
- package/dist/Agent.d.ts.map +1 -0
- package/dist/Agent.js +610 -0
- package/dist/Agent.js.map +1 -0
- package/dist/Analytics.d.ts +46 -0
- package/dist/Analytics.d.ts.map +1 -0
- package/dist/Analytics.js +89 -0
- package/dist/Analytics.js.map +1 -0
- package/dist/Approval.d.ts +70 -0
- package/dist/Approval.d.ts.map +1 -0
- package/dist/Approval.js +127 -0
- package/dist/Approval.js.map +1 -0
- package/dist/Catalog.d.ts +238 -0
- package/dist/Catalog.d.ts.map +1 -0
- package/dist/Catalog.js +169 -0
- package/dist/Catalog.js.map +1 -0
- package/dist/Checklist.d.ts +99 -0
- package/dist/Checklist.d.ts.map +1 -0
- package/dist/Checklist.js +105 -0
- package/dist/Checklist.js.map +1 -0
- package/dist/Data.d.ts +107 -0
- package/dist/Data.d.ts.map +1 -0
- package/dist/Data.js +93 -0
- package/dist/Data.js.map +1 -0
- package/dist/Devices.d.ts +857 -0
- package/dist/Devices.d.ts.map +1 -0
- package/dist/Devices.js +590 -0
- package/dist/Devices.js.map +1 -0
- package/dist/Durable.d.ts +406 -0
- package/dist/Durable.d.ts.map +1 -0
- package/dist/Durable.js +203 -0
- package/dist/Durable.js.map +1 -0
- package/dist/Errors.d.ts +95 -0
- package/dist/Errors.d.ts.map +1 -0
- package/dist/Errors.js +72 -0
- package/dist/Errors.js.map +1 -0
- package/dist/JsonSchema.d.ts +355 -0
- package/dist/JsonSchema.d.ts.map +1 -0
- package/dist/JsonSchema.js +151 -0
- package/dist/JsonSchema.js.map +1 -0
- package/dist/Manifest.d.ts +353 -0
- package/dist/Manifest.d.ts.map +1 -0
- package/dist/Manifest.js +894 -0
- package/dist/Manifest.js.map +1 -0
- package/dist/Module.d.ts +447 -0
- package/dist/Module.d.ts.map +1 -0
- package/dist/Module.js +221 -0
- package/dist/Module.js.map +1 -0
- package/dist/Optimistic.d.ts +192 -0
- package/dist/Optimistic.d.ts.map +1 -0
- package/dist/Optimistic.js +319 -0
- package/dist/Optimistic.js.map +1 -0
- package/dist/Projection.d.ts +163 -0
- package/dist/Projection.d.ts.map +1 -0
- package/dist/Projection.js +158 -0
- package/dist/Projection.js.map +1 -0
- package/dist/Proposals.d.ts +103 -0
- package/dist/Proposals.d.ts.map +1 -0
- package/dist/Proposals.js +72 -0
- package/dist/Proposals.js.map +1 -0
- package/dist/Receipt.d.ts +243 -0
- package/dist/Receipt.d.ts.map +1 -0
- package/dist/Receipt.js +108 -0
- package/dist/Receipt.js.map +1 -0
- package/dist/Records.d.ts +297 -0
- package/dist/Records.d.ts.map +1 -0
- package/dist/Records.js +171 -0
- package/dist/Records.js.map +1 -0
- package/dist/Render.d.ts +207 -0
- package/dist/Render.d.ts.map +1 -0
- package/dist/Render.js +502 -0
- package/dist/Render.js.map +1 -0
- package/dist/Rpc.d.ts +115 -0
- package/dist/Rpc.d.ts.map +1 -0
- package/dist/Rpc.js +68 -0
- package/dist/Rpc.js.map +1 -0
- package/dist/SearchLanguages.d.ts +4 -0
- package/dist/SearchLanguages.d.ts.map +1 -0
- package/dist/SearchLanguages.js +33 -0
- package/dist/SearchLanguages.js.map +1 -0
- package/dist/Service.d.ts +59 -0
- package/dist/Service.d.ts.map +1 -0
- package/dist/Service.js +38 -0
- package/dist/Service.js.map +1 -0
- package/dist/Versions.d.ts +9 -0
- package/dist/Versions.d.ts.map +1 -0
- package/dist/Versions.js +78 -0
- package/dist/Versions.js.map +1 -0
- package/dist/contracts/ActionConsent.d.ts +189 -0
- package/dist/contracts/ActionConsent.d.ts.map +1 -0
- package/dist/contracts/ActionConsent.js +129 -0
- package/dist/contracts/ActionConsent.js.map +1 -0
- package/dist/contracts/ActionRegistry.d.ts +149 -0
- package/dist/contracts/ActionRegistry.d.ts.map +1 -0
- package/dist/contracts/ActionRegistry.js +37 -0
- package/dist/contracts/ActionRegistry.js.map +1 -0
- package/dist/contracts/Actor.d.ts +129 -0
- package/dist/contracts/Actor.d.ts.map +1 -0
- package/dist/contracts/Actor.js +47 -0
- package/dist/contracts/Actor.js.map +1 -0
- package/dist/contracts/AgentResources.d.ts +248 -0
- package/dist/contracts/AgentResources.d.ts.map +1 -0
- package/dist/contracts/AgentResources.js +158 -0
- package/dist/contracts/AgentResources.js.map +1 -0
- package/dist/contracts/AgentRuntime.d.ts +453 -0
- package/dist/contracts/AgentRuntime.d.ts.map +1 -0
- package/dist/contracts/AgentRuntime.js +117 -0
- package/dist/contracts/AgentRuntime.js.map +1 -0
- package/dist/contracts/Approvals.d.ts +303 -0
- package/dist/contracts/Approvals.d.ts.map +1 -0
- package/dist/contracts/Approvals.js +117 -0
- package/dist/contracts/Approvals.js.map +1 -0
- package/dist/contracts/Audit.d.ts +510 -0
- package/dist/contracts/Audit.d.ts.map +1 -0
- package/dist/contracts/Audit.js +139 -0
- package/dist/contracts/Audit.js.map +1 -0
- package/dist/contracts/CalendarProvider.d.ts +572 -0
- package/dist/contracts/CalendarProvider.d.ts.map +1 -0
- package/dist/contracts/CalendarProvider.js +203 -0
- package/dist/contracts/CalendarProvider.js.map +1 -0
- package/dist/contracts/Capability.d.ts +197 -0
- package/dist/contracts/Capability.d.ts.map +1 -0
- package/dist/contracts/Capability.js +189 -0
- package/dist/contracts/Capability.js.map +1 -0
- package/dist/contracts/ClientSDK.d.ts +250 -0
- package/dist/contracts/ClientSDK.d.ts.map +1 -0
- package/dist/contracts/ClientSDK.js +184 -0
- package/dist/contracts/ClientSDK.js.map +1 -0
- package/dist/contracts/CollabDocument.d.ts +781 -0
- package/dist/contracts/CollabDocument.d.ts.map +1 -0
- package/dist/contracts/CollabDocument.js +364 -0
- package/dist/contracts/CollabDocument.js.map +1 -0
- package/dist/contracts/Command.d.ts +183 -0
- package/dist/contracts/Command.d.ts.map +1 -0
- package/dist/contracts/Command.js +66 -0
- package/dist/contracts/Command.js.map +1 -0
- package/dist/contracts/Connections.d.ts +612 -0
- package/dist/contracts/Connections.d.ts.map +1 -0
- package/dist/contracts/Connections.js +323 -0
- package/dist/contracts/Connections.js.map +1 -0
- package/dist/contracts/ContextAccounting.d.ts +79 -0
- package/dist/contracts/ContextAccounting.d.ts.map +1 -0
- package/dist/contracts/ContextAccounting.js +32 -0
- package/dist/contracts/ContextAccounting.js.map +1 -0
- package/dist/contracts/Daemon.d.ts +486 -0
- package/dist/contracts/Daemon.d.ts.map +1 -0
- package/dist/contracts/Daemon.js +192 -0
- package/dist/contracts/Daemon.js.map +1 -0
- package/dist/contracts/DbTx.d.ts +149 -0
- package/dist/contracts/DbTx.d.ts.map +1 -0
- package/dist/contracts/DbTx.js +94 -0
- package/dist/contracts/DbTx.js.map +1 -0
- package/dist/contracts/Delegation.d.ts +121 -0
- package/dist/contracts/Delegation.d.ts.map +1 -0
- package/dist/contracts/Delegation.js +76 -0
- package/dist/contracts/Delegation.js.map +1 -0
- package/dist/contracts/DeviceControl.d.ts +293 -0
- package/dist/contracts/DeviceControl.d.ts.map +1 -0
- package/dist/contracts/DeviceControl.js +107 -0
- package/dist/contracts/DeviceControl.js.map +1 -0
- package/dist/contracts/Directory.d.ts +492 -0
- package/dist/contracts/Directory.d.ts.map +1 -0
- package/dist/contracts/Directory.js +225 -0
- package/dist/contracts/Directory.js.map +1 -0
- package/dist/contracts/DirectoryProvider.d.ts +214 -0
- package/dist/contracts/DirectoryProvider.d.ts.map +1 -0
- package/dist/contracts/DirectoryProvider.js +73 -0
- package/dist/contracts/DirectoryProvider.js.map +1 -0
- package/dist/contracts/DocumentSource.d.ts +190 -0
- package/dist/contracts/DocumentSource.d.ts.map +1 -0
- package/dist/contracts/DocumentSource.js +64 -0
- package/dist/contracts/DocumentSource.js.map +1 -0
- package/dist/contracts/Files.d.ts +762 -0
- package/dist/contracts/Files.d.ts.map +1 -0
- package/dist/contracts/Files.js +339 -0
- package/dist/contracts/Files.js.map +1 -0
- package/dist/contracts/Flags.d.ts +265 -0
- package/dist/contracts/Flags.d.ts.map +1 -0
- package/dist/contracts/Flags.js +197 -0
- package/dist/contracts/Flags.js.map +1 -0
- package/dist/contracts/Host.d.ts +320 -0
- package/dist/contracts/Host.d.ts.map +1 -0
- package/dist/contracts/Host.js +224 -0
- package/dist/contracts/Host.js.map +1 -0
- package/dist/contracts/HttpApi.d.ts +102 -0
- package/dist/contracts/HttpApi.d.ts.map +1 -0
- package/dist/contracts/HttpApi.js +89 -0
- package/dist/contracts/HttpApi.js.map +1 -0
- package/dist/contracts/Ingestion.d.ts +522 -0
- package/dist/contracts/Ingestion.d.ts.map +1 -0
- package/dist/contracts/Ingestion.js +275 -0
- package/dist/contracts/Ingestion.js.map +1 -0
- package/dist/contracts/Ingress.d.ts +132 -0
- package/dist/contracts/Ingress.d.ts.map +1 -0
- package/dist/contracts/Ingress.js +102 -0
- package/dist/contracts/Ingress.js.map +1 -0
- package/dist/contracts/Invocation.d.ts +361 -0
- package/dist/contracts/Invocation.d.ts.map +1 -0
- package/dist/contracts/Invocation.js +104 -0
- package/dist/contracts/Invocation.js.map +1 -0
- package/dist/contracts/LocalClient.d.ts +878 -0
- package/dist/contracts/LocalClient.d.ts.map +1 -0
- package/dist/contracts/LocalClient.js +423 -0
- package/dist/contracts/LocalClient.js.map +1 -0
- package/dist/contracts/Locale.d.ts +162 -0
- package/dist/contracts/Locale.d.ts.map +1 -0
- package/dist/contracts/Locale.js +123 -0
- package/dist/contracts/Locale.js.map +1 -0
- package/dist/contracts/MachineIdentity.d.ts +434 -0
- package/dist/contracts/MachineIdentity.d.ts.map +1 -0
- package/dist/contracts/MachineIdentity.js +223 -0
- package/dist/contracts/MachineIdentity.js.map +1 -0
- package/dist/contracts/MailProvider.d.ts +791 -0
- package/dist/contracts/MailProvider.d.ts.map +1 -0
- package/dist/contracts/MailProvider.js +237 -0
- package/dist/contracts/MailProvider.js.map +1 -0
- package/dist/contracts/Memory.d.ts +62 -0
- package/dist/contracts/Memory.d.ts.map +1 -0
- package/dist/contracts/Memory.js +43 -0
- package/dist/contracts/Memory.js.map +1 -0
- package/dist/contracts/Messaging.d.ts +154 -0
- package/dist/contracts/Messaging.d.ts.map +1 -0
- package/dist/contracts/Messaging.js +97 -0
- package/dist/contracts/Messaging.js.map +1 -0
- package/dist/contracts/Metering.d.ts +334 -0
- package/dist/contracts/Metering.d.ts.map +1 -0
- package/dist/contracts/Metering.js +202 -0
- package/dist/contracts/Metering.js.map +1 -0
- package/dist/contracts/ModelProvider.d.ts +142 -0
- package/dist/contracts/ModelProvider.d.ts.map +1 -0
- package/dist/contracts/ModelProvider.js +72 -0
- package/dist/contracts/ModelProvider.js.map +1 -0
- package/dist/contracts/ModuleManifest.d.ts +2519 -0
- package/dist/contracts/ModuleManifest.d.ts.map +1 -0
- package/dist/contracts/ModuleManifest.js +272 -0
- package/dist/contracts/ModuleManifest.js.map +1 -0
- package/dist/contracts/NotificationChannel.d.ts +378 -0
- package/dist/contracts/NotificationChannel.d.ts.map +1 -0
- package/dist/contracts/NotificationChannel.js +136 -0
- package/dist/contracts/NotificationChannel.js.map +1 -0
- package/dist/contracts/Notifications.d.ts +417 -0
- package/dist/contracts/Notifications.d.ts.map +1 -0
- package/dist/contracts/Notifications.js +267 -0
- package/dist/contracts/Notifications.js.map +1 -0
- package/dist/contracts/Outbox.d.ts +469 -0
- package/dist/contracts/Outbox.d.ts.map +1 -0
- package/dist/contracts/Outbox.js +215 -0
- package/dist/contracts/Outbox.js.map +1 -0
- package/dist/contracts/Privacy.d.ts +1029 -0
- package/dist/contracts/Privacy.d.ts.map +1 -0
- package/dist/contracts/Privacy.js +437 -0
- package/dist/contracts/Privacy.js.map +1 -0
- package/dist/contracts/Progress.d.ts +305 -0
- package/dist/contracts/Progress.d.ts.map +1 -0
- package/dist/contracts/Progress.js +174 -0
- package/dist/contracts/Progress.js.map +1 -0
- package/dist/contracts/QuerySurface.d.ts +231 -0
- package/dist/contracts/QuerySurface.d.ts.map +1 -0
- package/dist/contracts/QuerySurface.js +113 -0
- package/dist/contracts/QuerySurface.js.map +1 -0
- package/dist/contracts/Readiness.d.ts +105 -0
- package/dist/contracts/Readiness.d.ts.map +1 -0
- package/dist/contracts/Readiness.js +57 -0
- package/dist/contracts/Readiness.js.map +1 -0
- package/dist/contracts/Release.d.ts +295 -0
- package/dist/contracts/Release.d.ts.map +1 -0
- package/dist/contracts/Release.js +175 -0
- package/dist/contracts/Release.js.map +1 -0
- package/dist/contracts/ResultRendering.d.ts +533 -0
- package/dist/contracts/ResultRendering.d.ts.map +1 -0
- package/dist/contracts/ResultRendering.js +59 -0
- package/dist/contracts/ResultRendering.js.map +1 -0
- package/dist/contracts/Sandbox.d.ts +1164 -0
- package/dist/contracts/Sandbox.d.ts.map +1 -0
- package/dist/contracts/Sandbox.js +550 -0
- package/dist/contracts/Sandbox.js.map +1 -0
- package/dist/contracts/Scheduler.d.ts +814 -0
- package/dist/contracts/Scheduler.d.ts.map +1 -0
- package/dist/contracts/Scheduler.js +202 -0
- package/dist/contracts/Scheduler.js.map +1 -0
- package/dist/contracts/ScreenContext.d.ts +514 -0
- package/dist/contracts/ScreenContext.d.ts.map +1 -0
- package/dist/contracts/ScreenContext.js +272 -0
- package/dist/contracts/ScreenContext.js.map +1 -0
- package/dist/contracts/Search.d.ts +308 -0
- package/dist/contracts/Search.d.ts.map +1 -0
- package/dist/contracts/Search.js +107 -0
- package/dist/contracts/Search.js.map +1 -0
- package/dist/contracts/Secrets.d.ts +483 -0
- package/dist/contracts/Secrets.d.ts.map +1 -0
- package/dist/contracts/Secrets.js +136 -0
- package/dist/contracts/Secrets.js.map +1 -0
- package/dist/contracts/Settings.d.ts +221 -0
- package/dist/contracts/Settings.d.ts.map +1 -0
- package/dist/contracts/Settings.js +163 -0
- package/dist/contracts/Settings.js.map +1 -0
- package/dist/contracts/Sharing.d.ts +319 -0
- package/dist/contracts/Sharing.d.ts.map +1 -0
- package/dist/contracts/Sharing.js +172 -0
- package/dist/contracts/Sharing.js.map +1 -0
- package/dist/contracts/Slot.d.ts +162 -0
- package/dist/contracts/Slot.d.ts.map +1 -0
- package/dist/contracts/Slot.js +56 -0
- package/dist/contracts/Slot.js.map +1 -0
- package/dist/contracts/Space.d.ts +256 -0
- package/dist/contracts/Space.d.ts.map +1 -0
- package/dist/contracts/Space.js +133 -0
- package/dist/contracts/Space.js.map +1 -0
- package/dist/contracts/StorageAdapter.d.ts +124 -0
- package/dist/contracts/StorageAdapter.d.ts.map +1 -0
- package/dist/contracts/StorageAdapter.js +96 -0
- package/dist/contracts/StorageAdapter.js.map +1 -0
- package/dist/contracts/StorageBackend.d.ts +310 -0
- package/dist/contracts/StorageBackend.d.ts.map +1 -0
- package/dist/contracts/StorageBackend.js +196 -0
- package/dist/contracts/StorageBackend.js.map +1 -0
- package/dist/contracts/Sync.d.ts +286 -0
- package/dist/contracts/Sync.d.ts.map +1 -0
- package/dist/contracts/Sync.js +157 -0
- package/dist/contracts/Sync.js.map +1 -0
- package/dist/contracts/Telemetry.d.ts +183 -0
- package/dist/contracts/Telemetry.d.ts.map +1 -0
- package/dist/contracts/Telemetry.js +153 -0
- package/dist/contracts/Telemetry.js.map +1 -0
- package/dist/contracts/ThemeTokens.d.ts +212 -0
- package/dist/contracts/ThemeTokens.d.ts.map +1 -0
- package/dist/contracts/ThemeTokens.js +111 -0
- package/dist/contracts/ThemeTokens.js.map +1 -0
- package/dist/contracts/ToolSource.d.ts +135 -0
- package/dist/contracts/ToolSource.d.ts.map +1 -0
- package/dist/contracts/ToolSource.js +81 -0
- package/dist/contracts/ToolSource.js.map +1 -0
- package/dist/contracts/Versioning.d.ts +363 -0
- package/dist/contracts/Versioning.d.ts.map +1 -0
- package/dist/contracts/Versioning.js +201 -0
- package/dist/contracts/Versioning.js.map +1 -0
- package/dist/contracts/View.d.ts +232 -0
- package/dist/contracts/View.d.ts.map +1 -0
- package/dist/contracts/View.js +102 -0
- package/dist/contracts/View.js.map +1 -0
- package/dist/contracts/WorkItems.d.ts +242 -0
- package/dist/contracts/WorkItems.d.ts.map +1 -0
- package/dist/contracts/WorkItems.js +126 -0
- package/dist/contracts/WorkItems.js.map +1 -0
- package/dist/contracts/Workflow.d.ts +191 -0
- package/dist/contracts/Workflow.d.ts.map +1 -0
- package/dist/contracts/Workflow.js +63 -0
- package/dist/contracts/Workflow.js.map +1 -0
- package/dist/contracts/index.d.ts +75 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +196 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/devices/module.d.ts +3777 -0
- package/dist/devices/module.d.ts.map +1 -0
- package/dist/devices/module.js +179 -0
- package/dist/devices/module.js.map +1 -0
- package/dist/drizzle/Entity.d.ts +148 -0
- package/dist/drizzle/Entity.d.ts.map +1 -0
- package/dist/drizzle/Entity.js +396 -0
- package/dist/drizzle/Entity.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -3
- package/schema/Actor.json +46 -0
- package/schema/AuditRecord.json +403 -0
- package/schema/DaemonHealth.json +29 -0
- package/schema/InvocationError.json +257 -0
- package/schema/InvocationReceipt.json +253 -0
- package/schema/Lockfile.json +129 -0
- package/schema/OutboxEvent.json +36 -0
- package/schema/PairingConfirm.json +33 -0
- package/schema/PairingResult.json +18 -0
- package/schema/PairingStart.json +18 -0
- package/schema/ProvenanceEntry.json +110 -0
- package/schema/ReplayEnvelope.json +269 -0
- package/schema/Surface.json +17 -0
- package/schema/codegen/LocalClient.json +1295 -0
- package/schema/codegen/Sandbox.json +320 -0
- package/schema/contracts/ActionConsent.json +1930 -0
- package/schema/contracts/ActionRegistry.json +722 -0
- package/schema/contracts/Actor.json +451 -0
- package/schema/contracts/AgentResources.json +1400 -0
- package/schema/contracts/AgentRuntime.json +4017 -0
- package/schema/contracts/Approvals.json +2916 -0
- package/schema/contracts/Audit.json +3268 -0
- package/schema/contracts/CalendarProvider.json +5557 -0
- package/schema/contracts/ClientSDK.json +1400 -0
- package/schema/contracts/CollabDocument.json +4012 -0
- package/schema/contracts/Command.json +616 -0
- package/schema/contracts/Connections.json +6687 -0
- package/schema/contracts/ContextAccounting.json +685 -0
- package/schema/contracts/Daemon.json +4555 -0
- package/schema/contracts/DbTx.json +321 -0
- package/schema/contracts/Delegation.json +949 -0
- package/schema/contracts/DeviceControl.json +2626 -0
- package/schema/contracts/Directory.json +5168 -0
- package/schema/contracts/DirectoryProvider.json +2090 -0
- package/schema/contracts/DocumentSource.json +2044 -0
- package/schema/contracts/Files.json +4122 -0
- package/schema/contracts/Flags.json +1202 -0
- package/schema/contracts/Host.json +1769 -0
- package/schema/contracts/HttpApi.json +1615 -0
- package/schema/contracts/Ingestion.json +3211 -0
- package/schema/contracts/Ingress.json +819 -0
- package/schema/contracts/Invocation.json +2044 -0
- package/schema/contracts/LocalClient.json +6642 -0
- package/schema/contracts/Locale.json +654 -0
- package/schema/contracts/MachineIdentity.json +2303 -0
- package/schema/contracts/MailProvider.json +6663 -0
- package/schema/contracts/Memory.json +579 -0
- package/schema/contracts/Messaging.json +1764 -0
- package/schema/contracts/Metering.json +3060 -0
- package/schema/contracts/ModelProvider.json +1127 -0
- package/schema/contracts/ModuleManifest.json +9449 -0
- package/schema/contracts/NotificationChannel.json +986 -0
- package/schema/contracts/Notifications.json +4280 -0
- package/schema/contracts/Outbox.json +1451 -0
- package/schema/contracts/Privacy.json +4354 -0
- package/schema/contracts/Progress.json +1524 -0
- package/schema/contracts/QuerySurface.json +661 -0
- package/schema/contracts/Readiness.json +209 -0
- package/schema/contracts/Release.json +805 -0
- package/schema/contracts/ResultRendering.json +2859 -0
- package/schema/contracts/Sandbox.json +2286 -0
- package/schema/contracts/Scheduler.json +6138 -0
- package/schema/contracts/ScreenContext.json +1238 -0
- package/schema/contracts/Search.json +1058 -0
- package/schema/contracts/Secrets.json +2444 -0
- package/schema/contracts/Settings.json +654 -0
- package/schema/contracts/Sharing.json +2854 -0
- package/schema/contracts/Slot.json +537 -0
- package/schema/contracts/Space.json +892 -0
- package/schema/contracts/StorageAdapter.json +623 -0
- package/schema/contracts/StorageBackend.json +2421 -0
- package/schema/contracts/Sync.json +894 -0
- package/schema/contracts/Telemetry.json +696 -0
- package/schema/contracts/ThemeTokens.json +547 -0
- package/schema/contracts/ToolSource.json +1333 -0
- package/schema/contracts/Versioning.json +1481 -0
- package/schema/contracts/View.json +750 -0
- package/schema/contracts/WorkItems.json +1731 -0
- package/schema/contracts/Workflow.json +1242 -0
- package/src/Agent.ts +758 -0
- package/src/Analytics.ts +110 -0
- package/src/Approval.ts +131 -0
- package/src/Catalog.ts +192 -0
- package/src/Checklist.ts +162 -0
- package/src/Data.ts +109 -0
- package/src/Devices.ts +721 -0
- package/src/Durable.ts +240 -0
- package/src/Errors.ts +111 -0
- package/src/JsonSchema.ts +166 -0
- package/src/Manifest.ts +1147 -0
- package/src/Module.ts +640 -0
- package/src/Optimistic.ts +332 -0
- package/src/Projection.ts +207 -0
- package/src/Proposals.ts +89 -0
- package/src/Receipt.ts +125 -0
- package/src/Records.ts +197 -0
- package/src/Render.ts +515 -0
- package/src/Rpc.ts +113 -0
- package/src/SearchLanguages.ts +33 -0
- package/src/Service.ts +102 -0
- package/src/Versions.ts +69 -0
- package/src/contracts/ActionConsent.ts +150 -0
- package/src/contracts/ActionRegistry.ts +39 -0
- package/src/contracts/Actor.ts +53 -0
- package/src/contracts/AgentResources.ts +167 -0
- package/src/contracts/AgentRuntime.ts +154 -0
- package/src/contracts/Approvals.ts +133 -0
- package/src/contracts/Audit.ts +160 -0
- package/src/contracts/CalendarProvider.ts +241 -0
- package/src/contracts/Capability.ts +246 -0
- package/src/contracts/ClientSDK.ts +199 -0
- package/src/contracts/CollabDocument.ts +420 -0
- package/src/contracts/Command.ts +74 -0
- package/src/contracts/Connections.ts +360 -0
- package/src/contracts/ContextAccounting.ts +35 -0
- package/src/contracts/Daemon.ts +247 -0
- package/src/contracts/DbTx.ts +110 -0
- package/src/contracts/Delegation.ts +91 -0
- package/src/contracts/DeviceControl.ts +143 -0
- package/src/contracts/Directory.ts +384 -0
- package/src/contracts/DirectoryProvider.ts +82 -0
- package/src/contracts/DocumentSource.ts +71 -0
- package/src/contracts/Files.ts +395 -0
- package/src/contracts/Flags.ts +241 -0
- package/src/contracts/Host.ts +245 -0
- package/src/contracts/HttpApi.ts +100 -0
- package/src/contracts/Ingestion.ts +315 -0
- package/src/contracts/Ingress.ts +132 -0
- package/src/contracts/Invocation.ts +122 -0
- package/src/contracts/LocalClient.ts +614 -0
- package/src/contracts/Locale.ts +133 -0
- package/src/contracts/MachineIdentity.ts +305 -0
- package/src/contracts/MailProvider.ts +272 -0
- package/src/contracts/Memory.ts +47 -0
- package/src/contracts/Messaging.ts +108 -0
- package/src/contracts/Metering.ts +231 -0
- package/src/contracts/ModelProvider.ts +87 -0
- package/src/contracts/ModuleManifest.ts +310 -0
- package/src/contracts/NotificationChannel.ts +158 -0
- package/src/contracts/Notifications.ts +309 -0
- package/src/contracts/Outbox.ts +246 -0
- package/src/contracts/Privacy.ts +502 -0
- package/src/contracts/Progress.ts +196 -0
- package/src/contracts/QuerySurface.ts +134 -0
- package/src/contracts/Readiness.ts +67 -0
- package/src/contracts/Release.ts +199 -0
- package/src/contracts/ResultRendering.ts +65 -0
- package/src/contracts/Sandbox.ts +648 -0
- package/src/contracts/Scheduler.ts +237 -0
- package/src/contracts/ScreenContext.ts +316 -0
- package/src/contracts/Search.ts +126 -0
- package/src/contracts/Secrets.ts +162 -0
- package/src/contracts/Settings.ts +207 -0
- package/src/contracts/Sharing.ts +205 -0
- package/src/contracts/Slot.ts +61 -0
- package/src/contracts/Space.ts +157 -0
- package/src/contracts/StorageAdapter.ts +104 -0
- package/src/contracts/StorageBackend.ts +220 -0
- package/src/contracts/Sync.ts +180 -0
- package/src/contracts/Telemetry.ts +177 -0
- package/src/contracts/ThemeTokens.ts +136 -0
- package/src/contracts/ToolSource.ts +94 -0
- package/src/contracts/Versioning.ts +237 -0
- package/src/contracts/View.ts +116 -0
- package/src/contracts/WorkItems.ts +144 -0
- package/src/contracts/Workflow.ts +67 -0
- package/src/contracts/index.ts +205 -0
- package/src/devices/module.ts +201 -0
- package/src/drizzle/Entity.ts +524 -0
- package/src/index.ts +19 -0
package/dist/Manifest.js
ADDED
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module manifest's declarations beyond entities, actions and events
|
|
3
|
+
* (decisions.md "Kernel contracts"): permission vocabulary, settings, skills,
|
|
4
|
+
* views, slots and contributions, commands, work-item sources (decision 3),
|
|
5
|
+
* entity resolvers and published query views (decision 6). Each is data, with
|
|
6
|
+
* Effect Schema for every value it types, so it emits as JSON Schema
|
|
7
|
+
* (`moduleToJson`) and another language can read and check it.
|
|
8
|
+
*
|
|
9
|
+
* `manifestProblems` checks the declarations of every installed module
|
|
10
|
+
* together: references must resolve (entities, actions, views, slots, query
|
|
11
|
+
* views), ids must be namespaced by their module and unique where they are
|
|
12
|
+
* global, defaults must decode against their schemas, and published query
|
|
13
|
+
* views must be plain `SELECT`s over the module's own schema. The kernel runs it
|
|
14
|
+
* when it builds its registry and refuses to start an app with any problem.
|
|
15
|
+
*
|
|
16
|
+
* Jobs are declared by the Scheduler contract (`jobs`), which adds its own field;
|
|
17
|
+
* `manifestProblems` checks them too: each must invoke an installed action with
|
|
18
|
+
* input that action accepts, on a cron or interval schedule.
|
|
19
|
+
*/
|
|
20
|
+
import { Exit, Schema } from "effect";
|
|
21
|
+
import { ApprovalRule, approvalRuleShapeProblems } from "./Approval.js";
|
|
22
|
+
import { analyticsEventProblems } from "./Analytics.js";
|
|
23
|
+
import { renderProblems } from "./Render.js";
|
|
24
|
+
import { satisfiesRange } from "./Versions.js";
|
|
25
|
+
import { CatchUp, ScheduleSpec } from "./Durable.js";
|
|
26
|
+
import { BestEffortFields } from "./Module.js";
|
|
27
|
+
import { optimisticProblems } from "./Optimistic.js";
|
|
28
|
+
import { SEARCH_LANGUAGES } from "./SearchLanguages.js";
|
|
29
|
+
/** Where a setting's value lives: per person, per organisation, per app deployment, or per module installation. */
|
|
30
|
+
export const SettingScope = Schema.Literals(["user", "org", "app", "module"]);
|
|
31
|
+
export const SKILL_AUDIENCES = ["runtime", "development", "both"];
|
|
32
|
+
/** The states of a work item in the unified inbox (decision 3). */
|
|
33
|
+
export const WorkItemState = Schema.Literals(["open", "waiting", "done"]);
|
|
34
|
+
export const isNoDataSubjects = (entry) => "none" in entry;
|
|
35
|
+
/** The declarations of `dataSubjects` that name a person (by entity), leaving out the entities about nobody. */
|
|
36
|
+
export const dataSubjectDeclarations = (entries) => Object.fromEntries(Object.entries(entries ?? {}).flatMap(([key, entry]) => (isNoDataSubjects(entry) ? [] : [[key, entry]])));
|
|
37
|
+
/**
|
|
38
|
+
* Declarations deleting, on erasure, every record of `entities` that holds a person's user id in any user-typed
|
|
39
|
+
* attribute (by entity key), with `overrides` for the entities that do something else.
|
|
40
|
+
*/
|
|
41
|
+
export const deleteRecordsAbout = (entities, overrides = {}) => Object.fromEntries(Object.entries(entities).flatMap(([key, entity]) => {
|
|
42
|
+
const fields = userFields(entity);
|
|
43
|
+
return fields.length === 0 ? [] : [[key, { fields, erase: overrides[key] ?? { kind: "delete" } }]];
|
|
44
|
+
}));
|
|
45
|
+
/** The fields of an entity whose policy attributes hold a user id (`Eloxiv::User` columns). */
|
|
46
|
+
export const userFields = (entity) => Object.values(entity.policyAttributes).flatMap((a) => a.kind === "column" && a.type === "Entity" && a.entityType === "Eloxiv::User" ? [a.field] : []);
|
|
47
|
+
/** Field or column names that say they hold a person's id (`authorId`, `owner_id`, `user`, `createdBy`...). */
|
|
48
|
+
const PERSON_NAME = /^(?:user|owner|author|creator|created_?by|updated_?by|assignee|customer|member|actor|subject|recipient|sender|requester|requested_?by|approver|reviewer|person|principal)(?:_?ids?)?$|(?:user|person)_?ids?$/iu;
|
|
49
|
+
/** The fields of an entity whose name or column says they hold a person's id, typed or not. */
|
|
50
|
+
export const personNamedFields = (entity) => Object.entries(entity.columns).flatMap(([field, column]) => PERSON_NAME.test(field) || PERSON_NAME.test(column) ? [field] : []);
|
|
51
|
+
/**
|
|
52
|
+
* The privacy module's completeness rule: every entity of `modules` is declared in its module's `dataSubjects`,
|
|
53
|
+
* either with the fields naming a person (every user-typed policy attribute's among them) or as about nobody, which
|
|
54
|
+
* an entity with a user-typed attribute, or a field named for a person, cannot be: nothing about a person is left
|
|
55
|
+
* out of an export or an erasure by omission.
|
|
56
|
+
*/
|
|
57
|
+
export const dataSubjectCoverageProblems = (modules) => {
|
|
58
|
+
const problems = [];
|
|
59
|
+
for (const module of modules) {
|
|
60
|
+
for (const [key, entity] of Object.entries(module.entities)) {
|
|
61
|
+
const typed = userFields(entity);
|
|
62
|
+
const declared = (module.dataSubjects ?? {})[key];
|
|
63
|
+
if (declared === undefined) {
|
|
64
|
+
problems.push(typed.length > 0
|
|
65
|
+
? `${module.name}: entity ${key} holds user ids (${typed.join(", ")}) but is not declared in dataSubjects (the Privacy contract: say how it is exported and erased)`
|
|
66
|
+
: `${module.name}: entity ${key} is not declared in dataSubjects (the Privacy contract: name the fields that hold a person's id, or declare it { none: reason })`);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (isNoDataSubjects(declared)) {
|
|
70
|
+
const named = [...new Set([...typed, ...personNamedFields(entity)])];
|
|
71
|
+
if (named.length > 0) {
|
|
72
|
+
problems.push(`${module.name}: dataSubjects ${key} says it is about nobody, but ${named.join(", ")} hold${named.length === 1 ? "s" : ""} a person's id`);
|
|
73
|
+
}
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const missing = typed.filter((f) => !declared.fields.includes(f));
|
|
77
|
+
if (missing.length > 0) {
|
|
78
|
+
problems.push(`${module.name}: dataSubjects ${key} leaves out its user fields ${missing.join(", ")}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return problems;
|
|
83
|
+
};
|
|
84
|
+
/** The database view a published query view is created as: `<schema>.qv_<local id>`. */
|
|
85
|
+
export const queryViewName = (id) => `qv_${id.slice(id.indexOf(".") + 1)}`;
|
|
86
|
+
/** The schema holding the query surface's views (QuerySurface): one per published query view. */
|
|
87
|
+
export const QUERY_SURFACE_SCHEMA = "eloxiv_surface";
|
|
88
|
+
/**
|
|
89
|
+
* The relation name a published query view has on the query surface (QuerySurface): `<module>_<local id>`,
|
|
90
|
+
* the name queries use, unqualified (`hello.greetings` is `hello_greetings`).
|
|
91
|
+
*/
|
|
92
|
+
export const queryRelationName = (id) => id.replace(".", "_");
|
|
93
|
+
/**
|
|
94
|
+
* Is a setting's value schema marked sensitive? Secrets never go in settings (the Secrets contract holds
|
|
95
|
+
* them): a schema annotated `sensitive: true` or `writeOnly: true`, a `password` format, or a `Redacted`
|
|
96
|
+
* value, anywhere inside it.
|
|
97
|
+
*/
|
|
98
|
+
export const isSensitiveSchema = (schema) => {
|
|
99
|
+
const seen = new Set();
|
|
100
|
+
const visit = (value) => {
|
|
101
|
+
if (value === null || typeof value !== "object" || seen.has(value))
|
|
102
|
+
return false;
|
|
103
|
+
seen.add(value);
|
|
104
|
+
const record = value;
|
|
105
|
+
if (record["sensitive"] === true || record["writeOnly"] === true || record["format"] === "password")
|
|
106
|
+
return true;
|
|
107
|
+
return Object.values(record).some(visit);
|
|
108
|
+
};
|
|
109
|
+
// The schema's AST: annotations anywhere in it, including Effect's `Redacted` declarations.
|
|
110
|
+
const marked = (value) => {
|
|
111
|
+
if (value === null || typeof value !== "object" || seen.has(value))
|
|
112
|
+
return false;
|
|
113
|
+
seen.add(value);
|
|
114
|
+
const annotations = value.annotations;
|
|
115
|
+
const representation = annotations?.["representation"];
|
|
116
|
+
if (annotations?.["sensitive"] === true || representation?.id === "effect/schema/Redacted")
|
|
117
|
+
return true;
|
|
118
|
+
return Object.values(value).some(marked);
|
|
119
|
+
};
|
|
120
|
+
if (marked(schema.ast))
|
|
121
|
+
return true;
|
|
122
|
+
seen.clear();
|
|
123
|
+
try {
|
|
124
|
+
return visit(Schema.toJsonSchemaDocument(schema));
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// A schema with no JSON form cannot be validated as a setting either; the default check reports it.
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const tokenize = (sql) => {
|
|
132
|
+
const tokens = [];
|
|
133
|
+
let i = 0;
|
|
134
|
+
while (i < sql.length) {
|
|
135
|
+
const c = sql[i];
|
|
136
|
+
if (/\s/.test(c)) {
|
|
137
|
+
i++;
|
|
138
|
+
}
|
|
139
|
+
else if (c === "'") {
|
|
140
|
+
let j = i + 1;
|
|
141
|
+
for (;;) {
|
|
142
|
+
if (j >= sql.length)
|
|
143
|
+
return "an unterminated string literal";
|
|
144
|
+
if (sql[j] === "'") {
|
|
145
|
+
if (sql[j + 1] === "'")
|
|
146
|
+
j += 2;
|
|
147
|
+
else
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
else
|
|
151
|
+
j++;
|
|
152
|
+
}
|
|
153
|
+
tokens.push({ kind: "string" });
|
|
154
|
+
i = j + 1;
|
|
155
|
+
}
|
|
156
|
+
else if (c === '"') {
|
|
157
|
+
let j = i + 1;
|
|
158
|
+
let text = "";
|
|
159
|
+
for (;;) {
|
|
160
|
+
if (j >= sql.length)
|
|
161
|
+
return "an unterminated quoted identifier";
|
|
162
|
+
if (sql[j] === '"') {
|
|
163
|
+
if (sql[j + 1] === '"') {
|
|
164
|
+
text += '"';
|
|
165
|
+
j += 2;
|
|
166
|
+
}
|
|
167
|
+
else
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
else
|
|
171
|
+
text += sql[j++];
|
|
172
|
+
}
|
|
173
|
+
tokens.push({ kind: "ident", text });
|
|
174
|
+
i = j + 1;
|
|
175
|
+
}
|
|
176
|
+
else if (/[A-Za-z_]/.test(c)) {
|
|
177
|
+
let j = i;
|
|
178
|
+
while (j < sql.length && /[A-Za-z0-9_]/.test(sql[j]))
|
|
179
|
+
j++;
|
|
180
|
+
const text = sql.slice(i, j);
|
|
181
|
+
// E'...', U&'...', B'...' and X'...' literals have their own escape rules: not allowed.
|
|
182
|
+
if (sql[j] === "'" || sql[j] === "&")
|
|
183
|
+
return `a prefixed literal (${text}'...')`;
|
|
184
|
+
tokens.push({ kind: "word", text, upper: text.toUpperCase() });
|
|
185
|
+
i = j;
|
|
186
|
+
}
|
|
187
|
+
else if (/[0-9]/.test(c)) {
|
|
188
|
+
let j = i;
|
|
189
|
+
while (j < sql.length && /[0-9.eE]/.test(sql[j]))
|
|
190
|
+
j++;
|
|
191
|
+
tokens.push({ kind: "number" });
|
|
192
|
+
i = j;
|
|
193
|
+
}
|
|
194
|
+
else if ((c === "-" && sql[i + 1] === "-") || (c === "/" && sql[i + 1] === "*")) {
|
|
195
|
+
return "a comment";
|
|
196
|
+
}
|
|
197
|
+
else if (c === "$" || c === "\\" || c === "`") {
|
|
198
|
+
return "a dollar quote, parameter or backslash";
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
tokens.push({ kind: "punct", text: c });
|
|
202
|
+
i++;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return tokens;
|
|
206
|
+
};
|
|
207
|
+
/** Keywords that make a statement something other than a plain read, or that this check does not admit. */
|
|
208
|
+
const DENIED_KEYWORDS = new Set([
|
|
209
|
+
"INSERT",
|
|
210
|
+
"UPDATE",
|
|
211
|
+
"DELETE",
|
|
212
|
+
"MERGE",
|
|
213
|
+
"INTO",
|
|
214
|
+
"WITH",
|
|
215
|
+
"FOR",
|
|
216
|
+
"CALL",
|
|
217
|
+
"DO",
|
|
218
|
+
"COPY",
|
|
219
|
+
"CREATE",
|
|
220
|
+
"DROP",
|
|
221
|
+
"ALTER",
|
|
222
|
+
"GRANT",
|
|
223
|
+
"REVOKE",
|
|
224
|
+
"TRUNCATE",
|
|
225
|
+
"LOCK",
|
|
226
|
+
"SET",
|
|
227
|
+
"RESET",
|
|
228
|
+
"RETURNING",
|
|
229
|
+
"EXECUTE",
|
|
230
|
+
"PREPARE",
|
|
231
|
+
"LISTEN",
|
|
232
|
+
"NOTIFY",
|
|
233
|
+
"VACUUM",
|
|
234
|
+
"ANALYZE",
|
|
235
|
+
"EXPLAIN",
|
|
236
|
+
"TABLE",
|
|
237
|
+
"ROWS",
|
|
238
|
+
]);
|
|
239
|
+
/** Functions with side effects, or that run SQL given as text, or read server state: refused by name. */
|
|
240
|
+
const DENIED_FUNCTION = /^(pg_|lo_|dblink|txid_|set_config$|current_setting$|nextval$|setval$|currval$|lastval$|ts_stat$|ts_rewrite$|query_to_xml|cursor_to_xml|table_to_xml|schema_to_xml|database_to_xml|xmlparse$)/i;
|
|
241
|
+
/** Clauses after which a comma at the same depth separates from-items. */
|
|
242
|
+
const CLAUSES = new Set([
|
|
243
|
+
"SELECT",
|
|
244
|
+
"FROM",
|
|
245
|
+
"WHERE",
|
|
246
|
+
"GROUP",
|
|
247
|
+
"HAVING",
|
|
248
|
+
"ORDER",
|
|
249
|
+
"LIMIT",
|
|
250
|
+
"OFFSET",
|
|
251
|
+
"FETCH",
|
|
252
|
+
"WINDOW",
|
|
253
|
+
"UNION",
|
|
254
|
+
"INTERSECT",
|
|
255
|
+
"EXCEPT",
|
|
256
|
+
]);
|
|
257
|
+
/**
|
|
258
|
+
* Why `sql` is not accepted as a published query view over `schema`, or
|
|
259
|
+
* `undefined` if it is. Deliberately conservative (fail closed): one `SELECT`
|
|
260
|
+
* statement, no comments, no CTEs, no locking or `INTO`, every table named as
|
|
261
|
+
* `<schema>.<table>`, subqueries only as `(SELECT ...)` or `(VALUES ...)`, and no
|
|
262
|
+
* schema-qualified or state-changing function calls. Setup checks the created
|
|
263
|
+
* view's real dependencies in Postgres as well.
|
|
264
|
+
*/
|
|
265
|
+
export const plainSelectProblem = (sql, schema) => {
|
|
266
|
+
const tokens = tokenize(sql.trim().replace(/;\s*$/, ""));
|
|
267
|
+
if (typeof tokens === "string")
|
|
268
|
+
return `it holds ${tokens}`;
|
|
269
|
+
if (tokens.some((t) => t.kind === "punct" && t.text === ";"))
|
|
270
|
+
return "it holds more than one statement";
|
|
271
|
+
const first = tokens[0];
|
|
272
|
+
if (first?.kind !== "word" || first.upper !== "SELECT")
|
|
273
|
+
return "it does not start with SELECT";
|
|
274
|
+
const name = (token) => token?.kind === "ident" ? token.text : token?.kind === "word" ? token.text.toLowerCase() : undefined;
|
|
275
|
+
const clauses = ["SELECT"];
|
|
276
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
277
|
+
const token = tokens[i];
|
|
278
|
+
const next = tokens[i + 1];
|
|
279
|
+
if (token.kind === "punct" && token.text === "(")
|
|
280
|
+
clauses.push("");
|
|
281
|
+
if (token.kind === "punct" && token.text === ")") {
|
|
282
|
+
clauses.pop();
|
|
283
|
+
if (clauses.length === 0)
|
|
284
|
+
return "its parentheses do not balance";
|
|
285
|
+
}
|
|
286
|
+
// `FROM x` also appears inside some function calls (EXTRACT, SUBSTRING, TRIM): only clause-level FROMs,
|
|
287
|
+
// after a SELECT at the same depth, name tables. Anything else is refused.
|
|
288
|
+
const clause = clauses[clauses.length - 1];
|
|
289
|
+
// A quoted name before `(` is a function call this check cannot read the way Postgres resolves it.
|
|
290
|
+
if (token.kind === "ident" && next?.kind === "punct" && next.text === "(") {
|
|
291
|
+
return `it calls a function by a quoted name ("${token.text}")`;
|
|
292
|
+
}
|
|
293
|
+
if (token.kind === "word") {
|
|
294
|
+
if (DENIED_KEYWORDS.has(token.upper))
|
|
295
|
+
return `it uses ${token.upper}`;
|
|
296
|
+
if (next?.kind === "punct" && next.text === "(" && DENIED_FUNCTION.test(token.text)) {
|
|
297
|
+
return `it calls ${token.text}()`;
|
|
298
|
+
}
|
|
299
|
+
if (token.upper === "FROM" && clause === "")
|
|
300
|
+
return "it uses FROM outside a SELECT (for example inside a function call)";
|
|
301
|
+
if (CLAUSES.has(token.upper))
|
|
302
|
+
clauses[clauses.length - 1] = token.upper;
|
|
303
|
+
}
|
|
304
|
+
if (token.kind === "punct" && token.text === "." && next !== undefined) {
|
|
305
|
+
const after = tokens[i + 2];
|
|
306
|
+
if (after?.kind === "punct" && after.text === "(")
|
|
307
|
+
return `it calls a schema-qualified function (${name(next)})`;
|
|
308
|
+
}
|
|
309
|
+
const startsFromItem = (token.kind === "word" && (token.upper === "FROM" || token.upper === "JOIN")) ||
|
|
310
|
+
(token.kind === "punct" && token.text === "," && clauses[clauses.length - 1] === "FROM");
|
|
311
|
+
if (!startsFromItem)
|
|
312
|
+
continue;
|
|
313
|
+
let j = i + 1;
|
|
314
|
+
while (tokens[j]?.kind === "word" && ["ONLY", "LATERAL"].includes(tokens[j].upper))
|
|
315
|
+
j++;
|
|
316
|
+
const item = tokens[j];
|
|
317
|
+
if (item?.kind === "punct" && item.text === "(") {
|
|
318
|
+
const inner = tokens[j + 1];
|
|
319
|
+
if (inner?.kind !== "word" || (inner.upper !== "SELECT" && inner.upper !== "VALUES")) {
|
|
320
|
+
return "it uses a parenthesised from-item that is not a subquery";
|
|
321
|
+
}
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
const dot = tokens[j + 1];
|
|
325
|
+
const table = tokens[j + 2];
|
|
326
|
+
if (name(item) === undefined || dot?.kind !== "punct" || dot.text !== "." || name(table) === undefined) {
|
|
327
|
+
return `it reads a table not qualified by the module's schema (${name(item) ?? "?"})`;
|
|
328
|
+
}
|
|
329
|
+
if (name(item) !== schema)
|
|
330
|
+
return `it reads ${name(item)}.${name(table)}, outside the module's schema ${schema}`;
|
|
331
|
+
const call = tokens[j + 3];
|
|
332
|
+
if (call?.kind === "punct" && call.text === "(")
|
|
333
|
+
return "it reads from a function";
|
|
334
|
+
}
|
|
335
|
+
if (clauses.length !== 1)
|
|
336
|
+
return "its parentheses do not balance";
|
|
337
|
+
return undefined;
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* The names of the entities an action declares it acts on: `writes`, `target` and `actsOn`, without
|
|
341
|
+
* duplicates. Its policy grants access to these entities' tables and to no other.
|
|
342
|
+
*/
|
|
343
|
+
export const declaredEntityNames = (action) => [
|
|
344
|
+
...new Set([action.writes, action.target?.entity, ...(action.actsOn ?? [])].filter((n) => n !== undefined)),
|
|
345
|
+
];
|
|
346
|
+
// ---------------------------------------------------------------------------
|
|
347
|
+
// Checking the declarations of an app's modules together
|
|
348
|
+
const LOCAL_ID = /^[a-z][a-zA-Z0-9_-]*(\.[a-z][a-zA-Z0-9_-]*)*$/;
|
|
349
|
+
const ROUTE = /^\/([A-Za-z0-9_$-]+(\/[A-Za-z0-9_$-]+)*)?$/;
|
|
350
|
+
const entries = (record) => Object.entries(record ?? {});
|
|
351
|
+
const isJson = (value) => {
|
|
352
|
+
try {
|
|
353
|
+
return JSON.stringify(JSON.parse(JSON.stringify(value))) === JSON.stringify(value);
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
const fieldsOf = (entity) => new Set(Object.keys(entity.columns));
|
|
360
|
+
/** A media type an entity accepts: `type/subtype` or `type/*`. */
|
|
361
|
+
/** The kernel's own Cedar actions on entities: no module action may take their names. */
|
|
362
|
+
export const KERNEL_ENTITY_ACTIONS = new Set(["read", "share", "attach", "collaborate"]);
|
|
363
|
+
/** The CollabDocument contract's limits: the defaults, and the most an entity may declare. */
|
|
364
|
+
export const COLLAB_LIMITS = {
|
|
365
|
+
maxBytes: 2 * 1024 * 1024,
|
|
366
|
+
maxBytesCeiling: 16 * 1024 * 1024,
|
|
367
|
+
maxUpdateBytes: 256 * 1024,
|
|
368
|
+
updatesPerMinute: 1200,
|
|
369
|
+
/** The rate window keeps each update's time for a minute: bounded, so its row stays small. */
|
|
370
|
+
updatesPerMinuteCeiling: 6000,
|
|
371
|
+
text: "content",
|
|
372
|
+
};
|
|
373
|
+
/** An entity's collaborative document's limits, with the defaults filled in. */
|
|
374
|
+
export const collabLimits = (collab) => ({
|
|
375
|
+
maxBytes: collab.maxBytes ?? COLLAB_LIMITS.maxBytes,
|
|
376
|
+
maxUpdateBytes: collab.maxUpdateBytes ?? Math.min(COLLAB_LIMITS.maxUpdateBytes, collab.maxBytes ?? Infinity),
|
|
377
|
+
updatesPerMinute: collab.updatesPerMinute ?? COLLAB_LIMITS.updatesPerMinute,
|
|
378
|
+
text: collab.text ?? COLLAB_LIMITS.text,
|
|
379
|
+
});
|
|
380
|
+
const isPositiveInteger = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
381
|
+
/** What is wrong with an entity's `collab` declaration. */
|
|
382
|
+
export const collabProblems = (entity, collab) => {
|
|
383
|
+
const problems = [];
|
|
384
|
+
const limits = collabLimits(collab);
|
|
385
|
+
if (collab.maxBytes !== undefined &&
|
|
386
|
+
!(isPositiveInteger(collab.maxBytes) && collab.maxBytes <= COLLAB_LIMITS.maxBytesCeiling)) {
|
|
387
|
+
problems.push(`entity ${entity} lets its collaborative document grow to ${collab.maxBytes} bytes (a positive integer, at most ${COLLAB_LIMITS.maxBytesCeiling})`);
|
|
388
|
+
}
|
|
389
|
+
if (collab.maxUpdateBytes !== undefined &&
|
|
390
|
+
!(isPositiveInteger(collab.maxUpdateBytes) && collab.maxUpdateBytes <= limits.maxBytes)) {
|
|
391
|
+
problems.push(`entity ${entity} accepts collaborative updates of ${collab.maxUpdateBytes} bytes (a positive integer, at most its maxBytes)`);
|
|
392
|
+
}
|
|
393
|
+
if (collab.updatesPerMinute !== undefined &&
|
|
394
|
+
!(isPositiveInteger(collab.updatesPerMinute) && collab.updatesPerMinute <= COLLAB_LIMITS.updatesPerMinuteCeiling)) {
|
|
395
|
+
problems.push(`entity ${entity} accepts ${collab.updatesPerMinute} collaborative updates a minute (a positive integer, at most ${COLLAB_LIMITS.updatesPerMinuteCeiling})`);
|
|
396
|
+
}
|
|
397
|
+
if (collab.text !== undefined && !/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/u.test(collab.text)) {
|
|
398
|
+
problems.push(`entity ${entity} names ${collab.text} as its collaborative text (letters, digits, _ and -)`);
|
|
399
|
+
}
|
|
400
|
+
return problems;
|
|
401
|
+
};
|
|
402
|
+
export const MEDIA_TYPE_PATTERN = /^[a-z0-9][a-z0-9!#$&^_.+-]*\/(?:\*|[a-z0-9][a-z0-9!#$&^_.+-]*)$/u;
|
|
403
|
+
/**
|
|
404
|
+
* Why `name` cannot name a module, if it cannot. A module's name becomes its database roles
|
|
405
|
+
* (`eloxiv_mod_<name>`, `eloxiv_own_<name>`) and its default schema, so it is a plain lower-case identifier that
|
|
406
|
+
* leaves those roles within PostgreSQL's 63 bytes (52 characters at most), and it is not the kernel's (`eloxiv`,
|
|
407
|
+
* `eloxiv_*`) or PostgreSQL's (`pg_*`).
|
|
408
|
+
*/
|
|
409
|
+
export const moduleNameProblem = (name) => {
|
|
410
|
+
if (!/^[a-z][a-z0-9_]*$/.test(name))
|
|
411
|
+
return "must be lower-case letters, digits and '_', starting with a letter";
|
|
412
|
+
if (name.length > 52)
|
|
413
|
+
return "must be at most 52 characters (its roles' names are limited to 63)";
|
|
414
|
+
if (name === "eloxiv" || name.startsWith("eloxiv_") || name.startsWith("pg_")) {
|
|
415
|
+
return "is reserved (eloxiv, eloxiv_* and pg_* belong to the kernel and PostgreSQL)";
|
|
416
|
+
}
|
|
417
|
+
return undefined;
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* Every problem with the manifests of `modules` taken together, as readable
|
|
421
|
+
* sentences naming the module and the declaration. Empty when the app is valid.
|
|
422
|
+
*/
|
|
423
|
+
export const manifestProblems = (modules) => {
|
|
424
|
+
const problems = [];
|
|
425
|
+
const seen = (kind, map, key, owner) => {
|
|
426
|
+
const previous = map.get(key);
|
|
427
|
+
if (previous !== undefined)
|
|
428
|
+
problems.push(`${owner}: ${kind} ${key} is also declared by ${previous}`);
|
|
429
|
+
else
|
|
430
|
+
map.set(key, owner);
|
|
431
|
+
};
|
|
432
|
+
// Global names: modules, Cedar namespaces, entity types, tables, actions, view routes.
|
|
433
|
+
const moduleNames = new Map();
|
|
434
|
+
const namespaces = new Map();
|
|
435
|
+
const cedarTypes = new Map();
|
|
436
|
+
const tables = new Map();
|
|
437
|
+
const actionNames = new Map();
|
|
438
|
+
const actionsByName = new Map();
|
|
439
|
+
const routes = new Map();
|
|
440
|
+
const views = new Map();
|
|
441
|
+
const commands = new Map();
|
|
442
|
+
const slots = new Map();
|
|
443
|
+
const surfaceRelations = new Map();
|
|
444
|
+
for (const module of modules) {
|
|
445
|
+
const nameProblem = moduleNameProblem(module.name);
|
|
446
|
+
if (nameProblem !== undefined)
|
|
447
|
+
problems.push(`${module.name}: module name ${nameProblem}`);
|
|
448
|
+
seen("module", moduleNames, module.name, module.name);
|
|
449
|
+
// The kernel records its own migrations, snapshot and audit names under `eloxiv`.
|
|
450
|
+
if (module.name === "eloxiv")
|
|
451
|
+
problems.push(`eloxiv: the module name eloxiv is the kernel's own`);
|
|
452
|
+
seen("Cedar namespace", namespaces, module.cedarNamespace, module.name);
|
|
453
|
+
for (const entity of Object.values(module.entities)) {
|
|
454
|
+
seen("entity type", cedarTypes, entity.cedarType, module.name);
|
|
455
|
+
seen("table", tables, `${entity.table.schema}.${entity.table.name}`, module.name);
|
|
456
|
+
}
|
|
457
|
+
for (const action of Object.values(module.actions)) {
|
|
458
|
+
seen("action", actionNames, action.name, module.name);
|
|
459
|
+
actionsByName.set(action.name, action);
|
|
460
|
+
}
|
|
461
|
+
for (const [id, view] of entries(module.views)) {
|
|
462
|
+
views.set(id, view);
|
|
463
|
+
seen("view route", routes, view.route, module.name);
|
|
464
|
+
}
|
|
465
|
+
for (const [id, command] of entries(module.commands))
|
|
466
|
+
commands.set(id, command);
|
|
467
|
+
for (const [id, slot] of entries(module.slots))
|
|
468
|
+
slots.set(id, slot);
|
|
469
|
+
for (const id of Object.keys(module.queryViews ?? {})) {
|
|
470
|
+
const relation = queryRelationName(id);
|
|
471
|
+
seen("query surface relation", surfaceRelations, relation, module.name);
|
|
472
|
+
if (relation.startsWith("pg_")) {
|
|
473
|
+
problems.push(`${module.name}: query view ${id} would be named ${relation} on the query surface, beside the catalog's names`);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
for (const module of modules) {
|
|
478
|
+
const m = module.name;
|
|
479
|
+
const problem = (text) => problems.push(`${m}: ${text}`);
|
|
480
|
+
const entities = module.entities;
|
|
481
|
+
const actions = Object.values(module.actions);
|
|
482
|
+
const ownQueryViews = module.queryViews ?? {};
|
|
483
|
+
const ids = (kind, record) => {
|
|
484
|
+
for (const id of Object.keys(record ?? {})) {
|
|
485
|
+
if (!id.startsWith(`${m}.`) || !LOCAL_ID.test(id.slice(m.length + 1))) {
|
|
486
|
+
problem(`${kind} id ${id} must be namespaced by its module (${m}.<name>, lower camel or kebab case)`);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
ids("permission", module.permissions);
|
|
491
|
+
ids("setting", module.settings);
|
|
492
|
+
ids("flag", module.flags);
|
|
493
|
+
ids("skill", module.skills);
|
|
494
|
+
ids("view", module.views);
|
|
495
|
+
ids("slot", module.slots);
|
|
496
|
+
ids("contribution", module.contributions);
|
|
497
|
+
ids("command", module.commands);
|
|
498
|
+
ids("work-item source", module.workItemSources);
|
|
499
|
+
ids("query view", module.queryViews);
|
|
500
|
+
ids("approval rule", module.approvalRules);
|
|
501
|
+
ids("tool group", module.toolGroups);
|
|
502
|
+
for (const [id, group] of entries(module.toolGroups)) {
|
|
503
|
+
if (group.description.trim() === "")
|
|
504
|
+
problem(`tool group ${id} has no description`);
|
|
505
|
+
if (group.actions.length === 0)
|
|
506
|
+
problem(`tool group ${id} names no actions`);
|
|
507
|
+
for (const action of group.actions) {
|
|
508
|
+
if (!actions.some((a) => a.name === action))
|
|
509
|
+
problem(`tool group ${id} names unknown action ${action}`);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
ids("analytics event", module.analyticsEvents);
|
|
513
|
+
for (const [id, declaration] of entries(module.analyticsEvents)) {
|
|
514
|
+
for (const why of analyticsEventProblems(id, declaration))
|
|
515
|
+
problem(why);
|
|
516
|
+
}
|
|
517
|
+
for (const [id, rule] of entries(module.approvalRules)) {
|
|
518
|
+
for (const shape of approvalRuleShapeProblems(rule))
|
|
519
|
+
problem(`approval rule ${id} ${shape}`);
|
|
520
|
+
if (Schema.is(ApprovalRule)(rule) && !actionsByName.has(rule.action)) {
|
|
521
|
+
problem(`approval rule ${id} applies to unknown action ${rule.action}`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
for (const entity of Object.values(entities)) {
|
|
525
|
+
if (!entity.cedarType.startsWith(`${module.cedarNamespace}::`)) {
|
|
526
|
+
problem(`entity ${entity.name} has Cedar type ${entity.cedarType}, outside namespace ${module.cedarNamespace}`);
|
|
527
|
+
}
|
|
528
|
+
// A grant is made in, and counts only in, its record's organisation: a shareable record must name one.
|
|
529
|
+
const attributes = Object.values(entity.policyAttributes);
|
|
530
|
+
const orgs = attributes.filter((a) => a.kind === "column" && a.type === "Entity" && a.entityType === "Eloxiv::Org");
|
|
531
|
+
if (attributes.some((a) => a.kind === "sharing") && orgs.length !== 1) {
|
|
532
|
+
problem(`entity ${entity.name} has sharing attributes, so it needs exactly one organisation attribute (an Eloxiv::Org column)`);
|
|
533
|
+
}
|
|
534
|
+
// Search's index and files are kept per organisation, read from the record.
|
|
535
|
+
for (const kind of ["search", "files", "collab"]) {
|
|
536
|
+
if (entity[kind] !== undefined && orgs.length !== 1) {
|
|
537
|
+
problem(`entity ${entity.name} declares ${kind}, so it needs exactly one organisation attribute (an Eloxiv::Org column)`);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if (entity.search !== undefined) {
|
|
541
|
+
const search = entity.search;
|
|
542
|
+
const fields = Object.entries(search.fields ?? {});
|
|
543
|
+
if (fields.length === 0)
|
|
544
|
+
problem(`entity ${entity.name} declares search over no fields`);
|
|
545
|
+
for (const [field, weight] of fields) {
|
|
546
|
+
if (!fieldsOf(entity).has(field))
|
|
547
|
+
problem(`entity ${entity.name} searches unknown field ${field}`);
|
|
548
|
+
if (!["A", "B", "C", "D"].includes(weight)) {
|
|
549
|
+
problem(`entity ${entity.name} gives search field ${field} weight ${weight} (A, B, C or D)`);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
if (search.title !== undefined && !(search.title in (search.fields ?? {}))) {
|
|
553
|
+
problem(`entity ${entity.name} shows ${search.title} as its search title, which it does not search`);
|
|
554
|
+
}
|
|
555
|
+
if (search.language !== undefined && !SEARCH_LANGUAGES.includes(search.language)) {
|
|
556
|
+
problem(`entity ${entity.name} searches in unknown language ${search.language} (${SEARCH_LANGUAGES.join(", ")})`);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
if (entity.collab !== undefined) {
|
|
560
|
+
for (const problemText of collabProblems(entity.name, entity.collab))
|
|
561
|
+
problem(problemText);
|
|
562
|
+
}
|
|
563
|
+
if (entity.files !== undefined) {
|
|
564
|
+
const files = entity.files;
|
|
565
|
+
if (files.maxBytes !== undefined && !(Number.isSafeInteger(files.maxBytes) && files.maxBytes > 0)) {
|
|
566
|
+
problem(`entity ${entity.name} accepts files of at most ${files.maxBytes} bytes (a positive integer)`);
|
|
567
|
+
}
|
|
568
|
+
for (const type of files.types ?? []) {
|
|
569
|
+
if (!MEDIA_TYPE_PATTERN.test(type)) {
|
|
570
|
+
problem(`entity ${entity.name} accepts files of type ${type}, which is not type/subtype or type/*`);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
// The action contract: what each action may change.
|
|
576
|
+
for (const action of actions) {
|
|
577
|
+
// `read`, `share`, `attach` and `collaborate` are the kernel's own Cedar actions on entities (reading; sharing
|
|
578
|
+
// and its grants; attaching files; changing a record's collaborative document).
|
|
579
|
+
if (KERNEL_ENTITY_ACTIONS.has(action.cedarAction)) {
|
|
580
|
+
problem(`${action.name}: the Cedar action ${action.cedarAction} is reserved for the kernel`);
|
|
581
|
+
}
|
|
582
|
+
if (action.writes !== undefined && !(action.writes in entities)) {
|
|
583
|
+
problem(`${action.name} writes unknown entity ${action.writes}`);
|
|
584
|
+
}
|
|
585
|
+
const target = action.target;
|
|
586
|
+
if (target !== undefined && !(target.entity in entities)) {
|
|
587
|
+
problem(`${action.name} targets unknown entity ${target.entity}`);
|
|
588
|
+
}
|
|
589
|
+
for (const name of action.actsOn ?? []) {
|
|
590
|
+
if (!(name in entities))
|
|
591
|
+
problem(`${action.name} acts on unknown entity ${name}`);
|
|
592
|
+
}
|
|
593
|
+
if (action.organisationWide && declaredEntityNames(action).length === 0) {
|
|
594
|
+
problem(`${action.name} is organisation-wide, so it must declare an entity (writes, target or actsOn)`);
|
|
595
|
+
}
|
|
596
|
+
if (action.bestEffort) {
|
|
597
|
+
// Best effort is declared, never inferred: it needs targets to count and an output to report them in.
|
|
598
|
+
const fields = action.output.fields ?? {};
|
|
599
|
+
const missing = Object.keys(BestEffortFields).filter((k) => !(k in fields));
|
|
600
|
+
if (target === undefined || missing.length > 0) {
|
|
601
|
+
problem(`${action.name} is best effort, so it needs a target and an output with ${Object.keys(BestEffortFields).join(", ")}`);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (action.reportsWritten) {
|
|
605
|
+
// What an untargeted write did: it needs no target (a targeted one reports its completion) and an output to
|
|
606
|
+
// report it in.
|
|
607
|
+
const fields = action.output.fields ?? {};
|
|
608
|
+
if (target !== undefined || action.writes === undefined || !("written" in fields)) {
|
|
609
|
+
problem(`${action.name} reports what it wrote, so it needs writes, no target and an output with written`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
for (const text of optimisticProblems(action, entities))
|
|
613
|
+
problem(text);
|
|
614
|
+
}
|
|
615
|
+
// Jobs (the Scheduler contract): the action they invoke, with their input, on their schedule.
|
|
616
|
+
for (const [id, job] of entries(module.jobs)) {
|
|
617
|
+
const where = `job ${m}.${id}`;
|
|
618
|
+
if (job.description.trim() === "")
|
|
619
|
+
problem(`${where} has no description`);
|
|
620
|
+
if (!Schema.is(ScheduleSpec)(job.schedule))
|
|
621
|
+
problem(`${where} has a schedule that is neither cron nor interval`);
|
|
622
|
+
if (job.catchUp !== undefined && !Schema.is(CatchUp)(job.catchUp)) {
|
|
623
|
+
problem(`${where} has unknown catch-up policy ${String(job.catchUp)}`);
|
|
624
|
+
}
|
|
625
|
+
if (job.identity !== "system")
|
|
626
|
+
problem(`${where} has unknown identity ${String(job.identity)}`);
|
|
627
|
+
const action = actionsByName.get(job.action);
|
|
628
|
+
if (action === undefined)
|
|
629
|
+
problem(`${where} invokes unknown action ${job.action}`);
|
|
630
|
+
else if (!isJson(job.input))
|
|
631
|
+
problem(`${where} has input that is not JSON`);
|
|
632
|
+
else {
|
|
633
|
+
// A job whose input its action would refuse fails at startup, not at its first run.
|
|
634
|
+
const decoded = Schema.decodeUnknownExit(action.input)(job.input);
|
|
635
|
+
if (Exit.isFailure(decoded))
|
|
636
|
+
problem(`${where} has input that ${job.action} refuses`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
for (const [id, permission] of entries(module.permissions)) {
|
|
640
|
+
if (permission.description.trim() === "")
|
|
641
|
+
problem(`permission ${id} has no description`);
|
|
642
|
+
if (permission.actions.length === 0)
|
|
643
|
+
problem(`permission ${id} names no actions`);
|
|
644
|
+
for (const action of permission.actions) {
|
|
645
|
+
if (!KERNEL_ENTITY_ACTIONS.has(action) && !actions.some((a) => a.name === action)) {
|
|
646
|
+
problem(`permission ${id} names unknown action ${action} (an action of ${m}, read or share)`);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
for (const [id, setting] of entries(module.settings)) {
|
|
651
|
+
if (!Schema.is(SettingScope)(setting.scope))
|
|
652
|
+
problem(`setting ${id} has unknown scope ${String(setting.scope)}`);
|
|
653
|
+
if (!isJson(setting.default))
|
|
654
|
+
problem(`setting ${id} has a default that is not JSON`);
|
|
655
|
+
else {
|
|
656
|
+
const decoded = Schema.decodeUnknownExit(setting.schema)(setting.default);
|
|
657
|
+
if (Exit.isFailure(decoded))
|
|
658
|
+
problem(`setting ${id} has a default that does not decode against its schema`);
|
|
659
|
+
}
|
|
660
|
+
if (isSensitiveSchema(setting.schema)) {
|
|
661
|
+
problem(`setting ${id} is marked sensitive: secrets never go in settings (use the Secrets contract)`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
for (const [id, flag] of entries(module.flags)) {
|
|
665
|
+
if (typeof flag.description !== "string" || flag.description.trim() === "")
|
|
666
|
+
problem(`flag ${id} has no description`);
|
|
667
|
+
if (typeof flag.default !== "boolean")
|
|
668
|
+
problem(`flag ${id} has a default that is not a boolean`);
|
|
669
|
+
}
|
|
670
|
+
for (const [id, skill] of entries(module.skills)) {
|
|
671
|
+
if (skill.description.trim() === "")
|
|
672
|
+
problem(`skill ${id} has no description`);
|
|
673
|
+
const content = skill.content;
|
|
674
|
+
if ((content.path === undefined) === (content.text === undefined)) {
|
|
675
|
+
problem(`skill ${id} must give its content as exactly one of path or text`);
|
|
676
|
+
}
|
|
677
|
+
else if (content.path !== undefined) {
|
|
678
|
+
const path = content.path;
|
|
679
|
+
if (path === "" || path.startsWith("/") || path.includes("\\") || path.split("/").includes("..")) {
|
|
680
|
+
problem(`skill ${id} has path ${path}, which must stay inside the module's directory`);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
else if (String(content.text).trim() === "")
|
|
684
|
+
problem(`skill ${id} has empty text`);
|
|
685
|
+
const audience = skill.audience;
|
|
686
|
+
if (audience !== undefined && !SKILL_AUDIENCES.includes(audience)) {
|
|
687
|
+
problem(`skill ${id} has audience ${JSON.stringify(audience)}, which is not one of ${SKILL_AUDIENCES.join(", ")}`);
|
|
688
|
+
}
|
|
689
|
+
const evals = skill.evals;
|
|
690
|
+
if (evals !== undefined) {
|
|
691
|
+
const path = typeof evals.path === "string" ? evals.path : "";
|
|
692
|
+
if (path === "" || path.startsWith("/") || path.includes("\\") || path.split("/").includes("..")) {
|
|
693
|
+
problem(`skill ${id} has evals path ${path}, which must stay inside the module's directory`);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
for (const [id, view] of entries(module.views)) {
|
|
698
|
+
if (!ROUTE.test(view.route))
|
|
699
|
+
problem(`view ${id} has route ${view.route}, which is not a shell route (/a/b)`);
|
|
700
|
+
if (view.title.trim() === "")
|
|
701
|
+
problem(`view ${id} has no title`);
|
|
702
|
+
const shows = view.shows;
|
|
703
|
+
if ((shows.entity === undefined) === (shows.queryView === undefined)) {
|
|
704
|
+
problem(`view ${id} must show exactly one entity or query view`);
|
|
705
|
+
}
|
|
706
|
+
else if (shows.entity !== undefined && !(shows.entity in entities)) {
|
|
707
|
+
problem(`view ${id} shows unknown entity ${shows.entity}`);
|
|
708
|
+
}
|
|
709
|
+
else if (shows.queryView !== undefined && !(shows.queryView in ownQueryViews)) {
|
|
710
|
+
problem(`view ${id} shows unknown query view ${shows.queryView}`);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
for (const [id, slot] of entries(module.slots)) {
|
|
714
|
+
if (slot.accepts !== "view" && slot.accepts !== "command")
|
|
715
|
+
problem(`slot ${id} accepts unknown kind`);
|
|
716
|
+
}
|
|
717
|
+
for (const [id, contribution] of entries(module.contributions)) {
|
|
718
|
+
const slot = slots.get(contribution.slot);
|
|
719
|
+
const target = contribution;
|
|
720
|
+
if (slot === undefined)
|
|
721
|
+
problem(`contribution ${id} contributes to slot ${contribution.slot}, which does not exist`);
|
|
722
|
+
if ((target.view === undefined) === (target.command === undefined)) {
|
|
723
|
+
problem(`contribution ${id} must contribute exactly one view or command`);
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
if (target.view !== undefined && !views.has(target.view)) {
|
|
727
|
+
problem(`contribution ${id} contributes unknown view ${target.view}`);
|
|
728
|
+
}
|
|
729
|
+
if (target.command !== undefined && !commands.has(target.command)) {
|
|
730
|
+
problem(`contribution ${id} contributes unknown command ${target.command}`);
|
|
731
|
+
}
|
|
732
|
+
const kind = target.view !== undefined ? "view" : "command";
|
|
733
|
+
if (slot !== undefined && slot.accepts !== kind) {
|
|
734
|
+
problem(`contribution ${id} contributes a ${kind} to slot ${contribution.slot}, which accepts ${slot.accepts}s`);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
for (const [id, command] of entries(module.commands)) {
|
|
738
|
+
if (command.title.trim() === "")
|
|
739
|
+
problem(`command ${id} has no title`);
|
|
740
|
+
const run = command.run;
|
|
741
|
+
if ((run.action === undefined) === (run.view === undefined)) {
|
|
742
|
+
problem(`command ${id} must run exactly one action or view`);
|
|
743
|
+
}
|
|
744
|
+
else if (run.action !== undefined && !actionNames.has(run.action)) {
|
|
745
|
+
problem(`command ${id} runs unknown action ${run.action}`);
|
|
746
|
+
}
|
|
747
|
+
else if (run.view !== undefined && !views.has(run.view)) {
|
|
748
|
+
problem(`command ${id} opens unknown view ${run.view}`);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
const needsField = (what, entity, field) => {
|
|
752
|
+
if (!fieldsOf(entity).has(field))
|
|
753
|
+
problem(`${what} names unknown field ${field} of ${entity.name}`);
|
|
754
|
+
};
|
|
755
|
+
for (const [id, source] of entries(module.workItemSources)) {
|
|
756
|
+
if (source.description.trim() === "")
|
|
757
|
+
problem(`work-item source ${id} has no description`);
|
|
758
|
+
const entity = entities[source.entity];
|
|
759
|
+
if (entity === undefined)
|
|
760
|
+
problem(`work-item source ${id} reads unknown entity ${source.entity}`);
|
|
761
|
+
else {
|
|
762
|
+
needsField(`work-item source ${id}`, entity, source.title);
|
|
763
|
+
if (source.assignee !== null)
|
|
764
|
+
needsField(`work-item source ${id}`, entity, source.assignee);
|
|
765
|
+
const state = source.state;
|
|
766
|
+
if (state.field !== undefined) {
|
|
767
|
+
needsField(`work-item source ${id}`, entity, state.field);
|
|
768
|
+
const values = Object.values(state.values ?? {});
|
|
769
|
+
if (values.length === 0)
|
|
770
|
+
problem(`work-item source ${id} maps no state values`);
|
|
771
|
+
for (const value of values) {
|
|
772
|
+
if (!Schema.is(WorkItemState)(value))
|
|
773
|
+
problem(`work-item source ${id} maps to unknown state ${String(value)}`);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
else if (!Schema.is(WorkItemState)(state.constant)) {
|
|
777
|
+
problem(`work-item source ${id} has unknown state ${String(state.constant)}`);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
if (!views.has(source.link.view))
|
|
781
|
+
problem(`work-item source ${id} links to unknown view ${source.link.view}`);
|
|
782
|
+
}
|
|
783
|
+
for (const [name, resolver] of entries(module.entityResolvers)) {
|
|
784
|
+
const entity = entities[name];
|
|
785
|
+
if (entity === undefined) {
|
|
786
|
+
problem(`entity resolver ${name} resolves unknown entity ${name}`);
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
789
|
+
needsField(`entity resolver ${name}`, entity, resolver.title);
|
|
790
|
+
if (resolver.link !== undefined && !views.has(resolver.link.view)) {
|
|
791
|
+
problem(`entity resolver ${name} links to unknown view ${resolver.link.view}`);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
for (const [id, view] of entries(module.queryViews)) {
|
|
795
|
+
const local = id.slice(m.length + 1);
|
|
796
|
+
if (!/^[a-z][a-z0-9_]*$/.test(local))
|
|
797
|
+
problem(`query view ${id} needs a lower snake case name after ${m}.`);
|
|
798
|
+
const entity = entities[view.entity];
|
|
799
|
+
if (entity === undefined) {
|
|
800
|
+
problem(`query view ${id} is filtered by unknown entity ${view.entity}`);
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
const why = plainSelectProblem(view.sql, entity.table.schema);
|
|
804
|
+
if (why !== undefined) {
|
|
805
|
+
problem(`query view ${id} is not a plain SELECT over schema ${entity.table.schema}: ${why}`);
|
|
806
|
+
}
|
|
807
|
+
const fields = view.row.fields;
|
|
808
|
+
if (fields === undefined)
|
|
809
|
+
problem(`query view ${id} must describe its row as a struct`);
|
|
810
|
+
else {
|
|
811
|
+
const pk = entity.columns[entity.primaryKey];
|
|
812
|
+
if (!(pk in fields)) {
|
|
813
|
+
problem(`query view ${id} must return ${entity.name}'s primary key column ${pk}, so its policy can filter rows`);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
if (view.render !== undefined) {
|
|
817
|
+
for (const why of renderProblems(view.render, Schema.Array(view.row)))
|
|
818
|
+
problem(`query view ${id}'s renderer ${why}`);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
// Renderers (the ResultRendering contract) must fit the output they render.
|
|
822
|
+
for (const action of actions) {
|
|
823
|
+
if (action.render === undefined)
|
|
824
|
+
continue;
|
|
825
|
+
for (const why of renderProblems(action.render, action.output))
|
|
826
|
+
problem(`${action.name}'s renderer ${why}`);
|
|
827
|
+
}
|
|
828
|
+
// The kernel versions the module works with (the Versioning contract).
|
|
829
|
+
if (module.kernel !== undefined && satisfiesRange("0.0.0", module.kernel) === undefined) {
|
|
830
|
+
problem(`kernel range ${module.kernel} cannot be read (use comparators such as >=1.0.0 <2.0.0, ^1.2.0 or ~1.2.0)`);
|
|
831
|
+
}
|
|
832
|
+
// Setup compares versions to refuse downgrades: they must be numbers separated by dots.
|
|
833
|
+
if (!/^v?\d+(?:\.\d+)*(?:-[0-9A-Za-z.-]+)?$/.test(module.version)) {
|
|
834
|
+
problem(`version ${module.version} is not a version (numbers separated by dots, such as 1.2.0)`);
|
|
835
|
+
}
|
|
836
|
+
// Data subjects (the Privacy contract): declared entities and fields, a declared erasure.
|
|
837
|
+
for (const [name, entry] of entries(module.dataSubjects)) {
|
|
838
|
+
const entity = entities[name];
|
|
839
|
+
if (entity === undefined) {
|
|
840
|
+
problem(`dataSubjects ${name} names unknown entity ${name}`);
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
if (isNoDataSubjects(entry)) {
|
|
844
|
+
if (typeof entry.none !== "string" || entry.none.trim() === "")
|
|
845
|
+
problem(`dataSubjects ${name} says it is about nobody without a reason`);
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
const declaration = entry;
|
|
849
|
+
if (declaration.fields.length === 0)
|
|
850
|
+
problem(`dataSubjects ${name} names no fields`);
|
|
851
|
+
const exported = declaration.export;
|
|
852
|
+
if (exported !== undefined && exported !== false) {
|
|
853
|
+
for (const field of exported.fields) {
|
|
854
|
+
if (!declaration.fields.includes(field))
|
|
855
|
+
problem(`dataSubjects ${name} exports by ${field}, not one of its fields`);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
// Requests are made in an organisation: the kernel finds and erases the person's records there.
|
|
859
|
+
const orgAttributes = Object.values(entity.policyAttributes).filter((a) => a.kind === "column" && a.type === "Entity" && a.entityType === "Eloxiv::Org");
|
|
860
|
+
if (orgAttributes.length !== 1) {
|
|
861
|
+
problem(`dataSubjects ${name} needs exactly one organisation attribute (an Eloxiv::Org column) on ${name}`);
|
|
862
|
+
}
|
|
863
|
+
for (const field of declaration.fields)
|
|
864
|
+
needsField(`dataSubjects ${name}`, entity, field);
|
|
865
|
+
if (declaration.fields.includes(entity.primaryKey)) {
|
|
866
|
+
problem(`dataSubjects ${name}: the primary key ${entity.primaryKey} cannot hold a person's id (it never changes)`);
|
|
867
|
+
}
|
|
868
|
+
const erase = declaration.erase;
|
|
869
|
+
if (erase.kind === "anonymise") {
|
|
870
|
+
const set = (erase.set ?? {});
|
|
871
|
+
for (const field of Object.keys(set))
|
|
872
|
+
needsField(`dataSubjects ${name}`, entity, field);
|
|
873
|
+
if (entity.primaryKey in set)
|
|
874
|
+
problem(`dataSubjects ${name} cannot anonymise the primary key ${entity.primaryKey}`);
|
|
875
|
+
const left = declaration.fields.filter((f) => !(f in set));
|
|
876
|
+
if (left.length > 0)
|
|
877
|
+
problem(`dataSubjects ${name} anonymises but keeps the person's id in ${left.join(", ")}`);
|
|
878
|
+
for (const [field, value] of Object.entries(set)) {
|
|
879
|
+
if (!(value === null || ["string", "number", "boolean"].includes(typeof value))) {
|
|
880
|
+
problem(`dataSubjects ${name} sets ${field} to a value that is not a string, number, boolean or null`);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
else if (erase.kind === "retain") {
|
|
885
|
+
if (typeof erase.reason !== "string" || erase.reason.trim() === "")
|
|
886
|
+
problem(`dataSubjects ${name} retains records without a reason`);
|
|
887
|
+
}
|
|
888
|
+
else if (erase.kind !== "delete")
|
|
889
|
+
problem(`dataSubjects ${name} has unknown erasure ${String(erase.kind)}`);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
return problems;
|
|
893
|
+
};
|
|
894
|
+
//# sourceMappingURL=Manifest.js.map
|