@fantastic.dev/better-stripe 0.50.3 → 0.52.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/CHANGELOG.md +33 -0
- package/README.md +5 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +166 -32
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +83 -16
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +134 -0
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +67 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/usage/boundaries.d.ts +132 -0
- package/dist/client/usage/boundaries.d.ts.map +1 -0
- package/dist/client/usage/boundaries.js +43 -0
- package/dist/client/usage/boundaries.js.map +1 -0
- package/dist/client/usage/client.d.ts +37 -0
- package/dist/client/usage/client.d.ts.map +1 -0
- package/dist/client/usage/client.js +59 -0
- package/dist/client/usage/client.js.map +1 -0
- package/dist/client/usage/contracts.d.ts +59 -0
- package/dist/client/usage/contracts.d.ts.map +1 -0
- package/dist/client/usage/contracts.js +63 -0
- package/dist/client/usage/contracts.js.map +1 -0
- package/dist/client/usage/index.d.ts +7 -0
- package/dist/client/usage/index.d.ts.map +1 -0
- package/dist/client/usage/index.js +4 -0
- package/dist/client/usage/index.js.map +1 -0
- package/dist/client/usage/records.d.ts +50 -0
- package/dist/client/usage/records.d.ts.map +1 -0
- package/dist/client/usage/records.js +54 -0
- package/dist/client/usage/records.js.map +1 -0
- package/dist/component/_generated/api.d.ts +6 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +79 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
- package/dist/component/earnings/triggers.d.ts +178 -16
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/schema.d.ts +67 -0
- package/dist/component/schema.js +5 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/usage/helpers.d.ts +13 -0
- package/dist/component/usage/helpers.d.ts.map +1 -0
- package/dist/component/usage/helpers.js +34 -0
- package/dist/component/usage/helpers.js.map +1 -0
- package/dist/component/usage/mutations.d.ts +14 -0
- package/dist/component/usage/mutations.d.ts.map +1 -0
- package/dist/component/usage/mutations.js +124 -0
- package/dist/component/usage/mutations.js.map +1 -0
- package/dist/component/usage/queries.d.ts +62 -0
- package/dist/component/usage/queries.d.ts.map +1 -0
- package/dist/component/usage/queries.js +65 -0
- package/dist/component/usage/queries.js.map +1 -0
- package/dist/component/usage/schema.d.ts +110 -0
- package/dist/component/usage/schema.d.ts.map +1 -0
- package/dist/component/usage/schema.js +54 -0
- package/dist/component/usage/schema.js.map +1 -0
- package/docs/README.md +7 -0
- package/docs/development.md +26 -8
- package/docs/metered-usage.md +289 -37
- package/docs/metering-setup.md +184 -0
- package/docs/usage-ledger.md +62 -0
- package/package.json +8 -2
- package/src/client/index.ts +5 -0
- package/src/client/transferContinuation.test.ts +2 -6
- package/src/client/usage/boundaries.test.ts +136 -0
- package/src/client/usage/boundaries.ts +182 -0
- package/src/client/usage/client.ts +97 -0
- package/src/client/usage/contracts.test.ts +145 -0
- package/src/client/usage/contracts.ts +79 -0
- package/src/client/usage/index.ts +34 -0
- package/src/client/usage/ledger-client.test.ts +74 -0
- package/src/client/usage/records.ts +76 -0
- package/src/component/_generated/api.ts +6 -0
- package/src/component/_generated/component.ts +106 -0
- package/src/component/schema.ts +10 -0
- package/src/component/usage/helpers.ts +33 -0
- package/src/component/usage/ledger.test.ts +310 -0
- package/src/component/usage/mutations.ts +139 -0
- package/src/component/usage/queries.ts +69 -0
- package/src/component/usage/schema.ts +65 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { PreparedUsageRecord, UsageScope } from "./records.js";
|
|
2
|
+
export type UsagePeriod = {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
};
|
|
6
|
+
export type UsagePageRequest = {
|
|
7
|
+
period: UsagePeriod;
|
|
8
|
+
limit: number;
|
|
9
|
+
cursor: string | null;
|
|
10
|
+
};
|
|
11
|
+
export type UsageAvailability<T> = {
|
|
12
|
+
status: "available";
|
|
13
|
+
value: T;
|
|
14
|
+
observedAt: number;
|
|
15
|
+
} | {
|
|
16
|
+
status: "unavailable" | "unsupported";
|
|
17
|
+
reason: string;
|
|
18
|
+
retryable: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type UsageAuthorization<Context> = {
|
|
21
|
+
/** Throw on denial. Resolve identity and tenant ownership in the host. */
|
|
22
|
+
authorize(ctx: Context, request: {
|
|
23
|
+
scope: UsageScope;
|
|
24
|
+
operation: "record" | "read" | "reconcile" | "correct" | "configure";
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
/** Throw when the server-verified activity is not billable. */
|
|
27
|
+
authorizeActivity(ctx: Context, record: PreparedUsageRecord): Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
/** Independent observations; none is inferred from another field. */
|
|
30
|
+
export type UsageObservations = {
|
|
31
|
+
localAcceptedQuantity: string;
|
|
32
|
+
providerAcceptedQuantity: string;
|
|
33
|
+
aggregate: UsageAvailability<{
|
|
34
|
+
quantity: string;
|
|
35
|
+
complete: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
estimate: UsageAvailability<{
|
|
38
|
+
amountDecimal: string;
|
|
39
|
+
currency: string;
|
|
40
|
+
}>;
|
|
41
|
+
invoice: UsageAvailability<{
|
|
42
|
+
invoiceId: string;
|
|
43
|
+
status: "draft" | "open" | "paid" | "void" | "uncollectible";
|
|
44
|
+
amount: string;
|
|
45
|
+
currency: string;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
export type UsageCorrectionRequest = {
|
|
49
|
+
scope: UsageScope;
|
|
50
|
+
sourceEventId: string;
|
|
51
|
+
correctionId: string;
|
|
52
|
+
reason: string;
|
|
53
|
+
/** Cancellation preserves the original event. Replacement is a new event. */
|
|
54
|
+
operation: "cancel";
|
|
55
|
+
};
|
|
56
|
+
export type UsageRetentionPolicy = {
|
|
57
|
+
/** Financial evidence has no automatic deletion path. */
|
|
58
|
+
financialEvidence: "retain";
|
|
59
|
+
/** Execution payload cleanup must never erase event/payment/correction history. */
|
|
60
|
+
executionJournalDays: number;
|
|
61
|
+
};
|
|
62
|
+
export type UsageTransitionRequest = {
|
|
63
|
+
scope: UsageScope;
|
|
64
|
+
fromVersion: string;
|
|
65
|
+
toVersion: string;
|
|
66
|
+
effectiveAt: number;
|
|
67
|
+
pendingUsage: "drain_before_transition";
|
|
68
|
+
reservations: "resolve_before_transition";
|
|
69
|
+
existingCredits: "retain_original_terms";
|
|
70
|
+
};
|
|
71
|
+
export type UsageSubscriptionBinding = {
|
|
72
|
+
subscriptionId: string;
|
|
73
|
+
subscriptionItemId: string;
|
|
74
|
+
stripePriceId: string;
|
|
75
|
+
period: UsagePeriod;
|
|
76
|
+
interval: "month";
|
|
77
|
+
};
|
|
78
|
+
export type UsageCreditProvenance = {
|
|
79
|
+
grantId: string;
|
|
80
|
+
purchasePaymentIntentId: string;
|
|
81
|
+
currency: string;
|
|
82
|
+
originalAmount: string;
|
|
83
|
+
/** Quantity projections retain their original plan version and unit. */
|
|
84
|
+
planVersion: string;
|
|
85
|
+
reservationId: string;
|
|
86
|
+
scaledQuantity: string;
|
|
87
|
+
};
|
|
88
|
+
export type UsageCorrectionOutcome = {
|
|
89
|
+
correctionId: string;
|
|
90
|
+
sourceEventId: string;
|
|
91
|
+
state: "requested" | "provider_accepted" | "confirmed" | "held" | "unsupported" | "invoice_adjustment_required";
|
|
92
|
+
providerAdjustmentId: string | null;
|
|
93
|
+
reason: string;
|
|
94
|
+
};
|
|
95
|
+
export type UsageReceipt = {
|
|
96
|
+
eventId: string;
|
|
97
|
+
identity: string;
|
|
98
|
+
acceptedAt: number;
|
|
99
|
+
delivery: import("./records.js").UsageDeliveryState;
|
|
100
|
+
};
|
|
101
|
+
export type UsageHistoryPage = {
|
|
102
|
+
events: Array<{
|
|
103
|
+
receipt: UsageReceipt;
|
|
104
|
+
record: PreparedUsageRecord;
|
|
105
|
+
}>;
|
|
106
|
+
cursor: string | null;
|
|
107
|
+
isDone: boolean;
|
|
108
|
+
};
|
|
109
|
+
export type UsageProviderCapabilities = {
|
|
110
|
+
aggregation: "sum";
|
|
111
|
+
scaledIntegerQuantities: true;
|
|
112
|
+
realTimeBalance: false;
|
|
113
|
+
eventCancellation: "provider_window";
|
|
114
|
+
invoiceFinalization: "asynchronous";
|
|
115
|
+
};
|
|
116
|
+
/** Contract for host adapters; this interface does not supply a billing engine. */
|
|
117
|
+
export interface UsageContractPort {
|
|
118
|
+
record(record: PreparedUsageRecord): Promise<UsageReceipt>;
|
|
119
|
+
read(request: {
|
|
120
|
+
scope: UsageScope;
|
|
121
|
+
page: UsagePageRequest;
|
|
122
|
+
}): Promise<UsageHistoryPage>;
|
|
123
|
+
reconcile(request: {
|
|
124
|
+
scope: UsageScope;
|
|
125
|
+
period: UsagePeriod;
|
|
126
|
+
}): Promise<UsageAvailability<UsageObservations>>;
|
|
127
|
+
capabilities(scope: UsageScope): Promise<UsageAvailability<UsageProviderCapabilities>>;
|
|
128
|
+
}
|
|
129
|
+
export declare function validateUsagePageRequest(input: unknown): UsagePageRequest;
|
|
130
|
+
export declare function assertUsageReplay(original: PreparedUsageRecord, candidate: PreparedUsageRecord): void;
|
|
131
|
+
export declare function authorizeUsageRecord<Context, Result>(ctx: Context, policy: UsageAuthorization<Context>, input: unknown, accept: (record: PreparedUsageRecord) => Promise<Result>): Promise<Result>;
|
|
132
|
+
//# sourceMappingURL=boundaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../../../src/client/usage/boundaries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAKpE,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AACzD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAC3B;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACrD;IACE,MAAM,EAAE,aAAa,GAAG,aAAa,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AACN,MAAM,MAAM,kBAAkB,CAAC,OAAO,IAAI;IACxC,0EAA0E;IAC1E,SAAS,CACP,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE;QACP,KAAK,EAAE,UAAU,CAAC;QAClB,SAAS,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;KACtE,GACA,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,+DAA+D;IAC/D,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7E,CAAC;AAEF,qEAAqE;AACr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BAAiB,CAAC;IACrC,mBAAmB,EAAE,cAAc,CAAC;CACrC,CAAC;AACF,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3D,IAAI,CAAC,OAAO,EAAE;QACZ,KAAK,EAAE,UAAU,CAAC;QAClB,IAAI,EAAE,gBAAgB,CAAC;KACxB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9B,SAAS,CAAC,OAAO,EAAE;QACjB,KAAK,EAAE,UAAU,CAAC;QAClB,MAAM,EAAE,WAAW,CAAC;KACrB,GAAG,OAAO,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAClD,YAAY,CACV,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,CAAC,CAAC;CAC1D;AASD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAKzE;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,mBAAmB,GAC7B,IAAI,CAqBN;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EACxD,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,EACnC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,MAAM,CAAC,GACvD,OAAO,CAAC,MAAM,CAAC,CAKjB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { prepareUsageRecord } from "./records.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { defineUsagePlan } from "./contracts.js";
|
|
4
|
+
const seconds = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
5
|
+
const pageSchema = z.strictObject({
|
|
6
|
+
period: z.strictObject({ start: seconds, end: seconds }),
|
|
7
|
+
limit: z.number().int().min(1).max(100),
|
|
8
|
+
cursor: z.string().min(1).max(2048).nullable(),
|
|
9
|
+
});
|
|
10
|
+
export function validateUsagePageRequest(input) {
|
|
11
|
+
const request = pageSchema.parse(input);
|
|
12
|
+
if (request.period.end <= request.period.start)
|
|
13
|
+
throw new Error("Usage period must have a positive duration");
|
|
14
|
+
return request;
|
|
15
|
+
}
|
|
16
|
+
export function assertUsageReplay(original, candidate) {
|
|
17
|
+
const signature = (record) => JSON.stringify([
|
|
18
|
+
record.schemaVersion,
|
|
19
|
+
record.identity,
|
|
20
|
+
record.sourceEventId,
|
|
21
|
+
record.scope.livemode,
|
|
22
|
+
record.scope.stripeAccountId,
|
|
23
|
+
record.scope.customerAccount,
|
|
24
|
+
record.scope.meterId,
|
|
25
|
+
record.quantity,
|
|
26
|
+
record.scaledQuantity,
|
|
27
|
+
record.occurredAt,
|
|
28
|
+
record.binding.stripeCustomerId,
|
|
29
|
+
record.binding.stripePriceId,
|
|
30
|
+
record.binding.eventName,
|
|
31
|
+
record.binding.apiVersion,
|
|
32
|
+
defineUsagePlan(record.binding.plan),
|
|
33
|
+
]);
|
|
34
|
+
if (signature(original) !== signature(candidate))
|
|
35
|
+
throw new Error("Conflicting usage replay");
|
|
36
|
+
}
|
|
37
|
+
export async function authorizeUsageRecord(ctx, policy, input, accept) {
|
|
38
|
+
const record = prepareUsageRecord(input);
|
|
39
|
+
await policy.authorize(ctx, { scope: record.scope, operation: "record" });
|
|
40
|
+
await policy.authorizeActivity(ctx, record);
|
|
41
|
+
return accept(record);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=boundaries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundaries.js","sourceRoot":"","sources":["../../../src/client/usage/boundaries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC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MAAM,CAAC,QAAQ;QACf,MAAM,CAAC,cAAc;QACrB,MAAM,CAAC,UAAU;QACjB,MAAM,CAAC,OAAO,CAAC,gBAAgB;QAC/B,MAAM,CAAC,OAAO,CAAC,aAAa;QAC5B,MAAM,CAAC,OAAO,CAAC,SAAS;QACxB,MAAM,CAAC,OAAO,CAAC,UAAU;QACzB,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;KACrC,CAAC,CAAC;IACL,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,SAAS,CAAC,SAAS,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAY,EACZ,MAAmC,EACnC,KAAc,EACd,MAAwD;IAExD,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1E,MAAM,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Component, RunCtx } from "../helpers.js";
|
|
2
|
+
import { type PreparedUsageRecord, type UsageScope, type UsageDeliveryState } from "./records.js";
|
|
3
|
+
import { type UsagePageRequest, type UsageSubscriptionBinding, type UsageReceipt } from "./boundaries.js";
|
|
4
|
+
import type { Id } from "../../component/_generated/dataModel.js";
|
|
5
|
+
import type { FunctionHandle } from "convex/server";
|
|
6
|
+
export type RecordUsageOptions = {
|
|
7
|
+
event: unknown;
|
|
8
|
+
subscription: UsageSubscriptionBinding;
|
|
9
|
+
reservationId?: Id<"usageReservations">;
|
|
10
|
+
dispatch?: FunctionHandle<"action">;
|
|
11
|
+
quota?: number;
|
|
12
|
+
};
|
|
13
|
+
export type UsageEventView = {
|
|
14
|
+
receipt: UsageReceipt;
|
|
15
|
+
record: PreparedUsageRecord;
|
|
16
|
+
subscription: UsageSubscriptionBinding;
|
|
17
|
+
delivery: UsageDeliveryState;
|
|
18
|
+
};
|
|
19
|
+
/** Trusted host facade. Authenticate and authorize each exact scope first. */
|
|
20
|
+
export declare class UsageLedgerClient {
|
|
21
|
+
private readonly component;
|
|
22
|
+
constructor(component: Component);
|
|
23
|
+
record(ctx: RunCtx, opts: RecordUsageOptions): Promise<UsageReceipt>;
|
|
24
|
+
get(ctx: RunCtx, opts: {
|
|
25
|
+
scope: UsageScope;
|
|
26
|
+
eventId: string;
|
|
27
|
+
}): Promise<UsageEventView | null>;
|
|
28
|
+
read(ctx: RunCtx, opts: {
|
|
29
|
+
scope: UsageScope;
|
|
30
|
+
page: UsagePageRequest;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
events: UsageEventView[];
|
|
33
|
+
cursor: string | null;
|
|
34
|
+
isDone: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/usage/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAO,EAAE,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,wBAAwB,CAAC;IACvC,aAAa,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,YAAY,EAAE,wBAAwB,CAAC;IACvC,QAAQ,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAiBF,8EAA8E;AAC9E,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAtC,YAA6B,SAAS,EAAE,SAAS,EAAI;IAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAoBzE;IACK,GAAG,CACP,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAC3C,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAMhC;IACK,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,gBAAgB,CAAA;KAAE;;;;OAe1E;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { runMutationOrThrow } from "../helpers.js";
|
|
2
|
+
import { componentRef } from "../webhooks/helpers.js";
|
|
3
|
+
import { prepareUsageRecord, } from "./records.js";
|
|
4
|
+
import { validateUsagePageRequest, } from "./boundaries.js";
|
|
5
|
+
function decode({ event, delivery }) {
|
|
6
|
+
return {
|
|
7
|
+
receipt: {
|
|
8
|
+
eventId: event._id,
|
|
9
|
+
identity: event.identity,
|
|
10
|
+
acceptedAt: event.acceptedAt,
|
|
11
|
+
delivery: "queued",
|
|
12
|
+
},
|
|
13
|
+
record: JSON.parse(event.recordJson),
|
|
14
|
+
subscription: JSON.parse(event.subscriptionJson),
|
|
15
|
+
delivery,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Trusted host facade. Authenticate and authorize each exact scope first. */
|
|
19
|
+
export class UsageLedgerClient {
|
|
20
|
+
component;
|
|
21
|
+
constructor(component) {
|
|
22
|
+
this.component = component;
|
|
23
|
+
}
|
|
24
|
+
async record(ctx, opts) {
|
|
25
|
+
const event = prepareUsageRecord(opts.event);
|
|
26
|
+
const input = {
|
|
27
|
+
scope: event.scope,
|
|
28
|
+
binding: event.binding,
|
|
29
|
+
sourceEventId: event.sourceEventId,
|
|
30
|
+
quantity: event.quantity,
|
|
31
|
+
occurredAt: event.occurredAt,
|
|
32
|
+
};
|
|
33
|
+
return runMutationOrThrow(ctx, componentRef(this.component, "usage/mutations/record"), {
|
|
34
|
+
inputJson: JSON.stringify(input),
|
|
35
|
+
subscriptionJson: JSON.stringify(opts.subscription),
|
|
36
|
+
dispatch: opts.dispatch,
|
|
37
|
+
reservationId: opts.reservationId,
|
|
38
|
+
quota: opts.quota,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async get(ctx, opts) {
|
|
42
|
+
const result = (await ctx.runQuery(componentRef(this.component, "usage/queries/get"), opts));
|
|
43
|
+
return result ? decode(result) : null;
|
|
44
|
+
}
|
|
45
|
+
async read(ctx, opts) {
|
|
46
|
+
const page = validateUsagePageRequest(opts.page);
|
|
47
|
+
const result = (await ctx.runQuery(componentRef(this.component, "usage/queries/read"), {
|
|
48
|
+
scope: opts.scope,
|
|
49
|
+
period: page.period,
|
|
50
|
+
paginationOpts: { numItems: page.limit, cursor: page.cursor },
|
|
51
|
+
}));
|
|
52
|
+
return {
|
|
53
|
+
events: result.page.map(decode),
|
|
54
|
+
cursor: result.isDone ? null : result.continueCursor,
|
|
55
|
+
isDone: result.isDone,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/client/usage/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,kBAAkB,GAInB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wBAAwB,GAIzB,MAAM,iBAAiB,CAAC;AAiBzB,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAc;IAC7C,OAAO;QACL,OAAO,EAAE;YACP,OAAO,EAAE,KAAK,CAAC,GAAG;YAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,QAAQ,EAAE,QAAQ;SACnB;QACD,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAwB;QAC3D,YAAY,EAAE,IAAI,CAAC,KAAK,CACtB,KAAK,CAAC,gBAAgB,CACK;QAC7B,QAAQ;KACT,CAAC;AACJ,CAAC;AACD,8EAA8E;AAC9E,MAAM,OAAO,iBAAiB;IACC,SAAS;IAAtC,YAA6B,SAAoB;yBAApB,SAAS;IAAc,CAAC;IACrD,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,IAAwB;QAChD,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,MAAM,KAAK,GAAG;YACZ,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,KAAK,CAAC,UAAU;SAC7B,CAAC;QACF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CAAC,cAAc;YACpD,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const planSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
key: z.ZodString;
|
|
4
|
+
version: z.ZodString;
|
|
5
|
+
unit: z.ZodObject<{
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
precision: z.ZodNumber;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
rate: z.ZodObject<{
|
|
10
|
+
currency: z.ZodString;
|
|
11
|
+
unitAmountDecimal: z.ZodString;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
model: z.ZodLiteral<"pay_as_you_go">;
|
|
14
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
15
|
+
key: z.ZodString;
|
|
16
|
+
version: z.ZodString;
|
|
17
|
+
unit: z.ZodObject<{
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
precision: z.ZodNumber;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
rate: z.ZodObject<{
|
|
22
|
+
currency: z.ZodString;
|
|
23
|
+
unitAmountDecimal: z.ZodString;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
model: z.ZodLiteral<"included_overage">;
|
|
26
|
+
includedQuantity: z.ZodString;
|
|
27
|
+
reset: z.ZodLiteral<"billing_period">;
|
|
28
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
29
|
+
key: z.ZodString;
|
|
30
|
+
version: z.ZodString;
|
|
31
|
+
unit: z.ZodObject<{
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
precision: z.ZodNumber;
|
|
34
|
+
}, z.core.$strict>;
|
|
35
|
+
rate: z.ZodObject<{
|
|
36
|
+
currency: z.ZodString;
|
|
37
|
+
unitAmountDecimal: z.ZodString;
|
|
38
|
+
}, z.core.$strict>;
|
|
39
|
+
model: z.ZodLiteral<"prepaid">;
|
|
40
|
+
insufficientBalance: z.ZodLiteral<"reject">;
|
|
41
|
+
}, z.core.$strict>], "model">;
|
|
42
|
+
/** Configuration contracts only. Validating a plan does not enable billing. */
|
|
43
|
+
export type UsagePlan = z.infer<typeof planSchema>;
|
|
44
|
+
export type UsageBillingModel = UsagePlan["model"];
|
|
45
|
+
export type ExactUsageQuantity = {
|
|
46
|
+
quantity: string;
|
|
47
|
+
scaledQuantity: string;
|
|
48
|
+
precision: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Parse a nonnegative decimal quantity without rounding. The shared contract
|
|
52
|
+
* supports 0–6 decimal places and at most 18 scaled digits. A provider adapter
|
|
53
|
+
* must additionally enforce its own supported bounds before accepting usage.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseUsageQuantity(value: unknown, precision: number): ExactUsageQuantity;
|
|
56
|
+
/** Validate and copy terms; provider provisioning and host authorization are separate. */
|
|
57
|
+
export declare function defineUsagePlan(input: unknown): UsagePlan;
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/client/usage/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAad,CAAC;AAEH,+EAA+E;AAC/E,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;AACnD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,GAChB,kBAAkB,CAqBpB;AAED,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAKzD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const unit = z.strictObject({
|
|
3
|
+
name: z.string().min(1).max(100),
|
|
4
|
+
precision: z.number().int().min(0).max(6),
|
|
5
|
+
});
|
|
6
|
+
const rate = z.strictObject({
|
|
7
|
+
currency: z.string().regex(/^[a-z]{3}$/),
|
|
8
|
+
// Decimal minor currency units per whole billable unit, never a JS float.
|
|
9
|
+
unitAmountDecimal: z.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,12})?$/),
|
|
10
|
+
});
|
|
11
|
+
const common = {
|
|
12
|
+
key: z.string().min(1).max(100),
|
|
13
|
+
version: z.string().min(1).max(100),
|
|
14
|
+
unit,
|
|
15
|
+
rate,
|
|
16
|
+
};
|
|
17
|
+
const planSchema = z.discriminatedUnion("model", [
|
|
18
|
+
z.strictObject({ ...common, model: z.literal("pay_as_you_go") }),
|
|
19
|
+
z.strictObject({
|
|
20
|
+
...common,
|
|
21
|
+
model: z.literal("included_overage"),
|
|
22
|
+
includedQuantity: z.string(),
|
|
23
|
+
reset: z.literal("billing_period"),
|
|
24
|
+
}),
|
|
25
|
+
z.strictObject({
|
|
26
|
+
...common,
|
|
27
|
+
model: z.literal("prepaid"),
|
|
28
|
+
insufficientBalance: z.literal("reject"),
|
|
29
|
+
}),
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Parse a nonnegative decimal quantity without rounding. The shared contract
|
|
33
|
+
* supports 0–6 decimal places and at most 18 scaled digits. A provider adapter
|
|
34
|
+
* must additionally enforce its own supported bounds before accepting usage.
|
|
35
|
+
*/
|
|
36
|
+
export function parseUsageQuantity(value, precision) {
|
|
37
|
+
if (!Number.isInteger(precision) || precision < 0 || precision > 6)
|
|
38
|
+
throw new Error("Usage precision must be an integer between 0 and 6");
|
|
39
|
+
if (typeof value !== "string" ||
|
|
40
|
+
value.length > 25 ||
|
|
41
|
+
!/^(0|[1-9]\d*)(\.\d+)?$/.test(value))
|
|
42
|
+
throw new Error("Usage quantity must be a nonnegative decimal string");
|
|
43
|
+
const [whole, fraction = ""] = value.split(".");
|
|
44
|
+
if (fraction.length > precision)
|
|
45
|
+
throw new Error("Usage quantity exceeds configured precision");
|
|
46
|
+
const scaled = BigInt(whole + fraction.padEnd(precision, "0"));
|
|
47
|
+
if (scaled > 999999999999999999n)
|
|
48
|
+
throw new Error("Usage quantity exceeds the shared scaled bound");
|
|
49
|
+
const normalizedFraction = fraction.replace(/0+$/, "");
|
|
50
|
+
return {
|
|
51
|
+
quantity: normalizedFraction ? `${whole}.${normalizedFraction}` : whole,
|
|
52
|
+
scaledQuantity: scaled.toString(),
|
|
53
|
+
precision,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Validate and copy terms; provider provisioning and host authorization are separate. */
|
|
57
|
+
export function defineUsagePlan(input) {
|
|
58
|
+
const plan = planSchema.parse(input);
|
|
59
|
+
if (plan.model === "included_overage")
|
|
60
|
+
parseUsageQuantity(plan.includedQuantity, plan.unit.precision);
|
|
61
|
+
return plan;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/client/usage/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,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AAC;IACjE,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { defineUsagePlan, parseUsageQuantity } from "./contracts.js";
|
|
2
|
+
export type { UsagePlan, UsageBillingModel, ExactUsageQuantity, } from "./contracts.js";
|
|
3
|
+
export { prepareUsageRecord } from "./records.js";
|
|
4
|
+
export type { UsageScope, PreparedUsageRecord, UsageDeliveryState, } from "./records.js";
|
|
5
|
+
export { assertUsageReplay, validateUsagePageRequest, authorizeUsageRecord, } from "./boundaries.js";
|
|
6
|
+
export type { UsagePeriod, UsagePageRequest, UsageAvailability, UsageAuthorization, UsageObservations, UsageCorrectionRequest, UsageRetentionPolicy, UsageTransitionRequest, UsageSubscriptionBinding, UsageCreditProvenance, UsageCorrectionOutcome, UsageReceipt, UsageHistoryPage, UsageProviderCapabilities, UsageContractPort, } from "./boundaries.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/usage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACrE,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EACV,UAAU,EACV,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,EAChB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/usage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAMrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAMlD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type UsagePlan } from "./contracts.js";
|
|
3
|
+
export declare const scopeSchema: z.ZodObject<{
|
|
4
|
+
stripeAccountId: z.ZodString;
|
|
5
|
+
customerAccount: z.ZodString;
|
|
6
|
+
meterId: z.ZodString;
|
|
7
|
+
livemode: z.ZodBoolean;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
declare const recordSchema: z.ZodObject<{
|
|
10
|
+
scope: z.ZodObject<{
|
|
11
|
+
stripeAccountId: z.ZodString;
|
|
12
|
+
customerAccount: z.ZodString;
|
|
13
|
+
meterId: z.ZodString;
|
|
14
|
+
livemode: z.ZodBoolean;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
binding: z.ZodObject<{
|
|
17
|
+
stripeCustomerId: z.ZodString;
|
|
18
|
+
stripePriceId: z.ZodString;
|
|
19
|
+
eventName: z.ZodString;
|
|
20
|
+
apiVersion: z.ZodDefault<z.ZodEnum<{
|
|
21
|
+
"2026-09-30.endive": "2026-09-30.endive";
|
|
22
|
+
"2026-09-30.preview": "2026-09-30.preview";
|
|
23
|
+
}>>;
|
|
24
|
+
plan: z.ZodUnknown;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
sourceEventId: z.ZodString;
|
|
27
|
+
quantity: z.ZodUnknown;
|
|
28
|
+
occurredAt: z.ZodNumber;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
/** The exact Stripe realm, Accounts v2 payer, meter and test/live scope. */
|
|
31
|
+
export type UsageScope = z.infer<typeof scopeSchema>;
|
|
32
|
+
export type PreparedUsageRecord = Omit<z.infer<typeof recordSchema>, "quantity" | "binding"> & {
|
|
33
|
+
schemaVersion: 1;
|
|
34
|
+
identity: string;
|
|
35
|
+
quantity: string;
|
|
36
|
+
scaledQuantity: string;
|
|
37
|
+
binding: Omit<z.infer<typeof recordSchema>["binding"], "plan"> & {
|
|
38
|
+
plan: UsagePlan;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type UsageDeliveryState = "queued" | "sending" | "provider_accepted" | "rejected" | "unknown" | "held";
|
|
42
|
+
/**
|
|
43
|
+
* Validate and snapshot a record before acceptance. This pure helper does not
|
|
44
|
+
* authorize an actor, verify provider ownership, persist or deliver anything.
|
|
45
|
+
* Occurrence time is Unix seconds; native provider windows are enforced by the
|
|
46
|
+
* acceptance/delivery implementation, not by changing historical event time.
|
|
47
|
+
*/
|
|
48
|
+
export declare function prepareUsageRecord(input: unknown): PreparedUsageRecord;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../src/client/usage/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,WAAW;;;;;kBAKtB,CAAC;AACH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;kBAchB,CAAC;AAEH,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACrD,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,EAC5B,UAAU,GAAG,SAAS,CACvB,GAAG;IACF,aAAa,EAAE,CAAC,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,GAAG;QAC/D,IAAI,EAAE,SAAS,CAAC;KACjB,CAAC;CACH,CAAC;AACF,MAAM,MAAM,kBAAkB,GAC5B,QAAQ,GAAG,SAAS,GAAG,mBAAmB,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;AAE/E;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAqBtE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { STRIPE_API_VERSION } from "../constants.js";
|
|
3
|
+
import { STRIPE_CUSTOMER_PREVIEW_API_VERSION } from "../apiVersion.js";
|
|
4
|
+
import { defineUsagePlan, parseUsageQuantity, } from "./contracts.js";
|
|
5
|
+
export const scopeSchema = z.strictObject({
|
|
6
|
+
stripeAccountId: z.string().regex(/^acct_[a-zA-Z0-9]+$/),
|
|
7
|
+
customerAccount: z.string().regex(/^acct_[a-zA-Z0-9]+$/),
|
|
8
|
+
meterId: z.string().regex(/^mtr_[a-zA-Z0-9_]+$/),
|
|
9
|
+
livemode: z.boolean(),
|
|
10
|
+
});
|
|
11
|
+
const recordSchema = z.strictObject({
|
|
12
|
+
scope: scopeSchema,
|
|
13
|
+
binding: z.strictObject({
|
|
14
|
+
stripeCustomerId: z.string().regex(/^cus_[a-zA-Z0-9]+$/),
|
|
15
|
+
stripePriceId: z.string().regex(/^price_[a-zA-Z0-9]+$/),
|
|
16
|
+
eventName: z.string().min(1).max(100),
|
|
17
|
+
apiVersion: z
|
|
18
|
+
.enum([STRIPE_API_VERSION, STRIPE_CUSTOMER_PREVIEW_API_VERSION])
|
|
19
|
+
.default(STRIPE_API_VERSION),
|
|
20
|
+
plan: z.unknown(),
|
|
21
|
+
}),
|
|
22
|
+
sourceEventId: z.string().min(1).max(200),
|
|
23
|
+
quantity: z.unknown(),
|
|
24
|
+
occurredAt: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Validate and snapshot a record before acceptance. This pure helper does not
|
|
28
|
+
* authorize an actor, verify provider ownership, persist or deliver anything.
|
|
29
|
+
* Occurrence time is Unix seconds; native provider windows are enforced by the
|
|
30
|
+
* acceptance/delivery implementation, not by changing historical event time.
|
|
31
|
+
*/
|
|
32
|
+
export function prepareUsageRecord(input) {
|
|
33
|
+
const record = recordSchema.parse(input);
|
|
34
|
+
const plan = defineUsagePlan(record.binding.plan);
|
|
35
|
+
const quantity = parseUsageQuantity(record.quantity, plan.unit.precision);
|
|
36
|
+
const scope = record.scope;
|
|
37
|
+
return {
|
|
38
|
+
...record,
|
|
39
|
+
schemaVersion: 1,
|
|
40
|
+
quantity: quantity.quantity,
|
|
41
|
+
scaledQuantity: quantity.scaledQuantity,
|
|
42
|
+
binding: { ...record.binding, plan },
|
|
43
|
+
// A plan/version/quantity change must conflict with the original source
|
|
44
|
+
// event, so these are deliberately outside the deduplication identity.
|
|
45
|
+
identity: JSON.stringify([
|
|
46
|
+
scope.livemode,
|
|
47
|
+
scope.stripeAccountId,
|
|
48
|
+
scope.customerAccount,
|
|
49
|
+
scope.meterId,
|
|
50
|
+
record.sourceEventId,
|
|
51
|
+
]),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../../src/client/usage/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EA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AAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC;CACxE,CAAC,CAAC;AAmBH;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3B,OAAO;QACL,GAAG,MAAM;QACT,aAAa,EAAE,CAAC;QAChB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,OAAO,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE;QACpC,wEAAwE;QACxE,uEAAuE;QACvE,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;YACvB,KAAK,CAAC,QAAQ;YACd,KAAK,CAAC,eAAe;YACrB,KAAK,CAAC,eAAe;YACrB,KAAK,CAAC,OAAO;YACb,MAAM,CAAC,aAAa;SACrB,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -160,6 +160,9 @@ import type * as settlement_clawbackSchema from "../settlement/clawbackSchema.js
|
|
|
160
160
|
import type * as settlement_clawbacks from "../settlement/clawbacks.js";
|
|
161
161
|
import type * as settlement_mutations from "../settlement/mutations.js";
|
|
162
162
|
import type * as settlement_queries from "../settlement/queries.js";
|
|
163
|
+
import type * as usage_helpers from "../usage/helpers.js";
|
|
164
|
+
import type * as usage_mutations from "../usage/mutations.js";
|
|
165
|
+
import type * as usage_queries from "../usage/queries.js";
|
|
163
166
|
import type * as webhooks_mutations from "../webhooks/mutations.js";
|
|
164
167
|
import type * as webhooks_queries from "../webhooks/queries.js";
|
|
165
168
|
import type * as webhooks_validators from "../webhooks/validators.js";
|
|
@@ -319,6 +322,9 @@ declare const fullApi: ApiFromModules<{
|
|
|
319
322
|
"settlement/clawbacks": typeof settlement_clawbacks;
|
|
320
323
|
"settlement/mutations": typeof settlement_mutations;
|
|
321
324
|
"settlement/queries": typeof settlement_queries;
|
|
325
|
+
"usage/helpers": typeof usage_helpers;
|
|
326
|
+
"usage/mutations": typeof usage_mutations;
|
|
327
|
+
"usage/queries": typeof usage_queries;
|
|
322
328
|
"webhooks/mutations": typeof webhooks_mutations;
|
|
323
329
|
"webhooks/queries": typeof webhooks_queries;
|
|
324
330
|
"webhooks/validators": typeof webhooks_validators;
|