@fantastic.dev/better-stripe 0.97.1 → 0.99.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 (111) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts +11 -0
  4. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js +39 -1
  6. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/c10/attachEvents.d.ts +22 -0
  8. package/dist/client/billing/renewalAttach/internal/c10/attachEvents.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAttach/internal/c10/attachEvents.js +13 -5
  10. package/dist/client/billing/renewalAttach/internal/c10/attachEvents.js.map +1 -1
  11. package/dist/client/billing/renewalAttach/internal/operations/actorFailureControl.d.ts +17 -0
  12. package/dist/client/billing/renewalAttach/internal/operations/actorFailureControl.d.ts.map +1 -0
  13. package/dist/client/billing/renewalAttach/internal/operations/actorFailureControl.js +140 -0
  14. package/dist/client/billing/renewalAttach/internal/operations/actorFailureControl.js.map +1 -0
  15. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +61 -9
  16. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -1
  17. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +41 -411
  18. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -1
  19. package/dist/client/billing/renewalAttach/internal/operations/initialActorData.d.ts +21 -0
  20. package/dist/client/billing/renewalAttach/internal/operations/initialActorData.d.ts.map +1 -0
  21. package/dist/client/billing/renewalAttach/internal/operations/initialActorData.js +36 -0
  22. package/dist/client/billing/renewalAttach/internal/operations/initialActorData.js.map +1 -0
  23. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +141 -0
  24. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -1
  25. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +132 -182
  26. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -1
  27. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +1 -0
  28. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -1
  29. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +17 -5
  30. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -1
  31. package/dist/client/billing/renewalAttach/internal/operations/transportCapture.d.ts +35 -0
  32. package/dist/client/billing/renewalAttach/internal/operations/transportCapture.d.ts.map +1 -0
  33. package/dist/client/billing/renewalAttach/internal/operations/transportCapture.js +46 -0
  34. package/dist/client/billing/renewalAttach/internal/operations/transportCapture.js.map +1 -0
  35. package/dist/client/billing/renewalAttach/internal/operations/transportKernel.d.ts +63 -0
  36. package/dist/client/billing/renewalAttach/internal/operations/transportKernel.d.ts.map +1 -0
  37. package/dist/client/billing/renewalAttach/internal/operations/transportKernel.js +380 -0
  38. package/dist/client/billing/renewalAttach/internal/operations/transportKernel.js.map +1 -0
  39. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +8 -0
  40. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -1
  41. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +25 -0
  42. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -1
  43. package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.d.ts +56 -0
  44. package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.d.ts.map +1 -0
  45. package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.js +49 -0
  46. package/dist/client/billing/renewalAttach/internal/producer/journalWorkFactory.js.map +1 -0
  47. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts +1 -0
  48. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts.map +1 -1
  49. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js +3 -0
  50. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js.map +1 -1
  51. package/dist/client/billing/renewalAttach/internal/producer/operationFactory.d.ts +65 -0
  52. package/dist/client/billing/renewalAttach/internal/producer/operationFactory.d.ts.map +1 -0
  53. package/dist/client/billing/renewalAttach/internal/producer/operationFactory.js +162 -0
  54. package/dist/client/billing/renewalAttach/internal/producer/operationFactory.js.map +1 -0
  55. package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.d.ts +4 -0
  56. package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.d.ts.map +1 -0
  57. package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.js +87 -0
  58. package/dist/client/billing/renewalAttach/internal/producer/recoveryEntry.js.map +1 -0
  59. package/dist/client/billing/renewalAttach/internal/producer/recoveryFactory.d.ts +368 -0
  60. package/dist/client/billing/renewalAttach/internal/producer/recoveryFactory.d.ts.map +1 -0
  61. package/dist/client/billing/renewalAttach/internal/producer/recoveryFactory.js +106 -0
  62. package/dist/client/billing/renewalAttach/internal/producer/recoveryFactory.js.map +1 -0
  63. package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.d.ts +4 -0
  64. package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.d.ts.map +1 -1
  65. package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.js +24 -3
  66. package/dist/client/billing/renewalAttach/internal/producer/stockDelegateFactory.js.map +1 -1
  67. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +1 -0
  68. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -1
  69. package/dist/client/billing/renewalAttach/internal/recovery/output.js +22 -8
  70. package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -1
  71. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +1 -0
  72. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -1
  73. package/dist/client/billing/renewalAttach/internal/recovery/record.js +10 -2
  74. package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -1
  75. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +3 -0
  76. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -1
  77. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +69 -156
  78. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -1
  79. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +18 -0
  80. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -1
  81. package/dist/client/billing/renewalAttach/internal/recovery/relation.js +15 -1
  82. package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -1
  83. package/docs/renewal-context-reads.md +69 -8
  84. package/package.json +1 -1
  85. package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +45 -3
  86. package/src/client/billing/renewalAttach/internal/c10/attachEvents.ts +17 -5
  87. package/src/client/billing/renewalAttach/internal/operations/actorFailureControl.ts +165 -0
  88. package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +48 -535
  89. package/src/client/billing/renewalAttach/internal/operations/initialActorData.ts +41 -0
  90. package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +168 -209
  91. package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +23 -5
  92. package/src/client/billing/renewalAttach/internal/operations/transportCapture.ts +60 -0
  93. package/src/client/billing/renewalAttach/internal/operations/transportKernel.ts +500 -0
  94. package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +28 -0
  95. package/src/client/billing/renewalAttach/internal/producer/journalWorkFactory.ts +54 -0
  96. package/src/client/billing/renewalAttach/internal/producer/lineageAuthority.ts +3 -0
  97. package/src/client/billing/renewalAttach/internal/producer/operationFactory.ts +176 -0
  98. package/src/client/billing/renewalAttach/internal/producer/producerAcquisition.integration.test.ts +240 -0
  99. package/src/client/billing/renewalAttach/internal/producer/producerActor.integration.test.ts +526 -0
  100. package/src/client/billing/renewalAttach/internal/producer/producerRecovery.integration.test.ts +394 -0
  101. package/src/client/billing/renewalAttach/internal/producer/producerRecoveryControls.integration.test.ts +437 -0
  102. package/src/client/billing/renewalAttach/internal/producer/producerRecoveryIsolation.integration.test.ts +332 -0
  103. package/src/client/billing/renewalAttach/internal/producer/producerTransport.integration.test.ts +440 -0
  104. package/src/client/billing/renewalAttach/internal/producer/recoveryEntry.ts +109 -0
  105. package/src/client/billing/renewalAttach/internal/producer/recoveryFactory.ts +135 -0
  106. package/src/client/billing/renewalAttach/internal/producer/stockDelegateFactory.ts +29 -5
  107. package/src/client/billing/renewalAttach/internal/recovery/output.ts +34 -8
  108. package/src/client/billing/renewalAttach/internal/recovery/record.ts +16 -2
  109. package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +107 -188
  110. package/src/client/billing/renewalAttach/internal/recovery/relation.ts +17 -1
  111. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +82 -11
@@ -36,7 +36,11 @@ export async function initialOperations(
36
36
  endWallMs?: number;
37
37
  afterBind?: () => Promise<void>;
38
38
  afterAppend?: () => Promise<void>;
39
+ beforeAppend?: () => Promise<void>;
40
+ afterRetain?: () => Promise<void>;
39
41
  source?: RetainedInput;
42
+ sources?: readonly RetainedInput[];
43
+ keys?: readonly string[];
40
44
  } = {},
41
45
  ) {
42
46
  const h = await codecFixture();
@@ -107,17 +111,72 @@ export async function initialOperations(
107
111
  periodEnd: prepared.expected.periodEnd,
108
112
  },
109
113
  };
114
+ assert(!options.sources || options.sources.length === count);
115
+ assert(!options.keys || options.keys.length === count);
116
+ const records = options.sources
117
+ ? await Promise.all(
118
+ options.sources.map(async (original) => {
119
+ const raw = original.attachRequest;
120
+ const prepared = await prepareRenewalPriceReplacementV2(
121
+ raw.preparation,
122
+ );
123
+ const request = await prepareRenewalScheduleAttachmentV2({
124
+ prepared,
125
+ apiVersion: raw.apiVersion,
126
+ attachKey: raw.attachKey,
127
+ firstDispatchedAt: raw.firstDispatchedAt,
128
+ });
129
+ return {
130
+ ...record,
131
+ attachRequest: raw,
132
+ originalBundle: original.originalBundle,
133
+ requestBinding: request.requestIdentity.binding,
134
+ dispatch: {
135
+ scope: request.scope,
136
+ apiVersion: request.apiVersion,
137
+ method: request.method,
138
+ path: request.path,
139
+ payload: request.payload,
140
+ key: request.key,
141
+ firstDispatchedAt: request.firstDispatchedAt,
142
+ },
143
+ timingPolicy: {
144
+ ...record.timingPolicy,
145
+ firstDispatchedAt: raw.firstDispatchedAt,
146
+ periodStart: prepared.expected.periodStart,
147
+ periodEnd: prepared.expected.periodEnd,
148
+ },
149
+ };
150
+ }),
151
+ )
152
+ : null;
110
153
  const sdk = new BetterStripe(components.betterStripe, {
111
154
  STRIPE_SECRET_KEY: "sk_test_invalid_owner_core",
112
155
  });
156
+ const sdks = options.keys?.map(
157
+ (key) =>
158
+ new BetterStripe(components.betterStripe, { STRIPE_SECRET_KEY: key }),
159
+ );
113
160
  const refs = components.betterStripe.renewalOperations;
114
161
  const host = {
115
162
  run: actionGeneric({
116
163
  args: {},
117
164
  handler: async (ctx): Promise<null> => {
118
165
  const runMutation = ctx.runMutation;
119
- if (options.afterBind || options.afterAppend)
166
+ if (
167
+ options.afterBind ||
168
+ options.afterAppend ||
169
+ options.afterRetain ||
170
+ options.beforeAppend
171
+ )
120
172
  ctx.runMutation = async (ref, ...args) => {
173
+ if (
174
+ getFunctionAddress(ref).reference?.endsWith(
175
+ "/appendStageEvent",
176
+ ) &&
177
+ options.beforeAppend
178
+ )
179
+ await options.beforeAppend();
121
180
  const result = await runMutation(ref, ...args);
122
181
  if (
123
182
  getFunctionAddress(ref).reference?.endsWith(
@@ -133,35 +192,47 @@ export async function initialOperations(
133
192
  options.afterAppend
134
193
  )
135
194
  await options.afterAppend();
195
+ if (
196
+ getFunctionAddress(ref).reference?.endsWith(
197
+ "/retainProviderAcknowledgement",
198
+ ) &&
199
+ options.afterRetain
200
+ )
201
+ await options.afterRetain();
136
202
  return result;
137
203
  };
138
204
  await Promise.all(
139
205
  Array.from({ length: count }, async (_, index) => {
206
+ const current = records?.[index] ?? record;
207
+ const selectedSDK = sdks?.[index] ?? sdk;
140
208
  const logicalOperationId =
141
- record.logicalOperationId + "-owner-" + index;
142
- const recordJSON = canonical({ ...record, logicalOperationId });
209
+ current.logicalOperationId + "-owner-" + index;
210
+ const recordJSON = canonical({ ...current, logicalOperationId });
143
211
  const created = await ctx.runMutation(
144
212
  refs.mutations.createAuthorizedOperation,
145
213
  {
146
- authorizationScope: record.authorization.scope,
147
- authorizationRevision: record.authorization.revision,
214
+ authorizationScope: current.authorization.scope,
215
+ authorizationRevision: current.authorization.revision,
148
216
  logicalOperationId,
149
217
  recordJSON,
150
218
  },
151
219
  );
152
220
  assert(created.status === "created");
153
- const journal = await createClassActionOperationJournal(sdk, {
154
- actualActionCtx: ctx,
155
- operationId: created.operationId,
156
- });
221
+ const journal = await createClassActionOperationJournal(
222
+ selectedSDK,
223
+ {
224
+ actualActionCtx: ctx,
225
+ operationId: created.operationId,
226
+ },
227
+ );
157
228
  const fresh = await journal.reserveFreshAttempt({
158
229
  expectedRevision: 0,
159
230
  stage: "attach",
160
- expectedRequestBinding: record.requestBinding,
231
+ expectedRequestBinding: current.requestBinding,
161
232
  recordJSON,
162
233
  });
163
234
  assert(fresh.result.disposition === "acquired" && fresh.call);
164
- await work({ journal, fresh, sdk, index });
235
+ await work({ journal, fresh, sdk: selectedSDK, index });
165
236
  }),
166
237
  );
167
238
  return null;