@orion-studios/payload-studio 0.6.0-beta.9 → 0.7.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.
Files changed (66) hide show
  1. package/README.md +6 -1
  2. package/bin/init.js +329 -0
  3. package/dist/admin/client.js +2106 -585
  4. package/dist/admin/client.mjs +2161 -653
  5. package/dist/admin/index.d.mts +2 -2
  6. package/dist/admin/index.d.ts +2 -2
  7. package/dist/admin/index.js +190 -36
  8. package/dist/admin/index.mjs +2 -2
  9. package/dist/admin-app/client.js +14 -5
  10. package/dist/admin-app/client.mjs +1 -1
  11. package/dist/admin-app/index.d.mts +2 -2
  12. package/dist/admin-app/index.d.ts +2 -2
  13. package/dist/admin-app/styles.css +361 -41
  14. package/dist/admin.css +98 -2
  15. package/dist/blocks/index.mjs +1 -2
  16. package/dist/builder-v2/client.d.mts +18 -0
  17. package/dist/builder-v2/client.d.ts +18 -0
  18. package/dist/builder-v2/client.js +4287 -0
  19. package/dist/builder-v2/client.mjs +4162 -0
  20. package/dist/builder-v2/index.d.mts +249 -0
  21. package/dist/builder-v2/index.d.ts +249 -0
  22. package/dist/builder-v2/index.js +836 -0
  23. package/dist/builder-v2/index.mjs +786 -0
  24. package/dist/builder-v2/styles.css +2705 -0
  25. package/dist/{chunk-PF3EBZXF.mjs → chunk-7ZMXZRBP.mjs} +39 -3
  26. package/dist/{chunk-XKUTZ7IU.mjs → chunk-DTHBPJXU.mjs} +246 -25
  27. package/dist/{chunk-JQAHXYAM.mjs → chunk-KMYMSR7W.mjs} +163 -3
  28. package/dist/{chunk-WLOPFFN2.mjs → chunk-MMJNHBOF.mjs} +193 -39
  29. package/dist/{chunk-KPIX7OSV.mjs → chunk-NF37A575.mjs} +14 -5
  30. package/dist/{chunk-OTHERBGX.mjs → chunk-OF6BATTO.mjs} +57 -112
  31. package/dist/chunk-VA545CHJ.mjs +202 -0
  32. package/dist/forms/index.d.mts +25 -0
  33. package/dist/forms/index.d.ts +25 -0
  34. package/dist/forms/index.js +237 -0
  35. package/dist/forms/index.mjs +25 -0
  36. package/dist/forms/server.d.mts +35 -0
  37. package/dist/forms/server.d.ts +35 -0
  38. package/dist/forms/server.js +442 -0
  39. package/dist/forms/server.mjs +228 -0
  40. package/dist/{index-Crx_MtPw.d.ts → index-0xXWuOuz.d.ts} +38 -6
  41. package/dist/{index-Cv-6qnrw.d.mts → index-BU82akSL.d.mts} +38 -6
  42. package/dist/{index-Bm2SaC3r.d.mts → index-BbTcimgH.d.mts} +4 -2
  43. package/dist/{index-D8BNfUJb.d.mts → index-Cen-9wcc.d.mts} +17 -5
  44. package/dist/{index-52HdVLQq.d.ts → index-DAdN56fM.d.ts} +1 -1
  45. package/dist/{index-CkT_eyhK.d.ts → index-DV-nW43e.d.ts} +4 -2
  46. package/dist/{index-DEQC3Dwj.d.mts → index-G_uTNffQ.d.mts} +1 -1
  47. package/dist/{index-DD_E2UfJ.d.ts → index-gxcMPpm-.d.ts} +17 -5
  48. package/dist/index.d.mts +5 -5
  49. package/dist/index.d.ts +5 -5
  50. package/dist/index.js +522 -171
  51. package/dist/index.mjs +10 -11
  52. package/dist/nextjs/index.d.mts +1 -1
  53. package/dist/nextjs/index.d.ts +1 -1
  54. package/dist/nextjs/index.js +95 -114
  55. package/dist/nextjs/index.mjs +2 -2
  56. package/dist/{sitePreviewTypes-BkHCWxNW.d.mts → sitePreviewTypes-BrJwGzJj.d.mts} +1 -1
  57. package/dist/{sitePreviewTypes-BkHCWxNW.d.ts → sitePreviewTypes-BrJwGzJj.d.ts} +1 -1
  58. package/dist/studio-pages/builder.css +66 -5
  59. package/dist/studio-pages/client.js +618 -73
  60. package/dist/studio-pages/client.mjs +641 -96
  61. package/dist/studio-pages/index.d.mts +1 -1
  62. package/dist/studio-pages/index.d.ts +1 -1
  63. package/dist/studio-pages/index.js +1893 -24
  64. package/dist/studio-pages/index.mjs +11 -3
  65. package/package.json +38 -3
  66. package/dist/chunk-OQSEJXC4.mjs +0 -166
@@ -0,0 +1,202 @@
1
+ // src/forms/validation.ts
2
+ var MAJOR_EMAIL_PROVIDERS = [
3
+ "gmail.com",
4
+ "yahoo.com",
5
+ "outlook.com",
6
+ "hotmail.com",
7
+ "icloud.com",
8
+ "live.com",
9
+ "protonmail.com"
10
+ ];
11
+ var KNOWN_GOOD_DOMAINS = /* @__PURE__ */ new Set([
12
+ ...MAJOR_EMAIL_PROVIDERS,
13
+ "aol.com",
14
+ "gmx.com",
15
+ "googlemail.com",
16
+ "hey.com",
17
+ "mac.com",
18
+ "mail.com",
19
+ "me.com",
20
+ "msn.com",
21
+ "pm.me",
22
+ "proton.me",
23
+ "ymail.com",
24
+ "zoho.com"
25
+ ]);
26
+ var EXPLICIT_TYPO_MAP = {
27
+ "gamil.com": "gmail.com",
28
+ "gmial.com": "gmail.com",
29
+ "gmai.com": "gmail.com",
30
+ "gmaill.com": "gmail.com",
31
+ "gmail.co": "gmail.com",
32
+ "gmail.con": "gmail.com",
33
+ "gmail.cmo": "gmail.com",
34
+ "hotmial.com": "hotmail.com",
35
+ "hotmall.com": "hotmail.com",
36
+ "hotmail.co": "hotmail.com",
37
+ "hotmail.con": "hotmail.com",
38
+ "iclod.com": "icloud.com",
39
+ "icloud.co": "icloud.com",
40
+ "icoud.com": "icloud.com",
41
+ "outlok.com": "outlook.com",
42
+ "outloook.com": "outlook.com",
43
+ "outlook.co": "outlook.com",
44
+ "outlook.con": "outlook.com",
45
+ "protonmail.co": "protonmail.com",
46
+ "yaho.com": "yahoo.com",
47
+ "yahooo.com": "yahoo.com",
48
+ "yahoo.co": "yahoo.com",
49
+ "yahoo.con": "yahoo.com"
50
+ };
51
+ var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
52
+ function levenshtein(a, b) {
53
+ if (a === b) return 0;
54
+ const rows = a.length + 1;
55
+ const cols = b.length + 1;
56
+ const dist = Array.from({ length: cols }, (_, j) => j);
57
+ for (let i = 1; i < rows; i += 1) {
58
+ let prevDiagonal = dist[0];
59
+ dist[0] = i;
60
+ for (let j = 1; j < cols; j += 1) {
61
+ const temp = dist[j];
62
+ dist[j] = Math.min(
63
+ dist[j] + 1,
64
+ dist[j - 1] + 1,
65
+ prevDiagonal + (a[i - 1] === b[j - 1] ? 0 : 1)
66
+ );
67
+ prevDiagonal = temp;
68
+ }
69
+ }
70
+ return dist[cols - 1];
71
+ }
72
+ function normalizeEmail(value) {
73
+ return value.trim().toLowerCase();
74
+ }
75
+ function validateEmail(value, options = {}) {
76
+ const normalized = normalizeEmail(value);
77
+ if (normalized.length === 0) {
78
+ return { valid: false, normalized, message: "Email is required." };
79
+ }
80
+ if (!EMAIL_PATTERN.test(normalized)) {
81
+ return { valid: false, normalized, message: "Enter a valid email address." };
82
+ }
83
+ const [localPart, domain] = normalized.split("@");
84
+ const knownGood = options.knownGoodDomains ? /* @__PURE__ */ new Set([...KNOWN_GOOD_DOMAINS, ...options.knownGoodDomains.map((entry) => entry.toLowerCase())]) : KNOWN_GOOD_DOMAINS;
85
+ if (knownGood.has(domain)) {
86
+ return { valid: true, normalized };
87
+ }
88
+ const explicitCorrection = EXPLICIT_TYPO_MAP[domain];
89
+ if (explicitCorrection) {
90
+ const suggestion = `${localPart}@${explicitCorrection}`;
91
+ return {
92
+ valid: false,
93
+ normalized,
94
+ message: `Did you mean ${suggestion}?`,
95
+ suggestion
96
+ };
97
+ }
98
+ for (const provider of MAJOR_EMAIL_PROVIDERS) {
99
+ if (levenshtein(domain, provider) === 1) {
100
+ const suggestion = `${localPart}@${provider}`;
101
+ return {
102
+ valid: false,
103
+ normalized,
104
+ message: `Did you mean ${suggestion}?`,
105
+ suggestion
106
+ };
107
+ }
108
+ }
109
+ return { valid: true, normalized };
110
+ }
111
+ function normalizePhone(value) {
112
+ const digits = value.replace(/\D+/g, "");
113
+ if (digits.length === 11 && digits.startsWith("1")) {
114
+ return digits.slice(1);
115
+ }
116
+ return digits;
117
+ }
118
+ function formatPhoneUS(value) {
119
+ const digits = normalizePhone(value).slice(0, 10);
120
+ if (digits.length === 0) return "";
121
+ if (digits.length < 4) return `(${digits}`;
122
+ if (digits.length < 7) return `(${digits.slice(0, 3)}) ${digits.slice(3)}`;
123
+ return `(${digits.slice(0, 3)}) ${digits.slice(3, 6)}-${digits.slice(6)}`;
124
+ }
125
+ function validatePhoneUS(value) {
126
+ const digits = normalizePhone(value);
127
+ if (digits.length === 0) {
128
+ return { valid: false, normalized: "", message: "Phone number is required." };
129
+ }
130
+ if (digits.length !== 10) {
131
+ return { valid: false, normalized: digits, message: "Enter a 10-digit phone number." };
132
+ }
133
+ return { valid: true, normalized: digits };
134
+ }
135
+ function normalizeUrl(value) {
136
+ const trimmed = value.trim();
137
+ if (trimmed.length === 0) return "";
138
+ if (/^https?:\/\//i.test(trimmed)) return trimmed;
139
+ return `https://${trimmed}`;
140
+ }
141
+ function validateUrl(value) {
142
+ const normalized = normalizeUrl(value);
143
+ if (normalized.length === 0) {
144
+ return { valid: false, normalized, message: "URL is required." };
145
+ }
146
+ try {
147
+ const parsed = new URL(normalized);
148
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
149
+ return { valid: false, normalized, message: "Enter a valid web address." };
150
+ }
151
+ if (!parsed.hostname.includes(".")) {
152
+ return { valid: false, normalized, message: "Enter a valid web address." };
153
+ }
154
+ return { valid: true, normalized };
155
+ } catch {
156
+ return { valid: false, normalized, message: "Enter a valid web address." };
157
+ }
158
+ }
159
+ function validateRequired(value, label = "This field") {
160
+ const normalized = typeof value === "string" ? value.trim() : "";
161
+ const present = typeof value === "string" ? normalized.length > 0 : Array.isArray(value) ? value.length > 0 : value !== null && value !== void 0 && value !== false;
162
+ if (!present) {
163
+ return { valid: false, normalized, message: `${label} is required.` };
164
+ }
165
+ return { valid: true, normalized: typeof value === "string" ? normalized : String(value) };
166
+ }
167
+ function normalizeFieldValue(value, fieldType) {
168
+ switch (fieldType) {
169
+ case "email":
170
+ return normalizeEmail(value);
171
+ case "phone":
172
+ return normalizePhone(value);
173
+ case "url":
174
+ return normalizeUrl(value);
175
+ default:
176
+ return value.trim();
177
+ }
178
+ }
179
+ function inferFieldType(field) {
180
+ const type = typeof field.type === "string" ? field.type.toLowerCase() : "";
181
+ if (type === "email" || type === "phone" || type === "tel" || type === "url") {
182
+ return type === "tel" ? "phone" : type;
183
+ }
184
+ const name = typeof field.name === "string" ? field.name.toLowerCase() : "";
185
+ if (name.includes("email")) return "email";
186
+ if (name.includes("phone") || name.includes("mobile")) return "phone";
187
+ if (name.includes("website") || name.endsWith("url")) return "url";
188
+ return "text";
189
+ }
190
+
191
+ export {
192
+ normalizeEmail,
193
+ validateEmail,
194
+ normalizePhone,
195
+ formatPhoneUS,
196
+ validatePhoneUS,
197
+ normalizeUrl,
198
+ validateUrl,
199
+ validateRequired,
200
+ normalizeFieldValue,
201
+ inferFieldType
202
+ };
@@ -0,0 +1,25 @@
1
+ type FieldValidationResult = {
2
+ valid: boolean;
3
+ normalized: string;
4
+ message?: string;
5
+ suggestion?: string;
6
+ };
7
+ declare function normalizeEmail(value: string): string;
8
+ type ValidateEmailOptions = {
9
+ knownGoodDomains?: string[];
10
+ };
11
+ declare function validateEmail(value: string, options?: ValidateEmailOptions): FieldValidationResult;
12
+ declare function normalizePhone(value: string): string;
13
+ declare function formatPhoneUS(value: string): string;
14
+ declare function validatePhoneUS(value: string): FieldValidationResult;
15
+ declare function normalizeUrl(value: string): string;
16
+ declare function validateUrl(value: string): FieldValidationResult;
17
+ declare function validateRequired(value: unknown, label?: string): FieldValidationResult;
18
+ type StudioFormFieldType = 'email' | 'phone' | 'url' | 'text';
19
+ declare function normalizeFieldValue(value: string, fieldType: StudioFormFieldType): string;
20
+ declare function inferFieldType(field: {
21
+ name?: unknown;
22
+ type?: unknown;
23
+ }): StudioFormFieldType;
24
+
25
+ export { type FieldValidationResult, type StudioFormFieldType, type ValidateEmailOptions, formatPhoneUS, inferFieldType, normalizeEmail, normalizeFieldValue, normalizePhone, normalizeUrl, validateEmail, validatePhoneUS, validateRequired, validateUrl };
@@ -0,0 +1,25 @@
1
+ type FieldValidationResult = {
2
+ valid: boolean;
3
+ normalized: string;
4
+ message?: string;
5
+ suggestion?: string;
6
+ };
7
+ declare function normalizeEmail(value: string): string;
8
+ type ValidateEmailOptions = {
9
+ knownGoodDomains?: string[];
10
+ };
11
+ declare function validateEmail(value: string, options?: ValidateEmailOptions): FieldValidationResult;
12
+ declare function normalizePhone(value: string): string;
13
+ declare function formatPhoneUS(value: string): string;
14
+ declare function validatePhoneUS(value: string): FieldValidationResult;
15
+ declare function normalizeUrl(value: string): string;
16
+ declare function validateUrl(value: string): FieldValidationResult;
17
+ declare function validateRequired(value: unknown, label?: string): FieldValidationResult;
18
+ type StudioFormFieldType = 'email' | 'phone' | 'url' | 'text';
19
+ declare function normalizeFieldValue(value: string, fieldType: StudioFormFieldType): string;
20
+ declare function inferFieldType(field: {
21
+ name?: unknown;
22
+ type?: unknown;
23
+ }): StudioFormFieldType;
24
+
25
+ export { type FieldValidationResult, type StudioFormFieldType, type ValidateEmailOptions, formatPhoneUS, inferFieldType, normalizeEmail, normalizeFieldValue, normalizePhone, normalizeUrl, validateEmail, validatePhoneUS, validateRequired, validateUrl };
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/forms/index.ts
21
+ var forms_exports = {};
22
+ __export(forms_exports, {
23
+ formatPhoneUS: () => formatPhoneUS,
24
+ inferFieldType: () => inferFieldType,
25
+ normalizeEmail: () => normalizeEmail,
26
+ normalizeFieldValue: () => normalizeFieldValue,
27
+ normalizePhone: () => normalizePhone,
28
+ normalizeUrl: () => normalizeUrl,
29
+ validateEmail: () => validateEmail,
30
+ validatePhoneUS: () => validatePhoneUS,
31
+ validateRequired: () => validateRequired,
32
+ validateUrl: () => validateUrl
33
+ });
34
+ module.exports = __toCommonJS(forms_exports);
35
+
36
+ // src/forms/validation.ts
37
+ var MAJOR_EMAIL_PROVIDERS = [
38
+ "gmail.com",
39
+ "yahoo.com",
40
+ "outlook.com",
41
+ "hotmail.com",
42
+ "icloud.com",
43
+ "live.com",
44
+ "protonmail.com"
45
+ ];
46
+ var KNOWN_GOOD_DOMAINS = /* @__PURE__ */ new Set([
47
+ ...MAJOR_EMAIL_PROVIDERS,
48
+ "aol.com",
49
+ "gmx.com",
50
+ "googlemail.com",
51
+ "hey.com",
52
+ "mac.com",
53
+ "mail.com",
54
+ "me.com",
55
+ "msn.com",
56
+ "pm.me",
57
+ "proton.me",
58
+ "ymail.com",
59
+ "zoho.com"
60
+ ]);
61
+ var EXPLICIT_TYPO_MAP = {
62
+ "gamil.com": "gmail.com",
63
+ "gmial.com": "gmail.com",
64
+ "gmai.com": "gmail.com",
65
+ "gmaill.com": "gmail.com",
66
+ "gmail.co": "gmail.com",
67
+ "gmail.con": "gmail.com",
68
+ "gmail.cmo": "gmail.com",
69
+ "hotmial.com": "hotmail.com",
70
+ "hotmall.com": "hotmail.com",
71
+ "hotmail.co": "hotmail.com",
72
+ "hotmail.con": "hotmail.com",
73
+ "iclod.com": "icloud.com",
74
+ "icloud.co": "icloud.com",
75
+ "icoud.com": "icloud.com",
76
+ "outlok.com": "outlook.com",
77
+ "outloook.com": "outlook.com",
78
+ "outlook.co": "outlook.com",
79
+ "outlook.con": "outlook.com",
80
+ "protonmail.co": "protonmail.com",
81
+ "yaho.com": "yahoo.com",
82
+ "yahooo.com": "yahoo.com",
83
+ "yahoo.co": "yahoo.com",
84
+ "yahoo.con": "yahoo.com"
85
+ };
86
+ var EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
87
+ function levenshtein(a, b) {
88
+ if (a === b) return 0;
89
+ const rows = a.length + 1;
90
+ const cols = b.length + 1;
91
+ const dist = Array.from({ length: cols }, (_, j) => j);
92
+ for (let i = 1; i < rows; i += 1) {
93
+ let prevDiagonal = dist[0];
94
+ dist[0] = i;
95
+ for (let j = 1; j < cols; j += 1) {
96
+ const temp = dist[j];
97
+ dist[j] = Math.min(
98
+ dist[j] + 1,
99
+ dist[j - 1] + 1,
100
+ prevDiagonal + (a[i - 1] === b[j - 1] ? 0 : 1)
101
+ );
102
+ prevDiagonal = temp;
103
+ }
104
+ }
105
+ return dist[cols - 1];
106
+ }
107
+ function normalizeEmail(value) {
108
+ return value.trim().toLowerCase();
109
+ }
110
+ function validateEmail(value, options = {}) {
111
+ const normalized = normalizeEmail(value);
112
+ if (normalized.length === 0) {
113
+ return { valid: false, normalized, message: "Email is required." };
114
+ }
115
+ if (!EMAIL_PATTERN.test(normalized)) {
116
+ return { valid: false, normalized, message: "Enter a valid email address." };
117
+ }
118
+ const [localPart, domain] = normalized.split("@");
119
+ const knownGood = options.knownGoodDomains ? /* @__PURE__ */ new Set([...KNOWN_GOOD_DOMAINS, ...options.knownGoodDomains.map((entry) => entry.toLowerCase())]) : KNOWN_GOOD_DOMAINS;
120
+ if (knownGood.has(domain)) {
121
+ return { valid: true, normalized };
122
+ }
123
+ const explicitCorrection = EXPLICIT_TYPO_MAP[domain];
124
+ if (explicitCorrection) {
125
+ const suggestion = `${localPart}@${explicitCorrection}`;
126
+ return {
127
+ valid: false,
128
+ normalized,
129
+ message: `Did you mean ${suggestion}?`,
130
+ suggestion
131
+ };
132
+ }
133
+ for (const provider of MAJOR_EMAIL_PROVIDERS) {
134
+ if (levenshtein(domain, provider) === 1) {
135
+ const suggestion = `${localPart}@${provider}`;
136
+ return {
137
+ valid: false,
138
+ normalized,
139
+ message: `Did you mean ${suggestion}?`,
140
+ suggestion
141
+ };
142
+ }
143
+ }
144
+ return { valid: true, normalized };
145
+ }
146
+ function normalizePhone(value) {
147
+ const digits = value.replace(/\D+/g, "");
148
+ if (digits.length === 11 && digits.startsWith("1")) {
149
+ return digits.slice(1);
150
+ }
151
+ return digits;
152
+ }
153
+ function formatPhoneUS(value) {
154
+ const digits = normalizePhone(value).slice(0, 10);
155
+ if (digits.length === 0) return "";
156
+ if (digits.length < 4) return `(${digits}`;
157
+ if (digits.length < 7) return `(${digits.slice(0, 3)}) ${digits.slice(3)}`;
158
+ return `(${digits.slice(0, 3)}) ${digits.slice(3, 6)}-${digits.slice(6)}`;
159
+ }
160
+ function validatePhoneUS(value) {
161
+ const digits = normalizePhone(value);
162
+ if (digits.length === 0) {
163
+ return { valid: false, normalized: "", message: "Phone number is required." };
164
+ }
165
+ if (digits.length !== 10) {
166
+ return { valid: false, normalized: digits, message: "Enter a 10-digit phone number." };
167
+ }
168
+ return { valid: true, normalized: digits };
169
+ }
170
+ function normalizeUrl(value) {
171
+ const trimmed = value.trim();
172
+ if (trimmed.length === 0) return "";
173
+ if (/^https?:\/\//i.test(trimmed)) return trimmed;
174
+ return `https://${trimmed}`;
175
+ }
176
+ function validateUrl(value) {
177
+ const normalized = normalizeUrl(value);
178
+ if (normalized.length === 0) {
179
+ return { valid: false, normalized, message: "URL is required." };
180
+ }
181
+ try {
182
+ const parsed = new URL(normalized);
183
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
184
+ return { valid: false, normalized, message: "Enter a valid web address." };
185
+ }
186
+ if (!parsed.hostname.includes(".")) {
187
+ return { valid: false, normalized, message: "Enter a valid web address." };
188
+ }
189
+ return { valid: true, normalized };
190
+ } catch {
191
+ return { valid: false, normalized, message: "Enter a valid web address." };
192
+ }
193
+ }
194
+ function validateRequired(value, label = "This field") {
195
+ const normalized = typeof value === "string" ? value.trim() : "";
196
+ const present = typeof value === "string" ? normalized.length > 0 : Array.isArray(value) ? value.length > 0 : value !== null && value !== void 0 && value !== false;
197
+ if (!present) {
198
+ return { valid: false, normalized, message: `${label} is required.` };
199
+ }
200
+ return { valid: true, normalized: typeof value === "string" ? normalized : String(value) };
201
+ }
202
+ function normalizeFieldValue(value, fieldType) {
203
+ switch (fieldType) {
204
+ case "email":
205
+ return normalizeEmail(value);
206
+ case "phone":
207
+ return normalizePhone(value);
208
+ case "url":
209
+ return normalizeUrl(value);
210
+ default:
211
+ return value.trim();
212
+ }
213
+ }
214
+ function inferFieldType(field) {
215
+ const type = typeof field.type === "string" ? field.type.toLowerCase() : "";
216
+ if (type === "email" || type === "phone" || type === "tel" || type === "url") {
217
+ return type === "tel" ? "phone" : type;
218
+ }
219
+ const name = typeof field.name === "string" ? field.name.toLowerCase() : "";
220
+ if (name.includes("email")) return "email";
221
+ if (name.includes("phone") || name.includes("mobile")) return "phone";
222
+ if (name.includes("website") || name.endsWith("url")) return "url";
223
+ return "text";
224
+ }
225
+ // Annotate the CommonJS export names for ESM import in node:
226
+ 0 && (module.exports = {
227
+ formatPhoneUS,
228
+ inferFieldType,
229
+ normalizeEmail,
230
+ normalizeFieldValue,
231
+ normalizePhone,
232
+ normalizeUrl,
233
+ validateEmail,
234
+ validatePhoneUS,
235
+ validateRequired,
236
+ validateUrl
237
+ });
@@ -0,0 +1,25 @@
1
+ import {
2
+ formatPhoneUS,
3
+ inferFieldType,
4
+ normalizeEmail,
5
+ normalizeFieldValue,
6
+ normalizePhone,
7
+ normalizeUrl,
8
+ validateEmail,
9
+ validatePhoneUS,
10
+ validateRequired,
11
+ validateUrl
12
+ } from "../chunk-VA545CHJ.mjs";
13
+ import "../chunk-6BWS3CLP.mjs";
14
+ export {
15
+ formatPhoneUS,
16
+ inferFieldType,
17
+ normalizeEmail,
18
+ normalizeFieldValue,
19
+ normalizePhone,
20
+ normalizeUrl,
21
+ validateEmail,
22
+ validatePhoneUS,
23
+ validateRequired,
24
+ validateUrl
25
+ };
@@ -0,0 +1,35 @@
1
+ import { Payload } from 'payload';
2
+ export { FieldValidationResult, StudioFormFieldType, ValidateEmailOptions, formatPhoneUS, inferFieldType, normalizeEmail, normalizeFieldValue, normalizePhone, normalizeUrl, validateEmail, validatePhoneUS, validateRequired, validateUrl } from './index.mjs';
3
+
4
+ type RateLimitStore = {
5
+ isLimited(key: string, now: number): boolean;
6
+ };
7
+ declare function createMemoryRateLimitStore(options?: {
8
+ max?: number;
9
+ windowMs?: number;
10
+ }): RateLimitStore;
11
+ type FormSubmissionHandlerOptions = {
12
+ getPayloadClient: () => Promise<Payload>;
13
+ formsCollectionSlug?: string;
14
+ submissionsCollectionSlug?: string;
15
+ allowedOrigins?: string[];
16
+ honeypotFieldName?: string;
17
+ minFillTimeMs?: number;
18
+ rateLimitStore?: RateLimitStore | null;
19
+ knownGoodEmailDomains?: string[];
20
+ onSubmission?: (args: {
21
+ formDoc: Record<string, unknown>;
22
+ normalizedData: Record<string, unknown>;
23
+ submissionID: number | string;
24
+ }) => Promise<void> | void;
25
+ };
26
+ type RouteContext = {
27
+ params: Promise<{
28
+ slug: string;
29
+ }> | {
30
+ slug: string;
31
+ };
32
+ };
33
+ declare function createFormSubmissionHandler(options: FormSubmissionHandlerOptions): (request: Request, context: RouteContext) => Promise<Response>;
34
+
35
+ export { type FormSubmissionHandlerOptions, type RateLimitStore, createFormSubmissionHandler, createMemoryRateLimitStore };
@@ -0,0 +1,35 @@
1
+ import { Payload } from 'payload';
2
+ export { FieldValidationResult, StudioFormFieldType, ValidateEmailOptions, formatPhoneUS, inferFieldType, normalizeEmail, normalizeFieldValue, normalizePhone, normalizeUrl, validateEmail, validatePhoneUS, validateRequired, validateUrl } from './index.js';
3
+
4
+ type RateLimitStore = {
5
+ isLimited(key: string, now: number): boolean;
6
+ };
7
+ declare function createMemoryRateLimitStore(options?: {
8
+ max?: number;
9
+ windowMs?: number;
10
+ }): RateLimitStore;
11
+ type FormSubmissionHandlerOptions = {
12
+ getPayloadClient: () => Promise<Payload>;
13
+ formsCollectionSlug?: string;
14
+ submissionsCollectionSlug?: string;
15
+ allowedOrigins?: string[];
16
+ honeypotFieldName?: string;
17
+ minFillTimeMs?: number;
18
+ rateLimitStore?: RateLimitStore | null;
19
+ knownGoodEmailDomains?: string[];
20
+ onSubmission?: (args: {
21
+ formDoc: Record<string, unknown>;
22
+ normalizedData: Record<string, unknown>;
23
+ submissionID: number | string;
24
+ }) => Promise<void> | void;
25
+ };
26
+ type RouteContext = {
27
+ params: Promise<{
28
+ slug: string;
29
+ }> | {
30
+ slug: string;
31
+ };
32
+ };
33
+ declare function createFormSubmissionHandler(options: FormSubmissionHandlerOptions): (request: Request, context: RouteContext) => Promise<Response>;
34
+
35
+ export { type FormSubmissionHandlerOptions, type RateLimitStore, createFormSubmissionHandler, createMemoryRateLimitStore };