@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.
- package/README.md +5 -3
- package/dist/commonjs/funcs/billableMetricsListEvents.js +1 -0
- package/dist/commonjs/funcs/billableMetricsListEvents.js.map +1 -1
- package/dist/commonjs/funcs/billableMetricsMeter.js +2 -0
- package/dist/commonjs/funcs/billableMetricsMeter.js.map +1 -1
- package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts +19 -0
- package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts.map +1 -0
- package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.js +125 -0
- package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/eventresponse.d.ts +7 -0
- package/dist/commonjs/models/eventresponse.d.ts.map +1 -1
- package/dist/commonjs/models/eventresponse.js +1 -0
- package/dist/commonjs/models/eventresponse.js.map +1 -1
- package/dist/commonjs/models/index.d.ts +6 -0
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js +6 -0
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/invoice.d.ts +4 -4
- package/dist/commonjs/models/invoice.d.ts.map +1 -1
- package/dist/commonjs/models/invoice.js +7 -6
- package/dist/commonjs/models/invoice.js.map +1 -1
- package/dist/commonjs/models/meterevent.d.ts +4 -0
- package/dist/commonjs/models/meterevent.d.ts.map +1 -1
- package/dist/commonjs/models/meterevent.js +1 -0
- package/dist/commonjs/models/meterevent.js.map +1 -1
- package/dist/commonjs/models/operations/advancetestclock.d.ts +12 -12
- package/dist/commonjs/models/operations/advancetestclock.d.ts.map +1 -1
- package/dist/commonjs/models/operations/advancetestclock.js +13 -13
- package/dist/commonjs/models/operations/advancetestclock.js.map +1 -1
- package/dist/commonjs/models/operations/createplan.d.ts +8 -2
- package/dist/commonjs/models/operations/createplan.d.ts.map +1 -1
- package/dist/commonjs/models/operations/createplan.js +4 -1
- package/dist/commonjs/models/operations/createplan.js.map +1 -1
- package/dist/commonjs/models/operations/getbillablemetricmeter.d.ts +11 -1
- package/dist/commonjs/models/operations/getbillablemetricmeter.d.ts.map +1 -1
- package/dist/commonjs/models/operations/getbillablemetricmeter.js +2 -0
- package/dist/commonjs/models/operations/getbillablemetricmeter.js.map +1 -1
- package/dist/commonjs/models/operations/index.d.ts +1 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +1 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/ingestevent.d.ts +71 -3
- package/dist/commonjs/models/operations/ingestevent.d.ts.map +1 -1
- package/dist/commonjs/models/operations/ingestevent.js +28 -2
- package/dist/commonjs/models/operations/ingestevent.js.map +1 -1
- package/dist/commonjs/models/operations/listbillablemetricevents.d.ts +5 -0
- package/dist/commonjs/models/operations/listbillablemetricevents.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listbillablemetricevents.js +1 -0
- package/dist/commonjs/models/operations/listbillablemetricevents.js.map +1 -1
- package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.d.ts +30 -0
- package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.d.ts.map +1 -0
- package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.js +63 -0
- package/dist/commonjs/models/operations/reconcilesubscriptionfeatures.js.map +1 -0
- package/dist/commonjs/models/operations/updateplan.d.ts +6 -0
- package/dist/commonjs/models/operations/updateplan.d.ts.map +1 -1
- package/dist/commonjs/models/operations/updateplan.js +3 -0
- package/dist/commonjs/models/operations/updateplan.js.map +1 -1
- package/dist/commonjs/models/plan.d.ts +5 -0
- package/dist/commonjs/models/plan.d.ts.map +1 -1
- package/dist/commonjs/models/plan.js +2 -0
- package/dist/commonjs/models/plan.js.map +1 -1
- package/dist/commonjs/models/plancreditallocation.d.ts +30 -0
- package/dist/commonjs/models/plancreditallocation.d.ts.map +1 -0
- package/dist/commonjs/models/plancreditallocation.js +62 -0
- package/dist/commonjs/models/plancreditallocation.js.map +1 -0
- package/dist/commonjs/models/reconciledfeatureadded.d.ts +15 -0
- package/dist/commonjs/models/reconciledfeatureadded.d.ts.map +1 -0
- package/dist/commonjs/models/reconciledfeatureadded.js +52 -0
- package/dist/commonjs/models/reconciledfeatureadded.js.map +1 -0
- package/dist/commonjs/models/reconciledfeaturefailed.d.ts +29 -0
- package/dist/commonjs/models/reconciledfeaturefailed.d.ts.map +1 -0
- package/dist/commonjs/models/reconciledfeaturefailed.js +62 -0
- package/dist/commonjs/models/reconciledfeaturefailed.js.map +1 -0
- package/dist/commonjs/models/reconciledfeatureremoved.d.ts +11 -0
- package/dist/commonjs/models/reconciledfeatureremoved.d.ts.map +1 -0
- package/dist/commonjs/models/reconciledfeatureremoved.js +51 -0
- package/dist/commonjs/models/reconciledfeatureremoved.js.map +1 -0
- package/dist/commonjs/models/reconciledfeatureskipped.d.ts +11 -0
- package/dist/commonjs/models/reconciledfeatureskipped.d.ts.map +1 -0
- package/dist/commonjs/models/reconciledfeatureskipped.js +51 -0
- package/dist/commonjs/models/reconciledfeatureskipped.js.map +1 -0
- package/dist/commonjs/models/subscriptionreconciliation.d.ts +62 -0
- package/dist/commonjs/models/subscriptionreconciliation.d.ts.map +1 -0
- package/dist/commonjs/models/subscriptionreconciliation.js +83 -0
- package/dist/commonjs/models/subscriptionreconciliation.js.map +1 -0
- package/dist/commonjs/models/usageresponse.d.ts +10 -2
- package/dist/commonjs/models/usageresponse.d.ts.map +1 -1
- package/dist/commonjs/models/usageresponse.js +2 -0
- package/dist/commonjs/models/usageresponse.js.map +1 -1
- package/dist/commonjs/sdk/subscriptions.d.ts +7 -0
- package/dist/commonjs/sdk/subscriptions.d.ts.map +1 -1
- package/dist/commonjs/sdk/subscriptions.js +10 -0
- package/dist/commonjs/sdk/subscriptions.js.map +1 -1
- package/dist/esm/funcs/billableMetricsListEvents.js +1 -0
- package/dist/esm/funcs/billableMetricsListEvents.js.map +1 -1
- package/dist/esm/funcs/billableMetricsMeter.js +2 -0
- package/dist/esm/funcs/billableMetricsMeter.js.map +1 -1
- package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts +19 -0
- package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.d.ts.map +1 -0
- package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.js +89 -0
- package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/eventresponse.d.ts +7 -0
- package/dist/esm/models/eventresponse.d.ts.map +1 -1
- package/dist/esm/models/eventresponse.js +1 -0
- package/dist/esm/models/eventresponse.js.map +1 -1
- package/dist/esm/models/index.d.ts +6 -0
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js +6 -0
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/invoice.d.ts +4 -4
- package/dist/esm/models/invoice.d.ts.map +1 -1
- package/dist/esm/models/invoice.js +5 -4
- package/dist/esm/models/invoice.js.map +1 -1
- package/dist/esm/models/meterevent.d.ts +4 -0
- package/dist/esm/models/meterevent.d.ts.map +1 -1
- package/dist/esm/models/meterevent.js +1 -0
- package/dist/esm/models/meterevent.js.map +1 -1
- package/dist/esm/models/operations/advancetestclock.d.ts +12 -12
- package/dist/esm/models/operations/advancetestclock.d.ts.map +1 -1
- package/dist/esm/models/operations/advancetestclock.js +10 -10
- package/dist/esm/models/operations/advancetestclock.js.map +1 -1
- package/dist/esm/models/operations/createplan.d.ts +8 -2
- package/dist/esm/models/operations/createplan.d.ts.map +1 -1
- package/dist/esm/models/operations/createplan.js +4 -1
- package/dist/esm/models/operations/createplan.js.map +1 -1
- package/dist/esm/models/operations/getbillablemetricmeter.d.ts +11 -1
- package/dist/esm/models/operations/getbillablemetricmeter.d.ts.map +1 -1
- package/dist/esm/models/operations/getbillablemetricmeter.js +2 -0
- package/dist/esm/models/operations/getbillablemetricmeter.js.map +1 -1
- package/dist/esm/models/operations/index.d.ts +1 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +1 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/ingestevent.d.ts +71 -3
- package/dist/esm/models/operations/ingestevent.d.ts.map +1 -1
- package/dist/esm/models/operations/ingestevent.js +25 -1
- package/dist/esm/models/operations/ingestevent.js.map +1 -1
- package/dist/esm/models/operations/listbillablemetricevents.d.ts +5 -0
- package/dist/esm/models/operations/listbillablemetricevents.d.ts.map +1 -1
- package/dist/esm/models/operations/listbillablemetricevents.js +1 -0
- package/dist/esm/models/operations/listbillablemetricevents.js.map +1 -1
- package/dist/esm/models/operations/reconcilesubscriptionfeatures.d.ts +30 -0
- package/dist/esm/models/operations/reconcilesubscriptionfeatures.d.ts.map +1 -0
- package/dist/esm/models/operations/reconcilesubscriptionfeatures.js +25 -0
- package/dist/esm/models/operations/reconcilesubscriptionfeatures.js.map +1 -0
- package/dist/esm/models/operations/updateplan.d.ts +6 -0
- package/dist/esm/models/operations/updateplan.d.ts.map +1 -1
- package/dist/esm/models/operations/updateplan.js +3 -0
- package/dist/esm/models/operations/updateplan.js.map +1 -1
- package/dist/esm/models/plan.d.ts +5 -0
- package/dist/esm/models/plan.d.ts.map +1 -1
- package/dist/esm/models/plan.js +2 -0
- package/dist/esm/models/plan.js.map +1 -1
- package/dist/esm/models/plancreditallocation.d.ts +30 -0
- package/dist/esm/models/plancreditallocation.d.ts.map +1 -0
- package/dist/esm/models/plancreditallocation.js +24 -0
- package/dist/esm/models/plancreditallocation.js.map +1 -0
- package/dist/esm/models/reconciledfeatureadded.d.ts +15 -0
- package/dist/esm/models/reconciledfeatureadded.d.ts.map +1 -0
- package/dist/esm/models/reconciledfeatureadded.js +15 -0
- package/dist/esm/models/reconciledfeatureadded.js.map +1 -0
- package/dist/esm/models/reconciledfeaturefailed.d.ts +29 -0
- package/dist/esm/models/reconciledfeaturefailed.d.ts.map +1 -0
- package/dist/esm/models/reconciledfeaturefailed.js +25 -0
- package/dist/esm/models/reconciledfeaturefailed.js.map +1 -0
- package/dist/esm/models/reconciledfeatureremoved.d.ts +11 -0
- package/dist/esm/models/reconciledfeatureremoved.d.ts.map +1 -0
- package/dist/esm/models/reconciledfeatureremoved.js +14 -0
- package/dist/esm/models/reconciledfeatureremoved.js.map +1 -0
- package/dist/esm/models/reconciledfeatureskipped.d.ts +11 -0
- package/dist/esm/models/reconciledfeatureskipped.d.ts.map +1 -0
- package/dist/esm/models/reconciledfeatureskipped.js +14 -0
- package/dist/esm/models/reconciledfeatureskipped.js.map +1 -0
- package/dist/esm/models/subscriptionreconciliation.d.ts +62 -0
- package/dist/esm/models/subscriptionreconciliation.d.ts.map +1 -0
- package/dist/esm/models/subscriptionreconciliation.js +44 -0
- package/dist/esm/models/subscriptionreconciliation.js.map +1 -0
- package/dist/esm/models/usageresponse.d.ts +10 -2
- package/dist/esm/models/usageresponse.d.ts.map +1 -1
- package/dist/esm/models/usageresponse.js +2 -0
- package/dist/esm/models/usageresponse.js.map +1 -1
- package/dist/esm/sdk/subscriptions.d.ts +7 -0
- package/dist/esm/sdk/subscriptions.d.ts.map +1 -1
- package/dist/esm/sdk/subscriptions.js +10 -0
- package/dist/esm/sdk/subscriptions.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/billableMetricsListEvents.ts +1 -0
- package/src/funcs/billableMetricsMeter.ts +2 -0
- package/src/funcs/subscriptionsReconcileSubscriptionFeatures.ts +184 -0
- package/src/lib/config.ts +2 -2
- package/src/models/eventresponse.ts +8 -0
- package/src/models/index.ts +6 -0
- package/src/models/invoice.ts +10 -9
- package/src/models/meterevent.ts +5 -0
- package/src/models/operations/advancetestclock.ts +39 -23
- package/src/models/operations/createplan.ts +11 -3
- package/src/models/operations/getbillablemetricmeter.ts +13 -1
- package/src/models/operations/index.ts +1 -0
- package/src/models/operations/ingestevent.ts +116 -6
- package/src/models/operations/listbillablemetricevents.ts +6 -0
- package/src/models/operations/reconcilesubscriptionfeatures.ts +78 -0
- package/src/models/operations/updateplan.ts +8 -0
- package/src/models/plan.ts +9 -0
- package/src/models/plancreditallocation.ts +68 -0
- package/src/models/reconciledfeatureadded.ts +38 -0
- package/src/models/reconciledfeaturefailed.ts +55 -0
- package/src/models/reconciledfeatureremoved.ts +33 -0
- package/src/models/reconciledfeatureskipped.ts +33 -0
- package/src/models/subscriptionreconciliation.ts +144 -0
- package/src/models/usageresponse.ts +12 -2
- package/src/sdk/subscriptions.ts +18 -0
package/src/models/meterevent.ts
CHANGED
|
@@ -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
|
|
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
|
|
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 =
|
|
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:
|
|
31
|
+
requestBody: AdvanceTestClockRequestBody1 | AdvanceTestClockRequestBody2;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
/** @internal */
|
|
33
|
-
export type
|
|
35
|
+
export type AdvanceTestClockRequestBody2$Outbound = {
|
|
34
36
|
advanceBy: string;
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
/** @internal */
|
|
38
|
-
export const
|
|
39
|
-
|
|
40
|
+
export const AdvanceTestClockRequestBody2$outboundSchema: z.ZodType<
|
|
41
|
+
AdvanceTestClockRequestBody2$Outbound,
|
|
40
42
|
z.ZodTypeDef,
|
|
41
|
-
|
|
43
|
+
AdvanceTestClockRequestBody2
|
|
42
44
|
> = z.object({
|
|
43
45
|
advanceBy: z.string(),
|
|
44
46
|
});
|
|
45
47
|
|
|
46
|
-
export function
|
|
47
|
-
|
|
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
|
|
59
|
+
export type AdvanceTestClockRequestBody1$Outbound = {
|
|
52
60
|
currentTime: string;
|
|
53
61
|
};
|
|
54
62
|
|
|
55
63
|
/** @internal */
|
|
56
|
-
export const
|
|
57
|
-
|
|
64
|
+
export const AdvanceTestClockRequestBody1$outboundSchema: z.ZodType<
|
|
65
|
+
AdvanceTestClockRequestBody1$Outbound,
|
|
58
66
|
z.ZodTypeDef,
|
|
59
|
-
|
|
67
|
+
AdvanceTestClockRequestBody1
|
|
60
68
|
> = z.object({
|
|
61
69
|
currentTime: z.date().transform(v => v.toISOString()),
|
|
62
70
|
});
|
|
63
71
|
|
|
64
|
-
export function
|
|
65
|
-
|
|
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
|
-
|
|
|
71
|
-
|
|
|
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(() =>
|
|
80
|
-
z.lazy(() =>
|
|
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:
|
|
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(() =>
|
|
108
|
-
z.lazy(() =>
|
|
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
|
|
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
|
|
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()
|
|
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
|
|
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
|
|
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
|
|
56
|
-
|
|
141
|
+
export const IngestEventRequestBody1$outboundSchema: z.ZodType<
|
|
142
|
+
IngestEventRequestBody1$Outbound,
|
|
57
143
|
z.ZodTypeDef,
|
|
58
|
-
|
|
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(
|
package/src/models/plan.ts
CHANGED
|
@@ -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
|
+
}
|