@aneuhold/core-ts-db-lib 3.0.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/lib/browser.d.ts +19 -16
  3. package/lib/browser.d.ts.map +1 -1
  4. package/lib/browser.js +10 -12
  5. package/lib/browser.js.map +1 -1
  6. package/lib/browser.ts +46 -36
  7. package/lib/documents/BaseDocument.d.ts +22 -9
  8. package/lib/documents/BaseDocument.d.ts.map +1 -1
  9. package/lib/documents/BaseDocument.js +16 -7
  10. package/lib/documents/BaseDocument.js.map +1 -1
  11. package/lib/documents/BaseDocument.ts +27 -7
  12. package/lib/documents/common/ApiKey.d.ts +8 -25
  13. package/lib/documents/common/ApiKey.d.ts.map +1 -1
  14. package/lib/documents/common/ApiKey.js +7 -36
  15. package/lib/documents/common/ApiKey.js.map +1 -1
  16. package/lib/documents/common/ApiKey.ts +11 -41
  17. package/lib/documents/common/User.d.ts +25 -31
  18. package/lib/documents/common/User.d.ts.map +1 -1
  19. package/lib/documents/common/User.js +22 -39
  20. package/lib/documents/common/User.js.map +1 -1
  21. package/lib/documents/common/User.ts +29 -53
  22. package/lib/documents/dashboard/NonogramKatanaItem.d.ts +18 -27
  23. package/lib/documents/dashboard/NonogramKatanaItem.d.ts.map +1 -1
  24. package/lib/documents/dashboard/NonogramKatanaItem.js +17 -31
  25. package/lib/documents/dashboard/NonogramKatanaItem.js.map +1 -1
  26. package/lib/documents/dashboard/NonogramKatanaItem.ts +21 -45
  27. package/lib/documents/dashboard/NonogramKatanaUpgrade.d.ts +16 -41
  28. package/lib/documents/dashboard/NonogramKatanaUpgrade.d.ts.map +1 -1
  29. package/lib/documents/dashboard/NonogramKatanaUpgrade.js +17 -43
  30. package/lib/documents/dashboard/NonogramKatanaUpgrade.js.map +1 -1
  31. package/lib/documents/dashboard/NonogramKatanaUpgrade.ts +21 -55
  32. package/lib/documents/dashboard/Task.d.ts +73 -97
  33. package/lib/documents/dashboard/Task.d.ts.map +1 -1
  34. package/lib/documents/dashboard/Task.js +38 -80
  35. package/lib/documents/dashboard/Task.js.map +1 -1
  36. package/lib/documents/dashboard/Task.ts +71 -111
  37. package/lib/documents/dashboard/UserConfig.d.ts +49 -69
  38. package/lib/documents/dashboard/UserConfig.d.ts.map +1 -1
  39. package/lib/documents/dashboard/UserConfig.js +31 -51
  40. package/lib/documents/dashboard/UserConfig.js.map +1 -1
  41. package/lib/documents/dashboard/UserConfig.ts +41 -87
  42. package/lib/embedded-types/dashboard/nonogramKatanaItem/ItemName.d.ts +5 -0
  43. package/lib/embedded-types/dashboard/nonogramKatanaItem/ItemName.d.ts.map +1 -1
  44. package/lib/embedded-types/dashboard/nonogramKatanaItem/ItemName.js +5 -0
  45. package/lib/embedded-types/dashboard/nonogramKatanaItem/ItemName.js.map +1 -1
  46. package/lib/embedded-types/dashboard/nonogramKatanaItem/ItemName.ts +7 -0
  47. package/lib/embedded-types/dashboard/nonogramKatanaUpgrade/UpgradeName.d.ts +5 -0
  48. package/lib/embedded-types/dashboard/nonogramKatanaUpgrade/UpgradeName.d.ts.map +1 -1
  49. package/lib/embedded-types/dashboard/nonogramKatanaUpgrade/UpgradeName.js +5 -0
  50. package/lib/embedded-types/dashboard/nonogramKatanaUpgrade/UpgradeName.js.map +1 -1
  51. package/lib/embedded-types/dashboard/nonogramKatanaUpgrade/UpgradeName.ts +7 -0
  52. package/lib/embedded-types/dashboard/task/FilterSettings.d.ts +69 -41
  53. package/lib/embedded-types/dashboard/task/FilterSettings.d.ts.map +1 -1
  54. package/lib/embedded-types/dashboard/task/FilterSettings.js +29 -36
  55. package/lib/embedded-types/dashboard/task/FilterSettings.js.map +1 -1
  56. package/lib/embedded-types/dashboard/task/FilterSettings.ts +51 -74
  57. package/lib/embedded-types/dashboard/task/RecurrenceInfo.d.ts +74 -52
  58. package/lib/embedded-types/dashboard/task/RecurrenceInfo.d.ts.map +1 -1
  59. package/lib/embedded-types/dashboard/task/RecurrenceInfo.js +66 -28
  60. package/lib/embedded-types/dashboard/task/RecurrenceInfo.js.map +1 -1
  61. package/lib/embedded-types/dashboard/task/RecurrenceInfo.ts +83 -77
  62. package/lib/embedded-types/dashboard/task/SortSettings.d.ts +61 -42
  63. package/lib/embedded-types/dashboard/task/SortSettings.d.ts.map +1 -1
  64. package/lib/embedded-types/dashboard/task/SortSettings.js +34 -31
  65. package/lib/embedded-types/dashboard/task/SortSettings.js.map +1 -1
  66. package/lib/embedded-types/dashboard/task/SortSettings.ts +66 -61
  67. package/lib/embedded-types/dashboard/userConfig/Tags.d.ts +18 -11
  68. package/lib/embedded-types/dashboard/userConfig/Tags.d.ts.map +1 -1
  69. package/lib/embedded-types/dashboard/userConfig/Tags.js +15 -1
  70. package/lib/embedded-types/dashboard/userConfig/Tags.js.map +1 -1
  71. package/lib/embedded-types/dashboard/userConfig/Tags.ts +21 -9
  72. package/lib/schemas/required-refs/RequiredUserId.d.ts +9 -5
  73. package/lib/schemas/required-refs/RequiredUserId.d.ts.map +1 -1
  74. package/lib/schemas/required-refs/RequiredUserId.js +9 -4
  75. package/lib/schemas/required-refs/RequiredUserId.js.map +1 -1
  76. package/lib/schemas/required-refs/RequiredUserId.ts +13 -4
  77. package/lib/services/DocumentService.d.ts +1 -1
  78. package/lib/services/DocumentService.d.ts.map +1 -1
  79. package/lib/services/DocumentService.js +0 -1
  80. package/lib/services/DocumentService.js.map +1 -1
  81. package/lib/services/DocumentService.ts +1 -1
  82. package/lib/services/dashboard/Task/TaskRecurrenceService.d.ts +4 -4
  83. package/lib/services/dashboard/Task/TaskRecurrenceService.d.ts.map +1 -1
  84. package/lib/services/dashboard/Task/TaskRecurrenceService.js +3 -4
  85. package/lib/services/dashboard/Task/TaskRecurrenceService.js.map +1 -1
  86. package/lib/services/dashboard/Task/TaskRecurrenceService.ts +8 -5
  87. package/lib/services/dashboard/Task/TaskService.d.ts +1 -2
  88. package/lib/services/dashboard/Task/TaskService.d.ts.map +1 -1
  89. package/lib/services/dashboard/Task/TaskService.js +0 -1
  90. package/lib/services/dashboard/Task/TaskService.js.map +1 -1
  91. package/lib/services/dashboard/Task/TaskService.ts +1 -2
  92. package/lib/services/dashboard/Task/TaskSortService.d.ts.map +1 -1
  93. package/lib/services/dashboard/Task/TaskSortService.js +0 -1
  94. package/lib/services/dashboard/Task/TaskSortService.js.map +1 -1
  95. package/lib/services/dashboard/Task/TaskSortService.ts +1 -2
  96. package/package.json +10 -10
  97. package/lib/documents/BaseDocumentWithType.d.ts +0 -8
  98. package/lib/documents/BaseDocumentWithType.d.ts.map +0 -1
  99. package/lib/documents/BaseDocumentWithType.js +0 -7
  100. package/lib/documents/BaseDocumentWithType.js.map +0 -1
  101. package/lib/documents/BaseDocumentWithType.ts +0 -8
  102. package/lib/schemas/type-guards/commonTypeGuards.d.ts +0 -36
  103. package/lib/schemas/type-guards/commonTypeGuards.d.ts.map +0 -1
  104. package/lib/schemas/type-guards/commonTypeGuards.js +0 -46
  105. package/lib/schemas/type-guards/commonTypeGuards.js.map +0 -1
  106. package/lib/schemas/type-guards/commonTypeGuards.ts +0 -49
  107. package/lib/schemas/validators/DocumentValidator.d.ts +0 -9
  108. package/lib/schemas/validators/DocumentValidator.d.ts.map +0 -1
  109. package/lib/schemas/validators/DocumentValidator.js +0 -2
  110. package/lib/schemas/validators/DocumentValidator.js.map +0 -1
  111. package/lib/schemas/validators/DocumentValidator.ts +0 -9
  112. package/lib/schemas/validators/ValidateUtil.d.ts +0 -122
  113. package/lib/schemas/validators/ValidateUtil.d.ts.map +0 -1
  114. package/lib/schemas/validators/ValidateUtil.js +0 -216
  115. package/lib/schemas/validators/ValidateUtil.js.map +0 -1
  116. package/lib/schemas/validators/ValidateUtil.ts +0 -240
@@ -1,66 +1,32 @@
1
- import type { UUID } from 'crypto';
2
- import NonogramKatanaItemName from '../../embedded-types/dashboard/nonogramKatanaItem/ItemName.js';
1
+ import { z } from 'zod';
3
2
  import NonogramKatanaUpgradeName from '../../embedded-types/dashboard/nonogramKatanaUpgrade/UpgradeName.js';
4
- import RequiredUserId from '../../schemas/required-refs/RequiredUserId.js';
5
- import type { DocumentValidator } from '../../schemas/validators/DocumentValidator.js';
6
- import BaseDocumentWithType from '../BaseDocumentWithType.js';
3
+ import { RequiredUserIdSchema } from '../../schemas/required-refs/RequiredUserId.js';
4
+ import { BaseDocumentWithTypeSchema } from '../BaseDocument.js';
7
5
 
8
6
  /**
9
- * Validates a {@link NonogramKatanaUpgrade} document.
10
- *
11
- * @param upgrade The {@link NonogramKatanaUpgrade} document to validate.
12
- * @returns An object containing the updated document and any validation errors.
7
+ * The docType value for NonogramKatanaUpgrade documents.
13
8
  */
14
- export const validateNonogramKatanaUpgrade: DocumentValidator<NonogramKatanaUpgrade> = (
15
- upgrade: NonogramKatanaUpgrade
16
- ) => {
17
- const errors: string[] = [];
18
-
19
- // No validation at the moment.
20
-
21
- return { updatedDoc: upgrade, errors };
22
- };
9
+ export const NonogramKatanaUpgrade_docType = 'nonogramKatanaUpgrade';
23
10
 
24
11
  /**
25
- * Represents an upgrade for a Nonogram Katana.
26
- *
27
- * @example
28
- * ```typescript
29
- * const upgrade = new NonogramKatanaUpgrade(ownerId, upgradeName);
30
- * upgrade.completed = true;
31
- * upgrade.priority = 5;
32
- * ```
12
+ * The schema for {@link NonogramKatanaUpgrade} documents.
33
13
  */
34
- export default class NonogramKatanaUpgrade extends BaseDocumentWithType implements RequiredUserId {
35
- static docType = 'nonogramKatanaUpgrade';
36
-
37
- docType = NonogramKatanaUpgrade.docType;
38
-
39
- /**
40
- * The owner of this Nonogram Katana upgrade.
41
- */
42
- userId: UUID;
43
-
44
- upgradeName: NonogramKatanaUpgradeName;
45
-
46
- completed: boolean = false;
47
-
48
- currentItemAmounts: { [key in NonogramKatanaItemName]?: number } = {};
49
-
14
+ export const NonogramKatanaUpgradeSchema = z.object({
15
+ ...BaseDocumentWithTypeSchema.shape,
16
+ ...RequiredUserIdSchema.shape,
17
+ docType: z.literal(NonogramKatanaUpgrade_docType).default(NonogramKatanaUpgrade_docType),
18
+ upgradeName: z.enum(NonogramKatanaUpgradeName),
19
+ completed: z.boolean().default(false),
20
+ currentItemAmounts: z
21
+ .partialRecord(z.enum(NonogramKatanaUpgradeName), z.int().nullish())
22
+ .default({}),
50
23
  /**
51
24
  * Priority, where the higher the number, the higher up the list it is.
52
25
  */
53
- priority: number = 0;
26
+ priority: z.int().default(0)
27
+ });
54
28
 
55
- /**
56
- * Creates an instance of NonogramKatanaUpgrade.
57
- *
58
- * @param ownerId - The ID of the owner of this upgrade.
59
- * @param upgradeName - The name of the upgrade.
60
- */
61
- constructor(ownerId: UUID, upgradeName: NonogramKatanaUpgradeName) {
62
- super();
63
- this.userId = ownerId;
64
- this.upgradeName = upgradeName;
65
- }
66
- }
29
+ /**
30
+ * Represents an upgrade for a Nonogram Katana.
31
+ */
32
+ export type NonogramKatanaUpgrade = z.infer<typeof NonogramKatanaUpgradeSchema>;
@@ -1,18 +1,77 @@
1
- import type { UUID } from 'crypto';
2
- import type { DashboardTaskFilterSettings } from '../../embedded-types/dashboard/task/FilterSettings.js';
3
- import type { ParentRecurringTaskInfo, RecurrenceInfo } from '../../embedded-types/dashboard/task/RecurrenceInfo.js';
4
- import type { DashboardTaskSortSettings } from '../../embedded-types/dashboard/task/SortSettings.js';
5
- import RequiredUserId from '../../schemas/required-refs/RequiredUserId.js';
6
- import type { DocumentValidator } from '../../schemas/validators/DocumentValidator.js';
7
- import { type DocumentMap } from '../../services/DocumentService.js';
8
- import BaseDocumentWithType from '../BaseDocumentWithType.js';
1
+ import { z } from 'zod';
2
+ import type { DocumentMap } from '../../services/DocumentService.js';
9
3
  /**
10
- * Validates a {@link DashboardTask} object.
11
- *
12
- * @param task - The {@link DashboardTask} object to validate.
13
- * @returns An object containing the updated document and any validation errors.
4
+ * The docType value for DashboardTask documents.
5
+ */
6
+ export declare const DashboardTask_docType = "task";
7
+ /**
8
+ * The schema for {@link DashboardTask} documents.
14
9
  */
15
- export declare const validateDashboardTask: DocumentValidator<DashboardTask>;
10
+ export declare const DashboardTaskSchema: z.ZodObject<{
11
+ docType: z.ZodDefault<z.ZodLiteral<"task">>;
12
+ sharedWith: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>>>;
13
+ assignedTo: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>>>;
14
+ recurrenceInfo: z.ZodOptional<z.ZodNullable<z.ZodObject<{
15
+ frequency: z.ZodObject<{
16
+ type: z.ZodEnum<typeof import("../../embedded-types/dashboard/task/RecurrenceInfo.js").RecurrenceFrequencyType>;
17
+ everyXTimeUnit: z.ZodOptional<z.ZodNullable<z.ZodObject<{
18
+ timeUnit: z.ZodEnum<{
19
+ day: "day";
20
+ week: "week";
21
+ month: "month";
22
+ year: "year";
23
+ }>;
24
+ x: z.ZodInt;
25
+ }, z.core.$strip>>>;
26
+ weekDaySet: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodInt>>>;
27
+ everyXWeekdayOfMonth: z.ZodOptional<z.ZodNullable<z.ZodObject<{
28
+ weekDay: z.ZodInt;
29
+ weekOfMonth: z.ZodUnion<readonly [z.ZodInt, z.ZodLiteral<"last">]>;
30
+ }, z.core.$strip>>>;
31
+ }, z.core.$strip>;
32
+ recurrenceBasis: z.ZodEnum<typeof import("../../embedded-types/dashboard/task/RecurrenceInfo.js").RecurrenceBasis>;
33
+ recurrenceEffect: z.ZodEnum<typeof import("../../embedded-types/dashboard/task/RecurrenceInfo.js").RecurrenceEffect>;
34
+ }, z.core.$strip>>>;
35
+ parentRecurringTaskInfo: z.ZodOptional<z.ZodNullable<z.ZodObject<{
36
+ taskId: z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>;
37
+ startDate: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
38
+ dueDate: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
39
+ }, z.core.$strip>>>;
40
+ title: z.ZodDefault<z.ZodString>;
41
+ completed: z.ZodDefault<z.ZodBoolean>;
42
+ parentTaskId: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>>>;
43
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
44
+ createdDate: z.ZodDefault<z.ZodDate>;
45
+ lastUpdatedDate: z.ZodDefault<z.ZodDate>;
46
+ startDate: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
47
+ dueDate: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
48
+ tags: z.ZodDefault<z.ZodRecord<z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>, z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>>>;
49
+ category: z.ZodDefault<z.ZodString>;
50
+ filterSettings: z.ZodDefault<z.ZodRecord<z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>, z.ZodObject<{
51
+ userId: z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>;
52
+ completed: z.ZodObject<{
53
+ show: z.ZodBoolean;
54
+ }, z.core.$strip>;
55
+ grandChildrenTasks: z.ZodObject<{
56
+ show: z.ZodBoolean;
57
+ }, z.core.$strip>;
58
+ startDate: z.ZodObject<{
59
+ showFutureTasks: z.ZodBoolean;
60
+ }, z.core.$strip>;
61
+ tags: z.ZodRecord<z.ZodString, z.ZodObject<{
62
+ show: z.ZodBoolean;
63
+ }, z.core.$strip>>;
64
+ }, z.core.$strip>>>;
65
+ sortSettings: z.ZodDefault<z.ZodRecord<z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>, z.ZodObject<{
66
+ userId: z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>;
67
+ sortList: z.ZodArray<z.ZodObject<{
68
+ sortBy: z.ZodEnum<typeof import("../../embedded-types/dashboard/task/SortSettings.js").DashboardTaskSortBy>;
69
+ sortDirection: z.ZodEnum<typeof import("../../embedded-types/dashboard/task/SortSettings.js").DashboardTaskSortDirection>;
70
+ }, z.core.$strip>>;
71
+ }, z.core.$strip>>>;
72
+ _id: z.ZodPipe<z.ZodDefault<z.ZodUUID>, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>;
73
+ userId: z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>;
74
+ }, z.core.$strip>;
16
75
  /**
17
76
  * A utility type for a map of tasks.
18
77
  */
@@ -38,88 +97,5 @@ export type DashboardTaskMap = DocumentMap<DashboardTask>;
38
97
  * - The user sets a task as recurring with a frequency? Only that task is marked, because when the recurrence comes up, the frontend will update that task and all sub tasks.
39
98
  * - The date + time for the recurrence happens? If the users browser is open, the frontend will trigger the update ideally. This needs to be checked if this can be done in a performant way.
40
99
  */
41
- export default class DashboardTask extends BaseDocumentWithType implements RequiredUserId {
42
- static docType: string;
43
- docType: string;
44
- /**
45
- * The owner of this task.
46
- */
47
- userId: UUID;
48
- /**
49
- * What happens when:
50
- *
51
- * - A task is shared that has sub tasks? All the subtasks are shared as well from the frontend. This in case the frontend fails to make a connection to the backend, the state will still be correct.
52
- * - A subtask of a shared task is deleted? It is deleted like normal
53
- * - A user that has been shared a task adds a subtask? The subtask gets the same owner as the parent shared task.
54
- * - A shared task with subtasks is unshared? The frontend will need to make the updates and send them to the backend.
55
- * - A user removes a collaborator and they have shared tasks with that
56
- * collaborator? Nothing happens to the tasks. That way, if they add the
57
- * collaborator back it will return to normal. But the frontend needs to
58
- * double check for this when displaying things.
59
- */
60
- sharedWith: UUID[];
61
- /**
62
- * The user ID that this task is assigned to.
63
- */
64
- assignedTo?: UUID;
65
- /**
66
- * The recurrence info for this task if there is any.
67
- */
68
- recurrenceInfo?: RecurrenceInfo;
69
- /**
70
- * The recurring task info for the parent recurring task if there is one.
71
- *
72
- * If this is set, then the current tasks's recurrence info should be the
73
- * same as the parent recurring task.
74
- */
75
- parentRecurringTaskInfo?: ParentRecurringTaskInfo;
76
- /**
77
- * The title of the task.
78
- */
79
- title: string;
80
- completed: boolean;
81
- /**
82
- * The ID of the parent task if there is one.
83
- */
84
- parentTaskId?: UUID;
85
- /**
86
- * The description of the task. This is purposefully optional in case the
87
- * user wants to just use the title. This also helps the frontend
88
- * differentiate between a task that has no description and a task that has
89
- * an empty description.
90
- */
91
- description?: string;
92
- /**
93
- * The date this task was created.
94
- */
95
- createdDate: Date;
96
- /**
97
- * The date this task was last updated.
98
- */
99
- lastUpdatedDate: Date;
100
- startDate?: Date;
101
- dueDate?: Date;
102
- /**
103
- * User-assigned tags for this task.
104
- */
105
- tags: {
106
- [userId: UUID]: string[] | undefined;
107
- };
108
- /**
109
- * System-assigned category for this task. This should be used to determine
110
- * where this task should be displayed.
111
- */
112
- category: string;
113
- /**
114
- * The filter settings for subtasks of this task specifically, keyed on
115
- * each user.
116
- */
117
- filterSettings: DashboardTaskFilterSettings;
118
- /**
119
- * The sort settings for subtasks of this task specifically, keyed on
120
- * each user.
121
- */
122
- sortSettings: DashboardTaskSortSettings;
123
- constructor(ownerId: UUID);
124
- }
100
+ export type DashboardTask = z.infer<typeof DashboardTaskSchema>;
125
101
  //# sourceMappingURL=Task.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/documents/dashboard/Task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uDAAuD,CAAC;AACzG,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACf,MAAM,uDAAuD,CAAC;AAE/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAA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AAM,CAAa;IAE7B;;;OAGG;IACH,cAAc,EAAE,2BAA2B,CAAM;IAEjD;;;OAGG;IACH,YAAY,EAAE,yBAAyB,CAAM;gBAEjC,OAAO,EAAE,IAAI;CAO1B"}
1
+ {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/documents/dashboard/Task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAGrE;;GAEG;AACH,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwF9B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -1,63 +1,20 @@
1
- import { validateRecurrenceInfo } from '../../embedded-types/dashboard/task/RecurrenceInfo.js';
2
- import RequiredUserId from '../../schemas/required-refs/RequiredUserId.js';
3
- import Validate from '../../schemas/validators/ValidateUtil.js';
4
- import DocumentService, {} from '../../services/DocumentService.js';
5
- import BaseDocumentWithType from '../BaseDocumentWithType.js';
1
+ import { z } from 'zod';
2
+ import { DashboardTaskFilterSettingsSchema } from '../../embedded-types/dashboard/task/FilterSettings.js';
3
+ import { ParentRecurringTaskInfoSchema, RecurrenceInfoSchema } from '../../embedded-types/dashboard/task/RecurrenceInfo.js';
4
+ import { DashboardTaskSortSettingsSchema } from '../../embedded-types/dashboard/task/SortSettings.js';
5
+ import { RequiredUserIdSchema } from '../../schemas/required-refs/RequiredUserId.js';
6
+ import { BaseDocumentWithTypeSchema } from '../BaseDocument.js';
6
7
  /**
7
- * Validates a {@link DashboardTask} object.
8
- *
9
- * @param task - The {@link DashboardTask} object to validate.
10
- * @returns An object containing the updated document and any validation errors.
8
+ * The docType value for DashboardTask documents.
11
9
  */
12
- export const validateDashboardTask = (task) => {
13
- const errors = [];
14
- const validate = new Validate(task, errors);
15
- const exampleTask = new DashboardTask(DocumentService.generateID());
16
- validate.string('title', exampleTask.title);
17
- validate.boolean('completed', exampleTask.completed);
18
- validate.optionalString('description');
19
- validate.array('sharedWith', exampleTask.sharedWith);
20
- validate.optionalObject('recurrenceInfo');
21
- validate.object('tags', {});
22
- validate.string('category', exampleTask.category);
23
- validate.object('createdDate', exampleTask.createdDate);
24
- validate.object('lastUpdatedDate', exampleTask.lastUpdatedDate);
25
- validate.optionalObject('startDate');
26
- validate.optionalObject('dueDate');
27
- validate.optionalObject('parentRecurringTaskInfo');
28
- validate.object('filterSettings', {});
29
- validate.object('sortSettings', {});
30
- validateRecurrenceInfo(task, errors);
31
- return { updatedDoc: task, errors };
32
- };
10
+ export const DashboardTask_docType = 'task';
33
11
  /**
34
- * When thinking about the logic of tasks, the following thoughts come to mind:
35
- *
36
- * What would you expect a task manager to do in the case that you have a task
37
- * with a bunch of subtasks, and you share that single task with another person?
38
- *
39
- * - Should the subtasks be automatically shared as well no matter what? (Would make behavior simpler for the user)
40
- * - Should there instead be an option to share the subtasks automatically?
41
- * - In the case that the other user adds a subtask to the original task you shared, would you expect to see that subtask?
42
- * - If there is an option to not share the subtasks automatically, what happens when the other user adds a subtask to the one you shared?
43
- *
44
- * Because of the complexity for the user in not automatically sharing subtasks,
45
- * it seems better to always automatically share subtasks. In a theoretical sense,
46
- * sharing a task with someone seems to imply the shared ownership of completing
47
- * the overall task, including all the subtasks.
48
- *
49
- * Recurring Tasks:
50
- *
51
- * - The user sets a task as recurring with a frequency? Only that task is marked, because when the recurrence comes up, the frontend will update that task and all sub tasks.
52
- * - The date + time for the recurrence happens? If the users browser is open, the frontend will trigger the update ideally. This needs to be checked if this can be done in a performant way.
12
+ * The schema for {@link DashboardTask} documents.
53
13
  */
54
- export default class DashboardTask extends BaseDocumentWithType {
55
- static docType = 'task';
56
- docType = DashboardTask.docType;
57
- /**
58
- * The owner of this task.
59
- */
60
- userId;
14
+ export const DashboardTaskSchema = z.object({
15
+ ...BaseDocumentWithTypeSchema.shape,
16
+ ...RequiredUserIdSchema.shape,
17
+ docType: z.literal(DashboardTask_docType).default(DashboardTask_docType),
61
18
  /**
62
19
  * What happens when:
63
20
  *
@@ -70,73 +27,74 @@ export default class DashboardTask extends BaseDocumentWithType {
70
27
  * collaborator back it will return to normal. But the frontend needs to
71
28
  * double check for this when displaying things.
72
29
  */
73
- sharedWith = [];
30
+ sharedWith: z.array(z.uuidv7().transform((val) => val)).default([]),
74
31
  /**
75
32
  * The user ID that this task is assigned to.
76
33
  */
77
- assignedTo;
34
+ assignedTo: z
35
+ .uuidv7()
36
+ .transform((val) => val)
37
+ .nullish(),
78
38
  /**
79
39
  * The recurrence info for this task if there is any.
80
40
  */
81
- recurrenceInfo;
41
+ recurrenceInfo: RecurrenceInfoSchema.nullish(),
82
42
  /**
83
43
  * The recurring task info for the parent recurring task if there is one.
84
44
  *
85
45
  * If this is set, then the current tasks's recurrence info should be the
86
46
  * same as the parent recurring task.
87
47
  */
88
- parentRecurringTaskInfo;
48
+ parentRecurringTaskInfo: ParentRecurringTaskInfoSchema.nullish(),
89
49
  /**
90
50
  * The title of the task.
91
51
  */
92
- title = '';
93
- completed = false;
52
+ title: z.string().default(''),
53
+ completed: z.boolean().default(false),
94
54
  /**
95
55
  * The ID of the parent task if there is one.
96
56
  */
97
- parentTaskId;
57
+ parentTaskId: z
58
+ .uuidv7()
59
+ .transform((val) => val)
60
+ .nullish(),
98
61
  /**
99
62
  * The description of the task. This is purposefully optional in case the
100
63
  * user wants to just use the title. This also helps the frontend
101
64
  * differentiate between a task that has no description and a task that has
102
65
  * an empty description.
103
66
  */
104
- description;
67
+ description: z.string().nullish(),
105
68
  /**
106
69
  * The date this task was created.
107
70
  */
108
- createdDate = new Date();
71
+ createdDate: z.date().default(() => new Date()),
109
72
  /**
110
73
  * The date this task was last updated.
111
74
  */
112
- lastUpdatedDate = new Date();
113
- startDate;
114
- dueDate;
75
+ lastUpdatedDate: z.date().default(() => new Date()),
76
+ startDate: z.date().nullish(),
77
+ dueDate: z.date().nullish(),
115
78
  /**
116
79
  * User-assigned tags for this task.
117
80
  */
118
- tags = {};
81
+ tags: z
82
+ .record(z.uuidv7().transform((id) => id), z.array(z.string()).nullish())
83
+ .default({}),
119
84
  /**
120
85
  * System-assigned category for this task. This should be used to determine
121
86
  * where this task should be displayed.
122
87
  */
123
- category = 'default';
88
+ category: z.string().default('default'),
124
89
  /**
125
90
  * The filter settings for subtasks of this task specifically, keyed on
126
91
  * each user.
127
92
  */
128
- filterSettings = {};
93
+ filterSettings: DashboardTaskFilterSettingsSchema.default({}),
129
94
  /**
130
95
  * The sort settings for subtasks of this task specifically, keyed on
131
96
  * each user.
132
97
  */
133
- sortSettings = {};
134
- constructor(ownerId) {
135
- super();
136
- this.userId = ownerId;
137
- this.tags = {
138
- [ownerId]: []
139
- };
140
- }
141
- }
98
+ sortSettings: DashboardTaskSortSettingsSchema.default({})
99
+ });
142
100
  //# sourceMappingURL=Task.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Task.js","sourceRoot":"","sources":["../../../src/documents/dashboard/Task.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AAE/F,OAAO,cAAc,MAAM,+CAA+C,CAAC;AAE3E,OAAO,QAAQ,MAAM,0CAA0C,CAAC;AAChE,OAAO,eAAe,EAAE,EAAoB,MAAM,mCAAmC,CAAC;AACtF,OAAO,oBAAoB,MAAM,4BAA4B,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqC,CAAC,IAAmB,EAAE,EAAE;IAC7F,MAAM,MAAM,GAAa,EAAE,CAAC;IAC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