@antelopejs/interface-dms-saas 0.0.1

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 (165) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +51 -0
  3. package/dist/billing.d.ts +25 -0
  4. package/dist/billing.js +15 -0
  5. package/dist/billing.js.map +1 -0
  6. package/dist/data-api.d.ts +1 -0
  7. package/dist/data-api.js +6 -0
  8. package/dist/data-api.js.map +1 -0
  9. package/dist/db/index.d.ts +2 -0
  10. package/dist/db/index.js +19 -0
  11. package/dist/db/index.js.map +1 -0
  12. package/dist/db/models/billingSettings.model.d.ts +22 -0
  13. package/dist/db/models/billingSettings.model.js +9 -0
  14. package/dist/db/models/billingSettings.model.js.map +1 -0
  15. package/dist/db/models/creditNotes.model.d.ts +25 -0
  16. package/dist/db/models/creditNotes.model.js +26 -0
  17. package/dist/db/models/creditNotes.model.js.map +1 -0
  18. package/dist/db/models/features.model.d.ts +22 -0
  19. package/dist/db/models/features.model.js +9 -0
  20. package/dist/db/models/features.model.js.map +1 -0
  21. package/dist/db/models/index.d.ts +19 -0
  22. package/dist/db/models/index.js +36 -0
  23. package/dist/db/models/index.js.map +1 -0
  24. package/dist/db/models/invoices.model.d.ts +29 -0
  25. package/dist/db/models/invoices.model.js +60 -0
  26. package/dist/db/models/invoices.model.js.map +1 -0
  27. package/dist/db/models/legalDocuments.model.d.ts +22 -0
  28. package/dist/db/models/legalDocuments.model.js +9 -0
  29. package/dist/db/models/legalDocuments.model.js.map +1 -0
  30. package/dist/db/models/planMigrations.model.d.ts +29 -0
  31. package/dist/db/models/planMigrations.model.js +70 -0
  32. package/dist/db/models/planMigrations.model.js.map +1 -0
  33. package/dist/db/models/plans.model.d.ts +31 -0
  34. package/dist/db/models/plans.model.js +74 -0
  35. package/dist/db/models/plans.model.js.map +1 -0
  36. package/dist/db/models/platformNotes.model.d.ts +33 -0
  37. package/dist/db/models/platformNotes.model.js +27 -0
  38. package/dist/db/models/platformNotes.model.js.map +1 -0
  39. package/dist/db/models/refunds.model.d.ts +23 -0
  40. package/dist/db/models/refunds.model.js +17 -0
  41. package/dist/db/models/refunds.model.js.map +1 -0
  42. package/dist/db/models/revision.d.ts +1 -0
  43. package/dist/db/models/revision.js +14 -0
  44. package/dist/db/models/revision.js.map +1 -0
  45. package/dist/db/models/segments.model.d.ts +29 -0
  46. package/dist/db/models/segments.model.js +81 -0
  47. package/dist/db/models/segments.model.js.map +1 -0
  48. package/dist/db/models/stripeWebhookEvents.model.d.ts +26 -0
  49. package/dist/db/models/stripeWebhookEvents.model.js +70 -0
  50. package/dist/db/models/stripeWebhookEvents.model.js.map +1 -0
  51. package/dist/db/models/supportMessages.model.d.ts +23 -0
  52. package/dist/db/models/supportMessages.model.js +17 -0
  53. package/dist/db/models/supportMessages.model.js.map +1 -0
  54. package/dist/db/models/supportTicketEvents.model.d.ts +22 -0
  55. package/dist/db/models/supportTicketEvents.model.js +9 -0
  56. package/dist/db/models/supportTicketEvents.model.js.map +1 -0
  57. package/dist/db/models/supportTickets.model.d.ts +25 -0
  58. package/dist/db/models/supportTickets.model.js +32 -0
  59. package/dist/db/models/supportTickets.model.js.map +1 -0
  60. package/dist/db/models/tenantBillingInfo.model.d.ts +24 -0
  61. package/dist/db/models/tenantBillingInfo.model.js +20 -0
  62. package/dist/db/models/tenantBillingInfo.model.js.map +1 -0
  63. package/dist/db/models/tenantBillingState.model.d.ts +28 -0
  64. package/dist/db/models/tenantBillingState.model.js +72 -0
  65. package/dist/db/models/tenantBillingState.model.js.map +1 -0
  66. package/dist/db/models/tenantSubscriptions.model.d.ts +51 -0
  67. package/dist/db/models/tenantSubscriptions.model.js +305 -0
  68. package/dist/db/models/tenantSubscriptions.model.js.map +1 -0
  69. package/dist/db/models/trialConsumptions.model.d.ts +24 -0
  70. package/dist/db/models/trialConsumptions.model.js +30 -0
  71. package/dist/db/models/trialConsumptions.model.js.map +1 -0
  72. package/dist/db/models/update-result.d.ts +1 -0
  73. package/dist/db/models/update-result.js +13 -0
  74. package/dist/db/models/update-result.js.map +1 -0
  75. package/dist/db/models/userSegments.model.d.ts +30 -0
  76. package/dist/db/models/userSegments.model.js +97 -0
  77. package/dist/db/models/userSegments.model.js.map +1 -0
  78. package/dist/db/tables/billingSettings.table.d.ts +22 -0
  79. package/dist/db/tables/billingSettings.table.js +73 -0
  80. package/dist/db/tables/billingSettings.table.js.map +1 -0
  81. package/dist/db/tables/creditNotes.table.d.ts +26 -0
  82. package/dist/db/tables/creditNotes.table.js +110 -0
  83. package/dist/db/tables/creditNotes.table.js.map +1 -0
  84. package/dist/db/tables/features.table.d.ts +18 -0
  85. package/dist/db/tables/features.table.js +70 -0
  86. package/dist/db/tables/features.table.js.map +1 -0
  87. package/dist/db/tables/index.d.ts +19 -0
  88. package/dist/db/tables/index.js +36 -0
  89. package/dist/db/tables/index.js.map +1 -0
  90. package/dist/db/tables/invoices.table.d.ts +47 -0
  91. package/dist/db/tables/invoices.table.js +140 -0
  92. package/dist/db/tables/invoices.table.js.map +1 -0
  93. package/dist/db/tables/legalDocuments.table.d.ts +10 -0
  94. package/dist/db/tables/legalDocuments.table.js +44 -0
  95. package/dist/db/tables/legalDocuments.table.js.map +1 -0
  96. package/dist/db/tables/planMigrations.table.d.ts +61 -0
  97. package/dist/db/tables/planMigrations.table.js +114 -0
  98. package/dist/db/tables/planMigrations.table.js.map +1 -0
  99. package/dist/db/tables/plans.table.d.ts +41 -0
  100. package/dist/db/tables/plans.table.js +125 -0
  101. package/dist/db/tables/plans.table.js.map +1 -0
  102. package/dist/db/tables/platformNotes.table.d.ts +13 -0
  103. package/dist/db/tables/platformNotes.table.js +58 -0
  104. package/dist/db/tables/platformNotes.table.js.map +1 -0
  105. package/dist/db/tables/refunds.table.d.ts +15 -0
  106. package/dist/db/tables/refunds.table.js +70 -0
  107. package/dist/db/tables/refunds.table.js.map +1 -0
  108. package/dist/db/tables/segments.table.d.ts +37 -0
  109. package/dist/db/tables/segments.table.js +79 -0
  110. package/dist/db/tables/segments.table.js.map +1 -0
  111. package/dist/db/tables/stripeWebhookEvents.table.d.ts +12 -0
  112. package/dist/db/tables/stripeWebhookEvents.table.js +54 -0
  113. package/dist/db/tables/stripeWebhookEvents.table.js.map +1 -0
  114. package/dist/db/tables/supportMessages.table.d.ts +14 -0
  115. package/dist/db/tables/supportMessages.table.js +62 -0
  116. package/dist/db/tables/supportMessages.table.js.map +1 -0
  117. package/dist/db/tables/supportTicketEvents.table.d.ts +14 -0
  118. package/dist/db/tables/supportTicketEvents.table.js +61 -0
  119. package/dist/db/tables/supportTicketEvents.table.js.map +1 -0
  120. package/dist/db/tables/supportTickets.table.d.ts +25 -0
  121. package/dist/db/tables/supportTickets.table.js +109 -0
  122. package/dist/db/tables/supportTickets.table.js.map +1 -0
  123. package/dist/db/tables/tenantBillingInfo.table.d.ts +24 -0
  124. package/dist/db/tables/tenantBillingInfo.table.js +62 -0
  125. package/dist/db/tables/tenantBillingInfo.table.js.map +1 -0
  126. package/dist/db/tables/tenantBillingState.table.d.ts +12 -0
  127. package/dist/db/tables/tenantBillingState.table.js +59 -0
  128. package/dist/db/tables/tenantBillingState.table.js.map +1 -0
  129. package/dist/db/tables/tenantSubscriptions.table.d.ts +46 -0
  130. package/dist/db/tables/tenantSubscriptions.table.js +157 -0
  131. package/dist/db/tables/tenantSubscriptions.table.js.map +1 -0
  132. package/dist/db/tables/trialConsumptions.table.d.ts +10 -0
  133. package/dist/db/tables/trialConsumptions.table.js +55 -0
  134. package/dist/db/tables/trialConsumptions.table.js.map +1 -0
  135. package/dist/db/tables/userSegments.table.d.ts +11 -0
  136. package/dist/db/tables/userSegments.table.js +56 -0
  137. package/dist/db/tables/userSegments.table.js.map +1 -0
  138. package/dist/hidden-filter.d.ts +1 -0
  139. package/dist/hidden-filter.js +10 -0
  140. package/dist/hidden-filter.js.map +1 -0
  141. package/dist/index.d.ts +8 -0
  142. package/dist/index.js +48 -0
  143. package/dist/index.js.map +1 -0
  144. package/dist/invoice-line-items.d.ts +42 -0
  145. package/dist/invoice-line-items.js +83 -0
  146. package/dist/invoice-line-items.js.map +1 -0
  147. package/dist/page-definitions.d.ts +17 -0
  148. package/dist/page-definitions.js +60 -0
  149. package/dist/page-definitions.js.map +1 -0
  150. package/dist/pages.d.ts +59 -0
  151. package/dist/pages.js +88 -0
  152. package/dist/pages.js.map +1 -0
  153. package/dist/plans.d.ts +27 -0
  154. package/dist/plans.js +60 -0
  155. package/dist/plans.js.map +1 -0
  156. package/dist/provisioning.d.ts +5 -0
  157. package/dist/provisioning.js +3 -0
  158. package/dist/provisioning.js.map +1 -0
  159. package/dist/registration.d.ts +6 -0
  160. package/dist/registration.js +9 -0
  161. package/dist/registration.js.map +1 -0
  162. package/dist/workspace-lifecycle.d.ts +27 -0
  163. package/dist/workspace-lifecycle.js +30 -0
  164. package/dist/workspace-lifecycle.js.map +1 -0
  165. package/package.json +108 -0
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TenantSubscriptionModel = void 0;
4
+ const node_crypto_1 = require("node:crypto");
5
+ const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
6
+ const tenantSubscriptions_table_1 = require("../tables/tenantSubscriptions.table");
7
+ const STATUS_CANCELLED = "cancelled";
8
+ const STATUS_PAST_DUE = "past_due";
9
+ const STATUS_ACTIVE = "active";
10
+ const STATUS_SUSPENDED = "suspended";
11
+ class TenantSubscriptionModel extends (0, interface_database_decorators_1.BasicDataModel)(tenantSubscriptions_table_1.TenantSubscription, tenantSubscriptions_table_1.tenantSubscriptionsTableName) {
12
+ insert(rows, options) {
13
+ const initialize = (row) => ({ ...row, revision: (0, node_crypto_1.randomUUID)() });
14
+ return super.insert(Array.isArray(rows) ? rows.map(initialize) : initialize(rows), options);
15
+ }
16
+ async mutateRevision(current, patch) {
17
+ const instance = TenantSubscriptionModel.fromPlainData(patch);
18
+ (0, interface_database_decorators_1.triggerEvent)(instance, "update");
19
+ return this.table
20
+ .atomicMutation(current._id, {
21
+ type: "update",
22
+ revisionField: "revision",
23
+ expectedRevision: current.revision === undefined
24
+ ? { kind: "missing" }
25
+ : current.revision,
26
+ nextRevision: (0, node_crypto_1.randomUUID)(),
27
+ patch: TenantSubscriptionModel.toDatabase(instance),
28
+ })
29
+ .run();
30
+ }
31
+ async update(idOrPatch, patchOrOptions, options) {
32
+ const id = typeof idOrPatch === "string" ? idOrPatch : idOrPatch._id;
33
+ const patch = typeof idOrPatch === "string"
34
+ ? patchOrOptions
35
+ : idOrPatch;
36
+ const validation = typeof idOrPatch === "string"
37
+ ? options
38
+ : patchOrOptions;
39
+ if (!id)
40
+ throw new Error("Subscription identity is required");
41
+ if (validation?.validate &&
42
+ !TenantSubscriptionModel.validate(patch, { partial: true }).ok)
43
+ throw new Error("Invalid subscription patch");
44
+ const current = await this.get(id);
45
+ if (!current)
46
+ return 0;
47
+ if (current.deletionStartedAt || current.domainTransition)
48
+ throw new Error("Subscription transition requires reconciliation");
49
+ const { _id, ...changes } = patch;
50
+ const outcome = await this.mutateRevision(current, changes);
51
+ if (outcome !== "applied")
52
+ throw new Error(`Subscription update ${outcome}; reload before retry`);
53
+ return 1;
54
+ }
55
+ async beginTransition(current, intent) {
56
+ if (current.deletionStartedAt)
57
+ throw new Error("Subscription deletion has started");
58
+ if (current.domainTransition &&
59
+ (current.domainTransition.operationId !== intent.operationId ||
60
+ current.domainTransition.kind !== intent.kind ||
61
+ current.domainTransition.targetPlanId !== intent.targetPlanId ||
62
+ new Date(current.domainTransition.requestedAt).getTime() !==
63
+ intent.requestedAt.getTime())) {
64
+ throw new Error("Subscription has a different pending transition");
65
+ }
66
+ const outcome = await this.mutateRevision(current, {
67
+ domainTransition: intent,
68
+ });
69
+ if (outcome !== "applied")
70
+ throw new Error(`Subscription admission ${outcome}; reconciliation required`);
71
+ }
72
+ async updateDuringTransition(id, operationId, patch) {
73
+ const current = await this.get(id);
74
+ if (!current ||
75
+ current.deletionStartedAt ||
76
+ current.domainTransition?.operationId !== operationId)
77
+ throw new Error("Subscription operation is no longer current");
78
+ const outcome = await this.mutateRevision(current, patch);
79
+ if (outcome !== "applied")
80
+ throw new Error(`Subscription operation ${outcome}; reconciliation required`);
81
+ }
82
+ async completeTransition(id, operationId, patch) {
83
+ await this.updateDuringTransition(id, operationId, {
84
+ ...patch,
85
+ domainTransition: null,
86
+ });
87
+ }
88
+ async findOne() {
89
+ const row = await this.table
90
+ .orderBy("updatedAt", "desc")
91
+ .nth(0)
92
+ .default(undefined)
93
+ .run();
94
+ return row ? TenantSubscriptionModel.fromDatabase(row) : undefined;
95
+ }
96
+ async findOneByStripeCustomer(stripeCustomerId) {
97
+ const row = await this.table
98
+ .getAll(stripeCustomerId, "stripeCustomerId")
99
+ .nth(0)
100
+ .default(undefined)
101
+ .run();
102
+ return row ? TenantSubscriptionModel.fromDatabase(row) : undefined;
103
+ }
104
+ async findByCardFingerprint(cardFingerprint) {
105
+ const rows = await this.table
106
+ .getAll(cardFingerprint, "cardFingerprint")
107
+ .filter((row) => row.key("status").ne(STATUS_CANCELLED))
108
+ .run();
109
+ return rows
110
+ .map((row) => TenantSubscriptionModel.fromDatabase(row))
111
+ .filter((row) => row !== undefined);
112
+ }
113
+ async findByPlan(planId) {
114
+ const rows = await this.table.getAll(planId, "planId").run();
115
+ return rows
116
+ .map((row) => TenantSubscriptionModel.fromDatabase(row))
117
+ .filter((row) => row !== undefined);
118
+ }
119
+ async countByPlan(planId) {
120
+ return this.table.getAll(planId, "planId").count().run();
121
+ }
122
+ async claimSelfRefund(subscriptionId) {
123
+ const existing = await this.get(subscriptionId);
124
+ if (!existing || existing.refundRequestedAt)
125
+ return false;
126
+ await this.update(subscriptionId, { refundRequestedAt: new Date() });
127
+ return true;
128
+ }
129
+ async releaseSelfRefund(subscriptionId) {
130
+ await this.update(subscriptionId, { refundRequestedAt: null });
131
+ }
132
+ async findByStatus(status) {
133
+ const rows = await this.table.getAll(status, "status").run();
134
+ return rows
135
+ .map((row) => TenantSubscriptionModel.fromDatabase(row))
136
+ .filter((row) => row !== undefined);
137
+ }
138
+ async findCancelledOrPastDue() {
139
+ const rows = await this.table
140
+ .getAll([STATUS_CANCELLED, STATUS_PAST_DUE], "status")
141
+ .run();
142
+ return rows
143
+ .map((row) => TenantSubscriptionModel.fromDatabase(row))
144
+ .filter((row) => row !== undefined);
145
+ }
146
+ async findCancelledUpdatedBefore(cutoff) {
147
+ const rows = await this.table
148
+ .filter((row) => row
149
+ .key("deletionStartedAt")
150
+ .ne(null)
151
+ .or(row
152
+ .key("status")
153
+ .eq(STATUS_CANCELLED)
154
+ .and(row.key("updatedAt").lt(cutoff))))
155
+ .run();
156
+ return rows
157
+ .map((row) => TenantSubscriptionModel.fromDatabase(row))
158
+ .filter((row) => row !== undefined);
159
+ }
160
+ async findPastDueSinceBefore(cutoff) {
161
+ const rows = await this.table
162
+ .getAll(STATUS_PAST_DUE, "status")
163
+ .filter((row) => row
164
+ .key("pastDueSince")
165
+ .ne(null)
166
+ .and(row.key("pastDueSince").lt(cutoff)))
167
+ .run();
168
+ return rows
169
+ .map((row) => TenantSubscriptionModel.fromDatabase(row))
170
+ .filter((row) => row !== undefined);
171
+ }
172
+ async suspendPastDue(subscriptionId, cutoff) {
173
+ const current = await this.get(subscriptionId);
174
+ if (!current ||
175
+ current.deletionStartedAt ||
176
+ current.domainTransition ||
177
+ current.status !== STATUS_PAST_DUE ||
178
+ !current.pastDueSince ||
179
+ current.pastDueSince >= cutoff)
180
+ return;
181
+ const outcome = await this.mutateRevision(current, {
182
+ status: STATUS_SUSPENDED,
183
+ cronNotification: {
184
+ kind: "suspended",
185
+ eventId: JSON.stringify([
186
+ "suspended",
187
+ current._id,
188
+ current.pastDueSince.toISOString(),
189
+ ]),
190
+ },
191
+ });
192
+ if (outcome === "unknown")
193
+ throw new Error("Suspension outcome is unknown");
194
+ }
195
+ async findExpiredFreeBefore(cutoff) {
196
+ const rows = await this.table
197
+ .getAll(STATUS_ACTIVE, "status")
198
+ .filter((row) => row
199
+ .key("freeUntil")
200
+ .ne(null)
201
+ .and(row.key("freeUntil").lt(cutoff))
202
+ .and(row.key("stripeSubscriptionId").eq(null)))
203
+ .run();
204
+ return rows
205
+ .map((row) => TenantSubscriptionModel.fromDatabase(row))
206
+ .filter((row) => row !== undefined);
207
+ }
208
+ async findFreeEndingBetween(start, end) {
209
+ const rows = await this.table
210
+ .getAll(STATUS_ACTIVE, "status")
211
+ .filter((row) => row
212
+ .key("freeUntil")
213
+ .ne(null)
214
+ .and(row.key("freeUntil").ge(start))
215
+ .and(row.key("freeUntil").lt(end))
216
+ .and(row.key("stripeSubscriptionId").eq(null)))
217
+ .run();
218
+ return rows
219
+ .map((row) => TenantSubscriptionModel.fromDatabase(row))
220
+ .filter((row) => row !== undefined);
221
+ }
222
+ async expireFree(subscriptionId, cutoff) {
223
+ const current = await this.get(subscriptionId);
224
+ if (!current ||
225
+ current.deletionStartedAt ||
226
+ current.domainTransition ||
227
+ current.status !== STATUS_ACTIVE ||
228
+ !current.freeUntil ||
229
+ current.freeUntil >= cutoff ||
230
+ current.stripeSubscriptionId)
231
+ return;
232
+ const outcome = await this.mutateRevision(current, {
233
+ status: STATUS_PAST_DUE,
234
+ pastDueSince: new Date(),
235
+ cronNotification: {
236
+ kind: "free_expired",
237
+ eventId: JSON.stringify([
238
+ "free_expired",
239
+ current._id,
240
+ current.freeUntil.toISOString(),
241
+ ]),
242
+ },
243
+ });
244
+ if (outcome === "unknown")
245
+ throw new Error("Free expiry outcome is unknown");
246
+ }
247
+ async findCronNotifications(kind) {
248
+ const rows = await this.table
249
+ .filter((row) => row.key("cronNotification").ne(null))
250
+ .run();
251
+ return rows
252
+ .map((row) => TenantSubscriptionModel.fromDatabase(row))
253
+ .filter((row) => row?.cronNotification?.kind === kind);
254
+ }
255
+ async completeCronNotification(subscription) {
256
+ const current = await this.get(subscription._id);
257
+ if (!current ||
258
+ current.cronNotification?.eventId !==
259
+ subscription.cronNotification?.eventId)
260
+ return;
261
+ const outcome = await this.mutateRevision(current, {
262
+ cronNotification: null,
263
+ });
264
+ if (outcome === "unknown")
265
+ throw new Error("Notification acknowledgement is unknown");
266
+ }
267
+ async beginCancelledDeletion(subscriptionId, cutoff) {
268
+ const current = await this.get(subscriptionId);
269
+ if (!current)
270
+ return undefined;
271
+ if (current.deletionStartedAt)
272
+ return current;
273
+ if (current.domainTransition ||
274
+ current.status !== STATUS_CANCELLED ||
275
+ current.updatedAt >= cutoff)
276
+ return undefined;
277
+ const outcome = await this.mutateRevision(current, {
278
+ deletionStartedAt: new Date(),
279
+ cronNotification: null,
280
+ });
281
+ if (outcome === "unknown")
282
+ throw new Error("Deletion admission outcome is unknown");
283
+ return outcome === "applied" ? this.get(subscriptionId) : undefined;
284
+ }
285
+ async finishDeletion(subscription) {
286
+ if (!subscription.deletionStartedAt)
287
+ throw new Error("Subscription deletion was not admitted");
288
+ const outcome = await this.table
289
+ .atomicMutation(subscription._id, {
290
+ type: "delete",
291
+ revisionField: "revision",
292
+ expectedRevision: subscription.revision === undefined
293
+ ? { kind: "missing" }
294
+ : subscription.revision,
295
+ })
296
+ .run();
297
+ if (outcome === "unknown")
298
+ throw new Error("Subscription deletion outcome is unknown");
299
+ }
300
+ async deleteAll() {
301
+ await this.table.delete().run();
302
+ }
303
+ }
304
+ exports.TenantSubscriptionModel = TenantSubscriptionModel;
305
+ //# sourceMappingURL=tenantSubscriptions.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tenantSubscriptions.model.js","sourceRoot":"","sources":["../../../src/db/models/tenantSubscriptions.model.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAEzC,6FAKmD;AACnD,mFAM6C;AAE7C,MAAM,gBAAgB,GAA6B,WAAW,CAAC;AAC/D,MAAM,eAAe,GAA6B,UAAU,CAAC;AAC7D,MAAM,aAAa,GAA6B,QAAQ,CAAC;AACzD,MAAM,gBAAgB,GAA6B,WAAW,CAAC;AAG/D,MAAa,uBAAwB,SAAQ,IAAA,8CAAc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c,CAAC,YAAY,CAAC,GAAG,EAAE;YAChC,IAAI,EAAE,QAAQ;YACd,aAAa,EAAE,UAAU;YACzB,gBAAgB,EACd,YAAY,CAAC,QAAQ,KAAK,SAAS;gBACjC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE;gBACrB,CAAC,CAAC,YAAY,CAAC,QAAQ;SAC5B,CAAC;aACD,GAAG,EAAE,CAAC;QACT,IAAI,OAAO,KAAK,SAAS;YACvB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;CACF;AA9ZD,0DA8ZC"}
@@ -0,0 +1,24 @@
1
+ import { TrialConsumption } from "../tables/trialConsumptions.table";
2
+ declare const TrialConsumptionModel_base: {
3
+ new (database: import("@antelopejs/interface-database").SchemaInstance<any>): {
4
+ readonly table: import("@antelopejs/interface-database").Table<TrialConsumption>;
5
+ readonly database: import("@antelopejs/interface-database").SchemaInstance<any>;
6
+ get(id: string): PromiseLike<TrialConsumption | undefined>;
7
+ getBy(index: keyof TrialConsumption, ...keys: any[]): PromiseLike<TrialConsumption[]>;
8
+ getAll(): PromiseLike<TrialConsumption[]>;
9
+ insert(obj: import("@antelopejs/interface-database-decorators").DeepPartial<TrialConsumption> | import("@antelopejs/interface-database-decorators").DeepPartial<TrialConsumption>[], options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<string[]>;
10
+ update(id: string, obj: import("@antelopejs/interface-database-decorators").DeepPartial<TrialConsumption>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
11
+ update(obj: import("@antelopejs/interface-database-decorators").DeepPartial<TrialConsumption>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
12
+ delete(id: string): Promise<number>;
13
+ };
14
+ readonly schemaName: string;
15
+ fromPlainData(obj: any): TrialConsumption;
16
+ fromDatabase(obj: any): TrialConsumption | undefined;
17
+ toDatabase(obj: any): Record<string, any>;
18
+ validate(obj: unknown, options?: import("@antelopejs/interface-database-decorators").ValidateInputOptions): import("@antelopejs/interface-database-decorators").ValidationResult;
19
+ };
20
+ export declare class TrialConsumptionModel extends TrialConsumptionModel_base {
21
+ findByUser(userId: string): Promise<TrialConsumption[]>;
22
+ existsForIdentity(emailHash: string, paymentFingerprint: string | null): Promise<boolean>;
23
+ }
24
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrialConsumptionModel = void 0;
4
+ const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
5
+ const trialConsumptions_table_1 = require("../tables/trialConsumptions.table");
6
+ class TrialConsumptionModel extends (0, interface_database_decorators_1.BasicDataModel)(trialConsumptions_table_1.TrialConsumption, trialConsumptions_table_1.trialConsumptionsTableName) {
7
+ async findByUser(userId) {
8
+ const rows = await this.table.getAll(userId, "userId").run();
9
+ return rows
10
+ .map((row) => TrialConsumptionModel.fromDatabase(row))
11
+ .filter((row) => row !== undefined);
12
+ }
13
+ async existsForIdentity(emailHash, paymentFingerprint) {
14
+ const emailCount = await this.table
15
+ .getAll(emailHash, "emailHash")
16
+ .count()
17
+ .run();
18
+ if (emailCount > 0)
19
+ return true;
20
+ if (!paymentFingerprint)
21
+ return false;
22
+ const fingerprintCount = await this.table
23
+ .getAll(paymentFingerprint, "paymentFingerprint")
24
+ .count()
25
+ .run();
26
+ return fingerprintCount > 0;
27
+ }
28
+ }
29
+ exports.TrialConsumptionModel = TrialConsumptionModel;
30
+ //# sourceMappingURL=trialConsumptions.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trialConsumptions.model.js","sourceRoot":"","sources":["../../../src/db/models/trialConsumptions.model.ts"],"names":[],"mappings":";;;AAAA,6FAA2E;AAC3E,+EAG2C;AAG3C,MAAa,qBAAsB,SAAQ,IAAA,8CAAc,EACvD,0CAAgB,EAChB,oDAA0B,CAC3B;IACC,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;QAC7D,OAAO,IAAI;aACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,qBAAqB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;aACrD,MAAM,CAAC,CAAC,GAAG,EAA2B,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,iBAAiB,CACrB,SAAiB,EACjB,kBAAiC;QAEjC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK;aAChC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC;aAC9B,KAAK,EAAE;aACP,GAAG,EAAE,CAAC;QACT,IAAI,UAAU,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAChC,IAAI,CAAC,kBAAkB;YAAE,OAAO,KAAK,CAAC;QACtC,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,KAAK;aACtC,MAAM,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;aAChD,KAAK,EAAE;aACP,GAAG,EAAE,CAAC;QACT,OAAO,gBAAgB,GAAG,CAAC,CAAC;IAC9B,CAAC;CACF;AA3BD,sDA2BC"}
@@ -0,0 +1 @@
1
+ export declare function hasSelectedRow(result: unknown): boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasSelectedRow = hasSelectedRow;
4
+ function hasSelectedRow(result) {
5
+ if (typeof result === "number")
6
+ return result > 0;
7
+ const counts = result;
8
+ return Boolean(counts?.matchedCount ||
9
+ counts?.modifiedCount ||
10
+ counts?.replaced ||
11
+ counts?.unchanged);
12
+ }
13
+ //# sourceMappingURL=update-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-result.js","sourceRoot":"","sources":["../../../src/db/models/update-result.ts"],"names":[],"mappings":";;AAQA,wCASC;AATD,SAAgB,cAAc,CAAC,MAAe;IAC5C,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,GAAG,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAkC,CAAC;IAClD,OAAO,OAAO,CACZ,MAAM,EAAE,YAAY;QACpB,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,SAAS,CAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { Segment } from "../tables/segments.table";
2
+ import { UserSegment } from "../tables/userSegments.table";
3
+ declare const UserSegmentModel_base: {
4
+ new (database: import("@antelopejs/interface-database").SchemaInstance<any>): {
5
+ readonly table: import("@antelopejs/interface-database").Table<UserSegment>;
6
+ readonly database: import("@antelopejs/interface-database").SchemaInstance<any>;
7
+ get(id: string): PromiseLike<UserSegment | undefined>;
8
+ getBy(index: keyof UserSegment, ...keys: any[]): PromiseLike<UserSegment[]>;
9
+ getAll(): PromiseLike<UserSegment[]>;
10
+ insert(obj: import("@antelopejs/interface-database-decorators").DeepPartial<UserSegment> | import("@antelopejs/interface-database-decorators").DeepPartial<UserSegment>[], options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<string[]>;
11
+ update(id: string, obj: import("@antelopejs/interface-database-decorators").DeepPartial<UserSegment>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
12
+ update(obj: import("@antelopejs/interface-database-decorators").DeepPartial<UserSegment>, options?: import("@antelopejs/interface-database-decorators").ValidateOptions): Promise<number>;
13
+ delete(id: string): Promise<number>;
14
+ };
15
+ readonly schemaName: string;
16
+ fromPlainData(obj: any): UserSegment;
17
+ fromDatabase(obj: any): UserSegment | undefined;
18
+ toDatabase(obj: any): Record<string, any>;
19
+ validate(obj: unknown, options?: import("@antelopejs/interface-database-decorators").ValidateInputOptions): import("@antelopejs/interface-database-decorators").ValidationResult;
20
+ };
21
+ export declare class UserSegmentModel extends UserSegmentModel_base {
22
+ listByUser(userId: string): Promise<UserSegment[]>;
23
+ listBySegment(segmentId: string): Promise<UserSegment[]>;
24
+ countBySegment(segmentId: string): Promise<number>;
25
+ replaceForSegment(segment: Segment, userIds: readonly string[], evaluatedAt: Date): Promise<void>;
26
+ cleanupUnpublishable(segmentId: string): Promise<void>;
27
+ private deleteMembership;
28
+ deleteAllForUser(userId: string): Promise<void>;
29
+ }
30
+ export {};
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserSegmentModel = void 0;
4
+ const node_crypto_1 = require("node:crypto");
5
+ const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
6
+ const segments_model_1 = require("./segments.model");
7
+ const userSegments_table_1 = require("../tables/userSegments.table");
8
+ const SNAPSHOT_ATTEMPTS = 3;
9
+ function sameGenerations(before, after) {
10
+ const current = new Map(after.map((segment) => [segment._id, segment.membershipGeneration]));
11
+ return (before.length === after.length &&
12
+ before.every((segment) => current.has(segment._id) &&
13
+ current.get(segment._id) === segment.membershipGeneration));
14
+ }
15
+ class UserSegmentModel extends (0, interface_database_decorators_1.BasicDataModel)(userSegments_table_1.UserSegment, userSegments_table_1.userSegmentsTableName) {
16
+ async listByUser(userId) {
17
+ const segments = (0, interface_database_decorators_1.GetModel)(segments_model_1.SegmentModel);
18
+ for (let attempt = 0; attempt < SNAPSHOT_ATTEMPTS; attempt++) {
19
+ const before = await segments.getAll();
20
+ const rows = await this.getBy("userId", userId);
21
+ if (!sameGenerations(before, await segments.getAll()))
22
+ continue;
23
+ const published = new Map(before.map((segment) => [segment._id, segment.membershipGeneration]));
24
+ return rows.filter((row) => published.has(row.segmentId) &&
25
+ row.generation === published.get(row.segmentId));
26
+ }
27
+ throw new Error("Segment publication changed while reading memberships");
28
+ }
29
+ async listBySegment(segmentId) {
30
+ const segments = (0, interface_database_decorators_1.GetModel)(segments_model_1.SegmentModel);
31
+ for (let attempt = 0; attempt < SNAPSHOT_ATTEMPTS; attempt++) {
32
+ const before = await segments.get(segmentId);
33
+ if (!before)
34
+ return [];
35
+ const rows = await this.getBy("segmentId", segmentId);
36
+ const after = await segments.get(segmentId);
37
+ if (!after || before.membershipGeneration !== after.membershipGeneration)
38
+ continue;
39
+ return rows.filter((row) => row.generation === before.membershipGeneration);
40
+ }
41
+ throw new Error("Segment publication changed while reading memberships");
42
+ }
43
+ async countBySegment(segmentId) {
44
+ return (await this.listBySegment(segmentId)).length;
45
+ }
46
+ async replaceForSegment(segment, userIds, evaluatedAt) {
47
+ const generation = (0, node_crypto_1.randomUUID)();
48
+ const members = [...new Set(userIds)];
49
+ if (members.length > 0) {
50
+ await this.insert(members.map((userId) => {
51
+ const membership = {
52
+ _id: (0, node_crypto_1.createHash)("sha256")
53
+ .update(JSON.stringify([generation, userId]))
54
+ .digest("hex"),
55
+ userId,
56
+ segmentId: segment._id,
57
+ evaluatedAt,
58
+ generation,
59
+ revision: (0, node_crypto_1.randomUUID)(),
60
+ };
61
+ if (segment.revision !== undefined)
62
+ membership.sourceRevision = segment.revision;
63
+ return membership;
64
+ }));
65
+ }
66
+ await (0, interface_database_decorators_1.GetModel)(segments_model_1.SegmentModel).publishMemberships(segment, generation, members.length, evaluatedAt);
67
+ await this.cleanupUnpublishable(segment._id);
68
+ }
69
+ async cleanupUnpublishable(segmentId) {
70
+ const rows = await this.getBy("segmentId", segmentId);
71
+ const current = await (0, interface_database_decorators_1.GetModel)(segments_model_1.SegmentModel).get(segmentId);
72
+ for (const row of rows) {
73
+ if (current &&
74
+ (row.generation === current.membershipGeneration ||
75
+ row.sourceRevision === current.revision))
76
+ continue;
77
+ await this.deleteMembership(row);
78
+ }
79
+ }
80
+ async deleteMembership(row) {
81
+ const outcome = await this.table
82
+ .atomicMutation(row._id, {
83
+ type: "delete",
84
+ revisionField: "revision",
85
+ expectedRevision: row.revision === undefined ? { kind: "missing" } : row.revision,
86
+ })
87
+ .run();
88
+ if (outcome === "unknown")
89
+ throw new Error("Membership deletion outcome is unknown");
90
+ }
91
+ async deleteAllForUser(userId) {
92
+ for (const row of await this.getBy("userId", userId))
93
+ await this.deleteMembership(row);
94
+ }
95
+ }
96
+ exports.UserSegmentModel = UserSegmentModel;
97
+ //# sourceMappingURL=userSegments.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userSegments.model.js","sourceRoot":"","sources":["../../../src/db/models/userSegments.model.ts"],"names":[],"mappings":";;;AAAA,6CAAqD;AACrD,6FAGmD;AAEnD,qDAAgD;AAChD,qEAGsC;AAEtC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,SAAS,eAAe,CAAC,MAAiB,EAAE,KAAgB;IAC1D,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CACpE,CAAC;IACF,OAAO,CACL,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAC9B,MAAM,CAAC,KAAK,CACV,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,oBAAoB,CAC5D,CACF,CAAC;AACJ,CAAC;AAGD,MAAa,gBAAiB,SAAQ,IAAA,8CAAc,EAClD,gCAAW,EACX,0CAAqB,CACtB;IACC,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,MAAM,QAAQ,GAAG,IAAA,wCAAQ,EAAC,6BAAY,CAAC,CAAC;QACxC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,iBAAiB,EAAE,OAAO,EAAE,EAAE,CAAC;YAC7D,MAAM,MAAM,GAAG,MAAM,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G,CAAC,CAAC;IACrC,CAAC;CACF;AA9GD,4CA8GC"}
@@ -0,0 +1,22 @@
1
+ import { Table } from "@antelopejs/interface-database-decorators";
2
+ export declare const billingSettingsTableName = "billing_settings";
3
+ export declare const BILLING_SETTINGS_SINGLETON_ID = "singleton";
4
+ export declare const DEFAULT_AUTO_SUSPEND_DELAY_DAYS = 14;
5
+ export declare const DEFAULT_STRIPE_TAX_CODE = "txcd_10000000";
6
+ export declare const DEFAULT_MAX_FREE_WORKSPACES_PER_CARD = 1;
7
+ export declare const DEFAULT_DATA_RETENTION_DAYS = 30;
8
+ export declare const REFUND_PRORATA_MODES: readonly ["full", "prorated"];
9
+ export type RefundProrataMode = (typeof REFUND_PRORATA_MODES)[number];
10
+ export declare class BillingSettings extends Table {
11
+ _id: string;
12
+ autoSuspendEnabled: boolean;
13
+ autoSuspendDelayDays: number;
14
+ dataRetentionDaysAfterCancellation: number;
15
+ maxFreeWorkspacesPerCard: number;
16
+ moneyBackGuaranteeEnabled: boolean;
17
+ moneyBackGuaranteeWindowDays: number;
18
+ moneyBackGuaranteeMode: RefundProrataMode;
19
+ autoProrataOnCancelEnabled: boolean;
20
+ stripeTaxCode: string | null;
21
+ updatedAt: Date;
22
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BillingSettings = exports.REFUND_PRORATA_MODES = exports.DEFAULT_DATA_RETENTION_DAYS = exports.DEFAULT_MAX_FREE_WORKSPACES_PER_CARD = exports.DEFAULT_STRIPE_TAX_CODE = exports.DEFAULT_AUTO_SUSPEND_DELAY_DAYS = exports.BILLING_SETTINGS_SINGLETON_ID = exports.billingSettingsTableName = void 0;
13
+ const interface_database_decorators_1 = require("@antelopejs/interface-database-decorators");
14
+ const constants_1 = require("@antelopejs/interface-dms/constants");
15
+ exports.billingSettingsTableName = "billing_settings";
16
+ exports.BILLING_SETTINGS_SINGLETON_ID = "singleton";
17
+ exports.DEFAULT_AUTO_SUSPEND_DELAY_DAYS = 14;
18
+ exports.DEFAULT_STRIPE_TAX_CODE = "txcd_10000000";
19
+ exports.DEFAULT_MAX_FREE_WORKSPACES_PER_CARD = 1;
20
+ exports.DEFAULT_DATA_RETENTION_DAYS = 30;
21
+ exports.REFUND_PRORATA_MODES = ["full", "prorated"];
22
+ let BillingSettings = class BillingSettings extends interface_database_decorators_1.Table {
23
+ };
24
+ exports.BillingSettings = BillingSettings;
25
+ __decorate([
26
+ (0, interface_database_decorators_1.Field)("string"),
27
+ __metadata("design:type", String)
28
+ ], BillingSettings.prototype, "_id", void 0);
29
+ __decorate([
30
+ (0, interface_database_decorators_1.Field)("boolean"),
31
+ __metadata("design:type", Boolean)
32
+ ], BillingSettings.prototype, "autoSuspendEnabled", void 0);
33
+ __decorate([
34
+ (0, interface_database_decorators_1.Field)("number"),
35
+ __metadata("design:type", Number)
36
+ ], BillingSettings.prototype, "autoSuspendDelayDays", void 0);
37
+ __decorate([
38
+ (0, interface_database_decorators_1.Field)("number"),
39
+ __metadata("design:type", Number)
40
+ ], BillingSettings.prototype, "dataRetentionDaysAfterCancellation", void 0);
41
+ __decorate([
42
+ (0, interface_database_decorators_1.Field)("number"),
43
+ __metadata("design:type", Number)
44
+ ], BillingSettings.prototype, "maxFreeWorkspacesPerCard", void 0);
45
+ __decorate([
46
+ (0, interface_database_decorators_1.Field)("boolean"),
47
+ __metadata("design:type", Boolean)
48
+ ], BillingSettings.prototype, "moneyBackGuaranteeEnabled", void 0);
49
+ __decorate([
50
+ (0, interface_database_decorators_1.Field)("number"),
51
+ __metadata("design:type", Number)
52
+ ], BillingSettings.prototype, "moneyBackGuaranteeWindowDays", void 0);
53
+ __decorate([
54
+ (0, interface_database_decorators_1.Field)("string"),
55
+ __metadata("design:type", String)
56
+ ], BillingSettings.prototype, "moneyBackGuaranteeMode", void 0);
57
+ __decorate([
58
+ (0, interface_database_decorators_1.Field)("boolean"),
59
+ __metadata("design:type", Boolean)
60
+ ], BillingSettings.prototype, "autoProrataOnCancelEnabled", void 0);
61
+ __decorate([
62
+ (0, interface_database_decorators_1.Field)("string"),
63
+ __metadata("design:type", Object)
64
+ ], BillingSettings.prototype, "stripeTaxCode", void 0);
65
+ __decorate([
66
+ (0, interface_database_decorators_1.UpdateTime)(),
67
+ (0, interface_database_decorators_1.Field)("date"),
68
+ __metadata("design:type", Date)
69
+ ], BillingSettings.prototype, "updatedAt", void 0);
70
+ exports.BillingSettings = BillingSettings = __decorate([
71
+ (0, interface_database_decorators_1.RegisterTable)(exports.billingSettingsTableName, constants_1.CORE_SCHEMA_NAME)
72
+ ], BillingSettings);
73
+ //# sourceMappingURL=billingSettings.table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billingSettings.table.js","sourceRoot":"","sources":["../../../src/db/tables/billingSettings.table.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6FAKmD;AACnD,mEAAuE;AAE1D,QAAA,wBAAwB,GAAG,kBAAkB,CAAC;AAC9C,QAAA,6BAA6B,GAAG,WAAW,CAAC;AAC5C,QAAA,+BAA+B,GAAG,EAAE,CAAC;AAErC,QAAA,uBAAuB,GAAG,eAAe,CAAC;AAG1C,QAAA,oCAAoC,GAAG,CAAC,CAAC;AAGzC,QAAA,2BAA2B,GAAG,EAAE,CAAC;AAEjC,QAAA,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