@fantastic.dev/better-stripe 0.41.0 → 0.43.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.
Files changed (209) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +1 -1
  3. package/dist/client/balanceFundingWorkflow/client.d.ts +172 -0
  4. package/dist/client/balanceFundingWorkflow/client.d.ts.map +1 -0
  5. package/dist/client/balanceFundingWorkflow/client.js +289 -0
  6. package/dist/client/balanceFundingWorkflow/client.js.map +1 -0
  7. package/dist/client/billing/balanceFunding.d.ts +5 -0
  8. package/dist/client/billing/balanceFunding.d.ts.map +1 -1
  9. package/dist/client/billing/balanceFunding.js +30 -0
  10. package/dist/client/billing/balanceFunding.js.map +1 -1
  11. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +1388 -2
  12. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  13. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +710 -17
  14. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  15. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +1420 -34
  16. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  17. package/dist/client/connect/payoutSyncTestHelpers.d.ts +694 -1
  18. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  19. package/dist/client/costRecovery-invoices.d.ts +3 -2
  20. package/dist/client/costRecovery-invoices.d.ts.map +1 -1
  21. package/dist/client/costRecovery-invoices.js +10 -5
  22. package/dist/client/costRecovery-invoices.js.map +1 -1
  23. package/dist/client/costRecovery.d.ts +4 -2
  24. package/dist/client/costRecovery.d.ts.map +1 -1
  25. package/dist/client/costRecovery.js +2 -2
  26. package/dist/client/costRecovery.js.map +1 -1
  27. package/dist/client/index.d.ts +3 -0
  28. package/dist/client/index.d.ts.map +1 -1
  29. package/dist/client/index.js +4 -0
  30. package/dist/client/index.js.map +1 -1
  31. package/dist/client/processingCostReconciliation/client.d.ts +14 -0
  32. package/dist/client/processingCostReconciliation/client.d.ts.map +1 -0
  33. package/dist/client/processingCostReconciliation/client.js +35 -0
  34. package/dist/client/processingCostReconciliation/client.js.map +1 -0
  35. package/dist/client/processingCostReconciliation/contracts.d.ts +172 -0
  36. package/dist/client/processingCostReconciliation/contracts.d.ts.map +1 -0
  37. package/dist/client/processingCostReconciliation/contracts.js +55 -0
  38. package/dist/client/processingCostReconciliation/contracts.js.map +1 -0
  39. package/dist/client/processingCostReconciliation/invoiceFunding.d.ts +15 -0
  40. package/dist/client/processingCostReconciliation/invoiceFunding.d.ts.map +1 -0
  41. package/dist/client/processingCostReconciliation/invoiceFunding.js +195 -0
  42. package/dist/client/processingCostReconciliation/invoiceFunding.js.map +1 -0
  43. package/dist/client/processingCostReconciliation/provider.d.ts +9 -0
  44. package/dist/client/processingCostReconciliation/provider.d.ts.map +1 -0
  45. package/dist/client/processingCostReconciliation/provider.js +148 -0
  46. package/dist/client/processingCostReconciliation/provider.js.map +1 -0
  47. package/dist/client/settlement/processingCostHistory.d.ts +12 -0
  48. package/dist/client/settlement/processingCostHistory.d.ts.map +1 -0
  49. package/dist/client/settlement/processingCostHistory.js +20 -0
  50. package/dist/client/settlement/processingCostHistory.js.map +1 -0
  51. package/dist/client/settlement/processingCosts.d.ts +3 -0
  52. package/dist/client/settlement/processingCosts.d.ts.map +1 -1
  53. package/dist/client/settlement/processingCosts.js +27 -7
  54. package/dist/client/settlement/processingCosts.js.map +1 -1
  55. package/dist/component/_generated/api.d.ts +36 -0
  56. package/dist/component/_generated/api.d.ts.map +1 -1
  57. package/dist/component/_generated/api.js.map +1 -1
  58. package/dist/component/_generated/component.d.ts +988 -0
  59. package/dist/component/_generated/component.d.ts.map +1 -1
  60. package/dist/component/balanceFunding/helpers.d.ts +42 -0
  61. package/dist/component/balanceFunding/helpers.d.ts.map +1 -1
  62. package/dist/component/balanceFunding/internal/actions.d.ts +39 -0
  63. package/dist/component/balanceFunding/internal/actions.d.ts.map +1 -0
  64. package/dist/component/balanceFunding/internal/actions.js +80 -0
  65. package/dist/component/balanceFunding/internal/actions.js.map +1 -0
  66. package/dist/component/balanceFunding/internal/mutations.d.ts +55 -0
  67. package/dist/component/balanceFunding/internal/mutations.d.ts.map +1 -0
  68. package/dist/component/balanceFunding/internal/mutations.js +54 -0
  69. package/dist/component/balanceFunding/internal/mutations.js.map +1 -0
  70. package/dist/component/balanceFunding/internal/queries.d.ts +116 -0
  71. package/dist/component/balanceFunding/internal/queries.d.ts.map +1 -0
  72. package/dist/component/balanceFunding/internal/queries.js +35 -0
  73. package/dist/component/balanceFunding/internal/queries.js.map +1 -0
  74. package/dist/component/balanceFunding/internal/workflow.d.ts +10 -0
  75. package/dist/component/balanceFunding/internal/workflow.d.ts.map +1 -0
  76. package/dist/component/balanceFunding/internal/workflow.js +31 -0
  77. package/dist/component/balanceFunding/internal/workflow.js.map +1 -0
  78. package/dist/component/balanceFunding/lifecycleHandlers.d.ts +126 -0
  79. package/dist/component/balanceFunding/lifecycleHandlers.d.ts.map +1 -1
  80. package/dist/component/balanceFunding/mutations.d.ts +419 -16
  81. package/dist/component/balanceFunding/mutations.d.ts.map +1 -1
  82. package/dist/component/balanceFunding/mutations.js +24 -0
  83. package/dist/component/balanceFunding/mutations.js.map +1 -1
  84. package/dist/component/balanceFunding/preparationHandlers.d.ts +42 -0
  85. package/dist/component/balanceFunding/preparationHandlers.d.ts.map +1 -1
  86. package/dist/component/balanceFunding/queries.d.ts +78 -0
  87. package/dist/component/balanceFunding/queries.d.ts.map +1 -1
  88. package/dist/component/balanceFunding/queries.js +35 -0
  89. package/dist/component/balanceFunding/queries.js.map +1 -1
  90. package/dist/component/balanceFunding/receipt.d.ts +5 -0
  91. package/dist/component/balanceFunding/receipt.d.ts.map +1 -0
  92. package/dist/component/balanceFunding/receipt.js +37 -0
  93. package/dist/component/balanceFunding/receipt.js.map +1 -0
  94. package/dist/component/balanceFunding/schema.d.ts +506 -2
  95. package/dist/component/balanceFunding/schema.d.ts.map +1 -1
  96. package/dist/component/balanceFunding/schema.js +2 -0
  97. package/dist/component/balanceFunding/schema.js.map +1 -1
  98. package/dist/component/balanceFunding/stateHandlers.d.ts +42 -0
  99. package/dist/component/balanceFunding/stateHandlers.d.ts.map +1 -1
  100. package/dist/component/balanceFunding/workflowControl.d.ts +19 -0
  101. package/dist/component/balanceFunding/workflowControl.d.ts.map +1 -0
  102. package/dist/component/balanceFunding/workflowControl.js +149 -0
  103. package/dist/component/balanceFunding/workflowControl.js.map +1 -0
  104. package/dist/component/balanceFunding/workflowSchema.d.ts +356 -0
  105. package/dist/component/balanceFunding/workflowSchema.d.ts.map +1 -0
  106. package/dist/component/balanceFunding/workflowSchema.js +48 -0
  107. package/dist/component/balanceFunding/workflowSchema.js.map +1 -0
  108. package/dist/component/balanceFunding/workflowState.d.ts +157 -0
  109. package/dist/component/balanceFunding/workflowState.d.ts.map +1 -0
  110. package/dist/component/balanceFunding/workflowState.js +194 -0
  111. package/dist/component/balanceFunding/workflowState.js.map +1 -0
  112. package/dist/component/balanceFunding/workflowValidators.d.ts +306 -0
  113. package/dist/component/balanceFunding/workflowValidators.d.ts.map +1 -0
  114. package/dist/component/balanceFunding/workflowValidators.js +27 -0
  115. package/dist/component/balanceFunding/workflowValidators.js.map +1 -0
  116. package/dist/component/earnings/triggers.d.ts +388 -2
  117. package/dist/component/earnings/triggers.d.ts.map +1 -1
  118. package/dist/component/payoutRelease/queries.d.ts +2 -2
  119. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  120. package/dist/component/processingCostReconciliation/adoption.d.ts +29 -0
  121. package/dist/component/processingCostReconciliation/adoption.d.ts.map +1 -0
  122. package/dist/component/processingCostReconciliation/adoption.js +58 -0
  123. package/dist/component/processingCostReconciliation/adoption.js.map +1 -0
  124. package/dist/component/processingCostReconciliation/bridge.d.ts +45 -0
  125. package/dist/component/processingCostReconciliation/bridge.d.ts.map +1 -0
  126. package/dist/component/processingCostReconciliation/bridge.js +41 -0
  127. package/dist/component/processingCostReconciliation/bridge.js.map +1 -0
  128. package/dist/component/processingCostReconciliation/helpers.d.ts +327 -0
  129. package/dist/component/processingCostReconciliation/helpers.d.ts.map +1 -0
  130. package/dist/component/processingCostReconciliation/helpers.js +39 -0
  131. package/dist/component/processingCostReconciliation/helpers.js.map +1 -0
  132. package/dist/component/processingCostReconciliation/mutations.d.ts +303 -0
  133. package/dist/component/processingCostReconciliation/mutations.d.ts.map +1 -0
  134. package/dist/component/processingCostReconciliation/mutations.js +121 -0
  135. package/dist/component/processingCostReconciliation/mutations.js.map +1 -0
  136. package/dist/component/processingCostReconciliation/queries.d.ts +422 -0
  137. package/dist/component/processingCostReconciliation/queries.d.ts.map +1 -0
  138. package/dist/component/processingCostReconciliation/queries.js +19 -0
  139. package/dist/component/processingCostReconciliation/queries.js.map +1 -0
  140. package/dist/component/processingCostReconciliation/rollback.d.ts +21 -0
  141. package/dist/component/processingCostReconciliation/rollback.d.ts.map +1 -0
  142. package/dist/component/processingCostReconciliation/rollback.js +54 -0
  143. package/dist/component/processingCostReconciliation/rollback.js.map +1 -0
  144. package/dist/component/processingCostReconciliation/schema.d.ts +2460 -0
  145. package/dist/component/processingCostReconciliation/schema.d.ts.map +1 -0
  146. package/dist/component/processingCostReconciliation/schema.js +137 -0
  147. package/dist/component/processingCostReconciliation/schema.js.map +1 -0
  148. package/dist/component/processingCostReconciliation/steps.d.ts +306 -0
  149. package/dist/component/processingCostReconciliation/steps.d.ts.map +1 -0
  150. package/dist/component/processingCostReconciliation/steps.js +149 -0
  151. package/dist/component/processingCostReconciliation/steps.js.map +1 -0
  152. package/dist/component/processingCostReconciliation/validation.d.ts +13 -0
  153. package/dist/component/processingCostReconciliation/validation.d.ts.map +1 -0
  154. package/dist/component/processingCostReconciliation/validation.js +61 -0
  155. package/dist/component/processingCostReconciliation/validation.js.map +1 -0
  156. package/dist/component/processingCostReconciliation/workflow.d.ts +105 -0
  157. package/dist/component/processingCostReconciliation/workflow.d.ts.map +1 -0
  158. package/dist/component/processingCostReconciliation/workflow.js +33 -0
  159. package/dist/component/processingCostReconciliation/workflow.js.map +1 -0
  160. package/dist/component/schema.d.ts +694 -1
  161. package/dist/component/schema.js +2 -0
  162. package/dist/component/schema.js.map +1 -1
  163. package/package.json +1 -1
  164. package/src/client/balanceFundingWorkflow/capture.test.ts +144 -0
  165. package/src/client/balanceFundingWorkflow/client.ts +419 -0
  166. package/src/client/billing/balanceFunding.ts +50 -0
  167. package/src/client/costRecovery-invoices.ts +19 -4
  168. package/src/client/costRecovery.ts +4 -2
  169. package/src/client/index.ts +15 -0
  170. package/src/client/processingCostReconciliation/client.ts +75 -0
  171. package/src/client/processingCostReconciliation/contracts.ts +176 -0
  172. package/src/client/processingCostReconciliation/invoiceFunding.ts +270 -0
  173. package/src/client/processingCostReconciliation/invoiceProvider.test.ts +353 -0
  174. package/src/client/processingCostReconciliation/provider.test.ts +324 -0
  175. package/src/client/processingCostReconciliation/provider.ts +178 -0
  176. package/src/client/settlement/processingCostHistory.ts +31 -0
  177. package/src/client/settlement/processingCosts.ts +50 -15
  178. package/src/component/_generated/api.ts +36 -0
  179. package/src/component/_generated/component.ts +1094 -0
  180. package/src/component/balanceFunding/internal/actions.ts +107 -0
  181. package/src/component/balanceFunding/internal/mutations.ts +66 -0
  182. package/src/component/balanceFunding/internal/queries.ts +34 -0
  183. package/src/component/balanceFunding/internal/workflow.ts +49 -0
  184. package/src/component/balanceFunding/mutations.ts +34 -0
  185. package/src/component/balanceFunding/queries.ts +38 -0
  186. package/src/component/balanceFunding/receipt.ts +48 -0
  187. package/src/component/balanceFunding/schema.ts +2 -0
  188. package/src/component/balanceFunding/scopeLookup.test.ts +94 -0
  189. package/src/component/balanceFunding/workflow.fixtures.ts +366 -0
  190. package/src/component/balanceFunding/workflow.test.ts +552 -0
  191. package/src/component/balanceFunding/workflowControl.ts +198 -0
  192. package/src/component/balanceFunding/workflowSchema.ts +78 -0
  193. package/src/component/balanceFunding/workflowState.ts +285 -0
  194. package/src/component/balanceFunding/workflowValidators.ts +40 -0
  195. package/src/component/processingCostReconciliation/adoption.test.ts +206 -0
  196. package/src/component/processingCostReconciliation/adoption.ts +77 -0
  197. package/src/component/processingCostReconciliation/bridge.ts +50 -0
  198. package/src/component/processingCostReconciliation/helpers.ts +55 -0
  199. package/src/component/processingCostReconciliation/invoice.test.ts +152 -0
  200. package/src/component/processingCostReconciliation/mutations.ts +148 -0
  201. package/src/component/processingCostReconciliation/queries.ts +18 -0
  202. package/src/component/processingCostReconciliation/rollback.ts +72 -0
  203. package/src/component/processingCostReconciliation/schema.ts +191 -0
  204. package/src/component/processingCostReconciliation/state.test.ts +407 -0
  205. package/src/component/processingCostReconciliation/steps.ts +168 -0
  206. package/src/component/processingCostReconciliation/validation.ts +79 -0
  207. package/src/component/processingCostReconciliation/workflow.test.ts +329 -0
  208. package/src/component/processingCostReconciliation/workflow.ts +50 -0
  209. package/src/component/schema.ts +2 -0
@@ -0,0 +1,61 @@
1
+ import { same } from "../recoveryWorkflow/helpers.js";
2
+ import { conflict } from "./helpers.js";
3
+ const identifier = (value) => typeof value === "string" && value.trim().length > 0 && value.length <= 200;
4
+ export function observationFailure(op, o, original) {
5
+ if ([
6
+ o.gross,
7
+ o.originalProcessingFee,
8
+ o.processingFee,
9
+ o.disputeFees,
10
+ o.principalReturned,
11
+ ].some((n) => !Number.isSafeInteger(n) || n < 0) ||
12
+ o.gross === 0 ||
13
+ o.principalReturned > o.gross ||
14
+ !identifier(o.sourceChargeId) ||
15
+ !identifier(o.provenance.invoiceId) ||
16
+ !identifier(o.provenance.invoicePaymentId) ||
17
+ !identifier(o.provenance.customerAccountId))
18
+ return {
19
+ status: "rejected",
20
+ reason: "unsupported_source",
21
+ retryable: false,
22
+ };
23
+ if (o.paymentIntentId !== op.source.paymentIntentId ||
24
+ o.gross !== op.source.gross ||
25
+ o.currency !== op.currency)
26
+ return conflict("identity_changed");
27
+ if (op.source.kind === "sale") {
28
+ if (o.provenance.recoveryInvoiceItemId !== undefined)
29
+ return conflict("identity_changed");
30
+ if (!identifier(o.provenance.stripePriceId) ||
31
+ !identifier(o.provenance.stripeProductId))
32
+ return {
33
+ status: "rejected",
34
+ reason: "unsupported_source",
35
+ retryable: false,
36
+ };
37
+ if (o.provenance.customerAccountId !== op.source.customerAccountId ||
38
+ (op.source.invoiceId !== undefined &&
39
+ o.provenance.invoiceId !== op.source.invoiceId) ||
40
+ (op.source.subscriptionId !== undefined &&
41
+ o.provenance.subscriptionId !== op.source.subscriptionId) ||
42
+ (op.source.stripePriceId !== undefined &&
43
+ o.provenance.stripePriceId !== op.source.stripePriceId) ||
44
+ (op.source.stripeProductId !== undefined &&
45
+ o.provenance.stripeProductId !== op.source.stripeProductId))
46
+ return conflict("identity_changed");
47
+ }
48
+ else if (o.provenance.stripePriceId !== undefined ||
49
+ o.provenance.stripeProductId !== undefined)
50
+ return conflict("identity_changed");
51
+ if (original &&
52
+ (original.policy.sellingFee !== op.policy.sellingFee ||
53
+ original.source.kind !== op.source.kind ||
54
+ (original.source.kind === "sale" &&
55
+ op.source.kind === "sale" &&
56
+ original.source.stripeAccountId !== op.source.stripeAccountId) ||
57
+ !same(original.result?.observation.provenance, o.provenance)))
58
+ return conflict("identity_changed");
59
+ return null;
60
+ }
61
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/component/processingCostReconciliation/validation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,EAAE,CACpC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;AAC9E,MAAM,UAAU,kBAAkB,CAChC,EAAiD,EACjD,C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,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC;YAChE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;QAE/D,OAAO,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IACtC,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,105 @@
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
+ currency: import("convex/values").VString<string, "required">;
5
+ operationId: import("convex/values").VId<import("convex/values").GenericId<"processingCostReconciliationOperations">, "required">;
6
+ version: import("convex/values").VFloat64<number, "required">;
7
+ }>, import("@convex-dev/workflow").WorkflowMutationResult<{
8
+ accountId: string;
9
+ currency: string;
10
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
11
+ scopeKey: string;
12
+ status: "queued" | "running";
13
+ version: number;
14
+ } | {
15
+ accountId: string;
16
+ currency: string;
17
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
18
+ result: {
19
+ claim: {
20
+ _creationTime: number;
21
+ _id: import("convex/values").GenericId<"recoveryClaims">;
22
+ accountId: string;
23
+ amountDue: number;
24
+ claimKey: string;
25
+ collectedAmount: number;
26
+ currency: string;
27
+ openingCollection?: {
28
+ amountDue: number;
29
+ collectedAmount: number;
30
+ operationKey: string;
31
+ revision: number;
32
+ } | undefined;
33
+ outstanding: number;
34
+ reservedAmount: number;
35
+ revision: number;
36
+ scopeKey: string;
37
+ sign: "negative" | "positive" | "zero";
38
+ sourceChargeId: string;
39
+ sourceGross: number;
40
+ sourceProcessingFee: number;
41
+ };
42
+ deficit: {
43
+ amountDue: number;
44
+ currency: string;
45
+ disputeLiability: number;
46
+ processingLiability: number;
47
+ retainedFee: number;
48
+ };
49
+ observation: {
50
+ currency: string;
51
+ disputeFees: number;
52
+ gross: number;
53
+ originalProcessingFee: number;
54
+ paymentIntentId: string;
55
+ principalReturned: number;
56
+ processingFee: number;
57
+ provenance: {
58
+ customerAccountId: string;
59
+ invoiceId: string;
60
+ invoicePaymentId: string;
61
+ recoveryInvoiceItemId?: string | undefined;
62
+ stripePriceId?: string | undefined;
63
+ stripeProductId?: string | undefined;
64
+ subscriptionId?: string | undefined;
65
+ };
66
+ sourceChargeId: string;
67
+ };
68
+ rollbackClaim?: {
69
+ _creationTime: number;
70
+ _id: import("convex/values").GenericId<"recoveryClaims">;
71
+ accountId: string;
72
+ amountDue: number;
73
+ claimKey: string;
74
+ collectedAmount: number;
75
+ currency: string;
76
+ openingCollection?: {
77
+ amountDue: number;
78
+ collectedAmount: number;
79
+ operationKey: string;
80
+ revision: number;
81
+ } | undefined;
82
+ outstanding: number;
83
+ reservedAmount: number;
84
+ revision: number;
85
+ scopeKey: string;
86
+ sign: "negative" | "positive" | "zero";
87
+ sourceChargeId: string;
88
+ sourceGross: number;
89
+ sourceProcessingFee: number;
90
+ } | undefined;
91
+ };
92
+ scopeKey: string;
93
+ status: "completed";
94
+ version: number;
95
+ } | {
96
+ accountId: string;
97
+ currency: string;
98
+ operationId: import("convex/values").GenericId<"processingCostReconciliationOperations">;
99
+ reason: string;
100
+ retryable: boolean;
101
+ scopeKey: string;
102
+ status: "conflict" | "not_ready" | "rejected" | "unknown";
103
+ version: number;
104
+ }>>;
105
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../../src/component/processingCostReconciliation/workflow.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CZ,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { anyApi } from "convex/server";
2
+ import { executionWorkflow } from "../durableExecution/runtime.js";
3
+ import { refFields, safeStatus } from "./schema.js";
4
+ import { financialRetryDecision } from "../../client/financialOutcomes/retry.js";
5
+ export const run = executionWorkflow
6
+ .define({ args: refFields, returns: safeStatus })
7
+ .handler(async (step, args) => {
8
+ const op = await step.runQuery(anyApi.processingCostReconciliation.queries.saved, args);
9
+ for (let attempt = 0; attempt < op.maxAttempts; attempt++) {
10
+ const observed = await step.runAction(anyApi.processingCostReconciliation.bridge.invoke, args, { name: `observe-${attempt}`, retry: false });
11
+ const state = observed.status === "ready"
12
+ ? await step.runMutation(anyApi.processingCostReconciliation.steps.apply, { ...args, observation: observed.value }, { name: "apply" })
13
+ : await step.runMutation(anyApi.processingCostReconciliation.steps.unavailable, { ...args, outcome: observed });
14
+ if (!["not_ready", "unknown"].includes(state.status))
15
+ return state;
16
+ if (state.status !== "not_ready" && state.status !== "unknown")
17
+ return state;
18
+ const decision = financialRetryDecision({
19
+ status: state.status,
20
+ reason: state.reason,
21
+ retryable: state.retryable,
22
+ }, attempt, {
23
+ maxRetries: op.maxAttempts - 1,
24
+ initialDelayMs: op.retryDelayMs,
25
+ maxDelayMs: op.retryDelayMs,
26
+ });
27
+ if (decision.status === "stop")
28
+ return state;
29
+ await step.sleep(decision.delayMs);
30
+ }
31
+ throw new Error("Processing-cost observation budget exhausted.");
32
+ });
33
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../../src/component/processingCostReconciliation/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,MAAM,CAAC,MAAM,GAAG,GAAG,iBAAiB;KACjC,MA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