@fantastic.dev/better-stripe 0.107.0 → 0.109.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 (59) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts +31 -0
  4. package/dist/client/billing/renewalAttach/internal/observation/freshActor.d.ts.map +1 -0
  5. package/dist/client/billing/renewalAttach/internal/observation/freshActor.js +112 -0
  6. package/dist/client/billing/renewalAttach/internal/observation/freshActor.js.map +1 -0
  7. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts +17 -0
  8. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.d.ts.map +1 -0
  9. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js +191 -0
  10. package/dist/client/billing/renewalAttach/internal/observation/freshTransport.js.map +1 -0
  11. package/dist/client/billing/renewalAttach/internal/observation/invocation.d.ts +29 -0
  12. package/dist/client/billing/renewalAttach/internal/observation/invocation.d.ts.map +1 -0
  13. package/dist/client/billing/renewalAttach/internal/observation/invocation.js +205 -0
  14. package/dist/client/billing/renewalAttach/internal/observation/invocation.js.map +1 -0
  15. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +1 -0
  16. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -1
  17. package/dist/client/billing/renewalAttach/internal/observation/profile.js +5 -1
  18. package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -1
  19. package/dist/client/billing/renewalAttach/internal/observation/reader.d.ts +10 -0
  20. package/dist/client/billing/renewalAttach/internal/observation/reader.d.ts.map +1 -0
  21. package/dist/client/billing/renewalAttach/internal/observation/reader.js +30 -0
  22. package/dist/client/billing/renewalAttach/internal/observation/reader.js.map +1 -0
  23. package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts +44 -0
  24. package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.d.ts.map +1 -0
  25. package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js +145 -0
  26. package/dist/client/billing/renewalAttach/internal/observation/readerAuthorization.js.map +1 -0
  27. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +9 -0
  28. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -1
  29. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +2 -0
  30. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -1
  31. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +2 -0
  32. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -1
  33. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +9 -0
  34. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -1
  35. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
  36. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  37. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  38. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  39. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  40. package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
  41. package/docs/renewal-context-reads.md +107 -0
  42. package/package.json +1 -1
  43. package/src/client/billing/renewalAttach/internal/observation/freshActor.integration.test.ts +360 -0
  44. package/src/client/billing/renewalAttach/internal/observation/freshActor.ts +175 -0
  45. package/src/client/billing/renewalAttach/internal/observation/freshActorControls.integration.test.ts +442 -0
  46. package/src/client/billing/renewalAttach/internal/observation/freshTransport.ts +252 -0
  47. package/src/client/billing/renewalAttach/internal/observation/invocation.ts +299 -0
  48. package/src/client/billing/renewalAttach/internal/observation/profile.ts +9 -1
  49. package/src/client/billing/renewalAttach/internal/observation/reader.integration.test.ts +93 -0
  50. package/src/client/billing/renewalAttach/internal/observation/reader.ts +35 -0
  51. package/src/client/billing/renewalAttach/internal/observation/readerAuthorization.ts +179 -0
  52. package/src/client/billing/renewalAttach/internal/observation/readerControls.integration.test.ts +553 -0
  53. package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +11 -0
  54. package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +12 -0
  55. package/src/client/billing/renewalAttach/internal/test-fixtures/freshObservation.ts +94 -0
  56. package/src/client/billing/renewalAttach/internal/test-fixtures/historySnapshot.ts +5 -1
  57. package/src/client/billing/renewalAttach/internal/test-fixtures/observationReader.ts +101 -0
  58. package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +41 -4
  59. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +5 -1
@@ -2642,14 +2642,6 @@ export declare function setup(amounts?: number[]): Promise<{
2642
2642
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
2643
2643
  requestKey: string;
2644
2644
  result?: {
2645
- reason: "identity_changed" | "revision_changed" | "scope_busy";
2646
- retryable: false;
2647
- status: "conflict";
2648
- } | {
2649
- reason: "policy_invalid";
2650
- retryable: false;
2651
- status: "rejected";
2652
- } | {
2653
2645
  operation: {
2654
2646
  accountId: string;
2655
2647
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -2660,6 +2652,14 @@ export declare function setup(amounts?: number[]): Promise<{
2660
2652
  } | {
2661
2653
  enabled: boolean;
2662
2654
  status: "unchanged";
2655
+ } | {
2656
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
2657
+ retryable: false;
2658
+ status: "conflict";
2659
+ } | {
2660
+ reason: "policy_invalid";
2661
+ retryable: false;
2662
+ status: "rejected";
2663
2663
  } | {
2664
2664
  reason: "provider_pending";
2665
2665
  retryable: true;
@@ -2670,14 +2670,6 @@ export declare function setup(amounts?: number[]): Promise<{
2670
2670
  payload: import("convex/values").VString<string, "required">;
2671
2671
  preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
2672
2672
  result: import("convex/values").VUnion<{
2673
- reason: "identity_changed" | "revision_changed" | "scope_busy";
2674
- retryable: false;
2675
- status: "conflict";
2676
- } | {
2677
- reason: "policy_invalid";
2678
- retryable: false;
2679
- status: "rejected";
2680
- } | {
2681
2673
  operation: {
2682
2674
  accountId: string;
2683
2675
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -2688,6 +2680,14 @@ export declare function setup(amounts?: number[]): Promise<{
2688
2680
  } | {
2689
2681
  enabled: boolean;
2690
2682
  status: "unchanged";
2683
+ } | {
2684
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
2685
+ retryable: false;
2686
+ status: "conflict";
2687
+ } | {
2688
+ reason: "policy_invalid";
2689
+ retryable: false;
2690
+ status: "rejected";
2691
2691
  } | {
2692
2692
  reason: "provider_pending";
2693
2693
  retryable: true;
@@ -9,6 +9,17 @@ export declare const bridge: import("convex/server").RegisteredAction<"internal"
9
9
  stripeSubscriptionId: string;
10
10
  version: number;
11
11
  }, Promise<{
12
+ status: "ready";
13
+ value: {
14
+ customerAccount: string;
15
+ enabled?: boolean | undefined;
16
+ paymentMethodId: string | null;
17
+ paymentMethodTypes?: string[] | null | undefined;
18
+ phase: "apply" | "attach" | "create";
19
+ providerApiVersion: string;
20
+ stripeSubscriptionId: string;
21
+ };
22
+ } | {
12
23
  reason: "history_incomplete" | "provider_outcome_unknown";
13
24
  retryable: false;
14
25
  status: "unknown";
@@ -24,16 +35,5 @@ export declare const bridge: import("convex/server").RegisteredAction<"internal"
24
35
  reason: "provider_pending";
25
36
  retryable: true;
26
37
  status: "not_ready";
27
- } | {
28
- status: "ready";
29
- value: {
30
- customerAccount: string;
31
- enabled?: boolean | undefined;
32
- paymentMethodId: string | null;
33
- paymentMethodTypes?: string[] | null | undefined;
34
- phase: "apply" | "attach" | "create";
35
- providerApiVersion: string;
36
- stripeSubscriptionId: string;
37
- };
38
38
  }>>;
39
39
  //# sourceMappingURL=actions.d.ts.map
@@ -2,6 +2,14 @@ import type { Infer } from "convex/values";
2
2
  import type { MutationCtx } from "../_generated/server.js";
3
3
  import { prepareArgs, finishPreparationArgs } from "./mutationValidators.js";
4
4
  export declare function prepareHandler(ctx: MutationCtx, args: Infer<typeof prepareArgs>): Promise<{
5
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
6
+ retryable: false;
7
+ status: "conflict";
8
+ } | {
9
+ reason: "policy_invalid";
10
+ retryable: false;
11
+ status: "rejected";
12
+ } | {
5
13
  operation: {
6
14
  accountId: string;
7
15
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -12,14 +20,6 @@ export declare function prepareHandler(ctx: MutationCtx, args: Infer<typeof prep
12
20
  } | {
13
21
  enabled: boolean;
14
22
  status: "unchanged";
15
- } | {
16
- reason: "identity_changed" | "revision_changed" | "scope_busy";
17
- retryable: false;
18
- status: "conflict";
19
- } | {
20
- reason: "policy_invalid";
21
- retryable: false;
22
- status: "rejected";
23
23
  } | {
24
24
  reason: "provider_pending";
25
25
  retryable: true;
@@ -9,9 +9,9 @@ export declare function legOwnership(ctx: MutationCtx, bucketKey: string, prior:
9
9
  orgId: string | undefined;
10
10
  ownershipStatus: "ambiguous";
11
11
  } | {
12
+ registrationId?: undefined;
12
13
  userId?: undefined;
13
14
  orgId?: undefined;
14
- registrationId?: undefined;
15
15
  ownershipStatus: "ambiguous";
16
16
  } | {
17
17
  registrationId: import("convex/values").GenericId<"financialOwnership">;
@@ -19,9 +19,9 @@ export declare function legOwnership(ctx: MutationCtx, bucketKey: string, prior:
19
19
  orgId: string | undefined;
20
20
  ownershipStatus: "unknown";
21
21
  } | {
22
+ registrationId?: undefined;
22
23
  userId?: undefined;
23
24
  orgId?: undefined;
24
- registrationId?: undefined;
25
25
  ownershipStatus: "unknown";
26
26
  } | {
27
27
  registrationId: import("convex/values").GenericId<"financialOwnership">;
@@ -29,9 +29,9 @@ export declare function legOwnership(ctx: MutationCtx, bucketKey: string, prior:
29
29
  orgId: string | undefined;
30
30
  ownershipStatus: "contradictory";
31
31
  } | {
32
+ registrationId?: undefined;
32
33
  userId?: undefined;
33
34
  orgId?: undefined;
34
- registrationId?: undefined;
35
35
  ownershipStatus: "contradictory";
36
36
  } | {
37
37
  registrationId: import("convex/values").GenericId<"financialOwnership">;
@@ -2632,6 +2632,14 @@ export declare function setupCredits(): 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
+ } | {
2635
2643
  operation: {
2636
2644
  accountId: string;
2637
2645
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -2642,14 +2650,6 @@ export declare function setupCredits(): Promise<{
2642
2650
  } | {
2643
2651
  enabled: boolean;
2644
2652
  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,6 +2660,14 @@ export declare function setupCredits(): 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
+ } | {
2663
2671
  operation: {
2664
2672
  accountId: string;
2665
2673
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -2670,14 +2678,6 @@ export declare function setupCredits(): Promise<{
2670
2678
  } | {
2671
2679
  enabled: boolean;
2672
2680
  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;
@@ -942,3 +942,110 @@ future-period observation entry still needs fresh host authorization, a separate
942
942
  bounded GET-only lifetime and complete lifecycle/invoice/history acquisition.
943
943
  Production Source profiles remain empty. Provider qualification, genuine
944
944
  generation/deployed compatibility and final Dojo acceptance remain outstanding.
945
+
946
+ ### Private fresh authorized history reader
947
+
948
+ `captureAuthorizedObservationHistoryReader` supplies a private once-only `read()`
949
+ method for a freshly authenticated Action. Its production compiled entry list is
950
+ empty and refuses before root, Action or clock reflection. An enabled trusted
951
+ entry must bind the exact maintained SDK component object, a stable installation
952
+ scope key and a real host authorization query reference. The class bootstrap
953
+ retains its existing three fields. Calling Action metadata does not identify the
954
+ target component for authorization.
955
+
956
+ The host query receives exactly the installation scope, attachment operation ID
957
+ and configure operation ID. It must authenticate through its own `ctx.auth` and
958
+ apply the host's business policy to both operations. It returns a closed stable
959
+ authorization snapshot containing the authenticated `tokenIdentifier`, those
960
+ exact scope/operation values, provider scope, authorization ID/revision and an
961
+ expiry in wall-clock milliseconds. Provider scope is platform mode, null connected
962
+ account, live mode, customer-account ID, original subscription ID and owned
963
+ schedule ID. The reader compares that scope to the fully reconstructed retained
964
+ history. Authorization snapshots may differ from the original retained host
965
+ envelopes; permission to observe is checked afresh.
966
+
967
+ The Action identity and host authorization query run before component DATA reads
968
+ and again before release. Both authorization snapshots must be identical,
969
+ including expiry; sliding expiries or revision changes reject. Authentication,
970
+ RPC and root pointers, component identity and semantic function addresses are
971
+ checked around every await. Convex generated references may be fresh proxy
972
+ objects on access, so address checks compare the exact `name`, `reference` or
973
+ `functionHandle` discriminator/value rather than proxy object equality.
974
+
975
+ A new 30-second wall/monotonic budget starts before metadata binding and covers
976
+ idle time before `read()`, both authorization phases and reconstruction. A timeout
977
+ race closes hung calls permanently; late fulfillment cannot continue reading.
978
+ Clock rollback, deadline equality, expired authorization and pointer drift close
979
+ the reader. The old write Owner and its period boundary are never consulted.
980
+
981
+ Only four existing component query routes are available: operation load, attempt
982
+ manifest, full event and retained acknowledgement. A complete parent/child read
983
+ makes at most twelve component queries plus two host authorization queries.
984
+ Each query reply is detached and frozen before another query. Event counts are
985
+ captured once from validated own DATA and cannot grow across awaits.
986
+ There is no journal mutation, reservation, client selection or provider request.
987
+ The result contains immutable retained history and the fresh authorization
988
+ snapshot, with operational authority false. The embedded historical DATA retains
989
+ its false provider-authentication and public-delivery claims.
990
+
991
+ These checks establish two authorization points, not uninterrupted permission
992
+ between them or after return. Sequential queries are not an atomic snapshot;
993
+ contradictory history rejects without automatic refetch. A synthetic registered
994
+ host query in controlled tests does not bind a real installation policy. Fresh
995
+ GET acquisition, provider lifecycle/invoice/history evidence, genuine generation
996
+ and deployed compatibility remain outstanding.
997
+
998
+ ### Private fresh provider observer
999
+
1000
+ The private fresh observer shares one invocation with the authorized history
1001
+ reader. The invocation is minted into a private identity table and retains the
1002
+ actual class/Action binding, authorization and complete history. Returned reader
1003
+ DATA and copied tokens cannot create an observer. The reader closes the
1004
+ invocation after its DATA result; the observer keeps the same original 30-second
1005
+ budget through acquisition and final release. No timer is reset or nested.
1006
+
1007
+ Provider reads need a separate compiled observer profile. Production entries are
1008
+ empty. An entry must bind the exact history entry, fixed
1009
+ `endive-schedule-first-44-v1` profile and an immutable, non-proxy qualifier returning
1010
+ literal true before client selection. Profile membership and qualifier identity
1011
+ remain guarded around awaits. The client comes from the maintained constructor's
1012
+ actual selection method at the pinned Endive API. It may be cached; the observer
1013
+ requires a fresh authorized selection, not a newly allocated instance or an old
1014
+ parent lineage.
1015
+
1016
+ The transport captures the actual SDK `rawRequest` method and receiver. It
1017
+ permits only sequential schedule-first GET rows, undefined bodies, zero retries
1018
+ and at most 44 calls. Four base replies precede at most forty distinct coupon
1019
+ reads. It reauthenticates and requires the unchanged authorization snapshot before
1020
+ each GET and before output release. Method, receiver and root configuration drift
1021
+ refuse. Every result retains operational authority false.
1022
+
1023
+ Only settlement of the actual returned SDK promise can produce provider-rejection
1024
+ DATA. A private capsule binds that promise and attempt before any diagnostic
1025
+ release. The captured native Promise method avoids a poisoned public `.then`.
1026
+ Final authorization is still required after an asynchronous rejection; timeout,
1027
+ authorization, synchronous dispatch and post-fulfillment decoder failures cannot
1028
+ masquerade as that rejection. Late settlement after expiry cannot resume reads or
1029
+ authorize output. The retained component receipt is never deleted on read failure.
1030
+
1031
+ The observer passes exactly the seven-input evidence contract, with invoice and
1032
+ historical inputs null, and preserves the analyzer's twelve-key result and false
1033
+ authority flags. If analysis cannot be admitted, it returns an explicit
1034
+ `analysis_not_admitted` marker rather than inventing evidence. Monthly future
1035
+ duration can remain unknown even with retained C9 when the independent duration
1036
+ predicate is unqualified. The controlled weekly pending profile has no trial or
1037
+ anchor reset; active successor matching uses the actual native item/period and
1038
+ does not assume that the old item ID survives.
1039
+
1040
+ Identity routing is checked separately from coupon eligibility. Multiple items or
1041
+ unsupported/overflowing coupon inventory stop after four base reads, with an
1042
+ explicit incomplete-inventory marker and the full authorized base DATA. Terminal
1043
+ facts from the analyzer are preserved, including unknown completion where proof
1044
+ is insufficient. An empty coupon array in this result does not assert a complete
1045
+ inventory. Foreign base identity returns conflict without adopting its material.
1046
+
1047
+ Sequential resources are not an atomic snapshot, and initial/per-read/final
1048
+ authorization does not prove uninterrupted permission or exclusive provider
1049
+ causality. Invoice selection and full line pagination, authenticated immutable
1050
+ historical witnesses, a public installation binding, genuine generation/deployed
1051
+ compatibility, provider qualification and final Dojo acceptance remain required.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fantastic.dev/better-stripe",
3
- "version": "0.107.0",
3
+ "version": "0.109.0",
4
4
  "description": "Convex component for Stripe Accounts v2, subscriptions, metered billing and Connect marketplaces, with React workflows.",
5
5
  "keywords": [
6
6
  "stripe",