@quatronic/sdk 0.9.0-test.ce03797 → 0.9.1-rc.3

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 (75) hide show
  1. package/README.md +0 -6
  2. package/dist/{chunk-VQKYPW5V.js → chunk-IFESUTF2.js} +3 -7
  3. package/dist/chunk-IFESUTF2.js.map +1 -0
  4. package/dist/{chunk-WOFBDOMY.js → chunk-POZI4OKJ.js} +2 -2
  5. package/dist/{chunk-YCKDMG4B.js → chunk-TPBRMW5N.js} +1 -30
  6. package/dist/chunk-TPBRMW5N.js.map +1 -0
  7. package/dist/{chunk-P5GBQVO7.js → chunk-YFZB5EW6.js} +2 -2
  8. package/dist/cli/skills-postinstall.js +6 -13
  9. package/dist/cli/skills.js +5 -11
  10. package/dist/eslint/index.d.ts +1 -11
  11. package/dist/eslint/index.js +4 -123
  12. package/dist/eslint/index.js.map +1 -1
  13. package/dist/next/auth/index.d.ts +0 -50
  14. package/dist/next/auth/index.js +101 -504
  15. package/dist/next/auth/index.js.map +1 -1
  16. package/dist/next/boot/index.js +3 -3
  17. package/dist/next/db/index.js +1 -1
  18. package/dist/next/sentry/client.js +3 -3
  19. package/dist/next/sentry/client.js.map +1 -1
  20. package/dist/next/sentry/index.js +1 -1
  21. package/dist/next/sentry/register.js +3 -3
  22. package/dist/node/sentry/index.js +1 -1
  23. package/dist/node/sentry/register.js +2 -2
  24. package/package.json +2 -75
  25. package/skills/catalog.json +0 -3
  26. package/skills/qore-add-api-route/SKILL.md +1 -1
  27. package/skills/qore-add-connection/SKILL.next.md +1 -3
  28. package/skills/qore-add-connection/SKILL.node.md +1 -3
  29. package/skills/qore-add-env-key/SKILL.md +9 -174
  30. package/skills/qore-add-feature/SKILL.md +1 -1
  31. package/skills/qore-add-integration/SKILL.next.md +2 -4
  32. package/skills/qore-add-integration/SKILL.node.md +6 -6
  33. package/skills/qore-add-page/SKILL.md +1 -1
  34. package/skills/qore-author-skill/SKILL.md +1 -1
  35. package/skills/qore-debug-issue/SKILL.md +0 -10
  36. package/skills/qore-observability/SKILL.md +0 -17
  37. package/skills/qore-secure-io/SKILL.md +0 -15
  38. package/skills/qore-ship-checklist/SKILL.md +0 -10
  39. package/skills/qore-translate-strings/SKILL.md +0 -10
  40. package/skills/qore-use-addons/SKILL.md +0 -2
  41. package/skills/qore-use-database/SKILL.md +0 -2
  42. package/skills/qore-use-design-system/SKILL.md +1 -1
  43. package/skills/qore-use-mail-domain/SKILL.next.md +1 -1
  44. package/skills/qore-use-mail-domain/SKILL.node.md +2 -2
  45. package/skills/qore-use-permissions/SKILL.md +0 -10
  46. package/dist/chunk-7XIDABOQ.js +0 -83
  47. package/dist/chunk-7XIDABOQ.js.map +0 -1
  48. package/dist/chunk-VQKYPW5V.js.map +0 -1
  49. package/dist/chunk-YCKDMG4B.js.map +0 -1
  50. package/dist/chunk-YXIYI7R2.js +0 -23
  51. package/dist/chunk-YXIYI7R2.js.map +0 -1
  52. package/dist/context-B_u-vpkw.d.ts +0 -111
  53. package/dist/expo/auth/index.d.ts +0 -8
  54. package/dist/expo/auth/index.js +0 -177
  55. package/dist/expo/auth/index.js.map +0 -1
  56. package/dist/expo/config/index.d.ts +0 -16
  57. package/dist/expo/config/index.js +0 -17
  58. package/dist/expo/config/index.js.map +0 -1
  59. package/dist/expo/log/index.d.ts +0 -9
  60. package/dist/expo/log/index.js +0 -16
  61. package/dist/expo/log/index.js.map +0 -1
  62. package/dist/expo/query/index.d.ts +0 -15
  63. package/dist/expo/query/index.js +0 -52
  64. package/dist/expo/query/index.js.map +0 -1
  65. package/dist/expo/sentry/index.d.ts +0 -29
  66. package/dist/expo/sentry/index.js +0 -93
  67. package/dist/expo/sentry/index.js.map +0 -1
  68. package/dist/expo/testing/index.d.ts +0 -32
  69. package/dist/expo/testing/index.js +0 -57
  70. package/dist/expo/testing/index.js.map +0 -1
  71. package/skills/qore-mobile-add-screen/SKILL.md +0 -58
  72. package/skills/qore-mobile-call-server/SKILL.md +0 -74
  73. package/skills/qore-mobile-run-on-device/SKILL.md +0 -41
  74. /package/dist/{chunk-WOFBDOMY.js.map → chunk-POZI4OKJ.js.map} +0 -0
  75. /package/dist/{chunk-P5GBQVO7.js.map → chunk-YFZB5EW6.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/expo/core/pkce.ts","../../../src/expo/core/url.ts","../../../src/expo/auth/client.ts","../../../src/expo/auth/native.ts","../../../src/expo/auth/index.ts"],"sourcesContent":["const ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\"\n\n/** base64url without padding; no dependency on a global `btoa`. */\nexport function base64url(bytes: Uint8Array): string {\n let out = \"\"\n let i = 0\n for (; i + 2 < bytes.length; i += 3) {\n const n = (bytes[i]! << 16) | (bytes[i + 1]! << 8) | bytes[i + 2]!\n out += ALPHABET[(n >> 18) & 63]! + ALPHABET[(n >> 12) & 63]! + ALPHABET[(n >> 6) & 63]! + ALPHABET[n & 63]!\n }\n const rest = bytes.length - i\n if (rest === 1) {\n const n = bytes[i]! << 16\n out += ALPHABET[(n >> 18) & 63]! + ALPHABET[(n >> 12) & 63]!\n } else if (rest === 2) {\n const n = (bytes[i]! << 16) | (bytes[i + 1]! << 8)\n out += ALPHABET[(n >> 18) & 63]! + ALPHABET[(n >> 12) & 63]! + ALPHABET[(n >> 6) & 63]!\n }\n return out\n}\n\n/** Standard base64 (as a SHA-256 digest comes back) to base64url without padding. */\nexport function base64ToUrl(b64: string): string {\n return b64.replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\")\n}\n\nexport interface PkceCrypto {\n randomBytes(n: number): Uint8Array\n sha256Base64(input: string): Promise<string>\n}\n\n/** A 43-character verifier and its S256 challenge (RFC 7636). */\nexport async function createPkce(crypto: PkceCrypto): Promise<{ verifier: string; challenge: string }> {\n const verifier = base64url(crypto.randomBytes(32))\n const challenge = base64ToUrl(await crypto.sha256Base64(verifier))\n return { verifier, challenge }\n}\n","// URL helpers that do not rely on React Native's partial `URL` polyfill.\n\n/** The first value of query parameter `name` in `url`, decoded; null when absent. */\nexport function queryParam(url: string, name: string): string | null {\n const query = url.split(\"#\", 1)[0]!.split(\"?\")[1]\n if (!query) return null\n for (const pair of query.split(\"&\")) {\n const i = pair.indexOf(\"=\")\n const key = i < 0 ? pair : pair.slice(0, i)\n if (safeDecode(key) !== name) continue\n return i < 0 ? \"\" : safeDecode(pair.slice(i + 1).replace(/\\+/g, \" \"))\n }\n return null\n}\n\nfunction safeDecode(s: string): string {\n try {\n return decodeURIComponent(s)\n } catch {\n return s\n }\n}\n\n/** `serverUrl` without trailing slashes. */\nexport function normalizeOrigin(serverUrl: string): string {\n return serverUrl.replace(/\\/+$/, \"\")\n}\n","// The device half of mobile sign-in. The server half is\n// `createAuthRouteHandlers({ mobile })` in `@quatronic/sdk/next/auth`; change\n// both together. This file imports no React Native module: `native.ts` builds\n// the platform from the real peers, tests hand in a fake one.\nimport { ApiError, Unauthenticated } from \"../core/errors\"\nimport { createPkce, type PkceCrypto } from \"../core/pkce\"\nimport { normalizeOrigin, queryParam } from \"../core/url\"\n\n/** Where the session token lives: the platform keystore, never AsyncStorage. */\nexport const TOKEN_KEY = \"qore.session\"\n\nexport interface AuthPlatform extends PkceCrypto {\n store: {\n get(key: string): Promise<string | null>\n set(key: string, value: string): Promise<void>\n delete(key: string): Promise<void>\n }\n /** The app's own return URL: `exp://…/--/auth/return` in Expo Go, `<scheme>://auth/return` in a build. */\n returnUrl(): string\n /** Opens the system browser on `url` and resolves with the URL it was sent back to, or null when the user closed it. */\n openAuthSession(url: string, returnUrl: string): Promise<string | null>\n openBrowser(url: string): Promise<void>\n fetch: typeof fetch\n}\n\n/** What `/api/auth/me` answers to a bearer caller. */\nexport interface Me {\n sub: string\n email: string | null\n name: string | null\n organizationAlias: string | null\n roles: string[]\n permissions: string[]\n}\n\n/** Why a login did not produce a session. The server sends all but `cancelled` and `failed` itself. */\nexport type LoginFailure = \"cancelled\" | \"expired\" | \"no_app_access\" | \"identity_mismatch\" | \"failed\"\n\nexport type LoginResult = { ok: true } | { ok: false; reason: LoginFailure; detail?: string }\n\nconst SERVER_REASONS: ReadonlySet<string> = new Set([\"cancelled\", \"expired\", \"no_app_access\", \"identity_mismatch\", \"failed\"])\n\nexport interface MobileAuthOptions {\n /** The app's own Next server, e.g. `https://shop.acme.qore.app`. The device talks to nothing else. */\n serverUrl: string\n /** Sent as `X-Qore-App-Version` on every request, so server logs say which build called. */\n appVersion?: string\n}\n\nexport interface MobileAuth {\n login(locale: string): Promise<LoginResult>\n logout(): Promise<void>\n /** Fetch a route of the app's own server (`/api/...`) with the session token. Throws `Unauthenticated` on 401 (the token is cleared), `ApiError` on any other error status. */\n apiFetch<T>(path: string, init?: RequestInit): Promise<T>\n /** Keycloak's \"forgot password\" page in the system browser. Keycloak mails the link; nothing comes back to the app. */\n openPasswordReset(locale: string): Promise<void>\n /** Whether a token is stored. Says nothing about whether the server still accepts it. */\n hasSession(): Promise<boolean>\n readonly serverUrl: string\n}\n\nexport function createMobileAuthWith(platform: AuthPlatform, opts: MobileAuthOptions): MobileAuth {\n const origin = normalizeOrigin(opts.serverUrl)\n const versionHeader = opts.appVersion ? { \"x-qore-app-version\": opts.appVersion } : undefined\n\n function headers(init?: HeadersInit, token?: string): Headers {\n const h = new Headers(init)\n if (versionHeader) h.set(\"x-qore-app-version\", versionHeader[\"x-qore-app-version\"])\n if (token) h.set(\"authorization\", `Bearer ${token}`)\n return h\n }\n\n async function apiFetch<T>(path: string, init: RequestInit = {}): Promise<T> {\n // A relative path only: the token is for the app's own server and nobody else.\n if (!path.startsWith(\"/\") || path.startsWith(\"//\")) throw new Error(`apiFetch takes a path on the app's own server, got \"${path}\"`)\n const token = await platform.store.get(TOKEN_KEY)\n if (!token) throw new Unauthenticated()\n const res = await platform.fetch(`${origin}${path}`, { ...init, headers: headers(init.headers, token) })\n if (res.status === 401) {\n await platform.store.delete(TOKEN_KEY)\n throw new Unauthenticated()\n }\n if (!res.ok) {\n const body = (await res.json().catch(() => null)) as { error?: unknown } | null\n throw new ApiError(res.status, typeof body?.error === \"string\" ? body.error : null)\n }\n if (res.status === 204) return undefined as T\n return (await res.json()) as T\n }\n\n async function login(locale: string): Promise<LoginResult> {\n const { verifier, challenge } = await createPkce(platform)\n const returnUrl = platform.returnUrl()\n const url =\n `${origin}/api/auth/mobile/login?challenge=${encodeURIComponent(challenge)}` +\n `&redirect=${encodeURIComponent(returnUrl)}&locale=${encodeURIComponent(locale)}`\n const back = await platform.openAuthSession(url, returnUrl)\n if (back === null) return { ok: false, reason: \"cancelled\" }\n\n const error = queryParam(back, \"error\")\n if (error !== null) return { ok: false, reason: SERVER_REASONS.has(error) ? (error as LoginFailure) : \"failed\", detail: error }\n const code = queryParam(back, \"code\")\n if (!code) return { ok: false, reason: \"failed\", detail: \"no_code\" }\n\n let res: Response\n try {\n res = await platform.fetch(`${origin}/api/auth/mobile/redeem`, {\n method: \"POST\",\n headers: headers({ \"content-type\": \"application/json\" }),\n body: JSON.stringify({ code, verifier }),\n })\n } catch {\n return { ok: false, reason: \"failed\", detail: \"network\" }\n }\n const body = (await res.json().catch(() => null)) as { token?: unknown; error?: unknown } | null\n if (!res.ok || typeof body?.token !== \"string\") {\n const detail = typeof body?.error === \"string\" ? body.error : `http_${res.status}`\n // The code lives a minute; a slow redeem is an expired login, not a broken one.\n return { ok: false, reason: detail === \"invalid_grant\" ? \"expired\" : \"failed\", detail }\n }\n await platform.store.set(TOKEN_KEY, body.token)\n return { ok: true }\n }\n\n async function logout(): Promise<void> {\n const token = await platform.store.get(TOKEN_KEY)\n await platform.store.delete(TOKEN_KEY)\n if (!token) return\n // Best effort: the local token is already gone, which is what signs the device out.\n await platform.fetch(`${origin}/api/auth/mobile/logout`, { method: \"POST\", headers: headers(undefined, token) }).catch(() => undefined)\n }\n\n async function openPasswordReset(locale: string): Promise<void> {\n await platform.openBrowser(`${origin}/api/auth/mobile/reset-password?locale=${encodeURIComponent(locale)}`)\n }\n\n return {\n login,\n logout,\n apiFetch,\n openPasswordReset,\n hasSession: async () => (await platform.store.get(TOKEN_KEY)) !== null,\n serverUrl: origin,\n }\n}\n","// The only file of `expo/auth` that imports React Native peers.\nimport * as Crypto from \"expo-crypto\"\nimport * as Linking from \"expo-linking\"\nimport * as SecureStore from \"expo-secure-store\"\nimport * as WebBrowser from \"expo-web-browser\"\nimport type { AuthPlatform } from \"./client\"\n\nexport const nativeAuthPlatform: AuthPlatform = {\n randomBytes: (n) => Crypto.getRandomBytes(n),\n sha256Base64: (input) =>\n Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, input, { encoding: Crypto.CryptoEncoding.BASE64 }),\n store: {\n get: (key) => SecureStore.getItemAsync(key),\n set: (key, value) => SecureStore.setItemAsync(key, value),\n delete: (key) => SecureStore.deleteItemAsync(key),\n },\n returnUrl: () => Linking.createURL(\"auth/return\"),\n openAuthSession: async (url, returnUrl) => {\n const result = await WebBrowser.openAuthSessionAsync(url, returnUrl)\n return result.type === \"success\" ? result.url : null\n },\n openBrowser: async (url) => {\n await WebBrowser.openBrowserAsync(url)\n },\n fetch: (input, init) => fetch(input, init),\n}\n","// @quatronic/sdk/expo/auth — sign-in for a Qore mobile app (React Native / Expo).\n// Runs on the device. Its server counterpart is `@quatronic/sdk/next/auth`\n// with `mobile` set; see docs/surfaces.md. Never import this from `src/`.\nimport { createMobileAuthWith, type MobileAuth, type MobileAuthOptions } from \"./client\"\nimport { nativeAuthPlatform } from \"./native\"\n\n/** The device auth client for the app's own server. Create it once, at module scope. */\nexport function createMobileAuth(opts: MobileAuthOptions): MobileAuth {\n return createMobileAuthWith(nativeAuthPlatform, opts)\n}\n\nexport { ApiError, Unauthenticated } from \"../core/errors\"\nexport type { LoginFailure, LoginResult, Me, MobileAuth, MobileAuthOptions } from \"./client\"\nexport { Can, QoreAuthProvider, useAuth, useCan, useMe } from \"./context\"\nexport type { AuthContextValue, AuthStatus, Qore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,OAAO,CAAC;AAAA,EACjH,OAAO;AAAA,IACL,KAAK,CAAC,QAAoB,yBAAa,GAAG;AAAA,IAC1C,KAAK,CAAC,KAAK,UAAsB,yBAAa,KAAK,KAAK;AAAA,IACxD,QAAQ,CAAC,QAAoB,4BAAgB,GAAG;AAAA,EAClD;AAAA,EACA,WAAW,MAAc,kBAAU,aAAa;AAAA,EAChD,iBAAiB,OAAO,KAAK,cAAc;AACzC,UAAM,SAAS,MAAiB,gCAAqB,KAAK,SAAS;AACnE,WAAO,OAAO,SAAS,YAAY,OAAO,MAAM;AAAA,EAClD;AAAA,EACA,aAAa,OAAO,QAAQ;AAC1B,UAAiB,4BAAiB,GAAG;AAAA,EACvC;AAAA,EACA,OAAO,CAAC,OAAO,SAAS,MAAM,OAAO,IAAI;AAC3C;;;AClBO,SAAS,iBAAiB,MAAqC;AACpE,SAAO,qBAAqB,oBAAoB,IAAI;AACtD;","names":[]}
@@ -1,16 +0,0 @@
1
- interface MobileConfigInput {
2
- /** `EXPO_PUBLIC_SERVER_URL`: the app's own server. */
3
- serverUrl: string;
4
- /** `EXPO_PUBLIC_SENTRY_DSN`; empty turns Sentry off. */
5
- sentryDsn: string;
6
- /** `EXPO_PUBLIC_QORE_ENV`. */
7
- qoreEnv: string;
8
- }
9
- interface ConfigProblem {
10
- key: string;
11
- problem: string;
12
- }
13
- /** Empty when the build can run. */
14
- declare function checkConfig(c: MobileConfigInput): ConfigProblem[];
15
-
16
- export { type ConfigProblem, type MobileConfigInput, checkConfig };
@@ -1,17 +0,0 @@
1
- // src/expo/config/index.ts
2
- function checkConfig(c) {
3
- const problems = [];
4
- if (!isOrigin(c.serverUrl)) problems.push({ key: "EXPO_PUBLIC_SERVER_URL", problem: "must be an https:// origin" });
5
- if (c.sentryDsn && !/^https:\/\/\S+$/i.test(c.sentryDsn))
6
- problems.push({ key: "EXPO_PUBLIC_SENTRY_DSN", problem: "must be an https:// DSN, or empty to turn Sentry off" });
7
- if (!/^[a-z][a-z0-9-]*$/.test(c.qoreEnv))
8
- problems.push({ key: "EXPO_PUBLIC_QORE_ENV", problem: "must be an environment name such as staging" });
9
- return problems;
10
- }
11
- function isOrigin(raw) {
12
- return /^https:\/\/[a-z0-9.-]+(?::\d{1,5})?\/*$/i.test(raw);
13
- }
14
- export {
15
- checkConfig
16
- };
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/expo/config/index.ts"],"sourcesContent":["// @quatronic/sdk/expo/config — checks the mobile app's public config. The web\n// app refuses to boot on a bad env; a phone shows the problems on screen,\n// since nobody reads its log. Pure: no React Native import.\n\nexport interface MobileConfigInput {\n /** `EXPO_PUBLIC_SERVER_URL`: the app's own server. */\n serverUrl: string\n /** `EXPO_PUBLIC_SENTRY_DSN`; empty turns Sentry off. */\n sentryDsn: string\n /** `EXPO_PUBLIC_QORE_ENV`. */\n qoreEnv: string\n}\n\nexport interface ConfigProblem {\n key: string\n problem: string\n}\n\n/** Empty when the build can run. */\nexport function checkConfig(c: MobileConfigInput): ConfigProblem[] {\n const problems: ConfigProblem[] = []\n if (!isOrigin(c.serverUrl)) problems.push({ key: \"EXPO_PUBLIC_SERVER_URL\", problem: \"must be an https:// origin\" })\n if (c.sentryDsn && !/^https:\\/\\/\\S+$/i.test(c.sentryDsn))\n problems.push({ key: \"EXPO_PUBLIC_SENTRY_DSN\", problem: \"must be an https:// DSN, or empty to turn Sentry off\" })\n if (!/^[a-z][a-z0-9-]*$/.test(c.qoreEnv))\n problems.push({ key: \"EXPO_PUBLIC_QORE_ENV\", problem: \"must be an environment name such as staging\" })\n return problems\n}\n\n// A regex, not `new URL`: React Native's URL polyfill is partial.\nfunction isOrigin(raw: string): boolean {\n return /^https:\\/\\/[a-z0-9.-]+(?::\\d{1,5})?\\/*$/i.test(raw)\n}\n"],"mappings":";AAmBO,SAAS,YAAY,GAAuC;AACjE,QAAM,WAA4B,CAAC;AACnC,MAAI,CAAC,SAAS,EAAE,SAAS,EAAG,UAAS,KAAK,EAAE,KAAK,0BAA0B,SAAS,6BAA6B,CAAC;AAClH,MAAI,EAAE,aAAa,CAAC,mBAAmB,KAAK,EAAE,SAAS;AACrD,aAAS,KAAK,EAAE,KAAK,0BAA0B,SAAS,uDAAuD,CAAC;AAClH,MAAI,CAAC,oBAAoB,KAAK,EAAE,OAAO;AACrC,aAAS,KAAK,EAAE,KAAK,wBAAwB,SAAS,8CAA8C,CAAC;AACvG,SAAO;AACT;AAGA,SAAS,SAAS,KAAsB;AACtC,SAAO,2CAA2C,KAAK,GAAG;AAC5D;","names":[]}
@@ -1,9 +0,0 @@
1
- type LogAttributes = Record<string, string | number | boolean>;
2
- declare const log: {
3
- debug: (message: string, attrs?: LogAttributes) => void;
4
- info: (message: string, attrs?: LogAttributes) => void;
5
- warn: (message: string, attrs?: LogAttributes) => void;
6
- error: (message: string, attrs?: LogAttributes) => void;
7
- };
8
-
9
- export { type LogAttributes, log };
@@ -1,16 +0,0 @@
1
- // src/expo/log/index.ts
2
- import * as Sentry from "@sentry/react-native";
3
- function emit(level, message, attrs) {
4
- if (typeof __DEV__ !== "undefined" && __DEV__) console.log(`[${level}] ${message}`, attrs ?? "");
5
- Sentry.logger[level](message, attrs);
6
- }
7
- var log = {
8
- debug: (message, attrs) => emit("debug", message, attrs),
9
- info: (message, attrs) => emit("info", message, attrs),
10
- warn: (message, attrs) => emit("warn", message, attrs),
11
- error: (message, attrs) => emit("error", message, attrs)
12
- };
13
- export {
14
- log
15
- };
16
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/expo/log/index.ts"],"sourcesContent":["// @quatronic/sdk/expo/log — the mobile app's logger. Lines go to Sentry Logs\n// (tag app=mobile); in development they are printed too. Attributes are\n// filterable values: no names or addresses (they are scrubbed anyway).\n// The server's counterpart is the `Sentry.logger` the Next app already uses.\nimport * as Sentry from \"@sentry/react-native\"\n\nexport type LogAttributes = Record<string, string | number | boolean>\ntype Level = \"debug\" | \"info\" | \"warn\" | \"error\"\n\nfunction emit(level: Level, message: string, attrs?: LogAttributes): void {\n if (typeof __DEV__ !== \"undefined\" && __DEV__) console.log(`[${level}] ${message}`, attrs ?? \"\")\n Sentry.logger[level](message, attrs)\n}\n\nexport const log = {\n debug: (message: string, attrs?: LogAttributes) => emit(\"debug\", message, attrs),\n info: (message: string, attrs?: LogAttributes) => emit(\"info\", message, attrs),\n warn: (message: string, attrs?: LogAttributes) => emit(\"warn\", message, attrs),\n error: (message: string, attrs?: LogAttributes) => emit(\"error\", message, attrs),\n}\n"],"mappings":";AAIA,YAAY,YAAY;AAKxB,SAAS,KAAK,OAAc,SAAiB,OAA6B;AACxE,MAAI,OAAO,YAAY,eAAe,QAAS,SAAQ,IAAI,IAAI,KAAK,KAAK,OAAO,IAAI,SAAS,EAAE;AAC/F,EAAO,cAAO,KAAK,EAAE,SAAS,KAAK;AACrC;AAEO,IAAM,MAAM;AAAA,EACjB,OAAO,CAAC,SAAiB,UAA0B,KAAK,SAAS,SAAS,KAAK;AAAA,EAC/E,MAAM,CAAC,SAAiB,UAA0B,KAAK,QAAQ,SAAS,KAAK;AAAA,EAC7E,MAAM,CAAC,SAAiB,UAA0B,KAAK,QAAQ,SAAS,KAAK;AAAA,EAC7E,OAAO,CAAC,SAAiB,UAA0B,KAAK,SAAS,SAAS,KAAK;AACjF;","names":[]}
@@ -1,15 +0,0 @@
1
- import { QueryClient } from '@tanstack/react-query';
2
-
3
- /** Retrying cannot fix a missing session or a request the server refused. */
4
- declare function shouldRetry(failureCount: number, error: unknown): boolean;
5
- interface QueryClientOptions {
6
- /** Runs when any query or mutation finds the session gone. Wire it to `useAuth().expire`. */
7
- onUnauthenticated: () => void;
8
- /** How long a result counts as fresh. Default 30 s. */
9
- staleTime?: number;
10
- }
11
-
12
- /** The app's query client. Create it once, inside the auth provider, so `onUnauthenticated` can reach `expire`. */
13
- declare function createQueryClient(opts: QueryClientOptions): QueryClient;
14
-
15
- export { type QueryClientOptions, createQueryClient, shouldRetry };
@@ -1,52 +0,0 @@
1
- import {
2
- ApiError,
3
- Unauthenticated
4
- } from "../../chunk-YXIYI7R2.js";
5
-
6
- // src/expo/query/index.ts
7
- import NetInfo from "@react-native-community/netinfo";
8
- import { focusManager, onlineManager } from "@tanstack/react-query";
9
- import { AppState, Platform } from "react-native";
10
-
11
- // src/expo/query/core.ts
12
- import { QueryCache, QueryClient } from "@tanstack/react-query";
13
- function shouldRetry(failureCount, error) {
14
- if (error instanceof Unauthenticated) return false;
15
- if (error instanceof ApiError && error.status < 500) return false;
16
- return failureCount < 2;
17
- }
18
- function createQueryClientCore({ onUnauthenticated, staleTime = 3e4 }) {
19
- const onError = (error) => {
20
- if (error instanceof Unauthenticated) onUnauthenticated();
21
- };
22
- return new QueryClient({
23
- queryCache: new QueryCache({ onError }),
24
- defaultOptions: {
25
- queries: { retry: shouldRetry, staleTime },
26
- // A mutation is not repeated behind the user's back.
27
- mutations: { retry: false, onError }
28
- }
29
- });
30
- }
31
-
32
- // src/expo/query/index.ts
33
- var wired = false;
34
- function wireDeviceEvents() {
35
- if (wired) return;
36
- wired = true;
37
- onlineManager.setEventListener((setOnline) => NetInfo.addEventListener((state) => setOnline(state.isConnected !== false)));
38
- focusManager.setEventListener((setFocused) => {
39
- if (Platform.OS === "web") return void 0;
40
- const sub = AppState.addEventListener("change", (s) => setFocused(s === "active"));
41
- return () => sub.remove();
42
- });
43
- }
44
- function createQueryClient(opts) {
45
- wireDeviceEvents();
46
- return createQueryClientCore(opts);
47
- }
48
- export {
49
- createQueryClient,
50
- shouldRetry
51
- };
52
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/expo/query/index.ts","../../../src/expo/query/core.ts"],"sourcesContent":["// @quatronic/sdk/expo/query — TanStack Query set up for a phone. Runs on the\n// device; the web app has its own client. See docs/surfaces.md.\nimport NetInfo from \"@react-native-community/netinfo\"\nimport { focusManager, onlineManager, type QueryClient } from \"@tanstack/react-query\"\nimport { AppState, Platform } from \"react-native\"\nimport { createQueryClientCore, type QueryClientOptions } from \"./core\"\n\nlet wired = false\n\n/** Queries pause offline and resume on reconnect; \"window focus\" is the app returning to the foreground. Installed once per process. */\nfunction wireDeviceEvents(): void {\n if (wired) return\n wired = true\n onlineManager.setEventListener((setOnline) => NetInfo.addEventListener((state) => setOnline(state.isConnected !== false)))\n focusManager.setEventListener((setFocused) => {\n if (Platform.OS === \"web\") return undefined\n const sub = AppState.addEventListener(\"change\", (s) => setFocused(s === \"active\"))\n return () => sub.remove()\n })\n}\n\n/** The app's query client. Create it once, inside the auth provider, so `onUnauthenticated` can reach `expire`. */\nexport function createQueryClient(opts: QueryClientOptions): QueryClient {\n wireDeviceEvents()\n return createQueryClientCore(opts)\n}\n\nexport { shouldRetry } from \"./core\"\nexport type { QueryClientOptions } from \"./core\"\n","// Pure half of `expo/query`: no React Native import, so it is unit-tested in Node.\nimport { QueryCache, QueryClient } from \"@tanstack/react-query\"\nimport { ApiError, Unauthenticated } from \"../core/errors\"\n\n/** Retrying cannot fix a missing session or a request the server refused. */\nexport function shouldRetry(failureCount: number, error: unknown): boolean {\n if (error instanceof Unauthenticated) return false\n if (error instanceof ApiError && error.status < 500) return false\n return failureCount < 2\n}\n\nexport interface QueryClientOptions {\n /** Runs when any query or mutation finds the session gone. Wire it to `useAuth().expire`. */\n onUnauthenticated: () => void\n /** How long a result counts as fresh. Default 30 s. */\n staleTime?: number\n}\n\nexport function createQueryClientCore({ onUnauthenticated, staleTime = 30_000 }: QueryClientOptions): QueryClient {\n const onError = (error: unknown) => {\n if (error instanceof Unauthenticated) onUnauthenticated()\n }\n return new QueryClient({\n queryCache: new QueryCache({ onError }),\n defaultOptions: {\n queries: { retry: shouldRetry, staleTime },\n // A mutation is not repeated behind the user's back.\n mutations: { retry: false, onError },\n },\n })\n}\n"],"mappings":";;;;;;AAEA,OAAO,aAAa;AACpB,SAAS,cAAc,qBAAuC;AAC9D,SAAS,UAAU,gBAAgB;;;ACHnC,SAAS,YAAY,mBAAmB;AAIjC,SAAS,YAAY,cAAsB,OAAyB;AACzE,MAAI,iBAAiB,gBAAiB,QAAO;AAC7C,MAAI,iBAAiB,YAAY,MAAM,SAAS,IAAK,QAAO;AAC5D,SAAO,eAAe;AACxB;AASO,SAAS,sBAAsB,EAAE,mBAAmB,YAAY,IAAO,GAAoC;AAChH,QAAM,UAAU,CAAC,UAAmB;AAClC,QAAI,iBAAiB,gBAAiB,mBAAkB;AAAA,EAC1D;AACA,SAAO,IAAI,YAAY;AAAA,IACrB,YAAY,IAAI,WAAW,EAAE,QAAQ,CAAC;AAAA,IACtC,gBAAgB;AAAA,MACd,SAAS,EAAE,OAAO,aAAa,UAAU;AAAA;AAAA,MAEzC,WAAW,EAAE,OAAO,OAAO,QAAQ;AAAA,IACrC;AAAA,EACF,CAAC;AACH;;;ADvBA,IAAI,QAAQ;AAGZ,SAAS,mBAAyB;AAChC,MAAI,MAAO;AACX,UAAQ;AACR,gBAAc,iBAAiB,CAAC,cAAc,QAAQ,iBAAiB,CAAC,UAAU,UAAU,MAAM,gBAAgB,KAAK,CAAC,CAAC;AACzH,eAAa,iBAAiB,CAAC,eAAe;AAC5C,QAAI,SAAS,OAAO,MAAO,QAAO;AAClC,UAAM,MAAM,SAAS,iBAAiB,UAAU,CAAC,MAAM,WAAW,MAAM,QAAQ,CAAC;AACjF,WAAO,MAAM,IAAI,OAAO;AAAA,EAC1B,CAAC;AACH;AAGO,SAAS,kBAAkB,MAAuC;AACvE,mBAAiB;AACjB,SAAO,sBAAsB,IAAI;AACnC;","names":[]}
@@ -1,29 +0,0 @@
1
- import { ComponentType } from 'react';
2
-
3
- interface MobileSentryConfig {
4
- /** The module's Sentry DSN (public by design). Empty turns Sentry off. */
5
- dsn: string;
6
- /** The Qore environment name, the same as the server's `QORE_ENV`, so phone and server filter together. */
7
- environment: string;
8
- /** The app's own server. Trace headers go there and nowhere else. */
9
- serverUrl: string;
10
- /** Defaults to `<slug>@<version>+<build>` from the app config. */
11
- release?: string;
12
- }
13
- /** `<slug>@<version>+<build>`; the build is left off when unknown (Expo Go). */
14
- declare function releaseName(slug: string | undefined, version: string | undefined, build: string | null | undefined): string;
15
-
16
- /** Call once, at the top of the root layout module, before anything renders. No DSN, no Sentry. */
17
- declare function qoreSentryInit(cfg: MobileSentryConfig): void;
18
- /** On sign-in and sign-out: the Keycloak subject only, as on the server. Pass it to `QoreAuthProvider`'s `onUserChange`. */
19
- declare function setTelemetryUser(sub: string | null): void;
20
- /**
21
- * In the root layout, with Expo Router's `useNavigationContainerRef()`: one
22
- * transaction per screen, tab switches included, which the screen's API calls
23
- * hang under.
24
- */
25
- declare function useNavigationTelemetry(navigationRef: unknown): void;
26
- /** Wrap the root layout's default export: catches render errors and adds touch breadcrumbs. */
27
- declare function wrap<P extends object>(component: ComponentType<P>): ComponentType<P>;
28
-
29
- export { type MobileSentryConfig, qoreSentryInit, releaseName, setTelemetryUser, useNavigationTelemetry, wrap };
@@ -1,93 +0,0 @@
1
- import {
2
- SECRET_PARAMS,
3
- scrubEvent,
4
- scrubLog,
5
- scrubSpan
6
- } from "../../chunk-VQKYPW5V.js";
7
-
8
- // src/expo/sentry/index.ts
9
- import * as Sentry from "@sentry/react-native";
10
- import Constants from "expo-constants";
11
- import { useEffect } from "react";
12
-
13
- // src/expo/sentry/options.ts
14
- var APP_TAG = { app: "mobile" };
15
- var tagLog = (l) => {
16
- const scrubbed = scrubLog(l);
17
- scrubbed.attributes = { ...scrubbed.attributes, ...APP_TAG };
18
- return scrubbed;
19
- };
20
- var tagSpan = (s) => {
21
- const scrubbed = scrubSpan(s);
22
- scrubbed.data = { ...scrubbed.data, ...APP_TAG };
23
- return scrubbed;
24
- };
25
- var escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
26
- function releaseName(slug, version, build) {
27
- return `${slug || "app"}@${version || "0.0.0"}${build ? `+${build}` : ""}`;
28
- }
29
- function buildMobileOptions(cfg) {
30
- const production = cfg.environment === "production";
31
- const origin = cfg.serverUrl.replace(/\/+$/, "");
32
- return {
33
- dsn: cfg.dsn,
34
- environment: cfg.environment,
35
- release: cfg.release,
36
- // Who it was is the Keycloak subject (setTelemetryUser), never a name or address.
37
- sendDefaultPii: false,
38
- dataCollection: { urlQueryParams: { deny: [...SECRET_PARAMS] } },
39
- // The origin plus a path boundary, so `https://app.example` does not match `https://app.example.evil`.
40
- tracePropagationTargets: [new RegExp(`^${escapeRe(origin)}(?:[/?#]|$)`)],
41
- tracesSampleRate: production ? 0.1 : 1,
42
- enableLogs: true,
43
- // Logs are what the app says through `log`, not whatever reaches console.
44
- enableAutoConsoleLogs: false,
45
- replaysSessionSampleRate: production ? 0.1 : 1,
46
- replaysOnErrorSampleRate: 1,
47
- initialScope: { tags: { ...APP_TAG } },
48
- beforeSend: scrubEvent,
49
- beforeSendTransaction: scrubEvent,
50
- beforeSendLog: tagLog,
51
- beforeSendSpan: tagSpan
52
- };
53
- }
54
- var NAVIGATION_OPTIONS = {
55
- ignoreEmptyBackNavigationTransactions: false,
56
- // `(tabs)/explore`, not `explore`: the route file, so two screens with one name stay apart.
57
- useFullPathsForNavigationRoutes: true,
58
- enableTimeToInitialDisplay: true
59
- };
60
- var REPLAY_OPTIONS = { maskAllText: true, maskAllImages: true, maskAllVectors: true };
61
-
62
- // src/expo/sentry/index.ts
63
- var navigation = Sentry.reactNavigationIntegration({ ...NAVIGATION_OPTIONS });
64
- var enabled = false;
65
- function qoreSentryInit(cfg) {
66
- if (!cfg.dsn || enabled) return;
67
- enabled = true;
68
- const release = cfg.release ?? releaseName(Constants.expoConfig?.slug, Constants.expoConfig?.version, Constants.nativeBuildVersion);
69
- Sentry.init({
70
- ...buildMobileOptions({ ...cfg, release }),
71
- // Replay is native only: Expo Go skips it, a development or store build records.
72
- integrations: [navigation, Sentry.mobileReplayIntegration({ ...REPLAY_OPTIONS })]
73
- });
74
- }
75
- function setTelemetryUser(sub) {
76
- if (enabled) Sentry.setUser(sub ? { id: sub } : null);
77
- }
78
- function useNavigationTelemetry(navigationRef) {
79
- useEffect(() => {
80
- if (enabled && navigationRef) navigation.registerNavigationContainer(navigationRef);
81
- }, [navigationRef]);
82
- }
83
- function wrap2(component) {
84
- return Sentry.wrap(component);
85
- }
86
- export {
87
- qoreSentryInit,
88
- releaseName,
89
- setTelemetryUser,
90
- useNavigationTelemetry,
91
- wrap2 as wrap
92
- };
93
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/expo/sentry/index.ts","../../../src/expo/sentry/options.ts"],"sourcesContent":["// @quatronic/sdk/expo/sentry — errors, traces, logs and masked Replay for a\n// Qore mobile app, into the module's Sentry project with tag app=mobile.\n// Runs on the device; the web counterpart is `@quatronic/sdk/next/sentry`.\nimport * as Sentry from \"@sentry/react-native\"\nimport Constants from \"expo-constants\"\nimport { useEffect, type ComponentType } from \"react\"\nimport { buildMobileOptions, NAVIGATION_OPTIONS, releaseName, REPLAY_OPTIONS, type MobileSentryConfig } from \"./options\"\n\n// Created at import, as Sentry requires, and registered by useNavigationTelemetry.\n// Sentry's expoRouterIntegration looks for a module Expo Router 58 no longer\n// ships and then does nothing, so the container is registered by hand.\nconst navigation = Sentry.reactNavigationIntegration({ ...NAVIGATION_OPTIONS })\nlet enabled = false\n\n/** Call once, at the top of the root layout module, before anything renders. No DSN, no Sentry. */\nexport function qoreSentryInit(cfg: MobileSentryConfig): void {\n if (!cfg.dsn || enabled) return\n enabled = true\n const release = cfg.release ?? releaseName(Constants.expoConfig?.slug, Constants.expoConfig?.version, Constants.nativeBuildVersion)\n Sentry.init({\n ...buildMobileOptions({ ...cfg, release }),\n // Replay is native only: Expo Go skips it, a development or store build records.\n integrations: [navigation, Sentry.mobileReplayIntegration({ ...REPLAY_OPTIONS })],\n })\n}\n\n/** On sign-in and sign-out: the Keycloak subject only, as on the server. Pass it to `QoreAuthProvider`'s `onUserChange`. */\nexport function setTelemetryUser(sub: string | null): void {\n if (enabled) Sentry.setUser(sub ? { id: sub } : null)\n}\n\n/**\n * In the root layout, with Expo Router's `useNavigationContainerRef()`: one\n * transaction per screen, tab switches included, which the screen's API calls\n * hang under.\n */\nexport function useNavigationTelemetry(navigationRef: unknown): void {\n useEffect(() => {\n if (enabled && navigationRef) navigation.registerNavigationContainer(navigationRef)\n }, [navigationRef])\n}\n\n/** Wrap the root layout's default export: catches render errors and adds touch breadcrumbs. */\nexport function wrap<P extends object>(component: ComponentType<P>): ComponentType<P> {\n return Sentry.wrap(component)\n}\n\nexport { releaseName } from \"./options\"\nexport type { MobileSentryConfig } from \"./options\"\n","// Pure half of `expo/sentry`: the init options, unit-tested in Node.\nimport { SECRET_PARAMS, scrubEvent, scrubLog, scrubSpan } from \"../../sentry-core/scrub\"\n\nexport interface MobileSentryConfig {\n /** The module's Sentry DSN (public by design). Empty turns Sentry off. */\n dsn: string\n /** The Qore environment name, the same as the server's `QORE_ENV`, so phone and server filter together. */\n environment: string\n /** The app's own server. Trace headers go there and nowhere else. */\n serverUrl: string\n /** Defaults to `<slug>@<version>+<build>` from the app config. */\n release?: string\n}\n\n/** Tells phone events from server ones in the shared project. */\nconst APP_TAG = { app: \"mobile\" } as const\n\n// The scope's tags reach errors and transactions only: Sentry Logs and child\n// spans never see them, so those carry the tag as an attribute.\nconst tagLog = <L extends Parameters<typeof scrubLog>[0]>(l: L): L => {\n const scrubbed = scrubLog(l)\n scrubbed.attributes = { ...scrubbed.attributes, ...APP_TAG }\n return scrubbed\n}\nconst tagSpan = <S extends Parameters<typeof scrubSpan>[0]>(s: S): S => {\n const scrubbed = scrubSpan(s)\n scrubbed.data = { ...scrubbed.data, ...APP_TAG }\n return scrubbed\n}\n\nconst escapeRe = (s: string) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n\n/** `<slug>@<version>+<build>`; the build is left off when unknown (Expo Go). */\nexport function releaseName(slug: string | undefined, version: string | undefined, build: string | null | undefined): string {\n return `${slug || \"app\"}@${version || \"0.0.0\"}${build ? `+${build}` : \"\"}`\n}\n\n/**\n * Everything `Sentry.init` gets except the integrations, which need the\n * native module. Scrubbing is the server's (`sentry-core/scrub`), so the\n * phone and the server redact the same things.\n */\nexport function buildMobileOptions(cfg: MobileSentryConfig & { release: string }) {\n const production = cfg.environment === \"production\"\n const origin = cfg.serverUrl.replace(/\\/+$/, \"\")\n return {\n dsn: cfg.dsn,\n environment: cfg.environment,\n release: cfg.release,\n // Who it was is the Keycloak subject (setTelemetryUser), never a name or address.\n sendDefaultPii: false,\n dataCollection: { urlQueryParams: { deny: [...SECRET_PARAMS] } },\n // The origin plus a path boundary, so `https://app.example` does not match `https://app.example.evil`.\n tracePropagationTargets: [new RegExp(`^${escapeRe(origin)}(?:[/?#]|$)`)],\n tracesSampleRate: production ? 0.1 : 1,\n enableLogs: true,\n // Logs are what the app says through `log`, not whatever reaches console.\n enableAutoConsoleLogs: false,\n replaysSessionSampleRate: production ? 0.1 : 1,\n replaysOnErrorSampleRate: 1,\n initialScope: { tags: { ...APP_TAG } },\n beforeSend: scrubEvent,\n beforeSendTransaction: scrubEvent,\n beforeSendLog: tagLog,\n beforeSendSpan: tagSpan,\n }\n}\n\n/**\n * The navigation integration's options. With Sentry's default\n * (`ignoreEmptyBackNavigationTransactions: true`) a navigation to a route it\n * has seen before is dropped when nothing hangs under it — which is exactly a\n * switch back to a tab that is already mounted, so tab switches never showed up.\n */\nexport const NAVIGATION_OPTIONS = {\n ignoreEmptyBackNavigationTransactions: false,\n // `(tabs)/explore`, not `explore`: the route file, so two screens with one name stay apart.\n useFullPathsForNavigationRoutes: true,\n enableTimeToInitialDisplay: true,\n} as const\n\n/** Session Replay records shapes only: every text, image and vector is masked on the phone. Never unmask by default. */\nexport const REPLAY_OPTIONS = { maskAllText: true, maskAllImages: true, maskAllVectors: true } as const\n"],"mappings":";;;;;;;;AAGA,YAAY,YAAY;AACxB,OAAO,eAAe;AACtB,SAAS,iBAAqC;;;ACU9C,IAAM,UAAU,EAAE,KAAK,SAAS;AAIhC,IAAM,SAAS,CAA2C,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M,eAAe,MAAM,gBAAgB,KAAK;;;ADvE7F,IAAM,aAAoB,kCAA2B,EAAE,GAAG,mBAAmB,CAAC;AAC9E,IAAI,UAAU;AAGP,SAAS,eAAe,KAA+B;AAC5D,MAAI,CAAC,IAAI,OAAO,QAAS;AACzB,YAAU;AACV,QAAM,UAAU,IAAI,WAAW,YAAY,UAAU,YAAY,MAAM,UAAU,YAAY,SAAS,UAAU,kBAAkB;AAClI,EAAO,YAAK;AAAA,IACV,GAAG,mBAAmB,EAAE,GAAG,KAAK,QAAQ,CAAC;AAAA;AAAA,IAEzC,cAAc,CAAC,YAAmB,+BAAwB,EAAE,GAAG,eAAe,CAAC,CAAC;AAAA,EAClF,CAAC;AACH;AAGO,SAAS,iBAAiB,KAA0B;AACzD,MAAI,QAAS,CAAO,eAAQ,MAAM,EAAE,IAAI,IAAI,IAAI,IAAI;AACtD;AAOO,SAAS,uBAAuB,eAA8B;AACnE,YAAU,MAAM;AACd,QAAI,WAAW,cAAe,YAAW,4BAA4B,aAAa;AAAA,EACpF,GAAG,CAAC,aAAa,CAAC;AACpB;AAGO,SAASA,MAAuB,WAA+C;AACpF,SAAc,YAAK,SAAS;AAC9B;","names":["wrap"]}
@@ -1,32 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import { QueryClient } from '@tanstack/react-query';
4
- import { c as AuthStatus, a as MobileAuth, e as Me } from '../../context-B_u-vpkw.js';
5
- export { A as ApiError, U as Unauthenticated } from '../../context-B_u-vpkw.js';
6
-
7
- type Route = unknown;
8
- /**
9
- * A `MobileAuth` whose `apiFetch` answers from `routes`: path → body, or a
10
- * function of the request init. A missing route throws `ApiError(404)`; an
11
- * `Error` value is thrown as is (use `new Unauthenticated()` for a 401).
12
- */
13
- declare function mockApiFetch(routes?: Record<string, Route>): MobileAuth;
14
- /** A signed-in user with no roles; override what the test needs. */
15
- declare const testUser: (over?: Partial<Me>) => Me;
16
- interface MockAuthProviderProps {
17
- children: ReactNode;
18
- /** Default: signed in as `testUser()`. */
19
- status?: AuthStatus;
20
- auth?: MobileAuth;
21
- signIn?: (locale: string) => Promise<void>;
22
- signOut?: () => Promise<void>;
23
- }
24
- declare function MockAuthProvider({ children, status, auth, signIn, signOut }: MockAuthProviderProps): react.JSX.Element;
25
- /** A query client for one test: no retries, nothing kept between tests. */
26
- declare function createTestQueryClient(): QueryClient;
27
- /** `MockAuthProvider` inside a fresh `QueryClientProvider`. */
28
- declare function TestProviders({ children, client, ...auth }: MockAuthProviderProps & {
29
- client?: QueryClient;
30
- }): react.JSX.Element;
31
-
32
- export { AuthStatus, Me, MobileAuth, MockAuthProvider, type MockAuthProviderProps, TestProviders, createTestQueryClient, mockApiFetch, testUser };
@@ -1,57 +0,0 @@
1
- import {
2
- AuthContextProvider
3
- } from "../../chunk-7XIDABOQ.js";
4
- import {
5
- ApiError,
6
- Unauthenticated
7
- } from "../../chunk-YXIYI7R2.js";
8
-
9
- // src/expo/testing/index.tsx
10
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
11
- import { jsx } from "react/jsx-runtime";
12
- function mockApiFetch(routes = {}) {
13
- return {
14
- serverUrl: "https://app.test",
15
- login: async () => ({ ok: true }),
16
- logout: async () => void 0,
17
- openPasswordReset: async () => void 0,
18
- hasSession: async () => true,
19
- apiFetch: async (path, init) => {
20
- if (!(path in routes)) throw new ApiError(404, "not_found");
21
- const route = routes[path];
22
- const value = typeof route === "function" ? route(init) : route;
23
- if (value instanceof Error) throw value;
24
- return value;
25
- }
26
- };
27
- }
28
- var testUser = (over = {}) => ({
29
- sub: "user-1",
30
- email: null,
31
- name: "Test User",
32
- organizationAlias: "acme",
33
- roles: [],
34
- permissions: [],
35
- ...over
36
- });
37
- var noop = async () => void 0;
38
- function MockAuthProvider({ children, status = { state: "signedIn", me: testUser() }, auth, signIn, signOut }) {
39
- const value = { status, auth: auth ?? mockApiFetch(), signIn: signIn ?? noop, signOut: signOut ?? noop, refresh: noop, expire: () => void 0 };
40
- return /* @__PURE__ */ jsx(AuthContextProvider, { value, children });
41
- }
42
- function createTestQueryClient() {
43
- return new QueryClient({ defaultOptions: { queries: { retry: false, gcTime: 0 }, mutations: { retry: false } } });
44
- }
45
- function TestProviders({ children, client, ...auth }) {
46
- return /* @__PURE__ */ jsx(QueryClientProvider, { client: client ?? createTestQueryClient(), children: /* @__PURE__ */ jsx(MockAuthProvider, { ...auth, children }) });
47
- }
48
- export {
49
- ApiError,
50
- MockAuthProvider,
51
- TestProviders,
52
- Unauthenticated,
53
- createTestQueryClient,
54
- mockApiFetch,
55
- testUser
56
- };
57
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/expo/testing/index.tsx"],"sourcesContent":["// @quatronic/sdk/expo/testing — for the mobile app's component tests (jest).\n// Provides the same auth context as `QoreAuthProvider`, with a fixed status.\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\"\nimport type { ReactNode } from \"react\"\nimport type { Me, MobileAuth } from \"../auth/client\"\nimport { AuthContextProvider, type AuthStatus } from \"../auth/context\"\nimport { ApiError } from \"../core/errors\"\n\ntype Route = unknown\n\n/**\n * A `MobileAuth` whose `apiFetch` answers from `routes`: path → body, or a\n * function of the request init. A missing route throws `ApiError(404)`; an\n * `Error` value is thrown as is (use `new Unauthenticated()` for a 401).\n */\nexport function mockApiFetch(routes: Record<string, Route> = {}): MobileAuth {\n return {\n serverUrl: \"https://app.test\",\n login: async () => ({ ok: true }),\n logout: async () => undefined,\n openPasswordReset: async () => undefined,\n hasSession: async () => true,\n apiFetch: async <T,>(path: string, init?: RequestInit): Promise<T> => {\n if (!(path in routes)) throw new ApiError(404, \"not_found\")\n const route = routes[path]\n const value = typeof route === \"function\" ? (route as (i: RequestInit | undefined) => unknown)(init) : route\n if (value instanceof Error) throw value\n return value as T\n },\n }\n}\n\n/** A signed-in user with no roles; override what the test needs. */\nexport const testUser = (over: Partial<Me> = {}): Me => ({\n sub: \"user-1\",\n email: null,\n name: \"Test User\",\n organizationAlias: \"acme\",\n roles: [],\n permissions: [],\n ...over,\n})\n\nexport interface MockAuthProviderProps {\n children: ReactNode\n /** Default: signed in as `testUser()`. */\n status?: AuthStatus\n auth?: MobileAuth\n signIn?: (locale: string) => Promise<void>\n signOut?: () => Promise<void>\n}\n\nconst noop = async () => undefined\n\nexport function MockAuthProvider({ children, status = { state: \"signedIn\", me: testUser() }, auth, signIn, signOut }: MockAuthProviderProps) {\n const value = { status, auth: auth ?? mockApiFetch(), signIn: signIn ?? noop, signOut: signOut ?? noop, refresh: noop, expire: () => undefined }\n return <AuthContextProvider value={value}>{children}</AuthContextProvider>\n}\n\n/** A query client for one test: no retries, nothing kept between tests. */\nexport function createTestQueryClient(): QueryClient {\n return new QueryClient({ defaultOptions: { queries: { retry: false, gcTime: 0 }, mutations: { retry: false } } })\n}\n\n/** `MockAuthProvider` inside a fresh `QueryClientProvider`. */\nexport function TestProviders({ children, client, ...auth }: MockAuthProviderProps & { client?: QueryClient }) {\n return (\n <QueryClientProvider client={client ?? createTestQueryClient()}>\n <MockAuthProvider {...auth}>{children}</MockAuthProvider>\n </QueryClientProvider>\n )\n}\n\nexport { ApiError, Unauthenticated } from \"../core/errors\"\nexport type { AuthStatus } from \"../auth/context\"\nexport type { Me, MobileAuth } from \"../auth/client\"\n"],"mappings":";;;;;;;;;AAEA,SAAS,aAAa,2BAA2B;AAsDxC;AAzCF,SAAS,aAAa,SAAgC,CAAC,GAAe;AAC3E,SAAO;AAAA,IACL,WAAW;AAAA,IACX,OAAO,aAAa,EAAE,IAAI,KAAK;AAAA,IAC/B,QAAQ,YAAY;AAAA,IACpB,mBAAmB,YAAY;AAAA,IAC/B,YAAY,YAAY;AAAA,IACxB,UAAU,OAAW,MAAc,SAAmC;AACpE,UAAI,EAAE,QAAQ,QAAS,OAAM,IAAI,SAAS,KAAK,WAAW;AAC1D,YAAM,QAAQ,OAAO,IAAI;AACzB,YAAM,QAAQ,OAAO,UAAU,aAAc,MAAkD,IAAI,IAAI;AACvG,UAAI,iBAAiB,MAAO,OAAM;AAClC,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAGO,IAAM,WAAW,CAAC,OAAoB,CAAC,OAAW;AAAA,EACvD,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AAAA,EACN,mBAAmB;AAAA,EACnB,OAAO,CAAC;AAAA,EACR,aAAa,CAAC;AAAA,EACd,GAAG;AACL;AAWA,IAAM,OAAO,YAAY;AAElB,SAAS,iBAAiB,EAAE,UAAU,SAAS,EAAE,OAAO,YAAY,IAAI,SAAS,EAAE,GAAG,MAAM,QAAQ,QAAQ,GAA0B;AAC3I,QAAM,QAAQ,EAAE,QAAQ,MAAM,QAAQ,aAAa,GAAG,QAAQ,UAAU,MAAM,SAAS,WAAW,MAAM,SAAS,MAAM,QAAQ,MAAM,OAAU;AAC/I,SAAO,oBAAC,uBAAoB,OAAe,UAAS;AACtD;AAGO,SAAS,wBAAqC;AACnD,SAAO,IAAI,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,OAAO,OAAO,QAAQ,EAAE,GAAG,WAAW,EAAE,OAAO,MAAM,EAAE,EAAE,CAAC;AAClH;AAGO,SAAS,cAAc,EAAE,UAAU,QAAQ,GAAG,KAAK,GAAqD;AAC7G,SACE,oBAAC,uBAAoB,QAAQ,UAAU,sBAAsB,GAC3D,8BAAC,oBAAkB,GAAG,MAAO,UAAS,GACxC;AAEJ;","names":[]}
@@ -1,58 +0,0 @@
1
- ---
2
- name: qore-mobile-add-screen
3
- description: Add a screen to this module's phone app (mobile/, Expo Router) — a route file, a tab if it needs one, en+nl strings, loading/error states, a permission check and a component test. Use for any new screen or tab in mobile/; for a web page in src/app use qore-add-page instead.
4
- allowed-tools: Bash(pnpm:*), Edit, Read
5
- ---
6
-
7
- # Add a screen to the phone app
8
-
9
- `mobile/` is the Expo app; it is its own pnpm project (`cd mobile` before any `pnpm`
10
- command) and imports only `@quatronic/sdk/expo/*` — never `next/*`, `node/*` or anything
11
- from the module's `src/`. `pnpm lint` in `mobile/` enforces that. Read `mobile/CLAUDE.md`
12
- first; for Expo APIs read the versioned docs it points to.
13
-
14
- 1. **Route file.** Expo Router maps files to screens:
15
- - a tab: `mobile/src/app/(tabs)/<name>.tsx`, plus a `<Tabs.Screen name="<name>" …>` in
16
- `mobile/src/app/(tabs)/_layout.tsx` with a `title` from `tr(...)` and a
17
- `lucide-react-native` icon re-exported from `@/components/ui`;
18
- - a pushed screen (detail, settings): `mobile/src/app/<name>.tsx`, reached with
19
- `router.push("/<name>")` or `<Link href="/<name>">`.
20
-
21
- Default-export a component that renders `<Screen>` from `@/components/ui`. Everything
22
- under `(tabs)` is already signed-in only; the root layout handles the gate.
23
-
24
- 2. **Strings.** Every visible string is a key in **both**
25
- `mobile/src/i18n/messages/en.json` and `nl.json`, read with `const t = useT()` from
26
- `@/i18n`. The parity test (`pnpm test`) fails when one catalog lacks a key. Tab titles
27
- live under `tabs.*`.
28
-
29
- 3. **Data.** A screen that loads something uses a query hook over `apiFetch` — see
30
- /qore-mobile-call-server. Render the three states with `LoadingState` and
31
- `ErrorState` (`@/components/ui`); pass `onRetry={() => query.refetch()}`.
32
-
33
- 4. **Permissions.** Hide what the user cannot use with `useCan("<permission>")` or
34
- `<Can permission="<permission>">` from `@/lib/auth`. That only hides it: the server
35
- route must check the same permission with `requireAuthFor`, because anyone can call it.
36
-
37
- 5. **Style.** NativeWind classes with the theme's semantic tokens (`bg-card`,
38
- `text-muted-foreground`, `border-border`) from `mobile/src/global.css`; navigation
39
- options take colour values, read them from `useTokens()` (`@/styles/theme`). Tap
40
- targets at least 44 pt, and give a `Pressable` an `accessibilityRole` and
41
- `accessibilityLabel`.
42
-
43
- 6. **Test.** `mobile/src/app/__tests__/<name>.test.tsx`, rendered inside
44
- `TestProviders` from `@quatronic/sdk/expo/testing`:
45
- ```tsx
46
- import { render, screen } from "@testing-library/react-native"
47
- import { mockApiFetch, TestProviders, testUser } from "@quatronic/sdk/expo/testing"
48
-
49
- const auth = mockApiFetch({ "/api/orders": [{ id: "o1", total: 12 }] })
50
- const me = testUser({ permissions: ["orders.read"] })
51
- render(<TestProviders auth={auth} status={{ state: "signedIn", me }}><OrdersScreen /></TestProviders>)
52
- expect(await screen.findByText("o1")).toBeTruthy()
53
- ```
54
-
55
- 7. `cd mobile && pnpm typecheck && pnpm lint && pnpm test`.
56
-
57
- Navigation is traced already: every screen, tab switches included, becomes a transaction
58
- in the Monitoring tab's Traces with tag `app=mobile`. Do not add your own.
@@ -1,74 +0,0 @@
1
- ---
2
- name: qore-mobile-call-server
3
- description: Let the phone app (mobile/) read or change data — a route on this module's own Next server plus a TanStack Query hook over apiFetch on the phone. Use whenever a mobile screen needs data, a backend call or an external API.
4
- allowed-tools: Bash(pnpm:*), Edit, Read
5
- ---
6
-
7
- # Call the server from the phone app
8
-
9
- The phone talks to **one** host: this module's own Next server (`EXPO_PUBLIC_SERVER_URL`).
10
- Everything else — the database, another module, a third-party API, any secret — sits
11
- behind a route on that server. `apiFetch` refuses any other host, and
12
- `qdc/no-raw-fetch` refuses `fetch` in `mobile/src`.
13
-
14
- ## 1. The server route (`src/`, the web half)
15
-
16
- Add it as for any route (/qore-add-api-route): `src/app/api/<area>/route.ts`, guarded with
17
- `requireAuth()` or `requireAuthFor("<permission>")` from `@/lib/auth`. Nothing mobile-specific:
18
- the SDK accepts the phone's `Authorization: Bearer` session where a browser sends a cookie,
19
- so the same route serves both, and `getAccessToken()` / `callBackend` work unchanged for
20
- the downstream call. Return JSON with a stable shape and errors as `{ error: "<code>" }`.
21
-
22
- **Additive only.** Installed phones run old builds for months; a store update is not a
23
- deploy. Never rename or remove a field, a route or an error code the phone reads, and
24
- never make an optional request field required. Add a new field or a `/v2` route instead.
25
- The request header `x-qore-app-version` says which build called, in logs and traces.
26
-
27
- ## 2. The query hook (`mobile/`, the phone half)
28
-
29
- Put the hook next to its screen's feature, `mobile/src/features/<area>/use<Thing>.ts`:
30
-
31
- ```ts
32
- import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
33
- import { useAuth } from "@/lib/auth"
34
-
35
- export type Order = { id: string; total: number }
36
-
37
- export function useOrders() {
38
- const { auth } = useAuth()
39
- return useQuery({ queryKey: ["orders"], queryFn: () => auth.apiFetch<Order[]>("/api/orders") })
40
- }
41
-
42
- export function useCreateOrder() {
43
- const { auth } = useAuth()
44
- const qc = useQueryClient()
45
- return useMutation({
46
- mutationFn: (body: { total: number }) =>
47
- auth.apiFetch<Order>("/api/orders", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }),
48
- onSuccess: () => qc.invalidateQueries({ queryKey: ["orders"] }),
49
- })
50
- }
51
- ```
52
-
53
- Take `auth` from `useAuth()`, not a module import, so a test's `mockApiFetch` reaches it.
54
- Type the response by hand next to the hook; there is no shared types folder yet.
55
-
56
- ## 3. Errors
57
-
58
- The shared query client (`@/lib/query`) already does the rest — do not repeat it per hook:
59
-
60
- | Error | Meaning | Handled by |
61
- |---|---|---|
62
- | `Unauthenticated` | session gone; token already cleared | query client → login screen with "session ended" |
63
- | `ApiError` 4xx | the server refused (`err.code` is its `error`) | your screen: show `ErrorState`, no retry |
64
- | `ApiError` 5xx, network | server or connection trouble | retried twice, then your `ErrorState` with `onRetry` |
65
-
66
- Offline, queries pause and resume when the connection returns; the offline banner says so.
67
-
68
- ## 4. Check
69
-
70
- - Server: `pnpm test` at the module root for the route.
71
- - Phone: a component test with `mockApiFetch({ "/api/orders": [...] })` (see
72
- /qore-mobile-add-screen), then `cd mobile && pnpm typecheck && pnpm lint && pnpm test`.
73
- - On a device: /qore-mobile-run-on-device. The call shows up in Traces as a span under
74
- the screen's transaction, continuing into the server's.
@@ -1,41 +0,0 @@
1
- ---
2
- name: qore-mobile-run-on-device
3
- description: Run the phone app (mobile/) on a real phone with Expo Go against the module's staging server, sign in, and find the phone's errors, logs and traces in the portal. Use when asked to try, test or debug the mobile app on a device.
4
- allowed-tools: Bash(pnpm:*), Bash(npx expo:*), Read
5
- ---
6
-
7
- # Run the phone app on a device
8
-
9
- 1. **Configure.** `mobile/.env` holds three public values, never a secret:
10
- - `EXPO_PUBLIC_SERVER_URL` — the module's **staging** origin, `https://…`, no path;
11
- - `EXPO_PUBLIC_SENTRY_DSN` — the module's Sentry DSN (public by design; empty turns
12
- Sentry off);
13
- - `EXPO_PUBLIC_QORE_ENV` — `staging`.
14
-
15
- The portal shows the server URL and the DSN on the module's page. A wrong value is not a crash: the
16
- app opens on a "misconfigured" screen naming the key.
17
-
18
- 2. **Start.** `cd mobile && pnpm install && npx expo start`. Scan the QR code with the
19
- camera (iOS) or the Expo Go app (Android). Phone and computer on the same network; on a
20
- network that blocks that, `npx expo start --tunnel`.
21
-
22
- 3. **Sign in.** Login opens the server's Keycloak page in an in-app browser and comes back
23
- to the app. In Expo Go the return address is `exp://…`, which the staging server accepts
24
- and production refuses — a real build uses the app's own scheme. A login that fails
25
- returns with a reason on the login screen (no access to this app, expired, cancelled).
26
-
27
- 4. **Look.** In the portal, the module's **Monitoring** tab, environment staging:
28
- - pick **Phone** in the toolbar to see only the phone's errors, logs and traces
29
- (each also carries `app=mobile`);
30
- - Traces has one transaction per screen, tab switches included, with each `apiFetch`
31
- call as a span that continues into the server's trace;
32
- - Replays: Expo Go does not record them; a development or store build does, masked.
33
-
34
- Phone logs come only from `log` (`@/lib/log`); `console.*` stays on the device.
35
-
36
- 5. **Reload** with `r` in the terminal, or shake the phone for the dev menu. A change to
37
- `app.config.ts`, a plugin or a native package needs a restart of `npx expo start`, and
38
- one that Expo Go does not include needs a development build — ask before setting one up.
39
-
40
- Do not hand-edit `mobile/ios` or `mobile/android`; they are generated. Add a native package
41
- with `npx expo install <package>`, which picks the version matching the Expo SDK.