@headless-lms/core 0.2.0 → 0.3.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/dist/assets/events.d.ts +39 -21
- package/dist/assets/events.js +1 -1
- package/dist/assets/events.js.map +1 -1
- package/dist/assets/file-urls.d.ts +20 -0
- package/dist/assets/file-urls.js +25 -0
- package/dist/assets/file-urls.js.map +1 -0
- package/dist/assets/index.d.ts +5 -4
- package/dist/assets/index.js +3 -2
- package/dist/assets/model.d.ts +2 -2
- package/dist/assets/ports.d.ts +45 -15
- package/dist/assets/service.d.ts +39 -7
- package/dist/assets/service.js +291 -38
- package/dist/assets/service.js.map +1 -1
- package/dist/automations/actions.d.ts +13 -24
- package/dist/automations/actions.js +168 -43
- package/dist/automations/actions.js.map +1 -1
- package/dist/automations/catalog.d.ts +2 -1
- package/dist/automations/catalog.js +229 -13
- package/dist/automations/catalog.js.map +1 -1
- package/dist/automations/community-derivations.d.ts +14 -0
- package/dist/automations/community-derivations.js +439 -0
- package/dist/automations/community-derivations.js.map +1 -0
- package/dist/automations/community-mail.d.ts +112 -0
- package/dist/automations/community-mail.js +90 -0
- package/dist/automations/community-mail.js.map +1 -0
- package/dist/automations/community-notifications.d.ts +16 -0
- package/dist/automations/community-notifications.js +84 -0
- package/dist/automations/community-notifications.js.map +1 -0
- package/dist/automations/events.d.ts +28 -0
- package/dist/automations/index.d.ts +4 -2
- package/dist/automations/index.js +3 -2
- package/dist/automations/model.d.ts +10 -3
- package/dist/automations/model.js +15 -2
- package/dist/automations/model.js.map +1 -1
- package/dist/automations/ports.d.ts +5 -1
- package/dist/automations/schedule.d.ts +6 -0
- package/dist/automations/schedule.js +41 -0
- package/dist/automations/schedule.js.map +1 -0
- package/dist/automations/seeds.d.ts +17 -0
- package/dist/automations/seeds.js +235 -0
- package/dist/automations/seeds.js.map +1 -0
- package/dist/automations/service.d.ts +22 -3
- package/dist/automations/service.js +306 -43
- package/dist/automations/service.js.map +1 -1
- package/dist/content/events.d.ts +631 -19
- package/dist/content/events.js +44 -1
- package/dist/content/events.js.map +1 -1
- package/dist/content/index.d.ts +4 -4
- package/dist/content/model.d.ts +2 -2
- package/dist/content/ports.d.ts +71 -18
- package/dist/content/service.d.ts +57 -18
- package/dist/content/service.js +502 -23
- package/dist/content/service.js.map +1 -1
- package/dist/content/types.d.ts +2 -2
- package/dist/discussion/authors.d.ts +10 -0
- package/dist/discussion/authors.js +23 -0
- package/dist/discussion/authors.js.map +1 -0
- package/dist/discussion/chats.d.ts +104 -0
- package/dist/discussion/chats.js +798 -0
- package/dist/discussion/chats.js.map +1 -0
- package/dist/discussion/events.d.ts +619 -56
- package/dist/discussion/events.js +106 -3
- package/dist/discussion/events.js.map +1 -1
- package/dist/discussion/index.d.ts +7 -3
- package/dist/discussion/index.js +4 -1
- package/dist/discussion/ports.d.ts +288 -27
- package/dist/discussion/ports.js +6 -1
- package/dist/discussion/ports.js.map +1 -0
- package/dist/discussion/posts.d.ts +103 -0
- package/dist/discussion/posts.js +723 -0
- package/dist/discussion/posts.js.map +1 -0
- package/dist/discussion/service.d.ts +32 -10
- package/dist/discussion/service.js +293 -78
- package/dist/discussion/service.js.map +1 -1
- package/dist/entitlements/events.d.ts +178 -11
- package/dist/entitlements/events.js +28 -1
- package/dist/entitlements/events.js.map +1 -1
- package/dist/entitlements/index.d.ts +5 -4
- package/dist/entitlements/index.js +2 -1
- package/dist/entitlements/model.d.ts +3 -2
- package/dist/entitlements/ports.d.ts +124 -11
- package/dist/entitlements/rules.d.ts +12 -0
- package/dist/entitlements/rules.js +17 -0
- package/dist/entitlements/rules.js.map +1 -0
- package/dist/entitlements/service.d.ts +54 -3
- package/dist/entitlements/service.js +472 -2
- package/dist/entitlements/service.js.map +1 -1
- package/dist/identity/access.d.ts +6 -0
- package/dist/identity/access.js +7 -0
- package/dist/identity/access.js.map +1 -0
- package/dist/identity/index.d.ts +6 -4
- package/dist/identity/index.js +3 -1
- package/dist/identity/model.d.ts +2 -1
- package/dist/identity/notifications.d.ts +27 -0
- package/dist/identity/notifications.js +101 -0
- package/dist/identity/notifications.js.map +1 -0
- package/dist/identity/ports.d.ts +73 -3
- package/dist/identity/service.d.ts +14 -3
- package/dist/identity/service.js +62 -5
- package/dist/identity/service.js.map +1 -1
- package/dist/integrations/model.js +1 -1
- package/dist/integrations/model.js.map +1 -1
- package/dist/integrations/service.js +2 -2
- package/dist/integrations/service.js.map +1 -1
- package/dist/organizations/access-scopes.d.ts +19 -0
- package/dist/organizations/access-scopes.js +89 -0
- package/dist/organizations/access-scopes.js.map +1 -0
- package/dist/organizations/events.d.ts +74 -32
- package/dist/organizations/events.js +6 -0
- package/dist/organizations/events.js.map +1 -1
- package/dist/organizations/index.d.ts +7 -6
- package/dist/organizations/index.js +4 -3
- package/dist/organizations/members.d.ts +8 -5
- package/dist/organizations/members.js.map +1 -1
- package/dist/organizations/ports.d.ts +14 -11
- package/dist/organizations/roles.d.ts +6 -10
- package/dist/organizations/roles.js +19 -7
- package/dist/organizations/roles.js.map +1 -1
- package/dist/organizations/service.d.ts +20 -11
- package/dist/organizations/service.js +157 -47
- package/dist/organizations/service.js.map +1 -1
- package/dist/organizations/types.d.ts +1 -10
- package/dist/progress/index.d.ts +2 -2
- package/dist/progress/ports.d.ts +6 -1
- package/dist/progress/service.d.ts +3 -1
- package/dist/progress/service.js +6 -2
- package/dist/progress/service.js.map +1 -1
- package/dist/reporting/admin/index.d.ts +4 -0
- package/dist/reporting/admin/index.js +2 -0
- package/dist/reporting/admin/model.d.ts +108 -0
- package/dist/reporting/admin/ports.d.ts +27 -0
- package/dist/reporting/admin/service.d.ts +22 -0
- package/dist/reporting/admin/service.js +38 -0
- package/dist/reporting/admin/service.js.map +1 -0
- package/dist/reporting/member/index.d.ts +5 -0
- package/dist/reporting/member/index.js +2 -0
- package/dist/reporting/member/model.d.ts +124 -0
- package/dist/reporting/member/ports.d.ts +45 -0
- package/dist/reporting/member/service.d.ts +73 -0
- package/dist/reporting/member/service.js +286 -0
- package/dist/reporting/member/service.js.map +1 -0
- package/dist/shared/actor.d.ts +9 -0
- package/dist/shared/errors.d.ts +7 -1
- package/dist/shared/errors.js +10 -1
- package/dist/shared/errors.js.map +1 -1
- package/dist/shared/id.d.ts +11 -0
- package/dist/shared/id.js +12 -1
- package/dist/shared/id.js.map +1 -1
- package/dist/shared/mailer.d.ts +4 -1
- package/dist/shared/mailer.js.map +1 -1
- package/dist/shared/network.d.ts +10 -0
- package/dist/shared/network.js +211 -0
- package/dist/shared/network.js.map +1 -0
- package/dist/types/assets.d.ts +2 -2
- package/dist/types/automations.d.ts +10 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/discussion.d.ts +11 -3
- package/dist/types/email-templates.d.ts +121 -0
- package/dist/types/entitlements.d.ts +2 -2
- package/dist/types/identity.d.ts +48 -2
- package/dist/types/index.d.ts +9 -9
- package/dist/types/ports.d.ts +6 -0
- package/dist/types/schemas/assets.d.ts +65 -37
- package/dist/types/schemas/assets.js +17 -12
- package/dist/types/schemas/assets.js.map +1 -1
- package/dist/types/schemas/automations.d.ts +18 -1
- package/dist/types/schemas/automations.js +15 -6
- package/dist/types/schemas/automations.js.map +1 -1
- package/dist/types/schemas/content.d.ts +335 -3
- package/dist/types/schemas/content.js +139 -3
- package/dist/types/schemas/content.js.map +1 -1
- package/dist/types/schemas/discussion.d.ts +370 -3
- package/dist/types/schemas/discussion.js +199 -4
- package/dist/types/schemas/discussion.js.map +1 -1
- package/dist/types/schemas/entitlements.d.ts +36 -2
- package/dist/types/schemas/entitlements.js +23 -1
- package/dist/types/schemas/entitlements.js.map +1 -1
- package/dist/types/schemas/identity.d.ts +111 -1
- package/dist/types/schemas/identity.js +55 -2
- package/dist/types/schemas/identity.js.map +1 -1
- package/dist/types/schemas/index.d.ts +8 -8
- package/dist/types/schemas/index.js +8 -8
- package/dist/types/schemas/organizations.d.ts +8 -0
- package/dist/types/schemas/organizations.js +2 -0
- package/dist/types/schemas/organizations.js.map +1 -1
- package/dist/types/schemas/shared.d.ts +3 -1
- package/dist/types/schemas/shared.js +5 -1
- package/dist/types/schemas/shared.js.map +1 -1
- package/package.json +2 -2
- package/dist/reporting/courses/index.d.ts +0 -4
- package/dist/reporting/courses/index.js +0 -2
- package/dist/reporting/courses/model.d.ts +0 -24
- package/dist/reporting/courses/ports.d.ts +0 -13
- package/dist/reporting/courses/service.d.ts +0 -19
- package/dist/reporting/courses/service.js +0 -20
- package/dist/reporting/courses/service.js.map +0 -1
- package/dist/reporting/dashboard/index.d.ts +0 -4
- package/dist/reporting/dashboard/index.js +0 -2
- package/dist/reporting/dashboard/model.d.ts +0 -14
- package/dist/reporting/dashboard/ports.d.ts +0 -13
- package/dist/reporting/dashboard/service.d.ts +0 -19
- package/dist/reporting/dashboard/service.js +0 -20
- package/dist/reporting/dashboard/service.js.map +0 -1
- package/dist/reporting/learn/index.d.ts +0 -5
- package/dist/reporting/learn/index.js +0 -2
- package/dist/reporting/learn/model.d.ts +0 -23
- package/dist/reporting/learn/ports.d.ts +0 -43
- package/dist/reporting/learn/ports.js +0 -1
- package/dist/reporting/learn/service.d.ts +0 -49
- package/dist/reporting/learn/service.js +0 -116
- package/dist/reporting/learn/service.js.map +0 -1
- package/dist/reporting/students/index.d.ts +0 -4
- package/dist/reporting/students/index.js +0 -2
- package/dist/reporting/students/model.d.ts +0 -51
- package/dist/reporting/students/model.js +0 -1
- package/dist/reporting/students/ports.d.ts +0 -15
- package/dist/reporting/students/ports.js +0 -1
- package/dist/reporting/students/service.d.ts +0 -20
- package/dist/reporting/students/service.js +0 -23
- package/dist/reporting/students/service.js.map +0 -1
- /package/dist/reporting/{courses → admin}/model.js +0 -0
- /package/dist/reporting/{courses → admin}/ports.js +0 -0
- /package/dist/reporting/{dashboard → member}/model.js +0 -0
- /package/dist/reporting/{dashboard → member}/ports.js +0 -0
- /package/dist/{reporting/learn/model.js → shared/actor.js} +0 -0
package/dist/types/ports.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ interface PresignDownloadInput {
|
|
|
39
39
|
downloadFilename?: string;
|
|
40
40
|
}
|
|
41
41
|
interface ObjectStorage {
|
|
42
|
+
readonly uploadExpirySeconds: number;
|
|
42
43
|
/** Presigned URL for a direct browser upload (temporary, expiring). */
|
|
43
44
|
presignUpload(input: {
|
|
44
45
|
key: string;
|
|
@@ -49,6 +50,11 @@ interface ObjectStorage {
|
|
|
49
50
|
presignDownload(input: PresignDownloadInput): Promise<string>;
|
|
50
51
|
/** Object metadata, or null if it does not exist. */
|
|
51
52
|
stat(key: string): Promise<StoredObjectInfo | null>;
|
|
53
|
+
list(prefix: string): Promise<StoredObjectInfo[]>;
|
|
54
|
+
copy(input: {
|
|
55
|
+
from: string;
|
|
56
|
+
to: string;
|
|
57
|
+
}): Promise<void>;
|
|
52
58
|
/** Permanently remove an object. */
|
|
53
59
|
remove(key: string): Promise<void>;
|
|
54
60
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region src/types/schemas/assets.d.ts
|
|
3
3
|
declare const assetKindSchema: z.ZodEnum<{
|
|
4
|
+
image: "image";
|
|
4
5
|
video: "video";
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
audio: "audio";
|
|
7
|
+
document: "document";
|
|
7
8
|
}>;
|
|
8
9
|
type AssetKind = z.infer<typeof assetKindSchema>;
|
|
10
|
+
declare const assetSourceSchema: z.ZodEnum<{
|
|
11
|
+
library: "library";
|
|
12
|
+
member: "member";
|
|
13
|
+
}>;
|
|
14
|
+
type AssetSource = z.infer<typeof assetSourceSchema>;
|
|
9
15
|
declare const assetStatusSchema: z.ZodEnum<{
|
|
10
16
|
pending: "pending";
|
|
11
17
|
ready: "ready";
|
|
@@ -16,9 +22,14 @@ declare const assetSchema: z.ZodObject<{
|
|
|
16
22
|
id: z.ZodString;
|
|
17
23
|
key: z.ZodString;
|
|
18
24
|
kind: z.ZodEnum<{
|
|
25
|
+
image: "image";
|
|
19
26
|
video: "video";
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
audio: "audio";
|
|
28
|
+
document: "document";
|
|
29
|
+
}>;
|
|
30
|
+
source: z.ZodEnum<{
|
|
31
|
+
library: "library";
|
|
32
|
+
member: "member";
|
|
22
33
|
}>;
|
|
23
34
|
filename: z.ZodString;
|
|
24
35
|
contentType: z.ZodString;
|
|
@@ -33,14 +44,43 @@ declare const assetSchema: z.ZodObject<{
|
|
|
33
44
|
}, z.core.$strict>;
|
|
34
45
|
type Asset = z.output<typeof assetSchema>;
|
|
35
46
|
type AssetInput = z.input<typeof assetSchema>;
|
|
47
|
+
declare const assetViewSchema: z.ZodObject<{
|
|
48
|
+
orgId: z.ZodString;
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
key: z.ZodString;
|
|
51
|
+
kind: z.ZodEnum<{
|
|
52
|
+
image: "image";
|
|
53
|
+
video: "video";
|
|
54
|
+
audio: "audio";
|
|
55
|
+
document: "document";
|
|
56
|
+
}>;
|
|
57
|
+
source: z.ZodEnum<{
|
|
58
|
+
library: "library";
|
|
59
|
+
member: "member";
|
|
60
|
+
}>;
|
|
61
|
+
filename: z.ZodString;
|
|
62
|
+
contentType: z.ZodString;
|
|
63
|
+
size: z.ZodNumber;
|
|
64
|
+
status: z.ZodEnum<{
|
|
65
|
+
pending: "pending";
|
|
66
|
+
ready: "ready";
|
|
67
|
+
}>;
|
|
68
|
+
uploadedBy: z.ZodString;
|
|
69
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
70
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
71
|
+
url: z.ZodNullable<z.ZodString>;
|
|
72
|
+
downloadUrl: z.ZodNullable<z.ZodString>;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
type AssetView = z.output<typeof assetViewSchema>;
|
|
75
|
+
declare const assetUrlsSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
76
|
+
type AssetUrls = z.infer<typeof assetUrlsSchema>;
|
|
36
77
|
declare const requestUploadInputSchema: z.ZodObject<{
|
|
37
78
|
uploadedBy: z.ZodString;
|
|
38
79
|
filename: z.ZodString;
|
|
39
80
|
contentType: z.ZodString;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
content: "content";
|
|
81
|
+
source: z.ZodEnum<{
|
|
82
|
+
library: "library";
|
|
83
|
+
member: "member";
|
|
44
84
|
}>;
|
|
45
85
|
}, z.core.$strict>;
|
|
46
86
|
type RequestUploadInput = z.infer<typeof requestUploadInputSchema>;
|
|
@@ -50,9 +90,14 @@ declare const uploadTicketSchema: z.ZodObject<{
|
|
|
50
90
|
id: z.ZodString;
|
|
51
91
|
key: z.ZodString;
|
|
52
92
|
kind: z.ZodEnum<{
|
|
93
|
+
image: "image";
|
|
53
94
|
video: "video";
|
|
54
|
-
|
|
55
|
-
|
|
95
|
+
audio: "audio";
|
|
96
|
+
document: "document";
|
|
97
|
+
}>;
|
|
98
|
+
source: z.ZodEnum<{
|
|
99
|
+
library: "library";
|
|
100
|
+
member: "member";
|
|
56
101
|
}>;
|
|
57
102
|
filename: z.ZodString;
|
|
58
103
|
contentType: z.ZodString;
|
|
@@ -64,6 +109,8 @@ declare const uploadTicketSchema: z.ZodObject<{
|
|
|
64
109
|
uploadedBy: z.ZodString;
|
|
65
110
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
66
111
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
112
|
+
url: z.ZodNullable<z.ZodString>;
|
|
113
|
+
downloadUrl: z.ZodNullable<z.ZodString>;
|
|
67
114
|
}, z.core.$strict>;
|
|
68
115
|
uploadUrl: z.ZodString;
|
|
69
116
|
method: z.ZodLiteral<"PUT">;
|
|
@@ -71,42 +118,23 @@ declare const uploadTicketSchema: z.ZodObject<{
|
|
|
71
118
|
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
72
119
|
}, z.core.$strict>;
|
|
73
120
|
type UploadTicket = z.infer<typeof uploadTicketSchema>;
|
|
74
|
-
declare const downloadTicketSchema: z.ZodObject<{
|
|
75
|
-
url: z.ZodString;
|
|
76
|
-
asset: z.ZodObject<{
|
|
77
|
-
orgId: z.ZodString;
|
|
78
|
-
id: z.ZodString;
|
|
79
|
-
key: z.ZodString;
|
|
80
|
-
kind: z.ZodEnum<{
|
|
81
|
-
video: "video";
|
|
82
|
-
download: "download";
|
|
83
|
-
content: "content";
|
|
84
|
-
}>;
|
|
85
|
-
filename: z.ZodString;
|
|
86
|
-
contentType: z.ZodString;
|
|
87
|
-
size: z.ZodNumber;
|
|
88
|
-
status: z.ZodEnum<{
|
|
89
|
-
pending: "pending";
|
|
90
|
-
ready: "ready";
|
|
91
|
-
}>;
|
|
92
|
-
uploadedBy: z.ZodString;
|
|
93
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
94
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
95
|
-
}, z.core.$strict>;
|
|
96
|
-
}, z.core.$strict>;
|
|
97
|
-
type DownloadTicket = z.infer<typeof downloadTicketSchema>;
|
|
98
121
|
declare const assetsQuerySchema: z.ZodObject<{
|
|
99
122
|
page: z.ZodNumber;
|
|
100
123
|
pageSize: z.ZodNumber;
|
|
101
124
|
search: z.ZodOptional<z.ZodString>;
|
|
102
125
|
sort: z.ZodOptional<z.ZodString>;
|
|
103
126
|
kind: z.ZodOptional<z.ZodEnum<{
|
|
127
|
+
image: "image";
|
|
104
128
|
video: "video";
|
|
105
|
-
|
|
106
|
-
|
|
129
|
+
audio: "audio";
|
|
130
|
+
document: "document";
|
|
131
|
+
}>>;
|
|
132
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
133
|
+
library: "library";
|
|
134
|
+
member: "member";
|
|
107
135
|
}>>;
|
|
108
136
|
}, z.core.$strict>;
|
|
109
137
|
type AssetsQuery = z.infer<typeof assetsQuerySchema>;
|
|
110
138
|
//#endregion
|
|
111
|
-
export { Asset, AssetInput, AssetKind, AssetStatus,
|
|
139
|
+
export { Asset, AssetInput, AssetKind, AssetSource, AssetStatus, AssetUrls, AssetView, AssetsQuery, RequestUploadInput, UploadTicket, assetKindSchema, assetSchema, assetSourceSchema, assetStatusSchema, assetUrlsSchema, assetViewSchema, assetsQuerySchema, requestUploadInputSchema, uploadTicketSchema };
|
|
112
140
|
//# sourceMappingURL=assets.d.ts.map
|
|
@@ -2,16 +2,19 @@ import { idSchema } from "./shared.js";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/types/schemas/assets.ts
|
|
4
4
|
const assetKindSchema = z.enum([
|
|
5
|
+
"image",
|
|
5
6
|
"video",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
7
|
+
"audio",
|
|
8
|
+
"document"
|
|
8
9
|
]);
|
|
10
|
+
const assetSourceSchema = z.enum(["library", "member"]);
|
|
9
11
|
const assetStatusSchema = z.enum(["pending", "ready"]);
|
|
10
12
|
const assetSchema = z.object({
|
|
11
13
|
orgId: idSchema,
|
|
12
14
|
id: idSchema,
|
|
13
15
|
key: z.string().trim().min(1),
|
|
14
16
|
kind: assetKindSchema,
|
|
17
|
+
source: assetSourceSchema,
|
|
15
18
|
filename: z.string().trim().min(1),
|
|
16
19
|
contentType: z.string().trim().min(1),
|
|
17
20
|
size: z.number().int().min(0),
|
|
@@ -20,31 +23,33 @@ const assetSchema = z.object({
|
|
|
20
23
|
createdAt: z.coerce.date(),
|
|
21
24
|
updatedAt: z.coerce.date()
|
|
22
25
|
}).strict();
|
|
26
|
+
const assetViewSchema = assetSchema.extend({
|
|
27
|
+
url: z.string().nullable(),
|
|
28
|
+
downloadUrl: z.string().nullable()
|
|
29
|
+
}).strict();
|
|
30
|
+
const assetUrlsSchema = z.record(idSchema, z.string());
|
|
23
31
|
const requestUploadInputSchema = z.object({
|
|
24
32
|
uploadedBy: idSchema,
|
|
25
|
-
filename: z.string().trim().min(1),
|
|
26
|
-
contentType: z.string().trim().min(1),
|
|
27
|
-
|
|
33
|
+
filename: z.string().trim().min(1).max(255),
|
|
34
|
+
contentType: z.string().trim().min(1).max(255),
|
|
35
|
+
source: assetSourceSchema
|
|
28
36
|
}).strict();
|
|
29
37
|
const uploadTicketSchema = z.object({
|
|
30
|
-
asset:
|
|
38
|
+
asset: assetViewSchema,
|
|
31
39
|
uploadUrl: z.string().trim().min(1),
|
|
32
40
|
method: z.literal("PUT"),
|
|
33
41
|
expiresInSeconds: z.number().int().positive(),
|
|
34
42
|
headers: z.record(z.string(), z.string())
|
|
35
43
|
}).strict();
|
|
36
|
-
const downloadTicketSchema = z.object({
|
|
37
|
-
url: z.string().trim().min(1),
|
|
38
|
-
asset: assetSchema
|
|
39
|
-
}).strict();
|
|
40
44
|
const assetsQuerySchema = z.object({
|
|
41
45
|
page: z.number().int().min(1),
|
|
42
46
|
pageSize: z.number().int().min(1),
|
|
43
47
|
search: z.string().optional(),
|
|
44
48
|
sort: z.string().optional(),
|
|
45
|
-
kind: assetKindSchema.optional()
|
|
49
|
+
kind: assetKindSchema.optional(),
|
|
50
|
+
source: assetSourceSchema.optional()
|
|
46
51
|
}).strict();
|
|
47
52
|
//#endregion
|
|
48
|
-
export { assetKindSchema, assetSchema, assetStatusSchema,
|
|
53
|
+
export { assetKindSchema, assetSchema, assetSourceSchema, assetStatusSchema, assetUrlsSchema, assetViewSchema, assetsQuerySchema, requestUploadInputSchema, uploadTicketSchema };
|
|
49
54
|
|
|
50
55
|
//# sourceMappingURL=assets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.js","names":[],"sources":["../../../src/types/schemas/assets.ts"],"sourcesContent":["import { z } from 'zod';\nimport { idSchema } from './shared.js';\n\nexport const assetKindSchema = z.enum(['video', '
|
|
1
|
+
{"version":3,"file":"assets.js","names":[],"sources":["../../../src/types/schemas/assets.ts"],"sourcesContent":["import { z } from 'zod';\nimport { idSchema } from './shared.js';\n\nexport const assetKindSchema = z.enum(['image', 'video', 'audio', 'document']);\nexport type AssetKind = z.infer<typeof assetKindSchema>;\n\nexport const assetSourceSchema = z.enum(['library', 'member']);\nexport type AssetSource = z.infer<typeof assetSourceSchema>;\n\nexport const assetStatusSchema = z.enum(['pending', 'ready']);\nexport type AssetStatus = z.infer<typeof assetStatusSchema>;\n\nexport const assetSchema = z\n .object({\n orgId: idSchema,\n id: idSchema,\n key: z.string().trim().min(1),\n kind: assetKindSchema,\n source: assetSourceSchema,\n filename: z.string().trim().min(1),\n contentType: z.string().trim().min(1),\n size: z.number().int().min(0),\n status: assetStatusSchema,\n uploadedBy: idSchema,\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type Asset = z.output<typeof assetSchema>;\nexport type AssetInput = z.input<typeof assetSchema>;\n\nexport const assetViewSchema = assetSchema\n .extend({ url: z.string().nullable(), downloadUrl: z.string().nullable() })\n .strict();\nexport type AssetView = z.output<typeof assetViewSchema>;\n\nexport const assetUrlsSchema = z.record(idSchema, z.string());\nexport type AssetUrls = z.infer<typeof assetUrlsSchema>;\n\nexport const requestUploadInputSchema = z\n .object({\n uploadedBy: idSchema,\n filename: z.string().trim().min(1).max(255),\n contentType: z.string().trim().min(1).max(255),\n source: assetSourceSchema,\n })\n .strict();\nexport type RequestUploadInput = z.infer<typeof requestUploadInputSchema>;\n\nexport const uploadTicketSchema = z\n .object({\n asset: assetViewSchema,\n uploadUrl: z.string().trim().min(1),\n method: z.literal('PUT'),\n expiresInSeconds: z.number().int().positive(),\n headers: z.record(z.string(), z.string()),\n })\n .strict();\nexport type UploadTicket = z.infer<typeof uploadTicketSchema>;\n\nexport const assetsQuerySchema = z\n .object({\n page: z.number().int().min(1),\n pageSize: z.number().int().min(1),\n search: z.string().optional(),\n sort: z.string().optional(),\n kind: assetKindSchema.optional(),\n source: assetSourceSchema.optional(),\n })\n .strict();\nexport type AssetsQuery = z.infer<typeof assetsQuerySchema>;\n"],"mappings":";;;AAGA,MAAa,kBAAkB,EAAE,KAAK;CAAC;CAAS;CAAS;CAAS;AAAU,CAAC;AAG7E,MAAa,oBAAoB,EAAE,KAAK,CAAC,WAAW,QAAQ,CAAC;A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AG,EAAE,OAAO,CAAC;AAC1C,CAAC,CAAC,CACD,OAAO;AAGV,MAAa,oBAAoB,EAC9B,OAAO;CACN,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;CAC5B,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;CAChC,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,MAAM,gBAAgB,SAAS;CAC/B,QAAQ,kBAAkB,SAAS;AACrC,CAAC,CAAC,CACD,OAAO"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { DomainEvent, JsonValue } from "../shared.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/types/schemas/automations.d.ts
|
|
4
|
+
declare const MAX_AUTOMATION_TRIGGERS = 20;
|
|
5
|
+
declare const MAX_AUTOMATION_ACTIONS = 20;
|
|
6
|
+
declare const MAX_WEBHOOK_EVENTS = 100;
|
|
4
7
|
declare const automationTriggerSchema: z.ZodString;
|
|
5
8
|
type AutomationTrigger = z.infer<typeof automationTriggerSchema>;
|
|
6
9
|
declare const automationTriggersSchema: z.ZodArray<z.ZodString>;
|
|
@@ -9,6 +12,11 @@ declare const automationKindSchema: z.ZodEnum<{
|
|
|
9
12
|
webhook: "webhook";
|
|
10
13
|
}>;
|
|
11
14
|
type AutomationKind = z.infer<typeof automationKindSchema>;
|
|
15
|
+
declare const automationSourceSchema: z.ZodEnum<{
|
|
16
|
+
system: "system";
|
|
17
|
+
user: "user";
|
|
18
|
+
}>;
|
|
19
|
+
type AutomationSource = z.infer<typeof automationSourceSchema>;
|
|
12
20
|
declare const automationActionSchema: z.ZodObject<{
|
|
13
21
|
type: z.ZodString;
|
|
14
22
|
input: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
@@ -29,6 +37,11 @@ declare const automationSchema: z.ZodObject<{
|
|
|
29
37
|
input: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
30
38
|
}, z.core.$strict>>;
|
|
31
39
|
enabled: z.ZodBoolean;
|
|
40
|
+
filter: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
|
|
41
|
+
source: z.ZodEnum<{
|
|
42
|
+
system: "system";
|
|
43
|
+
user: "user";
|
|
44
|
+
}>;
|
|
32
45
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
33
46
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
34
47
|
}, z.core.$strict>;
|
|
@@ -42,6 +55,7 @@ declare const createAutomationInputSchema: z.ZodObject<{
|
|
|
42
55
|
type: z.ZodString;
|
|
43
56
|
input: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
44
57
|
}, z.core.$strict>>;
|
|
58
|
+
filter: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>>;
|
|
45
59
|
}, z.core.$strict>;
|
|
46
60
|
type CreateAutomationInput = z.infer<typeof createAutomationInputSchema>;
|
|
47
61
|
declare const updateAutomationInputSchema: z.ZodObject<{
|
|
@@ -52,6 +66,7 @@ declare const updateAutomationInputSchema: z.ZodObject<{
|
|
|
52
66
|
type: z.ZodString;
|
|
53
67
|
input: z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
|
|
54
68
|
}, z.core.$strict>>>;
|
|
69
|
+
filter: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>>>;
|
|
55
70
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
56
71
|
}, z.core.$strict>;
|
|
57
72
|
type UpdateAutomationInput = z.infer<typeof updateAutomationInputSchema>;
|
|
@@ -87,6 +102,7 @@ declare const automationActionResultSchema: z.ZodObject<{
|
|
|
87
102
|
failed: "failed";
|
|
88
103
|
}>;
|
|
89
104
|
error: z.ZodOptional<z.ZodString>;
|
|
105
|
+
recipients: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
90
106
|
}, z.core.$strict>;
|
|
91
107
|
type AutomationActionResult = z.infer<typeof automationActionResultSchema>;
|
|
92
108
|
declare const automationRunSchema: z.ZodObject<{
|
|
@@ -109,6 +125,7 @@ declare const automationRunSchema: z.ZodObject<{
|
|
|
109
125
|
failed: "failed";
|
|
110
126
|
}>;
|
|
111
127
|
error: z.ZodOptional<z.ZodString>;
|
|
128
|
+
recipients: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
112
129
|
}, z.core.$strict>>;
|
|
113
130
|
startedAt: z.ZodCoercedDate<unknown>;
|
|
114
131
|
finishedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
@@ -181,5 +198,5 @@ declare const createdWebhookSchema: z.ZodObject<{
|
|
|
181
198
|
}, z.core.$strict>;
|
|
182
199
|
type CreatedWebhook = z.output<typeof createdWebhookSchema>;
|
|
183
200
|
//#endregion
|
|
184
|
-
export { Automation, AutomationAction, AutomationActionResult, AutomationInput, AutomationKind, AutomationRun, AutomationRunInput, AutomationRunStatus, AutomationRunsQuery, AutomationTrigger, AutomationsQuery, AvailableAction, AvailableActions, AvailableTriggers, CreateAutomationInput, CreateWebhookInput, CreatedWebhook, DeliverWebhookInput, UpdateAutomationInput, UpdateWebhookInput, Webhook, WebhookSecret, automationActionResultSchema, automationActionSchema, automationKindSchema, automationRunSchema, automationRunStatusSchema, automationRunsQuerySchema, automationSchema, automationTriggerSchema, automationTriggersSchema, automationsQuerySchema, availableActionSchema, availableTriggersSchema, createAutomationInputSchema, createWebhookInputSchema, createdWebhookSchema, deliverWebhookInputSchema, updateAutomationInputSchema, updateWebhookInputSchema, webhookSchema, webhookSecretSchema, webhookUrlSchema };
|
|
201
|
+
export { Automation, AutomationAction, AutomationActionResult, AutomationInput, AutomationKind, AutomationRun, AutomationRunInput, AutomationRunStatus, AutomationRunsQuery, AutomationSource, AutomationTrigger, AutomationsQuery, AvailableAction, AvailableActions, AvailableTriggers, CreateAutomationInput, CreateWebhookInput, CreatedWebhook, DeliverWebhookInput, MAX_AUTOMATION_ACTIONS, MAX_AUTOMATION_TRIGGERS, MAX_WEBHOOK_EVENTS, UpdateAutomationInput, UpdateWebhookInput, Webhook, WebhookSecret, automationActionResultSchema, automationActionSchema, automationKindSchema, automationRunSchema, automationRunStatusSchema, automationRunsQuerySchema, automationSchema, automationSourceSchema, automationTriggerSchema, automationTriggersSchema, automationsQuerySchema, availableActionSchema, availableTriggersSchema, createAutomationInputSchema, createWebhookInputSchema, createdWebhookSchema, deliverWebhookInputSchema, updateAutomationInputSchema, updateWebhookInputSchema, webhookSchema, webhookSecretSchema, webhookUrlSchema };
|
|
185
202
|
//# sourceMappingURL=automations.d.ts.map
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { domainEventSchema, idSchema, jsonRecordSchema } from "./shared.js";
|
|
2
|
+
import { isPublicHostname } from "../../shared/network.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
//#region src/types/schemas/automations.ts
|
|
5
|
+
const MAX_AUTOMATION_TRIGGERS = 20;
|
|
6
|
+
const MAX_AUTOMATION_ACTIONS = 20;
|
|
7
|
+
const MAX_WEBHOOK_EVENTS = 100;
|
|
4
8
|
const automationTriggerSchema = z.string().trim().min(1);
|
|
5
|
-
const automationTriggersSchema = z.array(automationTriggerSchema).min(1);
|
|
9
|
+
const automationTriggersSchema = z.array(automationTriggerSchema).min(1).max(20);
|
|
6
10
|
const automationKindSchema = z.enum(["workflow", "webhook"]);
|
|
11
|
+
const automationSourceSchema = z.enum(["system", "user"]);
|
|
7
12
|
const automationActionSchema = z.object({
|
|
8
13
|
type: z.string().trim().min(1),
|
|
9
14
|
input: jsonRecordSchema
|
|
@@ -17,6 +22,8 @@ const automationSchema = z.object({
|
|
|
17
22
|
triggers: z.array(automationTriggerSchema),
|
|
18
23
|
actions: z.array(automationActionSchema),
|
|
19
24
|
enabled: z.boolean(),
|
|
25
|
+
filter: jsonRecordSchema.nullable(),
|
|
26
|
+
source: automationSourceSchema,
|
|
20
27
|
createdAt: z.coerce.date(),
|
|
21
28
|
updatedAt: z.coerce.date()
|
|
22
29
|
}).strict();
|
|
@@ -24,7 +31,8 @@ const createAutomationInputSchema = z.object({
|
|
|
24
31
|
name: z.string(),
|
|
25
32
|
description: z.string().optional(),
|
|
26
33
|
triggers: automationTriggersSchema,
|
|
27
|
-
actions: z.array(automationActionSchema)
|
|
34
|
+
actions: z.array(automationActionSchema).min(1).max(20),
|
|
35
|
+
filter: jsonRecordSchema.nullable().optional()
|
|
28
36
|
}).strict();
|
|
29
37
|
const updateAutomationInputSchema = createAutomationInputSchema.partial().extend({ enabled: z.boolean().optional() });
|
|
30
38
|
const automationsQuerySchema = z.object({ kind: automationKindSchema.optional() }).strict();
|
|
@@ -47,7 +55,8 @@ const automationActionResultSchema = z.object({
|
|
|
47
55
|
index: z.number().int().min(0),
|
|
48
56
|
type: z.string().trim().min(1),
|
|
49
57
|
status: z.enum(["completed", "failed"]),
|
|
50
|
-
error: z.string().optional()
|
|
58
|
+
error: z.string().optional(),
|
|
59
|
+
recipients: z.array(z.string()).optional()
|
|
51
60
|
}).strict();
|
|
52
61
|
const automationRunSchema = z.object({
|
|
53
62
|
orgId: idSchema,
|
|
@@ -79,7 +88,7 @@ const deliverWebhookInputSchema = z.object({
|
|
|
79
88
|
url: z.string(),
|
|
80
89
|
secretRef: idSchema
|
|
81
90
|
}).strict();
|
|
82
|
-
const webhookUrlSchema = z.url({ protocol: /^https?$/ });
|
|
91
|
+
const webhookUrlSchema = z.url({ protocol: /^https?$/ }).refine((value) => isPublicHostname(new URL(value).hostname), { message: "Webhook URL must be a public address, not localhost or a private network address" });
|
|
83
92
|
const webhookSchema = z.object({
|
|
84
93
|
orgId: idSchema,
|
|
85
94
|
id: idSchema,
|
|
@@ -92,13 +101,13 @@ const webhookSchema = z.object({
|
|
|
92
101
|
}).strict();
|
|
93
102
|
const createWebhookInputSchema = z.object({
|
|
94
103
|
url: webhookUrlSchema,
|
|
95
|
-
events:
|
|
104
|
+
events: z.array(automationTriggerSchema).min(1).max(100),
|
|
96
105
|
description: z.string().optional()
|
|
97
106
|
}).strict();
|
|
98
107
|
const updateWebhookInputSchema = createWebhookInputSchema.partial().extend({ enabled: z.boolean().optional() });
|
|
99
108
|
const webhookSecretSchema = z.object({ secret: z.string() }).strict();
|
|
100
109
|
const createdWebhookSchema = webhookSchema.extend({ secret: z.string() }).strict();
|
|
101
110
|
//#endregion
|
|
102
|
-
export { automationActionResultSchema, automationActionSchema, automationKindSchema, automationRunSchema, automationRunStatusSchema, automationRunsQuerySchema, automationSchema, automationTriggerSchema, automationTriggersSchema, automationsQuerySchema, availableActionSchema, availableTriggersSchema, createAutomationInputSchema, createWebhookInputSchema, createdWebhookSchema, deliverWebhookInputSchema, updateAutomationInputSchema, updateWebhookInputSchema, webhookSchema, webhookSecretSchema, webhookUrlSchema };
|
|
111
|
+
export { MAX_AUTOMATION_ACTIONS, MAX_AUTOMATION_TRIGGERS, MAX_WEBHOOK_EVENTS, automationActionResultSchema, automationActionSchema, automationKindSchema, automationRunSchema, automationRunStatusSchema, automationRunsQuerySchema, automationSchema, automationSourceSchema, automationTriggerSchema, automationTriggersSchema, automationsQuerySchema, availableActionSchema, availableTriggersSchema, createAutomationInputSchema, createWebhookInputSchema, createdWebhookSchema, deliverWebhookInputSchema, updateAutomationInputSchema, updateWebhookInputSchema, webhookSchema, webhookSecretSchema, webhookUrlSchema };
|
|
103
112
|
|
|
104
113
|
//# sourceMappingURL=automations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automations.js","names":[],"sources":["../../../src/types/schemas/automations.ts"],"sourcesContent":["import { z } from 'zod';\nimport { domainEventSchema, idSchema, jsonRecordSchema } from './shared.js';\n\nexport const automationTriggerSchema = z.string().trim().min(1);\nexport type AutomationTrigger = z.infer<typeof automationTriggerSchema>;\n\nexport const automationTriggersSchema = z.array(automationTriggerSchema).min(1);\n\nexport const automationKindSchema = z.enum(['workflow', 'webhook']);\nexport type AutomationKind = z.infer<typeof automationKindSchema>;\n\nexport const automationActionSchema = z\n .object({\n type: z.string().trim().min(1),\n input: jsonRecordSchema,\n })\n .strict();\nexport type AutomationAction = z.infer<typeof automationActionSchema>;\n\nexport const automationSchema = z\n .object({\n orgId: idSchema,\n id: idSchema,\n name: z.string(),\n kind: automationKindSchema,\n description: z.string().nullable(),\n triggers: z.array(automationTriggerSchema),\n actions: z.array(automationActionSchema),\n enabled: z.boolean(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type Automation = z.output<typeof automationSchema>;\nexport type AutomationInput = z.input<typeof automationSchema>;\n\nexport const createAutomationInputSchema = z\n .object({\n name: z.string(),\n description: z.string().optional(),\n triggers: automationTriggersSchema,\n actions: z.array(automationActionSchema),\n })\n .strict();\nexport type CreateAutomationInput = z.infer<typeof createAutomationInputSchema>;\n\nexport const updateAutomationInputSchema = createAutomationInputSchema.partial().extend({\n enabled: z.boolean().optional(),\n});\nexport type UpdateAutomationInput = z.infer<typeof updateAutomationInputSchema>;\n\nexport const automationsQuerySchema = z\n .object({\n kind: automationKindSchema.optional(),\n })\n .strict();\nexport type AutomationsQuery = z.infer<typeof automationsQuerySchema>;\n\nexport const automationRunsQuerySchema = z\n .object({\n page: z.number().int().min(1),\n pageSize: z.number().int().min(1),\n status: z.enum(['running', 'completed', 'failed']).optional(),\n sort: z.string().optional(),\n })\n .strict();\nexport type AutomationRunsQuery = z.infer<typeof automationRunsQuerySchema>;\n\nexport const automationRunStatusSchema = z.enum(['running', 'completed', 'failed']);\nexport type AutomationRunStatus = z.infer<typeof automationRunStatusSchema>;\n\nexport const automationActionResultSchema = z\n .object({\n index: z.number().int().min(0),\n type: z.string().trim().min(1),\n status: z.enum(['completed', 'failed']),\n error: z.string().optional(),\n })\n .strict();\nexport type AutomationActionResult = z.infer<typeof automationActionResultSchema>;\n\nexport const automationRunSchema = z\n .object({\n orgId: idSchema,\n id: idSchema,\n automationId: idSchema,\n trigger: automationTriggerSchema,\n eventId: idSchema,\n event: domainEventSchema,\n status: automationRunStatusSchema,\n actionResults: z.array(automationActionResultSchema),\n startedAt: z.coerce.date(),\n finishedAt: z.coerce.date().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type AutomationRun = z.output<typeof automationRunSchema>;\nexport type AutomationRunInput = z.input<typeof automationRunSchema>;\n\nexport const availableActionSchema = z\n .object({\n type: z.string().trim().min(1),\n description: z.string(),\n inputSchema: jsonRecordSchema,\n source: z.string(),\n })\n .strict();\nexport type AvailableAction = z.infer<typeof availableActionSchema>;\nexport type AvailableActions = AvailableAction[];\n\nexport const availableTriggersSchema = z\n .object({\n triggers: z.array(\n z\n .object({\n type: z.string().trim().min(1),\n label: z.string().min(1),\n category: z.string().min(1),\n description: z.string(),\n })\n .strict(),\n ),\n })\n .strict();\nexport type AvailableTriggers = z.infer<typeof availableTriggersSchema>;\n\nexport const deliverWebhookInputSchema = z\n .object({\n url: z.string(),\n secretRef: idSchema,\n })\n .strict();\nexport type DeliverWebhookInput = z.infer<typeof deliverWebhookInputSchema>;\n\nexport const webhookUrlSchema = z.url({ protocol: /^https?$/ });\n\nexport const webhookSchema = z\n .object({\n orgId: idSchema,\n id: idSchema,\n url: z.string(),\n events: z.array(automationTriggerSchema),\n description: z.string().nullable(),\n enabled: z.boolean(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type Webhook = z.output<typeof webhookSchema>;\n\nexport const createWebhookInputSchema = z\n .object({\n url: webhookUrlSchema,\n events:
|
|
1
|
+
{"version":3,"file":"automations.js","names":[],"sources":["../../../src/types/schemas/automations.ts"],"sourcesContent":["import { z } from 'zod';\nimport { isPublicHostname } from '../../shared/network.js';\nimport { domainEventSchema, idSchema, jsonRecordSchema } from './shared.js';\n\nexport const MAX_AUTOMATION_TRIGGERS = 20;\nexport const MAX_AUTOMATION_ACTIONS = 20;\nexport const MAX_WEBHOOK_EVENTS = 100;\n\nexport const automationTriggerSchema = z.string().trim().min(1);\nexport type AutomationTrigger = z.infer<typeof automationTriggerSchema>;\n\nexport const automationTriggersSchema = z\n .array(automationTriggerSchema)\n .min(1)\n .max(MAX_AUTOMATION_TRIGGERS);\n\nexport const automationKindSchema = z.enum(['workflow', 'webhook']);\nexport type AutomationKind = z.infer<typeof automationKindSchema>;\n\nexport const automationSourceSchema = z.enum(['system', 'user']);\nexport type AutomationSource = z.infer<typeof automationSourceSchema>;\n\nexport const automationActionSchema = z\n .object({\n type: z.string().trim().min(1),\n input: jsonRecordSchema,\n })\n .strict();\nexport type AutomationAction = z.infer<typeof automationActionSchema>;\n\nexport const automationSchema = z\n .object({\n orgId: idSchema,\n id: idSchema,\n name: z.string(),\n kind: automationKindSchema,\n description: z.string().nullable(),\n triggers: z.array(automationTriggerSchema),\n actions: z.array(automationActionSchema),\n enabled: z.boolean(),\n filter: jsonRecordSchema.nullable(),\n source: automationSourceSchema,\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type Automation = z.output<typeof automationSchema>;\nexport type AutomationInput = z.input<typeof automationSchema>;\n\nexport const createAutomationInputSchema = z\n .object({\n name: z.string(),\n description: z.string().optional(),\n triggers: automationTriggersSchema,\n actions: z.array(automationActionSchema).min(1).max(MAX_AUTOMATION_ACTIONS),\n filter: jsonRecordSchema.nullable().optional(),\n })\n .strict();\nexport type CreateAutomationInput = z.infer<typeof createAutomationInputSchema>;\n\nexport const updateAutomationInputSchema = createAutomationInputSchema.partial().extend({\n enabled: z.boolean().optional(),\n});\nexport type UpdateAutomationInput = z.infer<typeof updateAutomationInputSchema>;\n\nexport const automationsQuerySchema = z\n .object({\n kind: automationKindSchema.optional(),\n })\n .strict();\nexport type AutomationsQuery = z.infer<typeof automationsQuerySchema>;\n\nexport const automationRunsQuerySchema = z\n .object({\n page: z.number().int().min(1),\n pageSize: z.number().int().min(1),\n status: z.enum(['running', 'completed', 'failed']).optional(),\n sort: z.string().optional(),\n })\n .strict();\nexport type AutomationRunsQuery = z.infer<typeof automationRunsQuerySchema>;\n\nexport const automationRunStatusSchema = z.enum(['running', 'completed', 'failed']);\nexport type AutomationRunStatus = z.infer<typeof automationRunStatusSchema>;\n\nexport const automationActionResultSchema = z\n .object({\n index: z.number().int().min(0),\n type: z.string().trim().min(1),\n status: z.enum(['completed', 'failed']),\n error: z.string().optional(),\n recipients: z.array(z.string()).optional(),\n })\n .strict();\nexport type AutomationActionResult = z.infer<typeof automationActionResultSchema>;\n\nexport const automationRunSchema = z\n .object({\n orgId: idSchema,\n id: idSchema,\n automationId: idSchema,\n trigger: automationTriggerSchema,\n eventId: idSchema,\n event: domainEventSchema,\n status: automationRunStatusSchema,\n actionResults: z.array(automationActionResultSchema),\n startedAt: z.coerce.date(),\n finishedAt: z.coerce.date().nullable(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type AutomationRun = z.output<typeof automationRunSchema>;\nexport type AutomationRunInput = z.input<typeof automationRunSchema>;\n\nexport const availableActionSchema = z\n .object({\n type: z.string().trim().min(1),\n description: z.string(),\n inputSchema: jsonRecordSchema,\n source: z.string(),\n })\n .strict();\nexport type AvailableAction = z.infer<typeof availableActionSchema>;\nexport type AvailableActions = AvailableAction[];\n\nexport const availableTriggersSchema = z\n .object({\n triggers: z.array(\n z\n .object({\n type: z.string().trim().min(1),\n label: z.string().min(1),\n category: z.string().min(1),\n description: z.string(),\n })\n .strict(),\n ),\n })\n .strict();\nexport type AvailableTriggers = z.infer<typeof availableTriggersSchema>;\n\nexport const deliverWebhookInputSchema = z\n .object({\n url: z.string(),\n secretRef: idSchema,\n })\n .strict();\nexport type DeliverWebhookInput = z.infer<typeof deliverWebhookInputSchema>;\n\nexport const webhookUrlSchema = z\n .url({ protocol: /^https?$/ })\n .refine((value) => isPublicHostname(new URL(value).hostname), {\n message: 'Webhook URL must be a public address, not localhost or a private network address',\n });\n\nexport const webhookSchema = z\n .object({\n orgId: idSchema,\n id: idSchema,\n url: z.string(),\n events: z.array(automationTriggerSchema),\n description: z.string().nullable(),\n enabled: z.boolean(),\n createdAt: z.coerce.date(),\n updatedAt: z.coerce.date(),\n })\n .strict();\nexport type Webhook = z.output<typeof webhookSchema>;\n\nexport const createWebhookInputSchema = z\n .object({\n url: webhookUrlSchema,\n events: z.array(automationTriggerSchema).min(1).max(MAX_WEBHOOK_EVENTS),\n description: z.string().optional(),\n })\n .strict();\nexport type CreateWebhookInput = z.infer<typeof createWebhookInputSchema>;\n\nexport const updateWebhookInputSchema = createWebhookInputSchema.partial().extend({\n enabled: z.boolean().optional(),\n});\nexport type UpdateWebhookInput = z.infer<typeof updateWebhookInputSchema>;\n\nexport const webhookSecretSchema = z\n .object({\n secret: z.string(),\n })\n .strict();\nexport type WebhookSecret = z.infer<typeof webhookSecretSchema>;\n\nexport const createdWebhookSchema = webhookSchema.extend({ secret: z.string() }).strict();\nexport type CreatedWebhook = z.output<typeof createdWebhookSchema>;\n"],"mappings":";;;;AAIA,MAAa,0BAA0B;AACvC,MAAa,yBAAyB;AACtC,MAAa,qBAAqB;AAElC,MAAa,0BAA0B,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AAG9D,MAAa,2BAA2B,EACrC,MAAM,uBAAuB,CAAC,CAC9B,IAAI,CAAC,CAAC,CACN,IAAA,EAA2B;AAE9B,MAAa,uBAAuB,EAAE,KAAK,CAAC,YAAY,SAAS,CAAC;AAGlE,MAAa,yBAAyB,EAAE,KAAK,CAAC,UAAU,MAAM,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