@codecks/fetch 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.
package/dist/index.js ADDED
@@ -0,0 +1,3214 @@
1
+ //#region src/collection-utils.ts
2
+ const ensureMapValue = (map, key, fallback) => {
3
+ const exist = map.get(key);
4
+ if (exist) return exist;
5
+ const newValue = fallback();
6
+ map.set(key, newValue);
7
+ return newValue;
8
+ };
9
+
10
+ //#endregion
11
+ //#region src/models/_desc.ts
12
+ const makeModel = (opts) => {
13
+ return opts;
14
+ };
15
+ const relation = (relName, options) => {
16
+ return {
17
+ relName,
18
+ options
19
+ };
20
+ };
21
+
22
+ //#endregion
23
+ //#region src/models/_root.ts
24
+ const _rootDesc = makeModel({
25
+ name: "_root",
26
+ fields: {},
27
+ relations: {
28
+ releases: relation("release", { type: "hasMany" }),
29
+ accountOnboardingSteps: relation("accountOnboardingStep", { type: "hasMany" }),
30
+ apps: relation("app", { type: "hasMany" }),
31
+ account: relation("account", { type: "hasOne" }),
32
+ loggedInUser: relation("user", { type: "hasOne" }),
33
+ cardsStatusHistory: relation("cardsStatusHistory", { type: "hasMany" }),
34
+ cardsEffortHistory: relation("cardsEffortHistory", { type: "hasMany" }),
35
+ cardsFinishedHistory: relation("cardsFinishedHistory", { type: "hasMany" }),
36
+ cardsTimeToFinished: relation("cardsTimeToFinished", { type: "hasMany" })
37
+ },
38
+ keys: []
39
+ });
40
+
41
+ //#endregion
42
+ //#region src/model-pool.ts
43
+ const ROOT_ID = "";
44
+ const dateStrToDay = (dateAsStr) => {
45
+ const parts = dateAsStr.split("-");
46
+ return {
47
+ year: parseInt(parts[0], 10),
48
+ month: parseInt(parts[1], 10),
49
+ day: parseInt(parts[2], 10)
50
+ };
51
+ };
52
+ const parseField = (v, field) => {
53
+ if (!field) return v;
54
+ switch (field.type) {
55
+ case "date": return new Date(v);
56
+ case "day": return dateStrToDay(v);
57
+ default: return v;
58
+ }
59
+ };
60
+ const transformData = (desc, data) => {
61
+ return Object.fromEntries(Object.entries(data).map(([k, v]) => [k, parseField(v, desc.fields[k])]));
62
+ };
63
+ var ModelPool = class {
64
+ data = new Map();
65
+ modelMap;
66
+ constructor(modelMap$1) {
67
+ this.modelMap = modelMap$1;
68
+ }
69
+ addModelInstance(model, id$1, _data) {
70
+ const instanceById = ensureMapValue(this.data, model, () => new Map());
71
+ const exists = instanceById.get(id$1);
72
+ const desc = this.modelMap[model];
73
+ if (!desc) throw new Error(`Unknown model: ${model}`);
74
+ const data = transformData(desc, _data);
75
+ if (exists) Object.assign(exists, data);
76
+ else instanceById.set(id$1, data);
77
+ }
78
+ add(data) {
79
+ Object.entries(data).forEach(([modelName, payload]) => {
80
+ if (modelName === _rootDesc.name) this.addModelInstance(modelName, ROOT_ID, payload);
81
+ else Object.entries(payload).forEach(([id$1, payload$1]) => {
82
+ this.addModelInstance(modelName, id$1, payload$1);
83
+ });
84
+ });
85
+ }
86
+ get(model, id$1) {
87
+ const instances = this.data.get(model);
88
+ if (!instances) return null;
89
+ return instances.get(id$1) ?? null;
90
+ }
91
+ };
92
+
93
+ //#endregion
94
+ //#region src/models/_fields.ts
95
+ const id = () => {
96
+ return { type: "id" };
97
+ };
98
+ const string = (opts) => {
99
+ return { type: "string" };
100
+ };
101
+ const int = (opts) => {
102
+ return { type: "int" };
103
+ };
104
+ const bigint = (opts) => {
105
+ return { type: "bigint" };
106
+ };
107
+ const bool = (opts) => {
108
+ return { type: "bool" };
109
+ };
110
+ const date = (opts) => {
111
+ return { type: "date" };
112
+ };
113
+ const day = (opts) => {
114
+ return { type: "day" };
115
+ };
116
+ const object = (opts) => {
117
+ return { type: "obj" };
118
+ };
119
+ const array = (opts) => {
120
+ return { type: "array" };
121
+ };
122
+ const belongsTo = (opts) => {
123
+ return { type: () => {
124
+ return { type: "belongsTo" };
125
+ } };
126
+ };
127
+
128
+ //#endregion
129
+ //#region src/models/AccountOnboardingStep.ts
130
+ const accountOnboardingStepDesc = makeModel({
131
+ name: "accountOnboardingStep",
132
+ fields: {
133
+ key: id(),
134
+ title: string({}),
135
+ description: string({}),
136
+ chapter: string({}),
137
+ sortValue: string({}),
138
+ variants: array({}),
139
+ xp: int({}),
140
+ milestone: string({})
141
+ },
142
+ relations: {},
143
+ keys: ["key"]
144
+ });
145
+
146
+ //#endregion
147
+ //#region src/models/File.ts
148
+ const fileDesc = makeModel({
149
+ name: "file",
150
+ fields: {
151
+ id: id(),
152
+ name: string({}),
153
+ url: string({}),
154
+ size: string({}),
155
+ isDeleted: string({}),
156
+ meta: object({}),
157
+ createdAt: date({}),
158
+ deletedAt: date({}),
159
+ selfHosted: string({}),
160
+ accountId: belongsTo({}).type(),
161
+ uploaderId: belongsTo({}).type(),
162
+ deletedById: belongsTo({}).type()
163
+ },
164
+ relations: {
165
+ account: relation("account", {
166
+ type: "belongsTo",
167
+ fk: "accountId"
168
+ }),
169
+ uploader: relation("user", {
170
+ type: "belongsTo",
171
+ fk: "uploaderId"
172
+ }),
173
+ deletedBy: relation("user", {
174
+ type: "belongsTo",
175
+ fk: "deletedById"
176
+ })
177
+ },
178
+ keys: ["id"]
179
+ });
180
+
181
+ //#endregion
182
+ //#region src/models/Release.ts
183
+ const releaseDesc = makeModel({
184
+ name: "release",
185
+ fields: {
186
+ id: id(),
187
+ version: string({}),
188
+ isLive: string({}),
189
+ content: string({}),
190
+ title: string({}),
191
+ createdAt: date({})
192
+ },
193
+ relations: {},
194
+ keys: ["id"]
195
+ });
196
+
197
+ //#endregion
198
+ //#region src/models/User.ts
199
+ const userDesc = makeModel({
200
+ name: "user",
201
+ fields: {
202
+ id: id(),
203
+ name: string({}),
204
+ fullName: string({ optional: true }),
205
+ timezone: string({ optional: true }),
206
+ createdAt: date({}),
207
+ hasPassword: bool({}),
208
+ showCardIdInTimer: bool({}),
209
+ disableMovingImages: bool({}),
210
+ autoMeFilterCardLimit: int({ optional: true }),
211
+ isIntegration: bool({}),
212
+ statusColorPalette: string({}),
213
+ wantsNewsletter: bool({ optional: true }),
214
+ wantsDailyDigestMail: bool({ optional: true }),
215
+ wantsConvoDigestMail: bool({ optional: true }),
216
+ disableAnimations: bool({}),
217
+ enableClickToEditCards: bool({}),
218
+ cdxRole: string({}),
219
+ profileImageId: belongsTo({ optional: true }).type(),
220
+ lastSeenReleaseId: belongsTo({}).type()
221
+ },
222
+ relations: {
223
+ profileImage: relation("file", {
224
+ type: "belongsTo",
225
+ fk: "profileImageId"
226
+ }),
227
+ lastSeenRelease: relation("release", {
228
+ type: "belongsTo",
229
+ fk: "lastSeenReleaseId"
230
+ }),
231
+ projectOrders: relation("projectOrder", { type: "hasMany" }),
232
+ projectSelections: relation("projectSelection", { type: "hasMany" }),
233
+ queueSelections: relation("queueSelection", { type: "hasMany" }),
234
+ accountRoles: relation("accountRole", { type: "hasMany" }),
235
+ cardDiffNotifications: relation("cardDiffNotification", { type: "hasMany" }),
236
+ resolvableNotifications: relation("resolvableNotification", { type: "hasMany" }),
237
+ publicProjectMembership: relation("publicProjectMembership", { type: "hasMany" }),
238
+ lastSeenCardUpvotes: relation("lastSeenCardUpvote", { type: "hasMany" }),
239
+ dueCards: relation("dueCard", { type: "hasMany" }),
240
+ assigneeDeckAssignments: relation("assigneeDeckAssignment", { type: "hasMany" }),
241
+ autoFinishedTimeTrackingSegments: relation("autoFinishedTimeTrackingSegment", { type: "hasMany" }),
242
+ savedSearches: relation("savedSearch", { type: "hasMany" }),
243
+ activities: relation("activity", { type: "hasMany" }),
244
+ emails: relation("userEmail", { type: "hasMany" }),
245
+ tags: relation("userTag", { type: "hasMany" }),
246
+ unverifiedEmails: relation("userEmail", { type: "hasMany" }),
247
+ primaryEmail: relation("userEmail", { type: "hasOne" }),
248
+ pinnedMilestoneNext: relation("pinnedMilestone", { type: "hasOne" }),
249
+ projectAccess: relation("projectUser", { type: "hasMany" }),
250
+ explicitProjectAccess: relation("projectUser", { type: "hasMany" }),
251
+ withProjectAccess: relation("userProjectAccess", { type: "hasMany" }),
252
+ projectSettings: relation("projectUserSetting", { type: "hasMany" }),
253
+ accountSettings: relation("accountUserSetting", { type: "hasMany" }),
254
+ dismissedHints: relation("userDismissedHint", { type: "hasMany" }),
255
+ slackIntegrations: relation("integration", { type: "hasMany" }),
256
+ activeTimeTracker: relation("activeTimeTracker", { type: "hasOne" }),
257
+ participations: relation("resolvableParticipant", { type: "hasMany" }),
258
+ upvotes: relation("cardUpvote", { type: "hasMany" }),
259
+ userOnboarding: relation("userOnboarding", { type: "hasOne" })
260
+ },
261
+ keys: ["id"]
262
+ });
263
+
264
+ //#endregion
265
+ //#region src/models/Account.ts
266
+ const accountDesc = makeModel({
267
+ name: "account",
268
+ fields: {
269
+ id: id(),
270
+ subdomain: string({}),
271
+ name: string({}),
272
+ billingName: string({ optional: true }),
273
+ billingLine1: string({ optional: true }),
274
+ billingLine2: string({ optional: true }),
275
+ billingZip: string({ optional: true }),
276
+ billingCity: string({ optional: true }),
277
+ billingCountryCode: string({ optional: true }),
278
+ billingEmail: string({ optional: true }),
279
+ netGiftAmount: int({}),
280
+ persona: string({ optional: true }),
281
+ createdAt: date({}),
282
+ disabledAt: date({ optional: true }),
283
+ totalMediaByteUsage: bigint({}),
284
+ isDisabled: string({}),
285
+ milestonesEnabled: string({}),
286
+ sprintsEnabled: string({}),
287
+ priorityLabels: object({}),
288
+ effortScale: object({}),
289
+ statusChangeDurations: object({}),
290
+ activeFeatureFlags: object({}),
291
+ timeTrackingMode: string({}),
292
+ maxTimeTrackingSegmentMsDuration: int({}),
293
+ timeTrackingSwimLaneInfo: bool({}),
294
+ workdays: string({}),
295
+ workflowMode: string({}),
296
+ isLearning: bool({}),
297
+ isNonProfit: bool({}),
298
+ dependenciesEnabled: bool({}),
299
+ maxHandSlotCount: int({}),
300
+ seats: int({}),
301
+ activeProjectCount: int({}),
302
+ billingType: string({}),
303
+ allowInheritHeroCover: bool({}),
304
+ attachmentCoverMode: string({}),
305
+ staffPermission: string({}),
306
+ offeringTrial: bool({}),
307
+ coupon: object({ optional: true }),
308
+ hideCompletedCardCountForDecks: bool({}),
309
+ visionBoardEnabled: bool({}),
310
+ fallbackEffort: int({}),
311
+ timelineScaleType: string({}),
312
+ startWeekday: string({}),
313
+ disabledById: belongsTo({ optional: true }).type()
314
+ },
315
+ relations: {
316
+ disabledBy: relation("user", {
317
+ type: "belongsTo",
318
+ fk: "disabledById"
319
+ }),
320
+ cards: relation("card", { type: "hasMany" }),
321
+ invoices: relation("invoice", { type: "hasMany" }),
322
+ cardPresets: relation("cardPreset", { type: "hasMany" }),
323
+ attachments: relation("attachment", { type: "hasMany" }),
324
+ discordGuilds: relation("discordGuild", { type: "hasMany" }),
325
+ timeTrackingSegments: relation("timeTrackingSegment", { type: "hasMany" }),
326
+ workflowItems: relation("workflowItem", { type: "hasMany" }),
327
+ deckAssignments: relation("deckAssignment", { type: "hasMany" }),
328
+ assigneeAssignments: relation("assigneeAssignment", { type: "hasMany" }),
329
+ assigneeDeckAssignments: relation("assigneeDeckAssignment", { type: "hasMany" }),
330
+ wizards: relation("wizard", { type: "hasMany" }),
331
+ milestones: relation("milestone", { type: "hasMany" }),
332
+ sprints: relation("sprint", { type: "hasMany" }),
333
+ sprintConfigs: relation("sprintConfig", { type: "hasMany" }),
334
+ handCards: relation("handCard", { type: "hasMany" }),
335
+ resolvables: relation("resolvable", { type: "hasMany" }),
336
+ cardUpvotes: relation("cardUpvote", { type: "hasMany" }),
337
+ resolvableParticipants: relation("resolvableParticipant", { type: "hasMany" }),
338
+ userReportSettings: relation("userReportSetting", { type: "hasMany" }),
339
+ cardOrders: relation("cardOrder", { type: "hasMany" }),
340
+ accountUserAchievements: relation("accountUserAchievement", { type: "hasMany" }),
341
+ userInviteCodes: relation("userInviteCode", { type: "hasMany" }),
342
+ visionBoards: relation("visionBoard", { type: "hasMany" }),
343
+ deckSubscriptions: relation("deckSubscription", { type: "hasMany" }),
344
+ appInstallations: relation("appInstallation", { type: "hasMany" }),
345
+ files: relation("file", { type: "hasMany" }),
346
+ decks: relation("deck", { type: "hasMany" }),
347
+ queueEntries: relation("queueEntry", { type: "hasMany" }),
348
+ visionBoardQueries: relation("visionBoardQuery", { type: "hasMany" }),
349
+ anyDecks: relation("deck", { type: "hasMany" }),
350
+ projects: relation("project", { type: "hasMany" }),
351
+ archivedProjects: relation("project", { type: "hasMany" }),
352
+ anyProjects: relation("project", { type: "hasMany" }),
353
+ roles: relation("accountRole", { type: "hasMany" }),
354
+ invitations: relation("userInvitation", { type: "hasMany" }),
355
+ githubIntegration: relation("integration", { type: "hasOne" }),
356
+ slackIntegration: relation("integration", { type: "hasOne" }),
357
+ affiliateCodes: relation("affiliateCode", { type: "hasMany" }),
358
+ activities: relation("activity", { type: "hasMany" }),
359
+ stripeAccountSync: relation("stripeAccountSync", { type: "hasOne" }),
360
+ accountOnboarding: relation("accountOnboarding", { type: "hasOne" })
361
+ },
362
+ keys: ["id"]
363
+ });
364
+
365
+ //#endregion
366
+ //#region src/models/AccountOnboarding.ts
367
+ const accountOnboardingDesc = makeModel({
368
+ name: "accountOnboarding",
369
+ fields: {
370
+ variants: array({}),
371
+ steps: object({}),
372
+ accountId: belongsTo({}).type()
373
+ },
374
+ relations: { account: relation("account", {
375
+ type: "belongsTo",
376
+ fk: "accountId"
377
+ }) },
378
+ keys: ["accountId"]
379
+ });
380
+
381
+ //#endregion
382
+ //#region src/models/AccountRole.ts
383
+ const accountRoleDesc = makeModel({
384
+ name: "accountRole",
385
+ fields: {
386
+ role: string({}),
387
+ createdAt: date({}),
388
+ lastChangedAt: date({}),
389
+ roleAsPrio: int({}),
390
+ userId: belongsTo({}).type(),
391
+ accountId: belongsTo({}).type()
392
+ },
393
+ relations: {
394
+ user: relation("user", {
395
+ type: "belongsTo",
396
+ fk: "userId"
397
+ }),
398
+ account: relation("account", {
399
+ type: "belongsTo",
400
+ fk: "accountId"
401
+ })
402
+ },
403
+ keys: ["accountId", "userId"]
404
+ });
405
+
406
+ //#endregion
407
+ //#region src/models/AccountUserAchievement.ts
408
+ const accountUserAchievementDesc = makeModel({
409
+ name: "accountUserAchievement",
410
+ fields: {
411
+ value: object({}),
412
+ context: object({}),
413
+ accountId: belongsTo({}).type(),
414
+ userId: belongsTo({}).type()
415
+ },
416
+ relations: {
417
+ account: relation("account", {
418
+ type: "belongsTo",
419
+ fk: "accountId"
420
+ }),
421
+ user: relation("user", {
422
+ type: "belongsTo",
423
+ fk: "userId"
424
+ })
425
+ },
426
+ keys: [
427
+ "accountId",
428
+ "userId",
429
+ "key"
430
+ ]
431
+ });
432
+
433
+ //#endregion
434
+ //#region src/models/Project.ts
435
+ const projectDesc = makeModel({
436
+ name: "project",
437
+ fields: {
438
+ id: id(),
439
+ name: string({}),
440
+ visibility: string({}),
441
+ defaultUserAccess: string({}),
442
+ createdAt: date({}),
443
+ accountSeq: int({}),
444
+ allowUpvotes: string({}),
445
+ isPublic: string({}),
446
+ commentsArePublic: string({}),
447
+ publicRegistryAgreement: string({ optional: true }),
448
+ publicLayoutVersion: string({}),
449
+ publicIsExplicit: string({}),
450
+ markerColor: string({ optional: true }),
451
+ effortIcon: string({ optional: true }),
452
+ spaces: string({}),
453
+ publicPath: string({ optional: true }),
454
+ publicMessage: string({ optional: true }),
455
+ publicHeading: string({ optional: true }),
456
+ publicBackgroundColor: string({ optional: true }),
457
+ accountId: belongsTo({}).type(),
458
+ coverFileId: belongsTo({ optional: true }).type(),
459
+ publicBannerFileId: belongsTo({ optional: true }).type(),
460
+ publicTileFileId: belongsTo({ optional: true }).type(),
461
+ publicBackgroundImageId: belongsTo({ optional: true }).type()
462
+ },
463
+ relations: {
464
+ account: relation("account", {
465
+ type: "belongsTo",
466
+ fk: "accountId"
467
+ }),
468
+ coverFile: relation("file", {
469
+ type: "belongsTo",
470
+ fk: "coverFileId"
471
+ }),
472
+ publicBannerFile: relation("file", {
473
+ type: "belongsTo",
474
+ fk: "publicBannerFileId"
475
+ }),
476
+ publicTileFile: relation("file", {
477
+ type: "belongsTo",
478
+ fk: "publicTileFileId"
479
+ }),
480
+ publicBackgroundImage: relation("file", {
481
+ type: "belongsTo",
482
+ fk: "publicBackgroundImageId"
483
+ }),
484
+ decks: relation("deck", { type: "hasMany" }),
485
+ milestoneProjects: relation("milestoneProject", { type: "hasMany" }),
486
+ sprintProjects: relation("sprintProject", { type: "hasMany" }),
487
+ publicProjectVisits: relation("publicProjectVisit", { type: "hasMany" }),
488
+ dailyPublicProjectMembership: relation("dailyPublicProjectMembership", { type: "hasMany" }),
489
+ publicProjectMemberships: relation("publicProjectMembership", { type: "hasMany" }),
490
+ cardUpvotes: relation("cardUpvote", { type: "hasMany" }),
491
+ tags: relation("projectTag", { type: "hasMany" }),
492
+ activities: relation("activity", { type: "hasMany" }),
493
+ explicitProjectUsers: relation("projectUser", { type: "hasMany" }),
494
+ access: relation("userProjectAccess", { type: "hasMany" }),
495
+ publicProjectInfo: relation("publicProjectInfo", { type: "hasOne" })
496
+ },
497
+ keys: ["id"]
498
+ });
499
+
500
+ //#endregion
501
+ //#region src/models/Milestone.ts
502
+ const milestoneDesc = makeModel({
503
+ name: "milestone",
504
+ fields: {
505
+ id: id(),
506
+ name: string({}),
507
+ color: string({}),
508
+ date: day({}),
509
+ startDate: day({ optional: true }),
510
+ createdAt: date({}),
511
+ accountSeq: int({}),
512
+ description: string({ optional: true }),
513
+ isGlobal: string({}),
514
+ handSyncEnabled: string({}),
515
+ manualOrderLabels: string({}),
516
+ stats: object({}),
517
+ userCapacities: object({}),
518
+ isDeleted: bool({}),
519
+ preferredOrder: string({ optional: true }),
520
+ accountId: belongsTo({}).type(),
521
+ creatorId: belongsTo({}).type(),
522
+ coverFileId: belongsTo({ optional: true }).type()
523
+ },
524
+ relations: {
525
+ account: relation("account", {
526
+ type: "belongsTo",
527
+ fk: "accountId"
528
+ }),
529
+ creator: relation("user", {
530
+ type: "belongsTo",
531
+ fk: "creatorId"
532
+ }),
533
+ coverFile: relation("file", {
534
+ type: "belongsTo",
535
+ fk: "coverFileId"
536
+ }),
537
+ milestoneProjects: relation("milestoneProject", { type: "hasMany" }),
538
+ cards: relation("card", { type: "hasMany" }),
539
+ activities: relation("activity", { type: "hasMany" }),
540
+ progress: relation("milestoneProgress", { type: "hasMany" })
541
+ },
542
+ keys: ["id"]
543
+ });
544
+
545
+ //#endregion
546
+ //#region src/models/ProjectTag.ts
547
+ const projectTagDesc = makeModel({
548
+ name: "projectTag",
549
+ fields: {
550
+ id: id(),
551
+ tag: string({}),
552
+ color: string({ optional: true }),
553
+ emoji: string({ optional: true }),
554
+ description: string({ optional: true }),
555
+ createdAt: date({}),
556
+ projectId: belongsTo({}).type()
557
+ },
558
+ relations: { project: relation("project", {
559
+ type: "belongsTo",
560
+ fk: "projectId"
561
+ }) },
562
+ keys: ["id"]
563
+ });
564
+
565
+ //#endregion
566
+ //#region src/models/Deck.ts
567
+ const deckDesc = makeModel({
568
+ name: "deck",
569
+ fields: {
570
+ id: id(),
571
+ content: string({}),
572
+ description: string({}),
573
+ title: string({}),
574
+ sortValue: string({}),
575
+ preferredOrder: string({ optional: true }),
576
+ coverColor: string({ optional: true }),
577
+ isDeleted: string({}),
578
+ accountSeq: int({}),
579
+ spaceId: int({ optional: true }),
580
+ defaultCard: object({}),
581
+ isOnboardingDeck: bool({}),
582
+ handSyncEnabled: string({}),
583
+ stickyDefaultProjectTag: string({}),
584
+ manualOrderLabels: string({}),
585
+ workflowItemOrderLabels: string({}),
586
+ createdAt: date({}),
587
+ stats: object({}),
588
+ hasGuardians: string({}),
589
+ allowedCardTypes: string({}),
590
+ projectId: belongsTo({}).type(),
591
+ accountId: belongsTo({}).type(),
592
+ milestoneId: belongsTo({ optional: true }).type(),
593
+ creatorId: belongsTo({}).type(),
594
+ coverFileId: belongsTo({ optional: true }).type(),
595
+ descriptionCoverFileId: belongsTo({ optional: true }).type(),
596
+ defaultProjectTagId: belongsTo({ optional: true }).type()
597
+ },
598
+ relations: {
599
+ project: relation("project", {
600
+ type: "belongsTo",
601
+ fk: "projectId"
602
+ }),
603
+ account: relation("account", {
604
+ type: "belongsTo",
605
+ fk: "accountId"
606
+ }),
607
+ milestone: relation("milestone", {
608
+ type: "belongsTo",
609
+ fk: "milestoneId"
610
+ }),
611
+ creator: relation("user", {
612
+ type: "belongsTo",
613
+ fk: "creatorId"
614
+ }),
615
+ coverFile: relation("file", {
616
+ type: "belongsTo",
617
+ fk: "coverFileId"
618
+ }),
619
+ descriptionCoverFile: relation("file", {
620
+ type: "belongsTo",
621
+ fk: "descriptionCoverFileId"
622
+ }),
623
+ defaultProjectTag: relation("projectTag", {
624
+ type: "belongsTo",
625
+ fk: "defaultProjectTagId"
626
+ }),
627
+ cards: relation("card", { type: "hasMany" }),
628
+ workflowItems: relation("workflowItem", { type: "hasMany" }),
629
+ cardOrderInDecks: relation("cardOrderInDeck", { type: "hasMany" }),
630
+ activities: relation("activity", { type: "hasMany" }),
631
+ guardians: relation("deckGuardian", { type: "hasMany" })
632
+ },
633
+ keys: ["id"]
634
+ });
635
+
636
+ //#endregion
637
+ //#region src/models/AccountUserSetting.ts
638
+ const accountUserSettingDesc = makeModel({
639
+ name: "accountUserSetting",
640
+ fields: {
641
+ wantsWeeklyDigestMail: bool({}),
642
+ timelineScaleTypeOverwrite: string({}),
643
+ startWeekdayOverwrite: string({}),
644
+ accountId: belongsTo({}).type(),
645
+ userId: belongsTo({}).type(),
646
+ inboxDeckId: belongsTo({}).type()
647
+ },
648
+ relations: {
649
+ account: relation("account", {
650
+ type: "belongsTo",
651
+ fk: "accountId"
652
+ }),
653
+ user: relation("user", {
654
+ type: "belongsTo",
655
+ fk: "userId"
656
+ }),
657
+ inboxDeck: relation("deck", {
658
+ type: "belongsTo",
659
+ fk: "inboxDeckId"
660
+ })
661
+ },
662
+ keys: ["accountId", "userId"]
663
+ });
664
+
665
+ //#endregion
666
+ //#region src/models/SprintConfig.ts
667
+ const sprintConfigDesc = makeModel({
668
+ name: "sprintConfig",
669
+ fields: {
670
+ id: id(),
671
+ name: string({}),
672
+ color: string({}),
673
+ stopOn: day({ optional: true }),
674
+ isGlobal: string({}),
675
+ upcomingSprints: int({}),
676
+ sprintDurationWeeks: int({}),
677
+ sprintStartWeekday: int({}),
678
+ endHour: int({}),
679
+ endHourTimezone: string({}),
680
+ createdAt: date({}),
681
+ preferredOrder: string({ optional: true }),
682
+ moveOnFinish: string({}),
683
+ autoBeastModeDurationHours: int({ optional: true }),
684
+ autoAssignStartedCard: bool({}),
685
+ autoAssignNewCard: bool({}),
686
+ beastGracePeriodHours: int({}),
687
+ accountId: belongsTo({}).type(),
688
+ creatorId: belongsTo({}).type()
689
+ },
690
+ relations: {
691
+ account: relation("account", {
692
+ type: "belongsTo",
693
+ fk: "accountId"
694
+ }),
695
+ creator: relation("user", {
696
+ type: "belongsTo",
697
+ fk: "creatorId"
698
+ }),
699
+ sprintProjects: relation("sprintProject", { type: "hasMany" }),
700
+ sprints: relation("sprint", { type: "hasMany" }),
701
+ progress: relation("sprintConfigProgress", { type: "hasMany" })
702
+ },
703
+ keys: ["id"]
704
+ });
705
+
706
+ //#endregion
707
+ //#region src/models/Sprint.ts
708
+ const sprintDesc = makeModel({
709
+ name: "sprint",
710
+ fields: {
711
+ id: id(),
712
+ description: string({}),
713
+ name: string({ optional: true }),
714
+ accountSeq: int({}),
715
+ index: int({}),
716
+ startDate: day({}),
717
+ endDate: day({}),
718
+ stats: object({}),
719
+ manualOrderLabels: string({}),
720
+ userCapacities: object({}),
721
+ handSyncEnabled: string({}),
722
+ createdAt: date({}),
723
+ isDeleted: bool({}),
724
+ completedAt: date({ optional: true }),
725
+ lockedAt: date({ optional: true }),
726
+ accountId: belongsTo({}).type(),
727
+ sprintConfigId: belongsTo({}).type(),
728
+ creatorId: belongsTo({}).type(),
729
+ coverFileId: belongsTo({ optional: true }).type(),
730
+ autoMilestoneId: belongsTo({ optional: true }).type()
731
+ },
732
+ relations: {
733
+ account: relation("account", {
734
+ type: "belongsTo",
735
+ fk: "accountId"
736
+ }),
737
+ sprintConfig: relation("sprintConfig", {
738
+ type: "belongsTo",
739
+ fk: "sprintConfigId"
740
+ }),
741
+ creator: relation("user", {
742
+ type: "belongsTo",
743
+ fk: "creatorId"
744
+ }),
745
+ coverFile: relation("file", {
746
+ type: "belongsTo",
747
+ fk: "coverFileId"
748
+ }),
749
+ autoMilestone: relation("milestone", {
750
+ type: "belongsTo",
751
+ fk: "autoMilestoneId"
752
+ }),
753
+ cards: relation("card", { type: "hasMany" }),
754
+ progress: relation("sprintProgress", { type: "hasMany" }),
755
+ activities: relation("activity", { type: "hasMany" })
756
+ },
757
+ keys: ["id"]
758
+ });
759
+
760
+ //#endregion
761
+ //#region src/models/WorkflowItem.ts
762
+ const workflowItemDesc = makeModel({
763
+ name: "workflowItem",
764
+ fields: {
765
+ itemId: id(),
766
+ version: string({}),
767
+ sortOrder: string({}),
768
+ sortValue: string({}),
769
+ priority: string({ optional: true }),
770
+ content: string({}),
771
+ createdAt: date({}),
772
+ lastUpdatedAt: date({}),
773
+ tags: array({}),
774
+ masterTags: array({}),
775
+ mentionedUsers: array({}),
776
+ title: string({}),
777
+ effort: int({ optional: true }),
778
+ label: string({ optional: true }),
779
+ checkboxStats: object({}),
780
+ accountSeq: int({}),
781
+ checkboxInfo: array({}),
782
+ visibility: string({}),
783
+ accountId: belongsTo({}).type(),
784
+ deckId: belongsTo({}).type(),
785
+ targetDeckId: belongsTo({ optional: true }).type(),
786
+ assigneeId: belongsTo({ optional: true }).type(),
787
+ creatorId: belongsTo({}).type()
788
+ },
789
+ relations: {
790
+ account: relation("account", {
791
+ type: "belongsTo",
792
+ fk: "accountId"
793
+ }),
794
+ deck: relation("deck", {
795
+ type: "belongsTo",
796
+ fk: "deckId"
797
+ }),
798
+ targetDeck: relation("deck", {
799
+ type: "belongsTo",
800
+ fk: "targetDeckId"
801
+ }),
802
+ assignee: relation("user", {
803
+ type: "belongsTo",
804
+ fk: "assigneeId"
805
+ }),
806
+ creator: relation("user", {
807
+ type: "belongsTo",
808
+ fk: "creatorId"
809
+ }),
810
+ diffs: relation("workflowItemHistory", { type: "hasMany" }),
811
+ inDeps: relation("workflowItem", { type: "hasMany" }),
812
+ outDeps: relation("workflowItem", { type: "hasMany" })
813
+ },
814
+ keys: ["itemId"]
815
+ });
816
+
817
+ //#endregion
818
+ //#region src/models/DiscordGuild.ts
819
+ const discordGuildDesc = makeModel({
820
+ name: "discordGuild",
821
+ fields: {
822
+ id: id(),
823
+ discordGuildId: string({}),
824
+ guildName: string({}),
825
+ guildIconId: string({}),
826
+ scope: string({}),
827
+ karmaRoleThresholds: object({}),
828
+ removeCommandEnabled: string({}),
829
+ removeCommandEmoji: string({}),
830
+ removeCommandRoleId: string({}),
831
+ createdAt: date({}),
832
+ accountId: belongsTo({}).type()
833
+ },
834
+ relations: {
835
+ account: relation("account", {
836
+ type: "belongsTo",
837
+ fk: "accountId"
838
+ }),
839
+ slashCommands: relation("discordSlashCommand", { type: "hasMany" }),
840
+ projectNotifications: relation("discordProjectNotification", { type: "hasMany" }),
841
+ dailyDiscordGuildVoteMemberships: relation("dailyDiscordGuildVoteMembership", { type: "hasMany" }),
842
+ members: relation("discordMember", { type: "hasMany" })
843
+ },
844
+ keys: ["id"]
845
+ });
846
+
847
+ //#endregion
848
+ //#region src/models/VisionBoard.ts
849
+ const visionBoardDesc = makeModel({
850
+ name: "visionBoard",
851
+ fields: {
852
+ id: id(),
853
+ accountSeq: int({}),
854
+ createdAt: date({}),
855
+ isDeleted: bool({}),
856
+ cardId: belongsTo({}).type(),
857
+ accountId: belongsTo({}).type(),
858
+ creatorId: belongsTo({}).type()
859
+ },
860
+ relations: {
861
+ card: relation("card", {
862
+ type: "belongsTo",
863
+ fk: "cardId"
864
+ }),
865
+ account: relation("account", {
866
+ type: "belongsTo",
867
+ fk: "accountId"
868
+ }),
869
+ creator: relation("user", {
870
+ type: "belongsTo",
871
+ fk: "creatorId"
872
+ })
873
+ },
874
+ keys: ["id"]
875
+ });
876
+
877
+ //#endregion
878
+ //#region src/models/Card.ts
879
+ const cardDesc = makeModel({
880
+ name: "card",
881
+ fields: {
882
+ cardId: id(),
883
+ version: int({}),
884
+ accountSeq: int({}),
885
+ content: string({}),
886
+ status: string({}),
887
+ derivedStatus: string({}),
888
+ createdAt: date({}),
889
+ lastUpdatedAt: date({}),
890
+ tags: array({}),
891
+ masterTags: array({}),
892
+ mentionedUsers: array({}),
893
+ title: string({}),
894
+ priority: string({ optional: true }),
895
+ effort: int({ optional: true }),
896
+ checkboxStats: object({}),
897
+ checkboxInfo: array({}),
898
+ visibility: string({}),
899
+ legacyProjectSeq: int({ optional: true }),
900
+ meta: object({}),
901
+ embeds: object({}),
902
+ isPublic: bool({}),
903
+ hasBlockingDeps: bool({}),
904
+ dueDate: day({ optional: true }),
905
+ isDoc: bool({ optional: true }),
906
+ childCardInfo: string({}),
907
+ accountId: belongsTo({}).type(),
908
+ deckId: belongsTo({ optional: true }).type(),
909
+ assigneeId: belongsTo({ optional: true }).type(),
910
+ creatorId: belongsTo({ optional: true }).type(),
911
+ milestoneId: belongsTo({ optional: true }).type(),
912
+ sprintId: belongsTo({ optional: true }).type(),
913
+ legacyProjectId: belongsTo({ optional: true }).type(),
914
+ coverFileId: belongsTo({ optional: true }).type(),
915
+ parentCardId: belongsTo({ optional: true }).type(),
916
+ sourceWorkflowItemId: belongsTo({ optional: true }).type(),
917
+ discordGuildId: belongsTo({}).type(),
918
+ visionBoardId: belongsTo({ optional: true }).type()
919
+ },
920
+ relations: {
921
+ account: relation("account", {
922
+ type: "belongsTo",
923
+ fk: "accountId"
924
+ }),
925
+ deck: relation("deck", {
926
+ type: "belongsTo",
927
+ fk: "deckId"
928
+ }),
929
+ assignee: relation("user", {
930
+ type: "belongsTo",
931
+ fk: "assigneeId"
932
+ }),
933
+ creator: relation("user", {
934
+ type: "belongsTo",
935
+ fk: "creatorId"
936
+ }),
937
+ milestone: relation("milestone", {
938
+ type: "belongsTo",
939
+ fk: "milestoneId"
940
+ }),
941
+ sprint: relation("sprint", {
942
+ type: "belongsTo",
943
+ fk: "sprintId"
944
+ }),
945
+ legacyProject: relation("project", {
946
+ type: "belongsTo",
947
+ fk: "legacyProjectId"
948
+ }),
949
+ coverFile: relation("file", {
950
+ type: "belongsTo",
951
+ fk: "coverFileId"
952
+ }),
953
+ parentCard: relation("card", {
954
+ type: "belongsTo",
955
+ fk: "parentCardId"
956
+ }),
957
+ sourceWorkflowItem: relation("workflowItem", {
958
+ type: "belongsTo",
959
+ fk: "sourceWorkflowItemId"
960
+ }),
961
+ discordGuild: relation("discordGuild", {
962
+ type: "belongsTo",
963
+ fk: "discordGuildId"
964
+ }),
965
+ visionBoard: relation("visionBoard", {
966
+ type: "belongsTo",
967
+ fk: "visionBoardId"
968
+ }),
969
+ resolvables: relation("resolvable", { type: "hasMany" }),
970
+ handCards: relation("handCard", { type: "hasMany" }),
971
+ timeTrackingSegments: relation("timeTrackingSegment", { type: "hasMany" }),
972
+ cardSubscriptions: relation("cardSubscription", { type: "hasMany" }),
973
+ cardOrders: relation("cardOrder", { type: "hasMany" }),
974
+ resolvableEntries: relation("resolvableEntry", { type: "hasMany" }),
975
+ queueEntries: relation("queueEntry", { type: "hasMany" }),
976
+ attachments: relation("attachment", { type: "hasMany" }),
977
+ diffs: relation("cardHistory", { type: "hasMany" }),
978
+ totalTimeTrackingSums: relation("timeTrackingSum", { type: "hasOne" }),
979
+ userTimeTrackingSums: relation("timeTrackingSum", { type: "hasMany" }),
980
+ childCards: relation("card", { type: "hasMany" }),
981
+ inDeps: relation("card", { type: "hasMany" }),
982
+ outDeps: relation("card", { type: "hasMany" }),
983
+ cardReferences: relation("card", { type: "hasMany" }),
984
+ upvotes: relation("cardUpvote", { type: "hasMany" })
985
+ },
986
+ keys: ["cardId"]
987
+ });
988
+
989
+ //#endregion
990
+ //#region src/models/ActiveTimeTracker.ts
991
+ const activeTimeTrackerDesc = makeModel({
992
+ name: "activeTimeTracker",
993
+ fields: {
994
+ id: id(),
995
+ createdAt: date({}),
996
+ cardId: belongsTo({}).type(),
997
+ userId: belongsTo({}).type(),
998
+ accountId: belongsTo({}).type()
999
+ },
1000
+ relations: {
1001
+ card: relation("card", {
1002
+ type: "belongsTo",
1003
+ fk: "cardId"
1004
+ }),
1005
+ user: relation("user", {
1006
+ type: "belongsTo",
1007
+ fk: "userId"
1008
+ }),
1009
+ account: relation("account", {
1010
+ type: "belongsTo",
1011
+ fk: "accountId"
1012
+ })
1013
+ },
1014
+ keys: ["id"]
1015
+ });
1016
+
1017
+ //#endregion
1018
+ //#region src/models/Activity.ts
1019
+ const activityDesc = makeModel({
1020
+ name: "activity",
1021
+ fields: {
1022
+ id: id(),
1023
+ type: string({}),
1024
+ data: object({}),
1025
+ isRemovedFromDeckEntry: bool({}),
1026
+ isRemovedFromMilestoneEntry: bool({}),
1027
+ isRemovedFromSprintEntry: bool({}),
1028
+ createdAt: date({}),
1029
+ cardId: belongsTo({}).type(),
1030
+ deckId: belongsTo({}).type(),
1031
+ projectId: belongsTo({}).type(),
1032
+ milestoneId: belongsTo({}).type(),
1033
+ sprintId: belongsTo({}).type(),
1034
+ changerId: belongsTo({}).type()
1035
+ },
1036
+ relations: {
1037
+ card: relation("card", {
1038
+ type: "belongsTo",
1039
+ fk: "cardId"
1040
+ }),
1041
+ deck: relation("deck", {
1042
+ type: "belongsTo",
1043
+ fk: "deckId"
1044
+ }),
1045
+ project: relation("project", {
1046
+ type: "belongsTo",
1047
+ fk: "projectId"
1048
+ }),
1049
+ milestone: relation("milestone", {
1050
+ type: "belongsTo",
1051
+ fk: "milestoneId"
1052
+ }),
1053
+ sprint: relation("sprint", {
1054
+ type: "belongsTo",
1055
+ fk: "sprintId"
1056
+ }),
1057
+ changer: relation("user", {
1058
+ type: "belongsTo",
1059
+ fk: "changerId"
1060
+ })
1061
+ },
1062
+ keys: ["id"]
1063
+ });
1064
+
1065
+ //#endregion
1066
+ //#region src/models/AffiliateCode.ts
1067
+ const affiliateCodeDesc = makeModel({
1068
+ name: "affiliateCode",
1069
+ fields: {
1070
+ id: id(),
1071
+ code: string({}),
1072
+ vanityUrl: string({}),
1073
+ message: string({}),
1074
+ label: string({}),
1075
+ isDisabled: string({}),
1076
+ isDeleted: string({}),
1077
+ validUntil: string({}),
1078
+ remainingRedemptions: string({}),
1079
+ reward: object({}),
1080
+ createdAt: date({}),
1081
+ accountId: belongsTo({}).type(),
1082
+ creatorId: belongsTo({}).type()
1083
+ },
1084
+ relations: {
1085
+ account: relation("account", {
1086
+ type: "belongsTo",
1087
+ fk: "accountId"
1088
+ }),
1089
+ creator: relation("user", {
1090
+ type: "belongsTo",
1091
+ fk: "creatorId"
1092
+ }),
1093
+ stats: relation("affiliateCodeStat", { type: "hasMany" })
1094
+ },
1095
+ keys: ["id"]
1096
+ });
1097
+
1098
+ //#endregion
1099
+ //#region src/models/AffiliateCodeStat.ts
1100
+ const affiliateCodeStatDesc = makeModel({
1101
+ name: "affiliateCodeStat",
1102
+ fields: {
1103
+ month: int({}),
1104
+ year: int({}),
1105
+ visits: int({}),
1106
+ newVisitors: int({}),
1107
+ signups: int({}),
1108
+ revenue: int({}),
1109
+ affiliateCodeId: belongsTo({}).type()
1110
+ },
1111
+ relations: { affiliateCode: relation("affiliateCode", {
1112
+ type: "belongsTo",
1113
+ fk: "affiliateCodeId"
1114
+ }) },
1115
+ keys: ["affiliateCodeId", "month"]
1116
+ });
1117
+
1118
+ //#endregion
1119
+ //#region src/models/App.ts
1120
+ const appDesc = makeModel({
1121
+ name: "app",
1122
+ fields: {
1123
+ id: id(),
1124
+ name: string({}),
1125
+ createdAt: date({}),
1126
+ payload: object({})
1127
+ },
1128
+ relations: {},
1129
+ keys: ["id"]
1130
+ });
1131
+
1132
+ //#endregion
1133
+ //#region src/models/AppInstallation.ts
1134
+ const appInstallationDesc = makeModel({
1135
+ name: "appInstallation",
1136
+ fields: {
1137
+ id: id(),
1138
+ createdAt: date({}),
1139
+ accountId: belongsTo({}).type(),
1140
+ appId: belongsTo({}).type(),
1141
+ installerId: belongsTo({}).type()
1142
+ },
1143
+ relations: {
1144
+ account: relation("account", {
1145
+ type: "belongsTo",
1146
+ fk: "accountId"
1147
+ }),
1148
+ app: relation("app", {
1149
+ type: "belongsTo",
1150
+ fk: "appId"
1151
+ }),
1152
+ installer: relation("user", {
1153
+ type: "belongsTo",
1154
+ fk: "installerId"
1155
+ })
1156
+ },
1157
+ keys: ["id"]
1158
+ });
1159
+
1160
+ //#endregion
1161
+ //#region src/models/AssigneeAssignment.ts
1162
+ const assigneeAssignmentDesc = makeModel({
1163
+ name: "assigneeAssignment",
1164
+ fields: {
1165
+ lastAssignedAt: date({}),
1166
+ accountId: belongsTo({}).type(),
1167
+ assigneeId: belongsTo({}).type(),
1168
+ assignedById: belongsTo({}).type()
1169
+ },
1170
+ relations: {
1171
+ account: relation("account", {
1172
+ type: "belongsTo",
1173
+ fk: "accountId"
1174
+ }),
1175
+ assignee: relation("user", {
1176
+ type: "belongsTo",
1177
+ fk: "assigneeId"
1178
+ }),
1179
+ assignedBy: relation("user", {
1180
+ type: "belongsTo",
1181
+ fk: "assignedById"
1182
+ })
1183
+ },
1184
+ keys: ["assigneeId", "assignedById"]
1185
+ });
1186
+
1187
+ //#endregion
1188
+ //#region src/models/AssigneeDeckAssignment.ts
1189
+ const assigneeDeckAssignmentDesc = makeModel({
1190
+ name: "assigneeDeckAssignment",
1191
+ fields: {
1192
+ lastAssignedAt: date({}),
1193
+ accountId: belongsTo({}).type(),
1194
+ deckId: belongsTo({}).type(),
1195
+ assigneeId: belongsTo({}).type(),
1196
+ assignedById: belongsTo({}).type()
1197
+ },
1198
+ relations: {
1199
+ account: relation("account", {
1200
+ type: "belongsTo",
1201
+ fk: "accountId"
1202
+ }),
1203
+ deck: relation("deck", {
1204
+ type: "belongsTo",
1205
+ fk: "deckId"
1206
+ }),
1207
+ assignee: relation("user", {
1208
+ type: "belongsTo",
1209
+ fk: "assigneeId"
1210
+ }),
1211
+ assignedBy: relation("user", {
1212
+ type: "belongsTo",
1213
+ fk: "assignedById"
1214
+ })
1215
+ },
1216
+ keys: [
1217
+ "assigneeId",
1218
+ "assignedById",
1219
+ "deckId"
1220
+ ]
1221
+ });
1222
+
1223
+ //#endregion
1224
+ //#region src/models/Attachment.ts
1225
+ const attachmentDesc = makeModel({
1226
+ name: "attachment",
1227
+ fields: {
1228
+ id: id(),
1229
+ content: string({}),
1230
+ title: string({}),
1231
+ createdAt: date({}),
1232
+ fileId: belongsTo({}).type(),
1233
+ cardId: belongsTo({}).type(),
1234
+ accountId: belongsTo({}).type(),
1235
+ creatorId: belongsTo({}).type()
1236
+ },
1237
+ relations: {
1238
+ file: relation("file", {
1239
+ type: "belongsTo",
1240
+ fk: "fileId"
1241
+ }),
1242
+ card: relation("card", {
1243
+ type: "belongsTo",
1244
+ fk: "cardId"
1245
+ }),
1246
+ account: relation("account", {
1247
+ type: "belongsTo",
1248
+ fk: "accountId"
1249
+ }),
1250
+ creator: relation("user", {
1251
+ type: "belongsTo",
1252
+ fk: "creatorId"
1253
+ })
1254
+ },
1255
+ keys: ["id"]
1256
+ });
1257
+
1258
+ //#endregion
1259
+ //#region src/models/TimeTrackingSegment.ts
1260
+ const timeTrackingSegmentDesc = makeModel({
1261
+ name: "timeTrackingSegment",
1262
+ fields: {
1263
+ id: id(),
1264
+ createdAt: date({}),
1265
+ finishedAt: date({ optional: true }),
1266
+ startedAt: date({}),
1267
+ modifyDurationMsBy: int({}),
1268
+ addedManually: string({}),
1269
+ autoFinishedState: string({}),
1270
+ cardId: belongsTo({}).type(),
1271
+ userId: belongsTo({}).type(),
1272
+ accountId: belongsTo({}).type()
1273
+ },
1274
+ relations: {
1275
+ card: relation("card", {
1276
+ type: "belongsTo",
1277
+ fk: "cardId"
1278
+ }),
1279
+ user: relation("user", {
1280
+ type: "belongsTo",
1281
+ fk: "userId"
1282
+ }),
1283
+ account: relation("account", {
1284
+ type: "belongsTo",
1285
+ fk: "accountId"
1286
+ })
1287
+ },
1288
+ keys: ["id"]
1289
+ });
1290
+
1291
+ //#endregion
1292
+ //#region src/models/AutoFinishedTimeTrackingSegment.ts
1293
+ const autoFinishedTimeTrackingSegmentDesc = makeModel({
1294
+ name: "autoFinishedTimeTrackingSegment",
1295
+ fields: {
1296
+ createdAt: date({}),
1297
+ userId: belongsTo({}).type(),
1298
+ accountId: belongsTo({}).type(),
1299
+ cardId: belongsTo({}).type(),
1300
+ timeTrackingSegmentId: belongsTo({}).type()
1301
+ },
1302
+ relations: {
1303
+ user: relation("user", {
1304
+ type: "belongsTo",
1305
+ fk: "userId"
1306
+ }),
1307
+ account: relation("account", {
1308
+ type: "belongsTo",
1309
+ fk: "accountId"
1310
+ }),
1311
+ card: relation("card", {
1312
+ type: "belongsTo",
1313
+ fk: "cardId"
1314
+ }),
1315
+ timeTrackingSegment: relation("timeTrackingSegment", {
1316
+ type: "belongsTo",
1317
+ fk: "timeTrackingSegmentId"
1318
+ })
1319
+ },
1320
+ keys: ["userId", "accountId"]
1321
+ });
1322
+
1323
+ //#endregion
1324
+ //#region src/models/CardDiffNotification.ts
1325
+ const cardDiffNotificationDesc = makeModel({
1326
+ name: "cardDiffNotification",
1327
+ fields: {
1328
+ changes: object({}),
1329
+ asOwner: bool({}),
1330
+ changers: array({}),
1331
+ lastUpdatedAt: date({}),
1332
+ createdAt: date({}),
1333
+ userId: belongsTo({}).type(),
1334
+ cardId: belongsTo({}).type(),
1335
+ accountId: belongsTo({}).type()
1336
+ },
1337
+ relations: {
1338
+ user: relation("user", {
1339
+ type: "belongsTo",
1340
+ fk: "userId"
1341
+ }),
1342
+ card: relation("card", {
1343
+ type: "belongsTo",
1344
+ fk: "cardId"
1345
+ }),
1346
+ account: relation("account", {
1347
+ type: "belongsTo",
1348
+ fk: "accountId"
1349
+ })
1350
+ },
1351
+ keys: ["userId", "cardId"]
1352
+ });
1353
+
1354
+ //#endregion
1355
+ //#region src/models/CardHistory.ts
1356
+ const cardHistoryDesc = makeModel({
1357
+ name: "cardHistory",
1358
+ fields: {
1359
+ diff: object({}),
1360
+ versionCreatedAt: date({}),
1361
+ version: int({}),
1362
+ accountId: belongsTo({}).type(),
1363
+ cardId: belongsTo({}).type(),
1364
+ changerId: belongsTo({}).type()
1365
+ },
1366
+ relations: {
1367
+ account: relation("account", {
1368
+ type: "belongsTo",
1369
+ fk: "accountId"
1370
+ }),
1371
+ card: relation("card", {
1372
+ type: "belongsTo",
1373
+ fk: "cardId"
1374
+ }),
1375
+ changer: relation("user", {
1376
+ type: "belongsTo",
1377
+ fk: "changerId"
1378
+ })
1379
+ },
1380
+ keys: ["cardId", "version"]
1381
+ });
1382
+
1383
+ //#endregion
1384
+ //#region src/models/CardOrderInDeck.ts
1385
+ const cardOrderInDeckDesc = makeModel({
1386
+ name: "cardOrderInDeck",
1387
+ fields: {
1388
+ sortIndex: string({}),
1389
+ cardId: belongsTo({}).type(),
1390
+ deckId: belongsTo({}).type(),
1391
+ changerId: belongsTo({}).type()
1392
+ },
1393
+ relations: {
1394
+ card: relation("card", {
1395
+ type: "belongsTo",
1396
+ fk: "cardId"
1397
+ }),
1398
+ deck: relation("deck", {
1399
+ type: "belongsTo",
1400
+ fk: "deckId"
1401
+ }),
1402
+ changer: relation("user", {
1403
+ type: "belongsTo",
1404
+ fk: "changerId"
1405
+ })
1406
+ },
1407
+ keys: ["cardId", "deckId"]
1408
+ });
1409
+
1410
+ //#endregion
1411
+ //#region src/models/CardOrder.ts
1412
+ const cardOrderDesc = makeModel({
1413
+ name: "cardOrder",
1414
+ fields: {
1415
+ sortValue: string({}),
1416
+ label: string({}),
1417
+ cardId: belongsTo({}).type(),
1418
+ accountId: belongsTo({}).type()
1419
+ },
1420
+ relations: {
1421
+ card: relation("card", {
1422
+ type: "belongsTo",
1423
+ fk: "cardId"
1424
+ }),
1425
+ account: relation("account", {
1426
+ type: "belongsTo",
1427
+ fk: "accountId"
1428
+ })
1429
+ },
1430
+ keys: ["context", "cardId"]
1431
+ });
1432
+
1433
+ //#endregion
1434
+ //#region src/models/CardPreset.ts
1435
+ const cardPresetDesc = makeModel({
1436
+ name: "cardPreset",
1437
+ fields: {
1438
+ id: id(),
1439
+ name: string({}),
1440
+ data: object({}),
1441
+ createdAt: date({}),
1442
+ accountId: belongsTo({}).type(),
1443
+ creatorId: belongsTo({}).type()
1444
+ },
1445
+ relations: {
1446
+ account: relation("account", {
1447
+ type: "belongsTo",
1448
+ fk: "accountId"
1449
+ }),
1450
+ creator: relation("user", {
1451
+ type: "belongsTo",
1452
+ fk: "creatorId"
1453
+ })
1454
+ },
1455
+ keys: ["id"]
1456
+ });
1457
+
1458
+ //#endregion
1459
+ //#region src/models/CardSubscription.ts
1460
+ const cardSubscriptionDesc = makeModel({
1461
+ name: "cardSubscription",
1462
+ fields: {
1463
+ id: id(),
1464
+ createdAt: date({}),
1465
+ userId: belongsTo({}).type(),
1466
+ cardId: belongsTo({}).type(),
1467
+ accountId: belongsTo({}).type()
1468
+ },
1469
+ relations: {
1470
+ user: relation("user", {
1471
+ type: "belongsTo",
1472
+ fk: "userId"
1473
+ }),
1474
+ card: relation("card", {
1475
+ type: "belongsTo",
1476
+ fk: "cardId"
1477
+ }),
1478
+ account: relation("account", {
1479
+ type: "belongsTo",
1480
+ fk: "accountId"
1481
+ })
1482
+ },
1483
+ keys: ["id"]
1484
+ });
1485
+
1486
+ //#endregion
1487
+ //#region src/models/CardUpvote.ts
1488
+ const cardUpvoteDesc = makeModel({
1489
+ name: "cardUpvote",
1490
+ fields: {
1491
+ id: id(),
1492
+ type: string({}),
1493
+ createdAt: date({}),
1494
+ discordUserInfo: object({}),
1495
+ userId: belongsTo({}).type(),
1496
+ accountId: belongsTo({}).type(),
1497
+ cardId: belongsTo({}).type()
1498
+ },
1499
+ relations: {
1500
+ user: relation("user", {
1501
+ type: "belongsTo",
1502
+ fk: "userId"
1503
+ }),
1504
+ account: relation("account", {
1505
+ type: "belongsTo",
1506
+ fk: "accountId"
1507
+ }),
1508
+ card: relation("card", {
1509
+ type: "belongsTo",
1510
+ fk: "cardId"
1511
+ })
1512
+ },
1513
+ keys: ["id"]
1514
+ });
1515
+
1516
+ //#endregion
1517
+ //#region src/models/CardsEffortHistory.ts
1518
+ const cardsEffortHistoryDesc = makeModel({
1519
+ name: "cardsEffortHistory",
1520
+ fields: {
1521
+ effortSum: bigint({}),
1522
+ cardCount: bigint({}),
1523
+ date: day({})
1524
+ },
1525
+ relations: {},
1526
+ keys: [
1527
+ "date",
1528
+ "effortSum",
1529
+ "cardCount"
1530
+ ]
1531
+ });
1532
+
1533
+ //#endregion
1534
+ //#region src/models/CardsFinishedHistory.ts
1535
+ const cardsFinishedHistoryDesc = makeModel({
1536
+ name: "cardsFinishedHistory",
1537
+ fields: {
1538
+ effortSum: bigint({}),
1539
+ cardCount: bigint({}),
1540
+ date: day({}),
1541
+ assigneeId: belongsTo({}).type()
1542
+ },
1543
+ relations: { assignee: relation("user", {
1544
+ type: "belongsTo",
1545
+ fk: "assigneeId"
1546
+ }) },
1547
+ keys: [
1548
+ "date",
1549
+ "effortSum",
1550
+ "cardCount",
1551
+ "assigneeId"
1552
+ ]
1553
+ });
1554
+
1555
+ //#endregion
1556
+ //#region src/models/CardsStatusHistory.ts
1557
+ const cardsStatusHistoryDesc = makeModel({
1558
+ name: "cardsStatusHistory",
1559
+ fields: {
1560
+ status: string({}),
1561
+ count: int({}),
1562
+ date: day({})
1563
+ },
1564
+ relations: {},
1565
+ keys: [
1566
+ "date",
1567
+ "status",
1568
+ "count"
1569
+ ]
1570
+ });
1571
+
1572
+ //#endregion
1573
+ //#region src/models/CardsTimeToFinished.ts
1574
+ const cardsTimeToFinishedDesc = makeModel({
1575
+ name: "cardsTimeToFinished",
1576
+ fields: {
1577
+ effort: int({}),
1578
+ startedAt: date({}),
1579
+ doneAt: date({}),
1580
+ cardId: belongsTo({}).type(),
1581
+ assigneeId: belongsTo({}).type()
1582
+ },
1583
+ relations: {
1584
+ card: relation("card", {
1585
+ type: "belongsTo",
1586
+ fk: "cardId"
1587
+ }),
1588
+ assignee: relation("user", {
1589
+ type: "belongsTo",
1590
+ fk: "assigneeId"
1591
+ })
1592
+ },
1593
+ keys: [
1594
+ "cardId",
1595
+ "startedAt",
1596
+ "doneAt",
1597
+ "effort",
1598
+ "assigneeId"
1599
+ ]
1600
+ });
1601
+
1602
+ //#endregion
1603
+ //#region src/models/DailyDiscordGuildVoteMembership.ts
1604
+ const dailyDiscordGuildVoteMembershipDesc = makeModel({
1605
+ name: "dailyDiscordGuildVoteMembership",
1606
+ fields: {
1607
+ t: date({}),
1608
+ membershipCount: int({}),
1609
+ discordGuildId: belongsTo({}).type()
1610
+ },
1611
+ relations: { discordGuild: relation("discordGuild", {
1612
+ type: "belongsTo",
1613
+ fk: "discordGuildId"
1614
+ }) },
1615
+ keys: ["t", "guildId"]
1616
+ });
1617
+
1618
+ //#endregion
1619
+ //#region src/models/DailyPublicProjectMembership.ts
1620
+ const dailyPublicProjectMembershipDesc = makeModel({
1621
+ name: "dailyPublicProjectMembership",
1622
+ fields: {
1623
+ t: date({}),
1624
+ membershipCount: int({}),
1625
+ projectId: belongsTo({}).type()
1626
+ },
1627
+ relations: { project: relation("project", {
1628
+ type: "belongsTo",
1629
+ fk: "projectId"
1630
+ }) },
1631
+ keys: ["t", "projectId"]
1632
+ });
1633
+
1634
+ //#endregion
1635
+ //#region src/models/PublicProjectVisit.ts
1636
+ const publicProjectVisitDesc = makeModel({
1637
+ name: "publicProjectVisit",
1638
+ fields: {
1639
+ t: date({}),
1640
+ topReferrers: object({}),
1641
+ visitCounts: int({}),
1642
+ projectId: belongsTo({}).type()
1643
+ },
1644
+ relations: { project: relation("project", {
1645
+ type: "belongsTo",
1646
+ fk: "projectId"
1647
+ }) },
1648
+ keys: ["t", "projectId"]
1649
+ });
1650
+
1651
+ //#endregion
1652
+ //#region src/models/DeckAssignment.ts
1653
+ const deckAssignmentDesc = makeModel({
1654
+ name: "deckAssignment",
1655
+ fields: {
1656
+ lastAssignedAt: date({}),
1657
+ deckId: belongsTo({}).type(),
1658
+ userId: belongsTo({}).type(),
1659
+ accountId: belongsTo({}).type()
1660
+ },
1661
+ relations: {
1662
+ deck: relation("deck", {
1663
+ type: "belongsTo",
1664
+ fk: "deckId"
1665
+ }),
1666
+ user: relation("user", {
1667
+ type: "belongsTo",
1668
+ fk: "userId"
1669
+ }),
1670
+ account: relation("account", {
1671
+ type: "belongsTo",
1672
+ fk: "accountId"
1673
+ })
1674
+ },
1675
+ keys: ["userId", "deckId"]
1676
+ });
1677
+
1678
+ //#endregion
1679
+ //#region src/models/DeckGuardian.ts
1680
+ const deckGuardianDesc = makeModel({
1681
+ name: "deckGuardian",
1682
+ fields: {
1683
+ userId: belongsTo({}).type(),
1684
+ accountId: belongsTo({}).type(),
1685
+ deckId: belongsTo({}).type()
1686
+ },
1687
+ relations: {
1688
+ user: relation("user", {
1689
+ type: "belongsTo",
1690
+ fk: "userId"
1691
+ }),
1692
+ account: relation("account", {
1693
+ type: "belongsTo",
1694
+ fk: "accountId"
1695
+ }),
1696
+ deck: relation("deck", {
1697
+ type: "belongsTo",
1698
+ fk: "deckId"
1699
+ })
1700
+ },
1701
+ keys: ["deckId", "userId"]
1702
+ });
1703
+
1704
+ //#endregion
1705
+ //#region src/models/DeckSubscription.ts
1706
+ const deckSubscriptionDesc = makeModel({
1707
+ name: "deckSubscription",
1708
+ fields: {
1709
+ id: id(),
1710
+ userId: belongsTo({}).type(),
1711
+ deckId: belongsTo({}).type(),
1712
+ accountId: belongsTo({}).type()
1713
+ },
1714
+ relations: {
1715
+ user: relation("user", {
1716
+ type: "belongsTo",
1717
+ fk: "userId"
1718
+ }),
1719
+ deck: relation("deck", {
1720
+ type: "belongsTo",
1721
+ fk: "deckId"
1722
+ }),
1723
+ account: relation("account", {
1724
+ type: "belongsTo",
1725
+ fk: "accountId"
1726
+ })
1727
+ },
1728
+ keys: ["id"]
1729
+ });
1730
+
1731
+ //#endregion
1732
+ //#region src/models/DiscordMember.ts
1733
+ const discordMemberDesc = makeModel({
1734
+ name: "discordMember",
1735
+ fields: {
1736
+ id: id(),
1737
+ discordUserId: string({}),
1738
+ name: string({}),
1739
+ nick: string({}),
1740
+ avatar: string({}),
1741
+ discriminator: string({}),
1742
+ createdAt: date({}),
1743
+ deckyScore: int({}),
1744
+ discordGuildId: belongsTo({}).type()
1745
+ },
1746
+ relations: { discordGuild: relation("discordGuild", {
1747
+ type: "belongsTo",
1748
+ fk: "discordGuildId"
1749
+ }) },
1750
+ keys: ["id"]
1751
+ });
1752
+
1753
+ //#endregion
1754
+ //#region src/models/DiscordProjectNotification.ts
1755
+ const discordProjectNotificationDesc = makeModel({
1756
+ name: "discordProjectNotification",
1757
+ fields: {
1758
+ id: id(),
1759
+ discordChannelId: string({}),
1760
+ disabledTypes: object({}),
1761
+ createdAt: date({}),
1762
+ projectId: belongsTo({}).type(),
1763
+ discordGuildId: belongsTo({}).type()
1764
+ },
1765
+ relations: {
1766
+ project: relation("project", {
1767
+ type: "belongsTo",
1768
+ fk: "projectId"
1769
+ }),
1770
+ discordGuild: relation("discordGuild", {
1771
+ type: "belongsTo",
1772
+ fk: "discordGuildId"
1773
+ })
1774
+ },
1775
+ keys: ["id"]
1776
+ });
1777
+
1778
+ //#endregion
1779
+ //#region src/models/DiscordSlashCommand.ts
1780
+ const discordSlashCommandDesc = makeModel({
1781
+ name: "discordSlashCommand",
1782
+ fields: {
1783
+ id: id(),
1784
+ channelId: string({}),
1785
+ statusTargetChannelId: string({}),
1786
+ reaction: string({}),
1787
+ name: string({}),
1788
+ description: string({}),
1789
+ autoAddRoleToThread: string({}),
1790
+ leaderboard: object({}),
1791
+ reactionThreshold: int({}),
1792
+ karmaForCompletion: int({}),
1793
+ maxFileSizeInBytes: int({}),
1794
+ statusMessages: object({}),
1795
+ permissions: object({}),
1796
+ deckId: belongsTo({}).type(),
1797
+ discordGuildId: belongsTo({}).type()
1798
+ },
1799
+ relations: {
1800
+ deck: relation("deck", {
1801
+ type: "belongsTo",
1802
+ fk: "deckId"
1803
+ }),
1804
+ discordGuild: relation("discordGuild", {
1805
+ type: "belongsTo",
1806
+ fk: "discordGuildId"
1807
+ })
1808
+ },
1809
+ keys: ["id"]
1810
+ });
1811
+
1812
+ //#endregion
1813
+ //#region src/models/DueCard.ts
1814
+ const dueCardDesc = makeModel({
1815
+ name: "dueCard",
1816
+ fields: {
1817
+ createdAt: date({}),
1818
+ userId: belongsTo({}).type(),
1819
+ accountId: belongsTo({}).type(),
1820
+ cardId: belongsTo({}).type()
1821
+ },
1822
+ relations: {
1823
+ user: relation("user", {
1824
+ type: "belongsTo",
1825
+ fk: "userId"
1826
+ }),
1827
+ account: relation("account", {
1828
+ type: "belongsTo",
1829
+ fk: "accountId"
1830
+ }),
1831
+ card: relation("card", {
1832
+ type: "belongsTo",
1833
+ fk: "cardId"
1834
+ })
1835
+ },
1836
+ keys: ["userId", "cardId"]
1837
+ });
1838
+
1839
+ //#endregion
1840
+ //#region src/models/HandCard.ts
1841
+ const handCardDesc = makeModel({
1842
+ name: "handCard",
1843
+ fields: {
1844
+ sortIndex: int({}),
1845
+ userId: belongsTo({}).type(),
1846
+ accountId: belongsTo({}).type(),
1847
+ cardId: belongsTo({}).type()
1848
+ },
1849
+ relations: {
1850
+ user: relation("user", {
1851
+ type: "belongsTo",
1852
+ fk: "userId"
1853
+ }),
1854
+ account: relation("account", {
1855
+ type: "belongsTo",
1856
+ fk: "accountId"
1857
+ }),
1858
+ card: relation("card", {
1859
+ type: "belongsTo",
1860
+ fk: "cardId"
1861
+ })
1862
+ },
1863
+ keys: [
1864
+ "cardId",
1865
+ "userId",
1866
+ "accountId"
1867
+ ]
1868
+ });
1869
+
1870
+ //#endregion
1871
+ //#region src/models/Integration.ts
1872
+ const integrationDesc = makeModel({
1873
+ name: "integration",
1874
+ fields: {
1875
+ id: id(),
1876
+ type: string({}),
1877
+ disabled: string({}),
1878
+ userData: object({}),
1879
+ createdAt: date({}),
1880
+ version: int({}),
1881
+ accountId: belongsTo({}).type(),
1882
+ userId: belongsTo({}).type(),
1883
+ creatorId: belongsTo({}).type()
1884
+ },
1885
+ relations: {
1886
+ account: relation("account", {
1887
+ type: "belongsTo",
1888
+ fk: "accountId"
1889
+ }),
1890
+ user: relation("user", {
1891
+ type: "belongsTo",
1892
+ fk: "userId"
1893
+ }),
1894
+ creator: relation("user", {
1895
+ type: "belongsTo",
1896
+ fk: "creatorId"
1897
+ })
1898
+ },
1899
+ keys: ["id"]
1900
+ });
1901
+
1902
+ //#endregion
1903
+ //#region src/models/Invoice.ts
1904
+ const invoiceDesc = makeModel({
1905
+ name: "invoice",
1906
+ fields: {
1907
+ id: id(),
1908
+ invoiceNumber: string({}),
1909
+ url: string({}),
1910
+ createdAt: date({}),
1911
+ total: int({}),
1912
+ subtotal: int({}),
1913
+ charged: int({}),
1914
+ chargeData: object({}),
1915
+ accountId: belongsTo({}).type()
1916
+ },
1917
+ relations: { account: relation("account", {
1918
+ type: "belongsTo",
1919
+ fk: "accountId"
1920
+ }) },
1921
+ keys: ["id"]
1922
+ });
1923
+
1924
+ //#endregion
1925
+ //#region src/models/LastSeenCardUpvote.ts
1926
+ const lastSeenCardUpvoteDesc = makeModel({
1927
+ name: "lastSeenCardUpvote",
1928
+ fields: {
1929
+ lastSeenAt: date({}),
1930
+ createdAt: date({}),
1931
+ userId: belongsTo({}).type(),
1932
+ accountId: belongsTo({}).type()
1933
+ },
1934
+ relations: {
1935
+ user: relation("user", {
1936
+ type: "belongsTo",
1937
+ fk: "userId"
1938
+ }),
1939
+ account: relation("account", {
1940
+ type: "belongsTo",
1941
+ fk: "accountId"
1942
+ })
1943
+ },
1944
+ keys: ["userId", "accountId"]
1945
+ });
1946
+
1947
+ //#endregion
1948
+ //#region src/models/MilestoneProgress.ts
1949
+ const milestoneProgressDesc = makeModel({
1950
+ name: "milestoneProgress",
1951
+ fields: {
1952
+ progress: object({}),
1953
+ milestoneId: belongsTo({}).type()
1954
+ },
1955
+ relations: { milestone: relation("milestone", {
1956
+ type: "belongsTo",
1957
+ fk: "milestoneId"
1958
+ }) },
1959
+ keys: ["milestoneId", "date"]
1960
+ });
1961
+
1962
+ //#endregion
1963
+ //#region src/models/MilestoneProject.ts
1964
+ const milestoneProjectDesc = makeModel({
1965
+ name: "milestoneProject",
1966
+ fields: {
1967
+ milestoneId: belongsTo({}).type(),
1968
+ projectId: belongsTo({}).type(),
1969
+ accountId: belongsTo({}).type()
1970
+ },
1971
+ relations: {
1972
+ milestone: relation("milestone", {
1973
+ type: "belongsTo",
1974
+ fk: "milestoneId"
1975
+ }),
1976
+ project: relation("project", {
1977
+ type: "belongsTo",
1978
+ fk: "projectId"
1979
+ }),
1980
+ account: relation("account", {
1981
+ type: "belongsTo",
1982
+ fk: "accountId"
1983
+ })
1984
+ },
1985
+ keys: ["milestoneId", "projectId"]
1986
+ });
1987
+
1988
+ //#endregion
1989
+ //#region src/models/PinnedMilestone.ts
1990
+ const pinnedMilestoneDesc = makeModel({
1991
+ name: "pinnedMilestone",
1992
+ fields: {
1993
+ id: id(),
1994
+ autoAssignStartedCard: bool({}),
1995
+ autoAssignNewCard: bool({}),
1996
+ userId: belongsTo({}).type(),
1997
+ accountId: belongsTo({}).type(),
1998
+ sprintId: belongsTo({}).type(),
1999
+ milestoneId: belongsTo({}).type()
2000
+ },
2001
+ relations: {
2002
+ user: relation("user", {
2003
+ type: "belongsTo",
2004
+ fk: "userId"
2005
+ }),
2006
+ account: relation("account", {
2007
+ type: "belongsTo",
2008
+ fk: "accountId"
2009
+ }),
2010
+ sprint: relation("sprint", {
2011
+ type: "belongsTo",
2012
+ fk: "sprintId"
2013
+ }),
2014
+ milestone: relation("milestone", {
2015
+ type: "belongsTo",
2016
+ fk: "milestoneId"
2017
+ })
2018
+ },
2019
+ keys: ["id"]
2020
+ });
2021
+
2022
+ //#endregion
2023
+ //#region src/models/ProjectOrder.ts
2024
+ const projectOrderDesc = makeModel({
2025
+ name: "projectOrder",
2026
+ fields: {
2027
+ sortIndex: int({}),
2028
+ userId: belongsTo({}).type(),
2029
+ accountId: belongsTo({}).type(),
2030
+ projectId: belongsTo({}).type()
2031
+ },
2032
+ relations: {
2033
+ user: relation("user", {
2034
+ type: "belongsTo",
2035
+ fk: "userId"
2036
+ }),
2037
+ account: relation("account", {
2038
+ type: "belongsTo",
2039
+ fk: "accountId"
2040
+ }),
2041
+ project: relation("project", {
2042
+ type: "belongsTo",
2043
+ fk: "projectId"
2044
+ })
2045
+ },
2046
+ keys: [
2047
+ "projectId",
2048
+ "userId",
2049
+ "accountId"
2050
+ ]
2051
+ });
2052
+
2053
+ //#endregion
2054
+ //#region src/models/ProjectSelection.ts
2055
+ const projectSelectionDesc = makeModel({
2056
+ name: "projectSelection",
2057
+ fields: {
2058
+ id: id(),
2059
+ userId: belongsTo({}).type(),
2060
+ accountId: belongsTo({}).type(),
2061
+ projectId: belongsTo({}).type()
2062
+ },
2063
+ relations: {
2064
+ user: relation("user", {
2065
+ type: "belongsTo",
2066
+ fk: "userId"
2067
+ }),
2068
+ account: relation("account", {
2069
+ type: "belongsTo",
2070
+ fk: "accountId"
2071
+ }),
2072
+ project: relation("project", {
2073
+ type: "belongsTo",
2074
+ fk: "projectId"
2075
+ })
2076
+ },
2077
+ keys: ["id"]
2078
+ });
2079
+
2080
+ //#endregion
2081
+ //#region src/models/ProjectUserSetting.ts
2082
+ const projectUserSettingDesc = makeModel({
2083
+ name: "projectUserSetting",
2084
+ fields: {
2085
+ projectId: belongsTo({}).type(),
2086
+ userId: belongsTo({}).type()
2087
+ },
2088
+ relations: {
2089
+ project: relation("project", {
2090
+ type: "belongsTo",
2091
+ fk: "projectId"
2092
+ }),
2093
+ user: relation("user", {
2094
+ type: "belongsTo",
2095
+ fk: "userId"
2096
+ })
2097
+ },
2098
+ keys: ["projectId", "userId"]
2099
+ });
2100
+
2101
+ //#endregion
2102
+ //#region src/models/ProjectUser.ts
2103
+ const projectUserDesc = makeModel({
2104
+ name: "projectUser",
2105
+ fields: {
2106
+ projectRole: string({}),
2107
+ userId: belongsTo({}).type(),
2108
+ projectId: belongsTo({}).type(),
2109
+ accountId: belongsTo({}).type()
2110
+ },
2111
+ relations: {
2112
+ user: relation("user", {
2113
+ type: "belongsTo",
2114
+ fk: "userId"
2115
+ }),
2116
+ project: relation("project", {
2117
+ type: "belongsTo",
2118
+ fk: "projectId"
2119
+ }),
2120
+ account: relation("account", {
2121
+ type: "belongsTo",
2122
+ fk: "accountId"
2123
+ })
2124
+ },
2125
+ keys: ["projectId", "userId"]
2126
+ });
2127
+
2128
+ //#endregion
2129
+ //#region src/models/PublicProjectInfo.ts
2130
+ const publicProjectInfoDesc = makeModel({
2131
+ name: "publicProjectInfo",
2132
+ fields: {
2133
+ lastActivityAt: string({}),
2134
+ activities7d: string({}),
2135
+ cardCount: string({}),
2136
+ visits7d: string({}),
2137
+ cardDoneStreak: string({}),
2138
+ projectId: belongsTo({}).type(),
2139
+ accountId: belongsTo({}).type()
2140
+ },
2141
+ relations: {
2142
+ project: relation("project", {
2143
+ type: "belongsTo",
2144
+ fk: "projectId"
2145
+ }),
2146
+ account: relation("account", {
2147
+ type: "belongsTo",
2148
+ fk: "accountId"
2149
+ })
2150
+ },
2151
+ keys: ["projectId"]
2152
+ });
2153
+
2154
+ //#endregion
2155
+ //#region src/models/PublicProjectMembership.ts
2156
+ const publicProjectMembershipDesc = makeModel({
2157
+ name: "publicProjectMembership",
2158
+ fields: {
2159
+ digestFrequencyInDays: int({}),
2160
+ createdAt: date({}),
2161
+ userId: belongsTo({}).type(),
2162
+ projectId: belongsTo({}).type()
2163
+ },
2164
+ relations: {
2165
+ user: relation("user", {
2166
+ type: "belongsTo",
2167
+ fk: "userId"
2168
+ }),
2169
+ project: relation("project", {
2170
+ type: "belongsTo",
2171
+ fk: "projectId"
2172
+ })
2173
+ },
2174
+ keys: ["userId", "projectId"]
2175
+ });
2176
+
2177
+ //#endregion
2178
+ //#region src/models/QueueEntry.ts
2179
+ const queueEntryDesc = makeModel({
2180
+ name: "queueEntry",
2181
+ fields: {
2182
+ id: id(),
2183
+ sortIndex: int({}),
2184
+ cardDoneAt: date({}),
2185
+ createdAt: date({}),
2186
+ accountId: belongsTo({}).type(),
2187
+ userId: belongsTo({}).type(),
2188
+ cardId: belongsTo({}).type()
2189
+ },
2190
+ relations: {
2191
+ account: relation("account", {
2192
+ type: "belongsTo",
2193
+ fk: "accountId"
2194
+ }),
2195
+ user: relation("user", {
2196
+ type: "belongsTo",
2197
+ fk: "userId"
2198
+ }),
2199
+ card: relation("card", {
2200
+ type: "belongsTo",
2201
+ fk: "cardId"
2202
+ })
2203
+ },
2204
+ keys: ["id"]
2205
+ });
2206
+
2207
+ //#endregion
2208
+ //#region src/models/QueueSelection.ts
2209
+ const queueSelectionDesc = makeModel({
2210
+ name: "queueSelection",
2211
+ fields: {
2212
+ id: id(),
2213
+ sortIndex: int({}),
2214
+ userId: belongsTo({}).type(),
2215
+ accountId: belongsTo({}).type(),
2216
+ queueUserId: belongsTo({}).type()
2217
+ },
2218
+ relations: {
2219
+ user: relation("user", {
2220
+ type: "belongsTo",
2221
+ fk: "userId"
2222
+ }),
2223
+ account: relation("account", {
2224
+ type: "belongsTo",
2225
+ fk: "accountId"
2226
+ }),
2227
+ queueUser: relation("user", {
2228
+ type: "belongsTo",
2229
+ fk: "queueUserId"
2230
+ })
2231
+ },
2232
+ keys: ["id"]
2233
+ });
2234
+
2235
+ //#endregion
2236
+ //#region src/models/Resolvable.ts
2237
+ const resolvableDesc = makeModel({
2238
+ name: "resolvable",
2239
+ fields: {
2240
+ id: id(),
2241
+ context: string({}),
2242
+ contextAsPrio: int({}),
2243
+ isClosed: bool({}),
2244
+ closedAt: date({ optional: true }),
2245
+ createdAt: date({}),
2246
+ isPublic: bool({}),
2247
+ cardId: belongsTo({}).type(),
2248
+ accountId: belongsTo({}).type(),
2249
+ creatorId: belongsTo({}).type(),
2250
+ closedById: belongsTo({ optional: true }).type()
2251
+ },
2252
+ relations: {
2253
+ card: relation("card", {
2254
+ type: "belongsTo",
2255
+ fk: "cardId"
2256
+ }),
2257
+ account: relation("account", {
2258
+ type: "belongsTo",
2259
+ fk: "accountId"
2260
+ }),
2261
+ creator: relation("user", {
2262
+ type: "belongsTo",
2263
+ fk: "creatorId"
2264
+ }),
2265
+ closedBy: relation("user", {
2266
+ type: "belongsTo",
2267
+ fk: "closedById"
2268
+ }),
2269
+ participants: relation("resolvableParticipant", { type: "hasMany" }),
2270
+ participantHistories: relation("resolvableParticipantHistory", { type: "hasMany" }),
2271
+ entries: relation("resolvableEntry", { type: "hasMany" })
2272
+ },
2273
+ keys: ["id"]
2274
+ });
2275
+
2276
+ //#endregion
2277
+ //#region src/models/ResolvableEntry.ts
2278
+ const resolvableEntryDesc = makeModel({
2279
+ name: "resolvableEntry",
2280
+ fields: {
2281
+ entryId: id(),
2282
+ content: string({}),
2283
+ lastChangedAt: date({}),
2284
+ createdAt: date({}),
2285
+ version: int({}),
2286
+ meta: object({}),
2287
+ resolvableId: belongsTo({}).type(),
2288
+ cardId: belongsTo({}).type(),
2289
+ authorId: belongsTo({}).type()
2290
+ },
2291
+ relations: {
2292
+ resolvable: relation("resolvable", {
2293
+ type: "belongsTo",
2294
+ fk: "resolvableId"
2295
+ }),
2296
+ card: relation("card", {
2297
+ type: "belongsTo",
2298
+ fk: "cardId"
2299
+ }),
2300
+ author: relation("user", {
2301
+ type: "belongsTo",
2302
+ fk: "authorId"
2303
+ }),
2304
+ reactions: relation("resolvableEntryReaction", { type: "hasMany" }),
2305
+ histories: relation("resolvableEntryHistory", { type: "hasMany" })
2306
+ },
2307
+ keys: ["entryId"]
2308
+ });
2309
+
2310
+ //#endregion
2311
+ //#region src/models/ResolvableEntryHistory.ts
2312
+ const resolvableEntryHistoryDesc = makeModel({
2313
+ name: "resolvableEntryHistory",
2314
+ fields: {
2315
+ content: string({}),
2316
+ lastChangedAt: date({}),
2317
+ version: int({}),
2318
+ resolvableId: belongsTo({}).type(),
2319
+ authorId: belongsTo({}).type(),
2320
+ entryId: belongsTo({}).type()
2321
+ },
2322
+ relations: {
2323
+ resolvable: relation("resolvable", {
2324
+ type: "belongsTo",
2325
+ fk: "resolvableId"
2326
+ }),
2327
+ author: relation("user", {
2328
+ type: "belongsTo",
2329
+ fk: "authorId"
2330
+ }),
2331
+ entry: relation("resolvableEntry", {
2332
+ type: "belongsTo",
2333
+ fk: "entryId"
2334
+ })
2335
+ },
2336
+ keys: ["entryId", "version"]
2337
+ });
2338
+
2339
+ //#endregion
2340
+ //#region src/models/ResolvableEntryReaction.ts
2341
+ const resolvableEntryReactionDesc = makeModel({
2342
+ name: "resolvableEntryReaction",
2343
+ fields: {
2344
+ id: id(),
2345
+ value: object({}),
2346
+ createdAt: date({}),
2347
+ isPublic: bool({}),
2348
+ resolvableEntryId: belongsTo({}).type(),
2349
+ accountId: belongsTo({}).type(),
2350
+ userId: belongsTo({}).type(),
2351
+ resolvableId: belongsTo({}).type()
2352
+ },
2353
+ relations: {
2354
+ resolvableEntry: relation("resolvableEntry", {
2355
+ type: "belongsTo",
2356
+ fk: "resolvableEntryId"
2357
+ }),
2358
+ account: relation("account", {
2359
+ type: "belongsTo",
2360
+ fk: "accountId"
2361
+ }),
2362
+ user: relation("user", {
2363
+ type: "belongsTo",
2364
+ fk: "userId"
2365
+ }),
2366
+ resolvable: relation("resolvable", {
2367
+ type: "belongsTo",
2368
+ fk: "resolvableId"
2369
+ })
2370
+ },
2371
+ keys: ["id"]
2372
+ });
2373
+
2374
+ //#endregion
2375
+ //#region src/models/ResolvableNotification.ts
2376
+ const resolvableNotificationDesc = makeModel({
2377
+ name: "resolvableNotification",
2378
+ fields: {
2379
+ isParticipating: bool({}),
2380
+ isSnoozing: bool({}),
2381
+ unseenEntryCount: int({}),
2382
+ unseenAuthors: array({}),
2383
+ isLastParticipant: bool({}),
2384
+ lastUpdatedAt: date({}),
2385
+ snoozeUntil: date({ optional: true }),
2386
+ remindMeOn: date({ optional: true }),
2387
+ createdAt: date({}),
2388
+ userId: belongsTo({}).type(),
2389
+ resolvableId: belongsTo({}).type(),
2390
+ accountId: belongsTo({}).type(),
2391
+ latestEntryId: belongsTo({}).type(),
2392
+ latestSeenEntryId: belongsTo({}).type()
2393
+ },
2394
+ relations: {
2395
+ user: relation("user", {
2396
+ type: "belongsTo",
2397
+ fk: "userId"
2398
+ }),
2399
+ resolvable: relation("resolvable", {
2400
+ type: "belongsTo",
2401
+ fk: "resolvableId"
2402
+ }),
2403
+ account: relation("account", {
2404
+ type: "belongsTo",
2405
+ fk: "accountId"
2406
+ }),
2407
+ latestEntry: relation("resolvableEntry", {
2408
+ type: "belongsTo",
2409
+ fk: "latestEntryId"
2410
+ }),
2411
+ latestSeenEntry: relation("resolvableEntry", {
2412
+ type: "belongsTo",
2413
+ fk: "latestSeenEntryId"
2414
+ })
2415
+ },
2416
+ keys: ["userId", "resolvableId"]
2417
+ });
2418
+
2419
+ //#endregion
2420
+ //#region src/models/ResolvableParticipantHistory.ts
2421
+ const resolvableParticipantHistoryDesc = makeModel({
2422
+ name: "resolvableParticipantHistory",
2423
+ fields: {
2424
+ firstJoinedAt: string({}),
2425
+ done: string({}),
2426
+ status: string({}),
2427
+ lastChangedAt: date({}),
2428
+ version: int({}),
2429
+ reaction: string({}),
2430
+ resolvableId: belongsTo({}).type(),
2431
+ userId: belongsTo({}).type(),
2432
+ addedById: belongsTo({}).type()
2433
+ },
2434
+ relations: {
2435
+ resolvable: relation("resolvable", {
2436
+ type: "belongsTo",
2437
+ fk: "resolvableId"
2438
+ }),
2439
+ user: relation("user", {
2440
+ type: "belongsTo",
2441
+ fk: "userId"
2442
+ }),
2443
+ addedBy: relation("user", {
2444
+ type: "belongsTo",
2445
+ fk: "addedById"
2446
+ })
2447
+ },
2448
+ keys: [
2449
+ "participantId",
2450
+ "resolvableId",
2451
+ "version"
2452
+ ]
2453
+ });
2454
+
2455
+ //#endregion
2456
+ //#region src/models/ResolvableParticipant.ts
2457
+ const resolvableParticipantDesc = makeModel({
2458
+ name: "resolvableParticipant",
2459
+ fields: {
2460
+ firstJoinedAt: date({}),
2461
+ lastChangedAt: date({}),
2462
+ done: bool({}),
2463
+ status: string({}),
2464
+ discordUserId: string({}),
2465
+ resolvableIsClosed: bool({}),
2466
+ resolvableId: belongsTo({}).type(),
2467
+ accountId: belongsTo({}).type(),
2468
+ userId: belongsTo({}).type(),
2469
+ addedById: belongsTo({}).type()
2470
+ },
2471
+ relations: {
2472
+ resolvable: relation("resolvable", {
2473
+ type: "belongsTo",
2474
+ fk: "resolvableId"
2475
+ }),
2476
+ account: relation("account", {
2477
+ type: "belongsTo",
2478
+ fk: "accountId"
2479
+ }),
2480
+ user: relation("user", {
2481
+ type: "belongsTo",
2482
+ fk: "userId"
2483
+ }),
2484
+ addedBy: relation("user", {
2485
+ type: "belongsTo",
2486
+ fk: "addedById"
2487
+ })
2488
+ },
2489
+ keys: ["participantId", "resolvableId"]
2490
+ });
2491
+
2492
+ //#endregion
2493
+ //#region src/models/SavedSearch.ts
2494
+ const savedSearchDesc = makeModel({
2495
+ name: "savedSearch",
2496
+ fields: {
2497
+ id: id(),
2498
+ tokens: array({}),
2499
+ forceOr: bool({}),
2500
+ accountId: belongsTo({}).type(),
2501
+ ownerId: belongsTo({}).type()
2502
+ },
2503
+ relations: {
2504
+ account: relation("account", {
2505
+ type: "belongsTo",
2506
+ fk: "accountId"
2507
+ }),
2508
+ owner: relation("user", {
2509
+ type: "belongsTo",
2510
+ fk: "ownerId"
2511
+ })
2512
+ },
2513
+ keys: ["id"]
2514
+ });
2515
+
2516
+ //#endregion
2517
+ //#region src/models/SprintConfigProgress.ts
2518
+ const sprintConfigProgressDesc = makeModel({
2519
+ name: "sprintConfigProgress",
2520
+ fields: {
2521
+ progress: object({}),
2522
+ sprintConfigId: belongsTo({}).type()
2523
+ },
2524
+ relations: { sprintConfig: relation("sprintConfig", {
2525
+ type: "belongsTo",
2526
+ fk: "sprintConfigId"
2527
+ }) },
2528
+ keys: ["sprintConfigId", "date"]
2529
+ });
2530
+
2531
+ //#endregion
2532
+ //#region src/models/SprintProgress.ts
2533
+ const sprintProgressDesc = makeModel({
2534
+ name: "sprintProgress",
2535
+ fields: {
2536
+ progress: object({}),
2537
+ sprintId: belongsTo({}).type()
2538
+ },
2539
+ relations: { sprint: relation("sprint", {
2540
+ type: "belongsTo",
2541
+ fk: "sprintId"
2542
+ }) },
2543
+ keys: ["sprintId", "date"]
2544
+ });
2545
+
2546
+ //#endregion
2547
+ //#region src/models/SprintProject.ts
2548
+ const sprintProjectDesc = makeModel({
2549
+ name: "sprintProject",
2550
+ fields: {
2551
+ sprintConfigId: belongsTo({}).type(),
2552
+ projectId: belongsTo({}).type(),
2553
+ accountId: belongsTo({}).type()
2554
+ },
2555
+ relations: {
2556
+ sprintConfig: relation("sprintConfig", {
2557
+ type: "belongsTo",
2558
+ fk: "sprintConfigId"
2559
+ }),
2560
+ project: relation("project", {
2561
+ type: "belongsTo",
2562
+ fk: "projectId"
2563
+ }),
2564
+ account: relation("account", {
2565
+ type: "belongsTo",
2566
+ fk: "accountId"
2567
+ })
2568
+ },
2569
+ keys: ["sprintConfigId", "projectId"]
2570
+ });
2571
+
2572
+ //#endregion
2573
+ //#region src/models/StripeAccountSync.ts
2574
+ const stripeAccountSyncDesc = makeModel({
2575
+ name: "stripeAccountSync",
2576
+ fields: {
2577
+ status: string({}),
2578
+ euVatIdData: object({}),
2579
+ vatCountryCode: string({}),
2580
+ vatTaxPercentage: int({}),
2581
+ centsPerSeat: int({}),
2582
+ billingCycleStart: date({}),
2583
+ billingCycleEnd: date({}),
2584
+ grossActualBalance: int({}),
2585
+ grossBonusBalance: int({}),
2586
+ netGiftBalance: int({}),
2587
+ paymentMethod: object({}),
2588
+ hasBeenCancelledAt: date({}),
2589
+ planType: string({}),
2590
+ planName: string({}),
2591
+ pendingPlanType: string({}),
2592
+ repeatingCoupon: object({}),
2593
+ accountId: belongsTo({}).type()
2594
+ },
2595
+ relations: { account: relation("account", {
2596
+ type: "belongsTo",
2597
+ fk: "accountId"
2598
+ }) },
2599
+ keys: ["accountId"]
2600
+ });
2601
+
2602
+ //#endregion
2603
+ //#region src/models/TimeTrackingSum.ts
2604
+ const timeTrackingSumDesc = makeModel({
2605
+ name: "timeTrackingSum",
2606
+ fields: {
2607
+ sumMs: int({}),
2608
+ runningStartedAt: date({}),
2609
+ runningModifyDurationMsBy: int({}),
2610
+ cardId: belongsTo({}).type(),
2611
+ userId: belongsTo({}).type()
2612
+ },
2613
+ relations: {
2614
+ card: relation("card", {
2615
+ type: "belongsTo",
2616
+ fk: "cardId"
2617
+ }),
2618
+ user: relation("user", {
2619
+ type: "belongsTo",
2620
+ fk: "userId"
2621
+ })
2622
+ },
2623
+ keys: ["cardId", "userId"]
2624
+ });
2625
+
2626
+ //#endregion
2627
+ //#region src/models/UserDismissedHint.ts
2628
+ const userDismissedHintDesc = makeModel({
2629
+ name: "userDismissedHint",
2630
+ fields: {
2631
+ hintKey: string({}),
2632
+ createdAt: date({}),
2633
+ returnAt: date({}),
2634
+ userId: belongsTo({}).type()
2635
+ },
2636
+ relations: { user: relation("user", {
2637
+ type: "belongsTo",
2638
+ fk: "userId"
2639
+ }) },
2640
+ keys: ["userId", "hintKey"]
2641
+ });
2642
+
2643
+ //#endregion
2644
+ //#region src/models/UserEmail.ts
2645
+ const userEmailDesc = makeModel({
2646
+ name: "userEmail",
2647
+ fields: {
2648
+ id: id(),
2649
+ email: string({}),
2650
+ createdAt: date({}),
2651
+ isPrimary: bool({}),
2652
+ isVerified: bool({}),
2653
+ userId: belongsTo({}).type()
2654
+ },
2655
+ relations: { user: relation("user", {
2656
+ type: "belongsTo",
2657
+ fk: "userId"
2658
+ }) },
2659
+ keys: ["id"]
2660
+ });
2661
+
2662
+ //#endregion
2663
+ //#region src/models/UserInvitation.ts
2664
+ const userInvitationDesc = makeModel({
2665
+ name: "userInvitation",
2666
+ fields: {
2667
+ id: id(),
2668
+ email: string({}),
2669
+ role: string({}),
2670
+ accessToProjectIds: array({}),
2671
+ createdAt: date({}),
2672
+ accountId: belongsTo({}).type(),
2673
+ inviterId: belongsTo({}).type()
2674
+ },
2675
+ relations: {
2676
+ account: relation("account", {
2677
+ type: "belongsTo",
2678
+ fk: "accountId"
2679
+ }),
2680
+ inviter: relation("user", {
2681
+ type: "belongsTo",
2682
+ fk: "inviterId"
2683
+ })
2684
+ },
2685
+ keys: ["id"]
2686
+ });
2687
+
2688
+ //#endregion
2689
+ //#region src/models/UserInviteCode.ts
2690
+ const userInviteCodeDesc = makeModel({
2691
+ name: "userInviteCode",
2692
+ fields: {
2693
+ id: id(),
2694
+ token: string({}),
2695
+ role: string({}),
2696
+ useCount: string({}),
2697
+ isActive: string({}),
2698
+ accessToProjectIds: array({}),
2699
+ validUntil: date({}),
2700
+ createdAt: date({}),
2701
+ accountId: belongsTo({}).type(),
2702
+ creatorId: belongsTo({}).type()
2703
+ },
2704
+ relations: {
2705
+ account: relation("account", {
2706
+ type: "belongsTo",
2707
+ fk: "accountId"
2708
+ }),
2709
+ creator: relation("user", {
2710
+ type: "belongsTo",
2711
+ fk: "creatorId"
2712
+ })
2713
+ },
2714
+ keys: ["id"]
2715
+ });
2716
+
2717
+ //#endregion
2718
+ //#region src/models/UserOnboarding.ts
2719
+ const userOnboardingDesc = makeModel({
2720
+ name: "userOnboarding",
2721
+ fields: {
2722
+ steps: object({}),
2723
+ userId: belongsTo({}).type()
2724
+ },
2725
+ relations: { user: relation("user", {
2726
+ type: "belongsTo",
2727
+ fk: "userId"
2728
+ }) },
2729
+ keys: ["userId"]
2730
+ });
2731
+
2732
+ //#endregion
2733
+ //#region src/models/UserProjectAccess.ts
2734
+ const userProjectAccessDesc = makeModel({
2735
+ name: "userProjectAccess",
2736
+ fields: {
2737
+ role: string({}),
2738
+ projectRole: string({}),
2739
+ userId: belongsTo({}).type(),
2740
+ projectId: belongsTo({}).type()
2741
+ },
2742
+ relations: {
2743
+ user: relation("user", {
2744
+ type: "belongsTo",
2745
+ fk: "userId"
2746
+ }),
2747
+ project: relation("project", {
2748
+ type: "belongsTo",
2749
+ fk: "projectId"
2750
+ })
2751
+ },
2752
+ keys: ["projectId", "userId"]
2753
+ });
2754
+
2755
+ //#endregion
2756
+ //#region src/models/UserTag.ts
2757
+ const userTagDesc = makeModel({
2758
+ name: "userTag",
2759
+ fields: {
2760
+ id: id(),
2761
+ tag: string({}),
2762
+ createdAt: date({}),
2763
+ userId: belongsTo({}).type(),
2764
+ accountId: belongsTo({}).type()
2765
+ },
2766
+ relations: {
2767
+ user: relation("user", {
2768
+ type: "belongsTo",
2769
+ fk: "userId"
2770
+ }),
2771
+ account: relation("account", {
2772
+ type: "belongsTo",
2773
+ fk: "accountId"
2774
+ })
2775
+ },
2776
+ keys: ["id"]
2777
+ });
2778
+
2779
+ //#endregion
2780
+ //#region src/models/UserReportSetting.ts
2781
+ const userReportSettingDesc = makeModel({
2782
+ name: "userReportSetting",
2783
+ fields: {
2784
+ id: id(),
2785
+ name: string({}),
2786
+ fileSizeBytesLimit: bigint({}),
2787
+ createdAt: date({}),
2788
+ deckMapping: object({}),
2789
+ prioMapping: object({}),
2790
+ accountId: belongsTo({}).type()
2791
+ },
2792
+ relations: {
2793
+ account: relation("account", {
2794
+ type: "belongsTo",
2795
+ fk: "accountId"
2796
+ }),
2797
+ reportTokens: relation("userReportToken", { type: "hasMany" })
2798
+ },
2799
+ keys: ["id"]
2800
+ });
2801
+
2802
+ //#endregion
2803
+ //#region src/models/UserReportEmail.ts
2804
+ const userReportEmailDesc = makeModel({
2805
+ name: "userReportEmail",
2806
+ fields: {
2807
+ id: id(),
2808
+ email: string({}),
2809
+ createdAt: date({}),
2810
+ enabled: string({}),
2811
+ userReportSettingId: belongsTo({}).type(),
2812
+ accountId: belongsTo({}).type()
2813
+ },
2814
+ relations: {
2815
+ userReportSetting: relation("userReportSetting", {
2816
+ type: "belongsTo",
2817
+ fk: "userReportSettingId"
2818
+ }),
2819
+ account: relation("account", {
2820
+ type: "belongsTo",
2821
+ fk: "accountId"
2822
+ })
2823
+ },
2824
+ keys: ["id"]
2825
+ });
2826
+
2827
+ //#endregion
2828
+ //#region src/models/UserReportToken.ts
2829
+ const userReportTokenDesc = makeModel({
2830
+ name: "userReportToken",
2831
+ fields: {
2832
+ token: id(),
2833
+ label: string({}),
2834
+ reportCount: int({}),
2835
+ createdAt: date({}),
2836
+ enabled: string({}),
2837
+ userReportSettingId: belongsTo({}).type()
2838
+ },
2839
+ relations: { userReportSetting: relation("userReportSetting", {
2840
+ type: "belongsTo",
2841
+ fk: "userReportSettingId"
2842
+ }) },
2843
+ keys: ["token"]
2844
+ });
2845
+
2846
+ //#endregion
2847
+ //#region src/models/VisionBoardQuery.ts
2848
+ const visionBoardQueryDesc = makeModel({
2849
+ name: "visionBoardQuery",
2850
+ fields: {
2851
+ id: id(),
2852
+ query: object({}),
2853
+ lastUsedAt: date({}),
2854
+ isStale: bool({}),
2855
+ type: string({}),
2856
+ payload: object({}),
2857
+ createdAt: date({}),
2858
+ cardId: belongsTo({}).type(),
2859
+ accountId: belongsTo({}).type()
2860
+ },
2861
+ relations: {
2862
+ card: relation("card", {
2863
+ type: "belongsTo",
2864
+ fk: "cardId"
2865
+ }),
2866
+ account: relation("account", {
2867
+ type: "belongsTo",
2868
+ fk: "accountId"
2869
+ })
2870
+ },
2871
+ keys: ["id"]
2872
+ });
2873
+
2874
+ //#endregion
2875
+ //#region src/models/Wizard.ts
2876
+ const wizardDesc = makeModel({
2877
+ name: "wizard",
2878
+ fields: {
2879
+ id: id(),
2880
+ name: string({}),
2881
+ currentStep: string({}),
2882
+ data: object({}),
2883
+ createdAt: date({}),
2884
+ finishedAt: date({}),
2885
+ accountId: belongsTo({}).type()
2886
+ },
2887
+ relations: { account: relation("account", {
2888
+ type: "belongsTo",
2889
+ fk: "accountId"
2890
+ }) },
2891
+ keys: ["id"]
2892
+ });
2893
+
2894
+ //#endregion
2895
+ //#region src/models/WorkflowItemHistory.ts
2896
+ const workflowItemHistoryDesc = makeModel({
2897
+ name: "workflowItemHistory",
2898
+ fields: {
2899
+ diff: object({}),
2900
+ versionCreatedAt: date({}),
2901
+ version: int({}),
2902
+ accountId: belongsTo({}).type(),
2903
+ changerId: belongsTo({}).type()
2904
+ },
2905
+ relations: {
2906
+ account: relation("account", {
2907
+ type: "belongsTo",
2908
+ fk: "accountId"
2909
+ }),
2910
+ changer: relation("user", {
2911
+ type: "belongsTo",
2912
+ fk: "changerId"
2913
+ })
2914
+ },
2915
+ keys: ["itemId", "version"]
2916
+ });
2917
+
2918
+ //#endregion
2919
+ //#region src/models/index.ts
2920
+ const modelMap = {
2921
+ _root: _rootDesc,
2922
+ accountOnboardingStep: accountOnboardingStepDesc,
2923
+ accountOnboarding: accountOnboardingDesc,
2924
+ accountRole: accountRoleDesc,
2925
+ accountUserAchievement: accountUserAchievementDesc,
2926
+ accountUserSetting: accountUserSettingDesc,
2927
+ account: accountDesc,
2928
+ activeTimeTracker: activeTimeTrackerDesc,
2929
+ activity: activityDesc,
2930
+ affiliateCodeStat: affiliateCodeStatDesc,
2931
+ affiliateCode: affiliateCodeDesc,
2932
+ appInstallation: appInstallationDesc,
2933
+ app: appDesc,
2934
+ assigneeAssignment: assigneeAssignmentDesc,
2935
+ assigneeDeckAssignment: assigneeDeckAssignmentDesc,
2936
+ attachment: attachmentDesc,
2937
+ autoFinishedTimeTrackingSegment: autoFinishedTimeTrackingSegmentDesc,
2938
+ cardDiffNotification: cardDiffNotificationDesc,
2939
+ cardHistory: cardHistoryDesc,
2940
+ cardOrderInDeck: cardOrderInDeckDesc,
2941
+ cardOrder: cardOrderDesc,
2942
+ cardPreset: cardPresetDesc,
2943
+ cardSubscription: cardSubscriptionDesc,
2944
+ cardUpvote: cardUpvoteDesc,
2945
+ card: cardDesc,
2946
+ cardsEffortHistory: cardsEffortHistoryDesc,
2947
+ cardsFinishedHistory: cardsFinishedHistoryDesc,
2948
+ cardsStatusHistory: cardsStatusHistoryDesc,
2949
+ cardsTimeToFinished: cardsTimeToFinishedDesc,
2950
+ dailyDiscordGuildVoteMembership: dailyDiscordGuildVoteMembershipDesc,
2951
+ dailyPublicProjectMembership: dailyPublicProjectMembershipDesc,
2952
+ publicProjectVisit: publicProjectVisitDesc,
2953
+ deckAssignment: deckAssignmentDesc,
2954
+ deckGuardian: deckGuardianDesc,
2955
+ deckSubscription: deckSubscriptionDesc,
2956
+ deck: deckDesc,
2957
+ discordGuild: discordGuildDesc,
2958
+ discordMember: discordMemberDesc,
2959
+ discordProjectNotification: discordProjectNotificationDesc,
2960
+ discordSlashCommand: discordSlashCommandDesc,
2961
+ dueCard: dueCardDesc,
2962
+ file: fileDesc,
2963
+ handCard: handCardDesc,
2964
+ integration: integrationDesc,
2965
+ invoice: invoiceDesc,
2966
+ lastSeenCardUpvote: lastSeenCardUpvoteDesc,
2967
+ milestoneProgress: milestoneProgressDesc,
2968
+ milestoneProject: milestoneProjectDesc,
2969
+ milestone: milestoneDesc,
2970
+ pinnedMilestone: pinnedMilestoneDesc,
2971
+ projectOrder: projectOrderDesc,
2972
+ projectSelection: projectSelectionDesc,
2973
+ projectTag: projectTagDesc,
2974
+ projectUserSetting: projectUserSettingDesc,
2975
+ projectUser: projectUserDesc,
2976
+ project: projectDesc,
2977
+ publicProjectInfo: publicProjectInfoDesc,
2978
+ publicProjectMembership: publicProjectMembershipDesc,
2979
+ queueEntry: queueEntryDesc,
2980
+ queueSelection: queueSelectionDesc,
2981
+ release: releaseDesc,
2982
+ resolvableEntryHistory: resolvableEntryHistoryDesc,
2983
+ resolvableEntryReaction: resolvableEntryReactionDesc,
2984
+ resolvableEntry: resolvableEntryDesc,
2985
+ resolvableNotification: resolvableNotificationDesc,
2986
+ resolvableParticipantHistory: resolvableParticipantHistoryDesc,
2987
+ resolvableParticipant: resolvableParticipantDesc,
2988
+ resolvable: resolvableDesc,
2989
+ savedSearch: savedSearchDesc,
2990
+ sprintConfigProgress: sprintConfigProgressDesc,
2991
+ sprintConfig: sprintConfigDesc,
2992
+ sprintProgress: sprintProgressDesc,
2993
+ sprintProject: sprintProjectDesc,
2994
+ sprint: sprintDesc,
2995
+ stripeAccountSync: stripeAccountSyncDesc,
2996
+ timeTrackingSegment: timeTrackingSegmentDesc,
2997
+ timeTrackingSum: timeTrackingSumDesc,
2998
+ userDismissedHint: userDismissedHintDesc,
2999
+ userEmail: userEmailDesc,
3000
+ userInvitation: userInvitationDesc,
3001
+ userInviteCode: userInviteCodeDesc,
3002
+ userOnboarding: userOnboardingDesc,
3003
+ userProjectAccess: userProjectAccessDesc,
3004
+ userTag: userTagDesc,
3005
+ user: userDesc,
3006
+ userReportEmail: userReportEmailDesc,
3007
+ userReportSetting: userReportSettingDesc,
3008
+ userReportToken: userReportTokenDesc,
3009
+ visionBoardQuery: visionBoardQueryDesc,
3010
+ visionBoard: visionBoardDesc,
3011
+ wizard: wizardDesc,
3012
+ workflowItemHistory: workflowItemHistoryDesc,
3013
+ workflowItem: workflowItemDesc
3014
+ };
3015
+
3016
+ //#endregion
3017
+ //#region src/query-helpers.ts
3018
+ const getRelKey = (r, k) => {
3019
+ const isPlainKey = () => {
3020
+ if (r.type === "first") return false;
3021
+ if (r.filter && Object.keys(r.filter).length > 0) return false;
3022
+ if (r.type === "query" || r.type === void 0) {
3023
+ if (r.limit || r.orderBy || r.offset) return false;
3024
+ }
3025
+ return true;
3026
+ };
3027
+ if (isPlainKey()) return k;
3028
+ const q = { ...r.filter };
3029
+ if (r.type === "first") {
3030
+ q.$first = true;
3031
+ q.$order = r.orderBy;
3032
+ }
3033
+ if (r.type === "query" || r.type === void 0) {
3034
+ if (r.limit) q.$limit = r.limit;
3035
+ if (r.offset) q.$offset = r.offset;
3036
+ if (r.orderBy) q.$order = r.orderBy;
3037
+ }
3038
+ return `${k}(${JSON.stringify(q)})`;
3039
+ };
3040
+ const serializeModel = (q, modelDesc) => {
3041
+ const list = q.fields ? [...q.fields] : [];
3042
+ if (!q.relations) return list;
3043
+ const relObj = {};
3044
+ Object.entries(q.relations).forEach(([k, _v]) => {
3045
+ const rels = Array.isArray(_v) ? _v : [_v];
3046
+ rels.forEach((r) => {
3047
+ switch (r?.type) {
3048
+ case "count": {
3049
+ list.push(`count(${getRelKey(r, k)})`);
3050
+ break;
3051
+ }
3052
+ case "exists": {
3053
+ list.push(`exists(${getRelKey(r, k)})`);
3054
+ break;
3055
+ }
3056
+ default:
3057
+ relObj[getRelKey(r, k)] = serializeModel(r, modelDesc);
3058
+ break;
3059
+ }
3060
+ });
3061
+ });
3062
+ if (Object.keys(relObj).length) list.push(relObj);
3063
+ return list;
3064
+ };
3065
+ const serializeRelations = (q, modelDesc) => {
3066
+ return Object.fromEntries(Object.entries(q).map(([k, v]) => [k, serializeModel(v, modelDesc.relations[k])]));
3067
+ };
3068
+ const serializeRootQuery = (q) => {
3069
+ return { _root: serializeRelations(q, _rootDesc) };
3070
+ };
3071
+ const serializeInstanceQuery = (q, instances, modelMap$1) => {
3072
+ return Object.fromEntries(instances.map((instance) => {
3073
+ const name = instance["~model"];
3074
+ return [`${name}(${instance["~key"]})`, serializeModel(q, modelMap$1[name])];
3075
+ }));
3076
+ };
3077
+
3078
+ //#endregion
3079
+ //#region src/reconcile-query.ts
3080
+ const reconcileRootQuery = (query, response, pool) => {
3081
+ const result = {};
3082
+ const responsePart = response._root;
3083
+ for (const [relName, modelFields] of Object.entries(query)) {
3084
+ const relDesc = _rootDesc.relations[relName];
3085
+ const id$1 = responsePart[relName];
3086
+ if (!id$1) {
3087
+ result[relName] = null;
3088
+ continue;
3089
+ } else result[relName] = reconcileInstanceQuery(modelFields, response, modelMap[relDesc.relName], `${id$1}`, pool);
3090
+ }
3091
+ return result;
3092
+ };
3093
+ const reconcileInstanceQuery = (query, response, instanceModel, key, pool) => {
3094
+ const instance = pool.get(instanceModel.name, key);
3095
+ if (!instance) {
3096
+ console.warn(`no instance found in pool: [${instanceModel.name}, ${key}]`);
3097
+ return null;
3098
+ }
3099
+ const result = {
3100
+ "~model": instanceModel.name,
3101
+ "~key": key
3102
+ };
3103
+ instanceModel.keys.map((k) => result[k] = instance[k]);
3104
+ for (const field of query.fields || []) result[field] = instance[field];
3105
+ for (const [relName, _relEntries] of Object.entries(query.relations || {})) {
3106
+ const relEntryList = Array.isArray(_relEntries) ? _relEntries : [_relEntries];
3107
+ for (const relEntry of relEntryList) {
3108
+ const relDesc = instanceModel.relations[relName];
3109
+ if (!relDesc) throw new Error(`Can't find relation ${relName} in ${instanceModel.name}`);
3110
+ const opts = relDesc.options;
3111
+ const relModel = modelMap[relDesc.relName];
3112
+ switch (opts.type) {
3113
+ case "belongsTo":
3114
+ result[opts.fk] = instance[relName];
3115
+ result[relName] = opts.fk ? reconcileInstanceQuery(relEntry, response, relModel, `${instance[relName]}`, pool) : null;
3116
+ break;
3117
+ case "hasOne":
3118
+ result[`~${relName}`] = instance[relName];
3119
+ result[relName] = reconcileInstanceQuery(relEntry, response, relModel, `${instance[relName]}`, pool);
3120
+ break;
3121
+ case "hasMany":
3122
+ const asName = relEntry.as ?? relName;
3123
+ const relKey = getRelKey(relEntry, relName);
3124
+ const val = instance[relKey];
3125
+ switch (relEntry.type) {
3126
+ case "count": {
3127
+ result[asName] = instance[`count(${relKey})`];
3128
+ break;
3129
+ }
3130
+ case "exists": {
3131
+ result[asName] = instance[`exists(${relKey})`];
3132
+ break;
3133
+ }
3134
+ case "first":
3135
+ result[`~${asName}`] = val;
3136
+ result[asName] = reconcileInstanceQuery(relEntry, response, relModel, `${val}`, pool);
3137
+ break;
3138
+ default: {
3139
+ result[`~${asName}`] = val;
3140
+ result[asName] = val.map((id$1) => reconcileInstanceQuery(relEntry, response, relModel, `${id$1}`, pool));
3141
+ }
3142
+ }
3143
+ break;
3144
+ }
3145
+ }
3146
+ }
3147
+ return result;
3148
+ };
3149
+
3150
+ //#endregion
3151
+ //#region src/index.ts
3152
+ const buildFetchers = (opts = {}) => {
3153
+ const fetchImpl = opts.fetch || globalThis.fetch;
3154
+ const configuredFetch = async (url, init = {}) => {
3155
+ const headers = new Headers(init.headers);
3156
+ if (opts.accessToken) headers.set("X-Auth-Token", opts.accessToken);
3157
+ if (opts.subdomain) headers.set("X-Account", opts.subdomain);
3158
+ if (opts.headers) Object.entries(opts.headers).forEach(([key, value]) => {
3159
+ headers.set(key, value);
3160
+ });
3161
+ const fullUrl = opts.baseUrl ? `${opts.baseUrl}${url}` : url;
3162
+ return fetchImpl(fullUrl, {
3163
+ ...init,
3164
+ headers
3165
+ });
3166
+ };
3167
+ const fetchWithQuery = async (query) => {
3168
+ const response = await configuredFetch("", {
3169
+ method: "POST",
3170
+ body: JSON.stringify({ query: JSON.stringify(query) })
3171
+ }).then(async (r) => {
3172
+ const content = await r.json();
3173
+ if (r.status !== 200) throw new Error(`[${r.status}] ${JSON.stringify(content)}`);
3174
+ return content;
3175
+ });
3176
+ return response;
3177
+ };
3178
+ const _fetchSingleInstance = async (instance, q) => {
3179
+ const response = await fetchWithQuery(serializeInstanceQuery(q, [instance], modelMap));
3180
+ const pool = new ModelPool(modelMap);
3181
+ pool.add(response);
3182
+ return reconcileInstanceQuery(q, response, modelMap[instance["~model"]], instance["~key"], pool);
3183
+ };
3184
+ return {
3185
+ fetchFromRoot: async (q) => {
3186
+ const response = await fetchWithQuery(serializeRootQuery(q));
3187
+ const pool = new ModelPool(modelMap);
3188
+ pool.add(response);
3189
+ return reconcileRootQuery(q, response, pool);
3190
+ },
3191
+ fetchFromInstance: _fetchSingleInstance,
3192
+ fetchInstance: async (key, id$1, q) => {
3193
+ const instance = {
3194
+ "~model": key,
3195
+ "~key": id$1
3196
+ };
3197
+ return _fetchSingleInstance(instance, q);
3198
+ },
3199
+ fetchInstances: async (key, ids, q) => {
3200
+ const modelDesc = modelMap[key];
3201
+ const instances = ids.map((id$1) => ({
3202
+ "~model": key,
3203
+ "~key": id$1
3204
+ }));
3205
+ const response = await fetchWithQuery(serializeInstanceQuery(q, instances, modelMap));
3206
+ const pool = new ModelPool(modelMap);
3207
+ pool.add(response);
3208
+ return Object.fromEntries(ids.map((id$1) => [id$1, reconcileInstanceQuery(q, response, modelDesc, id$1, pool)]));
3209
+ }
3210
+ };
3211
+ };
3212
+
3213
+ //#endregion
3214
+ export { buildFetchers };