@fantastic.dev/better-stripe 0.53.0 → 0.54.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 +6 -0
- package/README.md +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +116 -2
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +58 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +116 -2
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +58 -1
- 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 +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/usage/client.d.ts +2 -2
- package/dist/client/usage/client.d.ts.map +1 -1
- package/dist/client/usage/client.js +3 -3
- package/dist/client/usage/client.js.map +1 -1
- package/dist/client/usage/deliveryClient.d.ts +64 -0
- package/dist/client/usage/deliveryClient.d.ts.map +1 -0
- package/dist/client/usage/deliveryClient.js +60 -0
- package/dist/client/usage/deliveryClient.js.map +1 -0
- package/dist/client/usage/deliveryProtocol.d.ts +130 -0
- package/dist/client/usage/deliveryProtocol.d.ts.map +1 -0
- package/dist/client/usage/deliveryProtocol.js +21 -0
- package/dist/client/usage/deliveryProtocol.js.map +1 -0
- package/dist/client/usage/deliveryProvider.d.ts +32 -0
- package/dist/client/usage/deliveryProvider.d.ts.map +1 -0
- package/dist/client/usage/deliveryProvider.js +127 -0
- package/dist/client/usage/deliveryProvider.js.map +1 -0
- package/dist/client/usage/index.d.ts +3 -0
- package/dist/client/usage/index.d.ts.map +1 -1
- package/dist/client/usage/index.js +1 -0
- package/dist/client/usage/index.js.map +1 -1
- package/dist/client/webhooks/handler.d.ts.map +1 -1
- package/dist/client/webhooks/handler.js +2 -1
- package/dist/client/webhooks/handler.js.map +1 -1
- package/dist/client/webhooks/meterErrors.d.ts +5 -0
- package/dist/client/webhooks/meterErrors.d.ts.map +1 -0
- package/dist/client/webhooks/meterErrors.js +98 -0
- package/dist/client/webhooks/meterErrors.js.map +1 -0
- package/dist/client/webhooks/v2.d.ts.map +1 -1
- package/dist/client/webhooks/v2.js +5 -0
- package/dist/client/webhooks/v2.js.map +1 -1
- package/dist/component/_generated/api.d.ts +14 -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 +170 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/mutations.d.ts +43 -43
- package/dist/component/earnings/triggers.d.ts +104 -2
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/refundHistory/queries.d.ts +1 -1
- package/dist/component/schema.d.ts +58 -1
- package/dist/component/schema.js +3 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/usage/schema.d.ts +96 -1
- package/dist/component/usage/schema.d.ts.map +1 -1
- package/dist/component/usage/schema.js +11 -2
- package/dist/component/usage/schema.js.map +1 -1
- package/dist/component/usageDelivery/bridge.d.ts +25 -0
- package/dist/component/usageDelivery/bridge.d.ts.map +1 -0
- package/dist/component/usageDelivery/bridge.js +45 -0
- package/dist/component/usageDelivery/bridge.js.map +1 -0
- package/dist/component/usageDelivery/fields.d.ts +78 -0
- package/dist/component/usageDelivery/fields.d.ts.map +1 -0
- package/dist/component/usageDelivery/fields.js +38 -0
- package/dist/component/usageDelivery/fields.js.map +1 -0
- package/dist/component/usageDelivery/helpers.d.ts +83 -0
- package/dist/component/usageDelivery/helpers.d.ts.map +1 -0
- package/dist/component/usageDelivery/helpers.js +63 -0
- package/dist/component/usageDelivery/helpers.js.map +1 -0
- package/dist/component/usageDelivery/mutations.d.ts +97 -0
- package/dist/component/usageDelivery/mutations.d.ts.map +1 -0
- package/dist/component/usageDelivery/mutations.js +153 -0
- package/dist/component/usageDelivery/mutations.js.map +1 -0
- package/dist/component/usageDelivery/queries.d.ts +113 -0
- package/dist/component/usageDelivery/queries.d.ts.map +1 -0
- package/dist/component/usageDelivery/queries.js +22 -0
- package/dist/component/usageDelivery/queries.js.map +1 -0
- package/dist/component/usageDelivery/schema.d.ts +79 -0
- package/dist/component/usageDelivery/schema.d.ts.map +1 -0
- package/dist/component/usageDelivery/schema.js +30 -0
- package/dist/component/usageDelivery/schema.js.map +1 -0
- package/dist/component/usageDelivery/steps.d.ts +85 -0
- package/dist/component/usageDelivery/steps.d.ts.map +1 -0
- package/dist/component/usageDelivery/steps.js +154 -0
- package/dist/component/usageDelivery/steps.js.map +1 -0
- package/dist/component/usageDelivery/workflow.d.ts +15 -0
- package/dist/component/usageDelivery/workflow.d.ts.map +1 -0
- package/dist/component/usageDelivery/workflow.js +28 -0
- package/dist/component/usageDelivery/workflow.js.map +1 -0
- package/docs/README.md +3 -1
- package/docs/metering-setup.md +1 -1
- package/docs/usage-delivery.md +143 -0
- package/package.json +3 -2
- package/src/client/index.ts +16 -0
- package/src/client/usage/client.ts +5 -2
- package/src/client/usage/deliveryClient.ts +130 -0
- package/src/client/usage/deliveryProtocol.ts +26 -0
- package/src/client/usage/deliveryProvider.test.ts +207 -0
- package/src/client/usage/deliveryProvider.ts +155 -0
- package/src/client/usage/index.ts +13 -0
- package/src/client/webhooks/handler.ts +2 -1
- package/src/client/webhooks/meterErrors.test.ts +164 -0
- package/src/client/webhooks/meterErrors.ts +118 -0
- package/src/client/webhooks/v2.ts +5 -0
- package/src/component/_generated/api.ts +14 -0
- package/src/component/_generated/component.ts +302 -0
- package/src/component/schema.ts +6 -0
- package/src/component/usage/schema.ts +11 -2
- package/src/component/usageDelivery/bridge.ts +56 -0
- package/src/component/usageDelivery/concurrency.test.ts +62 -0
- package/src/component/usageDelivery/fields.ts +59 -0
- package/src/component/usageDelivery/helpers.ts +77 -0
- package/src/component/usageDelivery/mutations.ts +185 -0
- package/src/component/usageDelivery/queries.ts +25 -0
- package/src/component/usageDelivery/schema.ts +33 -0
- package/src/component/usageDelivery/steps.ts +171 -0
- package/src/component/usageDelivery/workflow.test.ts +402 -0
- package/src/component/usageDelivery/workflow.ts +36 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/usage/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;CACtB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CACtC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EACnB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAC9B,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EACrB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAClB,CAAC;AACF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC;IACpD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACt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AAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;CACzC,CAAC,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const invoke: import("convex/server").RegisteredAction<"internal", {
|
|
2
|
+
apiVersion: string;
|
|
3
|
+
attempt: number;
|
|
4
|
+
definitionVersion: 1;
|
|
5
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
6
|
+
identifier: string;
|
|
7
|
+
scope: {
|
|
8
|
+
customerAccount: string;
|
|
9
|
+
livemode: boolean;
|
|
10
|
+
meterId: string;
|
|
11
|
+
stripeAccountId: string;
|
|
12
|
+
};
|
|
13
|
+
}, Promise<{
|
|
14
|
+
created: number;
|
|
15
|
+
status: "accepted";
|
|
16
|
+
} | {
|
|
17
|
+
status: "rate_limited";
|
|
18
|
+
} | {
|
|
19
|
+
status: "unavailable";
|
|
20
|
+
} | {
|
|
21
|
+
status: "unknown";
|
|
22
|
+
} | {
|
|
23
|
+
status: "rejected";
|
|
24
|
+
}>>;
|
|
25
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../../src/component/usageDelivery/bridge.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;GAuCjB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { anyApi } from "convex/server";
|
|
2
|
+
import { internalAction } from "../_generated/server.js";
|
|
3
|
+
import { request } from "./schema.js";
|
|
4
|
+
import { outcome } from "./fields.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
const accepted = z.strictObject({
|
|
7
|
+
status: z.literal("accepted"),
|
|
8
|
+
created: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
9
|
+
});
|
|
10
|
+
const parsedOutcome = z.union([
|
|
11
|
+
accepted,
|
|
12
|
+
z.strictObject({
|
|
13
|
+
status: z.enum(["rate_limited", "unavailable", "unknown", "rejected"]),
|
|
14
|
+
}),
|
|
15
|
+
]);
|
|
16
|
+
export const invoke = internalAction({
|
|
17
|
+
args: request,
|
|
18
|
+
returns: outcome,
|
|
19
|
+
handler: async (ctx, args) => {
|
|
20
|
+
try {
|
|
21
|
+
const { outbox } = await ctx.runQuery(anyApi.usageDelivery.queries.saved, { scope: args.scope, eventId: args.eventId });
|
|
22
|
+
if (outbox.held)
|
|
23
|
+
return { status: "unavailable" };
|
|
24
|
+
if (!outbox.provider ||
|
|
25
|
+
outbox.attempts !== args.attempt ||
|
|
26
|
+
outbox.state !== "sending" ||
|
|
27
|
+
outbox.providerIdentifier !== args.identifier)
|
|
28
|
+
return { status: "unknown" };
|
|
29
|
+
const raw = await ctx.runAction(outbox.provider, args);
|
|
30
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
31
|
+
return { status: "unknown" };
|
|
32
|
+
const result = raw;
|
|
33
|
+
if (Object.keys(result).length !== Object.keys(args).length + 1 ||
|
|
34
|
+
Object.keys(args).some((key) => JSON.stringify(result[key]) !==
|
|
35
|
+
JSON.stringify(args[key])))
|
|
36
|
+
return { status: "unknown" };
|
|
37
|
+
const validated = parsedOutcome.safeParse(result.outcome);
|
|
38
|
+
return validated.success ? validated.data : { status: "unknown" };
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return { status: "unknown" };
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../src/component/usageDelivery/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,y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AkB,KAAK,IAAI,CAAC,UAAU;gBAE7C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;YAC/B,MAAM,GAAG,GAAY,MAAM,GAAG,CAAC,SAAS,CACtC,MAAM,CAAC,QAAoC,EAC3C,IAAI,CACL,CAAC;YACF,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;gBACvD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,GAA8B,CAAC;YAC9C,IACE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;gBAC3D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CACpB,CAAC,GAAG,EAAE,EAAE,CACN,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBAC3B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAwB,CAAC,CAAC,CACjD;gBAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;YAC/B,MAAM,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC1D,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QACpE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export declare const reason: import("convex/values").VUnion<"administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy", [import("convex/values").VLiteral<"rate_limited", "required">, import("convex/values").VLiteral<"provider_unavailable", "required">, import("convex/values").VLiteral<"provider_outcome_unknown", "required">, import("convex/values").VLiteral<"provider_rejected", "required">, import("convex/values").VLiteral<"retry_exhausted", "required">, import("convex/values").VLiteral<"delivery_window_expired", "required">, import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"administrative_hold", "required">], "required", never>;
|
|
2
|
+
export { usageDeliveryOutcomeValidator as outcome } from "../../client/usage/deliveryProtocol.js";
|
|
3
|
+
export declare const deliveryFields: {
|
|
4
|
+
provider: import("convex/values").VString<string | undefined, "optional">;
|
|
5
|
+
workflowId: import("convex/values").VString<string | undefined, "optional">;
|
|
6
|
+
definitionVersion: import("convex/values").VLiteral<1 | undefined, "optional">;
|
|
7
|
+
firstSendAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
8
|
+
leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
9
|
+
held: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
10
|
+
reason: import("convex/values").VUnion<"administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined, [import("convex/values").VLiteral<"rate_limited", "required">, import("convex/values").VLiteral<"provider_unavailable", "required">, import("convex/values").VLiteral<"provider_outcome_unknown", "required">, import("convex/values").VLiteral<"provider_rejected", "required">, import("convex/values").VLiteral<"retry_exhausted", "required">, import("convex/values").VLiteral<"delivery_window_expired", "required">, import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"administrative_hold", "required">], "optional", never>;
|
|
11
|
+
receipt: import("convex/values").VObject<{
|
|
12
|
+
created: number;
|
|
13
|
+
identifier: string;
|
|
14
|
+
} | undefined, {
|
|
15
|
+
identifier: import("convex/values").VString<string, "required">;
|
|
16
|
+
created: import("convex/values").VFloat64<number, "required">;
|
|
17
|
+
}, "optional", "created" | "identifier">;
|
|
18
|
+
};
|
|
19
|
+
export declare const locksTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
20
|
+
eventId?: import("convex/values").GenericId<"usageEvents"> | undefined;
|
|
21
|
+
key: string;
|
|
22
|
+
leaseUntil: number;
|
|
23
|
+
nextAttemptAt: number;
|
|
24
|
+
}, {
|
|
25
|
+
key: import("convex/values").VString<string, "required">;
|
|
26
|
+
eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents"> | undefined, "optional">;
|
|
27
|
+
leaseUntil: import("convex/values").VFloat64<number, "required">;
|
|
28
|
+
nextAttemptAt: import("convex/values").VFloat64<number, "required">;
|
|
29
|
+
}, "required", "eventId" | "key" | "leaseUntil" | "nextAttemptAt">, {
|
|
30
|
+
by_key: ["key", "_creationTime"];
|
|
31
|
+
}, {}, {}>;
|
|
32
|
+
export declare const errorCode: import("convex/values").VUnion<"archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past", [import("convex/values").VLiteral<"meter_event_customer_not_found", "required">, import("convex/values").VLiteral<"meter_event_no_customer_defined", "required">, import("convex/values").VLiteral<"meter_event_dimension_count_too_high", "required">, import("convex/values").VLiteral<"archived_meter", "required">, import("convex/values").VLiteral<"timestamp_too_far_in_past", "required">, import("convex/values").VLiteral<"timestamp_in_future", "required">, import("convex/values").VLiteral<"meter_event_value_not_found", "required">, import("convex/values").VLiteral<"meter_event_invalid_value", "required">, import("convex/values").VLiteral<"no_meter", "required">], "required", never>;
|
|
33
|
+
export declare const errorFields: {
|
|
34
|
+
scopeKey: import("convex/values").VString<string, "required">;
|
|
35
|
+
eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
|
|
36
|
+
providerEventId: import("convex/values").VString<string, "required">;
|
|
37
|
+
code: import("convex/values").VUnion<"archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past", [import("convex/values").VLiteral<"meter_event_customer_not_found", "required">, import("convex/values").VLiteral<"meter_event_no_customer_defined", "required">, import("convex/values").VLiteral<"meter_event_dimension_count_too_high", "required">, import("convex/values").VLiteral<"archived_meter", "required">, import("convex/values").VLiteral<"timestamp_too_far_in_past", "required">, import("convex/values").VLiteral<"timestamp_in_future", "required">, import("convex/values").VLiteral<"meter_event_value_not_found", "required">, import("convex/values").VLiteral<"meter_event_invalid_value", "required">, import("convex/values").VLiteral<"no_meter", "required">], "required", never>;
|
|
38
|
+
observedAt: import("convex/values").VFloat64<number, "required">;
|
|
39
|
+
dedupe: import("convex/values").VString<string, "required">;
|
|
40
|
+
};
|
|
41
|
+
export declare const errorDoc: import("convex/values").VObject<{
|
|
42
|
+
_creationTime: number;
|
|
43
|
+
_id: import("convex/values").GenericId<"usageDeliveryErrors">;
|
|
44
|
+
code: "archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past";
|
|
45
|
+
dedupe: string;
|
|
46
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
47
|
+
observedAt: number;
|
|
48
|
+
providerEventId: string;
|
|
49
|
+
scopeKey: string;
|
|
50
|
+
}, {
|
|
51
|
+
scopeKey: import("convex/values").VString<string, "required">;
|
|
52
|
+
eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
|
|
53
|
+
providerEventId: import("convex/values").VString<string, "required">;
|
|
54
|
+
code: import("convex/values").VUnion<"archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past", [import("convex/values").VLiteral<"meter_event_customer_not_found", "required">, import("convex/values").VLiteral<"meter_event_no_customer_defined", "required">, import("convex/values").VLiteral<"meter_event_dimension_count_too_high", "required">, import("convex/values").VLiteral<"archived_meter", "required">, import("convex/values").VLiteral<"timestamp_too_far_in_past", "required">, import("convex/values").VLiteral<"timestamp_in_future", "required">, import("convex/values").VLiteral<"meter_event_value_not_found", "required">, import("convex/values").VLiteral<"meter_event_invalid_value", "required">, import("convex/values").VLiteral<"no_meter", "required">], "required", never>;
|
|
55
|
+
observedAt: import("convex/values").VFloat64<number, "required">;
|
|
56
|
+
dedupe: import("convex/values").VString<string, "required">;
|
|
57
|
+
_id: import("convex/values").VId<import("convex/values").GenericId<"usageDeliveryErrors">, "required">;
|
|
58
|
+
_creationTime: import("convex/values").VFloat64<number, "required">;
|
|
59
|
+
}, "required", "_creationTime" | "_id" | "code" | "dedupe" | "eventId" | "observedAt" | "providerEventId" | "scopeKey">;
|
|
60
|
+
export declare const errorsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
61
|
+
code: "archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past";
|
|
62
|
+
dedupe: string;
|
|
63
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
64
|
+
observedAt: number;
|
|
65
|
+
providerEventId: string;
|
|
66
|
+
scopeKey: string;
|
|
67
|
+
}, {
|
|
68
|
+
scopeKey: import("convex/values").VString<string, "required">;
|
|
69
|
+
eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
|
|
70
|
+
providerEventId: import("convex/values").VString<string, "required">;
|
|
71
|
+
code: import("convex/values").VUnion<"archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past", [import("convex/values").VLiteral<"meter_event_customer_not_found", "required">, import("convex/values").VLiteral<"meter_event_no_customer_defined", "required">, import("convex/values").VLiteral<"meter_event_dimension_count_too_high", "required">, import("convex/values").VLiteral<"archived_meter", "required">, import("convex/values").VLiteral<"timestamp_too_far_in_past", "required">, import("convex/values").VLiteral<"timestamp_in_future", "required">, import("convex/values").VLiteral<"meter_event_value_not_found", "required">, import("convex/values").VLiteral<"meter_event_invalid_value", "required">, import("convex/values").VLiteral<"no_meter", "required">], "required", never>;
|
|
72
|
+
observedAt: import("convex/values").VFloat64<number, "required">;
|
|
73
|
+
dedupe: import("convex/values").VString<string, "required">;
|
|
74
|
+
}, "required", "code" | "dedupe" | "eventId" | "observedAt" | "providerEventId" | "scopeKey">, {
|
|
75
|
+
by_dedupe: ["dedupe", "_creationTime"];
|
|
76
|
+
by_event: ["eventId", "_creationTime"];
|
|
77
|
+
}, {}, {}>;
|
|
78
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/component/usageDelivery/fields.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,owBASlB,CAAC;AACF,OAAO,EAAE,6BAA6B,IAAI,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAClG,eAAO,MAAM,cAAc;IACzB,QAAQ;IACR,UAAU;IACV,iBAAiB;IACjB,WAAW;IACX,UAAU;IACV,IAAI;IACJ,MAAM;IACN,OAAO;;;;;;;CAGR,CAAC;AACF,eAAO,MAAM,UAAU;;;;;;;;;;;;UAKI,CAAC;AAE5B,eAAO,MAAM,SAAS,i9BAUrB,CAAC;AACF,eAAO,MAAM,WAAW;IACtB,QAAQ;IACR,OAAO;IACP,eAAe;IACf,IAAI;IACJ,UAAU;IACV,MAAM;CACP,CAAC;AACF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;uHAInB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;UAES,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineTable } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
export const reason = v.union(v.literal("rate_limited"), v.literal("provider_unavailable"), v.literal("provider_outcome_unknown"), v.literal("provider_rejected"), v.literal("retry_exhausted"), v.literal("delivery_window_expired"), v.literal("scope_busy"), v.literal("administrative_hold"));
|
|
4
|
+
export { usageDeliveryOutcomeValidator as outcome } from "../../client/usage/deliveryProtocol.js";
|
|
5
|
+
export const deliveryFields = {
|
|
6
|
+
provider: v.optional(v.string()),
|
|
7
|
+
workflowId: v.optional(v.string()),
|
|
8
|
+
definitionVersion: v.optional(v.literal(1)),
|
|
9
|
+
firstSendAt: v.optional(v.number()),
|
|
10
|
+
leaseUntil: v.optional(v.number()),
|
|
11
|
+
held: v.optional(v.boolean()),
|
|
12
|
+
reason: v.optional(reason),
|
|
13
|
+
receipt: v.optional(v.object({ identifier: v.string(), created: v.number() })),
|
|
14
|
+
};
|
|
15
|
+
export const locksTable = defineTable({
|
|
16
|
+
key: v.string(),
|
|
17
|
+
eventId: v.optional(v.id("usageEvents")),
|
|
18
|
+
leaseUntil: v.number(),
|
|
19
|
+
nextAttemptAt: v.number(),
|
|
20
|
+
}).index("by_key", ["key"]);
|
|
21
|
+
export const errorCode = v.union(v.literal("meter_event_customer_not_found"), v.literal("meter_event_no_customer_defined"), v.literal("meter_event_dimension_count_too_high"), v.literal("archived_meter"), v.literal("timestamp_too_far_in_past"), v.literal("timestamp_in_future"), v.literal("meter_event_value_not_found"), v.literal("meter_event_invalid_value"), v.literal("no_meter"));
|
|
22
|
+
export const errorFields = {
|
|
23
|
+
scopeKey: v.string(),
|
|
24
|
+
eventId: v.id("usageEvents"),
|
|
25
|
+
providerEventId: v.string(),
|
|
26
|
+
code: errorCode,
|
|
27
|
+
observedAt: v.number(),
|
|
28
|
+
dedupe: v.string(),
|
|
29
|
+
};
|
|
30
|
+
export const errorDoc = v.object({
|
|
31
|
+
_id: v.id("usageDeliveryErrors"),
|
|
32
|
+
_creationTime: v.number(),
|
|
33
|
+
...errorFields,
|
|
34
|
+
});
|
|
35
|
+
export const errorsTable = defineTable(errorFields)
|
|
36
|
+
.index("by_dedupe", ["dedupe"])
|
|
37
|
+
.index("by_event", ["eventId"]);
|
|
38
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../src/component/usageDelivery/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAC3B,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,EACzB,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,EACjC,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,EACrC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAC9B,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAC5B,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,EACpC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EACvB,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CACjC,CAAC;AACF,OAAO,EAAE,6BAA6B,IAAI,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAClG,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAChC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,iBAAiB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3C,WAAW,EAAE,CAAC,CAAC,QAAQ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MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC;IAC5B,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,IAAI,EAAE,SAAS;IACf,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;CACnB,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,qBAAqB,CAAC;IAChC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,GAAG,WAAW;CACf,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC;KAChD,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC;KAC9B,KAAK,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { QueryCtx } from "../_generated/server.js";
|
|
2
|
+
import type { Doc, Id } from "../_generated/dataModel.js";
|
|
3
|
+
import type { UsageScope, PreparedUsageRecord } from "../../client/usage/records.js";
|
|
4
|
+
export declare function read(ctx: QueryCtx, args: {
|
|
5
|
+
scope: UsageScope;
|
|
6
|
+
eventId: Id<"usageEvents">;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
event: {
|
|
9
|
+
_creationTime: number;
|
|
10
|
+
_id: import("convex/values").GenericId<"usageEvents">;
|
|
11
|
+
acceptedAt: number;
|
|
12
|
+
identity: string;
|
|
13
|
+
occurredAt: number;
|
|
14
|
+
recordJson: string;
|
|
15
|
+
reservationId?: import("convex/values").GenericId<"usageReservations"> | undefined;
|
|
16
|
+
scopeKey: string;
|
|
17
|
+
subscriptionJson: string;
|
|
18
|
+
};
|
|
19
|
+
outbox: {
|
|
20
|
+
_creationTime: number;
|
|
21
|
+
_id: import("convex/values").GenericId<"usageOutbox">;
|
|
22
|
+
attempts: number;
|
|
23
|
+
definitionVersion?: 1 | undefined;
|
|
24
|
+
dispatch?: string | undefined;
|
|
25
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
26
|
+
firstSendAt?: number | undefined;
|
|
27
|
+
held?: boolean | undefined;
|
|
28
|
+
leaseUntil?: number | undefined;
|
|
29
|
+
nextAttemptAt: number;
|
|
30
|
+
provider?: string | undefined;
|
|
31
|
+
providerIdentifier: string;
|
|
32
|
+
reason?: "administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
|
|
33
|
+
receipt?: {
|
|
34
|
+
created: number;
|
|
35
|
+
identifier: string;
|
|
36
|
+
} | undefined;
|
|
37
|
+
scopeKey: string;
|
|
38
|
+
state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
|
|
39
|
+
workflowId?: string | undefined;
|
|
40
|
+
};
|
|
41
|
+
record: PreparedUsageRecord;
|
|
42
|
+
}>;
|
|
43
|
+
export declare function statusOf(outbox: Doc<"usageOutbox">): {
|
|
44
|
+
validationErrors: Array<{
|
|
45
|
+
providerEventId: string;
|
|
46
|
+
code: import("convex/values").Infer<typeof import("./fields.js").errorCode>;
|
|
47
|
+
observedAt: number;
|
|
48
|
+
}>;
|
|
49
|
+
validationHistoryComplete: boolean;
|
|
50
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
51
|
+
state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
|
|
52
|
+
attempts: number;
|
|
53
|
+
held: boolean;
|
|
54
|
+
reason: "administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
|
|
55
|
+
providerIdentifier: string;
|
|
56
|
+
receipt: {
|
|
57
|
+
created: number;
|
|
58
|
+
identifier: string;
|
|
59
|
+
} | undefined;
|
|
60
|
+
};
|
|
61
|
+
export declare function lockKeys(record: PreparedUsageRecord): {
|
|
62
|
+
realm: string;
|
|
63
|
+
customer: string;
|
|
64
|
+
};
|
|
65
|
+
export declare function currentStatus(ctx: QueryCtx, outbox: Doc<"usageOutbox">): Promise<{
|
|
66
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
67
|
+
state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
|
|
68
|
+
attempts: number;
|
|
69
|
+
held: boolean;
|
|
70
|
+
reason: "administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
|
|
71
|
+
providerIdentifier: string;
|
|
72
|
+
receipt: {
|
|
73
|
+
created: number;
|
|
74
|
+
identifier: string;
|
|
75
|
+
} | undefined;
|
|
76
|
+
validationErrors: {
|
|
77
|
+
providerEventId: string;
|
|
78
|
+
code: "archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past";
|
|
79
|
+
observedAt: number;
|
|
80
|
+
}[];
|
|
81
|
+
validationHistoryComplete: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/component/usageDelivery/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AAEvC,wBAAsB,IAAI,CACxB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAab,mBAAmB;GAE9D;AACD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC;IAE/C,gBAAgB,EAAQ,KAAK,CAAC;QAC5B,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,OAAO,eAAe,EAAE,KAAK,CACjC,cAAc,aAAa,EAAE,SAAS,CACvC,CAAC;QACF,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,yBAAyB;IACzB,OAAO;IACP,KAAK;IACL,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,kBAAkB;IAClB,OAAO;;;;EAEV;AACD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,mBAAmB;;;EAanD;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;GAiB5E"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { scopeKey } from "../usage/helpers.js";
|
|
2
|
+
export async function read(ctx, args) {
|
|
3
|
+
const event = await ctx.db.get("usageEvents", args.eventId);
|
|
4
|
+
if (!event || event.scopeKey !== scopeKey(args.scope))
|
|
5
|
+
throw new Error("Usage delivery scope unavailable");
|
|
6
|
+
const outbox = await ctx.db
|
|
7
|
+
.query("usageOutbox")
|
|
8
|
+
.withIndex("by_event", (q) => q.eq("eventId", event._id))
|
|
9
|
+
.unique();
|
|
10
|
+
if (!outbox)
|
|
11
|
+
throw new Error("Usage outbox unavailable");
|
|
12
|
+
return {
|
|
13
|
+
event,
|
|
14
|
+
outbox,
|
|
15
|
+
record: JSON.parse(event.recordJson),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function statusOf(outbox) {
|
|
19
|
+
return {
|
|
20
|
+
validationErrors: [],
|
|
21
|
+
validationHistoryComplete: true,
|
|
22
|
+
eventId: outbox.eventId,
|
|
23
|
+
state: outbox.state,
|
|
24
|
+
attempts: outbox.attempts,
|
|
25
|
+
held: outbox.held ?? false,
|
|
26
|
+
reason: outbox.reason,
|
|
27
|
+
providerIdentifier: outbox.providerIdentifier,
|
|
28
|
+
receipt: outbox.receipt,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function lockKeys(record) {
|
|
32
|
+
const realm = JSON.stringify([
|
|
33
|
+
record.scope.stripeAccountId,
|
|
34
|
+
record.scope.livemode,
|
|
35
|
+
]);
|
|
36
|
+
return {
|
|
37
|
+
realm,
|
|
38
|
+
customer: JSON.stringify([
|
|
39
|
+
realm,
|
|
40
|
+
record.binding.stripeCustomerId,
|
|
41
|
+
record.scope.meterId,
|
|
42
|
+
]),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export async function currentStatus(ctx, outbox) {
|
|
46
|
+
const errors = await ctx.db
|
|
47
|
+
.query("usageDeliveryErrors")
|
|
48
|
+
.withIndex("by_event", (q) => q.eq("eventId", outbox.eventId))
|
|
49
|
+
.order("desc")
|
|
50
|
+
.take(21);
|
|
51
|
+
return {
|
|
52
|
+
...statusOf(outbox),
|
|
53
|
+
validationErrors: errors
|
|
54
|
+
.slice(0, 20)
|
|
55
|
+
.map(({ providerEventId, code, observedAt }) => ({
|
|
56
|
+
providerEventId,
|
|
57
|
+
code,
|
|
58
|
+
observedAt,
|
|
59
|
+
})),
|
|
60
|
+
validationHistoryComplete: errors.length <= 20,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/component/usageDelivery/helpers.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MA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AC,SAAS,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,eAAe;QAC5B,MAAM,CAAC,KAAK,CAAC,QAAQ;KACtB,CAAC,CAAC;IACH,OAAO;QACL,KAAK;QACL,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;YACvB,KAAK;YACL,MAAM,CAAC,OAAO,CAAC,gBAAgB;YAC/B,MAAM,CAAC,KAAK,CAAC,OAAO;SACrB,CAAC;KACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAa,EAAE,MAA0B;IAC3E,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,EAAE;SACxB,KAAK,CAAC,qBAAqB,CAAC;SAC5B,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;SAC7D,KAAK,CAAC,MAAM,CAAC;SACb,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO;QACL,GAAG,QAAQ,CAAC,MAAM,CAAC;QACnB,gBAAgB,EAAE,MAAM;aACrB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;aACZ,GAAG,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;YAC/C,eAAe;YACf,IAAI;YACJ,UAAU;SACX,CAAC,CAAC;QACL,yBAAyB,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;KAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export declare const start: import("convex/server").RegisteredMutation<"public", {
|
|
2
|
+
definitionVersion: 1;
|
|
3
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
4
|
+
provider: string;
|
|
5
|
+
scope: {
|
|
6
|
+
customerAccount: string;
|
|
7
|
+
livemode: boolean;
|
|
8
|
+
meterId: string;
|
|
9
|
+
stripeAccountId: string;
|
|
10
|
+
};
|
|
11
|
+
}, Promise<{
|
|
12
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
13
|
+
state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
|
|
14
|
+
attempts: number;
|
|
15
|
+
held: boolean;
|
|
16
|
+
reason: "administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
|
|
17
|
+
providerIdentifier: string;
|
|
18
|
+
receipt: {
|
|
19
|
+
created: number;
|
|
20
|
+
identifier: string;
|
|
21
|
+
} | undefined;
|
|
22
|
+
validationErrors: {
|
|
23
|
+
providerEventId: string;
|
|
24
|
+
code: "archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past";
|
|
25
|
+
observedAt: number;
|
|
26
|
+
}[];
|
|
27
|
+
validationHistoryComplete: boolean;
|
|
28
|
+
}>>;
|
|
29
|
+
export declare const hold: import("convex/server").RegisteredMutation<"public", {
|
|
30
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
31
|
+
scope: {
|
|
32
|
+
customerAccount: string;
|
|
33
|
+
livemode: boolean;
|
|
34
|
+
meterId: string;
|
|
35
|
+
stripeAccountId: string;
|
|
36
|
+
};
|
|
37
|
+
}, Promise<{
|
|
38
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
39
|
+
state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
|
|
40
|
+
attempts: number;
|
|
41
|
+
held: boolean;
|
|
42
|
+
reason: "administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
|
|
43
|
+
providerIdentifier: string;
|
|
44
|
+
receipt: {
|
|
45
|
+
created: number;
|
|
46
|
+
identifier: string;
|
|
47
|
+
} | undefined;
|
|
48
|
+
validationErrors: {
|
|
49
|
+
providerEventId: string;
|
|
50
|
+
code: "archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past";
|
|
51
|
+
observedAt: number;
|
|
52
|
+
}[];
|
|
53
|
+
validationHistoryComplete: boolean;
|
|
54
|
+
}>>;
|
|
55
|
+
export declare const resume: import("convex/server").RegisteredMutation<"public", {
|
|
56
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
57
|
+
scope: {
|
|
58
|
+
customerAccount: string;
|
|
59
|
+
livemode: boolean;
|
|
60
|
+
meterId: string;
|
|
61
|
+
stripeAccountId: string;
|
|
62
|
+
};
|
|
63
|
+
}, Promise<{
|
|
64
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
65
|
+
state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
|
|
66
|
+
attempts: number;
|
|
67
|
+
held: boolean;
|
|
68
|
+
reason: "administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
|
|
69
|
+
providerIdentifier: string;
|
|
70
|
+
receipt: {
|
|
71
|
+
created: number;
|
|
72
|
+
identifier: string;
|
|
73
|
+
} | undefined;
|
|
74
|
+
validationErrors: {
|
|
75
|
+
providerEventId: string;
|
|
76
|
+
code: "archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past";
|
|
77
|
+
observedAt: number;
|
|
78
|
+
}[];
|
|
79
|
+
validationHistoryComplete: boolean;
|
|
80
|
+
}>>;
|
|
81
|
+
/** Only a verified host webhook/provider action may submit native reports. */
|
|
82
|
+
export declare const recordErrorReport: import("convex/server").RegisteredMutation<"public", {
|
|
83
|
+
livemode: boolean;
|
|
84
|
+
meterId?: string | undefined;
|
|
85
|
+
providerEventId: string;
|
|
86
|
+
samples: {
|
|
87
|
+
code: "archived_meter" | "meter_event_customer_not_found" | "meter_event_dimension_count_too_high" | "meter_event_invalid_value" | "meter_event_no_customer_defined" | "meter_event_value_not_found" | "no_meter" | "timestamp_in_future" | "timestamp_too_far_in_past";
|
|
88
|
+
identifier: string;
|
|
89
|
+
}[];
|
|
90
|
+
stripeAccountId: string;
|
|
91
|
+
truncated: boolean;
|
|
92
|
+
}, Promise<{
|
|
93
|
+
matched: number;
|
|
94
|
+
unattributed: number;
|
|
95
|
+
truncated: boolean;
|
|
96
|
+
}>>;
|
|
97
|
+
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/component/usageDelivery/mutations.ts"],"names":[],"mappings":"AAiDA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsBhB,CAAC;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;GAaf,CAAC;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;GAwBjB,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;GAuE5B,CAAC"}
|