@jsb188/mday 1.1.10 → 1.1.12

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 (210) hide show
  1. package/package.json +140 -54
  2. package/src/constants/agentMemory.ts +123 -0
  3. package/src/constants/agentNote.ts +212 -0
  4. package/src/constants/aiChat.ts +10 -0
  5. package/src/constants/billing.ts +126 -0
  6. package/src/constants/campaign.ts +236 -0
  7. package/src/constants/contact.ts +72 -0
  8. package/src/constants/csvExport.ts +133 -0
  9. package/src/constants/dataTable.ts +21 -21
  10. package/src/constants/dataTableFieldTypes.generated.ts +59 -0
  11. package/src/constants/docAccess.ts +33 -0
  12. package/src/constants/dt.ts +234 -0
  13. package/src/constants/email.ts +125 -7
  14. package/src/constants/fieldDoc.ts +104 -0
  15. package/src/constants/graphqlReactivity.ts +196 -0
  16. package/src/constants/integration.ts +8 -9
  17. package/src/constants/log.ts +14 -408
  18. package/src/constants/logDisplay/README.md +88 -0
  19. package/src/constants/logDisplay/defaults.ts +39 -0
  20. package/src/constants/logDisplay/index.ts +27 -0
  21. package/src/constants/logDisplay/operations/arable.ts +16 -0
  22. package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
  23. package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
  24. package/src/constants/logDisplay/shared/accounting.ts +13 -0
  25. package/src/constants/logDisplay/shared/interactions.ts +13 -0
  26. package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
  27. package/src/constants/logTaxonomy.generated.ts +2207 -0
  28. package/src/constants/noteDoc.ts +77 -0
  29. package/src/constants/organization.ts +18 -21
  30. package/src/constants/pageRoute.ts +23 -0
  31. package/src/constants/qrCode.ts +30 -0
  32. package/src/constants/sheet.ts +126 -14
  33. package/src/constants/sms.ts +18 -0
  34. package/src/constants/square.ts +6 -6
  35. package/src/constants/storage.ts +80 -7
  36. package/src/constants/usage.ts +82 -0
  37. package/src/constants/workflowSteps.ts +60 -0
  38. package/src/schemas/editLogEntry.ts +836 -780
  39. package/src/schemas/inboundContact.ts +60 -55
  40. package/src/schemas/logsQuery.ts +55 -49
  41. package/src/types/account.d.ts +4 -1
  42. package/src/types/agentMemory.d.ts +98 -0
  43. package/src/types/agentNote.d.ts +443 -0
  44. package/src/types/billing.d.ts +537 -0
  45. package/src/types/campaign.d.ts +1533 -0
  46. package/src/types/contact.d.ts +15 -0
  47. package/src/types/csvExport.d.ts +213 -0
  48. package/src/types/dataAnalysis.d.ts +44 -0
  49. package/src/types/dataTable.d.ts +115 -403
  50. package/src/types/definitionElement.d.ts +35 -0
  51. package/src/types/docAccess.d.ts +96 -0
  52. package/src/types/dt.d.ts +257 -0
  53. package/src/types/email.d.ts +184 -24
  54. package/src/types/emailReplyReport.d.ts +76 -0
  55. package/src/types/fieldDoc.d.ts +702 -0
  56. package/src/types/fieldDocContract.d.ts +90 -0
  57. package/src/types/inboundContact.d.ts +10 -1
  58. package/src/types/log.d.ts +254 -295
  59. package/src/types/logDisplay.types.ts +85 -0
  60. package/src/types/organization.d.ts +91 -43
  61. package/src/types/pageRoute.d.ts +48 -0
  62. package/src/types/qrCode.d.ts +96 -0
  63. package/src/types/richText.d.ts +81 -0
  64. package/src/types/sheet.d.ts +678 -129
  65. package/src/types/sms.d.ts +38 -0
  66. package/src/types/storage.d.ts +449 -129
  67. package/src/types/usage.d.ts +106 -0
  68. package/src/types/workflow.d.ts +315 -54
  69. package/src/utils/agentMemory.ts +15 -0
  70. package/src/utils/agentNote.ts +850 -0
  71. package/src/utils/aiChat.ts +43 -0
  72. package/src/utils/aiChatWork.ts +64 -0
  73. package/src/utils/billing.ts +37 -0
  74. package/src/utils/campaign.ts +1174 -0
  75. package/src/utils/campaignAI.ts +72 -0
  76. package/src/utils/campaignAccess.ts +239 -0
  77. package/src/utils/campaignEmail.ts +601 -0
  78. package/src/utils/campaignEmailCompiler.ts +372 -0
  79. package/src/utils/campaignEmailImages.ts +60 -0
  80. package/src/utils/campaignEmailStyles.ts +544 -0
  81. package/src/utils/campaignLifecycle.ts +104 -0
  82. package/src/utils/campaignPreview.ts +285 -0
  83. package/src/utils/contact.ts +50 -0
  84. package/src/utils/csvExport.ts +19 -0
  85. package/src/utils/dataTable.ts +95 -618
  86. package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
  87. package/src/utils/dataTableRelativeDate.ts +447 -0
  88. package/src/utils/definitionElement.ts +84 -0
  89. package/src/utils/docAccess.ts +383 -0
  90. package/src/utils/documentName.ts +53 -0
  91. package/src/utils/email.ts +317 -51
  92. package/src/utils/emailReplyReport.test.ts +187 -0
  93. package/src/utils/emailReplyReport.ts +143 -0
  94. package/src/utils/fieldDoc.ts +157 -0
  95. package/src/utils/fieldDocAnswers.ts +128 -0
  96. package/src/utils/fieldDocDefaults.ts +36 -0
  97. package/src/utils/fieldDocProgram.ts +36 -0
  98. package/src/utils/fieldDocSummary.ts +30 -0
  99. package/src/utils/log.ts +276 -192
  100. package/src/utils/logDisplay.helpers.ts +177 -0
  101. package/src/utils/logDisplay.ts +87 -0
  102. package/src/utils/logRegistryValue.ts +90 -0
  103. package/src/utils/logStoreRead.ts +262 -0
  104. package/src/utils/logTaxonomy.helpers.ts +17 -0
  105. package/src/utils/logTaxonomy.ts +76 -0
  106. package/src/utils/logTaxonomyDisplay.ts +395 -0
  107. package/src/utils/noteDoc.ts +609 -0
  108. package/src/utils/organization.ts +337 -84
  109. package/src/utils/pageRoute.ts +71 -0
  110. package/src/utils/qrCode.helpers.ts +189 -0
  111. package/src/utils/qrCode.test.ts +519 -0
  112. package/src/utils/qrCode.ts +273 -0
  113. package/src/utils/richTextHTML.ts +385 -0
  114. package/src/utils/sheet.ts +199 -107
  115. package/src/utils/sheetAxisMove.ts +616 -0
  116. package/src/utils/sheetBootstrap.ts +1402 -0
  117. package/src/utils/sheetCellLiteral.ts +101 -0
  118. package/src/utils/sheetCommand.ts +358 -0
  119. package/src/utils/sheetDesign.ts +705 -0
  120. package/src/utils/sheetExport.ts +186 -0
  121. package/src/utils/sheetFeatureReference.ts +183 -0
  122. package/src/utils/sheetFormulaArgs.ts +168 -0
  123. package/src/utils/sheetFormulaCompile.ts +475 -0
  124. package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
  125. package/src/utils/sheetFormulaCriteria.ts +656 -0
  126. package/src/utils/sheetFormulaDate.ts +444 -0
  127. package/src/utils/sheetFormulaEvaluation.ts +899 -0
  128. package/src/utils/sheetFormulaEvaluator.ts +997 -0
  129. package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
  130. package/src/utils/sheetFormulaLogical.ts +116 -0
  131. package/src/utils/sheetFormulaLookup.ts +488 -0
  132. package/src/utils/sheetFormulaMath.ts +48 -0
  133. package/src/utils/sheetFormulaParser.ts +729 -0
  134. package/src/utils/sheetFormulaRange.ts +330 -0
  135. package/src/utils/sheetFormulaReference.ts +703 -0
  136. package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
  137. package/src/utils/sheetFormulaReferenceDates.ts +237 -0
  138. package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
  139. package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
  140. package/src/utils/sheetFormulaReferenceMath.ts +95 -0
  141. package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
  142. package/src/utils/sheetFormulaReferenceText.ts +462 -0
  143. package/src/utils/sheetFormulaSyntax.ts +1027 -0
  144. package/src/utils/sheetFormulaText.ts +430 -0
  145. package/src/utils/sheetJournal.ts +200 -0
  146. package/src/utils/sheetNumberFormat.ts +1012 -0
  147. package/src/utils/sheetPreview.ts +68 -0
  148. package/src/utils/sheetSequence.ts +118 -0
  149. package/src/utils/sheetSnapshot.ts +739 -0
  150. package/src/utils/sheetStructureEdit.ts +914 -0
  151. package/src/utils/sheetStructureReferences.ts +389 -0
  152. package/src/utils/square.ts +22 -12
  153. package/src/utils/storage.ts +198 -0
  154. package/src/utils/table-route.ts +127 -11
  155. package/src/utils/time.ts +12 -0
  156. package/src/utils/workflow.ts +334 -40
  157. package/src/utils/workflowLogFingerprint.ts +302 -0
  158. package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
  159. package/src/utils/workflowProgress.ts +280 -0
  160. package/src/utils/workflowTriggers.ts +61 -0
  161. package/tests/agentNote.test.ts +395 -0
  162. package/tests/campaignAI.test.ts +119 -0
  163. package/tests/campaignAccess.test.ts +239 -0
  164. package/tests/campaignEmail.test.ts +441 -0
  165. package/tests/campaignLifecycle.test.ts +134 -0
  166. package/tests/campaignPublication.test.ts +309 -0
  167. package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
  168. package/tests/dataTableRelativeDate.test.ts +412 -0
  169. package/tests/docAccess.test.ts +525 -0
  170. package/tests/editLogEntry.test.ts +112 -0
  171. package/tests/email.test.ts +39 -0
  172. package/tests/fieldDocProgram.test.ts +114 -0
  173. package/tests/logDisplay.fixtures.ts +67 -0
  174. package/tests/logDisplay.test.ts +227 -0
  175. package/tests/noteDoc.test.ts +514 -0
  176. package/tests/richTextHTML.test.ts +185 -0
  177. package/tests/sheetAxisMove.test.ts +352 -0
  178. package/tests/sheetBootstrap.test.ts +1967 -0
  179. package/tests/sheetFeatureReference.test.ts +22 -0
  180. package/tests/sheetFormulaCriteria.test.ts +269 -0
  181. package/tests/sheetFormulaEvaluator.test.ts +468 -0
  182. package/tests/sheetFormulaFunctions.test.ts +538 -0
  183. package/tests/sheetFormulaLanguage.test.ts +361 -0
  184. package/tests/sheetFormulaParity.fixtures.ts +872 -0
  185. package/tests/sheetFormulaParity.test.ts +188 -0
  186. package/tests/sheetFormulaRange.test.ts +167 -0
  187. package/tests/sheetFormulaReference.test.ts +78 -0
  188. package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
  189. package/tests/sheetFormulaTextDate.test.ts +512 -0
  190. package/tests/sheetSequence.test.ts +22 -0
  191. package/tests/sheetSnapshot.test.ts +134 -0
  192. package/tests/sheetStructureEdit.test.ts +537 -0
  193. package/tests/sheetStructureReferences.test.ts +589 -0
  194. package/tests/workflowLifecycleStatus.test.ts +60 -0
  195. package/tests/workflowLogFingerprint.test.ts +203 -0
  196. package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
  197. package/tests/workflowProgress.test.ts +180 -0
  198. package/tests/workflowTriggers.test.ts +29 -0
  199. package/tsconfig.json +10 -10
  200. package/vitest.config.ts +8 -0
  201. package/src/constants/log-activityTexts.ts +0 -235
  202. package/src/constants/product.ts +0 -42
  203. package/src/constants/report.ts +0 -44
  204. package/src/schemas/organization.ts +0 -65
  205. package/src/schemas/productsQuery.ts +0 -53
  206. package/src/schemas/reportsQuery.ts +0 -20
  207. package/src/types/product.d.ts +0 -84
  208. package/src/types/report.d.ts +0 -290
  209. package/src/utils/product-calEvent.ts +0 -455
  210. package/src/utils/report.ts +0 -158
@@ -0,0 +1,537 @@
1
+ import type {
2
+ BILLING_ACCESS_NOTICE_CHANNELS,
3
+ BILLING_ENFORCEMENT_ENUMS,
4
+ BILLING_INTENT_TYPES,
5
+ BILLING_INTERVALS,
6
+ BILLING_LIVE_SUBSCRIPTION_STATUSES,
7
+ BILLING_MANUAL_GRANT_METHODS,
8
+ BILLING_PAYMENT_METHOD_TYPES,
9
+ BILLING_PLAN_KEYS,
10
+ BILLING_PURCHASE_ATTEMPT_STATUSES,
11
+ BILLING_SELF_SERVE_PLAN_KEYS,
12
+ BILLING_STRIPE_EVENT_STATUSES,
13
+ BILLING_STRIPE_INTERVALS,
14
+ } from '../constants/billing.ts';
15
+
16
+ export type BillingPlanKeyEnum = (typeof BILLING_PLAN_KEYS)[number];
17
+ export type BillingSelfServePlanKeyEnum =
18
+ (typeof BILLING_SELF_SERVE_PLAN_KEYS)[number];
19
+ export type BillingIntervalEnum = (typeof BILLING_INTERVALS)[number];
20
+ export type BillingStripeIntervalEnum =
21
+ (typeof BILLING_STRIPE_INTERVALS)[number];
22
+ export type BillingEnforcementEnum = (typeof BILLING_ENFORCEMENT_ENUMS)[number];
23
+ export type BillingManualGrantMethodEnum =
24
+ (typeof BILLING_MANUAL_GRANT_METHODS)[number];
25
+ export type BillingStripeEventStatusEnum =
26
+ (typeof BILLING_STRIPE_EVENT_STATUSES)[number];
27
+ export type BillingPurchaseAttemptStatusEnum =
28
+ (typeof BILLING_PURCHASE_ATTEMPT_STATUSES)[number];
29
+ export type BillingAccessNoticeChannelEnum =
30
+ (typeof BILLING_ACCESS_NOTICE_CHANNELS)[number];
31
+ export type BillingIntentTypeEnum = (typeof BILLING_INTENT_TYPES)[number];
32
+ export type BillingPaymentMethodTypeEnum =
33
+ (typeof BILLING_PAYMENT_METHOD_TYPES)[number];
34
+ export type BillingLiveSubscriptionStatusEnum =
35
+ (typeof BILLING_LIVE_SUBSCRIPTION_STATUSES)[number];
36
+
37
+ /*
38
+ * Stripe address object as stored in billing_customers.address.
39
+ */
40
+ export interface BillingStripeAddressData {
41
+ city: string | null;
42
+ country: string | null;
43
+ line1: string | null;
44
+ line2: string | null;
45
+ postal_code: string | null;
46
+ state: string | null;
47
+ }
48
+
49
+ /*
50
+ * Columns shared by every Stripe mirror table. "stripeAccountId" is NULL for
51
+ * our platform account and acct_... for a connected account; "syncedAt" is
52
+ * when the Stripe fetch behind the row started (the stale-write guard).
53
+ */
54
+ export interface BillingStripeMirrorData {
55
+ id: bigint;
56
+ stripeAccountId: string | null;
57
+ livemode: boolean;
58
+ syncedAt: Date;
59
+ }
60
+
61
+ /*
62
+ * Derived per-organization billing access state (billing_accounts).
63
+ */
64
+ export interface BillingAccountData {
65
+ __table?: 'billing_accounts';
66
+ id: bigint;
67
+ organizationId: bigint;
68
+ enforcement: BillingEnforcementEnum;
69
+ graceDays: number;
70
+ planKey: BillingPlanKeyEnum | null;
71
+ subscriptionStatus: string | null;
72
+ stripePaidThroughAt: Date | null;
73
+ manualPaidThroughAt: Date | null;
74
+ paidThroughAt: Date | null;
75
+ dueThroughAt: Date | null;
76
+ accessEndsAt: Date | null;
77
+ accessLockedAt: Date | null;
78
+ recomputedAt: Date | null;
79
+ notes: string | null;
80
+ createdAt: Date;
81
+ updatedAt: Date;
82
+ }
83
+
84
+ /*
85
+ * Stripe Customer mirror row (billing_customers).
86
+ */
87
+ export interface BillingCustomerData extends BillingStripeMirrorData {
88
+ __table?: 'billing_customers';
89
+ stripeCustomerId: string;
90
+ organizationId: bigint | null;
91
+ counterpartyId: bigint | null;
92
+ email: string | null;
93
+ name: string | null;
94
+ address: BillingStripeAddressData | null;
95
+ taxExempt: string | null;
96
+ metadata: Record<string, string>;
97
+ testClockId: string | null;
98
+ stripeCreatedAt: Date | null;
99
+ deletedAt: Date | null;
100
+ stripeObject: Record<string, unknown>;
101
+ createdAt: Date;
102
+ updatedAt: Date;
103
+ }
104
+
105
+ /*
106
+ * Stripe Product mirror row (billing_products).
107
+ */
108
+ export interface BillingProductData extends BillingStripeMirrorData {
109
+ __table?: 'billing_products';
110
+ stripeProductId: string;
111
+ name: string | null;
112
+ active: boolean;
113
+ planKey: BillingPlanKeyEnum | null;
114
+ taxCode: string | null;
115
+ metadata: Record<string, string>;
116
+ deletedAt: Date | null;
117
+ stripeObject: Record<string, unknown>;
118
+ createdAt: Date;
119
+ updatedAt: Date;
120
+ }
121
+
122
+ /*
123
+ * Stripe Price mirror row (billing_prices).
124
+ */
125
+ export interface BillingPriceData extends BillingStripeMirrorData {
126
+ __table?: 'billing_prices';
127
+ stripePriceId: string;
128
+ stripeProductId: string;
129
+ planKey: BillingPlanKeyEnum | null;
130
+ active: boolean;
131
+ currency: string;
132
+ unitAmount: bigint | null;
133
+ unitAmountDecimal: string | null;
134
+ type: string | null;
135
+ billingInterval: BillingStripeIntervalEnum | null;
136
+ intervalCount: number | null;
137
+ usageType: string | null;
138
+ meterId: string | null;
139
+ taxBehavior: string | null;
140
+ lookupKey: string | null;
141
+ nickname: string | null;
142
+ organizationId: bigint | null;
143
+ metadata: Record<string, string>;
144
+ deletedAt: Date | null;
145
+ stripeObject: Record<string, unknown>;
146
+ createdAt: Date;
147
+ updatedAt: Date;
148
+ }
149
+
150
+ /*
151
+ * Stripe Subscription mirror row (billing_subscriptions).
152
+ */
153
+ export interface BillingSubscriptionData extends BillingStripeMirrorData {
154
+ __table?: 'billing_subscriptions';
155
+ stripeSubscriptionId: string;
156
+ stripeCustomerId: string;
157
+ organizationId: bigint | null;
158
+ status: string;
159
+ collectionMethod: string | null;
160
+ daysUntilDue: number | null;
161
+ planKey: BillingPlanKeyEnum | null;
162
+ billingInterval: BillingStripeIntervalEnum | null;
163
+ currentPeriodStart: Date | null;
164
+ currentPeriodEnd: Date | null;
165
+ cancelAtPeriodEnd: boolean;
166
+ cancelAt: Date | null;
167
+ canceledAt: Date | null;
168
+ endedAt: Date | null;
169
+ latestInvoiceId: string | null;
170
+ stripeScheduleId: string | null;
171
+ testClockId: string | null;
172
+ metadata: Record<string, string>;
173
+ stripeCreatedAt: Date | null;
174
+ stripeObject: Record<string, unknown>;
175
+ createdAt: Date;
176
+ updatedAt: Date;
177
+ }
178
+
179
+ /*
180
+ * Stripe SubscriptionItem mirror row (billing_subscription_items).
181
+ */
182
+ export interface BillingSubscriptionItemData extends BillingStripeMirrorData {
183
+ __table?: 'billing_subscription_items';
184
+ stripeSubscriptionItemId: string;
185
+ stripeSubscriptionId: string;
186
+ stripePriceId: string | null;
187
+ stripeProductId: string | null;
188
+ planKey: BillingPlanKeyEnum | null;
189
+ quantity: bigint | null;
190
+ usageType: string | null;
191
+ meterId: string | null;
192
+ currentPeriodStart: Date | null;
193
+ currentPeriodEnd: Date | null;
194
+ deletedAt: Date | null;
195
+ createdAt: Date;
196
+ updatedAt: Date;
197
+ }
198
+
199
+ /*
200
+ * Stripe Invoice mirror row (billing_invoices). Amounts are minor units.
201
+ */
202
+ export interface BillingInvoiceData extends BillingStripeMirrorData {
203
+ __table?: 'billing_invoices';
204
+ stripeInvoiceId: string;
205
+ stripeCustomerId: string;
206
+ organizationId: bigint | null;
207
+ stripeSubscriptionId: string | null;
208
+ number: string | null;
209
+ status: string | null;
210
+ billingReason: string | null;
211
+ collectionMethod: string | null;
212
+ currency: string;
213
+ subtotal: bigint;
214
+ totalTax: bigint;
215
+ total: bigint;
216
+ amountDue: bigint;
217
+ amountPaid: bigint;
218
+ amountRemaining: bigint;
219
+ amountPaidOffStripe: bigint | null;
220
+ prePaymentCreditNotesAmount: bigint;
221
+ postPaymentCreditNotesAmount: bigint;
222
+ amountReversed: bigint;
223
+ // When the charge fetch behind amountReversed started (its stale-write guard)
224
+ amountReversedSyncedAt: Date | null;
225
+ hostedInvoiceUrl: string | null;
226
+ invoicePdf: string | null;
227
+ dueDate: Date | null;
228
+ finalizedAt: Date | null;
229
+ paidAt: Date | null;
230
+ voidedAt: Date | null;
231
+ markedUncollectibleAt: Date | null;
232
+ automaticTaxStatus: string | null;
233
+ testClockId: string | null;
234
+ metadata: Record<string, string>;
235
+ stripeCreatedAt: Date | null;
236
+ deletedAt: Date | null;
237
+ stripeObject: Record<string, unknown>;
238
+ createdAt: Date;
239
+ updatedAt: Date;
240
+ }
241
+
242
+ /*
243
+ * Stripe invoice line mirror row (billing_invoice_lines). Lines are replaced
244
+ * wholesale per invoice sync, so they have no "updatedAt".
245
+ */
246
+ export interface BillingInvoiceLineData extends BillingStripeMirrorData {
247
+ __table?: 'billing_invoice_lines';
248
+ stripeInvoiceId: string;
249
+ stripeLineId: string;
250
+ parentType: string | null;
251
+ stripeSubscriptionId: string | null;
252
+ stripeSubscriptionItemId: string | null;
253
+ stripeInvoiceItemId: string | null;
254
+ stripePriceId: string | null;
255
+ stripeProductId: string | null;
256
+ planKey: BillingPlanKeyEnum | null;
257
+ description: string | null;
258
+ amount: bigint;
259
+ currency: string;
260
+ // Stripe Decimal quantity as a decimal string
261
+ quantity: string | null;
262
+ periodStart: Date | null;
263
+ periodEnd: Date | null;
264
+ proration: boolean;
265
+ createdAt: Date;
266
+ }
267
+
268
+ /*
269
+ * Latest snapshot of any other Stripe object (billing_stripe_objects).
270
+ */
271
+ export interface BillingStripeObjectData extends BillingStripeMirrorData {
272
+ __table?: 'billing_stripe_objects';
273
+ objectType: string;
274
+ stripeObjectId: string;
275
+ organizationId: bigint | null;
276
+ stripeCustomerId: string | null;
277
+ stripeInvoiceId: string | null;
278
+ status: string | null;
279
+ amount: bigint | null;
280
+ currency: string | null;
281
+ stripeCreatedAt: Date | null;
282
+ deletedAt: Date | null;
283
+ stripeObject: Record<string, unknown>;
284
+ createdAt: Date;
285
+ updatedAt: Date;
286
+ }
287
+
288
+ /*
289
+ * Recorded Stripe webhook event (billing_stripe_events); payload is redacted.
290
+ */
291
+ export interface BillingStripeEventData {
292
+ __table?: 'billing_stripe_events';
293
+ id: bigint;
294
+ stripeEventId: string;
295
+ stripeAccountId: string | null;
296
+ livemode: boolean;
297
+ type: string;
298
+ apiVersion: string | null;
299
+ objectType: string | null;
300
+ stripeObjectId: string | null;
301
+ requestId: string | null;
302
+ requestIdempotencyKey: string | null;
303
+ stripeCreatedAt: Date;
304
+ payload: Record<string, unknown>;
305
+ status: BillingStripeEventStatusEnum;
306
+ attempts: number;
307
+ lastError: string | null;
308
+ organizationId: bigint | null;
309
+ receivedAt: Date;
310
+ processedAt: Date | null;
311
+ updatedAt: Date;
312
+ }
313
+
314
+ /*
315
+ * Staff-recorded renewal paid outside Stripe (billing_manual_grants).
316
+ */
317
+ export interface BillingManualGrantData {
318
+ __table?: 'billing_manual_grants';
319
+ id: bigint;
320
+ organizationId: bigint;
321
+ planKey: BillingPlanKeyEnum;
322
+ periodStart: Date;
323
+ periodEnd: Date;
324
+ amount: bigint | null;
325
+ currency: string;
326
+ method: BillingManualGrantMethodEnum;
327
+ reference: string | null;
328
+ note: string | null;
329
+ createdByAccountId: bigint | null;
330
+ voidedAt: Date | null;
331
+ voidReason: string | null;
332
+ createdAt: Date;
333
+ updatedAt: Date;
334
+ }
335
+
336
+ /*
337
+ * One self-serve purchase attempt (billing_purchase_attempts).
338
+ */
339
+ export interface BillingPurchaseAttemptData {
340
+ __table?: 'billing_purchase_attempts';
341
+ id: bigint;
342
+ organizationId: bigint;
343
+ accountId: bigint | null;
344
+ livemode: boolean;
345
+ stripePriceId: string;
346
+ planKey: BillingPlanKeyEnum | null;
347
+ billingInterval: BillingStripeIntervalEnum | null;
348
+ status: BillingPurchaseAttemptStatusEnum;
349
+ stripeCustomerId: string | null;
350
+ stripeSubscriptionId: string | null;
351
+ idempotencyKey: string;
352
+ errorCode: string | null;
353
+ createdAt: Date;
354
+ updatedAt: Date;
355
+ }
356
+
357
+ /*
358
+ * Throttle row for "subscription expired" notices (billing_access_notices).
359
+ */
360
+ export interface BillingAccessNoticeData {
361
+ __table?: 'billing_access_notices';
362
+ id: bigint;
363
+ organizationId: bigint;
364
+ channel: BillingAccessNoticeChannelEnum;
365
+ recipient: string;
366
+ lastSentAt: Date;
367
+ sentCount: number;
368
+ createdAt: Date;
369
+ updatedAt: Date;
370
+ }
371
+
372
+ /*
373
+ * The billing_accounts fields that access recompute compares and publishes.
374
+ */
375
+ export type BillingAccountSnapshot = Pick<
376
+ BillingAccountData,
377
+ | 'organizationId'
378
+ | 'enforcement'
379
+ | 'graceDays'
380
+ | 'planKey'
381
+ | 'subscriptionStatus'
382
+ | 'stripePaidThroughAt'
383
+ | 'manualPaidThroughAt'
384
+ | 'paidThroughAt'
385
+ | 'dueThroughAt'
386
+ | 'accessEndsAt'
387
+ | 'accessLockedAt'
388
+ >;
389
+
390
+ /*
391
+ * Lock state change produced by one access recompute.
392
+ */
393
+ export type BillingAccessLockTransition = 'LOCKED' | 'UNLOCKED';
394
+
395
+ /*
396
+ * Result of one access recompute that changed billing_accounts; published
397
+ * only after the transaction that produced it commits.
398
+ */
399
+ export interface BillingAccessChange {
400
+ organizationId: bigint;
401
+ before: BillingAccountSnapshot | null;
402
+ after: BillingAccountSnapshot;
403
+ lockTransition: BillingAccessLockTransition | null;
404
+ }
405
+
406
+ /*
407
+ * GraphQL BillingPlanPrice.
408
+ */
409
+ export interface BillingPlanPriceGQL {
410
+ priceId: string;
411
+ lookupKey: string;
412
+ planKey: BillingPlanKeyEnum;
413
+ interval: BillingIntervalEnum;
414
+ unitAmount: number;
415
+ currency: string;
416
+ }
417
+
418
+ /*
419
+ * GraphQL BillingPlan.
420
+ */
421
+ export interface BillingPlanGQL {
422
+ planKey: BillingPlanKeyEnum;
423
+ name: string;
424
+ contactSales: boolean;
425
+ prices: BillingPlanPriceGQL[];
426
+ }
427
+
428
+ /*
429
+ * GraphQL BillingClientConfig.
430
+ */
431
+ export interface BillingClientConfigGQL {
432
+ publishableKey: string;
433
+ livemode: boolean;
434
+ paymentMethodTypes: string[];
435
+ }
436
+
437
+ /*
438
+ * GraphQL BillingAccess (also OrganizationRelationship.billingAccess).
439
+ */
440
+ export interface BillingAccessGQL {
441
+ enforcement: BillingEnforcementEnum;
442
+ planKey: BillingPlanKeyEnum | null;
443
+ subscriptionStatus: string | null;
444
+ paidThroughAt: string | null;
445
+ accessEndsAt: string | null;
446
+ accessLockedAt: string | null;
447
+ graceDays: number;
448
+ }
449
+
450
+ /*
451
+ * GraphQL BillingSubscriptionSummary.
452
+ */
453
+ export interface BillingSubscriptionSummaryGQL {
454
+ id: string;
455
+ status: string;
456
+ planKey: BillingPlanKeyEnum | null;
457
+ interval: BillingIntervalEnum | null;
458
+ currentPeriodEnd: string | null;
459
+ cancelAtPeriodEnd: boolean;
460
+ collectionMethod: string | null;
461
+ unitAmount: number | null;
462
+ currency: string | null;
463
+ }
464
+
465
+ /*
466
+ * GraphQL BillingInvoiceSummary.
467
+ */
468
+ export interface BillingInvoiceSummaryGQL {
469
+ id: string;
470
+ number: string | null;
471
+ status: string;
472
+ total: number;
473
+ amountDue: number;
474
+ amountPaid: number;
475
+ currency: string;
476
+ hostedInvoiceUrl: string | null;
477
+ invoicePdf: string | null;
478
+ periodStart: string | null;
479
+ periodEnd: string | null;
480
+ paidAt: string | null;
481
+ dueDate: string | null;
482
+ createdAt: string | null;
483
+ }
484
+
485
+ /*
486
+ * GraphQL OrganizationBilling.
487
+ */
488
+ export interface OrganizationBillingGQL {
489
+ organizationId: string;
490
+ access: BillingAccessGQL | null;
491
+ subscription: BillingSubscriptionSummaryGQL | null;
492
+ invoices: BillingInvoiceSummaryGQL[];
493
+ }
494
+
495
+ /*
496
+ * GraphQL BillingPurchasePreview.
497
+ */
498
+ export interface BillingPurchasePreviewGQL {
499
+ subtotal: number;
500
+ tax: number;
501
+ total: number;
502
+ currency: string;
503
+ taxStatus: string | null;
504
+ }
505
+
506
+ /*
507
+ * GraphQL BillingPurchaseStart. clientSecret goes only to the requesting user.
508
+ */
509
+ export interface BillingPurchaseStartGQL {
510
+ purchaseAttemptId: string;
511
+ subscriptionId: string;
512
+ intentType: BillingIntentTypeEnum;
513
+ clientSecret: string;
514
+ amountDue: number;
515
+ currency: string;
516
+ }
517
+
518
+ /*
519
+ * GraphQL BillingAddressInput.
520
+ */
521
+ export interface BillingAddressInputGQL {
522
+ line1: string;
523
+ line2?: string | null;
524
+ city: string;
525
+ state?: string | null;
526
+ postalCode: string;
527
+ country: string;
528
+ }
529
+
530
+ /*
531
+ * GraphQL BillingDetailsInput.
532
+ */
533
+ export interface BillingDetailsInputGQL {
534
+ name: string;
535
+ email: string;
536
+ address: BillingAddressInputGQL;
537
+ }