@schematichq/schematic-typescript-node 1.5.13 → 1.6.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 +49 -28
- package/dist/api/resources/credits/client/Client.d.ts +41 -5
- package/dist/api/resources/credits/client/requests/ReserveCreditsRequestBody.d.ts +18 -0
- package/dist/api/resources/credits/client/requests/index.d.ts +1 -0
- package/dist/api/resources/credits/types/ReleaseCreditReservationResponse.d.ts +6 -0
- package/dist/api/resources/credits/types/ReserveCreditsResponse.d.ts +6 -0
- package/dist/api/resources/credits/types/index.d.ts +2 -0
- package/dist/api/resources/features/client/Client.d.ts +18 -0
- package/dist/api/resources/features/client/requests/CheckAndReserveFlagRequestBody.d.ts +15 -0
- package/dist/api/resources/features/client/requests/index.d.ts +1 -0
- package/dist/api/resources/features/types/CheckAndReserveFlagResponse.d.ts +6 -0
- package/dist/api/resources/features/types/index.d.ts +1 -0
- 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/CheckAndReserveFlagResponseData.d.ts +35 -0
- package/dist/api/types/CreditReservationResponseData.d.ts +15 -0
- package/dist/api/types/CreditUsageReason.d.ts +2 -0
- package/dist/api/types/EventBodyTrack.d.ts +2 -0
- package/dist/api/types/EventDetailResponseData.d.ts +1 -0
- package/dist/api/types/EventResponseData.d.ts +1 -0
- package/dist/api/types/FlagCheckReservationResponseData.d.ts +15 -0
- package/dist/api/types/PlanVersionMigrationResponseData.d.ts +2 -0
- package/dist/api/types/index.d.ts +3 -1
- package/dist/credits/index.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 +36 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -9
- package/dist/serialization/resources/credits/client/requests/ReserveCreditsRequestBody.d.ts +13 -0
- package/dist/serialization/resources/credits/client/requests/index.d.ts +1 -0
- package/dist/serialization/resources/credits/types/ReleaseCreditReservationResponse.d.ts +11 -0
- package/dist/serialization/resources/credits/types/ReserveCreditsResponse.d.ts +11 -0
- package/dist/serialization/resources/credits/types/index.d.ts +2 -0
- package/dist/serialization/resources/features/client/requests/CheckAndReserveFlagRequestBody.d.ts +14 -0
- package/dist/serialization/resources/features/client/requests/index.d.ts +1 -0
- package/dist/serialization/resources/features/types/CheckAndReserveFlagResponse.d.ts +11 -0
- package/dist/serialization/resources/features/types/index.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/CheckAndReserveFlagResponseData.d.ts +28 -0
- package/dist/serialization/types/CreditReservationResponseData.d.ts +17 -0
- package/dist/serialization/types/CreditUsageReason.d.ts +1 -1
- package/dist/serialization/types/EventBodyTrack.d.ts +1 -0
- package/dist/serialization/types/EventDetailResponseData.d.ts +1 -0
- package/dist/serialization/types/EventResponseData.d.ts +1 -0
- package/dist/serialization/types/FlagCheckReservationResponseData.d.ts +16 -0
- package/dist/serialization/types/PlanVersionMigrationResponseData.d.ts +2 -0
- package/dist/serialization/types/index.d.ts +3 -1
- package/dist/wrapper.d.ts +41 -10
- package/package.json +9 -1
- package/dist/api/types/ReleaseCreditLeaseRequestBody.d.ts +0 -1
- package/dist/serialization/types/ReleaseCreditLeaseRequestBody.d.ts +0 -7
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:
|
|
838
836
|
|
|
839
|
-
|
|
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
|
+
```
|
|
845
|
+
|
|
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,11 @@ 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.
|
|
878
897
|
|
|
879
898
|
### Failure behavior
|
|
880
899
|
|
|
881
|
-
|
|
900
|
+
A check that cannot be gated (API unreachable, Redis down, lease exhausted) fails closed by default. Override per check:
|
|
882
901
|
|
|
883
902
|
```ts
|
|
884
903
|
const result = await client.check(evalCtx, "inference", {
|
|
@@ -888,20 +907,22 @@ const result = await client.check(evalCtx, "inference", {
|
|
|
888
907
|
});
|
|
889
908
|
```
|
|
890
909
|
|
|
891
|
-
`fail-open`
|
|
910
|
+
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
911
|
|
|
893
912
|
### Configuration options
|
|
894
913
|
|
|
895
914
|
| Option | Type | Default | Description |
|
|
896
915
|
|---|---|---|---|
|
|
897
|
-
| `
|
|
898
|
-
| `defaultReservationTTL` | `number` | 60 seconds | How long an unsettled reservation is held (ms)
|
|
899
|
-
| `
|
|
900
|
-
| `
|
|
901
|
-
| `
|
|
902
|
-
| `
|
|
903
|
-
| `
|
|
904
|
-
| `
|
|
916
|
+
| `mode` | `"client" \| "server" \| "auto"` | `auto` | Where the credit hold lives; `auto` picks client when DataStream is enabled, server otherwise |
|
|
917
|
+
| `defaultReservationTTL` | `number` | 60 seconds | How long an unsettled reservation is held (ms) |
|
|
918
|
+
| `defaultLeaseDuration` | `number` | 5 minutes | (client mode) Lease lifetime (ms) |
|
|
919
|
+
| `defaultLeaseSize` | `number` | 10000 | (client mode) Credits requested per lease acquire or extend |
|
|
920
|
+
| `lowWaterMark` | `number` | 0.25 | (client mode) Extend in the background when the lease balance dips below this fraction |
|
|
921
|
+
| `sweepIntervalMs` | `number` | 1000 | (client mode) Sweep interval for expired reservations (ms) |
|
|
922
|
+
| `prewarmResolveTimeoutMs` | `number` | 5000 | (client mode) How long `prewarm()` waits for a freshly identified company to surface (ms) |
|
|
923
|
+
| `redisClient` | `RedisClient` | `dataStream.redisClient` | (client mode) Redis client for lease and reservation state |
|
|
924
|
+
| `redisKeyPrefix` | `string` | `dataStream.redisKeyPrefix` | (client mode) Key prefix for lease and reservation keys |
|
|
925
|
+
| `overrides` | `object` | — | (client mode) Per-credit-type overrides of the above, keyed by credit type ID |
|
|
905
926
|
|
|
906
927
|
## Testing
|
|
907
928
|
|
|
@@ -447,7 +447,6 @@ export declare class CreditsClient {
|
|
|
447
447
|
private __extendCreditLease;
|
|
448
448
|
/**
|
|
449
449
|
* @param {string} lease_id - lease_id
|
|
450
|
-
* @param {Schematic.ReleaseCreditLeaseRequestBody} request
|
|
451
450
|
* @param {CreditsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
452
451
|
*
|
|
453
452
|
* @throws {@link Schematic.BadRequestError}
|
|
@@ -459,11 +458,9 @@ export declare class CreditsClient {
|
|
|
459
458
|
* @throws {@link errors.SchematicTimeoutError}
|
|
460
459
|
*
|
|
461
460
|
* @example
|
|
462
|
-
* await client.credits.releaseCreditLease("lease_id"
|
|
463
|
-
* "key": "value"
|
|
464
|
-
* })
|
|
461
|
+
* await client.credits.releaseCreditLease("lease_id")
|
|
465
462
|
*/
|
|
466
|
-
releaseCreditLease(lease_id: string,
|
|
463
|
+
releaseCreditLease(lease_id: string, requestOptions?: CreditsClient.RequestOptions): core.HttpResponsePromise<Schematic.ReleaseCreditLeaseResponse>;
|
|
467
464
|
private __releaseCreditLease;
|
|
468
465
|
/**
|
|
469
466
|
* @param {Schematic.ListBillingPlanCreditGrantsRequest} request
|
|
@@ -597,6 +594,45 @@ export declare class CreditsClient {
|
|
|
597
594
|
*/
|
|
598
595
|
countBillingPlanCreditGrants(request?: Schematic.CountBillingPlanCreditGrantsRequest, requestOptions?: CreditsClient.RequestOptions): core.HttpResponsePromise<Schematic.CountBillingPlanCreditGrantsResponse>;
|
|
599
596
|
private __countBillingPlanCreditGrants;
|
|
597
|
+
/**
|
|
598
|
+
* @param {Schematic.ReserveCreditsRequestBody} request
|
|
599
|
+
* @param {CreditsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
600
|
+
*
|
|
601
|
+
* @throws {@link Schematic.BadRequestError}
|
|
602
|
+
* @throws {@link Schematic.UnauthorizedError}
|
|
603
|
+
* @throws {@link Schematic.PaymentRequiredError}
|
|
604
|
+
* @throws {@link Schematic.ForbiddenError}
|
|
605
|
+
* @throws {@link Schematic.NotFoundError}
|
|
606
|
+
* @throws {@link Schematic.InternalServerError}
|
|
607
|
+
* @throws {@link errors.SchematicError}
|
|
608
|
+
* @throws {@link errors.SchematicTimeoutError}
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* await client.credits.reserveCredits({
|
|
612
|
+
* amount: 1.1,
|
|
613
|
+
* companyId: "company_id",
|
|
614
|
+
* creditTypeId: "credit_type_id"
|
|
615
|
+
* })
|
|
616
|
+
*/
|
|
617
|
+
reserveCredits(request: Schematic.ReserveCreditsRequestBody, requestOptions?: CreditsClient.RequestOptions): core.HttpResponsePromise<Schematic.ReserveCreditsResponse>;
|
|
618
|
+
private __reserveCredits;
|
|
619
|
+
/**
|
|
620
|
+
* @param {string} reservation_id - reservation_id
|
|
621
|
+
* @param {CreditsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
622
|
+
*
|
|
623
|
+
* @throws {@link Schematic.BadRequestError}
|
|
624
|
+
* @throws {@link Schematic.UnauthorizedError}
|
|
625
|
+
* @throws {@link Schematic.ForbiddenError}
|
|
626
|
+
* @throws {@link Schematic.NotFoundError}
|
|
627
|
+
* @throws {@link Schematic.InternalServerError}
|
|
628
|
+
* @throws {@link errors.SchematicError}
|
|
629
|
+
* @throws {@link errors.SchematicTimeoutError}
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* await client.credits.releaseCreditReservation("reservation_id")
|
|
633
|
+
*/
|
|
634
|
+
releaseCreditReservation(reservation_id: string, requestOptions?: CreditsClient.RequestOptions): core.HttpResponsePromise<Schematic.ReleaseCreditReservationResponse>;
|
|
635
|
+
private __releaseCreditReservation;
|
|
600
636
|
/**
|
|
601
637
|
* @param {Schematic.ListCreditSpendPoliciesRequest} request
|
|
602
638
|
* @param {CreditsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* amount: 1.1,
|
|
5
|
+
* companyId: "company_id",
|
|
6
|
+
* creditTypeId: "credit_type_id"
|
|
7
|
+
* }
|
|
8
|
+
*/
|
|
9
|
+
export interface ReserveCreditsRequestBody {
|
|
10
|
+
/** Credits to hold for the operation. The full amount must be available; a partial hold is never taken */
|
|
11
|
+
amount: number;
|
|
12
|
+
companyId: string;
|
|
13
|
+
creditTypeId: string;
|
|
14
|
+
/** 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 */
|
|
15
|
+
expiresAt?: Date;
|
|
16
|
+
/** A caller-chosen key for safe retries: a second request with the same key returns the original reservation instead of taking another hold */
|
|
17
|
+
idempotencyKey?: string;
|
|
18
|
+
}
|
|
@@ -20,6 +20,7 @@ export type { ListCreditBundlesRequest } from "./ListCreditBundlesRequest";
|
|
|
20
20
|
export type { ListCreditEventLedgerRequest } from "./ListCreditEventLedgerRequest";
|
|
21
21
|
export type { ListCreditSpendPoliciesRequest } from "./ListCreditSpendPoliciesRequest";
|
|
22
22
|
export type { ListGrantsForCreditRequest } from "./ListGrantsForCreditRequest";
|
|
23
|
+
export type { ReserveCreditsRequestBody } from "./ReserveCreditsRequestBody";
|
|
23
24
|
export type { UpdateBillingCreditRequestBody } from "./UpdateBillingCreditRequestBody";
|
|
24
25
|
export type { UpdateCreditBundleDetailsRequestBody } from "./UpdateCreditBundleDetailsRequestBody";
|
|
25
26
|
export type { UpdateCreditSpendPolicyRequestBody } from "./UpdateCreditSpendPolicyRequestBody";
|
|
@@ -44,6 +44,8 @@ export * from "./ListCreditSpendPoliciesResponse";
|
|
|
44
44
|
export * from "./ListGrantsForCreditParams";
|
|
45
45
|
export * from "./ListGrantsForCreditResponse";
|
|
46
46
|
export * from "./ReleaseCreditLeaseResponse";
|
|
47
|
+
export * from "./ReleaseCreditReservationResponse";
|
|
48
|
+
export * from "./ReserveCreditsResponse";
|
|
47
49
|
export * from "./SoftDeleteBillingCreditResponse";
|
|
48
50
|
export * from "./UpdateBillingCreditResponse";
|
|
49
51
|
export * from "./UpdateBillingPlanCreditGrantResponse";
|
|
@@ -318,6 +318,24 @@ export declare class FeaturesClient {
|
|
|
318
318
|
*/
|
|
319
319
|
checkFlag(key: string, request: Schematic.CheckFlagRequestBody, requestOptions?: FeaturesClient.RequestOptions): core.HttpResponsePromise<Schematic.CheckFlagResponse>;
|
|
320
320
|
private __checkFlag;
|
|
321
|
+
/**
|
|
322
|
+
* @param {string} key - key
|
|
323
|
+
* @param {Schematic.CheckAndReserveFlagRequestBody} request
|
|
324
|
+
* @param {FeaturesClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
325
|
+
*
|
|
326
|
+
* @throws {@link Schematic.BadRequestError}
|
|
327
|
+
* @throws {@link Schematic.UnauthorizedError}
|
|
328
|
+
* @throws {@link Schematic.ForbiddenError}
|
|
329
|
+
* @throws {@link Schematic.NotFoundError}
|
|
330
|
+
* @throws {@link Schematic.InternalServerError}
|
|
331
|
+
* @throws {@link errors.SchematicError}
|
|
332
|
+
* @throws {@link errors.SchematicTimeoutError}
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* await client.features.checkAndReserveFlag("key")
|
|
336
|
+
*/
|
|
337
|
+
checkAndReserveFlag(key: string, request?: Schematic.CheckAndReserveFlagRequestBody, requestOptions?: FeaturesClient.RequestOptions): core.HttpResponsePromise<Schematic.CheckAndReserveFlagResponse>;
|
|
338
|
+
private __checkAndReserveFlag;
|
|
321
339
|
/**
|
|
322
340
|
* @param {Schematic.CheckFlagRequestBody} request
|
|
323
341
|
* @param {FeaturesClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as Schematic from "../../../../index";
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* {}
|
|
5
|
+
*/
|
|
6
|
+
export interface CheckAndReserveFlagRequestBody {
|
|
7
|
+
company?: Record<string, string>;
|
|
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
|
+
expiresAt?: Date;
|
|
10
|
+
/** 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 quantity times the entitlement's consumption rate */
|
|
11
|
+
preflight?: Schematic.PreflightRequestBody;
|
|
12
|
+
/** Units of the feature the operation will consume; defaults to 1. Sets the hold size together with the entitlement's consumption rate, and is echoed back on the reservation for the settling track event */
|
|
13
|
+
quantity?: number;
|
|
14
|
+
user?: Record<string, string>;
|
|
15
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type { CheckAndReserveFlagRequestBody } from "./CheckAndReserveFlagRequestBody";
|
|
1
2
|
export type { CheckFlagsBulkRequestBody } from "./CheckFlagsBulkRequestBody";
|
|
2
3
|
export type { CountFeaturesRequest } from "./CountFeaturesRequest";
|
|
3
4
|
export type { CountFlagsRequest } from "./CountFlagsRequest";
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type * as Schematic from "../index";
|
|
2
|
+
export interface CheckAndReserveFlagResponseData {
|
|
3
|
+
/** If company keys were provided and matched a company, its ID */
|
|
4
|
+
companyId?: string;
|
|
5
|
+
/** If a feature entitlement rule was matched, its entitlement details */
|
|
6
|
+
entitlement?: Schematic.FeatureEntitlement;
|
|
7
|
+
/** If an error occurred while checking the flag, the error message */
|
|
8
|
+
error?: string;
|
|
9
|
+
/** Deprecated: Use Entitlement.Allocation instead. */
|
|
10
|
+
featureAllocation?: number;
|
|
11
|
+
/** Deprecated: Use Entitlement.Usage instead. */
|
|
12
|
+
featureUsage?: number;
|
|
13
|
+
/** Deprecated: Use Entitlement.EventName instead. */
|
|
14
|
+
featureUsageEvent?: string;
|
|
15
|
+
/** Deprecated: Use Entitlement.MetricPeriod instead. */
|
|
16
|
+
featureUsagePeriod?: Schematic.MetricPeriod;
|
|
17
|
+
/** Deprecated: Use Entitlement.MetricResetAt instead. */
|
|
18
|
+
featureUsageResetAt?: Date;
|
|
19
|
+
/** The key used to check the flag */
|
|
20
|
+
flag: string;
|
|
21
|
+
/** If a flag was found, its ID */
|
|
22
|
+
flagId?: string;
|
|
23
|
+
/** A human-readable explanation of the result */
|
|
24
|
+
reason: string;
|
|
25
|
+
/** The hold taken on the company's credit balance for this operation, when the flag allowed it and the feature is credit-metered. Settle it by sending a track event carrying its ID as reservation_id; the unspent hold is refunded at expires_at otherwise */
|
|
26
|
+
reservation?: Schematic.FlagCheckReservationResponseData;
|
|
27
|
+
/** If a rule was found, its ID */
|
|
28
|
+
ruleId?: string;
|
|
29
|
+
/** If a rule was found, its type */
|
|
30
|
+
ruleType?: Schematic.RuleType;
|
|
31
|
+
/** If user keys were provided and matched a user, its ID */
|
|
32
|
+
userId?: string;
|
|
33
|
+
/** A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted */
|
|
34
|
+
value: boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface CreditReservationResponseData {
|
|
2
|
+
companyId: string;
|
|
3
|
+
createdAt: Date;
|
|
4
|
+
creditTypeId: string;
|
|
5
|
+
/** When the unspent hold is refunded if no track event settles it */
|
|
6
|
+
expiresAt: Date;
|
|
7
|
+
id: string;
|
|
8
|
+
/** When the reservation was settled, released, or expired; null while the hold is open */
|
|
9
|
+
releasedAt?: Date;
|
|
10
|
+
/** Credits held from the company's balance for the operation */
|
|
11
|
+
reservedAmount: number;
|
|
12
|
+
/** Credits the settling track event recorded against the hold; zero until settled. May exceed reserved_amount, in which case the overage was debited from the balance, up to the overdraft limit when one is set */
|
|
13
|
+
settledAmount: number;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
}
|
|
@@ -3,6 +3,8 @@ export declare const CreditUsageReason: {
|
|
|
3
3
|
readonly LeaseRelease: "lease_release";
|
|
4
4
|
readonly ManualAdjustment: "manual_adjustment";
|
|
5
5
|
readonly Reconciliation: "reconciliation";
|
|
6
|
+
readonly ReservationHold: "reservation_hold";
|
|
7
|
+
readonly ReservationRelease: "reservation_release";
|
|
6
8
|
readonly Track: "track";
|
|
7
9
|
};
|
|
8
10
|
export type CreditUsageReason = (typeof CreditUsageReason)[keyof typeof CreditUsageReason];
|
|
@@ -7,6 +7,8 @@ export interface EventBodyTrack {
|
|
|
7
7
|
leaseId?: string;
|
|
8
8
|
/** Optionally specify the quantity of the event */
|
|
9
9
|
quantity?: number;
|
|
10
|
+
/** Credit reservation ID this track event settles. lease_id takes precedence when both are set */
|
|
11
|
+
reservationId?: string;
|
|
10
12
|
/** A map of trait names to trait values */
|
|
11
13
|
traits?: Record<string, unknown>;
|
|
12
14
|
/** Key-value pairs to identify user associated with track event */
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface FlagCheckReservationResponseData {
|
|
2
|
+
companyId: string;
|
|
3
|
+
/** Credits per unit of usage the hold was priced at */
|
|
4
|
+
consumptionRate: number;
|
|
5
|
+
creditTypeId: string;
|
|
6
|
+
/** Credits held from the company's balance */
|
|
7
|
+
creditsReserved: number;
|
|
8
|
+
/** The event subtype the settling track event should carry */
|
|
9
|
+
eventSubtype?: string;
|
|
10
|
+
/** When the unspent hold is refunded if no track event settles it */
|
|
11
|
+
expiresAt: Date;
|
|
12
|
+
id: string;
|
|
13
|
+
/** Units of usage the hold covers, as requested */
|
|
14
|
+
quantityReserved: number;
|
|
15
|
+
}
|