@quatronic/sdk 0.7.0-rc.8 → 0.7.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.
Files changed (37) hide show
  1. package/dist/auth/index.js +1 -1
  2. package/dist/{chunk-5MNPBJYS.js → chunk-G7VPNC6M.js} +5 -11
  3. package/dist/{chunk-5MNPBJYS.js.map → chunk-G7VPNC6M.js.map} +1 -1
  4. package/dist/{chunk-ZZTO5Z3N.js → chunk-HQT57ITV.js} +2 -2
  5. package/dist/{chunk-EK6TGWWT.js → chunk-MET4SIMB.js} +2 -8
  6. package/dist/chunk-MET4SIMB.js.map +1 -0
  7. package/dist/{chunk-ROHIN74F.js → chunk-TEBDKNUB.js} +2 -2
  8. package/dist/cli/skills-postinstall.js +118 -1
  9. package/dist/cli/skills.js +118 -1
  10. package/dist/eslint/index.js +2 -22
  11. package/dist/eslint/index.js.map +1 -1
  12. package/dist/next/auth/index.d.ts +12 -0
  13. package/dist/next/auth/index.js +12 -4
  14. package/dist/next/auth/index.js.map +1 -1
  15. package/dist/next/better-auth/index.js +1 -1
  16. package/dist/next/connections/index.js +3 -3
  17. package/dist/next/security/index.js +3 -3
  18. package/dist/next/sentry/client.d.ts +0 -1
  19. package/dist/next/sentry/client.js +2 -2
  20. package/dist/next/sentry/register.js +2 -2
  21. package/dist/next/users/index.js +7 -4
  22. package/dist/next/users/index.js.map +1 -1
  23. package/dist/node/connections/index.js +3 -3
  24. package/dist/node/identity/index.js +2 -2
  25. package/dist/node/sentry/register.js +2 -2
  26. package/package.json +1 -5
  27. package/skills/qore-enable-auth-method/SKILL.md +4 -3
  28. package/skills/qore-use-mail-domain/SKILL.next.md +4 -4
  29. package/dist/chunk-EK6TGWWT.js.map +0 -1
  30. package/dist/observability/index.d.ts +0 -10
  31. package/dist/observability/index.js +0 -7
  32. package/dist/observability/index.js.map +0 -1
  33. package/migrations/report-error/codemod.mjs +0 -94
  34. package/migrations/report-error/instructions.md +0 -46
  35. package/migrations/report-error/meta.json +0 -6
  36. /package/dist/{chunk-ZZTO5Z3N.js.map → chunk-HQT57ITV.js.map} +0 -0
  37. /package/dist/{chunk-ROHIN74F.js.map → chunk-TEBDKNUB.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getLogger,
3
3
  setUserContext
4
- } from "../../chunk-EK6TGWWT.js";
4
+ } from "../../chunk-MET4SIMB.js";
5
5
 
6
6
  // src/next/better-auth/plugin.ts
7
7
  import { createAuthMiddleware, getSessionFromCtx } from "better-auth/api";
@@ -3,7 +3,7 @@ import {
3
3
  assertConnections,
4
4
  assertInboundConnection,
5
5
  connection
6
- } from "../../chunk-ZZTO5Z3N.js";
6
+ } from "../../chunk-HQT57ITV.js";
7
7
  import {
8
8
  CONNECTION_REJECTED_ATTR,
9
9
  CONNECTION_REJECT_REASON_ATTR,
@@ -11,9 +11,9 @@ import {
11
11
  ConnectionError,
12
12
  DEFAULT_CONNECTION_TIMEOUT_MS,
13
13
  requireConnection
14
- } from "../../chunk-ROHIN74F.js";
14
+ } from "../../chunk-TEBDKNUB.js";
15
15
  import "../../chunk-5XMTUPIY.js";
16
- import "../../chunk-EK6TGWWT.js";
16
+ import "../../chunk-MET4SIMB.js";
17
17
  export {
18
18
  CONNECTION_REJECTED_ATTR,
19
19
  CONNECTION_REJECT_REASON_ATTR,
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  parseJsonBounded
3
3
  } from "../../chunk-FUPTRHT7.js";
4
- import {
5
- STATIC_SECURITY_HEADERS
6
- } from "../../chunk-2HE2D4SY.js";
7
4
  import {
8
5
  proxyMatcher
9
6
  } from "../../chunk-X6D3TBNS.js";
7
+ import {
8
+ STATIC_SECURITY_HEADERS
9
+ } from "../../chunk-2HE2D4SY.js";
10
10
 
11
11
  // src/next/security/index.ts
12
12
  import { NextResponse } from "next/server";
@@ -6,7 +6,6 @@ interface SentryLike {
6
6
  setUser(user: {
7
7
  id: string;
8
8
  } | null): void;
9
- captureException(err: unknown, hint?: object): unknown;
10
9
  }
11
10
 
12
11
  type BrowserSentry = SentryLike & {
@@ -3,9 +3,9 @@ import {
3
3
  } from "../../chunk-DYOSRJH3.js";
4
4
  import {
5
5
  initSentry
6
- } from "../../chunk-5MNPBJYS.js";
6
+ } from "../../chunk-G7VPNC6M.js";
7
+ import "../../chunk-MET4SIMB.js";
7
8
  import "../../chunk-7ASQHY7O.js";
8
- import "../../chunk-EK6TGWWT.js";
9
9
 
10
10
  // src/next/sentry/client.ts
11
11
  import * as Sentry from "@sentry/nextjs";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  initSentry
3
- } from "../../chunk-5MNPBJYS.js";
3
+ } from "../../chunk-G7VPNC6M.js";
4
+ import "../../chunk-MET4SIMB.js";
4
5
  import {
5
6
  readSentryConfig
6
7
  } from "../../chunk-7ASQHY7O.js";
7
- import "../../chunk-EK6TGWWT.js";
8
8
 
9
9
  // src/next/sentry/register.ts
10
10
  import * as Sentry from "@sentry/nextjs";
@@ -66,21 +66,24 @@ function userDirectory(opts = {}) {
66
66
  const missing = REQUIRED.filter((k) => !env[k]);
67
67
  if (missing.length) throw new Error(`userDirectory(): missing env ${missing.join(", ")}`);
68
68
  const issuer = `${env.KC_URL.replace(/\/+$/, "")}/realms/${env.KC_REALM}`;
69
+ const internal = env.KC_INTERNAL_URL?.trim();
70
+ const serverBase = internal ? `${internal.replace(/\/+$/, "")}/realms/${env.KC_REALM}` : issuer;
69
71
  const clientId = env.KC_CLIENT_ID;
70
72
  const sourceKey = `${issuer}|${clientId}`;
71
- let source = sources.get(sourceKey);
73
+ const sourceMapKey = `${serverBase}|${sourceKey}`;
74
+ let source = sources.get(sourceMapKey);
72
75
  if (!source || opts.fetchImpl) {
73
76
  source = serviceTokenSource({
74
- tokenUrl: `${issuer}/protocol/openid-connect/token`,
77
+ tokenUrl: `${serverBase}/protocol/openid-connect/token`,
75
78
  clientId,
76
79
  clientSecret: env.KC_CLIENT_SECRET,
77
80
  fetchImpl: opts.fetchImpl
78
81
  });
79
- if (!opts.fetchImpl) sources.set(sourceKey, source);
82
+ if (!opts.fetchImpl) sources.set(sourceMapKey, source);
80
83
  }
81
84
  const tokens = source;
82
85
  return createUserDirectory({
83
- baseUrl: `${issuer}/qdc-directory`,
86
+ baseUrl: `${serverBase}/qdc-directory`,
84
87
  getToken: () => tokens.get(),
85
88
  onUnauthorized: () => tokens.invalidate(),
86
89
  cacheScope: sourceKey,
@@ -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"],"mapp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UAAI,UAAU,MAAM,IAAI,OAAO,UAAW,QAAO,OAAO;AACxD,mBAAa,QAAQ,EAAE,QAAQ,MAAM;AACnC,mBAAW;AAAA,MACb,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,aAAmB;AACjB,eAAS;AAAA,IACX;AAAA,EACF;AACF;;;AC/CA,IAAM,WAAW,CAAC,UAAU,YAAY,gBAAgB,kBAAkB;AAC1E,IAAM,UAAU,oBAAI,IAAmD;AAGhE,SAAS,cACd,OAA+E,CAAC,GACjE;AACf,QAAM,MAAM,KAAK,OAAQ,QAAQ;AACjC,QAAM,UAAU,SAAS,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC9C,MAAI,QAAQ,OAAQ,OAAM,IAAI,MAAM,gCAAgC,QAAQ,KAAK,IAAI,CAAC,EAAE;AACxF,QAAM,SAAS,GAAG,IAAI,OAAQ,QAAQ,QAAQ,EAAE,CAAC,WAAW,IAAI,QAAQ;AACxE,QAAM,WAAW,IAAI;AACrB,QAAM,YAAY,GAAG,MAAM,IAAI,QAAQ;AACvC,MAAI,SAAS,QAAQ,IAAI,SAAS;AAClC,MAAI,CAAC,UAAU,KAAK,WAAW;AAC7B,aAAS,mBAAmB;AAAA,MAC1B,UAAU,GAAG,MAAM;AAAA,MACnB;AAAA,MACA,cAAc,IAAI;AAAA,MAClB,WAAW,KAAK;AAAA,IAClB,CAAC;AACD,QAAI,CAAC,KAAK,UAAW,SAAQ,IAAI,WAAW,MAAM;AAAA,EACpD;AACA,QAAM,SAAS;AACf,SAAO,oBAAoB;AAAA,IACzB,SAAS,GAAG,MAAM;AAAA,IAClB,UAAU,MAAM,OAAO,IAAI;AAAA,IAC3B,gBAAgB,MAAM,OAAO,WAAW;AAAA,IACxC,YAAY;AAAA,IACZ,WAAW,KAAK;AAAA,EAClB,CAAC;AACH;","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":";;;;;;;;AAEA,IAAM,UAAU;AAET,SAAS,mBAAmB,KAMhC;AACD,QAAM,YAAY,IAAI,aAAa;AACnC,QAAM,QAAQ,IAAI,SAAS,KAAK;AAChC,MAAI;AACJ,MAAI;AAEJ,iBAAe,U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unk-ZZTO5Z3N.js";
6
+ } from "../../chunk-HQT57ITV.js";
7
7
  import {
8
8
  CONNECTION_REJECTED_ATTR,
9
9
  CONNECTION_REJECT_REASON_ATTR,
@@ -11,9 +11,9 @@ import {
11
11
  ConnectionError,
12
12
  DEFAULT_CONNECTION_TIMEOUT_MS,
13
13
  requireConnection
14
- } from "../../chunk-ROHIN74F.js";
14
+ } from "../../chunk-TEBDKNUB.js";
15
15
  import "../../chunk-5XMTUPIY.js";
16
- import "../../chunk-EK6TGWWT.js";
16
+ import "../../chunk-MET4SIMB.js";
17
17
  export {
18
18
  CONNECTION_REJECTED_ATTR,
19
19
  CONNECTION_REJECT_REASON_ATTR,
@@ -4,12 +4,12 @@ import {
4
4
  import {
5
5
  ConnectionError,
6
6
  requireConnection
7
- } from "../../chunk-ROHIN74F.js";
7
+ } from "../../chunk-TEBDKNUB.js";
8
8
  import {
9
9
  defaultEnv,
10
10
  readConn
11
11
  } from "../../chunk-5XMTUPIY.js";
12
- import "../../chunk-EK6TGWWT.js";
12
+ import "../../chunk-MET4SIMB.js";
13
13
 
14
14
  // src/identity-core/jwksCache.ts
15
15
  import { createRemoteJWKSet } from "jose";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  initSentry
3
- } from "../../chunk-5MNPBJYS.js";
3
+ } from "../../chunk-G7VPNC6M.js";
4
+ import "../../chunk-MET4SIMB.js";
4
5
  import {
5
6
  readSentryConfig
6
7
  } from "../../chunk-7ASQHY7O.js";
7
- import "../../chunk-EK6TGWWT.js";
8
8
 
9
9
  // src/node/sentry/register.ts
10
10
  import * as Sentry from "@sentry/node";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatronic/sdk",
3
- "version": "0.7.0-rc.8",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -51,10 +51,6 @@
51
51
  "types": "./dist/node/sentry/register.d.ts",
52
52
  "import": "./dist/node/sentry/register.js"
53
53
  },
54
- "./observability": {
55
- "types": "./dist/observability/index.d.ts",
56
- "import": "./dist/observability/index.js"
57
- },
58
54
  "./next/config": {
59
55
  "types": "./dist/next/config/index.d.ts",
60
56
  "import": "./dist/next/config/index.js"
@@ -47,8 +47,8 @@ No migration; no new table.
47
47
  ## Recipe: Magic link
48
48
 
49
49
  No migration — reuses the `verification` table. Emails go through
50
- `sendEmail` (`src/lib/email`), which logs to the console when
51
- `RESEND_API_KEY` is unset, so it works locally without a mail provider.
50
+ `sendEmail` (`src/lib/email`), which prints the mail to the terminal under
51
+ `pnpm dev` when no mail key is set, so it works locally without a mail provider.
52
52
 
53
53
  1. In `src/lib/auth.ts`: uncomment `// import { magicLink … }` at the top
54
54
  (merge it into the existing `better-auth/plugins` import), then uncomment the
@@ -61,7 +61,8 @@ No migration — reuses the `verification` table. Emails go through
61
61
  needed. Add `magicLinkEmail` to the existing `@/lib/email` import at the
62
62
  top of `src/lib/auth.ts`; the `magicLink({ sendMagicLink … })` block
63
63
  uncommented in step 1 already calls it.
64
- 5. For real email delivery set `RESEND_API_KEY` + `EMAIL_FROM`.
64
+ 5. For real email delivery, link a mail domain to this module in the portal
65
+ (or set `RESEND_API_KEY` + `EMAIL_FROM` for a Resend key of your own).
65
66
  6. Run the check loop.
66
67
 
67
68
  ## Recipe: Two-factor (TOTP)
@@ -56,10 +56,10 @@ Worked example: `docs/examples/mail.example.ts`.
56
56
  ## This is not auth email
57
57
 
58
58
  If this app has Better Auth (`next-betterauth`), verification and magic-link
59
- email already flow through `src/lib/email/send.ts` and its own
60
- `RESEND_API_KEY`/`EMAIL_FROM` — a separate mechanism tied to the portal's
61
- platform sender, not to a per-module linked domain. Don't merge the two;
62
- `sendMail` here is for this module's own business email.
59
+ email already flow through `src/lib/email/send.ts`. It sends over the same
60
+ linked domain (or the app's own `RESEND_API_KEY`/`EMAIL_FROM` when set), but
61
+ with its own templates. Don't route auth email through `sendMail`; `sendMail`
62
+ here is for this module's own business email.
63
63
 
64
64
  ## Ship it
65
65
 
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/telemetry-hooks/index.ts"],"sourcesContent":["export type LogAttrs = Record<string, unknown>\ntype Flat = Record<string, string | number | boolean>\ntype Level = \"debug\" | \"info\" | \"warn\" | \"error\"\n\nexport interface QoreLogger {\n debug(attrs: LogAttrs, msg: string): void\n info(attrs: LogAttrs, msg: string): void\n warn(attrs: LogAttrs, msg: string): void\n error(attrs: LogAttrs, msg: string): void\n}\n\nexport interface TelemetryHooks {\n log?: Record<Level, (msg: string, attrs?: Flat) => void>\n setUser?: (user: { id: string } | null) => void\n captureException?: (err: unknown, hint: { extra: Flat }) => void\n}\n\nconst KEY = Symbol.for(\"@quatronic/sdk.telemetry-hooks\")\ntype Holder = { [KEY]?: TelemetryHooks }\nconst holder = globalThis as Holder\n\nexport function setTelemetryHooks(hooks: TelemetryHooks): void {\n holder[KEY] = hooks\n}\n\nexport function resetTelemetryHooks(): void {\n delete holder[KEY]\n}\n\nexport function flattenAttrs(attrs: LogAttrs): Flat {\n const out: Flat = {}\n for (const [key, value] of Object.entries(attrs)) {\n if (value === undefined || value === null) continue\n if (value instanceof Error) {\n out[\"error.type\"] = value.name\n out[\"error.message\"] = value.message\n } else if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n out[key] = value\n } else {\n out[key] = JSON.stringify(value)\n }\n }\n return out\n}\n\nfunction emit(level: Level, attrs: LogAttrs, msg: string): void {\n const flat = flattenAttrs(attrs)\n const sink = holder[KEY]?.log\n if (sink) return sink[level](msg, flat)\n const line = JSON.stringify({ level, msg, ...flat })\n if (level === \"error\") console.error(line)\n else if (level === \"warn\") console.warn(line)\n else console.log(line)\n}\n\nconst logger: QoreLogger = {\n debug: (a, m) => emit(\"debug\", a, m),\n info: (a, m) => emit(\"info\", a, m),\n warn: (a, m) => emit(\"warn\", a, m),\n error: (a, m) => emit(\"error\", a, m),\n}\n\nexport function getLogger(): QoreLogger {\n return logger\n}\n\nexport function setUserContext(id: string | null): void {\n holder[KEY]?.setUser?.(id ? { id } : null)\n}\n\n/**\n * Hands an error the app caught to the error tracker, with flat context.\n *\n * Without a tracker it writes the same JSON line `getLogger().error` would, so\n * a caught error is never silently dropped in an app that has no Sentry.\n */\nexport function reportError(err: unknown, ctx: LogAttrs = {}): void {\n const capture = holder[KEY]?.captureException\n if (capture) return capture(err, { extra: flattenAttrs(ctx) })\n emit(\"error\", { ...ctx, err: err instanceof Error ? err : new Error(String(err)) }, \"unhandled error reported\")\n}\n"],"mappings":";AAiBA,IAAM,MAAM,uBAAO,IAAI,gCAAgC;AAEvD,IAAM,SAAS;AAER,SAAS,kBAAkB,OAA6B;AAC7D,SAAO,GAAG,IAAI;AAChB;AAMO,SAAS,aAAa,OAAuB;AAClD,QAAM,MAAY,CAAC;AACnB,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;AAChD,QAAI,UAAU,UAAa,UAAU,KAAM;AAC3C,QAAI,iBAAiB,OAAO;AAC1B,UAAI,YAAY,IAAI,MAAM;AAC1B,UAAI,eAAe,IAAI,MAAM;AAAA,IAC/B,WAAW,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW;AAC/F,UAAI,GAAG,IAAI;AAAA,IACb,OAAO;AACL,UAAI,GAAG,IAAI,KAAK,UAAU,KAAK;AAAA,IACjC;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,KAAK,OAAc,OAAiB,KAAmB;AAC9D,QAAM,OAAO,aAAa,KAAK;AAC/B,QAAM,OAAO,OAAO,GAAG,GAAG;AAC1B,MAAI,KAAM,QAAO,KAAK,KAAK,EAAE,KAAK,IAAI;AACtC,QAAM,OAAO,KAAK,UAAU,EAAE,OAAO,KAAK,GAAG,KAAK,CAAC;AACnD,MAAI,UAAU,QAAS,SAAQ,MAAM,IAAI;AAAA,WAChC,UAAU,OAAQ,SAAQ,KAAK,IAAI;AAAA,MACvC,SAAQ,IAAI,IAAI;AACvB;AAEA,IAAM,SAAqB;AAAA,EACzB,OAAO,CAAC,GAAG,MAAM,KAAK,SAAS,GAAG,CAAC;AAAA,EACnC,MAAM,CAAC,GAAG,MAAM,KAAK,QAAQ,GAAG,CAAC;AAAA,EACjC,MAAM,CAAC,GAAG,MAAM,KAAK,QAAQ,GAAG,CAAC;AAAA,EACjC,OAAO,CAAC,GAAG,MAAM,KAAK,SAAS,GAAG,CAAC;AACrC;AAEO,SAAS,YAAwB;AACtC,SAAO;AACT;AAEO,SAAS,eAAe,IAAyB;AACtD,SAAO,GAAG,GAAG,UAAU,KAAK,EAAE,GAAG,IAAI,IAAI;AAC3C;AAQO,SAAS,YAAY,KAAc,MAAgB,CAAC,GAAS;AAClE,QAAM,UAAU,OAAO,GAAG,GAAG;AAC7B,MAAI,QAAS,QAAO,QAAQ,KAAK,EAAE,OAAO,aAAa,GAAG,EAAE,CAAC;AAC7D,OAAK,SAAS,EAAE,GAAG,KAAK,KAAK,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC,EAAE,GAAG,0BAA0B;AAChH;","names":[]}
@@ -1,10 +0,0 @@
1
- type LogAttrs = Record<string, unknown>;
2
- /**
3
- * Hands an error the app caught to the error tracker, with flat context.
4
- *
5
- * Without a tracker it writes the same JSON line `getLogger().error` would, so
6
- * a caught error is never silently dropped in an app that has no Sentry.
7
- */
8
- declare function reportError(err: unknown, ctx?: LogAttrs): void;
9
-
10
- export { reportError };
@@ -1,7 +0,0 @@
1
- import {
2
- reportError
3
- } from "../chunk-EK6TGWWT.js";
4
- export {
5
- reportError
6
- };
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,94 +0,0 @@
1
- // jscodeshift transform for migration report-error. Moves the mechanical
2
- // Sentry.captureException calls that QDC-OBS-004 flags onto reportError.
3
- //
4
- // npx jscodeshift@17.3.0 --parser=tsx \
5
- // -t node_modules/@quatronic/sdk/migrations/report-error/codemod.mjs src
6
- //
7
- // Rewritten: `captureException(err)` and `captureException(err, { extra })`,
8
- // through a namespace or a named import of any @sentry/* package. A call that
9
- // passes tags, a level, a scope callback or anything else is left for a person;
10
- // instructions.md says what to do with each.
11
-
12
- const SENTRY = /^@sentry\//
13
- const MODULE = "@quatronic/sdk/observability"
14
-
15
- function keyName(prop) {
16
- if (prop.computed) return null
17
- if (prop.key.type === "Identifier") return prop.key.name
18
- return typeof prop.key.value === "string" ? prop.key.value : null
19
- }
20
-
21
- /** The context to hand reportError, or false when the hint does not map. */
22
- function contextOf(hint) {
23
- if (!hint) return null
24
- if (hint.type !== "ObjectExpression" || hint.properties.length !== 1) return false
25
- const only = hint.properties[0]
26
- if ((only.type !== "ObjectProperty" && only.type !== "Property") || keyName(only) !== "extra") return false
27
- return only.value
28
- }
29
-
30
- export default function transformer(file, api) {
31
- const j = api.jscodeshift
32
- const root = j(file.source)
33
-
34
- const namespaces = new Set()
35
- const named = new Set()
36
- const sentryImports = root.find(j.ImportDeclaration).filter((p) => SENTRY.test(String(p.node.source.value)))
37
- sentryImports.forEach((p) => {
38
- for (const s of p.node.specifiers ?? []) {
39
- if (s.type === "ImportNamespaceSpecifier" || s.type === "ImportDefaultSpecifier") namespaces.add(s.local.name)
40
- else if (s.type === "ImportSpecifier" && s.imported.name === "captureException") named.add(s.local.name)
41
- }
42
- })
43
- if (namespaces.size === 0 && named.size === 0) return undefined
44
-
45
- let changed = 0
46
- root.find(j.CallExpression).forEach((p) => {
47
- const c = p.node.callee
48
- const isCapture =
49
- (c.type === "Identifier" && named.has(c.name)) ||
50
- (c.type === "MemberExpression" &&
51
- !c.computed &&
52
- c.object.type === "Identifier" &&
53
- namespaces.has(c.object.name) &&
54
- c.property.type === "Identifier" &&
55
- c.property.name === "captureException")
56
- if (!isCapture) return
57
- const [err, hint, ...rest] = p.node.arguments
58
- if (!err || rest.length > 0 || err.type === "SpreadElement") return
59
- const ctx = contextOf(hint)
60
- if (ctx === false) return
61
- p.node.callee = j.identifier("reportError")
62
- p.node.arguments = ctx ? [err, ctx] : [err]
63
- changed++
64
- })
65
- if (changed === 0) return undefined
66
-
67
- // Drop a named captureException import nothing uses any more.
68
- const stillUsed = (name) =>
69
- root
70
- .find(j.Identifier, { name })
71
- .filter((p) => j(p).closest(j.ImportDeclaration).length === 0).length > 0
72
- sentryImports.forEach((p) => {
73
- const before = p.node.specifiers.length
74
- p.node.specifiers = p.node.specifiers.filter(
75
- (s) => s.type !== "ImportSpecifier" || s.imported.name !== "captureException" || stillUsed(s.local.name),
76
- )
77
- if (before > 0 && p.node.specifiers.length === 0) j(p).remove()
78
- })
79
-
80
- const existing = root.find(j.ImportDeclaration, { source: { value: MODULE } })
81
- if (existing.find(j.ImportSpecifier, { imported: { name: "reportError" } }).length === 0) {
82
- const spec = j.importSpecifier(j.identifier("reportError"))
83
- if (existing.length > 0) existing.get().node.specifiers.push(spec)
84
- else {
85
- const decl = j.importDeclaration([spec], j.literal(MODULE))
86
- const imports = root.find(j.ImportDeclaration)
87
- if (imports.length > 0) imports.at(imports.length - 1).insertAfter(decl)
88
- else root.get().node.program.body.unshift(decl)
89
- }
90
- }
91
- return root.toSource({ quote: "double" })
92
- }
93
-
94
- export const parser = "tsx"
@@ -1,46 +0,0 @@
1
- # report-error
2
-
3
- Report a caught error with `reportError` from `@quatronic/sdk/observability`,
4
- not with `Sentry.captureException`.
5
-
6
- **Rule:** `qdc/use-report-error` (QDC-OBS-004). This is a test-only migration, so no shipped config switches the rule on; run it explicitly with `eslint --rule "qdc/use-report-error: warn"`.
7
-
8
- ## Why
9
-
10
- The SDK owns the error tracker: it initialises Sentry and wires it into its
11
- telemetry hooks. An app that calls `reportError` keeps reporting when that
12
- wiring changes (another tracker, a different scrubbing policy, a test fake).
13
- An app that calls Sentry directly has to be edited for each of those changes.
14
- Without a tracker, `reportError` writes an error line to the console instead of
15
- dropping the error.
16
-
17
- Spans, `Sentry.logger` and tags stay `Sentry.*`. Only the capture call moves.
18
-
19
- ## Run the codemod
20
-
21
- ```bash
22
- npx jscodeshift@17.3.0 --parser=tsx \
23
- -t node_modules/@quatronic/sdk/migrations/report-error/codemod.mjs src
24
- ```
25
-
26
- It rewrites these calls:
27
-
28
- ```ts
29
- Sentry.captureException(err) // → reportError(err)
30
- Sentry.captureException(err, { extra: { "qore.invoice.id": id } })
31
- // → reportError(err, { "qore.invoice.id": id })
32
- ```
33
-
34
- It adds the import and removes a named `captureException` import that nothing
35
- uses any more. Run your formatter (the printer may add semicolons), then
36
- `pnpm lint` to see what is left.
37
-
38
- ## By hand
39
-
40
- | You pass | Do this |
41
- |---|---|
42
- | `{ tags: {...} }` | Put the tags in the context: `reportError(err, { "qore.area.name": v })`. Keys follow QDC-OBS-002 (`qore.<area>.<name>`) and QDC-OBS-003 (no personal data). |
43
- | `{ level: "warning" }` or `captureMessage` | It is not an error. Use `Sentry.logger.warn(...)`. |
44
- | `{ user: ... }` | Leave it out. The SDK sets the user from the session; the context carries ids only. |
45
- | a scope callback `(scope) => ...` | Move what the callback sets into the context object. |
46
- | `{ fingerprint: [...] }` | Keep that call as `Sentry.captureException` and suppress the line with a reason: `// eslint-disable-next-line qdc/use-report-error -- custom grouping for <why>`. |
@@ -1,6 +0,0 @@
1
- {
2
- "id": "report-error",
3
- "rule": "use-report-error",
4
- "introducedIn": "0.7.0",
5
- "testOnly": true
6
- }