@schemavaults/send-email-api-options 0.0.4 → 0.0.5

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/bun.lock CHANGED
@@ -11,7 +11,7 @@
11
11
  "@eslint/js": "9.39.1",
12
12
  "@typescript-eslint/eslint-plugin": "8.48.1",
13
13
  "@typescript-eslint/parser": "8.48.1",
14
- "bun-types": "1.3.6",
14
+ "bun-types": "1.3.11",
15
15
  "eslint": "9.39.1",
16
16
  "globals": "16.5.0",
17
17
  "tsc-alias": "1.8.16",
@@ -100,7 +100,7 @@
100
100
 
101
101
  "braces": ["braces@3.0.3", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="],
102
102
 
103
- "bun-types": ["bun-types@1.3.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ=="],
103
+ "bun-types": ["bun-types@1.3.11", "", { "dependencies": { "@types/node": "*" } }, "sha512-1KGPpoxQWl9f6wcZh57LvrPIInQMn2TQ7jsgxqpRzg+l0QPOFvJVH7HmvHo/AiPgwXy+/Thf6Ov3EdVn1vOabg=="],
104
104
 
105
105
  "callsites": ["callsites@3.1.0", "", {}, "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="],
106
106
 
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { sendEmailRequestBodySchema, sendEmailRequestBodySchema as default, } from "./send-email-request-body-schema";
1
+ export { sendEmailRequestBodySchema, sendEmailRequestBodySchema as default, createSendEmailRequestBodySchema, } from "./send-email-request-body-schema";
2
2
  export type { SendEmailRequestBody } from "./send-email-request-body-schema";
3
+ export { emailTemplateIdSchema } from "./email-template-id-schema";
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export { sendEmailRequestBodySchema, sendEmailRequestBodySchema as default, } from "./send-email-request-body-schema";
1
+ export { sendEmailRequestBodySchema, sendEmailRequestBodySchema as default, createSendEmailRequestBodySchema, } from "./send-email-request-body-schema";
2
+ export { emailTemplateIdSchema } from "./email-template-id-schema";
2
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,IAAI,OAAO,GACtC,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,IAAI,OAAO,EACrC,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -1,4 +1,72 @@
1
1
  import { z } from "zod";
2
+ export declare function createRecipientSchema(allow_mailing_list_ids_as_recipients?: boolean): z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodString]> | z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
3
+ /**
4
+ *
5
+ * @param allow_mailing_list_ids_as_recipients
6
+ * @returns Schema for validating send-email request body
7
+ */
8
+ export declare function createSendEmailRequestBodySchema(allow_mailing_list_ids_as_recipients?: boolean): z.ZodObject<{
9
+ message: z.ZodUnion<[z.ZodObject<{
10
+ template_id: z.ZodString;
11
+ template_props: z.ZodUnknown;
12
+ }, "strict", z.ZodTypeAny, {
13
+ template_id: string;
14
+ template_props?: unknown;
15
+ }, {
16
+ template_id: string;
17
+ template_props?: unknown;
18
+ }>, z.ZodObject<{
19
+ text: z.ZodString;
20
+ html: z.ZodString;
21
+ }, "strict", z.ZodTypeAny, {
22
+ text: string;
23
+ html: string;
24
+ }, {
25
+ text: string;
26
+ html: string;
27
+ }>]>;
28
+ to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodString]> | z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
29
+ from: z.ZodOptional<z.ZodString>;
30
+ subject: z.ZodString;
31
+ replyTo: z.ZodOptional<z.ZodString>;
32
+ cc: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
33
+ bcc: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
34
+ }, "strict", z.ZodTypeAny, {
35
+ message: {
36
+ template_id: string;
37
+ template_props?: unknown;
38
+ } | {
39
+ text: string;
40
+ html: string;
41
+ };
42
+ to: string | string[];
43
+ subject: string;
44
+ from?: string | undefined;
45
+ replyTo?: string | undefined;
46
+ cc?: string | string[] | undefined;
47
+ bcc?: string | string[] | undefined;
48
+ }, {
49
+ message: {
50
+ template_id: string;
51
+ template_props?: unknown;
52
+ } | {
53
+ text: string;
54
+ html: string;
55
+ };
56
+ to: string | string[];
57
+ subject: string;
58
+ from?: string | undefined;
59
+ replyTo?: string | undefined;
60
+ cc?: string | string[] | undefined;
61
+ bcc?: string | string[] | undefined;
62
+ }>;
63
+ /**
64
+ * Default send email request body schema
65
+ * @see createSendEmailRequestBodySchema
66
+ *
67
+ * This schema will not allow "to: <mailing_list_uuid>"-- use createSendEmailRequestBodySchema
68
+ * with allow_mailing_list_ids_as_recipients = true to accept UUIDs
69
+ */
2
70
  export declare const sendEmailRequestBodySchema: z.ZodObject<{
3
71
  message: z.ZodUnion<[z.ZodObject<{
4
72
  template_id: z.ZodString;
@@ -19,7 +87,7 @@ export declare const sendEmailRequestBodySchema: z.ZodObject<{
19
87
  text: string;
20
88
  html: string;
21
89
  }>]>;
22
- to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
90
+ to: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">, z.ZodString]> | z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
23
91
  from: z.ZodOptional<z.ZodString>;
24
92
  subject: z.ZodString;
25
93
  replyTo: z.ZodOptional<z.ZodString>;
@@ -55,3 +123,4 @@ export declare const sendEmailRequestBodySchema: z.ZodObject<{
55
123
  bcc?: string | string[] | undefined;
56
124
  }>;
57
125
  export type SendEmailRequestBody = z.infer<typeof sendEmailRequestBodySchema>;
126
+ export default createSendEmailRequestBodySchema;
@@ -20,33 +20,61 @@ const sendRawEmailOptions = z
20
20
  })
21
21
  .strict();
22
22
  const MAX_RECIPIENTS = 50;
23
- export const sendEmailRequestBodySchema = z
24
- .object({
25
- to: z.union([
26
- z.string().email(),
27
- z.string().email().array().min(1).max(MAX_RECIPIENTS),
28
- ]),
29
- from: z.string().email().optional(),
30
- subject: z.string().nonempty(),
31
- message: z.union([sendEmailTemplateOptions, sendRawEmailOptions]),
32
- replyTo: z.string().email().optional(),
33
- cc: z
34
- .union([
35
- z.string().email(),
36
- z.string().email().array().min(1).max(MAX_RECIPIENTS),
37
- ])
38
- .optional(),
39
- bcc: z
40
- .union([
41
- z.string().email(),
42
- z.string().email().array().min(1).max(MAX_RECIPIENTS),
43
- ])
44
- .optional(),
45
- })
46
- .required({
47
- to: true,
48
- message: true,
49
- subject: true,
50
- })
51
- .strict();
23
+ export function createRecipientSchema(allow_mailing_list_ids_as_recipients = false) {
24
+ if (allow_mailing_list_ids_as_recipients) {
25
+ return z.union([
26
+ z.string().email(), // single recipient
27
+ z.string().email().array().min(1).max(MAX_RECIPIENTS), // multi recipient
28
+ z.string().uuid(), // mailing list id as recipient
29
+ ]);
30
+ }
31
+ else {
32
+ return z.union([
33
+ z.string().email(), // single recipient
34
+ z.string().email().array().min(1).max(MAX_RECIPIENTS), // multi recipient
35
+ ]);
36
+ }
37
+ }
38
+ /**
39
+ *
40
+ * @param allow_mailing_list_ids_as_recipients
41
+ * @returns Schema for validating send-email request body
42
+ */
43
+ export function createSendEmailRequestBodySchema(allow_mailing_list_ids_as_recipients = false) {
44
+ return z
45
+ .object({
46
+ to: createRecipientSchema(allow_mailing_list_ids_as_recipients),
47
+ from: z.string().email().optional(),
48
+ subject: z.string().nonempty(),
49
+ message: z.union([sendEmailTemplateOptions, sendRawEmailOptions]),
50
+ replyTo: z.string().email().optional(),
51
+ cc: z
52
+ .union([
53
+ z.string().email(),
54
+ z.string().email().array().min(1).max(MAX_RECIPIENTS),
55
+ ])
56
+ .optional(),
57
+ bcc: z
58
+ .union([
59
+ z.string().email(),
60
+ z.string().email().array().min(1).max(MAX_RECIPIENTS),
61
+ ])
62
+ .optional(),
63
+ })
64
+ .required({
65
+ to: true,
66
+ message: true,
67
+ subject: true,
68
+ })
69
+ .strict();
70
+ }
71
+ /**
72
+ * Default send email request body schema
73
+ * @see createSendEmailRequestBodySchema
74
+ *
75
+ * This schema will not allow "to: <mailing_list_uuid>"-- use createSendEmailRequestBodySchema
76
+ * with allow_mailing_list_ids_as_recipients = true to accept UUIDs
77
+ */
78
+ export const sendEmailRequestBodySchema = createSendEmailRequestBodySchema();
79
+ export default createSendEmailRequestBodySchema;
52
80
  //# sourceMappingURL=send-email-request-body-schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"send-email-request-body-schema.js","sourceRoot":"","sources":["../src/send-email-request-body-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,wBAAwB,GAAG,CAAC;KAC/B,MAAM,CAAC;IACN,WAAW,EAAE,qBAAqB;IAClC,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;CAC5B,CAAC;KACD,QAAQ,CAAC;IACR,WAAW,EAAE,IAAI;CAClB,CAAC;KACD,MAAM,EAAE,CAAC;A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,KAAK,EAAE;QAClB,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC;KACtD,CAAC;SACD,QAAQ,EAAE;CACd,CAAC;KACD,QAAQ,CAAC;IACR,EAAE,EAAE,IAAI;IACR,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;CACd,CAAC;KACD,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"send-email-request-body-schema.js","sourceRoot":"","sources":["../src/send-email-request-body-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,wBAAwB,GAAG,CAAC;KAC/B,MAAM,CAAC;IACN,WAAW,EAAE,qBAAqB;IAClC,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;CAC5B,CAAC;KACD,QAAQ,CAAC;IACR,WAAW,EAAE,IAAI;CAClB,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,mBAAmB,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC;KACD,QAAQ,CAAC;IACR,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;CACX,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,cAAc,GAAW,EAAE,CAAC;AAElC,MAAM,UAAU,qBAAqB,CACnC,uCAAgD,KAAK;IAErD,IAAI,oCAAoC,EAAE,CAAC;QACzC,OAAO,CAAC,CAAC,KAAK,CAAC;YACb,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,mBAAmB;YACvC,CAAC,CAAC,MAAM,EAAE,CAAC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AC,MAAM,EAAE,CAAC,KAAK,EAAE;YAClB,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC;SACtD,CAAC;aACD,QAAQ,EAAE;KACd,CAAC;SACD,QAAQ,CAAC;QACR,EAAE,EAAE,IAAI;QACR,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;KACd,CAAC;SACD,MAAM,EAAE,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,EAAE,CAAC;AAI7E,eAAe,gCAAgC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@schemavaults/send-email-api-options",
3
3
  "description": "Schema defining the shape of the request body to send an email via @schemavaults/mail-server",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
7
7
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "devDependencies": {
28
28
  "typescript": "5.9.3",
29
29
  "tsc-alias": "1.8.16",
30
- "bun-types": "1.3.6",
30
+ "bun-types": "1.3.11",
31
31
  "eslint": "9.39.1",
32
32
  "@eslint/js": "9.39.1",
33
33
  "globals": "16.5.0",
@@ -37,7 +37,6 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "packageManager": "bun@1.3.6",
41
40
  "exports": {
42
41
  ".": {
43
42
  "types": "./dist/index.d.ts",
@@ -54,5 +53,6 @@
54
53
  "import": "./dist/*",
55
54
  "require": "./dist/*"
56
55
  }
57
- }
56
+ },
57
+ "packageManager": "bun@1.3.11"
58
58
  }