@eloxiv/contracts 0.0.0-stage → 0.1.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 +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 +888 -0
- package/dist/contracts/LocalClient.d.ts.map +1 -0
- package/dist/contracts/LocalClient.js +429 -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 +1298 -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 +6657 -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 +620 -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
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifications: durable records per recipient (in-app, readable, markable, synced to the recipient's
|
|
3
|
+
* replica), delivered through channels (NotificationChannel) according to each person's preferences, with
|
|
4
|
+
* system email templates that organisations can override and preview. See docs/contracts/notifications.md.
|
|
5
|
+
*/
|
|
6
|
+
import { Schema } from "effect"
|
|
7
|
+
import { InvalidInput, InvocationError } from "../Errors.ts"
|
|
8
|
+
import { defineOperation, defineServiceContract } from "../Service.ts"
|
|
9
|
+
import { ChannelKind, DecisionKind, DecisionVerdict, DeliveryRecord } from "./NotificationChannel.ts"
|
|
10
|
+
import { EntityReference } from "./WorkItems.ts"
|
|
11
|
+
|
|
12
|
+
export const Notification = Schema.Struct({
|
|
13
|
+
id: Schema.String,
|
|
14
|
+
orgId: Schema.String,
|
|
15
|
+
recipientId: Schema.String,
|
|
16
|
+
/** What kind of notification it is (`approvals.requested`); preferences are per category. */
|
|
17
|
+
category: Schema.String,
|
|
18
|
+
title: Schema.String,
|
|
19
|
+
body: Schema.String,
|
|
20
|
+
link: Schema.NullOr(EntityReference),
|
|
21
|
+
createdAt: Schema.String,
|
|
22
|
+
readAt: Schema.NullOr(Schema.String),
|
|
23
|
+
dismissedAt: Schema.NullOr(Schema.String),
|
|
24
|
+
})
|
|
25
|
+
export type Notification = typeof Notification.Type
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A system email template. `{{name}}` is replaced by the variable `name` (HTML-escaped in `html`); a missing
|
|
29
|
+
* variable renders as the empty string. Templates are registered in code; organisations override subject,
|
|
30
|
+
* text and HTML per template.
|
|
31
|
+
*/
|
|
32
|
+
export const EmailTemplate = Schema.Struct({
|
|
33
|
+
id: Schema.String,
|
|
34
|
+
description: Schema.String,
|
|
35
|
+
subject: Schema.String,
|
|
36
|
+
text: Schema.String,
|
|
37
|
+
html: Schema.NullOr(Schema.String),
|
|
38
|
+
/** The variables the template uses, documented for overrides and previews. */
|
|
39
|
+
variables: Schema.Array(Schema.String),
|
|
40
|
+
})
|
|
41
|
+
export type EmailTemplate = typeof EmailTemplate.Type
|
|
42
|
+
|
|
43
|
+
export const RenderedEmail = Schema.Struct({
|
|
44
|
+
subject: Schema.String,
|
|
45
|
+
text: Schema.String,
|
|
46
|
+
html: Schema.NullOr(Schema.String),
|
|
47
|
+
/** Whether an organisation override was used. */
|
|
48
|
+
overridden: Schema.Boolean,
|
|
49
|
+
})
|
|
50
|
+
export type RenderedEmail = typeof RenderedEmail.Type
|
|
51
|
+
|
|
52
|
+
/** Render `{{name}}` placeholders; `escape` is applied to each value (for HTML). */
|
|
53
|
+
export const renderPlaceholders = (
|
|
54
|
+
template: string,
|
|
55
|
+
variables: Readonly<Record<string, unknown>>,
|
|
56
|
+
escape: (value: string) => string = (value) => value,
|
|
57
|
+
): string =>
|
|
58
|
+
template.replaceAll(/\{\{\s*([A-Za-z0-9_.-]+)\s*\}\}/g, (_, name: string) => {
|
|
59
|
+
const value = variables[name]
|
|
60
|
+
if (value === undefined || value === null) return ""
|
|
61
|
+
return escape(typeof value === "string" ? value : JSON.stringify(value))
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
export const escapeHtml = (value: string): string =>
|
|
65
|
+
value
|
|
66
|
+
.replaceAll("&", "&")
|
|
67
|
+
.replaceAll("<", "<")
|
|
68
|
+
.replaceAll(">", ">")
|
|
69
|
+
.replaceAll('"', """)
|
|
70
|
+
.replaceAll("'", "'")
|
|
71
|
+
|
|
72
|
+
export const SendNotification = Schema.Struct({
|
|
73
|
+
orgId: Schema.String,
|
|
74
|
+
recipients: Schema.Array(Schema.String),
|
|
75
|
+
category: Schema.String,
|
|
76
|
+
title: Schema.String,
|
|
77
|
+
body: Schema.String,
|
|
78
|
+
link: Schema.optionalKey(Schema.NullOr(EntityReference)),
|
|
79
|
+
/** The email to send through the email channel when the recipient's preferences include it. */
|
|
80
|
+
email: Schema.optionalKey(
|
|
81
|
+
Schema.Struct({ template: Schema.String, variables: Schema.Record(Schema.String, Schema.Unknown) }),
|
|
82
|
+
),
|
|
83
|
+
/**
|
|
84
|
+
* Makes the send idempotent: one notification per (key, recipient). Workflow steps pass a key derived from
|
|
85
|
+
* their execution, so a step that runs again after a crash does not notify twice.
|
|
86
|
+
*/
|
|
87
|
+
key: Schema.optionalKey(Schema.String),
|
|
88
|
+
})
|
|
89
|
+
export type SendNotification = typeof SendNotification.Type
|
|
90
|
+
|
|
91
|
+
export const NotificationId = Schema.Struct({ id: Schema.String })
|
|
92
|
+
|
|
93
|
+
/** `notifications.list`: the caller's own notifications in the organisation they act in, newest first. */
|
|
94
|
+
export const NotificationList = Schema.Struct({
|
|
95
|
+
unreadOnly: Schema.optionalKey(Schema.Boolean),
|
|
96
|
+
category: Schema.optionalKey(Schema.String),
|
|
97
|
+
limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 200 }))),
|
|
98
|
+
})
|
|
99
|
+
export const NotificationCount = Schema.Struct({ category: Schema.optionalKey(Schema.String) })
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* `notifications.notify`: a notification an agent or a person sends (to themselves; to other members of the
|
|
103
|
+
* organisation with `notifications.send`). Its category is `message` unless given; `email` also sends it as
|
|
104
|
+
* system email (the `notifications.message` template) to recipients whose preferences include email.
|
|
105
|
+
*/
|
|
106
|
+
export const NotifyRequest = Schema.Struct({
|
|
107
|
+
title: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(200)),
|
|
108
|
+
body: Schema.String.check(Schema.isMaxLength(4_000)),
|
|
109
|
+
recipients: Schema.optionalKey(Schema.Array(Schema.String).check(Schema.isMinLength(1), Schema.isMaxLength(50))),
|
|
110
|
+
category: Schema.optionalKey(Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(100))),
|
|
111
|
+
link: Schema.optionalKey(EntityReference),
|
|
112
|
+
email: Schema.optionalKey(Schema.Boolean),
|
|
113
|
+
})
|
|
114
|
+
/**
|
|
115
|
+
* `notifications.setPreference`: the channels a category reaches the person on, in the organisation they act in.
|
|
116
|
+
* With `add: true` the channels are added to the ones the person has now (email when they never chose), in one
|
|
117
|
+
* write, instead of replacing them: what a device's "turn on notifications" uses to add push.
|
|
118
|
+
*/
|
|
119
|
+
export const Preference = Schema.Struct({
|
|
120
|
+
category: Schema.String,
|
|
121
|
+
channels: Schema.Array(ChannelKind),
|
|
122
|
+
add: Schema.optionalKey(Schema.Boolean),
|
|
123
|
+
})
|
|
124
|
+
export type Preference = typeof Preference.Type
|
|
125
|
+
export const TemplateOverride = Schema.Struct({
|
|
126
|
+
template: Schema.String,
|
|
127
|
+
subject: Schema.String,
|
|
128
|
+
text: Schema.String,
|
|
129
|
+
html: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
/** A push provider an installation registers with. */
|
|
133
|
+
export const PushProvider = Schema.Literals(["apns", "fcm"])
|
|
134
|
+
export type PushProvider = typeof PushProvider.Type
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* `notifications.registerInstallation`: this app installation's native push token, registered by the signed-in
|
|
138
|
+
* person (their own session only). `installationId` is the app install's stable id (a UUID it keeps in secure
|
|
139
|
+
* storage); registering it again replaces the token (rotation). `appId` is the APNs topic (bundle id) or the
|
|
140
|
+
* Android package; `environment` is APNs only (default `production`, ignored for FCM).
|
|
141
|
+
*/
|
|
142
|
+
export const PushInstallationRegistration = Schema.Struct({
|
|
143
|
+
installationId: Schema.String.check(
|
|
144
|
+
Schema.isPattern(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/),
|
|
145
|
+
),
|
|
146
|
+
provider: PushProvider,
|
|
147
|
+
token: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(4_096)),
|
|
148
|
+
appId: Schema.String.check(Schema.isNonEmpty(), Schema.isMaxLength(255)),
|
|
149
|
+
environment: Schema.optionalKey(Schema.Literals(["production", "sandbox"])),
|
|
150
|
+
})
|
|
151
|
+
export type PushInstallationRegistration = typeof PushInstallationRegistration.Type
|
|
152
|
+
export const PushInstallationId = Schema.Struct({ installationId: Schema.String })
|
|
153
|
+
|
|
154
|
+
/** `POST /api/notifications/decide`: a push notification's decision token, and the verdict the person chose. */
|
|
155
|
+
export const DecideRequest = Schema.Struct({ token: Schema.String, verdict: DecisionVerdict })
|
|
156
|
+
export type DecideRequest = typeof DecideRequest.Type
|
|
157
|
+
|
|
158
|
+
/** A decision taken through a push notification's token (or the recorded one, `replayed`). */
|
|
159
|
+
export const DecideResult = Schema.Struct({
|
|
160
|
+
kind: DecisionKind,
|
|
161
|
+
requestId: Schema.String,
|
|
162
|
+
verdict: DecisionVerdict,
|
|
163
|
+
/** What the action returned: an approval's `pending`, `approved` or `rejected`; a consent's `approved` or `rejected`. */
|
|
164
|
+
status: Schema.String,
|
|
165
|
+
replayed: Schema.Boolean,
|
|
166
|
+
})
|
|
167
|
+
export type DecideResult = typeof DecideResult.Type
|
|
168
|
+
|
|
169
|
+
/** The decision token is unknown, malformed, does not offer the verdict, or its installation was signed out. */
|
|
170
|
+
export class InvalidDecision extends Schema.TaggedError<InvalidDecision>()("InvalidDecision", {
|
|
171
|
+
message: Schema.String,
|
|
172
|
+
}) {}
|
|
173
|
+
|
|
174
|
+
/** The decision token expired (24 hours, or the request's own expiry when sooner). */
|
|
175
|
+
export class DecisionExpired extends Schema.TaggedError<DecisionExpired>()("DecisionExpired", {
|
|
176
|
+
message: Schema.String,
|
|
177
|
+
}) {}
|
|
178
|
+
|
|
179
|
+
export class UnknownTemplate extends Schema.TaggedError<UnknownTemplate>()("UnknownTemplate", {
|
|
180
|
+
template: Schema.String,
|
|
181
|
+
}) {}
|
|
182
|
+
|
|
183
|
+
export const NotificationsContract = defineServiceContract({
|
|
184
|
+
name: "Notifications",
|
|
185
|
+
kind: "kernel",
|
|
186
|
+
version: "1.3.0",
|
|
187
|
+
description:
|
|
188
|
+
"Durable notifications per recipient: in-app records each person reads, marks and dismisses (synced to their replica), delivered through channels by category according to per-user preferences, with retries through the outbox and a delivery log. System email uses registered templates with variables, per-organisation overrides, preview, an unsubscribe link and suppression. Push goes to the app installations each person registers from their own session; approval and consent notifications carry a single-use decision token the person redeems from the notification.",
|
|
189
|
+
operations: {
|
|
190
|
+
send: defineOperation({
|
|
191
|
+
description:
|
|
192
|
+
"Create one notification per recipient (members of the organisation) in the caller's transaction, and queue its delivery to each channel the recipient's preference for the category names (default: in-app and email). Idempotent per (key, recipient).",
|
|
193
|
+
input: SendNotification,
|
|
194
|
+
output: Schema.Struct({ ids: Schema.Array(Schema.String) }),
|
|
195
|
+
errors: Schema.Union([InvalidInput, UnknownTemplate]),
|
|
196
|
+
}),
|
|
197
|
+
list: defineOperation({
|
|
198
|
+
description:
|
|
199
|
+
"Action notifications.list: the caller's own notifications in the organisation they act in, newest first (dismissed ones left out), optionally only unread ones or one category.",
|
|
200
|
+
input: NotificationList,
|
|
201
|
+
output: Schema.Struct({ notifications: Schema.Array(Notification) }),
|
|
202
|
+
errors: InvocationError,
|
|
203
|
+
}),
|
|
204
|
+
count: defineOperation({
|
|
205
|
+
description: "Action notifications.count: how many of the caller's notifications are unread (and not dismissed).",
|
|
206
|
+
input: NotificationCount,
|
|
207
|
+
output: Schema.Struct({ unread: Schema.Int }),
|
|
208
|
+
errors: InvocationError,
|
|
209
|
+
}),
|
|
210
|
+
notify: defineOperation({
|
|
211
|
+
description:
|
|
212
|
+
"Action notifications.notify: send a notification to yourself, or with notifications.send to other members of your organisation, delivered like any other (in-app, and email when asked and preferred).",
|
|
213
|
+
input: NotifyRequest,
|
|
214
|
+
output: Schema.Struct({ recipients: Schema.Array(Schema.String) }),
|
|
215
|
+
errors: InvocationError,
|
|
216
|
+
}),
|
|
217
|
+
markRead: defineOperation({
|
|
218
|
+
description: "Action notifications.markRead: mark one of your notifications read.",
|
|
219
|
+
input: NotificationId,
|
|
220
|
+
output: NotificationId,
|
|
221
|
+
errors: InvocationError,
|
|
222
|
+
}),
|
|
223
|
+
markUnread: defineOperation({
|
|
224
|
+
description: "Action notifications.markUnread: mark one of your notifications unread again.",
|
|
225
|
+
input: NotificationId,
|
|
226
|
+
output: NotificationId,
|
|
227
|
+
errors: InvocationError,
|
|
228
|
+
}),
|
|
229
|
+
dismiss: defineOperation({
|
|
230
|
+
description: "Action notifications.dismiss: dismiss one of your notifications.",
|
|
231
|
+
input: NotificationId,
|
|
232
|
+
output: NotificationId,
|
|
233
|
+
errors: InvocationError,
|
|
234
|
+
}),
|
|
235
|
+
setPreference: defineOperation({
|
|
236
|
+
description:
|
|
237
|
+
"Action notifications.setPreference: the channels a category reaches you on, in the organisation you act in (an empty list silences it).",
|
|
238
|
+
input: Preference,
|
|
239
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
240
|
+
errors: InvocationError,
|
|
241
|
+
}),
|
|
242
|
+
setEmailTemplate: defineOperation({
|
|
243
|
+
description:
|
|
244
|
+
"Action notifications.setEmailTemplate: override a registered email template's subject, text and HTML for the organisation (needs the notifications.manage permission).",
|
|
245
|
+
input: TemplateOverride,
|
|
246
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
247
|
+
errors: InvocationError,
|
|
248
|
+
}),
|
|
249
|
+
preview: defineOperation({
|
|
250
|
+
description:
|
|
251
|
+
"Render a template for an organisation with example variables, using its override when it has one. Nothing is sent.",
|
|
252
|
+
input: Schema.Struct({
|
|
253
|
+
orgId: Schema.String,
|
|
254
|
+
template: Schema.String,
|
|
255
|
+
variables: Schema.Record(Schema.String, Schema.Unknown),
|
|
256
|
+
}),
|
|
257
|
+
output: RenderedEmail,
|
|
258
|
+
errors: UnknownTemplate,
|
|
259
|
+
}),
|
|
260
|
+
unsubscribe: defineOperation({
|
|
261
|
+
description:
|
|
262
|
+
"`GET` or `POST /notifications/unsubscribe?token=...` (the link in every email, and RFC 8058 one-click): the signed token names the organisation, person and category; the address is suppressed for that category and email is removed from the person's preference. Audited.",
|
|
263
|
+
input: Schema.Struct({ token: Schema.String }),
|
|
264
|
+
output: Schema.Struct({ category: Schema.String }),
|
|
265
|
+
errors: InvalidInput,
|
|
266
|
+
}),
|
|
267
|
+
registerInstallation: defineOperation({
|
|
268
|
+
description:
|
|
269
|
+
"Action notifications.registerInstallation: register this app installation's APNs or FCM token for push, from the person's own signed-in session only (agents, API tokens, OAuth grants and devices are refused). Registering the installation again replaces its token; a token registered elsewhere moves here. Signing out (or revoking) the registering session removes it; so does erasure.",
|
|
270
|
+
input: PushInstallationRegistration,
|
|
271
|
+
output: PushInstallationId,
|
|
272
|
+
errors: InvocationError,
|
|
273
|
+
}),
|
|
274
|
+
unregisterInstallation: defineOperation({
|
|
275
|
+
description:
|
|
276
|
+
"Action notifications.unregisterInstallation: remove one of your installations (nothing if unknown).",
|
|
277
|
+
input: PushInstallationId,
|
|
278
|
+
output: PushInstallationId,
|
|
279
|
+
errors: InvocationError,
|
|
280
|
+
}),
|
|
281
|
+
decide: defineOperation({
|
|
282
|
+
description:
|
|
283
|
+
"`POST /api/notifications/decide { token, verdict }` (no session; rate-limited; no-store): redeem an approval or consent notification's decision token once, while it is unexpired and the installation registration it was sent to (its session and generation) still stands. The person's decision runs through the existing action (approvals.approve|reject, consent.approve with remember once, consent.reject) as that person under the registering session, under live membership, policy and eligibility, with the chat SDK's decision key; a consent must still be pending. The decision and the token's recorded answer commit together: a later redemption of the same token returns the recorded answer and decides nothing; a transient failure (503 ActionFailed) decides nothing and leaves the token unspent; the person's same decision made elsewhere answers the request's status (replayed). Not an action: no agent or MCP surface reaches it.",
|
|
284
|
+
input: DecideRequest,
|
|
285
|
+
output: DecideResult,
|
|
286
|
+
errors: Schema.Union([InvalidDecision, DecisionExpired, InvocationError]),
|
|
287
|
+
}),
|
|
288
|
+
deliveries: defineOperation({
|
|
289
|
+
description: "The delivery log of a notification (every channel, attempt counts, last error).",
|
|
290
|
+
input: Schema.Struct({ orgId: Schema.String, notificationId: Schema.String }),
|
|
291
|
+
output: Schema.Struct({ deliveries: Schema.Array(DeliveryRecord) }),
|
|
292
|
+
errors: Schema.Never,
|
|
293
|
+
}),
|
|
294
|
+
},
|
|
295
|
+
types: {
|
|
296
|
+
Notification,
|
|
297
|
+
EmailTemplate,
|
|
298
|
+
RenderedEmail,
|
|
299
|
+
SendNotification,
|
|
300
|
+
Preference,
|
|
301
|
+
UnknownTemplate,
|
|
302
|
+
PushProvider,
|
|
303
|
+
PushInstallationRegistration,
|
|
304
|
+
DecideRequest,
|
|
305
|
+
DecideResult,
|
|
306
|
+
InvalidDecision,
|
|
307
|
+
DecisionExpired,
|
|
308
|
+
},
|
|
309
|
+
})
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbox (decision 4): events written in the same transaction as the change,
|
|
3
|
+
* delivered at least once to every subscriber. Documented in
|
|
4
|
+
* docs/contracts/outbox.md; conformance kit `@eloxiv/testing/conformance/Outbox`.
|
|
5
|
+
*/
|
|
6
|
+
import { Schema } from "effect"
|
|
7
|
+
import { Forbidden, InvalidInput, Unauthenticated } from "../Errors.ts"
|
|
8
|
+
import { OutboxEvent } from "../Records.ts"
|
|
9
|
+
import { defineServiceContract } from "../Service.ts"
|
|
10
|
+
|
|
11
|
+
/** The permission an organisation's administrators need to list, retry and discard its dead letters. */
|
|
12
|
+
export const OUTBOX_MANAGE = "eloxiv.outbox.manage"
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* How a subscriber's (or an event trigger's) failed deliveries are retried, and what happens when the
|
|
16
|
+
* retries are exhausted. Every field is optional; the kernel's defaults are `DEFAULT_DELIVERY_POLICY`.
|
|
17
|
+
* A delivery is never retried forever: `maxAttempts` always applies (it must be a finite whole number),
|
|
18
|
+
* and `maxAgeMs`, when set, ends the retries earlier once the event (or a dead letter's retry) is that old.
|
|
19
|
+
*/
|
|
20
|
+
export const DeliveryPolicy = Schema.Struct({
|
|
21
|
+
/** Attempts before the delivery is exhausted (at least 1). */
|
|
22
|
+
maxAttempts: Schema.optionalKey(Schema.Number),
|
|
23
|
+
/** Exhausted once this long (ms) has passed since the event occurred (or since a dead letter was retried). */
|
|
24
|
+
maxAgeMs: Schema.optionalKey(Schema.Number),
|
|
25
|
+
/** Delay before attempt n + 1: `min(maxMs, initialMs * factor^(n - 1))`. */
|
|
26
|
+
backoff: Schema.optionalKey(
|
|
27
|
+
Schema.Struct({
|
|
28
|
+
initialMs: Schema.optionalKey(Schema.Number),
|
|
29
|
+
factor: Schema.optionalKey(Schema.Number),
|
|
30
|
+
maxMs: Schema.optionalKey(Schema.Number),
|
|
31
|
+
}),
|
|
32
|
+
),
|
|
33
|
+
/**
|
|
34
|
+
* On exhaustion: `dead-letter` (the default) keeps the delivery as a dead letter, visible and retryable
|
|
35
|
+
* by an administrator; `discard` closes it at once (still recorded, as `discarded`, and logged).
|
|
36
|
+
*/
|
|
37
|
+
onExhausted: Schema.optionalKey(Schema.Literals(["dead-letter", "discard"])),
|
|
38
|
+
})
|
|
39
|
+
export type DeliveryPolicy = typeof DeliveryPolicy.Type
|
|
40
|
+
|
|
41
|
+
/** The policy a subscriber or trigger gets for every field it does not set. */
|
|
42
|
+
export const DEFAULT_DELIVERY_POLICY = {
|
|
43
|
+
maxAttempts: 20,
|
|
44
|
+
backoff: { initialMs: 100, factor: 2, maxMs: 60_000 },
|
|
45
|
+
onExhausted: "dead-letter",
|
|
46
|
+
} as const
|
|
47
|
+
|
|
48
|
+
/** Where one subscriber's delivery of one event stands, once it has failed at least once. */
|
|
49
|
+
export const DeliveryFailure = Schema.Struct({
|
|
50
|
+
/** The subscriber id, or `trigger:<id>` for an event trigger. */
|
|
51
|
+
subscriber: Schema.String,
|
|
52
|
+
/** `retrying` until it succeeds (the record goes) or is exhausted (`dead` or `discarded`). */
|
|
53
|
+
state: Schema.Literals(["retrying", "dead", "discarded"]),
|
|
54
|
+
/** Failed attempts since the delivery was first tried (or since a dead letter was retried). */
|
|
55
|
+
attempts: Schema.Number,
|
|
56
|
+
lastError: Schema.String,
|
|
57
|
+
/** When a `retrying` delivery may run next. */
|
|
58
|
+
nextAttemptAt: Schema.NullOr(Schema.String),
|
|
59
|
+
})
|
|
60
|
+
export type DeliveryFailure = typeof DeliveryFailure.Type
|
|
61
|
+
|
|
62
|
+
/** A delivery whose retries were exhausted: kept, with its last error, until it is retried or discarded. */
|
|
63
|
+
export const DeadLetter = Schema.Struct({
|
|
64
|
+
eventId: Schema.String,
|
|
65
|
+
subscriber: Schema.String,
|
|
66
|
+
type: Schema.String,
|
|
67
|
+
/** The emitting module. */
|
|
68
|
+
module: Schema.String,
|
|
69
|
+
orgId: Schema.String,
|
|
70
|
+
payload: Schema.Unknown,
|
|
71
|
+
occurredAt: Schema.String,
|
|
72
|
+
/** `dead` until an administrator retries or discards it; `discarded` stays visible as a record. */
|
|
73
|
+
state: Schema.Literals(["dead", "discarded"]),
|
|
74
|
+
attempts: Schema.Number,
|
|
75
|
+
lastError: Schema.String,
|
|
76
|
+
firstFailedAt: Schema.String,
|
|
77
|
+
deadAt: Schema.String,
|
|
78
|
+
/** Who closed it: a user id (discarded by an administrator), `policy` (`onExhausted: discard`), or null. */
|
|
79
|
+
closedBy: Schema.NullOr(Schema.String),
|
|
80
|
+
closedAt: Schema.NullOr(Schema.String),
|
|
81
|
+
})
|
|
82
|
+
export type DeadLetter = typeof DeadLetter.Type
|
|
83
|
+
|
|
84
|
+
export const DeadLetterFilter = Schema.Struct({
|
|
85
|
+
orgId: Schema.optionalKey(Schema.String),
|
|
86
|
+
eventId: Schema.optionalKey(Schema.String),
|
|
87
|
+
subscriber: Schema.optionalKey(Schema.String),
|
|
88
|
+
/** Default `dead`. */
|
|
89
|
+
state: Schema.optionalKey(Schema.Literals(["dead", "discarded"])),
|
|
90
|
+
})
|
|
91
|
+
export type DeadLetterFilter = typeof DeadLetterFilter.Type
|
|
92
|
+
|
|
93
|
+
/** One dead letter: an event's delivery to one subscriber. */
|
|
94
|
+
export const DeadLetterRef = Schema.Struct({ eventId: Schema.String, subscriber: Schema.String })
|
|
95
|
+
export type DeadLetterRef = typeof DeadLetterRef.Type
|
|
96
|
+
|
|
97
|
+
/** The failures an administrator's call can end with. */
|
|
98
|
+
const ManageErrors = Schema.Union([Unauthenticated, Forbidden, InvalidInput])
|
|
99
|
+
|
|
100
|
+
/** An event to write, inside the transaction of the invocation that emitted it. */
|
|
101
|
+
export const OutboxPublish = Schema.Struct({
|
|
102
|
+
invocationId: Schema.String,
|
|
103
|
+
type: Schema.String,
|
|
104
|
+
/** The emitting module. */
|
|
105
|
+
module: Schema.String,
|
|
106
|
+
orgId: Schema.String,
|
|
107
|
+
payload: Schema.Unknown,
|
|
108
|
+
})
|
|
109
|
+
export type OutboxPublish = typeof OutboxPublish.Type
|
|
110
|
+
|
|
111
|
+
/** An event and where its delivery stands. */
|
|
112
|
+
export const OutboxEventStatus = Schema.Struct({
|
|
113
|
+
...OutboxEvent.fields,
|
|
114
|
+
/** Set once every subscriber has succeeded. */
|
|
115
|
+
deliveredAt: Schema.NullOr(Schema.String),
|
|
116
|
+
/**
|
|
117
|
+
* Set once no delivery is outstanding: each subscriber succeeded, or was dead-lettered or discarded. A
|
|
118
|
+
* settled event is not claimed again until a dead letter of it is retried.
|
|
119
|
+
*/
|
|
120
|
+
settledAt: Schema.NullOr(Schema.String),
|
|
121
|
+
/** Delivery passes that included this event. */
|
|
122
|
+
attempts: Schema.Number,
|
|
123
|
+
/** The failing subscribers' errors from the last pass, if it failed. */
|
|
124
|
+
lastError: Schema.NullOr(Schema.String),
|
|
125
|
+
/** When the next pass may include it (exponential backoff after a failure). */
|
|
126
|
+
nextAttemptAt: Schema.String,
|
|
127
|
+
/** Subscriber ids that have succeeded for this event; they are never run again for it. */
|
|
128
|
+
deliveredTo: Schema.Array(Schema.String),
|
|
129
|
+
/** Deliveries that have failed and not (yet) succeeded: retrying, dead-lettered or discarded. */
|
|
130
|
+
failures: Schema.Array(DeliveryFailure),
|
|
131
|
+
})
|
|
132
|
+
export type OutboxEventStatus = typeof OutboxEventStatus.Type
|
|
133
|
+
|
|
134
|
+
export const OutboxFilter = Schema.Struct({
|
|
135
|
+
ids: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
136
|
+
invocationId: Schema.optionalKey(Schema.String),
|
|
137
|
+
type: Schema.optionalKey(Schema.String),
|
|
138
|
+
})
|
|
139
|
+
export type OutboxFilter = typeof OutboxFilter.Type
|
|
140
|
+
|
|
141
|
+
/** A module's subscription to an event type. */
|
|
142
|
+
export const OutboxSubscription = Schema.Struct({
|
|
143
|
+
/** Stable id, recorded per delivered event. */
|
|
144
|
+
id: Schema.String,
|
|
145
|
+
/** The event type it receives. */
|
|
146
|
+
event: Schema.String,
|
|
147
|
+
/** The subscribing module, whose runtime role the subscriber runs as. */
|
|
148
|
+
module: Schema.String,
|
|
149
|
+
/** Retries and exhaustion; unset fields take `DEFAULT_DELIVERY_POLICY`. */
|
|
150
|
+
delivery: Schema.optionalKey(DeliveryPolicy),
|
|
151
|
+
})
|
|
152
|
+
export type OutboxSubscription = typeof OutboxSubscription.Type
|
|
153
|
+
|
|
154
|
+
export const OutboxContract = defineServiceContract({
|
|
155
|
+
name: "Outbox",
|
|
156
|
+
kind: "kernel",
|
|
157
|
+
version: "1.1.0",
|
|
158
|
+
description:
|
|
159
|
+
"The transactional outbox. Events are written in the transaction of the invocation that emitted them and " +
|
|
160
|
+
"delivered at least once to every subscriber, each in its own savepoint as its module's runtime role, " +
|
|
161
|
+
"acting as a system actor limited to the event's organisation. A failing subscriber is retried with " +
|
|
162
|
+
"backoff under its delivery policy without holding up other events or subscribers; subscribers that " +
|
|
163
|
+
"succeeded are not run again. A delivery whose retries are exhausted becomes a dead letter (or is " +
|
|
164
|
+
"discarded, if its policy says so): it is kept with its last error, logged, counted by Readiness, and an " +
|
|
165
|
+
"organisation's administrators list, retry and discard its dead letters through authorised, audited " +
|
|
166
|
+
"operations. Event triggers are delivered and dead-lettered the same way.",
|
|
167
|
+
operations: {
|
|
168
|
+
publish: {
|
|
169
|
+
description:
|
|
170
|
+
"Write an event in the current transaction (the invocation path does this for the events a handler " +
|
|
171
|
+
"emits) and wake the dispatcher after commit. A call that fails or rolls back leaves no event.",
|
|
172
|
+
input: OutboxPublish,
|
|
173
|
+
output: Schema.Struct({ id: Schema.String }),
|
|
174
|
+
errors: Schema.Never,
|
|
175
|
+
},
|
|
176
|
+
dispatch: {
|
|
177
|
+
description:
|
|
178
|
+
"One delivery pass: claim due, undelivered events (skipping those another dispatcher holds), run every " +
|
|
179
|
+
"subscriber that has not yet succeeded for each, and record the outcome. Returns how many events became " +
|
|
180
|
+
"fully delivered. The kernel runs it continuously, woken by notifications and polling.",
|
|
181
|
+
input: Schema.Struct({}),
|
|
182
|
+
output: Schema.Struct({ delivered: Schema.Number }),
|
|
183
|
+
errors: Schema.Never,
|
|
184
|
+
},
|
|
185
|
+
events: {
|
|
186
|
+
description: "Events and their delivery state, oldest first.",
|
|
187
|
+
input: OutboxFilter,
|
|
188
|
+
output: Schema.Array(OutboxEventStatus),
|
|
189
|
+
errors: Schema.Never,
|
|
190
|
+
},
|
|
191
|
+
retry: {
|
|
192
|
+
description:
|
|
193
|
+
"Make an unsettled event, and its retrying deliveries, due now without waiting out their backoff. " +
|
|
194
|
+
"Subscribers that already succeeded are still not run again; dead letters are not reopened (see " +
|
|
195
|
+
"`retryDeadLetter`).",
|
|
196
|
+
input: Schema.Struct({ eventId: Schema.String }),
|
|
197
|
+
output: Schema.Struct({}),
|
|
198
|
+
errors: Schema.Never,
|
|
199
|
+
},
|
|
200
|
+
deadLetters: {
|
|
201
|
+
description:
|
|
202
|
+
"Operators and trusted code: dead letters (default state `dead`) across organisations, oldest first.",
|
|
203
|
+
input: DeadLetterFilter,
|
|
204
|
+
output: Schema.Array(DeadLetter),
|
|
205
|
+
errors: Schema.Never,
|
|
206
|
+
},
|
|
207
|
+
listDeadLetters: {
|
|
208
|
+
description:
|
|
209
|
+
"An administrator (the `eloxiv.outbox.manage` permission) lists the dead letters of the organisation " +
|
|
210
|
+
"they act in (state `dead` by default; `discarded` lists closed ones). Audited.",
|
|
211
|
+
input: Schema.Struct({ state: Schema.optionalKey(Schema.Literals(["dead", "discarded"])) }),
|
|
212
|
+
output: Schema.Array(DeadLetter),
|
|
213
|
+
errors: ManageErrors,
|
|
214
|
+
},
|
|
215
|
+
retryDeadLetter: {
|
|
216
|
+
description:
|
|
217
|
+
"An administrator retries one of the organisation's dead letters: it runs again with a fresh attempt " +
|
|
218
|
+
"budget (attempts and age count from the retry) and the event is claimed again. Audited. Fails with " +
|
|
219
|
+
"InvalidInput when no such dead letter is open in the organisation.",
|
|
220
|
+
input: DeadLetterRef,
|
|
221
|
+
output: Schema.Struct({}),
|
|
222
|
+
errors: ManageErrors,
|
|
223
|
+
},
|
|
224
|
+
discardDeadLetter: {
|
|
225
|
+
description:
|
|
226
|
+
"An administrator closes one of the organisation's dead letters without running it: it is kept as " +
|
|
227
|
+
"`discarded` (who and when), never run again, and the event settles if nothing else is outstanding. " +
|
|
228
|
+
"Audited. Fails with InvalidInput when no such dead letter is open in the organisation.",
|
|
229
|
+
input: DeadLetterRef,
|
|
230
|
+
output: Schema.Struct({}),
|
|
231
|
+
errors: ManageErrors,
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
types: {
|
|
235
|
+
OutboxEvent,
|
|
236
|
+
OutboxEventStatus,
|
|
237
|
+
OutboxPublish,
|
|
238
|
+
OutboxFilter,
|
|
239
|
+
Subscription: OutboxSubscription,
|
|
240
|
+
DeliveryPolicy,
|
|
241
|
+
DeliveryFailure,
|
|
242
|
+
DeadLetter,
|
|
243
|
+
DeadLetterFilter,
|
|
244
|
+
DeadLetterRef,
|
|
245
|
+
},
|
|
246
|
+
})
|