@stewardhq/sdk 0.3.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +332 -273
  3. package/dist/_chunks/errors.js +1 -1
  4. package/dist/_chunks/events.d.ts +386 -78
  5. package/dist/_chunks/events.js +1035 -19
  6. package/dist/_chunks/index.d.ts +3752 -305
  7. package/dist/_chunks/locale.d.ts +270 -2
  8. package/dist/_chunks/src.js +925 -31
  9. package/dist/_chunks/validators.d.ts +46 -2
  10. package/dist/_chunks/validators.js +128 -27
  11. package/dist/_chunks/webhook-core.d.ts +2 -2
  12. package/dist/contract.d.ts +4 -4
  13. package/dist/contract.js +4 -4
  14. package/dist/index.d.ts +447 -33
  15. package/dist/index.js +1659 -26
  16. package/dist/server.d.ts +66 -16
  17. package/dist/server.js +35 -4
  18. package/package.json +14 -13
  19. package/dist/_chunks/steward.d.ts +0 -189
  20. package/dist/_chunks/steward.js +0 -564
  21. package/dist/testing/fixtures/events/LOCK.json +0 -27
  22. package/dist/testing/fixtures/events/account.deleted.json +0 -36
  23. package/dist/testing/fixtures/events/account.state_changed.json +0 -53
  24. package/dist/testing/fixtures/events/account.updated.json +0 -37
  25. package/dist/testing/fixtures/events/checkout.completed.json +0 -36
  26. package/dist/testing/fixtures/events/checkout.expired.json +0 -26
  27. package/dist/testing/fixtures/events/checkout.failed.json +0 -27
  28. package/dist/testing/fixtures/events/invoice.created.json +0 -37
  29. package/dist/testing/fixtures/events/invoice.issued.json +0 -38
  30. package/dist/testing/fixtures/events/invoice.voided.json +0 -39
  31. package/dist/testing/fixtures/events/subscription.activated.json +0 -40
  32. package/dist/testing/fixtures/events/subscription.cancel_scheduled.json +0 -38
  33. package/dist/testing/fixtures/events/subscription.canceled.json +0 -29
  34. package/dist/testing/fixtures/events/subscription.expired.json +0 -27
  35. package/dist/testing/fixtures/events/subscription.payment_failed.json +0 -38
  36. package/dist/testing/fixtures/events/subscription.reactivated.json +0 -36
  37. package/dist/testing/fixtures/events/subscription.renewed.json +0 -39
  38. package/dist/testing/fixtures/events/subscription.suspended.json +0 -36
  39. package/dist/testing/fixtures/events/subscription.terminated.json +0 -28
  40. package/dist/testing.d.ts +0 -656
  41. package/dist/testing.js +0 -3684
@@ -1,27 +1,27 @@
1
1
  import { z } from "zod";
2
2
  //#region ../contract/src/accounts.d.ts
3
3
  declare const AccountLocaleSchema: z.ZodEnum<{
4
- tr: "tr";
5
4
  en: "en";
5
+ tr: "tr";
6
6
  }>;
7
7
  declare const AccountUpsertInputSchema: z.ZodObject<{
8
8
  displayName: z.ZodString;
9
9
  metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
10
10
  notificationEmails: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEmail>, z.ZodTransform<string[], string[]>>>;
11
11
  locale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
12
- tr: "tr";
13
12
  en: "en";
13
+ tr: "tr";
14
14
  }>>>;
15
15
  }, z.core.$strip>;
16
16
  type AccountUpsertInput = z.input<typeof AccountUpsertInputSchema>;
17
17
  declare const BillingProfileKindSchema: z.ZodEnum<{
18
- individual: "individual";
19
18
  company: "company";
19
+ individual: "individual";
20
20
  }>;
21
21
  declare const BillingProfileSchema: z.ZodObject<{
22
22
  kind: z.ZodEnum<{
23
- individual: "individual";
24
23
  company: "company";
24
+ individual: "individual";
25
25
  }>;
26
26
  contactName: z.ZodString;
27
27
  companyName: z.ZodOptional<z.ZodString>;
@@ -42,10 +42,10 @@ declare const AccessStateSchema: z.ZodEnum<{
42
42
  type AccessState = z.infer<typeof AccessStateSchema>;
43
43
  declare const SubscriptionStatusSchema: z.ZodEnum<{
44
44
  active: "active";
45
- suspended: "suspended";
46
- past_due: "past_due";
47
45
  canceled: "canceled";
48
46
  expired: "expired";
47
+ past_due: "past_due";
48
+ suspended: "suspended";
49
49
  }>;
50
50
  type SubscriptionStatus = z.infer<typeof SubscriptionStatusSchema>;
51
51
  /** Snapshot içindeki canlı abonelik özeti (yoksa null). */
@@ -53,10 +53,10 @@ declare const SubscriptionSummarySchema: z.ZodObject<{
53
53
  id: z.ZodUUID;
54
54
  status: z.ZodEnum<{
55
55
  active: "active";
56
- suspended: "suspended";
57
- past_due: "past_due";
58
56
  canceled: "canceled";
59
57
  expired: "expired";
58
+ past_due: "past_due";
59
+ suspended: "suspended";
60
60
  }>;
61
61
  planCode: z.ZodString;
62
62
  interval: z.ZodEnum<{
@@ -81,10 +81,10 @@ declare const EntitlementSnapshotSchema: z.ZodObject<{
81
81
  id: z.ZodUUID;
82
82
  status: z.ZodEnum<{
83
83
  active: "active";
84
- suspended: "suspended";
85
- past_due: "past_due";
86
84
  canceled: "canceled";
87
85
  expired: "expired";
86
+ past_due: "past_due";
87
+ suspended: "suspended";
88
88
  }>;
89
89
  planCode: z.ZodString;
90
90
  interval: z.ZodEnum<{
@@ -104,7 +104,10 @@ declare const AccountDunningStateSchema: z.ZodObject<{
104
104
  nextActionAt: z.ZodNullable<z.ZodISODateTime>;
105
105
  }, z.core.$strip>;
106
106
  type AccountDunningState = z.infer<typeof AccountDunningStateSchema>;
107
- /** Dönem sonunda uygulanacak plan değişikliği. F4b'ye kadar her zaman null. */
107
+ /**
108
+ * Change applied at the period end (`POST /v1/subscriptions/:id/change`, MF9). Null until then.
109
+ * `price: "current"` on the same plan shows the same `planCode`/`interval` with the new `amountMinor`.
110
+ */
108
111
  declare const AccountScheduledChangeSchema: z.ZodObject<{
109
112
  planCode: z.ZodString;
110
113
  interval: z.ZodEnum<{
@@ -112,16 +115,17 @@ declare const AccountScheduledChangeSchema: z.ZodObject<{
112
115
  year: "year";
113
116
  }>;
114
117
  effectiveAt: z.ZodISODateTime;
118
+ amountMinor: z.ZodOptional<z.ZodNumber>;
115
119
  }, z.core.$strip>;
116
120
  type AccountScheduledChange = z.infer<typeof AccountScheduledChangeSchema>;
117
121
  declare const AccountSubscriptionStateSchema: z.ZodObject<{
118
122
  id: z.ZodUUID;
119
123
  status: z.ZodEnum<{
120
124
  active: "active";
121
- suspended: "suspended";
122
- past_due: "past_due";
123
125
  canceled: "canceled";
124
126
  expired: "expired";
127
+ past_due: "past_due";
128
+ suspended: "suspended";
125
129
  }>;
126
130
  planCode: z.ZodString;
127
131
  interval: z.ZodEnum<{
@@ -146,6 +150,7 @@ declare const AccountSubscriptionStateSchema: z.ZodObject<{
146
150
  year: "year";
147
151
  }>;
148
152
  effectiveAt: z.ZodISODateTime;
153
+ amountMinor: z.ZodOptional<z.ZodNumber>;
149
154
  }, z.core.$strip>>;
150
155
  }, z.core.$strip>;
151
156
  type AccountSubscriptionState = z.infer<typeof AccountSubscriptionStateSchema>;
@@ -161,14 +166,64 @@ declare const AccountOpenCheckoutSchema: z.ZodObject<{
161
166
  currency: z.ZodString;
162
167
  amountMinor: z.ZodNumber;
163
168
  expiresAt: z.ZodISODateTime;
169
+ paymentMethod: z.ZodOptional<z.ZodEnum<{
170
+ bank_transfer: "bank_transfer";
171
+ card: "card";
172
+ }>>;
164
173
  }, z.core.$strip>;
165
174
  type AccountOpenCheckout = z.infer<typeof AccountOpenCheckoutSchema>;
175
+ /**
176
+ * An unpaid invoice of the account (billing core, M22/M34): renewal or final invoices written
177
+ * before payment. Account level (not under a subscription) so the final invoice of an ended
178
+ * subscription stays visible; the product can show a banner before `dueAt`.
179
+ */
180
+ declare const AccountOpenInvoiceSchema: z.ZodObject<{
181
+ id: z.ZodUUID;
182
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
183
+ billingReason: z.ZodEnum<{
184
+ manual: "manual";
185
+ purchase: "purchase";
186
+ subscription_create: "subscription_create";
187
+ subscription_cycle: "subscription_cycle";
188
+ subscription_update: "subscription_update";
189
+ }>;
190
+ totalMinor: z.ZodNumber;
191
+ currency: z.ZodString;
192
+ dueAt: z.ZodISODateTime;
193
+ }, z.core.$strip>;
194
+ type AccountOpenInvoice = z.infer<typeof AccountOpenInvoiceSchema>;
195
+ /**
196
+ * Low-churn meter facts of the account state (metering, M13; Polar `active_meters`, coarse). One
197
+ * entry per catalog meter. Balances and period bounds are NOT here (they change with every event;
198
+ * read them with `GET /v1/accounts/:ref/meters`): this block changes when the plan changes, a
199
+ * threshold is crossed or a new period resets the standing — never per event.
200
+ */
201
+ declare const AccountMeterStateSchema: z.ZodObject<{
202
+ includedUnits: z.ZodNullable<z.ZodNumber>;
203
+ billable: z.ZodBoolean;
204
+ standing: z.ZodEnum<{
205
+ exhausted: "exhausted";
206
+ low: "low";
207
+ ok: "ok";
208
+ }>;
209
+ }, z.core.$strip>;
210
+ type AccountMeterState = z.infer<typeof AccountMeterStateSchema>;
211
+ declare const AccountMetersStateSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
212
+ includedUnits: z.ZodNullable<z.ZodNumber>;
213
+ billable: z.ZodBoolean;
214
+ standing: z.ZodEnum<{
215
+ exhausted: "exhausted";
216
+ low: "low";
217
+ ok: "ok";
218
+ }>;
219
+ }, z.core.$strip>>;
220
+ type AccountMetersState = z.infer<typeof AccountMetersStateSchema>;
166
221
  /** Fatura profili özeti: yalnızca var mı ve türü (alanlar PII, burada yok). */
167
222
  declare const AccountProfileStateSchema: z.ZodObject<{
168
223
  present: z.ZodBoolean;
169
224
  kind: z.ZodNullable<z.ZodEnum<{
170
- individual: "individual";
171
225
  company: "company";
226
+ individual: "individual";
172
227
  }>>;
173
228
  }, z.core.$strip>;
174
229
  type AccountProfileState = z.infer<typeof AccountProfileStateSchema>;
@@ -188,10 +243,10 @@ declare const AccountStateSchema: z.ZodObject<{
188
243
  id: z.ZodUUID;
189
244
  status: z.ZodEnum<{
190
245
  active: "active";
191
- suspended: "suspended";
192
- past_due: "past_due";
193
246
  canceled: "canceled";
194
247
  expired: "expired";
248
+ past_due: "past_due";
249
+ suspended: "suspended";
195
250
  }>;
196
251
  planCode: z.ZodString;
197
252
  interval: z.ZodEnum<{
@@ -216,6 +271,7 @@ declare const AccountStateSchema: z.ZodObject<{
216
271
  year: "year";
217
272
  }>;
218
273
  effectiveAt: z.ZodISODateTime;
274
+ amountMinor: z.ZodOptional<z.ZodNumber>;
219
275
  }, z.core.$strip>>;
220
276
  }, z.core.$strip>>;
221
277
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -229,14 +285,84 @@ declare const AccountStateSchema: z.ZodObject<{
229
285
  currency: z.ZodString;
230
286
  amountMinor: z.ZodNumber;
231
287
  expiresAt: z.ZodISODateTime;
288
+ paymentMethod: z.ZodOptional<z.ZodEnum<{
289
+ bank_transfer: "bank_transfer";
290
+ card: "card";
291
+ }>>;
232
292
  }, z.core.$strip>>;
233
293
  profile: z.ZodObject<{
234
294
  present: z.ZodBoolean;
235
295
  kind: z.ZodNullable<z.ZodEnum<{
236
- individual: "individual";
237
296
  company: "company";
297
+ individual: "individual";
238
298
  }>>;
239
299
  }, z.core.$strip>;
300
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
301
+ id: z.ZodUUID;
302
+ status: z.ZodEnum<{
303
+ active: "active";
304
+ canceled: "canceled";
305
+ expired: "expired";
306
+ past_due: "past_due";
307
+ suspended: "suspended";
308
+ }>;
309
+ planCode: z.ZodString;
310
+ interval: z.ZodEnum<{
311
+ month: "month";
312
+ year: "year";
313
+ }>;
314
+ amountMinor: z.ZodNumber;
315
+ currency: z.ZodString;
316
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
317
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
318
+ cancelAtPeriodEnd: z.ZodBoolean;
319
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
320
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
321
+ dunning: z.ZodNullable<z.ZodObject<{
322
+ step: z.ZodNumber;
323
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
324
+ }, z.core.$strip>>;
325
+ scheduledChange: z.ZodNullable<z.ZodObject<{
326
+ planCode: z.ZodString;
327
+ interval: z.ZodEnum<{
328
+ month: "month";
329
+ year: "year";
330
+ }>;
331
+ effectiveAt: z.ZodISODateTime;
332
+ amountMinor: z.ZodOptional<z.ZodNumber>;
333
+ }, z.core.$strip>>;
334
+ }, z.core.$strip>>>;
335
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
336
+ id: z.ZodUUID;
337
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
338
+ billingReason: z.ZodEnum<{
339
+ manual: "manual";
340
+ purchase: "purchase";
341
+ subscription_create: "subscription_create";
342
+ subscription_cycle: "subscription_cycle";
343
+ subscription_update: "subscription_update";
344
+ }>;
345
+ totalMinor: z.ZodNumber;
346
+ currency: z.ZodString;
347
+ dueAt: z.ZodISODateTime;
348
+ }, z.core.$strip>>>;
349
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
350
+ code: z.ZodNullable<z.ZodString>;
351
+ type: z.ZodString;
352
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
353
+ source: z.ZodString;
354
+ grantedAt: z.ZodISODateTime;
355
+ }, z.core.$strip>>>;
356
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
357
+ includedUnits: z.ZodNullable<z.ZodNumber>;
358
+ billable: z.ZodBoolean;
359
+ standing: z.ZodEnum<{
360
+ exhausted: "exhausted";
361
+ low: "low";
362
+ ok: "ok";
363
+ }>;
364
+ }, z.core.$strip>>>;
365
+ bankTransferCode: z.ZodOptional<z.ZodString>;
240
366
  }, z.core.$strip>;
241
367
  type AccountState = z.infer<typeof AccountStateSchema>;
242
368
  declare const AccountSchema: z.ZodObject<{
@@ -256,10 +382,10 @@ declare const AccountSchema: z.ZodObject<{
256
382
  id: z.ZodUUID;
257
383
  status: z.ZodEnum<{
258
384
  active: "active";
259
- suspended: "suspended";
260
- past_due: "past_due";
261
385
  canceled: "canceled";
262
386
  expired: "expired";
387
+ past_due: "past_due";
388
+ suspended: "suspended";
263
389
  }>;
264
390
  planCode: z.ZodString;
265
391
  interval: z.ZodEnum<{
@@ -274,8 +400,8 @@ declare const AccountSchema: z.ZodObject<{
274
400
  }, z.core.$strip>;
275
401
  notificationEmails: z.ZodDefault<z.ZodArray<z.ZodString>>;
276
402
  locale: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
277
- tr: "tr";
278
403
  en: "en";
404
+ tr: "tr";
279
405
  }>>>;
280
406
  }, z.core.$strip>;
281
407
  type Account = z.infer<typeof AccountSchema>;
@@ -284,28 +410,29 @@ declare const AccountDeleteResponseSchema: z.ZodObject<{
284
410
  deletedAt: z.ZodISODateTime;
285
411
  }, z.core.$strip>;
286
412
  type AccountDeleteResponse = z.infer<typeof AccountDeleteResponseSchema>;
287
- declare const ACCOUNT_INCLUDES: readonly ["profile", "subscriptions", "checkouts", "payments", "invoices", "grants"];
413
+ declare const ACCOUNT_INCLUDES: readonly ['profile', 'subscriptions', 'checkouts', 'payments', 'invoices', 'grants'];
288
414
  type AccountInclude = (typeof ACCOUNT_INCLUDES)[number];
289
415
  //#endregion
290
416
  //#region ../contract/src/events.d.ts
291
417
  declare const EventIdSchema: z.ZodString;
292
418
  declare const ApiVersionSchema: z.ZodString;
293
419
  declare const EVENT_DETAIL_SCHEMAS: {
294
- readonly "account.updated": z.ZodObject<{
420
+ readonly 'account.updated': z.ZodObject<{
295
421
  changed: z.ZodArray<z.ZodString>;
296
422
  }, z.core.$strip>;
297
- readonly "checkout.completed": z.ZodObject<{
423
+ readonly 'checkout.completed': z.ZodObject<{
298
424
  subscriptionId: z.ZodUUID;
299
425
  checkoutSessionId: z.ZodUUID;
300
426
  }, z.core.$strip>;
301
- readonly "checkout.failed": z.ZodObject<{
427
+ readonly 'checkout.failed': z.ZodObject<{
302
428
  checkoutSessionId: z.ZodUUID;
303
429
  reason: z.ZodString;
304
430
  }, z.core.$strip>;
305
- readonly "checkout.expired": z.ZodObject<{
431
+ readonly 'checkout.expired': z.ZodObject<{
306
432
  checkoutSessionId: z.ZodUUID;
307
433
  }, z.core.$strip>;
308
- readonly "subscription.activated": z.ZodObject<{
434
+ readonly 'subscription.activated': z.ZodObject<{
435
+ subscriptionId: z.ZodUUID;
309
436
  planCode: z.ZodString;
310
437
  interval: z.ZodEnum<{
311
438
  month: "month";
@@ -314,78 +441,167 @@ declare const EVENT_DETAIL_SCHEMAS: {
314
441
  amountMinor: z.ZodNumber;
315
442
  currency: z.ZodString;
316
443
  actorRef: z.ZodNullable<z.ZodString>;
317
- subscriptionId: z.ZodUUID;
444
+ replacedSubscriptionId: z.ZodOptional<z.ZodUUID>;
318
445
  }, z.core.$strip>;
319
- readonly "subscription.renewed": z.ZodObject<{
446
+ readonly 'subscription.renewed': z.ZodObject<{
447
+ subscriptionId: z.ZodUUID;
320
448
  paymentId: z.ZodUUID;
321
449
  periodStart: z.ZodNullable<z.ZodISODateTime>;
322
450
  periodEnd: z.ZodNullable<z.ZodISODateTime>;
323
451
  invoiceId: z.ZodNullable<z.ZodUUID>;
324
- subscriptionId: z.ZodUUID;
325
452
  }, z.core.$strip>;
326
- readonly "subscription.payment_failed": z.ZodObject<{
453
+ readonly 'subscription.payment_failed': z.ZodObject<{
454
+ subscriptionId: z.ZodUUID;
327
455
  paymentId: z.ZodNullable<z.ZodUUID>;
328
456
  attempt: z.ZodNumber;
329
457
  nextRetryAt: z.ZodNullable<z.ZodISODateTime>;
330
- subscriptionId: z.ZodUUID;
458
+ invoiceId: z.ZodOptional<z.ZodUUID>;
331
459
  }, z.core.$strip>;
332
- readonly "subscription.suspended": z.ZodObject<{
333
- dunningDay: z.ZodNumber;
460
+ readonly 'subscription.suspended': z.ZodObject<{
334
461
  subscriptionId: z.ZodUUID;
462
+ dunningDay: z.ZodNumber;
335
463
  }, z.core.$strip>;
336
- readonly "subscription.reactivated": z.ZodObject<{
337
- paymentId: z.ZodNullable<z.ZodUUID>;
464
+ readonly 'subscription.reactivated': z.ZodObject<{
338
465
  subscriptionId: z.ZodUUID;
466
+ paymentId: z.ZodNullable<z.ZodUUID>;
339
467
  }, z.core.$strip>;
340
- readonly "subscription.cancel_scheduled": z.ZodObject<{
468
+ readonly 'subscription.cancel_scheduled': z.ZodObject<{
469
+ subscriptionId: z.ZodUUID;
341
470
  cancelAt: z.ZodISODateTime;
342
471
  reason: z.ZodString;
343
472
  actorRef: z.ZodNullable<z.ZodString>;
344
- subscriptionId: z.ZodUUID;
345
473
  }, z.core.$strip>;
346
- readonly "subscription.canceled": z.ZodObject<{
474
+ readonly 'subscription.canceled': z.ZodObject<{
475
+ subscriptionId: z.ZodUUID;
347
476
  reason: z.ZodString;
348
477
  effectiveAt: z.ZodISODateTime;
349
478
  actorRef: z.ZodNullable<z.ZodString>;
350
- subscriptionId: z.ZodUUID;
351
479
  }, z.core.$strip>;
352
- readonly "subscription.expired": z.ZodObject<{
353
- effectiveAt: z.ZodISODateTime;
480
+ readonly 'subscription.expired': z.ZodObject<{
354
481
  subscriptionId: z.ZodUUID;
482
+ effectiveAt: z.ZodISODateTime;
355
483
  }, z.core.$strip>;
356
- readonly "subscription.terminated": z.ZodObject<{
484
+ readonly 'subscription.terminated': z.ZodObject<{
485
+ subscriptionId: z.ZodUUID;
357
486
  reason: z.ZodEnum<{
358
487
  nonpayment: "nonpayment";
359
488
  }>;
360
489
  dunningDay: z.ZodNumber;
361
- subscriptionId: z.ZodUUID;
362
490
  }, z.core.$strip>;
363
- readonly "invoice.created": z.ZodObject<{
491
+ readonly 'invoice.created': z.ZodObject<{
364
492
  invoiceId: z.ZodUUID;
365
493
  totalMinor: z.ZodNumber;
366
494
  currency: z.ZodString;
367
495
  }, z.core.$strip>;
368
- readonly "invoice.issued": z.ZodObject<{
496
+ readonly 'invoice.issued': z.ZodObject<{
369
497
  invoiceId: z.ZodUUID;
370
498
  number: z.ZodString;
371
499
  totalMinor: z.ZodNumber;
372
500
  currency: z.ZodString;
373
501
  }, z.core.$strip>;
374
- readonly "invoice.voided": z.ZodObject<{
502
+ readonly 'invoice.voided': z.ZodObject<{
375
503
  invoiceId: z.ZodUUID;
376
504
  number: z.ZodNullable<z.ZodString>;
377
505
  totalMinor: z.ZodNumber;
378
506
  currency: z.ZodString;
379
507
  reason: z.ZodString;
380
508
  }, z.core.$strip>;
381
- readonly "account.state_changed": z.ZodObject<{
509
+ readonly 'account.state_changed': z.ZodObject<{
382
510
  cause: z.ZodString;
383
511
  causeEventId: z.ZodNullable<z.ZodString>;
384
512
  }, z.core.$strip>;
385
- readonly "account.deleted": z.ZodObject<{
513
+ readonly 'account.deleted': z.ZodObject<{
386
514
  deletedAt: z.ZodISODateTime;
387
515
  actorRef: z.ZodNullable<z.ZodString>;
388
516
  }, z.core.$strip>;
517
+ readonly 'invoice.paid': z.ZodObject<{
518
+ invoiceId: z.ZodUUID;
519
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
520
+ paymentId: z.ZodUUID;
521
+ billingReason: z.ZodNullable<z.ZodEnum<{
522
+ manual: "manual";
523
+ purchase: "purchase";
524
+ subscription_create: "subscription_create";
525
+ subscription_cycle: "subscription_cycle";
526
+ subscription_update: "subscription_update";
527
+ }>>;
528
+ totalMinor: z.ZodNumber;
529
+ currency: z.ZodString;
530
+ paidAt: z.ZodISODateTime;
531
+ }, z.core.$strip>;
532
+ readonly 'benefit_grant.created': z.ZodObject<{
533
+ grantId: z.ZodUUID;
534
+ benefit: z.ZodObject<{
535
+ code: z.ZodNullable<z.ZodString>;
536
+ type: z.ZodString;
537
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
538
+ source: z.ZodString;
539
+ grantedAt: z.ZodISODateTime;
540
+ }, z.core.$strip>;
541
+ }, z.core.$strip>;
542
+ readonly 'benefit_grant.updated': z.ZodObject<{
543
+ grantId: z.ZodUUID;
544
+ benefit: z.ZodObject<{
545
+ code: z.ZodNullable<z.ZodString>;
546
+ type: z.ZodString;
547
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
548
+ source: z.ZodString;
549
+ grantedAt: z.ZodISODateTime;
550
+ }, z.core.$strip>;
551
+ previousProperties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
552
+ }, z.core.$strip>;
553
+ readonly 'benefit_grant.revoked': z.ZodObject<{
554
+ grantId: z.ZodUUID;
555
+ benefit: z.ZodObject<{
556
+ code: z.ZodNullable<z.ZodString>;
557
+ type: z.ZodString;
558
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
559
+ source: z.ZodString;
560
+ grantedAt: z.ZodISODateTime;
561
+ }, z.core.$strip>;
562
+ revokedAt: z.ZodISODateTime;
563
+ }, z.core.$strip>;
564
+ readonly 'benefit_grant.cycled': z.ZodObject<{
565
+ grantId: z.ZodUUID;
566
+ benefit: z.ZodObject<{
567
+ code: z.ZodNullable<z.ZodString>;
568
+ type: z.ZodString;
569
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
570
+ source: z.ZodString;
571
+ grantedAt: z.ZodISODateTime;
572
+ }, z.core.$strip>;
573
+ periodStart: z.ZodISODateTime;
574
+ periodEnd: z.ZodISODateTime;
575
+ }, z.core.$strip>;
576
+ readonly 'meter.threshold_crossed': z.ZodObject<{
577
+ meter: z.ZodString;
578
+ standing: z.ZodEnum<{
579
+ exhausted: "exhausted";
580
+ low: "low";
581
+ ok: "ok";
582
+ }>;
583
+ previous: z.ZodEnum<{
584
+ exhausted: "exhausted";
585
+ low: "low";
586
+ ok: "ok";
587
+ }>;
588
+ periodStart: z.ZodISODateTime;
589
+ periodEnd: z.ZodISODateTime;
590
+ consumedUnits: z.ZodNumber;
591
+ creditedUnits: z.ZodNumber;
592
+ }, z.core.$strip>;
593
+ readonly 'meter.period_closed': z.ZodObject<{
594
+ periodStart: z.ZodISODateTime;
595
+ periodEnd: z.ZodISODateTime;
596
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
597
+ meters: z.ZodArray<z.ZodObject<{
598
+ meter: z.ZodString;
599
+ consumedUnits: z.ZodNumber;
600
+ creditedUnits: z.ZodNumber;
601
+ overageUnits: z.ZodNumber;
602
+ }, z.core.$strip>>;
603
+ meterChargeId: z.ZodNullable<z.ZodUUID>;
604
+ }, z.core.$strip>;
389
605
  };
390
606
  type EventType = keyof typeof EVENT_DETAIL_SCHEMAS;
391
607
  /** Tüm event tipleri (yenileri dahil). */
@@ -397,9 +613,11 @@ declare const EVENT_TYPES: EventType[];
397
613
  declare const LEGACY_EVENT_TYPES: readonly ["account.updated", "checkout.completed", "checkout.failed", "checkout.expired", "subscription.activated", "subscription.renewed", "subscription.payment_failed", "subscription.suspended", "subscription.reactivated", "subscription.cancel_scheduled", "subscription.canceled", "subscription.expired", "subscription.terminated", "invoice.created", "invoice.issued"];
398
614
  type LegacyEventType = (typeof LEGACY_EVENT_TYPES)[number];
399
615
  /** `account.state_changed.detail.cause` — bilinen değerler; küme açık. */
400
- type AccountStateChangeCause = LegacyEventType | "account.upserted" | "billing_profile.updated" | "checkout.opened" | "checkout.initialize_failed" | "checkout.canceled" | "grant.created" | "grant.revoked" | "grant.window_applied" | "dunning.advanced" | "dunning_policy.updated" | "payment.recorded" | "catalog.synced" | "account.refreshed" | "grant.plan_set" | "resync" | "account.deleted" | (string & Record<never, never>);
401
- type FullStateEventType = "account.state_changed" | "account.deleted";
616
+ type AccountStateChangeCause = LegacyEventType | 'account.upserted' | 'billing_profile.updated' | 'checkout.opened' | 'checkout.initialize_failed' | 'checkout.canceled' | 'grant.created' | 'grant.revoked' | 'grant.window_applied' | 'dunning.advanced' | 'dunning_policy.updated' | 'payment.recorded' | 'catalog.synced' | 'account.refreshed' | 'grant.plan_set' | 'resync' | 'account.deleted' | 'invoice.paid' | 'subscription.period_advanced' | 'subscription.uncanceled' | 'subscription.change_scheduled' | 'invoice.waived' | 'invoice.payment_reminder' | 'meter.threshold_crossed' | 'meter.period_rolled' | 'credits.granted' | 'bank_transfer.code_assigned' | (string & Record<never, never>);
617
+ type FullStateEventType = 'account.state_changed' | 'account.deleted' | 'invoice.paid' | 'benefit_grant.created' | 'benefit_grant.updated' | 'benefit_grant.revoked' | 'benefit_grant.cycled' | 'meter.threshold_crossed' | 'meter.period_closed';
402
618
  type AccountSchemaOf<T extends EventType> = T extends FullStateEventType ? typeof AccountStateSchema : typeof EntitlementSnapshotSchema;
619
+ /** Event types whose `data.account` is the full `AccountState` (the others: the entitlement snapshot). */
620
+ declare const FULL_STATE_EVENT_TYPES: ReadonlySet<string>;
403
621
  declare function envelope<T extends EventType>(type: T): z.ZodObject<{
404
622
  id: z.ZodString;
405
623
  type: z.ZodLiteral<T>;
@@ -410,21 +628,22 @@ declare function envelope<T extends EventType>(type: T): z.ZodObject<{
410
628
  data: z.ZodObject<{
411
629
  account: AccountSchemaOf<T>;
412
630
  detail: {
413
- readonly "account.updated": z.ZodObject<{
631
+ readonly 'account.updated': z.ZodObject<{
414
632
  changed: z.ZodArray<z.ZodString>;
415
633
  }, z.core.$strip>;
416
- readonly "checkout.completed": z.ZodObject<{
634
+ readonly 'checkout.completed': z.ZodObject<{
417
635
  subscriptionId: z.ZodUUID;
418
636
  checkoutSessionId: z.ZodUUID;
419
637
  }, z.core.$strip>;
420
- readonly "checkout.failed": z.ZodObject<{
638
+ readonly 'checkout.failed': z.ZodObject<{
421
639
  checkoutSessionId: z.ZodUUID;
422
640
  reason: z.ZodString;
423
641
  }, z.core.$strip>;
424
- readonly "checkout.expired": z.ZodObject<{
642
+ readonly 'checkout.expired': z.ZodObject<{
425
643
  checkoutSessionId: z.ZodUUID;
426
644
  }, z.core.$strip>;
427
- readonly "subscription.activated": z.ZodObject<{
645
+ readonly 'subscription.activated': z.ZodObject<{
646
+ subscriptionId: z.ZodUUID;
428
647
  planCode: z.ZodString;
429
648
  interval: z.ZodEnum<{
430
649
  month: "month";
@@ -433,78 +652,167 @@ declare function envelope<T extends EventType>(type: T): z.ZodObject<{
433
652
  amountMinor: z.ZodNumber;
434
653
  currency: z.ZodString;
435
654
  actorRef: z.ZodNullable<z.ZodString>;
436
- subscriptionId: z.ZodUUID;
655
+ replacedSubscriptionId: z.ZodOptional<z.ZodUUID>;
437
656
  }, z.core.$strip>;
438
- readonly "subscription.renewed": z.ZodObject<{
657
+ readonly 'subscription.renewed': z.ZodObject<{
658
+ subscriptionId: z.ZodUUID;
439
659
  paymentId: z.ZodUUID;
440
660
  periodStart: z.ZodNullable<z.ZodISODateTime>;
441
661
  periodEnd: z.ZodNullable<z.ZodISODateTime>;
442
662
  invoiceId: z.ZodNullable<z.ZodUUID>;
443
- subscriptionId: z.ZodUUID;
444
663
  }, z.core.$strip>;
445
- readonly "subscription.payment_failed": z.ZodObject<{
664
+ readonly 'subscription.payment_failed': z.ZodObject<{
665
+ subscriptionId: z.ZodUUID;
446
666
  paymentId: z.ZodNullable<z.ZodUUID>;
447
667
  attempt: z.ZodNumber;
448
668
  nextRetryAt: z.ZodNullable<z.ZodISODateTime>;
449
- subscriptionId: z.ZodUUID;
669
+ invoiceId: z.ZodOptional<z.ZodUUID>;
450
670
  }, z.core.$strip>;
451
- readonly "subscription.suspended": z.ZodObject<{
452
- dunningDay: z.ZodNumber;
671
+ readonly 'subscription.suspended': z.ZodObject<{
453
672
  subscriptionId: z.ZodUUID;
673
+ dunningDay: z.ZodNumber;
454
674
  }, z.core.$strip>;
455
- readonly "subscription.reactivated": z.ZodObject<{
456
- paymentId: z.ZodNullable<z.ZodUUID>;
675
+ readonly 'subscription.reactivated': z.ZodObject<{
457
676
  subscriptionId: z.ZodUUID;
677
+ paymentId: z.ZodNullable<z.ZodUUID>;
458
678
  }, z.core.$strip>;
459
- readonly "subscription.cancel_scheduled": z.ZodObject<{
679
+ readonly 'subscription.cancel_scheduled': z.ZodObject<{
680
+ subscriptionId: z.ZodUUID;
460
681
  cancelAt: z.ZodISODateTime;
461
682
  reason: z.ZodString;
462
683
  actorRef: z.ZodNullable<z.ZodString>;
463
- subscriptionId: z.ZodUUID;
464
684
  }, z.core.$strip>;
465
- readonly "subscription.canceled": z.ZodObject<{
685
+ readonly 'subscription.canceled': z.ZodObject<{
686
+ subscriptionId: z.ZodUUID;
466
687
  reason: z.ZodString;
467
688
  effectiveAt: z.ZodISODateTime;
468
689
  actorRef: z.ZodNullable<z.ZodString>;
469
- subscriptionId: z.ZodUUID;
470
690
  }, z.core.$strip>;
471
- readonly "subscription.expired": z.ZodObject<{
472
- effectiveAt: z.ZodISODateTime;
691
+ readonly 'subscription.expired': z.ZodObject<{
473
692
  subscriptionId: z.ZodUUID;
693
+ effectiveAt: z.ZodISODateTime;
474
694
  }, z.core.$strip>;
475
- readonly "subscription.terminated": z.ZodObject<{
695
+ readonly 'subscription.terminated': z.ZodObject<{
696
+ subscriptionId: z.ZodUUID;
476
697
  reason: z.ZodEnum<{
477
698
  nonpayment: "nonpayment";
478
699
  }>;
479
700
  dunningDay: z.ZodNumber;
480
- subscriptionId: z.ZodUUID;
481
701
  }, z.core.$strip>;
482
- readonly "invoice.created": z.ZodObject<{
702
+ readonly 'invoice.created': z.ZodObject<{
483
703
  invoiceId: z.ZodUUID;
484
704
  totalMinor: z.ZodNumber;
485
705
  currency: z.ZodString;
486
706
  }, z.core.$strip>;
487
- readonly "invoice.issued": z.ZodObject<{
707
+ readonly 'invoice.issued': z.ZodObject<{
488
708
  invoiceId: z.ZodUUID;
489
709
  number: z.ZodString;
490
710
  totalMinor: z.ZodNumber;
491
711
  currency: z.ZodString;
492
712
  }, z.core.$strip>;
493
- readonly "invoice.voided": z.ZodObject<{
713
+ readonly 'invoice.voided': z.ZodObject<{
494
714
  invoiceId: z.ZodUUID;
495
715
  number: z.ZodNullable<z.ZodString>;
496
716
  totalMinor: z.ZodNumber;
497
717
  currency: z.ZodString;
498
718
  reason: z.ZodString;
499
719
  }, z.core.$strip>;
500
- readonly "account.state_changed": z.ZodObject<{
720
+ readonly 'account.state_changed': z.ZodObject<{
501
721
  cause: z.ZodString;
502
722
  causeEventId: z.ZodNullable<z.ZodString>;
503
723
  }, z.core.$strip>;
504
- readonly "account.deleted": z.ZodObject<{
724
+ readonly 'account.deleted': z.ZodObject<{
505
725
  deletedAt: z.ZodISODateTime;
506
726
  actorRef: z.ZodNullable<z.ZodString>;
507
727
  }, z.core.$strip>;
728
+ readonly 'invoice.paid': z.ZodObject<{
729
+ invoiceId: z.ZodUUID;
730
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
731
+ paymentId: z.ZodUUID;
732
+ billingReason: z.ZodNullable<z.ZodEnum<{
733
+ manual: "manual";
734
+ purchase: "purchase";
735
+ subscription_create: "subscription_create";
736
+ subscription_cycle: "subscription_cycle";
737
+ subscription_update: "subscription_update";
738
+ }>>;
739
+ totalMinor: z.ZodNumber;
740
+ currency: z.ZodString;
741
+ paidAt: z.ZodISODateTime;
742
+ }, z.core.$strip>;
743
+ readonly 'benefit_grant.created': z.ZodObject<{
744
+ grantId: z.ZodUUID;
745
+ benefit: z.ZodObject<{
746
+ code: z.ZodNullable<z.ZodString>;
747
+ type: z.ZodString;
748
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
749
+ source: z.ZodString;
750
+ grantedAt: z.ZodISODateTime;
751
+ }, z.core.$strip>;
752
+ }, z.core.$strip>;
753
+ readonly 'benefit_grant.updated': z.ZodObject<{
754
+ grantId: z.ZodUUID;
755
+ benefit: z.ZodObject<{
756
+ code: z.ZodNullable<z.ZodString>;
757
+ type: z.ZodString;
758
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
759
+ source: z.ZodString;
760
+ grantedAt: z.ZodISODateTime;
761
+ }, z.core.$strip>;
762
+ previousProperties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
763
+ }, z.core.$strip>;
764
+ readonly 'benefit_grant.revoked': z.ZodObject<{
765
+ grantId: z.ZodUUID;
766
+ benefit: z.ZodObject<{
767
+ code: z.ZodNullable<z.ZodString>;
768
+ type: z.ZodString;
769
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
770
+ source: z.ZodString;
771
+ grantedAt: z.ZodISODateTime;
772
+ }, z.core.$strip>;
773
+ revokedAt: z.ZodISODateTime;
774
+ }, z.core.$strip>;
775
+ readonly 'benefit_grant.cycled': z.ZodObject<{
776
+ grantId: z.ZodUUID;
777
+ benefit: z.ZodObject<{
778
+ code: z.ZodNullable<z.ZodString>;
779
+ type: z.ZodString;
780
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
781
+ source: z.ZodString;
782
+ grantedAt: z.ZodISODateTime;
783
+ }, z.core.$strip>;
784
+ periodStart: z.ZodISODateTime;
785
+ periodEnd: z.ZodISODateTime;
786
+ }, z.core.$strip>;
787
+ readonly 'meter.threshold_crossed': z.ZodObject<{
788
+ meter: z.ZodString;
789
+ standing: z.ZodEnum<{
790
+ exhausted: "exhausted";
791
+ low: "low";
792
+ ok: "ok";
793
+ }>;
794
+ previous: z.ZodEnum<{
795
+ exhausted: "exhausted";
796
+ low: "low";
797
+ ok: "ok";
798
+ }>;
799
+ periodStart: z.ZodISODateTime;
800
+ periodEnd: z.ZodISODateTime;
801
+ consumedUnits: z.ZodNumber;
802
+ creditedUnits: z.ZodNumber;
803
+ }, z.core.$strip>;
804
+ readonly 'meter.period_closed': z.ZodObject<{
805
+ periodStart: z.ZodISODateTime;
806
+ periodEnd: z.ZodISODateTime;
807
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
808
+ meters: z.ZodArray<z.ZodObject<{
809
+ meter: z.ZodString;
810
+ consumedUnits: z.ZodNumber;
811
+ creditedUnits: z.ZodNumber;
812
+ overageUnits: z.ZodNumber;
813
+ }, z.core.$strip>>;
814
+ meterChargeId: z.ZodNullable<z.ZodUUID>;
815
+ }, z.core.$strip>;
508
816
  }[T];
509
817
  }, z.core.$strip>;
510
818
  }, z.core.$strip>;
@@ -548,4 +856,4 @@ declare const PingSchema: z.ZodObject<{
548
856
  }, z.core.$strip>;
549
857
  type Ping = z.infer<typeof PingSchema>;
550
858
  //#endregion
551
- export { AccountOpenCheckoutSchema as A, AccountUpsertInput as B, AccountDeleteResponse as C, AccountInclude as D, AccountDunningStateSchema as E, AccountSchema as F, BillingProfileSchema as G, BillingProfile as H, AccountState as I, SubscriptionStatus as J, EntitlementSnapshot as K, AccountStateSchema as L, AccountProfileStateSchema as M, AccountScheduledChange as N, AccountLocaleSchema as O, AccountScheduledChangeSchema as P, AccountSubscriptionState as R, Account as S, AccountDunningState as T, BillingProfileInput as U, AccountUpsertInputSchema as V, BillingProfileKindSchema as W, SubscriptionSummary as X, SubscriptionStatusSchema as Y, SubscriptionSummarySchema as Z, PingSchema as _, BillingEvent as a, AccessState as b, EVENT_DETAIL_SCHEMAS as c, EventIdSchema as d, EventType as f, Ping as g, PING_EVENT_TYPE as h, ApiVersionSchema as i, AccountProfileState as j, AccountOpenCheckout as k, EVENT_TYPES as l, LegacyEventType as m, AnyBillingEvent as n, BillingEventOf as o, LEGACY_EVENT_TYPES as p, EntitlementSnapshotSchema as q, AnyBillingEventSchema as r, BillingEventSchema as s, AccountStateChangeCause as t, EventDetail as u, isEventType as v, AccountDeleteResponseSchema as w, AccessStateSchema as x, ACCOUNT_INCLUDES as y, AccountSubscriptionStateSchema as z };
859
+ export { EntitlementSnapshot as $, AccountMeterState as A, AccountScheduledChange as B, Account as C, AccountDunningStateSchema as D, AccountDunningState as E, AccountOpenCheckoutSchema as F, AccountSubscriptionState as G, AccountSchema as H, AccountOpenInvoice as I, AccountUpsertInputSchema as J, AccountSubscriptionStateSchema as K, AccountOpenInvoiceSchema as L, AccountMetersState as M, AccountMetersStateSchema as N, AccountInclude as O, AccountOpenCheckout as P, BillingProfileSchema as Q, AccountProfileState as R, AccessStateSchema as S, AccountDeleteResponseSchema as T, AccountState as U, AccountScheduledChangeSchema as V, AccountStateSchema as W, BillingProfileInput as X, BillingProfile as Y, BillingProfileKindSchema as Z, Ping as _, BillingEvent as a, ACCOUNT_INCLUDES as b, EVENT_DETAIL_SCHEMAS as c, EventIdSchema as d, EntitlementSnapshotSchema as et, EventType as f, PING_EVENT_TYPE as g, LegacyEventType as h, ApiVersionSchema as i, SubscriptionSummarySchema as it, AccountMeterStateSchema as j, AccountLocaleSchema as k, EVENT_TYPES as l, LEGACY_EVENT_TYPES as m, AnyBillingEvent as n, SubscriptionStatusSchema as nt, BillingEventOf as o, FULL_STATE_EVENT_TYPES as p, AccountUpsertInput as q, AnyBillingEventSchema as r, SubscriptionSummary as rt, BillingEventSchema as s, AccountStateChangeCause as t, SubscriptionStatus as tt, EventDetail as u, PingSchema as v, AccountDeleteResponse as w, AccessState as x, isEventType as y, AccountProfileStateSchema as z };