@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.
@@ -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 API wraps it in `{comment: ...}`.
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.wrappedCommentSchema.parse(response.data));
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/a/1/ch/${exports.TEST_CHANNEL_ID}/`,
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/a/1/ch/${exports.TEST_CHANNEL_ID}/t/${exports.TEST_THREAD_ID}/`,
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/a/1/msg/${exports.TEST_CONVERSATION_ID}/`,
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/a/1/ch/${exports.TEST_CHANNEL_ID}/t/${exports.TEST_THREAD_ID}/c/${exports.TEST_COMMENT_ID}`,
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/a/...`).
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 '/a/1/ch/7Yp.../t/7Yq.../'
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 = `/a/${workspaceId}/`;
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 `/a/${workspaceId}/ch`;
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 `/a/${workspaceId}/inbox${tabParam}`;
98
+ return `/${workspaceId}/inbox${tabParam}`;
99
99
  }
100
100
  /** Returns the URL for the messages/conversations root. */
101
101
  function getMessagesRootURL(workspaceId) {
102
- return `/a/${workspaceId}/msg`;
102
+ return `/${workspaceId}/msg`;
103
103
  }
104
104
  /** Returns the URL for a user profile. */
105
105
  function getUserProfileURL(params) {
106
- return `/a/${params.workspaceId}/people/u/${params.userId}`;
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 `/a/${workspaceId}/saved`;
110
+ return `/${workspaceId}/saved`;
111
111
  }
112
112
  /** Returns the URL for a saved thread. */
113
113
  function getSavedThreadURL(params) {
114
- return `/a/${params.workspaceId}/saved/t/${params.threadId}`;
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 `/a/${workspaceId}/search`;
118
+ return `/${workspaceId}/search`;
119
119
  }
120
120
  /** Returns the URL for a search with a query. */
121
121
  function getSearchQueryURL(params) {
122
- return `/a/${params.workspaceId}/search?q=${decodeURIComponent(params.query)}`;
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
- ? `/a/${params.workspaceId}/settings/${params.initialLocation}`
128
- : `/a/${params.workspaceId}/settings`;
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 `/a/${workspaceId}/people/u`;
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 API wraps it in `{comment: ...}`.
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.wrappedCommentSchema.parse(response.data));
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/a/1/ch/${TEST_CHANNEL_ID}/`,
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/a/1/ch/${TEST_CHANNEL_ID}/t/${TEST_THREAD_ID}/`,
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/a/1/msg/${TEST_CONVERSATION_ID}/`,
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/a/1/ch/${TEST_CHANNEL_ID}/t/${TEST_THREAD_ID}/c/${TEST_COMMENT_ID}`,
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/a/...`).
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 '/a/1/ch/7Yp.../t/7Yq.../'
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 = `/a/${workspaceId}/`;
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 `/a/${workspaceId}/ch`;
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 `/a/${workspaceId}/inbox${tabParam}`;
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 `/a/${workspaceId}/msg`;
83
+ return `/${workspaceId}/msg`;
84
84
  }
85
85
  /** Returns the URL for a user profile. */
86
86
  export function getUserProfileURL(params) {
87
- return `/a/${params.workspaceId}/people/u/${params.userId}`;
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 `/a/${workspaceId}/saved`;
91
+ return `/${workspaceId}/saved`;
92
92
  }
93
93
  /** Returns the URL for a saved thread. */
94
94
  export function getSavedThreadURL(params) {
95
- return `/a/${params.workspaceId}/saved/t/${params.threadId}`;
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 `/a/${workspaceId}/search`;
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 `/a/${params.workspaceId}/search?q=${decodeURIComponent(params.query)}`;
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
- ? `/a/${params.workspaceId}/settings/${params.initialLocation}`
109
- : `/a/${params.workspaceId}/settings`;
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 `/a/${workspaceId}/people/u`;
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 API wraps it in `{comment: ...}`.
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/a/...`).
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 '/a/1/ch/7Yp.../t/7Yq.../'
19
+ * // returns '/1/ch/7Yp.../t/7Yq.../'
20
20
  */
21
21
  export declare function getCommsURL(params: CommsURLParams): string;
22
22
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/comms-sdk",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "A TypeScript wrapper for the Comms REST API.",
5
5
  "author": "Doist developers",
6
6
  "homepage": "https://doist.github.io/comms-sdk-typescript/",