@quatronic/sdk 0.7.1-rc.8 → 0.7.1-test.9412cbd

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.
Files changed (84) hide show
  1. package/dist/chunk-5RAO3LPF.js +116 -0
  2. package/dist/chunk-5RAO3LPF.js.map +1 -0
  3. package/dist/{chunk-2AYDFLKR.js → chunk-NMJOF3ZM.js} +6 -104
  4. package/dist/chunk-NMJOF3ZM.js.map +1 -0
  5. package/dist/chunk-P7HNHLW7.js +65 -0
  6. package/dist/chunk-P7HNHLW7.js.map +1 -0
  7. package/dist/chunk-QMOZDE3U.js +158 -0
  8. package/dist/chunk-QMOZDE3U.js.map +1 -0
  9. package/dist/chunk-WU7N4PET.js +20 -0
  10. package/dist/chunk-WU7N4PET.js.map +1 -0
  11. package/dist/cli/legacy/qdc-sourcemaps.js +16 -6
  12. package/dist/cli/skills-postinstall.js +4 -3
  13. package/dist/cli/skills.js +4 -3
  14. package/dist/cli/sourcemaps.js +16 -6
  15. package/dist/integrations/index.d.ts +3 -75
  16. package/dist/integrations/index.js +6 -4
  17. package/dist/mail/index.d.ts +9 -0
  18. package/dist/mail/index.js +26 -0
  19. package/dist/mail/index.js.map +1 -0
  20. package/dist/next/auth/index.js +3 -152
  21. package/dist/next/auth/index.js.map +1 -1
  22. package/dist/next/boot/index.d.ts +33 -0
  23. package/dist/next/boot/index.js +21 -0
  24. package/dist/next/boot/index.js.map +1 -0
  25. package/dist/next/db/index.d.ts +18 -1
  26. package/dist/next/db/index.js +25 -0
  27. package/dist/next/db/index.js.map +1 -1
  28. package/dist/next/global-error/index.d.ts +9 -0
  29. package/dist/next/global-error/index.js +17 -0
  30. package/dist/next/global-error/index.js.map +1 -0
  31. package/dist/next/integrations/index.d.ts +2 -1
  32. package/dist/next/integrations/index.js +6 -4
  33. package/dist/next/platform/index.d.ts +19 -0
  34. package/dist/next/platform/index.js +44 -0
  35. package/dist/next/platform/index.js.map +1 -0
  36. package/dist/next/security/index.d.ts +23 -1
  37. package/dist/next/security/index.js +39 -56
  38. package/dist/next/security/index.js.map +1 -1
  39. package/dist/next/security/testing.js +10 -1
  40. package/dist/next/security/testing.js.map +1 -1
  41. package/dist/next/sentry/register.js +5 -13
  42. package/dist/next/sentry/register.js.map +1 -1
  43. package/dist/node/boot/index.d.ts +9 -0
  44. package/dist/node/boot/index.js +13 -0
  45. package/dist/node/boot/index.js.map +1 -0
  46. package/dist/node/integrations/index.d.ts +2 -1
  47. package/dist/node/integrations/index.js +6 -4
  48. package/dist/node-HH3ZZD2R.js +46 -0
  49. package/dist/node-HH3ZZD2R.js.map +1 -0
  50. package/dist/types-Cl7g4ego.d.ts +80 -0
  51. package/migrations/bootstrap-qore-env/codemod.mjs +77 -0
  52. package/migrations/bootstrap-qore-env/instructions.md +28 -0
  53. package/migrations/bootstrap-qore-env/meta.json +7 -0
  54. package/migrations/global-error/codemod.mjs +28 -0
  55. package/migrations/global-error/instructions.md +26 -0
  56. package/migrations/global-error/meta.json +7 -0
  57. package/migrations/local-db-port/codemod.mjs +61 -0
  58. package/migrations/local-db-port/instructions.md +45 -0
  59. package/migrations/local-db-port/meta.json +7 -0
  60. package/migrations/mail-reexport/codemod.mjs +64 -0
  61. package/migrations/mail-reexport/instructions.md +27 -0
  62. package/migrations/mail-reexport/meta.json +7 -0
  63. package/migrations/no-raw-fetch/meta.json +1 -1
  64. package/migrations/platform-routes/codemod.mjs +45 -0
  65. package/migrations/platform-routes/instructions.md +30 -0
  66. package/migrations/platform-routes/meta.json +7 -0
  67. package/migrations/qore-boot/codemod.mjs +263 -0
  68. package/migrations/qore-boot/instructions.md +74 -0
  69. package/migrations/qore-boot/meta.json +7 -0
  70. package/migrations/qore-proxy/codemod.mjs +88 -0
  71. package/migrations/qore-proxy/instructions.md +56 -0
  72. package/migrations/qore-proxy/meta.json +7 -0
  73. package/migrations/run.mjs +334 -0
  74. package/migrations/sourcemaps-finalize/codemod.mjs +63 -0
  75. package/migrations/sourcemaps-finalize/instructions.md +56 -0
  76. package/migrations/sourcemaps-finalize/meta.json +7 -0
  77. package/package.json +23 -2
  78. package/skills/catalog.json +1 -0
  79. package/skills/qore-add-env-key/SKILL.md +57 -0
  80. package/skills/qore-add-integration/SKILL.next.md +13 -7
  81. package/skills/qore-add-integration/SKILL.node.md +13 -7
  82. package/skills/qore-author-skill/SKILL.md +1 -0
  83. package/workspace-requirements.json +4 -0
  84. package/dist/chunk-2AYDFLKR.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/next/security/testing.ts"],"sourcesContent":["import { ALWAYS_EXCLUDED } from \"../../security-core/proxy\"\nimport type { SecuredProxy } from \"./index\"\n\n/**\n * The security-header contract, as a list of checks an app runs against its own\n * proxy.\n *\n * These are not tests of `@quatronic/sdk` — this package has its own. They are\n * for the generated app, so that removing `withSecurityHeaders` from\n * `src/proxy.ts`, or matching so few routes that it stops running, fails that\n * app's build rather than being noticed in a penetration test.\n *\n * It returns checks rather than declaring them, so this module needs no test\n * runner of its own and works under whichever one the app uses:\n *\n * import { describe, it } from \"vitest\"\n * import { securityHeaderChecks } from \"@quatronic/sdk/next/security/testing\"\n * import { config, proxy } from \"@/proxy\"\n *\n * describe(\"security headers\", () => {\n * for (const check of securityHeaderChecks({ proxy, config })) it(check.name, check.run)\n * })\n *\n * A failing check throws with the header it wanted and the value it got, which\n * every runner reports as the test failure.\n */\n\nexport interface SecurityContractCookie {\n name: string\n value: string\n}\n\nexport interface SecurityContractTarget {\n /** The app's `proxy` export — the value `withSecurityHeaders` returned. */\n proxy: SecuredProxy\n /** The app's `config` export. Its matcher is checked too. */\n config: { matcher: readonly string[] }\n /**\n * Cookies that make a request look signed-in, so an auth module's proxy\n * passes it through instead of redirecting.\n *\n * Defaults to both QDC session cookies at once, which is what lets one\n * shipped test file cover every recipe: an app generated from `next-auth`\n * reads `qdc_session`, one from `next-betterauth` reads\n * `better-auth.session_token`, and a `next-base` app reads neither.\n */\n sessionCookies?: readonly SecurityContractCookie[]\n /** The URL the stub request carries. Must be a route the matcher covers. */\n url?: string\n}\n\nexport interface SecurityCheck {\n name: string\n run: () => Promise<void>\n}\n\nconst DEFAULT_SESSION_COOKIES: SecurityContractCookie[] = [\n { name: \"qdc_session\", value: \"test\" },\n { name: \"better-auth.session_token\", value: \"test\" },\n]\n\nconst DEFAULT_URL = \"https://app.example.test/dashboard\"\n\nfunction nextUrlStub(href: string): URL {\n return Object.assign(new URL(href), { clone: () => nextUrlStub(href) })\n}\n\n/**\n * Enough of a `NextRequest` for a proxy: the URL it can clone and the cookie\n * jar it reads. Casting through `unknown` keeps the stub honest about being one\n * — a partial `NextRequest` is exactly what this is.\n */\nfunction makeRequest(url: string, cookies: readonly SecurityContractCookie[]): NextRequestStub {\n return Object.assign(new Request(url), {\n nextUrl: nextUrlStub(url),\n cookies: {\n has: (name: string) => cookies.some((cookie) => cookie.name === name),\n get: (name: string) => cookies.find((cookie) => cookie.name === name),\n getAll: () => [...cookies],\n },\n }) as unknown as NextRequestStub\n}\n\ntype NextRequestStub = Parameters<SecuredProxy>[0]\n\n/** No runtime reads the fetch event, and jsdom has no `NextFetchEvent`. */\nconst NO_EVENT = {} as unknown as Parameters<SecuredProxy>[1]\n\nfunction cspOf(response: Response): string {\n return (\n response.headers.get(\"content-security-policy\") ??\n response.headers.get(\"content-security-policy-report-only\") ??\n \"\"\n )\n}\n\nfunction nonceOf(csp: string): string | undefined {\n return /'nonce-([^']+)'/.exec(csp)?.[1]\n}\n\nfunction expectHeader(response: Response, name: string, value: string): void {\n const actual = response.headers.get(name)\n if (actual !== value) {\n throw new Error(\n `${name}: expected ${JSON.stringify(value)}, got ${actual === null ? \"no header\" : JSON.stringify(actual)}`,\n )\n }\n}\n\nfunction expectContains(actual: string, needle: string, what: string): void {\n if (!actual.includes(needle)) {\n throw new Error(`${what}: expected it to contain ${JSON.stringify(needle)}, got ${JSON.stringify(actual)}`)\n }\n}\n\nexport function securityHeaderChecks(target: SecurityContractTarget): SecurityCheck[] {\n const url = target.url ?? DEFAULT_URL\n const signedIn = target.sessionCookies ?? DEFAULT_SESSION_COOKIES\n const run = (cookies: readonly SecurityContractCookie[]): Promise<Response> =>\n Promise.resolve(target.proxy(makeRequest(url, cookies), NO_EVENT))\n\n return [\n {\n name: \"sends the static headers on a signed-in request\",\n async run() {\n const response = await run(signedIn)\n expectHeader(response, \"x-content-type-options\", \"nosniff\")\n expectHeader(response, \"x-frame-options\", \"DENY\")\n expectHeader(response, \"referrer-policy\", \"strict-origin-when-cross-origin\")\n expectHeader(response, \"cross-origin-resource-policy\", \"same-origin\")\n expectContains(\n response.headers.get(\"strict-transport-security\") ?? \"\",\n \"max-age=\",\n \"strict-transport-security\",\n )\n expectContains(\n response.headers.get(\"permissions-policy\") ?? \"\",\n \"camera=()\",\n \"permissions-policy\",\n )\n },\n },\n {\n name: \"sends them on a request with no session too\",\n async run() {\n // Whatever this app does with an anonymous request — pass it through or\n // redirect it to a login — the response is still one the browser hardens.\n const response = await run([])\n expectHeader(response, \"x-content-type-options\", \"nosniff\")\n expectContains(cspOf(response), \"default-src 'self'\", \"content-security-policy\")\n },\n },\n {\n name: \"builds a CSP with a fresh nonce per response\",\n async run() {\n const first = cspOf(await run(signedIn))\n const second = cspOf(await run(signedIn))\n\n expectContains(first, \"'strict-dynamic'\", \"content-security-policy\")\n expectContains(first, \"frame-ancestors 'none'\", \"content-security-policy\")\n expectContains(first, \"object-src 'none'\", \"content-security-policy\")\n expectContains(first, \"report-uri /api/csp-report\", \"content-security-policy\")\n\n const nonce = nonceOf(first)\n if (!nonce) throw new Error(`content-security-policy carries no nonce: ${first}`)\n if (nonce === nonceOf(second)) {\n throw new Error(`two responses shared one nonce (${nonce}); a reused nonce protects nothing`)\n }\n },\n },\n {\n name: \"hands the nonce to the renderer on the forwarded request\",\n async run() {\n // A nonce only protects anything if the page carrying it is the page the\n // nonce was minted for. Next reads it off the request's CSP header.\n const response = await run(signedIn)\n const nonce = nonceOf(cspOf(response))\n if (!nonce) throw new Error(\"content-security-policy carries no nonce\")\n\n expectHeader(response, \"x-middleware-request-x-qdc-nonce\", nonce)\n expectContains(\n response.headers.get(\"x-middleware-request-content-security-policy\") ?? \"\",\n `'nonce-${nonce}'`,\n \"the forwarded request's content-security-policy\",\n )\n },\n },\n {\n name: \"matches every route that serves HTML\",\n run() {\n if (target.config.matcher.length === 0) {\n throw new Error(\"config.matcher is empty, so the proxy never runs\")\n }\n // Next extracts `config` statically, so the app writes this as a\n // literal rather than calling `proxyMatcher`. That makes the literal\n // the thing that can drift, and this the check that catches it: the\n // build output and the image optimizer are the only sanctioned holes,\n // and nonce-ing them would be pointless work on every asset request.\n for (const pattern of target.config.matcher) {\n for (const excluded of ALWAYS_EXCLUDED) {\n expectContains(pattern, excluded, \"config.matcher entry\")\n }\n }\n return Promise.resolve()\n },\n },\n ]\n}\n"],"mappings":";;;;;AAwDA,IAAM,0BAAoD;AAAA,EACxD,EAAE,MAAM,eAAe,OAAO,OAAO;AAAA,EACrC,EAAE,MAAM,6BAA6B,OAAO,OAAO;AACrD;AAEA,IAAM,cAAc;AAEpB,SAAS,YAAY,MAAmB;AACtC,SAAO,OAAO,OAAO,IAAI,IAAI,IAAI,GAAG,EAAE,OAAO,MAAM,YAAY,IAAI,EAAE,CAAC;AACxE;AAOA,SAAS,YAAY,KAAa,SAA6D;AAC7F,SAAO,OAAO,OAAO,IAAI,QAAQ,GAAG,GAAG;AAAA,IACrC,SAAS,YAAY,GAAG;AAAA,IACxB,SAAS;AAAA,MACP,KAAK,CAAC,SAAiB,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,IAAI;AAAA,MACpE,KAAK,CAAC,SAAiB,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,IAAI;AAAA,MACpE,QAAQ,MAAM,CAAC,GAAG,OAAO;AAAA,IAC3B;AAAA,EACF,CAAC;AACH;AAKA,IAAM,WAAW,CAAC;AAElB,SAAS,MAAM,UAA4B;AACzC,SACE,SAAS,QAAQ,IAAI,yBAAy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AAe,SAAS,UAAU,sBAAsB;AAAA,UAC1D;AAAA,QACF;AACA,eAAO,QAAQ,QAAQ;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/next/security/testing.ts"],"sourcesContent":["import { ALWAYS_EXCLUDED } from \"../../security-core/proxy\"\nimport { QORE_CSP_REPORT_URI } from \"../../security-core/cspReport\"\nimport type { SecuredProxy } from \"./index\"\n\n/**\n * The security-header contract, as a list of checks an app runs against its own\n * proxy.\n *\n * These are not tests of `@quatronic/sdk` — this package has its own. They are\n * for the generated app, so that removing `withSecurityHeaders` from\n * `src/proxy.ts`, or matching so few routes that it stops running, fails that\n * app's build rather than being noticed in a penetration test.\n *\n * It returns checks rather than declaring them, so this module needs no test\n * runner of its own and works under whichever one the app uses:\n *\n * import { describe, it } from \"vitest\"\n * import { securityHeaderChecks } from \"@quatronic/sdk/next/security/testing\"\n * import { config, proxy } from \"@/proxy\"\n *\n * describe(\"security headers\", () => {\n * for (const check of securityHeaderChecks({ proxy, config })) it(check.name, check.run)\n * })\n *\n * A failing check throws with the header it wanted and the value it got, which\n * every runner reports as the test failure.\n */\n\nexport interface SecurityContractCookie {\n name: string\n value: string\n}\n\nexport interface SecurityContractTarget {\n /** The app's `proxy` export — the value `withSecurityHeaders` returned. */\n proxy: SecuredProxy\n /** The app's `config` export. Its matcher is checked too. */\n config: { matcher: readonly string[] }\n /**\n * Cookies that make a request look signed-in, so an auth module's proxy\n * passes it through instead of redirecting.\n *\n * Defaults to both QDC session cookies at once, which is what lets one\n * shipped test file cover every recipe: an app generated from `next-auth`\n * reads `qdc_session`, one from `next-betterauth` reads\n * `better-auth.session_token`, and a `next-base` app reads neither.\n */\n sessionCookies?: readonly SecurityContractCookie[]\n /** The URL the stub request carries. Must be a route the matcher covers. */\n url?: string\n}\n\nexport interface SecurityCheck {\n name: string\n run: () => Promise<void>\n}\n\nconst DEFAULT_SESSION_COOKIES: SecurityContractCookie[] = [\n { name: \"qdc_session\", value: \"test\" },\n { name: \"better-auth.session_token\", value: \"test\" },\n]\n\nconst DEFAULT_URL = \"https://app.example.test/dashboard\"\n\nfunction nextUrlStub(href: string): URL {\n return Object.assign(new URL(href), { clone: () => nextUrlStub(href) })\n}\n\n/**\n * Enough of a `NextRequest` for a proxy: the URL it can clone and the cookie\n * jar it reads. Casting through `unknown` keeps the stub honest about being one\n * — a partial `NextRequest` is exactly what this is.\n */\nfunction makeRequest(url: string, cookies: readonly SecurityContractCookie[]): NextRequestStub {\n return Object.assign(new Request(url), {\n nextUrl: nextUrlStub(url),\n cookies: {\n has: (name: string) => cookies.some((cookie) => cookie.name === name),\n get: (name: string) => cookies.find((cookie) => cookie.name === name),\n getAll: () => [...cookies],\n },\n }) as unknown as NextRequestStub\n}\n\ntype NextRequestStub = Parameters<SecuredProxy>[0]\n\n/** No runtime reads the fetch event, and jsdom has no `NextFetchEvent`. */\nconst NO_EVENT = {} as unknown as Parameters<SecuredProxy>[1]\n\nfunction cspOf(response: Response): string {\n return (\n response.headers.get(\"content-security-policy\") ??\n response.headers.get(\"content-security-policy-report-only\") ??\n \"\"\n )\n}\n\nfunction nonceOf(csp: string): string | undefined {\n return /'nonce-([^']+)'/.exec(csp)?.[1]\n}\n\nfunction expectHeader(response: Response, name: string, value: string): void {\n const actual = response.headers.get(name)\n if (actual !== value) {\n throw new Error(\n `${name}: expected ${JSON.stringify(value)}, got ${actual === null ? \"no header\" : JSON.stringify(actual)}`,\n )\n }\n}\n\nconst REPORT_URIS = [\"/api/csp-report\", QORE_CSP_REPORT_URI]\n\nfunction expectContains(actual: string, needle: string, what: string): void {\n if (!actual.includes(needle)) {\n throw new Error(`${what}: expected it to contain ${JSON.stringify(needle)}, got ${JSON.stringify(actual)}`)\n }\n}\n\nexport function securityHeaderChecks(target: SecurityContractTarget): SecurityCheck[] {\n const url = target.url ?? DEFAULT_URL\n const signedIn = target.sessionCookies ?? DEFAULT_SESSION_COOKIES\n const run = (cookies: readonly SecurityContractCookie[]): Promise<Response> =>\n Promise.resolve(target.proxy(makeRequest(url, cookies), NO_EVENT))\n\n return [\n {\n name: \"sends the static headers on a signed-in request\",\n async run() {\n const response = await run(signedIn)\n expectHeader(response, \"x-content-type-options\", \"nosniff\")\n expectHeader(response, \"x-frame-options\", \"DENY\")\n expectHeader(response, \"referrer-policy\", \"strict-origin-when-cross-origin\")\n expectHeader(response, \"cross-origin-resource-policy\", \"same-origin\")\n expectContains(\n response.headers.get(\"strict-transport-security\") ?? \"\",\n \"max-age=\",\n \"strict-transport-security\",\n )\n expectContains(\n response.headers.get(\"permissions-policy\") ?? \"\",\n \"camera=()\",\n \"permissions-policy\",\n )\n },\n },\n {\n name: \"sends them on a request with no session too\",\n async run() {\n // Whatever this app does with an anonymous request — pass it through or\n // redirect it to a login — the response is still one the browser hardens.\n const response = await run([])\n expectHeader(response, \"x-content-type-options\", \"nosniff\")\n expectContains(cspOf(response), \"default-src 'self'\", \"content-security-policy\")\n },\n },\n {\n name: \"builds a CSP with a fresh nonce per response\",\n async run() {\n const first = cspOf(await run(signedIn))\n const second = cspOf(await run(signedIn))\n\n expectContains(first, \"'strict-dynamic'\", \"content-security-policy\")\n expectContains(first, \"frame-ancestors 'none'\", \"content-security-policy\")\n expectContains(first, \"object-src 'none'\", \"content-security-policy\")\n // `withSecurityHeaders` reports to the app's own route, `qoreProxy` to the\n // platform's; either one collects the evidence.\n if (!REPORT_URIS.some((uri) => first.includes(`report-uri ${uri}`))) {\n throw new Error(\n `content-security-policy: expected a report-uri of ${REPORT_URIS.join(\" or \")}, got ${JSON.stringify(first)}`,\n )\n }\n\n const nonce = nonceOf(first)\n if (!nonce) throw new Error(`content-security-policy carries no nonce: ${first}`)\n if (nonce === nonceOf(second)) {\n throw new Error(`two responses shared one nonce (${nonce}); a reused nonce protects nothing`)\n }\n },\n },\n {\n name: \"hands the nonce to the renderer on the forwarded request\",\n async run() {\n // A nonce only protects anything if the page carrying it is the page the\n // nonce was minted for. Next reads it off the request's CSP header.\n const response = await run(signedIn)\n const nonce = nonceOf(cspOf(response))\n if (!nonce) throw new Error(\"content-security-policy carries no nonce\")\n\n expectHeader(response, \"x-middleware-request-x-qdc-nonce\", nonce)\n expectContains(\n response.headers.get(\"x-middleware-request-content-security-policy\") ?? \"\",\n `'nonce-${nonce}'`,\n \"the forwarded request's content-security-policy\",\n )\n },\n },\n {\n name: \"matches every route that serves HTML\",\n run() {\n if (target.config.matcher.length === 0) {\n throw new Error(\"config.matcher is empty, so the proxy never runs\")\n }\n // Next extracts `config` statically, so the app writes this as a\n // literal rather than calling `proxyMatcher`. That makes the literal\n // the thing that can drift, and this the check that catches it: the\n // build output and the image optimizer are the only sanctioned holes,\n // and nonce-ing them would be pointless work on every asset request.\n for (const pattern of target.config.matcher) {\n for (const excluded of ALWAYS_EXCLUDED) {\n expectContains(pattern, excluded, \"config.matcher entry\")\n }\n }\n return Promise.resolve()\n },\n },\n ]\n}\n"],"mappings":";;;;;;;;;AAyDA,IAAM,0BAAoD;AAAA,EACxD,EAAE,MAAM,eAAe,OAAO,OAAO;AAAA,EACrC,EAAE,MAAM,6BAA6B,OAAO,OAAO;AACrD;AAEA,IAAM,cAAc;AAEpB,SAAS,YAAY,MAAmB;AACtC,SAAO,OAAO,OAAO,IAAI,IAAI,IAAI,GAAG,EAAE,OAAO,MAAM,YAAY,IAAI,EAAE,CAAC;AACxE;AAOA,SAAS,YAAY,KAAa,SAA6D;AAC7F,SAAO,OAAO,OAAO,IAAI,QAAQ,GAAG,GAAG;AAAA,IACrC,SAAS,YAAY,GAAG;AAAA,IACxB,SAAS;AAAA,MACP,KAAK,CAAC,SAAiB,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,IAAI;AAAA,MACpE,KAAK,CAAC,SAAiB,QAAQ,KAAK,CAAC,WAAW,OAAO,SAAS,IAAI;AAAA,MACpE,QAAQ,MAAM,CAAC,GAAG,OAAO;AAAA,IAC3B;AAAA,EACF,CAAC;AACH;AAKA,IAAM,WAAW,CAAC;AAEl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E,UAAU,KAAK;AAAA,UACf;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,MAAM;AACJ,YAAI,OAAO,OAAO,QAAQ,WAAW,GAAG;AACtC,gBAAM,IAAI,MAAM,kDAAkD;AAAA,QACpE;AAMA,mBAAW,WAAW,OAAO,OAAO,SAAS;AAC3C,qBAAW,YAAY,iBAAiB;AACtC,2BAAe,SAAS,UAAU,sBAAsB;AAAA,UAC1D;AAAA,QACF;AACA,eAAO,QAAQ,QAAQ;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,18 +1,10 @@
1
1
  import {
2
- initSentry
3
- } from "../../chunk-G7VPNC6M.js";
2
+ onRequestError,
3
+ register
4
+ } from "../../chunk-WU7N4PET.js";
5
+ import "../../chunk-G7VPNC6M.js";
4
6
  import "../../chunk-MET4SIMB.js";
5
- import {
6
- readSentryConfig
7
- } from "../../chunk-7ASQHY7O.js";
8
-
9
- // src/next/sentry/register.ts
10
- import * as Sentry from "@sentry/nextjs";
11
- async function register() {
12
- const runtime = process.env.NEXT_RUNTIME === "edge" ? "edge" : "node";
13
- initSentry(Sentry, runtime, readSentryConfig(process.env, { frontend: true }));
14
- }
15
- var onRequestError = Sentry.captureRequestError;
7
+ import "../../chunk-7ASQHY7O.js";
16
8
  export {
17
9
  onRequestError,
18
10
  register
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/next/sentry/register.ts"],"sourcesContent":["import * as Sentry from \"@sentry/nextjs\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { initSentry } from \"../../sentry-core/init\"\n\nexport async function register(): Promise<void> {\n const runtime = process.env.NEXT_RUNTIME === \"edge\" ? \"edge\" : \"node\"\n initSentry(Sentry, runtime, readSentryConfig(process.env, { frontend: true }))\n}\n\nexport const onRequestError = Sentry.captureRequestError\n"],"mappings":";;;;;;;;;AAAA,YAAY,YAAY;AAIxB,eAAsB,WAA0B;AAC9C,QAAM,UAAU,QAAQ,IAAI,iBAAiB,SAAS,SAAS;AAC/D,aAAW,QAAQ,SAAS,iBAAiB,QAAQ,KAAK,EAAE,UAAU,KAAK,CAAC,CAAC;AAC/E;AAEO,IAAM,iBAAwB;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,9 @@
1
+ import { I as IntegrationMap } from '../../types-Cl7g4ego.js';
2
+
3
+ interface QoreBootOptions {
4
+ /** The backend's `integrations` from `./config/integrations.js`. */
5
+ integrations?: IntegrationMap;
6
+ }
7
+ declare function qoreBoot(options?: QoreBootOptions): void;
8
+
9
+ export { type QoreBootOptions, qoreBoot };
@@ -0,0 +1,13 @@
1
+ import {
2
+ assertIntegrations
3
+ } from "../../chunk-5RAO3LPF.js";
4
+ import "../../chunk-5XMTUPIY.js";
5
+
6
+ // src/node/boot/index.ts
7
+ function qoreBoot(options = {}) {
8
+ if (options.integrations) assertIntegrations(options.integrations);
9
+ }
10
+ export {
11
+ qoreBoot
12
+ };
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/node/boot/index.ts"],"sourcesContent":["// The platform's boot steps for a Node backend, called once at the top of\n// `src/index.ts`. Sentry itself starts earlier, through\n// `node --import @quatronic/sdk/node/sentry/register`; everything after that\n// lives here, so a new boot step reaches every backend as an SDK release.\nimport { assertIntegrations } from \"../../integrations-core/assertIntegrations\"\nimport type { IntegrationMap } from \"../../integrations-core/types\"\n\nexport interface QoreBootOptions {\n /** The backend's `integrations` from `./config/integrations.js`. */\n integrations?: IntegrationMap\n}\n\nexport function qoreBoot(options: QoreBootOptions = {}): void {\n // Visibility, never a gate: one warning per required integration key that is\n // unset. The service starts regardless; only calls to that integration fail.\n if (options.integrations) assertIntegrations(options.integrations)\n}\n"],"mappings":";;;;;;AAYO,SAAS,SAAS,UAA2B,CAAC,GAAS;AAG5D,MAAI,QAAQ,aAAc,oBAAmB,QAAQ,YAAY;AACnE;","names":[]}
@@ -1,2 +1,3 @@
1
- export { AUTH_ENV_FIELDS, AUTH_SECRET_FIELDS, AuthKind, DEFAULT_INTEGRATION_TIMEOUT_MS, EnvKey, EnvRef, INTEGRATION_ALIAS_ATTR, INTEGRATION_SPAN_TYPE, INTEGRATION_SPAN_TYPE_ATTR, IntegrationAuth, IntegrationClient, IntegrationConfig, IntegrationDefinition, IntegrationError, IntegrationErrorCode, IntegrationHandle, IntegrationMap, IntegrationProblem, IntegrationRequest, OAUTH_REFRESH_SKEW_MS, PLATFORM_MANAGED_HOSTS, ParamValue, Protocol, RESERVED_KEY_PREFIX, allKeys, assertIntegrations, createIntegrationClient, defineIntegrations, isPlatformManagedHost, loggingEnabled, loggingKey, readRef, requiredKeys } from '../../integrations/index.js';
1
+ export { A as AUTH_ENV_FIELDS, b as AUTH_SECRET_FIELDS, c as AuthKind, d as EnvKey, E as EnvRef, e as IntegrationAuth, a as IntegrationDefinition, I as IntegrationMap, P as Protocol, R as RESERVED_KEY_PREFIX, f as defineIntegrations } from '../../types-Cl7g4ego.js';
2
+ export { DEFAULT_INTEGRATION_TIMEOUT_MS, INTEGRATION_ALIAS_ATTR, INTEGRATION_SPAN_TYPE, INTEGRATION_SPAN_TYPE_ATTR, IntegrationClient, IntegrationConfig, IntegrationError, IntegrationErrorCode, IntegrationHandle, IntegrationProblem, IntegrationRequest, OAUTH_REFRESH_SKEW_MS, PLATFORM_MANAGED_HOSTS, ParamValue, allKeys, assertIntegrations, createIntegrationClient, isPlatformManagedHost, loggingEnabled, loggingKey, readRef, requiredKeys } from '../../integrations/index.js';
2
3
  import '../../env-R-bci5RU.js';
@@ -1,22 +1,24 @@
1
1
  import {
2
- AUTH_ENV_FIELDS,
3
- AUTH_SECRET_FIELDS,
4
2
  DEFAULT_INTEGRATION_TIMEOUT_MS,
5
3
  INTEGRATION_ALIAS_ATTR,
6
4
  INTEGRATION_SPAN_TYPE,
7
5
  INTEGRATION_SPAN_TYPE_ATTR,
8
6
  IntegrationError,
9
7
  OAUTH_REFRESH_SKEW_MS,
8
+ createIntegrationClient
9
+ } from "../../chunk-NMJOF3ZM.js";
10
+ import {
11
+ AUTH_ENV_FIELDS,
12
+ AUTH_SECRET_FIELDS,
10
13
  RESERVED_KEY_PREFIX,
11
14
  allKeys,
12
15
  assertIntegrations,
13
- createIntegrationClient,
14
16
  defineIntegrations,
15
17
  loggingEnabled,
16
18
  loggingKey,
17
19
  readRef,
18
20
  requiredKeys
19
- } from "../../chunk-2AYDFLKR.js";
21
+ } from "../../chunk-5RAO3LPF.js";
20
22
  import {
21
23
  PLATFORM_MANAGED_HOSTS,
22
24
  isPlatformManagedHost
@@ -0,0 +1,46 @@
1
+ import {
2
+ assertIntegrations
3
+ } from "./chunk-5RAO3LPF.js";
4
+ import "./chunk-5XMTUPIY.js";
5
+ import {
6
+ runAuthMigrations
7
+ } from "./chunk-QMOZDE3U.js";
8
+ import {
9
+ createMigrationDb,
10
+ parseRoleFromUrl
11
+ } from "./chunk-BJN7YE63.js";
12
+ import "./chunk-4MBB2UQW.js";
13
+
14
+ // src/next/boot/node.ts
15
+ import * as Sentry from "@sentry/nextjs";
16
+ function required(key) {
17
+ const value = process.env[key];
18
+ if (!value) throw new Error(`qoreRegister: ${key} is required`);
19
+ return value;
20
+ }
21
+ async function bootNode(boot) {
22
+ if (boot.integrations) {
23
+ assertIntegrations((await boot.integrations()).integrations);
24
+ }
25
+ if (boot.env) (await boot.env()).serverEnv();
26
+ if (boot.authMigrations) {
27
+ const { db, close } = createMigrationDb(required("MIGRATION_DATABASE_URL"));
28
+ try {
29
+ await runAuthMigrations(db, { runtimeRole: parseRoleFromUrl(required("DATABASE_URL")) });
30
+ } finally {
31
+ await close();
32
+ }
33
+ }
34
+ if (boot.migrations) await (await boot.migrations()).runAppMigrations();
35
+ if (boot.seed && process.env.QORE_RUN_SEED === "true") {
36
+ try {
37
+ await (await boot.seed()).default();
38
+ } catch (err) {
39
+ Sentry.captureException(err, { tags: { "qore.seed.phase": "boot" } });
40
+ }
41
+ }
42
+ }
43
+ export {
44
+ bootNode
45
+ };
46
+ //# sourceMappingURL=node-HH3ZZD2R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/next/boot/node.ts"],"sourcesContent":["// The Node-runtime half of qoreRegister. Loaded only behind the NEXT_RUNTIME\n// check in ./index.ts, so pg, drizzle and the auth migrations never reach the\n// edge bundle.\nimport * as Sentry from \"@sentry/nextjs\"\nimport { runAuthMigrations } from \"../../auth-core/migrate\"\nimport { createMigrationDb, parseRoleFromUrl } from \"../../db-core/migration-db\"\nimport { assertIntegrations } from \"../../integrations-core/assertIntegrations\"\nimport type { NodeBoot } from \"./types\"\n\nfunction required(key: string): string {\n const value = process.env[key]\n if (!value) throw new Error(`qoreRegister: ${key} is required`)\n return value\n}\n\nexport async function bootNode(boot: NodeBoot): Promise<void> {\n if (boot.integrations) {\n // Visibility, never a gate: one warning per required integration key that\n // is unset. The app boots regardless; only calls to that integration fail.\n assertIntegrations((await boot.integrations()).integrations)\n }\n\n // Validating the app's env first turns a missing key into the app's own\n // \"copy values from the portal\" message instead of a database error.\n if (boot.env) (await boot.env()).serverEnv()\n\n if (boot.authMigrations) {\n const { db, close } = createMigrationDb(required(\"MIGRATION_DATABASE_URL\"))\n try {\n await runAuthMigrations(db, { runtimeRole: parseRoleFromUrl(required(\"DATABASE_URL\")) })\n } finally {\n await close()\n }\n }\n\n if (boot.migrations) await (await boot.migrations()).runAppMigrations()\n\n // The preview seed must never keep the app from booting: a failure is reported, not thrown.\n if (boot.seed && process.env.QORE_RUN_SEED === \"true\") {\n try {\n await (await boot.seed()).default()\n } catch (err) {\n Sentry.captureException(err, { tags: { \"qore.seed.phase\": \"boot\" } })\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAGA,YAAY,YAAY;AAMxB,SAAS,SAAS,KAAqB;AACrC,QAAM,QAAQ,QAAQ,IAAI,GAAG;AAC7B,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,iBAAiB,GAAG,cAAc;AAC9D,SAAO;AACT;AAEA,eAAsB,SAAS,MAA+B;AAC5D,MAAI,KAAK,cAAc;AAGrB,wBAAoB,MAAM,KAAK,aAAa,GAAG,YAAY;AAAA,EAC7D;AAIA,MAAI,KAAK,IAAK,EAAC,MAAM,KAAK,IAAI,GAAG,UAAU;AAE3C,MAAI,KAAK,gBAAgB;AACvB,UAAM,EAAE,IAAI,MAAM,IAAI,kBAAkB,SAAS,wBAAwB,CAAC;AAC1E,QAAI;AACF,YAAM,kBAAkB,IAAI,EAAE,aAAa,iBAAiB,SAAS,cAAc,CAAC,EAAE,CAAC;AAAA,IACzF,UAAE;AACA,YAAM,MAAM;AAAA,IACd;AAAA,EACF;AAEA,MAAI,KAAK,WAAY,QAAO,MAAM,KAAK,WAAW,GAAG,iBAAiB;AAGtE,MAAI,KAAK,QAAQ,QAAQ,IAAI,kBAAkB,QAAQ;AACrD,QAAI;AACF,aAAO,MAAM,KAAK,KAAK,GAAG,QAAQ;AAAA,IACpC,SAAS,KAAK;AACZ,MAAO,wBAAiB,KAAK,EAAE,MAAM,EAAE,mBAAmB,OAAO,EAAE,CAAC;AAAA,IACtE;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * How an integration authenticates. Every field except `header` and
3
+ * `credentialsIn` names an **env key** — the SDK reads the value from the
4
+ * environment at call time, never from the declaration — so a declaration can
5
+ * sit in source control and carry no secret.
6
+ */
7
+ type AuthKind = "none" | "api_key_header" | "bearer_static" | "basic" | "oauth2_client_credentials";
8
+ /** What the API speaks. Informational for the portal; the client sends bytes either way. */
9
+ type Protocol = "rest" | "odata" | "soap" | "graphql";
10
+ /** The name of an env var, e.g. `SAP_BASE_URL`. */
11
+ type EnvKey = string;
12
+ /**
13
+ * A reference to an env var. The short form is required; the object form can
14
+ * be optional and carry a default the app falls back on when the key is unset.
15
+ */
16
+ type EnvRef = EnvKey | {
17
+ key: EnvKey;
18
+ optional?: boolean;
19
+ default?: string | number | boolean;
20
+ };
21
+ type IntegrationAuth = {
22
+ kind: "none";
23
+ } | {
24
+ kind: "api_key_header";
25
+ header: string;
26
+ apiKey: EnvKey;
27
+ } | {
28
+ kind: "bearer_static";
29
+ token: EnvKey;
30
+ } | {
31
+ kind: "basic";
32
+ username: EnvKey;
33
+ password: EnvKey;
34
+ } | {
35
+ kind: "oauth2_client_credentials";
36
+ tokenUrl: EnvKey;
37
+ clientId: EnvKey;
38
+ clientSecret: EnvKey;
39
+ scope?: EnvKey;
40
+ audience?: EnvKey;
41
+ /** Where the client credentials go on the token request. Default `"header"`. */
42
+ credentialsIn?: "header" | "body";
43
+ };
44
+ interface IntegrationDefinition {
45
+ /** Human name shown in the portal, e.g. "SAP S/4HANA Cloud". */
46
+ label: string;
47
+ protocol: Protocol;
48
+ /** Env key holding the base URL for this environment. */
49
+ baseUrl: EnvKey;
50
+ auth: IntegrationAuth;
51
+ /** Further env the app reads for this integration, by logical name. */
52
+ config?: Record<string, EnvRef>;
53
+ }
54
+ type IntegrationMap = Record<string, IntegrationDefinition>;
55
+ /**
56
+ * Identity function that pins the literal types of the map, so an alias typo
57
+ * at a call site is a compile error (`keyof M`) rather than a runtime
58
+ * `not_declared`. Same shape as `definePermissions` in `auth-core`.
59
+ */
60
+ declare function defineIntegrations<const M extends IntegrationMap>(map: M): M;
61
+ /**
62
+ * Which fields of each auth kind name an env key. Shared with the manifest
63
+ * extractor and the portal, which derive the required-env list from a
64
+ * declaration without evaluating app code.
65
+ */
66
+ declare const AUTH_ENV_FIELDS: Record<AuthKind, readonly string[]>;
67
+ /**
68
+ * Auth fields whose env value is a secret, so the portal locks it whatever
69
+ * `env.ts` labels it. The identifier of a login counts with its secret:
70
+ * `username` sits with `password` and `clientId` with `clientSecret`, because
71
+ * that is where a person looks for them and they are replaced together.
72
+ */
73
+ declare const AUTH_SECRET_FIELDS: readonly ["apiKey", "token", "username", "password", "clientId", "clientSecret"];
74
+ /**
75
+ * Env keys under this prefix belong to the platform
76
+ * (`QORE_INTEGRATION_<ALIAS>_LOGGING` today). A declaration may not claim one.
77
+ */
78
+ declare const RESERVED_KEY_PREFIX = "QORE_INTEGRATION_";
79
+
80
+ export { AUTH_ENV_FIELDS as A, type EnvRef as E, type IntegrationMap as I, type Protocol as P, RESERVED_KEY_PREFIX as R, type IntegrationDefinition as a, AUTH_SECRET_FIELDS as b, type AuthKind as c, type EnvKey as d, type IntegrationAuth as e, defineIntegrations as f };
@@ -0,0 +1,77 @@
1
+ // Code migration bootstrap-qore-env. `pnpm bootstrap` used to fetch local
2
+ // secrets through `qdc-setup-env` (the `setup:env` script), which talks to a
3
+ // portal endpoint that is being retired. It now runs `qore env pull`.
4
+ //
5
+ // Every `pnpm run setup:env` in the scripts becomes `qore env pull`, and a
6
+ // `setup:env` that runs qdc-setup-env goes once nothing calls it. The file is
7
+ // edited as text, so its formatting and every other key stay as they are; an
8
+ // edit whose result does not parse to exactly the expected object is not
9
+ // written.
10
+ export const parser = "text"
11
+
12
+ const CALL = /\bpnpm (?:run )?setup:env\b/
13
+ const SEE = "see the bootstrap-qore-env instructions"
14
+
15
+ /** Every key of `a` and `b` equal, compared as JSON. */
16
+ const same = (a, b) => JSON.stringify(a) === JSON.stringify(b)
17
+
18
+ /** Replaces one script's value in the text, or null when it is not there exactly once. */
19
+ function setValue(text, key, from, to) {
20
+ const literal = `${JSON.stringify(key)}: ${JSON.stringify(from)}`
21
+ if (text.split(literal).length !== 2) return null
22
+ return text.replace(literal, () => `${JSON.stringify(key)}: ${JSON.stringify(to)}`)
23
+ }
24
+
25
+ /** Drops the `"key": ...` line, and a comma it leaves dangling. */
26
+ function dropLine(text, key) {
27
+ const lines = text.split("\n")
28
+ const i = lines.findIndex((l) => l.trimStart().startsWith(`${JSON.stringify(key)}:`))
29
+ if (i < 0) return null
30
+ const hadComma = /,\s*$/.test(lines[i])
31
+ lines.splice(i, 1)
32
+ if (!hadComma) {
33
+ let p = i - 1
34
+ while (p >= 0 && lines[p].trim() === "") p--
35
+ if (p >= 0) lines[p] = lines[p].replace(/,(\s*)$/, "$1")
36
+ }
37
+ return lines.join("\n")
38
+ }
39
+
40
+ export default function transformer(file, api) {
41
+ if (file.path !== "package.json") return undefined
42
+ let pkg
43
+ try {
44
+ pkg = JSON.parse(file.source)
45
+ } catch {
46
+ return undefined
47
+ }
48
+ const scripts = pkg.scripts ?? {}
49
+ const legacy = typeof scripts["setup:env"] === "string" && scripts["setup:env"].includes("qdc-setup-env")
50
+ const direct = Object.entries(scripts).filter(([k, v]) => k !== "setup:env" && typeof v === "string" && v.includes("qdc-setup-env"))
51
+ if (direct.length > 0) {
52
+ return void api.report({ status: "manual", reason: `"${direct[0][0]}" runs qdc-setup-env; use qore env pull, ${SEE}` })
53
+ }
54
+ if (!legacy) return undefined
55
+
56
+ const want = { ...pkg, scripts: { ...scripts } }
57
+ let text = file.source
58
+ for (const [key, value] of Object.entries(scripts)) {
59
+ if (key === "setup:env" || typeof value !== "string" || !CALL.test(value)) continue
60
+ const next = value.replace(new RegExp(CALL.source, "g"), "qore env pull")
61
+ want.scripts[key] = next
62
+ text = setValue(text, key, value, next)
63
+ if (text === null) return void api.report({ status: "manual", reason: `could not edit "${key}" safely; ${SEE}` })
64
+ }
65
+ if (!Object.values(want.scripts).some((v) => typeof v === "string" && v.includes("setup:env"))) {
66
+ delete want.scripts["setup:env"]
67
+ text = dropLine(text, "setup:env")
68
+ }
69
+ let got
70
+ try {
71
+ got = text === null ? null : JSON.parse(text)
72
+ } catch {
73
+ got = null
74
+ }
75
+ if (!got || !same(got, want)) return void api.report({ status: "manual", reason: `could not edit the scripts safely; ${SEE}` })
76
+ return text
77
+ }
@@ -0,0 +1,28 @@
1
+ # bootstrap-qore-env: local secrets through the Qore CLI
2
+
3
+ `pnpm bootstrap` used to fetch your local secrets with `qdc-setup-env` (the
4
+ `setup:env` script). That talks to a portal endpoint that is being retired, after
5
+ which it stops working. The Qore CLI does the same with `qore env pull`.
6
+
7
+ The upgrade bot runs this for you:
8
+
9
+ ```bash
10
+ node node_modules/@quatronic/sdk/migrations/run.mjs --only bootstrap-qore-env
11
+ ```
12
+
13
+ It changes `package.json` like this, and leaves every other script alone:
14
+
15
+ ```diff
16
+ - "bootstrap": "pnpm install && pnpm run setup:env && pnpm run db:up",
17
+ + "bootstrap": "pnpm install && qore env pull && pnpm run db:up",
18
+ - "setup:env": "qdc-setup-env",
19
+ ```
20
+
21
+ Install the CLI once on your machine if you have not: see the Qore CLI page in
22
+ the portal.
23
+
24
+ ## By hand
25
+
26
+ A script of your own that runs `qdc-setup-env` directly is listed in the pull
27
+ request. Replace that call with `qore env pull`. It writes `.env.local` for a
28
+ Next app and `.env` for a backend, and asks you to log in the first time.
@@ -0,0 +1,7 @@
1
+ {
2
+ "id": "bootstrap-qore-env",
3
+ "rule": null,
4
+ "introducedIn": "0.8.0",
5
+ "targets": ["package.json"],
6
+ "order": 10
7
+ }
@@ -0,0 +1,28 @@
1
+ // Code migration global-error. The page Next shows when the root layout
2
+ // throws becomes a re-export of @quatronic/sdk/next/global-error, so how a
3
+ // crash is reported and shown reaches the app as SDK releases.
4
+ //
5
+ // Tier 1 only: a global-error.tsx the team changed is kept as it is.
6
+ export const parser = "text"
7
+
8
+ // node scripts/tier1-fingerprints.mjs --templates <QDC-app-templates> src/app/global-error.tsx
9
+ const GLOBAL_ERROR = new Set([
10
+ "041294fbb8d4a355", // react-betterauth-next@8292521 2026-09-29
11
+ ])
12
+
13
+ const REEXPORT = "@quatronic/sdk/next/global-error"
14
+
15
+ // "use client" stays here: bundling the SDK drops the directive from the
16
+ // package, and Next requires it on this file.
17
+ export const GLOBAL_ERROR_SOURCE = `"use client"
18
+
19
+ // What Next renders when the root layout itself throws. It lives in the SDK, so
20
+ // how a crash is reported and shown reaches this app with a version bump.
21
+ export { default } from "${REEXPORT}"
22
+ `
23
+
24
+ export default function transformer(file, api) {
25
+ if (file.source.includes(REEXPORT)) return undefined
26
+ if (GLOBAL_ERROR.has(api.fingerprint(file.source))) return GLOBAL_ERROR_SOURCE
27
+ return void api.report({ status: "kept", reason: `changed by the team; it can re-export the default from ${REEXPORT}` })
28
+ }
@@ -0,0 +1,26 @@
1
+ # global-error: the crash page from the SDK
2
+
3
+ `src/app/global-error.tsx` is what Next renders when the root layout throws. It
4
+ used to call Sentry itself. It now re-exports the SDK's page, which reports the
5
+ error to Sentry the same way, so a change to crash reporting reaches your app as
6
+ an SDK release.
7
+
8
+ The upgrade bot runs this for you:
9
+
10
+ ```bash
11
+ node node_modules/@quatronic/sdk/migrations/run.mjs --only global-error
12
+ ```
13
+
14
+ A file exactly as the templates generated it becomes:
15
+
16
+ ```tsx
17
+ "use client"
18
+
19
+ export { default } from "@quatronic/sdk/next/global-error"
20
+ ```
21
+
22
+ Keep `"use client"`: Next requires it on this file, and the SDK's bundle does not
23
+ carry it.
24
+
25
+ A file your team changed is kept and listed in the pull request. If it only
26
+ restyled the page, keep it as it is: it goes on reporting through Sentry.
@@ -0,0 +1,7 @@
1
+ {
2
+ "id": "global-error",
3
+ "rule": null,
4
+ "introducedIn": "0.8.0",
5
+ "targets": ["src/app/global-error.tsx"],
6
+ "order": 10
7
+ }
@@ -0,0 +1,61 @@
1
+ // Code migration local-db-port. The local database listens on the port the
2
+ // portal assigned this module (DB_PORT), on loopback only:
3
+ //
4
+ // docker-compose.yml "${DB_PORT:-5432}:5432" -> "127.0.0.1:${DB_PORT:-5432}:5432"
5
+ // "5432:5432" -> the same
6
+ // package.json (Next) docker compose ... -> docker compose --env-file .env.local ...
7
+ //
8
+ // Without the second, a Next app's DB_PORT (in .env.local, where `qore env
9
+ // pull` writes it) never reaches docker compose, so the database starts on
10
+ // 5432 while DATABASE_URL points at the assigned port. Without the first, the
11
+ // database (postgres/postgres) is reachable from the whole network.
12
+ //
13
+ // Line edits, so files the team changed elsewhere migrate too.
14
+ export const parser = "text"
15
+
16
+ const SEE = "see the local-db-port instructions"
17
+ const PORT_LINE = /^(\s*-\s*)(["']?)(?:\$\{DB_PORT:-5432\}|5432):5432\2[ \t]*$/m
18
+ const COMPOSE = /\bdocker compose (?!--env-file)/g
19
+
20
+ const isNext = (api) => ["next.config.mjs", "next.config.ts", "next.config.js"].some((p) => api.exists(p))
21
+
22
+ function compose(file) {
23
+ if (!PORT_LINE.test(file.source)) return undefined
24
+ return file.source.replace(PORT_LINE, (_, lead) => `${lead}"127.0.0.1:\${DB_PORT:-5432}:5432"`)
25
+ }
26
+
27
+ function packageJson(file, api) {
28
+ if (!isNext(api) || !api.exists("docker-compose.yml")) return undefined
29
+ let pkg
30
+ try {
31
+ pkg = JSON.parse(file.source)
32
+ } catch {
33
+ return undefined
34
+ }
35
+ const scripts = pkg.scripts ?? {}
36
+ const want = { ...pkg, scripts: { ...scripts } }
37
+ let text = file.source
38
+ for (const [key, value] of Object.entries(scripts)) {
39
+ if (typeof value !== "string" || !new RegExp(COMPOSE.source).test(value)) continue
40
+ const next = value.replace(COMPOSE, "docker compose --env-file .env.local ")
41
+ const literal = `${JSON.stringify(key)}: ${JSON.stringify(value)}`
42
+ if (text.split(literal).length !== 2) {
43
+ return void api.report({ status: "manual", reason: `could not edit "${key}" safely; add --env-file .env.local, ${SEE}` })
44
+ }
45
+ text = text.replace(literal, () => `${JSON.stringify(key)}: ${JSON.stringify(next)}`)
46
+ want.scripts[key] = next
47
+ }
48
+ if (text === file.source) return undefined
49
+ try {
50
+ if (JSON.stringify(JSON.parse(text)) === JSON.stringify(want)) return text
51
+ } catch {
52
+ // fall through
53
+ }
54
+ return void api.report({ status: "manual", reason: `could not edit the scripts safely; ${SEE}` })
55
+ }
56
+
57
+ export default function transformer(file, api) {
58
+ if (file.path === "docker-compose.yml") return compose(file)
59
+ if (file.path === "package.json") return packageJson(file, api)
60
+ return undefined
61
+ }
@@ -0,0 +1,45 @@
1
+ # local-db-port: the local database on the assigned port, loopback only
2
+
3
+ The portal assigns every module with a database its own local port (`DB_PORT`),
4
+ so two modules never fight over 5432, and `DATABASE_URL` from `qore env pull`
5
+ points at that port. Two things in older apps get in the way:
6
+
7
+ - `docker-compose.yml` binds the port on every network interface, so the
8
+ database, with its well-known `postgres`/`postgres` login, is reachable from
9
+ your whole network.
10
+ - In a Next app, `pnpm db:up` does not read `.env.local`, where `DB_PORT` is. The
11
+ database then starts on 5432 while the app connects to the assigned port.
12
+
13
+ The upgrade bot runs this for you:
14
+
15
+ ```bash
16
+ node node_modules/@quatronic/sdk/migrations/run.mjs --only local-db-port
17
+ ```
18
+
19
+ ```diff
20
+ # docker-compose.yml
21
+ ports:
22
+ - - "${DB_PORT:-5432}:5432"
23
+ + - "127.0.0.1:${DB_PORT:-5432}:5432"
24
+ ```
25
+
26
+ ```diff
27
+ # package.json (Next apps)
28
+ - "db:up": "docker compose up -d --wait",
29
+ + "db:up": "docker compose --env-file .env.local up -d --wait",
30
+ ```
31
+
32
+ A backend needs no `--env-file`: docker compose reads `.env` by itself.
33
+
34
+ ## Did you put `DB_PORT` in `.env`?
35
+
36
+ Apps generated before August 2026 have a README tip: "Create a `.env` file next
37
+ to `docker-compose.yml` with `DB_PORT=5433`". After this migration a Next app's
38
+ `db:up` reads `.env.local` only, so that `.env` is ignored and the database
39
+ starts on 5432 again. Move the line to `.env.local` (or run `qore env pull`,
40
+ which writes the assigned `DB_PORT` there) and delete the `.env` if nothing
41
+ else is in it. `.env` is not committed, so the upgrade bot cannot see or move
42
+ it for you.
43
+
44
+ If your database was already running, restart it once with
45
+ `pnpm db:down && pnpm db:up`. It comes back on the assigned port with its data.
@@ -0,0 +1,7 @@
1
+ {
2
+ "id": "local-db-port",
3
+ "rule": null,
4
+ "introducedIn": "0.8.0",
5
+ "targets": ["docker-compose.yml", "package.json"],
6
+ "order": 10
7
+ }