@doist/twist-sdk 2.9.0 → 2.9.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.
@@ -98,6 +98,13 @@ var ThreadsClient = /** @class */ (function (_super) {
98
98
  var params = args;
99
99
  var schema = this.threadSchema;
100
100
  if (options === null || options === void 0 ? void 0 : options.batch) {
101
+ // The batch builder URL-encodes array params with `.join(',')`, which turns an
102
+ // array of attachment objects into `[object Object]`. Until batch serialization
103
+ // handles nested objects, reject attachments in batch mode rather than sending a
104
+ // silently broken payload. Upload + attach outside the batch instead.
105
+ if (args.attachments && args.attachments.length > 0) {
106
+ throw new Error('createThread does not support `attachments` in batch mode; create the thread with attachments outside the batch.');
107
+ }
101
108
  return { method: method, url: url, params: params, schema: schema };
102
109
  }
103
110
  return (0, http_client_1.request)({
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- 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.SystemMessageSchema = void 0;
14
+ 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.SystemMessageSchema = void 0;
15
15
  exports.createChannelSchema = createChannelSchema;
16
16
  exports.createThreadSchema = createThreadSchema;
17
17
  exports.createConversationSchema = createConversationSchema;
@@ -29,8 +29,7 @@ exports.SystemMessageSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.unknown()
29
29
  // the attachment kind (file vs image vs link preview vs unfurled GIF).
30
30
  // Loose: unknown keys from the backend pass through rather than being stripped,
31
31
  // so newly-added or off-spec fields stay accessible to callers.
32
- exports.AttachmentSchema = zod_1.z
33
- .object({
32
+ var attachmentShape = {
34
33
  attachmentId: zod_1.z.string(),
35
34
  urlType: zod_1.z.string(),
36
35
  title: zod_1.z.string().nullable().optional(),
@@ -47,8 +46,12 @@ exports.AttachmentSchema = zod_1.z
47
46
  video: zod_1.z.string().nullable().optional(),
48
47
  videoType: zod_1.z.string().nullable().optional(),
49
48
  videoAutoPlay: zod_1.z.boolean().nullable().optional(),
50
- })
51
- .loose();
49
+ };
50
+ exports.AttachmentSchema = zod_1.z.object(attachmentShape).loose();
51
+ // Request-side attachment schema. Unlike the loose response `AttachmentSchema`,
52
+ // this strips unknown keys so caller typos / off-spec fields are dropped instead
53
+ // of being forwarded on the wire. Use this for `*Args` request schemas.
54
+ exports.RequestAttachmentSchema = zod_1.z.object(attachmentShape);
52
55
  // Base user schema with common fields shared between User and WorkspaceUser
53
56
  exports.BaseUserSchema = zod_1.z.object({
54
57
  id: zod_1.z.number(),
@@ -35,6 +35,7 @@ exports.CreateThreadArgsSchema = zod_1.z.object({
35
35
  recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
36
36
  groups: zod_1.z.array(zod_1.z.number()).nullable().optional(),
37
37
  tempId: zod_1.z.number().nullable().optional(),
38
+ attachments: zod_1.z.array(entities_1.RequestAttachmentSchema).nullable().optional(),
38
39
  });
39
40
  exports.UpdateThreadArgsSchema = zod_1.z.object({
40
41
  id: zod_1.z.number(),
@@ -45,7 +46,7 @@ exports.CreateCommentArgsSchema = zod_1.z.object({
45
46
  threadId: zod_1.z.number(),
46
47
  content: zod_1.z.string(),
47
48
  tempId: zod_1.z.number().nullable().optional(),
48
- attachments: zod_1.z.array(entities_1.AttachmentSchema).nullable().optional(),
49
+ attachments: zod_1.z.array(entities_1.RequestAttachmentSchema).nullable().optional(),
49
50
  actions: zod_1.z.unknown().nullable().optional(),
50
51
  recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
51
52
  groups: zod_1.z.array(zod_1.z.number()).nullable().optional(),
@@ -66,7 +67,7 @@ exports.CreateMessageArgsSchema = zod_1.z
66
67
  conversationId: zod_1.z.number().nullable().optional(),
67
68
  threadId: zod_1.z.number().nullable().optional(),
68
69
  content: zod_1.z.string(),
69
- attachments: zod_1.z.array(entities_1.AttachmentSchema).nullable().optional(),
70
+ attachments: zod_1.z.array(entities_1.RequestAttachmentSchema).nullable().optional(),
70
71
  })
71
72
  .refine(function (data) {
72
73
  return ((data.conversationId && !data.threadId) || (!data.conversationId && data.threadId));
@@ -95,6 +95,13 @@ var ThreadsClient = /** @class */ (function (_super) {
95
95
  var params = args;
96
96
  var schema = this.threadSchema;
97
97
  if (options === null || options === void 0 ? void 0 : options.batch) {
98
+ // The batch builder URL-encodes array params with `.join(',')`, which turns an
99
+ // array of attachment objects into `[object Object]`. Until batch serialization
100
+ // handles nested objects, reject attachments in batch mode rather than sending a
101
+ // silently broken payload. Upload + attach outside the batch instead.
102
+ if (args.attachments && args.attachments.length > 0) {
103
+ throw new Error('createThread does not support `attachments` in batch mode; create the thread with attachments outside the batch.');
104
+ }
98
105
  return { method: method, url: url, params: params, schema: schema };
99
106
  }
100
107
  return request({
@@ -20,8 +20,7 @@ export var SystemMessageSchema = z.union([z.string(), z.unknown()]).nullable().o
20
20
  // the attachment kind (file vs image vs link preview vs unfurled GIF).
21
21
  // Loose: unknown keys from the backend pass through rather than being stripped,
22
22
  // so newly-added or off-spec fields stay accessible to callers.
23
- export var AttachmentSchema = z
24
- .object({
23
+ var attachmentShape = {
25
24
  attachmentId: z.string(),
26
25
  urlType: z.string(),
27
26
  title: z.string().nullable().optional(),
@@ -38,8 +37,12 @@ export var AttachmentSchema = z
38
37
  video: z.string().nullable().optional(),
39
38
  videoType: z.string().nullable().optional(),
40
39
  videoAutoPlay: z.boolean().nullable().optional(),
41
- })
42
- .loose();
40
+ };
41
+ export var AttachmentSchema = z.object(attachmentShape).loose();
42
+ // Request-side attachment schema. Unlike the loose response `AttachmentSchema`,
43
+ // this strips unknown keys so caller typos / off-spec fields are dropped instead
44
+ // of being forwarded on the wire. Use this for `*Args` request schemas.
45
+ export var RequestAttachmentSchema = z.object(attachmentShape);
43
46
  // Base user schema with common fields shared between User and WorkspaceUser
44
47
  export var BaseUserSchema = z.object({
45
48
  id: z.number(),
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AttachmentSchema } from './entities.js';
2
+ import { RequestAttachmentSchema } from './entities.js';
3
3
  import { NOTIFY_AUDIENCES } from './enums.js';
4
4
  export var CreateChannelArgsSchema = z.object({
5
5
  workspaceId: z.number(),
@@ -32,6 +32,7 @@ export var CreateThreadArgsSchema = z.object({
32
32
  recipients: z.array(z.number()).nullable().optional(),
33
33
  groups: z.array(z.number()).nullable().optional(),
34
34
  tempId: z.number().nullable().optional(),
35
+ attachments: z.array(RequestAttachmentSchema).nullable().optional(),
35
36
  });
36
37
  export var UpdateThreadArgsSchema = z.object({
37
38
  id: z.number(),
@@ -42,7 +43,7 @@ export var CreateCommentArgsSchema = z.object({
42
43
  threadId: z.number(),
43
44
  content: z.string(),
44
45
  tempId: z.number().nullable().optional(),
45
- attachments: z.array(AttachmentSchema).nullable().optional(),
46
+ attachments: z.array(RequestAttachmentSchema).nullable().optional(),
46
47
  actions: z.unknown().nullable().optional(),
47
48
  recipients: z.array(z.number()).nullable().optional(),
48
49
  groups: z.array(z.number()).nullable().optional(),
@@ -63,7 +64,7 @@ export var CreateMessageArgsSchema = z
63
64
  conversationId: z.number().nullable().optional(),
64
65
  threadId: z.number().nullable().optional(),
65
66
  content: z.string(),
66
- attachments: z.array(AttachmentSchema).nullable().optional(),
67
+ attachments: z.array(RequestAttachmentSchema).nullable().optional(),
67
68
  })
68
69
  .refine(function (data) {
69
70
  return ((data.conversationId && !data.threadId) || (!data.conversationId && data.threadId));
@@ -56,6 +56,7 @@ export declare class ThreadsClient extends BaseClient {
56
56
  * @param args.title - The thread title.
57
57
  * @param args.content - The thread content.
58
58
  * @param args.recipients - Optional array of user IDs to notify.
59
+ * @param args.attachments - Optional array of {@link Attachment}s (from `attachments.upload`).
59
60
  * @param args.sendAsIntegration - Optional flag to send as integration.
60
61
  * @param options - Optional configuration. Set `batch: true` to return a descriptor for batch requests.
61
62
  * @returns The created thread object.
@@ -19,6 +19,25 @@ export declare const AttachmentSchema: z.ZodObject<{
19
19
  videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
20
20
  }, z.core.$loose>;
21
21
  export type Attachment = z.infer<typeof AttachmentSchema>;
22
+ export declare const RequestAttachmentSchema: z.ZodObject<{
23
+ attachmentId: z.ZodString;
24
+ urlType: z.ZodString;
25
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
29
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
33
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
34
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
38
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
39
+ }, z.core.$strip>;
40
+ export type RequestAttachment = z.infer<typeof RequestAttachmentSchema>;
22
41
  export declare const BaseUserSchema: z.ZodObject<{
23
42
  id: z.ZodNumber;
24
43
  name: z.ZodString;
@@ -34,6 +34,24 @@ export declare const CreateThreadArgsSchema: z.ZodObject<{
34
34
  recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
35
35
  groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
36
36
  tempId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
37
+ attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
38
+ attachmentId: z.ZodString;
39
+ urlType: z.ZodString;
40
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
+ fileName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
+ fileSize: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
44
+ underlyingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
+ imageWidth: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
48
+ imageHeight: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
49
+ duration: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ uploadState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
54
+ }, z.core.$strip>>>>;
37
55
  }, z.core.$strip>;
38
56
  export type CreateThreadArgs = z.infer<typeof CreateThreadArgsSchema>;
39
57
  export declare const UpdateThreadArgsSchema: z.ZodObject<{
@@ -63,7 +81,7 @@ export declare const CreateCommentArgsSchema: z.ZodObject<{
63
81
  video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
64
82
  videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
65
83
  videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
66
- }, z.core.$loose>>>>;
84
+ }, z.core.$strip>>>>;
67
85
  actions: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
68
86
  recipients: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
69
87
  groups: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
@@ -106,7 +124,7 @@ export declare const CreateMessageArgsSchema: z.ZodObject<{
106
124
  video: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
125
  videoType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
108
126
  videoAutoPlay: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
109
- }, z.core.$loose>>>>;
127
+ }, z.core.$strip>>>>;
110
128
  }, z.core.$strip>;
111
129
  export type CreateMessageArgs = z.infer<typeof CreateMessageArgsSchema>;
112
130
  export declare const GetChannelsArgsSchema: z.ZodObject<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/twist-sdk",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "description": "A TypeScript wrapper for the Twist REST API.",
5
5
  "author": "Doist developers",
6
6
  "homepage": "https://doist.github.io/twist-sdk-typescript/",