@doist/todoist-sdk 8.3.0-next.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 -9
- package/dist/cjs/types/sync/commands/index.js +0 -1
- package/dist/cjs/types/sync/resource-types.js +0 -1
- 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/index.js +0 -1
- 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 -10
- package/dist/esm/types/sync/commands/index.js +0 -1
- package/dist/esm/types/sync/resource-types.js +0 -1
- 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/index.js +0 -1
- 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/commands/index.d.ts +0 -9
- package/dist/types/types/sync/resource-types.d.ts +1 -1
- package/dist/types/types/sync/resources/index.d.ts +0 -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/types/sync/resources/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +1 -2
- package/dist/types/utils/validators.d.ts +42 -40
- package/package.json +1 -1
- package/dist/cjs/types/sync/commands/goals.js +0 -2
- package/dist/cjs/types/sync/resources/goals.js +0 -33
- package/dist/esm/types/sync/commands/goals.js +0 -1
- package/dist/esm/types/sync/resources/goals.js +0 -30
- package/dist/types/types/sync/commands/goals.d.ts +0 -33
- package/dist/types/types/sync/resources/goals.d.ts +0 -37
package/dist/cjs/todoist-api.js
CHANGED
|
@@ -16,7 +16,6 @@ const zod_1 = require("zod");
|
|
|
16
16
|
const endpoints_1 = require("./consts/endpoints");
|
|
17
17
|
const http_client_1 = require("./transport/http-client");
|
|
18
18
|
const reminders_1 = require("./types/reminders");
|
|
19
|
-
const goals_1 = require("./types/sync/resources/goals");
|
|
20
19
|
const activity_helpers_1 = require("./utils/activity-helpers");
|
|
21
20
|
const case_conversion_1 = require("./utils/case-conversion");
|
|
22
21
|
const multipart_upload_1 = require("./utils/multipart-upload");
|
|
@@ -39,13 +38,25 @@ function spreadIfDefined(value, fn) {
|
|
|
39
38
|
return value !== undefined ? fn(value) : {};
|
|
40
39
|
}
|
|
41
40
|
function serializeUserUpdateArgs(args) {
|
|
42
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.dateFormat, (v) => ({
|
|
41
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.dateFormat, (v) => ({
|
|
42
|
+
dateFormat: sync_1.DATE_FORMAT_TO_API[v],
|
|
43
|
+
}))), spreadIfDefined(args.timeFormat, (v) => ({
|
|
44
|
+
timeFormat: sync_1.TIME_FORMAT_TO_API[v],
|
|
45
|
+
}))), spreadIfDefined(args.startDay, (v) => ({
|
|
46
|
+
startDay: sync_1.DAY_OF_WEEK_TO_API[v],
|
|
47
|
+
}))), spreadIfDefined(args.nextWeek, (v) => ({
|
|
48
|
+
nextWeek: sync_1.DAY_OF_WEEK_TO_API[v],
|
|
49
|
+
})));
|
|
43
50
|
}
|
|
44
51
|
function serializeTaskUpdateDateCompleteArgs(args) {
|
|
45
|
-
return Object.assign(Object.assign(Object.assign({}, args), { isForward: args.isForward ? 1 : 0 }), spreadIfDefined(args.resetSubtasks, (v) => ({
|
|
52
|
+
return Object.assign(Object.assign(Object.assign({}, args), { isForward: args.isForward ? 1 : 0 }), spreadIfDefined(args.resetSubtasks, (v) => ({
|
|
53
|
+
resetSubtasks: v ? 1 : 0,
|
|
54
|
+
})));
|
|
46
55
|
}
|
|
47
56
|
function serializeUpdateGoalsArgs(args) {
|
|
48
|
-
return Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.vacationMode, (v) => ({ vacationMode: v ? 1 : 0 }))), spreadIfDefined(args.karmaDisabled, (v) => ({
|
|
57
|
+
return Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.vacationMode, (v) => ({ vacationMode: v ? 1 : 0 }))), spreadIfDefined(args.karmaDisabled, (v) => ({
|
|
58
|
+
karmaDisabled: v ? 1 : 0,
|
|
59
|
+
})));
|
|
49
60
|
}
|
|
50
61
|
function preprocessSyncCommands(commands) {
|
|
51
62
|
return commands.map((cmd) => {
|
|
@@ -135,11 +146,7 @@ class TodoistApi {
|
|
|
135
146
|
throw new types_1.TodoistRequestError(value.error, value.httpCode, value.errorExtra);
|
|
136
147
|
});
|
|
137
148
|
}
|
|
138
|
-
|
|
139
|
-
if (data.goals) {
|
|
140
|
-
data.goals = data.goals.map((goal) => goals_1.GoalSchema.parse(goal));
|
|
141
|
-
}
|
|
142
|
-
return data;
|
|
149
|
+
return (0, validators_1.parseSyncResponse)(response.data);
|
|
143
150
|
}
|
|
144
151
|
/**
|
|
145
152
|
* Executes a raw Sync API request.
|
|
@@ -27,7 +27,6 @@ __exportStar(require("./workspaces"), exports);
|
|
|
27
27
|
__exportStar(require("./folders"), exports);
|
|
28
28
|
__exportStar(require("./workspace-filters"), exports);
|
|
29
29
|
__exportStar(require("./workspace-goals"), exports);
|
|
30
|
-
__exportStar(require("./goals"), exports);
|
|
31
30
|
__exportStar(require("./notifications"), exports);
|
|
32
31
|
__exportStar(require("./sharing"), exports);
|
|
33
32
|
__exportStar(require("./view-options"), exports);
|
|
@@ -2,22 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CalendarAccountSchema = exports.CALENDAR_SYNC_STATES = exports.CALENDAR_ACCOUNT_TYPES = exports.CalendarSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.CalendarSchema = zod_1.z
|
|
6
|
-
.object({
|
|
5
|
+
exports.CalendarSchema = zod_1.z.looseObject({
|
|
7
6
|
id: zod_1.z.string(),
|
|
8
7
|
summary: zod_1.z.string(),
|
|
9
8
|
color: zod_1.z.string().nullable(),
|
|
10
9
|
accountId: zod_1.z.string(),
|
|
11
10
|
isVisible: zod_1.z.boolean(),
|
|
12
11
|
isTaskCalendar: zod_1.z.boolean().optional(),
|
|
13
|
-
})
|
|
14
|
-
.passthrough();
|
|
12
|
+
});
|
|
15
13
|
/** Available calendar account provider types. */
|
|
16
14
|
exports.CALENDAR_ACCOUNT_TYPES = ['google', 'microsoft', 'apple'];
|
|
17
15
|
/** Available calendar sync states. */
|
|
18
16
|
exports.CALENDAR_SYNC_STATES = ['synced', 'syncing', 'error'];
|
|
19
|
-
exports.CalendarAccountSchema = zod_1.z
|
|
20
|
-
.object({
|
|
17
|
+
exports.CalendarAccountSchema = zod_1.z.looseObject({
|
|
21
18
|
id: zod_1.z.string(),
|
|
22
19
|
name: zod_1.z.string(),
|
|
23
20
|
type: zod_1.z.enum(exports.CALENDAR_ACCOUNT_TYPES),
|
|
@@ -27,5 +24,4 @@ exports.CalendarAccountSchema = zod_1.z
|
|
|
27
24
|
isAllDayTasksEnabled: zod_1.z.boolean().optional(),
|
|
28
25
|
pendingOperationUntil: zod_1.z.string().nullable().optional(),
|
|
29
26
|
calendarsSyncState: zod_1.z.enum(exports.CALENDAR_SYNC_STATES).optional(),
|
|
30
|
-
})
|
|
31
|
-
.passthrough();
|
|
27
|
+
});
|
|
@@ -3,23 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CollaboratorStateSchema = exports.COLLABORATOR_STATUSES = exports.CollaboratorSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const types_1 = require("../../workspaces/types");
|
|
6
|
-
exports.CollaboratorSchema = zod_1.z
|
|
7
|
-
.object({
|
|
6
|
+
exports.CollaboratorSchema = zod_1.z.looseObject({
|
|
8
7
|
id: zod_1.z.string(),
|
|
9
8
|
email: zod_1.z.string(),
|
|
10
9
|
fullName: zod_1.z.string(),
|
|
11
10
|
timezone: zod_1.z.string(),
|
|
12
11
|
imageId: zod_1.z.string().nullable(),
|
|
13
|
-
})
|
|
14
|
-
.passthrough();
|
|
12
|
+
});
|
|
15
13
|
/** Available collaborator statuses. */
|
|
16
14
|
exports.COLLABORATOR_STATUSES = ['active', 'invited'];
|
|
17
|
-
exports.CollaboratorStateSchema = zod_1.z
|
|
18
|
-
.object({
|
|
15
|
+
exports.CollaboratorStateSchema = zod_1.z.looseObject({
|
|
19
16
|
userId: zod_1.z.string(),
|
|
20
17
|
projectId: zod_1.z.string(),
|
|
21
18
|
state: zod_1.z.enum(exports.COLLABORATOR_STATUSES),
|
|
22
19
|
isDeleted: zod_1.z.boolean(),
|
|
23
20
|
workspaceRole: types_1.WorkspaceRoleSchema.optional(),
|
|
24
|
-
})
|
|
25
|
-
.passthrough();
|
|
21
|
+
});
|
|
@@ -2,27 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CompletedInfoSchema = exports.CompletedTaskMetadataSchema = exports.CompletedSectionMetadataSchema = exports.CompletedProjectMetadataSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.CompletedProjectMetadataSchema = zod_1.z
|
|
6
|
-
.object({
|
|
5
|
+
exports.CompletedProjectMetadataSchema = zod_1.z.looseObject({
|
|
7
6
|
projectId: zod_1.z.string(),
|
|
8
7
|
archivedSections: zod_1.z.number().int(),
|
|
9
8
|
completedItems: zod_1.z.number().int(),
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
exports.CompletedSectionMetadataSchema = zod_1.z
|
|
13
|
-
.object({
|
|
9
|
+
});
|
|
10
|
+
exports.CompletedSectionMetadataSchema = zod_1.z.looseObject({
|
|
14
11
|
sectionId: zod_1.z.string(),
|
|
15
12
|
id: zod_1.z.string(),
|
|
16
13
|
completedItems: zod_1.z.number().int(),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
exports.CompletedTaskMetadataSchema = zod_1.z
|
|
20
|
-
.object({
|
|
14
|
+
});
|
|
15
|
+
exports.CompletedTaskMetadataSchema = zod_1.z.looseObject({
|
|
21
16
|
itemId: zod_1.z.string(),
|
|
22
17
|
id: zod_1.z.string().optional(),
|
|
23
18
|
completedItems: zod_1.z.number().int(),
|
|
24
|
-
})
|
|
25
|
-
.passthrough();
|
|
19
|
+
});
|
|
26
20
|
exports.CompletedInfoSchema = zod_1.z.union([
|
|
27
21
|
exports.CompletedProjectMetadataSchema,
|
|
28
22
|
exports.CompletedSectionMetadataSchema,
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FilterSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.FilterSchema = zod_1.z
|
|
6
|
-
.object({
|
|
5
|
+
exports.FilterSchema = zod_1.z.looseObject({
|
|
7
6
|
id: zod_1.z.string(),
|
|
8
7
|
name: zod_1.z.string(),
|
|
9
8
|
query: zod_1.z.string(),
|
|
@@ -12,5 +11,4 @@ exports.FilterSchema = zod_1.z
|
|
|
12
11
|
isFavorite: zod_1.z.boolean(),
|
|
13
12
|
isFrozen: zod_1.z.boolean(),
|
|
14
13
|
itemOrder: zod_1.z.number().int(),
|
|
15
|
-
})
|
|
16
|
-
.passthrough();
|
|
14
|
+
});
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FolderSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.FolderSchema = zod_1.z
|
|
6
|
-
.object({
|
|
5
|
+
exports.FolderSchema = zod_1.z.looseObject({
|
|
7
6
|
id: zod_1.z.string(),
|
|
8
7
|
name: zod_1.z.string(),
|
|
9
8
|
workspaceId: zod_1.z.string(),
|
|
10
9
|
isDeleted: zod_1.z.boolean(),
|
|
11
10
|
defaultOrder: zod_1.z.number().int(),
|
|
12
11
|
childOrder: zod_1.z.number().int(),
|
|
13
|
-
})
|
|
14
|
-
.passthrough();
|
|
12
|
+
});
|
|
@@ -21,7 +21,6 @@ __exportStar(require("./tooltips"), exports);
|
|
|
21
21
|
__exportStar(require("./notes"), exports);
|
|
22
22
|
__exportStar(require("./workspace-filters"), exports);
|
|
23
23
|
__exportStar(require("./workspace-goals"), exports);
|
|
24
|
-
__exportStar(require("./goals"), exports);
|
|
25
24
|
__exportStar(require("./calendars"), exports);
|
|
26
25
|
__exportStar(require("./reminders"), exports);
|
|
27
26
|
__exportStar(require("./completed-info"), exports);
|
|
@@ -5,13 +5,12 @@ const zod_1 = require("zod");
|
|
|
5
5
|
/**
|
|
6
6
|
* Live notification resource from the Sync API.
|
|
7
7
|
*
|
|
8
|
-
* Uses a
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Uses a loose object schema with commonly-present fields for forward
|
|
9
|
+
* compatibility. The Sync API returns 20+ notification variants; fully typing
|
|
10
|
+
* each is too fragile for a library, so we validate the common shape and
|
|
11
|
+
* preserve all extra fields.
|
|
12
12
|
*/
|
|
13
|
-
exports.LiveNotificationSchema = zod_1.z
|
|
14
|
-
.object({
|
|
13
|
+
exports.LiveNotificationSchema = zod_1.z.looseObject({
|
|
15
14
|
id: zod_1.z.string(),
|
|
16
15
|
createdAt: zod_1.z.string(),
|
|
17
16
|
fromUid: zod_1.z.string(),
|
|
@@ -35,5 +34,4 @@ exports.LiveNotificationSchema = zod_1.z
|
|
|
35
34
|
projectName: zod_1.z.string().optional(),
|
|
36
35
|
isDeleted: zod_1.z.boolean().optional(),
|
|
37
36
|
invitationSecret: zod_1.z.string().optional(),
|
|
38
|
-
})
|
|
39
|
-
.passthrough();
|
|
37
|
+
});
|
|
@@ -7,8 +7,7 @@ const types_1 = require("../../comments/types");
|
|
|
7
7
|
* Sync API note (comment) resource.
|
|
8
8
|
* Separate from the REST `CommentSchema` which transforms `itemId` to `taskId`.
|
|
9
9
|
*/
|
|
10
|
-
exports.NoteSchema = zod_1.z
|
|
11
|
-
.object({
|
|
10
|
+
exports.NoteSchema = zod_1.z.looseObject({
|
|
12
11
|
id: zod_1.z.string(),
|
|
13
12
|
itemId: zod_1.z.string().optional(),
|
|
14
13
|
projectId: zod_1.z.string().optional(),
|
|
@@ -19,5 +18,4 @@ exports.NoteSchema = zod_1.z
|
|
|
19
18
|
uidsToNotify: zod_1.z.array(zod_1.z.string()).nullable(),
|
|
20
19
|
reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.string())).nullable(),
|
|
21
20
|
isDeleted: zod_1.z.boolean(),
|
|
22
|
-
})
|
|
23
|
-
.passthrough();
|
|
21
|
+
});
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ReminderSchema = exports.RelativeReminderSchema = exports.AbsoluteReminderSchema = exports.LocationReminderSchema = exports.LOCATION_TRIGGERS = exports.REMINDER_TYPES = exports.ReminderTypeEnum = exports.ReminderBaseSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const types_1 = require("../../tasks/types");
|
|
6
|
-
exports.ReminderBaseSchema = zod_1.z.
|
|
6
|
+
exports.ReminderBaseSchema = zod_1.z.looseObject({
|
|
7
7
|
id: zod_1.z.string(),
|
|
8
8
|
notifyUid: zod_1.z.string(),
|
|
9
9
|
itemId: zod_1.z.string(),
|
|
@@ -31,18 +31,18 @@ exports.LocationReminderSchema = exports.ReminderBaseSchema.extend({
|
|
|
31
31
|
locLong: zod_1.z.string(),
|
|
32
32
|
locTrigger: zod_1.z.enum(exports.LOCATION_TRIGGERS),
|
|
33
33
|
radius: zod_1.z.number().int(),
|
|
34
|
-
})
|
|
34
|
+
});
|
|
35
35
|
exports.AbsoluteReminderSchema = exports.ReminderBaseSchema.extend({
|
|
36
36
|
type: zod_1.z.literal(exports.ReminderTypeEnum.Absolute),
|
|
37
37
|
due: types_1.DueDateSchema,
|
|
38
38
|
isUrgent: zod_1.z.boolean().optional(),
|
|
39
|
-
})
|
|
39
|
+
});
|
|
40
40
|
exports.RelativeReminderSchema = exports.ReminderBaseSchema.extend({
|
|
41
41
|
type: zod_1.z.literal(exports.ReminderTypeEnum.Relative),
|
|
42
42
|
minuteOffset: zod_1.z.number().int(),
|
|
43
43
|
due: types_1.DueDateSchema.optional(),
|
|
44
44
|
isUrgent: zod_1.z.boolean().optional(),
|
|
45
|
-
})
|
|
45
|
+
});
|
|
46
46
|
exports.ReminderSchema = zod_1.z.discriminatedUnion('type', [
|
|
47
47
|
exports.LocationReminderSchema,
|
|
48
48
|
exports.AbsoluteReminderSchema,
|
|
@@ -4,38 +4,32 @@ exports.SuggestionSchema = exports.SyncWorkspaceTemplateSuggestionsSchema = expo
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
/** Available template types. */
|
|
6
6
|
exports.TEMPLATE_TYPES = ['project', 'setup'];
|
|
7
|
-
exports.TemplateSuggestionSchema = zod_1.z
|
|
8
|
-
.object({
|
|
7
|
+
exports.TemplateSuggestionSchema = zod_1.z.looseObject({
|
|
9
8
|
id: zod_1.z.string(),
|
|
10
9
|
name: zod_1.z.string(),
|
|
11
10
|
templateType: zod_1.z.enum(exports.TEMPLATE_TYPES),
|
|
12
|
-
})
|
|
13
|
-
.passthrough();
|
|
11
|
+
});
|
|
14
12
|
exports.WorkspaceTemplateSuggestionSchema = exports.TemplateSuggestionSchema.extend({
|
|
15
13
|
workspaceId: zod_1.z.string().nullable(),
|
|
16
14
|
});
|
|
17
15
|
/** Available suggestion section types. */
|
|
18
16
|
exports.SUGGESTION_SECTION_TYPES = ['templates', 'most_used_user_templates'];
|
|
19
|
-
exports.SyncTemplateSuggestionsSchema = zod_1.z
|
|
20
|
-
.object({
|
|
17
|
+
exports.SyncTemplateSuggestionsSchema = zod_1.z.looseObject({
|
|
21
18
|
type: zod_1.z.enum(exports.SUGGESTION_SECTION_TYPES),
|
|
22
19
|
content: zod_1.z.object({
|
|
23
20
|
templates: zod_1.z.array(exports.TemplateSuggestionSchema),
|
|
24
21
|
locale: zod_1.z.string(),
|
|
25
22
|
}),
|
|
26
23
|
isDeleted: zod_1.z.boolean(),
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
exports.SyncWorkspaceTemplateSuggestionsSchema = zod_1.z
|
|
30
|
-
.object({
|
|
24
|
+
});
|
|
25
|
+
exports.SyncWorkspaceTemplateSuggestionsSchema = zod_1.z.looseObject({
|
|
31
26
|
type: zod_1.z.literal('most_used_workspace_templates'),
|
|
32
27
|
content: zod_1.z.object({
|
|
33
28
|
templates: zod_1.z.array(exports.WorkspaceTemplateSuggestionSchema),
|
|
34
29
|
locale: zod_1.z.string(),
|
|
35
30
|
}),
|
|
36
31
|
isDeleted: zod_1.z.boolean(),
|
|
37
|
-
})
|
|
38
|
-
.passthrough();
|
|
32
|
+
});
|
|
39
33
|
exports.SuggestionSchema = zod_1.z.union([
|
|
40
34
|
exports.SyncWorkspaceTemplateSuggestionsSchema,
|
|
41
35
|
exports.SyncTemplateSuggestionsSchema,
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TooltipsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.TooltipsSchema = zod_1.z
|
|
6
|
-
.object({
|
|
5
|
+
exports.TooltipsSchema = zod_1.z.looseObject({
|
|
7
6
|
seen: zod_1.z.array(zod_1.z.string()).optional(),
|
|
8
7
|
scheduled: zod_1.z.array(zod_1.z.string()).optional(),
|
|
9
|
-
})
|
|
10
|
-
.passthrough();
|
|
8
|
+
});
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserPlanLimitsSchema = exports.PlanLimitsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.PlanLimitsSchema = zod_1.z
|
|
6
|
-
.object({
|
|
5
|
+
exports.PlanLimitsSchema = zod_1.z.looseObject({
|
|
7
6
|
activeProjects: zod_1.z.number().int().optional(),
|
|
8
7
|
activityLog: zod_1.z.number().int().optional(),
|
|
9
8
|
collaboratorsPerProject: zod_1.z.number().int().optional(),
|
|
@@ -14,11 +13,8 @@ exports.PlanLimitsSchema = zod_1.z
|
|
|
14
13
|
remindersPerUser: zod_1.z.number().int().optional(),
|
|
15
14
|
sectionsPerProject: zod_1.z.number().int().optional(),
|
|
16
15
|
tasksPerProject: zod_1.z.number().int().optional(),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
exports.UserPlanLimitsSchema = zod_1.z
|
|
20
|
-
.object({
|
|
16
|
+
});
|
|
17
|
+
exports.UserPlanLimitsSchema = zod_1.z.looseObject({
|
|
21
18
|
current: exports.PlanLimitsSchema,
|
|
22
19
|
next: exports.PlanLimitsSchema.nullable(),
|
|
23
|
-
})
|
|
24
|
-
.passthrough();
|
|
20
|
+
});
|
|
@@ -13,8 +13,7 @@ exports.QuickAddFeatureSchema = zod_1.z.object({
|
|
|
13
13
|
/**
|
|
14
14
|
* Sync API user settings resource.
|
|
15
15
|
*/
|
|
16
|
-
exports.UserSettingsSchema = zod_1.z
|
|
17
|
-
.object({
|
|
16
|
+
exports.UserSettingsSchema = zod_1.z.looseObject({
|
|
18
17
|
completedSoundDesktop: zod_1.z.boolean(),
|
|
19
18
|
completedSoundMobile: zod_1.z.boolean(),
|
|
20
19
|
debugLogSendingEnabledUntil: zod_1.z.string().nullable(),
|
|
@@ -24,7 +23,7 @@ exports.UserSettingsSchema = zod_1.z
|
|
|
24
23
|
countsShown: zod_1.z.boolean(),
|
|
25
24
|
features: zod_1.z.array(exports.NavigationFeatureSchema),
|
|
26
25
|
})
|
|
27
|
-
.
|
|
26
|
+
.loose(),
|
|
28
27
|
reminderDesktop: zod_1.z.boolean(),
|
|
29
28
|
reminderEmail: zod_1.z.boolean(),
|
|
30
29
|
reminderPush: zod_1.z.boolean(),
|
|
@@ -37,6 +36,5 @@ exports.UserSettingsSchema = zod_1.z
|
|
|
37
36
|
labelsShown: zod_1.z.boolean(),
|
|
38
37
|
features: zod_1.z.array(exports.QuickAddFeatureSchema),
|
|
39
38
|
})
|
|
40
|
-
.
|
|
41
|
-
})
|
|
42
|
-
.passthrough();
|
|
39
|
+
.loose(),
|
|
40
|
+
});
|
|
@@ -4,8 +4,7 @@ exports.SyncUserSchema = exports.GettingStartedGuideProjectSchema = exports.Join
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const types_1 = require("../../users/types");
|
|
6
6
|
const user_preferences_1 = require("../user-preferences");
|
|
7
|
-
exports.FeaturesSchema = zod_1.z
|
|
8
|
-
.object({
|
|
7
|
+
exports.FeaturesSchema = zod_1.z.looseObject({
|
|
9
8
|
karmaDisabled: zod_1.z.boolean(),
|
|
10
9
|
restriction: zod_1.z.number().int(),
|
|
11
10
|
karmaVacation: zod_1.z.boolean(),
|
|
@@ -16,40 +15,32 @@ exports.FeaturesSchema = zod_1.z
|
|
|
16
15
|
autoInviteDisabled: zod_1.z.boolean().optional(),
|
|
17
16
|
goldTheme: zod_1.z.boolean().optional(),
|
|
18
17
|
migratedFromTdb: zod_1.z.boolean().optional(),
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
exports.TzInfoSchema = zod_1.z
|
|
22
|
-
.object({
|
|
18
|
+
});
|
|
19
|
+
exports.TzInfoSchema = zod_1.z.looseObject({
|
|
23
20
|
timezone: zod_1.z.string(),
|
|
24
21
|
hours: zod_1.z.number().int(),
|
|
25
22
|
minutes: zod_1.z.number().int(),
|
|
26
23
|
isDst: user_preferences_1.BooleanFromZeroOneSchema,
|
|
27
24
|
gmtString: zod_1.z.string(),
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
exports.JoinableWorkspaceSchema = zod_1.z
|
|
31
|
-
.object({
|
|
25
|
+
});
|
|
26
|
+
exports.JoinableWorkspaceSchema = zod_1.z.looseObject({
|
|
32
27
|
workspaceId: zod_1.z.string(),
|
|
33
28
|
workspaceName: zod_1.z.string(),
|
|
34
29
|
memberCount: zod_1.z.number().int(),
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
exports.GettingStartedGuideProjectSchema = zod_1.z
|
|
38
|
-
.object({
|
|
30
|
+
});
|
|
31
|
+
exports.GettingStartedGuideProjectSchema = zod_1.z.looseObject({
|
|
39
32
|
onboardingUseCase: zod_1.z.string(),
|
|
40
33
|
projectId: zod_1.z.string(),
|
|
41
34
|
completed: zod_1.z.boolean(),
|
|
42
35
|
closed: zod_1.z.boolean(),
|
|
43
|
-
})
|
|
44
|
-
.passthrough();
|
|
36
|
+
});
|
|
45
37
|
/**
|
|
46
38
|
* Sync API user resource.
|
|
47
39
|
*
|
|
48
40
|
* This is a superset of the REST `CurrentUserSchema` — the Sync API returns
|
|
49
41
|
* many additional fields for features, onboarding state, and account details.
|
|
50
42
|
*/
|
|
51
|
-
exports.SyncUserSchema = zod_1.z
|
|
52
|
-
.object({
|
|
43
|
+
exports.SyncUserSchema = zod_1.z.looseObject({
|
|
53
44
|
id: zod_1.z.string(),
|
|
54
45
|
email: zod_1.z.string(),
|
|
55
46
|
fullName: zod_1.z.string(),
|
|
@@ -116,5 +107,4 @@ exports.SyncUserSchema = zod_1.z
|
|
|
116
107
|
websocketUrl: zod_1.z.string(),
|
|
117
108
|
weekendStartDay: zod_1.z.number().int(),
|
|
118
109
|
weeklyGoal: zod_1.z.number().int(),
|
|
119
|
-
})
|
|
120
|
-
.passthrough();
|
|
110
|
+
});
|
|
@@ -52,13 +52,10 @@ exports.SORT_ORDERS = ['ASC', 'DESC'];
|
|
|
52
52
|
exports.SortOrderSchema = zod_1.z.enum(exports.SORT_ORDERS).nullable();
|
|
53
53
|
/** Available calendar layout modes. */
|
|
54
54
|
exports.CALENDAR_LAYOUTS = ['WEEK', 'MONTH'];
|
|
55
|
-
exports.CalendarSettingsSchema = zod_1.z
|
|
56
|
-
.object({
|
|
55
|
+
exports.CalendarSettingsSchema = zod_1.z.looseObject({
|
|
57
56
|
layout: zod_1.z.enum(exports.CALENDAR_LAYOUTS).optional(),
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
exports.ViewOptionsSchema = zod_1.z
|
|
61
|
-
.object({
|
|
57
|
+
});
|
|
58
|
+
exports.ViewOptionsSchema = zod_1.z.looseObject({
|
|
62
59
|
viewType: exports.ViewTypeSchema,
|
|
63
60
|
objectId: zod_1.z.string().optional(),
|
|
64
61
|
groupedBy: exports.GroupedBySchema.optional(),
|
|
@@ -67,10 +64,8 @@ exports.ViewOptionsSchema = zod_1.z
|
|
|
67
64
|
showCompletedTasks: zod_1.z.boolean().optional(),
|
|
68
65
|
sortedBy: exports.SortedBySchema.optional(),
|
|
69
66
|
sortOrder: exports.SortOrderSchema.optional(),
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
exports.ProjectViewOptionsDefaultsSchema = zod_1.z
|
|
73
|
-
.object({
|
|
67
|
+
});
|
|
68
|
+
exports.ProjectViewOptionsDefaultsSchema = zod_1.z.looseObject({
|
|
74
69
|
projectId: zod_1.z.string(),
|
|
75
70
|
viewMode: exports.ViewModeSchema.nullable().optional(),
|
|
76
71
|
groupedBy: exports.GroupedBySchema.optional(),
|
|
@@ -79,5 +74,4 @@ exports.ProjectViewOptionsDefaultsSchema = zod_1.z
|
|
|
79
74
|
showCompletedTasks: zod_1.z.boolean().optional(),
|
|
80
75
|
filteredBy: zod_1.z.string().nullable().optional(),
|
|
81
76
|
calendarSettings: exports.CalendarSettingsSchema.nullable().optional(),
|
|
82
|
-
})
|
|
83
|
-
.passthrough();
|
|
77
|
+
});
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WorkspaceFilterSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.WorkspaceFilterSchema = zod_1.z
|
|
6
|
-
.object({
|
|
5
|
+
exports.WorkspaceFilterSchema = zod_1.z.looseObject({
|
|
7
6
|
id: zod_1.z.string(),
|
|
8
7
|
workspaceId: zod_1.z.string(),
|
|
9
8
|
name: zod_1.z.string(),
|
|
@@ -17,5 +16,4 @@ exports.WorkspaceFilterSchema = zod_1.z
|
|
|
17
16
|
updaterUid: zod_1.z.string(),
|
|
18
17
|
createdAt: zod_1.z.string(),
|
|
19
18
|
updatedAt: zod_1.z.string(),
|
|
20
|
-
})
|
|
21
|
-
.passthrough();
|
|
19
|
+
});
|
|
@@ -2,21 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WorkspaceGoalSchema = exports.WorkspaceGoalProgressSchema = exports.WorkspaceGoalMilestoneSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
exports.WorkspaceGoalMilestoneSchema = zod_1.z
|
|
6
|
-
.object({
|
|
5
|
+
exports.WorkspaceGoalMilestoneSchema = zod_1.z.looseObject({
|
|
7
6
|
id: zod_1.z.string(),
|
|
8
7
|
title: zod_1.z.string(),
|
|
9
8
|
isCompleted: zod_1.z.boolean(),
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
exports.WorkspaceGoalProgressSchema = zod_1.z
|
|
13
|
-
.object({
|
|
9
|
+
});
|
|
10
|
+
exports.WorkspaceGoalProgressSchema = zod_1.z.looseObject({
|
|
14
11
|
completedItems: zod_1.z.number().int(),
|
|
15
12
|
totalItems: zod_1.z.number().int(),
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
exports.WorkspaceGoalSchema = zod_1.z
|
|
19
|
-
.object({
|
|
13
|
+
});
|
|
14
|
+
exports.WorkspaceGoalSchema = zod_1.z.looseObject({
|
|
20
15
|
id: zod_1.z.string(),
|
|
21
16
|
workspaceId: zod_1.z.string(),
|
|
22
17
|
title: zod_1.z.string(),
|
|
@@ -28,5 +23,4 @@ exports.WorkspaceGoalSchema = zod_1.z
|
|
|
28
23
|
creatorUid: zod_1.z.string(),
|
|
29
24
|
createdAt: zod_1.z.string(),
|
|
30
25
|
updatedAt: zod_1.z.string(),
|
|
31
|
-
})
|
|
32
|
-
.passthrough();
|
|
26
|
+
});
|
|
@@ -23,7 +23,7 @@ const types_1 = require("../../workspaces/types");
|
|
|
23
23
|
* domain settings, and sorting preferences.
|
|
24
24
|
*/
|
|
25
25
|
exports.SyncWorkspaceSchema = zod_1.z
|
|
26
|
-
.
|
|
26
|
+
.looseObject({
|
|
27
27
|
id: common_1.StringOrNumberSchema,
|
|
28
28
|
name: zod_1.z.string(),
|
|
29
29
|
description: zod_1.z.string(),
|
|
@@ -66,7 +66,6 @@ exports.SyncWorkspaceSchema = zod_1.z
|
|
|
66
66
|
.optional(),
|
|
67
67
|
properties: types_1.WorkspacePropertiesSchema.optional(),
|
|
68
68
|
})
|
|
69
|
-
.passthrough()
|
|
70
69
|
.transform((_a) => {
|
|
71
70
|
var { dateCreated, createdAt } = _a, rest = __rest(_a, ["dateCreated", "createdAt"]);
|
|
72
71
|
return (Object.assign(Object.assign({}, rest), { createdAt: createdAt !== null && createdAt !== void 0 ? createdAt : dateCreated }));
|
|
@@ -7,6 +7,7 @@ exports.isPersonalProject = isPersonalProject;
|
|
|
7
7
|
exports.validateProject = validateProject;
|
|
8
8
|
exports.validateProjectArray = validateProjectArray;
|
|
9
9
|
exports.validateWorkspaceUserArray = validateWorkspaceUserArray;
|
|
10
|
+
exports.parseSyncResponse = parseSyncResponse;
|
|
10
11
|
const types_1 = require("../types/activity/types");
|
|
11
12
|
const types_2 = require("../types/backups/types");
|
|
12
13
|
const types_3 = require("../types/comments/types");
|
|
@@ -24,7 +25,12 @@ function createValidator(schema) {
|
|
|
24
25
|
return (input) => schema.parse(input);
|
|
25
26
|
}
|
|
26
27
|
function createArrayValidator(validateItem) {
|
|
27
|
-
return (input) =>
|
|
28
|
+
return (input) => {
|
|
29
|
+
if (!Array.isArray(input)) {
|
|
30
|
+
throw new TypeError(`Expected array, got ${typeof input}`);
|
|
31
|
+
}
|
|
32
|
+
return input.map(validateItem);
|
|
33
|
+
};
|
|
28
34
|
}
|
|
29
35
|
// Entity validators
|
|
30
36
|
exports.validateTask = createValidator(types_10.TaskSchema);
|
|
@@ -57,6 +63,9 @@ function validateProject(input) {
|
|
|
57
63
|
return types_8.PersonalProjectSchema.parse(input);
|
|
58
64
|
}
|
|
59
65
|
function validateProjectArray(input) {
|
|
66
|
+
if (!Array.isArray(input)) {
|
|
67
|
+
throw new TypeError(`Expected array, got ${typeof input}`);
|
|
68
|
+
}
|
|
60
69
|
return input.map(validateProject);
|
|
61
70
|
}
|
|
62
71
|
exports.validateWorkspaceProject = createValidator(types_8.WorkspaceProjectSchema);
|
|
@@ -141,3 +150,30 @@ exports.validateSyncUser = createValidator(resources_1.SyncUserSchema);
|
|
|
141
150
|
exports.validateUserSettings = createValidator(resources_1.UserSettingsSchema);
|
|
142
151
|
exports.validateSuggestion = createValidator(resources_1.SuggestionSchema);
|
|
143
152
|
exports.validateSuggestionArray = createArrayValidator(exports.validateSuggestion);
|
|
153
|
+
function parseSyncResponse(raw) {
|
|
154
|
+
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: (0, exports.validateTaskArray)(raw.items) } : {})), ('projects' in raw ? { projects: validateProjectArray(raw.projects) } : {})), ('sections' in raw ? { sections: (0, exports.validateSectionArray)(raw.sections) } : {})), ('labels' in raw ? { labels: (0, exports.validateLabelArray)(raw.labels) } : {})), ('notes' in raw ? { notes: (0, exports.validateNoteArray)(raw.notes) } : {})), ('projectNotes' in raw ? { projectNotes: (0, exports.validateNoteArray)(raw.projectNotes) } : {})), ('filters' in raw ? { filters: (0, exports.validateFilterArray)(raw.filters) } : {})), ('reminders' in raw ? { reminders: (0, exports.validateReminderArray)(raw.reminders) } : {})), ('remindersLocation' in raw
|
|
155
|
+
? { remindersLocation: (0, exports.validateLocationReminderArray)(raw.remindersLocation) }
|
|
156
|
+
: {})), ('user' in raw ? { user: (0, exports.validateSyncUser)(raw.user) } : {})), ('liveNotifications' in raw
|
|
157
|
+
? { liveNotifications: (0, exports.validateLiveNotificationArray)(raw.liveNotifications) }
|
|
158
|
+
: {})), ('collaborators' in raw
|
|
159
|
+
? { collaborators: (0, exports.validateCollaboratorArray)(raw.collaborators) }
|
|
160
|
+
: {})), ('collaboratorStates' in raw
|
|
161
|
+
? { collaboratorStates: (0, exports.validateCollaboratorStateArray)(raw.collaboratorStates) }
|
|
162
|
+
: {})), ('userSettings' in raw ? { userSettings: (0, exports.validateUserSettings)(raw.userSettings) } : {})), ('userPlanLimits' in raw
|
|
163
|
+
? { userPlanLimits: (0, exports.validateUserPlanLimits)(raw.userPlanLimits) }
|
|
164
|
+
: {})), ('completedInfo' in raw
|
|
165
|
+
? { completedInfo: (0, exports.validateCompletedInfoArray)(raw.completedInfo) }
|
|
166
|
+
: {})), ('workspaces' in raw ? { workspaces: (0, exports.validateSyncWorkspaceArray)(raw.workspaces) } : {})), ('workspaceUsers' in raw
|
|
167
|
+
? { workspaceUsers: validateWorkspaceUserArray(raw.workspaceUsers) }
|
|
168
|
+
: {})), ('workspaceFilters' in raw
|
|
169
|
+
? { workspaceFilters: (0, exports.validateWorkspaceFilterArray)(raw.workspaceFilters) }
|
|
170
|
+
: {})), ('viewOptions' in raw ? { viewOptions: (0, exports.validateViewOptionsArray)(raw.viewOptions) } : {})), ('projectViewOptionsDefaults' in raw
|
|
171
|
+
? {
|
|
172
|
+
projectViewOptionsDefaults: (0, exports.validateProjectViewOptionsDefaultsArray)(raw.projectViewOptionsDefaults),
|
|
173
|
+
}
|
|
174
|
+
: {})), ('folders' in raw ? { folders: (0, exports.validateFolderArray)(raw.folders) } : {})), ('workspaceGoals' in raw
|
|
175
|
+
? { workspaceGoals: (0, exports.validateWorkspaceGoalArray)(raw.workspaceGoals) }
|
|
176
|
+
: {})), ('calendars' in raw ? { calendars: (0, exports.validateCalendarArray)(raw.calendars) } : {})), ('calendarAccounts' in raw
|
|
177
|
+
? { calendarAccounts: (0, exports.validateCalendarAccountArray)(raw.calendarAccounts) }
|
|
178
|
+
: {})), ('suggestions' in raw ? { suggestions: (0, exports.validateSuggestionArray)(raw.suggestions) } : {})), ('tooltips' in raw ? { tooltips: (0, exports.validateTooltips)(raw.tooltips) } : {}));
|
|
179
|
+
}
|