@doist/twist-sdk 2.0.0 → 2.0.2
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/channels-client.js +2 -1
- package/dist/cjs/clients/comments-client.js +2 -1
- package/dist/cjs/clients/conversation-messages-client.js +2 -1
- package/dist/cjs/clients/conversations-client.js +2 -1
- package/dist/cjs/clients/inbox-client.js +2 -1
- package/dist/cjs/clients/threads-client.js +2 -1
- package/dist/cjs/types/entities.js +2 -2
- package/dist/cjs/utils/timestamp-conversion.js +4 -1
- package/dist/esm/clients/channels-client.js +2 -1
- package/dist/esm/clients/comments-client.js +2 -1
- package/dist/esm/clients/conversation-messages-client.js +2 -1
- package/dist/esm/clients/conversations-client.js +2 -1
- package/dist/esm/clients/inbox-client.js +2 -1
- package/dist/esm/clients/threads-client.js +2 -1
- package/dist/esm/types/entities.js +2 -2
- package/dist/esm/utils/timestamp-conversion.js +4 -1
- package/dist/types/types/entities.d.ts +6 -6
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.ChannelsClient = void 0;
|
|
19
|
+
var zod_1 = require("zod");
|
|
19
20
|
var endpoints_1 = require("../consts/endpoints");
|
|
20
21
|
var rest_client_1 = require("../rest-client");
|
|
21
22
|
var entities_1 = require("../types/entities");
|
|
@@ -33,7 +34,7 @@ var ChannelsClient = /** @class */ (function (_super) {
|
|
|
33
34
|
var url = "".concat(endpoints_1.ENDPOINT_CHANNELS, "/get");
|
|
34
35
|
var params = args;
|
|
35
36
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
36
|
-
return { method: method, url: url, params: params };
|
|
37
|
+
return { method: method, url: url, params: params, schema: zod_1.z.array(entities_1.ChannelSchema) };
|
|
37
38
|
}
|
|
38
39
|
return (0, rest_client_1.request)({
|
|
39
40
|
httpMethod: method,
|
|
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.CommentsClient = void 0;
|
|
19
|
+
var zod_1 = require("zod");
|
|
19
20
|
var endpoints_1 = require("../consts/endpoints");
|
|
20
21
|
var rest_client_1 = require("../rest-client");
|
|
21
22
|
var entities_1 = require("../types/entities");
|
|
@@ -39,7 +40,7 @@ var CommentsClient = /** @class */ (function (_super) {
|
|
|
39
40
|
var method = 'GET';
|
|
40
41
|
var url = "".concat(endpoints_1.ENDPOINT_COMMENTS, "/get");
|
|
41
42
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
42
|
-
return { method: method, url: url, params: params };
|
|
43
|
+
return { method: method, url: url, params: params, schema: zod_1.z.array(entities_1.CommentSchema) };
|
|
43
44
|
}
|
|
44
45
|
return (0, rest_client_1.request)({
|
|
45
46
|
httpMethod: method,
|
|
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.ConversationMessagesClient = void 0;
|
|
19
|
+
var zod_1 = require("zod");
|
|
19
20
|
var endpoints_1 = require("../consts/endpoints");
|
|
20
21
|
var rest_client_1 = require("../rest-client");
|
|
21
22
|
var entities_1 = require("../types/entities");
|
|
@@ -43,7 +44,7 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
|
|
|
43
44
|
var method = 'GET';
|
|
44
45
|
var url = "".concat(endpoints_1.ENDPOINT_CONVERSATION_MESSAGES, "/get");
|
|
45
46
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
46
|
-
return { method: method, url: url, params: params };
|
|
47
|
+
return { method: method, url: url, params: params, schema: zod_1.z.array(entities_1.ConversationMessageSchema) };
|
|
47
48
|
}
|
|
48
49
|
return (0, rest_client_1.request)({
|
|
49
50
|
httpMethod: method,
|
|
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.ConversationsClient = void 0;
|
|
19
|
+
var zod_1 = require("zod");
|
|
19
20
|
var endpoints_1 = require("../consts/endpoints");
|
|
20
21
|
var rest_client_1 = require("../rest-client");
|
|
21
22
|
var entities_1 = require("../types/entities");
|
|
@@ -33,7 +34,7 @@ var ConversationsClient = /** @class */ (function (_super) {
|
|
|
33
34
|
var url = "".concat(endpoints_1.ENDPOINT_CONVERSATIONS, "/get");
|
|
34
35
|
var params = args;
|
|
35
36
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
36
|
-
return { method: method, url: url, params: params };
|
|
37
|
+
return { method: method, url: url, params: params, schema: zod_1.z.array(entities_1.ConversationSchema) };
|
|
37
38
|
}
|
|
38
39
|
return (0, rest_client_1.request)({
|
|
39
40
|
httpMethod: method,
|
|
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.InboxClient = void 0;
|
|
19
|
+
var zod_1 = require("zod");
|
|
19
20
|
var endpoints_1 = require("../consts/endpoints");
|
|
20
21
|
var rest_client_1 = require("../rest-client");
|
|
21
22
|
var entities_1 = require("../types/entities");
|
|
@@ -43,7 +44,7 @@ var InboxClient = /** @class */ (function (_super) {
|
|
|
43
44
|
var method = 'GET';
|
|
44
45
|
var url = "".concat(endpoints_1.ENDPOINT_INBOX, "/get");
|
|
45
46
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
46
|
-
return { method: method, url: url, params: params };
|
|
47
|
+
return { method: method, url: url, params: params, schema: zod_1.z.array(entities_1.InboxThreadSchema) };
|
|
47
48
|
}
|
|
48
49
|
return (0, rest_client_1.request)({
|
|
49
50
|
httpMethod: method,
|
|
@@ -16,6 +16,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.ThreadsClient = void 0;
|
|
19
|
+
var zod_1 = require("zod");
|
|
19
20
|
var endpoints_1 = require("../consts/endpoints");
|
|
20
21
|
var rest_client_1 = require("../rest-client");
|
|
21
22
|
var entities_1 = require("../types/entities");
|
|
@@ -33,7 +34,7 @@ var ThreadsClient = /** @class */ (function (_super) {
|
|
|
33
34
|
var url = "".concat(endpoints_1.ENDPOINT_THREADS, "/get");
|
|
34
35
|
var params = args;
|
|
35
36
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
36
|
-
return { method: method, url: url, params: params };
|
|
37
|
+
return { method: method, url: url, params: params, schema: zod_1.z.array(entities_1.ThreadSchema) };
|
|
37
38
|
}
|
|
38
39
|
return (0, rest_client_1.request)({
|
|
39
40
|
httpMethod: method,
|
|
@@ -138,7 +138,7 @@ exports.ThreadSchema = zod_1.z
|
|
|
138
138
|
snippet: zod_1.z.string(),
|
|
139
139
|
snippetCreator: zod_1.z.number(),
|
|
140
140
|
snippetMaskAvatarUrl: zod_1.z.string().nullable().optional(),
|
|
141
|
-
snippetMaskPoster: zod_1.z.
|
|
141
|
+
snippetMaskPoster: zod_1.z.string().nullable().optional(),
|
|
142
142
|
starred: zod_1.z.boolean(),
|
|
143
143
|
systemMessage: exports.SystemMessageSchema,
|
|
144
144
|
toEmails: zod_1.z.array(zod_1.z.string()).nullable().optional(),
|
|
@@ -325,7 +325,7 @@ exports.InboxThreadSchema = zod_1.z
|
|
|
325
325
|
snippet: zod_1.z.string(),
|
|
326
326
|
snippetCreator: zod_1.z.number(),
|
|
327
327
|
snippetMaskAvatarUrl: zod_1.z.string().nullable().optional(),
|
|
328
|
-
snippetMaskPoster: zod_1.z.
|
|
328
|
+
snippetMaskPoster: zod_1.z.string().nullable().optional(),
|
|
329
329
|
starred: zod_1.z.boolean(),
|
|
330
330
|
systemMessage: exports.SystemMessageSchema,
|
|
331
331
|
isArchived: zod_1.z.boolean(),
|
|
@@ -31,7 +31,10 @@ function transformTimestamps(obj) {
|
|
|
31
31
|
if (key.endsWith('Ts') && typeof value === 'number') {
|
|
32
32
|
// Remove 'Ts' suffix and convert to Date
|
|
33
33
|
var newKey = key.slice(0, -2);
|
|
34
|
-
|
|
34
|
+
// If the base key already exists in the original object, use *Date suffix
|
|
35
|
+
// to avoid overwriting it (e.g. pinned + pinnedTs → pinned + pinnedDate)
|
|
36
|
+
var targetKey = newKey in obj ? "".concat(newKey, "Date") : newKey;
|
|
37
|
+
result[targetKey] = timestampToDate(value);
|
|
35
38
|
}
|
|
36
39
|
else if (typeof value === 'object' && value !== null) {
|
|
37
40
|
// Recursively transform nested objects
|
|
@@ -13,6 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
import { z } from 'zod';
|
|
16
17
|
import { ENDPOINT_CHANNELS } from '../consts/endpoints.js';
|
|
17
18
|
import { request } from '../rest-client.js';
|
|
18
19
|
import { ChannelSchema } from '../types/entities.js';
|
|
@@ -30,7 +31,7 @@ var ChannelsClient = /** @class */ (function (_super) {
|
|
|
30
31
|
var url = "".concat(ENDPOINT_CHANNELS, "/get");
|
|
31
32
|
var params = args;
|
|
32
33
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
33
|
-
return { method: method, url: url, params: params };
|
|
34
|
+
return { method: method, url: url, params: params, schema: z.array(ChannelSchema) };
|
|
34
35
|
}
|
|
35
36
|
return request({
|
|
36
37
|
httpMethod: method,
|
|
@@ -13,6 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
import { z } from 'zod';
|
|
16
17
|
import { ENDPOINT_COMMENTS } from '../consts/endpoints.js';
|
|
17
18
|
import { request } from '../rest-client.js';
|
|
18
19
|
import { CommentSchema } from '../types/entities.js';
|
|
@@ -36,7 +37,7 @@ var CommentsClient = /** @class */ (function (_super) {
|
|
|
36
37
|
var method = 'GET';
|
|
37
38
|
var url = "".concat(ENDPOINT_COMMENTS, "/get");
|
|
38
39
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
39
|
-
return { method: method, url: url, params: params };
|
|
40
|
+
return { method: method, url: url, params: params, schema: z.array(CommentSchema) };
|
|
40
41
|
}
|
|
41
42
|
return request({
|
|
42
43
|
httpMethod: method,
|
|
@@ -13,6 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
import { z } from 'zod';
|
|
16
17
|
import { ENDPOINT_CONVERSATION_MESSAGES } from '../consts/endpoints.js';
|
|
17
18
|
import { request } from '../rest-client.js';
|
|
18
19
|
import { ConversationMessageSchema } from '../types/entities.js';
|
|
@@ -40,7 +41,7 @@ var ConversationMessagesClient = /** @class */ (function (_super) {
|
|
|
40
41
|
var method = 'GET';
|
|
41
42
|
var url = "".concat(ENDPOINT_CONVERSATION_MESSAGES, "/get");
|
|
42
43
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
43
|
-
return { method: method, url: url, params: params };
|
|
44
|
+
return { method: method, url: url, params: params, schema: z.array(ConversationMessageSchema) };
|
|
44
45
|
}
|
|
45
46
|
return request({
|
|
46
47
|
httpMethod: method,
|
|
@@ -13,6 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
import { z } from 'zod';
|
|
16
17
|
import { ENDPOINT_CONVERSATIONS } from '../consts/endpoints.js';
|
|
17
18
|
import { request } from '../rest-client.js';
|
|
18
19
|
import { ConversationSchema, UnreadConversationSchema, } from '../types/entities.js';
|
|
@@ -30,7 +31,7 @@ var ConversationsClient = /** @class */ (function (_super) {
|
|
|
30
31
|
var url = "".concat(ENDPOINT_CONVERSATIONS, "/get");
|
|
31
32
|
var params = args;
|
|
32
33
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
33
|
-
return { method: method, url: url, params: params };
|
|
34
|
+
return { method: method, url: url, params: params, schema: z.array(ConversationSchema) };
|
|
34
35
|
}
|
|
35
36
|
return request({
|
|
36
37
|
httpMethod: method,
|
|
@@ -13,6 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
import { z } from 'zod';
|
|
16
17
|
import { ENDPOINT_INBOX } from '../consts/endpoints.js';
|
|
17
18
|
import { request } from '../rest-client.js';
|
|
18
19
|
import { InboxThreadSchema } from '../types/entities.js';
|
|
@@ -40,7 +41,7 @@ var InboxClient = /** @class */ (function (_super) {
|
|
|
40
41
|
var method = 'GET';
|
|
41
42
|
var url = "".concat(ENDPOINT_INBOX, "/get");
|
|
42
43
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
43
|
-
return { method: method, url: url, params: params };
|
|
44
|
+
return { method: method, url: url, params: params, schema: z.array(InboxThreadSchema) };
|
|
44
45
|
}
|
|
45
46
|
return request({
|
|
46
47
|
httpMethod: method,
|
|
@@ -13,6 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
13
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
14
|
};
|
|
15
15
|
})();
|
|
16
|
+
import { z } from 'zod';
|
|
16
17
|
import { ENDPOINT_THREADS } from '../consts/endpoints.js';
|
|
17
18
|
import { request } from '../rest-client.js';
|
|
18
19
|
import { ThreadSchema, UnreadThreadSchema } from '../types/entities.js';
|
|
@@ -30,7 +31,7 @@ var ThreadsClient = /** @class */ (function (_super) {
|
|
|
30
31
|
var url = "".concat(ENDPOINT_THREADS, "/get");
|
|
31
32
|
var params = args;
|
|
32
33
|
if (options === null || options === void 0 ? void 0 : options.batch) {
|
|
33
|
-
return { method: method, url: url, params: params };
|
|
34
|
+
return { method: method, url: url, params: params, schema: z.array(ThreadSchema) };
|
|
34
35
|
}
|
|
35
36
|
return request({
|
|
36
37
|
httpMethod: method,
|
|
@@ -135,7 +135,7 @@ export var ThreadSchema = z
|
|
|
135
135
|
snippet: z.string(),
|
|
136
136
|
snippetCreator: z.number(),
|
|
137
137
|
snippetMaskAvatarUrl: z.string().nullable().optional(),
|
|
138
|
-
snippetMaskPoster: z.
|
|
138
|
+
snippetMaskPoster: z.string().nullable().optional(),
|
|
139
139
|
starred: z.boolean(),
|
|
140
140
|
systemMessage: SystemMessageSchema,
|
|
141
141
|
toEmails: z.array(z.string()).nullable().optional(),
|
|
@@ -322,7 +322,7 @@ export var InboxThreadSchema = z
|
|
|
322
322
|
snippet: z.string(),
|
|
323
323
|
snippetCreator: z.number(),
|
|
324
324
|
snippetMaskAvatarUrl: z.string().nullable().optional(),
|
|
325
|
-
snippetMaskPoster: z.
|
|
325
|
+
snippetMaskPoster: z.string().nullable().optional(),
|
|
326
326
|
starred: z.boolean(),
|
|
327
327
|
systemMessage: SystemMessageSchema,
|
|
328
328
|
isArchived: z.boolean(),
|
|
@@ -27,7 +27,10 @@ export function transformTimestamps(obj) {
|
|
|
27
27
|
if (key.endsWith('Ts') && typeof value === 'number') {
|
|
28
28
|
// Remove 'Ts' suffix and convert to Date
|
|
29
29
|
var newKey = key.slice(0, -2);
|
|
30
|
-
|
|
30
|
+
// If the base key already exists in the original object, use *Date suffix
|
|
31
|
+
// to avoid overwriting it (e.g. pinned + pinnedTs → pinned + pinnedDate)
|
|
32
|
+
var targetKey = newKey in obj ? "".concat(newKey, "Date") : newKey;
|
|
33
|
+
result[targetKey] = timestampToDate(value);
|
|
31
34
|
}
|
|
32
35
|
else if (typeof value === 'object' && value !== null) {
|
|
33
36
|
// Recursively transform nested objects
|
|
@@ -145,7 +145,7 @@ export declare const ThreadSchema: z.ZodPipe<z.ZodObject<{
|
|
|
145
145
|
snippet: z.ZodString;
|
|
146
146
|
snippetCreator: z.ZodNumber;
|
|
147
147
|
snippetMaskAvatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
148
|
-
snippetMaskPoster: z.ZodOptional<z.ZodNullable<z.
|
|
148
|
+
snippetMaskPoster: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
149
149
|
starred: z.ZodBoolean;
|
|
150
150
|
systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
|
|
151
151
|
toEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
@@ -208,7 +208,7 @@ export declare const ThreadSchema: z.ZodPipe<z.ZodObject<{
|
|
|
208
208
|
recipients?: number[] | null | undefined;
|
|
209
209
|
responders?: number[] | null | undefined;
|
|
210
210
|
snippetMaskAvatarUrl?: string | null | undefined;
|
|
211
|
-
snippetMaskPoster?: string |
|
|
211
|
+
snippetMaskPoster?: string | null | undefined;
|
|
212
212
|
systemMessage?: unknown;
|
|
213
213
|
toEmails?: string[] | null | undefined;
|
|
214
214
|
isSaved?: boolean | null | undefined;
|
|
@@ -268,7 +268,7 @@ export declare const ThreadSchema: z.ZodPipe<z.ZodObject<{
|
|
|
268
268
|
recipients?: number[] | null | undefined;
|
|
269
269
|
responders?: number[] | null | undefined;
|
|
270
270
|
snippetMaskAvatarUrl?: string | null | undefined;
|
|
271
|
-
snippetMaskPoster?: string |
|
|
271
|
+
snippetMaskPoster?: string | null | undefined;
|
|
272
272
|
systemMessage?: unknown;
|
|
273
273
|
toEmails?: string[] | null | undefined;
|
|
274
274
|
isSaved?: boolean | null | undefined;
|
|
@@ -603,7 +603,7 @@ export declare const InboxThreadSchema: z.ZodPipe<z.ZodObject<{
|
|
|
603
603
|
snippet: z.ZodString;
|
|
604
604
|
snippetCreator: z.ZodNumber;
|
|
605
605
|
snippetMaskAvatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
606
|
-
snippetMaskPoster: z.ZodOptional<z.ZodNullable<z.
|
|
606
|
+
snippetMaskPoster: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
607
607
|
starred: z.ZodBoolean;
|
|
608
608
|
systemMessage: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>>;
|
|
609
609
|
isArchived: z.ZodBoolean;
|
|
@@ -719,7 +719,7 @@ export declare const InboxThreadSchema: z.ZodPipe<z.ZodObject<{
|
|
|
719
719
|
reactions?: Record<string, number[]> | null | undefined;
|
|
720
720
|
recipients?: number[] | null | undefined;
|
|
721
721
|
snippetMaskAvatarUrl?: string | null | undefined;
|
|
722
|
-
snippetMaskPoster?:
|
|
722
|
+
snippetMaskPoster?: string | null | undefined;
|
|
723
723
|
systemMessage?: unknown;
|
|
724
724
|
isSaved?: boolean | null | undefined;
|
|
725
725
|
responders?: number[] | null | undefined;
|
|
@@ -782,7 +782,7 @@ export declare const InboxThreadSchema: z.ZodPipe<z.ZodObject<{
|
|
|
782
782
|
reactions?: Record<string, number[]> | null | undefined;
|
|
783
783
|
recipients?: number[] | null | undefined;
|
|
784
784
|
snippetMaskAvatarUrl?: string | null | undefined;
|
|
785
|
-
snippetMaskPoster?:
|
|
785
|
+
snippetMaskPoster?: string | null | undefined;
|
|
786
786
|
systemMessage?: unknown;
|
|
787
787
|
isSaved?: boolean | null | undefined;
|
|
788
788
|
responders?: number[] | null | undefined;
|