atmn 1.1.25 → 2.0.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.
- package/README.md +120 -0
- package/dist/bin.js +23102 -0
- package/dist/index.js +2906 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -74
- package/src/actions/api/callApi.ts +280 -0
- package/src/actions/api/registerApiCommands.ts +121 -0
- package/src/actions/env/fetchOrgInfo.ts +32 -0
- package/src/actions/env/types/orgInfo.ts +18 -0
- package/src/actions/env.ts +94 -0
- package/src/actions/init/runInit.ts +401 -0
- package/src/actions/login/keyless.ts +135 -0
- package/src/actions/login.ts +144 -0
- package/src/actions/pull/appendPlanVersionFixture.ts +373 -0
- package/src/actions/pull/applyPreview.ts +553 -0
- package/src/actions/pull/applySettingsPreview.ts +114 -0
- package/src/actions/pull/changedFixtureKeys.ts +88 -0
- package/src/actions/pull/listSourceFiles.ts +29 -0
- package/src/actions/pull/locateFixture.ts +78 -0
- package/src/actions/pull/resolveCollectionTarget.ts +198 -0
- package/src/actions/pull/rewriteConfig.ts +57 -0
- package/src/actions/pull/scaffoldConfig.ts +118 -0
- package/src/actions/pull.ts +399 -0
- package/src/actions/push/backfillInternalIds.ts +394 -0
- package/src/actions/push/deprecatedFields.ts +55 -0
- package/src/actions/push.ts +294 -0
- package/src/actions/reset/runReset.ts +58 -0
- package/src/actions/sandbox/createSandbox.ts +83 -0
- package/src/actions/sandbox/deleteSandbox.ts +91 -0
- package/src/actions/sandbox/listSandboxes.ts +28 -0
- package/src/actions/sandbox/types/sandboxClient.ts +16 -0
- package/src/actions/sandbox/useSandbox.ts +157 -0
- package/src/actions/sandbox/withSandboxScopeHint.ts +27 -0
- package/src/actions/skills/skills.ts +246 -0
- package/src/auth/announceAuthorizationUrl.ts +26 -0
- package/src/auth/browser/openSystemBrowser.ts +7 -0
- package/src/auth/browser/tryOpenBrowser.ts +17 -0
- package/src/auth/browser/watchLauncher.ts +46 -0
- package/src/auth/buildAuthorizationUrl.ts +36 -0
- package/src/auth/callbackPages.ts +126 -0
- package/src/auth/createOrgApiKeys.ts +46 -0
- package/src/auth/keyless.ts +119 -0
- package/src/auth/oauthConfig.ts +63 -0
- package/src/auth/runOAuthFlow.ts +230 -0
- package/src/auth/types/browserOpener.ts +5 -0
- package/src/auth/types/impersonationTokens.ts +23 -0
- package/src/auth/types/oauthTokens.ts +13 -0
- package/src/auth/types/orgApiKeys.ts +6 -0
- package/src/bin.ts +9 -0
- package/src/cli.ts +648 -0
- package/src/config/configPackageName.ts +9 -0
- package/src/config/legacyConfig.ts +25 -0
- package/src/config/loadConfig.ts +231 -0
- package/src/env/assertSandboxTarget.ts +20 -0
- package/src/env/loadEnv.ts +184 -0
- package/src/env/resolveTarget.ts +134 -0
- package/src/env/sandboxKeyName.ts +18 -0
- package/src/generated/apiRoutes.ts +3787 -0
- package/src/generated/client.ts +51564 -0
- package/src/generated/emit.ts +1163 -0
- package/src/generated/emitRuntime.ts +522 -0
- package/src/generated/features.ts +146 -0
- package/src/generated/labels.ts +29 -0
- package/src/generated/licenses.ts +287 -0
- package/src/generated/lintRules.ts +2207 -0
- package/src/generated/lintRuntime.ts +865 -0
- package/src/generated/plans.ts +1628 -0
- package/src/generated/referralPrograms.ts +22 -0
- package/src/generated/rewards.ts +58 -0
- package/src/generated/settings.ts +21 -0
- package/src/generated/skills.ts +305 -0
- package/src/generated/variants.ts +934 -0
- package/src/generated/wire.ts +334 -0
- package/src/http/autumnFetch.ts +30 -0
- package/src/index.ts +20 -0
- package/src/project/chooseConfigDir.ts +41 -0
- package/src/project/resolveProject.ts +115 -0
- package/src/project/rootMarker.ts +40 -0
- package/src/prompt/prompt.ts +186 -0
- package/src/prompt/select.ts +162 -0
- package/src/render/renderEnv.ts +77 -0
- package/src/render/renderPreview.ts +945 -0
- package/src/render/renderSandboxes.ts +92 -0
- package/src/render/stripTerminalControls.ts +19 -0
- package/src/repo/findRepoRoot.ts +79 -0
- package/src/surgery/appendPropertyEdit.ts +67 -0
- package/src/surgery/appendToArray.ts +87 -0
- package/src/surgery/appendToBinding.ts +19 -0
- package/src/surgery/appendToCollection.ts +40 -0
- package/src/surgery/appendToFixtureArray.ts +71 -0
- package/src/surgery/arrayBinding.ts +30 -0
- package/src/surgery/deleteFixtureLiteral.ts +81 -0
- package/src/surgery/deleteReference.ts +48 -0
- package/src/surgery/ensureBuilderImport.ts +65 -0
- package/src/surgery/findFixture.ts +238 -0
- package/src/surgery/fixtureEdit.ts +156 -0
- package/src/surgery/fixtureLocation.ts +32 -0
- package/src/surgery/insertCollection.ts +86 -0
- package/src/surgery/insertFirstProperty.ts +73 -0
- package/src/surgery/patchFixtureProperty.ts +152 -0
- package/src/surgery/patchSingletonProperty.ts +221 -0
- package/src/surgery/replaceFixture.ts +28 -0
- package/src/surgery/setFixtureProperty.ts +55 -0
- package/src/surgery/staticFixtureRule.ts +48 -0
- package/src/version.ts +5 -0
- package/dist/cli.js +0 -146296
- package/dist/compose/index.js +0 -122
- package/dist/src/compose/builders/builderFunctions.d.ts +0 -84
- package/dist/src/compose/builders/rewardFunctions.d.ts +0 -5
- package/dist/src/compose/builders/variantFunctions.d.ts +0 -2
- package/dist/src/compose/index.d.ts +0 -19
- package/dist/src/compose/models/featureModels.d.ts +0 -262
- package/dist/src/compose/models/index.d.ts +0 -3
- package/dist/src/compose/models/planModels.d.ts +0 -562
- package/dist/src/compose/models/rewardModels.d.ts +0 -52
- package/dist/src/compose/models/variantModels.d.ts +0 -34
- package/readme.md +0 -186
|
@@ -0,0 +1,1628 @@
|
|
|
1
|
+
// Generated by @autumn/atmn-generator from packages/openapi/openapi-internal.yml.
|
|
2
|
+
// Do not edit — run `bun generate` in packages/atmn-generator instead.
|
|
3
|
+
|
|
4
|
+
export type Plan = {
|
|
5
|
+
/** The ID of the plan to create or update. */
|
|
6
|
+
planId: string;
|
|
7
|
+
/** Address an existing row by its stable id. Omit when creating — the server generates one. A differing plan_id alongside it is a rename. */
|
|
8
|
+
internalId?: string;
|
|
9
|
+
/** Display name of the plan. Required when creating. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Optional description of the plan. */
|
|
12
|
+
description?: string | null;
|
|
13
|
+
/** Group identifier for mutually exclusive plans. */
|
|
14
|
+
group?: string;
|
|
15
|
+
/** Whether the plan is an add-on. Defaults to false. */
|
|
16
|
+
addOn?: boolean;
|
|
17
|
+
/** Whether the plan is automatically enabled for new customers. Defaults to false. */
|
|
18
|
+
autoEnable?: boolean;
|
|
19
|
+
/** Archive or unarchive the plan. */
|
|
20
|
+
archived?: boolean;
|
|
21
|
+
/** Take the active pointer. On `new_version`, omit to mint a draft; `true` promotes the minted row immediately. */
|
|
22
|
+
active: boolean;
|
|
23
|
+
/** Payment processors this plan is connected to. Omit to keep. */
|
|
24
|
+
processors?: {
|
|
25
|
+
stripe?: {
|
|
26
|
+
/** Stripe product ID this plan is billed under. */
|
|
27
|
+
productId: string;
|
|
28
|
+
/** Extra Stripe product IDs aliased to this plan. */
|
|
29
|
+
additionalProductIds?: Array<string>;
|
|
30
|
+
} | null;
|
|
31
|
+
revenuecat?: {
|
|
32
|
+
/** Every RevenueCat product that maps to this plan. Replaces the current set. */
|
|
33
|
+
products: Array<{
|
|
34
|
+
/** RevenueCat product ID that grants this plan when purchased. */
|
|
35
|
+
productId: string;
|
|
36
|
+
/** Prepaid quantities granted when this specific RevenueCat product is purchased, in feature units. */
|
|
37
|
+
featureQuantities?: Array<{
|
|
38
|
+
featureId: string;
|
|
39
|
+
quantity?: number;
|
|
40
|
+
}>;
|
|
41
|
+
}>;
|
|
42
|
+
} | null;
|
|
43
|
+
};
|
|
44
|
+
/** Base recurring price. Omit to leave unchanged; null removes it. */
|
|
45
|
+
price?: {
|
|
46
|
+
/** Base price amount for the plan, in major currency units (e.g. dollars). */
|
|
47
|
+
amount: number;
|
|
48
|
+
/** Billing interval (e.g. 'month', 'year'). */
|
|
49
|
+
interval: "one_off" | "week" | "month" | "quarter" | "semi_annual" | "year";
|
|
50
|
+
/** Number of intervals per billing cycle. Defaults to 1. */
|
|
51
|
+
intervalCount?: number;
|
|
52
|
+
/** Base price amounts in additional currencies. The base 'amount' is in the org's default currency. */
|
|
53
|
+
additionalCurrencies?: Array<{
|
|
54
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
55
|
+
currency: string;
|
|
56
|
+
/** Price amount in this currency. Set explicitly per currency, not converted from the base amount. */
|
|
57
|
+
amount: number;
|
|
58
|
+
}>;
|
|
59
|
+
/** Adopt an existing Stripe price instead of creating one. The id must already exist in Stripe. */
|
|
60
|
+
processors?: {
|
|
61
|
+
stripe?: {
|
|
62
|
+
/** Stripe price ID. For prepaid with included > 0 this is the V2 price. */
|
|
63
|
+
priceId: string;
|
|
64
|
+
} | null;
|
|
65
|
+
};
|
|
66
|
+
} | null;
|
|
67
|
+
/** Feature configurations for this plan. */
|
|
68
|
+
items?: Array<{
|
|
69
|
+
/** Bills this many feature units when outstanding overage reaches it. */
|
|
70
|
+
thresholdBilling?: {
|
|
71
|
+
threshold: number;
|
|
72
|
+
} | null;
|
|
73
|
+
/** The ID of the feature to configure. */
|
|
74
|
+
featureId: string;
|
|
75
|
+
/** Number of free units included. Balance resets to this each interval for consumable features. */
|
|
76
|
+
included?: number;
|
|
77
|
+
/** If true, customer has unlimited access to this feature. */
|
|
78
|
+
unlimited?: boolean;
|
|
79
|
+
/** Whether entity-level grants contribute to a shared customer balance. Defaults to false. */
|
|
80
|
+
pooled?: boolean;
|
|
81
|
+
/** Reset configuration for consumable features. Omit for non-consumable features like seats. */
|
|
82
|
+
reset?: {
|
|
83
|
+
/** Interval at which balance resets (e.g. 'month', 'year'). For consumable features only. */
|
|
84
|
+
interval:
|
|
85
|
+
| "one_off"
|
|
86
|
+
| "minute"
|
|
87
|
+
| "hour"
|
|
88
|
+
| "day"
|
|
89
|
+
| "week"
|
|
90
|
+
| "month"
|
|
91
|
+
| "quarter"
|
|
92
|
+
| "semi_annual"
|
|
93
|
+
| "year";
|
|
94
|
+
/** Number of intervals between resets. Defaults to 1. */
|
|
95
|
+
intervalCount?: number;
|
|
96
|
+
};
|
|
97
|
+
/** Pricing for usage beyond included units. Omit for free features. */
|
|
98
|
+
price?: {
|
|
99
|
+
/** Price per billing_units after included usage. Either 'amount' or 'tiers' is required. */
|
|
100
|
+
amount?: number;
|
|
101
|
+
/** Amounts in additional currencies for this flat price. The base 'amount' is in the org's default currency. Only valid with 'amount', not 'tiers'. */
|
|
102
|
+
additionalCurrencies?: Array<{
|
|
103
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
104
|
+
currency: string;
|
|
105
|
+
/** Price amount in this currency. Set explicitly per currency, not converted from the base amount. */
|
|
106
|
+
amount: number;
|
|
107
|
+
}>;
|
|
108
|
+
/** Tiered pricing. Either 'amount' or 'tiers' is required. */
|
|
109
|
+
tiers?: Array<{
|
|
110
|
+
to: number | "inf";
|
|
111
|
+
amount?: number;
|
|
112
|
+
flatAmount?: number;
|
|
113
|
+
/** Per-currency amounts for this tier. Tier boundaries ('to') are shared across all currencies. */
|
|
114
|
+
additionalCurrencies?: Array<{
|
|
115
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
116
|
+
currency: string;
|
|
117
|
+
/** Per-unit amount for this tier in this currency. */
|
|
118
|
+
amount?: number;
|
|
119
|
+
/** Flat amount for this tier in this currency, if the tier uses one. */
|
|
120
|
+
flatAmount?: number;
|
|
121
|
+
}>;
|
|
122
|
+
}>;
|
|
123
|
+
tierBehavior?: "graduated" | "volume";
|
|
124
|
+
/** Billing interval. For consumable features, should match reset.interval. */
|
|
125
|
+
interval:
|
|
126
|
+
| "one_off"
|
|
127
|
+
| "week"
|
|
128
|
+
| "month"
|
|
129
|
+
| "quarter"
|
|
130
|
+
| "semi_annual"
|
|
131
|
+
| "year";
|
|
132
|
+
/** Number of intervals per billing cycle. Defaults to 1. */
|
|
133
|
+
intervalCount?: number;
|
|
134
|
+
/** Units per price increment. Usage is rounded UP when billed (e.g. billing_units=100 means 101 rounds to 200). Defaults to 1. */
|
|
135
|
+
billingUnits?: number;
|
|
136
|
+
/** 'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go. */
|
|
137
|
+
billingMethod: "prepaid" | "usage_based";
|
|
138
|
+
/** Only pulled as `prorated_legacy` for a price still on the legacy immediate-proration behavior, alongside its `proration` knobs. */
|
|
139
|
+
allocatedBilling?: "arrear" | "prorated_legacy";
|
|
140
|
+
/** Max units purchasable beyond included. E.g. included=100, max_purchase=300 allows 400 total. Null for no limit. */
|
|
141
|
+
maxPurchase?: number | null;
|
|
142
|
+
/** Adopt an existing Stripe price instead of creating one. The id must already exist in Stripe. */
|
|
143
|
+
processors?: {
|
|
144
|
+
stripe?: {
|
|
145
|
+
/** Stripe price ID. For prepaid with included > 0 this is the V2 price. */
|
|
146
|
+
priceId: string;
|
|
147
|
+
} | null;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
/** Proration settings for prepaid features. Controls mid-cycle quantity change billing. */
|
|
151
|
+
proration?: {
|
|
152
|
+
/** Billing behavior when quantity increases mid-cycle. */
|
|
153
|
+
onIncrease:
|
|
154
|
+
| "bill_immediately"
|
|
155
|
+
| "prorate_immediately"
|
|
156
|
+
| "prorate_next_cycle"
|
|
157
|
+
| "bill_next_cycle";
|
|
158
|
+
/** Credit behavior when quantity decreases mid-cycle. */
|
|
159
|
+
onDecrease:
|
|
160
|
+
| "prorate"
|
|
161
|
+
| "prorate_immediately"
|
|
162
|
+
| "prorate_next_cycle"
|
|
163
|
+
| "none"
|
|
164
|
+
| "no_prorations";
|
|
165
|
+
};
|
|
166
|
+
/** Rollover config for unused units. If set, unused included units carry over. */
|
|
167
|
+
rollover?: {
|
|
168
|
+
/** Max rollover units. Omit for unlimited rollover. */
|
|
169
|
+
max?: number;
|
|
170
|
+
/** Maximum rollover as a percentage (0-100) of included + prepaid grant. Mutually exclusive with max. */
|
|
171
|
+
maxPercentage?: number;
|
|
172
|
+
/** When rolled over units expire. */
|
|
173
|
+
expiryDurationType: "month" | "forever";
|
|
174
|
+
/** Number of periods before expiry. */
|
|
175
|
+
expiryDurationLength?: number;
|
|
176
|
+
};
|
|
177
|
+
/** Overrides fields of this item's feature for customers on this plan (e.g. a credit system's credit_schema). */
|
|
178
|
+
featureOverride?: {
|
|
179
|
+
/** For credit system features: replaces the feature's credit_schema entirely for customers on this plan. */
|
|
180
|
+
creditSchema?: Array<
|
|
181
|
+
| {
|
|
182
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
183
|
+
meteredFeatureId: string;
|
|
184
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
185
|
+
billingUnits?: number;
|
|
186
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
187
|
+
dimensions?: Record<
|
|
188
|
+
string,
|
|
189
|
+
| {
|
|
190
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
191
|
+
match: Record<string, string | number | boolean>;
|
|
192
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
193
|
+
priority?: number;
|
|
194
|
+
tierBehavior: "graduated";
|
|
195
|
+
tiers: Array<{
|
|
196
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
197
|
+
to: number | "inf";
|
|
198
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
199
|
+
creditCost: number;
|
|
200
|
+
}>;
|
|
201
|
+
}
|
|
202
|
+
| {
|
|
203
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
204
|
+
match: Record<string, string | number | boolean>;
|
|
205
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
206
|
+
priority?: number;
|
|
207
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
208
|
+
creditCost: number;
|
|
209
|
+
}
|
|
210
|
+
>;
|
|
211
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
212
|
+
multipliers?: Record<
|
|
213
|
+
string,
|
|
214
|
+
{
|
|
215
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
216
|
+
match: Record<string, string | number | boolean>;
|
|
217
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
218
|
+
factor?: number;
|
|
219
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
220
|
+
add?: number;
|
|
221
|
+
}
|
|
222
|
+
>;
|
|
223
|
+
tierBehavior: "graduated";
|
|
224
|
+
tiers: Array<{
|
|
225
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
226
|
+
to: number | "inf";
|
|
227
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
228
|
+
creditCost: number;
|
|
229
|
+
}>;
|
|
230
|
+
}
|
|
231
|
+
| {
|
|
232
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
233
|
+
meteredFeatureId: string;
|
|
234
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
235
|
+
billingUnits?: number;
|
|
236
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
237
|
+
dimensions?: Record<
|
|
238
|
+
string,
|
|
239
|
+
| {
|
|
240
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
241
|
+
match: Record<string, string | number | boolean>;
|
|
242
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
243
|
+
priority?: number;
|
|
244
|
+
tierBehavior: "graduated";
|
|
245
|
+
tiers: Array<{
|
|
246
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
247
|
+
to: number | "inf";
|
|
248
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
249
|
+
creditCost: number;
|
|
250
|
+
}>;
|
|
251
|
+
}
|
|
252
|
+
| {
|
|
253
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
254
|
+
match: Record<string, string | number | boolean>;
|
|
255
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
256
|
+
priority?: number;
|
|
257
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
258
|
+
creditCost: number;
|
|
259
|
+
}
|
|
260
|
+
>;
|
|
261
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
262
|
+
multipliers?: Record<
|
|
263
|
+
string,
|
|
264
|
+
{
|
|
265
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
266
|
+
match: Record<string, string | number | boolean>;
|
|
267
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
268
|
+
factor?: number;
|
|
269
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
270
|
+
add?: number;
|
|
271
|
+
}
|
|
272
|
+
>;
|
|
273
|
+
/** Credits consumed per billing-unit group. */
|
|
274
|
+
creditCost: number;
|
|
275
|
+
}
|
|
276
|
+
>;
|
|
277
|
+
/** For AI credit system features: replaces the feature's markup chain entirely for customers on this plan. An unset level means no markup at that level rather than inheriting the feature's. */
|
|
278
|
+
markups?: {
|
|
279
|
+
/** Default percentage markup for customers on this plan. Use -100 to make usage free. */
|
|
280
|
+
defaultMarkup?: number;
|
|
281
|
+
/** Per-provider markup percentages for customers on this plan. */
|
|
282
|
+
providerMarkups?: Record<
|
|
283
|
+
string,
|
|
284
|
+
{
|
|
285
|
+
markup: number;
|
|
286
|
+
}
|
|
287
|
+
> | null;
|
|
288
|
+
/** Per-model markup overrides for customers on this plan. */
|
|
289
|
+
modelMarkups?: Record<
|
|
290
|
+
string,
|
|
291
|
+
{
|
|
292
|
+
markup?: number;
|
|
293
|
+
inputCost?: number;
|
|
294
|
+
outputCost?: number;
|
|
295
|
+
}
|
|
296
|
+
> | null;
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
/** @deprecated Per-entity items are deprecated but existing catalogs carry them, so a config must keep round-tripping the field. */
|
|
300
|
+
entityFeatureId?: string;
|
|
301
|
+
}>;
|
|
302
|
+
/** Free trial. Omit to leave unchanged; null removes it. */
|
|
303
|
+
freeTrial?: {
|
|
304
|
+
/** Number of duration_type periods the trial lasts. */
|
|
305
|
+
durationLength: number;
|
|
306
|
+
/** Unit of time for the trial ('day', 'month', 'year'). Defaults to "month". */
|
|
307
|
+
durationType?: "day" | "month" | "year";
|
|
308
|
+
/** If true, a payment method is required to start the trial and the customer is charged when it ends. Defaults to false. */
|
|
309
|
+
cardRequired?: boolean;
|
|
310
|
+
/** Behavior when the trial ends. 'bill' charges the customer (default). 'revert' expires the trial and restores the customer's previous plan. */
|
|
311
|
+
onEnd?: "bill" | "revert";
|
|
312
|
+
} | null;
|
|
313
|
+
/** Miscellaneous plan-level configuration flags. */
|
|
314
|
+
config?: {
|
|
315
|
+
/** If true, entitlements attached to this plan will still reset on schedule even when the customer's product is in a past_due state. Defaults to false. */
|
|
316
|
+
ignorePastDue?: boolean;
|
|
317
|
+
};
|
|
318
|
+
/** Plan-level billing controls used as customer defaults. */
|
|
319
|
+
billingControls?: {
|
|
320
|
+
/** List of auto top-up configurations per feature. Defaults to []. */
|
|
321
|
+
autoTopups?: Array<{
|
|
322
|
+
/** The ID of the feature (credit balance) to auto top-up. */
|
|
323
|
+
featureId: string;
|
|
324
|
+
/** Whether auto top-up is enabled. Defaults to false. */
|
|
325
|
+
enabled?: boolean;
|
|
326
|
+
/** When the balance drops below this threshold, an auto top-up will be purchased. */
|
|
327
|
+
threshold: number;
|
|
328
|
+
/** Amount of credits to add per auto top-up. */
|
|
329
|
+
quantity: number;
|
|
330
|
+
/** Optional rate limit to cap how often auto top-ups occur. Pass count to set the current window's consumed top-ups. */
|
|
331
|
+
purchaseLimit?: {
|
|
332
|
+
/** The time interval for the purchase limit window. */
|
|
333
|
+
interval: "hour" | "day" | "week" | "month";
|
|
334
|
+
/** Number of intervals in the purchase limit window. Defaults to 1. */
|
|
335
|
+
intervalCount?: number;
|
|
336
|
+
/** Maximum number of auto top-ups allowed within the interval. */
|
|
337
|
+
limit: number;
|
|
338
|
+
/** Set the current window's consumed auto top-up count. Omit to leave runtime state unchanged. */
|
|
339
|
+
count?: number;
|
|
340
|
+
};
|
|
341
|
+
/** When true, auto top-up creates a send_invoice invoice instead of auto-charging. */
|
|
342
|
+
invoiceMode?: boolean;
|
|
343
|
+
}>;
|
|
344
|
+
/** List of overage spend limits per feature (caps overage spend). Defaults to []. */
|
|
345
|
+
spendLimits?: Array<{
|
|
346
|
+
/** Optional feature ID this spend limit applies to. */
|
|
347
|
+
featureId?: string;
|
|
348
|
+
/** Whether the overage spend limit is enabled. Defaults to false. */
|
|
349
|
+
enabled?: boolean;
|
|
350
|
+
/** How overage_limit is interpreted: an absolute overage cap (default) or a percentage of the main-plan allowance. */
|
|
351
|
+
limitType?: "absolute" | "usage_percentage";
|
|
352
|
+
/** Overage cap for the feature: absolute units, or a percent (e.g. 120) when limit_type is usage_percentage. */
|
|
353
|
+
overageLimit?: number;
|
|
354
|
+
/** When true, overage for this feature is not posted to Stripe. Usage tracking and balance resets still behave normally. */
|
|
355
|
+
skipOverageBilling?: boolean;
|
|
356
|
+
}>;
|
|
357
|
+
/** List of hard usage caps per feature (max units per interval). Defaults to []. */
|
|
358
|
+
usageLimits?: Array<{
|
|
359
|
+
/** The feature this usage limit applies to. */
|
|
360
|
+
featureId: string;
|
|
361
|
+
/** Whether this usage limit is enabled. Defaults to true. */
|
|
362
|
+
enabled?: boolean;
|
|
363
|
+
/** Maximum units allowed per interval. */
|
|
364
|
+
limit: number;
|
|
365
|
+
/** Interval for the cap, aligned to the customer's billing cycle. */
|
|
366
|
+
interval: "day" | "week" | "month" | "year";
|
|
367
|
+
/** Window alignment. 'billing_cycle' phases the interval to the customer's renewal time; 'utc' aligns to the UTC calendar. */
|
|
368
|
+
anchor?: "billing_cycle" | "utc";
|
|
369
|
+
/** When set, only usage from events whose properties match counts toward this cap. Omit to count all usage of the feature. */
|
|
370
|
+
filter?: {
|
|
371
|
+
properties: Record<string, string | number | boolean>;
|
|
372
|
+
};
|
|
373
|
+
}>;
|
|
374
|
+
/** List of usage alert configurations per feature. Defaults to []. */
|
|
375
|
+
usageAlerts?: Array<{
|
|
376
|
+
/** The feature ID this alert applies to. */
|
|
377
|
+
featureId?: string;
|
|
378
|
+
/** Whether this usage alert is enabled. Defaults to true. */
|
|
379
|
+
enabled?: boolean;
|
|
380
|
+
/** The threshold value that triggers the alert. For usage or remaining, this is an absolute count. For usage_percentage or remaining_percentage, this is a percentage (0-100). */
|
|
381
|
+
threshold: number;
|
|
382
|
+
/** Whether the threshold is an absolute count or a percentage of the usage allowance or remaining balance. */
|
|
383
|
+
thresholdType:
|
|
384
|
+
| "usage"
|
|
385
|
+
| "usage_percentage"
|
|
386
|
+
| "remaining"
|
|
387
|
+
| "remaining_percentage";
|
|
388
|
+
/** What 100% means. balance: every grant on the feature. included: the plan allowance only. recurring: grants that reset. usage_limit: the cap of the usage limit with the same feature and filter. Defaults to "balance". */
|
|
389
|
+
basis?: "balance" | "included" | "recurring" | "usage_limit";
|
|
390
|
+
/** Only valid with basis usage_limit. Points the alert at the usage limit carrying the same filter. */
|
|
391
|
+
filter?: {
|
|
392
|
+
properties: Record<string, string | number | boolean>;
|
|
393
|
+
};
|
|
394
|
+
/** Optional user-defined label to distinguish multiple alerts on the same feature. */
|
|
395
|
+
name?: string;
|
|
396
|
+
}>;
|
|
397
|
+
/** List of overage allowed controls per feature. When enabled, usage can exceed balance. Defaults to []. */
|
|
398
|
+
overageAllowed?: Array<{
|
|
399
|
+
/** The feature ID this overage allowed control applies to. */
|
|
400
|
+
featureId: string;
|
|
401
|
+
/** Whether overage is allowed for this feature. Defaults to false. */
|
|
402
|
+
enabled?: boolean;
|
|
403
|
+
}>;
|
|
404
|
+
};
|
|
405
|
+
/** Arbitrary key-value metadata shared across all versions. Defaults to {}. */
|
|
406
|
+
metadata?: Record<string, unknown>;
|
|
407
|
+
/** Target this version row by slug. At most one of `version` / `version_slug`; omit both to target the active row. Defaults to "vN", N being the server's version number, which counts in creation order; state it explicitly on every history row so a nuke-and-repush or a sandbox-to-prod push keeps the same names even though the numbers may differ. */
|
|
408
|
+
versionSlug?: string;
|
|
409
|
+
/** When false, skip Stripe product/price creation on create. */
|
|
410
|
+
createInStripe?: boolean;
|
|
411
|
+
/** Declared overlays on variants of this plan. Omit to leave them unchanged. Follow is `propagate.variants`, not presence here. */
|
|
412
|
+
variants?: Array<{
|
|
413
|
+
/** The variant plan this overlay applies to. */
|
|
414
|
+
variantPlanId: string;
|
|
415
|
+
/** Address an existing variant row by its stable id, instead of by plan id and version. */
|
|
416
|
+
internalId?: string;
|
|
417
|
+
/** Which version of the variant this overlay targets. At most one of `version` / `version_slug`; omit both to target latest. */
|
|
418
|
+
version?: number;
|
|
419
|
+
/** Which version of the variant this overlay targets, by slug. Same pin as `version`; omit both to target latest. Defaults to "vN", N being the server's version number; state it explicitly on every variant history row. */
|
|
420
|
+
versionSlug?: string;
|
|
421
|
+
/** Display name when creating the variant if it does not exist. */
|
|
422
|
+
name: string;
|
|
423
|
+
/** Archive or unarchive this variant. Omit to leave archived state unchanged. */
|
|
424
|
+
archived?: boolean;
|
|
425
|
+
/** Slug for the row this variant mints. Omit to inherit the base's `new_version_slug`, then `v{n}`. Ignored when this entry resolves to an existing row. */
|
|
426
|
+
newVersionSlug?: string;
|
|
427
|
+
/** Overrides the base plan's processors for this variant. Omit to inherit when the base processors change. */
|
|
428
|
+
processors?: {
|
|
429
|
+
stripe?: {
|
|
430
|
+
/** Stripe product ID this plan is billed under. */
|
|
431
|
+
productId: string;
|
|
432
|
+
/** Extra Stripe product IDs aliased to this plan. */
|
|
433
|
+
additionalProductIds?: Array<string>;
|
|
434
|
+
} | null;
|
|
435
|
+
revenuecat?: {
|
|
436
|
+
/** Every RevenueCat product that maps to this plan. Replaces the current set. */
|
|
437
|
+
products: Array<{
|
|
438
|
+
/** RevenueCat product ID that grants this plan when purchased. */
|
|
439
|
+
productId: string;
|
|
440
|
+
/** Prepaid quantities granted when this specific RevenueCat product is purchased, in feature units. */
|
|
441
|
+
featureQuantities?: Array<{
|
|
442
|
+
featureId: string;
|
|
443
|
+
quantity?: number;
|
|
444
|
+
}>;
|
|
445
|
+
}>;
|
|
446
|
+
} | null;
|
|
447
|
+
};
|
|
448
|
+
/** Pointer write for this nested variant. Omit to link it to this base; `null` detaches it. A string must be this plan's id. */
|
|
449
|
+
baseVariantId?: string | null;
|
|
450
|
+
/** Declared overlay on this variant. `items` is PUT (replaces the list); `add_items` / `remove_items` are PATCH. Independent of `propagate`. Blocked on an archived variant unless `archived` is false in the same entry. */
|
|
451
|
+
customize?: {
|
|
452
|
+
/** Override the base price of the plan. Pass null to remove the base price. */
|
|
453
|
+
price?: {
|
|
454
|
+
/** Base price amount for the plan, in major currency units (e.g. dollars). */
|
|
455
|
+
amount: number;
|
|
456
|
+
/** Billing interval (e.g. 'month', 'year'). */
|
|
457
|
+
interval:
|
|
458
|
+
| "one_off"
|
|
459
|
+
| "week"
|
|
460
|
+
| "month"
|
|
461
|
+
| "quarter"
|
|
462
|
+
| "semi_annual"
|
|
463
|
+
| "year";
|
|
464
|
+
/** Number of intervals per billing cycle. Defaults to 1. */
|
|
465
|
+
intervalCount?: number;
|
|
466
|
+
/** Base price amounts in additional currencies. The base 'amount' is in the org's default currency. */
|
|
467
|
+
additionalCurrencies?: Array<{
|
|
468
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
469
|
+
currency: string;
|
|
470
|
+
/** Price amount in this currency. Set explicitly per currency, not converted from the base amount. */
|
|
471
|
+
amount: number;
|
|
472
|
+
}>;
|
|
473
|
+
} | null;
|
|
474
|
+
/** Override the items in the plan (PUT-style — replaces all existing items). Mutually exclusive with add_items / remove_items / deprecated update_items. */
|
|
475
|
+
items?: Array<{
|
|
476
|
+
/** Bills this many feature units when outstanding overage reaches it. */
|
|
477
|
+
thresholdBilling?: {
|
|
478
|
+
threshold: number;
|
|
479
|
+
} | null;
|
|
480
|
+
/** The ID of the feature to configure. */
|
|
481
|
+
featureId: string;
|
|
482
|
+
/** Number of free units included. Balance resets to this each interval for consumable features. */
|
|
483
|
+
included?: number;
|
|
484
|
+
/** If true, customer has unlimited access to this feature. */
|
|
485
|
+
unlimited?: boolean;
|
|
486
|
+
/** Whether entity-level grants contribute to a shared customer balance. Defaults to false. */
|
|
487
|
+
pooled?: boolean;
|
|
488
|
+
/** Reset configuration for consumable features. Omit for non-consumable features like seats. */
|
|
489
|
+
reset?: {
|
|
490
|
+
/** Interval at which balance resets (e.g. 'month', 'year'). For consumable features only. */
|
|
491
|
+
interval:
|
|
492
|
+
| "one_off"
|
|
493
|
+
| "minute"
|
|
494
|
+
| "hour"
|
|
495
|
+
| "day"
|
|
496
|
+
| "week"
|
|
497
|
+
| "month"
|
|
498
|
+
| "quarter"
|
|
499
|
+
| "semi_annual"
|
|
500
|
+
| "year";
|
|
501
|
+
/** Number of intervals between resets. Defaults to 1. */
|
|
502
|
+
intervalCount?: number;
|
|
503
|
+
};
|
|
504
|
+
/** Pricing for usage beyond included units. Omit for free features. */
|
|
505
|
+
price?: {
|
|
506
|
+
/** Price per billing_units after included usage. Either 'amount' or 'tiers' is required. */
|
|
507
|
+
amount?: number;
|
|
508
|
+
/** Amounts in additional currencies for this flat price. The base 'amount' is in the org's default currency. Only valid with 'amount', not 'tiers'. */
|
|
509
|
+
additionalCurrencies?: Array<{
|
|
510
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
511
|
+
currency: string;
|
|
512
|
+
/** Price amount in this currency. Set explicitly per currency, not converted from the base amount. */
|
|
513
|
+
amount: number;
|
|
514
|
+
}>;
|
|
515
|
+
/** Tiered pricing. Either 'amount' or 'tiers' is required. */
|
|
516
|
+
tiers?: Array<{
|
|
517
|
+
to: number | "inf";
|
|
518
|
+
amount?: number;
|
|
519
|
+
flatAmount?: number;
|
|
520
|
+
/** Per-currency amounts for this tier. Tier boundaries ('to') are shared across all currencies. */
|
|
521
|
+
additionalCurrencies?: Array<{
|
|
522
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
523
|
+
currency: string;
|
|
524
|
+
/** Per-unit amount for this tier in this currency. */
|
|
525
|
+
amount?: number;
|
|
526
|
+
/** Flat amount for this tier in this currency, if the tier uses one. */
|
|
527
|
+
flatAmount?: number;
|
|
528
|
+
}>;
|
|
529
|
+
}>;
|
|
530
|
+
tierBehavior?: "graduated" | "volume";
|
|
531
|
+
/** Billing interval. For consumable features, should match reset.interval. */
|
|
532
|
+
interval:
|
|
533
|
+
| "one_off"
|
|
534
|
+
| "week"
|
|
535
|
+
| "month"
|
|
536
|
+
| "quarter"
|
|
537
|
+
| "semi_annual"
|
|
538
|
+
| "year";
|
|
539
|
+
/** Number of intervals per billing cycle. Defaults to 1. */
|
|
540
|
+
intervalCount?: number;
|
|
541
|
+
/** Units per price increment. Usage is rounded UP when billed (e.g. billing_units=100 means 101 rounds to 200). Defaults to 1. */
|
|
542
|
+
billingUnits?: number;
|
|
543
|
+
/** 'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go. */
|
|
544
|
+
billingMethod: "prepaid" | "usage_based";
|
|
545
|
+
allocatedBilling?: "arrear" | "prorated_legacy";
|
|
546
|
+
/** Max units purchasable beyond included. E.g. included=100, max_purchase=300 allows 400 total. Null for no limit. */
|
|
547
|
+
maxPurchase?: number | null;
|
|
548
|
+
};
|
|
549
|
+
/** Proration settings for prepaid features. Controls mid-cycle quantity change billing. */
|
|
550
|
+
proration?: {
|
|
551
|
+
/** Billing behavior when quantity increases mid-cycle. */
|
|
552
|
+
onIncrease:
|
|
553
|
+
| "bill_immediately"
|
|
554
|
+
| "prorate_immediately"
|
|
555
|
+
| "prorate_next_cycle"
|
|
556
|
+
| "bill_next_cycle";
|
|
557
|
+
/** Credit behavior when quantity decreases mid-cycle. */
|
|
558
|
+
onDecrease:
|
|
559
|
+
| "prorate"
|
|
560
|
+
| "prorate_immediately"
|
|
561
|
+
| "prorate_next_cycle"
|
|
562
|
+
| "none"
|
|
563
|
+
| "no_prorations";
|
|
564
|
+
};
|
|
565
|
+
/** Rollover config for unused units. If set, unused included units carry over. */
|
|
566
|
+
rollover?: {
|
|
567
|
+
/** Max rollover units. Omit for unlimited rollover. */
|
|
568
|
+
max?: number;
|
|
569
|
+
/** Maximum rollover as a percentage (0-100) of included + prepaid grant. Mutually exclusive with max. */
|
|
570
|
+
maxPercentage?: number;
|
|
571
|
+
/** When rolled over units expire. */
|
|
572
|
+
expiryDurationType: "month" | "forever";
|
|
573
|
+
/** Number of periods before expiry. */
|
|
574
|
+
expiryDurationLength?: number;
|
|
575
|
+
};
|
|
576
|
+
/** Overrides fields of this item's feature for customers on this plan (e.g. a credit system's credit_schema). */
|
|
577
|
+
featureOverride?: {
|
|
578
|
+
/** For credit system features: replaces the feature's credit_schema entirely for customers on this plan. */
|
|
579
|
+
creditSchema?: Array<
|
|
580
|
+
| {
|
|
581
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
582
|
+
meteredFeatureId: string;
|
|
583
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
584
|
+
billingUnits?: number;
|
|
585
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
586
|
+
dimensions?: Record<
|
|
587
|
+
string,
|
|
588
|
+
| {
|
|
589
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
590
|
+
match: Record<string, string | number | boolean>;
|
|
591
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
592
|
+
priority?: number;
|
|
593
|
+
tierBehavior: "graduated";
|
|
594
|
+
tiers: Array<{
|
|
595
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
596
|
+
to: number | "inf";
|
|
597
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
598
|
+
creditCost: number;
|
|
599
|
+
}>;
|
|
600
|
+
}
|
|
601
|
+
| {
|
|
602
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
603
|
+
match: Record<string, string | number | boolean>;
|
|
604
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
605
|
+
priority?: number;
|
|
606
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
607
|
+
creditCost: number;
|
|
608
|
+
}
|
|
609
|
+
>;
|
|
610
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
611
|
+
multipliers?: Record<
|
|
612
|
+
string,
|
|
613
|
+
{
|
|
614
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
615
|
+
match: Record<string, string | number | boolean>;
|
|
616
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
617
|
+
factor?: number;
|
|
618
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
619
|
+
add?: number;
|
|
620
|
+
}
|
|
621
|
+
>;
|
|
622
|
+
tierBehavior: "graduated";
|
|
623
|
+
tiers: Array<{
|
|
624
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
625
|
+
to: number | "inf";
|
|
626
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
627
|
+
creditCost: number;
|
|
628
|
+
}>;
|
|
629
|
+
}
|
|
630
|
+
| {
|
|
631
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
632
|
+
meteredFeatureId: string;
|
|
633
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
634
|
+
billingUnits?: number;
|
|
635
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
636
|
+
dimensions?: Record<
|
|
637
|
+
string,
|
|
638
|
+
| {
|
|
639
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
640
|
+
match: Record<string, string | number | boolean>;
|
|
641
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
642
|
+
priority?: number;
|
|
643
|
+
tierBehavior: "graduated";
|
|
644
|
+
tiers: Array<{
|
|
645
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
646
|
+
to: number | "inf";
|
|
647
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
648
|
+
creditCost: number;
|
|
649
|
+
}>;
|
|
650
|
+
}
|
|
651
|
+
| {
|
|
652
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
653
|
+
match: Record<string, string | number | boolean>;
|
|
654
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
655
|
+
priority?: number;
|
|
656
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
657
|
+
creditCost: number;
|
|
658
|
+
}
|
|
659
|
+
>;
|
|
660
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
661
|
+
multipliers?: Record<
|
|
662
|
+
string,
|
|
663
|
+
{
|
|
664
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
665
|
+
match: Record<string, string | number | boolean>;
|
|
666
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
667
|
+
factor?: number;
|
|
668
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
669
|
+
add?: number;
|
|
670
|
+
}
|
|
671
|
+
>;
|
|
672
|
+
/** Credits consumed per billing-unit group. */
|
|
673
|
+
creditCost: number;
|
|
674
|
+
}
|
|
675
|
+
>;
|
|
676
|
+
/** For AI credit system features: replaces the feature's markup chain entirely for customers on this plan. An unset level means no markup at that level rather than inheriting the feature's. */
|
|
677
|
+
markups?: {
|
|
678
|
+
/** Default percentage markup for customers on this plan. Use -100 to make usage free. */
|
|
679
|
+
defaultMarkup?: number;
|
|
680
|
+
/** Per-provider markup percentages for customers on this plan. */
|
|
681
|
+
providerMarkups?: Record<
|
|
682
|
+
string,
|
|
683
|
+
{
|
|
684
|
+
markup: number;
|
|
685
|
+
}
|
|
686
|
+
> | null;
|
|
687
|
+
/** Per-model markup overrides for customers on this plan. */
|
|
688
|
+
modelMarkups?: Record<
|
|
689
|
+
string,
|
|
690
|
+
{
|
|
691
|
+
markup?: number;
|
|
692
|
+
inputCost?: number;
|
|
693
|
+
outputCost?: number;
|
|
694
|
+
}
|
|
695
|
+
> | null;
|
|
696
|
+
};
|
|
697
|
+
};
|
|
698
|
+
entityFeatureId?: string;
|
|
699
|
+
}>;
|
|
700
|
+
/** Items to add to the plan. */
|
|
701
|
+
addItems?: Array<{
|
|
702
|
+
/** Bills this many feature units when outstanding overage reaches it. */
|
|
703
|
+
thresholdBilling?: {
|
|
704
|
+
threshold: number;
|
|
705
|
+
} | null;
|
|
706
|
+
/** The ID of the feature to configure. */
|
|
707
|
+
featureId: string;
|
|
708
|
+
/** Number of free units included. Balance resets to this each interval for consumable features. */
|
|
709
|
+
included?: number;
|
|
710
|
+
/** If true, customer has unlimited access to this feature. */
|
|
711
|
+
unlimited?: boolean;
|
|
712
|
+
/** Whether entity-level grants contribute to a shared customer balance. Defaults to false. */
|
|
713
|
+
pooled?: boolean;
|
|
714
|
+
/** Reset configuration for consumable features. Omit for non-consumable features like seats. */
|
|
715
|
+
reset?: {
|
|
716
|
+
/** Interval at which balance resets (e.g. 'month', 'year'). For consumable features only. */
|
|
717
|
+
interval:
|
|
718
|
+
| "one_off"
|
|
719
|
+
| "minute"
|
|
720
|
+
| "hour"
|
|
721
|
+
| "day"
|
|
722
|
+
| "week"
|
|
723
|
+
| "month"
|
|
724
|
+
| "quarter"
|
|
725
|
+
| "semi_annual"
|
|
726
|
+
| "year";
|
|
727
|
+
/** Number of intervals between resets. Defaults to 1. */
|
|
728
|
+
intervalCount?: number;
|
|
729
|
+
};
|
|
730
|
+
/** Pricing for usage beyond included units. Omit for free features. */
|
|
731
|
+
price?: {
|
|
732
|
+
/** Price per billing_units after included usage. Either 'amount' or 'tiers' is required. */
|
|
733
|
+
amount?: number;
|
|
734
|
+
/** Amounts in additional currencies for this flat price. The base 'amount' is in the org's default currency. Only valid with 'amount', not 'tiers'. */
|
|
735
|
+
additionalCurrencies?: Array<{
|
|
736
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
737
|
+
currency: string;
|
|
738
|
+
/** Price amount in this currency. Set explicitly per currency, not converted from the base amount. */
|
|
739
|
+
amount: number;
|
|
740
|
+
}>;
|
|
741
|
+
/** Tiered pricing. Either 'amount' or 'tiers' is required. */
|
|
742
|
+
tiers?: Array<{
|
|
743
|
+
to: number | "inf";
|
|
744
|
+
amount?: number;
|
|
745
|
+
flatAmount?: number;
|
|
746
|
+
/** Per-currency amounts for this tier. Tier boundaries ('to') are shared across all currencies. */
|
|
747
|
+
additionalCurrencies?: Array<{
|
|
748
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
749
|
+
currency: string;
|
|
750
|
+
/** Per-unit amount for this tier in this currency. */
|
|
751
|
+
amount?: number;
|
|
752
|
+
/** Flat amount for this tier in this currency, if the tier uses one. */
|
|
753
|
+
flatAmount?: number;
|
|
754
|
+
}>;
|
|
755
|
+
}>;
|
|
756
|
+
tierBehavior?: "graduated" | "volume";
|
|
757
|
+
/** Billing interval. For consumable features, should match reset.interval. */
|
|
758
|
+
interval:
|
|
759
|
+
| "one_off"
|
|
760
|
+
| "week"
|
|
761
|
+
| "month"
|
|
762
|
+
| "quarter"
|
|
763
|
+
| "semi_annual"
|
|
764
|
+
| "year";
|
|
765
|
+
/** Number of intervals per billing cycle. Defaults to 1. */
|
|
766
|
+
intervalCount?: number;
|
|
767
|
+
/** Units per price increment. Usage is rounded UP when billed (e.g. billing_units=100 means 101 rounds to 200). Defaults to 1. */
|
|
768
|
+
billingUnits?: number;
|
|
769
|
+
/** 'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go. */
|
|
770
|
+
billingMethod: "prepaid" | "usage_based";
|
|
771
|
+
allocatedBilling?: "arrear" | "prorated_legacy";
|
|
772
|
+
/** Max units purchasable beyond included. E.g. included=100, max_purchase=300 allows 400 total. Null for no limit. */
|
|
773
|
+
maxPurchase?: number | null;
|
|
774
|
+
};
|
|
775
|
+
/** Proration settings for prepaid features. Controls mid-cycle quantity change billing. */
|
|
776
|
+
proration?: {
|
|
777
|
+
/** Billing behavior when quantity increases mid-cycle. */
|
|
778
|
+
onIncrease:
|
|
779
|
+
| "bill_immediately"
|
|
780
|
+
| "prorate_immediately"
|
|
781
|
+
| "prorate_next_cycle"
|
|
782
|
+
| "bill_next_cycle";
|
|
783
|
+
/** Credit behavior when quantity decreases mid-cycle. */
|
|
784
|
+
onDecrease:
|
|
785
|
+
| "prorate"
|
|
786
|
+
| "prorate_immediately"
|
|
787
|
+
| "prorate_next_cycle"
|
|
788
|
+
| "none"
|
|
789
|
+
| "no_prorations";
|
|
790
|
+
};
|
|
791
|
+
/** Rollover config for unused units. If set, unused included units carry over. */
|
|
792
|
+
rollover?: {
|
|
793
|
+
/** Max rollover units. Omit for unlimited rollover. */
|
|
794
|
+
max?: number;
|
|
795
|
+
/** Maximum rollover as a percentage (0-100) of included + prepaid grant. Mutually exclusive with max. */
|
|
796
|
+
maxPercentage?: number;
|
|
797
|
+
/** When rolled over units expire. */
|
|
798
|
+
expiryDurationType: "month" | "forever";
|
|
799
|
+
/** Number of periods before expiry. */
|
|
800
|
+
expiryDurationLength?: number;
|
|
801
|
+
};
|
|
802
|
+
/** Overrides fields of this item's feature for customers on this plan (e.g. a credit system's credit_schema). */
|
|
803
|
+
featureOverride?: {
|
|
804
|
+
/** For credit system features: replaces the feature's credit_schema entirely for customers on this plan. */
|
|
805
|
+
creditSchema?: Array<
|
|
806
|
+
| {
|
|
807
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
808
|
+
meteredFeatureId: string;
|
|
809
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
810
|
+
billingUnits?: number;
|
|
811
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
812
|
+
dimensions?: Record<
|
|
813
|
+
string,
|
|
814
|
+
| {
|
|
815
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
816
|
+
match: Record<string, string | number | boolean>;
|
|
817
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
818
|
+
priority?: number;
|
|
819
|
+
tierBehavior: "graduated";
|
|
820
|
+
tiers: Array<{
|
|
821
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
822
|
+
to: number | "inf";
|
|
823
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
824
|
+
creditCost: number;
|
|
825
|
+
}>;
|
|
826
|
+
}
|
|
827
|
+
| {
|
|
828
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
829
|
+
match: Record<string, string | number | boolean>;
|
|
830
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
831
|
+
priority?: number;
|
|
832
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
833
|
+
creditCost: number;
|
|
834
|
+
}
|
|
835
|
+
>;
|
|
836
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
837
|
+
multipliers?: Record<
|
|
838
|
+
string,
|
|
839
|
+
{
|
|
840
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
841
|
+
match: Record<string, string | number | boolean>;
|
|
842
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
843
|
+
factor?: number;
|
|
844
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
845
|
+
add?: number;
|
|
846
|
+
}
|
|
847
|
+
>;
|
|
848
|
+
tierBehavior: "graduated";
|
|
849
|
+
tiers: Array<{
|
|
850
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
851
|
+
to: number | "inf";
|
|
852
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
853
|
+
creditCost: number;
|
|
854
|
+
}>;
|
|
855
|
+
}
|
|
856
|
+
| {
|
|
857
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
858
|
+
meteredFeatureId: string;
|
|
859
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
860
|
+
billingUnits?: number;
|
|
861
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
862
|
+
dimensions?: Record<
|
|
863
|
+
string,
|
|
864
|
+
| {
|
|
865
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
866
|
+
match: Record<string, string | number | boolean>;
|
|
867
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
868
|
+
priority?: number;
|
|
869
|
+
tierBehavior: "graduated";
|
|
870
|
+
tiers: Array<{
|
|
871
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
872
|
+
to: number | "inf";
|
|
873
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
874
|
+
creditCost: number;
|
|
875
|
+
}>;
|
|
876
|
+
}
|
|
877
|
+
| {
|
|
878
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
879
|
+
match: Record<string, string | number | boolean>;
|
|
880
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
881
|
+
priority?: number;
|
|
882
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
883
|
+
creditCost: number;
|
|
884
|
+
}
|
|
885
|
+
>;
|
|
886
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
887
|
+
multipliers?: Record<
|
|
888
|
+
string,
|
|
889
|
+
{
|
|
890
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
891
|
+
match: Record<string, string | number | boolean>;
|
|
892
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
893
|
+
factor?: number;
|
|
894
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
895
|
+
add?: number;
|
|
896
|
+
}
|
|
897
|
+
>;
|
|
898
|
+
/** Credits consumed per billing-unit group. */
|
|
899
|
+
creditCost: number;
|
|
900
|
+
}
|
|
901
|
+
>;
|
|
902
|
+
/** For AI credit system features: replaces the feature's markup chain entirely for customers on this plan. An unset level means no markup at that level rather than inheriting the feature's. */
|
|
903
|
+
markups?: {
|
|
904
|
+
/** Default percentage markup for customers on this plan. Use -100 to make usage free. */
|
|
905
|
+
defaultMarkup?: number;
|
|
906
|
+
/** Per-provider markup percentages for customers on this plan. */
|
|
907
|
+
providerMarkups?: Record<
|
|
908
|
+
string,
|
|
909
|
+
{
|
|
910
|
+
markup: number;
|
|
911
|
+
}
|
|
912
|
+
> | null;
|
|
913
|
+
/** Per-model markup overrides for customers on this plan. */
|
|
914
|
+
modelMarkups?: Record<
|
|
915
|
+
string,
|
|
916
|
+
{
|
|
917
|
+
markup?: number;
|
|
918
|
+
inputCost?: number;
|
|
919
|
+
outputCost?: number;
|
|
920
|
+
}
|
|
921
|
+
> | null;
|
|
922
|
+
};
|
|
923
|
+
};
|
|
924
|
+
entityFeatureId?: string;
|
|
925
|
+
}>;
|
|
926
|
+
/** Filters selecting items to remove from the plan. */
|
|
927
|
+
removeItems?: Array<{
|
|
928
|
+
/** Match items linked to this feature. */
|
|
929
|
+
featureId?: string;
|
|
930
|
+
/** Match items with this billing method (prepaid or usage_based). */
|
|
931
|
+
billingMethod?: "prepaid" | "usage_based";
|
|
932
|
+
/** Match items with this interval. Accepts either a BillingInterval (price-side) or a ResetInterval (reset-side, includes day/hour/minute) so price-less items keyed by reset.interval can be disambiguated. */
|
|
933
|
+
interval?:
|
|
934
|
+
| "one_off"
|
|
935
|
+
| "week"
|
|
936
|
+
| "month"
|
|
937
|
+
| "quarter"
|
|
938
|
+
| "semi_annual"
|
|
939
|
+
| "year"
|
|
940
|
+
| "one_off"
|
|
941
|
+
| "minute"
|
|
942
|
+
| "hour"
|
|
943
|
+
| "day"
|
|
944
|
+
| "week"
|
|
945
|
+
| "month"
|
|
946
|
+
| "quarter"
|
|
947
|
+
| "semi_annual"
|
|
948
|
+
| "year";
|
|
949
|
+
/** Match items with this interval_count. Disambiguates between items that share an interval but differ in count. */
|
|
950
|
+
intervalCount?: number;
|
|
951
|
+
/** Match items whose grant equals this included usage. Omitted is a wildcard. */
|
|
952
|
+
included?: number;
|
|
953
|
+
}>;
|
|
954
|
+
/** Override the plan's default free trial. Pass an object to set a custom trial, or null to remove the trial entirely. */
|
|
955
|
+
freeTrial?: {
|
|
956
|
+
/** Number of duration_type periods the trial lasts. */
|
|
957
|
+
durationLength: number;
|
|
958
|
+
/** Unit of time for the trial ('day', 'month', 'year'). Defaults to "month". */
|
|
959
|
+
durationType?: "day" | "month" | "year";
|
|
960
|
+
/** If true, a payment method is required to start the trial and the customer is charged when it ends. Defaults to false. */
|
|
961
|
+
cardRequired?: boolean;
|
|
962
|
+
/** Behavior when the trial ends. 'bill' charges the customer (default). 'revert' expires the trial and restores the customer's previous plan. */
|
|
963
|
+
onEnd?: "bill" | "revert";
|
|
964
|
+
} | null;
|
|
965
|
+
/** Override the plan's billing controls (auto top-ups, spend limits, usage limits, usage alerts, overage allowed) for this customer. */
|
|
966
|
+
billingControls?: {
|
|
967
|
+
/** List of auto top-up configurations per feature. Defaults to []. */
|
|
968
|
+
autoTopups?: Array<{
|
|
969
|
+
/** The ID of the feature (credit balance) to auto top-up. */
|
|
970
|
+
featureId: string;
|
|
971
|
+
/** Whether auto top-up is enabled. Defaults to false. */
|
|
972
|
+
enabled?: boolean;
|
|
973
|
+
/** When the balance drops below this threshold, an auto top-up will be purchased. */
|
|
974
|
+
threshold: number;
|
|
975
|
+
/** Amount of credits to add per auto top-up. */
|
|
976
|
+
quantity: number;
|
|
977
|
+
/** Optional rate limit to cap how often auto top-ups occur. Pass count to set the current window's consumed top-ups. */
|
|
978
|
+
purchaseLimit?: {
|
|
979
|
+
/** The time interval for the purchase limit window. */
|
|
980
|
+
interval: "hour" | "day" | "week" | "month";
|
|
981
|
+
/** Number of intervals in the purchase limit window. Defaults to 1. */
|
|
982
|
+
intervalCount?: number;
|
|
983
|
+
/** Maximum number of auto top-ups allowed within the interval. */
|
|
984
|
+
limit: number;
|
|
985
|
+
/** Set the current window's consumed auto top-up count. Omit to leave runtime state unchanged. */
|
|
986
|
+
count?: number;
|
|
987
|
+
};
|
|
988
|
+
/** When true, auto top-up creates a send_invoice invoice instead of auto-charging. */
|
|
989
|
+
invoiceMode?: boolean;
|
|
990
|
+
}>;
|
|
991
|
+
/** List of overage spend limits per feature (caps overage spend). Defaults to []. */
|
|
992
|
+
spendLimits?: Array<{
|
|
993
|
+
/** Optional feature ID this spend limit applies to. */
|
|
994
|
+
featureId?: string;
|
|
995
|
+
/** Whether the overage spend limit is enabled. Defaults to false. */
|
|
996
|
+
enabled?: boolean;
|
|
997
|
+
/** How overage_limit is interpreted: an absolute overage cap (default) or a percentage of the main-plan allowance. */
|
|
998
|
+
limitType?: "absolute" | "usage_percentage";
|
|
999
|
+
/** Overage cap for the feature: absolute units, or a percent (e.g. 120) when limit_type is usage_percentage. */
|
|
1000
|
+
overageLimit?: number;
|
|
1001
|
+
/** When true, overage for this feature is not posted to Stripe. Usage tracking and balance resets still behave normally. */
|
|
1002
|
+
skipOverageBilling?: boolean;
|
|
1003
|
+
}>;
|
|
1004
|
+
/** List of hard usage caps per feature (max units per interval). Defaults to []. */
|
|
1005
|
+
usageLimits?: Array<{
|
|
1006
|
+
/** The feature this usage limit applies to. */
|
|
1007
|
+
featureId: string;
|
|
1008
|
+
/** Whether this usage limit is enabled. Defaults to true. */
|
|
1009
|
+
enabled?: boolean;
|
|
1010
|
+
/** Maximum units allowed per interval. */
|
|
1011
|
+
limit: number;
|
|
1012
|
+
/** Interval for the cap, aligned to the customer's billing cycle. */
|
|
1013
|
+
interval: "day" | "week" | "month" | "year";
|
|
1014
|
+
/** Window alignment. 'billing_cycle' phases the interval to the customer's renewal time; 'utc' aligns to the UTC calendar. */
|
|
1015
|
+
anchor?: "billing_cycle" | "utc";
|
|
1016
|
+
/** When set, only usage from events whose properties match counts toward this cap. Omit to count all usage of the feature. */
|
|
1017
|
+
filter?: {
|
|
1018
|
+
properties: Record<string, string | number | boolean>;
|
|
1019
|
+
};
|
|
1020
|
+
}>;
|
|
1021
|
+
/** List of usage alert configurations per feature. Defaults to []. */
|
|
1022
|
+
usageAlerts?: Array<{
|
|
1023
|
+
/** The feature ID this alert applies to. */
|
|
1024
|
+
featureId?: string;
|
|
1025
|
+
/** Whether this usage alert is enabled. Defaults to true. */
|
|
1026
|
+
enabled?: boolean;
|
|
1027
|
+
/** The threshold value that triggers the alert. For usage or remaining, this is an absolute count. For usage_percentage or remaining_percentage, this is a percentage (0-100). */
|
|
1028
|
+
threshold: number;
|
|
1029
|
+
/** Whether the threshold is an absolute count or a percentage of the usage allowance or remaining balance. */
|
|
1030
|
+
thresholdType:
|
|
1031
|
+
| "usage"
|
|
1032
|
+
| "usage_percentage"
|
|
1033
|
+
| "remaining"
|
|
1034
|
+
| "remaining_percentage";
|
|
1035
|
+
/** What 100% means. balance: every grant on the feature. included: the plan allowance only. recurring: grants that reset. usage_limit: the cap of the usage limit with the same feature and filter. Defaults to "balance". */
|
|
1036
|
+
basis?: "balance" | "included" | "recurring" | "usage_limit";
|
|
1037
|
+
/** Only valid with basis usage_limit. Points the alert at the usage limit carrying the same filter. */
|
|
1038
|
+
filter?: {
|
|
1039
|
+
properties: Record<string, string | number | boolean>;
|
|
1040
|
+
};
|
|
1041
|
+
/** Optional user-defined label to distinguish multiple alerts on the same feature. */
|
|
1042
|
+
name?: string;
|
|
1043
|
+
}>;
|
|
1044
|
+
/** List of overage allowed controls per feature. When enabled, usage can exceed balance. Defaults to []. */
|
|
1045
|
+
overageAllowed?: Array<{
|
|
1046
|
+
/** The feature ID this overage allowed control applies to. */
|
|
1047
|
+
featureId: string;
|
|
1048
|
+
/** Whether overage is allowed for this feature. Defaults to false. */
|
|
1049
|
+
enabled?: boolean;
|
|
1050
|
+
}>;
|
|
1051
|
+
};
|
|
1052
|
+
/** License links to add or override for this customer, keyed by license_plan_id. Omitted fields inherit the plan catalog link (included defaults to 1 when the license is not in the catalog). A bare entry restores the license to pure catalog inheritance. */
|
|
1053
|
+
upsertLicenses?: Array<{
|
|
1054
|
+
licensePlanId: string;
|
|
1055
|
+
versionSlug?: string;
|
|
1056
|
+
included?: number;
|
|
1057
|
+
prepaidOnly?: boolean;
|
|
1058
|
+
customize?: {
|
|
1059
|
+
price?: {
|
|
1060
|
+
/** Base price amount for the plan, in major currency units (e.g. dollars). */
|
|
1061
|
+
amount: number;
|
|
1062
|
+
/** Billing interval (e.g. 'month', 'year'). */
|
|
1063
|
+
interval:
|
|
1064
|
+
| "one_off"
|
|
1065
|
+
| "week"
|
|
1066
|
+
| "month"
|
|
1067
|
+
| "quarter"
|
|
1068
|
+
| "semi_annual"
|
|
1069
|
+
| "year";
|
|
1070
|
+
/** Number of intervals per billing cycle. Defaults to 1. */
|
|
1071
|
+
intervalCount?: number;
|
|
1072
|
+
/** Base price amounts in additional currencies. The base 'amount' is in the org's default currency. */
|
|
1073
|
+
additionalCurrencies?: Array<{
|
|
1074
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
1075
|
+
currency: string;
|
|
1076
|
+
/** Price amount in this currency. Set explicitly per currency, not converted from the base amount. */
|
|
1077
|
+
amount: number;
|
|
1078
|
+
}>;
|
|
1079
|
+
} | null;
|
|
1080
|
+
addItems?: Array<{
|
|
1081
|
+
/** Bills this many feature units when outstanding overage reaches it. */
|
|
1082
|
+
thresholdBilling?: {
|
|
1083
|
+
threshold: number;
|
|
1084
|
+
} | null;
|
|
1085
|
+
/** The ID of the feature to configure. */
|
|
1086
|
+
featureId: string;
|
|
1087
|
+
/** Number of free units included. Balance resets to this each interval for consumable features. */
|
|
1088
|
+
included?: number;
|
|
1089
|
+
/** If true, customer has unlimited access to this feature. */
|
|
1090
|
+
unlimited?: boolean;
|
|
1091
|
+
/** Whether entity-level grants contribute to a shared customer balance. Defaults to false. */
|
|
1092
|
+
pooled?: boolean;
|
|
1093
|
+
/** Reset configuration for consumable features. Omit for non-consumable features like seats. */
|
|
1094
|
+
reset?: {
|
|
1095
|
+
/** Interval at which balance resets (e.g. 'month', 'year'). For consumable features only. */
|
|
1096
|
+
interval:
|
|
1097
|
+
| "one_off"
|
|
1098
|
+
| "minute"
|
|
1099
|
+
| "hour"
|
|
1100
|
+
| "day"
|
|
1101
|
+
| "week"
|
|
1102
|
+
| "month"
|
|
1103
|
+
| "quarter"
|
|
1104
|
+
| "semi_annual"
|
|
1105
|
+
| "year";
|
|
1106
|
+
/** Number of intervals between resets. Defaults to 1. */
|
|
1107
|
+
intervalCount?: number;
|
|
1108
|
+
};
|
|
1109
|
+
/** Pricing for usage beyond included units. Omit for free features. */
|
|
1110
|
+
price?: {
|
|
1111
|
+
/** Price per billing_units after included usage. Either 'amount' or 'tiers' is required. */
|
|
1112
|
+
amount?: number;
|
|
1113
|
+
/** Amounts in additional currencies for this flat price. The base 'amount' is in the org's default currency. Only valid with 'amount', not 'tiers'. */
|
|
1114
|
+
additionalCurrencies?: Array<{
|
|
1115
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
1116
|
+
currency: string;
|
|
1117
|
+
/** Price amount in this currency. Set explicitly per currency, not converted from the base amount. */
|
|
1118
|
+
amount: number;
|
|
1119
|
+
}>;
|
|
1120
|
+
/** Tiered pricing. Either 'amount' or 'tiers' is required. */
|
|
1121
|
+
tiers?: Array<{
|
|
1122
|
+
to: number | "inf";
|
|
1123
|
+
amount?: number;
|
|
1124
|
+
flatAmount?: number;
|
|
1125
|
+
/** Per-currency amounts for this tier. Tier boundaries ('to') are shared across all currencies. */
|
|
1126
|
+
additionalCurrencies?: Array<{
|
|
1127
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
1128
|
+
currency: string;
|
|
1129
|
+
/** Per-unit amount for this tier in this currency. */
|
|
1130
|
+
amount?: number;
|
|
1131
|
+
/** Flat amount for this tier in this currency, if the tier uses one. */
|
|
1132
|
+
flatAmount?: number;
|
|
1133
|
+
}>;
|
|
1134
|
+
}>;
|
|
1135
|
+
tierBehavior?: "graduated" | "volume";
|
|
1136
|
+
/** Billing interval. For consumable features, should match reset.interval. */
|
|
1137
|
+
interval:
|
|
1138
|
+
| "one_off"
|
|
1139
|
+
| "week"
|
|
1140
|
+
| "month"
|
|
1141
|
+
| "quarter"
|
|
1142
|
+
| "semi_annual"
|
|
1143
|
+
| "year";
|
|
1144
|
+
/** Number of intervals per billing cycle. Defaults to 1. */
|
|
1145
|
+
intervalCount?: number;
|
|
1146
|
+
/** Units per price increment. Usage is rounded UP when billed (e.g. billing_units=100 means 101 rounds to 200). Defaults to 1. */
|
|
1147
|
+
billingUnits?: number;
|
|
1148
|
+
/** 'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go. */
|
|
1149
|
+
billingMethod: "prepaid" | "usage_based";
|
|
1150
|
+
allocatedBilling?: "arrear" | "prorated_legacy";
|
|
1151
|
+
/** Max units purchasable beyond included. E.g. included=100, max_purchase=300 allows 400 total. Null for no limit. */
|
|
1152
|
+
maxPurchase?: number | null;
|
|
1153
|
+
};
|
|
1154
|
+
/** Proration settings for prepaid features. Controls mid-cycle quantity change billing. */
|
|
1155
|
+
proration?: {
|
|
1156
|
+
/** Billing behavior when quantity increases mid-cycle. */
|
|
1157
|
+
onIncrease:
|
|
1158
|
+
| "bill_immediately"
|
|
1159
|
+
| "prorate_immediately"
|
|
1160
|
+
| "prorate_next_cycle"
|
|
1161
|
+
| "bill_next_cycle";
|
|
1162
|
+
/** Credit behavior when quantity decreases mid-cycle. */
|
|
1163
|
+
onDecrease:
|
|
1164
|
+
| "prorate"
|
|
1165
|
+
| "prorate_immediately"
|
|
1166
|
+
| "prorate_next_cycle"
|
|
1167
|
+
| "none"
|
|
1168
|
+
| "no_prorations";
|
|
1169
|
+
};
|
|
1170
|
+
/** Rollover config for unused units. If set, unused included units carry over. */
|
|
1171
|
+
rollover?: {
|
|
1172
|
+
/** Max rollover units. Omit for unlimited rollover. */
|
|
1173
|
+
max?: number;
|
|
1174
|
+
/** Maximum rollover as a percentage (0-100) of included + prepaid grant. Mutually exclusive with max. */
|
|
1175
|
+
maxPercentage?: number;
|
|
1176
|
+
/** When rolled over units expire. */
|
|
1177
|
+
expiryDurationType: "month" | "forever";
|
|
1178
|
+
/** Number of periods before expiry. */
|
|
1179
|
+
expiryDurationLength?: number;
|
|
1180
|
+
};
|
|
1181
|
+
/** Overrides fields of this item's feature for customers on this plan (e.g. a credit system's credit_schema). */
|
|
1182
|
+
featureOverride?: {
|
|
1183
|
+
/** For credit system features: replaces the feature's credit_schema entirely for customers on this plan. */
|
|
1184
|
+
creditSchema?: Array<
|
|
1185
|
+
| {
|
|
1186
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
1187
|
+
meteredFeatureId: string;
|
|
1188
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
1189
|
+
billingUnits?: number;
|
|
1190
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
1191
|
+
dimensions?: Record<
|
|
1192
|
+
string,
|
|
1193
|
+
| {
|
|
1194
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1195
|
+
match: Record<string, string | number | boolean>;
|
|
1196
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
1197
|
+
priority?: number;
|
|
1198
|
+
tierBehavior: "graduated";
|
|
1199
|
+
tiers: Array<{
|
|
1200
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
1201
|
+
to?: unknown;
|
|
1202
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
1203
|
+
creditCost: number;
|
|
1204
|
+
}>;
|
|
1205
|
+
}
|
|
1206
|
+
| {
|
|
1207
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1208
|
+
match: Record<string, string | number | boolean>;
|
|
1209
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
1210
|
+
priority?: number;
|
|
1211
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
1212
|
+
creditCost: number;
|
|
1213
|
+
}
|
|
1214
|
+
>;
|
|
1215
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
1216
|
+
multipliers?: Record<
|
|
1217
|
+
string,
|
|
1218
|
+
{
|
|
1219
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1220
|
+
match: Record<string, string | number | boolean>;
|
|
1221
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
1222
|
+
factor?: number;
|
|
1223
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
1224
|
+
add?: number;
|
|
1225
|
+
}
|
|
1226
|
+
>;
|
|
1227
|
+
tierBehavior: "graduated";
|
|
1228
|
+
tiers: Array<{
|
|
1229
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
1230
|
+
to: number | "inf";
|
|
1231
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
1232
|
+
creditCost: number;
|
|
1233
|
+
}>;
|
|
1234
|
+
}
|
|
1235
|
+
| {
|
|
1236
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
1237
|
+
meteredFeatureId: string;
|
|
1238
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
1239
|
+
billingUnits?: number;
|
|
1240
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
1241
|
+
dimensions?: Record<
|
|
1242
|
+
string,
|
|
1243
|
+
| {
|
|
1244
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1245
|
+
match: Record<string, string | number | boolean>;
|
|
1246
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
1247
|
+
priority?: number;
|
|
1248
|
+
tierBehavior: "graduated";
|
|
1249
|
+
tiers: Array<{
|
|
1250
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
1251
|
+
to?: unknown;
|
|
1252
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
1253
|
+
creditCost: number;
|
|
1254
|
+
}>;
|
|
1255
|
+
}
|
|
1256
|
+
| {
|
|
1257
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1258
|
+
match: Record<string, string | number | boolean>;
|
|
1259
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
1260
|
+
priority?: number;
|
|
1261
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
1262
|
+
creditCost: number;
|
|
1263
|
+
}
|
|
1264
|
+
>;
|
|
1265
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
1266
|
+
multipliers?: Record<
|
|
1267
|
+
string,
|
|
1268
|
+
{
|
|
1269
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1270
|
+
match: Record<string, string | number | boolean>;
|
|
1271
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
1272
|
+
factor?: number;
|
|
1273
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
1274
|
+
add?: number;
|
|
1275
|
+
}
|
|
1276
|
+
>;
|
|
1277
|
+
/** Credits consumed per billing-unit group. */
|
|
1278
|
+
creditCost: number;
|
|
1279
|
+
}
|
|
1280
|
+
>;
|
|
1281
|
+
/** For AI credit system features: replaces the feature's markup chain entirely for customers on this plan. An unset level means no markup at that level rather than inheriting the feature's. */
|
|
1282
|
+
markups?: {
|
|
1283
|
+
/** Default percentage markup for customers on this plan. Use -100 to make usage free. */
|
|
1284
|
+
defaultMarkup?: number;
|
|
1285
|
+
/** Per-provider markup percentages for customers on this plan. */
|
|
1286
|
+
providerMarkups?: Record<
|
|
1287
|
+
string,
|
|
1288
|
+
{
|
|
1289
|
+
markup: number;
|
|
1290
|
+
}
|
|
1291
|
+
> | null;
|
|
1292
|
+
/** Per-model markup overrides for customers on this plan. */
|
|
1293
|
+
modelMarkups?: Record<
|
|
1294
|
+
string,
|
|
1295
|
+
{
|
|
1296
|
+
markup?: number;
|
|
1297
|
+
inputCost?: number;
|
|
1298
|
+
outputCost?: number;
|
|
1299
|
+
}
|
|
1300
|
+
> | null;
|
|
1301
|
+
};
|
|
1302
|
+
};
|
|
1303
|
+
entityFeatureId?: string;
|
|
1304
|
+
}>;
|
|
1305
|
+
removeItems?: Array<{
|
|
1306
|
+
/** Match items linked to this feature. */
|
|
1307
|
+
featureId?: string;
|
|
1308
|
+
/** Match items with this billing method (prepaid or usage_based). */
|
|
1309
|
+
billingMethod?: "prepaid" | "usage_based";
|
|
1310
|
+
/** Match items with this interval. Accepts either a BillingInterval (price-side) or a ResetInterval (reset-side, includes day/hour/minute) so price-less items keyed by reset.interval can be disambiguated. */
|
|
1311
|
+
interval?:
|
|
1312
|
+
| "one_off"
|
|
1313
|
+
| "week"
|
|
1314
|
+
| "month"
|
|
1315
|
+
| "quarter"
|
|
1316
|
+
| "semi_annual"
|
|
1317
|
+
| "year"
|
|
1318
|
+
| "one_off"
|
|
1319
|
+
| "minute"
|
|
1320
|
+
| "hour"
|
|
1321
|
+
| "day"
|
|
1322
|
+
| "week"
|
|
1323
|
+
| "month"
|
|
1324
|
+
| "quarter"
|
|
1325
|
+
| "semi_annual"
|
|
1326
|
+
| "year";
|
|
1327
|
+
/** Match items with this interval_count. Disambiguates between items that share an interval but differ in count. */
|
|
1328
|
+
intervalCount?: number;
|
|
1329
|
+
/** Match items whose grant equals this included usage. Omitted is a wildcard. */
|
|
1330
|
+
included?: number;
|
|
1331
|
+
}>;
|
|
1332
|
+
} | null;
|
|
1333
|
+
metadata?: Record<string, unknown>;
|
|
1334
|
+
}>;
|
|
1335
|
+
/** License links to drop, keyed by license_plan_id. Parallel to remove_items. */
|
|
1336
|
+
removeLicenses?: Array<{
|
|
1337
|
+
licensePlanId: string;
|
|
1338
|
+
}>;
|
|
1339
|
+
} | null;
|
|
1340
|
+
}>;
|
|
1341
|
+
/** Plans offered as assignable licenses under this plan. Omit to leave them unchanged. */
|
|
1342
|
+
licenses?: Array<{
|
|
1343
|
+
licensePlanId: string;
|
|
1344
|
+
versionSlug?: string;
|
|
1345
|
+
included?: number;
|
|
1346
|
+
prepaidOnly?: boolean;
|
|
1347
|
+
customize?: {
|
|
1348
|
+
price?: {
|
|
1349
|
+
/** Base price amount for the plan, in major currency units (e.g. dollars). */
|
|
1350
|
+
amount: number;
|
|
1351
|
+
/** Billing interval (e.g. 'month', 'year'). */
|
|
1352
|
+
interval:
|
|
1353
|
+
| "one_off"
|
|
1354
|
+
| "week"
|
|
1355
|
+
| "month"
|
|
1356
|
+
| "quarter"
|
|
1357
|
+
| "semi_annual"
|
|
1358
|
+
| "year";
|
|
1359
|
+
/** Number of intervals per billing cycle. Defaults to 1. */
|
|
1360
|
+
intervalCount?: number;
|
|
1361
|
+
/** Base price amounts in additional currencies. The base 'amount' is in the org's default currency. */
|
|
1362
|
+
additionalCurrencies?: Array<{
|
|
1363
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
1364
|
+
currency: string;
|
|
1365
|
+
/** Price amount in this currency. Set explicitly per currency, not converted from the base amount. */
|
|
1366
|
+
amount: number;
|
|
1367
|
+
}>;
|
|
1368
|
+
} | null;
|
|
1369
|
+
addItems?: Array<{
|
|
1370
|
+
/** Bills this many feature units when outstanding overage reaches it. */
|
|
1371
|
+
thresholdBilling?: {
|
|
1372
|
+
threshold: number;
|
|
1373
|
+
} | null;
|
|
1374
|
+
/** The ID of the feature to configure. */
|
|
1375
|
+
featureId: string;
|
|
1376
|
+
/** Number of free units included. Balance resets to this each interval for consumable features. */
|
|
1377
|
+
included?: number;
|
|
1378
|
+
/** If true, customer has unlimited access to this feature. */
|
|
1379
|
+
unlimited?: boolean;
|
|
1380
|
+
/** Whether entity-level grants contribute to a shared customer balance. Defaults to false. */
|
|
1381
|
+
pooled?: boolean;
|
|
1382
|
+
/** Reset configuration for consumable features. Omit for non-consumable features like seats. */
|
|
1383
|
+
reset?: {
|
|
1384
|
+
/** Interval at which balance resets (e.g. 'month', 'year'). For consumable features only. */
|
|
1385
|
+
interval:
|
|
1386
|
+
| "one_off"
|
|
1387
|
+
| "minute"
|
|
1388
|
+
| "hour"
|
|
1389
|
+
| "day"
|
|
1390
|
+
| "week"
|
|
1391
|
+
| "month"
|
|
1392
|
+
| "quarter"
|
|
1393
|
+
| "semi_annual"
|
|
1394
|
+
| "year";
|
|
1395
|
+
/** Number of intervals between resets. Defaults to 1. */
|
|
1396
|
+
intervalCount?: number;
|
|
1397
|
+
};
|
|
1398
|
+
/** Pricing for usage beyond included units. Omit for free features. */
|
|
1399
|
+
price?: {
|
|
1400
|
+
/** Price per billing_units after included usage. Either 'amount' or 'tiers' is required. */
|
|
1401
|
+
amount?: number;
|
|
1402
|
+
/** Amounts in additional currencies for this flat price. The base 'amount' is in the org's default currency. Only valid with 'amount', not 'tiers'. */
|
|
1403
|
+
additionalCurrencies?: Array<{
|
|
1404
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
1405
|
+
currency: string;
|
|
1406
|
+
/** Price amount in this currency. Set explicitly per currency, not converted from the base amount. */
|
|
1407
|
+
amount: number;
|
|
1408
|
+
}>;
|
|
1409
|
+
/** Tiered pricing. Either 'amount' or 'tiers' is required. */
|
|
1410
|
+
tiers?: Array<{
|
|
1411
|
+
to: number | "inf";
|
|
1412
|
+
amount?: number;
|
|
1413
|
+
flatAmount?: number;
|
|
1414
|
+
/** Per-currency amounts for this tier. Tier boundaries ('to') are shared across all currencies. */
|
|
1415
|
+
additionalCurrencies?: Array<{
|
|
1416
|
+
/** Three-letter Stripe-supported currency code (e.g. 'eur', 'gbp'). */
|
|
1417
|
+
currency: string;
|
|
1418
|
+
/** Per-unit amount for this tier in this currency. */
|
|
1419
|
+
amount?: number;
|
|
1420
|
+
/** Flat amount for this tier in this currency, if the tier uses one. */
|
|
1421
|
+
flatAmount?: number;
|
|
1422
|
+
}>;
|
|
1423
|
+
}>;
|
|
1424
|
+
tierBehavior?: "graduated" | "volume";
|
|
1425
|
+
/** Billing interval. For consumable features, should match reset.interval. */
|
|
1426
|
+
interval:
|
|
1427
|
+
| "one_off"
|
|
1428
|
+
| "week"
|
|
1429
|
+
| "month"
|
|
1430
|
+
| "quarter"
|
|
1431
|
+
| "semi_annual"
|
|
1432
|
+
| "year";
|
|
1433
|
+
/** Number of intervals per billing cycle. Defaults to 1. */
|
|
1434
|
+
intervalCount?: number;
|
|
1435
|
+
/** Units per price increment. Usage is rounded UP when billed (e.g. billing_units=100 means 101 rounds to 200). Defaults to 1. */
|
|
1436
|
+
billingUnits?: number;
|
|
1437
|
+
/** 'prepaid' for upfront payment (seats), 'usage_based' for pay-as-you-go. */
|
|
1438
|
+
billingMethod: "prepaid" | "usage_based";
|
|
1439
|
+
allocatedBilling?: "arrear" | "prorated_legacy";
|
|
1440
|
+
/** Max units purchasable beyond included. E.g. included=100, max_purchase=300 allows 400 total. Null for no limit. */
|
|
1441
|
+
maxPurchase?: number | null;
|
|
1442
|
+
};
|
|
1443
|
+
/** Proration settings for prepaid features. Controls mid-cycle quantity change billing. */
|
|
1444
|
+
proration?: {
|
|
1445
|
+
/** Billing behavior when quantity increases mid-cycle. */
|
|
1446
|
+
onIncrease:
|
|
1447
|
+
| "bill_immediately"
|
|
1448
|
+
| "prorate_immediately"
|
|
1449
|
+
| "prorate_next_cycle"
|
|
1450
|
+
| "bill_next_cycle";
|
|
1451
|
+
/** Credit behavior when quantity decreases mid-cycle. */
|
|
1452
|
+
onDecrease:
|
|
1453
|
+
| "prorate"
|
|
1454
|
+
| "prorate_immediately"
|
|
1455
|
+
| "prorate_next_cycle"
|
|
1456
|
+
| "none"
|
|
1457
|
+
| "no_prorations";
|
|
1458
|
+
};
|
|
1459
|
+
/** Rollover config for unused units. If set, unused included units carry over. */
|
|
1460
|
+
rollover?: {
|
|
1461
|
+
/** Max rollover units. Omit for unlimited rollover. */
|
|
1462
|
+
max?: number;
|
|
1463
|
+
/** Maximum rollover as a percentage (0-100) of included + prepaid grant. Mutually exclusive with max. */
|
|
1464
|
+
maxPercentage?: number;
|
|
1465
|
+
/** When rolled over units expire. */
|
|
1466
|
+
expiryDurationType: "month" | "forever";
|
|
1467
|
+
/** Number of periods before expiry. */
|
|
1468
|
+
expiryDurationLength?: number;
|
|
1469
|
+
};
|
|
1470
|
+
/** Overrides fields of this item's feature for customers on this plan (e.g. a credit system's credit_schema). */
|
|
1471
|
+
featureOverride?: {
|
|
1472
|
+
/** For credit system features: replaces the feature's credit_schema entirely for customers on this plan. */
|
|
1473
|
+
creditSchema?: Array<
|
|
1474
|
+
| {
|
|
1475
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
1476
|
+
meteredFeatureId: string;
|
|
1477
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
1478
|
+
billingUnits?: number;
|
|
1479
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
1480
|
+
dimensions?: Record<
|
|
1481
|
+
string,
|
|
1482
|
+
| {
|
|
1483
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1484
|
+
match: Record<string, string | number | boolean>;
|
|
1485
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
1486
|
+
priority?: number;
|
|
1487
|
+
tierBehavior: "graduated";
|
|
1488
|
+
tiers: Array<{
|
|
1489
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
1490
|
+
to: number | "inf";
|
|
1491
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
1492
|
+
creditCost: number;
|
|
1493
|
+
}>;
|
|
1494
|
+
}
|
|
1495
|
+
| {
|
|
1496
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1497
|
+
match: Record<string, string | number | boolean>;
|
|
1498
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
1499
|
+
priority?: number;
|
|
1500
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
1501
|
+
creditCost: number;
|
|
1502
|
+
}
|
|
1503
|
+
>;
|
|
1504
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
1505
|
+
multipliers?: Record<
|
|
1506
|
+
string,
|
|
1507
|
+
{
|
|
1508
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1509
|
+
match: Record<string, string | number | boolean>;
|
|
1510
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
1511
|
+
factor?: number;
|
|
1512
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
1513
|
+
add?: number;
|
|
1514
|
+
}
|
|
1515
|
+
>;
|
|
1516
|
+
tierBehavior: "graduated";
|
|
1517
|
+
tiers: Array<{
|
|
1518
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
1519
|
+
to: number | "inf";
|
|
1520
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
1521
|
+
creditCost: number;
|
|
1522
|
+
}>;
|
|
1523
|
+
}
|
|
1524
|
+
| {
|
|
1525
|
+
/** ID of the metered feature that draws from this credit system. */
|
|
1526
|
+
meteredFeatureId: string;
|
|
1527
|
+
/** Number of metered-feature units priced together. Defaults to one when omitted. */
|
|
1528
|
+
billingUnits?: number;
|
|
1529
|
+
/** Named rates chosen by event properties. The most specific match sets the rate; with no match the item's own rate applies. */
|
|
1530
|
+
dimensions?: Record<
|
|
1531
|
+
string,
|
|
1532
|
+
| {
|
|
1533
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1534
|
+
match: Record<string, string | number | boolean>;
|
|
1535
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
1536
|
+
priority?: number;
|
|
1537
|
+
tierBehavior: "graduated";
|
|
1538
|
+
tiers: Array<{
|
|
1539
|
+
/** Inclusive upper usage boundary for this graduated tier. The final tier must be 'inf'. */
|
|
1540
|
+
to: number | "inf";
|
|
1541
|
+
/** Credits consumed per billing-unit group within this tier. */
|
|
1542
|
+
creditCost: number;
|
|
1543
|
+
}>;
|
|
1544
|
+
}
|
|
1545
|
+
| {
|
|
1546
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1547
|
+
match: Record<string, string | number | boolean>;
|
|
1548
|
+
/** Breaks ties between dimensions that match the same number of keys. Higher wins. */
|
|
1549
|
+
priority?: number;
|
|
1550
|
+
/** Credits consumed per billing-unit group when this dimension matches. */
|
|
1551
|
+
creditCost: number;
|
|
1552
|
+
}
|
|
1553
|
+
>;
|
|
1554
|
+
/** Named adjustments chosen by event properties. Every match applies: factors multiply, then adds are summed. */
|
|
1555
|
+
multipliers?: Record<
|
|
1556
|
+
string,
|
|
1557
|
+
{
|
|
1558
|
+
/** Event properties this entry applies to. Every key must equal the tracked property, compared as strings. */
|
|
1559
|
+
match: Record<string, string | number | boolean>;
|
|
1560
|
+
/** Multiplies the matched rate. All matching multipliers stack. */
|
|
1561
|
+
factor?: number;
|
|
1562
|
+
/** Added to the rate after every factor is applied, in credits per billing-unit group. */
|
|
1563
|
+
add?: number;
|
|
1564
|
+
}
|
|
1565
|
+
>;
|
|
1566
|
+
/** Credits consumed per billing-unit group. */
|
|
1567
|
+
creditCost: number;
|
|
1568
|
+
}
|
|
1569
|
+
>;
|
|
1570
|
+
/** For AI credit system features: replaces the feature's markup chain entirely for customers on this plan. An unset level means no markup at that level rather than inheriting the feature's. */
|
|
1571
|
+
markups?: {
|
|
1572
|
+
/** Default percentage markup for customers on this plan. Use -100 to make usage free. */
|
|
1573
|
+
defaultMarkup?: number;
|
|
1574
|
+
/** Per-provider markup percentages for customers on this plan. */
|
|
1575
|
+
providerMarkups?: Record<
|
|
1576
|
+
string,
|
|
1577
|
+
{
|
|
1578
|
+
markup: number;
|
|
1579
|
+
}
|
|
1580
|
+
> | null;
|
|
1581
|
+
/** Per-model markup overrides for customers on this plan. */
|
|
1582
|
+
modelMarkups?: Record<
|
|
1583
|
+
string,
|
|
1584
|
+
{
|
|
1585
|
+
markup?: number;
|
|
1586
|
+
inputCost?: number;
|
|
1587
|
+
outputCost?: number;
|
|
1588
|
+
}
|
|
1589
|
+
> | null;
|
|
1590
|
+
};
|
|
1591
|
+
};
|
|
1592
|
+
entityFeatureId?: string;
|
|
1593
|
+
}>;
|
|
1594
|
+
removeItems?: Array<{
|
|
1595
|
+
/** Match items linked to this feature. */
|
|
1596
|
+
featureId?: string;
|
|
1597
|
+
/** Match items with this billing method (prepaid or usage_based). */
|
|
1598
|
+
billingMethod?: "prepaid" | "usage_based";
|
|
1599
|
+
/** Match items with this interval. Accepts either a BillingInterval (price-side) or a ResetInterval (reset-side, includes day/hour/minute) so price-less items keyed by reset.interval can be disambiguated. */
|
|
1600
|
+
interval?:
|
|
1601
|
+
| "one_off"
|
|
1602
|
+
| "week"
|
|
1603
|
+
| "month"
|
|
1604
|
+
| "quarter"
|
|
1605
|
+
| "semi_annual"
|
|
1606
|
+
| "year"
|
|
1607
|
+
| "one_off"
|
|
1608
|
+
| "minute"
|
|
1609
|
+
| "hour"
|
|
1610
|
+
| "day"
|
|
1611
|
+
| "week"
|
|
1612
|
+
| "month"
|
|
1613
|
+
| "quarter"
|
|
1614
|
+
| "semi_annual"
|
|
1615
|
+
| "year";
|
|
1616
|
+
/** Match items with this interval_count. Disambiguates between items that share an interval but differ in count. */
|
|
1617
|
+
intervalCount?: number;
|
|
1618
|
+
/** Match items whose grant equals this included usage. Omitted is a wildcard. */
|
|
1619
|
+
included?: number;
|
|
1620
|
+
}>;
|
|
1621
|
+
} | null;
|
|
1622
|
+
metadata?: Record<string, unknown>;
|
|
1623
|
+
}>;
|
|
1624
|
+
/** Base plan id to attach this plan to. `null` detaches it from its base. Omit to leave the pointer unchanged. Nesting under the base's variants[] also links. */
|
|
1625
|
+
baseVariantId?: string | null;
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
export const plan = (input: Plan): Plan => input;
|