@schematichq/schematic-typescript-node 1.4.7 → 1.5.0

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 (134) hide show
  1. package/README.md +111 -6
  2. package/dist/api/resources/accounts/client/Client.d.ts +20 -0
  3. package/dist/api/resources/accounts/client/requests/CountAccountMembersRequest.d.ts +18 -0
  4. package/dist/api/resources/accounts/client/requests/index.d.ts +1 -0
  5. package/dist/api/resources/accounts/types/CountAccountMembersParams.d.ts +12 -0
  6. package/dist/api/resources/accounts/types/CountAccountMembersResponse.d.ts +6 -0
  7. package/dist/api/resources/accounts/types/index.d.ts +2 -0
  8. package/dist/api/resources/billing/client/Client.d.ts +6 -6
  9. package/dist/api/resources/billing/client/requests/CountBillingProductsRequest.d.ts +1 -1
  10. package/dist/api/resources/billing/client/requests/CountCustomersRequest.d.ts +1 -1
  11. package/dist/api/resources/billing/client/requests/ListBillingPricesRequest.d.ts +1 -1
  12. package/dist/api/resources/billing/client/requests/ListBillingProductPricesRequest.d.ts +1 -1
  13. package/dist/api/resources/billing/client/requests/ListBillingProductsRequest.d.ts +1 -1
  14. package/dist/api/resources/billing/client/requests/ListCustomersWithSubscriptionsRequest.d.ts +1 -1
  15. package/dist/api/resources/checkout/client/Client.d.ts +16 -0
  16. package/dist/api/resources/entitlements/client/Client.d.ts +3 -3
  17. package/dist/api/resources/entitlements/client/requests/CountFeatureUsageRequest.d.ts +1 -1
  18. package/dist/api/resources/entitlements/client/requests/CreateBillingLinkedPlanEntitlementRequestBody.d.ts +1 -1
  19. package/dist/api/resources/entitlements/client/requests/ListFeatureUsageRequest.d.ts +1 -1
  20. package/dist/api/resources/features/client/Client.d.ts +3 -3
  21. package/dist/api/resources/features/client/requests/CountFeaturesRequest.d.ts +1 -1
  22. package/dist/api/resources/features/client/requests/CreateBillingLinkedFeatureRequestBody.d.ts +1 -1
  23. package/dist/api/resources/features/client/requests/ListFeaturesRequest.d.ts +1 -1
  24. package/dist/api/resources/integrationsapi/client/Client.d.ts +54 -3
  25. package/dist/api/resources/integrationsapi/types/AssumeStripeInstalledResponse.d.ts +6 -0
  26. package/dist/api/resources/integrationsapi/types/InstallIntegrationResponse.d.ts +6 -0
  27. package/dist/api/resources/integrationsapi/types/InstallStripeResponse.d.ts +6 -0
  28. package/dist/api/resources/integrationsapi/types/{LoadSampleDataSetV2Response.d.ts → LoadSampleDataSetResponse.d.ts} +1 -1
  29. package/dist/api/resources/integrationsapi/types/index.d.ts +4 -1
  30. package/dist/api/resources/plangroups/client/requests/CreatePlanGroupRequestBody.d.ts +1 -0
  31. package/dist/api/resources/plangroups/client/requests/UpdatePlanGroupRequestBody.d.ts +1 -0
  32. package/dist/api/resources/plans/client/Client.d.ts +1 -1
  33. package/dist/api/resources/plans/client/requests/CreateBillingLinkedPlanRequestBody.d.ts +1 -1
  34. package/dist/api/types/AccountMemberResponseData.d.ts +2 -0
  35. package/dist/api/types/BillingCreditGrantReason.d.ts +1 -0
  36. package/dist/api/types/BillingCreditGrantResponseData.d.ts +4 -0
  37. package/dist/api/types/BillingCreditLedgerAuthority.d.ts +6 -0
  38. package/dist/api/types/BillingCreditView.d.ts +1 -0
  39. package/dist/api/types/BillingPlanCreditGrantResponseData.d.ts +2 -0
  40. package/dist/api/types/BillingProviderType.d.ts +1 -0
  41. package/dist/api/types/ChangeSubscriptionInternalRequestBody.d.ts +1 -0
  42. package/dist/api/types/ChangeSubscriptionRequestBody.d.ts +1 -0
  43. package/dist/api/types/CheckoutDataResponseData.d.ts +1 -0
  44. package/dist/api/types/CheckoutFieldInput.d.ts +8 -0
  45. package/dist/api/types/CheckoutFieldResponseData.d.ts +12 -0
  46. package/dist/api/types/CheckoutFieldValue.d.ts +4 -0
  47. package/dist/api/types/CheckoutFieldWithValue.d.ts +9 -0
  48. package/dist/api/types/CompanyCreditBalanceResponseData.d.ts +2 -0
  49. package/dist/api/types/CompanyPlanCreditGrantView.d.ts +1 -0
  50. package/dist/api/types/ComponentHydrateResponseData.d.ts +1 -0
  51. package/dist/api/types/ComponentPreviewResponseData.d.ts +1 -0
  52. package/dist/api/types/CreateBillingPlanCreditGrantRequestBody.d.ts +2 -0
  53. package/dist/api/types/CreditCompanyGrantView.d.ts +3 -0
  54. package/dist/api/types/CreditEventLedgerResponseData.d.ts +1 -0
  55. package/dist/api/types/CreditUsageReason.d.ts +8 -0
  56. package/dist/api/types/EventDetailResponseData.d.ts +1 -0
  57. package/dist/api/types/EventResponseData.d.ts +1 -0
  58. package/dist/api/types/InstallIntegrationRequestBody.d.ts +9 -0
  59. package/dist/api/types/IntegrationConfig.d.ts +4 -1
  60. package/dist/api/types/IntegrationInstallConfig.d.ts +13 -0
  61. package/dist/api/types/IntegrationInstallResponseData.d.ts +6 -0
  62. package/dist/api/types/IntegrationType.d.ts +1 -0
  63. package/dist/api/types/ManagePlanRequest.d.ts +1 -0
  64. package/dist/api/types/MetronomeIntegrationConfig.d.ts +1 -0
  65. package/dist/api/types/MigrationErrorCode.d.ts +1 -0
  66. package/dist/api/types/PlanCreditGrantView.d.ts +1 -0
  67. package/dist/api/types/PlanGroupDetailResponseData.d.ts +1 -0
  68. package/dist/api/types/UpdateBillingPlanCreditGrantRequestBody.d.ts +2 -0
  69. package/dist/api/types/index.d.ts +10 -0
  70. package/dist/cache/redis.d.ts +29 -2
  71. package/dist/credits/check.d.ts +49 -0
  72. package/dist/credits/index.d.ts +7 -0
  73. package/dist/credits/lease-manager.d.ts +68 -0
  74. package/dist/credits/lease-store.d.ts +133 -0
  75. package/dist/credits/redis-lease-store.d.ts +30 -0
  76. package/dist/credits/redis-reservation-store.d.ts +46 -0
  77. package/dist/credits/reservation-store.d.ts +64 -0
  78. package/dist/credits/track.d.ts +44 -0
  79. package/dist/credits/types.d.ts +175 -0
  80. package/dist/datastream/datastream-client.d.ts +19 -3
  81. package/dist/datastream/merge.d.ts +5 -11
  82. package/dist/index.d.ts +1 -0
  83. package/dist/index.js +85 -3
  84. package/dist/rules-engine.d.ts +3 -1
  85. package/dist/serialization/resources/accounts/types/CountAccountMembersParams.d.ts +12 -0
  86. package/dist/serialization/resources/accounts/types/CountAccountMembersResponse.d.ts +12 -0
  87. package/dist/serialization/resources/accounts/types/index.d.ts +2 -0
  88. package/dist/serialization/resources/integrationsapi/types/AssumeStripeInstalledResponse.d.ts +11 -0
  89. package/dist/serialization/resources/integrationsapi/types/InstallIntegrationResponse.d.ts +11 -0
  90. package/dist/serialization/resources/integrationsapi/types/InstallStripeResponse.d.ts +11 -0
  91. package/dist/serialization/resources/integrationsapi/types/{LoadSampleDataSetV2Response.d.ts → LoadSampleDataSetResponse.d.ts} +2 -2
  92. package/dist/serialization/resources/integrationsapi/types/index.d.ts +4 -1
  93. package/dist/serialization/resources/plangroups/client/requests/CreatePlanGroupRequestBody.d.ts +2 -0
  94. package/dist/serialization/resources/plangroups/client/requests/UpdatePlanGroupRequestBody.d.ts +2 -0
  95. package/dist/serialization/types/AccountMemberResponseData.d.ts +2 -0
  96. package/dist/serialization/types/BillingCreditGrantReason.d.ts +1 -1
  97. package/dist/serialization/types/BillingCreditGrantResponseData.d.ts +3 -0
  98. package/dist/serialization/types/BillingCreditLedgerAuthority.d.ts +7 -0
  99. package/dist/serialization/types/BillingCreditView.d.ts +2 -0
  100. package/dist/serialization/types/BillingPlanCreditGrantResponseData.d.ts +1 -0
  101. package/dist/serialization/types/BillingProviderType.d.ts +1 -1
  102. package/dist/serialization/types/ChangeSubscriptionInternalRequestBody.d.ts +2 -0
  103. package/dist/serialization/types/ChangeSubscriptionRequestBody.d.ts +2 -0
  104. package/dist/serialization/types/CheckoutDataResponseData.d.ts +2 -0
  105. package/dist/serialization/types/CheckoutFieldInput.d.ts +14 -0
  106. package/dist/serialization/types/CheckoutFieldResponseData.d.ts +18 -0
  107. package/dist/serialization/types/CheckoutFieldValue.d.ts +10 -0
  108. package/dist/serialization/types/CheckoutFieldWithValue.d.ts +15 -0
  109. package/dist/serialization/types/CompanyCreditBalanceResponseData.d.ts +2 -0
  110. package/dist/serialization/types/CompanyPlanCreditGrantView.d.ts +1 -0
  111. package/dist/serialization/types/ComponentHydrateResponseData.d.ts +2 -0
  112. package/dist/serialization/types/ComponentPreviewResponseData.d.ts +2 -0
  113. package/dist/serialization/types/CreateBillingPlanCreditGrantRequestBody.d.ts +1 -0
  114. package/dist/serialization/types/CreditCompanyGrantView.d.ts +3 -0
  115. package/dist/serialization/types/CreditEventLedgerResponseData.d.ts +2 -0
  116. package/dist/serialization/types/CreditUsageReason.d.ts +7 -0
  117. package/dist/serialization/types/EventDetailResponseData.d.ts +1 -0
  118. package/dist/serialization/types/EventResponseData.d.ts +1 -0
  119. package/dist/serialization/types/InstallIntegrationRequestBody.d.ts +16 -0
  120. package/dist/serialization/types/IntegrationConfig.d.ts +5 -1
  121. package/dist/serialization/types/IntegrationInstallConfig.d.ts +20 -0
  122. package/dist/serialization/types/IntegrationInstallResponseData.d.ts +14 -0
  123. package/dist/serialization/types/IntegrationType.d.ts +1 -1
  124. package/dist/serialization/types/ManagePlanRequest.d.ts +2 -0
  125. package/dist/serialization/types/MetronomeIntegrationConfig.d.ts +7 -0
  126. package/dist/serialization/types/MigrationErrorCode.d.ts +1 -1
  127. package/dist/serialization/types/PlanCreditGrantView.d.ts +1 -0
  128. package/dist/serialization/types/PlanGroupDetailResponseData.d.ts +2 -0
  129. package/dist/serialization/types/UpdateBillingPlanCreditGrantRequestBody.d.ts +1 -0
  130. package/dist/serialization/types/index.d.ts +10 -0
  131. package/dist/wasm/rulesengine.js +5 -5
  132. package/dist/wrapper.d.ts +158 -6
  133. package/package.json +5 -4
  134. package/dist/wasm/rulesengine_bg.wasm +0 -0
@@ -242,7 +242,7 @@ export declare class PlansClient {
242
242
  *
243
243
  * @example
244
244
  * await client.plans.upsertPlanForBillingProduct({
245
- * billingProvider: "orb",
245
+ * billingProvider: "metronome",
246
246
  * description: "description",
247
247
  * externalResourceId: "external_resource_id",
248
248
  * name: "name",
@@ -2,7 +2,7 @@ import type * as Schematic from "../../../../index";
2
2
  /**
3
3
  * @example
4
4
  * {
5
- * billingProvider: "orb",
5
+ * billingProvider: "metronome",
6
6
  * description: "description",
7
7
  * externalResourceId: "external_resource_id",
8
8
  * name: "name",
@@ -2,8 +2,10 @@ import type * as Schematic from "../index";
2
2
  export interface AccountMemberResponseData {
3
3
  createdAt: Date;
4
4
  email?: string;
5
+ firstName?: string;
5
6
  id: string;
6
7
  imageUrl?: string;
8
+ lastName?: string;
7
9
  name?: string;
8
10
  permissions: Record<string, Schematic.AccountMemberPermission[]>;
9
11
  role?: Schematic.AccountMemberRole;
@@ -4,5 +4,6 @@ export declare const BillingCreditGrantReason: {
4
4
  readonly Free: "free";
5
5
  readonly Plan: "plan";
6
6
  readonly Purchased: "purchased";
7
+ readonly Rollover: "rollover";
7
8
  };
8
9
  export type BillingCreditGrantReason = (typeof BillingCreditGrantReason)[keyof typeof BillingCreditGrantReason];
@@ -18,6 +18,10 @@ export interface BillingCreditGrantResponseData {
18
18
  quantityUsed: number;
19
19
  renewalEnabled: boolean;
20
20
  renewalPeriod?: Schematic.BillingPlanCreditGrantResetCadence;
21
+ reserved?: number;
22
+ settled?: number;
23
+ /** For rollover grants, the ID of the source grant that this grant rolled from. */
24
+ sourceGrantId?: string;
21
25
  sourceLabel: string;
22
26
  transfers?: Schematic.CreditTransferResponseData[];
23
27
  updatedAt: Date;
@@ -0,0 +1,6 @@
1
+ export declare const BillingCreditLedgerAuthority: {
2
+ readonly SchematicAuthoritative: "schematic_authoritative";
3
+ readonly ExternalMirror: "external_mirror";
4
+ readonly ExternalRated: "external_rated";
5
+ };
6
+ export type BillingCreditLedgerAuthority = (typeof BillingCreditLedgerAuthority)[keyof typeof BillingCreditLedgerAuthority];
@@ -12,6 +12,7 @@ export interface BillingCreditView {
12
12
  environmentId: string;
13
13
  icon?: string;
14
14
  id: string;
15
+ ledgerAuthority: Schematic.BillingCreditLedgerAuthority;
15
16
  name: string;
16
17
  pluralName?: string;
17
18
  price?: Schematic.BillingPriceView;
@@ -31,5 +31,7 @@ export interface BillingPlanCreditGrantResponseData {
31
31
  resetCadence?: Schematic.BillingPlanCreditGrantResetCadence;
32
32
  resetStart?: Schematic.BillingPlanCreditGrantResetStart;
33
33
  resetType?: Schematic.BillingPlanCreditGrantResetType;
34
+ /** Percentage of unused credits that carry over when this grant resets. Only meaningful when reset_type is plan_period. */
35
+ rolloverPercentage: number;
34
36
  updatedAt: Date;
35
37
  }
@@ -1,4 +1,5 @@
1
1
  export declare const BillingProviderType: {
2
+ readonly Metronome: "metronome";
2
3
  readonly Orb: "orb";
3
4
  readonly Schematic: "schematic";
4
5
  readonly Stripe: "stripe";
@@ -5,6 +5,7 @@ export interface ChangeSubscriptionInternalRequestBody {
5
5
  companyId: string;
6
6
  couponExternalId?: string;
7
7
  creditBundles: Schematic.UpdateCreditBundleRequestBody[];
8
+ customFieldValues: Schematic.CheckoutFieldValue[];
8
9
  newPlanId: string;
9
10
  newPriceId: string;
10
11
  payInAdvance: Schematic.UpdatePayInAdvanceRequestBody[];
@@ -4,6 +4,7 @@ export interface ChangeSubscriptionRequestBody {
4
4
  autoTopupOverrides: Schematic.UpdateAutoTopupOverrideRequestBody[];
5
5
  couponExternalId?: string;
6
6
  creditBundles: Schematic.UpdateCreditBundleRequestBody[];
7
+ customFieldValues: Schematic.CheckoutFieldValue[];
7
8
  newPlanId: string;
8
9
  newPriceId: string;
9
10
  payInAdvance: Schematic.UpdatePayInAdvanceRequestBody[];
@@ -5,6 +5,7 @@ export interface CheckoutDataResponseData {
5
5
  activeUsageBasedEntitlements: Schematic.UsageBasedEntitlementResponseData[];
6
6
  availableCreditBundles: Schematic.BillingCreditBundleResponseData[];
7
7
  company?: Schematic.CompanyDetailResponseData;
8
+ customCheckoutFields: Schematic.CheckoutFieldWithValue[];
8
9
  featureUsage?: Schematic.FeatureUsageDetailResponseData;
9
10
  selectedCreditBundles: Schematic.CreditBundlePurchaseResponseData[];
10
11
  selectedPlan?: Schematic.PlanDetailResponseData;
@@ -0,0 +1,8 @@
1
+ export interface CheckoutFieldInput {
2
+ definitionId?: string;
3
+ helperText?: string;
4
+ id?: string;
5
+ name: string;
6
+ required: boolean;
7
+ stripeMetadataKey: string;
8
+ }
@@ -0,0 +1,12 @@
1
+ export interface CheckoutFieldResponseData {
2
+ createdAt: Date;
3
+ definitionId: string;
4
+ helperText?: string;
5
+ id: string;
6
+ name: string;
7
+ position: number;
8
+ required: boolean;
9
+ stripeMetadataKey: string;
10
+ traitHierarchy: string[];
11
+ updatedAt: Date;
12
+ }
@@ -0,0 +1,4 @@
1
+ export interface CheckoutFieldValue {
2
+ id: string;
3
+ value: string;
4
+ }
@@ -0,0 +1,9 @@
1
+ export interface CheckoutFieldWithValue {
2
+ definitionId: string;
3
+ helperText?: string;
4
+ id: string;
5
+ name: string;
6
+ required: boolean;
7
+ stripeMetadataKey: string;
8
+ value?: string;
9
+ }
@@ -2,6 +2,8 @@ import type * as Schematic from "../index";
2
2
  export interface CompanyCreditBalanceResponseData {
3
3
  creditId: string;
4
4
  remaining: number;
5
+ reserved: number;
6
+ settled: number;
5
7
  source: Schematic.BillingProviderType;
6
8
  total?: number;
7
9
  }
@@ -34,6 +34,7 @@ export interface CompanyPlanCreditGrantView {
34
34
  resetCadence?: Schematic.BillingPlanCreditGrantResetCadence;
35
35
  resetStart?: Schematic.BillingPlanCreditGrantResetStart;
36
36
  resetType: Schematic.BillingPlanCreditGrantResetType;
37
+ rolloverPercentage: number;
37
38
  /** Deprecated field, will be removed in the future. Use Credit.SingularName instead. */
38
39
  singularName?: string;
39
40
  updatedAt: Date;
@@ -10,6 +10,7 @@ export interface ComponentHydrateResponseData {
10
10
  component?: Schematic.ComponentResponseData;
11
11
  creditBundles: Schematic.BillingCreditBundleView[];
12
12
  creditGrants: Schematic.CreditCompanyGrantView[];
13
+ customCheckoutFields: Schematic.CheckoutFieldWithValue[];
13
14
  defaultPlan?: Schematic.PlanDetailResponseData;
14
15
  displaySettings: Schematic.ComponentDisplaySettings;
15
16
  featureUsage?: Schematic.FeatureUsageDetailResponseData;
@@ -10,6 +10,7 @@ export interface ComponentPreviewResponseData {
10
10
  component?: Schematic.ComponentResponseData;
11
11
  creditBundles: Schematic.BillingCreditBundleView[];
12
12
  creditGrants: Schematic.CreditCompanyGrantView[];
13
+ customCheckoutFields: Schematic.CheckoutFieldWithValue[];
13
14
  defaultPlan?: Schematic.PlanDetailResponseData;
14
15
  displaySettings: Schematic.ComponentDisplaySettings;
15
16
  featureUsage?: Schematic.FeatureUsageDetailResponseData;
@@ -20,4 +20,6 @@ export interface CreateBillingPlanCreditGrantRequestBody {
20
20
  resetCadence: Schematic.BillingPlanCreditGrantResetCadence;
21
21
  resetStart: Schematic.BillingPlanCreditGrantResetStart;
22
22
  resetType?: Schematic.BillingPlanCreditGrantResetType;
23
+ /** Percentage of unused credits that carry over when this grant resets. Only applies when reset_type is plan_period. Rolled-over credits expire at the next reset and are not rolled again. Defaults to 0. */
24
+ rolloverPercentage?: number;
23
25
  }
@@ -25,7 +25,10 @@ export interface CreditCompanyGrantView {
25
25
  quantityUsed: number;
26
26
  renewalEnabled: boolean;
27
27
  renewalPeriod?: Schematic.BillingPlanCreditGrantResetCadence;
28
+ reserved?: number;
29
+ settled?: number;
28
30
  singularName?: string;
31
+ sourceGrantId?: string;
29
32
  sourceLabel: string;
30
33
  transfers?: Schematic.CreditTransferView[];
31
34
  updatedAt: Date;
@@ -30,5 +30,6 @@ export interface CreditEventLedgerResponseData {
30
30
  sourceId: number;
31
31
  toGrantId?: string;
32
32
  usageEventId?: string;
33
+ usageReason?: Schematic.CreditUsageReason;
33
34
  zeroedOutReason?: Schematic.BillingCreditGrantZeroedOutReason;
34
35
  }
@@ -0,0 +1,8 @@
1
+ export declare const CreditUsageReason: {
2
+ readonly LeaseHold: "lease_hold";
3
+ readonly LeaseRelease: "lease_release";
4
+ readonly ManualAdjustment: "manual_adjustment";
5
+ readonly Reconciliation: "reconciliation";
6
+ readonly Track: "track";
7
+ };
8
+ export type CreditUsageReason = (typeof CreditUsageReason)[keyof typeof CreditUsageReason];
@@ -14,6 +14,7 @@ export interface EventDetailResponseData {
14
14
  features: Schematic.PreviewObject[];
15
15
  id: string;
16
16
  idempotencyKey?: string;
17
+ leaseId?: string;
17
18
  loadedAt?: Date;
18
19
  processedAt?: Date;
19
20
  quantity: number;
@@ -11,6 +11,7 @@ export interface EventResponseData {
11
11
  featureIds: string[];
12
12
  id: string;
13
13
  idempotencyKey?: string;
14
+ leaseId?: string;
14
15
  loadedAt?: Date;
15
16
  processedAt?: Date;
16
17
  quantity: number;
@@ -0,0 +1,9 @@
1
+ import type * as Schematic from "../index";
2
+ export interface InstallIntegrationRequestBody {
3
+ companyMatchingCriteria?: Schematic.CompanyMatchingCriteria;
4
+ companyMatchingField?: string;
5
+ config?: Record<string, unknown>;
6
+ isSandbox?: boolean;
7
+ liveMode?: boolean;
8
+ type: Schematic.IntegrationType;
9
+ }
@@ -1,9 +1,12 @@
1
1
  import type * as Schematic from "../index";
2
- export type IntegrationConfig = Schematic.IntegrationConfig.Clerk | Schematic.IntegrationConfig.Orb | Schematic.IntegrationConfig.Stripe | Schematic.IntegrationConfig.Workos;
2
+ export type IntegrationConfig = Schematic.IntegrationConfig.Clerk | Schematic.IntegrationConfig.Metronome | Schematic.IntegrationConfig.Orb | Schematic.IntegrationConfig.Stripe | Schematic.IntegrationConfig.Workos;
3
3
  export declare namespace IntegrationConfig {
4
4
  interface Clerk extends Schematic.ClerkIntegrationConfig {
5
5
  type: "clerk";
6
6
  }
7
+ interface Metronome extends Schematic.MetronomeIntegrationConfig {
8
+ type: "metronome";
9
+ }
7
10
  interface Orb extends Schematic.OrbIntegrationConfig {
8
11
  type: "orb";
9
12
  }
@@ -0,0 +1,13 @@
1
+ import type * as Schematic from "../index";
2
+ export interface IntegrationInstallConfig {
3
+ companyMatchingCriteria?: Schematic.CompanyMatchingCriteria;
4
+ companyMatchingField?: string;
5
+ config?: Schematic.IntegrationConfig;
6
+ createdAt: Date;
7
+ id: string;
8
+ integrationId: string;
9
+ isAppInstall: boolean;
10
+ isConnectInstall: boolean;
11
+ liveMode: boolean;
12
+ updatedAt: Date;
13
+ }
@@ -0,0 +1,6 @@
1
+ import type * as Schematic from "../index";
2
+ export interface IntegrationInstallResponseData {
3
+ capabilities: Schematic.IntegrationCapabilities;
4
+ config: Schematic.IntegrationInstallConfig;
5
+ integration: Schematic.IntegrationResponseData;
6
+ }
@@ -1,5 +1,6 @@
1
1
  export declare const IntegrationType: {
2
2
  readonly Clerk: "clerk";
3
+ readonly Metronome: "metronome";
3
4
  readonly Orb: "orb";
4
5
  readonly Stripe: "stripe";
5
6
  readonly Unknown: "unknown";
@@ -9,6 +9,7 @@ export interface ManagePlanRequest {
9
9
  companyId: string;
10
10
  couponExternalId?: string;
11
11
  creditBundles: Schematic.UpdateCreditBundleRequestBody[];
12
+ customFieldValues: Schematic.CheckoutFieldValue[];
12
13
  payInAdvanceEntitlements: Schematic.UpdatePayInAdvanceRequestBody[];
13
14
  paymentMethodExternalId?: string;
14
15
  promoCode?: string;
@@ -0,0 +1 @@
1
+ export type MetronomeIntegrationConfig = {};
@@ -3,6 +3,7 @@ export declare const MigrationErrorCode: {
3
3
  readonly MultipleSubscriptions: "multiple_subscriptions";
4
4
  readonly NoPriceForInterval: "no_price_for_interval";
5
5
  readonly NotOnOriginVersion: "not_on_origin_version";
6
+ readonly OperationItemNotFound: "operation_item_not_found";
6
7
  readonly PermanentConfig: "permanent_config";
7
8
  readonly PermanentDecline: "permanent_decline";
8
9
  readonly TransientDecline: "transient_decline";
@@ -31,6 +31,7 @@ export interface PlanCreditGrantView {
31
31
  resetCadence?: Schematic.BillingPlanCreditGrantResetCadence;
32
32
  resetStart?: Schematic.BillingPlanCreditGrantResetStart;
33
33
  resetType: Schematic.BillingPlanCreditGrantResetType;
34
+ rolloverPercentage: number;
34
35
  /** Deprecated field, will be removed in the future. Use Credit.SingularName instead. */
35
36
  singularName?: string;
36
37
  updatedAt: Date;
@@ -3,6 +3,7 @@ export interface PlanGroupDetailResponseData {
3
3
  addOns: Schematic.PlanGroupPlanDetailResponseData[];
4
4
  checkoutSettings: Schematic.CheckoutSettingsResponseData;
5
5
  componentSettings: Schematic.ComponentSettingsResponseData;
6
+ customCheckoutFields: Schematic.CheckoutFieldResponseData[];
6
7
  customPlanConfig?: Schematic.CustomPlanViewConfigResponseData;
7
8
  customPlanId?: string;
8
9
  defaultPlan?: Schematic.PlanGroupPlanDetailResponseData;
@@ -17,4 +17,6 @@ export interface UpdateBillingPlanCreditGrantRequestBody {
17
17
  resetCadence: Schematic.BillingPlanCreditGrantResetCadence;
18
18
  resetStart: Schematic.BillingPlanCreditGrantResetStart;
19
19
  resetType?: Schematic.BillingPlanCreditGrantResetType;
20
+ /** Percentage of unused credits that carry over when this grant resets. Only applies when reset_type is plan_period. Rolled-over credits expire at the next reset and are not rolled again. */
21
+ rolloverPercentage?: number;
20
22
  }
@@ -22,6 +22,7 @@ export * from "./BillingCreditExpiryUnit";
22
22
  export * from "./BillingCreditGrantReason";
23
23
  export * from "./BillingCreditGrantResponseData";
24
24
  export * from "./BillingCreditGrantZeroedOutReason";
25
+ export * from "./BillingCreditLedgerAuthority";
25
26
  export * from "./BillingCreditLedgerResponseData";
26
27
  export * from "./BillingCreditResponseData";
27
28
  export * from "./BillingCreditRolloverPolicy";
@@ -65,6 +66,10 @@ export * from "./CheckFlagResponseData";
65
66
  export * from "./CheckFlagsBulkResponseData";
66
67
  export * from "./CheckFlagsResponseData";
67
68
  export * from "./CheckoutDataResponseData";
69
+ export * from "./CheckoutFieldInput";
70
+ export * from "./CheckoutFieldResponseData";
71
+ export * from "./CheckoutFieldValue";
72
+ export * from "./CheckoutFieldWithValue";
68
73
  export * from "./CheckoutSettingsResponseData";
69
74
  export * from "./CheckoutSubscription";
70
75
  export * from "./ClerkIntegrationConfig";
@@ -143,6 +148,7 @@ export * from "./CreditTransferView";
143
148
  export * from "./CreditTriggerConfig";
144
149
  export * from "./CreditUsage";
145
150
  export * from "./CreditUsageAggregation";
151
+ export * from "./CreditUsageReason";
146
152
  export * from "./CurrencyPriceRequestBody";
147
153
  export * from "./CustomPlanActivationStrategy";
148
154
  export * from "./CustomPlanBillingResponseData";
@@ -209,8 +215,11 @@ export * from "./FlagType";
209
215
  export * from "./FlagView";
210
216
  export * from "./GenericPreviewObject";
211
217
  export * from "./InsightsSummaryResponseData";
218
+ export * from "./InstallIntegrationRequestBody";
212
219
  export * from "./IntegrationCapabilities";
213
220
  export * from "./IntegrationConfig";
221
+ export * from "./IntegrationInstallConfig";
222
+ export * from "./IntegrationInstallResponseData";
214
223
  export * from "./IntegrationResponseData";
215
224
  export * from "./IntegrationState";
216
225
  export * from "./IntegrationsDataSetResponseData";
@@ -231,6 +240,7 @@ export * from "./MarkCustomPlanBillingPaidRequestBody";
231
240
  export * from "./MeterRequestBody";
232
241
  export * from "./MetricPeriod";
233
242
  export * from "./MetricPeriodMonthReset";
243
+ export * from "./MetronomeIntegrationConfig";
234
244
  export * from "./MigrationErrorCode";
235
245
  export * from "./MrrResponseData";
236
246
  export * from "./OrbIntegrationConfig";
@@ -1,7 +1,10 @@
1
1
  import { CacheProvider, CacheOptions } from "./types";
2
2
  /**
3
- * Minimal interface describing the redis client methods used by RedisCacheProvider.
4
- * Compatible with the 'redis' package's RedisClientType.
3
+ * Minimal interface describing the redis client methods used by the SDK.
4
+ * Compatible with the 'redis' package's RedisClientType (node-redis v4).
5
+ *
6
+ * Includes hash + sorted-set + eval surface used by the credit-lease and
7
+ * reservation stores to coordinate state across multiple SDK pods.
5
8
  */
6
9
  export interface RedisClient {
7
10
  get(key: string): Promise<string | null>;
@@ -12,6 +15,30 @@ export interface RedisClient {
12
15
  MATCH: string;
13
16
  COUNT: number;
14
17
  }): AsyncIterable<string>;
18
+ hSet(key: string, field: string | Record<string, string | number>, value?: string | number): Promise<unknown>;
19
+ hGet(key: string, field: string): Promise<string | null | undefined>;
20
+ hGetAll(key: string): Promise<Record<string, string>>;
21
+ hDel(key: string, field: string | string[]): Promise<unknown>;
22
+ zAdd(key: string, members: {
23
+ score: number;
24
+ value: string;
25
+ } | {
26
+ score: number;
27
+ value: string;
28
+ }[]): Promise<unknown>;
29
+ zRangeByScore(key: string, min: number | string, max: number | string, options?: {
30
+ LIMIT: {
31
+ offset: number;
32
+ count: number;
33
+ };
34
+ }): Promise<string[]>;
35
+ zRem(key: string, member: string | string[]): Promise<unknown>;
36
+ zCard(key: string): Promise<number>;
37
+ eval(script: string, options: {
38
+ keys: string[];
39
+ arguments: string[];
40
+ }): Promise<unknown>;
41
+ pExpireAt(key: string, timestamp: number): Promise<unknown>;
15
42
  }
16
43
  export interface RedisOptions extends CacheOptions {
17
44
  /** Pre-created, connected redis client */
@@ -0,0 +1,49 @@
1
+ import type * as api from "../api";
2
+ import type { DataStreamClient } from "../datastream";
3
+ import type { Logger } from "../logger";
4
+ import type { CheckFlagOptions } from "../wrapper";
5
+ import { CreditLeaseManager } from "./lease-manager";
6
+ import type { ILeaseStore } from "./lease-store";
7
+ import type { IReservationStore } from "./reservation-store";
8
+ import type { CheckOptions, CheckResult } from "./types";
9
+ /** Internal helper bundling everything needed to satisfy a lease-bearing check. */
10
+ export interface CreditCheckDeps {
11
+ leaseStore: ILeaseStore;
12
+ reservations: IReservationStore;
13
+ manager: CreditLeaseManager;
14
+ datastream: DataStreamClient | undefined;
15
+ logger: Logger;
16
+ /**
17
+ * Report a `flag_check` event for a check the lease path resolved itself.
18
+ * Mirrors the plain `checkFlag` paths (which enqueue one per check) so
19
+ * lease-gated checks stay visible to flag-check analytics and company
20
+ * last-seen. Fallback exits don't call this — the plain check they
21
+ * delegate to enqueues its own.
22
+ */
23
+ enqueueFlagCheckEvent: (body: api.EventBodyFlagCheck) => void;
24
+ }
25
+ /**
26
+ * Drives a single `client.check` with `usage` set.
27
+ *
28
+ * Steps:
29
+ * 1. Resolve the matching credit-balance condition on the flag to get
30
+ * `creditId` + `consumptionRate`.
31
+ * 2. Acquire (or reuse) a lease for `(company, creditId)`.
32
+ * 3. Try to reserve `quantity × consumptionRate` from the lease.
33
+ * 4. Run the WASM rules engine against a substituted company snapshot
34
+ * (`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.
38
+ */
39
+ export declare function checkWithLease(deps: CreditCheckDeps, key: string, evalCtx: api.CheckFlagRequestBody, options: CheckOptions, fallback: () => Promise<CheckResult>): Promise<CheckResult>;
40
+ /**
41
+ * Build the preflight options envelope for a client-side rules evaluation.
42
+ * With an `eventSubtype` the quantity goes out as the `event_usage` pair so
43
+ * the engine matches it to the subtype's condition; without one it goes out
44
+ * as the generic `usage` knob. Exported so `client.check`'s fallback path can
45
+ * thread the same preflight through a plain flag check — any client-side
46
+ * evaluation (datastream, replicator) honors it even when the lease path
47
+ * can't run.
48
+ */
49
+ export declare function buildPreflightOptions(options: CheckOptions): CheckFlagOptions | undefined;
@@ -0,0 +1,7 @@
1
+ export { LeaseStore, leaseKey, type LeaseEntry, type ILeaseStore } from "./lease-store";
2
+ export { ReservationStore, type IReservationStore } from "./reservation-store";
3
+ export { CreditLeaseManager } from "./lease-manager";
4
+ export { RedisLeaseStore } from "./redis-lease-store";
5
+ export { RedisReservationStore } from "./redis-reservation-store";
6
+ export { DEFAULT_LEASE_DURATION_MS, DEFAULT_LEASE_SIZE, DEFAULT_LOW_WATER_MARK, DEFAULT_PREWARM_POLL_INTERVAL_MS, DEFAULT_PREWARM_RESOLVE_TIMEOUT_MS, DEFAULT_RESERVATION_TTL_MS, DEFAULT_SWEEP_INTERVAL_MS, } from "./types";
7
+ export type { CreditLeaseConfig, ResolvedLeaseConfig, Reservation, CheckOptions, CheckResult, OnAcquireFailure, TrackWithReservationOptions, } from "./types";
@@ -0,0 +1,68 @@
1
+ import type { CreditsClient } from "../api/resources/credits/client/Client";
2
+ import type { Logger } from "../logger";
3
+ import { type ILeaseStore, type LeaseEntry } from "./lease-store";
4
+ import { type CreditLeaseConfig, type ResolvedLeaseConfig } from "./types";
5
+ /**
6
+ * Owns the lifecycle of `credit_lease` rows for a single client: acquire on
7
+ * first use or after expiry, extend when the local view dips below the low
8
+ * water mark, release on `client.close()`.
9
+ *
10
+ * Concurrency: each operation (acquire, extend) has its own best-effort
11
+ * single-flight map keyed by `(company, creditType)`. It's best-effort —
12
+ * callers racing ahead of the registration can still issue duplicate wire
13
+ * calls — which is safe because the server is idempotent for an active slot
14
+ * and `replace` keeps the first live lease.
15
+ */
16
+ export declare class CreditLeaseManager {
17
+ private readonly creditsClient;
18
+ private readonly leaseStore;
19
+ private readonly logger;
20
+ private readonly config;
21
+ private readonly inflightAcquire;
22
+ private readonly inflightExtend;
23
+ constructor(opts: {
24
+ creditsClient: CreditsClient;
25
+ leaseStore: ILeaseStore;
26
+ logger: Logger;
27
+ config: CreditLeaseConfig;
28
+ });
29
+ resolveConfig(creditTypeId: string): ResolvedLeaseConfig;
30
+ /**
31
+ * Return the current lease entry, acquiring one (or replacing an expired
32
+ * one) if none is live. Best-effort single-flight: callers arriving after
33
+ * a request is registered share it (the first caller's `requestOptions`
34
+ * win); callers racing ahead of registration may duplicate the wire call,
35
+ * which the server's idempotent acquire absorbs.
36
+ * Never rejects: a store (Redis) failure is logged and reported as
37
+ * `undefined`, the same as a wire failure, so callers route it through
38
+ * their fail-open/fail-closed handling instead of an unhandled rejection.
39
+ */
40
+ acquireIfNeeded(companyId: string, creditTypeId: string, requestOptions?: CreditsClient.RequestOptions): Promise<LeaseEntry | undefined>;
41
+ private acquire;
42
+ /**
43
+ * Single-flight: kick off a background extend when one is warranted.
44
+ * An extend is triggered if EITHER:
45
+ * - the local remaining is below the low-water-mark ratio (steady-state
46
+ * refresh), or
47
+ * - the caller passes `requiredCredits` and the local remaining is below
48
+ * that figure (a single check just failed a reserve for that many
49
+ * credits — extend opportunistically instead of waiting for the next
50
+ * sub-watermark check).
51
+ * Returns the in-flight promise so callers can await it or fire-and-forget.
52
+ * Never rejects (it is often fire-and-forget — a rejection would surface
53
+ * as an unhandled promise rejection).
54
+ */
55
+ maybeExtendInBackground(companyId: string, creditTypeId: string, requiredCredits?: number, requestOptions?: CreditsClient.RequestOptions): Promise<LeaseEntry | undefined>;
56
+ private extend;
57
+ /**
58
+ * Release every live lease held in the store. ONLY safe when the store is
59
+ * per-process (in-memory): those leases are exclusively this process's, so
60
+ * releasing them on `close()` returns their unspent remainder to the
61
+ * company balance immediately instead of waiting out the lease expiry. A
62
+ * shared (Redis) store must never do this — sibling pods are still
63
+ * drawing on the same leases — and is excluded by the `list` capability
64
+ * check (only the in-memory store implements it). Best-effort: failures
65
+ * are logged and the lease falls back to server-side expiry.
66
+ */
67
+ releaseAllLocalLeases(): Promise<void>;
68
+ }