@schematichq/schematic-typescript-node 1.5.1 → 1.5.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/dist/api/resources/billing/client/Client.d.ts +47 -0
- package/dist/api/resources/billing/client/requests/ListBillingPricesRequest.d.ts +3 -0
- package/dist/api/resources/billing/client/requests/ListBillingProductPricesRequest.d.ts +3 -0
- package/dist/api/resources/billing/types/DeleteBillingCouponResponse.d.ts +6 -0
- package/dist/api/resources/billing/types/DeleteBillingCustomerResponse.d.ts +6 -0
- package/dist/api/resources/billing/types/DeleteBillingInvoiceResponse.d.ts +6 -0
- package/dist/api/resources/billing/types/ListBillingPricesParams.d.ts +2 -0
- package/dist/api/resources/billing/types/ListBillingProductPricesParams.d.ts +2 -0
- package/dist/api/resources/billing/types/index.d.ts +3 -0
- package/dist/api/resources/plans/client/Client.d.ts +1 -5
- package/dist/api/resources/plans/client/requests/PublishPlanVersionRequestBody.d.ts +1 -6
- package/dist/api/resources/webhooks/client/Client.d.ts +18 -0
- package/dist/api/resources/webhooks/client/requests/TestWebhookRequestBody.d.ts +10 -0
- package/dist/api/resources/webhooks/client/requests/index.d.ts +1 -0
- package/dist/api/resources/webhooks/types/SendTestWebhookActionResponse.d.ts +6 -0
- package/dist/api/resources/webhooks/types/index.d.ts +1 -0
- package/dist/api/types/AccountMemberPermission.d.ts +0 -1
- package/dist/api/types/CheckFlagsResponseData.d.ts +2 -0
- package/dist/api/types/CompanyCreditBalance.d.ts +8 -0
- package/dist/api/types/CompanySubscriptionResponseData.d.ts +1 -0
- package/dist/api/types/FeatureEntitlement.d.ts +4 -0
- package/dist/api/types/RulesengineFeatureEntitlement.d.ts +4 -0
- package/dist/api/types/TestWebhookResponseData.d.ts +4 -0
- package/dist/api/types/index.d.ts +2 -0
- package/dist/credits/check.d.ts +9 -5
- package/dist/credits/types.d.ts +11 -9
- package/dist/datastream/merge.d.ts +1 -1
- package/dist/index.js +9 -9
- package/dist/rules-engine.d.ts +4 -0
- package/dist/serialization/resources/billing/types/DeleteBillingCouponResponse.d.ts +11 -0
- package/dist/serialization/resources/billing/types/DeleteBillingCustomerResponse.d.ts +11 -0
- package/dist/serialization/resources/billing/types/DeleteBillingInvoiceResponse.d.ts +11 -0
- package/dist/serialization/resources/billing/types/ListBillingPricesParams.d.ts +1 -0
- package/dist/serialization/resources/billing/types/ListBillingProductPricesParams.d.ts +1 -0
- package/dist/serialization/resources/billing/types/index.d.ts +3 -0
- package/dist/serialization/resources/plans/client/requests/PublishPlanVersionRequestBody.d.ts +0 -2
- package/dist/serialization/resources/webhooks/client/requests/TestWebhookRequestBody.d.ts +10 -0
- package/dist/serialization/resources/webhooks/client/requests/index.d.ts +1 -0
- package/dist/serialization/resources/webhooks/types/SendTestWebhookActionResponse.d.ts +11 -0
- package/dist/serialization/resources/webhooks/types/index.d.ts +1 -0
- package/dist/serialization/types/AccountMemberPermission.d.ts +1 -1
- package/dist/serialization/types/CheckFlagsResponseData.d.ts +2 -0
- package/dist/serialization/types/CompanyCreditBalance.d.ts +11 -0
- package/dist/serialization/types/CompanySubscriptionResponseData.d.ts +1 -0
- package/dist/serialization/types/FeatureEntitlement.d.ts +2 -0
- package/dist/serialization/types/RulesengineFeatureEntitlement.d.ts +2 -0
- package/dist/serialization/types/TestWebhookResponseData.d.ts +10 -0
- package/dist/serialization/types/index.d.ts +2 -0
- package/dist/wasm/rulesengine.js +4 -4
- package/dist/wrapper.d.ts +0 -30
- package/package.json +1 -1
|
@@ -54,6 +54,36 @@ export declare class BillingClient {
|
|
|
54
54
|
*/
|
|
55
55
|
upsertBillingCoupon(request: Schematic.CreateCouponRequestBody, requestOptions?: BillingClient.RequestOptions): core.HttpResponsePromise<Schematic.UpsertBillingCouponResponse>;
|
|
56
56
|
private __upsertBillingCoupon;
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} billing_id - billing_id
|
|
59
|
+
* @param {BillingClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
60
|
+
*
|
|
61
|
+
* @throws {@link Schematic.BadRequestError}
|
|
62
|
+
* @throws {@link Schematic.UnauthorizedError}
|
|
63
|
+
* @throws {@link Schematic.ForbiddenError}
|
|
64
|
+
* @throws {@link Schematic.NotFoundError}
|
|
65
|
+
* @throws {@link Schematic.InternalServerError}
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* await client.billing.deleteBillingCoupon("billing_id")
|
|
69
|
+
*/
|
|
70
|
+
deleteBillingCoupon(billing_id: string, requestOptions?: BillingClient.RequestOptions): core.HttpResponsePromise<Schematic.DeleteBillingCouponResponse>;
|
|
71
|
+
private __deleteBillingCoupon;
|
|
72
|
+
/**
|
|
73
|
+
* @param {string} billing_id - billing_id
|
|
74
|
+
* @param {BillingClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
75
|
+
*
|
|
76
|
+
* @throws {@link Schematic.BadRequestError}
|
|
77
|
+
* @throws {@link Schematic.UnauthorizedError}
|
|
78
|
+
* @throws {@link Schematic.ForbiddenError}
|
|
79
|
+
* @throws {@link Schematic.NotFoundError}
|
|
80
|
+
* @throws {@link Schematic.InternalServerError}
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* await client.billing.deleteBillingCustomer("billing_id")
|
|
84
|
+
*/
|
|
85
|
+
deleteBillingCustomer(billing_id: string, requestOptions?: BillingClient.RequestOptions): core.HttpResponsePromise<Schematic.DeleteBillingCustomerResponse>;
|
|
86
|
+
private __deleteBillingCustomer;
|
|
57
87
|
/**
|
|
58
88
|
* @param {Schematic.CreateBillingCustomerRequestBody} request
|
|
59
89
|
* @param {BillingClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -164,6 +194,21 @@ export declare class BillingClient {
|
|
|
164
194
|
*/
|
|
165
195
|
upsertInvoice(request: Schematic.CreateInvoiceRequestBody, requestOptions?: BillingClient.RequestOptions): core.HttpResponsePromise<Schematic.UpsertInvoiceResponse>;
|
|
166
196
|
private __upsertInvoice;
|
|
197
|
+
/**
|
|
198
|
+
* @param {string} billing_id - billing_id
|
|
199
|
+
* @param {BillingClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
200
|
+
*
|
|
201
|
+
* @throws {@link Schematic.BadRequestError}
|
|
202
|
+
* @throws {@link Schematic.UnauthorizedError}
|
|
203
|
+
* @throws {@link Schematic.ForbiddenError}
|
|
204
|
+
* @throws {@link Schematic.NotFoundError}
|
|
205
|
+
* @throws {@link Schematic.InternalServerError}
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* await client.billing.deleteBillingInvoice("billing_id")
|
|
209
|
+
*/
|
|
210
|
+
deleteBillingInvoice(billing_id: string, requestOptions?: BillingClient.RequestOptions): core.HttpResponsePromise<Schematic.DeleteBillingInvoiceResponse>;
|
|
211
|
+
private __deleteBillingInvoice;
|
|
167
212
|
/**
|
|
168
213
|
* @param {Schematic.ListMetersRequest} request
|
|
169
214
|
* @param {BillingClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -275,6 +320,7 @@ export declare class BillingClient {
|
|
|
275
320
|
* ids: ["ids"],
|
|
276
321
|
* interval: "interval",
|
|
277
322
|
* isActive: true,
|
|
323
|
+
* planVersionId: "plan_version_id",
|
|
278
324
|
* price: 1000000,
|
|
279
325
|
* productId: "product_id",
|
|
280
326
|
* productIds: ["product_ids"],
|
|
@@ -350,6 +396,7 @@ export declare class BillingClient {
|
|
|
350
396
|
* ids: ["ids"],
|
|
351
397
|
* interval: "interval",
|
|
352
398
|
* isActive: true,
|
|
399
|
+
* planVersionId: "plan_version_id",
|
|
353
400
|
* price: 1000000,
|
|
354
401
|
* productId: "product_id",
|
|
355
402
|
* productIds: ["product_ids"],
|
|
@@ -8,6 +8,7 @@ import type * as Schematic from "../../../../index";
|
|
|
8
8
|
* ids: ["ids"],
|
|
9
9
|
* interval: "interval",
|
|
10
10
|
* isActive: true,
|
|
11
|
+
* planVersionId: "plan_version_id",
|
|
11
12
|
* price: 1000000,
|
|
12
13
|
* productId: "product_id",
|
|
13
14
|
* productIds: ["product_ids"],
|
|
@@ -31,6 +32,8 @@ export interface ListBillingPricesRequest {
|
|
|
31
32
|
interval?: string;
|
|
32
33
|
/** Filter for active prices on active products (defaults to true if not specified) */
|
|
33
34
|
isActive?: boolean;
|
|
35
|
+
/** Filter for prices belonging to a specific plan version (e.g. the latest published version) */
|
|
36
|
+
planVersionId?: string;
|
|
34
37
|
price?: number;
|
|
35
38
|
productId?: string;
|
|
36
39
|
productIds?: string | string[];
|
|
@@ -8,6 +8,7 @@ import type * as Schematic from "../../../../index";
|
|
|
8
8
|
* ids: ["ids"],
|
|
9
9
|
* interval: "interval",
|
|
10
10
|
* isActive: true,
|
|
11
|
+
* planVersionId: "plan_version_id",
|
|
11
12
|
* price: 1000000,
|
|
12
13
|
* productId: "product_id",
|
|
13
14
|
* productIds: ["product_ids"],
|
|
@@ -31,6 +32,8 @@ export interface ListBillingProductPricesRequest {
|
|
|
31
32
|
interval?: string;
|
|
32
33
|
/** Filter for active prices on active products (defaults to true if not specified) */
|
|
33
34
|
isActive?: boolean;
|
|
35
|
+
/** Filter for prices belonging to a specific plan version (e.g. the latest published version) */
|
|
36
|
+
planVersionId?: string;
|
|
34
37
|
price?: number;
|
|
35
38
|
productId?: string;
|
|
36
39
|
productIds?: string | string[];
|
|
@@ -17,6 +17,8 @@ export interface ListBillingPricesParams {
|
|
|
17
17
|
limit?: number;
|
|
18
18
|
/** Page offset (default 0) */
|
|
19
19
|
offset?: number;
|
|
20
|
+
/** Filter for prices belonging to a specific plan version (e.g. the latest published version) */
|
|
21
|
+
planVersionId?: string;
|
|
20
22
|
price?: number;
|
|
21
23
|
productId?: string;
|
|
22
24
|
productIds?: string[];
|
|
@@ -17,6 +17,8 @@ export interface ListBillingProductPricesParams {
|
|
|
17
17
|
limit?: number;
|
|
18
18
|
/** Page offset (default 0) */
|
|
19
19
|
offset?: number;
|
|
20
|
+
/** Filter for prices belonging to a specific plan version (e.g. the latest published version) */
|
|
21
|
+
planVersionId?: string;
|
|
20
22
|
price?: number;
|
|
21
23
|
productId?: string;
|
|
22
24
|
productIds?: string[];
|
|
@@ -2,6 +2,9 @@ export * from "./CountBillingProductsParams";
|
|
|
2
2
|
export * from "./CountBillingProductsResponse";
|
|
3
3
|
export * from "./CountCustomersParams";
|
|
4
4
|
export * from "./CountCustomersResponse";
|
|
5
|
+
export * from "./DeleteBillingCouponResponse";
|
|
6
|
+
export * from "./DeleteBillingCustomerResponse";
|
|
7
|
+
export * from "./DeleteBillingInvoiceResponse";
|
|
5
8
|
export * from "./DeleteBillingProductResponse";
|
|
6
9
|
export * from "./DeletePaymentMethodByExternalIdResponse";
|
|
7
10
|
export * from "./DeleteProductPriceResponse";
|
|
@@ -370,11 +370,7 @@ export declare class PlansClient {
|
|
|
370
370
|
* @example
|
|
371
371
|
* await client.plans.publishPlanVersion("plan_id", {
|
|
372
372
|
* excludedCompanyIds: ["excluded_company_ids"],
|
|
373
|
-
* migrationStrategy: "immediate"
|
|
374
|
-
* payInAdvance: [{
|
|
375
|
-
* priceId: "price_id",
|
|
376
|
-
* quantity: 1000000
|
|
377
|
-
* }]
|
|
373
|
+
* migrationStrategy: "immediate"
|
|
378
374
|
* })
|
|
379
375
|
*/
|
|
380
376
|
publishPlanVersion(plan_id: string, request: Schematic.PublishPlanVersionRequestBody, requestOptions?: PlansClient.RequestOptions): core.HttpResponsePromise<Schematic.PublishPlanVersionResponse>;
|
|
@@ -3,11 +3,7 @@ import type * as Schematic from "../../../../index";
|
|
|
3
3
|
* @example
|
|
4
4
|
* {
|
|
5
5
|
* excludedCompanyIds: ["excluded_company_ids"],
|
|
6
|
-
* migrationStrategy: "immediate"
|
|
7
|
-
* payInAdvance: [{
|
|
8
|
-
* priceId: "price_id",
|
|
9
|
-
* quantity: 1000000
|
|
10
|
-
* }]
|
|
6
|
+
* migrationStrategy: "immediate"
|
|
11
7
|
* }
|
|
12
8
|
*/
|
|
13
9
|
export interface PublishPlanVersionRequestBody {
|
|
@@ -16,5 +12,4 @@ export interface PublishPlanVersionRequestBody {
|
|
|
16
12
|
daysUntilDue?: number;
|
|
17
13
|
excludedCompanyIds: string[];
|
|
18
14
|
migrationStrategy: Schematic.PlanVersionMigrationStrategy;
|
|
19
|
-
payInAdvance: Schematic.UpdatePayInAdvanceRequestBody[];
|
|
20
15
|
}
|
|
@@ -149,6 +149,24 @@ export declare class WebhooksClient {
|
|
|
149
149
|
*/
|
|
150
150
|
deleteWebhook(webhook_id: string, requestOptions?: WebhooksClient.RequestOptions): core.HttpResponsePromise<Schematic.DeleteWebhookResponse>;
|
|
151
151
|
private __deleteWebhook;
|
|
152
|
+
/**
|
|
153
|
+
* @param {string} webhook_id - webhook_id
|
|
154
|
+
* @param {Schematic.TestWebhookRequestBody} request
|
|
155
|
+
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
156
|
+
*
|
|
157
|
+
* @throws {@link Schematic.BadRequestError}
|
|
158
|
+
* @throws {@link Schematic.UnauthorizedError}
|
|
159
|
+
* @throws {@link Schematic.ForbiddenError}
|
|
160
|
+
* @throws {@link Schematic.NotFoundError}
|
|
161
|
+
* @throws {@link Schematic.InternalServerError}
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* await client.webhooks.sendTestWebhookAction("webhook_id", {
|
|
165
|
+
* requestType: "subscription.trial.ended"
|
|
166
|
+
* })
|
|
167
|
+
*/
|
|
168
|
+
sendTestWebhookAction(webhook_id: string, request: Schematic.TestWebhookRequestBody, requestOptions?: WebhooksClient.RequestOptions): core.HttpResponsePromise<Schematic.SendTestWebhookActionResponse>;
|
|
169
|
+
private __sendTestWebhookAction;
|
|
152
170
|
/**
|
|
153
171
|
* @param {Schematic.CountWebhooksRequest} request
|
|
154
172
|
* @param {WebhooksClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
@@ -3,4 +3,5 @@ export type { CountWebhooksRequest } from "./CountWebhooksRequest";
|
|
|
3
3
|
export type { CreateWebhookRequestBody } from "./CreateWebhookRequestBody";
|
|
4
4
|
export type { ListWebhookEventsRequest } from "./ListWebhookEventsRequest";
|
|
5
5
|
export type { ListWebhooksRequest } from "./ListWebhooksRequest";
|
|
6
|
+
export type { TestWebhookRequestBody } from "./TestWebhookRequestBody";
|
|
6
7
|
export type { UpdateWebhookRequestBody } from "./UpdateWebhookRequestBody";
|
|
@@ -10,4 +10,5 @@ export * from "./ListWebhookEventsParams";
|
|
|
10
10
|
export * from "./ListWebhookEventsResponse";
|
|
11
11
|
export * from "./ListWebhooksParams";
|
|
12
12
|
export * from "./ListWebhooksResponse";
|
|
13
|
+
export * from "./SendTestWebhookActionResponse";
|
|
13
14
|
export * from "./UpdateWebhookResponse";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type * as Schematic from "../index";
|
|
2
2
|
export interface CheckFlagsResponseData {
|
|
3
|
+
/** Lease-aware credit balances keyed by credit ID, covering every credit type the company holds a balance in */
|
|
4
|
+
creditBalances?: Record<string, Schematic.CompanyCreditBalance>;
|
|
3
5
|
flags: Schematic.CheckFlagResponseData[];
|
|
4
6
|
plan?: Schematic.DatastreamCompanyPlan;
|
|
5
7
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface CompanyCreditBalance {
|
|
2
|
+
/** Remaining credit, excluding any open lease hold (the value SDKs gate on) */
|
|
3
|
+
remaining: number;
|
|
4
|
+
/** Amount held by the company's open credit lease, 0 when none is open */
|
|
5
|
+
reserved: number;
|
|
6
|
+
/** Spendable balance including the open lease hold (remaining + reserved) */
|
|
7
|
+
settled: number;
|
|
8
|
+
}
|
|
@@ -7,6 +7,7 @@ export interface CompanySubscriptionResponseData {
|
|
|
7
7
|
discounts: Schematic.BillingSubscriptionDiscountView[];
|
|
8
8
|
expiredAt?: Date;
|
|
9
9
|
interval: string;
|
|
10
|
+
isInitial: boolean;
|
|
10
11
|
latestInvoice?: Schematic.InvoiceResponseData;
|
|
11
12
|
paymentMethod?: Schematic.PaymentMethodResponseData;
|
|
12
13
|
products: Schematic.BillingProductForSubscriptionResponseData[];
|
|
@@ -2,6 +2,8 @@ import type * as Schematic from "../index";
|
|
|
2
2
|
export interface FeatureEntitlement {
|
|
3
3
|
/** If the company has a numeric entitlement for this feature, the allocated amount */
|
|
4
4
|
allocation?: number;
|
|
5
|
+
/** If the company has a credit-based entitlement for this feature, the credit cost per unit of usage */
|
|
6
|
+
consumptionRate?: number;
|
|
5
7
|
/** If the company has a credit-based entitlement for this feature, the ID of the credit */
|
|
6
8
|
creditId?: string;
|
|
7
9
|
/** If the company has a credit-based entitlement for this feature, the credit available to fund new consumption or a new lease hold — open lease holds are excluded. Clients that hold a lease should gate on this plus their own unspent hold; clients with no lease awareness should use credit_settled instead */
|
|
@@ -16,6 +18,8 @@ export interface FeatureEntitlement {
|
|
|
16
18
|
creditUsed?: number;
|
|
17
19
|
/** If the feature is event-based, the name of the event tracked for usage */
|
|
18
20
|
eventName?: string;
|
|
21
|
+
/** For event-based or credit-metered feature entitlements, the event subtype whose usage is tracked */
|
|
22
|
+
eventSubtype?: string;
|
|
19
23
|
/** The ID of the feature */
|
|
20
24
|
featureId: string;
|
|
21
25
|
/** The key of the flag associated with the feature */
|
|
@@ -2,6 +2,8 @@ import type * as Schematic from "../index";
|
|
|
2
2
|
export interface RulesengineFeatureEntitlement {
|
|
3
3
|
/** If the company has a numeric entitlement for this feature, the allocated amount */
|
|
4
4
|
allocation?: number;
|
|
5
|
+
/** If the company has a credit-based entitlement for this feature, the credit cost per unit of usage */
|
|
6
|
+
consumptionRate?: number;
|
|
5
7
|
/** If the company has a credit-based entitlement for this feature, the ID of the credit */
|
|
6
8
|
creditId?: string;
|
|
7
9
|
/** If the company has a credit-based entitlement for this feature, the credit available to fund new consumption or a new lease hold — open lease holds are excluded. Clients that hold a lease should gate on this plus their own unspent hold; clients with no lease awareness should use credit_settled instead */
|
|
@@ -16,6 +18,8 @@ export interface RulesengineFeatureEntitlement {
|
|
|
16
18
|
creditUsed?: number;
|
|
17
19
|
/** If the feature is event-based, the name of the event tracked for usage */
|
|
18
20
|
eventName?: string;
|
|
21
|
+
/** For event-based or credit-metered feature entitlements, the event subtype whose usage is tracked */
|
|
22
|
+
eventSubtype?: string;
|
|
19
23
|
/** The ID of the feature */
|
|
20
24
|
featureId: string;
|
|
21
25
|
/** The key of the flag associated with the feature */
|
|
@@ -73,6 +73,7 @@ export * from "./CheckoutFieldWithValue";
|
|
|
73
73
|
export * from "./CheckoutSettingsResponseData";
|
|
74
74
|
export * from "./CheckoutSubscription";
|
|
75
75
|
export * from "./ClerkIntegrationConfig";
|
|
76
|
+
export * from "./CompanyCreditBalance";
|
|
76
77
|
export * from "./CompanyCreditBalanceResponseData";
|
|
77
78
|
export * from "./CompanyDetailResponseData";
|
|
78
79
|
export * from "./CompanyEventPeriodMetricsResponseData";
|
|
@@ -339,6 +340,7 @@ export * from "./SubscriptionTraitUpdate";
|
|
|
339
340
|
export * from "./SubscriptionType";
|
|
340
341
|
export * from "./TemporaryAccessTokenResourceType";
|
|
341
342
|
export * from "./TemporaryAccessTokenResponseData";
|
|
343
|
+
export * from "./TestWebhookResponseData";
|
|
342
344
|
export * from "./TimeSeriesGranularity";
|
|
343
345
|
export * from "./TopFeatureByUsageResponseData";
|
|
344
346
|
export * from "./TopFeaturesByUsageResponseData";
|
package/dist/credits/check.d.ts
CHANGED
|
@@ -26,15 +26,19 @@ export interface CreditCheckDeps {
|
|
|
26
26
|
* Drives a single `client.check` with `usage` set.
|
|
27
27
|
*
|
|
28
28
|
* Steps:
|
|
29
|
-
* 1.
|
|
30
|
-
*
|
|
29
|
+
* 1. Probe the engine once (real balance, no preflight, no substitution) and
|
|
30
|
+
* read the matched plan entitlement. If it isn't credit-metered
|
|
31
|
+
* (`valueType != credit` — boolean/override grant, numeric allocation,
|
|
32
|
+
* unlimited, or not entitled) there's nothing to lease: defer to the plain
|
|
33
|
+
* check. Otherwise `creditId` + `consumptionRate` + `eventSubtype` come
|
|
34
|
+
* straight off the entitlement — no structural flag scan.
|
|
31
35
|
* 2. Acquire (or reuse) a lease for `(company, creditId)`.
|
|
32
36
|
* 3. Try to reserve `quantity × consumptionRate` from the lease.
|
|
33
37
|
* 4. Run the WASM rules engine against a substituted company snapshot
|
|
34
38
|
* (`credit_balances[creditId] = lease.localRemaining` *before* the
|
|
35
|
-
* reservation we just made was debited),
|
|
36
|
-
*
|
|
37
|
-
*
|
|
39
|
+
* reservation we just made was debited), gating with `credit_cost` so the
|
|
40
|
+
* engine evaluates the post-call balance. The reservation we made in step 3
|
|
41
|
+
* only sticks if the engine says allowed.
|
|
38
42
|
*/
|
|
39
43
|
export declare function checkWithLease(deps: CreditCheckDeps, key: string, evalCtx: api.CheckFlagRequestBody, options: CheckOptions, fallback: () => Promise<CheckResult>): Promise<CheckResult>;
|
|
40
44
|
/**
|
package/dist/credits/types.d.ts
CHANGED
|
@@ -150,15 +150,17 @@ export interface CheckResult {
|
|
|
150
150
|
/**
|
|
151
151
|
* Entitlement payload from the check.
|
|
152
152
|
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
153
|
+
* For a credit-metered feature the entitlement carries the lease-aware
|
|
154
|
+
* three-way split the server computes: `creditRemaining` (drawable now, open
|
|
155
|
+
* lease holds excluded), `creditReserved` (the open lease's unspent hold),
|
|
156
|
+
* and `creditSettled` (`creditRemaining + creditReserved` = the balance net
|
|
157
|
+
* of actual consumption). Bind a user-facing "credits remaining" counter to
|
|
158
|
+
* `creditSettled` — it's invariant to in-flight lease holds, so it doesn't
|
|
159
|
+
* dip mid-call the way the raw server balance does.
|
|
160
|
+
*
|
|
161
|
+
* These come from the company's resolved entitlement, so the lease-balance
|
|
162
|
+
* substitution a lease-bearing `check()` applies for gating does NOT distort
|
|
163
|
+
* them — the same values surface whether or not `usage` was passed.
|
|
162
164
|
*/
|
|
163
165
|
entitlement?: api.RulesengineFeatureEntitlement;
|
|
164
166
|
/** Flag key checked. */
|
|
@@ -11,7 +11,7 @@ export declare function deepCopyUser(u: Schematic.RulesengineUser): Schematic.Ru
|
|
|
11
11
|
* Partials don't carry refreshed entitlements, so when their derived fields
|
|
12
12
|
* change in another part of the company we sync them here to match server
|
|
13
13
|
* behavior:
|
|
14
|
-
* - creditRemaining ← credit_balances[credit_id]
|
|
14
|
+
* - creditRemaining ← credit_balances[credit_id] (or credit_lease_balance[credit_id].remaining)
|
|
15
15
|
* - usage ← metric value matching (eventName, metricPeriod, monthReset)
|
|
16
16
|
* Both are skipped when the partial also sends entitlements wholesale.
|
|
17
17
|
*
|