@eloxiv/kernel 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/AccountMail.d.ts +40 -0
- package/dist/AccountMail.d.ts.map +1 -0
- package/dist/AccountMail.js +169 -0
- package/dist/AccountMail.js.map +1 -0
- package/dist/AppConfig.d.ts +72 -0
- package/dist/AppConfig.d.ts.map +1 -0
- package/dist/AppConfig.js +87 -0
- package/dist/AppConfig.js.map +1 -0
- package/dist/Approvals.d.ts +132 -0
- package/dist/Approvals.d.ts.map +1 -0
- package/dist/Approvals.js +342 -0
- package/dist/Approvals.js.map +1 -0
- package/dist/Audit.d.ts +93 -0
- package/dist/Audit.d.ts.map +1 -0
- package/dist/Audit.js +275 -0
- package/dist/Audit.js.map +1 -0
- package/dist/AuthSeam.d.ts +58 -0
- package/dist/AuthSeam.d.ts.map +1 -0
- package/dist/AuthSeam.js +101 -0
- package/dist/AuthSeam.js.map +1 -0
- package/dist/Authority.d.ts +160 -0
- package/dist/Authority.d.ts.map +1 -0
- package/dist/Authority.js +325 -0
- package/dist/Authority.js.map +1 -0
- package/dist/Avatars.d.ts +26 -0
- package/dist/Avatars.d.ts.map +1 -0
- package/dist/Avatars.js +140 -0
- package/dist/Avatars.js.map +1 -0
- package/dist/Base64url.d.ts +9 -0
- package/dist/Base64url.d.ts.map +1 -0
- package/dist/Base64url.js +26 -0
- package/dist/Base64url.js.map +1 -0
- package/dist/BasePath.d.ts +39 -0
- package/dist/BasePath.d.ts.map +1 -0
- package/dist/BasePath.js +70 -0
- package/dist/BasePath.js.map +1 -0
- package/dist/CallActed.d.ts +10 -0
- package/dist/CallActed.d.ts.map +1 -0
- package/dist/CallActed.js +10 -0
- package/dist/CallActed.js.map +1 -0
- package/dist/Config.d.ts +459 -0
- package/dist/Config.d.ts.map +1 -0
- package/dist/Config.js +415 -0
- package/dist/Config.js.map +1 -0
- package/dist/DeliveryPolicy.d.ts +20 -0
- package/dist/DeliveryPolicy.d.ts.map +1 -0
- package/dist/DeliveryPolicy.js +35 -0
- package/dist/DeliveryPolicy.js.map +1 -0
- package/dist/DesktopSignIn.d.ts +24 -0
- package/dist/DesktopSignIn.d.ts.map +1 -0
- package/dist/DesktopSignIn.js +148 -0
- package/dist/DesktopSignIn.js.map +1 -0
- package/dist/Directory.d.ts +179 -0
- package/dist/Directory.d.ts.map +1 -0
- package/dist/Directory.js +1184 -0
- package/dist/Directory.js.map +1 -0
- package/dist/Flags.d.ts +59 -0
- package/dist/Flags.d.ts.map +1 -0
- package/dist/Flags.js +195 -0
- package/dist/Flags.js.map +1 -0
- package/dist/Gate.d.ts +42 -0
- package/dist/Gate.d.ts.map +1 -0
- package/dist/Gate.js +132 -0
- package/dist/Gate.js.map +1 -0
- package/dist/Hash.d.ts +4 -0
- package/dist/Hash.d.ts.map +1 -0
- package/dist/Hash.js +16 -0
- package/dist/Hash.js.map +1 -0
- package/dist/Identity.d.ts +327 -0
- package/dist/Identity.d.ts.map +1 -0
- package/dist/Identity.js +1232 -0
- package/dist/Identity.js.map +1 -0
- package/dist/IntervalJob.d.ts +40 -0
- package/dist/IntervalJob.d.ts.map +1 -0
- package/dist/IntervalJob.js +76 -0
- package/dist/IntervalJob.js.map +1 -0
- package/dist/Invocation.d.ts +210 -0
- package/dist/Invocation.d.ts.map +1 -0
- package/dist/Invocation.js +1680 -0
- package/dist/Invocation.js.map +1 -0
- package/dist/KernelHandlers.d.ts +19 -0
- package/dist/KernelHandlers.d.ts.map +1 -0
- package/dist/KernelHandlers.js +15 -0
- package/dist/KernelHandlers.js.map +1 -0
- package/dist/KernelModule.d.ts +65 -0
- package/dist/KernelModule.d.ts.map +1 -0
- package/dist/KernelModule.js +116 -0
- package/dist/KernelModule.js.map +1 -0
- package/dist/MemberRoutes.d.ts +6 -0
- package/dist/MemberRoutes.d.ts.map +1 -0
- package/dist/MemberRoutes.js +107 -0
- package/dist/MemberRoutes.js.map +1 -0
- package/dist/Module.d.ts +479 -0
- package/dist/Module.d.ts.map +1 -0
- package/dist/Module.js +30 -0
- package/dist/Module.js.map +1 -0
- package/dist/ModuleIdentity.d.ts +17 -0
- package/dist/ModuleIdentity.d.ts.map +1 -0
- package/dist/ModuleIdentity.js +106 -0
- package/dist/ModuleIdentity.js.map +1 -0
- package/dist/Notifications.d.ts +107 -0
- package/dist/Notifications.d.ts.map +1 -0
- package/dist/Notifications.js +475 -0
- package/dist/Notifications.js.map +1 -0
- package/dist/Outbox.d.ts +146 -0
- package/dist/Outbox.d.ts.map +1 -0
- package/dist/Outbox.js +518 -0
- package/dist/Outbox.js.map +1 -0
- package/dist/Privacy.d.ts +50 -0
- package/dist/Privacy.d.ts.map +1 -0
- package/dist/Privacy.js +167 -0
- package/dist/Privacy.js.map +1 -0
- package/dist/Progress.d.ts +42 -0
- package/dist/Progress.d.ts.map +1 -0
- package/dist/Progress.js +215 -0
- package/dist/Progress.js.map +1 -0
- package/dist/QuerySurface.d.ts +73 -0
- package/dist/QuerySurface.d.ts.map +1 -0
- package/dist/QuerySurface.js +440 -0
- package/dist/QuerySurface.js.map +1 -0
- package/dist/QueryViews.d.ts +70 -0
- package/dist/QueryViews.d.ts.map +1 -0
- package/dist/QueryViews.js +94 -0
- package/dist/QueryViews.js.map +1 -0
- package/dist/Readiness.d.ts +40 -0
- package/dist/Readiness.d.ts.map +1 -0
- package/dist/Readiness.js +203 -0
- package/dist/Readiness.js.map +1 -0
- package/dist/Redact.d.ts +11 -0
- package/dist/Redact.d.ts.map +1 -0
- package/dist/Redact.js +21 -0
- package/dist/Redact.js.map +1 -0
- package/dist/Registry.d.ts +117 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/Registry.js +297 -0
- package/dist/Registry.js.map +1 -0
- package/dist/Release.d.ts +205 -0
- package/dist/Release.d.ts.map +1 -0
- package/dist/Release.js +880 -0
- package/dist/Release.js.map +1 -0
- package/dist/Retention.d.ts +43 -0
- package/dist/Retention.d.ts.map +1 -0
- package/dist/Retention.js +124 -0
- package/dist/Retention.js.map +1 -0
- package/dist/Scheduler.d.ts +56 -0
- package/dist/Scheduler.d.ts.map +1 -0
- package/dist/Scheduler.js +470 -0
- package/dist/Scheduler.js.map +1 -0
- package/dist/Server.d.ts +341 -0
- package/dist/Server.d.ts.map +1 -0
- package/dist/Server.js +1106 -0
- package/dist/Server.js.map +1 -0
- package/dist/Sessions.d.ts +38 -0
- package/dist/Sessions.d.ts.map +1 -0
- package/dist/Sessions.js +45 -0
- package/dist/Sessions.js.map +1 -0
- package/dist/Settings.d.ts +63 -0
- package/dist/Settings.d.ts.map +1 -0
- package/dist/Settings.js +219 -0
- package/dist/Settings.js.map +1 -0
- package/dist/Sharing.d.ts +99 -0
- package/dist/Sharing.d.ts.map +1 -0
- package/dist/Sharing.js +315 -0
- package/dist/Sharing.js.map +1 -0
- package/dist/Sync.d.ts +188 -0
- package/dist/Sync.d.ts.map +1 -0
- package/dist/Sync.js +1100 -0
- package/dist/Sync.js.map +1 -0
- package/dist/Telemetry.d.ts +154 -0
- package/dist/Telemetry.d.ts.map +1 -0
- package/dist/Telemetry.js +536 -0
- package/dist/Telemetry.js.map +1 -0
- package/dist/Versioning.d.ts +98 -0
- package/dist/Versioning.d.ts.map +1 -0
- package/dist/Versioning.js +387 -0
- package/dist/Versioning.js.map +1 -0
- package/dist/WorkItems.d.ts +67 -0
- package/dist/WorkItems.d.ts.map +1 -0
- package/dist/WorkItems.js +211 -0
- package/dist/WorkItems.js.map +1 -0
- package/dist/Workflows.d.ts +78 -0
- package/dist/Workflows.d.ts.map +1 -0
- package/dist/Workflows.js +478 -0
- package/dist/Workflows.js.map +1 -0
- package/dist/agent/Admission.d.ts +22 -0
- package/dist/agent/Admission.d.ts.map +1 -0
- package/dist/agent/Admission.js +34 -0
- package/dist/agent/Admission.js.map +1 -0
- package/dist/agent/Channels.d.ts +15 -0
- package/dist/agent/Channels.d.ts.map +1 -0
- package/dist/agent/Channels.js +50 -0
- package/dist/agent/Channels.js.map +1 -0
- package/dist/agent/Context.d.ts +73 -0
- package/dist/agent/Context.d.ts.map +1 -0
- package/dist/agent/Context.js +338 -0
- package/dist/agent/Context.js.map +1 -0
- package/dist/agent/Http.d.ts +18 -0
- package/dist/agent/Http.d.ts.map +1 -0
- package/dist/agent/Http.js +410 -0
- package/dist/agent/Http.js.map +1 -0
- package/dist/agent/Metering.d.ts +162 -0
- package/dist/agent/Metering.d.ts.map +1 -0
- package/dist/agent/Metering.js +315 -0
- package/dist/agent/Metering.js.map +1 -0
- package/dist/agent/ModelSetup.d.ts +10 -0
- package/dist/agent/ModelSetup.d.ts.map +1 -0
- package/dist/agent/ModelSetup.js +331 -0
- package/dist/agent/ModelSetup.js.map +1 -0
- package/dist/agent/Models.d.ts +197 -0
- package/dist/agent/Models.d.ts.map +1 -0
- package/dist/agent/Models.js +489 -0
- package/dist/agent/Models.js.map +1 -0
- package/dist/agent/Processors.d.ts +102 -0
- package/dist/agent/Processors.d.ts.map +1 -0
- package/dist/agent/Processors.js +80 -0
- package/dist/agent/Processors.js.map +1 -0
- package/dist/agent/Queue.d.ts +21 -0
- package/dist/agent/Queue.d.ts.map +1 -0
- package/dist/agent/Queue.js +64 -0
- package/dist/agent/Queue.js.map +1 -0
- package/dist/agent/Receipts.d.ts +41 -0
- package/dist/agent/Receipts.d.ts.map +1 -0
- package/dist/agent/Receipts.js +142 -0
- package/dist/agent/Receipts.js.map +1 -0
- package/dist/agent/Resources.d.ts +68 -0
- package/dist/agent/Resources.d.ts.map +1 -0
- package/dist/agent/Resources.js +207 -0
- package/dist/agent/Resources.js.map +1 -0
- package/dist/agent/Run.d.ts +178 -0
- package/dist/agent/Run.d.ts.map +1 -0
- package/dist/agent/Run.js +2896 -0
- package/dist/agent/Run.js.map +1 -0
- package/dist/agent/Runtime.d.ts +79 -0
- package/dist/agent/Runtime.d.ts.map +1 -0
- package/dist/agent/Runtime.js +366 -0
- package/dist/agent/Runtime.js.map +1 -0
- package/dist/agent/Settings.d.ts +126 -0
- package/dist/agent/Settings.d.ts.map +1 -0
- package/dist/agent/Settings.js +44 -0
- package/dist/agent/Settings.js.map +1 -0
- package/dist/agent/Skills.d.ts +73 -0
- package/dist/agent/Skills.d.ts.map +1 -0
- package/dist/agent/Skills.js +95 -0
- package/dist/agent/Skills.js.map +1 -0
- package/dist/agent/Store.d.ts +37 -0
- package/dist/agent/Store.d.ts.map +1 -0
- package/dist/agent/Store.js +50 -0
- package/dist/agent/Store.js.map +1 -0
- package/dist/agent/ToolSearch.d.ts +37 -0
- package/dist/agent/ToolSearch.d.ts.map +1 -0
- package/dist/agent/ToolSearch.js +119 -0
- package/dist/agent/ToolSearch.js.map +1 -0
- package/dist/agent/index.d.ts +37 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +44 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/module.d.ts +12889 -0
- package/dist/agent/module.d.ts.map +1 -0
- package/dist/agent/module.js +1550 -0
- package/dist/agent/module.js.map +1 -0
- package/dist/appState/Sweep.d.ts +21 -0
- package/dist/appState/Sweep.d.ts.map +1 -0
- package/dist/appState/Sweep.js +46 -0
- package/dist/appState/Sweep.js.map +1 -0
- package/dist/appState/module.d.ts +1710 -0
- package/dist/appState/module.d.ts.map +1 -0
- package/dist/appState/module.js +344 -0
- package/dist/appState/module.js.map +1 -0
- package/dist/audit/module.d.ts +158 -0
- package/dist/audit/module.d.ts.map +1 -0
- package/dist/audit/module.js +72 -0
- package/dist/audit/module.js.map +1 -0
- package/dist/auth/AuthProvider.d.ts +224 -0
- package/dist/auth/AuthProvider.d.ts.map +1 -0
- package/dist/auth/AuthProvider.js +104 -0
- package/dist/auth/AuthProvider.js.map +1 -0
- package/dist/auth/BetterAuthProvider.d.ts +40 -0
- package/dist/auth/BetterAuthProvider.d.ts.map +1 -0
- package/dist/auth/BetterAuthProvider.js +458 -0
- package/dist/auth/BetterAuthProvider.js.map +1 -0
- package/dist/auth/Methods.d.ts +7 -0
- package/dist/auth/Methods.d.ts.map +1 -0
- package/dist/auth/Methods.js +7 -0
- package/dist/auth/Methods.js.map +1 -0
- package/dist/auth/SessionTokens.d.ts +23 -0
- package/dist/auth/SessionTokens.d.ts.map +1 -0
- package/dist/auth/SessionTokens.js +150 -0
- package/dist/auth/SessionTokens.js.map +1 -0
- package/dist/collab/Collab.d.ts +105 -0
- package/dist/collab/Collab.d.ts.map +1 -0
- package/dist/collab/Collab.js +475 -0
- package/dist/collab/Collab.js.map +1 -0
- package/dist/collab/Housekeeping.d.ts +38 -0
- package/dist/collab/Housekeeping.d.ts.map +1 -0
- package/dist/collab/Housekeeping.js +146 -0
- package/dist/collab/Housekeeping.js.map +1 -0
- package/dist/collab/LiveCopy.d.ts +7 -0
- package/dist/collab/LiveCopy.d.ts.map +1 -0
- package/dist/collab/LiveCopy.js +79 -0
- package/dist/collab/LiveCopy.js.map +1 -0
- package/dist/collab/Socket.d.ts +19 -0
- package/dist/collab/Socket.d.ts.map +1 -0
- package/dist/collab/Socket.js +323 -0
- package/dist/collab/Socket.js.map +1 -0
- package/dist/collab/Store.d.ts +42 -0
- package/dist/collab/Store.d.ts.map +1 -0
- package/dist/collab/Store.js +59 -0
- package/dist/collab/Store.js.map +1 -0
- package/dist/collab/Ydoc.d.ts +88 -0
- package/dist/collab/Ydoc.d.ts.map +1 -0
- package/dist/collab/Ydoc.js +314 -0
- package/dist/collab/Ydoc.js.map +1 -0
- package/dist/collab/derive/bundle.gen.d.ts +2 -0
- package/dist/collab/derive/bundle.gen.d.ts.map +1 -0
- package/dist/collab/derive/bundle.gen.js +3 -0
- package/dist/collab/derive/bundle.gen.js.map +1 -0
- package/dist/collab/derive/entry.d.ts +3 -0
- package/dist/collab/derive/entry.d.ts.map +1 -0
- package/dist/collab/derive/entry.js +35 -0
- package/dist/collab/derive/entry.js.map +1 -0
- package/dist/collab/derive/polyfill.d.ts +3 -0
- package/dist/collab/derive/polyfill.d.ts.map +1 -0
- package/dist/collab/derive/polyfill.js +17 -0
- package/dist/collab/derive/polyfill.js.map +1 -0
- package/dist/collab/module.d.ts +305 -0
- package/dist/collab/module.d.ts.map +1 -0
- package/dist/collab/module.js +161 -0
- package/dist/collab/module.js.map +1 -0
- package/dist/connections/Connections.d.ts +199 -0
- package/dist/connections/Connections.d.ts.map +1 -0
- package/dist/connections/Connections.js +1633 -0
- package/dist/connections/Connections.js.map +1 -0
- package/dist/connections/Connector.d.ts +213 -0
- package/dist/connections/Connector.d.ts.map +1 -0
- package/dist/connections/Connector.js +55 -0
- package/dist/connections/Connector.js.map +1 -0
- package/dist/connections/Crypto.d.ts +55 -0
- package/dist/connections/Crypto.d.ts.map +1 -0
- package/dist/connections/Crypto.js +100 -0
- package/dist/connections/Crypto.js.map +1 -0
- package/dist/connections/Destinations.d.ts +63 -0
- package/dist/connections/Destinations.d.ts.map +1 -0
- package/dist/connections/Destinations.js +338 -0
- package/dist/connections/Destinations.js.map +1 -0
- package/dist/connections/Discovery.d.ts +53 -0
- package/dist/connections/Discovery.d.ts.map +1 -0
- package/dist/connections/Discovery.js +209 -0
- package/dist/connections/Discovery.js.map +1 -0
- package/dist/connections/EffectKinds.d.ts +17 -0
- package/dist/connections/EffectKinds.d.ts.map +1 -0
- package/dist/connections/EffectKinds.js +26 -0
- package/dist/connections/EffectKinds.js.map +1 -0
- package/dist/connections/Effects.d.ts +49 -0
- package/dist/connections/Effects.d.ts.map +1 -0
- package/dist/connections/Effects.js +347 -0
- package/dist/connections/Effects.js.map +1 -0
- package/dist/connections/Metering.d.ts +40 -0
- package/dist/connections/Metering.d.ts.map +1 -0
- package/dist/connections/Metering.js +142 -0
- package/dist/connections/Metering.js.map +1 -0
- package/dist/connections/ProviderApi.d.ts +47 -0
- package/dist/connections/ProviderApi.d.ts.map +1 -0
- package/dist/connections/ProviderApi.js +103 -0
- package/dist/connections/ProviderApi.js.map +1 -0
- package/dist/connections/Secrets.d.ts +78 -0
- package/dist/connections/Secrets.d.ts.map +1 -0
- package/dist/connections/Secrets.js +342 -0
- package/dist/connections/Secrets.js.map +1 -0
- package/dist/connections/Sync.d.ts +85 -0
- package/dist/connections/Sync.d.ts.map +1 -0
- package/dist/connections/Sync.js +201 -0
- package/dist/connections/Sync.js.map +1 -0
- package/dist/connections/module.d.ts +1061 -0
- package/dist/connections/module.d.ts.map +1 -0
- package/dist/connections/module.js +485 -0
- package/dist/connections/module.js.map +1 -0
- package/dist/data/Corpus.d.ts +79 -0
- package/dist/data/Corpus.d.ts.map +1 -0
- package/dist/data/Corpus.js +343 -0
- package/dist/data/Corpus.js.map +1 -0
- package/dist/data/Datasets.d.ts +88 -0
- package/dist/data/Datasets.d.ts.map +1 -0
- package/dist/data/Datasets.js +375 -0
- package/dist/data/Datasets.js.map +1 -0
- package/dist/data/Programs.d.ts +58 -0
- package/dist/data/Programs.d.ts.map +1 -0
- package/dist/data/Programs.js +197 -0
- package/dist/data/Programs.js.map +1 -0
- package/dist/data/module.d.ts +210 -0
- package/dist/data/module.d.ts.map +1 -0
- package/dist/data/module.js +140 -0
- package/dist/data/module.js.map +1 -0
- package/dist/db/Bootstrap.d.ts +508 -0
- package/dist/db/Bootstrap.d.ts.map +1 -0
- package/dist/db/Bootstrap.js +2368 -0
- package/dist/db/Bootstrap.js.map +1 -0
- package/dist/db/Catalog.d.ts +10 -0
- package/dist/db/Catalog.d.ts.map +1 -0
- package/dist/db/Catalog.js +9 -0
- package/dist/db/Catalog.js.map +1 -0
- package/dist/db/Conflicts.d.ts +18 -0
- package/dist/db/Conflicts.d.ts.map +1 -0
- package/dist/db/Conflicts.js +29 -0
- package/dist/db/Conflicts.js.map +1 -0
- package/dist/db/DirectoryLock.d.ts +16 -0
- package/dist/db/DirectoryLock.d.ts.map +1 -0
- package/dist/db/DirectoryLock.js +15 -0
- package/dist/db/DirectoryLock.js.map +1 -0
- package/dist/db/HandlerGate.d.ts +28 -0
- package/dist/db/HandlerGate.d.ts.map +1 -0
- package/dist/db/HandlerGate.js +76 -0
- package/dist/db/HandlerGate.js.map +1 -0
- package/dist/db/Host.d.ts +94 -0
- package/dist/db/Host.d.ts.map +1 -0
- package/dist/db/Host.js +189 -0
- package/dist/db/Host.js.map +1 -0
- package/dist/db/KernelSchema.d.ts +52 -0
- package/dist/db/KernelSchema.d.ts.map +1 -0
- package/dist/db/KernelSchema.js +4313 -0
- package/dist/db/KernelSchema.js.map +1 -0
- package/dist/db/MigrationCheck.d.ts +38 -0
- package/dist/db/MigrationCheck.d.ts.map +1 -0
- package/dist/db/MigrationCheck.js +180 -0
- package/dist/db/MigrationCheck.js.map +1 -0
- package/dist/db/QueryViewCheck.d.ts +172 -0
- package/dist/db/QueryViewCheck.d.ts.map +1 -0
- package/dist/db/QueryViewCheck.js +967 -0
- package/dist/db/QueryViewCheck.js.map +1 -0
- package/dist/db/ReadOnly.d.ts +13 -0
- package/dist/db/ReadOnly.d.ts.map +1 -0
- package/dist/db/ReadOnly.js +16 -0
- package/dist/db/ReadOnly.js.map +1 -0
- package/dist/db/Scram.d.ts +5 -0
- package/dist/db/Scram.d.ts.map +1 -0
- package/dist/db/Scram.js +17 -0
- package/dist/db/Scram.js.map +1 -0
- package/dist/db/SqlState.d.ts +36 -0
- package/dist/db/SqlState.d.ts.map +1 -0
- package/dist/db/SqlState.js +64 -0
- package/dist/db/SqlState.js.map +1 -0
- package/dist/db/Startup.d.ts +18 -0
- package/dist/db/Startup.d.ts.map +1 -0
- package/dist/db/Startup.js +22 -0
- package/dist/db/Startup.js.map +1 -0
- package/dist/db/ZeroDdl.d.ts +85 -0
- package/dist/db/ZeroDdl.d.ts.map +1 -0
- package/dist/db/ZeroDdl.js +240 -0
- package/dist/db/ZeroDdl.js.map +1 -0
- package/dist/db/ZeroPush.d.ts +7 -0
- package/dist/db/ZeroPush.d.ts.map +1 -0
- package/dist/db/ZeroPush.js +126 -0
- package/dist/db/ZeroPush.js.map +1 -0
- package/dist/devices/Devices.d.ts +130 -0
- package/dist/devices/Devices.d.ts.map +1 -0
- package/dist/devices/Devices.js +769 -0
- package/dist/devices/Devices.js.map +1 -0
- package/dist/devices/Flow.d.ts +47 -0
- package/dist/devices/Flow.d.ts.map +1 -0
- package/dist/devices/Flow.js +131 -0
- package/dist/devices/Flow.js.map +1 -0
- package/dist/devices/Http.d.ts +6 -0
- package/dist/devices/Http.d.ts.map +1 -0
- package/dist/devices/Http.js +103 -0
- package/dist/devices/Http.js.map +1 -0
- package/dist/devices/module.d.ts +1313 -0
- package/dist/devices/module.d.ts.map +1 -0
- package/dist/devices/module.js +266 -0
- package/dist/devices/module.js.map +1 -0
- package/dist/durable/Cluster.d.ts +13 -0
- package/dist/durable/Cluster.d.ts.map +1 -0
- package/dist/durable/Cluster.js +57 -0
- package/dist/durable/Cluster.js.map +1 -0
- package/dist/durable/Definition.d.ts +215 -0
- package/dist/durable/Definition.d.ts.map +1 -0
- package/dist/durable/Definition.js +18 -0
- package/dist/durable/Definition.js.map +1 -0
- package/dist/durable/Schedule.d.ts +46 -0
- package/dist/durable/Schedule.d.ts.map +1 -0
- package/dist/durable/Schedule.js +120 -0
- package/dist/durable/Schedule.js.map +1 -0
- package/dist/durable/Trust.d.ts +90 -0
- package/dist/durable/Trust.d.ts.map +1 -0
- package/dist/durable/Trust.js +61 -0
- package/dist/durable/Trust.js.map +1 -0
- package/dist/enterprise/Routes.d.ts +32 -0
- package/dist/enterprise/Routes.d.ts.map +1 -0
- package/dist/enterprise/Routes.js +448 -0
- package/dist/enterprise/Routes.js.map +1 -0
- package/dist/enterprise/WorkOs.d.ts +42 -0
- package/dist/enterprise/WorkOs.d.ts.map +1 -0
- package/dist/enterprise/WorkOs.js +109 -0
- package/dist/enterprise/WorkOs.js.map +1 -0
- package/dist/files/FileTable.d.ts +937 -0
- package/dist/files/FileTable.d.ts.map +1 -0
- package/dist/files/FileTable.js +79 -0
- package/dist/files/FileTable.js.map +1 -0
- package/dist/files/Files.d.ts +169 -0
- package/dist/files/Files.d.ts.map +1 -0
- package/dist/files/Files.js +1232 -0
- package/dist/files/Files.js.map +1 -0
- package/dist/files/Http.d.ts +13 -0
- package/dist/files/Http.d.ts.map +1 -0
- package/dist/files/Http.js +30 -0
- package/dist/files/Http.js.map +1 -0
- package/dist/files/LocalStorage.d.ts +7 -0
- package/dist/files/LocalStorage.d.ts.map +1 -0
- package/dist/files/LocalStorage.js +284 -0
- package/dist/files/LocalStorage.js.map +1 -0
- package/dist/files/Providers.d.ts +64 -0
- package/dist/files/Providers.d.ts.map +1 -0
- package/dist/files/Providers.js +245 -0
- package/dist/files/Providers.js.map +1 -0
- package/dist/files/S3Storage.d.ts +27 -0
- package/dist/files/S3Storage.d.ts.map +1 -0
- package/dist/files/S3Storage.js +301 -0
- package/dist/files/S3Storage.js.map +1 -0
- package/dist/files/SigV4.d.ts +65 -0
- package/dist/files/SigV4.d.ts.map +1 -0
- package/dist/files/SigV4.js +152 -0
- package/dist/files/SigV4.js.map +1 -0
- package/dist/files/Sniff.d.ts +50 -0
- package/dist/files/Sniff.d.ts.map +1 -0
- package/dist/files/Sniff.js +223 -0
- package/dist/files/Sniff.js.map +1 -0
- package/dist/files/Storage.d.ts +75 -0
- package/dist/files/Storage.d.ts.map +1 -0
- package/dist/files/Storage.js +70 -0
- package/dist/files/Storage.js.map +1 -0
- package/dist/files/module.d.ts +666 -0
- package/dist/files/module.d.ts.map +1 -0
- package/dist/files/module.js +217 -0
- package/dist/files/module.js.map +1 -0
- package/dist/flags/module.d.ts +966 -0
- package/dist/flags/module.d.ts.map +1 -0
- package/dist/flags/module.js +146 -0
- package/dist/flags/module.js.map +1 -0
- package/dist/inbox/Flow.d.ts +49 -0
- package/dist/inbox/Flow.d.ts.map +1 -0
- package/dist/inbox/Flow.js +425 -0
- package/dist/inbox/Flow.js.map +1 -0
- package/dist/inbox/System.d.ts +11 -0
- package/dist/inbox/System.d.ts.map +1 -0
- package/dist/inbox/System.js +26 -0
- package/dist/inbox/System.js.map +1 -0
- package/dist/inbox/approvals.d.ts +1548 -0
- package/dist/inbox/approvals.d.ts.map +1 -0
- package/dist/inbox/approvals.js +268 -0
- package/dist/inbox/approvals.js.map +1 -0
- package/dist/inbox/consent.d.ts +1213 -0
- package/dist/inbox/consent.d.ts.map +1 -0
- package/dist/inbox/consent.js +281 -0
- package/dist/inbox/consent.js.map +1 -0
- package/dist/inbox/index.d.ts +2231 -0
- package/dist/inbox/index.d.ts.map +1 -0
- package/dist/inbox/index.js +22 -0
- package/dist/inbox/index.js.map +1 -0
- package/dist/inbox/notifications.d.ts +2743 -0
- package/dist/inbox/notifications.d.ts.map +1 -0
- package/dist/inbox/notifications.js +362 -0
- package/dist/inbox/notifications.js.map +1 -0
- package/dist/inbox/tables.d.ts +1992 -0
- package/dist/inbox/tables.d.ts.map +1 -0
- package/dist/inbox/tables.js +149 -0
- package/dist/inbox/tables.js.map +1 -0
- package/dist/inbox/workItems.d.ts +1188 -0
- package/dist/inbox/workItems.d.ts.map +1 -0
- package/dist/inbox/workItems.js +158 -0
- package/dist/inbox/workItems.js.map +1 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/dist/ingestion/Chunk.d.ts +15 -0
- package/dist/ingestion/Chunk.d.ts.map +1 -0
- package/dist/ingestion/Chunk.js +49 -0
- package/dist/ingestion/Chunk.js.map +1 -0
- package/dist/ingestion/Extract.d.ts +69 -0
- package/dist/ingestion/Extract.d.ts.map +1 -0
- package/dist/ingestion/Extract.js +376 -0
- package/dist/ingestion/Extract.js.map +1 -0
- package/dist/ingestion/ExtractChild.d.ts +2 -0
- package/dist/ingestion/ExtractChild.d.ts.map +1 -0
- package/dist/ingestion/ExtractChild.js +54 -0
- package/dist/ingestion/ExtractChild.js.map +1 -0
- package/dist/ingestion/ExtractPool.d.ts +38 -0
- package/dist/ingestion/ExtractPool.d.ts.map +1 -0
- package/dist/ingestion/ExtractPool.js +203 -0
- package/dist/ingestion/ExtractPool.js.map +1 -0
- package/dist/ingestion/Ingestion.d.ts +183 -0
- package/dist/ingestion/Ingestion.d.ts.map +1 -0
- package/dist/ingestion/Ingestion.js +650 -0
- package/dist/ingestion/Ingestion.js.map +1 -0
- package/dist/ingestion/Isolated.d.ts +18 -0
- package/dist/ingestion/Isolated.d.ts.map +1 -0
- package/dist/ingestion/Isolated.js +15 -0
- package/dist/ingestion/Isolated.js.map +1 -0
- package/dist/ingestion/Markup.d.ts +29 -0
- package/dist/ingestion/Markup.d.ts.map +1 -0
- package/dist/ingestion/Markup.js +111 -0
- package/dist/ingestion/Markup.js.map +1 -0
- package/dist/ingestion/Pdf.d.ts +6 -0
- package/dist/ingestion/Pdf.d.ts.map +1 -0
- package/dist/ingestion/Pdf.js +192 -0
- package/dist/ingestion/Pdf.js.map +1 -0
- package/dist/ingestion/Runs.d.ts +59 -0
- package/dist/ingestion/Runs.d.ts.map +1 -0
- package/dist/ingestion/Runs.js +128 -0
- package/dist/ingestion/Runs.js.map +1 -0
- package/dist/ingestion/Scrub.d.ts +16 -0
- package/dist/ingestion/Scrub.d.ts.map +1 -0
- package/dist/ingestion/Scrub.js +15 -0
- package/dist/ingestion/Scrub.js.map +1 -0
- package/dist/ingestion/Zip.d.ts +19 -0
- package/dist/ingestion/Zip.d.ts.map +1 -0
- package/dist/ingestion/Zip.js +85 -0
- package/dist/ingestion/Zip.js.map +1 -0
- package/dist/ingestion/module.d.ts +111 -0
- package/dist/ingestion/module.d.ts.map +1 -0
- package/dist/ingestion/module.js +51 -0
- package/dist/ingestion/module.js.map +1 -0
- package/dist/ingress/Definition.d.ts +146 -0
- package/dist/ingress/Definition.d.ts.map +1 -0
- package/dist/ingress/Definition.js +12 -0
- package/dist/ingress/Definition.js.map +1 -0
- package/dist/ingress/Ingress.d.ts +61 -0
- package/dist/ingress/Ingress.d.ts.map +1 -0
- package/dist/ingress/Ingress.js +929 -0
- package/dist/ingress/Ingress.js.map +1 -0
- package/dist/ingress/Verifiers.d.ts +43 -0
- package/dist/ingress/Verifiers.d.ts.map +1 -0
- package/dist/ingress/Verifiers.js +137 -0
- package/dist/ingress/Verifiers.js.map +1 -0
- package/dist/machine/MachineIdentity.d.ts +34 -0
- package/dist/machine/MachineIdentity.d.ts.map +1 -0
- package/dist/machine/MachineIdentity.js +200 -0
- package/dist/machine/MachineIdentity.js.map +1 -0
- package/dist/machine/Managed.d.ts +40 -0
- package/dist/machine/Managed.d.ts.map +1 -0
- package/dist/machine/Managed.js +163 -0
- package/dist/machine/Managed.js.map +1 -0
- package/dist/machine/OAuth.d.ts +11 -0
- package/dist/machine/OAuth.d.ts.map +1 -0
- package/dist/machine/OAuth.js +913 -0
- package/dist/machine/OAuth.js.map +1 -0
- package/dist/machine/Pages.d.ts +64 -0
- package/dist/machine/Pages.d.ts.map +1 -0
- package/dist/machine/Pages.js +54 -0
- package/dist/machine/Pages.js.map +1 -0
- package/dist/machine/Tokens.d.ts +25 -0
- package/dist/machine/Tokens.d.ts.map +1 -0
- package/dist/machine/Tokens.js +62 -0
- package/dist/machine/Tokens.js.map +1 -0
- package/dist/make/Credentials.d.ts +8 -0
- package/dist/make/Credentials.d.ts.map +1 -0
- package/dist/make/Credentials.js +29 -0
- package/dist/make/Credentials.js.map +1 -0
- package/dist/make/Example.d.ts +159 -0
- package/dist/make/Example.d.ts.map +1 -0
- package/dist/make/Example.js +94 -0
- package/dist/make/Example.js.map +1 -0
- package/dist/make/Execute.d.ts +151 -0
- package/dist/make/Execute.d.ts.map +1 -0
- package/dist/make/Execute.js +316 -0
- package/dist/make/Execute.js.map +1 -0
- package/dist/make/Http.d.ts +17 -0
- package/dist/make/Http.d.ts.map +1 -0
- package/dist/make/Http.js +63 -0
- package/dist/make/Http.js.map +1 -0
- package/dist/make/Lifecycle.d.ts +167 -0
- package/dist/make/Lifecycle.d.ts.map +1 -0
- package/dist/make/Lifecycle.js +580 -0
- package/dist/make/Lifecycle.js.map +1 -0
- package/dist/make/Manifest.d.ts +61 -0
- package/dist/make/Manifest.d.ts.map +1 -0
- package/dist/make/Manifest.js +792 -0
- package/dist/make/Manifest.js.map +1 -0
- package/dist/make/Repair.d.ts +111 -0
- package/dist/make/Repair.d.ts.map +1 -0
- package/dist/make/Repair.js +236 -0
- package/dist/make/Repair.js.map +1 -0
- package/dist/make/Runtime.d.ts +144 -0
- package/dist/make/Runtime.d.ts.map +1 -0
- package/dist/make/Runtime.js +309 -0
- package/dist/make/Runtime.js.map +1 -0
- package/dist/make/Session.d.ts +19 -0
- package/dist/make/Session.d.ts.map +1 -0
- package/dist/make/Session.js +27 -0
- package/dist/make/Session.js.map +1 -0
- package/dist/make/SqlGuard.d.ts +48 -0
- package/dist/make/SqlGuard.d.ts.map +1 -0
- package/dist/make/SqlGuard.js +333 -0
- package/dist/make/SqlGuard.js.map +1 -0
- package/dist/make/Subscribe.d.ts +18 -0
- package/dist/make/Subscribe.d.ts.map +1 -0
- package/dist/make/Subscribe.js +175 -0
- package/dist/make/Subscribe.js.map +1 -0
- package/dist/make/Validate.d.ts +47 -0
- package/dist/make/Validate.d.ts.map +1 -0
- package/dist/make/Validate.js +222 -0
- package/dist/make/Validate.js.map +1 -0
- package/dist/make/ViewStep.d.ts +27 -0
- package/dist/make/ViewStep.d.ts.map +1 -0
- package/dist/make/ViewStep.js +43 -0
- package/dist/make/ViewStep.js.map +1 -0
- package/dist/make/module.d.ts +808 -0
- package/dist/make/module.d.ts.map +1 -0
- package/dist/make/module.js +232 -0
- package/dist/make/module.js.map +1 -0
- package/dist/notifications/Decide.d.ts +29 -0
- package/dist/notifications/Decide.d.ts.map +1 -0
- package/dist/notifications/Decide.js +395 -0
- package/dist/notifications/Decide.js.map +1 -0
- package/dist/notifications/Providers.d.ts +110 -0
- package/dist/notifications/Providers.d.ts.map +1 -0
- package/dist/notifications/Providers.js +404 -0
- package/dist/notifications/Providers.js.map +1 -0
- package/dist/notifications/Push.d.ts +189 -0
- package/dist/notifications/Push.d.ts.map +1 -0
- package/dist/notifications/Push.js +457 -0
- package/dist/notifications/Push.js.map +1 -0
- package/dist/notifications/Smtp.d.ts +74 -0
- package/dist/notifications/Smtp.d.ts.map +1 -0
- package/dist/notifications/Smtp.js +344 -0
- package/dist/notifications/Smtp.js.map +1 -0
- package/dist/policy/CedarSchema.d.ts +47 -0
- package/dist/policy/CedarSchema.d.ts.map +1 -0
- package/dist/policy/CedarSchema.js +115 -0
- package/dist/policy/CedarSchema.js.map +1 -0
- package/dist/policy/Compiler.d.ts +364 -0
- package/dist/policy/Compiler.d.ts.map +1 -0
- package/dist/policy/Compiler.js +1311 -0
- package/dist/policy/Compiler.js.map +1 -0
- package/dist/policy/Policy.d.ts +70 -0
- package/dist/policy/Policy.d.ts.map +1 -0
- package/dist/policy/Policy.js +114 -0
- package/dist/policy/Policy.js.map +1 -0
- package/dist/policy/Rls.d.ts +110 -0
- package/dist/policy/Rls.d.ts.map +1 -0
- package/dist/policy/Rls.js +314 -0
- package/dist/policy/Rls.js.map +1 -0
- package/dist/policy/Row.d.ts +17 -0
- package/dist/policy/Row.d.ts.map +1 -0
- package/dist/policy/Row.js +3 -0
- package/dist/policy/Row.js.map +1 -0
- package/dist/privacy/Flow.d.ts +20 -0
- package/dist/privacy/Flow.d.ts.map +1 -0
- package/dist/privacy/Flow.js +193 -0
- package/dist/privacy/Flow.js.map +1 -0
- package/dist/privacy/Inventory.d.ts +110 -0
- package/dist/privacy/Inventory.d.ts.map +1 -0
- package/dist/privacy/Inventory.js +1704 -0
- package/dist/privacy/Inventory.js.map +1 -0
- package/dist/privacy/Sources.d.ts +86 -0
- package/dist/privacy/Sources.d.ts.map +1 -0
- package/dist/privacy/Sources.js +598 -0
- package/dist/privacy/Sources.js.map +1 -0
- package/dist/privacy/Visits.d.ts +21 -0
- package/dist/privacy/Visits.d.ts.map +1 -0
- package/dist/privacy/Visits.js +279 -0
- package/dist/privacy/Visits.js.map +1 -0
- package/dist/privacy/ZeroCvr.d.ts +15 -0
- package/dist/privacy/ZeroCvr.d.ts.map +1 -0
- package/dist/privacy/ZeroCvr.js +63 -0
- package/dist/privacy/ZeroCvr.js.map +1 -0
- package/dist/privacy/module.d.ts +2505 -0
- package/dist/privacy/module.d.ts.map +1 -0
- package/dist/privacy/module.js +228 -0
- package/dist/privacy/module.js.map +1 -0
- package/dist/progress/module.d.ts +1572 -0
- package/dist/progress/module.d.ts.map +1 -0
- package/dist/progress/module.js +139 -0
- package/dist/progress/module.js.map +1 -0
- package/dist/proposals/module.d.ts +275 -0
- package/dist/proposals/module.d.ts.map +1 -0
- package/dist/proposals/module.js +269 -0
- package/dist/proposals/module.js.map +1 -0
- package/dist/query/module.d.ts +91 -0
- package/dist/query/module.d.ts.map +1 -0
- package/dist/query/module.js +50 -0
- package/dist/query/module.js.map +1 -0
- package/dist/records/Access.d.ts +26 -0
- package/dist/records/Access.d.ts.map +1 -0
- package/dist/records/Access.js +43 -0
- package/dist/records/Access.js.map +1 -0
- package/dist/records/References.d.ts +18 -0
- package/dist/records/References.d.ts.map +1 -0
- package/dist/records/References.js +47 -0
- package/dist/records/References.js.map +1 -0
- package/dist/runtime/bun.d.ts +29 -0
- package/dist/runtime/bun.d.ts.map +1 -0
- package/dist/runtime/bun.js +71 -0
- package/dist/runtime/bun.js.map +1 -0
- package/dist/runtime/idle.d.ts +5 -0
- package/dist/runtime/idle.d.ts.map +1 -0
- package/dist/runtime/idle.js +61 -0
- package/dist/runtime/idle.js.map +1 -0
- package/dist/runtime/node.d.ts +36 -0
- package/dist/runtime/node.d.ts.map +1 -0
- package/dist/runtime/node.js +86 -0
- package/dist/runtime/node.js.map +1 -0
- package/dist/runtime/resolve.d.ts +8 -0
- package/dist/runtime/resolve.d.ts.map +1 -0
- package/dist/runtime/resolve.js +136 -0
- package/dist/runtime/resolve.js.map +1 -0
- package/dist/sandbox/Sandbox.d.ts +86 -0
- package/dist/sandbox/Sandbox.d.ts.map +1 -0
- package/dist/sandbox/Sandbox.js +246 -0
- package/dist/sandbox/Sandbox.js.map +1 -0
- package/dist/sandbox/worker.d.ts +93 -0
- package/dist/sandbox/worker.d.ts.map +1 -0
- package/dist/sandbox/worker.js +503 -0
- package/dist/sandbox/worker.js.map +1 -0
- package/dist/scheduler/Automations.d.ts +99 -0
- package/dist/scheduler/Automations.d.ts.map +1 -0
- package/dist/scheduler/Automations.js +247 -0
- package/dist/scheduler/Automations.js.map +1 -0
- package/dist/scheduler/History.d.ts +61 -0
- package/dist/scheduler/History.d.ts.map +1 -0
- package/dist/scheduler/History.js +154 -0
- package/dist/scheduler/History.js.map +1 -0
- package/dist/scheduler/module.d.ts +2365 -0
- package/dist/scheduler/module.d.ts.map +1 -0
- package/dist/scheduler/module.js +370 -0
- package/dist/scheduler/module.js.map +1 -0
- package/dist/search/RecordLock.d.ts +22 -0
- package/dist/search/RecordLock.d.ts.map +1 -0
- package/dist/search/RecordLock.js +21 -0
- package/dist/search/RecordLock.js.map +1 -0
- package/dist/search/Search.d.ts +63 -0
- package/dist/search/Search.d.ts.map +1 -0
- package/dist/search/Search.js +424 -0
- package/dist/search/Search.js.map +1 -0
- package/dist/search/Sources.d.ts +56 -0
- package/dist/search/Sources.d.ts.map +1 -0
- package/dist/search/Sources.js +121 -0
- package/dist/search/Sources.js.map +1 -0
- package/dist/search/module.d.ts +72 -0
- package/dist/search/module.d.ts.map +1 -0
- package/dist/search/module.js +44 -0
- package/dist/search/module.js.map +1 -0
- package/dist/settings/module.d.ts +677 -0
- package/dist/settings/module.d.ts.map +1 -0
- package/dist/settings/module.js +103 -0
- package/dist/settings/module.js.map +1 -0
- package/dist/sharing/module.d.ts +1105 -0
- package/dist/sharing/module.d.ts.map +1 -0
- package/dist/sharing/module.js +295 -0
- package/dist/sharing/module.js.map +1 -0
- package/dist/spaces/module.d.ts +1787 -0
- package/dist/spaces/module.d.ts.map +1 -0
- package/dist/spaces/module.js +248 -0
- package/dist/spaces/module.js.map +1 -0
- package/dist/surfaces/Agent.d.ts +89 -0
- package/dist/surfaces/Agent.d.ts.map +1 -0
- package/dist/surfaces/Agent.js +112 -0
- package/dist/surfaces/Agent.js.map +1 -0
- package/dist/surfaces/CookieGuard.d.ts +77 -0
- package/dist/surfaces/CookieGuard.d.ts.map +1 -0
- package/dist/surfaces/CookieGuard.js +373 -0
- package/dist/surfaces/CookieGuard.js.map +1 -0
- package/dist/surfaces/Http.d.ts +15 -0
- package/dist/surfaces/Http.d.ts.map +1 -0
- package/dist/surfaces/Http.js +250 -0
- package/dist/surfaces/Http.js.map +1 -0
- package/dist/surfaces/Mcp.d.ts +90 -0
- package/dist/surfaces/Mcp.d.ts.map +1 -0
- package/dist/surfaces/Mcp.js +443 -0
- package/dist/surfaces/Mcp.js.map +1 -0
- package/dist/surfaces/Rpc.d.ts +15 -0
- package/dist/surfaces/Rpc.d.ts.map +1 -0
- package/dist/surfaces/Rpc.js +68 -0
- package/dist/surfaces/Rpc.js.map +1 -0
- package/dist/surfaces/headers.d.ts +9 -0
- package/dist/surfaces/headers.d.ts.map +1 -0
- package/dist/surfaces/headers.js +15 -0
- package/dist/surfaces/headers.js.map +1 -0
- package/dist/surfaces/request.d.ts +68 -0
- package/dist/surfaces/request.d.ts.map +1 -0
- package/dist/surfaces/request.js +130 -0
- package/dist/surfaces/request.js.map +1 -0
- package/dist/telemetry/module.d.ts +74 -0
- package/dist/telemetry/module.d.ts.map +1 -0
- package/dist/telemetry/module.js +77 -0
- package/dist/telemetry/module.js.map +1 -0
- package/dist/versioning/module.d.ts +231 -0
- package/dist/versioning/module.d.ts.map +1 -0
- package/dist/versioning/module.js +151 -0
- package/dist/versioning/module.js.map +1 -0
- package/package.json +71 -3
- package/src/AccountMail.ts +218 -0
- package/src/AppConfig.ts +148 -0
- package/src/Approvals.ts +555 -0
- package/src/Audit.ts +381 -0
- package/src/AuthSeam.ts +136 -0
- package/src/Authority.ts +577 -0
- package/src/Avatars.ts +172 -0
- package/src/Base64url.ts +23 -0
- package/src/BasePath.ts +80 -0
- package/src/CallActed.ts +10 -0
- package/src/Config.ts +857 -0
- package/src/DeliveryPolicy.ts +52 -0
- package/src/DesktopSignIn.ts +181 -0
- package/src/Directory.ts +1792 -0
- package/src/Flags.ts +281 -0
- package/src/Gate.ts +159 -0
- package/src/Hash.ts +14 -0
- package/src/Identity.ts +1811 -0
- package/src/IntervalJob.ts +96 -0
- package/src/Invocation.ts +2387 -0
- package/src/KernelHandlers.ts +29 -0
- package/src/KernelModule.ts +165 -0
- package/src/MemberRoutes.ts +146 -0
- package/src/Module.ts +573 -0
- package/src/ModuleIdentity.ts +134 -0
- package/src/Notifications.ts +665 -0
- package/src/Outbox.ts +761 -0
- package/src/Privacy.ts +265 -0
- package/src/Progress.ts +360 -0
- package/src/QuerySurface.ts +559 -0
- package/src/QueryViews.ts +165 -0
- package/src/Readiness.ts +284 -0
- package/src/Redact.ts +22 -0
- package/src/Registry.ts +399 -0
- package/src/Release.ts +1197 -0
- package/src/Retention.ts +167 -0
- package/src/Scheduler.ts +657 -0
- package/src/Server.ts +1838 -0
- package/src/Sessions.ts +56 -0
- package/src/Settings.ts +312 -0
- package/src/Sharing.ts +525 -0
- package/src/Sync.ts +1478 -0
- package/src/Telemetry.ts +754 -0
- package/src/Versioning.ts +588 -0
- package/src/WorkItems.ts +367 -0
- package/src/Workflows.ts +746 -0
- package/src/agent/Admission.ts +37 -0
- package/src/agent/Channels.ts +58 -0
- package/src/agent/Context.ts +430 -0
- package/src/agent/Http.ts +523 -0
- package/src/agent/Metering.ts +625 -0
- package/src/agent/ModelSetup.ts +414 -0
- package/src/agent/Models.ts +850 -0
- package/src/agent/Processors.ts +156 -0
- package/src/agent/Queue.ts +97 -0
- package/src/agent/Receipts.ts +192 -0
- package/src/agent/Resources.ts +376 -0
- package/src/agent/Run.ts +3762 -0
- package/src/agent/Runtime.ts +635 -0
- package/src/agent/Settings.ts +171 -0
- package/src/agent/Skills.ts +118 -0
- package/src/agent/Store.ts +73 -0
- package/src/agent/ToolSearch.ts +152 -0
- package/src/agent/index.ts +68 -0
- package/src/agent/migrations/agent/0000_agent.sql +162 -0
- package/src/agent/migrations/agent/0001_model_call.sql +33 -0
- package/src/agent/migrations/agent/0002_device.sql +2 -0
- package/src/agent/migrations/agent/0003_authority.sql +1 -0
- package/src/agent/migrations/agent/0004_budget_alert.sql +2 -0
- package/src/agent/migrations/agent/0005_feedback.sql +13 -0
- package/src/agent/migrations/agent/0095_run_options.sql +3 -0
- package/src/agent/migrations/agent/0096_conversation_meta.sql +7 -0
- package/src/agent/migrations/agent/0097_submission.sql +26 -0
- package/src/agent/migrations/agent/0098_threads.sql +21 -0
- package/src/agent/migrations/agent/0099_submission_refused.sql +4 -0
- package/src/agent/migrations/agent/0142_teams.sql +19 -0
- package/src/agent/module.ts +1793 -0
- package/src/appState/Sweep.ts +66 -0
- package/src/appState/migrations/0000_app_state.sql +35 -0
- package/src/appState/module.ts +418 -0
- package/src/audit/migrations/README.md +1 -0
- package/src/audit/module.ts +95 -0
- package/src/auth/AuthProvider.ts +293 -0
- package/src/auth/BetterAuthProvider.ts +476 -0
- package/src/auth/Methods.ts +7 -0
- package/src/auth/SessionTokens.ts +156 -0
- package/src/collab/Collab.ts +708 -0
- package/src/collab/Housekeeping.ts +193 -0
- package/src/collab/LiveCopy.ts +98 -0
- package/src/collab/Socket.ts +380 -0
- package/src/collab/Store.ts +105 -0
- package/src/collab/Ydoc.ts +337 -0
- package/src/collab/derive/bundle.gen.ts +2 -0
- package/src/collab/derive/entry.ts +34 -0
- package/src/collab/derive/polyfill.ts +15 -0
- package/src/collab/migrations/.gitkeep +0 -0
- package/src/collab/module.ts +237 -0
- package/src/connections/Connections.ts +2315 -0
- package/src/connections/Connector.ts +304 -0
- package/src/connections/Crypto.ts +134 -0
- package/src/connections/Destinations.ts +351 -0
- package/src/connections/Discovery.ts +251 -0
- package/src/connections/EffectKinds.ts +30 -0
- package/src/connections/Effects.ts +541 -0
- package/src/connections/Metering.ts +205 -0
- package/src/connections/ProviderApi.ts +137 -0
- package/src/connections/Secrets.ts +581 -0
- package/src/connections/Sync.ts +318 -0
- package/src/connections/migrations/.gitkeep +0 -0
- package/src/connections/module.ts +584 -0
- package/src/data/Corpus.ts +434 -0
- package/src/data/Datasets.ts +479 -0
- package/src/data/Programs.ts +285 -0
- package/src/data/migrations/README.md +1 -0
- package/src/data/module.ts +177 -0
- package/src/db/Bootstrap.ts +2832 -0
- package/src/db/Catalog.ts +10 -0
- package/src/db/Conflicts.ts +42 -0
- package/src/db/DirectoryLock.ts +19 -0
- package/src/db/HandlerGate.ts +107 -0
- package/src/db/Host.ts +250 -0
- package/src/db/KernelSchema.ts +4422 -0
- package/src/db/MigrationCheck.ts +221 -0
- package/src/db/QueryViewCheck.ts +1035 -0
- package/src/db/ReadOnly.ts +23 -0
- package/src/db/Scram.ts +20 -0
- package/src/db/SqlState.ts +77 -0
- package/src/db/Startup.ts +25 -0
- package/src/db/ZeroDdl.ts +272 -0
- package/src/db/ZeroPush.ts +128 -0
- package/src/db/schema.snapshot.json +13831 -0
- package/src/devices/Devices.ts +1219 -0
- package/src/devices/Flow.ts +198 -0
- package/src/devices/Http.ts +212 -0
- package/src/devices/migrations/0000_devices.sql +53 -0
- package/src/devices/migrations/0001_parent_run.sql +2 -0
- package/src/devices/migrations/0002_authority.sql +1 -0
- package/src/devices/migrations/0003_follow_up.sql +4 -0
- package/src/devices/migrations/0004_commands.sql +30 -0
- package/src/devices/migrations/0005_command_cancel.sql +7 -0
- package/src/devices/module.ts +313 -0
- package/src/durable/Cluster.ts +90 -0
- package/src/durable/Definition.ts +244 -0
- package/src/durable/Schedule.ts +155 -0
- package/src/durable/Trust.ts +149 -0
- package/src/enterprise/Routes.ts +501 -0
- package/src/enterprise/WorkOs.ts +133 -0
- package/src/files/FileTable.ts +84 -0
- package/src/files/Files.ts +1652 -0
- package/src/files/Http.ts +46 -0
- package/src/files/LocalStorage.ts +348 -0
- package/src/files/Providers.ts +356 -0
- package/src/files/S3Storage.ts +403 -0
- package/src/files/SigV4.ts +222 -0
- package/src/files/Sniff.ts +218 -0
- package/src/files/Storage.ts +143 -0
- package/src/files/migrations/README.md +1 -0
- package/src/files/module.ts +282 -0
- package/src/flags/migrations/0000_flags.sql +20 -0
- package/src/flags/module.ts +178 -0
- package/src/inbox/Flow.ts +548 -0
- package/src/inbox/System.ts +33 -0
- package/src/inbox/approvals.ts +335 -0
- package/src/inbox/consent.ts +331 -0
- package/src/inbox/index.ts +24 -0
- package/src/inbox/migrations/approvals/0000_approvals.sql +36 -0
- package/src/inbox/migrations/approvals/0001_provenance.sql +1 -0
- package/src/inbox/migrations/approvals/0002_withdrawn.sql +3 -0
- package/src/inbox/migrations/approvals/0003_title.sql +11 -0
- package/src/inbox/migrations/consent/0000_consent.sql +31 -0
- package/src/inbox/migrations/consent/0001_consent_revoked.sql +3 -0
- package/src/inbox/migrations/consent/0002_permission_request.sql +1 -0
- package/src/inbox/migrations/consent/0003_title.sql +11 -0
- package/src/inbox/migrations/inbox/0000_work_items.sql +31 -0
- package/src/inbox/migrations/notifications/0000_notifications.sql +66 -0
- package/src/inbox/notifications.ts +471 -0
- package/src/inbox/tables.ts +163 -0
- package/src/inbox/workItems.ts +199 -0
- package/src/index.ts +229 -0
- package/src/ingestion/Chunk.ts +49 -0
- package/src/ingestion/Extract.ts +387 -0
- package/src/ingestion/ExtractChild.ts +67 -0
- package/src/ingestion/ExtractPool.ts +270 -0
- package/src/ingestion/Ingestion.ts +929 -0
- package/src/ingestion/Isolated.ts +26 -0
- package/src/ingestion/Markup.ts +117 -0
- package/src/ingestion/Pdf.ts +167 -0
- package/src/ingestion/Runs.ts +192 -0
- package/src/ingestion/Scrub.ts +22 -0
- package/src/ingestion/Zip.ts +87 -0
- package/src/ingestion/migrations/README.md +1 -0
- package/src/ingestion/module.ts +65 -0
- package/src/ingress/Definition.ts +158 -0
- package/src/ingress/Ingress.ts +1220 -0
- package/src/ingress/Verifiers.ts +166 -0
- package/src/machine/MachineIdentity.ts +310 -0
- package/src/machine/Managed.ts +228 -0
- package/src/machine/OAuth.ts +1140 -0
- package/src/machine/Pages.ts +139 -0
- package/src/machine/Tokens.ts +75 -0
- package/src/make/Credentials.ts +36 -0
- package/src/make/Example.ts +104 -0
- package/src/make/Execute.ts +534 -0
- package/src/make/Http.ts +71 -0
- package/src/make/Lifecycle.ts +911 -0
- package/src/make/Manifest.ts +884 -0
- package/src/make/Repair.ts +262 -0
- package/src/make/Runtime.ts +494 -0
- package/src/make/Session.ts +33 -0
- package/src/make/SqlGuard.ts +362 -0
- package/src/make/Subscribe.ts +282 -0
- package/src/make/Validate.ts +247 -0
- package/src/make/ViewStep.ts +64 -0
- package/src/make/migrations/README.md +1 -0
- package/src/make/module.ts +261 -0
- package/src/notifications/Decide.ts +483 -0
- package/src/notifications/Providers.ts +532 -0
- package/src/notifications/Push.ts +594 -0
- package/src/notifications/Smtp.ts +379 -0
- package/src/policy/CedarSchema.ts +156 -0
- package/src/policy/Compiler.ts +1627 -0
- package/src/policy/Policy.ts +178 -0
- package/src/policy/Rls.ts +460 -0
- package/src/policy/Row.ts +15 -0
- package/src/privacy/Flow.ts +283 -0
- package/src/privacy/Inventory.ts +2414 -0
- package/src/privacy/Sources.ts +831 -0
- package/src/privacy/Visits.ts +339 -0
- package/src/privacy/ZeroCvr.ts +66 -0
- package/src/privacy/migrations/0000_privacy.sql +48 -0
- package/src/privacy/module.ts +280 -0
- package/src/progress/migrations/0000_progress.sql +27 -0
- package/src/progress/migrations/0001_notify.sql +1 -0
- package/src/progress/module.ts +161 -0
- package/src/proposals/migrations/README.md +1 -0
- package/src/proposals/module.ts +338 -0
- package/src/query/migrations/README.md +1 -0
- package/src/query/module.ts +66 -0
- package/src/records/Access.ts +97 -0
- package/src/records/References.ts +65 -0
- package/src/runtime/bun.ts +131 -0
- package/src/runtime/idle.ts +88 -0
- package/src/runtime/node.ts +140 -0
- package/src/runtime/resolve.ts +141 -0
- package/src/sandbox/Sandbox.ts +330 -0
- package/src/sandbox/worker.ts +577 -0
- package/src/scheduler/Automations.ts +319 -0
- package/src/scheduler/History.ts +231 -0
- package/src/scheduler/migrations/0000_schedules.sql +11 -0
- package/src/scheduler/migrations/0001_resumed_at.sql +1 -0
- package/src/scheduler/migrations/0002_origin.sql +3 -0
- package/src/scheduler/migrations/0003_authority.sql +1 -0
- package/src/scheduler/migrations/0004_operate.sql +18 -0
- package/src/scheduler/module.ts +445 -0
- package/src/search/RecordLock.ts +25 -0
- package/src/search/Search.ts +563 -0
- package/src/search/Sources.ts +157 -0
- package/src/search/migrations/README.md +1 -0
- package/src/search/module.ts +49 -0
- package/src/settings/migrations/0000_settings.sql +15 -0
- package/src/settings/module.ts +126 -0
- package/src/sharing/migrations/0000_access_requests.sql +17 -0
- package/src/sharing/module.ts +351 -0
- package/src/spaces/migrations/0000_spaces.sql +35 -0
- package/src/spaces/module.ts +287 -0
- package/src/surfaces/Agent.ts +224 -0
- package/src/surfaces/CookieGuard.ts +433 -0
- package/src/surfaces/Http.ts +341 -0
- package/src/surfaces/Mcp.ts +585 -0
- package/src/surfaces/Rpc.ts +101 -0
- package/src/surfaces/headers.ts +16 -0
- package/src/surfaces/request.ts +173 -0
- package/src/telemetry/migrations/.gitkeep +0 -0
- package/src/telemetry/module.ts +94 -0
- package/src/versioning/migrations/.gitkeep +0 -0
- package/src/versioning/module.ts +194 -0
package/src/Release.ts
ADDED
|
@@ -0,0 +1,1197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Release (contract: `@eloxiv/contracts` `ReleaseContract`, docs/contracts/release.md): how a deployment's
|
|
3
|
+
* kernel is migrated and released.
|
|
4
|
+
*
|
|
5
|
+
* - **A lease.** Setup holds a PostgreSQL session advisory lock on the app's database for its whole run, with
|
|
6
|
+
* an owner row (`eloxiv.release_lease`) renewed while it runs. Another setup waits for it (up to `waitMs`),
|
|
7
|
+
* then fails with `ReleaseLeaseHeld` naming the holder; a lock held past the row's expiry is a stuck holder,
|
|
8
|
+
* reported at once. The lock goes with the holder's session, so a crashed setup never blocks the next.
|
|
9
|
+
* - **Module migrations as their owner, then one transaction.** Each module's migrations run on a session that
|
|
10
|
+
* logs in as the module's owner role, in its own transaction, which leaves the module closed (row-level
|
|
11
|
+
* security forced, no policy, no privilege) and commits only once its checks pass. Then, in one transaction
|
|
12
|
+
* on setup's own session: Better Auth's, the kernel's and Effect cluster's migrations, the hardening
|
|
13
|
+
* (privileges, row-level security, triggers, the recorded security state), the published query views, the
|
|
14
|
+
* sync publication and the schema snapshots. A failure in it leaves migrated modules closed, never open. A
|
|
15
|
+
* migration declared `-- eloxiv:no-transaction` (index builds `CONCURRENTLY`) runs alone between two such
|
|
16
|
+
* rounds; transaction control, role changes, SQL that does not parse and statements that cannot run in a
|
|
17
|
+
* transaction in an undeclared migration are refused before anything runs.
|
|
18
|
+
* - **Schema snapshots.** After hardening, each module's schema (and the kernel's) is described from the
|
|
19
|
+
* catalogue, canonically, and recorded with its fingerprint; `status` compares the live schema with it.
|
|
20
|
+
* - **Version skew.** The kernel advertises its release at `GET /release`; writes from a client whose
|
|
21
|
+
* `x-eloxiv-client-version` is older than the minimum are refused with `ClientOutdated` (see Invocation).
|
|
22
|
+
*/
|
|
23
|
+
import { PgClient } from "@effect/sql-pg"
|
|
24
|
+
import type { ReleaseInfo, ReleaseLease, ReleaseRecord, ReleaseStatus, SchemaSnapshotRecord } from "@eloxiv/contracts"
|
|
25
|
+
import { MigrationFailed, ReleaseLeaseHeld, satisfiesRange } from "@eloxiv/contracts"
|
|
26
|
+
import { Cause, Context, Duration, Effect, Exit, Layer, Redacted, Schedule, type Scope } from "effect"
|
|
27
|
+
import * as Reactivity from "effect/reactivity/Reactivity"
|
|
28
|
+
import { SqlClient } from "effect/sql"
|
|
29
|
+
import { canonicalJson, sha256 } from "./Hash.ts"
|
|
30
|
+
import type { AnyKernelModule } from "./Module.ts"
|
|
31
|
+
import {
|
|
32
|
+
bootstrapModules,
|
|
33
|
+
closeModule,
|
|
34
|
+
dropQueryViews,
|
|
35
|
+
dropSurfaceViews,
|
|
36
|
+
ensurePublication,
|
|
37
|
+
hardenModules,
|
|
38
|
+
kernelSecurityState,
|
|
39
|
+
kernelStateDifferences,
|
|
40
|
+
migrateCluster,
|
|
41
|
+
markCurrentMigration,
|
|
42
|
+
moduleSessionHygiene,
|
|
43
|
+
OWNER_LOGIN_LOCK,
|
|
44
|
+
planMigrations,
|
|
45
|
+
platformTableAccess,
|
|
46
|
+
publishModuleViews,
|
|
47
|
+
publishPlatformReads,
|
|
48
|
+
publishSurfaceViews,
|
|
49
|
+
recordedKernelState,
|
|
50
|
+
recordKernelState,
|
|
51
|
+
readModuleMigrations,
|
|
52
|
+
securityDifferences,
|
|
53
|
+
securityState,
|
|
54
|
+
UnsafeModuleSchema,
|
|
55
|
+
unsafeModuleObjects,
|
|
56
|
+
} from "./db/Bootstrap.ts"
|
|
57
|
+
import { allKernelMigrations, CLUSTER_SCHEMA, type Migration } from "./db/KernelSchema.ts"
|
|
58
|
+
import { migrationProblems, splitStatements, statementsOf } from "./db/MigrationCheck.ts"
|
|
59
|
+
import { type HostProfile, hostDifferences } from "./db/Host.ts"
|
|
60
|
+
import { hasZeroDdl, pauseZeroDdl, resumeZeroDdl, zeroDdlLeftPaused } from "./db/ZeroDdl.ts"
|
|
61
|
+
import { syncRecordSources } from "./search/Sources.ts"
|
|
62
|
+
|
|
63
|
+
/** The kernel's own migrations and snapshot are recorded under this module name. */
|
|
64
|
+
export const KERNEL_MODULE = "eloxiv"
|
|
65
|
+
/** The schemas the kernel's snapshot describes. */
|
|
66
|
+
export const KERNEL_SCHEMAS: ReadonlyArray<string> = ["eloxiv", "eloxiv_ctx", "eloxiv_setup", CLUSTER_SCHEMA]
|
|
67
|
+
|
|
68
|
+
/** The advisory lock key of the migration lease (on the app's database). */
|
|
69
|
+
export const LEASE_KEY = 4_242_002
|
|
70
|
+
|
|
71
|
+
const ident = (name: string): string => {
|
|
72
|
+
if (!/^[a-z_][a-z0-9_]*$/.test(name)) throw new Error(`Unsafe SQL identifier: ${name}`)
|
|
73
|
+
return `"${name}"`
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const iso = (column: string) => `to_char(${column} AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"')`
|
|
77
|
+
|
|
78
|
+
const messageOf = (error: unknown): string => {
|
|
79
|
+
const e = error as { reason?: { cause?: { message?: string } }; message?: string } | undefined
|
|
80
|
+
return e?.reason?.cause?.message ?? e?.message ?? String(error)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
84
|
+
// Version skew
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Compare two versions (`major.minor.patch`, any number of numeric parts, optional `-prerelease`): negative
|
|
88
|
+
* when `a` is older. A prerelease is older than its release. `undefined` when either is not a version.
|
|
89
|
+
*/
|
|
90
|
+
export const compareVersions = (a: string, b: string): number | undefined => {
|
|
91
|
+
const parse = (v: string) => {
|
|
92
|
+
const match = /^v?(\d+(?:\.\d+)*)(?:-([0-9A-Za-z.-]+))?$/.exec(v.trim())
|
|
93
|
+
return match === null ? undefined : { parts: match[1]!.split(".").map(Number), pre: match[2] }
|
|
94
|
+
}
|
|
95
|
+
const x = parse(a)
|
|
96
|
+
const y = parse(b)
|
|
97
|
+
if (x === undefined || y === undefined) return undefined
|
|
98
|
+
for (let i = 0; i < Math.max(x.parts.length, y.parts.length); i++) {
|
|
99
|
+
const d = (x.parts[i] ?? 0) - (y.parts[i] ?? 0)
|
|
100
|
+
if (d !== 0) return Math.sign(d)
|
|
101
|
+
}
|
|
102
|
+
if (x.pre === y.pre) return 0
|
|
103
|
+
if (x.pre === undefined) return 1
|
|
104
|
+
if (y.pre === undefined) return -1
|
|
105
|
+
return x.pre < y.pre ? -1 : 1
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
109
|
+
// Module versions (the Versioning contract)
|
|
110
|
+
|
|
111
|
+
/** The kernel's own version: what modules' `kernel` ranges are checked against, and what `/release` reports. */
|
|
112
|
+
export const KERNEL_VERSION = "0.1.1"
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Why setup must refuse these modules on this kernel: a declared kernel range that excludes `kernelVersion` (or
|
|
116
|
+
* cannot be read), or a module version older than the one installed (a downgrade). Reads the installed versions
|
|
117
|
+
* when the table exists (a fresh database has none).
|
|
118
|
+
*/
|
|
119
|
+
export const moduleVersionProblems = (
|
|
120
|
+
sql: SqlClient.SqlClient,
|
|
121
|
+
modules: ReadonlyArray<AnyKernelModule>,
|
|
122
|
+
kernelVersion: string,
|
|
123
|
+
) =>
|
|
124
|
+
Effect.gen(function* () {
|
|
125
|
+
const problems: Array<{ readonly module: string; readonly message: string }> = []
|
|
126
|
+
const [exists] = yield* sql<{ present: boolean }>`
|
|
127
|
+
SELECT pg_catalog.to_regclass('eloxiv.module_version') IS NOT NULL AS present`
|
|
128
|
+
const installed = new Map<string, string>()
|
|
129
|
+
if (exists?.present === true) {
|
|
130
|
+
for (const row of yield* sql<{
|
|
131
|
+
module: string
|
|
132
|
+
version: string
|
|
133
|
+
}>`SELECT module, version FROM eloxiv.module_version`) {
|
|
134
|
+
installed.set(row.module, row.version)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const module of modules) {
|
|
138
|
+
const name = module.contract.name
|
|
139
|
+
const range = module.contract.kernel ?? "*"
|
|
140
|
+
const fits = satisfiesRange(kernelVersion, range)
|
|
141
|
+
if (fits !== true) {
|
|
142
|
+
problems.push({
|
|
143
|
+
module: name,
|
|
144
|
+
message:
|
|
145
|
+
fits === undefined
|
|
146
|
+
? `Module ${name} declares kernel range ${range}, which cannot be read`
|
|
147
|
+
: `Module ${name} ${module.contract.version} works with kernel ${range}; this kernel is ${kernelVersion}`,
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
const previous = installed.get(name)
|
|
151
|
+
const order = previous === undefined ? undefined : compareVersions(module.contract.version, previous)
|
|
152
|
+
// A MAKE module goes back only by MAKE's rollback (an administrator's, to a version installed before, over
|
|
153
|
+
// migrations that are additive and rollback-safe); its lifecycle refuses any other older version.
|
|
154
|
+
const rollback = module.make !== undefined && order !== undefined
|
|
155
|
+
if (previous !== undefined && (order === undefined || order < 0) && !rollback) {
|
|
156
|
+
problems.push({
|
|
157
|
+
module: name,
|
|
158
|
+
message: `Module ${name} ${module.contract.version} is older than the installed ${previous}: setup does not downgrade a module`,
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return problems
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
/** Record each module's version, and a history row for every module whose version changed (or is new). */
|
|
166
|
+
export const recordModuleVersions = (
|
|
167
|
+
sql: SqlClient.SqlClient,
|
|
168
|
+
modules: ReadonlyArray<AnyKernelModule>,
|
|
169
|
+
kernelVersion: string,
|
|
170
|
+
) =>
|
|
171
|
+
Effect.forEach(
|
|
172
|
+
modules,
|
|
173
|
+
(module) =>
|
|
174
|
+
Effect.gen(function* () {
|
|
175
|
+
const name = module.contract.name
|
|
176
|
+
const version = module.contract.version
|
|
177
|
+
const [previous] = yield* sql<{ version: string }>`
|
|
178
|
+
SELECT version FROM eloxiv.module_version WHERE module = ${name} FOR UPDATE`
|
|
179
|
+
if (previous?.version === version) return
|
|
180
|
+
yield* sql`INSERT INTO eloxiv.module_version_history (module, from_version, to_version, kernel_version)
|
|
181
|
+
VALUES (${name}, ${previous?.version ?? null}, ${version}, ${kernelVersion})`
|
|
182
|
+
yield* sql`INSERT INTO eloxiv.module_version (module, version, kernel_range)
|
|
183
|
+
VALUES (${name}, ${version}, ${module.contract.kernel ?? "*"})
|
|
184
|
+
ON CONFLICT (module) DO UPDATE SET version = EXCLUDED.version, kernel_range = EXCLUDED.kernel_range,
|
|
185
|
+
updated_at = now()`
|
|
186
|
+
}),
|
|
187
|
+
{ discard: true },
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
/** The app's release settings: its build version and the oldest client version writes are accepted from. */
|
|
191
|
+
export class ReleaseSettings extends Context.Service<
|
|
192
|
+
ReleaseSettings,
|
|
193
|
+
{ readonly appVersion: string | undefined; readonly minClientVersion: string | undefined }
|
|
194
|
+
>()("@eloxiv/kernel/ReleaseSettings") {}
|
|
195
|
+
|
|
196
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
197
|
+
// Migrations
|
|
198
|
+
|
|
199
|
+
export { migrationProblems } from "./db/MigrationCheck.ts"
|
|
200
|
+
|
|
201
|
+
const appliedNames = (sql: SqlClient.SqlClient, module: string) =>
|
|
202
|
+
sql<{ name: string }>`SELECT name FROM eloxiv.module_migration WHERE module = ${module} ORDER BY name`.pipe(
|
|
203
|
+
Effect.map((rows) => rows.map((r) => r.name)),
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Apply `module`'s pending migrations in order, each in a savepoint as `role`, up to (not including) the first
|
|
208
|
+
* pending non-transactional one. A failure is the migration's `MigrationFailed`.
|
|
209
|
+
*
|
|
210
|
+
* After each migration, setup checks it is still in the transaction it started (`xid`) and still the role it
|
|
211
|
+
* set: the preflight refuses transaction control and role changes, and this catches anything that got past it
|
|
212
|
+
* (the transaction then fails rather than commit with what the migration left).
|
|
213
|
+
*/
|
|
214
|
+
/**
|
|
215
|
+
* Run a migration's statements on `sql`, one statement at a time (each chunk is split with PostgreSQL's grammar).
|
|
216
|
+
* In a database zero-cache replicates, setup's own event trigger announces each schema change where it happens
|
|
217
|
+
* (ZeroDdl.ts).
|
|
218
|
+
*/
|
|
219
|
+
const runStatements = (sql: SqlClient.SqlClient, chunks: ReadonlyArray<string>) =>
|
|
220
|
+
Effect.gen(function* () {
|
|
221
|
+
for (const chunk of chunks) {
|
|
222
|
+
for (const statement of yield* statementsOf(chunk)) yield* sql.unsafe(statement.text)
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
const applyPending = (
|
|
227
|
+
sql: SqlClient.SqlClient,
|
|
228
|
+
module: string,
|
|
229
|
+
role: string,
|
|
230
|
+
migrations: ReadonlyArray<Migration>,
|
|
231
|
+
xid: string,
|
|
232
|
+
) =>
|
|
233
|
+
Effect.gen(function* () {
|
|
234
|
+
const applied = new Set(yield* appliedNames(sql, module))
|
|
235
|
+
const done: Array<string> = []
|
|
236
|
+
for (const migration of migrations) {
|
|
237
|
+
if (applied.has(migration.name)) continue
|
|
238
|
+
if (migration.transactional === false) break
|
|
239
|
+
yield* sql
|
|
240
|
+
.withTransaction(
|
|
241
|
+
Effect.gen(function* () {
|
|
242
|
+
yield* sql.unsafe(`SET LOCAL ROLE ${ident(role)}`)
|
|
243
|
+
yield* runStatements(sql, migration.statements)
|
|
244
|
+
const [now] = yield* sql<{ xid: string; role: string }>`
|
|
245
|
+
SELECT txid_current()::text AS xid, current_user AS role`
|
|
246
|
+
if (now?.xid !== xid || now.role !== role) {
|
|
247
|
+
return yield* Effect.fail(
|
|
248
|
+
new MigrationFailed({
|
|
249
|
+
module,
|
|
250
|
+
migration: migration.name,
|
|
251
|
+
message:
|
|
252
|
+
now?.xid !== xid
|
|
253
|
+
? `${module}/${migration.name} ended setup's transaction; migrations may not control transactions`
|
|
254
|
+
: `${module}/${migration.name} changed the role it runs as (to ${now.role}); migrations run as ${role}`,
|
|
255
|
+
}),
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
yield* sql.unsafe(`RESET ROLE`)
|
|
259
|
+
yield* sql`INSERT INTO eloxiv.module_migration (module, name) VALUES (${module}, ${migration.name})`
|
|
260
|
+
}),
|
|
261
|
+
)
|
|
262
|
+
.pipe(
|
|
263
|
+
Effect.mapError((e) =>
|
|
264
|
+
e instanceof MigrationFailed
|
|
265
|
+
? e
|
|
266
|
+
: new MigrationFailed({ module, migration: migration.name, message: messageOf(e) }),
|
|
267
|
+
),
|
|
268
|
+
)
|
|
269
|
+
done.push(migration.name)
|
|
270
|
+
}
|
|
271
|
+
return done
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
/** The first pending migration of `module`, if it is a declared non-transactional one. */
|
|
275
|
+
const pendingOutside = (sql: SqlClient.SqlClient, module: string, migrations: ReadonlyArray<Migration>) =>
|
|
276
|
+
Effect.map(appliedNames(sql, module), (names) => {
|
|
277
|
+
const applied = new Set(names)
|
|
278
|
+
const next = migrations.find((m) => !applied.has(m.name))
|
|
279
|
+
return next?.transactional === false ? next : undefined
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
283
|
+
// Schema snapshots
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* A canonical description of `schemas` from the catalogue: relations with their columns, owners and sorted
|
|
287
|
+
* privileges, constraints, indexes, views, triggers, row-level security policies and functions. No object
|
|
288
|
+
* ids, so two databases built by the same migrations describe alike. Run with `pg_catalog` as the search
|
|
289
|
+
* path (names in definitions are then always qualified).
|
|
290
|
+
*/
|
|
291
|
+
export const schemaSnapshot = (sql: SqlClient.SqlClient, schemas: ReadonlyArray<string>) =>
|
|
292
|
+
Effect.gen(function* () {
|
|
293
|
+
const list = [...schemas]
|
|
294
|
+
const [row] = yield* sql<{ snapshot: unknown }>`
|
|
295
|
+
SELECT jsonb_build_object(
|
|
296
|
+
'schemas', (SELECT coalesce(jsonb_agg(jsonb_build_object('name', n.nspname,
|
|
297
|
+
'owner', pg_get_userbyid(n.nspowner),
|
|
298
|
+
'acl', (SELECT coalesce(jsonb_agg(a ORDER BY a), '[]') FROM unnest(n.nspacl::text[]) a)) ORDER BY n.nspname), '[]')
|
|
299
|
+
FROM pg_catalog.pg_namespace n WHERE n.nspname = ANY(${list})),
|
|
300
|
+
'relations', (SELECT coalesce(jsonb_agg(jsonb_build_object(
|
|
301
|
+
'name', n.nspname || '.' || c.relname, 'kind', c.relkind, 'owner', pg_get_userbyid(c.relowner),
|
|
302
|
+
'rls', c.relrowsecurity, 'forceRls', c.relforcerowsecurity, 'options', c.reloptions,
|
|
303
|
+
'acl', (SELECT coalesce(jsonb_agg(a ORDER BY a), '[]') FROM unnest(c.relacl::text[]) a),
|
|
304
|
+
'columns', (SELECT coalesce(jsonb_agg(jsonb_build_object('name', a.attname,
|
|
305
|
+
'type', format_type(a.atttypid, a.atttypmod), 'notNull', a.attnotnull,
|
|
306
|
+
'default', pg_get_expr(d.adbin, d.adrelid), 'identity', a.attidentity, 'generated', a.attgenerated)
|
|
307
|
+
ORDER BY a.attnum), '[]')
|
|
308
|
+
FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_attrdef d ON d.adrelid = a.attrelid AND d.adnum = a.attnum
|
|
309
|
+
WHERE a.attrelid = c.oid AND a.attnum > 0 AND NOT a.attisdropped))
|
|
310
|
+
ORDER BY n.nspname, c.relname), '[]')
|
|
311
|
+
FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
312
|
+
WHERE n.nspname = ANY(${list}) AND c.relkind IN ('r', 'p', 'v', 'm', 'S', 'f')),
|
|
313
|
+
'constraints', (SELECT coalesce(jsonb_agg(jsonb_build_object('name', c.conname,
|
|
314
|
+
'on', c.conrelid::regclass::text, 'definition', pg_get_constraintdef(c.oid))
|
|
315
|
+
ORDER BY c.conrelid::regclass::text, c.conname), '[]')
|
|
316
|
+
FROM pg_catalog.pg_constraint c JOIN pg_catalog.pg_namespace n ON n.oid = c.connamespace WHERE n.nspname = ANY(${list})),
|
|
317
|
+
'indexes', (SELECT coalesce(jsonb_agg(jsonb_build_object('name', i.schemaname || '.' || i.indexname,
|
|
318
|
+
'definition', i.indexdef) ORDER BY i.schemaname, i.indexname), '[]')
|
|
319
|
+
FROM pg_catalog.pg_indexes i WHERE i.schemaname = ANY(${list})),
|
|
320
|
+
'views', (SELECT coalesce(jsonb_agg(jsonb_build_object('name', v.schemaname || '.' || v.viewname,
|
|
321
|
+
'definition', v.definition) ORDER BY v.schemaname, v.viewname), '[]')
|
|
322
|
+
FROM pg_catalog.pg_views v WHERE v.schemaname = ANY(${list})),
|
|
323
|
+
'triggers', (SELECT coalesce(jsonb_agg(jsonb_build_object('name', t.tgname,
|
|
324
|
+
'definition', pg_get_triggerdef(t.oid), 'enabled', t.tgenabled) ORDER BY t.tgrelid::regclass::text, t.tgname), '[]')
|
|
325
|
+
FROM pg_catalog.pg_trigger t JOIN pg_catalog.pg_class c ON c.oid = t.tgrelid JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
326
|
+
WHERE n.nspname = ANY(${list}) AND NOT t.tgisinternal),
|
|
327
|
+
'policies', (SELECT coalesce(jsonb_agg(jsonb_build_object('name', p.schemaname || '.' || p.tablename || '.' || p.policyname,
|
|
328
|
+
'permissive', p.permissive, 'roles', p.roles, 'command', p.cmd, 'using', p.qual, 'check', p.with_check)
|
|
329
|
+
ORDER BY p.schemaname, p.tablename, p.policyname), '[]')
|
|
330
|
+
FROM pg_catalog.pg_policies p WHERE p.schemaname = ANY(${list})),
|
|
331
|
+
'functions', (SELECT coalesce(jsonb_agg(jsonb_build_object(
|
|
332
|
+
'name', n.nspname || '.' || p.proname || '(' || pg_get_function_identity_arguments(p.oid) || ')',
|
|
333
|
+
'returns', pg_get_function_result(p.oid), 'securityDefiner', p.prosecdef, 'volatility', p.provolatile,
|
|
334
|
+
'config', p.proconfig, 'source', p.prosrc,
|
|
335
|
+
'acl', (SELECT coalesce(jsonb_agg(a ORDER BY a), '[]') FROM unnest(p.proacl::text[]) a))
|
|
336
|
+
ORDER BY n.nspname, p.proname, pg_get_function_identity_arguments(p.oid)), '[]')
|
|
337
|
+
FROM pg_catalog.pg_proc p JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace WHERE n.nspname = ANY(${list}))
|
|
338
|
+
) AS snapshot`
|
|
339
|
+
const snapshot = row!.snapshot
|
|
340
|
+
const fingerprint = yield* Effect.promise(() => sha256(canonicalJson(snapshot)))
|
|
341
|
+
return { fingerprint, snapshot }
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
/** The schemas a module's snapshot describes. */
|
|
345
|
+
const schemasOf = (module: AnyKernelModule | typeof KERNEL_MODULE) =>
|
|
346
|
+
module === KERNEL_MODULE ? KERNEL_SCHEMAS : [module.schema]
|
|
347
|
+
const nameOf = (module: AnyKernelModule | typeof KERNEL_MODULE) =>
|
|
348
|
+
module === KERNEL_MODULE ? KERNEL_MODULE : module.contract.name
|
|
349
|
+
|
|
350
|
+
/** Record every module's snapshot (and the kernel's), in the setup's transaction. */
|
|
351
|
+
const recordSnapshots = (sql: SqlClient.SqlClient, modules: ReadonlyArray<AnyKernelModule>) =>
|
|
352
|
+
Effect.gen(function* () {
|
|
353
|
+
// Deterministic definitions: every name outside pg_catalog is printed qualified.
|
|
354
|
+
yield* sql.unsafe(`SET LOCAL search_path TO pg_catalog, pg_temp`)
|
|
355
|
+
const recorded: Record<string, string> = {}
|
|
356
|
+
for (const module of [KERNEL_MODULE, ...modules] as const) {
|
|
357
|
+
const name = nameOf(module)
|
|
358
|
+
const { fingerprint, snapshot } = yield* schemaSnapshot(sql, schemasOf(module))
|
|
359
|
+
const migrations = yield* appliedNames(sql, name)
|
|
360
|
+
yield* sql`INSERT INTO eloxiv.schema_snapshot (module, fingerprint, snapshot, migrations, recorded_at)
|
|
361
|
+
VALUES (${name}, ${fingerprint}, ${JSON.stringify(snapshot)}::jsonb, ${migrations}, now())
|
|
362
|
+
ON CONFLICT (module) DO UPDATE SET fingerprint = EXCLUDED.fingerprint, snapshot = EXCLUDED.snapshot,
|
|
363
|
+
migrations = EXCLUDED.migrations, recorded_at = EXCLUDED.recorded_at`
|
|
364
|
+
recorded[name] = fingerprint
|
|
365
|
+
}
|
|
366
|
+
return recorded
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
/** The live snapshot of a module's schema, outside setup (any role may read the catalogue). */
|
|
370
|
+
export const liveSnapshot = (sql: SqlClient.SqlClient, schemas: ReadonlyArray<string>) =>
|
|
371
|
+
sql.withTransaction(
|
|
372
|
+
Effect.gen(function* () {
|
|
373
|
+
yield* sql.unsafe(`SET LOCAL search_path TO pg_catalog, pg_temp`)
|
|
374
|
+
return yield* schemaSnapshot(sql, schemas)
|
|
375
|
+
}),
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
379
|
+
// Migrate and harden
|
|
380
|
+
|
|
381
|
+
export interface MigrateOptions {
|
|
382
|
+
readonly modules: ReadonlyArray<AnyKernelModule>
|
|
383
|
+
/**
|
|
384
|
+
* The Cedar policies row-level security is generated from: every module's (the registry's), or each module's
|
|
385
|
+
* own (a MAKE module's policy is compiled alone, so it can never reach another module's tables).
|
|
386
|
+
*/
|
|
387
|
+
readonly policies: string | ((module: AnyKernelModule) => string)
|
|
388
|
+
/** The kernel's database role: the kernel's, Better Auth's and Effect cluster's migrations run as it. */
|
|
389
|
+
readonly kernelRole: string
|
|
390
|
+
/**
|
|
391
|
+
* Better Auth's pending migrations, as SQL against its `auth` schema (`Identity.pendingMigrations`): applied in
|
|
392
|
+
* setup's transaction, as the kernel role.
|
|
393
|
+
*/
|
|
394
|
+
readonly authMigrations?: string | undefined
|
|
395
|
+
/**
|
|
396
|
+
* The backend pid of the session holding the migration lease (`withLease`, which passes it): every owner
|
|
397
|
+
* session checks, just before it commits, that this backend still holds the lease's lock.
|
|
398
|
+
*/
|
|
399
|
+
readonly leasePid: number
|
|
400
|
+
/**
|
|
401
|
+
* A connection logged in as a module's owner role (`connectOwner`), in the caller's scope: each module's
|
|
402
|
+
* migrations run on one, never on setup's own session.
|
|
403
|
+
*/
|
|
404
|
+
readonly ownerSession: (owner: string) => Effect.Effect<SqlClient.SqlClient, unknown, Scope.Scope>
|
|
405
|
+
/**
|
|
406
|
+
* The kernel's version (the Versioning contract): setup refuses, before changing anything, a module whose
|
|
407
|
+
* declared kernel range excludes it or that is older than the version installed, and records every module's
|
|
408
|
+
* version with the hardening. Omitted (tests of setup's steps alone): neither.
|
|
409
|
+
*/
|
|
410
|
+
readonly kernelVersion?: string | undefined
|
|
411
|
+
/** What the database host allows (`detectHost`): recorded with the kernel's state, and what setup does where not. */
|
|
412
|
+
readonly host: HostProfile
|
|
413
|
+
/** Run `f` on a fresh connection of the setup role to the app's database (not the lease session). */
|
|
414
|
+
readonly adminSession: <A, E>(f: (sql: SqlClient.SqlClient) => Effect.Effect<A, E>) => Effect.Effect<A, unknown>
|
|
415
|
+
/** Modules whose roles `bootstrapCluster` found changed and restored: reported as repaired. */
|
|
416
|
+
readonly rolesRepaired?: ReadonlyArray<string> | undefined
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** What a run of `migrateAndHarden` did. */
|
|
420
|
+
export interface MigrateReport {
|
|
421
|
+
readonly applied: Record<string, ReadonlyArray<string>>
|
|
422
|
+
readonly outsideTransaction: ReadonlyArray<string>
|
|
423
|
+
readonly snapshots: Record<string, string>
|
|
424
|
+
/** Modules whose security state had drifted since their last hardening, and were hardened again. */
|
|
425
|
+
readonly repaired: ReadonlyArray<string>
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* The fence on setup's own session: fail unless this session holds the migration lease (the advisory lock, and
|
|
430
|
+
* the lease's record names it). Setup checks it first in every transaction and before every non-transactional
|
|
431
|
+
* migration.
|
|
432
|
+
*/
|
|
433
|
+
export const assertLeaseHeld = (sql: SqlClient.SqlClient) =>
|
|
434
|
+
Effect.gen(function* () {
|
|
435
|
+
const [row] = yield* sql<{ locked: boolean; recorded: boolean }>`
|
|
436
|
+
SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_locks WHERE locktype = 'advisory' AND pid = pg_catalog.pg_backend_pid()
|
|
437
|
+
AND granted AND database = (SELECT oid FROM pg_catalog.pg_database WHERE datname = pg_catalog.current_database())
|
|
438
|
+
AND classid = 0 AND objid = ${sql.literal(String(LEASE_KEY))} AND objsubid = 1) AS locked,
|
|
439
|
+
EXISTS (SELECT 1 FROM eloxiv.release_lease WHERE pid = pg_catalog.pg_backend_pid()) AS recorded`
|
|
440
|
+
if (row?.locked !== true || !row.recorded) {
|
|
441
|
+
return yield* new MigrationFailed({
|
|
442
|
+
module: KERNEL_MODULE,
|
|
443
|
+
migration: null,
|
|
444
|
+
message: "This setup no longer holds the migration lease; nothing more was applied. Run setup again.",
|
|
445
|
+
})
|
|
446
|
+
}
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* The fence on an owner session (which cannot read the lease's record): fail unless the backend `leasePid`,
|
|
451
|
+
* setup's own session, still holds the migration lease's lock in this database. A backend that lost its lease
|
|
452
|
+
* (terminated as a stuck setup) no longer exists, and another setup's session has another pid, so a migration
|
|
453
|
+
* that took the lock itself does not pass either.
|
|
454
|
+
*/
|
|
455
|
+
export const assertLeaseHeldBy = (sql: SqlClient.SqlClient, leasePid: number, module: string) =>
|
|
456
|
+
Effect.gen(function* () {
|
|
457
|
+
const [row] = yield* sql<{ held: boolean }>`
|
|
458
|
+
SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_locks WHERE locktype = 'advisory' AND granted
|
|
459
|
+
AND pid = ${leasePid}
|
|
460
|
+
AND database = (SELECT oid FROM pg_catalog.pg_database WHERE datname = pg_catalog.current_database())
|
|
461
|
+
AND classid = 0 AND objid = ${sql.literal(String(LEASE_KEY))} AND objsubid = 1) AS held`
|
|
462
|
+
if (row?.held !== true) {
|
|
463
|
+
return yield* new MigrationFailed({
|
|
464
|
+
module,
|
|
465
|
+
migration: null,
|
|
466
|
+
message:
|
|
467
|
+
"Setup no longer holds the migration lease; the module's migrations were not committed. Run setup again.",
|
|
468
|
+
})
|
|
469
|
+
}
|
|
470
|
+
})
|
|
471
|
+
|
|
472
|
+
interface Plan {
|
|
473
|
+
readonly module: AnyKernelModule
|
|
474
|
+
readonly migrations: ReadonlyArray<Migration>
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** `plan`'s pending migrations up to (not including) the first pending non-transactional one. */
|
|
478
|
+
const pendingInTransaction = (sql: SqlClient.SqlClient, plan: Plan) =>
|
|
479
|
+
Effect.map(appliedNames(sql, plan.module.contract.name), (names) => {
|
|
480
|
+
const applied = new Set(names)
|
|
481
|
+
const pending: Array<Migration> = []
|
|
482
|
+
for (const migration of plan.migrations) {
|
|
483
|
+
if (applied.has(migration.name)) continue
|
|
484
|
+
if (migration.transactional === false) break
|
|
485
|
+
pending.push(migration)
|
|
486
|
+
}
|
|
487
|
+
return pending
|
|
488
|
+
})
|
|
489
|
+
|
|
490
|
+
const asMigrationFailed = (module: string, migration: string | null) => (e: unknown) =>
|
|
491
|
+
e instanceof MigrationFailed ? e : new MigrationFailed({ module, migration, message: messageOf(e) })
|
|
492
|
+
|
|
493
|
+
/** An `UnsafeModuleSchema` refusal (a defect, so hardening's transaction rolls back) as `MigrationFailed`. */
|
|
494
|
+
/** Refuse a module table that is not one of the module's entities, when the privacy module is installed. */
|
|
495
|
+
const undeclaredTables = (sql: SqlClient.SqlClient, modules: ReadonlyArray<AnyKernelModule>) =>
|
|
496
|
+
Effect.gen(function* () {
|
|
497
|
+
if (!modules.some((module) => module.contract.name === "privacy")) return
|
|
498
|
+
for (const module of modules) {
|
|
499
|
+
const declared = new Set(
|
|
500
|
+
Object.values(module.contract.entities as Record<string, { table: { schema: string; name: string } }>)
|
|
501
|
+
.filter((entity) => entity.table.schema === module.schema)
|
|
502
|
+
.map((entity) => entity.table.name),
|
|
503
|
+
)
|
|
504
|
+
const tables = yield* sql<{ name: string }>`
|
|
505
|
+
SELECT c.relname AS name FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
506
|
+
WHERE n.nspname = ${module.schema} AND c.relkind IN ('r', 'p') AND NOT c.relispartition ORDER BY 1`
|
|
507
|
+
const undeclared = tables.map((t) => t.name).filter((name) => !declared.has(name))
|
|
508
|
+
if (undeclared.length > 0) {
|
|
509
|
+
return yield* new MigrationFailed({
|
|
510
|
+
module: module.contract.name,
|
|
511
|
+
migration: null,
|
|
512
|
+
message: `Module ${module.contract.name} creates ${undeclared.map((t) => `${module.schema}.${t}`).join(", ")}, which ${undeclared.length === 1 ? "is not one of its entities" : "are not among its entities"}: with the privacy module installed, every table a module creates is an entity, declared in its dataSubjects`,
|
|
513
|
+
})
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
const refusalsAsFailures = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
|
|
519
|
+
effect.pipe(
|
|
520
|
+
Effect.catchDefect((defect) =>
|
|
521
|
+
defect instanceof UnsafeModuleSchema
|
|
522
|
+
? Effect.fail(new MigrationFailed({ module: defect.module, migration: null, message: defect.message }))
|
|
523
|
+
: Effect.die(defect),
|
|
524
|
+
),
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Step 2: one module's pending migrations, on a session logged in as its owner, in one transaction. The
|
|
529
|
+
* module's published views are dropped; each migration runs and is recorded (`eloxiv_setup.record_migration`),
|
|
530
|
+
* and after each one the session must still be in the same transaction as the same role (the preflight already
|
|
531
|
+
* refused transaction control and role changes; there is no other role to change to); then the module is closed
|
|
532
|
+
* (`closeModule`), checked for unsafe objects, and its views are created and checked, all with the catalogue
|
|
533
|
+
* named qualified and `pg_temp` last; and, just before the commit, setup's lease session must still hold the
|
|
534
|
+
* lease. Anything refused rolls all of it back.
|
|
535
|
+
*/
|
|
536
|
+
const migrateAsOwner = <E, R>(
|
|
537
|
+
owner: SqlClient.SqlClient,
|
|
538
|
+
plan: Plan,
|
|
539
|
+
pending: ReadonlyArray<Migration>,
|
|
540
|
+
leasePid: number,
|
|
541
|
+
/** On setup's session: mark the migration about to run as the one the owner session may record. */
|
|
542
|
+
markCurrent: (name: string) => Effect.Effect<unknown, E, R>,
|
|
543
|
+
) =>
|
|
544
|
+
owner.withTransaction(
|
|
545
|
+
Effect.gen(function* () {
|
|
546
|
+
const name = plan.module.contract.name
|
|
547
|
+
const [start] = yield* owner<{ xid: string; role: string }>`
|
|
548
|
+
SELECT pg_catalog.txid_current()::text AS xid, current_user::text AS role`
|
|
549
|
+
if (start?.role !== plan.module.owner) {
|
|
550
|
+
return yield* new MigrationFailed({
|
|
551
|
+
module: name,
|
|
552
|
+
migration: null,
|
|
553
|
+
message: `Module ${name}'s migration session runs as ${start?.role}, not its owner role ${plan.module.owner}`,
|
|
554
|
+
})
|
|
555
|
+
}
|
|
556
|
+
yield* dropQueryViews(owner, plan.module.schema).pipe(Effect.mapError(asMigrationFailed(name, null)))
|
|
557
|
+
for (const migration of pending) {
|
|
558
|
+
yield* Effect.gen(function* () {
|
|
559
|
+
yield* markCurrent(migration.name)
|
|
560
|
+
yield* runStatements(owner, migration.statements)
|
|
561
|
+
const [now] = yield* owner<{ xid: string; role: string }>`
|
|
562
|
+
SELECT pg_catalog.txid_current()::text AS xid, current_user::text AS role`
|
|
563
|
+
if (now?.xid !== start.xid || now.role !== plan.module.owner) {
|
|
564
|
+
return yield* new MigrationFailed({
|
|
565
|
+
module: name,
|
|
566
|
+
migration: migration.name,
|
|
567
|
+
message:
|
|
568
|
+
now?.xid !== start.xid
|
|
569
|
+
? `${name}/${migration.name} ended its transaction; migrations may not control transactions`
|
|
570
|
+
: `${name}/${migration.name} changed the role it runs as (to ${now.role}); migrations run as ${plan.module.owner}`,
|
|
571
|
+
})
|
|
572
|
+
}
|
|
573
|
+
yield* owner`SELECT eloxiv_setup.record_migration(${migration.name})`
|
|
574
|
+
}).pipe(Effect.mapError(asMigrationFailed(name, migration.name)))
|
|
575
|
+
}
|
|
576
|
+
yield* Effect.gen(function* () {
|
|
577
|
+
yield* closeModule(owner, plan.module)
|
|
578
|
+
const unsafe = yield* unsafeModuleObjects(owner, plan.module.schema, [plan.module.role, plan.module.owner])
|
|
579
|
+
if (unsafe.length > 0) {
|
|
580
|
+
return yield* Effect.die(
|
|
581
|
+
new UnsafeModuleSchema(
|
|
582
|
+
name,
|
|
583
|
+
`Module ${name} left objects that escape row-level security: ${unsafe.join("; ")}`,
|
|
584
|
+
),
|
|
585
|
+
)
|
|
586
|
+
}
|
|
587
|
+
yield* publishModuleViews(owner, plan.module, "create")
|
|
588
|
+
}).pipe(refusalsAsFailures, Effect.mapError(asMigrationFailed(name, null)))
|
|
589
|
+
yield* assertLeaseHeldBy(owner, leasePid, name).pipe(Effect.mapError(asMigrationFailed(name, null)))
|
|
590
|
+
}),
|
|
591
|
+
)
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Under the lease, on setup's own superuser session `sql` (which never runs a module's migration): every pending
|
|
595
|
+
* migration and the hardening. Before anything runs, every module migration is parsed with PostgreSQL's grammar
|
|
596
|
+
* (`migrationProblems`): transaction control, role and session changes, SQL that does not parse, and statements
|
|
597
|
+
* that cannot run in a transaction in an undeclared migration are refused.
|
|
598
|
+
*
|
|
599
|
+
* 0. On setup's session, committed: each module's schema (empty until its migrations run) and its owner's right
|
|
600
|
+
* to record migrations (`bootstrapModules`). Owner sessions must see them.
|
|
601
|
+
* 1. Each module with pending migrations, one after another: its migrations on a session logged in as its owner
|
|
602
|
+
* role, in that session's own transaction (`migrateAsOwner`), which leaves the module closed and commits only
|
|
603
|
+
* once its checks pass and the lease still holds.
|
|
604
|
+
* 2. On setup's session, in one transaction: Better Auth's, the kernel's and Effect cluster's migrations (on the
|
|
605
|
+
* first round), the hardening of every module (unsafe objects checked again, on a connection no migration
|
|
606
|
+
* touched; the security state compared, repaired and recorded; the module roles held to their fixed state),
|
|
607
|
+
* the published views (checked again for the modules just migrated, and granted), the sync publication and the
|
|
608
|
+
* schema snapshots.
|
|
609
|
+
*
|
|
610
|
+
* Owner transactions commit before step 2 (setup's session must see what they did), and step 2 does no DDL
|
|
611
|
+
* before they have: a DDL-serialising event trigger (zero-cache's takes a transaction advisory lock) would
|
|
612
|
+
* otherwise make an owner session wait for setup's own open transaction. A failure in step 1 leaves everything
|
|
613
|
+
* as it was (earlier modules' committed steps excepted, which are closed); a failure in step 2 leaves each
|
|
614
|
+
* migrated module applied, recorded and closed: row-level security forced with no policy, no privilege for
|
|
615
|
+
* anyone but the owner, no published view. Its runtime role reaches nothing until a setup succeeds. A declared
|
|
616
|
+
* non-transactional migration runs alone, on its owner's session, between two such rounds.
|
|
617
|
+
*/
|
|
618
|
+
export const migrateAndHarden = (sql: SqlClient.SqlClient, options: MigrateOptions) =>
|
|
619
|
+
Effect.gen(function* () {
|
|
620
|
+
const plans: Array<Plan> = []
|
|
621
|
+
for (const module of options.modules) plans.push({ module, migrations: yield* readModuleMigrations(module) })
|
|
622
|
+
const problems: Array<{ module: string; migration: string; problems: ReadonlyArray<string> }> = []
|
|
623
|
+
for (const plan of plans) {
|
|
624
|
+
for (const m of plan.migrations) {
|
|
625
|
+
const found = yield* migrationProblems(plan.module.contract.name, m)
|
|
626
|
+
if (found.length > 0) problems.push({ module: plan.module.contract.name, migration: m.name, problems: found })
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (problems.length > 0) {
|
|
630
|
+
return yield* new MigrationFailed({
|
|
631
|
+
module: problems[0]!.module,
|
|
632
|
+
migration: problems[0]!.migration,
|
|
633
|
+
message: problems.flatMap((p) => p.problems).join("\n"),
|
|
634
|
+
})
|
|
635
|
+
}
|
|
636
|
+
const authStatements =
|
|
637
|
+
options.authMigrations === undefined || options.authMigrations.trim() === ""
|
|
638
|
+
? []
|
|
639
|
+
: yield* splitStatements(options.authMigrations)
|
|
640
|
+
const applied: Record<string, Array<string>> = {}
|
|
641
|
+
const note = (module: string, names: ReadonlyArray<string>) => {
|
|
642
|
+
if (names.length > 0) applied[module] = [...(applied[module] ?? []), ...names]
|
|
643
|
+
}
|
|
644
|
+
const failed = asMigrationFailed(KERNEL_MODULE, null)
|
|
645
|
+
const outsideTransaction: Array<string> = []
|
|
646
|
+
const repaired = new Set<string>(options.rolesRepaired ?? [])
|
|
647
|
+
let first = true
|
|
648
|
+
let snapshots: Record<string, string> = {}
|
|
649
|
+
|
|
650
|
+
// zero-cache's DDL triggers cannot run as the roles setup's DDL runs as: they are paused for this run (and
|
|
651
|
+
// resumed whatever happens), and setup announces its schema changes itself (ZeroDdl.ts).
|
|
652
|
+
const zero = yield* hasZeroDdl(sql, options.host.eventTriggers).pipe(Effect.mapError(failed))
|
|
653
|
+
if (zero) yield* pauseZeroDdl(sql).pipe(Effect.mapError(failed))
|
|
654
|
+
const mark = (module: string) => (name: string) => markCurrentMigration(sql, module, name)
|
|
655
|
+
const run = Effect.gen(function* () {
|
|
656
|
+
// The Versioning contract: an incompatible module or a downgrade is refused before anything changes.
|
|
657
|
+
if (options.kernelVersion !== undefined) {
|
|
658
|
+
const refused = yield* moduleVersionProblems(sql, options.modules, options.kernelVersion).pipe(
|
|
659
|
+
Effect.mapError(failed),
|
|
660
|
+
)
|
|
661
|
+
if (refused.length > 0) {
|
|
662
|
+
return yield* new MigrationFailed({
|
|
663
|
+
module: refused[0]!.module,
|
|
664
|
+
migration: null,
|
|
665
|
+
message: refused.map((r) => r.message).join("\n"),
|
|
666
|
+
})
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
// Step 0: the module schemas the owner sessions migrate in, what their roles may do outside them, and the
|
|
670
|
+
// migrations each owner session may record.
|
|
671
|
+
yield* sql
|
|
672
|
+
.withTransaction(
|
|
673
|
+
Effect.gen(function* () {
|
|
674
|
+
yield* assertLeaseHeld(sql)
|
|
675
|
+
const { surfaceDropped } = yield* bootstrapModules(sql, options.modules)
|
|
676
|
+
const [db] = yield* sql<{ name: string }>`SELECT pg_catalog.current_database() AS name`
|
|
677
|
+
for (const plan of plans) {
|
|
678
|
+
if (yield* moduleSessionHygiene(sql, plan.module, db!.name)) repaired.add(plan.module.contract.name)
|
|
679
|
+
}
|
|
680
|
+
const planned: Array<{ module: string; names: ReadonlyArray<string> }> = []
|
|
681
|
+
for (const plan of plans) {
|
|
682
|
+
const applied = new Set(yield* appliedNames(sql, plan.module.contract.name))
|
|
683
|
+
planned.push({
|
|
684
|
+
module: plan.module.contract.name,
|
|
685
|
+
names: plan.migrations.map((m) => m.name).filter((name) => !applied.has(name)),
|
|
686
|
+
})
|
|
687
|
+
}
|
|
688
|
+
yield* planMigrations(sql, planned)
|
|
689
|
+
// Query-surface views a legacy module's roles held were dropped: the kernel's state as this leaves it.
|
|
690
|
+
if (surfaceDropped) yield* recordKernelState(sql, options.host)
|
|
691
|
+
}),
|
|
692
|
+
)
|
|
693
|
+
.pipe(Effect.mapError(failed))
|
|
694
|
+
|
|
695
|
+
for (;;) {
|
|
696
|
+
// Step 1: each module's pending migrations, on its owner's session.
|
|
697
|
+
const migrated = new Set<string>()
|
|
698
|
+
for (const plan of plans) {
|
|
699
|
+
const name = plan.module.contract.name
|
|
700
|
+
const pending = yield* pendingInTransaction(sql, plan).pipe(Effect.mapError(failed))
|
|
701
|
+
if (pending.length === 0) continue
|
|
702
|
+
// The module's query-surface views read its tables (as its runtime role, so not its owner's to drop):
|
|
703
|
+
// dropped on setup's session first, committed with the kernel's state as that leaves it, so a setup
|
|
704
|
+
// that fails from here leaves a recorded state the next one accepts. Step 2 creates them again.
|
|
705
|
+
yield* sql
|
|
706
|
+
.withTransaction(
|
|
707
|
+
Effect.gen(function* () {
|
|
708
|
+
yield* assertLeaseHeld(sql)
|
|
709
|
+
if (yield* dropSurfaceViews(sql, plan.module)) yield* recordKernelState(sql, options.host)
|
|
710
|
+
}),
|
|
711
|
+
)
|
|
712
|
+
.pipe(Effect.mapError(failed))
|
|
713
|
+
yield* Effect.scoped(
|
|
714
|
+
Effect.gen(function* () {
|
|
715
|
+
const owner = yield* options.ownerSession(plan.module.owner)
|
|
716
|
+
yield* migrateAsOwner(owner, plan, pending, options.leasePid, mark(name))
|
|
717
|
+
}),
|
|
718
|
+
).pipe(Effect.mapError(asMigrationFailed(name, null)))
|
|
719
|
+
note(
|
|
720
|
+
name,
|
|
721
|
+
pending.map((m) => m.name),
|
|
722
|
+
)
|
|
723
|
+
migrated.add(name)
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// Step 2: the kernel's migrations and the hardening, in one transaction on setup's session.
|
|
727
|
+
snapshots = yield* sql
|
|
728
|
+
.withTransaction(
|
|
729
|
+
Effect.gen(function* () {
|
|
730
|
+
yield* assertLeaseHeld(sql)
|
|
731
|
+
const [tx] = yield* sql<{ xid: string }>`SELECT pg_catalog.txid_current()::text AS xid`
|
|
732
|
+
const xid = tx!.xid
|
|
733
|
+
if (first && authStatements.length > 0) {
|
|
734
|
+
// Better Auth's tables, as the kernel role (it owns schema auth), exactly as Better Auth would
|
|
735
|
+
// create them, but in this transaction.
|
|
736
|
+
yield* Effect.gen(function* () {
|
|
737
|
+
yield* sql.unsafe(`SET LOCAL ROLE ${ident(options.kernelRole)}`)
|
|
738
|
+
yield* sql.unsafe(`SET LOCAL search_path TO auth`)
|
|
739
|
+
yield* runStatements(sql, authStatements)
|
|
740
|
+
yield* sql.unsafe(`RESET ROLE`)
|
|
741
|
+
yield* sql.unsafe(`RESET search_path`)
|
|
742
|
+
}).pipe(
|
|
743
|
+
Effect.mapError(
|
|
744
|
+
(e) => new MigrationFailed({ module: "auth", migration: "better-auth", message: messageOf(e) }),
|
|
745
|
+
),
|
|
746
|
+
)
|
|
747
|
+
}
|
|
748
|
+
if (first) {
|
|
749
|
+
note(
|
|
750
|
+
KERNEL_MODULE,
|
|
751
|
+
yield* applyPending(sql, KERNEL_MODULE, options.kernelRole, allKernelMigrations, xid),
|
|
752
|
+
)
|
|
753
|
+
// Effect cluster's storage, as the kernel role (it owns the schema), with its own history tables.
|
|
754
|
+
yield* sql.unsafe(`SET LOCAL ROLE ${ident(options.kernelRole)}`)
|
|
755
|
+
yield* migrateCluster.pipe(
|
|
756
|
+
Effect.provideService(SqlClient.SqlClient, sql),
|
|
757
|
+
Effect.catchDefect((defect) =>
|
|
758
|
+
Effect.fail(
|
|
759
|
+
new MigrationFailed({ module: KERNEL_MODULE, migration: "cluster", message: messageOf(defect) }),
|
|
760
|
+
),
|
|
761
|
+
),
|
|
762
|
+
)
|
|
763
|
+
yield* sql.unsafe(`RESET ROLE`)
|
|
764
|
+
yield* sql.unsafe(`RESET search_path`)
|
|
765
|
+
}
|
|
766
|
+
// With the privacy module installed, every table a module's migrations create is one of its entities
|
|
767
|
+
// (each declared in `dataSubjects`): none is left out of an export or an erasure by omission.
|
|
768
|
+
yield* undeclaredTables(sql, options.modules)
|
|
769
|
+
// Each module's views, and what the platform reads may read of it, are published within its
|
|
770
|
+
// hardening, before its state is recorded.
|
|
771
|
+
const fixed = yield* hardenModules(sql, options.modules, options.policies, (module) =>
|
|
772
|
+
Effect.andThen(
|
|
773
|
+
publishModuleViews(sql, module, migrated.has(module.contract.name) ? "grant" : "publish"),
|
|
774
|
+
platformTableAccess(sql, module),
|
|
775
|
+
),
|
|
776
|
+
).pipe(refusalsAsFailures)
|
|
777
|
+
// The query surface and the platform read functions: the kernel's state, recorded below.
|
|
778
|
+
yield* Effect.andThen(
|
|
779
|
+
publishSurfaceViews(sql, options.modules),
|
|
780
|
+
publishPlatformReads(sql, options.modules),
|
|
781
|
+
).pipe(refusalsAsFailures)
|
|
782
|
+
// Search and Files: the tracked tables, and the index rebuilt for every changed declaration.
|
|
783
|
+
yield* syncRecordSources(sql, options.modules)
|
|
784
|
+
yield* ensurePublication(sql, options.modules, options.host)
|
|
785
|
+
const recorded = yield* recordSnapshots(sql, options.modules)
|
|
786
|
+
if (options.kernelVersion !== undefined) {
|
|
787
|
+
yield* recordModuleVersions(sql, options.modules, options.kernelVersion)
|
|
788
|
+
}
|
|
789
|
+
yield* recordKernelState(sql, options.host)
|
|
790
|
+
const [end] = yield* sql<{ xid: string }>`SELECT pg_catalog.txid_current()::text AS xid`
|
|
791
|
+
if (end?.xid !== xid) {
|
|
792
|
+
return yield* new MigrationFailed({
|
|
793
|
+
module: KERNEL_MODULE,
|
|
794
|
+
migration: null,
|
|
795
|
+
message: "Setup's transaction ended before its hardening was recorded",
|
|
796
|
+
})
|
|
797
|
+
}
|
|
798
|
+
for (const name of fixed) repaired.add(name)
|
|
799
|
+
return recorded
|
|
800
|
+
}),
|
|
801
|
+
)
|
|
802
|
+
.pipe(Effect.mapError(failed))
|
|
803
|
+
first = false
|
|
804
|
+
// Declared non-transactional migrations now at the head of a module's pending list run alone, on the
|
|
805
|
+
// owner's session, then the next round applies what follows them and hardens again.
|
|
806
|
+
let ranOutside = false
|
|
807
|
+
for (const plan of plans) {
|
|
808
|
+
const name = plan.module.contract.name
|
|
809
|
+
const next = yield* pendingOutside(sql, name, plan.migrations).pipe(Effect.orDie)
|
|
810
|
+
if (next === undefined) continue
|
|
811
|
+
yield* assertLeaseHeld(sql)
|
|
812
|
+
yield* Effect.scoped(
|
|
813
|
+
Effect.gen(function* () {
|
|
814
|
+
const owner = yield* options.ownerSession(plan.module.owner)
|
|
815
|
+
yield* assertLeaseHeldBy(owner, options.leasePid, name)
|
|
816
|
+
yield* markCurrentMigration(sql, name, next.name)
|
|
817
|
+
yield* runStatements(owner, next.statements)
|
|
818
|
+
yield* owner`SELECT eloxiv_setup.record_migration(${next.name})`
|
|
819
|
+
}),
|
|
820
|
+
).pipe(Effect.mapError(asMigrationFailed(name, next.name)))
|
|
821
|
+
note(name, [next.name])
|
|
822
|
+
outsideTransaction.push(`${name}/${next.name}`)
|
|
823
|
+
ranOutside = true
|
|
824
|
+
}
|
|
825
|
+
if (!ranOutside) break
|
|
826
|
+
}
|
|
827
|
+
})
|
|
828
|
+
// Enabled again on a connection of its own: this session may be the one that was lost.
|
|
829
|
+
const resume = options
|
|
830
|
+
.adminSession(resumeZeroDdl)
|
|
831
|
+
.pipe(
|
|
832
|
+
Effect.catchCause((cause) =>
|
|
833
|
+
Effect.logError("Could not enable zero-cache's DDL triggers again; the next setup does", cause),
|
|
834
|
+
),
|
|
835
|
+
)
|
|
836
|
+
yield* zero ? run.pipe(Effect.ensuring(resume)) : run
|
|
837
|
+
return { applied, outsideTransaction, snapshots, repaired: [...repaired] } satisfies MigrateReport
|
|
838
|
+
})
|
|
839
|
+
|
|
840
|
+
/** Why setup refuses a host that allows less than the recorded profile (`hostDifferences`). */
|
|
841
|
+
export const hostRefusal = (hosted: ReadonlyArray<string>): string =>
|
|
842
|
+
`The database host allows less than when the last setup recorded the kernel's security state ` +
|
|
843
|
+
`(${hosted.join("; ")}): setup does not drop a protection it applied. Run setup where it was, or ` +
|
|
844
|
+
`re-baseline knowingly (ELOXIV_SETUP_REBASELINE=1, or setup's rebaselineKernelState).`
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Before setup changes anything, on its session: the kernel's security state must be the one the last setup
|
|
848
|
+
* recorded (`kernelSecurityState`). A kernel function's body or settings, an owner, a privilege of anyone but a
|
|
849
|
+
* module role (setup holds those itself), row-level security, a view's definition, a trigger or default
|
|
850
|
+
* privileges in the kernel's or Better Auth's schemas, or a revoked catalogue function granted back, changed
|
|
851
|
+
* outside setup is refused, naming each, and never recorded as the expected state. A database set up before
|
|
852
|
+
* (it has kernel migrations) with no record, or a record in another format, is refused too, unless the operator
|
|
853
|
+
* re-baselines (`rebaseline`: setup then records the state as it is, logging that it did).
|
|
854
|
+
*
|
|
855
|
+
* The host (`host`, db/Host.ts) is compared with the profile the last setup recorded too: a protection it applied
|
|
856
|
+
* that the host no longer allows, or another setup role, is refused the same way, so moving a database to a host
|
|
857
|
+
* that allows less is a decision an operator takes (`rebaseline`), never something setup does quietly.
|
|
858
|
+
*/
|
|
859
|
+
export const assertKernelState = (sql: SqlClient.SqlClient, host: HostProfile, rebaseline = false) =>
|
|
860
|
+
Effect.gen(function* () {
|
|
861
|
+
const recorded = yield* recordedKernelState(sql)
|
|
862
|
+
if (recorded.kind === "recorded") {
|
|
863
|
+
const hosted = hostDifferences(recorded.host, host)
|
|
864
|
+
const differences = kernelStateDifferences(recorded.state, yield* kernelSecurityState(sql))
|
|
865
|
+
if (hosted.length === 0 && differences.length === 0) return
|
|
866
|
+
if (rebaseline) {
|
|
867
|
+
return yield* Effect.logWarning(
|
|
868
|
+
`Re-baselining the kernel's security state as it is now, with these changes: ${[...hosted, ...differences].join("; ")}`,
|
|
869
|
+
)
|
|
870
|
+
}
|
|
871
|
+
return yield* new MigrationFailed({
|
|
872
|
+
module: KERNEL_MODULE,
|
|
873
|
+
migration: null,
|
|
874
|
+
message: [
|
|
875
|
+
...(hosted.length === 0 ? [] : [hostRefusal(hosted)]),
|
|
876
|
+
...(differences.length === 0
|
|
877
|
+
? []
|
|
878
|
+
: [
|
|
879
|
+
`The kernel's schemas were changed outside setup (${differences.join("; ")}); setup does not record ` +
|
|
880
|
+
`that as their expected state. Undo the change (or run the kernel migrations that make it), then run setup again.`,
|
|
881
|
+
]),
|
|
882
|
+
].join("\n"),
|
|
883
|
+
})
|
|
884
|
+
}
|
|
885
|
+
const [previous] = yield* sql<{ setUp: boolean }>`
|
|
886
|
+
SELECT pg_catalog.to_regclass('eloxiv.module_migration') IS NOT NULL
|
|
887
|
+
AND EXISTS (SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
888
|
+
WHERE n.nspname = 'eloxiv' AND c.relname = 'organization') AS "setUp"`
|
|
889
|
+
if (previous?.setUp !== true) return
|
|
890
|
+
if (rebaseline) {
|
|
891
|
+
return yield* Effect.logWarning("Re-baselining the kernel's security state: none was recorded in this format")
|
|
892
|
+
}
|
|
893
|
+
return yield* new MigrationFailed({
|
|
894
|
+
module: KERNEL_MODULE,
|
|
895
|
+
migration: null,
|
|
896
|
+
message:
|
|
897
|
+
recorded.kind === "foreign"
|
|
898
|
+
? `The kernel's recorded security state is in another format; check the kernel's schemas, then re-baseline ` +
|
|
899
|
+
`(ELOXIV_SETUP_REBASELINE=1, or setup's rebaselineKernelState)`
|
|
900
|
+
: `This database was set up before but has no recorded security state of the kernel's schemas; check them, ` +
|
|
901
|
+
`then re-baseline (ELOXIV_SETUP_REBASELINE=1, or setup's rebaselineKernelState)`,
|
|
902
|
+
})
|
|
903
|
+
})
|
|
904
|
+
|
|
905
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
906
|
+
// The lease
|
|
907
|
+
|
|
908
|
+
export interface LeaseOptions {
|
|
909
|
+
/** Recorded with the lease and in the history (default: host and process id). */
|
|
910
|
+
readonly owner: string
|
|
911
|
+
/** How long to wait for another setup's lease before failing (ms). */
|
|
912
|
+
readonly waitMs: number
|
|
913
|
+
/** How long the owner row stays valid without renewal; renewed every third of it (ms). */
|
|
914
|
+
readonly ttlMs: number
|
|
915
|
+
/** The kernel's database role, which owns the `eloxiv` schema the lease is recorded in. */
|
|
916
|
+
readonly kernelRole: string
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
interface Holder {
|
|
920
|
+
readonly owner: string
|
|
921
|
+
readonly acquiredAt: string
|
|
922
|
+
readonly expiresAt: string
|
|
923
|
+
readonly expired: boolean
|
|
924
|
+
readonly pid: number
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Run `body` holding the migration lease on the database `url` points at (a superuser URL). One session holds
|
|
929
|
+
* the advisory lock and is the only superuser connection `body` gets (with its backend pid, which owner sessions
|
|
930
|
+
* check before they commit), so all of setup's own work runs on the session that holds the lock: the lock cannot
|
|
931
|
+
* be lost while that work goes on. Terminating that session (the recovery for a stuck setup) ends its
|
|
932
|
+
* transaction with it, before another setup can take the lock. The session never reconnects: once it is gone,
|
|
933
|
+
* every further statement of `body` fails. A module's migrations run on an owner session of their own: one whose
|
|
934
|
+
* setup lost its lease cannot commit (`assertLeaseHeldBy`), and the next setup to take the lock ends any such
|
|
935
|
+
* session before it records itself, so no migration of a lost setup is still running once another holds the
|
|
936
|
+
* lease.
|
|
937
|
+
*
|
|
938
|
+
* The owner row's expiry is renewed from a second connection (the lease's session is busy migrating), and only
|
|
939
|
+
* while the lease's session is alive and still recorded as the holder.
|
|
940
|
+
*/
|
|
941
|
+
export const withLease = <A, E, R>(
|
|
942
|
+
url: Redacted.Redacted,
|
|
943
|
+
options: LeaseOptions,
|
|
944
|
+
body: (sql: SqlClient.SqlClient, leasePid: number) => Effect.Effect<A, E, R>,
|
|
945
|
+
) =>
|
|
946
|
+
Effect.scoped(
|
|
947
|
+
Effect.gen(function* () {
|
|
948
|
+
// One connection, never replaced: the advisory lock lives and dies with it, and so does the work.
|
|
949
|
+
const sql = yield* PgClient.makeClient({ url }).pipe(Effect.orDie)
|
|
950
|
+
const query = <T extends object>(text: string, params: ReadonlyArray<unknown> = []) => sql.unsafe<T>(text, params)
|
|
951
|
+
const holder = query<Holder>(
|
|
952
|
+
`SELECT owner, ${iso("acquired_at")} AS "acquiredAt", ${iso("expires_at")} AS "expiresAt",
|
|
953
|
+
expires_at < now() AS expired, pid FROM eloxiv.release_lease`,
|
|
954
|
+
).pipe(
|
|
955
|
+
Effect.map((rows) => rows[0]),
|
|
956
|
+
Effect.orElseSucceed(() => undefined),
|
|
957
|
+
)
|
|
958
|
+
const started = Date.now()
|
|
959
|
+
for (;;) {
|
|
960
|
+
const [got] = yield* query<{ got: boolean }>(`SELECT pg_try_advisory_lock($1) AS got`, [LEASE_KEY]).pipe(
|
|
961
|
+
Effect.orDie,
|
|
962
|
+
)
|
|
963
|
+
if (got?.got === true) break
|
|
964
|
+
const current = yield* holder
|
|
965
|
+
const held = (message: string) =>
|
|
966
|
+
new ReleaseLeaseHeld({
|
|
967
|
+
message,
|
|
968
|
+
owner: current?.owner ?? null,
|
|
969
|
+
acquiredAt: current?.acquiredAt ?? null,
|
|
970
|
+
expiresAt: current?.expiresAt ?? null,
|
|
971
|
+
})
|
|
972
|
+
if (current?.expired === true) {
|
|
973
|
+
return yield* held(
|
|
974
|
+
`The migration lease held by ${current.owner} since ${current.acquiredAt} expired at ${current.expiresAt}, ` +
|
|
975
|
+
`but its session (backend pid ${current.pid}) still holds the lock: that setup is stuck. Stop it ` +
|
|
976
|
+
`(for example SELECT pg_terminate_backend(${current.pid})) and run setup again.`,
|
|
977
|
+
)
|
|
978
|
+
}
|
|
979
|
+
if (Date.now() - started >= options.waitMs) {
|
|
980
|
+
return yield* held(
|
|
981
|
+
`Another setup${current === undefined ? "" : ` (${current.owner}, since ${current.acquiredAt})`} holds the ` +
|
|
982
|
+
`migration lease; waited ${options.waitMs} ms. Run setup again once it has finished.`,
|
|
983
|
+
)
|
|
984
|
+
}
|
|
985
|
+
yield* Effect.sleep(Duration.millis(200))
|
|
986
|
+
}
|
|
987
|
+
yield* Effect.addFinalizer(() =>
|
|
988
|
+
query(`DELETE FROM eloxiv.release_lease WHERE pid = pg_backend_pid()`).pipe(
|
|
989
|
+
Effect.andThen(query(`SELECT pg_advisory_unlock($1)`, [LEASE_KEY])),
|
|
990
|
+
Effect.ignore,
|
|
991
|
+
),
|
|
992
|
+
)
|
|
993
|
+
// The lease's record: created here (under the lock) so a fresh database has it before anything else.
|
|
994
|
+
// Only on a fresh database: zero-cache's event triggers make even a no-op `IF NOT EXISTS` cost (Bootstrap.ts).
|
|
995
|
+
const [lease] = yield* query<{ present: boolean }>(
|
|
996
|
+
`SELECT to_regclass('eloxiv.release_lease') IS NOT NULL AS present`,
|
|
997
|
+
).pipe(Effect.orDie)
|
|
998
|
+
if (lease?.present !== true) {
|
|
999
|
+
yield* query(`CREATE SCHEMA IF NOT EXISTS eloxiv AUTHORIZATION ${ident(options.kernelRole)}`).pipe(Effect.orDie)
|
|
1000
|
+
yield* query(`CREATE TABLE IF NOT EXISTS eloxiv.release_lease (
|
|
1001
|
+
singleton boolean PRIMARY KEY DEFAULT true CHECK (singleton),
|
|
1002
|
+
owner text NOT NULL, pid integer NOT NULL, acquired_at timestamptz NOT NULL, expires_at timestamptz NOT NULL)`).pipe(
|
|
1003
|
+
Effect.orDie,
|
|
1004
|
+
)
|
|
1005
|
+
}
|
|
1006
|
+
// Owner sessions a lost setup left (its lease session is gone, so it can commit nothing more): ended, and
|
|
1007
|
+
// waited for, before this setup records itself and starts.
|
|
1008
|
+
// By the role they logged in as (a migration can change its application name): an owner role logs in only
|
|
1009
|
+
// while setup connects it, so every such session is a setup's.
|
|
1010
|
+
yield* query(
|
|
1011
|
+
`SELECT pg_terminate_backend(pid, 10000) FROM pg_stat_activity
|
|
1012
|
+
WHERE datname = current_database() AND usename LIKE 'eloxiv\\_own\\_%' AND pid <> pg_backend_pid()`,
|
|
1013
|
+
).pipe(Effect.orDie)
|
|
1014
|
+
const [recorded] = yield* query<{ pid: number }>(
|
|
1015
|
+
`INSERT INTO eloxiv.release_lease (owner, pid, acquired_at, expires_at)
|
|
1016
|
+
VALUES ($1, pg_backend_pid(), now(), now() + $2 * interval '1 millisecond')
|
|
1017
|
+
ON CONFLICT (singleton) DO UPDATE SET owner = EXCLUDED.owner, pid = EXCLUDED.pid,
|
|
1018
|
+
acquired_at = EXCLUDED.acquired_at, expires_at = EXCLUDED.expires_at
|
|
1019
|
+
RETURNING pid`,
|
|
1020
|
+
[options.owner, options.ttlMs],
|
|
1021
|
+
).pipe(Effect.orDie)
|
|
1022
|
+
const pid = recorded!.pid
|
|
1023
|
+
// Renewal, from a connection of its own and for this session only: it stops once the session is gone or
|
|
1024
|
+
// another setup has recorded itself (the lease is lost, and the session's work ended with it).
|
|
1025
|
+
const renewer = yield* PgClient.makeClient({ url }).pipe(Effect.orDie)
|
|
1026
|
+
yield* renewer
|
|
1027
|
+
.unsafe<{ pid: number }>(
|
|
1028
|
+
`UPDATE eloxiv.release_lease SET expires_at = now() + $1 * interval '1 millisecond'
|
|
1029
|
+
WHERE pid = $2 AND EXISTS (SELECT 1 FROM pg_stat_activity WHERE pid = $2) RETURNING pid`,
|
|
1030
|
+
[options.ttlMs, pid],
|
|
1031
|
+
)
|
|
1032
|
+
.pipe(
|
|
1033
|
+
Effect.map((rows) => rows.length > 0),
|
|
1034
|
+
Effect.orElseSucceed(() => true),
|
|
1035
|
+
Effect.repeat({
|
|
1036
|
+
schedule: Schedule.spaced(Duration.millis(Math.max(100, Math.floor(options.ttlMs / 3)))),
|
|
1037
|
+
while: (renewed) => renewed,
|
|
1038
|
+
}),
|
|
1039
|
+
Effect.andThen(
|
|
1040
|
+
Effect.logWarning(`The migration lease of ${options.owner} (backend pid ${pid}) was lost; renewal stopped`),
|
|
1041
|
+
),
|
|
1042
|
+
Effect.forkScoped,
|
|
1043
|
+
)
|
|
1044
|
+
return yield* body(sql, pid)
|
|
1045
|
+
}),
|
|
1046
|
+
).pipe(Effect.provide(Reactivity.layer))
|
|
1047
|
+
|
|
1048
|
+
/** Record a finished setup in the history (outside its transaction, so failures are recorded too). */
|
|
1049
|
+
export const recordHistory = (
|
|
1050
|
+
sql: SqlClient.SqlClient,
|
|
1051
|
+
entry: {
|
|
1052
|
+
readonly owner: string
|
|
1053
|
+
readonly startedAt: Date
|
|
1054
|
+
readonly exit: Exit.Exit<{ readonly applied: Record<string, ReadonlyArray<string>> }, unknown>
|
|
1055
|
+
},
|
|
1056
|
+
) => {
|
|
1057
|
+
const failed = Exit.isFailure(entry.exit)
|
|
1058
|
+
const error = failed ? messageOf(Cause.squash((entry.exit as Exit.Failure<unknown, unknown>).cause)) : null
|
|
1059
|
+
const applied = Exit.isSuccess(entry.exit) ? entry.exit.value.applied : {}
|
|
1060
|
+
return sql`INSERT INTO eloxiv.release_history (owner, started_at, outcome, error, applied)
|
|
1061
|
+
VALUES (${entry.owner}, ${entry.startedAt}, ${failed ? "failed" : "succeeded"}, ${error},
|
|
1062
|
+
${JSON.stringify(applied)}::jsonb)`.pipe(Effect.ignore)
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Whether `owner` can log in while no setup is connecting it: setup gives an owner role LOGIN only while it holds
|
|
1067
|
+
* that role's login lock (`OWNER_LOGIN_LOCK`, in the cluster's admin database, so for any app on the cluster),
|
|
1068
|
+
* so LOGIN seen with the lock free, twice, is LOGIN left behind (by an operator, or a setup that crashed in the
|
|
1069
|
+
* window, which the next setup removes). A password without LOGIN lets no one in; the kernel role cannot see
|
|
1070
|
+
* passwords.
|
|
1071
|
+
*/
|
|
1072
|
+
const ownerLoginOutsideSetup = (sql: SqlClient.SqlClient, owner: string) =>
|
|
1073
|
+
Effect.gen(function* () {
|
|
1074
|
+
const lockFree = Effect.map(
|
|
1075
|
+
sql<{ held: boolean }>`
|
|
1076
|
+
SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_locks WHERE locktype = 'advisory' AND granted AND objsubid = 2
|
|
1077
|
+
AND classid::bigint = ${sql.literal(String(OWNER_LOGIN_LOCK))}
|
|
1078
|
+
AND objid::bigint = (pg_catalog.hashtext(${owner})::bigint & 4294967295)) AS held`,
|
|
1079
|
+
(rows) => rows[0]?.held !== true,
|
|
1080
|
+
)
|
|
1081
|
+
const login = Effect.map(
|
|
1082
|
+
sql<{ login: boolean }>`SELECT rolcanlogin AS login FROM pg_catalog.pg_roles WHERE rolname = ${owner}`,
|
|
1083
|
+
(rows) => rows[0]?.login === true,
|
|
1084
|
+
)
|
|
1085
|
+
for (const check of [lockFree, login, lockFree, login]) if (!(yield* check)) return false
|
|
1086
|
+
return true
|
|
1087
|
+
}).pipe(Effect.orDie)
|
|
1088
|
+
|
|
1089
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
1090
|
+
// The runtime service
|
|
1091
|
+
|
|
1092
|
+
export interface ReleaseShape {
|
|
1093
|
+
/** Whether the database is current for this build. */
|
|
1094
|
+
readonly status: Effect.Effect<ReleaseStatus>
|
|
1095
|
+
readonly snapshots: Effect.Effect<ReadonlyArray<SchemaSnapshotRecord>>
|
|
1096
|
+
readonly info: Effect.Effect<ReleaseInfo>
|
|
1097
|
+
readonly lease: Effect.Effect<ReleaseLease | null>
|
|
1098
|
+
readonly history: Effect.Effect<ReadonlyArray<ReleaseRecord>>
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
export class Release extends Context.Service<Release, ReleaseShape>()("@eloxiv/kernel/Release") {
|
|
1102
|
+
static readonly layer = (modules: ReadonlyArray<AnyKernelModule>, kernelVersion: string) =>
|
|
1103
|
+
Layer.effect(
|
|
1104
|
+
Release,
|
|
1105
|
+
Effect.gen(function* () {
|
|
1106
|
+
const sql = yield* SqlClient.SqlClient
|
|
1107
|
+
const settings = yield* ReleaseSettings
|
|
1108
|
+
const built: Array<{
|
|
1109
|
+
readonly module: string
|
|
1110
|
+
readonly schemas: ReadonlyArray<string>
|
|
1111
|
+
readonly migrations: ReadonlyArray<string>
|
|
1112
|
+
}> = [{ module: KERNEL_MODULE, schemas: KERNEL_SCHEMAS, migrations: allKernelMigrations.map((m) => m.name) }]
|
|
1113
|
+
for (const module of modules) {
|
|
1114
|
+
built.push({
|
|
1115
|
+
module: module.contract.name,
|
|
1116
|
+
schemas: [module.schema],
|
|
1117
|
+
migrations: (yield* readModuleMigrations(module).pipe(Effect.orDie)).map((m) => m.name),
|
|
1118
|
+
})
|
|
1119
|
+
}
|
|
1120
|
+
const snapshots = sql<SchemaSnapshotRecord>`
|
|
1121
|
+
SELECT module, fingerprint, migrations, ${sql.literal(iso("recorded_at"))} AS "recordedAt"
|
|
1122
|
+
FROM eloxiv.schema_snapshot ORDER BY module`.pipe(
|
|
1123
|
+
Effect.map((rows) => rows.map((r) => ({ ...r, migrations: [...r.migrations] }))),
|
|
1124
|
+
Effect.orDie,
|
|
1125
|
+
)
|
|
1126
|
+
const status = Effect.gen(function* () {
|
|
1127
|
+
const recorded = new Map((yield* snapshots).map((s) => [s.module, s]))
|
|
1128
|
+
const pending: Array<string> = []
|
|
1129
|
+
const drifted: Array<string> = []
|
|
1130
|
+
const unrecorded: Array<string> = []
|
|
1131
|
+
for (const entry of built) {
|
|
1132
|
+
const applied = new Set(yield* appliedNames(sql, entry.module).pipe(Effect.orDie))
|
|
1133
|
+
for (const name of entry.migrations) if (!applied.has(name)) pending.push(`${entry.module}/${name}`)
|
|
1134
|
+
const snapshot = recorded.get(entry.module)
|
|
1135
|
+
if (snapshot === undefined) {
|
|
1136
|
+
unrecorded.push(entry.module)
|
|
1137
|
+
continue
|
|
1138
|
+
}
|
|
1139
|
+
const live = yield* liveSnapshot(sql, entry.schemas).pipe(Effect.orDie)
|
|
1140
|
+
if (live.fingerprint !== snapshot.fingerprint) drifted.push(entry.module)
|
|
1141
|
+
}
|
|
1142
|
+
// Security drift: the kernel's schemas, or a module's security state, differ from what the last setup
|
|
1143
|
+
// recorded; or a module's owner role can log in outside setup's connect window.
|
|
1144
|
+
const insecure: Array<string> = []
|
|
1145
|
+
const kernel = yield* recordedKernelState(sql).pipe(Effect.orDie)
|
|
1146
|
+
if (kernel.kind !== "recorded") insecure.push(KERNEL_MODULE)
|
|
1147
|
+
else {
|
|
1148
|
+
const live = yield* sql.withTransaction(kernelSecurityState(sql)).pipe(Effect.orDie)
|
|
1149
|
+
if (kernelStateDifferences(kernel.state, live).length > 0) insecure.push(KERNEL_MODULE)
|
|
1150
|
+
}
|
|
1151
|
+
// zero-cache's DDL triggers disabled (or setup's own left on) while no setup holds the lease.
|
|
1152
|
+
if (yield* zeroDdlLeftPaused(sql, LEASE_KEY).pipe(Effect.orDie)) insecure.push("zero-cache")
|
|
1153
|
+
for (const module of modules) {
|
|
1154
|
+
const [hardened] = yield* sql<{ security: unknown }>`
|
|
1155
|
+
SELECT security FROM eloxiv.module_hardening WHERE module = ${module.contract.name}`.pipe(Effect.orDie)
|
|
1156
|
+
if (hardened === undefined) continue
|
|
1157
|
+
const live = yield* sql.withTransaction(securityState(sql, module)).pipe(Effect.orDie)
|
|
1158
|
+
if (
|
|
1159
|
+
hardened.security === null ||
|
|
1160
|
+
securityDifferences(hardened.security, live).length > 0 ||
|
|
1161
|
+
(yield* ownerLoginOutsideSetup(sql, module.owner))
|
|
1162
|
+
) {
|
|
1163
|
+
insecure.push(module.contract.name)
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
return { pending, drifted, unrecorded, insecure } satisfies ReleaseStatus
|
|
1167
|
+
})
|
|
1168
|
+
const info = Effect.map(snapshots, (recorded) => {
|
|
1169
|
+
const byModule = new Map(recorded.map((s) => [s.module, s.fingerprint]))
|
|
1170
|
+
return {
|
|
1171
|
+
kernelVersion,
|
|
1172
|
+
appVersion: settings.appVersion ?? null,
|
|
1173
|
+
minClientVersion: settings.minClientVersion ?? null,
|
|
1174
|
+
modules: [
|
|
1175
|
+
{ name: KERNEL_MODULE, version: kernelVersion, schema: byModule.get(KERNEL_MODULE) ?? null },
|
|
1176
|
+
...modules.map((m) => ({
|
|
1177
|
+
name: m.contract.name,
|
|
1178
|
+
version: m.contract.version,
|
|
1179
|
+
schema: byModule.get(m.contract.name) ?? null,
|
|
1180
|
+
})),
|
|
1181
|
+
],
|
|
1182
|
+
} satisfies ReleaseInfo
|
|
1183
|
+
})
|
|
1184
|
+
const lease = sql<ReleaseLease>`
|
|
1185
|
+
SELECT owner, ${sql.literal(iso("acquired_at"))} AS "acquiredAt", ${sql.literal(iso("expires_at"))} AS "expiresAt"
|
|
1186
|
+
FROM eloxiv.release_lease`.pipe(
|
|
1187
|
+
Effect.map((rows) => rows[0] ?? null),
|
|
1188
|
+
Effect.orDie,
|
|
1189
|
+
)
|
|
1190
|
+
const history = sql<ReleaseRecord>`
|
|
1191
|
+
SELECT owner, ${sql.literal(iso("started_at"))} AS "startedAt", ${sql.literal(iso("finished_at"))} AS "finishedAt",
|
|
1192
|
+
outcome, error, applied
|
|
1193
|
+
FROM eloxiv.release_history ORDER BY id`.pipe(Effect.orDie)
|
|
1194
|
+
return Release.of({ status, snapshots, info, lease, history })
|
|
1195
|
+
}),
|
|
1196
|
+
)
|
|
1197
|
+
}
|