@schematichq/schematic-typescript-node 1.5.0 → 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.
Files changed (89) hide show
  1. package/dist/Client.d.ts +8 -0
  2. package/dist/api/resources/billing/client/Client.d.ts +47 -0
  3. package/dist/api/resources/billing/client/requests/ListBillingPricesRequest.d.ts +3 -0
  4. package/dist/api/resources/billing/client/requests/ListBillingProductPricesRequest.d.ts +3 -0
  5. package/dist/api/resources/billing/types/DeleteBillingCouponResponse.d.ts +6 -0
  6. package/dist/api/resources/billing/types/DeleteBillingCustomerResponse.d.ts +6 -0
  7. package/dist/api/resources/billing/types/DeleteBillingInvoiceResponse.d.ts +6 -0
  8. package/dist/api/resources/billing/types/ListBillingPricesParams.d.ts +2 -0
  9. package/dist/api/resources/billing/types/ListBillingProductPricesParams.d.ts +2 -0
  10. package/dist/api/resources/billing/types/index.d.ts +3 -0
  11. package/dist/api/resources/credits/client/Client.d.ts +0 -48
  12. package/dist/api/resources/credits/client/requests/index.d.ts +0 -2
  13. package/dist/api/resources/credits/types/index.d.ts +0 -4
  14. package/dist/api/resources/plangroups/client/Client.d.ts +2 -0
  15. package/dist/api/resources/plangroups/client/requests/CreatePlanGroupRequestBody.d.ts +4 -0
  16. package/dist/api/resources/plangroups/client/requests/UpdatePlanGroupRequestBody.d.ts +4 -0
  17. package/dist/api/resources/plans/client/Client.d.ts +2 -10
  18. package/dist/api/resources/plans/client/requests/PublishPlanVersionRequestBody.d.ts +1 -6
  19. package/dist/api/resources/plans/client/requests/RetryCustomPlanBillingRequestBody.d.ts +1 -6
  20. package/dist/api/resources/webhooks/client/Client.d.ts +18 -0
  21. package/dist/api/resources/webhooks/client/requests/TestWebhookRequestBody.d.ts +10 -0
  22. package/dist/api/resources/webhooks/client/requests/index.d.ts +1 -0
  23. package/dist/api/resources/webhooks/types/SendTestWebhookActionResponse.d.ts +6 -0
  24. package/dist/api/resources/webhooks/types/index.d.ts +1 -0
  25. package/dist/api/types/AccountMemberPermission.d.ts +0 -1
  26. package/dist/api/types/BillingCreditGrantZeroedOutReason.d.ts +1 -0
  27. package/dist/api/types/ChangeSubscriptionInternalRequestBody.d.ts +1 -0
  28. package/dist/api/types/ChangeSubscriptionRequestBody.d.ts +1 -0
  29. package/dist/api/types/CheckFlagsResponseData.d.ts +2 -0
  30. package/dist/api/types/CheckoutSettingsResponseData.d.ts +3 -0
  31. package/dist/api/types/CompanyCreditBalance.d.ts +8 -0
  32. package/dist/api/types/CompanySubscriptionResponseData.d.ts +1 -0
  33. package/dist/api/types/FeatureEntitlement.d.ts +9 -1
  34. package/dist/api/types/PlanChangeResponseData.d.ts +2 -0
  35. package/dist/api/types/PreviewSubscriptionChangeResponseData.d.ts +3 -0
  36. package/dist/api/types/RulesengineFeatureEntitlement.d.ts +9 -1
  37. package/dist/api/types/TestWebhookResponseData.d.ts +4 -0
  38. package/dist/api/types/index.d.ts +2 -2
  39. package/dist/credits/check.d.ts +9 -5
  40. package/dist/credits/types.d.ts +11 -9
  41. package/dist/datastream/merge.d.ts +1 -1
  42. package/dist/index.js +9 -9
  43. package/dist/rules-engine.d.ts +4 -0
  44. package/dist/serialization/resources/billing/types/DeleteBillingCouponResponse.d.ts +11 -0
  45. package/dist/serialization/resources/billing/types/DeleteBillingCustomerResponse.d.ts +11 -0
  46. package/dist/serialization/resources/billing/types/DeleteBillingInvoiceResponse.d.ts +11 -0
  47. package/dist/serialization/resources/billing/types/ListBillingPricesParams.d.ts +1 -0
  48. package/dist/serialization/resources/billing/types/ListBillingProductPricesParams.d.ts +1 -0
  49. package/dist/serialization/resources/billing/types/index.d.ts +3 -0
  50. package/dist/serialization/resources/credits/types/index.d.ts +0 -4
  51. package/dist/serialization/resources/plangroups/client/requests/CreatePlanGroupRequestBody.d.ts +3 -0
  52. package/dist/serialization/resources/plangroups/client/requests/UpdatePlanGroupRequestBody.d.ts +3 -0
  53. package/dist/serialization/resources/plans/client/requests/PublishPlanVersionRequestBody.d.ts +0 -2
  54. package/dist/serialization/resources/plans/client/requests/RetryCustomPlanBillingRequestBody.d.ts +0 -2
  55. package/dist/serialization/resources/webhooks/client/requests/TestWebhookRequestBody.d.ts +10 -0
  56. package/dist/serialization/resources/webhooks/client/requests/index.d.ts +1 -0
  57. package/dist/serialization/resources/webhooks/types/SendTestWebhookActionResponse.d.ts +11 -0
  58. package/dist/serialization/resources/webhooks/types/index.d.ts +1 -0
  59. package/dist/serialization/types/AccountMemberPermission.d.ts +1 -1
  60. package/dist/serialization/types/BillingCreditGrantZeroedOutReason.d.ts +1 -1
  61. package/dist/serialization/types/ChangeSubscriptionInternalRequestBody.d.ts +1 -0
  62. package/dist/serialization/types/ChangeSubscriptionRequestBody.d.ts +1 -0
  63. package/dist/serialization/types/CheckFlagsResponseData.d.ts +2 -0
  64. package/dist/serialization/types/CheckoutSettingsResponseData.d.ts +3 -0
  65. package/dist/serialization/types/CompanyCreditBalance.d.ts +11 -0
  66. package/dist/serialization/types/CompanySubscriptionResponseData.d.ts +1 -0
  67. package/dist/serialization/types/FeatureEntitlement.d.ts +4 -0
  68. package/dist/serialization/types/PlanChangeResponseData.d.ts +1 -0
  69. package/dist/serialization/types/PreviewSubscriptionChangeResponseData.d.ts +3 -0
  70. package/dist/serialization/types/RulesengineFeatureEntitlement.d.ts +4 -0
  71. package/dist/serialization/types/TestWebhookResponseData.d.ts +10 -0
  72. package/dist/serialization/types/index.d.ts +2 -2
  73. package/dist/wasm/rulesengine.js +4 -4
  74. package/dist/wrapper.d.ts +0 -30
  75. package/package.json +1 -1
  76. package/dist/api/resources/credits/client/requests/CountCreditLedgerRequest.d.ts +0 -26
  77. package/dist/api/resources/credits/client/requests/GetEnrichedCreditLedgerRequest.d.ts +0 -26
  78. package/dist/api/resources/credits/types/CountCreditLedgerParams.d.ts +0 -16
  79. package/dist/api/resources/credits/types/CountCreditLedgerResponse.d.ts +0 -6
  80. package/dist/api/resources/credits/types/GetEnrichedCreditLedgerParams.d.ts +0 -16
  81. package/dist/api/resources/credits/types/GetEnrichedCreditLedgerResponse.d.ts +0 -6
  82. package/dist/api/types/CreditLedgerEnrichedEntryResponseData.d.ts +0 -25
  83. package/dist/api/types/CreditLedgerPeriod.d.ts +0 -7
  84. package/dist/serialization/resources/credits/types/CountCreditLedgerParams.d.ts +0 -17
  85. package/dist/serialization/resources/credits/types/CountCreditLedgerResponse.d.ts +0 -12
  86. package/dist/serialization/resources/credits/types/GetEnrichedCreditLedgerParams.d.ts +0 -17
  87. package/dist/serialization/resources/credits/types/GetEnrichedCreditLedgerResponse.d.ts +0 -12
  88. package/dist/serialization/types/CreditLedgerEnrichedEntryResponseData.d.ts +0 -33
  89. package/dist/serialization/types/CreditLedgerPeriod.d.ts +0 -7
@@ -26,15 +26,19 @@ export interface CreditCheckDeps {
26
26
  * Drives a single `client.check` with `usage` set.
27
27
  *
28
28
  * Steps:
29
- * 1. Resolve the matching credit-balance condition on the flag to get
30
- * `creditId` + `consumptionRate`.
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), plus `event_usage` options so
36
- * the engine evaluates the post-call balance. The reservation we made
37
- * in step 3 only sticks if the engine says allowed.
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
  /**
@@ -150,15 +150,17 @@ export interface CheckResult {
150
150
  /**
151
151
  * Entitlement payload from the check.
152
152
  *
153
- * NOTE: `entitlement.creditRemaining` (and `creditTotal` / `creditUsed`) is
154
- * NOT lease-aware and must not be used as a user-facing balance when credit
155
- * leases are enabled. The WASM derives those fields from the company's
156
- * server `creditBalances`, which a lease distorts: a plain `checkFlag` sees
157
- * the balance net of the whole lease tranche (reads low/~0), and a
158
- * lease-bearing `check()` sees the substituted *tranche-local* balance, not
159
- * the company total. For any "credits remaining" display use
160
- * `client.getCreditBalance(...).settled` (`B − spent`), which speaks the
161
- * server's `remaining`/`reserved`/`settled` vocabulary.
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
  *