@doist/comms-sdk 0.4.4 → 0.4.6
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/comments-client.js +3 -6
- package/dist/cjs/testUtils/test-defaults.js +4 -4
- package/dist/cjs/utils/url-helpers.js +14 -14
- package/dist/esm/clients/comments-client.js +3 -6
- package/dist/esm/testUtils/test-defaults.js +4 -4
- package/dist/esm/utils/url-helpers.js +14 -14
- package/dist/types/clients/comments-client.d.ts +2 -2
- package/dist/types/utils/url-helpers.d.ts +2 -2
- package/package.json +1 -1
|
@@ -23,10 +23,6 @@ class CommentsClient extends base_client_1.BaseClient {
|
|
|
23
23
|
this.commentListSchema = this.linkBaseUrl
|
|
24
24
|
? zod_1.z.array(this.commentSchema)
|
|
25
25
|
: exports.CommentListSchema;
|
|
26
|
-
// `getone` wraps the comment in `{ comment: ... }`; built once per client.
|
|
27
|
-
this.wrappedCommentSchema = zod_1.z
|
|
28
|
-
.object({ comment: this.commentSchema })
|
|
29
|
-
.transform((data) => data.comment);
|
|
30
26
|
}
|
|
31
27
|
/**
|
|
32
28
|
* Gets all comments for a thread. `newerThan` / `olderThan` (`Date`) are
|
|
@@ -67,7 +63,8 @@ class CommentsClient extends base_client_1.BaseClient {
|
|
|
67
63
|
}).then((response) => this.commentListSchema.parse(response.data));
|
|
68
64
|
}
|
|
69
65
|
/**
|
|
70
|
-
* Gets a single comment object by id. The
|
|
66
|
+
* Gets a single comment object by id. The `getone` endpoint returns the
|
|
67
|
+
* comment object directly (the same shape as `add`), not wrapped.
|
|
71
68
|
*
|
|
72
69
|
* @param id - The comment ID.
|
|
73
70
|
* @returns The comment object.
|
|
@@ -80,7 +77,7 @@ class CommentsClient extends base_client_1.BaseClient {
|
|
|
80
77
|
apiToken: this.apiToken,
|
|
81
78
|
payload: { id },
|
|
82
79
|
customFetch: this.customFetch,
|
|
83
|
-
}).then((response) => this.
|
|
80
|
+
}).then((response) => this.commentSchema.parse(response.data));
|
|
84
81
|
}
|
|
85
82
|
/**
|
|
86
83
|
* Creates a new comment on a thread. `id` is auto-generated if not supplied.
|
|
@@ -35,7 +35,7 @@ exports.mockChannel = {
|
|
|
35
35
|
archived: false,
|
|
36
36
|
created: new Date('2021-01-01T00:00:00Z'),
|
|
37
37
|
version: 0,
|
|
38
|
-
url: `https://comms.todoist.com/
|
|
38
|
+
url: `https://comms.todoist.com/1/ch/${exports.TEST_CHANNEL_ID}/`,
|
|
39
39
|
};
|
|
40
40
|
exports.mockThread = {
|
|
41
41
|
id: exports.TEST_THREAD_ID,
|
|
@@ -51,7 +51,7 @@ exports.mockThread = {
|
|
|
51
51
|
snippet: 'This is a test thread',
|
|
52
52
|
snippetCreator: 1,
|
|
53
53
|
isArchived: false,
|
|
54
|
-
url: `https://comms.todoist.com/
|
|
54
|
+
url: `https://comms.todoist.com/1/ch/${exports.TEST_CHANNEL_ID}/t/${exports.TEST_THREAD_ID}/`,
|
|
55
55
|
};
|
|
56
56
|
exports.mockGroup = {
|
|
57
57
|
id: exports.TEST_GROUP_ID,
|
|
@@ -72,7 +72,7 @@ exports.mockConversation = {
|
|
|
72
72
|
archived: false,
|
|
73
73
|
created: new Date('2021-01-01T00:00:00Z'),
|
|
74
74
|
creator: 1,
|
|
75
|
-
url: `https://comms.todoist.com/
|
|
75
|
+
url: `https://comms.todoist.com/1/msg/${exports.TEST_CONVERSATION_ID}/`,
|
|
76
76
|
};
|
|
77
77
|
exports.mockComment = {
|
|
78
78
|
id: exports.TEST_COMMENT_ID,
|
|
@@ -82,7 +82,7 @@ exports.mockComment = {
|
|
|
82
82
|
workspaceId: 1,
|
|
83
83
|
channelId: exports.TEST_CHANNEL_ID,
|
|
84
84
|
posted: new Date('2021-01-01T00:00:00Z'),
|
|
85
|
-
url: `https://comms.todoist.com/
|
|
85
|
+
url: `https://comms.todoist.com/1/ch/${exports.TEST_CHANNEL_ID}/t/${exports.TEST_THREAD_ID}/c/${exports.TEST_COMMENT_ID}`,
|
|
86
86
|
};
|
|
87
87
|
exports.mockWorkspaceUser = {
|
|
88
88
|
id: 1,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Helper functions for creating Comms permalinks (`https://comms.todoist.com
|
|
3
|
+
* Helper functions for creating Comms permalinks (`https://comms.todoist.com/...`).
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getCommsURL = getCommsURL;
|
|
@@ -27,11 +27,11 @@ const COMMS_BASE_URL = 'https://comms.todoist.com';
|
|
|
27
27
|
* @returns A relative URL path
|
|
28
28
|
* @example
|
|
29
29
|
* getCommsURL({ workspaceId: 1, channelId: '7Yp...', threadId: '7Yq...' })
|
|
30
|
-
* // returns '/
|
|
30
|
+
* // returns '/1/ch/7Yp.../t/7Yq.../'
|
|
31
31
|
*/
|
|
32
32
|
function getCommsURL(params) {
|
|
33
33
|
const { workspaceId, channelId, conversationId, threadId, commentId, messageId, userId } = params;
|
|
34
|
-
let url =
|
|
34
|
+
let url = `/${workspaceId}/`;
|
|
35
35
|
if (channelId) {
|
|
36
36
|
url += `ch/${channelId}/`;
|
|
37
37
|
if (threadId) {
|
|
@@ -90,44 +90,44 @@ function getCommentURL(params) {
|
|
|
90
90
|
}
|
|
91
91
|
/** Returns the URL for the threads root (channels view). */
|
|
92
92
|
function getThreadsRootURL(workspaceId) {
|
|
93
|
-
return
|
|
93
|
+
return `/${workspaceId}/ch`;
|
|
94
94
|
}
|
|
95
95
|
/** Returns the URL for the inbox. */
|
|
96
96
|
function getInboxURL(workspaceId, tab) {
|
|
97
97
|
const tabParam = tab ? `/${tab}` : '';
|
|
98
|
-
return
|
|
98
|
+
return `/${workspaceId}/inbox${tabParam}`;
|
|
99
99
|
}
|
|
100
100
|
/** Returns the URL for the messages/conversations root. */
|
|
101
101
|
function getMessagesRootURL(workspaceId) {
|
|
102
|
-
return
|
|
102
|
+
return `/${workspaceId}/msg`;
|
|
103
103
|
}
|
|
104
104
|
/** Returns the URL for a user profile. */
|
|
105
105
|
function getUserProfileURL(params) {
|
|
106
|
-
return
|
|
106
|
+
return `/${params.workspaceId}/people/u/${params.userId}`;
|
|
107
107
|
}
|
|
108
108
|
/** Returns the URL for the saved threads view. */
|
|
109
109
|
function getSavedThreadsRootURL(workspaceId) {
|
|
110
|
-
return
|
|
110
|
+
return `/${workspaceId}/saved`;
|
|
111
111
|
}
|
|
112
112
|
/** Returns the URL for a saved thread. */
|
|
113
113
|
function getSavedThreadURL(params) {
|
|
114
|
-
return
|
|
114
|
+
return `/${params.workspaceId}/saved/t/${params.threadId}`;
|
|
115
115
|
}
|
|
116
116
|
/** Returns the URL for the search root. */
|
|
117
117
|
function getSearchRootURL(workspaceId) {
|
|
118
|
-
return
|
|
118
|
+
return `/${workspaceId}/search`;
|
|
119
119
|
}
|
|
120
120
|
/** Returns the URL for a search with a query. */
|
|
121
121
|
function getSearchQueryURL(params) {
|
|
122
|
-
return
|
|
122
|
+
return `/${params.workspaceId}/search?q=${decodeURIComponent(params.query)}`;
|
|
123
123
|
}
|
|
124
124
|
/** Returns the URL for settings. */
|
|
125
125
|
function getSettingsURL(params) {
|
|
126
126
|
return params.initialLocation
|
|
127
|
-
?
|
|
128
|
-
:
|
|
127
|
+
? `/${params.workspaceId}/settings/${params.initialLocation}`
|
|
128
|
+
: `/${params.workspaceId}/settings`;
|
|
129
129
|
}
|
|
130
130
|
/** Returns the URL for the team members root. */
|
|
131
131
|
function getTeamMembersRootURL(workspaceId) {
|
|
132
|
-
return
|
|
132
|
+
return `/${workspaceId}/people/u`;
|
|
133
133
|
}
|
|
@@ -20,10 +20,6 @@ export class CommentsClient extends BaseClient {
|
|
|
20
20
|
this.commentListSchema = this.linkBaseUrl
|
|
21
21
|
? z.array(this.commentSchema)
|
|
22
22
|
: CommentListSchema;
|
|
23
|
-
// `getone` wraps the comment in `{ comment: ... }`; built once per client.
|
|
24
|
-
this.wrappedCommentSchema = z
|
|
25
|
-
.object({ comment: this.commentSchema })
|
|
26
|
-
.transform((data) => data.comment);
|
|
27
23
|
}
|
|
28
24
|
/**
|
|
29
25
|
* Gets all comments for a thread. `newerThan` / `olderThan` (`Date`) are
|
|
@@ -64,7 +60,8 @@ export class CommentsClient extends BaseClient {
|
|
|
64
60
|
}).then((response) => this.commentListSchema.parse(response.data));
|
|
65
61
|
}
|
|
66
62
|
/**
|
|
67
|
-
* Gets a single comment object by id. The
|
|
63
|
+
* Gets a single comment object by id. The `getone` endpoint returns the
|
|
64
|
+
* comment object directly (the same shape as `add`), not wrapped.
|
|
68
65
|
*
|
|
69
66
|
* @param id - The comment ID.
|
|
70
67
|
* @returns The comment object.
|
|
@@ -77,7 +74,7 @@ export class CommentsClient extends BaseClient {
|
|
|
77
74
|
apiToken: this.apiToken,
|
|
78
75
|
payload: { id },
|
|
79
76
|
customFetch: this.customFetch,
|
|
80
|
-
}).then((response) => this.
|
|
77
|
+
}).then((response) => this.commentSchema.parse(response.data));
|
|
81
78
|
}
|
|
82
79
|
/**
|
|
83
80
|
* Creates a new comment on a thread. `id` is auto-generated if not supplied.
|
|
@@ -32,7 +32,7 @@ export const mockChannel = {
|
|
|
32
32
|
archived: false,
|
|
33
33
|
created: new Date('2021-01-01T00:00:00Z'),
|
|
34
34
|
version: 0,
|
|
35
|
-
url: `https://comms.todoist.com/
|
|
35
|
+
url: `https://comms.todoist.com/1/ch/${TEST_CHANNEL_ID}/`,
|
|
36
36
|
};
|
|
37
37
|
export const mockThread = {
|
|
38
38
|
id: TEST_THREAD_ID,
|
|
@@ -48,7 +48,7 @@ export const mockThread = {
|
|
|
48
48
|
snippet: 'This is a test thread',
|
|
49
49
|
snippetCreator: 1,
|
|
50
50
|
isArchived: false,
|
|
51
|
-
url: `https://comms.todoist.com/
|
|
51
|
+
url: `https://comms.todoist.com/1/ch/${TEST_CHANNEL_ID}/t/${TEST_THREAD_ID}/`,
|
|
52
52
|
};
|
|
53
53
|
export const mockGroup = {
|
|
54
54
|
id: TEST_GROUP_ID,
|
|
@@ -69,7 +69,7 @@ export const mockConversation = {
|
|
|
69
69
|
archived: false,
|
|
70
70
|
created: new Date('2021-01-01T00:00:00Z'),
|
|
71
71
|
creator: 1,
|
|
72
|
-
url: `https://comms.todoist.com/
|
|
72
|
+
url: `https://comms.todoist.com/1/msg/${TEST_CONVERSATION_ID}/`,
|
|
73
73
|
};
|
|
74
74
|
export const mockComment = {
|
|
75
75
|
id: TEST_COMMENT_ID,
|
|
@@ -79,7 +79,7 @@ export const mockComment = {
|
|
|
79
79
|
workspaceId: 1,
|
|
80
80
|
channelId: TEST_CHANNEL_ID,
|
|
81
81
|
posted: new Date('2021-01-01T00:00:00Z'),
|
|
82
|
-
url: `https://comms.todoist.com/
|
|
82
|
+
url: `https://comms.todoist.com/1/ch/${TEST_CHANNEL_ID}/t/${TEST_THREAD_ID}/c/${TEST_COMMENT_ID}`,
|
|
83
83
|
};
|
|
84
84
|
export const mockWorkspaceUser = {
|
|
85
85
|
id: 1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Helper functions for creating Comms permalinks (`https://comms.todoist.com
|
|
2
|
+
* Helper functions for creating Comms permalinks (`https://comms.todoist.com/...`).
|
|
3
3
|
*/
|
|
4
4
|
const COMMS_BASE_URL = 'https://comms.todoist.com';
|
|
5
5
|
/**
|
|
@@ -8,11 +8,11 @@ const COMMS_BASE_URL = 'https://comms.todoist.com';
|
|
|
8
8
|
* @returns A relative URL path
|
|
9
9
|
* @example
|
|
10
10
|
* getCommsURL({ workspaceId: 1, channelId: '7Yp...', threadId: '7Yq...' })
|
|
11
|
-
* // returns '/
|
|
11
|
+
* // returns '/1/ch/7Yp.../t/7Yq.../'
|
|
12
12
|
*/
|
|
13
13
|
export function getCommsURL(params) {
|
|
14
14
|
const { workspaceId, channelId, conversationId, threadId, commentId, messageId, userId } = params;
|
|
15
|
-
let url =
|
|
15
|
+
let url = `/${workspaceId}/`;
|
|
16
16
|
if (channelId) {
|
|
17
17
|
url += `ch/${channelId}/`;
|
|
18
18
|
if (threadId) {
|
|
@@ -71,44 +71,44 @@ export function getCommentURL(params) {
|
|
|
71
71
|
}
|
|
72
72
|
/** Returns the URL for the threads root (channels view). */
|
|
73
73
|
export function getThreadsRootURL(workspaceId) {
|
|
74
|
-
return
|
|
74
|
+
return `/${workspaceId}/ch`;
|
|
75
75
|
}
|
|
76
76
|
/** Returns the URL for the inbox. */
|
|
77
77
|
export function getInboxURL(workspaceId, tab) {
|
|
78
78
|
const tabParam = tab ? `/${tab}` : '';
|
|
79
|
-
return
|
|
79
|
+
return `/${workspaceId}/inbox${tabParam}`;
|
|
80
80
|
}
|
|
81
81
|
/** Returns the URL for the messages/conversations root. */
|
|
82
82
|
export function getMessagesRootURL(workspaceId) {
|
|
83
|
-
return
|
|
83
|
+
return `/${workspaceId}/msg`;
|
|
84
84
|
}
|
|
85
85
|
/** Returns the URL for a user profile. */
|
|
86
86
|
export function getUserProfileURL(params) {
|
|
87
|
-
return
|
|
87
|
+
return `/${params.workspaceId}/people/u/${params.userId}`;
|
|
88
88
|
}
|
|
89
89
|
/** Returns the URL for the saved threads view. */
|
|
90
90
|
export function getSavedThreadsRootURL(workspaceId) {
|
|
91
|
-
return
|
|
91
|
+
return `/${workspaceId}/saved`;
|
|
92
92
|
}
|
|
93
93
|
/** Returns the URL for a saved thread. */
|
|
94
94
|
export function getSavedThreadURL(params) {
|
|
95
|
-
return
|
|
95
|
+
return `/${params.workspaceId}/saved/t/${params.threadId}`;
|
|
96
96
|
}
|
|
97
97
|
/** Returns the URL for the search root. */
|
|
98
98
|
export function getSearchRootURL(workspaceId) {
|
|
99
|
-
return
|
|
99
|
+
return `/${workspaceId}/search`;
|
|
100
100
|
}
|
|
101
101
|
/** Returns the URL for a search with a query. */
|
|
102
102
|
export function getSearchQueryURL(params) {
|
|
103
|
-
return
|
|
103
|
+
return `/${params.workspaceId}/search?q=${decodeURIComponent(params.query)}`;
|
|
104
104
|
}
|
|
105
105
|
/** Returns the URL for settings. */
|
|
106
106
|
export function getSettingsURL(params) {
|
|
107
107
|
return params.initialLocation
|
|
108
|
-
?
|
|
109
|
-
:
|
|
108
|
+
? `/${params.workspaceId}/settings/${params.initialLocation}`
|
|
109
|
+
: `/${params.workspaceId}/settings`;
|
|
110
110
|
}
|
|
111
111
|
/** Returns the URL for the team members root. */
|
|
112
112
|
export function getTeamMembersRootURL(workspaceId) {
|
|
113
|
-
return
|
|
113
|
+
return `/${workspaceId}/people/u`;
|
|
114
114
|
}
|
|
@@ -137,7 +137,6 @@ export declare class CommentsClient extends BaseClient {
|
|
|
137
137
|
private readonly linkBaseUrl;
|
|
138
138
|
private readonly commentSchema;
|
|
139
139
|
private readonly commentListSchema;
|
|
140
|
-
private readonly wrappedCommentSchema;
|
|
141
140
|
/**
|
|
142
141
|
* Gets all comments for a thread. `newerThan` / `olderThan` (`Date`) are
|
|
143
142
|
* converted to `newer_than_ts` / `older_than_ts` epoch seconds on the
|
|
@@ -161,7 +160,8 @@ export declare class CommentsClient extends BaseClient {
|
|
|
161
160
|
*/
|
|
162
161
|
getComments(args: GetCommentsArgs): Promise<Comment[]>;
|
|
163
162
|
/**
|
|
164
|
-
* Gets a single comment object by id. The
|
|
163
|
+
* Gets a single comment object by id. The `getone` endpoint returns the
|
|
164
|
+
* comment object directly (the same shape as `add`), not wrapped.
|
|
165
165
|
*
|
|
166
166
|
* @param id - The comment ID.
|
|
167
167
|
* @returns The comment object.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Helper functions for creating Comms permalinks (`https://comms.todoist.com
|
|
2
|
+
* Helper functions for creating Comms permalinks (`https://comms.todoist.com/...`).
|
|
3
3
|
*/
|
|
4
4
|
export type CommsURLParams = {
|
|
5
5
|
workspaceId: number;
|
|
@@ -16,7 +16,7 @@ export type CommsURLParams = {
|
|
|
16
16
|
* @returns A relative URL path
|
|
17
17
|
* @example
|
|
18
18
|
* getCommsURL({ workspaceId: 1, channelId: '7Yp...', threadId: '7Yq...' })
|
|
19
|
-
* // returns '/
|
|
19
|
+
* // returns '/1/ch/7Yp.../t/7Yq.../'
|
|
20
20
|
*/
|
|
21
21
|
export declare function getCommsURL(params: CommsURLParams): string;
|
|
22
22
|
/**
|