@stewardhq/sdk 0.3.0 → 0.5.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 (39) hide show
  1. package/README.md +122 -92
  2. package/dist/_chunks/errors.js +1 -1
  3. package/dist/_chunks/events.d.ts +301 -4
  4. package/dist/_chunks/events.js +995 -17
  5. package/dist/_chunks/index.d.ts +3129 -63
  6. package/dist/_chunks/locale.d.ts +269 -1
  7. package/dist/_chunks/src.js +807 -25
  8. package/dist/_chunks/validators.d.ts +45 -1
  9. package/dist/_chunks/validators.js +128 -27
  10. package/dist/contract.d.ts +4 -4
  11. package/dist/contract.js +4 -4
  12. package/dist/index.d.ts +436 -22
  13. package/dist/index.js +1659 -26
  14. package/dist/server.d.ts +44 -6
  15. package/dist/server.js +29 -2
  16. package/package.json +2 -7
  17. package/dist/_chunks/steward.d.ts +0 -189
  18. package/dist/_chunks/steward.js +0 -564
  19. package/dist/testing/fixtures/events/LOCK.json +0 -27
  20. package/dist/testing/fixtures/events/account.deleted.json +0 -36
  21. package/dist/testing/fixtures/events/account.state_changed.json +0 -53
  22. package/dist/testing/fixtures/events/account.updated.json +0 -37
  23. package/dist/testing/fixtures/events/checkout.completed.json +0 -36
  24. package/dist/testing/fixtures/events/checkout.expired.json +0 -26
  25. package/dist/testing/fixtures/events/checkout.failed.json +0 -27
  26. package/dist/testing/fixtures/events/invoice.created.json +0 -37
  27. package/dist/testing/fixtures/events/invoice.issued.json +0 -38
  28. package/dist/testing/fixtures/events/invoice.voided.json +0 -39
  29. package/dist/testing/fixtures/events/subscription.activated.json +0 -40
  30. package/dist/testing/fixtures/events/subscription.cancel_scheduled.json +0 -38
  31. package/dist/testing/fixtures/events/subscription.canceled.json +0 -29
  32. package/dist/testing/fixtures/events/subscription.expired.json +0 -27
  33. package/dist/testing/fixtures/events/subscription.payment_failed.json +0 -38
  34. package/dist/testing/fixtures/events/subscription.reactivated.json +0 -36
  35. package/dist/testing/fixtures/events/subscription.renewed.json +0 -39
  36. package/dist/testing/fixtures/events/subscription.suspended.json +0 -36
  37. package/dist/testing/fixtures/events/subscription.terminated.json +0 -28
  38. package/dist/testing.d.ts +0 -656
  39. package/dist/testing.js +0 -3684
@@ -1,4 +1,4 @@
1
- import { I as AccountState, J as SubscriptionStatus, K as EntitlementSnapshot, f as EventType } from "./events.js";
1
+ import { $ as EntitlementSnapshot, U as AccountState, f as EventType, tt as SubscriptionStatus } from "./events.js";
2
2
  import { z } from "zod";
3
3
  //#region ../contract/src/common.d.ts
4
4
  declare const API_VERSION = "2026-10-01";
@@ -26,6 +26,33 @@ type EntitlementValue = z.infer<typeof EntitlementValueSchema>;
26
26
  declare const EntitlementsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
27
27
  type Entitlements = z.infer<typeof EntitlementsSchema>;
28
28
  declare const MetadataSchema: z.ZodRecord<z.ZodString, z.ZodString>;
29
+ /**
30
+ * Why an invoice was written (Polar `billing_reason`): `subscription_create` first period,
31
+ * `subscription_cycle` renewal (phase 2 adds overage lines to it), `subscription_update` plan
32
+ * change, `purchase` reserved (one-off purchases are deferred), `manual` staff-written.
33
+ */
34
+ declare const INVOICE_BILLING_REASONS: readonly ["subscription_create", "subscription_cycle", "subscription_update", "purchase", "manual"];
35
+ declare const InvoiceBillingReasonSchema: z.ZodEnum<{
36
+ subscription_create: "subscription_create";
37
+ subscription_cycle: "subscription_cycle";
38
+ subscription_update: "subscription_update";
39
+ purchase: "purchase";
40
+ manual: "manual";
41
+ }>;
42
+ type InvoiceBillingReason = z.infer<typeof InvoiceBillingReasonSchema>;
43
+ /**
44
+ * Collection state of an invoice written before payment: `unpaid` (open, has `dueAt`), `paid`,
45
+ * `uncollectible` (given up after dunning), `waived` (operator forgave it). Invoices written the
46
+ * pre-billing-core way (after a payment, manual invoices) carry no payment status.
47
+ */
48
+ declare const INVOICE_PAYMENT_STATUSES: readonly ["unpaid", "paid", "uncollectible", "waived"];
49
+ declare const InvoicePaymentStatusSchema: z.ZodEnum<{
50
+ unpaid: "unpaid";
51
+ paid: "paid";
52
+ uncollectible: "uncollectible";
53
+ waived: "waived";
54
+ }>;
55
+ type InvoicePaymentStatus = z.infer<typeof InvoicePaymentStatusSchema>;
29
56
  declare const ERROR_CATEGORIES: readonly ["validation", "not_found", "conflict", "config", "provider", "unavailable"];
30
57
  declare const ErrorCategorySchema: z.ZodEnum<{
31
58
  validation: "validation";
@@ -58,6 +85,602 @@ declare const ErrorResponseSchema: z.ZodObject<{
58
85
  }, z.core.$strip>;
59
86
  type ErrorResponse = z.infer<typeof ErrorResponseSchema>;
60
87
  //#endregion
88
+ //#region ../contract/src/meters.d.ts
89
+ declare const METER_FILTER_OPERATORS: readonly ["eq", "ne", "gt", "gte", "lt", "lte", "like", "not_like"];
90
+ type MeterFilterOperator = (typeof METER_FILTER_OPERATORS)[number];
91
+ /** Deepest nesting of `and`/`or` groups. */
92
+ declare const METER_FILTER_MAX_DEPTH = 3;
93
+ /** Most conditions in one filter. */
94
+ declare const METER_FILTER_MAX_CONDITIONS = 20;
95
+ type MeterFilterValue = string | number | boolean;
96
+ type MeterFilterOperand = {
97
+ readonly eq: MeterFilterValue;
98
+ } | {
99
+ readonly ne: MeterFilterValue;
100
+ } | {
101
+ readonly gt: number;
102
+ } | {
103
+ readonly gte: number;
104
+ } | {
105
+ readonly lt: number;
106
+ } | {
107
+ readonly lte: number;
108
+ } | {
109
+ readonly like: string;
110
+ } | {
111
+ readonly not_like: string;
112
+ };
113
+ /** One condition: exactly one property (`name` or `metadata.<key>`). */
114
+ type MeterFilterCondition = {
115
+ readonly [property: string]: MeterFilterValue | MeterFilterOperand;
116
+ };
117
+ type MeterFilterGroup = {
118
+ readonly and: readonly MeterFilter[];
119
+ } | {
120
+ readonly or: readonly MeterFilter[];
121
+ };
122
+ type MeterFilter = MeterFilterGroup | MeterFilterCondition;
123
+ /** A condition in explicit form. `property` is `name` or `metadata.<key>`. */
124
+ type MeterFilterClause = {
125
+ property: string;
126
+ operator: MeterFilterOperator;
127
+ value: MeterFilterValue;
128
+ };
129
+ /**
130
+ * The explicit form of a condition, or `null` when it is not a valid condition (the schema reports
131
+ * why). `{name: "x"}` → `{property: "name", operator: "eq", value: "x"}`.
132
+ */
133
+ declare function meterFilterClauseOf(condition: MeterFilterCondition): MeterFilterClause | null;
134
+ /** Meter filter (see the syntax above). Validates structure; the value is kept as given. */
135
+ declare const MeterFilterSchema: z.ZodCustom<MeterFilter, MeterFilter>;
136
+ /**
137
+ * Canonical form of a valid filter: every condition explicit (`{name: "x"}` → `{name: {eq: "x"}}`),
138
+ * a fresh object. Two filters that differ only by the shorthand have the same canonical JSON
139
+ * (the lock check, M4, compares canonical filters). Throws on an invalid filter.
140
+ */
141
+ declare function canonicalMeterFilter(filter: MeterFilter): MeterFilter;
142
+ /**
143
+ * What a meter computes over its matching events in a period (M4; no `min`/`avg`):
144
+ * `count` events; `sum` / `max` of the finite, non-negative number at `metadata.<key>` (decimals
145
+ * allowed); `unique` count of distinct values at `metadata.<key>`. An event without a usable
146
+ * value adds nothing to that meter (`invalid_value`, shown by doctor).
147
+ */
148
+ declare const METER_AGGREGATION_KINDS: readonly ["count", "sum", "max", "unique"];
149
+ type MeterAggregationKind = (typeof METER_AGGREGATION_KINDS)[number];
150
+ declare const MeterAggregationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
151
+ kind: z.ZodLiteral<"count">;
152
+ }, z.core.$strip>, z.ZodObject<{
153
+ kind: z.ZodLiteral<"sum">;
154
+ key: z.ZodString;
155
+ }, z.core.$strip>, z.ZodObject<{
156
+ kind: z.ZodLiteral<"max">;
157
+ key: z.ZodString;
158
+ }, z.core.$strip>, z.ZodObject<{
159
+ kind: z.ZodLiteral<"unique">;
160
+ key: z.ZodString;
161
+ }, z.core.$strip>], "kind">;
162
+ type MeterAggregation = z.infer<typeof MeterAggregationSchema>;
163
+ /** Largest unit amount in a definition (credit, rollover cap, credit grant): exact as a JSON number. */
164
+ declare const MAX_METER_UNITS = 1000000000000000;
165
+ /** Default `lowAt` (M14): standing becomes `low` at 80% of the credit. */
166
+ declare const DEFAULT_METER_LOW_AT = 0.8;
167
+ /** A positive unit amount in a definition: at most 6 decimals (M4), at most `MAX_METER_UNITS`. */
168
+ declare const MeterUnitsSchema: z.ZodNumber;
169
+ /** Customer-facing text per locale (hosted checkout and portal). Both locales are required. */
170
+ declare const MeterLabelSchema: z.ZodObject<{
171
+ tr: z.ZodString;
172
+ en: z.ZodString;
173
+ }, z.core.$strip>;
174
+ type MeterLabel = z.infer<typeof MeterLabelSchema>;
175
+ /** Share of the credit at which standing becomes `low`: 0 < x ≤ 1, at most 6 decimals. */
176
+ declare const MeterLowAtSchema: z.ZodNumber;
177
+ /**
178
+ * Meter definition (catalog sync input; the record key is the meter code). Input takes `event`
179
+ * and/or `filter`; the output has only `filter`, canonical, `event` folded in (`{and: [{name:
180
+ * {eq: event}}, …filter]}`). Filter and aggregation lock once the meter's first period opened
181
+ * (`422 meter_locked`; M4): a change means a new code.
182
+ */
183
+ declare const MeterDefSchema: z.ZodPipe<z.ZodObject<{
184
+ event: z.ZodOptional<z.ZodString>;
185
+ filter: z.ZodOptional<z.ZodCustom<MeterFilter, MeterFilter>>;
186
+ aggregation: z.ZodDiscriminatedUnion<[z.ZodObject<{
187
+ kind: z.ZodLiteral<"count">;
188
+ }, z.core.$strip>, z.ZodObject<{
189
+ kind: z.ZodLiteral<"sum">;
190
+ key: z.ZodString;
191
+ }, z.core.$strip>, z.ZodObject<{
192
+ kind: z.ZodLiteral<"max">;
193
+ key: z.ZodString;
194
+ }, z.core.$strip>, z.ZodObject<{
195
+ kind: z.ZodLiteral<"unique">;
196
+ key: z.ZodString;
197
+ }, z.core.$strip>], "kind">;
198
+ label: z.ZodObject<{
199
+ tr: z.ZodString;
200
+ en: z.ZodString;
201
+ }, z.core.$strip>;
202
+ unitLabel: z.ZodOptional<z.ZodObject<{
203
+ tr: z.ZodString;
204
+ en: z.ZodString;
205
+ }, z.core.$strip>>;
206
+ displayPer: z.ZodOptional<z.ZodNumber>;
207
+ lowAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
208
+ }, z.core.$strip>, z.ZodTransform<{
209
+ aggregation: {
210
+ kind: "count";
211
+ } | {
212
+ kind: "sum";
213
+ key: string;
214
+ } | {
215
+ kind: "max";
216
+ key: string;
217
+ } | {
218
+ kind: "unique";
219
+ key: string;
220
+ };
221
+ label: {
222
+ tr: string;
223
+ en: string;
224
+ };
225
+ lowAt: number | null;
226
+ unitLabel?: {
227
+ tr: string;
228
+ en: string;
229
+ } | undefined;
230
+ displayPer?: number | undefined;
231
+ filter: MeterFilter;
232
+ }, {
233
+ aggregation: {
234
+ kind: "count";
235
+ } | {
236
+ kind: "sum";
237
+ key: string;
238
+ } | {
239
+ kind: "max";
240
+ key: string;
241
+ } | {
242
+ kind: "unique";
243
+ key: string;
244
+ };
245
+ label: {
246
+ tr: string;
247
+ en: string;
248
+ };
249
+ lowAt: number | null;
250
+ event?: string | undefined;
251
+ filter?: MeterFilter | undefined;
252
+ unitLabel?: {
253
+ tr: string;
254
+ en: string;
255
+ } | undefined;
256
+ displayPer?: number | undefined;
257
+ }>>;
258
+ type MeterDef = z.output<typeof MeterDefSchema>;
259
+ type MeterDefInput = z.input<typeof MeterDefSchema>;
260
+ /**
261
+ * A meter as returned by `GET /v1/catalog` (active meters). Lenient for forward compatibility: a
262
+ * newer steward may use filter or aggregation forms this version does not define; narrow `filter`
263
+ * with `MeterFilterSchema` and `aggregation` with `MeterAggregationSchema`.
264
+ */
265
+ declare const CatalogMeterSchema: z.ZodObject<{
266
+ filter: z.ZodUnknown;
267
+ aggregation: z.ZodObject<{
268
+ kind: z.ZodString;
269
+ key: z.ZodOptional<z.ZodString>;
270
+ }, z.core.$loose>;
271
+ label: z.ZodObject<{
272
+ tr: z.ZodString;
273
+ en: z.ZodString;
274
+ }, z.core.$strip>;
275
+ unitLabel: z.ZodOptional<z.ZodObject<{
276
+ tr: z.ZodString;
277
+ en: z.ZodString;
278
+ }, z.core.$strip>>;
279
+ displayPer: z.ZodOptional<z.ZodNumber>;
280
+ lowAt: z.ZodNullable<z.ZodNumber>;
281
+ }, z.core.$strip>;
282
+ type CatalogMeter = z.infer<typeof CatalogMeterSchema>;
283
+ /**
284
+ * `meter_credit` benefit properties (M5, M6): `units` granted at the start of every meter period
285
+ * (plan + add-ons for the same meter add up; the default plan's credit only when no other layer
286
+ * credits the meter — `meterCreditsOf`); `rolloverCapUnits` turns rollover on — the unused
287
+ * balance carries over up to the cap (absent: unused credit expires; debt never carries).
288
+ */
289
+ declare const MeterCreditPropertiesSchema: z.ZodObject<{
290
+ meter: z.ZodString;
291
+ units: z.ZodNumber;
292
+ rolloverCapUnits: z.ZodOptional<z.ZodNumber>;
293
+ }, z.core.$strip>;
294
+ type MeterCreditProperties = z.infer<typeof MeterCreditPropertiesSchema>;
295
+ /** Largest `perUnits` of a metered price. */
296
+ declare const MAX_METERED_PRICE_PER_UNITS = 1000000000000;
297
+ /**
298
+ * Metered price (catalog sync input; MF5, M20): overage above the credit is billed
299
+ * `amountMinor` per `perUnits` units ("₺12,50 / 1.000 token" = `{amountMinor: 1250, perUnits:
300
+ * 1000}`; an integer pair, no decimal unit price). Key `(planCode, meter, currency)`. Tax terms
301
+ * must equal the plan's base prices in that currency (`metered_price_tax_mismatch`). `capMinor`
302
+ * caps the overage amount per meter period. Mutable in place like base prices (M36); a
303
+ * subscription locks the rate it started with.
304
+ */
305
+ declare const MeteredPriceDefSchema: z.ZodObject<{
306
+ planCode: z.ZodString;
307
+ meter: z.ZodString;
308
+ currency: z.ZodString;
309
+ amountMinor: z.ZodNumber;
310
+ perUnits: z.ZodNumber;
311
+ taxInclusive: z.ZodBoolean;
312
+ taxRateBps: z.ZodNumber;
313
+ capMinor: z.ZodOptional<z.ZodNumber>;
314
+ }, z.core.$strip>;
315
+ type MeteredPriceDef = z.infer<typeof MeteredPriceDefSchema>;
316
+ /** Metered price as returned by `GET /v1/catalog` (active ones). */
317
+ declare const MeteredPriceSchema: z.ZodObject<{
318
+ planCode: z.ZodString;
319
+ meter: z.ZodString;
320
+ currency: z.ZodString;
321
+ amountMinor: z.ZodNumber;
322
+ perUnits: z.ZodNumber;
323
+ taxInclusive: z.ZodBoolean;
324
+ taxRateBps: z.ZodNumber;
325
+ id: z.ZodUUID;
326
+ active: z.ZodBoolean;
327
+ capMinor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
328
+ createdAt: z.ZodISODateTime;
329
+ }, z.core.$strip>;
330
+ type MeteredPrice = z.infer<typeof MeteredPriceSchema>;
331
+ /**
332
+ * Credit standing of a meter in its period (M14): `low` once consumption reaches `lowAt` × credit,
333
+ * `exhausted` once the balance is ≤ 0; a meter without credit is always `ok`. Standing describes
334
+ * the credit only: a billable meter (metered price) keeps working past `exhausted` (M15).
335
+ */
336
+ declare const METER_STANDINGS: readonly ["ok", "low", "exhausted"];
337
+ declare const MeterStandingSchema: z.ZodEnum<{
338
+ ok: "ok";
339
+ low: "low";
340
+ exhausted: "exhausted";
341
+ }>;
342
+ type MeterStanding = z.infer<typeof MeterStandingSchema>;
343
+ /**
344
+ * Units as a decimal string (invoice lines, meter charges): non-negative, at most 6 decimals.
345
+ * Steward writes the canonical form (`microToDecimalString`: no exponent, no trailing zeros).
346
+ */
347
+ declare const DecimalUnitsStringSchema: z.ZodString;
348
+ /** One meter of `GET /v1/accounts/:ref/meters`: the meter's OPEN period (periods are per meter, M7). */
349
+ declare const AccountMeterSchema: z.ZodObject<{
350
+ periodStart: z.ZodISODateTime;
351
+ periodEnd: z.ZodISODateTime;
352
+ includedUnits: z.ZodNullable<z.ZodNumber>;
353
+ consumedUnits: z.ZodNumber;
354
+ creditedUnits: z.ZodNumber;
355
+ balance: z.ZodNumber;
356
+ overageUnits: z.ZodNumber;
357
+ standing: z.ZodEnum<{
358
+ ok: "ok";
359
+ low: "low";
360
+ exhausted: "exhausted";
361
+ }>;
362
+ billable: z.ZodBoolean;
363
+ amountDueMinor: z.ZodNullable<z.ZodNumber>;
364
+ currency: z.ZodNullable<z.ZodString>;
365
+ capReached: z.ZodOptional<z.ZodBoolean>;
366
+ }, z.core.$strip>;
367
+ type AccountMeter = z.infer<typeof AccountMeterSchema>;
368
+ /**
369
+ * `GET /v1/accounts/:ref/meters` (M13): a meter READ, not a second state model — no version, no
370
+ * events. ETag = the account's `meters_seq` (rollup and credit writes); `If-None-Match` → 304.
371
+ * `rolledUpThrough`: events received before this moment are counted.
372
+ */
373
+ declare const AccountMetersSchema: z.ZodObject<{
374
+ ref: z.ZodString;
375
+ asOf: z.ZodISODateTime;
376
+ rolledUpThrough: z.ZodISODateTime;
377
+ meters: z.ZodRecord<z.ZodString, z.ZodObject<{
378
+ periodStart: z.ZodISODateTime;
379
+ periodEnd: z.ZodISODateTime;
380
+ includedUnits: z.ZodNullable<z.ZodNumber>;
381
+ consumedUnits: z.ZodNumber;
382
+ creditedUnits: z.ZodNumber;
383
+ balance: z.ZodNumber;
384
+ overageUnits: z.ZodNumber;
385
+ standing: z.ZodEnum<{
386
+ ok: "ok";
387
+ low: "low";
388
+ exhausted: "exhausted";
389
+ }>;
390
+ billable: z.ZodBoolean;
391
+ amountDueMinor: z.ZodNullable<z.ZodNumber>;
392
+ currency: z.ZodNullable<z.ZodString>;
393
+ capReached: z.ZodOptional<z.ZodBoolean>;
394
+ }, z.core.$strip>>;
395
+ }, z.core.$strip>;
396
+ type AccountMeters = z.infer<typeof AccountMetersSchema>;
397
+ declare const METER_PERIOD_STATUSES: readonly ["open", "closing", "closed"];
398
+ declare const MeterPeriodStatusSchema: z.ZodEnum<{
399
+ open: "open";
400
+ closing: "closing";
401
+ closed: "closed";
402
+ }>;
403
+ type MeterPeriodStatus = z.infer<typeof MeterPeriodStatusSchema>;
404
+ /** A meter period (`GET /v1/accounts/:ref/meters/periods`; closed periods, newest first). */
405
+ declare const MeterPeriodSchema: z.ZodObject<{
406
+ meter: z.ZodString;
407
+ periodStart: z.ZodISODateTime;
408
+ periodEnd: z.ZodISODateTime;
409
+ status: z.ZodEnum<{
410
+ open: "open";
411
+ closing: "closing";
412
+ closed: "closed";
413
+ }>;
414
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
415
+ consumedUnits: z.ZodNumber;
416
+ creditedUnits: z.ZodNumber;
417
+ overageUnits: z.ZodNumber;
418
+ closedAt: z.ZodNullable<z.ZodISODateTime>;
419
+ }, z.core.$strip>;
420
+ type MeterPeriod = z.infer<typeof MeterPeriodSchema>;
421
+ declare const MeterPeriodListSchema: z.ZodObject<{
422
+ ref: z.ZodString;
423
+ periods: z.ZodArray<z.ZodObject<{
424
+ meter: z.ZodString;
425
+ periodStart: z.ZodISODateTime;
426
+ periodEnd: z.ZodISODateTime;
427
+ status: z.ZodEnum<{
428
+ open: "open";
429
+ closing: "closing";
430
+ closed: "closed";
431
+ }>;
432
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
433
+ consumedUnits: z.ZodNumber;
434
+ creditedUnits: z.ZodNumber;
435
+ overageUnits: z.ZodNumber;
436
+ closedAt: z.ZodNullable<z.ZodISODateTime>;
437
+ }, z.core.$strip>>;
438
+ }, z.core.$strip>;
439
+ type MeterPeriodList = z.infer<typeof MeterPeriodListSchema>;
440
+ /**
441
+ * `POST /v1/accounts/:ref/credits` (M5): a one-off credit for the meter's open period (goodwill,
442
+ * campaign). Needs no benefit; recorded in the append-only credit ledger with the actor.
443
+ * Unknown meter: `422 meter_not_found`.
444
+ */
445
+ declare const CreditGrantInputSchema: z.ZodObject<{
446
+ meter: z.ZodString;
447
+ units: z.ZodNumber;
448
+ reason: z.ZodString;
449
+ }, z.core.$strip>;
450
+ type CreditGrantInput = z.input<typeof CreditGrantInputSchema>;
451
+ /** Credit ledger entry kinds (M5). Entries are never rewritten. */
452
+ declare const METER_CREDIT_ENTRY_KINDS: readonly ["cycle_grant", "rollover", "plan_change", "manual_grant", "adjustment"];
453
+ declare const MeterCreditEntryKindSchema: z.ZodEnum<{
454
+ cycle_grant: "cycle_grant";
455
+ rollover: "rollover";
456
+ plan_change: "plan_change";
457
+ manual_grant: "manual_grant";
458
+ adjustment: "adjustment";
459
+ }>;
460
+ type MeterCreditEntryKind = z.infer<typeof MeterCreditEntryKindSchema>;
461
+ declare const MeterCreditEntrySchema: z.ZodObject<{
462
+ id: z.ZodUUID;
463
+ meter: z.ZodString;
464
+ kind: z.ZodEnum<{
465
+ cycle_grant: "cycle_grant";
466
+ rollover: "rollover";
467
+ plan_change: "plan_change";
468
+ manual_grant: "manual_grant";
469
+ adjustment: "adjustment";
470
+ }>;
471
+ units: z.ZodNumber;
472
+ periodStart: z.ZodISODateTime;
473
+ reason: z.ZodNullable<z.ZodString>;
474
+ actorRef: z.ZodNullable<z.ZodString>;
475
+ createdAt: z.ZodISODateTime;
476
+ }, z.core.$strip>;
477
+ type MeterCreditEntry = z.infer<typeof MeterCreditEntrySchema>;
478
+ declare const METER_CHARGE_STATUSES: readonly ["dry_run", "carried", "invoiced"];
479
+ declare const MeterChargeStatusSchema: z.ZodEnum<{
480
+ dry_run: "dry_run";
481
+ carried: "carried";
482
+ invoiced: "invoiced";
483
+ }>;
484
+ type MeterChargeStatus = z.infer<typeof MeterChargeStatusSchema>;
485
+ /** One priced meter of a charge (M21): overage × locked rate, capped. Units are decimal strings. */
486
+ declare const MeterChargeLineSchema: z.ZodObject<{
487
+ meter: z.ZodString;
488
+ consumedUnits: z.ZodString;
489
+ creditedUnits: z.ZodString;
490
+ overageUnits: z.ZodString;
491
+ priceAmountMinor: z.ZodNumber;
492
+ pricePerUnits: z.ZodNumber;
493
+ capMinor: z.ZodNullable<z.ZodNumber>;
494
+ amountMinor: z.ZodNumber;
495
+ }, z.core.$strip>;
496
+ type MeterChargeLine = z.infer<typeof MeterChargeLineSchema>;
497
+ /**
498
+ * Pricing record of a closed meter period (M21; money data, never rewritten). Totals use the
499
+ * invoice rule (`meterChargeTotals`, one rounding). `status`: `dry_run` (chargeMode `dry_run`:
500
+ * recorded, not invoiced), `carried` (below `billing.minInvoiceMinor` on an overage-only invoice:
501
+ * carried into the next invoice), `invoiced` (`invoiceId` set). `carriedInMinor`: earlier carried
502
+ * amounts included here.
503
+ */
504
+ declare const MeterChargeSchema: z.ZodObject<{
505
+ id: z.ZodUUID;
506
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
507
+ periodStart: z.ZodISODateTime;
508
+ periodEnd: z.ZodISODateTime;
509
+ currency: z.ZodString;
510
+ taxInclusive: z.ZodBoolean;
511
+ taxRateBps: z.ZodNumber;
512
+ lines: z.ZodArray<z.ZodObject<{
513
+ meter: z.ZodString;
514
+ consumedUnits: z.ZodString;
515
+ creditedUnits: z.ZodString;
516
+ overageUnits: z.ZodString;
517
+ priceAmountMinor: z.ZodNumber;
518
+ pricePerUnits: z.ZodNumber;
519
+ capMinor: z.ZodNullable<z.ZodNumber>;
520
+ amountMinor: z.ZodNumber;
521
+ }, z.core.$strip>>;
522
+ subtotalMinor: z.ZodNumber;
523
+ taxMinor: z.ZodNumber;
524
+ totalMinor: z.ZodNumber;
525
+ carriedInMinor: z.ZodNumber;
526
+ status: z.ZodEnum<{
527
+ dry_run: "dry_run";
528
+ carried: "carried";
529
+ invoiced: "invoiced";
530
+ }>;
531
+ invoiceId: z.ZodNullable<z.ZodUUID>;
532
+ createdAt: z.ZodISODateTime;
533
+ }, z.core.$strip>;
534
+ type MeterCharge = z.infer<typeof MeterChargeSchema>;
535
+ /** `GET /v1/accounts/:ref/meter-charges` (newest first). */
536
+ declare const MeterChargeListSchema: z.ZodObject<{
537
+ ref: z.ZodString;
538
+ charges: z.ZodArray<z.ZodObject<{
539
+ id: z.ZodUUID;
540
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
541
+ periodStart: z.ZodISODateTime;
542
+ periodEnd: z.ZodISODateTime;
543
+ currency: z.ZodString;
544
+ taxInclusive: z.ZodBoolean;
545
+ taxRateBps: z.ZodNumber;
546
+ lines: z.ZodArray<z.ZodObject<{
547
+ meter: z.ZodString;
548
+ consumedUnits: z.ZodString;
549
+ creditedUnits: z.ZodString;
550
+ overageUnits: z.ZodString;
551
+ priceAmountMinor: z.ZodNumber;
552
+ pricePerUnits: z.ZodNumber;
553
+ capMinor: z.ZodNullable<z.ZodNumber>;
554
+ amountMinor: z.ZodNumber;
555
+ }, z.core.$strip>>;
556
+ subtotalMinor: z.ZodNumber;
557
+ taxMinor: z.ZodNumber;
558
+ totalMinor: z.ZodNumber;
559
+ carriedInMinor: z.ZodNumber;
560
+ status: z.ZodEnum<{
561
+ dry_run: "dry_run";
562
+ carried: "carried";
563
+ invoiced: "invoiced";
564
+ }>;
565
+ invoiceId: z.ZodNullable<z.ZodUUID>;
566
+ createdAt: z.ZodISODateTime;
567
+ }, z.core.$strip>>;
568
+ }, z.core.$strip>;
569
+ type MeterChargeList = z.infer<typeof MeterChargeListSchema>;
570
+ //#endregion
571
+ //#region ../contract/src/benefits.d.ts
572
+ /** Benefit types this contract version defines. */
573
+ declare const BENEFIT_TYPES: readonly ["feature_flag", "meter_credit"];
574
+ declare const BenefitTypeSchema: z.ZodEnum<{
575
+ feature_flag: "feature_flag";
576
+ meter_credit: "meter_credit";
577
+ }>;
578
+ type BenefitType = z.infer<typeof BenefitTypeSchema>;
579
+ /** Customer-facing description per locale (hosted checkout and portal "what's included"). */
580
+ declare const BenefitDescriptionSchema: z.ZodObject<{
581
+ tr: z.ZodOptional<z.ZodString>;
582
+ en: z.ZodOptional<z.ZodString>;
583
+ }, z.core.$strip>;
584
+ type BenefitDescription = z.infer<typeof BenefitDescriptionSchema>;
585
+ /** `feature_flag` properties: catalog feature key → value (K4 typing; checked against `features` on catalog sync). */
586
+ declare const FeatureFlagPropertiesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
587
+ type FeatureFlagProperties = z.infer<typeof FeatureFlagPropertiesSchema>;
588
+ declare const FeatureFlagBenefitDefSchema: z.ZodObject<{
589
+ type: z.ZodLiteral<"feature_flag">;
590
+ properties: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
591
+ description: z.ZodOptional<z.ZodObject<{
592
+ tr: z.ZodOptional<z.ZodString>;
593
+ en: z.ZodOptional<z.ZodString>;
594
+ }, z.core.$strip>>;
595
+ }, z.core.$strip>;
596
+ type FeatureFlagBenefitDef = z.infer<typeof FeatureFlagBenefitDefSchema>;
597
+ /** `meter_credit` definition (metering phase 2): the meter must be a catalog meter (checked on catalog sync). */
598
+ declare const MeterCreditBenefitDefSchema: z.ZodObject<{
599
+ type: z.ZodLiteral<"meter_credit">;
600
+ properties: z.ZodObject<{
601
+ meter: z.ZodString;
602
+ units: z.ZodNumber;
603
+ rolloverCapUnits: z.ZodOptional<z.ZodNumber>;
604
+ }, z.core.$strip>;
605
+ description: z.ZodOptional<z.ZodObject<{
606
+ tr: z.ZodOptional<z.ZodString>;
607
+ en: z.ZodOptional<z.ZodString>;
608
+ }, z.core.$strip>>;
609
+ }, z.core.$strip>;
610
+ type MeterCreditBenefitDef = z.infer<typeof MeterCreditBenefitDefSchema>;
611
+ /** Catalog benefit definition (catalog sync input), discriminated by `type`. */
612
+ declare const BenefitDefSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
613
+ type: z.ZodLiteral<"feature_flag">;
614
+ properties: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
615
+ description: z.ZodOptional<z.ZodObject<{
616
+ tr: z.ZodOptional<z.ZodString>;
617
+ en: z.ZodOptional<z.ZodString>;
618
+ }, z.core.$strip>>;
619
+ }, z.core.$strip>, z.ZodObject<{
620
+ type: z.ZodLiteral<"meter_credit">;
621
+ properties: z.ZodObject<{
622
+ meter: z.ZodString;
623
+ units: z.ZodNumber;
624
+ rolloverCapUnits: z.ZodOptional<z.ZodNumber>;
625
+ }, z.core.$strip>;
626
+ description: z.ZodOptional<z.ZodObject<{
627
+ tr: z.ZodOptional<z.ZodString>;
628
+ en: z.ZodOptional<z.ZodString>;
629
+ }, z.core.$strip>>;
630
+ }, z.core.$strip>], "type">;
631
+ type BenefitDef = z.infer<typeof BenefitDefSchema>;
632
+ /**
633
+ * Benefit definition as returned by `GET /v1/catalog`. `type` is an open set (a newer steward may
634
+ * return types this version does not define); narrow with `type === "feature_flag"`.
635
+ */
636
+ declare const CatalogBenefitSchema: z.ZodObject<{
637
+ type: z.ZodString;
638
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
639
+ description: z.ZodOptional<z.ZodObject<{
640
+ tr: z.ZodOptional<z.ZodString>;
641
+ en: z.ZodOptional<z.ZodString>;
642
+ }, z.core.$strip>>;
643
+ }, z.core.$strip>;
644
+ type CatalogBenefit = z.infer<typeof CatalogBenefitSchema>;
645
+ /**
646
+ * Where a granted benefit comes from, e.g. `plan:<code>` (default plan or a live subscription's
647
+ * plan), `grant:<id>` (a grant), `override` (account overrides). Open set: informational.
648
+ */
649
+ declare const BenefitSourceSchema: z.ZodString;
650
+ /**
651
+ * A benefit granted to the account (`AccountState.benefits[]`; Polar granted benefit).
652
+ * `code` is the catalog benefit code; `null` for an implicit benefit that has no catalog code
653
+ * (a plan's entitlement matrix, account overrides). `type` is an open set (see
654
+ * `CatalogBenefitSchema`); `properties` are the values granted.
655
+ */
656
+ declare const AccountBenefitSchema: z.ZodObject<{
657
+ code: z.ZodNullable<z.ZodString>;
658
+ type: z.ZodString;
659
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
660
+ source: z.ZodString;
661
+ grantedAt: z.ZodISODateTime;
662
+ }, z.core.$strip>;
663
+ type AccountBenefit = z.infer<typeof AccountBenefitSchema>;
664
+ type FeatureFlagAccountBenefit = AccountBenefit & {
665
+ type: "feature_flag";
666
+ properties: FeatureFlagProperties;
667
+ };
668
+ /** Narrows a granted benefit to `feature_flag` (type and property values checked). */
669
+ declare function isFeatureFlagBenefit(benefit: AccountBenefit): benefit is FeatureFlagAccountBenefit;
670
+ type MeterCreditAccountBenefit = AccountBenefit & {
671
+ type: "meter_credit";
672
+ properties: MeterCreditProperties;
673
+ };
674
+ /** Narrows a granted benefit to `meter_credit` (type and properties checked). */
675
+ declare function isMeterCreditBenefit(benefit: AccountBenefit): benefit is MeterCreditAccountBenefit;
676
+ /** Feature types (same values as `FeatureTypeSchema` in `catalog.ts`). */
677
+ type BenefitFeatureType = "limit" | "boolean" | "string";
678
+ /**
679
+ * Whether a value fits a feature type (K4): `limit` → integer ≥ 0 or `null` (unlimited),
680
+ * `boolean` → boolean, `string` → string. `null` is only valid for `limit`.
681
+ */
682
+ declare function featureValueMatchesType(type: BenefitFeatureType, value: EntitlementValue): boolean;
683
+ //#endregion
61
684
  //#region ../contract/src/catalog.d.ts
62
685
  declare const FeatureTypeSchema: z.ZodEnum<{
63
686
  string: "string";
@@ -74,14 +697,28 @@ declare const FeatureDefSchema: z.ZodObject<{
74
697
  description: z.ZodOptional<z.ZodString>;
75
698
  }, z.core.$strip>;
76
699
  type FeatureDef = z.infer<typeof FeatureDefSchema>;
700
+ /** Upper bound of benefits a plan lists. */
701
+ declare const MAX_PLAN_BENEFITS = 100;
702
+ /** Plan in the catalog sync input. */
77
703
  declare const PlanDefSchema: z.ZodObject<{
78
704
  code: z.ZodString;
79
705
  name: z.ZodString;
80
- rank: z.ZodNumber;
706
+ rank: z.ZodDefault<z.ZodNumber>;
81
707
  sellable: z.ZodBoolean;
82
708
  entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
709
+ benefits: z.ZodDefault<z.ZodArray<z.ZodString>>;
83
710
  }, z.core.$strip>;
84
711
  type PlanDef = z.infer<typeof PlanDefSchema>;
712
+ /** Plan as returned by `GET /v1/catalog`. */
713
+ declare const CatalogPlanSchema: z.ZodObject<{
714
+ code: z.ZodString;
715
+ name: z.ZodString;
716
+ rank: z.ZodDefault<z.ZodNumber>;
717
+ sellable: z.ZodBoolean;
718
+ entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
719
+ benefits: z.ZodOptional<z.ZodArray<z.ZodString>>;
720
+ }, z.core.$strip>;
721
+ type CatalogPlan = z.infer<typeof CatalogPlanSchema>;
85
722
  declare const PriceDefSchema: z.ZodObject<{
86
723
  planCode: z.ZodString;
87
724
  interval: z.ZodEnum<{
@@ -95,6 +732,14 @@ declare const PriceDefSchema: z.ZodObject<{
95
732
  taxRateBps: z.ZodNumber;
96
733
  }, z.core.$strip>;
97
734
  type PriceDef = z.infer<typeof PriceDefSchema>;
735
+ /** Upper bound of benefit definitions in one catalog. */
736
+ declare const MAX_CATALOG_BENEFITS = 200;
737
+ /** Upper bound of meters in one catalog. */
738
+ declare const MAX_CATALOG_METERS = 100;
739
+ /** Upper bound of metered prices in one catalog. */
740
+ declare const MAX_CATALOG_METERED_PRICES = 500;
741
+ /** Issue `params.code` of a metered price whose tax terms differ from the plan's base price (M20). */
742
+ declare const METERED_PRICE_TAX_MISMATCH = "metered_price_tax_mismatch";
98
743
  declare const CatalogSyncInputSchema: z.ZodObject<{
99
744
  defaultPlanCode: z.ZodString;
100
745
  features: z.ZodArray<z.ZodObject<{
@@ -109,9 +754,10 @@ declare const CatalogSyncInputSchema: z.ZodObject<{
109
754
  plans: z.ZodArray<z.ZodObject<{
110
755
  code: z.ZodString;
111
756
  name: z.ZodString;
112
- rank: z.ZodNumber;
757
+ rank: z.ZodDefault<z.ZodNumber>;
113
758
  sellable: z.ZodBoolean;
114
759
  entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
760
+ benefits: z.ZodDefault<z.ZodArray<z.ZodString>>;
115
761
  }, z.core.$strip>>;
116
762
  prices: z.ZodArray<z.ZodObject<{
117
763
  planCode: z.ZodString;
@@ -125,6 +771,110 @@ declare const CatalogSyncInputSchema: z.ZodObject<{
125
771
  taxInclusive: z.ZodBoolean;
126
772
  taxRateBps: z.ZodNumber;
127
773
  }, z.core.$strip>>;
774
+ benefits: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
775
+ type: z.ZodLiteral<"feature_flag">;
776
+ properties: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
777
+ description: z.ZodOptional<z.ZodObject<{
778
+ tr: z.ZodOptional<z.ZodString>;
779
+ en: z.ZodOptional<z.ZodString>;
780
+ }, z.core.$strip>>;
781
+ }, z.core.$strip>, z.ZodObject<{
782
+ type: z.ZodLiteral<"meter_credit">;
783
+ properties: z.ZodObject<{
784
+ meter: z.ZodString;
785
+ units: z.ZodNumber;
786
+ rolloverCapUnits: z.ZodOptional<z.ZodNumber>;
787
+ }, z.core.$strip>;
788
+ description: z.ZodOptional<z.ZodObject<{
789
+ tr: z.ZodOptional<z.ZodString>;
790
+ en: z.ZodOptional<z.ZodString>;
791
+ }, z.core.$strip>>;
792
+ }, z.core.$strip>], "type">>>;
793
+ meters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodObject<{
794
+ event: z.ZodOptional<z.ZodString>;
795
+ filter: z.ZodOptional<z.ZodCustom<MeterFilter, MeterFilter>>;
796
+ aggregation: z.ZodDiscriminatedUnion<[z.ZodObject<{
797
+ kind: z.ZodLiteral<"count">;
798
+ }, z.core.$strip>, z.ZodObject<{
799
+ kind: z.ZodLiteral<"sum">;
800
+ key: z.ZodString;
801
+ }, z.core.$strip>, z.ZodObject<{
802
+ kind: z.ZodLiteral<"max">;
803
+ key: z.ZodString;
804
+ }, z.core.$strip>, z.ZodObject<{
805
+ kind: z.ZodLiteral<"unique">;
806
+ key: z.ZodString;
807
+ }, z.core.$strip>], "kind">;
808
+ label: z.ZodObject<{
809
+ tr: z.ZodString;
810
+ en: z.ZodString;
811
+ }, z.core.$strip>;
812
+ unitLabel: z.ZodOptional<z.ZodObject<{
813
+ tr: z.ZodString;
814
+ en: z.ZodString;
815
+ }, z.core.$strip>>;
816
+ displayPer: z.ZodOptional<z.ZodNumber>;
817
+ lowAt: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
818
+ }, z.core.$strip>, z.ZodTransform<{
819
+ aggregation: {
820
+ kind: "count";
821
+ } | {
822
+ kind: "sum";
823
+ key: string;
824
+ } | {
825
+ kind: "max";
826
+ key: string;
827
+ } | {
828
+ kind: "unique";
829
+ key: string;
830
+ };
831
+ label: {
832
+ tr: string;
833
+ en: string;
834
+ };
835
+ lowAt: number | null;
836
+ unitLabel?: {
837
+ tr: string;
838
+ en: string;
839
+ } | undefined;
840
+ displayPer?: number | undefined;
841
+ filter: MeterFilter;
842
+ }, {
843
+ aggregation: {
844
+ kind: "count";
845
+ } | {
846
+ kind: "sum";
847
+ key: string;
848
+ } | {
849
+ kind: "max";
850
+ key: string;
851
+ } | {
852
+ kind: "unique";
853
+ key: string;
854
+ };
855
+ label: {
856
+ tr: string;
857
+ en: string;
858
+ };
859
+ lowAt: number | null;
860
+ event?: string | undefined;
861
+ filter?: MeterFilter | undefined;
862
+ unitLabel?: {
863
+ tr: string;
864
+ en: string;
865
+ } | undefined;
866
+ displayPer?: number | undefined;
867
+ }>>>>;
868
+ meteredPrices: z.ZodDefault<z.ZodArray<z.ZodObject<{
869
+ planCode: z.ZodString;
870
+ meter: z.ZodString;
871
+ currency: z.ZodString;
872
+ amountMinor: z.ZodNumber;
873
+ perUnits: z.ZodNumber;
874
+ taxInclusive: z.ZodBoolean;
875
+ taxRateBps: z.ZodNumber;
876
+ capMinor: z.ZodOptional<z.ZodNumber>;
877
+ }, z.core.$strip>>>;
128
878
  }, z.core.$strip>;
129
879
  type CatalogSyncInput = z.input<typeof CatalogSyncInputSchema>;
130
880
  declare const PriceSchema: z.ZodObject<{
@@ -158,9 +908,10 @@ declare const CatalogSchema: z.ZodObject<{
158
908
  plans: z.ZodArray<z.ZodObject<{
159
909
  code: z.ZodString;
160
910
  name: z.ZodString;
161
- rank: z.ZodNumber;
911
+ rank: z.ZodDefault<z.ZodNumber>;
162
912
  sellable: z.ZodBoolean;
163
913
  entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
914
+ benefits: z.ZodOptional<z.ZodArray<z.ZodString>>;
164
915
  }, z.core.$strip>>;
165
916
  prices: z.ZodArray<z.ZodObject<{
166
917
  planCode: z.ZodString;
@@ -177,6 +928,44 @@ declare const CatalogSchema: z.ZodObject<{
177
928
  active: z.ZodBoolean;
178
929
  createdAt: z.ZodISODateTime;
179
930
  }, z.core.$strip>>;
931
+ benefits: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
932
+ type: z.ZodString;
933
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
934
+ description: z.ZodOptional<z.ZodObject<{
935
+ tr: z.ZodOptional<z.ZodString>;
936
+ en: z.ZodOptional<z.ZodString>;
937
+ }, z.core.$strip>>;
938
+ }, z.core.$strip>>>;
939
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
940
+ filter: z.ZodUnknown;
941
+ aggregation: z.ZodObject<{
942
+ kind: z.ZodString;
943
+ key: z.ZodOptional<z.ZodString>;
944
+ }, z.core.$loose>;
945
+ label: z.ZodObject<{
946
+ tr: z.ZodString;
947
+ en: z.ZodString;
948
+ }, z.core.$strip>;
949
+ unitLabel: z.ZodOptional<z.ZodObject<{
950
+ tr: z.ZodString;
951
+ en: z.ZodString;
952
+ }, z.core.$strip>>;
953
+ displayPer: z.ZodOptional<z.ZodNumber>;
954
+ lowAt: z.ZodNullable<z.ZodNumber>;
955
+ }, z.core.$strip>>>;
956
+ meteredPrices: z.ZodOptional<z.ZodArray<z.ZodObject<{
957
+ planCode: z.ZodString;
958
+ meter: z.ZodString;
959
+ currency: z.ZodString;
960
+ amountMinor: z.ZodNumber;
961
+ perUnits: z.ZodNumber;
962
+ taxInclusive: z.ZodBoolean;
963
+ taxRateBps: z.ZodNumber;
964
+ id: z.ZodUUID;
965
+ active: z.ZodBoolean;
966
+ capMinor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
967
+ createdAt: z.ZodISODateTime;
968
+ }, z.core.$strip>>>;
180
969
  }, z.core.$strip>;
181
970
  type Catalog = z.infer<typeof CatalogSchema>;
182
971
  declare const CatalogSyncResultSchema: z.ZodObject<{
@@ -192,6 +981,14 @@ declare const CatalogSyncResultSchema: z.ZodObject<{
192
981
  provider: z.ZodString;
193
982
  code: z.ZodString;
194
983
  }, z.core.$strip>>;
984
+ changedBenefits: z.ZodOptional<z.ZodArray<z.ZodString>>;
985
+ archivedBenefits: z.ZodOptional<z.ZodArray<z.ZodString>>;
986
+ updatedPrices: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
987
+ changedMeters: z.ZodOptional<z.ZodArray<z.ZodString>>;
988
+ archivedMeters: z.ZodOptional<z.ZodArray<z.ZodString>>;
989
+ createdMeteredPrices: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
990
+ updatedMeteredPrices: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
991
+ deactivatedMeteredPrices: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
195
992
  }, z.core.$strip>;
196
993
  type CatalogSyncResult = z.infer<typeof CatalogSyncResultSchema>;
197
994
  /** `POST /v1/admin/accounts/refresh` — ürünün tüm hesaplarının snapshot'ı yeniden hesaplanır. */
@@ -201,6 +998,16 @@ declare const AccountsRefreshResultSchema: z.ZodObject<{
201
998
  type AccountsRefreshResult = z.infer<typeof AccountsRefreshResultSchema>;
202
999
  //#endregion
203
1000
  //#region ../contract/src/checkout.d.ts
1001
+ /**
1002
+ * Identity number sent to the payment provider (and, when the invoice needs one, used on the
1003
+ * invoice) for an INDIVIDUAL buyer (M31): steward never asks for or stores a TCKN; the Turkish
1004
+ * "final consumer" placeholder goes instead. A company buyer's VKN comes from the billing profile.
1005
+ *
1006
+ * It deliberately FAILS the TCKN checksum (`isValidTckn("11111111111") === false`): never run it
1007
+ * through a TCKN validator and never show it as a customer's TCKN. Kept here, not in a provider
1008
+ * adapter, because another provider may need a different rule.
1009
+ */
1010
+ declare const INDIVIDUAL_IDENTITY_PLACEHOLDER = "11111111111";
204
1011
  /** Accepted document — content lives in the product, steward keeps only the trace. */
205
1012
  declare const ConsentSchema: z.ZodObject<{
206
1013
  document: z.ZodString;
@@ -397,6 +1204,7 @@ declare const CheckoutSessionCreatedSchema: z.ZodObject<{
397
1204
  year: "year";
398
1205
  }>;
399
1206
  effectiveAt: z.ZodISODateTime;
1207
+ amountMinor: z.ZodOptional<z.ZodNumber>;
400
1208
  }, z.core.$strip>>;
401
1209
  }, z.core.$strip>>;
402
1210
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -418,12 +1226,77 @@ declare const CheckoutSessionCreatedSchema: z.ZodObject<{
418
1226
  company: "company";
419
1227
  }>>;
420
1228
  }, z.core.$strip>;
1229
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
1230
+ id: z.ZodUUID;
1231
+ status: z.ZodEnum<{
1232
+ active: "active";
1233
+ suspended: "suspended";
1234
+ past_due: "past_due";
1235
+ canceled: "canceled";
1236
+ expired: "expired";
1237
+ }>;
1238
+ planCode: z.ZodString;
1239
+ interval: z.ZodEnum<{
1240
+ month: "month";
1241
+ year: "year";
1242
+ }>;
1243
+ amountMinor: z.ZodNumber;
1244
+ currency: z.ZodString;
1245
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
1246
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
1247
+ cancelAtPeriodEnd: z.ZodBoolean;
1248
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
1249
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
1250
+ dunning: z.ZodNullable<z.ZodObject<{
1251
+ step: z.ZodNumber;
1252
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
1253
+ }, z.core.$strip>>;
1254
+ scheduledChange: z.ZodNullable<z.ZodObject<{
1255
+ planCode: z.ZodString;
1256
+ interval: z.ZodEnum<{
1257
+ month: "month";
1258
+ year: "year";
1259
+ }>;
1260
+ effectiveAt: z.ZodISODateTime;
1261
+ amountMinor: z.ZodOptional<z.ZodNumber>;
1262
+ }, z.core.$strip>>;
1263
+ }, z.core.$strip>>>;
1264
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
1265
+ id: z.ZodUUID;
1266
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
1267
+ billingReason: z.ZodEnum<{
1268
+ subscription_create: "subscription_create";
1269
+ subscription_cycle: "subscription_cycle";
1270
+ subscription_update: "subscription_update";
1271
+ purchase: "purchase";
1272
+ manual: "manual";
1273
+ }>;
1274
+ totalMinor: z.ZodNumber;
1275
+ currency: z.ZodString;
1276
+ dueAt: z.ZodISODateTime;
1277
+ }, z.core.$strip>>>;
1278
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
1279
+ code: z.ZodNullable<z.ZodString>;
1280
+ type: z.ZodString;
1281
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1282
+ source: z.ZodString;
1283
+ grantedAt: z.ZodISODateTime;
1284
+ }, z.core.$strip>>>;
1285
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
1286
+ includedUnits: z.ZodNullable<z.ZodNumber>;
1287
+ billable: z.ZodBoolean;
1288
+ standing: z.ZodEnum<{
1289
+ ok: "ok";
1290
+ low: "low";
1291
+ exhausted: "exhausted";
1292
+ }>;
1293
+ }, z.core.$strip>>>;
421
1294
  }, z.core.$strip>>;
422
1295
  }, z.core.$strip>;
423
1296
  type CheckoutSessionCreated = z.infer<typeof CheckoutSessionCreatedSchema>;
424
1297
  /** `STATUS` value of the outcome redirect (`{STATUS}` placeholder in `successUrl`). */
425
1298
  type CheckoutReturnStatus = "success" | "failed" | "pending";
426
- /** Redirect input: the stored session fields (service row, fake steward record). */
1299
+ /** Redirect input: the stored session fields (service row). */
427
1300
  type CheckoutRedirectTarget = {
428
1301
  id: string;
429
1302
  successUrl: string;
@@ -431,14 +1304,14 @@ type CheckoutRedirectTarget = {
431
1304
  accountRef: string;
432
1305
  };
433
1306
  /**
434
- * Browser redirect for a checkout outcome — the service and the fake steward share it.
1307
+ * Browser redirect for a checkout outcome — used by the service.
435
1308
  * Placeholders in `successUrl` (`{CHECKOUT_ID}` `{STATUS}` `{ACCOUNT_REF}` `{LOCALE}`) are
436
1309
  * filled with URL-encoded values; nothing is appended, so a URL without placeholders is used
437
1310
  * as-is. An encoded value cannot change the origin; it is still checked, and if the origin
438
1311
  * would change the URL is returned unfilled.
439
1312
  */
440
1313
  declare function checkoutRedirectUrl(target: CheckoutRedirectTarget, status: CheckoutReturnStatus): string;
441
- declare const CHECKOUT_ERRORS: readonly ["account_not_found", "already_subscribed", "plan_not_sellable", "return_url_not_allowed", "provider_not_configured", "provider_error", "account_deleted"];
1314
+ declare const CHECKOUT_ERRORS: readonly ["account_not_found", "already_subscribed", "plan_not_sellable", "return_url_not_allowed", "provider_not_configured", "provider_error", "account_deleted", "meter_already_billed"];
442
1315
  type CheckoutError = (typeof CHECKOUT_ERRORS)[number];
443
1316
  //#endregion
444
1317
  //#region ../contract/src/portal.d.ts
@@ -500,6 +1373,32 @@ declare const CancelSubscriptionInputSchema: z.ZodObject<{
500
1373
  skipProvider: z.ZodDefault<z.ZodBoolean>;
501
1374
  }, z.core.$strip>;
502
1375
  type CancelSubscriptionInput = z.input<typeof CancelSubscriptionInputSchema>;
1376
+ /**
1377
+ * `POST /v1/subscriptions/{id}/change` (billing core MF9): schedule a change for the next period
1378
+ * boundary (`AccountState.subscription.scheduledChange`); the next renewal invoice is written from
1379
+ * the new terms. `planCode` / `interval` pick another price of the subscription's currency;
1380
+ * `price: "current"` re-locks the current amount of the (possibly updated) price and the plan's
1381
+ * current metered rates — a metered price added later is attached only this way (M20, M36). At
1382
+ * least one of the three. `when` is required so other timings can be added later. A second change
1383
+ * replaces the first; asking for the current plan and interval while a change is pending takes it
1384
+ * back ("keep my plan"; a move to the current price the operator announced stays).
1385
+ * Errors: 404 `subscription_not_found`; 409 `already_subscribed` (another live subscription of the
1386
+ * account holds the target plan or is moving to it), `meter_already_billed` (the target prices a
1387
+ * meter another live subscription bills; for `price: "current"` only when that is the only
1388
+ * difference); 422 `plan_not_found`, `plan_not_sellable`, `subscription_change_invalid` (no such
1389
+ * price, nothing changes, the subscription is not live, has a cancellation scheduled or is a legacy
1390
+ * provider subscription).
1391
+ */
1392
+ declare const SubscriptionChangeInputSchema: z.ZodObject<{
1393
+ planCode: z.ZodOptional<z.ZodString>;
1394
+ interval: z.ZodOptional<z.ZodEnum<{
1395
+ month: "month";
1396
+ year: "year";
1397
+ }>>;
1398
+ price: z.ZodOptional<z.ZodLiteral<"current">>;
1399
+ when: z.ZodLiteral<"next_period">;
1400
+ }, z.core.$strip>;
1401
+ type SubscriptionChangeInput = z.input<typeof SubscriptionChangeInputSchema>;
503
1402
  declare const PaymentSchema: z.ZodObject<{
504
1403
  id: z.ZodUUID;
505
1404
  subscriptionId: z.ZodUUID;
@@ -515,9 +1414,12 @@ declare const PaymentSchema: z.ZodObject<{
515
1414
  occurredAt: z.ZodISODateTime;
516
1415
  }, z.core.$strip>;
517
1416
  type Payment = z.infer<typeof PaymentSchema>;
1417
+ /** Upper bound of named benefits in one grant. */
1418
+ declare const MAX_GRANT_BENEFITS = 100;
518
1419
  declare const GrantCreateInputSchema: z.ZodObject<{
519
1420
  planCode: z.ZodOptional<z.ZodString>;
520
1421
  overrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>>;
1422
+ benefitCodes: z.ZodOptional<z.ZodArray<z.ZodString>>;
521
1423
  reason: z.ZodString;
522
1424
  startsAt: z.ZodOptional<z.ZodISODateTime>;
523
1425
  endsAt: z.ZodOptional<z.ZodISODateTime>;
@@ -528,6 +1430,7 @@ declare const GrantSchema: z.ZodObject<{
528
1430
  accountRef: z.ZodString;
529
1431
  planCode: z.ZodNullable<z.ZodString>;
530
1432
  overrides: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
1433
+ benefitCodes: z.ZodOptional<z.ZodArray<z.ZodString>>;
531
1434
  reason: z.ZodString;
532
1435
  actorRef: z.ZodNullable<z.ZodString>;
533
1436
  startsAt: z.ZodISODateTime;
@@ -560,6 +1463,10 @@ declare const InvoiceLineSchema: z.ZodObject<{
560
1463
  quantity: z.ZodNumber;
561
1464
  unitAmountMinor: z.ZodNumber;
562
1465
  amountMinor: z.ZodNumber;
1466
+ meter: z.ZodOptional<z.ZodString>;
1467
+ units: z.ZodOptional<z.ZodString>;
1468
+ priceAmountMinor: z.ZodOptional<z.ZodNumber>;
1469
+ pricePerUnits: z.ZodOptional<z.ZodNumber>;
563
1470
  }, z.core.$strip>;
564
1471
  type InvoiceLine = z.infer<typeof InvoiceLineSchema>;
565
1472
  declare const InvoiceSchema: z.ZodObject<{
@@ -598,6 +1505,10 @@ declare const InvoiceSchema: z.ZodObject<{
598
1505
  quantity: z.ZodNumber;
599
1506
  unitAmountMinor: z.ZodNumber;
600
1507
  amountMinor: z.ZodNumber;
1508
+ meter: z.ZodOptional<z.ZodString>;
1509
+ units: z.ZodOptional<z.ZodString>;
1510
+ priceAmountMinor: z.ZodOptional<z.ZodNumber>;
1511
+ pricePerUnits: z.ZodOptional<z.ZodNumber>;
601
1512
  }, z.core.$strip>>;
602
1513
  issuer: z.ZodString;
603
1514
  externalRef: z.ZodNullable<z.ZodString>;
@@ -608,6 +1519,21 @@ declare const InvoiceSchema: z.ZodObject<{
608
1519
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
609
1520
  voidedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
610
1521
  voidReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1522
+ billingReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
1523
+ subscription_create: "subscription_create";
1524
+ subscription_cycle: "subscription_cycle";
1525
+ subscription_update: "subscription_update";
1526
+ purchase: "purchase";
1527
+ manual: "manual";
1528
+ }>>>;
1529
+ paymentStatus: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
1530
+ unpaid: "unpaid";
1531
+ paid: "paid";
1532
+ uncollectible: "uncollectible";
1533
+ waived: "waived";
1534
+ }>>>;
1535
+ periodStart: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1536
+ periodEnd: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
611
1537
  }, z.core.$strip>;
612
1538
  type Invoice = z.infer<typeof InvoiceSchema>;
613
1539
  declare const InvoiceIssueInputSchema: z.ZodObject<{
@@ -649,6 +1575,34 @@ declare const InvoiceVoidInputSchema: z.ZodObject<{
649
1575
  reason: z.ZodString;
650
1576
  }, z.core.$strip>;
651
1577
  type InvoiceVoidInput = z.input<typeof InvoiceVoidInputSchema>;
1578
+ /**
1579
+ * `POST /v1/invoices/{id}/payment-sessions` — opens steward's hosted pay page for an unpaid
1580
+ * invoice (the product's own "Pay invoice" button; emails and the portal link to the same page).
1581
+ * 409 `invoice_not_payable` when the invoice is not unpaid.
1582
+ */
1583
+ declare const InvoicePaymentSessionCreateInputSchema: z.ZodObject<{
1584
+ locale: z.ZodOptional<z.ZodEnum<{
1585
+ tr: "tr";
1586
+ en: "en";
1587
+ }>>;
1588
+ returnUrl: z.ZodOptional<z.ZodURL>;
1589
+ }, z.core.$strip>;
1590
+ type InvoicePaymentSessionCreateInput = z.input<typeof InvoicePaymentSessionCreateInputSchema>;
1591
+ /** Pay page session: redirect the customer to `url` (it carries the page key; do not log it). */
1592
+ declare const InvoicePaymentSessionSchema: z.ZodObject<{
1593
+ id: z.ZodUUID;
1594
+ url: z.ZodString;
1595
+ expiresAt: z.ZodISODateTime;
1596
+ }, z.core.$strip>;
1597
+ type InvoicePaymentSession = z.infer<typeof InvoicePaymentSessionSchema>;
1598
+ /**
1599
+ * `POST /v1/invoices/{id}/waive` — an operator forgives an unpaid invoice (`paymentStatus:
1600
+ * "waived"`, e.g. before deleting the account). 409 `invoice_not_waivable` otherwise.
1601
+ */
1602
+ declare const InvoiceWaiveInputSchema: z.ZodObject<{
1603
+ reason: z.ZodString;
1604
+ }, z.core.$strip>;
1605
+ type InvoiceWaiveInput = z.input<typeof InvoiceWaiveInputSchema>;
652
1606
  /**
653
1607
  * Vergi dahil tutardan matrah ve vergiyi ayrıştırır (tam sayı, kuruşa
654
1608
  * yuvarlama). Toplam her zaman korunur: subtotal + tax === total.
@@ -850,6 +1804,10 @@ declare const AccountDetailSchema: z.ZodObject<{
850
1804
  quantity: z.ZodNumber;
851
1805
  unitAmountMinor: z.ZodNumber;
852
1806
  amountMinor: z.ZodNumber;
1807
+ meter: z.ZodOptional<z.ZodString>;
1808
+ units: z.ZodOptional<z.ZodString>;
1809
+ priceAmountMinor: z.ZodOptional<z.ZodNumber>;
1810
+ pricePerUnits: z.ZodOptional<z.ZodNumber>;
853
1811
  }, z.core.$strip>>;
854
1812
  issuer: z.ZodString;
855
1813
  externalRef: z.ZodNullable<z.ZodString>;
@@ -860,12 +1818,28 @@ declare const AccountDetailSchema: z.ZodObject<{
860
1818
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
861
1819
  voidedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
862
1820
  voidReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1821
+ billingReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
1822
+ subscription_create: "subscription_create";
1823
+ subscription_cycle: "subscription_cycle";
1824
+ subscription_update: "subscription_update";
1825
+ purchase: "purchase";
1826
+ manual: "manual";
1827
+ }>>>;
1828
+ paymentStatus: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
1829
+ unpaid: "unpaid";
1830
+ paid: "paid";
1831
+ uncollectible: "uncollectible";
1832
+ waived: "waived";
1833
+ }>>>;
1834
+ periodStart: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1835
+ periodEnd: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
863
1836
  }, z.core.$strip>>>;
864
1837
  grants: z.ZodOptional<z.ZodArray<z.ZodObject<{
865
1838
  id: z.ZodUUID;
866
1839
  accountRef: z.ZodString;
867
1840
  planCode: z.ZodNullable<z.ZodString>;
868
1841
  overrides: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
1842
+ benefitCodes: z.ZodOptional<z.ZodArray<z.ZodString>>;
869
1843
  reason: z.ZodString;
870
1844
  actorRef: z.ZodNullable<z.ZodString>;
871
1845
  startsAt: z.ZodISODateTime;
@@ -958,6 +1932,7 @@ declare const AccountUpsertResponseSchema: z.ZodObject<{
958
1932
  year: "year";
959
1933
  }>;
960
1934
  effectiveAt: z.ZodISODateTime;
1935
+ amountMinor: z.ZodOptional<z.ZodNumber>;
961
1936
  }, z.core.$strip>>;
962
1937
  }, z.core.$strip>>;
963
1938
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -979,6 +1954,71 @@ declare const AccountUpsertResponseSchema: z.ZodObject<{
979
1954
  company: "company";
980
1955
  }>>;
981
1956
  }, z.core.$strip>;
1957
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
1958
+ id: z.ZodUUID;
1959
+ status: z.ZodEnum<{
1960
+ active: "active";
1961
+ suspended: "suspended";
1962
+ past_due: "past_due";
1963
+ canceled: "canceled";
1964
+ expired: "expired";
1965
+ }>;
1966
+ planCode: z.ZodString;
1967
+ interval: z.ZodEnum<{
1968
+ month: "month";
1969
+ year: "year";
1970
+ }>;
1971
+ amountMinor: z.ZodNumber;
1972
+ currency: z.ZodString;
1973
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
1974
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
1975
+ cancelAtPeriodEnd: z.ZodBoolean;
1976
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
1977
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
1978
+ dunning: z.ZodNullable<z.ZodObject<{
1979
+ step: z.ZodNumber;
1980
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
1981
+ }, z.core.$strip>>;
1982
+ scheduledChange: z.ZodNullable<z.ZodObject<{
1983
+ planCode: z.ZodString;
1984
+ interval: z.ZodEnum<{
1985
+ month: "month";
1986
+ year: "year";
1987
+ }>;
1988
+ effectiveAt: z.ZodISODateTime;
1989
+ amountMinor: z.ZodOptional<z.ZodNumber>;
1990
+ }, z.core.$strip>>;
1991
+ }, z.core.$strip>>>;
1992
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
1993
+ id: z.ZodUUID;
1994
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
1995
+ billingReason: z.ZodEnum<{
1996
+ subscription_create: "subscription_create";
1997
+ subscription_cycle: "subscription_cycle";
1998
+ subscription_update: "subscription_update";
1999
+ purchase: "purchase";
2000
+ manual: "manual";
2001
+ }>;
2002
+ totalMinor: z.ZodNumber;
2003
+ currency: z.ZodString;
2004
+ dueAt: z.ZodISODateTime;
2005
+ }, z.core.$strip>>>;
2006
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
2007
+ code: z.ZodNullable<z.ZodString>;
2008
+ type: z.ZodString;
2009
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2010
+ source: z.ZodString;
2011
+ grantedAt: z.ZodISODateTime;
2012
+ }, z.core.$strip>>>;
2013
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
2014
+ includedUnits: z.ZodNullable<z.ZodNumber>;
2015
+ billable: z.ZodBoolean;
2016
+ standing: z.ZodEnum<{
2017
+ ok: "ok";
2018
+ low: "low";
2019
+ exhausted: "exhausted";
2020
+ }>;
2021
+ }, z.core.$strip>>>;
982
2022
  }, z.core.$strip>>;
983
2023
  }, z.core.$strip>;
984
2024
  type AccountUpsertResponse = z.infer<typeof AccountUpsertResponseSchema>;
@@ -988,6 +2028,7 @@ declare const GrantCreateResponseSchema: z.ZodObject<{
988
2028
  accountRef: z.ZodString;
989
2029
  planCode: z.ZodNullable<z.ZodString>;
990
2030
  overrides: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
2031
+ benefitCodes: z.ZodOptional<z.ZodArray<z.ZodString>>;
991
2032
  reason: z.ZodString;
992
2033
  actorRef: z.ZodNullable<z.ZodString>;
993
2034
  startsAt: z.ZodISODateTime;
@@ -1038,6 +2079,7 @@ declare const GrantCreateResponseSchema: z.ZodObject<{
1038
2079
  year: "year";
1039
2080
  }>;
1040
2081
  effectiveAt: z.ZodISODateTime;
2082
+ amountMinor: z.ZodOptional<z.ZodNumber>;
1041
2083
  }, z.core.$strip>>;
1042
2084
  }, z.core.$strip>>;
1043
2085
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -1059,6 +2101,71 @@ declare const GrantCreateResponseSchema: z.ZodObject<{
1059
2101
  company: "company";
1060
2102
  }>>;
1061
2103
  }, z.core.$strip>;
2104
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
2105
+ id: z.ZodUUID;
2106
+ status: z.ZodEnum<{
2107
+ active: "active";
2108
+ suspended: "suspended";
2109
+ past_due: "past_due";
2110
+ canceled: "canceled";
2111
+ expired: "expired";
2112
+ }>;
2113
+ planCode: z.ZodString;
2114
+ interval: z.ZodEnum<{
2115
+ month: "month";
2116
+ year: "year";
2117
+ }>;
2118
+ amountMinor: z.ZodNumber;
2119
+ currency: z.ZodString;
2120
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
2121
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
2122
+ cancelAtPeriodEnd: z.ZodBoolean;
2123
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
2124
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
2125
+ dunning: z.ZodNullable<z.ZodObject<{
2126
+ step: z.ZodNumber;
2127
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
2128
+ }, z.core.$strip>>;
2129
+ scheduledChange: z.ZodNullable<z.ZodObject<{
2130
+ planCode: z.ZodString;
2131
+ interval: z.ZodEnum<{
2132
+ month: "month";
2133
+ year: "year";
2134
+ }>;
2135
+ effectiveAt: z.ZodISODateTime;
2136
+ amountMinor: z.ZodOptional<z.ZodNumber>;
2137
+ }, z.core.$strip>>;
2138
+ }, z.core.$strip>>>;
2139
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
2140
+ id: z.ZodUUID;
2141
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
2142
+ billingReason: z.ZodEnum<{
2143
+ subscription_create: "subscription_create";
2144
+ subscription_cycle: "subscription_cycle";
2145
+ subscription_update: "subscription_update";
2146
+ purchase: "purchase";
2147
+ manual: "manual";
2148
+ }>;
2149
+ totalMinor: z.ZodNumber;
2150
+ currency: z.ZodString;
2151
+ dueAt: z.ZodISODateTime;
2152
+ }, z.core.$strip>>>;
2153
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
2154
+ code: z.ZodNullable<z.ZodString>;
2155
+ type: z.ZodString;
2156
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2157
+ source: z.ZodString;
2158
+ grantedAt: z.ZodISODateTime;
2159
+ }, z.core.$strip>>>;
2160
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
2161
+ includedUnits: z.ZodNullable<z.ZodNumber>;
2162
+ billable: z.ZodBoolean;
2163
+ standing: z.ZodEnum<{
2164
+ ok: "ok";
2165
+ low: "low";
2166
+ exhausted: "exhausted";
2167
+ }>;
2168
+ }, z.core.$strip>>>;
1062
2169
  }, z.core.$strip>>;
1063
2170
  }, z.core.$strip>;
1064
2171
  type GrantCreateResponse = z.infer<typeof GrantCreateResponseSchema>;
@@ -1135,6 +2242,7 @@ declare const CancelSubscriptionResponseSchema: z.ZodObject<{
1135
2242
  year: "year";
1136
2243
  }>;
1137
2244
  effectiveAt: z.ZodISODateTime;
2245
+ amountMinor: z.ZodOptional<z.ZodNumber>;
1138
2246
  }, z.core.$strip>>;
1139
2247
  }, z.core.$strip>>;
1140
2248
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -1156,6 +2264,71 @@ declare const CancelSubscriptionResponseSchema: z.ZodObject<{
1156
2264
  company: "company";
1157
2265
  }>>;
1158
2266
  }, z.core.$strip>;
2267
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
2268
+ id: z.ZodUUID;
2269
+ status: z.ZodEnum<{
2270
+ active: "active";
2271
+ suspended: "suspended";
2272
+ past_due: "past_due";
2273
+ canceled: "canceled";
2274
+ expired: "expired";
2275
+ }>;
2276
+ planCode: z.ZodString;
2277
+ interval: z.ZodEnum<{
2278
+ month: "month";
2279
+ year: "year";
2280
+ }>;
2281
+ amountMinor: z.ZodNumber;
2282
+ currency: z.ZodString;
2283
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
2284
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
2285
+ cancelAtPeriodEnd: z.ZodBoolean;
2286
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
2287
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
2288
+ dunning: z.ZodNullable<z.ZodObject<{
2289
+ step: z.ZodNumber;
2290
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
2291
+ }, z.core.$strip>>;
2292
+ scheduledChange: z.ZodNullable<z.ZodObject<{
2293
+ planCode: z.ZodString;
2294
+ interval: z.ZodEnum<{
2295
+ month: "month";
2296
+ year: "year";
2297
+ }>;
2298
+ effectiveAt: z.ZodISODateTime;
2299
+ amountMinor: z.ZodOptional<z.ZodNumber>;
2300
+ }, z.core.$strip>>;
2301
+ }, z.core.$strip>>>;
2302
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
2303
+ id: z.ZodUUID;
2304
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
2305
+ billingReason: z.ZodEnum<{
2306
+ subscription_create: "subscription_create";
2307
+ subscription_cycle: "subscription_cycle";
2308
+ subscription_update: "subscription_update";
2309
+ purchase: "purchase";
2310
+ manual: "manual";
2311
+ }>;
2312
+ totalMinor: z.ZodNumber;
2313
+ currency: z.ZodString;
2314
+ dueAt: z.ZodISODateTime;
2315
+ }, z.core.$strip>>>;
2316
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
2317
+ code: z.ZodNullable<z.ZodString>;
2318
+ type: z.ZodString;
2319
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2320
+ source: z.ZodString;
2321
+ grantedAt: z.ZodISODateTime;
2322
+ }, z.core.$strip>>>;
2323
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
2324
+ includedUnits: z.ZodNullable<z.ZodNumber>;
2325
+ billable: z.ZodBoolean;
2326
+ standing: z.ZodEnum<{
2327
+ ok: "ok";
2328
+ low: "low";
2329
+ exhausted: "exhausted";
2330
+ }>;
2331
+ }, z.core.$strip>>>;
1159
2332
  }, z.core.$strip>>;
1160
2333
  }, z.core.$strip>;
1161
2334
  type CancelSubscriptionResponse = z.infer<typeof CancelSubscriptionResponseSchema>;
@@ -1196,6 +2369,10 @@ declare const InvoiceIssueResponseSchema: z.ZodObject<{
1196
2369
  quantity: z.ZodNumber;
1197
2370
  unitAmountMinor: z.ZodNumber;
1198
2371
  amountMinor: z.ZodNumber;
2372
+ meter: z.ZodOptional<z.ZodString>;
2373
+ units: z.ZodOptional<z.ZodString>;
2374
+ priceAmountMinor: z.ZodOptional<z.ZodNumber>;
2375
+ pricePerUnits: z.ZodOptional<z.ZodNumber>;
1199
2376
  }, z.core.$strip>>;
1200
2377
  issuer: z.ZodString;
1201
2378
  externalRef: z.ZodNullable<z.ZodString>;
@@ -1206,6 +2383,21 @@ declare const InvoiceIssueResponseSchema: z.ZodObject<{
1206
2383
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1207
2384
  voidedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1208
2385
  voidReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2386
+ billingReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
2387
+ subscription_create: "subscription_create";
2388
+ subscription_cycle: "subscription_cycle";
2389
+ subscription_update: "subscription_update";
2390
+ purchase: "purchase";
2391
+ manual: "manual";
2392
+ }>>>;
2393
+ paymentStatus: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
2394
+ unpaid: "unpaid";
2395
+ paid: "paid";
2396
+ uncollectible: "uncollectible";
2397
+ waived: "waived";
2398
+ }>>>;
2399
+ periodStart: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
2400
+ periodEnd: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1209
2401
  account: z.ZodOptional<z.ZodObject<{
1210
2402
  version: z.ZodNumber;
1211
2403
  planCode: z.ZodString;
@@ -1250,6 +2442,7 @@ declare const InvoiceIssueResponseSchema: z.ZodObject<{
1250
2442
  year: "year";
1251
2443
  }>;
1252
2444
  effectiveAt: z.ZodISODateTime;
2445
+ amountMinor: z.ZodOptional<z.ZodNumber>;
1253
2446
  }, z.core.$strip>>;
1254
2447
  }, z.core.$strip>>;
1255
2448
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -1271,6 +2464,71 @@ declare const InvoiceIssueResponseSchema: z.ZodObject<{
1271
2464
  company: "company";
1272
2465
  }>>;
1273
2466
  }, z.core.$strip>;
2467
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
2468
+ id: z.ZodUUID;
2469
+ status: z.ZodEnum<{
2470
+ active: "active";
2471
+ suspended: "suspended";
2472
+ past_due: "past_due";
2473
+ canceled: "canceled";
2474
+ expired: "expired";
2475
+ }>;
2476
+ planCode: z.ZodString;
2477
+ interval: z.ZodEnum<{
2478
+ month: "month";
2479
+ year: "year";
2480
+ }>;
2481
+ amountMinor: z.ZodNumber;
2482
+ currency: z.ZodString;
2483
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
2484
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
2485
+ cancelAtPeriodEnd: z.ZodBoolean;
2486
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
2487
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
2488
+ dunning: z.ZodNullable<z.ZodObject<{
2489
+ step: z.ZodNumber;
2490
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
2491
+ }, z.core.$strip>>;
2492
+ scheduledChange: z.ZodNullable<z.ZodObject<{
2493
+ planCode: z.ZodString;
2494
+ interval: z.ZodEnum<{
2495
+ month: "month";
2496
+ year: "year";
2497
+ }>;
2498
+ effectiveAt: z.ZodISODateTime;
2499
+ amountMinor: z.ZodOptional<z.ZodNumber>;
2500
+ }, z.core.$strip>>;
2501
+ }, z.core.$strip>>>;
2502
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
2503
+ id: z.ZodUUID;
2504
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
2505
+ billingReason: z.ZodEnum<{
2506
+ subscription_create: "subscription_create";
2507
+ subscription_cycle: "subscription_cycle";
2508
+ subscription_update: "subscription_update";
2509
+ purchase: "purchase";
2510
+ manual: "manual";
2511
+ }>;
2512
+ totalMinor: z.ZodNumber;
2513
+ currency: z.ZodString;
2514
+ dueAt: z.ZodISODateTime;
2515
+ }, z.core.$strip>>>;
2516
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
2517
+ code: z.ZodNullable<z.ZodString>;
2518
+ type: z.ZodString;
2519
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2520
+ source: z.ZodString;
2521
+ grantedAt: z.ZodISODateTime;
2522
+ }, z.core.$strip>>>;
2523
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
2524
+ includedUnits: z.ZodNullable<z.ZodNumber>;
2525
+ billable: z.ZodBoolean;
2526
+ standing: z.ZodEnum<{
2527
+ ok: "ok";
2528
+ low: "low";
2529
+ exhausted: "exhausted";
2530
+ }>;
2531
+ }, z.core.$strip>>>;
1274
2532
  }, z.core.$strip>>;
1275
2533
  }, z.core.$strip>;
1276
2534
  type InvoiceIssueResponse = z.infer<typeof InvoiceIssueResponseSchema>;
@@ -1311,6 +2569,10 @@ declare const ManualInvoiceResponseSchema: z.ZodObject<{
1311
2569
  quantity: z.ZodNumber;
1312
2570
  unitAmountMinor: z.ZodNumber;
1313
2571
  amountMinor: z.ZodNumber;
2572
+ meter: z.ZodOptional<z.ZodString>;
2573
+ units: z.ZodOptional<z.ZodString>;
2574
+ priceAmountMinor: z.ZodOptional<z.ZodNumber>;
2575
+ pricePerUnits: z.ZodOptional<z.ZodNumber>;
1314
2576
  }, z.core.$strip>>;
1315
2577
  issuer: z.ZodString;
1316
2578
  externalRef: z.ZodNullable<z.ZodString>;
@@ -1321,6 +2583,21 @@ declare const ManualInvoiceResponseSchema: z.ZodObject<{
1321
2583
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1322
2584
  voidedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1323
2585
  voidReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2586
+ billingReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
2587
+ subscription_create: "subscription_create";
2588
+ subscription_cycle: "subscription_cycle";
2589
+ subscription_update: "subscription_update";
2590
+ purchase: "purchase";
2591
+ manual: "manual";
2592
+ }>>>;
2593
+ paymentStatus: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
2594
+ unpaid: "unpaid";
2595
+ paid: "paid";
2596
+ uncollectible: "uncollectible";
2597
+ waived: "waived";
2598
+ }>>>;
2599
+ periodStart: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
2600
+ periodEnd: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1324
2601
  account: z.ZodOptional<z.ZodObject<{
1325
2602
  version: z.ZodNumber;
1326
2603
  planCode: z.ZodString;
@@ -1365,6 +2642,7 @@ declare const ManualInvoiceResponseSchema: z.ZodObject<{
1365
2642
  year: "year";
1366
2643
  }>;
1367
2644
  effectiveAt: z.ZodISODateTime;
2645
+ amountMinor: z.ZodOptional<z.ZodNumber>;
1368
2646
  }, z.core.$strip>>;
1369
2647
  }, z.core.$strip>>;
1370
2648
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -1386,6 +2664,71 @@ declare const ManualInvoiceResponseSchema: z.ZodObject<{
1386
2664
  company: "company";
1387
2665
  }>>;
1388
2666
  }, z.core.$strip>;
2667
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
2668
+ id: z.ZodUUID;
2669
+ status: z.ZodEnum<{
2670
+ active: "active";
2671
+ suspended: "suspended";
2672
+ past_due: "past_due";
2673
+ canceled: "canceled";
2674
+ expired: "expired";
2675
+ }>;
2676
+ planCode: z.ZodString;
2677
+ interval: z.ZodEnum<{
2678
+ month: "month";
2679
+ year: "year";
2680
+ }>;
2681
+ amountMinor: z.ZodNumber;
2682
+ currency: z.ZodString;
2683
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
2684
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
2685
+ cancelAtPeriodEnd: z.ZodBoolean;
2686
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
2687
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
2688
+ dunning: z.ZodNullable<z.ZodObject<{
2689
+ step: z.ZodNumber;
2690
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
2691
+ }, z.core.$strip>>;
2692
+ scheduledChange: z.ZodNullable<z.ZodObject<{
2693
+ planCode: z.ZodString;
2694
+ interval: z.ZodEnum<{
2695
+ month: "month";
2696
+ year: "year";
2697
+ }>;
2698
+ effectiveAt: z.ZodISODateTime;
2699
+ amountMinor: z.ZodOptional<z.ZodNumber>;
2700
+ }, z.core.$strip>>;
2701
+ }, z.core.$strip>>>;
2702
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
2703
+ id: z.ZodUUID;
2704
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
2705
+ billingReason: z.ZodEnum<{
2706
+ subscription_create: "subscription_create";
2707
+ subscription_cycle: "subscription_cycle";
2708
+ subscription_update: "subscription_update";
2709
+ purchase: "purchase";
2710
+ manual: "manual";
2711
+ }>;
2712
+ totalMinor: z.ZodNumber;
2713
+ currency: z.ZodString;
2714
+ dueAt: z.ZodISODateTime;
2715
+ }, z.core.$strip>>>;
2716
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
2717
+ code: z.ZodNullable<z.ZodString>;
2718
+ type: z.ZodString;
2719
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2720
+ source: z.ZodString;
2721
+ grantedAt: z.ZodISODateTime;
2722
+ }, z.core.$strip>>>;
2723
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
2724
+ includedUnits: z.ZodNullable<z.ZodNumber>;
2725
+ billable: z.ZodBoolean;
2726
+ standing: z.ZodEnum<{
2727
+ ok: "ok";
2728
+ low: "low";
2729
+ exhausted: "exhausted";
2730
+ }>;
2731
+ }, z.core.$strip>>>;
1389
2732
  }, z.core.$strip>>;
1390
2733
  }, z.core.$strip>;
1391
2734
  type ManualInvoiceResponse = z.infer<typeof ManualInvoiceResponseSchema>;
@@ -1426,6 +2769,10 @@ declare const InvoiceVoidResponseSchema: z.ZodObject<{
1426
2769
  quantity: z.ZodNumber;
1427
2770
  unitAmountMinor: z.ZodNumber;
1428
2771
  amountMinor: z.ZodNumber;
2772
+ meter: z.ZodOptional<z.ZodString>;
2773
+ units: z.ZodOptional<z.ZodString>;
2774
+ priceAmountMinor: z.ZodOptional<z.ZodNumber>;
2775
+ pricePerUnits: z.ZodOptional<z.ZodNumber>;
1429
2776
  }, z.core.$strip>>;
1430
2777
  issuer: z.ZodString;
1431
2778
  externalRef: z.ZodNullable<z.ZodString>;
@@ -1436,6 +2783,21 @@ declare const InvoiceVoidResponseSchema: z.ZodObject<{
1436
2783
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1437
2784
  voidedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1438
2785
  voidReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2786
+ billingReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
2787
+ subscription_create: "subscription_create";
2788
+ subscription_cycle: "subscription_cycle";
2789
+ subscription_update: "subscription_update";
2790
+ purchase: "purchase";
2791
+ manual: "manual";
2792
+ }>>>;
2793
+ paymentStatus: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
2794
+ unpaid: "unpaid";
2795
+ paid: "paid";
2796
+ uncollectible: "uncollectible";
2797
+ waived: "waived";
2798
+ }>>>;
2799
+ periodStart: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
2800
+ periodEnd: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
1439
2801
  account: z.ZodOptional<z.ZodObject<{
1440
2802
  version: z.ZodNumber;
1441
2803
  planCode: z.ZodString;
@@ -1480,6 +2842,7 @@ declare const InvoiceVoidResponseSchema: z.ZodObject<{
1480
2842
  year: "year";
1481
2843
  }>;
1482
2844
  effectiveAt: z.ZodISODateTime;
2845
+ amountMinor: z.ZodOptional<z.ZodNumber>;
1483
2846
  }, z.core.$strip>>;
1484
2847
  }, z.core.$strip>>;
1485
2848
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -1501,6 +2864,71 @@ declare const InvoiceVoidResponseSchema: z.ZodObject<{
1501
2864
  company: "company";
1502
2865
  }>>;
1503
2866
  }, z.core.$strip>;
2867
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
2868
+ id: z.ZodUUID;
2869
+ status: z.ZodEnum<{
2870
+ active: "active";
2871
+ suspended: "suspended";
2872
+ past_due: "past_due";
2873
+ canceled: "canceled";
2874
+ expired: "expired";
2875
+ }>;
2876
+ planCode: z.ZodString;
2877
+ interval: z.ZodEnum<{
2878
+ month: "month";
2879
+ year: "year";
2880
+ }>;
2881
+ amountMinor: z.ZodNumber;
2882
+ currency: z.ZodString;
2883
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
2884
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
2885
+ cancelAtPeriodEnd: z.ZodBoolean;
2886
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
2887
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
2888
+ dunning: z.ZodNullable<z.ZodObject<{
2889
+ step: z.ZodNumber;
2890
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
2891
+ }, z.core.$strip>>;
2892
+ scheduledChange: z.ZodNullable<z.ZodObject<{
2893
+ planCode: z.ZodString;
2894
+ interval: z.ZodEnum<{
2895
+ month: "month";
2896
+ year: "year";
2897
+ }>;
2898
+ effectiveAt: z.ZodISODateTime;
2899
+ amountMinor: z.ZodOptional<z.ZodNumber>;
2900
+ }, z.core.$strip>>;
2901
+ }, z.core.$strip>>>;
2902
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
2903
+ id: z.ZodUUID;
2904
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
2905
+ billingReason: z.ZodEnum<{
2906
+ subscription_create: "subscription_create";
2907
+ subscription_cycle: "subscription_cycle";
2908
+ subscription_update: "subscription_update";
2909
+ purchase: "purchase";
2910
+ manual: "manual";
2911
+ }>;
2912
+ totalMinor: z.ZodNumber;
2913
+ currency: z.ZodString;
2914
+ dueAt: z.ZodISODateTime;
2915
+ }, z.core.$strip>>>;
2916
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
2917
+ code: z.ZodNullable<z.ZodString>;
2918
+ type: z.ZodString;
2919
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2920
+ source: z.ZodString;
2921
+ grantedAt: z.ZodISODateTime;
2922
+ }, z.core.$strip>>>;
2923
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
2924
+ includedUnits: z.ZodNullable<z.ZodNumber>;
2925
+ billable: z.ZodBoolean;
2926
+ standing: z.ZodEnum<{
2927
+ ok: "ok";
2928
+ low: "low";
2929
+ exhausted: "exhausted";
2930
+ }>;
2931
+ }, z.core.$strip>>>;
1504
2932
  }, z.core.$strip>>;
1505
2933
  }, z.core.$strip>;
1506
2934
  type InvoiceVoidResponse = z.infer<typeof InvoiceVoidResponseSchema>;
@@ -1582,6 +3010,7 @@ declare const CheckoutSessionResponseSchema: z.ZodObject<{
1582
3010
  year: "year";
1583
3011
  }>;
1584
3012
  effectiveAt: z.ZodISODateTime;
3013
+ amountMinor: z.ZodOptional<z.ZodNumber>;
1585
3014
  }, z.core.$strip>>;
1586
3015
  }, z.core.$strip>>;
1587
3016
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -1603,22 +3032,812 @@ declare const CheckoutSessionResponseSchema: z.ZodObject<{
1603
3032
  company: "company";
1604
3033
  }>>;
1605
3034
  }, z.core.$strip>;
1606
- }, z.core.$strip>>;
1607
- }, z.core.$strip>;
1608
- type CheckoutSessionResponse = z.infer<typeof CheckoutSessionResponseSchema>;
1609
- /** Değişiklik yapan her istekte zorunlu başlıklar. */
1610
- declare const HEADER_IDEMPOTENCY_KEY = "idempotency-key";
1611
- declare const HEADER_ACTOR_REF = "x-actor-ref";
1612
- declare const HEADER_API_VERSION = "steward-api-version";
1613
- declare const HEADER_SDK = "x-steward-sdk";
1614
- declare const HEADER_REQUEST_ID = "x-request-id";
1615
- //#endregion
1616
- //#region ../contract/src/errors.d.ts
1617
- type ErrorCodeSpec = {
1618
- readonly httpStatus: number;
1619
- readonly category: ErrorCategory;
1620
- readonly retryable: boolean;
1621
- };
3035
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
3036
+ id: z.ZodUUID;
3037
+ status: z.ZodEnum<{
3038
+ active: "active";
3039
+ suspended: "suspended";
3040
+ past_due: "past_due";
3041
+ canceled: "canceled";
3042
+ expired: "expired";
3043
+ }>;
3044
+ planCode: z.ZodString;
3045
+ interval: z.ZodEnum<{
3046
+ month: "month";
3047
+ year: "year";
3048
+ }>;
3049
+ amountMinor: z.ZodNumber;
3050
+ currency: z.ZodString;
3051
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3052
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3053
+ cancelAtPeriodEnd: z.ZodBoolean;
3054
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
3055
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3056
+ dunning: z.ZodNullable<z.ZodObject<{
3057
+ step: z.ZodNumber;
3058
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
3059
+ }, z.core.$strip>>;
3060
+ scheduledChange: z.ZodNullable<z.ZodObject<{
3061
+ planCode: z.ZodString;
3062
+ interval: z.ZodEnum<{
3063
+ month: "month";
3064
+ year: "year";
3065
+ }>;
3066
+ effectiveAt: z.ZodISODateTime;
3067
+ amountMinor: z.ZodOptional<z.ZodNumber>;
3068
+ }, z.core.$strip>>;
3069
+ }, z.core.$strip>>>;
3070
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
3071
+ id: z.ZodUUID;
3072
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
3073
+ billingReason: z.ZodEnum<{
3074
+ subscription_create: "subscription_create";
3075
+ subscription_cycle: "subscription_cycle";
3076
+ subscription_update: "subscription_update";
3077
+ purchase: "purchase";
3078
+ manual: "manual";
3079
+ }>;
3080
+ totalMinor: z.ZodNumber;
3081
+ currency: z.ZodString;
3082
+ dueAt: z.ZodISODateTime;
3083
+ }, z.core.$strip>>>;
3084
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
3085
+ code: z.ZodNullable<z.ZodString>;
3086
+ type: z.ZodString;
3087
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3088
+ source: z.ZodString;
3089
+ grantedAt: z.ZodISODateTime;
3090
+ }, z.core.$strip>>>;
3091
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3092
+ includedUnits: z.ZodNullable<z.ZodNumber>;
3093
+ billable: z.ZodBoolean;
3094
+ standing: z.ZodEnum<{
3095
+ ok: "ok";
3096
+ low: "low";
3097
+ exhausted: "exhausted";
3098
+ }>;
3099
+ }, z.core.$strip>>>;
3100
+ }, z.core.$strip>>;
3101
+ }, z.core.$strip>;
3102
+ type CheckoutSessionResponse = z.infer<typeof CheckoutSessionResponseSchema>;
3103
+ /** `POST /v1/invoices/{id}/waive` (billing core): the waived invoice and the state after it (`openInvoices` shrinks). */
3104
+ declare const InvoiceWaiveResponseSchema: z.ZodObject<{
3105
+ id: z.ZodUUID;
3106
+ accountRef: z.ZodString;
3107
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
3108
+ paymentId: z.ZodNullable<z.ZodUUID>;
3109
+ status: z.ZodEnum<{
3110
+ void: "void";
3111
+ draft: "draft";
3112
+ issued: "issued";
3113
+ }>;
3114
+ number: z.ZodNullable<z.ZodString>;
3115
+ currency: z.ZodString;
3116
+ subtotalMinor: z.ZodNumber;
3117
+ taxMinor: z.ZodNumber;
3118
+ totalMinor: z.ZodNumber;
3119
+ taxRateBps: z.ZodNumber;
3120
+ buyer: z.ZodObject<{
3121
+ kind: z.ZodEnum<{
3122
+ individual: "individual";
3123
+ company: "company";
3124
+ }>;
3125
+ contactName: z.ZodString;
3126
+ companyName: z.ZodOptional<z.ZodString>;
3127
+ taxOffice: z.ZodOptional<z.ZodString>;
3128
+ taxId: z.ZodOptional<z.ZodString>;
3129
+ email: z.ZodEmail;
3130
+ phone: z.ZodString;
3131
+ address: z.ZodString;
3132
+ city: z.ZodString;
3133
+ country: z.ZodDefault<z.ZodString>;
3134
+ }, z.core.$strip>;
3135
+ lines: z.ZodArray<z.ZodObject<{
3136
+ description: z.ZodString;
3137
+ quantity: z.ZodNumber;
3138
+ unitAmountMinor: z.ZodNumber;
3139
+ amountMinor: z.ZodNumber;
3140
+ meter: z.ZodOptional<z.ZodString>;
3141
+ units: z.ZodOptional<z.ZodString>;
3142
+ priceAmountMinor: z.ZodOptional<z.ZodNumber>;
3143
+ pricePerUnits: z.ZodOptional<z.ZodNumber>;
3144
+ }, z.core.$strip>>;
3145
+ issuer: z.ZodString;
3146
+ externalRef: z.ZodNullable<z.ZodString>;
3147
+ hasDocument: z.ZodBoolean;
3148
+ issuedAt: z.ZodNullable<z.ZodISODateTime>;
3149
+ createdAt: z.ZodISODateTime;
3150
+ dueAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
3151
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3152
+ voidedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
3153
+ voidReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3154
+ billingReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
3155
+ subscription_create: "subscription_create";
3156
+ subscription_cycle: "subscription_cycle";
3157
+ subscription_update: "subscription_update";
3158
+ purchase: "purchase";
3159
+ manual: "manual";
3160
+ }>>>;
3161
+ paymentStatus: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
3162
+ unpaid: "unpaid";
3163
+ paid: "paid";
3164
+ uncollectible: "uncollectible";
3165
+ waived: "waived";
3166
+ }>>>;
3167
+ periodStart: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
3168
+ periodEnd: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
3169
+ account: z.ZodOptional<z.ZodObject<{
3170
+ version: z.ZodNumber;
3171
+ planCode: z.ZodString;
3172
+ accessState: z.ZodEnum<{
3173
+ active: "active";
3174
+ suspended: "suspended";
3175
+ }>;
3176
+ entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
3177
+ ref: z.ZodString;
3178
+ displayName: z.ZodString;
3179
+ updatedAt: z.ZodISODateTime;
3180
+ catalogVersion: z.ZodNullable<z.ZodString>;
3181
+ subscription: z.ZodNullable<z.ZodObject<{
3182
+ id: z.ZodUUID;
3183
+ status: z.ZodEnum<{
3184
+ active: "active";
3185
+ suspended: "suspended";
3186
+ past_due: "past_due";
3187
+ canceled: "canceled";
3188
+ expired: "expired";
3189
+ }>;
3190
+ planCode: z.ZodString;
3191
+ interval: z.ZodEnum<{
3192
+ month: "month";
3193
+ year: "year";
3194
+ }>;
3195
+ amountMinor: z.ZodNumber;
3196
+ currency: z.ZodString;
3197
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3198
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3199
+ cancelAtPeriodEnd: z.ZodBoolean;
3200
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
3201
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3202
+ dunning: z.ZodNullable<z.ZodObject<{
3203
+ step: z.ZodNumber;
3204
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
3205
+ }, z.core.$strip>>;
3206
+ scheduledChange: z.ZodNullable<z.ZodObject<{
3207
+ planCode: z.ZodString;
3208
+ interval: z.ZodEnum<{
3209
+ month: "month";
3210
+ year: "year";
3211
+ }>;
3212
+ effectiveAt: z.ZodISODateTime;
3213
+ amountMinor: z.ZodOptional<z.ZodNumber>;
3214
+ }, z.core.$strip>>;
3215
+ }, z.core.$strip>>;
3216
+ openCheckout: z.ZodNullable<z.ZodObject<{
3217
+ id: z.ZodUUID;
3218
+ planCode: z.ZodString;
3219
+ interval: z.ZodEnum<{
3220
+ month: "month";
3221
+ year: "year";
3222
+ }>;
3223
+ intervalCount: z.ZodNumber;
3224
+ currency: z.ZodString;
3225
+ amountMinor: z.ZodNumber;
3226
+ expiresAt: z.ZodISODateTime;
3227
+ }, z.core.$strip>>;
3228
+ profile: z.ZodObject<{
3229
+ present: z.ZodBoolean;
3230
+ kind: z.ZodNullable<z.ZodEnum<{
3231
+ individual: "individual";
3232
+ company: "company";
3233
+ }>>;
3234
+ }, z.core.$strip>;
3235
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
3236
+ id: z.ZodUUID;
3237
+ status: z.ZodEnum<{
3238
+ active: "active";
3239
+ suspended: "suspended";
3240
+ past_due: "past_due";
3241
+ canceled: "canceled";
3242
+ expired: "expired";
3243
+ }>;
3244
+ planCode: z.ZodString;
3245
+ interval: z.ZodEnum<{
3246
+ month: "month";
3247
+ year: "year";
3248
+ }>;
3249
+ amountMinor: z.ZodNumber;
3250
+ currency: z.ZodString;
3251
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3252
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3253
+ cancelAtPeriodEnd: z.ZodBoolean;
3254
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
3255
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3256
+ dunning: z.ZodNullable<z.ZodObject<{
3257
+ step: z.ZodNumber;
3258
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
3259
+ }, z.core.$strip>>;
3260
+ scheduledChange: z.ZodNullable<z.ZodObject<{
3261
+ planCode: z.ZodString;
3262
+ interval: z.ZodEnum<{
3263
+ month: "month";
3264
+ year: "year";
3265
+ }>;
3266
+ effectiveAt: z.ZodISODateTime;
3267
+ amountMinor: z.ZodOptional<z.ZodNumber>;
3268
+ }, z.core.$strip>>;
3269
+ }, z.core.$strip>>>;
3270
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
3271
+ id: z.ZodUUID;
3272
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
3273
+ billingReason: z.ZodEnum<{
3274
+ subscription_create: "subscription_create";
3275
+ subscription_cycle: "subscription_cycle";
3276
+ subscription_update: "subscription_update";
3277
+ purchase: "purchase";
3278
+ manual: "manual";
3279
+ }>;
3280
+ totalMinor: z.ZodNumber;
3281
+ currency: z.ZodString;
3282
+ dueAt: z.ZodISODateTime;
3283
+ }, z.core.$strip>>>;
3284
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
3285
+ code: z.ZodNullable<z.ZodString>;
3286
+ type: z.ZodString;
3287
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3288
+ source: z.ZodString;
3289
+ grantedAt: z.ZodISODateTime;
3290
+ }, z.core.$strip>>>;
3291
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3292
+ includedUnits: z.ZodNullable<z.ZodNumber>;
3293
+ billable: z.ZodBoolean;
3294
+ standing: z.ZodEnum<{
3295
+ ok: "ok";
3296
+ low: "low";
3297
+ exhausted: "exhausted";
3298
+ }>;
3299
+ }, z.core.$strip>>>;
3300
+ }, z.core.$strip>>;
3301
+ }, z.core.$strip>;
3302
+ type InvoiceWaiveResponse = z.infer<typeof InvoiceWaiveResponseSchema>;
3303
+ /** `POST /v1/subscriptions/{id}/change` (billing core MF9): the subscription and the state with `scheduledChange`. */
3304
+ declare const ChangeSubscriptionResponseSchema: z.ZodObject<{
3305
+ id: z.ZodUUID;
3306
+ accountRef: z.ZodString;
3307
+ status: z.ZodEnum<{
3308
+ active: "active";
3309
+ suspended: "suspended";
3310
+ past_due: "past_due";
3311
+ canceled: "canceled";
3312
+ expired: "expired";
3313
+ }>;
3314
+ planCode: z.ZodString;
3315
+ priceId: z.ZodUUID;
3316
+ interval: z.ZodEnum<{
3317
+ month: "month";
3318
+ year: "year";
3319
+ }>;
3320
+ amountMinor: z.ZodNumber;
3321
+ currency: z.ZodString;
3322
+ provider: z.ZodString;
3323
+ providerSubscriptionRef: z.ZodString;
3324
+ cancelAtPeriodEnd: z.ZodBoolean;
3325
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3326
+ cancelReason: z.ZodNullable<z.ZodString>;
3327
+ canceledAt: z.ZodNullable<z.ZodISODateTime>;
3328
+ startedAt: z.ZodISODateTime;
3329
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3330
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3331
+ dunningStartedAt: z.ZodNullable<z.ZodISODateTime>;
3332
+ account: z.ZodOptional<z.ZodObject<{
3333
+ version: z.ZodNumber;
3334
+ planCode: z.ZodString;
3335
+ accessState: z.ZodEnum<{
3336
+ active: "active";
3337
+ suspended: "suspended";
3338
+ }>;
3339
+ entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
3340
+ ref: z.ZodString;
3341
+ displayName: z.ZodString;
3342
+ updatedAt: z.ZodISODateTime;
3343
+ catalogVersion: z.ZodNullable<z.ZodString>;
3344
+ subscription: z.ZodNullable<z.ZodObject<{
3345
+ id: z.ZodUUID;
3346
+ status: z.ZodEnum<{
3347
+ active: "active";
3348
+ suspended: "suspended";
3349
+ past_due: "past_due";
3350
+ canceled: "canceled";
3351
+ expired: "expired";
3352
+ }>;
3353
+ planCode: z.ZodString;
3354
+ interval: z.ZodEnum<{
3355
+ month: "month";
3356
+ year: "year";
3357
+ }>;
3358
+ amountMinor: z.ZodNumber;
3359
+ currency: z.ZodString;
3360
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3361
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3362
+ cancelAtPeriodEnd: z.ZodBoolean;
3363
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
3364
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3365
+ dunning: z.ZodNullable<z.ZodObject<{
3366
+ step: z.ZodNumber;
3367
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
3368
+ }, z.core.$strip>>;
3369
+ scheduledChange: z.ZodNullable<z.ZodObject<{
3370
+ planCode: z.ZodString;
3371
+ interval: z.ZodEnum<{
3372
+ month: "month";
3373
+ year: "year";
3374
+ }>;
3375
+ effectiveAt: z.ZodISODateTime;
3376
+ amountMinor: z.ZodOptional<z.ZodNumber>;
3377
+ }, z.core.$strip>>;
3378
+ }, z.core.$strip>>;
3379
+ openCheckout: z.ZodNullable<z.ZodObject<{
3380
+ id: z.ZodUUID;
3381
+ planCode: z.ZodString;
3382
+ interval: z.ZodEnum<{
3383
+ month: "month";
3384
+ year: "year";
3385
+ }>;
3386
+ intervalCount: z.ZodNumber;
3387
+ currency: z.ZodString;
3388
+ amountMinor: z.ZodNumber;
3389
+ expiresAt: z.ZodISODateTime;
3390
+ }, z.core.$strip>>;
3391
+ profile: z.ZodObject<{
3392
+ present: z.ZodBoolean;
3393
+ kind: z.ZodNullable<z.ZodEnum<{
3394
+ individual: "individual";
3395
+ company: "company";
3396
+ }>>;
3397
+ }, z.core.$strip>;
3398
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
3399
+ id: z.ZodUUID;
3400
+ status: z.ZodEnum<{
3401
+ active: "active";
3402
+ suspended: "suspended";
3403
+ past_due: "past_due";
3404
+ canceled: "canceled";
3405
+ expired: "expired";
3406
+ }>;
3407
+ planCode: z.ZodString;
3408
+ interval: z.ZodEnum<{
3409
+ month: "month";
3410
+ year: "year";
3411
+ }>;
3412
+ amountMinor: z.ZodNumber;
3413
+ currency: z.ZodString;
3414
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3415
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3416
+ cancelAtPeriodEnd: z.ZodBoolean;
3417
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
3418
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3419
+ dunning: z.ZodNullable<z.ZodObject<{
3420
+ step: z.ZodNumber;
3421
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
3422
+ }, z.core.$strip>>;
3423
+ scheduledChange: z.ZodNullable<z.ZodObject<{
3424
+ planCode: z.ZodString;
3425
+ interval: z.ZodEnum<{
3426
+ month: "month";
3427
+ year: "year";
3428
+ }>;
3429
+ effectiveAt: z.ZodISODateTime;
3430
+ amountMinor: z.ZodOptional<z.ZodNumber>;
3431
+ }, z.core.$strip>>;
3432
+ }, z.core.$strip>>>;
3433
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
3434
+ id: z.ZodUUID;
3435
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
3436
+ billingReason: z.ZodEnum<{
3437
+ subscription_create: "subscription_create";
3438
+ subscription_cycle: "subscription_cycle";
3439
+ subscription_update: "subscription_update";
3440
+ purchase: "purchase";
3441
+ manual: "manual";
3442
+ }>;
3443
+ totalMinor: z.ZodNumber;
3444
+ currency: z.ZodString;
3445
+ dueAt: z.ZodISODateTime;
3446
+ }, z.core.$strip>>>;
3447
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
3448
+ code: z.ZodNullable<z.ZodString>;
3449
+ type: z.ZodString;
3450
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3451
+ source: z.ZodString;
3452
+ grantedAt: z.ZodISODateTime;
3453
+ }, z.core.$strip>>>;
3454
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3455
+ includedUnits: z.ZodNullable<z.ZodNumber>;
3456
+ billable: z.ZodBoolean;
3457
+ standing: z.ZodEnum<{
3458
+ ok: "ok";
3459
+ low: "low";
3460
+ exhausted: "exhausted";
3461
+ }>;
3462
+ }, z.core.$strip>>>;
3463
+ }, z.core.$strip>>;
3464
+ }, z.core.$strip>;
3465
+ type ChangeSubscriptionResponse = z.infer<typeof ChangeSubscriptionResponseSchema>;
3466
+ /** `POST /v1/subscriptions/{id}/uncancel` (billing core MF9): the scheduled cancellation is taken back. */
3467
+ declare const UncancelSubscriptionResponseSchema: z.ZodObject<{
3468
+ id: z.ZodUUID;
3469
+ accountRef: z.ZodString;
3470
+ status: z.ZodEnum<{
3471
+ active: "active";
3472
+ suspended: "suspended";
3473
+ past_due: "past_due";
3474
+ canceled: "canceled";
3475
+ expired: "expired";
3476
+ }>;
3477
+ planCode: z.ZodString;
3478
+ priceId: z.ZodUUID;
3479
+ interval: z.ZodEnum<{
3480
+ month: "month";
3481
+ year: "year";
3482
+ }>;
3483
+ amountMinor: z.ZodNumber;
3484
+ currency: z.ZodString;
3485
+ provider: z.ZodString;
3486
+ providerSubscriptionRef: z.ZodString;
3487
+ cancelAtPeriodEnd: z.ZodBoolean;
3488
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3489
+ cancelReason: z.ZodNullable<z.ZodString>;
3490
+ canceledAt: z.ZodNullable<z.ZodISODateTime>;
3491
+ startedAt: z.ZodISODateTime;
3492
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3493
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3494
+ dunningStartedAt: z.ZodNullable<z.ZodISODateTime>;
3495
+ account: z.ZodOptional<z.ZodObject<{
3496
+ version: z.ZodNumber;
3497
+ planCode: z.ZodString;
3498
+ accessState: z.ZodEnum<{
3499
+ active: "active";
3500
+ suspended: "suspended";
3501
+ }>;
3502
+ entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
3503
+ ref: z.ZodString;
3504
+ displayName: z.ZodString;
3505
+ updatedAt: z.ZodISODateTime;
3506
+ catalogVersion: z.ZodNullable<z.ZodString>;
3507
+ subscription: z.ZodNullable<z.ZodObject<{
3508
+ id: z.ZodUUID;
3509
+ status: z.ZodEnum<{
3510
+ active: "active";
3511
+ suspended: "suspended";
3512
+ past_due: "past_due";
3513
+ canceled: "canceled";
3514
+ expired: "expired";
3515
+ }>;
3516
+ planCode: z.ZodString;
3517
+ interval: z.ZodEnum<{
3518
+ month: "month";
3519
+ year: "year";
3520
+ }>;
3521
+ amountMinor: z.ZodNumber;
3522
+ currency: z.ZodString;
3523
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3524
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3525
+ cancelAtPeriodEnd: z.ZodBoolean;
3526
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
3527
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3528
+ dunning: z.ZodNullable<z.ZodObject<{
3529
+ step: z.ZodNumber;
3530
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
3531
+ }, z.core.$strip>>;
3532
+ scheduledChange: z.ZodNullable<z.ZodObject<{
3533
+ planCode: z.ZodString;
3534
+ interval: z.ZodEnum<{
3535
+ month: "month";
3536
+ year: "year";
3537
+ }>;
3538
+ effectiveAt: z.ZodISODateTime;
3539
+ amountMinor: z.ZodOptional<z.ZodNumber>;
3540
+ }, z.core.$strip>>;
3541
+ }, z.core.$strip>>;
3542
+ openCheckout: z.ZodNullable<z.ZodObject<{
3543
+ id: z.ZodUUID;
3544
+ planCode: z.ZodString;
3545
+ interval: z.ZodEnum<{
3546
+ month: "month";
3547
+ year: "year";
3548
+ }>;
3549
+ intervalCount: z.ZodNumber;
3550
+ currency: z.ZodString;
3551
+ amountMinor: z.ZodNumber;
3552
+ expiresAt: z.ZodISODateTime;
3553
+ }, z.core.$strip>>;
3554
+ profile: z.ZodObject<{
3555
+ present: z.ZodBoolean;
3556
+ kind: z.ZodNullable<z.ZodEnum<{
3557
+ individual: "individual";
3558
+ company: "company";
3559
+ }>>;
3560
+ }, z.core.$strip>;
3561
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
3562
+ id: z.ZodUUID;
3563
+ status: z.ZodEnum<{
3564
+ active: "active";
3565
+ suspended: "suspended";
3566
+ past_due: "past_due";
3567
+ canceled: "canceled";
3568
+ expired: "expired";
3569
+ }>;
3570
+ planCode: z.ZodString;
3571
+ interval: z.ZodEnum<{
3572
+ month: "month";
3573
+ year: "year";
3574
+ }>;
3575
+ amountMinor: z.ZodNumber;
3576
+ currency: z.ZodString;
3577
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3578
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3579
+ cancelAtPeriodEnd: z.ZodBoolean;
3580
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
3581
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3582
+ dunning: z.ZodNullable<z.ZodObject<{
3583
+ step: z.ZodNumber;
3584
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
3585
+ }, z.core.$strip>>;
3586
+ scheduledChange: z.ZodNullable<z.ZodObject<{
3587
+ planCode: z.ZodString;
3588
+ interval: z.ZodEnum<{
3589
+ month: "month";
3590
+ year: "year";
3591
+ }>;
3592
+ effectiveAt: z.ZodISODateTime;
3593
+ amountMinor: z.ZodOptional<z.ZodNumber>;
3594
+ }, z.core.$strip>>;
3595
+ }, z.core.$strip>>>;
3596
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
3597
+ id: z.ZodUUID;
3598
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
3599
+ billingReason: z.ZodEnum<{
3600
+ subscription_create: "subscription_create";
3601
+ subscription_cycle: "subscription_cycle";
3602
+ subscription_update: "subscription_update";
3603
+ purchase: "purchase";
3604
+ manual: "manual";
3605
+ }>;
3606
+ totalMinor: z.ZodNumber;
3607
+ currency: z.ZodString;
3608
+ dueAt: z.ZodISODateTime;
3609
+ }, z.core.$strip>>>;
3610
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
3611
+ code: z.ZodNullable<z.ZodString>;
3612
+ type: z.ZodString;
3613
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3614
+ source: z.ZodString;
3615
+ grantedAt: z.ZodISODateTime;
3616
+ }, z.core.$strip>>>;
3617
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3618
+ includedUnits: z.ZodNullable<z.ZodNumber>;
3619
+ billable: z.ZodBoolean;
3620
+ standing: z.ZodEnum<{
3621
+ ok: "ok";
3622
+ low: "low";
3623
+ exhausted: "exhausted";
3624
+ }>;
3625
+ }, z.core.$strip>>>;
3626
+ }, z.core.$strip>>;
3627
+ }, z.core.$strip>;
3628
+ type UncancelSubscriptionResponse = z.infer<typeof UncancelSubscriptionResponseSchema>;
3629
+ /**
3630
+ * `POST /v1/accounts/{ref}/credits` (metering MF2): the ledger entry written, the meters after it
3631
+ * and (K5) the account state after it (a credit may change a meter's standing).
3632
+ */
3633
+ declare const CreditGrantResponseSchema: z.ZodObject<{
3634
+ account: z.ZodOptional<z.ZodObject<{
3635
+ version: z.ZodNumber;
3636
+ planCode: z.ZodString;
3637
+ accessState: z.ZodEnum<{
3638
+ active: "active";
3639
+ suspended: "suspended";
3640
+ }>;
3641
+ entitlements: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
3642
+ ref: z.ZodString;
3643
+ displayName: z.ZodString;
3644
+ updatedAt: z.ZodISODateTime;
3645
+ catalogVersion: z.ZodNullable<z.ZodString>;
3646
+ subscription: z.ZodNullable<z.ZodObject<{
3647
+ id: z.ZodUUID;
3648
+ status: z.ZodEnum<{
3649
+ active: "active";
3650
+ suspended: "suspended";
3651
+ past_due: "past_due";
3652
+ canceled: "canceled";
3653
+ expired: "expired";
3654
+ }>;
3655
+ planCode: z.ZodString;
3656
+ interval: z.ZodEnum<{
3657
+ month: "month";
3658
+ year: "year";
3659
+ }>;
3660
+ amountMinor: z.ZodNumber;
3661
+ currency: z.ZodString;
3662
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3663
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3664
+ cancelAtPeriodEnd: z.ZodBoolean;
3665
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
3666
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3667
+ dunning: z.ZodNullable<z.ZodObject<{
3668
+ step: z.ZodNumber;
3669
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
3670
+ }, z.core.$strip>>;
3671
+ scheduledChange: z.ZodNullable<z.ZodObject<{
3672
+ planCode: z.ZodString;
3673
+ interval: z.ZodEnum<{
3674
+ month: "month";
3675
+ year: "year";
3676
+ }>;
3677
+ effectiveAt: z.ZodISODateTime;
3678
+ amountMinor: z.ZodOptional<z.ZodNumber>;
3679
+ }, z.core.$strip>>;
3680
+ }, z.core.$strip>>;
3681
+ openCheckout: z.ZodNullable<z.ZodObject<{
3682
+ id: z.ZodUUID;
3683
+ planCode: z.ZodString;
3684
+ interval: z.ZodEnum<{
3685
+ month: "month";
3686
+ year: "year";
3687
+ }>;
3688
+ intervalCount: z.ZodNumber;
3689
+ currency: z.ZodString;
3690
+ amountMinor: z.ZodNumber;
3691
+ expiresAt: z.ZodISODateTime;
3692
+ }, z.core.$strip>>;
3693
+ profile: z.ZodObject<{
3694
+ present: z.ZodBoolean;
3695
+ kind: z.ZodNullable<z.ZodEnum<{
3696
+ individual: "individual";
3697
+ company: "company";
3698
+ }>>;
3699
+ }, z.core.$strip>;
3700
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
3701
+ id: z.ZodUUID;
3702
+ status: z.ZodEnum<{
3703
+ active: "active";
3704
+ suspended: "suspended";
3705
+ past_due: "past_due";
3706
+ canceled: "canceled";
3707
+ expired: "expired";
3708
+ }>;
3709
+ planCode: z.ZodString;
3710
+ interval: z.ZodEnum<{
3711
+ month: "month";
3712
+ year: "year";
3713
+ }>;
3714
+ amountMinor: z.ZodNumber;
3715
+ currency: z.ZodString;
3716
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
3717
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
3718
+ cancelAtPeriodEnd: z.ZodBoolean;
3719
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
3720
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
3721
+ dunning: z.ZodNullable<z.ZodObject<{
3722
+ step: z.ZodNumber;
3723
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
3724
+ }, z.core.$strip>>;
3725
+ scheduledChange: z.ZodNullable<z.ZodObject<{
3726
+ planCode: z.ZodString;
3727
+ interval: z.ZodEnum<{
3728
+ month: "month";
3729
+ year: "year";
3730
+ }>;
3731
+ effectiveAt: z.ZodISODateTime;
3732
+ amountMinor: z.ZodOptional<z.ZodNumber>;
3733
+ }, z.core.$strip>>;
3734
+ }, z.core.$strip>>>;
3735
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
3736
+ id: z.ZodUUID;
3737
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
3738
+ billingReason: z.ZodEnum<{
3739
+ subscription_create: "subscription_create";
3740
+ subscription_cycle: "subscription_cycle";
3741
+ subscription_update: "subscription_update";
3742
+ purchase: "purchase";
3743
+ manual: "manual";
3744
+ }>;
3745
+ totalMinor: z.ZodNumber;
3746
+ currency: z.ZodString;
3747
+ dueAt: z.ZodISODateTime;
3748
+ }, z.core.$strip>>>;
3749
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
3750
+ code: z.ZodNullable<z.ZodString>;
3751
+ type: z.ZodString;
3752
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3753
+ source: z.ZodString;
3754
+ grantedAt: z.ZodISODateTime;
3755
+ }, z.core.$strip>>>;
3756
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3757
+ includedUnits: z.ZodNullable<z.ZodNumber>;
3758
+ billable: z.ZodBoolean;
3759
+ standing: z.ZodEnum<{
3760
+ ok: "ok";
3761
+ low: "low";
3762
+ exhausted: "exhausted";
3763
+ }>;
3764
+ }, z.core.$strip>>>;
3765
+ }, z.core.$strip>>;
3766
+ entry: z.ZodObject<{
3767
+ id: z.ZodUUID;
3768
+ meter: z.ZodString;
3769
+ kind: z.ZodEnum<{
3770
+ cycle_grant: "cycle_grant";
3771
+ rollover: "rollover";
3772
+ plan_change: "plan_change";
3773
+ manual_grant: "manual_grant";
3774
+ adjustment: "adjustment";
3775
+ }>;
3776
+ units: z.ZodNumber;
3777
+ periodStart: z.ZodISODateTime;
3778
+ reason: z.ZodNullable<z.ZodString>;
3779
+ actorRef: z.ZodNullable<z.ZodString>;
3780
+ createdAt: z.ZodISODateTime;
3781
+ }, z.core.$strip>;
3782
+ meters: z.ZodObject<{
3783
+ ref: z.ZodString;
3784
+ asOf: z.ZodISODateTime;
3785
+ rolledUpThrough: z.ZodISODateTime;
3786
+ meters: z.ZodRecord<z.ZodString, z.ZodObject<{
3787
+ periodStart: z.ZodISODateTime;
3788
+ periodEnd: z.ZodISODateTime;
3789
+ includedUnits: z.ZodNullable<z.ZodNumber>;
3790
+ consumedUnits: z.ZodNumber;
3791
+ creditedUnits: z.ZodNumber;
3792
+ balance: z.ZodNumber;
3793
+ overageUnits: z.ZodNumber;
3794
+ standing: z.ZodEnum<{
3795
+ ok: "ok";
3796
+ low: "low";
3797
+ exhausted: "exhausted";
3798
+ }>;
3799
+ billable: z.ZodBoolean;
3800
+ amountDueMinor: z.ZodNullable<z.ZodNumber>;
3801
+ currency: z.ZodNullable<z.ZodString>;
3802
+ capReached: z.ZodOptional<z.ZodBoolean>;
3803
+ }, z.core.$strip>>;
3804
+ }, z.core.$strip>;
3805
+ }, z.core.$strip>;
3806
+ type CreditGrantResponse = z.infer<typeof CreditGrantResponseSchema>;
3807
+ /**
3808
+ * Known `GET /v1/me` capabilities (M27): what this steward understands beyond the 0.2 contract.
3809
+ * `steward catalog push` sends a catalog with `benefits` only when `benefits` is listed (an older
3810
+ * steward would silently drop the key); phase 2 adds `events` (`POST /v1/events/ingest`), `meters`
3811
+ * (catalog `meters`, `meter_credit` benefits, `GET …/meters`, credits) and `overage` (metered
3812
+ * prices, meter charges). A steward lists a capability only once it implements it. Open set.
3813
+ */
3814
+ declare const STEWARD_CAPABILITIES: readonly ["benefits", "events", "meters", "overage"];
3815
+ type StewardCapability = (typeof STEWARD_CAPABILITIES)[number];
3816
+ /** `GET /v1/me`: the key's product and scope (setup check). `capabilities` absent from older steward. */
3817
+ declare const MeResponseSchema: z.ZodObject<{
3818
+ product: z.ZodString;
3819
+ keyName: z.ZodString;
3820
+ scope: z.ZodEnum<{
3821
+ product: "product";
3822
+ admin: "admin";
3823
+ checkout: "checkout";
3824
+ }>;
3825
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
3826
+ }, z.core.$strip>;
3827
+ type MeResponse = z.infer<typeof MeResponseSchema>;
3828
+ /** Değişiklik yapan her istekte zorunlu başlıklar. */
3829
+ declare const HEADER_IDEMPOTENCY_KEY = "idempotency-key";
3830
+ declare const HEADER_ACTOR_REF = "x-actor-ref";
3831
+ declare const HEADER_API_VERSION = "steward-api-version";
3832
+ declare const HEADER_SDK = "x-steward-sdk";
3833
+ declare const HEADER_REQUEST_ID = "x-request-id";
3834
+ //#endregion
3835
+ //#region ../contract/src/errors.d.ts
3836
+ type ErrorCodeSpec = {
3837
+ readonly httpStatus: number;
3838
+ readonly category: ErrorCategory;
3839
+ readonly retryable: boolean;
3840
+ };
1622
3841
  declare const ERROR_CODES: Readonly<{
1623
3842
  invalid_json: ErrorCodeSpec;
1624
3843
  invalid_request: ErrorCodeSpec;
@@ -1653,10 +3872,16 @@ declare const ERROR_CODES: Readonly<{
1653
3872
  override_type_mismatch: ErrorCodeSpec;
1654
3873
  /** Grant girdisindeki plan katalogda yok. */
1655
3874
  plan_not_found: ErrorCodeSpec;
3875
+ /** Grant `benefitCodes`: a code is not an active (not archived) catalog benefit of the product. */
3876
+ benefit_not_found: ErrorCodeSpec;
1656
3877
  invalid_window: ErrorCodeSpec;
1657
3878
  already_subscribed: ErrorCodeSpec;
1658
3879
  already_canceled: ErrorCodeSpec;
1659
- /** `PUT …/plan` `mode: "strict"`: canlı aboneliğin planı hedefi geçiyor; hiçbir şey yazılmadı. */
3880
+ /**
3881
+ * LEGACY — no longer produced (billing core, M35: no plan rank). Steward before the billing core
3882
+ * answered `PUT …/plan` `mode: "strict"` with it when a live subscription's plan outranked the
3883
+ * target. Kept so clients that handle it keep compiling.
3884
+ */
1660
3885
  subscription_plan_higher: ErrorCodeSpec;
1661
3886
  plan_not_sellable: ErrorCodeSpec;
1662
3887
  /**
@@ -1682,6 +3907,35 @@ declare const ERROR_CODES: Readonly<{
1682
3907
  invoice_not_voidable: ErrorCodeSpec;
1683
3908
  /** Void: ödemeli fatura; iptali iade yolundadır (F4d). */
1684
3909
  invoice_has_payment: ErrorCodeSpec;
3910
+ /** `DELETE /v1/accounts/:ref`: the account has an unpaid invoice; pay or waive it first. */
3911
+ invoice_open: ErrorCodeSpec;
3912
+ /** Pay page session: the invoice is not unpaid (paid, waived, uncollectible, or not an invoice-first invoice). */
3913
+ invoice_not_payable: ErrorCodeSpec;
3914
+ /** Waive: the invoice is not unpaid. */
3915
+ invoice_not_waivable: ErrorCodeSpec;
3916
+ /**
3917
+ * `POST /v1/subscriptions/:id/change`: the requested change is not possible — no active price for
3918
+ * the target plan/interval in the subscription's currency, nothing would change, or the
3919
+ * subscription is not live. Plan lookup errors keep their codes (`plan_not_found`, `plan_not_sellable`).
3920
+ */
3921
+ subscription_change_invalid: ErrorCodeSpec;
3922
+ /**
3923
+ * `POST /v1/subscriptions/:id/uncancel`: the live subscription has no cancellation scheduled for
3924
+ * the period end (an ended or immediately canceled one is `already_canceled`).
3925
+ */
3926
+ cancel_not_scheduled: ErrorCodeSpec;
3927
+ /** `POST /v1/events/ingest`: more than 1 000 events (or a body over 1 MiB) in one batch; split it. */
3928
+ batch_too_large: ErrorCodeSpec;
3929
+ /** `POST /v1/events/ingest`: the unprocessed event backlog is too large; `Retry-After`, keep the batch queued (M11). */
3930
+ events_backlog: ErrorCodeSpec;
3931
+ /** Catalog sync: a meter's filter or aggregation changed after its first period opened; use a new meter code (M4). */
3932
+ meter_locked: ErrorCodeSpec;
3933
+ /** Credit grant (or another meter lookup): the code is not an active catalog meter of the product. */
3934
+ meter_not_found: ErrorCodeSpec;
3935
+ /** Catalog sync: a metered price's tax terms differ from the plan's base price in that currency (M20). */
3936
+ metered_price_tax_mismatch: ErrorCodeSpec;
3937
+ /** A second live subscription would bill the same meter's overage (M20: one billing subscription per meter). */
3938
+ meter_already_billed: ErrorCodeSpec;
1685
3939
  internal_error: ErrorCodeSpec;
1686
3940
  /** `/health`: veritabanına ulaşılamıyor. */
1687
3941
  database_unavailable: ErrorCodeSpec;
@@ -1701,61 +3955,384 @@ declare function isKnownErrorCode(code: string): code is ErrorCode;
1701
3955
  declare function errorCodeSpec(code: string): ErrorCodeSpec | null;
1702
3956
  //#endregion
1703
3957
  //#region ../contract/src/rules.d.ts
1704
- /** Hesap başına en fazla bir abonelik bu durumlardan birindedir. */
3958
+ /** Live subscription statuses. An account may hold several live subscriptions (billing core, M34). */
1705
3959
  declare const LIVE_SUBSCRIPTION_STATUSES: readonly ["active", "past_due", "suspended"];
1706
3960
  declare function isLiveSubscriptionStatus(status: SubscriptionStatus): boolean;
1707
3961
  type Instant = string | Date;
1708
- /** Kuralın katalogdan okuduğu kadarı; `Catalog` ve `CatalogSyncInput` doğrudan verilebilir. */
3962
+ /** Catalog benefit definition as the rule reads it (catalog input and `GET /v1/catalog` both fit). */
3963
+ type BenefitRulesDefinition = {
3964
+ type: string;
3965
+ properties: Readonly<Record<string, unknown>>;
3966
+ };
3967
+ /** What the rule reads from the catalog; `Catalog` and `CatalogSyncInput` can be passed as they are. */
1709
3968
  type EntitlementRulesCatalog = {
1710
3969
  defaultPlanCode: string;
3970
+ /**
3971
+ * Feature `type` picks the merge rule. Without it the value decides: number or `null` → limit,
3972
+ * boolean → OR, string → last layer wins.
3973
+ */
1711
3974
  features: readonly {
1712
3975
  key: string;
3976
+ type?: BenefitFeatureType | undefined;
1713
3977
  }[];
1714
3978
  /**
1715
- * Adayların (abonelik ve grant planları) TÜMÜ burada olmalı; katalogdan
1716
- * çıkarılıp pasifleşmiş plana bağlı abonelik/grant varsa o plan da verilir.
3979
+ * Every plan a subscription or grant refers to must be here: a plan removed from the catalog
3980
+ * (inactive) that a subscription/grant still refers to is passed as well. `rank` is not read.
1717
3981
  */
1718
3982
  plans: readonly {
1719
3983
  code: string;
1720
- rank: number;
3984
+ rank?: number | undefined;
1721
3985
  entitlements: Readonly<Record<string, EntitlementValue>>;
3986
+ /** Codes of catalog `benefits` the plan includes, in display order. */
3987
+ benefits?: readonly string[] | undefined;
1722
3988
  }[];
3989
+ /** Grantable (not archived) catalog benefits by code. A code that is not here is not granted. */
3990
+ benefits?: Readonly<Record<string, BenefitRulesDefinition>> | undefined;
1723
3991
  };
1724
3992
  type EntitlementRulesGrant = {
1725
- /** Plan grant'i değilse null/yok. */
1726
- planCode?: string | null;
1727
- overrides?: Readonly<Record<string, EntitlementValue>>;
1728
- startsAt?: Instant;
1729
- endsAt?: Instant | null;
1730
- revokedAt?: Instant | null;
1731
- /** Varsa (tümünde) grant'ler `createdAt`, sonra `id` ile sıralanır; yoksa verilen sıra oluşturulma sırasıdır. */
1732
- createdAt?: Instant;
1733
- id?: string;
3993
+ /** Null/absent unless it is a plan grant. */
3994
+ planCode?: string | null | undefined;
3995
+ overrides?: Readonly<Record<string, EntitlementValue>> | undefined;
3996
+ /** Named catalog benefits granted independently of a plan (billing core, M32). */
3997
+ benefitCodes?: readonly string[] | null | undefined;
3998
+ startsAt?: Instant | undefined;
3999
+ endsAt?: Instant | null | undefined;
4000
+ revokedAt?: Instant | null | undefined;
4001
+ /** When every grant has it, grants are ordered by `createdAt`, then `id`; otherwise the given order is the creation order. */
4002
+ createdAt?: Instant | undefined;
4003
+ id?: string | undefined;
4004
+ };
4005
+ type BenefitRulesSubscription = {
4006
+ planCode: string;
4007
+ status: SubscriptionStatus;
4008
+ /** When every subscription has it, they are ordered by `startedAt`, then `id`; otherwise the given order is the start order. */
4009
+ startedAt?: Instant | undefined;
4010
+ id?: string | undefined;
4011
+ };
4012
+ type ResolveBenefitsInput = {
4013
+ catalog: EntitlementRulesCatalog;
4014
+ /** The account's subscriptions; those not live (canceled/expired) are ignored. */
4015
+ subscriptions: readonly BenefitRulesSubscription[];
4016
+ grants?: readonly EntitlementRulesGrant[] | undefined;
4017
+ /**
4018
+ * Instant at which grant windows (`startsAt <= at < endsAt`) are evaluated. Without it windows
4019
+ * are not evaluated: the caller passes only active grants (a revoked grant is always ignored).
4020
+ */
4021
+ at?: Instant | undefined;
1734
4022
  };
1735
4023
  type ResolveEntitlementsInput = {
1736
4024
  catalog: EntitlementRulesCatalog;
1737
- /** Hesabın aboneliği; durumu canlı değilse (canceled/expired) yok sayılır. */
4025
+ /** The account's subscription; ignored unless live. */
1738
4026
  subscription: {
1739
4027
  planCode: string;
1740
4028
  status: SubscriptionStatus;
1741
4029
  } | null;
1742
- grants?: readonly EntitlementRulesGrant[];
1743
- /**
1744
- * Grant penceresinin (`startsAt <= at < endsAt`) değerlendirildiği an.
1745
- * Verilmezse pencere değerlendirilmez: çağıran yalnızca aktif grant'leri
1746
- * verir (iptal edilmiş grant her durumda yok sayılır).
1747
- */
1748
- at?: Instant;
4030
+ grants?: readonly EntitlementRulesGrant[] | undefined;
4031
+ /** See `ResolveBenefitsInput.at`. */
4032
+ at?: Instant | undefined;
4033
+ };
4034
+ /** A granted benefit (`AccountState.benefits[]` without `grantedAt`, which the service keeps in its grant log). */
4035
+ type ResolvedBenefit = {
4036
+ /** Catalog benefit code; `null` for a plan's implicit benefit and for account overrides. */
4037
+ code: string | null;
4038
+ type: string;
4039
+ properties: Record<string, unknown>;
4040
+ /** `plan:<code>`, `grant:<id>` or `override`. */
4041
+ source: string;
1749
4042
  };
1750
4043
  type ResolvedEntitlements = Pick<EntitlementSnapshot, "planCode" | "accessState" | "entitlements">;
1751
- /** İptal edilmemiş ve (`at` verildiyse) penceresi içinde olan grant. */
4044
+ type ResolvedBenefits = ResolvedEntitlements & {
4045
+ /** Granted benefits in layer order; the `override` benefit (if any) is last. */
4046
+ benefits: ResolvedBenefit[];
4047
+ };
4048
+ /** Type of a plan's implicit benefit and of account overrides. */
4049
+ declare const FEATURE_FLAG_BENEFIT_TYPE = "feature_flag";
4050
+ /** Source of the account overrides benefit. */
4051
+ declare const OVERRIDE_BENEFIT_SOURCE = "override";
4052
+ /** Not revoked and (when `at` is given) inside its window. */
1752
4053
  declare function isGrantActive(grant: EntitlementRulesGrant, at?: Instant): boolean;
1753
4054
  /**
1754
- * Hesabın etkin planı, hakları ve erişim durumu. Adaylardan biri katalogda
1755
- * yoksa fırlatır (tutarsız veri; servis bunu FK ile garanti eder).
4055
+ * The account's granted benefits and their projection (planCode, accessState, entitlements).
4056
+ * Throws when a plan it refers to is not in the catalog (inconsistent data; the service
4057
+ * guarantees it with foreign keys).
4058
+ */
4059
+ declare function resolveBenefits(input: ResolveBenefitsInput): ResolvedBenefits;
4060
+ /**
4061
+ * The account's effective plan, entitlements and access state: the projection of
4062
+ * `resolveBenefits` for a single subscription (the pre-billing-core signature).
1756
4063
  */
1757
4064
  declare function resolveEntitlements(input: ResolveEntitlementsInput): ResolvedEntitlements;
1758
4065
  //#endregion
4066
+ //#region ../contract/src/ingest.d.ts
4067
+ /** Most events in one ingest batch (M11). */
4068
+ declare const EVENTS_INGEST_MAX_EVENTS = 1000;
4069
+ /** Largest ingest request body in bytes (M11; enforced on the route, not by the schema). */
4070
+ declare const EVENTS_INGEST_MAX_BYTES = 1048576;
4071
+ declare const EVENT_NAME_MAX_LENGTH = 128;
4072
+ declare const EVENT_METADATA_MAX_PAIRS = 50;
4073
+ declare const EVENT_METADATA_KEY_MAX_LENGTH = 40;
4074
+ declare const EVENT_METADATA_STRING_MAX_LENGTH = 500;
4075
+ /** How far back an event `timestamp` may lie, relative to its receipt (M18). */
4076
+ declare const EVENT_TIMESTAMP_MAX_AGE_DAYS = 35;
4077
+ /** How far ahead an event `timestamp` may lie, relative to its receipt (clock skew, M18). */
4078
+ declare const EVENT_TIMESTAMP_MAX_SKEW_MINUTES = 5;
4079
+ /** Whether a string contains C0 control characters or DEL (kept out of names and keys shown in logs and doctor). */
4080
+ declare function hasControlCharacters(value: string): boolean;
4081
+ /** Event name (free text, e.g. `ai.completion`); meters select events by it. */
4082
+ declare const EventNameSchema: z.ZodString;
4083
+ /** Product-chosen dedup key of an event, unique within the product (`cmpl_<id>`, `req_<id>`; M10). */
4084
+ declare const EventExternalIdSchema: z.ZodString;
4085
+ /** Metadata key; a meter filter reads it as `metadata.<key>`. `__proto__` is reserved. */
4086
+ declare const EventMetadataKeySchema: z.ZodString;
4087
+ declare const EventMetadataValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
4088
+ type EventMetadataValue = z.infer<typeof EventMetadataValueSchema>;
4089
+ declare const EventMetadataSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
4090
+ type EventMetadata = z.infer<typeof EventMetadataSchema>;
4091
+ /** One event the product sends (product → steward; not a webhook `BillingEvent`). */
4092
+ declare const IngestEventSchema: z.ZodObject<{
4093
+ accountRef: z.ZodString;
4094
+ name: z.ZodString;
4095
+ externalId: z.ZodString;
4096
+ timestamp: z.ZodOptional<z.ZodISODateTime>;
4097
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
4098
+ }, z.core.$strip>;
4099
+ type IngestEvent = z.infer<typeof IngestEventSchema>;
4100
+ /** `POST /v1/events/ingest` body. */
4101
+ declare const EventsIngestInputSchema: z.ZodObject<{
4102
+ events: z.ZodArray<z.ZodObject<{
4103
+ accountRef: z.ZodString;
4104
+ name: z.ZodString;
4105
+ externalId: z.ZodString;
4106
+ timestamp: z.ZodOptional<z.ZodISODateTime>;
4107
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
4108
+ }, z.core.$strip>>;
4109
+ }, z.core.$strip>;
4110
+ type EventsIngestInput = z.infer<typeof EventsIngestInputSchema>;
4111
+ /** Per-event rejection codes this version knows (M12). The result schema accepts others too. */
4112
+ declare const INGEST_REJECT_CODES: readonly ["account_not_found", "account_deleted", "timestamp_out_of_range"];
4113
+ declare const IngestRejectCodeSchema: z.ZodEnum<{
4114
+ account_not_found: "account_not_found";
4115
+ account_deleted: "account_deleted";
4116
+ timestamp_out_of_range: "timestamp_out_of_range";
4117
+ }>;
4118
+ type IngestRejectCode = z.infer<typeof IngestRejectCodeSchema>;
4119
+ declare const IngestRejectionSchema: z.ZodObject<{
4120
+ index: z.ZodNumber;
4121
+ externalId: z.ZodString;
4122
+ code: z.ZodType<"account_not_found" | "account_deleted" | "timestamp_out_of_range" | (string & Record<never, never>), string, z.core.$ZodTypeInternals<"account_not_found" | "account_deleted" | "timestamp_out_of_range" | (string & Record<never, never>), string>>;
4123
+ }, z.core.$strip>;
4124
+ type IngestRejection = z.infer<typeof IngestRejectionSchema>;
4125
+ /**
4126
+ * `POST /v1/events/ingest` result (200): `inserted` new events, `duplicates` already stored
4127
+ * (`externalId` seen before), `rejected` per event (sorted by `index`; the SDK does not retry them).
4128
+ */
4129
+ declare const EventsIngestResultSchema: z.ZodObject<{
4130
+ inserted: z.ZodNumber;
4131
+ duplicates: z.ZodNumber;
4132
+ rejected: z.ZodArray<z.ZodObject<{
4133
+ index: z.ZodNumber;
4134
+ externalId: z.ZodString;
4135
+ code: z.ZodType<"account_not_found" | "account_deleted" | "timestamp_out_of_range" | (string & Record<never, never>), string, z.core.$ZodTypeInternals<"account_not_found" | "account_deleted" | "timestamp_out_of_range" | (string & Record<never, never>), string>>;
4136
+ }, z.core.$strip>>;
4137
+ }, z.core.$strip>;
4138
+ type EventsIngestResult = z.infer<typeof EventsIngestResultSchema>;
4139
+ /**
4140
+ * Whether an event `timestamp` is accepted for an event received at `receivedAt` (M18):
4141
+ * [received − 35 days, received + 5 minutes], both ends inclusive. Outside: `timestamp_out_of_range`.
4142
+ */
4143
+ declare function isEventTimestampInRange(timestamp: Date, receivedAt: Date): boolean;
4144
+ //#endregion
4145
+ //#region ../contract/src/meter-rules.d.ts
4146
+ /** What the rules read from an event (an `IngestEvent`, a stored event row, a queued SDK event). */
4147
+ type MeterRulesEvent = {
4148
+ readonly name: string;
4149
+ readonly metadata?: Readonly<Record<string, unknown>> | undefined;
4150
+ };
4151
+ /** What the rules read from a meter (`MeterDef`, or a stored meter row). */
4152
+ type MeterRulesMeter = {
4153
+ readonly filter: MeterFilter;
4154
+ readonly aggregation: MeterAggregation;
4155
+ };
4156
+ /**
4157
+ * Whether an event matches a meter filter (syntax and semantics: `meters.ts`). A condition on an
4158
+ * absent metadata key is false for every operator; `eq` needs the same type; `like` is a
4159
+ * case-sensitive substring. Throws on a filter the schema would reject.
4160
+ */
4161
+ declare function matchesFilter(event: MeterRulesEvent, filter: MeterFilter): boolean;
4162
+ /**
4163
+ * What one matching event contributes to a meter (M4):
4164
+ * - `count`: `{kind: "count"}` (one unit);
4165
+ * - `sum` / `max`: the number at `metadata.<key>` in micro units (beyond 6 decimals half up);
4166
+ * - `unique`: the canonical value at `metadata.<key>` — `s:<string>`, `n:<plain decimal>`,
4167
+ * `b:true|false` (types never collide: `"500"` ≠ `500`; numbers without exponent, so
4168
+ * `1e21` and `1000000000000000000000` are one value);
4169
+ * - `{kind: "invalid_value"}`: the key is absent, or (`sum`/`max`) its value is not a finite,
4170
+ * non-negative number — a numeric string does not count. The event adds nothing to that meter.
4171
+ */
4172
+ type MeterContribution = {
4173
+ kind: "count";
4174
+ } | {
4175
+ kind: "sum" | "max";
4176
+ micro: bigint;
4177
+ } | {
4178
+ kind: "unique";
4179
+ value: string;
4180
+ } | {
4181
+ kind: "invalid_value";
4182
+ };
4183
+ declare function contributionOf(event: MeterRulesEvent, aggregation: MeterAggregation): MeterContribution;
4184
+ /**
4185
+ * A meter's value over a set of events (reference computation; the service recomputes a closing
4186
+ * period from raw events with the same result, M8): `count` → matching events, `sum` → total,
4187
+ * `max` → the largest value (0 when none), `unique` → distinct values. `matched` counts events
4188
+ * that passed the filter (invalid ones included), `invalid` those without a usable value.
4189
+ */
4190
+ declare function consumptionOf(events: Iterable<MeterRulesEvent>, meter: MeterRulesMeter): {
4191
+ consumedMicro: bigint;
4192
+ matched: number;
4193
+ invalid: number;
4194
+ };
4195
+ /**
4196
+ * A granted benefit as the credit rule reads it: `AccountState.benefits[]`, a `ResolvedBenefit`
4197
+ * of `resolveBenefits` (`rules.ts`), or a catalog benefit row. Only `meter_credit` benefits with
4198
+ * a code count.
4199
+ */
4200
+ type MeterCreditBenefit = {
4201
+ readonly code: string | null;
4202
+ readonly type: string;
4203
+ readonly properties: Readonly<Record<string, unknown>>;
4204
+ /** The granting layer: `plan:<code>`, `grant:<id>` (absent when unknown). */
4205
+ readonly source?: string | undefined;
4206
+ };
4207
+ /** What the granted `meter_credit` benefits give one meter per period. */
4208
+ type GrantedMeterCredit = {
4209
+ /** Sum of the counted benefits' `units` (micro units). */
4210
+ unitsMicro: bigint;
4211
+ /** Sum of the counted benefits' `rolloverCapUnits` (a benefit without a cap adds none); null when none has a cap (rollover off, M6). */
4212
+ rolloverCapMicro: bigint | null;
4213
+ /**
4214
+ * The counted benefits, in grant order (one entry per benefit code); `source` is the layer of the
4215
+ * grant that counts (null when the input had none).
4216
+ */
4217
+ benefits: {
4218
+ code: string;
4219
+ source: string | null;
4220
+ unitsMicro: bigint;
4221
+ rolloverCapMicro: bigint | null;
4222
+ }[];
4223
+ };
4224
+ type MeterCreditsOptions = {
4225
+ /**
4226
+ * The product's default plan. Its `meter_credit` benefits (source `plan:<default>`) count for a
4227
+ * meter only when no other layer grants a `meter_credit` for that meter: a paid plan REPLACES the
4228
+ * free quota, it does not stack on it. Omitted or null: every layer counts (e.g. the credits of
4229
+ * one plan on its own).
4230
+ */
4231
+ defaultPlanCode?: string | null | undefined;
4232
+ };
4233
+ /**
4234
+ * The credit rule (M5; decided 2026-09-19): the granted `meter_credit` benefits per meter code.
4235
+ * - Several benefits on one meter sum their units AND their rollover caps (plan + add-on).
4236
+ * - A benefit code granted by several layers counts once (its first counted grant).
4237
+ * - The default plan's credit for a meter counts only when no other layer credits that meter
4238
+ * (`options.defaultPlanCode`): free 50k + team 2M → 2M, free only → 50k.
4239
+ * - Benefits of another type, without a code, or whose properties do not parse are ignored.
4240
+ * The service (`AccountState.meters.includedUnits`, cycle grants) and the SDK (`stateOf`,
4241
+ * `Meters()` fallback) both use this function. Vectors: `credits.json`.
4242
+ */
4243
+ declare function meterCreditsOf(benefits: Iterable<MeterCreditBenefit>, options?: MeterCreditsOptions): Map<string, GrantedMeterCredit>;
4244
+ /** `max(0, consumed − credited)` (M21). */
4245
+ declare function overageOf(input: {
4246
+ consumedMicro: bigint;
4247
+ creditedMicro: bigint;
4248
+ }): bigint;
4249
+ /**
4250
+ * Credit standing of a meter (M14): no credit (`creditedMicro` 0) → `ok`; balance
4251
+ * (`credited − consumed`) ≤ 0 → `exhausted`; consumption ≥ `lowAt` × credit → `low` (`lowAt`
4252
+ * null disables `low`); else `ok`. Exact integer comparison (`lowAt` read as micro units).
4253
+ * `billable` does not change the standing — it describes the credit; a billable meter goes
4254
+ * `low`/`exhausted` too and only the gate stays open (M15).
4255
+ */
4256
+ declare function standingOf(input: {
4257
+ creditedMicro: bigint;
4258
+ consumedMicro: bigint;
4259
+ lowAt: number | null;
4260
+ billable?: boolean | undefined;
4261
+ }): MeterStanding;
4262
+ /**
4263
+ * Credit carried into the next period (M6): `min(max(closing balance, 0), cap)`; `capMicro`
4264
+ * null (rollover off) → 0. Debt never carries.
4265
+ */
4266
+ declare function rolloverOf(input: {
4267
+ closingBalanceMicro: bigint;
4268
+ capMicro: bigint | null;
4269
+ }): bigint;
4270
+ /**
4271
+ * `from` + `months` months in UTC with the month-end clamp of the service's `addInterval`
4272
+ * (`service/src/periods.ts`, date-fns `addMonths` on `UTCDate`): the day of month is kept, or the
4273
+ * last day of a shorter month (Jan 31 + 1 → Feb 28/29); the time of day is kept.
4274
+ */
4275
+ declare function addUtcMonths(from: Date, months: number): Date;
4276
+ /**
4277
+ * The monthly meter period containing `at` (M7): `[anchor + n months, anchor + (n + 1) months)`,
4278
+ * start inclusive, end exclusive, where every boundary is computed FROM THE ANCHOR (`addUtcMonths`;
4279
+ * Jan 31 → Feb 28 → Mar 31, no drift) — the same grid as the billing cycle's `nextPeriodEnd` for a
4280
+ * monthly subscription. `n` may be negative (`at` before the anchor). UTC throughout.
4281
+ */
4282
+ declare function periodBoundsOf(anchor: Date, at: Date): {
4283
+ start: Date;
4284
+ end: Date;
4285
+ };
4286
+ /** A period's overage and the (locked) metered rate that prices it. */
4287
+ type OverageRateInput = {
4288
+ overageMicro: bigint;
4289
+ amountMinor: number;
4290
+ perUnits: number;
4291
+ capMinor?: number | null | undefined;
4292
+ };
4293
+ /**
4294
+ * Overage amount in minor units (M21): `round_half_up(overage × amountMinor / perUnits)` on micro
4295
+ * units with BigInt — proportional (no block rounding), always whole minor units — then clipped
4296
+ * by `capMinor`. Tax terms are the price's (gross when tax-inclusive).
4297
+ */
4298
+ declare function rateOverage(input: OverageRateInput): number;
4299
+ /**
4300
+ * Whether the period's priced overage reached the rate's `capMinor` (M15: the SDK gate closes on a
4301
+ * billable meter once the cap is reached — further use would be free): there is overage
4302
+ * (`overageMicro` > 0) and its amount before the cap (`rateOverage` without `capMinor`) is ≥ the
4303
+ * cap. No cap → false. Same validation as `rateOverage`.
4304
+ */
4305
+ declare function overageCapReached(input: OverageRateInput): boolean;
4306
+ /**
4307
+ * A line of an invoice that carries overage (a meter line) or not (the base fee, a carried
4308
+ * amount). `amountMinor` is in the price's tax terms (gross when tax-inclusive).
4309
+ */
4310
+ type MeterChargeTotalsLine = {
4311
+ readonly description: string;
4312
+ readonly amountMinor: number;
4313
+ readonly meter?: string | undefined;
4314
+ /** Overage units, decimal string (`microToDecimalString`). */
4315
+ readonly units?: string | undefined;
4316
+ readonly priceAmountMinor?: number | undefined;
4317
+ readonly pricePerUnits?: number | undefined;
4318
+ };
4319
+ /**
4320
+ * Totals and stored lines of an invoice (or meter charge) with overage lines: the manual invoice
4321
+ * rule (`manualInvoiceTotals`) with every line at quantity 1 — ONE rounding at invoice level
4322
+ * (tax-inclusive: the total is kept and split with `splitInclusiveTax`, the net spread over the
4323
+ * lines by largest remainder; exclusive: tax added on the sum). Stored lines are net and keep
4324
+ * their meter fields (`meter`, `units`, `priceAmountMinor`, `pricePerUnits`).
4325
+ */
4326
+ declare function meterChargeTotals(lines: readonly MeterChargeTotalsLine[], terms: {
4327
+ taxInclusive: boolean;
4328
+ taxRateBps: number;
4329
+ }): {
4330
+ subtotalMinor: number;
4331
+ taxMinor: number;
4332
+ totalMinor: number;
4333
+ lines: InvoiceLine[];
4334
+ };
4335
+ //#endregion
1759
4336
  //#region ../contract/src/plan.d.ts
1760
4337
  declare const PLAN_SET_MODES: readonly ["ensure", "strict"];
1761
4338
  declare const PlanSetModeSchema: z.ZodEnum<{
@@ -1774,7 +4351,7 @@ declare const PlanSetInputSchema: z.ZodObject<{
1774
4351
  overrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>>;
1775
4352
  }, z.core.$strip>;
1776
4353
  type PlanSetInput = z.input<typeof PlanSetInputSchema>;
1777
- /** `warnings[].code` — bilinen değerler; küme açık. */
4354
+ /** `warnings[].code` — open set. None is produced since the billing core; `subscription_plan_higher` is legacy. */
1778
4355
  type PlanSetWarningCode = "subscription_plan_higher" | (string & Record<never, never>);
1779
4356
  declare const PlanSetWarningSchema: z.ZodObject<{
1780
4357
  code: z.ZodString;
@@ -1788,6 +4365,7 @@ declare const PlanSetResponseSchema: z.ZodObject<{
1788
4365
  accountRef: z.ZodString;
1789
4366
  planCode: z.ZodNullable<z.ZodString>;
1790
4367
  overrides: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodBoolean, z.ZodString, z.ZodNull]>>;
4368
+ benefitCodes: z.ZodOptional<z.ZodArray<z.ZodString>>;
1791
4369
  reason: z.ZodString;
1792
4370
  actorRef: z.ZodNullable<z.ZodString>;
1793
4371
  startsAt: z.ZodISODateTime;
@@ -1839,6 +4417,7 @@ declare const PlanSetResponseSchema: z.ZodObject<{
1839
4417
  year: "year";
1840
4418
  }>;
1841
4419
  effectiveAt: z.ZodISODateTime;
4420
+ amountMinor: z.ZodOptional<z.ZodNumber>;
1842
4421
  }, z.core.$strip>>;
1843
4422
  }, z.core.$strip>>;
1844
4423
  openCheckout: z.ZodNullable<z.ZodObject<{
@@ -1860,6 +4439,71 @@ declare const PlanSetResponseSchema: z.ZodObject<{
1860
4439
  company: "company";
1861
4440
  }>>;
1862
4441
  }, z.core.$strip>;
4442
+ subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
4443
+ id: z.ZodUUID;
4444
+ status: z.ZodEnum<{
4445
+ active: "active";
4446
+ suspended: "suspended";
4447
+ past_due: "past_due";
4448
+ canceled: "canceled";
4449
+ expired: "expired";
4450
+ }>;
4451
+ planCode: z.ZodString;
4452
+ interval: z.ZodEnum<{
4453
+ month: "month";
4454
+ year: "year";
4455
+ }>;
4456
+ amountMinor: z.ZodNumber;
4457
+ currency: z.ZodString;
4458
+ currentPeriodEnd: z.ZodNullable<z.ZodISODateTime>;
4459
+ cancelAt: z.ZodNullable<z.ZodISODateTime>;
4460
+ cancelAtPeriodEnd: z.ZodBoolean;
4461
+ pastDueSince: z.ZodNullable<z.ZodISODateTime>;
4462
+ currentPeriodStart: z.ZodNullable<z.ZodISODateTime>;
4463
+ dunning: z.ZodNullable<z.ZodObject<{
4464
+ step: z.ZodNumber;
4465
+ nextActionAt: z.ZodNullable<z.ZodISODateTime>;
4466
+ }, z.core.$strip>>;
4467
+ scheduledChange: z.ZodNullable<z.ZodObject<{
4468
+ planCode: z.ZodString;
4469
+ interval: z.ZodEnum<{
4470
+ month: "month";
4471
+ year: "year";
4472
+ }>;
4473
+ effectiveAt: z.ZodISODateTime;
4474
+ amountMinor: z.ZodOptional<z.ZodNumber>;
4475
+ }, z.core.$strip>>;
4476
+ }, z.core.$strip>>>;
4477
+ openInvoices: z.ZodOptional<z.ZodArray<z.ZodObject<{
4478
+ id: z.ZodUUID;
4479
+ subscriptionId: z.ZodNullable<z.ZodUUID>;
4480
+ billingReason: z.ZodEnum<{
4481
+ subscription_create: "subscription_create";
4482
+ subscription_cycle: "subscription_cycle";
4483
+ subscription_update: "subscription_update";
4484
+ purchase: "purchase";
4485
+ manual: "manual";
4486
+ }>;
4487
+ totalMinor: z.ZodNumber;
4488
+ currency: z.ZodString;
4489
+ dueAt: z.ZodISODateTime;
4490
+ }, z.core.$strip>>>;
4491
+ benefits: z.ZodOptional<z.ZodArray<z.ZodObject<{
4492
+ code: z.ZodNullable<z.ZodString>;
4493
+ type: z.ZodString;
4494
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4495
+ source: z.ZodString;
4496
+ grantedAt: z.ZodISODateTime;
4497
+ }, z.core.$strip>>>;
4498
+ meters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
4499
+ includedUnits: z.ZodNullable<z.ZodNumber>;
4500
+ billable: z.ZodBoolean;
4501
+ standing: z.ZodEnum<{
4502
+ ok: "ok";
4503
+ low: "low";
4504
+ exhausted: "exhausted";
4505
+ }>;
4506
+ }, z.core.$strip>>>;
1863
4507
  }, z.core.$strip>;
1864
4508
  warnings: z.ZodArray<z.ZodObject<{
1865
4509
  code: z.ZodString;
@@ -1874,7 +4518,7 @@ declare const ResyncResultSchema: z.ZodObject<{
1874
4518
  type ResyncResult = z.infer<typeof ResyncResultSchema>;
1875
4519
  //#endregion
1876
4520
  //#region ../contract/src/emails.d.ts
1877
- declare const EMAIL_TEMPLATES: readonly ["subscription_started", "payment_receipt", "payment_failed", "cancel_scheduled", "subscription_ended", "access_suspended", "subscription_terminated", "invoice_issued"];
4521
+ declare const EMAIL_TEMPLATES: readonly ["subscription_started", "payment_receipt", "payment_failed", "cancel_scheduled", "subscription_ended", "access_suspended", "subscription_terminated", "invoice_issued", "invoice_payment_due", "price_change_notice"];
1878
4522
  declare const EmailTemplateSchema: z.ZodEnum<{
1879
4523
  subscription_started: "subscription_started";
1880
4524
  payment_receipt: "payment_receipt";
@@ -1884,9 +4528,170 @@ declare const EmailTemplateSchema: z.ZodEnum<{
1884
4528
  access_suspended: "access_suspended";
1885
4529
  subscription_terminated: "subscription_terminated";
1886
4530
  invoice_issued: "invoice_issued";
4531
+ invoice_payment_due: "invoice_payment_due";
4532
+ price_change_notice: "price_change_notice";
1887
4533
  }>;
1888
4534
  type EmailTemplate = z.infer<typeof EmailTemplateSchema>;
1889
- /** Which event triggers which template. Events not listed send no email. */
4535
+ /** `invoice_payment_due`: summary of an unpaid invoice, its due date and the hosted pay page link. */
4536
+ declare const InvoicePaymentDueEmailSchema: z.ZodObject<{
4537
+ invoiceId: z.ZodUUID;
4538
+ number: z.ZodNullable<z.ZodString>;
4539
+ billingReason: z.ZodEnum<{
4540
+ subscription_create: "subscription_create";
4541
+ subscription_cycle: "subscription_cycle";
4542
+ subscription_update: "subscription_update";
4543
+ purchase: "purchase";
4544
+ manual: "manual";
4545
+ }>;
4546
+ planName: z.ZodNullable<z.ZodString>;
4547
+ totalMinor: z.ZodNumber;
4548
+ currency: z.ZodString;
4549
+ periodStart: z.ZodNullable<z.ZodISODateTime>;
4550
+ periodEnd: z.ZodNullable<z.ZodISODateTime>;
4551
+ dueAt: z.ZodISODateTime;
4552
+ payUrl: z.ZodURL;
4553
+ reminder: z.ZodBoolean;
4554
+ }, z.core.$strip>;
4555
+ type InvoicePaymentDueEmail = z.infer<typeof InvoicePaymentDueEmailSchema>;
4556
+ /** A metered (overage) rate as a notice shows it: `amountMinor` per `perUnits` units, at most `capMinor` per usage period. */
4557
+ declare const NoticedMeteredRateSchema: z.ZodObject<{
4558
+ amountMinor: z.ZodNumber;
4559
+ perUnits: z.ZodNumber;
4560
+ capMinor: z.ZodNullable<z.ZodNumber>;
4561
+ }, z.core.$strip>;
4562
+ type NoticedMeteredRate = z.infer<typeof NoticedMeteredRateSchema>;
4563
+ /**
4564
+ * One meter whose overage rate changes with the move to the current terms (metering M20, M36): the
4565
+ * subscription's locked rate and the plan's current one, in the notice's currency and tax terms.
4566
+ * The meter's labels as they were when the notice was written (the e-mail is never recomputed).
4567
+ */
4568
+ declare const PriceChangeNoticeMeteredRateSchema: z.ZodObject<{
4569
+ meter: z.ZodString;
4570
+ label: z.ZodObject<{
4571
+ tr: z.ZodString;
4572
+ en: z.ZodString;
4573
+ }, z.core.$strip>;
4574
+ unitLabel: z.ZodNullable<z.ZodObject<{
4575
+ tr: z.ZodString;
4576
+ en: z.ZodString;
4577
+ }, z.core.$strip>>;
4578
+ displayPer: z.ZodNullable<z.ZodNumber>;
4579
+ oldRate: z.ZodNullable<z.ZodObject<{
4580
+ amountMinor: z.ZodNumber;
4581
+ perUnits: z.ZodNumber;
4582
+ capMinor: z.ZodNullable<z.ZodNumber>;
4583
+ }, z.core.$strip>>;
4584
+ newRate: z.ZodNullable<z.ZodObject<{
4585
+ amountMinor: z.ZodNumber;
4586
+ perUnits: z.ZodNumber;
4587
+ capMinor: z.ZodNullable<z.ZodNumber>;
4588
+ }, z.core.$strip>>;
4589
+ }, z.core.$strip>;
4590
+ type PriceChangeNoticeMeteredRate = z.infer<typeof PriceChangeNoticeMeteredRateSchema>;
4591
+ /**
4592
+ * `price_change_notice`: a subscription moves to the current terms of its plan from `effectiveAt` —
4593
+ * its per-period amount and/or its metered rates (`meteredRates`: only the meters whose rate
4594
+ * changes; absent when none does). Old and new amount are equal when only metered rates change.
4595
+ */
4596
+ declare const PriceChangeNoticeEmailSchema: z.ZodObject<{
4597
+ subscriptionId: z.ZodUUID;
4598
+ planCode: z.ZodString;
4599
+ planName: z.ZodString;
4600
+ interval: z.ZodEnum<{
4601
+ month: "month";
4602
+ year: "year";
4603
+ }>;
4604
+ currency: z.ZodString;
4605
+ oldAmountMinor: z.ZodNumber;
4606
+ newAmountMinor: z.ZodNumber;
4607
+ taxInclusive: z.ZodBoolean;
4608
+ effectiveAt: z.ZodISODateTime;
4609
+ meteredRates: z.ZodOptional<z.ZodArray<z.ZodObject<{
4610
+ meter: z.ZodString;
4611
+ label: z.ZodObject<{
4612
+ tr: z.ZodString;
4613
+ en: z.ZodString;
4614
+ }, z.core.$strip>;
4615
+ unitLabel: z.ZodNullable<z.ZodObject<{
4616
+ tr: z.ZodString;
4617
+ en: z.ZodString;
4618
+ }, z.core.$strip>>;
4619
+ displayPer: z.ZodNullable<z.ZodNumber>;
4620
+ oldRate: z.ZodNullable<z.ZodObject<{
4621
+ amountMinor: z.ZodNumber;
4622
+ perUnits: z.ZodNumber;
4623
+ capMinor: z.ZodNullable<z.ZodNumber>;
4624
+ }, z.core.$strip>>;
4625
+ newRate: z.ZodNullable<z.ZodObject<{
4626
+ amountMinor: z.ZodNumber;
4627
+ perUnits: z.ZodNumber;
4628
+ capMinor: z.ZodNullable<z.ZodNumber>;
4629
+ }, z.core.$strip>>;
4630
+ }, z.core.$strip>>>;
4631
+ }, z.core.$strip>;
4632
+ type PriceChangeNoticeEmail = z.infer<typeof PriceChangeNoticeEmailSchema>;
4633
+ /** Payload schema per billing core template. */
4634
+ declare const EMAIL_PAYLOAD_SCHEMAS: Readonly<{
4635
+ readonly invoice_payment_due: z.ZodObject<{
4636
+ invoiceId: z.ZodUUID;
4637
+ number: z.ZodNullable<z.ZodString>;
4638
+ billingReason: z.ZodEnum<{
4639
+ subscription_create: "subscription_create";
4640
+ subscription_cycle: "subscription_cycle";
4641
+ subscription_update: "subscription_update";
4642
+ purchase: "purchase";
4643
+ manual: "manual";
4644
+ }>;
4645
+ planName: z.ZodNullable<z.ZodString>;
4646
+ totalMinor: z.ZodNumber;
4647
+ currency: z.ZodString;
4648
+ periodStart: z.ZodNullable<z.ZodISODateTime>;
4649
+ periodEnd: z.ZodNullable<z.ZodISODateTime>;
4650
+ dueAt: z.ZodISODateTime;
4651
+ payUrl: z.ZodURL;
4652
+ reminder: z.ZodBoolean;
4653
+ }, z.core.$strip>;
4654
+ readonly price_change_notice: z.ZodObject<{
4655
+ subscriptionId: z.ZodUUID;
4656
+ planCode: z.ZodString;
4657
+ planName: z.ZodString;
4658
+ interval: z.ZodEnum<{
4659
+ month: "month";
4660
+ year: "year";
4661
+ }>;
4662
+ currency: z.ZodString;
4663
+ oldAmountMinor: z.ZodNumber;
4664
+ newAmountMinor: z.ZodNumber;
4665
+ taxInclusive: z.ZodBoolean;
4666
+ effectiveAt: z.ZodISODateTime;
4667
+ meteredRates: z.ZodOptional<z.ZodArray<z.ZodObject<{
4668
+ meter: z.ZodString;
4669
+ label: z.ZodObject<{
4670
+ tr: z.ZodString;
4671
+ en: z.ZodString;
4672
+ }, z.core.$strip>;
4673
+ unitLabel: z.ZodNullable<z.ZodObject<{
4674
+ tr: z.ZodString;
4675
+ en: z.ZodString;
4676
+ }, z.core.$strip>>;
4677
+ displayPer: z.ZodNullable<z.ZodNumber>;
4678
+ oldRate: z.ZodNullable<z.ZodObject<{
4679
+ amountMinor: z.ZodNumber;
4680
+ perUnits: z.ZodNumber;
4681
+ capMinor: z.ZodNullable<z.ZodNumber>;
4682
+ }, z.core.$strip>>;
4683
+ newRate: z.ZodNullable<z.ZodObject<{
4684
+ amountMinor: z.ZodNumber;
4685
+ perUnits: z.ZodNumber;
4686
+ capMinor: z.ZodNullable<z.ZodNumber>;
4687
+ }, z.core.$strip>>;
4688
+ }, z.core.$strip>>>;
4689
+ }, z.core.$strip>;
4690
+ }>;
4691
+ /**
4692
+ * Which event triggers which template. Events not listed send no email. The billing core
4693
+ * templates (`invoice_payment_due`, `price_change_notice`) are not triggered by an event type alone.
4694
+ */
1890
4695
  declare const EMAIL_TEMPLATE_BY_EVENT: Readonly<Partial<Record<EventType, EmailTemplate>>>;
1891
4696
  declare function emailTemplateOf(type: string): EmailTemplate | null;
1892
4697
  declare const EMAIL_LOCALES: readonly ["tr", "en"];
@@ -1982,6 +4787,20 @@ declare const EmailSettingsSchema: z.ZodObject<{
1982
4787
  en: z.ZodOptional<z.ZodString>;
1983
4788
  }, z.core.$strip>>;
1984
4789
  }, z.core.$strip>>;
4790
+ invoice_payment_due: z.ZodOptional<z.ZodObject<{
4791
+ enabled: z.ZodDefault<z.ZodBoolean>;
4792
+ extraText: z.ZodOptional<z.ZodObject<{
4793
+ tr: z.ZodOptional<z.ZodString>;
4794
+ en: z.ZodOptional<z.ZodString>;
4795
+ }, z.core.$strip>>;
4796
+ }, z.core.$strip>>;
4797
+ price_change_notice: z.ZodOptional<z.ZodObject<{
4798
+ enabled: z.ZodDefault<z.ZodBoolean>;
4799
+ extraText: z.ZodOptional<z.ZodObject<{
4800
+ tr: z.ZodOptional<z.ZodString>;
4801
+ en: z.ZodOptional<z.ZodString>;
4802
+ }, z.core.$strip>>;
4803
+ }, z.core.$strip>>;
1985
4804
  }, z.core.$strip>>;
1986
4805
  }, z.core.$strip>;
1987
4806
  type EmailSettings = z.output<typeof EmailSettingsSchema>;
@@ -2025,6 +4844,14 @@ declare const EmailSettingsPatchSchema: z.ZodObject<{
2025
4844
  enabled: z.ZodOptional<z.ZodBoolean>;
2026
4845
  extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2027
4846
  }, z.core.$strict>>>;
4847
+ invoice_payment_due: z.ZodOptional<z.ZodNullable<z.ZodObject<{
4848
+ enabled: z.ZodOptional<z.ZodBoolean>;
4849
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
4850
+ }, z.core.$strict>>>;
4851
+ price_change_notice: z.ZodOptional<z.ZodNullable<z.ZodObject<{
4852
+ enabled: z.ZodOptional<z.ZodBoolean>;
4853
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
4854
+ }, z.core.$strict>>>;
2028
4855
  }, z.core.$strict>>;
2029
4856
  }, z.core.$strict>;
2030
4857
  type EmailSettingsPatch = z.output<typeof EmailSettingsPatchSchema>;
@@ -2039,15 +4866,25 @@ declare function billingPageUrl(appUrl: string | undefined, billingPath: string
2039
4866
  type EmailRelevanceFacts = {
2040
4867
  /** Current (stored) account state at send time. */
2041
4868
  state: AccountState;
2042
- /** `detail.subscriptionId` of the triggering event, if any. */
4869
+ /** `detail.subscriptionId` of the triggering event, if any (looked up in `state.subscriptions`). */
2043
4870
  subscriptionId: string | null;
2044
4871
  /** Current status of the invoice (`invoice_issued`). */
2045
4872
  invoiceStatus?: string | null;
4873
+ /** Current payment status of the invoice (`invoice_payment_due`). */
4874
+ invoicePaymentStatus?: string | null;
2046
4875
  };
4876
+ /**
4877
+ * The event's subscription among the account's live subscriptions at send time, or null when it
4878
+ * is not live. Looked up by id in `subscriptions` (billing core, M34: any live subscription, not
4879
+ * only the primary one); a state without that list (older steward) has only the primary
4880
+ * `subscription`.
4881
+ */
4882
+ declare function liveSubscriptionOf(state: AccountState, subscriptionId: string | null): AccountState["subscription"];
2047
4883
  /**
2048
4884
  * Whether the email still describes the account at send time. Receipts, the welcome email
2049
4885
  * (legal confirmation) and the final termination notice always go; the others only while
2050
- * the situation they describe still holds.
4886
+ * the situation they describe still holds for the event's subscription (which need not be the
4887
+ * primary one when the account has several).
2051
4888
  */
2052
4889
  declare function isEmailRelevant(template: EmailTemplate, facts: EmailRelevanceFacts): boolean;
2053
4890
  //#endregion
@@ -2072,6 +4909,59 @@ declare const BrandingSchema: z.ZodObject<{
2072
4909
  supportEmail: z.ZodOptional<z.ZodEmail>;
2073
4910
  }, z.core.$strip>;
2074
4911
  type Branding = z.infer<typeof BrandingSchema>;
4912
+ declare const DEFAULT_PAYMENT_DUE_DAYS = 7;
4913
+ declare const DEFAULT_MIN_INVOICE_MINOR = 1000;
4914
+ declare const PaymentDueDaysSchema: z.ZodNumber;
4915
+ declare const BillingSettingsSchema: z.ZodObject<{
4916
+ paymentDueDays: z.ZodDefault<z.ZodNumber>;
4917
+ minInvoiceMinor: z.ZodDefault<z.ZodNumber>;
4918
+ allowMultipleSubscriptions: z.ZodDefault<z.ZodBoolean>;
4919
+ }, z.core.$strip>;
4920
+ type BillingSettings = z.output<typeof BillingSettingsSchema>;
4921
+ /** Patch of `settings.billing`: an omitted field is unchanged, `null` restores its default. */
4922
+ declare const BillingSettingsPatchSchema: z.ZodObject<{
4923
+ paymentDueDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
4924
+ minInvoiceMinor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
4925
+ allowMultipleSubscriptions: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
4926
+ }, z.core.$strict>;
4927
+ declare const DEFAULT_EVENT_RETENTION_DAYS = 120;
4928
+ declare const DEFAULT_LATE_GRACE_MINUTES = 60;
4929
+ declare const METER_CHARGE_MODES: readonly ["off", "dry_run", "live"];
4930
+ declare const MeterChargeModeSchema: z.ZodEnum<{
4931
+ off: "off";
4932
+ dry_run: "dry_run";
4933
+ live: "live";
4934
+ }>;
4935
+ type MeterChargeMode = z.infer<typeof MeterChargeModeSchema>;
4936
+ declare const DEFAULT_METER_CHARGE_MODE: MeterChargeMode;
4937
+ declare const EventRetentionDaysSchema: z.ZodNumber;
4938
+ declare const LateGraceMinutesSchema: z.ZodNumber;
4939
+ declare const EventsSettingsSchema: z.ZodObject<{
4940
+ retentionDays: z.ZodDefault<z.ZodNumber>;
4941
+ }, z.core.$strip>;
4942
+ type EventsSettings = z.output<typeof EventsSettingsSchema>;
4943
+ declare const MeteringSettingsSchema: z.ZodObject<{
4944
+ lateGraceMinutes: z.ZodDefault<z.ZodNumber>;
4945
+ chargeMode: z.ZodDefault<z.ZodEnum<{
4946
+ off: "off";
4947
+ dry_run: "dry_run";
4948
+ live: "live";
4949
+ }>>;
4950
+ }, z.core.$strip>;
4951
+ type MeteringSettings = z.output<typeof MeteringSettingsSchema>;
4952
+ /** Patch of `settings.events`: an omitted field is unchanged, `null` restores its default. */
4953
+ declare const EventsSettingsPatchSchema: z.ZodObject<{
4954
+ retentionDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
4955
+ }, z.core.$strict>;
4956
+ /** Patch of `settings.metering`: an omitted field is unchanged, `null` restores its default. */
4957
+ declare const MeteringSettingsPatchSchema: z.ZodObject<{
4958
+ lateGraceMinutes: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
4959
+ chargeMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
4960
+ off: "off";
4961
+ dry_run: "dry_run";
4962
+ live: "live";
4963
+ }>>>;
4964
+ }, z.core.$strict>;
2075
4965
  declare const ProductSettingsSchema: z.ZodObject<{
2076
4966
  provider: z.ZodDefault<z.ZodString>;
2077
4967
  appUrl: z.ZodOptional<z.ZodURL>;
@@ -2155,10 +5045,46 @@ declare const ProductSettingsSchema: z.ZodObject<{
2155
5045
  en: z.ZodOptional<z.ZodString>;
2156
5046
  }, z.core.$strip>>;
2157
5047
  }, z.core.$strip>>;
5048
+ invoice_payment_due: z.ZodOptional<z.ZodObject<{
5049
+ enabled: z.ZodDefault<z.ZodBoolean>;
5050
+ extraText: z.ZodOptional<z.ZodObject<{
5051
+ tr: z.ZodOptional<z.ZodString>;
5052
+ en: z.ZodOptional<z.ZodString>;
5053
+ }, z.core.$strip>>;
5054
+ }, z.core.$strip>>;
5055
+ price_change_notice: z.ZodOptional<z.ZodObject<{
5056
+ enabled: z.ZodDefault<z.ZodBoolean>;
5057
+ extraText: z.ZodOptional<z.ZodObject<{
5058
+ tr: z.ZodOptional<z.ZodString>;
5059
+ en: z.ZodOptional<z.ZodString>;
5060
+ }, z.core.$strip>>;
5061
+ }, z.core.$strip>>;
2158
5062
  }, z.core.$strip>>;
2159
5063
  }, z.core.$strip>>;
5064
+ billing: z.ZodOptional<z.ZodObject<{
5065
+ paymentDueDays: z.ZodDefault<z.ZodNumber>;
5066
+ minInvoiceMinor: z.ZodDefault<z.ZodNumber>;
5067
+ allowMultipleSubscriptions: z.ZodDefault<z.ZodBoolean>;
5068
+ }, z.core.$strip>>;
5069
+ events: z.ZodOptional<z.ZodObject<{
5070
+ retentionDays: z.ZodDefault<z.ZodNumber>;
5071
+ }, z.core.$strip>>;
5072
+ metering: z.ZodOptional<z.ZodObject<{
5073
+ lateGraceMinutes: z.ZodDefault<z.ZodNumber>;
5074
+ chargeMode: z.ZodDefault<z.ZodEnum<{
5075
+ off: "off";
5076
+ dry_run: "dry_run";
5077
+ live: "live";
5078
+ }>>;
5079
+ }, z.core.$strip>>;
2160
5080
  }, z.core.$strip>;
2161
5081
  type ProductSettings = z.output<typeof ProductSettingsSchema>;
5082
+ /** `settings.billing` with defaults filled in. */
5083
+ declare function billingSettingsOf(settings: Pick<ProductSettings, "billing">): BillingSettings;
5084
+ /** `settings.events` with defaults filled in. */
5085
+ declare function eventsSettingsOf(settings: Pick<ProductSettings, "events">): EventsSettings;
5086
+ /** `settings.metering` with defaults filled in. */
5087
+ declare function meteringSettingsOf(settings: Pick<ProductSettings, "metering">): MeteringSettings;
2162
5088
  declare const BrandingPatchSchema: z.ZodObject<{
2163
5089
  name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2164
5090
  logoUrl: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
@@ -2224,8 +5150,32 @@ declare const ProductSettingsPatchSchema: z.ZodObject<{
2224
5150
  enabled: z.ZodOptional<z.ZodBoolean>;
2225
5151
  extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
2226
5152
  }, z.core.$strict>>>;
5153
+ invoice_payment_due: z.ZodOptional<z.ZodNullable<z.ZodObject<{
5154
+ enabled: z.ZodOptional<z.ZodBoolean>;
5155
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
5156
+ }, z.core.$strict>>>;
5157
+ price_change_notice: z.ZodOptional<z.ZodNullable<z.ZodObject<{
5158
+ enabled: z.ZodOptional<z.ZodBoolean>;
5159
+ extraText: z.ZodOptional<typeof EmailExtraTextSchema>;
5160
+ }, z.core.$strict>>>;
2227
5161
  }, z.core.$strict>>;
2228
5162
  }, z.core.$strict>>>;
5163
+ billing: z.ZodOptional<z.ZodNullable<z.ZodObject<{
5164
+ paymentDueDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
5165
+ minInvoiceMinor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
5166
+ allowMultipleSubscriptions: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
5167
+ }, z.core.$strict>>>;
5168
+ events: z.ZodOptional<z.ZodNullable<z.ZodObject<{
5169
+ retentionDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
5170
+ }, z.core.$strict>>>;
5171
+ metering: z.ZodOptional<z.ZodNullable<z.ZodObject<{
5172
+ lateGraceMinutes: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
5173
+ chargeMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
5174
+ off: "off";
5175
+ dry_run: "dry_run";
5176
+ live: "live";
5177
+ }>>>;
5178
+ }, z.core.$strict>>>;
2229
5179
  }, z.core.$strict>;
2230
5180
  type ProductSettingsPatch = z.input<typeof ProductSettingsPatchSchema>;
2231
5181
  /**
@@ -2267,6 +5217,13 @@ declare const EventTypeSchema: z.ZodEnum<{
2267
5217
  "invoice.voided": "invoice.voided";
2268
5218
  "account.state_changed": "account.state_changed";
2269
5219
  "account.deleted": "account.deleted";
5220
+ "invoice.paid": "invoice.paid";
5221
+ "benefit_grant.created": "benefit_grant.created";
5222
+ "benefit_grant.updated": "benefit_grant.updated";
5223
+ "benefit_grant.revoked": "benefit_grant.revoked";
5224
+ "benefit_grant.cycled": "benefit_grant.cycled";
5225
+ "meter.threshold_crossed": "meter.threshold_crossed";
5226
+ "meter.period_closed": "meter.period_closed";
2270
5227
  }>;
2271
5228
  declare const WEBHOOK_ENDPOINT_STATUSES: readonly ["active", "paused", "inactive"];
2272
5229
  declare const WebhookEndpointStatusSchema: z.ZodEnum<{
@@ -2306,7 +5263,14 @@ declare const WebhookEndpointCreateInputSchema: z.ZodObject<{
2306
5263
  "invoice.voided": "invoice.voided";
2307
5264
  "account.state_changed": "account.state_changed";
2308
5265
  "account.deleted": "account.deleted";
2309
- }>>, z.ZodTransform<("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" | "invoice.voided" | "account.state_changed" | "account.deleted")[], ("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" | "invoice.voided" | "account.state_changed" | "account.deleted")[]>>>;
5266
+ "invoice.paid": "invoice.paid";
5267
+ "benefit_grant.created": "benefit_grant.created";
5268
+ "benefit_grant.updated": "benefit_grant.updated";
5269
+ "benefit_grant.revoked": "benefit_grant.revoked";
5270
+ "benefit_grant.cycled": "benefit_grant.cycled";
5271
+ "meter.threshold_crossed": "meter.threshold_crossed";
5272
+ "meter.period_closed": "meter.period_closed";
5273
+ }>>, z.ZodTransform<("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" | "invoice.voided" | "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")[], ("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" | "invoice.voided" | "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")[]>>>;
2310
5274
  description: z.ZodOptional<z.ZodString>;
2311
5275
  }, z.core.$strict>;
2312
5276
  type WebhookEndpointCreateInput = z.input<typeof WebhookEndpointCreateInputSchema>;
@@ -2361,6 +5325,13 @@ declare const WebhookEndpointSchema: z.ZodObject<{
2361
5325
  "invoice.voided": "invoice.voided";
2362
5326
  "account.state_changed": "account.state_changed";
2363
5327
  "account.deleted": "account.deleted";
5328
+ "invoice.paid": "invoice.paid";
5329
+ "benefit_grant.created": "benefit_grant.created";
5330
+ "benefit_grant.updated": "benefit_grant.updated";
5331
+ "benefit_grant.revoked": "benefit_grant.revoked";
5332
+ "benefit_grant.cycled": "benefit_grant.cycled";
5333
+ "meter.threshold_crossed": "meter.threshold_crossed";
5334
+ "meter.period_closed": "meter.period_closed";
2364
5335
  }>>>;
2365
5336
  description: z.ZodNullable<z.ZodString>;
2366
5337
  createdAt: z.ZodISODateTime;
@@ -2407,6 +5378,13 @@ declare const WebhookEndpointListSchema: z.ZodObject<{
2407
5378
  "invoice.voided": "invoice.voided";
2408
5379
  "account.state_changed": "account.state_changed";
2409
5380
  "account.deleted": "account.deleted";
5381
+ "invoice.paid": "invoice.paid";
5382
+ "benefit_grant.created": "benefit_grant.created";
5383
+ "benefit_grant.updated": "benefit_grant.updated";
5384
+ "benefit_grant.revoked": "benefit_grant.revoked";
5385
+ "benefit_grant.cycled": "benefit_grant.cycled";
5386
+ "meter.threshold_crossed": "meter.threshold_crossed";
5387
+ "meter.period_closed": "meter.period_closed";
2410
5388
  }>>>;
2411
5389
  description: z.ZodNullable<z.ZodString>;
2412
5390
  createdAt: z.ZodISODateTime;
@@ -2437,7 +5415,7 @@ declare const DoctorSeveritySchema: z.ZodEnum<{
2437
5415
  }>;
2438
5416
  type DoctorSeverity = z.infer<typeof DoctorSeveritySchema>;
2439
5417
  /** `warnings[].code` — bu sürümün ürettiği kodlar; küme açık. */
2440
- type DoctorWarningCode = "catalog_not_synced" | "price_not_synced_with_provider" | "price_unsellable" | "provider_not_configured" | "provider_unhealthy" | "no_return_origin" | "app_url_missing" | "branding_incomplete" | "legal_links_missing" | "no_active_endpoint" | "no_state_changed_endpoint" | "endpoint_wrong_secret" | "endpoint_old_contract" | "endpoint_unreachable" | "endpoint_failing" | "endpoint_dead_deliveries" | "endpoint_pending_backlog" | "dunning_dry_run" | "email_not_configured" | "email_sender_missing" | "email_billing_link_missing" | (string & Record<never, never>);
5418
+ type DoctorWarningCode = "catalog_not_synced" | "price_unsellable" | "price_drift" | "legacy_provider_subscription" | "provider_not_configured" | "provider_unhealthy" | "no_return_origin" | "app_url_missing" | "branding_incomplete" | "legal_links_missing" | "no_active_endpoint" | "no_state_changed_endpoint" | "endpoint_wrong_secret" | "endpoint_old_contract" | "endpoint_unreachable" | "endpoint_failing" | "endpoint_dead_deliveries" | "endpoint_pending_backlog" | "dunning_dry_run" | "email_not_configured" | "email_sender_missing" | "email_billing_link_missing" | "events_backlog" | "meter_rollup_lag" | "events_invalid_value" | "meter_without_events" | "events_unmatched" | "overage_charge_mode_off" | "overage_dry_run" | "overage_unrated_subscriptions" | (string & Record<never, never>);
2441
5419
  declare const DoctorWarningSchema: z.ZodObject<{
2442
5420
  code: z.ZodString;
2443
5421
  severity: z.ZodEnum<{
@@ -2450,10 +5428,10 @@ declare const DoctorWarningSchema: z.ZodObject<{
2450
5428
  }, z.core.$strip>;
2451
5429
  type DoctorWarning = z.infer<typeof DoctorWarningSchema>;
2452
5430
  /**
2453
- * Satılamayan fiyatın nedeni — küme açık:
2454
- * `provider_price_missing` (sağlayıcıda plan karşılığı yok; katalog senkronu yeniden koşulur),
2455
- * `provider_not_configured`, `unsupported_currency`, `interval_count_unsupported`
2456
- * (checkout yalnızca `intervalCount: 1` satar).
5431
+ * Why an active price cannot be sold — open set: `provider_not_configured`,
5432
+ * `unsupported_currency`, `interval_count_unsupported` (checkout sells `intervalCount: 1` only).
5433
+ * `provider_price_missing` (no provider plan for the price) is produced only by steward before the
5434
+ * billing core: prices live only in steward now (M30).
2457
5435
  */
2458
5436
  type DoctorUnsellableReason = "provider_price_missing" | "provider_not_configured" | "unsupported_currency" | "interval_count_unsupported" | (string & Record<never, never>);
2459
5437
  declare const DoctorUnsellablePriceSchema: z.ZodObject<{
@@ -2484,15 +5462,56 @@ declare const DoctorCatalogSchema: z.ZodObject<{
2484
5462
  currency: z.ZodString;
2485
5463
  reason: z.ZodString;
2486
5464
  }, z.core.$strip>>;
5465
+ priceDriftSubscriptions: z.ZodOptional<z.ZodNumber>;
2487
5466
  }, z.core.$strip>;
2488
5467
  type DoctorCatalog = z.infer<typeof DoctorCatalogSchema>;
5468
+ /** Billing core facts (M30). Absent from older steward. */
5469
+ declare const DoctorBillingSchema: z.ZodObject<{
5470
+ legacyProviderSubscriptions: z.ZodNumber;
5471
+ }, z.core.$strip>;
5472
+ type DoctorBilling = z.infer<typeof DoctorBillingSchema>;
5473
+ /**
5474
+ * Event ingest and rollup facts (metering phase 2, M29; only for a product that defines meters).
5475
+ * Absent from older steward. Names and meter codes only: no metadata, no account refs.
5476
+ */
5477
+ declare const DoctorEventsSchema: z.ZodObject<{
5478
+ meters: z.ZodNumber;
5479
+ backfillingMeters: z.ZodArray<z.ZodString>;
5480
+ backlogRows: z.ZodNumber;
5481
+ rollupLagSeconds: z.ZodNumber;
5482
+ backlogged: z.ZodBoolean;
5483
+ sampledEvents: z.ZodNumber;
5484
+ unmatchedEventNames: z.ZodArray<z.ZodObject<{
5485
+ name: z.ZodString;
5486
+ events: z.ZodNumber;
5487
+ }, z.core.$strip>>;
5488
+ invalidValues: z.ZodArray<z.ZodObject<{
5489
+ meter: z.ZodString;
5490
+ events: z.ZodNumber;
5491
+ }, z.core.$strip>>;
5492
+ metersWithoutEvents: z.ZodArray<z.ZodString>;
5493
+ }, z.core.$strip>;
5494
+ type DoctorEvents = z.infer<typeof DoctorEventsSchema>;
5495
+ /** Rollup lag above which the doctor warns (the `rollup lag > 60 s` alert, M29). */
5496
+ declare const DOCTOR_ROLLUP_LAG_WARN_SECONDS = 60;
5497
+ /**
5498
+ * Overage facts (metering MF5, M20/M21): present when the catalog has a metered price or the
5499
+ * product has meter charges. Absent from older steward.
5500
+ */
5501
+ declare const DoctorOverageSchema: z.ZodObject<{
5502
+ chargeMode: z.ZodString;
5503
+ meteredPrices: z.ZodNumber;
5504
+ unratedSubscriptions: z.ZodNumber;
5505
+ carriedCharges: z.ZodNumber;
5506
+ }, z.core.$strip>;
5507
+ type DoctorOverage = z.infer<typeof DoctorOverageSchema>;
2489
5508
  declare const DOCTOR_PROVIDER_ENVIRONMENTS: readonly ["sandbox", "live", "fake"];
2490
5509
  declare const DoctorProviderSchema: z.ZodObject<{
2491
5510
  id: z.ZodString;
2492
5511
  configured: z.ZodBoolean;
2493
5512
  environment: z.ZodNullable<z.ZodEnum<{
2494
- sandbox: "sandbox";
2495
5513
  live: "live";
5514
+ sandbox: "sandbox";
2496
5515
  fake: "fake";
2497
5516
  }>>;
2498
5517
  merchantId: z.ZodNullable<z.ZodString>;
@@ -2558,6 +5577,13 @@ declare const DoctorEndpointSchema: z.ZodObject<{
2558
5577
  "invoice.voided": "invoice.voided";
2559
5578
  "account.state_changed": "account.state_changed";
2560
5579
  "account.deleted": "account.deleted";
5580
+ "invoice.paid": "invoice.paid";
5581
+ "benefit_grant.created": "benefit_grant.created";
5582
+ "benefit_grant.updated": "benefit_grant.updated";
5583
+ "benefit_grant.revoked": "benefit_grant.revoked";
5584
+ "benefit_grant.cycled": "benefit_grant.cycled";
5585
+ "meter.threshold_crossed": "meter.threshold_crossed";
5586
+ "meter.period_closed": "meter.period_closed";
2561
5587
  }>>>;
2562
5588
  pending: z.ZodNumber;
2563
5589
  dead: z.ZodNumber;
@@ -2607,13 +5633,14 @@ declare const DoctorReportSchema: z.ZodObject<{
2607
5633
  currency: z.ZodString;
2608
5634
  reason: z.ZodString;
2609
5635
  }, z.core.$strip>>;
5636
+ priceDriftSubscriptions: z.ZodOptional<z.ZodNumber>;
2610
5637
  }, z.core.$strip>;
2611
5638
  provider: z.ZodObject<{
2612
5639
  id: z.ZodString;
2613
5640
  configured: z.ZodBoolean;
2614
5641
  environment: z.ZodNullable<z.ZodEnum<{
2615
- sandbox: "sandbox";
2616
5642
  live: "live";
5643
+ sandbox: "sandbox";
2617
5644
  fake: "fake";
2618
5645
  }>>;
2619
5646
  merchantId: z.ZodNullable<z.ZodString>;
@@ -2664,6 +5691,13 @@ declare const DoctorReportSchema: z.ZodObject<{
2664
5691
  "invoice.voided": "invoice.voided";
2665
5692
  "account.state_changed": "account.state_changed";
2666
5693
  "account.deleted": "account.deleted";
5694
+ "invoice.paid": "invoice.paid";
5695
+ "benefit_grant.created": "benefit_grant.created";
5696
+ "benefit_grant.updated": "benefit_grant.updated";
5697
+ "benefit_grant.revoked": "benefit_grant.revoked";
5698
+ "benefit_grant.cycled": "benefit_grant.cycled";
5699
+ "meter.threshold_crossed": "meter.threshold_crossed";
5700
+ "meter.period_closed": "meter.period_closed";
2667
5701
  }>>>;
2668
5702
  pending: z.ZodNumber;
2669
5703
  dead: z.ZodNumber;
@@ -2690,6 +5724,32 @@ declare const DoctorReportSchema: z.ZodObject<{
2690
5724
  disabledTemplates: z.ZodArray<z.ZodString>;
2691
5725
  ready: z.ZodBoolean;
2692
5726
  }, z.core.$strip>>;
5727
+ billing: z.ZodOptional<z.ZodObject<{
5728
+ legacyProviderSubscriptions: z.ZodNumber;
5729
+ }, z.core.$strip>>;
5730
+ events: z.ZodOptional<z.ZodObject<{
5731
+ meters: z.ZodNumber;
5732
+ backfillingMeters: z.ZodArray<z.ZodString>;
5733
+ backlogRows: z.ZodNumber;
5734
+ rollupLagSeconds: z.ZodNumber;
5735
+ backlogged: z.ZodBoolean;
5736
+ sampledEvents: z.ZodNumber;
5737
+ unmatchedEventNames: z.ZodArray<z.ZodObject<{
5738
+ name: z.ZodString;
5739
+ events: z.ZodNumber;
5740
+ }, z.core.$strip>>;
5741
+ invalidValues: z.ZodArray<z.ZodObject<{
5742
+ meter: z.ZodString;
5743
+ events: z.ZodNumber;
5744
+ }, z.core.$strip>>;
5745
+ metersWithoutEvents: z.ZodArray<z.ZodString>;
5746
+ }, z.core.$strip>>;
5747
+ overage: z.ZodOptional<z.ZodObject<{
5748
+ chargeMode: z.ZodString;
5749
+ meteredPrices: z.ZodNumber;
5750
+ unratedSubscriptions: z.ZodNumber;
5751
+ carriedCharges: z.ZodNumber;
5752
+ }, z.core.$strip>>;
2693
5753
  warnings: z.ZodArray<z.ZodObject<{
2694
5754
  code: z.ZodString;
2695
5755
  severity: z.ZodEnum<{
@@ -2716,6 +5776,12 @@ type DoctorFacts = {
2716
5776
  configured: boolean;
2717
5777
  defaultFromConfigured: boolean;
2718
5778
  };
5779
+ /** Billing core facts; omitted: no billing section in the report. */
5780
+ billing?: DoctorBilling;
5781
+ /** Event ingest and rollup facts; omitted: no events section (a product without meters). */
5782
+ events?: DoctorEvents;
5783
+ /** Overage facts (MF5); omitted: no overage section in the report. */
5784
+ overage?: DoctorOverage;
2719
5785
  };
2720
5786
  /** Email readiness from settings and the deployment's transport (pure). */
2721
5787
  declare function emailReadinessOf(settings: DoctorFacts["settings"], transport: NonNullable<DoctorFacts["emailTransport"]>): DoctorEmails;
@@ -2728,4 +5794,4 @@ declare function hostedReadinessOf(settings: DoctorFacts["settings"]): DoctorHos
2728
5794
  /** Olgulardan raporu türetir (saf): endpoint teşhisleri, hosted hazırlığı, uyarılar ve `ok`. */
2729
5795
  declare function buildDoctorReport(facts: DoctorFacts): DoctorReport;
2730
5796
  //#endregion
2731
- export { Branding as $, CancelSubscriptionInputSchema as $n, PriceDef as $r, PlanSetWarningSchema as $t, buildDoctorReport as A, InvoiceIssueResponse as An, CheckoutSessionSchema as Ar, EmailTemplate as At, WebhookEndpointCreateInputSchema as B, InvoiceLineSchema as Bn, AccountsRefreshResultSchema as Br, emailTemplateOf as Bt, DoctorSeveritySchema as C, GrantCreateResponse as Cn, CheckoutReturnStatus as Cr, EmailLocale as Ct, DoctorWarning as D, HEADER_IDEMPOTENCY_KEY as Dn, CheckoutSessionCreateParsed as Dr, EmailSettingsPatch as Dt, DoctorUnsellableReason as E, HEADER_API_VERSION as En, CheckoutSessionCreateInputSchema as Er, EmailSettings as Et, EventTypeSchema as F, ManualInvoiceResponseSchema as Fn, MAX_CHECKOUT_CONSENT_DOCS as Fr, NotificationEmailsSchema as Ft, WebhookEndpointSchema as G, MANUAL_INVOICE_MAX_AMOUNT_MINOR as Gn, CatalogSyncResult as Gr, PlanSetInput as Gt, WebhookEndpointListSchema as H, InvoiceStatusSchema as Hn, CatalogSchema as Hr, isEmailRelevant as Ht, WEBHOOK_ENDPOINT_STATUSES as I, Invoice as In, ProviderPayload as Ir, applyEmailSettingsPatch as It, WebhookLastDelivery as J, ManualInvoiceLineInput as Jn, FeatureDefSchema as Jr, PlanSetModeSchema as Jt, WebhookEndpointStatus as K, ManualInvoiceInput as Kn, CatalogSyncResultSchema as Kr, PlanSetInputSchema as Kt, WEBHOOK_SECRET_PREFIX as L, InvoiceIssueInput as Ln, ProviderPayloadSchema as Lr, billingPageUrl as Lt, endpointDiagnosisOf as M, InvoiceVoidResponse as Mn, CheckoutStatusSchema as Mr, EmailTemplateSettings as Mt, hostedReadinessOf as N, InvoiceVoidResponseSchema as Nn, Consent as Nr, EmailTemplateSettingsSchema as Nt, DoctorWarningCode as O, HEADER_REQUEST_ID as On, CheckoutSessionCreated as Or, EmailSettingsPatchSchema as Ot, DEFAULT_ENDPOINT_EVENT_TYPES as P, ManualInvoiceResponse as Pn, ConsentSchema as Pr, MAX_NOTIFICATION_EMAILS as Pt, webhookEndpointUrlProblem as Q, CancelSubscriptionInput as Qn, Price as Qr, PlanSetWarningCode as Qt, WebhookEndpoint as R, InvoiceIssueInputSchema as Rn, checkoutRedirectUrl as Rr, emailLocaleOf as Rt, DoctorSeverity as S, MetadataSchema as Si, CheckoutSessionResponseSchema as Sn, CheckoutRedirectTarget as Sr, EmailExtraTextSchema as St, DoctorUnsellablePriceSchema as T, HEADER_ACTOR_REF as Tn, CheckoutSessionCreateInput as Tr, EmailSenderSchema as Tt, WebhookEndpointRotateInput as U, InvoiceVoidInput as Un, CatalogSyncInput as Ur, uniqueEmails as Ut, WebhookEndpointList as V, InvoiceSchema as Vn, Catalog as Vr, emailTemplateSettings as Vt, WebhookEndpointRotateInputSchema as W, InvoiceVoidInputSchema as Wn, CatalogSyncInputSchema as Wr, PLAN_SET_MODES as Wt, WebhookSecretSchema as X, manualInvoiceTotals as Xn, PlanDef as Xr, PlanSetResponseSchema as Xt, WebhookLastDeliverySchema as Y, ManualInvoiceLineInputSchema as Yn, FeatureTypeSchema as Yr, PlanSetResponse as Yt, generateWebhookSecret as Z, splitInclusiveTax as Zn, PlanDefSchema as Zr, PlanSetWarning as Zt, DoctorProviderSchema as _, ErrorResponseSchema as _i, AccountUpsertResponse as _n, CheckoutConsentInput as _r, BILLING_PATH_PLACEHOLDERS as _t, DOCTOR_SEVERITIES as a, CodeSchema as ai, ResolveEntitlementsInput as an, PaymentSchema as ar, ProductSettingsPatch as at, DoctorSettings as b, Interval as bi, CancelSubscriptionResponseSchema as bn, CheckoutPrefill as br, EMAIL_TEMPLATES as bt, DoctorEmails as c, DateTimeSchema as ci, isLiveSubscriptionStatus as cn, Subscription as cr, ReturnOriginSchema as ct, DoctorEndpointDiagnosis as d, EntitlementValueSchema as di, ErrorCode as dn, PortalSession as dr, SettingsLocaleSchema as dt, PriceDefSchema as ei, ResyncResult as en, Grant as er, BrandingPatchSchema as et, DoctorEndpointSchema as f, Entitlements as fi, ErrorCodeSpec as fn, PortalSessionCreateInput as fr, TtlMinutesSchema as ft, DoctorProvider as g, ErrorResponse as gi, AccountDetailSchema as gn, CHECKOUT_ERRORS as gr, returnOriginsOf as gt, DoctorHostedSchema as h, ErrorCategorySchema as hi, AccountDetail as hn, PortalSessionSchema as hr, isReturnUrlAllowed as ht, DOCTOR_REQUIRED_LEGAL_LINKS as i, AmountMinorSchema as ii, LIVE_SUBSCRIPTION_STATUSES as in, Payment as ir, ProductSettings as it, emailReadinessOf as j, InvoiceIssueResponseSchema as jn, CheckoutStatus as jr, EmailTemplateSchema as jt, DoctorWarningSchema as k, HEADER_SDK as kn, CheckoutSessionCreatedSchema as kr, EmailSettingsSchema as kt, DoctorEmailsSchema as l, ERROR_CATEGORIES as li, resolveEntitlements as ln, SubscriptionSchema as lr, SETTINGS_LOCALES as lt, DoctorHosted as m, ErrorCategory as mi, isKnownErrorCode as mn, PortalSessionError as mr, applySettingsPatch as mt, DOCTOR_PROVIDER_ENVIRONMENTS as n, API_VERSION as ni, EntitlementRulesCatalog as nn, GrantCreateInputSchema as nr, DEFAULT_CHECKOUT_TTL_MINUTES as nt, DoctorCatalog as o, Currency as oi, ResolvedEntitlements as on, Stats as or, ProductSettingsPatchSchema as ot, DoctorFacts as p, EntitlementsSchema as pi, errorCodeSpec as pn, PortalSessionCreateInputSchema as pr, WebUrlSchema as pt, WebhookEndpointStatusSchema as q, ManualInvoiceInputSchema as qn, FeatureDef as qr, PlanSetMode as qt, DOCTOR_REQUIRED_BRANDING as r, ActorRefSchema as ri, EntitlementRulesGrant as rn, GrantSchema as rr, DEFAULT_PORTAL_TTL_MINUTES as rt, DoctorCatalogSchema as s, CurrencySchema as si, isGrantActive as sn, StatsSchema as sr, ProductSettingsSchema as st, DOCTOR_PENDING_BACKLOG_MS as t, PriceSchema as ti, ResyncResultSchema as tn, GrantCreateInput as tr, BrandingSchema as tt, DoctorEndpoint as u, EntitlementValue as ui, ERROR_CODES as un, PORTAL_SESSION_ERRORS as ur, SettingsLocale as ut, DoctorReport as v, ExternalRefSchema as vi, AccountUpsertResponseSchema as vn, CheckoutConsentInputSchema as vr, BillingPathSchema as vt, DoctorUnsellablePrice as w, GrantCreateResponseSchema as wn, CheckoutSession as wr, EmailRelevanceFacts as wt, DoctorSettingsSchema as x, IntervalSchema as xi, CheckoutSessionResponse as xn, CheckoutPrefillSchema as xr, EMAIL_TEMPLATE_BY_EVENT as xt, DoctorReportSchema as y, IdSchema as yi, CancelSubscriptionResponse as yn, CheckoutError as yr, EMAIL_LOCALES as yt, WebhookEndpointCreateInput as z, InvoiceLine as zn, AccountsRefreshResult as zr, emailRecipients as zt };
5797
+ export { WebhookEndpointStatus as $, CatalogPlanSchema as $a, ManualInvoiceInputSchema as $i, matchesFilter as $n, MAX_METERED_PRICE_PER_UNITS as $o, ErrorCode as $r, canonicalMeterFilter as $s, EmailExtraTextSchema as $t, DoctorSeveritySchema as A, CheckoutPrefillSchema as Aa, MeResponse as Ai, PLAN_SET_MODES as An, CatalogBenefit as Ao, IngestRejectCode as Ar, MeterFilterClause as As, PaymentDueDaysSchema as At, hostedReadinessOf as B, CheckoutStatus as Ba, InvoiceLineSchema as Bi, ResyncResult as Bn, featureValueMatchesType as Bo, FEATURE_FLAG_BENEFIT_TYPE as Br, MeterPeriod as Bs, WebUrlSchema as Bt, DoctorProvider as C, PortalSessionError as Ca, InvoiceBillingReason as Cc, InvoiceIssueResponseSchema as Ci, emailLocaleOf as Cn, BenefitDefSchema as Co, EventsIngestInput as Cr, MeterCreditEntrySchema as Cs, LateGraceMinutesSchema as Ct, DoctorSettings as D, CheckoutConsentInputSchema as Da, MetadataSchema as Dc, InvoiceWaiveResponseSchema as Di, isEmailRelevant as Dn, BenefitSourceSchema as Do, INGEST_REJECT_CODES as Dr, MeterDefInput as Ds, MeteringSettings as Dt, DoctorReportSchema as E, CheckoutConsentInput as Ea, InvoicePaymentStatusSchema as Ec, InvoiceWaiveResponse as Ei, emailTemplateSettings as En, BenefitFeatureType as Eo, EventsIngestResultSchema as Er, MeterDef as Es, MeterChargeModeSchema as Et, DoctorWarningCode as F, CheckoutSessionCreateInputSchema as Fa, UncancelSubscriptionResponseSchema as Fi, PlanSetResponse as Fn, FeatureFlagProperties as Fo, isEventTimestampInRange as Fr, MeterFilterSchema as Fs, ReturnOriginSchema as Ft, WebhookEndpoint as G, MAX_CHECKOUT_CONSENT_DOCS as Ga, InvoiceSchema as Gi, MeterCreditBenefit as Gn, AccountMeters as Go, ResolvedBenefit as Gr, MeterPeriodStatusSchema as Gs, meteringSettingsOf as Gt, EventTypeSchema as H, Consent as Ha, InvoicePaymentSessionCreateInput as Hi, GrantedMeterCredit as Hn, isMeterCreditBenefit as Ho, OVERRIDE_BENEFIT_SOURCE as Hr, MeterPeriodListSchema as Hs, billingSettingsOf as Ht, DoctorWarningSchema as I, CheckoutSessionCreateParsed as Ia, Invoice as Ii, PlanSetResponseSchema as In, FeatureFlagPropertiesSchema as Io, BenefitRulesDefinition as Ir, MeterFilterValue as Is, SETTINGS_LOCALES as It, WebhookEndpointList as J, checkoutRedirectUrl as Ja, InvoiceVoidInputSchema as Ji, MeterRulesMeter as Jn, CatalogMeterSchema as Jo, isGrantActive as Jr, MeterUnitsSchema as Js, BillingPathSchema as Jt, WebhookEndpointCreateInput as K, ProviderPayload as Ka, InvoiceStatusSchema as Ki, MeterCreditsOptions as Kn, AccountMetersSchema as Ko, ResolvedBenefits as Kr, MeterStanding as Ks, returnOriginsOf as Kt, buildDoctorReport as L, CheckoutSessionCreated as La, InvoiceIssueInput as Li, PlanSetWarning as Ln, MeterCreditAccountBenefit as Lo, BenefitRulesSubscription as Lr, MeterLabel as Ls, SettingsLocale as Lt, DoctorUnsellablePriceSchema as M, CheckoutReturnStatus as Ma, STEWARD_CAPABILITIES as Mi, PlanSetInputSchema as Mn, FeatureFlagAccountBenefit as Mo, IngestRejection as Mr, MeterFilterGroup as Ms, ProductSettingsPatch as Mt, DoctorUnsellableReason as N, CheckoutSession as Na, StewardCapability as Ni, PlanSetMode as Nn, FeatureFlagBenefitDef as No, IngestRejectionSchema as Nr, MeterFilterOperand as Ns, ProductSettingsPatchSchema as Nt, DoctorSettingsSchema as O, CheckoutError as Oa, ManualInvoiceResponse as Oi, liveSubscriptionOf as On, BenefitType as Oo, IngestEvent as Or, MeterDefSchema as Os, MeteringSettingsPatchSchema as Ot, DoctorWarning as P, CheckoutSessionCreateInput as Pa, UncancelSubscriptionResponse as Pi, PlanSetModeSchema as Pn, FeatureFlagBenefitDefSchema as Po, hasControlCharacters as Pr, MeterFilterOperator as Ps, ProductSettingsSchema as Pt, WebhookEndpointSchema as Q, CatalogPlan as Qa, ManualInvoiceInput as Qi, contributionOf as Qn, DecimalUnitsStringSchema as Qo, ERROR_CODES as Qr, MeteredPriceSchema as Qs, EMAIL_TEMPLATE_BY_EVENT as Qt, emailReadinessOf as R, CheckoutSessionCreatedSchema as Ra, InvoiceIssueInputSchema as Ri, PlanSetWarningCode as Rn, MeterCreditBenefitDef as Ro, EntitlementRulesCatalog as Rr, MeterLabelSchema as Rs, SettingsLocaleSchema as Rt, DoctorOverageSchema as S, PortalSessionCreateInputSchema as Sa, IntervalSchema as Sc, InvoiceIssueResponse as Si, billingPageUrl as Sn, BenefitDef as So, EventNameSchema as Sr, MeterCreditEntryKindSchema as Ss, EventsSettingsSchema as St, DoctorReport as T, CHECKOUT_ERRORS as Ta, InvoicePaymentStatus as Tc, InvoiceVoidResponseSchema as Ti, emailTemplateOf as Tn, BenefitDescriptionSchema as To, EventsIngestResult as Tr, MeterCreditPropertiesSchema as Ts, MeterChargeMode as Tt, WEBHOOK_ENDPOINT_STATUSES as U, ConsentSchema as Ua, InvoicePaymentSessionCreateInputSchema as Ui, MeterChargeTotalsLine as Un, AccountMeter as Uo, ResolveBenefitsInput as Ur, MeterPeriodSchema as Us, eventsSettingsOf as Ut, DEFAULT_ENDPOINT_EVENT_TYPES as V, CheckoutStatusSchema as Va, InvoicePaymentSession as Vi, ResyncResultSchema as Vn, isFeatureFlagBenefit as Vo, LIVE_SUBSCRIPTION_STATUSES as Vr, MeterPeriodList as Vs, applySettingsPatch as Vt, WEBHOOK_SECRET_PREFIX as W, INDIVIDUAL_IDENTITY_PLACEHOLDER as Wa, InvoicePaymentSessionSchema as Wi, MeterContribution as Wn, AccountMeterSchema as Wo, ResolveEntitlementsInput as Wr, MeterPeriodStatus as Ws, isReturnUrlAllowed as Wt, WebhookEndpointRotateInput as X, AccountsRefreshResultSchema as Xa, InvoiceWaiveInputSchema as Xi, addUtcMonths as Xn, CreditGrantInputSchema as Xo, resolveBenefits as Xr, MeteredPriceDef as Xs, EMAIL_PAYLOAD_SCHEMAS as Xt, WebhookEndpointListSchema as Y, AccountsRefreshResult as Ya, InvoiceWaiveInput as Yi, OverageRateInput as Yn, CreditGrantInput as Yo, isLiveSubscriptionStatus as Yr, MeteredPrice as Ys, EMAIL_LOCALES as Yt, WebhookEndpointRotateInputSchema as Z, Catalog as Za, MANUAL_INVOICE_MAX_AMOUNT_MINOR as Zi, consumptionOf as Zn, DEFAULT_METER_LOW_AT as Zo, resolveEntitlements as Zr, MeteredPriceDefSchema as Zs, EMAIL_TEMPLATES as Zt, DoctorEventsSchema as _, SubscriptionChangeInputSchema as _a, ExternalRefSchema as _c, HEADER_ACTOR_REF as _i, PriceChangeNoticeEmail as _n, PriceDefSchema as _o, EventMetadata as _r, MeterChargeSchema as _s, DEFAULT_PAYMENT_DUE_DAYS as _t, DOCTOR_ROLLUP_LAG_WARN_SECONDS as a, CancelSubscriptionInputSchema as aa, Currency as ac, AccountUpsertResponse as ai, EmailSettingsPatchSchema as an, FeatureDef as ao, rateOverage as ar, METER_FILTER_MAX_DEPTH as as, webhookEndpointUrlProblem as at, DoctorHostedSchema as b, PortalSession as ba, IdSchema as bc, HEADER_REQUEST_ID as bi, PriceChangeNoticeMeteredRateSchema as bn, AccountBenefitSchema as bo, EventMetadataValue as br, MeterCreditEntry as bs, EventsSettings as bt, DoctorBillingSchema as c, GrantCreateInputSchema as ca, ERROR_CATEGORIES as cc, CancelSubscriptionResponseSchema as ci, EmailTemplateSchema as cn, MAX_CATALOG_BENEFITS as co, EVENTS_INGEST_MAX_BYTES as cr, METER_STANDINGS as cs, BillingSettingsSchema as ct, DoctorEmails as d, Payment as da, Entitlements as dc, CheckoutSessionResponse as di, InvoicePaymentDueEmail as dn, MAX_PLAN_BENEFITS as do, EVENT_METADATA_MAX_PAIRS as dr, MeterAggregationSchema as ds, BrandingSchema as dt, ManualInvoiceLineInput as ea, meterFilterClauseOf as ec, ErrorCodeSpec as ei, EmailLocale as en, CatalogSchema as eo, meterChargeTotals as er, MAX_METER_UNITS as es, WebhookEndpointStatusSchema as et, DoctorEmailsSchema as f, PaymentSchema as fa, EntitlementsSchema as fc, CheckoutSessionResponseSchema as fi, InvoicePaymentDueEmailSchema as fn, METERED_PRICE_TAX_MISMATCH as fo, EVENT_METADATA_STRING_MAX_LENGTH as fr, MeterCharge as fs, DEFAULT_CHECKOUT_TTL_MINUTES as ft, DoctorEvents as g, SubscriptionChangeInput as ga, ErrorResponseSchema as gc, GrantCreateResponseSchema as gi, NotificationEmailsSchema as gn, PriceDef as go, EventExternalIdSchema as gr, MeterChargeListSchema as gs, DEFAULT_MIN_INVOICE_MINOR as gt, DoctorEndpointSchema as h, Subscription as ha, ErrorResponse as hc, GrantCreateResponse as hi, NoticedMeteredRateSchema as hn, Price as ho, EVENT_TIMESTAMP_MAX_SKEW_MINUTES as hr, MeterChargeList as hs, DEFAULT_METER_CHARGE_MODE as ht, DOCTOR_REQUIRED_LEGAL_LINKS as i, CancelSubscriptionInput as ia, CodeSchema as ic, AccountDetailSchema as ii, EmailSettingsPatch as in, CatalogSyncResultSchema as io, periodBoundsOf as ir, METER_FILTER_MAX_CONDITIONS as is, generateWebhookSecret as it, DoctorUnsellablePrice as j, CheckoutRedirectTarget as ja, MeResponseSchema as ji, PlanSetInput as jn, CatalogBenefitSchema as jo, IngestRejectCodeSchema as jr, MeterFilterCondition as js, ProductSettings as jt, DoctorSeverity as k, CheckoutPrefill as ka, ManualInvoiceResponseSchema as ki, uniqueEmails as kn, BenefitTypeSchema as ko, IngestEventSchema as kr, MeterFilter as ks, MeteringSettingsSchema as kt, DoctorCatalog as l, GrantSchema as la, EntitlementValue as lc, ChangeSubscriptionResponse as li, EmailTemplateSettings as ln, MAX_CATALOG_METERED_PRICES as lo, EVENTS_INGEST_MAX_EVENTS as lr, MeterAggregation as ls, Branding as lt, DoctorEndpointDiagnosis as m, StatsSchema as ma, ErrorCategorySchema as mc, CreditGrantResponseSchema as mi, NoticedMeteredRate as mn, PlanDefSchema as mo, EVENT_TIMESTAMP_MAX_AGE_DAYS as mr, MeterChargeLineSchema as ms, DEFAULT_LATE_GRACE_MINUTES as mt, DOCTOR_PROVIDER_ENVIRONMENTS as n, manualInvoiceTotals as na, ActorRefSchema as nc, isKnownErrorCode as ni, EmailSenderSchema as nn, CatalogSyncInputSchema as no, overageCapReached as nr, METER_CHARGE_STATUSES as ns, WebhookLastDeliverySchema as nt, DOCTOR_SEVERITIES as o, Grant as oa, CurrencySchema as oc, AccountUpsertResponseSchema as oi, EmailSettingsSchema as on, FeatureDefSchema as oo, rolloverOf as or, METER_FILTER_OPERATORS as os, BillingSettings as ot, DoctorEndpoint as p, Stats as pa, ErrorCategory as pc, CreditGrantResponse as pi, MAX_NOTIFICATION_EMAILS as pn, PlanDef as po, EVENT_NAME_MAX_LENGTH as pr, MeterChargeLine as ps, DEFAULT_EVENT_RETENTION_DAYS as pt, WebhookEndpointCreateInputSchema as q, ProviderPayloadSchema as qa, InvoiceVoidInput as qi, MeterRulesEvent as qn, CatalogMeter as qo, ResolvedEntitlements as qr, MeterStandingSchema as qs, BILLING_PATH_PLACEHOLDERS as qt, DOCTOR_REQUIRED_BRANDING as r, splitInclusiveTax as ra, AmountMinorSchema as rc, AccountDetail as ri, EmailSettings as rn, CatalogSyncResult as ro, overageOf as rr, METER_CREDIT_ENTRY_KINDS as rs, WebhookSecretSchema as rt, DoctorBilling as s, GrantCreateInput as sa, DateTimeSchema as sc, CancelSubscriptionResponse as si, EmailTemplate as sn, FeatureTypeSchema as so, standingOf as sr, METER_PERIOD_STATUSES as ss, BillingSettingsPatchSchema as st, DOCTOR_PENDING_BACKLOG_MS as t, ManualInvoiceLineInputSchema as ta, API_VERSION as tc, errorCodeSpec as ti, EmailRelevanceFacts as tn, CatalogSyncInput as to, meterCreditsOf as tr, METER_AGGREGATION_KINDS as ts, WebhookLastDelivery as tt, DoctorCatalogSchema as u, MAX_GRANT_BENEFITS as ua, EntitlementValueSchema as uc, ChangeSubscriptionResponseSchema as ui, EmailTemplateSettingsSchema as un, MAX_CATALOG_METERS as uo, EVENT_METADATA_KEY_MAX_LENGTH as ur, MeterAggregationKind as us, BrandingPatchSchema as ut, DoctorFacts as v, SubscriptionSchema as va, INVOICE_BILLING_REASONS as vc, HEADER_API_VERSION as vi, PriceChangeNoticeEmailSchema as vn, PriceSchema as vo, EventMetadataKeySchema as vr, MeterChargeStatus as vs, DEFAULT_PORTAL_TTL_MINUTES as vt, DoctorProviderSchema as w, PortalSessionSchema as wa, InvoiceBillingReasonSchema as wc, InvoiceVoidResponse as wi, emailRecipients as wn, BenefitDescription as wo, EventsIngestInputSchema as wr, MeterCreditProperties as ws, METER_CHARGE_MODES as wt, DoctorOverage as x, PortalSessionCreateInput as xa, Interval as xc, HEADER_SDK as xi, applyEmailSettingsPatch as xn, BENEFIT_TYPES as xo, EventMetadataValueSchema as xr, MeterCreditEntryKind as xs, EventsSettingsPatchSchema as xt, DoctorHosted as y, PORTAL_SESSION_ERRORS as ya, INVOICE_PAYMENT_STATUSES as yc, HEADER_IDEMPOTENCY_KEY as yi, PriceChangeNoticeMeteredRate as yn, AccountBenefit as yo, EventMetadataSchema as yr, MeterChargeStatusSchema as ys, EventRetentionDaysSchema as yt, endpointDiagnosisOf as z, CheckoutSessionSchema as za, InvoiceLine as zi, PlanSetWarningSchema as zn, MeterCreditBenefitDefSchema as zo, EntitlementRulesGrant as zr, MeterLowAtSchema as zs, TtlMinutesSchema as zt };