@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.
- package/README.md +1 -1
- package/dist/cjs/clients/add-comment-helper.js +18 -2
- package/dist/cjs/clients/base-client.js +11 -5
- package/dist/cjs/clients/channels-client.js +142 -14
- package/dist/cjs/clients/comments-client.js +99 -14
- package/dist/cjs/clients/conversation-messages-client.js +91 -9
- package/dist/cjs/clients/conversations-client.js +166 -15
- package/dist/cjs/clients/groups-client.js +98 -5
- package/dist/cjs/clients/inbox-client.js +102 -16
- package/dist/cjs/clients/reactions-client.js +40 -2
- package/dist/cjs/clients/search-client.js +50 -0
- package/dist/cjs/clients/threads-client.js +238 -24
- package/dist/cjs/clients/users-client.js +138 -11
- package/dist/cjs/clients/workspace-users-client.js +110 -10
- package/dist/cjs/clients/workspaces-client.js +89 -8
- package/dist/cjs/comms-api.js +1 -0
- package/dist/cjs/consts/endpoints.js +8 -3
- package/dist/cjs/testUtils/test-defaults.js +3 -1
- package/dist/cjs/types/api-version.js +8 -0
- package/dist/cjs/types/entities.js +119 -98
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/requests.js +0 -1
- package/dist/cjs/utils/url-helpers.js +3 -1
- package/dist/esm/clients/add-comment-helper.js +18 -2
- package/dist/esm/clients/base-client.js +11 -5
- package/dist/esm/clients/channels-client.js +143 -15
- package/dist/esm/clients/comments-client.js +100 -15
- package/dist/esm/clients/conversation-messages-client.js +92 -10
- package/dist/esm/clients/conversations-client.js +167 -16
- package/dist/esm/clients/groups-client.js +98 -5
- package/dist/esm/clients/inbox-client.js +102 -16
- package/dist/esm/clients/reactions-client.js +40 -2
- package/dist/esm/clients/search-client.js +50 -0
- package/dist/esm/clients/threads-client.js +239 -25
- package/dist/esm/clients/users-client.js +138 -11
- package/dist/esm/clients/workspace-users-client.js +110 -10
- package/dist/esm/clients/workspaces-client.js +90 -9
- package/dist/esm/comms-api.js +1 -0
- package/dist/esm/consts/endpoints.js +8 -3
- package/dist/esm/testUtils/test-defaults.js +2 -0
- package/dist/esm/types/api-version.js +5 -0
- package/dist/esm/types/entities.js +111 -97
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/requests.js +0 -1
- package/dist/esm/utils/url-helpers.js +3 -1
- package/dist/types/clients/add-comment-helper.d.ts +20 -1
- package/dist/types/clients/base-client.d.ts +10 -0
- package/dist/types/clients/channels-client.d.ts +126 -6
- package/dist/types/clients/comments-client.d.ts +77 -6
- package/dist/types/clients/conversation-messages-client.d.ts +79 -5
- package/dist/types/clients/conversations-client.d.ts +146 -3
- package/dist/types/clients/groups-client.d.ts +98 -5
- package/dist/types/clients/inbox-client.d.ts +463 -5
- package/dist/types/clients/reactions-client.d.ts +40 -2
- package/dist/types/clients/search-client.d.ts +50 -0
- package/dist/types/clients/threads-client.d.ts +204 -8
- package/dist/types/clients/users-client.d.ts +138 -11
- package/dist/types/clients/workspace-users-client.d.ts +110 -10
- package/dist/types/clients/workspaces-client.d.ts +82 -7
- package/dist/types/comms-api.d.ts +3 -0
- package/dist/types/consts/endpoints.d.ts +6 -1
- package/dist/types/testUtils/test-defaults.d.ts +1 -0
- package/dist/types/types/api-version.d.ts +6 -0
- package/dist/types/types/entities.d.ts +1654 -126
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/requests.d.ts +2 -21
- 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
|
-
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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";
|