@tappify/extension-sdk 2.0.0 → 2.1.0-beta.1

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 (148) hide show
  1. package/README.md +208 -0
  2. package/dist/chunk-2CY5HVY7.mjs +59 -0
  3. package/dist/chunk-2CY5HVY7.mjs.map +1 -0
  4. package/dist/{chunk-2DBSVKAU.cjs → chunk-6HETNZJY.cjs} +1 -1
  5. package/dist/chunk-6HETNZJY.cjs.map +1 -0
  6. package/dist/{chunk-PYJMJF44.cjs → chunk-7YKH4LZN.cjs} +9 -2
  7. package/dist/chunk-7YKH4LZN.cjs.map +1 -0
  8. package/dist/{chunk-RMUWRESK.cjs → chunk-A74HCO6T.cjs} +31 -18
  9. package/dist/chunk-A74HCO6T.cjs.map +1 -0
  10. package/dist/chunk-BPCGXXMD.cjs +781 -0
  11. package/dist/chunk-BPCGXXMD.cjs.map +1 -0
  12. package/dist/chunk-EB5XWQAU.cjs +132 -0
  13. package/dist/chunk-EB5XWQAU.cjs.map +1 -0
  14. package/dist/{chunk-5AAPD5WV.cjs → chunk-GAUZYBXE.cjs} +11 -11
  15. package/dist/chunk-GAUZYBXE.cjs.map +1 -0
  16. package/dist/chunk-J5LGTIGS.mjs +10 -0
  17. package/dist/chunk-J5LGTIGS.mjs.map +1 -0
  18. package/dist/{chunk-ZT35X7KL.mjs → chunk-KZ5NGFUP.mjs} +22 -9
  19. package/dist/chunk-KZ5NGFUP.mjs.map +1 -0
  20. package/dist/chunk-NN263PGQ.cjs +70 -0
  21. package/dist/chunk-NN263PGQ.cjs.map +1 -0
  22. package/dist/{chunk-3YWVYA42.cjs → chunk-O357OJXL.cjs} +14 -18
  23. package/dist/chunk-O357OJXL.cjs.map +1 -0
  24. package/dist/chunk-ONJMPO3P.cjs +59 -0
  25. package/dist/chunk-ONJMPO3P.cjs.map +1 -0
  26. package/dist/{chunk-OPPYEA7F.cjs → chunk-PRCZMOLD.cjs} +3 -3
  27. package/dist/chunk-PRCZMOLD.cjs.map +1 -0
  28. package/dist/chunk-Q7SFCCGT.cjs +10 -0
  29. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  30. package/dist/{chunk-QHM7XNRK.mjs → chunk-QA5AL3VZ.mjs} +2 -2
  31. package/dist/{chunk-QHM7XNRK.mjs.map → chunk-QA5AL3VZ.mjs.map} +1 -1
  32. package/dist/chunk-QJMZRV7A.mjs +132 -0
  33. package/dist/chunk-QJMZRV7A.mjs.map +1 -0
  34. package/dist/{chunk-CSTYBKZC.mjs → chunk-QXD7WVKK.mjs} +1 -1
  35. package/dist/chunk-QXD7WVKK.mjs.map +1 -0
  36. package/dist/{chunk-4C5Z3CIK.mjs → chunk-RBIQT75L.mjs} +2 -2
  37. package/dist/chunk-RBIQT75L.mjs.map +1 -0
  38. package/dist/{chunk-MNDVYPEP.mjs → chunk-SGCYEEXD.mjs} +9 -2
  39. package/dist/chunk-SGCYEEXD.mjs.map +1 -0
  40. package/dist/{chunk-BDCX6LRQ.mjs → chunk-SGEYDV3K.mjs} +3 -3
  41. package/dist/chunk-SGEYDV3K.mjs.map +1 -0
  42. package/dist/{chunk-IGK2AP6J.mjs → chunk-SLGOHIBL.mjs} +13 -17
  43. package/dist/chunk-SLGOHIBL.mjs.map +1 -0
  44. package/dist/chunk-SWG7CNTZ.mjs +781 -0
  45. package/dist/chunk-SWG7CNTZ.mjs.map +1 -0
  46. package/dist/{chunk-7KIKOH5H.cjs → chunk-VV7ELNRW.cjs} +3 -3
  47. package/dist/chunk-VV7ELNRW.cjs.map +1 -0
  48. package/dist/chunk-Z43DPNZ6.mjs +70 -0
  49. package/dist/chunk-Z43DPNZ6.mjs.map +1 -0
  50. package/dist/client-CV1qzQgx.d.cts +25 -0
  51. package/dist/client-CnlSHDWE.d.ts +25 -0
  52. package/dist/codegen.cjs.map +1 -1
  53. package/dist/codegen.d.cts +40 -7
  54. package/dist/codegen.d.ts +40 -7
  55. package/dist/codegen.mjs.map +1 -1
  56. package/dist/{constants-DJ_KgZpN.d.cts → constants-BAimnqOK.d.cts} +41 -8
  57. package/dist/{constants-DJ_KgZpN.d.ts → constants-BAimnqOK.d.ts} +41 -8
  58. package/dist/{context-Ml7k_V14.d.ts → context-Cr93B05o.d.ts} +5 -4
  59. package/dist/{context-Dt6xh_5t.d.cts → context-DJ3REtdT.d.cts} +5 -4
  60. package/dist/{errors-COsBh7kd.d.cts → errors-Cqh0wrqt.d.cts} +3 -2
  61. package/dist/{errors-COsBh7kd.d.ts → errors-Cqh0wrqt.d.ts} +3 -2
  62. package/dist/host.cjs +5 -4
  63. package/dist/host.cjs.map +1 -1
  64. package/dist/host.d.cts +5 -5
  65. package/dist/host.d.ts +5 -5
  66. package/dist/host.mjs +4 -3
  67. package/dist/host.mjs.map +1 -1
  68. package/dist/index.cjs +9 -656
  69. package/dist/index.cjs.map +1 -1
  70. package/dist/index.d.cts +69 -627
  71. package/dist/index.d.ts +69 -627
  72. package/dist/index.mjs +5 -652
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/manifest.cjs +138 -85
  75. package/dist/manifest.cjs.map +1 -1
  76. package/dist/manifest.d.cts +93 -12
  77. package/dist/manifest.d.ts +93 -12
  78. package/dist/manifest.mjs +125 -72
  79. package/dist/manifest.mjs.map +1 -1
  80. package/dist/server.cjs +15 -66
  81. package/dist/server.cjs.map +1 -1
  82. package/dist/server.d.cts +6 -6
  83. package/dist/server.d.ts +6 -6
  84. package/dist/server.mjs +10 -61
  85. package/dist/server.mjs.map +1 -1
  86. package/dist/testing/index.cjs +73 -750
  87. package/dist/testing/index.cjs.map +1 -1
  88. package/dist/testing/index.d.cts +30 -11
  89. package/dist/testing/index.d.ts +30 -11
  90. package/dist/testing/index.mjs +89 -766
  91. package/dist/testing/index.mjs.map +1 -1
  92. package/dist/testing/jest.cjs +6 -5
  93. package/dist/testing/jest.cjs.map +1 -1
  94. package/dist/testing/jest.mjs +3 -2
  95. package/dist/testing/jest.mjs.map +1 -1
  96. package/dist/testing/vitest.cjs +6 -5
  97. package/dist/testing/vitest.cjs.map +1 -1
  98. package/dist/testing/vitest.d.cts +10 -0
  99. package/dist/testing/vitest.d.ts +10 -0
  100. package/dist/testing/vitest.mjs +3 -2
  101. package/dist/testing/vitest.mjs.map +1 -1
  102. package/dist/{types-DrpQSv_2.d.cts → types-BYGcp5pZ.d.ts} +4 -3
  103. package/dist/{types-DDAGLpov.d.ts → types-I1JOZyI_.d.cts} +4 -3
  104. package/dist/ui/styles.css +740 -0
  105. package/dist/ui.cjs +1018 -0
  106. package/dist/ui.cjs.map +1 -0
  107. package/dist/ui.d.cts +231 -0
  108. package/dist/ui.d.ts +231 -0
  109. package/dist/ui.mjs +1018 -0
  110. package/dist/ui.mjs.map +1 -0
  111. package/dist/vite-preview-bootstrap.cjs +66 -0
  112. package/dist/vite-preview-bootstrap.cjs.map +1 -0
  113. package/dist/vite-preview-bootstrap.d.cts +15 -0
  114. package/dist/vite-preview-bootstrap.d.ts +15 -0
  115. package/dist/vite-preview-bootstrap.mjs +66 -0
  116. package/dist/vite-preview-bootstrap.mjs.map +1 -0
  117. package/dist/vite-preview.cjs +876 -0
  118. package/dist/vite-preview.cjs.map +1 -0
  119. package/dist/vite-preview.d.cts +9 -0
  120. package/dist/vite-preview.d.ts +9 -0
  121. package/dist/vite-preview.mjs +876 -0
  122. package/dist/vite-preview.mjs.map +1 -0
  123. package/dist/vite.cjs +316 -59
  124. package/dist/vite.cjs.map +1 -1
  125. package/dist/vite.d.cts +51 -8
  126. package/dist/vite.d.ts +51 -8
  127. package/dist/vite.mjs +308 -53
  128. package/dist/vite.mjs.map +1 -1
  129. package/dist/work-events-DB3WR468.d.ts +547 -0
  130. package/dist/work-events-Dxe7Djdy.d.cts +547 -0
  131. package/package.json +19 -2
  132. package/schema/extension-v2.json +432 -121
  133. package/dist/chunk-2DBSVKAU.cjs.map +0 -1
  134. package/dist/chunk-3YWVYA42.cjs.map +0 -1
  135. package/dist/chunk-4C5Z3CIK.mjs.map +0 -1
  136. package/dist/chunk-5AAPD5WV.cjs.map +0 -1
  137. package/dist/chunk-7KIKOH5H.cjs.map +0 -1
  138. package/dist/chunk-BDCX6LRQ.mjs.map +0 -1
  139. package/dist/chunk-CSTYBKZC.mjs.map +0 -1
  140. package/dist/chunk-IGK2AP6J.mjs.map +0 -1
  141. package/dist/chunk-MNDVYPEP.mjs.map +0 -1
  142. package/dist/chunk-OPPYEA7F.cjs.map +0 -1
  143. package/dist/chunk-PYJMJF44.cjs.map +0 -1
  144. package/dist/chunk-RMUWRESK.cjs.map +0 -1
  145. package/dist/chunk-ZT35X7KL.mjs.map +0 -1
  146. package/dist/handler-CZIlZ5vu.d.ts +0 -227
  147. package/dist/handler-kU9Jf36K.d.cts +0 -227
  148. package/dist/styles.css +0 -367
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/vulakh/Desktop/Work/Tappify/extension-sdk/dist/testing/index.cjs","../../src/testing/client.ts","../../src/testing/envelope.ts","../../src/testing/fixtures.ts","../../src/testing/mock.ts","../../src/testing/render.tsx","../../src/testing/validators.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACF,yDAA8B;AAC9B;AACA;AC7BA;AACE;AACA;AACA;AAAA,4BAGK;AD6BP;AACA;AE9BO,IAAM,gBAAA,EAA8B;AAAA,EACzC,KAAA,EAAO,EAAE,IAAA,EAAM,YAAA,EAAc,EAAA,EAAI,YAAA,EAAc,MAAA,EAAQ,KAAK,CAAA;AAAA,EAC5D,QAAA,EAAU,KAAA;AAAA,EACV,OAAA,EAAS;AACX,CAAA;AAWO,SAAS,YAAA,CAAa,QAAA,EAAgC;AAC3D,EAAA,MAAM,QAAA,EAA8B;AAAA,IAClC,SAAA,EAAW,QAA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AACvD;ALmrB+G;AACA;AM3xB/C;AAG1D,EAAA;AACN;AAEgD;AACR,EAAA;AACxC;AAE0C;AACjB,EAAA;AAKF,EAAA;AAEvB;AAiCY;AACkC,EAAA;AAEvB,EAAA;AACZ,IAAA;AACL,MAAA;AACF,IAAA;AACF,EAAA;AAE0B,EAAA;AAC0C,EAAA;AAErB,EAAA;AACpB,IAAA;AACoC,IAAA;AAE1B,IAAA;AAC0B,MAAA;AAC3D,MAAA;AACF,IAAA;AAE+B,IAAA;AACL,IAAA;AACjB,MAAA;AACmC,QAAA;AAC1C,MAAA;AACA,MAAA;AACF,IAAA;AAE+B,IAAA;AACtB,MAAA;AAC+F,QAAA;AACtG,MAAA;AACF,IAAA;AAE+B,IAAA;AACV,IAAA;AAC0C,MAAA;AAC7D,MAAA;AACF,IAAA;AAEoD,IAAA;AAC7B,MAAA;AACZ,QAAA;AACgD,UAAA;AACvD,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AAEO,EAAA;AACT;AA2BY;AACe,EAAA;AACN,EAAA;AACV,IAAA;AAC8E,MAAA;AACrF,IAAA;AACF,EAAA;AAIG,EAAA;AAE+C,IAAA;AAChD,EAAA;AACJ;AN6sB+G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/vulakh/Desktop/Work/Tappify/extension-sdk/dist/testing/index.cjs","sourcesContent":[null,"import {\n exportJWK,\n generateKeyPair,\n SignJWT,\n type CryptoKey,\n type JSONWebKeySet,\n} from 'jose';\nimport { TapError } from '../client/errors';\nimport type { TapFilters } from '../client/types';\nimport { createTappifyHandler } from '../server/handler';\nimport type {\n ContextBlock,\n MentionItems,\n MetricsInput,\n MetricsResponse,\n TappifyClaims,\n TappifyHandlerOptions,\n TappifyHealth,\n TappifyInstall,\n WorkOperation,\n} from '../server/types';\nimport {\n callEnvelope,\n DEFAULT_FILTERS,\n readEnvelopeResponse,\n} from './envelope';\n\nconst TEST_KID = 'tappify-test-key';\nconst TEST_ISSUER = 'https://api.tappify.ai';\n\ninterface TestKeys {\n privateKey: CryptoKey;\n jwks: JSONWebKeySet;\n}\n\nlet keys: Promise<TestKeys> | null = null;\n\nfunction ensureKeys(): Promise<TestKeys> {\n keys ??= (async () => {\n const pair = await generateKeyPair('RS256', { extractable: true });\n const publicJwk = await exportJWK(pair.publicKey);\n return {\n privateKey: pair.privateKey,\n jwks: {\n keys: [{ ...publicJwk, kid: TEST_KID, alg: 'RS256', use: 'sig' }],\n },\n };\n })();\n\n return keys;\n}\n\n/**\n * Returns the public key set that verifies the tokens `signTestToken` signs.\n *\n * @remarks\n * The pair is generated once per process and cached, so every call in a suite\n * returns the same set. Pass it as `jwks` to `createTappifyHandler` when a test\n * drives the handler itself; `createTestClient` does that for you.\n *\n * @example\n * ```ts\n * import { createTappifyHandler } from '@tappify/extension-sdk/server';\n * import { testJwks } from '@tappify/extension-sdk/testing';\n *\n * async function buildHandler() {\n * return createTappifyHandler({ extensionId: 'starter', jwks: await testJwks() });\n * }\n * ```\n */\nexport async function testJwks(): Promise<JSONWebKeySet> {\n return (await ensureKeys()).jwks;\n}\n\n/**\n * Signs an install token a handler built against `testJwks` accepts.\n *\n * @remarks\n * Every claim has a default — install `ins_test`, extension `starter`, project\n * `prj_north`, organization `org_test`, no scopes — and the audience is\n * `ext:<extensionId>`, taken from `options.extensionId`, then from the claims, then\n * `starter`. It expires in five minutes unless `expiresIn` says otherwise, which is\n * how a test covers an expired token. `createTestClient` and `createTapMock` sign\n * their own tokens, so reach for this only when a test verifies a token itself.\n *\n * @example\n * ```ts\n * import { verifyTappifyToken } from '@tappify/extension-sdk/server';\n * import { signTestToken, testJwks } from '@tappify/extension-sdk/testing';\n *\n * async function claimsOfTestToken() {\n * const token = await signTestToken({ scopes: ['analytics:read'] });\n * return verifyTappifyToken(token, {\n * extensionId: 'starter',\n * jwks: await testJwks(),\n * });\n * }\n * ```\n */\nexport async function signTestToken(\n claims: Partial<TappifyClaims> = {},\n options: { extensionId?: string; expiresIn?: string } = {},\n): Promise<string> {\n const { privateKey } = await ensureKeys();\n const extensionId = options.extensionId ?? claims.extensionId ?? 'starter';\n\n return new SignJWT({\n installId: claims.installId ?? 'ins_test',\n extensionId,\n projectId: claims.projectId ?? 'prj_north',\n organizationId: claims.organizationId ?? 'org_test',\n scopes: claims.scopes ?? [],\n ...(claims.userId === undefined ? {} : { userId: claims.userId }),\n })\n .setProtectedHeader({ alg: 'RS256', kid: TEST_KID })\n .setIssuer(TEST_ISSUER)\n .setAudience(`ext:${extensionId}`)\n .setIssuedAt()\n .setExpirationTime(options.expiresIn ?? '5m')\n .sign(privateKey);\n}\n\n/** What every call a `TestClient` makes carries, unless a call overrides it. */\nexport interface TestClientDefaults {\n /** Merged over the default install, whose id is `ins_test`. */\n install?: Partial<TappifyInstall>;\n /** The scopes the token claims. Defaults to none. */\n scopes?: string[];\n /** What the handler reads as `credentials`. Defaults to empty. */\n credentials?: Record<string, unknown>;\n /** What the handler reads as `documents`, including `settings`. */\n documents?: Record<string, unknown>;\n /** The filter bar behind the call. Defaults to a seven-day September range. */\n filters?: TapFilters;\n /** One fixed idempotency key. Left out, each call gets its own. */\n eventId?: string;\n /** The origin the request url is built on. Defaults to `https://vendor.test`. */\n origin?: string;\n}\n\n/** One method per route Tappify calls, plus `raw` for the response itself. */\nexport interface TestClient {\n /** Calls the health route, which carries no token. */\n health(): Promise<TappifyHealth>;\n /** Calls the connector's metrics route. */\n metrics(input: MetricsInput): Promise<MetricsResponse>;\n /** Calls one tool by id and returns the card it answered with. */\n tool(id: string, input: unknown): Promise<unknown>;\n /** Calls one mention by id, with the query as the `q` parameter. */\n mention(id: string, query: string): Promise<MentionItems>;\n /** Calls one action by id. */\n action(id: string, input: unknown): Promise<unknown>;\n /** Calls one procedure by name; the input defaults to an empty object. */\n procedure(name: string, input?: unknown): Promise<unknown>;\n /** Calls one context block by id. */\n context(id: string): Promise<ContextBlock>;\n /** Posts one Tappify event, which the handler answers with 204. */\n event(name: string, payload: Record<string, unknown>): Promise<void>;\n /** Calls one work operation. */\n work(operation: WorkOperation, input: unknown): Promise<unknown>;\n /**\n * Sends any method and path and returns the `Response`, for a test that asserts\n * on a status rather than a body.\n */\n raw(method: string, path: string, body?: unknown): Promise<Response>;\n}\n\nconst HEALTH_PATH = '/tappify/health';\n\n/**\n * Drives a vendor server the way Tappify does, so a route is tested without a\n * running Tappify.\n *\n * @remarks\n * Pass the options object you hand `createTappifyHandler`, not the handler it\n * returns: the client rebuilds the handler around `testJwks` and signs each call\n * with a matching token. A built handler throws a `TapError` carrying\n * `TAP_TEST_TARGET_INVALID`, because it would verify against the live Tappify key\n * set and answer 401. Every call carries a fresh event id and the envelope Tappify\n * sends, and every call but `health` a signed token, so the handler reads the same\n * `install`, `context`, `credentials` and `documents` it will read in production. A route that\n * answers an error rejects with a `TapServerError` carrying the code, message and\n * status from the body, which is what a test asserts on; use `raw` when the status\n * itself is the assertion. Every method calls the unprefixed path — `/tappify/…` —\n * whatever `basePath` the options carry, so a `basePath` the handler strips off\n * something else is not exercised here, and one that is itself a prefix of\n * `/tappify`, such as `/tap`, makes every call 404 `TAP_ROUTE_UNKNOWN`. Reach a\n * prefixed path through `raw` when that is what you need to cover.\n *\n * @example\n * ```ts\n * import type { TappifyHandlerOptions } from '@tappify/extension-sdk/server';\n * import { createTestClient } from '@tappify/extension-sdk/testing';\n * import { expect, it } from 'vitest';\n *\n * const handlerOptions: TappifyHandlerOptions = {\n * extensionId: 'starter',\n * health: () => ({ ok: true, version: '0.1.0' }),\n * };\n * const client = createTestClient(handlerOptions, { scopes: ['analytics:read'] });\n *\n * it('answers the health check', async () => {\n * await expect(client.health()).resolves.toEqual({ ok: true, version: '0.1.0' });\n * });\n * ```\n */\nexport function createTestClient(\n target: TappifyHandlerOptions,\n defaults: TestClientDefaults = {},\n): TestClient {\n if (typeof target === 'function') {\n throw new TapError(\n 'TAP_TEST_TARGET_INVALID',\n 'createTestClient() was handed a built handler instead of the options object. A handler from createTappifyHandler() verifies install tokens against the live Tappify key set, so every call the test client makes would come back 401. Pass the options themselves — createTestClient(handlerOptions) — or, when you need the handler, build it with createTappifyHandler({ ...handlerOptions, jwks: await testJwks() }) and drive it through createTapMock({ handler, extensionId: handlerOptions.extensionId }) so the test token carries the audience the handler expects.',\n );\n }\n\n const extensionId = target.extensionId;\n const handlerPromise = testJwks().then(jwks =>\n createTappifyHandler({ ...target, jwks }),\n );\n\n const install: TappifyInstall = {\n id: 'ins_test',\n extensionId,\n projectId: 'prj_north',\n organizationId: 'org_test',\n ...defaults.install,\n };\n\n const filters = defaults.filters ?? DEFAULT_FILTERS;\n const origin = defaults.origin ?? 'https://vendor.test';\n\n let sent = 0;\n\n function envelope(input: unknown, event?: unknown): string {\n return callEnvelope({\n install,\n filters,\n input,\n credentials: defaults.credentials,\n documents: defaults.documents,\n event,\n });\n }\n\n async function send(\n method: string,\n path: string,\n body?: string,\n ): Promise<Response> {\n const handler = await handlerPromise;\n sent += 1;\n const headers = new Headers({\n 'content-type': 'application/json',\n 'x-tappify-event-id': defaults.eventId ?? `evt_${path}_${String(sent)}`,\n });\n\n if (path !== HEALTH_PATH) {\n const token = await signTestToken(\n {\n installId: install.id,\n extensionId: install.extensionId,\n projectId: install.projectId,\n organizationId: install.organizationId,\n scopes: defaults.scopes ?? [],\n },\n { extensionId },\n );\n headers.set('authorization', `Bearer ${token}`);\n }\n\n return handler(\n new Request(`${origin}${path}`, {\n method,\n headers,\n ...(body === undefined ? {} : { body }),\n }),\n );\n }\n\n async function call(\n method: string,\n path: string,\n body?: string,\n ): Promise<unknown> {\n return readEnvelopeResponse(\n await send(method, path, body),\n `${method} ${path}`,\n );\n }\n\n return {\n health: async () => (await call('GET', HEALTH_PATH)) as TappifyHealth,\n metrics: async input =>\n (await call(\n 'POST',\n '/tappify/metrics',\n envelope(input),\n )) as MetricsResponse,\n tool: (id, input) => call('POST', `/tappify/tools/${id}`, envelope(input)),\n mention: async (id, query) =>\n (await call(\n 'GET',\n `/tappify/mentions/${id}?q=${encodeURIComponent(query)}`,\n )) as MentionItems,\n action: (id, input) =>\n call('POST', `/tappify/actions/${id}`, envelope(input)),\n procedure: (name, input = {}) =>\n call('POST', `/tappify/procedures/${name}`, envelope(input)),\n context: async id =>\n (await call('GET', `/tappify/context/${id}`)) as ContextBlock,\n event: async (name, payload) => {\n await call('POST', '/tappify/events', envelope({}, { name, payload }));\n },\n work: (operation, input) =>\n call('POST', `/tappify/work/${operation}`, envelope(input)),\n raw: (method, path, body) =>\n send(method, path, body === undefined ? undefined : JSON.stringify(body)),\n };\n}\n","import { TapServerError } from '../client/errors';\nimport type { TapFilters } from '../client/types';\nimport { SERVER_ERROR_CODES } from '../server/codes';\nimport type { TappifyCallContext, TappifyInstall } from '../server/types';\nimport { readRecord, readText } from '../server/wire';\n\nexport const DEFAULT_FILTERS: TapFilters = {\n range: { from: '2026-09-01', to: '2026-09-08', preset: '7d' },\n platform: 'all',\n country: 'all',\n};\n\nexport interface CallEnvelope {\n install: TappifyInstall;\n filters: TapFilters;\n input: unknown;\n credentials?: Record<string, unknown>;\n documents?: Record<string, unknown>;\n event?: unknown;\n}\n\nexport function callEnvelope(envelope: CallEnvelope): string {\n const context: TappifyCallContext = {\n projectId: envelope.install.projectId,\n platform: envelope.filters.platform,\n from: envelope.filters.range.from,\n to: envelope.filters.range.to,\n filters: envelope.filters,\n };\n\n return JSON.stringify({\n install: envelope.install,\n context,\n input: envelope.input,\n credentials: envelope.credentials ?? {},\n documents: envelope.documents ?? {},\n event: envelope.event,\n });\n}\n\nfunction parseJson(text: string): { parsed: boolean; value: unknown } {\n try {\n return { parsed: true, value: JSON.parse(text) as unknown };\n } catch {\n return { parsed: false, value: undefined };\n }\n}\n\nexport async function readEnvelopeResponse(\n response: Response,\n call: string,\n): Promise<unknown> {\n const text = await response.text();\n const body = parseJson(text);\n const status = String(response.status);\n\n if (response.ok) {\n if (body.parsed) return body.value;\n if (text.trim() === '') return undefined;\n\n throw new TapServerError(\n SERVER_ERROR_CODES.INTERNAL_ERROR,\n `The extension server answered ${status} for ${call} with a body that is not JSON. Every Tappify route answers JSON, or 204 with no body.`,\n response.status,\n );\n }\n\n const error = readRecord(body.value, 'error');\n\n throw new TapServerError(\n readText(error, 'code') ?? SERVER_ERROR_CODES.INTERNAL_ERROR,\n readText(error, 'message') ??\n `The extension server answered ${status} for ${call} without a JSON error body.`,\n response.status,\n );\n}\n","import type {\n TapApp,\n TapCrashesResult,\n TapKeyword,\n TapListing,\n TapProjectResult,\n TapQuery,\n TapRelease,\n TapResult,\n TapRevenueResult,\n TapReviewsResult,\n TapSeriesMetric,\n TapSeriesPoint,\n TapSeriesResult,\n} from '../client/types';\n\n/** The owner's two Northlight apps, one per platform. */\nexport const fixtureApps: TapApp[] = [\n {\n id: 'app_ios',\n name: 'Northlight',\n platform: 'ios',\n storeId: '1490000001',\n bundleId: 'ai.tappify.northlight',\n },\n {\n id: 'app_android',\n name: 'Northlight',\n platform: 'android',\n storeId: 'ai.tappify.northlight',\n bundleId: 'ai.tappify.northlight',\n },\n];\n\n/** Three shipped releases: two iOS versions and the Android build of the newer one. */\nexport const fixtureReleases: TapRelease[] = [\n {\n id: 'rel_42',\n version: '4.2.0',\n build: '118',\n platform: 'ios',\n state: 'ready_for_sale',\n shippedAt: '2026-09-01T09:00:00.000Z',\n },\n {\n id: 'rel_41',\n version: '4.1.0',\n build: '107',\n platform: 'ios',\n state: 'ready_for_sale',\n shippedAt: '2026-08-11T09:00:00.000Z',\n },\n {\n id: 'rel_a42',\n version: '4.2.0',\n build: '4200',\n platform: 'android',\n state: 'published',\n shippedAt: '2026-09-02T09:00:00.000Z',\n },\n];\n\n/**\n * Three tracked terms with positions, two on iOS and one on Android, scored on\n * the host's 1 to 10 traffic scale.\n */\nexport const fixtureKeywords: TapKeyword[] = [\n {\n id: 'kw_1',\n term: 'photo editor',\n platform: 'ios',\n country: 'US',\n position: 4,\n popularity: 6.6,\n },\n {\n id: 'kw_2',\n term: 'collage maker',\n platform: 'ios',\n country: 'US',\n position: 11,\n popularity: 5.3,\n },\n {\n id: 'kw_3',\n term: 'photo editor',\n platform: 'android',\n country: 'US',\n position: 7,\n popularity: 6,\n },\n];\n\n/** One store listing, for iOS in `en-US`. */\nexport const fixtureListings: TapListing[] = [\n {\n platform: 'ios',\n country: 'US',\n locale: 'en-US',\n title: 'Northlight — Photo Editor',\n subtitle: 'Edit, collage, share',\n description: 'Northlight turns a camera roll into a finished post.',\n keywords: ['photo', 'editor', 'collage'],\n updatedAt: '2026-08-28T12:00:00.000Z',\n },\n];\n\n/** The Northlight project, with `fixtureApps` and `fixtureReleases` under it. */\nexport const fixtureProject: TapProjectResult = {\n project: {\n id: 'prj_north',\n name: 'Northlight',\n platforms: ['ios', 'android'],\n },\n apps: fixtureApps,\n releases: fixtureReleases,\n};\n\nconst SERIES_VALUES: Record<TapSeriesMetric, number[]> = {\n downloads: [1180, 1240, 1310, 1290, 1402, 1512, 1488],\n impressions: [21400, 22150, 22980, 22110, 24020, 25510, 25010],\n page_views: [8120, 8340, 8710, 8290, 9110, 9640, 9420],\n conversion_rate: [0.145, 0.149, 0.15, 0.156, 0.152, 0.157, 0.158],\n};\n\nfunction week(): string[] {\n return [\n '2026-09-01',\n '2026-09-02',\n '2026-09-03',\n '2026-09-04',\n '2026-09-05',\n '2026-09-06',\n '2026-09-07',\n ];\n}\n\n/**\n * Builds the seven-day series for one metric, over the first week of September\n * 2026.\n *\n * @remarks\n * The same seven values every call, so an assertion on a total or a peak is\n * stable: downloads peak at 1,512 and `conversion_rate` comes back with unit\n * `ratio` where the other three come back as `count`. The range in the query does\n * not change the points, so a test that drives the filter bar asserts on the call,\n * not on different numbers.\n *\n * @example\n * ```ts\n * import { fixtureSeries } from '@tappify/extension-sdk/testing';\n *\n * const downloads = fixtureSeries('downloads');\n * const best = Math.max(...downloads.points.map(point => point.value));\n * ```\n */\nexport function fixtureSeries(metric: TapSeriesMetric): TapSeriesResult {\n const points: TapSeriesPoint[] = week().map((at, index) => ({\n at,\n value: SERIES_VALUES[metric][index],\n }));\n\n return {\n metric,\n unit: metric === 'conversion_rate' ? 'ratio' : 'count',\n points,\n };\n}\n\n/** Three reviews across three countries, averaging 3.7 stars, one already replied to. */\nexport const fixtureReviews: TapReviewsResult = {\n total: 3,\n averageRating: 3.7,\n reviews: [\n {\n id: 'rev_1',\n platform: 'ios',\n country: 'US',\n rating: 5,\n title: 'Fast and clean',\n body: 'The new collage layouts are exactly what I wanted.',\n author: 'kbrady',\n submittedAt: '2026-09-05T18:22:00.000Z',\n replied: false,\n },\n {\n id: 'rev_2',\n platform: 'ios',\n country: 'GB',\n rating: 2,\n title: 'Crashes on export',\n body: 'Since 4.2 the export button closes the app.',\n author: null,\n submittedAt: '2026-09-04T08:10:00.000Z',\n replied: true,\n },\n {\n id: 'rev_3',\n platform: 'android',\n country: 'DE',\n rating: 4,\n title: null,\n body: 'Gute App, aber der Export dauert lange.',\n author: 'mgruber',\n submittedAt: '2026-09-03T16:45:00.000Z',\n replied: false,\n },\n ],\n};\n\n/** A 99.42% crash-free user rate with two issues, both on build 118. */\nexport const fixtureCrashes: TapCrashesResult = {\n crashFreeRate: 99.42,\n issues: [\n {\n id: 'crash_1',\n title: 'ExportSession.finish — index out of range',\n count: 214,\n build: '118',\n firstSeenAt: '2026-09-01T11:02:00.000Z',\n lastSeenAt: '2026-09-07T21:40:00.000Z',\n },\n {\n id: 'crash_2',\n title: 'PhotoLibrary.load — permission revoked',\n count: 37,\n build: '118',\n firstSeenAt: '2026-09-02T07:15:00.000Z',\n lastSeenAt: '2026-09-06T13:05:00.000Z',\n },\n ],\n};\n\n/** 41,200 USD of recurring revenue, 18 refunds, and a seven-day series under it. */\nexport const fixtureRevenue: TapRevenueResult = {\n currency: 'USD',\n mrr: 41200,\n refunds: 18,\n points: week().map((at, index) => ({\n at,\n value: [1310, 1355, 1401, 1388, 1470, 1525, 1502][index],\n })),\n};\n\n/** The shape of `fixtures`: every sandbox fixture under one name. */\nexport interface TapFixtures {\n project: TapProjectResult;\n apps: TapApp[];\n releases: TapRelease[];\n keywords: TapKeyword[];\n listings: TapListing[];\n reviews: TapReviewsResult;\n crashes: TapCrashesResult;\n revenue: TapRevenueResult;\n /** `fixtureSeries`, so a series is built per metric rather than held. */\n series(metric: TapSeriesMetric): TapSeriesResult;\n}\n\n/**\n * The sandbox data the mock bridge and the portal preview both answer with, so a\n * component behaves the same in a test and in the preview.\n *\n * @remarks\n * These are the same objects the `fixture*` exports hold, gathered under one name.\n * `answerFixtureQuery` clones before it answers, but reading `fixtures` directly\n * hands you the live object, so a test that sorts or splices one has to copy it\n * first.\n *\n * @example\n * ```ts\n * import { fixtures } from '@tappify/extension-sdk/testing';\n *\n * const newest = [...fixtures.releases].sort((left, right) =>\n * right.version.localeCompare(left.version),\n * )[0];\n * ```\n */\nexport const fixtures: TapFixtures = {\n project: fixtureProject,\n apps: fixtureApps,\n releases: fixtureReleases,\n keywords: fixtureKeywords,\n listings: fixtureListings,\n reviews: fixtureReviews,\n crashes: fixtureCrashes,\n revenue: fixtureRevenue,\n series: fixtureSeries,\n};\n\n/**\n * Answers one `tap.data.query` from the fixtures, which is what the mock bridge\n * does.\n *\n * @remarks\n * Every branch is cloned with `structuredClone`, so a component that sorts or\n * splices a result cannot reach the fixture the next test reads. It checks no\n * scope — `createTapMock` refuses an ungranted kind before it gets here — and it\n * ignores the range and platform in the query, so the numbers are the same\n * whatever the filter bar says. The seven assertions inside are the one place\n * TypeScript cannot follow the distributive conditional in `TapResult<Q>` back\n * through a `switch`; each branch returns exactly the result its `case` selected.\n *\n * @example\n * ```ts\n * import { answerFixtureQuery } from '@tappify/extension-sdk/testing';\n *\n * const reviews = answerFixtureQuery({\n * kind: 'reviews',\n * range: { from: '2026-09-01', to: '2026-09-08' },\n * });\n * const lowest = Math.min(...reviews.reviews.map(review => review.rating));\n * ```\n */\nexport function answerFixtureQuery<Q extends TapQuery>(query: Q): TapResult<Q> {\n switch (query.kind) {\n case 'project':\n return structuredClone(fixtureProject) as TapResult<Q>;\n case 'series':\n return structuredClone(fixtureSeries(query.metric)) as TapResult<Q>;\n case 'keywords':\n return structuredClone({ keywords: fixtureKeywords }) as TapResult<Q>;\n case 'listing':\n return structuredClone({ listings: fixtureListings }) as TapResult<Q>;\n case 'reviews':\n return structuredClone(fixtureReviews) as TapResult<Q>;\n case 'crashes':\n return structuredClone(fixtureCrashes) as TapResult<Q>;\n case 'revenue':\n return structuredClone(fixtureRevenue) as TapResult<Q>;\n }\n}\n","import { TapError } from '../client/errors';\nimport type {\n Tap,\n TapChangeKey,\n TapChatCard,\n TapCollection,\n TapConfirmOptions,\n TapFilters,\n TapHostEvents,\n TapProcedures,\n TapSingleton,\n TapSize,\n TapStorage,\n TapToastTone,\n} from '../client/types';\nimport { QUERY_SCOPES, SCOPE_KEYS, type ScopeKey } from '../manifest/constants';\nimport type { TappifyFetchHandler } from '../server/handler';\nimport { signTestToken } from './client';\nimport {\n callEnvelope,\n DEFAULT_FILTERS,\n readEnvelopeResponse,\n} from './envelope';\nimport { answerFixtureQuery } from './fixtures';\n\n/**\n * Everything the component asked the host to do, in call order, for a test to\n * assert on.\n */\nexport interface TapMockCalls {\n /** One entry per `tap.nav.push`. */\n navigations: string[];\n /** One entry per `tap.nav.setSearch`. */\n searches: Record<string, string | null>[];\n /** One entry per `tap.ui.toast`; the tone defaults to `neutral`. */\n toasts: { message: string; tone: TapToastTone }[];\n /** One entry per `tap.ui.confirm`, whatever the mock answered. */\n confirms: TapConfirmOptions[];\n /** One entry per `tap.actions.run`, which the mock records rather than refuses. */\n actions: { actionId: string; input: unknown }[];\n /** One entry per `tap.telemetry.event`. */\n telemetry: {\n name: string;\n props?: Record<string, string | number | boolean>;\n }[];\n /** One entry per `tap.nav.openChat`. */\n chats: { prompt: string; context?: Record<string, unknown> }[];\n /** One url per `tap.nav.openExternal`, with no confirmation asked. */\n externals: string[];\n /** The filename and byte size per `tap.ui.download`, not the blob itself. */\n downloads: { filename: string; size: number }[];\n /** One entry per `tap.ui.copy`, with no clipboard touched. */\n copies: string[];\n /** One card per `tap.ui.openInChat`, unformatted. */\n cards: TapChatCard[];\n /** How many times `tap.ui.expand` was called. */\n expands: number;\n /** How many times `tap.nav.openSettings` was called. */\n settingsOpens: number;\n}\n\n/**\n * How the mock bridge is built, and the options `renderWithTap` forwards to it.\n */\nexport interface CreateTapMockOptions {\n /** Defaults to `ins_test`. */\n installId?: string;\n /** Defaults to `starter`, and has to match `handler`'s own extension id. */\n extensionId?: string;\n /** Defaults to `Starter`. */\n extensionName?: string;\n /** What the install granted. Defaults to every scope. */\n scopes?: ScopeKey[];\n /** What `tap.ui.size` reports. Defaults to `slot`. */\n size?: TapSize;\n /** Merged over the fixture filter bar. */\n filters?: Partial<TapFilters>;\n /** Merged over the fixture Northlight project. */\n project?: Partial<Tap['project']>;\n /** What `tap.context` holds. Defaults to empty. */\n context?: Record<string, unknown>;\n /** What `tap.params` holds, in the host's positional shape. Defaults to empty. */\n params?: Record<string, string>;\n /** What `useTapTheme` reports. Defaults to `light`. */\n theme?: 'light' | 'dark';\n /** What `tap.ui.confirm` resolves to. Defaults to `true`. */\n confirmAnswer?: boolean;\n /** The collections to expose, and the kind of each. Left out, every name works. */\n storage?: Record<string, 'singleton' | 'collection'>;\n /** One function per procedure, answering `tap.server.<name>` in process. */\n server?: Record<string, (input: unknown) => unknown>;\n /** Your own handler, so `tap.server.<name>` goes through its real routes. */\n handler?: TappifyFetchHandler;\n /** A token to send to `handler`. Defaults to one the mock signs itself. */\n handlerToken?: string;\n}\n\n/** The mock bridge, with the recorded calls and the handles that drive it. */\nexport interface TapMock {\n /** The bridge itself, which `renderWithTap` puts above the component. */\n tap: Tap;\n calls: TapMockCalls;\n /** The node `TapDialog` renders into, appended to the document by `renderWithTap`. */\n portal: HTMLElement;\n /** What a collection holds now, or just the one document under `documentId`. */\n documents(collection: string, documentId?: string): unknown[];\n /** Delivers a Tappify event to everything subscribed through `tap.data.subscribe`. */\n emit<E extends keyof TapHostEvents>(\n event: E,\n payload: TapHostEvents[E],\n ): void;\n /** Replaces the whole filter bar and re-renders the hooks that read it. */\n setFilters(filters: TapFilters): void;\n /** Moves the mount between slot, panel and page. */\n setSize(size: TapSize): void;\n /** Switches the theme `useTapTheme` reports. */\n setTheme(mode: 'light' | 'dark'): void;\n /** Replaces the route `useTapParams` reports, in the host's own positional shape. */\n setParams(params: Record<string, string>): void;\n}\n\ninterface StoredDocument {\n id: string;\n data: unknown;\n}\n\ntype StorageHandle = TapSingleton<unknown> & TapCollection<unknown>;\n\ntype ExposedHandle = TapSingleton<unknown> | TapCollection<unknown>;\n\nconst SINGLETON_ID = 'singleton';\n\nconst PROBE_KEYS = new Set([\n 'then',\n 'toJSON',\n '$$typeof',\n 'constructor',\n 'prototype',\n 'valueOf',\n 'toString',\n 'inspect',\n 'asymmetricMatch',\n 'nodeType',\n]);\n\nfunction unknownCollectionError(collection: string): TapError {\n return new TapError(\n 'TAP_UNKNOWN_COLLECTION',\n `This mock exposes no storage collection called \"${collection}\". createTapMock({ storage: … }) was given an explicit map, so only the collections it names exist. Add \"${collection}\" to that map, or drop the storage option to expose every collection.`,\n );\n}\n\nfunction singletonView(handle: StorageHandle): TapSingleton<unknown> {\n return {\n get: () => handle.get(),\n set: document => handle.set(document),\n patch: partial => handle.patch(partial),\n };\n}\n\nfunction collectionView(handle: StorageHandle): TapCollection<unknown> {\n return {\n list: listOptions => handle.list(listOptions),\n get: id => handle.get(id),\n put: (id, document) => handle.put(id, document),\n delete: id => handle.delete(id),\n };\n}\n\nfunction scopeError(scope: ScopeKey): TapError {\n return new TapError(\n 'TAP_SCOPE_MISSING',\n `This install has not granted ${scope}. Declare it under \"scopes\" in tappify.extension.json, or pass scopes: [\"${scope}\"] to renderWithTap() to test the granted path.`,\n );\n}\n\nfunction asObject(value: unknown): object {\n return typeof value === 'object' && value !== null ? value : {};\n}\n\n/**\n * Builds the bridge a component talks to in a test, without rendering anything.\n *\n * @remarks\n * Data queries answer from the sandbox fixtures, storage is an in-memory store, and\n * everything else the host would do is recorded in `calls`. Scopes default to all of\n * them: pass `scopes` to test the refused path, where a data query rejects with\n * `TAP_SCOPE_MISSING` for the kind's own scope and every storage call, reads\n * included, needs `storage:write`. A procedure needs either `server`, which answers\n * in process, or `handler`, which is called over a real `Request` with a token the\n * mock signs — so that handler has to be built with `jwks: await testJwks()` and the\n * same `extensionId` — and without either, `tap.server.<name>` rejects with\n * `TAP_UNKNOWN_PROCEDURE`. With `storage` given, a collection the map does not name\n * throws `TAP_UNKNOWN_COLLECTION`. Unlike the host, this mock records\n * `tap.actions.run` and resolves it as pending rather than refusing it, so a test\n * can assert on the call today. Use `renderWithTap` when there is a component to\n * render.\n *\n * @example\n * ```ts\n * import { createTapMock } from '@tappify/extension-sdk/testing';\n * import { expect, it } from 'vitest';\n *\n * it('answers a keyword query from the fixtures', async () => {\n * const mock = createTapMock({ scopes: ['store.metadata:read'] });\n * const keywords = await mock.tap.data.query({ kind: 'keywords' });\n * expect(keywords.keywords).toHaveLength(3);\n * });\n * ```\n */\nexport function createTapMock(options: CreateTapMockOptions = {}): TapMock {\n const granted = new Set<ScopeKey>(options.scopes ?? SCOPE_KEYS);\n const listeners = new Map<TapChangeKey, Set<() => void>>();\n const eventHandlers = new Map<string, Set<(payload: unknown) => void>>();\n const state = new Map<string, unknown>();\n const store = new Map<string, StoredDocument[]>();\n\n const portal = document.createElement('div');\n portal.dataset.tapPortal = 'true';\n\n const calls: TapMockCalls = {\n navigations: [],\n searches: [],\n toasts: [],\n confirms: [],\n actions: [],\n telemetry: [],\n chats: [],\n externals: [],\n downloads: [],\n copies: [],\n cards: [],\n expands: 0,\n settingsOpens: 0,\n };\n\n const emitChange = (key: TapChangeKey): void => {\n for (const listener of listeners.get(key) ?? []) listener();\n };\n\n const subscribe = (key: TapChangeKey, listener: () => void): (() => void) => {\n const set = listeners.get(key) ?? new Set<() => void>();\n set.add(listener);\n listeners.set(key, set);\n return () => {\n set.delete(listener);\n };\n };\n\n const withStorage = <T>(run: () => T): Promise<T> =>\n granted.has('storage:write')\n ? Promise.resolve(run())\n : Promise.reject(scopeError('storage:write'));\n\n const bucket = (collection: string): StoredDocument[] => {\n const existing = store.get(collection);\n if (existing) return existing;\n const created: StoredDocument[] = [];\n store.set(collection, created);\n return created;\n };\n\n function buildHandle(collection: string): StorageHandle {\n const find = (id: string): StoredDocument | undefined =>\n bucket(collection).find(entry => entry.id === id);\n\n const write = (id: string, data: unknown): void => {\n const items = bucket(collection);\n const index = items.findIndex(entry => entry.id === id);\n if (index === -1) items.push({ id, data });\n else items[index] = { id, data };\n emitChange(`storage:${collection}`);\n };\n\n return {\n get: (id?: string) =>\n withStorage(() => find(id ?? SINGLETON_ID)?.data ?? null),\n set: document =>\n withStorage(() => {\n write(SINGLETON_ID, document);\n }),\n patch: partial =>\n withStorage(() => {\n const merged = { ...asObject(find(SINGLETON_ID)?.data), ...partial };\n write(SINGLETON_ID, merged);\n return merged;\n }),\n list: () =>\n withStorage(() => ({\n items: bucket(collection)\n .filter(entry => entry.id !== SINGLETON_ID)\n .map(entry => ({ ...asObject(entry.data), id: entry.id })),\n })),\n put: (id, document) =>\n withStorage(() => {\n write(id, document);\n }),\n delete: id =>\n withStorage(() => {\n const items = bucket(collection);\n const index = items.findIndex(entry => entry.id === id);\n if (index !== -1) {\n items.splice(index, 1);\n emitChange(`storage:${collection}`);\n }\n }),\n };\n }\n\n const handles = new Map<string, ExposedHandle>();\n const kinds = options.storage;\n\n const exposeHandle = (collection: string): ExposedHandle => {\n const kind = kinds?.[collection];\n if (kinds !== undefined && kind === undefined) {\n throw unknownCollectionError(collection);\n }\n\n const handle = buildHandle(collection);\n if (kind === 'singleton') return singletonView(handle);\n if (kind === 'collection') return collectionView(handle);\n return handle;\n };\n\n const handleFor = (collection: string): ExposedHandle | undefined => {\n if (PROBE_KEYS.has(collection)) return undefined;\n\n const existing = handles.get(collection);\n if (existing) return existing;\n const created = exposeHandle(collection);\n handles.set(collection, created);\n return created;\n };\n\n const storageTarget: TapStorage = {};\n const storage = new Proxy(storageTarget, {\n get: (_target, property) =>\n typeof property === 'string' ? handleFor(property) : undefined,\n has: () => true,\n ownKeys: () => [...store.keys()],\n getOwnPropertyDescriptor: () => ({ enumerable: true, configurable: true }),\n });\n\n let calledProcedures = 0;\n let signedToken: Promise<string> | null = null;\n\n function handlerToken(): Promise<string> {\n if (options.handlerToken !== undefined) {\n return Promise.resolve(options.handlerToken);\n }\n signedToken ??= signTestToken(\n {\n installId: tap.extension.installId,\n extensionId: tap.extension.id,\n projectId: tap.extension.projectId,\n organizationId: tap.auth.organizationId,\n scopes: [...granted],\n },\n { extensionId: tap.extension.id },\n );\n return signedToken;\n }\n\n async function callProcedure(name: string, input: unknown): Promise<unknown> {\n const local = options.server?.[name];\n if (local) return local(input);\n\n if (options.handler) {\n const path = `/tappify/procedures/${name}`;\n calledProcedures += 1;\n const response = await options.handler(\n new Request(`https://vendor.test${path}`, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n 'x-tappify-event-id': `evt_${name}_${String(calledProcedures)}`,\n authorization: `Bearer ${await handlerToken()}`,\n },\n body: callEnvelope({\n install: {\n id: tap.extension.installId,\n extensionId: tap.extension.id,\n projectId: tap.extension.projectId,\n organizationId: tap.auth.organizationId,\n },\n filters: tap.filters,\n input,\n }),\n }),\n );\n\n return readEnvelopeResponse(response, `POST ${path}`);\n }\n\n throw new TapError(\n 'TAP_UNKNOWN_PROCEDURE',\n `No handler is registered for the procedure \"${name}\". Pass server: { ${name}: input => … } or handler: <your createTappifyHandler handler> to createTapMock().`,\n );\n }\n\n const serverTarget: TapProcedures = {};\n\n const tap: Tap = {\n extension: {\n id: options.extensionId ?? 'starter',\n name: options.extensionName ?? 'Starter',\n installId: options.installId ?? 'ins_test',\n projectId: 'prj_north',\n },\n env: 'dev',\n host: { version: 'test', sdkMajors: [2] },\n auth: {\n token: 'test-token',\n user: { id: 'usr_test', role: 'admin' },\n organizationId: 'org_test',\n scopes: [...granted],\n can: scope => granted.has(scope),\n },\n project: {\n id: 'prj_north',\n name: 'Northlight',\n platforms: ['ios', 'android'],\n apps: [],\n releases: [],\n keywords: [],\n ...options.project,\n },\n filters: { ...DEFAULT_FILTERS, ...options.filters },\n theme: { mode: options.theme ?? 'light' },\n locale: 'en-US',\n timezone: 'UTC',\n format: {\n number: (value, formatOptions) =>\n new Intl.NumberFormat('en-US', formatOptions).format(value),\n currency: (value, code) =>\n new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: code,\n }).format(value),\n date: value => new Date(value).toISOString().slice(0, 10),\n relative: value => new Date(value).toISOString(),\n },\n nav: {\n push: path => calls.navigations.push(path),\n setSearch: params => calls.searches.push(params),\n openSettings: () => {\n calls.settingsOpens += 1;\n },\n openChat: (prompt, context) => calls.chats.push({ prompt, context }),\n openExternal: url => calls.externals.push(url),\n },\n data: {\n query: query => {\n const scope = QUERY_SCOPES[query.kind];\n if (!granted.has(scope)) return Promise.reject(scopeError(scope));\n return Promise.resolve(answerFixtureQuery(query));\n },\n subscribe: <E extends keyof TapHostEvents>(\n event: E,\n handler: (payload: TapHostEvents[E]) => void,\n ): (() => void) => {\n const key = String(event);\n const set = eventHandlers.get(key) ?? new Set<(p: unknown) => void>();\n const wrapped = (payload: unknown): void => {\n handler(payload as TapHostEvents[E]);\n };\n set.add(wrapped);\n eventHandlers.set(key, set);\n return () => {\n set.delete(wrapped);\n };\n },\n },\n server: new Proxy(serverTarget, {\n get:\n (_target, property) =>\n (input: unknown): Promise<unknown> =>\n callProcedure(String(property), input),\n has: () => true,\n }),\n state: {\n get: <T>(key: string): T | undefined => {\n const value = state.get(key);\n return value === undefined ? undefined : (value as T);\n },\n set: (key, value) => {\n state.set(key, value);\n emitChange(`state:${key}`);\n },\n subscribe: (key, handler) => subscribe(`state:${key}`, handler),\n },\n ui: {\n size: options.size ?? 'slot',\n toast: (message, tone = 'neutral') =>\n calls.toasts.push({ message, tone }),\n confirm: confirmOptions => {\n calls.confirms.push(confirmOptions);\n return Promise.resolve(options.confirmAnswer ?? true);\n },\n openInChat: card => calls.cards.push(card),\n expand: () => {\n calls.expands += 1;\n },\n download: (blob, filename) =>\n calls.downloads.push({ filename, size: blob.size }),\n copy: text => {\n calls.copies.push(text);\n return Promise.resolve();\n },\n },\n context: options.context ?? {},\n params: options.params ?? {},\n storage,\n telemetry: {\n event: (name, props) => calls.telemetry.push({ name, props }),\n },\n actions: {\n run: (actionId, input) => {\n calls.actions.push({ actionId, input });\n return Promise.resolve({\n id: `run_${String(calls.actions.length)}`,\n actionId,\n status: 'pending' as const,\n requestedAt: new Date(0).toISOString(),\n });\n },\n },\n invalidate: () => undefined,\n __portal: portal,\n __subscribe: subscribe,\n };\n\n return {\n tap,\n calls,\n portal,\n documents: (collection, documentId) =>\n bucket(collection)\n .filter(entry => documentId === undefined || entry.id === documentId)\n .map(entry => entry.data),\n emit: (event, payload) => {\n for (const handler of eventHandlers.get(String(event)) ?? []) {\n handler(payload);\n }\n },\n setFilters: filters => {\n tap.filters = filters;\n emitChange('filters');\n },\n setSize: size => {\n tap.ui = { ...tap.ui, size };\n emitChange('size');\n },\n setTheme: mode => {\n tap.theme = { mode };\n emitChange('theme');\n },\n setParams: params => {\n tap.params = params;\n emitChange('params');\n },\n };\n}\n","import { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport {\n render,\n type RenderOptions,\n type RenderResult,\n} from '@testing-library/react';\nimport type { ReactElement, ReactNode } from 'react';\nimport { installPrefix, procedurePrefix } from '../client/query';\nimport type { Tap } from '../client/types';\nimport { TapHostProvider } from '../host/provider';\nimport { createTapMock, type CreateTapMockOptions, type TapMock } from './mock';\n\n/**\n * What `renderWithTap` takes: its own three options, plus every\n * `CreateTapMockOptions` member it forwards to the mock.\n */\nexport interface RenderWithTapOptions extends CreateTapMockOptions {\n /** A mock you built yourself. Given, every mock option here is ignored. */\n mock?: TapMock;\n /** Your own client, for a test that reads the cache. Defaults to a fresh one. */\n queryClient?: QueryClient;\n /** Passed to Testing Library's `render`, for a mount point of your own. */\n container?: RenderOptions['container'];\n}\n\n/** What `renderWithTap` returns: Testing Library's result plus the bridge. */\nexport interface RenderWithTapResult extends RenderResult {\n /** The same object `useTap` returns inside the component. */\n tap: Tap;\n /** The mock behind the bridge, which the matchers take. */\n mock: TapMock;\n /** The client the render used, whether it was passed in or built here. */\n queryClient: QueryClient;\n}\n\n/**\n * Renders a component against the mock bridge, so a widget, tab, page, row action\n * or settings panel is testable outside Tappify.\n *\n * @remarks\n * It builds a mock from the same options `createTapMock` takes unless you pass\n * `mock`, wraps the component in the host provider and a `QueryClient` that does\n * not retry and does not cache between tests, and appends the mock's portal to the\n * rendered document so `TapDialog` has somewhere to go. It rewires\n * `tap.invalidate` onto that client, so a component calling it drops the right\n * cache entries. Scopes default to all of them, so pass `scopes` to cover the\n * refused path; a `handler` has to be built with `jwks: await testJwks()` and the\n * same `extensionId` the mock reports. Load\n * `@tappify/extension-sdk/testing/vitest` or `.../testing/jest` as a setup file\n * first: that installs the host CSS variables, registers the matchers and clears\n * the portal between tests.\n *\n * @example\n * ```tsx\n * import { TapStat, useTapQuery } from '@tappify/extension-sdk';\n * import { renderWithTap } from '@tappify/extension-sdk/testing';\n * import { screen, waitFor } from '@testing-library/react';\n * import { expect, it } from 'vitest';\n *\n * function Crashes() {\n * const crashes = useTapQuery({\n * kind: 'crashes',\n * range: { from: '2026-09-01', to: '2026-09-08' },\n * });\n * return <TapStat label=\"Issues\" value={crashes.data?.issues.length ?? 0} />;\n * }\n *\n * it('renders the issues the fixtures answer with', async () => {\n * renderWithTap(<Crashes />, { scopes: ['ui:render', 'crashes:read'] });\n * await waitFor(() => expect(screen.getByText('2')).toBeTruthy());\n * });\n * ```\n */\nexport function renderWithTap(\n ui: ReactElement,\n options: RenderWithTapOptions = {},\n): RenderWithTapResult {\n const mock = options.mock ?? createTapMock(options);\n const queryClient =\n options.queryClient ??\n new QueryClient({\n defaultOptions: { queries: { retry: false, gcTime: 0 } },\n });\n\n const installId = mock.tap.extension.installId;\n mock.tap.invalidate = name => {\n void queryClient.invalidateQueries({\n queryKey:\n name === undefined\n ? installPrefix(installId)\n : procedurePrefix(installId, name),\n });\n };\n\n function Wrapper({ children }: { children: ReactNode }): ReactElement {\n return (\n <QueryClientProvider client={queryClient}>\n <TapHostProvider tap={mock.tap}>{children}</TapHostProvider>\n </QueryClientProvider>\n );\n }\n\n const result = render(ui, { wrapper: Wrapper, container: options.container });\n result.baseElement.append(mock.portal);\n\n return { ...result, tap: mock.tap, mock, queryClient };\n}\n","import { CARD_KEYS } from '../manifest/constants';\nimport type { MetricDeclaration, ToolDeclaration } from '../manifest/types';\n\nfunction record(value: unknown): Record<string, unknown> | null {\n return typeof value === 'object' && value !== null\n ? (value as Record<string, unknown>)\n : null;\n}\n\nfunction list(value: unknown): unknown[] | null {\n return Array.isArray(value) ? value : null;\n}\n\nfunction isPoint(value: unknown): boolean {\n const pair = list(value);\n return (\n pair !== null &&\n pair.length === 2 &&\n typeof pair[0] === 'string' &&\n typeof pair[1] === 'number'\n );\n}\n\n/**\n * Checks a metrics response against the metrics the manifest declares and returns\n * what is wrong with it.\n *\n * @remarks\n * Returns an empty array when the response is sound, so a test asserts on an empty\n * list. It reports a body that is not `{ series: [...] }`, an entry with no\n * `metric` key, a metric the declarations do not name, a unit that disagrees with\n * the declared one, a missing `points` array, and any point that is not a\n * `[string, number]` pair. It does not check that every declared metric is\n * answered, so assert on the length yourself when that matters. The strings are the\n * ones `tappify extension doctor` reports.\n *\n * @example\n * ```ts\n * import { validateMetricsResponse } from '@tappify/extension-sdk/testing';\n * import { expect, it } from 'vitest';\n *\n * const metrics = [\n * { key: 'orders', label: 'Orders', unit: 'count' as const, kind: 'counter' as const },\n * ];\n *\n * it('answers orders as a counted series', () => {\n * const response = { series: [{ metric: 'orders', unit: 'count', points: [['2026-09-01', 12]] }] };\n * expect(validateMetricsResponse(response, metrics)).toEqual([]);\n * });\n * ```\n */\nexport function validateMetricsResponse(\n response: unknown,\n metrics: MetricDeclaration[],\n): string[] {\n const series = list(record(response)?.series);\n\n if (series === null) {\n return [\n 'A metrics response is { \"series\": [...] }. Return one entry per declared metric, even when it has no points.',\n ];\n }\n\n const issues: string[] = [];\n const declared = new Map(metrics.map(metric => [metric.key, metric]));\n\n for (const [index, entry] of series.entries()) {\n const item = record(entry);\n const key = typeof item?.metric === 'string' ? item.metric : null;\n\n if (item === null || key === null) {\n issues.push(`series[${String(index)}] has no \"metric\" key.`);\n continue;\n }\n\n const metric = declared.get(key);\n if (metric === undefined) {\n issues.push(\n `series[${String(index)}] reports \"${key}\", which is not declared under contributes.connector.metrics.`,\n );\n continue;\n }\n\n if (item.unit !== metric.unit) {\n issues.push(\n `series[${String(index)}] reports unit \"${String(item.unit)}\" but \"${key}\" is declared as \"${metric.unit}\".`,\n );\n }\n\n const points = list(item.points);\n if (points === null) {\n issues.push(`series[${String(index)}] has no \"points\" array.`);\n continue;\n }\n\n for (const [pointIndex, point] of points.entries()) {\n if (!isPoint(point)) {\n issues.push(\n `series[${String(index)}].points[${String(pointIndex)}] must be a two-element [timestamp, value] pair: a string and a number.`,\n );\n }\n }\n }\n\n return issues;\n}\n\n/**\n * Checks a tool's answer against the card shape its declared `returns` kind has to\n * carry, and returns what is missing.\n *\n * @remarks\n * Returns an empty array when the answer is sound. A `value` card needs `label` and\n * `value`, a `series` card `label` and `points`, a `table` card `columns` and\n * `rows`, a `list` card `items`, and a `comparison` card `label`, `left` and\n * `right`; anything that is not an object is reported on its own. It checks the\n * keys are present, not what they hold, so an empty `rows` array passes.\n *\n * @example\n * ```ts\n * import { validateToolResponse } from '@tappify/extension-sdk/testing';\n * import { expect, it } from 'vitest';\n *\n * it('answers keyword_gaps with a table card', () => {\n * const card = { columns: [{ key: 'term', label: 'Term' }], rows: [] };\n * expect(validateToolResponse(card, 'table')).toEqual([]);\n * });\n * ```\n */\nexport function validateToolResponse(\n value: unknown,\n returns: ToolDeclaration['returns'],\n): string[] {\n const body = record(value);\n if (body === null) {\n return [\n `A \"${returns}\" tool returns an object the host draws as a card, not ${typeof value}.`,\n ];\n }\n\n return CARD_KEYS[returns]\n .filter(key => !(key in body))\n .map(\n key =>\n `A \"${returns}\" tool response needs a \"${key}\" key; the host draws the card from it.`,\n );\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/extension-sdk/extension-sdk/dist/testing/index.cjs","../../src/testing/render.tsx","../../src/testing/validators.ts","../../src/testing/work-events.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACF,yDAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACA;ACxCA,mDAAiD;AACjD;AACE;AAAA,+CAGK;AA6FC,+CAAA;AAxBD,SAAS,aAAA,CACd,EAAA,EACA,QAAA,EAAgC,CAAC,CAAA,EACZ;AACrB,EAAA,MAAM,KAAA,mBAAO,OAAA,CAAQ,IAAA,UAAQ,6CAAA,OAAqB,GAAA;AAClD,EAAA,MAAM,YAAA,mBACJ,OAAA,CAAQ,WAAA,UACR,IAAI,4BAAA,CAAY;AAAA,IACd,cAAA,EAAgB,EAAE,OAAA,EAAS,EAAE,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,EAAE,EAAE;AAAA,EACzD,CAAC,GAAA;AAEH,EAAA,MAAM,UAAA,EAAY,IAAA,CAAK,GAAA,CAAI,SAAA,CAAU,SAAA;AACrC,EAAA,IAAA,CAAK,GAAA,CAAI,WAAA,EAAa,CAAA,IAAA,EAAA,GAAQ;AAC5B,IAAA,KAAK,WAAA,CAAY,iBAAA,CAAkB;AAAA,MACjC,QAAA,EACE,KAAA,IAAS,KAAA,EAAA,EACL,6CA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A,IACZ,SAAA,EAAW,8BAAA;AAAA,IACX,GAAG;AAAA,EACL,CAAA;AACF;AAUA,MAAA,SAAsB,sBAAA,CACpB,KAAA,EACA,OAAA,EACkB;AAClB,EAAA,IAAI,OAAA;AACJ,EAAA,MAAM,6CAAA,KAAc,EAAO;AAAA,IACzB,GAAG,OAAA;AAAA,IACH,KAAA,EAAO,CAAC,KAAA,EAAO,IAAA,EAAA,GAAS;AACtB,MAAA,QAAA,EAAU,IAAI,OAAA,CAAQ,KAAA,EAAO,IAAI,CAAA;AACjC,MAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,IAAI,QAAA,CAAS,IAAA,EAAM,EAAE,MAAA,EAAQ,IAAI,CAAC,CAAC,CAAA;AAAA,IAC5D;AAAA,EACF,CAAC,CAAA;AACD,EAAA,GAAA,CAAI,CAAC,OAAA;AACH,IAAA,MAAM,IAAI,KAAA,CAAM,kDAAkD,CAAA;AACpE,EAAA,OAAO,OAAA;AACT;AHmGA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,g6CAAC","file":"/home/runner/work/extension-sdk/extension-sdk/dist/testing/index.cjs","sourcesContent":[null,"import { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport {\n render,\n type RenderOptions,\n type RenderResult,\n} from '@testing-library/react';\nimport type { ReactElement, ReactNode } from 'react';\nimport { installPrefix, procedurePrefix } from '../client/query';\nimport type { Tap } from '../client/types';\nimport { TapHostProvider } from '../host/provider';\nimport { createTapMock, type CreateTapMockOptions, type TapMock } from './mock';\n\n/**\n * What `renderWithTap` takes: its own three options, plus every\n * `CreateTapMockOptions` member it forwards to the mock.\n */\nexport interface RenderWithTapOptions extends CreateTapMockOptions {\n /** A mock you built yourself. Given, every mock option here is ignored. */\n mock?: TapMock;\n /** Your own client, for a test that reads the cache. Defaults to a fresh one. */\n queryClient?: QueryClient;\n /** Passed to Testing Library's `render`, for a mount point of your own. */\n container?: RenderOptions['container'];\n}\n\n/** What `renderWithTap` returns: Testing Library's result plus the bridge. */\nexport interface RenderWithTapResult extends RenderResult {\n /** The same object `useTap` returns inside the component. */\n tap: Tap;\n /** The mock behind the bridge, which the matchers take. */\n mock: TapMock;\n /** The client the render used, whether it was passed in or built here. */\n queryClient: QueryClient;\n}\n\n/**\n * Renders a component against the mock bridge, so a widget, tab, page, row action\n * or settings panel is testable outside Tappify.\n *\n * @remarks\n * It builds a mock from the same options `createTapMock` takes unless you pass\n * `mock`, wraps the component in the host provider and a `QueryClient` that does\n * not retry and does not cache between tests, and appends the mock's portal to the\n * rendered document so SDK dialogs have somewhere to go. It rewires\n * `tap.invalidate` onto that client, so a component calling it drops the right\n * cache entries. Scopes default to all of them, so pass `scopes` to cover the\n * refused path; a `handler` has to be built with `jwks: await testJwks()` and the\n * same `extensionId` the mock reports. Load\n * `@tappify/extension-sdk/testing/vitest` or `.../testing/jest` as a setup file\n * first: that installs the host CSS variables, registers the matchers and clears\n * the portal between tests.\n *\n * @example\n * ```tsx\n * import { useTapQuery } from '@tappify/extension-sdk';\n * import { Metric } from '@tappify/extension-sdk/ui';\n * import { renderWithTap } from '@tappify/extension-sdk/testing';\n * import { screen, waitFor } from '@testing-library/react';\n * import { expect, it } from 'vitest';\n *\n * function Crashes() {\n * const crashes = useTapQuery({\n * kind: 'crashes',\n * range: { from: '2026-09-01', to: '2026-09-08' },\n * });\n * return <Metric label=\"Issues\" value={crashes.data?.issues.length ?? 0} />;\n * }\n *\n * it('renders the issues the fixtures answer with', async () => {\n * renderWithTap(<Crashes />, { scopes: ['ui:render', 'crashes:read'] });\n * await waitFor(() => expect(screen.getByText('2')).toBeTruthy());\n * });\n * ```\n */\nexport function renderWithTap(\n ui: ReactElement,\n options: RenderWithTapOptions = {},\n): RenderWithTapResult {\n const mock = options.mock ?? createTapMock(options);\n const queryClient =\n options.queryClient ??\n new QueryClient({\n defaultOptions: { queries: { retry: false, gcTime: 0 } },\n });\n\n const installId = mock.tap.extension.installId;\n mock.tap.invalidate = name => {\n void queryClient.invalidateQueries({\n queryKey:\n name === undefined\n ? installPrefix(installId)\n : procedurePrefix(installId, name),\n });\n };\n\n function Wrapper({ children }: { children: ReactNode }): ReactElement {\n return (\n <QueryClientProvider client={queryClient}>\n <TapHostProvider tap={mock.tap}>{children}</TapHostProvider>\n </QueryClientProvider>\n );\n }\n\n const result = render(ui, { wrapper: Wrapper, container: options.container });\n result.baseElement.append(mock.portal);\n\n return { ...result, tap: mock.tap, mock, queryClient };\n}\n","import { CARD_KEYS } from '../manifest/constants';\nimport type { MetricDeclaration, ToolDeclaration } from '../manifest/types';\n\nfunction record(value: unknown): Record<string, unknown> | null {\n return typeof value === 'object' && value !== null\n ? (value as Record<string, unknown>)\n : null;\n}\n\nfunction list(value: unknown): unknown[] | null {\n return Array.isArray(value) ? value : null;\n}\n\nfunction isPoint(value: unknown): boolean {\n const pair = list(value);\n return (\n pair !== null &&\n pair.length === 2 &&\n typeof pair[0] === 'string' &&\n typeof pair[1] === 'number'\n );\n}\n\n/**\n * Checks a metrics response against the metrics the manifest declares and returns\n * what is wrong with it.\n *\n * @remarks\n * Returns an empty array when the response is sound, so a test asserts on an empty\n * list. It reports a body that is not `{ series: [...] }`, an entry with no\n * `metric` key, a metric the declarations do not name, a unit that disagrees with\n * the declared one, a missing `points` array, and any point that is not a\n * `[string, number]` pair. It does not check that every declared metric is\n * answered, so assert on the length yourself when that matters. The strings are the\n * ones `tappify extension doctor` reports.\n *\n * @example\n * ```ts\n * import { validateMetricsResponse } from '@tappify/extension-sdk/testing';\n * import { expect, it } from 'vitest';\n *\n * const metrics = [\n * { key: 'orders', label: 'Orders', unit: 'count' as const, kind: 'counter' as const },\n * ];\n *\n * it('answers orders as a counted series', () => {\n * const response = { series: [{ metric: 'orders', unit: 'count', points: [['2026-09-01', 12]] }] };\n * expect(validateMetricsResponse(response, metrics)).toEqual([]);\n * });\n * ```\n */\nexport function validateMetricsResponse(\n response: unknown,\n metrics: MetricDeclaration[],\n): string[] {\n const series = list(record(response)?.series);\n\n if (series === null) {\n return [\n 'A metrics response is { \"series\": [...] }. Return one entry per declared metric, even when it has no points.',\n ];\n }\n\n const issues: string[] = [];\n const declared = new Map(metrics.map(metric => [metric.key, metric]));\n\n for (const [index, entry] of series.entries()) {\n const item = record(entry);\n const key = typeof item?.metric === 'string' ? item.metric : null;\n\n if (item === null || key === null) {\n issues.push(`series[${String(index)}] has no \"metric\" key.`);\n continue;\n }\n\n const metric = declared.get(key);\n if (metric === undefined) {\n issues.push(\n `series[${String(index)}] reports \"${key}\", which is not declared under contributes.connector.metrics.`,\n );\n continue;\n }\n\n if (item.unit !== metric.unit) {\n issues.push(\n `series[${String(index)}] reports unit \"${String(item.unit)}\" but \"${key}\" is declared as \"${metric.unit}\".`,\n );\n }\n\n const points = list(item.points);\n if (points === null) {\n issues.push(`series[${String(index)}] has no \"points\" array.`);\n continue;\n }\n\n for (const [pointIndex, point] of points.entries()) {\n if (!isPoint(point)) {\n issues.push(\n `series[${String(index)}].points[${String(pointIndex)}] must be a two-element [timestamp, value] pair: a string and a number.`,\n );\n }\n }\n }\n\n return issues;\n}\n\n/**\n * Checks a tool's answer against the card shape its declared `returns` kind has to\n * carry, and returns what is missing.\n *\n * @remarks\n * Returns an empty array when the answer is sound. A `value` card needs `label` and\n * `value`, a `series` card `label` and `points`, a `table` card `columns` and\n * `rows`, a `list` card `items`, and a `comparison` card `label`, `left` and\n * `right`; anything that is not an object is reported on its own. It checks the\n * keys are present, not what they hold, so an empty `rows` array passes.\n *\n * @example\n * ```ts\n * import { validateToolResponse } from '@tappify/extension-sdk/testing';\n * import { expect, it } from 'vitest';\n *\n * it('answers keyword_gaps with a table card', () => {\n * const card = { columns: [{ key: 'term', label: 'Term' }], rows: [] };\n * expect(validateToolResponse(card, 'table')).toEqual([]);\n * });\n * ```\n */\nexport function validateToolResponse(\n value: unknown,\n returns: ToolDeclaration['returns'],\n): string[] {\n const body = record(value);\n if (body === null) {\n return [\n `A \"${returns}\" tool returns an object the host draws as a card, not ${typeof value}.`,\n ];\n }\n\n return CARD_KEYS[returns]\n .filter(key => !(key in body))\n .map(\n key =>\n `A \"${returns}\" tool response needs a \"${key}\" key; the host draws the card from it.`,\n );\n}\n","import type {\n WorkHydratedCommentCreatedEvent,\n WorkHydratedItemDeletedEvent,\n WorkHydratedStatusChangedEvent,\n} from '../server/work';\nimport {\n sendWorkEvent,\n type SendWorkEventOptions,\n type WorkEvent,\n} from '../server/work-events';\n\n/** A fresh complete comment signal with deterministic identity and shallow overrides. */\nexport function workCommentCreatedFixture(\n overrides: Partial<WorkHydratedCommentCreatedEvent> = {},\n): WorkHydratedCommentCreatedEvent {\n return {\n type: 'comment.created',\n externalItemId: 'item_test',\n providerEventId: 'event_comment_test',\n occurredAt: '2026-10-15T12:00:00.000Z',\n dedupeKey: 'item_test:event_comment_test',\n comment: {\n externalCommentId: 'comment_test',\n body: 'A provider comment.',\n author: { id: 'author_test', displayName: 'Sam' },\n createdAt: '2026-10-15T12:00:00.000Z',\n },\n ...overrides,\n };\n}\n\n/** A fresh complete status signal with deterministic identity and shallow overrides. */\nexport function workStatusChangedFixture(\n overrides: Partial<WorkHydratedStatusChangedEvent> = {},\n): WorkHydratedStatusChangedEvent {\n return {\n type: 'status.changed',\n externalItemId: 'item_test',\n providerEventId: 'event_status_test',\n occurredAt: '2026-10-15T12:00:00.000Z',\n dedupeKey: 'item_test:event_status_test',\n status: { id: 'resolved_test', label: 'Resolved', stage: 'done' },\n ...overrides,\n };\n}\n\n/** A fresh deletion signal with deterministic identity and shallow overrides. */\nexport function workItemDeletedFixture(\n overrides: Partial<WorkHydratedItemDeletedEvent> = {},\n): WorkHydratedItemDeletedEvent {\n return {\n type: 'item.deleted',\n externalItemId: 'item_test',\n providerEventId: 'event_deleted_test',\n occurredAt: '2026-10-15T12:00:00.000Z',\n dedupeKey: 'item_test:event_deleted_test',\n ...overrides,\n };\n}\n\n/**\n * Captures a signed work-event Request through the real sender without network I/O.\n *\n * @remarks\n * Uses the same validation, serialization, signing and callback URL as\n * sendWorkEvent. Supply the callback and secret your test install was configured\n * with; the accepting transport is supplied by this helper.\n */\nexport async function signedWorkEventRequest(\n event: WorkEvent,\n options: Omit<SendWorkEventOptions, 'fetch'>,\n): Promise<Request> {\n let request: Request | undefined;\n await sendWorkEvent(event, {\n ...options,\n fetch: (input, init) => {\n request = new Request(input, init);\n return Promise.resolve(new Response(null, { status: 202 }));\n },\n });\n if (!request)\n throw new Error('The work event sender did not produce a request.');\n return request;\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { JSONWebKeySet } from 'jose';
2
- import { a as TapFilters, N as TapProjectResult, o as TapApp, Q as TapRelease, D as TapKeyword, F as TapListing, U as TapReviewsResult, v as TapCrashesResult, R as TapRevenueResult, W as TapSeriesMetric, Y as TapSeriesResult, d as TapQuery, e as TapResult, b as TapSize, T as Tap, a6 as TapToastTone, t as TapConfirmOptions, q as TapChatCard, c as TapHostEvents } from '../types-DrpQSv_2.cjs';
3
- import { h as TappifyHealth, b as MetricsInput, c as MetricsResponse, M as MentionItems, C as ContextBlock, W as WorkOperation, i as TappifyInstall, g as TappifyHandlerOptions, a as TappifyClaims, T as TappifyFetchHandler } from '../handler-kU9Jf36K.cjs';
2
+ import { a as TapFilters, N as TapProjectResult, o as TapApp, Q as TapRelease, D as TapKeyword, F as TapListing, U as TapReviewsResult, v as TapCrashesResult, R as TapRevenueResult, W as TapSeriesMetric, Y as TapSeriesResult, d as TapQuery, e as TapResult, b as TapSize, T as Tap, a6 as TapToastTone, t as TapConfirmOptions, q as TapChatCard, c as TapHostEvents } from '../types-I1JOZyI_.cjs';
3
+ import { k as TappifyHealth, b as MetricsInput, c as MetricsResponse, M as MentionItems, C as ContextBlock, Z as WorkOperationMap, l as TappifyInstall, j as TappifyHandlerOptions, a as TappifyClaims, T as TappifyFetchHandler, B as WorkEvent, S as SendWorkEventOptions, F as WorkHydratedCommentCreatedEvent, I as WorkHydratedItemDeletedEvent, J as WorkHydratedStatusChangedEvent } from '../work-events-Dxe7Djdy.cjs';
4
4
  export { M as MatcherResult, a as MatcherTarget, r as registerTapMatchers, t as tapMatchers } from '../matchers-Cz93AK1n.cjs';
5
- import { S as ScopeKey, x as MetricDeclaration, a3 as ToolDeclaration } from '../constants-DJ_KgZpN.cjs';
5
+ import { S as ScopeKey, x as MetricDeclaration, a4 as ToolDeclaration } from '../constants-BAimnqOK.cjs';
6
6
  import { QueryClient } from '@tanstack/react-query';
7
7
  import { RenderOptions, RenderResult } from '@testing-library/react';
8
8
  import { ReactElement } from 'react';
@@ -91,7 +91,9 @@ interface TestClient {
91
91
  /** Posts one Tappify event, which the handler answers with 204. */
92
92
  event(name: string, payload: Record<string, unknown>): Promise<void>;
93
93
  /** Calls one work operation. */
94
- work(operation: WorkOperation, input: unknown): Promise<unknown>;
94
+ work<O extends keyof WorkOperationMap>(operation: O, input: WorkOperationMap[O]['input']): Promise<WorkOperationMap[O]['output']>;
95
+ /** @deprecated Call set_status or describe_container using the current work protocol. */
96
+ work(operation: 'status' | 'resolve', input: unknown): Promise<unknown>;
95
97
  /**
96
98
  * Sends any method and path and returns the `Response`, for a test that asserts
97
99
  * on a status rather than a body.
@@ -138,7 +140,7 @@ interface TestClient {
138
140
  declare function createTestClient(target: TappifyHandlerOptions, defaults?: TestClientDefaults): TestClient;
139
141
 
140
142
  /**
141
- * Sets the host's fifteen CSS variables on an element, so a component renders in
143
+ * Sets the host's eleven One UI CSS variables on an element, so a component renders in
142
144
  * a test the way it renders in the host.
143
145
  *
144
146
  * @remarks
@@ -216,7 +218,7 @@ interface TapFixtures {
216
218
  series(metric: TapSeriesMetric): TapSeriesResult;
217
219
  }
218
220
  /**
219
- * The sandbox data the mock bridge and the portal preview both answer with, so a
221
+ * The sandbox data the mock bridge and the local preview both answer with, so a
220
222
  * component behaves the same in a test and in the preview.
221
223
  *
222
224
  * @remarks
@@ -348,7 +350,7 @@ interface TapMock {
348
350
  /** The bridge itself, which `renderWithTap` puts above the component. */
349
351
  tap: Tap;
350
352
  calls: TapMockCalls;
351
- /** The node `TapDialog` renders into, appended to the document by `renderWithTap`. */
353
+ /** The node SDK dialogs render into, appended to the document by `renderWithTap`. */
352
354
  portal: HTMLElement;
353
355
  /** What a collection holds now, or just the one document under `documentId`. */
354
356
  documents(collection: string, documentId?: string): unknown[];
@@ -424,7 +426,7 @@ interface RenderWithTapResult extends RenderResult {
424
426
  * It builds a mock from the same options `createTapMock` takes unless you pass
425
427
  * `mock`, wraps the component in the host provider and a `QueryClient` that does
426
428
  * not retry and does not cache between tests, and appends the mock's portal to the
427
- * rendered document so `TapDialog` has somewhere to go. It rewires
429
+ * rendered document so SDK dialogs have somewhere to go. It rewires
428
430
  * `tap.invalidate` onto that client, so a component calling it drops the right
429
431
  * cache entries. Scopes default to all of them, so pass `scopes` to cover the
430
432
  * refused path; a `handler` has to be built with `jwks: await testJwks()` and the
@@ -435,7 +437,8 @@ interface RenderWithTapResult extends RenderResult {
435
437
  *
436
438
  * @example
437
439
  * ```tsx
438
- * import { TapStat, useTapQuery } from '@tappify/extension-sdk';
440
+ * import { useTapQuery } from '@tappify/extension-sdk';
441
+ * import { Metric } from '@tappify/extension-sdk/ui';
439
442
  * import { renderWithTap } from '@tappify/extension-sdk/testing';
440
443
  * import { screen, waitFor } from '@testing-library/react';
441
444
  * import { expect, it } from 'vitest';
@@ -445,7 +448,7 @@ interface RenderWithTapResult extends RenderResult {
445
448
  * kind: 'crashes',
446
449
  * range: { from: '2026-09-01', to: '2026-09-08' },
447
450
  * });
448
- * return <TapStat label="Issues" value={crashes.data?.issues.length ?? 0} />;
451
+ * return <Metric label="Issues" value={crashes.data?.issues.length ?? 0} />;
449
452
  * }
450
453
  *
451
454
  * it('renders the issues the fixtures answer with', async () => {
@@ -509,4 +512,20 @@ declare function validateMetricsResponse(response: unknown, metrics: MetricDecla
509
512
  */
510
513
  declare function validateToolResponse(value: unknown, returns: ToolDeclaration['returns']): string[];
511
514
 
512
- export { type CreateTapMockOptions, type RenderWithTapOptions, type RenderWithTapResult, type TapFixtures, type TapMock, type TapMockCalls, type TestClient, type TestClientDefaults, answerFixtureQuery, createTapMock, createTestClient, fixtureApps, fixtureCrashes, fixtureKeywords, fixtureListings, fixtureProject, fixtureReleases, fixtureRevenue, fixtureReviews, fixtureSeries, fixtures, installHostTheme, renderWithTap, signTestToken, testJwks, validateMetricsResponse, validateToolResponse };
515
+ /** A fresh complete comment signal with deterministic identity and shallow overrides. */
516
+ declare function workCommentCreatedFixture(overrides?: Partial<WorkHydratedCommentCreatedEvent>): WorkHydratedCommentCreatedEvent;
517
+ /** A fresh complete status signal with deterministic identity and shallow overrides. */
518
+ declare function workStatusChangedFixture(overrides?: Partial<WorkHydratedStatusChangedEvent>): WorkHydratedStatusChangedEvent;
519
+ /** A fresh deletion signal with deterministic identity and shallow overrides. */
520
+ declare function workItemDeletedFixture(overrides?: Partial<WorkHydratedItemDeletedEvent>): WorkHydratedItemDeletedEvent;
521
+ /**
522
+ * Captures a signed work-event Request through the real sender without network I/O.
523
+ *
524
+ * @remarks
525
+ * Uses the same validation, serialization, signing and callback URL as
526
+ * sendWorkEvent. Supply the callback and secret your test install was configured
527
+ * with; the accepting transport is supplied by this helper.
528
+ */
529
+ declare function signedWorkEventRequest(event: WorkEvent, options: Omit<SendWorkEventOptions, 'fetch'>): Promise<Request>;
530
+
531
+ export { type CreateTapMockOptions, type RenderWithTapOptions, type RenderWithTapResult, type TapFixtures, type TapMock, type TapMockCalls, type TestClient, type TestClientDefaults, answerFixtureQuery, createTapMock, createTestClient, fixtureApps, fixtureCrashes, fixtureKeywords, fixtureListings, fixtureProject, fixtureReleases, fixtureRevenue, fixtureReviews, fixtureSeries, fixtures, installHostTheme, renderWithTap, signTestToken, signedWorkEventRequest, testJwks, validateMetricsResponse, validateToolResponse, workCommentCreatedFixture, workItemDeletedFixture, workStatusChangedFixture };
@@ -1,8 +1,8 @@
1
1
  import { JSONWebKeySet } from 'jose';
2
- import { a as TapFilters, N as TapProjectResult, o as TapApp, Q as TapRelease, D as TapKeyword, F as TapListing, U as TapReviewsResult, v as TapCrashesResult, R as TapRevenueResult, W as TapSeriesMetric, Y as TapSeriesResult, d as TapQuery, e as TapResult, b as TapSize, T as Tap, a6 as TapToastTone, t as TapConfirmOptions, q as TapChatCard, c as TapHostEvents } from '../types-DDAGLpov.js';
3
- import { h as TappifyHealth, b as MetricsInput, c as MetricsResponse, M as MentionItems, C as ContextBlock, W as WorkOperation, i as TappifyInstall, g as TappifyHandlerOptions, a as TappifyClaims, T as TappifyFetchHandler } from '../handler-CZIlZ5vu.js';
2
+ import { a as TapFilters, N as TapProjectResult, o as TapApp, Q as TapRelease, D as TapKeyword, F as TapListing, U as TapReviewsResult, v as TapCrashesResult, R as TapRevenueResult, W as TapSeriesMetric, Y as TapSeriesResult, d as TapQuery, e as TapResult, b as TapSize, T as Tap, a6 as TapToastTone, t as TapConfirmOptions, q as TapChatCard, c as TapHostEvents } from '../types-BYGcp5pZ.js';
3
+ import { k as TappifyHealth, b as MetricsInput, c as MetricsResponse, M as MentionItems, C as ContextBlock, Z as WorkOperationMap, l as TappifyInstall, j as TappifyHandlerOptions, a as TappifyClaims, T as TappifyFetchHandler, B as WorkEvent, S as SendWorkEventOptions, F as WorkHydratedCommentCreatedEvent, I as WorkHydratedItemDeletedEvent, J as WorkHydratedStatusChangedEvent } from '../work-events-DB3WR468.js';
4
4
  export { M as MatcherResult, a as MatcherTarget, r as registerTapMatchers, t as tapMatchers } from '../matchers-Cz93AK1n.js';
5
- import { S as ScopeKey, x as MetricDeclaration, a3 as ToolDeclaration } from '../constants-DJ_KgZpN.js';
5
+ import { S as ScopeKey, x as MetricDeclaration, a4 as ToolDeclaration } from '../constants-BAimnqOK.js';
6
6
  import { QueryClient } from '@tanstack/react-query';
7
7
  import { RenderOptions, RenderResult } from '@testing-library/react';
8
8
  import { ReactElement } from 'react';
@@ -91,7 +91,9 @@ interface TestClient {
91
91
  /** Posts one Tappify event, which the handler answers with 204. */
92
92
  event(name: string, payload: Record<string, unknown>): Promise<void>;
93
93
  /** Calls one work operation. */
94
- work(operation: WorkOperation, input: unknown): Promise<unknown>;
94
+ work<O extends keyof WorkOperationMap>(operation: O, input: WorkOperationMap[O]['input']): Promise<WorkOperationMap[O]['output']>;
95
+ /** @deprecated Call set_status or describe_container using the current work protocol. */
96
+ work(operation: 'status' | 'resolve', input: unknown): Promise<unknown>;
95
97
  /**
96
98
  * Sends any method and path and returns the `Response`, for a test that asserts
97
99
  * on a status rather than a body.
@@ -138,7 +140,7 @@ interface TestClient {
138
140
  declare function createTestClient(target: TappifyHandlerOptions, defaults?: TestClientDefaults): TestClient;
139
141
 
140
142
  /**
141
- * Sets the host's fifteen CSS variables on an element, so a component renders in
143
+ * Sets the host's eleven One UI CSS variables on an element, so a component renders in
142
144
  * a test the way it renders in the host.
143
145
  *
144
146
  * @remarks
@@ -216,7 +218,7 @@ interface TapFixtures {
216
218
  series(metric: TapSeriesMetric): TapSeriesResult;
217
219
  }
218
220
  /**
219
- * The sandbox data the mock bridge and the portal preview both answer with, so a
221
+ * The sandbox data the mock bridge and the local preview both answer with, so a
220
222
  * component behaves the same in a test and in the preview.
221
223
  *
222
224
  * @remarks
@@ -348,7 +350,7 @@ interface TapMock {
348
350
  /** The bridge itself, which `renderWithTap` puts above the component. */
349
351
  tap: Tap;
350
352
  calls: TapMockCalls;
351
- /** The node `TapDialog` renders into, appended to the document by `renderWithTap`. */
353
+ /** The node SDK dialogs render into, appended to the document by `renderWithTap`. */
352
354
  portal: HTMLElement;
353
355
  /** What a collection holds now, or just the one document under `documentId`. */
354
356
  documents(collection: string, documentId?: string): unknown[];
@@ -424,7 +426,7 @@ interface RenderWithTapResult extends RenderResult {
424
426
  * It builds a mock from the same options `createTapMock` takes unless you pass
425
427
  * `mock`, wraps the component in the host provider and a `QueryClient` that does
426
428
  * not retry and does not cache between tests, and appends the mock's portal to the
427
- * rendered document so `TapDialog` has somewhere to go. It rewires
429
+ * rendered document so SDK dialogs have somewhere to go. It rewires
428
430
  * `tap.invalidate` onto that client, so a component calling it drops the right
429
431
  * cache entries. Scopes default to all of them, so pass `scopes` to cover the
430
432
  * refused path; a `handler` has to be built with `jwks: await testJwks()` and the
@@ -435,7 +437,8 @@ interface RenderWithTapResult extends RenderResult {
435
437
  *
436
438
  * @example
437
439
  * ```tsx
438
- * import { TapStat, useTapQuery } from '@tappify/extension-sdk';
440
+ * import { useTapQuery } from '@tappify/extension-sdk';
441
+ * import { Metric } from '@tappify/extension-sdk/ui';
439
442
  * import { renderWithTap } from '@tappify/extension-sdk/testing';
440
443
  * import { screen, waitFor } from '@testing-library/react';
441
444
  * import { expect, it } from 'vitest';
@@ -445,7 +448,7 @@ interface RenderWithTapResult extends RenderResult {
445
448
  * kind: 'crashes',
446
449
  * range: { from: '2026-09-01', to: '2026-09-08' },
447
450
  * });
448
- * return <TapStat label="Issues" value={crashes.data?.issues.length ?? 0} />;
451
+ * return <Metric label="Issues" value={crashes.data?.issues.length ?? 0} />;
449
452
  * }
450
453
  *
451
454
  * it('renders the issues the fixtures answer with', async () => {
@@ -509,4 +512,20 @@ declare function validateMetricsResponse(response: unknown, metrics: MetricDecla
509
512
  */
510
513
  declare function validateToolResponse(value: unknown, returns: ToolDeclaration['returns']): string[];
511
514
 
512
- export { type CreateTapMockOptions, type RenderWithTapOptions, type RenderWithTapResult, type TapFixtures, type TapMock, type TapMockCalls, type TestClient, type TestClientDefaults, answerFixtureQuery, createTapMock, createTestClient, fixtureApps, fixtureCrashes, fixtureKeywords, fixtureListings, fixtureProject, fixtureReleases, fixtureRevenue, fixtureReviews, fixtureSeries, fixtures, installHostTheme, renderWithTap, signTestToken, testJwks, validateMetricsResponse, validateToolResponse };
515
+ /** A fresh complete comment signal with deterministic identity and shallow overrides. */
516
+ declare function workCommentCreatedFixture(overrides?: Partial<WorkHydratedCommentCreatedEvent>): WorkHydratedCommentCreatedEvent;
517
+ /** A fresh complete status signal with deterministic identity and shallow overrides. */
518
+ declare function workStatusChangedFixture(overrides?: Partial<WorkHydratedStatusChangedEvent>): WorkHydratedStatusChangedEvent;
519
+ /** A fresh deletion signal with deterministic identity and shallow overrides. */
520
+ declare function workItemDeletedFixture(overrides?: Partial<WorkHydratedItemDeletedEvent>): WorkHydratedItemDeletedEvent;
521
+ /**
522
+ * Captures a signed work-event Request through the real sender without network I/O.
523
+ *
524
+ * @remarks
525
+ * Uses the same validation, serialization, signing and callback URL as
526
+ * sendWorkEvent. Supply the callback and secret your test install was configured
527
+ * with; the accepting transport is supplied by this helper.
528
+ */
529
+ declare function signedWorkEventRequest(event: WorkEvent, options: Omit<SendWorkEventOptions, 'fetch'>): Promise<Request>;
530
+
531
+ export { type CreateTapMockOptions, type RenderWithTapOptions, type RenderWithTapResult, type TapFixtures, type TapMock, type TapMockCalls, type TestClient, type TestClientDefaults, answerFixtureQuery, createTapMock, createTestClient, fixtureApps, fixtureCrashes, fixtureKeywords, fixtureListings, fixtureProject, fixtureReleases, fixtureRevenue, fixtureReviews, fixtureSeries, fixtures, installHostTheme, renderWithTap, signTestToken, signedWorkEventRequest, testJwks, validateMetricsResponse, validateToolResponse, workCommentCreatedFixture, workItemDeletedFixture, workStatusChangedFixture };