@doist/comms-sdk 0.1.0-alpha.1 → 0.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.
Files changed (62) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/clients/add-comment-helper.js +17 -0
  3. package/dist/cjs/clients/base-client.js +3 -5
  4. package/dist/cjs/clients/channels-client.js +123 -6
  5. package/dist/cjs/clients/comments-client.js +75 -9
  6. package/dist/cjs/clients/conversation-messages-client.js +76 -5
  7. package/dist/cjs/clients/conversations-client.js +143 -3
  8. package/dist/cjs/clients/groups-client.js +98 -5
  9. package/dist/cjs/clients/inbox-client.js +87 -14
  10. package/dist/cjs/clients/reactions-client.js +40 -2
  11. package/dist/cjs/clients/search-client.js +50 -0
  12. package/dist/cjs/clients/threads-client.js +211 -16
  13. package/dist/cjs/clients/users-client.js +138 -11
  14. package/dist/cjs/clients/workspace-users-client.js +110 -10
  15. package/dist/cjs/clients/workspaces-client.js +80 -7
  16. package/dist/cjs/comms-api.js +1 -0
  17. package/dist/cjs/consts/endpoints.js +8 -3
  18. package/dist/cjs/testUtils/test-defaults.js +3 -1
  19. package/dist/cjs/types/api-version.js +8 -0
  20. package/dist/cjs/types/index.js +1 -0
  21. package/dist/cjs/types/requests.js +0 -1
  22. package/dist/esm/clients/add-comment-helper.js +17 -0
  23. package/dist/esm/clients/base-client.js +3 -5
  24. package/dist/esm/clients/channels-client.js +123 -6
  25. package/dist/esm/clients/comments-client.js +75 -9
  26. package/dist/esm/clients/conversation-messages-client.js +76 -5
  27. package/dist/esm/clients/conversations-client.js +143 -3
  28. package/dist/esm/clients/groups-client.js +98 -5
  29. package/dist/esm/clients/inbox-client.js +87 -14
  30. package/dist/esm/clients/reactions-client.js +40 -2
  31. package/dist/esm/clients/search-client.js +50 -0
  32. package/dist/esm/clients/threads-client.js +211 -16
  33. package/dist/esm/clients/users-client.js +138 -11
  34. package/dist/esm/clients/workspace-users-client.js +110 -10
  35. package/dist/esm/clients/workspaces-client.js +80 -7
  36. package/dist/esm/comms-api.js +1 -0
  37. package/dist/esm/consts/endpoints.js +8 -3
  38. package/dist/esm/testUtils/test-defaults.js +2 -0
  39. package/dist/esm/types/api-version.js +5 -0
  40. package/dist/esm/types/index.js +1 -0
  41. package/dist/esm/types/requests.js +0 -1
  42. package/dist/types/clients/add-comment-helper.d.ts +17 -0
  43. package/dist/types/clients/base-client.d.ts +4 -0
  44. package/dist/types/clients/channels-client.d.ts +123 -6
  45. package/dist/types/clients/comments-client.d.ts +73 -6
  46. package/dist/types/clients/conversation-messages-client.d.ts +76 -5
  47. package/dist/types/clients/conversations-client.d.ts +143 -3
  48. package/dist/types/clients/groups-client.d.ts +98 -5
  49. package/dist/types/clients/inbox-client.d.ts +81 -5
  50. package/dist/types/clients/reactions-client.d.ts +40 -2
  51. package/dist/types/clients/search-client.d.ts +50 -0
  52. package/dist/types/clients/threads-client.d.ts +200 -8
  53. package/dist/types/clients/users-client.d.ts +138 -11
  54. package/dist/types/clients/workspace-users-client.d.ts +110 -10
  55. package/dist/types/clients/workspaces-client.d.ts +80 -7
  56. package/dist/types/comms-api.d.ts +3 -0
  57. package/dist/types/consts/endpoints.d.ts +6 -1
  58. package/dist/types/testUtils/test-defaults.d.ts +1 -0
  59. package/dist/types/types/api-version.d.ts +6 -0
  60. package/dist/types/types/index.d.ts +1 -0
  61. package/dist/types/types/requests.d.ts +2 -21
  62. package/package.json +1 -1
@@ -7,38 +7,138 @@ import { BaseClient } from './base-client.js';
7
7
  * rejects non-empty `name` and `channelIds` — set neither.
8
8
  */
9
9
  export declare class WorkspaceUsersClient extends BaseClient {
10
- /** Returns workspace user objects for the given workspace id. */
10
+ /**
11
+ * Returns a list of workspace user objects for the given workspace id.
12
+ *
13
+ * @param args - The arguments for getting workspace users.
14
+ * @param args.workspaceId - The workspace ID.
15
+ * @param args.archived - Optional flag to filter archived users.
16
+ * @returns An array of workspace user objects.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const users = await api.workspaceUsers.getWorkspaceUsers({ workspaceId: 123 })
21
+ * users.forEach(u => console.log(u.fullName, u.userType))
22
+ * ```
23
+ */
11
24
  getWorkspaceUsers(args: GetWorkspaceUsersArgs): Promise<WorkspaceUser[]>;
12
- /** Returns workspace user IDs for the given workspace id. */
25
+ /**
26
+ * Returns a list of workspace user IDs for the given workspace id.
27
+ *
28
+ * @param workspaceId - The workspace ID.
29
+ * @returns An array of user IDs.
30
+ */
13
31
  getWorkspaceUserIds(workspaceId: number): Promise<number[]>;
14
- /** Gets a user by id. */
32
+ /**
33
+ * Gets a user by id.
34
+ *
35
+ * @param args - The arguments for getting a user by ID.
36
+ * @param args.workspaceId - The workspace ID.
37
+ * @param args.userId - The user's ID.
38
+ * @returns The workspace user object.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const user = await api.workspaceUsers.getUserById({ workspaceId: 123, userId: 456 })
43
+ * console.log(user.fullName, user.email)
44
+ * ```
45
+ */
15
46
  getUserById(args: GetUserByIdArgs): Promise<WorkspaceUser>;
16
- /** Gets a user by email. */
47
+ /**
48
+ * Gets a user by email.
49
+ *
50
+ * @param args - The arguments for getting a user by email.
51
+ * @param args.workspaceId - The workspace ID.
52
+ * @param args.email - The user's email.
53
+ * @returns The workspace user object.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const user = await api.workspaceUsers.getUserByEmail({
58
+ * workspaceId: 123,
59
+ * email: 'user@example.com',
60
+ * })
61
+ * ```
62
+ */
17
63
  getUserByEmail(args: GetUserByEmailArgs): Promise<WorkspaceUser>;
18
- /** Gets the user's info in the context of the workspace. */
64
+ /**
65
+ * Gets the user's info in the context of the workspace.
66
+ *
67
+ * @param args - The arguments for getting user info.
68
+ * @param args.workspaceId - The workspace ID.
69
+ * @param args.userId - The user's ID.
70
+ * @returns Information about the user in the workspace context.
71
+ */
19
72
  getUserInfo(args: GetUserInfoArgs): Promise<Record<string, unknown>>;
20
- /** Gets the user's local time (e.g., "2017-05-10 07:55:40"). */
73
+ /**
74
+ * Gets the user's local time (e.g., "2017-05-10 07:55:40").
75
+ *
76
+ * @param args - The arguments for getting user local time.
77
+ * @param args.workspaceId - The workspace ID.
78
+ * @param args.userId - The user's ID.
79
+ * @returns The user's local time as a string.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const localTime = await api.workspaceUsers.getUserLocalTime({
84
+ * workspaceId: 123,
85
+ * userId: 456,
86
+ * })
87
+ * console.log('User local time:', localTime)
88
+ * ```
89
+ */
21
90
  getUserLocalTime(args: GetUserLocalTimeArgs): Promise<string>;
22
- /** Adds a person to a workspace. */
91
+ /**
92
+ * Adds a person to a workspace.
93
+ *
94
+ * @param args - The arguments for adding a user.
95
+ * @param args.workspaceId - The workspace ID.
96
+ * @param args.email - The user's email.
97
+ * @param args.userType - Optional user type (USER, GUEST, or ADMIN).
98
+ * @returns The created workspace user object.
99
+ */
23
100
  addUser(args: {
24
101
  workspaceId: number;
25
102
  email: string;
26
103
  userType?: UserType;
27
104
  }): Promise<WorkspaceUser>;
28
- /** Updates a person in a workspace. */
105
+ /**
106
+ * Updates a person in a workspace.
107
+ *
108
+ * @param args - The arguments for updating a user.
109
+ * @param args.workspaceId - The workspace ID.
110
+ * @param args.userType - The user type (USER, GUEST, or ADMIN).
111
+ * @param args.email - Optional email of the user to update.
112
+ * @param args.userId - Optional user ID to update (use either email or userId).
113
+ * @returns The updated workspace user object.
114
+ */
29
115
  updateUser(args: {
30
116
  workspaceId: number;
31
117
  userType: UserType;
32
118
  email?: string;
33
119
  userId?: number;
34
120
  }): Promise<WorkspaceUser>;
35
- /** Removes a person from a workspace. */
121
+ /**
122
+ * Removes a person from a workspace.
123
+ *
124
+ * @param args - The arguments for removing a user.
125
+ * @param args.workspaceId - The workspace ID.
126
+ * @param args.email - Optional email of the user to remove.
127
+ * @param args.userId - Optional user ID to remove (use either email or userId).
128
+ */
36
129
  removeUser(args: {
37
130
  workspaceId: number;
38
131
  email?: string;
39
132
  userId?: number;
40
133
  }): Promise<void>;
41
- /** Sends a new workspace invitation to the selected user. */
134
+ /**
135
+ * Sends a new workspace invitation to the selected user.
136
+ *
137
+ * @param args - The arguments for resending an invite.
138
+ * @param args.workspaceId - The workspace ID.
139
+ * @param args.email - The user's email.
140
+ * @param args.userId - Optional user ID.
141
+ */
42
142
  resendInvite(args: {
43
143
  workspaceId: number;
44
144
  email: string;
@@ -62,18 +62,91 @@ export declare const ChannelListSchema: z.ZodArray<z.ZodPipe<z.ZodObject<{
62
62
  * currently rejects any `color` other than `1` on add/update.
63
63
  */
64
64
  export declare class WorkspacesClient extends BaseClient {
65
- /** Gets all the user's workspaces. */
65
+ /**
66
+ * Gets all the user's workspaces.
67
+ *
68
+ * @returns An array of all workspaces the user belongs to.
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const workspaces = await api.workspaces.getWorkspaces()
73
+ * workspaces.forEach(ws => console.log(ws.name))
74
+ * ```
75
+ */
66
76
  getWorkspaces(): Promise<Workspace[]>;
67
- /** Gets a single workspace object by id. */
77
+ /**
78
+ * Gets a single workspace object by id.
79
+ *
80
+ * @param id - The workspace ID.
81
+ * @returns The workspace object.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const workspace = await api.workspaces.getWorkspace(123)
86
+ * console.log(workspace.name)
87
+ * ```
88
+ */
68
89
  getWorkspace(id: number): Promise<Workspace>;
69
- /** Gets the user's default workspace. */
90
+ /**
91
+ * Gets the user's default workspace.
92
+ *
93
+ * @returns The default workspace object.
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const workspace = await api.workspaces.getDefaultWorkspace()
98
+ * console.log(workspace.name)
99
+ * ```
100
+ */
70
101
  getDefaultWorkspace(): Promise<Workspace>;
71
- /** Creates a new workspace. */
102
+ /**
103
+ * Creates a new workspace.
104
+ *
105
+ * @param name - The name of the new workspace.
106
+ * @returns The created workspace object.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const workspace = await api.workspaces.createWorkspace('My Team')
111
+ * console.log('Created:', workspace.name)
112
+ * ```
113
+ */
72
114
  createWorkspace(name: string): Promise<Workspace>;
73
- /** Updates an existing workspace. */
115
+ /**
116
+ * Updates an existing workspace.
117
+ *
118
+ * @param id - The workspace ID.
119
+ * @param name - The new name for the workspace.
120
+ * @returns The updated workspace object.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const workspace = await api.workspaces.updateWorkspace(123, 'New Team Name')
125
+ * ```
126
+ */
74
127
  updateWorkspace(id: number, name: string): Promise<Workspace>;
75
- /** Removes a workspace and all its data (not recoverable). */
128
+ /**
129
+ * Removes a workspace and all its data (not recoverable).
130
+ *
131
+ * @param id - The workspace ID.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * await api.workspaces.removeWorkspace(123)
136
+ * ```
137
+ */
76
138
  removeWorkspace(id: number): Promise<void>;
77
- /** Gets the public channels of a workspace. */
139
+ /**
140
+ * Gets the public channels of a workspace.
141
+ *
142
+ * @param id - The workspace ID.
143
+ * @returns An array of public channel objects.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const channels = await api.workspaces.getPublicChannels(123)
148
+ * channels.forEach(ch => console.log(ch.name))
149
+ * ```
150
+ */
78
151
  getPublicChannels(id: number): Promise<Channel[]>;
79
152
  }
@@ -10,10 +10,13 @@ import { ThreadsClient } from './clients/threads-client.js';
10
10
  import { UsersClient } from './clients/users-client.js';
11
11
  import { WorkspaceUsersClient } from './clients/workspace-users-client.js';
12
12
  import { WorkspacesClient } from './clients/workspaces-client.js';
13
+ import type { ApiVersion } from './types/api-version.js';
13
14
  import type { CustomFetch } from './types/http.js';
14
15
  export type CommsApiOptions = {
15
16
  /** Optional custom API base URL. If not provided, defaults to Comms' standard API endpoint. */
16
17
  baseUrl?: string;
18
+ /** Optional API version. Defaults to 'v1'. */
19
+ version?: ApiVersion;
17
20
  /** Optional custom fetch implementation for cross-platform compatibility (e.g., Obsidian, React Native, Electron). */
18
21
  customFetch?: CustomFetch;
19
22
  };
@@ -1,10 +1,15 @@
1
+ import type { ApiVersion } from '../types/api-version.js';
1
2
  /**
2
3
  * Gets the base URI for Comms API requests.
3
4
  *
5
+ * Preserves any path component on `domainBase` so callers can route through
6
+ * a proxy (e.g. `https://proxy.example.com/comms` → `.../comms/api/v1/`).
7
+ *
8
+ * @param version - API version. Defaults to 'v1'.
4
9
  * @param domainBase - Custom domain base URL. Defaults to Comms' API domain.
5
10
  * @returns Complete base URI with trailing slash (e.g., 'https://comms.todoist.com/api/v1/')
6
11
  */
7
- export declare function getCommsBaseUri(domainBase?: string): string;
12
+ export declare function getCommsBaseUri(version?: ApiVersion, domainBase?: string): string;
8
13
  export declare const ENDPOINT_USERS = "users";
9
14
  export declare const ENDPOINT_WORKSPACES = "workspaces";
10
15
  export declare const ENDPOINT_CHANNELS = "channels";
@@ -1,5 +1,6 @@
1
1
  import type { Channel, Comment, Conversation, Group, Thread, User, Workspace, WorkspaceUser } from '../types/entities.js';
2
2
  export declare const TEST_API_TOKEN = "test-api-token";
3
+ export declare const TEST_API_BASE_URL: string;
3
4
  export declare const TEST_CHANNEL_ID = "7YpL3oZ4kZ9vP7Q1tR2sX3y";
4
5
  export declare const TEST_THREAD_ID = "7YpL3oZ4kZ9vP7Q1tR2sX3z";
5
6
  export declare const TEST_COMMENT_ID = "7YpL3oZ4kZ9vP7Q1tR2sX41";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Supported Comms API versions
3
+ */
4
+ export declare const API_VERSIONS: readonly ["v1"];
5
+ export type ApiVersion = (typeof API_VERSIONS)[number];
6
+ export declare const DEFAULT_API_VERSION: ApiVersion;
@@ -1,3 +1,4 @@
1
+ export * from './api-version.js';
1
2
  export * from './entities.js';
2
3
  export * from './enums.js';
3
4
  export * from './errors.js';
@@ -131,25 +131,14 @@ export declare const GetThreadsArgsSchema: z.ZodObject<{
131
131
  olderThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
132
132
  limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
133
133
  }, z.core.$strip>;
134
- export type GetThreadsArgs = Omit<z.infer<typeof GetThreadsArgsSchema>, 'newerThan' | 'olderThan'> & {
135
- newerThan?: Date | null;
136
- olderThan?: Date | null;
137
- /** @deprecated Use `newerThan` instead. */
138
- newer_than_ts?: number | null;
139
- /** @deprecated Use `olderThan` instead. */
140
- older_than_ts?: number | null;
141
- };
134
+ export type GetThreadsArgs = z.infer<typeof GetThreadsArgsSchema>;
142
135
  export declare const GetCommentsArgsSchema: z.ZodObject<{
143
136
  threadId: z.ZodString;
144
- from: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
145
137
  newerThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
146
138
  olderThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
147
139
  limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
148
140
  }, z.core.$strip>;
149
- export type GetCommentsArgs = Omit<z.infer<typeof GetCommentsArgsSchema>, 'from'> & {
150
- /** @deprecated Use `newerThan` instead. */
151
- from?: Date | null;
152
- };
141
+ export type GetCommentsArgs = z.infer<typeof GetCommentsArgsSchema>;
153
142
  export declare const GetConversationsArgsSchema: z.ZodObject<{
154
143
  workspaceId: z.ZodNumber;
155
144
  archived: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
@@ -231,10 +220,6 @@ export type GetInboxArgs = {
231
220
  workspaceId: number;
232
221
  newerThan?: Date;
233
222
  olderThan?: Date;
234
- /** @deprecated Use `newerThan` instead. */
235
- since?: Date;
236
- /** @deprecated Use `olderThan` instead. */
237
- until?: Date;
238
223
  limit?: number;
239
224
  cursor?: string;
240
225
  archiveFilter?: ArchiveFilter;
@@ -243,10 +228,6 @@ export type ArchiveAllArgs = {
243
228
  workspaceId: number;
244
229
  channelIds?: string[];
245
230
  olderThan?: Date;
246
- /** @deprecated Use `olderThan` instead. */
247
- until?: Date;
248
- /** @deprecated Not supported by the archive_all endpoint — this value is ignored. */
249
- since?: Date;
250
231
  };
251
232
  export type AddReactionArgs = {
252
233
  threadId?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/comms-sdk",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.2.0",
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/",