@hexabot-ai/types 3.0.0-alpha.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.
- package/LICENSE.md +120 -0
- package/README.md +172 -0
- package/dist/cjs/analytics/index.js +18 -0
- package/dist/cjs/analytics/integration-health.js +30 -0
- package/dist/cjs/analytics/stats.js +32 -0
- package/dist/cjs/attachment/attachment.js +53 -0
- package/dist/cjs/attachment/index.js +16 -0
- package/dist/cjs/audit/audit-log.js +33 -0
- package/dist/cjs/audit/index.js +11 -0
- package/dist/cjs/channel/channel-metadata.js +15 -0
- package/dist/cjs/channel/index.js +15 -0
- package/dist/cjs/channel/source-full.js +16 -0
- package/dist/cjs/channel/source.js +25 -0
- package/dist/cjs/chat/attachment.js +32 -0
- package/dist/cjs/chat/button.js +70 -0
- package/dist/cjs/chat/index.js +87 -0
- package/dist/cjs/chat/label-group.js +22 -0
- package/dist/cjs/chat/label.js +37 -0
- package/dist/cjs/chat/message-contract.js +183 -0
- package/dist/cjs/chat/message.js +107 -0
- package/dist/cjs/chat/options.js +122 -0
- package/dist/cjs/chat/quick-reply.js +35 -0
- package/dist/cjs/chat/subscriber.js +36 -0
- package/dist/cjs/chat/thread.js +36 -0
- package/dist/cjs/cms/content-type.js +17 -0
- package/dist/cjs/cms/content.js +29 -0
- package/dist/cjs/cms/index.js +21 -0
- package/dist/cjs/cms/menu.js +36 -0
- package/dist/cjs/dummy/dummy.js +18 -0
- package/dist/cjs/dummy/index.js +12 -0
- package/dist/cjs/i18n/index.js +16 -0
- package/dist/cjs/i18n/language.js +19 -0
- package/dist/cjs/i18n/translation.js +17 -0
- package/dist/cjs/index.js +32 -0
- package/dist/cjs/setting/index.js +18 -0
- package/dist/cjs/setting/metadata.js +17 -0
- package/dist/cjs/setting/setting.js +36 -0
- package/dist/cjs/shared/aliases.js +41 -0
- package/dist/cjs/shared/base.js +14 -0
- package/dist/cjs/shared/object.js +19 -0
- package/dist/cjs/shared/preprocess.js +13 -0
- package/dist/cjs/shared/profile.js +33 -0
- package/dist/cjs/user/credential.js +26 -0
- package/dist/cjs/user/domain.js +56 -0
- package/dist/cjs/user/index.js +39 -0
- package/dist/cjs/user/model.js +24 -0
- package/dist/cjs/user/permission.js +32 -0
- package/dist/cjs/user/role.js +24 -0
- package/dist/cjs/user/user-profile-assigned.js +38 -0
- package/dist/cjs/user/user-profile.js +12 -0
- package/dist/cjs/user/user.js +44 -0
- package/dist/cjs/workflow/domain.js +44 -0
- package/dist/cjs/workflow/helpers.js +35 -0
- package/dist/cjs/workflow/index.js +40 -0
- package/dist/cjs/workflow/mcp-server.js +33 -0
- package/dist/cjs/workflow/memory-definition.js +21 -0
- package/dist/cjs/workflow/memory-record.js +44 -0
- package/dist/cjs/workflow/workflow-run.js +100 -0
- package/dist/cjs/workflow/workflow-version.js +39 -0
- package/dist/cjs/workflow/workflow.js +98 -0
- package/dist/esm/analytics/index.js +7 -0
- package/dist/esm/analytics/integration-health.js +27 -0
- package/dist/esm/analytics/stats.js +29 -0
- package/dist/esm/attachment/attachment.js +50 -0
- package/dist/esm/attachment/index.js +6 -0
- package/dist/esm/audit/audit-log.js +30 -0
- package/dist/esm/audit/index.js +6 -0
- package/dist/esm/channel/channel-metadata.js +12 -0
- package/dist/esm/channel/index.js +8 -0
- package/dist/esm/channel/source-full.js +13 -0
- package/dist/esm/channel/source.js +22 -0
- package/dist/esm/chat/attachment.js +29 -0
- package/dist/esm/chat/button.js +67 -0
- package/dist/esm/chat/index.js +15 -0
- package/dist/esm/chat/label-group.js +19 -0
- package/dist/esm/chat/label.js +34 -0
- package/dist/esm/chat/message-contract.js +180 -0
- package/dist/esm/chat/message.js +104 -0
- package/dist/esm/chat/options.js +119 -0
- package/dist/esm/chat/quick-reply.js +32 -0
- package/dist/esm/chat/subscriber.js +33 -0
- package/dist/esm/chat/thread.js +33 -0
- package/dist/esm/cms/content-type.js +14 -0
- package/dist/esm/cms/content.js +26 -0
- package/dist/esm/cms/index.js +8 -0
- package/dist/esm/cms/menu.js +33 -0
- package/dist/esm/dummy/dummy.js +15 -0
- package/dist/esm/dummy/index.js +6 -0
- package/dist/esm/i18n/index.js +7 -0
- package/dist/esm/i18n/language.js +16 -0
- package/dist/esm/i18n/translation.js +14 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/setting/index.js +7 -0
- package/dist/esm/setting/metadata.js +14 -0
- package/dist/esm/setting/setting.js +33 -0
- package/dist/esm/shared/aliases.js +35 -0
- package/dist/esm/shared/base.js +11 -0
- package/dist/esm/shared/object.js +14 -0
- package/dist/esm/shared/preprocess.js +9 -0
- package/dist/esm/shared/profile.js +30 -0
- package/dist/esm/user/credential.js +23 -0
- package/dist/esm/user/domain.js +53 -0
- package/dist/esm/user/index.js +13 -0
- package/dist/esm/user/model.js +21 -0
- package/dist/esm/user/permission.js +29 -0
- package/dist/esm/user/role.js +21 -0
- package/dist/esm/user/user-profile-assigned.js +35 -0
- package/dist/esm/user/user-profile.js +9 -0
- package/dist/esm/user/user.js +41 -0
- package/dist/esm/workflow/domain.js +41 -0
- package/dist/esm/workflow/helpers.js +30 -0
- package/dist/esm/workflow/index.js +12 -0
- package/dist/esm/workflow/mcp-server.js +30 -0
- package/dist/esm/workflow/memory-definition.js +18 -0
- package/dist/esm/workflow/memory-record.js +41 -0
- package/dist/esm/workflow/workflow-run.js +96 -0
- package/dist/esm/workflow/workflow-version.js +36 -0
- package/dist/esm/workflow/workflow.js +94 -0
- package/dist/types/analytics/index.d.ts +3 -0
- package/dist/types/analytics/index.d.ts.map +1 -0
- package/dist/types/analytics/integration-health.d.ts +55 -0
- package/dist/types/analytics/integration-health.d.ts.map +1 -0
- package/dist/types/analytics/stats.d.ts +43 -0
- package/dist/types/analytics/stats.d.ts.map +1 -0
- package/dist/types/attachment/attachment.d.ts +212 -0
- package/dist/types/attachment/attachment.d.ts.map +1 -0
- package/dist/types/attachment/index.d.ts +2 -0
- package/dist/types/attachment/index.d.ts.map +1 -0
- package/dist/types/audit/audit-log.d.ts +58 -0
- package/dist/types/audit/audit-log.d.ts.map +1 -0
- package/dist/types/audit/index.d.ts +2 -0
- package/dist/types/audit/index.d.ts.map +1 -0
- package/dist/types/channel/channel-metadata.d.ts +7 -0
- package/dist/types/channel/channel-metadata.d.ts.map +1 -0
- package/dist/types/channel/index.d.ts +4 -0
- package/dist/types/channel/index.d.ts.map +1 -0
- package/dist/types/channel/source-full.d.ts +58 -0
- package/dist/types/channel/source-full.d.ts.map +1 -0
- package/dist/types/channel/source.d.ts +44 -0
- package/dist/types/channel/source.d.ts.map +1 -0
- package/dist/types/chat/attachment.d.ts +34 -0
- package/dist/types/chat/attachment.d.ts.map +1 -0
- package/dist/types/chat/button.d.ts +31 -0
- package/dist/types/chat/button.d.ts.map +1 -0
- package/dist/types/chat/index.d.ts +11 -0
- package/dist/types/chat/index.d.ts.map +1 -0
- package/dist/types/chat/label-group.d.ts +47 -0
- package/dist/types/chat/label-group.d.ts.map +1 -0
- package/dist/types/chat/label.d.ts +102 -0
- package/dist/types/chat/label.d.ts.map +1 -0
- package/dist/types/chat/message-contract.d.ts +883 -0
- package/dist/types/chat/message-contract.d.ts.map +1 -0
- package/dist/types/chat/message.d.ts +1132 -0
- package/dist/types/chat/message.d.ts.map +1 -0
- package/dist/types/chat/options.d.ts +64 -0
- package/dist/types/chat/options.d.ts.map +1 -0
- package/dist/types/chat/quick-reply.d.ts +32 -0
- package/dist/types/chat/quick-reply.d.ts.map +1 -0
- package/dist/types/chat/subscriber.d.ts +236 -0
- package/dist/types/chat/subscriber.d.ts.map +1 -0
- package/dist/types/chat/thread.d.ts +126 -0
- package/dist/types/chat/thread.d.ts.map +1 -0
- package/dist/types/cms/content-type.d.ts +26 -0
- package/dist/types/cms/content-type.d.ts.map +1 -0
- package/dist/types/cms/content.d.ts +49 -0
- package/dist/types/cms/content.d.ts.map +1 -0
- package/dist/types/cms/index.d.ts +4 -0
- package/dist/types/cms/index.d.ts.map +1 -0
- package/dist/types/cms/menu.d.ts +85 -0
- package/dist/types/cms/menu.d.ts.map +1 -0
- package/dist/types/dummy/dummy.d.ts +26 -0
- package/dist/types/dummy/dummy.d.ts.map +1 -0
- package/dist/types/dummy/index.d.ts +2 -0
- package/dist/types/dummy/index.d.ts.map +1 -0
- package/dist/types/i18n/index.d.ts +3 -0
- package/dist/types/i18n/index.d.ts.map +1 -0
- package/dist/types/i18n/language.d.ts +32 -0
- package/dist/types/i18n/language.d.ts.map +1 -0
- package/dist/types/i18n/translation.d.ts +26 -0
- package/dist/types/i18n/translation.d.ts.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/setting/index.d.ts +3 -0
- package/dist/types/setting/index.d.ts.map +1 -0
- package/dist/types/setting/metadata.d.ts +26 -0
- package/dist/types/setting/metadata.d.ts.map +1 -0
- package/dist/types/setting/setting.d.ts +41 -0
- package/dist/types/setting/setting.d.ts.map +1 -0
- package/dist/types/shared/aliases.d.ts +4 -0
- package/dist/types/shared/aliases.d.ts.map +1 -0
- package/dist/types/shared/base.d.ts +7 -0
- package/dist/types/shared/base.d.ts.map +1 -0
- package/dist/types/shared/object.d.ts +3 -0
- package/dist/types/shared/object.d.ts.map +1 -0
- package/dist/types/shared/preprocess.d.ts +3 -0
- package/dist/types/shared/preprocess.d.ts.map +1 -0
- package/dist/types/shared/profile.d.ts +40 -0
- package/dist/types/shared/profile.d.ts.map +1 -0
- package/dist/types/user/credential.d.ts +97 -0
- package/dist/types/user/credential.d.ts.map +1 -0
- package/dist/types/user/domain.d.ts +54 -0
- package/dist/types/user/domain.d.ts.map +1 -0
- package/dist/types/user/index.d.ts +9 -0
- package/dist/types/user/index.d.ts.map +1 -0
- package/dist/types/user/model.d.ts +142 -0
- package/dist/types/user/model.d.ts.map +1 -0
- package/dist/types/user/permission.d.ts +90 -0
- package/dist/types/user/permission.d.ts.map +1 -0
- package/dist/types/user/role.d.ts +111 -0
- package/dist/types/user/role.d.ts.map +1 -0
- package/dist/types/user/user-profile-assigned.d.ts +181 -0
- package/dist/types/user/user-profile-assigned.d.ts.map +1 -0
- package/dist/types/user/user-profile.d.ts +32 -0
- package/dist/types/user/user-profile.d.ts.map +1 -0
- package/dist/types/user/user.d.ts +270 -0
- package/dist/types/user/user.d.ts.map +1 -0
- package/dist/types/workflow/domain.d.ts +32 -0
- package/dist/types/workflow/domain.d.ts.map +1 -0
- package/dist/types/workflow/helpers.d.ts +117 -0
- package/dist/types/workflow/helpers.d.ts.map +1 -0
- package/dist/types/workflow/index.d.ts +8 -0
- package/dist/types/workflow/index.d.ts.map +1 -0
- package/dist/types/workflow/mcp-server.d.ts +67 -0
- package/dist/types/workflow/mcp-server.d.ts.map +1 -0
- package/dist/types/workflow/memory-definition.d.ts +35 -0
- package/dist/types/workflow/memory-definition.d.ts.map +1 -0
- package/dist/types/workflow/memory-record.d.ts +284 -0
- package/dist/types/workflow/memory-record.d.ts.map +1 -0
- package/dist/types/workflow/workflow-run.d.ts +375 -0
- package/dist/types/workflow/workflow-run.d.ts.map +1 -0
- package/dist/types/workflow/workflow-version.d.ts +179 -0
- package/dist/types/workflow/workflow-version.d.ts.map +1 -0
- package/dist/types/workflow/workflow.d.ts +366 -0
- package/dist/types/workflow/workflow.d.ts.map +1 -0
- package/package.json +59 -0
- package/src/analytics/index.ts +26 -0
- package/src/analytics/integration-health.ts +44 -0
- package/src/analytics/stats.ts +41 -0
- package/src/attachment/attachment.ts +75 -0
- package/src/attachment/index.ts +19 -0
- package/src/audit/audit-log.ts +42 -0
- package/src/audit/index.ts +12 -0
- package/src/channel/channel-metadata.ts +20 -0
- package/src/channel/index.ts +19 -0
- package/src/channel/source-full.ts +25 -0
- package/src/channel/source.ts +42 -0
- package/src/chat/attachment.ts +44 -0
- package/src/chat/button.ts +90 -0
- package/src/chat/index.ts +173 -0
- package/src/chat/label-group.ts +35 -0
- package/src/chat/label.ts +56 -0
- package/src/chat/message-contract.ts +370 -0
- package/src/chat/message.ts +164 -0
- package/src/chat/options.ts +130 -0
- package/src/chat/quick-reply.ts +41 -0
- package/src/chat/subscriber.ts +73 -0
- package/src/chat/thread.ts +55 -0
- package/src/cms/content-type.ts +26 -0
- package/src/cms/content.ts +48 -0
- package/src/cms/index.ts +33 -0
- package/src/cms/menu.ts +54 -0
- package/src/dummy/dummy.ts +30 -0
- package/src/dummy/index.ts +14 -0
- package/src/i18n/index.ts +23 -0
- package/src/i18n/language.ts +28 -0
- package/src/i18n/translation.ts +26 -0
- package/src/index.test.ts +1271 -0
- package/src/index.ts +27 -0
- package/src/setting/index.ts +25 -0
- package/src/setting/metadata.ts +26 -0
- package/src/setting/setting.ts +46 -0
- package/src/shared/aliases.ts +48 -0
- package/src/shared/base.ts +13 -0
- package/src/shared/object.ts +19 -0
- package/src/shared/preprocess.ts +14 -0
- package/src/shared/profile.ts +49 -0
- package/src/user/credential.ts +45 -0
- package/src/user/domain.ts +94 -0
- package/src/user/index.ts +78 -0
- package/src/user/model.ts +40 -0
- package/src/user/permission.ts +51 -0
- package/src/user/role.ts +43 -0
- package/src/user/user-profile-assigned.ts +70 -0
- package/src/user/user-profile.ts +21 -0
- package/src/user/user.ts +87 -0
- package/src/workflow/domain.ts +47 -0
- package/src/workflow/helpers.ts +40 -0
- package/src/workflow/index.ts +70 -0
- package/src/workflow/mcp-server.ts +64 -0
- package/src/workflow/memory-definition.ts +31 -0
- package/src/workflow/memory-record.ts +71 -0
- package/src/workflow/workflow-run.ts +156 -0
- package/src/workflow/workflow-version.ts +68 -0
- package/src/workflow/workflow.ts +163 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2026 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
import type { Attachment } from "../attachment/attachment";
|
|
10
|
+
|
|
11
|
+
import { attachmentPayloadSchema } from "./attachment";
|
|
12
|
+
import { PayloadType, buttonSchema } from "./button";
|
|
13
|
+
import type { Message as EntityMessage } from "./message";
|
|
14
|
+
import { contentOptionsSchema } from "./options";
|
|
15
|
+
import { stdQuickReplySchema } from "./quick-reply";
|
|
16
|
+
|
|
17
|
+
export enum StdEventType {
|
|
18
|
+
message = "message",
|
|
19
|
+
delivery = "delivery",
|
|
20
|
+
read = "read",
|
|
21
|
+
typing = "typing",
|
|
22
|
+
follow = "follow",
|
|
23
|
+
echo = "echo",
|
|
24
|
+
error = "error",
|
|
25
|
+
unknown = "",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export enum IncomingMessageType {
|
|
29
|
+
text = "text",
|
|
30
|
+
postback = "postback",
|
|
31
|
+
quickReply = "quickReply",
|
|
32
|
+
location = "location",
|
|
33
|
+
attachment = "attachment",
|
|
34
|
+
unknown = "",
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const incomingMessageType = z.enum(IncomingMessageType);
|
|
38
|
+
|
|
39
|
+
export type IncomingMessageTypeLiteral = z.infer<typeof incomingMessageType>;
|
|
40
|
+
|
|
41
|
+
export enum OutgoingMessageType {
|
|
42
|
+
text = "text",
|
|
43
|
+
quickReply = "quickReply",
|
|
44
|
+
buttons = "buttons",
|
|
45
|
+
attachment = "attachment",
|
|
46
|
+
list = "list",
|
|
47
|
+
carousel = "carousel",
|
|
48
|
+
system = "system",
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const outgoingMessageTypeSchema = z.enum(OutgoingMessageType);
|
|
52
|
+
|
|
53
|
+
export type OutgoingMessageTypeLiteral = z.infer<
|
|
54
|
+
typeof outgoingMessageTypeSchema
|
|
55
|
+
>;
|
|
56
|
+
|
|
57
|
+
export const payloadTypeSchema = z.enum(PayloadType);
|
|
58
|
+
|
|
59
|
+
export type PayloadTypeLiteral = z.infer<typeof payloadTypeSchema>;
|
|
60
|
+
|
|
61
|
+
export const stdOutgoingTextMessageDataSchema = z.object({
|
|
62
|
+
text: z.string(),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export type StdOutgoingTextMessageData = z.infer<
|
|
66
|
+
typeof stdOutgoingTextMessageDataSchema
|
|
67
|
+
>;
|
|
68
|
+
|
|
69
|
+
export const stdOutgoingQuickRepliesMessageDataSchema = z.object({
|
|
70
|
+
text: z.string(),
|
|
71
|
+
quickReplies: z.array(stdQuickReplySchema),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export type StdOutgoingQuickRepliesMessageData = z.infer<
|
|
75
|
+
typeof stdOutgoingQuickRepliesMessageDataSchema
|
|
76
|
+
>;
|
|
77
|
+
|
|
78
|
+
export const stdOutgoingButtonsMessageDataSchema = z.object({
|
|
79
|
+
text: z.string(),
|
|
80
|
+
buttons: z.array(buttonSchema),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export type StdOutgoingButtonsMessageData = z.infer<
|
|
84
|
+
typeof stdOutgoingButtonsMessageDataSchema
|
|
85
|
+
>;
|
|
86
|
+
|
|
87
|
+
export const contentElementSchema = z
|
|
88
|
+
.object({
|
|
89
|
+
id: z.string(),
|
|
90
|
+
title: z.string(),
|
|
91
|
+
})
|
|
92
|
+
.catchall(z.any());
|
|
93
|
+
|
|
94
|
+
export type ContentElement = z.infer<typeof contentElementSchema>;
|
|
95
|
+
|
|
96
|
+
export const contentPaginationSchema = z.object({
|
|
97
|
+
total: z.number(),
|
|
98
|
+
skip: z.number(),
|
|
99
|
+
limit: z.number(),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export type ContentPagination = z.infer<typeof contentPaginationSchema>;
|
|
103
|
+
|
|
104
|
+
export const stdOutgoingListMessageDataSchema = z.object({
|
|
105
|
+
options: contentOptionsSchema,
|
|
106
|
+
elements: z.array(contentElementSchema),
|
|
107
|
+
pagination: contentPaginationSchema,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export type StdOutgoingListMessageData = z.infer<
|
|
111
|
+
typeof stdOutgoingListMessageDataSchema
|
|
112
|
+
>;
|
|
113
|
+
|
|
114
|
+
export interface OutgoingPopulatedListMessage {
|
|
115
|
+
title: string;
|
|
116
|
+
subtitle: string | null;
|
|
117
|
+
image_url?: { payload: Attachment; type: string } | null;
|
|
118
|
+
url?: string;
|
|
119
|
+
action_title?: string;
|
|
120
|
+
action_payload?: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const stdOutgoingAttachmentMessageDataSchema = z.object({
|
|
124
|
+
attachment: attachmentPayloadSchema,
|
|
125
|
+
quickReplies: z.array(stdQuickReplySchema).optional(),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export type StdOutgoingAttachmentMessageData = z.infer<
|
|
129
|
+
typeof stdOutgoingAttachmentMessageDataSchema
|
|
130
|
+
>;
|
|
131
|
+
|
|
132
|
+
export const stdOutgoingSystemMessageDataSchema = z.object({
|
|
133
|
+
outcome: z.string().optional(),
|
|
134
|
+
data: z.any().optional(),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export type StdOutgoingSystemMessageData = z.infer<
|
|
138
|
+
typeof stdOutgoingSystemMessageDataSchema
|
|
139
|
+
>;
|
|
140
|
+
|
|
141
|
+
export const stdOutgoingTextMessageSchema = z.object({
|
|
142
|
+
type: z.literal(OutgoingMessageType.text),
|
|
143
|
+
data: stdOutgoingTextMessageDataSchema,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
export type StdOutgoingTextMessage = z.infer<
|
|
147
|
+
typeof stdOutgoingTextMessageSchema
|
|
148
|
+
>;
|
|
149
|
+
|
|
150
|
+
export const stdOutgoingQuickRepliesMessageSchema = z.object({
|
|
151
|
+
type: z.literal(OutgoingMessageType.quickReply),
|
|
152
|
+
data: stdOutgoingQuickRepliesMessageDataSchema,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
export type StdOutgoingQuickRepliesMessage = z.infer<
|
|
156
|
+
typeof stdOutgoingQuickRepliesMessageSchema
|
|
157
|
+
>;
|
|
158
|
+
|
|
159
|
+
export const stdOutgoingButtonsMessageSchema = z.object({
|
|
160
|
+
type: z.literal(OutgoingMessageType.buttons),
|
|
161
|
+
data: stdOutgoingButtonsMessageDataSchema,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
export type StdOutgoingButtonsMessage = z.infer<
|
|
165
|
+
typeof stdOutgoingButtonsMessageSchema
|
|
166
|
+
>;
|
|
167
|
+
|
|
168
|
+
export const stdOutgoingListMessageSchema = z.object({
|
|
169
|
+
type: z.literal(OutgoingMessageType.list),
|
|
170
|
+
data: stdOutgoingListMessageDataSchema,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
export type StdOutgoingListMessage = z.infer<
|
|
174
|
+
typeof stdOutgoingListMessageSchema
|
|
175
|
+
>;
|
|
176
|
+
|
|
177
|
+
export const stdOutgoingCarouselMessageSchema = z.object({
|
|
178
|
+
type: z.literal(OutgoingMessageType.carousel),
|
|
179
|
+
data: stdOutgoingListMessageDataSchema,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
export type StdOutgoingCarouselMessage = z.infer<
|
|
183
|
+
typeof stdOutgoingCarouselMessageSchema
|
|
184
|
+
>;
|
|
185
|
+
|
|
186
|
+
export const stdOutgoingAttachmentMessageSchema = z.object({
|
|
187
|
+
type: z.literal(OutgoingMessageType.attachment),
|
|
188
|
+
data: stdOutgoingAttachmentMessageDataSchema,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
export type StdOutgoingAttachmentMessage = z.infer<
|
|
192
|
+
typeof stdOutgoingAttachmentMessageSchema
|
|
193
|
+
>;
|
|
194
|
+
|
|
195
|
+
export const stdOutgoingMessageSchema = z.discriminatedUnion("type", [
|
|
196
|
+
stdOutgoingTextMessageSchema,
|
|
197
|
+
stdOutgoingQuickRepliesMessageSchema,
|
|
198
|
+
stdOutgoingButtonsMessageSchema,
|
|
199
|
+
stdOutgoingListMessageSchema,
|
|
200
|
+
stdOutgoingCarouselMessageSchema,
|
|
201
|
+
stdOutgoingAttachmentMessageSchema,
|
|
202
|
+
]);
|
|
203
|
+
|
|
204
|
+
export type StdOutgoingMessage = z.infer<typeof stdOutgoingMessageSchema>;
|
|
205
|
+
|
|
206
|
+
export const stdIncomingTextMessageDataSchema = z.object({
|
|
207
|
+
text: z.string(),
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
export type StdIncomingTextMessageData = z.infer<
|
|
211
|
+
typeof stdIncomingTextMessageDataSchema
|
|
212
|
+
>;
|
|
213
|
+
|
|
214
|
+
export const stdIncomingPayloadMessageDataSchema = z.object({
|
|
215
|
+
text: z.string(),
|
|
216
|
+
payload: z.string(),
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
export type StdIncomingPayloadMessageData = z.infer<
|
|
220
|
+
typeof stdIncomingPayloadMessageDataSchema
|
|
221
|
+
>;
|
|
222
|
+
|
|
223
|
+
export const stdIncomingLocationMessageDataSchema = z.object({
|
|
224
|
+
coordinates: z.object({
|
|
225
|
+
lat: z.number(),
|
|
226
|
+
lon: z.number(),
|
|
227
|
+
}),
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
export type StdIncomingLocationMessageData = z.infer<
|
|
231
|
+
typeof stdIncomingLocationMessageDataSchema
|
|
232
|
+
>;
|
|
233
|
+
|
|
234
|
+
export const stdIncomingAttachmentMessageDataSchema = z.object({
|
|
235
|
+
serializedText: z.string(),
|
|
236
|
+
attachment: z.union([
|
|
237
|
+
attachmentPayloadSchema,
|
|
238
|
+
z.array(attachmentPayloadSchema),
|
|
239
|
+
]),
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
export type StdIncomingAttachmentMessageData = z.infer<
|
|
243
|
+
typeof stdIncomingAttachmentMessageDataSchema
|
|
244
|
+
>;
|
|
245
|
+
|
|
246
|
+
export const stdIncomingTextMessageSchema = z.object({
|
|
247
|
+
type: z.literal(IncomingMessageType.text),
|
|
248
|
+
data: stdIncomingTextMessageDataSchema,
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
export type StdIncomingTextMessage = z.infer<
|
|
252
|
+
typeof stdIncomingTextMessageSchema
|
|
253
|
+
>;
|
|
254
|
+
|
|
255
|
+
export const stdIncomingPostBackMessageSchema = z.object({
|
|
256
|
+
type: z.literal(IncomingMessageType.postback),
|
|
257
|
+
data: stdIncomingPayloadMessageDataSchema,
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
export type StdIncomingPostBackMessage = z.infer<
|
|
261
|
+
typeof stdIncomingPostBackMessageSchema
|
|
262
|
+
>;
|
|
263
|
+
|
|
264
|
+
export const stdIncomingQuickReplyMessageSchema = z.object({
|
|
265
|
+
type: z.literal(IncomingMessageType.quickReply),
|
|
266
|
+
data: stdIncomingPayloadMessageDataSchema,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
export type StdIncomingQuickReplyMessage = z.infer<
|
|
270
|
+
typeof stdIncomingQuickReplyMessageSchema
|
|
271
|
+
>;
|
|
272
|
+
|
|
273
|
+
export const stdIncomingLocationMessageSchema = z.object({
|
|
274
|
+
type: z.literal(IncomingMessageType.location),
|
|
275
|
+
data: stdIncomingLocationMessageDataSchema,
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
export type StdIncomingLocationMessage = z.infer<
|
|
279
|
+
typeof stdIncomingLocationMessageSchema
|
|
280
|
+
>;
|
|
281
|
+
|
|
282
|
+
export const stdIncomingAttachmentMessageSchema = z.object({
|
|
283
|
+
type: z.literal(IncomingMessageType.attachment),
|
|
284
|
+
data: stdIncomingAttachmentMessageDataSchema,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
export type StdIncomingAttachmentMessage = z.infer<
|
|
288
|
+
typeof stdIncomingAttachmentMessageSchema
|
|
289
|
+
>;
|
|
290
|
+
|
|
291
|
+
export const stdIncomingMessageSchema = z.discriminatedUnion("type", [
|
|
292
|
+
stdIncomingTextMessageSchema,
|
|
293
|
+
stdIncomingPostBackMessageSchema,
|
|
294
|
+
stdIncomingQuickReplyMessageSchema,
|
|
295
|
+
stdIncomingLocationMessageSchema,
|
|
296
|
+
stdIncomingAttachmentMessageSchema,
|
|
297
|
+
]);
|
|
298
|
+
|
|
299
|
+
export type StdIncomingMessage = z.infer<typeof stdIncomingMessageSchema>;
|
|
300
|
+
|
|
301
|
+
export interface IncomingMessage
|
|
302
|
+
extends Omit<EntityMessage, "recipient" | "sentBy"> {
|
|
303
|
+
message: StdIncomingMessage;
|
|
304
|
+
sender: string;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface OutgoingMessage extends Omit<EntityMessage, "sender"> {
|
|
308
|
+
message: StdOutgoingMessage;
|
|
309
|
+
recipient: string;
|
|
310
|
+
sentBy?: string;
|
|
311
|
+
handover: boolean;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export type AnyMessage = IncomingMessage | OutgoingMessage;
|
|
315
|
+
|
|
316
|
+
export const stdOutgoingTextEnvelopeSchema = stdOutgoingTextMessageSchema;
|
|
317
|
+
|
|
318
|
+
export type StdOutgoingTextEnvelope = StdOutgoingTextMessage;
|
|
319
|
+
|
|
320
|
+
export const stdOutgoingQuickRepliesEnvelopeSchema =
|
|
321
|
+
stdOutgoingQuickRepliesMessageSchema;
|
|
322
|
+
|
|
323
|
+
export type StdOutgoingQuickRepliesEnvelope = StdOutgoingQuickRepliesMessage;
|
|
324
|
+
|
|
325
|
+
export const stdOutgoingButtonsEnvelopeSchema = stdOutgoingButtonsMessageSchema;
|
|
326
|
+
|
|
327
|
+
export type StdOutgoingButtonsEnvelope = StdOutgoingButtonsMessage;
|
|
328
|
+
|
|
329
|
+
export const stdOutgoingListEnvelopeSchema = z.discriminatedUnion("type", [
|
|
330
|
+
stdOutgoingListMessageSchema,
|
|
331
|
+
stdOutgoingCarouselMessageSchema,
|
|
332
|
+
]);
|
|
333
|
+
|
|
334
|
+
export type StdOutgoingListEnvelope = z.infer<
|
|
335
|
+
typeof stdOutgoingListEnvelopeSchema
|
|
336
|
+
>;
|
|
337
|
+
|
|
338
|
+
export const stdOutgoingAttachmentEnvelopeSchema =
|
|
339
|
+
stdOutgoingAttachmentMessageSchema;
|
|
340
|
+
|
|
341
|
+
export type StdOutgoingAttachmentEnvelope = StdOutgoingAttachmentMessage;
|
|
342
|
+
|
|
343
|
+
export const stdOutgoingSystemMessageSchema = z.object({
|
|
344
|
+
type: z.literal(OutgoingMessageType.system),
|
|
345
|
+
data: stdOutgoingSystemMessageDataSchema,
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
export type StdOutgoingSystemMessage = z.infer<
|
|
349
|
+
typeof stdOutgoingSystemMessageSchema
|
|
350
|
+
>;
|
|
351
|
+
|
|
352
|
+
export const stdOutgoingSystemEnvelopeSchema = stdOutgoingSystemMessageSchema;
|
|
353
|
+
|
|
354
|
+
export type StdOutgoingSystemEnvelope = StdOutgoingSystemMessage;
|
|
355
|
+
|
|
356
|
+
export const stdOutgoingMessageEnvelopeSchema = stdOutgoingMessageSchema;
|
|
357
|
+
|
|
358
|
+
export type StdOutgoingMessageEnvelope = StdOutgoingMessage;
|
|
359
|
+
|
|
360
|
+
export const stdOutgoingEnvelopeSchema = z.discriminatedUnion("type", [
|
|
361
|
+
stdOutgoingTextMessageSchema,
|
|
362
|
+
stdOutgoingQuickRepliesMessageSchema,
|
|
363
|
+
stdOutgoingButtonsMessageSchema,
|
|
364
|
+
stdOutgoingListMessageSchema,
|
|
365
|
+
stdOutgoingCarouselMessageSchema,
|
|
366
|
+
stdOutgoingAttachmentMessageSchema,
|
|
367
|
+
stdOutgoingSystemMessageSchema,
|
|
368
|
+
]);
|
|
369
|
+
|
|
370
|
+
export type StdOutgoingEnvelope = z.infer<typeof stdOutgoingEnvelopeSchema>;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2026 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
import { asId, withAliases } from "../shared/aliases";
|
|
10
|
+
import { baseStubSchema } from "../shared/base";
|
|
11
|
+
import { preprocess } from "../shared/preprocess";
|
|
12
|
+
import { userSchema } from "../user/user";
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
IncomingMessageType,
|
|
16
|
+
OutgoingMessageType,
|
|
17
|
+
stdOutgoingMessageSchema,
|
|
18
|
+
stdIncomingMessageSchema,
|
|
19
|
+
type StdIncomingMessage,
|
|
20
|
+
type StdOutgoingMessage,
|
|
21
|
+
} from "./message-contract";
|
|
22
|
+
import { subscriberSchema } from "./subscriber";
|
|
23
|
+
import { threadSchema } from "./thread";
|
|
24
|
+
|
|
25
|
+
const messageAliasMap = {
|
|
26
|
+
senderId: "sender",
|
|
27
|
+
recipientId: "recipient",
|
|
28
|
+
sentById: "sentBy",
|
|
29
|
+
threadId: "thread",
|
|
30
|
+
} as const;
|
|
31
|
+
const incomingOnlyTypes = new Set<IncomingMessageType>([
|
|
32
|
+
IncomingMessageType.postback,
|
|
33
|
+
IncomingMessageType.location,
|
|
34
|
+
]);
|
|
35
|
+
const outgoingOnlyTypes = new Set<OutgoingMessageType>([
|
|
36
|
+
OutgoingMessageType.buttons,
|
|
37
|
+
OutgoingMessageType.list,
|
|
38
|
+
OutgoingMessageType.carousel,
|
|
39
|
+
OutgoingMessageType.system,
|
|
40
|
+
]);
|
|
41
|
+
const invalidDirectionMessage = {
|
|
42
|
+
type: "__invalidDirection__",
|
|
43
|
+
data: null,
|
|
44
|
+
};
|
|
45
|
+
const parseByDirection = (
|
|
46
|
+
message: unknown,
|
|
47
|
+
record: Record<string, unknown>,
|
|
48
|
+
): unknown => {
|
|
49
|
+
const hasSender = record.sender != null;
|
|
50
|
+
const hasRecipient = record.recipient != null;
|
|
51
|
+
const hasSentBy = record.sentBy != null;
|
|
52
|
+
const shouldUseOutgoingSchema = hasRecipient || hasSentBy;
|
|
53
|
+
const shouldUseIncomingSchema = hasSender && !shouldUseOutgoingSchema;
|
|
54
|
+
|
|
55
|
+
if (shouldUseOutgoingSchema) {
|
|
56
|
+
const parsed = stdOutgoingMessageSchema.safeParse(message);
|
|
57
|
+
|
|
58
|
+
return parsed.success ? parsed.data : invalidDirectionMessage;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (shouldUseIncomingSchema) {
|
|
62
|
+
const parsed = stdIncomingMessageSchema.safeParse(message);
|
|
63
|
+
|
|
64
|
+
return parsed.success ? parsed.data : invalidDirectionMessage;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const type =
|
|
68
|
+
typeof message === "object" && message !== null
|
|
69
|
+
? (message as Record<string, unknown>).type
|
|
70
|
+
: undefined;
|
|
71
|
+
|
|
72
|
+
if (typeof type !== "string") {
|
|
73
|
+
const parsed = messagePayloadSchema.safeParse(message);
|
|
74
|
+
|
|
75
|
+
return parsed.success ? parsed.data : message;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (incomingOnlyTypes.has(type as IncomingMessageType)) {
|
|
79
|
+
const parsed = stdIncomingMessageSchema.safeParse(message);
|
|
80
|
+
|
|
81
|
+
return parsed.success ? parsed.data : message;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (outgoingOnlyTypes.has(type as OutgoingMessageType)) {
|
|
85
|
+
const parsed = stdOutgoingMessageSchema.safeParse(message);
|
|
86
|
+
|
|
87
|
+
return parsed.success ? parsed.data : message;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const parsed = messagePayloadSchema.safeParse(message);
|
|
91
|
+
|
|
92
|
+
return parsed.success ? parsed.data : message;
|
|
93
|
+
};
|
|
94
|
+
const normalizeMessageRecord = (value: unknown): unknown => {
|
|
95
|
+
const normalized = withAliases(value, messageAliasMap);
|
|
96
|
+
if (
|
|
97
|
+
typeof normalized !== "object" ||
|
|
98
|
+
normalized === null ||
|
|
99
|
+
!("message" in normalized)
|
|
100
|
+
) {
|
|
101
|
+
return normalized;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const record = normalized as Record<string, unknown>;
|
|
105
|
+
record.message = parseByDirection(record.message, record);
|
|
106
|
+
|
|
107
|
+
return record;
|
|
108
|
+
};
|
|
109
|
+
const messagePayloadSchema = z.union([
|
|
110
|
+
stdIncomingMessageSchema,
|
|
111
|
+
stdOutgoingMessageSchema,
|
|
112
|
+
]) as z.ZodType<StdIncomingMessage | StdOutgoingMessage>;
|
|
113
|
+
const messageStubObjectSchema = baseStubSchema.extend({
|
|
114
|
+
mid: z.string().optional(),
|
|
115
|
+
message: messagePayloadSchema,
|
|
116
|
+
read: z.coerce.boolean(),
|
|
117
|
+
delivery: z.coerce.boolean(),
|
|
118
|
+
handover: z.coerce.boolean(),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
export const messageStubSchema = messageStubObjectSchema;
|
|
122
|
+
|
|
123
|
+
export const messageSchema = preprocess(
|
|
124
|
+
normalizeMessageRecord,
|
|
125
|
+
messageStubObjectSchema.extend({
|
|
126
|
+
sender: preprocess(
|
|
127
|
+
(value) => (value == null ? null : asId(value)),
|
|
128
|
+
z.string().nullable(),
|
|
129
|
+
).optional(),
|
|
130
|
+
recipient: preprocess(
|
|
131
|
+
(value) => (value == null ? null : asId(value)),
|
|
132
|
+
z.string().nullable(),
|
|
133
|
+
).optional(),
|
|
134
|
+
sentBy: preprocess(
|
|
135
|
+
(value) => (value == null ? null : asId(value)),
|
|
136
|
+
z.string().nullable(),
|
|
137
|
+
).optional(),
|
|
138
|
+
thread: preprocess(
|
|
139
|
+
(value) => (value == null ? null : asId(value)),
|
|
140
|
+
z.string(),
|
|
141
|
+
),
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const messageFullObjectSchema = messageStubObjectSchema.extend({
|
|
146
|
+
sender: subscriberSchema.nullable().optional(),
|
|
147
|
+
recipient: subscriberSchema.nullable().optional(),
|
|
148
|
+
sentBy: z
|
|
149
|
+
.lazy(() => userSchema)
|
|
150
|
+
.nullable()
|
|
151
|
+
.optional(),
|
|
152
|
+
thread: threadSchema,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
export const messageFullSchema = preprocess(
|
|
156
|
+
normalizeMessageRecord,
|
|
157
|
+
messageFullObjectSchema,
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
export type MessageStub = z.infer<typeof messageStubSchema>;
|
|
161
|
+
|
|
162
|
+
export type Message = z.infer<typeof messageSchema>;
|
|
163
|
+
|
|
164
|
+
export type MessageFull = z.infer<typeof messageFullSchema>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2026 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
import { buttonSchema } from "./button";
|
|
10
|
+
|
|
11
|
+
export const contentOptionsSchema = z.object({
|
|
12
|
+
display: z.enum(["list", "carousel"]).meta({
|
|
13
|
+
title: "Display",
|
|
14
|
+
}),
|
|
15
|
+
contentType: z
|
|
16
|
+
.string()
|
|
17
|
+
.optional()
|
|
18
|
+
.meta({
|
|
19
|
+
title: "Content Type",
|
|
20
|
+
"ui:widget": "AutoCompleteWidget",
|
|
21
|
+
"ui:options": {
|
|
22
|
+
entity: "ContentType",
|
|
23
|
+
valueKey: "id",
|
|
24
|
+
labelKey: "name",
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
fields: z
|
|
28
|
+
.object({
|
|
29
|
+
title: z.string().meta({
|
|
30
|
+
title: "Title",
|
|
31
|
+
"ui:field": "AutoCompleteField",
|
|
32
|
+
"ui:options": {
|
|
33
|
+
entity: "ContentType",
|
|
34
|
+
idFormPath: "content.contentType",
|
|
35
|
+
nestedArrayField: "schema.properties",
|
|
36
|
+
nestedArrayItemField: "type",
|
|
37
|
+
nestedArrayItemValue: "string",
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
subtitle: z
|
|
41
|
+
.string()
|
|
42
|
+
.optional()
|
|
43
|
+
.meta({
|
|
44
|
+
title: "Subtitle",
|
|
45
|
+
"ui:field": "AutoCompleteField",
|
|
46
|
+
"ui:options": {
|
|
47
|
+
entity: "ContentType",
|
|
48
|
+
idFormPath: "content.contentType",
|
|
49
|
+
nestedArrayField: "schema.properties",
|
|
50
|
+
nestedArrayItemField: "type",
|
|
51
|
+
nestedArrayItemValue: "string",
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
image_url: z
|
|
55
|
+
.string()
|
|
56
|
+
.optional()
|
|
57
|
+
.meta({
|
|
58
|
+
title: "Image URL Field",
|
|
59
|
+
"ui:field": "AutoCompleteField",
|
|
60
|
+
"ui:options": {
|
|
61
|
+
entity: "ContentType",
|
|
62
|
+
idFormPath: "content.contentType",
|
|
63
|
+
nestedArrayField: "schema.properties",
|
|
64
|
+
nestedArrayItemField: "type",
|
|
65
|
+
nestedArrayItemValue: "file",
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
url: z
|
|
69
|
+
.string()
|
|
70
|
+
.optional()
|
|
71
|
+
.meta({
|
|
72
|
+
title: "URL",
|
|
73
|
+
"ui:field": "AutoCompleteField",
|
|
74
|
+
"ui:options": {
|
|
75
|
+
showOnlyWhenWebUrlButton: true,
|
|
76
|
+
entity: "ContentType",
|
|
77
|
+
valueKey: "name",
|
|
78
|
+
idFormPath: "content.contentType",
|
|
79
|
+
nestedArrayField: "schema.properties",
|
|
80
|
+
nestedArrayItemField: "type",
|
|
81
|
+
nestedArrayItemValue: "uri",
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
action_title: z
|
|
85
|
+
.string()
|
|
86
|
+
.optional()
|
|
87
|
+
.meta({
|
|
88
|
+
title: "Action Title",
|
|
89
|
+
"ui:options": {
|
|
90
|
+
showOnlyWhenPostbackButton: true,
|
|
91
|
+
},
|
|
92
|
+
}),
|
|
93
|
+
action_payload: z
|
|
94
|
+
.string()
|
|
95
|
+
.optional()
|
|
96
|
+
.meta({
|
|
97
|
+
title: "Action Payload",
|
|
98
|
+
"ui:options": {
|
|
99
|
+
showOnlyWhenPostbackButton: true,
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
})
|
|
103
|
+
.meta({ title: "Fields" }),
|
|
104
|
+
buttons: z.array(buttonSchema).meta({ title: "Buttons" }),
|
|
105
|
+
limit: z.number().finite(),
|
|
106
|
+
query: z.any().optional(),
|
|
107
|
+
top_element_style: z.enum(["large", "compact"]).optional().meta({
|
|
108
|
+
title: "Top Element Style",
|
|
109
|
+
}),
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export type ContentOptions = z.infer<typeof contentOptionsSchema>;
|
|
113
|
+
|
|
114
|
+
export const fallbackOptionsSchema = z.object({
|
|
115
|
+
active: z.boolean(),
|
|
116
|
+
message: z.array(z.string()),
|
|
117
|
+
max_attempts: z.number().finite(),
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
export type FallbackOptions = z.infer<typeof fallbackOptionsSchema>;
|
|
121
|
+
|
|
122
|
+
export const ActionOptionsSchema = z.object({
|
|
123
|
+
typing: z.union([z.boolean(), z.int().nonnegative()]).optional(),
|
|
124
|
+
content: contentOptionsSchema.optional(),
|
|
125
|
+
fallback: fallbackOptionsSchema.optional(),
|
|
126
|
+
assignTo: z.string().optional(),
|
|
127
|
+
effects: z.array(z.string()).optional(),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export type ActionOptions = z.infer<typeof ActionOptionsSchema>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
3
|
+
* Copyright (c) 2026 Hexastack.
|
|
4
|
+
* Full terms: see LICENSE.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
import { attachmentPayloadSchema } from "./attachment";
|
|
10
|
+
import { PayloadType } from "./button";
|
|
11
|
+
|
|
12
|
+
export const coordinatesSchema = z.object({
|
|
13
|
+
lat: z.number(),
|
|
14
|
+
lon: z.number(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const payloadSchema = z.discriminatedUnion("type", [
|
|
18
|
+
z.object({
|
|
19
|
+
type: z.literal(PayloadType.location),
|
|
20
|
+
coordinates: coordinatesSchema,
|
|
21
|
+
}),
|
|
22
|
+
z.object({
|
|
23
|
+
type: z.literal(PayloadType.attachment),
|
|
24
|
+
attachment: attachmentPayloadSchema,
|
|
25
|
+
}),
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
export const stdQuickReplySchema = z.object({
|
|
29
|
+
title: z.string().meta({
|
|
30
|
+
title: "Title",
|
|
31
|
+
description: "The label shown to the user.",
|
|
32
|
+
}),
|
|
33
|
+
payload: z.string().meta({
|
|
34
|
+
title: "Payload",
|
|
35
|
+
description: "The value sent back when the quick reply is selected.",
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export type Payload = z.infer<typeof payloadSchema>;
|
|
40
|
+
|
|
41
|
+
export type StdQuickReply = z.infer<typeof stdQuickReplySchema>;
|