@doist/todoist-sdk 8.2.1 → 8.3.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.
- package/dist/cjs/todoist-api.js +16 -4
- package/dist/cjs/types/sync/resources/calendars.js +4 -8
- package/dist/cjs/types/sync/resources/collaborators.js +4 -8
- package/dist/cjs/types/sync/resources/completed-info.js +6 -12
- package/dist/cjs/types/sync/resources/filters.js +2 -4
- package/dist/cjs/types/sync/resources/folders.js +2 -4
- package/dist/cjs/types/sync/resources/live-notifications.js +6 -8
- package/dist/cjs/types/sync/resources/notes.js +2 -4
- package/dist/cjs/types/sync/resources/reminders.js +4 -4
- package/dist/cjs/types/sync/resources/suggestions.js +6 -12
- package/dist/cjs/types/sync/resources/tooltips.js +2 -4
- package/dist/cjs/types/sync/resources/user-plan-limits.js +4 -8
- package/dist/cjs/types/sync/resources/user-settings.js +4 -6
- package/dist/cjs/types/sync/resources/user.js +10 -20
- package/dist/cjs/types/sync/resources/view-options.js +6 -12
- package/dist/cjs/types/sync/resources/workspace-filters.js +2 -4
- package/dist/cjs/types/sync/resources/workspace-goals.js +6 -12
- package/dist/cjs/types/sync/resources/workspaces.js +1 -2
- package/dist/cjs/utils/validators.js +37 -1
- package/dist/esm/todoist-api.js +17 -5
- package/dist/esm/types/sync/resources/calendars.js +4 -8
- package/dist/esm/types/sync/resources/collaborators.js +4 -8
- package/dist/esm/types/sync/resources/completed-info.js +6 -12
- package/dist/esm/types/sync/resources/filters.js +2 -4
- package/dist/esm/types/sync/resources/folders.js +2 -4
- package/dist/esm/types/sync/resources/live-notifications.js +6 -8
- package/dist/esm/types/sync/resources/notes.js +2 -4
- package/dist/esm/types/sync/resources/reminders.js +4 -4
- package/dist/esm/types/sync/resources/suggestions.js +6 -12
- package/dist/esm/types/sync/resources/tooltips.js +2 -4
- package/dist/esm/types/sync/resources/user-plan-limits.js +4 -8
- package/dist/esm/types/sync/resources/user-settings.js +4 -6
- package/dist/esm/types/sync/resources/user.js +10 -20
- package/dist/esm/types/sync/resources/view-options.js +6 -12
- package/dist/esm/types/sync/resources/workspace-filters.js +2 -4
- package/dist/esm/types/sync/resources/workspace-goals.js +6 -12
- package/dist/esm/types/sync/resources/workspaces.js +1 -2
- package/dist/esm/utils/validators.js +36 -1
- package/dist/types/types/sync/resources/live-notifications.d.ts +4 -4
- package/dist/types/types/sync/resources/reminders.d.ts +1 -1
- package/dist/types/utils/validators.d.ts +34 -32
- package/package.json +1 -1
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const CalendarSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const CalendarSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
summary: z.string(),
|
|
6
5
|
color: z.string().nullable(),
|
|
7
6
|
accountId: z.string(),
|
|
8
7
|
isVisible: z.boolean(),
|
|
9
8
|
isTaskCalendar: z.boolean().optional(),
|
|
10
|
-
})
|
|
11
|
-
.passthrough();
|
|
9
|
+
});
|
|
12
10
|
/** Available calendar account provider types. */
|
|
13
11
|
export const CALENDAR_ACCOUNT_TYPES = ['google', 'microsoft', 'apple'];
|
|
14
12
|
/** Available calendar sync states. */
|
|
15
13
|
export const CALENDAR_SYNC_STATES = ['synced', 'syncing', 'error'];
|
|
16
|
-
export const CalendarAccountSchema = z
|
|
17
|
-
.object({
|
|
14
|
+
export const CalendarAccountSchema = z.looseObject({
|
|
18
15
|
id: z.string(),
|
|
19
16
|
name: z.string(),
|
|
20
17
|
type: z.enum(CALENDAR_ACCOUNT_TYPES),
|
|
@@ -24,5 +21,4 @@ export const CalendarAccountSchema = z
|
|
|
24
21
|
isAllDayTasksEnabled: z.boolean().optional(),
|
|
25
22
|
pendingOperationUntil: z.string().nullable().optional(),
|
|
26
23
|
calendarsSyncState: z.enum(CALENDAR_SYNC_STATES).optional(),
|
|
27
|
-
})
|
|
28
|
-
.passthrough();
|
|
24
|
+
});
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { WorkspaceRoleSchema } from '../../workspaces/types.js';
|
|
3
|
-
export const CollaboratorSchema = z
|
|
4
|
-
.object({
|
|
3
|
+
export const CollaboratorSchema = z.looseObject({
|
|
5
4
|
id: z.string(),
|
|
6
5
|
email: z.string(),
|
|
7
6
|
fullName: z.string(),
|
|
8
7
|
timezone: z.string(),
|
|
9
8
|
imageId: z.string().nullable(),
|
|
10
|
-
})
|
|
11
|
-
.passthrough();
|
|
9
|
+
});
|
|
12
10
|
/** Available collaborator statuses. */
|
|
13
11
|
export const COLLABORATOR_STATUSES = ['active', 'invited'];
|
|
14
|
-
export const CollaboratorStateSchema = z
|
|
15
|
-
.object({
|
|
12
|
+
export const CollaboratorStateSchema = z.looseObject({
|
|
16
13
|
userId: z.string(),
|
|
17
14
|
projectId: z.string(),
|
|
18
15
|
state: z.enum(COLLABORATOR_STATUSES),
|
|
19
16
|
isDeleted: z.boolean(),
|
|
20
17
|
workspaceRole: WorkspaceRoleSchema.optional(),
|
|
21
|
-
})
|
|
22
|
-
.passthrough();
|
|
18
|
+
});
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const CompletedProjectMetadataSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const CompletedProjectMetadataSchema = z.looseObject({
|
|
4
3
|
projectId: z.string(),
|
|
5
4
|
archivedSections: z.number().int(),
|
|
6
5
|
completedItems: z.number().int(),
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
export const CompletedSectionMetadataSchema = z
|
|
10
|
-
.object({
|
|
6
|
+
});
|
|
7
|
+
export const CompletedSectionMetadataSchema = z.looseObject({
|
|
11
8
|
sectionId: z.string(),
|
|
12
9
|
id: z.string(),
|
|
13
10
|
completedItems: z.number().int(),
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export const CompletedTaskMetadataSchema = z
|
|
17
|
-
.object({
|
|
11
|
+
});
|
|
12
|
+
export const CompletedTaskMetadataSchema = z.looseObject({
|
|
18
13
|
itemId: z.string(),
|
|
19
14
|
id: z.string().optional(),
|
|
20
15
|
completedItems: z.number().int(),
|
|
21
|
-
})
|
|
22
|
-
.passthrough();
|
|
16
|
+
});
|
|
23
17
|
export const CompletedInfoSchema = z.union([
|
|
24
18
|
CompletedProjectMetadataSchema,
|
|
25
19
|
CompletedSectionMetadataSchema,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const FilterSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const FilterSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
name: z.string(),
|
|
6
5
|
query: z.string(),
|
|
@@ -9,5 +8,4 @@ export const FilterSchema = z
|
|
|
9
8
|
isFavorite: z.boolean(),
|
|
10
9
|
isFrozen: z.boolean(),
|
|
11
10
|
itemOrder: z.number().int(),
|
|
12
|
-
})
|
|
13
|
-
.passthrough();
|
|
11
|
+
});
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const FolderSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const FolderSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
name: z.string(),
|
|
6
5
|
workspaceId: z.string(),
|
|
7
6
|
isDeleted: z.boolean(),
|
|
8
7
|
defaultOrder: z.number().int(),
|
|
9
8
|
childOrder: z.number().int(),
|
|
10
|
-
})
|
|
11
|
-
.passthrough();
|
|
9
|
+
});
|
|
@@ -2,13 +2,12 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* Live notification resource from the Sync API.
|
|
4
4
|
*
|
|
5
|
-
* Uses a
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Uses a loose object schema with commonly-present fields for forward
|
|
6
|
+
* compatibility. The Sync API returns 20+ notification variants; fully typing
|
|
7
|
+
* each is too fragile for a library, so we validate the common shape and
|
|
8
|
+
* preserve all extra fields.
|
|
9
9
|
*/
|
|
10
|
-
export const LiveNotificationSchema = z
|
|
11
|
-
.object({
|
|
10
|
+
export const LiveNotificationSchema = z.looseObject({
|
|
12
11
|
id: z.string(),
|
|
13
12
|
createdAt: z.string(),
|
|
14
13
|
fromUid: z.string(),
|
|
@@ -32,5 +31,4 @@ export const LiveNotificationSchema = z
|
|
|
32
31
|
projectName: z.string().optional(),
|
|
33
32
|
isDeleted: z.boolean().optional(),
|
|
34
33
|
invitationSecret: z.string().optional(),
|
|
35
|
-
})
|
|
36
|
-
.passthrough();
|
|
34
|
+
});
|
|
@@ -4,8 +4,7 @@ import { AttachmentSchema } from '../../comments/types.js';
|
|
|
4
4
|
* Sync API note (comment) resource.
|
|
5
5
|
* Separate from the REST `CommentSchema` which transforms `itemId` to `taskId`.
|
|
6
6
|
*/
|
|
7
|
-
export const NoteSchema = z
|
|
8
|
-
.object({
|
|
7
|
+
export const NoteSchema = z.looseObject({
|
|
9
8
|
id: z.string(),
|
|
10
9
|
itemId: z.string().optional(),
|
|
11
10
|
projectId: z.string().optional(),
|
|
@@ -16,5 +15,4 @@ export const NoteSchema = z
|
|
|
16
15
|
uidsToNotify: z.array(z.string()).nullable(),
|
|
17
16
|
reactions: z.record(z.string(), z.array(z.string())).nullable(),
|
|
18
17
|
isDeleted: z.boolean(),
|
|
19
|
-
})
|
|
20
|
-
.passthrough();
|
|
18
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { DueDateSchema } from '../../tasks/types.js';
|
|
3
|
-
export const ReminderBaseSchema = z.
|
|
3
|
+
export const ReminderBaseSchema = z.looseObject({
|
|
4
4
|
id: z.string(),
|
|
5
5
|
notifyUid: z.string(),
|
|
6
6
|
itemId: z.string(),
|
|
@@ -28,18 +28,18 @@ export const LocationReminderSchema = ReminderBaseSchema.extend({
|
|
|
28
28
|
locLong: z.string(),
|
|
29
29
|
locTrigger: z.enum(LOCATION_TRIGGERS),
|
|
30
30
|
radius: z.number().int(),
|
|
31
|
-
})
|
|
31
|
+
});
|
|
32
32
|
export const AbsoluteReminderSchema = ReminderBaseSchema.extend({
|
|
33
33
|
type: z.literal(ReminderTypeEnum.Absolute),
|
|
34
34
|
due: DueDateSchema,
|
|
35
35
|
isUrgent: z.boolean().optional(),
|
|
36
|
-
})
|
|
36
|
+
});
|
|
37
37
|
export const RelativeReminderSchema = ReminderBaseSchema.extend({
|
|
38
38
|
type: z.literal(ReminderTypeEnum.Relative),
|
|
39
39
|
minuteOffset: z.number().int(),
|
|
40
40
|
due: DueDateSchema.optional(),
|
|
41
41
|
isUrgent: z.boolean().optional(),
|
|
42
|
-
})
|
|
42
|
+
});
|
|
43
43
|
export const ReminderSchema = z.discriminatedUnion('type', [
|
|
44
44
|
LocationReminderSchema,
|
|
45
45
|
AbsoluteReminderSchema,
|
|
@@ -1,38 +1,32 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/** Available template types. */
|
|
3
3
|
export const TEMPLATE_TYPES = ['project', 'setup'];
|
|
4
|
-
export const TemplateSuggestionSchema = z
|
|
5
|
-
.object({
|
|
4
|
+
export const TemplateSuggestionSchema = z.looseObject({
|
|
6
5
|
id: z.string(),
|
|
7
6
|
name: z.string(),
|
|
8
7
|
templateType: z.enum(TEMPLATE_TYPES),
|
|
9
|
-
})
|
|
10
|
-
.passthrough();
|
|
8
|
+
});
|
|
11
9
|
export const WorkspaceTemplateSuggestionSchema = TemplateSuggestionSchema.extend({
|
|
12
10
|
workspaceId: z.string().nullable(),
|
|
13
11
|
});
|
|
14
12
|
/** Available suggestion section types. */
|
|
15
13
|
export const SUGGESTION_SECTION_TYPES = ['templates', 'most_used_user_templates'];
|
|
16
|
-
export const SyncTemplateSuggestionsSchema = z
|
|
17
|
-
.object({
|
|
14
|
+
export const SyncTemplateSuggestionsSchema = z.looseObject({
|
|
18
15
|
type: z.enum(SUGGESTION_SECTION_TYPES),
|
|
19
16
|
content: z.object({
|
|
20
17
|
templates: z.array(TemplateSuggestionSchema),
|
|
21
18
|
locale: z.string(),
|
|
22
19
|
}),
|
|
23
20
|
isDeleted: z.boolean(),
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
export const SyncWorkspaceTemplateSuggestionsSchema = z
|
|
27
|
-
.object({
|
|
21
|
+
});
|
|
22
|
+
export const SyncWorkspaceTemplateSuggestionsSchema = z.looseObject({
|
|
28
23
|
type: z.literal('most_used_workspace_templates'),
|
|
29
24
|
content: z.object({
|
|
30
25
|
templates: z.array(WorkspaceTemplateSuggestionSchema),
|
|
31
26
|
locale: z.string(),
|
|
32
27
|
}),
|
|
33
28
|
isDeleted: z.boolean(),
|
|
34
|
-
})
|
|
35
|
-
.passthrough();
|
|
29
|
+
});
|
|
36
30
|
export const SuggestionSchema = z.union([
|
|
37
31
|
SyncWorkspaceTemplateSuggestionsSchema,
|
|
38
32
|
SyncTemplateSuggestionsSchema,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const PlanLimitsSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const PlanLimitsSchema = z.looseObject({
|
|
4
3
|
activeProjects: z.number().int().optional(),
|
|
5
4
|
activityLog: z.number().int().optional(),
|
|
6
5
|
collaboratorsPerProject: z.number().int().optional(),
|
|
@@ -11,11 +10,8 @@ export const PlanLimitsSchema = z
|
|
|
11
10
|
remindersPerUser: z.number().int().optional(),
|
|
12
11
|
sectionsPerProject: z.number().int().optional(),
|
|
13
12
|
tasksPerProject: z.number().int().optional(),
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export const UserPlanLimitsSchema = z
|
|
17
|
-
.object({
|
|
13
|
+
});
|
|
14
|
+
export const UserPlanLimitsSchema = z.looseObject({
|
|
18
15
|
current: PlanLimitsSchema,
|
|
19
16
|
next: PlanLimitsSchema.nullable(),
|
|
20
|
-
})
|
|
21
|
-
.passthrough();
|
|
17
|
+
});
|
|
@@ -10,8 +10,7 @@ export const QuickAddFeatureSchema = z.object({
|
|
|
10
10
|
/**
|
|
11
11
|
* Sync API user settings resource.
|
|
12
12
|
*/
|
|
13
|
-
export const UserSettingsSchema = z
|
|
14
|
-
.object({
|
|
13
|
+
export const UserSettingsSchema = z.looseObject({
|
|
15
14
|
completedSoundDesktop: z.boolean(),
|
|
16
15
|
completedSoundMobile: z.boolean(),
|
|
17
16
|
debugLogSendingEnabledUntil: z.string().nullable(),
|
|
@@ -21,7 +20,7 @@ export const UserSettingsSchema = z
|
|
|
21
20
|
countsShown: z.boolean(),
|
|
22
21
|
features: z.array(NavigationFeatureSchema),
|
|
23
22
|
})
|
|
24
|
-
.
|
|
23
|
+
.loose(),
|
|
25
24
|
reminderDesktop: z.boolean(),
|
|
26
25
|
reminderEmail: z.boolean(),
|
|
27
26
|
reminderPush: z.boolean(),
|
|
@@ -34,6 +33,5 @@ export const UserSettingsSchema = z
|
|
|
34
33
|
labelsShown: z.boolean(),
|
|
35
34
|
features: z.array(QuickAddFeatureSchema),
|
|
36
35
|
})
|
|
37
|
-
.
|
|
38
|
-
})
|
|
39
|
-
.passthrough();
|
|
36
|
+
.loose(),
|
|
37
|
+
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { PREMIUM_STATUSES } from '../../users/types.js';
|
|
3
3
|
import { BooleanFromZeroOneSchema, DateFormatSchema, DayOfWeekSchema, TimeFormatSchema, } from '../user-preferences.js';
|
|
4
|
-
export const FeaturesSchema = z
|
|
5
|
-
.object({
|
|
4
|
+
export const FeaturesSchema = z.looseObject({
|
|
6
5
|
karmaDisabled: z.boolean(),
|
|
7
6
|
restriction: z.number().int(),
|
|
8
7
|
karmaVacation: z.boolean(),
|
|
@@ -13,40 +12,32 @@ export const FeaturesSchema = z
|
|
|
13
12
|
autoInviteDisabled: z.boolean().optional(),
|
|
14
13
|
goldTheme: z.boolean().optional(),
|
|
15
14
|
migratedFromTdb: z.boolean().optional(),
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
export const TzInfoSchema = z
|
|
19
|
-
.object({
|
|
15
|
+
});
|
|
16
|
+
export const TzInfoSchema = z.looseObject({
|
|
20
17
|
timezone: z.string(),
|
|
21
18
|
hours: z.number().int(),
|
|
22
19
|
minutes: z.number().int(),
|
|
23
20
|
isDst: BooleanFromZeroOneSchema,
|
|
24
21
|
gmtString: z.string(),
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export const JoinableWorkspaceSchema = z
|
|
28
|
-
.object({
|
|
22
|
+
});
|
|
23
|
+
export const JoinableWorkspaceSchema = z.looseObject({
|
|
29
24
|
workspaceId: z.string(),
|
|
30
25
|
workspaceName: z.string(),
|
|
31
26
|
memberCount: z.number().int(),
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
export const GettingStartedGuideProjectSchema = z
|
|
35
|
-
.object({
|
|
27
|
+
});
|
|
28
|
+
export const GettingStartedGuideProjectSchema = z.looseObject({
|
|
36
29
|
onboardingUseCase: z.string(),
|
|
37
30
|
projectId: z.string(),
|
|
38
31
|
completed: z.boolean(),
|
|
39
32
|
closed: z.boolean(),
|
|
40
|
-
})
|
|
41
|
-
.passthrough();
|
|
33
|
+
});
|
|
42
34
|
/**
|
|
43
35
|
* Sync API user resource.
|
|
44
36
|
*
|
|
45
37
|
* This is a superset of the REST `CurrentUserSchema` — the Sync API returns
|
|
46
38
|
* many additional fields for features, onboarding state, and account details.
|
|
47
39
|
*/
|
|
48
|
-
export const SyncUserSchema = z
|
|
49
|
-
.object({
|
|
40
|
+
export const SyncUserSchema = z.looseObject({
|
|
50
41
|
id: z.string(),
|
|
51
42
|
email: z.string(),
|
|
52
43
|
fullName: z.string(),
|
|
@@ -113,5 +104,4 @@ export const SyncUserSchema = z
|
|
|
113
104
|
websocketUrl: z.string(),
|
|
114
105
|
weekendStartDay: z.number().int(),
|
|
115
106
|
weeklyGoal: z.number().int(),
|
|
116
|
-
})
|
|
117
|
-
.passthrough();
|
|
107
|
+
});
|
|
@@ -49,13 +49,10 @@ export const SORT_ORDERS = ['ASC', 'DESC'];
|
|
|
49
49
|
export const SortOrderSchema = z.enum(SORT_ORDERS).nullable();
|
|
50
50
|
/** Available calendar layout modes. */
|
|
51
51
|
export const CALENDAR_LAYOUTS = ['WEEK', 'MONTH'];
|
|
52
|
-
export const CalendarSettingsSchema = z
|
|
53
|
-
.object({
|
|
52
|
+
export const CalendarSettingsSchema = z.looseObject({
|
|
54
53
|
layout: z.enum(CALENDAR_LAYOUTS).optional(),
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
export const ViewOptionsSchema = z
|
|
58
|
-
.object({
|
|
54
|
+
});
|
|
55
|
+
export const ViewOptionsSchema = z.looseObject({
|
|
59
56
|
viewType: ViewTypeSchema,
|
|
60
57
|
objectId: z.string().optional(),
|
|
61
58
|
groupedBy: GroupedBySchema.optional(),
|
|
@@ -64,10 +61,8 @@ export const ViewOptionsSchema = z
|
|
|
64
61
|
showCompletedTasks: z.boolean().optional(),
|
|
65
62
|
sortedBy: SortedBySchema.optional(),
|
|
66
63
|
sortOrder: SortOrderSchema.optional(),
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
export const ProjectViewOptionsDefaultsSchema = z
|
|
70
|
-
.object({
|
|
64
|
+
});
|
|
65
|
+
export const ProjectViewOptionsDefaultsSchema = z.looseObject({
|
|
71
66
|
projectId: z.string(),
|
|
72
67
|
viewMode: ViewModeSchema.nullable().optional(),
|
|
73
68
|
groupedBy: GroupedBySchema.optional(),
|
|
@@ -76,5 +71,4 @@ export const ProjectViewOptionsDefaultsSchema = z
|
|
|
76
71
|
showCompletedTasks: z.boolean().optional(),
|
|
77
72
|
filteredBy: z.string().nullable().optional(),
|
|
78
73
|
calendarSettings: CalendarSettingsSchema.nullable().optional(),
|
|
79
|
-
})
|
|
80
|
-
.passthrough();
|
|
74
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const WorkspaceFilterSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const WorkspaceFilterSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
workspaceId: z.string(),
|
|
6
5
|
name: z.string(),
|
|
@@ -14,5 +13,4 @@ export const WorkspaceFilterSchema = z
|
|
|
14
13
|
updaterUid: z.string(),
|
|
15
14
|
createdAt: z.string(),
|
|
16
15
|
updatedAt: z.string(),
|
|
17
|
-
})
|
|
18
|
-
.passthrough();
|
|
16
|
+
});
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const WorkspaceGoalMilestoneSchema = z
|
|
3
|
-
.object({
|
|
2
|
+
export const WorkspaceGoalMilestoneSchema = z.looseObject({
|
|
4
3
|
id: z.string(),
|
|
5
4
|
title: z.string(),
|
|
6
5
|
isCompleted: z.boolean(),
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
export const WorkspaceGoalProgressSchema = z
|
|
10
|
-
.object({
|
|
6
|
+
});
|
|
7
|
+
export const WorkspaceGoalProgressSchema = z.looseObject({
|
|
11
8
|
completedItems: z.number().int(),
|
|
12
9
|
totalItems: z.number().int(),
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export const WorkspaceGoalSchema = z
|
|
16
|
-
.object({
|
|
10
|
+
});
|
|
11
|
+
export const WorkspaceGoalSchema = z.looseObject({
|
|
17
12
|
id: z.string(),
|
|
18
13
|
workspaceId: z.string(),
|
|
19
14
|
title: z.string(),
|
|
@@ -25,5 +20,4 @@ export const WorkspaceGoalSchema = z
|
|
|
25
20
|
creatorUid: z.string(),
|
|
26
21
|
createdAt: z.string(),
|
|
27
22
|
updatedAt: z.string(),
|
|
28
|
-
})
|
|
29
|
-
.passthrough();
|
|
23
|
+
});
|
|
@@ -20,7 +20,7 @@ import { WorkspaceRoleSchema, WorkspacePlanSchema, WorkspaceLimitsSchema, Worksp
|
|
|
20
20
|
* domain settings, and sorting preferences.
|
|
21
21
|
*/
|
|
22
22
|
export const SyncWorkspaceSchema = z
|
|
23
|
-
.
|
|
23
|
+
.looseObject({
|
|
24
24
|
id: StringOrNumberSchema,
|
|
25
25
|
name: z.string(),
|
|
26
26
|
description: z.string(),
|
|
@@ -63,7 +63,6 @@ export const SyncWorkspaceSchema = z
|
|
|
63
63
|
.optional(),
|
|
64
64
|
properties: WorkspacePropertiesSchema.optional(),
|
|
65
65
|
})
|
|
66
|
-
.passthrough()
|
|
67
66
|
.transform((_a) => {
|
|
68
67
|
var { dateCreated, createdAt } = _a, rest = __rest(_a, ["dateCreated", "createdAt"]);
|
|
69
68
|
return (Object.assign(Object.assign({}, rest), { createdAt: createdAt !== null && createdAt !== void 0 ? createdAt : dateCreated }));
|
|
@@ -15,7 +15,12 @@ function createValidator(schema) {
|
|
|
15
15
|
return (input) => schema.parse(input);
|
|
16
16
|
}
|
|
17
17
|
function createArrayValidator(validateItem) {
|
|
18
|
-
return (input) =>
|
|
18
|
+
return (input) => {
|
|
19
|
+
if (!Array.isArray(input)) {
|
|
20
|
+
throw new TypeError(`Expected array, got ${typeof input}`);
|
|
21
|
+
}
|
|
22
|
+
return input.map(validateItem);
|
|
23
|
+
};
|
|
19
24
|
}
|
|
20
25
|
// Entity validators
|
|
21
26
|
export const validateTask = createValidator(TaskSchema);
|
|
@@ -48,6 +53,9 @@ export function validateProject(input) {
|
|
|
48
53
|
return PersonalProjectSchema.parse(input);
|
|
49
54
|
}
|
|
50
55
|
export function validateProjectArray(input) {
|
|
56
|
+
if (!Array.isArray(input)) {
|
|
57
|
+
throw new TypeError(`Expected array, got ${typeof input}`);
|
|
58
|
+
}
|
|
51
59
|
return input.map(validateProject);
|
|
52
60
|
}
|
|
53
61
|
export const validateWorkspaceProject = createValidator(WorkspaceProjectSchema);
|
|
@@ -132,3 +140,30 @@ export const validateSyncUser = createValidator(SyncUserSchema);
|
|
|
132
140
|
export const validateUserSettings = createValidator(UserSettingsSchema);
|
|
133
141
|
export const validateSuggestion = createValidator(SuggestionSchema);
|
|
134
142
|
export const validateSuggestionArray = createArrayValidator(validateSuggestion);
|
|
143
|
+
export function parseSyncResponse(raw) {
|
|
144
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, raw), ('items' in raw ? { items: validateTaskArray(raw.items) } : {})), ('projects' in raw ? { projects: validateProjectArray(raw.projects) } : {})), ('sections' in raw ? { sections: validateSectionArray(raw.sections) } : {})), ('labels' in raw ? { labels: validateLabelArray(raw.labels) } : {})), ('notes' in raw ? { notes: validateNoteArray(raw.notes) } : {})), ('projectNotes' in raw ? { projectNotes: validateNoteArray(raw.projectNotes) } : {})), ('filters' in raw ? { filters: validateFilterArray(raw.filters) } : {})), ('reminders' in raw ? { reminders: validateReminderArray(raw.reminders) } : {})), ('remindersLocation' in raw
|
|
145
|
+
? { remindersLocation: validateLocationReminderArray(raw.remindersLocation) }
|
|
146
|
+
: {})), ('user' in raw ? { user: validateSyncUser(raw.user) } : {})), ('liveNotifications' in raw
|
|
147
|
+
? { liveNotifications: validateLiveNotificationArray(raw.liveNotifications) }
|
|
148
|
+
: {})), ('collaborators' in raw
|
|
149
|
+
? { collaborators: validateCollaboratorArray(raw.collaborators) }
|
|
150
|
+
: {})), ('collaboratorStates' in raw
|
|
151
|
+
? { collaboratorStates: validateCollaboratorStateArray(raw.collaboratorStates) }
|
|
152
|
+
: {})), ('userSettings' in raw ? { userSettings: validateUserSettings(raw.userSettings) } : {})), ('userPlanLimits' in raw
|
|
153
|
+
? { userPlanLimits: validateUserPlanLimits(raw.userPlanLimits) }
|
|
154
|
+
: {})), ('completedInfo' in raw
|
|
155
|
+
? { completedInfo: validateCompletedInfoArray(raw.completedInfo) }
|
|
156
|
+
: {})), ('workspaces' in raw ? { workspaces: validateSyncWorkspaceArray(raw.workspaces) } : {})), ('workspaceUsers' in raw
|
|
157
|
+
? { workspaceUsers: validateWorkspaceUserArray(raw.workspaceUsers) }
|
|
158
|
+
: {})), ('workspaceFilters' in raw
|
|
159
|
+
? { workspaceFilters: validateWorkspaceFilterArray(raw.workspaceFilters) }
|
|
160
|
+
: {})), ('viewOptions' in raw ? { viewOptions: validateViewOptionsArray(raw.viewOptions) } : {})), ('projectViewOptionsDefaults' in raw
|
|
161
|
+
? {
|
|
162
|
+
projectViewOptionsDefaults: validateProjectViewOptionsDefaultsArray(raw.projectViewOptionsDefaults),
|
|
163
|
+
}
|
|
164
|
+
: {})), ('folders' in raw ? { folders: validateFolderArray(raw.folders) } : {})), ('workspaceGoals' in raw
|
|
165
|
+
? { workspaceGoals: validateWorkspaceGoalArray(raw.workspaceGoals) }
|
|
166
|
+
: {})), ('calendars' in raw ? { calendars: validateCalendarArray(raw.calendars) } : {})), ('calendarAccounts' in raw
|
|
167
|
+
? { calendarAccounts: validateCalendarAccountArray(raw.calendarAccounts) }
|
|
168
|
+
: {})), ('suggestions' in raw ? { suggestions: validateSuggestionArray(raw.suggestions) } : {})), ('tooltips' in raw ? { tooltips: validateTooltips(raw.tooltips) } : {}));
|
|
169
|
+
}
|
|
@@ -2,10 +2,10 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* Live notification resource from the Sync API.
|
|
4
4
|
*
|
|
5
|
-
* Uses a
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Uses a loose object schema with commonly-present fields for forward
|
|
6
|
+
* compatibility. The Sync API returns 20+ notification variants; fully typing
|
|
7
|
+
* each is too fragile for a library, so we validate the common shape and
|
|
8
|
+
* preserve all extra fields.
|
|
9
9
|
*/
|
|
10
10
|
export declare const LiveNotificationSchema: z.ZodObject<{
|
|
11
11
|
id: z.ZodString;
|
|
@@ -5,7 +5,7 @@ export declare const ReminderBaseSchema: z.ZodObject<{
|
|
|
5
5
|
itemId: z.ZodString;
|
|
6
6
|
projectId: z.ZodOptional<z.ZodString>;
|
|
7
7
|
isDeleted: z.ZodBoolean;
|
|
8
|
-
}, z.core.$
|
|
8
|
+
}, z.core.$loose>;
|
|
9
9
|
/** Enum-like object of reminder type values. */
|
|
10
10
|
export declare const ReminderTypeEnum: {
|
|
11
11
|
readonly Relative: "relative";
|