@schematichq/schematic-typescript-node 1.6.1 → 1.6.3
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 +2 -0
- package/dist/api/resources/billing/client/requests/CreateInvoiceRequestBody.d.ts +1 -0
- 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 +5 -1
- package/dist/api/resources/entitlements/client/requests/CreatePlanEntitlementRequestBody.d.ts +5 -1
- package/dist/api/resources/entitlements/client/requests/UpdatePlanEntitlementRequestBody.d.ts +5 -1
- package/dist/api/resources/features/client/requests/CheckAndReserveFlagRequestBody.d.ts +4 -2
- 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/ChangeSubscriptionInternalRequestBody.d.ts +2 -0
- package/dist/api/types/ChangeSubscriptionRequestBody.d.ts +2 -0
- package/dist/api/types/CompanyFeatureUsageExportMetadataVisibleColumnsItem.d.ts +1 -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 +5 -1
- package/dist/api/types/CreditEventLedgerResponseData.d.ts +2 -0
- package/dist/api/types/CreditGrantPriceTierRequestBody.d.ts +8 -0
- package/dist/api/types/CreditTransferReason.d.ts +7 -0
- package/dist/api/types/InvoiceRequestBody.d.ts +1 -0
- package/dist/api/types/InvoiceResponseData.d.ts +2 -0
- package/dist/api/types/ManagePlanRequest.d.ts +2 -0
- package/dist/api/types/PlanCreditGrantView.d.ts +3 -0
- package/dist/api/types/PlanEntitlementResponseData.d.ts +5 -1
- package/dist/api/types/PreviewSubscriptionFinanceResponseData.d.ts +2 -0
- package/dist/api/types/RulesengineComparableOperator.d.ts +11 -0
- package/dist/api/types/RulesengineCondition.d.ts +1 -1
- package/dist/api/types/UpcomingInvoiceResponseData.d.ts +2 -0
- package/dist/api/types/UpdateBillingPlanCreditGrantRequestBody.d.ts +11 -1
- package/dist/api/types/UsageBasedEntitlementRequestBody.d.ts +5 -1
- package/dist/api/types/UsageBasedEntitlementResponseData.d.ts +1 -1
- package/dist/api/types/index.d.ts +5 -0
- package/dist/cache/redis.d.ts +11 -0
- package/dist/credits/check.d.ts +10 -5
- package/dist/credits/index.d.ts +3 -3
- 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/types.d.ts +1 -0
- package/dist/index.js +12 -10
- package/dist/serialization/resources/billing/client/requests/CreateInvoiceRequestBody.d.ts +1 -0
- 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/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/ChangeSubscriptionInternalRequestBody.d.ts +1 -0
- package/dist/serialization/types/ChangeSubscriptionRequestBody.d.ts +1 -0
- package/dist/serialization/types/CompanyFeatureUsageExportMetadataVisibleColumnsItem.d.ts +1 -1
- 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 +3 -0
- package/dist/serialization/types/CreditGrantPriceTierRequestBody.d.ts +11 -0
- package/dist/serialization/types/CreditTransferReason.d.ts +7 -0
- package/dist/serialization/types/InvoiceRequestBody.d.ts +1 -0
- package/dist/serialization/types/InvoiceResponseData.d.ts +1 -0
- package/dist/serialization/types/ManagePlanRequest.d.ts +1 -0
- package/dist/serialization/types/PlanCreditGrantView.d.ts +5 -0
- package/dist/serialization/types/PlanEntitlementResponseData.d.ts +4 -0
- package/dist/serialization/types/PreviewSubscriptionFinanceResponseData.d.ts +1 -0
- package/dist/serialization/types/RulesengineComparableOperator.d.ts +7 -0
- package/dist/serialization/types/RulesengineCondition.d.ts +2 -2
- package/dist/serialization/types/UpcomingInvoiceResponseData.d.ts +1 -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 +5 -0
- package/dist/wasm/rulesengine.d.ts +1 -0
- package/dist/wasm/rulesengine.js +34 -4
- package/dist/wasm/rulesengine_bg.wasm.d.ts +2 -0
- package/dist/wrapper.d.ts +50 -16
- package/package.json +3 -3
|
@@ -5,6 +5,7 @@ export const __wbg_rulesenginejs_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const alloc: (a: number) => number;
|
|
6
6
|
export const checkFlag: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
7
7
|
export const checkFlagCombined: (a: number, b: number) => number;
|
|
8
|
+
export const checkFlagsCombined: (a: number, b: number) => number;
|
|
8
9
|
export const dealloc: (a: number, b: number) => void;
|
|
9
10
|
export const getCurrentMetricPeriodStartForCalendarMetricPeriod: (a: number) => bigint;
|
|
10
11
|
export const getCurrentMetricPeriodStartForCompanyBillingSubscription: (a: number, b: number) => bigint;
|
|
@@ -15,6 +16,7 @@ export const getResultJsonLength: () => number;
|
|
|
15
16
|
export const get_version_key_wasm: () => number;
|
|
16
17
|
export const rulesenginejs_checkFlag: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
|
|
17
18
|
export const rulesenginejs_checkFlagWithOptions: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number, number];
|
|
19
|
+
export const rulesenginejs_checkFlags: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
|
|
18
20
|
export const rulesenginejs_getVersionKey: (a: number) => [number, number];
|
|
19
21
|
export const rulesenginejs_new: () => number;
|
|
20
22
|
export const setCurrentTimeMillis: (a: bigint) => void;
|
package/dist/wrapper.d.ts
CHANGED
|
@@ -66,27 +66,40 @@ export interface SchematicOptions {
|
|
|
66
66
|
*/
|
|
67
67
|
creditLeases?: CreditLeaseConfig;
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Options for a single flag check.
|
|
71
|
+
*
|
|
72
|
+
* `creditCost`, `usage` and `eventUsage` are preflight inputs: they ask
|
|
73
|
+
* "would this action be allowed?" rather than "is it allowed now". They apply
|
|
74
|
+
* on every evaluation path, forwarded to the WASM rules engine's
|
|
75
|
+
* `checkFlagWithOptions` when the flag is evaluated locally (DataStream) and
|
|
76
|
+
* sent as the request body's `preflight` when it is evaluated over the REST
|
|
77
|
+
* API. The engine picks the most specific knob for each condition it
|
|
78
|
+
* evaluates. No reservation is issued; for lease-backed gating use `check()`.
|
|
79
|
+
*/
|
|
69
80
|
export interface CheckFlagOptions {
|
|
70
81
|
/** Default value to return on error. Can be a boolean or a function returning a boolean. If not provided, uses configured flag defaults */
|
|
71
82
|
defaultValue?: boolean | (() => boolean);
|
|
72
83
|
/** The maximum time to wait for a response in milliseconds */
|
|
73
84
|
timeoutMs?: number;
|
|
74
85
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* (DataStream); the REST fallback path does not support preflight and
|
|
79
|
-
* ignores these. No reservation is issued — for lease-backed gating use
|
|
80
|
-
* `check()` instead.
|
|
86
|
+
* Pre-computed cost of the action, keyed by credit id. Highest precedence
|
|
87
|
+
* for credit-balance gates. A cost of zero means the action is free, not
|
|
88
|
+
* that the input is absent.
|
|
81
89
|
*/
|
|
82
|
-
/** Pre-computed per-credit-id cost. Highest precedence for credit-balance gates. */
|
|
83
90
|
creditCost?: Record<string, number>;
|
|
84
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Quantity applied to whatever numeric condition is being evaluated. Zero
|
|
93
|
+
* has no effect. Both the REST request body and the local (WASM) engine
|
|
94
|
+
* take an integer, so a fraction rounds up rather than letting the check
|
|
95
|
+
* pass on less usage than the action is about to record.
|
|
96
|
+
*/
|
|
85
97
|
usage?: number;
|
|
86
98
|
/**
|
|
87
99
|
* Simulated quantity scoped to a specific event subtype. Preferred over
|
|
88
100
|
* `usage` when the subtype is known. Deliberately singular: one check
|
|
89
|
-
* preflights one action.
|
|
101
|
+
* preflights one action. `quantity` rounds up the same way `usage` does,
|
|
102
|
+
* and zero has no effect.
|
|
90
103
|
*/
|
|
91
104
|
eventUsage?: {
|
|
92
105
|
eventSubtype: string;
|
|
@@ -149,6 +162,8 @@ export declare class SchematicClient extends BaseClient {
|
|
|
149
162
|
private prewarmResolveTimeoutMs;
|
|
150
163
|
private creditLeaseMode?;
|
|
151
164
|
private serverReservationTTL;
|
|
165
|
+
private closing;
|
|
166
|
+
private readonly pendingPrewarms;
|
|
152
167
|
/**
|
|
153
168
|
* Creates a new instance of the SchematicClient
|
|
154
169
|
* @param opts - Configuration options for the client
|
|
@@ -222,6 +237,11 @@ export declare class SchematicClient extends BaseClient {
|
|
|
222
237
|
* are still drawing on — doing so would refund the grant server-side and
|
|
223
238
|
* pull the balance out from under them. Shared leases reclaim themselves:
|
|
224
239
|
* they expire (client- and server-side) or are fully consumed.
|
|
240
|
+
*
|
|
241
|
+
* Lease work already in flight is waited out before the release, so an
|
|
242
|
+
* acquire that lands mid-shutdown is one the release can see. The wait and
|
|
243
|
+
* the release share one `SHUTDOWN_DRAIN_TIMEOUT_MS` budget, so close()
|
|
244
|
+
* stays bounded however slow the store or the wire is.
|
|
225
245
|
* @returns Promise that resolves when everything has been stopped
|
|
226
246
|
*/
|
|
227
247
|
close(): Promise<void>;
|
|
@@ -239,10 +259,10 @@ export declare class SchematicClient extends BaseClient {
|
|
|
239
259
|
*/
|
|
240
260
|
prewarm(evalCtx: api.CheckFlagRequestBody, creditTypeIds: string[]): Promise<void>;
|
|
241
261
|
/**
|
|
242
|
-
* Like `resolveCompanyId` but
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* surfaced within `prewarmResolveTimeoutMs
|
|
262
|
+
* Like `resolveCompanyId` but, on a cache miss, actively fetches the
|
|
263
|
+
* company over the datastream, warming the cache as a side effect. Returns
|
|
264
|
+
* the resolved id, the `comp_`-prefixed id the keys carry if the company
|
|
265
|
+
* never surfaced within `prewarmResolveTimeoutMs`, or undefined.
|
|
246
266
|
*
|
|
247
267
|
* `identify` does not push a company into the datastream cache — companies
|
|
248
268
|
* are only streamed in response to a request. So we call `getCompany`
|
|
@@ -269,9 +289,8 @@ export declare class SchematicClient extends BaseClient {
|
|
|
269
289
|
* through to a plain flag check and returns `{allowed: value}` with no
|
|
270
290
|
* reservation, byte-compatible with `checkFlag` semantics. The caller's
|
|
271
291
|
* preflight (`usage` / `eventSubtype`) is still threaded through the plain
|
|
272
|
-
* check, so
|
|
273
|
-
*
|
|
274
|
-
* REST fallback ignores preflight.
|
|
292
|
+
* check, so every evaluation path (datastream, replicator, REST) gates on
|
|
293
|
+
* the post-call balance — just without a reservation.
|
|
275
294
|
*/
|
|
276
295
|
check(evalCtx: api.CheckFlagRequestBody, key: string, options?: CheckOptions): Promise<CheckResult>;
|
|
277
296
|
/**
|
|
@@ -301,6 +320,14 @@ export declare class SchematicClient extends BaseClient {
|
|
|
301
320
|
* event — across pods and process restarts, not just within one process.
|
|
302
321
|
*/
|
|
303
322
|
trackWithReservation(reservation: Reservation | undefined, actualQuantity: number, options?: TrackWithReservationOptions): Promise<void>;
|
|
323
|
+
/**
|
|
324
|
+
* The Schematic company id for an evaluation context, resolved in the
|
|
325
|
+
* server's order: every supplied key/value pair is an ordinary entity key
|
|
326
|
+
* and gets looked up first; only when nothing matches is a value read as
|
|
327
|
+
* the company's own id, by its `comp_` prefix rather than by the name of
|
|
328
|
+
* the key it sits under. An account is free to define a key called `id`
|
|
329
|
+
* holding its own identifier, so the name alone settles nothing.
|
|
330
|
+
*/
|
|
304
331
|
private resolveCompanyId;
|
|
305
332
|
/**
|
|
306
333
|
* Send a non-blocking event to create or update companies and users.
|
|
@@ -317,6 +344,13 @@ export declare class SchematicClient extends BaseClient {
|
|
|
317
344
|
* @throws Will log error if event enqueueing fails
|
|
318
345
|
*/
|
|
319
346
|
track(body: api.EventBodyTrack, options?: TrackOptions): Promise<void>;
|
|
347
|
+
/**
|
|
348
|
+
* Enqueue a track event, optimistically bumping the cached company metric
|
|
349
|
+
* with it unless `updateMetrics` says not to. The bump is a local
|
|
350
|
+
* prediction of what the stream will push back, so it belongs only to an
|
|
351
|
+
* event that records usage the server has not already counted.
|
|
352
|
+
*/
|
|
353
|
+
private emitTrack;
|
|
320
354
|
/**
|
|
321
355
|
* Sets the default value for a specific feature flag
|
|
322
356
|
* @param flag - The feature flag identifier
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematichq/schematic-typescript-node",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"resolutions": {
|
|
61
61
|
"sharp": "^0.35.4",
|
|
62
|
-
"undici": "7.29.
|
|
62
|
+
"undici": "7.29.1"
|
|
63
63
|
},
|
|
64
64
|
"packageManager": "yarn@1.22.22",
|
|
65
65
|
"engines": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"license": "MIT",
|
|
70
70
|
"resolutions": {
|
|
71
71
|
"sharp": "^0.35.4",
|
|
72
|
-
"undici": "7.29.
|
|
72
|
+
"undici": "7.29.1"
|
|
73
73
|
},
|
|
74
74
|
"files": [
|
|
75
75
|
"dist/**/*.js",
|