@doist/todoist-sdk 9.2.0-next.1 → 9.2.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/clients/app-client.js +24 -25
- package/dist/cjs/clients/comment-client.js +3 -3
- package/dist/cjs/clients/folder-client.js +3 -3
- package/dist/cjs/clients/insights-client.js +6 -6
- package/dist/cjs/clients/label-client.js +3 -3
- package/dist/cjs/clients/project-client.js +8 -8
- package/dist/cjs/clients/section-client.js +5 -5
- package/dist/cjs/clients/task-client.js +6 -6
- package/dist/cjs/clients/ui-extension-client.js +4 -4
- package/dist/cjs/clients/workspace-client.js +3 -3
- package/dist/cjs/consts/endpoints.js +1 -6
- package/dist/cjs/test-utils/test-defaults.js +3 -26
- package/dist/cjs/todoist-api.js +0 -33
- package/dist/cjs/types/apps/types.js +1 -0
- package/dist/cjs/types/index.js +0 -1
- 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/response.js +10 -12
- package/dist/cjs/utils/validators.js +51 -53
- package/dist/esm/clients/app-client.js +24 -25
- package/dist/esm/clients/comment-client.js +3 -3
- package/dist/esm/clients/folder-client.js +3 -3
- package/dist/esm/clients/insights-client.js +6 -6
- package/dist/esm/clients/label-client.js +3 -3
- package/dist/esm/clients/project-client.js +8 -8
- package/dist/esm/clients/section-client.js +5 -5
- package/dist/esm/clients/task-client.js +6 -6
- package/dist/esm/clients/ui-extension-client.js +4 -4
- package/dist/esm/clients/workspace-client.js +3 -3
- package/dist/esm/consts/endpoints.js +0 -5
- package/dist/esm/test-utils/test-defaults.js +1 -24
- package/dist/esm/todoist-api.js +0 -33
- package/dist/esm/types/apps/types.js +1 -0
- package/dist/esm/types/index.js +0 -1
- 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/response.js +0 -2
- package/dist/esm/utils/validators.js +0 -2
- package/dist/types/clients/app-client.d.ts +1 -1
- package/dist/types/consts/endpoints.d.ts +0 -5
- package/dist/types/test-utils/test-defaults.d.ts +1 -4
- package/dist/types/todoist-api.d.ts +0 -12
- package/dist/types/types/apps/types.d.ts +4 -0
- package/dist/types/types/index.d.ts +0 -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/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +4 -29
- package/dist/types/types/tasks/requests.d.ts +0 -1
- package/dist/types/utils/validators.d.ts +13 -55
- package/package.json +1 -1
- package/dist/cjs/clients/goals-client.js +0 -145
- package/dist/cjs/types/goals/index.js +0 -18
- package/dist/cjs/types/goals/requests.js +0 -2
- package/dist/cjs/types/goals/types.js +0 -56
- package/dist/cjs/types/sync/commands/goals.js +0 -2
- package/dist/esm/clients/goals-client.js +0 -141
- package/dist/esm/types/goals/index.js +0 -2
- package/dist/esm/types/goals/requests.js +0 -1
- package/dist/esm/types/goals/types.js +0 -53
- package/dist/esm/types/sync/commands/goals.js +0 -1
- package/dist/types/clients/goals-client.d.ts +0 -20
- package/dist/types/types/goals/index.d.ts +0 -2
- package/dist/types/types/goals/requests.d.ts +0 -33
- package/dist/types/types/goals/types.d.ts +0 -51
- package/dist/types/types/sync/commands/goals.d.ts +0 -33
|
@@ -750,7 +750,6 @@ export declare const SyncResponseSchema: z.ZodObject<{
|
|
|
750
750
|
}>;
|
|
751
751
|
objectId: z.ZodOptional<z.ZodString>;
|
|
752
752
|
groupedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
753
|
-
WORKSPACE: "WORKSPACE";
|
|
754
753
|
PROJECT: "PROJECT";
|
|
755
754
|
LABEL: "LABEL";
|
|
756
755
|
ASSIGNEE: "ASSIGNEE";
|
|
@@ -758,6 +757,7 @@ export declare const SyncResponseSchema: z.ZodObject<{
|
|
|
758
757
|
DUE_DATE: "DUE_DATE";
|
|
759
758
|
DEADLINE: "DEADLINE";
|
|
760
759
|
PRIORITY: "PRIORITY";
|
|
760
|
+
WORKSPACE: "WORKSPACE";
|
|
761
761
|
}>>>;
|
|
762
762
|
filteredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
763
763
|
viewMode: z.ZodOptional<z.ZodEnum<{
|
|
@@ -767,13 +767,13 @@ export declare const SyncResponseSchema: z.ZodObject<{
|
|
|
767
767
|
}>>;
|
|
768
768
|
showCompletedTasks: z.ZodOptional<z.ZodBoolean>;
|
|
769
769
|
sortedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
770
|
-
WORKSPACE: "WORKSPACE";
|
|
771
770
|
PROJECT: "PROJECT";
|
|
772
771
|
ASSIGNEE: "ASSIGNEE";
|
|
773
772
|
ADDED_DATE: "ADDED_DATE";
|
|
774
773
|
DUE_DATE: "DUE_DATE";
|
|
775
774
|
DEADLINE: "DEADLINE";
|
|
776
775
|
PRIORITY: "PRIORITY";
|
|
776
|
+
WORKSPACE: "WORKSPACE";
|
|
777
777
|
MANUAL: "MANUAL";
|
|
778
778
|
ALPHABETICALLY: "ALPHABETICALLY";
|
|
779
779
|
}>>>;
|
|
@@ -790,7 +790,6 @@ export declare const SyncResponseSchema: z.ZodObject<{
|
|
|
790
790
|
CALENDAR: "CALENDAR";
|
|
791
791
|
}>>>;
|
|
792
792
|
groupedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
793
|
-
WORKSPACE: "WORKSPACE";
|
|
794
793
|
PROJECT: "PROJECT";
|
|
795
794
|
LABEL: "LABEL";
|
|
796
795
|
ASSIGNEE: "ASSIGNEE";
|
|
@@ -798,15 +797,16 @@ export declare const SyncResponseSchema: z.ZodObject<{
|
|
|
798
797
|
DUE_DATE: "DUE_DATE";
|
|
799
798
|
DEADLINE: "DEADLINE";
|
|
800
799
|
PRIORITY: "PRIORITY";
|
|
800
|
+
WORKSPACE: "WORKSPACE";
|
|
801
801
|
}>>>;
|
|
802
802
|
sortedBy: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
803
|
-
WORKSPACE: "WORKSPACE";
|
|
804
803
|
PROJECT: "PROJECT";
|
|
805
804
|
ASSIGNEE: "ASSIGNEE";
|
|
806
805
|
ADDED_DATE: "ADDED_DATE";
|
|
807
806
|
DUE_DATE: "DUE_DATE";
|
|
808
807
|
DEADLINE: "DEADLINE";
|
|
809
808
|
PRIORITY: "PRIORITY";
|
|
809
|
+
WORKSPACE: "WORKSPACE";
|
|
810
810
|
MANUAL: "MANUAL";
|
|
811
811
|
ALPHABETICALLY: "ALPHABETICALLY";
|
|
812
812
|
}>>>;
|
|
@@ -832,31 +832,6 @@ export declare const SyncResponseSchema: z.ZodObject<{
|
|
|
832
832
|
defaultOrder: z.ZodNumber;
|
|
833
833
|
childOrder: z.ZodNumber;
|
|
834
834
|
}, z.core.$loose>>>;
|
|
835
|
-
goals: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
836
|
-
id: z.ZodString;
|
|
837
|
-
ownerType: z.ZodEnum<{
|
|
838
|
-
USER: "USER";
|
|
839
|
-
WORKSPACE: "WORKSPACE";
|
|
840
|
-
}>;
|
|
841
|
-
ownerId: z.ZodString;
|
|
842
|
-
name: z.ZodString;
|
|
843
|
-
description: z.ZodNullable<z.ZodString>;
|
|
844
|
-
deadline: z.ZodNullable<z.ZodString>;
|
|
845
|
-
parentGoalId: z.ZodNullable<z.ZodString>;
|
|
846
|
-
childOrder: z.ZodNumber;
|
|
847
|
-
isCompleted: z.ZodBoolean;
|
|
848
|
-
completedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
849
|
-
responsibleUid: z.ZodNullable<z.ZodString>;
|
|
850
|
-
isDeleted: z.ZodBoolean;
|
|
851
|
-
progress: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodObject<{
|
|
852
|
-
totalTaskCount: z.ZodNumber;
|
|
853
|
-
completedTaskCount: z.ZodNumber;
|
|
854
|
-
percentage: z.ZodNumber;
|
|
855
|
-
}, z.core.$loose>>>;
|
|
856
|
-
creatorUid: z.ZodString;
|
|
857
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
858
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
859
|
-
}, z.core.$loose>>>;
|
|
860
835
|
workspaceGoals: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
861
836
|
id: z.ZodString;
|
|
862
837
|
workspaceId: z.ZodString;
|
|
@@ -816,53 +816,6 @@ export declare const validateFolder: (input: unknown) => {
|
|
|
816
816
|
defaultOrder: number;
|
|
817
817
|
childOrder: number;
|
|
818
818
|
}[];
|
|
819
|
-
export declare const validateGoal: (input: unknown) => {
|
|
820
|
-
[x: string]: unknown;
|
|
821
|
-
id: string;
|
|
822
|
-
ownerType: "USER" | "WORKSPACE";
|
|
823
|
-
ownerId: string;
|
|
824
|
-
name: string;
|
|
825
|
-
description: string | null;
|
|
826
|
-
deadline: string | null;
|
|
827
|
-
parentGoalId: string | null;
|
|
828
|
-
childOrder: number;
|
|
829
|
-
isCompleted: boolean;
|
|
830
|
-
completedAt: Date | null;
|
|
831
|
-
responsibleUid: string | null;
|
|
832
|
-
isDeleted: boolean;
|
|
833
|
-
creatorUid: string;
|
|
834
|
-
createdAt: Date;
|
|
835
|
-
updatedAt: Date;
|
|
836
|
-
progress?: {
|
|
837
|
-
[x: string]: unknown;
|
|
838
|
-
totalTaskCount: number;
|
|
839
|
-
completedTaskCount: number;
|
|
840
|
-
percentage: number;
|
|
841
|
-
} | undefined;
|
|
842
|
-
}, validateGoalArray: (input: unknown) => {
|
|
843
|
-
[x: string]: unknown;
|
|
844
|
-
id: string;
|
|
845
|
-
ownerType: "USER" | "WORKSPACE";
|
|
846
|
-
ownerId: string;
|
|
847
|
-
name: string;
|
|
848
|
-
description: string | null;
|
|
849
|
-
deadline: string | null;
|
|
850
|
-
parentGoalId: string | null;
|
|
851
|
-
childOrder: number;
|
|
852
|
-
isCompleted: boolean;
|
|
853
|
-
completedAt: Date | null;
|
|
854
|
-
responsibleUid: string | null;
|
|
855
|
-
isDeleted: boolean;
|
|
856
|
-
creatorUid: string;
|
|
857
|
-
createdAt: Date;
|
|
858
|
-
updatedAt: Date;
|
|
859
|
-
progress?: {
|
|
860
|
-
[x: string]: unknown;
|
|
861
|
-
totalTaskCount: number;
|
|
862
|
-
completedTaskCount: number;
|
|
863
|
-
percentage: number;
|
|
864
|
-
} | undefined;
|
|
865
|
-
}[];
|
|
866
819
|
export declare const validateNote: (input: unknown) => {
|
|
867
820
|
[x: string]: unknown;
|
|
868
821
|
id: string;
|
|
@@ -1184,29 +1137,29 @@ export declare const validateViewOptions: (input: unknown) => {
|
|
|
1184
1137
|
[x: string]: unknown;
|
|
1185
1138
|
viewType: "PROJECT" | "TODAY" | "UPCOMING" | "LABEL" | "FILTER" | "WORKSPACE_FILTER" | "SEARCH" | "TEMPLATE_PREVIEW" | "TASK_DETAIL" | "AUTOMATION" | "ASSIGNED" | "OVERDUE" | "WORKSPACE_OVERVIEW";
|
|
1186
1139
|
objectId?: string | undefined;
|
|
1187
|
-
groupedBy?: "
|
|
1140
|
+
groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
|
|
1188
1141
|
filteredBy?: string | null | undefined;
|
|
1189
1142
|
viewMode?: "LIST" | "BOARD" | "CALENDAR" | undefined;
|
|
1190
1143
|
showCompletedTasks?: boolean | undefined;
|
|
1191
|
-
sortedBy?: "
|
|
1144
|
+
sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
|
|
1192
1145
|
sortOrder?: "ASC" | "DESC" | null | undefined;
|
|
1193
1146
|
}, validateViewOptionsArray: (input: unknown) => {
|
|
1194
1147
|
[x: string]: unknown;
|
|
1195
1148
|
viewType: "PROJECT" | "TODAY" | "UPCOMING" | "LABEL" | "FILTER" | "WORKSPACE_FILTER" | "SEARCH" | "TEMPLATE_PREVIEW" | "TASK_DETAIL" | "AUTOMATION" | "ASSIGNED" | "OVERDUE" | "WORKSPACE_OVERVIEW";
|
|
1196
1149
|
objectId?: string | undefined;
|
|
1197
|
-
groupedBy?: "
|
|
1150
|
+
groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
|
|
1198
1151
|
filteredBy?: string | null | undefined;
|
|
1199
1152
|
viewMode?: "LIST" | "BOARD" | "CALENDAR" | undefined;
|
|
1200
1153
|
showCompletedTasks?: boolean | undefined;
|
|
1201
|
-
sortedBy?: "
|
|
1154
|
+
sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
|
|
1202
1155
|
sortOrder?: "ASC" | "DESC" | null | undefined;
|
|
1203
1156
|
}[];
|
|
1204
1157
|
export declare const validateProjectViewOptionsDefaults: (input: unknown) => {
|
|
1205
1158
|
[x: string]: unknown;
|
|
1206
1159
|
projectId: string;
|
|
1207
1160
|
viewMode?: "LIST" | "BOARD" | "CALENDAR" | null | undefined;
|
|
1208
|
-
groupedBy?: "
|
|
1209
|
-
sortedBy?: "
|
|
1161
|
+
groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
|
|
1162
|
+
sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
|
|
1210
1163
|
sortOrder?: "ASC" | "DESC" | null | undefined;
|
|
1211
1164
|
showCompletedTasks?: boolean | undefined;
|
|
1212
1165
|
filteredBy?: string | null | undefined;
|
|
@@ -1218,8 +1171,8 @@ export declare const validateProjectViewOptionsDefaults: (input: unknown) => {
|
|
|
1218
1171
|
[x: string]: unknown;
|
|
1219
1172
|
projectId: string;
|
|
1220
1173
|
viewMode?: "LIST" | "BOARD" | "CALENDAR" | null | undefined;
|
|
1221
|
-
groupedBy?: "
|
|
1222
|
-
sortedBy?: "
|
|
1174
|
+
groupedBy?: "PROJECT" | "LABEL" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | null | undefined;
|
|
1175
|
+
sortedBy?: "PROJECT" | "ASSIGNEE" | "ADDED_DATE" | "DUE_DATE" | "DEADLINE" | "PRIORITY" | "WORKSPACE" | "MANUAL" | "ALPHABETICALLY" | null | undefined;
|
|
1223
1176
|
sortOrder?: "ASC" | "DESC" | null | undefined;
|
|
1224
1177
|
showCompletedTasks?: boolean | undefined;
|
|
1225
1178
|
filteredBy?: string | null | undefined;
|
|
@@ -1569,6 +1522,7 @@ export declare const validateSuggestion: (input: unknown) => {
|
|
|
1569
1522
|
export declare function parseSyncResponse(raw: Record<string, unknown>): SyncResponse;
|
|
1570
1523
|
export declare const validateApp: (input: unknown) => {
|
|
1571
1524
|
id: string;
|
|
1525
|
+
clientId: string;
|
|
1572
1526
|
status: "public";
|
|
1573
1527
|
displayName: string;
|
|
1574
1528
|
userId: string;
|
|
@@ -1582,6 +1536,7 @@ export declare const validateApp: (input: unknown) => {
|
|
|
1582
1536
|
appTokenScopes: string[] | null;
|
|
1583
1537
|
}, validateAppArray: (input: unknown) => {
|
|
1584
1538
|
id: string;
|
|
1539
|
+
clientId: string;
|
|
1585
1540
|
status: "public";
|
|
1586
1541
|
displayName: string;
|
|
1587
1542
|
userId: string;
|
|
@@ -1596,6 +1551,7 @@ export declare const validateApp: (input: unknown) => {
|
|
|
1596
1551
|
}[];
|
|
1597
1552
|
export declare const validateAppWithUserCount: (input: unknown) => {
|
|
1598
1553
|
id: string;
|
|
1554
|
+
clientId: string;
|
|
1599
1555
|
status: "public";
|
|
1600
1556
|
displayName: string;
|
|
1601
1557
|
userId: string;
|
|
@@ -1649,6 +1605,7 @@ export declare const validateAppInstallation: (input: unknown) => {
|
|
|
1649
1605
|
appTokenScopesValidated: boolean;
|
|
1650
1606
|
integration: {
|
|
1651
1607
|
id: string;
|
|
1608
|
+
clientId: string;
|
|
1652
1609
|
status: "public";
|
|
1653
1610
|
displayName: string;
|
|
1654
1611
|
userId: string;
|
|
@@ -1669,6 +1626,7 @@ export declare const validateAppInstallation: (input: unknown) => {
|
|
|
1669
1626
|
appTokenScopesValidated: boolean;
|
|
1670
1627
|
integration: {
|
|
1671
1628
|
id: string;
|
|
1629
|
+
clientId: string;
|
|
1672
1630
|
status: "public";
|
|
1673
1631
|
displayName: string;
|
|
1674
1632
|
userId: string;
|
package/package.json
CHANGED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GoalsClient = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const endpoints_1 = require("../consts/endpoints");
|
|
6
|
-
const http_client_1 = require("../transport/http-client");
|
|
7
|
-
const request_helpers_1 = require("../utils/request-helpers");
|
|
8
|
-
const validators_1 = require("../utils/validators");
|
|
9
|
-
const base_client_1 = require("./base-client");
|
|
10
|
-
/**
|
|
11
|
-
* Internal sub-client handling all goal-domain endpoints.
|
|
12
|
-
*
|
|
13
|
-
* Instantiated by `TodoistApi`; every public goal method on `TodoistApi`
|
|
14
|
-
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
15
|
-
*/
|
|
16
|
-
class GoalsClient extends base_client_1.BaseClient {
|
|
17
|
-
async getGoals(args) {
|
|
18
|
-
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
19
|
-
httpMethod: 'GET',
|
|
20
|
-
baseUri: this.syncApiBase,
|
|
21
|
-
relativePath: endpoints_1.ENDPOINT_REST_GOALS,
|
|
22
|
-
apiToken: this.authToken,
|
|
23
|
-
customFetch: this.customFetch,
|
|
24
|
-
payload: args,
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
results: (0, validators_1.validateGoalArray)(results),
|
|
28
|
-
nextCursor,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
async searchGoals(args) {
|
|
32
|
-
const { data: { results, nextCursor }, } = await (0, http_client_1.request)({
|
|
33
|
-
httpMethod: 'GET',
|
|
34
|
-
baseUri: this.syncApiBase,
|
|
35
|
-
relativePath: endpoints_1.ENDPOINT_REST_GOALS_SEARCH,
|
|
36
|
-
apiToken: this.authToken,
|
|
37
|
-
customFetch: this.customFetch,
|
|
38
|
-
payload: args,
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
results: (0, validators_1.validateGoalArray)(results),
|
|
42
|
-
nextCursor,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
async getGoal(id) {
|
|
46
|
-
zod_1.z.string().parse(id);
|
|
47
|
-
const response = await (0, http_client_1.request)({
|
|
48
|
-
httpMethod: 'GET',
|
|
49
|
-
baseUri: this.syncApiBase,
|
|
50
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
|
|
51
|
-
apiToken: this.authToken,
|
|
52
|
-
customFetch: this.customFetch,
|
|
53
|
-
});
|
|
54
|
-
return (0, validators_1.validateGoal)(response.data);
|
|
55
|
-
}
|
|
56
|
-
async addGoal(args, requestId) {
|
|
57
|
-
const response = await (0, http_client_1.request)({
|
|
58
|
-
httpMethod: 'POST',
|
|
59
|
-
baseUri: this.syncApiBase,
|
|
60
|
-
relativePath: endpoints_1.ENDPOINT_REST_GOALS,
|
|
61
|
-
apiToken: this.authToken,
|
|
62
|
-
customFetch: this.customFetch,
|
|
63
|
-
payload: args,
|
|
64
|
-
requestId: requestId,
|
|
65
|
-
});
|
|
66
|
-
return (0, validators_1.validateGoal)(response.data);
|
|
67
|
-
}
|
|
68
|
-
async updateGoal(id, args, requestId) {
|
|
69
|
-
zod_1.z.string().parse(id);
|
|
70
|
-
const response = await (0, http_client_1.request)({
|
|
71
|
-
httpMethod: 'POST',
|
|
72
|
-
baseUri: this.syncApiBase,
|
|
73
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
|
|
74
|
-
apiToken: this.authToken,
|
|
75
|
-
customFetch: this.customFetch,
|
|
76
|
-
payload: args,
|
|
77
|
-
requestId: requestId,
|
|
78
|
-
});
|
|
79
|
-
return (0, validators_1.validateGoal)(response.data);
|
|
80
|
-
}
|
|
81
|
-
async deleteGoal(id, requestId) {
|
|
82
|
-
zod_1.z.string().parse(id);
|
|
83
|
-
const response = await (0, http_client_1.request)({
|
|
84
|
-
httpMethod: 'DELETE',
|
|
85
|
-
baseUri: this.syncApiBase,
|
|
86
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id),
|
|
87
|
-
apiToken: this.authToken,
|
|
88
|
-
customFetch: this.customFetch,
|
|
89
|
-
requestId: requestId,
|
|
90
|
-
});
|
|
91
|
-
return (0, http_client_1.isSuccess)(response);
|
|
92
|
-
}
|
|
93
|
-
async completeGoal(id, requestId) {
|
|
94
|
-
zod_1.z.string().parse(id);
|
|
95
|
-
const response = await (0, http_client_1.request)({
|
|
96
|
-
httpMethod: 'POST',
|
|
97
|
-
baseUri: this.syncApiBase,
|
|
98
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_COMPLETE),
|
|
99
|
-
apiToken: this.authToken,
|
|
100
|
-
customFetch: this.customFetch,
|
|
101
|
-
requestId: requestId,
|
|
102
|
-
});
|
|
103
|
-
return (0, validators_1.validateGoal)(response.data);
|
|
104
|
-
}
|
|
105
|
-
async uncompleteGoal(id, requestId) {
|
|
106
|
-
zod_1.z.string().parse(id);
|
|
107
|
-
const response = await (0, http_client_1.request)({
|
|
108
|
-
httpMethod: 'POST',
|
|
109
|
-
baseUri: this.syncApiBase,
|
|
110
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, id, endpoints_1.GOAL_UNCOMPLETE),
|
|
111
|
-
apiToken: this.authToken,
|
|
112
|
-
customFetch: this.customFetch,
|
|
113
|
-
requestId: requestId,
|
|
114
|
-
});
|
|
115
|
-
return (0, validators_1.validateGoal)(response.data);
|
|
116
|
-
}
|
|
117
|
-
async linkTaskToGoal({ goalId, taskId }, requestId) {
|
|
118
|
-
zod_1.z.string().parse(goalId);
|
|
119
|
-
zod_1.z.string().parse(taskId);
|
|
120
|
-
const response = await (0, http_client_1.request)({
|
|
121
|
-
httpMethod: 'POST',
|
|
122
|
-
baseUri: this.syncApiBase,
|
|
123
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS),
|
|
124
|
-
apiToken: this.authToken,
|
|
125
|
-
customFetch: this.customFetch,
|
|
126
|
-
payload: { itemId: taskId },
|
|
127
|
-
requestId: requestId,
|
|
128
|
-
});
|
|
129
|
-
return (0, validators_1.validateGoal)(response.data);
|
|
130
|
-
}
|
|
131
|
-
async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
|
|
132
|
-
zod_1.z.string().parse(goalId);
|
|
133
|
-
zod_1.z.string().parse(taskId);
|
|
134
|
-
const response = await (0, http_client_1.request)({
|
|
135
|
-
httpMethod: 'DELETE',
|
|
136
|
-
baseUri: this.syncApiBase,
|
|
137
|
-
relativePath: (0, request_helpers_1.generatePath)(endpoints_1.ENDPOINT_REST_GOALS, goalId, endpoints_1.GOAL_TASKS, taskId),
|
|
138
|
-
apiToken: this.authToken,
|
|
139
|
-
customFetch: this.customFetch,
|
|
140
|
-
requestId: requestId,
|
|
141
|
-
});
|
|
142
|
-
return (0, http_client_1.isSuccess)(response);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
exports.GoalsClient = GoalsClient;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./requests"), exports);
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.GoalSchema = exports.GoalProgressSchema = exports.GOAL_OWNER_TYPES = void 0;
|
|
15
|
-
const zod_1 = require("zod");
|
|
16
|
-
/** Available goal owner types. */
|
|
17
|
-
exports.GOAL_OWNER_TYPES = ['USER', 'WORKSPACE'];
|
|
18
|
-
/**
|
|
19
|
-
* Progress of a {@link Goal}.
|
|
20
|
-
*
|
|
21
|
-
* The REST API returns these counts under `total_item_count` / `completed_item_count`,
|
|
22
|
-
* reflecting the backend's generic "item" terminology. The SDK normalizes them to
|
|
23
|
-
* `totalTaskCount` / `completedTaskCount` so the public surface consistently speaks
|
|
24
|
-
* in "tasks" (matching the rest of the SDK). The `preprocess` step below performs
|
|
25
|
-
* that rename after the transport layer's snake_case → camelCase conversion — do not
|
|
26
|
-
* remove it without also changing the downstream field names.
|
|
27
|
-
*/
|
|
28
|
-
exports.GoalProgressSchema = zod_1.z.preprocess((raw) => {
|
|
29
|
-
if (raw === null || raw === undefined || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
30
|
-
return raw;
|
|
31
|
-
}
|
|
32
|
-
const _a = raw, { totalItemCount, completedItemCount, totalTaskCount, completedTaskCount } = _a, rest = __rest(_a, ["totalItemCount", "completedItemCount", "totalTaskCount", "completedTaskCount"]);
|
|
33
|
-
return Object.assign(Object.assign({}, rest), { totalTaskCount: totalTaskCount !== null && totalTaskCount !== void 0 ? totalTaskCount : totalItemCount, completedTaskCount: completedTaskCount !== null && completedTaskCount !== void 0 ? completedTaskCount : completedItemCount });
|
|
34
|
-
}, zod_1.z.looseObject({
|
|
35
|
-
totalTaskCount: zod_1.z.number().int(),
|
|
36
|
-
completedTaskCount: zod_1.z.number().int(),
|
|
37
|
-
percentage: zod_1.z.number(),
|
|
38
|
-
}));
|
|
39
|
-
exports.GoalSchema = zod_1.z.looseObject({
|
|
40
|
-
id: zod_1.z.string(),
|
|
41
|
-
ownerType: zod_1.z.enum(exports.GOAL_OWNER_TYPES),
|
|
42
|
-
ownerId: zod_1.z.string(),
|
|
43
|
-
name: zod_1.z.string(),
|
|
44
|
-
description: zod_1.z.string().nullable(),
|
|
45
|
-
deadline: zod_1.z.string().nullable(),
|
|
46
|
-
parentGoalId: zod_1.z.string().nullable(),
|
|
47
|
-
childOrder: zod_1.z.number().int(),
|
|
48
|
-
isCompleted: zod_1.z.boolean(),
|
|
49
|
-
completedAt: zod_1.z.coerce.date().nullable(),
|
|
50
|
-
responsibleUid: zod_1.z.string().nullable(),
|
|
51
|
-
isDeleted: zod_1.z.boolean(),
|
|
52
|
-
progress: exports.GoalProgressSchema.optional(),
|
|
53
|
-
creatorUid: zod_1.z.string(),
|
|
54
|
-
createdAt: zod_1.z.coerce.date(),
|
|
55
|
-
updatedAt: zod_1.z.coerce.date(),
|
|
56
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ENDPOINT_REST_GOALS, ENDPOINT_REST_GOALS_SEARCH, GOAL_COMPLETE, GOAL_TASKS, GOAL_UNCOMPLETE, } from '../consts/endpoints.js';
|
|
3
|
-
import { isSuccess, request } from '../transport/http-client.js';
|
|
4
|
-
import { generatePath } from '../utils/request-helpers.js';
|
|
5
|
-
import { validateGoal, validateGoalArray } from '../utils/validators.js';
|
|
6
|
-
import { BaseClient } from './base-client.js';
|
|
7
|
-
/**
|
|
8
|
-
* Internal sub-client handling all goal-domain endpoints.
|
|
9
|
-
*
|
|
10
|
-
* Instantiated by `TodoistApi`; every public goal method on `TodoistApi`
|
|
11
|
-
* delegates here. See `todoist-api.ts` for the user-facing JSDoc.
|
|
12
|
-
*/
|
|
13
|
-
export class GoalsClient extends BaseClient {
|
|
14
|
-
async getGoals(args) {
|
|
15
|
-
const { data: { results, nextCursor }, } = await request({
|
|
16
|
-
httpMethod: 'GET',
|
|
17
|
-
baseUri: this.syncApiBase,
|
|
18
|
-
relativePath: ENDPOINT_REST_GOALS,
|
|
19
|
-
apiToken: this.authToken,
|
|
20
|
-
customFetch: this.customFetch,
|
|
21
|
-
payload: args,
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
results: validateGoalArray(results),
|
|
25
|
-
nextCursor,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
async searchGoals(args) {
|
|
29
|
-
const { data: { results, nextCursor }, } = await request({
|
|
30
|
-
httpMethod: 'GET',
|
|
31
|
-
baseUri: this.syncApiBase,
|
|
32
|
-
relativePath: ENDPOINT_REST_GOALS_SEARCH,
|
|
33
|
-
apiToken: this.authToken,
|
|
34
|
-
customFetch: this.customFetch,
|
|
35
|
-
payload: args,
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
results: validateGoalArray(results),
|
|
39
|
-
nextCursor,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
async getGoal(id) {
|
|
43
|
-
z.string().parse(id);
|
|
44
|
-
const response = await request({
|
|
45
|
-
httpMethod: 'GET',
|
|
46
|
-
baseUri: this.syncApiBase,
|
|
47
|
-
relativePath: generatePath(ENDPOINT_REST_GOALS, id),
|
|
48
|
-
apiToken: this.authToken,
|
|
49
|
-
customFetch: this.customFetch,
|
|
50
|
-
});
|
|
51
|
-
return validateGoal(response.data);
|
|
52
|
-
}
|
|
53
|
-
async addGoal(args, requestId) {
|
|
54
|
-
const response = await request({
|
|
55
|
-
httpMethod: 'POST',
|
|
56
|
-
baseUri: this.syncApiBase,
|
|
57
|
-
relativePath: ENDPOINT_REST_GOALS,
|
|
58
|
-
apiToken: this.authToken,
|
|
59
|
-
customFetch: this.customFetch,
|
|
60
|
-
payload: args,
|
|
61
|
-
requestId: requestId,
|
|
62
|
-
});
|
|
63
|
-
return validateGoal(response.data);
|
|
64
|
-
}
|
|
65
|
-
async updateGoal(id, args, requestId) {
|
|
66
|
-
z.string().parse(id);
|
|
67
|
-
const response = await request({
|
|
68
|
-
httpMethod: 'POST',
|
|
69
|
-
baseUri: this.syncApiBase,
|
|
70
|
-
relativePath: generatePath(ENDPOINT_REST_GOALS, id),
|
|
71
|
-
apiToken: this.authToken,
|
|
72
|
-
customFetch: this.customFetch,
|
|
73
|
-
payload: args,
|
|
74
|
-
requestId: requestId,
|
|
75
|
-
});
|
|
76
|
-
return validateGoal(response.data);
|
|
77
|
-
}
|
|
78
|
-
async deleteGoal(id, requestId) {
|
|
79
|
-
z.string().parse(id);
|
|
80
|
-
const response = await request({
|
|
81
|
-
httpMethod: 'DELETE',
|
|
82
|
-
baseUri: this.syncApiBase,
|
|
83
|
-
relativePath: generatePath(ENDPOINT_REST_GOALS, id),
|
|
84
|
-
apiToken: this.authToken,
|
|
85
|
-
customFetch: this.customFetch,
|
|
86
|
-
requestId: requestId,
|
|
87
|
-
});
|
|
88
|
-
return isSuccess(response);
|
|
89
|
-
}
|
|
90
|
-
async completeGoal(id, requestId) {
|
|
91
|
-
z.string().parse(id);
|
|
92
|
-
const response = await request({
|
|
93
|
-
httpMethod: 'POST',
|
|
94
|
-
baseUri: this.syncApiBase,
|
|
95
|
-
relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_COMPLETE),
|
|
96
|
-
apiToken: this.authToken,
|
|
97
|
-
customFetch: this.customFetch,
|
|
98
|
-
requestId: requestId,
|
|
99
|
-
});
|
|
100
|
-
return validateGoal(response.data);
|
|
101
|
-
}
|
|
102
|
-
async uncompleteGoal(id, requestId) {
|
|
103
|
-
z.string().parse(id);
|
|
104
|
-
const response = await request({
|
|
105
|
-
httpMethod: 'POST',
|
|
106
|
-
baseUri: this.syncApiBase,
|
|
107
|
-
relativePath: generatePath(ENDPOINT_REST_GOALS, id, GOAL_UNCOMPLETE),
|
|
108
|
-
apiToken: this.authToken,
|
|
109
|
-
customFetch: this.customFetch,
|
|
110
|
-
requestId: requestId,
|
|
111
|
-
});
|
|
112
|
-
return validateGoal(response.data);
|
|
113
|
-
}
|
|
114
|
-
async linkTaskToGoal({ goalId, taskId }, requestId) {
|
|
115
|
-
z.string().parse(goalId);
|
|
116
|
-
z.string().parse(taskId);
|
|
117
|
-
const response = await request({
|
|
118
|
-
httpMethod: 'POST',
|
|
119
|
-
baseUri: this.syncApiBase,
|
|
120
|
-
relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS),
|
|
121
|
-
apiToken: this.authToken,
|
|
122
|
-
customFetch: this.customFetch,
|
|
123
|
-
payload: { itemId: taskId },
|
|
124
|
-
requestId: requestId,
|
|
125
|
-
});
|
|
126
|
-
return validateGoal(response.data);
|
|
127
|
-
}
|
|
128
|
-
async unlinkTaskFromGoal({ goalId, taskId }, requestId) {
|
|
129
|
-
z.string().parse(goalId);
|
|
130
|
-
z.string().parse(taskId);
|
|
131
|
-
const response = await request({
|
|
132
|
-
httpMethod: 'DELETE',
|
|
133
|
-
baseUri: this.syncApiBase,
|
|
134
|
-
relativePath: generatePath(ENDPOINT_REST_GOALS, goalId, GOAL_TASKS, taskId),
|
|
135
|
-
apiToken: this.authToken,
|
|
136
|
-
customFetch: this.customFetch,
|
|
137
|
-
requestId: requestId,
|
|
138
|
-
});
|
|
139
|
-
return isSuccess(response);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|