@doist/comms-sdk 0.1.0-alpha.1 → 0.2.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.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/clients/add-comment-helper.js +18 -2
  3. package/dist/cjs/clients/base-client.js +11 -5
  4. package/dist/cjs/clients/channels-client.js +142 -14
  5. package/dist/cjs/clients/comments-client.js +99 -14
  6. package/dist/cjs/clients/conversation-messages-client.js +91 -9
  7. package/dist/cjs/clients/conversations-client.js +166 -15
  8. package/dist/cjs/clients/groups-client.js +98 -5
  9. package/dist/cjs/clients/inbox-client.js +102 -16
  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 +238 -24
  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 +89 -8
  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/entities.js +119 -98
  21. package/dist/cjs/types/index.js +1 -0
  22. package/dist/cjs/types/requests.js +0 -1
  23. package/dist/cjs/utils/url-helpers.js +3 -1
  24. package/dist/esm/clients/add-comment-helper.js +18 -2
  25. package/dist/esm/clients/base-client.js +11 -5
  26. package/dist/esm/clients/channels-client.js +143 -15
  27. package/dist/esm/clients/comments-client.js +100 -15
  28. package/dist/esm/clients/conversation-messages-client.js +92 -10
  29. package/dist/esm/clients/conversations-client.js +167 -16
  30. package/dist/esm/clients/groups-client.js +98 -5
  31. package/dist/esm/clients/inbox-client.js +102 -16
  32. package/dist/esm/clients/reactions-client.js +40 -2
  33. package/dist/esm/clients/search-client.js +50 -0
  34. package/dist/esm/clients/threads-client.js +239 -25
  35. package/dist/esm/clients/users-client.js +138 -11
  36. package/dist/esm/clients/workspace-users-client.js +110 -10
  37. package/dist/esm/clients/workspaces-client.js +90 -9
  38. package/dist/esm/comms-api.js +1 -0
  39. package/dist/esm/consts/endpoints.js +8 -3
  40. package/dist/esm/testUtils/test-defaults.js +2 -0
  41. package/dist/esm/types/api-version.js +5 -0
  42. package/dist/esm/types/entities.js +111 -97
  43. package/dist/esm/types/index.js +1 -0
  44. package/dist/esm/types/requests.js +0 -1
  45. package/dist/esm/utils/url-helpers.js +3 -1
  46. package/dist/types/clients/add-comment-helper.d.ts +20 -1
  47. package/dist/types/clients/base-client.d.ts +10 -0
  48. package/dist/types/clients/channels-client.d.ts +126 -6
  49. package/dist/types/clients/comments-client.d.ts +77 -6
  50. package/dist/types/clients/conversation-messages-client.d.ts +79 -5
  51. package/dist/types/clients/conversations-client.d.ts +146 -3
  52. package/dist/types/clients/groups-client.d.ts +98 -5
  53. package/dist/types/clients/inbox-client.d.ts +463 -5
  54. package/dist/types/clients/reactions-client.d.ts +40 -2
  55. package/dist/types/clients/search-client.d.ts +50 -0
  56. package/dist/types/clients/threads-client.d.ts +204 -8
  57. package/dist/types/clients/users-client.d.ts +138 -11
  58. package/dist/types/clients/workspace-users-client.d.ts +110 -10
  59. package/dist/types/clients/workspaces-client.d.ts +82 -7
  60. package/dist/types/comms-api.d.ts +3 -0
  61. package/dist/types/consts/endpoints.d.ts +6 -1
  62. package/dist/types/testUtils/test-defaults.d.ts +1 -0
  63. package/dist/types/types/api-version.d.ts +6 -0
  64. package/dist/types/types/entities.d.ts +1654 -126
  65. package/dist/types/types/index.d.ts +1 -0
  66. package/dist/types/types/requests.d.ts +2 -21
  67. package/package.json +1 -1
@@ -62,18 +62,93 @@ 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
+ private readonly linkBaseUrl;
66
+ private readonly channelListSchema;
67
+ /**
68
+ * Gets all the user's workspaces.
69
+ *
70
+ * @returns An array of all workspaces the user belongs to.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const workspaces = await api.workspaces.getWorkspaces()
75
+ * workspaces.forEach(ws => console.log(ws.name))
76
+ * ```
77
+ */
66
78
  getWorkspaces(): Promise<Workspace[]>;
67
- /** Gets a single workspace object by id. */
79
+ /**
80
+ * Gets a single workspace object by id.
81
+ *
82
+ * @param id - The workspace ID.
83
+ * @returns The workspace object.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const workspace = await api.workspaces.getWorkspace(123)
88
+ * console.log(workspace.name)
89
+ * ```
90
+ */
68
91
  getWorkspace(id: number): Promise<Workspace>;
69
- /** Gets the user's default workspace. */
92
+ /**
93
+ * Gets the user's default workspace.
94
+ *
95
+ * @returns The default workspace object.
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const workspace = await api.workspaces.getDefaultWorkspace()
100
+ * console.log(workspace.name)
101
+ * ```
102
+ */
70
103
  getDefaultWorkspace(): Promise<Workspace>;
71
- /** Creates a new workspace. */
104
+ /**
105
+ * Creates a new workspace.
106
+ *
107
+ * @param name - The name of the new workspace.
108
+ * @returns The created workspace object.
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const workspace = await api.workspaces.createWorkspace('My Team')
113
+ * console.log('Created:', workspace.name)
114
+ * ```
115
+ */
72
116
  createWorkspace(name: string): Promise<Workspace>;
73
- /** Updates an existing workspace. */
117
+ /**
118
+ * Updates an existing workspace.
119
+ *
120
+ * @param id - The workspace ID.
121
+ * @param name - The new name for the workspace.
122
+ * @returns The updated workspace object.
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * const workspace = await api.workspaces.updateWorkspace(123, 'New Team Name')
127
+ * ```
128
+ */
74
129
  updateWorkspace(id: number, name: string): Promise<Workspace>;
75
- /** Removes a workspace and all its data (not recoverable). */
130
+ /**
131
+ * Removes a workspace and all its data (not recoverable).
132
+ *
133
+ * @param id - The workspace ID.
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * await api.workspaces.removeWorkspace(123)
138
+ * ```
139
+ */
76
140
  removeWorkspace(id: number): Promise<void>;
77
- /** Gets the public channels of a workspace. */
141
+ /**
142
+ * Gets the public channels of a workspace.
143
+ *
144
+ * @param id - The workspace ID.
145
+ * @returns An array of public channel objects.
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const channels = await api.workspaces.getPublicChannels(123)
150
+ * channels.forEach(ch => console.log(ch.name))
151
+ * ```
152
+ */
78
153
  getPublicChannels(id: number): Promise<Channel[]>;
79
154
  }
@@ -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;