@fantastic.dev/better-stripe 0.102.0 → 0.103.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 +6 -0
- package/README.md +1 -1
- package/dist/client/billing/renewalAttach/internal/c10/appendAck.d.ts +7 -0
- package/dist/client/billing/renewalAttach/internal/c10/appendAck.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/c10/appendAck.js +13 -1
- package/dist/client/billing/renewalAttach/internal/c10/appendAck.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/c10/configureEvents.d.ts +23 -0
- package/dist/client/billing/renewalAttach/internal/c10/configureEvents.d.ts.map +1 -1
- package/dist/client/billing/renewalAttach/internal/c10/configureEvents.js +34 -2
- package/dist/client/billing/renewalAttach/internal/c10/configureEvents.js.map +1 -1
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts +6 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.d.ts.map +1 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.js +49 -0
- package/dist/client/billing/renewalAttach/internal/producer/configureJournalWork.js.map +1 -0
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
- package/dist/component/balanceFunding/mutations.d.ts +16 -16
- 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 +16 -16
- 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/usage/allowance.fixtures.d.ts +16 -16
- package/docs/renewal-context-reads.md +40 -4
- package/package.json +1 -1
- package/src/client/billing/renewalAttach/internal/c10/appendAck.ts +17 -0
- package/src/client/billing/renewalAttach/internal/c10/configureEvents.ts +45 -2
- package/src/client/billing/renewalAttach/internal/producer/configureJournalWork.ts +53 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureChannelControls.integration.test.ts +542 -0
- package/src/client/billing/renewalAttach/internal/producer/producerConfigureChannels.integration.test.ts +321 -0
- package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +38 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/queries.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIlB,CAAC;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiBd,CAAC;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;GAQf,CAAC;AAEH,4FAA4F;AAC5F,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/queries.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIlB,CAAC;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiBd,CAAC;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;GAQf,CAAC;AAEH,4FAA4F;AAC5F,eAAO,MAAM,QAAQ;;;;;;YAsBE,MAAM;YAAmB,gBAAgB;;;YAS3C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAE1B,CAAC"}
|
|
@@ -14,7 +14,7 @@ export declare function checkRollback(ctx: MutationCtx, op: Doc<"processingCostR
|
|
|
14
14
|
readonly bindFunding?: undefined;
|
|
15
15
|
} | {
|
|
16
16
|
reason?: undefined;
|
|
17
|
-
|
|
17
|
+
retryable?: undefined;
|
|
18
18
|
readonly status: "ready";
|
|
19
19
|
readonly bindFunding: boolean;
|
|
20
20
|
}>;
|
|
@@ -2632,14 +2632,6 @@ export declare function setupAllowance(): Promise<{
|
|
|
2632
2632
|
preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
|
|
2633
2633
|
requestKey: string;
|
|
2634
2634
|
result?: {
|
|
2635
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2636
|
-
retryable: false;
|
|
2637
|
-
status: "conflict";
|
|
2638
|
-
} | {
|
|
2639
|
-
reason: "policy_invalid";
|
|
2640
|
-
retryable: false;
|
|
2641
|
-
status: "rejected";
|
|
2642
|
-
} | {
|
|
2643
2635
|
operation: {
|
|
2644
2636
|
accountId: string;
|
|
2645
2637
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -2650,6 +2642,14 @@ export declare function setupAllowance(): Promise<{
|
|
|
2650
2642
|
} | {
|
|
2651
2643
|
enabled: boolean;
|
|
2652
2644
|
status: "unchanged";
|
|
2645
|
+
} | {
|
|
2646
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2647
|
+
retryable: false;
|
|
2648
|
+
status: "conflict";
|
|
2649
|
+
} | {
|
|
2650
|
+
reason: "policy_invalid";
|
|
2651
|
+
retryable: false;
|
|
2652
|
+
status: "rejected";
|
|
2653
2653
|
} | {
|
|
2654
2654
|
reason: "provider_pending";
|
|
2655
2655
|
retryable: true;
|
|
@@ -2660,14 +2660,6 @@ export declare function setupAllowance(): Promise<{
|
|
|
2660
2660
|
payload: import("convex/values").VString<string, "required">;
|
|
2661
2661
|
preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
|
|
2662
2662
|
result: import("convex/values").VUnion<{
|
|
2663
|
-
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2664
|
-
retryable: false;
|
|
2665
|
-
status: "conflict";
|
|
2666
|
-
} | {
|
|
2667
|
-
reason: "policy_invalid";
|
|
2668
|
-
retryable: false;
|
|
2669
|
-
status: "rejected";
|
|
2670
|
-
} | {
|
|
2671
2663
|
operation: {
|
|
2672
2664
|
accountId: string;
|
|
2673
2665
|
operationId: import("convex/values").GenericId<"balanceFundingOperations">;
|
|
@@ -2678,6 +2670,14 @@ export declare function setupAllowance(): Promise<{
|
|
|
2678
2670
|
} | {
|
|
2679
2671
|
enabled: boolean;
|
|
2680
2672
|
status: "unchanged";
|
|
2673
|
+
} | {
|
|
2674
|
+
reason: "identity_changed" | "revision_changed" | "scope_busy";
|
|
2675
|
+
retryable: false;
|
|
2676
|
+
status: "conflict";
|
|
2677
|
+
} | {
|
|
2678
|
+
reason: "policy_invalid";
|
|
2679
|
+
retryable: false;
|
|
2680
|
+
status: "rejected";
|
|
2681
2681
|
} | {
|
|
2682
2682
|
reason: "provider_pending";
|
|
2683
2683
|
retryable: true;
|
|
@@ -262,10 +262,46 @@ committed; retained DATA and failed or lost replies cannot remint the consumed
|
|
|
262
262
|
call.
|
|
263
263
|
|
|
264
264
|
The result is an opaque private view containing `owner`, `basisJSON` and
|
|
265
|
-
`operationalAuthority: false`.
|
|
266
|
-
preflight/write
|
|
267
|
-
required, as do genuine generation and operational qualification.
|
|
268
|
-
Source profile arrays remain empty.
|
|
265
|
+
`operationalAuthority: false`. The separate private C10 factory below can use
|
|
266
|
+
that identity. Configure transport, preflight/write actors and public scheduling
|
|
267
|
+
remain required, as do genuine generation and operational qualification.
|
|
268
|
+
Production Source profile arrays remain empty.
|
|
269
|
+
|
|
270
|
+
## Private configure C10 channel
|
|
271
|
+
|
|
272
|
+
`createAdmittedConfigureEventCompiler(token)` accepts only the actual admitted
|
|
273
|
+
child identity. It captures one configure channel, including when capture fails;
|
|
274
|
+
callers cannot replace its source, sender, Owner or options. Copied views and
|
|
275
|
+
proxy identities cannot create another channel. The retained raw C6 configuration
|
|
276
|
+
supplies its source. The compiler reconstructs C7 dispatch and complete C9 receipt
|
|
277
|
+
DATA and compares each event before appending sequences 1 through 3 to the child
|
|
278
|
+
attempt. The parent attachment history remains separate.
|
|
279
|
+
|
|
280
|
+
The channel derives the canonical Owner from the original parent token. A fixed
|
|
281
|
+
synchronous child guard adds binding and custody checks at every channel gate,
|
|
282
|
+
including after hashing and around append/ACK handling and awaits. The guard
|
|
283
|
+
must return undefined; asynchronous or other non-void results refuse. It cannot
|
|
284
|
+
replace the Owner checks or retirement subscription. The guarded parent kernel
|
|
285
|
+
stays independent of configure lineage code, preserving the existing legacy
|
|
286
|
+
compiler and avoiding an import cycle.
|
|
287
|
+
|
|
288
|
+
The sender receives the exact original reservation object from the actual child
|
|
289
|
+
CAS and uses its original class-bound journal. A captured DATA copy is
|
|
290
|
+
insufficient. The actual component append must commit and return its matching
|
|
291
|
+
complete reply before C10 acknowledgement. Per-child work tracking follows the
|
|
292
|
+
actual append RPC promise independently of a channel timeout. A timed-out channel
|
|
293
|
+
can remain closed while a committed mutation reply is still pending. Late replies
|
|
294
|
+
cannot reopen it. Separate child and SDK-root channels retain their own sequence,
|
|
295
|
+
work and retirement state.
|
|
296
|
+
|
|
297
|
+
C10 append acknowledgement establishes DATA consistency only. Dispatch intent,
|
|
298
|
+
a committed response or receipt event, and a retained C9 do not establish provider
|
|
299
|
+
custody, returned configure ACK custody, pending/effective replacement or fresh
|
|
300
|
+
dispatch permission. Receipt retention remains a separate operation; a future
|
|
301
|
+
configure completion pipeline must retain the complete C9 before publishing
|
|
302
|
+
receipt event 3 and returning its actual acknowledgement. Future execution also
|
|
303
|
+
requires its own frontier checks. This channel factory supplies no provider
|
|
304
|
+
transport or preflight/write actor and activates no operational Source profile.
|
|
269
305
|
|
|
270
306
|
## Component operation journal
|
|
271
307
|
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Stage and append share one irreversible latch and the same original owner. */
|
|
2
|
+
import { types } from "node:util";
|
|
2
3
|
import { SOURCE_OWNER } from "./ownerBinding.js";
|
|
3
4
|
import { ownerForInitialLineage } from "../producer/ownerFactory.js";
|
|
4
5
|
import {
|
|
@@ -24,9 +25,23 @@ export function createStageChannel(raw: unknown) {
|
|
|
24
25
|
export function createInitialStageChannel(token: object, raw: unknown) {
|
|
25
26
|
return stageChannel(raw, ownerForInitialLineage(token));
|
|
26
27
|
}
|
|
28
|
+
/** A fixed internal guard can add checks, never replace the canonical Owner. */
|
|
29
|
+
export function createGuardedInitialStageChannel(
|
|
30
|
+
token: object,
|
|
31
|
+
raw: unknown,
|
|
32
|
+
guard: () => unknown,
|
|
33
|
+
) {
|
|
34
|
+
need(
|
|
35
|
+
arguments.length === 3 &&
|
|
36
|
+
typeof guard === "function" &&
|
|
37
|
+
!types.isProxy(guard),
|
|
38
|
+
);
|
|
39
|
+
return stageChannel(raw, ownerForInitialLineage(token), guard);
|
|
40
|
+
}
|
|
27
41
|
function stageChannel(
|
|
28
42
|
raw: unknown,
|
|
29
43
|
owner: Pick<typeof SOURCE_OWNER, "basis" | "check" | "subscribe">,
|
|
44
|
+
guard?: () => unknown,
|
|
30
45
|
) {
|
|
31
46
|
let closedChannel = false,
|
|
32
47
|
unsubscribe = () => {},
|
|
@@ -44,7 +59,9 @@ function stageChannel(
|
|
|
44
59
|
const gate = (): Time => {
|
|
45
60
|
try {
|
|
46
61
|
need(!closedChannel);
|
|
62
|
+
if (guard) need(guard() === undefined);
|
|
47
63
|
const t = owner.check();
|
|
64
|
+
if (guard) need(guard() === undefined);
|
|
48
65
|
need(
|
|
49
66
|
basis &&
|
|
50
67
|
Number.isSafeInteger(basis.startWallMs) &&
|
|
@@ -12,13 +12,56 @@ import {
|
|
|
12
12
|
captureConfigureReceipt,
|
|
13
13
|
} from "./eventCapture.js";
|
|
14
14
|
import { materialize } from "./eventCodec.js";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
createStageChannel,
|
|
17
|
+
createGuardedInitialStageChannel,
|
|
18
|
+
} from "./appendAck.js";
|
|
19
|
+
import { readConfigureLineage } from "../producer/configureLineage.js";
|
|
20
|
+
import { journalWorkForConfigureLineage } from "../producer/configureJournalWork.js";
|
|
16
21
|
import {
|
|
17
22
|
projectRenewalConfigurationV2,
|
|
18
23
|
constructRenewalConfigurationReceiptV2,
|
|
19
24
|
} from "./publicApi.js";
|
|
20
25
|
export function createConfigureEventCompiler(raw: unknown, options: unknown) {
|
|
21
|
-
|
|
26
|
+
return configureEventCompiler(raw, createStageChannel(options));
|
|
27
|
+
}
|
|
28
|
+
const admittedChannels = new WeakSet<object>();
|
|
29
|
+
/** One exact admitted child, without replacement source, sender or Owner inputs. */
|
|
30
|
+
export function createAdmittedConfigureEventCompiler(token: object) {
|
|
31
|
+
if (typeof token !== "object" || token === null)
|
|
32
|
+
throw Error("CONFIGURE_CHANNEL_UNBOUND");
|
|
33
|
+
if (admittedChannels.has(token)) throw Error("CONFIGURE_CHANNEL_CONSUMED");
|
|
34
|
+
admittedChannels.add(token);
|
|
35
|
+
if (arguments.length !== 1) throw Error("CONFIGURE_CHANNEL_UNBOUND");
|
|
36
|
+
const lineage = readConfigureLineage(token);
|
|
37
|
+
const send = journalWorkForConfigureLineage(token).captureSend();
|
|
38
|
+
const guard = () => {
|
|
39
|
+
readConfigureLineage(token);
|
|
40
|
+
};
|
|
41
|
+
const channel = createGuardedInitialStageChannel(
|
|
42
|
+
lineage.parentToken,
|
|
43
|
+
{
|
|
44
|
+
timeoutMs: 5000,
|
|
45
|
+
send(
|
|
46
|
+
record: Parameters<typeof send>[0],
|
|
47
|
+
ack: Parameters<typeof send>[1],
|
|
48
|
+
) {
|
|
49
|
+
guard();
|
|
50
|
+
return send(record, (value) => {
|
|
51
|
+
guard();
|
|
52
|
+
ack(value);
|
|
53
|
+
guard();
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
guard,
|
|
58
|
+
);
|
|
59
|
+
return configureEventCompiler(lineage.configuration, channel);
|
|
60
|
+
}
|
|
61
|
+
function configureEventCompiler(
|
|
62
|
+
raw: unknown,
|
|
63
|
+
channel: ReturnType<typeof createStageChannel>,
|
|
64
|
+
) {
|
|
22
65
|
let source: ReturnType<typeof captureConfigureSource>;
|
|
23
66
|
try {
|
|
24
67
|
channel.gate();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { readConfigureLineage } from "./configureLineage.js";
|
|
2
|
+
import { requireConfigure } from "./configureJournalData.js";
|
|
3
|
+
|
|
4
|
+
const journals = new WeakMap<object, ReturnType<typeof construct>>();
|
|
5
|
+
function construct(token: object) {
|
|
6
|
+
const original = readConfigureLineage(token);
|
|
7
|
+
let pending = 0;
|
|
8
|
+
function gate() {
|
|
9
|
+
const current = readConfigureLineage(token);
|
|
10
|
+
requireConfigure(
|
|
11
|
+
current.journal === original.journal &&
|
|
12
|
+
current.originalReservation === original.originalReservation &&
|
|
13
|
+
current.owner === original.owner,
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return Object.freeze({
|
|
17
|
+
captureSend() {
|
|
18
|
+
requireConfigure(arguments.length === 0);
|
|
19
|
+
gate();
|
|
20
|
+
// Original class-owned object custody; captured reservation DATA cannot send.
|
|
21
|
+
const send = original.journal.createC10Send(original.originalReservation);
|
|
22
|
+
return async (
|
|
23
|
+
record: Parameters<typeof send>[0],
|
|
24
|
+
ack: Parameters<typeof send>[1],
|
|
25
|
+
) => {
|
|
26
|
+
gate();
|
|
27
|
+
pending++;
|
|
28
|
+
try {
|
|
29
|
+
await send(record, ack);
|
|
30
|
+
gate();
|
|
31
|
+
} finally {
|
|
32
|
+
pending--;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
idle() {
|
|
37
|
+
requireConfigure(arguments.length === 0);
|
|
38
|
+
gate();
|
|
39
|
+
return pending === 0;
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Actual RPC settlement is tracked independently of channel closure or timeout. */
|
|
44
|
+
export function journalWorkForConfigureLineage(token: object) {
|
|
45
|
+
requireConfigure(arguments.length === 1);
|
|
46
|
+
readConfigureLineage(token);
|
|
47
|
+
let work = journals.get(token);
|
|
48
|
+
if (!work) {
|
|
49
|
+
work = construct(token);
|
|
50
|
+
journals.set(token, work);
|
|
51
|
+
}
|
|
52
|
+
return work;
|
|
53
|
+
}
|