@doist/comms-sdk 0.0.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.
- package/LICENSE +21 -0
- package/README.md +143 -45
- package/dist/cjs/authentication.js +211 -0
- package/dist/cjs/clients/add-comment-helper.js +70 -0
- package/dist/cjs/clients/base-client.js +25 -0
- package/dist/cjs/clients/channels-client.js +200 -0
- package/dist/cjs/clients/comments-client.js +159 -0
- package/dist/cjs/clients/conversation-messages-client.js +158 -0
- package/dist/cjs/clients/conversations-client.js +243 -0
- package/dist/cjs/clients/groups-client.js +164 -0
- package/dist/cjs/clients/inbox-client.js +171 -0
- package/dist/cjs/clients/reactions-client.js +97 -0
- package/dist/cjs/clients/search-client.js +138 -0
- package/dist/cjs/clients/threads-client.js +330 -0
- package/dist/cjs/clients/users-client.js +326 -0
- package/dist/cjs/clients/workspace-users-client.js +240 -0
- package/dist/cjs/clients/workspaces-client.js +166 -0
- package/dist/cjs/comms-api.js +66 -0
- package/dist/cjs/consts/endpoints.js +32 -0
- package/dist/cjs/index.js +48 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/testUtils/msw-handlers.js +51 -0
- package/dist/cjs/testUtils/msw-setup.js +21 -0
- package/dist/cjs/testUtils/obsidian-fetch-adapter.js +53 -0
- package/dist/cjs/testUtils/test-defaults.js +104 -0
- package/dist/cjs/transport/fetch-with-retry.js +136 -0
- package/dist/cjs/transport/http-client.js +56 -0
- package/dist/cjs/transport/http-dispatcher.js +143 -0
- package/dist/cjs/types/api-version.js +8 -0
- package/dist/cjs/types/entities.js +411 -0
- package/dist/cjs/types/enums.js +37 -0
- package/dist/cjs/types/errors.js +12 -0
- package/dist/cjs/types/http.js +4 -0
- package/dist/cjs/types/index.js +22 -0
- package/dist/cjs/types/requests.js +116 -0
- package/dist/cjs/utils/case-conversion.js +54 -0
- package/dist/cjs/utils/index.js +19 -0
- package/dist/cjs/utils/timestamp-conversion.js +49 -0
- package/dist/cjs/utils/url-helpers.js +131 -0
- package/dist/cjs/utils/uuidv7.js +174 -0
- package/dist/esm/authentication.js +203 -0
- package/dist/esm/clients/add-comment-helper.js +67 -0
- package/dist/esm/clients/base-client.js +21 -0
- package/dist/esm/clients/channels-client.js +196 -0
- package/dist/esm/clients/comments-client.js +155 -0
- package/dist/esm/clients/conversation-messages-client.js +154 -0
- package/dist/esm/clients/conversations-client.js +239 -0
- package/dist/esm/clients/groups-client.js +160 -0
- package/dist/esm/clients/inbox-client.js +167 -0
- package/dist/esm/clients/reactions-client.js +93 -0
- package/dist/esm/clients/search-client.js +134 -0
- package/dist/esm/clients/threads-client.js +326 -0
- package/dist/esm/clients/users-client.js +322 -0
- package/dist/esm/clients/workspace-users-client.js +236 -0
- package/dist/esm/clients/workspaces-client.js +162 -0
- package/dist/esm/comms-api.js +62 -0
- package/dist/esm/consts/endpoints.js +28 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/testUtils/msw-handlers.js +45 -0
- package/dist/esm/testUtils/msw-setup.js +18 -0
- package/dist/esm/testUtils/obsidian-fetch-adapter.js +50 -0
- package/dist/esm/testUtils/test-defaults.js +101 -0
- package/dist/esm/transport/fetch-with-retry.js +133 -0
- package/dist/esm/transport/http-client.js +51 -0
- package/dist/esm/transport/http-dispatcher.js +104 -0
- package/dist/esm/types/api-version.js +5 -0
- package/dist/esm/types/entities.js +408 -0
- package/dist/esm/types/enums.js +34 -0
- package/dist/esm/types/errors.js +8 -0
- package/dist/esm/types/http.js +1 -0
- package/dist/esm/types/index.js +6 -0
- package/dist/esm/types/requests.js +113 -0
- package/dist/esm/utils/case-conversion.js +47 -0
- package/dist/esm/utils/index.js +3 -0
- package/dist/esm/utils/timestamp-conversion.js +45 -0
- package/dist/esm/utils/url-helpers.js +112 -0
- package/dist/esm/utils/uuidv7.js +163 -0
- package/dist/types/authentication.d.ts +160 -0
- package/dist/types/clients/add-comment-helper.d.ts +29 -0
- package/dist/types/clients/base-client.d.ts +28 -0
- package/dist/types/clients/channels-client.d.ts +208 -0
- package/dist/types/clients/comments-client.d.ts +224 -0
- package/dist/types/clients/conversation-messages-client.d.ts +198 -0
- package/dist/types/clients/conversations-client.d.ts +346 -0
- package/dist/types/clients/groups-client.d.ts +148 -0
- package/dist/types/clients/inbox-client.d.ts +96 -0
- package/dist/types/clients/reactions-client.d.ts +57 -0
- package/dist/types/clients/search-client.d.ts +70 -0
- package/dist/types/clients/threads-client.d.ts +536 -0
- package/dist/types/clients/users-client.d.ts +250 -0
- package/dist/types/clients/workspace-users-client.d.ts +147 -0
- package/dist/types/clients/workspaces-client.d.ts +152 -0
- package/dist/types/comms-api.d.ts +62 -0
- package/dist/types/consts/endpoints.d.ts +24 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/testUtils/msw-handlers.d.ts +28 -0
- package/dist/types/testUtils/msw-setup.d.ts +1 -0
- package/dist/types/testUtils/obsidian-fetch-adapter.d.ts +29 -0
- package/dist/types/testUtils/test-defaults.d.ts +17 -0
- package/dist/types/transport/fetch-with-retry.d.ts +4 -0
- package/dist/types/transport/http-client.d.ts +13 -0
- package/dist/types/transport/http-dispatcher.d.ts +10 -0
- package/dist/types/types/api-version.d.ts +6 -0
- package/dist/types/types/entities.d.ts +1288 -0
- package/dist/types/types/enums.d.ts +55 -0
- package/dist/types/types/errors.d.ts +6 -0
- package/dist/types/types/http.d.ts +54 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/requests.d.ts +366 -0
- package/dist/types/utils/case-conversion.d.ts +8 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/timestamp-conversion.d.ts +13 -0
- package/dist/types/utils/url-helpers.d.ts +88 -0
- package/dist/types/utils/uuidv7.d.ts +40 -0
- package/package.json +91 -8
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marker constants for the two "broadcast" group recipients. These appear
|
|
3
|
+
* in group-bearing fields (`Thread.groups`, `Comment.groups`,
|
|
4
|
+
* `Channel.defaultGroups`, `directGroupMentions`, etc.) in place of a
|
|
5
|
+
* real group ID and tell the backend to notify "everyone in the channel"
|
|
6
|
+
* or "everyone in the thread" respectively. Input and output are
|
|
7
|
+
* symmetric. Defined here (and not in `./entities`) so that `enums`
|
|
8
|
+
* stays leaf-level — `entities` imports from `enums`, never the reverse.
|
|
9
|
+
*/
|
|
10
|
+
export declare const EVERYONE: "EVERYONE";
|
|
11
|
+
export declare const EVERYONE_IN_THREAD: "EVERYONE_IN_THREAD";
|
|
12
|
+
/** Union of the two broadcast group markers. */
|
|
13
|
+
export declare const GROUP_ID_MARKERS: readonly ["EVERYONE", "EVERYONE_IN_THREAD"];
|
|
14
|
+
export type GroupIdMarker = (typeof GROUP_ID_MARKERS)[number];
|
|
15
|
+
/**
|
|
16
|
+
* A group identifier on the wire — either an opaque group ID or one of
|
|
17
|
+
* the {@link GROUP_ID_MARKERS} for a broadcast audience.
|
|
18
|
+
*/
|
|
19
|
+
export type GroupId = string;
|
|
20
|
+
export declare const USER_TYPES: readonly ["USER", "GUEST", "ADMIN"];
|
|
21
|
+
/**
|
|
22
|
+
* The type of user in a workspace.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Possible values:
|
|
26
|
+
* - `'USER'` - Regular user
|
|
27
|
+
* - `'GUEST'` - Guest user
|
|
28
|
+
* - `'ADMIN'` - Administrator
|
|
29
|
+
*/
|
|
30
|
+
export type UserType = (typeof USER_TYPES)[number];
|
|
31
|
+
export declare const WORKSPACE_PLANS: readonly ["free", "unlimited", "business"];
|
|
32
|
+
/**
|
|
33
|
+
* The plan type for a workspace. Any string accepted; the listed values
|
|
34
|
+
* are the ones the backend exposes today.
|
|
35
|
+
*/
|
|
36
|
+
export type WorkspacePlan = (typeof WORKSPACE_PLANS)[number] | (string & {});
|
|
37
|
+
export declare const NOTIFY_AUDIENCES: readonly ["channel", "thread"];
|
|
38
|
+
/**
|
|
39
|
+
* The audience to notify when posting a comment, in addition to any
|
|
40
|
+
* individual `recipients` or custom `groups`.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Possible values:
|
|
44
|
+
* - `'channel'` - Notify everyone in the channel.
|
|
45
|
+
* - `'thread'` - Notify everyone who has interacted with the thread.
|
|
46
|
+
*/
|
|
47
|
+
export type NotifyAudience = (typeof NOTIFY_AUDIENCES)[number];
|
|
48
|
+
/**
|
|
49
|
+
* Internal mapping from {@link NotifyAudience} to the broadcast marker IDs
|
|
50
|
+
* (`EVERYONE` / `EVERYONE_IN_THREAD`) that comment- and thread-creation
|
|
51
|
+
* endpoints use on the wire. SDK consumers should use {@link NotifyAudience}
|
|
52
|
+
* via `notifyAudience` on the request args rather than passing these IDs
|
|
53
|
+
* directly.
|
|
54
|
+
*/
|
|
55
|
+
export declare const NOTIFY_AUDIENCE_GROUP_IDS: Readonly<Record<NotifyAudience, GroupId>>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const HTTP_METHODS: readonly ["POST", "GET", "PUT", "PATCH", "DELETE"];
|
|
2
|
+
export type HttpMethod = (typeof HTTP_METHODS)[number];
|
|
3
|
+
export type HttpResponse<T = unknown> = {
|
|
4
|
+
data: T;
|
|
5
|
+
status: number;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
export type RequestConfig = {
|
|
9
|
+
baseURL?: string;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Custom fetch response interface for cross-platform HTTP clients.
|
|
15
|
+
* This minimal interface allows custom HTTP implementations (e.g., Obsidian's requestUrl,
|
|
16
|
+
* Electron's net module, React Native's networking) to work with the SDK.
|
|
17
|
+
*/
|
|
18
|
+
export type CustomFetchResponse = {
|
|
19
|
+
ok: boolean;
|
|
20
|
+
status: number;
|
|
21
|
+
statusText: string;
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
text(): Promise<string>;
|
|
24
|
+
json(): Promise<unknown>;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Custom fetch function type for providing alternative HTTP implementations.
|
|
28
|
+
* This enables the SDK to work in restrictive environments like Obsidian plugins,
|
|
29
|
+
* browser extensions, Electron apps, React Native, and enterprise environments
|
|
30
|
+
* with specific networking requirements.
|
|
31
|
+
*
|
|
32
|
+
* @param url - The URL to fetch
|
|
33
|
+
* @param options - Standard RequestInit options plus optional timeout
|
|
34
|
+
* @returns A promise that resolves to a CustomFetchResponse
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Obsidian plugin example
|
|
39
|
+
* const obsidianFetch: CustomFetch = async (url, options) => {
|
|
40
|
+
* const response = await requestUrl({ url, method: options?.method, body: options?.body })
|
|
41
|
+
* return {
|
|
42
|
+
* ok: response.status >= 200 && response.status < 300,
|
|
43
|
+
* status: response.status,
|
|
44
|
+
* statusText: '',
|
|
45
|
+
* headers: response.headers,
|
|
46
|
+
* text: async () => response.text,
|
|
47
|
+
* json: async () => response.json,
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export type CustomFetch = (url: string, options?: RequestInit & {
|
|
53
|
+
timeout?: number;
|
|
54
|
+
}) => Promise<CustomFetchResponse>;
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Attachment } from './entities.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create-side requests require an `id` on the wire. The SDK clients accept
|
|
5
|
+
* `id` as optional and auto-generate one via
|
|
6
|
+
* {@link import('../utils/uuidv7.js').generateId} when the caller doesn't pass
|
|
7
|
+
* one — callers can still mint their own ID locally (e.g. for optimistic
|
|
8
|
+
* UI) and have it stick.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CreateChannelArgsSchema: z.ZodObject<{
|
|
11
|
+
workspaceId: z.ZodNumber;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
id: z.ZodOptional<z.ZodString>;
|
|
14
|
+
userIds: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
15
|
+
color: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
16
|
+
public: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
17
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
defaultGroups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
19
|
+
defaultRecipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
20
|
+
isFavorited: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
21
|
+
icon: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type CreateChannelArgs = z.infer<typeof CreateChannelArgsSchema>;
|
|
24
|
+
export declare const UpdateChannelArgsSchema: z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
color: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
28
|
+
public: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
29
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
defaultGroups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
31
|
+
defaultRecipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
32
|
+
isFavorited: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
33
|
+
icon: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type UpdateChannelArgs = z.infer<typeof UpdateChannelArgsSchema>;
|
|
36
|
+
export declare const CreateThreadArgsSchema: z.ZodObject<{
|
|
37
|
+
channelId: z.ZodString;
|
|
38
|
+
content: z.ZodString;
|
|
39
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
40
|
+
id: z.ZodOptional<z.ZodString>;
|
|
41
|
+
recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
42
|
+
groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type CreateThreadArgs = z.infer<typeof CreateThreadArgsSchema>;
|
|
45
|
+
export declare const UpdateThreadArgsSchema: z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type UpdateThreadArgs = z.infer<typeof UpdateThreadArgsSchema>;
|
|
51
|
+
export declare const CreateCommentArgsSchema: z.ZodObject<{
|
|
52
|
+
threadId: z.ZodString;
|
|
53
|
+
content: z.ZodString;
|
|
54
|
+
id: z.ZodOptional<z.ZodString>;
|
|
55
|
+
attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
56
|
+
attachmentId: z.ZodString;
|
|
57
|
+
urlType: z.ZodString;
|
|
58
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
|
+
fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
61
|
+
fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
62
|
+
underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
65
|
+
imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
66
|
+
imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
67
|
+
duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
68
|
+
uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
|
+
video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
+
videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
72
|
+
}, z.core.$loose>>>>;
|
|
73
|
+
actions: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
74
|
+
recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
75
|
+
groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
76
|
+
directMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
77
|
+
directGroupMentions: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
78
|
+
notifyAudience: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
79
|
+
channel: "channel";
|
|
80
|
+
thread: "thread";
|
|
81
|
+
}>>>;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
export type CreateCommentArgs = z.infer<typeof CreateCommentArgsSchema>;
|
|
84
|
+
export declare const UpdateCommentArgsSchema: z.ZodObject<{
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
content: z.ZodString;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export type UpdateCommentArgs = z.infer<typeof UpdateCommentArgsSchema>;
|
|
89
|
+
export declare const CreateConversationArgsSchema: z.ZodObject<{
|
|
90
|
+
workspaceId: z.ZodNumber;
|
|
91
|
+
recipients: z.ZodArray<z.ZodNumber>;
|
|
92
|
+
id: z.ZodOptional<z.ZodString>;
|
|
93
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
export type CreateConversationArgs = z.infer<typeof CreateConversationArgsSchema>;
|
|
96
|
+
export declare const CreateMessageArgsSchema: z.ZodObject<{
|
|
97
|
+
conversationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
98
|
+
threadId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
99
|
+
content: z.ZodString;
|
|
100
|
+
id: z.ZodOptional<z.ZodString>;
|
|
101
|
+
attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
102
|
+
attachmentId: z.ZodString;
|
|
103
|
+
urlType: z.ZodString;
|
|
104
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
105
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
106
|
+
fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
107
|
+
fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
108
|
+
underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
109
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
110
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
111
|
+
imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
112
|
+
imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
113
|
+
duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
114
|
+
uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
115
|
+
video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
|
+
videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
117
|
+
videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
118
|
+
}, z.core.$loose>>>>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
export type CreateMessageArgs = z.infer<typeof CreateMessageArgsSchema>;
|
|
121
|
+
export declare const GetChannelsArgsSchema: z.ZodObject<{
|
|
122
|
+
workspaceId: z.ZodNumber;
|
|
123
|
+
archived: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
124
|
+
}, z.core.$strip>;
|
|
125
|
+
export type GetChannelsArgs = z.infer<typeof GetChannelsArgsSchema>;
|
|
126
|
+
export declare const GetThreadsArgsSchema: z.ZodObject<{
|
|
127
|
+
workspaceId: z.ZodNumber;
|
|
128
|
+
channelId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
129
|
+
archived: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
130
|
+
newerThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
131
|
+
olderThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
132
|
+
limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
export type GetThreadsArgs = z.infer<typeof GetThreadsArgsSchema>;
|
|
135
|
+
export declare const GetCommentsArgsSchema: z.ZodObject<{
|
|
136
|
+
threadId: z.ZodString;
|
|
137
|
+
newerThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
138
|
+
olderThan: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
139
|
+
limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
export type GetCommentsArgs = z.infer<typeof GetCommentsArgsSchema>;
|
|
142
|
+
export declare const GetConversationsArgsSchema: z.ZodObject<{
|
|
143
|
+
workspaceId: z.ZodNumber;
|
|
144
|
+
archived: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
export type GetConversationsArgs = z.infer<typeof GetConversationsArgsSchema>;
|
|
147
|
+
export declare const GetOrCreateConversationArgsSchema: z.ZodObject<{
|
|
148
|
+
workspaceId: z.ZodNumber;
|
|
149
|
+
userIds: z.ZodArray<z.ZodNumber>;
|
|
150
|
+
id: z.ZodOptional<z.ZodString>;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
export type GetOrCreateConversationArgs = z.infer<typeof GetOrCreateConversationArgsSchema>;
|
|
153
|
+
export type UpdateUserArgs = {
|
|
154
|
+
name?: string;
|
|
155
|
+
password?: string;
|
|
156
|
+
timezone?: string;
|
|
157
|
+
lang?: string;
|
|
158
|
+
dateFormat?: string;
|
|
159
|
+
timeFormat?: string;
|
|
160
|
+
/** Theme ID (0-12). String aliases like `'dark'` are also accepted. */
|
|
161
|
+
theme?: number | string;
|
|
162
|
+
};
|
|
163
|
+
type SearchArgsCommon = {
|
|
164
|
+
workspaceId: number;
|
|
165
|
+
channelIds?: string[];
|
|
166
|
+
authorIds?: number[];
|
|
167
|
+
dateFrom?: string;
|
|
168
|
+
dateTo?: string;
|
|
169
|
+
limit?: number;
|
|
170
|
+
cursor?: string;
|
|
171
|
+
};
|
|
172
|
+
export type SearchArgs = (SearchArgsCommon & {
|
|
173
|
+
query: string;
|
|
174
|
+
mentionSelf?: boolean;
|
|
175
|
+
}) | (SearchArgsCommon & {
|
|
176
|
+
query?: string;
|
|
177
|
+
mentionSelf: true;
|
|
178
|
+
});
|
|
179
|
+
export type SearchThreadArgs = {
|
|
180
|
+
query: string;
|
|
181
|
+
threadId: string;
|
|
182
|
+
limit?: number;
|
|
183
|
+
cursor?: string;
|
|
184
|
+
};
|
|
185
|
+
export type SearchConversationArgs = {
|
|
186
|
+
query: string;
|
|
187
|
+
conversationId: string;
|
|
188
|
+
limit?: number;
|
|
189
|
+
cursor?: string;
|
|
190
|
+
};
|
|
191
|
+
export type GetConversationMessagesArgs = {
|
|
192
|
+
conversationId: string;
|
|
193
|
+
newerThan?: Date;
|
|
194
|
+
olderThan?: Date;
|
|
195
|
+
limit?: number;
|
|
196
|
+
cursor?: string;
|
|
197
|
+
};
|
|
198
|
+
export type CreateConversationMessageArgs = {
|
|
199
|
+
conversationId: string;
|
|
200
|
+
content: string;
|
|
201
|
+
/** Caller-supplied ID. Auto-generated if omitted. */
|
|
202
|
+
id?: string;
|
|
203
|
+
attachments?: Attachment[];
|
|
204
|
+
actions?: unknown[];
|
|
205
|
+
directMentions?: number[];
|
|
206
|
+
directGroupMentions?: string[];
|
|
207
|
+
notify?: boolean;
|
|
208
|
+
};
|
|
209
|
+
export type UpdateConversationMessageArgs = {
|
|
210
|
+
id: string;
|
|
211
|
+
content: string;
|
|
212
|
+
attachments?: Attachment[];
|
|
213
|
+
actions?: unknown[];
|
|
214
|
+
directMentions?: number[];
|
|
215
|
+
directGroupMentions?: string[];
|
|
216
|
+
};
|
|
217
|
+
export declare const ARCHIVE_FILTER_VALUES: readonly ["active", "archived", "all"];
|
|
218
|
+
export type ArchiveFilter = (typeof ARCHIVE_FILTER_VALUES)[number];
|
|
219
|
+
export type GetInboxArgs = {
|
|
220
|
+
workspaceId: number;
|
|
221
|
+
newerThan?: Date;
|
|
222
|
+
olderThan?: Date;
|
|
223
|
+
limit?: number;
|
|
224
|
+
cursor?: string;
|
|
225
|
+
archiveFilter?: ArchiveFilter;
|
|
226
|
+
};
|
|
227
|
+
export type ArchiveAllArgs = {
|
|
228
|
+
workspaceId: number;
|
|
229
|
+
channelIds?: string[];
|
|
230
|
+
olderThan?: Date;
|
|
231
|
+
};
|
|
232
|
+
export type AddReactionArgs = {
|
|
233
|
+
threadId?: string;
|
|
234
|
+
commentId?: string;
|
|
235
|
+
messageId?: string;
|
|
236
|
+
reaction: string;
|
|
237
|
+
};
|
|
238
|
+
export type RemoveReactionArgs = {
|
|
239
|
+
threadId?: string;
|
|
240
|
+
commentId?: string;
|
|
241
|
+
messageId?: string;
|
|
242
|
+
reaction: string;
|
|
243
|
+
};
|
|
244
|
+
export type GetReactionsArgs = {
|
|
245
|
+
threadId?: string;
|
|
246
|
+
commentId?: string;
|
|
247
|
+
messageId?: string;
|
|
248
|
+
};
|
|
249
|
+
export type AddChannelUserArgs = {
|
|
250
|
+
id: string;
|
|
251
|
+
userId: number;
|
|
252
|
+
};
|
|
253
|
+
export type AddChannelUsersArgs = {
|
|
254
|
+
id: string;
|
|
255
|
+
userIds: number[];
|
|
256
|
+
};
|
|
257
|
+
export type RemoveChannelUserArgs = {
|
|
258
|
+
id: string;
|
|
259
|
+
userId: number;
|
|
260
|
+
};
|
|
261
|
+
export type RemoveChannelUsersArgs = {
|
|
262
|
+
id: string;
|
|
263
|
+
userIds: number[];
|
|
264
|
+
};
|
|
265
|
+
export declare const THREAD_ACTIONS: readonly ["close", "reopen"];
|
|
266
|
+
export type ThreadAction = (typeof THREAD_ACTIONS)[number];
|
|
267
|
+
/**
|
|
268
|
+
* Shared shape for endpoints that post a comment as part of a thread action
|
|
269
|
+
* (close, reopen). Identical to {@link CreateCommentArgs} except the target
|
|
270
|
+
* is identified by `id` (the thread ID) instead of `threadId`.
|
|
271
|
+
*/
|
|
272
|
+
type ThreadActionCommentArgs = Omit<CreateCommentArgs, 'threadId'> & {
|
|
273
|
+
id: string;
|
|
274
|
+
};
|
|
275
|
+
export type CloseThreadArgs = ThreadActionCommentArgs;
|
|
276
|
+
export type ReopenThreadArgs = ThreadActionCommentArgs;
|
|
277
|
+
export type MoveThreadToChannelArgs = {
|
|
278
|
+
id: string;
|
|
279
|
+
toChannel: string;
|
|
280
|
+
};
|
|
281
|
+
export type MarkThreadReadArgs = {
|
|
282
|
+
id: string;
|
|
283
|
+
objIndex: number;
|
|
284
|
+
};
|
|
285
|
+
export type MarkThreadUnreadArgs = {
|
|
286
|
+
id: string;
|
|
287
|
+
objIndex: number;
|
|
288
|
+
};
|
|
289
|
+
export type MarkThreadUnreadForOthersArgs = {
|
|
290
|
+
id: string;
|
|
291
|
+
objIndex: number;
|
|
292
|
+
};
|
|
293
|
+
export type MuteThreadArgs = {
|
|
294
|
+
id: string;
|
|
295
|
+
minutes: number;
|
|
296
|
+
};
|
|
297
|
+
export type MarkCommentPositionArgs = {
|
|
298
|
+
threadId: string;
|
|
299
|
+
commentId: string;
|
|
300
|
+
};
|
|
301
|
+
export type UpdateConversationArgs = {
|
|
302
|
+
id: string;
|
|
303
|
+
title: string;
|
|
304
|
+
archived?: boolean;
|
|
305
|
+
};
|
|
306
|
+
export type AddConversationUserArgs = {
|
|
307
|
+
id: string;
|
|
308
|
+
userId: number;
|
|
309
|
+
};
|
|
310
|
+
export type AddConversationUsersArgs = {
|
|
311
|
+
id: string;
|
|
312
|
+
userIds: number[];
|
|
313
|
+
};
|
|
314
|
+
export type RemoveConversationUserArgs = {
|
|
315
|
+
id: string;
|
|
316
|
+
userId: number;
|
|
317
|
+
};
|
|
318
|
+
export type RemoveConversationUsersArgs = {
|
|
319
|
+
id: string;
|
|
320
|
+
userIds: number[];
|
|
321
|
+
};
|
|
322
|
+
export type MuteConversationArgs = {
|
|
323
|
+
id: string;
|
|
324
|
+
minutes: number;
|
|
325
|
+
};
|
|
326
|
+
export type AddGroupUserArgs = {
|
|
327
|
+
id: string;
|
|
328
|
+
workspaceId: number;
|
|
329
|
+
userId: number;
|
|
330
|
+
};
|
|
331
|
+
export type AddGroupUsersArgs = {
|
|
332
|
+
id: string;
|
|
333
|
+
workspaceId: number;
|
|
334
|
+
userIds: number[];
|
|
335
|
+
};
|
|
336
|
+
export type RemoveGroupUserArgs = {
|
|
337
|
+
id: string;
|
|
338
|
+
workspaceId: number;
|
|
339
|
+
userId: number;
|
|
340
|
+
};
|
|
341
|
+
export type RemoveGroupUsersArgs = {
|
|
342
|
+
id: string;
|
|
343
|
+
workspaceId: number;
|
|
344
|
+
userIds: number[];
|
|
345
|
+
};
|
|
346
|
+
export type GetWorkspaceUsersArgs = {
|
|
347
|
+
workspaceId: number;
|
|
348
|
+
archived?: boolean;
|
|
349
|
+
};
|
|
350
|
+
export type GetUserByIdArgs = {
|
|
351
|
+
workspaceId: number;
|
|
352
|
+
userId: number;
|
|
353
|
+
};
|
|
354
|
+
export type GetUserByEmailArgs = {
|
|
355
|
+
workspaceId: number;
|
|
356
|
+
email: string;
|
|
357
|
+
};
|
|
358
|
+
export type GetUserInfoArgs = {
|
|
359
|
+
workspaceId: number;
|
|
360
|
+
userId: number;
|
|
361
|
+
};
|
|
362
|
+
export type GetUserLocalTimeArgs = {
|
|
363
|
+
workspaceId: number;
|
|
364
|
+
userId: number;
|
|
365
|
+
};
|
|
366
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a Unix timestamp (in seconds) to a Date object.
|
|
3
|
+
* @param timestamp - Unix timestamp in seconds
|
|
4
|
+
* @returns Date object
|
|
5
|
+
*/
|
|
6
|
+
export declare function timestampToDate(timestamp: number): Date;
|
|
7
|
+
/**
|
|
8
|
+
* Recursively transforms all timestamp fields (ending in 'Ts') in an object to Date objects.
|
|
9
|
+
* Also renames the fields by removing the 'Ts' suffix.
|
|
10
|
+
* @param obj - The object to transform
|
|
11
|
+
* @returns The transformed object with Date fields
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformTimestamps<T>(obj: T): T;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for creating Comms permalinks (`https://comms.todoist.com/a/...`).
|
|
3
|
+
*/
|
|
4
|
+
export type CommsURLParams = {
|
|
5
|
+
workspaceId: number;
|
|
6
|
+
channelId?: string;
|
|
7
|
+
conversationId?: string;
|
|
8
|
+
threadId?: string;
|
|
9
|
+
commentId?: string;
|
|
10
|
+
messageId?: string;
|
|
11
|
+
userId?: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Builds a relative Comms URL based on the provided parameters
|
|
15
|
+
* @param params - URL parameters including workspace, channel, conversation, thread, etc.
|
|
16
|
+
* @returns A relative URL path
|
|
17
|
+
* @example
|
|
18
|
+
* getCommsURL({ workspaceId: 1, channelId: '7Yp...', threadId: '7Yq...' })
|
|
19
|
+
* // returns '/a/1/ch/7Yp.../t/7Yq.../'
|
|
20
|
+
*/
|
|
21
|
+
export declare function getCommsURL(params: CommsURLParams): string;
|
|
22
|
+
/**
|
|
23
|
+
* Builds a full Comms URL (with protocol and hostname) based on the provided parameters
|
|
24
|
+
* @param params - URL parameters including workspace, channel, conversation, thread, etc.
|
|
25
|
+
* @param baseUrl - Optional base URL (defaults to 'https://comms.todoist.com')
|
|
26
|
+
*/
|
|
27
|
+
export declare function getFullCommsURL(params: CommsURLParams, baseUrl?: string): string;
|
|
28
|
+
/** Returns the URL for a thread in a channel. */
|
|
29
|
+
export declare function getThreadURL(params: {
|
|
30
|
+
workspaceId: number;
|
|
31
|
+
channelId: string;
|
|
32
|
+
threadId: string;
|
|
33
|
+
}): string;
|
|
34
|
+
/** Returns the URL for a channel. */
|
|
35
|
+
export declare function getChannelURL(params: {
|
|
36
|
+
workspaceId: number;
|
|
37
|
+
channelId: string;
|
|
38
|
+
}): string;
|
|
39
|
+
/** Returns the URL for a conversation. */
|
|
40
|
+
export declare function getConversationURL(params: {
|
|
41
|
+
workspaceId: number;
|
|
42
|
+
conversationId: string;
|
|
43
|
+
}): string;
|
|
44
|
+
/** Returns the URL for a specific message in a conversation. */
|
|
45
|
+
export declare function getMessageURL(params: {
|
|
46
|
+
workspaceId: number;
|
|
47
|
+
conversationId: string;
|
|
48
|
+
messageId: string;
|
|
49
|
+
}): string;
|
|
50
|
+
/** Returns the URL for a comment in a thread. */
|
|
51
|
+
export declare function getCommentURL(params: {
|
|
52
|
+
workspaceId: number;
|
|
53
|
+
channelId: string;
|
|
54
|
+
threadId: string;
|
|
55
|
+
commentId: string;
|
|
56
|
+
}): string;
|
|
57
|
+
/** Returns the URL for the threads root (channels view). */
|
|
58
|
+
export declare function getThreadsRootURL(workspaceId: number): string;
|
|
59
|
+
/** Returns the URL for the inbox. */
|
|
60
|
+
export declare function getInboxURL(workspaceId: number, tab?: 'done' | 'mentions'): string;
|
|
61
|
+
/** Returns the URL for the messages/conversations root. */
|
|
62
|
+
export declare function getMessagesRootURL(workspaceId: number): string;
|
|
63
|
+
/** Returns the URL for a user profile. */
|
|
64
|
+
export declare function getUserProfileURL(params: {
|
|
65
|
+
workspaceId: number;
|
|
66
|
+
userId: number;
|
|
67
|
+
}): string;
|
|
68
|
+
/** Returns the URL for the saved threads view. */
|
|
69
|
+
export declare function getSavedThreadsRootURL(workspaceId: number): string;
|
|
70
|
+
/** Returns the URL for a saved thread. */
|
|
71
|
+
export declare function getSavedThreadURL(params: {
|
|
72
|
+
workspaceId: number;
|
|
73
|
+
threadId: string;
|
|
74
|
+
}): string;
|
|
75
|
+
/** Returns the URL for the search root. */
|
|
76
|
+
export declare function getSearchRootURL(workspaceId: number): string;
|
|
77
|
+
/** Returns the URL for a search with a query. */
|
|
78
|
+
export declare function getSearchQueryURL(params: {
|
|
79
|
+
workspaceId: number;
|
|
80
|
+
query: string;
|
|
81
|
+
}): string;
|
|
82
|
+
/** Returns the URL for settings. */
|
|
83
|
+
export declare function getSettingsURL(params: {
|
|
84
|
+
workspaceId: number;
|
|
85
|
+
initialLocation?: string;
|
|
86
|
+
}): string;
|
|
87
|
+
/** Returns the URL for the team members root. */
|
|
88
|
+
export declare function getTeamMembersRootURL(workspaceId: number): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare class UuidV7Error extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
/** Encode a 16-byte UUID as a base58 string. */
|
|
5
|
+
export declare function encodeUuidToBase58(bytes: Uint8Array): string;
|
|
6
|
+
/**
|
|
7
|
+
* Decode a base58 string back into 16 UUID bytes. Throws {@link UuidV7Error}
|
|
8
|
+
* if the input is malformed or doesn't decode to exactly 16 bytes.
|
|
9
|
+
*/
|
|
10
|
+
export declare function decodeBase58ToUuidBytes(value: string): Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* Mint a fresh ID. Callers should generate one of these locally when
|
|
13
|
+
* creating a new channel / thread / comment / conversation / message /
|
|
14
|
+
* group — the backend requires the client to supply the ID on create.
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateId(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the `id` for a create-style API call: validate the caller-supplied
|
|
19
|
+
* value (throwing {@link UuidV7Error} before the request leaves the SDK) or
|
|
20
|
+
* mint a fresh one via {@link generateId}.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveCreateId(id: string | undefined): string;
|
|
23
|
+
/**
|
|
24
|
+
* Validate that a value matches the expected ID format (the decoded bytes
|
|
25
|
+
* have the v7 version nibble + RFC 4122/9562 variant bits). Does NOT
|
|
26
|
+
* validate the embedded timestamp — the backend may still reject a value
|
|
27
|
+
* that is too far in the future or past.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidUuidV7Base58(value: unknown): value is string;
|
|
30
|
+
/**
|
|
31
|
+
* Encode a canonical UUID string (hyphenated or not, any case) as a
|
|
32
|
+
* wire-format ID. Useful when interoperating with systems that hand you
|
|
33
|
+
* UUIDs in canonical form.
|
|
34
|
+
*/
|
|
35
|
+
export declare function base58FromUuidString(uuid: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Inverse of {@link base58FromUuidString}: takes a wire-format ID and
|
|
38
|
+
* returns the canonical hyphenated UUID string.
|
|
39
|
+
*/
|
|
40
|
+
export declare function uuidStringFromBase58(value: string): string;
|