@voltro/cli 0.33.0 → 0.34.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 +1801 -0
- package/bin/nodeEnvironment.d.mts +30 -0
- package/bin/nodeEnvironment.mjs +158 -0
- package/bin/voltro.mjs +69 -5
- package/dist/addCommand-BNeoeSxe.js +124 -0
- package/dist/addCommand-aXSQveak.js +2 -0
- package/dist/agentsMd-BTchIZku.js +2 -0
- package/dist/agentsMd-mhQMF1bx.js +254 -0
- package/dist/apiBuild-BICVGnEC.js +2 -0
- package/dist/{apiBuild-h9VHtnlw.js → apiBuild-DZF_f0_I.js} +46 -46
- package/dist/appPort-B_HpJ_ck.js +48 -0
- package/dist/baselineCommand-C2ClWZN3.js +2 -0
- package/dist/baselineCommand-DIttzO8A.js +227 -0
- package/dist/bin.js +71 -28
- package/dist/build-CE7Ca9gm.js +711 -0
- package/dist/cacheCommand-DA4OH9xt.js +42 -0
- package/dist/capabilitiesCommand-nq_pz5xd.js +123 -0
- package/dist/checkCommand-Dv8r9tGO.js +231 -0
- package/dist/checkCommand-YZDmkAGd.js +2 -0
- package/dist/{cliArgs-qdZSElM3.js → cliArgs-D4p8n7EE.js} +12 -1
- package/dist/cliError-BmdYnghb.js +10 -0
- package/dist/cliOutput-D1tSBoRM.js +15 -0
- package/dist/{cliRuntime-Oh517vCV.js → cliRuntime-Dh7UDinH.js} +20 -20
- package/dist/cloudClient-DWL-Hw_T.js +67 -0
- package/dist/cloudCmd-Cvv5HGaZ.js +364 -0
- package/dist/clusterCmd-CNXKlcvD.js +54 -0
- package/dist/codegen-CYM3Zqrf.js +605 -0
- package/dist/codegen-ChBi_hVa.js +2 -0
- package/dist/codegenCommand-DC6w2tNZ.js +30 -0
- package/dist/codemodRunner-DRRqXR74.js +5243 -0
- package/dist/commandRunner-BLAEFLjp.js +47 -0
- package/dist/commands-gutsz-Ac.js +808 -0
- package/dist/connectionConfig-UFlIEiys.js +66 -0
- package/dist/dashboardCommand-3YG8p-UA.js +25 -0
- package/dist/dataCommand-qL0r7fPO.js +535 -0
- package/dist/dataProfile-dW-PsfLB.js +15 -0
- package/dist/{dbCommand-DTLKAfbA.js → dbCommand-B6X0FZbq.js} +551 -401
- package/dist/dbCommand-CpdKLeQq.js +2 -0
- package/dist/{dev-C_P8FLSx.js → dev-CerMd0mW.js} +3122 -3129
- package/dist/dev-CoG-ZPx8.js +3 -0
- package/dist/devActivity-Dx_3nnGv.js +100 -0
- package/dist/devActivity.js +1 -1
- package/dist/dialectDriver-CgXnDfec.js +39 -0
- package/dist/discover-C9XKJDco.js +25 -0
- package/dist/doctorCommand-BvqGBwNG.js +2 -0
- package/dist/{checkCommand-xGhRFFg2.js → doctorCommand-CnDXQxfa.js} +520 -1278
- package/dist/dormancyCommand-Dszo57d6.js +69 -0
- package/dist/e2eCmd-BRabZww-.js +147 -0
- package/dist/embeddingsCommand-C0sKVRo1.js +73 -0
- package/dist/envCommand-DPgdV1Bq.js +60 -0
- package/dist/evalCommand-6RUfPen4.js +118 -0
- package/dist/evolveCommand-DHpkgjgH.js +281 -0
- package/dist/fileTaxonomy-CJfgOllU.js +457 -0
- package/dist/frameworkTableAssembly-BGHmck-x.js +2 -0
- package/dist/{frameworkTableAssembly-BwIrO5nv.js → frameworkTableAssembly-DkkP6BgC.js} +184 -148
- package/dist/generateCommand-oibemh97.js +147 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +4 -3
- package/dist/infoCommand-BJw9nLUR.js +60 -0
- package/dist/{inspect-BUUjt773.js → inspect-CBqFtAKA.js} +82 -40
- package/dist/inspect-C_T_WGvl.js +2 -0
- package/dist/inspectCmd-Bppy-GGw.js +224 -0
- package/dist/inspectFetch-Cm8_wVvp.js +151 -0
- package/dist/inspectMetrics-CfdKLh6t.js +72 -0
- package/dist/loadEnv-D9nEOClM.js +44 -0
- package/dist/logFileSink-C_D2wRN1.js +105 -0
- package/dist/logsCmd-CCca3KRZ.js +260 -0
- package/dist/manifestBuild-ChsKAhmn.js +2 -0
- package/dist/{manifestBuild-BLrVuSlM.js → manifestBuild-sxpwdKY1.js} +1 -1
- package/dist/metaCommands-7MJfZ5cf.js +196 -0
- package/dist/migrate-CBwOt_iV.js +83 -0
- package/dist/mssqlClusterPatch-_4cE_nun.js +44 -0
- package/dist/newCommand-COWOJ1_E.js +156 -0
- package/dist/nodeEnvironment-cGFAj1J8.js +28 -0
- package/dist/packageCommand-Cug_3Ogl.js +271 -0
- package/dist/pageConvention-cEiRxdab.js +5 -0
- package/dist/privacyCommand-C-Df56U_.js +146 -0
- package/dist/projectScaffold-DmzEKHib.js +2 -0
- package/dist/projectScaffold-LMMtaavR.js +814 -0
- package/dist/renderModeScan-D7J1B7Kw.js +105 -0
- package/dist/renderProfile-1OWWAAtx.js +81 -0
- package/dist/runtimeRegistry-DMeKfTHP.js +81 -0
- package/dist/runtimeTrace-CRxalXTs.js +91 -0
- package/dist/scheduleCmd--jksTrf6.js +69 -0
- package/dist/scheduleManifestCmd-D2x0CTTY.js +249 -0
- package/dist/schemaIr-UJybUUZW.js +103 -0
- package/dist/{sdkgen-C81QIkiL.js → sdkgen-CYJscZC7.js} +111 -209
- package/dist/seedRunner-TFHHiToI.js +329 -0
- package/dist/serveCommand-B_isw7q4.js +1647 -0
- package/dist/serveCommand-DOvbgRnQ.js +2 -0
- package/dist/serveEntry.js +5 -5
- package/dist/serverlessCommand-CfJZy6dS.js +482 -0
- package/dist/start-9LiUOfES.js +1087 -0
- package/dist/start-B-9Nsp-S.js +3 -0
- package/dist/startEntry.js +2 -2
- package/dist/staticCommand-Dr2M6tpU.js +304 -0
- package/dist/storageCommand-Co6NfLqN.js +42 -0
- package/dist/templates-De8IR5-c.js +102 -0
- package/dist/test-CI6iDsYc.js +115 -0
- package/dist/tracesCmd-CkEZQrtt.js +232 -0
- package/dist/tsconfigPaths-BWXBWgcl.js +107 -0
- package/dist/tsxLoader-EuXmSJ1K.js +51 -0
- package/dist/typecheckCommand-BlsWiCNq.js +61 -0
- package/dist/updateCommand-Bkptutss.js +585 -0
- package/dist/updateCommand-us1_hdIC.js +2 -0
- package/dist/{inspectMetrics-1xzTKAFx.js → webDev-CBYvPqQr.js} +975 -1559
- package/dist/webDev-Cg-fFiyd2.js +2 -0
- package/dist/webhookDiscovery-CrGAfhIG.js +2 -0
- package/dist/webhookDiscovery-D7VaeMlz.js +51 -0
- package/dist/webhooksCommand-CID96Rga.js +267 -0
- package/dist/workflowsCmd-D1VTmLMY.js +608 -0
- package/package.json +179 -17
- package/templates/AGENTS.core.md +58 -3
- package/templates/AGENTS.md +64 -7
- package/templates/agent-docs/_index.md +6 -4
- package/templates/agent-docs/_manifest.json +22 -5
- package/templates/agent-docs/ai.md +370 -0
- package/templates/agent-docs/authentication.md +265 -31
- package/templates/agent-docs/caching.md +6 -0
- package/templates/agent-docs/cli.md +794 -50
- package/templates/agent-docs/data.md +550 -11
- package/templates/agent-docs/database/migrations.md +174 -25
- package/templates/agent-docs/database/misc.md +156 -40
- package/templates/agent-docs/database/querying.md +19 -1
- package/templates/agent-docs/database/scaling.md +60 -0
- package/templates/agent-docs/database/schema.md +1 -0
- package/templates/agent-docs/database/seedsdialects.md +208 -19
- package/templates/agent-docs/database/transactions.md +68 -0
- package/templates/agent-docs/deployment.md +69 -3
- package/templates/agent-docs/introduction.md +87 -16
- package/templates/agent-docs/local-first-mobile.md +79 -4
- package/templates/agent-docs/multi-tenancy.md +95 -20
- package/templates/agent-docs/observability.md +58 -3
- package/templates/agent-docs/plugins/ai-flows.md +161 -2
- package/templates/agent-docs/plugins/analytics-postgres.md +1 -1
- package/templates/agent-docs/plugins/audit.md +37 -1
- package/templates/agent-docs/plugins/auth-social.md +143 -0
- package/templates/agent-docs/plugins/auth-workos.md +4 -2
- package/templates/agent-docs/plugins/auth.md +131 -6
- package/templates/agent-docs/plugins/billing.md +132 -15
- package/templates/agent-docs/plugins/cdc-out.md +46 -7
- package/templates/agent-docs/plugins/clickhouse.md +1 -1
- package/templates/agent-docs/plugins/duckdb.md +1 -1
- package/templates/agent-docs/plugins/flags.md +132 -0
- package/templates/agent-docs/plugins/governance.md +105 -7
- package/templates/agent-docs/plugins/multitenancy.md +9 -4
- package/templates/agent-docs/plugins/presence.md +13 -2
- package/templates/agent-docs/plugins/ratelimit.md +9 -0
- package/templates/agent-docs/plugins/search.md +157 -6
- package/templates/agent-docs/plugins/sso-saml.md +47 -8
- package/templates/agent-docs/plugins/webhooks.md +105 -0
- package/templates/agent-docs/plugins.md +150 -18
- package/templates/agent-docs/reference.md +60 -3
- package/templates/agent-docs/releases.md +1117 -0
- package/templates/agent-docs/routing.md +43 -25
- package/templates/agent-docs/scheduling.md +10 -0
- package/templates/agent-docs/schema-driven-ui.md +92 -12
- package/templates/agent-docs/security.md +426 -0
- package/templates/agent-docs/templates/apibackends.md +87 -18
- package/templates/agent-docs/templates/appshells.md +32 -14
- package/templates/agent-docs/templates/overview.md +13 -8
- package/templates/agent-docs/testing.md +211 -14
- package/templates/agent-docs/whats-new.md +1700 -104
- package/templates/agent-docs/workflows.md +130 -14
- package/templates/apps/api-ai/actions/summarize.action.ts +11 -0
- package/templates/apps/api-ai/package.json +8 -7
- package/templates/apps/api-auth/actions/me.action.ts +13 -0
- package/templates/apps/api-auth/package.json +9 -8
- package/templates/apps/api-backend/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend/package.json +12 -8
- package/templates/apps/api-backend/queries/notes.query.ts +30 -8
- package/templates/apps/api-backend-deactivation/actions/users.get.action.ts +14 -0
- package/templates/apps/api-backend-deactivation/mutations/users.create.mutation.ts +8 -0
- package/templates/apps/api-backend-deactivation/mutations/users.deactivate.mutation.ts +10 -0
- package/templates/apps/api-backend-deactivation/package.json +8 -7
- package/templates/apps/api-backend-mail/actions/sendWelcome.action.ts +17 -0
- package/templates/apps/api-backend-mail/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend-mail/package.json +9 -8
- package/templates/apps/api-backend-mail/queries/notes.query.ts +30 -8
- package/templates/apps/api-backend-mariadb/.env.example +14 -0
- package/templates/apps/api-backend-mariadb/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend-mariadb/package.json +10 -9
- package/templates/apps/api-backend-mariadb/queries/notes.query.ts +30 -8
- package/templates/apps/api-backend-sqlite/.env.example +14 -0
- package/templates/apps/api-backend-sqlite/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend-sqlite/package.json +9 -8
- package/templates/apps/api-backend-sqlite/queries/notes.query.ts +30 -8
- package/templates/apps/api-backend-storage/actions/uploadAvatar.action.ts +13 -0
- package/templates/apps/api-backend-storage/actions/uploadDocument.action.ts +12 -0
- package/templates/apps/api-backend-storage/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend-storage/package.json +9 -8
- package/templates/apps/api-backend-storage/queries/notes.query.ts +30 -8
- package/templates/apps/api-cms/actions/content.get.action.ts +7 -0
- package/templates/apps/api-cms/actions/content.types.action.ts +6 -0
- package/templates/apps/api-cms/actions/me.action.ts +13 -0
- package/templates/apps/api-cms/app.config.ts +19 -0
- package/templates/apps/api-cms/authz.ts +63 -0
- package/templates/apps/api-cms/mutations/content.publish.mutation.ts +10 -0
- package/templates/apps/api-cms/mutations/content.saveDraft.mutation.ts +10 -0
- package/templates/apps/api-cms/mutations/content.unpublish.mutation.ts +5 -0
- package/templates/apps/api-cms/package.json +11 -10
- package/templates/apps/api-cms/queries/content.list.query.ts +23 -7
- package/templates/apps/api-cms/tests/accessDecisions.test.ts +121 -0
- package/templates/apps/api-cms/tests/content.descriptors.test.ts +8 -4
- package/templates/apps/api-collab/mutations/documents.create.mutation.ts +8 -0
- package/templates/apps/api-collab/mutations/documents.setBody.mutation.ts +13 -0
- package/templates/apps/api-collab/package.json +9 -8
- package/templates/apps/api-collab/queries/documents.query.ts +19 -7
- package/templates/apps/api-data-advanced/package.json +9 -8
- package/templates/apps/api-data-advanced/queries/authors.withBooks.query.ts +12 -0
- package/templates/apps/api-data-advanced/queries/books.search.query.ts +9 -0
- package/templates/apps/api-durable/mutations/orders.approve.mutation.ts +17 -0
- package/templates/apps/api-durable/mutations/orders.place.mutation.ts +9 -0
- package/templates/apps/api-durable/package.json +9 -8
- package/templates/apps/api-feature-flags/actions/notes.export.action.ts +16 -0
- package/templates/apps/api-feature-flags/mutations/notes.create.mutation.ts +12 -0
- package/templates/apps/api-feature-flags/package.json +10 -9
- package/templates/apps/api-governance/README.md +30 -8
- package/templates/apps/api-governance/actions/profiles.get.action.server.ts +17 -1
- package/templates/apps/api-governance/actions/profiles.get.action.ts +29 -4
- package/templates/apps/api-governance/database/schema.ts +16 -4
- package/templates/apps/api-governance/mutations/profiles.create.mutation.ts +12 -0
- package/templates/apps/api-governance/package.json +9 -8
- package/templates/apps/api-kv/actions/sync.pull.action.ts +15 -0
- package/templates/apps/api-kv/actions/sync.reset.action.ts +13 -0
- package/templates/apps/api-kv/actions/sync.status.action.ts +7 -0
- package/templates/apps/api-kv/package.json +9 -8
- package/templates/apps/api-kv/queries/events.list.query.ts +19 -8
- package/templates/apps/api-moderation/mutations/comments.create.mutation.ts +11 -0
- package/templates/apps/api-moderation/mutations/posts.create.mutation.ts +13 -0
- package/templates/apps/api-moderation/package.json +9 -8
- package/templates/apps/api-observability/mutations/notes.create.mutation.ts +8 -0
- package/templates/apps/api-observability/package.json +9 -8
- package/templates/apps/api-observability/queries/notes.list.query.ts +13 -0
- package/templates/apps/api-ratelimit/mutations/notes.create.mutation.ts +14 -0
- package/templates/apps/api-ratelimit/package.json +9 -8
- package/templates/apps/api-rbac/package.json +9 -8
- package/templates/apps/api-rest/package.json +8 -7
- package/templates/apps/api-saas/mutations/projects.create.mutation.ts +13 -0
- package/templates/apps/api-saas/package.json +12 -11
- package/templates/apps/api-saas/queries/projects.list.query.ts +11 -0
- package/templates/apps/api-saas-starter/actions/me.action.ts +13 -0
- package/templates/apps/api-saas-starter/app.config.ts +19 -0
- package/templates/apps/api-saas-starter/authz.ts +75 -0
- package/templates/apps/api-saas-starter/mutations/invites.create.mutation.ts +10 -0
- package/templates/apps/api-saas-starter/mutations/projects.create.mutation.ts +9 -0
- package/templates/apps/api-saas-starter/package.json +15 -11
- package/templates/apps/api-saas-starter/queries/invites.list.query.ts +19 -8
- package/templates/apps/api-saas-starter/queries/projects.list.query.ts +18 -7
- package/templates/apps/api-saas-starter/tests/accessDecisions.test.ts +135 -0
- package/templates/apps/api-search/mutations/articles.create.mutation.ts +14 -0
- package/templates/apps/api-search/package.json +9 -8
- package/templates/apps/api-search/queries/articles.list.query.ts +21 -8
- package/templates/apps/api-status/README.md +10 -3
- package/templates/apps/api-status/app.config.ts +8 -3
- package/templates/apps/api-status/authz.ts +5 -3
- package/templates/apps/api-status/package.json +9 -8
- package/templates/apps/api-status/queries/components.list.query.ts +14 -6
- package/templates/apps/api-status/queries/incidents.live.query.ts +23 -10
- package/templates/apps/api-status/queries/updates.list.query.ts +16 -9
- package/templates/apps/api-status/tests/status.test.ts +9 -1
- package/templates/apps/api-versioning/actions/documents.asOf.action.ts +12 -0
- package/templates/apps/api-versioning/actions/documents.history.action.ts +13 -0
- package/templates/apps/api-versioning/mutations/documents.create.mutation.ts +9 -0
- package/templates/apps/api-versioning/mutations/documents.update.mutation.ts +12 -0
- package/templates/apps/api-versioning/package.json +9 -8
- package/templates/apps/api-webhooks/mutations/orders.fulfill.mutation.ts +16 -0
- package/templates/apps/api-webhooks/package.json +10 -9
- package/templates/apps/api-webhooks/queries/orders.list.query.ts +10 -0
- package/templates/apps/changelog/package.json +8 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +10 -8
- package/templates/apps/frontend-admin/src/lib/admin.ts +20 -9
- package/templates/apps/frontend-admin/src/locales/de.ts +11 -1
- package/templates/apps/frontend-admin/src/locales/en.ts +13 -1
- package/templates/apps/frontend-admin/src/pages/admin/[entity]/page.tsx +65 -22
- package/templates/apps/frontend-admin/src/pages/admin/entity.test.tsx +130 -23
- package/templates/apps/frontend-admin/src/pages/admin/layout.tsx +3 -2
- package/templates/apps/frontend-admin/src/pages/admin/page.test.tsx +19 -2
- package/templates/apps/frontend-admin/src/pages/admin/page.tsx +9 -4
- package/templates/apps/frontend-app/app.config.ts +4 -3
- package/templates/apps/frontend-app/package.json +11 -8
- package/templates/apps/frontend-app/src/lib/api.ts +25 -0
- package/templates/apps/frontend-app/src/pages/page.test.tsx +130 -82
- package/templates/apps/frontend-app/src/pages/page.tsx +14 -18
- package/templates/apps/frontend-auth/package.json +10 -8
- package/templates/apps/frontend-blank/package.json +9 -7
- package/templates/apps/frontend-cms/package.json +11 -9
- package/templates/apps/frontend-collab/package.json +12 -9
- package/templates/apps/frontend-collab/src/pages/page.test.tsx +122 -78
- package/templates/apps/frontend-contact/package.json +9 -7
- package/templates/apps/frontend-dashboard/package.json +9 -7
- package/templates/apps/frontend-docs/package.json +9 -7
- package/templates/apps/frontend-i18n/package.json +8 -6
- package/templates/apps/frontend-landing/package.json +9 -7
- package/templates/apps/frontend-portal/package.json +10 -8
- package/templates/apps/frontend-saas/app.config.ts +10 -6
- package/templates/apps/frontend-saas/package.json +10 -8
- package/templates/apps/frontend-saas/src/lib/api.ts +27 -32
- package/templates/apps/frontend-saas/src/pages/dashboard/billing/page.tsx +7 -8
- package/templates/apps/frontend-saas/src/pages/dashboard/page.test.tsx +27 -3
- package/templates/apps/frontend-saas/src/pages/dashboard/page.tsx +4 -4
- package/templates/apps/frontend-saas/src/pages/dashboard/team/page.tsx +3 -4
- package/templates/apps/frontend-spa/package.json +9 -7
- package/templates/apps/frontend-ssr/package.json +9 -7
- package/templates/apps/frontend-ssr-api/package.json +10 -8
- package/templates/apps/frontend-static-blog/package.json +8 -6
- package/templates/apps/frontend-status/package.json +10 -8
- package/templates/apps/mobile-app/README.md +1 -0
- package/templates/apps/mobile-app/package.json +4 -2
- package/templates/apps/mobile-app/src/app/index.tsx +22 -12
- package/templates/apps/mobile-app/src/app/orders/[id].tsx +1 -1
- package/templates/apps/mobile-app/src/lib/api.ts +34 -0
- package/templates/apps/mobile-app/voltro.mobile.ts +4 -2
- package/templates/baselines/bare/.env.example +14 -0
- package/templates/baselines/bare/baseline.json +4 -4
- package/templates/baselines/compose/.env.example +14 -0
- package/templates/baselines/compose/README.md +1 -1
- package/templates/baselines/compose/baseline.json +5 -5
- package/templates/baselines/compose-mariadb/.env.example +14 -0
- package/templates/baselines/compose-mariadb/README.md +1 -1
- package/templates/baselines/compose-mariadb/baseline.json +5 -5
- package/templates/baselines/helm/.env.example +14 -0
- package/templates/baselines/helm/baseline.json +4 -4
- package/dist/apiBuild-C-x9YacA.js +0 -2
- package/dist/checkCommand-DRovTKza.js +0 -2
- package/dist/commands-CJfepbm4.js +0 -11541
- package/dist/dbCommand-b1gum4td.js +0 -2
- package/dist/dev-iiMtlkfs.js +0 -3
- package/dist/devActivity-BhIu6ncs.js +0 -159
- package/dist/frameworkTableAssembly-D-EebUQX.js +0 -2
- package/dist/inspect-mmBuRXmy.js +0 -2
- package/dist/manifestBuild-Dj8Jjoto.js +0 -2
- package/dist/seedRunner-Bqxgp7HZ.js +0 -230
- package/dist/serveCommand-DdaM4Hup.js +0 -1608
- package/dist/start-C0koT0UO.js +0 -1084
- /package/templates/apps/api-ai/actions/{summarize.action.server.tsx → summarize.action.server.ts} +0 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { n as e } from "./cliOutput-D1tSBoRM.js";
|
|
2
|
+
import { n as t, o as n, r, t as i } from "./inspectFetch-Cm8_wVvp.js";
|
|
3
|
+
import { ansi as a } from "@voltro/logger";
|
|
4
|
+
//#region src/inspectCmd.ts
|
|
5
|
+
var o = {
|
|
6
|
+
app: {
|
|
7
|
+
path: "/_voltro/inspect/app",
|
|
8
|
+
method: "GET",
|
|
9
|
+
desc: "manifest meta (kind, name, store, …)"
|
|
10
|
+
},
|
|
11
|
+
routes: {
|
|
12
|
+
path: "/_voltro/inspect/routes",
|
|
13
|
+
method: "GET",
|
|
14
|
+
desc: "web page table (web apps only)"
|
|
15
|
+
},
|
|
16
|
+
rpc: {
|
|
17
|
+
path: "/_voltro/inspect/rpc",
|
|
18
|
+
method: "GET",
|
|
19
|
+
desc: "procedures + workflow descriptors"
|
|
20
|
+
},
|
|
21
|
+
metrics: {
|
|
22
|
+
path: "/_voltro/inspect/metrics",
|
|
23
|
+
method: "GET",
|
|
24
|
+
desc: "rolling rpc latency buckets"
|
|
25
|
+
},
|
|
26
|
+
cache: {
|
|
27
|
+
path: "/_voltro/inspect/cache",
|
|
28
|
+
method: "GET",
|
|
29
|
+
desc: "web data-cache stats (web apps only)"
|
|
30
|
+
},
|
|
31
|
+
schedules: {
|
|
32
|
+
path: "/_voltro/inspect/schedules",
|
|
33
|
+
method: "GET",
|
|
34
|
+
desc: "cron registrations + coordination mode"
|
|
35
|
+
},
|
|
36
|
+
aggregates: {
|
|
37
|
+
path: "/_voltro/inspect/aggregates",
|
|
38
|
+
method: "GET",
|
|
39
|
+
desc: "materialised aggregate views"
|
|
40
|
+
},
|
|
41
|
+
workflows: {
|
|
42
|
+
path: "/_voltro/inspect/workflows/runs",
|
|
43
|
+
method: "GET",
|
|
44
|
+
desc: "recorded workflow runs (+ `--failing`)"
|
|
45
|
+
},
|
|
46
|
+
invoke: {
|
|
47
|
+
path: "/_voltro/inspect/invoke",
|
|
48
|
+
method: "POST",
|
|
49
|
+
desc: "call a procedure (--tag --input)"
|
|
50
|
+
}
|
|
51
|
+
}, s = 20, c = 200, l = (e) => e.consecutiveFailures > 0, u = (e) => {
|
|
52
|
+
let t = [], n = !1;
|
|
53
|
+
for (let r of e) {
|
|
54
|
+
if (r === "--failing") {
|
|
55
|
+
n = !0;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
t.push(r);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
failingOnly: n,
|
|
62
|
+
rest: t
|
|
63
|
+
};
|
|
64
|
+
}, d = async (e) => {
|
|
65
|
+
let t = await i(e, `/_voltro/inspect/workflows/runs?limit=${c}`);
|
|
66
|
+
if (t.kind !== "ok") return [];
|
|
67
|
+
let n = t.data.runs ?? [], r = /* @__PURE__ */ new Map();
|
|
68
|
+
for (let e of n) {
|
|
69
|
+
let t = r.get(e.tag);
|
|
70
|
+
t === void 0 ? r.set(e.tag, [e]) : t.push(e);
|
|
71
|
+
}
|
|
72
|
+
return [...r].map(([e, t]) => {
|
|
73
|
+
let n = 0;
|
|
74
|
+
for (let e of t) {
|
|
75
|
+
if (e.status === "failed") {
|
|
76
|
+
n++;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (!(e.status === "running" || e.status === "suspended" || e.status === "cancelled")) break;
|
|
80
|
+
}
|
|
81
|
+
let r = t[0];
|
|
82
|
+
return {
|
|
83
|
+
name: e,
|
|
84
|
+
cron: "",
|
|
85
|
+
lastStatus: r?.status ?? null,
|
|
86
|
+
lastFiredAt: r?.startedAt ?? null,
|
|
87
|
+
consecutiveFailures: n,
|
|
88
|
+
totalRunsSeen: t.length,
|
|
89
|
+
lastError: t.find((e) => e.status === "failed")?.errorMessage ?? null
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
}, f = async (e) => {
|
|
93
|
+
let t = await i(e, "/_voltro/inspect/schedules");
|
|
94
|
+
if (t.kind !== "ok") return [];
|
|
95
|
+
let n = t.data.schedules ?? [];
|
|
96
|
+
return await Promise.all(n.map(async (t) => {
|
|
97
|
+
let n = await i(e, `/_voltro/inspect/schedules/runs?name=${encodeURIComponent(t.name)}&limit=${s}`), r = n.kind === "ok" ? n.data.runs ?? [] : [], a = 0;
|
|
98
|
+
for (let e of r) {
|
|
99
|
+
if (e.status === "failed") {
|
|
100
|
+
a++;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (!(e.status === "skipped" || e.status === "missed")) break;
|
|
104
|
+
}
|
|
105
|
+
let o = r[0];
|
|
106
|
+
return {
|
|
107
|
+
name: t.name,
|
|
108
|
+
cron: t.cron,
|
|
109
|
+
lastStatus: o?.status ?? null,
|
|
110
|
+
lastFiredAt: o?.firedAt ?? null,
|
|
111
|
+
consecutiveFailures: a,
|
|
112
|
+
totalRunsSeen: r.length,
|
|
113
|
+
lastError: r.find((e) => e.status === "failed")?.errorMessage ?? null
|
|
114
|
+
};
|
|
115
|
+
}));
|
|
116
|
+
}, p = (t, n, r, i) => {
|
|
117
|
+
let o = r ? n.filter(l) : n;
|
|
118
|
+
if (i === "json") {
|
|
119
|
+
e({
|
|
120
|
+
process: t,
|
|
121
|
+
schedules: o
|
|
122
|
+
}, { pretty: !1 });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (console.log(a.bold(`# schedules @${t}`)), o.length === 0) {
|
|
126
|
+
console.log(a.dim(r ? " no failing schedules" : " no schedules registered"));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
for (let e of o) {
|
|
130
|
+
let t = l(e) ? a.red(`FAILING x${e.consecutiveFailures}`) : e.lastStatus === null ? a.dim("never run") : a.dim(e.lastStatus);
|
|
131
|
+
console.log(e.cron === "" ? ` ${e.name} ${t}` : ` ${e.name} ${a.dim(e.cron)} ${t}`), e.consecutiveFailures > 0 && e.consecutiveFailures === e.totalRunsSeen && console.log(a.red(` every recorded run failed (last ${e.totalRunsSeen})`)), e.lastError !== null && console.log(` ${a.dim(e.lastError)}`);
|
|
132
|
+
}
|
|
133
|
+
}, m = () => {
|
|
134
|
+
console.log("voltro inspect — query the live /_voltro/inspect/* surface of every running api"), console.log(""), console.log("Usage:"), console.log(" voltro inspect <subcommand> [--process NAME] [--format pretty|json]"), console.log(""), console.log("Subcommands:");
|
|
135
|
+
let e = Object.keys(o).reduce((e, t) => Math.max(e, t.length), 0);
|
|
136
|
+
for (let [t, n] of Object.entries(o)) console.log(` ${t.padEnd(e + 2)}${n.method.padEnd(5)}${n.desc}`);
|
|
137
|
+
console.log(""), console.log("Examples:"), console.log(" voltro inspect app"), console.log(" voltro inspect schedules --failing # exits 1 if any cron is broken"), console.log(" voltro inspect workflows --failing # exits 1 if any workflow is broken"), console.log(" voltro inspect rpc --format json | jq '.[].data.procedures'"), console.log(" voltro inspect invoke --tag users.list --input '{}'");
|
|
138
|
+
}, h = async () => {
|
|
139
|
+
let e = await n();
|
|
140
|
+
if (console.log(""), e.length === 0) {
|
|
141
|
+
console.log(a.dim(" (no live api processes — start one with `voltro dev`)"));
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
console.log("Live api processes:");
|
|
145
|
+
for (let t of e) console.log(` - ${t.name} ${a.dim(t.url)}`);
|
|
146
|
+
}, g = (e) => {
|
|
147
|
+
let t, n = {}, r;
|
|
148
|
+
for (let i = 0; i < e.length; i++) {
|
|
149
|
+
let a = e[i];
|
|
150
|
+
if (a === "--tag" || a === "--procedure" || a === "--proc") {
|
|
151
|
+
t = e[++i];
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (a === "--input") {
|
|
155
|
+
let t = e[++i];
|
|
156
|
+
if (t === void 0) {
|
|
157
|
+
r = "--input expects a JSON value";
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
n = JSON.parse(t);
|
|
162
|
+
} catch {
|
|
163
|
+
r = `--input: invalid JSON '${t}'`;
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
tag: t,
|
|
170
|
+
input: n,
|
|
171
|
+
inputError: r
|
|
172
|
+
};
|
|
173
|
+
}, _ = (t) => {
|
|
174
|
+
let n = t.filter((e) => e.kind === "ok"), r = t.filter((e) => e.kind === "err").map((e) => ({
|
|
175
|
+
name: e.name,
|
|
176
|
+
error: e.error
|
|
177
|
+
}));
|
|
178
|
+
return e(r.length > 0 ? {
|
|
179
|
+
results: n.map((e) => ({
|
|
180
|
+
process: e.name,
|
|
181
|
+
data: e.data
|
|
182
|
+
})),
|
|
183
|
+
fetchErrors: r
|
|
184
|
+
} : { results: n.map((e) => ({
|
|
185
|
+
process: e.name,
|
|
186
|
+
data: e.data
|
|
187
|
+
})) }, { pretty: !1 }), +(n.length === 0);
|
|
188
|
+
}, v = (t, n) => {
|
|
189
|
+
let r = !1;
|
|
190
|
+
for (let i of n) i.kind === "ok" ? (r = !0, console.log(a.bold(`# ${t} @${i.name}`)), e(i.data)) : console.error(a.dim(`# fetch failed: ${i.name}: ${i.error}`));
|
|
191
|
+
return +!r;
|
|
192
|
+
}, y = async (e) => {
|
|
193
|
+
let [a, ...s] = e;
|
|
194
|
+
if (a === void 0 || a === "--help" || a === "-h" || a === "help") return m(), await h(), 0;
|
|
195
|
+
let c = o[a];
|
|
196
|
+
if (c === void 0) return console.error(`voltro inspect: unknown subcommand '${a}'`), m(), 2;
|
|
197
|
+
let y = t(s);
|
|
198
|
+
if ("error" in y) return console.error(`voltro inspect: ${y.error}`), 2;
|
|
199
|
+
let { process: b, target: x, rest: S } = r(y.rest), C = y.format, w = a === "schedules" || a === "workflows" ? u(S) : void 0, T;
|
|
200
|
+
if (a === "invoke") {
|
|
201
|
+
if (T = g(S), T.inputError !== void 0) return console.error(`voltro inspect invoke: ${T.inputError}`), 2;
|
|
202
|
+
if (T.tag === void 0) return console.error("voltro inspect invoke: --tag <procedureTag> is required"), 2;
|
|
203
|
+
}
|
|
204
|
+
let E = await n(b, x);
|
|
205
|
+
if (E.length === 0) return console.error(b === void 0 ? "voltro inspect: no live api processes found (start one with `voltro dev`)" : `voltro inspect: no live api named '${b}'`), 1;
|
|
206
|
+
if (w?.failingOnly === !0) {
|
|
207
|
+
let e = 0;
|
|
208
|
+
for (let t of E) {
|
|
209
|
+
let n = a === "workflows" ? await d(t) : await f(t);
|
|
210
|
+
e += n.filter(l).length, p(t.name, n, !0, C);
|
|
211
|
+
}
|
|
212
|
+
return +(e > 0);
|
|
213
|
+
}
|
|
214
|
+
let D = await Promise.all(E.map((e) => c.method === "POST" ? i(e, c.path, {
|
|
215
|
+
method: "POST",
|
|
216
|
+
body: {
|
|
217
|
+
tag: T.tag,
|
|
218
|
+
input: T.input
|
|
219
|
+
}
|
|
220
|
+
}) : i(e, c.path)));
|
|
221
|
+
return C === "json" ? _(D) : v(a, D);
|
|
222
|
+
};
|
|
223
|
+
//#endregion
|
|
224
|
+
export { y as runInspectCommand };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { n as e } from "./runtimeRegistry-DMeKfTHP.js";
|
|
2
|
+
//#region src/inspectFetch.ts
|
|
3
|
+
var t = (e, t, n = !1) => {
|
|
4
|
+
let r = { ...e ?? {} }, i = t ?? process.env.VOLTRO_INSPECT_TOKEN;
|
|
5
|
+
if (i !== void 0 && i !== "" && (r.authorization = `Bearer ${i}`), n) {
|
|
6
|
+
let e = process.env.VOLTRO_INSPECT_WRITE_TOKEN;
|
|
7
|
+
e !== void 0 && e !== "" && (r["x-voltro-inspect-write"] = e);
|
|
8
|
+
}
|
|
9
|
+
return r;
|
|
10
|
+
}, n = /* @__PURE__ */ new Set([
|
|
11
|
+
"POST",
|
|
12
|
+
"PUT",
|
|
13
|
+
"PATCH",
|
|
14
|
+
"DELETE"
|
|
15
|
+
]), r = async (e, r, i) => {
|
|
16
|
+
let a = `${e.url.replace(/\/+$/, "")}${r.startsWith("/") ? r : `/${r}`}`, o = i?.method ?? "GET", s = i?.body !== void 0;
|
|
17
|
+
try {
|
|
18
|
+
let r = await fetch(a, {
|
|
19
|
+
method: o,
|
|
20
|
+
headers: t(s ? { "content-type": "application/json" } : void 0, e.inspectToken, n.has(o)),
|
|
21
|
+
...s ? { body: JSON.stringify(i.body) } : {}
|
|
22
|
+
}), c = await r.text(), l;
|
|
23
|
+
if (c.length > 0) try {
|
|
24
|
+
l = JSON.parse(c);
|
|
25
|
+
} catch {
|
|
26
|
+
l = c;
|
|
27
|
+
}
|
|
28
|
+
if (!r.ok) {
|
|
29
|
+
let t = l, i = typeof t == "object" && t ? String(t.message ?? t.reason ?? t.error ?? `HTTP ${r.status}`) : `HTTP ${r.status}`, a = n.has(o) && (process.env.VOLTRO_INSPECT_WRITE_TOKEN ?? "") === "" && /write/i.test(i);
|
|
30
|
+
return {
|
|
31
|
+
kind: "err",
|
|
32
|
+
name: e.name,
|
|
33
|
+
error: a ? `${i}\n VOLTRO_INSPECT_WRITE_TOKEN is not set in this shell. \`voltro dev\` mints it into the project's \`.env.local\`; export it (or run from a shell that loaded it).` : i
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
kind: "ok",
|
|
38
|
+
name: e.name,
|
|
39
|
+
status: r.status,
|
|
40
|
+
data: l
|
|
41
|
+
};
|
|
42
|
+
} catch (t) {
|
|
43
|
+
return {
|
|
44
|
+
kind: "err",
|
|
45
|
+
name: e.name,
|
|
46
|
+
error: t.message || String(t)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}, i = (e, t = process.env) => {
|
|
50
|
+
let n = [], r, i;
|
|
51
|
+
for (let t = 0; t < e.length; t++) {
|
|
52
|
+
let a = e[t];
|
|
53
|
+
if (a === "--url") {
|
|
54
|
+
r = e[++t];
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (a.startsWith("--url=")) {
|
|
58
|
+
r = a.slice(6);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (a === "--token") {
|
|
62
|
+
i = e[++t];
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (a.startsWith("--token=")) {
|
|
66
|
+
i = a.slice(8);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
n.push(a);
|
|
70
|
+
}
|
|
71
|
+
if (r ??= t.VOLTRO_INSPECT_URL, r === void 0 || r === "") return {
|
|
72
|
+
target: void 0,
|
|
73
|
+
rest: n
|
|
74
|
+
};
|
|
75
|
+
let a;
|
|
76
|
+
try {
|
|
77
|
+
a = new URL(r);
|
|
78
|
+
} catch {
|
|
79
|
+
return {
|
|
80
|
+
target: void 0,
|
|
81
|
+
rest: n,
|
|
82
|
+
error: `--url: not a valid URL: "${r}"`
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
let o = i ?? t.VOLTRO_INSPECT_TOKEN;
|
|
86
|
+
return {
|
|
87
|
+
target: {
|
|
88
|
+
url: r.replace(/\/+$/, ""),
|
|
89
|
+
name: a.host,
|
|
90
|
+
...o !== void 0 && o !== "" ? { token: o } : {}
|
|
91
|
+
},
|
|
92
|
+
rest: n
|
|
93
|
+
};
|
|
94
|
+
}, a = (e) => ({
|
|
95
|
+
id: `remote:${e.url}`,
|
|
96
|
+
name: e.name,
|
|
97
|
+
kind: "api",
|
|
98
|
+
url: e.url,
|
|
99
|
+
pid: 0,
|
|
100
|
+
registeredAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
101
|
+
heartbeatAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
102
|
+
status: "live",
|
|
103
|
+
logFile: "",
|
|
104
|
+
...e.token === void 0 ? {} : { inspectToken: e.token }
|
|
105
|
+
}), o = async (t, n) => n === void 0 ? (await e()).apps.filter((e) => e.kind === "api" && e.status === "live" && e.url.length > 0 && (t === void 0 || e.name === t)) : [a(n)], s = (e) => {
|
|
106
|
+
let t = "pretty", n = [];
|
|
107
|
+
for (let r = 0; r < e.length; r++) {
|
|
108
|
+
let i = e[r];
|
|
109
|
+
if (i === "--format") {
|
|
110
|
+
let n = e[++r];
|
|
111
|
+
if (n !== "pretty" && n !== "json") return { error: "--format: must be 'pretty' | 'json'" };
|
|
112
|
+
t = n;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (i === "--json" || i === "--format=json") {
|
|
116
|
+
t = "json";
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (i === "--format=pretty") {
|
|
120
|
+
t = "pretty";
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
n.push(i);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
format: t,
|
|
127
|
+
rest: n
|
|
128
|
+
};
|
|
129
|
+
}, c = (e, t = process.env) => {
|
|
130
|
+
let { target: n, rest: r, error: a } = i(e, t), o, s = [];
|
|
131
|
+
for (let e = 0; e < r.length; e++) {
|
|
132
|
+
let t = r[e];
|
|
133
|
+
if (t === "--process") {
|
|
134
|
+
o = r[++e];
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (t.startsWith("--process=")) {
|
|
138
|
+
o = t.slice(10);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
s.push(t);
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
process: o,
|
|
145
|
+
target: n,
|
|
146
|
+
rest: s,
|
|
147
|
+
...a === void 0 ? {} : { error: a }
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
//#endregion
|
|
151
|
+
export { a, i, s as n, o, c as r, r as t };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { recordSample as e } from "@voltro/runtime";
|
|
2
|
+
//#region src/inspectMetrics.ts
|
|
3
|
+
var t = 5e3, n = 6e4, r = (e, t) => {
|
|
4
|
+
if (e.length === 0) return 0;
|
|
5
|
+
if (e.length === 1) return e[0];
|
|
6
|
+
let n = t * (e.length - 1), r = Math.floor(n), i = Math.ceil(n);
|
|
7
|
+
if (r === i) return e[r];
|
|
8
|
+
let a = n - r;
|
|
9
|
+
return e[r] * (1 - a) + e[i] * a;
|
|
10
|
+
}, i = (e) => {
|
|
11
|
+
if (e.length === 0) return {
|
|
12
|
+
p50: 0,
|
|
13
|
+
p95: 0,
|
|
14
|
+
p99: 0,
|
|
15
|
+
mean: 0,
|
|
16
|
+
min: 0,
|
|
17
|
+
max: 0
|
|
18
|
+
};
|
|
19
|
+
let t = e.slice().sort((e, t) => e - t), n = 0;
|
|
20
|
+
for (let e of t) n += e;
|
|
21
|
+
return {
|
|
22
|
+
p50: r(t, .5),
|
|
23
|
+
p95: r(t, .95),
|
|
24
|
+
p99: r(t, .99),
|
|
25
|
+
mean: n / t.length,
|
|
26
|
+
min: t[0],
|
|
27
|
+
max: t[t.length - 1]
|
|
28
|
+
};
|
|
29
|
+
}, a = (r = {}) => {
|
|
30
|
+
let a = r.maxSamples ?? t, o = r.defaultWindowMs ?? n, s = [];
|
|
31
|
+
return {
|
|
32
|
+
record(t) {
|
|
33
|
+
e(t), s.push({
|
|
34
|
+
...t,
|
|
35
|
+
ts: Date.now()
|
|
36
|
+
}), s.length > a && s.shift();
|
|
37
|
+
},
|
|
38
|
+
snapshot(e) {
|
|
39
|
+
let t = e ?? o, n = Date.now(), r = n - t, a = /* @__PURE__ */ new Map(), c = 0;
|
|
40
|
+
for (let e of s) {
|
|
41
|
+
if (e.ts < r) continue;
|
|
42
|
+
c++;
|
|
43
|
+
let t = `${e.kind}\u0000${e.tag}`, n = a.get(t);
|
|
44
|
+
n || (n = {
|
|
45
|
+
kind: e.kind,
|
|
46
|
+
tag: e.tag,
|
|
47
|
+
samples: []
|
|
48
|
+
}, a.set(t, n)), n.samples.push(e);
|
|
49
|
+
}
|
|
50
|
+
let l = [];
|
|
51
|
+
for (let e of a.values()) {
|
|
52
|
+
let t = e.samples.map((e) => e.durationMs), n = 0;
|
|
53
|
+
for (let t of e.samples) t.status === "error" && n++;
|
|
54
|
+
l.push({
|
|
55
|
+
kind: e.kind,
|
|
56
|
+
tag: e.tag,
|
|
57
|
+
count: e.samples.length,
|
|
58
|
+
errorCount: n,
|
|
59
|
+
latencyMs: i(t)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return l.sort((e, t) => t.count - e.count), {
|
|
63
|
+
windowMs: t,
|
|
64
|
+
capturedAt: n,
|
|
65
|
+
totalSamples: c,
|
|
66
|
+
buckets: l
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { a as t };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { dirname as e, isAbsolute as t, resolve as n } from "node:path";
|
|
2
|
+
import { existsSync as r, readFileSync as i, statSync as a } from "node:fs";
|
|
3
|
+
import { createLogger as o } from "@voltro/logger";
|
|
4
|
+
//#region src/loadEnv.ts
|
|
5
|
+
var s = o({ scope: "voltro:cli" }), c = (e, t) => {
|
|
6
|
+
if (t?.code !== "EACCES") return "";
|
|
7
|
+
if (typeof process.getuid != "function") return " — permission denied";
|
|
8
|
+
try {
|
|
9
|
+
let t = a(e);
|
|
10
|
+
return ` — permission denied: the file is owned by uid ${t.uid} (mode ${(t.mode & 511).toString(8)}) and this process is uid ${process.getuid()}. A container running as root with the workspace bind-mounted writes files the host user cannot read; run it as \`--user <your-uid>:<your-gid>\`, or delete the file and let the owning user recreate it.`;
|
|
11
|
+
} catch {
|
|
12
|
+
return " — permission denied (and the file could not be stat-ed either)";
|
|
13
|
+
}
|
|
14
|
+
}, l = [], u = (a) => {
|
|
15
|
+
l.length = 0;
|
|
16
|
+
let o = a[1] && !a[1].startsWith("-") ? a[1] : void 0, u = o ? t(o) ? o : n(process.cwd(), o) : process.cwd(), d = [], f = u;
|
|
17
|
+
for (;;) {
|
|
18
|
+
d.push(f);
|
|
19
|
+
let t = e(f);
|
|
20
|
+
if (t === f) break;
|
|
21
|
+
f = t;
|
|
22
|
+
}
|
|
23
|
+
for (let e of d) for (let t of [".env.local", ".env"]) {
|
|
24
|
+
let a = n(e, t);
|
|
25
|
+
if (r(a)) {
|
|
26
|
+
l.push(a);
|
|
27
|
+
try {
|
|
28
|
+
let e = i(a, "utf8");
|
|
29
|
+
for (let t of e.split(/\r?\n/)) {
|
|
30
|
+
let e = t.trim();
|
|
31
|
+
if (e === "" || e.startsWith("#")) continue;
|
|
32
|
+
let n = e.indexOf("=");
|
|
33
|
+
if (n < 1) continue;
|
|
34
|
+
let r = e.slice(0, n).trim(), i = e.slice(n + 1).trim();
|
|
35
|
+
(i.startsWith("\"") && i.endsWith("\"") || i.startsWith("'") && i.endsWith("'")) && (i = i.slice(1, -1)), process.env[r] === void 0 && (process.env[r] = i);
|
|
36
|
+
}
|
|
37
|
+
} catch (e) {
|
|
38
|
+
s.warn(`failed to load env file (continuing)${c(a, e)}`, { path: a }, e);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { l as n, u as t };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { join as e } from "node:path";
|
|
2
|
+
import { closeSync as t, mkdirSync as n, openSync as r, promises as i, readdirSync as a, statSync as o, unlinkSync as s, writeSync as c } from "node:fs";
|
|
3
|
+
import { addSink as l } from "@voltro/logger";
|
|
4
|
+
import { homedir as u } from "node:os";
|
|
5
|
+
//#region src/logFileSink.ts
|
|
6
|
+
var d = e(u(), ".voltro", "logs"), f = () => {
|
|
7
|
+
let e = Number(process.env.VOLTRO_LOG_FILE_TTL_MS);
|
|
8
|
+
return Number.isFinite(e) && e > 0 ? e : 3600 * 1e3;
|
|
9
|
+
}, p = !1, m = () => {
|
|
10
|
+
if (p) return;
|
|
11
|
+
p = !0;
|
|
12
|
+
let t = Date.now() - f(), n = [];
|
|
13
|
+
try {
|
|
14
|
+
n = a(d);
|
|
15
|
+
} catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
for (let r of n) {
|
|
19
|
+
if (!r.endsWith(".log")) continue;
|
|
20
|
+
let n = e(d, r);
|
|
21
|
+
try {
|
|
22
|
+
o(n).mtimeMs < t && s(n);
|
|
23
|
+
} catch {}
|
|
24
|
+
}
|
|
25
|
+
}, h = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80), g = (t, n) => e(d, `${h(t)}-${n}.log`), _ = (t) => {
|
|
26
|
+
let n = h(t), r = [];
|
|
27
|
+
try {
|
|
28
|
+
r = a(d);
|
|
29
|
+
} catch {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let i = r.filter((e) => e.startsWith(`${n}-`) && e.endsWith(".log"));
|
|
33
|
+
if (i.length === 0) return;
|
|
34
|
+
let s, c = -1;
|
|
35
|
+
for (let t of i) {
|
|
36
|
+
let n = e(d, t);
|
|
37
|
+
try {
|
|
38
|
+
let e = o(n);
|
|
39
|
+
e.mtimeMs > c && (c = e.mtimeMs, s = n);
|
|
40
|
+
} catch {}
|
|
41
|
+
}
|
|
42
|
+
return s;
|
|
43
|
+
}, v = (e) => {
|
|
44
|
+
try {
|
|
45
|
+
n(d, { recursive: !0 });
|
|
46
|
+
} catch {}
|
|
47
|
+
m();
|
|
48
|
+
let i = g(e, process.pid), a = r(i, "w"), o = (e) => {
|
|
49
|
+
let t = {
|
|
50
|
+
ts: e.ts.getTime(),
|
|
51
|
+
level: e.level,
|
|
52
|
+
source: e.scope === "client" ? "client" : "server",
|
|
53
|
+
message: e.message,
|
|
54
|
+
fields: e.fields
|
|
55
|
+
};
|
|
56
|
+
e.scope !== void 0 && (t.scope = e.scope);
|
|
57
|
+
try {
|
|
58
|
+
return JSON.stringify(t) + "\n";
|
|
59
|
+
} catch {
|
|
60
|
+
return JSON.stringify({
|
|
61
|
+
ts: e.ts.getTime(),
|
|
62
|
+
level: e.level,
|
|
63
|
+
source: t.source,
|
|
64
|
+
message: e.message,
|
|
65
|
+
fields: {},
|
|
66
|
+
...e.scope === void 0 ? {} : { scope: e.scope }
|
|
67
|
+
}) + "\n";
|
|
68
|
+
}
|
|
69
|
+
}, s = !1, u = l((e) => {
|
|
70
|
+
if (!s) try {
|
|
71
|
+
c(a, o(e));
|
|
72
|
+
} catch {}
|
|
73
|
+
}), f = () => {
|
|
74
|
+
if (!s) {
|
|
75
|
+
s = !0;
|
|
76
|
+
try {
|
|
77
|
+
t(a);
|
|
78
|
+
} catch {}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
process.once("exit", f);
|
|
82
|
+
let p = () => f();
|
|
83
|
+
return process.on("uncaughtException", p), process.on("unhandledRejection", p), {
|
|
84
|
+
path: i,
|
|
85
|
+
dispose: async () => {
|
|
86
|
+
u(), f(), process.off("exit", f), process.off("uncaughtException", p), process.off("unhandledRejection", p);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}, y = async (e, t) => {
|
|
90
|
+
let n;
|
|
91
|
+
try {
|
|
92
|
+
n = await i.readFile(e, "utf8");
|
|
93
|
+
} catch {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
let r = n.split("\n"), a = [], o = t?.since ?? 0;
|
|
97
|
+
for (let e of r) if (e.length !== 0) try {
|
|
98
|
+
let t = JSON.parse(e);
|
|
99
|
+
if (typeof t.ts != "number" || t.ts < o) continue;
|
|
100
|
+
a.push(t);
|
|
101
|
+
} catch {}
|
|
102
|
+
return t?.max !== void 0 && a.length > t.max ? a.slice(a.length - t.max) : a;
|
|
103
|
+
};
|
|
104
|
+
//#endregion
|
|
105
|
+
export { v as n, y as r, _ as t };
|