@fantastic.dev/better-stripe 0.62.0 → 0.64.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 (217) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +22 -2
  3. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +550 -0
  4. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  5. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +275 -0
  6. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  7. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +550 -0
  8. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  9. package/dist/client/connect/payoutSyncTestHelpers.d.ts +275 -0
  10. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  11. package/dist/client/financialOwnership.d.ts +2 -2
  12. package/dist/client/financialOwnership.d.ts.map +1 -1
  13. package/dist/client/financialOwnership.js +2 -2
  14. package/dist/client/financialOwnership.js.map +1 -1
  15. package/dist/client/paymentSource/resolver.d.ts +1 -0
  16. package/dist/client/paymentSource/resolver.d.ts.map +1 -1
  17. package/dist/client/paymentSource/resolver.js +11 -2
  18. package/dist/client/paymentSource/resolver.js.map +1 -1
  19. package/dist/client/paymentSource/zeroTierLines.d.ts +4 -0
  20. package/dist/client/paymentSource/zeroTierLines.d.ts.map +1 -0
  21. package/dist/client/paymentSource/zeroTierLines.js +35 -0
  22. package/dist/client/paymentSource/zeroTierLines.js.map +1 -0
  23. package/dist/client/payoutRevisionMigration.d.ts +37 -0
  24. package/dist/client/payoutRevisionMigration.d.ts.map +1 -0
  25. package/dist/client/payoutRevisionMigration.js +49 -0
  26. package/dist/client/payoutRevisionMigration.js.map +1 -0
  27. package/dist/client/publicTypes.d.ts +2 -0
  28. package/dist/client/publicTypes.d.ts.map +1 -1
  29. package/dist/client/reversalObservations.d.ts +62 -0
  30. package/dist/client/reversalObservations.d.ts.map +1 -0
  31. package/dist/client/reversalObservations.js +79 -0
  32. package/dist/client/reversalObservations.js.map +1 -0
  33. package/dist/client/usage/configuration.d.ts +13 -0
  34. package/dist/client/usage/configuration.d.ts.map +1 -0
  35. package/dist/client/usage/configuration.js +2 -0
  36. package/dist/client/usage/configuration.js.map +1 -0
  37. package/dist/client/usage/deliveryProvider.d.ts.map +1 -1
  38. package/dist/client/usage/deliveryProvider.js +16 -0
  39. package/dist/client/usage/deliveryProvider.js.map +1 -1
  40. package/dist/client/usage/index.d.ts +2 -0
  41. package/dist/client/usage/index.d.ts.map +1 -1
  42. package/dist/client/usage/invoiceSale.d.ts.map +1 -1
  43. package/dist/client/usage/invoiceSale.js +15 -2
  44. package/dist/client/usage/invoiceSale.js.map +1 -1
  45. package/dist/client/usage/observationClient.d.ts +2 -2
  46. package/dist/client/usage/observationClient.d.ts.map +1 -1
  47. package/dist/client/usage/views.d.ts +24 -0
  48. package/dist/client/usage/views.d.ts.map +1 -0
  49. package/dist/client/usage/views.js +2 -0
  50. package/dist/client/usage/views.js.map +1 -0
  51. package/dist/component/_generated/api.d.ts +28 -0
  52. package/dist/component/_generated/api.d.ts.map +1 -1
  53. package/dist/component/_generated/api.js.map +1 -1
  54. package/dist/component/_generated/component.d.ts +354 -0
  55. package/dist/component/_generated/component.d.ts.map +1 -1
  56. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  57. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  58. package/dist/component/connect/mutations.d.ts.map +1 -1
  59. package/dist/component/connect/mutations.js +2 -0
  60. package/dist/component/connect/mutations.js.map +1 -1
  61. package/dist/component/connect/reversalClaims.d.ts.map +1 -1
  62. package/dist/component/connect/reversalClaims.js +10 -1
  63. package/dist/component/connect/reversalClaims.js.map +1 -1
  64. package/dist/component/earnings/triggers.d.ts +408 -16
  65. package/dist/component/earnings/triggers.d.ts.map +1 -1
  66. package/dist/component/financialObservations/transferSchema.d.ts +1 -0
  67. package/dist/component/financialObservations/transferSchema.d.ts.map +1 -1
  68. package/dist/component/financialObservations/transferSchema.js +1 -0
  69. package/dist/component/financialObservations/transferSchema.js.map +1 -1
  70. package/dist/component/payoutRevisionJournal/mutations.d.ts +15 -0
  71. package/dist/component/payoutRevisionJournal/mutations.d.ts.map +1 -0
  72. package/dist/component/payoutRevisionJournal/mutations.js +11 -0
  73. package/dist/component/payoutRevisionJournal/mutations.js.map +1 -0
  74. package/dist/component/payoutRevisionJournal/schema.d.ts +45 -0
  75. package/dist/component/payoutRevisionJournal/schema.d.ts.map +1 -0
  76. package/dist/component/payoutRevisionJournal/schema.js +22 -0
  77. package/dist/component/payoutRevisionJournal/schema.js.map +1 -0
  78. package/dist/component/payoutRevisionJournal/state.d.ts +36 -0
  79. package/dist/component/payoutRevisionJournal/state.d.ts.map +1 -0
  80. package/dist/component/payoutRevisionJournal/state.js +111 -0
  81. package/dist/component/payoutRevisionJournal/state.js.map +1 -0
  82. package/dist/component/payoutRevisionMigration/mutations.d.ts +36 -0
  83. package/dist/component/payoutRevisionMigration/mutations.d.ts.map +1 -0
  84. package/dist/component/payoutRevisionMigration/mutations.js +126 -0
  85. package/dist/component/payoutRevisionMigration/mutations.js.map +1 -0
  86. package/dist/component/payoutRevisionMigration/queries.d.ts +38 -0
  87. package/dist/component/payoutRevisionMigration/queries.d.ts.map +1 -0
  88. package/dist/component/payoutRevisionMigration/queries.js +39 -0
  89. package/dist/component/payoutRevisionMigration/queries.js.map +1 -0
  90. package/dist/component/payoutRevisionMigration/schema.d.ts +115 -0
  91. package/dist/component/payoutRevisionMigration/schema.d.ts.map +1 -0
  92. package/dist/component/payoutRevisionMigration/schema.js +52 -0
  93. package/dist/component/payoutRevisionMigration/schema.js.map +1 -0
  94. package/dist/component/payoutSnapshots/legacyRevisionWriter.d.ts +4 -0
  95. package/dist/component/payoutSnapshots/legacyRevisionWriter.d.ts.map +1 -0
  96. package/dist/component/payoutSnapshots/legacyRevisionWriter.js +33 -0
  97. package/dist/component/payoutSnapshots/legacyRevisionWriter.js.map +1 -0
  98. package/dist/component/payoutSnapshots/revisions.d.ts.map +1 -1
  99. package/dist/component/payoutSnapshots/revisions.js +23 -29
  100. package/dist/component/payoutSnapshots/revisions.js.map +1 -1
  101. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  102. package/dist/component/refundSync/mutations.d.ts +1 -1
  103. package/dist/component/refundSync/mutations.d.ts.map +1 -1
  104. package/dist/component/reversalObservations/capture.d.ts +6 -0
  105. package/dist/component/reversalObservations/capture.d.ts.map +1 -0
  106. package/dist/component/reversalObservations/capture.js +96 -0
  107. package/dist/component/reversalObservations/capture.js.map +1 -0
  108. package/dist/component/reversalObservations/indexSlice.d.ts +29 -0
  109. package/dist/component/reversalObservations/indexSlice.d.ts.map +1 -0
  110. package/dist/component/reversalObservations/indexSlice.js +101 -0
  111. package/dist/component/reversalObservations/indexSlice.js.map +1 -0
  112. package/dist/component/reversalObservations/integrity.d.ts +25 -0
  113. package/dist/component/reversalObservations/integrity.d.ts.map +1 -0
  114. package/dist/component/reversalObservations/integrity.js +19 -0
  115. package/dist/component/reversalObservations/integrity.js.map +1 -0
  116. package/dist/component/reversalObservations/mutations.d.ts +37 -0
  117. package/dist/component/reversalObservations/mutations.d.ts.map +1 -0
  118. package/dist/component/reversalObservations/mutations.js +181 -0
  119. package/dist/component/reversalObservations/mutations.js.map +1 -0
  120. package/dist/component/reversalObservations/pagination.d.ts +34 -0
  121. package/dist/component/reversalObservations/pagination.d.ts.map +1 -0
  122. package/dist/component/reversalObservations/pagination.js +31 -0
  123. package/dist/component/reversalObservations/pagination.js.map +1 -0
  124. package/dist/component/reversalObservations/queries.d.ts +221 -0
  125. package/dist/component/reversalObservations/queries.d.ts.map +1 -0
  126. package/dist/component/reversalObservations/queries.js +114 -0
  127. package/dist/component/reversalObservations/queries.js.map +1 -0
  128. package/dist/component/reversalObservations/references.d.ts +17 -0
  129. package/dist/component/reversalObservations/references.d.ts.map +1 -0
  130. package/dist/component/reversalObservations/references.js +95 -0
  131. package/dist/component/reversalObservations/references.js.map +1 -0
  132. package/dist/component/reversalObservations/schema.d.ts +525 -0
  133. package/dist/component/reversalObservations/schema.d.ts.map +1 -0
  134. package/dist/component/reversalObservations/schema.js +92 -0
  135. package/dist/component/reversalObservations/schema.js.map +1 -0
  136. package/dist/component/reversalObservations/selectors.d.ts +3 -0
  137. package/dist/component/reversalObservations/selectors.d.ts.map +1 -0
  138. package/dist/component/reversalObservations/selectors.js +8 -0
  139. package/dist/component/reversalObservations/selectors.js.map +1 -0
  140. package/dist/component/reversalObservations/state.d.ts +34 -0
  141. package/dist/component/reversalObservations/state.d.ts.map +1 -0
  142. package/dist/component/reversalObservations/state.js +34 -0
  143. package/dist/component/reversalObservations/state.js.map +1 -0
  144. package/dist/component/schema.d.ts +275 -0
  145. package/dist/component/schema.js +10 -0
  146. package/dist/component/schema.js.map +1 -1
  147. package/dist/component/usage/allowance.fixtures.d.ts +291 -16
  148. package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
  149. package/dist/component/usageCredits/accounting.fixtures.d.ts +275 -0
  150. package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
  151. package/dist/react/workflows/Usage.types.d.ts +2 -23
  152. package/dist/react/workflows/Usage.types.d.ts.map +1 -1
  153. package/dist/react/workflows/Usage.types.js.map +1 -1
  154. package/dist/react/workflows/UsageConfiguration.types.d.ts +3 -11
  155. package/dist/react/workflows/UsageConfiguration.types.d.ts.map +1 -1
  156. package/docs/README.md +4 -1
  157. package/docs/client-api.md +6 -0
  158. package/docs/financial-observations.md +51 -8
  159. package/docs/payout-revision-migration.md +54 -0
  160. package/docs/react-workflows-audit.md +73 -2
  161. package/docs/usage-configuration.md +4 -0
  162. package/docs/usage-delivery.md +4 -0
  163. package/docs/usage-example.md +250 -0
  164. package/docs/usage-react.md +4 -0
  165. package/docs/usage-settlement.md +8 -3
  166. package/package.json +4 -2
  167. package/src/client/financialOwnership.ts +2 -2
  168. package/src/client/paymentSource/resolver.ts +14 -2
  169. package/src/client/paymentSource/zeroTierLines.ts +42 -0
  170. package/src/client/payoutRevisionMigration.test.ts +40 -0
  171. package/src/client/payoutRevisionMigration.ts +96 -0
  172. package/src/client/publicTypes.ts +15 -0
  173. package/src/client/reversalObservations.test.ts +69 -0
  174. package/src/client/reversalObservations.ts +151 -0
  175. package/src/client/usage/configuration.ts +9 -0
  176. package/src/client/usage/deliveryProvider.test.ts +77 -37
  177. package/src/client/usage/deliveryProvider.ts +19 -0
  178. package/src/client/usage/index.ts +4 -0
  179. package/src/client/usage/invoiceSale.test.ts +68 -0
  180. package/src/client/usage/invoiceSale.ts +20 -2
  181. package/src/client/usage/views.ts +23 -0
  182. package/src/component/_generated/api.ts +28 -0
  183. package/src/component/_generated/component.ts +423 -0
  184. package/src/component/connect/mutations.ts +2 -0
  185. package/src/component/connect/reversalClaims.ts +13 -1
  186. package/src/component/financialObservations/transferSchema.ts +1 -0
  187. package/src/component/payoutRevisionJournal/mutations.ts +11 -0
  188. package/src/component/payoutRevisionJournal/schema.ts +34 -0
  189. package/src/component/payoutRevisionJournal/state.ts +141 -0
  190. package/src/component/payoutRevisionMigration/mutations.ts +135 -0
  191. package/src/component/payoutRevisionMigration/queries.ts +50 -0
  192. package/src/component/payoutRevisionMigration/schema.ts +51 -0
  193. package/src/component/payoutSnapshots/legacy-revisions.test.ts +246 -0
  194. package/src/component/payoutSnapshots/legacyRevisionWriter.ts +39 -0
  195. package/src/component/payoutSnapshots/revision-journal-callbacks.test.ts +160 -0
  196. package/src/component/payoutSnapshots/revision-journal-held.test.ts +94 -0
  197. package/src/component/payoutSnapshots/revision-journal.test.ts +310 -0
  198. package/src/component/payoutSnapshots/revision-migration.test.ts +128 -0
  199. package/src/component/payoutSnapshots/revisions.ts +22 -30
  200. package/src/component/reversalObservations/boundaries.test.ts +62 -0
  201. package/src/component/reversalObservations/capture-integrity.test.ts +119 -0
  202. package/src/component/reversalObservations/capture.ts +129 -0
  203. package/src/component/reversalObservations/continuation.test.ts +131 -0
  204. package/src/component/reversalObservations/indexSlice.ts +124 -0
  205. package/src/component/reversalObservations/integrity.ts +31 -0
  206. package/src/component/reversalObservations/lifecycle.test.ts +81 -0
  207. package/src/component/reversalObservations/mutations.ts +211 -0
  208. package/src/component/reversalObservations/pagination.ts +40 -0
  209. package/src/component/reversalObservations/provenance.test.ts +167 -0
  210. package/src/component/reversalObservations/queries.ts +121 -0
  211. package/src/component/reversalObservations/references.ts +134 -0
  212. package/src/component/reversalObservations/schema.ts +100 -0
  213. package/src/component/reversalObservations/selectors.ts +9 -0
  214. package/src/component/reversalObservations/state.ts +42 -0
  215. package/src/component/schema.ts +18 -0
  216. package/src/react/workflows/Usage.types.ts +5 -29
  217. package/src/react/workflows/UsageConfiguration.types.ts +3 -11
@@ -0,0 +1,100 @@
1
+ import { defineTable } from "convex/server";
2
+ import { v } from "convex/values";
3
+ import { transferReversalOpFields } from "../connect/validators.js";
4
+ import { legFields } from "../financialObservations/schema.js";
5
+ export const payloadsTable = defineTable(transferReversalOpFields);
6
+ export const payloadDoc = v.object({
7
+ ...transferReversalOpFields,
8
+ _id: v.id("reversalObservationPayloads"),
9
+ _creationTime: v.number(),
10
+ });
11
+ export const ref = v.object({
12
+ transferId: v.id("transfers"),
13
+ bucketDigest: v.string(),
14
+ ownerDigest: v.optional(v.string()),
15
+ identityFingerprint: v.string(),
16
+ ambiguous: v.boolean(),
17
+ markerId: v.optional(v.id("financialTransferObservations")),
18
+ markerGeneration: v.optional(v.number()),
19
+ markerIdentityFingerprint: v.optional(v.string()),
20
+ ownershipFingerprint: v.optional(v.string()),
21
+ registrationId: v.optional(v.id("financialOwnership")),
22
+ });
23
+ export const headerFields = {
24
+ originalOperationId: v.id("transferReversalOps"),
25
+ sourceCreatedAt: v.number(),
26
+ producer: v.literal("reversal_claim_lifecycle"),
27
+ producerVersion: v.literal(1),
28
+ originalPayloadId: v.id("reversalObservationPayloads"),
29
+ latestPayloadId: v.id("reversalObservationPayloads"),
30
+ referenceFingerprints: v.array(v.string()),
31
+ originalFingerprint: v.string(),
32
+ latestIdentityFingerprint: v.string(),
33
+ originalIdentityFingerprint: v.string(),
34
+ fingerprint: v.string(),
35
+ operationDigest: v.string(),
36
+ sourceChargeDigest: v.string(),
37
+ generation: v.number(),
38
+ deleted: v.boolean(),
39
+ sliceCount: v.number(),
40
+ indexedCount: v.number(),
41
+ nextIndex: v.number(),
42
+ status: v.union(
43
+ v.literal("pending"),
44
+ v.literal("validating"),
45
+ v.literal("complete"),
46
+ v.literal("held"),
47
+ ),
48
+ legacy: v.boolean(),
49
+ isContradictory: v.boolean(),
50
+ indexTransferGeneration: v.union(v.number(), v.null()),
51
+ };
52
+ export const headerDoc = v.object({
53
+ ...headerFields,
54
+ _id: v.id("reversalObservations"),
55
+ _creationTime: v.number(),
56
+ });
57
+ export const observationsTable = defineTable(headerFields)
58
+ .index("by_original_operation", ["originalOperationId"])
59
+ .index("by_operation_digest", ["operationDigest"])
60
+ .index("by_source_charge_digest", ["sourceChargeDigest"]);
61
+ export const refsTable = defineTable({
62
+ observationId: v.id("reversalObservations"),
63
+ chunkIndex: v.number(),
64
+ refs: v.array(v.union(ref, v.null())),
65
+ }).index("by_observation_chunk", ["observationId", "chunkIndex"]);
66
+ export const sliceFields = {
67
+ originalOperationId: v.id("transferReversalOps"),
68
+ observationId: v.id("reversalObservations"),
69
+ sliceIndex: v.number(),
70
+ generation: v.number(),
71
+ bucketDigest: v.optional(v.string()),
72
+ ownerDigest: v.optional(v.string()),
73
+ transferId: v.optional(v.id("transfers")),
74
+ bucketKey: v.optional(v.string()),
75
+ registrationId: legFields.registrationId,
76
+ userId: legFields.userId,
77
+ orgId: legFields.orgId,
78
+ ownershipStatus: legFields.ownershipStatus,
79
+ identityStatus: v.union(
80
+ v.literal("matched"),
81
+ v.literal("unknown"),
82
+ v.literal("contradictory"),
83
+ ),
84
+ transferGeneration: v.union(v.number(), v.null()),
85
+ };
86
+ export const sliceDoc = v.object({
87
+ ...sliceFields,
88
+ _id: v.id("reversalObservationSlices"),
89
+ _creationTime: v.number(),
90
+ });
91
+ export const slicesTable = defineTable(sliceFields)
92
+ .index("by_observation_slice", ["observationId", "sliceIndex"])
93
+ .index("by_bucket", ["bucketDigest"])
94
+ .index("by_owner", ["ownerDigest"]);
95
+ export const operationResult = v.object({
96
+ coverage: v.literal("unknown"),
97
+ generation: v.union(v.number(), v.null()),
98
+ transferGeneration: v.union(v.number(), v.null()),
99
+ observation: v.union(headerDoc, v.null()),
100
+ });
@@ -0,0 +1,9 @@
1
+ import { canonicalFingerprint } from "../operationEvidence/canonical.js";
2
+ export const bucketDigest = (bucketKey: string) =>
3
+ canonicalFingerprint({ domain: "reversal-bucket-v1", bucketKey });
4
+ export const ownerDigest = (userId: string, orgId?: string) =>
5
+ canonicalFingerprint({
6
+ domain: "reversal-owner-v1",
7
+ userId,
8
+ ...(orgId === undefined ? {} : { orgId }),
9
+ });
@@ -0,0 +1,42 @@
1
+ import type { Id } from "../_generated/dataModel.js";
2
+ import type { QueryCtx } from "../_generated/server.js";
3
+ import { observationGeneration } from "../financialObservations/generations.js";
4
+ import { transferProducerScope } from "../financialObservations/transferHelpers.js";
5
+ import { lifecycleScope } from "./capture.js";
6
+ export async function header(
7
+ ctx: QueryCtx,
8
+ operationId: Id<"transferReversalOps">,
9
+ ) {
10
+ const rows = await ctx.db
11
+ .query("reversalObservations")
12
+ .withIndex("by_original_operation", (q) =>
13
+ q.eq("originalOperationId", operationId),
14
+ )
15
+ .take(2);
16
+ const row = rows[0];
17
+ return rows.length === 1 &&
18
+ [row.generation, row.sliceCount, row.indexedCount, row.nextIndex].every(
19
+ Number.isSafeInteger,
20
+ ) &&
21
+ row.generation >= 1 &&
22
+ row.sliceCount >= 0 &&
23
+ row.indexedCount >= 0 &&
24
+ row.indexedCount <= row.sliceCount &&
25
+ row.nextIndex >= 0 &&
26
+ row.nextIndex <= row.sliceCount &&
27
+ row.referenceFingerprints.length ===
28
+ (row.legacy ? 0 : Math.ceil(row.sliceCount / 64)) &&
29
+ row.referenceFingerprints.every((value) => /^[a-f0-9]{64}$/.test(value)) &&
30
+ (!(row.status === "complete" || row.status === "validating") ||
31
+ row.indexedCount === row.sliceCount) &&
32
+ (row.status !== "complete" || row.nextIndex === 0)
33
+ ? row
34
+ : null;
35
+ }
36
+ export async function readState(ctx: QueryCtx) {
37
+ return {
38
+ coverage: "unknown" as const,
39
+ generation: await observationGeneration(ctx, lifecycleScope),
40
+ transferGeneration: await observationGeneration(ctx, transferProducerScope),
41
+ };
42
+ }
@@ -1,3 +1,14 @@
1
+ import {
2
+ observationsTable as reversalObservations,
3
+ payloadsTable as reversalObservationPayloads,
4
+ refsTable as reversalObservationRefs,
5
+ slicesTable as reversalObservationSlices,
6
+ } from "./reversalObservations/schema.js";
7
+ import {
8
+ jobsTable as payoutRevisionMigrationsTable,
9
+ resultsTable as payoutRevisionMigrationResultsTable,
10
+ } from "./payoutRevisionMigration/schema.js";
11
+ import { journalTable as payoutRevisionJournal } from "./payoutRevisionJournal/schema.js";
1
12
  import {
2
13
  claimsTable as usageCorrectionClaims,
3
14
  operationsTable as usageCorrections,
@@ -125,6 +136,13 @@ import { pricesTable, productsTable } from "./products/schema";
125
136
  import { webhookEventsTable } from "./webhooks/schema";
126
137
 
127
138
  export default defineSchema({
139
+ reversalObservations,
140
+ reversalObservationPayloads,
141
+ reversalObservationRefs,
142
+ reversalObservationSlices,
143
+ payoutRevisionJournal,
144
+ payoutRevisionMigrations: payoutRevisionMigrationsTable,
145
+ payoutRevisionMigrationResults: payoutRevisionMigrationResultsTable,
128
146
  usageCorrectionClaims,
129
147
  usageCorrections,
130
148
  usageCorrectionHistory,
@@ -1,32 +1,8 @@
1
- import type {
2
- UsageAvailability,
3
- UsagePeriod,
4
- } from "../../client/usage/boundaries.js";
5
- import type { UsageLocalSummary } from "../../client/usage/summary.js";
6
- import type { UsageAggregateObservation } from "../../client/usage/observationTypes.js";
7
- import type { UsageAllowanceStatus } from "../../client/usage/allowanceTerms.js";
8
- import type {
9
- UsageCreditBalance,
10
- UsageCreditPurchase,
11
- } from "../../client/usage/creditTerms.js";
12
- import type { UsageCreditReconciliation } from "../../client/usage/creditObservation.js";
13
- /** Cache identity only. The authenticated host must resolve and authorize original native bindings. */
14
- export type UsageViewScope = {
15
- identityKey: string;
16
- accountKey: string;
17
- /** Include original plan/price version in this opaque host meter key. */
18
- meterKey: string;
19
- period: UsagePeriod;
20
- currency: string;
21
- };
22
- export type UsageBillingSnapshot = {
23
- summary: UsageAvailability<UsageLocalSummary>;
24
- provider?: UsageAggregateObservation;
25
- allowance?: UsageAvailability<UsageAllowanceStatus | null>;
26
- credits?: UsageAvailability<UsageCreditBalance>;
27
- purchase?: UsageCreditPurchase | null;
28
- creditApplication?: UsageAvailability<UsageCreditReconciliation>;
29
- };
1
+ import type { UsageViewScope } from "../../client/usage/views.js";
2
+ export type {
3
+ UsageViewScope,
4
+ UsageBillingSnapshot,
5
+ } from "../../client/usage/views.js";
30
6
  export function usageViewKey(scope: UsageViewScope) {
31
7
  return JSON.stringify([
32
8
  scope.identityKey,
@@ -1,8 +1,7 @@
1
1
  import type { ReactNode } from "react";
2
- import type {
3
- UsagePlan,
4
- UsageBillingModel,
5
- } from "../../client/usage/contracts.js";
2
+ import type { UsageConfigurationValue } from "../../client/usage/configuration.js";
3
+ export type { UsageConfigurationValue } from "../../client/usage/configuration.js";
4
+ import type { UsageBillingModel } from "../../client/usage/contracts.js";
6
5
  /** Display/cache context from an authenticated host. Never use this as server authorization. */
7
6
  export type UsageConfigurationScope = {
8
7
  identityKey: string;
@@ -14,13 +13,6 @@ export type UsageConfigurationScope = {
14
13
  /** Host has verified the configured issuer realm and supported native catalog. */
15
14
  capability: "issuer_native" | "unsupported";
16
15
  };
17
- export type UsageConfigurationValue = {
18
- plan: UsagePlan;
19
- eventName: string;
20
- displayName: string;
21
- meterId?: string;
22
- creditPackage?: { quantity: string; topUp: "manual" };
23
- };
24
16
  export type UsageMeterChoice = {
25
17
  id: string;
26
18
  active: boolean;