@doist/twist-sdk 2.7.0 → 2.8.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 (35) hide show
  1. package/dist/cjs/clients/add-comment-helper.js +1 -2
  2. package/dist/cjs/clients/base-client.js +10 -0
  3. package/dist/cjs/clients/channels-client.js +9 -6
  4. package/dist/cjs/clients/comments-client.js +16 -6
  5. package/dist/cjs/clients/conversation-messages-client.js +9 -8
  6. package/dist/cjs/clients/conversations-client.js +11 -8
  7. package/dist/cjs/clients/inbox-client.js +6 -3
  8. package/dist/cjs/clients/threads-client.js +18 -9
  9. package/dist/cjs/clients/workspace-users-client.js +9 -2
  10. package/dist/cjs/clients/workspaces-client.js +7 -3
  11. package/dist/cjs/types/entities.js +99 -79
  12. package/dist/esm/clients/add-comment-helper.js +1 -2
  13. package/dist/esm/clients/base-client.js +10 -0
  14. package/dist/esm/clients/channels-client.js +10 -7
  15. package/dist/esm/clients/comments-client.js +17 -7
  16. package/dist/esm/clients/conversation-messages-client.js +10 -9
  17. package/dist/esm/clients/conversations-client.js +12 -9
  18. package/dist/esm/clients/inbox-client.js +7 -4
  19. package/dist/esm/clients/threads-client.js +19 -10
  20. package/dist/esm/clients/workspace-users-client.js +9 -2
  21. package/dist/esm/clients/workspaces-client.js +8 -4
  22. package/dist/esm/types/entities.js +92 -78
  23. package/dist/types/clients/add-comment-helper.d.ts +3 -1
  24. package/dist/types/clients/base-client.d.ts +4 -0
  25. package/dist/types/clients/channels-client.d.ts +1 -0
  26. package/dist/types/clients/comments-client.d.ts +1 -0
  27. package/dist/types/clients/conversation-messages-client.d.ts +1 -0
  28. package/dist/types/clients/conversations-client.d.ts +1 -0
  29. package/dist/types/clients/inbox-client.d.ts +1 -0
  30. package/dist/types/clients/threads-client.d.ts +2 -0
  31. package/dist/types/clients/workspace-users-client.d.ts +5 -0
  32. package/dist/types/clients/workspaces-client.d.ts +1 -0
  33. package/dist/types/types/entities.d.ts +1539 -185
  34. package/dist/types/types/requests.d.ts +5 -0
  35. package/package.json +6 -2
@@ -11,7 +11,13 @@ 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.WorkspaceUserSchema = exports.CommentSchema = exports.ConversationSchema = exports.GroupSchema = exports.ThreadSchema = exports.ChannelSchema = 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.AttachmentSchema = exports.SystemMessageSchema = void 0;
15
+ exports.createChannelSchema = createChannelSchema;
16
+ exports.createThreadSchema = createThreadSchema;
17
+ exports.createConversationSchema = createConversationSchema;
18
+ exports.createCommentSchema = createCommentSchema;
19
+ exports.createConversationMessageSchema = createConversationMessageSchema;
20
+ exports.createInboxThreadSchema = createInboxThreadSchema;
15
21
  var zod_1 = require("zod");
16
22
  var url_helpers_1 = require("../utils/url-helpers");
17
23
  var enums_1 = require("./enums");
@@ -112,8 +118,7 @@ exports.WorkspaceSchema = zod_1.z.object({
112
118
  plan: zod_1.z.enum(enums_1.WORKSPACE_PLANS).nullable().optional(),
113
119
  });
114
120
  // Channel entity from API
115
- exports.ChannelSchema = zod_1.z
116
- .object({
121
+ exports.ChannelObjectSchema = zod_1.z.object({
117
122
  id: zod_1.z.number(),
118
123
  name: zod_1.z.string(),
119
124
  description: zod_1.z.string().nullable().optional(),
@@ -131,11 +136,13 @@ exports.ChannelSchema = zod_1.z
131
136
  icon: zod_1.z.number().nullable().optional(),
132
137
  version: zod_1.z.number(),
133
138
  filters: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).nullable().optional(),
134
- })
135
- .transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({ workspaceId: data.workspaceId, channelId: data.id }) })); });
139
+ });
140
+ function createChannelSchema(linkBaseUrl) {
141
+ return exports.ChannelObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({ workspaceId: data.workspaceId, channelId: data.id }, linkBaseUrl) })); });
142
+ }
143
+ exports.ChannelSchema = createChannelSchema();
136
144
  // Thread entity from API
137
- exports.ThreadSchema = zod_1.z
138
- .object({
145
+ exports.ThreadObjectSchema = zod_1.z.object({
139
146
  id: zod_1.z.number(),
140
147
  title: zod_1.z.string(),
141
148
  content: zod_1.z.string(),
@@ -198,12 +205,15 @@ exports.ThreadSchema = zod_1.z
198
205
  })
199
206
  .nullable()
200
207
  .optional(),
201
- })
202
- .transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({
203
- workspaceId: data.workspaceId,
204
- channelId: data.channelId,
205
- threadId: data.id,
206
- }) })); });
208
+ });
209
+ function createThreadSchema(linkBaseUrl) {
210
+ return exports.ThreadObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({
211
+ workspaceId: data.workspaceId,
212
+ channelId: data.channelId,
213
+ threadId: data.id,
214
+ }, linkBaseUrl) })); });
215
+ }
216
+ exports.ThreadSchema = createThreadSchema();
207
217
  // Group entity from API
208
218
  exports.GroupSchema = zod_1.z.object({
209
219
  id: zod_1.z.number(),
@@ -214,8 +224,7 @@ exports.GroupSchema = zod_1.z.object({
214
224
  version: zod_1.z.number(),
215
225
  });
216
226
  // Conversation entity from API
217
- exports.ConversationSchema = zod_1.z
218
- .object({
227
+ exports.ConversationObjectSchema = zod_1.z.object({
219
228
  id: zod_1.z.number(),
220
229
  workspaceId: zod_1.z.number(),
221
230
  userIds: zod_1.z.array(zod_1.z.number()),
@@ -251,11 +260,13 @@ exports.ConversationSchema = zod_1.z
251
260
  })
252
261
  .nullable()
253
262
  .optional(),
254
- })
255
- .transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({ workspaceId: data.workspaceId, conversationId: data.id }) })); });
263
+ });
264
+ function createConversationSchema(linkBaseUrl) {
265
+ return exports.ConversationObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({ workspaceId: data.workspaceId, conversationId: data.id }, linkBaseUrl) })); });
266
+ }
267
+ exports.ConversationSchema = createConversationSchema();
256
268
  // Comment entity from API
257
- exports.CommentSchema = zod_1.z
258
- .object({
269
+ exports.CommentObjectSchema = zod_1.z.object({
259
270
  id: zod_1.z.number(),
260
271
  content: zod_1.z.string(),
261
272
  creator: zod_1.z.number(),
@@ -280,13 +291,16 @@ exports.CommentSchema = zod_1.z
280
291
  deletedBy: zod_1.z.number().nullable().optional(),
281
292
  version: zod_1.z.number().nullable().optional(),
282
293
  actions: zod_1.z.array(zod_1.z.unknown()).nullable().optional(),
283
- })
284
- .transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({
285
- workspaceId: data.workspaceId,
286
- channelId: data.channelId,
287
- threadId: data.threadId,
288
- commentId: data.id,
289
- }) })); });
294
+ });
295
+ function createCommentSchema(linkBaseUrl) {
296
+ return exports.CommentObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({
297
+ workspaceId: data.workspaceId,
298
+ channelId: data.channelId,
299
+ threadId: data.threadId,
300
+ commentId: data.id,
301
+ }, linkBaseUrl) })); });
302
+ }
303
+ exports.CommentSchema = createCommentSchema();
290
304
  // WorkspaceUser entity from v4 API
291
305
  exports.WorkspaceUserSchema = exports.BaseUserSchema.extend({
292
306
  email: zod_1.z.string().nullable().optional(),
@@ -298,8 +312,7 @@ exports.WorkspaceUserSchema = exports.BaseUserSchema.extend({
298
312
  version: zod_1.z.number(),
299
313
  });
300
314
  // ConversationMessage entity from API
301
- exports.ConversationMessageSchema = zod_1.z
302
- .object({
315
+ exports.ConversationMessageObjectSchema = zod_1.z.object({
303
316
  id: zod_1.z.number(),
304
317
  content: zod_1.z.string(),
305
318
  creator: zod_1.z.number(),
@@ -316,58 +329,65 @@ exports.ConversationMessageSchema = zod_1.z
316
329
  directMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
317
330
  version: zod_1.z.number().nullable().optional(),
318
331
  workspaceId: zod_1.z.number(),
319
- })
320
- .transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({
321
- workspaceId: data.workspaceId,
322
- conversationId: data.conversationId,
323
- messageId: data.id,
324
- }) })); });
332
+ });
333
+ function createConversationMessageSchema(linkBaseUrl) {
334
+ return exports.ConversationMessageObjectSchema.transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({
335
+ workspaceId: data.workspaceId,
336
+ conversationId: data.conversationId,
337
+ messageId: data.id,
338
+ }, linkBaseUrl) })); });
339
+ }
340
+ exports.ConversationMessageSchema = createConversationMessageSchema();
325
341
  // InboxThread entity from API - returns full Thread objects with additional inbox metadata
326
- exports.InboxThreadSchema = zod_1.z
327
- .object({
328
- id: zod_1.z.number(),
329
- title: zod_1.z.string(),
330
- content: zod_1.z.string(),
331
- creator: zod_1.z.number(),
332
- creatorName: zod_1.z.string().nullable().optional(),
333
- channelId: zod_1.z.number(),
334
- workspaceId: zod_1.z.number(),
335
- actions: zod_1.z.array(zod_1.z.unknown()).nullable().optional(),
336
- attachments: zod_1.z.array(exports.AttachmentSchema).nullable().optional(),
337
- commentCount: zod_1.z.number(),
338
- directGroupMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
339
- directMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
340
- groups: zod_1.z.array(zod_1.z.number()).nullable().optional(),
341
- lastEdited: zod_1.z.date().nullable().optional(),
342
- lastObjIndex: zod_1.z.number().nullable().optional(),
343
- lastUpdated: zod_1.z.date(),
344
- mutedUntil: zod_1.z.date().nullable().optional(),
345
- participants: zod_1.z.array(zod_1.z.number()).nullable().optional(),
346
- pinned: zod_1.z.boolean(),
347
- pinnedDate: zod_1.z.date().nullable().optional(),
348
- posted: zod_1.z.date(),
349
- reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.number())).nullable().optional(),
350
- recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
351
- snippet: zod_1.z.string(),
352
- snippetCreator: zod_1.z.number(),
353
- snippetMaskAvatarUrl: zod_1.z.string().nullable().optional(),
354
- snippetMaskPoster: zod_1.z.string().nullable().optional(),
355
- starred: zod_1.z.boolean(),
356
- systemMessage: exports.SystemMessageSchema,
357
- isArchived: zod_1.z.boolean(),
358
- inInbox: zod_1.z.boolean(),
359
- isSaved: zod_1.z.boolean().nullable().optional(),
360
- closed: zod_1.z.boolean(),
361
- responders: zod_1.z.array(zod_1.z.number()).nullable().optional(),
362
- lastComment: exports.CommentSchema.nullable().optional(),
363
- toEmails: zod_1.z.array(zod_1.z.string()).nullable().optional(),
364
- version: zod_1.z.number().nullable().optional(),
365
- })
366
- .transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({
367
- workspaceId: data.workspaceId,
368
- channelId: data.channelId,
369
- threadId: data.id,
370
- }) })); });
342
+ function createInboxThreadObjectSchema(linkBaseUrl) {
343
+ return zod_1.z.object({
344
+ id: zod_1.z.number(),
345
+ title: zod_1.z.string(),
346
+ content: zod_1.z.string(),
347
+ creator: zod_1.z.number(),
348
+ creatorName: zod_1.z.string().nullable().optional(),
349
+ channelId: zod_1.z.number(),
350
+ workspaceId: zod_1.z.number(),
351
+ actions: zod_1.z.array(zod_1.z.unknown()).nullable().optional(),
352
+ attachments: zod_1.z.array(exports.AttachmentSchema).nullable().optional(),
353
+ commentCount: zod_1.z.number(),
354
+ directGroupMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
355
+ directMentions: zod_1.z.array(zod_1.z.number()).nullable().optional(),
356
+ groups: zod_1.z.array(zod_1.z.number()).nullable().optional(),
357
+ lastEdited: zod_1.z.date().nullable().optional(),
358
+ lastObjIndex: zod_1.z.number().nullable().optional(),
359
+ lastUpdated: zod_1.z.date(),
360
+ mutedUntil: zod_1.z.date().nullable().optional(),
361
+ participants: zod_1.z.array(zod_1.z.number()).nullable().optional(),
362
+ pinned: zod_1.z.boolean(),
363
+ pinnedDate: zod_1.z.date().nullable().optional(),
364
+ posted: zod_1.z.date(),
365
+ reactions: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.number())).nullable().optional(),
366
+ recipients: zod_1.z.array(zod_1.z.number()).nullable().optional(),
367
+ snippet: zod_1.z.string(),
368
+ snippetCreator: zod_1.z.number(),
369
+ snippetMaskAvatarUrl: zod_1.z.string().nullable().optional(),
370
+ snippetMaskPoster: zod_1.z.string().nullable().optional(),
371
+ starred: zod_1.z.boolean(),
372
+ systemMessage: exports.SystemMessageSchema,
373
+ isArchived: zod_1.z.boolean(),
374
+ inInbox: zod_1.z.boolean(),
375
+ isSaved: zod_1.z.boolean().nullable().optional(),
376
+ closed: zod_1.z.boolean(),
377
+ responders: zod_1.z.array(zod_1.z.number()).nullable().optional(),
378
+ lastComment: createCommentSchema(linkBaseUrl).nullable().optional(),
379
+ toEmails: zod_1.z.array(zod_1.z.string()).nullable().optional(),
380
+ version: zod_1.z.number().nullable().optional(),
381
+ });
382
+ }
383
+ function createInboxThreadSchema(linkBaseUrl) {
384
+ return createInboxThreadObjectSchema(linkBaseUrl).transform(function (data) { return (__assign(__assign({}, data), { url: (0, url_helpers_1.getFullTwistURL)({
385
+ workspaceId: data.workspaceId,
386
+ channelId: data.channelId,
387
+ threadId: data.id,
388
+ }, linkBaseUrl) })); });
389
+ }
390
+ exports.InboxThreadSchema = createInboxThreadSchema();
371
391
  // UnreadThread entity from API - simplified thread reference for unread threads
372
392
  exports.UnreadThreadSchema = zod_1.z.object({
373
393
  threadId: zod_1.z.number(),
@@ -31,7 +31,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
31
31
  };
32
32
  import { ENDPOINT_COMMENTS } from '../consts/endpoints.js';
33
33
  import { request } from '../transport/http-client.js';
34
- import { CommentSchema } from '../types/entities.js';
35
34
  import { NOTIFY_AUDIENCE_GROUP_IDS, NOTIFY_AUDIENCES } from '../types/enums.js';
36
35
  var SENTINEL_GROUP_IDS = new Set(Object.values(NOTIFY_AUDIENCE_GROUP_IDS));
37
36
  function isNotifyAudience(value) {
@@ -59,7 +58,7 @@ export function addCommentRequest(context, params, options) {
59
58
  var normalized = applyNotifyAudience(params);
60
59
  var payload = (options === null || options === void 0 ? void 0 : options.threadAction)
61
60
  ? __assign(__assign({}, normalized), { threadAction: options.threadAction }) : normalized;
62
- var schema = CommentSchema;
61
+ var schema = context.schema;
63
62
  if (options === null || options === void 0 ? void 0 : options.batch) {
64
63
  return { method: method, url: url, params: payload, schema: schema };
65
64
  }
@@ -28,6 +28,16 @@ var BaseClient = /** @class */ (function () {
28
28
  // Use centralized helper function for default Twist API URL
29
29
  return getTwistBaseUri(apiVersion);
30
30
  };
31
+ /**
32
+ * Base URL for entity web links, or `undefined` to use getFullTwistURL's default web app.
33
+ */
34
+ BaseClient.prototype.getLinkBaseUrl = function () {
35
+ if (!this.baseUrl) {
36
+ return undefined;
37
+ }
38
+ // Strip a trailing slash so links don't double up, since entity paths start with '/'.
39
+ return this.baseUrl.endsWith('/') ? this.baseUrl.slice(0, -1) : this.baseUrl;
40
+ };
31
41
  return BaseClient;
32
42
  }());
33
43
  export { BaseClient };
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
16
16
  import { z } from 'zod';
17
17
  import { ENDPOINT_CHANNELS } from '../consts/endpoints.js';
18
18
  import { request } from '../transport/http-client.js';
19
- import { ChannelSchema } from '../types/entities.js';
19
+ import { createChannelSchema } from '../types/entities.js';
20
20
  import { BaseClient } from './base-client.js';
21
21
  /**
22
22
  * Client for interacting with Twist channel endpoints.
@@ -24,14 +24,17 @@ import { BaseClient } from './base-client.js';
24
24
  var ChannelsClient = /** @class */ (function (_super) {
25
25
  __extends(ChannelsClient, _super);
26
26
  function ChannelsClient() {
27
- return _super !== null && _super.apply(this, arguments) || this;
27
+ var _this = _super !== null && _super.apply(this, arguments) || this;
28
+ _this.channelSchema = createChannelSchema(_this.getLinkBaseUrl());
29
+ return _this;
28
30
  }
29
31
  ChannelsClient.prototype.getChannels = function (args, options) {
32
+ var _this = this;
30
33
  var method = 'GET';
31
34
  var url = "".concat(ENDPOINT_CHANNELS, "/get");
32
35
  var params = args;
33
36
  if (options === null || options === void 0 ? void 0 : options.batch) {
34
- return { method: method, url: url, params: params, schema: z.array(ChannelSchema) };
37
+ return { method: method, url: url, params: params, schema: z.array(this.channelSchema) };
35
38
  }
36
39
  return request({
37
40
  httpMethod: method,
@@ -40,13 +43,13 @@ var ChannelsClient = /** @class */ (function (_super) {
40
43
  apiToken: this.apiToken,
41
44
  payload: params,
42
45
  customFetch: this.customFetch,
43
- }).then(function (response) { return response.data.map(function (channel) { return ChannelSchema.parse(channel); }); });
46
+ }).then(function (response) { return response.data.map(function (channel) { return _this.channelSchema.parse(channel); }); });
44
47
  };
45
48
  ChannelsClient.prototype.getChannel = function (id, options) {
46
49
  var method = 'GET';
47
50
  var url = "".concat(ENDPOINT_CHANNELS, "/getone");
48
51
  var params = { id: id };
49
- var schema = ChannelSchema;
52
+ var schema = this.channelSchema;
50
53
  if (options === null || options === void 0 ? void 0 : options.batch) {
51
54
  return { method: method, url: url, params: params, schema: schema };
52
55
  }
@@ -63,7 +66,7 @@ var ChannelsClient = /** @class */ (function (_super) {
63
66
  var method = 'POST';
64
67
  var url = "".concat(ENDPOINT_CHANNELS, "/add");
65
68
  var params = args;
66
- var schema = ChannelSchema;
69
+ var schema = this.channelSchema;
67
70
  if (options === null || options === void 0 ? void 0 : options.batch) {
68
71
  return { method: method, url: url, params: params, schema: schema };
69
72
  }
@@ -80,7 +83,7 @@ var ChannelsClient = /** @class */ (function (_super) {
80
83
  var method = 'POST';
81
84
  var url = "".concat(ENDPOINT_CHANNELS, "/update");
82
85
  var params = args;
83
- var schema = ChannelSchema;
86
+ var schema = this.channelSchema;
84
87
  if (options === null || options === void 0 ? void 0 : options.batch) {
85
88
  return { method: method, url: url, params: params, schema: schema };
86
89
  }
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
16
16
  import { z } from 'zod';
17
17
  import { ENDPOINT_COMMENTS } from '../consts/endpoints.js';
18
18
  import { request } from '../transport/http-client.js';
19
- import { CommentSchema } from '../types/entities.js';
19
+ import { createCommentSchema } from '../types/entities.js';
20
20
  import { addCommentRequest } from './add-comment-helper.js';
21
21
  import { BaseClient } from './base-client.js';
22
22
  /**
@@ -25,9 +25,12 @@ import { BaseClient } from './base-client.js';
25
25
  var CommentsClient = /** @class */ (function (_super) {
26
26
  __extends(CommentsClient, _super);
27
27
  function CommentsClient() {
28
- return _super !== null && _super.apply(this, arguments) || this;
28
+ var _this = _super !== null && _super.apply(this, arguments) || this;
29
+ _this.commentSchema = createCommentSchema(_this.getLinkBaseUrl());
30
+ return _this;
29
31
  }
30
32
  CommentsClient.prototype.getComments = function (args, options) {
33
+ var _this = this;
31
34
  var _a;
32
35
  var params = {
33
36
  thread_id: args.threadId,
@@ -42,7 +45,7 @@ var CommentsClient = /** @class */ (function (_super) {
42
45
  var method = 'GET';
43
46
  var url = "".concat(ENDPOINT_COMMENTS, "/get");
44
47
  if (options === null || options === void 0 ? void 0 : options.batch) {
45
- return { method: method, url: url, params: params, schema: z.array(CommentSchema) };
48
+ return { method: method, url: url, params: params, schema: z.array(this.commentSchema) };
46
49
  }
47
50
  return request({
48
51
  httpMethod: method,
@@ -51,14 +54,16 @@ var CommentsClient = /** @class */ (function (_super) {
51
54
  apiToken: this.apiToken,
52
55
  payload: params,
53
56
  customFetch: this.customFetch,
54
- }).then(function (response) { return response.data.map(function (comment) { return CommentSchema.parse(comment); }); });
57
+ }).then(function (response) { return response.data.map(function (comment) { return _this.commentSchema.parse(comment); }); });
55
58
  };
56
59
  CommentsClient.prototype.getComment = function (id, options) {
57
60
  var method = 'GET';
58
61
  var url = "".concat(ENDPOINT_COMMENTS, "/getone");
59
62
  var params = { id: id };
60
63
  // The API wraps the response in {"comment": {...}}, so we need to unwrap it
61
- var wrappedSchema = z.object({ comment: CommentSchema }).transform(function (data) { return data.comment; });
64
+ var wrappedSchema = z
65
+ .object({ comment: this.commentSchema })
66
+ .transform(function (data) { return data.comment; });
62
67
  if (options === null || options === void 0 ? void 0 : options.batch) {
63
68
  return { method: method, url: url, params: params, schema: wrappedSchema };
64
69
  }
@@ -72,13 +77,18 @@ var CommentsClient = /** @class */ (function (_super) {
72
77
  }).then(function (response) { return wrappedSchema.parse(response.data); });
73
78
  };
74
79
  CommentsClient.prototype.createComment = function (args, options) {
75
- return addCommentRequest({ baseUri: this.getBaseUri(), apiToken: this.apiToken, customFetch: this.customFetch }, args, options);
80
+ return addCommentRequest({
81
+ baseUri: this.getBaseUri(),
82
+ apiToken: this.apiToken,
83
+ customFetch: this.customFetch,
84
+ schema: this.commentSchema,
85
+ }, args, options);
76
86
  };
77
87
  CommentsClient.prototype.updateComment = function (args, options) {
78
88
  var method = 'POST';
79
89
  var url = "".concat(ENDPOINT_COMMENTS, "/update");
80
90
  var params = args;
81
- var schema = CommentSchema;
91
+ var schema = this.commentSchema;
82
92
  if (options === null || options === void 0 ? void 0 : options.batch) {
83
93
  return { method: method, url: url, params: params, schema: schema };
84
94
  }
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
16
16
  import { z } from 'zod';
17
17
  import { ENDPOINT_CONVERSATION_MESSAGES } from '../consts/endpoints.js';
18
18
  import { request } from '../transport/http-client.js';
19
- import { ConversationMessageSchema } from '../types/entities.js';
19
+ import { createConversationMessageSchema } from '../types/entities.js';
20
20
  import { BaseClient } from './base-client.js';
21
21
  /**
22
22
  * Client for interacting with Twist conversation message endpoints.
@@ -24,9 +24,12 @@ import { BaseClient } from './base-client.js';
24
24
  var ConversationMessagesClient = /** @class */ (function (_super) {
25
25
  __extends(ConversationMessagesClient, _super);
26
26
  function ConversationMessagesClient() {
27
- return _super !== null && _super.apply(this, arguments) || this;
27
+ var _this = _super !== null && _super.apply(this, arguments) || this;
28
+ _this.messageSchema = createConversationMessageSchema(_this.getLinkBaseUrl());
29
+ return _this;
28
30
  }
29
31
  ConversationMessagesClient.prototype.getMessages = function (args, options) {
32
+ var _this = this;
30
33
  var params = {
31
34
  conversation_id: args.conversationId,
32
35
  };
@@ -41,7 +44,7 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
41
44
  var method = 'GET';
42
45
  var url = "".concat(ENDPOINT_CONVERSATION_MESSAGES, "/get");
43
46
  if (options === null || options === void 0 ? void 0 : options.batch) {
44
- return { method: method, url: url, params: params, schema: z.array(ConversationMessageSchema) };
47
+ return { method: method, url: url, params: params, schema: z.array(this.messageSchema) };
45
48
  }
46
49
  return request({
47
50
  httpMethod: method,
@@ -50,15 +53,13 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
50
53
  apiToken: this.apiToken,
51
54
  payload: params,
52
55
  customFetch: this.customFetch,
53
- }).then(function (response) {
54
- return response.data.map(function (message) { return ConversationMessageSchema.parse(message); });
55
- });
56
+ }).then(function (response) { return response.data.map(function (message) { return _this.messageSchema.parse(message); }); });
56
57
  };
57
58
  ConversationMessagesClient.prototype.getMessage = function (id, options) {
58
59
  var method = 'GET';
59
60
  var url = "".concat(ENDPOINT_CONVERSATION_MESSAGES, "/getone");
60
61
  var params = { id: id };
61
- var schema = ConversationMessageSchema;
62
+ var schema = this.messageSchema;
62
63
  if (options === null || options === void 0 ? void 0 : options.batch) {
63
64
  return { method: method, url: url, params: params, schema: schema };
64
65
  }
@@ -82,7 +83,7 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
82
83
  params.actions = args.actions;
83
84
  var method = 'POST';
84
85
  var url = "".concat(ENDPOINT_CONVERSATION_MESSAGES, "/add");
85
- var schema = ConversationMessageSchema;
86
+ var schema = this.messageSchema;
86
87
  if (options === null || options === void 0 ? void 0 : options.batch) {
87
88
  return { method: method, url: url, params: params, schema: schema };
88
89
  }
@@ -104,7 +105,7 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
104
105
  params.attachments = args.attachments;
105
106
  var method = 'POST';
106
107
  var url = "".concat(ENDPOINT_CONVERSATION_MESSAGES, "/update");
107
- var schema = ConversationMessageSchema;
108
+ var schema = this.messageSchema;
108
109
  if (options === null || options === void 0 ? void 0 : options.batch) {
109
110
  return { method: method, url: url, params: params, schema: schema };
110
111
  }
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
16
16
  import { z } from 'zod';
17
17
  import { ENDPOINT_CONVERSATIONS } from '../consts/endpoints.js';
18
18
  import { request } from '../transport/http-client.js';
19
- import { ConversationSchema, UnreadConversationSchema, } from '../types/entities.js';
19
+ import { createConversationSchema, UnreadConversationSchema, } from '../types/entities.js';
20
20
  import { BaseClient } from './base-client.js';
21
21
  /**
22
22
  * Client for interacting with Twist conversation endpoints.
@@ -24,14 +24,17 @@ import { BaseClient } from './base-client.js';
24
24
  var ConversationsClient = /** @class */ (function (_super) {
25
25
  __extends(ConversationsClient, _super);
26
26
  function ConversationsClient() {
27
- return _super !== null && _super.apply(this, arguments) || this;
27
+ var _this = _super !== null && _super.apply(this, arguments) || this;
28
+ _this.conversationSchema = createConversationSchema(_this.getLinkBaseUrl());
29
+ return _this;
28
30
  }
29
31
  ConversationsClient.prototype.getConversations = function (args, options) {
32
+ var _this = this;
30
33
  var method = 'GET';
31
34
  var url = "".concat(ENDPOINT_CONVERSATIONS, "/get");
32
35
  var params = args;
33
36
  if (options === null || options === void 0 ? void 0 : options.batch) {
34
- return { method: method, url: url, params: params, schema: z.array(ConversationSchema) };
37
+ return { method: method, url: url, params: params, schema: z.array(this.conversationSchema) };
35
38
  }
36
39
  return request({
37
40
  httpMethod: method,
@@ -41,14 +44,14 @@ var ConversationsClient = /** @class */ (function (_super) {
41
44
  payload: params,
42
45
  customFetch: this.customFetch,
43
46
  }).then(function (response) {
44
- return response.data.map(function (conversation) { return ConversationSchema.parse(conversation); });
47
+ return response.data.map(function (conversation) { return _this.conversationSchema.parse(conversation); });
45
48
  });
46
49
  };
47
50
  ConversationsClient.prototype.getConversation = function (id, options) {
48
51
  var method = 'GET';
49
52
  var url = "".concat(ENDPOINT_CONVERSATIONS, "/getone");
50
53
  var params = { id: id };
51
- var schema = ConversationSchema;
54
+ var schema = this.conversationSchema;
52
55
  if (options === null || options === void 0 ? void 0 : options.batch) {
53
56
  return { method: method, url: url, params: params, schema: schema };
54
57
  }
@@ -65,7 +68,7 @@ var ConversationsClient = /** @class */ (function (_super) {
65
68
  var method = 'POST';
66
69
  var url = "".concat(ENDPOINT_CONVERSATIONS, "/get_or_create");
67
70
  var params = args;
68
- var schema = ConversationSchema;
71
+ var schema = this.conversationSchema;
69
72
  if (options === null || options === void 0 ? void 0 : options.batch) {
70
73
  return { method: method, url: url, params: params, schema: schema };
71
74
  }
@@ -84,7 +87,7 @@ var ConversationsClient = /** @class */ (function (_super) {
84
87
  params.archived = args.archived;
85
88
  var method = 'POST';
86
89
  var url = "".concat(ENDPOINT_CONVERSATIONS, "/update");
87
- var schema = ConversationSchema;
90
+ var schema = this.conversationSchema;
88
91
  if (options === null || options === void 0 ? void 0 : options.batch) {
89
92
  return { method: method, url: url, params: params, schema: schema };
90
93
  }
@@ -255,7 +258,7 @@ var ConversationsClient = /** @class */ (function (_super) {
255
258
  var method = 'POST';
256
259
  var url = "".concat(ENDPOINT_CONVERSATIONS, "/mute");
257
260
  var params = { id: args.id, minutes: args.minutes };
258
- var schema = ConversationSchema;
261
+ var schema = this.conversationSchema;
259
262
  if (options === null || options === void 0 ? void 0 : options.batch) {
260
263
  return { method: method, url: url, params: params, schema: schema };
261
264
  }
@@ -272,7 +275,7 @@ var ConversationsClient = /** @class */ (function (_super) {
272
275
  var method = 'POST';
273
276
  var url = "".concat(ENDPOINT_CONVERSATIONS, "/unmute");
274
277
  var params = { id: id };
275
- var schema = ConversationSchema;
278
+ var schema = this.conversationSchema;
276
279
  if (options === null || options === void 0 ? void 0 : options.batch) {
277
280
  return { method: method, url: url, params: params, schema: schema };
278
281
  }
@@ -16,7 +16,7 @@ var __extends = (this && this.__extends) || (function () {
16
16
  import { z } from 'zod';
17
17
  import { ENDPOINT_INBOX } from '../consts/endpoints.js';
18
18
  import { request } from '../transport/http-client.js';
19
- import { InboxThreadSchema } from '../types/entities.js';
19
+ import { createInboxThreadSchema } from '../types/entities.js';
20
20
  import { BaseClient } from './base-client.js';
21
21
  /**
22
22
  * Client for interacting with Twist inbox endpoints.
@@ -24,9 +24,12 @@ import { BaseClient } from './base-client.js';
24
24
  var InboxClient = /** @class */ (function (_super) {
25
25
  __extends(InboxClient, _super);
26
26
  function InboxClient() {
27
- return _super !== null && _super.apply(this, arguments) || this;
27
+ var _this = _super !== null && _super.apply(this, arguments) || this;
28
+ _this.inboxThreadSchema = createInboxThreadSchema(_this.getLinkBaseUrl());
29
+ return _this;
28
30
  }
29
31
  InboxClient.prototype.getInbox = function (args, options) {
32
+ var _this = this;
30
33
  var _a, _b;
31
34
  var params = {
32
35
  workspace_id: args.workspaceId,
@@ -46,7 +49,7 @@ var InboxClient = /** @class */ (function (_super) {
46
49
  var method = 'GET';
47
50
  var url = "".concat(ENDPOINT_INBOX, "/get");
48
51
  if (options === null || options === void 0 ? void 0 : options.batch) {
49
- return { method: method, url: url, params: params, schema: z.array(InboxThreadSchema) };
52
+ return { method: method, url: url, params: params, schema: z.array(this.inboxThreadSchema) };
50
53
  }
51
54
  return request({
52
55
  httpMethod: method,
@@ -55,7 +58,7 @@ var InboxClient = /** @class */ (function (_super) {
55
58
  apiToken: this.apiToken,
56
59
  payload: params,
57
60
  customFetch: this.customFetch,
58
- }).then(function (response) { return response.data.map(function (thread) { return InboxThreadSchema.parse(thread); }); });
61
+ }).then(function (response) { return response.data.map(function (thread) { return _this.inboxThreadSchema.parse(thread); }); });
59
62
  };
60
63
  InboxClient.prototype.getCount = function (workspaceId, options) {
61
64
  var method = 'GET';