@aneuhold/core-ts-db-lib 3.0.2 → 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 +34 -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,94 +1,71 @@
1
1
  import type { UUID } from 'crypto';
2
- import DashboardUserConfig from '../../../documents/dashboard/UserConfig.js';
3
- import Validate from '../../../schemas/validators/ValidateUtil.js';
2
+ import { z } from 'zod';
4
3
 
5
4
  /**
6
- * Returns the default filter settings for a task list for a given user.
7
- *
8
- * @param userId - The ID of the user.
9
- * @returns The default filter settings for the user's task list.
5
+ * Zod schema for {@link StandardFilterSetting}.
6
+ */
7
+ export const StandardFilterSettingSchema = z.object({
8
+ show: z.boolean()
9
+ });
10
+
11
+ /**
12
+ * Represents a standard filter setting.
13
+ */
14
+ export type StandardFilterSetting = z.infer<typeof StandardFilterSettingSchema>;
15
+
16
+ /**
17
+ * Zod schema for {@link DashboardTaskListFilterSettings}.
10
18
  */
11
- export function getDefaultTaskListFilterSettings(userId: UUID): DashboardTaskListFilterSettings {
12
- return {
13
- userId,
14
- completed: { show: true },
15
- grandChildrenTasks: { show: false },
16
- startDate: { showFutureTasks: true },
17
- tags: {}
18
- };
19
- }
19
+ export const DashboardTaskListFilterSettingsSchema = z.object({
20
+ /**
21
+ * The ID of the user.
22
+ */
23
+ userId: z.uuidv7().transform((val) => val as UUID),
24
+ completed: StandardFilterSettingSchema,
25
+ grandChildrenTasks: StandardFilterSettingSchema,
26
+ startDate: z.object({
27
+ showFutureTasks: z.boolean()
28
+ }),
29
+ /**
30
+ * The default for tags, if not defined, is to show them.
31
+ */
32
+ tags: z.record(z.string(), StandardFilterSettingSchema)
33
+ });
20
34
 
21
35
  /**
22
- * Validates the filter settings in the user configuration.
36
+ * The filter settings for a list of tasks for a particular user.
23
37
  *
24
- * @param validate - The validation utility.
25
- * @param config - The user configuration containing the filter settings.
38
+ * Any new settings should be made optional so that they can be added
39
+ * without breaking existing users or tasks.
26
40
  */
27
- export function validateFilterSettings(validate: Validate, config: DashboardUserConfig) {
28
- validate.object('taskListFilterSettings', {});
29
- const categories = Object.keys(config.taskListFilterSettings);
30
- if (categories.length > 0) {
31
- const defaultSettings = getDefaultTaskListFilterSettings(config.userId);
32
- categories.forEach((category) => {
33
- validate.string(`taskListFilterSettings.${category}.userId`, defaultSettings.userId);
34
- validate.object(`taskListFilterSettings.${category}.completed`, defaultSettings.completed);
35
- validate.boolean(
36
- `taskListFilterSettings.${category}.completed.show`,
37
- defaultSettings.completed.show
38
- );
39
- validate.object(
40
- `taskListFilterSettings.${category}.grandChildrenTasks`,
41
- defaultSettings.grandChildrenTasks
42
- );
43
- validate.boolean(
44
- `taskListFilterSettings.${category}.grandChildrenTasks.show`,
45
- defaultSettings.grandChildrenTasks.show
46
- );
47
- validate.object(`taskListFilterSettings.${category}.startDate`, defaultSettings.startDate);
48
- validate.boolean(
49
- `taskListFilterSettings.${category}.startDate.showFutureTasks`,
50
- defaultSettings.startDate.showFutureTasks
51
- );
52
- validate.object(`taskListFilterSettings.${category}.tags`, defaultSettings.tags);
53
- });
54
- }
55
- }
41
+ export type DashboardTaskListFilterSettings = z.infer<typeof DashboardTaskListFilterSettingsSchema>;
56
42
 
57
43
  /**
58
- * Global task list filter settings. These are created for each user in the
59
- * Dashboard config.
44
+ * Zod schema for {@link DashboardTaskFilterSettings}.
60
45
  */
61
- export type DashboardTaskListGlobalFilterSettings = {
62
- [category: string]: DashboardTaskListFilterSettings;
63
- };
46
+ export const DashboardTaskFilterSettingsSchema = z.record(
47
+ z.uuidv7().transform((val) => val as UUID),
48
+ DashboardTaskListFilterSettingsSchema
49
+ );
64
50
 
65
51
  /**
66
52
  * The filter settings for a particular task. Each user can have their
67
53
  * own settings for a task.
68
54
  */
69
- export type DashboardTaskFilterSettings = {
70
- [userId: UUID]: DashboardTaskListFilterSettings;
71
- };
55
+ export type DashboardTaskFilterSettings = z.infer<typeof DashboardTaskFilterSettingsSchema>;
72
56
 
73
57
  /**
74
- * The filter settings for a list of tasks for a particular user.
75
- *
76
- * Any new settings should be made optional so that they can be added
77
- * without breaking existing users or tasks.
58
+ * Zod schema for {@link DashboardTaskListGlobalFilterSettings}.
78
59
  */
79
- export type DashboardTaskListFilterSettings = {
80
- userId: UUID;
81
- completed: StandardFilterSetting;
82
- grandChildrenTasks: StandardFilterSetting;
83
- startDate: {
84
- showFutureTasks: boolean;
85
- };
86
- /**
87
- * The default for tags, if not defined, is to show them.
88
- */
89
- tags: { [tag: string]: StandardFilterSetting };
90
- };
60
+ export const DashboardTaskListGlobalFilterSettingsSchema = z.record(
61
+ z.string(),
62
+ DashboardTaskListFilterSettingsSchema
63
+ );
91
64
 
92
- export type StandardFilterSetting = {
93
- show: boolean;
94
- };
65
+ /**
66
+ * Global task list filter settings. These are created for each user in the
67
+ * Dashboard config.
68
+ */
69
+ export type DashboardTaskListGlobalFilterSettings = z.infer<
70
+ typeof DashboardTaskListGlobalFilterSettingsSchema
71
+ >;
@@ -1,50 +1,4 @@
1
- import type { UUID } from 'crypto';
2
- import DashboardTask from '../../../documents/dashboard/Task.js';
3
- /**
4
- * Validates the recurrence information of a given task.
5
- *
6
- * @param task - The dashboard task to validate.
7
- * @param errors - An array to collect validation error messages.
8
- */
9
- export declare function validateRecurrenceInfo(task: DashboardTask, errors: string[]): void;
10
- /**
11
- * Represents the recurrence information for a task.
12
- */
13
- export type RecurrenceInfo = {
14
- frequency: RecurrenceFrequency;
15
- recurrenceBasis: RecurrenceBasis;
16
- recurrenceEffect: RecurrenceEffect;
17
- };
18
- /**
19
- * Represents the frequency of recurrence for a task.
20
- */
21
- export type RecurrenceFrequency = {
22
- type: RecurrenceFrequencyType;
23
- everyXTimeUnit?: {
24
- timeUnit: 'day' | 'week' | 'month' | 'year';
25
- /**
26
- * The number of time units that should pass before the task recurs.
27
- */
28
- x: number;
29
- };
30
- /**
31
- * The set of week days that the task should recur on. This is 0-6 with 0
32
- * being Sunday.
33
- *
34
- * The idea that each of these values is unique needs to be enforced on the
35
- * frontend.
36
- */
37
- weekDaySet?: number[];
38
- everyXWeekdayOfMonth?: {
39
- weekDay: number;
40
- /**
41
- * The week of the month that the task should recur on. This is 0-4 with 0
42
- * being the first week of the month. If this is 'last', then it will
43
- * recur on the last week of the month.
44
- */
45
- weekOfMonth: number | 'last';
46
- };
47
- };
1
+ import { z } from 'zod';
48
2
  /**
49
3
  * Enum representing the different types of recurrence frequencies.
50
4
  */
@@ -54,6 +8,10 @@ export declare enum RecurrenceFrequencyType {
54
8
  everyXWeekdayOfMonth = "everyXWeekdayOfMonth",
55
9
  lastDayOfMonth = "lastDayOfMonth"
56
10
  }
11
+ /**
12
+ * Zod schema for {@link RecurrenceFrequencyType}.
13
+ */
14
+ export declare const RecurrenceFrequencyTypeSchema: z.ZodEnum<typeof RecurrenceFrequencyType>;
57
15
  /**
58
16
  * The basis of date movement for a recurring task.
59
17
  */
@@ -61,6 +19,10 @@ export declare enum RecurrenceBasis {
61
19
  startDate = "startDate",
62
20
  dueDate = "dueDate"
63
21
  }
22
+ /**
23
+ * Zod schema for {@link RecurrenceBasis}.
24
+ */
25
+ export declare const RecurrenceBasisSchema: z.ZodEnum<typeof RecurrenceBasis>;
64
26
  /**
65
27
  * The effect of recurrence for a recurring task.
66
28
  */
@@ -81,15 +43,75 @@ export declare enum RecurrenceEffect {
81
43
  */
82
44
  stack = "stack"
83
45
  }
46
+ /**
47
+ * Zod schema for {@link RecurrenceEffect}.
48
+ */
49
+ export declare const RecurrenceEffectSchema: z.ZodEnum<typeof RecurrenceEffect>;
50
+ /**
51
+ * Zod schema for {@link RecurrenceFrequency}.
52
+ */
53
+ export declare const RecurrenceFrequencySchema: z.ZodObject<{
54
+ type: z.ZodEnum<typeof RecurrenceFrequencyType>;
55
+ everyXTimeUnit: z.ZodOptional<z.ZodNullable<z.ZodObject<{
56
+ timeUnit: z.ZodEnum<{
57
+ day: "day";
58
+ week: "week";
59
+ month: "month";
60
+ year: "year";
61
+ }>;
62
+ x: z.ZodInt;
63
+ }, z.core.$strip>>>;
64
+ weekDaySet: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodInt>>>;
65
+ everyXWeekdayOfMonth: z.ZodOptional<z.ZodNullable<z.ZodObject<{
66
+ weekDay: z.ZodInt;
67
+ weekOfMonth: z.ZodUnion<readonly [z.ZodInt, z.ZodLiteral<"last">]>;
68
+ }, z.core.$strip>>>;
69
+ }, z.core.$strip>;
70
+ /**
71
+ * Represents the frequency of recurrence for a task.
72
+ */
73
+ export type RecurrenceFrequency = z.infer<typeof RecurrenceFrequencySchema>;
74
+ /**
75
+ * Zod schema for {@link RecurrenceInfo}.
76
+ */
77
+ export declare const RecurrenceInfoSchema: z.ZodObject<{
78
+ frequency: z.ZodObject<{
79
+ type: z.ZodEnum<typeof RecurrenceFrequencyType>;
80
+ everyXTimeUnit: z.ZodOptional<z.ZodNullable<z.ZodObject<{
81
+ timeUnit: z.ZodEnum<{
82
+ day: "day";
83
+ week: "week";
84
+ month: "month";
85
+ year: "year";
86
+ }>;
87
+ x: z.ZodInt;
88
+ }, z.core.$strip>>>;
89
+ weekDaySet: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodInt>>>;
90
+ everyXWeekdayOfMonth: z.ZodOptional<z.ZodNullable<z.ZodObject<{
91
+ weekDay: z.ZodInt;
92
+ weekOfMonth: z.ZodUnion<readonly [z.ZodInt, z.ZodLiteral<"last">]>;
93
+ }, z.core.$strip>>>;
94
+ }, z.core.$strip>;
95
+ recurrenceBasis: z.ZodEnum<typeof RecurrenceBasis>;
96
+ recurrenceEffect: z.ZodEnum<typeof RecurrenceEffect>;
97
+ }, z.core.$strip>;
98
+ /**
99
+ * Represents the recurrence information for a task.
100
+ */
101
+ export type RecurrenceInfo = z.infer<typeof RecurrenceInfoSchema>;
102
+ /**
103
+ * Zod schema for {@link ParentRecurringTaskInfo}.
104
+ */
105
+ export declare const ParentRecurringTaskInfoSchema: z.ZodObject<{
106
+ taskId: z.ZodPipe<z.ZodUUID, z.ZodTransform<`${string}-${string}-${string}-${string}-${string}`, string>>;
107
+ startDate: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
108
+ dueDate: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
109
+ }, z.core.$strip>;
84
110
  /**
85
111
  * The recurring task info for the parent recurring task if there is one.
86
112
  *
87
113
  * If this is set, then the current tasks's recurrence info should be the
88
114
  * same as the parent recurring task.
89
115
  */
90
- export type ParentRecurringTaskInfo = {
91
- taskId: UUID;
92
- startDate?: Date;
93
- dueDate?: Date;
94
- };
116
+ export type ParentRecurringTaskInfo = z.infer<typeof ParentRecurringTaskInfoSchema>;
95
117
  //# sourceMappingURL=RecurrenceInfo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RecurrenceInfo.d.ts","sourceRoot":"","sources":["../../../../src/embedded-types/dashboard/task/RecurrenceInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,aAAa,MAAM,sCAAsC,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAuBlF;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,mBAAmB,CAAC;IAC/B,eAAe,EAAE,eAAe,CAAC;IACjC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,cAAc,CAAC,EAAE;QACf,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;QAC5C;;WAEG;QACH,CAAC,EAAE,MAAM,CAAC;KACX,CAAC;IACF;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,oBAAoB,CAAC,EAAE;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB;;;;WAIG;QACH,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,oBAAY,uBAAuB;IACjC,cAAc,mBAAmB;IACjC,UAAU,eAAe;IACzB,oBAAoB,yBAAyB;IAC7C,cAAc,mBAAmB;CAClC;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,oBAAY,gBAAgB;IAC1B;;OAEG;IACH,WAAW,gBAAgB;IAC3B;;;OAGG;IACH,gBAAgB,qBAAqB;IACrC;;;;OAIG;IACH,KAAK,UAAU;CAChB;AAED;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB,CAAC"}
1
+ {"version":3,"file":"RecurrenceInfo.d.ts","sourceRoot":"","sources":["../../../../src/embedded-types/dashboard/task/RecurrenceInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,oBAAY,uBAAuB;IACjC,cAAc,mBAAmB;IACjC,UAAU,eAAe;IACzB,oBAAoB,yBAAyB;IAC7C,cAAc,mBAAmB;CAClC;AAED;;GAEG;AACH,eAAO,MAAM,6BAA6B,2CAAkC,CAAC;AAE7E;;GAEG;AACH,oBAAY,eAAe;IACzB,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,mCAA0B,CAAC;AAE7D;;GAEG;AACH,oBAAY,gBAAgB;IAC1B;;OAEG;IACH,WAAW,gBAAgB;IAC3B;;;OAGG;IACH,gBAAgB,qBAAqB;IACrC;;;;OAIG;IACH,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,oCAA2B,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;iBA8BpC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;iBAI/B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;iBAOxC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC"}
@@ -1,31 +1,4 @@
1
- import DashboardTask from '../../../documents/dashboard/Task.js';
2
- /**
3
- * Validates the recurrence information of a given task.
4
- *
5
- * @param task - The dashboard task to validate.
6
- * @param errors - An array to collect validation error messages.
7
- */
8
- export function validateRecurrenceInfo(task, errors) {
9
- const recurrenceErrors = [];
10
- if (!task.recurrenceInfo) {
11
- return;
12
- }
13
- if (!task.recurrenceInfo.frequency) {
14
- recurrenceErrors.push('RecurrenceInfo frequency is required.');
15
- }
16
- if (!task.recurrenceInfo.recurrenceBasis) {
17
- recurrenceErrors.push('RecurrenceInfo recurrenceBasis is required.');
18
- }
19
- if (!task.recurrenceInfo.recurrenceEffect) {
20
- recurrenceErrors.push('RecurrenceInfo recurrenceEffect is required.');
21
- }
22
- // Write more of this later if there are any changes to the data model so it
23
- // can be correctly converted.
24
- if (recurrenceErrors.length > 0) {
25
- task.recurrenceInfo = undefined;
26
- }
27
- errors.push(...recurrenceErrors);
28
- }
1
+ import { z } from 'zod';
29
2
  /**
30
3
  * Enum representing the different types of recurrence frequencies.
31
4
  */
@@ -36,6 +9,10 @@ export var RecurrenceFrequencyType;
36
9
  RecurrenceFrequencyType["everyXWeekdayOfMonth"] = "everyXWeekdayOfMonth";
37
10
  RecurrenceFrequencyType["lastDayOfMonth"] = "lastDayOfMonth";
38
11
  })(RecurrenceFrequencyType || (RecurrenceFrequencyType = {}));
12
+ /**
13
+ * Zod schema for {@link RecurrenceFrequencyType}.
14
+ */
15
+ export const RecurrenceFrequencyTypeSchema = z.enum(RecurrenceFrequencyType);
39
16
  /**
40
17
  * The basis of date movement for a recurring task.
41
18
  */
@@ -44,6 +21,10 @@ export var RecurrenceBasis;
44
21
  RecurrenceBasis["startDate"] = "startDate";
45
22
  RecurrenceBasis["dueDate"] = "dueDate";
46
23
  })(RecurrenceBasis || (RecurrenceBasis = {}));
24
+ /**
25
+ * Zod schema for {@link RecurrenceBasis}.
26
+ */
27
+ export const RecurrenceBasisSchema = z.enum(RecurrenceBasis);
47
28
  /**
48
29
  * The effect of recurrence for a recurring task.
49
30
  */
@@ -65,4 +46,61 @@ export var RecurrenceEffect;
65
46
  */
66
47
  RecurrenceEffect["stack"] = "stack";
67
48
  })(RecurrenceEffect || (RecurrenceEffect = {}));
49
+ /**
50
+ * Zod schema for {@link RecurrenceEffect}.
51
+ */
52
+ export const RecurrenceEffectSchema = z.enum(RecurrenceEffect);
53
+ /**
54
+ * Zod schema for {@link RecurrenceFrequency}.
55
+ */
56
+ export const RecurrenceFrequencySchema = z.object({
57
+ type: RecurrenceFrequencyTypeSchema,
58
+ everyXTimeUnit: z
59
+ .object({
60
+ timeUnit: z.enum(['day', 'week', 'month', 'year']),
61
+ /**
62
+ * The number of time units that should pass before the task recurs.
63
+ */
64
+ x: z.int()
65
+ })
66
+ .nullish(),
67
+ /**
68
+ * The set of week days that the task should recur on. This is 0-6 with 0
69
+ * being Sunday.
70
+ *
71
+ * The idea that each of these values is unique needs to be enforced on the
72
+ * frontend.
73
+ */
74
+ weekDaySet: z.array(z.int().min(0).max(6)).nullish(),
75
+ everyXWeekdayOfMonth: z
76
+ .object({
77
+ weekDay: z.int().min(0).max(6),
78
+ /**
79
+ * The week of the month that the task should recur on. This is 0-4 with 0
80
+ * being the first week of the month. If this is 'last', then it will
81
+ * recur on the last week of the month.
82
+ */
83
+ weekOfMonth: z.union([z.int().min(0).max(4), z.literal('last')])
84
+ })
85
+ .nullish()
86
+ });
87
+ /**
88
+ * Zod schema for {@link RecurrenceInfo}.
89
+ */
90
+ export const RecurrenceInfoSchema = z.object({
91
+ frequency: RecurrenceFrequencySchema,
92
+ recurrenceBasis: RecurrenceBasisSchema,
93
+ recurrenceEffect: RecurrenceEffectSchema
94
+ });
95
+ /**
96
+ * Zod schema for {@link ParentRecurringTaskInfo}.
97
+ */
98
+ export const ParentRecurringTaskInfoSchema = z.object({
99
+ /**
100
+ * The ID of the parent recurring task.
101
+ */
102
+ taskId: z.uuidv7().transform((val) => val),
103
+ startDate: z.date().nullish(),
104
+ dueDate: z.date().nullish()
105
+ });
68
106
  //# sourceMappingURL=RecurrenceInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RecurrenceInfo.js","sourceRoot":"","sources":["../../../../src/embedded-types/dashboard/task/RecurrenceInfo.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,sCAAsC,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAmB,EAAE,MAAgB;IAC1E,MAAM,gBAAgB,GAAa,EAAE,CAAC;IACtC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QACzB,OAAO;IACT,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;QACnC,gBAAgB,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;QACzC,gBAAgB,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;QAC1C,gBAAgB,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;IACxE,CAAC;IAED,4EAA4E;IAC5E,8BAA8B;IAE9B,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;IAClC,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC;AACnC,CAAC;AA0CD;;GAEG;AACH,MAAM,CAAN,IAAY,uBAKX;AALD,WAAY,uBAAuB;IACjC,4DAAiC,CAAA;IACjC,oDAAyB,CAAA;IACzB,wEAA6C,CAAA;IAC7C,4DAAiC,CAAA;AACnC,CAAC,EALW,uBAAuB,KAAvB,uBAAuB,QAKlC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,sCAAmB,CAAA;AACrB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,gBAgBX;AAhBD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,+CAA2B,CAAA;IAC3B;;;OAGG;IACH,yDAAqC,CAAA;IACrC;;;;OAIG;IACH,mCAAe,CAAA;AACjB,CAAC,EAhBW,gBAAgB,KAAhB,gBAAgB,QAgB3B"}
1
+ {"version":3,"file":"RecurrenceInfo.js","sourceRoot":"","sources":["../../../../src/embedded-types/dashboard/task/RecurrenceInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAN,IAAY,uBAKX;AALD,WAAY,uBAAuB;IACjC,4DAAiC,CAAA;IACjC,oDAAyB,CAAA;IACzB,wEAA6C,CAAA;IAC7C,4DAAiC,CAAA;AACnC,CAAC,EALW,uBAAuB,KAAvB,uBAAuB,QAKlC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,sCAAmB,CAAA;AACrB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAN,IAAY,gBAgBX;AAhBD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,+CAA2B,CAAA;IAC3B;;;OAGG;IACH,yDAAqC,CAAA;IACrC;;;;OAIG;IACH,mCAAe,CAAA;AACjB,CAAC,EAhBW,gBAAgB,KAAhB,gBAAgB,QAgB3B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,IAAI,EAAE,6BAA6B;IACnC,cAAc,EAAE,CAAC;SACd,MAAM,CAAC;QACN,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAClD;;WAEG;QACH,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE;KACX,CAAC;SACD,OAAO,EAAE;IACZ;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE;IACpD,oBAAoB,EAAE,CAAC;SACpB,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9B;;;;WAIG;QACH,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;KACjE,CAAC;SACD,OAAO,EAAE;CACb,CAAC,CAAC;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,SAAS,EAAE,yBAAyB;IACpC,eAAe,EAAE,qBAAqB;IACtC,gBAAgB,EAAE,sBAAsB;CACzC,CAAC,CAAC;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC;IACpD;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAW,CAAC;IAClD,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE;IAC7B,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE;CAC5B,CAAC,CAAC"}
@@ -1,76 +1,5 @@
1
1
  import type { UUID } from 'crypto';
2
- import DashboardTask from '../../../documents/dashboard/Task.js';
3
-
4
- /**
5
- * Validates the recurrence information of a given task.
6
- *
7
- * @param task - The dashboard task to validate.
8
- * @param errors - An array to collect validation error messages.
9
- */
10
- export function validateRecurrenceInfo(task: DashboardTask, errors: string[]): void {
11
- const recurrenceErrors: string[] = [];
12
- if (!task.recurrenceInfo) {
13
- return;
14
- }
15
-
16
- if (!task.recurrenceInfo.frequency) {
17
- recurrenceErrors.push('RecurrenceInfo frequency is required.');
18
- }
19
- if (!task.recurrenceInfo.recurrenceBasis) {
20
- recurrenceErrors.push('RecurrenceInfo recurrenceBasis is required.');
21
- }
22
- if (!task.recurrenceInfo.recurrenceEffect) {
23
- recurrenceErrors.push('RecurrenceInfo recurrenceEffect is required.');
24
- }
25
-
26
- // Write more of this later if there are any changes to the data model so it
27
- // can be correctly converted.
28
-
29
- if (recurrenceErrors.length > 0) {
30
- task.recurrenceInfo = undefined;
31
- }
32
- errors.push(...recurrenceErrors);
33
- }
34
-
35
- /**
36
- * Represents the recurrence information for a task.
37
- */
38
- export type RecurrenceInfo = {
39
- frequency: RecurrenceFrequency;
40
- recurrenceBasis: RecurrenceBasis;
41
- recurrenceEffect: RecurrenceEffect;
42
- };
43
-
44
- /**
45
- * Represents the frequency of recurrence for a task.
46
- */
47
- export type RecurrenceFrequency = {
48
- type: RecurrenceFrequencyType;
49
- everyXTimeUnit?: {
50
- timeUnit: 'day' | 'week' | 'month' | 'year';
51
- /**
52
- * The number of time units that should pass before the task recurs.
53
- */
54
- x: number;
55
- };
56
- /**
57
- * The set of week days that the task should recur on. This is 0-6 with 0
58
- * being Sunday.
59
- *
60
- * The idea that each of these values is unique needs to be enforced on the
61
- * frontend.
62
- */
63
- weekDaySet?: number[];
64
- everyXWeekdayOfMonth?: {
65
- weekDay: number;
66
- /**
67
- * The week of the month that the task should recur on. This is 0-4 with 0
68
- * being the first week of the month. If this is 'last', then it will
69
- * recur on the last week of the month.
70
- */
71
- weekOfMonth: number | 'last';
72
- };
73
- };
2
+ import { z } from 'zod';
74
3
 
75
4
  /**
76
5
  * Enum representing the different types of recurrence frequencies.
@@ -82,6 +11,11 @@ export enum RecurrenceFrequencyType {
82
11
  lastDayOfMonth = 'lastDayOfMonth'
83
12
  }
84
13
 
14
+ /**
15
+ * Zod schema for {@link RecurrenceFrequencyType}.
16
+ */
17
+ export const RecurrenceFrequencyTypeSchema = z.enum(RecurrenceFrequencyType);
18
+
85
19
  /**
86
20
  * The basis of date movement for a recurring task.
87
21
  */
@@ -90,6 +24,11 @@ export enum RecurrenceBasis {
90
24
  dueDate = 'dueDate'
91
25
  }
92
26
 
27
+ /**
28
+ * Zod schema for {@link RecurrenceBasis}.
29
+ */
30
+ export const RecurrenceBasisSchema = z.enum(RecurrenceBasis);
31
+
93
32
  /**
94
33
  * The effect of recurrence for a recurring task.
95
34
  */
@@ -111,14 +50,81 @@ export enum RecurrenceEffect {
111
50
  stack = 'stack'
112
51
  }
113
52
 
53
+ /**
54
+ * Zod schema for {@link RecurrenceEffect}.
55
+ */
56
+ export const RecurrenceEffectSchema = z.enum(RecurrenceEffect);
57
+
58
+ /**
59
+ * Zod schema for {@link RecurrenceFrequency}.
60
+ */
61
+ export const RecurrenceFrequencySchema = z.object({
62
+ type: RecurrenceFrequencyTypeSchema,
63
+ everyXTimeUnit: z
64
+ .object({
65
+ timeUnit: z.enum(['day', 'week', 'month', 'year']),
66
+ /**
67
+ * The number of time units that should pass before the task recurs.
68
+ */
69
+ x: z.int()
70
+ })
71
+ .nullish(),
72
+ /**
73
+ * The set of week days that the task should recur on. This is 0-6 with 0
74
+ * being Sunday.
75
+ *
76
+ * The idea that each of these values is unique needs to be enforced on the
77
+ * frontend.
78
+ */
79
+ weekDaySet: z.array(z.int().min(0).max(6)).nullish(),
80
+ everyXWeekdayOfMonth: z
81
+ .object({
82
+ weekDay: z.int().min(0).max(6),
83
+ /**
84
+ * The week of the month that the task should recur on. This is 0-4 with 0
85
+ * being the first week of the month. If this is 'last', then it will
86
+ * recur on the last week of the month.
87
+ */
88
+ weekOfMonth: z.union([z.int().min(0).max(4), z.literal('last')])
89
+ })
90
+ .nullish()
91
+ });
92
+
93
+ /**
94
+ * Represents the frequency of recurrence for a task.
95
+ */
96
+ export type RecurrenceFrequency = z.infer<typeof RecurrenceFrequencySchema>;
97
+
98
+ /**
99
+ * Zod schema for {@link RecurrenceInfo}.
100
+ */
101
+ export const RecurrenceInfoSchema = z.object({
102
+ frequency: RecurrenceFrequencySchema,
103
+ recurrenceBasis: RecurrenceBasisSchema,
104
+ recurrenceEffect: RecurrenceEffectSchema
105
+ });
106
+
107
+ /**
108
+ * Represents the recurrence information for a task.
109
+ */
110
+ export type RecurrenceInfo = z.infer<typeof RecurrenceInfoSchema>;
111
+
112
+ /**
113
+ * Zod schema for {@link ParentRecurringTaskInfo}.
114
+ */
115
+ export const ParentRecurringTaskInfoSchema = z.object({
116
+ /**
117
+ * The ID of the parent recurring task.
118
+ */
119
+ taskId: z.uuidv7().transform((val) => val as UUID),
120
+ startDate: z.date().nullish(),
121
+ dueDate: z.date().nullish()
122
+ });
123
+
114
124
  /**
115
125
  * The recurring task info for the parent recurring task if there is one.
116
126
  *
117
127
  * If this is set, then the current tasks's recurrence info should be the
118
128
  * same as the parent recurring task.
119
129
  */
120
- export type ParentRecurringTaskInfo = {
121
- taskId: UUID;
122
- startDate?: Date;
123
- dueDate?: Date;
124
- };
130
+ export type ParentRecurringTaskInfo = z.infer<typeof ParentRecurringTaskInfoSchema>;