@fantastic.dev/better-stripe 0.100.0 → 0.102.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/producer/classOwnedActionRoot.d.ts +2 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +16 -0
- package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.js +117 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureAdmission.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts +53 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js +198 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalData.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureLineage.d.ts +959 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureLineage.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureLineage.js +115 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureLineage.js.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +2 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +4 -0
- package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js.map +1 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +18 -18
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +9 -9
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +50 -50
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +25 -25
- package/dist/component/balanceFunding/mutations.d.ts +27 -27
- package/dist/component/balanceFunding/queries.d.ts +1 -1
- package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
- package/dist/component/earnings/triggers.d.ts +22 -22
- package/dist/component/payoutRelease/queries.d.ts +2 -2
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
- package/dist/component/renewalOperations/attachValidation.d.ts +19 -0
- package/dist/component/renewalOperations/attachValidation.d.ts.map +1 -0
- package/dist/component/renewalOperations/attachValidation.js +167 -0
- package/dist/component/renewalOperations/attachValidation.js.map +1 -0
- package/dist/component/renewalOperations/configureAcknowledgement.d.ts +13 -0
- package/dist/component/renewalOperations/configureAcknowledgement.d.ts.map +1 -0
- package/dist/component/renewalOperations/configureAcknowledgement.js +108 -0
- package/dist/component/renewalOperations/configureAcknowledgement.js.map +1 -0
- package/dist/component/renewalOperations/configureParent.d.ts +10 -0
- package/dist/component/renewalOperations/configureParent.d.ts.map +1 -0
- package/dist/component/renewalOperations/configureParent.js +62 -0
- package/dist/component/renewalOperations/configureParent.js.map +1 -0
- package/dist/component/renewalOperations/configureValidation.d.ts +12 -0
- package/dist/component/renewalOperations/configureValidation.d.ts.map +1 -0
- package/dist/component/renewalOperations/configureValidation.js +64 -0
- package/dist/component/renewalOperations/configureValidation.js.map +1 -0
- package/dist/component/renewalOperations/helpers.d.ts +16 -21
- package/dist/component/renewalOperations/helpers.d.ts.map +1 -1
- package/dist/component/renewalOperations/helpers.js +13 -169
- package/dist/component/renewalOperations/helpers.js.map +1 -1
- package/dist/component/renewalOperations/mutations.d.ts +6 -6
- package/dist/component/renewalOperations/mutations.d.ts.map +1 -1
- package/dist/component/renewalOperations/mutations.js +14 -7
- package/dist/component/renewalOperations/mutations.js.map +1 -1
- package/dist/component/renewalOperations/operationContext.d.ts +12 -0
- package/dist/component/renewalOperations/operationContext.d.ts.map +1 -0
- package/dist/component/renewalOperations/operationContext.js +14 -0
- package/dist/component/renewalOperations/operationContext.js.map +1 -0
- package/dist/component/renewalOperations/queries.d.ts +4 -4
- package/dist/component/renewalOperations/queries.js +2 -1
- package/dist/component/renewalOperations/queries.js.map +1 -1
- package/dist/component/renewalOperations/schema.d.ts +59 -59
- package/dist/component/renewalOperations/schema.js +3 -3
- package/dist/component/renewalOperations/schema.js.map +1 -1
- package/dist/component/renewalOperations/stageAcknowledgement.d.ts +15 -0
- package/dist/component/renewalOperations/stageAcknowledgement.d.ts.map +1 -0
- package/dist/component/renewalOperations/stageAcknowledgement.js +20 -0
- package/dist/component/renewalOperations/stageAcknowledgement.js.map +1 -0
- package/dist/component/renewalOperations/validationTypes.d.ts +9 -0
- package/dist/component/renewalOperations/validationTypes.d.ts.map +1 -0
- package/dist/component/renewalOperations/validationTypes.js +2 -0
- package/dist/component/renewalOperations/validationTypes.js.map +1 -0
- package/dist/component/schema.d.ts +9 -9
- package/dist/component/usage/allowance.fixtures.d.ts +25 -25
- package/dist/component/usageCredits/accounting.fixtures.d.ts +9 -9
- package/dist/shared/renewalOperationJournal.d.ts +1 -1
- package/dist/shared/renewalOperationJournal.d.ts.map +1 -1
- package/dist/shared/renewalOperationJournal.js +41 -9
- package/dist/shared/renewalOperationJournal.js.map +1 -1
- package/docs/renewal-context-reads.md +81 -11
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +21 -0
- package/src/client/billing/renewalAttach/internal/producer/configureAdmission.ts +179 -0
- package/src/client/billing/renewalAttach/internal/producer/configureJournalData.ts +248 -0
- package/src/client/billing/renewalAttach/internal/producer/configureLineage.ts +166 -0
- package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +13 -0
- package/src/client/billing/renewalAttach/internal/producer/lineageAuthority.ts +2 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureAdmission.integration.test.ts +203 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureControls.integration.test.ts +566 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +316 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +61 -3
- package/src/component/renewalOperations/attachValidation.ts +203 -0
- package/src/component/renewalOperations/configureAcknowledgement.test.ts +30 -0
- package/src/component/renewalOperations/configureAcknowledgement.ts +182 -0
- package/src/component/renewalOperations/configureAcknowledgementControls.test.ts +96 -0
- package/src/component/renewalOperations/configureBasis.test.ts +77 -0
- package/src/component/renewalOperations/configureCreation.test.ts +75 -0
- package/src/component/renewalOperations/configureJournal.fixtures.ts +385 -0
- package/src/component/renewalOperations/configureParent.ts +71 -0
- package/src/component/renewalOperations/configurePolicy.test.ts +105 -0
- package/src/component/renewalOperations/configurePublication.test.ts +85 -0
- package/src/component/renewalOperations/configureReceiptBounds.test.ts +39 -0
- package/src/component/renewalOperations/configureSourceControls.test.ts +65 -0
- package/src/component/renewalOperations/configureValidation.ts +70 -0
- package/src/component/renewalOperations/helpers.ts +21 -204
- package/src/component/renewalOperations/mutations.ts +16 -7
- package/src/component/renewalOperations/operationContext.ts +21 -0
- package/src/component/renewalOperations/queries.ts +1 -1
- package/src/component/renewalOperations/schema.ts +3 -3
- package/src/component/renewalOperations/stageAcknowledgement.ts +45 -0
- package/src/component/renewalOperations/validationTypes.ts +9 -0
- package/src/shared/renewalOperationJournal.ts +49 -8
|
@@ -219,12 +219,54 @@ changed predicates, removed class eligibility, copied DATA or unknown lineage
|
|
|
219
219
|
identities refuse. The same checks apply to cached views, and separate SDK roots
|
|
220
220
|
retain distinct output and receipt identities.
|
|
221
221
|
|
|
222
|
-
This reader
|
|
223
|
-
receipt.
|
|
224
|
-
|
|
222
|
+
This reader supplies private configure admission with the actual attachment
|
|
223
|
+
receipt. Admission uses a separately authorized stage operation and request/key.
|
|
224
|
+
Configure execution still requires its channels, transport, actors and complete
|
|
225
|
+
journal integration. The internal return record
|
|
225
226
|
does not establish delivery to a disconnected caller, qualify a provider profile
|
|
226
227
|
or create a public scheduling entrypoint.
|
|
227
228
|
|
|
229
|
+
## Private configure admission
|
|
230
|
+
|
|
231
|
+
The private initial invocation core accepts `admitConfigure(call, journal)` only
|
|
232
|
+
with the original winning child reservation call and its actual class-bound
|
|
233
|
+
journal. It spends that call before checking arity or parent custody. The parent
|
|
234
|
+
comes from the core's closure; callers cannot replace its Owner, receipt, ACK,
|
|
235
|
+
client, selector, clocks or basis. A copied admission view cannot reconstruct the
|
|
236
|
+
private identity.
|
|
237
|
+
|
|
238
|
+
Admission requires the actual returned attachment ACK from initial completion,
|
|
239
|
+
replay or no-POST resumption. A published receipt whose reply is still pending is
|
|
240
|
+
insufficient. The parent and child journals must share the actual checked SDK
|
|
241
|
+
root, root cell and component. Each retains its own checked Action receiver and
|
|
242
|
+
RPC pointers; different genuine Action contexts are supported.
|
|
243
|
+
|
|
244
|
+
The child retains the exact parent Owner, selected client, origin association,
|
|
245
|
+
clock functions and original basis. Admission performs no new selection, Owner
|
|
246
|
+
construction or origin capture. Normal Owner checks still sample its original
|
|
247
|
+
clocks. Complete C3/C6/C7 source, parent history and retained acknowledgement DATA
|
|
248
|
+
must agree, including typed dispatch/response contents before event hashing.
|
|
249
|
+
Every used reservation, load, history, event, acknowledgement and binding reply
|
|
250
|
+
receives complete bounded runtime DATA checks against the current source
|
|
251
|
+
contract. Generated attachment-only declarations and reference identities stay
|
|
252
|
+
unchanged; these checks do not establish genuine generation or deployed
|
|
253
|
+
compatibility.
|
|
254
|
+
|
|
255
|
+
The actual child basis transaction must commit and return its complete matching
|
|
256
|
+
descriptor. Reads after binding require the original basis, head zero and no
|
|
257
|
+
known child ACK. The no-ACK read precedes the final head read; no later journal
|
|
258
|
+
await precedes readiness. This is a read fence, with no atomic lock against
|
|
259
|
+
subsequent journal changes. Future execution must check its frontier again.
|
|
260
|
+
Owner retirement rejects a pending admission even if its basis mutation has
|
|
261
|
+
committed; retained DATA and failed or lost replies cannot remint the consumed
|
|
262
|
+
call.
|
|
263
|
+
|
|
264
|
+
The result is an opaque private view containing `owner`, `basisJSON` and
|
|
265
|
+
`operationalAuthority: false`. It supplies no configure transport, C10 channel,
|
|
266
|
+
preflight/write actor or public scheduling API. Those integrations remain
|
|
267
|
+
required, as do genuine generation and operational qualification. Production
|
|
268
|
+
Source profile arrays remain empty.
|
|
269
|
+
|
|
228
270
|
## Component operation journal
|
|
229
271
|
|
|
230
272
|
The component's `renewalOperations` functions retain host-authorized operation
|
|
@@ -242,15 +284,15 @@ The finite JSON model preserves unknown nested fields, array order and own
|
|
|
242
284
|
properties, including absent versus null values. Original record JSON must fit
|
|
243
285
|
500,000 characters and UTF-8 bytes, 10,000 nodes and depth 40.
|
|
244
286
|
|
|
245
|
-
Legacy `schemaVersion: 1` records retain their existing shape. Attachment
|
|
246
|
-
`schemaVersion: 2` records instead declare a closed `timingPolicy` with `version: 1`,
|
|
287
|
+
Legacy `schemaVersion: 1` records retain their existing shape. Attachment and
|
|
288
|
+
configure `schemaVersion: 2` records instead declare a closed `timingPolicy` with `version: 1`,
|
|
247
289
|
`firstDispatchedAt`, `periodStart`, `periodEnd`, `workEndWallMs` and `endWallMs`.
|
|
248
290
|
First-dispatch and period fields use epoch seconds; wall cutoff fields use epoch
|
|
249
291
|
milliseconds. They have no root `basis`; a policy does not establish a live
|
|
250
292
|
execution origin.
|
|
251
293
|
|
|
252
|
-
Before V2 creation, a successful creation duplicate or a stored-source
|
|
253
|
-
the component reconstructs the actual pure C1 preparation from the complete
|
|
294
|
+
Before V2 attachment creation, a successful creation duplicate or a stored-source
|
|
295
|
+
read, the component reconstructs the actual pure C1 preparation from the complete
|
|
254
296
|
`attachRequest.preparation`, then reconstructs C2. The entire seven-field
|
|
255
297
|
dispatch, account, API version, request binding and policy must match the
|
|
256
298
|
retained source. A stored preparation flag or matching period fields alone
|
|
@@ -259,6 +301,28 @@ host-authorized DATA: no layout or equality to the preparation is inferred.
|
|
|
259
301
|
Changing it still changes the immutable full record. Existing V1 records are
|
|
260
302
|
not migrated or supplied with a new basis.
|
|
261
303
|
|
|
304
|
+
A V2 configure record uses a separate logical operation identity, reservation,
|
|
305
|
+
request binding and C7 key. Its closed `configureRecord` contains `configuration`,
|
|
306
|
+
`request`, `attachReceipt` and the complete opaque `originalBundle`. Its closed
|
|
307
|
+
`parentAttachment` contains `operationId`, `attemptId`, `sourcePayloadId` and
|
|
308
|
+
`receiptBinding`. The host must authorize the exact parent and child pair. The
|
|
309
|
+
component does not impose equality on their host authorization scope strings.
|
|
310
|
+
|
|
311
|
+
Configure admission reconstructs C3, C6 and C7 and compares the complete dispatch,
|
|
312
|
+
account, API version, request and timing policy. A keyed parent lookup requires a
|
|
313
|
+
V2 attachment with its actual current attempt, bound basis, complete retained C3
|
|
314
|
+
and published receipt event 3. The child must match that complete C3, raw attachment
|
|
315
|
+
request and opaque original bundle. Its period and both wall cutoffs equal the
|
|
316
|
+
parent's policy. Binding the child requires exactly the parent's canonical basis
|
|
317
|
+
JSON, including the original wall and monotonic origins. Stored-source reads and
|
|
318
|
+
duplicate operations recheck these links and refuse corrupt DATA without repair.
|
|
319
|
+
|
|
320
|
+
This parent link establishes DATA consistency. Runtime configure admission still
|
|
321
|
+
requires a fresh winning child reservation, the actual live parent owner and its
|
|
322
|
+
actual returned attachment acknowledgement custody. Stored rows and equal basis
|
|
323
|
+
JSON cannot reconstruct those capabilities. Source tests use an isolated component;
|
|
324
|
+
genuine Convex generation, deployment and provider execution remain unverified.
|
|
325
|
+
|
|
262
326
|
`reserveAttempt` performs the first PREPARED-to-RESERVED transaction. Exactly one
|
|
263
327
|
winning invocation receives `acquired`; an identical later request receives
|
|
264
328
|
`existing` with the retained reservation. The result is DATA. Copying or loading
|
|
@@ -302,14 +366,20 @@ V2 event writes require the checked bound basis for that same operation and
|
|
|
302
366
|
attempt. Events or a known receipt without a bound basis are corruption; they
|
|
303
367
|
cannot be adopted as a fresh binding.
|
|
304
368
|
|
|
305
|
-
`retainProviderAcknowledgement` reconstructs the complete attachment
|
|
306
|
-
from the
|
|
369
|
+
`retainProviderAcknowledgement` reconstructs the complete attachment C3 or V2
|
|
370
|
+
configure C9 receipt from the checked source, dispatch and stored response. It compares
|
|
307
371
|
the full receipt and applies the existing whole-output JSON and privacy rules.
|
|
372
|
+
Configure C9 retention preserves the complete provider snapshot, transport,
|
|
373
|
+
C7 request and consistency bindings, including absent versus null default settings.
|
|
374
|
+
It means `configure_acknowledged`; it does not establish pending or effective
|
|
375
|
+
replacement. V1 configure records retain their previous acknowledgement behavior.
|
|
308
376
|
The transaction stores one owned receipt payload and a stable
|
|
309
377
|
`knownAcknowledgement` reference. It does not append receipt event 3.
|
|
310
378
|
|
|
311
379
|
A first retention must name the current history head, 2 or 3. When event 3
|
|
312
|
-
exists, its complete request and receipt must match.
|
|
380
|
+
exists, its complete request and receipt must match. Retention at head 2 does
|
|
381
|
+
not model or impose the size of a prospective receipt event 3; an actual event 3
|
|
382
|
+
must independently satisfy the event JSON bounds. An identical retry returns
|
|
313
383
|
the original retention descriptor without writes. A caller that retained at
|
|
314
384
|
head 2 can repeat that same request after matching event 3 is appended. A
|
|
315
385
|
request for a future head refuses. Once a receipt is retained, event 3 must
|
|
@@ -326,7 +396,7 @@ hash. They never infer or repair ownership from its contents.
|
|
|
326
396
|
For V2, complete owned history and any known receipt are also checked before
|
|
327
397
|
successful create-existing, reserve-existing and bind-duplicate returns, append
|
|
328
398
|
returns or writes, and all four queries below. These checks reconstruct the full
|
|
329
|
-
C3 receipt and validate every retained source/event/receipt reference, payload
|
|
399
|
+
stage-specific C3 or C9 receipt and validate every retained source/event/receipt reference, payload
|
|
330
400
|
owner and complete canonical receipt JSON. An absent sequence or an identical
|
|
331
401
|
old event does not bypass corrupt known DATA. The acknowledgement getter reuses
|
|
332
402
|
that validated receipt; it does not treat a matching binding alone as sufficient.
|
package/package.json
CHANGED
|
@@ -391,3 +391,24 @@ export function captureInitialJournalSelection(
|
|
|
391
391
|
},
|
|
392
392
|
});
|
|
393
393
|
}
|
|
394
|
+
|
|
395
|
+
/** Same maintained SDK root; each Action retains its own checked RPC pointers. */
|
|
396
|
+
export function checkConfigureJournalAssociation(
|
|
397
|
+
parent: object,
|
|
398
|
+
child: object,
|
|
399
|
+
): void {
|
|
400
|
+
if (arguments.length !== 2) journalUnbound();
|
|
401
|
+
readCheckedJournalActionRPC(parent);
|
|
402
|
+
readCheckedJournalActionRPC(child);
|
|
403
|
+
const original = journalBindings.get(parent);
|
|
404
|
+
const next = journalBindings.get(child);
|
|
405
|
+
if (
|
|
406
|
+
!original ||
|
|
407
|
+
!next ||
|
|
408
|
+
original.root !== next.root ||
|
|
409
|
+
original.cell !== next.cell ||
|
|
410
|
+
original.rpc.component !== next.rpc.component ||
|
|
411
|
+
original.rpc.operationId === next.rpc.operationId
|
|
412
|
+
)
|
|
413
|
+
journalUnbound();
|
|
414
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {
|
|
2
|
+
captureAttachDispatch,
|
|
3
|
+
captureAttachResponse,
|
|
4
|
+
captureAttachReceipt,
|
|
5
|
+
} from "../c10/eventCapture.js";
|
|
6
|
+
import { reconstructConfigurationV2 } from "../../../renewalV2/index.js";
|
|
7
|
+
import { canonicalJournalEvent } from "../../../../../shared/renewalOperationJournal.js";
|
|
8
|
+
import { ownedAwaitForInitialLineage } from "./ownedAwaitFactory.js";
|
|
9
|
+
import { closed } from "../operations/types.js";
|
|
10
|
+
import {
|
|
11
|
+
consumeConfigureLineage,
|
|
12
|
+
checkConfigureLineage,
|
|
13
|
+
finishConfigureLineage,
|
|
14
|
+
closeConfigureLineage,
|
|
15
|
+
} from "./configureLineage.js";
|
|
16
|
+
import {
|
|
17
|
+
checkOperationLoad,
|
|
18
|
+
checkEmptyConfigureHistory,
|
|
19
|
+
configureBasisDescriptor,
|
|
20
|
+
captureParentHistory,
|
|
21
|
+
checkParentAcknowledgement,
|
|
22
|
+
matchConfigureDATA,
|
|
23
|
+
requireConfigure,
|
|
24
|
+
object,
|
|
25
|
+
text,
|
|
26
|
+
} from "./configureJournalData.js";
|
|
27
|
+
|
|
28
|
+
/** Bind actual child custody to the live parent's exact basis; no execution profile. */
|
|
29
|
+
export async function captureConfigureAdmission(
|
|
30
|
+
parentToken: object,
|
|
31
|
+
call: unknown,
|
|
32
|
+
journal: unknown,
|
|
33
|
+
arity: number,
|
|
34
|
+
) {
|
|
35
|
+
const token = consumeConfigureLineage(parentToken, call, journal, arity);
|
|
36
|
+
const state = checkConfigureLineage(token);
|
|
37
|
+
const owned = ownedAwaitForInitialLineage(parentToken);
|
|
38
|
+
async function checked<T>(work: () => T | PromiseLike<T>): Promise<T> {
|
|
39
|
+
checkConfigureLineage(token);
|
|
40
|
+
const result = await owned(work);
|
|
41
|
+
checkConfigureLineage(token);
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
async function parentFrontier() {
|
|
45
|
+
checkOperationLoad(
|
|
46
|
+
await checked(() => state.parent.journal.loadAuthorizedOperation()),
|
|
47
|
+
state.parentReservation,
|
|
48
|
+
state.parent.basisJSON,
|
|
49
|
+
);
|
|
50
|
+
const events = captureParentHistory(
|
|
51
|
+
await checked(() =>
|
|
52
|
+
state.parent.journal.readAttempt({
|
|
53
|
+
attemptId: state.parentReservation.attemptId,
|
|
54
|
+
}),
|
|
55
|
+
),
|
|
56
|
+
state.parentReservation,
|
|
57
|
+
);
|
|
58
|
+
for (const descriptor of events) {
|
|
59
|
+
const raw: unknown = await checked(() =>
|
|
60
|
+
state.parent.journal.readStageEvent({
|
|
61
|
+
attemptId: state.parentReservation.attemptId,
|
|
62
|
+
sequence: descriptor.sequence,
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
const event = closed(raw, [...Object.keys(descriptor), "dataJSON"]);
|
|
66
|
+
const dataJSON = text(event.dataJSON);
|
|
67
|
+
const parsed: unknown = JSON.parse(dataJSON);
|
|
68
|
+
const receipt = object(state.acknowledgement.receipt);
|
|
69
|
+
// Typed privacy/bounds capture and complete C3 equality precede hashing.
|
|
70
|
+
if (descriptor.sequence === 1) {
|
|
71
|
+
captureAttachDispatch(parsed);
|
|
72
|
+
matchConfigureDATA(parsed, {
|
|
73
|
+
event: "dispatch",
|
|
74
|
+
stage: "attach",
|
|
75
|
+
request: receipt.request,
|
|
76
|
+
});
|
|
77
|
+
} else if (descriptor.sequence === 2) {
|
|
78
|
+
captureAttachResponse(parsed);
|
|
79
|
+
const response = object(parsed);
|
|
80
|
+
matchConfigureDATA(parsed, {
|
|
81
|
+
event: "response",
|
|
82
|
+
stage: "attach",
|
|
83
|
+
request: receipt.request,
|
|
84
|
+
body: receipt.providerSnapshot,
|
|
85
|
+
status: response.status,
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
captureAttachReceipt(parsed);
|
|
89
|
+
matchConfigureDATA(parsed, {
|
|
90
|
+
event: "receipt",
|
|
91
|
+
stage: "attach",
|
|
92
|
+
request: receipt.request,
|
|
93
|
+
receipt: state.acknowledgement.receipt,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const canonical = await checked(() =>
|
|
97
|
+
canonicalJournalEvent(descriptor.sequence, dataJSON),
|
|
98
|
+
);
|
|
99
|
+
requireConfigure(
|
|
100
|
+
canonical.json === dataJSON && canonical.binding === descriptor.binding,
|
|
101
|
+
);
|
|
102
|
+
matchConfigureDATA(raw, { ...descriptor, dataJSON });
|
|
103
|
+
}
|
|
104
|
+
checkParentAcknowledgement(
|
|
105
|
+
await checked(() => state.parent.journal.readProviderAcknowledgement()),
|
|
106
|
+
state.parentReservation,
|
|
107
|
+
events,
|
|
108
|
+
state.receiptJSON,
|
|
109
|
+
state.receiptBinding,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
async function childFrontier(allowUnbound: boolean) {
|
|
113
|
+
checkOperationLoad(
|
|
114
|
+
await checked(() => state.consumed.journal.loadAuthorizedOperation()),
|
|
115
|
+
state.reservation,
|
|
116
|
+
state.parent.basisJSON,
|
|
117
|
+
allowUnbound,
|
|
118
|
+
);
|
|
119
|
+
matchConfigureDATA(
|
|
120
|
+
await checked(() => state.consumed.journal.readProviderAcknowledgement()),
|
|
121
|
+
null,
|
|
122
|
+
);
|
|
123
|
+
// Best-effort frontier fence, not an atomic lock. No later journal await.
|
|
124
|
+
return checked(() =>
|
|
125
|
+
state.consumed.journal.readAttempt({
|
|
126
|
+
attemptId: state.reservation.attemptId,
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const rebuilt = await checked(() =>
|
|
132
|
+
reconstructConfigurationV2(state.configuration),
|
|
133
|
+
);
|
|
134
|
+
requireConfigure(rebuilt.material && "requestIdentity" in rebuilt.result);
|
|
135
|
+
const request = rebuilt.result;
|
|
136
|
+
matchConfigureDATA(state.source.request, request);
|
|
137
|
+
matchConfigureDATA(state.source.attachReceipt, rebuilt.material.receipt);
|
|
138
|
+
const { scope, apiVersion, method, path, payload, key, firstDispatchedAt } =
|
|
139
|
+
request;
|
|
140
|
+
matchConfigureDATA(state.original.dispatch, {
|
|
141
|
+
scope,
|
|
142
|
+
apiVersion,
|
|
143
|
+
method,
|
|
144
|
+
path,
|
|
145
|
+
payload,
|
|
146
|
+
key,
|
|
147
|
+
firstDispatchedAt,
|
|
148
|
+
});
|
|
149
|
+
requireConfigure(
|
|
150
|
+
state.reservation.requestBinding === request.requestIdentity.binding &&
|
|
151
|
+
state.reservation.key === key &&
|
|
152
|
+
state.reservation.apiVersion === apiVersion &&
|
|
153
|
+
state.reservation.firstDispatchedAt === firstDispatchedAt,
|
|
154
|
+
);
|
|
155
|
+
await parentFrontier();
|
|
156
|
+
checkEmptyConfigureHistory(await childFrontier(true), state.reservation);
|
|
157
|
+
const reply: unknown = await checked(() =>
|
|
158
|
+
state.consumed.journal.bindInitialBasis({
|
|
159
|
+
attemptId: state.reservation.attemptId,
|
|
160
|
+
policyJSON: state.reservation.timingPolicyJSON,
|
|
161
|
+
basisJSON: state.parent.basisJSON,
|
|
162
|
+
}),
|
|
163
|
+
);
|
|
164
|
+
matchConfigureDATA(reply, {
|
|
165
|
+
status: "bound",
|
|
166
|
+
operationId: state.reservation.operationId,
|
|
167
|
+
initialBasis: configureBasisDescriptor(
|
|
168
|
+
state.reservation,
|
|
169
|
+
state.parent.basisJSON,
|
|
170
|
+
),
|
|
171
|
+
});
|
|
172
|
+
await parentFrontier();
|
|
173
|
+
checkEmptyConfigureHistory(await childFrontier(false), state.reservation);
|
|
174
|
+
return finishConfigureLineage(token);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
closeConfigureLineage(token);
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
import type { Value } from "convex/values";
|
|
3
|
+
import {
|
|
4
|
+
admitJournalValue,
|
|
5
|
+
canonicalJournalRecord,
|
|
6
|
+
journalReservationMaterial,
|
|
7
|
+
} from "../../../../../shared/renewalOperationJournal.js";
|
|
8
|
+
import { closed } from "../operations/types.js";
|
|
9
|
+
|
|
10
|
+
export function configureAdmissionStop(): never {
|
|
11
|
+
throw Error("CONFIGURE_ADMISSION_UNBOUND");
|
|
12
|
+
}
|
|
13
|
+
export function requireConfigure(value: unknown): asserts value {
|
|
14
|
+
if (!value) configureAdmissionStop();
|
|
15
|
+
}
|
|
16
|
+
export function text(value: unknown): string {
|
|
17
|
+
requireConfigure(typeof value === "string" && value.length > 0);
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
export function object(raw: unknown): Record<string, unknown> {
|
|
21
|
+
requireConfigure(
|
|
22
|
+
raw &&
|
|
23
|
+
typeof raw === "object" &&
|
|
24
|
+
!types.isProxy(raw) &&
|
|
25
|
+
!Array.isArray(raw),
|
|
26
|
+
);
|
|
27
|
+
const keys = Reflect.ownKeys(raw);
|
|
28
|
+
requireConfigure(
|
|
29
|
+
keys.length <= 10000 && keys.every((key) => typeof key === "string"),
|
|
30
|
+
);
|
|
31
|
+
return closed(
|
|
32
|
+
raw,
|
|
33
|
+
keys.filter((key): key is string => typeof key === "string"),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
/** Complete own-DATA equality, then the actual component return-value byte limit.
|
|
37
|
+
* Expected values are independently constructed finite wire DATA, not API types.
|
|
38
|
+
*/
|
|
39
|
+
export function matchConfigureDATA(raw: unknown, expected: unknown): void {
|
|
40
|
+
let nodes = 0;
|
|
41
|
+
function match(value: unknown, wanted: unknown, depth: number): void {
|
|
42
|
+
requireConfigure(++nodes <= 10000 && depth <= 40 && !types.isProxy(value));
|
|
43
|
+
if (wanted === null || typeof wanted !== "object") {
|
|
44
|
+
requireConfigure(value === wanted);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(wanted)) {
|
|
48
|
+
requireConfigure(
|
|
49
|
+
Array.isArray(value) &&
|
|
50
|
+
Object.getPrototypeOf(value) === Array.prototype &&
|
|
51
|
+
value.length === wanted.length,
|
|
52
|
+
);
|
|
53
|
+
const own = Reflect.ownKeys(value);
|
|
54
|
+
requireConfigure(own.length === wanted.length + 1);
|
|
55
|
+
for (let index = 0; index < wanted.length; index++) {
|
|
56
|
+
const d = Object.getOwnPropertyDescriptor(value, String(index));
|
|
57
|
+
requireConfigure(d && d.enumerable && "value" in d);
|
|
58
|
+
match(d.value, wanted[index], depth + 1);
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const actual = closed(value, Object.keys(wanted));
|
|
63
|
+
for (const [key, child] of Object.entries(wanted))
|
|
64
|
+
match(actual[key], child, depth + 1);
|
|
65
|
+
}
|
|
66
|
+
match(raw, expected, 0);
|
|
67
|
+
// The complete finite graph has just been matched, before this DATA-only cast.
|
|
68
|
+
admitJournalValue(expected as Value);
|
|
69
|
+
}
|
|
70
|
+
const reservationKeys = [
|
|
71
|
+
"operationId",
|
|
72
|
+
"attemptId",
|
|
73
|
+
"payloadId",
|
|
74
|
+
"authorizationScope",
|
|
75
|
+
"authorizationId",
|
|
76
|
+
"authorizationRevision",
|
|
77
|
+
"logicalOperationId",
|
|
78
|
+
"requestBinding",
|
|
79
|
+
"key",
|
|
80
|
+
"apiVersion",
|
|
81
|
+
"accountJSON",
|
|
82
|
+
"firstDispatchedAt",
|
|
83
|
+
"ordinal",
|
|
84
|
+
"preparedRevision",
|
|
85
|
+
"committedRevision",
|
|
86
|
+
"recordJSON",
|
|
87
|
+
"stage",
|
|
88
|
+
"recordVersion",
|
|
89
|
+
"timingPolicyJSON",
|
|
90
|
+
];
|
|
91
|
+
/** Rebuild the complete current wire contract; generated references stay untouched. */
|
|
92
|
+
export function captureOperationalReservation(
|
|
93
|
+
raw: unknown,
|
|
94
|
+
stage: "attach" | "configure",
|
|
95
|
+
) {
|
|
96
|
+
const own = closed(raw, reservationKeys);
|
|
97
|
+
const full = canonicalJournalRecord(text(own.recordJSON));
|
|
98
|
+
const material = journalReservationMaterial(full);
|
|
99
|
+
requireConfigure("recordVersion" in material && material.stage === stage);
|
|
100
|
+
const id = (value: unknown) => {
|
|
101
|
+
const result = text(value);
|
|
102
|
+
requireConfigure(result.length <= 255);
|
|
103
|
+
return result;
|
|
104
|
+
};
|
|
105
|
+
const result = Object.freeze({
|
|
106
|
+
operationId: id(own.operationId),
|
|
107
|
+
attemptId: id(own.attemptId),
|
|
108
|
+
payloadId: id(own.payloadId),
|
|
109
|
+
authorizationScope: full.authorizationScope,
|
|
110
|
+
authorizationId: full.authorizationId,
|
|
111
|
+
authorizationRevision: full.authorizationRevision,
|
|
112
|
+
logicalOperationId: full.logicalOperationId,
|
|
113
|
+
requestBinding: full.requestBinding,
|
|
114
|
+
ordinal: 1 as const,
|
|
115
|
+
preparedRevision: 0 as const,
|
|
116
|
+
committedRevision: 1 as const,
|
|
117
|
+
recordJSON: full.json,
|
|
118
|
+
...material,
|
|
119
|
+
stage,
|
|
120
|
+
});
|
|
121
|
+
matchConfigureDATA(raw, result);
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
export type OperationalReservationDATA = ReturnType<
|
|
125
|
+
typeof captureOperationalReservation
|
|
126
|
+
>;
|
|
127
|
+
export function configureBasisDescriptor(
|
|
128
|
+
reservation: OperationalReservationDATA,
|
|
129
|
+
basisJSON: string,
|
|
130
|
+
) {
|
|
131
|
+
return {
|
|
132
|
+
version: 1 as const,
|
|
133
|
+
attemptId: reservation.attemptId,
|
|
134
|
+
sourcePayloadId: reservation.payloadId,
|
|
135
|
+
stage: reservation.stage,
|
|
136
|
+
policyJSON: reservation.timingPolicyJSON,
|
|
137
|
+
basisJSON,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export function checkOperationLoad(
|
|
141
|
+
raw: unknown,
|
|
142
|
+
reservation: OperationalReservationDATA,
|
|
143
|
+
basisJSON: string,
|
|
144
|
+
allowUnbound = false,
|
|
145
|
+
) {
|
|
146
|
+
const own = closed(raw, [
|
|
147
|
+
"operationId",
|
|
148
|
+
"recordJSON",
|
|
149
|
+
"revision",
|
|
150
|
+
"recordVersion",
|
|
151
|
+
"activeAttempt",
|
|
152
|
+
"initialBasis",
|
|
153
|
+
]);
|
|
154
|
+
const { recordJSON, ...summary } = reservation;
|
|
155
|
+
const basis =
|
|
156
|
+
allowUnbound && own.initialBasis === null
|
|
157
|
+
? null
|
|
158
|
+
: configureBasisDescriptor(reservation, basisJSON);
|
|
159
|
+
matchConfigureDATA(raw, {
|
|
160
|
+
operationId: reservation.operationId,
|
|
161
|
+
recordJSON,
|
|
162
|
+
revision: 1,
|
|
163
|
+
recordVersion: 2,
|
|
164
|
+
activeAttempt: summary,
|
|
165
|
+
initialBasis: basis,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
export function checkEmptyConfigureHistory(
|
|
169
|
+
raw: unknown,
|
|
170
|
+
reservation: OperationalReservationDATA,
|
|
171
|
+
) {
|
|
172
|
+
matchConfigureDATA(raw, { reservation, events: [] });
|
|
173
|
+
}
|
|
174
|
+
export function captureParentHistory(
|
|
175
|
+
raw: unknown,
|
|
176
|
+
reservation: OperationalReservationDATA,
|
|
177
|
+
) {
|
|
178
|
+
const own = closed(raw, ["reservation", "events"]);
|
|
179
|
+
requireConfigure(
|
|
180
|
+
!types.isProxy(own.events) &&
|
|
181
|
+
Array.isArray(own.events) &&
|
|
182
|
+
Object.getPrototypeOf(own.events) === Array.prototype &&
|
|
183
|
+
own.events.length === 3,
|
|
184
|
+
);
|
|
185
|
+
const events = Array.from({ length: 3 }, (_, index) => {
|
|
186
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
187
|
+
own.events,
|
|
188
|
+
String(index),
|
|
189
|
+
);
|
|
190
|
+
requireConfigure(
|
|
191
|
+
descriptor && descriptor.enumerable && "value" in descriptor,
|
|
192
|
+
);
|
|
193
|
+
const event = closed(descriptor.value, [
|
|
194
|
+
"operationId",
|
|
195
|
+
"attemptId",
|
|
196
|
+
"stage",
|
|
197
|
+
"sourcePayloadId",
|
|
198
|
+
"sequence",
|
|
199
|
+
"binding",
|
|
200
|
+
"payloadId",
|
|
201
|
+
"eventId",
|
|
202
|
+
]);
|
|
203
|
+
return {
|
|
204
|
+
operationId: reservation.operationId,
|
|
205
|
+
attemptId: reservation.attemptId,
|
|
206
|
+
stage: "attach" as const,
|
|
207
|
+
sourcePayloadId: reservation.payloadId,
|
|
208
|
+
sequence:
|
|
209
|
+
index === 0 ? (1 as const) : index === 1 ? (2 as const) : (3 as const),
|
|
210
|
+
binding: text(event.binding),
|
|
211
|
+
payloadId: text(event.payloadId),
|
|
212
|
+
eventId: text(event.eventId),
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
requireConfigure(
|
|
216
|
+
new Set(events.map((event) => event.eventId)).size === 3 &&
|
|
217
|
+
new Set(events.map((event) => event.payloadId)).size === 3,
|
|
218
|
+
);
|
|
219
|
+
matchConfigureDATA(raw, { reservation, events });
|
|
220
|
+
return events;
|
|
221
|
+
}
|
|
222
|
+
export function checkParentAcknowledgement(
|
|
223
|
+
raw: unknown,
|
|
224
|
+
reservation: OperationalReservationDATA,
|
|
225
|
+
events: ReturnType<typeof captureParentHistory>,
|
|
226
|
+
receiptJSON: string,
|
|
227
|
+
receiptBinding: string,
|
|
228
|
+
) {
|
|
229
|
+
const own = closed(raw, ["retention", "receiptJSON"]);
|
|
230
|
+
const retained = object(own.retention);
|
|
231
|
+
matchConfigureDATA(raw, {
|
|
232
|
+
receiptJSON,
|
|
233
|
+
retention: {
|
|
234
|
+
status: "retained",
|
|
235
|
+
operationId: reservation.operationId,
|
|
236
|
+
schemaVersion: 1,
|
|
237
|
+
stage: "attach",
|
|
238
|
+
attemptId: reservation.attemptId,
|
|
239
|
+
sourcePayloadId: reservation.payloadId,
|
|
240
|
+
dispatchEventId: events[0].eventId,
|
|
241
|
+
dispatchPayloadId: events[0].payloadId,
|
|
242
|
+
responseEventId: events[1].eventId,
|
|
243
|
+
responsePayloadId: events[1].payloadId,
|
|
244
|
+
receiptPayloadId: text(retained.receiptPayloadId),
|
|
245
|
+
receiptBinding,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
}
|