@fantastic.dev/better-stripe 0.109.1 → 0.111.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 +12 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts +41 -0
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.js +40 -3
- package/dist/client/billing/renewalAttach/internal/observation/freshActor.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts +10 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js +162 -57
- package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.d.ts +14 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.js +109 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoiceAuthorization.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.d.ts +20 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.js +176 -0
- package/dist/client/billing/renewalAttach/internal/observation/invoicePlan.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +24 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +1 -0
- package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -1
- package/dist/client/billing/renewalObservation/evidence-invoice.d.ts.map +1 -1
- package/dist/client/billing/renewalObservation/evidence-invoice.js +3 -0
- package/dist/client/billing/renewalObservation/evidence-invoice.js.map +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +84 -32
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +42 -16
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +52 -0
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +26 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/mutations.d.ts +27 -27
- package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
- package/dist/component/balanceFunding/queries.d.ts +1 -1
- package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
- package/dist/component/earnings/triggers.d.ts +44 -0
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/renewalWitnesses/eligibility.d.ts +36 -0
- package/dist/component/renewalWitnesses/eligibility.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/eligibility.js +60 -0
- package/dist/component/renewalWitnesses/eligibility.js.map +1 -0
- package/dist/component/renewalWitnesses/protocol.d.ts +75 -0
- package/dist/component/renewalWitnesses/protocol.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/protocol.js +82 -0
- package/dist/component/renewalWitnesses/protocol.js.map +1 -0
- package/dist/component/renewalWitnesses/schema.d.ts +99 -0
- package/dist/component/renewalWitnesses/schema.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/schema.js +36 -0
- package/dist/component/renewalWitnesses/schema.js.map +1 -0
- package/dist/component/renewalWitnesses/source.d.ts +22 -0
- package/dist/component/renewalWitnesses/source.d.ts.map +1 -0
- package/dist/component/renewalWitnesses/source.js +108 -0
- package/dist/component/renewalWitnesses/source.js.map +1 -0
- package/dist/component/schema.d.ts +42 -16
- package/dist/component/schema.js +2 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/usage/allowance.fixtures.d.ts +26 -0
- package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
- package/dist/component/usageCredits/accounting.fixtures.d.ts +42 -16
- package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
- package/dist/shared/renewalWitness.d.ts +51 -0
- package/dist/shared/renewalWitness.d.ts.map +1 -0
- package/dist/shared/renewalWitness.js +127 -0
- package/dist/shared/renewalWitness.js.map +1 -0
- package/docs/renewal-invoice-reads.md +85 -0
- package/docs/renewal-witness-protocol.md +88 -0
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/observation/freshActor.ts +69 -3
- package/src/client/billing/renewalAttach/internal/observation/freshTransport.ts +189 -59
- package/src/client/billing/renewalAttach/internal/observation/invoiceActor.integration.test.ts +142 -0
- package/src/client/billing/renewalAttach/internal/observation/invoiceActorControls.integration.test.ts +495 -0
- package/src/client/billing/renewalAttach/internal/observation/invoiceAuthorization.ts +145 -0
- package/src/client/billing/renewalAttach/internal/observation/invoicePlan.ts +284 -0
- package/src/client/billing/renewalAttach/internal/observation/profile.ts +1 -1
- package/src/client/billing/renewalAttach/internal/observation/types.ts +7 -1
- package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +30 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureWriteControls.integration.test.ts +74 -62
- package/src/client/billing/renewalAttach/internal/test-fixtures/invoiceObservation.ts +158 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +11 -1
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +4 -0
- package/src/client/billing/renewalObservation/evidence-invoice-identity.test.ts +13 -0
- package/src/client/billing/renewalObservation/evidence-invoice.ts +8 -0
- package/src/component/renewalOperations/configureJournal.fixtures.ts +25 -3
- package/src/component/renewalWitnesses/bounds.test.ts +204 -0
- package/src/component/renewalWitnesses/codec.test.ts +84 -0
- package/src/component/renewalWitnesses/controls.test.ts +250 -0
- package/src/component/renewalWitnesses/eligibility.ts +78 -0
- package/src/component/renewalWitnesses/protocol.test.ts +63 -0
- package/src/component/renewalWitnesses/protocol.ts +103 -0
- package/src/component/renewalWitnesses/schema.ts +36 -0
- package/src/component/renewalWitnesses/source.ts +157 -0
- package/src/component/schema.ts +2 -0
- package/src/shared/renewalWitness.ts +179 -0
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import Stripe from "stripe";
|
|
2
|
+
import { getFunctionAddress } from "convex/server";
|
|
3
|
+
import {
|
|
4
|
+
createInvoiceReadPlan,
|
|
5
|
+
InvoiceAcquisitionStop,
|
|
6
|
+
} from "./invoicePlan.js";
|
|
7
|
+
import {
|
|
8
|
+
createInvoiceAuthorization,
|
|
9
|
+
invoiceProfileGuard,
|
|
10
|
+
} from "./invoiceAuthorization.js";
|
|
11
|
+
import type { InvoiceObservationProfile } from "../operations/sourceOperations.js";
|
|
12
|
+
import type { InvoiceContextV1 } from "../../../renewalObservation/evidence-v1-types.js";
|
|
2
13
|
import { types } from "node:util";
|
|
3
14
|
import {
|
|
4
15
|
COMPILED_FRESH_OBSERVATION_ENTRIES,
|
|
@@ -16,6 +27,7 @@ import {
|
|
|
16
27
|
couponReadRow,
|
|
17
28
|
observationCouponIds,
|
|
18
29
|
validateBaseRouting,
|
|
30
|
+
validateCoupon,
|
|
19
31
|
} from "./profile.js";
|
|
20
32
|
import { captureObservationReply, safeReadDiagnostics } from "./capture.js";
|
|
21
33
|
import type {
|
|
@@ -67,13 +79,30 @@ type Settlement = Readonly<{
|
|
|
67
79
|
export function captureFreshGetTransport(
|
|
68
80
|
token: object,
|
|
69
81
|
profile: FreshObservationProfile,
|
|
82
|
+
invoiceProfile: InvoiceObservationProfile | null = null,
|
|
70
83
|
) {
|
|
71
|
-
freshNeed(arguments.length === 2);
|
|
84
|
+
freshNeed(arguments.length === 2 || arguments.length === 3);
|
|
72
85
|
const state = readObservationInvocation(token),
|
|
73
86
|
captured = state.readCaptured();
|
|
74
87
|
freshNeed(state.historyEntry === profile.historyEntry);
|
|
75
88
|
const covers = profile.coversObservation;
|
|
89
|
+
const invoiceAddress =
|
|
90
|
+
invoiceProfile &&
|
|
91
|
+
JSON.stringify(getFunctionAddress(invoiceProfile.authorizationQuery));
|
|
92
|
+
let invoiceAuthorization: ReturnType<
|
|
93
|
+
typeof createInvoiceAuthorization
|
|
94
|
+
> | null = null;
|
|
95
|
+
let invoiceUsed = false;
|
|
76
96
|
function profileGuard() {
|
|
97
|
+
if (invoiceProfile) {
|
|
98
|
+
invoiceProfileGuard(invoiceProfile);
|
|
99
|
+
freshNeed(
|
|
100
|
+
invoiceProfile.freshProfile === profile &&
|
|
101
|
+
JSON.stringify(
|
|
102
|
+
getFunctionAddress(invoiceProfile.authorizationQuery),
|
|
103
|
+
) === invoiceAddress,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
77
106
|
readObservationInvocation(token);
|
|
78
107
|
freshNeed(
|
|
79
108
|
COMPILED_FRESH_OBSERVATION_ENTRIES.includes(profile) &&
|
|
@@ -105,6 +134,7 @@ export function captureFreshGetTransport(
|
|
|
105
134
|
);
|
|
106
135
|
function guard() {
|
|
107
136
|
profileGuard();
|
|
137
|
+
invoiceAuthorization?.guard();
|
|
108
138
|
selection.check();
|
|
109
139
|
freshNeed(
|
|
110
140
|
Object.getPrototypeOf(client) === Stripe.prototype &&
|
|
@@ -136,6 +166,70 @@ export function captureFreshGetTransport(
|
|
|
136
166
|
freshNeed(ordinal - 4 < ids.length);
|
|
137
167
|
return couponReadRow(ids[ordinal - 4], ordinal + 1);
|
|
138
168
|
}
|
|
169
|
+
async function dispatch(row: ObservationReadRow, invoiceRead = false) {
|
|
170
|
+
if (invoiceRead) await invoiceAuthorization!.authorize();
|
|
171
|
+
else await state.authorizeUnchanged();
|
|
172
|
+
guard();
|
|
173
|
+
|
|
174
|
+
let promise: object | null = null;
|
|
175
|
+
const cell: { capsule: Settlement | null } = { capsule: null };
|
|
176
|
+
const result: unknown = await state.owned(() => {
|
|
177
|
+
const actualPromise: unknown = Reflect.apply(method, client, [
|
|
178
|
+
"GET",
|
|
179
|
+
row.path,
|
|
180
|
+
undefined,
|
|
181
|
+
row.options,
|
|
182
|
+
]);
|
|
183
|
+
freshNeed(
|
|
184
|
+
actualPromise &&
|
|
185
|
+
typeof actualPromise === "object" &&
|
|
186
|
+
!types.isProxy(actualPromise) &&
|
|
187
|
+
types.isPromise(actualPromise),
|
|
188
|
+
);
|
|
189
|
+
promise = actualPromise;
|
|
190
|
+
return Reflect.apply(nativeThen, actualPromise, [
|
|
191
|
+
(value: unknown) =>
|
|
192
|
+
(cell.capsule = Object.freeze({
|
|
193
|
+
promise: actualPromise,
|
|
194
|
+
kind: "fulfilled" as const,
|
|
195
|
+
value,
|
|
196
|
+
})),
|
|
197
|
+
(value: unknown) =>
|
|
198
|
+
(cell.capsule = Object.freeze({
|
|
199
|
+
promise: actualPromise,
|
|
200
|
+
kind: "rejected" as const,
|
|
201
|
+
value,
|
|
202
|
+
})),
|
|
203
|
+
]) as Promise<Settlement>;
|
|
204
|
+
}, guard);
|
|
205
|
+
guard();
|
|
206
|
+
const capsule = cell.capsule;
|
|
207
|
+
freshNeed(capsule && result === capsule && capsule.promise === promise);
|
|
208
|
+
const settled: Settlement = capsule;
|
|
209
|
+
if (settled.kind === "rejected") {
|
|
210
|
+
ended = true;
|
|
211
|
+
return Object.freeze({
|
|
212
|
+
kind: "provider_rejected" as const,
|
|
213
|
+
failure: freeze({
|
|
214
|
+
category: "provider_rejected" as const,
|
|
215
|
+
phase: "read" as const,
|
|
216
|
+
resource: row.resource,
|
|
217
|
+
ordinal: row.ordinal,
|
|
218
|
+
request: {
|
|
219
|
+
method: "GET" as const,
|
|
220
|
+
path: row.path,
|
|
221
|
+
apiVersion: row.options.apiVersion,
|
|
222
|
+
},
|
|
223
|
+
diagnostics: safeReadDiagnostics(settled.value),
|
|
224
|
+
outcome: "unknown" as const,
|
|
225
|
+
operationalAuthority: false as const,
|
|
226
|
+
}),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
const body = captureObservationReply(settled.value);
|
|
230
|
+
guard();
|
|
231
|
+
return Object.freeze({ kind: "fulfilled" as const, body });
|
|
232
|
+
}
|
|
139
233
|
return Object.freeze({
|
|
140
234
|
guard,
|
|
141
235
|
async read(
|
|
@@ -152,7 +246,7 @@ export function captureFreshGetTransport(
|
|
|
152
246
|
busy = true;
|
|
153
247
|
try {
|
|
154
248
|
guard();
|
|
155
|
-
freshNeed(ordinal < 44 && !types.isProxy(raw));
|
|
249
|
+
freshNeed(!invoiceUsed && ordinal < 44 && !types.isProxy(raw));
|
|
156
250
|
const row = expected(),
|
|
157
251
|
actual = closed(raw, [
|
|
158
252
|
"resource",
|
|
@@ -178,68 +272,104 @@ export function captureFreshGetTransport(
|
|
|
178
272
|
options.apiVersion === row.options.apiVersion &&
|
|
179
273
|
options.maxNetworkRetries === 0,
|
|
180
274
|
);
|
|
181
|
-
await
|
|
182
|
-
guard();
|
|
275
|
+
const result = await dispatch(row);
|
|
183
276
|
ordinal++;
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
277
|
+
if (result.kind === "provider_rejected") return result;
|
|
278
|
+
const body = result.body;
|
|
279
|
+
bodies.push(body);
|
|
280
|
+
return Object.freeze({ kind: "fulfilled" as const, body });
|
|
281
|
+
} catch (error) {
|
|
282
|
+
ended = true;
|
|
283
|
+
state.close();
|
|
284
|
+
throw error;
|
|
285
|
+
} finally {
|
|
286
|
+
busy = false;
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
async finalizeInvoices() {
|
|
290
|
+
if (invoiceAuthorization) await invoiceAuthorization.authorize();
|
|
291
|
+
else await state.authorizeUnchanged();
|
|
292
|
+
guard();
|
|
293
|
+
},
|
|
294
|
+
async acquireInvoices(): Promise<
|
|
295
|
+
Readonly<{
|
|
296
|
+
status: "complete" | "unavailable" | "conflict" | "provider_rejected";
|
|
297
|
+
context: InvoiceContextV1 | null;
|
|
298
|
+
reason: string | null;
|
|
299
|
+
failure: ReadFailure | null;
|
|
300
|
+
}>
|
|
301
|
+
> {
|
|
302
|
+
freshNeed(
|
|
303
|
+
arguments.length === 0 &&
|
|
304
|
+
invoiceProfile &&
|
|
305
|
+
!invoiceUsed &&
|
|
306
|
+
!busy &&
|
|
307
|
+
!ended,
|
|
308
|
+
);
|
|
309
|
+
invoiceUsed = true;
|
|
310
|
+
busy = true;
|
|
311
|
+
try {
|
|
215
312
|
guard();
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
313
|
+
const reads: ObservationReads = {
|
|
314
|
+
schedule: bodies[0],
|
|
315
|
+
subscription: bodies[1],
|
|
316
|
+
targetPrice: bodies[2],
|
|
317
|
+
billingCustomer: bodies[3],
|
|
318
|
+
coupons: bodies.slice(4),
|
|
319
|
+
};
|
|
320
|
+
validateBaseRouting(captured.history.record, reads);
|
|
321
|
+
const ids = observationCouponIds(
|
|
322
|
+
captured.history.record,
|
|
323
|
+
reads.subscription,
|
|
324
|
+
);
|
|
325
|
+
freshNeed(ordinal === 4 + ids.length);
|
|
326
|
+
reads.coupons.forEach((body, index) =>
|
|
327
|
+
validateCoupon(captured.history.record, ids[index], body),
|
|
328
|
+
);
|
|
329
|
+
let plan: ReturnType<typeof createInvoiceReadPlan>;
|
|
330
|
+
try {
|
|
331
|
+
plan = createInvoiceReadPlan(captured.history.record, reads, ordinal);
|
|
332
|
+
} catch (error) {
|
|
333
|
+
if (!(error instanceof InvoiceAcquisitionStop)) throw error;
|
|
221
334
|
return Object.freeze({
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
resource: row.resource,
|
|
227
|
-
ordinal: row.ordinal,
|
|
228
|
-
request: {
|
|
229
|
-
method: "GET" as const,
|
|
230
|
-
path: row.path,
|
|
231
|
-
apiVersion: row.options.apiVersion,
|
|
232
|
-
},
|
|
233
|
-
diagnostics: safeReadDiagnostics(settled.value),
|
|
234
|
-
outcome: "unknown" as const,
|
|
235
|
-
operationalAuthority: false as const,
|
|
236
|
-
}),
|
|
335
|
+
status: error.kind,
|
|
336
|
+
context: null,
|
|
337
|
+
reason: error.reason,
|
|
338
|
+
failure: null,
|
|
237
339
|
});
|
|
238
340
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
341
|
+
invoiceAuthorization = createInvoiceAuthorization(
|
|
342
|
+
token,
|
|
343
|
+
invoiceProfile,
|
|
344
|
+
plan.pins,
|
|
345
|
+
);
|
|
346
|
+
while (!plan.done()) {
|
|
347
|
+
const result = await dispatch(plan.row(), true);
|
|
348
|
+
if (result.kind === "provider_rejected")
|
|
349
|
+
return Object.freeze({
|
|
350
|
+
status: "provider_rejected",
|
|
351
|
+
context: null,
|
|
352
|
+
reason: null,
|
|
353
|
+
failure: result.failure,
|
|
354
|
+
});
|
|
355
|
+
try {
|
|
356
|
+
plan.accept(result.body);
|
|
357
|
+
} catch (error) {
|
|
358
|
+
if (!(error instanceof InvoiceAcquisitionStop)) throw error;
|
|
359
|
+
return Object.freeze({
|
|
360
|
+
status: error.kind,
|
|
361
|
+
context: null,
|
|
362
|
+
reason: error.reason,
|
|
363
|
+
failure: null,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return Object.freeze({
|
|
368
|
+
status: "complete",
|
|
369
|
+
context: plan.context(),
|
|
370
|
+
reason: null,
|
|
371
|
+
failure: null,
|
|
372
|
+
});
|
|
243
373
|
} catch (error) {
|
|
244
374
|
ended = true;
|
|
245
375
|
state.close();
|
package/src/client/billing/renewalAttach/internal/observation/invoiceActor.integration.test.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { expect, it } from "vitest";
|
|
2
|
+
import { anyApi } from "convex/server";
|
|
3
|
+
import {
|
|
4
|
+
configureAdmissionCase,
|
|
5
|
+
admissionControls,
|
|
6
|
+
} from "../test-fixtures/producerConfigureAdmission.js";
|
|
7
|
+
import {
|
|
8
|
+
observerIdentity,
|
|
9
|
+
authorizeObservation,
|
|
10
|
+
} from "../test-fixtures/observationReader.js";
|
|
11
|
+
import {
|
|
12
|
+
prepareInvoiceObservation,
|
|
13
|
+
authorizeInvoices,
|
|
14
|
+
invoiceControls,
|
|
15
|
+
} from "../test-fixtures/invoiceObservation.js";
|
|
16
|
+
|
|
17
|
+
import * as actors from "./freshActor.js";
|
|
18
|
+
|
|
19
|
+
const options = {
|
|
20
|
+
identity: observerIdentity,
|
|
21
|
+
hostQuery: authorizeObservation,
|
|
22
|
+
hostInvoiceQuery: authorizeInvoices,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
it("EMPTY invoice profile refuses before input reflection", async () => {
|
|
26
|
+
admissionControls.invoices.splice(0);
|
|
27
|
+
const capture = Reflect.get(actors, "captureFreshInvoiceRenewalObservation");
|
|
28
|
+
expect(capture).toBeTypeOf("function");
|
|
29
|
+
let traps = 0;
|
|
30
|
+
const poison = new Proxy(
|
|
31
|
+
{},
|
|
32
|
+
{
|
|
33
|
+
get() {
|
|
34
|
+
traps++;
|
|
35
|
+
throw Error("TRAP");
|
|
36
|
+
},
|
|
37
|
+
getPrototypeOf() {
|
|
38
|
+
traps++;
|
|
39
|
+
throw Error("TRAP");
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
await expect(capture(poison, poison)).rejects.toThrow(
|
|
44
|
+
"INVOICE_OBSERVATION_UNBOUND",
|
|
45
|
+
);
|
|
46
|
+
expect(traps).toBe(0);
|
|
47
|
+
});
|
|
48
|
+
configureAdmissionCase(
|
|
49
|
+
"fresh invoice acquisition correlates pinned periods and successor without C9",
|
|
50
|
+
prepareInvoiceObservation,
|
|
51
|
+
async (h, state) => {
|
|
52
|
+
const capture = Reflect.get(
|
|
53
|
+
actors,
|
|
54
|
+
"captureFreshInvoiceRenewalObservation",
|
|
55
|
+
);
|
|
56
|
+
expect(capture).toBeTypeOf("function");
|
|
57
|
+
const before = h.calls.length;
|
|
58
|
+
await h.inAnotherAction(async (ctx) => {
|
|
59
|
+
const actor = await capture(h.sdk, {
|
|
60
|
+
actualActionCtx: ctx,
|
|
61
|
+
operationId: state.operationId,
|
|
62
|
+
parentOperationId: state.parentOperationId,
|
|
63
|
+
});
|
|
64
|
+
const result = await actor.invoke();
|
|
65
|
+
expect(result.invoiceInventory).toBe("complete");
|
|
66
|
+
expect(result.invoiceContext?.original.invoice).toEqual(
|
|
67
|
+
state.inventories[0].invoice,
|
|
68
|
+
);
|
|
69
|
+
expect(result.evidence?.invoiceEvidence.predicate).toBe(
|
|
70
|
+
"invoice_lines_correlated",
|
|
71
|
+
);
|
|
72
|
+
expect(result.evidence?.currentMaterial.predicate).toBe(
|
|
73
|
+
"current_target_material_match",
|
|
74
|
+
);
|
|
75
|
+
expect(result.evidence?.invoiceEvidence.current?.subscriptionItemId).toBe(
|
|
76
|
+
"si_successor",
|
|
77
|
+
);
|
|
78
|
+
expect(result.evidence?.operationalAuthority).toBe(false);
|
|
79
|
+
expect(result.history.configureReceipt).toBeNull();
|
|
80
|
+
await expect(actor.invoke()).rejects.toThrow();
|
|
81
|
+
});
|
|
82
|
+
expect(h.calls.slice(before).map((c) => c.method)).toEqual(
|
|
83
|
+
Array(11).fill("GET"),
|
|
84
|
+
);
|
|
85
|
+
expect(invoiceControls.count).toBe(6);
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
identity: observerIdentity,
|
|
89
|
+
hostQuery: authorizeObservation,
|
|
90
|
+
hostInvoiceQuery: authorizeInvoices,
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
configureAdmissionCase(
|
|
95
|
+
"foreign customer in an expanded pinned pointer refuses before invoice I/O",
|
|
96
|
+
prepareInvoiceObservation,
|
|
97
|
+
async (h, state) => {
|
|
98
|
+
state.reads.subscription.latest_invoice = {
|
|
99
|
+
id: "in_current",
|
|
100
|
+
object: "invoice",
|
|
101
|
+
customer: "cus_foreign",
|
|
102
|
+
};
|
|
103
|
+
const before = h.calls.length;
|
|
104
|
+
await h.inAnotherAction(async (ctx) => {
|
|
105
|
+
const actor = await actors.captureFreshInvoiceRenewalObservation(h.sdk, {
|
|
106
|
+
actualActionCtx: ctx,
|
|
107
|
+
operationId: state.operationId,
|
|
108
|
+
parentOperationId: state.parentOperationId,
|
|
109
|
+
});
|
|
110
|
+
const result = await actor.invoke();
|
|
111
|
+
expect(result.invoiceInventory).toBe("conflict");
|
|
112
|
+
expect(result.invoiceContext).toBeNull();
|
|
113
|
+
});
|
|
114
|
+
expect(h.calls.slice(before)).toHaveLength(6);
|
|
115
|
+
expect(invoiceControls.count).toBe(0);
|
|
116
|
+
},
|
|
117
|
+
options,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
configureAdmissionCase(
|
|
121
|
+
"the maintained generated API proxy is a usable fixed invoice authorization reference",
|
|
122
|
+
prepareInvoiceObservation,
|
|
123
|
+
async (h, state) => {
|
|
124
|
+
admissionControls.invoices.splice(
|
|
125
|
+
0,
|
|
126
|
+
1,
|
|
127
|
+
Object.freeze({
|
|
128
|
+
...state.invoiceProfile,
|
|
129
|
+
authorizationQuery: anyApi.initialOwner.authorizeInvoices,
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
await h.inAnotherAction(async (ctx) => {
|
|
133
|
+
const actor = await actors.captureFreshInvoiceRenewalObservation(h.sdk, {
|
|
134
|
+
actualActionCtx: ctx,
|
|
135
|
+
operationId: state.operationId,
|
|
136
|
+
parentOperationId: state.parentOperationId,
|
|
137
|
+
});
|
|
138
|
+
expect((await actor.invoke()).invoiceInventory).toBe("complete");
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
options,
|
|
142
|
+
);
|