@doist/todoist-sdk 9.1.0-next.2 → 9.1.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/authentication.js +1 -0
- package/dist/cjs/clients/app-client.js +347 -0
- package/dist/cjs/clients/base-client.js +1 -0
- package/dist/cjs/clients/ui-extension-client.js +109 -0
- package/dist/cjs/consts/endpoints.js +70 -6
- package/dist/cjs/test-utils/test-defaults.js +75 -23
- package/dist/cjs/todoist-api.js +269 -33
- package/dist/cjs/transport/http-client.js +1 -0
- package/dist/cjs/types/apps/types.js +253 -0
- package/dist/cjs/types/index.js +2 -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/types/ui-extensions/index.js +18 -0
- package/dist/cjs/types/ui-extensions/types.js +77 -0
- package/dist/cjs/utils/validators.js +45 -33
- package/dist/esm/authentication.js +1 -0
- package/dist/esm/clients/app-client.js +343 -0
- package/dist/esm/clients/base-client.js +1 -0
- package/dist/esm/clients/ui-extension-client.js +105 -0
- package/dist/esm/consts/endpoints.js +54 -5
- package/dist/esm/test-utils/test-defaults.js +73 -22
- package/dist/esm/todoist-api.js +269 -33
- package/dist/esm/transport/http-client.js +1 -0
- package/dist/esm/types/apps/types.js +248 -0
- package/dist/esm/types/index.js +2 -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/types/ui-extensions/types.js +74 -0
- package/dist/esm/utils/validators.js +14 -2
- package/dist/types/authentication.d.ts +1 -1
- package/dist/types/clients/app-client.d.ts +37 -0
- package/dist/types/clients/base-client.d.ts +1 -0
- package/dist/types/clients/ui-extension-client.d.ts +18 -0
- package/dist/types/consts/endpoints.d.ts +25 -5
- package/dist/types/test-utils/test-defaults.d.ts +16 -4
- package/dist/types/todoist-api.d.ts +202 -12
- package/dist/types/types/apps/index.d.ts +2 -0
- package/dist/types/types/apps/requests.d.ts +89 -0
- package/dist/types/types/apps/types.d.ts +414 -0
- package/dist/types/types/http.d.ts +1 -1
- package/dist/types/types/index.d.ts +2 -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/user.d.ts +2 -2
- package/dist/types/types/sync/resources/view-options.d.ts +6 -6
- package/dist/types/types/sync/response.d.ts +6 -31
- package/dist/types/types/sync/user-preferences.d.ts +1 -1
- package/dist/types/types/tasks/requests.d.ts +0 -1
- package/dist/types/types/ui-extensions/index.d.ts +2 -0
- package/dist/types/types/ui-extensions/requests.d.ts +108 -0
- package/dist/types/types/ui-extensions/types.d.ts +185 -0
- package/dist/types/utils/validators.d.ts +231 -55
- package/package.json +1 -1
- package/dist/cjs/clients/goals-client.js +0 -145
- package/dist/cjs/types/goals/types.js +0 -56
- package/dist/esm/clients/goals-client.js +0 -141
- package/dist/esm/types/goals/types.js +0 -53
- package/dist/types/clients/goals-client.d.ts +0 -20
- 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
- /package/dist/cjs/types/{goals → apps}/index.js +0 -0
- /package/dist/cjs/types/{goals → apps}/requests.js +0 -0
- /package/dist/cjs/types/{sync/commands/goals.js → ui-extensions/requests.js} +0 -0
- /package/dist/esm/types/{goals → apps}/index.js +0 -0
- /package/dist/esm/types/{goals → apps}/requests.js +0 -0
- /package/dist/{types/types/goals/index.d.ts → esm/types/ui-extensions/index.js} +0 -0
- /package/dist/esm/types/{sync/commands/goals.js → ui-extensions/requests.js} +0 -0
|
@@ -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;
|
|
@@ -1567,3 +1520,226 @@ export declare const validateSuggestion: (input: unknown) => {
|
|
|
1567
1520
|
isDeleted: boolean;
|
|
1568
1521
|
})[];
|
|
1569
1522
|
export declare function parseSyncResponse(raw: Record<string, unknown>): SyncResponse;
|
|
1523
|
+
export declare const validateApp: (input: unknown) => {
|
|
1524
|
+
id: string;
|
|
1525
|
+
status: "public";
|
|
1526
|
+
displayName: string;
|
|
1527
|
+
userId: string;
|
|
1528
|
+
createdAt: Date;
|
|
1529
|
+
serviceUrl: string | null;
|
|
1530
|
+
oauthRedirectUri: string | null;
|
|
1531
|
+
description: string | null;
|
|
1532
|
+
iconSm: string | null;
|
|
1533
|
+
iconMd: string | null;
|
|
1534
|
+
iconLg: string | null;
|
|
1535
|
+
appTokenScopes: string[] | null;
|
|
1536
|
+
}, validateAppArray: (input: unknown) => {
|
|
1537
|
+
id: string;
|
|
1538
|
+
status: "public";
|
|
1539
|
+
displayName: string;
|
|
1540
|
+
userId: string;
|
|
1541
|
+
createdAt: Date;
|
|
1542
|
+
serviceUrl: string | null;
|
|
1543
|
+
oauthRedirectUri: string | null;
|
|
1544
|
+
description: string | null;
|
|
1545
|
+
iconSm: string | null;
|
|
1546
|
+
iconMd: string | null;
|
|
1547
|
+
iconLg: string | null;
|
|
1548
|
+
appTokenScopes: string[] | null;
|
|
1549
|
+
}[];
|
|
1550
|
+
export declare const validateAppWithUserCount: (input: unknown) => {
|
|
1551
|
+
id: string;
|
|
1552
|
+
status: "public";
|
|
1553
|
+
displayName: string;
|
|
1554
|
+
userId: string;
|
|
1555
|
+
createdAt: Date;
|
|
1556
|
+
serviceUrl: string | null;
|
|
1557
|
+
oauthRedirectUri: string | null;
|
|
1558
|
+
description: string | null;
|
|
1559
|
+
iconSm: string | null;
|
|
1560
|
+
iconMd: string | null;
|
|
1561
|
+
iconLg: string | null;
|
|
1562
|
+
appTokenScopes: string[] | null;
|
|
1563
|
+
userCount: number;
|
|
1564
|
+
};
|
|
1565
|
+
export declare const validateAppSecrets: (input: unknown) => {
|
|
1566
|
+
clientId: string;
|
|
1567
|
+
clientSecret: string;
|
|
1568
|
+
};
|
|
1569
|
+
export declare const validateAppVerificationToken: (input: unknown) => {
|
|
1570
|
+
verificationToken: string;
|
|
1571
|
+
};
|
|
1572
|
+
export declare const validateAppTestToken: (input: unknown) => {
|
|
1573
|
+
accessToken?: string | null | undefined;
|
|
1574
|
+
};
|
|
1575
|
+
export declare const validateAppDistributionToken: (input: unknown) => {
|
|
1576
|
+
distributionToken: string;
|
|
1577
|
+
};
|
|
1578
|
+
export declare const validateAppByDistributionToken: (input: unknown) => {
|
|
1579
|
+
id: string;
|
|
1580
|
+
displayName: string;
|
|
1581
|
+
description: string | null;
|
|
1582
|
+
iconMd: string | null;
|
|
1583
|
+
appTokenScopes: string[] | null;
|
|
1584
|
+
uiExtensions: {
|
|
1585
|
+
name: string;
|
|
1586
|
+
description: string;
|
|
1587
|
+
icon: string | null;
|
|
1588
|
+
extensionType: "context-menu" | "composer" | "settings";
|
|
1589
|
+
}[];
|
|
1590
|
+
};
|
|
1591
|
+
export declare const validateAppWebhook: (input: unknown) => {
|
|
1592
|
+
status: "active" | "invalid";
|
|
1593
|
+
callbackUrl: string;
|
|
1594
|
+
version: "1";
|
|
1595
|
+
events: ("project:added" | "project:updated" | "project:deleted" | "project:archived" | "project:unarchived" | "item:added" | "item:updated" | "item:completed" | "item:uncompleted" | "item:deleted" | "note:added" | "note:updated" | "note:deleted" | "section:added" | "section:updated" | "section:deleted" | "section:archived" | "section:unarchived" | "label:added" | "label:updated" | "label:deleted" | "filter:added" | "filter:updated" | "filter:deleted" | "reminder:fired")[];
|
|
1596
|
+
};
|
|
1597
|
+
export declare const validateAppInstallation: (input: unknown) => {
|
|
1598
|
+
id: string;
|
|
1599
|
+
creator: string;
|
|
1600
|
+
createdTs: number;
|
|
1601
|
+
installationType: "user";
|
|
1602
|
+
appTokenScopesValidated: boolean;
|
|
1603
|
+
integration: {
|
|
1604
|
+
id: string;
|
|
1605
|
+
status: "public";
|
|
1606
|
+
displayName: string;
|
|
1607
|
+
userId: string;
|
|
1608
|
+
createdAt: Date;
|
|
1609
|
+
serviceUrl: string | null;
|
|
1610
|
+
oauthRedirectUri: string | null;
|
|
1611
|
+
description: string | null;
|
|
1612
|
+
iconSm: string | null;
|
|
1613
|
+
iconMd: string | null;
|
|
1614
|
+
iconLg: string | null;
|
|
1615
|
+
appTokenScopes: string[] | null;
|
|
1616
|
+
} | null;
|
|
1617
|
+
}, validateAppInstallationArray: (input: unknown) => {
|
|
1618
|
+
id: string;
|
|
1619
|
+
creator: string;
|
|
1620
|
+
createdTs: number;
|
|
1621
|
+
installationType: "user";
|
|
1622
|
+
appTokenScopesValidated: boolean;
|
|
1623
|
+
integration: {
|
|
1624
|
+
id: string;
|
|
1625
|
+
status: "public";
|
|
1626
|
+
displayName: string;
|
|
1627
|
+
userId: string;
|
|
1628
|
+
createdAt: Date;
|
|
1629
|
+
serviceUrl: string | null;
|
|
1630
|
+
oauthRedirectUri: string | null;
|
|
1631
|
+
description: string | null;
|
|
1632
|
+
iconSm: string | null;
|
|
1633
|
+
iconMd: string | null;
|
|
1634
|
+
iconLg: string | null;
|
|
1635
|
+
appTokenScopes: string[] | null;
|
|
1636
|
+
} | null;
|
|
1637
|
+
}[];
|
|
1638
|
+
export declare const validateUserAuthorization: (input: unknown) => {
|
|
1639
|
+
accessTokenId: string;
|
|
1640
|
+
scope: string[];
|
|
1641
|
+
scopeDescriptions: string[];
|
|
1642
|
+
createdAt: Date;
|
|
1643
|
+
app: {
|
|
1644
|
+
id: string;
|
|
1645
|
+
displayName: string;
|
|
1646
|
+
description: string | null;
|
|
1647
|
+
serviceUrl: string | null;
|
|
1648
|
+
iconMd: string | null;
|
|
1649
|
+
} | null;
|
|
1650
|
+
}, validateUserAuthorizationArray: (input: unknown) => {
|
|
1651
|
+
accessTokenId: string;
|
|
1652
|
+
scope: string[];
|
|
1653
|
+
scopeDescriptions: string[];
|
|
1654
|
+
createdAt: Date;
|
|
1655
|
+
app: {
|
|
1656
|
+
id: string;
|
|
1657
|
+
displayName: string;
|
|
1658
|
+
description: string | null;
|
|
1659
|
+
serviceUrl: string | null;
|
|
1660
|
+
iconMd: string | null;
|
|
1661
|
+
} | null;
|
|
1662
|
+
}[];
|
|
1663
|
+
export declare const validateUiExtension: (input: unknown) => {
|
|
1664
|
+
id: string;
|
|
1665
|
+
integrationId: string;
|
|
1666
|
+
extensionId: string;
|
|
1667
|
+
url: string;
|
|
1668
|
+
icon: string | null;
|
|
1669
|
+
name: string;
|
|
1670
|
+
description: string;
|
|
1671
|
+
width: number | null;
|
|
1672
|
+
height: number | null;
|
|
1673
|
+
defVersion: number;
|
|
1674
|
+
minimumCardistVersion: string;
|
|
1675
|
+
extensionType: "context-menu";
|
|
1676
|
+
contextType: "task" | "project";
|
|
1677
|
+
} | {
|
|
1678
|
+
id: string;
|
|
1679
|
+
integrationId: string;
|
|
1680
|
+
extensionId: string;
|
|
1681
|
+
url: string;
|
|
1682
|
+
icon: string | null;
|
|
1683
|
+
name: string;
|
|
1684
|
+
description: string;
|
|
1685
|
+
width: number | null;
|
|
1686
|
+
height: number | null;
|
|
1687
|
+
defVersion: number;
|
|
1688
|
+
minimumCardistVersion: string;
|
|
1689
|
+
extensionType: "composer";
|
|
1690
|
+
composerType: "task" | "comment";
|
|
1691
|
+
} | {
|
|
1692
|
+
id: string;
|
|
1693
|
+
integrationId: string;
|
|
1694
|
+
extensionId: string;
|
|
1695
|
+
url: string;
|
|
1696
|
+
icon: string | null;
|
|
1697
|
+
name: string;
|
|
1698
|
+
description: string;
|
|
1699
|
+
width: number | null;
|
|
1700
|
+
height: number | null;
|
|
1701
|
+
defVersion: number;
|
|
1702
|
+
minimumCardistVersion: string;
|
|
1703
|
+
extensionType: "settings";
|
|
1704
|
+
}, validateUiExtensionArray: (input: unknown) => ({
|
|
1705
|
+
id: string;
|
|
1706
|
+
integrationId: string;
|
|
1707
|
+
extensionId: string;
|
|
1708
|
+
url: string;
|
|
1709
|
+
icon: string | null;
|
|
1710
|
+
name: string;
|
|
1711
|
+
description: string;
|
|
1712
|
+
width: number | null;
|
|
1713
|
+
height: number | null;
|
|
1714
|
+
defVersion: number;
|
|
1715
|
+
minimumCardistVersion: string;
|
|
1716
|
+
extensionType: "context-menu";
|
|
1717
|
+
contextType: "task" | "project";
|
|
1718
|
+
} | {
|
|
1719
|
+
id: string;
|
|
1720
|
+
integrationId: string;
|
|
1721
|
+
extensionId: string;
|
|
1722
|
+
url: string;
|
|
1723
|
+
icon: string | null;
|
|
1724
|
+
name: string;
|
|
1725
|
+
description: string;
|
|
1726
|
+
width: number | null;
|
|
1727
|
+
height: number | null;
|
|
1728
|
+
defVersion: number;
|
|
1729
|
+
minimumCardistVersion: string;
|
|
1730
|
+
extensionType: "composer";
|
|
1731
|
+
composerType: "task" | "comment";
|
|
1732
|
+
} | {
|
|
1733
|
+
id: string;
|
|
1734
|
+
integrationId: string;
|
|
1735
|
+
extensionId: string;
|
|
1736
|
+
url: string;
|
|
1737
|
+
icon: string | null;
|
|
1738
|
+
name: string;
|
|
1739
|
+
description: string;
|
|
1740
|
+
width: number | null;
|
|
1741
|
+
height: number | null;
|
|
1742
|
+
defVersion: number;
|
|
1743
|
+
minimumCardistVersion: string;
|
|
1744
|
+
extensionType: "settings";
|
|
1745
|
+
})[];
|
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,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
|
-
}
|