@fantastic.dev/better-stripe 0.41.0 → 0.42.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 +10 -0
- package/README.md +1 -1
- package/dist/client/balanceFundingWorkflow/client.d.ts +172 -0
- package/dist/client/balanceFundingWorkflow/client.d.ts.map +1 -0
- package/dist/client/balanceFundingWorkflow/client.js +289 -0
- package/dist/client/balanceFundingWorkflow/client.js.map +1 -0
- package/dist/client/billing/balanceFunding.d.ts +5 -0
- package/dist/client/billing/balanceFunding.d.ts.map +1 -1
- package/dist/client/billing/balanceFunding.js +30 -0
- package/dist/client/billing/balanceFunding.js.map +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +366 -2
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +199 -17
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +366 -2
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +199 -17
- 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/component/_generated/api.d.ts +18 -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 +473 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/balanceFunding/helpers.d.ts +42 -0
- package/dist/component/balanceFunding/helpers.d.ts.map +1 -1
- package/dist/component/balanceFunding/internal/actions.d.ts +39 -0
- package/dist/component/balanceFunding/internal/actions.d.ts.map +1 -0
- package/dist/component/balanceFunding/internal/actions.js +80 -0
- package/dist/component/balanceFunding/internal/actions.js.map +1 -0
- package/dist/component/balanceFunding/internal/mutations.d.ts +55 -0
- package/dist/component/balanceFunding/internal/mutations.d.ts.map +1 -0
- package/dist/component/balanceFunding/internal/mutations.js +54 -0
- package/dist/component/balanceFunding/internal/mutations.js.map +1 -0
- package/dist/component/balanceFunding/internal/queries.d.ts +116 -0
- package/dist/component/balanceFunding/internal/queries.d.ts.map +1 -0
- package/dist/component/balanceFunding/internal/queries.js +35 -0
- package/dist/component/balanceFunding/internal/queries.js.map +1 -0
- package/dist/component/balanceFunding/internal/workflow.d.ts +10 -0
- package/dist/component/balanceFunding/internal/workflow.d.ts.map +1 -0
- package/dist/component/balanceFunding/internal/workflow.js +31 -0
- package/dist/component/balanceFunding/internal/workflow.js.map +1 -0
- package/dist/component/balanceFunding/lifecycleHandlers.d.ts +126 -0
- package/dist/component/balanceFunding/lifecycleHandlers.d.ts.map +1 -1
- package/dist/component/balanceFunding/mutations.d.ts +403 -0
- package/dist/component/balanceFunding/mutations.d.ts.map +1 -1
- package/dist/component/balanceFunding/mutations.js +24 -0
- package/dist/component/balanceFunding/mutations.js.map +1 -1
- package/dist/component/balanceFunding/preparationHandlers.d.ts +42 -0
- package/dist/component/balanceFunding/preparationHandlers.d.ts.map +1 -1
- package/dist/component/balanceFunding/queries.d.ts +78 -0
- package/dist/component/balanceFunding/queries.d.ts.map +1 -1
- package/dist/component/balanceFunding/queries.js +35 -0
- package/dist/component/balanceFunding/queries.js.map +1 -1
- package/dist/component/balanceFunding/receipt.d.ts +5 -0
- package/dist/component/balanceFunding/receipt.d.ts.map +1 -0
- package/dist/component/balanceFunding/receipt.js +37 -0
- package/dist/component/balanceFunding/receipt.js.map +1 -0
- package/dist/component/balanceFunding/schema.d.ts +506 -2
- package/dist/component/balanceFunding/schema.d.ts.map +1 -1
- package/dist/component/balanceFunding/schema.js +2 -0
- package/dist/component/balanceFunding/schema.js.map +1 -1
- package/dist/component/balanceFunding/stateHandlers.d.ts +50 -8
- package/dist/component/balanceFunding/stateHandlers.d.ts.map +1 -1
- package/dist/component/balanceFunding/workflowControl.d.ts +19 -0
- package/dist/component/balanceFunding/workflowControl.d.ts.map +1 -0
- package/dist/component/balanceFunding/workflowControl.js +149 -0
- package/dist/component/balanceFunding/workflowControl.js.map +1 -0
- package/dist/component/balanceFunding/workflowSchema.d.ts +356 -0
- package/dist/component/balanceFunding/workflowSchema.d.ts.map +1 -0
- package/dist/component/balanceFunding/workflowSchema.js +48 -0
- package/dist/component/balanceFunding/workflowSchema.js.map +1 -0
- package/dist/component/balanceFunding/workflowState.d.ts +157 -0
- package/dist/component/balanceFunding/workflowState.d.ts.map +1 -0
- package/dist/component/balanceFunding/workflowState.js +194 -0
- package/dist/component/balanceFunding/workflowState.js.map +1 -0
- package/dist/component/balanceFunding/workflowValidators.d.ts +306 -0
- package/dist/component/balanceFunding/workflowValidators.d.ts.map +1 -0
- package/dist/component/balanceFunding/workflowValidators.js +27 -0
- package/dist/component/balanceFunding/workflowValidators.js.map +1 -0
- package/dist/component/earnings/triggers.d.ts +102 -18
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/schema.d.ts +183 -1
- package/package.json +1 -1
- package/src/client/balanceFundingWorkflow/capture.test.ts +144 -0
- package/src/client/balanceFundingWorkflow/client.ts +419 -0
- package/src/client/billing/balanceFunding.ts +50 -0
- package/src/client/index.ts +15 -0
- package/src/component/_generated/api.ts +18 -0
- package/src/component/_generated/component.ts +524 -0
- package/src/component/balanceFunding/internal/actions.ts +107 -0
- package/src/component/balanceFunding/internal/mutations.ts +66 -0
- package/src/component/balanceFunding/internal/queries.ts +34 -0
- package/src/component/balanceFunding/internal/workflow.ts +49 -0
- package/src/component/balanceFunding/mutations.ts +34 -0
- package/src/component/balanceFunding/queries.ts +38 -0
- package/src/component/balanceFunding/receipt.ts +48 -0
- package/src/component/balanceFunding/schema.ts +2 -0
- package/src/component/balanceFunding/scopeLookup.test.ts +94 -0
- package/src/component/balanceFunding/workflow.fixtures.ts +366 -0
- package/src/component/balanceFunding/workflow.test.ts +552 -0
- package/src/component/balanceFunding/workflowControl.ts +198 -0
- package/src/component/balanceFunding/workflowSchema.ts +78 -0
- package/src/component/balanceFunding/workflowState.ts +285 -0
- package/src/component/balanceFunding/workflowValidators.ts +40 -0
|
@@ -48,6 +48,48 @@ export declare function readOperation(ctx: QueryCtx | MutationCtx, args: Ref): P
|
|
|
48
48
|
accountId: string;
|
|
49
49
|
cancelRequested: boolean;
|
|
50
50
|
enabled: boolean;
|
|
51
|
+
execution?: {
|
|
52
|
+
apply?: {
|
|
53
|
+
receipt?: {
|
|
54
|
+
customerAccount: string;
|
|
55
|
+
enabled?: boolean | undefined;
|
|
56
|
+
paymentMethodId: string | null;
|
|
57
|
+
paymentMethodTypes?: string[] | null | undefined;
|
|
58
|
+
phase: "apply" | "attach" | "create";
|
|
59
|
+
providerApiVersion: string;
|
|
60
|
+
stripeSubscriptionId: string;
|
|
61
|
+
} | undefined;
|
|
62
|
+
state: "running" | "succeeded" | "unknown";
|
|
63
|
+
} | undefined;
|
|
64
|
+
attach?: {
|
|
65
|
+
receipt?: {
|
|
66
|
+
customerAccount: string;
|
|
67
|
+
enabled?: boolean | undefined;
|
|
68
|
+
paymentMethodId: string | null;
|
|
69
|
+
paymentMethodTypes?: string[] | null | undefined;
|
|
70
|
+
phase: "apply" | "attach" | "create";
|
|
71
|
+
providerApiVersion: string;
|
|
72
|
+
stripeSubscriptionId: string;
|
|
73
|
+
} | undefined;
|
|
74
|
+
state: "running" | "succeeded" | "unknown";
|
|
75
|
+
} | undefined;
|
|
76
|
+
create?: {
|
|
77
|
+
receipt?: {
|
|
78
|
+
customerAccount: string;
|
|
79
|
+
enabled?: boolean | undefined;
|
|
80
|
+
paymentMethodId: string | null;
|
|
81
|
+
paymentMethodTypes?: string[] | null | undefined;
|
|
82
|
+
phase: "apply" | "attach" | "create";
|
|
83
|
+
providerApiVersion: string;
|
|
84
|
+
stripeSubscriptionId: string;
|
|
85
|
+
} | undefined;
|
|
86
|
+
state: "running" | "succeeded" | "unknown";
|
|
87
|
+
} | undefined;
|
|
88
|
+
definitionVersion: string;
|
|
89
|
+
providerAction: string;
|
|
90
|
+
providerApiVersion: string;
|
|
91
|
+
workflowId?: string | undefined;
|
|
92
|
+
} | undefined;
|
|
51
93
|
failureCode?: "invalid_scope" | "policy_invalid" | "unsupported_source" | undefined;
|
|
52
94
|
kind: "apply" | "prepare";
|
|
53
95
|
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/component/balanceFunding/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,kBAAkB,EACnB,MAAM,aAAa,CAAC;AACrB,KAAK,KAAK,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AACrD,KAAK,GAAG,GAAG;KACR,CAAC,IAAI,MAAM,OAAO,kBAAkB,GAAG,KAAK,CAAC,CAAC,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9E,CAAC;AAWF,eAAO,MAAM,WAAW,UAAW,OAAO,WAAqC,CAAC;AAChF,eAAO,MAAM,IAAI,MAAO,OAAO,KAAK,OAAO,YACR,CAAC;AACpC,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,QAGjC;AACD,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,QAGzC;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,SAAI,QAGjD;AACD,eAAO,MAAM,WAAW,WACd,kBAAkB,GAAG,kBAAkB,GAAG,YAAY;YAChD,UAAU;;;CAA+C,CAAC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AAG,WAAW,EAC3B,IAAI,EAAE,KAAK,GAAG;IAAE,aAAa,EAAE,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC,KAAK,CAAC,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;UAarE;AACD,wBAAsB,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,WAAW,EAAE,IAAI,EAAE,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAYzE;AACD,wBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,YAAY,CAAC;IAEjD,SAAS;IACT,QAAQ;IACR,WAAW;IACX,OAAO;EAEV;AACD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,0BAA0B,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,QAmBA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const bridge: import("convex/server").RegisteredAction<"internal", {
|
|
2
|
+
accountId: string;
|
|
3
|
+
definitionVersion: string;
|
|
4
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
5
|
+
phase: "apply" | "attach" | "create";
|
|
6
|
+
providerApiVersion: string;
|
|
7
|
+
providerKey: string;
|
|
8
|
+
scopeKey: string;
|
|
9
|
+
stripeSubscriptionId: string;
|
|
10
|
+
version: number;
|
|
11
|
+
}, Promise<{
|
|
12
|
+
reason: "history_incomplete" | "provider_outcome_unknown";
|
|
13
|
+
retryable: false;
|
|
14
|
+
status: "unknown";
|
|
15
|
+
} | {
|
|
16
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
17
|
+
retryable: false;
|
|
18
|
+
status: "conflict";
|
|
19
|
+
} | {
|
|
20
|
+
reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
|
|
21
|
+
retryable: false;
|
|
22
|
+
status: "rejected";
|
|
23
|
+
} | {
|
|
24
|
+
reason: "provider_pending";
|
|
25
|
+
retryable: true;
|
|
26
|
+
status: "not_ready";
|
|
27
|
+
} | {
|
|
28
|
+
status: "ready";
|
|
29
|
+
value: {
|
|
30
|
+
customerAccount: string;
|
|
31
|
+
enabled?: boolean | undefined;
|
|
32
|
+
paymentMethodId: string | null;
|
|
33
|
+
paymentMethodTypes?: string[] | null | undefined;
|
|
34
|
+
phase: "apply" | "attach" | "create";
|
|
35
|
+
providerApiVersion: string;
|
|
36
|
+
stripeSubscriptionId: string;
|
|
37
|
+
};
|
|
38
|
+
}>>;
|
|
39
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/component/balanceFunding/internal/actions.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmGjB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { internalAction } from "../../_generated/server.js";
|
|
2
|
+
import { internal } from "../../_generated/api.js";
|
|
3
|
+
import { phaseRefFields } from "../workflowValidators.js";
|
|
4
|
+
import { providerResult } from "../workflowSchema.js";
|
|
5
|
+
import { normalizeReceipt } from "../receipt.js";
|
|
6
|
+
import { phaseKey, unknown } from "../workflowState.js";
|
|
7
|
+
export const bridge = internalAction({
|
|
8
|
+
args: phaseRefFields,
|
|
9
|
+
returns: providerResult,
|
|
10
|
+
handler: async (ctx, args) => {
|
|
11
|
+
const { phase: _phase, providerKey: _key, ...base } = args;
|
|
12
|
+
const context = await ctx.runQuery(internal.balanceFunding.internal.queries.readContext, base);
|
|
13
|
+
if (phaseKey(context.operation, args.phase) !== args.providerKey)
|
|
14
|
+
return {
|
|
15
|
+
status: "conflict",
|
|
16
|
+
reason: "identity_changed",
|
|
17
|
+
retryable: false,
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
const result = await ctx.runAction(context.operation.execution.providerAction, args);
|
|
21
|
+
if (result &&
|
|
22
|
+
typeof result === "object" &&
|
|
23
|
+
"status" in result &&
|
|
24
|
+
result.status === "ready" &&
|
|
25
|
+
"value" in result) {
|
|
26
|
+
const receipt = normalizeReceipt(result.value, args);
|
|
27
|
+
if (receipt) {
|
|
28
|
+
// Preserve positive evidence even if cancellation races this action.
|
|
29
|
+
// A failed receipt write is retried as its own workflow step.
|
|
30
|
+
try {
|
|
31
|
+
await ctx.runMutation(internal.balanceFunding.internal.mutations.recordProviderReceipt, { ...args, receipt });
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
/* journal the validated receipt below */
|
|
35
|
+
}
|
|
36
|
+
return { status: "ready", value: receipt };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (result &&
|
|
40
|
+
typeof result === "object" &&
|
|
41
|
+
"status" in result &&
|
|
42
|
+
"reason" in result) {
|
|
43
|
+
const current = await ctx.runQuery(internal.balanceFunding.internal.queries.readContext, base);
|
|
44
|
+
if (!current.operation.execution?.[args.phase]) {
|
|
45
|
+
if (result.status === "conflict" &&
|
|
46
|
+
(result.reason === "scope_busy" ||
|
|
47
|
+
result.reason === "revision_changed" ||
|
|
48
|
+
result.reason === "identity_changed"))
|
|
49
|
+
return {
|
|
50
|
+
status: "conflict",
|
|
51
|
+
reason: result.reason,
|
|
52
|
+
retryable: false,
|
|
53
|
+
};
|
|
54
|
+
if (result.status === "rejected" &&
|
|
55
|
+
(result.reason === "policy_invalid" ||
|
|
56
|
+
result.reason === "unsupported_source" ||
|
|
57
|
+
result.reason === "invalid_scope"))
|
|
58
|
+
return {
|
|
59
|
+
status: "rejected",
|
|
60
|
+
reason: result.reason,
|
|
61
|
+
retryable: false,
|
|
62
|
+
};
|
|
63
|
+
if (result.status === "not_ready" &&
|
|
64
|
+
result.reason === "provider_pending")
|
|
65
|
+
return {
|
|
66
|
+
status: "not_ready",
|
|
67
|
+
reason: "provider_pending",
|
|
68
|
+
retryable: true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
/* Raw host/provider errors must never enter durable history. */
|
|
75
|
+
}
|
|
76
|
+
await ctx.runMutation(internal.balanceFunding.internal.mutations.markProviderUnknown, args);
|
|
77
|
+
return unknown();
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/component/balanceFunding/internal/actions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAwB,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACxD,MAAM,CAAC,MAAM,MAAM,GAAG,cAAc,CAAC;IACnC,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAA2B,EAAE;QACpD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC3D,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,QAAQ,CAChC,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EACpD,IAAI,CACL,CAAC;QACF,IAAI,QAAQ,CAA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AAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC/C,IACE,MAAM,CAAC,MAAM,KAAK,UAAU;wBAC5B,CAAC,MAAM,CAAC,MAAM,KAAK,YAAY;4BAC7B,MAAM,CAAC,MAAM,KAAK,kBAAkB;4BACpC,MAAM,CAAC,MAAM,KAAK,kBAAkB,CAAC;wBAEvC,OAAO;4BACL,MAAM,EAAE,UAAU;4BAClB,MAAM,EAAE,MAAM,CAAC,MAAM;4BACrB,SAAS,EAAE,KAAK;yBACjB,CAAC;oBACJ,IACE,MAAM,CAAC,MAAM,KAAK,UAAU;wBAC5B,CAAC,MAAM,CAAC,MAAM,KAAK,gBAAgB;4BACjC,MAAM,CAAC,MAAM,KAAK,oBAAoB;4BACtC,MAAM,CAAC,MAAM,KAAK,eAAe,CAAC;wBAEpC,OAAO;4BACL,MAAM,EAAE,UAAU;4BAClB,MAAM,EAAE,MAAM,CAAC,MAAM;4BACrB,SAAS,EAAE,KAAK;yBACjB,CAAC;oBACJ,IACE,MAAM,CAAC,MAAM,KAAK,WAAW;wBAC7B,MAAM,CAAC,MAAM,KAAK,kBAAkB;wBAEpC,OAAO;4BACL,MAAM,EAAE,WAAW;4BACnB,MAAM,EAAE,kBAAkB;4BAC1B,SAAS,EAAE,IAAI;yBAChB,CAAC;gBACN,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,gEAAgE;QAClE,CAAC;QACD,MAAM,GAAG,CAAC,WAAW,CACnB,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,mBAAmB,EAC9D,IAAI,CACL,CAAC;QACF,OAAO,OAAO,EAAE,CAAC;IACnB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const recordProviderReceipt: import("convex/server").RegisteredMutation<"internal", {
|
|
2
|
+
accountId: string;
|
|
3
|
+
definitionVersion: string;
|
|
4
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
5
|
+
phase: "apply" | "attach" | "create";
|
|
6
|
+
providerApiVersion: string;
|
|
7
|
+
providerKey: string;
|
|
8
|
+
scopeKey: string;
|
|
9
|
+
stripeSubscriptionId: string;
|
|
10
|
+
version: number;
|
|
11
|
+
} & {
|
|
12
|
+
receipt: import("../workflowSchema.js").ProvisioningReceipt;
|
|
13
|
+
}, Promise<null>>;
|
|
14
|
+
export declare const markProviderUnknown: import("convex/server").RegisteredMutation<"internal", {
|
|
15
|
+
accountId: string;
|
|
16
|
+
definitionVersion: string;
|
|
17
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
18
|
+
phase: "apply" | "attach" | "create";
|
|
19
|
+
providerApiVersion: string;
|
|
20
|
+
providerKey: string;
|
|
21
|
+
scopeKey: string;
|
|
22
|
+
stripeSubscriptionId: string;
|
|
23
|
+
version: number;
|
|
24
|
+
}, Promise<null>>;
|
|
25
|
+
export declare const finishFromReceipts: import("convex/server").RegisteredMutation<"internal", {
|
|
26
|
+
accountId: string;
|
|
27
|
+
definitionVersion: string;
|
|
28
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
29
|
+
providerApiVersion: string;
|
|
30
|
+
scopeKey: string;
|
|
31
|
+
stripeSubscriptionId: string;
|
|
32
|
+
version: number;
|
|
33
|
+
}, Promise<null>>;
|
|
34
|
+
export declare const onComplete: import("convex/server").RegisteredMutation<"internal", {
|
|
35
|
+
context: {
|
|
36
|
+
accountId: string;
|
|
37
|
+
definitionVersion: string;
|
|
38
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
39
|
+
providerApiVersion: string;
|
|
40
|
+
scopeKey: string;
|
|
41
|
+
stripeSubscriptionId: string;
|
|
42
|
+
version: number;
|
|
43
|
+
};
|
|
44
|
+
result: {
|
|
45
|
+
kind: "success";
|
|
46
|
+
returnValue: any;
|
|
47
|
+
} | {
|
|
48
|
+
kind: "failed";
|
|
49
|
+
error: string;
|
|
50
|
+
} | {
|
|
51
|
+
kind: "canceled";
|
|
52
|
+
};
|
|
53
|
+
workflowId: import("@convex-dev/workflow").WorkflowId;
|
|
54
|
+
}, Promise<null>>;
|
|
55
|
+
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../../src/component/balanceFunding/internal/mutations.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;iBAIhC,CAAC;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;iBAI9B,CAAC;AACH,eAAO,MAAM,kBAAkB;;;;;;;;iBAI7B,CAAC;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;iBAkCrB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { internalMutation } from "../../_generated/server.js";
|
|
3
|
+
import { vWorkflowId } from "@convex-dev/workflow";
|
|
4
|
+
import { vResultValidator } from "@convex-dev/workpool";
|
|
5
|
+
import { workflowRef, workflowRefFields, phaseRefFields, } from "../workflowValidators.js";
|
|
6
|
+
import { provisioningReceipt } from "../workflowSchema.js";
|
|
7
|
+
import { finishFromReceiptsHandler, recordProviderReceiptHandler, markProviderUnknownHandler, readWorkflowContext, } from "../workflowState.js";
|
|
8
|
+
export const recordProviderReceipt = internalMutation({
|
|
9
|
+
args: { ...phaseRefFields, receipt: provisioningReceipt },
|
|
10
|
+
returns: v.null(),
|
|
11
|
+
handler: recordProviderReceiptHandler,
|
|
12
|
+
});
|
|
13
|
+
export const markProviderUnknown = internalMutation({
|
|
14
|
+
args: phaseRefFields,
|
|
15
|
+
returns: v.null(),
|
|
16
|
+
handler: markProviderUnknownHandler,
|
|
17
|
+
});
|
|
18
|
+
export const finishFromReceipts = internalMutation({
|
|
19
|
+
args: workflowRefFields,
|
|
20
|
+
returns: v.null(),
|
|
21
|
+
handler: finishFromReceiptsHandler,
|
|
22
|
+
});
|
|
23
|
+
export const onComplete = internalMutation({
|
|
24
|
+
args: {
|
|
25
|
+
workflowId: vWorkflowId,
|
|
26
|
+
result: vResultValidator,
|
|
27
|
+
context: workflowRef,
|
|
28
|
+
},
|
|
29
|
+
returns: v.null(),
|
|
30
|
+
handler: async (ctx, args) => {
|
|
31
|
+
const { operation } = await readWorkflowContext(ctx, args.context);
|
|
32
|
+
if (operation.execution?.workflowId !== args.workflowId ||
|
|
33
|
+
["succeeded", "failed", "canceled"].includes(operation.state))
|
|
34
|
+
return null;
|
|
35
|
+
const unsettled = [
|
|
36
|
+
operation.execution?.create,
|
|
37
|
+
operation.execution?.attach,
|
|
38
|
+
operation.execution?.apply,
|
|
39
|
+
].some((phase) => phase?.state === "running" || phase?.state === "unknown");
|
|
40
|
+
if (args.result.kind !== "success" &&
|
|
41
|
+
(unsettled ||
|
|
42
|
+
(args.result.kind === "canceled" &&
|
|
43
|
+
[
|
|
44
|
+
operation.execution?.create,
|
|
45
|
+
operation.execution?.attach,
|
|
46
|
+
operation.execution?.apply,
|
|
47
|
+
].some(Boolean))))
|
|
48
|
+
await ctx.db.patch("balanceFundingOperations", operation._id, {
|
|
49
|
+
state: "unknown",
|
|
50
|
+
});
|
|
51
|
+
return null;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../../src/component/balanceFunding/internal/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,cAAc,GACf,MAAM,0BAA0B,CAAC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SAAS,GAAG;YAChB,SAAS,CAAC,SAAS,EAAE,MAAM;YAC3B,SAAS,CAAC,SAAS,EAAE,MAAM;YAC3B,SAAS,CAAC,SAAS,EAAE,KAAK;SAC3B,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,IAAI,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC;QAC5E,IACE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;YAC9B,CAAC,SAAS;gBACR,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU;oBAC9B;wBACE,SAAS,CAAC,SAAS,EAAE,MAAM;wBAC3B,SAAS,CAAC,SAAS,EAAE,MAAM;wBAC3B,SAAS,CAAC,SAAS,EAAE,KAAK;qBAC3B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAErB,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,0BAA0B,EAAE,SAAS,CAAC,GAAG,EAAE;gBAC5D,KAAK,EAAE,SAAS;aACjB,CAAC,CAAC;QACL,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export declare const readContext: import("convex/server").RegisteredQuery<"internal", {
|
|
2
|
+
accountId: string;
|
|
3
|
+
definitionVersion: string;
|
|
4
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
5
|
+
providerApiVersion: string;
|
|
6
|
+
scopeKey: string;
|
|
7
|
+
stripeSubscriptionId: string;
|
|
8
|
+
version: number;
|
|
9
|
+
}, Promise<{
|
|
10
|
+
operation: {
|
|
11
|
+
_creationTime: number;
|
|
12
|
+
_id: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
13
|
+
accountId: string;
|
|
14
|
+
cancelRequested: boolean;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
execution?: {
|
|
17
|
+
apply?: {
|
|
18
|
+
receipt?: {
|
|
19
|
+
customerAccount: string;
|
|
20
|
+
enabled?: boolean | undefined;
|
|
21
|
+
paymentMethodId: string | null;
|
|
22
|
+
paymentMethodTypes?: string[] | null | undefined;
|
|
23
|
+
phase: "apply" | "attach" | "create";
|
|
24
|
+
providerApiVersion: string;
|
|
25
|
+
stripeSubscriptionId: string;
|
|
26
|
+
} | undefined;
|
|
27
|
+
state: "running" | "succeeded" | "unknown";
|
|
28
|
+
} | undefined;
|
|
29
|
+
attach?: {
|
|
30
|
+
receipt?: {
|
|
31
|
+
customerAccount: string;
|
|
32
|
+
enabled?: boolean | undefined;
|
|
33
|
+
paymentMethodId: string | null;
|
|
34
|
+
paymentMethodTypes?: string[] | null | undefined;
|
|
35
|
+
phase: "apply" | "attach" | "create";
|
|
36
|
+
providerApiVersion: string;
|
|
37
|
+
stripeSubscriptionId: string;
|
|
38
|
+
} | undefined;
|
|
39
|
+
state: "running" | "succeeded" | "unknown";
|
|
40
|
+
} | undefined;
|
|
41
|
+
create?: {
|
|
42
|
+
receipt?: {
|
|
43
|
+
customerAccount: string;
|
|
44
|
+
enabled?: boolean | undefined;
|
|
45
|
+
paymentMethodId: string | null;
|
|
46
|
+
paymentMethodTypes?: string[] | null | undefined;
|
|
47
|
+
phase: "apply" | "attach" | "create";
|
|
48
|
+
providerApiVersion: string;
|
|
49
|
+
stripeSubscriptionId: string;
|
|
50
|
+
} | undefined;
|
|
51
|
+
state: "running" | "succeeded" | "unknown";
|
|
52
|
+
} | undefined;
|
|
53
|
+
definitionVersion: string;
|
|
54
|
+
providerAction: string;
|
|
55
|
+
providerApiVersion: string;
|
|
56
|
+
workflowId?: string | undefined;
|
|
57
|
+
} | undefined;
|
|
58
|
+
failureCode?: "invalid_scope" | "policy_invalid" | "unsupported_source" | undefined;
|
|
59
|
+
kind: "apply" | "prepare";
|
|
60
|
+
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
61
|
+
providerKey: string;
|
|
62
|
+
providerKeys: {
|
|
63
|
+
attach?: string | undefined;
|
|
64
|
+
create?: string | undefined;
|
|
65
|
+
disable: string;
|
|
66
|
+
enable: string;
|
|
67
|
+
};
|
|
68
|
+
receipt?: {
|
|
69
|
+
customerAccount: string;
|
|
70
|
+
paymentMethodId: string | null;
|
|
71
|
+
paymentMethodTypes: string[] | null;
|
|
72
|
+
providerApiVersion: string;
|
|
73
|
+
stripeSubscriptionId: string;
|
|
74
|
+
} | undefined;
|
|
75
|
+
scopeKey: string;
|
|
76
|
+
state: "canceled" | "failed" | "pending" | "running" | "succeeded" | "unknown";
|
|
77
|
+
version: number;
|
|
78
|
+
};
|
|
79
|
+
preparation: {
|
|
80
|
+
_creationTime: number;
|
|
81
|
+
_id: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
82
|
+
accountId: string;
|
|
83
|
+
activeOperationId?: import("convex/values").GenericId<"balanceFundingOperations"> | undefined;
|
|
84
|
+
consentAt: number;
|
|
85
|
+
consentReference: string;
|
|
86
|
+
enabled: boolean;
|
|
87
|
+
operationVersion: number;
|
|
88
|
+
preparation: {
|
|
89
|
+
customerAccount: string;
|
|
90
|
+
paymentMethodId?: string | undefined;
|
|
91
|
+
previousPaymentMethodId: string | null;
|
|
92
|
+
previousPaymentMethodTypes: string[] | null;
|
|
93
|
+
stripeSubscriptionId: string;
|
|
94
|
+
};
|
|
95
|
+
preparationOperationId?: import("convex/values").GenericId<"balanceFundingOperations"> | undefined;
|
|
96
|
+
providerApiVersion: string;
|
|
97
|
+
scopeKey: string;
|
|
98
|
+
startsPaused: boolean;
|
|
99
|
+
verified: boolean;
|
|
100
|
+
};
|
|
101
|
+
}>>;
|
|
102
|
+
export declare const plan: import("convex/server").RegisteredQuery<"internal", {
|
|
103
|
+
accountId: string;
|
|
104
|
+
definitionVersion: string;
|
|
105
|
+
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
106
|
+
providerApiVersion: string;
|
|
107
|
+
scopeKey: string;
|
|
108
|
+
stripeSubscriptionId: string;
|
|
109
|
+
version: number;
|
|
110
|
+
}, Promise<{
|
|
111
|
+
kind: "apply" | "prepare";
|
|
112
|
+
applyKey: string;
|
|
113
|
+
createKey?: string | undefined;
|
|
114
|
+
attachKey?: string | undefined;
|
|
115
|
+
}>>;
|
|
116
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../../src/component/balanceFunding/internal/queries.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAItB,CAAC;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;GAuBf,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { internalQuery } from "../../_generated/server.js";
|
|
3
|
+
import { operationDoc, preparationDoc } from "../schema.js";
|
|
4
|
+
import { workflowRefFields } from "../workflowValidators.js";
|
|
5
|
+
import { readWorkflowContext } from "../workflowState.js";
|
|
6
|
+
export const readContext = internalQuery({
|
|
7
|
+
args: workflowRefFields,
|
|
8
|
+
returns: v.object({ operation: operationDoc, preparation: preparationDoc }),
|
|
9
|
+
handler: (ctx, args) => readWorkflowContext(ctx, args),
|
|
10
|
+
});
|
|
11
|
+
export const plan = internalQuery({
|
|
12
|
+
args: workflowRefFields,
|
|
13
|
+
returns: v.object({
|
|
14
|
+
createKey: v.optional(v.string()),
|
|
15
|
+
attachKey: v.optional(v.string()),
|
|
16
|
+
applyKey: v.string(),
|
|
17
|
+
kind: v.union(v.literal("prepare"), v.literal("apply")),
|
|
18
|
+
}),
|
|
19
|
+
handler: async (ctx, args) => {
|
|
20
|
+
const { operation } = await readWorkflowContext(ctx, args);
|
|
21
|
+
return {
|
|
22
|
+
kind: operation.kind,
|
|
23
|
+
applyKey: operation.enabled
|
|
24
|
+
? operation.providerKeys.enable
|
|
25
|
+
: operation.providerKeys.disable,
|
|
26
|
+
...(operation.providerKeys.create
|
|
27
|
+
? { createKey: operation.providerKeys.create }
|
|
28
|
+
: {}),
|
|
29
|
+
...(operation.providerKeys.attach
|
|
30
|
+
? { attachKey: operation.providerKeys.attach }
|
|
31
|
+
: {}),
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../../src/component/balanceFunding/internal/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;IACvC,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;IAC3E,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC;CACvD,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC;IAChC,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACjC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KACxD,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,mBAAmB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC3D,OAAO;YACL,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,QAAQ,EAAE,SAAS,CAAC,OAAO;gBACzB,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM;gBAC/B,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO;YAClC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM;gBAC/B,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE;gBAC9C,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM;gBAC/B,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE;gBAC9C,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const run: import("convex/server").RegisteredMutation<"internal", import("@convex-dev/workflow").WorkflowArgs<{
|
|
2
|
+
accountId: import("convex/values").VString<string, "required">;
|
|
3
|
+
scopeKey: import("convex/values").VString<string, "required">;
|
|
4
|
+
operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
|
|
5
|
+
version: import("convex/values").VFloat64<number, "required">;
|
|
6
|
+
stripeSubscriptionId: import("convex/values").VString<string, "required">;
|
|
7
|
+
providerApiVersion: import("convex/values").VString<string, "required">;
|
|
8
|
+
definitionVersion: import("convex/values").VString<string, "required">;
|
|
9
|
+
}>, import("@convex-dev/workflow").WorkflowMutationResult<null>>;
|
|
10
|
+
//# sourceMappingURL=workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../../src/component/balanceFunding/internal/workflow.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,GAAG;;;;;;;;gEA4Cd,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { internal } from "../../_generated/api.js";
|
|
3
|
+
import { executionWorkflow } from "../../durableExecution/runtime.js";
|
|
4
|
+
import { workflowRefFields } from "../workflowValidators.js";
|
|
5
|
+
export const run = executionWorkflow.define({
|
|
6
|
+
args: workflowRefFields,
|
|
7
|
+
returns: v.null(),
|
|
8
|
+
handler: async (step, args) => {
|
|
9
|
+
const plan = await step.runQuery(internal.balanceFunding.internal.queries.plan, args, { name: "plan-v1" });
|
|
10
|
+
for (const phase of plan.kind === "prepare"
|
|
11
|
+
? ["create", "attach"]
|
|
12
|
+
: ["apply"]) {
|
|
13
|
+
const phaseArgs = {
|
|
14
|
+
...args,
|
|
15
|
+
phase,
|
|
16
|
+
providerKey: phase === "apply"
|
|
17
|
+
? plan.applyKey
|
|
18
|
+
: phase === "create"
|
|
19
|
+
? plan.createKey
|
|
20
|
+
: plan.attachKey,
|
|
21
|
+
};
|
|
22
|
+
const result = await step.runAction(internal.balanceFunding.internal.actions.bridge, phaseArgs, { name: `${phase}-provider-v1`, retry: false });
|
|
23
|
+
if (result.status !== "ready")
|
|
24
|
+
throw new Error("Balance funding provider outcome requires reconciliation.");
|
|
25
|
+
await step.runMutation(internal.balanceFunding.internal.mutations.recordProviderReceipt, { ...phaseArgs, receipt: result.value }, { name: `${phase}-record-v1` });
|
|
26
|
+
}
|
|
27
|
+
await step.runMutation(internal.balanceFunding.internal.mutations.finishFromReceipts, args, { name: "finish-v1" });
|
|
28
|
+
return null;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../../../src/component/balanceFunding/internal/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,MAAM,CAAC,MAAM,GAAG,GAAG,iBAAiB,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE;IACjB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAiB,EAAE;QAC3C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAC9B,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAC7C,IAAI,EACJ,EAAE,IAAI,EAAE,SAAS,EAAE,CACpB,CAAC;QACF,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;YACzC,CAAC,CAAE,CAAC,QAAQ,EAAE,QAAQ,CAAW;YACjC,CAAC,CAAE,CAAC,OAAO,CAAW,EAAE,CAAC;YACzB,MAAM,SAAS,GAAG;gBAChB,GAAG,IAAI;gBACP,KAAK;gBACL,WAAW,EACT,KAAK,KAAK,OAAO;oBACf,CAAC,CAAC,IAAI,CAAC,QAAQ;oBACf,CAAC,CAAC,KAAK,KAAK,QAAQ;wBAClB,CAAC,CAAC,IAAI,CAAC,SAAU;wBACjB,CAAC,CAAC,IAAI,CAAC,SAAU;aACxB,CAAC;YACF,MAAM,MAAM,GAAG,M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