@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
|
@@ -644,6 +644,89 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
644
644
|
},
|
|
645
645
|
Name
|
|
646
646
|
>;
|
|
647
|
+
cancelWorkflow: FunctionReference<
|
|
648
|
+
"mutation",
|
|
649
|
+
"internal",
|
|
650
|
+
{
|
|
651
|
+
accountId: string;
|
|
652
|
+
definitionVersion: string;
|
|
653
|
+
operationId: string;
|
|
654
|
+
providerApiVersion: string;
|
|
655
|
+
scopeKey: string;
|
|
656
|
+
stripeSubscriptionId: string;
|
|
657
|
+
version: number;
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
accountId: string;
|
|
661
|
+
cancelRequested: boolean;
|
|
662
|
+
failureCode?:
|
|
663
|
+
"invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
664
|
+
operationId: string;
|
|
665
|
+
scopeKey: string;
|
|
666
|
+
state:
|
|
667
|
+
| "pending"
|
|
668
|
+
| "running"
|
|
669
|
+
| "unknown"
|
|
670
|
+
| "succeeded"
|
|
671
|
+
| "canceled"
|
|
672
|
+
| "failed";
|
|
673
|
+
version: number;
|
|
674
|
+
},
|
|
675
|
+
Name
|
|
676
|
+
>;
|
|
677
|
+
claimProviderPhase: FunctionReference<
|
|
678
|
+
"mutation",
|
|
679
|
+
"internal",
|
|
680
|
+
{
|
|
681
|
+
accountId: string;
|
|
682
|
+
definitionVersion: string;
|
|
683
|
+
operationId: string;
|
|
684
|
+
phase: "create" | "attach" | "apply";
|
|
685
|
+
providerApiVersion: string;
|
|
686
|
+
providerKey: string;
|
|
687
|
+
scopeKey: string;
|
|
688
|
+
stripeSubscriptionId: string;
|
|
689
|
+
version: number;
|
|
690
|
+
},
|
|
691
|
+
| {
|
|
692
|
+
mode: "execute" | "reconcile";
|
|
693
|
+
paymentMethodId?: string;
|
|
694
|
+
status: "claimed";
|
|
695
|
+
}
|
|
696
|
+
| {
|
|
697
|
+
status: "ready";
|
|
698
|
+
value: {
|
|
699
|
+
customerAccount: string;
|
|
700
|
+
enabled?: boolean;
|
|
701
|
+
paymentMethodId: string | null;
|
|
702
|
+
paymentMethodTypes?: Array<string> | null;
|
|
703
|
+
phase: "create" | "attach" | "apply";
|
|
704
|
+
providerApiVersion: string;
|
|
705
|
+
stripeSubscriptionId: string;
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
| {
|
|
709
|
+
reason: "provider_outcome_unknown" | "history_incomplete";
|
|
710
|
+
retryable: false;
|
|
711
|
+
status: "unknown";
|
|
712
|
+
}
|
|
713
|
+
| {
|
|
714
|
+
reason: "scope_busy" | "identity_changed" | "revision_changed";
|
|
715
|
+
retryable: false;
|
|
716
|
+
status: "conflict";
|
|
717
|
+
}
|
|
718
|
+
| {
|
|
719
|
+
reason: "invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
720
|
+
retryable: false;
|
|
721
|
+
status: "rejected";
|
|
722
|
+
}
|
|
723
|
+
| {
|
|
724
|
+
reason: "provider_pending";
|
|
725
|
+
retryable: true;
|
|
726
|
+
status: "not_ready";
|
|
727
|
+
},
|
|
728
|
+
Name
|
|
729
|
+
>;
|
|
647
730
|
failBeforeStart: FunctionReference<
|
|
648
731
|
"mutation",
|
|
649
732
|
"internal",
|
|
@@ -661,6 +744,48 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
661
744
|
accountId: string;
|
|
662
745
|
cancelRequested: boolean;
|
|
663
746
|
enabled: boolean;
|
|
747
|
+
execution?: {
|
|
748
|
+
apply?: {
|
|
749
|
+
receipt?: {
|
|
750
|
+
customerAccount: string;
|
|
751
|
+
enabled?: boolean;
|
|
752
|
+
paymentMethodId: string | null;
|
|
753
|
+
paymentMethodTypes?: Array<string> | null;
|
|
754
|
+
phase: "create" | "attach" | "apply";
|
|
755
|
+
providerApiVersion: string;
|
|
756
|
+
stripeSubscriptionId: string;
|
|
757
|
+
};
|
|
758
|
+
state: "running" | "unknown" | "succeeded";
|
|
759
|
+
};
|
|
760
|
+
attach?: {
|
|
761
|
+
receipt?: {
|
|
762
|
+
customerAccount: string;
|
|
763
|
+
enabled?: boolean;
|
|
764
|
+
paymentMethodId: string | null;
|
|
765
|
+
paymentMethodTypes?: Array<string> | null;
|
|
766
|
+
phase: "create" | "attach" | "apply";
|
|
767
|
+
providerApiVersion: string;
|
|
768
|
+
stripeSubscriptionId: string;
|
|
769
|
+
};
|
|
770
|
+
state: "running" | "unknown" | "succeeded";
|
|
771
|
+
};
|
|
772
|
+
create?: {
|
|
773
|
+
receipt?: {
|
|
774
|
+
customerAccount: string;
|
|
775
|
+
enabled?: boolean;
|
|
776
|
+
paymentMethodId: string | null;
|
|
777
|
+
paymentMethodTypes?: Array<string> | null;
|
|
778
|
+
phase: "create" | "attach" | "apply";
|
|
779
|
+
providerApiVersion: string;
|
|
780
|
+
stripeSubscriptionId: string;
|
|
781
|
+
};
|
|
782
|
+
state: "running" | "unknown" | "succeeded";
|
|
783
|
+
};
|
|
784
|
+
definitionVersion: string;
|
|
785
|
+
providerAction: string;
|
|
786
|
+
providerApiVersion: string;
|
|
787
|
+
workflowId?: string;
|
|
788
|
+
};
|
|
664
789
|
failureCode?:
|
|
665
790
|
"invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
666
791
|
kind: "prepare" | "apply";
|
|
@@ -714,6 +839,48 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
714
839
|
accountId: string;
|
|
715
840
|
cancelRequested: boolean;
|
|
716
841
|
enabled: boolean;
|
|
842
|
+
execution?: {
|
|
843
|
+
apply?: {
|
|
844
|
+
receipt?: {
|
|
845
|
+
customerAccount: string;
|
|
846
|
+
enabled?: boolean;
|
|
847
|
+
paymentMethodId: string | null;
|
|
848
|
+
paymentMethodTypes?: Array<string> | null;
|
|
849
|
+
phase: "create" | "attach" | "apply";
|
|
850
|
+
providerApiVersion: string;
|
|
851
|
+
stripeSubscriptionId: string;
|
|
852
|
+
};
|
|
853
|
+
state: "running" | "unknown" | "succeeded";
|
|
854
|
+
};
|
|
855
|
+
attach?: {
|
|
856
|
+
receipt?: {
|
|
857
|
+
customerAccount: string;
|
|
858
|
+
enabled?: boolean;
|
|
859
|
+
paymentMethodId: string | null;
|
|
860
|
+
paymentMethodTypes?: Array<string> | null;
|
|
861
|
+
phase: "create" | "attach" | "apply";
|
|
862
|
+
providerApiVersion: string;
|
|
863
|
+
stripeSubscriptionId: string;
|
|
864
|
+
};
|
|
865
|
+
state: "running" | "unknown" | "succeeded";
|
|
866
|
+
};
|
|
867
|
+
create?: {
|
|
868
|
+
receipt?: {
|
|
869
|
+
customerAccount: string;
|
|
870
|
+
enabled?: boolean;
|
|
871
|
+
paymentMethodId: string | null;
|
|
872
|
+
paymentMethodTypes?: Array<string> | null;
|
|
873
|
+
phase: "create" | "attach" | "apply";
|
|
874
|
+
providerApiVersion: string;
|
|
875
|
+
stripeSubscriptionId: string;
|
|
876
|
+
};
|
|
877
|
+
state: "running" | "unknown" | "succeeded";
|
|
878
|
+
};
|
|
879
|
+
definitionVersion: string;
|
|
880
|
+
providerAction: string;
|
|
881
|
+
providerApiVersion: string;
|
|
882
|
+
workflowId?: string;
|
|
883
|
+
};
|
|
717
884
|
failureCode?:
|
|
718
885
|
"invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
719
886
|
kind: "prepare" | "apply";
|
|
@@ -767,6 +934,48 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
767
934
|
accountId: string;
|
|
768
935
|
cancelRequested: boolean;
|
|
769
936
|
enabled: boolean;
|
|
937
|
+
execution?: {
|
|
938
|
+
apply?: {
|
|
939
|
+
receipt?: {
|
|
940
|
+
customerAccount: string;
|
|
941
|
+
enabled?: boolean;
|
|
942
|
+
paymentMethodId: string | null;
|
|
943
|
+
paymentMethodTypes?: Array<string> | null;
|
|
944
|
+
phase: "create" | "attach" | "apply";
|
|
945
|
+
providerApiVersion: string;
|
|
946
|
+
stripeSubscriptionId: string;
|
|
947
|
+
};
|
|
948
|
+
state: "running" | "unknown" | "succeeded";
|
|
949
|
+
};
|
|
950
|
+
attach?: {
|
|
951
|
+
receipt?: {
|
|
952
|
+
customerAccount: string;
|
|
953
|
+
enabled?: boolean;
|
|
954
|
+
paymentMethodId: string | null;
|
|
955
|
+
paymentMethodTypes?: Array<string> | null;
|
|
956
|
+
phase: "create" | "attach" | "apply";
|
|
957
|
+
providerApiVersion: string;
|
|
958
|
+
stripeSubscriptionId: string;
|
|
959
|
+
};
|
|
960
|
+
state: "running" | "unknown" | "succeeded";
|
|
961
|
+
};
|
|
962
|
+
create?: {
|
|
963
|
+
receipt?: {
|
|
964
|
+
customerAccount: string;
|
|
965
|
+
enabled?: boolean;
|
|
966
|
+
paymentMethodId: string | null;
|
|
967
|
+
paymentMethodTypes?: Array<string> | null;
|
|
968
|
+
phase: "create" | "attach" | "apply";
|
|
969
|
+
providerApiVersion: string;
|
|
970
|
+
stripeSubscriptionId: string;
|
|
971
|
+
};
|
|
972
|
+
state: "running" | "unknown" | "succeeded";
|
|
973
|
+
};
|
|
974
|
+
definitionVersion: string;
|
|
975
|
+
providerAction: string;
|
|
976
|
+
providerApiVersion: string;
|
|
977
|
+
workflowId?: string;
|
|
978
|
+
};
|
|
770
979
|
failureCode?:
|
|
771
980
|
"invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
772
981
|
kind: "prepare" | "apply";
|
|
@@ -849,6 +1058,48 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
849
1058
|
accountId: string;
|
|
850
1059
|
cancelRequested: boolean;
|
|
851
1060
|
enabled: boolean;
|
|
1061
|
+
execution?: {
|
|
1062
|
+
apply?: {
|
|
1063
|
+
receipt?: {
|
|
1064
|
+
customerAccount: string;
|
|
1065
|
+
enabled?: boolean;
|
|
1066
|
+
paymentMethodId: string | null;
|
|
1067
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1068
|
+
phase: "create" | "attach" | "apply";
|
|
1069
|
+
providerApiVersion: string;
|
|
1070
|
+
stripeSubscriptionId: string;
|
|
1071
|
+
};
|
|
1072
|
+
state: "running" | "unknown" | "succeeded";
|
|
1073
|
+
};
|
|
1074
|
+
attach?: {
|
|
1075
|
+
receipt?: {
|
|
1076
|
+
customerAccount: string;
|
|
1077
|
+
enabled?: boolean;
|
|
1078
|
+
paymentMethodId: string | null;
|
|
1079
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1080
|
+
phase: "create" | "attach" | "apply";
|
|
1081
|
+
providerApiVersion: string;
|
|
1082
|
+
stripeSubscriptionId: string;
|
|
1083
|
+
};
|
|
1084
|
+
state: "running" | "unknown" | "succeeded";
|
|
1085
|
+
};
|
|
1086
|
+
create?: {
|
|
1087
|
+
receipt?: {
|
|
1088
|
+
customerAccount: string;
|
|
1089
|
+
enabled?: boolean;
|
|
1090
|
+
paymentMethodId: string | null;
|
|
1091
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1092
|
+
phase: "create" | "attach" | "apply";
|
|
1093
|
+
providerApiVersion: string;
|
|
1094
|
+
stripeSubscriptionId: string;
|
|
1095
|
+
};
|
|
1096
|
+
state: "running" | "unknown" | "succeeded";
|
|
1097
|
+
};
|
|
1098
|
+
definitionVersion: string;
|
|
1099
|
+
providerAction: string;
|
|
1100
|
+
providerApiVersion: string;
|
|
1101
|
+
workflowId?: string;
|
|
1102
|
+
};
|
|
852
1103
|
failureCode?:
|
|
853
1104
|
"invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
854
1105
|
kind: "prepare" | "apply";
|
|
@@ -935,6 +1186,48 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
935
1186
|
accountId: string;
|
|
936
1187
|
cancelRequested: boolean;
|
|
937
1188
|
enabled: boolean;
|
|
1189
|
+
execution?: {
|
|
1190
|
+
apply?: {
|
|
1191
|
+
receipt?: {
|
|
1192
|
+
customerAccount: string;
|
|
1193
|
+
enabled?: boolean;
|
|
1194
|
+
paymentMethodId: string | null;
|
|
1195
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1196
|
+
phase: "create" | "attach" | "apply";
|
|
1197
|
+
providerApiVersion: string;
|
|
1198
|
+
stripeSubscriptionId: string;
|
|
1199
|
+
};
|
|
1200
|
+
state: "running" | "unknown" | "succeeded";
|
|
1201
|
+
};
|
|
1202
|
+
attach?: {
|
|
1203
|
+
receipt?: {
|
|
1204
|
+
customerAccount: string;
|
|
1205
|
+
enabled?: boolean;
|
|
1206
|
+
paymentMethodId: string | null;
|
|
1207
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1208
|
+
phase: "create" | "attach" | "apply";
|
|
1209
|
+
providerApiVersion: string;
|
|
1210
|
+
stripeSubscriptionId: string;
|
|
1211
|
+
};
|
|
1212
|
+
state: "running" | "unknown" | "succeeded";
|
|
1213
|
+
};
|
|
1214
|
+
create?: {
|
|
1215
|
+
receipt?: {
|
|
1216
|
+
customerAccount: string;
|
|
1217
|
+
enabled?: boolean;
|
|
1218
|
+
paymentMethodId: string | null;
|
|
1219
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1220
|
+
phase: "create" | "attach" | "apply";
|
|
1221
|
+
providerApiVersion: string;
|
|
1222
|
+
stripeSubscriptionId: string;
|
|
1223
|
+
};
|
|
1224
|
+
state: "running" | "unknown" | "succeeded";
|
|
1225
|
+
};
|
|
1226
|
+
definitionVersion: string;
|
|
1227
|
+
providerAction: string;
|
|
1228
|
+
providerApiVersion: string;
|
|
1229
|
+
workflowId?: string;
|
|
1230
|
+
};
|
|
938
1231
|
failureCode?:
|
|
939
1232
|
"invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
940
1233
|
kind: "prepare" | "apply";
|
|
@@ -965,6 +1258,59 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
965
1258
|
},
|
|
966
1259
|
Name
|
|
967
1260
|
>;
|
|
1261
|
+
resumeWorkflow: FunctionReference<
|
|
1262
|
+
"mutation",
|
|
1263
|
+
"internal",
|
|
1264
|
+
{
|
|
1265
|
+
accountId: string;
|
|
1266
|
+
definitionVersion: string;
|
|
1267
|
+
operationId: string;
|
|
1268
|
+
providerApiVersion: string;
|
|
1269
|
+
scopeKey: string;
|
|
1270
|
+
stripeSubscriptionId: string;
|
|
1271
|
+
version: number;
|
|
1272
|
+
},
|
|
1273
|
+
| {
|
|
1274
|
+
operation: {
|
|
1275
|
+
accountId: string;
|
|
1276
|
+
operationId: string;
|
|
1277
|
+
scopeKey: string;
|
|
1278
|
+
version: number;
|
|
1279
|
+
};
|
|
1280
|
+
status: "accepted";
|
|
1281
|
+
workflowId?: string;
|
|
1282
|
+
}
|
|
1283
|
+
| {
|
|
1284
|
+
operation: {
|
|
1285
|
+
accountId: string;
|
|
1286
|
+
operationId: string;
|
|
1287
|
+
scopeKey: string;
|
|
1288
|
+
version: number;
|
|
1289
|
+
};
|
|
1290
|
+
status: "canceled";
|
|
1291
|
+
}
|
|
1292
|
+
| {
|
|
1293
|
+
reason: "provider_outcome_unknown" | "history_incomplete";
|
|
1294
|
+
retryable: false;
|
|
1295
|
+
status: "unknown";
|
|
1296
|
+
}
|
|
1297
|
+
| {
|
|
1298
|
+
reason: "scope_busy" | "identity_changed" | "revision_changed";
|
|
1299
|
+
retryable: false;
|
|
1300
|
+
status: "conflict";
|
|
1301
|
+
}
|
|
1302
|
+
| {
|
|
1303
|
+
reason: "invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
1304
|
+
retryable: false;
|
|
1305
|
+
status: "rejected";
|
|
1306
|
+
}
|
|
1307
|
+
| {
|
|
1308
|
+
reason: "provider_pending";
|
|
1309
|
+
retryable: true;
|
|
1310
|
+
status: "not_ready";
|
|
1311
|
+
},
|
|
1312
|
+
Name
|
|
1313
|
+
>;
|
|
968
1314
|
savePreparation: FunctionReference<
|
|
969
1315
|
"mutation",
|
|
970
1316
|
"internal",
|
|
@@ -1013,6 +1359,48 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
1013
1359
|
accountId: string;
|
|
1014
1360
|
cancelRequested: boolean;
|
|
1015
1361
|
enabled: boolean;
|
|
1362
|
+
execution?: {
|
|
1363
|
+
apply?: {
|
|
1364
|
+
receipt?: {
|
|
1365
|
+
customerAccount: string;
|
|
1366
|
+
enabled?: boolean;
|
|
1367
|
+
paymentMethodId: string | null;
|
|
1368
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1369
|
+
phase: "create" | "attach" | "apply";
|
|
1370
|
+
providerApiVersion: string;
|
|
1371
|
+
stripeSubscriptionId: string;
|
|
1372
|
+
};
|
|
1373
|
+
state: "running" | "unknown" | "succeeded";
|
|
1374
|
+
};
|
|
1375
|
+
attach?: {
|
|
1376
|
+
receipt?: {
|
|
1377
|
+
customerAccount: string;
|
|
1378
|
+
enabled?: boolean;
|
|
1379
|
+
paymentMethodId: string | null;
|
|
1380
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1381
|
+
phase: "create" | "attach" | "apply";
|
|
1382
|
+
providerApiVersion: string;
|
|
1383
|
+
stripeSubscriptionId: string;
|
|
1384
|
+
};
|
|
1385
|
+
state: "running" | "unknown" | "succeeded";
|
|
1386
|
+
};
|
|
1387
|
+
create?: {
|
|
1388
|
+
receipt?: {
|
|
1389
|
+
customerAccount: string;
|
|
1390
|
+
enabled?: boolean;
|
|
1391
|
+
paymentMethodId: string | null;
|
|
1392
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1393
|
+
phase: "create" | "attach" | "apply";
|
|
1394
|
+
providerApiVersion: string;
|
|
1395
|
+
stripeSubscriptionId: string;
|
|
1396
|
+
};
|
|
1397
|
+
state: "running" | "unknown" | "succeeded";
|
|
1398
|
+
};
|
|
1399
|
+
definitionVersion: string;
|
|
1400
|
+
providerAction: string;
|
|
1401
|
+
providerApiVersion: string;
|
|
1402
|
+
workflowId?: string;
|
|
1403
|
+
};
|
|
1016
1404
|
failureCode?:
|
|
1017
1405
|
"invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
1018
1406
|
kind: "prepare" | "apply";
|
|
@@ -1043,6 +1431,60 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
1043
1431
|
},
|
|
1044
1432
|
Name
|
|
1045
1433
|
>;
|
|
1434
|
+
startWorkflow: FunctionReference<
|
|
1435
|
+
"mutation",
|
|
1436
|
+
"internal",
|
|
1437
|
+
{
|
|
1438
|
+
accountId: string;
|
|
1439
|
+
definitionVersion: string;
|
|
1440
|
+
operationId: string;
|
|
1441
|
+
providerAction: string;
|
|
1442
|
+
providerApiVersion: string;
|
|
1443
|
+
scopeKey: string;
|
|
1444
|
+
stripeSubscriptionId: string;
|
|
1445
|
+
version: number;
|
|
1446
|
+
},
|
|
1447
|
+
| {
|
|
1448
|
+
operation: {
|
|
1449
|
+
accountId: string;
|
|
1450
|
+
operationId: string;
|
|
1451
|
+
scopeKey: string;
|
|
1452
|
+
version: number;
|
|
1453
|
+
};
|
|
1454
|
+
status: "accepted";
|
|
1455
|
+
workflowId?: string;
|
|
1456
|
+
}
|
|
1457
|
+
| {
|
|
1458
|
+
operation: {
|
|
1459
|
+
accountId: string;
|
|
1460
|
+
operationId: string;
|
|
1461
|
+
scopeKey: string;
|
|
1462
|
+
version: number;
|
|
1463
|
+
};
|
|
1464
|
+
status: "canceled";
|
|
1465
|
+
}
|
|
1466
|
+
| {
|
|
1467
|
+
reason: "provider_outcome_unknown" | "history_incomplete";
|
|
1468
|
+
retryable: false;
|
|
1469
|
+
status: "unknown";
|
|
1470
|
+
}
|
|
1471
|
+
| {
|
|
1472
|
+
reason: "scope_busy" | "identity_changed" | "revision_changed";
|
|
1473
|
+
retryable: false;
|
|
1474
|
+
status: "conflict";
|
|
1475
|
+
}
|
|
1476
|
+
| {
|
|
1477
|
+
reason: "invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
1478
|
+
retryable: false;
|
|
1479
|
+
status: "rejected";
|
|
1480
|
+
}
|
|
1481
|
+
| {
|
|
1482
|
+
reason: "provider_pending";
|
|
1483
|
+
retryable: true;
|
|
1484
|
+
status: "not_ready";
|
|
1485
|
+
},
|
|
1486
|
+
Name
|
|
1487
|
+
>;
|
|
1046
1488
|
};
|
|
1047
1489
|
queries: {
|
|
1048
1490
|
findPreparationOperation: FunctionReference<
|
|
@@ -1166,6 +1608,48 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
1166
1608
|
accountId: string;
|
|
1167
1609
|
cancelRequested: boolean;
|
|
1168
1610
|
enabled: boolean;
|
|
1611
|
+
execution?: {
|
|
1612
|
+
apply?: {
|
|
1613
|
+
receipt?: {
|
|
1614
|
+
customerAccount: string;
|
|
1615
|
+
enabled?: boolean;
|
|
1616
|
+
paymentMethodId: string | null;
|
|
1617
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1618
|
+
phase: "create" | "attach" | "apply";
|
|
1619
|
+
providerApiVersion: string;
|
|
1620
|
+
stripeSubscriptionId: string;
|
|
1621
|
+
};
|
|
1622
|
+
state: "running" | "unknown" | "succeeded";
|
|
1623
|
+
};
|
|
1624
|
+
attach?: {
|
|
1625
|
+
receipt?: {
|
|
1626
|
+
customerAccount: string;
|
|
1627
|
+
enabled?: boolean;
|
|
1628
|
+
paymentMethodId: string | null;
|
|
1629
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1630
|
+
phase: "create" | "attach" | "apply";
|
|
1631
|
+
providerApiVersion: string;
|
|
1632
|
+
stripeSubscriptionId: string;
|
|
1633
|
+
};
|
|
1634
|
+
state: "running" | "unknown" | "succeeded";
|
|
1635
|
+
};
|
|
1636
|
+
create?: {
|
|
1637
|
+
receipt?: {
|
|
1638
|
+
customerAccount: string;
|
|
1639
|
+
enabled?: boolean;
|
|
1640
|
+
paymentMethodId: string | null;
|
|
1641
|
+
paymentMethodTypes?: Array<string> | null;
|
|
1642
|
+
phase: "create" | "attach" | "apply";
|
|
1643
|
+
providerApiVersion: string;
|
|
1644
|
+
stripeSubscriptionId: string;
|
|
1645
|
+
};
|
|
1646
|
+
state: "running" | "unknown" | "succeeded";
|
|
1647
|
+
};
|
|
1648
|
+
definitionVersion: string;
|
|
1649
|
+
providerAction: string;
|
|
1650
|
+
providerApiVersion: string;
|
|
1651
|
+
workflowId?: string;
|
|
1652
|
+
};
|
|
1169
1653
|
failureCode?:
|
|
1170
1654
|
"invalid_scope" | "unsupported_source" | "policy_invalid";
|
|
1171
1655
|
kind: "prepare" | "apply";
|
|
@@ -1229,6 +1713,46 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
1229
1713
|
} | null,
|
|
1230
1714
|
Name
|
|
1231
1715
|
>;
|
|
1716
|
+
readScopePreparation: FunctionReference<
|
|
1717
|
+
"query",
|
|
1718
|
+
"internal",
|
|
1719
|
+
{
|
|
1720
|
+
accountId: string;
|
|
1721
|
+
providerApiVersion: string;
|
|
1722
|
+
scopeKey: string;
|
|
1723
|
+
stripeSubscriptionId: string;
|
|
1724
|
+
},
|
|
1725
|
+
| {
|
|
1726
|
+
_creationTime: number;
|
|
1727
|
+
_id: string;
|
|
1728
|
+
accountId: string;
|
|
1729
|
+
activeOperationId?: string;
|
|
1730
|
+
consentAt: number;
|
|
1731
|
+
consentReference: string;
|
|
1732
|
+
enabled: boolean;
|
|
1733
|
+
operationVersion: number;
|
|
1734
|
+
preparation: {
|
|
1735
|
+
customerAccount: string;
|
|
1736
|
+
paymentMethodId?: string;
|
|
1737
|
+
previousPaymentMethodId: string | null;
|
|
1738
|
+
previousPaymentMethodTypes: Array<string> | null;
|
|
1739
|
+
stripeSubscriptionId: string;
|
|
1740
|
+
};
|
|
1741
|
+
preparationOperationId?: string;
|
|
1742
|
+
providerApiVersion: string;
|
|
1743
|
+
scopeKey: string;
|
|
1744
|
+
startsPaused: boolean;
|
|
1745
|
+
verified: boolean;
|
|
1746
|
+
}
|
|
1747
|
+
| {
|
|
1748
|
+
reason: "scope_busy" | "identity_changed" | "revision_changed";
|
|
1749
|
+
retryable: false;
|
|
1750
|
+
status: "conflict";
|
|
1751
|
+
}
|
|
1752
|
+
| { reason: "invalid_scope"; retryable: false; status: "rejected" }
|
|
1753
|
+
| null,
|
|
1754
|
+
Name
|
|
1755
|
+
>;
|
|
1232
1756
|
};
|
|
1233
1757
|
};
|
|
1234
1758
|
billing: {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { FunctionHandle } from "convex/server";
|
|
2
|
+
import { internalAction } from "../../_generated/server.js";
|
|
3
|
+
import { internal } from "../../_generated/api.js";
|
|
4
|
+
import { phaseRefFields, type FundingPhaseRef } from "../workflowValidators.js";
|
|
5
|
+
import { providerResult, type ProviderResult } from "../workflowSchema.js";
|
|
6
|
+
import { normalizeReceipt } from "../receipt.js";
|
|
7
|
+
import { phaseKey, unknown } from "../workflowState.js";
|
|
8
|
+
export const bridge = internalAction({
|
|
9
|
+
args: phaseRefFields,
|
|
10
|
+
returns: providerResult,
|
|
11
|
+
handler: async (ctx, args): Promise<ProviderResult> => {
|
|
12
|
+
const { phase: _phase, providerKey: _key, ...base } = args;
|
|
13
|
+
const context = await ctx.runQuery(
|
|
14
|
+
internal.balanceFunding.internal.queries.readContext,
|
|
15
|
+
base,
|
|
16
|
+
);
|
|
17
|
+
if (phaseKey(context.operation, args.phase) !== args.providerKey)
|
|
18
|
+
return {
|
|
19
|
+
status: "conflict",
|
|
20
|
+
reason: "identity_changed",
|
|
21
|
+
retryable: false,
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
const result: unknown = await ctx.runAction(
|
|
25
|
+
context.operation.execution!.providerAction as FunctionHandle<
|
|
26
|
+
"action",
|
|
27
|
+
FundingPhaseRef,
|
|
28
|
+
unknown
|
|
29
|
+
>,
|
|
30
|
+
args,
|
|
31
|
+
);
|
|
32
|
+
if (
|
|
33
|
+
result &&
|
|
34
|
+
typeof result === "object" &&
|
|
35
|
+
"status" in result &&
|
|
36
|
+
result.status === "ready" &&
|
|
37
|
+
"value" in result
|
|
38
|
+
) {
|
|
39
|
+
const receipt = normalizeReceipt(result.value, args);
|
|
40
|
+
if (receipt) {
|
|
41
|
+
// Preserve positive evidence even if cancellation races this action.
|
|
42
|
+
// A failed receipt write is retried as its own workflow step.
|
|
43
|
+
try {
|
|
44
|
+
await ctx.runMutation(
|
|
45
|
+
internal.balanceFunding.internal.mutations.recordProviderReceipt,
|
|
46
|
+
{ ...args, receipt },
|
|
47
|
+
);
|
|
48
|
+
} catch {
|
|
49
|
+
/* journal the validated receipt below */
|
|
50
|
+
}
|
|
51
|
+
return { status: "ready", value: receipt };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (
|
|
55
|
+
result &&
|
|
56
|
+
typeof result === "object" &&
|
|
57
|
+
"status" in result &&
|
|
58
|
+
"reason" in result
|
|
59
|
+
) {
|
|
60
|
+
const current = await ctx.runQuery(
|
|
61
|
+
internal.balanceFunding.internal.queries.readContext,
|
|
62
|
+
base,
|
|
63
|
+
);
|
|
64
|
+
if (!current.operation.execution?.[args.phase]) {
|
|
65
|
+
if (
|
|
66
|
+
result.status === "conflict" &&
|
|
67
|
+
(result.reason === "scope_busy" ||
|
|
68
|
+
result.reason === "revision_changed" ||
|
|
69
|
+
result.reason === "identity_changed")
|
|
70
|
+
)
|
|
71
|
+
return {
|
|
72
|
+
status: "conflict",
|
|
73
|
+
reason: result.reason,
|
|
74
|
+
retryable: false,
|
|
75
|
+
};
|
|
76
|
+
if (
|
|
77
|
+
result.status === "rejected" &&
|
|
78
|
+
(result.reason === "policy_invalid" ||
|
|
79
|
+
result.reason === "unsupported_source" ||
|
|
80
|
+
result.reason === "invalid_scope")
|
|
81
|
+
)
|
|
82
|
+
return {
|
|
83
|
+
status: "rejected",
|
|
84
|
+
reason: result.reason,
|
|
85
|
+
retryable: false,
|
|
86
|
+
};
|
|
87
|
+
if (
|
|
88
|
+
result.status === "not_ready" &&
|
|
89
|
+
result.reason === "provider_pending"
|
|
90
|
+
)
|
|
91
|
+
return {
|
|
92
|
+
status: "not_ready",
|
|
93
|
+
reason: "provider_pending",
|
|
94
|
+
retryable: true,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} catch {
|
|
99
|
+
/* Raw host/provider errors must never enter durable history. */
|
|
100
|
+
}
|
|
101
|
+
await ctx.runMutation(
|
|
102
|
+
internal.balanceFunding.internal.mutations.markProviderUnknown,
|
|
103
|
+
args,
|
|
104
|
+
);
|
|
105
|
+
return unknown();
|
|
106
|
+
},
|
|
107
|
+
});
|