@doist/todoist-api-typescript 6.7.0 → 6.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/todoist-api.js +53 -5
- package/dist/cjs/types/sync/index.js +1 -0
- package/dist/cjs/types/sync/resources/live-notifications.js +11 -0
- package/dist/cjs/types/sync/resources/user.js +7 -6
- package/dist/cjs/types/sync/resources/workspaces.js +7 -0
- package/dist/cjs/types/sync/user-preferences.js +51 -0
- package/dist/esm/todoist-api.js +53 -5
- package/dist/esm/types/sync/index.js +1 -0
- package/dist/esm/types/sync/resources/live-notifications.js +11 -0
- package/dist/esm/types/sync/resources/user.js +7 -6
- package/dist/esm/types/sync/resources/workspaces.js +7 -0
- package/dist/esm/types/sync/user-preferences.js +48 -0
- package/dist/types/types/requests.d.ts +14 -6
- package/dist/types/types/sync/commands/others.d.ts +14 -3
- package/dist/types/types/sync/commands/reminders.d.ts +13 -3
- package/dist/types/types/sync/commands/tasks.d.ts +2 -2
- package/dist/types/types/sync/index.d.ts +1 -0
- package/dist/types/types/sync/resources/live-notifications.d.ts +9 -0
- package/dist/types/types/sync/resources/user.d.ts +6 -6
- package/dist/types/types/sync/resources/workspaces.d.ts +5 -0
- package/dist/types/types/sync/user-preferences.d.ts +13 -0
- package/dist/types/utils/validators.d.ts +34 -6
- package/package.json +1 -1
package/dist/cjs/todoist-api.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.TodoistApi = void 0;
|
|
4
15
|
const rest_client_1 = require("./rest-client");
|
|
@@ -10,6 +21,7 @@ const activity_helpers_1 = require("./utils/activity-helpers");
|
|
|
10
21
|
const uncompletable_helpers_1 = require("./utils/uncompletable-helpers");
|
|
11
22
|
const zod_1 = require("zod");
|
|
12
23
|
const uuid_1 = require("uuid");
|
|
24
|
+
const sync_1 = require("./types/sync");
|
|
13
25
|
const types_1 = require("./types");
|
|
14
26
|
const MAX_COMMAND_COUNT = 100;
|
|
15
27
|
/**
|
|
@@ -20,6 +32,29 @@ const MAX_COMMAND_COUNT = 100;
|
|
|
20
32
|
function generatePath(...segments) {
|
|
21
33
|
return segments.join('/');
|
|
22
34
|
}
|
|
35
|
+
function spreadIfDefined(value, fn) {
|
|
36
|
+
return value !== undefined ? fn(value) : {};
|
|
37
|
+
}
|
|
38
|
+
function serializeUserUpdateArgs(args) {
|
|
39
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.dateFormat, (v) => ({ dateFormat: sync_1.DATE_FORMAT_TO_API[v] }))), spreadIfDefined(args.timeFormat, (v) => ({ timeFormat: sync_1.TIME_FORMAT_TO_API[v] }))), spreadIfDefined(args.startDay, (v) => ({ startDay: sync_1.DAY_OF_WEEK_TO_API[v] }))), spreadIfDefined(args.nextWeek, (v) => ({ nextWeek: sync_1.DAY_OF_WEEK_TO_API[v] })));
|
|
40
|
+
}
|
|
41
|
+
function serializeTaskUpdateDateCompleteArgs(args) {
|
|
42
|
+
return Object.assign(Object.assign(Object.assign({}, args), { isForward: args.isForward ? 1 : 0 }), spreadIfDefined(args.resetSubtasks, (v) => ({ resetSubtasks: v ? 1 : 0 })));
|
|
43
|
+
}
|
|
44
|
+
function serializeUpdateGoalsArgs(args) {
|
|
45
|
+
return Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.vacationMode, (v) => ({ vacationMode: v ? 1 : 0 }))), spreadIfDefined(args.karmaDisabled, (v) => ({ karmaDisabled: v ? 1 : 0 })));
|
|
46
|
+
}
|
|
47
|
+
function preprocessSyncCommands(commands) {
|
|
48
|
+
return commands.map((cmd) => {
|
|
49
|
+
if (cmd.type === 'user_update')
|
|
50
|
+
return Object.assign(Object.assign({}, cmd), { args: serializeUserUpdateArgs(cmd.args) });
|
|
51
|
+
if (cmd.type === 'item_update_date_complete')
|
|
52
|
+
return Object.assign(Object.assign({}, cmd), { args: serializeTaskUpdateDateCompleteArgs(cmd.args) });
|
|
53
|
+
if (cmd.type === 'update_goals')
|
|
54
|
+
return Object.assign(Object.assign({}, cmd), { args: serializeUpdateGoalsArgs(cmd.args) });
|
|
55
|
+
return cmd;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
23
58
|
class TodoistApi {
|
|
24
59
|
constructor(
|
|
25
60
|
/**
|
|
@@ -56,13 +91,16 @@ class TodoistApi {
|
|
|
56
91
|
* @throws TodoistRequestError if sync status contains errors
|
|
57
92
|
*/
|
|
58
93
|
async requestSync(syncRequest, requestId, hasSyncCommands = false) {
|
|
94
|
+
var _a;
|
|
95
|
+
const processedRequest = ((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length)
|
|
96
|
+
? Object.assign(Object.assign({}, syncRequest), { commands: preprocessSyncCommands(syncRequest.commands) }) : syncRequest;
|
|
59
97
|
const response = await (0, rest_client_1.request)({
|
|
60
98
|
httpMethod: 'POST',
|
|
61
99
|
baseUri: this.syncApiBase,
|
|
62
100
|
relativePath: endpoints_1.ENDPOINT_SYNC,
|
|
63
101
|
apiToken: this.authToken,
|
|
64
102
|
customFetch: this.customFetch,
|
|
65
|
-
payload:
|
|
103
|
+
payload: processedRequest,
|
|
66
104
|
requestId: requestId,
|
|
67
105
|
hasSyncCommands: hasSyncCommands,
|
|
68
106
|
});
|
|
@@ -317,7 +355,7 @@ class TodoistApi {
|
|
|
317
355
|
const commands = ids.map((id) => ({
|
|
318
356
|
type: 'item_move',
|
|
319
357
|
uuid: (0, uuid_1.v4)(),
|
|
320
|
-
args: Object.assign(Object.assign(Object.assign({ id }, (args.projectId
|
|
358
|
+
args: Object.assign(Object.assign(Object.assign({ id }, spreadIfDefined(args.projectId, (v) => ({ projectId: v }))), spreadIfDefined(args.sectionId, (v) => ({ sectionId: v }))), spreadIfDefined(args.parentId, (v) => ({ parentId: v }))),
|
|
321
359
|
}));
|
|
322
360
|
const syncRequest = {
|
|
323
361
|
commands,
|
|
@@ -349,7 +387,7 @@ class TodoistApi {
|
|
|
349
387
|
relativePath: generatePath(endpoints_1.ENDPOINT_REST_TASKS, id, endpoints_1.ENDPOINT_REST_TASK_MOVE),
|
|
350
388
|
apiToken: this.authToken,
|
|
351
389
|
customFetch: this.customFetch,
|
|
352
|
-
payload: Object.assign(Object.assign(Object.assign({}, (args.projectId
|
|
390
|
+
payload: Object.assign(Object.assign(Object.assign({}, spreadIfDefined(args.projectId, (v) => ({ project_id: v }))), spreadIfDefined(args.sectionId, (v) => ({ section_id: v }))), spreadIfDefined(args.parentId, (v) => ({ parent_id: v }))),
|
|
353
391
|
requestId: requestId,
|
|
354
392
|
});
|
|
355
393
|
return (0, validators_1.validateTask)(response.data);
|
|
@@ -1047,8 +1085,18 @@ class TodoistApi {
|
|
|
1047
1085
|
* @returns A promise that resolves to a paginated response of activity events.
|
|
1048
1086
|
*/
|
|
1049
1087
|
async getActivityLogs(args = {}) {
|
|
1050
|
-
|
|
1051
|
-
|
|
1088
|
+
var _a, _b;
|
|
1089
|
+
// Resolve dateFrom: prefer new param, fall back to deprecated `since`
|
|
1090
|
+
const rawDateFrom = (_a = args.dateFrom) !== null && _a !== void 0 ? _a : args.since;
|
|
1091
|
+
const rawDateTo = (_b = args.dateTo) !== null && _b !== void 0 ? _b : args.until;
|
|
1092
|
+
// Convert Date objects to YYYY-MM-DD strings
|
|
1093
|
+
const dateFrom = rawDateFrom instanceof Date ? (0, url_helpers_1.formatDateToYYYYMMDD)(rawDateFrom) : rawDateFrom;
|
|
1094
|
+
const dateTo = rawDateTo instanceof Date ? (0, url_helpers_1.formatDateToYYYYMMDD)(rawDateTo) : rawDateTo;
|
|
1095
|
+
// Destructure out deprecated and raw date fields so they don't leak into the payload
|
|
1096
|
+
const { since: _since, until: _until, dateFrom: _dateFrom, dateTo: _dateTo } = args, rest = __rest(args, ["since", "until", "dateFrom", "dateTo"]);
|
|
1097
|
+
const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), spreadIfDefined(args.objectType, (v) => ({
|
|
1098
|
+
objectType: (0, activity_helpers_1.normalizeObjectTypeForApi)(v),
|
|
1099
|
+
})));
|
|
1052
1100
|
const { data: { results, nextCursor }, } = await (0, rest_client_1.request)({
|
|
1053
1101
|
httpMethod: 'GET',
|
|
1054
1102
|
baseUri: this.syncApiBase,
|
|
@@ -24,5 +24,16 @@ exports.LiveNotificationSchema = zod_1.z
|
|
|
24
24
|
itemContent: zod_1.z.string().optional(),
|
|
25
25
|
responsibleUid: zod_1.z.string().optional(),
|
|
26
26
|
assignedByUid: zod_1.z.string().optional(),
|
|
27
|
+
fromUser: zod_1.z
|
|
28
|
+
.object({
|
|
29
|
+
email: zod_1.z.string(),
|
|
30
|
+
fullName: zod_1.z.string(),
|
|
31
|
+
id: zod_1.z.string(),
|
|
32
|
+
imageId: zod_1.z.string().nullable(),
|
|
33
|
+
})
|
|
34
|
+
.optional(),
|
|
35
|
+
projectName: zod_1.z.string().optional(),
|
|
36
|
+
isDeleted: zod_1.z.boolean().optional(),
|
|
37
|
+
invitationSecret: zod_1.z.string().optional(),
|
|
27
38
|
})
|
|
28
39
|
.passthrough();
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SyncUserSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
+
const user_preferences_1 = require("../user-preferences");
|
|
5
6
|
const FeaturesSchema = zod_1.z
|
|
6
7
|
.object({
|
|
7
8
|
karmaDisabled: zod_1.z.boolean(),
|
|
8
9
|
restriction: zod_1.z.number().int(),
|
|
9
10
|
karmaVacation: zod_1.z.boolean(),
|
|
10
11
|
dateistLang: zod_1.z.any(),
|
|
11
|
-
beta:
|
|
12
|
+
beta: user_preferences_1.BooleanFromZeroOneSchema,
|
|
12
13
|
hasPushReminders: zod_1.z.boolean(),
|
|
13
14
|
dateistInlineDisabled: zod_1.z.boolean(),
|
|
14
15
|
autoInviteDisabled: zod_1.z.boolean().optional(),
|
|
@@ -21,7 +22,7 @@ const TzInfoSchema = zod_1.z
|
|
|
21
22
|
timezone: zod_1.z.string(),
|
|
22
23
|
hours: zod_1.z.number().int(),
|
|
23
24
|
minutes: zod_1.z.number().int(),
|
|
24
|
-
isDst:
|
|
25
|
+
isDst: user_preferences_1.BooleanFromZeroOneSchema,
|
|
25
26
|
gmtString: zod_1.z.string(),
|
|
26
27
|
})
|
|
27
28
|
.passthrough();
|
|
@@ -59,7 +60,7 @@ exports.SyncUserSchema = zod_1.z
|
|
|
59
60
|
avatarSmall: zod_1.z.string().optional(),
|
|
60
61
|
businessAccountId: zod_1.z.string().nullable(),
|
|
61
62
|
dailyGoal: zod_1.z.number().int(),
|
|
62
|
-
dateFormat:
|
|
63
|
+
dateFormat: user_preferences_1.DateFormatSchema,
|
|
63
64
|
dateistLang: zod_1.z.string().nullable(),
|
|
64
65
|
daysOff: zod_1.z.array(zod_1.z.number().int()),
|
|
65
66
|
featureIdentifier: zod_1.z.string(),
|
|
@@ -81,7 +82,7 @@ exports.SyncUserSchema = zod_1.z
|
|
|
81
82
|
mfaEnabled: zod_1.z.boolean().optional(),
|
|
82
83
|
mobileHost: zod_1.z.string().nullable(),
|
|
83
84
|
mobileNumber: zod_1.z.string().nullable(),
|
|
84
|
-
nextWeek:
|
|
85
|
+
nextWeek: user_preferences_1.DayOfWeekSchema,
|
|
85
86
|
onboardingLevel: zod_1.z.string().nullable().optional(),
|
|
86
87
|
onboardingRole: zod_1.z.string().nullable().optional(),
|
|
87
88
|
onboardingPersona: zod_1.z.string().nullable().optional(),
|
|
@@ -108,10 +109,10 @@ exports.SyncUserSchema = zod_1.z
|
|
|
108
109
|
.optional(),
|
|
109
110
|
shareLimit: zod_1.z.number().int(),
|
|
110
111
|
sortOrder: zod_1.z.number().int(),
|
|
111
|
-
startDay:
|
|
112
|
+
startDay: user_preferences_1.DayOfWeekSchema,
|
|
112
113
|
startPage: zod_1.z.string(),
|
|
113
114
|
themeId: zod_1.z.string(),
|
|
114
|
-
timeFormat:
|
|
115
|
+
timeFormat: user_preferences_1.TimeFormatSchema,
|
|
115
116
|
token: zod_1.z.string(),
|
|
116
117
|
tzInfo: TzInfoSchema,
|
|
117
118
|
uniquePrefix: zod_1.z.number().int(),
|
|
@@ -31,6 +31,13 @@ exports.SyncWorkspaceSchema = zod_1.z
|
|
|
31
31
|
isGuestAllowed: zod_1.z.boolean().nullable().optional(),
|
|
32
32
|
currentActiveProjects: zod_1.z.number().nullable(),
|
|
33
33
|
currentMemberCount: zod_1.z.number().nullable(),
|
|
34
|
+
memberCountByType: zod_1.z
|
|
35
|
+
.object({
|
|
36
|
+
adminCount: zod_1.z.number().int(),
|
|
37
|
+
guestCount: zod_1.z.number().int(),
|
|
38
|
+
memberCount: zod_1.z.number().int(),
|
|
39
|
+
})
|
|
40
|
+
.optional(),
|
|
34
41
|
currentTemplateCount: zod_1.z.number().nullable(),
|
|
35
42
|
pendingInvitations: zod_1.z.array(zod_1.z.string()).nullable().optional(),
|
|
36
43
|
domainName: zod_1.z.string().optional(),
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DayOfWeekSchema = exports.TimeFormatSchema = exports.DateFormatSchema = exports.BooleanFromZeroOneSchema = exports.DAY_OF_WEEK_TO_API = exports.TIME_FORMAT_TO_API = exports.DATE_FORMAT_TO_API = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const DATE_FORMAT_FROM_API = { 0: 'DD/MM/YYYY', 1: 'MM/DD/YYYY' };
|
|
6
|
+
const TIME_FORMAT_FROM_API = { 0: '24h', 1: '12h' };
|
|
7
|
+
const DAY_OF_WEEK_FROM_API = {
|
|
8
|
+
1: 'Monday',
|
|
9
|
+
2: 'Tuesday',
|
|
10
|
+
3: 'Wednesday',
|
|
11
|
+
4: 'Thursday',
|
|
12
|
+
5: 'Friday',
|
|
13
|
+
6: 'Saturday',
|
|
14
|
+
7: 'Sunday',
|
|
15
|
+
};
|
|
16
|
+
exports.DATE_FORMAT_TO_API = {
|
|
17
|
+
'DD/MM/YYYY': 0,
|
|
18
|
+
'MM/DD/YYYY': 1,
|
|
19
|
+
};
|
|
20
|
+
exports.TIME_FORMAT_TO_API = { '24h': 0, '12h': 1 };
|
|
21
|
+
exports.DAY_OF_WEEK_TO_API = {
|
|
22
|
+
Monday: 1,
|
|
23
|
+
Tuesday: 2,
|
|
24
|
+
Wednesday: 3,
|
|
25
|
+
Thursday: 4,
|
|
26
|
+
Friday: 5,
|
|
27
|
+
Saturday: 6,
|
|
28
|
+
Sunday: 7,
|
|
29
|
+
};
|
|
30
|
+
/** Zod read-schema: parse API 0/1 integer, emit boolean */
|
|
31
|
+
exports.BooleanFromZeroOneSchema = zod_1.z
|
|
32
|
+
.union([zod_1.z.literal(0), zod_1.z.literal(1)])
|
|
33
|
+
.transform((v) => v === 1);
|
|
34
|
+
/** Zod read-schemas: parse API numbers, emit descriptive strings */
|
|
35
|
+
exports.DateFormatSchema = zod_1.z
|
|
36
|
+
.union([zod_1.z.literal(0), zod_1.z.literal(1)])
|
|
37
|
+
.transform((v) => DATE_FORMAT_FROM_API[v]);
|
|
38
|
+
exports.TimeFormatSchema = zod_1.z
|
|
39
|
+
.union([zod_1.z.literal(0), zod_1.z.literal(1)])
|
|
40
|
+
.transform((v) => TIME_FORMAT_FROM_API[v]);
|
|
41
|
+
exports.DayOfWeekSchema = zod_1.z
|
|
42
|
+
.union([
|
|
43
|
+
zod_1.z.literal(1),
|
|
44
|
+
zod_1.z.literal(2),
|
|
45
|
+
zod_1.z.literal(3),
|
|
46
|
+
zod_1.z.literal(4),
|
|
47
|
+
zod_1.z.literal(5),
|
|
48
|
+
zod_1.z.literal(6),
|
|
49
|
+
zod_1.z.literal(7),
|
|
50
|
+
])
|
|
51
|
+
.transform((v) => DAY_OF_WEEK_FROM_API[v]);
|
package/dist/esm/todoist-api.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { request, isSuccess } from './rest-client.js';
|
|
2
13
|
import { getSyncBaseUri, ENDPOINT_REST_TASKS, ENDPOINT_REST_TASKS_FILTER, ENDPOINT_REST_TASKS_COMPLETED_BY_COMPLETION_DATE, ENDPOINT_REST_TASKS_COMPLETED_BY_DUE_DATE, ENDPOINT_REST_TASKS_COMPLETED_SEARCH, ENDPOINT_REST_PROJECTS, ENDPOINT_REST_PROJECTS_SEARCH, ENDPOINT_SYNC_QUICK_ADD, ENDPOINT_REST_TASK_CLOSE, ENDPOINT_REST_TASK_REOPEN, ENDPOINT_REST_TASK_MOVE, ENDPOINT_REST_LABELS, ENDPOINT_REST_LABELS_SEARCH, ENDPOINT_REST_PROJECT_COLLABORATORS, ENDPOINT_REST_SECTIONS, ENDPOINT_REST_SECTIONS_SEARCH, ENDPOINT_REST_COMMENTS, ENDPOINT_REST_LABELS_SHARED, ENDPOINT_REST_LABELS_SHARED_RENAME, ENDPOINT_REST_LABELS_SHARED_REMOVE, ENDPOINT_SYNC, PROJECT_ARCHIVE, PROJECT_UNARCHIVE, ENDPOINT_REST_PROJECTS_MOVE_TO_WORKSPACE, ENDPOINT_REST_PROJECTS_MOVE_TO_PERSONAL, ENDPOINT_REST_PROJECTS_ARCHIVED, ENDPOINT_REST_USER, ENDPOINT_REST_PRODUCTIVITY, ENDPOINT_REST_ACTIVITIES, ENDPOINT_REST_UPLOADS, ENDPOINT_WORKSPACE_INVITATIONS, ENDPOINT_WORKSPACE_INVITATIONS_ALL, ENDPOINT_WORKSPACE_INVITATIONS_DELETE, getWorkspaceInvitationAcceptEndpoint, getWorkspaceInvitationRejectEndpoint, ENDPOINT_WORKSPACE_JOIN, ENDPOINT_WORKSPACE_LOGO, ENDPOINT_WORKSPACE_PLAN_DETAILS, ENDPOINT_WORKSPACE_USERS, getWorkspaceActiveProjectsEndpoint, getWorkspaceArchivedProjectsEndpoint, } from './consts/endpoints.js';
|
|
3
14
|
import { validateAttachment, validateComment, validateCommentArray, validateCurrentUser, validateLabel, validateLabelArray, validateProject, validateProjectArray, validateSection, validateSectionArray, validateTask, validateTaskArray, validateUserArray, validateProductivityStats, validateActivityEventArray, validateWorkspaceUserArray, validateWorkspaceInvitation, validateWorkspaceInvitationArray, validateWorkspacePlanDetails, validateJoinWorkspaceResult, validateWorkspaceArray, } from './utils/validators.js';
|
|
@@ -7,6 +18,7 @@ import { normalizeObjectTypeForApi, denormalizeObjectTypeFromApi } from './utils
|
|
|
7
18
|
import { processTaskContent } from './utils/uncompletable-helpers.js';
|
|
8
19
|
import { z } from 'zod';
|
|
9
20
|
import { v4 as uuidv4 } from 'uuid';
|
|
21
|
+
import { DATE_FORMAT_TO_API, TIME_FORMAT_TO_API, DAY_OF_WEEK_TO_API, } from './types/sync/index.js';
|
|
10
22
|
import { TodoistRequestError } from './types/index.js';
|
|
11
23
|
const MAX_COMMAND_COUNT = 100;
|
|
12
24
|
/**
|
|
@@ -17,6 +29,29 @@ const MAX_COMMAND_COUNT = 100;
|
|
|
17
29
|
function generatePath(...segments) {
|
|
18
30
|
return segments.join('/');
|
|
19
31
|
}
|
|
32
|
+
function spreadIfDefined(value, fn) {
|
|
33
|
+
return value !== undefined ? fn(value) : {};
|
|
34
|
+
}
|
|
35
|
+
function serializeUserUpdateArgs(args) {
|
|
36
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.dateFormat, (v) => ({ dateFormat: DATE_FORMAT_TO_API[v] }))), spreadIfDefined(args.timeFormat, (v) => ({ timeFormat: TIME_FORMAT_TO_API[v] }))), spreadIfDefined(args.startDay, (v) => ({ startDay: DAY_OF_WEEK_TO_API[v] }))), spreadIfDefined(args.nextWeek, (v) => ({ nextWeek: DAY_OF_WEEK_TO_API[v] })));
|
|
37
|
+
}
|
|
38
|
+
function serializeTaskUpdateDateCompleteArgs(args) {
|
|
39
|
+
return Object.assign(Object.assign(Object.assign({}, args), { isForward: args.isForward ? 1 : 0 }), spreadIfDefined(args.resetSubtasks, (v) => ({ resetSubtasks: v ? 1 : 0 })));
|
|
40
|
+
}
|
|
41
|
+
function serializeUpdateGoalsArgs(args) {
|
|
42
|
+
return Object.assign(Object.assign(Object.assign({}, args), spreadIfDefined(args.vacationMode, (v) => ({ vacationMode: v ? 1 : 0 }))), spreadIfDefined(args.karmaDisabled, (v) => ({ karmaDisabled: v ? 1 : 0 })));
|
|
43
|
+
}
|
|
44
|
+
function preprocessSyncCommands(commands) {
|
|
45
|
+
return commands.map((cmd) => {
|
|
46
|
+
if (cmd.type === 'user_update')
|
|
47
|
+
return Object.assign(Object.assign({}, cmd), { args: serializeUserUpdateArgs(cmd.args) });
|
|
48
|
+
if (cmd.type === 'item_update_date_complete')
|
|
49
|
+
return Object.assign(Object.assign({}, cmd), { args: serializeTaskUpdateDateCompleteArgs(cmd.args) });
|
|
50
|
+
if (cmd.type === 'update_goals')
|
|
51
|
+
return Object.assign(Object.assign({}, cmd), { args: serializeUpdateGoalsArgs(cmd.args) });
|
|
52
|
+
return cmd;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
20
55
|
export class TodoistApi {
|
|
21
56
|
constructor(
|
|
22
57
|
/**
|
|
@@ -53,13 +88,16 @@ export class TodoistApi {
|
|
|
53
88
|
* @throws TodoistRequestError if sync status contains errors
|
|
54
89
|
*/
|
|
55
90
|
async requestSync(syncRequest, requestId, hasSyncCommands = false) {
|
|
91
|
+
var _a;
|
|
92
|
+
const processedRequest = ((_a = syncRequest.commands) === null || _a === void 0 ? void 0 : _a.length)
|
|
93
|
+
? Object.assign(Object.assign({}, syncRequest), { commands: preprocessSyncCommands(syncRequest.commands) }) : syncRequest;
|
|
56
94
|
const response = await request({
|
|
57
95
|
httpMethod: 'POST',
|
|
58
96
|
baseUri: this.syncApiBase,
|
|
59
97
|
relativePath: ENDPOINT_SYNC,
|
|
60
98
|
apiToken: this.authToken,
|
|
61
99
|
customFetch: this.customFetch,
|
|
62
|
-
payload:
|
|
100
|
+
payload: processedRequest,
|
|
63
101
|
requestId: requestId,
|
|
64
102
|
hasSyncCommands: hasSyncCommands,
|
|
65
103
|
});
|
|
@@ -314,7 +352,7 @@ export class TodoistApi {
|
|
|
314
352
|
const commands = ids.map((id) => ({
|
|
315
353
|
type: 'item_move',
|
|
316
354
|
uuid: uuidv4(),
|
|
317
|
-
args: Object.assign(Object.assign(Object.assign({ id }, (args.projectId
|
|
355
|
+
args: Object.assign(Object.assign(Object.assign({ id }, spreadIfDefined(args.projectId, (v) => ({ projectId: v }))), spreadIfDefined(args.sectionId, (v) => ({ sectionId: v }))), spreadIfDefined(args.parentId, (v) => ({ parentId: v }))),
|
|
318
356
|
}));
|
|
319
357
|
const syncRequest = {
|
|
320
358
|
commands,
|
|
@@ -346,7 +384,7 @@ export class TodoistApi {
|
|
|
346
384
|
relativePath: generatePath(ENDPOINT_REST_TASKS, id, ENDPOINT_REST_TASK_MOVE),
|
|
347
385
|
apiToken: this.authToken,
|
|
348
386
|
customFetch: this.customFetch,
|
|
349
|
-
payload: Object.assign(Object.assign(Object.assign({}, (args.projectId
|
|
387
|
+
payload: Object.assign(Object.assign(Object.assign({}, spreadIfDefined(args.projectId, (v) => ({ project_id: v }))), spreadIfDefined(args.sectionId, (v) => ({ section_id: v }))), spreadIfDefined(args.parentId, (v) => ({ parent_id: v }))),
|
|
350
388
|
requestId: requestId,
|
|
351
389
|
});
|
|
352
390
|
return validateTask(response.data);
|
|
@@ -1044,8 +1082,18 @@ export class TodoistApi {
|
|
|
1044
1082
|
* @returns A promise that resolves to a paginated response of activity events.
|
|
1045
1083
|
*/
|
|
1046
1084
|
async getActivityLogs(args = {}) {
|
|
1047
|
-
|
|
1048
|
-
|
|
1085
|
+
var _a, _b;
|
|
1086
|
+
// Resolve dateFrom: prefer new param, fall back to deprecated `since`
|
|
1087
|
+
const rawDateFrom = (_a = args.dateFrom) !== null && _a !== void 0 ? _a : args.since;
|
|
1088
|
+
const rawDateTo = (_b = args.dateTo) !== null && _b !== void 0 ? _b : args.until;
|
|
1089
|
+
// Convert Date objects to YYYY-MM-DD strings
|
|
1090
|
+
const dateFrom = rawDateFrom instanceof Date ? formatDateToYYYYMMDD(rawDateFrom) : rawDateFrom;
|
|
1091
|
+
const dateTo = rawDateTo instanceof Date ? formatDateToYYYYMMDD(rawDateTo) : rawDateTo;
|
|
1092
|
+
// Destructure out deprecated and raw date fields so they don't leak into the payload
|
|
1093
|
+
const { since: _since, until: _until, dateFrom: _dateFrom, dateTo: _dateTo } = args, rest = __rest(args, ["since", "until", "dateFrom", "dateTo"]);
|
|
1094
|
+
const processedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), (dateFrom !== undefined ? { dateFrom } : {})), (dateTo !== undefined ? { dateTo } : {})), spreadIfDefined(args.objectType, (v) => ({
|
|
1095
|
+
objectType: normalizeObjectTypeForApi(v),
|
|
1096
|
+
})));
|
|
1049
1097
|
const { data: { results, nextCursor }, } = await request({
|
|
1050
1098
|
httpMethod: 'GET',
|
|
1051
1099
|
baseUri: this.syncApiBase,
|
|
@@ -21,5 +21,16 @@ export const LiveNotificationSchema = z
|
|
|
21
21
|
itemContent: z.string().optional(),
|
|
22
22
|
responsibleUid: z.string().optional(),
|
|
23
23
|
assignedByUid: z.string().optional(),
|
|
24
|
+
fromUser: z
|
|
25
|
+
.object({
|
|
26
|
+
email: z.string(),
|
|
27
|
+
fullName: z.string(),
|
|
28
|
+
id: z.string(),
|
|
29
|
+
imageId: z.string().nullable(),
|
|
30
|
+
})
|
|
31
|
+
.optional(),
|
|
32
|
+
projectName: z.string().optional(),
|
|
33
|
+
isDeleted: z.boolean().optional(),
|
|
34
|
+
invitationSecret: z.string().optional(),
|
|
24
35
|
})
|
|
25
36
|
.passthrough();
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { BooleanFromZeroOneSchema, DateFormatSchema, DayOfWeekSchema, TimeFormatSchema, } from '../user-preferences.js';
|
|
2
3
|
const FeaturesSchema = z
|
|
3
4
|
.object({
|
|
4
5
|
karmaDisabled: z.boolean(),
|
|
5
6
|
restriction: z.number().int(),
|
|
6
7
|
karmaVacation: z.boolean(),
|
|
7
8
|
dateistLang: z.any(),
|
|
8
|
-
beta:
|
|
9
|
+
beta: BooleanFromZeroOneSchema,
|
|
9
10
|
hasPushReminders: z.boolean(),
|
|
10
11
|
dateistInlineDisabled: z.boolean(),
|
|
11
12
|
autoInviteDisabled: z.boolean().optional(),
|
|
@@ -18,7 +19,7 @@ const TzInfoSchema = z
|
|
|
18
19
|
timezone: z.string(),
|
|
19
20
|
hours: z.number().int(),
|
|
20
21
|
minutes: z.number().int(),
|
|
21
|
-
isDst:
|
|
22
|
+
isDst: BooleanFromZeroOneSchema,
|
|
22
23
|
gmtString: z.string(),
|
|
23
24
|
})
|
|
24
25
|
.passthrough();
|
|
@@ -56,7 +57,7 @@ export const SyncUserSchema = z
|
|
|
56
57
|
avatarSmall: z.string().optional(),
|
|
57
58
|
businessAccountId: z.string().nullable(),
|
|
58
59
|
dailyGoal: z.number().int(),
|
|
59
|
-
dateFormat:
|
|
60
|
+
dateFormat: DateFormatSchema,
|
|
60
61
|
dateistLang: z.string().nullable(),
|
|
61
62
|
daysOff: z.array(z.number().int()),
|
|
62
63
|
featureIdentifier: z.string(),
|
|
@@ -78,7 +79,7 @@ export const SyncUserSchema = z
|
|
|
78
79
|
mfaEnabled: z.boolean().optional(),
|
|
79
80
|
mobileHost: z.string().nullable(),
|
|
80
81
|
mobileNumber: z.string().nullable(),
|
|
81
|
-
nextWeek:
|
|
82
|
+
nextWeek: DayOfWeekSchema,
|
|
82
83
|
onboardingLevel: z.string().nullable().optional(),
|
|
83
84
|
onboardingRole: z.string().nullable().optional(),
|
|
84
85
|
onboardingPersona: z.string().nullable().optional(),
|
|
@@ -105,10 +106,10 @@ export const SyncUserSchema = z
|
|
|
105
106
|
.optional(),
|
|
106
107
|
shareLimit: z.number().int(),
|
|
107
108
|
sortOrder: z.number().int(),
|
|
108
|
-
startDay:
|
|
109
|
+
startDay: DayOfWeekSchema,
|
|
109
110
|
startPage: z.string(),
|
|
110
111
|
themeId: z.string(),
|
|
111
|
-
timeFormat:
|
|
112
|
+
timeFormat: TimeFormatSchema,
|
|
112
113
|
token: z.string(),
|
|
113
114
|
tzInfo: TzInfoSchema,
|
|
114
115
|
uniquePrefix: z.number().int(),
|
|
@@ -28,6 +28,13 @@ export const SyncWorkspaceSchema = z
|
|
|
28
28
|
isGuestAllowed: z.boolean().nullable().optional(),
|
|
29
29
|
currentActiveProjects: z.number().nullable(),
|
|
30
30
|
currentMemberCount: z.number().nullable(),
|
|
31
|
+
memberCountByType: z
|
|
32
|
+
.object({
|
|
33
|
+
adminCount: z.number().int(),
|
|
34
|
+
guestCount: z.number().int(),
|
|
35
|
+
memberCount: z.number().int(),
|
|
36
|
+
})
|
|
37
|
+
.optional(),
|
|
31
38
|
currentTemplateCount: z.number().nullable(),
|
|
32
39
|
pendingInvitations: z.array(z.string()).nullable().optional(),
|
|
33
40
|
domainName: z.string().optional(),
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const DATE_FORMAT_FROM_API = { 0: 'DD/MM/YYYY', 1: 'MM/DD/YYYY' };
|
|
3
|
+
const TIME_FORMAT_FROM_API = { 0: '24h', 1: '12h' };
|
|
4
|
+
const DAY_OF_WEEK_FROM_API = {
|
|
5
|
+
1: 'Monday',
|
|
6
|
+
2: 'Tuesday',
|
|
7
|
+
3: 'Wednesday',
|
|
8
|
+
4: 'Thursday',
|
|
9
|
+
5: 'Friday',
|
|
10
|
+
6: 'Saturday',
|
|
11
|
+
7: 'Sunday',
|
|
12
|
+
};
|
|
13
|
+
export const DATE_FORMAT_TO_API = {
|
|
14
|
+
'DD/MM/YYYY': 0,
|
|
15
|
+
'MM/DD/YYYY': 1,
|
|
16
|
+
};
|
|
17
|
+
export const TIME_FORMAT_TO_API = { '24h': 0, '12h': 1 };
|
|
18
|
+
export const DAY_OF_WEEK_TO_API = {
|
|
19
|
+
Monday: 1,
|
|
20
|
+
Tuesday: 2,
|
|
21
|
+
Wednesday: 3,
|
|
22
|
+
Thursday: 4,
|
|
23
|
+
Friday: 5,
|
|
24
|
+
Saturday: 6,
|
|
25
|
+
Sunday: 7,
|
|
26
|
+
};
|
|
27
|
+
/** Zod read-schema: parse API 0/1 integer, emit boolean */
|
|
28
|
+
export const BooleanFromZeroOneSchema = z
|
|
29
|
+
.union([z.literal(0), z.literal(1)])
|
|
30
|
+
.transform((v) => v === 1);
|
|
31
|
+
/** Zod read-schemas: parse API numbers, emit descriptive strings */
|
|
32
|
+
export const DateFormatSchema = z
|
|
33
|
+
.union([z.literal(0), z.literal(1)])
|
|
34
|
+
.transform((v) => DATE_FORMAT_FROM_API[v]);
|
|
35
|
+
export const TimeFormatSchema = z
|
|
36
|
+
.union([z.literal(0), z.literal(1)])
|
|
37
|
+
.transform((v) => TIME_FORMAT_FROM_API[v]);
|
|
38
|
+
export const DayOfWeekSchema = z
|
|
39
|
+
.union([
|
|
40
|
+
z.literal(1),
|
|
41
|
+
z.literal(2),
|
|
42
|
+
z.literal(3),
|
|
43
|
+
z.literal(4),
|
|
44
|
+
z.literal(5),
|
|
45
|
+
z.literal(6),
|
|
46
|
+
z.literal(7),
|
|
47
|
+
])
|
|
48
|
+
.transform((v) => DAY_OF_WEEK_FROM_API[v]);
|
|
@@ -465,14 +465,24 @@ type GetActivityLogsArgsBase = {
|
|
|
465
465
|
* Maximum number of results to return per page.
|
|
466
466
|
*/
|
|
467
467
|
limit?: number;
|
|
468
|
+
/**
|
|
469
|
+
* Start date for filtering events (inclusive). Replaces deprecated `since`.
|
|
470
|
+
* Accepts a Date object or YYYY-MM-DD string.
|
|
471
|
+
*/
|
|
472
|
+
dateFrom?: Date | string;
|
|
473
|
+
/**
|
|
474
|
+
* End date for filtering events (inclusive). Replaces deprecated `until`.
|
|
475
|
+
* Accepts a Date object or YYYY-MM-DD string.
|
|
476
|
+
*/
|
|
477
|
+
dateTo?: Date | string;
|
|
468
478
|
};
|
|
469
479
|
type GetActivityLogsArgsWithDate = GetActivityLogsArgsBase & {
|
|
470
480
|
/**
|
|
471
|
-
*
|
|
481
|
+
* @deprecated Use `dateFrom` instead. Will be removed in the next major version.
|
|
472
482
|
*/
|
|
473
483
|
since?: Date;
|
|
474
484
|
/**
|
|
475
|
-
*
|
|
485
|
+
* @deprecated Use `dateTo` instead. Will be removed in the next major version.
|
|
476
486
|
*/
|
|
477
487
|
until?: Date;
|
|
478
488
|
};
|
|
@@ -482,13 +492,11 @@ type GetActivityLogsArgsWithDate = GetActivityLogsArgsBase & {
|
|
|
482
492
|
*/
|
|
483
493
|
type GetActivityLogsArgsWithString = GetActivityLogsArgsBase & {
|
|
484
494
|
/**
|
|
485
|
-
*
|
|
486
|
-
* @deprecated Use Date object instead. String format will be removed in the next major version.
|
|
495
|
+
* @deprecated Use `dateFrom` instead. Will be removed in the next major version.
|
|
487
496
|
*/
|
|
488
497
|
since?: string;
|
|
489
498
|
/**
|
|
490
|
-
*
|
|
491
|
-
* @deprecated Use Date object instead. String format will be removed in the next major version.
|
|
499
|
+
* @deprecated Use `dateTo` instead. Will be removed in the next major version.
|
|
492
500
|
*/
|
|
493
501
|
until?: string;
|
|
494
502
|
};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DateFormat, DayOfWeek, TimeFormat } from '../user-preferences.js';
|
|
2
|
+
export type UserUpdateArgs = {
|
|
3
|
+
fullName?: string;
|
|
4
|
+
autoReminder?: number;
|
|
5
|
+
dateFormat?: DateFormat;
|
|
6
|
+
nextWeek?: DayOfWeek;
|
|
7
|
+
startDay?: DayOfWeek;
|
|
8
|
+
startPage?: string;
|
|
9
|
+
themeId?: string;
|
|
10
|
+
timeFormat?: TimeFormat;
|
|
11
|
+
timezone?: string;
|
|
12
|
+
};
|
|
2
13
|
export type DeleteCollaboratorArgs = {
|
|
3
14
|
projectId: string;
|
|
4
15
|
email: string;
|
|
@@ -23,6 +34,6 @@ export type UpdateGoalsArgs = {
|
|
|
23
34
|
dailyGoal?: number;
|
|
24
35
|
weeklyGoal?: number;
|
|
25
36
|
ignoreDays?: number[];
|
|
26
|
-
vacationMode?:
|
|
27
|
-
karmaDisabled?:
|
|
37
|
+
vacationMode?: boolean;
|
|
38
|
+
karmaDisabled?: boolean;
|
|
28
39
|
};
|
|
@@ -24,16 +24,26 @@ export type ReminderAddArgs = {
|
|
|
24
24
|
};
|
|
25
25
|
export type ReminderUpdateArgs = {
|
|
26
26
|
id: string;
|
|
27
|
+
type: 'absolute';
|
|
28
|
+
service?: ReminderService;
|
|
27
29
|
notifyUid?: string;
|
|
28
|
-
type?: 'relative' | 'absolute' | 'location';
|
|
29
30
|
due?: SyncDueDate;
|
|
31
|
+
} | {
|
|
32
|
+
id: string;
|
|
33
|
+
type: 'relative';
|
|
34
|
+
service?: ReminderService;
|
|
35
|
+
notifyUid?: string;
|
|
30
36
|
minuteOffset?: number;
|
|
37
|
+
due?: SyncDueDate;
|
|
38
|
+
} | {
|
|
39
|
+
id: string;
|
|
40
|
+
type: 'location';
|
|
31
41
|
name?: string;
|
|
32
42
|
locLat?: string;
|
|
33
43
|
locLong?: string;
|
|
34
|
-
locTrigger?: 'on_enter' | 'on_leave';
|
|
35
44
|
radius?: number;
|
|
36
|
-
|
|
45
|
+
locTrigger?: 'on_enter' | 'on_leave';
|
|
46
|
+
notifyUid?: string;
|
|
37
47
|
};
|
|
38
48
|
export type ReminderDeleteArgs = {
|
|
39
49
|
id: string;
|
|
@@ -67,8 +67,8 @@ export type TaskUncompleteArgs = {
|
|
|
67
67
|
export type TaskUpdateDateCompleteArgs = {
|
|
68
68
|
id: string;
|
|
69
69
|
due: SyncDueDate;
|
|
70
|
-
isForward:
|
|
71
|
-
resetSubtasks?:
|
|
70
|
+
isForward: boolean;
|
|
71
|
+
resetSubtasks?: boolean;
|
|
72
72
|
};
|
|
73
73
|
export type TaskDeleteArgs = {
|
|
74
74
|
id: string;
|
|
@@ -19,5 +19,14 @@ export declare const LiveNotificationSchema: z.ZodObject<{
|
|
|
19
19
|
itemContent: z.ZodOptional<z.ZodString>;
|
|
20
20
|
responsibleUid: z.ZodOptional<z.ZodString>;
|
|
21
21
|
assignedByUid: z.ZodOptional<z.ZodString>;
|
|
22
|
+
fromUser: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
email: z.ZodString;
|
|
24
|
+
fullName: z.ZodString;
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
imageId: z.ZodNullable<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
29
|
+
isDeleted: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
invitationSecret: z.ZodOptional<z.ZodString>;
|
|
22
31
|
}, z.core.$loose>;
|
|
23
32
|
export type LiveNotification = z.infer<typeof LiveNotificationSchema>;
|
|
@@ -17,7 +17,7 @@ export declare const SyncUserSchema: z.ZodObject<{
|
|
|
17
17
|
avatarSmall: z.ZodOptional<z.ZodString>;
|
|
18
18
|
businessAccountId: z.ZodNullable<z.ZodString>;
|
|
19
19
|
dailyGoal: z.ZodNumber;
|
|
20
|
-
dateFormat: z.
|
|
20
|
+
dateFormat: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>, z.ZodTransform<"DD/MM/YYYY" | "MM/DD/YYYY", 0 | 1>>;
|
|
21
21
|
dateistLang: z.ZodNullable<z.ZodString>;
|
|
22
22
|
daysOff: z.ZodArray<z.ZodNumber>;
|
|
23
23
|
featureIdentifier: z.ZodString;
|
|
@@ -26,7 +26,7 @@ export declare const SyncUserSchema: z.ZodObject<{
|
|
|
26
26
|
restriction: z.ZodNumber;
|
|
27
27
|
karmaVacation: z.ZodBoolean;
|
|
28
28
|
dateistLang: z.ZodAny;
|
|
29
|
-
beta: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]
|
|
29
|
+
beta: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>, z.ZodTransform<boolean, 0 | 1>>;
|
|
30
30
|
hasPushReminders: z.ZodBoolean;
|
|
31
31
|
dateistInlineDisabled: z.ZodBoolean;
|
|
32
32
|
autoInviteDisabled: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -59,7 +59,7 @@ export declare const SyncUserSchema: z.ZodObject<{
|
|
|
59
59
|
mfaEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
60
60
|
mobileHost: z.ZodNullable<z.ZodString>;
|
|
61
61
|
mobileNumber: z.ZodNullable<z.ZodString>;
|
|
62
|
-
nextWeek: z.
|
|
62
|
+
nextWeek: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<7>]>, z.ZodTransform<"Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday", 2 | 1 | 3 | 4 | 5 | 6 | 7>>;
|
|
63
63
|
onboardingLevel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
64
|
onboardingRole: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
65
65
|
onboardingPersona: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -83,16 +83,16 @@ export declare const SyncUserSchema: z.ZodObject<{
|
|
|
83
83
|
}, z.core.$strip>>>;
|
|
84
84
|
shareLimit: z.ZodNumber;
|
|
85
85
|
sortOrder: z.ZodNumber;
|
|
86
|
-
startDay: z.
|
|
86
|
+
startDay: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<7>]>, z.ZodTransform<"Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday", 2 | 1 | 3 | 4 | 5 | 6 | 7>>;
|
|
87
87
|
startPage: z.ZodString;
|
|
88
88
|
themeId: z.ZodString;
|
|
89
|
-
timeFormat: z.
|
|
89
|
+
timeFormat: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>, z.ZodTransform<"24h" | "12h", 0 | 1>>;
|
|
90
90
|
token: z.ZodString;
|
|
91
91
|
tzInfo: z.ZodObject<{
|
|
92
92
|
timezone: z.ZodString;
|
|
93
93
|
hours: z.ZodNumber;
|
|
94
94
|
minutes: z.ZodNumber;
|
|
95
|
-
isDst: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]
|
|
95
|
+
isDst: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>, z.ZodTransform<boolean, 0 | 1>>;
|
|
96
96
|
gmtString: z.ZodString;
|
|
97
97
|
}, z.core.$loose>;
|
|
98
98
|
uniquePrefix: z.ZodNumber;
|
|
@@ -36,6 +36,11 @@ export declare const SyncWorkspaceSchema: z.ZodObject<{
|
|
|
36
36
|
isGuestAllowed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
37
37
|
currentActiveProjects: z.ZodNullable<z.ZodNumber>;
|
|
38
38
|
currentMemberCount: z.ZodNullable<z.ZodNumber>;
|
|
39
|
+
memberCountByType: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
adminCount: z.ZodNumber;
|
|
41
|
+
guestCount: z.ZodNumber;
|
|
42
|
+
memberCount: z.ZodNumber;
|
|
43
|
+
}, z.core.$strip>>;
|
|
39
44
|
currentTemplateCount: z.ZodNullable<z.ZodNumber>;
|
|
40
45
|
pendingInvitations: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
41
46
|
domainName: z.ZodOptional<z.ZodString>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type DateFormat = 'DD/MM/YYYY' | 'MM/DD/YYYY';
|
|
3
|
+
export type TimeFormat = '24h' | '12h';
|
|
4
|
+
export type DayOfWeek = 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday' | 'Sunday';
|
|
5
|
+
export declare const DATE_FORMAT_TO_API: Record<DateFormat, 0 | 1>;
|
|
6
|
+
export declare const TIME_FORMAT_TO_API: Record<TimeFormat, 0 | 1>;
|
|
7
|
+
export declare const DAY_OF_WEEK_TO_API: Record<DayOfWeek, 1 | 2 | 3 | 4 | 5 | 6 | 7>;
|
|
8
|
+
/** Zod read-schema: parse API 0/1 integer, emit boolean */
|
|
9
|
+
export declare const BooleanFromZeroOneSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>, z.ZodTransform<boolean, 0 | 1>>;
|
|
10
|
+
/** Zod read-schemas: parse API numbers, emit descriptive strings */
|
|
11
|
+
export declare const DateFormatSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>, z.ZodTransform<"DD/MM/YYYY" | "MM/DD/YYYY", 0 | 1>>;
|
|
12
|
+
export declare const TimeFormatSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>, z.ZodTransform<"24h" | "12h", 0 | 1>>;
|
|
13
|
+
export declare const DayOfWeekSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<7>]>, z.ZodTransform<"Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday", 2 | 1 | 3 | 4 | 5 | 6 | 7>>;
|
|
@@ -908,6 +908,15 @@ export declare const validateLiveNotification: (input: unknown) => {
|
|
|
908
908
|
itemContent?: string | undefined;
|
|
909
909
|
responsibleUid?: string | undefined;
|
|
910
910
|
assignedByUid?: string | undefined;
|
|
911
|
+
fromUser?: {
|
|
912
|
+
email: string;
|
|
913
|
+
fullName: string;
|
|
914
|
+
id: string;
|
|
915
|
+
imageId: string | null;
|
|
916
|
+
} | undefined;
|
|
917
|
+
projectName?: string | undefined;
|
|
918
|
+
isDeleted?: boolean | undefined;
|
|
919
|
+
invitationSecret?: string | undefined;
|
|
911
920
|
};
|
|
912
921
|
export declare const validateLiveNotificationArray: (input: unknown[]) => {
|
|
913
922
|
[x: string]: unknown;
|
|
@@ -922,6 +931,15 @@ export declare const validateLiveNotificationArray: (input: unknown[]) => {
|
|
|
922
931
|
itemContent?: string | undefined;
|
|
923
932
|
responsibleUid?: string | undefined;
|
|
924
933
|
assignedByUid?: string | undefined;
|
|
934
|
+
fromUser?: {
|
|
935
|
+
email: string;
|
|
936
|
+
fullName: string;
|
|
937
|
+
id: string;
|
|
938
|
+
imageId: string | null;
|
|
939
|
+
} | undefined;
|
|
940
|
+
projectName?: string | undefined;
|
|
941
|
+
isDeleted?: boolean | undefined;
|
|
942
|
+
invitationSecret?: string | undefined;
|
|
925
943
|
}[];
|
|
926
944
|
export declare const validateSyncWorkspace: (input: unknown) => {
|
|
927
945
|
[x: string]: unknown;
|
|
@@ -950,6 +968,11 @@ export declare const validateSyncWorkspace: (input: unknown) => {
|
|
|
950
968
|
inviteCode?: string | null | undefined;
|
|
951
969
|
isLinkSharingEnabled?: boolean | null | undefined;
|
|
952
970
|
isGuestAllowed?: boolean | null | undefined;
|
|
971
|
+
memberCountByType?: {
|
|
972
|
+
adminCount: number;
|
|
973
|
+
guestCount: number;
|
|
974
|
+
memberCount: number;
|
|
975
|
+
} | undefined;
|
|
953
976
|
pendingInvitations?: string[] | null | undefined;
|
|
954
977
|
domainName?: string | undefined;
|
|
955
978
|
domainDiscovery?: boolean | undefined;
|
|
@@ -988,6 +1011,11 @@ export declare const validateSyncWorkspaceArray: (input: unknown[]) => {
|
|
|
988
1011
|
inviteCode?: string | null | undefined;
|
|
989
1012
|
isLinkSharingEnabled?: boolean | null | undefined;
|
|
990
1013
|
isGuestAllowed?: boolean | null | undefined;
|
|
1014
|
+
memberCountByType?: {
|
|
1015
|
+
adminCount: number;
|
|
1016
|
+
guestCount: number;
|
|
1017
|
+
memberCount: number;
|
|
1018
|
+
} | undefined;
|
|
991
1019
|
pendingInvitations?: string[] | null | undefined;
|
|
992
1020
|
domainName?: string | undefined;
|
|
993
1021
|
domainDiscovery?: boolean | undefined;
|
|
@@ -1008,7 +1036,7 @@ export declare const validateSyncUser: (input: unknown) => {
|
|
|
1008
1036
|
autoReminder: number;
|
|
1009
1037
|
businessAccountId: string | null;
|
|
1010
1038
|
dailyGoal: number;
|
|
1011
|
-
dateFormat:
|
|
1039
|
+
dateFormat: "DD/MM/YYYY" | "MM/DD/YYYY";
|
|
1012
1040
|
dateistLang: string | null;
|
|
1013
1041
|
daysOff: number[];
|
|
1014
1042
|
featureIdentifier: string;
|
|
@@ -1018,7 +1046,7 @@ export declare const validateSyncUser: (input: unknown) => {
|
|
|
1018
1046
|
restriction: number;
|
|
1019
1047
|
karmaVacation: boolean;
|
|
1020
1048
|
dateistLang: any;
|
|
1021
|
-
beta:
|
|
1049
|
+
beta: boolean;
|
|
1022
1050
|
hasPushReminders: boolean;
|
|
1023
1051
|
dateistInlineDisabled: boolean;
|
|
1024
1052
|
autoInviteDisabled?: boolean | undefined;
|
|
@@ -1050,22 +1078,22 @@ export declare const validateSyncUser: (input: unknown) => {
|
|
|
1050
1078
|
lang: string;
|
|
1051
1079
|
mobileHost: string | null;
|
|
1052
1080
|
mobileNumber: string | null;
|
|
1053
|
-
nextWeek:
|
|
1081
|
+
nextWeek: "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday";
|
|
1054
1082
|
premiumStatus: "not_premium" | "current_personal_plan" | "legacy_personal_plan" | "teams_business_member";
|
|
1055
1083
|
premiumUntil: string | null;
|
|
1056
1084
|
shareLimit: number;
|
|
1057
1085
|
sortOrder: number;
|
|
1058
|
-
startDay:
|
|
1086
|
+
startDay: "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday";
|
|
1059
1087
|
startPage: string;
|
|
1060
1088
|
themeId: string;
|
|
1061
|
-
timeFormat:
|
|
1089
|
+
timeFormat: "24h" | "12h";
|
|
1062
1090
|
token: string;
|
|
1063
1091
|
tzInfo: {
|
|
1064
1092
|
[x: string]: unknown;
|
|
1065
1093
|
timezone: string;
|
|
1066
1094
|
hours: number;
|
|
1067
1095
|
minutes: number;
|
|
1068
|
-
isDst:
|
|
1096
|
+
isDst: boolean;
|
|
1069
1097
|
gmtString: string;
|
|
1070
1098
|
};
|
|
1071
1099
|
uniquePrefix: number;
|
package/package.json
CHANGED