@schematichq/schematic-typescript-node 1.6.0 → 1.6.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 +51 -28
- package/dist/api/resources/credits/client/requests/AcquireCreditLeaseRequestBody.d.ts +1 -0
- package/dist/api/resources/credits/client/requests/ExtendCreditLeaseRequestBody.d.ts +3 -0
- package/dist/api/resources/entitlements/client/requests/CreateBillingLinkedPlanEntitlementRequestBody.d.ts +4 -0
- package/dist/api/resources/entitlements/client/requests/CreatePlanEntitlementRequestBody.d.ts +4 -0
- package/dist/api/resources/entitlements/client/requests/UpdatePlanEntitlementRequestBody.d.ts +4 -0
- package/dist/api/resources/features/client/requests/CheckAndReserveFlagRequestBody.d.ts +4 -2
- package/dist/api/resources/planmigrations/client/Client.d.ts +4 -2
- package/dist/api/resources/planmigrations/client/requests/CountMigrationsRequest.d.ts +3 -1
- package/dist/api/resources/planmigrations/client/requests/ListMigrationsRequest.d.ts +3 -1
- package/dist/api/resources/planmigrations/types/CountMigrationsParams.d.ts +1 -0
- package/dist/api/resources/planmigrations/types/ListMigrationsParams.d.ts +1 -0
- package/dist/api/resources/plans/client/Client.d.ts +4 -0
- package/dist/api/resources/plans/client/requests/CountPlansRequest.d.ts +6 -0
- package/dist/api/resources/plans/client/requests/ListPlansRequest.d.ts +6 -0
- package/dist/api/resources/plans/types/CountPlansParams.d.ts +4 -0
- package/dist/api/resources/plans/types/ListPlansParams.d.ts +4 -0
- package/dist/api/types/BillingArrearsCadence.d.ts +1 -0
- package/dist/api/types/BillingCreditGrantReason.d.ts +3 -0
- package/dist/api/types/BillingCreditResponseData.d.ts +1 -0
- package/dist/api/types/BillingPlanCreditGrantBillingMode.d.ts +5 -0
- package/dist/api/types/BillingPlanCreditGrantPriceTierResponseData.d.ts +10 -0
- package/dist/api/types/BillingPlanCreditGrantResponseData.d.ts +12 -0
- package/dist/api/types/CompanyPlanCreditGrantView.d.ts +3 -0
- package/dist/api/types/CreateBillingPlanCreditGrantRequestBody.d.ts +11 -1
- package/dist/api/types/CreateEntitlementInBundleRequestBody.d.ts +4 -0
- package/dist/api/types/CreditEventLedgerResponseData.d.ts +1 -0
- package/dist/api/types/CreditGrantPriceTierRequestBody.d.ts +8 -0
- package/dist/api/types/CreditTransferReason.d.ts +7 -0
- package/dist/api/types/PlanCreditGrantView.d.ts +3 -0
- package/dist/api/types/PlanEntitlementResponseData.d.ts +4 -0
- package/dist/api/types/PlanVersionMigrationResponseData.d.ts +2 -0
- package/dist/api/types/UpdateBillingPlanCreditGrantRequestBody.d.ts +11 -1
- package/dist/api/types/UsageBasedEntitlementRequestBody.d.ts +4 -0
- package/dist/api/types/index.d.ts +4 -0
- package/dist/cache/redis.d.ts +11 -0
- package/dist/credits/check.d.ts +10 -5
- package/dist/credits/index.d.ts +4 -4
- package/dist/credits/lease-manager.d.ts +74 -2
- package/dist/credits/lease-store.d.ts +27 -11
- package/dist/credits/redis-lease-store.d.ts +2 -2
- package/dist/credits/server-check.d.ts +40 -0
- package/dist/credits/track.d.ts +1 -1
- package/dist/credits/types.d.ts +37 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -10
- package/dist/serialization/resources/credits/client/requests/ExtendCreditLeaseRequestBody.d.ts +1 -0
- package/dist/serialization/resources/entitlements/client/requests/CreateBillingLinkedPlanEntitlementRequestBody.d.ts +4 -0
- package/dist/serialization/resources/entitlements/client/requests/CreatePlanEntitlementRequestBody.d.ts +4 -0
- package/dist/serialization/resources/entitlements/client/requests/UpdatePlanEntitlementRequestBody.d.ts +4 -0
- package/dist/serialization/resources/features/client/requests/CheckAndReserveFlagRequestBody.d.ts +1 -0
- package/dist/serialization/resources/planmigrations/types/CountMigrationsParams.d.ts +1 -0
- package/dist/serialization/resources/planmigrations/types/ListMigrationsParams.d.ts +1 -0
- package/dist/serialization/resources/plans/types/CountPlansParams.d.ts +2 -0
- package/dist/serialization/resources/plans/types/ListPlansParams.d.ts +2 -0
- package/dist/serialization/types/BillingArrearsCadence.d.ts +1 -1
- package/dist/serialization/types/BillingCreditGrantReason.d.ts +1 -1
- package/dist/serialization/types/BillingCreditResponseData.d.ts +2 -0
- package/dist/serialization/types/BillingPlanCreditGrantBillingMode.d.ts +7 -0
- package/dist/serialization/types/BillingPlanCreditGrantPriceTierResponseData.d.ts +12 -0
- package/dist/serialization/types/BillingPlanCreditGrantResponseData.d.ts +10 -0
- package/dist/serialization/types/CompanyPlanCreditGrantView.d.ts +5 -0
- package/dist/serialization/types/CreateBillingPlanCreditGrantRequestBody.d.ts +8 -0
- package/dist/serialization/types/CreateEntitlementInBundleRequestBody.d.ts +4 -0
- package/dist/serialization/types/CreditEventLedgerResponseData.d.ts +2 -0
- package/dist/serialization/types/CreditGrantPriceTierRequestBody.d.ts +11 -0
- package/dist/serialization/types/CreditTransferReason.d.ts +7 -0
- package/dist/serialization/types/PlanCreditGrantView.d.ts +5 -0
- package/dist/serialization/types/PlanEntitlementResponseData.d.ts +4 -0
- package/dist/serialization/types/PlanVersionMigrationResponseData.d.ts +2 -0
- package/dist/serialization/types/UpdateBillingPlanCreditGrantRequestBody.d.ts +8 -0
- package/dist/serialization/types/UsageBasedEntitlementRequestBody.d.ts +4 -0
- package/dist/serialization/types/index.d.ts +4 -0
- package/dist/wrapper.d.ts +91 -26
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -800,13 +800,12 @@ const client = new SchematicClient({
|
|
|
800
800
|
|
|
801
801
|
## Credit Leases and Reservations
|
|
802
802
|
|
|
803
|
-
For features metered by credit burndown (e.g. inference tokens), the
|
|
803
|
+
For features metered by credit burndown (e.g. inference tokens), `check()` holds credits for the work about to run and `trackWithReservation()` settles the hold with actual usage. The SDK gates in one of two modes:
|
|
804
804
|
|
|
805
|
-
-
|
|
806
|
-
-
|
|
807
|
-
- When the work completes, a track call reports actual usage; the difference between reserved and actual usage is refunded to the lease.
|
|
805
|
+
- **Client mode** acquires a **lease**, a tranche of credits held against the company's balance, and carves a per-request **reservation** out of it locally, so a check needs no API call. It requires [DataStream](#datastream) (or [Replicator Mode](#replicator-mode)) and, across multiple processes, a shared Redis so every instance gates against the same lease.
|
|
806
|
+
- **Server mode** makes one `check-and-reserve` API call per check. No lease, no Redis, no local state.
|
|
808
807
|
|
|
809
|
-
|
|
808
|
+
`creditLeases.mode` defaults to `auto`: client when DataStream is enabled, server otherwise. Client mode suits high-throughput gating; server mode suits low-volume checks and operations that run for seconds.
|
|
810
809
|
|
|
811
810
|
### Setup
|
|
812
811
|
|
|
@@ -821,25 +820,35 @@ const client = new SchematicClient({
|
|
|
821
820
|
apiKey: process.env.SCHEMATIC_API_KEY,
|
|
822
821
|
useDataStream: true,
|
|
823
822
|
dataStream: {
|
|
824
|
-
redisClient, // also backs lease + reservation state
|
|
823
|
+
redisClient, // also backs lease + reservation state
|
|
825
824
|
},
|
|
826
825
|
creditLeases: {
|
|
827
|
-
defaultLeaseDuration: 5 * 60 * 1000, // lease lifetime (ms)
|
|
828
|
-
defaultReservationTTL: 60 * 1000, // how long a reservation is held if not settled by a track (ms)
|
|
829
826
|
defaultLeaseSize: 10_000, // credits requested per lease
|
|
830
|
-
|
|
827
|
+
defaultLeaseDuration: 5 * 60 * 1000, // lease lifetime (ms)
|
|
828
|
+
defaultReservationTTL: 60 * 1000, // how long a reservation is held if no track settles it (ms)
|
|
831
829
|
},
|
|
832
830
|
});
|
|
833
831
|
```
|
|
834
832
|
|
|
835
|
-
|
|
833
|
+
Set `creditLeases.redisClient` to keep lease state in a different Redis than the DataStream cache.
|
|
836
834
|
|
|
837
|
-
|
|
835
|
+
Server mode needs only a TTL:
|
|
836
|
+
|
|
837
|
+
```ts
|
|
838
|
+
const client = new SchematicClient({
|
|
839
|
+
apiKey: process.env.SCHEMATIC_API_KEY,
|
|
840
|
+
creditLeases: {
|
|
841
|
+
defaultReservationTTL: 60 * 1000, // how long the server holds the credits if no track settles them (ms, max 1 hour)
|
|
842
|
+
},
|
|
843
|
+
});
|
|
844
|
+
```
|
|
838
845
|
|
|
839
|
-
`
|
|
846
|
+
Only `mode` and `defaultReservationTTL` apply in server mode; the SDK warns at startup if a client-only option is set.
|
|
847
|
+
|
|
848
|
+
### Checking and tracking
|
|
840
849
|
|
|
841
850
|
```ts
|
|
842
|
-
//
|
|
851
|
+
// Reserve up to maxTokens for this operation.
|
|
843
852
|
const result = await client.check(
|
|
844
853
|
{ company: { id: "your-company-id" } },
|
|
845
854
|
"inference",
|
|
@@ -854,15 +863,25 @@ if (!result.allowed) {
|
|
|
854
863
|
|
|
855
864
|
const inference = await runInference(/* ... */);
|
|
856
865
|
|
|
857
|
-
// Report actual usage; the unused slice of the reservation is refunded
|
|
858
|
-
|
|
866
|
+
// Report actual usage; the unused slice of the reservation is refunded.
|
|
867
|
+
if (result.reservation) {
|
|
868
|
+
await client.trackWithReservation(result.reservation, inference.tokensUsed);
|
|
869
|
+
} else {
|
|
870
|
+
await client.track({
|
|
871
|
+
event: "inference_tokens",
|
|
872
|
+
company: { id: "your-company-id" },
|
|
873
|
+
quantity: inference.tokensUsed,
|
|
874
|
+
});
|
|
875
|
+
}
|
|
859
876
|
```
|
|
860
877
|
|
|
861
|
-
|
|
878
|
+
A check can allow without taking a hold (the feature is not credit-metered, `usage` is 0, or the check failed open), and that usage still has to be tracked.
|
|
879
|
+
|
|
880
|
+
An unsettled reservation expires after `defaultReservationTTL` and its credits return to the lease. A late settle still bills the usage (the track event carries a deterministic idempotency key, so it never double-bills) but does not re-debit the local lease, so set `defaultReservationTTL` above the longest expected gap between `check()` and `trackWithReservation()`.
|
|
862
881
|
|
|
863
882
|
### Pre-warming
|
|
864
883
|
|
|
865
|
-
|
|
884
|
+
Pre-warm leases when the user is identified, so a session's first check does not wait on a lease acquire:
|
|
866
885
|
|
|
867
886
|
```ts
|
|
868
887
|
await client.identify(
|
|
@@ -874,11 +893,13 @@ await client.identify(
|
|
|
874
893
|
);
|
|
875
894
|
```
|
|
876
895
|
|
|
877
|
-
Or call `client.prewarm(evalCtx, creditTypeIds)` directly.
|
|
896
|
+
Or call `client.prewarm(evalCtx, creditTypeIds)` directly. Both are no-ops in server mode.
|
|
897
|
+
|
|
898
|
+
Pre-warming resolves the company the way the server does: it looks the keys up first, whatever they are named, and only when nothing matches does it read a value carrying Schematic's `comp_` prefix as the company id.
|
|
878
899
|
|
|
879
900
|
### Failure behavior
|
|
880
901
|
|
|
881
|
-
|
|
902
|
+
A check that cannot be gated (API unreachable, Redis down, lease exhausted) fails closed by default. Override per check:
|
|
882
903
|
|
|
883
904
|
```ts
|
|
884
905
|
const result = await client.check(evalCtx, "inference", {
|
|
@@ -888,20 +909,22 @@ const result = await client.check(evalCtx, "inference", {
|
|
|
888
909
|
});
|
|
889
910
|
```
|
|
890
911
|
|
|
891
|
-
`fail-open`
|
|
912
|
+
In client mode, `fail-open` still evaluates the flag's rules with the credit balance assumed sufficient, so plan targeting and all non-credit conditions apply and only the credit gate is bypassed. In server mode it returns the flag's default value, which is `false` unless you pass `defaultValue` or configure a `flagDefaults` entry.
|
|
892
913
|
|
|
893
914
|
### Configuration options
|
|
894
915
|
|
|
895
916
|
| Option | Type | Default | Description |
|
|
896
917
|
|---|---|---|---|
|
|
897
|
-
| `
|
|
898
|
-
| `defaultReservationTTL` | `number` | 60 seconds | How long an unsettled reservation is held (ms)
|
|
899
|
-
| `
|
|
900
|
-
| `
|
|
901
|
-
| `
|
|
902
|
-
| `
|
|
903
|
-
| `
|
|
904
|
-
| `
|
|
918
|
+
| `mode` | `"client" \| "server" \| "auto"` | `auto` | Where the credit hold lives; `auto` picks client when DataStream is enabled, server otherwise |
|
|
919
|
+
| `defaultReservationTTL` | `number` | 60 seconds | How long an unsettled reservation is held (ms) |
|
|
920
|
+
| `defaultLeaseDuration` | `number` | 5 minutes | (client mode) Lease lifetime (ms) |
|
|
921
|
+
| `defaultLeaseSize` | `number` | 10000 | (client mode) Credits requested per lease acquire or extend |
|
|
922
|
+
| `lowWaterMark` | `number` | 0.25 | (client mode) Extend in the background when the lease balance dips below this fraction |
|
|
923
|
+
| `sweepIntervalMs` | `number` | 1000 | (client mode) Sweep interval for expired reservations (ms) |
|
|
924
|
+
| `prewarmResolveTimeoutMs` | `number` | 5000 | (client mode) How long `prewarm()` waits for a freshly identified company to surface (ms) |
|
|
925
|
+
| `redisClient` | `RedisClient` | `dataStream.redisClient` | (client mode) Redis client for lease and reservation state |
|
|
926
|
+
| `redisKeyPrefix` | `string` | `dataStream.redisKeyPrefix` | (client mode) Key prefix for lease and reservation keys |
|
|
927
|
+
| `overrides` | `object` | — | (client mode) Per-credit-type overrides of the above, keyed by credit type ID |
|
|
905
928
|
|
|
906
929
|
## Testing
|
|
907
930
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
export interface AcquireCreditLeaseRequestBody {
|
|
10
10
|
companyId: string;
|
|
11
11
|
creditTypeId: string;
|
|
12
|
+
/** When the hold lapses if the lease is never released; defaults to five minutes from now and may be at most one hour out. The unspent hold is refunded on expiry */
|
|
12
13
|
expiresAt?: Date;
|
|
13
14
|
requestedAmount: number;
|
|
14
15
|
}
|
|
@@ -6,5 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export interface ExtendCreditLeaseRequestBody {
|
|
8
8
|
additionalAmount: number;
|
|
9
|
+
/** Pushes the lease's expiry out; may be at most one hour from now. Leave unset to keep the expiry the lease already has */
|
|
9
10
|
expiresAt?: Date;
|
|
11
|
+
/** A caller-chosen key for safe retries: a second request with the same key returns the lease as it stands instead of growing it again. Keys are unique per environment across every extend */
|
|
12
|
+
idempotencyKey?: string;
|
|
10
13
|
}
|
|
@@ -24,7 +24,11 @@ export interface CreateBillingLinkedPlanEntitlementRequestBody {
|
|
|
24
24
|
monthlyPriceTiers?: Schematic.CreatePriceTierRequestBody[];
|
|
25
25
|
monthlyUnitPrice?: number;
|
|
26
26
|
monthlyUnitPriceDecimal?: string;
|
|
27
|
+
/** How often overage charges are assessed and invoiced. Defaults to end_of_billing_period, where the billing provider aggregates usage over the subscription's own period and bills it at period end. Set to monthly or quarterly to have overage assessed each month or quarter and billed on its own invoice, which is the point of the setting on annual plans. A quarter charges each month's usage against that month's allowance. Only applies to overage price behavior. */
|
|
28
|
+
overageBillingCadence?: Schematic.BillingArrearsCadence;
|
|
27
29
|
overageBillingProductId?: string;
|
|
30
|
+
/** Which boundary closes a monthly or quarterly overage window: the subscription's own recurrence (billing_period_start) or the calendar month (month_end). Quarterly windows run in three-month blocks from the billing period start, held to the subscription's own period, or in calendar quarters at month_end. Only applies when overage_billing_cadence is monthly or quarterly, and must match metric_period_month_reset so each window closes when the allowance resets: billing_period_start for billing_cycle, month_end for first_of_month. Defaults to the anchor that matches the reset. */
|
|
31
|
+
overageInvoiceAnchor?: Schematic.BillingArrearsAnchor;
|
|
28
32
|
planId: string;
|
|
29
33
|
planVersionId?: string;
|
|
30
34
|
priceBehavior?: Schematic.EntitlementPriceBehavior;
|
package/dist/api/resources/entitlements/client/requests/CreatePlanEntitlementRequestBody.d.ts
CHANGED
|
@@ -20,7 +20,11 @@ export interface CreatePlanEntitlementRequestBody {
|
|
|
20
20
|
monthlyPriceTiers?: Schematic.CreatePriceTierRequestBody[];
|
|
21
21
|
monthlyUnitPrice?: number;
|
|
22
22
|
monthlyUnitPriceDecimal?: string;
|
|
23
|
+
/** How often overage charges are assessed and invoiced. Defaults to end_of_billing_period, where the billing provider aggregates usage over the subscription's own period and bills it at period end. Set to monthly or quarterly to have overage assessed each month or quarter and billed on its own invoice, which is the point of the setting on annual plans. A quarter charges each month's usage against that month's allowance. Only applies to overage price behavior. */
|
|
24
|
+
overageBillingCadence?: Schematic.BillingArrearsCadence;
|
|
23
25
|
overageBillingProductId?: string;
|
|
26
|
+
/** Which boundary closes a monthly or quarterly overage window: the subscription's own recurrence (billing_period_start) or the calendar month (month_end). Quarterly windows run in three-month blocks from the billing period start, held to the subscription's own period, or in calendar quarters at month_end. Only applies when overage_billing_cadence is monthly or quarterly, and must match metric_period_month_reset so each window closes when the allowance resets: billing_period_start for billing_cycle, month_end for first_of_month. Defaults to the anchor that matches the reset. */
|
|
27
|
+
overageInvoiceAnchor?: Schematic.BillingArrearsAnchor;
|
|
24
28
|
planId: string;
|
|
25
29
|
planVersionId?: string;
|
|
26
30
|
priceBehavior?: Schematic.EntitlementPriceBehavior;
|
package/dist/api/resources/entitlements/client/requests/UpdatePlanEntitlementRequestBody.d.ts
CHANGED
|
@@ -17,7 +17,11 @@ export interface UpdatePlanEntitlementRequestBody {
|
|
|
17
17
|
monthlyPriceTiers?: Schematic.CreatePriceTierRequestBody[];
|
|
18
18
|
monthlyUnitPrice?: number;
|
|
19
19
|
monthlyUnitPriceDecimal?: string;
|
|
20
|
+
/** How often overage charges are assessed and invoiced. Defaults to end_of_billing_period, where the billing provider aggregates usage over the subscription's own period and bills it at period end. Set to monthly or quarterly to have overage assessed each month or quarter and billed on its own invoice, which is the point of the setting on annual plans. A quarter charges each month's usage against that month's allowance. Only applies to overage price behavior. */
|
|
21
|
+
overageBillingCadence?: Schematic.BillingArrearsCadence;
|
|
20
22
|
overageBillingProductId?: string;
|
|
23
|
+
/** Which boundary closes a monthly or quarterly overage window: the subscription's own recurrence (billing_period_start) or the calendar month (month_end). Quarterly windows run in three-month blocks from the billing period start, held to the subscription's own period, or in calendar quarters at month_end. Only applies when overage_billing_cadence is monthly or quarterly, and must match metric_period_month_reset so each window closes when the allowance resets: billing_period_start for billing_cycle, month_end for first_of_month. Defaults to the anchor that matches the reset. */
|
|
24
|
+
overageInvoiceAnchor?: Schematic.BillingArrearsAnchor;
|
|
21
25
|
priceBehavior?: Schematic.EntitlementPriceBehavior;
|
|
22
26
|
/** Use MonthlyPriceTiers or YearlyPriceTiers instead */
|
|
23
27
|
priceTiers?: Schematic.CreatePriceTierRequestBody[];
|
|
@@ -7,9 +7,11 @@ export interface CheckAndReserveFlagRequestBody {
|
|
|
7
7
|
company?: Record<string, string>;
|
|
8
8
|
/** When the hold lapses if no track event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry */
|
|
9
9
|
expiresAt?: Date;
|
|
10
|
-
/**
|
|
10
|
+
/** A caller-chosen key for safe retries: a second request with the same key returns the original reservation instead of taking another hold */
|
|
11
|
+
idempotencyKey?: string;
|
|
12
|
+
/** Hypothetical usage to evaluate the flag against. When credit_cost names the entitlement's credit, that cost is what gets held; otherwise the hold is the entitlement's consumption rate times quantity, or, when quantity is omitted, times the usage stated here */
|
|
11
13
|
preflight?: Schematic.PreflightRequestBody;
|
|
12
|
-
/** Units of the feature the operation will consume
|
|
14
|
+
/** Units of the feature the operation will consume. Sets the hold size together with the entitlement's consumption rate, and is echoed back on the reservation for the settling track event. When it is omitted the units come from preflight.event_usage.quantity, if that event subtype is the entitlement's, else from preflight.usage, else 1 */
|
|
13
15
|
quantity?: number;
|
|
14
16
|
user?: Record<string, string>;
|
|
15
17
|
}
|
|
@@ -87,13 +87,14 @@ export declare class PlanmigrationsClient {
|
|
|
87
87
|
*
|
|
88
88
|
* @example
|
|
89
89
|
* await client.planmigrations.listMigrations({
|
|
90
|
+
* featureId: "feature_id",
|
|
90
91
|
* planVersionId: "plan_version_id",
|
|
91
92
|
* status: "cancelled",
|
|
92
93
|
* limit: 1000000,
|
|
93
94
|
* offset: 1000000
|
|
94
95
|
* })
|
|
95
96
|
*/
|
|
96
|
-
listMigrations(request
|
|
97
|
+
listMigrations(request?: Schematic.ListMigrationsRequest, requestOptions?: PlanmigrationsClient.RequestOptions): core.HttpResponsePromise<Schematic.ListMigrationsResponse>;
|
|
97
98
|
private __listMigrations;
|
|
98
99
|
/**
|
|
99
100
|
* @param {Schematic.CreateMigrationInput} request
|
|
@@ -202,13 +203,14 @@ export declare class PlanmigrationsClient {
|
|
|
202
203
|
*
|
|
203
204
|
* @example
|
|
204
205
|
* await client.planmigrations.countMigrations({
|
|
206
|
+
* featureId: "feature_id",
|
|
205
207
|
* planVersionId: "plan_version_id",
|
|
206
208
|
* status: "cancelled",
|
|
207
209
|
* limit: 1000000,
|
|
208
210
|
* offset: 1000000
|
|
209
211
|
* })
|
|
210
212
|
*/
|
|
211
|
-
countMigrations(request
|
|
213
|
+
countMigrations(request?: Schematic.CountMigrationsRequest, requestOptions?: PlanmigrationsClient.RequestOptions): core.HttpResponsePromise<Schematic.CountMigrationsResponse>;
|
|
212
214
|
private __countMigrations;
|
|
213
215
|
/**
|
|
214
216
|
* @param {Schematic.PreviewMigrationRequestBody} request
|
|
@@ -2,6 +2,7 @@ import type * as Schematic from "../../../../index";
|
|
|
2
2
|
/**
|
|
3
3
|
* @example
|
|
4
4
|
* {
|
|
5
|
+
* featureId: "feature_id",
|
|
5
6
|
* planVersionId: "plan_version_id",
|
|
6
7
|
* status: "cancelled",
|
|
7
8
|
* limit: 1000000,
|
|
@@ -9,7 +10,8 @@ import type * as Schematic from "../../../../index";
|
|
|
9
10
|
* }
|
|
10
11
|
*/
|
|
11
12
|
export interface CountMigrationsRequest {
|
|
12
|
-
|
|
13
|
+
featureId?: string;
|
|
14
|
+
planVersionId?: string;
|
|
13
15
|
status?: Schematic.PlanVersionMigrationStatus;
|
|
14
16
|
/** Page limit (default 100) */
|
|
15
17
|
limit?: number;
|
|
@@ -2,6 +2,7 @@ import type * as Schematic from "../../../../index";
|
|
|
2
2
|
/**
|
|
3
3
|
* @example
|
|
4
4
|
* {
|
|
5
|
+
* featureId: "feature_id",
|
|
5
6
|
* planVersionId: "plan_version_id",
|
|
6
7
|
* status: "cancelled",
|
|
7
8
|
* limit: 1000000,
|
|
@@ -9,7 +10,8 @@ import type * as Schematic from "../../../../index";
|
|
|
9
10
|
* }
|
|
10
11
|
*/
|
|
11
12
|
export interface ListMigrationsRequest {
|
|
12
|
-
|
|
13
|
+
featureId?: string;
|
|
14
|
+
planVersionId?: string;
|
|
13
15
|
status?: Schematic.PlanVersionMigrationStatus;
|
|
14
16
|
/** Page limit (default 100) */
|
|
15
17
|
limit?: number;
|
|
@@ -143,6 +143,8 @@ export declare class PlansClient {
|
|
|
143
143
|
* q: "q",
|
|
144
144
|
* scopedToCompanyId: "scoped_to_company_id",
|
|
145
145
|
* withEntitlements: true,
|
|
146
|
+
* withPublishedVersion: true,
|
|
147
|
+
* withoutEntitlementForIncludeDrafts: true,
|
|
146
148
|
* withoutEntitlementFor: "without_entitlement_for",
|
|
147
149
|
* withoutPaidProductId: true,
|
|
148
150
|
* limit: 1000000,
|
|
@@ -342,6 +344,8 @@ export declare class PlansClient {
|
|
|
342
344
|
* q: "q",
|
|
343
345
|
* scopedToCompanyId: "scoped_to_company_id",
|
|
344
346
|
* withEntitlements: true,
|
|
347
|
+
* withPublishedVersion: true,
|
|
348
|
+
* withoutEntitlementForIncludeDrafts: true,
|
|
345
349
|
* withoutEntitlementFor: "without_entitlement_for",
|
|
346
350
|
* withoutPaidProductId: true,
|
|
347
351
|
* limit: 1000000,
|
|
@@ -16,6 +16,8 @@ import type * as Schematic from "../../../../index";
|
|
|
16
16
|
* q: "q",
|
|
17
17
|
* scopedToCompanyId: "scoped_to_company_id",
|
|
18
18
|
* withEntitlements: true,
|
|
19
|
+
* withPublishedVersion: true,
|
|
20
|
+
* withoutEntitlementForIncludeDrafts: true,
|
|
19
21
|
* withoutEntitlementFor: "without_entitlement_for",
|
|
20
22
|
* withoutPaidProductId: true,
|
|
21
23
|
* limit: 1000000,
|
|
@@ -48,6 +50,10 @@ export interface CountPlansRequest {
|
|
|
48
50
|
scopedToCompanyId?: string;
|
|
49
51
|
/** Include each plan's entitlements in the response */
|
|
50
52
|
withEntitlements?: boolean;
|
|
53
|
+
/** Only return plans that have a published version */
|
|
54
|
+
withPublishedVersion?: boolean;
|
|
55
|
+
/** With without_entitlement_for, also treat an entitlement on a plan's draft version as existing */
|
|
56
|
+
withoutEntitlementForIncludeDrafts?: boolean;
|
|
51
57
|
/** Filter out plans that already have a plan entitlement for the specified feature ID */
|
|
52
58
|
withoutEntitlementFor?: string;
|
|
53
59
|
/** Filter out plans that have a paid billing product ID */
|
|
@@ -16,6 +16,8 @@ import type * as Schematic from "../../../../index";
|
|
|
16
16
|
* q: "q",
|
|
17
17
|
* scopedToCompanyId: "scoped_to_company_id",
|
|
18
18
|
* withEntitlements: true,
|
|
19
|
+
* withPublishedVersion: true,
|
|
20
|
+
* withoutEntitlementForIncludeDrafts: true,
|
|
19
21
|
* withoutEntitlementFor: "without_entitlement_for",
|
|
20
22
|
* withoutPaidProductId: true,
|
|
21
23
|
* limit: 1000000,
|
|
@@ -48,6 +50,10 @@ export interface ListPlansRequest {
|
|
|
48
50
|
scopedToCompanyId?: string;
|
|
49
51
|
/** Include each plan's entitlements in the response */
|
|
50
52
|
withEntitlements?: boolean;
|
|
53
|
+
/** Only return plans that have a published version */
|
|
54
|
+
withPublishedVersion?: boolean;
|
|
55
|
+
/** With without_entitlement_for, also treat an entitlement on a plan's draft version as existing */
|
|
56
|
+
withoutEntitlementForIncludeDrafts?: boolean;
|
|
51
57
|
/** Filter out plans that already have a plan entitlement for the specified feature ID */
|
|
52
58
|
withoutEntitlementFor?: string;
|
|
53
59
|
/** Filter out plans that have a paid billing product ID */
|
|
@@ -32,8 +32,12 @@ export interface CountPlansParams {
|
|
|
32
32
|
scopedToCompanyId?: string;
|
|
33
33
|
/** Include each plan's entitlements in the response */
|
|
34
34
|
withEntitlements?: boolean;
|
|
35
|
+
/** Only return plans that have a published version */
|
|
36
|
+
withPublishedVersion?: boolean;
|
|
35
37
|
/** Filter out plans that already have a plan entitlement for the specified feature ID */
|
|
36
38
|
withoutEntitlementFor?: string;
|
|
39
|
+
/** With without_entitlement_for, also treat an entitlement on a plan's draft version as existing */
|
|
40
|
+
withoutEntitlementForIncludeDrafts?: boolean;
|
|
37
41
|
/** Filter out plans that have a paid billing product ID */
|
|
38
42
|
withoutPaidProductId?: boolean;
|
|
39
43
|
}
|
|
@@ -32,8 +32,12 @@ export interface ListPlansParams {
|
|
|
32
32
|
scopedToCompanyId?: string;
|
|
33
33
|
/** Include each plan's entitlements in the response */
|
|
34
34
|
withEntitlements?: boolean;
|
|
35
|
+
/** Only return plans that have a published version */
|
|
36
|
+
withPublishedVersion?: boolean;
|
|
35
37
|
/** Filter out plans that already have a plan entitlement for the specified feature ID */
|
|
36
38
|
withoutEntitlementFor?: string;
|
|
39
|
+
/** With without_entitlement_for, also treat an entitlement on a plan's draft version as existing */
|
|
40
|
+
withoutEntitlementForIncludeDrafts?: boolean;
|
|
37
41
|
/** Filter out plans that have a paid billing product ID */
|
|
38
42
|
withoutPaidProductId?: boolean;
|
|
39
43
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const BillingArrearsCadence: {
|
|
2
2
|
readonly EndOfBillingPeriod: "end_of_billing_period";
|
|
3
3
|
readonly Monthly: "monthly";
|
|
4
|
+
readonly Quarterly: "quarterly";
|
|
4
5
|
};
|
|
5
6
|
export type BillingArrearsCadence = (typeof BillingArrearsCadence)[keyof typeof BillingArrearsCadence];
|
|
@@ -3,6 +3,9 @@ export declare const BillingCreditGrantReason: {
|
|
|
3
3
|
readonly BillingCreditAutoTopup: "billing_credit_auto_topup";
|
|
4
4
|
readonly Free: "free";
|
|
5
5
|
readonly Plan: "plan";
|
|
6
|
+
readonly PostpaidForgiven: "postpaid_forgiven";
|
|
7
|
+
readonly PostpaidOverdraft: "postpaid_overdraft";
|
|
8
|
+
readonly PostpaidSettlement: "postpaid_settlement";
|
|
6
9
|
readonly Purchased: "purchased";
|
|
7
10
|
readonly Rollover: "rollover";
|
|
8
11
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface BillingPlanCreditGrantPriceTierResponseData {
|
|
2
|
+
/** Lower bound of the tier, in credits per invoice (inclusive). */
|
|
3
|
+
from: number;
|
|
4
|
+
/** Price per credit in this tier, in the plan currency's smallest unit. */
|
|
5
|
+
perUnitPrice?: number;
|
|
6
|
+
/** Price per credit in this tier as a decimal, for rates below one cent. */
|
|
7
|
+
perUnitPriceDecimal?: string;
|
|
8
|
+
/** Upper bound of the tier, in credits per invoice (inclusive). Null marks the final, unbounded tier. */
|
|
9
|
+
to?: number;
|
|
10
|
+
}
|
|
@@ -16,6 +16,8 @@ export interface BillingPlanCreditGrantResponseData {
|
|
|
16
16
|
autoTopupSelfService: boolean;
|
|
17
17
|
autoTopupThresholdCredits?: number;
|
|
18
18
|
autoTopupThresholdPercent?: number;
|
|
19
|
+
/** Whether the credits are included in the plan price (granted) or billed as their own subscription line at a price per credit (billed). */
|
|
20
|
+
billingMode: Schematic.BillingPlanCreditGrantBillingMode;
|
|
19
21
|
/** Deprecated: bundle availability is a per-bundle plan compatibility set now; use compatible_plan_ids on credit bundles instead. */
|
|
20
22
|
canBuyBundles: boolean;
|
|
21
23
|
/** Credits granted once per company on top of the per-license amount. Always 0 when scaling is fixed. */
|
|
@@ -49,6 +51,10 @@ export interface BillingPlanCreditGrantResponseData {
|
|
|
49
51
|
postpaidRatePerUnit?: number;
|
|
50
52
|
/** Decimal form of postpaid_rate_per_unit, for rates finer than one minor unit. */
|
|
51
53
|
postpaidRatePerUnitDecimal?: string;
|
|
54
|
+
/** The Stripe price a billed grant bills through. Minted when the plan version is published. */
|
|
55
|
+
price?: Schematic.BillingPriceResponseData;
|
|
56
|
+
/** Tier table pricing the credits, cheapest bound first. Empty unless billing_mode is billed and the credits are priced on tiers. */
|
|
57
|
+
priceTiers: Schematic.BillingPlanCreditGrantPriceTierResponseData[];
|
|
52
58
|
resetCadence?: Schematic.BillingPlanCreditGrantResetCadence;
|
|
53
59
|
resetStart?: Schematic.BillingPlanCreditGrantResetStart;
|
|
54
60
|
resetType?: Schematic.BillingPlanCreditGrantResetType;
|
|
@@ -56,5 +62,11 @@ export interface BillingPlanCreditGrantResponseData {
|
|
|
56
62
|
rolloverPercentage: number;
|
|
57
63
|
/** Whether the grant is a fixed amount per company, or issued once per license the company holds. */
|
|
58
64
|
scaling: Schematic.PlanCreditGrantScaling;
|
|
65
|
+
/** How price_tiers apply: volume prices every credit at the rate of the tier the total lands in, graduated prices each tier's own credits at its own rate. Set only when price_tiers is non-empty. */
|
|
66
|
+
tierMode?: Schematic.BillingTiersMode;
|
|
67
|
+
/** Price per credit in the plan currency's smallest unit. Set only when billing_mode is billed and the credits are priced at one rate. */
|
|
68
|
+
unitPrice?: number;
|
|
69
|
+
/** Price per credit as a decimal in the plan currency's smallest unit. Set only when billing_mode is billed and the rate is below one cent. */
|
|
70
|
+
unitPriceDecimal?: string;
|
|
59
71
|
updatedAt: Date;
|
|
60
72
|
}
|
|
@@ -17,6 +17,8 @@ export interface CompanyPlanCreditGrantView {
|
|
|
17
17
|
billingCreditPostpaidEnabled: boolean;
|
|
18
18
|
billingCreditPostpaidRatePerUnit?: number;
|
|
19
19
|
billingCreditPostpaidRatePerUnitDecimal?: string;
|
|
20
|
+
billingMode: Schematic.BillingPlanCreditGrantBillingMode;
|
|
21
|
+
billingProductPriceId?: string;
|
|
20
22
|
companyAutoTopupAmount?: number;
|
|
21
23
|
companyAutoTopupEnabled?: boolean;
|
|
22
24
|
companyAutoTopupThresholdCredits?: number;
|
|
@@ -41,6 +43,7 @@ export interface CompanyPlanCreditGrantView {
|
|
|
41
43
|
planVersionId?: string;
|
|
42
44
|
/** Deprecated field, will be removed in the future. Use Credit.PluralName instead. */
|
|
43
45
|
pluralName?: string;
|
|
46
|
+
price?: Schematic.BillingPriceView;
|
|
44
47
|
resetCadence?: Schematic.BillingPlanCreditGrantResetCadence;
|
|
45
48
|
resetStart?: Schematic.BillingPlanCreditGrantResetStart;
|
|
46
49
|
resetType: Schematic.BillingPlanCreditGrantResetType;
|
|
@@ -3,7 +3,7 @@ export interface CreateBillingPlanCreditGrantRequestBody {
|
|
|
3
3
|
applyToExisting?: boolean;
|
|
4
4
|
/** Which boundary closes a monthly arrears window: the subscription's own recurrence (billing_period_start) or the calendar month (month_end). Only applies when arrears_cadence is monthly; defaults to billing_period_start. */
|
|
5
5
|
arrearsAnchor?: Schematic.BillingArrearsAnchor;
|
|
6
|
-
/** How often postpaid charges are closed and invoiced: end_of_billing_period (the default) or monthly. */
|
|
6
|
+
/** How often postpaid charges are closed and invoiced: end_of_billing_period (the default) or monthly. Quarterly is not available for postpaid charges. */
|
|
7
7
|
arrearsCadence?: Schematic.BillingArrearsCadence;
|
|
8
8
|
autoTopupAmount?: number;
|
|
9
9
|
autoTopupAmountType?: Schematic.CreditAutoTopupAmountType;
|
|
@@ -15,6 +15,8 @@ export interface CreateBillingPlanCreditGrantRequestBody {
|
|
|
15
15
|
autoTopupSelfService?: boolean;
|
|
16
16
|
autoTopupThresholdCredits?: number;
|
|
17
17
|
autoTopupThresholdPercent?: number;
|
|
18
|
+
/** Whether the credits are included in the plan price (granted) or billed as their own subscription line at a price per credit (billed). Billed is only available on custom plans. Defaults to granted. */
|
|
19
|
+
billingMode?: Schematic.BillingPlanCreditGrantBillingMode;
|
|
18
20
|
/** Deprecated: use compatible_plan_ids on credit bundles instead. Still accepted; writes through to the credit's bundle compatibility. */
|
|
19
21
|
canBuyBundles?: boolean;
|
|
20
22
|
/** Credits granted once per company on top of the per-license amount. Only valid when scaling is per_license. Defaults to 0. */
|
|
@@ -36,6 +38,8 @@ export interface CreateBillingPlanCreditGrantRequestBody {
|
|
|
36
38
|
postpaidRatePerUnit?: number;
|
|
37
39
|
/** Decimal string form of postpaid_rate_per_unit, for rates finer than one minor unit (for example 0.0002). Takes precedence over postpaid_rate_per_unit when both are set, matching how the credit's own price_per_unit_decimal behaves. */
|
|
38
40
|
postpaidRatePerUnitDecimal?: string;
|
|
41
|
+
/** Tier table pricing the credits on this grant, cheapest bound first, the last tier unbounded. Give this instead of unit_price to charge a rate that changes with the number of credits on the invoice. Requires tier_mode. */
|
|
42
|
+
priceTiers?: Schematic.CreditGrantPriceTierRequestBody[];
|
|
39
43
|
resetCadence: Schematic.BillingPlanCreditGrantResetCadence;
|
|
40
44
|
resetStart: Schematic.BillingPlanCreditGrantResetStart;
|
|
41
45
|
resetType?: Schematic.BillingPlanCreditGrantResetType;
|
|
@@ -43,4 +47,10 @@ export interface CreateBillingPlanCreditGrantRequestBody {
|
|
|
43
47
|
rolloverPercentage?: number;
|
|
44
48
|
/** Whether the grant is a fixed amount per company, or issued once per license the company holds. Defaults to fixed. */
|
|
45
49
|
scaling?: Schematic.PlanCreditGrantScaling;
|
|
50
|
+
/** How price_tiers apply: volume prices every credit at the rate of the tier the total lands in, graduated prices each tier's own credits at its own rate. Required with price_tiers. */
|
|
51
|
+
tierMode?: Schematic.BillingTiersMode;
|
|
52
|
+
/** Price per credit in the plan currency's smallest unit. Required when billing_mode is billed, unless unit_price_decimal or price_tiers is set. */
|
|
53
|
+
unitPrice?: number;
|
|
54
|
+
/** Price per credit as a decimal in the plan currency's smallest unit, for prices below one cent. */
|
|
55
|
+
unitPriceDecimal?: string;
|
|
46
56
|
}
|
|
@@ -12,7 +12,11 @@ export interface CreateEntitlementInBundleRequestBody {
|
|
|
12
12
|
monthlyPriceTiers?: Schematic.CreatePriceTierRequestBody[];
|
|
13
13
|
monthlyUnitPrice?: number;
|
|
14
14
|
monthlyUnitPriceDecimal?: string;
|
|
15
|
+
/** How often overage charges are assessed and invoiced. Defaults to end_of_billing_period, where the billing provider aggregates usage over the subscription's own period and bills it at period end. Set to monthly or quarterly to have overage assessed each month or quarter and billed on its own invoice, which is the point of the setting on annual plans. A quarter charges each month's usage against that month's allowance. Only applies to overage price behavior. */
|
|
16
|
+
overageBillingCadence?: Schematic.BillingArrearsCadence;
|
|
15
17
|
overageBillingProductId?: string;
|
|
18
|
+
/** Which boundary closes a monthly or quarterly overage window: the subscription's own recurrence (billing_period_start) or the calendar month (month_end). Quarterly windows run in three-month blocks from the billing period start, held to the subscription's own period, or in calendar quarters at month_end. Only applies when overage_billing_cadence is monthly or quarterly, and must match metric_period_month_reset so each window closes when the allowance resets: billing_period_start for billing_cycle, month_end for first_of_month. Defaults to the anchor that matches the reset. */
|
|
19
|
+
overageInvoiceAnchor?: Schematic.BillingArrearsAnchor;
|
|
16
20
|
planId: string;
|
|
17
21
|
planVersionId?: string;
|
|
18
22
|
priceBehavior?: Schematic.EntitlementPriceBehavior;
|
|
@@ -29,6 +29,7 @@ export interface CreditEventLedgerResponseData {
|
|
|
29
29
|
quantityRemainingAtZeroOut?: number;
|
|
30
30
|
sourceId: number;
|
|
31
31
|
toGrantId?: string;
|
|
32
|
+
transferReason?: Schematic.CreditTransferReason;
|
|
32
33
|
usageEventId?: string;
|
|
33
34
|
usageReason?: Schematic.CreditUsageReason;
|
|
34
35
|
zeroedOutReason?: Schematic.BillingCreditGrantZeroedOutReason;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface CreditGrantPriceTierRequestBody {
|
|
2
|
+
/** Price per credit in this tier, in the plan currency's smallest unit. */
|
|
3
|
+
perUnitPrice?: number;
|
|
4
|
+
/** Price per credit in this tier as a decimal in the plan currency's smallest unit, for prices below one cent. */
|
|
5
|
+
perUnitPriceDecimal?: string;
|
|
6
|
+
/** Inclusive upper bound of this tier, counted in credits per invoice. Null marks the final, unbounded tier. */
|
|
7
|
+
upTo?: number;
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const CreditTransferReason: {
|
|
2
|
+
readonly OverdraftRecovery: "overdraft_recovery";
|
|
3
|
+
readonly PostpaidDebtMoved: "postpaid_debt_moved";
|
|
4
|
+
readonly PostpaidForgiven: "postpaid_forgiven";
|
|
5
|
+
readonly PostpaidPaid: "postpaid_paid";
|
|
6
|
+
};
|
|
7
|
+
export type CreditTransferReason = (typeof CreditTransferReason)[keyof typeof CreditTransferReason];
|
|
@@ -17,6 +17,8 @@ export interface PlanCreditGrantView {
|
|
|
17
17
|
billingCreditPostpaidEnabled: boolean;
|
|
18
18
|
billingCreditPostpaidRatePerUnit?: number;
|
|
19
19
|
billingCreditPostpaidRatePerUnitDecimal?: string;
|
|
20
|
+
billingMode: Schematic.BillingPlanCreditGrantBillingMode;
|
|
21
|
+
billingProductPriceId?: string;
|
|
20
22
|
companyCreditAmount: number;
|
|
21
23
|
createdAt: Date;
|
|
22
24
|
credit?: Schematic.BillingCreditView;
|
|
@@ -38,6 +40,7 @@ export interface PlanCreditGrantView {
|
|
|
38
40
|
planVersionId?: string;
|
|
39
41
|
/** Deprecated field, will be removed in the future. Use Credit.PluralName instead. */
|
|
40
42
|
pluralName?: string;
|
|
43
|
+
price?: Schematic.BillingPriceView;
|
|
41
44
|
resetCadence?: Schematic.BillingPlanCreditGrantResetCadence;
|
|
42
45
|
resetStart?: Schematic.BillingPlanCreditGrantResetStart;
|
|
43
46
|
resetType: Schematic.BillingPlanCreditGrantResetType;
|
|
@@ -14,6 +14,10 @@ export interface PlanEntitlementResponseData {
|
|
|
14
14
|
meteredYearlyPrice?: Schematic.BillingPriceView;
|
|
15
15
|
metricPeriod?: Schematic.MetricPeriod;
|
|
16
16
|
metricPeriodMonthReset?: Schematic.MetricPeriodMonthReset;
|
|
17
|
+
/** How often overage charges are assessed and invoiced. Null or end_of_billing_period means the billing provider aggregates usage over the subscription's own period and bills it at period end. Monthly and quarterly mean Schematic assesses the overage each month or quarter and bills it on its own invoice. Only applies to overage price behavior. */
|
|
18
|
+
overageBillingCadence?: Schematic.BillingArrearsCadence;
|
|
19
|
+
/** Which boundary closes a monthly or quarterly overage window: the subscription's own recurrence (billing_period_start) or the calendar month (month_end), which for a quarterly window means calendar quarters. Only meaningful when overage_billing_cadence is monthly or quarterly. */
|
|
20
|
+
overageInvoiceAnchor?: Schematic.BillingArrearsAnchor;
|
|
17
21
|
plan?: Schematic.PlanResponseData;
|
|
18
22
|
planId: string;
|
|
19
23
|
priceBehavior?: Schematic.EntitlementPriceBehavior;
|