@paygentic/sdk 0.8.0 → 0.8.2

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 (216) hide show
  1. package/README.md +5 -3
  2. package/dist/commonjs/funcs/billableMetricsListEvents.js +1 -0
  3. package/dist/commonjs/funcs/billableMetricsListEvents.js.map +1 -1
  4. package/dist/commonjs/funcs/billableMetricsMeter.js +2 -0
  5. package/dist/commonjs/funcs/billableMetricsMeter.js.map +1 -1
  6. package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts +19 -0
  7. package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts.map +1 -0
  8. package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.js +125 -0
  9. package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.js.map +1 -0
  10. package/dist/commonjs/lib/config.d.ts +2 -2
  11. package/dist/commonjs/lib/config.js +2 -2
  12. package/dist/commonjs/models/eventresponse.d.ts +7 -0
  13. package/dist/commonjs/models/eventresponse.d.ts.map +1 -1
  14. package/dist/commonjs/models/eventresponse.js +1 -0
  15. package/dist/commonjs/models/eventresponse.js.map +1 -1
  16. package/dist/commonjs/models/index.d.ts +6 -0
  17. package/dist/commonjs/models/index.d.ts.map +1 -1
  18. package/dist/commonjs/models/index.js +6 -0
  19. package/dist/commonjs/models/index.js.map +1 -1
  20. package/dist/commonjs/models/invoice.d.ts +4 -4
  21. package/dist/commonjs/models/invoice.d.ts.map +1 -1
  22. package/dist/commonjs/models/invoice.js +7 -6
  23. package/dist/commonjs/models/invoice.js.map +1 -1
  24. package/dist/commonjs/models/meterevent.d.ts +4 -0
  25. package/dist/commonjs/models/meterevent.d.ts.map +1 -1
  26. package/dist/commonjs/models/meterevent.js +1 -0
  27. package/dist/commonjs/models/meterevent.js.map +1 -1
  28. package/dist/commonjs/models/operations/advancetestclock.d.ts +12 -12
  29. package/dist/commonjs/models/operations/advancetestclock.d.ts.map +1 -1
  30. package/dist/commonjs/models/operations/advancetestclock.js +13 -13
  31. package/dist/commonjs/models/operations/advancetestclock.js.map +1 -1
  32. package/dist/commonjs/models/operations/createplan.d.ts +8 -2
  33. package/dist/commonjs/models/operations/createplan.d.ts.map +1 -1
  34. package/dist/commonjs/models/operations/createplan.js +4 -1
  35. package/dist/commonjs/models/operations/createplan.js.map +1 -1
  36. package/dist/commonjs/models/operations/getbillablemetricmeter.d.ts +11 -1
  37. package/dist/commonjs/models/operations/getbillablemetricmeter.d.ts.map +1 -1
  38. package/dist/commonjs/models/operations/getbillablemetricmeter.js +2 -0
  39. package/dist/commonjs/models/operations/getbillablemetricmeter.js.map +1 -1
  40. package/dist/commonjs/models/operations/index.d.ts +1 -0
  41. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  42. package/dist/commonjs/models/operations/index.js +1 -0
  43. package/dist/commonjs/models/operations/index.js.map +1 -1
  44. package/dist/commonjs/models/operations/ingestevent.d.ts +71 -3
  45. package/dist/commonjs/models/operations/ingestevent.d.ts.map +1 -1
  46. package/dist/commonjs/models/operations/ingestevent.js +28 -2
  47. package/dist/commonjs/models/operations/ingestevent.js.map +1 -1
  48. package/dist/commonjs/models/operations/listbillablemetricevents.d.ts +5 -0
  49. package/dist/commonjs/models/operations/listbillablemetricevents.d.ts.map +1 -1
  50. package/dist/commonjs/models/operations/listbillablemetricevents.js +1 -0
  51. package/dist/commonjs/models/operations/listbillablemetricevents.js.map +1 -1
  52. package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.d.ts +30 -0
  53. package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.d.ts.map +1 -0
  54. package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.js +63 -0
  55. package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.js.map +1 -0
  56. package/dist/commonjs/models/operations/updateplan.d.ts +6 -0
  57. package/dist/commonjs/models/operations/updateplan.d.ts.map +1 -1
  58. package/dist/commonjs/models/operations/updateplan.js +3 -0
  59. package/dist/commonjs/models/operations/updateplan.js.map +1 -1
  60. package/dist/commonjs/models/plan.d.ts +5 -0
  61. package/dist/commonjs/models/plan.d.ts.map +1 -1
  62. package/dist/commonjs/models/plan.js +2 -0
  63. package/dist/commonjs/models/plan.js.map +1 -1
  64. package/dist/commonjs/models/plancreditallocation.d.ts +30 -0
  65. package/dist/commonjs/models/plancreditallocation.d.ts.map +1 -0
  66. package/dist/commonjs/models/plancreditallocation.js +62 -0
  67. package/dist/commonjs/models/plancreditallocation.js.map +1 -0
  68. package/dist/commonjs/models/reconciledfeatureadded.d.ts +15 -0
  69. package/dist/commonjs/models/reconciledfeatureadded.d.ts.map +1 -0
  70. package/dist/commonjs/models/reconciledfeatureadded.js +52 -0
  71. package/dist/commonjs/models/reconciledfeatureadded.js.map +1 -0
  72. package/dist/commonjs/models/reconciledfeaturefailed.d.ts +29 -0
  73. package/dist/commonjs/models/reconciledfeaturefailed.d.ts.map +1 -0
  74. package/dist/commonjs/models/reconciledfeaturefailed.js +62 -0
  75. package/dist/commonjs/models/reconciledfeaturefailed.js.map +1 -0
  76. package/dist/commonjs/models/reconciledfeatureremoved.d.ts +11 -0
  77. package/dist/commonjs/models/reconciledfeatureremoved.d.ts.map +1 -0
  78. package/dist/commonjs/models/reconciledfeatureremoved.js +51 -0
  79. package/dist/commonjs/models/reconciledfeatureremoved.js.map +1 -0
  80. package/dist/commonjs/models/reconciledfeatureskipped.d.ts +11 -0
  81. package/dist/commonjs/models/reconciledfeatureskipped.d.ts.map +1 -0
  82. package/dist/commonjs/models/reconciledfeatureskipped.js +51 -0
  83. package/dist/commonjs/models/reconciledfeatureskipped.js.map +1 -0
  84. package/dist/commonjs/models/subscriptionreconciliation.d.ts +62 -0
  85. package/dist/commonjs/models/subscriptionreconciliation.d.ts.map +1 -0
  86. package/dist/commonjs/models/subscriptionreconciliation.js +83 -0
  87. package/dist/commonjs/models/subscriptionreconciliation.js.map +1 -0
  88. package/dist/commonjs/models/usageresponse.d.ts +10 -2
  89. package/dist/commonjs/models/usageresponse.d.ts.map +1 -1
  90. package/dist/commonjs/models/usageresponse.js +2 -0
  91. package/dist/commonjs/models/usageresponse.js.map +1 -1
  92. package/dist/commonjs/sdk/subscriptions.d.ts +7 -0
  93. package/dist/commonjs/sdk/subscriptions.d.ts.map +1 -1
  94. package/dist/commonjs/sdk/subscriptions.js +10 -0
  95. package/dist/commonjs/sdk/subscriptions.js.map +1 -1
  96. package/dist/esm/funcs/billableMetricsListEvents.js +1 -0
  97. package/dist/esm/funcs/billableMetricsListEvents.js.map +1 -1
  98. package/dist/esm/funcs/billableMetricsMeter.js +2 -0
  99. package/dist/esm/funcs/billableMetricsMeter.js.map +1 -1
  100. package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts +19 -0
  101. package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts.map +1 -0
  102. package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.js +89 -0
  103. package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.js.map +1 -0
  104. package/dist/esm/lib/config.d.ts +2 -2
  105. package/dist/esm/lib/config.js +2 -2
  106. package/dist/esm/models/eventresponse.d.ts +7 -0
  107. package/dist/esm/models/eventresponse.d.ts.map +1 -1
  108. package/dist/esm/models/eventresponse.js +1 -0
  109. package/dist/esm/models/eventresponse.js.map +1 -1
  110. package/dist/esm/models/index.d.ts +6 -0
  111. package/dist/esm/models/index.d.ts.map +1 -1
  112. package/dist/esm/models/index.js +6 -0
  113. package/dist/esm/models/index.js.map +1 -1
  114. package/dist/esm/models/invoice.d.ts +4 -4
  115. package/dist/esm/models/invoice.d.ts.map +1 -1
  116. package/dist/esm/models/invoice.js +5 -4
  117. package/dist/esm/models/invoice.js.map +1 -1
  118. package/dist/esm/models/meterevent.d.ts +4 -0
  119. package/dist/esm/models/meterevent.d.ts.map +1 -1
  120. package/dist/esm/models/meterevent.js +1 -0
  121. package/dist/esm/models/meterevent.js.map +1 -1
  122. package/dist/esm/models/operations/advancetestclock.d.ts +12 -12
  123. package/dist/esm/models/operations/advancetestclock.d.ts.map +1 -1
  124. package/dist/esm/models/operations/advancetestclock.js +10 -10
  125. package/dist/esm/models/operations/advancetestclock.js.map +1 -1
  126. package/dist/esm/models/operations/createplan.d.ts +8 -2
  127. package/dist/esm/models/operations/createplan.d.ts.map +1 -1
  128. package/dist/esm/models/operations/createplan.js +4 -1
  129. package/dist/esm/models/operations/createplan.js.map +1 -1
  130. package/dist/esm/models/operations/getbillablemetricmeter.d.ts +11 -1
  131. package/dist/esm/models/operations/getbillablemetricmeter.d.ts.map +1 -1
  132. package/dist/esm/models/operations/getbillablemetricmeter.js +2 -0
  133. package/dist/esm/models/operations/getbillablemetricmeter.js.map +1 -1
  134. package/dist/esm/models/operations/index.d.ts +1 -0
  135. package/dist/esm/models/operations/index.d.ts.map +1 -1
  136. package/dist/esm/models/operations/index.js +1 -0
  137. package/dist/esm/models/operations/index.js.map +1 -1
  138. package/dist/esm/models/operations/ingestevent.d.ts +71 -3
  139. package/dist/esm/models/operations/ingestevent.d.ts.map +1 -1
  140. package/dist/esm/models/operations/ingestevent.js +25 -1
  141. package/dist/esm/models/operations/ingestevent.js.map +1 -1
  142. package/dist/esm/models/operations/listbillablemetricevents.d.ts +5 -0
  143. package/dist/esm/models/operations/listbillablemetricevents.d.ts.map +1 -1
  144. package/dist/esm/models/operations/listbillablemetricevents.js +1 -0
  145. package/dist/esm/models/operations/listbillablemetricevents.js.map +1 -1
  146. package/dist/esm/models/operations/reconcilesubscriptionfeatures.d.ts +30 -0
  147. package/dist/esm/models/operations/reconcilesubscriptionfeatures.d.ts.map +1 -0
  148. package/dist/esm/models/operations/reconcilesubscriptionfeatures.js +25 -0
  149. package/dist/esm/models/operations/reconcilesubscriptionfeatures.js.map +1 -0
  150. package/dist/esm/models/operations/updateplan.d.ts +6 -0
  151. package/dist/esm/models/operations/updateplan.d.ts.map +1 -1
  152. package/dist/esm/models/operations/updateplan.js +3 -0
  153. package/dist/esm/models/operations/updateplan.js.map +1 -1
  154. package/dist/esm/models/plan.d.ts +5 -0
  155. package/dist/esm/models/plan.d.ts.map +1 -1
  156. package/dist/esm/models/plan.js +2 -0
  157. package/dist/esm/models/plan.js.map +1 -1
  158. package/dist/esm/models/plancreditallocation.d.ts +30 -0
  159. package/dist/esm/models/plancreditallocation.d.ts.map +1 -0
  160. package/dist/esm/models/plancreditallocation.js +24 -0
  161. package/dist/esm/models/plancreditallocation.js.map +1 -0
  162. package/dist/esm/models/reconciledfeatureadded.d.ts +15 -0
  163. package/dist/esm/models/reconciledfeatureadded.d.ts.map +1 -0
  164. package/dist/esm/models/reconciledfeatureadded.js +15 -0
  165. package/dist/esm/models/reconciledfeatureadded.js.map +1 -0
  166. package/dist/esm/models/reconciledfeaturefailed.d.ts +29 -0
  167. package/dist/esm/models/reconciledfeaturefailed.d.ts.map +1 -0
  168. package/dist/esm/models/reconciledfeaturefailed.js +25 -0
  169. package/dist/esm/models/reconciledfeaturefailed.js.map +1 -0
  170. package/dist/esm/models/reconciledfeatureremoved.d.ts +11 -0
  171. package/dist/esm/models/reconciledfeatureremoved.d.ts.map +1 -0
  172. package/dist/esm/models/reconciledfeatureremoved.js +14 -0
  173. package/dist/esm/models/reconciledfeatureremoved.js.map +1 -0
  174. package/dist/esm/models/reconciledfeatureskipped.d.ts +11 -0
  175. package/dist/esm/models/reconciledfeatureskipped.d.ts.map +1 -0
  176. package/dist/esm/models/reconciledfeatureskipped.js +14 -0
  177. package/dist/esm/models/reconciledfeatureskipped.js.map +1 -0
  178. package/dist/esm/models/subscriptionreconciliation.d.ts +62 -0
  179. package/dist/esm/models/subscriptionreconciliation.d.ts.map +1 -0
  180. package/dist/esm/models/subscriptionreconciliation.js +44 -0
  181. package/dist/esm/models/subscriptionreconciliation.js.map +1 -0
  182. package/dist/esm/models/usageresponse.d.ts +10 -2
  183. package/dist/esm/models/usageresponse.d.ts.map +1 -1
  184. package/dist/esm/models/usageresponse.js +2 -0
  185. package/dist/esm/models/usageresponse.js.map +1 -1
  186. package/dist/esm/sdk/subscriptions.d.ts +7 -0
  187. package/dist/esm/sdk/subscriptions.d.ts.map +1 -1
  188. package/dist/esm/sdk/subscriptions.js +10 -0
  189. package/dist/esm/sdk/subscriptions.js.map +1 -1
  190. package/jsr.json +1 -1
  191. package/package.json +1 -1
  192. package/src/funcs/billableMetricsListEvents.ts +1 -0
  193. package/src/funcs/billableMetricsMeter.ts +2 -0
  194. package/src/funcs/subscriptionsReconcileSubscriptionFeatures.ts +184 -0
  195. package/src/lib/config.ts +2 -2
  196. package/src/models/eventresponse.ts +8 -0
  197. package/src/models/index.ts +6 -0
  198. package/src/models/invoice.ts +10 -9
  199. package/src/models/meterevent.ts +5 -0
  200. package/src/models/operations/advancetestclock.ts +39 -23
  201. package/src/models/operations/createplan.ts +11 -3
  202. package/src/models/operations/getbillablemetricmeter.ts +13 -1
  203. package/src/models/operations/index.ts +1 -0
  204. package/src/models/operations/ingestevent.ts +116 -6
  205. package/src/models/operations/listbillablemetricevents.ts +6 -0
  206. package/src/models/operations/reconcilesubscriptionfeatures.ts +78 -0
  207. package/src/models/operations/updateplan.ts +8 -0
  208. package/src/models/plan.ts +9 -0
  209. package/src/models/plancreditallocation.ts +68 -0
  210. package/src/models/reconciledfeatureadded.ts +38 -0
  211. package/src/models/reconciledfeaturefailed.ts +55 -0
  212. package/src/models/reconciledfeatureremoved.ts +33 -0
  213. package/src/models/reconciledfeatureskipped.ts +33 -0
  214. package/src/models/subscriptionreconciliation.ts +144 -0
  215. package/src/models/usageresponse.ts +12 -2
  216. package/src/sdk/subscriptions.ts +18 -0
@@ -47,6 +47,10 @@ export type MeterEvent = {
47
47
  * Optional external identifier for cross-referencing with external systems. Alphanumeric characters, hyphens, and underscores only.
48
48
  */
49
49
  externalId?: string | undefined;
50
+ /**
51
+ * The merchant's own customer identifier the event was reported with. Empty subject with an externalSubject means the event is not linked to a customer yet.
52
+ */
53
+ externalSubject?: string | undefined;
50
54
  };
51
55
 
52
56
  /** @internal */
@@ -69,6 +73,7 @@ export const MeterEvent$inboundSchema: z.ZodType<
69
73
  idempotencyKey: z.string(),
70
74
  data: z.record(z.any()),
71
75
  externalId: z.string().optional(),
76
+ externalSubject: z.string().optional(),
72
77
  });
73
78
 
74
79
  export function meterEventFromJSON(
@@ -5,70 +5,84 @@
5
5
  import * as z from "zod/v3";
6
6
  import { remap as remap$ } from "../../lib/primitives.js";
7
7
 
8
- export type RequestBody2 = {
8
+ export type AdvanceTestClockRequestBody2 = {
9
9
  /**
10
10
  * ISO 8601 duration format indicating clock advancement distance. Sample values: 'P1M' moves forward one month, 'P7D' moves forward seven days, 'PT2H' moves forward two hours, 'P1Y2M3DT4H5M6S' moves forward one year, two months, three days, four hours, five minutes, and six seconds
11
11
  */
12
12
  advanceBy: string;
13
13
  };
14
14
 
15
- export type RequestBody1 = {
15
+ export type AdvanceTestClockRequestBody1 = {
16
16
  /**
17
17
  * New absolute time for the test clock (must be forward in time)
18
18
  */
19
19
  currentTime: Date;
20
20
  };
21
21
 
22
- export type AdvanceTestClockRequestBody = RequestBody1 | RequestBody2;
22
+ export type AdvanceTestClockRequestBody =
23
+ | AdvanceTestClockRequestBody1
24
+ | AdvanceTestClockRequestBody2;
23
25
 
24
26
  export type AdvanceTestClockRequest = {
25
27
  /**
26
28
  * Test clock ID
27
29
  */
28
30
  id: string;
29
- requestBody: RequestBody1 | RequestBody2;
31
+ requestBody: AdvanceTestClockRequestBody1 | AdvanceTestClockRequestBody2;
30
32
  };
31
33
 
32
34
  /** @internal */
33
- export type RequestBody2$Outbound = {
35
+ export type AdvanceTestClockRequestBody2$Outbound = {
34
36
  advanceBy: string;
35
37
  };
36
38
 
37
39
  /** @internal */
38
- export const RequestBody2$outboundSchema: z.ZodType<
39
- RequestBody2$Outbound,
40
+ export const AdvanceTestClockRequestBody2$outboundSchema: z.ZodType<
41
+ AdvanceTestClockRequestBody2$Outbound,
40
42
  z.ZodTypeDef,
41
- RequestBody2
43
+ AdvanceTestClockRequestBody2
42
44
  > = z.object({
43
45
  advanceBy: z.string(),
44
46
  });
45
47
 
46
- export function requestBody2ToJSON(requestBody2: RequestBody2): string {
47
- return JSON.stringify(RequestBody2$outboundSchema.parse(requestBody2));
48
+ export function advanceTestClockRequestBody2ToJSON(
49
+ advanceTestClockRequestBody2: AdvanceTestClockRequestBody2,
50
+ ): string {
51
+ return JSON.stringify(
52
+ AdvanceTestClockRequestBody2$outboundSchema.parse(
53
+ advanceTestClockRequestBody2,
54
+ ),
55
+ );
48
56
  }
49
57
 
50
58
  /** @internal */
51
- export type RequestBody1$Outbound = {
59
+ export type AdvanceTestClockRequestBody1$Outbound = {
52
60
  currentTime: string;
53
61
  };
54
62
 
55
63
  /** @internal */
56
- export const RequestBody1$outboundSchema: z.ZodType<
57
- RequestBody1$Outbound,
64
+ export const AdvanceTestClockRequestBody1$outboundSchema: z.ZodType<
65
+ AdvanceTestClockRequestBody1$Outbound,
58
66
  z.ZodTypeDef,
59
- RequestBody1
67
+ AdvanceTestClockRequestBody1
60
68
  > = z.object({
61
69
  currentTime: z.date().transform(v => v.toISOString()),
62
70
  });
63
71
 
64
- export function requestBody1ToJSON(requestBody1: RequestBody1): string {
65
- return JSON.stringify(RequestBody1$outboundSchema.parse(requestBody1));
72
+ export function advanceTestClockRequestBody1ToJSON(
73
+ advanceTestClockRequestBody1: AdvanceTestClockRequestBody1,
74
+ ): string {
75
+ return JSON.stringify(
76
+ AdvanceTestClockRequestBody1$outboundSchema.parse(
77
+ advanceTestClockRequestBody1,
78
+ ),
79
+ );
66
80
  }
67
81
 
68
82
  /** @internal */
69
83
  export type AdvanceTestClockRequestBody$Outbound =
70
- | RequestBody1$Outbound
71
- | RequestBody2$Outbound;
84
+ | AdvanceTestClockRequestBody1$Outbound
85
+ | AdvanceTestClockRequestBody2$Outbound;
72
86
 
73
87
  /** @internal */
74
88
  export const AdvanceTestClockRequestBody$outboundSchema: z.ZodType<
@@ -76,8 +90,8 @@ export const AdvanceTestClockRequestBody$outboundSchema: z.ZodType<
76
90
  z.ZodTypeDef,
77
91
  AdvanceTestClockRequestBody
78
92
  > = z.union([
79
- z.lazy(() => RequestBody1$outboundSchema),
80
- z.lazy(() => RequestBody2$outboundSchema),
93
+ z.lazy(() => AdvanceTestClockRequestBody1$outboundSchema),
94
+ z.lazy(() => AdvanceTestClockRequestBody2$outboundSchema),
81
95
  ]);
82
96
 
83
97
  export function advanceTestClockRequestBodyToJSON(
@@ -93,7 +107,9 @@ export function advanceTestClockRequestBodyToJSON(
93
107
  /** @internal */
94
108
  export type AdvanceTestClockRequest$Outbound = {
95
109
  id: string;
96
- RequestBody: RequestBody1$Outbound | RequestBody2$Outbound;
110
+ RequestBody:
111
+ | AdvanceTestClockRequestBody1$Outbound
112
+ | AdvanceTestClockRequestBody2$Outbound;
97
113
  };
98
114
 
99
115
  /** @internal */
@@ -104,8 +120,8 @@ export const AdvanceTestClockRequest$outboundSchema: z.ZodType<
104
120
  > = z.object({
105
121
  id: z.string(),
106
122
  requestBody: z.union([
107
- z.lazy(() => RequestBody1$outboundSchema),
108
- z.lazy(() => RequestBody2$outboundSchema),
123
+ z.lazy(() => AdvanceTestClockRequestBody1$outboundSchema),
124
+ z.lazy(() => AdvanceTestClockRequestBody2$outboundSchema),
109
125
  ]),
110
126
  }).transform((v) => {
111
127
  return remap$(v, {
@@ -4,6 +4,7 @@
4
4
 
5
5
  import * as z from "zod/v3";
6
6
  import { ClosedEnum } from "../../types/enums.js";
7
+ import * as models from "../index.js";
7
8
 
8
9
  /**
9
10
  * ISO 8601 duration for the billing period. Takes precedence over billingInterval when both are provided.
@@ -104,7 +105,7 @@ export type CreatePlanRequest = {
104
105
  /**
105
106
  * Unique identifier for a product
106
107
  */
107
- productId?: string | undefined;
108
+ productId: string;
108
109
  /**
109
110
  * Whether tax is added on top of the price (exclusive) or included in the price (inclusive)
110
111
  */
@@ -125,6 +126,10 @@ export type CreatePlanRequest = {
125
126
  * ISO 8601 datetime reference point for billing period alignment. Must be in the past or present. When set, subscriptions created under this plan align their first billing period to the next recurrence of this anchor.
126
127
  */
127
128
  billingAnchor?: Date | null | undefined;
129
+ /**
130
+ * 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 may target the same pricingUnitId.
131
+ */
132
+ creditAllocations?: Array<models.PlanCreditAllocation> | undefined;
128
133
  };
129
134
 
130
135
  /** @internal */
@@ -159,12 +164,13 @@ export type CreatePlanRequest$Outbound = {
159
164
  merchantId: string;
160
165
  name: string;
161
166
  prices?: Array<string> | undefined;
162
- productId?: string | undefined;
167
+ productId: string;
163
168
  taxBehavior: string;
164
169
  renewalReminderEnabled: boolean;
165
170
  renewalReminderDays: number;
166
171
  billingVersion: number;
167
172
  billingAnchor?: string | null | undefined;
173
+ creditAllocations?: Array<models.PlanCreditAllocation$Outbound> | undefined;
168
174
  };
169
175
 
170
176
  /** @internal */
@@ -183,13 +189,15 @@ export const CreatePlanRequest$outboundSchema: z.ZodType<
183
189
  merchantId: z.string(),
184
190
  name: z.string(),
185
191
  prices: z.array(z.string()).optional(),
186
- productId: z.string().optional(),
192
+ productId: z.string(),
187
193
  taxBehavior: CreatePlanTaxBehavior$outboundSchema.default("exclusive"),
188
194
  renewalReminderEnabled: z.boolean().default(true),
189
195
  renewalReminderDays: z.number().int().default(3),
190
196
  billingVersion: BillingVersion$outboundSchema.default(1),
191
197
  billingAnchor: z.nullable(z.date().transform(v => v.toISOString()))
192
198
  .optional(),
199
+ creditAllocations: z.array(models.PlanCreditAllocation$outboundSchema)
200
+ .optional(),
193
201
  });
194
202
 
195
203
  export function createPlanRequestToJSON(
@@ -44,9 +44,17 @@ export type GetBillableMetricMeterRequest = {
44
44
  */
45
45
  filterGroupBy?: string | undefined;
46
46
  /**
47
- * Comma-separated dimension keys
47
+ * Comma-separated dimension keys. Configure keys for the grouping on the metric. Only the "subject" grouping is supported by default.
48
48
  */
49
49
  groupBy?: string | undefined;
50
+ /**
51
+ * Cap groupedValues to the top-N by value (descending). With windowSize, restricts the windowed series to those top-N groups. Bounds the payload for high-cardinality groupings; groupCount reports the untruncated distinct-group count.
52
+ */
53
+ groupLimit?: number | undefined;
54
+ /**
55
+ * Offset into the value-descending group ordering; requires groupLimit to page through grouped results. With windowSize set, pages the windowed series through the ranked groups (offset 0 yields the top-N).
56
+ */
57
+ groupOffset?: number | undefined;
50
58
  };
51
59
 
52
60
  /** @internal */
@@ -63,6 +71,8 @@ export type GetBillableMetricMeterRequest$Outbound = {
63
71
  windowSize?: string | undefined;
64
72
  filterGroupBy?: string | undefined;
65
73
  groupBy?: string | undefined;
74
+ groupLimit?: number | undefined;
75
+ groupOffset?: number | undefined;
66
76
  };
67
77
 
68
78
  /** @internal */
@@ -78,6 +88,8 @@ export const GetBillableMetricMeterRequest$outboundSchema: z.ZodType<
78
88
  windowSize: GetBillableMetricMeterWindowSize$outboundSchema.optional(),
79
89
  filterGroupBy: z.string().optional(),
80
90
  groupBy: z.string().optional(),
91
+ groupLimit: z.number().int().optional(),
92
+ groupOffset: z.number().int().optional(),
81
93
  });
82
94
 
83
95
  export function getBillableMetricMeterRequestToJSON(
@@ -105,6 +105,7 @@ export * from "./listsources.js";
105
105
  export * from "./listsubscriptions.js";
106
106
  export * from "./listtestclocks.js";
107
107
  export * from "./purchaseentitlementgrant.js";
108
+ export * from "./reconcilesubscriptionfeatures.js";
108
109
  export * from "./rejectsourceevent.js";
109
110
  export * from "./replacescheduleintervals.js";
110
111
  export * from "./terminatesubscription.js";
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as z from "zod/v3";
6
6
 
7
- export type IngestEventRequest = {
7
+ export type IngestEventRequestBody2 = {
8
8
  /**
9
9
  * CloudEvents type. Must match an eventType configured on a BillableMetric.
10
10
  */
@@ -14,9 +14,52 @@ export type IngestEventRequest = {
14
14
  */
15
15
  source: string;
16
16
  /**
17
- * Customer or entity ID this event relates to.
17
+ * Customer or entity ID this event relates to. Required unless externalSubject is provided.
18
+ */
19
+ subject?: string | undefined;
20
+ /**
21
+ * Your own customer identifier, matched against the customer's externalId. Fallback for when the Paygentic customer ID is not known — prefer subject when it is. Events reported before the customer exists are linked retroactively once a customer with this externalId is created. Resolution is eventually consistent: after an externalId is removed or reassigned, events may resolve to the previous customer for up to one hour. If subject is also provided, subject takes precedence and externalSubject is recorded but not used for resolution.
22
+ */
23
+ externalSubject: string;
24
+ /**
25
+ * Organization/merchant ID. Defaults to the authenticated user's organization. Platform users can specify a different organization.
26
+ */
27
+ namespace?: string | undefined;
28
+ /**
29
+ * Event timestamp. Defaults to server time if not provided.
30
+ */
31
+ timestamp?: Date | undefined;
32
+ /**
33
+ * User-provided deduplication key. If not provided, a unique key is generated.
34
+ */
35
+ idempotencyKey?: string | undefined;
36
+ /**
37
+ * Optional external identifier for cross-referencing with external systems. Alphanumeric characters, hyphens, and underscores only.
38
+ */
39
+ externalId?: string | undefined;
40
+ /**
41
+ * Event payload containing the metering data.
42
+ */
43
+ data: { [k: string]: any };
44
+ };
45
+
46
+ export type IngestEventRequestBody1 = {
47
+ /**
48
+ * CloudEvents type. Must match an eventType configured on a BillableMetric.
49
+ */
50
+ type: string;
51
+ /**
52
+ * Event source URI identifying the application.
53
+ */
54
+ source: string;
55
+ /**
56
+ * Customer or entity ID this event relates to. Required unless externalSubject is provided.
18
57
  */
19
58
  subject: string;
59
+ /**
60
+ * Your own customer identifier, matched against the customer's externalId. Fallback for when the Paygentic customer ID is not known — prefer subject when it is. Events reported before the customer exists are linked retroactively once a customer with this externalId is created. Resolution is eventually consistent: after an externalId is removed or reassigned, events may resolve to the previous customer for up to one hour. If subject is also provided, subject takes precedence and externalSubject is recorded but not used for resolution.
61
+ */
62
+ externalSubject?: string | undefined;
20
63
  /**
21
64
  * Organization/merchant ID. Defaults to the authenticated user's organization. Platform users can specify a different organization.
22
65
  */
@@ -39,11 +82,54 @@ export type IngestEventRequest = {
39
82
  data: { [k: string]: any };
40
83
  };
41
84
 
85
+ export type IngestEventRequest =
86
+ | IngestEventRequestBody1
87
+ | IngestEventRequestBody2;
88
+
89
+ /** @internal */
90
+ export type IngestEventRequestBody2$Outbound = {
91
+ type: string;
92
+ source: string;
93
+ subject?: string | undefined;
94
+ externalSubject: string;
95
+ namespace?: string | undefined;
96
+ timestamp?: string | undefined;
97
+ idempotencyKey?: string | undefined;
98
+ externalId?: string | undefined;
99
+ data: { [k: string]: any };
100
+ };
101
+
102
+ /** @internal */
103
+ export const IngestEventRequestBody2$outboundSchema: z.ZodType<
104
+ IngestEventRequestBody2$Outbound,
105
+ z.ZodTypeDef,
106
+ IngestEventRequestBody2
107
+ > = z.object({
108
+ type: z.string(),
109
+ source: z.string(),
110
+ subject: z.string().optional(),
111
+ externalSubject: z.string(),
112
+ namespace: z.string().optional(),
113
+ timestamp: z.date().transform(v => v.toISOString()).optional(),
114
+ idempotencyKey: z.string().optional(),
115
+ externalId: z.string().optional(),
116
+ data: z.record(z.any()),
117
+ });
118
+
119
+ export function ingestEventRequestBody2ToJSON(
120
+ ingestEventRequestBody2: IngestEventRequestBody2,
121
+ ): string {
122
+ return JSON.stringify(
123
+ IngestEventRequestBody2$outboundSchema.parse(ingestEventRequestBody2),
124
+ );
125
+ }
126
+
42
127
  /** @internal */
43
- export type IngestEventRequest$Outbound = {
128
+ export type IngestEventRequestBody1$Outbound = {
44
129
  type: string;
45
130
  source: string;
46
131
  subject: string;
132
+ externalSubject?: string | undefined;
47
133
  namespace?: string | undefined;
48
134
  timestamp?: string | undefined;
49
135
  idempotencyKey?: string | undefined;
@@ -52,14 +138,15 @@ export type IngestEventRequest$Outbound = {
52
138
  };
53
139
 
54
140
  /** @internal */
55
- export const IngestEventRequest$outboundSchema: z.ZodType<
56
- IngestEventRequest$Outbound,
141
+ export const IngestEventRequestBody1$outboundSchema: z.ZodType<
142
+ IngestEventRequestBody1$Outbound,
57
143
  z.ZodTypeDef,
58
- IngestEventRequest
144
+ IngestEventRequestBody1
59
145
  > = z.object({
60
146
  type: z.string(),
61
147
  source: z.string(),
62
148
  subject: z.string(),
149
+ externalSubject: z.string().optional(),
63
150
  namespace: z.string().optional(),
64
151
  timestamp: z.date().transform(v => v.toISOString()).optional(),
65
152
  idempotencyKey: z.string().optional(),
@@ -67,6 +154,29 @@ export const IngestEventRequest$outboundSchema: z.ZodType<
67
154
  data: z.record(z.any()),
68
155
  });
69
156
 
157
+ export function ingestEventRequestBody1ToJSON(
158
+ ingestEventRequestBody1: IngestEventRequestBody1,
159
+ ): string {
160
+ return JSON.stringify(
161
+ IngestEventRequestBody1$outboundSchema.parse(ingestEventRequestBody1),
162
+ );
163
+ }
164
+
165
+ /** @internal */
166
+ export type IngestEventRequest$Outbound =
167
+ | IngestEventRequestBody1$Outbound
168
+ | IngestEventRequestBody2$Outbound;
169
+
170
+ /** @internal */
171
+ export const IngestEventRequest$outboundSchema: z.ZodType<
172
+ IngestEventRequest$Outbound,
173
+ z.ZodTypeDef,
174
+ IngestEventRequest
175
+ > = z.union([
176
+ z.lazy(() => IngestEventRequestBody1$outboundSchema),
177
+ z.lazy(() => IngestEventRequestBody2$outboundSchema),
178
+ ]);
179
+
70
180
  export function ingestEventRequestToJSON(
71
181
  ingestEventRequest: IngestEventRequest,
72
182
  ): string {
@@ -30,6 +30,10 @@ export type ListBillableMetricEventsRequest = {
30
30
  * Filter by external identifier. Alphanumeric characters, hyphens, and underscores only.
31
31
  */
32
32
  externalId?: string | undefined;
33
+ /**
34
+ * Filter by the merchant's own customer identifier the event was reported with.
35
+ */
36
+ externalSubject?: string | undefined;
33
37
  };
34
38
 
35
39
  /** @internal */
@@ -41,6 +45,7 @@ export type ListBillableMetricEventsRequest$Outbound = {
41
45
  limit: number;
42
46
  offset: number;
43
47
  externalId?: string | undefined;
48
+ externalSubject?: string | undefined;
44
49
  };
45
50
 
46
51
  /** @internal */
@@ -56,6 +61,7 @@ export const ListBillableMetricEventsRequest$outboundSchema: z.ZodType<
56
61
  limit: z.number().int().default(20),
57
62
  offset: z.number().int().default(0),
58
63
  externalId: z.string().optional(),
64
+ externalSubject: z.string().optional(),
59
65
  });
60
66
 
61
67
  export function listBillableMetricEventsRequestToJSON(
@@ -0,0 +1,78 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+
8
+ export type ReconcileSubscriptionFeaturesRequestBody = {
9
+ /**
10
+ * Preview the outcome without creating any entitlement, grant, or line item.
11
+ */
12
+ dryRun?: boolean | undefined;
13
+ };
14
+
15
+ export type ReconcileSubscriptionFeaturesRequest = {
16
+ /**
17
+ * The subscription ID
18
+ */
19
+ id: string;
20
+ requestBody?: ReconcileSubscriptionFeaturesRequestBody | undefined;
21
+ };
22
+
23
+ /** @internal */
24
+ export type ReconcileSubscriptionFeaturesRequestBody$Outbound = {
25
+ dryRun: boolean;
26
+ };
27
+
28
+ /** @internal */
29
+ export const ReconcileSubscriptionFeaturesRequestBody$outboundSchema: z.ZodType<
30
+ ReconcileSubscriptionFeaturesRequestBody$Outbound,
31
+ z.ZodTypeDef,
32
+ ReconcileSubscriptionFeaturesRequestBody
33
+ > = z.object({
34
+ dryRun: z.boolean().default(false),
35
+ });
36
+
37
+ export function reconcileSubscriptionFeaturesRequestBodyToJSON(
38
+ reconcileSubscriptionFeaturesRequestBody:
39
+ ReconcileSubscriptionFeaturesRequestBody,
40
+ ): string {
41
+ return JSON.stringify(
42
+ ReconcileSubscriptionFeaturesRequestBody$outboundSchema.parse(
43
+ reconcileSubscriptionFeaturesRequestBody,
44
+ ),
45
+ );
46
+ }
47
+
48
+ /** @internal */
49
+ export type ReconcileSubscriptionFeaturesRequest$Outbound = {
50
+ id: string;
51
+ RequestBody?: ReconcileSubscriptionFeaturesRequestBody$Outbound | undefined;
52
+ };
53
+
54
+ /** @internal */
55
+ export const ReconcileSubscriptionFeaturesRequest$outboundSchema: z.ZodType<
56
+ ReconcileSubscriptionFeaturesRequest$Outbound,
57
+ z.ZodTypeDef,
58
+ ReconcileSubscriptionFeaturesRequest
59
+ > = z.object({
60
+ id: z.string(),
61
+ requestBody: z.lazy(() =>
62
+ ReconcileSubscriptionFeaturesRequestBody$outboundSchema
63
+ ).optional(),
64
+ }).transform((v) => {
65
+ return remap$(v, {
66
+ requestBody: "RequestBody",
67
+ });
68
+ });
69
+
70
+ export function reconcileSubscriptionFeaturesRequestToJSON(
71
+ reconcileSubscriptionFeaturesRequest: ReconcileSubscriptionFeaturesRequest,
72
+ ): string {
73
+ return JSON.stringify(
74
+ ReconcileSubscriptionFeaturesRequest$outboundSchema.parse(
75
+ reconcileSubscriptionFeaturesRequest,
76
+ ),
77
+ );
78
+ }
@@ -5,6 +5,7 @@
5
5
  import * as z from "zod/v3";
6
6
  import { remap as remap$ } from "../../lib/primitives.js";
7
7
  import { ClosedEnum } from "../../types/enums.js";
8
+ import * as models from "../index.js";
8
9
 
9
10
  /**
10
11
  * ISO 8601 duration for the billing period. Takes precedence over billingInterval when both are provided.
@@ -98,6 +99,10 @@ export type UpdatePlanRequestBody = {
98
99
  * ISO 8601 datetime reference point for billing period alignment. Must be in the past or present. Set to null to clear the anchor and revert to start-time-based anchoring.
99
100
  */
100
101
  billingAnchor?: Date | null | undefined;
102
+ /**
103
+ * 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 may target the same pricingUnitId.
104
+ */
105
+ creditAllocations?: Array<models.PlanCreditAllocation> | undefined;
101
106
  };
102
107
 
103
108
  export type UpdatePlanRequest = {
@@ -137,6 +142,7 @@ export type UpdatePlanRequestBody$Outbound = {
137
142
  renewalReminderEnabled?: boolean | undefined;
138
143
  renewalReminderDays?: number | undefined;
139
144
  billingAnchor?: string | null | undefined;
145
+ creditAllocations?: Array<models.PlanCreditAllocation$Outbound> | undefined;
140
146
  };
141
147
 
142
148
  /** @internal */
@@ -158,6 +164,8 @@ export const UpdatePlanRequestBody$outboundSchema: z.ZodType<
158
164
  renewalReminderDays: z.number().int().optional(),
159
165
  billingAnchor: z.nullable(z.date().transform(v => v.toISOString()))
160
166
  .optional(),
167
+ creditAllocations: z.array(models.PlanCreditAllocation$outboundSchema)
168
+ .optional(),
161
169
  });
162
170
 
163
171
  export function updatePlanRequestBodyToJSON(
@@ -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
+ }