careermate 0.0.1

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 (137) hide show
  1. package/AGENTS.md +33 -0
  2. package/INSTALL.md +230 -0
  3. package/LICENSE +21 -0
  4. package/README.md +532 -0
  5. package/THIRD_PARTY_NOTICES.md +57 -0
  6. package/bin/careermate.mjs +77 -0
  7. package/dist/career-os/README.md +78 -0
  8. package/dist/career-os/eop/cover-letter.md +46 -0
  9. package/dist/career-os/eop/fit-analysis.md +48 -0
  10. package/dist/career-os/eop/interview-prep.md +39 -0
  11. package/dist/career-os/eop/job-analysis.md +42 -0
  12. package/dist/career-os/eop/profile-extraction.md +37 -0
  13. package/dist/career-os/knowledge/ats.md +131 -0
  14. package/dist/career-os/knowledge/company-research.md +137 -0
  15. package/dist/career-os/knowledge/cover-letter.md +135 -0
  16. package/dist/career-os/knowledge/fit-matching.md +121 -0
  17. package/dist/career-os/knowledge/human-writing.md +118 -0
  18. package/dist/career-os/knowledge/interview-behavioral.md +132 -0
  19. package/dist/career-os/knowledge/interview-technical.md +126 -0
  20. package/dist/career-os/knowledge/linkedin-profile.md +152 -0
  21. package/dist/career-os/knowledge/networking-referrals.md +166 -0
  22. package/dist/career-os/knowledge/offer-evaluation-decision.md +121 -0
  23. package/dist/career-os/knowledge/onboarding-first-90-days.md +126 -0
  24. package/dist/career-os/knowledge/portfolio.md +121 -0
  25. package/dist/career-os/knowledge/recruiter-screen.md +105 -0
  26. package/dist/career-os/knowledge/rejection-triage-iteration.md +115 -0
  27. package/dist/career-os/knowledge/resume.md +123 -0
  28. package/dist/career-os/knowledge/salary-negotiation.md +123 -0
  29. package/dist/career-os/knowledge/verifiers/ats-compat.md +64 -0
  30. package/dist/career-os/knowledge/verifiers/consistency.md +61 -0
  31. package/dist/career-os/knowledge/verifiers/human-voice.md +82 -0
  32. package/dist/career-os/knowledge/verifiers/recency-staleness.md +72 -0
  33. package/dist/career-os/knowledge/verifiers/responsiveness-on-target.md +82 -0
  34. package/dist/career-os/knowledge/verifiers/truthfulness.md +67 -0
  35. package/dist/doctor.mjs +79094 -0
  36. package/dist/mcp.mjs +96108 -0
  37. package/dist/migrate.mjs +4735 -0
  38. package/dist/pdf.worker.min.mjs +28 -0
  39. package/dist/public/app.js +150 -0
  40. package/dist/public/fonts/PretendardVariable.woff2 +0 -0
  41. package/dist/public/icon-180.png +0 -0
  42. package/dist/public/index.html +52 -0
  43. package/dist/public/lib.js +394 -0
  44. package/dist/public/pages/applications.js +107 -0
  45. package/dist/public/pages/documents.js +467 -0
  46. package/dist/public/pages/home.js +261 -0
  47. package/dist/public/pages/interview.js +227 -0
  48. package/dist/public/pages/jobs.js +493 -0
  49. package/dist/public/pages/profile.js +556 -0
  50. package/dist/public/pages/settings.js +240 -0
  51. package/dist/public/styles.css +498 -0
  52. package/dist/site/analytics.js +97 -0
  53. package/dist/site/favicon.svg +1 -0
  54. package/dist/site/fonts/PretendardVariable.woff2 +0 -0
  55. package/dist/site/icon-180.png +0 -0
  56. package/dist/site/icon-512.png +0 -0
  57. package/dist/site/index.html +598 -0
  58. package/dist/site/landing.js +54 -0
  59. package/dist/site/llms-install.txt +217 -0
  60. package/dist/site/robots.txt +4 -0
  61. package/dist/site/sitemap.xml +21 -0
  62. package/dist/site/start.html +326 -0
  63. package/dist/site/style.css +550 -0
  64. package/dist/site/vercel.json +20 -0
  65. package/dist/web.mjs +46852 -0
  66. package/docs/FAQ.md +101 -0
  67. package/docs/MCP_TOOLS.md +311 -0
  68. package/docs/README.md +28 -0
  69. package/docs/START_WORKFLOW.md +137 -0
  70. package/docs/SUPPORTED_AI_APPS.md +112 -0
  71. package/docs/WORKFLOWS.md +202 -0
  72. package/docs/career-os/README.md +78 -0
  73. package/docs/career-os/eop/cover-letter.md +46 -0
  74. package/docs/career-os/eop/fit-analysis.md +48 -0
  75. package/docs/career-os/eop/interview-prep.md +39 -0
  76. package/docs/career-os/eop/job-analysis.md +42 -0
  77. package/docs/career-os/eop/profile-extraction.md +37 -0
  78. package/docs/career-os/knowledge/ats.md +131 -0
  79. package/docs/career-os/knowledge/company-research.md +137 -0
  80. package/docs/career-os/knowledge/cover-letter.md +135 -0
  81. package/docs/career-os/knowledge/fit-matching.md +121 -0
  82. package/docs/career-os/knowledge/human-writing.md +118 -0
  83. package/docs/career-os/knowledge/interview-behavioral.md +132 -0
  84. package/docs/career-os/knowledge/interview-technical.md +126 -0
  85. package/docs/career-os/knowledge/linkedin-profile.md +152 -0
  86. package/docs/career-os/knowledge/networking-referrals.md +166 -0
  87. package/docs/career-os/knowledge/offer-evaluation-decision.md +121 -0
  88. package/docs/career-os/knowledge/onboarding-first-90-days.md +126 -0
  89. package/docs/career-os/knowledge/portfolio.md +121 -0
  90. package/docs/career-os/knowledge/recruiter-screen.md +105 -0
  91. package/docs/career-os/knowledge/rejection-triage-iteration.md +115 -0
  92. package/docs/career-os/knowledge/resume.md +123 -0
  93. package/docs/career-os/knowledge/salary-negotiation.md +123 -0
  94. package/docs/career-os/knowledge/verifiers/ats-compat.md +64 -0
  95. package/docs/career-os/knowledge/verifiers/consistency.md +61 -0
  96. package/docs/career-os/knowledge/verifiers/human-voice.md +82 -0
  97. package/docs/career-os/knowledge/verifiers/recency-staleness.md +72 -0
  98. package/docs/career-os/knowledge/verifiers/responsiveness-on-target.md +82 -0
  99. package/docs/career-os/knowledge/verifiers/truthfulness.md +67 -0
  100. package/package.json +89 -0
  101. package/packages/core/src/context.ts +74 -0
  102. package/packages/core/src/index.ts +8 -0
  103. package/packages/core/src/onboarding.ts +81 -0
  104. package/packages/core/src/services.ts +187 -0
  105. package/packages/core/src/summary.ts +104 -0
  106. package/packages/db/src/connection.ts +76 -0
  107. package/packages/db/src/index.ts +23 -0
  108. package/packages/db/src/paths.ts +52 -0
  109. package/packages/db/src/repositories.ts +891 -0
  110. package/packages/db/src/runtime.ts +58 -0
  111. package/packages/db/src/schema.ts +307 -0
  112. package/packages/exporters/src/html.ts +110 -0
  113. package/packages/exporters/src/index.ts +364 -0
  114. package/packages/exporters/src/markdown.ts +178 -0
  115. package/packages/knowledge/src/index.ts +168 -0
  116. package/packages/mcp-tools/src/bridge.ts +106 -0
  117. package/packages/mcp-tools/src/index.ts +17 -0
  118. package/packages/mcp-tools/src/result.ts +49 -0
  119. package/packages/mcp-tools/src/tools.ts +747 -0
  120. package/packages/mcp-tools/src/update.ts +330 -0
  121. package/packages/parsers/src/documents.ts +533 -0
  122. package/packages/parsers/src/html.ts +86 -0
  123. package/packages/parsers/src/index.ts +231 -0
  124. package/packages/parsers/src/keywords.ts +151 -0
  125. package/packages/prompts/src/humanize.ts +59 -0
  126. package/packages/prompts/src/index.ts +82 -0
  127. package/packages/prompts/src/install.ts +43 -0
  128. package/packages/prompts/src/onboarding.ts +35 -0
  129. package/packages/prompts/src/system.ts +57 -0
  130. package/packages/shared/src/build-info.ts +22 -0
  131. package/packages/shared/src/enums.ts +142 -0
  132. package/packages/shared/src/index.ts +19 -0
  133. package/packages/shared/src/schemas.ts +453 -0
  134. package/packages/workflows/src/definitions.ts +109 -0
  135. package/packages/workflows/src/index.ts +39 -0
  136. package/scripts/init.ts +371 -0
  137. package/tsconfig.json +32 -0
@@ -0,0 +1,4735 @@
1
+ import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (target, all) => {
4
+ for (var name in all)
5
+ __defProp(target, name, { get: all[name], enumerable: true });
6
+ };
7
+
8
+ // packages/db/src/paths.ts
9
+ import os from "node:os";
10
+ import path from "node:path";
11
+ import fs from "node:fs";
12
+ function getDataDir() {
13
+ const override = process.env.CAREERMATE_DATA_DIR?.trim();
14
+ const dir = override && override.length > 0 ? override : path.join(os.homedir(), ".careermate");
15
+ fs.mkdirSync(dir, { recursive: true });
16
+ return dir;
17
+ }
18
+ function getDbPath() {
19
+ return path.join(getDataDir(), "careermate.sqlite");
20
+ }
21
+
22
+ // packages/db/src/connection.ts
23
+ import { DatabaseSync } from "node:sqlite";
24
+
25
+ // packages/db/src/schema.ts
26
+ var MIGRATIONS = [
27
+ // v1 — initial schema
28
+ `
29
+ CREATE TABLE IF NOT EXISTS profile (
30
+ id TEXT PRIMARY KEY,
31
+ name TEXT, email TEXT, phone TEXT, location TEXT,
32
+ headline TEXT, summary TEXT,
33
+ desired_roles TEXT NOT NULL DEFAULT '[]',
34
+ desired_conditions TEXT,
35
+ preferred_tone TEXT,
36
+ emphasis_points TEXT NOT NULL DEFAULT '[]',
37
+ links TEXT NOT NULL DEFAULT '[]',
38
+ created_at TEXT NOT NULL,
39
+ updated_at TEXT NOT NULL
40
+ );
41
+
42
+ CREATE TABLE IF NOT EXISTS experiences (
43
+ id TEXT PRIMARY KEY,
44
+ company TEXT NOT NULL,
45
+ role TEXT,
46
+ employment_type TEXT,
47
+ start_date TEXT,
48
+ end_date TEXT,
49
+ is_current INTEGER NOT NULL DEFAULT 0,
50
+ description TEXT,
51
+ achievements TEXT NOT NULL DEFAULT '[]',
52
+ tech TEXT NOT NULL DEFAULT '[]',
53
+ order_index INTEGER NOT NULL DEFAULT 0,
54
+ created_at TEXT NOT NULL,
55
+ updated_at TEXT NOT NULL
56
+ );
57
+
58
+ CREATE TABLE IF NOT EXISTS projects (
59
+ id TEXT PRIMARY KEY,
60
+ name TEXT NOT NULL,
61
+ role TEXT,
62
+ description TEXT,
63
+ highlights TEXT NOT NULL DEFAULT '[]',
64
+ tech TEXT NOT NULL DEFAULT '[]',
65
+ url TEXT,
66
+ start_date TEXT,
67
+ end_date TEXT,
68
+ order_index INTEGER NOT NULL DEFAULT 0,
69
+ created_at TEXT NOT NULL,
70
+ updated_at TEXT NOT NULL
71
+ );
72
+
73
+ CREATE TABLE IF NOT EXISTS skills (
74
+ id TEXT PRIMARY KEY,
75
+ name TEXT NOT NULL,
76
+ category TEXT,
77
+ level TEXT,
78
+ years REAL,
79
+ order_index INTEGER NOT NULL DEFAULT 0,
80
+ created_at TEXT NOT NULL,
81
+ updated_at TEXT NOT NULL
82
+ );
83
+
84
+ CREATE TABLE IF NOT EXISTS documents (
85
+ id TEXT PRIMARY KEY,
86
+ kind TEXT NOT NULL,
87
+ title TEXT NOT NULL,
88
+ content TEXT NOT NULL DEFAULT '',
89
+ source TEXT NOT NULL DEFAULT 'manual',
90
+ is_primary INTEGER NOT NULL DEFAULT 0,
91
+ tags TEXT NOT NULL DEFAULT '[]',
92
+ created_at TEXT NOT NULL,
93
+ updated_at TEXT NOT NULL
94
+ );
95
+
96
+ CREATE TABLE IF NOT EXISTS cover_letters (
97
+ id TEXT PRIMARY KEY,
98
+ title TEXT NOT NULL,
99
+ job_id TEXT,
100
+ is_primary INTEGER NOT NULL DEFAULT 0,
101
+ current_version_id TEXT,
102
+ created_at TEXT NOT NULL,
103
+ updated_at TEXT NOT NULL
104
+ );
105
+
106
+ CREATE TABLE IF NOT EXISTS cover_letter_versions (
107
+ id TEXT PRIMARY KEY,
108
+ cover_letter_id TEXT NOT NULL,
109
+ version_no INTEGER NOT NULL,
110
+ content TEXT NOT NULL,
111
+ note TEXT,
112
+ source TEXT NOT NULL DEFAULT 'ai',
113
+ created_at TEXT NOT NULL
114
+ );
115
+
116
+ CREATE TABLE IF NOT EXISTS jobs (
117
+ id TEXT PRIMARY KEY,
118
+ company TEXT NOT NULL,
119
+ position TEXT NOT NULL,
120
+ url TEXT,
121
+ location TEXT,
122
+ employment_type TEXT,
123
+ description TEXT,
124
+ requirements TEXT NOT NULL DEFAULT '[]',
125
+ keywords TEXT NOT NULL DEFAULT '[]',
126
+ deadline TEXT,
127
+ source TEXT,
128
+ created_at TEXT NOT NULL,
129
+ updated_at TEXT NOT NULL
130
+ );
131
+
132
+ CREATE TABLE IF NOT EXISTS fit_analyses (
133
+ id TEXT PRIMARY KEY,
134
+ job_id TEXT NOT NULL,
135
+ score REAL,
136
+ summary TEXT,
137
+ strengths TEXT NOT NULL DEFAULT '[]',
138
+ gaps TEXT NOT NULL DEFAULT '[]',
139
+ matched_keywords TEXT NOT NULL DEFAULT '[]',
140
+ missing_keywords TEXT NOT NULL DEFAULT '[]',
141
+ recommendations TEXT NOT NULL DEFAULT '[]',
142
+ created_at TEXT NOT NULL,
143
+ updated_at TEXT NOT NULL
144
+ );
145
+
146
+ CREATE TABLE IF NOT EXISTS applications (
147
+ id TEXT PRIMARY KEY,
148
+ job_id TEXT NOT NULL UNIQUE,
149
+ status TEXT NOT NULL DEFAULT 'draft',
150
+ resume_id TEXT,
151
+ cover_letter_id TEXT,
152
+ applied_at TEXT,
153
+ notes TEXT,
154
+ created_at TEXT NOT NULL,
155
+ updated_at TEXT NOT NULL
156
+ );
157
+
158
+ CREATE TABLE IF NOT EXISTS interview_preps (
159
+ id TEXT PRIMARY KEY,
160
+ job_id TEXT NOT NULL UNIQUE,
161
+ questions TEXT NOT NULL DEFAULT '[]',
162
+ star_guides TEXT NOT NULL DEFAULT '[]',
163
+ self_introduction TEXT,
164
+ notes TEXT,
165
+ created_at TEXT NOT NULL,
166
+ updated_at TEXT NOT NULL
167
+ );
168
+
169
+ CREATE TABLE IF NOT EXISTS activities (
170
+ id TEXT PRIMARY KEY,
171
+ type TEXT NOT NULL,
172
+ entity_type TEXT,
173
+ entity_id TEXT,
174
+ summary TEXT NOT NULL,
175
+ created_at TEXT NOT NULL
176
+ );
177
+
178
+ CREATE INDEX IF NOT EXISTS idx_fit_job ON fit_analyses(job_id);
179
+ CREATE INDEX IF NOT EXISTS idx_clv_letter ON cover_letter_versions(cover_letter_id);
180
+ CREATE INDEX IF NOT EXISTS idx_cl_job ON cover_letters(job_id);
181
+ CREATE INDEX IF NOT EXISTS idx_activities_created ON activities(created_at DESC);
182
+ `,
183
+ // v2 — add foreign keys so PRAGMA foreign_keys=ON is actually enforced.
184
+ //
185
+ // SQLite cannot ALTER a table to add constraints, so each table that needs an
186
+ // FK is recreated (create new → copy → drop old → rename). The copy also
187
+ // repairs pre-existing orphans: child rows whose parent is gone are dropped
188
+ // (CASCADE intent) and dangling optional refs are nulled (SET NULL intent), so
189
+ // a subsequent PRAGMA foreign_key_check stays clean. FKs are disabled for the
190
+ // rebuild and the whole thing runs in one transaction (auto-rolled-back if the
191
+ // process dies mid-migration, since the version bump happens only afterwards).
192
+ `
193
+ PRAGMA foreign_keys=OFF;
194
+ BEGIN;
195
+
196
+ -- cover_letters.job_id -> jobs(id) ON DELETE SET NULL
197
+ CREATE TABLE cover_letters_new (
198
+ id TEXT PRIMARY KEY,
199
+ title TEXT NOT NULL,
200
+ job_id TEXT REFERENCES jobs(id) ON DELETE SET NULL,
201
+ is_primary INTEGER NOT NULL DEFAULT 0,
202
+ current_version_id TEXT,
203
+ created_at TEXT NOT NULL,
204
+ updated_at TEXT NOT NULL
205
+ );
206
+ INSERT INTO cover_letters_new (id,title,job_id,is_primary,current_version_id,created_at,updated_at)
207
+ SELECT id,title,
208
+ CASE WHEN job_id IN (SELECT id FROM jobs) THEN job_id ELSE NULL END,
209
+ is_primary,current_version_id,created_at,updated_at
210
+ FROM cover_letters;
211
+ DROP TABLE cover_letters;
212
+ ALTER TABLE cover_letters_new RENAME TO cover_letters;
213
+
214
+ -- cover_letter_versions.cover_letter_id -> cover_letters(id) ON DELETE CASCADE
215
+ CREATE TABLE cover_letter_versions_new (
216
+ id TEXT PRIMARY KEY,
217
+ cover_letter_id TEXT NOT NULL REFERENCES cover_letters(id) ON DELETE CASCADE,
218
+ version_no INTEGER NOT NULL,
219
+ content TEXT NOT NULL,
220
+ note TEXT,
221
+ source TEXT NOT NULL DEFAULT 'ai',
222
+ created_at TEXT NOT NULL
223
+ );
224
+ INSERT INTO cover_letter_versions_new (id,cover_letter_id,version_no,content,note,source,created_at)
225
+ SELECT id,cover_letter_id,version_no,content,note,source,created_at
226
+ FROM cover_letter_versions
227
+ WHERE cover_letter_id IN (SELECT id FROM cover_letters);
228
+ DROP TABLE cover_letter_versions;
229
+ ALTER TABLE cover_letter_versions_new RENAME TO cover_letter_versions;
230
+
231
+ -- fit_analyses.job_id -> jobs(id) ON DELETE CASCADE
232
+ CREATE TABLE fit_analyses_new (
233
+ id TEXT PRIMARY KEY,
234
+ job_id TEXT NOT NULL REFERENCES jobs(id) ON DELETE CASCADE,
235
+ score REAL,
236
+ summary TEXT,
237
+ strengths TEXT NOT NULL DEFAULT '[]',
238
+ gaps TEXT NOT NULL DEFAULT '[]',
239
+ matched_keywords TEXT NOT NULL DEFAULT '[]',
240
+ missing_keywords TEXT NOT NULL DEFAULT '[]',
241
+ recommendations TEXT NOT NULL DEFAULT '[]',
242
+ created_at TEXT NOT NULL,
243
+ updated_at TEXT NOT NULL
244
+ );
245
+ INSERT INTO fit_analyses_new (id,job_id,score,summary,strengths,gaps,matched_keywords,missing_keywords,recommendations,created_at,updated_at)
246
+ SELECT id,job_id,score,summary,strengths,gaps,matched_keywords,missing_keywords,recommendations,created_at,updated_at
247
+ FROM fit_analyses
248
+ WHERE job_id IN (SELECT id FROM jobs);
249
+ DROP TABLE fit_analyses;
250
+ ALTER TABLE fit_analyses_new RENAME TO fit_analyses;
251
+
252
+ -- applications: job_id CASCADE, resume_id/cover_letter_id SET NULL
253
+ CREATE TABLE applications_new (
254
+ id TEXT PRIMARY KEY,
255
+ job_id TEXT NOT NULL UNIQUE REFERENCES jobs(id) ON DELETE CASCADE,
256
+ status TEXT NOT NULL DEFAULT 'draft',
257
+ resume_id TEXT REFERENCES documents(id) ON DELETE SET NULL,
258
+ cover_letter_id TEXT REFERENCES cover_letters(id) ON DELETE SET NULL,
259
+ applied_at TEXT,
260
+ notes TEXT,
261
+ created_at TEXT NOT NULL,
262
+ updated_at TEXT NOT NULL
263
+ );
264
+ INSERT INTO applications_new (id,job_id,status,resume_id,cover_letter_id,applied_at,notes,created_at,updated_at)
265
+ SELECT id,job_id,status,
266
+ CASE WHEN resume_id IN (SELECT id FROM documents) THEN resume_id ELSE NULL END,
267
+ CASE WHEN cover_letter_id IN (SELECT id FROM cover_letters) THEN cover_letter_id ELSE NULL END,
268
+ applied_at,notes,created_at,updated_at
269
+ FROM applications
270
+ WHERE job_id IN (SELECT id FROM jobs);
271
+ DROP TABLE applications;
272
+ ALTER TABLE applications_new RENAME TO applications;
273
+
274
+ -- interview_preps.job_id -> jobs(id) ON DELETE CASCADE
275
+ CREATE TABLE interview_preps_new (
276
+ id TEXT PRIMARY KEY,
277
+ job_id TEXT NOT NULL UNIQUE REFERENCES jobs(id) ON DELETE CASCADE,
278
+ questions TEXT NOT NULL DEFAULT '[]',
279
+ star_guides TEXT NOT NULL DEFAULT '[]',
280
+ self_introduction TEXT,
281
+ notes TEXT,
282
+ created_at TEXT NOT NULL,
283
+ updated_at TEXT NOT NULL
284
+ );
285
+ INSERT INTO interview_preps_new (id,job_id,questions,star_guides,self_introduction,notes,created_at,updated_at)
286
+ SELECT id,job_id,questions,star_guides,self_introduction,notes,created_at,updated_at
287
+ FROM interview_preps
288
+ WHERE job_id IN (SELECT id FROM jobs);
289
+ DROP TABLE interview_preps;
290
+ ALTER TABLE interview_preps_new RENAME TO interview_preps;
291
+
292
+ -- Recreate indexes dropped along with their tables.
293
+ CREATE INDEX IF NOT EXISTS idx_fit_job ON fit_analyses(job_id);
294
+ CREATE INDEX IF NOT EXISTS idx_clv_letter ON cover_letter_versions(cover_letter_id);
295
+ CREATE INDEX IF NOT EXISTS idx_cl_job ON cover_letters(job_id);
296
+
297
+ COMMIT;
298
+ PRAGMA foreign_keys=ON;
299
+ `
300
+ ];
301
+ function migrate(db) {
302
+ db.exec(`CREATE TABLE IF NOT EXISTS _meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);`);
303
+ const row = db.prepare(`SELECT value FROM _meta WHERE key = 'schema_version'`).get();
304
+ const from = row ? Number(row.value) : 0;
305
+ for (let v = from; v < MIGRATIONS.length; v++) {
306
+ db.exec(MIGRATIONS[v]);
307
+ }
308
+ const to = MIGRATIONS.length;
309
+ if (to !== from) {
310
+ db.prepare(
311
+ `INSERT INTO _meta (key, value) VALUES ('schema_version', ?)
312
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value`
313
+ ).run(String(to));
314
+ }
315
+ return { from, to };
316
+ }
317
+
318
+ // packages/db/src/connection.ts
319
+ var _db = null;
320
+ function getDb() {
321
+ if (_db) return _db;
322
+ const db = new DatabaseSync(getDbPath());
323
+ db.exec("PRAGMA journal_mode = WAL;");
324
+ db.exec("PRAGMA foreign_keys = ON;");
325
+ db.exec("PRAGMA busy_timeout = 5000;");
326
+ migrate(db);
327
+ _db = db;
328
+ return db;
329
+ }
330
+
331
+ // packages/shared/src/enums.ts
332
+ var APPLICATION_STATUSES = [
333
+ "draft",
334
+ // 작성 중
335
+ "planned",
336
+ // 지원 예정
337
+ "applied",
338
+ // 지원 완료
339
+ "document_passed",
340
+ // 서류 합격
341
+ "interview",
342
+ // 면접 진행
343
+ "final_passed",
344
+ // 최종 합격
345
+ "rejected",
346
+ // 불합격
347
+ "on_hold"
348
+ // 보류
349
+ ];
350
+ var DOCUMENT_KINDS = ["resume", "career_description", "portfolio", "other"];
351
+ var CONTENT_SOURCES = ["manual", "upload", "ai", "edit"];
352
+ var ACTIVITY_TYPES = [
353
+ "profile_updated",
354
+ "resume_added",
355
+ "cover_letter_added",
356
+ "cover_letter_version_saved",
357
+ "job_saved",
358
+ "fit_analysis_saved",
359
+ "application_status_changed",
360
+ "interview_prep_saved",
361
+ "document_exported"
362
+ ];
363
+ var ENTITY_TYPES = [
364
+ "profile",
365
+ "experience",
366
+ "project",
367
+ "skill",
368
+ "document",
369
+ "cover_letter",
370
+ "job",
371
+ "application",
372
+ "fit_analysis",
373
+ "interview_prep"
374
+ ];
375
+
376
+ // node_modules/zod/v3/external.js
377
+ var external_exports = {};
378
+ __export(external_exports, {
379
+ BRAND: () => BRAND,
380
+ DIRTY: () => DIRTY,
381
+ EMPTY_PATH: () => EMPTY_PATH,
382
+ INVALID: () => INVALID,
383
+ NEVER: () => NEVER,
384
+ OK: () => OK,
385
+ ParseStatus: () => ParseStatus,
386
+ Schema: () => ZodType,
387
+ ZodAny: () => ZodAny,
388
+ ZodArray: () => ZodArray,
389
+ ZodBigInt: () => ZodBigInt,
390
+ ZodBoolean: () => ZodBoolean,
391
+ ZodBranded: () => ZodBranded,
392
+ ZodCatch: () => ZodCatch,
393
+ ZodDate: () => ZodDate,
394
+ ZodDefault: () => ZodDefault,
395
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
396
+ ZodEffects: () => ZodEffects,
397
+ ZodEnum: () => ZodEnum,
398
+ ZodError: () => ZodError,
399
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
400
+ ZodFunction: () => ZodFunction,
401
+ ZodIntersection: () => ZodIntersection,
402
+ ZodIssueCode: () => ZodIssueCode,
403
+ ZodLazy: () => ZodLazy,
404
+ ZodLiteral: () => ZodLiteral,
405
+ ZodMap: () => ZodMap,
406
+ ZodNaN: () => ZodNaN,
407
+ ZodNativeEnum: () => ZodNativeEnum,
408
+ ZodNever: () => ZodNever,
409
+ ZodNull: () => ZodNull,
410
+ ZodNullable: () => ZodNullable,
411
+ ZodNumber: () => ZodNumber,
412
+ ZodObject: () => ZodObject,
413
+ ZodOptional: () => ZodOptional,
414
+ ZodParsedType: () => ZodParsedType,
415
+ ZodPipeline: () => ZodPipeline,
416
+ ZodPromise: () => ZodPromise,
417
+ ZodReadonly: () => ZodReadonly,
418
+ ZodRecord: () => ZodRecord,
419
+ ZodSchema: () => ZodType,
420
+ ZodSet: () => ZodSet,
421
+ ZodString: () => ZodString,
422
+ ZodSymbol: () => ZodSymbol,
423
+ ZodTransformer: () => ZodEffects,
424
+ ZodTuple: () => ZodTuple,
425
+ ZodType: () => ZodType,
426
+ ZodUndefined: () => ZodUndefined,
427
+ ZodUnion: () => ZodUnion,
428
+ ZodUnknown: () => ZodUnknown,
429
+ ZodVoid: () => ZodVoid,
430
+ addIssueToContext: () => addIssueToContext,
431
+ any: () => anyType,
432
+ array: () => arrayType,
433
+ bigint: () => bigIntType,
434
+ boolean: () => booleanType,
435
+ coerce: () => coerce,
436
+ custom: () => custom,
437
+ date: () => dateType,
438
+ datetimeRegex: () => datetimeRegex,
439
+ defaultErrorMap: () => en_default,
440
+ discriminatedUnion: () => discriminatedUnionType,
441
+ effect: () => effectsType,
442
+ enum: () => enumType,
443
+ function: () => functionType,
444
+ getErrorMap: () => getErrorMap,
445
+ getParsedType: () => getParsedType,
446
+ instanceof: () => instanceOfType,
447
+ intersection: () => intersectionType,
448
+ isAborted: () => isAborted,
449
+ isAsync: () => isAsync,
450
+ isDirty: () => isDirty,
451
+ isValid: () => isValid,
452
+ late: () => late,
453
+ lazy: () => lazyType,
454
+ literal: () => literalType,
455
+ makeIssue: () => makeIssue,
456
+ map: () => mapType,
457
+ nan: () => nanType,
458
+ nativeEnum: () => nativeEnumType,
459
+ never: () => neverType,
460
+ null: () => nullType,
461
+ nullable: () => nullableType,
462
+ number: () => numberType,
463
+ object: () => objectType,
464
+ objectUtil: () => objectUtil,
465
+ oboolean: () => oboolean,
466
+ onumber: () => onumber,
467
+ optional: () => optionalType,
468
+ ostring: () => ostring,
469
+ pipeline: () => pipelineType,
470
+ preprocess: () => preprocessType,
471
+ promise: () => promiseType,
472
+ quotelessJson: () => quotelessJson,
473
+ record: () => recordType,
474
+ set: () => setType,
475
+ setErrorMap: () => setErrorMap,
476
+ strictObject: () => strictObjectType,
477
+ string: () => stringType,
478
+ symbol: () => symbolType,
479
+ transformer: () => effectsType,
480
+ tuple: () => tupleType,
481
+ undefined: () => undefinedType,
482
+ union: () => unionType,
483
+ unknown: () => unknownType,
484
+ util: () => util,
485
+ void: () => voidType
486
+ });
487
+
488
+ // node_modules/zod/v3/helpers/util.js
489
+ var util;
490
+ (function(util2) {
491
+ util2.assertEqual = (_) => {
492
+ };
493
+ function assertIs(_arg) {
494
+ }
495
+ util2.assertIs = assertIs;
496
+ function assertNever(_x) {
497
+ throw new Error();
498
+ }
499
+ util2.assertNever = assertNever;
500
+ util2.arrayToEnum = (items) => {
501
+ const obj = {};
502
+ for (const item of items) {
503
+ obj[item] = item;
504
+ }
505
+ return obj;
506
+ };
507
+ util2.getValidEnumValues = (obj) => {
508
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
509
+ const filtered = {};
510
+ for (const k of validKeys) {
511
+ filtered[k] = obj[k];
512
+ }
513
+ return util2.objectValues(filtered);
514
+ };
515
+ util2.objectValues = (obj) => {
516
+ return util2.objectKeys(obj).map(function(e) {
517
+ return obj[e];
518
+ });
519
+ };
520
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
521
+ const keys = [];
522
+ for (const key in object) {
523
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
524
+ keys.push(key);
525
+ }
526
+ }
527
+ return keys;
528
+ };
529
+ util2.find = (arr, checker) => {
530
+ for (const item of arr) {
531
+ if (checker(item))
532
+ return item;
533
+ }
534
+ return void 0;
535
+ };
536
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
537
+ function joinValues(array, separator = " | ") {
538
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
539
+ }
540
+ util2.joinValues = joinValues;
541
+ util2.jsonStringifyReplacer = (_, value) => {
542
+ if (typeof value === "bigint") {
543
+ return value.toString();
544
+ }
545
+ return value;
546
+ };
547
+ })(util || (util = {}));
548
+ var objectUtil;
549
+ (function(objectUtil2) {
550
+ objectUtil2.mergeShapes = (first, second) => {
551
+ return {
552
+ ...first,
553
+ ...second
554
+ // second overwrites first
555
+ };
556
+ };
557
+ })(objectUtil || (objectUtil = {}));
558
+ var ZodParsedType = util.arrayToEnum([
559
+ "string",
560
+ "nan",
561
+ "number",
562
+ "integer",
563
+ "float",
564
+ "boolean",
565
+ "date",
566
+ "bigint",
567
+ "symbol",
568
+ "function",
569
+ "undefined",
570
+ "null",
571
+ "array",
572
+ "object",
573
+ "unknown",
574
+ "promise",
575
+ "void",
576
+ "never",
577
+ "map",
578
+ "set"
579
+ ]);
580
+ var getParsedType = (data) => {
581
+ const t = typeof data;
582
+ switch (t) {
583
+ case "undefined":
584
+ return ZodParsedType.undefined;
585
+ case "string":
586
+ return ZodParsedType.string;
587
+ case "number":
588
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
589
+ case "boolean":
590
+ return ZodParsedType.boolean;
591
+ case "function":
592
+ return ZodParsedType.function;
593
+ case "bigint":
594
+ return ZodParsedType.bigint;
595
+ case "symbol":
596
+ return ZodParsedType.symbol;
597
+ case "object":
598
+ if (Array.isArray(data)) {
599
+ return ZodParsedType.array;
600
+ }
601
+ if (data === null) {
602
+ return ZodParsedType.null;
603
+ }
604
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
605
+ return ZodParsedType.promise;
606
+ }
607
+ if (typeof Map !== "undefined" && data instanceof Map) {
608
+ return ZodParsedType.map;
609
+ }
610
+ if (typeof Set !== "undefined" && data instanceof Set) {
611
+ return ZodParsedType.set;
612
+ }
613
+ if (typeof Date !== "undefined" && data instanceof Date) {
614
+ return ZodParsedType.date;
615
+ }
616
+ return ZodParsedType.object;
617
+ default:
618
+ return ZodParsedType.unknown;
619
+ }
620
+ };
621
+
622
+ // node_modules/zod/v3/ZodError.js
623
+ var ZodIssueCode = util.arrayToEnum([
624
+ "invalid_type",
625
+ "invalid_literal",
626
+ "custom",
627
+ "invalid_union",
628
+ "invalid_union_discriminator",
629
+ "invalid_enum_value",
630
+ "unrecognized_keys",
631
+ "invalid_arguments",
632
+ "invalid_return_type",
633
+ "invalid_date",
634
+ "invalid_string",
635
+ "too_small",
636
+ "too_big",
637
+ "invalid_intersection_types",
638
+ "not_multiple_of",
639
+ "not_finite"
640
+ ]);
641
+ var quotelessJson = (obj) => {
642
+ const json = JSON.stringify(obj, null, 2);
643
+ return json.replace(/"([^"]+)":/g, "$1:");
644
+ };
645
+ var ZodError = class _ZodError extends Error {
646
+ get errors() {
647
+ return this.issues;
648
+ }
649
+ constructor(issues) {
650
+ super();
651
+ this.issues = [];
652
+ this.addIssue = (sub) => {
653
+ this.issues = [...this.issues, sub];
654
+ };
655
+ this.addIssues = (subs = []) => {
656
+ this.issues = [...this.issues, ...subs];
657
+ };
658
+ const actualProto = new.target.prototype;
659
+ if (Object.setPrototypeOf) {
660
+ Object.setPrototypeOf(this, actualProto);
661
+ } else {
662
+ this.__proto__ = actualProto;
663
+ }
664
+ this.name = "ZodError";
665
+ this.issues = issues;
666
+ }
667
+ format(_mapper) {
668
+ const mapper = _mapper || function(issue) {
669
+ return issue.message;
670
+ };
671
+ const fieldErrors = { _errors: [] };
672
+ const processError = (error) => {
673
+ for (const issue of error.issues) {
674
+ if (issue.code === "invalid_union") {
675
+ issue.unionErrors.map(processError);
676
+ } else if (issue.code === "invalid_return_type") {
677
+ processError(issue.returnTypeError);
678
+ } else if (issue.code === "invalid_arguments") {
679
+ processError(issue.argumentsError);
680
+ } else if (issue.path.length === 0) {
681
+ fieldErrors._errors.push(mapper(issue));
682
+ } else {
683
+ let curr = fieldErrors;
684
+ let i = 0;
685
+ while (i < issue.path.length) {
686
+ const el = issue.path[i];
687
+ const terminal = i === issue.path.length - 1;
688
+ if (!terminal) {
689
+ curr[el] = curr[el] || { _errors: [] };
690
+ } else {
691
+ curr[el] = curr[el] || { _errors: [] };
692
+ curr[el]._errors.push(mapper(issue));
693
+ }
694
+ curr = curr[el];
695
+ i++;
696
+ }
697
+ }
698
+ }
699
+ };
700
+ processError(this);
701
+ return fieldErrors;
702
+ }
703
+ static assert(value) {
704
+ if (!(value instanceof _ZodError)) {
705
+ throw new Error(`Not a ZodError: ${value}`);
706
+ }
707
+ }
708
+ toString() {
709
+ return this.message;
710
+ }
711
+ get message() {
712
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
713
+ }
714
+ get isEmpty() {
715
+ return this.issues.length === 0;
716
+ }
717
+ flatten(mapper = (issue) => issue.message) {
718
+ const fieldErrors = {};
719
+ const formErrors = [];
720
+ for (const sub of this.issues) {
721
+ if (sub.path.length > 0) {
722
+ const firstEl = sub.path[0];
723
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
724
+ fieldErrors[firstEl].push(mapper(sub));
725
+ } else {
726
+ formErrors.push(mapper(sub));
727
+ }
728
+ }
729
+ return { formErrors, fieldErrors };
730
+ }
731
+ get formErrors() {
732
+ return this.flatten();
733
+ }
734
+ };
735
+ ZodError.create = (issues) => {
736
+ const error = new ZodError(issues);
737
+ return error;
738
+ };
739
+
740
+ // node_modules/zod/v3/locales/en.js
741
+ var errorMap = (issue, _ctx) => {
742
+ let message;
743
+ switch (issue.code) {
744
+ case ZodIssueCode.invalid_type:
745
+ if (issue.received === ZodParsedType.undefined) {
746
+ message = "Required";
747
+ } else {
748
+ message = `Expected ${issue.expected}, received ${issue.received}`;
749
+ }
750
+ break;
751
+ case ZodIssueCode.invalid_literal:
752
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
753
+ break;
754
+ case ZodIssueCode.unrecognized_keys:
755
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
756
+ break;
757
+ case ZodIssueCode.invalid_union:
758
+ message = `Invalid input`;
759
+ break;
760
+ case ZodIssueCode.invalid_union_discriminator:
761
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
762
+ break;
763
+ case ZodIssueCode.invalid_enum_value:
764
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
765
+ break;
766
+ case ZodIssueCode.invalid_arguments:
767
+ message = `Invalid function arguments`;
768
+ break;
769
+ case ZodIssueCode.invalid_return_type:
770
+ message = `Invalid function return type`;
771
+ break;
772
+ case ZodIssueCode.invalid_date:
773
+ message = `Invalid date`;
774
+ break;
775
+ case ZodIssueCode.invalid_string:
776
+ if (typeof issue.validation === "object") {
777
+ if ("includes" in issue.validation) {
778
+ message = `Invalid input: must include "${issue.validation.includes}"`;
779
+ if (typeof issue.validation.position === "number") {
780
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
781
+ }
782
+ } else if ("startsWith" in issue.validation) {
783
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
784
+ } else if ("endsWith" in issue.validation) {
785
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
786
+ } else {
787
+ util.assertNever(issue.validation);
788
+ }
789
+ } else if (issue.validation !== "regex") {
790
+ message = `Invalid ${issue.validation}`;
791
+ } else {
792
+ message = "Invalid";
793
+ }
794
+ break;
795
+ case ZodIssueCode.too_small:
796
+ if (issue.type === "array")
797
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
798
+ else if (issue.type === "string")
799
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
800
+ else if (issue.type === "number")
801
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
802
+ else if (issue.type === "bigint")
803
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
804
+ else if (issue.type === "date")
805
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
806
+ else
807
+ message = "Invalid input";
808
+ break;
809
+ case ZodIssueCode.too_big:
810
+ if (issue.type === "array")
811
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
812
+ else if (issue.type === "string")
813
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
814
+ else if (issue.type === "number")
815
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
816
+ else if (issue.type === "bigint")
817
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
818
+ else if (issue.type === "date")
819
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
820
+ else
821
+ message = "Invalid input";
822
+ break;
823
+ case ZodIssueCode.custom:
824
+ message = `Invalid input`;
825
+ break;
826
+ case ZodIssueCode.invalid_intersection_types:
827
+ message = `Intersection results could not be merged`;
828
+ break;
829
+ case ZodIssueCode.not_multiple_of:
830
+ message = `Number must be a multiple of ${issue.multipleOf}`;
831
+ break;
832
+ case ZodIssueCode.not_finite:
833
+ message = "Number must be finite";
834
+ break;
835
+ default:
836
+ message = _ctx.defaultError;
837
+ util.assertNever(issue);
838
+ }
839
+ return { message };
840
+ };
841
+ var en_default = errorMap;
842
+
843
+ // node_modules/zod/v3/errors.js
844
+ var overrideErrorMap = en_default;
845
+ function setErrorMap(map) {
846
+ overrideErrorMap = map;
847
+ }
848
+ function getErrorMap() {
849
+ return overrideErrorMap;
850
+ }
851
+
852
+ // node_modules/zod/v3/helpers/parseUtil.js
853
+ var makeIssue = (params) => {
854
+ const { data, path: path2, errorMaps, issueData } = params;
855
+ const fullPath = [...path2, ...issueData.path || []];
856
+ const fullIssue = {
857
+ ...issueData,
858
+ path: fullPath
859
+ };
860
+ if (issueData.message !== void 0) {
861
+ return {
862
+ ...issueData,
863
+ path: fullPath,
864
+ message: issueData.message
865
+ };
866
+ }
867
+ let errorMessage = "";
868
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
869
+ for (const map of maps) {
870
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
871
+ }
872
+ return {
873
+ ...issueData,
874
+ path: fullPath,
875
+ message: errorMessage
876
+ };
877
+ };
878
+ var EMPTY_PATH = [];
879
+ function addIssueToContext(ctx, issueData) {
880
+ const overrideMap = getErrorMap();
881
+ const issue = makeIssue({
882
+ issueData,
883
+ data: ctx.data,
884
+ path: ctx.path,
885
+ errorMaps: [
886
+ ctx.common.contextualErrorMap,
887
+ // contextual error map is first priority
888
+ ctx.schemaErrorMap,
889
+ // then schema-bound map if available
890
+ overrideMap,
891
+ // then global override map
892
+ overrideMap === en_default ? void 0 : en_default
893
+ // then global default map
894
+ ].filter((x) => !!x)
895
+ });
896
+ ctx.common.issues.push(issue);
897
+ }
898
+ var ParseStatus = class _ParseStatus {
899
+ constructor() {
900
+ this.value = "valid";
901
+ }
902
+ dirty() {
903
+ if (this.value === "valid")
904
+ this.value = "dirty";
905
+ }
906
+ abort() {
907
+ if (this.value !== "aborted")
908
+ this.value = "aborted";
909
+ }
910
+ static mergeArray(status, results) {
911
+ const arrayValue = [];
912
+ for (const s of results) {
913
+ if (s.status === "aborted")
914
+ return INVALID;
915
+ if (s.status === "dirty")
916
+ status.dirty();
917
+ arrayValue.push(s.value);
918
+ }
919
+ return { status: status.value, value: arrayValue };
920
+ }
921
+ static async mergeObjectAsync(status, pairs) {
922
+ const syncPairs = [];
923
+ for (const pair of pairs) {
924
+ const key = await pair.key;
925
+ const value = await pair.value;
926
+ syncPairs.push({
927
+ key,
928
+ value
929
+ });
930
+ }
931
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
932
+ }
933
+ static mergeObjectSync(status, pairs) {
934
+ const finalObject = {};
935
+ for (const pair of pairs) {
936
+ const { key, value } = pair;
937
+ if (key.status === "aborted")
938
+ return INVALID;
939
+ if (value.status === "aborted")
940
+ return INVALID;
941
+ if (key.status === "dirty")
942
+ status.dirty();
943
+ if (value.status === "dirty")
944
+ status.dirty();
945
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
946
+ finalObject[key.value] = value.value;
947
+ }
948
+ }
949
+ return { status: status.value, value: finalObject };
950
+ }
951
+ };
952
+ var INVALID = Object.freeze({
953
+ status: "aborted"
954
+ });
955
+ var DIRTY = (value) => ({ status: "dirty", value });
956
+ var OK = (value) => ({ status: "valid", value });
957
+ var isAborted = (x) => x.status === "aborted";
958
+ var isDirty = (x) => x.status === "dirty";
959
+ var isValid = (x) => x.status === "valid";
960
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
961
+
962
+ // node_modules/zod/v3/helpers/errorUtil.js
963
+ var errorUtil;
964
+ (function(errorUtil2) {
965
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
966
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
967
+ })(errorUtil || (errorUtil = {}));
968
+
969
+ // node_modules/zod/v3/types.js
970
+ var ParseInputLazyPath = class {
971
+ constructor(parent, value, path2, key) {
972
+ this._cachedPath = [];
973
+ this.parent = parent;
974
+ this.data = value;
975
+ this._path = path2;
976
+ this._key = key;
977
+ }
978
+ get path() {
979
+ if (!this._cachedPath.length) {
980
+ if (Array.isArray(this._key)) {
981
+ this._cachedPath.push(...this._path, ...this._key);
982
+ } else {
983
+ this._cachedPath.push(...this._path, this._key);
984
+ }
985
+ }
986
+ return this._cachedPath;
987
+ }
988
+ };
989
+ var handleResult = (ctx, result) => {
990
+ if (isValid(result)) {
991
+ return { success: true, data: result.value };
992
+ } else {
993
+ if (!ctx.common.issues.length) {
994
+ throw new Error("Validation failed but no issues detected.");
995
+ }
996
+ return {
997
+ success: false,
998
+ get error() {
999
+ if (this._error)
1000
+ return this._error;
1001
+ const error = new ZodError(ctx.common.issues);
1002
+ this._error = error;
1003
+ return this._error;
1004
+ }
1005
+ };
1006
+ }
1007
+ };
1008
+ function processCreateParams(params) {
1009
+ if (!params)
1010
+ return {};
1011
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
1012
+ if (errorMap2 && (invalid_type_error || required_error)) {
1013
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1014
+ }
1015
+ if (errorMap2)
1016
+ return { errorMap: errorMap2, description };
1017
+ const customMap = (iss, ctx) => {
1018
+ const { message } = params;
1019
+ if (iss.code === "invalid_enum_value") {
1020
+ return { message: message ?? ctx.defaultError };
1021
+ }
1022
+ if (typeof ctx.data === "undefined") {
1023
+ return { message: message ?? required_error ?? ctx.defaultError };
1024
+ }
1025
+ if (iss.code !== "invalid_type")
1026
+ return { message: ctx.defaultError };
1027
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
1028
+ };
1029
+ return { errorMap: customMap, description };
1030
+ }
1031
+ var ZodType = class {
1032
+ get description() {
1033
+ return this._def.description;
1034
+ }
1035
+ _getType(input) {
1036
+ return getParsedType(input.data);
1037
+ }
1038
+ _getOrReturnCtx(input, ctx) {
1039
+ return ctx || {
1040
+ common: input.parent.common,
1041
+ data: input.data,
1042
+ parsedType: getParsedType(input.data),
1043
+ schemaErrorMap: this._def.errorMap,
1044
+ path: input.path,
1045
+ parent: input.parent
1046
+ };
1047
+ }
1048
+ _processInputParams(input) {
1049
+ return {
1050
+ status: new ParseStatus(),
1051
+ ctx: {
1052
+ common: input.parent.common,
1053
+ data: input.data,
1054
+ parsedType: getParsedType(input.data),
1055
+ schemaErrorMap: this._def.errorMap,
1056
+ path: input.path,
1057
+ parent: input.parent
1058
+ }
1059
+ };
1060
+ }
1061
+ _parseSync(input) {
1062
+ const result = this._parse(input);
1063
+ if (isAsync(result)) {
1064
+ throw new Error("Synchronous parse encountered promise.");
1065
+ }
1066
+ return result;
1067
+ }
1068
+ _parseAsync(input) {
1069
+ const result = this._parse(input);
1070
+ return Promise.resolve(result);
1071
+ }
1072
+ parse(data, params) {
1073
+ const result = this.safeParse(data, params);
1074
+ if (result.success)
1075
+ return result.data;
1076
+ throw result.error;
1077
+ }
1078
+ safeParse(data, params) {
1079
+ const ctx = {
1080
+ common: {
1081
+ issues: [],
1082
+ async: params?.async ?? false,
1083
+ contextualErrorMap: params?.errorMap
1084
+ },
1085
+ path: params?.path || [],
1086
+ schemaErrorMap: this._def.errorMap,
1087
+ parent: null,
1088
+ data,
1089
+ parsedType: getParsedType(data)
1090
+ };
1091
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
1092
+ return handleResult(ctx, result);
1093
+ }
1094
+ "~validate"(data) {
1095
+ const ctx = {
1096
+ common: {
1097
+ issues: [],
1098
+ async: !!this["~standard"].async
1099
+ },
1100
+ path: [],
1101
+ schemaErrorMap: this._def.errorMap,
1102
+ parent: null,
1103
+ data,
1104
+ parsedType: getParsedType(data)
1105
+ };
1106
+ if (!this["~standard"].async) {
1107
+ try {
1108
+ const result = this._parseSync({ data, path: [], parent: ctx });
1109
+ return isValid(result) ? {
1110
+ value: result.value
1111
+ } : {
1112
+ issues: ctx.common.issues
1113
+ };
1114
+ } catch (err) {
1115
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
1116
+ this["~standard"].async = true;
1117
+ }
1118
+ ctx.common = {
1119
+ issues: [],
1120
+ async: true
1121
+ };
1122
+ }
1123
+ }
1124
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
1125
+ value: result.value
1126
+ } : {
1127
+ issues: ctx.common.issues
1128
+ });
1129
+ }
1130
+ async parseAsync(data, params) {
1131
+ const result = await this.safeParseAsync(data, params);
1132
+ if (result.success)
1133
+ return result.data;
1134
+ throw result.error;
1135
+ }
1136
+ async safeParseAsync(data, params) {
1137
+ const ctx = {
1138
+ common: {
1139
+ issues: [],
1140
+ contextualErrorMap: params?.errorMap,
1141
+ async: true
1142
+ },
1143
+ path: params?.path || [],
1144
+ schemaErrorMap: this._def.errorMap,
1145
+ parent: null,
1146
+ data,
1147
+ parsedType: getParsedType(data)
1148
+ };
1149
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
1150
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
1151
+ return handleResult(ctx, result);
1152
+ }
1153
+ refine(check, message) {
1154
+ const getIssueProperties = (val) => {
1155
+ if (typeof message === "string" || typeof message === "undefined") {
1156
+ return { message };
1157
+ } else if (typeof message === "function") {
1158
+ return message(val);
1159
+ } else {
1160
+ return message;
1161
+ }
1162
+ };
1163
+ return this._refinement((val, ctx) => {
1164
+ const result = check(val);
1165
+ const setError = () => ctx.addIssue({
1166
+ code: ZodIssueCode.custom,
1167
+ ...getIssueProperties(val)
1168
+ });
1169
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
1170
+ return result.then((data) => {
1171
+ if (!data) {
1172
+ setError();
1173
+ return false;
1174
+ } else {
1175
+ return true;
1176
+ }
1177
+ });
1178
+ }
1179
+ if (!result) {
1180
+ setError();
1181
+ return false;
1182
+ } else {
1183
+ return true;
1184
+ }
1185
+ });
1186
+ }
1187
+ refinement(check, refinementData) {
1188
+ return this._refinement((val, ctx) => {
1189
+ if (!check(val)) {
1190
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
1191
+ return false;
1192
+ } else {
1193
+ return true;
1194
+ }
1195
+ });
1196
+ }
1197
+ _refinement(refinement) {
1198
+ return new ZodEffects({
1199
+ schema: this,
1200
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1201
+ effect: { type: "refinement", refinement }
1202
+ });
1203
+ }
1204
+ superRefine(refinement) {
1205
+ return this._refinement(refinement);
1206
+ }
1207
+ constructor(def) {
1208
+ this.spa = this.safeParseAsync;
1209
+ this._def = def;
1210
+ this.parse = this.parse.bind(this);
1211
+ this.safeParse = this.safeParse.bind(this);
1212
+ this.parseAsync = this.parseAsync.bind(this);
1213
+ this.safeParseAsync = this.safeParseAsync.bind(this);
1214
+ this.spa = this.spa.bind(this);
1215
+ this.refine = this.refine.bind(this);
1216
+ this.refinement = this.refinement.bind(this);
1217
+ this.superRefine = this.superRefine.bind(this);
1218
+ this.optional = this.optional.bind(this);
1219
+ this.nullable = this.nullable.bind(this);
1220
+ this.nullish = this.nullish.bind(this);
1221
+ this.array = this.array.bind(this);
1222
+ this.promise = this.promise.bind(this);
1223
+ this.or = this.or.bind(this);
1224
+ this.and = this.and.bind(this);
1225
+ this.transform = this.transform.bind(this);
1226
+ this.brand = this.brand.bind(this);
1227
+ this.default = this.default.bind(this);
1228
+ this.catch = this.catch.bind(this);
1229
+ this.describe = this.describe.bind(this);
1230
+ this.pipe = this.pipe.bind(this);
1231
+ this.readonly = this.readonly.bind(this);
1232
+ this.isNullable = this.isNullable.bind(this);
1233
+ this.isOptional = this.isOptional.bind(this);
1234
+ this["~standard"] = {
1235
+ version: 1,
1236
+ vendor: "zod",
1237
+ validate: (data) => this["~validate"](data)
1238
+ };
1239
+ }
1240
+ optional() {
1241
+ return ZodOptional.create(this, this._def);
1242
+ }
1243
+ nullable() {
1244
+ return ZodNullable.create(this, this._def);
1245
+ }
1246
+ nullish() {
1247
+ return this.nullable().optional();
1248
+ }
1249
+ array() {
1250
+ return ZodArray.create(this);
1251
+ }
1252
+ promise() {
1253
+ return ZodPromise.create(this, this._def);
1254
+ }
1255
+ or(option) {
1256
+ return ZodUnion.create([this, option], this._def);
1257
+ }
1258
+ and(incoming) {
1259
+ return ZodIntersection.create(this, incoming, this._def);
1260
+ }
1261
+ transform(transform) {
1262
+ return new ZodEffects({
1263
+ ...processCreateParams(this._def),
1264
+ schema: this,
1265
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1266
+ effect: { type: "transform", transform }
1267
+ });
1268
+ }
1269
+ default(def) {
1270
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
1271
+ return new ZodDefault({
1272
+ ...processCreateParams(this._def),
1273
+ innerType: this,
1274
+ defaultValue: defaultValueFunc,
1275
+ typeName: ZodFirstPartyTypeKind.ZodDefault
1276
+ });
1277
+ }
1278
+ brand() {
1279
+ return new ZodBranded({
1280
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
1281
+ type: this,
1282
+ ...processCreateParams(this._def)
1283
+ });
1284
+ }
1285
+ catch(def) {
1286
+ const catchValueFunc = typeof def === "function" ? def : () => def;
1287
+ return new ZodCatch({
1288
+ ...processCreateParams(this._def),
1289
+ innerType: this,
1290
+ catchValue: catchValueFunc,
1291
+ typeName: ZodFirstPartyTypeKind.ZodCatch
1292
+ });
1293
+ }
1294
+ describe(description) {
1295
+ const This = this.constructor;
1296
+ return new This({
1297
+ ...this._def,
1298
+ description
1299
+ });
1300
+ }
1301
+ pipe(target) {
1302
+ return ZodPipeline.create(this, target);
1303
+ }
1304
+ readonly() {
1305
+ return ZodReadonly.create(this);
1306
+ }
1307
+ isOptional() {
1308
+ return this.safeParse(void 0).success;
1309
+ }
1310
+ isNullable() {
1311
+ return this.safeParse(null).success;
1312
+ }
1313
+ };
1314
+ var cuidRegex = /^c[^\s-]{8,}$/i;
1315
+ var cuid2Regex = /^[0-9a-z]+$/;
1316
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
1317
+ var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
1318
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
1319
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
1320
+ var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
1321
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1322
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1323
+ var emojiRegex;
1324
+ var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
1325
+ var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
1326
+ var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
1327
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
1328
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1329
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
1330
+ var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
1331
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
1332
+ function timeRegexSource(args) {
1333
+ let secondsRegexSource = `[0-5]\\d`;
1334
+ if (args.precision) {
1335
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
1336
+ } else if (args.precision == null) {
1337
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
1338
+ }
1339
+ const secondsQuantifier = args.precision ? "+" : "?";
1340
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
1341
+ }
1342
+ function timeRegex(args) {
1343
+ return new RegExp(`^${timeRegexSource(args)}$`);
1344
+ }
1345
+ function datetimeRegex(args) {
1346
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1347
+ const opts = [];
1348
+ opts.push(args.local ? `Z?` : `Z`);
1349
+ if (args.offset)
1350
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
1351
+ regex = `${regex}(${opts.join("|")})`;
1352
+ return new RegExp(`^${regex}$`);
1353
+ }
1354
+ function isValidIP(ip, version) {
1355
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1356
+ return true;
1357
+ }
1358
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1359
+ return true;
1360
+ }
1361
+ return false;
1362
+ }
1363
+ function isValidJWT(jwt, alg) {
1364
+ if (!jwtRegex.test(jwt))
1365
+ return false;
1366
+ try {
1367
+ const [header] = jwt.split(".");
1368
+ if (!header)
1369
+ return false;
1370
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
1371
+ const decoded = JSON.parse(atob(base64));
1372
+ if (typeof decoded !== "object" || decoded === null)
1373
+ return false;
1374
+ if ("typ" in decoded && decoded?.typ !== "JWT")
1375
+ return false;
1376
+ if (!decoded.alg)
1377
+ return false;
1378
+ if (alg && decoded.alg !== alg)
1379
+ return false;
1380
+ return true;
1381
+ } catch {
1382
+ return false;
1383
+ }
1384
+ }
1385
+ function isValidCidr(ip, version) {
1386
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
1387
+ return true;
1388
+ }
1389
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
1390
+ return true;
1391
+ }
1392
+ return false;
1393
+ }
1394
+ var ZodString = class _ZodString extends ZodType {
1395
+ _parse(input) {
1396
+ if (this._def.coerce) {
1397
+ input.data = String(input.data);
1398
+ }
1399
+ const parsedType = this._getType(input);
1400
+ if (parsedType !== ZodParsedType.string) {
1401
+ const ctx2 = this._getOrReturnCtx(input);
1402
+ addIssueToContext(ctx2, {
1403
+ code: ZodIssueCode.invalid_type,
1404
+ expected: ZodParsedType.string,
1405
+ received: ctx2.parsedType
1406
+ });
1407
+ return INVALID;
1408
+ }
1409
+ const status = new ParseStatus();
1410
+ let ctx = void 0;
1411
+ for (const check of this._def.checks) {
1412
+ if (check.kind === "min") {
1413
+ if (input.data.length < check.value) {
1414
+ ctx = this._getOrReturnCtx(input, ctx);
1415
+ addIssueToContext(ctx, {
1416
+ code: ZodIssueCode.too_small,
1417
+ minimum: check.value,
1418
+ type: "string",
1419
+ inclusive: true,
1420
+ exact: false,
1421
+ message: check.message
1422
+ });
1423
+ status.dirty();
1424
+ }
1425
+ } else if (check.kind === "max") {
1426
+ if (input.data.length > check.value) {
1427
+ ctx = this._getOrReturnCtx(input, ctx);
1428
+ addIssueToContext(ctx, {
1429
+ code: ZodIssueCode.too_big,
1430
+ maximum: check.value,
1431
+ type: "string",
1432
+ inclusive: true,
1433
+ exact: false,
1434
+ message: check.message
1435
+ });
1436
+ status.dirty();
1437
+ }
1438
+ } else if (check.kind === "length") {
1439
+ const tooBig = input.data.length > check.value;
1440
+ const tooSmall = input.data.length < check.value;
1441
+ if (tooBig || tooSmall) {
1442
+ ctx = this._getOrReturnCtx(input, ctx);
1443
+ if (tooBig) {
1444
+ addIssueToContext(ctx, {
1445
+ code: ZodIssueCode.too_big,
1446
+ maximum: check.value,
1447
+ type: "string",
1448
+ inclusive: true,
1449
+ exact: true,
1450
+ message: check.message
1451
+ });
1452
+ } else if (tooSmall) {
1453
+ addIssueToContext(ctx, {
1454
+ code: ZodIssueCode.too_small,
1455
+ minimum: check.value,
1456
+ type: "string",
1457
+ inclusive: true,
1458
+ exact: true,
1459
+ message: check.message
1460
+ });
1461
+ }
1462
+ status.dirty();
1463
+ }
1464
+ } else if (check.kind === "email") {
1465
+ if (!emailRegex.test(input.data)) {
1466
+ ctx = this._getOrReturnCtx(input, ctx);
1467
+ addIssueToContext(ctx, {
1468
+ validation: "email",
1469
+ code: ZodIssueCode.invalid_string,
1470
+ message: check.message
1471
+ });
1472
+ status.dirty();
1473
+ }
1474
+ } else if (check.kind === "emoji") {
1475
+ if (!emojiRegex) {
1476
+ emojiRegex = new RegExp(_emojiRegex, "u");
1477
+ }
1478
+ if (!emojiRegex.test(input.data)) {
1479
+ ctx = this._getOrReturnCtx(input, ctx);
1480
+ addIssueToContext(ctx, {
1481
+ validation: "emoji",
1482
+ code: ZodIssueCode.invalid_string,
1483
+ message: check.message
1484
+ });
1485
+ status.dirty();
1486
+ }
1487
+ } else if (check.kind === "uuid") {
1488
+ if (!uuidRegex.test(input.data)) {
1489
+ ctx = this._getOrReturnCtx(input, ctx);
1490
+ addIssueToContext(ctx, {
1491
+ validation: "uuid",
1492
+ code: ZodIssueCode.invalid_string,
1493
+ message: check.message
1494
+ });
1495
+ status.dirty();
1496
+ }
1497
+ } else if (check.kind === "nanoid") {
1498
+ if (!nanoidRegex.test(input.data)) {
1499
+ ctx = this._getOrReturnCtx(input, ctx);
1500
+ addIssueToContext(ctx, {
1501
+ validation: "nanoid",
1502
+ code: ZodIssueCode.invalid_string,
1503
+ message: check.message
1504
+ });
1505
+ status.dirty();
1506
+ }
1507
+ } else if (check.kind === "cuid") {
1508
+ if (!cuidRegex.test(input.data)) {
1509
+ ctx = this._getOrReturnCtx(input, ctx);
1510
+ addIssueToContext(ctx, {
1511
+ validation: "cuid",
1512
+ code: ZodIssueCode.invalid_string,
1513
+ message: check.message
1514
+ });
1515
+ status.dirty();
1516
+ }
1517
+ } else if (check.kind === "cuid2") {
1518
+ if (!cuid2Regex.test(input.data)) {
1519
+ ctx = this._getOrReturnCtx(input, ctx);
1520
+ addIssueToContext(ctx, {
1521
+ validation: "cuid2",
1522
+ code: ZodIssueCode.invalid_string,
1523
+ message: check.message
1524
+ });
1525
+ status.dirty();
1526
+ }
1527
+ } else if (check.kind === "ulid") {
1528
+ if (!ulidRegex.test(input.data)) {
1529
+ ctx = this._getOrReturnCtx(input, ctx);
1530
+ addIssueToContext(ctx, {
1531
+ validation: "ulid",
1532
+ code: ZodIssueCode.invalid_string,
1533
+ message: check.message
1534
+ });
1535
+ status.dirty();
1536
+ }
1537
+ } else if (check.kind === "url") {
1538
+ try {
1539
+ new URL(input.data);
1540
+ } catch {
1541
+ ctx = this._getOrReturnCtx(input, ctx);
1542
+ addIssueToContext(ctx, {
1543
+ validation: "url",
1544
+ code: ZodIssueCode.invalid_string,
1545
+ message: check.message
1546
+ });
1547
+ status.dirty();
1548
+ }
1549
+ } else if (check.kind === "regex") {
1550
+ check.regex.lastIndex = 0;
1551
+ const testResult = check.regex.test(input.data);
1552
+ if (!testResult) {
1553
+ ctx = this._getOrReturnCtx(input, ctx);
1554
+ addIssueToContext(ctx, {
1555
+ validation: "regex",
1556
+ code: ZodIssueCode.invalid_string,
1557
+ message: check.message
1558
+ });
1559
+ status.dirty();
1560
+ }
1561
+ } else if (check.kind === "trim") {
1562
+ input.data = input.data.trim();
1563
+ } else if (check.kind === "includes") {
1564
+ if (!input.data.includes(check.value, check.position)) {
1565
+ ctx = this._getOrReturnCtx(input, ctx);
1566
+ addIssueToContext(ctx, {
1567
+ code: ZodIssueCode.invalid_string,
1568
+ validation: { includes: check.value, position: check.position },
1569
+ message: check.message
1570
+ });
1571
+ status.dirty();
1572
+ }
1573
+ } else if (check.kind === "toLowerCase") {
1574
+ input.data = input.data.toLowerCase();
1575
+ } else if (check.kind === "toUpperCase") {
1576
+ input.data = input.data.toUpperCase();
1577
+ } else if (check.kind === "startsWith") {
1578
+ if (!input.data.startsWith(check.value)) {
1579
+ ctx = this._getOrReturnCtx(input, ctx);
1580
+ addIssueToContext(ctx, {
1581
+ code: ZodIssueCode.invalid_string,
1582
+ validation: { startsWith: check.value },
1583
+ message: check.message
1584
+ });
1585
+ status.dirty();
1586
+ }
1587
+ } else if (check.kind === "endsWith") {
1588
+ if (!input.data.endsWith(check.value)) {
1589
+ ctx = this._getOrReturnCtx(input, ctx);
1590
+ addIssueToContext(ctx, {
1591
+ code: ZodIssueCode.invalid_string,
1592
+ validation: { endsWith: check.value },
1593
+ message: check.message
1594
+ });
1595
+ status.dirty();
1596
+ }
1597
+ } else if (check.kind === "datetime") {
1598
+ const regex = datetimeRegex(check);
1599
+ if (!regex.test(input.data)) {
1600
+ ctx = this._getOrReturnCtx(input, ctx);
1601
+ addIssueToContext(ctx, {
1602
+ code: ZodIssueCode.invalid_string,
1603
+ validation: "datetime",
1604
+ message: check.message
1605
+ });
1606
+ status.dirty();
1607
+ }
1608
+ } else if (check.kind === "date") {
1609
+ const regex = dateRegex;
1610
+ if (!regex.test(input.data)) {
1611
+ ctx = this._getOrReturnCtx(input, ctx);
1612
+ addIssueToContext(ctx, {
1613
+ code: ZodIssueCode.invalid_string,
1614
+ validation: "date",
1615
+ message: check.message
1616
+ });
1617
+ status.dirty();
1618
+ }
1619
+ } else if (check.kind === "time") {
1620
+ const regex = timeRegex(check);
1621
+ if (!regex.test(input.data)) {
1622
+ ctx = this._getOrReturnCtx(input, ctx);
1623
+ addIssueToContext(ctx, {
1624
+ code: ZodIssueCode.invalid_string,
1625
+ validation: "time",
1626
+ message: check.message
1627
+ });
1628
+ status.dirty();
1629
+ }
1630
+ } else if (check.kind === "duration") {
1631
+ if (!durationRegex.test(input.data)) {
1632
+ ctx = this._getOrReturnCtx(input, ctx);
1633
+ addIssueToContext(ctx, {
1634
+ validation: "duration",
1635
+ code: ZodIssueCode.invalid_string,
1636
+ message: check.message
1637
+ });
1638
+ status.dirty();
1639
+ }
1640
+ } else if (check.kind === "ip") {
1641
+ if (!isValidIP(input.data, check.version)) {
1642
+ ctx = this._getOrReturnCtx(input, ctx);
1643
+ addIssueToContext(ctx, {
1644
+ validation: "ip",
1645
+ code: ZodIssueCode.invalid_string,
1646
+ message: check.message
1647
+ });
1648
+ status.dirty();
1649
+ }
1650
+ } else if (check.kind === "jwt") {
1651
+ if (!isValidJWT(input.data, check.alg)) {
1652
+ ctx = this._getOrReturnCtx(input, ctx);
1653
+ addIssueToContext(ctx, {
1654
+ validation: "jwt",
1655
+ code: ZodIssueCode.invalid_string,
1656
+ message: check.message
1657
+ });
1658
+ status.dirty();
1659
+ }
1660
+ } else if (check.kind === "cidr") {
1661
+ if (!isValidCidr(input.data, check.version)) {
1662
+ ctx = this._getOrReturnCtx(input, ctx);
1663
+ addIssueToContext(ctx, {
1664
+ validation: "cidr",
1665
+ code: ZodIssueCode.invalid_string,
1666
+ message: check.message
1667
+ });
1668
+ status.dirty();
1669
+ }
1670
+ } else if (check.kind === "base64") {
1671
+ if (!base64Regex.test(input.data)) {
1672
+ ctx = this._getOrReturnCtx(input, ctx);
1673
+ addIssueToContext(ctx, {
1674
+ validation: "base64",
1675
+ code: ZodIssueCode.invalid_string,
1676
+ message: check.message
1677
+ });
1678
+ status.dirty();
1679
+ }
1680
+ } else if (check.kind === "base64url") {
1681
+ if (!base64urlRegex.test(input.data)) {
1682
+ ctx = this._getOrReturnCtx(input, ctx);
1683
+ addIssueToContext(ctx, {
1684
+ validation: "base64url",
1685
+ code: ZodIssueCode.invalid_string,
1686
+ message: check.message
1687
+ });
1688
+ status.dirty();
1689
+ }
1690
+ } else {
1691
+ util.assertNever(check);
1692
+ }
1693
+ }
1694
+ return { status: status.value, value: input.data };
1695
+ }
1696
+ _regex(regex, validation, message) {
1697
+ return this.refinement((data) => regex.test(data), {
1698
+ validation,
1699
+ code: ZodIssueCode.invalid_string,
1700
+ ...errorUtil.errToObj(message)
1701
+ });
1702
+ }
1703
+ _addCheck(check) {
1704
+ return new _ZodString({
1705
+ ...this._def,
1706
+ checks: [...this._def.checks, check]
1707
+ });
1708
+ }
1709
+ email(message) {
1710
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1711
+ }
1712
+ url(message) {
1713
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1714
+ }
1715
+ emoji(message) {
1716
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1717
+ }
1718
+ uuid(message) {
1719
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1720
+ }
1721
+ nanoid(message) {
1722
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1723
+ }
1724
+ cuid(message) {
1725
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1726
+ }
1727
+ cuid2(message) {
1728
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1729
+ }
1730
+ ulid(message) {
1731
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1732
+ }
1733
+ base64(message) {
1734
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1735
+ }
1736
+ base64url(message) {
1737
+ return this._addCheck({
1738
+ kind: "base64url",
1739
+ ...errorUtil.errToObj(message)
1740
+ });
1741
+ }
1742
+ jwt(options) {
1743
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
1744
+ }
1745
+ ip(options) {
1746
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1747
+ }
1748
+ cidr(options) {
1749
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1750
+ }
1751
+ datetime(options) {
1752
+ if (typeof options === "string") {
1753
+ return this._addCheck({
1754
+ kind: "datetime",
1755
+ precision: null,
1756
+ offset: false,
1757
+ local: false,
1758
+ message: options
1759
+ });
1760
+ }
1761
+ return this._addCheck({
1762
+ kind: "datetime",
1763
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1764
+ offset: options?.offset ?? false,
1765
+ local: options?.local ?? false,
1766
+ ...errorUtil.errToObj(options?.message)
1767
+ });
1768
+ }
1769
+ date(message) {
1770
+ return this._addCheck({ kind: "date", message });
1771
+ }
1772
+ time(options) {
1773
+ if (typeof options === "string") {
1774
+ return this._addCheck({
1775
+ kind: "time",
1776
+ precision: null,
1777
+ message: options
1778
+ });
1779
+ }
1780
+ return this._addCheck({
1781
+ kind: "time",
1782
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1783
+ ...errorUtil.errToObj(options?.message)
1784
+ });
1785
+ }
1786
+ duration(message) {
1787
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1788
+ }
1789
+ regex(regex, message) {
1790
+ return this._addCheck({
1791
+ kind: "regex",
1792
+ regex,
1793
+ ...errorUtil.errToObj(message)
1794
+ });
1795
+ }
1796
+ includes(value, options) {
1797
+ return this._addCheck({
1798
+ kind: "includes",
1799
+ value,
1800
+ position: options?.position,
1801
+ ...errorUtil.errToObj(options?.message)
1802
+ });
1803
+ }
1804
+ startsWith(value, message) {
1805
+ return this._addCheck({
1806
+ kind: "startsWith",
1807
+ value,
1808
+ ...errorUtil.errToObj(message)
1809
+ });
1810
+ }
1811
+ endsWith(value, message) {
1812
+ return this._addCheck({
1813
+ kind: "endsWith",
1814
+ value,
1815
+ ...errorUtil.errToObj(message)
1816
+ });
1817
+ }
1818
+ min(minLength, message) {
1819
+ return this._addCheck({
1820
+ kind: "min",
1821
+ value: minLength,
1822
+ ...errorUtil.errToObj(message)
1823
+ });
1824
+ }
1825
+ max(maxLength, message) {
1826
+ return this._addCheck({
1827
+ kind: "max",
1828
+ value: maxLength,
1829
+ ...errorUtil.errToObj(message)
1830
+ });
1831
+ }
1832
+ length(len, message) {
1833
+ return this._addCheck({
1834
+ kind: "length",
1835
+ value: len,
1836
+ ...errorUtil.errToObj(message)
1837
+ });
1838
+ }
1839
+ /**
1840
+ * Equivalent to `.min(1)`
1841
+ */
1842
+ nonempty(message) {
1843
+ return this.min(1, errorUtil.errToObj(message));
1844
+ }
1845
+ trim() {
1846
+ return new _ZodString({
1847
+ ...this._def,
1848
+ checks: [...this._def.checks, { kind: "trim" }]
1849
+ });
1850
+ }
1851
+ toLowerCase() {
1852
+ return new _ZodString({
1853
+ ...this._def,
1854
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1855
+ });
1856
+ }
1857
+ toUpperCase() {
1858
+ return new _ZodString({
1859
+ ...this._def,
1860
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1861
+ });
1862
+ }
1863
+ get isDatetime() {
1864
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1865
+ }
1866
+ get isDate() {
1867
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1868
+ }
1869
+ get isTime() {
1870
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1871
+ }
1872
+ get isDuration() {
1873
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1874
+ }
1875
+ get isEmail() {
1876
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1877
+ }
1878
+ get isURL() {
1879
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1880
+ }
1881
+ get isEmoji() {
1882
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1883
+ }
1884
+ get isUUID() {
1885
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1886
+ }
1887
+ get isNANOID() {
1888
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1889
+ }
1890
+ get isCUID() {
1891
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1892
+ }
1893
+ get isCUID2() {
1894
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1895
+ }
1896
+ get isULID() {
1897
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1898
+ }
1899
+ get isIP() {
1900
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1901
+ }
1902
+ get isCIDR() {
1903
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1904
+ }
1905
+ get isBase64() {
1906
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1907
+ }
1908
+ get isBase64url() {
1909
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1910
+ }
1911
+ get minLength() {
1912
+ let min = null;
1913
+ for (const ch of this._def.checks) {
1914
+ if (ch.kind === "min") {
1915
+ if (min === null || ch.value > min)
1916
+ min = ch.value;
1917
+ }
1918
+ }
1919
+ return min;
1920
+ }
1921
+ get maxLength() {
1922
+ let max = null;
1923
+ for (const ch of this._def.checks) {
1924
+ if (ch.kind === "max") {
1925
+ if (max === null || ch.value < max)
1926
+ max = ch.value;
1927
+ }
1928
+ }
1929
+ return max;
1930
+ }
1931
+ };
1932
+ ZodString.create = (params) => {
1933
+ return new ZodString({
1934
+ checks: [],
1935
+ typeName: ZodFirstPartyTypeKind.ZodString,
1936
+ coerce: params?.coerce ?? false,
1937
+ ...processCreateParams(params)
1938
+ });
1939
+ };
1940
+ function floatSafeRemainder(val, step) {
1941
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1942
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1943
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1944
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
1945
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1946
+ return valInt % stepInt / 10 ** decCount;
1947
+ }
1948
+ var ZodNumber = class _ZodNumber extends ZodType {
1949
+ constructor() {
1950
+ super(...arguments);
1951
+ this.min = this.gte;
1952
+ this.max = this.lte;
1953
+ this.step = this.multipleOf;
1954
+ }
1955
+ _parse(input) {
1956
+ if (this._def.coerce) {
1957
+ input.data = Number(input.data);
1958
+ }
1959
+ const parsedType = this._getType(input);
1960
+ if (parsedType !== ZodParsedType.number) {
1961
+ const ctx2 = this._getOrReturnCtx(input);
1962
+ addIssueToContext(ctx2, {
1963
+ code: ZodIssueCode.invalid_type,
1964
+ expected: ZodParsedType.number,
1965
+ received: ctx2.parsedType
1966
+ });
1967
+ return INVALID;
1968
+ }
1969
+ let ctx = void 0;
1970
+ const status = new ParseStatus();
1971
+ for (const check of this._def.checks) {
1972
+ if (check.kind === "int") {
1973
+ if (!util.isInteger(input.data)) {
1974
+ ctx = this._getOrReturnCtx(input, ctx);
1975
+ addIssueToContext(ctx, {
1976
+ code: ZodIssueCode.invalid_type,
1977
+ expected: "integer",
1978
+ received: "float",
1979
+ message: check.message
1980
+ });
1981
+ status.dirty();
1982
+ }
1983
+ } else if (check.kind === "min") {
1984
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1985
+ if (tooSmall) {
1986
+ ctx = this._getOrReturnCtx(input, ctx);
1987
+ addIssueToContext(ctx, {
1988
+ code: ZodIssueCode.too_small,
1989
+ minimum: check.value,
1990
+ type: "number",
1991
+ inclusive: check.inclusive,
1992
+ exact: false,
1993
+ message: check.message
1994
+ });
1995
+ status.dirty();
1996
+ }
1997
+ } else if (check.kind === "max") {
1998
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1999
+ if (tooBig) {
2000
+ ctx = this._getOrReturnCtx(input, ctx);
2001
+ addIssueToContext(ctx, {
2002
+ code: ZodIssueCode.too_big,
2003
+ maximum: check.value,
2004
+ type: "number",
2005
+ inclusive: check.inclusive,
2006
+ exact: false,
2007
+ message: check.message
2008
+ });
2009
+ status.dirty();
2010
+ }
2011
+ } else if (check.kind === "multipleOf") {
2012
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
2013
+ ctx = this._getOrReturnCtx(input, ctx);
2014
+ addIssueToContext(ctx, {
2015
+ code: ZodIssueCode.not_multiple_of,
2016
+ multipleOf: check.value,
2017
+ message: check.message
2018
+ });
2019
+ status.dirty();
2020
+ }
2021
+ } else if (check.kind === "finite") {
2022
+ if (!Number.isFinite(input.data)) {
2023
+ ctx = this._getOrReturnCtx(input, ctx);
2024
+ addIssueToContext(ctx, {
2025
+ code: ZodIssueCode.not_finite,
2026
+ message: check.message
2027
+ });
2028
+ status.dirty();
2029
+ }
2030
+ } else {
2031
+ util.assertNever(check);
2032
+ }
2033
+ }
2034
+ return { status: status.value, value: input.data };
2035
+ }
2036
+ gte(value, message) {
2037
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2038
+ }
2039
+ gt(value, message) {
2040
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2041
+ }
2042
+ lte(value, message) {
2043
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2044
+ }
2045
+ lt(value, message) {
2046
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2047
+ }
2048
+ setLimit(kind, value, inclusive, message) {
2049
+ return new _ZodNumber({
2050
+ ...this._def,
2051
+ checks: [
2052
+ ...this._def.checks,
2053
+ {
2054
+ kind,
2055
+ value,
2056
+ inclusive,
2057
+ message: errorUtil.toString(message)
2058
+ }
2059
+ ]
2060
+ });
2061
+ }
2062
+ _addCheck(check) {
2063
+ return new _ZodNumber({
2064
+ ...this._def,
2065
+ checks: [...this._def.checks, check]
2066
+ });
2067
+ }
2068
+ int(message) {
2069
+ return this._addCheck({
2070
+ kind: "int",
2071
+ message: errorUtil.toString(message)
2072
+ });
2073
+ }
2074
+ positive(message) {
2075
+ return this._addCheck({
2076
+ kind: "min",
2077
+ value: 0,
2078
+ inclusive: false,
2079
+ message: errorUtil.toString(message)
2080
+ });
2081
+ }
2082
+ negative(message) {
2083
+ return this._addCheck({
2084
+ kind: "max",
2085
+ value: 0,
2086
+ inclusive: false,
2087
+ message: errorUtil.toString(message)
2088
+ });
2089
+ }
2090
+ nonpositive(message) {
2091
+ return this._addCheck({
2092
+ kind: "max",
2093
+ value: 0,
2094
+ inclusive: true,
2095
+ message: errorUtil.toString(message)
2096
+ });
2097
+ }
2098
+ nonnegative(message) {
2099
+ return this._addCheck({
2100
+ kind: "min",
2101
+ value: 0,
2102
+ inclusive: true,
2103
+ message: errorUtil.toString(message)
2104
+ });
2105
+ }
2106
+ multipleOf(value, message) {
2107
+ return this._addCheck({
2108
+ kind: "multipleOf",
2109
+ value,
2110
+ message: errorUtil.toString(message)
2111
+ });
2112
+ }
2113
+ finite(message) {
2114
+ return this._addCheck({
2115
+ kind: "finite",
2116
+ message: errorUtil.toString(message)
2117
+ });
2118
+ }
2119
+ safe(message) {
2120
+ return this._addCheck({
2121
+ kind: "min",
2122
+ inclusive: true,
2123
+ value: Number.MIN_SAFE_INTEGER,
2124
+ message: errorUtil.toString(message)
2125
+ })._addCheck({
2126
+ kind: "max",
2127
+ inclusive: true,
2128
+ value: Number.MAX_SAFE_INTEGER,
2129
+ message: errorUtil.toString(message)
2130
+ });
2131
+ }
2132
+ get minValue() {
2133
+ let min = null;
2134
+ for (const ch of this._def.checks) {
2135
+ if (ch.kind === "min") {
2136
+ if (min === null || ch.value > min)
2137
+ min = ch.value;
2138
+ }
2139
+ }
2140
+ return min;
2141
+ }
2142
+ get maxValue() {
2143
+ let max = null;
2144
+ for (const ch of this._def.checks) {
2145
+ if (ch.kind === "max") {
2146
+ if (max === null || ch.value < max)
2147
+ max = ch.value;
2148
+ }
2149
+ }
2150
+ return max;
2151
+ }
2152
+ get isInt() {
2153
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
2154
+ }
2155
+ get isFinite() {
2156
+ let max = null;
2157
+ let min = null;
2158
+ for (const ch of this._def.checks) {
2159
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
2160
+ return true;
2161
+ } else if (ch.kind === "min") {
2162
+ if (min === null || ch.value > min)
2163
+ min = ch.value;
2164
+ } else if (ch.kind === "max") {
2165
+ if (max === null || ch.value < max)
2166
+ max = ch.value;
2167
+ }
2168
+ }
2169
+ return Number.isFinite(min) && Number.isFinite(max);
2170
+ }
2171
+ };
2172
+ ZodNumber.create = (params) => {
2173
+ return new ZodNumber({
2174
+ checks: [],
2175
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
2176
+ coerce: params?.coerce || false,
2177
+ ...processCreateParams(params)
2178
+ });
2179
+ };
2180
+ var ZodBigInt = class _ZodBigInt extends ZodType {
2181
+ constructor() {
2182
+ super(...arguments);
2183
+ this.min = this.gte;
2184
+ this.max = this.lte;
2185
+ }
2186
+ _parse(input) {
2187
+ if (this._def.coerce) {
2188
+ try {
2189
+ input.data = BigInt(input.data);
2190
+ } catch {
2191
+ return this._getInvalidInput(input);
2192
+ }
2193
+ }
2194
+ const parsedType = this._getType(input);
2195
+ if (parsedType !== ZodParsedType.bigint) {
2196
+ return this._getInvalidInput(input);
2197
+ }
2198
+ let ctx = void 0;
2199
+ const status = new ParseStatus();
2200
+ for (const check of this._def.checks) {
2201
+ if (check.kind === "min") {
2202
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2203
+ if (tooSmall) {
2204
+ ctx = this._getOrReturnCtx(input, ctx);
2205
+ addIssueToContext(ctx, {
2206
+ code: ZodIssueCode.too_small,
2207
+ type: "bigint",
2208
+ minimum: check.value,
2209
+ inclusive: check.inclusive,
2210
+ message: check.message
2211
+ });
2212
+ status.dirty();
2213
+ }
2214
+ } else if (check.kind === "max") {
2215
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2216
+ if (tooBig) {
2217
+ ctx = this._getOrReturnCtx(input, ctx);
2218
+ addIssueToContext(ctx, {
2219
+ code: ZodIssueCode.too_big,
2220
+ type: "bigint",
2221
+ maximum: check.value,
2222
+ inclusive: check.inclusive,
2223
+ message: check.message
2224
+ });
2225
+ status.dirty();
2226
+ }
2227
+ } else if (check.kind === "multipleOf") {
2228
+ if (input.data % check.value !== BigInt(0)) {
2229
+ ctx = this._getOrReturnCtx(input, ctx);
2230
+ addIssueToContext(ctx, {
2231
+ code: ZodIssueCode.not_multiple_of,
2232
+ multipleOf: check.value,
2233
+ message: check.message
2234
+ });
2235
+ status.dirty();
2236
+ }
2237
+ } else {
2238
+ util.assertNever(check);
2239
+ }
2240
+ }
2241
+ return { status: status.value, value: input.data };
2242
+ }
2243
+ _getInvalidInput(input) {
2244
+ const ctx = this._getOrReturnCtx(input);
2245
+ addIssueToContext(ctx, {
2246
+ code: ZodIssueCode.invalid_type,
2247
+ expected: ZodParsedType.bigint,
2248
+ received: ctx.parsedType
2249
+ });
2250
+ return INVALID;
2251
+ }
2252
+ gte(value, message) {
2253
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2254
+ }
2255
+ gt(value, message) {
2256
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2257
+ }
2258
+ lte(value, message) {
2259
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2260
+ }
2261
+ lt(value, message) {
2262
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2263
+ }
2264
+ setLimit(kind, value, inclusive, message) {
2265
+ return new _ZodBigInt({
2266
+ ...this._def,
2267
+ checks: [
2268
+ ...this._def.checks,
2269
+ {
2270
+ kind,
2271
+ value,
2272
+ inclusive,
2273
+ message: errorUtil.toString(message)
2274
+ }
2275
+ ]
2276
+ });
2277
+ }
2278
+ _addCheck(check) {
2279
+ return new _ZodBigInt({
2280
+ ...this._def,
2281
+ checks: [...this._def.checks, check]
2282
+ });
2283
+ }
2284
+ positive(message) {
2285
+ return this._addCheck({
2286
+ kind: "min",
2287
+ value: BigInt(0),
2288
+ inclusive: false,
2289
+ message: errorUtil.toString(message)
2290
+ });
2291
+ }
2292
+ negative(message) {
2293
+ return this._addCheck({
2294
+ kind: "max",
2295
+ value: BigInt(0),
2296
+ inclusive: false,
2297
+ message: errorUtil.toString(message)
2298
+ });
2299
+ }
2300
+ nonpositive(message) {
2301
+ return this._addCheck({
2302
+ kind: "max",
2303
+ value: BigInt(0),
2304
+ inclusive: true,
2305
+ message: errorUtil.toString(message)
2306
+ });
2307
+ }
2308
+ nonnegative(message) {
2309
+ return this._addCheck({
2310
+ kind: "min",
2311
+ value: BigInt(0),
2312
+ inclusive: true,
2313
+ message: errorUtil.toString(message)
2314
+ });
2315
+ }
2316
+ multipleOf(value, message) {
2317
+ return this._addCheck({
2318
+ kind: "multipleOf",
2319
+ value,
2320
+ message: errorUtil.toString(message)
2321
+ });
2322
+ }
2323
+ get minValue() {
2324
+ let min = null;
2325
+ for (const ch of this._def.checks) {
2326
+ if (ch.kind === "min") {
2327
+ if (min === null || ch.value > min)
2328
+ min = ch.value;
2329
+ }
2330
+ }
2331
+ return min;
2332
+ }
2333
+ get maxValue() {
2334
+ let max = null;
2335
+ for (const ch of this._def.checks) {
2336
+ if (ch.kind === "max") {
2337
+ if (max === null || ch.value < max)
2338
+ max = ch.value;
2339
+ }
2340
+ }
2341
+ return max;
2342
+ }
2343
+ };
2344
+ ZodBigInt.create = (params) => {
2345
+ return new ZodBigInt({
2346
+ checks: [],
2347
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
2348
+ coerce: params?.coerce ?? false,
2349
+ ...processCreateParams(params)
2350
+ });
2351
+ };
2352
+ var ZodBoolean = class extends ZodType {
2353
+ _parse(input) {
2354
+ if (this._def.coerce) {
2355
+ input.data = Boolean(input.data);
2356
+ }
2357
+ const parsedType = this._getType(input);
2358
+ if (parsedType !== ZodParsedType.boolean) {
2359
+ const ctx = this._getOrReturnCtx(input);
2360
+ addIssueToContext(ctx, {
2361
+ code: ZodIssueCode.invalid_type,
2362
+ expected: ZodParsedType.boolean,
2363
+ received: ctx.parsedType
2364
+ });
2365
+ return INVALID;
2366
+ }
2367
+ return OK(input.data);
2368
+ }
2369
+ };
2370
+ ZodBoolean.create = (params) => {
2371
+ return new ZodBoolean({
2372
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
2373
+ coerce: params?.coerce || false,
2374
+ ...processCreateParams(params)
2375
+ });
2376
+ };
2377
+ var ZodDate = class _ZodDate extends ZodType {
2378
+ _parse(input) {
2379
+ if (this._def.coerce) {
2380
+ input.data = new Date(input.data);
2381
+ }
2382
+ const parsedType = this._getType(input);
2383
+ if (parsedType !== ZodParsedType.date) {
2384
+ const ctx2 = this._getOrReturnCtx(input);
2385
+ addIssueToContext(ctx2, {
2386
+ code: ZodIssueCode.invalid_type,
2387
+ expected: ZodParsedType.date,
2388
+ received: ctx2.parsedType
2389
+ });
2390
+ return INVALID;
2391
+ }
2392
+ if (Number.isNaN(input.data.getTime())) {
2393
+ const ctx2 = this._getOrReturnCtx(input);
2394
+ addIssueToContext(ctx2, {
2395
+ code: ZodIssueCode.invalid_date
2396
+ });
2397
+ return INVALID;
2398
+ }
2399
+ const status = new ParseStatus();
2400
+ let ctx = void 0;
2401
+ for (const check of this._def.checks) {
2402
+ if (check.kind === "min") {
2403
+ if (input.data.getTime() < check.value) {
2404
+ ctx = this._getOrReturnCtx(input, ctx);
2405
+ addIssueToContext(ctx, {
2406
+ code: ZodIssueCode.too_small,
2407
+ message: check.message,
2408
+ inclusive: true,
2409
+ exact: false,
2410
+ minimum: check.value,
2411
+ type: "date"
2412
+ });
2413
+ status.dirty();
2414
+ }
2415
+ } else if (check.kind === "max") {
2416
+ if (input.data.getTime() > check.value) {
2417
+ ctx = this._getOrReturnCtx(input, ctx);
2418
+ addIssueToContext(ctx, {
2419
+ code: ZodIssueCode.too_big,
2420
+ message: check.message,
2421
+ inclusive: true,
2422
+ exact: false,
2423
+ maximum: check.value,
2424
+ type: "date"
2425
+ });
2426
+ status.dirty();
2427
+ }
2428
+ } else {
2429
+ util.assertNever(check);
2430
+ }
2431
+ }
2432
+ return {
2433
+ status: status.value,
2434
+ value: new Date(input.data.getTime())
2435
+ };
2436
+ }
2437
+ _addCheck(check) {
2438
+ return new _ZodDate({
2439
+ ...this._def,
2440
+ checks: [...this._def.checks, check]
2441
+ });
2442
+ }
2443
+ min(minDate, message) {
2444
+ return this._addCheck({
2445
+ kind: "min",
2446
+ value: minDate.getTime(),
2447
+ message: errorUtil.toString(message)
2448
+ });
2449
+ }
2450
+ max(maxDate, message) {
2451
+ return this._addCheck({
2452
+ kind: "max",
2453
+ value: maxDate.getTime(),
2454
+ message: errorUtil.toString(message)
2455
+ });
2456
+ }
2457
+ get minDate() {
2458
+ let min = null;
2459
+ for (const ch of this._def.checks) {
2460
+ if (ch.kind === "min") {
2461
+ if (min === null || ch.value > min)
2462
+ min = ch.value;
2463
+ }
2464
+ }
2465
+ return min != null ? new Date(min) : null;
2466
+ }
2467
+ get maxDate() {
2468
+ let max = null;
2469
+ for (const ch of this._def.checks) {
2470
+ if (ch.kind === "max") {
2471
+ if (max === null || ch.value < max)
2472
+ max = ch.value;
2473
+ }
2474
+ }
2475
+ return max != null ? new Date(max) : null;
2476
+ }
2477
+ };
2478
+ ZodDate.create = (params) => {
2479
+ return new ZodDate({
2480
+ checks: [],
2481
+ coerce: params?.coerce || false,
2482
+ typeName: ZodFirstPartyTypeKind.ZodDate,
2483
+ ...processCreateParams(params)
2484
+ });
2485
+ };
2486
+ var ZodSymbol = class extends ZodType {
2487
+ _parse(input) {
2488
+ const parsedType = this._getType(input);
2489
+ if (parsedType !== ZodParsedType.symbol) {
2490
+ const ctx = this._getOrReturnCtx(input);
2491
+ addIssueToContext(ctx, {
2492
+ code: ZodIssueCode.invalid_type,
2493
+ expected: ZodParsedType.symbol,
2494
+ received: ctx.parsedType
2495
+ });
2496
+ return INVALID;
2497
+ }
2498
+ return OK(input.data);
2499
+ }
2500
+ };
2501
+ ZodSymbol.create = (params) => {
2502
+ return new ZodSymbol({
2503
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2504
+ ...processCreateParams(params)
2505
+ });
2506
+ };
2507
+ var ZodUndefined = class extends ZodType {
2508
+ _parse(input) {
2509
+ const parsedType = this._getType(input);
2510
+ if (parsedType !== ZodParsedType.undefined) {
2511
+ const ctx = this._getOrReturnCtx(input);
2512
+ addIssueToContext(ctx, {
2513
+ code: ZodIssueCode.invalid_type,
2514
+ expected: ZodParsedType.undefined,
2515
+ received: ctx.parsedType
2516
+ });
2517
+ return INVALID;
2518
+ }
2519
+ return OK(input.data);
2520
+ }
2521
+ };
2522
+ ZodUndefined.create = (params) => {
2523
+ return new ZodUndefined({
2524
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2525
+ ...processCreateParams(params)
2526
+ });
2527
+ };
2528
+ var ZodNull = class extends ZodType {
2529
+ _parse(input) {
2530
+ const parsedType = this._getType(input);
2531
+ if (parsedType !== ZodParsedType.null) {
2532
+ const ctx = this._getOrReturnCtx(input);
2533
+ addIssueToContext(ctx, {
2534
+ code: ZodIssueCode.invalid_type,
2535
+ expected: ZodParsedType.null,
2536
+ received: ctx.parsedType
2537
+ });
2538
+ return INVALID;
2539
+ }
2540
+ return OK(input.data);
2541
+ }
2542
+ };
2543
+ ZodNull.create = (params) => {
2544
+ return new ZodNull({
2545
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2546
+ ...processCreateParams(params)
2547
+ });
2548
+ };
2549
+ var ZodAny = class extends ZodType {
2550
+ constructor() {
2551
+ super(...arguments);
2552
+ this._any = true;
2553
+ }
2554
+ _parse(input) {
2555
+ return OK(input.data);
2556
+ }
2557
+ };
2558
+ ZodAny.create = (params) => {
2559
+ return new ZodAny({
2560
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2561
+ ...processCreateParams(params)
2562
+ });
2563
+ };
2564
+ var ZodUnknown = class extends ZodType {
2565
+ constructor() {
2566
+ super(...arguments);
2567
+ this._unknown = true;
2568
+ }
2569
+ _parse(input) {
2570
+ return OK(input.data);
2571
+ }
2572
+ };
2573
+ ZodUnknown.create = (params) => {
2574
+ return new ZodUnknown({
2575
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2576
+ ...processCreateParams(params)
2577
+ });
2578
+ };
2579
+ var ZodNever = class extends ZodType {
2580
+ _parse(input) {
2581
+ const ctx = this._getOrReturnCtx(input);
2582
+ addIssueToContext(ctx, {
2583
+ code: ZodIssueCode.invalid_type,
2584
+ expected: ZodParsedType.never,
2585
+ received: ctx.parsedType
2586
+ });
2587
+ return INVALID;
2588
+ }
2589
+ };
2590
+ ZodNever.create = (params) => {
2591
+ return new ZodNever({
2592
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2593
+ ...processCreateParams(params)
2594
+ });
2595
+ };
2596
+ var ZodVoid = class extends ZodType {
2597
+ _parse(input) {
2598
+ const parsedType = this._getType(input);
2599
+ if (parsedType !== ZodParsedType.undefined) {
2600
+ const ctx = this._getOrReturnCtx(input);
2601
+ addIssueToContext(ctx, {
2602
+ code: ZodIssueCode.invalid_type,
2603
+ expected: ZodParsedType.void,
2604
+ received: ctx.parsedType
2605
+ });
2606
+ return INVALID;
2607
+ }
2608
+ return OK(input.data);
2609
+ }
2610
+ };
2611
+ ZodVoid.create = (params) => {
2612
+ return new ZodVoid({
2613
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2614
+ ...processCreateParams(params)
2615
+ });
2616
+ };
2617
+ var ZodArray = class _ZodArray extends ZodType {
2618
+ _parse(input) {
2619
+ const { ctx, status } = this._processInputParams(input);
2620
+ const def = this._def;
2621
+ if (ctx.parsedType !== ZodParsedType.array) {
2622
+ addIssueToContext(ctx, {
2623
+ code: ZodIssueCode.invalid_type,
2624
+ expected: ZodParsedType.array,
2625
+ received: ctx.parsedType
2626
+ });
2627
+ return INVALID;
2628
+ }
2629
+ if (def.exactLength !== null) {
2630
+ const tooBig = ctx.data.length > def.exactLength.value;
2631
+ const tooSmall = ctx.data.length < def.exactLength.value;
2632
+ if (tooBig || tooSmall) {
2633
+ addIssueToContext(ctx, {
2634
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2635
+ minimum: tooSmall ? def.exactLength.value : void 0,
2636
+ maximum: tooBig ? def.exactLength.value : void 0,
2637
+ type: "array",
2638
+ inclusive: true,
2639
+ exact: true,
2640
+ message: def.exactLength.message
2641
+ });
2642
+ status.dirty();
2643
+ }
2644
+ }
2645
+ if (def.minLength !== null) {
2646
+ if (ctx.data.length < def.minLength.value) {
2647
+ addIssueToContext(ctx, {
2648
+ code: ZodIssueCode.too_small,
2649
+ minimum: def.minLength.value,
2650
+ type: "array",
2651
+ inclusive: true,
2652
+ exact: false,
2653
+ message: def.minLength.message
2654
+ });
2655
+ status.dirty();
2656
+ }
2657
+ }
2658
+ if (def.maxLength !== null) {
2659
+ if (ctx.data.length > def.maxLength.value) {
2660
+ addIssueToContext(ctx, {
2661
+ code: ZodIssueCode.too_big,
2662
+ maximum: def.maxLength.value,
2663
+ type: "array",
2664
+ inclusive: true,
2665
+ exact: false,
2666
+ message: def.maxLength.message
2667
+ });
2668
+ status.dirty();
2669
+ }
2670
+ }
2671
+ if (ctx.common.async) {
2672
+ return Promise.all([...ctx.data].map((item, i) => {
2673
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2674
+ })).then((result2) => {
2675
+ return ParseStatus.mergeArray(status, result2);
2676
+ });
2677
+ }
2678
+ const result = [...ctx.data].map((item, i) => {
2679
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2680
+ });
2681
+ return ParseStatus.mergeArray(status, result);
2682
+ }
2683
+ get element() {
2684
+ return this._def.type;
2685
+ }
2686
+ min(minLength, message) {
2687
+ return new _ZodArray({
2688
+ ...this._def,
2689
+ minLength: { value: minLength, message: errorUtil.toString(message) }
2690
+ });
2691
+ }
2692
+ max(maxLength, message) {
2693
+ return new _ZodArray({
2694
+ ...this._def,
2695
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
2696
+ });
2697
+ }
2698
+ length(len, message) {
2699
+ return new _ZodArray({
2700
+ ...this._def,
2701
+ exactLength: { value: len, message: errorUtil.toString(message) }
2702
+ });
2703
+ }
2704
+ nonempty(message) {
2705
+ return this.min(1, message);
2706
+ }
2707
+ };
2708
+ ZodArray.create = (schema, params) => {
2709
+ return new ZodArray({
2710
+ type: schema,
2711
+ minLength: null,
2712
+ maxLength: null,
2713
+ exactLength: null,
2714
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2715
+ ...processCreateParams(params)
2716
+ });
2717
+ };
2718
+ function deepPartialify(schema) {
2719
+ if (schema instanceof ZodObject) {
2720
+ const newShape = {};
2721
+ for (const key in schema.shape) {
2722
+ const fieldSchema = schema.shape[key];
2723
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2724
+ }
2725
+ return new ZodObject({
2726
+ ...schema._def,
2727
+ shape: () => newShape
2728
+ });
2729
+ } else if (schema instanceof ZodArray) {
2730
+ return new ZodArray({
2731
+ ...schema._def,
2732
+ type: deepPartialify(schema.element)
2733
+ });
2734
+ } else if (schema instanceof ZodOptional) {
2735
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
2736
+ } else if (schema instanceof ZodNullable) {
2737
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
2738
+ } else if (schema instanceof ZodTuple) {
2739
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2740
+ } else {
2741
+ return schema;
2742
+ }
2743
+ }
2744
+ var ZodObject = class _ZodObject extends ZodType {
2745
+ constructor() {
2746
+ super(...arguments);
2747
+ this._cached = null;
2748
+ this.nonstrict = this.passthrough;
2749
+ this.augment = this.extend;
2750
+ }
2751
+ _getCached() {
2752
+ if (this._cached !== null)
2753
+ return this._cached;
2754
+ const shape = this._def.shape();
2755
+ const keys = util.objectKeys(shape);
2756
+ this._cached = { shape, keys };
2757
+ return this._cached;
2758
+ }
2759
+ _parse(input) {
2760
+ const parsedType = this._getType(input);
2761
+ if (parsedType !== ZodParsedType.object) {
2762
+ const ctx2 = this._getOrReturnCtx(input);
2763
+ addIssueToContext(ctx2, {
2764
+ code: ZodIssueCode.invalid_type,
2765
+ expected: ZodParsedType.object,
2766
+ received: ctx2.parsedType
2767
+ });
2768
+ return INVALID;
2769
+ }
2770
+ const { status, ctx } = this._processInputParams(input);
2771
+ const { shape, keys: shapeKeys } = this._getCached();
2772
+ const extraKeys = [];
2773
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2774
+ for (const key in ctx.data) {
2775
+ if (!shapeKeys.includes(key)) {
2776
+ extraKeys.push(key);
2777
+ }
2778
+ }
2779
+ }
2780
+ const pairs = [];
2781
+ for (const key of shapeKeys) {
2782
+ const keyValidator = shape[key];
2783
+ const value = ctx.data[key];
2784
+ pairs.push({
2785
+ key: { status: "valid", value: key },
2786
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2787
+ alwaysSet: key in ctx.data
2788
+ });
2789
+ }
2790
+ if (this._def.catchall instanceof ZodNever) {
2791
+ const unknownKeys = this._def.unknownKeys;
2792
+ if (unknownKeys === "passthrough") {
2793
+ for (const key of extraKeys) {
2794
+ pairs.push({
2795
+ key: { status: "valid", value: key },
2796
+ value: { status: "valid", value: ctx.data[key] }
2797
+ });
2798
+ }
2799
+ } else if (unknownKeys === "strict") {
2800
+ if (extraKeys.length > 0) {
2801
+ addIssueToContext(ctx, {
2802
+ code: ZodIssueCode.unrecognized_keys,
2803
+ keys: extraKeys
2804
+ });
2805
+ status.dirty();
2806
+ }
2807
+ } else if (unknownKeys === "strip") {
2808
+ } else {
2809
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2810
+ }
2811
+ } else {
2812
+ const catchall = this._def.catchall;
2813
+ for (const key of extraKeys) {
2814
+ const value = ctx.data[key];
2815
+ pairs.push({
2816
+ key: { status: "valid", value: key },
2817
+ value: catchall._parse(
2818
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
2819
+ //, ctx.child(key), value, getParsedType(value)
2820
+ ),
2821
+ alwaysSet: key in ctx.data
2822
+ });
2823
+ }
2824
+ }
2825
+ if (ctx.common.async) {
2826
+ return Promise.resolve().then(async () => {
2827
+ const syncPairs = [];
2828
+ for (const pair of pairs) {
2829
+ const key = await pair.key;
2830
+ const value = await pair.value;
2831
+ syncPairs.push({
2832
+ key,
2833
+ value,
2834
+ alwaysSet: pair.alwaysSet
2835
+ });
2836
+ }
2837
+ return syncPairs;
2838
+ }).then((syncPairs) => {
2839
+ return ParseStatus.mergeObjectSync(status, syncPairs);
2840
+ });
2841
+ } else {
2842
+ return ParseStatus.mergeObjectSync(status, pairs);
2843
+ }
2844
+ }
2845
+ get shape() {
2846
+ return this._def.shape();
2847
+ }
2848
+ strict(message) {
2849
+ errorUtil.errToObj;
2850
+ return new _ZodObject({
2851
+ ...this._def,
2852
+ unknownKeys: "strict",
2853
+ ...message !== void 0 ? {
2854
+ errorMap: (issue, ctx) => {
2855
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2856
+ if (issue.code === "unrecognized_keys")
2857
+ return {
2858
+ message: errorUtil.errToObj(message).message ?? defaultError
2859
+ };
2860
+ return {
2861
+ message: defaultError
2862
+ };
2863
+ }
2864
+ } : {}
2865
+ });
2866
+ }
2867
+ strip() {
2868
+ return new _ZodObject({
2869
+ ...this._def,
2870
+ unknownKeys: "strip"
2871
+ });
2872
+ }
2873
+ passthrough() {
2874
+ return new _ZodObject({
2875
+ ...this._def,
2876
+ unknownKeys: "passthrough"
2877
+ });
2878
+ }
2879
+ // const AugmentFactory =
2880
+ // <Def extends ZodObjectDef>(def: Def) =>
2881
+ // <Augmentation extends ZodRawShape>(
2882
+ // augmentation: Augmentation
2883
+ // ): ZodObject<
2884
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2885
+ // Def["unknownKeys"],
2886
+ // Def["catchall"]
2887
+ // > => {
2888
+ // return new ZodObject({
2889
+ // ...def,
2890
+ // shape: () => ({
2891
+ // ...def.shape(),
2892
+ // ...augmentation,
2893
+ // }),
2894
+ // }) as any;
2895
+ // };
2896
+ extend(augmentation) {
2897
+ return new _ZodObject({
2898
+ ...this._def,
2899
+ shape: () => ({
2900
+ ...this._def.shape(),
2901
+ ...augmentation
2902
+ })
2903
+ });
2904
+ }
2905
+ /**
2906
+ * Prior to zod@1.0.12 there was a bug in the
2907
+ * inferred type of merged objects. Please
2908
+ * upgrade if you are experiencing issues.
2909
+ */
2910
+ merge(merging) {
2911
+ const merged = new _ZodObject({
2912
+ unknownKeys: merging._def.unknownKeys,
2913
+ catchall: merging._def.catchall,
2914
+ shape: () => ({
2915
+ ...this._def.shape(),
2916
+ ...merging._def.shape()
2917
+ }),
2918
+ typeName: ZodFirstPartyTypeKind.ZodObject
2919
+ });
2920
+ return merged;
2921
+ }
2922
+ // merge<
2923
+ // Incoming extends AnyZodObject,
2924
+ // Augmentation extends Incoming["shape"],
2925
+ // NewOutput extends {
2926
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2927
+ // ? Augmentation[k]["_output"]
2928
+ // : k extends keyof Output
2929
+ // ? Output[k]
2930
+ // : never;
2931
+ // },
2932
+ // NewInput extends {
2933
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2934
+ // ? Augmentation[k]["_input"]
2935
+ // : k extends keyof Input
2936
+ // ? Input[k]
2937
+ // : never;
2938
+ // }
2939
+ // >(
2940
+ // merging: Incoming
2941
+ // ): ZodObject<
2942
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2943
+ // Incoming["_def"]["unknownKeys"],
2944
+ // Incoming["_def"]["catchall"],
2945
+ // NewOutput,
2946
+ // NewInput
2947
+ // > {
2948
+ // const merged: any = new ZodObject({
2949
+ // unknownKeys: merging._def.unknownKeys,
2950
+ // catchall: merging._def.catchall,
2951
+ // shape: () =>
2952
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2953
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2954
+ // }) as any;
2955
+ // return merged;
2956
+ // }
2957
+ setKey(key, schema) {
2958
+ return this.augment({ [key]: schema });
2959
+ }
2960
+ // merge<Incoming extends AnyZodObject>(
2961
+ // merging: Incoming
2962
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2963
+ // ZodObject<
2964
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2965
+ // Incoming["_def"]["unknownKeys"],
2966
+ // Incoming["_def"]["catchall"]
2967
+ // > {
2968
+ // // const mergedShape = objectUtil.mergeShapes(
2969
+ // // this._def.shape(),
2970
+ // // merging._def.shape()
2971
+ // // );
2972
+ // const merged: any = new ZodObject({
2973
+ // unknownKeys: merging._def.unknownKeys,
2974
+ // catchall: merging._def.catchall,
2975
+ // shape: () =>
2976
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2977
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2978
+ // }) as any;
2979
+ // return merged;
2980
+ // }
2981
+ catchall(index) {
2982
+ return new _ZodObject({
2983
+ ...this._def,
2984
+ catchall: index
2985
+ });
2986
+ }
2987
+ pick(mask) {
2988
+ const shape = {};
2989
+ for (const key of util.objectKeys(mask)) {
2990
+ if (mask[key] && this.shape[key]) {
2991
+ shape[key] = this.shape[key];
2992
+ }
2993
+ }
2994
+ return new _ZodObject({
2995
+ ...this._def,
2996
+ shape: () => shape
2997
+ });
2998
+ }
2999
+ omit(mask) {
3000
+ const shape = {};
3001
+ for (const key of util.objectKeys(this.shape)) {
3002
+ if (!mask[key]) {
3003
+ shape[key] = this.shape[key];
3004
+ }
3005
+ }
3006
+ return new _ZodObject({
3007
+ ...this._def,
3008
+ shape: () => shape
3009
+ });
3010
+ }
3011
+ /**
3012
+ * @deprecated
3013
+ */
3014
+ deepPartial() {
3015
+ return deepPartialify(this);
3016
+ }
3017
+ partial(mask) {
3018
+ const newShape = {};
3019
+ for (const key of util.objectKeys(this.shape)) {
3020
+ const fieldSchema = this.shape[key];
3021
+ if (mask && !mask[key]) {
3022
+ newShape[key] = fieldSchema;
3023
+ } else {
3024
+ newShape[key] = fieldSchema.optional();
3025
+ }
3026
+ }
3027
+ return new _ZodObject({
3028
+ ...this._def,
3029
+ shape: () => newShape
3030
+ });
3031
+ }
3032
+ required(mask) {
3033
+ const newShape = {};
3034
+ for (const key of util.objectKeys(this.shape)) {
3035
+ if (mask && !mask[key]) {
3036
+ newShape[key] = this.shape[key];
3037
+ } else {
3038
+ const fieldSchema = this.shape[key];
3039
+ let newField = fieldSchema;
3040
+ while (newField instanceof ZodOptional) {
3041
+ newField = newField._def.innerType;
3042
+ }
3043
+ newShape[key] = newField;
3044
+ }
3045
+ }
3046
+ return new _ZodObject({
3047
+ ...this._def,
3048
+ shape: () => newShape
3049
+ });
3050
+ }
3051
+ keyof() {
3052
+ return createZodEnum(util.objectKeys(this.shape));
3053
+ }
3054
+ };
3055
+ ZodObject.create = (shape, params) => {
3056
+ return new ZodObject({
3057
+ shape: () => shape,
3058
+ unknownKeys: "strip",
3059
+ catchall: ZodNever.create(),
3060
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3061
+ ...processCreateParams(params)
3062
+ });
3063
+ };
3064
+ ZodObject.strictCreate = (shape, params) => {
3065
+ return new ZodObject({
3066
+ shape: () => shape,
3067
+ unknownKeys: "strict",
3068
+ catchall: ZodNever.create(),
3069
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3070
+ ...processCreateParams(params)
3071
+ });
3072
+ };
3073
+ ZodObject.lazycreate = (shape, params) => {
3074
+ return new ZodObject({
3075
+ shape,
3076
+ unknownKeys: "strip",
3077
+ catchall: ZodNever.create(),
3078
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3079
+ ...processCreateParams(params)
3080
+ });
3081
+ };
3082
+ var ZodUnion = class extends ZodType {
3083
+ _parse(input) {
3084
+ const { ctx } = this._processInputParams(input);
3085
+ const options = this._def.options;
3086
+ function handleResults(results) {
3087
+ for (const result of results) {
3088
+ if (result.result.status === "valid") {
3089
+ return result.result;
3090
+ }
3091
+ }
3092
+ for (const result of results) {
3093
+ if (result.result.status === "dirty") {
3094
+ ctx.common.issues.push(...result.ctx.common.issues);
3095
+ return result.result;
3096
+ }
3097
+ }
3098
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
3099
+ addIssueToContext(ctx, {
3100
+ code: ZodIssueCode.invalid_union,
3101
+ unionErrors
3102
+ });
3103
+ return INVALID;
3104
+ }
3105
+ if (ctx.common.async) {
3106
+ return Promise.all(options.map(async (option) => {
3107
+ const childCtx = {
3108
+ ...ctx,
3109
+ common: {
3110
+ ...ctx.common,
3111
+ issues: []
3112
+ },
3113
+ parent: null
3114
+ };
3115
+ return {
3116
+ result: await option._parseAsync({
3117
+ data: ctx.data,
3118
+ path: ctx.path,
3119
+ parent: childCtx
3120
+ }),
3121
+ ctx: childCtx
3122
+ };
3123
+ })).then(handleResults);
3124
+ } else {
3125
+ let dirty = void 0;
3126
+ const issues = [];
3127
+ for (const option of options) {
3128
+ const childCtx = {
3129
+ ...ctx,
3130
+ common: {
3131
+ ...ctx.common,
3132
+ issues: []
3133
+ },
3134
+ parent: null
3135
+ };
3136
+ const result = option._parseSync({
3137
+ data: ctx.data,
3138
+ path: ctx.path,
3139
+ parent: childCtx
3140
+ });
3141
+ if (result.status === "valid") {
3142
+ return result;
3143
+ } else if (result.status === "dirty" && !dirty) {
3144
+ dirty = { result, ctx: childCtx };
3145
+ }
3146
+ if (childCtx.common.issues.length) {
3147
+ issues.push(childCtx.common.issues);
3148
+ }
3149
+ }
3150
+ if (dirty) {
3151
+ ctx.common.issues.push(...dirty.ctx.common.issues);
3152
+ return dirty.result;
3153
+ }
3154
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
3155
+ addIssueToContext(ctx, {
3156
+ code: ZodIssueCode.invalid_union,
3157
+ unionErrors
3158
+ });
3159
+ return INVALID;
3160
+ }
3161
+ }
3162
+ get options() {
3163
+ return this._def.options;
3164
+ }
3165
+ };
3166
+ ZodUnion.create = (types, params) => {
3167
+ return new ZodUnion({
3168
+ options: types,
3169
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
3170
+ ...processCreateParams(params)
3171
+ });
3172
+ };
3173
+ var getDiscriminator = (type) => {
3174
+ if (type instanceof ZodLazy) {
3175
+ return getDiscriminator(type.schema);
3176
+ } else if (type instanceof ZodEffects) {
3177
+ return getDiscriminator(type.innerType());
3178
+ } else if (type instanceof ZodLiteral) {
3179
+ return [type.value];
3180
+ } else if (type instanceof ZodEnum) {
3181
+ return type.options;
3182
+ } else if (type instanceof ZodNativeEnum) {
3183
+ return util.objectValues(type.enum);
3184
+ } else if (type instanceof ZodDefault) {
3185
+ return getDiscriminator(type._def.innerType);
3186
+ } else if (type instanceof ZodUndefined) {
3187
+ return [void 0];
3188
+ } else if (type instanceof ZodNull) {
3189
+ return [null];
3190
+ } else if (type instanceof ZodOptional) {
3191
+ return [void 0, ...getDiscriminator(type.unwrap())];
3192
+ } else if (type instanceof ZodNullable) {
3193
+ return [null, ...getDiscriminator(type.unwrap())];
3194
+ } else if (type instanceof ZodBranded) {
3195
+ return getDiscriminator(type.unwrap());
3196
+ } else if (type instanceof ZodReadonly) {
3197
+ return getDiscriminator(type.unwrap());
3198
+ } else if (type instanceof ZodCatch) {
3199
+ return getDiscriminator(type._def.innerType);
3200
+ } else {
3201
+ return [];
3202
+ }
3203
+ };
3204
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
3205
+ _parse(input) {
3206
+ const { ctx } = this._processInputParams(input);
3207
+ if (ctx.parsedType !== ZodParsedType.object) {
3208
+ addIssueToContext(ctx, {
3209
+ code: ZodIssueCode.invalid_type,
3210
+ expected: ZodParsedType.object,
3211
+ received: ctx.parsedType
3212
+ });
3213
+ return INVALID;
3214
+ }
3215
+ const discriminator = this.discriminator;
3216
+ const discriminatorValue = ctx.data[discriminator];
3217
+ const option = this.optionsMap.get(discriminatorValue);
3218
+ if (!option) {
3219
+ addIssueToContext(ctx, {
3220
+ code: ZodIssueCode.invalid_union_discriminator,
3221
+ options: Array.from(this.optionsMap.keys()),
3222
+ path: [discriminator]
3223
+ });
3224
+ return INVALID;
3225
+ }
3226
+ if (ctx.common.async) {
3227
+ return option._parseAsync({
3228
+ data: ctx.data,
3229
+ path: ctx.path,
3230
+ parent: ctx
3231
+ });
3232
+ } else {
3233
+ return option._parseSync({
3234
+ data: ctx.data,
3235
+ path: ctx.path,
3236
+ parent: ctx
3237
+ });
3238
+ }
3239
+ }
3240
+ get discriminator() {
3241
+ return this._def.discriminator;
3242
+ }
3243
+ get options() {
3244
+ return this._def.options;
3245
+ }
3246
+ get optionsMap() {
3247
+ return this._def.optionsMap;
3248
+ }
3249
+ /**
3250
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3251
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3252
+ * have a different value for each object in the union.
3253
+ * @param discriminator the name of the discriminator property
3254
+ * @param types an array of object schemas
3255
+ * @param params
3256
+ */
3257
+ static create(discriminator, options, params) {
3258
+ const optionsMap = /* @__PURE__ */ new Map();
3259
+ for (const type of options) {
3260
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3261
+ if (!discriminatorValues.length) {
3262
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3263
+ }
3264
+ for (const value of discriminatorValues) {
3265
+ if (optionsMap.has(value)) {
3266
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3267
+ }
3268
+ optionsMap.set(value, type);
3269
+ }
3270
+ }
3271
+ return new _ZodDiscriminatedUnion({
3272
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3273
+ discriminator,
3274
+ options,
3275
+ optionsMap,
3276
+ ...processCreateParams(params)
3277
+ });
3278
+ }
3279
+ };
3280
+ function mergeValues(a, b) {
3281
+ const aType = getParsedType(a);
3282
+ const bType = getParsedType(b);
3283
+ if (a === b) {
3284
+ return { valid: true, data: a };
3285
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
3286
+ const bKeys = util.objectKeys(b);
3287
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
3288
+ const newObj = { ...a, ...b };
3289
+ for (const key of sharedKeys) {
3290
+ const sharedValue = mergeValues(a[key], b[key]);
3291
+ if (!sharedValue.valid) {
3292
+ return { valid: false };
3293
+ }
3294
+ newObj[key] = sharedValue.data;
3295
+ }
3296
+ return { valid: true, data: newObj };
3297
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
3298
+ if (a.length !== b.length) {
3299
+ return { valid: false };
3300
+ }
3301
+ const newArray = [];
3302
+ for (let index = 0; index < a.length; index++) {
3303
+ const itemA = a[index];
3304
+ const itemB = b[index];
3305
+ const sharedValue = mergeValues(itemA, itemB);
3306
+ if (!sharedValue.valid) {
3307
+ return { valid: false };
3308
+ }
3309
+ newArray.push(sharedValue.data);
3310
+ }
3311
+ return { valid: true, data: newArray };
3312
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
3313
+ return { valid: true, data: a };
3314
+ } else {
3315
+ return { valid: false };
3316
+ }
3317
+ }
3318
+ var ZodIntersection = class extends ZodType {
3319
+ _parse(input) {
3320
+ const { status, ctx } = this._processInputParams(input);
3321
+ const handleParsed = (parsedLeft, parsedRight) => {
3322
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
3323
+ return INVALID;
3324
+ }
3325
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
3326
+ if (!merged.valid) {
3327
+ addIssueToContext(ctx, {
3328
+ code: ZodIssueCode.invalid_intersection_types
3329
+ });
3330
+ return INVALID;
3331
+ }
3332
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
3333
+ status.dirty();
3334
+ }
3335
+ return { status: status.value, value: merged.data };
3336
+ };
3337
+ if (ctx.common.async) {
3338
+ return Promise.all([
3339
+ this._def.left._parseAsync({
3340
+ data: ctx.data,
3341
+ path: ctx.path,
3342
+ parent: ctx
3343
+ }),
3344
+ this._def.right._parseAsync({
3345
+ data: ctx.data,
3346
+ path: ctx.path,
3347
+ parent: ctx
3348
+ })
3349
+ ]).then(([left, right]) => handleParsed(left, right));
3350
+ } else {
3351
+ return handleParsed(this._def.left._parseSync({
3352
+ data: ctx.data,
3353
+ path: ctx.path,
3354
+ parent: ctx
3355
+ }), this._def.right._parseSync({
3356
+ data: ctx.data,
3357
+ path: ctx.path,
3358
+ parent: ctx
3359
+ }));
3360
+ }
3361
+ }
3362
+ };
3363
+ ZodIntersection.create = (left, right, params) => {
3364
+ return new ZodIntersection({
3365
+ left,
3366
+ right,
3367
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
3368
+ ...processCreateParams(params)
3369
+ });
3370
+ };
3371
+ var ZodTuple = class _ZodTuple extends ZodType {
3372
+ _parse(input) {
3373
+ const { status, ctx } = this._processInputParams(input);
3374
+ if (ctx.parsedType !== ZodParsedType.array) {
3375
+ addIssueToContext(ctx, {
3376
+ code: ZodIssueCode.invalid_type,
3377
+ expected: ZodParsedType.array,
3378
+ received: ctx.parsedType
3379
+ });
3380
+ return INVALID;
3381
+ }
3382
+ if (ctx.data.length < this._def.items.length) {
3383
+ addIssueToContext(ctx, {
3384
+ code: ZodIssueCode.too_small,
3385
+ minimum: this._def.items.length,
3386
+ inclusive: true,
3387
+ exact: false,
3388
+ type: "array"
3389
+ });
3390
+ return INVALID;
3391
+ }
3392
+ const rest = this._def.rest;
3393
+ if (!rest && ctx.data.length > this._def.items.length) {
3394
+ addIssueToContext(ctx, {
3395
+ code: ZodIssueCode.too_big,
3396
+ maximum: this._def.items.length,
3397
+ inclusive: true,
3398
+ exact: false,
3399
+ type: "array"
3400
+ });
3401
+ status.dirty();
3402
+ }
3403
+ const items = [...ctx.data].map((item, itemIndex) => {
3404
+ const schema = this._def.items[itemIndex] || this._def.rest;
3405
+ if (!schema)
3406
+ return null;
3407
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3408
+ }).filter((x) => !!x);
3409
+ if (ctx.common.async) {
3410
+ return Promise.all(items).then((results) => {
3411
+ return ParseStatus.mergeArray(status, results);
3412
+ });
3413
+ } else {
3414
+ return ParseStatus.mergeArray(status, items);
3415
+ }
3416
+ }
3417
+ get items() {
3418
+ return this._def.items;
3419
+ }
3420
+ rest(rest) {
3421
+ return new _ZodTuple({
3422
+ ...this._def,
3423
+ rest
3424
+ });
3425
+ }
3426
+ };
3427
+ ZodTuple.create = (schemas, params) => {
3428
+ if (!Array.isArray(schemas)) {
3429
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3430
+ }
3431
+ return new ZodTuple({
3432
+ items: schemas,
3433
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
3434
+ rest: null,
3435
+ ...processCreateParams(params)
3436
+ });
3437
+ };
3438
+ var ZodRecord = class _ZodRecord extends ZodType {
3439
+ get keySchema() {
3440
+ return this._def.keyType;
3441
+ }
3442
+ get valueSchema() {
3443
+ return this._def.valueType;
3444
+ }
3445
+ _parse(input) {
3446
+ const { status, ctx } = this._processInputParams(input);
3447
+ if (ctx.parsedType !== ZodParsedType.object) {
3448
+ addIssueToContext(ctx, {
3449
+ code: ZodIssueCode.invalid_type,
3450
+ expected: ZodParsedType.object,
3451
+ received: ctx.parsedType
3452
+ });
3453
+ return INVALID;
3454
+ }
3455
+ const pairs = [];
3456
+ const keyType = this._def.keyType;
3457
+ const valueType = this._def.valueType;
3458
+ for (const key in ctx.data) {
3459
+ pairs.push({
3460
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3461
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3462
+ alwaysSet: key in ctx.data
3463
+ });
3464
+ }
3465
+ if (ctx.common.async) {
3466
+ return ParseStatus.mergeObjectAsync(status, pairs);
3467
+ } else {
3468
+ return ParseStatus.mergeObjectSync(status, pairs);
3469
+ }
3470
+ }
3471
+ get element() {
3472
+ return this._def.valueType;
3473
+ }
3474
+ static create(first, second, third) {
3475
+ if (second instanceof ZodType) {
3476
+ return new _ZodRecord({
3477
+ keyType: first,
3478
+ valueType: second,
3479
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3480
+ ...processCreateParams(third)
3481
+ });
3482
+ }
3483
+ return new _ZodRecord({
3484
+ keyType: ZodString.create(),
3485
+ valueType: first,
3486
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3487
+ ...processCreateParams(second)
3488
+ });
3489
+ }
3490
+ };
3491
+ var ZodMap = class extends ZodType {
3492
+ get keySchema() {
3493
+ return this._def.keyType;
3494
+ }
3495
+ get valueSchema() {
3496
+ return this._def.valueType;
3497
+ }
3498
+ _parse(input) {
3499
+ const { status, ctx } = this._processInputParams(input);
3500
+ if (ctx.parsedType !== ZodParsedType.map) {
3501
+ addIssueToContext(ctx, {
3502
+ code: ZodIssueCode.invalid_type,
3503
+ expected: ZodParsedType.map,
3504
+ received: ctx.parsedType
3505
+ });
3506
+ return INVALID;
3507
+ }
3508
+ const keyType = this._def.keyType;
3509
+ const valueType = this._def.valueType;
3510
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3511
+ return {
3512
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3513
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3514
+ };
3515
+ });
3516
+ if (ctx.common.async) {
3517
+ const finalMap = /* @__PURE__ */ new Map();
3518
+ return Promise.resolve().then(async () => {
3519
+ for (const pair of pairs) {
3520
+ const key = await pair.key;
3521
+ const value = await pair.value;
3522
+ if (key.status === "aborted" || value.status === "aborted") {
3523
+ return INVALID;
3524
+ }
3525
+ if (key.status === "dirty" || value.status === "dirty") {
3526
+ status.dirty();
3527
+ }
3528
+ finalMap.set(key.value, value.value);
3529
+ }
3530
+ return { status: status.value, value: finalMap };
3531
+ });
3532
+ } else {
3533
+ const finalMap = /* @__PURE__ */ new Map();
3534
+ for (const pair of pairs) {
3535
+ const key = pair.key;
3536
+ const value = pair.value;
3537
+ if (key.status === "aborted" || value.status === "aborted") {
3538
+ return INVALID;
3539
+ }
3540
+ if (key.status === "dirty" || value.status === "dirty") {
3541
+ status.dirty();
3542
+ }
3543
+ finalMap.set(key.value, value.value);
3544
+ }
3545
+ return { status: status.value, value: finalMap };
3546
+ }
3547
+ }
3548
+ };
3549
+ ZodMap.create = (keyType, valueType, params) => {
3550
+ return new ZodMap({
3551
+ valueType,
3552
+ keyType,
3553
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3554
+ ...processCreateParams(params)
3555
+ });
3556
+ };
3557
+ var ZodSet = class _ZodSet extends ZodType {
3558
+ _parse(input) {
3559
+ const { status, ctx } = this._processInputParams(input);
3560
+ if (ctx.parsedType !== ZodParsedType.set) {
3561
+ addIssueToContext(ctx, {
3562
+ code: ZodIssueCode.invalid_type,
3563
+ expected: ZodParsedType.set,
3564
+ received: ctx.parsedType
3565
+ });
3566
+ return INVALID;
3567
+ }
3568
+ const def = this._def;
3569
+ if (def.minSize !== null) {
3570
+ if (ctx.data.size < def.minSize.value) {
3571
+ addIssueToContext(ctx, {
3572
+ code: ZodIssueCode.too_small,
3573
+ minimum: def.minSize.value,
3574
+ type: "set",
3575
+ inclusive: true,
3576
+ exact: false,
3577
+ message: def.minSize.message
3578
+ });
3579
+ status.dirty();
3580
+ }
3581
+ }
3582
+ if (def.maxSize !== null) {
3583
+ if (ctx.data.size > def.maxSize.value) {
3584
+ addIssueToContext(ctx, {
3585
+ code: ZodIssueCode.too_big,
3586
+ maximum: def.maxSize.value,
3587
+ type: "set",
3588
+ inclusive: true,
3589
+ exact: false,
3590
+ message: def.maxSize.message
3591
+ });
3592
+ status.dirty();
3593
+ }
3594
+ }
3595
+ const valueType = this._def.valueType;
3596
+ function finalizeSet(elements2) {
3597
+ const parsedSet = /* @__PURE__ */ new Set();
3598
+ for (const element of elements2) {
3599
+ if (element.status === "aborted")
3600
+ return INVALID;
3601
+ if (element.status === "dirty")
3602
+ status.dirty();
3603
+ parsedSet.add(element.value);
3604
+ }
3605
+ return { status: status.value, value: parsedSet };
3606
+ }
3607
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3608
+ if (ctx.common.async) {
3609
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3610
+ } else {
3611
+ return finalizeSet(elements);
3612
+ }
3613
+ }
3614
+ min(minSize, message) {
3615
+ return new _ZodSet({
3616
+ ...this._def,
3617
+ minSize: { value: minSize, message: errorUtil.toString(message) }
3618
+ });
3619
+ }
3620
+ max(maxSize, message) {
3621
+ return new _ZodSet({
3622
+ ...this._def,
3623
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
3624
+ });
3625
+ }
3626
+ size(size, message) {
3627
+ return this.min(size, message).max(size, message);
3628
+ }
3629
+ nonempty(message) {
3630
+ return this.min(1, message);
3631
+ }
3632
+ };
3633
+ ZodSet.create = (valueType, params) => {
3634
+ return new ZodSet({
3635
+ valueType,
3636
+ minSize: null,
3637
+ maxSize: null,
3638
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3639
+ ...processCreateParams(params)
3640
+ });
3641
+ };
3642
+ var ZodFunction = class _ZodFunction extends ZodType {
3643
+ constructor() {
3644
+ super(...arguments);
3645
+ this.validate = this.implement;
3646
+ }
3647
+ _parse(input) {
3648
+ const { ctx } = this._processInputParams(input);
3649
+ if (ctx.parsedType !== ZodParsedType.function) {
3650
+ addIssueToContext(ctx, {
3651
+ code: ZodIssueCode.invalid_type,
3652
+ expected: ZodParsedType.function,
3653
+ received: ctx.parsedType
3654
+ });
3655
+ return INVALID;
3656
+ }
3657
+ function makeArgsIssue(args, error) {
3658
+ return makeIssue({
3659
+ data: args,
3660
+ path: ctx.path,
3661
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3662
+ issueData: {
3663
+ code: ZodIssueCode.invalid_arguments,
3664
+ argumentsError: error
3665
+ }
3666
+ });
3667
+ }
3668
+ function makeReturnsIssue(returns, error) {
3669
+ return makeIssue({
3670
+ data: returns,
3671
+ path: ctx.path,
3672
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3673
+ issueData: {
3674
+ code: ZodIssueCode.invalid_return_type,
3675
+ returnTypeError: error
3676
+ }
3677
+ });
3678
+ }
3679
+ const params = { errorMap: ctx.common.contextualErrorMap };
3680
+ const fn = ctx.data;
3681
+ if (this._def.returns instanceof ZodPromise) {
3682
+ const me = this;
3683
+ return OK(async function(...args) {
3684
+ const error = new ZodError([]);
3685
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3686
+ error.addIssue(makeArgsIssue(args, e));
3687
+ throw error;
3688
+ });
3689
+ const result = await Reflect.apply(fn, this, parsedArgs);
3690
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3691
+ error.addIssue(makeReturnsIssue(result, e));
3692
+ throw error;
3693
+ });
3694
+ return parsedReturns;
3695
+ });
3696
+ } else {
3697
+ const me = this;
3698
+ return OK(function(...args) {
3699
+ const parsedArgs = me._def.args.safeParse(args, params);
3700
+ if (!parsedArgs.success) {
3701
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3702
+ }
3703
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3704
+ const parsedReturns = me._def.returns.safeParse(result, params);
3705
+ if (!parsedReturns.success) {
3706
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3707
+ }
3708
+ return parsedReturns.data;
3709
+ });
3710
+ }
3711
+ }
3712
+ parameters() {
3713
+ return this._def.args;
3714
+ }
3715
+ returnType() {
3716
+ return this._def.returns;
3717
+ }
3718
+ args(...items) {
3719
+ return new _ZodFunction({
3720
+ ...this._def,
3721
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
3722
+ });
3723
+ }
3724
+ returns(returnType) {
3725
+ return new _ZodFunction({
3726
+ ...this._def,
3727
+ returns: returnType
3728
+ });
3729
+ }
3730
+ implement(func) {
3731
+ const validatedFunc = this.parse(func);
3732
+ return validatedFunc;
3733
+ }
3734
+ strictImplement(func) {
3735
+ const validatedFunc = this.parse(func);
3736
+ return validatedFunc;
3737
+ }
3738
+ static create(args, returns, params) {
3739
+ return new _ZodFunction({
3740
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3741
+ returns: returns || ZodUnknown.create(),
3742
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
3743
+ ...processCreateParams(params)
3744
+ });
3745
+ }
3746
+ };
3747
+ var ZodLazy = class extends ZodType {
3748
+ get schema() {
3749
+ return this._def.getter();
3750
+ }
3751
+ _parse(input) {
3752
+ const { ctx } = this._processInputParams(input);
3753
+ const lazySchema = this._def.getter();
3754
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3755
+ }
3756
+ };
3757
+ ZodLazy.create = (getter, params) => {
3758
+ return new ZodLazy({
3759
+ getter,
3760
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3761
+ ...processCreateParams(params)
3762
+ });
3763
+ };
3764
+ var ZodLiteral = class extends ZodType {
3765
+ _parse(input) {
3766
+ if (input.data !== this._def.value) {
3767
+ const ctx = this._getOrReturnCtx(input);
3768
+ addIssueToContext(ctx, {
3769
+ received: ctx.data,
3770
+ code: ZodIssueCode.invalid_literal,
3771
+ expected: this._def.value
3772
+ });
3773
+ return INVALID;
3774
+ }
3775
+ return { status: "valid", value: input.data };
3776
+ }
3777
+ get value() {
3778
+ return this._def.value;
3779
+ }
3780
+ };
3781
+ ZodLiteral.create = (value, params) => {
3782
+ return new ZodLiteral({
3783
+ value,
3784
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3785
+ ...processCreateParams(params)
3786
+ });
3787
+ };
3788
+ function createZodEnum(values, params) {
3789
+ return new ZodEnum({
3790
+ values,
3791
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
3792
+ ...processCreateParams(params)
3793
+ });
3794
+ }
3795
+ var ZodEnum = class _ZodEnum extends ZodType {
3796
+ _parse(input) {
3797
+ if (typeof input.data !== "string") {
3798
+ const ctx = this._getOrReturnCtx(input);
3799
+ const expectedValues = this._def.values;
3800
+ addIssueToContext(ctx, {
3801
+ expected: util.joinValues(expectedValues),
3802
+ received: ctx.parsedType,
3803
+ code: ZodIssueCode.invalid_type
3804
+ });
3805
+ return INVALID;
3806
+ }
3807
+ if (!this._cache) {
3808
+ this._cache = new Set(this._def.values);
3809
+ }
3810
+ if (!this._cache.has(input.data)) {
3811
+ const ctx = this._getOrReturnCtx(input);
3812
+ const expectedValues = this._def.values;
3813
+ addIssueToContext(ctx, {
3814
+ received: ctx.data,
3815
+ code: ZodIssueCode.invalid_enum_value,
3816
+ options: expectedValues
3817
+ });
3818
+ return INVALID;
3819
+ }
3820
+ return OK(input.data);
3821
+ }
3822
+ get options() {
3823
+ return this._def.values;
3824
+ }
3825
+ get enum() {
3826
+ const enumValues = {};
3827
+ for (const val of this._def.values) {
3828
+ enumValues[val] = val;
3829
+ }
3830
+ return enumValues;
3831
+ }
3832
+ get Values() {
3833
+ const enumValues = {};
3834
+ for (const val of this._def.values) {
3835
+ enumValues[val] = val;
3836
+ }
3837
+ return enumValues;
3838
+ }
3839
+ get Enum() {
3840
+ const enumValues = {};
3841
+ for (const val of this._def.values) {
3842
+ enumValues[val] = val;
3843
+ }
3844
+ return enumValues;
3845
+ }
3846
+ extract(values, newDef = this._def) {
3847
+ return _ZodEnum.create(values, {
3848
+ ...this._def,
3849
+ ...newDef
3850
+ });
3851
+ }
3852
+ exclude(values, newDef = this._def) {
3853
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3854
+ ...this._def,
3855
+ ...newDef
3856
+ });
3857
+ }
3858
+ };
3859
+ ZodEnum.create = createZodEnum;
3860
+ var ZodNativeEnum = class extends ZodType {
3861
+ _parse(input) {
3862
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
3863
+ const ctx = this._getOrReturnCtx(input);
3864
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3865
+ const expectedValues = util.objectValues(nativeEnumValues);
3866
+ addIssueToContext(ctx, {
3867
+ expected: util.joinValues(expectedValues),
3868
+ received: ctx.parsedType,
3869
+ code: ZodIssueCode.invalid_type
3870
+ });
3871
+ return INVALID;
3872
+ }
3873
+ if (!this._cache) {
3874
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
3875
+ }
3876
+ if (!this._cache.has(input.data)) {
3877
+ const expectedValues = util.objectValues(nativeEnumValues);
3878
+ addIssueToContext(ctx, {
3879
+ received: ctx.data,
3880
+ code: ZodIssueCode.invalid_enum_value,
3881
+ options: expectedValues
3882
+ });
3883
+ return INVALID;
3884
+ }
3885
+ return OK(input.data);
3886
+ }
3887
+ get enum() {
3888
+ return this._def.values;
3889
+ }
3890
+ };
3891
+ ZodNativeEnum.create = (values, params) => {
3892
+ return new ZodNativeEnum({
3893
+ values,
3894
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3895
+ ...processCreateParams(params)
3896
+ });
3897
+ };
3898
+ var ZodPromise = class extends ZodType {
3899
+ unwrap() {
3900
+ return this._def.type;
3901
+ }
3902
+ _parse(input) {
3903
+ const { ctx } = this._processInputParams(input);
3904
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3905
+ addIssueToContext(ctx, {
3906
+ code: ZodIssueCode.invalid_type,
3907
+ expected: ZodParsedType.promise,
3908
+ received: ctx.parsedType
3909
+ });
3910
+ return INVALID;
3911
+ }
3912
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3913
+ return OK(promisified.then((data) => {
3914
+ return this._def.type.parseAsync(data, {
3915
+ path: ctx.path,
3916
+ errorMap: ctx.common.contextualErrorMap
3917
+ });
3918
+ }));
3919
+ }
3920
+ };
3921
+ ZodPromise.create = (schema, params) => {
3922
+ return new ZodPromise({
3923
+ type: schema,
3924
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3925
+ ...processCreateParams(params)
3926
+ });
3927
+ };
3928
+ var ZodEffects = class extends ZodType {
3929
+ innerType() {
3930
+ return this._def.schema;
3931
+ }
3932
+ sourceType() {
3933
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3934
+ }
3935
+ _parse(input) {
3936
+ const { status, ctx } = this._processInputParams(input);
3937
+ const effect = this._def.effect || null;
3938
+ const checkCtx = {
3939
+ addIssue: (arg) => {
3940
+ addIssueToContext(ctx, arg);
3941
+ if (arg.fatal) {
3942
+ status.abort();
3943
+ } else {
3944
+ status.dirty();
3945
+ }
3946
+ },
3947
+ get path() {
3948
+ return ctx.path;
3949
+ }
3950
+ };
3951
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3952
+ if (effect.type === "preprocess") {
3953
+ const processed = effect.transform(ctx.data, checkCtx);
3954
+ if (ctx.common.async) {
3955
+ return Promise.resolve(processed).then(async (processed2) => {
3956
+ if (status.value === "aborted")
3957
+ return INVALID;
3958
+ const result = await this._def.schema._parseAsync({
3959
+ data: processed2,
3960
+ path: ctx.path,
3961
+ parent: ctx
3962
+ });
3963
+ if (result.status === "aborted")
3964
+ return INVALID;
3965
+ if (result.status === "dirty")
3966
+ return DIRTY(result.value);
3967
+ if (status.value === "dirty")
3968
+ return DIRTY(result.value);
3969
+ return result;
3970
+ });
3971
+ } else {
3972
+ if (status.value === "aborted")
3973
+ return INVALID;
3974
+ const result = this._def.schema._parseSync({
3975
+ data: processed,
3976
+ path: ctx.path,
3977
+ parent: ctx
3978
+ });
3979
+ if (result.status === "aborted")
3980
+ return INVALID;
3981
+ if (result.status === "dirty")
3982
+ return DIRTY(result.value);
3983
+ if (status.value === "dirty")
3984
+ return DIRTY(result.value);
3985
+ return result;
3986
+ }
3987
+ }
3988
+ if (effect.type === "refinement") {
3989
+ const executeRefinement = (acc) => {
3990
+ const result = effect.refinement(acc, checkCtx);
3991
+ if (ctx.common.async) {
3992
+ return Promise.resolve(result);
3993
+ }
3994
+ if (result instanceof Promise) {
3995
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3996
+ }
3997
+ return acc;
3998
+ };
3999
+ if (ctx.common.async === false) {
4000
+ const inner = this._def.schema._parseSync({
4001
+ data: ctx.data,
4002
+ path: ctx.path,
4003
+ parent: ctx
4004
+ });
4005
+ if (inner.status === "aborted")
4006
+ return INVALID;
4007
+ if (inner.status === "dirty")
4008
+ status.dirty();
4009
+ executeRefinement(inner.value);
4010
+ return { status: status.value, value: inner.value };
4011
+ } else {
4012
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
4013
+ if (inner.status === "aborted")
4014
+ return INVALID;
4015
+ if (inner.status === "dirty")
4016
+ status.dirty();
4017
+ return executeRefinement(inner.value).then(() => {
4018
+ return { status: status.value, value: inner.value };
4019
+ });
4020
+ });
4021
+ }
4022
+ }
4023
+ if (effect.type === "transform") {
4024
+ if (ctx.common.async === false) {
4025
+ const base = this._def.schema._parseSync({
4026
+ data: ctx.data,
4027
+ path: ctx.path,
4028
+ parent: ctx
4029
+ });
4030
+ if (!isValid(base))
4031
+ return INVALID;
4032
+ const result = effect.transform(base.value, checkCtx);
4033
+ if (result instanceof Promise) {
4034
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
4035
+ }
4036
+ return { status: status.value, value: result };
4037
+ } else {
4038
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
4039
+ if (!isValid(base))
4040
+ return INVALID;
4041
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
4042
+ status: status.value,
4043
+ value: result
4044
+ }));
4045
+ });
4046
+ }
4047
+ }
4048
+ util.assertNever(effect);
4049
+ }
4050
+ };
4051
+ ZodEffects.create = (schema, effect, params) => {
4052
+ return new ZodEffects({
4053
+ schema,
4054
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
4055
+ effect,
4056
+ ...processCreateParams(params)
4057
+ });
4058
+ };
4059
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
4060
+ return new ZodEffects({
4061
+ schema,
4062
+ effect: { type: "preprocess", transform: preprocess },
4063
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
4064
+ ...processCreateParams(params)
4065
+ });
4066
+ };
4067
+ var ZodOptional = class extends ZodType {
4068
+ _parse(input) {
4069
+ const parsedType = this._getType(input);
4070
+ if (parsedType === ZodParsedType.undefined) {
4071
+ return OK(void 0);
4072
+ }
4073
+ return this._def.innerType._parse(input);
4074
+ }
4075
+ unwrap() {
4076
+ return this._def.innerType;
4077
+ }
4078
+ };
4079
+ ZodOptional.create = (type, params) => {
4080
+ return new ZodOptional({
4081
+ innerType: type,
4082
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
4083
+ ...processCreateParams(params)
4084
+ });
4085
+ };
4086
+ var ZodNullable = class extends ZodType {
4087
+ _parse(input) {
4088
+ const parsedType = this._getType(input);
4089
+ if (parsedType === ZodParsedType.null) {
4090
+ return OK(null);
4091
+ }
4092
+ return this._def.innerType._parse(input);
4093
+ }
4094
+ unwrap() {
4095
+ return this._def.innerType;
4096
+ }
4097
+ };
4098
+ ZodNullable.create = (type, params) => {
4099
+ return new ZodNullable({
4100
+ innerType: type,
4101
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
4102
+ ...processCreateParams(params)
4103
+ });
4104
+ };
4105
+ var ZodDefault = class extends ZodType {
4106
+ _parse(input) {
4107
+ const { ctx } = this._processInputParams(input);
4108
+ let data = ctx.data;
4109
+ if (ctx.parsedType === ZodParsedType.undefined) {
4110
+ data = this._def.defaultValue();
4111
+ }
4112
+ return this._def.innerType._parse({
4113
+ data,
4114
+ path: ctx.path,
4115
+ parent: ctx
4116
+ });
4117
+ }
4118
+ removeDefault() {
4119
+ return this._def.innerType;
4120
+ }
4121
+ };
4122
+ ZodDefault.create = (type, params) => {
4123
+ return new ZodDefault({
4124
+ innerType: type,
4125
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
4126
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4127
+ ...processCreateParams(params)
4128
+ });
4129
+ };
4130
+ var ZodCatch = class extends ZodType {
4131
+ _parse(input) {
4132
+ const { ctx } = this._processInputParams(input);
4133
+ const newCtx = {
4134
+ ...ctx,
4135
+ common: {
4136
+ ...ctx.common,
4137
+ issues: []
4138
+ }
4139
+ };
4140
+ const result = this._def.innerType._parse({
4141
+ data: newCtx.data,
4142
+ path: newCtx.path,
4143
+ parent: {
4144
+ ...newCtx
4145
+ }
4146
+ });
4147
+ if (isAsync(result)) {
4148
+ return result.then((result2) => {
4149
+ return {
4150
+ status: "valid",
4151
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
4152
+ get error() {
4153
+ return new ZodError(newCtx.common.issues);
4154
+ },
4155
+ input: newCtx.data
4156
+ })
4157
+ };
4158
+ });
4159
+ } else {
4160
+ return {
4161
+ status: "valid",
4162
+ value: result.status === "valid" ? result.value : this._def.catchValue({
4163
+ get error() {
4164
+ return new ZodError(newCtx.common.issues);
4165
+ },
4166
+ input: newCtx.data
4167
+ })
4168
+ };
4169
+ }
4170
+ }
4171
+ removeCatch() {
4172
+ return this._def.innerType;
4173
+ }
4174
+ };
4175
+ ZodCatch.create = (type, params) => {
4176
+ return new ZodCatch({
4177
+ innerType: type,
4178
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
4179
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4180
+ ...processCreateParams(params)
4181
+ });
4182
+ };
4183
+ var ZodNaN = class extends ZodType {
4184
+ _parse(input) {
4185
+ const parsedType = this._getType(input);
4186
+ if (parsedType !== ZodParsedType.nan) {
4187
+ const ctx = this._getOrReturnCtx(input);
4188
+ addIssueToContext(ctx, {
4189
+ code: ZodIssueCode.invalid_type,
4190
+ expected: ZodParsedType.nan,
4191
+ received: ctx.parsedType
4192
+ });
4193
+ return INVALID;
4194
+ }
4195
+ return { status: "valid", value: input.data };
4196
+ }
4197
+ };
4198
+ ZodNaN.create = (params) => {
4199
+ return new ZodNaN({
4200
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
4201
+ ...processCreateParams(params)
4202
+ });
4203
+ };
4204
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
4205
+ var ZodBranded = class extends ZodType {
4206
+ _parse(input) {
4207
+ const { ctx } = this._processInputParams(input);
4208
+ const data = ctx.data;
4209
+ return this._def.type._parse({
4210
+ data,
4211
+ path: ctx.path,
4212
+ parent: ctx
4213
+ });
4214
+ }
4215
+ unwrap() {
4216
+ return this._def.type;
4217
+ }
4218
+ };
4219
+ var ZodPipeline = class _ZodPipeline extends ZodType {
4220
+ _parse(input) {
4221
+ const { status, ctx } = this._processInputParams(input);
4222
+ if (ctx.common.async) {
4223
+ const handleAsync = async () => {
4224
+ const inResult = await this._def.in._parseAsync({
4225
+ data: ctx.data,
4226
+ path: ctx.path,
4227
+ parent: ctx
4228
+ });
4229
+ if (inResult.status === "aborted")
4230
+ return INVALID;
4231
+ if (inResult.status === "dirty") {
4232
+ status.dirty();
4233
+ return DIRTY(inResult.value);
4234
+ } else {
4235
+ return this._def.out._parseAsync({
4236
+ data: inResult.value,
4237
+ path: ctx.path,
4238
+ parent: ctx
4239
+ });
4240
+ }
4241
+ };
4242
+ return handleAsync();
4243
+ } else {
4244
+ const inResult = this._def.in._parseSync({
4245
+ data: ctx.data,
4246
+ path: ctx.path,
4247
+ parent: ctx
4248
+ });
4249
+ if (inResult.status === "aborted")
4250
+ return INVALID;
4251
+ if (inResult.status === "dirty") {
4252
+ status.dirty();
4253
+ return {
4254
+ status: "dirty",
4255
+ value: inResult.value
4256
+ };
4257
+ } else {
4258
+ return this._def.out._parseSync({
4259
+ data: inResult.value,
4260
+ path: ctx.path,
4261
+ parent: ctx
4262
+ });
4263
+ }
4264
+ }
4265
+ }
4266
+ static create(a, b) {
4267
+ return new _ZodPipeline({
4268
+ in: a,
4269
+ out: b,
4270
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
4271
+ });
4272
+ }
4273
+ };
4274
+ var ZodReadonly = class extends ZodType {
4275
+ _parse(input) {
4276
+ const result = this._def.innerType._parse(input);
4277
+ const freeze = (data) => {
4278
+ if (isValid(data)) {
4279
+ data.value = Object.freeze(data.value);
4280
+ }
4281
+ return data;
4282
+ };
4283
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
4284
+ }
4285
+ unwrap() {
4286
+ return this._def.innerType;
4287
+ }
4288
+ };
4289
+ ZodReadonly.create = (type, params) => {
4290
+ return new ZodReadonly({
4291
+ innerType: type,
4292
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4293
+ ...processCreateParams(params)
4294
+ });
4295
+ };
4296
+ function cleanParams(params, data) {
4297
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
4298
+ const p2 = typeof p === "string" ? { message: p } : p;
4299
+ return p2;
4300
+ }
4301
+ function custom(check, _params = {}, fatal) {
4302
+ if (check)
4303
+ return ZodAny.create().superRefine((data, ctx) => {
4304
+ const r = check(data);
4305
+ if (r instanceof Promise) {
4306
+ return r.then((r2) => {
4307
+ if (!r2) {
4308
+ const params = cleanParams(_params, data);
4309
+ const _fatal = params.fatal ?? fatal ?? true;
4310
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4311
+ }
4312
+ });
4313
+ }
4314
+ if (!r) {
4315
+ const params = cleanParams(_params, data);
4316
+ const _fatal = params.fatal ?? fatal ?? true;
4317
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4318
+ }
4319
+ return;
4320
+ });
4321
+ return ZodAny.create();
4322
+ }
4323
+ var late = {
4324
+ object: ZodObject.lazycreate
4325
+ };
4326
+ var ZodFirstPartyTypeKind;
4327
+ (function(ZodFirstPartyTypeKind2) {
4328
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
4329
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
4330
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
4331
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
4332
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
4333
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
4334
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
4335
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
4336
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
4337
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
4338
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
4339
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
4340
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
4341
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
4342
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
4343
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
4344
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4345
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
4346
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
4347
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
4348
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
4349
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
4350
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
4351
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
4352
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
4353
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
4354
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
4355
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
4356
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
4357
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
4358
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
4359
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
4360
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4361
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4362
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4363
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4364
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4365
+ var instanceOfType = (cls, params = {
4366
+ message: `Input not instance of ${cls.name}`
4367
+ }) => custom((data) => data instanceof cls, params);
4368
+ var stringType = ZodString.create;
4369
+ var numberType = ZodNumber.create;
4370
+ var nanType = ZodNaN.create;
4371
+ var bigIntType = ZodBigInt.create;
4372
+ var booleanType = ZodBoolean.create;
4373
+ var dateType = ZodDate.create;
4374
+ var symbolType = ZodSymbol.create;
4375
+ var undefinedType = ZodUndefined.create;
4376
+ var nullType = ZodNull.create;
4377
+ var anyType = ZodAny.create;
4378
+ var unknownType = ZodUnknown.create;
4379
+ var neverType = ZodNever.create;
4380
+ var voidType = ZodVoid.create;
4381
+ var arrayType = ZodArray.create;
4382
+ var objectType = ZodObject.create;
4383
+ var strictObjectType = ZodObject.strictCreate;
4384
+ var unionType = ZodUnion.create;
4385
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
4386
+ var intersectionType = ZodIntersection.create;
4387
+ var tupleType = ZodTuple.create;
4388
+ var recordType = ZodRecord.create;
4389
+ var mapType = ZodMap.create;
4390
+ var setType = ZodSet.create;
4391
+ var functionType = ZodFunction.create;
4392
+ var lazyType = ZodLazy.create;
4393
+ var literalType = ZodLiteral.create;
4394
+ var enumType = ZodEnum.create;
4395
+ var nativeEnumType = ZodNativeEnum.create;
4396
+ var promiseType = ZodPromise.create;
4397
+ var effectsType = ZodEffects.create;
4398
+ var optionalType = ZodOptional.create;
4399
+ var nullableType = ZodNullable.create;
4400
+ var preprocessType = ZodEffects.createWithPreprocess;
4401
+ var pipelineType = ZodPipeline.create;
4402
+ var ostring = () => stringType().optional();
4403
+ var onumber = () => numberType().optional();
4404
+ var oboolean = () => booleanType().optional();
4405
+ var coerce = {
4406
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4407
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4408
+ boolean: ((arg) => ZodBoolean.create({
4409
+ ...arg,
4410
+ coerce: true
4411
+ })),
4412
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4413
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4414
+ };
4415
+ var NEVER = INVALID;
4416
+
4417
+ // packages/shared/src/schemas.ts
4418
+ var isoDateTime = external_exports.string();
4419
+ var id = external_exports.string();
4420
+ function isSafeUrl(u) {
4421
+ const s = u.trim();
4422
+ return !/^[a-z][a-z0-9+.-]*:/i.test(s) || /^(https?:|mailto:)/i.test(s);
4423
+ }
4424
+ var UNSAFE_URL_MSG = "javascript: \uAC19\uC740 \uC704\uD5D8\uD55C \uB9C1\uD06C\uB294 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. http(s) \uB9C1\uD06C\uB97C \uC0AC\uC6A9\uD558\uC138\uC694.";
4425
+ var MAX_URL = 2e3;
4426
+ var SafeUrl = external_exports.string().min(1).max(MAX_URL).refine(isSafeUrl, { message: UNSAFE_URL_MSG });
4427
+ var SafeUrlOptional = external_exports.string().max(MAX_URL).optional().refine((u) => u == null || u === "" || isSafeUrl(u), { message: UNSAFE_URL_MSG });
4428
+ var MAX_LINE = 500;
4429
+ var MAX_NOTE = 1e4;
4430
+ var MAX_BODY = 2e5;
4431
+ var MAX_ITEM = 2e3;
4432
+ var MAX_ITEMS = 500;
4433
+ var EMPTY_MSG = "\uB0B4\uC6A9\uC774 \uBE44\uC5B4 \uC788\uC2B5\uB2C8\uB2E4(\uACF5\uBC31\uB9CC\uC73C\uB85C\uB294 \uC800\uC7A5\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4).";
4434
+ var reqLine = external_exports.string().trim().min(1).max(MAX_LINE);
4435
+ var optLine = external_exports.string().max(MAX_LINE).optional();
4436
+ var optNote = external_exports.string().max(MAX_NOTE).optional();
4437
+ var optBody = external_exports.string().max(MAX_BODY).optional();
4438
+ var reqBody = external_exports.string().max(MAX_BODY).refine((s) => s.trim().length > 0, { message: EMPTY_MSG });
4439
+ var strList = external_exports.array(external_exports.string().max(MAX_ITEM)).max(MAX_ITEMS);
4440
+ var baseRecord = {
4441
+ id,
4442
+ created_at: isoDateTime,
4443
+ updated_at: isoDateTime
4444
+ };
4445
+ var LinkSchema = external_exports.object({
4446
+ label: reqLine,
4447
+ url: SafeUrl
4448
+ });
4449
+ var ProfileInputSchema = external_exports.object({
4450
+ name: reqLine.optional(),
4451
+ email: optLine,
4452
+ phone: optLine,
4453
+ location: optLine,
4454
+ headline: external_exports.string().max(MAX_LINE).optional().describe("\uD55C \uC904 \uC18C\uAC1C / \uC9C1\uBB34 \uD0C0\uC774\uD2C0"),
4455
+ summary: external_exports.string().max(MAX_NOTE).optional().describe("\uC790\uAE30\uC18C\uAC1C \uC694\uC57D"),
4456
+ desired_roles: strList.optional().describe("\uD76C\uB9DD \uC9C1\uBB34"),
4457
+ desired_conditions: external_exports.string().max(MAX_NOTE).optional().describe("\uD76C\uB9DD \uADFC\uBB34 \uC870\uAC74 (\uC5F0\uBD09, \uC9C0\uC5ED, \uADFC\uBB34\uD615\uD0DC \uB4F1)"),
4458
+ preferred_tone: external_exports.string().max(MAX_LINE).optional().describe("\uC790\uAE30\uC18C\uAC1C\uC11C \uC120\uD638 \uBB38\uCCB4 (\uC608: \uB2F4\uBC31\uD558\uACE0 \uAD6C\uCCB4\uC801)"),
4459
+ emphasis_points: strList.optional().describe("\uAC15\uC870\uD558\uACE0 \uC2F6\uC740 \uD575\uC2EC \uD3EC\uC778\uD2B8"),
4460
+ links: external_exports.array(LinkSchema).max(MAX_ITEMS).optional().describe("\uD3EC\uD2B8\uD3F4\uB9AC\uC624/\uAE43\uD5C8\uBE0C/\uB9C1\uD06C\uB4DC\uC778 \uB4F1")
4461
+ });
4462
+ var ProfileRecordSchema = external_exports.object({
4463
+ ...baseRecord,
4464
+ name: external_exports.string().nullable(),
4465
+ email: external_exports.string().nullable(),
4466
+ phone: external_exports.string().nullable(),
4467
+ location: external_exports.string().nullable(),
4468
+ headline: external_exports.string().nullable(),
4469
+ summary: external_exports.string().nullable(),
4470
+ desired_roles: external_exports.array(external_exports.string()),
4471
+ desired_conditions: external_exports.string().nullable(),
4472
+ preferred_tone: external_exports.string().nullable(),
4473
+ emphasis_points: external_exports.array(external_exports.string()),
4474
+ links: external_exports.array(LinkSchema)
4475
+ });
4476
+ var ExperienceInputSchema = external_exports.object({
4477
+ company: reqLine,
4478
+ role: optLine,
4479
+ employment_type: external_exports.string().max(MAX_LINE).optional().describe("\uC815\uADDC\uC9C1/\uACC4\uC57D\uC9C1/\uC778\uD134/\uD504\uB9AC\uB79C\uC11C \uB4F1"),
4480
+ start_date: external_exports.string().max(MAX_LINE).optional().describe("YYYY-MM \uB610\uB294 YYYY-MM-DD"),
4481
+ end_date: external_exports.string().max(MAX_LINE).optional().describe("\uC7AC\uC9C1 \uC911\uC774\uBA74 \uBE44\uC6CC\uB450\uAE30"),
4482
+ is_current: external_exports.boolean().optional(),
4483
+ description: optBody,
4484
+ achievements: strList.optional().describe("\uC131\uACFC/\uC5C5\uC801 (\uC815\uB7C9 \uC9C0\uD45C \uAD8C\uC7A5)"),
4485
+ tech: strList.optional().describe("\uC0AC\uC6A9 \uAE30\uC220/\uB3C4\uAD6C"),
4486
+ order_index: external_exports.number().optional()
4487
+ });
4488
+ var ExperienceRecordSchema = external_exports.object({
4489
+ ...baseRecord,
4490
+ company: external_exports.string(),
4491
+ role: external_exports.string().nullable(),
4492
+ employment_type: external_exports.string().nullable(),
4493
+ start_date: external_exports.string().nullable(),
4494
+ end_date: external_exports.string().nullable(),
4495
+ is_current: external_exports.boolean(),
4496
+ description: external_exports.string().nullable(),
4497
+ achievements: external_exports.array(external_exports.string()),
4498
+ tech: external_exports.array(external_exports.string()),
4499
+ order_index: external_exports.number()
4500
+ });
4501
+ var ProjectInputSchema = external_exports.object({
4502
+ name: reqLine,
4503
+ role: optLine,
4504
+ description: optBody,
4505
+ highlights: strList.optional(),
4506
+ tech: strList.optional(),
4507
+ url: SafeUrlOptional,
4508
+ start_date: optLine,
4509
+ end_date: optLine,
4510
+ order_index: external_exports.number().optional()
4511
+ });
4512
+ var ProjectRecordSchema = external_exports.object({
4513
+ ...baseRecord,
4514
+ name: external_exports.string(),
4515
+ role: external_exports.string().nullable(),
4516
+ description: external_exports.string().nullable(),
4517
+ highlights: external_exports.array(external_exports.string()),
4518
+ tech: external_exports.array(external_exports.string()),
4519
+ url: external_exports.string().nullable(),
4520
+ start_date: external_exports.string().nullable(),
4521
+ end_date: external_exports.string().nullable(),
4522
+ order_index: external_exports.number()
4523
+ });
4524
+ var SkillInputSchema = external_exports.object({
4525
+ name: reqLine,
4526
+ category: external_exports.string().max(MAX_LINE).optional().describe("\uC5B8\uC5B4/\uD504\uB808\uC784\uC6CC\uD06C/\uD234/\uC18C\uD504\uD2B8\uC2A4\uD0AC \uB4F1"),
4527
+ level: external_exports.string().max(MAX_LINE).optional().describe("\uC0C1/\uC911/\uD558 \uB610\uB294 \uC790\uC720 \uC11C\uC220"),
4528
+ years: external_exports.number().optional(),
4529
+ order_index: external_exports.number().optional()
4530
+ });
4531
+ var SkillRecordSchema = external_exports.object({
4532
+ ...baseRecord,
4533
+ name: external_exports.string(),
4534
+ category: external_exports.string().nullable(),
4535
+ level: external_exports.string().nullable(),
4536
+ years: external_exports.number().nullable(),
4537
+ order_index: external_exports.number()
4538
+ });
4539
+ var DocumentInputSchema = external_exports.object({
4540
+ kind: external_exports.enum(DOCUMENT_KINDS),
4541
+ title: reqLine,
4542
+ content: reqBody.describe("Markdown \uB610\uB294 \uC77C\uBC18 \uD14D\uC2A4\uD2B8 \uBCF8\uBB38"),
4543
+ source: external_exports.enum(CONTENT_SOURCES).optional(),
4544
+ is_primary: external_exports.boolean().optional().describe("\uB300\uD45C \uBB38\uC11C \uC5EC\uBD80"),
4545
+ tags: strList.optional()
4546
+ });
4547
+ var DocumentRecordSchema = external_exports.object({
4548
+ ...baseRecord,
4549
+ kind: external_exports.enum(DOCUMENT_KINDS),
4550
+ title: external_exports.string(),
4551
+ content: external_exports.string(),
4552
+ source: external_exports.enum(CONTENT_SOURCES),
4553
+ is_primary: external_exports.boolean(),
4554
+ tags: external_exports.array(external_exports.string())
4555
+ });
4556
+ var CoverLetterInputSchema = external_exports.object({
4557
+ title: reqLine,
4558
+ job_id: optLine.describe("\uD2B9\uC815 \uACF5\uACE0\uC5D0 \uC5F0\uACB0\uD560 \uACBD\uC6B0"),
4559
+ is_primary: external_exports.boolean().optional(),
4560
+ content: optBody.describe("\uCD08\uAE30 \uBC84\uC804 \uBCF8\uBB38 (\uC788\uC73C\uBA74 v1\uB85C \uC800\uC7A5)"),
4561
+ source: external_exports.enum(CONTENT_SOURCES).optional(),
4562
+ note: optNote.describe("\uCD08\uAE30 \uBC84\uC804 \uBA54\uBAA8")
4563
+ });
4564
+ var CoverLetterVersionInputSchema = external_exports.object({
4565
+ cover_letter_id: optLine.describe("\uAE30\uC874 \uC790\uAE30\uC18C\uAC1C\uC11C\uC5D0 \uC0C8 \uBC84\uC804 \uCD94\uAC00 \uC2DC"),
4566
+ title: external_exports.string().max(MAX_LINE).optional().describe("\uC0C8 \uC790\uAE30\uC18C\uAC1C\uC11C\uB97C \uB9CC\uB4E4 \uB54C \uC81C\uBAA9"),
4567
+ job_id: optLine,
4568
+ content: reqBody,
4569
+ note: optNote.describe("\uC774 \uBC84\uC804\uC758 \uBCC0\uACBD \uC694\uC57D (\uC608: \uC9C0\uC6D0\uB3D9\uAE30 \uBCF4\uAC15)"),
4570
+ source: external_exports.enum(CONTENT_SOURCES).optional(),
4571
+ set_current: external_exports.boolean().optional().describe("\uC774 \uBC84\uC804\uC744 \uD604\uC7AC \uBC84\uC804\uC73C\uB85C \uC9C0\uC815 (\uAE30\uBCF8 true)")
4572
+ });
4573
+ var CoverLetterVersionRecordSchema = external_exports.object({
4574
+ id,
4575
+ cover_letter_id: external_exports.string(),
4576
+ version_no: external_exports.number(),
4577
+ content: external_exports.string(),
4578
+ note: external_exports.string().nullable(),
4579
+ source: external_exports.enum(CONTENT_SOURCES),
4580
+ created_at: isoDateTime
4581
+ });
4582
+ var CoverLetterRecordSchema = external_exports.object({
4583
+ ...baseRecord,
4584
+ title: external_exports.string(),
4585
+ job_id: external_exports.string().nullable(),
4586
+ is_primary: external_exports.boolean(),
4587
+ current_version_id: external_exports.string().nullable(),
4588
+ version_count: external_exports.number(),
4589
+ current_content: external_exports.string().nullable(),
4590
+ versions: external_exports.array(CoverLetterVersionRecordSchema).optional()
4591
+ });
4592
+ var JobInputSchema = external_exports.object({
4593
+ company: reqLine,
4594
+ position: reqLine.describe("\uC9C1\uBB34/\uD3EC\uC9C0\uC158\uBA85"),
4595
+ url: SafeUrlOptional,
4596
+ location: optLine,
4597
+ employment_type: optLine,
4598
+ description: optBody.describe("\uACF5\uACE0 \uC6D0\uBB38 \uB610\uB294 \uC815\uB9AC\uB41C \uD14D\uC2A4\uD2B8"),
4599
+ requirements: strList.optional().describe("\uC790\uACA9\uC694\uAC74/\uC6B0\uB300\uC0AC\uD56D \uD575\uC2EC"),
4600
+ keywords: strList.optional().describe("\uD575\uC2EC \uD0A4\uC6CC\uB4DC"),
4601
+ deadline: external_exports.string().max(MAX_LINE).optional().describe("\uB9C8\uAC10\uC77C YYYY-MM-DD"),
4602
+ source: external_exports.string().max(MAX_LINE).optional().describe("\uCD9C\uCC98 (\uC0AC\uB78C\uC778/\uC6D0\uD2F0\uB4DC/\uC9C1\uC811 \uC785\uB825 \uB4F1)")
4603
+ });
4604
+ var JobRecordSchema = external_exports.object({
4605
+ ...baseRecord,
4606
+ company: external_exports.string(),
4607
+ position: external_exports.string(),
4608
+ url: external_exports.string().nullable(),
4609
+ location: external_exports.string().nullable(),
4610
+ employment_type: external_exports.string().nullable(),
4611
+ description: external_exports.string().nullable(),
4612
+ requirements: external_exports.array(external_exports.string()),
4613
+ keywords: external_exports.array(external_exports.string()),
4614
+ deadline: external_exports.string().nullable(),
4615
+ source: external_exports.string().nullable()
4616
+ });
4617
+ var FitAnalysisInputSchema = external_exports.object({
4618
+ job_id: reqLine.describe("\uBD84\uC11D \uB300\uC0C1 \uACF5\uACE0 ID"),
4619
+ score: external_exports.number().min(0).max(100).optional().describe("\uC885\uD569 \uC801\uD569\uB3C4 0~100"),
4620
+ summary: external_exports.string().max(MAX_NOTE).optional().describe("\uD55C\uB450 \uBB38\uB2E8 \uC694\uC57D"),
4621
+ strengths: strList.optional().describe("\uAC15\uC810 / \uC798 \uB9DE\uB294 \uBD80\uBD84"),
4622
+ gaps: strList.optional().describe("\uBD80\uC871\uD55C \uBD80\uBD84 / \uBCF4\uC644 \uD544\uC694"),
4623
+ matched_keywords: strList.optional(),
4624
+ missing_keywords: strList.optional(),
4625
+ recommendations: strList.optional().describe("\uC790\uAE30\uC18C\uAC1C\uC11C/\uC9C0\uC6D0 \uC804\uB7B5 \uC81C\uC548")
4626
+ });
4627
+ var FitAnalysisRecordSchema = external_exports.object({
4628
+ ...baseRecord,
4629
+ job_id: external_exports.string(),
4630
+ score: external_exports.number().nullable(),
4631
+ summary: external_exports.string().nullable(),
4632
+ strengths: external_exports.array(external_exports.string()),
4633
+ gaps: external_exports.array(external_exports.string()),
4634
+ matched_keywords: external_exports.array(external_exports.string()),
4635
+ missing_keywords: external_exports.array(external_exports.string()),
4636
+ recommendations: external_exports.array(external_exports.string())
4637
+ });
4638
+ var ApplicationInputSchema = external_exports.object({
4639
+ job_id: reqLine,
4640
+ status: external_exports.enum(APPLICATION_STATUSES).optional(),
4641
+ resume_id: optLine,
4642
+ cover_letter_id: optLine,
4643
+ applied_at: optLine,
4644
+ notes: optNote
4645
+ });
4646
+ var ApplicationStatusUpdateSchema = external_exports.object({
4647
+ job_id: optLine,
4648
+ application_id: optLine,
4649
+ status: external_exports.enum(APPLICATION_STATUSES),
4650
+ note: optNote.describe("\uC0C1\uD0DC \uBCC0\uACBD \uC0AC\uC720/\uBA54\uBAA8")
4651
+ });
4652
+ var ApplicationRecordSchema = external_exports.object({
4653
+ ...baseRecord,
4654
+ job_id: external_exports.string(),
4655
+ status: external_exports.enum(APPLICATION_STATUSES),
4656
+ resume_id: external_exports.string().nullable(),
4657
+ cover_letter_id: external_exports.string().nullable(),
4658
+ applied_at: external_exports.string().nullable(),
4659
+ notes: external_exports.string().nullable()
4660
+ });
4661
+ var StarGuideSchema = external_exports.object({
4662
+ question: external_exports.string().max(MAX_NOTE),
4663
+ situation: optNote,
4664
+ task: optNote,
4665
+ action: optNote,
4666
+ result: optNote
4667
+ });
4668
+ var InterviewQuestionSchema = external_exports.object({
4669
+ question: external_exports.string().max(MAX_NOTE),
4670
+ intent: external_exports.string().max(MAX_NOTE).optional().describe("\uC9C8\uBB38 \uC758\uB3C4"),
4671
+ followups: strList.optional().describe("\uC608\uC0C1 \uAF2C\uB9AC \uC9C8\uBB38"),
4672
+ answer_outline: optBody.describe("\uB2F5\uBCC0 \uAC00\uC774\uB4DC/\uD575\uC2EC \uD3EC\uC778\uD2B8")
4673
+ });
4674
+ var InterviewPrepInputSchema = external_exports.object({
4675
+ job_id: reqLine,
4676
+ questions: external_exports.array(InterviewQuestionSchema).max(MAX_ITEMS).optional(),
4677
+ star_guides: external_exports.array(StarGuideSchema).max(MAX_ITEMS).optional(),
4678
+ self_introduction: optBody.describe("1\uBD84 \uC790\uAE30\uC18C\uAC1C \uCD08\uC548"),
4679
+ notes: optNote.describe("\uBA74\uC811 \uD6C4\uAE30/\uBA54\uBAA8")
4680
+ });
4681
+ var InterviewPrepRecordSchema = external_exports.object({
4682
+ ...baseRecord,
4683
+ job_id: external_exports.string(),
4684
+ questions: external_exports.array(InterviewQuestionSchema),
4685
+ star_guides: external_exports.array(StarGuideSchema),
4686
+ self_introduction: external_exports.string().nullable(),
4687
+ notes: external_exports.string().nullable()
4688
+ });
4689
+ var ActivityRecordSchema = external_exports.object({
4690
+ id,
4691
+ type: external_exports.enum(ACTIVITY_TYPES),
4692
+ entity_type: external_exports.enum(ENTITY_TYPES).nullable(),
4693
+ entity_id: external_exports.string().nullable(),
4694
+ summary: external_exports.string(),
4695
+ created_at: isoDateTime
4696
+ });
4697
+ var OnboardingStatusSchema = external_exports.object({
4698
+ completed: external_exports.boolean(),
4699
+ has_profile: external_exports.boolean(),
4700
+ has_resume: external_exports.boolean(),
4701
+ has_cover_letter: external_exports.boolean(),
4702
+ has_experience: external_exports.boolean(),
4703
+ has_skills: external_exports.boolean(),
4704
+ has_job: external_exports.boolean(),
4705
+ profile_completeness: external_exports.number().describe("0~100 \uD504\uB85C\uD544 \uC644\uC131\uB3C4"),
4706
+ next_steps: external_exports.array(external_exports.string()).describe("\uC9C0\uAE08 \uD574\uC57C \uD560 \uB2E4\uC74C \uB2E8\uACC4 \uC548\uB0B4")
4707
+ });
4708
+ var ApplicationContextSchema = external_exports.object({
4709
+ profile: ProfileRecordSchema.nullable(),
4710
+ primary_resume: DocumentRecordSchema.nullable(),
4711
+ resumes: external_exports.array(DocumentRecordSchema),
4712
+ experiences: external_exports.array(ExperienceRecordSchema),
4713
+ projects: external_exports.array(ProjectRecordSchema),
4714
+ skills: external_exports.array(SkillRecordSchema),
4715
+ cover_letters: external_exports.array(CoverLetterRecordSchema),
4716
+ recent_applications: external_exports.array(ApplicationRecordSchema),
4717
+ job: JobRecordSchema.nullable(),
4718
+ fit_analysis: FitAnalysisRecordSchema.nullable(),
4719
+ related_history: external_exports.array(
4720
+ external_exports.object({
4721
+ job: JobRecordSchema,
4722
+ application: ApplicationRecordSchema.nullable(),
4723
+ fit_analysis: FitAnalysisRecordSchema.nullable()
4724
+ })
4725
+ ).describe("\uAC19\uC740 \uD68C\uC0AC/\uC9C1\uBB34 \uAD00\uB828 \uC774\uC804 \uAE30\uB85D"),
4726
+ writing_preferences: external_exports.object({
4727
+ preferred_tone: external_exports.string().nullable(),
4728
+ emphasis_points: external_exports.array(external_exports.string())
4729
+ })
4730
+ });
4731
+
4732
+ // scripts/migrate.ts
4733
+ getDb();
4734
+ console.log(`\u2705 CareerMate \uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uC900\uBE44 \uC644\uB8CC`);
4735
+ console.log(` \uC704\uCE58: ${getDbPath()}`);