@doist/comms-sdk 0.9.0 → 0.10.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.
@@ -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.RequestAttachmentSchema = exports.AttachmentSchema = exports.HookSubscribeResponseSchema = exports.StatusOkSchema = exports.SystemMessageSchema = void 0;
3
+ exports.SearchResultSchema = exports.ConversationSearchResultSchema = exports.ThreadSearchResultSchema = 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.HookSubscribeResponseSchema = exports.StatusOkSchema = exports.SystemMessageSchema = void 0;
4
4
  exports.createChannelSchema = createChannelSchema;
5
5
  exports.createThreadSchema = createThreadSchema;
6
6
  exports.createConversationSchema = createConversationSchema;
@@ -420,32 +420,43 @@ exports.UnreadConversationSchema = zod_1.z.object({
420
420
  directMention: zod_1.z.boolean(),
421
421
  });
422
422
  // SearchResult entity from API.
423
- // The API currently only emits 'thread' and 'conversation' results: a match inside a
423
+ // The API emits 'thread' and 'conversation' results: a match inside a
424
424
  // comment is returned as a 'thread' result with `commentId` set, and a match inside a
425
425
  // message as a 'conversation' result with `messageId` set.
426
- exports.SEARCH_RESULT_TYPES = ['thread', 'comment', 'message', 'conversation'];
427
- exports.SearchResultSchema = zod_1.z.object({
426
+ const searchResultBaseShape = {
428
427
  /**
429
428
  * Opaque search-result key in the form `thread_<threadId>` or
430
429
  * `conversation_<conversationId>`. Unique per result; not a Comms object id — use
431
430
  * `threadId`, `conversationId`, `commentId`, or `messageId` to reference objects.
432
431
  */
433
432
  id: zod_1.z.string(),
434
- type: zod_1.z.enum(exports.SEARCH_RESULT_TYPES),
435
433
  snippet: zod_1.z.string(),
436
434
  snippetCreatorId: zod_1.z.number(),
437
435
  snippetLastUpdated: zod_1.z.date(),
438
- /** The owning thread id. Set by the API on 'thread' results. */
439
- threadId: zod_1.z.string().nullable().optional(),
440
- /** The owning conversation id. Set by the API on 'conversation' results. */
441
- conversationId: zod_1.z.string().nullable().optional(),
442
- /** The matched comment id, set on 'thread' results when the match is a comment. */
443
- commentId: zod_1.z.string().nullable().optional(),
444
- /** The matched message id, set by the API on 'conversation' results. */
445
- messageId: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform(String).nullable().optional(),
446
436
  channelId: zod_1.z.string().nullable().optional(),
447
437
  channelName: zod_1.z.string().nullable().optional(),
448
438
  channelColor: zod_1.z.number().nullable().optional(),
449
439
  title: zod_1.z.string().nullable().optional(),
450
440
  closed: zod_1.z.boolean().nullable().optional(),
441
+ };
442
+ exports.SEARCH_RESULT_TYPES = ['thread', 'conversation'];
443
+ exports.ThreadSearchResultSchema = zod_1.z.object({
444
+ ...searchResultBaseShape,
445
+ type: zod_1.z.literal('thread'),
446
+ /** The owning thread id. */
447
+ threadId: zod_1.z.string(),
448
+ /** The matched comment id, set when the match is a comment. */
449
+ commentId: zod_1.z.string().nullable().optional(),
450
+ });
451
+ exports.ConversationSearchResultSchema = zod_1.z.object({
452
+ ...searchResultBaseShape,
453
+ type: zod_1.z.literal('conversation'),
454
+ /** The owning conversation id. */
455
+ conversationId: zod_1.z.string(),
456
+ /** The matched message id. */
457
+ messageId: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform(String).nullable().optional(),
451
458
  });
459
+ exports.SearchResultSchema = zod_1.z.discriminatedUnion('type', [
460
+ exports.ThreadSearchResultSchema,
461
+ exports.ConversationSearchResultSchema,
462
+ ]);
@@ -410,32 +410,43 @@ export const UnreadConversationSchema = z.object({
410
410
  directMention: z.boolean(),
411
411
  });
412
412
  // SearchResult entity from API.
413
- // The API currently only emits 'thread' and 'conversation' results: a match inside a
413
+ // The API emits 'thread' and 'conversation' results: a match inside a
414
414
  // comment is returned as a 'thread' result with `commentId` set, and a match inside a
415
415
  // message as a 'conversation' result with `messageId` set.
416
- export const SEARCH_RESULT_TYPES = ['thread', 'comment', 'message', 'conversation'];
417
- export const SearchResultSchema = z.object({
416
+ const searchResultBaseShape = {
418
417
  /**
419
418
  * Opaque search-result key in the form `thread_<threadId>` or
420
419
  * `conversation_<conversationId>`. Unique per result; not a Comms object id — use
421
420
  * `threadId`, `conversationId`, `commentId`, or `messageId` to reference objects.
422
421
  */
423
422
  id: z.string(),
424
- type: z.enum(SEARCH_RESULT_TYPES),
425
423
  snippet: z.string(),
426
424
  snippetCreatorId: z.number(),
427
425
  snippetLastUpdated: z.date(),
428
- /** The owning thread id. Set by the API on 'thread' results. */
429
- threadId: z.string().nullable().optional(),
430
- /** The owning conversation id. Set by the API on 'conversation' results. */
431
- conversationId: z.string().nullable().optional(),
432
- /** The matched comment id, set on 'thread' results when the match is a comment. */
433
- commentId: z.string().nullable().optional(),
434
- /** The matched message id, set by the API on 'conversation' results. */
435
- messageId: z.union([z.string(), z.number()]).transform(String).nullable().optional(),
436
426
  channelId: z.string().nullable().optional(),
437
427
  channelName: z.string().nullable().optional(),
438
428
  channelColor: z.number().nullable().optional(),
439
429
  title: z.string().nullable().optional(),
440
430
  closed: z.boolean().nullable().optional(),
431
+ };
432
+ export const SEARCH_RESULT_TYPES = ['thread', 'conversation'];
433
+ export const ThreadSearchResultSchema = z.object({
434
+ ...searchResultBaseShape,
435
+ type: z.literal('thread'),
436
+ /** The owning thread id. */
437
+ threadId: z.string(),
438
+ /** The matched comment id, set when the match is a comment. */
439
+ commentId: z.string().nullable().optional(),
440
+ });
441
+ export const ConversationSearchResultSchema = z.object({
442
+ ...searchResultBaseShape,
443
+ type: z.literal('conversation'),
444
+ /** The owning conversation id. */
445
+ conversationId: z.string(),
446
+ /** The matched message id. */
447
+ messageId: z.union([z.string(), z.number()]).transform(String).nullable().optional(),
441
448
  });
449
+ export const SearchResultSchema = z.discriminatedUnion('type', [
450
+ ThreadSearchResultSchema,
451
+ ConversationSearchResultSchema,
452
+ ]);
@@ -2802,29 +2802,65 @@ export declare const UnreadConversationSchema: z.ZodObject<{
2802
2802
  directMention: z.ZodBoolean;
2803
2803
  }, z.core.$strip>;
2804
2804
  export type UnreadConversation = z.infer<typeof UnreadConversationSchema>;
2805
- export declare const SEARCH_RESULT_TYPES: readonly ["thread", "comment", "message", "conversation"];
2805
+ export declare const SEARCH_RESULT_TYPES: readonly ["thread", "conversation"];
2806
2806
  export type SearchResultType = (typeof SEARCH_RESULT_TYPES)[number];
2807
- export declare const SearchResultSchema: z.ZodObject<{
2807
+ export declare const ThreadSearchResultSchema: z.ZodObject<{
2808
+ type: z.ZodLiteral<"thread">;
2809
+ threadId: z.ZodString;
2810
+ commentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2808
2811
  id: z.ZodString;
2809
- type: z.ZodEnum<{
2810
- thread: "thread";
2811
- message: "message";
2812
- comment: "comment";
2813
- conversation: "conversation";
2814
- }>;
2815
2812
  snippet: z.ZodString;
2816
2813
  snippetCreatorId: z.ZodNumber;
2817
2814
  snippetLastUpdated: z.ZodDate;
2818
- threadId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2819
- conversationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2820
- commentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2815
+ channelId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2816
+ channelName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2817
+ channelColor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
2818
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2819
+ closed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
2820
+ }, z.core.$strip>;
2821
+ export type ThreadSearchResult = z.infer<typeof ThreadSearchResultSchema>;
2822
+ export declare const ConversationSearchResultSchema: z.ZodObject<{
2823
+ type: z.ZodLiteral<"conversation">;
2824
+ conversationId: z.ZodString;
2821
2825
  messageId: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>>>;
2826
+ id: z.ZodString;
2827
+ snippet: z.ZodString;
2828
+ snippetCreatorId: z.ZodNumber;
2829
+ snippetLastUpdated: z.ZodDate;
2822
2830
  channelId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2823
2831
  channelName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2824
2832
  channelColor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
2825
2833
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2826
2834
  closed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
2827
2835
  }, z.core.$strip>;
2836
+ export type ConversationSearchResult = z.infer<typeof ConversationSearchResultSchema>;
2837
+ export declare const SearchResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2838
+ type: z.ZodLiteral<"thread">;
2839
+ threadId: z.ZodString;
2840
+ commentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2841
+ id: z.ZodString;
2842
+ snippet: z.ZodString;
2843
+ snippetCreatorId: z.ZodNumber;
2844
+ snippetLastUpdated: z.ZodDate;
2845
+ channelId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2846
+ channelName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2847
+ channelColor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
2848
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2849
+ closed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
2850
+ }, z.core.$strip>, z.ZodObject<{
2851
+ type: z.ZodLiteral<"conversation">;
2852
+ conversationId: z.ZodString;
2853
+ messageId: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>>>;
2854
+ id: z.ZodString;
2855
+ snippet: z.ZodString;
2856
+ snippetCreatorId: z.ZodNumber;
2857
+ snippetLastUpdated: z.ZodDate;
2858
+ channelId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2859
+ channelName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2860
+ channelColor: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
2861
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2862
+ closed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
2863
+ }, z.core.$strip>], "type">;
2828
2864
  export type SearchResult = z.infer<typeof SearchResultSchema>;
2829
2865
  export type SearchResponse = {
2830
2866
  items: SearchResult[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/comms-sdk",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "A TypeScript wrapper for the Comms REST API.",
5
5
  "author": "Doist developers",
6
6
  "homepage": "https://doist.github.io/comms-sdk-typescript/",