@paygentic/sdk 0.8.0 → 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.
- package/README.md +5 -3
- 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/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/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/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/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/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/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/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/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/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/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/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/subscriptionsReconcileSubscriptionFeatures.ts +184 -0
- package/src/lib/config.ts +2 -2
- package/src/models/index.ts +6 -0
- package/src/models/invoice.ts +10 -9
- package/src/models/operations/createplan.ts +11 -3
- package/src/models/operations/index.ts +1 -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/sdk/subscriptions.ts +18 -0
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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
package/src/sdk/subscriptions.ts
CHANGED
|
@@ -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
|
}
|