@vibesdotdev/account 1.0.0-rc.4 → 1.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/account-settings.storage.descriptor.d.ts +2 -0
- package/dist/account/account-settings.storage.descriptor.d.ts.map +1 -1
- package/dist/billing/internal/quota-client.d.ts +59 -0
- package/dist/billing/internal/quota-client.d.ts.map +1 -1
- package/dist/billing/internal/quota-client.js +113 -1
- package/dist/billing/internal/quota-client.js.map +1 -1
- package/dist/billing/overage/overage-policy.config.descriptor.d.ts +114 -0
- package/dist/billing/overage/overage-policy.config.descriptor.d.ts.map +1 -0
- package/dist/billing/overage/overage-policy.config.descriptor.js +52 -0
- package/dist/billing/overage/overage-policy.config.descriptor.js.map +1 -0
- package/dist/billing/overage/overage-policy.d.ts +159 -0
- package/dist/billing/overage/overage-policy.d.ts.map +1 -0
- package/dist/billing/overage/overage-policy.js +93 -0
- package/dist/billing/overage/overage-policy.js.map +1 -0
- package/dist/billing/usage/delivery.d.ts +96 -1
- package/dist/billing/usage/delivery.d.ts.map +1 -1
- package/dist/billing/usage/delivery.js +55 -0
- package/dist/billing/usage/delivery.js.map +1 -1
- package/dist/billing/usage/record-code-session-usage.d.ts +9 -2
- package/dist/billing/usage/record-code-session-usage.d.ts.map +1 -1
- package/dist/billing/usage/record-code-session-usage.js +4 -1
- package/dist/billing/usage/record-code-session-usage.js.map +1 -1
- package/dist/billing/usage/record-platform-resource.d.ts +14 -2
- package/dist/billing/usage/record-platform-resource.d.ts.map +1 -1
- package/dist/billing/usage/record-platform-resource.js +25 -6
- package/dist/billing/usage/record-platform-resource.js.map +1 -1
- package/dist/billing/usage/record-sandbox-uptime.d.ts +16 -3
- package/dist/billing/usage/record-sandbox-uptime.d.ts.map +1 -1
- package/dist/billing/usage/record-sandbox-uptime.js +24 -5
- package/dist/billing/usage/record-sandbox-uptime.js.map +1 -1
- package/dist/cli/plugin.d.ts.map +1 -1
- package/dist/cli/plugin.js +2 -0
- package/dist/cli/plugin.js.map +1 -1
- package/dist/org/account-org.plugin.d.ts +4 -5
- package/dist/org/account-org.plugin.d.ts.map +1 -1
- package/dist/org/account-org.plugin.js +5 -6
- package/dist/org/account-org.plugin.js.map +1 -1
- package/dist/org/orgId.context.descriptor.d.ts +2 -3
- package/dist/org/orgId.context.descriptor.d.ts.map +1 -1
- package/dist/org/orgId.context.descriptor.js +2 -3
- package/dist/org/orgId.context.descriptor.js.map +1 -1
- package/dist/org/orgId.context.impl.d.ts +5 -6
- package/dist/org/orgId.context.impl.d.ts.map +1 -1
- package/dist/org/orgId.context.impl.js +34 -8
- package/dist/org/orgId.context.impl.js.map +1 -1
- package/dist/plugin/billing-overage.d.ts +9 -0
- package/dist/plugin/billing-overage.d.ts.map +1 -0
- package/dist/plugin/billing-overage.js +17 -0
- package/dist/plugin/billing-overage.js.map +1 -0
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +5 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/system/account-system.config.descriptor.d.ts +17 -4
- package/dist/system/account-system.config.descriptor.d.ts.map +1 -1
- package/dist/system/account-system.config.descriptor.js +14 -2
- package/dist/system/account-system.config.descriptor.js.map +1 -1
- package/dist/system/config.d.ts +7 -2
- package/dist/system/config.d.ts.map +1 -1
- package/dist/system/config.js +15 -1
- package/dist/system/config.js.map +1 -1
- package/package.json +93 -18
|
@@ -34,6 +34,7 @@ export declare const accountSettingsStorageDescriptors: readonly [{
|
|
|
34
34
|
idField?: string | undefined;
|
|
35
35
|
collectionField?: string | undefined;
|
|
36
36
|
defaultAdapter?: string | undefined;
|
|
37
|
+
migrationSources?: string[] | undefined;
|
|
37
38
|
adapterConfig?: Record<string, unknown> | undefined;
|
|
38
39
|
scopePaths?: {
|
|
39
40
|
global?: string | undefined;
|
|
@@ -77,6 +78,7 @@ export declare const accountSettingsStorageDescriptors: readonly [{
|
|
|
77
78
|
idField?: string | undefined;
|
|
78
79
|
collectionField?: string | undefined;
|
|
79
80
|
defaultAdapter?: string | undefined;
|
|
81
|
+
migrationSources?: string[] | undefined;
|
|
80
82
|
adapterConfig?: Record<string, unknown> | undefined;
|
|
81
83
|
scopePaths?: {
|
|
82
84
|
global?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-settings.storage.descriptor.d.ts","sourceRoot":"","sources":["../../src/account/account-settings.storage.descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAStE,eAAO,MAAM,oCAAoC,EAAE,yBAkClD,CAAC;AAEF,eAAO,MAAM,mCAAmC,EAAE,yBAkCjD,CAAC;AAEF,eAAO,MAAM,iCAAiC
|
|
1
|
+
{"version":3,"file":"account-settings.storage.descriptor.d.ts","sourceRoot":"","sources":["../../src/account/account-settings.storage.descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAStE,eAAO,MAAM,oCAAoC,EAAE,yBAkClD,CAAC;AAEF,eAAO,MAAM,mCAAmC,EAAE,yBAkCjD,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGpC,CAAC;AAEX,eAAe,iCAAiC,CAAC"}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import * as z from 'zod/v4';
|
|
21
21
|
import { type RuntimeRef } from '@vibesdotdev/kernel';
|
|
22
22
|
import { FEATURE_SLUGS, type FeatureSlug } from '../schemas/core/feature-slugs.ts';
|
|
23
|
+
import { type OverageResolution } from '../overage/overage-policy.ts';
|
|
23
24
|
/** Entitlement configuration state — `limit: null` is never ambiguous. */
|
|
24
25
|
export declare const quotaLimitStateSchema: z.ZodEnum<{
|
|
25
26
|
unlimited: "unlimited";
|
|
@@ -185,5 +186,63 @@ export declare function checkFeatureQuotaDecided(params: {
|
|
|
185
186
|
limit: number | null;
|
|
186
187
|
remaining: number | null;
|
|
187
188
|
}>;
|
|
189
|
+
/**
|
|
190
|
+
* The billing subject an overage behavior (or a pooled balance) is read for.
|
|
191
|
+
* Account derives role and org class itself.
|
|
192
|
+
*
|
|
193
|
+
* - A user subject (`userId` set) is usage the user is billed for: alone
|
|
194
|
+
* (`organizationId: null`) or as a member drawing on the org.
|
|
195
|
+
* - An org-only subject (`userId: null`) is org-billed usage with no acting
|
|
196
|
+
* user — an org-owned host or code session. Account resolves it without
|
|
197
|
+
* the user and role layers, exactly as `record-internal` resolves
|
|
198
|
+
* org-only background usage, so a billing contact's personal override
|
|
199
|
+
* never decides it.
|
|
200
|
+
*/
|
|
201
|
+
export type OverageSubject = {
|
|
202
|
+
/** The acting user (asserted via `X-Vibes-User-Id`). */
|
|
203
|
+
userId: string;
|
|
204
|
+
/** The org billed, or null for usage billed to the user alone. */
|
|
205
|
+
organizationId: string | null;
|
|
206
|
+
} | {
|
|
207
|
+
/** No acting user: the org is the whole subject. */
|
|
208
|
+
userId: null;
|
|
209
|
+
organizationId: string;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Resolve the overage behavior for a billing subject through Account Web's
|
|
213
|
+
* internal `POST /api/billing/overage/resolve` (service bearer, plus
|
|
214
|
+
* `X-Vibes-User-Id` for a user subject — the same seam as
|
|
215
|
+
* {@link checkQuotaInternal}). An org-only subject sends no user header.
|
|
216
|
+
*
|
|
217
|
+
* Returns exactly `{ behavior, source }`. There is no default here: a refused
|
|
218
|
+
* request, an unreachable Account Web or an unreadable answer throws a typed
|
|
219
|
+
* `CapabilityError`, so a caller can never act on a behavior nobody declared.
|
|
220
|
+
*/
|
|
221
|
+
export declare function resolveOverageBehaviorInternal(runtime: RuntimeRef, subject: OverageSubject, auth: {
|
|
222
|
+
serviceToken: string;
|
|
223
|
+
/** Test seam: a pre-built canonical client (defaults to vibesAccountClient). */
|
|
224
|
+
transport?: InternalQuotaTransport;
|
|
225
|
+
}): Promise<OverageResolution>;
|
|
226
|
+
/** 200 body of the internal pooled-balance read: credits across the subject's funded pools. */
|
|
227
|
+
export declare const PooledBalanceSchema: z.ZodObject<{
|
|
228
|
+
total: z.ZodNumber;
|
|
229
|
+
}, z.core.$strip>;
|
|
230
|
+
export type PooledBalance = z.infer<typeof PooledBalanceSchema>;
|
|
231
|
+
/**
|
|
232
|
+
* Read a billing subject's pooled credit balance through Account Web's
|
|
233
|
+
* internal `POST /api/billing/credits/pooled-balance` — the pools a
|
|
234
|
+
* `record-internal` charge for the same subject would draw from: the org's
|
|
235
|
+
* pools for an org subject, the user's own pools otherwise.
|
|
236
|
+
*
|
|
237
|
+
* Admission gates read this before launching paid compute. There is no
|
|
238
|
+
* default: a refused request, an unreachable Account Web or an unreadable
|
|
239
|
+
* answer throws a typed `CapabilityError`, so a gate can never admit on a
|
|
240
|
+
* balance nobody reported.
|
|
241
|
+
*/
|
|
242
|
+
export declare function readPooledBalanceInternal(runtime: RuntimeRef, subject: OverageSubject, auth: {
|
|
243
|
+
serviceToken: string;
|
|
244
|
+
/** Test seam: a pre-built canonical client (defaults to vibesAccountClient). */
|
|
245
|
+
transport?: InternalQuotaTransport;
|
|
246
|
+
}): Promise<PooledBalance>;
|
|
188
247
|
export {};
|
|
189
248
|
//# sourceMappingURL=quota-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-client.d.ts","sourceRoot":"","sources":["../../../src/billing/internal/quota-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"quota-client.d.ts","sourceRoot":"","sources":["../../../src/billing/internal/quota-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC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EAAE,IAAI,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACtB,CAAC;AA8BL;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CACnD,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE;IACL,YAAY,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACnC,GACC,OAAO,CAAC,iBAAiB,CAAC,CAiC5B;AAED,+FAA+F;AAC/F,eAAO,MAAM,mBAAmB;;iBAG9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE;IACL,YAAY,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACnC,GACC,OAAO,CAAC,aAAa,CAAC,CAiCxB"}
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
* barrel.
|
|
19
19
|
*/
|
|
20
20
|
import * as z from 'zod/v4';
|
|
21
|
-
import { settle, valueFreeFailure } from '@vibesdotdev/kernel';
|
|
21
|
+
import { CapabilityError, settle, valueFreeFailure } from '@vibesdotdev/kernel';
|
|
22
22
|
import { JsonValueSchema } from '@vibesdotdev/kernel/schemas/json';
|
|
23
23
|
import { vibesAccountClient } from "../../client/factory.js";
|
|
24
24
|
import { failureStatus } from "../failure-status.js";
|
|
25
25
|
import { FEATURE_SLUGS } from "../schemas/core/feature-slugs.js";
|
|
26
|
+
import { OverageResolutionSchema } from "../overage/overage-policy.js";
|
|
26
27
|
/** Entitlement configuration state — `limit: null` is never ambiguous. */
|
|
27
28
|
export const quotaLimitStateSchema = z.enum(['limited', 'unlimited', 'unconfigured']);
|
|
28
29
|
/**
|
|
@@ -236,4 +237,115 @@ export async function checkFeatureQuotaDecided(params) {
|
|
|
236
237
|
remaining: decision.remaining
|
|
237
238
|
};
|
|
238
239
|
}
|
|
240
|
+
const overageResolveRequestSchema = z.object({
|
|
241
|
+
organizationId: z.string().min(1).nullable()
|
|
242
|
+
});
|
|
243
|
+
/** The service bearer, plus the asserted user only when the subject has one. */
|
|
244
|
+
function subjectHeaders(serviceToken, subject) {
|
|
245
|
+
const headers = { Authorization: `Bearer ${serviceToken}` };
|
|
246
|
+
if (subject.userId !== null)
|
|
247
|
+
headers['X-Vibes-User-Id'] = subject.userId;
|
|
248
|
+
return headers;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The canonical client types request headers as an open string map.
|
|
252
|
+
* Copy the closed subject contract into that map, key by key.
|
|
253
|
+
*/
|
|
254
|
+
function quotaTransportHeaders(headers) {
|
|
255
|
+
const pairs = [['Authorization', headers.Authorization]];
|
|
256
|
+
const userId = headers['X-Vibes-User-Id'];
|
|
257
|
+
if (userId !== undefined)
|
|
258
|
+
pairs.push(['X-Vibes-User-Id', userId]);
|
|
259
|
+
return Object.fromEntries(pairs);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Resolve the overage behavior for a billing subject through Account Web's
|
|
263
|
+
* internal `POST /api/billing/overage/resolve` (service bearer, plus
|
|
264
|
+
* `X-Vibes-User-Id` for a user subject — the same seam as
|
|
265
|
+
* {@link checkQuotaInternal}). An org-only subject sends no user header.
|
|
266
|
+
*
|
|
267
|
+
* Returns exactly `{ behavior, source }`. There is no default here: a refused
|
|
268
|
+
* request, an unreachable Account Web or an unreadable answer throws a typed
|
|
269
|
+
* `CapabilityError`, so a caller can never act on a behavior nobody declared.
|
|
270
|
+
*/
|
|
271
|
+
export async function resolveOverageBehaviorInternal(runtime, subject, auth) {
|
|
272
|
+
const body = quotaWireBodySchema.parse(overageResolveRequestSchema.parse({ organizationId: subject.organizationId }));
|
|
273
|
+
const transport = auth.transport ?? (await vibesAccountClient(runtime));
|
|
274
|
+
const posted = await settle(() => transport.post('/api/billing/overage/resolve', body, {
|
|
275
|
+
headers: quotaTransportHeaders(subjectHeaders(auth.serviceToken, subject)),
|
|
276
|
+
timeout: INTERNAL_QUOTA_TIMEOUT_MS
|
|
277
|
+
}));
|
|
278
|
+
if (!posted.ok) {
|
|
279
|
+
const status = failureStatus(posted.cause);
|
|
280
|
+
if (status !== undefined && status >= 400 && status < 500 && status !== 429) {
|
|
281
|
+
throw new CapabilityError('Account refused the overage resolution.', status === 404 ? 'NOT_FOUND' : 'INVALID_INPUT', {
|
|
282
|
+
reason: 'overage-resolution-rejected',
|
|
283
|
+
retryable: false,
|
|
284
|
+
details: { status }
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
const failure = valueFreeFailure(posted.cause);
|
|
288
|
+
throw new CapabilityError('Account could not resolve the overage behavior.', 'UNAVAILABLE', {
|
|
289
|
+
reason: 'overage-resolution-unavailable',
|
|
290
|
+
retryable: true,
|
|
291
|
+
details: { status, failure: [failure.name, failure.code, failure.reason].filter(Boolean).join(' ') }
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
const parsed = OverageResolutionSchema.safeParse(posted.value);
|
|
295
|
+
if (!parsed.success) {
|
|
296
|
+
throw new CapabilityError('Account answered the overage resolution with an invalid body.', 'UNAVAILABLE', {
|
|
297
|
+
reason: 'overage-resolution-invalid',
|
|
298
|
+
retryable: true
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return { behavior: parsed.data.behavior, source: parsed.data.source };
|
|
302
|
+
}
|
|
303
|
+
/** 200 body of the internal pooled-balance read: credits across the subject's funded pools. */
|
|
304
|
+
export const PooledBalanceSchema = z.object({
|
|
305
|
+
/** Sum of the subject's pool balances, in credits. Never negative. */
|
|
306
|
+
total: z.number().nonnegative()
|
|
307
|
+
});
|
|
308
|
+
/**
|
|
309
|
+
* Read a billing subject's pooled credit balance through Account Web's
|
|
310
|
+
* internal `POST /api/billing/credits/pooled-balance` — the pools a
|
|
311
|
+
* `record-internal` charge for the same subject would draw from: the org's
|
|
312
|
+
* pools for an org subject, the user's own pools otherwise.
|
|
313
|
+
*
|
|
314
|
+
* Admission gates read this before launching paid compute. There is no
|
|
315
|
+
* default: a refused request, an unreachable Account Web or an unreadable
|
|
316
|
+
* answer throws a typed `CapabilityError`, so a gate can never admit on a
|
|
317
|
+
* balance nobody reported.
|
|
318
|
+
*/
|
|
319
|
+
export async function readPooledBalanceInternal(runtime, subject, auth) {
|
|
320
|
+
const body = quotaWireBodySchema.parse(overageResolveRequestSchema.parse({ organizationId: subject.organizationId }));
|
|
321
|
+
const transport = auth.transport ?? (await vibesAccountClient(runtime));
|
|
322
|
+
const posted = await settle(() => transport.post('/api/billing/credits/pooled-balance', body, {
|
|
323
|
+
headers: quotaTransportHeaders(subjectHeaders(auth.serviceToken, subject)),
|
|
324
|
+
timeout: INTERNAL_QUOTA_TIMEOUT_MS
|
|
325
|
+
}));
|
|
326
|
+
if (!posted.ok) {
|
|
327
|
+
const status = failureStatus(posted.cause);
|
|
328
|
+
if (status !== undefined && status >= 400 && status < 500 && status !== 429) {
|
|
329
|
+
throw new CapabilityError('Account refused the pooled balance read.', status === 404 ? 'NOT_FOUND' : 'INVALID_INPUT', {
|
|
330
|
+
reason: 'pooled-balance-rejected',
|
|
331
|
+
retryable: false,
|
|
332
|
+
details: { status }
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
const failure = valueFreeFailure(posted.cause);
|
|
336
|
+
throw new CapabilityError('Account could not report the pooled balance.', 'UNAVAILABLE', {
|
|
337
|
+
reason: 'pooled-balance-unavailable',
|
|
338
|
+
retryable: true,
|
|
339
|
+
details: { status, failure: [failure.name, failure.code, failure.reason].filter(Boolean).join(' ') }
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
const parsed = PooledBalanceSchema.safeParse(posted.value);
|
|
343
|
+
if (!parsed.success) {
|
|
344
|
+
throw new CapabilityError('Account answered the pooled balance read with an invalid body.', 'UNAVAILABLE', {
|
|
345
|
+
reason: 'pooled-balance-invalid',
|
|
346
|
+
retryable: true
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return { total: parsed.data.total };
|
|
350
|
+
}
|
|
239
351
|
//# sourceMappingURL=quota-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-client.js","sourceRoot":"","sources":["../../../src/billing/internal/quota-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAmB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"quota-client.js","sourceRoot":"","sources":["../../../src/billing/internal/quota-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAmB,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAoB,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAA0B,MAAM,8BAA8B,CAAC;AAE/F,0EAA0E;AAC1E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;AAGtF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAwB,IAAI,GAAG,CAAC;IAC1E,aAAa,CAAC,qBAAqB,CAAC;IACpC,aAAa,CAAC,eAAe,CAAC;CAC9B,CAAC,CAAC;AAMH,wFAAwF;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C;QAC/C,MAAM,IAAI,eAAe,CAAC,8CAA8C,EAAE,aAAa,EAAE;YACxF,MAAM,EAAE,4BAA4B;YACpC,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;SACpG,CAAC,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,IAAI,eAAe,CAAC,gEAAgE,EAAE,aAAa,EAAE;YAC1G,MAAM,EAAE,wBAAwB;YAChC,SAAS,EAAE,IAAI;SACf,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
kind: "config/manifest";
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
namespace: string;
|
|
7
|
+
schema: import("zod/v4").ZodObject<{
|
|
8
|
+
defaults: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
9
|
+
enterprise: import("zod/v4").ZodDefault<import("zod/v4").ZodEnum<{
|
|
10
|
+
"continue-invoice": "continue-invoice";
|
|
11
|
+
pause: "pause";
|
|
12
|
+
"continue-internal": "continue-internal";
|
|
13
|
+
}>>;
|
|
14
|
+
standard: import("zod/v4").ZodDefault<import("zod/v4").ZodEnum<{
|
|
15
|
+
"continue-invoice": "continue-invoice";
|
|
16
|
+
pause: "pause";
|
|
17
|
+
"continue-internal": "continue-internal";
|
|
18
|
+
}>>;
|
|
19
|
+
internal: import("zod/v4").ZodDefault<import("zod/v4").ZodEnum<{
|
|
20
|
+
"continue-invoice": "continue-invoice";
|
|
21
|
+
"continue-internal": "continue-internal";
|
|
22
|
+
}>>;
|
|
23
|
+
}, import("zod/v4/core").$strict>>;
|
|
24
|
+
userDefault: import("zod/v4").ZodDefault<import("zod/v4").ZodEnum<{
|
|
25
|
+
"continue-invoice": "continue-invoice";
|
|
26
|
+
pause: "pause";
|
|
27
|
+
"continue-internal": "continue-internal";
|
|
28
|
+
}>>;
|
|
29
|
+
standardContinueInvoice: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
30
|
+
allowed: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
31
|
+
requiresPaymentMethod: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
32
|
+
setterRoles: import("zod/v4").ZodDefault<import("zod/v4").ZodArray<import("zod/v4").ZodEnum<{
|
|
33
|
+
owner: "owner";
|
|
34
|
+
admin: "admin";
|
|
35
|
+
}>>>;
|
|
36
|
+
}, import("zod/v4/core").$strict>>;
|
|
37
|
+
}, import("zod/v4/core").$strict>;
|
|
38
|
+
scope: "global";
|
|
39
|
+
tier: "system";
|
|
40
|
+
category: string;
|
|
41
|
+
storedLayer: "none";
|
|
42
|
+
allowedAdapters: string[];
|
|
43
|
+
fields: {
|
|
44
|
+
'defaults.enterprise': {
|
|
45
|
+
ui: {
|
|
46
|
+
label: string;
|
|
47
|
+
component: "select";
|
|
48
|
+
group: string;
|
|
49
|
+
};
|
|
50
|
+
options: {
|
|
51
|
+
value: string;
|
|
52
|
+
label: string;
|
|
53
|
+
}[];
|
|
54
|
+
};
|
|
55
|
+
'defaults.standard': {
|
|
56
|
+
ui: {
|
|
57
|
+
label: string;
|
|
58
|
+
component: "select";
|
|
59
|
+
group: string;
|
|
60
|
+
};
|
|
61
|
+
options: {
|
|
62
|
+
value: string;
|
|
63
|
+
label: string;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
'defaults.internal': {
|
|
67
|
+
ui: {
|
|
68
|
+
label: string;
|
|
69
|
+
component: "select";
|
|
70
|
+
group: string;
|
|
71
|
+
};
|
|
72
|
+
options: {
|
|
73
|
+
value: string;
|
|
74
|
+
label: string;
|
|
75
|
+
}[];
|
|
76
|
+
};
|
|
77
|
+
userDefault: {
|
|
78
|
+
ui: {
|
|
79
|
+
label: string;
|
|
80
|
+
component: "select";
|
|
81
|
+
group: string;
|
|
82
|
+
};
|
|
83
|
+
options: {
|
|
84
|
+
value: string;
|
|
85
|
+
label: string;
|
|
86
|
+
}[];
|
|
87
|
+
};
|
|
88
|
+
'standardContinueInvoice.allowed': {
|
|
89
|
+
ui: {
|
|
90
|
+
label: string;
|
|
91
|
+
component: "switch";
|
|
92
|
+
group: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
'standardContinueInvoice.requiresPaymentMethod': {
|
|
96
|
+
ui: {
|
|
97
|
+
label: string;
|
|
98
|
+
component: "switch";
|
|
99
|
+
group: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
groups: {
|
|
104
|
+
id: string;
|
|
105
|
+
label: string;
|
|
106
|
+
order: number;
|
|
107
|
+
}[];
|
|
108
|
+
customTables: false;
|
|
109
|
+
version: number;
|
|
110
|
+
internal: false;
|
|
111
|
+
enabled: true;
|
|
112
|
+
};
|
|
113
|
+
export default _default;
|
|
114
|
+
//# sourceMappingURL=overage-policy.config.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overage-policy.config.descriptor.d.ts","sourceRoot":"","sources":["../../../src/billing/overage/overage-policy.config.descriptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,wBA4CqC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { OVERAGE_POLICY_MANIFEST_ID, OveragePolicySchema } from "./overage-policy.js";
|
|
2
|
+
const behaviorOptions = [
|
|
3
|
+
{ value: 'continue-invoice', label: 'Keep running and invoice' },
|
|
4
|
+
{ value: 'pause', label: 'Pause immediately' },
|
|
5
|
+
{ value: 'continue-internal', label: 'Keep running, record internally' }
|
|
6
|
+
];
|
|
7
|
+
export default {
|
|
8
|
+
kind: 'config/manifest',
|
|
9
|
+
id: OVERAGE_POLICY_MANIFEST_ID,
|
|
10
|
+
name: 'Overage policy',
|
|
11
|
+
description: 'What running work does when a billing subject runs out of credits',
|
|
12
|
+
namespace: OVERAGE_POLICY_MANIFEST_ID,
|
|
13
|
+
schema: OveragePolicySchema,
|
|
14
|
+
scope: 'global',
|
|
15
|
+
tier: 'system',
|
|
16
|
+
category: 'billing',
|
|
17
|
+
storedLayer: 'none',
|
|
18
|
+
allowedAdapters: ['storage.json', 'storage.localdb'],
|
|
19
|
+
fields: {
|
|
20
|
+
'defaults.enterprise': {
|
|
21
|
+
ui: { label: 'Enterprise orgs', component: 'select', group: 'defaults' },
|
|
22
|
+
options: behaviorOptions
|
|
23
|
+
},
|
|
24
|
+
'defaults.standard': {
|
|
25
|
+
ui: { label: 'Standard orgs', component: 'select', group: 'defaults' },
|
|
26
|
+
options: behaviorOptions
|
|
27
|
+
},
|
|
28
|
+
'defaults.internal': {
|
|
29
|
+
ui: { label: 'Internal org', component: 'select', group: 'defaults' },
|
|
30
|
+
options: behaviorOptions
|
|
31
|
+
},
|
|
32
|
+
userDefault: {
|
|
33
|
+
ui: { label: 'Users without an org', component: 'select', group: 'defaults' },
|
|
34
|
+
options: behaviorOptions
|
|
35
|
+
},
|
|
36
|
+
'standardContinueInvoice.allowed': {
|
|
37
|
+
ui: { label: 'Standard orgs may choose invoicing', component: 'switch', group: 'standard' }
|
|
38
|
+
},
|
|
39
|
+
'standardContinueInvoice.requiresPaymentMethod': {
|
|
40
|
+
ui: { label: 'Require a payment method', component: 'switch', group: 'standard' }
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
groups: [
|
|
44
|
+
{ id: 'defaults', label: 'Defaults', order: 1 },
|
|
45
|
+
{ id: 'standard', label: 'Standard org opt-in', order: 2 }
|
|
46
|
+
],
|
|
47
|
+
customTables: false,
|
|
48
|
+
version: 1,
|
|
49
|
+
internal: false,
|
|
50
|
+
enabled: true
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=overage-policy.config.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overage-policy.config.descriptor.js","sourceRoot":"","sources":["../../../src/billing/overage/overage-policy.config.descriptor.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAEtF,MAAM,eAAe,GAAG;IACvB,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,0BAA0B,EAAE;IAChE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE;IAC9C,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,iCAAiC,EAAE;CACxE,CAAC;AAEF,eAAe;IACd,IAAI,EAAE,iBAAiB;IACvB,EAAE,EAAE,0BAA0B;IAC9B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,mEAAmE;IAChF,SAAS,EAAE,0BAA0B;IACrC,MAAM,EAAE,mBAAmB;IAC3B,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,MAAM;IACnB,eAAe,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC;IACpD,MAAM,EAAE;QACP,qBAAqB,EAAE;YACtB,EAAE,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;YACxE,OAAO,EAAE,eAAe;SACxB;QACD,mBAAmB,EAAE;YACpB,EAAE,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;YACtE,OAAO,EAAE,eAAe;SACxB;QACD,mBAAmB,EAAE;YACpB,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;YACrE,OAAO,EAAE,eAAe;SACxB;QACD,WAAW,EAAE;YACZ,EAAE,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;YAC7E,OAAO,EAAE,eAAe;SACxB;QACD,iCAAiC,EAAE;YAClC,EAAE,EAAE,EAAE,KAAK,EAAE,oCAAoC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;SAC3F;QACD,+CAA+C,EAAE;YAChD,EAAE,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;SACjF;KACD;IACD,MAAM,EAAE;QACP,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE;QAC/C,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,CAAC,EAAE;KAC1D;IACD,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,IAAI;CACsB,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overage policy — what happens to running work when a billing subject's
|
|
3
|
+
* credits reach zero.
|
|
4
|
+
*
|
|
5
|
+
* Three behaviors:
|
|
6
|
+
* - `continue-invoice` — keep running and invoice the overage.
|
|
7
|
+
* - `pause` — pause immediately.
|
|
8
|
+
* - `continue-internal` — keep running, never invoice, and record the
|
|
9
|
+
* overage for system visibility.
|
|
10
|
+
*
|
|
11
|
+
* The declared defaults live in the `billing.overage` config manifest
|
|
12
|
+
* (`overage-policy.config.descriptor.ts`) and resolve through the runtime
|
|
13
|
+
* like any other setting; this module is the schema they parse against, never
|
|
14
|
+
* a second copy of the values. Account Web resolves a subject's behavior
|
|
15
|
+
* (`POST /api/billing/overage/resolve`): an explicit override for the user in
|
|
16
|
+
* the org, then the role in the org, then the org, then the class default,
|
|
17
|
+
* then `userDefault` for usage with no org. Callers never hard-code one.
|
|
18
|
+
*/
|
|
19
|
+
import * as z from 'zod/v4';
|
|
20
|
+
export declare const OVERAGE_POLICY_MANIFEST_ID = "billing.overage";
|
|
21
|
+
export declare const OverageBehaviorSchema: z.ZodEnum<{
|
|
22
|
+
"continue-invoice": "continue-invoice";
|
|
23
|
+
pause: "pause";
|
|
24
|
+
"continue-internal": "continue-internal";
|
|
25
|
+
}>;
|
|
26
|
+
export type OverageBehavior = z.infer<typeof OverageBehaviorSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* The org class a default is keyed by. `enterprise` is an org whose
|
|
29
|
+
* subscription tier is `accountType: enterprise`; `standard` is every other
|
|
30
|
+
* individual or team org; `internal` is the org a system admin marks as
|
|
31
|
+
* Vibes-internal.
|
|
32
|
+
*/
|
|
33
|
+
export declare const OverageOrgClassSchema: z.ZodEnum<{
|
|
34
|
+
internal: "internal";
|
|
35
|
+
standard: "standard";
|
|
36
|
+
enterprise: "enterprise";
|
|
37
|
+
}>;
|
|
38
|
+
export type OverageOrgClass = z.infer<typeof OverageOrgClassSchema>;
|
|
39
|
+
/** Who may set an org's overage behavior. */
|
|
40
|
+
export declare const OverageSetterRoleSchema: z.ZodEnum<{
|
|
41
|
+
owner: "owner";
|
|
42
|
+
admin: "admin";
|
|
43
|
+
}>;
|
|
44
|
+
export type OverageSetterRole = z.infer<typeof OverageSetterRoleSchema>;
|
|
45
|
+
/**
|
|
46
|
+
* The behaviors the Vibes internal org may run under. Drew, 2026-10-29: the
|
|
47
|
+
* internal org "keeps moving" — it is never paused for credits, so `pause` is
|
|
48
|
+
* not a value its default can hold, and Account never resolves it to `pause`
|
|
49
|
+
* from an override either.
|
|
50
|
+
*/
|
|
51
|
+
export declare const InternalOverageBehaviorSchema: z.ZodEnum<{
|
|
52
|
+
"continue-invoice": "continue-invoice";
|
|
53
|
+
"continue-internal": "continue-internal";
|
|
54
|
+
}>;
|
|
55
|
+
/** Per-class defaults (Drew, 2026-10-29). */
|
|
56
|
+
export declare const OverageClassDefaultsSchema: z.ZodObject<{
|
|
57
|
+
enterprise: z.ZodDefault<z.ZodEnum<{
|
|
58
|
+
"continue-invoice": "continue-invoice";
|
|
59
|
+
pause: "pause";
|
|
60
|
+
"continue-internal": "continue-internal";
|
|
61
|
+
}>>;
|
|
62
|
+
standard: z.ZodDefault<z.ZodEnum<{
|
|
63
|
+
"continue-invoice": "continue-invoice";
|
|
64
|
+
pause: "pause";
|
|
65
|
+
"continue-internal": "continue-internal";
|
|
66
|
+
}>>;
|
|
67
|
+
internal: z.ZodDefault<z.ZodEnum<{
|
|
68
|
+
"continue-invoice": "continue-invoice";
|
|
69
|
+
"continue-internal": "continue-internal";
|
|
70
|
+
}>>;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
export type OverageClassDefaults = z.infer<typeof OverageClassDefaultsSchema>;
|
|
73
|
+
/**
|
|
74
|
+
* Whether a `standard` org may opt in to `continue-invoice`, and on what
|
|
75
|
+
* terms. The terms are the lane D review's (2026-10-29): a payment method on
|
|
76
|
+
* file and an owner or admin making the choice. `allowed` defaults to true and
|
|
77
|
+
* is policy, so it can be changed without code.
|
|
78
|
+
*/
|
|
79
|
+
export declare const StandardContinueInvoicePolicySchema: z.ZodObject<{
|
|
80
|
+
allowed: z.ZodDefault<z.ZodBoolean>;
|
|
81
|
+
requiresPaymentMethod: z.ZodDefault<z.ZodBoolean>;
|
|
82
|
+
setterRoles: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
83
|
+
owner: "owner";
|
|
84
|
+
admin: "admin";
|
|
85
|
+
}>>>;
|
|
86
|
+
}, z.core.$strict>;
|
|
87
|
+
export type StandardContinueInvoicePolicy = z.infer<typeof StandardContinueInvoicePolicySchema>;
|
|
88
|
+
export declare const OveragePolicySchema: z.ZodObject<{
|
|
89
|
+
defaults: z.ZodDefault<z.ZodObject<{
|
|
90
|
+
enterprise: z.ZodDefault<z.ZodEnum<{
|
|
91
|
+
"continue-invoice": "continue-invoice";
|
|
92
|
+
pause: "pause";
|
|
93
|
+
"continue-internal": "continue-internal";
|
|
94
|
+
}>>;
|
|
95
|
+
standard: z.ZodDefault<z.ZodEnum<{
|
|
96
|
+
"continue-invoice": "continue-invoice";
|
|
97
|
+
pause: "pause";
|
|
98
|
+
"continue-internal": "continue-internal";
|
|
99
|
+
}>>;
|
|
100
|
+
internal: z.ZodDefault<z.ZodEnum<{
|
|
101
|
+
"continue-invoice": "continue-invoice";
|
|
102
|
+
"continue-internal": "continue-internal";
|
|
103
|
+
}>>;
|
|
104
|
+
}, z.core.$strict>>;
|
|
105
|
+
userDefault: z.ZodDefault<z.ZodEnum<{
|
|
106
|
+
"continue-invoice": "continue-invoice";
|
|
107
|
+
pause: "pause";
|
|
108
|
+
"continue-internal": "continue-internal";
|
|
109
|
+
}>>;
|
|
110
|
+
standardContinueInvoice: z.ZodDefault<z.ZodObject<{
|
|
111
|
+
allowed: z.ZodDefault<z.ZodBoolean>;
|
|
112
|
+
requiresPaymentMethod: z.ZodDefault<z.ZodBoolean>;
|
|
113
|
+
setterRoles: z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
114
|
+
owner: "owner";
|
|
115
|
+
admin: "admin";
|
|
116
|
+
}>>>;
|
|
117
|
+
}, z.core.$strict>>;
|
|
118
|
+
}, z.core.$strict>;
|
|
119
|
+
export type OveragePolicy = z.infer<typeof OveragePolicySchema>;
|
|
120
|
+
/** Where a resolved behavior came from, most specific first. */
|
|
121
|
+
export declare const OverageBehaviorSourceSchema: z.ZodEnum<{
|
|
122
|
+
"user-override": "user-override";
|
|
123
|
+
"role-override": "role-override";
|
|
124
|
+
"org-override": "org-override";
|
|
125
|
+
"class-default": "class-default";
|
|
126
|
+
"user-default": "user-default";
|
|
127
|
+
}>;
|
|
128
|
+
export type OverageBehaviorSource = z.infer<typeof OverageBehaviorSourceSchema>;
|
|
129
|
+
/** A resolved overage behavior and where it came from. */
|
|
130
|
+
export declare const OverageResolutionSchema: z.ZodObject<{
|
|
131
|
+
behavior: z.ZodEnum<{
|
|
132
|
+
"continue-invoice": "continue-invoice";
|
|
133
|
+
pause: "pause";
|
|
134
|
+
"continue-internal": "continue-internal";
|
|
135
|
+
}>;
|
|
136
|
+
source: z.ZodEnum<{
|
|
137
|
+
"user-override": "user-override";
|
|
138
|
+
"role-override": "role-override";
|
|
139
|
+
"org-override": "org-override";
|
|
140
|
+
"class-default": "class-default";
|
|
141
|
+
"user-default": "user-default";
|
|
142
|
+
}>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
export type OverageResolution = z.infer<typeof OverageResolutionSchema>;
|
|
145
|
+
/** Why an org may not choose a behavior; absent when it may. */
|
|
146
|
+
export type OverageChoiceRefusal = 'standard-continue-invoice-disallowed' | 'payment-method-required' | 'setter-role-not-permitted';
|
|
147
|
+
/**
|
|
148
|
+
* Whether an org of `orgClass` may choose `behavior`, set by `setterRole`.
|
|
149
|
+
* Only `continue-invoice` on a `standard` org is conditioned here; the
|
|
150
|
+
* owner/admin-edit rule for every other choice belongs to the override
|
|
151
|
+
* route's own authorization.
|
|
152
|
+
*/
|
|
153
|
+
export declare function overageChoiceRefusal(policy: OveragePolicy, choice: {
|
|
154
|
+
orgClass: OverageOrgClass;
|
|
155
|
+
behavior: OverageBehavior;
|
|
156
|
+
hasPaymentMethod: boolean;
|
|
157
|
+
setterRole: OverageSetterRole | 'member';
|
|
158
|
+
}): OverageChoiceRefusal | null;
|
|
159
|
+
//# sourceMappingURL=overage-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overage-policy.d.ts","sourceRoot":"","sources":["../../../src/billing/overage/overage-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,eAAO,MAAM,0BAA0B,oBAAoB,CAAC;AAE5D,eAAO,MAAM,qBAAqB;;;;EAA6D,CAAC;AAChG,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;EAAiD,CAAC;AACpF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,6CAA6C;AAC7C,eAAO,MAAM,uBAAuB;;;EAA6B,CAAC;AAClE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;EAA2C,CAAC;AAEtF,6CAA6C;AAC7C,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;kBAIrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC;;;;;;;kBAI9C,CAAC;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAEhG,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAO9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,gEAAgE;AAChE,eAAO,MAAM,2BAA2B;;;;;;E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