@paygentic/sdk 0.7.20 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +5 -3
  2. package/dist/commonjs/funcs/pricesCreate.js +2 -2
  3. package/dist/commonjs/funcs/pricesCreate.js.map +1 -1
  4. package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts +19 -0
  5. package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts.map +1 -0
  6. package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.js +125 -0
  7. package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.js.map +1 -0
  8. package/dist/commonjs/lib/config.d.ts +2 -2
  9. package/dist/commonjs/lib/config.js +2 -2
  10. package/dist/commonjs/lib/config.js.map +1 -1
  11. package/dist/commonjs/models/index.d.ts +8 -0
  12. package/dist/commonjs/models/index.d.ts.map +1 -1
  13. package/dist/commonjs/models/index.js +8 -0
  14. package/dist/commonjs/models/index.js.map +1 -1
  15. package/dist/commonjs/models/invoice.d.ts +4 -4
  16. package/dist/commonjs/models/invoice.d.ts.map +1 -1
  17. package/dist/commonjs/models/invoice.js +7 -6
  18. package/dist/commonjs/models/invoice.js.map +1 -1
  19. package/dist/commonjs/models/meteredentitlementdetail.d.ts +9 -5
  20. package/dist/commonjs/models/meteredentitlementdetail.d.ts.map +1 -1
  21. package/dist/commonjs/models/meteredentitlementdetail.js +1 -0
  22. package/dist/commonjs/models/meteredentitlementdetail.js.map +1 -1
  23. package/dist/commonjs/models/meteredentitlementlistitem.d.ts +9 -5
  24. package/dist/commonjs/models/meteredentitlementlistitem.d.ts.map +1 -1
  25. package/dist/commonjs/models/meteredentitlementlistitem.js +1 -0
  26. package/dist/commonjs/models/meteredentitlementlistitem.js.map +1 -1
  27. package/dist/commonjs/models/operations/createplan.d.ts +11 -5
  28. package/dist/commonjs/models/operations/createplan.d.ts.map +1 -1
  29. package/dist/commonjs/models/operations/createplan.js +6 -3
  30. package/dist/commonjs/models/operations/createplan.js.map +1 -1
  31. package/dist/commonjs/models/operations/createprice.d.ts +7 -17
  32. package/dist/commonjs/models/operations/createprice.d.ts.map +1 -1
  33. package/dist/commonjs/models/operations/createprice.js +3 -13
  34. package/dist/commonjs/models/operations/createprice.js.map +1 -1
  35. package/dist/commonjs/models/operations/index.d.ts +1 -0
  36. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  37. package/dist/commonjs/models/operations/index.js +1 -0
  38. package/dist/commonjs/models/operations/index.js.map +1 -1
  39. package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.d.ts +30 -0
  40. package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.d.ts.map +1 -0
  41. package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.js +63 -0
  42. package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.js.map +1 -0
  43. package/dist/commonjs/models/operations/updateplan.d.ts +6 -0
  44. package/dist/commonjs/models/operations/updateplan.d.ts.map +1 -1
  45. package/dist/commonjs/models/operations/updateplan.js +3 -0
  46. package/dist/commonjs/models/operations/updateplan.js.map +1 -1
  47. package/dist/commonjs/models/operations/updateprice.d.ts +7 -17
  48. package/dist/commonjs/models/operations/updateprice.d.ts.map +1 -1
  49. package/dist/commonjs/models/operations/updateprice.js +3 -13
  50. package/dist/commonjs/models/operations/updateprice.js.map +1 -1
  51. package/dist/commonjs/models/plan.d.ts +5 -0
  52. package/dist/commonjs/models/plan.d.ts.map +1 -1
  53. package/dist/commonjs/models/plan.js +2 -0
  54. package/dist/commonjs/models/plan.js.map +1 -1
  55. package/dist/commonjs/models/plancreditallocation.d.ts +30 -0
  56. package/dist/commonjs/models/plancreditallocation.d.ts.map +1 -0
  57. package/dist/commonjs/models/plancreditallocation.js +62 -0
  58. package/dist/commonjs/models/plancreditallocation.js.map +1 -0
  59. package/dist/commonjs/models/price.d.ts +4 -4
  60. package/dist/commonjs/models/price.d.ts.map +1 -1
  61. package/dist/commonjs/models/price.js +5 -5
  62. package/dist/commonjs/models/price.js.map +1 -1
  63. package/dist/commonjs/models/pricemodel.d.ts +18 -0
  64. package/dist/commonjs/models/pricemodel.d.ts.map +1 -0
  65. package/dist/commonjs/models/pricemodel.js +52 -0
  66. package/dist/commonjs/models/pricemodel.js.map +1 -0
  67. package/dist/commonjs/models/pricemodelinput.d.ts +15 -0
  68. package/dist/commonjs/models/pricemodelinput.d.ts.map +1 -0
  69. package/dist/commonjs/models/pricemodelinput.js +49 -0
  70. package/dist/commonjs/models/pricemodelinput.js.map +1 -0
  71. package/dist/commonjs/models/reconciledfeatureadded.d.ts +15 -0
  72. package/dist/commonjs/models/reconciledfeatureadded.d.ts.map +1 -0
  73. package/dist/commonjs/models/reconciledfeatureadded.js +52 -0
  74. package/dist/commonjs/models/reconciledfeatureadded.js.map +1 -0
  75. package/dist/commonjs/models/reconciledfeaturefailed.d.ts +29 -0
  76. package/dist/commonjs/models/reconciledfeaturefailed.d.ts.map +1 -0
  77. package/dist/commonjs/models/reconciledfeaturefailed.js +62 -0
  78. package/dist/commonjs/models/reconciledfeaturefailed.js.map +1 -0
  79. package/dist/commonjs/models/reconciledfeatureremoved.d.ts +11 -0
  80. package/dist/commonjs/models/reconciledfeatureremoved.d.ts.map +1 -0
  81. package/dist/commonjs/models/reconciledfeatureremoved.js +51 -0
  82. package/dist/commonjs/models/reconciledfeatureremoved.js.map +1 -0
  83. package/dist/commonjs/models/reconciledfeatureskipped.d.ts +11 -0
  84. package/dist/commonjs/models/reconciledfeatureskipped.d.ts.map +1 -0
  85. package/dist/commonjs/models/reconciledfeatureskipped.js +51 -0
  86. package/dist/commonjs/models/reconciledfeatureskipped.js.map +1 -0
  87. package/dist/commonjs/models/schemasprice.d.ts +9 -10
  88. package/dist/commonjs/models/schemasprice.d.ts.map +1 -1
  89. package/dist/commonjs/models/schemasprice.js +4 -10
  90. package/dist/commonjs/models/schemasprice.js.map +1 -1
  91. package/dist/commonjs/models/subscriptionreconciliation.d.ts +62 -0
  92. package/dist/commonjs/models/subscriptionreconciliation.d.ts.map +1 -0
  93. package/dist/commonjs/models/subscriptionreconciliation.js +83 -0
  94. package/dist/commonjs/models/subscriptionreconciliation.js.map +1 -0
  95. package/dist/commonjs/sdk/subscriptions.d.ts +7 -0
  96. package/dist/commonjs/sdk/subscriptions.d.ts.map +1 -1
  97. package/dist/commonjs/sdk/subscriptions.js +10 -0
  98. package/dist/commonjs/sdk/subscriptions.js.map +1 -1
  99. package/dist/esm/funcs/pricesCreate.js +2 -2
  100. package/dist/esm/funcs/pricesCreate.js.map +1 -1
  101. package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts +19 -0
  102. package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts.map +1 -0
  103. package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.js +89 -0
  104. package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.js.map +1 -0
  105. package/dist/esm/lib/config.d.ts +2 -2
  106. package/dist/esm/lib/config.js +2 -2
  107. package/dist/esm/lib/config.js.map +1 -1
  108. package/dist/esm/models/index.d.ts +8 -0
  109. package/dist/esm/models/index.d.ts.map +1 -1
  110. package/dist/esm/models/index.js +8 -0
  111. package/dist/esm/models/index.js.map +1 -1
  112. package/dist/esm/models/invoice.d.ts +4 -4
  113. package/dist/esm/models/invoice.d.ts.map +1 -1
  114. package/dist/esm/models/invoice.js +5 -4
  115. package/dist/esm/models/invoice.js.map +1 -1
  116. package/dist/esm/models/meteredentitlementdetail.d.ts +9 -5
  117. package/dist/esm/models/meteredentitlementdetail.d.ts.map +1 -1
  118. package/dist/esm/models/meteredentitlementdetail.js +1 -0
  119. package/dist/esm/models/meteredentitlementdetail.js.map +1 -1
  120. package/dist/esm/models/meteredentitlementlistitem.d.ts +9 -5
  121. package/dist/esm/models/meteredentitlementlistitem.d.ts.map +1 -1
  122. package/dist/esm/models/meteredentitlementlistitem.js +1 -0
  123. package/dist/esm/models/meteredentitlementlistitem.js.map +1 -1
  124. package/dist/esm/models/operations/createplan.d.ts +11 -5
  125. package/dist/esm/models/operations/createplan.d.ts.map +1 -1
  126. package/dist/esm/models/operations/createplan.js +6 -3
  127. package/dist/esm/models/operations/createplan.js.map +1 -1
  128. package/dist/esm/models/operations/createprice.d.ts +7 -17
  129. package/dist/esm/models/operations/createprice.d.ts.map +1 -1
  130. package/dist/esm/models/operations/createprice.js +2 -12
  131. package/dist/esm/models/operations/createprice.js.map +1 -1
  132. package/dist/esm/models/operations/index.d.ts +1 -0
  133. package/dist/esm/models/operations/index.d.ts.map +1 -1
  134. package/dist/esm/models/operations/index.js +1 -0
  135. package/dist/esm/models/operations/index.js.map +1 -1
  136. package/dist/esm/models/operations/reconcilesubscriptionfeatures.d.ts +30 -0
  137. package/dist/esm/models/operations/reconcilesubscriptionfeatures.d.ts.map +1 -0
  138. package/dist/esm/models/operations/reconcilesubscriptionfeatures.js +25 -0
  139. package/dist/esm/models/operations/reconcilesubscriptionfeatures.js.map +1 -0
  140. package/dist/esm/models/operations/updateplan.d.ts +6 -0
  141. package/dist/esm/models/operations/updateplan.d.ts.map +1 -1
  142. package/dist/esm/models/operations/updateplan.js +3 -0
  143. package/dist/esm/models/operations/updateplan.js.map +1 -1
  144. package/dist/esm/models/operations/updateprice.d.ts +7 -17
  145. package/dist/esm/models/operations/updateprice.d.ts.map +1 -1
  146. package/dist/esm/models/operations/updateprice.js +2 -12
  147. package/dist/esm/models/operations/updateprice.js.map +1 -1
  148. package/dist/esm/models/plan.d.ts +5 -0
  149. package/dist/esm/models/plan.d.ts.map +1 -1
  150. package/dist/esm/models/plan.js +2 -0
  151. package/dist/esm/models/plan.js.map +1 -1
  152. package/dist/esm/models/plancreditallocation.d.ts +30 -0
  153. package/dist/esm/models/plancreditallocation.d.ts.map +1 -0
  154. package/dist/esm/models/plancreditallocation.js +24 -0
  155. package/dist/esm/models/plancreditallocation.js.map +1 -0
  156. package/dist/esm/models/price.d.ts +4 -4
  157. package/dist/esm/models/price.d.ts.map +1 -1
  158. package/dist/esm/models/price.js +4 -4
  159. package/dist/esm/models/price.js.map +1 -1
  160. package/dist/esm/models/pricemodel.d.ts +18 -0
  161. package/dist/esm/models/pricemodel.d.ts.map +1 -0
  162. package/dist/esm/models/pricemodel.js +16 -0
  163. package/dist/esm/models/pricemodel.js.map +1 -0
  164. package/dist/esm/models/pricemodelinput.d.ts +15 -0
  165. package/dist/esm/models/pricemodelinput.d.ts.map +1 -0
  166. package/dist/esm/models/pricemodelinput.js +13 -0
  167. package/dist/esm/models/pricemodelinput.js.map +1 -0
  168. package/dist/esm/models/reconciledfeatureadded.d.ts +15 -0
  169. package/dist/esm/models/reconciledfeatureadded.d.ts.map +1 -0
  170. package/dist/esm/models/reconciledfeatureadded.js +15 -0
  171. package/dist/esm/models/reconciledfeatureadded.js.map +1 -0
  172. package/dist/esm/models/reconciledfeaturefailed.d.ts +29 -0
  173. package/dist/esm/models/reconciledfeaturefailed.d.ts.map +1 -0
  174. package/dist/esm/models/reconciledfeaturefailed.js +25 -0
  175. package/dist/esm/models/reconciledfeaturefailed.js.map +1 -0
  176. package/dist/esm/models/reconciledfeatureremoved.d.ts +11 -0
  177. package/dist/esm/models/reconciledfeatureremoved.d.ts.map +1 -0
  178. package/dist/esm/models/reconciledfeatureremoved.js +14 -0
  179. package/dist/esm/models/reconciledfeatureremoved.js.map +1 -0
  180. package/dist/esm/models/reconciledfeatureskipped.d.ts +11 -0
  181. package/dist/esm/models/reconciledfeatureskipped.d.ts.map +1 -0
  182. package/dist/esm/models/reconciledfeatureskipped.js +14 -0
  183. package/dist/esm/models/reconciledfeatureskipped.js.map +1 -0
  184. package/dist/esm/models/schemasprice.d.ts +9 -10
  185. package/dist/esm/models/schemasprice.d.ts.map +1 -1
  186. package/dist/esm/models/schemasprice.js +3 -9
  187. package/dist/esm/models/schemasprice.js.map +1 -1
  188. package/dist/esm/models/subscriptionreconciliation.d.ts +62 -0
  189. package/dist/esm/models/subscriptionreconciliation.d.ts.map +1 -0
  190. package/dist/esm/models/subscriptionreconciliation.js +44 -0
  191. package/dist/esm/models/subscriptionreconciliation.js.map +1 -0
  192. package/dist/esm/sdk/subscriptions.d.ts +7 -0
  193. package/dist/esm/sdk/subscriptions.d.ts.map +1 -1
  194. package/dist/esm/sdk/subscriptions.js +10 -0
  195. package/dist/esm/sdk/subscriptions.js.map +1 -1
  196. package/jsr.json +1 -1
  197. package/package.json +1 -1
  198. package/src/funcs/pricesCreate.ts +2 -2
  199. package/src/funcs/subscriptionsReconcileSubscriptionFeatures.ts +184 -0
  200. package/src/lib/config.ts +2 -2
  201. package/src/models/index.ts +8 -0
  202. package/src/models/invoice.ts +10 -9
  203. package/src/models/meteredentitlementdetail.ts +10 -5
  204. package/src/models/meteredentitlementlistitem.ts +10 -5
  205. package/src/models/operations/createplan.ts +15 -7
  206. package/src/models/operations/createprice.ts +9 -22
  207. package/src/models/operations/index.ts +1 -0
  208. package/src/models/operations/reconcilesubscriptionfeatures.ts +78 -0
  209. package/src/models/operations/updateplan.ts +8 -0
  210. package/src/models/operations/updateprice.ts +9 -22
  211. package/src/models/plan.ts +9 -0
  212. package/src/models/plancreditallocation.ts +68 -0
  213. package/src/models/price.ts +6 -6
  214. package/src/models/pricemodel.ts +28 -0
  215. package/src/models/pricemodelinput.ts +22 -0
  216. package/src/models/reconciledfeatureadded.ts +38 -0
  217. package/src/models/reconciledfeaturefailed.ts +55 -0
  218. package/src/models/reconciledfeatureremoved.ts +33 -0
  219. package/src/models/reconciledfeatureskipped.ts +33 -0
  220. package/src/models/schemasprice.ts +11 -15
  221. package/src/models/subscriptionreconciliation.ts +144 -0
  222. package/src/sdk/subscriptions.ts +18 -0
@@ -7,20 +7,6 @@ import { remap as remap$ } from "../../lib/primitives.js";
7
7
  import { ClosedEnum } from "../../types/enums.js";
8
8
  import * as models from "../index.js";
9
9
 
10
- /**
11
- * The pricing model to be used, which can be standard, dynamic, volume-based, or percentage-based.
12
- */
13
- export const UpdatePriceModel = {
14
- Standard: "standard",
15
- Dynamic: "dynamic",
16
- Volume: "volume",
17
- Percentage: "percentage",
18
- } as const;
19
- /**
20
- * The pricing model to be used, which can be standard, dynamic, volume-based, or percentage-based.
21
- */
22
- export type UpdatePriceModel = ClosedEnum<typeof UpdatePriceModel>;
23
-
24
10
  /**
25
11
  * Billing timing preference. For billable metrics: 'instant' (charges immediately) or 'in_arrears' (charges at period end). For fees: 'in_advance' (charges upfront) or 'in_arrears' (charges at period end).
26
12
  */
@@ -39,14 +25,18 @@ export type UpdatePriceRequestBody = {
39
25
  * Unique identifier for a billable metric
40
26
  */
41
27
  billableMetricId?: string | undefined;
28
+ /**
29
+ * Denominate this metered price in a pricing unit (credits). Set to a pricing unit ID to draw down a credit pool, null to revert to real currency, or omit to leave unchanged.
30
+ */
31
+ pricingUnitId?: string | null | undefined;
42
32
  /**
43
33
  * Updated invoice line item label. Sample values: 'LLM Token Usage', 'Storage Charges', 'API Call Fees'
44
34
  */
45
35
  invoiceDisplayName?: string | undefined;
46
36
  /**
47
- * The pricing model to be used, which can be standard, dynamic, volume-based, or percentage-based.
37
+ * The pricing model to set. Only 'standard' is accepted. Legacy 'dynamic'/'volume'/'percentage' prices can still be edited (other fields) but cannot be switched to those models. Percentage/revenue-share is expressed via 'standard' with a unit-price multiplier.
48
38
  */
49
- model?: UpdatePriceModel | undefined;
39
+ model?: models.PriceModelInput | undefined;
50
40
  properties?: models.PricePropertiesUnion | undefined;
51
41
  /**
52
42
  * Billing timing preference. For billable metrics: 'instant' (charges immediately) or 'in_arrears' (charges at period end). For fees: 'in_advance' (charges upfront) or 'in_arrears' (charges at period end).
@@ -78,11 +68,6 @@ export type UpdatePriceRequest = {
78
68
  requestBody: UpdatePriceRequestBody;
79
69
  };
80
70
 
81
- /** @internal */
82
- export const UpdatePriceModel$outboundSchema: z.ZodNativeEnum<
83
- typeof UpdatePriceModel
84
- > = z.nativeEnum(UpdatePriceModel);
85
-
86
71
  /** @internal */
87
72
  export const UpdatePricePaymentTerm$outboundSchema: z.ZodNativeEnum<
88
73
  typeof UpdatePricePaymentTerm
@@ -91,6 +76,7 @@ export const UpdatePricePaymentTerm$outboundSchema: z.ZodNativeEnum<
91
76
  /** @internal */
92
77
  export type UpdatePriceRequestBody$Outbound = {
93
78
  billableMetricId?: string | undefined;
79
+ pricingUnitId?: string | null | undefined;
94
80
  invoiceDisplayName?: string | undefined;
95
81
  model?: string | undefined;
96
82
  properties?: models.PricePropertiesUnion$Outbound | undefined;
@@ -108,8 +94,9 @@ export const UpdatePriceRequestBody$outboundSchema: z.ZodType<
108
94
  UpdatePriceRequestBody
109
95
  > = z.object({
110
96
  billableMetricId: z.string().optional(),
97
+ pricingUnitId: z.nullable(z.string()).optional(),
111
98
  invoiceDisplayName: z.string().optional(),
112
- model: UpdatePriceModel$outboundSchema.optional(),
99
+ model: models.PriceModelInput$outboundSchema.optional(),
113
100
  properties: models.PricePropertiesUnion$outboundSchema.optional(),
114
101
  paymentTerm: UpdatePricePaymentTerm$outboundSchema.optional(),
115
102
  billingCadence: z.nullable(z.string()).optional(),
@@ -8,6 +8,10 @@ import { safeParse } from "../lib/schemas.js";
8
8
  import { ClosedEnum } from "../types/enums.js";
9
9
  import { Result as SafeParseResult } from "../types/fp.js";
10
10
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
11
+ import {
12
+ PlanCreditAllocation,
13
+ PlanCreditAllocation$inboundSchema,
14
+ } from "./plancreditallocation.js";
11
15
  import { Price, Price$inboundSchema } from "./price.js";
12
16
 
13
17
  export const PlanObject = {
@@ -110,6 +114,10 @@ export type Plan = {
110
114
  * ISO 8601 datetime reference point for billing period alignment. Must be in the past or present at the time of creation or update. When set, all subscriptions created under this plan align their first billing period to the next recurrence of this anchor. Null means each subscription uses its own start time (hour-rounded) as the anchor.
111
115
  */
112
116
  billingAnchor?: Date | null | undefined;
117
+ /**
118
+ * Credit-pool funding declarations for this plan. Each entry funds a distinct pricing unit's credit pool when a subscription to this plan activates: the allocated amount is minted as a credit grant on the customer's pool for that pricing unit, once at activation, or on a recurring basis only when that allocation explicitly sets recurrencePeriod. A plan may declare zero or more allocations; no two allocations on the same plan target the same pricingUnitId.
119
+ */
120
+ creditAllocations?: Array<PlanCreditAllocation> | undefined;
113
121
  };
114
122
 
115
123
  /** @internal */
@@ -182,6 +190,7 @@ export const Plan$inboundSchema: z.ZodType<Plan, z.ZodTypeDef, unknown> = z
182
190
  billingAnchor: z.nullable(
183
191
  z.string().datetime({ offset: true }).transform(v => new Date(v)),
184
192
  ).optional(),
193
+ creditAllocations: z.array(PlanCreditAllocation$inboundSchema).optional(),
185
194
  });
186
195
 
187
196
  export function planFromJSON(
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+
10
+ export type PlanCreditAllocation = {
11
+ /**
12
+ * Unique identifier for a pricing unit
13
+ */
14
+ pricingUnitId: string;
15
+ /**
16
+ * Number of credits minted into the customer's pool for this pricing unit each time the allocation is provisioned. Must be a positive number.
17
+ */
18
+ amount: number;
19
+ /**
20
+ * ISO 8601 duration (e.g. 'P1M') controlling how often the allocation's credits are re-minted on the customer's pool. Recurrence is opt-in: when omitted, the allocation is minted once at subscription activation and never refills — even on a recurring plan. Set this field explicitly for credits that should replenish each period.
21
+ */
22
+ recurrencePeriod?: string | undefined;
23
+ };
24
+
25
+ /** @internal */
26
+ export const PlanCreditAllocation$inboundSchema: z.ZodType<
27
+ PlanCreditAllocation,
28
+ z.ZodTypeDef,
29
+ unknown
30
+ > = z.object({
31
+ pricingUnitId: z.string(),
32
+ amount: z.number(),
33
+ recurrencePeriod: z.string().optional(),
34
+ });
35
+ /** @internal */
36
+ export type PlanCreditAllocation$Outbound = {
37
+ pricingUnitId: string;
38
+ amount: number;
39
+ recurrencePeriod?: string | undefined;
40
+ };
41
+
42
+ /** @internal */
43
+ export const PlanCreditAllocation$outboundSchema: z.ZodType<
44
+ PlanCreditAllocation$Outbound,
45
+ z.ZodTypeDef,
46
+ PlanCreditAllocation
47
+ > = z.object({
48
+ pricingUnitId: z.string(),
49
+ amount: z.number(),
50
+ recurrencePeriod: z.string().optional(),
51
+ });
52
+
53
+ export function planCreditAllocationToJSON(
54
+ planCreditAllocation: PlanCreditAllocation,
55
+ ): string {
56
+ return JSON.stringify(
57
+ PlanCreditAllocation$outboundSchema.parse(planCreditAllocation),
58
+ );
59
+ }
60
+ export function planCreditAllocationFromJSON(
61
+ jsonString: string,
62
+ ): SafeParseResult<PlanCreditAllocation, SDKValidationError> {
63
+ return safeParse(
64
+ jsonString,
65
+ (x) => PlanCreditAllocation$inboundSchema.parse(JSON.parse(x)),
66
+ `Failed to parse 'PlanCreditAllocation' from JSON`,
67
+ );
68
+ }
@@ -14,13 +14,13 @@ export const PriceObject = {
14
14
  } as const;
15
15
  export type PriceObject = ClosedEnum<typeof PriceObject>;
16
16
 
17
- export const PriceModel = {
17
+ export const PriceModel1 = {
18
18
  Standard: "standard",
19
19
  Dynamic: "dynamic",
20
20
  Volume: "volume",
21
21
  Percentage: "percentage",
22
22
  } as const;
23
- export type PriceModel = ClosedEnum<typeof PriceModel>;
23
+ export type PriceModel1 = ClosedEnum<typeof PriceModel1>;
24
24
 
25
25
  export const PricePaymentTerm = {
26
26
  Instant: "instant",
@@ -52,7 +52,7 @@ export type Price = {
52
52
  currency?: string | undefined;
53
53
  description?: string | undefined;
54
54
  invoiceDisplayName: string;
55
- model: PriceModel;
55
+ model: PriceModel1;
56
56
  paymentTerm: PricePaymentTerm;
57
57
  properties: { [k: string]: any };
58
58
  unitAmount?: string | undefined;
@@ -76,8 +76,8 @@ export const PriceObject$inboundSchema: z.ZodNativeEnum<typeof PriceObject> = z
76
76
  .nativeEnum(PriceObject);
77
77
 
78
78
  /** @internal */
79
- export const PriceModel$inboundSchema: z.ZodNativeEnum<typeof PriceModel> = z
80
- .nativeEnum(PriceModel);
79
+ export const PriceModel1$inboundSchema: z.ZodNativeEnum<typeof PriceModel1> = z
80
+ .nativeEnum(PriceModel1);
81
81
 
82
82
  /** @internal */
83
83
  export const PricePaymentTerm$inboundSchema: z.ZodNativeEnum<
@@ -99,7 +99,7 @@ export const Price$inboundSchema: z.ZodType<Price, z.ZodTypeDef, unknown> = z
99
99
  currency: z.string().optional(),
100
100
  description: z.string().optional(),
101
101
  invoiceDisplayName: z.string(),
102
- model: PriceModel$inboundSchema,
102
+ model: PriceModel1$inboundSchema,
103
103
  paymentTerm: PricePaymentTerm$inboundSchema,
104
104
  properties: z.record(z.any()),
105
105
  unitAmount: z.string().optional(),
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import * as openEnums from "../types/enums.js";
7
+ import { OpenEnum } from "../types/enums.js";
8
+
9
+ /**
10
+ * Pricing model of a price as returned by the API. Includes legacy models ('dynamic', 'volume', 'percentage') retained for existing prices; only 'standard' can be created (see PriceModelInput).
11
+ */
12
+ export const PriceModel = {
13
+ Standard: "standard",
14
+ Dynamic: "dynamic",
15
+ Volume: "volume",
16
+ Percentage: "percentage",
17
+ } as const;
18
+ /**
19
+ * Pricing model of a price as returned by the API. Includes legacy models ('dynamic', 'volume', 'percentage') retained for existing prices; only 'standard' can be created (see PriceModelInput).
20
+ */
21
+ export type PriceModel = OpenEnum<typeof PriceModel>;
22
+
23
+ /** @internal */
24
+ export const PriceModel$inboundSchema: z.ZodType<
25
+ PriceModel,
26
+ z.ZodTypeDef,
27
+ unknown
28
+ > = openEnums.inboundSchema(PriceModel);
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { ClosedEnum } from "../types/enums.js";
7
+
8
+ /**
9
+ * Pricing model accepted when creating or updating a price. Only 'standard' is creatable. Percentage-style and revenue-share pricing are expressed with 'standard' plus a unit-price multiplier (e.g. 10% ⇒ unitPrice '0.1'). The legacy 'dynamic', 'volume', and 'percentage' models remain billable and readable on existing prices but can no longer be created.
10
+ */
11
+ export const PriceModelInput = {
12
+ Standard: "standard",
13
+ } as const;
14
+ /**
15
+ * Pricing model accepted when creating or updating a price. Only 'standard' is creatable. Percentage-style and revenue-share pricing are expressed with 'standard' plus a unit-price multiplier (e.g. 10% ⇒ unitPrice '0.1'). The legacy 'dynamic', 'volume', and 'percentage' models remain billable and readable on existing prices but can no longer be created.
16
+ */
17
+ export type PriceModelInput = ClosedEnum<typeof PriceModelInput>;
18
+
19
+ /** @internal */
20
+ export const PriceModelInput$outboundSchema: z.ZodNativeEnum<
21
+ typeof PriceModelInput
22
+ > = z.nativeEnum(PriceModelInput);
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+
10
+ export type ReconciledFeatureAdded = {
11
+ featureId: string;
12
+ featureKey: string;
13
+ /**
14
+ * False when this feature's price never produces a recurring line item (an instant price, a credit-denominated price, or an already-elapsed one-time charge) — the feature is entitled but not billed by this reconciliation.
15
+ */
16
+ billed: boolean;
17
+ };
18
+
19
+ /** @internal */
20
+ export const ReconciledFeatureAdded$inboundSchema: z.ZodType<
21
+ ReconciledFeatureAdded,
22
+ z.ZodTypeDef,
23
+ unknown
24
+ > = z.object({
25
+ featureId: z.string(),
26
+ featureKey: z.string(),
27
+ billed: z.boolean(),
28
+ });
29
+
30
+ export function reconciledFeatureAddedFromJSON(
31
+ jsonString: string,
32
+ ): SafeParseResult<ReconciledFeatureAdded, SDKValidationError> {
33
+ return safeParse(
34
+ jsonString,
35
+ (x) => ReconciledFeatureAdded$inboundSchema.parse(JSON.parse(x)),
36
+ `Failed to parse 'ReconciledFeatureAdded' from JSON`,
37
+ );
38
+ }
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { ClosedEnum } from "../types/enums.js";
8
+ import { Result as SafeParseResult } from "../types/fp.js";
9
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
+
11
+ /**
12
+ * Coded failure reason. `grant_mint_failed` means the entitlement was created but its initial metered grant could not be minted; re-running this reconciliation retries the mint.
13
+ */
14
+ export const Reason = {
15
+ EntitlementFailed: "entitlement_failed",
16
+ GrantMintFailed: "grant_mint_failed",
17
+ } as const;
18
+ /**
19
+ * Coded failure reason. `grant_mint_failed` means the entitlement was created but its initial metered grant could not be minted; re-running this reconciliation retries the mint.
20
+ */
21
+ export type Reason = ClosedEnum<typeof Reason>;
22
+
23
+ export type ReconciledFeatureFailed = {
24
+ featureId: string;
25
+ featureKey: string;
26
+ /**
27
+ * Coded failure reason. `grant_mint_failed` means the entitlement was created but its initial metered grant could not be minted; re-running this reconciliation retries the mint.
28
+ */
29
+ reason: Reason;
30
+ };
31
+
32
+ /** @internal */
33
+ export const Reason$inboundSchema: z.ZodNativeEnum<typeof Reason> = z
34
+ .nativeEnum(Reason);
35
+
36
+ /** @internal */
37
+ export const ReconciledFeatureFailed$inboundSchema: z.ZodType<
38
+ ReconciledFeatureFailed,
39
+ z.ZodTypeDef,
40
+ unknown
41
+ > = z.object({
42
+ featureId: z.string(),
43
+ featureKey: z.string(),
44
+ reason: Reason$inboundSchema,
45
+ });
46
+
47
+ export function reconciledFeatureFailedFromJSON(
48
+ jsonString: string,
49
+ ): SafeParseResult<ReconciledFeatureFailed, SDKValidationError> {
50
+ return safeParse(
51
+ jsonString,
52
+ (x) => ReconciledFeatureFailed$inboundSchema.parse(JSON.parse(x)),
53
+ `Failed to parse 'ReconciledFeatureFailed' from JSON`,
54
+ );
55
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+
10
+ export type ReconciledFeatureRemoved = {
11
+ featureId: string;
12
+ featureKey: string;
13
+ };
14
+
15
+ /** @internal */
16
+ export const ReconciledFeatureRemoved$inboundSchema: z.ZodType<
17
+ ReconciledFeatureRemoved,
18
+ z.ZodTypeDef,
19
+ unknown
20
+ > = z.object({
21
+ featureId: z.string(),
22
+ featureKey: z.string(),
23
+ });
24
+
25
+ export function reconciledFeatureRemovedFromJSON(
26
+ jsonString: string,
27
+ ): SafeParseResult<ReconciledFeatureRemoved, SDKValidationError> {
28
+ return safeParse(
29
+ jsonString,
30
+ (x) => ReconciledFeatureRemoved$inboundSchema.parse(JSON.parse(x)),
31
+ `Failed to parse 'ReconciledFeatureRemoved' from JSON`,
32
+ );
33
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../types/fp.js";
8
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
9
+
10
+ export type ReconciledFeatureSkipped = {
11
+ featureId: string;
12
+ featureKey: string;
13
+ };
14
+
15
+ /** @internal */
16
+ export const ReconciledFeatureSkipped$inboundSchema: z.ZodType<
17
+ ReconciledFeatureSkipped,
18
+ z.ZodTypeDef,
19
+ unknown
20
+ > = z.object({
21
+ featureId: z.string(),
22
+ featureKey: z.string(),
23
+ });
24
+
25
+ export function reconciledFeatureSkippedFromJSON(
26
+ jsonString: string,
27
+ ): SafeParseResult<ReconciledFeatureSkipped, SDKValidationError> {
28
+ return safeParse(
29
+ jsonString,
30
+ (x) => ReconciledFeatureSkipped$inboundSchema.parse(JSON.parse(x)),
31
+ `Failed to parse 'ReconciledFeatureSkipped' from JSON`,
32
+ );
33
+ }
@@ -8,6 +8,7 @@ import { ClosedEnum } from "../types/enums.js";
8
8
  import { Result as SafeParseResult } from "../types/fp.js";
9
9
  import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
10
  import { PriceFeature, PriceFeature$inboundSchema } from "./pricefeature.js";
11
+ import { PriceModel, PriceModel$inboundSchema } from "./pricemodel.js";
11
12
  import {
12
13
  PricePropertiesUnion,
13
14
  PricePropertiesUnion$inboundSchema,
@@ -18,14 +19,6 @@ export const SchemasPriceObject = {
18
19
  } as const;
19
20
  export type SchemasPriceObject = ClosedEnum<typeof SchemasPriceObject>;
20
21
 
21
- export const SchemasPriceModel = {
22
- Standard: "standard",
23
- Dynamic: "dynamic",
24
- Volume: "volume",
25
- Percentage: "percentage",
26
- } as const;
27
- export type SchemasPriceModel = ClosedEnum<typeof SchemasPriceModel>;
28
-
29
22
  export const SchemasPricePaymentTerm = {
30
23
  Instant: "instant",
31
24
  InArrears: "in_arrears",
@@ -49,6 +42,10 @@ export type SchemasPrice = {
49
42
  * The unique identifier for the fee referred to by this price. Present when price is linked to a fee.
50
43
  */
51
44
  feeId?: string | undefined;
45
+ /**
46
+ * Unique identifier for a pricing unit
47
+ */
48
+ pricingUnitId?: string | undefined;
52
49
  /**
53
50
  * Unique identifier for an organization
54
51
  */
@@ -59,7 +56,10 @@ export type SchemasPrice = {
59
56
  billingCadence?: string | null | undefined;
60
57
  createdAt: Date;
61
58
  invoiceDisplayName: string;
62
- model?: SchemasPriceModel | undefined;
59
+ /**
60
+ * Pricing model of a price as returned by the API. Includes legacy models ('dynamic', 'volume', 'percentage') retained for existing prices; only 'standard' can be created (see PriceModelInput).
61
+ */
62
+ model?: PriceModel | undefined;
63
63
  paymentTerm: SchemasPricePaymentTerm;
64
64
  properties: PricePropertiesUnion;
65
65
  updatedAt: Date;
@@ -82,11 +82,6 @@ export const SchemasPriceObject$inboundSchema: z.ZodNativeEnum<
82
82
  typeof SchemasPriceObject
83
83
  > = z.nativeEnum(SchemasPriceObject);
84
84
 
85
- /** @internal */
86
- export const SchemasPriceModel$inboundSchema: z.ZodNativeEnum<
87
- typeof SchemasPriceModel
88
- > = z.nativeEnum(SchemasPriceModel);
89
-
90
85
  /** @internal */
91
86
  export const SchemasPricePaymentTerm$inboundSchema: z.ZodNativeEnum<
92
87
  typeof SchemasPricePaymentTerm
@@ -102,11 +97,12 @@ export const SchemasPrice$inboundSchema: z.ZodType<
102
97
  object: SchemasPriceObject$inboundSchema.default("price"),
103
98
  billableMetricId: z.string().optional(),
104
99
  feeId: z.string().optional(),
100
+ pricingUnitId: z.string().optional(),
105
101
  merchantId: z.string(),
106
102
  billingCadence: z.nullable(z.string()).optional(),
107
103
  createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
108
104
  invoiceDisplayName: z.string(),
109
- model: SchemasPriceModel$inboundSchema.optional(),
105
+ model: PriceModel$inboundSchema.optional(),
110
106
  paymentTerm: SchemasPricePaymentTerm$inboundSchema,
111
107
  properties: PricePropertiesUnion$inboundSchema,
112
108
  updatedAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
@@ -0,0 +1,144 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { ClosedEnum } from "../types/enums.js";
8
+ import { Result as SafeParseResult } from "../types/fp.js";
9
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
10
+ import {
11
+ ReconciledFeatureAdded,
12
+ ReconciledFeatureAdded$inboundSchema,
13
+ } from "./reconciledfeatureadded.js";
14
+ import {
15
+ ReconciledFeatureFailed,
16
+ ReconciledFeatureFailed$inboundSchema,
17
+ } from "./reconciledfeaturefailed.js";
18
+ import {
19
+ ReconciledFeatureRemoved,
20
+ ReconciledFeatureRemoved$inboundSchema,
21
+ } from "./reconciledfeatureremoved.js";
22
+ import {
23
+ ReconciledFeatureSkipped,
24
+ ReconciledFeatureSkipped$inboundSchema,
25
+ } from "./reconciledfeatureskipped.js";
26
+
27
+ export const SubscriptionReconciliationObject = {
28
+ SubscriptionReconciliation: "subscriptionReconciliation",
29
+ } as const;
30
+ export type SubscriptionReconciliationObject = ClosedEnum<
31
+ typeof SubscriptionReconciliationObject
32
+ >;
33
+
34
+ export type Features = {
35
+ added: Array<ReconciledFeatureAdded>;
36
+ /**
37
+ * Features the subscription already had an active entitlement for — left unchanged.
38
+ */
39
+ skipped: Array<ReconciledFeatureSkipped>;
40
+ /**
41
+ * Features no longer on the plan: their entitlement was canceled and grants voided so the subscription matches the plan's current features.
42
+ */
43
+ removed: Array<ReconciledFeatureRemoved>;
44
+ /**
45
+ * Features that could not be fully provisioned. Never billed by this call.
46
+ */
47
+ failed: Array<ReconciledFeatureFailed>;
48
+ };
49
+
50
+ export type SubscriptionReconciliationLineItems = {
51
+ /**
52
+ * Number of features newly billed on the subscription by this reconciliation. A dry-run preview returns the same count as the applied run.
53
+ */
54
+ created: number;
55
+ /**
56
+ * Number of features whose billing was removed from the subscription's upcoming (not-yet-invoiced) invoice because their price is no longer on the plan.
57
+ */
58
+ removed: number;
59
+ /**
60
+ * True when entitlements were provisioned successfully but the line-item synchronization step failed. Safe to retry.
61
+ */
62
+ syncFailed?: boolean | undefined;
63
+ };
64
+
65
+ export type SubscriptionReconciliation = {
66
+ object: SubscriptionReconciliationObject;
67
+ /**
68
+ * True when this reconciliation was a preview — no entitlement, grant, or line item was created.
69
+ */
70
+ dryRun: boolean;
71
+ features: Features;
72
+ lineItems: SubscriptionReconciliationLineItems;
73
+ };
74
+
75
+ /** @internal */
76
+ export const SubscriptionReconciliationObject$inboundSchema: z.ZodNativeEnum<
77
+ typeof SubscriptionReconciliationObject
78
+ > = z.nativeEnum(SubscriptionReconciliationObject);
79
+
80
+ /** @internal */
81
+ export const Features$inboundSchema: z.ZodType<
82
+ Features,
83
+ z.ZodTypeDef,
84
+ unknown
85
+ > = z.object({
86
+ added: z.array(ReconciledFeatureAdded$inboundSchema),
87
+ skipped: z.array(ReconciledFeatureSkipped$inboundSchema),
88
+ removed: z.array(ReconciledFeatureRemoved$inboundSchema),
89
+ failed: z.array(ReconciledFeatureFailed$inboundSchema),
90
+ });
91
+
92
+ export function featuresFromJSON(
93
+ jsonString: string,
94
+ ): SafeParseResult<Features, SDKValidationError> {
95
+ return safeParse(
96
+ jsonString,
97
+ (x) => Features$inboundSchema.parse(JSON.parse(x)),
98
+ `Failed to parse 'Features' from JSON`,
99
+ );
100
+ }
101
+
102
+ /** @internal */
103
+ export const SubscriptionReconciliationLineItems$inboundSchema: z.ZodType<
104
+ SubscriptionReconciliationLineItems,
105
+ z.ZodTypeDef,
106
+ unknown
107
+ > = z.object({
108
+ created: z.number().int(),
109
+ removed: z.number().int(),
110
+ syncFailed: z.boolean().optional(),
111
+ });
112
+
113
+ export function subscriptionReconciliationLineItemsFromJSON(
114
+ jsonString: string,
115
+ ): SafeParseResult<SubscriptionReconciliationLineItems, SDKValidationError> {
116
+ return safeParse(
117
+ jsonString,
118
+ (x) =>
119
+ SubscriptionReconciliationLineItems$inboundSchema.parse(JSON.parse(x)),
120
+ `Failed to parse 'SubscriptionReconciliationLineItems' from JSON`,
121
+ );
122
+ }
123
+
124
+ /** @internal */
125
+ export const SubscriptionReconciliation$inboundSchema: z.ZodType<
126
+ SubscriptionReconciliation,
127
+ z.ZodTypeDef,
128
+ unknown
129
+ > = z.object({
130
+ object: SubscriptionReconciliationObject$inboundSchema,
131
+ dryRun: z.boolean(),
132
+ features: z.lazy(() => Features$inboundSchema),
133
+ lineItems: z.lazy(() => SubscriptionReconciliationLineItems$inboundSchema),
134
+ });
135
+
136
+ export function subscriptionReconciliationFromJSON(
137
+ jsonString: string,
138
+ ): SafeParseResult<SubscriptionReconciliation, SDKValidationError> {
139
+ return safeParse(
140
+ jsonString,
141
+ (x) => SubscriptionReconciliation$inboundSchema.parse(JSON.parse(x)),
142
+ `Failed to parse 'SubscriptionReconciliation' from JSON`,
143
+ );
144
+ }
@@ -6,6 +6,7 @@ import { subscriptionsCreate } from "../funcs/subscriptionsCreate.js";
6
6
  import { subscriptionsGeneratePortalLink } from "../funcs/subscriptionsGeneratePortalLink.js";
7
7
  import { subscriptionsGet } from "../funcs/subscriptionsGet.js";
8
8
  import { subscriptionsList } from "../funcs/subscriptionsList.js";
9
+ import { subscriptionsReconcileSubscriptionFeatures } from "../funcs/subscriptionsReconcileSubscriptionFeatures.js";
9
10
  import { subscriptionsTerminate } from "../funcs/subscriptionsTerminate.js";
10
11
  import { subscriptionsUpdateSubscription } from "../funcs/subscriptionsUpdateSubscription.js";
11
12
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
@@ -106,4 +107,21 @@ export class Subscriptions extends ClientSDK {
106
107
  options,
107
108
  ));
108
109
  }
110
+
111
+ /**
112
+ * Reconcile Features
113
+ *
114
+ * @remarks
115
+ * Creates a reconciliation that converges a subscription's feature entitlements to its current plan. Provisions a missing entitlement (and, for metered features, its initial grant) for every plan feature the subscription does not already have; cancels the entitlement and voids the grants of any feature no longer on the plan; then synchronizes the corresponding prices' billing. An already-present feature is left unchanged. Restricted to active subscriptions billed on their plan's line-item schedule.
116
+ */
117
+ async reconcileSubscriptionFeatures(
118
+ request: operations.ReconcileSubscriptionFeaturesRequest,
119
+ options?: RequestOptions,
120
+ ): Promise<models.SubscriptionReconciliation> {
121
+ return unwrapAsync(subscriptionsReconcileSubscriptionFeatures(
122
+ this,
123
+ request,
124
+ options,
125
+ ));
126
+ }
109
127
  }