@tinkerlandai/indiana-sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Release facts and artifact evidence: [SDK release ledger](../../docs/sdk-releases.md). Earlier personal-package versions are preserved in [@houzhen888/groove-grow history](../../docs/sdk-changelog-groove-grow.md). The two packages have independent version histories.
4
4
 
5
+ ## 0.2.0 — 2026-10-16
6
+
7
+ - Breaking: server Funnel starts and decisions use `customer: { type: "id" | "externalUserId", value }`; optional `customerData` is creation-only and requires an external user reference. Remove start-body `customerToken` and decision `customerId`; no legacy compatibility. Customer-credential starts name no Customer.
8
+ - Export `createFunnelCampaignClient` from `/server` for explicit campaign decisions and starts with durable suppression. Validate returned Funnel and Customer identity before accepting a Run.
9
+ - Use `X-Indiana-Web-View` and `X-Indiana-Telemetry-Subject` response headers. Include current renderer, native shell and Paywall recovery/lifecycle fixes.
10
+ - Route native receipt recovery through independent `subscriptions/native/restore`, including read-only recovery. This package release does not certify or publish Apple/Google store integrations; real store acceptance remains deferred.
11
+
5
12
  ## 0.1.0 — 2026-10-16
6
13
 
7
14
  - Web Beta with current Indiana factories, Customer two-table identity, current Funnel runtime, Feature generation, Offering hierarchy and independent Paywall sessions. No legacy API or data compatibility.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # @tinkerlandai/indiana-sdk
2
2
 
3
- Indiana 的 JavaScript/TypeScript SDK,包含浏览器、Node.js、屏幕渲染与可选 AI 用量集成。`0.1.0` 以 `beta` 标签分发;服务端和数据库必须使用匹配的当前协议。本版本有破坏性变更,不提供旧名称、旧输入或旧数据模型的兼容层。
3
+ Indiana 的 JavaScript/TypeScript SDK,包含浏览器、Node.js、屏幕渲染与可选 AI 用量集成。`0.2.0` 以 `beta` 标签分发;服务端和数据库必须使用匹配的当前协议。本版本有破坏性变更,不提供旧名称、旧输入或旧数据模型的兼容层。
4
4
 
5
5
  ```sh
6
- npm install @tinkerlandai/indiana-sdk@0.1.0
6
+ npm install @tinkerlandai/indiana-sdk@0.2.0
7
7
  ```
8
8
 
9
9
  ## 一个 npm 包,五个入口
@@ -57,7 +57,11 @@ Customer 使用原始业务字段;资料更新是部分 patch,没有 Custome
57
57
 
58
58
  ## Funnel、Feature 与独立 Paywall
59
59
 
60
- 可信后端通过 `createFunnelStartClient().start()` 提交 `funnelId`、持久保留的 `requestId`、`customerToken`、`locale` 和 `parameters`。响应丢失时保留原编号和输入重试。商业参数放在 `parameters.commerce`。运行有独立的 Run Token,不能据此切换 Customer。
60
+ 可信后端通过 `createFunnelStartClient().start()` 提交 `funnelId`、持久保留的 `requestId`、`customer`、`locale` 和 `parameters`。`customer` 为 `{ type: "id", value: customerId }` 或 `{ type: "externalUserId", value: verifiedUser.id }`。后者可以同时提供仅用于新建的 `customerData`,需要 `customers:write` 权限;已有 Customer 不因此更新。服务端响应返回 `customerId`,后端再为它签发 Customer Session。旧的 start-body `customerToken` 和 decision `customerId` 明确拒绝。
61
+
62
+ `createFunnelClient({ customerToken, ...options })` 用于已持有 Customer 凭据的客户端;其 `start()` 不指定 `customer` 或 `customerData`,始终以凭据所属 Customer 运行。响应丢失时保留原编号和输入重试,商业参数放在 `parameters.commerce`。运行有独立的 Run Token,不能据此切换 Customer。
63
+
64
+ `createFunnelDecisionClient` 的 `submit/decide` 与 `/server` 的 `createFunnelCampaignClient` 同样使用明确的 `customer` 引用。Campaign 客户端提供显式 `decide/start`;受频率或进行中运行限制时,`start` 返回 `suppressed` 和重试时间,不伪造 Run 凭据。Run 实际展示后才提交 `shown`,不能用页面关闭或本地存储代替持久的展示事实。
61
65
 
62
66
  浏览器使用 `createFunnelRunController` 与 `showFunnelRun`。控制器负责当前协议的命令、读取、重试、恢复和订阅;展示句柄提供 `refresh()` 和 `destroy()`。业务操作按当前发布节点委派给服务端,客户端声明或重定向不构成付款证明。
63
67
 
@@ -73,10 +77,10 @@ Stripe 环境的 `autumn` 模式由 Indiana 执行;`record_only` 返回交给
73
77
 
74
78
  本 Beta **不认证完整商业功能或生产运行**。当前仍未接通的服务包括:
75
79
 
76
- - 订阅批处理及冲突管理。
77
- - Billing Authorization 的准备/确认/撤销、Billing Coupon 列表和账单调整确认。
80
+ - 订阅批处理。冲突查询/重试已有对应服务,但仍需匹配部署及业务前置条件。
81
+ - Postpaid Billing Authorization、Billing Coupon 列表和账单调整确认。当前 AutoTopup consent 的准备/确认/撤销已有服务,不能据此推定其他授权类型可用。
78
82
  - `claimRewardProduct` 的完整交付。
79
- - Apple/Google 购买、通知、收据恢复和商店验收;原生协议入口保留为后续配套,当前不可据此承诺交付。
83
+ - Apple/Google 真实商店验收。当前独立购买/恢复的协议及部分服务实现不代表商店已验收;`createNativeReceiptClient().recover()` 使用 `subscriptions/native/restore`,不再发送旧 Funnel 原生恢复命令。
80
84
 
81
85
  Live 商业执行仍有显式服务端门禁。其他 Product/Price、Entity、订阅追加和数量组合,以匹配服务端的实际能力为准;不自动回退到旧实现。
82
86
 
@@ -432,18 +432,26 @@ declare const apiOperations: {
432
432
  readonly audience: "mixed";
433
433
  readonly request: z.ZodUnion<(z.ZodObject<{
434
434
  requestId: z.ZodUUID;
435
- provider: z.ZodLiteral<"google">;
435
+ provider: z.ZodLiteral<"apple">;
436
436
  purchaseIntentId: z.ZodUUID;
437
- productId: z.ZodString;
438
- purchaseToken: z.ZodString;
437
+ productId: z.ZodOptional<z.ZodString>;
438
+ signedTransaction: z.ZodString;
439
439
  customerId: z.ZodOptional<z.ZodUUID>;
440
+ customerToken: z.ZodOptional<z.ZodString>;
440
441
  }, z.core.$strict> | z.ZodObject<{
442
+ intent: z.ZodLiteral<"read">;
441
443
  requestId: z.ZodUUID;
442
- provider: z.ZodLiteral<"apple">;
443
444
  purchaseIntentId: z.ZodUUID;
444
- productId: z.ZodString;
445
- signedTransaction: z.ZodString;
446
445
  customerId: z.ZodOptional<z.ZodUUID>;
446
+ customerToken: z.ZodOptional<z.ZodString>;
447
+ }, z.core.$strict> | z.ZodObject<{
448
+ requestId: z.ZodUUID;
449
+ provider: z.ZodLiteral<"google">;
450
+ purchaseIntentId: z.ZodUUID;
451
+ productId: z.ZodOptional<z.ZodString>;
452
+ purchaseToken: z.ZodString;
453
+ customerId: z.ZodOptional<z.ZodUUID>;
454
+ customerToken: z.ZodOptional<z.ZodString>;
447
455
  }, z.core.$strict>)[]>;
448
456
  readonly response: z.ZodObject<{
449
457
  requestId: z.ZodUUID;
@@ -2234,6 +2242,25 @@ declare const apiOperations: {
2234
2242
  catalogAmountMinor: z.ZodNumber;
2235
2243
  automaticTax: z.ZodBoolean;
2236
2244
  execution: z.ZodNullable<z.ZodObject<{
2245
+ append: z.ZodOptional<z.ZodObject<{
2246
+ subscriptionId: z.ZodString;
2247
+ customerId: z.ZodString;
2248
+ sourceItems: z.ZodArray<z.ZodObject<{
2249
+ id: z.ZodString;
2250
+ price_id: z.ZodString;
2251
+ quantity: z.ZodNumber;
2252
+ discounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
2253
+ id: z.ZodString;
2254
+ coupon: z.ZodString;
2255
+ start: z.ZodNumber;
2256
+ end: z.ZodNullable<z.ZodNumber>;
2257
+ }, z.core.$strict>>>;
2258
+ }, z.core.$strict>>;
2259
+ prorationDate: z.ZodNumber;
2260
+ amountMinor: z.ZodNumber;
2261
+ periodStartMs: z.ZodNumber;
2262
+ periodEndMs: z.ZodNumber;
2263
+ }, z.core.$strict>>;
2237
2264
  provider: z.ZodLiteral<"stripe">;
2238
2265
  executor: z.ZodEnum<{
2239
2266
  merchant: "merchant";
@@ -2275,9 +2302,9 @@ declare const apiOperations: {
2275
2302
  }, z.core.$strict>>;
2276
2303
  }, z.core.$strict>>;
2277
2304
  discounts: z.ZodArray<z.ZodObject<{
2278
- coupon: z.ZodUUID;
2305
+ coupon: z.ZodString;
2279
2306
  terms: z.ZodObject<{
2280
- id: z.ZodUUID;
2307
+ id: z.ZodString;
2281
2308
  name: z.ZodString;
2282
2309
  percent_off: z.ZodOptional<z.ZodNumber>;
2283
2310
  amount_off: z.ZodOptional<z.ZodNumber>;
@@ -2325,6 +2352,7 @@ declare const apiOperations: {
2325
2352
  operation: z.ZodObject<{
2326
2353
  operationId: z.ZodUUID;
2327
2354
  orderId: z.ZodUUID;
2355
+ append: z.ZodOptional<z.ZodBoolean>;
2328
2356
  status: z.ZodEnum<{
2329
2357
  pending: "pending";
2330
2358
  cancelled: "cancelled";
@@ -2337,6 +2365,25 @@ declare const apiOperations: {
2337
2365
  }>;
2338
2366
  checkoutUrl: z.ZodNullable<z.ZodURL>;
2339
2367
  execution: z.ZodNullable<z.ZodObject<{
2368
+ append: z.ZodOptional<z.ZodObject<{
2369
+ subscriptionId: z.ZodString;
2370
+ customerId: z.ZodString;
2371
+ sourceItems: z.ZodArray<z.ZodObject<{
2372
+ id: z.ZodString;
2373
+ price_id: z.ZodString;
2374
+ quantity: z.ZodNumber;
2375
+ discounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
2376
+ id: z.ZodString;
2377
+ coupon: z.ZodString;
2378
+ start: z.ZodNumber;
2379
+ end: z.ZodNullable<z.ZodNumber>;
2380
+ }, z.core.$strict>>>;
2381
+ }, z.core.$strict>>;
2382
+ prorationDate: z.ZodNumber;
2383
+ amountMinor: z.ZodNumber;
2384
+ periodStartMs: z.ZodNumber;
2385
+ periodEndMs: z.ZodNumber;
2386
+ }, z.core.$strict>>;
2340
2387
  provider: z.ZodLiteral<"stripe">;
2341
2388
  executor: z.ZodEnum<{
2342
2389
  merchant: "merchant";
@@ -2378,9 +2425,9 @@ declare const apiOperations: {
2378
2425
  }, z.core.$strict>>;
2379
2426
  }, z.core.$strict>>;
2380
2427
  discounts: z.ZodArray<z.ZodObject<{
2381
- coupon: z.ZodUUID;
2428
+ coupon: z.ZodString;
2382
2429
  terms: z.ZodObject<{
2383
- id: z.ZodUUID;
2430
+ id: z.ZodString;
2384
2431
  name: z.ZodString;
2385
2432
  percent_off: z.ZodOptional<z.ZodNumber>;
2386
2433
  amount_off: z.ZodOptional<z.ZodNumber>;
@@ -2547,6 +2594,7 @@ declare const apiOperations: {
2547
2594
  operation: z.ZodObject<{
2548
2595
  operationId: z.ZodUUID;
2549
2596
  orderId: z.ZodUUID;
2597
+ append: z.ZodOptional<z.ZodBoolean>;
2550
2598
  status: z.ZodEnum<{
2551
2599
  pending: "pending";
2552
2600
  cancelled: "cancelled";
@@ -2559,6 +2607,25 @@ declare const apiOperations: {
2559
2607
  }>;
2560
2608
  checkoutUrl: z.ZodNullable<z.ZodURL>;
2561
2609
  execution: z.ZodNullable<z.ZodObject<{
2610
+ append: z.ZodOptional<z.ZodObject<{
2611
+ subscriptionId: z.ZodString;
2612
+ customerId: z.ZodString;
2613
+ sourceItems: z.ZodArray<z.ZodObject<{
2614
+ id: z.ZodString;
2615
+ price_id: z.ZodString;
2616
+ quantity: z.ZodNumber;
2617
+ discounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
2618
+ id: z.ZodString;
2619
+ coupon: z.ZodString;
2620
+ start: z.ZodNumber;
2621
+ end: z.ZodNullable<z.ZodNumber>;
2622
+ }, z.core.$strict>>>;
2623
+ }, z.core.$strict>>;
2624
+ prorationDate: z.ZodNumber;
2625
+ amountMinor: z.ZodNumber;
2626
+ periodStartMs: z.ZodNumber;
2627
+ periodEndMs: z.ZodNumber;
2628
+ }, z.core.$strict>>;
2562
2629
  provider: z.ZodLiteral<"stripe">;
2563
2630
  executor: z.ZodEnum<{
2564
2631
  merchant: "merchant";
@@ -2600,9 +2667,9 @@ declare const apiOperations: {
2600
2667
  }, z.core.$strict>>;
2601
2668
  }, z.core.$strict>>;
2602
2669
  discounts: z.ZodArray<z.ZodObject<{
2603
- coupon: z.ZodUUID;
2670
+ coupon: z.ZodString;
2604
2671
  terms: z.ZodObject<{
2605
- id: z.ZodUUID;
2672
+ id: z.ZodString;
2606
2673
  name: z.ZodString;
2607
2674
  percent_off: z.ZodOptional<z.ZodNumber>;
2608
2675
  amount_off: z.ZodOptional<z.ZodNumber>;
@@ -3731,11 +3798,16 @@ declare const apiOperations: {
3731
3798
  terms: z.ZodDiscriminatedUnion<[z.ZodObject<{
3732
3799
  kind: z.ZodLiteral<"auto_topup">;
3733
3800
  threshold: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
3734
- maxPurchasesPerDay: z.ZodNumber;
3735
- purchaseLimits: z.ZodOptional<z.ZodObject<{
3736
- hour: z.ZodOptional<z.ZodNumber>;
3737
- week: z.ZodOptional<z.ZodNumber>;
3738
- month: z.ZodOptional<z.ZodNumber>;
3801
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
3802
+ purchaseLimit: z.ZodOptional<z.ZodObject<{
3803
+ interval: z.ZodEnum<{
3804
+ hour: "hour";
3805
+ day: "day";
3806
+ week: "week";
3807
+ month: "month";
3808
+ }>;
3809
+ intervalCount: z.ZodNumber;
3810
+ limit: z.ZodNumber;
3739
3811
  }, z.core.$strict>>;
3740
3812
  purchaseAmountMinor: z.ZodString;
3741
3813
  purchaseUnits: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -3776,9 +3848,9 @@ declare const apiOperations: {
3776
3848
  TRY: "TRY";
3777
3849
  RON: "RON";
3778
3850
  }>;
3779
- maxAmountMinorPerPeriod: z.ZodString;
3780
3851
  }, z.core.$strict>, z.ZodObject<{
3781
3852
  kind: z.ZodLiteral<"postpaid">;
3853
+ maxAmountMinorPerPeriod: z.ZodString;
3782
3854
  maxOutstandingMinor: z.ZodString;
3783
3855
  cashPrice: z.ZodObject<{
3784
3856
  currency: z.ZodEnum<{
@@ -3881,7 +3953,6 @@ declare const apiOperations: {
3881
3953
  TRY: "TRY";
3882
3954
  RON: "RON";
3883
3955
  }>;
3884
- maxAmountMinorPerPeriod: z.ZodString;
3885
3956
  }, z.core.$strict>], "kind">;
3886
3957
  status: z.ZodEnum<{
3887
3958
  revoked: "revoked";
@@ -3969,10 +4040,14 @@ declare const apiOperations: {
3969
4040
  blocked: "blocked";
3970
4041
  idle: "idle";
3971
4042
  }>;
3972
- orderId: z.ZodNullable<z.ZodUUID>;
4043
+ taskId: z.ZodNullable<z.ZodUUID>;
4044
+ invoiceId: z.ZodNullable<z.ZodUUID>;
3973
4045
  hostedInvoiceUrl: z.ZodNullable<z.ZodURL>;
3974
- purchasesToday: z.ZodNumber;
3975
- amountMinorThisMonth: z.ZodString;
4046
+ purchaseCount: z.ZodNumber;
4047
+ purchaseWindowEndsAt: z.ZodNullable<z.ZodISODateTime>;
4048
+ attemptCount: z.ZodNumber;
4049
+ failedAttemptCount: z.ZodNumber;
4050
+ suspendedAt: z.ZodNullable<z.ZodISODateTime>;
3976
4051
  nextAttemptAt: z.ZodNullable<z.ZodISODateTime>;
3977
4052
  failureReason: z.ZodNullable<z.ZodString>;
3978
4053
  }, z.core.$strict>>;
@@ -3988,11 +4063,16 @@ declare const apiOperations: {
3988
4063
  readonly request: z.ZodDiscriminatedUnion<[z.ZodObject<{
3989
4064
  kind: z.ZodLiteral<"auto_topup">;
3990
4065
  threshold: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
3991
- maxPurchasesPerDay: z.ZodNumber;
3992
- purchaseLimits: z.ZodOptional<z.ZodObject<{
3993
- hour: z.ZodOptional<z.ZodNumber>;
3994
- week: z.ZodOptional<z.ZodNumber>;
3995
- month: z.ZodOptional<z.ZodNumber>;
4066
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4067
+ purchaseLimit: z.ZodOptional<z.ZodObject<{
4068
+ interval: z.ZodEnum<{
4069
+ hour: "hour";
4070
+ day: "day";
4071
+ week: "week";
4072
+ month: "month";
4073
+ }>;
4074
+ intervalCount: z.ZodNumber;
4075
+ limit: z.ZodNumber;
3996
4076
  }, z.core.$strict>>;
3997
4077
  requestId: z.ZodUUID;
3998
4078
  productVersionId: z.ZodUUID;
@@ -4032,9 +4112,9 @@ declare const apiOperations: {
4032
4112
  TRY: "TRY";
4033
4113
  RON: "RON";
4034
4114
  }>;
4035
- maxAmountMinorPerPeriod: z.ZodString;
4036
4115
  }, z.core.$strict>, z.ZodObject<{
4037
4116
  kind: z.ZodLiteral<"postpaid">;
4117
+ maxAmountMinorPerPeriod: z.ZodString;
4038
4118
  maxOutstandingMinor: z.ZodString;
4039
4119
  requestId: z.ZodUUID;
4040
4120
  productVersionId: z.ZodUUID;
@@ -4074,7 +4154,6 @@ declare const apiOperations: {
4074
4154
  TRY: "TRY";
4075
4155
  RON: "RON";
4076
4156
  }>;
4077
- maxAmountMinorPerPeriod: z.ZodString;
4078
4157
  }, z.core.$strict>], "kind">;
4079
4158
  readonly response: z.ZodObject<{
4080
4159
  requestId: z.ZodUUID;
@@ -4090,11 +4169,16 @@ declare const apiOperations: {
4090
4169
  terms: z.ZodDiscriminatedUnion<[z.ZodObject<{
4091
4170
  kind: z.ZodLiteral<"auto_topup">;
4092
4171
  threshold: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4093
- maxPurchasesPerDay: z.ZodNumber;
4094
- purchaseLimits: z.ZodOptional<z.ZodObject<{
4095
- hour: z.ZodOptional<z.ZodNumber>;
4096
- week: z.ZodOptional<z.ZodNumber>;
4097
- month: z.ZodOptional<z.ZodNumber>;
4172
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4173
+ purchaseLimit: z.ZodOptional<z.ZodObject<{
4174
+ interval: z.ZodEnum<{
4175
+ hour: "hour";
4176
+ day: "day";
4177
+ week: "week";
4178
+ month: "month";
4179
+ }>;
4180
+ intervalCount: z.ZodNumber;
4181
+ limit: z.ZodNumber;
4098
4182
  }, z.core.$strict>>;
4099
4183
  purchaseAmountMinor: z.ZodString;
4100
4184
  purchaseUnits: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -4135,9 +4219,9 @@ declare const apiOperations: {
4135
4219
  TRY: "TRY";
4136
4220
  RON: "RON";
4137
4221
  }>;
4138
- maxAmountMinorPerPeriod: z.ZodString;
4139
4222
  }, z.core.$strict>, z.ZodObject<{
4140
4223
  kind: z.ZodLiteral<"postpaid">;
4224
+ maxAmountMinorPerPeriod: z.ZodString;
4141
4225
  maxOutstandingMinor: z.ZodString;
4142
4226
  cashPrice: z.ZodObject<{
4143
4227
  currency: z.ZodEnum<{
@@ -4240,7 +4324,6 @@ declare const apiOperations: {
4240
4324
  TRY: "TRY";
4241
4325
  RON: "RON";
4242
4326
  }>;
4243
- maxAmountMinorPerPeriod: z.ZodString;
4244
4327
  }, z.core.$strict>], "kind">;
4245
4328
  setupUrl: z.ZodNullable<z.ZodURL>;
4246
4329
  }, z.core.$strict>;
@@ -4269,11 +4352,16 @@ declare const apiOperations: {
4269
4352
  terms: z.ZodDiscriminatedUnion<[z.ZodObject<{
4270
4353
  kind: z.ZodLiteral<"auto_topup">;
4271
4354
  threshold: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4272
- maxPurchasesPerDay: z.ZodNumber;
4273
- purchaseLimits: z.ZodOptional<z.ZodObject<{
4274
- hour: z.ZodOptional<z.ZodNumber>;
4275
- week: z.ZodOptional<z.ZodNumber>;
4276
- month: z.ZodOptional<z.ZodNumber>;
4355
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4356
+ purchaseLimit: z.ZodOptional<z.ZodObject<{
4357
+ interval: z.ZodEnum<{
4358
+ hour: "hour";
4359
+ day: "day";
4360
+ week: "week";
4361
+ month: "month";
4362
+ }>;
4363
+ intervalCount: z.ZodNumber;
4364
+ limit: z.ZodNumber;
4277
4365
  }, z.core.$strict>>;
4278
4366
  purchaseAmountMinor: z.ZodString;
4279
4367
  purchaseUnits: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -4314,9 +4402,9 @@ declare const apiOperations: {
4314
4402
  TRY: "TRY";
4315
4403
  RON: "RON";
4316
4404
  }>;
4317
- maxAmountMinorPerPeriod: z.ZodString;
4318
4405
  }, z.core.$strict>, z.ZodObject<{
4319
4406
  kind: z.ZodLiteral<"postpaid">;
4407
+ maxAmountMinorPerPeriod: z.ZodString;
4320
4408
  maxOutstandingMinor: z.ZodString;
4321
4409
  cashPrice: z.ZodObject<{
4322
4410
  currency: z.ZodEnum<{
@@ -4419,7 +4507,6 @@ declare const apiOperations: {
4419
4507
  TRY: "TRY";
4420
4508
  RON: "RON";
4421
4509
  }>;
4422
- maxAmountMinorPerPeriod: z.ZodString;
4423
4510
  }, z.core.$strict>], "kind">;
4424
4511
  status: z.ZodEnum<{
4425
4512
  revoked: "revoked";
@@ -4440,7 +4527,7 @@ declare const apiOperations: {
4440
4527
  readonly permission: "billing:write";
4441
4528
  readonly audience: "customer";
4442
4529
  readonly request: z.ZodObject<{
4443
- authorizationId: z.ZodUUID;
4530
+ membershipId: z.ZodUUID;
4444
4531
  requestId: z.ZodUUID;
4445
4532
  grantIds: z.ZodArray<z.ZodUUID>;
4446
4533
  }, z.core.$strict>;
@@ -4454,7 +4541,56 @@ declare const apiOperations: {
4454
4541
  }>;
4455
4542
  }, z.core.$strict>;
4456
4543
  coupons: z.ZodObject<{
4457
- authorizationId: z.ZodUUID;
4544
+ membershipId: z.ZodUUID;
4545
+ operationId: z.ZodUUID;
4546
+ status: z.ZodEnum<{
4547
+ pending: "pending";
4548
+ effective: "effective";
4549
+ }>;
4550
+ execution: z.ZodNullable<z.ZodObject<{
4551
+ subscriptionId: z.ZodString;
4552
+ customerId: z.ZodString;
4553
+ accountId: z.ZodString;
4554
+ sourceItems: z.ZodArray<z.ZodObject<{
4555
+ id: z.ZodString;
4556
+ price_id: z.ZodString;
4557
+ quantity: z.ZodNumber;
4558
+ discounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
4559
+ id: z.ZodString;
4560
+ coupon: z.ZodString;
4561
+ start: z.ZodNumber;
4562
+ end: z.ZodNullable<z.ZodNumber>;
4563
+ }, z.core.$strict>>>;
4564
+ }, z.core.$strict>>;
4565
+ items: z.ZodArray<z.ZodObject<{
4566
+ id: z.ZodString;
4567
+ price: z.ZodString;
4568
+ quantity: z.ZodNumber;
4569
+ discounts: z.ZodArray<z.ZodObject<{
4570
+ coupon: z.ZodOptional<z.ZodString>;
4571
+ terms: z.ZodOptional<z.ZodObject<{
4572
+ id: z.ZodString;
4573
+ name: z.ZodOptional<z.ZodString>;
4574
+ percent_off: z.ZodOptional<z.ZodNumber>;
4575
+ amount_off: z.ZodOptional<z.ZodNumber>;
4576
+ currency: z.ZodOptional<z.ZodString>;
4577
+ duration: z.ZodEnum<{
4578
+ once: "once";
4579
+ repeating: "repeating";
4580
+ forever: "forever";
4581
+ }>;
4582
+ duration_in_months: z.ZodOptional<z.ZodNumber>;
4583
+ }, z.core.$strict>>;
4584
+ discount: z.ZodOptional<z.ZodString>;
4585
+ receipt: z.ZodOptional<z.ZodObject<{
4586
+ id: z.ZodString;
4587
+ coupon: z.ZodString;
4588
+ start: z.ZodNumber;
4589
+ end: z.ZodNullable<z.ZodNumber>;
4590
+ }, z.core.$strict>>;
4591
+ }, z.core.$strict>>;
4592
+ }, z.core.$strict>>;
4593
+ }, z.core.$strict>>;
4458
4594
  grants: z.ZodArray<z.ZodObject<{
4459
4595
  id: z.ZodUUID;
4460
4596
  couponId: z.ZodUUID;
@@ -4537,11 +4673,16 @@ declare const apiOperations: {
4537
4673
  terms: z.ZodDiscriminatedUnion<[z.ZodObject<{
4538
4674
  kind: z.ZodLiteral<"auto_topup">;
4539
4675
  threshold: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4540
- maxPurchasesPerDay: z.ZodNumber;
4541
- purchaseLimits: z.ZodOptional<z.ZodObject<{
4542
- hour: z.ZodOptional<z.ZodNumber>;
4543
- week: z.ZodOptional<z.ZodNumber>;
4544
- month: z.ZodOptional<z.ZodNumber>;
4676
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4677
+ purchaseLimit: z.ZodOptional<z.ZodObject<{
4678
+ interval: z.ZodEnum<{
4679
+ hour: "hour";
4680
+ day: "day";
4681
+ week: "week";
4682
+ month: "month";
4683
+ }>;
4684
+ intervalCount: z.ZodNumber;
4685
+ limit: z.ZodNumber;
4545
4686
  }, z.core.$strict>>;
4546
4687
  purchaseAmountMinor: z.ZodString;
4547
4688
  purchaseUnits: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -4582,9 +4723,9 @@ declare const apiOperations: {
4582
4723
  TRY: "TRY";
4583
4724
  RON: "RON";
4584
4725
  }>;
4585
- maxAmountMinorPerPeriod: z.ZodString;
4586
4726
  }, z.core.$strict>, z.ZodObject<{
4587
4727
  kind: z.ZodLiteral<"postpaid">;
4728
+ maxAmountMinorPerPeriod: z.ZodString;
4588
4729
  maxOutstandingMinor: z.ZodString;
4589
4730
  cashPrice: z.ZodObject<{
4590
4731
  currency: z.ZodEnum<{
@@ -4687,7 +4828,6 @@ declare const apiOperations: {
4687
4828
  TRY: "TRY";
4688
4829
  RON: "RON";
4689
4830
  }>;
4690
- maxAmountMinorPerPeriod: z.ZodString;
4691
4831
  }, z.core.$strict>], "kind">;
4692
4832
  status: z.ZodEnum<{
4693
4833
  revoked: "revoked";
@@ -5083,11 +5223,16 @@ declare const apiOperations: {
5083
5223
  terms: z.ZodDiscriminatedUnion<[z.ZodObject<{
5084
5224
  kind: z.ZodLiteral<"auto_topup">;
5085
5225
  threshold: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
5086
- maxPurchasesPerDay: z.ZodNumber;
5087
- purchaseLimits: z.ZodOptional<z.ZodObject<{
5088
- hour: z.ZodOptional<z.ZodNumber>;
5089
- week: z.ZodOptional<z.ZodNumber>;
5090
- month: z.ZodOptional<z.ZodNumber>;
5226
+ quantity: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
5227
+ purchaseLimit: z.ZodOptional<z.ZodObject<{
5228
+ interval: z.ZodEnum<{
5229
+ hour: "hour";
5230
+ day: "day";
5231
+ week: "week";
5232
+ month: "month";
5233
+ }>;
5234
+ intervalCount: z.ZodNumber;
5235
+ limit: z.ZodNumber;
5091
5236
  }, z.core.$strict>>;
5092
5237
  purchaseAmountMinor: z.ZodString;
5093
5238
  purchaseUnits: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -5128,9 +5273,9 @@ declare const apiOperations: {
5128
5273
  TRY: "TRY";
5129
5274
  RON: "RON";
5130
5275
  }>;
5131
- maxAmountMinorPerPeriod: z.ZodString;
5132
5276
  }, z.core.$strict>, z.ZodObject<{
5133
5277
  kind: z.ZodLiteral<"postpaid">;
5278
+ maxAmountMinorPerPeriod: z.ZodString;
5134
5279
  maxOutstandingMinor: z.ZodString;
5135
5280
  cashPrice: z.ZodObject<{
5136
5281
  currency: z.ZodEnum<{
@@ -5233,7 +5378,6 @@ declare const apiOperations: {
5233
5378
  TRY: "TRY";
5234
5379
  RON: "RON";
5235
5380
  }>;
5236
- maxAmountMinorPerPeriod: z.ZodString;
5237
5381
  }, z.core.$strict>], "kind">;
5238
5382
  status: z.ZodEnum<{
5239
5383
  revoked: "revoked";
@@ -5321,10 +5465,14 @@ declare const apiOperations: {
5321
5465
  blocked: "blocked";
5322
5466
  idle: "idle";
5323
5467
  }>;
5324
- orderId: z.ZodNullable<z.ZodUUID>;
5468
+ taskId: z.ZodNullable<z.ZodUUID>;
5469
+ invoiceId: z.ZodNullable<z.ZodUUID>;
5325
5470
  hostedInvoiceUrl: z.ZodNullable<z.ZodURL>;
5326
- purchasesToday: z.ZodNumber;
5327
- amountMinorThisMonth: z.ZodString;
5471
+ purchaseCount: z.ZodNumber;
5472
+ purchaseWindowEndsAt: z.ZodNullable<z.ZodISODateTime>;
5473
+ attemptCount: z.ZodNumber;
5474
+ failedAttemptCount: z.ZodNumber;
5475
+ suspendedAt: z.ZodNullable<z.ZodISODateTime>;
5328
5476
  nextAttemptAt: z.ZodNullable<z.ZodISODateTime>;
5329
5477
  failureReason: z.ZodNullable<z.ZodString>;
5330
5478
  }, z.core.$strict>>;
@@ -1 +1 @@
1
- import{Y as E,ic as O}from"./chunk-FMAMDKAV.js";var e=class extends Error{constructor(m,o,n,N){super(o);this.code=m;this.status=n;this.requestId=N;this.name="IndianaError"}code;status;requestId},V=Symbol("IndianaNoContent");function L(d,y){let m=d.webView??"hosted";if(!["hosted","embedded"].includes(m))throw new e("INVALID_REQUEST","Invalid Web View mode");let o=d.scope?E.parse(d.scope):void 0,n=new URL(d.baseUrl);if(n.username||n.password||n.search||n.hash)throw new e("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(n.protocol!=="https:"&&!(n.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(n.hostname)))throw new e("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let N=d.fetch??globalThis.fetch.bind(globalThis),u=d.timeoutMs??1e4;if(!Number.isFinite(u)||u<=0||u>12e4)throw new e("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let w=null,b,c=0,l=null,h=new Set;function S(){c+=1,w=null,l=null;for(let s of h)s.abort();h.clear()}async function _(s,R={},v="POST"){if(!w)throw new e("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let I=c,r=new AbortController;h.add(r);let p=()=>I!==c?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new e("TIMEOUT","Indiana request timed out"),g,A=new Promise((t,i)=>{g=()=>i(p()),r.signal.addEventListener("abort",g,{once:!0})}),D=setTimeout(()=>r.abort(),u),P=async()=>{let t=await N(`${n.href.replace(/\/$/,"")}/api/v1/${s}`,{method:v,headers:{"Content-Type":"application/json",Authorization:`Bearer ${w}`,...o?{"X-Indiana-Project":o.projectId,"X-Indiana-Environment":o.environment}:{}},body:v==="POST"?JSON.stringify(R):void 0,signal:r.signal,credentials:"omit",cache:"no-store",redirect:"error"});if(r.signal.aborted)throw p();let i=t.status===204?V:await t.json();if(r.signal.aborted)throw p();if(I!==c)throw new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!t.ok){let a=O.safeParse(i);throw new e(a.success?a.data.error.code:"HTTP_ERROR",a.success?a.data.error.message:"Indiana request failed",t.status,t.headers.get("X-Request-Id")??void 0)}if(o&&i&&typeof i=="object"&&"scope"in i){let a=E.safeParse(i.scope);if(!a.success||a.data.projectId!==o.projectId||a.data.environment!==o.environment)throw new e("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let T=t.headers.get("X-Grow-Web-View");if(T){if(!/^\/web-view\/renderer\/[a-f0-9]{64}$/.test(T))throw new e("INVALID_RESPONSE","Invalid Web View renderer metadata");b=T}let f=t.headers.get("X-Grow-Telemetry-Subject");if(f){if(!/^[a-f0-9]{64}$/.test(f))throw new e("INVALID_RESPONSE","Invalid telemetry identity");l!==f&&(l=f,y?.(l))}return i};try{return await Promise.race([P(),A])}catch(t){throw I!==c?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):t instanceof e?t:new e(r.signal.aborted?"TIMEOUT":"NETWORK_ERROR",r.signal.aborted?"Indiana request timed out":"Unable to read the Indiana response")}finally{clearTimeout(D),r.signal.removeEventListener("abort",g),h.delete(r)}}return{subjectKey:()=>l,webViewUrl(){if(m!=="embedded"){if(!b)throw new e("INVALID_RESPONSE","The gateway did not provide a hosted Web View renderer");return new URL(b,n).href}},identify(s){if(!s.trim()||/\s/.test(s)||s.length>4096)throw new e("INVALID_TOKEN","A nonempty server-issued token is required");S(),w=s},reset:S,request:_}}export{e as a,L as b};
1
+ import{Y as E,jc as O}from"./chunk-YOH6DIUN.js";var e=class extends Error{constructor(m,o,n,N){super(o);this.code=m;this.status=n;this.requestId=N;this.name="IndianaError"}code;status;requestId},V=Symbol("IndianaNoContent");function L(d,y){let m=d.webView??"hosted";if(!["hosted","embedded"].includes(m))throw new e("INVALID_REQUEST","Invalid Web View mode");let o=d.scope?E.parse(d.scope):void 0,n=new URL(d.baseUrl);if(n.username||n.password||n.search||n.hash)throw new e("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(n.protocol!=="https:"&&!(n.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(n.hostname)))throw new e("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let N=d.fetch??globalThis.fetch.bind(globalThis),u=d.timeoutMs??1e4;if(!Number.isFinite(u)||u<=0||u>12e4)throw new e("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let h=null,b,c=0,l=null,w=new Set;function S(){c+=1,h=null,l=null;for(let s of w)s.abort();w.clear()}async function _(s,R={},v="POST"){if(!h)throw new e("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let I=c,r=new AbortController;w.add(r);let p=()=>I!==c?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new e("TIMEOUT","Indiana request timed out"),g,A=new Promise((t,i)=>{g=()=>i(p()),r.signal.addEventListener("abort",g,{once:!0})}),D=setTimeout(()=>r.abort(),u),P=async()=>{let t=await N(`${n.href.replace(/\/$/,"")}/api/v1/${s}`,{method:v,headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`,...o?{"X-Indiana-Project":o.projectId,"X-Indiana-Environment":o.environment}:{}},body:v==="POST"?JSON.stringify(R):void 0,signal:r.signal,credentials:"omit",cache:"no-store",redirect:"error"});if(r.signal.aborted)throw p();let i=t.status===204?V:await t.json();if(r.signal.aborted)throw p();if(I!==c)throw new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!t.ok){let a=O.safeParse(i);throw new e(a.success?a.data.error.code:"HTTP_ERROR",a.success?a.data.error.message:"Indiana request failed",t.status,t.headers.get("X-Request-Id")??void 0)}if(o&&i&&typeof i=="object"&&"scope"in i){let a=E.safeParse(i.scope);if(!a.success||a.data.projectId!==o.projectId||a.data.environment!==o.environment)throw new e("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let T=t.headers.get("X-Indiana-Web-View");if(T){if(!/^\/web-view\/renderer\/[a-f0-9]{64}$/.test(T))throw new e("INVALID_RESPONSE","Invalid Web View renderer metadata");b=T}let f=t.headers.get("X-Indiana-Telemetry-Subject");if(f){if(!/^[a-f0-9]{64}$/.test(f))throw new e("INVALID_RESPONSE","Invalid telemetry identity");l!==f&&(l=f,y?.(l))}return i};try{return await Promise.race([P(),A])}catch(t){throw I!==c?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):t instanceof e?t:new e(r.signal.aborted?"TIMEOUT":"NETWORK_ERROR",r.signal.aborted?"Indiana request timed out":"Unable to read the Indiana response")}finally{clearTimeout(D),r.signal.removeEventListener("abort",g),w.delete(r)}}return{subjectKey:()=>l,webViewUrl(){if(m!=="embedded"){if(!b)throw new e("INVALID_RESPONSE","The gateway did not provide a hosted Web View renderer");return new URL(b,n).href}},identify(s){if(!s.trim()||/\s/.test(s)||s.length>4096)throw new e("INVALID_TOKEN","A nonempty server-issued token is required");S(),h=s},reset:S,request:_}}export{e as a,L as b};
@@ -0,0 +1 @@
1
+ import{a as s,b as E}from"./chunk-EZFAY4ZL.js";import{Dj as D,Lh as w,Mj as V,Oe as b,Oj as N,ma as I,na as x,oa as k,pa as h,ra as v,sj as O}from"./chunk-YOH6DIUN.js";async function q(n,t){if(!/^gg_ct_[A-Za-z0-9_-]{43}$/.test(t.customerToken))throw new s("INVALID_TOKEN","A verified Customer credential is required");let a=E(n);a.identify(t.customerToken);let i=w.resolvePaywall.request.parse({selector:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale,...t.requirement?{requirement:t.requirement}:{}}),e=null,o=null,u=null,r=null,c=null;async function p(){let l=w.resolvePaywall,f=l.response.parse(await a.request(l.path,l.request.parse({...i,selector:e?{type:"version",versionId:e.id}:i.selector})));if(f.paywall.paywallId!==t.paywallId)throw new s("INVALID_RESPONSE","The requested Paywall changed");if(e&&(f.paywall.id!==e.id||f.paywall.paywallId!==e.paywallId||f.paywall.offering.id!==e.offering.id))throw new s("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");return e=f.paywall,structuredClone(e)}async function d(l){if(!o)throw new s("INVALID_REQUEST","A quoted purchase is required");let f=l==="read"?w.readSubscriptionOperation:w.attach,m=f.response.parse(await a.request(f.path,f.request.parse({operationId:o.operationId,...l==="read"?{}:{intent:l}})));if(m.operation.operationId!==o.operationId||m.operation.currency!==i.commerce.currency)throw new s("INVALID_RESPONSE","The purchase operation changed");return u?.status==="complete"&&m.operation.status!=="complete"||u&&u.status!=="pending"&&m.operation.status==="pending"||(u=m.operation),structuredClone(u)}let y={get view(){return e?structuredClone(e):null},get quote(){return o?structuredClone(o):null},get operation(){return u?structuredClone(u):null},get webViewUrl(){return a.webViewUrl()},refresh:p,async preview(l){if(!e)throw new s("INVALID_REQUEST","Load the Paywall first");let f=e.document.buttons[l.actionId];if(f?.type!=="checkout")throw new s("INVALID_REQUEST","Choose an authored purchase action");let m=b(f.product,l.selection,e.capabilities);if(!m)throw new s("PRODUCT_UNAVAILABLE","Choose an available Product");let C=w.previewAttach.request.parse({requestId:l.requestId,plans:[{productVersionId:m}],provider:i.commerce.provider,currency:i.commerce.currency,...l.offerId?{offerId:l.offerId}:{},...l.nativeOffer?{nativeOffer:l.nativeOffer}:{}}),A=JSON.stringify(C);if(r&&r!==A&&(!u||u.status==="pending"))throw new s("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(r===A){if(c)return c;if(o)return structuredClone(o)}r=A;let P=(async()=>{let F=w.previewAttach,g=F.response.parse(await a.request(F.path,C));if(g.quote.currency!==i.commerce.currency||g.quote.provider!==i.commerce.provider||g.quote.lines.length!==1||g.quote.lines[0].productVersionId!==m)throw new s("INVALID_RESPONSE","The purchase quote changed its selected Product or presentment");return o=g.quote,u=null,structuredClone(o)})();c=P;try{return await P}finally{c===P&&(c=null)}},confirm:()=>d("confirm"),cancel:()=>d("cancel"),read:()=>d("read"),destroy(){a.reset(),e=null,o=null,u=null,r=null}};return await p(),y}function L(n){let t=null,a=null,i=0,e={attributes:v.parse(n.attributes??{}),onFeatureUsage:n.onFeatureUsage?(r,c)=>n.onFeatureUsage(r,structuredClone(c)):void 0,onExperimentViewed:n.onExperimentViewed?(r,c)=>n.onExperimentViewed(structuredClone(r),structuredClone(c)):void 0,stickyBucketAssignmentDocs:structuredClone(n.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:n.saveStickyBucketAssignmentDoc?r=>n.saveStickyBucketAssignmentDoc(structuredClone(r)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},o=r=>{if(!t)throw new Error("Initialize the Feature client before evaluation");if(t.expiresAt&&Date.parse(t.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return structuredClone(h(r,e))};async function u(){if(a)return a;let r=i,c=(async()=>{let p=V.parse(await n.load());if(p.scope.projectId!==n.scope.projectId||p.scope.environment!==n.scope.environment)throw new Error("Feature payload scope changed");if(r!==i)throw new Error("Feature client was reset");return t=structuredClone(p),e.features=t.features,e.savedGroups=I(t.savedGroups),e.trackedFeatureUsage={},structuredClone(t)})();a=c;try{return await c}finally{a===c&&(a=null)}}return{init:u,refresh:u,get generation(){return t?.generation??null},setAttributes(r){e.attributes=v.parse(r)},evalFeature:o,getFeatureValue(r,c){let p=o(r).value;return p===null?structuredClone(c):structuredClone(p)},reset(){i++,a=null,t=null,e.features={},e.savedGroups={},e.stickyBucketAssignmentDocs={},e.attributes={},e.trackedFeatureUsage={},e.trackedExperiments?.clear()}}}function Q(n,t,a){let i=N.parse(n);if(i.evaluationMode!=="local")throw new s("EVALUATION_MODE","Remote nodes are evaluated by Grow");if(i.expiresAt&&Date.parse(i.expiresAt)<=Date.now())throw new s("CONFIGURATION_EXPIRED","Refresh local rules at the scheduled transition");let e=i.topology.nodes.find(d=>d.id===t);if(!e)throw new s("NOT_FOUND","Funnel node is unavailable");let o=v.parse(a.attributes??{}),u={attributes:o,saveStickyBucketAssignmentDoc:a.saveStickyBucketAssignmentDoc?d=>a.saveStickyBucketAssignmentDoc(structuredClone(d)):void 0,onFeatureUsage:a.onFeatureUsage?(d,y)=>a.onFeatureUsage(d,structuredClone(y)):void 0,onExperimentViewed:a.onExperimentViewed?(d,y)=>a.onExperimentViewed(structuredClone(d),structuredClone(y)):void 0,features:structuredClone(i.growth.features),savedGroups:I(i.growth.savedGroups),stickyBucketAssignmentDocs:structuredClone(a.stickyBucketAssignmentDocs)},r,c;if(e.type==="condition"){let d=i.conditions[e.id];if(!d)throw new s("INVALID_RESPONSE","Local condition rules are unavailable");r=d.find(y=>x(o,y.condition,u.savedGroups))?.port??"default"}else if(e.type==="feature"){if(!e.resources.featureKey)throw new s("INVALID_RESPONSE","Feature reference is unavailable");c=h(e.resources.featureKey,u).value,r="next"}else if(e.type==="split"){let d=e.resources.experimentId,y=d?i.growth.experiments[d]:null;if(!y||!d)throw new s("INVALID_RESPONSE","Experiment reference is unavailable");let l=k(y,u);c=l.value,r=l.inExperiment&&!l.passthrough&&typeof l.value=="string"?l.value:"notParticipating"}else throw new s("SERVER_REQUIRED","This node is driven by the authoritative Funnel runtime");let p=e.outputs[r];if(!p)throw new s("INVALID_RESPONSE","Evaluated node exit is unavailable");return{nodeId:t,port:r,target:p,...c===void 0?{}:{value:c}}}function K(n,t){return t.type==="id"?n.customerId===t.value:n.externalUserId===t.value}function S(n,t){if(n===t)return!0;if(Array.isArray(n)||Array.isArray(t))return Array.isArray(n)&&Array.isArray(t)&&n.length===t.length&&n.every((e,o)=>S(e,t[o]));if(!n||!t||typeof n!="object"||typeof t!="object")return!1;let a=Object.entries(n),i=Object.entries(t);return a.length===i.length&&a.every(([e,o])=>Object.hasOwn(t,e)&&S(o,Reflect.get(t,e)))}function X(n){let t=/^gg_ct_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey);if(typeof window<"u"&&!t)throw new s("SERVER_ONLY","Funnel starts are issued by your backend");if(!t&&!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A customer credential or server API key is required");let a=E({...n,timeoutMs:n.timeoutMs??35e3});return a.identify(n.apiKey),{async start(i){let e=O.safeParse({...i,operation:"start"});if(!e.success||e.data.operation!=="start"||(t?e.data.customer!==void 0:e.data.customer===void 0))throw new s("INVALID_REQUEST","Invalid current Funnel start");let o=e.data,u=D.safeParse(await a.request("funnels",o));if(!u.success||!u.data.runToken)throw new s("INVALID_RESPONSE","Funnel start credentials are missing");let r=u.data;if(r.run.source.id!==o.funnelId||r.run.locale!==(o.locale??"en")||!S(r.run.parameters,o.parameters??{})||(o.customer?!r.customerId||o.customer.type==="id"&&r.customerId!==o.customer.value:r.customerId!==void 0))throw new s("INVALID_RESPONSE","Funnel start contract changed");return{...r,runToken:r.runToken}}}}export{K as a,S as b,q as c,L as d,Q as e,X as f};