@voltro/cli 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +655 -0
- package/THIRD-PARTY-NOTICES.md +90 -4
- package/dist/{apiBuild-eUM32r1u.js → apiBuild-BceikpQf.js} +3 -3
- package/dist/apiBuild-CxvR1Dwt.js +2 -0
- package/dist/bin.js +3 -3
- package/dist/checkCommand-BMr-X48w.js +2427 -0
- package/dist/checkCommand-BOk9y264.js +2 -0
- package/dist/cliRuntime-Oh517vCV.js +96 -0
- package/dist/{commands-CSkrUI1h.js → commands-D4Y1-Nlu.js} +8575 -9366
- package/dist/{dbCommand-CpYgmSw4.js → dbCommand-C7hbl5pk.js} +345 -266
- package/dist/dbCommand-D8nhyppR.js +2 -0
- package/dist/{dev-DlBWWnJQ.js → dev-Cr-teYsz.js} +1 -1
- package/dist/{dev-CEZwJhmb.js → dev-DmnkH-wr.js} +2939 -1832
- package/dist/fileConventions-Cof68_BL.js +33 -0
- package/dist/{frameworkTableAssembly-BwHU9Euq.js → frameworkTableAssembly-BzAajuUv.js} +115 -99
- package/dist/frameworkTableAssembly-DU0aOxjL.js +2 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +1 -1
- package/dist/{inspect-CUCCzw2I.js → inspect-BUUjt773.js} +349 -192
- package/dist/inspect-mmBuRXmy.js +2 -0
- package/dist/{inspectMetrics-BU90mvJN.js → inspectMetrics-BeJdP_3b.js} +1068 -978
- package/dist/{manifestBuild-BnzAxp2O.js → manifestBuild-BLrVuSlM.js} +1 -1
- package/dist/manifestBuild-Dj8Jjoto.js +2 -0
- package/dist/sdkgen-CqpOq_fy.js +582 -0
- package/dist/serveCommand-Ciq_wIY8.js +1577 -0
- package/dist/serveEntry.js +2 -2
- package/dist/{start-BGXIf6zT.js → start-ocqB1seX.js} +283 -270
- package/dist/startEntry.js +2 -2
- package/package.json +17 -17
- package/templates/AGENTS.core.md +50 -0
- package/templates/AGENTS.md +54 -2
- package/templates/agent-docs/_index.md +4 -2
- package/templates/agent-docs/_manifest.json +26 -5
- package/templates/agent-docs/ai.md +191 -0
- package/templates/agent-docs/cli.md +143 -6
- package/templates/agent-docs/configuration.md +32 -0
- package/templates/agent-docs/data.md +282 -0
- package/templates/agent-docs/database/migrations.md +47 -0
- package/templates/agent-docs/database/misc.md +57 -0
- package/templates/agent-docs/database/schema.md +3 -1
- package/templates/agent-docs/internationalization.md +169 -8
- package/templates/agent-docs/local-first-mobile.md +426 -0
- package/templates/agent-docs/routing.md +94 -3
- package/templates/agent-docs/schema-driven-ui.md +12 -0
- package/templates/agent-docs/security.md +17 -0
- package/templates/agent-docs/templates/apibackends.md +210 -1
- package/templates/agent-docs/templates/appshells.md +144 -1
- package/templates/agent-docs/templates/mobile.md +60 -0
- package/templates/agent-docs/templates/overview.md +17 -7
- package/templates/agent-docs/whats-new.md +238 -158
- package/templates/agent-docs/workflows.md +376 -0
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -8
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-sqlite/.env.example +19 -0
- package/templates/apps/api-backend-sqlite/README.md +38 -0
- package/templates/apps/api-backend-sqlite/app.config.ts +35 -0
- package/templates/apps/api-backend-sqlite/database/schema.ts +54 -0
- package/templates/apps/api-backend-sqlite/mutations/notes.create.mutation.server.ts +19 -0
- package/templates/apps/api-backend-sqlite/mutations/notes.create.mutation.ts +37 -0
- package/templates/apps/api-backend-sqlite/package.json +30 -0
- package/templates/apps/api-backend-sqlite/queries/notes.query.server.ts +14 -0
- package/templates/apps/api-backend-sqlite/queries/notes.query.ts +20 -0
- package/templates/apps/api-backend-sqlite/template.json +6 -0
- package/templates/apps/api-backend-sqlite/tests/notes.create.test.ts +50 -0
- package/templates/apps/api-backend-sqlite/tsconfig.json +5 -0
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-cms/README.md +104 -0
- package/templates/apps/api-cms/actions/content.get.action.server.ts +27 -0
- package/templates/apps/api-cms/actions/content.get.action.ts +19 -0
- package/templates/apps/api-cms/actions/content.types.action.server.ts +26 -0
- package/templates/apps/api-cms/actions/content.types.action.ts +40 -0
- package/templates/apps/api-cms/actions/me.action.server.ts +18 -0
- package/templates/apps/api-cms/actions/me.action.ts +16 -0
- package/templates/apps/api-cms/app.config.ts +61 -0
- package/templates/apps/api-cms/content/blogPost.contentType.ts +39 -0
- package/templates/apps/api-cms/content/index.ts +18 -0
- package/templates/apps/api-cms/content/page.contentType.ts +24 -0
- package/templates/apps/api-cms/database/schema.ts +64 -0
- package/templates/apps/api-cms/mutations/content.publish.mutation.server.ts +19 -0
- package/templates/apps/api-cms/mutations/content.publish.mutation.ts +15 -0
- package/templates/apps/api-cms/mutations/content.saveDraft.mutation.server.ts +36 -0
- package/templates/apps/api-cms/mutations/content.saveDraft.mutation.ts +32 -0
- package/templates/apps/api-cms/mutations/content.unpublish.mutation.server.ts +19 -0
- package/templates/apps/api-cms/mutations/content.unpublish.mutation.ts +11 -0
- package/templates/apps/api-cms/package.json +32 -0
- package/templates/apps/api-cms/queries/content.list.query.server.ts +0 -0
- package/templates/apps/api-cms/queries/content.list.query.ts +27 -0
- package/templates/apps/api-cms/template.json +6 -0
- package/templates/apps/api-cms/tests/content.descriptors.test.ts +64 -0
- package/templates/apps/api-cms/tests/content.write.test.ts +85 -0
- package/templates/apps/api-cms/tsconfig.json +5 -0
- package/templates/apps/api-collab/README.md +70 -0
- package/templates/apps/api-collab/app.config.ts +28 -0
- package/templates/apps/api-collab/database/schema.ts +63 -0
- package/templates/apps/api-collab/mutations/documents.create.mutation.server.ts +19 -0
- package/templates/apps/api-collab/mutations/documents.create.mutation.ts +36 -0
- package/templates/apps/api-collab/mutations/documents.setBody.mutation.server.ts +20 -0
- package/templates/apps/api-collab/mutations/documents.setBody.mutation.ts +30 -0
- package/templates/apps/api-collab/package.json +30 -0
- package/templates/apps/api-collab/queries/documents.query.server.ts +16 -0
- package/templates/apps/api-collab/queries/documents.query.ts +23 -0
- package/templates/apps/api-collab/template.json +6 -0
- package/templates/apps/api-collab/tests/documents.setBody.test.ts +89 -0
- package/templates/apps/api-collab/tsconfig.json +5 -0
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/package.json +7 -7
- package/templates/apps/api-saas/package.json +11 -11
- package/templates/apps/api-saas-starter/README.md +103 -0
- package/templates/apps/api-saas-starter/actions/me.action.server.ts +18 -0
- package/templates/apps/api-saas-starter/actions/me.action.ts +20 -0
- package/templates/apps/api-saas-starter/app.config.ts +87 -0
- package/templates/apps/api-saas-starter/database/schema.ts +57 -0
- package/templates/apps/api-saas-starter/mutations/invites.create.mutation.server.ts +26 -0
- package/templates/apps/api-saas-starter/mutations/invites.create.mutation.ts +18 -0
- package/templates/apps/api-saas-starter/mutations/projects.create.mutation.server.ts +29 -0
- package/templates/apps/api-saas-starter/mutations/projects.create.mutation.ts +18 -0
- package/templates/apps/api-saas-starter/package.json +32 -0
- package/templates/apps/api-saas-starter/queries/invites.list.query.server.ts +14 -0
- package/templates/apps/api-saas-starter/queries/invites.list.query.ts +17 -0
- package/templates/apps/api-saas-starter/queries/projects.list.query.server.ts +14 -0
- package/templates/apps/api-saas-starter/queries/projects.list.query.ts +18 -0
- package/templates/apps/api-saas-starter/template.json +6 -0
- package/templates/apps/api-saas-starter/tests/projects.create.test.ts +62 -0
- package/templates/apps/api-saas-starter/tests/session.test.ts +33 -0
- package/templates/apps/api-saas-starter/tsconfig.json +5 -0
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-status/README.md +88 -0
- package/templates/apps/api-status/app.config.ts +36 -0
- package/templates/apps/api-status/authz.ts +33 -0
- package/templates/apps/api-status/database/schema.ts +70 -0
- package/templates/apps/api-status/mutations/components.create.mutation.server.ts +19 -0
- package/templates/apps/api-status/mutations/components.create.mutation.ts +16 -0
- package/templates/apps/api-status/mutations/incidents.create.mutation.server.ts +25 -0
- package/templates/apps/api-status/mutations/incidents.create.mutation.ts +22 -0
- package/templates/apps/api-status/mutations/incidents.resolve.mutation.server.ts +24 -0
- package/templates/apps/api-status/mutations/incidents.resolve.mutation.ts +19 -0
- package/templates/apps/api-status/mutations/incidents.update.mutation.server.ts +26 -0
- package/templates/apps/api-status/mutations/incidents.update.mutation.ts +21 -0
- package/templates/apps/api-status/package.json +30 -0
- package/templates/apps/api-status/queries/components.list.query.server.ts +14 -0
- package/templates/apps/api-status/queries/components.list.query.ts +13 -0
- package/templates/apps/api-status/queries/incidents.live.query.server.ts +14 -0
- package/templates/apps/api-status/queries/incidents.live.query.ts +20 -0
- package/templates/apps/api-status/queries/updates.list.query.server.ts +14 -0
- package/templates/apps/api-status/queries/updates.list.query.ts +17 -0
- package/templates/apps/api-status/template.json +6 -0
- package/templates/apps/api-status/tests/status.test.ts +70 -0
- package/templates/apps/api-status/tsconfig.json +5 -0
- package/templates/apps/api-versioning/package.json +8 -8
- package/templates/apps/api-webhooks/package.json +9 -9
- package/templates/apps/changelog/package.json +6 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/app.config.ts +1 -1
- package/templates/apps/frontend-admin/package.json +8 -8
- package/templates/apps/frontend-admin/src/locales/index.ts +1 -1
- package/templates/apps/frontend-app/app.config.ts +1 -1
- package/templates/apps/frontend-app/package.json +8 -8
- package/templates/apps/frontend-app/src/locales/index.ts +1 -1
- package/templates/apps/frontend-app/src/pages/layout.tsx +1 -1
- package/templates/apps/frontend-app/src/pages/page.tsx +1 -1
- package/templates/apps/frontend-auth/README.md +78 -0
- package/templates/apps/frontend-auth/app.config.ts +34 -0
- package/templates/apps/frontend-auth/package.json +32 -0
- package/templates/apps/frontend-auth/src/components/AuthShell.tsx +35 -0
- package/templates/apps/frontend-auth/src/components/PasswordStrength.tsx +33 -0
- package/templates/apps/frontend-auth/src/config.ts +11 -0
- package/templates/apps/frontend-auth/src/globals.css +105 -0
- package/templates/apps/frontend-auth/src/globals.d.ts +6 -0
- package/templates/apps/frontend-auth/src/lib/auth.ts +34 -0
- package/templates/apps/frontend-auth/src/lib/redirect.test.ts +24 -0
- package/templates/apps/frontend-auth/src/lib/redirect.ts +29 -0
- package/templates/apps/frontend-auth/src/locales/de.ts +66 -0
- package/templates/apps/frontend-auth/src/locales/en.ts +76 -0
- package/templates/apps/frontend-auth/src/locales/index.ts +14 -0
- package/templates/apps/frontend-auth/src/pages/forgot/page.tsx +51 -0
- package/templates/apps/frontend-auth/src/pages/layout.tsx +12 -0
- package/templates/apps/frontend-auth/src/pages/login/page.test.tsx +53 -0
- package/templates/apps/frontend-auth/src/pages/login/page.tsx +67 -0
- package/templates/apps/frontend-auth/src/pages/logout/page.tsx +28 -0
- package/templates/apps/frontend-auth/src/pages/magic/page.tsx +51 -0
- package/templates/apps/frontend-auth/src/pages/page.tsx +26 -0
- package/templates/apps/frontend-auth/src/pages/reset/page.test.tsx +51 -0
- package/templates/apps/frontend-auth/src/pages/reset/page.tsx +63 -0
- package/templates/apps/frontend-auth/src/pages/signup/page.tsx +60 -0
- package/templates/apps/frontend-auth/src/pages/verify/page.tsx +50 -0
- package/templates/apps/frontend-auth/template.json +6 -0
- package/templates/apps/frontend-auth/tsconfig.json +5 -0
- package/templates/apps/frontend-blank/app.config.ts +1 -1
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-blank/src/locales/index.ts +1 -1
- package/templates/apps/frontend-blank/src/pages/layout.tsx +1 -1
- package/templates/apps/frontend-blank/src/pages/page.tsx +1 -1
- package/templates/apps/frontend-cms/README.md +47 -0
- package/templates/apps/frontend-cms/app.config.ts +37 -0
- package/templates/apps/frontend-cms/package.json +33 -0
- package/templates/apps/frontend-cms/src/config.ts +8 -0
- package/templates/apps/frontend-cms/src/globals.css +105 -0
- package/templates/apps/frontend-cms/src/globals.d.ts +6 -0
- package/templates/apps/frontend-cms/src/lib/api.ts +58 -0
- package/templates/apps/frontend-cms/src/locales/de.ts +50 -0
- package/templates/apps/frontend-cms/src/locales/en.ts +55 -0
- package/templates/apps/frontend-cms/src/locales/index.ts +14 -0
- package/templates/apps/frontend-cms/src/pages/(app)/error.tsx +18 -0
- package/templates/apps/frontend-cms/src/pages/(app)/layout.test.tsx +31 -0
- package/templates/apps/frontend-cms/src/pages/(app)/layout.tsx +62 -0
- package/templates/apps/frontend-cms/src/pages/(app)/not-found.tsx +14 -0
- package/templates/apps/frontend-cms/src/pages/(app)/page.test.tsx +110 -0
- package/templates/apps/frontend-cms/src/pages/(app)/page.tsx +159 -0
- package/templates/apps/frontend-cms/src/pages/layout.tsx +12 -0
- package/templates/apps/frontend-cms/src/pages/login/page.test.tsx +58 -0
- package/templates/apps/frontend-cms/src/pages/login/page.tsx +93 -0
- package/templates/apps/frontend-cms/template.json +6 -0
- package/templates/apps/frontend-cms/tsconfig.json +5 -0
- package/templates/apps/frontend-collab/README.md +80 -0
- package/templates/apps/frontend-collab/app.config.ts +38 -0
- package/templates/apps/frontend-collab/package.json +33 -0
- package/templates/apps/frontend-collab/src/locales/de.ts +29 -0
- package/templates/apps/frontend-collab/src/locales/en.ts +31 -0
- package/templates/apps/frontend-collab/src/locales/index.ts +15 -0
- package/templates/apps/frontend-collab/src/pages/layout.tsx +39 -0
- package/templates/apps/frontend-collab/src/pages/page.test.tsx +150 -0
- package/templates/apps/frontend-collab/src/pages/page.tsx +186 -0
- package/templates/apps/frontend-collab/template.json +6 -0
- package/templates/apps/frontend-collab/tsconfig.json +11 -0
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-dashboard/app.config.ts +1 -1
- package/templates/apps/frontend-dashboard/package.json +7 -7
- package/templates/apps/frontend-dashboard/src/locales/index.ts +1 -1
- package/templates/apps/frontend-docs/package.json +7 -7
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-portal/README.md +71 -0
- package/templates/apps/frontend-portal/app.config.ts +37 -0
- package/templates/apps/frontend-portal/package.json +32 -0
- package/templates/apps/frontend-portal/src/config.ts +8 -0
- package/templates/apps/frontend-portal/src/globals.css +93 -0
- package/templates/apps/frontend-portal/src/globals.d.ts +6 -0
- package/templates/apps/frontend-portal/src/lib/api.ts +62 -0
- package/templates/apps/frontend-portal/src/locales/de.ts +86 -0
- package/templates/apps/frontend-portal/src/locales/en.ts +93 -0
- package/templates/apps/frontend-portal/src/locales/index.ts +14 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/api-keys/page.test.tsx +71 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/api-keys/page.tsx +124 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/billing/page.test.tsx +86 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/billing/page.tsx +97 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/error.tsx +19 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/invoices/page.tsx +45 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/layout.test.tsx +31 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/layout.tsx +63 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/not-found.tsx +15 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/page.tsx +39 -0
- package/templates/apps/frontend-portal/src/pages/(portal)/profile/page.tsx +79 -0
- package/templates/apps/frontend-portal/src/pages/layout.tsx +12 -0
- package/templates/apps/frontend-portal/src/pages/login/page.test.tsx +58 -0
- package/templates/apps/frontend-portal/src/pages/login/page.tsx +96 -0
- package/templates/apps/frontend-portal/template.json +6 -0
- package/templates/apps/frontend-portal/tsconfig.json +5 -0
- package/templates/apps/frontend-saas/README.md +73 -0
- package/templates/apps/frontend-saas/app.config.ts +46 -0
- package/templates/apps/frontend-saas/package.json +32 -0
- package/templates/apps/frontend-saas/src/config.ts +8 -0
- package/templates/apps/frontend-saas/src/globals.css +85 -0
- package/templates/apps/frontend-saas/src/globals.d.ts +6 -0
- package/templates/apps/frontend-saas/src/lib/api.ts +47 -0
- package/templates/apps/frontend-saas/src/locales/de.ts +72 -0
- package/templates/apps/frontend-saas/src/locales/en.ts +81 -0
- package/templates/apps/frontend-saas/src/locales/index.ts +14 -0
- package/templates/apps/frontend-saas/src/pages/(marketing)/layout.tsx +30 -0
- package/templates/apps/frontend-saas/src/pages/(marketing)/login/page.test.tsx +58 -0
- package/templates/apps/frontend-saas/src/pages/(marketing)/login/page.tsx +96 -0
- package/templates/apps/frontend-saas/src/pages/(marketing)/page.tsx +27 -0
- package/templates/apps/frontend-saas/src/pages/dashboard/billing/page.tsx +72 -0
- package/templates/apps/frontend-saas/src/pages/dashboard/error.tsx +20 -0
- package/templates/apps/frontend-saas/src/pages/dashboard/layout.test.tsx +32 -0
- package/templates/apps/frontend-saas/src/pages/dashboard/layout.tsx +69 -0
- package/templates/apps/frontend-saas/src/pages/dashboard/not-found.tsx +17 -0
- package/templates/apps/frontend-saas/src/pages/dashboard/page.test.tsx +113 -0
- package/templates/apps/frontend-saas/src/pages/dashboard/page.tsx +76 -0
- package/templates/apps/frontend-saas/src/pages/dashboard/team/page.tsx +73 -0
- package/templates/apps/frontend-saas/src/pages/layout.tsx +12 -0
- package/templates/apps/frontend-saas/template.json +6 -0
- package/templates/apps/frontend-saas/tsconfig.json +5 -0
- package/templates/apps/frontend-spa/app.config.ts +1 -1
- package/templates/apps/frontend-spa/package.json +7 -7
- package/templates/apps/frontend-spa/src/locales/index.ts +1 -1
- package/templates/apps/frontend-spa/src/pages/layout.tsx +1 -1
- package/templates/apps/frontend-spa/src/pages/page.tsx +1 -1
- package/templates/apps/frontend-ssr/app.config.ts +1 -1
- package/templates/apps/frontend-ssr/package.json +7 -7
- package/templates/apps/frontend-ssr/src/locales/index.ts +1 -1
- package/templates/apps/frontend-ssr/src/pages/layout.tsx +1 -1
- package/templates/apps/frontend-ssr/src/pages/page.tsx +1 -1
- package/templates/apps/frontend-ssr-api/app.config.ts +1 -1
- package/templates/apps/frontend-ssr-api/package.json +8 -8
- package/templates/apps/frontend-ssr-api/src/locales/index.ts +1 -1
- package/templates/apps/frontend-ssr-api/src/pages/layout.tsx +1 -1
- package/templates/apps/frontend-static-blog/package.json +6 -6
- package/templates/apps/frontend-status/README.md +51 -0
- package/templates/apps/frontend-status/app.config.ts +39 -0
- package/templates/apps/frontend-status/package.json +32 -0
- package/templates/apps/frontend-status/src/config.ts +7 -0
- package/templates/apps/frontend-status/src/globals.css +70 -0
- package/templates/apps/frontend-status/src/globals.d.ts +6 -0
- package/templates/apps/frontend-status/src/lib/status.ts +81 -0
- package/templates/apps/frontend-status/src/locales/de.ts +41 -0
- package/templates/apps/frontend-status/src/locales/en.ts +45 -0
- package/templates/apps/frontend-status/src/locales/index.ts +13 -0
- package/templates/apps/frontend-status/src/pages/layout.tsx +27 -0
- package/templates/apps/frontend-status/src/pages/page.test.tsx +123 -0
- package/templates/apps/frontend-status/src/pages/page.tsx +136 -0
- package/templates/apps/frontend-status/template.json +6 -0
- package/templates/apps/frontend-status/tsconfig.json +11 -0
- package/templates/apps/mobile-app/README.md +58 -0
- package/templates/apps/mobile-app/app.config.ts +33 -0
- package/templates/apps/mobile-app/babel.config.js +5 -0
- package/templates/apps/mobile-app/metro.config.js +20 -0
- package/templates/apps/mobile-app/package.json +33 -0
- package/templates/apps/mobile-app/src/app/_layout.tsx +61 -0
- package/templates/apps/mobile-app/src/app/index.tsx +62 -0
- package/templates/apps/mobile-app/src/app/orders/[id].tsx +19 -0
- package/templates/apps/mobile-app/src/app/settings.tsx +51 -0
- package/templates/apps/mobile-app/src/client.ts +74 -0
- package/templates/apps/mobile-app/src/lib/deeplinks.ts +39 -0
- package/templates/apps/mobile-app/src/lib/notifications.ts +31 -0
- package/templates/apps/mobile-app/src/lib/sync.ts +29 -0
- package/templates/apps/mobile-app/src/persistence.ts +38 -0
- package/templates/apps/mobile-app/template.json +6 -0
- package/templates/apps/mobile-app/tests/deeplinks.test.ts +32 -0
- package/templates/apps/mobile-app/tests/notifications.test.ts +26 -0
- package/templates/apps/mobile-app/tests/sync.test.ts +34 -0
- package/templates/apps/mobile-app/tsconfig.json +10 -0
- package/templates/apps/mobile-app/voltro.mobile.ts +11 -0
- package/templates/baselines/compose/docker-compose.prod.yml +15 -0
- package/templates/baselines/compose-mariadb/docker-compose.prod.yml +15 -0
- package/templates/patches/@effect__cluster@0.60.0.patch +6 -6
- package/dist/apiBuild-DgBS9ayv.js +0 -2
- package/dist/dbCommand-DvguqlzF.js +0 -2
- package/dist/fileConventions-3bffWssN.js +0 -30
- package/dist/frameworkTableAssembly-lrjZtk0G.js +0 -2
- package/dist/inspect-gt8bq-Tz.js +0 -2
- package/dist/manifestBuild-ifczArzr.js +0 -2
- package/dist/serveCommand-ZTn-dPFa.js +0 -1425
|
@@ -0,0 +1,1577 @@
|
|
|
1
|
+
import { lt as e, st as t, t as n } from "./inspectMetrics-BeJdP_3b.js";
|
|
2
|
+
import { n as r, s as i, t as a } from "./seedRunner-Bqxgp7HZ.js";
|
|
3
|
+
import { r as o, t as s } from "./appModuleLoader-C9r9mxZt.js";
|
|
4
|
+
import { $ as c, $t as l, A as u, At as d, B as ee, Bt as f, C as te, Ct as ne, D as p, Dt as m, E as h, Et as g, F as _, Ft as re, G as ie, H as v, I as y, It as ae, J as oe, Jt as b, K as se, L as ce, M as le, Mt as x, N as S, Nt as ue, O as de, Ot as fe, P as pe, Pt as me, Q as he, Qt as ge, R as _e, Rt as C, S as ve, St as ye, T as be, Tt as w, U as xe, V as Se, Vt as T, W as E, X as Ce, Xt as D, Y as we, Yt as Te, Z as Ee, Zt as De, _ as Oe, _t as ke, an as O, at as k, b as Ae, bt as je, c as Me, ct as A, d as Ne, dt as Pe, en as Fe, et as Ie, ft as Le, g as Re, gt as ze, h as Be, ht as Ve, i as He, it as Ue, j, jt as We, k as Ge, kt as Ke, lt as qe, mt as Je, nn as Ye, nt as Xe, o as Ze, on as Qe, ot as $e, pt as M, q as et, qt as tt, r as nt, rn as N, rt, sn as it, st as P, t as at, tn as ot, tt as st, u as ct, ut as lt, v as ut, vt as dt, w as ft, wt as pt, x as mt, xt as ht, y as F, yt as gt, zt as _t } from "./dev-DmnkH-wr.js";
|
|
5
|
+
import { _ as vt, f as yt, m as I, n as L, p as bt, u as xt, v as St } from "./frameworkTableAssembly-BzAajuUv.js";
|
|
6
|
+
import { S as Ct, c as wt, n as Tt, p as Et, s as R } from "./fileConventions-Cof68_BL.js";
|
|
7
|
+
import { m as Dt } from "./inspect-BUUjt773.js";
|
|
8
|
+
import { n as Ot, t as kt } from "./startupRunner-DPGFchOa.js";
|
|
9
|
+
import { r as At, u as jt } from "./apiBuild-BceikpQf.js";
|
|
10
|
+
import { t as z } from "./bootTiming-BdyP9nYw.js";
|
|
11
|
+
import { n as Mt } from "./cliArgs-qdZSElM3.js";
|
|
12
|
+
import { basename as Nt, join as Pt } from "node:path";
|
|
13
|
+
import { pathToFileURL as Ft } from "node:url";
|
|
14
|
+
import { Cause as It, Effect as B, Layer as V, ManagedRuntime as Lt } from "effect";
|
|
15
|
+
import { createLogger as H } from "@voltro/logger";
|
|
16
|
+
import { existsSync as Rt } from "node:fs";
|
|
17
|
+
import { AggregateRegistry as zt, CostRegistry as Bt, Dispatcher as Vt, ExpectationRegistry as Ht, ExperimentRegistry as Ut, apiKeyManagementRoutes as Wt, attachAnalyticsMirror as Gt, attachExpectations as Kt, attachExperiments as qt, attachFinops as Jt, awaitServerListening as Yt, bindMutation as U, bindStream as Xt, bindSubscription as W, buildTracingLayer as Zt, cancelWakeup as Qt, compileCron as $t, dataStoreApiKeyStore as en, dataStoreIdempotencyStore as tn, formatServerOnlyLeaks as nn, formatUnresolvedSources as rn, frameworkApiKeyStrategy as an, getCredentialExpiry as on, installPolicyGuardResolver as sn, loadResourceTuples as cn, makeActionRunner as ln, makeAdvisoryLockCoordinator as un, makeApiKeyService as dn, makeApiKeyUsageBuffer as fn, makeApiKeyUsageFlusher as pn, makeAsyncKv as mn, makeCoordinatedScheduler as hn, makeEffectStoreLayer as gn, makeLazyWorkflowFacade as _n, makeMutationOutputCodec as vn, makeMutationRunner as yn, makeOneShotQueryRunner as bn, makeQueryDescriptorProducer as xn, makeQueryFinalizer as Sn, makeQueryReauthorizer as Cn, makeQuerySubscriber as wn, makeSchemaRegistry as Tn, makeWorkflowFacade as En, makeWorkflowFacadeWithCallerContext as G, makeWorkflowLayers as Dn, noopKv as K, onProcessShutdown as On, recordCredentialExpiry as kn, recordSubscriptionDelivery as An, recordWorkflowRun as jn, registerWakeup as Mn, resolveSecretsBackend as Nn, runProvidedEffect as Pn, setSecretsBackend as Fn, setSystemStoreHandle as In, setTupleSource as Ln, singleCoordinator as Rn, startRpcServer as zn, startScheduler as Bn, stripForbiddenForWire as Vn, unresolvedSources as Hn, workflowToRpc as Un, wrapStoreWithBootCodec as Wn } from "@voltro/runtime";
|
|
18
|
+
import { RpcGroup as Gn } from "@effect/rpc";
|
|
19
|
+
import { SqlClient as Kn } from "@effect/sql";
|
|
20
|
+
import { allRegisteredTables as qn, and as Jn, ensureTableRegistered as Yn, eq as q, or as Xn } from "@voltro/database";
|
|
21
|
+
import { appStorageProvider as Zn, fromNodeReadable as Qn, getObjectStream as $n, putObjectStream as er, toNodeReadable as tr } from "@voltro/plugin-storage";
|
|
22
|
+
import { AuthMiddleware as nr, ConnectionInfoMiddleware as rr, actionToRpc as J, anonymousSubject as ir, isWireReachable as ar, mutationToRpc as Y, queryToRpc as X, streamToRpc as or, workflowCancelDescriptor as Z, workflowDomainEventsQueryDescriptor as sr, workflowEventDeliveriesQueryDescriptor as cr, workflowResumeDescriptor as lr, workflowRunEventsQueryDescriptor as ur, workflowRunQueryDescriptor as dr, workflowRunStepsQueryDescriptor as fr, workflowRunsQueryDescriptor as pr, workflowSignalDescriptor as mr, workflowUpdateDescriptor as hr } from "@voltro/protocol";
|
|
23
|
+
import { isEnvContract as gr } from "@voltro/env";
|
|
24
|
+
import { assertProductionSessionSecret as _r, sessionExpiryFromHeaders as vr } from "@voltro/protocol/session";
|
|
25
|
+
import { createHash as yr, timingSafeEqual as br } from "node:crypto";
|
|
26
|
+
import { declaredSnapshot as xr, describeOutcome as Sr, runPlannedMigrations as Cr } from "@voltro/database/sql";
|
|
27
|
+
import { buildDeliverWebhookExecute as wr, buildWebhooksService as Tr, defaultIncomingPath as Er, deliverWebhookWorkflow as Dr, makeDeferredEmitHandler as Or, mountIncomingWebhook as kr } from "@voltro/plugin-webhooks";
|
|
28
|
+
import { getAuthSessionStrategy as Ar } from "@voltro/plugin-auth";
|
|
29
|
+
import { collectPublicApiRoutes as jr, restRoutesToHttpRoutes as Mr } from "@voltro/protocol/rest";
|
|
30
|
+
import { registerEmailTemplates as Nr } from "@voltro/plugin-mail";
|
|
31
|
+
import { channelFor as Pr, getBroadcastPlugin as Fr } from "@voltro/plugin-broadcast";
|
|
32
|
+
import { packBundle as Ir, runExport as Lr, runImport as Rr, storageBlobSink as zr, storageRefsBlobSource as Br, unpackBundle as Vr, unpackBundleToDir as Hr } from "@voltro/data-transfer";
|
|
33
|
+
//#region src/dbPoolReport.ts
|
|
34
|
+
var Ur = (e, t) => {
|
|
35
|
+
let n = e !== void 0 && t !== void 0 ? e * t : void 0;
|
|
36
|
+
return e === void 0 ? "db pool: max per replica UNSET (DB_MAX_CONNECTIONS) — each replica opens the driver's default pool, so the fleet total is that default × replicas. Set DB_MAX_CONNECTIONS so the total stays under your database's connection limit; the pool scales with replicaCount and the database does not." : `db pool: max=${e} per replica (DB_MAX_CONNECTIONS)` + (n === void 0 ? " — the fleet opens up to max × replicas connections. Check that against your database's limit before raising replicaCount." : ` × ${t} replicas = up to ${n} connections. Check that against your database's limit.`);
|
|
37
|
+
}, Wr = (e = process.env) => {
|
|
38
|
+
let t = e.REPLICA_COUNT;
|
|
39
|
+
if (t === void 0 || t === "") return;
|
|
40
|
+
let n = Number(t);
|
|
41
|
+
return Number.isInteger(n) && n > 0 ? n : void 0;
|
|
42
|
+
}, Gr = "/_voltro/admin/import", Kr = "/_voltro/admin/export", Q = (e, t) => ({
|
|
43
|
+
status: e,
|
|
44
|
+
contentType: "application/json; charset=utf-8",
|
|
45
|
+
body: JSON.stringify(t)
|
|
46
|
+
}), qr = (e) => {
|
|
47
|
+
let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
|
|
48
|
+
return n ? n[1] : null;
|
|
49
|
+
}, Jr = (e, t) => br(yr("sha256").update(e).digest(), yr("sha256").update(t).digest()), Yr = (e, t) => {
|
|
50
|
+
if (e.method.toUpperCase() !== "POST") return Q(405, { error: "method not allowed" });
|
|
51
|
+
if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
|
|
52
|
+
let n = qr(e.headers);
|
|
53
|
+
return !n || !Jr(n, t) ? Q(401, { error: "unauthorized" }) : null;
|
|
54
|
+
}, Xr = H({ scope: "voltro:admin-import" }), Zr = "VBUNDLE2", Qr = async function* (e) {
|
|
55
|
+
yield e;
|
|
56
|
+
}, $r = (e) => async (t) => {
|
|
57
|
+
let n = Yr(t, e.secret);
|
|
58
|
+
if (n) return n;
|
|
59
|
+
let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"] === "1" || t.headers["x-import-atomic"] === "true", o = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === Zr, c, l;
|
|
60
|
+
if (s) c = Qr(t.rawBody), l = "upload";
|
|
61
|
+
else {
|
|
62
|
+
let n;
|
|
63
|
+
try {
|
|
64
|
+
n = JSON.parse(Buffer.from(t.rawBody).toString("utf8") || "{}");
|
|
65
|
+
} catch {
|
|
66
|
+
return Q(400, { error: "body must be a packed bundle archive or { bundleKey } JSON" });
|
|
67
|
+
}
|
|
68
|
+
if (typeof n.bundleKey != "string" || !n.bundleKey) return Q(400, { error: "body.bundleKey (string) is required for the storage transport" });
|
|
69
|
+
if (!e.openArchive) return Q(501, { error: "storage transport not configured on this instance" });
|
|
70
|
+
c = e.openArchive(n.bundleKey), l = "storage";
|
|
71
|
+
}
|
|
72
|
+
let u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-import-"));
|
|
73
|
+
try {
|
|
74
|
+
e.assetSink ? await Vr(c, {
|
|
75
|
+
dir: f,
|
|
76
|
+
blobs: e.assetSink
|
|
77
|
+
}) : await Hr(c, f);
|
|
78
|
+
let t = await B.runPromiseExit(Rr({
|
|
79
|
+
store: e.store,
|
|
80
|
+
bundleDir: f,
|
|
81
|
+
...r ? { mode: r } : {},
|
|
82
|
+
...i ? { onConflict: i } : {},
|
|
83
|
+
...a ? { atomic: a } : {},
|
|
84
|
+
...e.snapshot ? { targetSnapshot: e.snapshot } : {},
|
|
85
|
+
force: o,
|
|
86
|
+
onWarn: (e) => Xr.warn("admin.import", { message: e }),
|
|
87
|
+
...e.assetSink ? { assetsAlreadyRestored: !0 } : {}
|
|
88
|
+
}));
|
|
89
|
+
if (t._tag === "Failure") {
|
|
90
|
+
let e = t.cause._tag === "Fail" ? t.cause.error : void 0;
|
|
91
|
+
if (e && e._tag === "SchemaDriftError") {
|
|
92
|
+
let t = e;
|
|
93
|
+
return Xr.warn("admin.import refused (schema drift)", {
|
|
94
|
+
transport: l,
|
|
95
|
+
bundle: t.bundleFingerprint.slice(0, 16),
|
|
96
|
+
target: t.targetFingerprint.slice(0, 16)
|
|
97
|
+
}), Q(409, {
|
|
98
|
+
error: "schema drift",
|
|
99
|
+
bundleFingerprint: t.bundleFingerprint,
|
|
100
|
+
targetFingerprint: t.targetFingerprint,
|
|
101
|
+
diff: t.diff,
|
|
102
|
+
hint: "re-export against the current schema, or resend with x-import-force: 1"
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
throw Error(String(e?.message ?? e ?? "import failed"));
|
|
106
|
+
}
|
|
107
|
+
let n = t.value, s = n.tables.reduce((e, t) => e + t.rowCount, 0);
|
|
108
|
+
return Xr.info("admin.import", {
|
|
109
|
+
transport: l,
|
|
110
|
+
tables: n.tables.length,
|
|
111
|
+
rows: s,
|
|
112
|
+
mode: r ?? "upsert",
|
|
113
|
+
atomic: a
|
|
114
|
+
}), Q(200, {
|
|
115
|
+
tables: n.tables.length,
|
|
116
|
+
rows: s,
|
|
117
|
+
transport: l
|
|
118
|
+
});
|
|
119
|
+
} catch (e) {
|
|
120
|
+
return Xr.warn("admin.import failed", {
|
|
121
|
+
transport: l,
|
|
122
|
+
error: e?.message ?? String(e)
|
|
123
|
+
}), Q(500, {
|
|
124
|
+
error: "import failed",
|
|
125
|
+
message: e?.message ?? String(e)
|
|
126
|
+
});
|
|
127
|
+
} finally {
|
|
128
|
+
await d.rm(f, {
|
|
129
|
+
recursive: !0,
|
|
130
|
+
force: !0
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}, ei = H({ scope: "voltro:admin-export" }), ti = async (e) => {
|
|
134
|
+
let t = [];
|
|
135
|
+
for await (let n of e) t.push(Buffer.from(n));
|
|
136
|
+
return new Uint8Array(Buffer.concat(t));
|
|
137
|
+
}, ni = (e) => typeof e.tenant == "string" && e.tenant ? {
|
|
138
|
+
kind: "tenant",
|
|
139
|
+
tenantId: e.tenant
|
|
140
|
+
} : Array.isArray(e.tables) && e.tables.length ? {
|
|
141
|
+
kind: "tables",
|
|
142
|
+
tables: e.tables.filter((e) => typeof e == "string")
|
|
143
|
+
} : { kind: "all" }, ri = (e) => async (t) => {
|
|
144
|
+
let n = Yr(t, e.secret);
|
|
145
|
+
if (n) return n;
|
|
146
|
+
let r;
|
|
147
|
+
try {
|
|
148
|
+
r = JSON.parse(Buffer.from(t.rawBody).toString("utf8") || "{}");
|
|
149
|
+
} catch {
|
|
150
|
+
return Q(400, { error: "body must be JSON: { profile?, tenant?, tables?, consistency?, compression?, bundleKey? }" });
|
|
151
|
+
}
|
|
152
|
+
let i = {};
|
|
153
|
+
if (typeof r.profile == "string" && r.profile) {
|
|
154
|
+
if (!e.loadProfile) return Q(501, { error: "server-side profiles not configured on this instance" });
|
|
155
|
+
try {
|
|
156
|
+
i = await e.loadProfile(r.profile);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
return Q(400, {
|
|
159
|
+
error: `profile '${r.profile}' could not be loaded`,
|
|
160
|
+
message: e?.message ?? String(e)
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? ni(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-export-"));
|
|
165
|
+
try {
|
|
166
|
+
let t = await B.runPromise(Lr({
|
|
167
|
+
store: e.store,
|
|
168
|
+
snapshot: e.snapshot,
|
|
169
|
+
dialect: e.dialect,
|
|
170
|
+
outDir: f,
|
|
171
|
+
...i.subset ? { subset: i.subset } : {
|
|
172
|
+
scope: s,
|
|
173
|
+
...e.tenantTables && e.tenantTables.length > 0 ? { tenantTables: e.tenantTables } : {}
|
|
174
|
+
},
|
|
175
|
+
consistency: a,
|
|
176
|
+
...o ? { compression: o } : {},
|
|
177
|
+
...i.masking ? { masking: i.masking } : {}
|
|
178
|
+
})), n = t.tables.reduce((e, t) => e + t.rowCount, 0), u = t.masking?.transformed.length ?? 0;
|
|
179
|
+
if (c) {
|
|
180
|
+
if (!e.putArchive) return Q(501, { error: "storage transport not configured on this instance" });
|
|
181
|
+
let i = r.bundleKey;
|
|
182
|
+
return await e.putArchive(i, () => Ir({
|
|
183
|
+
dir: f,
|
|
184
|
+
...l
|
|
185
|
+
})), ei.info("admin.export", {
|
|
186
|
+
transport: "storage",
|
|
187
|
+
tables: t.tables.length,
|
|
188
|
+
rows: n,
|
|
189
|
+
masked: u,
|
|
190
|
+
bundleKey: i
|
|
191
|
+
}), Q(200, {
|
|
192
|
+
bundleKey: i,
|
|
193
|
+
tables: t.tables.length,
|
|
194
|
+
rows: n,
|
|
195
|
+
masked: u,
|
|
196
|
+
transport: "storage"
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
let d = await ti(Ir({
|
|
200
|
+
dir: f,
|
|
201
|
+
...l
|
|
202
|
+
}));
|
|
203
|
+
return ei.info("admin.export", {
|
|
204
|
+
transport: "download",
|
|
205
|
+
tables: t.tables.length,
|
|
206
|
+
rows: n,
|
|
207
|
+
masked: u,
|
|
208
|
+
bytes: d.byteLength
|
|
209
|
+
}), {
|
|
210
|
+
status: 200,
|
|
211
|
+
contentType: "application/octet-stream",
|
|
212
|
+
body: d,
|
|
213
|
+
headers: {
|
|
214
|
+
"x-export-tables": String(t.tables.length),
|
|
215
|
+
"x-export-rows": String(n),
|
|
216
|
+
"x-export-masked": String(u)
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
} catch (e) {
|
|
220
|
+
return ei.warn("admin.export failed", { error: e?.message ?? String(e) }), Q(500, {
|
|
221
|
+
error: "export failed",
|
|
222
|
+
message: e?.message ?? String(e)
|
|
223
|
+
});
|
|
224
|
+
} finally {
|
|
225
|
+
await d.rm(f, {
|
|
226
|
+
recursive: !0,
|
|
227
|
+
force: !0
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}, ii = async (e) => {
|
|
231
|
+
let { resolve: t } = await import("node:path"), { existsSync: n } = await import("node:fs"), r = [
|
|
232
|
+
e,
|
|
233
|
+
`${e}.profile.ts`,
|
|
234
|
+
`data-profiles/${e}.ts`,
|
|
235
|
+
`data-profiles/${e}.profile.ts`
|
|
236
|
+
].map((e) => t(process.cwd(), e)), i = r.find((e) => n(e));
|
|
237
|
+
if (!i) throw Error(`data profile '${e}' not found (looked for: ${r.join(", ")})`);
|
|
238
|
+
let a = await import(i), o = a.default ?? a.profile;
|
|
239
|
+
if (!o) throw Error(`data profile '${i}' has no default export`);
|
|
240
|
+
return o;
|
|
241
|
+
}, ai = (e, t, n = {}) => (async function* () {
|
|
242
|
+
let r = await tr((await B.runPromise($n(e, t).pipe(B.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
|
|
243
|
+
a && clearTimeout(a), a = setTimeout(() => r.destroy(/* @__PURE__ */ Error(`storage read stalled for ${i}ms reading '${t}'`)), i);
|
|
244
|
+
};
|
|
245
|
+
try {
|
|
246
|
+
o();
|
|
247
|
+
for await (let e of r) o(), yield e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
248
|
+
} finally {
|
|
249
|
+
a && clearTimeout(a), r.destroy();
|
|
250
|
+
}
|
|
251
|
+
})(), oi = {
|
|
252
|
+
get: async () => void 0,
|
|
253
|
+
set: async () => {},
|
|
254
|
+
setWithTags: async () => {},
|
|
255
|
+
remove: async () => !1,
|
|
256
|
+
has: async () => !1,
|
|
257
|
+
clear: async () => {},
|
|
258
|
+
invalidateTag: async () => 0,
|
|
259
|
+
wrap: async (e, t, n) => n()
|
|
260
|
+
}, si = async (e) => {
|
|
261
|
+
In({
|
|
262
|
+
dataStore: e.store,
|
|
263
|
+
schemaRegistry: e.schemaRegistry
|
|
264
|
+
});
|
|
265
|
+
let t = (e.discovered.budgets?.length ?? 0) > 0, r, i = new Vt({
|
|
266
|
+
store: e.store,
|
|
267
|
+
...e.snapshotCache ? { cache: e.snapshotCache } : {},
|
|
268
|
+
...t ? { recordCost: (e) => r?.record(e) } : {},
|
|
269
|
+
recordDelivery: (e) => An({
|
|
270
|
+
label: e.label,
|
|
271
|
+
kind: e.kind,
|
|
272
|
+
durationMs: e.durationMs,
|
|
273
|
+
rowCount: e.rowCount
|
|
274
|
+
})
|
|
275
|
+
}), a = e.cache ?? oi, o = e.kv ?? K, s, c = () => void 0, l, u, d, f, te, ne, p, m = /* @__PURE__ */ new Map(), h = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, ie = async (t, n, r) => {
|
|
276
|
+
let i = {
|
|
277
|
+
...r,
|
|
278
|
+
source: r.source ?? `workflow:${t}`
|
|
279
|
+
};
|
|
280
|
+
m.set(n, i);
|
|
281
|
+
try {
|
|
282
|
+
let r = await e.store.query({
|
|
283
|
+
table: "_voltro_workflow_start_contexts",
|
|
284
|
+
order: [],
|
|
285
|
+
predicate: q("executionId", n),
|
|
286
|
+
projection: ["id"],
|
|
287
|
+
skip: void 0,
|
|
288
|
+
take: 1
|
|
289
|
+
}), a = {
|
|
290
|
+
workflowName: t,
|
|
291
|
+
executionId: n,
|
|
292
|
+
subject: i.subject ?? null,
|
|
293
|
+
traceId: i.traceId ?? null,
|
|
294
|
+
source: i.source ?? null,
|
|
295
|
+
parentExecutionId: i.parentExecutionId ?? null,
|
|
296
|
+
parentClosePolicy: i.parentClosePolicy ?? null,
|
|
297
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
298
|
+
};
|
|
299
|
+
r[0] === void 0 ? await e.store.insert("_voltro_workflow_start_contexts", {
|
|
300
|
+
id: h(),
|
|
301
|
+
...a
|
|
302
|
+
}) : await e.store.update("_voltro_workflow_start_contexts", r[0].id, a);
|
|
303
|
+
} catch (e) {
|
|
304
|
+
process.stderr.write(`[workflow] failed to persist start context for ${t}/${n}: ${e?.message ?? String(e)}\n`);
|
|
305
|
+
}
|
|
306
|
+
}, ae = async (t, n) => {
|
|
307
|
+
let r = m.get(n);
|
|
308
|
+
if (r !== void 0) return r;
|
|
309
|
+
try {
|
|
310
|
+
let t = (await e.store.query({
|
|
311
|
+
table: "_voltro_workflow_start_contexts",
|
|
312
|
+
order: [],
|
|
313
|
+
predicate: q("executionId", n),
|
|
314
|
+
projection: void 0,
|
|
315
|
+
skip: void 0,
|
|
316
|
+
take: 1
|
|
317
|
+
}))[0];
|
|
318
|
+
if (t === void 0) return;
|
|
319
|
+
let r = {
|
|
320
|
+
...t.subject === null ? {} : { subject: t.subject },
|
|
321
|
+
...t.traceId === null ? {} : { traceId: t.traceId },
|
|
322
|
+
...t.source === null ? {} : { source: t.source },
|
|
323
|
+
...t.parentExecutionId === null ? {} : { parentExecutionId: t.parentExecutionId },
|
|
324
|
+
...t.parentClosePolicy === null ? {} : { parentClosePolicy: t.parentClosePolicy }
|
|
325
|
+
};
|
|
326
|
+
return m.set(n, r), r;
|
|
327
|
+
} catch (e) {
|
|
328
|
+
process.stderr.write(`[workflow] failed to load start context for ${n}: ${e?.message ?? String(e)}\n`);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
}, b = (e.discovered.workflows?.length ?? 0) > 0 ? _n(() => s) : void 0, ce = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ue = ce || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", de = e.tenantIsolation === "namespace", fe = (e.log ?? H({ scope: "voltro:serve" })).child("webhooks"), he, _e, C = e.discovered.webhooks;
|
|
332
|
+
if (C && C.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
|
|
333
|
+
e.workflowEngineLayer;
|
|
334
|
+
let t = ge({
|
|
335
|
+
store: e.store,
|
|
336
|
+
schemaRegistry: e.schemaRegistry,
|
|
337
|
+
cache: a,
|
|
338
|
+
kv: o
|
|
339
|
+
}), n = C.outgoing.map((e) => e.descriptor);
|
|
340
|
+
_e = Dr.toLayer(wr(t, { events: n })), he = Tr(t, async (e) => {
|
|
341
|
+
let t = d;
|
|
342
|
+
if (t === void 0) {
|
|
343
|
+
fe.error("webhook delivery skipped — the workflow runtime was never built. This is a framework defect, not a configuration problem: report it with your engine setting. Deliveries are NOT queued and will not be retried.", {
|
|
344
|
+
deliveryId: e.deliveryId,
|
|
345
|
+
targetId: e.targetId
|
|
346
|
+
});
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
t.runPromise(Dr.execute(e)).catch((t) => {
|
|
350
|
+
fe.error("deliverWebhook workflow crashed", {
|
|
351
|
+
deliveryId: e.deliveryId,
|
|
352
|
+
targetId: e.targetId
|
|
353
|
+
}, t);
|
|
354
|
+
});
|
|
355
|
+
}, { events: n });
|
|
356
|
+
}
|
|
357
|
+
let ve = /* @__PURE__ */ new Map();
|
|
358
|
+
if (C) for (let e of C.incoming) {
|
|
359
|
+
let t = e.descriptor.path ?? Er(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = kr(e.descriptor, {
|
|
360
|
+
resolveSecret: async () => process.env[n] ?? null,
|
|
361
|
+
resolveWorkflows: () => b === void 0 ? void 0 : G(b, {
|
|
362
|
+
traceId: `incoming:${e.descriptor.id}`,
|
|
363
|
+
source: `incoming:${e.descriptor.id}`
|
|
364
|
+
}),
|
|
365
|
+
log: (e) => {
|
|
366
|
+
let t = {
|
|
367
|
+
webhookId: e.webhookId,
|
|
368
|
+
status: e.status,
|
|
369
|
+
signatureOk: String(e.signatureOk),
|
|
370
|
+
idempotency: e.idempotency,
|
|
371
|
+
durationMs: e.durationMs
|
|
372
|
+
};
|
|
373
|
+
e.status >= 500 ? fe.error("incoming delivery failed", t) : e.status >= 400 ? fe.warn("incoming delivery rejected", t) : fe.info("incoming delivery handled", t);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
ve.set(t, { handle: r });
|
|
377
|
+
}
|
|
378
|
+
sn(), Ln((t) => cn(e.store, t.subjectId, t.resourceType, t.resourceId));
|
|
379
|
+
let ye = [...e.discovered.outboxHandlers ?? [], ...Pe((C?.outgoing.length ?? 0) + (C?.incoming.length ?? 0) + (C?.providers.length ?? 0), []) ? [{
|
|
380
|
+
file: "<framework>/webhooks",
|
|
381
|
+
id: "voltro-webhook-emit",
|
|
382
|
+
definition: Or(() => he)
|
|
383
|
+
}] : []], be = ye.length > 0 ? me({
|
|
384
|
+
handlers: ye,
|
|
385
|
+
store: e.store,
|
|
386
|
+
log: (e.log ?? H({ scope: "voltro:serve" })).child("outbox")
|
|
387
|
+
}) : void 0, T = x({
|
|
388
|
+
definitions: (e.discovered.connections ?? []).map((e) => e.definition),
|
|
389
|
+
store: e.store,
|
|
390
|
+
publicUrl: We(e.port ?? 4e3),
|
|
391
|
+
log: (e.log ?? H({ scope: "voltro:serve" })).child("connections")
|
|
392
|
+
});
|
|
393
|
+
le({
|
|
394
|
+
events: e.discovered.events ?? [],
|
|
395
|
+
rpcTags: [
|
|
396
|
+
...e.discovered.queries.map((e) => e.descriptor.name),
|
|
397
|
+
...e.discovered.mutations.map((e) => e.descriptor.name),
|
|
398
|
+
...e.discovered.actions.map((e) => e.descriptor.name),
|
|
399
|
+
...(e.discovered.streams ?? []).map((e) => e.descriptor.name)
|
|
400
|
+
]
|
|
401
|
+
});
|
|
402
|
+
let Ce = (e.log ?? H({ scope: "voltro:serve" })).child("events"), Te = e.broadcastNamespace ?? ut(e.plugins, void 0), Ee = F(e.plugins, Te, Ce), Oe = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, ke = e.membership ?? Ae(e.plugins, {
|
|
403
|
+
instanceId: Oe,
|
|
404
|
+
namespace: Te,
|
|
405
|
+
meta: { mode: "serve" },
|
|
406
|
+
logger: Ce
|
|
407
|
+
}), O = S({
|
|
408
|
+
events: e.discovered.events ?? [],
|
|
409
|
+
origin: Oe,
|
|
410
|
+
...Ee.publishRemote === void 0 ? {} : { publishRemote: Ee.publishRemote }
|
|
411
|
+
}), Me = (e.discovered.events ?? []).length > 0 ? await Ee.attach(O.bus) : null, A = De({
|
|
412
|
+
store: e.store,
|
|
413
|
+
schemaRegistry: e.schemaRegistry,
|
|
414
|
+
cache: a,
|
|
415
|
+
kv: o,
|
|
416
|
+
...he === void 0 ? {} : { webhooksService: he },
|
|
417
|
+
...b === void 0 ? {} : { workflowsProxy: b },
|
|
418
|
+
eventTriggers: e.discovered.eventTriggers ?? [],
|
|
419
|
+
namespaceIsolationOn: de,
|
|
420
|
+
...be === void 0 ? {} : { outbox: { nudge: be.nudge } },
|
|
421
|
+
...T.active ? { connections: { registry: T.registry } } : {},
|
|
422
|
+
eventBus: O.bus
|
|
423
|
+
}), Ne = V.succeed(zt, ht), Fe = V.succeed(Ht, Ve), Le = V.succeed(Bt, Je), Re = V.succeed(Ut, ze), Be = (t, n) => {
|
|
424
|
+
let r = t.pipe(B.provide(gn(n)));
|
|
425
|
+
return (e.baseLayer ? r.pipe(B.provide(e.baseLayer)) : r).pipe(B.provide(Ne)).pipe(B.provide(Fe)).pipe(B.provide(Le)).pipe(B.provide(Re));
|
|
426
|
+
}, He = (e, t) => Pn(Be(e, t)), Ue = n(), j = se(e.plugins ?? [], Ue), Ge = E(e.plugins ?? [], Ue), Ke = yn({
|
|
427
|
+
store: e.store,
|
|
428
|
+
recordMetric: (e) => {
|
|
429
|
+
Ue.record(e);
|
|
430
|
+
},
|
|
431
|
+
...j.mutation === void 0 ? {} : { interceptor: j.mutation },
|
|
432
|
+
buildContext: (e, t, n) => A(e, t, n),
|
|
433
|
+
runEffect: He,
|
|
434
|
+
undoCapture: we()
|
|
435
|
+
}), Ye = oe(), Xe = ln({
|
|
436
|
+
buildContext: (e) => A(e),
|
|
437
|
+
runEffect: He,
|
|
438
|
+
recordMetric: (e) => {
|
|
439
|
+
Ue.record(e);
|
|
440
|
+
},
|
|
441
|
+
...j.action === void 0 ? {} : { interceptor: j.action }
|
|
442
|
+
}), Ze = Sn({
|
|
443
|
+
tenantScopedTables: e.tenantScopedTables,
|
|
444
|
+
softDeleteScopedTables: e.softDeleteScopedTables
|
|
445
|
+
}), Qe = {
|
|
446
|
+
buildContext: (e) => A(e),
|
|
447
|
+
finalize: (e, t) => Ze(e, t.subject),
|
|
448
|
+
provideEffect: Be,
|
|
449
|
+
...j.query === void 0 ? {} : { interceptor: j.query }
|
|
450
|
+
}, M = xn(Qe), et = bn({
|
|
451
|
+
...Qe,
|
|
452
|
+
queryRows: (t, n) => e.store.query(t).then((e) => Vn(t.table, e, n.subject))
|
|
453
|
+
}), nt = wn({
|
|
454
|
+
...Qe,
|
|
455
|
+
subscribeDescriptor: (e, t, n) => i.subscribe(e, t, n),
|
|
456
|
+
subscribeComputed: (e, t, n) => i.subscribeComputed(e, t, n)
|
|
457
|
+
}), N = (e) => e.filter((e) => ar(e.descriptor)), P = {};
|
|
458
|
+
for (let t of [
|
|
459
|
+
...N(e.discovered.queries),
|
|
460
|
+
...Ye.queries,
|
|
461
|
+
...T.queries
|
|
462
|
+
]) P[t.descriptor.name] = (e) => W(M(t, e), i, `subscription.${t.descriptor.name}`, void 0, void 0, Cn(t, e));
|
|
463
|
+
for (let t of [
|
|
464
|
+
...N(e.discovered.mutations),
|
|
465
|
+
...Ye.mutations,
|
|
466
|
+
...T.mutations
|
|
467
|
+
]) {
|
|
468
|
+
let n = vn(t.descriptor.output);
|
|
469
|
+
P[t.descriptor.name] = (r) => U(async (e, n) => Ke(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
|
|
470
|
+
}
|
|
471
|
+
for (let t of [...N(e.discovered.actions), ...T.actions]) {
|
|
472
|
+
let n = vn(t.descriptor.output);
|
|
473
|
+
P[t.descriptor.name] = (r) => U(async (e, n) => Xe(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
|
|
474
|
+
}
|
|
475
|
+
let at = () => `public-${Math.random().toString(36).slice(2, 10)}`, ot = [
|
|
476
|
+
...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
477
|
+
descriptor: e.descriptor,
|
|
478
|
+
invoke: (t, n) => et(e, t, {
|
|
479
|
+
subject: n.subject,
|
|
480
|
+
traceId: at()
|
|
481
|
+
}),
|
|
482
|
+
subscribe: (t, n, r) => nt(e, t, {
|
|
483
|
+
subject: n.subject,
|
|
484
|
+
traceId: at()
|
|
485
|
+
}, r)
|
|
486
|
+
})),
|
|
487
|
+
...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
488
|
+
descriptor: e.descriptor,
|
|
489
|
+
invoke: (t, n) => Ke(e, t, {
|
|
490
|
+
subject: n.subject,
|
|
491
|
+
traceId: at()
|
|
492
|
+
})
|
|
493
|
+
})),
|
|
494
|
+
...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
|
|
495
|
+
descriptor: e.descriptor,
|
|
496
|
+
invoke: (t, n) => Xe(e, t, {
|
|
497
|
+
subject: n.subject,
|
|
498
|
+
traceId: at()
|
|
499
|
+
})
|
|
500
|
+
}))
|
|
501
|
+
], ct = ot.length > 0 ? Mr(jr(ot), {
|
|
502
|
+
store: e.store,
|
|
503
|
+
resolveSubject: (t) => e.resolveSubject(t, -1)
|
|
504
|
+
}) : [], lt = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, dt = lt && lt.length >= 16 ? [{
|
|
505
|
+
method: "POST",
|
|
506
|
+
path: Gr,
|
|
507
|
+
handle: $r({
|
|
508
|
+
secret: lt,
|
|
509
|
+
store: e.store,
|
|
510
|
+
...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
|
|
511
|
+
assetSink: zr(Zn()),
|
|
512
|
+
openArchive: (e) => ai(Zn(), e)
|
|
513
|
+
})
|
|
514
|
+
}, {
|
|
515
|
+
method: "POST",
|
|
516
|
+
path: Kr,
|
|
517
|
+
handle: ri({
|
|
518
|
+
secret: lt,
|
|
519
|
+
store: e.store,
|
|
520
|
+
snapshot: e.dataTransferSnapshot ?? { tables: [] },
|
|
521
|
+
dialect: e.dataTransferDialect ?? "memory",
|
|
522
|
+
tenantTables: [...e.tenantScopedTables],
|
|
523
|
+
loadProfile: ii,
|
|
524
|
+
assetSource: Br(Zn(), e.store),
|
|
525
|
+
putArchive: async (e, t) => {
|
|
526
|
+
let { Readable: n } = await import("node:stream"), r = Zn(), i = Qn("storage", () => n.from(t()));
|
|
527
|
+
await B.runPromise(er(r, e, i, { contentType: "application/octet-stream" }));
|
|
528
|
+
}
|
|
529
|
+
})
|
|
530
|
+
}] : [], ft = [
|
|
531
|
+
...e.httpRoutes ?? [],
|
|
532
|
+
...ct,
|
|
533
|
+
...dt,
|
|
534
|
+
...T.httpRoutes
|
|
535
|
+
];
|
|
536
|
+
Object.assign(P, O.handlers);
|
|
537
|
+
for (let t of N(e.discovered.streams ?? [])) P[t.descriptor.name] = (n) => Xt((r) => {
|
|
538
|
+
let i = A(r), a = t.executor(n, i);
|
|
539
|
+
if (B.isEffect(a)) {
|
|
540
|
+
let t = a.pipe(B.provide(gn(i.store)));
|
|
541
|
+
return (e.baseLayer ? t.pipe(B.provide(e.baseLayer)) : t).pipe(B.provide(Ne)).pipe(B.provide(Fe)).pipe(B.provide(Le)).pipe(B.provide(Re));
|
|
542
|
+
}
|
|
543
|
+
return typeof a == "object" && a && typeof a.then == "function" ? B.promise(() => a) : a;
|
|
544
|
+
}, `stream.${t.descriptor.name}`);
|
|
545
|
+
for (let t of e.discovered.workflows ?? []) P[t.definition.name] = (e) => U(async (e, n) => {
|
|
546
|
+
let r = n;
|
|
547
|
+
return G(b, {
|
|
548
|
+
subject: r.subject,
|
|
549
|
+
traceId: r.traceId,
|
|
550
|
+
source: "workflow-rpc"
|
|
551
|
+
}).start(t.definition.name, e);
|
|
552
|
+
}, e, `workflow.${t.definition.name}`);
|
|
553
|
+
ce && (P[dr.name] = (e) => W(M({
|
|
554
|
+
descriptor: dr,
|
|
555
|
+
executor: (e) => {
|
|
556
|
+
let t = e.id;
|
|
557
|
+
return {
|
|
558
|
+
table: "_voltro_workflow_runs",
|
|
559
|
+
order: [{
|
|
560
|
+
column: "startedAt",
|
|
561
|
+
direction: "desc"
|
|
562
|
+
}],
|
|
563
|
+
predicate: Xn(q("id", t), q("executionId", t)),
|
|
564
|
+
take: 1,
|
|
565
|
+
skip: void 0,
|
|
566
|
+
projection: void 0
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
}, e), i, `subscription.${dr.name}`), P[pr.name] = (e) => W(M({
|
|
570
|
+
descriptor: pr,
|
|
571
|
+
executor: (e) => {
|
|
572
|
+
let t = e, n = [...t.tag === void 0 ? [] : [q("tag", t.tag)], ...t.status === void 0 ? [] : [q("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
|
|
573
|
+
return {
|
|
574
|
+
table: "_voltro_workflow_runs",
|
|
575
|
+
order: [{
|
|
576
|
+
column: "startedAt",
|
|
577
|
+
direction: "desc"
|
|
578
|
+
}],
|
|
579
|
+
predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : Jn(...n),
|
|
580
|
+
take: r,
|
|
581
|
+
skip: void 0,
|
|
582
|
+
projection: void 0
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
}, e), i, `subscription.${pr.name}`), P[fr.name] = (e) => W(M({
|
|
586
|
+
descriptor: fr,
|
|
587
|
+
executor: (e) => {
|
|
588
|
+
let t = e.runId;
|
|
589
|
+
return {
|
|
590
|
+
table: "_voltro_workflow_run_steps",
|
|
591
|
+
order: [{
|
|
592
|
+
column: "startedAt",
|
|
593
|
+
direction: "asc"
|
|
594
|
+
}],
|
|
595
|
+
predicate: q("runId", t),
|
|
596
|
+
take: 1e3,
|
|
597
|
+
skip: void 0,
|
|
598
|
+
projection: void 0
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
}, e), i, `subscription.${fr.name}`), P[ur.name] = (e) => W(M({
|
|
602
|
+
descriptor: ur,
|
|
603
|
+
executor: (e) => {
|
|
604
|
+
let t = e.runId;
|
|
605
|
+
return {
|
|
606
|
+
table: "_voltro_workflow_run_events",
|
|
607
|
+
order: [{
|
|
608
|
+
column: "occurredAt",
|
|
609
|
+
direction: "asc"
|
|
610
|
+
}],
|
|
611
|
+
predicate: q("runId", t),
|
|
612
|
+
take: 1e3,
|
|
613
|
+
skip: void 0,
|
|
614
|
+
projection: void 0
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
}, e), i, `subscription.${ur.name}`), P[sr.name] = (e) => W(M({
|
|
618
|
+
descriptor: sr,
|
|
619
|
+
executor: (e) => {
|
|
620
|
+
let t = e;
|
|
621
|
+
return {
|
|
622
|
+
table: "_voltro_workflow_events",
|
|
623
|
+
order: [{
|
|
624
|
+
column: "occurredAt",
|
|
625
|
+
direction: "desc"
|
|
626
|
+
}],
|
|
627
|
+
predicate: t.name === void 0 ? void 0 : q("name", t.name),
|
|
628
|
+
take: Math.max(1, Math.min(500, t.limit ?? 100)),
|
|
629
|
+
skip: void 0,
|
|
630
|
+
projection: void 0
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
}, e), i, `subscription.${sr.name}`), P[cr.name] = (e) => W(M({
|
|
634
|
+
descriptor: cr,
|
|
635
|
+
executor: (e) => {
|
|
636
|
+
let t = e.eventId;
|
|
637
|
+
return {
|
|
638
|
+
table: "_voltro_workflow_event_deliveries",
|
|
639
|
+
order: [{
|
|
640
|
+
column: "createdAt",
|
|
641
|
+
direction: "asc"
|
|
642
|
+
}],
|
|
643
|
+
predicate: q("eventId", t),
|
|
644
|
+
take: 500,
|
|
645
|
+
skip: void 0,
|
|
646
|
+
projection: void 0
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
}, e), i, `subscription.${cr.name}`), P[Z.name] = (t) => U(async (t, n) => {
|
|
650
|
+
let r = t;
|
|
651
|
+
return await D(e.store, n.subject, { executionId: r.executionId }), await b.cancel(r.workflowName, r.executionId), await xt(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
|
|
652
|
+
}, t, `action.${Z.name}`), P[lr.name] = (t) => U(async (t, n) => {
|
|
653
|
+
let r = t;
|
|
654
|
+
return await D(e.store, n.subject, { executionId: r.executionId }), await b.resume(r.workflowName, r.executionId), { ok: !0 };
|
|
655
|
+
}, t, `action.${lr.name}`), P[mr.name] = (t) => U(async (t, n) => {
|
|
656
|
+
let r = t;
|
|
657
|
+
return await D(e.store, n.subject, { id: r.id }), b.signal({ id: r.id }, r.signalName, r.payload);
|
|
658
|
+
}, t, `action.${mr.name}`), P[hr.name] = (t) => U(async (t, n) => {
|
|
659
|
+
let r = t;
|
|
660
|
+
return await D(e.store, n.subject, { id: r.id }), b.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
|
|
661
|
+
}, t, `action.${hr.name}`));
|
|
662
|
+
let pt = [
|
|
663
|
+
...N(e.discovered.queries).map((e) => X(e.descriptor)),
|
|
664
|
+
...N(e.discovered.mutations).map((e) => Y(e.descriptor)),
|
|
665
|
+
...N(e.discovered.actions).map((e) => J(e.descriptor)),
|
|
666
|
+
...Ye.queries.map((e) => X(e.descriptor)),
|
|
667
|
+
...Ye.mutations.map((e) => Y(e.descriptor)),
|
|
668
|
+
...T.queries.map((e) => X(e.descriptor)),
|
|
669
|
+
...T.mutations.map((e) => Y(e.descriptor)),
|
|
670
|
+
...T.actions.map((e) => J(e.descriptor)),
|
|
671
|
+
...N(e.discovered.streams ?? []).map((e) => or(e.descriptor)),
|
|
672
|
+
...O.rpcs,
|
|
673
|
+
...(e.discovered.workflows ?? []).map((e) => Un(e.definition)),
|
|
674
|
+
...ce ? [
|
|
675
|
+
X(dr),
|
|
676
|
+
X(pr),
|
|
677
|
+
X(fr),
|
|
678
|
+
X(ur),
|
|
679
|
+
X(sr),
|
|
680
|
+
X(cr),
|
|
681
|
+
J(Z),
|
|
682
|
+
J(lr),
|
|
683
|
+
J(mr),
|
|
684
|
+
J(hr)
|
|
685
|
+
] : []
|
|
686
|
+
], mt = Gn.make(...pt).middleware(nr).middleware(rr), gt = V.succeed(nr, nr.of(({ headers: t, clientId: n }) => B.promise(() => e.resolveSubject(t, n)))), _t = V.succeed(rr, rr.of(({ headers: e, clientId: t }) => B.sync(() => {
|
|
687
|
+
let n = on(t) ?? vr(e);
|
|
688
|
+
return {
|
|
689
|
+
clientId: t,
|
|
690
|
+
...e["idempotency-key"] ? { idempotencyKey: e["idempotency-key"] } : {},
|
|
691
|
+
...n === void 0 ? {} : { credentialExpiresAt: n }
|
|
692
|
+
};
|
|
693
|
+
}))), vt = e.dormancyTenantId ?? "default", yt = e.dormancy === "sleep" ? {
|
|
694
|
+
register: (t, n, r) => Mn(e.store, {
|
|
695
|
+
tenantId: r ?? vt,
|
|
696
|
+
kind: "workflow",
|
|
697
|
+
refId: t,
|
|
698
|
+
wakeAt: n
|
|
699
|
+
}),
|
|
700
|
+
cancel: (t, n) => Qt(e.store, {
|
|
701
|
+
tenantId: n ?? vt,
|
|
702
|
+
kind: "workflow",
|
|
703
|
+
refId: t
|
|
704
|
+
}).then(() => {})
|
|
705
|
+
} : void 0, I = ue ? await import("@voltro/workflow") : void 0, L = I?.makeWorkflowRunRecorder({
|
|
706
|
+
store: e.store,
|
|
707
|
+
...yt === void 0 ? {} : { wakeups: yt }
|
|
708
|
+
}), bt = async (t, n) => {
|
|
709
|
+
await I.closeWorkflowChildrenForParent({
|
|
710
|
+
store: e.store,
|
|
711
|
+
parentExecutionId: t,
|
|
712
|
+
parentStatus: n,
|
|
713
|
+
recorder: L,
|
|
714
|
+
log: { warn: (e, t) => {
|
|
715
|
+
process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
716
|
+
} },
|
|
717
|
+
interruptChild: async (t, n) => {
|
|
718
|
+
let r = (e.discovered.workflows ?? []).find((e) => e.definition.name === t);
|
|
719
|
+
if (!r) throw Error(`Unknown child workflow: ${t}`);
|
|
720
|
+
if (!d) throw Error("Workflow runtime is not ready");
|
|
721
|
+
await d.runPromise(r.definition.interrupt(n));
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
}, xt = async (t, n, r) => {
|
|
725
|
+
let i = (await e.store.query({
|
|
726
|
+
table: "_voltro_workflow_runs",
|
|
727
|
+
order: [],
|
|
728
|
+
predicate: q("executionId", n),
|
|
729
|
+
projection: void 0,
|
|
730
|
+
skip: void 0,
|
|
731
|
+
take: 1
|
|
732
|
+
}))[0];
|
|
733
|
+
if (i === void 0) return;
|
|
734
|
+
let a = await e.store.update("_voltro_workflow_runs", i.id, {
|
|
735
|
+
status: "cancelled",
|
|
736
|
+
cancelled: !0,
|
|
737
|
+
completedAt: /* @__PURE__ */ new Date()
|
|
738
|
+
}), o = i.subject?.tenantId ?? void 0;
|
|
739
|
+
a && await L.recordEvent({
|
|
740
|
+
runId: i.id,
|
|
741
|
+
eventType: "run-cancelled",
|
|
742
|
+
payload: {
|
|
743
|
+
reason: r,
|
|
744
|
+
workflowName: t,
|
|
745
|
+
executionId: n,
|
|
746
|
+
...o == null ? {} : { tenantId: o }
|
|
747
|
+
}
|
|
748
|
+
}), a && await bt(n, "cancelled");
|
|
749
|
+
}, St = [
|
|
750
|
+
...Dn(e.discovered.workflows ?? [], {
|
|
751
|
+
buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? A({
|
|
752
|
+
subject: t.subject,
|
|
753
|
+
traceId: t.traceId
|
|
754
|
+
}, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
|
|
755
|
+
resolveStartContext: ae
|
|
756
|
+
}, (t, n, r) => {
|
|
757
|
+
let i = I.getWorkflowVersionMetadata(t.definition);
|
|
758
|
+
return I.wrapWorkflowExecuteWithRunRecording({
|
|
759
|
+
name: t.definition.name,
|
|
760
|
+
store: e.store,
|
|
761
|
+
subject: r.subject,
|
|
762
|
+
source: r.source ?? null,
|
|
763
|
+
traceId: r.traceId,
|
|
764
|
+
workflowVersion: i.version,
|
|
765
|
+
workflowCompatibleVersions: i.compatibleWith,
|
|
766
|
+
workflowPatches: i.patches,
|
|
767
|
+
parentExecutionId: r?.parentExecutionId ?? null,
|
|
768
|
+
parentClosePolicy: r?.parentClosePolicy ?? null,
|
|
769
|
+
onParentClose: ({ executionId: e, status: t }) => bt(e, t),
|
|
770
|
+
...(() => {
|
|
771
|
+
let e = st(t.definition.name, I.getWorkflowFlowControl(t.definition)?.encryptSteps === !0);
|
|
772
|
+
return e === void 0 ? {} : { encryptStepPayload: e };
|
|
773
|
+
})(),
|
|
774
|
+
onTerminal: async ({ executionId: e }) => {
|
|
775
|
+
await u?.gate.release(e);
|
|
776
|
+
},
|
|
777
|
+
recorder: L,
|
|
778
|
+
pluginWorkflowStepLayer: Ge,
|
|
779
|
+
recordRun: jn
|
|
780
|
+
}, n);
|
|
781
|
+
}),
|
|
782
|
+
...e.discovered.workflowWorkers ?? [],
|
|
783
|
+
..._e === void 0 ? [] : [_e]
|
|
784
|
+
], Ct = St.length > 0 ? V.mergeAll(...St) : V.empty;
|
|
785
|
+
if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster" || _e !== void 0) && e.workflowEngineLayer !== void 0) {
|
|
786
|
+
let t = Ct.pipe(V.provideMerge(e.workflowEngineLayer));
|
|
787
|
+
d = Lt.make(e.baseLayer === void 0 ? t : t.pipe(V.provideMerge(e.baseLayer))), await d.runPromise(B.void);
|
|
788
|
+
let n = await import("@voltro/workflow/cluster"), r = (e) => d.runPromise(n.redriveFailedRun(e)), i = (e) => d.runPromise(n.resumeRunFromStep(e));
|
|
789
|
+
ne = await it({
|
|
790
|
+
provider: Fr(e.plugins ?? [])?.broadcast?.provider,
|
|
791
|
+
crossReplica: Fr(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
|
|
792
|
+
namespace: Te,
|
|
793
|
+
replicaId: crypto.randomUUID(),
|
|
794
|
+
pollStorage: () => d.runPromise(n.pollWorkflowStorage),
|
|
795
|
+
log: (e.log ?? H({ scope: "voltro:serve" })).child("workflow")
|
|
796
|
+
}), f = async (t) => {
|
|
797
|
+
let n = await Se({
|
|
798
|
+
store: e.store,
|
|
799
|
+
workflows: e.discovered.workflows ?? [],
|
|
800
|
+
runRedrive: r
|
|
801
|
+
}, t.runId);
|
|
802
|
+
return n.statusReset && await L.recordEvent({
|
|
803
|
+
runId: t.runId,
|
|
804
|
+
eventType: "run-redriven",
|
|
805
|
+
payload: {
|
|
806
|
+
reason: "inspect.redrive",
|
|
807
|
+
activitiesReset: n.outcome.activitiesReset
|
|
808
|
+
}
|
|
809
|
+
}), {
|
|
810
|
+
redriven: n.outcome.redriven,
|
|
811
|
+
activitiesReset: n.outcome.activitiesReset,
|
|
812
|
+
reason: n.outcome.reason
|
|
813
|
+
};
|
|
814
|
+
}, te = async (t) => {
|
|
815
|
+
let n = await v({
|
|
816
|
+
store: e.store,
|
|
817
|
+
workflows: e.discovered.workflows ?? [],
|
|
818
|
+
runResume: i
|
|
819
|
+
}, t.runId, t.step);
|
|
820
|
+
return n.statusReset && await L.recordEvent({
|
|
821
|
+
runId: t.runId,
|
|
822
|
+
eventType: "run-redriven",
|
|
823
|
+
payload: {
|
|
824
|
+
reason: "inspect.resume-from-step",
|
|
825
|
+
step: n.stepName,
|
|
826
|
+
activitiesReset: n.outcome.activitiesReset
|
|
827
|
+
}
|
|
828
|
+
}), {
|
|
829
|
+
redriven: n.outcome.redriven,
|
|
830
|
+
stepName: n.stepName,
|
|
831
|
+
activitiesReset: n.outcome.activitiesReset,
|
|
832
|
+
reason: n.outcome.reason
|
|
833
|
+
};
|
|
834
|
+
};
|
|
835
|
+
let a = hn({
|
|
836
|
+
coordinator: (e.scheduleCoordination ?? "single") === "advisoryLock" ? un(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Rn,
|
|
837
|
+
replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`
|
|
838
|
+
}), o = {
|
|
839
|
+
info: (e, t) => {
|
|
840
|
+
process.stdout.write(`[flow-control] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
841
|
+
},
|
|
842
|
+
warn: (e, t) => {
|
|
843
|
+
process.stderr.write(`[flow-control] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
844
|
+
},
|
|
845
|
+
error: (e, t) => {
|
|
846
|
+
process.stderr.write(`[flow-control] ERROR ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
847
|
+
}
|
|
848
|
+
}, p, m = () => {
|
|
849
|
+
if (p !== void 0) return p;
|
|
850
|
+
if (!(s === void 0 || L === void 0)) return p = _({
|
|
851
|
+
store: e.store,
|
|
852
|
+
log: z,
|
|
853
|
+
workflows: e.discovered.workflows ?? [],
|
|
854
|
+
workflowsProxy: s,
|
|
855
|
+
workflowRuntime: d,
|
|
856
|
+
workflowRunRecorder: L,
|
|
857
|
+
closeChildrenForParent: bt
|
|
858
|
+
}), p;
|
|
859
|
+
};
|
|
860
|
+
c = m, u = qe({
|
|
861
|
+
store: e.store,
|
|
862
|
+
workflows: e.discovered.workflows ?? [],
|
|
863
|
+
facade: () => s,
|
|
864
|
+
cancelRunWithReason: m,
|
|
865
|
+
scheduleCoordinated: a,
|
|
866
|
+
onAbandoned: async (t) => {
|
|
867
|
+
await Ie({
|
|
868
|
+
workflows: e.discovered.workflows ?? [],
|
|
869
|
+
facade: () => s,
|
|
870
|
+
log: o,
|
|
871
|
+
...t
|
|
872
|
+
});
|
|
873
|
+
},
|
|
874
|
+
log: o
|
|
875
|
+
});
|
|
876
|
+
let h = u;
|
|
877
|
+
h !== void 0 && On(() => h.stop()), l = $e({
|
|
878
|
+
store: e.store,
|
|
879
|
+
enabled: (e.discovered.workflows?.length ?? 0) > 0,
|
|
880
|
+
resumeSignal: () => d === void 0 || I === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
|
|
881
|
+
await d.runPromise(I.completeSuspendingSignal({
|
|
882
|
+
store: e.store,
|
|
883
|
+
target: k(t, n),
|
|
884
|
+
signalName: r,
|
|
885
|
+
payload: i
|
|
886
|
+
}));
|
|
887
|
+
},
|
|
888
|
+
runEffect: (e) => d.runPromise(e),
|
|
889
|
+
scheduleCoordinated: a,
|
|
890
|
+
log: o
|
|
891
|
+
});
|
|
892
|
+
let g = l;
|
|
893
|
+
g !== void 0 && On(() => g.stop()), s = (e.discovered.workflows?.length ?? 0) > 0 ? En({
|
|
894
|
+
workflows: e.discovered.workflows ?? [],
|
|
895
|
+
runEffect: (e) => d.runPromise(e),
|
|
896
|
+
onEnqueue: () => ne?.publishWake(),
|
|
897
|
+
...h === void 0 ? {} : { admitStart: h.gate.admitStart },
|
|
898
|
+
rememberStartContext: ie,
|
|
899
|
+
signal: async (t, n, r) => {
|
|
900
|
+
let i = await I.sendWorkflowSignal({
|
|
901
|
+
store: e.store,
|
|
902
|
+
recorder: L,
|
|
903
|
+
target: t,
|
|
904
|
+
signalName: n,
|
|
905
|
+
payload: r
|
|
906
|
+
});
|
|
907
|
+
return await d.runPromise(I.completeSuspendingSignal({
|
|
908
|
+
store: e.store,
|
|
909
|
+
target: t,
|
|
910
|
+
signalName: n,
|
|
911
|
+
payload: r
|
|
912
|
+
})).catch(() => {}), i;
|
|
913
|
+
},
|
|
914
|
+
update: (t, n, r, i) => I.sendWorkflowUpdate({
|
|
915
|
+
store: e.store,
|
|
916
|
+
recorder: L,
|
|
917
|
+
target: t,
|
|
918
|
+
updateName: n,
|
|
919
|
+
payload: r,
|
|
920
|
+
...i === void 0 ? {} : { options: i }
|
|
921
|
+
}),
|
|
922
|
+
listRuns: (t) => ee(e.store, t),
|
|
923
|
+
retry: (t, n) => xe({
|
|
924
|
+
store: e.store,
|
|
925
|
+
workflows: e.discovered.workflows ?? [],
|
|
926
|
+
runPromise: (e) => d.runPromise(e)
|
|
927
|
+
}, t, n),
|
|
928
|
+
redrive: (t) => Se({
|
|
929
|
+
store: e.store,
|
|
930
|
+
workflows: e.discovered.workflows ?? [],
|
|
931
|
+
runRedrive: r
|
|
932
|
+
}, t).then((e) => e.outcome)
|
|
933
|
+
}) : void 0;
|
|
934
|
+
}
|
|
935
|
+
let wt = V.mergeAll(mt.toLayer(P), gt, _t), Tt = tt(P, e.discovered.queries.map((e) => e.descriptor.name), ce), Et = V.mergeAll(mt.toLayer(Tt), gt, _t), R = e.observability, Dt = await Zt({
|
|
936
|
+
...e.appName === void 0 ? {} : { serviceName: e.appName },
|
|
937
|
+
...R && R.spanProcessors.length > 0 ? { extraSpanProcessors: R.spanProcessors } : {},
|
|
938
|
+
...R && R.metricReaders.length > 0 ? { extraMetricReaders: R.metricReaders } : {},
|
|
939
|
+
...R && Object.keys(R.resourceAttributes).length > 0 ? { resourceAttributes: R.resourceAttributes } : {},
|
|
940
|
+
...R && R.sampler !== void 0 ? { sampler: R.sampler } : {}
|
|
941
|
+
}), Ot = !1, kt = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: At, shutdown: jt } = zn({
|
|
942
|
+
group: mt,
|
|
943
|
+
handlersLayer: wt,
|
|
944
|
+
httpHandlersLayer: Et,
|
|
945
|
+
port: e.port ?? 4e3,
|
|
946
|
+
...e.host === void 0 ? {} : { host: e.host },
|
|
947
|
+
path: e.path ?? "/ws",
|
|
948
|
+
tracerLayer: Dt.layer,
|
|
949
|
+
healthCheck: {
|
|
950
|
+
isReady: () => Ot,
|
|
951
|
+
...kt ? { ping: kt } : {}
|
|
952
|
+
},
|
|
953
|
+
...ft.length > 0 ? { httpRoutes: ft } : {},
|
|
954
|
+
...e.getStore === void 0 ? {} : { getStore: e.getStore },
|
|
955
|
+
...ve.size > 0 ? { webhookRoutes: ve } : {},
|
|
956
|
+
...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
|
|
957
|
+
});
|
|
958
|
+
if (await Yt(At), (e.discovered.schedules?.length ?? 0) > 0) {
|
|
959
|
+
let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? un(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Rn;
|
|
960
|
+
p = await Bn(e.discovered.schedules ?? [], {
|
|
961
|
+
store: e.store,
|
|
962
|
+
coordinator: t,
|
|
963
|
+
defaultTrigger: e.scheduleDefaultTrigger ?? "self",
|
|
964
|
+
replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`,
|
|
965
|
+
armSelf: e.scheduleArmSelf ?? !0,
|
|
966
|
+
dormancy: e.dormancy ?? "always-on",
|
|
967
|
+
...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
|
|
968
|
+
buildContext: ({ traceId: t, scheduleName: n, subject: r }) => A({
|
|
969
|
+
subject: r,
|
|
970
|
+
traceId: t
|
|
971
|
+
}, e.store, void 0, `schedule:${n}`),
|
|
972
|
+
log: {
|
|
973
|
+
info: (e, t) => {
|
|
974
|
+
process.stdout.write(`[schedule] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
975
|
+
},
|
|
976
|
+
warn: (e, t) => {
|
|
977
|
+
process.stderr.write(`[schedule] ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
978
|
+
},
|
|
979
|
+
error: (e, t) => {
|
|
980
|
+
process.stderr.write(`[schedule] ERROR ${e} ${t ? JSON.stringify(t) : ""}\n`);
|
|
981
|
+
},
|
|
982
|
+
debug: () => {}
|
|
983
|
+
},
|
|
984
|
+
...e.scheduleFireInterceptor === void 0 ? {} : { interceptFire: e.scheduleFireInterceptor },
|
|
985
|
+
...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
|
|
986
|
+
}), e.onSchedulerReady?.(p);
|
|
987
|
+
}
|
|
988
|
+
let z = e.log ?? H({ scope: "voltro:serve" }), Mt, Nt;
|
|
989
|
+
if ((e.discovered.subscribers?.length ?? 0) > 0 && (Mt = re(e.discovered.subscribers ?? [], e.store, z.child("subscribe"), e.schemaRegistry, O.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
|
|
990
|
+
let t = z.child("reaction"), n = async (n, r) => {
|
|
991
|
+
if (n.kind === "workflow") {
|
|
992
|
+
if (b === void 0) {
|
|
993
|
+
t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
let e = n.payload === void 0 ? r.new ?? r.old ?? {} : n.payload(r);
|
|
997
|
+
await G(b, {
|
|
998
|
+
traceId: `reaction:${n.workflow}`,
|
|
999
|
+
source: `reaction:${n.workflow}`
|
|
1000
|
+
}).start(n.workflow, e);
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
await g(n.agent, r, {
|
|
1004
|
+
findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
|
|
1005
|
+
runAction: (e, t, n) => Promise.resolve(Xe(e, t, n)),
|
|
1006
|
+
makeSubject: (e) => ir(e),
|
|
1007
|
+
now: () => Date.now(),
|
|
1008
|
+
log: t
|
|
1009
|
+
});
|
|
1010
|
+
}, r = async (n, r) => {
|
|
1011
|
+
try {
|
|
1012
|
+
let { requireAiBudget: t } = await import("@voltro/ai");
|
|
1013
|
+
return (await B.runPromise(B.either(t(e.store, {
|
|
1014
|
+
tenantId: n,
|
|
1015
|
+
limitUsd: r
|
|
1016
|
+
}))))._tag === "Right";
|
|
1017
|
+
} catch (e) {
|
|
1018
|
+
return t.warn("reaction budget check failed — refusing the act", { tenantId: n }, e), !1;
|
|
1019
|
+
}
|
|
1020
|
+
}, i = rt(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
|
|
1021
|
+
Nt = w(e.discovered.reactions ?? [], e.store, {
|
|
1022
|
+
runAct: n,
|
|
1023
|
+
checkBudget: r,
|
|
1024
|
+
claimRateSlot: (e) => i.claim(e)
|
|
1025
|
+
}, t);
|
|
1026
|
+
}
|
|
1027
|
+
let Pt;
|
|
1028
|
+
(e.discovered.aggregates?.length ?? 0) > 0 && (Pt = await je({
|
|
1029
|
+
discovered: e.discovered.aggregates ?? [],
|
|
1030
|
+
store: e.store,
|
|
1031
|
+
log: z.child("aggregate"),
|
|
1032
|
+
...e.analytics === void 0 ? {} : { analytics: e.analytics },
|
|
1033
|
+
...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
|
|
1034
|
+
...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
|
|
1035
|
+
}), Ne = V.succeed(zt, Pt.registry));
|
|
1036
|
+
let Ft;
|
|
1037
|
+
(e.discovered.expectations?.length ?? 0) > 0 && (Ft = Kt({
|
|
1038
|
+
discovered: e.discovered.expectations ?? [],
|
|
1039
|
+
store: e.store,
|
|
1040
|
+
log: z.child("expectation")
|
|
1041
|
+
}), Fe = V.succeed(Ht, Ft.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (r = Jt({
|
|
1042
|
+
discovered: e.discovered.budgets ?? [],
|
|
1043
|
+
log: z.child("finops")
|
|
1044
|
+
}), Le = V.succeed(Bt, r.registry));
|
|
1045
|
+
let It;
|
|
1046
|
+
return (e.discovered.experiments?.length ?? 0) > 0 && (It = qt({
|
|
1047
|
+
discovered: e.discovered.experiments ?? [],
|
|
1048
|
+
store: e.store,
|
|
1049
|
+
log: z.child("experiment")
|
|
1050
|
+
}), Re = V.succeed(Ut, It.registry)), Ot = !0, e.bootTiming?.mark("ready"), {
|
|
1051
|
+
dispatcher: i,
|
|
1052
|
+
server: At,
|
|
1053
|
+
scheduler: p,
|
|
1054
|
+
eventsSnapshot: pe(O.bus, O.declared),
|
|
1055
|
+
membersSnapshot: () => ({
|
|
1056
|
+
members: ke.membership.list(),
|
|
1057
|
+
capturedAt: Date.now()
|
|
1058
|
+
}),
|
|
1059
|
+
rpcMetrics: () => Ue,
|
|
1060
|
+
webhooksService: () => he,
|
|
1061
|
+
runCanceller: () => c(),
|
|
1062
|
+
flowControlHealth: () => u?.cancelHealth(),
|
|
1063
|
+
inferenceHealth: () => l?.health(),
|
|
1064
|
+
workflowWriteActions: () => b === void 0 || L === void 0 ? void 0 : y({
|
|
1065
|
+
store: e.store,
|
|
1066
|
+
log: z,
|
|
1067
|
+
workflows: e.discovered.workflows ?? [],
|
|
1068
|
+
workflowsProxy: s,
|
|
1069
|
+
workflowRuntime: d,
|
|
1070
|
+
workflowRunRecorder: L,
|
|
1071
|
+
closeChildrenForParent: bt
|
|
1072
|
+
}),
|
|
1073
|
+
redriveWorkflowRun: (e) => f ? f(e) : Promise.reject(/* @__PURE__ */ Error("redrive: this app registers no workflows")),
|
|
1074
|
+
resumeWorkflowRunFromStep: (e) => te ? te(e) : Promise.reject(/* @__PURE__ */ Error("resume-from-step: this app registers no workflows")),
|
|
1075
|
+
close: async () => {
|
|
1076
|
+
Ot = !1, await Me?.detach(), await ke.detach(), Pt?.detach(), Ft?.detach(), r?.detach(), It?.detach(), Nt?.(), Mt?.(), await p?.shutdown(), i.close(), await ne?.detach(), await d?.dispose(), await new Promise((e) => At.close(() => e())), await jt();
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
}, $ = H({ scope: "voltro:serve" }), ci = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", li = Mt, ui = async (e) => {
|
|
1080
|
+
let t = jt(process.cwd());
|
|
1081
|
+
if (Rt(t)) {
|
|
1082
|
+
let n;
|
|
1083
|
+
try {
|
|
1084
|
+
let e = await import(Ft(t).href);
|
|
1085
|
+
typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
|
|
1086
|
+
} catch (e) {
|
|
1087
|
+
$.warn("serve bundle failed to load — using the standard serve path", {}, e);
|
|
1088
|
+
}
|
|
1089
|
+
if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
|
|
1090
|
+
}
|
|
1091
|
+
return di(e);
|
|
1092
|
+
}, di = async (ee) => {
|
|
1093
|
+
let g = z();
|
|
1094
|
+
process.env.NODE_ENV || (process.env.NODE_ENV = "production");
|
|
1095
|
+
try {
|
|
1096
|
+
_r();
|
|
1097
|
+
} catch (e) {
|
|
1098
|
+
throw Xe(e instanceof Error ? e.message : String(e));
|
|
1099
|
+
}
|
|
1100
|
+
let _ = process.cwd(), re = Number(process.env.PORT ?? li(ee, "--port") ?? 4e3), v = await Me(_);
|
|
1101
|
+
Fn(Nn(v?.secrets)), await e({
|
|
1102
|
+
rawEnv: v?.env,
|
|
1103
|
+
appType: "api",
|
|
1104
|
+
root: _,
|
|
1105
|
+
log: $,
|
|
1106
|
+
generateTypes: !1
|
|
1107
|
+
}), g.mark("config");
|
|
1108
|
+
let y = (process.env.DB_DIALECT ?? v?.store ?? "memory").toLowerCase(), oe = (y === "mariadb" || y === "postgres" || y === "mssql") && (process.env.CDC ?? "1") !== "0", se = y === "mariadb" ? "mariadb" : y === "mssql" ? "mssql" : void 0, le = At(_);
|
|
1109
|
+
if (!s() && Rt(le)) try {
|
|
1110
|
+
let e = await import(Ft(le).href);
|
|
1111
|
+
if (e.modules) {
|
|
1112
|
+
let t = {};
|
|
1113
|
+
for (let [n, r] of Object.entries(e.modules)) t[Pt(_, n)] = r;
|
|
1114
|
+
o(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
|
|
1115
|
+
}
|
|
1116
|
+
} catch (e) {
|
|
1117
|
+
$.warn("precompiled api bundle failed to load — falling back to source", {}, e);
|
|
1118
|
+
}
|
|
1119
|
+
let x = await Be(_), S = await ct(x, { cdc: oe && se !== void 0 });
|
|
1120
|
+
{
|
|
1121
|
+
let e = /* @__PURE__ */ new Set([
|
|
1122
|
+
...S.queries.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
|
|
1123
|
+
...S.mutations.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
|
|
1124
|
+
...S.actions.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name)
|
|
1125
|
+
]);
|
|
1126
|
+
vt(St(v?.plugins ?? []), [
|
|
1127
|
+
...S.queries.map((e) => e.descriptor.name),
|
|
1128
|
+
...S.mutations.map((e) => e.descriptor.name),
|
|
1129
|
+
...S.actions.map((e) => e.descriptor.name),
|
|
1130
|
+
...S.streams.map((e) => e.descriptor.name)
|
|
1131
|
+
], e);
|
|
1132
|
+
let t = d(S.serverOnlyLeaks, Ke(process.env, "strict"), nn, "`voltro serve`");
|
|
1133
|
+
if (t.action === "fail") throw Xe(t.message ?? "");
|
|
1134
|
+
t.action === "warn" && $.warn(t.message ?? "");
|
|
1135
|
+
}
|
|
1136
|
+
let pe = x.filter((e) => lt.test(e)), me = pe.length > 0 ? await Le(pe, $.child("webhooks")) : {
|
|
1137
|
+
outgoing: [],
|
|
1138
|
+
incoming: [],
|
|
1139
|
+
providers: []
|
|
1140
|
+
}, ge = M(S.events), w = me.outgoing.length + me.incoming.length + me.providers.length + ge.length === 0 ? void 0 : {
|
|
1141
|
+
...me,
|
|
1142
|
+
outgoing: [...me.outgoing, ...ge]
|
|
1143
|
+
}, xe = L({
|
|
1144
|
+
mix: S.featureMix,
|
|
1145
|
+
plugins: v?.plugins ?? [],
|
|
1146
|
+
cdc: oe && se !== void 0,
|
|
1147
|
+
...se ? { cdcDialect: se } : {}
|
|
1148
|
+
}), Se = v?.analytics !== void 0 && v.analytics.kind !== "noop" && y !== "memory" ? (await i(y)).makeSqlLayer(Ze()) : void 0, E = await _t({
|
|
1149
|
+
spec: v?.analytics,
|
|
1150
|
+
sqlLayer: Se,
|
|
1151
|
+
log: $
|
|
1152
|
+
}), D = (() => {
|
|
1153
|
+
let e = new Set(S.tables.map((e) => e.tableName)), t = [...S.tables];
|
|
1154
|
+
for (let n of [...xe, ...E.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
|
|
1155
|
+
return t;
|
|
1156
|
+
})();
|
|
1157
|
+
for (let e of D) Yn(e);
|
|
1158
|
+
{
|
|
1159
|
+
let e = rn(Hn(S.queries.map((e) => ({
|
|
1160
|
+
name: e.descriptor.name,
|
|
1161
|
+
source: e.descriptor.source
|
|
1162
|
+
})), new Set(D.flatMap((e) => {
|
|
1163
|
+
let t = e.tableName;
|
|
1164
|
+
return t === void 0 ? [] : [t];
|
|
1165
|
+
}))));
|
|
1166
|
+
e !== void 0 && $.warn(e);
|
|
1167
|
+
}
|
|
1168
|
+
let we = (process.env.NODE_ENV ?? "").toLowerCase();
|
|
1169
|
+
if (ci(we, y, process.env.VOLTRO_AUTO_MIGRATE)) {
|
|
1170
|
+
let e = (await i(y)).makeSqlLayer(Ze()), t = await B.runPromise(Kn.SqlClient.pipe(B.flatMap((e) => Cr(e, D, {
|
|
1171
|
+
appliedBy: `serve:${we}`,
|
|
1172
|
+
environment: "prod",
|
|
1173
|
+
dialectId: y
|
|
1174
|
+
})), B.provide(e)));
|
|
1175
|
+
t.kind === "prod-mismatch" && ($.error(Sr(t, y)), $.error("serve: refusing to boot — apply the schema first (voltro db apply in a pre-deploy step), or set VOLTRO_AUTO_MIGRATE=0 to bypass this check."), process.exit(1)), $.info(Sr(t, y));
|
|
1176
|
+
}
|
|
1177
|
+
let De = Tn(D);
|
|
1178
|
+
g.mark("discover");
|
|
1179
|
+
let k = await He(v, void 0), je = Wn(k, y);
|
|
1180
|
+
for (let e of N({
|
|
1181
|
+
dialect: String(v?.store ?? process.env.DB_DIALECT ?? "postgres"),
|
|
1182
|
+
changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
|
|
1183
|
+
dbUrl: process.env.DB_URL,
|
|
1184
|
+
tables: S.tables.map((e) => ({
|
|
1185
|
+
tableName: e.tableName,
|
|
1186
|
+
isReactive: e.isReactive === !0
|
|
1187
|
+
})),
|
|
1188
|
+
querySources: S.queries.flatMap((e) => {
|
|
1189
|
+
let t = e.descriptor.source;
|
|
1190
|
+
return t === void 0 ? [] : typeof t == "string" ? [t] : [...t];
|
|
1191
|
+
})
|
|
1192
|
+
})) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
|
|
1193
|
+
{
|
|
1194
|
+
let e = Ye(ot({
|
|
1195
|
+
tables: qn().map((e) => ({ tableName: e.tableName })),
|
|
1196
|
+
queries: S.queries.map((e) => ({
|
|
1197
|
+
name: e.descriptor.name,
|
|
1198
|
+
source: e.descriptor.source
|
|
1199
|
+
}))
|
|
1200
|
+
}));
|
|
1201
|
+
e !== void 0 && $.warn(e);
|
|
1202
|
+
}
|
|
1203
|
+
v?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = v.cache), v?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = v.cacheRedisUrl), v?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = v.cacheRedisDriver), v?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = v.cacheKeyPrefix);
|
|
1204
|
+
let { service: Pe, invalidationBus: Ie, snapshotCache: ze, cache: Ve, semantic: We, evictSource: qe, backend: Je, stats: $e, dispose: tt } = await Fe({
|
|
1205
|
+
env: process.env,
|
|
1206
|
+
semantic: v?.cacheSemantic ?? !1
|
|
1207
|
+
});
|
|
1208
|
+
We !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${Je}` + (Je === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), k.onChange((e) => {
|
|
1209
|
+
if (B.runFork(Ie.publish(e.table)), qe !== void 0) {
|
|
1210
|
+
let t = (e.new ?? e.old)?.id;
|
|
1211
|
+
qe({
|
|
1212
|
+
table: e.table,
|
|
1213
|
+
op: e.op,
|
|
1214
|
+
...t === void 0 ? {} : { id: t }
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
}), v?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = v.kv), v?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = v.kvRedisUrl), v?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = v.kvKeyPrefix);
|
|
1218
|
+
let { kv: rt, service: it } = await mn({ store: k });
|
|
1219
|
+
$.info(Ur(Ne(), Wr())), g.mark("store");
|
|
1220
|
+
let st = Gt({
|
|
1221
|
+
store: k,
|
|
1222
|
+
sink: E.sink,
|
|
1223
|
+
log: $
|
|
1224
|
+
}), ht = l({
|
|
1225
|
+
store: k,
|
|
1226
|
+
dialect: y
|
|
1227
|
+
}), F = v?.plugins ?? [], jt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Mt, H;
|
|
1228
|
+
y !== "memory" && (Mt = Lt.make((await i(y)).makeSqlLayer(Ze())), H = await Mt.runPromise(Kn.SqlClient));
|
|
1229
|
+
let zt = hn({
|
|
1230
|
+
coordinator: [
|
|
1231
|
+
"postgres",
|
|
1232
|
+
"mariadb",
|
|
1233
|
+
"mysql",
|
|
1234
|
+
"mssql"
|
|
1235
|
+
].includes(y) ? un(k, jt, $) : Rn,
|
|
1236
|
+
replicaId: jt,
|
|
1237
|
+
log: $
|
|
1238
|
+
}), Bt = [], Vt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Ht = Fr(v?.plugins ?? [])?.broadcast?.provider, Ut = ut(v?.plugins, v?.name ?? Nt(_));
|
|
1239
|
+
{
|
|
1240
|
+
let e = Oe(v?.plugins, v?.name ?? Nt(_));
|
|
1241
|
+
e !== void 0 && $.warn(e);
|
|
1242
|
+
}
|
|
1243
|
+
let Kt = Ae(v?.plugins, {
|
|
1244
|
+
instanceId: Vt,
|
|
1245
|
+
namespace: Ut,
|
|
1246
|
+
meta: { mode: "serve" },
|
|
1247
|
+
logger: $
|
|
1248
|
+
}), qt = {
|
|
1249
|
+
...H ? { sql: H } : {},
|
|
1250
|
+
instanceId: Vt,
|
|
1251
|
+
membership: Kt.membership,
|
|
1252
|
+
...Ht === void 0 ? {} : { broadcast: Ht },
|
|
1253
|
+
broadcastChannels: { presence: Pr(Ut, "presence") },
|
|
1254
|
+
scheduleCoordinated: (e, t, n) => {
|
|
1255
|
+
let r = zt(e, t, n);
|
|
1256
|
+
return Bt.push(r), r;
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
for (let e of F) e.bindDataStore?.(k, qt);
|
|
1260
|
+
j({
|
|
1261
|
+
store: k,
|
|
1262
|
+
...u(),
|
|
1263
|
+
log: $
|
|
1264
|
+
});
|
|
1265
|
+
let Jt = F.filter((e) => typeof e.onChangeEvent == "function");
|
|
1266
|
+
if (Jt.length > 0) {
|
|
1267
|
+
let e = k.changeScope ?? "local";
|
|
1268
|
+
k.onChange((t) => {
|
|
1269
|
+
let n = fe(t, e);
|
|
1270
|
+
for (let e of Jt) B.runFork(e.onChangeEvent(n).pipe(B.catchAllCause((t) => B.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: It.pretty(t) })))));
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
let Yt = et({
|
|
1274
|
+
plugins: F,
|
|
1275
|
+
appName: v?.name ?? "voltro-api",
|
|
1276
|
+
appType: "api",
|
|
1277
|
+
voltroVersion: process.env.npm_package_version ?? "0.0.0",
|
|
1278
|
+
log: $
|
|
1279
|
+
});
|
|
1280
|
+
F.length && await Yt.activate(), g.mark("plugins");
|
|
1281
|
+
let U = await Yt.gatherObservability(), Xt = {
|
|
1282
|
+
info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
1283
|
+
warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
|
|
1284
|
+
debug: () => {}
|
|
1285
|
+
}, W, Zt = await Re(k, v, y, Ut, Xt, (e, t) => {
|
|
1286
|
+
W?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
|
|
1287
|
+
}), Qt = v?.apiKeys, on = (typeof Qt == "object" ? Qt.prefix : void 0) ?? "voltro_", sn = Qt ? en(k) : void 0, cn = sn ? fn({ flush: pn(sn) }) : void 0;
|
|
1288
|
+
cn && On(() => cn.shutdown());
|
|
1289
|
+
let ln = sn ? dn(sn, {
|
|
1290
|
+
prefix: on,
|
|
1291
|
+
...cn ? { usage: cn } : {}
|
|
1292
|
+
}) : void 0, gn = ln ? [an(ln, { prefix: on })] : [], _n = nt([...v?.auth?.strategies ?? [], ...gn], Ar(v?.plugins ?? []), v?.auth?.anonymousTenantRequired ?? !1, v?.auth?.resolveScopes, () => je), vn = [...v?.restRoutes ?? [], ...ln ? Wt(ln, (typeof Qt == "object" ? Qt.managementPath : void 0) ?? "/v1/api-keys") : []], yn = v?.idempotency, bn = yn ? {
|
|
1293
|
+
store: tn(k),
|
|
1294
|
+
header: (typeof yn == "object" ? yn.header : void 0) ?? "Idempotency-Key",
|
|
1295
|
+
ttlMs: (typeof yn == "object" ? yn.ttlMs : void 0) ?? 864e5
|
|
1296
|
+
} : void 0, xn = vn.length > 0 ? Mr(vn, {
|
|
1297
|
+
store: k,
|
|
1298
|
+
resolveSubject: async (e) => (await _n({
|
|
1299
|
+
headers: e,
|
|
1300
|
+
clientId: -1
|
|
1301
|
+
})).subject,
|
|
1302
|
+
...bn ? { idempotency: bn } : {}
|
|
1303
|
+
}) : [], Sn = F.map((e) => e.services).filter((e) => e !== void 0), Cn = V.mergeAll(Te({
|
|
1304
|
+
analyticsLayer: E.layer,
|
|
1305
|
+
cacheService: Pe,
|
|
1306
|
+
kvService: it,
|
|
1307
|
+
...We === void 0 ? {} : { semanticCache: We },
|
|
1308
|
+
pluginServices: Sn,
|
|
1309
|
+
userLayers: v?.layers ?? []
|
|
1310
|
+
}), b(v?.http ?? {})), wn = v?.scheduling ?? {}, En = wn.trigger ?? "self", G = /* @__PURE__ */ new Set([
|
|
1311
|
+
"postgres",
|
|
1312
|
+
"mysql",
|
|
1313
|
+
"mariadb",
|
|
1314
|
+
"mssql"
|
|
1315
|
+
]), Dn = wn.coordination ?? (G.has(y) ? "advisoryLock" : "single"), K = Dn === "cluster" && G.has(y), An = K ? "cluster" : Dn === "advisoryLock" && G.has(y) ? "advisoryLock" : "single";
|
|
1316
|
+
Dn === "cluster" && !K && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), Dn === "advisoryLock" && !G.has(y) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
|
|
1317
|
+
let jn, Mn = S.workflows.length > 0 || S.workflowWorkers.length > 0 || S.eventTriggers.length > 0 || (w?.outgoing.length ?? 0) > 0 || K, Pn;
|
|
1318
|
+
if (Mn) {
|
|
1319
|
+
if (y === "mssql") {
|
|
1320
|
+
let e = await C(process.cwd());
|
|
1321
|
+
e && $.warn(e);
|
|
1322
|
+
}
|
|
1323
|
+
let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: a }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), o = K ? S.schedules.filter((e) => (e.trigger ?? En) === "self").map((e) => t({
|
|
1324
|
+
name: e.name,
|
|
1325
|
+
cron: $t(e),
|
|
1326
|
+
execute: async () => {
|
|
1327
|
+
await jn?.fireFromCluster(e.name);
|
|
1328
|
+
}
|
|
1329
|
+
})) : [];
|
|
1330
|
+
Pn = y === "memory" ? e.layerMemory : await (async () => {
|
|
1331
|
+
let e = await i(y), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
|
|
1332
|
+
return $.info(`workflow engine: cluster-${t}, dialect=${e.id}` + (t === "memory" ? " — single-process durable replay, no cross-pod shard handoff" + (e.id !== "sqlite" && e.id !== "turso" ? " (VOLTRO_WORKFLOW_RUNNER_STORAGE=memory: SqlRunnerStorage/cluster_runners + GET_LOCK skipped)" : "") : "")), n({
|
|
1333
|
+
sqlClientLayer: e.makeSqlLayer(Ze()),
|
|
1334
|
+
runnerStorage: t,
|
|
1335
|
+
dialectId: e.id,
|
|
1336
|
+
...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
|
|
1337
|
+
...a(),
|
|
1338
|
+
...o.length > 0 ? { extraShardingLayers: o } : {}
|
|
1339
|
+
});
|
|
1340
|
+
})();
|
|
1341
|
+
}
|
|
1342
|
+
let In = ie(F, n()), Ln = x.filter((e) => /\.subscribe\.tsx?$/.test(e)), zn = Ln.length > 0 ? await ae(Ln, $) : [], Bn = x.filter((e) => /\.reaction\.tsx?$/.test(e)), Vn = Bn.length > 0 ? await m(Bn, $) : [], Un = x.filter((e) => Et.test(e)), Gn = Un.length > 0 ? await ue(Un, $) : [], Jn = x.filter((e) => /\.aggregate\.tsx?$/.test(e)), q = Jn.length > 0 ? await ye(Jn, $) : [], Xn = ne();
|
|
1343
|
+
if (q.length > 0 && y !== "memory") try {
|
|
1344
|
+
Xn = pt((await i(y)).makeSqlLayer(Ze()));
|
|
1345
|
+
} catch (e) {
|
|
1346
|
+
$.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
|
|
1347
|
+
}
|
|
1348
|
+
let Zn = y === "memory" ? Rn : un(k, `aggregate@${process.pid}`, $), Qn = x.filter((e) => R.test(e)), $n = Qn.length > 0 ? await dt(Qn, $) : [], er = x.filter((e) => Tt.test(e)), tr = er.length > 0 ? await ke(er, $) : [], nr = x.filter((e) => wt.test(e)), rr = nr.length > 0 ? await gt(nr, $) : [], J = [], ir = [], ar = x.filter((e) => xt.test(e));
|
|
1349
|
+
if (ar.length > 0) {
|
|
1350
|
+
let e = $.child("agent"), t = x.filter((e) => yt.test(e));
|
|
1351
|
+
t.length > 0 && await I(t, e);
|
|
1352
|
+
let n = await bt(ar, e);
|
|
1353
|
+
for (let e of n.agents) for (let t of Ce(e)) (t.kind === "action" ? J : ir).push({
|
|
1354
|
+
file: t.file,
|
|
1355
|
+
descriptor: t.descriptor,
|
|
1356
|
+
executor: t.executor
|
|
1357
|
+
});
|
|
1358
|
+
n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
|
|
1359
|
+
}
|
|
1360
|
+
g.mark("workflow");
|
|
1361
|
+
let Y = () => {
|
|
1362
|
+
let e = Z.workflowWriteActions();
|
|
1363
|
+
if (e === void 0) throw Error("workflow actions: this app registers no workflows");
|
|
1364
|
+
return e;
|
|
1365
|
+
}, X = await Ee({
|
|
1366
|
+
files: x,
|
|
1367
|
+
store: k,
|
|
1368
|
+
log: $,
|
|
1369
|
+
seedPolicy: "report",
|
|
1370
|
+
seedPattern: a,
|
|
1371
|
+
loadSeedFiles: r,
|
|
1372
|
+
startupPattern: Ct,
|
|
1373
|
+
loadStartupFiles: kt,
|
|
1374
|
+
runStartups: Ot,
|
|
1375
|
+
emailPattern: he,
|
|
1376
|
+
loadEmailFiles: c,
|
|
1377
|
+
registerEmailTemplates: Nr
|
|
1378
|
+
});
|
|
1379
|
+
(X.startupCount > 0 || X.emailCount > 0) && $.info("boot lifecycle", {
|
|
1380
|
+
startups: X.startupCount,
|
|
1381
|
+
emailTemplates: X.emailCount
|
|
1382
|
+
}), X.startups !== void 0 && On(async () => {
|
|
1383
|
+
await X.startups.stop();
|
|
1384
|
+
});
|
|
1385
|
+
let or = {
|
|
1386
|
+
kind: "api",
|
|
1387
|
+
meta: {
|
|
1388
|
+
name: v?.name ?? "voltro-api",
|
|
1389
|
+
voltroVersion: at,
|
|
1390
|
+
port: re,
|
|
1391
|
+
mode: "start",
|
|
1392
|
+
store: y,
|
|
1393
|
+
cdc: oe ? "on" : "off"
|
|
1394
|
+
},
|
|
1395
|
+
rpc: O(S, _),
|
|
1396
|
+
workflows: Qe(S, _),
|
|
1397
|
+
events: () => Z.eventsSnapshot(),
|
|
1398
|
+
members: () => Z.membersSnapshot(),
|
|
1399
|
+
inspectFireSchedule: async ({ name: e, trigger: t }) => {
|
|
1400
|
+
if (!jn) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
|
|
1401
|
+
return { runId: await jn.fireNow(e, t) ?? null };
|
|
1402
|
+
},
|
|
1403
|
+
...w === void 0 ? {} : { webhooks: () => Ge({
|
|
1404
|
+
store: k,
|
|
1405
|
+
discoveredWebhooks: w
|
|
1406
|
+
}) },
|
|
1407
|
+
plugins: () => ({
|
|
1408
|
+
plugins: Yt.snapshot(),
|
|
1409
|
+
capturedAt: Date.now()
|
|
1410
|
+
}),
|
|
1411
|
+
env: () => t(v?.name ?? Nt(_), {
|
|
1412
|
+
...v?.env !== void 0 && gr(v.env) ? { contract: v.env } : {},
|
|
1413
|
+
plugins: v?.plugins ?? []
|
|
1414
|
+
}),
|
|
1415
|
+
dataCache: () => ve({
|
|
1416
|
+
stats: $e,
|
|
1417
|
+
backendKind: Je
|
|
1418
|
+
}),
|
|
1419
|
+
subscriptions: () => te(() => W),
|
|
1420
|
+
inspectTables: () => ce(S.tables),
|
|
1421
|
+
inspectRows: _e({
|
|
1422
|
+
store: k,
|
|
1423
|
+
tables: S.tables,
|
|
1424
|
+
mask: !0
|
|
1425
|
+
}),
|
|
1426
|
+
metrics: (e) => Z.rpcMetrics().snapshot(e),
|
|
1427
|
+
cluster: () => mt({
|
|
1428
|
+
store: k,
|
|
1429
|
+
dialect: y,
|
|
1430
|
+
useClusterCron: K,
|
|
1431
|
+
scheduleCoordChoice: Dn
|
|
1432
|
+
}),
|
|
1433
|
+
inspectSchedules: () => p({
|
|
1434
|
+
schedules: S.schedules,
|
|
1435
|
+
defaultTrigger: En,
|
|
1436
|
+
coordination: An
|
|
1437
|
+
}),
|
|
1438
|
+
inspectScheduleRuns: (e) => h(k, e),
|
|
1439
|
+
...be(k, {
|
|
1440
|
+
controls: A(S.workflows ?? []),
|
|
1441
|
+
active: (S.workflows?.length ?? 0) > 0,
|
|
1442
|
+
cancellation: () => Z.flowControlHealth()
|
|
1443
|
+
}),
|
|
1444
|
+
webhookActions: ft(() => Z.webhooksService()),
|
|
1445
|
+
inspectStartWorkflow: (e) => Y().inspectStartWorkflow(e),
|
|
1446
|
+
inspectCancelWorkflowRun: (e) => Y().inspectCancelWorkflowRun(e),
|
|
1447
|
+
inspectSuspendWorkflowRun: (e) => Y().inspectSuspendWorkflowRun(e),
|
|
1448
|
+
inspectResumeWorkflowRun: (e) => Y().inspectResumeWorkflowRun(e),
|
|
1449
|
+
inspectDiscardWorkflowRun: (e) => Y().inspectDiscardWorkflowRun(e),
|
|
1450
|
+
inspectRetryWorkflowRun: (e) => Y().inspectRetryWorkflowRun(e),
|
|
1451
|
+
inspectSignalWorkflowRun: (e) => Y().inspectSignalWorkflowRun(e),
|
|
1452
|
+
inspectUpdateWorkflowRun: (e) => Y().inspectUpdateWorkflowRun(e),
|
|
1453
|
+
inspectInferences: (e) => Ue({
|
|
1454
|
+
store: k,
|
|
1455
|
+
active: (S.workflows?.length ?? 0) > 0,
|
|
1456
|
+
dispatcher: () => Z.inferenceHealth()
|
|
1457
|
+
}, e.limit === void 0 ? {} : { limit: e.limit }),
|
|
1458
|
+
...P({
|
|
1459
|
+
store: k,
|
|
1460
|
+
cancelRun: async (e) => await Z.runCanceller()?.(e) ?? !1,
|
|
1461
|
+
retryRun: async (e) => Y().inspectRetryWorkflowRun({ runId: e }),
|
|
1462
|
+
redriveRun: async (e) => Z.redriveWorkflowRun({ runId: e }),
|
|
1463
|
+
log: $
|
|
1464
|
+
}),
|
|
1465
|
+
inspectRedriveWorkflowRun: (e) => Z.redriveWorkflowRun(e),
|
|
1466
|
+
inspectResumeWorkflowRunFromStep: (e) => Z.resumeWorkflowRunFromStep(e)
|
|
1467
|
+
}, Z = await si({
|
|
1468
|
+
bootTiming: g,
|
|
1469
|
+
broadcastNamespace: Ut,
|
|
1470
|
+
membership: {
|
|
1471
|
+
...Kt,
|
|
1472
|
+
instanceId: Vt
|
|
1473
|
+
},
|
|
1474
|
+
...v?.plugins === void 0 ? {} : { plugins: v.plugins },
|
|
1475
|
+
...bn ? { idempotency: {
|
|
1476
|
+
store: bn.store,
|
|
1477
|
+
ttlMs: bn.ttlMs
|
|
1478
|
+
} } : {},
|
|
1479
|
+
discovered: {
|
|
1480
|
+
queries: [...S.queries, ...ir],
|
|
1481
|
+
mutations: S.mutations,
|
|
1482
|
+
actions: [...S.actions, ...J],
|
|
1483
|
+
streams: S.streams,
|
|
1484
|
+
events: S.events,
|
|
1485
|
+
workflows: S.workflows,
|
|
1486
|
+
workflowWorkers: S.workflowWorkers,
|
|
1487
|
+
eventTriggers: S.eventTriggers,
|
|
1488
|
+
schedules: S.schedules,
|
|
1489
|
+
subscribers: zn,
|
|
1490
|
+
outboxHandlers: Gn,
|
|
1491
|
+
connections: S.connections,
|
|
1492
|
+
reactions: Vn,
|
|
1493
|
+
aggregates: q,
|
|
1494
|
+
expectations: $n,
|
|
1495
|
+
budgets: tr,
|
|
1496
|
+
experiments: rr,
|
|
1497
|
+
...w === void 0 ? {} : { webhooks: w }
|
|
1498
|
+
},
|
|
1499
|
+
log: $,
|
|
1500
|
+
analytics: E.sink,
|
|
1501
|
+
aggregateStorage: Xn,
|
|
1502
|
+
aggregateCoordinator: Zn,
|
|
1503
|
+
store: k,
|
|
1504
|
+
kv: rt,
|
|
1505
|
+
cache: Ve,
|
|
1506
|
+
snapshotCache: ze,
|
|
1507
|
+
schemaRegistry: De,
|
|
1508
|
+
tenantScopedTables: S.tenantScopedTables,
|
|
1509
|
+
softDeleteScopedTables: S.softDeleteScopedTables,
|
|
1510
|
+
dataTransferSnapshot: xr(D),
|
|
1511
|
+
dataTransferDialect: y,
|
|
1512
|
+
tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? v?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
|
|
1513
|
+
resolveSubject: async (e, t) => {
|
|
1514
|
+
let n = await _n({
|
|
1515
|
+
headers: e,
|
|
1516
|
+
clientId: t
|
|
1517
|
+
});
|
|
1518
|
+
return kn(t, n.credentialExpiresAt), n.subject;
|
|
1519
|
+
},
|
|
1520
|
+
httpRoutes: [...F.flatMap((e) => e.httpRoutes ?? []), ...xn],
|
|
1521
|
+
getStore: () => je,
|
|
1522
|
+
...Cn ? { baseLayer: Cn } : {},
|
|
1523
|
+
...Pn === void 0 ? {} : { workflowEngineLayer: Pn },
|
|
1524
|
+
scheduleDefaultTrigger: En,
|
|
1525
|
+
scheduleCoordination: An,
|
|
1526
|
+
scheduleArmSelf: !K,
|
|
1527
|
+
dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : v?.dormancy ?? "always-on",
|
|
1528
|
+
scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
|
|
1529
|
+
...In === void 0 ? {} : { scheduleFireInterceptor: In },
|
|
1530
|
+
onSchedulerReady: (e) => {
|
|
1531
|
+
jn = e;
|
|
1532
|
+
},
|
|
1533
|
+
inspectRoute: { handle: async (e, t, n, r) => await de(e, or, t, {
|
|
1534
|
+
method: n,
|
|
1535
|
+
...r === void 0 ? {} : { body: r }
|
|
1536
|
+
}) || (Dt(e, or, t, {
|
|
1537
|
+
method: n,
|
|
1538
|
+
...r === void 0 ? {} : { body: r }
|
|
1539
|
+
}) ?? {
|
|
1540
|
+
status: 404,
|
|
1541
|
+
contentType: "application/json",
|
|
1542
|
+
body: JSON.stringify({ error: "not an inspect route" })
|
|
1543
|
+
}) },
|
|
1544
|
+
...v?.name === void 0 ? {} : { appName: v.name },
|
|
1545
|
+
observability: U,
|
|
1546
|
+
port: re,
|
|
1547
|
+
...v?.transport?.wsPath ? { path: v.transport.wsPath } : {}
|
|
1548
|
+
});
|
|
1549
|
+
return W = Z.dispatcher, T(f([
|
|
1550
|
+
S.queries,
|
|
1551
|
+
S.mutations,
|
|
1552
|
+
S.actions,
|
|
1553
|
+
S.streams
|
|
1554
|
+
]), (e) => {
|
|
1555
|
+
$.warn(e);
|
|
1556
|
+
}), $.info(`API listening on :${re}`, {
|
|
1557
|
+
dialect: y,
|
|
1558
|
+
queries: S.queries.length,
|
|
1559
|
+
mutations: S.mutations.length,
|
|
1560
|
+
actions: S.actions.length,
|
|
1561
|
+
streams: S.streams.length,
|
|
1562
|
+
workflows: S.workflows.length,
|
|
1563
|
+
workflowWorkers: S.workflowWorkers.length,
|
|
1564
|
+
schedules: S.schedules.length,
|
|
1565
|
+
scheduleCoordination: An
|
|
1566
|
+
}), g.finish($), On(async () => {
|
|
1567
|
+
for (let e of Bt) e.stop();
|
|
1568
|
+
st.detach(), ht.stop(), tt(), Mt?.dispose();
|
|
1569
|
+
try {
|
|
1570
|
+
await Yt.deactivate(), await Zt?.close(), await E.dispose(), await Z.close(), await k.close?.();
|
|
1571
|
+
} catch (e) {
|
|
1572
|
+
console.error("serve: shutdown step failed, exiting anyway:", e);
|
|
1573
|
+
}
|
|
1574
|
+
}), await new Promise(() => {}), 0;
|
|
1575
|
+
};
|
|
1576
|
+
//#endregion
|
|
1577
|
+
export { ui as n, ii as r, di as t };
|