@doist/comms-sdk 0.4.0 → 0.4.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/dist/cjs/clients/threads-client.js +1 -0
- package/dist/cjs/types/entities.js +8 -5
- package/dist/cjs/types/requests.js +3 -2
- package/dist/esm/clients/threads-client.js +1 -0
- package/dist/esm/types/entities.js +7 -4
- package/dist/esm/types/requests.js +4 -3
- package/dist/types/clients/threads-client.d.ts +1 -0
- package/dist/types/types/entities.d.ts +19 -0
- package/dist/types/types/requests.d.ts +20 -2
- package/package.json +1 -1
|
@@ -95,6 +95,7 @@ class ThreadsClient extends base_client_1.BaseClient {
|
|
|
95
95
|
* @param args.content - The thread content.
|
|
96
96
|
* @param args.recipients - Optional array of user IDs to notify.
|
|
97
97
|
* @param args.groups - Optional array of custom group IDs to notify.
|
|
98
|
+
* @param args.attachments - Optional array of {@link Attachment}s (from `attachments.upload`).
|
|
98
99
|
* @returns The created thread object.
|
|
99
100
|
*
|
|
100
101
|
* @example
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SearchResultSchema = exports.SEARCH_RESULT_TYPES = exports.UnreadConversationSchema = exports.UnreadThreadSchema = exports.InboxThreadSchema = exports.ConversationMessageSchema = exports.ConversationMessageObjectSchema = exports.WorkspaceUserSchema = exports.CommentSchema = exports.CommentObjectSchema = exports.ConversationSchema = exports.ConversationObjectSchema = exports.GroupSchema = exports.ThreadSchema = exports.ThreadObjectSchema = exports.ChannelSchema = exports.ChannelObjectSchema = exports.WorkspaceSchema = exports.UserSchema = exports.BaseUserSchema = exports.AttachmentSchema = exports.StatusOkSchema = exports.SystemMessageSchema = void 0;
|
|
3
|
+
exports.SearchResultSchema = exports.SEARCH_RESULT_TYPES = exports.UnreadConversationSchema = exports.UnreadThreadSchema = exports.InboxThreadSchema = exports.ConversationMessageSchema = exports.ConversationMessageObjectSchema = exports.WorkspaceUserSchema = exports.CommentSchema = exports.CommentObjectSchema = exports.ConversationSchema = exports.ConversationObjectSchema = exports.GroupSchema = exports.ThreadSchema = exports.ThreadObjectSchema = exports.ChannelSchema = exports.ChannelObjectSchema = exports.WorkspaceSchema = exports.UserSchema = exports.BaseUserSchema = exports.RequestAttachmentSchema = exports.AttachmentSchema = exports.StatusOkSchema = exports.SystemMessageSchema = void 0;
|
|
4
4
|
exports.createChannelSchema = createChannelSchema;
|
|
5
5
|
exports.createThreadSchema = createThreadSchema;
|
|
6
6
|
exports.createConversationSchema = createConversationSchema;
|
|
@@ -33,8 +33,7 @@ exports.StatusOkSchema = zod_1.z.object({ status: zod_1.z.literal('ok') });
|
|
|
33
33
|
// the attachment kind (file vs image vs link preview vs unfurled GIF).
|
|
34
34
|
// Loose: unknown keys from the backend pass through rather than being
|
|
35
35
|
// stripped, so newly-added or off-spec fields stay accessible to callers.
|
|
36
|
-
|
|
37
|
-
.object({
|
|
36
|
+
const attachmentShape = {
|
|
38
37
|
attachmentId: zod_1.z.string(),
|
|
39
38
|
urlType: zod_1.z.string(),
|
|
40
39
|
title: zod_1.z.string().nullable().optional(),
|
|
@@ -51,8 +50,12 @@ exports.AttachmentSchema = zod_1.z
|
|
|
51
50
|
video: zod_1.z.string().nullable().optional(),
|
|
52
51
|
videoType: zod_1.z.string().nullable().optional(),
|
|
53
52
|
videoAutoPlay: zod_1.z.boolean().nullable().optional(),
|
|
54
|
-
}
|
|
55
|
-
|
|
53
|
+
};
|
|
54
|
+
exports.AttachmentSchema = zod_1.z.object(attachmentShape).loose();
|
|
55
|
+
// Request-side attachment schema. Unlike the loose response `AttachmentSchema`,
|
|
56
|
+
// this strips unknown keys so caller typos / off-spec fields are dropped instead
|
|
57
|
+
// of being forwarded on the wire. Use this for `*Args` request schemas.
|
|
58
|
+
exports.RequestAttachmentSchema = zod_1.z.object(attachmentShape);
|
|
56
59
|
// Fields shared by `User` and `WorkspaceUser`. Profile fields
|
|
57
60
|
// (`fullName`, `imageId`, avatar URLs) are sourced from Todoist-ID.
|
|
58
61
|
exports.BaseUserSchema = zod_1.z.object({
|
|
@@ -42,6 +42,7 @@ exports.CreateThreadArgsSchema = zod_1.z.object({
|
|
|
42
42
|
id: zod_1.z.string().optional(),
|
|
43
43
|
recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
|
|
44
44
|
groups: zod_1.z.array(zod_1.z.string()).nullable().optional(),
|
|
45
|
+
attachments: zod_1.z.array(entities_1.RequestAttachmentSchema).nullable().optional(),
|
|
45
46
|
});
|
|
46
47
|
exports.UpdateThreadArgsSchema = zod_1.z.object({
|
|
47
48
|
id: zod_1.z.string(),
|
|
@@ -52,7 +53,7 @@ exports.CreateCommentArgsSchema = zod_1.z.object({
|
|
|
52
53
|
threadId: zod_1.z.string(),
|
|
53
54
|
content: zod_1.z.string(),
|
|
54
55
|
id: zod_1.z.string().optional(),
|
|
55
|
-
attachments: zod_1.z.array(entities_1.
|
|
56
|
+
attachments: zod_1.z.array(entities_1.RequestAttachmentSchema).nullable().optional(),
|
|
56
57
|
actions: zod_1.z.unknown().nullable().optional(),
|
|
57
58
|
recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
|
|
58
59
|
groups: zod_1.z.array(zod_1.z.string()).nullable().optional(),
|
|
@@ -76,7 +77,7 @@ exports.CreateMessageArgsSchema = zod_1.z
|
|
|
76
77
|
threadId: zod_1.z.string().nullable().optional(),
|
|
77
78
|
content: zod_1.z.string(),
|
|
78
79
|
id: zod_1.z.string().optional(),
|
|
79
|
-
attachments: zod_1.z.array(entities_1.
|
|
80
|
+
attachments: zod_1.z.array(entities_1.RequestAttachmentSchema).nullable().optional(),
|
|
80
81
|
})
|
|
81
82
|
.refine((data) => {
|
|
82
83
|
return ((data.conversationId && !data.threadId) || (!data.conversationId && data.threadId));
|
|
@@ -92,6 +92,7 @@ export class ThreadsClient extends BaseClient {
|
|
|
92
92
|
* @param args.content - The thread content.
|
|
93
93
|
* @param args.recipients - Optional array of user IDs to notify.
|
|
94
94
|
* @param args.groups - Optional array of custom group IDs to notify.
|
|
95
|
+
* @param args.attachments - Optional array of {@link Attachment}s (from `attachments.upload`).
|
|
95
96
|
* @returns The created thread object.
|
|
96
97
|
*
|
|
97
98
|
* @example
|
|
@@ -23,8 +23,7 @@ export const StatusOkSchema = z.object({ status: z.literal('ok') });
|
|
|
23
23
|
// the attachment kind (file vs image vs link preview vs unfurled GIF).
|
|
24
24
|
// Loose: unknown keys from the backend pass through rather than being
|
|
25
25
|
// stripped, so newly-added or off-spec fields stay accessible to callers.
|
|
26
|
-
|
|
27
|
-
.object({
|
|
26
|
+
const attachmentShape = {
|
|
28
27
|
attachmentId: z.string(),
|
|
29
28
|
urlType: z.string(),
|
|
30
29
|
title: z.string().nullable().optional(),
|
|
@@ -41,8 +40,12 @@ export const AttachmentSchema = z
|
|
|
41
40
|
video: z.string().nullable().optional(),
|
|
42
41
|
videoType: z.string().nullable().optional(),
|
|
43
42
|
videoAutoPlay: z.boolean().nullable().optional(),
|
|
44
|
-
}
|
|
45
|
-
|
|
43
|
+
};
|
|
44
|
+
export const AttachmentSchema = z.object(attachmentShape).loose();
|
|
45
|
+
// Request-side attachment schema. Unlike the loose response `AttachmentSchema`,
|
|
46
|
+
// this strips unknown keys so caller typos / off-spec fields are dropped instead
|
|
47
|
+
// of being forwarded on the wire. Use this for `*Args` request schemas.
|
|
48
|
+
export const RequestAttachmentSchema = z.object(attachmentShape);
|
|
46
49
|
// Fields shared by `User` and `WorkspaceUser`. Profile fields
|
|
47
50
|
// (`fullName`, `imageId`, avatar URLs) are sourced from Todoist-ID.
|
|
48
51
|
export const BaseUserSchema = z.object({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { RequestAttachmentSchema } from './entities.js';
|
|
3
3
|
import { NOTIFY_AUDIENCES } from './enums.js';
|
|
4
4
|
/**
|
|
5
5
|
* Create-side requests require an `id` on the wire. The SDK clients accept
|
|
@@ -39,6 +39,7 @@ export const CreateThreadArgsSchema = z.object({
|
|
|
39
39
|
id: z.string().optional(),
|
|
40
40
|
recipients: z.array(z.number()).nullable().optional(),
|
|
41
41
|
groups: z.array(z.string()).nullable().optional(),
|
|
42
|
+
attachments: z.array(RequestAttachmentSchema).nullable().optional(),
|
|
42
43
|
});
|
|
43
44
|
export const UpdateThreadArgsSchema = z.object({
|
|
44
45
|
id: z.string(),
|
|
@@ -49,7 +50,7 @@ export const CreateCommentArgsSchema = z.object({
|
|
|
49
50
|
threadId: z.string(),
|
|
50
51
|
content: z.string(),
|
|
51
52
|
id: z.string().optional(),
|
|
52
|
-
attachments: z.array(
|
|
53
|
+
attachments: z.array(RequestAttachmentSchema).nullable().optional(),
|
|
53
54
|
actions: z.unknown().nullable().optional(),
|
|
54
55
|
recipients: z.array(z.number()).nullable().optional(),
|
|
55
56
|
groups: z.array(z.string()).nullable().optional(),
|
|
@@ -73,7 +74,7 @@ export const CreateMessageArgsSchema = z
|
|
|
73
74
|
threadId: z.string().nullable().optional(),
|
|
74
75
|
content: z.string(),
|
|
75
76
|
id: z.string().optional(),
|
|
76
|
-
attachments: z.array(
|
|
77
|
+
attachments: z.array(RequestAttachmentSchema).nullable().optional(),
|
|
77
78
|
})
|
|
78
79
|
.refine((data) => {
|
|
79
80
|
return ((data.conversationId && !data.threadId) || (!data.conversationId && data.threadId));
|
|
@@ -336,6 +336,7 @@ export declare class ThreadsClient extends BaseClient {
|
|
|
336
336
|
* @param args.content - The thread content.
|
|
337
337
|
* @param args.recipients - Optional array of user IDs to notify.
|
|
338
338
|
* @param args.groups - Optional array of custom group IDs to notify.
|
|
339
|
+
* @param args.attachments - Optional array of {@link Attachment}s (from `attachments.upload`).
|
|
339
340
|
* @returns The created thread object.
|
|
340
341
|
*
|
|
341
342
|
* @example
|
|
@@ -30,6 +30,25 @@ export declare const AttachmentSchema: z.ZodObject<{
|
|
|
30
30
|
videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
31
31
|
}, z.core.$loose>;
|
|
32
32
|
export type Attachment = z.infer<typeof AttachmentSchema>;
|
|
33
|
+
export declare const RequestAttachmentSchema: z.ZodObject<{
|
|
34
|
+
attachmentId: z.ZodString;
|
|
35
|
+
urlType: z.ZodString;
|
|
36
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
39
|
+
fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
40
|
+
underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
43
|
+
imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
44
|
+
imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
|
+
duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
|
+
uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export type RequestAttachment = z.infer<typeof RequestAttachmentSchema>;
|
|
33
52
|
export declare const BaseUserSchema: z.ZodObject<{
|
|
34
53
|
id: z.ZodNumber;
|
|
35
54
|
fullName: z.ZodString;
|
|
@@ -40,6 +40,24 @@ export declare const CreateThreadArgsSchema: z.ZodObject<{
|
|
|
40
40
|
id: z.ZodOptional<z.ZodString>;
|
|
41
41
|
recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
42
42
|
groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
43
|
+
attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
44
|
+
attachmentId: z.ZodString;
|
|
45
|
+
urlType: z.ZodString;
|
|
46
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
50
|
+
underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
54
|
+
imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
55
|
+
duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
|
+
video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
60
|
+
}, z.core.$strip>>>>;
|
|
43
61
|
}, z.core.$strip>;
|
|
44
62
|
export type CreateThreadArgs = z.infer<typeof CreateThreadArgsSchema>;
|
|
45
63
|
export declare const UpdateThreadArgsSchema: z.ZodObject<{
|
|
@@ -69,7 +87,7 @@ export declare const CreateCommentArgsSchema: z.ZodObject<{
|
|
|
69
87
|
video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
88
|
videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
89
|
videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
72
|
-
}, z.core.$
|
|
90
|
+
}, z.core.$strip>>>>;
|
|
73
91
|
actions: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
74
92
|
recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
75
93
|
groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -115,7 +133,7 @@ export declare const CreateMessageArgsSchema: z.ZodObject<{
|
|
|
115
133
|
video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
134
|
videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
117
135
|
videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
118
|
-
}, z.core.$
|
|
136
|
+
}, z.core.$strip>>>>;
|
|
119
137
|
}, z.core.$strip>;
|
|
120
138
|
export type CreateMessageArgs = z.infer<typeof CreateMessageArgsSchema>;
|
|
121
139
|
export declare const GetChannelsArgsSchema: z.ZodObject<{
|