@mj-biz-apps/orders-core-entities-server 5.38.0 → 5.39.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 (173) hide show
  1. package/dist/AlertTaskAssignment.d.ts +76 -0
  2. package/dist/AlertTaskAssignment.d.ts.map +1 -0
  3. package/dist/AlertTaskAssignment.js +166 -0
  4. package/dist/AlertTaskAssignment.js.map +1 -0
  5. package/dist/BasePaymentProvider.d.ts +208 -0
  6. package/dist/BasePaymentProvider.d.ts.map +1 -1
  7. package/dist/BasePaymentProvider.js +56 -0
  8. package/dist/BasePaymentProvider.js.map +1 -1
  9. package/dist/CancelSubscriptionOperation.d.ts +28 -2
  10. package/dist/CancelSubscriptionOperation.d.ts.map +1 -1
  11. package/dist/CancelSubscriptionOperation.js +173 -18
  12. package/dist/CancelSubscriptionOperation.js.map +1 -1
  13. package/dist/CapturePaymentOperation.d.ts +7 -0
  14. package/dist/CapturePaymentOperation.d.ts.map +1 -1
  15. package/dist/CapturePaymentOperation.js +85 -6
  16. package/dist/CapturePaymentOperation.js.map +1 -1
  17. package/dist/CheckoutPrePurchaseCheck.d.ts +41 -4
  18. package/dist/CheckoutPrePurchaseCheck.d.ts.map +1 -1
  19. package/dist/CheckoutPrePurchaseCheck.js +109 -4
  20. package/dist/CheckoutPrePurchaseCheck.js.map +1 -1
  21. package/dist/CheckoutSavedInstrument.d.ts +5 -0
  22. package/dist/CheckoutSavedInstrument.d.ts.map +1 -1
  23. package/dist/CheckoutSavedInstrument.js +10 -3
  24. package/dist/CheckoutSavedInstrument.js.map +1 -1
  25. package/dist/CheckoutSessionService.d.ts +4 -0
  26. package/dist/CheckoutSessionService.d.ts.map +1 -1
  27. package/dist/CheckoutSessionService.js +46 -21
  28. package/dist/CheckoutSessionService.js.map +1 -1
  29. package/dist/ConcessionApprovalTask.d.ts +2 -0
  30. package/dist/ConcessionApprovalTask.d.ts.map +1 -1
  31. package/dist/ConcessionApprovalTask.js +6 -2
  32. package/dist/ConcessionApprovalTask.js.map +1 -1
  33. package/dist/ConcessionGate.d.ts +29 -10
  34. package/dist/ConcessionGate.d.ts.map +1 -1
  35. package/dist/ConcessionGate.js +65 -26
  36. package/dist/ConcessionGate.js.map +1 -1
  37. package/dist/EntitlementBehavior.d.ts +21 -38
  38. package/dist/EntitlementBehavior.d.ts.map +1 -1
  39. package/dist/EntitlementBehavior.js +28 -11
  40. package/dist/EntitlementBehavior.js.map +1 -1
  41. package/dist/EntitlementEngine.d.ts +37 -5
  42. package/dist/EntitlementEngine.d.ts.map +1 -1
  43. package/dist/EntitlementEngine.js +67 -9
  44. package/dist/EntitlementEngine.js.map +1 -1
  45. package/dist/EntitlementGrantEntityServer.d.ts +23 -2
  46. package/dist/EntitlementGrantEntityServer.d.ts.map +1 -1
  47. package/dist/EntitlementGrantEntityServer.js +40 -5
  48. package/dist/EntitlementGrantEntityServer.js.map +1 -1
  49. package/dist/EntitlementRead.d.ts.map +1 -1
  50. package/dist/EntitlementRead.js +12 -4
  51. package/dist/EntitlementRead.js.map +1 -1
  52. package/dist/GetExternalInvoicingWorklistOperation.d.ts.map +1 -1
  53. package/dist/GetExternalInvoicingWorklistOperation.js +8 -0
  54. package/dist/GetExternalInvoicingWorklistOperation.js.map +1 -1
  55. package/dist/GetFulfillmentQueueOperation.d.ts +1 -0
  56. package/dist/GetFulfillmentQueueOperation.d.ts.map +1 -1
  57. package/dist/GetFulfillmentQueueOperation.js +14 -0
  58. package/dist/GetFulfillmentQueueOperation.js.map +1 -1
  59. package/dist/InvoiceRailResolver.js +4 -0
  60. package/dist/InvoiceRailResolver.js.map +1 -1
  61. package/dist/IssueExternalInvoiceOperation.d.ts +6 -1
  62. package/dist/IssueExternalInvoiceOperation.d.ts.map +1 -1
  63. package/dist/IssueExternalInvoiceOperation.js +9 -1
  64. package/dist/IssueExternalInvoiceOperation.js.map +1 -1
  65. package/dist/OrderAdjustmentEntityServer.d.ts +39 -0
  66. package/dist/OrderAdjustmentEntityServer.d.ts.map +1 -0
  67. package/dist/OrderAdjustmentEntityServer.js +100 -0
  68. package/dist/OrderAdjustmentEntityServer.js.map +1 -0
  69. package/dist/OrderConcessionEntityServer.d.ts +8 -0
  70. package/dist/OrderConcessionEntityServer.d.ts.map +1 -1
  71. package/dist/OrderConcessionEntityServer.js +53 -2
  72. package/dist/OrderConcessionEntityServer.js.map +1 -1
  73. package/dist/OrderEntityServer.d.ts +10 -0
  74. package/dist/OrderEntityServer.d.ts.map +1 -1
  75. package/dist/OrderEntityServer.js +89 -14
  76. package/dist/OrderEntityServer.js.map +1 -1
  77. package/dist/OrderJournalEntryFactory.d.ts +9 -3
  78. package/dist/OrderJournalEntryFactory.d.ts.map +1 -1
  79. package/dist/OrderJournalEntryFactory.js +54 -13
  80. package/dist/OrderJournalEntryFactory.js.map +1 -1
  81. package/dist/OrdersSettings.d.ts +9 -0
  82. package/dist/OrdersSettings.d.ts.map +1 -1
  83. package/dist/OrdersSettings.js +12 -0
  84. package/dist/OrdersSettings.js.map +1 -1
  85. package/dist/OutboundEvents.d.ts +6 -1
  86. package/dist/OutboundEvents.d.ts.map +1 -1
  87. package/dist/OutboundEvents.js +30 -1
  88. package/dist/OutboundEvents.js.map +1 -1
  89. package/dist/PaymentProviderResolver.d.ts.map +1 -1
  90. package/dist/PaymentProviderResolver.js +4 -0
  91. package/dist/PaymentProviderResolver.js.map +1 -1
  92. package/dist/PaymentScheduleReplacement.d.ts +126 -0
  93. package/dist/PaymentScheduleReplacement.d.ts.map +1 -0
  94. package/dist/PaymentScheduleReplacement.js +236 -0
  95. package/dist/PaymentScheduleReplacement.js.map +1 -0
  96. package/dist/ProviderBilledSubscriptions.d.ts +79 -0
  97. package/dist/ProviderBilledSubscriptions.d.ts.map +1 -0
  98. package/dist/ProviderBilledSubscriptions.js +79 -0
  99. package/dist/ProviderBilledSubscriptions.js.map +1 -0
  100. package/dist/ProviderSubscriptionCancel.d.ts +139 -0
  101. package/dist/ProviderSubscriptionCancel.d.ts.map +1 -0
  102. package/dist/ProviderSubscriptionCancel.js +155 -0
  103. package/dist/ProviderSubscriptionCancel.js.map +1 -0
  104. package/dist/ProviderSubscriptions.d.ts +278 -0
  105. package/dist/ProviderSubscriptions.d.ts.map +1 -0
  106. package/dist/ProviderSubscriptions.js +982 -0
  107. package/dist/ProviderSubscriptions.js.map +1 -0
  108. package/dist/RenewalCharging.d.ts.map +1 -1
  109. package/dist/RenewalCharging.js +6 -0
  110. package/dist/RenewalCharging.js.map +1 -1
  111. package/dist/ReplacePaymentScheduleOperation.d.ts +59 -0
  112. package/dist/ReplacePaymentScheduleOperation.d.ts.map +1 -0
  113. package/dist/ReplacePaymentScheduleOperation.js +250 -0
  114. package/dist/ReplacePaymentScheduleOperation.js.map +1 -0
  115. package/dist/SpawnRenewalsOperation.d.ts +2 -1
  116. package/dist/SpawnRenewalsOperation.d.ts.map +1 -1
  117. package/dist/SpawnRenewalsOperation.js +6 -1
  118. package/dist/SpawnRenewalsOperation.js.map +1 -1
  119. package/dist/StripePaymentProvider.d.ts +130 -3
  120. package/dist/StripePaymentProvider.d.ts.map +1 -1
  121. package/dist/StripePaymentProvider.js +329 -6
  122. package/dist/StripePaymentProvider.js.map +1 -1
  123. package/dist/SubscriptionBehavior.d.ts +27 -10
  124. package/dist/SubscriptionBehavior.d.ts.map +1 -1
  125. package/dist/SubscriptionBehavior.js +41 -70
  126. package/dist/SubscriptionBehavior.js.map +1 -1
  127. package/dist/SubscriptionEntityServer.d.ts +37 -0
  128. package/dist/SubscriptionEntityServer.d.ts.map +1 -0
  129. package/dist/SubscriptionEntityServer.js +64 -0
  130. package/dist/SubscriptionEntityServer.js.map +1 -0
  131. package/dist/TermExtension.d.ts.map +1 -1
  132. package/dist/TermExtension.js +9 -2
  133. package/dist/TermExtension.js.map +1 -1
  134. package/dist/TermGrantWindow.d.ts +39 -0
  135. package/dist/TermGrantWindow.d.ts.map +1 -0
  136. package/dist/TermGrantWindow.js +55 -0
  137. package/dist/TermGrantWindow.js.map +1 -0
  138. package/dist/TermLengthExceptions.d.ts.map +1 -1
  139. package/dist/TermLengthExceptions.js +4 -3
  140. package/dist/TermLengthExceptions.js.map +1 -1
  141. package/dist/TermShift.d.ts +14 -0
  142. package/dist/TermShift.d.ts.map +1 -1
  143. package/dist/TermShift.js +29 -7
  144. package/dist/TermShift.js.map +1 -1
  145. package/dist/booking-errors.d.ts +45 -0
  146. package/dist/booking-errors.d.ts.map +1 -0
  147. package/dist/booking-errors.js +161 -0
  148. package/dist/booking-errors.js.map +1 -0
  149. package/dist/checkoutCaptureAlert.d.ts +71 -1
  150. package/dist/checkoutCaptureAlert.d.ts.map +1 -1
  151. package/dist/checkoutCaptureAlert.js +171 -12
  152. package/dist/checkoutCaptureAlert.js.map +1 -1
  153. package/dist/checkoutCaptureRetry.d.ts +3 -1
  154. package/dist/checkoutCaptureRetry.d.ts.map +1 -1
  155. package/dist/checkoutCaptureRetry.js +3 -1
  156. package/dist/checkoutCaptureRetry.js.map +1 -1
  157. package/dist/displaced-start-event.d.ts +1 -1
  158. package/dist/displaced-start-event.d.ts.map +1 -1
  159. package/dist/displaced-start-event.js +3 -1
  160. package/dist/displaced-start-event.js.map +1 -1
  161. package/dist/index.d.ts +18 -6
  162. package/dist/index.d.ts.map +1 -1
  163. package/dist/index.js +19 -4
  164. package/dist/index.js.map +1 -1
  165. package/dist/isolatedProvider.d.ts +24 -0
  166. package/dist/isolatedProvider.d.ts.map +1 -1
  167. package/dist/isolatedProvider.js +33 -0
  168. package/dist/isolatedProvider.js.map +1 -1
  169. package/dist/testing.d.ts +10 -0
  170. package/dist/testing.d.ts.map +1 -0
  171. package/dist/testing.js +12 -0
  172. package/dist/testing.js.map +1 -0
  173. package/package.json +13 -2
@@ -0,0 +1,76 @@
1
+ /**
2
+ * AlertTaskAssignment — every alert Task Orders raises is assigned to a person.
3
+ *
4
+ * Orders raises alert Tasks when something needs a person: a settled checkout payment it could not book
5
+ * onto its order, a settled payment with no order at all, an outbound delivery that was dead-lettered.
6
+ * The tasks app notifies a person only when a task is ASSIGNED to them. Raised unassigned, an alert was a
7
+ * row in a list nobody was told about.
8
+ *
9
+ * So each alert is assigned to the active holders of the role the `AlertTaskRole` setting names, through
10
+ * the same helpers approval tasks use (`ActiveRoleHolderIDs`, `EnsureTaskAssignment`): one role for every
11
+ * alert, the tasks app has no group assignee. Unset, alerts stay unassigned, as before.
12
+ *
13
+ * NEVER FAILS THE CALLER. An alert is raised because something already went wrong; an assignment that
14
+ * cannot be made is logged, and the Task stays raised. Each outbound dispatch pass then assigns the open
15
+ * alerts nobody holds (`AssignUnassignedAlertTasks`), so a first failure is retried, not final.
16
+ *
17
+ * Example: AIDP names the role "Sidecar Support"; Sess and Ethan hold it. A delivery to the Learning Hub
18
+ * that fails for 24 hours raises a Task assigned to both, and each sees it with an in-app notification.
19
+ */
20
+ import { type IMetadataProvider, type UserInfo } from '@memberjunction/core';
21
+ /** What happened, for the caller's log and tests. */
22
+ export type AlertTaskAssignmentOutcome = {
23
+ Assigned: number;
24
+ Unassignable?: number;
25
+ } | {
26
+ Skipped: 'NoRoleConfigured' | 'RoleNotFound' | 'NoActiveHolders';
27
+ } | {
28
+ Failed: string;
29
+ };
30
+ /**
31
+ * The start of every alert Task name Orders raises. The sweep below finds alerts by these, so a new alert
32
+ * kind names itself here and in its raiser (`checkoutCaptureAlert.ts`) from the same constant.
33
+ */
34
+ export declare const ORDERS_ALERT_TASK_PREFIX: {
35
+ readonly CheckoutCaptureNotBooked: "Checkout capture not booked: ";
36
+ readonly CheckoutSettledNoOrder: "Checkout payment settled with no order: ";
37
+ readonly OutboundDeliveryFailed: "Outbound delivery failed: ";
38
+ readonly GatewaySubscription: "Gateway subscription needs attention: ";
39
+ readonly GatewaySubscriptionUrgent: "URGENT: Gateway subscription needs attention: ";
40
+ };
41
+ /** Unassigned alerts assigned per sweep, at most: a backlog clears over a few passes, never in one long one. */
42
+ export declare const ALERT_SWEEP_BATCH = 25;
43
+ /** How often the sweep runs, in minutes. The dispatch job runs every minute; the sweep on every 15th. */
44
+ export declare const ALERT_SWEEP_EVERY_MINUTES = 15;
45
+ /**
46
+ * Whether a scheduled dispatch pass at `now` runs the sweep: on the quarter hours (UTC minute 0, 15, 30, 45),
47
+ * so 96 sweeps a day instead of 1,440, the same in every process with no shared counter. A pass that misses
48
+ * a quarter hour leaves the sweep to the next one.
49
+ */
50
+ export declare function AlertSweepDue(now: Date): boolean;
51
+ /**
52
+ * Assign an alert Task to the active holders of the `AlertTaskRole` role. Idempotent: a holder already
53
+ * assigned is not assigned twice. Never throws.
54
+ */
55
+ export declare function AssignAlertTask(taskID: string, provider: IMetadataProvider, user: UserInfo): Promise<AlertTaskAssignmentOutcome>;
56
+ /**
57
+ * Assign the open Orders alert Tasks that nobody holds yet: one whose assignment failed when it was
58
+ * raised (a transient error, a role named before it existed), or raised before `AlertTaskRole` was set.
59
+ * A dead-letter alert is raised once, when its delivery is dead-lettered, so without this sweep a first
60
+ * failure would leave it unassigned for good.
61
+ *
62
+ * Runs on the scheduled dispatch pass every `ALERT_SWEEP_EVERY_MINUTES` (`AlertSweepDue`). With no role
63
+ * configured it reads nothing; otherwise one query for at most `ALERT_SWEEP_BATCH` open Tasks with no
64
+ * assignment at all, then the same idempotent assignment a new alert gets. A role that cannot be resolved is
65
+ * logged once per sweep, not once per Task. A Task that cannot be assigned is logged and skipped, so it never
66
+ * holds up the others. Never throws.
67
+ *
68
+ * A Task a person deliberately unassigns (removes every assignment from) while it is still Open is assigned
69
+ * again by the next sweep: an open alert must reach someone. To retire one, close it; the sweep only takes
70
+ * `Status = 'Open'`.
71
+ *
72
+ * Example: Ethan names "Sidecar Support" a day after two deliveries dead-lettered. On the next pass, both
73
+ * Tasks are assigned to Sess and Ethan.
74
+ */
75
+ export declare function AssignUnassignedAlertTasks(provider: IMetadataProvider, user: UserInfo): Promise<AlertTaskAssignmentOutcome>;
76
+ //# sourceMappingURL=AlertTaskAssignment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlertTaskAssignment.d.ts","sourceRoot":"","sources":["../src/AlertTaskAssignment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAqB,KAAK,iBAAiB,EAAyB,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQvH,qDAAqD;AACrD,MAAM,MAAM,0BAA0B,GAChC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,OAAO,EAAE,kBAAkB,GAAG,cAAc,GAAG,iBAAiB,CAAA;CAAE,GACpE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzB;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;CAO3B,CAAC;AAEX,gHAAgH;AAChH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,yGAAyG;AACzG,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAEhD;AAkCD;;;GAGG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAetI;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,0BAA0B,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA+CjI"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * AlertTaskAssignment — every alert Task Orders raises is assigned to a person.
3
+ *
4
+ * Orders raises alert Tasks when something needs a person: a settled checkout payment it could not book
5
+ * onto its order, a settled payment with no order at all, an outbound delivery that was dead-lettered.
6
+ * The tasks app notifies a person only when a task is ASSIGNED to them. Raised unassigned, an alert was a
7
+ * row in a list nobody was told about.
8
+ *
9
+ * So each alert is assigned to the active holders of the role the `AlertTaskRole` setting names, through
10
+ * the same helpers approval tasks use (`ActiveRoleHolderIDs`, `EnsureTaskAssignment`): one role for every
11
+ * alert, the tasks app has no group assignee. Unset, alerts stay unassigned, as before.
12
+ *
13
+ * NEVER FAILS THE CALLER. An alert is raised because something already went wrong; an assignment that
14
+ * cannot be made is logged, and the Task stays raised. Each outbound dispatch pass then assigns the open
15
+ * alerts nobody holds (`AssignUnassignedAlertTasks`), so a first failure is retried, not final.
16
+ *
17
+ * Example: AIDP names the role "Sidecar Support"; Sess and Ethan hold it. A delivery to the Learning Hub
18
+ * that fails for 24 hours raises a Task assigned to both, and each sees it with an in-app notification.
19
+ */
20
+ import { LogError, RunView } from '@memberjunction/core';
21
+ import { ActiveRoleHolderIDs, EnsureTaskAssignment } from './ConcessionApprovalTask.js';
22
+ import { OrdersSettings } from './OrdersSettings.js';
23
+ import { EscapeText } from './sql-guards.js';
24
+ const ROLE_ENTITY = 'MJ: Roles';
25
+ const USER_ENTITY = 'MJ: Users';
26
+ /**
27
+ * The start of every alert Task name Orders raises. The sweep below finds alerts by these, so a new alert
28
+ * kind names itself here and in its raiser (`checkoutCaptureAlert.ts`) from the same constant.
29
+ */
30
+ export const ORDERS_ALERT_TASK_PREFIX = {
31
+ CheckoutCaptureNotBooked: 'Checkout capture not booked: ',
32
+ CheckoutSettledNoOrder: 'Checkout payment settled with no order: ',
33
+ OutboundDeliveryFailed: 'Outbound delivery failed: ',
34
+ // A gateway subscription Orders could not create, record or cancel (#972), and its urgent form.
35
+ GatewaySubscription: 'Gateway subscription needs attention: ',
36
+ GatewaySubscriptionUrgent: 'URGENT: Gateway subscription needs attention: ',
37
+ };
38
+ /** Unassigned alerts assigned per sweep, at most: a backlog clears over a few passes, never in one long one. */
39
+ export const ALERT_SWEEP_BATCH = 25;
40
+ /** How often the sweep runs, in minutes. The dispatch job runs every minute; the sweep on every 15th. */
41
+ export const ALERT_SWEEP_EVERY_MINUTES = 15;
42
+ /**
43
+ * Whether a scheduled dispatch pass at `now` runs the sweep: on the quarter hours (UTC minute 0, 15, 30, 45),
44
+ * so 96 sweeps a day instead of 1,440, the same in every process with no shared counter. A pass that misses
45
+ * a quarter hour leaves the sweep to the next one.
46
+ */
47
+ export function AlertSweepDue(now) {
48
+ return now.getUTCMinutes() % ALERT_SWEEP_EVERY_MINUTES === 0;
49
+ }
50
+ const TASK_ENTITY = 'MJ_BizApps_Tasks: Tasks';
51
+ /** The users every alert is assigned to, read once per call. */
52
+ async function alertAssignees(provider, user) {
53
+ await OrdersSettings.Load(provider, user);
54
+ const roleName = OrdersSettings.AlertTaskRole;
55
+ if (!roleName)
56
+ return { Skipped: 'NoRoleConfigured', RoleName: null };
57
+ const rv = new RunView(provider);
58
+ const roles = await rv.RunView({ EntityName: ROLE_ENTITY, ExtraFilter: `Name = '${EscapeText(roleName)}'`, Fields: ['ID'], ResultType: 'simple', MaxRows: 1 }, user);
59
+ const roleID = roles.Success ? roles.Results?.[0]?.ID : undefined;
60
+ if (!roleID)
61
+ return { Skipped: 'RoleNotFound', RoleName: roleName };
62
+ const holders = await ActiveRoleHolderIDs(roleID, { Provider: provider, User: user });
63
+ if (holders.length === 0)
64
+ return { Skipped: 'NoActiveHolders', RoleName: roleName };
65
+ const userEntity = provider.EntityByName(USER_ENTITY);
66
+ if (!userEntity)
67
+ throw new Error(`Entity '${USER_ENTITY}' is not in metadata.`);
68
+ return { RoleName: roleName, UserEntityID: userEntity.ID, Holders: holders };
69
+ }
70
+ function skipReason(taskID, a) {
71
+ return a.Skipped === 'RoleNotFound'
72
+ ? `[BizAppsOrders] Alert Task ${taskID}: the alert role '${a.RoleName}' (Orders setting AlertTaskRole) does not exist, so nobody was assigned.`
73
+ : `[BizAppsOrders] Alert Task ${taskID}: the alert role '${a.RoleName}' has no active holder, so nobody was assigned.`;
74
+ }
75
+ /**
76
+ * Assign an alert Task to the active holders of the `AlertTaskRole` role. Idempotent: a holder already
77
+ * assigned is not assigned twice. Never throws.
78
+ */
79
+ export async function AssignAlertTask(taskID, provider, user) {
80
+ try {
81
+ const a = await alertAssignees(provider, user);
82
+ if ('Skipped' in a) {
83
+ if (a.Skipped !== 'NoRoleConfigured')
84
+ LogError(skipReason(taskID, a));
85
+ return { Skipped: a.Skipped };
86
+ }
87
+ const ctx = { Provider: provider, User: user };
88
+ for (const holder of a.Holders)
89
+ await EnsureTaskAssignment(taskID, a.UserEntityID, holder, ctx);
90
+ return { Assigned: a.Holders.length };
91
+ }
92
+ catch (err) {
93
+ const reason = err instanceof Error ? err.message : String(err);
94
+ LogError(`[BizAppsOrders] Alert Task ${taskID} could not be assigned: ${reason}`);
95
+ return { Failed: reason };
96
+ }
97
+ }
98
+ /**
99
+ * Assign the open Orders alert Tasks that nobody holds yet: one whose assignment failed when it was
100
+ * raised (a transient error, a role named before it existed), or raised before `AlertTaskRole` was set.
101
+ * A dead-letter alert is raised once, when its delivery is dead-lettered, so without this sweep a first
102
+ * failure would leave it unassigned for good.
103
+ *
104
+ * Runs on the scheduled dispatch pass every `ALERT_SWEEP_EVERY_MINUTES` (`AlertSweepDue`). With no role
105
+ * configured it reads nothing; otherwise one query for at most `ALERT_SWEEP_BATCH` open Tasks with no
106
+ * assignment at all, then the same idempotent assignment a new alert gets. A role that cannot be resolved is
107
+ * logged once per sweep, not once per Task. A Task that cannot be assigned is logged and skipped, so it never
108
+ * holds up the others. Never throws.
109
+ *
110
+ * A Task a person deliberately unassigns (removes every assignment from) while it is still Open is assigned
111
+ * again by the next sweep: an open alert must reach someone. To retire one, close it; the sweep only takes
112
+ * `Status = 'Open'`.
113
+ *
114
+ * Example: Ethan names "Sidecar Support" a day after two deliveries dead-lettered. On the next pass, both
115
+ * Tasks are assigned to Sess and Ethan.
116
+ */
117
+ export async function AssignUnassignedAlertTasks(provider, user) {
118
+ try {
119
+ const a = await alertAssignees(provider, user);
120
+ if ('Skipped' in a) {
121
+ if (a.Skipped !== 'NoRoleConfigured')
122
+ LogError(skipReason('sweep', a));
123
+ return { Skipped: a.Skipped };
124
+ }
125
+ const prefixes = Object.values(ORDERS_ALERT_TASK_PREFIX)
126
+ .map((p) => `Name LIKE '${EscapeText(p).replace(/[[%_]/g, '[$&]')}%'`)
127
+ .join(' OR ');
128
+ const rv = new RunView(provider);
129
+ const open = await rv.RunView({
130
+ EntityName: TASK_ENTITY,
131
+ ExtraFilter: `Status = 'Open' AND (${prefixes}) AND ID NOT IN ` +
132
+ `(SELECT ta.TaskID FROM __mj_BizAppsTasks.TaskAssignment ta WHERE ta.TaskID IS NOT NULL)`,
133
+ Fields: ['ID'],
134
+ // Newest first: Tasks that can never be assigned (they are logged and skipped) collect at the old
135
+ // end, so they cannot fill every batch and starve the alerts raised since.
136
+ OrderBy: '__mj_CreatedAt DESC',
137
+ MaxRows: ALERT_SWEEP_BATCH,
138
+ ResultType: 'simple',
139
+ BypassCache: true,
140
+ }, user);
141
+ if (!open.Success)
142
+ throw new Error(open.ErrorMessage ?? 'the unassigned alert Tasks could not be read');
143
+ const ctx = { Provider: provider, User: user };
144
+ let assigned = 0;
145
+ let unassignable = 0;
146
+ for (const task of open.Results ?? []) {
147
+ try {
148
+ for (const holder of a.Holders)
149
+ await EnsureTaskAssignment(task.ID, a.UserEntityID, holder, ctx);
150
+ assigned++;
151
+ }
152
+ catch (err) {
153
+ // One Task that cannot be assigned must not hold up the rest.
154
+ unassignable++;
155
+ LogError(`[BizAppsOrders] Alert Task ${task.ID} could not be assigned: ${err instanceof Error ? err.message : String(err)}`);
156
+ }
157
+ }
158
+ return unassignable ? { Assigned: assigned, Unassignable: unassignable } : { Assigned: assigned };
159
+ }
160
+ catch (err) {
161
+ const reason = err instanceof Error ? err.message : String(err);
162
+ LogError(`[BizAppsOrders] Unassigned alert Tasks could not be assigned: ${reason}`);
163
+ return { Failed: reason };
164
+ }
165
+ }
166
+ //# sourceMappingURL=AlertTaskAssignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AlertTaskAssignment.js","sourceRoot":"","sources":["../src/AlertTaskAssign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IAAI,CAAC,CAAC,OAAO;oBAAE,MAAM,oBAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;gBACjG,QAAQ,EAAE,CAAC;YACf,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACX,8DAA8D;gBAC9D,YAAY,EAAE,CAAC;gBACf,QAAQ,CAAC,8BAA8B,IAAI,CAAC,EAAE,2BAA2B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACjI,CAAC;QACL,CAAC;QACD,OAAO,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACtG,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChE,QAAQ,CAAC,iEAAiE,MAAM,EAAE,CAAC,CAAC;QACpF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC9B,CAAC;AACL,CAAC"}
@@ -45,10 +45,23 @@ export interface PaymentProviderConfig {
45
45
  */
46
46
  CredentialsRef: string | null;
47
47
  IsLiveMode: boolean;
48
+ /**
49
+ * `PaymentProvider.BillsSubscriptions`: this account bills the auto-renewing subscriptions sold
50
+ * through it, so Orders creates a gateway subscription after the first payment. Honoured only
51
+ * when the type's `Capabilities.SupportsSubscriptionBilling` is also set; see
52
+ * `ProviderBillsNewSubscriptions` in ./ProviderSubscriptions.ts, the one place the two are combined.
53
+ * Never consulted by the renewal jobs, which key on the subscription's own marker.
54
+ */
55
+ BillsSubscriptions: boolean;
48
56
  Capabilities: {
49
57
  SupportsTokenization: boolean;
50
58
  SupportsRefund: boolean;
51
59
  SupportsWebhooks: boolean;
60
+ /**
61
+ * `PaymentProviderType.SupportsSubscriptionBilling`: the gateway can bill a subscription itself
62
+ * (charge the card each period, send its own receipts).
63
+ */
64
+ SupportsSubscriptionBilling: boolean;
52
65
  };
53
66
  }
54
67
  /** Resolved secrets. Held only for the duration of a call and never persisted. */
@@ -352,6 +365,157 @@ export interface WebhookEvent {
352
365
  */
353
366
  OccurredAt?: Date;
354
367
  }
368
+ /**
369
+ * Ask the gateway to bill a subscription itself from a later day on (option E, E2): Orders took the
370
+ * first payment, and the gateway charges every renewal on the saved instrument.
371
+ *
372
+ * Example: Jane paid year 1 ($599) on the checkout on 31 Oct 2026, her card is `pm_…` on customer
373
+ * `cus_…`, and her term ends 30 Oct 2027. Orders asks for a subscription on `price_…` whose first
374
+ * charge is 00:00 business time on 30 Oct 2027; nothing is charged at creation.
375
+ */
376
+ export interface CreateProviderSubscriptionRequest {
377
+ /** The gateway customer the instrument belongs to (`PaymentDetail.ProviderCustomerRef`). */
378
+ ProviderCustomerRef: string;
379
+ /** The saved instrument every renewal is charged to (`PaymentDetail.ProviderInstrumentRef`). */
380
+ ProviderInstrumentRef: string;
381
+ /** The gateway's price (`PaymentProviderPrice.ProviderPriceID` flagged `UseForNewSubscriptions`). */
382
+ ProviderPriceID: string;
383
+ /** Units, from the term. A whole number of at least 1. */
384
+ Quantity: number;
385
+ /**
386
+ * When the gateway first charges. The time before it is not billed at all: the customer paid it
387
+ * through Orders. Must be in the future and no later than `LatestFirstChargeAt` allows.
388
+ */
389
+ FirstChargeAt: Date;
390
+ /** OUR idempotency key, so a retried create does not open a second gateway subscription. */
391
+ IdempotencyKey: string;
392
+ /** Stored on the gateway's subscription, so it can be found again from Orders' ids. */
393
+ Metadata?: Record<string, string>;
394
+ }
395
+ export interface CreateProviderSubscriptionResult {
396
+ Success: boolean;
397
+ Reason?: string;
398
+ /** The gateway's id (Stripe `sub_…`), written to `Subscription.ProviderSubscriptionID`. */
399
+ ProviderSubscriptionID?: string;
400
+ /** The gateway's own status word, for the log and the alert. */
401
+ Status?: string;
402
+ /** The first charge as the gateway recorded it. */
403
+ FirstChargeAt?: Date;
404
+ /**
405
+ * True when the gateway billed something at creation or did not start the subscription cleanly.
406
+ * Must never happen: the customer already paid this period through Orders, so it is a double
407
+ * charge, and the caller raises it as urgent.
408
+ */
409
+ ChargedAtCreation?: boolean;
410
+ /**
411
+ * Set on a refusal that only means another request with the same idempotency key is still being
412
+ * processed. That request gets the subscription and its caller records it, so this is not a
413
+ * problem for a person.
414
+ */
415
+ InFlightElsewhere?: boolean;
416
+ }
417
+ /** Find the gateway subscriptions on a customer that carry one metadata value. */
418
+ export interface FindProviderSubscriptionsRequest {
419
+ ProviderCustomerRef: string;
420
+ MetadataKey: string;
421
+ MetadataValue: string;
422
+ }
423
+ /** A subscription the gateway holds, as `FindProviderSubscriptions` reports it. */
424
+ export interface GatewaySubscription {
425
+ ProviderSubscriptionID: string;
426
+ /** The gateway's own status word. */
427
+ Status: string;
428
+ /** False once the gateway will never bill it again (Stripe: `canceled`, `incomplete_expired`). */
429
+ IsLive: boolean;
430
+ Metadata: Record<string, string>;
431
+ /** The price it bills (its first item), when the gateway reports one. */
432
+ ProviderPriceID?: string;
433
+ /** The quantity of that item. */
434
+ Quantity?: number;
435
+ /** When it first charges, or charged (Stripe: `billing_cycle_anchor`). */
436
+ FirstChargeAt?: Date;
437
+ }
438
+ /**
439
+ * Stop the gateway billing a subscription Orders has cancelled (E2b).
440
+ *
441
+ * `BillingEndsAt` is the instant after which the gateway must charge nothing: null for now. The
442
+ * driver decides how: end it now, at its period end, or at that instant, whichever stops every
443
+ * charge after `BillingEndsAt` without one before it that Orders has not sold.
444
+ *
445
+ * Example: Sess cancels Jane's SUB-000110 at the end of term 1 (ends 30 Oct 2027). Orders asks the
446
+ * gateway to bill nothing after 00:00 Central on 31 Oct 2027; Stripe's period ends at 00:00 Central on
447
+ * 30 Oct 2027, so it is told not to renew at period end, and the $599 renewal never happens.
448
+ */
449
+ export interface CancelProviderSubscriptionRequest {
450
+ /** The gateway's id (`Subscription.ProviderSubscriptionID`). */
451
+ ProviderSubscriptionID: string;
452
+ /** The gateway must charge nothing after this instant; null ends the subscription now. */
453
+ BillingEndsAt: Date | null;
454
+ /** OUR idempotency key, so a retried request is answered, not repeated. */
455
+ IdempotencyKey: string;
456
+ }
457
+ /** What the gateway did. Each `Success: true` outcome means it will charge nothing after `BillingEndsAt`. */
458
+ export type CancelProviderSubscriptionOutcome =
459
+ /** Ended now. */
460
+ 'CanceledNow'
461
+ /** Set to end at its current period end instead of renewing. */
462
+ | 'EndsAtPeriodEnd'
463
+ /** Set to end at an instant inside its current period. */
464
+ | 'EndsAt'
465
+ /** It had already ended (a retry, or someone cancelled it at the gateway). */
466
+ | 'AlreadyEnded'
467
+ /** It was already set to end no later than asked. */
468
+ | 'AlreadyEnding';
469
+ export interface CancelProviderSubscriptionResult {
470
+ Success: boolean;
471
+ Reason?: string;
472
+ Outcome?: CancelProviderSubscriptionOutcome;
473
+ /** When the gateway's billing actually ends: now, its period end or the instant set. */
474
+ BillingEndsAt?: Date;
475
+ /** The gateway's own status word after the call. */
476
+ Status?: string;
477
+ }
478
+ /**
479
+ * Where a gateway subscription's billing stands, read without changing it.
480
+ * · `Ended`: it charges nothing more.
481
+ * · `Ending`: it is set to end (`EndsAt`) and charges nothing more before then.
482
+ * · `Renewing`: it charges again at `CurrentPeriodEnd`.
483
+ * · `Collecting`: it is trying to collect a charge it has not been paid (Stripe: `past_due`, `unpaid`,
484
+ * `incomplete`, `paused`).
485
+ */
486
+ export type ProviderSubscriptionBillingState = 'Ended' | 'Ending' | 'Renewing' | 'Collecting';
487
+ export interface DescribeProviderSubscriptionResult {
488
+ Success: boolean;
489
+ Reason?: string;
490
+ State?: ProviderSubscriptionBillingState;
491
+ /** Start of the period the gateway last billed (or tried to): its latest charge, or its creation before the first one. */
492
+ CurrentPeriodStart?: Date | null;
493
+ /** End of that period: when it charges next, unless it is set to end. */
494
+ CurrentPeriodEnd?: Date | null;
495
+ /** When it ends, for `Ending`. */
496
+ EndsAt?: Date | null;
497
+ /** The gateway's own status word. */
498
+ Status?: string;
499
+ }
500
+ /** How often a gateway price bills. */
501
+ export interface GatewayPriceInterval {
502
+ Unit: 'day' | 'week' | 'month' | 'year';
503
+ /** Units per billing period: `{ Unit: 'month', Count: 3 }` is quarterly. */
504
+ Count: number;
505
+ }
506
+ export interface DescribeProviderPriceResult {
507
+ Success: boolean;
508
+ Reason?: string;
509
+ /** False when the gateway would refuse to start a new subscription on it. */
510
+ Active?: boolean;
511
+ /** How often it bills; null for a one-time price. */
512
+ Interval?: GatewayPriceInterval | null;
513
+ }
514
+ export interface FindProviderSubscriptionsResult {
515
+ Success: boolean;
516
+ Reason?: string;
517
+ Subscriptions?: GatewaySubscription[];
518
+ }
355
519
  /**
356
520
  * The driver contract.
357
521
  *
@@ -454,6 +618,50 @@ export declare class BasePaymentProvider {
454
618
  * for later must say so, not hand back an id nothing will accept.
455
619
  */
456
620
  EnsureCustomer(_request: EnsureCustomerRequest): Promise<EnsureCustomerResult>;
621
+ /**
622
+ * Have the gateway bill a subscription from `FirstChargeAt` on (option E, E2).
623
+ *
624
+ * Refuses by default. Orders calls it only for an account whose type supports subscription
625
+ * billing and whose `BillsSubscriptions` switch is on, and a driver that has not implemented it
626
+ * must say so rather than return an id: an id marks the Orders subscription as gateway-billed, and
627
+ * Orders then stops renewing it.
628
+ */
629
+ CreateProviderSubscription(_request: CreateProviderSubscriptionRequest): Promise<CreateProviderSubscriptionResult>;
630
+ /**
631
+ * The gateway subscriptions on a customer that carry a metadata value. Read-only. Used before a
632
+ * retried create, because a gateway forgets idempotency keys (Stripe after about 24 hours) and a
633
+ * second create would otherwise open a second subscription.
634
+ */
635
+ FindProviderSubscriptions(_request: FindProviderSubscriptionsRequest): Promise<FindProviderSubscriptionsResult>;
636
+ /**
637
+ * Stop the gateway billing a subscription after `BillingEndsAt` (E2b). Called by
638
+ * `Orders.CancelSubscription` BEFORE it writes anything, so a gateway that does not confirm leaves
639
+ * Orders unchanged rather than cancelled while the gateway still bills.
640
+ *
641
+ * Refuses by default: a driver that cannot cancel must say so, never report success.
642
+ */
643
+ CancelProviderSubscription(_request: CancelProviderSubscriptionRequest): Promise<CancelProviderSubscriptionResult>;
644
+ /**
645
+ * Where one gateway subscription's billing stands. Read-only. `Orders.CancelSubscription` reads it
646
+ * before deciding anything, because the gateway, not Orders, knows whether it has already charged a
647
+ * period Orders has not booked, or has already stopped.
648
+ *
649
+ * Refuses by default: a driver that cannot read the gateway must not let Orders guess.
650
+ */
651
+ DescribeProviderSubscription(_providerSubscriptionID: string): Promise<DescribeProviderSubscriptionResult>;
652
+ /**
653
+ * How often a gateway price bills. Read-only. Orders reads it before creating a subscription on the
654
+ * price, and refuses visibly when the price's period is not the Orders term's: a yearly price on a
655
+ * monthly product would otherwise be billed on the wrong cadence without a word.
656
+ */
657
+ DescribeProviderPrice(_providerPriceID: string): Promise<DescribeProviderPriceResult>;
658
+ /**
659
+ * The latest first charge the gateway accepts for a subscription created at `createdAt` on a price
660
+ * that bills every `interval`, or null when the driver knows no limit. Stripe refuses a first
661
+ * charge past the price's next natural billing date (one period from creation); the caller defers
662
+ * creating the subscription until the charge day fits. Without `interval`, a yearly price.
663
+ */
664
+ LatestFirstChargeAt(_createdAt: Date, _interval?: GatewayPriceInterval | null): Date | null;
457
665
  /**
458
666
  * Verify that a webhook really came from the gateway.
459
667
  *
@@ -1 +1 @@
1
- {"version":3,"file":"BasePaymentProvider.d.ts","sourceRoot":"","sources":["../src/BasePaymentProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,iFA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AAC,gCAAgC,CAAC;IAI/H;;;;OAIG;IACU,yBAAyB,CAAC,QAAQ,EAAE,gCAAgC,GAAG,OAAO,CAAC,+BAA+B,CAAC;IAI5H;;;;;;OAMG;IACU,0BAA0B,CAAC,QAAQ,EAAE,iCAAiC,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAI/H;;;;;;OAMG;IACU,4BAA4B,CAAC,uBAAuB,EAAE,MAAM,GAAG,OAAO,CAAC,kCAAkC,CAAC;IAIvH;;;;OAIG;IACU,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAIlG;;;;;OAKG;IACI,mBAAmB,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,oBAAoB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;IAIlG;;;;;;;OAOG;IACU,aAAa,CACtB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC7C,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAI/C,kGAAkG;IAC3F,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAI/D,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAQjD;AAED,0FAA0F;AAC1F,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
@@ -121,6 +121,62 @@ export class BasePaymentProvider {
121
121
  async EnsureCustomer(_request) {
122
122
  return { Success: false, Reason: this.notImplemented('keeping a customer for saved instruments') };
123
123
  }
124
+ /**
125
+ * Have the gateway bill a subscription from `FirstChargeAt` on (option E, E2).
126
+ *
127
+ * Refuses by default. Orders calls it only for an account whose type supports subscription
128
+ * billing and whose `BillsSubscriptions` switch is on, and a driver that has not implemented it
129
+ * must say so rather than return an id: an id marks the Orders subscription as gateway-billed, and
130
+ * Orders then stops renewing it.
131
+ */
132
+ async CreateProviderSubscription(_request) {
133
+ return { Success: false, Reason: this.notImplemented('creating a gateway-billed subscription') };
134
+ }
135
+ /**
136
+ * The gateway subscriptions on a customer that carry a metadata value. Read-only. Used before a
137
+ * retried create, because a gateway forgets idempotency keys (Stripe after about 24 hours) and a
138
+ * second create would otherwise open a second subscription.
139
+ */
140
+ async FindProviderSubscriptions(_request) {
141
+ return { Success: false, Reason: this.notImplemented('finding gateway-billed subscriptions') };
142
+ }
143
+ /**
144
+ * Stop the gateway billing a subscription after `BillingEndsAt` (E2b). Called by
145
+ * `Orders.CancelSubscription` BEFORE it writes anything, so a gateway that does not confirm leaves
146
+ * Orders unchanged rather than cancelled while the gateway still bills.
147
+ *
148
+ * Refuses by default: a driver that cannot cancel must say so, never report success.
149
+ */
150
+ async CancelProviderSubscription(_request) {
151
+ return { Success: false, Reason: this.notImplemented('cancelling a gateway-billed subscription') };
152
+ }
153
+ /**
154
+ * Where one gateway subscription's billing stands. Read-only. `Orders.CancelSubscription` reads it
155
+ * before deciding anything, because the gateway, not Orders, knows whether it has already charged a
156
+ * period Orders has not booked, or has already stopped.
157
+ *
158
+ * Refuses by default: a driver that cannot read the gateway must not let Orders guess.
159
+ */
160
+ async DescribeProviderSubscription(_providerSubscriptionID) {
161
+ return { Success: false, Reason: this.notImplemented('reading a gateway-billed subscription') };
162
+ }
163
+ /**
164
+ * How often a gateway price bills. Read-only. Orders reads it before creating a subscription on the
165
+ * price, and refuses visibly when the price's period is not the Orders term's: a yearly price on a
166
+ * monthly product would otherwise be billed on the wrong cadence without a word.
167
+ */
168
+ async DescribeProviderPrice(_providerPriceID) {
169
+ return { Success: false, Reason: this.notImplemented('reading a gateway price') };
170
+ }
171
+ /**
172
+ * The latest first charge the gateway accepts for a subscription created at `createdAt` on a price
173
+ * that bills every `interval`, or null when the driver knows no limit. Stripe refuses a first
174
+ * charge past the price's next natural billing date (one period from creation); the caller defers
175
+ * creating the subscription until the charge day fits. Without `interval`, a yearly price.
176
+ */
177
+ LatestFirstChargeAt(_createdAt, _interval) {
178
+ return null;
179
+ }
124
180
  /**
125
181
  * Verify that a webhook really came from the gateway.
126
182
  *
@@ -1 +1 @@
1
- {"version":3,"file":"BasePaymentProvider.js","sourceRoot":"","sources":["../src/BasePaymentProvider.ts"],"names":[],"mappings":"AAgYA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,mBAAmB;IAW5B,gGAAgG;IAChG,IAAW,iBAAiB;QACxB,OAAO,EAAE,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,IAAW,qBAAqB;QAC5B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,iBAAiB;QACxB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,QAA6B;QACnD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,2BAA2B,CAAC,EAAE,CAAC;IACxF,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAwB;QACzC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,EAAE,CAAC;IAClF,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,cAAc,CAAC,QAA+B;QACvD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,6BAA6B,CAAC,EAAE,CAAC;IAC1F,CAAC;IAED,gGAAgG;IACzF,KAAK,CAAC,YAAY,CAAC,QAA6B;QACnD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,2BAA2B,CAAC,EAAE,CAAC;IACxF,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,QAAuB;QACvC,OAAO,EAAE,OAAO,EAAE,KAAK,EA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