@tinkerlandai/indiana-sdk 0.8.3 → 0.8.5

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 (48) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +73 -3
  3. package/README.zh-CN.md +40 -3
  4. package/dist/{ai-usage-BV-FlgWr.d.ts → ai-usage-DUlre7JC.d.ts} +1 -1
  5. package/dist/{api-B3FIE41b.d.ts → api-XDc4pRlN.d.ts} +63 -10
  6. package/dist/chunk-3KQHKRZJ.js +1 -0
  7. package/dist/chunk-6A5WWFNS.js +10 -0
  8. package/dist/{chunk-SHSNIJJM.js → chunk-A3XRIG53.js} +1 -1
  9. package/dist/chunk-BUDTHBFF.js +173 -0
  10. package/dist/{chunk-BNU6IG3F.js → chunk-FGIGKO7A.js} +1 -1
  11. package/dist/chunk-HEBQUICQ.js +4 -0
  12. package/dist/chunk-SSLZKIIU.js +1 -0
  13. package/dist/chunk-SUXAWRR6.js +1 -0
  14. package/dist/chunk-WWUUVURR.js +1 -0
  15. package/dist/{configuration-sync-DNvKXHk-.d.ts → configuration-sync-Ce3dShy7.d.ts} +6 -1
  16. package/dist/content-DDMDNRCV.js +1 -0
  17. package/dist/{customer-page-WUQVK_tp.d.ts → customer-page-9B97Qdt_.d.ts} +21 -1
  18. package/dist/{funnel-local-client-wbz-4gFx.d.ts → funnel-local-client-CUGavICI.d.ts} +43 -23
  19. package/dist/funnel-runtime-host-QK6WDRPS.js +1 -0
  20. package/dist/index.d.ts +76 -26
  21. package/dist/index.js +1 -1
  22. package/dist/native-shell.js +1 -1
  23. package/dist/openrouter.d.ts +2 -2
  24. package/dist/openrouter.js +1 -1
  25. package/dist/page.d.ts +1 -1
  26. package/dist/page.js +1 -1
  27. package/dist/paywall-4QT3JYD4.js +1 -0
  28. package/dist/popup.d.ts +14 -4
  29. package/dist/popup.js +1 -1
  30. package/dist/react-native.d.ts +1 -1
  31. package/dist/react-native.js +1 -1
  32. package/dist/screen-renderer-DLXDQQKK.js +1 -0
  33. package/dist/server.d.ts +13 -13
  34. package/dist/server.js +1 -1
  35. package/dist/src-EG7RWDDY.js +1 -0
  36. package/dist/visual.js +2 -2
  37. package/package.json +1 -1
  38. package/dist/chunk-2QPETWDX.js +0 -1
  39. package/dist/chunk-ANOOBDW5.js +0 -350
  40. package/dist/chunk-EXCPE2XH.js +0 -1
  41. package/dist/chunk-X747SY26.js +0 -4
  42. package/dist/chunk-Y32NPIYY.js +0 -1
  43. package/dist/chunk-ZT66RIFU.js +0 -10
  44. package/dist/content-J3FKZTGT.js +0 -1
  45. package/dist/funnel-runtime-host-C5P5JTV3.js +0 -1
  46. package/dist/paywall-3GIRKSHN.js +0 -1
  47. package/dist/screen-renderer-5FPYVSPW.js +0 -1
  48. package/dist/src-BMJCIMIF.js +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  Release facts and artifact evidence: [SDK release ledger](../../docs/sdk-releases.md).
4
4
 
5
+ ## 0.8.5 — 2026-10-27
6
+
7
+ - Add direct browser script loading through `/sdk.js`, sharing the npm browser APIs and page/visual experiment factories without requiring a bundler. Website deployment distributes this entry independently of npm publication.
8
+ - Keep IAM release markers attached through host updates, group render-signature queries, and recover bounded visual work without duplicate exposure events.
9
+ - Disable Funnel Back navigation until the current presentation is rendered, and include the SDK version in experiment-event requests.
10
+ - Synchronize the packaged Web, iOS and Android renderers while retaining HTTP protocol 0.8.
11
+
12
+ ## 0.8.4 — 2026-10-26
13
+
14
+ - Add `prepareContent` and `preparePopup` to render authorized content before the opening click and reveal the same iframe on demand.
15
+ - Prepare bounded HTML DOM templates for supplied pages and Product variants; update variable text in place while preserving styles, images and unrelated content. Reuse inactive variants with empty variable slots.
16
+ - Prepare Local Funnel rule definitions once per pure segment and send advance signals without waiting for advisory prediction downloads. Late predictions remain fenced by Run position and identity.
17
+ - Synchronize the packaged Web, iOS and Android renderers. Retain HTTP protocol 0.8 and server authority over Funnel acceptance and commercial operations.
18
+ - Carry the committed Merchandise context through Feature evaluation, page experiments, Analytics events and Coupon applicability; refresh the generated native Paywall schema.
19
+ - Include the committed Android Push recovery proofs, visual target diagnostics and Paywall/Funnel focus restoration fixes.
20
+
5
21
  ## 0.8.3 — 2026-10-26
6
22
 
7
23
  - Refresh sanitized custom HTML fallback content when Product availability changes.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @tinkerlandai/indiana-sdk
2
2
 
3
- These examples use SDK 0.8.1 with `https://api.dev.tinker.cash` and test App credentials (protocol 0.8). Check [environment state](../../docs/development-status.md) before switching. The SDK default remains the production API, so set `baseUrl` explicitly for these examples.
3
+ These examples use SDK 0.8.4 with `https://api.dev.tinker.cash` and test App credentials (protocol 0.8). Check [environment state](../../docs/development-status.md) before switching. The SDK default remains the production API, so set `baseUrl` explicitly for these examples.
4
4
 
5
5
  [简体中文](./README.zh-CN.md)
6
6
 
@@ -9,13 +9,42 @@ The Indiana business SDK groups its capabilities as **Identity, Commerce, Growth
9
9
  **IAM source scanning, generation, validation and upload belong to the independent build package `@tinkerlandai/indiana-iam`.** This business SDK retains only the runtime release binding used by GB visual changes. See [SDK boundaries](../../docs/sdk-architecture.md) and the [IAM package](../iam/README.md).
10
10
 
11
11
  ```sh
12
- npm install --save-exact @tinkerlandai/indiana-sdk@0.8.1
12
+ npm install --save-exact @tinkerlandai/indiana-sdk@0.8.4
13
13
  ```
14
14
 
15
- SDK 0.8.1 requires HTTP protocol 0.8. Install a version that matches your runtime; publishing a package does not deploy the server. Publication and accepted environment scope are recorded in the [release ledger](../../docs/sdk-releases.md) and [development status](../../docs/development-status.md).
15
+ SDK 0.8.4 requires HTTP protocol 0.8. Install a version that matches your runtime; publishing a package does not deploy the server. Publication and accepted environment scope are recorded in the [release ledger](../../docs/sdk-releases.md) and [development status](../../docs/development-status.md).
16
16
 
17
17
  The data/session layer handles public JSON, integrity checks and authenticated operations. The presentation host composes that layer with the packaged screen renderer; the renderer receives supplied data and emits action intents. Client display entry points load presentation lazily. The `/server` entry has no screen presentation dependency and uses a scoped Server Key only on your backend. A local SDK guard never replaces runtime authorization or verified payment completion. Console preview supplies simulated data/session results to the same presentation host.
18
18
 
19
+ ## Plain HTML / script installation
20
+
21
+ The classic-script entry reuses the npm browser implementation, with no bundler:
22
+
23
+ ```html
24
+ <script src="https://dev.tinker.cash/sdk.js"></script>
25
+ <script type="module">
26
+ const {
27
+ createIndiana,
28
+ createPaywallSession,
29
+ showPaywall,
30
+ createFunnelRunController,
31
+ showFunnelRun,
32
+ mountContent,
33
+ } = await Indiana.ready;
34
+ const client = createIndiana({
35
+ baseUrl: "https://api.dev.tinker.cash",
36
+ scope: { projectId: "<APP_UUID>", environment: "sandbox" },
37
+ });
38
+ // Obtain customerToken from your authenticated backend session endpoint.
39
+ // client.identify(customerToken);
40
+ // await client.readHoldings();
41
+ // client.track("page_viewed", { page: location.pathname });
42
+ // await client.flush();
43
+ </script>
44
+ ```
45
+
46
+ Production uses `https://tinker.cash/sdk.js` and its matching API/credentials. `Indiana.ready` provides every root browser export plus `createPageExperiments` and `createVisualExperiments`; replace npm imports below with destructuring those names. Loading activates no sessions, events or experiments. Server Keys remain on your backend; Funnel start/recovery and logout cleanup retain the existing contracts. Duplicate tags share readiness, failures reject the Promise and UI loads lazily. With `async`/`defer`, wait for the loader tag's load event before accessing `Indiana`. CSP must allow the script origin and API connections. Page experiments use the same script entry; explicitly create their clients and call `start()`. See [script distribution](../../docs/sdk-architecture.md#web-script-distribution) and [the complete integration example](https://tinker.cash/docs/javascript#script).
47
+
19
48
  ## React Native core
20
49
 
21
50
  Use the independent `@tinkerlandai/indiana-react-native` package. The `@tinkerlandai/indiana-sdk/react-native` subpath shares the same implementation. Both support Customer Token identity, holdings, entitlement checks and usage reporting through your authenticated backend. It requires no DOM or native UI/store bridge. See [mobile SDK installation and examples](../../docs/mobile-sdk.md).
@@ -217,6 +246,26 @@ The selected environment's integration settings control behavior events, experim
217
246
 
218
247
  Flags default to local evaluation; Owner/Admin can switch each flag to server evaluation. Server-evaluated flags deliver only keys and results, using the caller's fallback until the first result arrives. Attribute changes immediately discard old results. List hashes are not a secrecy boundary. Local Funnels cannot depend on server-evaluated flags; mode switches also check active historical Runs. `identify` / `reset` release the previous identity's Feature instances and event queue.
219
248
 
249
+ Merchandise targeting resolves a trusted item in the selected App/environment. Register its attributes and maintain the
250
+ item in Console, then pass a reference rather than item metadata. The SDK resolves the initial SKU before returning;
251
+ after switching items, await context refresh before reading the next decision. Item experiments use `merchandiseId`
252
+ (the internal UUID) without a Customer fallback; Customer experiments keep their own bucketing identity.
253
+
254
+ ```ts
255
+ const merchandiseFlags = await indiana.features({
256
+ attributes: { ...bucketingIdentity, merchandise: { id: "sku-outdoor" } },
257
+ });
258
+ merchandiseFlags.setAttributes({
259
+ ...bucketingIdentity,
260
+ merchandise: { id: "sku-indoor" },
261
+ });
262
+ await merchandiseFlags.refreshRemote();
263
+ const eligible = merchandiseFlags.isOn("item-promotion");
264
+ indiana.track("Item Viewed", {}, { merchandise: { id: "sku-indoor" } });
265
+ await indiana.flush();
266
+ merchandiseFlags.destroy();
267
+ ```
268
+
220
269
  Offering pins the Product Version scope and hierarchy. Paywall pins a published Offering Version and independently chooses its displayed Product subset, groups, ordering, and default selection. `createPaywallStartClient`, `createPaywallSession`, and `showPaywall` use a standalone Paywall Session. After payment, read Entitlements again. Your backend still authorizes requests and consumes usage idempotently.
221
270
 
222
271
  ## Commercial capabilities and current service boundaries
@@ -378,3 +427,24 @@ export async function showBanner(
378
427
  ```
379
428
 
380
429
  Provide every declared action handler. `onContinue` uses `intent.requestId` as its backend idempotency key; `retryAction()` reuses that intent after a failure. Call `destroy()` on unmount, sign-out or account change. The host renders content and emits intents; your backend still authorizes and executes business actions.
430
+
431
+ To remove module loading, document preparation and iframe startup from the opening click, resolve the current Customer's content earlier and prepare it explicitly:
432
+
433
+ ```ts
434
+ import { prepareContent } from "@tinkerlandai/indiana-sdk";
435
+
436
+ const lifetime = new AbortController();
437
+ const popup = await prepareContent(container, {
438
+ content, // Already resolved with kind: "popup" for this Customer.
439
+ actions: { continue: onContinue },
440
+ onError: console.error,
441
+ signal: lifetime.signal,
442
+ });
443
+ openButton.addEventListener("click", () => popup.show(), {
444
+ signal: lifetime.signal,
445
+ });
446
+ // On unmount, sign-out or account/scope change:
447
+ // lifetime.abort();
448
+ ```
449
+
450
+ Preparation waits for the first render without opening the dialog or running actions. `show()` reveals the same iframe and is idempotent; destroy and prepare a fresh handle for another presentation. Abort also cancels preparation while it is pending. This does not pre-authorize business operations or guarantee that images have decoded. For low-level ScreenDocument rendering, `/popup` provides `preparePopup(document, options)` with `ready`, `show()` and `destroy()`.
package/README.zh-CN.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [English](./README.md)
2
2
 
3
- 本页使用 SDK 0.8.1、`https://api.dev.tinker.cash` 与测试 App 凭据(协议 0.8)。切换前核对[环境状态](../../docs/development-status.md)。SDK 默认仍指向生产 API,本页示例必须显式设置 `baseUrl`。
3
+ 本页使用 SDK 0.8.4、`https://api.dev.tinker.cash` 与测试 App 凭据(协议 0.8)。切换前核对[环境状态](../../docs/development-status.md)。SDK 默认仍指向生产 API,本页示例必须显式设置 `baseUrl`。
4
4
 
5
5
  # @tinkerlandai/indiana-sdk
6
6
 
@@ -9,13 +9,42 @@
9
9
  **IAM 的源码扫描、生成、校验和上传属于独立构建包 `@tinkerlandai/indiana-iam`。** 普通业务 SDK 只保留 GB visual 应用页面变更所需的运行时 release 绑定。完整定义见 [SDK 边界](../../docs/sdk-architecture.md) 与 [IAM 构建包](../iam/README.md)。
10
10
 
11
11
  ```sh
12
- npm install --save-exact @tinkerlandai/indiana-sdk@0.8.1
12
+ npm install --save-exact @tinkerlandai/indiana-sdk@0.8.4
13
13
  ```
14
14
 
15
- SDK 0.8.1 要求 HTTP 协议 0.8。安装版本须与运行服务匹配;发布包不会部署服务端。实际发布、标签与环境验收范围见 [SDK 发布总账](../../docs/sdk-releases.md) 和 [开发状态](../../docs/development-status.md)。
15
+ SDK 0.8.4 要求 HTTP 协议 0.8。安装版本须与运行服务匹配;发布包不会部署服务端。实际发布、标签与环境验收范围见 [SDK 发布总账](../../docs/sdk-releases.md) 和 [开发状态](../../docs/development-status.md)。
16
16
 
17
17
  数据/会话层负责公开 JSON、完整性校验和鉴权操作;展示宿主将会话接口接入打包的屏幕渲染器,渲染器消费已提供的数据并返回动作意图。客户端按需加载展示;`/server` 入口使用商户后端的受限 Server Key,不加载屏幕展示。SDK 本地检查不替代运行时授权或付款核实。后台 Preview 为同一个展示宿主提供模拟会话和数据。
18
18
 
19
+ ## 普通 HTML / script 接入
20
+
21
+ 普通 script 标签复用 npm 浏览器实现,无需打包工具:
22
+
23
+ ```html
24
+ <script src="https://dev.tinker.cash/sdk.js"></script>
25
+ <script type="module">
26
+ const {
27
+ createIndiana,
28
+ createPaywallSession,
29
+ showPaywall,
30
+ createFunnelRunController,
31
+ showFunnelRun,
32
+ mountContent,
33
+ } = await Indiana.ready;
34
+ const client = createIndiana({
35
+ baseUrl: "https://api.dev.tinker.cash",
36
+ scope: { projectId: "<APP_UUID>", environment: "sandbox" },
37
+ });
38
+ // 从验证登录后的自有后端接口获取 customerToken。
39
+ // client.identify(customerToken);
40
+ // await client.readHoldings();
41
+ // client.track("page_viewed", { page: location.pathname });
42
+ // await client.flush();
43
+ </script>
44
+ ```
45
+
46
+ 生产脚本为 `https://tinker.cash/sdk.js`,配套使用同环境 API 和凭据。`Indiana.ready` 返回根入口的全部浏览器导出,以及 `createPageExperiments` / `createVisualExperiments`;下文 npm import 可替换为从该 Promise 解构同名函数。加载不自动创建会话、发送事件或启动实验。Server Key 留在后端,Funnel 启动恢复与退出清理沿用现有流程。重复标签共用 ready,失败会拒绝 Promise,UI 按需加载。加载标签使用普通 script;添加 async/defer 时先等标签 load 事件,再访问 Indiana。CSP 需允许脚本来源和 API 连接。页面实验也使用该统一入口,显式创建客户端并调用 `start()`。详见 [script 分发](../../docs/sdk-architecture.md#web-script-distribution)和[完整接入示例](https://tinker.cash/docs/javascript#script)。
47
+
19
48
  ## React Native 核心入口
20
49
 
21
50
  React Native 使用独立包 `@tinkerlandai/indiana-react-native`,原 `@tinkerlandai/indiana-sdk/react-native` 子入口共用同一实现。两者均支持 Customer Token 身份接入、权益读取和经业务后端转发的用量上报。此入口无需 DOM,不包含原生 UI 或内购桥接。参见[移动端 SDK 安装与示例](../../docs/mobile-sdk.md)。
@@ -206,6 +235,10 @@ flags.destroy();
206
235
 
207
236
  每个 flag 默认本地计算,Owner/Admin 可切换为服务器计算。服务器 flag 只下发键与结果,首次结果到达前使用调用方默认值;属性变化立即丢弃旧结果。名单哈希不等于保密,敏感规则应使用服务器计算。本地 Funnel 不得依赖服务器 flag,切换时也会校验仍在运行的历史版本。`identify` / `reset` 会释放旧身份的功能实例和事件队列。
208
237
 
238
+ 商品定向使用当前 App/环境的可信商品主档。在 Console 登记属性并维护商品后,传入 `merchandise: { id: "sku-outdoor" }` 引用;SDK 在返回 Feature 客户端之前解析商品。切换商品后,先调用 `setAttributes({ ...bucketingIdentity, merchandise: { id: "sku-indoor" } })`,再等待 `refreshRemote()` 后读取决策。商品实验使用服务端解析的 `merchandiseId`(内部 UUID),不能回退到人的分桶标识。请求中的商品属性不能覆盖主档。
239
+
240
+ 自定义商品事件可调用 `indiana.track("Item Viewed", {}, { merchandise: { id: "sku-indoor" } })`,再 `flush()`。Customer 身份、商品引用和实验分桶单位分别记录;事件不构成订单或收入回执。
241
+
209
242
  Offering 固定 Product Version 的范围与层级。Paywall 固定已发布 Offering Version,并独立选择显示的 Product 子集、分组、顺序和默认项。`createPaywallStartClient`、`createPaywallSession`、`showPaywall` 使用独立 Paywall Session,不创建占位 Funnel。付款完成后重新查询权益,业务后端仍须重新鉴权并幂等扣减用量。
210
243
 
211
244
  ## Web 商业能力与当前服务边界
@@ -299,3 +332,7 @@ export async function showBanner(
299
332
  ```
300
333
 
301
334
  每个声明动作都需要同名 handler。`onContinue` 用 `intent.requestId` 作为业务后端的幂等键;失败后 `retryAction()` 重用原意图。卸载、退出或换号时调用 `destroy()`。宿主只渲染和发出意图,业务后端仍负责鉴权与执行。
335
+
336
+ 需要加快点击打开时,可提前为当前 Customer 读取内容,再调用根入口的 `prepareContent(container, options)`,参数与 `mountContent` 相同。它提前加载展示模块、校验文档并启动 iframe,等首次渲染后返回句柄;点击时同步调用 `handle.show()`,直接显示同一个 iframe。准备期间不打开弹窗、不抢焦点、不执行动作。句柄用于一次展示,重复 `show()` 不重复挂载;下一次展示需重新准备。
337
+
338
+ 可传入 `signal: abortController.signal`,在卸载、退出或切换 Customer/App/环境时 `abortController.abort()`,连同仍在等待的准备一起取消并释放资源。预渲染不代替业务鉴权,也不保证图片已完成解码。直接持有已授权 ScreenDocument 的低层接入可使用 `/popup` 的 `preparePopup(document, options)`;句柄立即返回,提供 `ready`、`show()` 和 `destroy()`。
@@ -1,5 +1,5 @@
1
1
  import { LanguageModelV4Usage, LanguageModelV4Middleware } from '@ai-sdk/provider';
2
- import { F as FoundationApi, A as ApiInput } from './api-B3FIE41b.js';
2
+ import { F as FoundationApi, A as ApiInput } from './api-XDc4pRlN.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  declare const tokenCounts: z.ZodObject<{
@@ -1650,6 +1650,10 @@ declare const apiOperations: {
1650
1650
  stickyBucketUsed: z$1.ZodOptional<z$1.ZodBoolean>;
1651
1651
  }, z$1.core.$strict>>;
1652
1652
  }, z$1.core.$strict>>;
1653
+ merchandiseContext: z$1.ZodOptional<z$1.ZodObject<{
1654
+ merchandiseId: z$1.ZodUUID;
1655
+ merchandise: z$1.ZodRecord<z$1.ZodString, z$1.ZodJSONSchema>;
1656
+ }, z$1.core.$strict>>;
1653
1657
  }, z$1.core.$strict>;
1654
1658
  };
1655
1659
  readonly trackEvents: {
@@ -1663,6 +1667,11 @@ declare const apiOperations: {
1663
1667
  eventUuid: z$1.ZodUUID;
1664
1668
  timestamp: z$1.ZodISODateTime;
1665
1669
  name: z$1.ZodString;
1670
+ merchandise: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodObject<{
1671
+ id: z$1.ZodString;
1672
+ }, z$1.core.$strict>, z$1.ZodObject<{
1673
+ internalId: z$1.ZodUUID;
1674
+ }, z$1.core.$strict>]>>;
1666
1675
  properties: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodJSONSchema>>;
1667
1676
  deviceId: z$1.ZodOptional<z$1.ZodString>;
1668
1677
  sessionId: z$1.ZodOptional<z$1.ZodString>;
@@ -10851,13 +10860,22 @@ declare const apiOperations: {
10851
10860
  }, z$1.core.$strict>, z$1.ZodObject<{
10852
10861
  type: z$1.ZodLiteral<"plans">;
10853
10862
  planIds: z$1.ZodArray<z$1.ZodUUID>;
10863
+ }, z$1.core.$strict>, z$1.ZodObject<{
10864
+ type: z$1.ZodLiteral<"merchandise">;
10865
+ scope: z$1.ZodObject<{
10866
+ type: z$1.ZodEnum<{
10867
+ selected: "selected";
10868
+ all: "all";
10869
+ condition: "condition";
10870
+ }>;
10871
+ }, z$1.core.$strict>;
10854
10872
  }, z$1.core.$strict>], "type">;
10855
10873
  }, z$1.core.$strict>;
10856
10874
  }, z$1.core.$strict>>;
10857
10875
  reason: z$1.ZodNullable<z$1.ZodEnum<{
10858
10876
  unavailable: "unavailable";
10859
- claim_disabled: "claim_disabled";
10860
10877
  inactive: "inactive";
10878
+ claim_disabled: "claim_disabled";
10861
10879
  outside_window: "outside_window";
10862
10880
  not_targeted: "not_targeted";
10863
10881
  not_first_purchase: "not_first_purchase";
@@ -10951,6 +10969,15 @@ declare const apiOperations: {
10951
10969
  }, z$1.core.$strict>, z$1.ZodObject<{
10952
10970
  type: z$1.ZodLiteral<"plans">;
10953
10971
  planIds: z$1.ZodArray<z$1.ZodUUID>;
10972
+ }, z$1.core.$strict>, z$1.ZodObject<{
10973
+ type: z$1.ZodLiteral<"merchandise">;
10974
+ scope: z$1.ZodObject<{
10975
+ type: z$1.ZodEnum<{
10976
+ selected: "selected";
10977
+ all: "all";
10978
+ condition: "condition";
10979
+ }>;
10980
+ }, z$1.core.$strict>;
10954
10981
  }, z$1.core.$strict>], "type">;
10955
10982
  }, z$1.core.$strict>;
10956
10983
  }, z$1.core.$strict>>;
@@ -11049,13 +11076,22 @@ declare const apiOperations: {
11049
11076
  }, z$1.core.$strict>, z$1.ZodObject<{
11050
11077
  type: z$1.ZodLiteral<"plans">;
11051
11078
  planIds: z$1.ZodArray<z$1.ZodUUID>;
11079
+ }, z$1.core.$strict>, z$1.ZodObject<{
11080
+ type: z$1.ZodLiteral<"merchandise">;
11081
+ scope: z$1.ZodObject<{
11082
+ type: z$1.ZodEnum<{
11083
+ selected: "selected";
11084
+ all: "all";
11085
+ condition: "condition";
11086
+ }>;
11087
+ }, z$1.core.$strict>;
11052
11088
  }, z$1.core.$strict>], "type">;
11053
11089
  }, z$1.core.$strict>;
11054
11090
  }, z$1.core.$strict>>;
11055
11091
  reason: z$1.ZodNullable<z$1.ZodEnum<{
11056
11092
  unavailable: "unavailable";
11057
- claim_disabled: "claim_disabled";
11058
11093
  inactive: "inactive";
11094
+ claim_disabled: "claim_disabled";
11059
11095
  outside_window: "outside_window";
11060
11096
  not_targeted: "not_targeted";
11061
11097
  not_first_purchase: "not_first_purchase";
@@ -11070,14 +11106,20 @@ declare const apiOperations: {
11070
11106
  readonly permission: "billing:write";
11071
11107
  readonly audience: "server";
11072
11108
  /** A stable merchant event records paid Coupon use; this does not verify a provider or grant subscription access. */
11073
- readonly request: z$1.ZodObject<{
11109
+ readonly request: z$1.ZodUnion<readonly [z$1.ZodObject<{
11110
+ productVersionId: z$1.ZodUUID;
11111
+ subscriptionId: z$1.ZodString;
11074
11112
  customerId: z$1.ZodUUID;
11075
11113
  eventId: z$1.ZodString;
11076
11114
  grantId: z$1.ZodUUID;
11077
- productVersionId: z$1.ZodUUID;
11078
- subscriptionId: z$1.ZodString;
11079
11115
  occurredAt: z$1.ZodISODateTime;
11080
- }, z$1.core.$strict>;
11116
+ }, z$1.core.$strict>, z$1.ZodObject<{
11117
+ merchandiseId: z$1.ZodUUID;
11118
+ customerId: z$1.ZodUUID;
11119
+ eventId: z$1.ZodString;
11120
+ grantId: z$1.ZodUUID;
11121
+ occurredAt: z$1.ZodISODateTime;
11122
+ }, z$1.core.$strict>]>;
11081
11123
  readonly response: z$1.ZodObject<{
11082
11124
  requestId: z$1.ZodUUID;
11083
11125
  scope: z$1.ZodObject<{
@@ -11087,19 +11129,30 @@ declare const apiOperations: {
11087
11129
  live: "live";
11088
11130
  }>;
11089
11131
  }, z$1.core.$strict>;
11090
- receipt: z$1.ZodObject<{
11132
+ receipt: z$1.ZodUnion<readonly [z$1.ZodObject<{
11133
+ productVersionId: z$1.ZodUUID;
11134
+ subscriptionId: z$1.ZodString;
11091
11135
  customerId: z$1.ZodUUID;
11092
11136
  eventId: z$1.ZodString;
11093
11137
  grantId: z$1.ZodUUID;
11094
- productVersionId: z$1.ZodUUID;
11095
- subscriptionId: z$1.ZodString;
11096
11138
  occurredAt: z$1.ZodISODateTime;
11097
11139
  id: z$1.ZodUUID;
11098
11140
  couponId: z$1.ZodUUID;
11099
11141
  status: z$1.ZodLiteral<"redeemed">;
11100
11142
  source: z$1.ZodLiteral<"merchant">;
11101
11143
  recordedAt: z$1.ZodISODateTime;
11102
- }, z$1.core.$strict>;
11144
+ }, z$1.core.$strict>, z$1.ZodObject<{
11145
+ merchandiseId: z$1.ZodUUID;
11146
+ customerId: z$1.ZodUUID;
11147
+ eventId: z$1.ZodString;
11148
+ grantId: z$1.ZodUUID;
11149
+ occurredAt: z$1.ZodISODateTime;
11150
+ id: z$1.ZodUUID;
11151
+ couponId: z$1.ZodUUID;
11152
+ status: z$1.ZodLiteral<"redeemed">;
11153
+ source: z$1.ZodLiteral<"merchant">;
11154
+ recordedAt: z$1.ZodISODateTime;
11155
+ }, z$1.core.$strict>]>;
11103
11156
  }, z$1.core.$strict>;
11104
11157
  };
11105
11158
  };
@@ -0,0 +1 @@
1
+ import{o as E,p as L,s as R}from"./chunk-6A5WWFNS.js";import{a as e}from"./chunk-SOQO2RDZ.js";import{a as P,j as C,m as D,p as j}from"./chunk-LMR2TM3X.js";import{b}from"./chunk-OBYJWIRB.js";import{a as U,b as M}from"./chunk-WWUUVURR.js";var H=Symbol("IndianaNoContent");function Q(u,q,k=URL){let l=u.configuration?.scope,A=u.scope??(l&&{projectId:l.projectId,environment:l.environment}),s=A?b.parse(A):void 0;if(s&&l&&(s.projectId!==l.projectId||s.environment!==l.environment))throw new e("SCOPE_MISMATCH","Configuration belongs to another App/environment");let i=new k(u.baseUrl??M);if(i.username||i.password||i.search||i.hash)throw new e("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(i.protocol!=="https:"&&!(i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname)))throw new e("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let V=u.fetch??globalThis.fetch.bind(globalThis),p=u.timeoutMs??1e4;if(!Number.isFinite(p)||p<1||p>12e4)throw new e("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let m=null,f=0,h=null,w=new Set;function O(){f+=1,m=null,h=null;for(let a of w)a.abort();w.clear()}async function K(a,x={},T="POST",v={}){let d=v.installationDetach===!0;if(d&&(a!=="push/installations/detach"||T!=="POST"))throw new e("INVALID_REQUEST","Installation authority only detaches this installation");if(!m&&!d)throw new e("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let y=f,o=new AbortController;d||w.add(o);let g=()=>!d&&y!==f?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new e("TIMEOUT","Indiana request timed out"),S,F=new Promise((n,r)=>{S=()=>r(g()),o.signal.addEventListener("abort",S,{once:!0})}),X=setTimeout(()=>o.abort(),p),$=async()=>{let n=await V(`${i.href.replace(/\/$/,"")}/api/v1/${a}`,{method:T,headers:{"Content-Type":"application/json",...d?{}:{Authorization:`Bearer ${m}`},[E]:R.current,[L]:U.version,...s?{"X-Indiana-Project":s.projectId,"X-Indiana-Environment":s.environment}:{}},body:T==="POST"?JSON.stringify(x):void 0,signal:o.signal,credentials:"omit",cache:"no-store",redirect:"error",...v.keepalive?{keepalive:!0}:{}});if(o.signal.aborted)throw g();let r;try{r=n.status===204?H:await n.json()}catch{throw o.signal.aborted?g():new e(n.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",n.status,n.headers.get("X-Request-Id")??void 0)}if(o.signal.aborted)throw g();if(!d&&y!==f)throw new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!n.ok){let t=D.safeParse(r),c=t.success&&(!P.safeParse(t.data.error.code).success||C(t.data.error.code,n.status)),N=c?t.data.error.code:"HTTP_ERROR",_=j(N,n.status,{retryAfter:n.headers.get("Retry-After"),recovery:c?t.data.error.recovery:void 0,reason:c?t.data.error.reason:void 0});throw new e(N,c?t.data.error.message:"Indiana request failed",n.status,n.headers.get("X-Request-Id")??(t.success?t.data.requestId:void 0),{..._,...t.success&&t.data.error.retryable===!1?{retryable:!1}:{},..._.retryAfterSeconds===void 0&&t.success&&t.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:t.data.error.retryAfterSeconds}:{}})}if(n.headers.get(E)!==R.current)throw new e("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(s&&r!==H){let t=r&&typeof r=="object"&&"scope"in r?r:r&&typeof r=="object"&&"configuration"in r?r.configuration:null;if(!t||typeof t!="object"||!("scope"in t))throw new e("INVALID_RESPONSE","Response is missing its App/environment scope");let c=b.safeParse(t.scope);if(!c.success||c.data.projectId!==s.projectId||c.data.environment!==s.environment)throw new e("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let I=n.headers.get("X-Indiana-Telemetry-Subject");if(I){if(!/^[a-f0-9]{64}$/.test(I))throw new e("INVALID_RESPONSE","Invalid telemetry identity");h!==I&&(h=I,q?.(h))}return r};try{return await Promise.race([$(),F])}catch(n){throw!d&&y!==f?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):n instanceof e?n:new e(o.signal.aborted?"TIMEOUT":"NETWORK_ERROR",o.signal.aborted?"Indiana request timed out":"Unable to read the Indiana response")}finally{clearTimeout(X),o.signal.removeEventListener("abort",S),w.delete(o)}}return{subjectKey:()=>h,identify(a){if(!a.trim()||/\s/.test(a)||a.length>4096)throw new e("INVALID_TOKEN","A nonempty server-issued token is required");O(),m=a},reset:O,request:K}}export{Q as a};