@quatronic/sdk 0.7.0-rc.9 → 0.7.0-test.1a5da40

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 (81) hide show
  1. package/dist/{chunk-2AYDFLKR.js → chunk-F3NHTHFO.js} +6 -104
  2. package/dist/chunk-F3NHTHFO.js.map +1 -0
  3. package/dist/chunk-P7HNHLW7.js +65 -0
  4. package/dist/chunk-P7HNHLW7.js.map +1 -0
  5. package/dist/chunk-QMOZDE3U.js +158 -0
  6. package/dist/chunk-QMOZDE3U.js.map +1 -0
  7. package/dist/chunk-TOBGX4CZ.js +109 -0
  8. package/dist/chunk-TOBGX4CZ.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 +133 -3
  13. package/dist/cli/skills.js +133 -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.d.ts +12 -0
  21. package/dist/next/auth/index.js +14 -155
  22. package/dist/next/auth/index.js.map +1 -1
  23. package/dist/next/boot/index.d.ts +33 -0
  24. package/dist/next/boot/index.js +21 -0
  25. package/dist/next/boot/index.js.map +1 -0
  26. package/dist/next/db/index.d.ts +18 -1
  27. package/dist/next/db/index.js +25 -0
  28. package/dist/next/db/index.js.map +1 -1
  29. package/dist/next/global-error/index.d.ts +9 -0
  30. package/dist/next/global-error/index.js +17 -0
  31. package/dist/next/global-error/index.js.map +1 -0
  32. package/dist/next/integrations/index.d.ts +2 -1
  33. package/dist/next/integrations/index.js +6 -4
  34. package/dist/next/platform/index.d.ts +19 -0
  35. package/dist/next/platform/index.js +44 -0
  36. package/dist/next/platform/index.js.map +1 -0
  37. package/dist/next/security/index.d.ts +23 -1
  38. package/dist/next/security/index.js +38 -55
  39. package/dist/next/security/index.js.map +1 -1
  40. package/dist/next/sentry/register.js +5 -13
  41. package/dist/next/sentry/register.js.map +1 -1
  42. package/dist/next/users/index.js +7 -4
  43. package/dist/next/users/index.js.map +1 -1
  44. package/dist/node/boot/index.d.ts +9 -0
  45. package/dist/node/boot/index.js +13 -0
  46. package/dist/node/boot/index.js.map +1 -0
  47. package/dist/node/integrations/index.d.ts +2 -1
  48. package/dist/node/integrations/index.js +6 -4
  49. package/dist/node-Z7ERWJDZ.js +46 -0
  50. package/dist/node-Z7ERWJDZ.js.map +1 -0
  51. package/dist/types-CAwj03sM.d.ts +75 -0
  52. package/migrations/bootstrap-qore-env/codemod.mjs +77 -0
  53. package/migrations/bootstrap-qore-env/instructions.md +28 -0
  54. package/migrations/bootstrap-qore-env/meta.json +7 -0
  55. package/migrations/global-error/codemod.mjs +28 -0
  56. package/migrations/global-error/instructions.md +26 -0
  57. package/migrations/global-error/meta.json +7 -0
  58. package/migrations/local-db-port/codemod.mjs +61 -0
  59. package/migrations/local-db-port/instructions.md +35 -0
  60. package/migrations/local-db-port/meta.json +7 -0
  61. package/migrations/mail-reexport/codemod.mjs +64 -0
  62. package/migrations/mail-reexport/instructions.md +27 -0
  63. package/migrations/mail-reexport/meta.json +7 -0
  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 +261 -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 +322 -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 +26 -4
  78. package/skills/qore-enable-auth-method/SKILL.md +4 -3
  79. package/skills/qore-use-mail-domain/SKILL.next.md +4 -4
  80. package/workspace-requirements.json +4 -0
  81. package/dist/chunk-2AYDFLKR.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/users-core/serviceToken.ts","../../../src/next/users/index.ts"],"sourcesContent":["import { DirectoryError } from \"./errors\"\n\nconst SKEW_MS = 30_000\n\nexport function serviceTokenSource(cfg: {\n tokenUrl: string\n clientId: string\n clientSecret: string\n fetchImpl?: typeof fetch\n clock?: () => number\n}) {\n const fetchImpl = cfg.fetchImpl ?? fetch\n const clock = cfg.clock ?? Date.now\n let cached: { token: string; refreshAt: number } | undefined\n let inflight: Promise<string> | undefined\n\n async function request(): Promise<string> {\n let res: Response\n try {\n res = await fetchImpl(cfg.tokenUrl, {\n method: \"POST\",\n headers: { \"content-type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({\n grant_type: \"client_credentials\",\n client_id: cfg.clientId,\n client_secret: cfg.clientSecret,\n }),\n signal: AbortSignal.timeout(10_000),\n })\n } catch (err) {\n throw new DirectoryError(\"unavailable\", `token endpoint unreachable: ${(err as Error).message}`)\n }\n if (res.status === 400 || res.status === 401 || res.status === 403) {\n throw new DirectoryError(\"unauthorized\", `client_credentials refused (${res.status})`)\n }\n if (!res.ok) throw new DirectoryError(\"unavailable\", `token endpoint ${res.status}`)\n let j: { access_token?: unknown; expires_in?: unknown }\n try {\n j = (await res.json()) as typeof j\n } catch (err) {\n throw new DirectoryError(\"unavailable\", `token endpoint returned an unreadable body: ${(err as Error).message}`)\n }\n if (typeof j.access_token !== \"string\" || !j.access_token || typeof j.expires_in !== \"number\" || !Number.isFinite(j.expires_in)) {\n throw new DirectoryError(\"unavailable\", \"token endpoint returned an invalid token response\")\n }\n cached = { token: j.access_token, refreshAt: clock() + j.expires_in * 1000 - SKEW_MS }\n return j.access_token\n }\n\n return {\n async get(): Promise<string> {\n if (cached && clock() < cached.refreshAt) return cached.token\n inflight ??= request().finally(() => {\n inflight = undefined\n })\n return inflight\n },\n invalidate(): void {\n cached = undefined\n },\n }\n}\n","import { createUserDirectory } from \"../../users-core/client\"\nimport { serviceTokenSource } from \"../../users-core/serviceToken\"\nimport type { UserDirectory } from \"../../users-core/types\"\n\nexport type {\n AppUser,\n FormerUser,\n CacheMode,\n ListUsersOptions,\n ListUsersResult,\n UserDirectory,\n} from \"../../users-core/types\"\nexport { DirectoryError, type DirectoryErrorCode } from \"../../users-core/errors\"\n\nconst REQUIRED = [\"KC_URL\", \"KC_REALM\", \"KC_CLIENT_ID\", \"KC_CLIENT_SECRET\"] as const\nconst sources = new Map<string, ReturnType<typeof serviceTokenSource>>()\n\n/** The users of this app (client) in this environment. Server-side only. */\nexport function userDirectory(\n opts: { env?: Record<string, string | undefined>; fetchImpl?: typeof fetch } = {},\n): UserDirectory {\n const env = opts.env ?? (process.env as Record<string, string | undefined>)\n const missing = REQUIRED.filter((k) => !env[k])\n if (missing.length) throw new Error(`userDirectory(): missing env ${missing.join(\", \")}`)\n const issuer = `${env.KC_URL!.replace(/\\/+$/, \"\")}/realms/${env.KC_REALM}`\n const clientId = env.KC_CLIENT_ID!\n const sourceKey = `${issuer}|${clientId}`\n let source = sources.get(sourceKey)\n if (!source || opts.fetchImpl) {\n source = serviceTokenSource({\n tokenUrl: `${issuer}/protocol/openid-connect/token`,\n clientId,\n clientSecret: env.KC_CLIENT_SECRET!,\n fetchImpl: opts.fetchImpl,\n })\n if (!opts.fetchImpl) sources.set(sourceKey, source)\n }\n const tokens = source\n return createUserDirectory({\n baseUrl: `${issuer}/qdc-directory`,\n getToken: () => tokens.get(),\n onUnauthorized: () => tokens.invalidate(),\n cacheScope: sourceKey,\n fetchImpl: opts.fetchImpl,\n })\n}\n"],"mappings":"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","names":[]}
1
+ {"version":3,"sources":["../../../src/users-core/serviceToken.ts","../../../src/next/users/index.ts"],"sourcesContent":["import { DirectoryError } from \"./errors\"\n\nconst SKEW_MS = 30_000\n\nexport function serviceTokenSource(cfg: {\n tokenUrl: string\n clientId: string\n clientSecret: string\n fetchImpl?: typeof fetch\n clock?: () => number\n}) {\n const fetchImpl = cfg.fetchImpl ?? fetch\n const clock = cfg.clock ?? Date.now\n let cached: { token: string; refreshAt: number } | undefined\n let inflight: Promise<string> | undefined\n\n async function request(): Promise<string> {\n let res: Response\n try {\n res = await fetchImpl(cfg.tokenUrl, {\n method: \"POST\",\n headers: { \"content-type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({\n grant_type: \"client_credentials\",\n client_id: cfg.clientId,\n client_secret: cfg.clientSecret,\n }),\n signal: AbortSignal.timeout(10_000),\n })\n } catch (err) {\n throw new DirectoryError(\"unavailable\", `token endpoint unreachable: ${(err as Error).message}`)\n }\n if (res.status === 400 || res.status === 401 || res.status === 403) {\n throw new DirectoryError(\"unauthorized\", `client_credentials refused (${res.status})`)\n }\n if (!res.ok) throw new DirectoryError(\"unavailable\", `token endpoint ${res.status}`)\n let j: { access_token?: unknown; expires_in?: unknown }\n try {\n j = (await res.json()) as typeof j\n } catch (err) {\n throw new DirectoryError(\"unavailable\", `token endpoint returned an unreadable body: ${(err as Error).message}`)\n }\n if (typeof j.access_token !== \"string\" || !j.access_token || typeof j.expires_in !== \"number\" || !Number.isFinite(j.expires_in)) {\n throw new DirectoryError(\"unavailable\", \"token endpoint returned an invalid token response\")\n }\n cached = { token: j.access_token, refreshAt: clock() + j.expires_in * 1000 - SKEW_MS }\n return j.access_token\n }\n\n return {\n async get(): Promise<string> {\n if (cached && clock() < cached.refreshAt) return cached.token\n inflight ??= request().finally(() => {\n inflight = undefined\n })\n return inflight\n },\n invalidate(): void {\n cached = undefined\n },\n }\n}\n","import { createUserDirectory } from \"../../users-core/client\"\nimport { serviceTokenSource } from \"../../users-core/serviceToken\"\nimport type { UserDirectory } from \"../../users-core/types\"\n\nexport type {\n AppUser,\n FormerUser,\n CacheMode,\n ListUsersOptions,\n ListUsersResult,\n UserDirectory,\n} from \"../../users-core/types\"\nexport { DirectoryError, type DirectoryErrorCode } from \"../../users-core/errors\"\n\nconst REQUIRED = [\"KC_URL\", \"KC_REALM\", \"KC_CLIENT_ID\", \"KC_CLIENT_SECRET\"] as const\nconst sources = new Map<string, ReturnType<typeof serviceTokenSource>>()\n\n/** The users of this app (client) in this environment. Server-side only. */\nexport function userDirectory(\n opts: { env?: Record<string, string | undefined>; fetchImpl?: typeof fetch } = {},\n): UserDirectory {\n const env = opts.env ?? (process.env as Record<string, string | undefined>)\n const missing = REQUIRED.filter((k) => !env[k])\n if (missing.length) throw new Error(`userDirectory(): missing env ${missing.join(\", \")}`)\n const issuer = `${env.KC_URL!.replace(/\\/+$/, \"\")}/realms/${env.KC_REALM}`\n // Optional in-cluster address for this server's own HTTP calls; KC_URL stays\n // the issuer. Unset: the public URL is used for both.\n const internal = env.KC_INTERNAL_URL?.trim()\n const serverBase = internal\n ? `${internal.replace(/\\/+$/, \"\")}/realms/${env.KC_REALM}`\n : issuer\n const clientId = env.KC_CLIENT_ID!\n const sourceKey = `${issuer}|${clientId}`\n const sourceMapKey = `${serverBase}|${sourceKey}`\n let source = sources.get(sourceMapKey)\n if (!source || opts.fetchImpl) {\n source = serviceTokenSource({\n tokenUrl: `${serverBase}/protocol/openid-connect/token`,\n clientId,\n clientSecret: env.KC_CLIENT_SECRET!,\n fetchImpl: opts.fetchImpl,\n })\n if (!opts.fetchImpl) sources.set(sourceMapKey, source)\n }\n const tokens = source\n return createUserDirectory({\n baseUrl: `${serverBase}/qdc-directory`,\n getToken: () => tokens.get(),\n onUnauthorized: () => tokens.invalidate(),\n cacheScope: sourceKey,\n fetchImpl: opts.fetchImpl,\n })\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,9 @@
1
+ import { I as IntegrationMap } from '../../types-CAwj03sM.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-TOBGX4CZ.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-CAwj03sM.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-F3NHTHFO.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-TOBGX4CZ.js";
20
22
  import {
21
23
  PLATFORM_MANAGED_HOSTS,
22
24
  isPlatformManagedHost
@@ -0,0 +1,46 @@
1
+ import {
2
+ assertIntegrations
3
+ } from "./chunk-TOBGX4CZ.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-Z7ERWJDZ.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,75 @@
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
+ /** Auth fields whose env value is a secret, so the portal masks it. */
68
+ declare const AUTH_SECRET_FIELDS: readonly ["apiKey", "token", "password", "clientSecret"];
69
+ /**
70
+ * Env keys under this prefix belong to the platform
71
+ * (`QORE_INTEGRATION_<ALIAS>_LOGGING` today). A declaration may not claim one.
72
+ */
73
+ declare const RESERVED_KEY_PREFIX = "QORE_INTEGRATION_";
74
+
75
+ 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.7.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.7.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,35 @@
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
+ If your database was already running, restart it once with
35
+ `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.7.0",
5
+ "targets": ["docker-compose.yml", "package.json"],
6
+ "order": 10
7
+ }
@@ -0,0 +1,64 @@
1
+ // Code migration mail-reexport. An app's src/lib/mail.ts becomes a re-export
2
+ // of @quatronic/sdk/mail, so how mail is sent (and logged) reaches it as SDK
3
+ // releases. Every rendering the templates produced has the SDK's signature,
4
+ // `sendMail(mail: Mail)`, so callers do not change.
5
+ //
6
+ // Tier 1 only: a mail.ts the team changed is kept as it is. The template's
7
+ // mail.test.ts (src/lib/ in Next apps, tests/ in backends) tests the old body
8
+ // (it mocks fetch and the logger), so it is
9
+ // deleted together with a replaced mail.ts; one the team changed is left for a
10
+ // person, since it will fail against the re-export.
11
+ export const parser = "text"
12
+
13
+ // node scripts/tier1-fingerprints.mjs --templates <QDC-app-templates> src/lib/mail.ts src/lib/mail.test.ts tests/mail.test.ts
14
+ const MAIL = new Set([
15
+ "865b9881e187cf73", // node-backend@30fdec5 2026-08-04
16
+ "6cb0fa829d99cf77", // node-backend@2fd295e 2026-09-07
17
+ "11fde4240bd6d7f7", // node-backend@8292521 2026-09-29
18
+ "94120fb267e75af8", // node-backend@a691748 2026-10-08
19
+ "f3d629f9d27883d6", // react-betterauth-next@30fdec5 2026-08-04
20
+ "39030a91919715e8", // react-betterauth-next@2fd295e 2026-09-07
21
+ "67c5fad8bf33b463", // react-betterauth-next@a691748 2026-10-08
22
+ ])
23
+
24
+ const MAIL_TEST = new Set([
25
+ "e9225a45d7032231", // react-betterauth-next@30fdec5 2026-08-04
26
+ "a5491c7c345292b0", // react-betterauth-next@a691748 2026-10-08
27
+ "0e14f2ab2f8524dc", // node-backend@28d9400 2026-09-21 tests/mail.test.ts
28
+ "9737c403a50268e4", // node-backend@a691748 2026-10-08 tests/mail.test.ts
29
+ ])
30
+
31
+ const MAIL_TESTS = new Set(["src/lib/mail.test.ts", "tests/mail.test.ts"])
32
+
33
+ const MAIL_TS = "src/lib/mail.ts"
34
+ const REEXPORT = "@quatronic/sdk/mail"
35
+
36
+ export const MAIL_SOURCE = `// Mail transport: Resend when MAIL_API_KEY is set, otherwise a logged skip.
37
+ // It lives in the SDK, so a fix to how mail is sent reaches this app with a
38
+ // version bump.
39
+ export { sendMail, type Mail } from "${REEXPORT}"
40
+ `
41
+
42
+ /** Whether mail.ts is, or is about to become, the re-export. */
43
+ function mailMoves(api) {
44
+ const source = api.read(MAIL_TS)
45
+ if (source === null) return false
46
+ return source.includes(REEXPORT) || MAIL.has(api.fingerprint(source))
47
+ }
48
+
49
+ export default function transformer(file, api) {
50
+ if (file.path === MAIL_TS) {
51
+ if (file.source.includes(REEXPORT)) return undefined
52
+ if (MAIL.has(api.fingerprint(file.source))) return MAIL_SOURCE
53
+ return void api.report({ status: "kept", reason: `changed by the team; it can re-export sendMail from ${REEXPORT}` })
54
+ }
55
+ if (MAIL_TESTS.has(file.path)) {
56
+ if (!mailMoves(api)) return undefined
57
+ if (MAIL_TEST.has(api.fingerprint(file.source))) return null
58
+ return void api.report({
59
+ status: "manual",
60
+ reason: "tests the mail.ts body that moved to the SDK; delete it or test your callers instead",
61
+ })
62
+ }
63
+ return undefined
64
+ }
@@ -0,0 +1,27 @@
1
+ # mail-reexport: send mail through the SDK
2
+
3
+ `src/lib/mail.ts` used to hold the Resend call. It now lives in
4
+ `@quatronic/sdk/mail`, with the same `sendMail(mail: Mail)` signature, so a fix
5
+ to how mail is sent reaches your app as an SDK release.
6
+
7
+ The upgrade bot runs this for you:
8
+
9
+ ```bash
10
+ node node_modules/@quatronic/sdk/migrations/run.mjs --only mail-reexport
11
+ ```
12
+
13
+ A `mail.ts` exactly as the templates generated it becomes:
14
+
15
+ ```ts
16
+ export { sendMail, type Mail } from "@quatronic/sdk/mail"
17
+ ```
18
+
19
+ and the template's `mail.test.ts` (`src/lib/` in a Next app, `tests/` in a backend), which tested the old body, is deleted.
20
+
21
+ A `mail.ts` your team changed is kept and listed in the pull request. Move it
22
+ when the SDK version does what you need: replace the body with the re-export
23
+ above, or call `sendMail` from the SDK inside your own function.
24
+
25
+ A `mail.test.ts` your team changed is listed as a manual change when `mail.ts`
26
+ moves. It mocks `fetch` and the logger of the old body and will fail against the
27
+ re-export. Delete it, or test your callers with `sendMail` mocked.
@@ -0,0 +1,7 @@
1
+ {
2
+ "id": "mail-reexport",
3
+ "rule": null,
4
+ "introducedIn": "0.7.0",
5
+ "targets": ["src/lib/mail.ts", "src/lib/mail.test.ts", "tests/mail.test.ts"],
6
+ "order": 10
7
+ }