pushary 1.9.62 → 1.9.63

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 (123) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -1
  3. package/dist/{api-7HLZRIUV.js → api-UHUUAONF.js} +10 -10
  4. package/dist/bin/pushary-bell-hook.js +27 -27
  5. package/dist/bin/pushary-bell.js +12 -12
  6. package/dist/bin/pushary-claude.js +28 -28
  7. package/dist/bin/pushary-clean.js +35 -34
  8. package/dist/bin/pushary-codex-bridge.js +21 -21
  9. package/dist/bin/pushary-codex-hook.js +35 -35
  10. package/dist/bin/pushary-codex-session.js +8 -8
  11. package/dist/bin/pushary-codex.js +14 -14
  12. package/dist/bin/pushary-connect.js +27 -27
  13. package/dist/bin/pushary-cowork.js +5 -5
  14. package/dist/bin/pushary-daemon.js +39 -38
  15. package/dist/bin/pushary-disconnect.js +30 -29
  16. package/dist/bin/pushary-doctor.js +45 -43
  17. package/dist/bin/pushary-elicitation-hook.js +28 -28
  18. package/dist/bin/pushary-gemini-bridge.js +15 -15
  19. package/dist/bin/pushary-gemini-hook.js +30 -30
  20. package/dist/bin/pushary-hook.js +31 -31
  21. package/dist/bin/pushary-login.js +27 -15
  22. package/dist/bin/pushary-logout.js +28 -28
  23. package/dist/bin/pushary-mcp.js +11 -11
  24. package/dist/bin/pushary-mode.js +14 -14
  25. package/dist/bin/pushary-notification-hook.js +26 -26
  26. package/dist/bin/pushary-opencode-hook.js +29 -29
  27. package/dist/bin/pushary-permission-denied-hook.js +31 -31
  28. package/dist/bin/pushary-permission-hook.js +30 -30
  29. package/dist/bin/pushary-post-hook.js +26 -26
  30. package/dist/bin/pushary-prompt-hook.js +26 -26
  31. package/dist/bin/pushary-session-end-hook.js +26 -26
  32. package/dist/bin/pushary-session-start-hook.js +34 -33
  33. package/dist/bin/pushary-setup.js +114 -4204
  34. package/dist/bin/pushary-stats.js +5 -5
  35. package/dist/bin/pushary-status.js +32 -32
  36. package/dist/bin/pushary-stop-hook.js +26 -26
  37. package/dist/bin/pushary-stopfailure-hook.js +26 -26
  38. package/dist/bin/pushary-suggestions.js +14 -14
  39. package/dist/bin/pushary-transcript-register.js +18 -18
  40. package/dist/bin/pushary-transcripts.js +62 -9
  41. package/dist/bin/pushary-upgrade.js +43 -41
  42. package/dist/bin/pushary-wait.js +14 -14
  43. package/dist/bin/pushary.js +7 -7
  44. package/dist/{chunk-67Q3Q5IO.js → chunk-2MZ6ROWZ.js} +6 -6
  45. package/dist/{chunk-7GU4PXE5.js → chunk-3GVV7XVT.js} +1 -1
  46. package/dist/{chunk-557ZE5EX.js → chunk-3QLFB2EY.js} +4 -4
  47. package/dist/{chunk-5R23J52J.js → chunk-4WFAP6QN.js} +10 -10
  48. package/dist/{chunk-UWCPY4RY.js → chunk-5JK3DQGZ.js} +2 -2
  49. package/dist/{chunk-CFIQ3252.js → chunk-5LOP4AVD.js} +3 -3
  50. package/dist/{chunk-FG5HMJ7C.js → chunk-6Z2VR3BA.js} +4 -2
  51. package/dist/{chunk-OZRT64BB.js → chunk-75ODMNOM.js} +1 -1
  52. package/dist/{chunk-4K6YZPZ3.js → chunk-7GRQGXF4.js} +1 -1
  53. package/dist/{chunk-FXECTHAG.js → chunk-7NCLUA65.js} +26 -4
  54. package/dist/{chunk-Q4WTIKM6.js → chunk-AB3VAQ25.js} +3 -3
  55. package/dist/{chunk-7ETELRQX.js → chunk-BCVCUDFI.js} +16 -5
  56. package/dist/{chunk-LCNN7UOE.js → chunk-BQFL2ECS.js} +3 -3
  57. package/dist/{chunk-DFKEJARZ.js → chunk-BUQU3OPX.js} +1 -1
  58. package/dist/{chunk-RFCEVROB.js → chunk-CLABCSZC.js} +4 -4
  59. package/dist/{chunk-LILS32LF.js → chunk-DMNLFWGY.js} +7 -108
  60. package/dist/{chunk-SDOWT67G.js → chunk-EHHTQURL.js} +5 -5
  61. package/dist/{chunk-ESXGCZDA.js → chunk-ELAK46NR.js} +4 -4
  62. package/dist/{chunk-ZJFJUAHS.js → chunk-EQ26IKZM.js} +6 -6
  63. package/dist/{chunk-NZLQ6GMX.js → chunk-FAF5AW3P.js} +9 -9
  64. package/dist/{chunk-A4CZPUQ6.js → chunk-FEAGK25K.js} +1 -1
  65. package/dist/{chunk-3LBB7GVF.js → chunk-GNUARBRZ.js} +4 -4
  66. package/dist/{chunk-AFV3FQNG.js → chunk-GZS72NCF.js} +4 -4
  67. package/dist/{chunk-3YGUWPNZ.js → chunk-HAIXS4OX.js} +2 -2
  68. package/dist/{chunk-TMHE5CVX.js → chunk-HOIO66DU.js} +3 -3
  69. package/dist/{chunk-NAZRRXZM.js → chunk-HZ72EMJE.js} +2 -2
  70. package/dist/{chunk-W3CBFLIX.js → chunk-IOH2T3CB.js} +17 -3
  71. package/dist/chunk-KEPESIIR.js +4117 -0
  72. package/dist/{chunk-3IFCXMC6.js → chunk-KL76XWZ7.js} +1 -1
  73. package/dist/{chunk-F35YILEN.js → chunk-KLZZI5TU.js} +1 -1
  74. package/dist/{chunk-GV43RXR2.js → chunk-KUCL7ETL.js} +1 -1
  75. package/dist/{chunk-G3ZDCYMU.js → chunk-L5CDGXPO.js} +3 -3
  76. package/dist/{chunk-EA6574W2.js → chunk-LGZ545TA.js} +5 -5
  77. package/dist/{chunk-6HIYOY6I.js → chunk-LTT54NOU.js} +8 -8
  78. package/dist/{chunk-6YSEOXP5.js → chunk-MK4USZYQ.js} +2 -2
  79. package/dist/{chunk-FX7KDF47.js → chunk-MRCVYYPW.js} +3 -3
  80. package/dist/{chunk-ZEDGKCCM.js → chunk-OJEIS5L2.js} +1 -1
  81. package/dist/{chunk-GFAG72LR.js → chunk-OP5IBEV7.js} +7 -3
  82. package/dist/{chunk-SJCPIYWJ.js → chunk-OU3BYBJ3.js} +2 -2
  83. package/dist/{chunk-W6MYFAOK.js → chunk-OW6VBXXI.js} +15 -15
  84. package/dist/{chunk-R3CLBNST.js → chunk-OY6Z4IKB.js} +1 -1
  85. package/dist/{chunk-SJJYXMJP.js → chunk-P6RF4RQN.js} +6 -6
  86. package/dist/{chunk-7E2ZN7XA.js → chunk-PIQ4HHA2.js} +5 -5
  87. package/dist/{chunk-VF3IL56Q.js → chunk-PJ34FOIV.js} +4 -4
  88. package/dist/{chunk-LWR5VKNC.js → chunk-PXAOEFJZ.js} +11 -11
  89. package/dist/{chunk-7EHZXZB2.js → chunk-QC2W42DE.js} +12 -12
  90. package/dist/{chunk-7NXB7OVX.js → chunk-RAJ3QEIL.js} +1 -1
  91. package/dist/chunk-S2Z6VWHH.js +112 -0
  92. package/dist/{chunk-MYEALNW6.js → chunk-SARPHHTT.js} +1 -1
  93. package/dist/{chunk-7NJ4TDUH.js → chunk-SKUSGWFK.js} +5 -5
  94. package/dist/{chunk-YQK72JGV.js → chunk-T3GHXR6N.js} +5 -5
  95. package/dist/{chunk-EUNSJKJJ.js → chunk-T6XQNOZV.js} +22 -15
  96. package/dist/{chunk-RSNN2TPE.js → chunk-TBKHQWIH.js} +9 -9
  97. package/dist/{chunk-M7MEVILL.js → chunk-TMGJAFSD.js} +4 -4
  98. package/dist/{chunk-PSCXEH42.js → chunk-V5W3CK7F.js} +2 -2
  99. package/dist/{chunk-UUAVYIWJ.js → chunk-V7N5NOZV.js} +4 -2
  100. package/dist/{chunk-LL2KHEJH.js → chunk-VC3HFFMQ.js} +1 -1
  101. package/dist/{chunk-QIPW7OVB.js → chunk-VDBXSUXP.js} +6 -6
  102. package/dist/{chunk-HSRNWCXJ.js → chunk-VFJSVPNL.js} +3 -3
  103. package/dist/{chunk-RU37NSZH.js → chunk-VHZAJ6IB.js} +3 -3
  104. package/dist/{chunk-BIUSODLS.js → chunk-VN7XH6TU.js} +2 -2
  105. package/dist/{chunk-EO6CL4PD.js → chunk-WUOOZE5S.js} +2 -2
  106. package/dist/{chunk-6JAWNRDR.js → chunk-XBTWG2VL.js} +4 -4
  107. package/dist/{chunk-MURJ4WAL.js → chunk-XE5N352V.js} +1 -1
  108. package/dist/{chunk-44FNEAXK.js → chunk-XO3KAH7K.js} +1 -1
  109. package/dist/{chunk-EVZDYG7L.js → chunk-YK6GR4GU.js} +2 -2
  110. package/dist/{chunk-FYS27SUS.js → chunk-YMZOM6BD.js} +6 -6
  111. package/dist/{codex-app-cards-switch-IIL7IPP6.js → codex-app-cards-switch-LXMAIOFB.js} +11 -11
  112. package/dist/{codex-desktop-launch-XCLMYVBD.js → codex-desktop-launch-VE5RLFUU.js} +1 -1
  113. package/dist/{codex-session-launch-UMVALJ3A.js → codex-session-launch-XZZWXCPK.js} +18 -18
  114. package/dist/{config-5N3GUJD5.js → config-PPX25AV5.js} +3 -3
  115. package/dist/{global-upgrade-5F4CSXED.js → global-upgrade-NRMHNLNU.js} +9 -9
  116. package/dist/{identity-7ULYW4RL.js → identity-ZFQR7JNW.js} +4 -4
  117. package/dist/{live-capabilities-QTSFXA6T.js → live-capabilities-SJRYRKNB.js} +4 -4
  118. package/dist/{paths-HEMK2ALW.js → paths-7VTVOQXJ.js} +3 -3
  119. package/dist/{reapply-AMFKVYZV.js → reapply-WOANOIRZ.js} +27 -26
  120. package/dist/src/index.js +21 -21
  121. package/dist/{upgrade-lock-IAZC5644.js → upgrade-lock-VAYJZVTB.js} +4 -4
  122. package/dist/{usage-NEFDYSRT.js → usage-C4DIYUR6.js} +3 -3
  123. package/package.json +1 -1
@@ -1,4 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ nativeBridgeAccount
4
+ } from "../chunk-KEPESIIR.js";
5
+ import {
6
+ runBrowserLogin
7
+ } from "../chunk-SARPHHTT.js";
2
8
  import {
3
9
  INSTALL_NODE_STEP,
4
10
  NPM_FILE_IN_USE_STEP,
@@ -11,36 +17,33 @@ import {
11
17
  phoneStartServiceState,
12
18
  renderCommandSurface,
13
19
  unverifiedKeyClosingReason
14
- } from "../chunk-M7MEVILL.js";
15
- import {
16
- runBrowserLogin
17
- } from "../chunk-MYEALNW6.js";
20
+ } from "../chunk-TMGJAFSD.js";
18
21
  import {
19
22
  coworkOutput,
20
23
  coworkSelection
21
- } from "../chunk-FX7KDF47.js";
24
+ } from "../chunk-MRCVYYPW.js";
22
25
  import "../chunk-PUZZELE6.js";
23
26
  import {
24
27
  clearDeclinedAgent,
25
28
  declinedAgentForSetupChoice
26
- } from "../chunk-6JAWNRDR.js";
29
+ } from "../chunk-XBTWG2VL.js";
27
30
  import {
28
31
  describeVersionManagerPin,
29
32
  saveSetupFailure,
30
33
  versionManagerOf
31
- } from "../chunk-3YGUWPNZ.js";
34
+ } from "../chunk-HAIXS4OX.js";
32
35
  import {
33
36
  codexTrustOutcome,
34
37
  describeCodexTrustConfirmation,
35
38
  needsCodexTrustStep
36
- } from "../chunk-BIUSODLS.js";
39
+ } from "../chunk-VN7XH6TU.js";
37
40
  import {
38
41
  describeWaitLadder
39
42
  } from "../chunk-CVWG2N3Y.js";
40
43
  import {
41
44
  writeJsonError,
42
45
  writeStdoutFully
43
- } from "../chunk-7GU4PXE5.js";
46
+ } from "../chunk-3GVV7XVT.js";
44
47
  import {
45
48
  BROWSER_CONNECT_COMMAND,
46
49
  confirmAppConnection,
@@ -49,22 +52,22 @@ import {
49
52
  pairingEscapeApplies,
50
53
  printConnectInstructions,
51
54
  waitForYourPhone
52
- } from "../chunk-NZLQ6GMX.js";
55
+ } from "../chunk-FAF5AW3P.js";
56
+ import "../chunk-3EGEA4KH.js";
53
57
  import {
54
58
  SETUP_AGENT_NAME,
55
59
  describeAnswerTestPrompt,
56
60
  describeRoundTripOutcome,
57
61
  roundTripEvidence,
58
62
  verifyRoundTrip
59
- } from "../chunk-RU37NSZH.js";
60
- import "../chunk-3EGEA4KH.js";
63
+ } from "../chunk-VHZAJ6IB.js";
61
64
  import {
62
65
  readManagedControlEvidence,
63
66
  waitForMachineReadiness
64
- } from "../chunk-SDOWT67G.js";
67
+ } from "../chunk-EHHTQURL.js";
65
68
  import {
66
69
  ensureCodexTrustsPusharyHooks
67
- } from "../chunk-EVZDYG7L.js";
70
+ } from "../chunk-YK6GR4GU.js";
68
71
  import {
69
72
  describeSetupSideEffects,
70
73
  installAgentSkill,
@@ -72,7 +75,7 @@ import {
72
75
  } from "../chunk-EUW7JL2K.js";
73
76
  import {
74
77
  codexEngineBehindLauncher
75
- } from "../chunk-UWCPY4RY.js";
78
+ } from "../chunk-5JK3DQGZ.js";
76
79
  import "../chunk-XCEN33UP.js";
77
80
  import {
78
81
  CURSOR_PLUGIN_BACKUP_INFIX,
@@ -82,7 +85,7 @@ import {
82
85
  soleGateFile,
83
86
  soleGateReceipt,
84
87
  soleGateReceiptFile
85
- } from "../chunk-3LBB7GVF.js";
88
+ } from "../chunk-GNUARBRZ.js";
86
89
  import {
87
90
  HERMES_PIP_PACKAGE,
88
91
  describeDetection,
@@ -95,30 +98,22 @@ import {
95
98
  runHermesConfigScript,
96
99
  shortenHome,
97
100
  vscodeSettingsTargets
98
- } from "../chunk-EA6574W2.js";
101
+ } from "../chunk-LGZ545TA.js";
99
102
  import {
100
103
  mcpServerBearer,
101
104
  readMacAppAgentKey
102
- } from "../chunk-QIPW7OVB.js";
105
+ } from "../chunk-VDBXSUXP.js";
103
106
  import {
104
107
  setHumanStream
105
108
  } from "../chunk-QCGNGEGE.js";
106
109
  import {
107
- AgentConfigError,
108
110
  CODEX_INSTRUCTIONS_LABEL,
109
111
  FX_PUSHARY_TOOLS_RULE,
110
112
  FX_QUESTION_TOOL,
111
113
  GEMINI_INSTRUCTIONS_LABEL,
112
114
  OPENCODE_INSTRUCTIONS_LABEL,
113
115
  SHARED_AGENTS_MD_LABEL,
114
- afterAgentFailureNote,
115
- agentFailureFromError,
116
- agentFailureWire,
117
- configFailureKind,
118
116
  configureFxSettings,
119
- describeMacAccountMismatch,
120
- describedAgentFailure,
121
- failedAgentsContext,
122
117
  fxIgnoresInstructionsFile,
123
118
  fxInstructionsBody,
124
119
  fxPusharyEntry,
@@ -126,16 +121,26 @@ import {
126
121
  readFxProfileForSetup,
127
122
  renderAgentInstructions,
128
123
  renderProjectAgentInstructions,
129
- retryAgentCommand,
130
124
  withFxPusharyServer,
131
125
  writeFxProfile,
132
- writeInstructionBlock,
126
+ writeInstructionBlock
127
+ } from "../chunk-DMNLFWGY.js";
128
+ import {
129
+ AgentConfigError,
130
+ afterAgentFailureNote,
131
+ agentFailureFromError,
132
+ agentFailureWire,
133
+ configFailureKind,
134
+ describeMacAccountMismatch,
135
+ describedAgentFailure,
136
+ failedAgentsContext,
137
+ retryAgentCommand,
133
138
  writeSetupConfigFile,
134
139
  writeSetupConfigJson
135
- } from "../chunk-LILS32LF.js";
140
+ } from "../chunk-S2Z6VWHH.js";
136
141
  import {
137
142
  MCP_BRIDGE_BINARY
138
- } from "../chunk-EO6CL4PD.js";
143
+ } from "../chunk-WUOOZE5S.js";
139
144
  import {
140
145
  OPENCODE_HOOK_BINARY,
141
146
  addOpenCodeMcpServer,
@@ -151,7 +156,7 @@ import {
151
156
  openCodePluginDir,
152
157
  openCodePluginFile,
153
158
  openCodeWired
154
- } from "../chunk-6HIYOY6I.js";
159
+ } from "../chunk-LTT54NOU.js";
155
160
  import {
156
161
  ansiPainter,
157
162
  createIo,
@@ -167,15 +172,15 @@ import {
167
172
  nodeCodexInstallProbe,
168
173
  phoneStartIsRequired,
169
174
  resolveControlPolicy
170
- } from "../chunk-TMHE5CVX.js";
175
+ } from "../chunk-HOIO66DU.js";
171
176
  import {
172
177
  detectClaudeVersion
173
- } from "../chunk-R3CLBNST.js";
178
+ } from "../chunk-OY6Z4IKB.js";
174
179
  import "../chunk-VUFHYMSP.js";
175
180
  import {
176
181
  describeAutoUpdateAnnouncement,
177
182
  takeAutoUpdateAnnouncement
178
- } from "../chunk-VF3IL56Q.js";
183
+ } from "../chunk-PJ34FOIV.js";
179
184
  import {
180
185
  addClaudeMcpServer,
181
186
  addCompatibleHooks,
@@ -195,7 +200,7 @@ import {
195
200
  hasCompatibleHooks,
196
201
  isClaudeMcpSnapshot,
197
202
  updateClaudeMcpSnapshot
198
- } from "../chunk-557ZE5EX.js";
203
+ } from "../chunk-3QLFB2EY.js";
199
204
  import {
200
205
  DAEMON_COLD_START_TIMEOUT_MS,
201
206
  clearDaemonNeedsLogin,
@@ -210,7 +215,7 @@ import {
210
215
  replaceDaemonService,
211
216
  stopDaemonService,
212
217
  waitForDaemonRemoteProof
213
- } from "../chunk-5R23J52J.js";
218
+ } from "../chunk-4WFAP6QN.js";
214
219
  import {
215
220
  KEEP_HINT,
216
221
  captureHookTakeover,
@@ -222,24 +227,24 @@ import {
222
227
  geminiWired,
223
228
  planHooks,
224
229
  pusharyHookExecutable
225
- } from "../chunk-7NJ4TDUH.js";
230
+ } from "../chunk-SKUSGWFK.js";
226
231
  import {
227
232
  GEMINI_HOOK_BINARY,
228
233
  GEMINI_HOOK_EVENTS,
229
234
  addGeminiHooks,
230
235
  addGeminiMcpServer
231
- } from "../chunk-LCNN7UOE.js";
236
+ } from "../chunk-BQFL2ECS.js";
232
237
  import {
233
238
  AGENT_CHOICES,
234
239
  effectiveControlMode,
235
240
  effectiveVerify,
236
241
  parseSetupOptions
237
- } from "../chunk-MURJ4WAL.js";
238
- import "../chunk-F35YILEN.js";
242
+ } from "../chunk-XE5N352V.js";
243
+ import "../chunk-KLZZI5TU.js";
239
244
  import "../chunk-NMUI3ZWG.js";
240
245
  import {
241
246
  transcriptPreferenceForSetup
242
- } from "../chunk-ZEDGKCCM.js";
247
+ } from "../chunk-OJEIS5L2.js";
243
248
  import "../chunk-XHKBHWLX.js";
244
249
  import {
245
250
  compareVersion,
@@ -257,7 +262,7 @@ import {
257
262
  recordMacAppKeyPrefix,
258
263
  resolveShellRc,
259
264
  writeKey
260
- } from "../chunk-W3CBFLIX.js";
265
+ } from "../chunk-IOH2T3CB.js";
261
266
  import {
262
267
  CODEX_ENGINE_DIRECTORY,
263
268
  CODEX_ENGINE_ENTRYPOINT,
@@ -266,26 +271,30 @@ import {
266
271
  } from "../chunk-E46NE7FB.js";
267
272
  import {
268
273
  reportEvent
269
- } from "../chunk-LWR5VKNC.js";
270
- import "../chunk-LL2KHEJH.js";
271
- import "../chunk-4K6YZPZ3.js";
272
- import "../chunk-RSNN2TPE.js";
273
- import "../chunk-ESXGCZDA.js";
274
+ } from "../chunk-PXAOEFJZ.js";
275
+ import "../chunk-VC3HFFMQ.js";
276
+ import "../chunk-7GRQGXF4.js";
277
+ import "../chunk-TBKHQWIH.js";
274
278
  import "../chunk-POFBE6ZY.js";
279
+ import "../chunk-ELAK46NR.js";
275
280
  import {
276
281
  checkApiKey,
277
282
  describeKeyCheck,
278
283
  samePusharyAccount
279
- } from "../chunk-Q4WTIKM6.js";
280
- import "../chunk-HSRNWCXJ.js";
281
- import "../chunk-G3ZDCYMU.js";
284
+ } from "../chunk-AB3VAQ25.js";
285
+ import "../chunk-VFJSVPNL.js";
286
+ import "../chunk-L5CDGXPO.js";
282
287
  import {
283
288
  UsageError
284
289
  } from "../chunk-PPY5N2E6.js";
285
290
  import {
286
291
  EXIT
287
292
  } from "../chunk-KZERVKTD.js";
288
- import "../chunk-PSCXEH42.js";
293
+ import "../chunk-V5W3CK7F.js";
294
+ import {
295
+ backupFile,
296
+ readJsonSafe
297
+ } from "../chunk-QENTGE75.js";
289
298
  import {
290
299
  CODEX_RESTART_AFTER_TRANSPORT_CHANGE,
291
300
  addCodexHookTrust,
@@ -326,7 +335,7 @@ import {
326
335
  readCodexMcpAuth,
327
336
  vscodePluginDir,
328
337
  vscodePluginMcp
329
- } from "../chunk-6YSEOXP5.js";
338
+ } from "../chunk-MK4USZYQ.js";
330
339
  import {
331
340
  NpmMissingError,
332
341
  fetchLatestPublishedVersion,
@@ -335,18 +344,14 @@ import {
335
344
  plannedGlobalPackage,
336
345
  resolveGlobalBinDir,
337
346
  resolveGlobalBinary
338
- } from "../chunk-CFIQ3252.js";
339
- import {
340
- backupFile,
341
- readJsonSafe
342
- } from "../chunk-QENTGE75.js";
347
+ } from "../chunk-5LOP4AVD.js";
343
348
  import {
344
349
  getBaseUrl
345
- } from "../chunk-DFKEJARZ.js";
350
+ } from "../chunk-BUQU3OPX.js";
346
351
  import {
347
352
  NPX_LATEST_COMMAND,
348
353
  renderCommandHelp
349
- } from "../chunk-FG5HMJ7C.js";
354
+ } from "../chunk-6Z2VR3BA.js";
350
355
  import {
351
356
  getPackageVersion,
352
357
  isNewerVersion,
@@ -365,15 +370,13 @@ import {
365
370
  isRecord,
366
371
  isTimeoutAction,
367
372
  isValidApiKey
368
- } from "../chunk-FXECTHAG.js";
369
- import {
370
- __export
371
- } from "../chunk-MLKGABMK.js";
373
+ } from "../chunk-7NCLUA65.js";
374
+ import "../chunk-MLKGABMK.js";
372
375
 
373
376
  // bin/pushary-setup.ts
374
- import { existsSync, readFileSync as readFileSync2, writeFileSync, mkdirSync, cpSync, rmSync, renameSync, realpathSync, statSync, openSync, readSync, closeSync } from "fs";
375
- import { join as join5, dirname as dirname3, basename } from "path";
376
- import { homedir as homedir2, hostname } from "os";
377
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, cpSync, rmSync, renameSync, realpathSync, statSync, openSync, readSync, closeSync } from "fs";
378
+ import { join as join4, dirname as dirname3, basename } from "path";
379
+ import { homedir, hostname } from "os";
377
380
  import { execSync } from "child_process";
378
381
  import { checkbox, input, confirm } from "@inquirer/prompts";
379
382
  import { fileURLToPath } from "url";
@@ -952,4099 +955,6 @@ var pairingComputerOf = (host, platform, detectedAgents) => ({
952
955
  agents: detectedAgents.filter(isComputerAgent)
953
956
  });
954
957
 
955
- // src/native-transcript-account.ts
956
- import { createHash } from "crypto";
957
- import { lstatSync, readFileSync } from "fs";
958
- import { homedir } from "os";
959
- import { join as join4 } from "path";
960
-
961
- // ../../node_modules/zod/v3/external.js
962
- var external_exports = {};
963
- __export(external_exports, {
964
- BRAND: () => BRAND,
965
- DIRTY: () => DIRTY,
966
- EMPTY_PATH: () => EMPTY_PATH,
967
- INVALID: () => INVALID,
968
- NEVER: () => NEVER,
969
- OK: () => OK,
970
- ParseStatus: () => ParseStatus,
971
- Schema: () => ZodType,
972
- ZodAny: () => ZodAny,
973
- ZodArray: () => ZodArray,
974
- ZodBigInt: () => ZodBigInt,
975
- ZodBoolean: () => ZodBoolean,
976
- ZodBranded: () => ZodBranded,
977
- ZodCatch: () => ZodCatch,
978
- ZodDate: () => ZodDate,
979
- ZodDefault: () => ZodDefault,
980
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
981
- ZodEffects: () => ZodEffects,
982
- ZodEnum: () => ZodEnum,
983
- ZodError: () => ZodError,
984
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
985
- ZodFunction: () => ZodFunction,
986
- ZodIntersection: () => ZodIntersection,
987
- ZodIssueCode: () => ZodIssueCode,
988
- ZodLazy: () => ZodLazy,
989
- ZodLiteral: () => ZodLiteral,
990
- ZodMap: () => ZodMap,
991
- ZodNaN: () => ZodNaN,
992
- ZodNativeEnum: () => ZodNativeEnum,
993
- ZodNever: () => ZodNever,
994
- ZodNull: () => ZodNull,
995
- ZodNullable: () => ZodNullable,
996
- ZodNumber: () => ZodNumber,
997
- ZodObject: () => ZodObject,
998
- ZodOptional: () => ZodOptional,
999
- ZodParsedType: () => ZodParsedType,
1000
- ZodPipeline: () => ZodPipeline,
1001
- ZodPromise: () => ZodPromise,
1002
- ZodReadonly: () => ZodReadonly,
1003
- ZodRecord: () => ZodRecord,
1004
- ZodSchema: () => ZodType,
1005
- ZodSet: () => ZodSet,
1006
- ZodString: () => ZodString,
1007
- ZodSymbol: () => ZodSymbol,
1008
- ZodTransformer: () => ZodEffects,
1009
- ZodTuple: () => ZodTuple,
1010
- ZodType: () => ZodType,
1011
- ZodUndefined: () => ZodUndefined,
1012
- ZodUnion: () => ZodUnion,
1013
- ZodUnknown: () => ZodUnknown,
1014
- ZodVoid: () => ZodVoid,
1015
- addIssueToContext: () => addIssueToContext,
1016
- any: () => anyType,
1017
- array: () => arrayType,
1018
- bigint: () => bigIntType,
1019
- boolean: () => booleanType,
1020
- coerce: () => coerce,
1021
- custom: () => custom,
1022
- date: () => dateType,
1023
- datetimeRegex: () => datetimeRegex,
1024
- defaultErrorMap: () => en_default,
1025
- discriminatedUnion: () => discriminatedUnionType,
1026
- effect: () => effectsType,
1027
- enum: () => enumType,
1028
- function: () => functionType,
1029
- getErrorMap: () => getErrorMap,
1030
- getParsedType: () => getParsedType,
1031
- instanceof: () => instanceOfType,
1032
- intersection: () => intersectionType,
1033
- isAborted: () => isAborted,
1034
- isAsync: () => isAsync,
1035
- isDirty: () => isDirty,
1036
- isValid: () => isValid,
1037
- late: () => late,
1038
- lazy: () => lazyType,
1039
- literal: () => literalType,
1040
- makeIssue: () => makeIssue,
1041
- map: () => mapType,
1042
- nan: () => nanType,
1043
- nativeEnum: () => nativeEnumType,
1044
- never: () => neverType,
1045
- null: () => nullType,
1046
- nullable: () => nullableType,
1047
- number: () => numberType,
1048
- object: () => objectType,
1049
- objectUtil: () => objectUtil,
1050
- oboolean: () => oboolean,
1051
- onumber: () => onumber,
1052
- optional: () => optionalType,
1053
- ostring: () => ostring,
1054
- pipeline: () => pipelineType,
1055
- preprocess: () => preprocessType,
1056
- promise: () => promiseType,
1057
- quotelessJson: () => quotelessJson,
1058
- record: () => recordType,
1059
- set: () => setType,
1060
- setErrorMap: () => setErrorMap,
1061
- strictObject: () => strictObjectType,
1062
- string: () => stringType,
1063
- symbol: () => symbolType,
1064
- transformer: () => effectsType,
1065
- tuple: () => tupleType,
1066
- undefined: () => undefinedType,
1067
- union: () => unionType,
1068
- unknown: () => unknownType,
1069
- util: () => util,
1070
- void: () => voidType
1071
- });
1072
-
1073
- // ../../node_modules/zod/v3/helpers/util.js
1074
- var util;
1075
- (function(util2) {
1076
- util2.assertEqual = (_) => {
1077
- };
1078
- function assertIs(_arg) {
1079
- }
1080
- util2.assertIs = assertIs;
1081
- function assertNever(_x) {
1082
- throw new Error();
1083
- }
1084
- util2.assertNever = assertNever;
1085
- util2.arrayToEnum = (items) => {
1086
- const obj = {};
1087
- for (const item of items) {
1088
- obj[item] = item;
1089
- }
1090
- return obj;
1091
- };
1092
- util2.getValidEnumValues = (obj) => {
1093
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
1094
- const filtered = {};
1095
- for (const k of validKeys) {
1096
- filtered[k] = obj[k];
1097
- }
1098
- return util2.objectValues(filtered);
1099
- };
1100
- util2.objectValues = (obj) => {
1101
- return util2.objectKeys(obj).map(function(e) {
1102
- return obj[e];
1103
- });
1104
- };
1105
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
1106
- const keys = [];
1107
- for (const key in object) {
1108
- if (Object.prototype.hasOwnProperty.call(object, key)) {
1109
- keys.push(key);
1110
- }
1111
- }
1112
- return keys;
1113
- };
1114
- util2.find = (arr, checker) => {
1115
- for (const item of arr) {
1116
- if (checker(item))
1117
- return item;
1118
- }
1119
- return void 0;
1120
- };
1121
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
1122
- function joinValues(array, separator = " | ") {
1123
- return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
1124
- }
1125
- util2.joinValues = joinValues;
1126
- util2.jsonStringifyReplacer = (_, value) => {
1127
- if (typeof value === "bigint") {
1128
- return value.toString();
1129
- }
1130
- return value;
1131
- };
1132
- })(util || (util = {}));
1133
- var objectUtil;
1134
- (function(objectUtil2) {
1135
- objectUtil2.mergeShapes = (first, second) => {
1136
- return {
1137
- ...first,
1138
- ...second
1139
- // second overwrites first
1140
- };
1141
- };
1142
- })(objectUtil || (objectUtil = {}));
1143
- var ZodParsedType = util.arrayToEnum([
1144
- "string",
1145
- "nan",
1146
- "number",
1147
- "integer",
1148
- "float",
1149
- "boolean",
1150
- "date",
1151
- "bigint",
1152
- "symbol",
1153
- "function",
1154
- "undefined",
1155
- "null",
1156
- "array",
1157
- "object",
1158
- "unknown",
1159
- "promise",
1160
- "void",
1161
- "never",
1162
- "map",
1163
- "set"
1164
- ]);
1165
- var getParsedType = (data) => {
1166
- const t = typeof data;
1167
- switch (t) {
1168
- case "undefined":
1169
- return ZodParsedType.undefined;
1170
- case "string":
1171
- return ZodParsedType.string;
1172
- case "number":
1173
- return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
1174
- case "boolean":
1175
- return ZodParsedType.boolean;
1176
- case "function":
1177
- return ZodParsedType.function;
1178
- case "bigint":
1179
- return ZodParsedType.bigint;
1180
- case "symbol":
1181
- return ZodParsedType.symbol;
1182
- case "object":
1183
- if (Array.isArray(data)) {
1184
- return ZodParsedType.array;
1185
- }
1186
- if (data === null) {
1187
- return ZodParsedType.null;
1188
- }
1189
- if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
1190
- return ZodParsedType.promise;
1191
- }
1192
- if (typeof Map !== "undefined" && data instanceof Map) {
1193
- return ZodParsedType.map;
1194
- }
1195
- if (typeof Set !== "undefined" && data instanceof Set) {
1196
- return ZodParsedType.set;
1197
- }
1198
- if (typeof Date !== "undefined" && data instanceof Date) {
1199
- return ZodParsedType.date;
1200
- }
1201
- return ZodParsedType.object;
1202
- default:
1203
- return ZodParsedType.unknown;
1204
- }
1205
- };
1206
-
1207
- // ../../node_modules/zod/v3/ZodError.js
1208
- var ZodIssueCode = util.arrayToEnum([
1209
- "invalid_type",
1210
- "invalid_literal",
1211
- "custom",
1212
- "invalid_union",
1213
- "invalid_union_discriminator",
1214
- "invalid_enum_value",
1215
- "unrecognized_keys",
1216
- "invalid_arguments",
1217
- "invalid_return_type",
1218
- "invalid_date",
1219
- "invalid_string",
1220
- "too_small",
1221
- "too_big",
1222
- "invalid_intersection_types",
1223
- "not_multiple_of",
1224
- "not_finite"
1225
- ]);
1226
- var quotelessJson = (obj) => {
1227
- const json = JSON.stringify(obj, null, 2);
1228
- return json.replace(/"([^"]+)":/g, "$1:");
1229
- };
1230
- var ZodError = class _ZodError extends Error {
1231
- get errors() {
1232
- return this.issues;
1233
- }
1234
- constructor(issues) {
1235
- super();
1236
- this.issues = [];
1237
- this.addIssue = (sub) => {
1238
- this.issues = [...this.issues, sub];
1239
- };
1240
- this.addIssues = (subs = []) => {
1241
- this.issues = [...this.issues, ...subs];
1242
- };
1243
- const actualProto = new.target.prototype;
1244
- if (Object.setPrototypeOf) {
1245
- Object.setPrototypeOf(this, actualProto);
1246
- } else {
1247
- this.__proto__ = actualProto;
1248
- }
1249
- this.name = "ZodError";
1250
- this.issues = issues;
1251
- }
1252
- format(_mapper) {
1253
- const mapper = _mapper || function(issue) {
1254
- return issue.message;
1255
- };
1256
- const fieldErrors = { _errors: [] };
1257
- const processError = (error) => {
1258
- for (const issue of error.issues) {
1259
- if (issue.code === "invalid_union") {
1260
- issue.unionErrors.map(processError);
1261
- } else if (issue.code === "invalid_return_type") {
1262
- processError(issue.returnTypeError);
1263
- } else if (issue.code === "invalid_arguments") {
1264
- processError(issue.argumentsError);
1265
- } else if (issue.path.length === 0) {
1266
- fieldErrors._errors.push(mapper(issue));
1267
- } else {
1268
- let curr = fieldErrors;
1269
- let i = 0;
1270
- while (i < issue.path.length) {
1271
- const el = issue.path[i];
1272
- const terminal = i === issue.path.length - 1;
1273
- if (!terminal) {
1274
- curr[el] = curr[el] || { _errors: [] };
1275
- } else {
1276
- curr[el] = curr[el] || { _errors: [] };
1277
- curr[el]._errors.push(mapper(issue));
1278
- }
1279
- curr = curr[el];
1280
- i++;
1281
- }
1282
- }
1283
- }
1284
- };
1285
- processError(this);
1286
- return fieldErrors;
1287
- }
1288
- static assert(value) {
1289
- if (!(value instanceof _ZodError)) {
1290
- throw new Error(`Not a ZodError: ${value}`);
1291
- }
1292
- }
1293
- toString() {
1294
- return this.message;
1295
- }
1296
- get message() {
1297
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
1298
- }
1299
- get isEmpty() {
1300
- return this.issues.length === 0;
1301
- }
1302
- flatten(mapper = (issue) => issue.message) {
1303
- const fieldErrors = {};
1304
- const formErrors = [];
1305
- for (const sub of this.issues) {
1306
- if (sub.path.length > 0) {
1307
- const firstEl = sub.path[0];
1308
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
1309
- fieldErrors[firstEl].push(mapper(sub));
1310
- } else {
1311
- formErrors.push(mapper(sub));
1312
- }
1313
- }
1314
- return { formErrors, fieldErrors };
1315
- }
1316
- get formErrors() {
1317
- return this.flatten();
1318
- }
1319
- };
1320
- ZodError.create = (issues) => {
1321
- const error = new ZodError(issues);
1322
- return error;
1323
- };
1324
-
1325
- // ../../node_modules/zod/v3/locales/en.js
1326
- var errorMap = (issue, _ctx) => {
1327
- let message;
1328
- switch (issue.code) {
1329
- case ZodIssueCode.invalid_type:
1330
- if (issue.received === ZodParsedType.undefined) {
1331
- message = "Required";
1332
- } else {
1333
- message = `Expected ${issue.expected}, received ${issue.received}`;
1334
- }
1335
- break;
1336
- case ZodIssueCode.invalid_literal:
1337
- message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
1338
- break;
1339
- case ZodIssueCode.unrecognized_keys:
1340
- message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
1341
- break;
1342
- case ZodIssueCode.invalid_union:
1343
- message = `Invalid input`;
1344
- break;
1345
- case ZodIssueCode.invalid_union_discriminator:
1346
- message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
1347
- break;
1348
- case ZodIssueCode.invalid_enum_value:
1349
- message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
1350
- break;
1351
- case ZodIssueCode.invalid_arguments:
1352
- message = `Invalid function arguments`;
1353
- break;
1354
- case ZodIssueCode.invalid_return_type:
1355
- message = `Invalid function return type`;
1356
- break;
1357
- case ZodIssueCode.invalid_date:
1358
- message = `Invalid date`;
1359
- break;
1360
- case ZodIssueCode.invalid_string:
1361
- if (typeof issue.validation === "object") {
1362
- if ("includes" in issue.validation) {
1363
- message = `Invalid input: must include "${issue.validation.includes}"`;
1364
- if (typeof issue.validation.position === "number") {
1365
- message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
1366
- }
1367
- } else if ("startsWith" in issue.validation) {
1368
- message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1369
- } else if ("endsWith" in issue.validation) {
1370
- message = `Invalid input: must end with "${issue.validation.endsWith}"`;
1371
- } else {
1372
- util.assertNever(issue.validation);
1373
- }
1374
- } else if (issue.validation !== "regex") {
1375
- message = `Invalid ${issue.validation}`;
1376
- } else {
1377
- message = "Invalid";
1378
- }
1379
- break;
1380
- case ZodIssueCode.too_small:
1381
- if (issue.type === "array")
1382
- message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
1383
- else if (issue.type === "string")
1384
- message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
1385
- else if (issue.type === "number")
1386
- message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1387
- else if (issue.type === "bigint")
1388
- message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1389
- else if (issue.type === "date")
1390
- message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
1391
- else
1392
- message = "Invalid input";
1393
- break;
1394
- case ZodIssueCode.too_big:
1395
- if (issue.type === "array")
1396
- message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
1397
- else if (issue.type === "string")
1398
- message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1399
- else if (issue.type === "number")
1400
- message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1401
- else if (issue.type === "bigint")
1402
- message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1403
- else if (issue.type === "date")
1404
- message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
1405
- else
1406
- message = "Invalid input";
1407
- break;
1408
- case ZodIssueCode.custom:
1409
- message = `Invalid input`;
1410
- break;
1411
- case ZodIssueCode.invalid_intersection_types:
1412
- message = `Intersection results could not be merged`;
1413
- break;
1414
- case ZodIssueCode.not_multiple_of:
1415
- message = `Number must be a multiple of ${issue.multipleOf}`;
1416
- break;
1417
- case ZodIssueCode.not_finite:
1418
- message = "Number must be finite";
1419
- break;
1420
- default:
1421
- message = _ctx.defaultError;
1422
- util.assertNever(issue);
1423
- }
1424
- return { message };
1425
- };
1426
- var en_default = errorMap;
1427
-
1428
- // ../../node_modules/zod/v3/errors.js
1429
- var overrideErrorMap = en_default;
1430
- function setErrorMap(map) {
1431
- overrideErrorMap = map;
1432
- }
1433
- function getErrorMap() {
1434
- return overrideErrorMap;
1435
- }
1436
-
1437
- // ../../node_modules/zod/v3/helpers/parseUtil.js
1438
- var makeIssue = (params) => {
1439
- const { data, path, errorMaps, issueData } = params;
1440
- const fullPath = [...path, ...issueData.path || []];
1441
- const fullIssue = {
1442
- ...issueData,
1443
- path: fullPath
1444
- };
1445
- if (issueData.message !== void 0) {
1446
- return {
1447
- ...issueData,
1448
- path: fullPath,
1449
- message: issueData.message
1450
- };
1451
- }
1452
- let errorMessage = "";
1453
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
1454
- for (const map of maps) {
1455
- errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
1456
- }
1457
- return {
1458
- ...issueData,
1459
- path: fullPath,
1460
- message: errorMessage
1461
- };
1462
- };
1463
- var EMPTY_PATH = [];
1464
- function addIssueToContext(ctx, issueData) {
1465
- const overrideMap = getErrorMap();
1466
- const issue = makeIssue({
1467
- issueData,
1468
- data: ctx.data,
1469
- path: ctx.path,
1470
- errorMaps: [
1471
- ctx.common.contextualErrorMap,
1472
- // contextual error map is first priority
1473
- ctx.schemaErrorMap,
1474
- // then schema-bound map if available
1475
- overrideMap,
1476
- // then global override map
1477
- overrideMap === en_default ? void 0 : en_default
1478
- // then global default map
1479
- ].filter((x) => !!x)
1480
- });
1481
- ctx.common.issues.push(issue);
1482
- }
1483
- var ParseStatus = class _ParseStatus {
1484
- constructor() {
1485
- this.value = "valid";
1486
- }
1487
- dirty() {
1488
- if (this.value === "valid")
1489
- this.value = "dirty";
1490
- }
1491
- abort() {
1492
- if (this.value !== "aborted")
1493
- this.value = "aborted";
1494
- }
1495
- static mergeArray(status, results) {
1496
- const arrayValue = [];
1497
- for (const s of results) {
1498
- if (s.status === "aborted")
1499
- return INVALID;
1500
- if (s.status === "dirty")
1501
- status.dirty();
1502
- arrayValue.push(s.value);
1503
- }
1504
- return { status: status.value, value: arrayValue };
1505
- }
1506
- static async mergeObjectAsync(status, pairs) {
1507
- const syncPairs = [];
1508
- for (const pair of pairs) {
1509
- const key = await pair.key;
1510
- const value = await pair.value;
1511
- syncPairs.push({
1512
- key,
1513
- value
1514
- });
1515
- }
1516
- return _ParseStatus.mergeObjectSync(status, syncPairs);
1517
- }
1518
- static mergeObjectSync(status, pairs) {
1519
- const finalObject = {};
1520
- for (const pair of pairs) {
1521
- const { key, value } = pair;
1522
- if (key.status === "aborted")
1523
- return INVALID;
1524
- if (value.status === "aborted")
1525
- return INVALID;
1526
- if (key.status === "dirty")
1527
- status.dirty();
1528
- if (value.status === "dirty")
1529
- status.dirty();
1530
- if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
1531
- finalObject[key.value] = value.value;
1532
- }
1533
- }
1534
- return { status: status.value, value: finalObject };
1535
- }
1536
- };
1537
- var INVALID = Object.freeze({
1538
- status: "aborted"
1539
- });
1540
- var DIRTY = (value) => ({ status: "dirty", value });
1541
- var OK = (value) => ({ status: "valid", value });
1542
- var isAborted = (x) => x.status === "aborted";
1543
- var isDirty = (x) => x.status === "dirty";
1544
- var isValid = (x) => x.status === "valid";
1545
- var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1546
-
1547
- // ../../node_modules/zod/v3/helpers/errorUtil.js
1548
- var errorUtil;
1549
- (function(errorUtil2) {
1550
- errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1551
- errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
1552
- })(errorUtil || (errorUtil = {}));
1553
-
1554
- // ../../node_modules/zod/v3/types.js
1555
- var ParseInputLazyPath = class {
1556
- constructor(parent, value, path, key) {
1557
- this._cachedPath = [];
1558
- this.parent = parent;
1559
- this.data = value;
1560
- this._path = path;
1561
- this._key = key;
1562
- }
1563
- get path() {
1564
- if (!this._cachedPath.length) {
1565
- if (Array.isArray(this._key)) {
1566
- this._cachedPath.push(...this._path, ...this._key);
1567
- } else {
1568
- this._cachedPath.push(...this._path, this._key);
1569
- }
1570
- }
1571
- return this._cachedPath;
1572
- }
1573
- };
1574
- var handleResult = (ctx, result) => {
1575
- if (isValid(result)) {
1576
- return { success: true, data: result.value };
1577
- } else {
1578
- if (!ctx.common.issues.length) {
1579
- throw new Error("Validation failed but no issues detected.");
1580
- }
1581
- return {
1582
- success: false,
1583
- get error() {
1584
- if (this._error)
1585
- return this._error;
1586
- const error = new ZodError(ctx.common.issues);
1587
- this._error = error;
1588
- return this._error;
1589
- }
1590
- };
1591
- }
1592
- };
1593
- function processCreateParams(params) {
1594
- if (!params)
1595
- return {};
1596
- const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
1597
- if (errorMap2 && (invalid_type_error || required_error)) {
1598
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1599
- }
1600
- if (errorMap2)
1601
- return { errorMap: errorMap2, description };
1602
- const customMap = (iss, ctx) => {
1603
- const { message } = params;
1604
- if (iss.code === "invalid_enum_value") {
1605
- return { message: message ?? ctx.defaultError };
1606
- }
1607
- if (typeof ctx.data === "undefined") {
1608
- return { message: message ?? required_error ?? ctx.defaultError };
1609
- }
1610
- if (iss.code !== "invalid_type")
1611
- return { message: ctx.defaultError };
1612
- return { message: message ?? invalid_type_error ?? ctx.defaultError };
1613
- };
1614
- return { errorMap: customMap, description };
1615
- }
1616
- var ZodType = class {
1617
- get description() {
1618
- return this._def.description;
1619
- }
1620
- _getType(input2) {
1621
- return getParsedType(input2.data);
1622
- }
1623
- _getOrReturnCtx(input2, ctx) {
1624
- return ctx || {
1625
- common: input2.parent.common,
1626
- data: input2.data,
1627
- parsedType: getParsedType(input2.data),
1628
- schemaErrorMap: this._def.errorMap,
1629
- path: input2.path,
1630
- parent: input2.parent
1631
- };
1632
- }
1633
- _processInputParams(input2) {
1634
- return {
1635
- status: new ParseStatus(),
1636
- ctx: {
1637
- common: input2.parent.common,
1638
- data: input2.data,
1639
- parsedType: getParsedType(input2.data),
1640
- schemaErrorMap: this._def.errorMap,
1641
- path: input2.path,
1642
- parent: input2.parent
1643
- }
1644
- };
1645
- }
1646
- _parseSync(input2) {
1647
- const result = this._parse(input2);
1648
- if (isAsync(result)) {
1649
- throw new Error("Synchronous parse encountered promise.");
1650
- }
1651
- return result;
1652
- }
1653
- _parseAsync(input2) {
1654
- const result = this._parse(input2);
1655
- return Promise.resolve(result);
1656
- }
1657
- parse(data, params) {
1658
- const result = this.safeParse(data, params);
1659
- if (result.success)
1660
- return result.data;
1661
- throw result.error;
1662
- }
1663
- safeParse(data, params) {
1664
- const ctx = {
1665
- common: {
1666
- issues: [],
1667
- async: params?.async ?? false,
1668
- contextualErrorMap: params?.errorMap
1669
- },
1670
- path: params?.path || [],
1671
- schemaErrorMap: this._def.errorMap,
1672
- parent: null,
1673
- data,
1674
- parsedType: getParsedType(data)
1675
- };
1676
- const result = this._parseSync({ data, path: ctx.path, parent: ctx });
1677
- return handleResult(ctx, result);
1678
- }
1679
- "~validate"(data) {
1680
- const ctx = {
1681
- common: {
1682
- issues: [],
1683
- async: !!this["~standard"].async
1684
- },
1685
- path: [],
1686
- schemaErrorMap: this._def.errorMap,
1687
- parent: null,
1688
- data,
1689
- parsedType: getParsedType(data)
1690
- };
1691
- if (!this["~standard"].async) {
1692
- try {
1693
- const result = this._parseSync({ data, path: [], parent: ctx });
1694
- return isValid(result) ? {
1695
- value: result.value
1696
- } : {
1697
- issues: ctx.common.issues
1698
- };
1699
- } catch (err) {
1700
- if (err?.message?.toLowerCase()?.includes("encountered")) {
1701
- this["~standard"].async = true;
1702
- }
1703
- ctx.common = {
1704
- issues: [],
1705
- async: true
1706
- };
1707
- }
1708
- }
1709
- return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
1710
- value: result.value
1711
- } : {
1712
- issues: ctx.common.issues
1713
- });
1714
- }
1715
- async parseAsync(data, params) {
1716
- const result = await this.safeParseAsync(data, params);
1717
- if (result.success)
1718
- return result.data;
1719
- throw result.error;
1720
- }
1721
- async safeParseAsync(data, params) {
1722
- const ctx = {
1723
- common: {
1724
- issues: [],
1725
- contextualErrorMap: params?.errorMap,
1726
- async: true
1727
- },
1728
- path: params?.path || [],
1729
- schemaErrorMap: this._def.errorMap,
1730
- parent: null,
1731
- data,
1732
- parsedType: getParsedType(data)
1733
- };
1734
- const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
1735
- const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
1736
- return handleResult(ctx, result);
1737
- }
1738
- refine(check2, message) {
1739
- const getIssueProperties = (val) => {
1740
- if (typeof message === "string" || typeof message === "undefined") {
1741
- return { message };
1742
- } else if (typeof message === "function") {
1743
- return message(val);
1744
- } else {
1745
- return message;
1746
- }
1747
- };
1748
- return this._refinement((val, ctx) => {
1749
- const result = check2(val);
1750
- const setError = () => ctx.addIssue({
1751
- code: ZodIssueCode.custom,
1752
- ...getIssueProperties(val)
1753
- });
1754
- if (typeof Promise !== "undefined" && result instanceof Promise) {
1755
- return result.then((data) => {
1756
- if (!data) {
1757
- setError();
1758
- return false;
1759
- } else {
1760
- return true;
1761
- }
1762
- });
1763
- }
1764
- if (!result) {
1765
- setError();
1766
- return false;
1767
- } else {
1768
- return true;
1769
- }
1770
- });
1771
- }
1772
- refinement(check2, refinementData) {
1773
- return this._refinement((val, ctx) => {
1774
- if (!check2(val)) {
1775
- ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
1776
- return false;
1777
- } else {
1778
- return true;
1779
- }
1780
- });
1781
- }
1782
- _refinement(refinement) {
1783
- return new ZodEffects({
1784
- schema: this,
1785
- typeName: ZodFirstPartyTypeKind.ZodEffects,
1786
- effect: { type: "refinement", refinement }
1787
- });
1788
- }
1789
- superRefine(refinement) {
1790
- return this._refinement(refinement);
1791
- }
1792
- constructor(def) {
1793
- this.spa = this.safeParseAsync;
1794
- this._def = def;
1795
- this.parse = this.parse.bind(this);
1796
- this.safeParse = this.safeParse.bind(this);
1797
- this.parseAsync = this.parseAsync.bind(this);
1798
- this.safeParseAsync = this.safeParseAsync.bind(this);
1799
- this.spa = this.spa.bind(this);
1800
- this.refine = this.refine.bind(this);
1801
- this.refinement = this.refinement.bind(this);
1802
- this.superRefine = this.superRefine.bind(this);
1803
- this.optional = this.optional.bind(this);
1804
- this.nullable = this.nullable.bind(this);
1805
- this.nullish = this.nullish.bind(this);
1806
- this.array = this.array.bind(this);
1807
- this.promise = this.promise.bind(this);
1808
- this.or = this.or.bind(this);
1809
- this.and = this.and.bind(this);
1810
- this.transform = this.transform.bind(this);
1811
- this.brand = this.brand.bind(this);
1812
- this.default = this.default.bind(this);
1813
- this.catch = this.catch.bind(this);
1814
- this.describe = this.describe.bind(this);
1815
- this.pipe = this.pipe.bind(this);
1816
- this.readonly = this.readonly.bind(this);
1817
- this.isNullable = this.isNullable.bind(this);
1818
- this.isOptional = this.isOptional.bind(this);
1819
- this["~standard"] = {
1820
- version: 1,
1821
- vendor: "zod",
1822
- validate: (data) => this["~validate"](data)
1823
- };
1824
- }
1825
- optional() {
1826
- return ZodOptional.create(this, this._def);
1827
- }
1828
- nullable() {
1829
- return ZodNullable.create(this, this._def);
1830
- }
1831
- nullish() {
1832
- return this.nullable().optional();
1833
- }
1834
- array() {
1835
- return ZodArray.create(this);
1836
- }
1837
- promise() {
1838
- return ZodPromise.create(this, this._def);
1839
- }
1840
- or(option) {
1841
- return ZodUnion.create([this, option], this._def);
1842
- }
1843
- and(incoming) {
1844
- return ZodIntersection.create(this, incoming, this._def);
1845
- }
1846
- transform(transform) {
1847
- return new ZodEffects({
1848
- ...processCreateParams(this._def),
1849
- schema: this,
1850
- typeName: ZodFirstPartyTypeKind.ZodEffects,
1851
- effect: { type: "transform", transform }
1852
- });
1853
- }
1854
- default(def) {
1855
- const defaultValueFunc = typeof def === "function" ? def : () => def;
1856
- return new ZodDefault({
1857
- ...processCreateParams(this._def),
1858
- innerType: this,
1859
- defaultValue: defaultValueFunc,
1860
- typeName: ZodFirstPartyTypeKind.ZodDefault
1861
- });
1862
- }
1863
- brand() {
1864
- return new ZodBranded({
1865
- typeName: ZodFirstPartyTypeKind.ZodBranded,
1866
- type: this,
1867
- ...processCreateParams(this._def)
1868
- });
1869
- }
1870
- catch(def) {
1871
- const catchValueFunc = typeof def === "function" ? def : () => def;
1872
- return new ZodCatch({
1873
- ...processCreateParams(this._def),
1874
- innerType: this,
1875
- catchValue: catchValueFunc,
1876
- typeName: ZodFirstPartyTypeKind.ZodCatch
1877
- });
1878
- }
1879
- describe(description) {
1880
- const This = this.constructor;
1881
- return new This({
1882
- ...this._def,
1883
- description
1884
- });
1885
- }
1886
- pipe(target) {
1887
- return ZodPipeline.create(this, target);
1888
- }
1889
- readonly() {
1890
- return ZodReadonly.create(this);
1891
- }
1892
- isOptional() {
1893
- return this.safeParse(void 0).success;
1894
- }
1895
- isNullable() {
1896
- return this.safeParse(null).success;
1897
- }
1898
- };
1899
- var cuidRegex = /^c[^\s-]{8,}$/i;
1900
- var cuid2Regex = /^[0-9a-z]+$/;
1901
- var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
1902
- 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;
1903
- var nanoidRegex = /^[a-z0-9_-]{21}$/i;
1904
- var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
1905
- 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)?)??$/;
1906
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1907
- var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1908
- var emojiRegex;
1909
- 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])$/;
1910
- 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])$/;
1911
- 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]))$/;
1912
- 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])$/;
1913
- var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1914
- var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
1915
- 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])))`;
1916
- var dateRegex = new RegExp(`^${dateRegexSource}$`);
1917
- function timeRegexSource(args) {
1918
- let secondsRegexSource = `[0-5]\\d`;
1919
- if (args.precision) {
1920
- secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
1921
- } else if (args.precision == null) {
1922
- secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
1923
- }
1924
- const secondsQuantifier = args.precision ? "+" : "?";
1925
- return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
1926
- }
1927
- function timeRegex(args) {
1928
- return new RegExp(`^${timeRegexSource(args)}$`);
1929
- }
1930
- function datetimeRegex(args) {
1931
- let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1932
- const opts = [];
1933
- opts.push(args.local ? `Z?` : `Z`);
1934
- if (args.offset)
1935
- opts.push(`([+-]\\d{2}:?\\d{2})`);
1936
- regex = `${regex}(${opts.join("|")})`;
1937
- return new RegExp(`^${regex}$`);
1938
- }
1939
- function isValidIP(ip, version) {
1940
- if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1941
- return true;
1942
- }
1943
- if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1944
- return true;
1945
- }
1946
- return false;
1947
- }
1948
- function isValidJWT(jwt, alg) {
1949
- if (!jwtRegex.test(jwt))
1950
- return false;
1951
- try {
1952
- const [header] = jwt.split(".");
1953
- if (!header)
1954
- return false;
1955
- const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
1956
- const decoded = JSON.parse(atob(base64));
1957
- if (typeof decoded !== "object" || decoded === null)
1958
- return false;
1959
- if ("typ" in decoded && decoded?.typ !== "JWT")
1960
- return false;
1961
- if (!decoded.alg)
1962
- return false;
1963
- if (alg && decoded.alg !== alg)
1964
- return false;
1965
- return true;
1966
- } catch {
1967
- return false;
1968
- }
1969
- }
1970
- function isValidCidr(ip, version) {
1971
- if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
1972
- return true;
1973
- }
1974
- if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
1975
- return true;
1976
- }
1977
- return false;
1978
- }
1979
- var ZodString = class _ZodString extends ZodType {
1980
- _parse(input2) {
1981
- if (this._def.coerce) {
1982
- input2.data = String(input2.data);
1983
- }
1984
- const parsedType = this._getType(input2);
1985
- if (parsedType !== ZodParsedType.string) {
1986
- const ctx2 = this._getOrReturnCtx(input2);
1987
- addIssueToContext(ctx2, {
1988
- code: ZodIssueCode.invalid_type,
1989
- expected: ZodParsedType.string,
1990
- received: ctx2.parsedType
1991
- });
1992
- return INVALID;
1993
- }
1994
- const status = new ParseStatus();
1995
- let ctx = void 0;
1996
- for (const check2 of this._def.checks) {
1997
- if (check2.kind === "min") {
1998
- if (input2.data.length < check2.value) {
1999
- ctx = this._getOrReturnCtx(input2, ctx);
2000
- addIssueToContext(ctx, {
2001
- code: ZodIssueCode.too_small,
2002
- minimum: check2.value,
2003
- type: "string",
2004
- inclusive: true,
2005
- exact: false,
2006
- message: check2.message
2007
- });
2008
- status.dirty();
2009
- }
2010
- } else if (check2.kind === "max") {
2011
- if (input2.data.length > check2.value) {
2012
- ctx = this._getOrReturnCtx(input2, ctx);
2013
- addIssueToContext(ctx, {
2014
- code: ZodIssueCode.too_big,
2015
- maximum: check2.value,
2016
- type: "string",
2017
- inclusive: true,
2018
- exact: false,
2019
- message: check2.message
2020
- });
2021
- status.dirty();
2022
- }
2023
- } else if (check2.kind === "length") {
2024
- const tooBig = input2.data.length > check2.value;
2025
- const tooSmall = input2.data.length < check2.value;
2026
- if (tooBig || tooSmall) {
2027
- ctx = this._getOrReturnCtx(input2, ctx);
2028
- if (tooBig) {
2029
- addIssueToContext(ctx, {
2030
- code: ZodIssueCode.too_big,
2031
- maximum: check2.value,
2032
- type: "string",
2033
- inclusive: true,
2034
- exact: true,
2035
- message: check2.message
2036
- });
2037
- } else if (tooSmall) {
2038
- addIssueToContext(ctx, {
2039
- code: ZodIssueCode.too_small,
2040
- minimum: check2.value,
2041
- type: "string",
2042
- inclusive: true,
2043
- exact: true,
2044
- message: check2.message
2045
- });
2046
- }
2047
- status.dirty();
2048
- }
2049
- } else if (check2.kind === "email") {
2050
- if (!emailRegex.test(input2.data)) {
2051
- ctx = this._getOrReturnCtx(input2, ctx);
2052
- addIssueToContext(ctx, {
2053
- validation: "email",
2054
- code: ZodIssueCode.invalid_string,
2055
- message: check2.message
2056
- });
2057
- status.dirty();
2058
- }
2059
- } else if (check2.kind === "emoji") {
2060
- if (!emojiRegex) {
2061
- emojiRegex = new RegExp(_emojiRegex, "u");
2062
- }
2063
- if (!emojiRegex.test(input2.data)) {
2064
- ctx = this._getOrReturnCtx(input2, ctx);
2065
- addIssueToContext(ctx, {
2066
- validation: "emoji",
2067
- code: ZodIssueCode.invalid_string,
2068
- message: check2.message
2069
- });
2070
- status.dirty();
2071
- }
2072
- } else if (check2.kind === "uuid") {
2073
- if (!uuidRegex.test(input2.data)) {
2074
- ctx = this._getOrReturnCtx(input2, ctx);
2075
- addIssueToContext(ctx, {
2076
- validation: "uuid",
2077
- code: ZodIssueCode.invalid_string,
2078
- message: check2.message
2079
- });
2080
- status.dirty();
2081
- }
2082
- } else if (check2.kind === "nanoid") {
2083
- if (!nanoidRegex.test(input2.data)) {
2084
- ctx = this._getOrReturnCtx(input2, ctx);
2085
- addIssueToContext(ctx, {
2086
- validation: "nanoid",
2087
- code: ZodIssueCode.invalid_string,
2088
- message: check2.message
2089
- });
2090
- status.dirty();
2091
- }
2092
- } else if (check2.kind === "cuid") {
2093
- if (!cuidRegex.test(input2.data)) {
2094
- ctx = this._getOrReturnCtx(input2, ctx);
2095
- addIssueToContext(ctx, {
2096
- validation: "cuid",
2097
- code: ZodIssueCode.invalid_string,
2098
- message: check2.message
2099
- });
2100
- status.dirty();
2101
- }
2102
- } else if (check2.kind === "cuid2") {
2103
- if (!cuid2Regex.test(input2.data)) {
2104
- ctx = this._getOrReturnCtx(input2, ctx);
2105
- addIssueToContext(ctx, {
2106
- validation: "cuid2",
2107
- code: ZodIssueCode.invalid_string,
2108
- message: check2.message
2109
- });
2110
- status.dirty();
2111
- }
2112
- } else if (check2.kind === "ulid") {
2113
- if (!ulidRegex.test(input2.data)) {
2114
- ctx = this._getOrReturnCtx(input2, ctx);
2115
- addIssueToContext(ctx, {
2116
- validation: "ulid",
2117
- code: ZodIssueCode.invalid_string,
2118
- message: check2.message
2119
- });
2120
- status.dirty();
2121
- }
2122
- } else if (check2.kind === "url") {
2123
- try {
2124
- new URL(input2.data);
2125
- } catch {
2126
- ctx = this._getOrReturnCtx(input2, ctx);
2127
- addIssueToContext(ctx, {
2128
- validation: "url",
2129
- code: ZodIssueCode.invalid_string,
2130
- message: check2.message
2131
- });
2132
- status.dirty();
2133
- }
2134
- } else if (check2.kind === "regex") {
2135
- check2.regex.lastIndex = 0;
2136
- const testResult = check2.regex.test(input2.data);
2137
- if (!testResult) {
2138
- ctx = this._getOrReturnCtx(input2, ctx);
2139
- addIssueToContext(ctx, {
2140
- validation: "regex",
2141
- code: ZodIssueCode.invalid_string,
2142
- message: check2.message
2143
- });
2144
- status.dirty();
2145
- }
2146
- } else if (check2.kind === "trim") {
2147
- input2.data = input2.data.trim();
2148
- } else if (check2.kind === "includes") {
2149
- if (!input2.data.includes(check2.value, check2.position)) {
2150
- ctx = this._getOrReturnCtx(input2, ctx);
2151
- addIssueToContext(ctx, {
2152
- code: ZodIssueCode.invalid_string,
2153
- validation: { includes: check2.value, position: check2.position },
2154
- message: check2.message
2155
- });
2156
- status.dirty();
2157
- }
2158
- } else if (check2.kind === "toLowerCase") {
2159
- input2.data = input2.data.toLowerCase();
2160
- } else if (check2.kind === "toUpperCase") {
2161
- input2.data = input2.data.toUpperCase();
2162
- } else if (check2.kind === "startsWith") {
2163
- if (!input2.data.startsWith(check2.value)) {
2164
- ctx = this._getOrReturnCtx(input2, ctx);
2165
- addIssueToContext(ctx, {
2166
- code: ZodIssueCode.invalid_string,
2167
- validation: { startsWith: check2.value },
2168
- message: check2.message
2169
- });
2170
- status.dirty();
2171
- }
2172
- } else if (check2.kind === "endsWith") {
2173
- if (!input2.data.endsWith(check2.value)) {
2174
- ctx = this._getOrReturnCtx(input2, ctx);
2175
- addIssueToContext(ctx, {
2176
- code: ZodIssueCode.invalid_string,
2177
- validation: { endsWith: check2.value },
2178
- message: check2.message
2179
- });
2180
- status.dirty();
2181
- }
2182
- } else if (check2.kind === "datetime") {
2183
- const regex = datetimeRegex(check2);
2184
- if (!regex.test(input2.data)) {
2185
- ctx = this._getOrReturnCtx(input2, ctx);
2186
- addIssueToContext(ctx, {
2187
- code: ZodIssueCode.invalid_string,
2188
- validation: "datetime",
2189
- message: check2.message
2190
- });
2191
- status.dirty();
2192
- }
2193
- } else if (check2.kind === "date") {
2194
- const regex = dateRegex;
2195
- if (!regex.test(input2.data)) {
2196
- ctx = this._getOrReturnCtx(input2, ctx);
2197
- addIssueToContext(ctx, {
2198
- code: ZodIssueCode.invalid_string,
2199
- validation: "date",
2200
- message: check2.message
2201
- });
2202
- status.dirty();
2203
- }
2204
- } else if (check2.kind === "time") {
2205
- const regex = timeRegex(check2);
2206
- if (!regex.test(input2.data)) {
2207
- ctx = this._getOrReturnCtx(input2, ctx);
2208
- addIssueToContext(ctx, {
2209
- code: ZodIssueCode.invalid_string,
2210
- validation: "time",
2211
- message: check2.message
2212
- });
2213
- status.dirty();
2214
- }
2215
- } else if (check2.kind === "duration") {
2216
- if (!durationRegex.test(input2.data)) {
2217
- ctx = this._getOrReturnCtx(input2, ctx);
2218
- addIssueToContext(ctx, {
2219
- validation: "duration",
2220
- code: ZodIssueCode.invalid_string,
2221
- message: check2.message
2222
- });
2223
- status.dirty();
2224
- }
2225
- } else if (check2.kind === "ip") {
2226
- if (!isValidIP(input2.data, check2.version)) {
2227
- ctx = this._getOrReturnCtx(input2, ctx);
2228
- addIssueToContext(ctx, {
2229
- validation: "ip",
2230
- code: ZodIssueCode.invalid_string,
2231
- message: check2.message
2232
- });
2233
- status.dirty();
2234
- }
2235
- } else if (check2.kind === "jwt") {
2236
- if (!isValidJWT(input2.data, check2.alg)) {
2237
- ctx = this._getOrReturnCtx(input2, ctx);
2238
- addIssueToContext(ctx, {
2239
- validation: "jwt",
2240
- code: ZodIssueCode.invalid_string,
2241
- message: check2.message
2242
- });
2243
- status.dirty();
2244
- }
2245
- } else if (check2.kind === "cidr") {
2246
- if (!isValidCidr(input2.data, check2.version)) {
2247
- ctx = this._getOrReturnCtx(input2, ctx);
2248
- addIssueToContext(ctx, {
2249
- validation: "cidr",
2250
- code: ZodIssueCode.invalid_string,
2251
- message: check2.message
2252
- });
2253
- status.dirty();
2254
- }
2255
- } else if (check2.kind === "base64") {
2256
- if (!base64Regex.test(input2.data)) {
2257
- ctx = this._getOrReturnCtx(input2, ctx);
2258
- addIssueToContext(ctx, {
2259
- validation: "base64",
2260
- code: ZodIssueCode.invalid_string,
2261
- message: check2.message
2262
- });
2263
- status.dirty();
2264
- }
2265
- } else if (check2.kind === "base64url") {
2266
- if (!base64urlRegex.test(input2.data)) {
2267
- ctx = this._getOrReturnCtx(input2, ctx);
2268
- addIssueToContext(ctx, {
2269
- validation: "base64url",
2270
- code: ZodIssueCode.invalid_string,
2271
- message: check2.message
2272
- });
2273
- status.dirty();
2274
- }
2275
- } else {
2276
- util.assertNever(check2);
2277
- }
2278
- }
2279
- return { status: status.value, value: input2.data };
2280
- }
2281
- _regex(regex, validation, message) {
2282
- return this.refinement((data) => regex.test(data), {
2283
- validation,
2284
- code: ZodIssueCode.invalid_string,
2285
- ...errorUtil.errToObj(message)
2286
- });
2287
- }
2288
- _addCheck(check2) {
2289
- return new _ZodString({
2290
- ...this._def,
2291
- checks: [...this._def.checks, check2]
2292
- });
2293
- }
2294
- email(message) {
2295
- return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
2296
- }
2297
- url(message) {
2298
- return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
2299
- }
2300
- emoji(message) {
2301
- return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
2302
- }
2303
- uuid(message) {
2304
- return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2305
- }
2306
- nanoid(message) {
2307
- return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
2308
- }
2309
- cuid(message) {
2310
- return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2311
- }
2312
- cuid2(message) {
2313
- return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
2314
- }
2315
- ulid(message) {
2316
- return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
2317
- }
2318
- base64(message) {
2319
- return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2320
- }
2321
- base64url(message) {
2322
- return this._addCheck({
2323
- kind: "base64url",
2324
- ...errorUtil.errToObj(message)
2325
- });
2326
- }
2327
- jwt(options) {
2328
- return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
2329
- }
2330
- ip(options) {
2331
- return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2332
- }
2333
- cidr(options) {
2334
- return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
2335
- }
2336
- datetime(options) {
2337
- if (typeof options === "string") {
2338
- return this._addCheck({
2339
- kind: "datetime",
2340
- precision: null,
2341
- offset: false,
2342
- local: false,
2343
- message: options
2344
- });
2345
- }
2346
- return this._addCheck({
2347
- kind: "datetime",
2348
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
2349
- offset: options?.offset ?? false,
2350
- local: options?.local ?? false,
2351
- ...errorUtil.errToObj(options?.message)
2352
- });
2353
- }
2354
- date(message) {
2355
- return this._addCheck({ kind: "date", message });
2356
- }
2357
- time(options) {
2358
- if (typeof options === "string") {
2359
- return this._addCheck({
2360
- kind: "time",
2361
- precision: null,
2362
- message: options
2363
- });
2364
- }
2365
- return this._addCheck({
2366
- kind: "time",
2367
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
2368
- ...errorUtil.errToObj(options?.message)
2369
- });
2370
- }
2371
- duration(message) {
2372
- return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
2373
- }
2374
- regex(regex, message) {
2375
- return this._addCheck({
2376
- kind: "regex",
2377
- regex,
2378
- ...errorUtil.errToObj(message)
2379
- });
2380
- }
2381
- includes(value, options) {
2382
- return this._addCheck({
2383
- kind: "includes",
2384
- value,
2385
- position: options?.position,
2386
- ...errorUtil.errToObj(options?.message)
2387
- });
2388
- }
2389
- startsWith(value, message) {
2390
- return this._addCheck({
2391
- kind: "startsWith",
2392
- value,
2393
- ...errorUtil.errToObj(message)
2394
- });
2395
- }
2396
- endsWith(value, message) {
2397
- return this._addCheck({
2398
- kind: "endsWith",
2399
- value,
2400
- ...errorUtil.errToObj(message)
2401
- });
2402
- }
2403
- min(minLength, message) {
2404
- return this._addCheck({
2405
- kind: "min",
2406
- value: minLength,
2407
- ...errorUtil.errToObj(message)
2408
- });
2409
- }
2410
- max(maxLength, message) {
2411
- return this._addCheck({
2412
- kind: "max",
2413
- value: maxLength,
2414
- ...errorUtil.errToObj(message)
2415
- });
2416
- }
2417
- length(len, message) {
2418
- return this._addCheck({
2419
- kind: "length",
2420
- value: len,
2421
- ...errorUtil.errToObj(message)
2422
- });
2423
- }
2424
- /**
2425
- * Equivalent to `.min(1)`
2426
- */
2427
- nonempty(message) {
2428
- return this.min(1, errorUtil.errToObj(message));
2429
- }
2430
- trim() {
2431
- return new _ZodString({
2432
- ...this._def,
2433
- checks: [...this._def.checks, { kind: "trim" }]
2434
- });
2435
- }
2436
- toLowerCase() {
2437
- return new _ZodString({
2438
- ...this._def,
2439
- checks: [...this._def.checks, { kind: "toLowerCase" }]
2440
- });
2441
- }
2442
- toUpperCase() {
2443
- return new _ZodString({
2444
- ...this._def,
2445
- checks: [...this._def.checks, { kind: "toUpperCase" }]
2446
- });
2447
- }
2448
- get isDatetime() {
2449
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
2450
- }
2451
- get isDate() {
2452
- return !!this._def.checks.find((ch) => ch.kind === "date");
2453
- }
2454
- get isTime() {
2455
- return !!this._def.checks.find((ch) => ch.kind === "time");
2456
- }
2457
- get isDuration() {
2458
- return !!this._def.checks.find((ch) => ch.kind === "duration");
2459
- }
2460
- get isEmail() {
2461
- return !!this._def.checks.find((ch) => ch.kind === "email");
2462
- }
2463
- get isURL() {
2464
- return !!this._def.checks.find((ch) => ch.kind === "url");
2465
- }
2466
- get isEmoji() {
2467
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
2468
- }
2469
- get isUUID() {
2470
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
2471
- }
2472
- get isNANOID() {
2473
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
2474
- }
2475
- get isCUID() {
2476
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
2477
- }
2478
- get isCUID2() {
2479
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
2480
- }
2481
- get isULID() {
2482
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
2483
- }
2484
- get isIP() {
2485
- return !!this._def.checks.find((ch) => ch.kind === "ip");
2486
- }
2487
- get isCIDR() {
2488
- return !!this._def.checks.find((ch) => ch.kind === "cidr");
2489
- }
2490
- get isBase64() {
2491
- return !!this._def.checks.find((ch) => ch.kind === "base64");
2492
- }
2493
- get isBase64url() {
2494
- return !!this._def.checks.find((ch) => ch.kind === "base64url");
2495
- }
2496
- get minLength() {
2497
- let min = null;
2498
- for (const ch of this._def.checks) {
2499
- if (ch.kind === "min") {
2500
- if (min === null || ch.value > min)
2501
- min = ch.value;
2502
- }
2503
- }
2504
- return min;
2505
- }
2506
- get maxLength() {
2507
- let max = null;
2508
- for (const ch of this._def.checks) {
2509
- if (ch.kind === "max") {
2510
- if (max === null || ch.value < max)
2511
- max = ch.value;
2512
- }
2513
- }
2514
- return max;
2515
- }
2516
- };
2517
- ZodString.create = (params) => {
2518
- return new ZodString({
2519
- checks: [],
2520
- typeName: ZodFirstPartyTypeKind.ZodString,
2521
- coerce: params?.coerce ?? false,
2522
- ...processCreateParams(params)
2523
- });
2524
- };
2525
- function floatSafeRemainder(val, step) {
2526
- const valDecCount = (val.toString().split(".")[1] || "").length;
2527
- const stepDecCount = (step.toString().split(".")[1] || "").length;
2528
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
2529
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
2530
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
2531
- return valInt % stepInt / 10 ** decCount;
2532
- }
2533
- var ZodNumber = class _ZodNumber extends ZodType {
2534
- constructor() {
2535
- super(...arguments);
2536
- this.min = this.gte;
2537
- this.max = this.lte;
2538
- this.step = this.multipleOf;
2539
- }
2540
- _parse(input2) {
2541
- if (this._def.coerce) {
2542
- input2.data = Number(input2.data);
2543
- }
2544
- const parsedType = this._getType(input2);
2545
- if (parsedType !== ZodParsedType.number) {
2546
- const ctx2 = this._getOrReturnCtx(input2);
2547
- addIssueToContext(ctx2, {
2548
- code: ZodIssueCode.invalid_type,
2549
- expected: ZodParsedType.number,
2550
- received: ctx2.parsedType
2551
- });
2552
- return INVALID;
2553
- }
2554
- let ctx = void 0;
2555
- const status = new ParseStatus();
2556
- for (const check2 of this._def.checks) {
2557
- if (check2.kind === "int") {
2558
- if (!util.isInteger(input2.data)) {
2559
- ctx = this._getOrReturnCtx(input2, ctx);
2560
- addIssueToContext(ctx, {
2561
- code: ZodIssueCode.invalid_type,
2562
- expected: "integer",
2563
- received: "float",
2564
- message: check2.message
2565
- });
2566
- status.dirty();
2567
- }
2568
- } else if (check2.kind === "min") {
2569
- const tooSmall = check2.inclusive ? input2.data < check2.value : input2.data <= check2.value;
2570
- if (tooSmall) {
2571
- ctx = this._getOrReturnCtx(input2, ctx);
2572
- addIssueToContext(ctx, {
2573
- code: ZodIssueCode.too_small,
2574
- minimum: check2.value,
2575
- type: "number",
2576
- inclusive: check2.inclusive,
2577
- exact: false,
2578
- message: check2.message
2579
- });
2580
- status.dirty();
2581
- }
2582
- } else if (check2.kind === "max") {
2583
- const tooBig = check2.inclusive ? input2.data > check2.value : input2.data >= check2.value;
2584
- if (tooBig) {
2585
- ctx = this._getOrReturnCtx(input2, ctx);
2586
- addIssueToContext(ctx, {
2587
- code: ZodIssueCode.too_big,
2588
- maximum: check2.value,
2589
- type: "number",
2590
- inclusive: check2.inclusive,
2591
- exact: false,
2592
- message: check2.message
2593
- });
2594
- status.dirty();
2595
- }
2596
- } else if (check2.kind === "multipleOf") {
2597
- if (floatSafeRemainder(input2.data, check2.value) !== 0) {
2598
- ctx = this._getOrReturnCtx(input2, ctx);
2599
- addIssueToContext(ctx, {
2600
- code: ZodIssueCode.not_multiple_of,
2601
- multipleOf: check2.value,
2602
- message: check2.message
2603
- });
2604
- status.dirty();
2605
- }
2606
- } else if (check2.kind === "finite") {
2607
- if (!Number.isFinite(input2.data)) {
2608
- ctx = this._getOrReturnCtx(input2, ctx);
2609
- addIssueToContext(ctx, {
2610
- code: ZodIssueCode.not_finite,
2611
- message: check2.message
2612
- });
2613
- status.dirty();
2614
- }
2615
- } else {
2616
- util.assertNever(check2);
2617
- }
2618
- }
2619
- return { status: status.value, value: input2.data };
2620
- }
2621
- gte(value, message) {
2622
- return this.setLimit("min", value, true, errorUtil.toString(message));
2623
- }
2624
- gt(value, message) {
2625
- return this.setLimit("min", value, false, errorUtil.toString(message));
2626
- }
2627
- lte(value, message) {
2628
- return this.setLimit("max", value, true, errorUtil.toString(message));
2629
- }
2630
- lt(value, message) {
2631
- return this.setLimit("max", value, false, errorUtil.toString(message));
2632
- }
2633
- setLimit(kind, value, inclusive, message) {
2634
- return new _ZodNumber({
2635
- ...this._def,
2636
- checks: [
2637
- ...this._def.checks,
2638
- {
2639
- kind,
2640
- value,
2641
- inclusive,
2642
- message: errorUtil.toString(message)
2643
- }
2644
- ]
2645
- });
2646
- }
2647
- _addCheck(check2) {
2648
- return new _ZodNumber({
2649
- ...this._def,
2650
- checks: [...this._def.checks, check2]
2651
- });
2652
- }
2653
- int(message) {
2654
- return this._addCheck({
2655
- kind: "int",
2656
- message: errorUtil.toString(message)
2657
- });
2658
- }
2659
- positive(message) {
2660
- return this._addCheck({
2661
- kind: "min",
2662
- value: 0,
2663
- inclusive: false,
2664
- message: errorUtil.toString(message)
2665
- });
2666
- }
2667
- negative(message) {
2668
- return this._addCheck({
2669
- kind: "max",
2670
- value: 0,
2671
- inclusive: false,
2672
- message: errorUtil.toString(message)
2673
- });
2674
- }
2675
- nonpositive(message) {
2676
- return this._addCheck({
2677
- kind: "max",
2678
- value: 0,
2679
- inclusive: true,
2680
- message: errorUtil.toString(message)
2681
- });
2682
- }
2683
- nonnegative(message) {
2684
- return this._addCheck({
2685
- kind: "min",
2686
- value: 0,
2687
- inclusive: true,
2688
- message: errorUtil.toString(message)
2689
- });
2690
- }
2691
- multipleOf(value, message) {
2692
- return this._addCheck({
2693
- kind: "multipleOf",
2694
- value,
2695
- message: errorUtil.toString(message)
2696
- });
2697
- }
2698
- finite(message) {
2699
- return this._addCheck({
2700
- kind: "finite",
2701
- message: errorUtil.toString(message)
2702
- });
2703
- }
2704
- safe(message) {
2705
- return this._addCheck({
2706
- kind: "min",
2707
- inclusive: true,
2708
- value: Number.MIN_SAFE_INTEGER,
2709
- message: errorUtil.toString(message)
2710
- })._addCheck({
2711
- kind: "max",
2712
- inclusive: true,
2713
- value: Number.MAX_SAFE_INTEGER,
2714
- message: errorUtil.toString(message)
2715
- });
2716
- }
2717
- get minValue() {
2718
- let min = null;
2719
- for (const ch of this._def.checks) {
2720
- if (ch.kind === "min") {
2721
- if (min === null || ch.value > min)
2722
- min = ch.value;
2723
- }
2724
- }
2725
- return min;
2726
- }
2727
- get maxValue() {
2728
- let max = null;
2729
- for (const ch of this._def.checks) {
2730
- if (ch.kind === "max") {
2731
- if (max === null || ch.value < max)
2732
- max = ch.value;
2733
- }
2734
- }
2735
- return max;
2736
- }
2737
- get isInt() {
2738
- return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
2739
- }
2740
- get isFinite() {
2741
- let max = null;
2742
- let min = null;
2743
- for (const ch of this._def.checks) {
2744
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
2745
- return true;
2746
- } else if (ch.kind === "min") {
2747
- if (min === null || ch.value > min)
2748
- min = ch.value;
2749
- } else if (ch.kind === "max") {
2750
- if (max === null || ch.value < max)
2751
- max = ch.value;
2752
- }
2753
- }
2754
- return Number.isFinite(min) && Number.isFinite(max);
2755
- }
2756
- };
2757
- ZodNumber.create = (params) => {
2758
- return new ZodNumber({
2759
- checks: [],
2760
- typeName: ZodFirstPartyTypeKind.ZodNumber,
2761
- coerce: params?.coerce || false,
2762
- ...processCreateParams(params)
2763
- });
2764
- };
2765
- var ZodBigInt = class _ZodBigInt extends ZodType {
2766
- constructor() {
2767
- super(...arguments);
2768
- this.min = this.gte;
2769
- this.max = this.lte;
2770
- }
2771
- _parse(input2) {
2772
- if (this._def.coerce) {
2773
- try {
2774
- input2.data = BigInt(input2.data);
2775
- } catch {
2776
- return this._getInvalidInput(input2);
2777
- }
2778
- }
2779
- const parsedType = this._getType(input2);
2780
- if (parsedType !== ZodParsedType.bigint) {
2781
- return this._getInvalidInput(input2);
2782
- }
2783
- let ctx = void 0;
2784
- const status = new ParseStatus();
2785
- for (const check2 of this._def.checks) {
2786
- if (check2.kind === "min") {
2787
- const tooSmall = check2.inclusive ? input2.data < check2.value : input2.data <= check2.value;
2788
- if (tooSmall) {
2789
- ctx = this._getOrReturnCtx(input2, ctx);
2790
- addIssueToContext(ctx, {
2791
- code: ZodIssueCode.too_small,
2792
- type: "bigint",
2793
- minimum: check2.value,
2794
- inclusive: check2.inclusive,
2795
- message: check2.message
2796
- });
2797
- status.dirty();
2798
- }
2799
- } else if (check2.kind === "max") {
2800
- const tooBig = check2.inclusive ? input2.data > check2.value : input2.data >= check2.value;
2801
- if (tooBig) {
2802
- ctx = this._getOrReturnCtx(input2, ctx);
2803
- addIssueToContext(ctx, {
2804
- code: ZodIssueCode.too_big,
2805
- type: "bigint",
2806
- maximum: check2.value,
2807
- inclusive: check2.inclusive,
2808
- message: check2.message
2809
- });
2810
- status.dirty();
2811
- }
2812
- } else if (check2.kind === "multipleOf") {
2813
- if (input2.data % check2.value !== BigInt(0)) {
2814
- ctx = this._getOrReturnCtx(input2, ctx);
2815
- addIssueToContext(ctx, {
2816
- code: ZodIssueCode.not_multiple_of,
2817
- multipleOf: check2.value,
2818
- message: check2.message
2819
- });
2820
- status.dirty();
2821
- }
2822
- } else {
2823
- util.assertNever(check2);
2824
- }
2825
- }
2826
- return { status: status.value, value: input2.data };
2827
- }
2828
- _getInvalidInput(input2) {
2829
- const ctx = this._getOrReturnCtx(input2);
2830
- addIssueToContext(ctx, {
2831
- code: ZodIssueCode.invalid_type,
2832
- expected: ZodParsedType.bigint,
2833
- received: ctx.parsedType
2834
- });
2835
- return INVALID;
2836
- }
2837
- gte(value, message) {
2838
- return this.setLimit("min", value, true, errorUtil.toString(message));
2839
- }
2840
- gt(value, message) {
2841
- return this.setLimit("min", value, false, errorUtil.toString(message));
2842
- }
2843
- lte(value, message) {
2844
- return this.setLimit("max", value, true, errorUtil.toString(message));
2845
- }
2846
- lt(value, message) {
2847
- return this.setLimit("max", value, false, errorUtil.toString(message));
2848
- }
2849
- setLimit(kind, value, inclusive, message) {
2850
- return new _ZodBigInt({
2851
- ...this._def,
2852
- checks: [
2853
- ...this._def.checks,
2854
- {
2855
- kind,
2856
- value,
2857
- inclusive,
2858
- message: errorUtil.toString(message)
2859
- }
2860
- ]
2861
- });
2862
- }
2863
- _addCheck(check2) {
2864
- return new _ZodBigInt({
2865
- ...this._def,
2866
- checks: [...this._def.checks, check2]
2867
- });
2868
- }
2869
- positive(message) {
2870
- return this._addCheck({
2871
- kind: "min",
2872
- value: BigInt(0),
2873
- inclusive: false,
2874
- message: errorUtil.toString(message)
2875
- });
2876
- }
2877
- negative(message) {
2878
- return this._addCheck({
2879
- kind: "max",
2880
- value: BigInt(0),
2881
- inclusive: false,
2882
- message: errorUtil.toString(message)
2883
- });
2884
- }
2885
- nonpositive(message) {
2886
- return this._addCheck({
2887
- kind: "max",
2888
- value: BigInt(0),
2889
- inclusive: true,
2890
- message: errorUtil.toString(message)
2891
- });
2892
- }
2893
- nonnegative(message) {
2894
- return this._addCheck({
2895
- kind: "min",
2896
- value: BigInt(0),
2897
- inclusive: true,
2898
- message: errorUtil.toString(message)
2899
- });
2900
- }
2901
- multipleOf(value, message) {
2902
- return this._addCheck({
2903
- kind: "multipleOf",
2904
- value,
2905
- message: errorUtil.toString(message)
2906
- });
2907
- }
2908
- get minValue() {
2909
- let min = null;
2910
- for (const ch of this._def.checks) {
2911
- if (ch.kind === "min") {
2912
- if (min === null || ch.value > min)
2913
- min = ch.value;
2914
- }
2915
- }
2916
- return min;
2917
- }
2918
- get maxValue() {
2919
- let max = null;
2920
- for (const ch of this._def.checks) {
2921
- if (ch.kind === "max") {
2922
- if (max === null || ch.value < max)
2923
- max = ch.value;
2924
- }
2925
- }
2926
- return max;
2927
- }
2928
- };
2929
- ZodBigInt.create = (params) => {
2930
- return new ZodBigInt({
2931
- checks: [],
2932
- typeName: ZodFirstPartyTypeKind.ZodBigInt,
2933
- coerce: params?.coerce ?? false,
2934
- ...processCreateParams(params)
2935
- });
2936
- };
2937
- var ZodBoolean = class extends ZodType {
2938
- _parse(input2) {
2939
- if (this._def.coerce) {
2940
- input2.data = Boolean(input2.data);
2941
- }
2942
- const parsedType = this._getType(input2);
2943
- if (parsedType !== ZodParsedType.boolean) {
2944
- const ctx = this._getOrReturnCtx(input2);
2945
- addIssueToContext(ctx, {
2946
- code: ZodIssueCode.invalid_type,
2947
- expected: ZodParsedType.boolean,
2948
- received: ctx.parsedType
2949
- });
2950
- return INVALID;
2951
- }
2952
- return OK(input2.data);
2953
- }
2954
- };
2955
- ZodBoolean.create = (params) => {
2956
- return new ZodBoolean({
2957
- typeName: ZodFirstPartyTypeKind.ZodBoolean,
2958
- coerce: params?.coerce || false,
2959
- ...processCreateParams(params)
2960
- });
2961
- };
2962
- var ZodDate = class _ZodDate extends ZodType {
2963
- _parse(input2) {
2964
- if (this._def.coerce) {
2965
- input2.data = new Date(input2.data);
2966
- }
2967
- const parsedType = this._getType(input2);
2968
- if (parsedType !== ZodParsedType.date) {
2969
- const ctx2 = this._getOrReturnCtx(input2);
2970
- addIssueToContext(ctx2, {
2971
- code: ZodIssueCode.invalid_type,
2972
- expected: ZodParsedType.date,
2973
- received: ctx2.parsedType
2974
- });
2975
- return INVALID;
2976
- }
2977
- if (Number.isNaN(input2.data.getTime())) {
2978
- const ctx2 = this._getOrReturnCtx(input2);
2979
- addIssueToContext(ctx2, {
2980
- code: ZodIssueCode.invalid_date
2981
- });
2982
- return INVALID;
2983
- }
2984
- const status = new ParseStatus();
2985
- let ctx = void 0;
2986
- for (const check2 of this._def.checks) {
2987
- if (check2.kind === "min") {
2988
- if (input2.data.getTime() < check2.value) {
2989
- ctx = this._getOrReturnCtx(input2, ctx);
2990
- addIssueToContext(ctx, {
2991
- code: ZodIssueCode.too_small,
2992
- message: check2.message,
2993
- inclusive: true,
2994
- exact: false,
2995
- minimum: check2.value,
2996
- type: "date"
2997
- });
2998
- status.dirty();
2999
- }
3000
- } else if (check2.kind === "max") {
3001
- if (input2.data.getTime() > check2.value) {
3002
- ctx = this._getOrReturnCtx(input2, ctx);
3003
- addIssueToContext(ctx, {
3004
- code: ZodIssueCode.too_big,
3005
- message: check2.message,
3006
- inclusive: true,
3007
- exact: false,
3008
- maximum: check2.value,
3009
- type: "date"
3010
- });
3011
- status.dirty();
3012
- }
3013
- } else {
3014
- util.assertNever(check2);
3015
- }
3016
- }
3017
- return {
3018
- status: status.value,
3019
- value: new Date(input2.data.getTime())
3020
- };
3021
- }
3022
- _addCheck(check2) {
3023
- return new _ZodDate({
3024
- ...this._def,
3025
- checks: [...this._def.checks, check2]
3026
- });
3027
- }
3028
- min(minDate, message) {
3029
- return this._addCheck({
3030
- kind: "min",
3031
- value: minDate.getTime(),
3032
- message: errorUtil.toString(message)
3033
- });
3034
- }
3035
- max(maxDate, message) {
3036
- return this._addCheck({
3037
- kind: "max",
3038
- value: maxDate.getTime(),
3039
- message: errorUtil.toString(message)
3040
- });
3041
- }
3042
- get minDate() {
3043
- let min = null;
3044
- for (const ch of this._def.checks) {
3045
- if (ch.kind === "min") {
3046
- if (min === null || ch.value > min)
3047
- min = ch.value;
3048
- }
3049
- }
3050
- return min != null ? new Date(min) : null;
3051
- }
3052
- get maxDate() {
3053
- let max = null;
3054
- for (const ch of this._def.checks) {
3055
- if (ch.kind === "max") {
3056
- if (max === null || ch.value < max)
3057
- max = ch.value;
3058
- }
3059
- }
3060
- return max != null ? new Date(max) : null;
3061
- }
3062
- };
3063
- ZodDate.create = (params) => {
3064
- return new ZodDate({
3065
- checks: [],
3066
- coerce: params?.coerce || false,
3067
- typeName: ZodFirstPartyTypeKind.ZodDate,
3068
- ...processCreateParams(params)
3069
- });
3070
- };
3071
- var ZodSymbol = class extends ZodType {
3072
- _parse(input2) {
3073
- const parsedType = this._getType(input2);
3074
- if (parsedType !== ZodParsedType.symbol) {
3075
- const ctx = this._getOrReturnCtx(input2);
3076
- addIssueToContext(ctx, {
3077
- code: ZodIssueCode.invalid_type,
3078
- expected: ZodParsedType.symbol,
3079
- received: ctx.parsedType
3080
- });
3081
- return INVALID;
3082
- }
3083
- return OK(input2.data);
3084
- }
3085
- };
3086
- ZodSymbol.create = (params) => {
3087
- return new ZodSymbol({
3088
- typeName: ZodFirstPartyTypeKind.ZodSymbol,
3089
- ...processCreateParams(params)
3090
- });
3091
- };
3092
- var ZodUndefined = class extends ZodType {
3093
- _parse(input2) {
3094
- const parsedType = this._getType(input2);
3095
- if (parsedType !== ZodParsedType.undefined) {
3096
- const ctx = this._getOrReturnCtx(input2);
3097
- addIssueToContext(ctx, {
3098
- code: ZodIssueCode.invalid_type,
3099
- expected: ZodParsedType.undefined,
3100
- received: ctx.parsedType
3101
- });
3102
- return INVALID;
3103
- }
3104
- return OK(input2.data);
3105
- }
3106
- };
3107
- ZodUndefined.create = (params) => {
3108
- return new ZodUndefined({
3109
- typeName: ZodFirstPartyTypeKind.ZodUndefined,
3110
- ...processCreateParams(params)
3111
- });
3112
- };
3113
- var ZodNull = class extends ZodType {
3114
- _parse(input2) {
3115
- const parsedType = this._getType(input2);
3116
- if (parsedType !== ZodParsedType.null) {
3117
- const ctx = this._getOrReturnCtx(input2);
3118
- addIssueToContext(ctx, {
3119
- code: ZodIssueCode.invalid_type,
3120
- expected: ZodParsedType.null,
3121
- received: ctx.parsedType
3122
- });
3123
- return INVALID;
3124
- }
3125
- return OK(input2.data);
3126
- }
3127
- };
3128
- ZodNull.create = (params) => {
3129
- return new ZodNull({
3130
- typeName: ZodFirstPartyTypeKind.ZodNull,
3131
- ...processCreateParams(params)
3132
- });
3133
- };
3134
- var ZodAny = class extends ZodType {
3135
- constructor() {
3136
- super(...arguments);
3137
- this._any = true;
3138
- }
3139
- _parse(input2) {
3140
- return OK(input2.data);
3141
- }
3142
- };
3143
- ZodAny.create = (params) => {
3144
- return new ZodAny({
3145
- typeName: ZodFirstPartyTypeKind.ZodAny,
3146
- ...processCreateParams(params)
3147
- });
3148
- };
3149
- var ZodUnknown = class extends ZodType {
3150
- constructor() {
3151
- super(...arguments);
3152
- this._unknown = true;
3153
- }
3154
- _parse(input2) {
3155
- return OK(input2.data);
3156
- }
3157
- };
3158
- ZodUnknown.create = (params) => {
3159
- return new ZodUnknown({
3160
- typeName: ZodFirstPartyTypeKind.ZodUnknown,
3161
- ...processCreateParams(params)
3162
- });
3163
- };
3164
- var ZodNever = class extends ZodType {
3165
- _parse(input2) {
3166
- const ctx = this._getOrReturnCtx(input2);
3167
- addIssueToContext(ctx, {
3168
- code: ZodIssueCode.invalid_type,
3169
- expected: ZodParsedType.never,
3170
- received: ctx.parsedType
3171
- });
3172
- return INVALID;
3173
- }
3174
- };
3175
- ZodNever.create = (params) => {
3176
- return new ZodNever({
3177
- typeName: ZodFirstPartyTypeKind.ZodNever,
3178
- ...processCreateParams(params)
3179
- });
3180
- };
3181
- var ZodVoid = class extends ZodType {
3182
- _parse(input2) {
3183
- const parsedType = this._getType(input2);
3184
- if (parsedType !== ZodParsedType.undefined) {
3185
- const ctx = this._getOrReturnCtx(input2);
3186
- addIssueToContext(ctx, {
3187
- code: ZodIssueCode.invalid_type,
3188
- expected: ZodParsedType.void,
3189
- received: ctx.parsedType
3190
- });
3191
- return INVALID;
3192
- }
3193
- return OK(input2.data);
3194
- }
3195
- };
3196
- ZodVoid.create = (params) => {
3197
- return new ZodVoid({
3198
- typeName: ZodFirstPartyTypeKind.ZodVoid,
3199
- ...processCreateParams(params)
3200
- });
3201
- };
3202
- var ZodArray = class _ZodArray extends ZodType {
3203
- _parse(input2) {
3204
- const { ctx, status } = this._processInputParams(input2);
3205
- const def = this._def;
3206
- if (ctx.parsedType !== ZodParsedType.array) {
3207
- addIssueToContext(ctx, {
3208
- code: ZodIssueCode.invalid_type,
3209
- expected: ZodParsedType.array,
3210
- received: ctx.parsedType
3211
- });
3212
- return INVALID;
3213
- }
3214
- if (def.exactLength !== null) {
3215
- const tooBig = ctx.data.length > def.exactLength.value;
3216
- const tooSmall = ctx.data.length < def.exactLength.value;
3217
- if (tooBig || tooSmall) {
3218
- addIssueToContext(ctx, {
3219
- code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
3220
- minimum: tooSmall ? def.exactLength.value : void 0,
3221
- maximum: tooBig ? def.exactLength.value : void 0,
3222
- type: "array",
3223
- inclusive: true,
3224
- exact: true,
3225
- message: def.exactLength.message
3226
- });
3227
- status.dirty();
3228
- }
3229
- }
3230
- if (def.minLength !== null) {
3231
- if (ctx.data.length < def.minLength.value) {
3232
- addIssueToContext(ctx, {
3233
- code: ZodIssueCode.too_small,
3234
- minimum: def.minLength.value,
3235
- type: "array",
3236
- inclusive: true,
3237
- exact: false,
3238
- message: def.minLength.message
3239
- });
3240
- status.dirty();
3241
- }
3242
- }
3243
- if (def.maxLength !== null) {
3244
- if (ctx.data.length > def.maxLength.value) {
3245
- addIssueToContext(ctx, {
3246
- code: ZodIssueCode.too_big,
3247
- maximum: def.maxLength.value,
3248
- type: "array",
3249
- inclusive: true,
3250
- exact: false,
3251
- message: def.maxLength.message
3252
- });
3253
- status.dirty();
3254
- }
3255
- }
3256
- if (ctx.common.async) {
3257
- return Promise.all([...ctx.data].map((item, i) => {
3258
- return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
3259
- })).then((result2) => {
3260
- return ParseStatus.mergeArray(status, result2);
3261
- });
3262
- }
3263
- const result = [...ctx.data].map((item, i) => {
3264
- return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
3265
- });
3266
- return ParseStatus.mergeArray(status, result);
3267
- }
3268
- get element() {
3269
- return this._def.type;
3270
- }
3271
- min(minLength, message) {
3272
- return new _ZodArray({
3273
- ...this._def,
3274
- minLength: { value: minLength, message: errorUtil.toString(message) }
3275
- });
3276
- }
3277
- max(maxLength, message) {
3278
- return new _ZodArray({
3279
- ...this._def,
3280
- maxLength: { value: maxLength, message: errorUtil.toString(message) }
3281
- });
3282
- }
3283
- length(len, message) {
3284
- return new _ZodArray({
3285
- ...this._def,
3286
- exactLength: { value: len, message: errorUtil.toString(message) }
3287
- });
3288
- }
3289
- nonempty(message) {
3290
- return this.min(1, message);
3291
- }
3292
- };
3293
- ZodArray.create = (schema, params) => {
3294
- return new ZodArray({
3295
- type: schema,
3296
- minLength: null,
3297
- maxLength: null,
3298
- exactLength: null,
3299
- typeName: ZodFirstPartyTypeKind.ZodArray,
3300
- ...processCreateParams(params)
3301
- });
3302
- };
3303
- function deepPartialify(schema) {
3304
- if (schema instanceof ZodObject) {
3305
- const newShape = {};
3306
- for (const key in schema.shape) {
3307
- const fieldSchema = schema.shape[key];
3308
- newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
3309
- }
3310
- return new ZodObject({
3311
- ...schema._def,
3312
- shape: () => newShape
3313
- });
3314
- } else if (schema instanceof ZodArray) {
3315
- return new ZodArray({
3316
- ...schema._def,
3317
- type: deepPartialify(schema.element)
3318
- });
3319
- } else if (schema instanceof ZodOptional) {
3320
- return ZodOptional.create(deepPartialify(schema.unwrap()));
3321
- } else if (schema instanceof ZodNullable) {
3322
- return ZodNullable.create(deepPartialify(schema.unwrap()));
3323
- } else if (schema instanceof ZodTuple) {
3324
- return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
3325
- } else {
3326
- return schema;
3327
- }
3328
- }
3329
- var ZodObject = class _ZodObject extends ZodType {
3330
- constructor() {
3331
- super(...arguments);
3332
- this._cached = null;
3333
- this.nonstrict = this.passthrough;
3334
- this.augment = this.extend;
3335
- }
3336
- _getCached() {
3337
- if (this._cached !== null)
3338
- return this._cached;
3339
- const shape = this._def.shape();
3340
- const keys = util.objectKeys(shape);
3341
- this._cached = { shape, keys };
3342
- return this._cached;
3343
- }
3344
- _parse(input2) {
3345
- const parsedType = this._getType(input2);
3346
- if (parsedType !== ZodParsedType.object) {
3347
- const ctx2 = this._getOrReturnCtx(input2);
3348
- addIssueToContext(ctx2, {
3349
- code: ZodIssueCode.invalid_type,
3350
- expected: ZodParsedType.object,
3351
- received: ctx2.parsedType
3352
- });
3353
- return INVALID;
3354
- }
3355
- const { status, ctx } = this._processInputParams(input2);
3356
- const { shape, keys: shapeKeys } = this._getCached();
3357
- const extraKeys = [];
3358
- if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
3359
- for (const key in ctx.data) {
3360
- if (!shapeKeys.includes(key)) {
3361
- extraKeys.push(key);
3362
- }
3363
- }
3364
- }
3365
- const pairs = [];
3366
- for (const key of shapeKeys) {
3367
- const keyValidator = shape[key];
3368
- const value = ctx.data[key];
3369
- pairs.push({
3370
- key: { status: "valid", value: key },
3371
- value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
3372
- alwaysSet: key in ctx.data
3373
- });
3374
- }
3375
- if (this._def.catchall instanceof ZodNever) {
3376
- const unknownKeys = this._def.unknownKeys;
3377
- if (unknownKeys === "passthrough") {
3378
- for (const key of extraKeys) {
3379
- pairs.push({
3380
- key: { status: "valid", value: key },
3381
- value: { status: "valid", value: ctx.data[key] }
3382
- });
3383
- }
3384
- } else if (unknownKeys === "strict") {
3385
- if (extraKeys.length > 0) {
3386
- addIssueToContext(ctx, {
3387
- code: ZodIssueCode.unrecognized_keys,
3388
- keys: extraKeys
3389
- });
3390
- status.dirty();
3391
- }
3392
- } else if (unknownKeys === "strip") {
3393
- } else {
3394
- throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
3395
- }
3396
- } else {
3397
- const catchall = this._def.catchall;
3398
- for (const key of extraKeys) {
3399
- const value = ctx.data[key];
3400
- pairs.push({
3401
- key: { status: "valid", value: key },
3402
- value: catchall._parse(
3403
- new ParseInputLazyPath(ctx, value, ctx.path, key)
3404
- //, ctx.child(key), value, getParsedType(value)
3405
- ),
3406
- alwaysSet: key in ctx.data
3407
- });
3408
- }
3409
- }
3410
- if (ctx.common.async) {
3411
- return Promise.resolve().then(async () => {
3412
- const syncPairs = [];
3413
- for (const pair of pairs) {
3414
- const key = await pair.key;
3415
- const value = await pair.value;
3416
- syncPairs.push({
3417
- key,
3418
- value,
3419
- alwaysSet: pair.alwaysSet
3420
- });
3421
- }
3422
- return syncPairs;
3423
- }).then((syncPairs) => {
3424
- return ParseStatus.mergeObjectSync(status, syncPairs);
3425
- });
3426
- } else {
3427
- return ParseStatus.mergeObjectSync(status, pairs);
3428
- }
3429
- }
3430
- get shape() {
3431
- return this._def.shape();
3432
- }
3433
- strict(message) {
3434
- errorUtil.errToObj;
3435
- return new _ZodObject({
3436
- ...this._def,
3437
- unknownKeys: "strict",
3438
- ...message !== void 0 ? {
3439
- errorMap: (issue, ctx) => {
3440
- const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
3441
- if (issue.code === "unrecognized_keys")
3442
- return {
3443
- message: errorUtil.errToObj(message).message ?? defaultError
3444
- };
3445
- return {
3446
- message: defaultError
3447
- };
3448
- }
3449
- } : {}
3450
- });
3451
- }
3452
- strip() {
3453
- return new _ZodObject({
3454
- ...this._def,
3455
- unknownKeys: "strip"
3456
- });
3457
- }
3458
- passthrough() {
3459
- return new _ZodObject({
3460
- ...this._def,
3461
- unknownKeys: "passthrough"
3462
- });
3463
- }
3464
- // const AugmentFactory =
3465
- // <Def extends ZodObjectDef>(def: Def) =>
3466
- // <Augmentation extends ZodRawShape>(
3467
- // augmentation: Augmentation
3468
- // ): ZodObject<
3469
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
3470
- // Def["unknownKeys"],
3471
- // Def["catchall"]
3472
- // > => {
3473
- // return new ZodObject({
3474
- // ...def,
3475
- // shape: () => ({
3476
- // ...def.shape(),
3477
- // ...augmentation,
3478
- // }),
3479
- // }) as any;
3480
- // };
3481
- extend(augmentation) {
3482
- return new _ZodObject({
3483
- ...this._def,
3484
- shape: () => ({
3485
- ...this._def.shape(),
3486
- ...augmentation
3487
- })
3488
- });
3489
- }
3490
- /**
3491
- * Prior to zod@1.0.12 there was a bug in the
3492
- * inferred type of merged objects. Please
3493
- * upgrade if you are experiencing issues.
3494
- */
3495
- merge(merging) {
3496
- const merged = new _ZodObject({
3497
- unknownKeys: merging._def.unknownKeys,
3498
- catchall: merging._def.catchall,
3499
- shape: () => ({
3500
- ...this._def.shape(),
3501
- ...merging._def.shape()
3502
- }),
3503
- typeName: ZodFirstPartyTypeKind.ZodObject
3504
- });
3505
- return merged;
3506
- }
3507
- // merge<
3508
- // Incoming extends AnyZodObject,
3509
- // Augmentation extends Incoming["shape"],
3510
- // NewOutput extends {
3511
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
3512
- // ? Augmentation[k]["_output"]
3513
- // : k extends keyof Output
3514
- // ? Output[k]
3515
- // : never;
3516
- // },
3517
- // NewInput extends {
3518
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
3519
- // ? Augmentation[k]["_input"]
3520
- // : k extends keyof Input
3521
- // ? Input[k]
3522
- // : never;
3523
- // }
3524
- // >(
3525
- // merging: Incoming
3526
- // ): ZodObject<
3527
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3528
- // Incoming["_def"]["unknownKeys"],
3529
- // Incoming["_def"]["catchall"],
3530
- // NewOutput,
3531
- // NewInput
3532
- // > {
3533
- // const merged: any = new ZodObject({
3534
- // unknownKeys: merging._def.unknownKeys,
3535
- // catchall: merging._def.catchall,
3536
- // shape: () =>
3537
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3538
- // typeName: ZodFirstPartyTypeKind.ZodObject,
3539
- // }) as any;
3540
- // return merged;
3541
- // }
3542
- setKey(key, schema) {
3543
- return this.augment({ [key]: schema });
3544
- }
3545
- // merge<Incoming extends AnyZodObject>(
3546
- // merging: Incoming
3547
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
3548
- // ZodObject<
3549
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3550
- // Incoming["_def"]["unknownKeys"],
3551
- // Incoming["_def"]["catchall"]
3552
- // > {
3553
- // // const mergedShape = objectUtil.mergeShapes(
3554
- // // this._def.shape(),
3555
- // // merging._def.shape()
3556
- // // );
3557
- // const merged: any = new ZodObject({
3558
- // unknownKeys: merging._def.unknownKeys,
3559
- // catchall: merging._def.catchall,
3560
- // shape: () =>
3561
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3562
- // typeName: ZodFirstPartyTypeKind.ZodObject,
3563
- // }) as any;
3564
- // return merged;
3565
- // }
3566
- catchall(index) {
3567
- return new _ZodObject({
3568
- ...this._def,
3569
- catchall: index
3570
- });
3571
- }
3572
- pick(mask) {
3573
- const shape = {};
3574
- for (const key of util.objectKeys(mask)) {
3575
- if (mask[key] && this.shape[key]) {
3576
- shape[key] = this.shape[key];
3577
- }
3578
- }
3579
- return new _ZodObject({
3580
- ...this._def,
3581
- shape: () => shape
3582
- });
3583
- }
3584
- omit(mask) {
3585
- const shape = {};
3586
- for (const key of util.objectKeys(this.shape)) {
3587
- if (!mask[key]) {
3588
- shape[key] = this.shape[key];
3589
- }
3590
- }
3591
- return new _ZodObject({
3592
- ...this._def,
3593
- shape: () => shape
3594
- });
3595
- }
3596
- /**
3597
- * @deprecated
3598
- */
3599
- deepPartial() {
3600
- return deepPartialify(this);
3601
- }
3602
- partial(mask) {
3603
- const newShape = {};
3604
- for (const key of util.objectKeys(this.shape)) {
3605
- const fieldSchema = this.shape[key];
3606
- if (mask && !mask[key]) {
3607
- newShape[key] = fieldSchema;
3608
- } else {
3609
- newShape[key] = fieldSchema.optional();
3610
- }
3611
- }
3612
- return new _ZodObject({
3613
- ...this._def,
3614
- shape: () => newShape
3615
- });
3616
- }
3617
- required(mask) {
3618
- const newShape = {};
3619
- for (const key of util.objectKeys(this.shape)) {
3620
- if (mask && !mask[key]) {
3621
- newShape[key] = this.shape[key];
3622
- } else {
3623
- const fieldSchema = this.shape[key];
3624
- let newField = fieldSchema;
3625
- while (newField instanceof ZodOptional) {
3626
- newField = newField._def.innerType;
3627
- }
3628
- newShape[key] = newField;
3629
- }
3630
- }
3631
- return new _ZodObject({
3632
- ...this._def,
3633
- shape: () => newShape
3634
- });
3635
- }
3636
- keyof() {
3637
- return createZodEnum(util.objectKeys(this.shape));
3638
- }
3639
- };
3640
- ZodObject.create = (shape, params) => {
3641
- return new ZodObject({
3642
- shape: () => shape,
3643
- unknownKeys: "strip",
3644
- catchall: ZodNever.create(),
3645
- typeName: ZodFirstPartyTypeKind.ZodObject,
3646
- ...processCreateParams(params)
3647
- });
3648
- };
3649
- ZodObject.strictCreate = (shape, params) => {
3650
- return new ZodObject({
3651
- shape: () => shape,
3652
- unknownKeys: "strict",
3653
- catchall: ZodNever.create(),
3654
- typeName: ZodFirstPartyTypeKind.ZodObject,
3655
- ...processCreateParams(params)
3656
- });
3657
- };
3658
- ZodObject.lazycreate = (shape, params) => {
3659
- return new ZodObject({
3660
- shape,
3661
- unknownKeys: "strip",
3662
- catchall: ZodNever.create(),
3663
- typeName: ZodFirstPartyTypeKind.ZodObject,
3664
- ...processCreateParams(params)
3665
- });
3666
- };
3667
- var ZodUnion = class extends ZodType {
3668
- _parse(input2) {
3669
- const { ctx } = this._processInputParams(input2);
3670
- const options = this._def.options;
3671
- function handleResults(results) {
3672
- for (const result of results) {
3673
- if (result.result.status === "valid") {
3674
- return result.result;
3675
- }
3676
- }
3677
- for (const result of results) {
3678
- if (result.result.status === "dirty") {
3679
- ctx.common.issues.push(...result.ctx.common.issues);
3680
- return result.result;
3681
- }
3682
- }
3683
- const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
3684
- addIssueToContext(ctx, {
3685
- code: ZodIssueCode.invalid_union,
3686
- unionErrors
3687
- });
3688
- return INVALID;
3689
- }
3690
- if (ctx.common.async) {
3691
- return Promise.all(options.map(async (option) => {
3692
- const childCtx = {
3693
- ...ctx,
3694
- common: {
3695
- ...ctx.common,
3696
- issues: []
3697
- },
3698
- parent: null
3699
- };
3700
- return {
3701
- result: await option._parseAsync({
3702
- data: ctx.data,
3703
- path: ctx.path,
3704
- parent: childCtx
3705
- }),
3706
- ctx: childCtx
3707
- };
3708
- })).then(handleResults);
3709
- } else {
3710
- let dirty = void 0;
3711
- const issues = [];
3712
- for (const option of options) {
3713
- const childCtx = {
3714
- ...ctx,
3715
- common: {
3716
- ...ctx.common,
3717
- issues: []
3718
- },
3719
- parent: null
3720
- };
3721
- const result = option._parseSync({
3722
- data: ctx.data,
3723
- path: ctx.path,
3724
- parent: childCtx
3725
- });
3726
- if (result.status === "valid") {
3727
- return result;
3728
- } else if (result.status === "dirty" && !dirty) {
3729
- dirty = { result, ctx: childCtx };
3730
- }
3731
- if (childCtx.common.issues.length) {
3732
- issues.push(childCtx.common.issues);
3733
- }
3734
- }
3735
- if (dirty) {
3736
- ctx.common.issues.push(...dirty.ctx.common.issues);
3737
- return dirty.result;
3738
- }
3739
- const unionErrors = issues.map((issues2) => new ZodError(issues2));
3740
- addIssueToContext(ctx, {
3741
- code: ZodIssueCode.invalid_union,
3742
- unionErrors
3743
- });
3744
- return INVALID;
3745
- }
3746
- }
3747
- get options() {
3748
- return this._def.options;
3749
- }
3750
- };
3751
- ZodUnion.create = (types, params) => {
3752
- return new ZodUnion({
3753
- options: types,
3754
- typeName: ZodFirstPartyTypeKind.ZodUnion,
3755
- ...processCreateParams(params)
3756
- });
3757
- };
3758
- var getDiscriminator = (type) => {
3759
- if (type instanceof ZodLazy) {
3760
- return getDiscriminator(type.schema);
3761
- } else if (type instanceof ZodEffects) {
3762
- return getDiscriminator(type.innerType());
3763
- } else if (type instanceof ZodLiteral) {
3764
- return [type.value];
3765
- } else if (type instanceof ZodEnum) {
3766
- return type.options;
3767
- } else if (type instanceof ZodNativeEnum) {
3768
- return util.objectValues(type.enum);
3769
- } else if (type instanceof ZodDefault) {
3770
- return getDiscriminator(type._def.innerType);
3771
- } else if (type instanceof ZodUndefined) {
3772
- return [void 0];
3773
- } else if (type instanceof ZodNull) {
3774
- return [null];
3775
- } else if (type instanceof ZodOptional) {
3776
- return [void 0, ...getDiscriminator(type.unwrap())];
3777
- } else if (type instanceof ZodNullable) {
3778
- return [null, ...getDiscriminator(type.unwrap())];
3779
- } else if (type instanceof ZodBranded) {
3780
- return getDiscriminator(type.unwrap());
3781
- } else if (type instanceof ZodReadonly) {
3782
- return getDiscriminator(type.unwrap());
3783
- } else if (type instanceof ZodCatch) {
3784
- return getDiscriminator(type._def.innerType);
3785
- } else {
3786
- return [];
3787
- }
3788
- };
3789
- var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
3790
- _parse(input2) {
3791
- const { ctx } = this._processInputParams(input2);
3792
- if (ctx.parsedType !== ZodParsedType.object) {
3793
- addIssueToContext(ctx, {
3794
- code: ZodIssueCode.invalid_type,
3795
- expected: ZodParsedType.object,
3796
- received: ctx.parsedType
3797
- });
3798
- return INVALID;
3799
- }
3800
- const discriminator = this.discriminator;
3801
- const discriminatorValue = ctx.data[discriminator];
3802
- const option = this.optionsMap.get(discriminatorValue);
3803
- if (!option) {
3804
- addIssueToContext(ctx, {
3805
- code: ZodIssueCode.invalid_union_discriminator,
3806
- options: Array.from(this.optionsMap.keys()),
3807
- path: [discriminator]
3808
- });
3809
- return INVALID;
3810
- }
3811
- if (ctx.common.async) {
3812
- return option._parseAsync({
3813
- data: ctx.data,
3814
- path: ctx.path,
3815
- parent: ctx
3816
- });
3817
- } else {
3818
- return option._parseSync({
3819
- data: ctx.data,
3820
- path: ctx.path,
3821
- parent: ctx
3822
- });
3823
- }
3824
- }
3825
- get discriminator() {
3826
- return this._def.discriminator;
3827
- }
3828
- get options() {
3829
- return this._def.options;
3830
- }
3831
- get optionsMap() {
3832
- return this._def.optionsMap;
3833
- }
3834
- /**
3835
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3836
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3837
- * have a different value for each object in the union.
3838
- * @param discriminator the name of the discriminator property
3839
- * @param types an array of object schemas
3840
- * @param params
3841
- */
3842
- static create(discriminator, options, params) {
3843
- const optionsMap = /* @__PURE__ */ new Map();
3844
- for (const type of options) {
3845
- const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3846
- if (!discriminatorValues.length) {
3847
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3848
- }
3849
- for (const value of discriminatorValues) {
3850
- if (optionsMap.has(value)) {
3851
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3852
- }
3853
- optionsMap.set(value, type);
3854
- }
3855
- }
3856
- return new _ZodDiscriminatedUnion({
3857
- typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3858
- discriminator,
3859
- options,
3860
- optionsMap,
3861
- ...processCreateParams(params)
3862
- });
3863
- }
3864
- };
3865
- function mergeValues(a, b) {
3866
- const aType = getParsedType(a);
3867
- const bType = getParsedType(b);
3868
- if (a === b) {
3869
- return { valid: true, data: a };
3870
- } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
3871
- const bKeys = util.objectKeys(b);
3872
- const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
3873
- const newObj = { ...a, ...b };
3874
- for (const key of sharedKeys) {
3875
- const sharedValue = mergeValues(a[key], b[key]);
3876
- if (!sharedValue.valid) {
3877
- return { valid: false };
3878
- }
3879
- newObj[key] = sharedValue.data;
3880
- }
3881
- return { valid: true, data: newObj };
3882
- } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
3883
- if (a.length !== b.length) {
3884
- return { valid: false };
3885
- }
3886
- const newArray = [];
3887
- for (let index = 0; index < a.length; index++) {
3888
- const itemA = a[index];
3889
- const itemB = b[index];
3890
- const sharedValue = mergeValues(itemA, itemB);
3891
- if (!sharedValue.valid) {
3892
- return { valid: false };
3893
- }
3894
- newArray.push(sharedValue.data);
3895
- }
3896
- return { valid: true, data: newArray };
3897
- } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
3898
- return { valid: true, data: a };
3899
- } else {
3900
- return { valid: false };
3901
- }
3902
- }
3903
- var ZodIntersection = class extends ZodType {
3904
- _parse(input2) {
3905
- const { status, ctx } = this._processInputParams(input2);
3906
- const handleParsed = (parsedLeft, parsedRight) => {
3907
- if (isAborted(parsedLeft) || isAborted(parsedRight)) {
3908
- return INVALID;
3909
- }
3910
- const merged = mergeValues(parsedLeft.value, parsedRight.value);
3911
- if (!merged.valid) {
3912
- addIssueToContext(ctx, {
3913
- code: ZodIssueCode.invalid_intersection_types
3914
- });
3915
- return INVALID;
3916
- }
3917
- if (isDirty(parsedLeft) || isDirty(parsedRight)) {
3918
- status.dirty();
3919
- }
3920
- return { status: status.value, value: merged.data };
3921
- };
3922
- if (ctx.common.async) {
3923
- return Promise.all([
3924
- this._def.left._parseAsync({
3925
- data: ctx.data,
3926
- path: ctx.path,
3927
- parent: ctx
3928
- }),
3929
- this._def.right._parseAsync({
3930
- data: ctx.data,
3931
- path: ctx.path,
3932
- parent: ctx
3933
- })
3934
- ]).then(([left, right]) => handleParsed(left, right));
3935
- } else {
3936
- return handleParsed(this._def.left._parseSync({
3937
- data: ctx.data,
3938
- path: ctx.path,
3939
- parent: ctx
3940
- }), this._def.right._parseSync({
3941
- data: ctx.data,
3942
- path: ctx.path,
3943
- parent: ctx
3944
- }));
3945
- }
3946
- }
3947
- };
3948
- ZodIntersection.create = (left, right, params) => {
3949
- return new ZodIntersection({
3950
- left,
3951
- right,
3952
- typeName: ZodFirstPartyTypeKind.ZodIntersection,
3953
- ...processCreateParams(params)
3954
- });
3955
- };
3956
- var ZodTuple = class _ZodTuple extends ZodType {
3957
- _parse(input2) {
3958
- const { status, ctx } = this._processInputParams(input2);
3959
- if (ctx.parsedType !== ZodParsedType.array) {
3960
- addIssueToContext(ctx, {
3961
- code: ZodIssueCode.invalid_type,
3962
- expected: ZodParsedType.array,
3963
- received: ctx.parsedType
3964
- });
3965
- return INVALID;
3966
- }
3967
- if (ctx.data.length < this._def.items.length) {
3968
- addIssueToContext(ctx, {
3969
- code: ZodIssueCode.too_small,
3970
- minimum: this._def.items.length,
3971
- inclusive: true,
3972
- exact: false,
3973
- type: "array"
3974
- });
3975
- return INVALID;
3976
- }
3977
- const rest = this._def.rest;
3978
- if (!rest && ctx.data.length > this._def.items.length) {
3979
- addIssueToContext(ctx, {
3980
- code: ZodIssueCode.too_big,
3981
- maximum: this._def.items.length,
3982
- inclusive: true,
3983
- exact: false,
3984
- type: "array"
3985
- });
3986
- status.dirty();
3987
- }
3988
- const items = [...ctx.data].map((item, itemIndex) => {
3989
- const schema = this._def.items[itemIndex] || this._def.rest;
3990
- if (!schema)
3991
- return null;
3992
- return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3993
- }).filter((x) => !!x);
3994
- if (ctx.common.async) {
3995
- return Promise.all(items).then((results) => {
3996
- return ParseStatus.mergeArray(status, results);
3997
- });
3998
- } else {
3999
- return ParseStatus.mergeArray(status, items);
4000
- }
4001
- }
4002
- get items() {
4003
- return this._def.items;
4004
- }
4005
- rest(rest) {
4006
- return new _ZodTuple({
4007
- ...this._def,
4008
- rest
4009
- });
4010
- }
4011
- };
4012
- ZodTuple.create = (schemas, params) => {
4013
- if (!Array.isArray(schemas)) {
4014
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
4015
- }
4016
- return new ZodTuple({
4017
- items: schemas,
4018
- typeName: ZodFirstPartyTypeKind.ZodTuple,
4019
- rest: null,
4020
- ...processCreateParams(params)
4021
- });
4022
- };
4023
- var ZodRecord = class _ZodRecord extends ZodType {
4024
- get keySchema() {
4025
- return this._def.keyType;
4026
- }
4027
- get valueSchema() {
4028
- return this._def.valueType;
4029
- }
4030
- _parse(input2) {
4031
- const { status, ctx } = this._processInputParams(input2);
4032
- if (ctx.parsedType !== ZodParsedType.object) {
4033
- addIssueToContext(ctx, {
4034
- code: ZodIssueCode.invalid_type,
4035
- expected: ZodParsedType.object,
4036
- received: ctx.parsedType
4037
- });
4038
- return INVALID;
4039
- }
4040
- const pairs = [];
4041
- const keyType = this._def.keyType;
4042
- const valueType = this._def.valueType;
4043
- for (const key in ctx.data) {
4044
- pairs.push({
4045
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
4046
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
4047
- alwaysSet: key in ctx.data
4048
- });
4049
- }
4050
- if (ctx.common.async) {
4051
- return ParseStatus.mergeObjectAsync(status, pairs);
4052
- } else {
4053
- return ParseStatus.mergeObjectSync(status, pairs);
4054
- }
4055
- }
4056
- get element() {
4057
- return this._def.valueType;
4058
- }
4059
- static create(first, second, third) {
4060
- if (second instanceof ZodType) {
4061
- return new _ZodRecord({
4062
- keyType: first,
4063
- valueType: second,
4064
- typeName: ZodFirstPartyTypeKind.ZodRecord,
4065
- ...processCreateParams(third)
4066
- });
4067
- }
4068
- return new _ZodRecord({
4069
- keyType: ZodString.create(),
4070
- valueType: first,
4071
- typeName: ZodFirstPartyTypeKind.ZodRecord,
4072
- ...processCreateParams(second)
4073
- });
4074
- }
4075
- };
4076
- var ZodMap = class extends ZodType {
4077
- get keySchema() {
4078
- return this._def.keyType;
4079
- }
4080
- get valueSchema() {
4081
- return this._def.valueType;
4082
- }
4083
- _parse(input2) {
4084
- const { status, ctx } = this._processInputParams(input2);
4085
- if (ctx.parsedType !== ZodParsedType.map) {
4086
- addIssueToContext(ctx, {
4087
- code: ZodIssueCode.invalid_type,
4088
- expected: ZodParsedType.map,
4089
- received: ctx.parsedType
4090
- });
4091
- return INVALID;
4092
- }
4093
- const keyType = this._def.keyType;
4094
- const valueType = this._def.valueType;
4095
- const pairs = [...ctx.data.entries()].map(([key, value], index) => {
4096
- return {
4097
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
4098
- value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
4099
- };
4100
- });
4101
- if (ctx.common.async) {
4102
- const finalMap = /* @__PURE__ */ new Map();
4103
- return Promise.resolve().then(async () => {
4104
- for (const pair of pairs) {
4105
- const key = await pair.key;
4106
- const value = await pair.value;
4107
- if (key.status === "aborted" || value.status === "aborted") {
4108
- return INVALID;
4109
- }
4110
- if (key.status === "dirty" || value.status === "dirty") {
4111
- status.dirty();
4112
- }
4113
- finalMap.set(key.value, value.value);
4114
- }
4115
- return { status: status.value, value: finalMap };
4116
- });
4117
- } else {
4118
- const finalMap = /* @__PURE__ */ new Map();
4119
- for (const pair of pairs) {
4120
- const key = pair.key;
4121
- const value = pair.value;
4122
- if (key.status === "aborted" || value.status === "aborted") {
4123
- return INVALID;
4124
- }
4125
- if (key.status === "dirty" || value.status === "dirty") {
4126
- status.dirty();
4127
- }
4128
- finalMap.set(key.value, value.value);
4129
- }
4130
- return { status: status.value, value: finalMap };
4131
- }
4132
- }
4133
- };
4134
- ZodMap.create = (keyType, valueType, params) => {
4135
- return new ZodMap({
4136
- valueType,
4137
- keyType,
4138
- typeName: ZodFirstPartyTypeKind.ZodMap,
4139
- ...processCreateParams(params)
4140
- });
4141
- };
4142
- var ZodSet = class _ZodSet extends ZodType {
4143
- _parse(input2) {
4144
- const { status, ctx } = this._processInputParams(input2);
4145
- if (ctx.parsedType !== ZodParsedType.set) {
4146
- addIssueToContext(ctx, {
4147
- code: ZodIssueCode.invalid_type,
4148
- expected: ZodParsedType.set,
4149
- received: ctx.parsedType
4150
- });
4151
- return INVALID;
4152
- }
4153
- const def = this._def;
4154
- if (def.minSize !== null) {
4155
- if (ctx.data.size < def.minSize.value) {
4156
- addIssueToContext(ctx, {
4157
- code: ZodIssueCode.too_small,
4158
- minimum: def.minSize.value,
4159
- type: "set",
4160
- inclusive: true,
4161
- exact: false,
4162
- message: def.minSize.message
4163
- });
4164
- status.dirty();
4165
- }
4166
- }
4167
- if (def.maxSize !== null) {
4168
- if (ctx.data.size > def.maxSize.value) {
4169
- addIssueToContext(ctx, {
4170
- code: ZodIssueCode.too_big,
4171
- maximum: def.maxSize.value,
4172
- type: "set",
4173
- inclusive: true,
4174
- exact: false,
4175
- message: def.maxSize.message
4176
- });
4177
- status.dirty();
4178
- }
4179
- }
4180
- const valueType = this._def.valueType;
4181
- function finalizeSet(elements2) {
4182
- const parsedSet = /* @__PURE__ */ new Set();
4183
- for (const element of elements2) {
4184
- if (element.status === "aborted")
4185
- return INVALID;
4186
- if (element.status === "dirty")
4187
- status.dirty();
4188
- parsedSet.add(element.value);
4189
- }
4190
- return { status: status.value, value: parsedSet };
4191
- }
4192
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
4193
- if (ctx.common.async) {
4194
- return Promise.all(elements).then((elements2) => finalizeSet(elements2));
4195
- } else {
4196
- return finalizeSet(elements);
4197
- }
4198
- }
4199
- min(minSize, message) {
4200
- return new _ZodSet({
4201
- ...this._def,
4202
- minSize: { value: minSize, message: errorUtil.toString(message) }
4203
- });
4204
- }
4205
- max(maxSize, message) {
4206
- return new _ZodSet({
4207
- ...this._def,
4208
- maxSize: { value: maxSize, message: errorUtil.toString(message) }
4209
- });
4210
- }
4211
- size(size, message) {
4212
- return this.min(size, message).max(size, message);
4213
- }
4214
- nonempty(message) {
4215
- return this.min(1, message);
4216
- }
4217
- };
4218
- ZodSet.create = (valueType, params) => {
4219
- return new ZodSet({
4220
- valueType,
4221
- minSize: null,
4222
- maxSize: null,
4223
- typeName: ZodFirstPartyTypeKind.ZodSet,
4224
- ...processCreateParams(params)
4225
- });
4226
- };
4227
- var ZodFunction = class _ZodFunction extends ZodType {
4228
- constructor() {
4229
- super(...arguments);
4230
- this.validate = this.implement;
4231
- }
4232
- _parse(input2) {
4233
- const { ctx } = this._processInputParams(input2);
4234
- if (ctx.parsedType !== ZodParsedType.function) {
4235
- addIssueToContext(ctx, {
4236
- code: ZodIssueCode.invalid_type,
4237
- expected: ZodParsedType.function,
4238
- received: ctx.parsedType
4239
- });
4240
- return INVALID;
4241
- }
4242
- function makeArgsIssue(args, error) {
4243
- return makeIssue({
4244
- data: args,
4245
- path: ctx.path,
4246
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
4247
- issueData: {
4248
- code: ZodIssueCode.invalid_arguments,
4249
- argumentsError: error
4250
- }
4251
- });
4252
- }
4253
- function makeReturnsIssue(returns, error) {
4254
- return makeIssue({
4255
- data: returns,
4256
- path: ctx.path,
4257
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
4258
- issueData: {
4259
- code: ZodIssueCode.invalid_return_type,
4260
- returnTypeError: error
4261
- }
4262
- });
4263
- }
4264
- const params = { errorMap: ctx.common.contextualErrorMap };
4265
- const fn = ctx.data;
4266
- if (this._def.returns instanceof ZodPromise) {
4267
- const me = this;
4268
- return OK(async function(...args) {
4269
- const error = new ZodError([]);
4270
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
4271
- error.addIssue(makeArgsIssue(args, e));
4272
- throw error;
4273
- });
4274
- const result = await Reflect.apply(fn, this, parsedArgs);
4275
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
4276
- error.addIssue(makeReturnsIssue(result, e));
4277
- throw error;
4278
- });
4279
- return parsedReturns;
4280
- });
4281
- } else {
4282
- const me = this;
4283
- return OK(function(...args) {
4284
- const parsedArgs = me._def.args.safeParse(args, params);
4285
- if (!parsedArgs.success) {
4286
- throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
4287
- }
4288
- const result = Reflect.apply(fn, this, parsedArgs.data);
4289
- const parsedReturns = me._def.returns.safeParse(result, params);
4290
- if (!parsedReturns.success) {
4291
- throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
4292
- }
4293
- return parsedReturns.data;
4294
- });
4295
- }
4296
- }
4297
- parameters() {
4298
- return this._def.args;
4299
- }
4300
- returnType() {
4301
- return this._def.returns;
4302
- }
4303
- args(...items) {
4304
- return new _ZodFunction({
4305
- ...this._def,
4306
- args: ZodTuple.create(items).rest(ZodUnknown.create())
4307
- });
4308
- }
4309
- returns(returnType) {
4310
- return new _ZodFunction({
4311
- ...this._def,
4312
- returns: returnType
4313
- });
4314
- }
4315
- implement(func) {
4316
- const validatedFunc = this.parse(func);
4317
- return validatedFunc;
4318
- }
4319
- strictImplement(func) {
4320
- const validatedFunc = this.parse(func);
4321
- return validatedFunc;
4322
- }
4323
- static create(args, returns, params) {
4324
- return new _ZodFunction({
4325
- args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
4326
- returns: returns || ZodUnknown.create(),
4327
- typeName: ZodFirstPartyTypeKind.ZodFunction,
4328
- ...processCreateParams(params)
4329
- });
4330
- }
4331
- };
4332
- var ZodLazy = class extends ZodType {
4333
- get schema() {
4334
- return this._def.getter();
4335
- }
4336
- _parse(input2) {
4337
- const { ctx } = this._processInputParams(input2);
4338
- const lazySchema = this._def.getter();
4339
- return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
4340
- }
4341
- };
4342
- ZodLazy.create = (getter, params) => {
4343
- return new ZodLazy({
4344
- getter,
4345
- typeName: ZodFirstPartyTypeKind.ZodLazy,
4346
- ...processCreateParams(params)
4347
- });
4348
- };
4349
- var ZodLiteral = class extends ZodType {
4350
- _parse(input2) {
4351
- if (input2.data !== this._def.value) {
4352
- const ctx = this._getOrReturnCtx(input2);
4353
- addIssueToContext(ctx, {
4354
- received: ctx.data,
4355
- code: ZodIssueCode.invalid_literal,
4356
- expected: this._def.value
4357
- });
4358
- return INVALID;
4359
- }
4360
- return { status: "valid", value: input2.data };
4361
- }
4362
- get value() {
4363
- return this._def.value;
4364
- }
4365
- };
4366
- ZodLiteral.create = (value, params) => {
4367
- return new ZodLiteral({
4368
- value,
4369
- typeName: ZodFirstPartyTypeKind.ZodLiteral,
4370
- ...processCreateParams(params)
4371
- });
4372
- };
4373
- function createZodEnum(values, params) {
4374
- return new ZodEnum({
4375
- values,
4376
- typeName: ZodFirstPartyTypeKind.ZodEnum,
4377
- ...processCreateParams(params)
4378
- });
4379
- }
4380
- var ZodEnum = class _ZodEnum extends ZodType {
4381
- _parse(input2) {
4382
- if (typeof input2.data !== "string") {
4383
- const ctx = this._getOrReturnCtx(input2);
4384
- const expectedValues = this._def.values;
4385
- addIssueToContext(ctx, {
4386
- expected: util.joinValues(expectedValues),
4387
- received: ctx.parsedType,
4388
- code: ZodIssueCode.invalid_type
4389
- });
4390
- return INVALID;
4391
- }
4392
- if (!this._cache) {
4393
- this._cache = new Set(this._def.values);
4394
- }
4395
- if (!this._cache.has(input2.data)) {
4396
- const ctx = this._getOrReturnCtx(input2);
4397
- const expectedValues = this._def.values;
4398
- addIssueToContext(ctx, {
4399
- received: ctx.data,
4400
- code: ZodIssueCode.invalid_enum_value,
4401
- options: expectedValues
4402
- });
4403
- return INVALID;
4404
- }
4405
- return OK(input2.data);
4406
- }
4407
- get options() {
4408
- return this._def.values;
4409
- }
4410
- get enum() {
4411
- const enumValues = {};
4412
- for (const val of this._def.values) {
4413
- enumValues[val] = val;
4414
- }
4415
- return enumValues;
4416
- }
4417
- get Values() {
4418
- const enumValues = {};
4419
- for (const val of this._def.values) {
4420
- enumValues[val] = val;
4421
- }
4422
- return enumValues;
4423
- }
4424
- get Enum() {
4425
- const enumValues = {};
4426
- for (const val of this._def.values) {
4427
- enumValues[val] = val;
4428
- }
4429
- return enumValues;
4430
- }
4431
- extract(values, newDef = this._def) {
4432
- return _ZodEnum.create(values, {
4433
- ...this._def,
4434
- ...newDef
4435
- });
4436
- }
4437
- exclude(values, newDef = this._def) {
4438
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
4439
- ...this._def,
4440
- ...newDef
4441
- });
4442
- }
4443
- };
4444
- ZodEnum.create = createZodEnum;
4445
- var ZodNativeEnum = class extends ZodType {
4446
- _parse(input2) {
4447
- const nativeEnumValues = util.getValidEnumValues(this._def.values);
4448
- const ctx = this._getOrReturnCtx(input2);
4449
- if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
4450
- const expectedValues = util.objectValues(nativeEnumValues);
4451
- addIssueToContext(ctx, {
4452
- expected: util.joinValues(expectedValues),
4453
- received: ctx.parsedType,
4454
- code: ZodIssueCode.invalid_type
4455
- });
4456
- return INVALID;
4457
- }
4458
- if (!this._cache) {
4459
- this._cache = new Set(util.getValidEnumValues(this._def.values));
4460
- }
4461
- if (!this._cache.has(input2.data)) {
4462
- const expectedValues = util.objectValues(nativeEnumValues);
4463
- addIssueToContext(ctx, {
4464
- received: ctx.data,
4465
- code: ZodIssueCode.invalid_enum_value,
4466
- options: expectedValues
4467
- });
4468
- return INVALID;
4469
- }
4470
- return OK(input2.data);
4471
- }
4472
- get enum() {
4473
- return this._def.values;
4474
- }
4475
- };
4476
- ZodNativeEnum.create = (values, params) => {
4477
- return new ZodNativeEnum({
4478
- values,
4479
- typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
4480
- ...processCreateParams(params)
4481
- });
4482
- };
4483
- var ZodPromise = class extends ZodType {
4484
- unwrap() {
4485
- return this._def.type;
4486
- }
4487
- _parse(input2) {
4488
- const { ctx } = this._processInputParams(input2);
4489
- if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
4490
- addIssueToContext(ctx, {
4491
- code: ZodIssueCode.invalid_type,
4492
- expected: ZodParsedType.promise,
4493
- received: ctx.parsedType
4494
- });
4495
- return INVALID;
4496
- }
4497
- const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
4498
- return OK(promisified.then((data) => {
4499
- return this._def.type.parseAsync(data, {
4500
- path: ctx.path,
4501
- errorMap: ctx.common.contextualErrorMap
4502
- });
4503
- }));
4504
- }
4505
- };
4506
- ZodPromise.create = (schema, params) => {
4507
- return new ZodPromise({
4508
- type: schema,
4509
- typeName: ZodFirstPartyTypeKind.ZodPromise,
4510
- ...processCreateParams(params)
4511
- });
4512
- };
4513
- var ZodEffects = class extends ZodType {
4514
- innerType() {
4515
- return this._def.schema;
4516
- }
4517
- sourceType() {
4518
- return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
4519
- }
4520
- _parse(input2) {
4521
- const { status, ctx } = this._processInputParams(input2);
4522
- const effect = this._def.effect || null;
4523
- const checkCtx = {
4524
- addIssue: (arg) => {
4525
- addIssueToContext(ctx, arg);
4526
- if (arg.fatal) {
4527
- status.abort();
4528
- } else {
4529
- status.dirty();
4530
- }
4531
- },
4532
- get path() {
4533
- return ctx.path;
4534
- }
4535
- };
4536
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4537
- if (effect.type === "preprocess") {
4538
- const processed = effect.transform(ctx.data, checkCtx);
4539
- if (ctx.common.async) {
4540
- return Promise.resolve(processed).then(async (processed2) => {
4541
- if (status.value === "aborted")
4542
- return INVALID;
4543
- const result = await this._def.schema._parseAsync({
4544
- data: processed2,
4545
- path: ctx.path,
4546
- parent: ctx
4547
- });
4548
- if (result.status === "aborted")
4549
- return INVALID;
4550
- if (result.status === "dirty")
4551
- return DIRTY(result.value);
4552
- if (status.value === "dirty")
4553
- return DIRTY(result.value);
4554
- return result;
4555
- });
4556
- } else {
4557
- if (status.value === "aborted")
4558
- return INVALID;
4559
- const result = this._def.schema._parseSync({
4560
- data: processed,
4561
- path: ctx.path,
4562
- parent: ctx
4563
- });
4564
- if (result.status === "aborted")
4565
- return INVALID;
4566
- if (result.status === "dirty")
4567
- return DIRTY(result.value);
4568
- if (status.value === "dirty")
4569
- return DIRTY(result.value);
4570
- return result;
4571
- }
4572
- }
4573
- if (effect.type === "refinement") {
4574
- const executeRefinement = (acc) => {
4575
- const result = effect.refinement(acc, checkCtx);
4576
- if (ctx.common.async) {
4577
- return Promise.resolve(result);
4578
- }
4579
- if (result instanceof Promise) {
4580
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
4581
- }
4582
- return acc;
4583
- };
4584
- if (ctx.common.async === false) {
4585
- const inner = this._def.schema._parseSync({
4586
- data: ctx.data,
4587
- path: ctx.path,
4588
- parent: ctx
4589
- });
4590
- if (inner.status === "aborted")
4591
- return INVALID;
4592
- if (inner.status === "dirty")
4593
- status.dirty();
4594
- executeRefinement(inner.value);
4595
- return { status: status.value, value: inner.value };
4596
- } else {
4597
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
4598
- if (inner.status === "aborted")
4599
- return INVALID;
4600
- if (inner.status === "dirty")
4601
- status.dirty();
4602
- return executeRefinement(inner.value).then(() => {
4603
- return { status: status.value, value: inner.value };
4604
- });
4605
- });
4606
- }
4607
- }
4608
- if (effect.type === "transform") {
4609
- if (ctx.common.async === false) {
4610
- const base = this._def.schema._parseSync({
4611
- data: ctx.data,
4612
- path: ctx.path,
4613
- parent: ctx
4614
- });
4615
- if (!isValid(base))
4616
- return INVALID;
4617
- const result = effect.transform(base.value, checkCtx);
4618
- if (result instanceof Promise) {
4619
- throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
4620
- }
4621
- return { status: status.value, value: result };
4622
- } else {
4623
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
4624
- if (!isValid(base))
4625
- return INVALID;
4626
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
4627
- status: status.value,
4628
- value: result
4629
- }));
4630
- });
4631
- }
4632
- }
4633
- util.assertNever(effect);
4634
- }
4635
- };
4636
- ZodEffects.create = (schema, effect, params) => {
4637
- return new ZodEffects({
4638
- schema,
4639
- typeName: ZodFirstPartyTypeKind.ZodEffects,
4640
- effect,
4641
- ...processCreateParams(params)
4642
- });
4643
- };
4644
- ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
4645
- return new ZodEffects({
4646
- schema,
4647
- effect: { type: "preprocess", transform: preprocess },
4648
- typeName: ZodFirstPartyTypeKind.ZodEffects,
4649
- ...processCreateParams(params)
4650
- });
4651
- };
4652
- var ZodOptional = class extends ZodType {
4653
- _parse(input2) {
4654
- const parsedType = this._getType(input2);
4655
- if (parsedType === ZodParsedType.undefined) {
4656
- return OK(void 0);
4657
- }
4658
- return this._def.innerType._parse(input2);
4659
- }
4660
- unwrap() {
4661
- return this._def.innerType;
4662
- }
4663
- };
4664
- ZodOptional.create = (type, params) => {
4665
- return new ZodOptional({
4666
- innerType: type,
4667
- typeName: ZodFirstPartyTypeKind.ZodOptional,
4668
- ...processCreateParams(params)
4669
- });
4670
- };
4671
- var ZodNullable = class extends ZodType {
4672
- _parse(input2) {
4673
- const parsedType = this._getType(input2);
4674
- if (parsedType === ZodParsedType.null) {
4675
- return OK(null);
4676
- }
4677
- return this._def.innerType._parse(input2);
4678
- }
4679
- unwrap() {
4680
- return this._def.innerType;
4681
- }
4682
- };
4683
- ZodNullable.create = (type, params) => {
4684
- return new ZodNullable({
4685
- innerType: type,
4686
- typeName: ZodFirstPartyTypeKind.ZodNullable,
4687
- ...processCreateParams(params)
4688
- });
4689
- };
4690
- var ZodDefault = class extends ZodType {
4691
- _parse(input2) {
4692
- const { ctx } = this._processInputParams(input2);
4693
- let data = ctx.data;
4694
- if (ctx.parsedType === ZodParsedType.undefined) {
4695
- data = this._def.defaultValue();
4696
- }
4697
- return this._def.innerType._parse({
4698
- data,
4699
- path: ctx.path,
4700
- parent: ctx
4701
- });
4702
- }
4703
- removeDefault() {
4704
- return this._def.innerType;
4705
- }
4706
- };
4707
- ZodDefault.create = (type, params) => {
4708
- return new ZodDefault({
4709
- innerType: type,
4710
- typeName: ZodFirstPartyTypeKind.ZodDefault,
4711
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4712
- ...processCreateParams(params)
4713
- });
4714
- };
4715
- var ZodCatch = class extends ZodType {
4716
- _parse(input2) {
4717
- const { ctx } = this._processInputParams(input2);
4718
- const newCtx = {
4719
- ...ctx,
4720
- common: {
4721
- ...ctx.common,
4722
- issues: []
4723
- }
4724
- };
4725
- const result = this._def.innerType._parse({
4726
- data: newCtx.data,
4727
- path: newCtx.path,
4728
- parent: {
4729
- ...newCtx
4730
- }
4731
- });
4732
- if (isAsync(result)) {
4733
- return result.then((result2) => {
4734
- return {
4735
- status: "valid",
4736
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
4737
- get error() {
4738
- return new ZodError(newCtx.common.issues);
4739
- },
4740
- input: newCtx.data
4741
- })
4742
- };
4743
- });
4744
- } else {
4745
- return {
4746
- status: "valid",
4747
- value: result.status === "valid" ? result.value : this._def.catchValue({
4748
- get error() {
4749
- return new ZodError(newCtx.common.issues);
4750
- },
4751
- input: newCtx.data
4752
- })
4753
- };
4754
- }
4755
- }
4756
- removeCatch() {
4757
- return this._def.innerType;
4758
- }
4759
- };
4760
- ZodCatch.create = (type, params) => {
4761
- return new ZodCatch({
4762
- innerType: type,
4763
- typeName: ZodFirstPartyTypeKind.ZodCatch,
4764
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4765
- ...processCreateParams(params)
4766
- });
4767
- };
4768
- var ZodNaN = class extends ZodType {
4769
- _parse(input2) {
4770
- const parsedType = this._getType(input2);
4771
- if (parsedType !== ZodParsedType.nan) {
4772
- const ctx = this._getOrReturnCtx(input2);
4773
- addIssueToContext(ctx, {
4774
- code: ZodIssueCode.invalid_type,
4775
- expected: ZodParsedType.nan,
4776
- received: ctx.parsedType
4777
- });
4778
- return INVALID;
4779
- }
4780
- return { status: "valid", value: input2.data };
4781
- }
4782
- };
4783
- ZodNaN.create = (params) => {
4784
- return new ZodNaN({
4785
- typeName: ZodFirstPartyTypeKind.ZodNaN,
4786
- ...processCreateParams(params)
4787
- });
4788
- };
4789
- var BRAND = /* @__PURE__ */ Symbol("zod_brand");
4790
- var ZodBranded = class extends ZodType {
4791
- _parse(input2) {
4792
- const { ctx } = this._processInputParams(input2);
4793
- const data = ctx.data;
4794
- return this._def.type._parse({
4795
- data,
4796
- path: ctx.path,
4797
- parent: ctx
4798
- });
4799
- }
4800
- unwrap() {
4801
- return this._def.type;
4802
- }
4803
- };
4804
- var ZodPipeline = class _ZodPipeline extends ZodType {
4805
- _parse(input2) {
4806
- const { status, ctx } = this._processInputParams(input2);
4807
- if (ctx.common.async) {
4808
- const handleAsync = async () => {
4809
- const inResult = await this._def.in._parseAsync({
4810
- data: ctx.data,
4811
- path: ctx.path,
4812
- parent: ctx
4813
- });
4814
- if (inResult.status === "aborted")
4815
- return INVALID;
4816
- if (inResult.status === "dirty") {
4817
- status.dirty();
4818
- return DIRTY(inResult.value);
4819
- } else {
4820
- return this._def.out._parseAsync({
4821
- data: inResult.value,
4822
- path: ctx.path,
4823
- parent: ctx
4824
- });
4825
- }
4826
- };
4827
- return handleAsync();
4828
- } else {
4829
- const inResult = this._def.in._parseSync({
4830
- data: ctx.data,
4831
- path: ctx.path,
4832
- parent: ctx
4833
- });
4834
- if (inResult.status === "aborted")
4835
- return INVALID;
4836
- if (inResult.status === "dirty") {
4837
- status.dirty();
4838
- return {
4839
- status: "dirty",
4840
- value: inResult.value
4841
- };
4842
- } else {
4843
- return this._def.out._parseSync({
4844
- data: inResult.value,
4845
- path: ctx.path,
4846
- parent: ctx
4847
- });
4848
- }
4849
- }
4850
- }
4851
- static create(a, b) {
4852
- return new _ZodPipeline({
4853
- in: a,
4854
- out: b,
4855
- typeName: ZodFirstPartyTypeKind.ZodPipeline
4856
- });
4857
- }
4858
- };
4859
- var ZodReadonly = class extends ZodType {
4860
- _parse(input2) {
4861
- const result = this._def.innerType._parse(input2);
4862
- const freeze = (data) => {
4863
- if (isValid(data)) {
4864
- data.value = Object.freeze(data.value);
4865
- }
4866
- return data;
4867
- };
4868
- return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
4869
- }
4870
- unwrap() {
4871
- return this._def.innerType;
4872
- }
4873
- };
4874
- ZodReadonly.create = (type, params) => {
4875
- return new ZodReadonly({
4876
- innerType: type,
4877
- typeName: ZodFirstPartyTypeKind.ZodReadonly,
4878
- ...processCreateParams(params)
4879
- });
4880
- };
4881
- function cleanParams(params, data) {
4882
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
4883
- const p2 = typeof p === "string" ? { message: p } : p;
4884
- return p2;
4885
- }
4886
- function custom(check2, _params = {}, fatal) {
4887
- if (check2)
4888
- return ZodAny.create().superRefine((data, ctx) => {
4889
- const r = check2(data);
4890
- if (r instanceof Promise) {
4891
- return r.then((r2) => {
4892
- if (!r2) {
4893
- const params = cleanParams(_params, data);
4894
- const _fatal = params.fatal ?? fatal ?? true;
4895
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4896
- }
4897
- });
4898
- }
4899
- if (!r) {
4900
- const params = cleanParams(_params, data);
4901
- const _fatal = params.fatal ?? fatal ?? true;
4902
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4903
- }
4904
- return;
4905
- });
4906
- return ZodAny.create();
4907
- }
4908
- var late = {
4909
- object: ZodObject.lazycreate
4910
- };
4911
- var ZodFirstPartyTypeKind;
4912
- (function(ZodFirstPartyTypeKind2) {
4913
- ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
4914
- ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
4915
- ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
4916
- ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
4917
- ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
4918
- ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
4919
- ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
4920
- ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
4921
- ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
4922
- ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
4923
- ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
4924
- ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
4925
- ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
4926
- ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
4927
- ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
4928
- ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
4929
- ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4930
- ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
4931
- ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
4932
- ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
4933
- ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
4934
- ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
4935
- ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
4936
- ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
4937
- ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
4938
- ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
4939
- ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
4940
- ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
4941
- ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
4942
- ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
4943
- ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
4944
- ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
4945
- ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4946
- ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4947
- ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4948
- ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4949
- })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4950
- var instanceOfType = (cls, params = {
4951
- message: `Input not instance of ${cls.name}`
4952
- }) => custom((data) => data instanceof cls, params);
4953
- var stringType = ZodString.create;
4954
- var numberType = ZodNumber.create;
4955
- var nanType = ZodNaN.create;
4956
- var bigIntType = ZodBigInt.create;
4957
- var booleanType = ZodBoolean.create;
4958
- var dateType = ZodDate.create;
4959
- var symbolType = ZodSymbol.create;
4960
- var undefinedType = ZodUndefined.create;
4961
- var nullType = ZodNull.create;
4962
- var anyType = ZodAny.create;
4963
- var unknownType = ZodUnknown.create;
4964
- var neverType = ZodNever.create;
4965
- var voidType = ZodVoid.create;
4966
- var arrayType = ZodArray.create;
4967
- var objectType = ZodObject.create;
4968
- var strictObjectType = ZodObject.strictCreate;
4969
- var unionType = ZodUnion.create;
4970
- var discriminatedUnionType = ZodDiscriminatedUnion.create;
4971
- var intersectionType = ZodIntersection.create;
4972
- var tupleType = ZodTuple.create;
4973
- var recordType = ZodRecord.create;
4974
- var mapType = ZodMap.create;
4975
- var setType = ZodSet.create;
4976
- var functionType = ZodFunction.create;
4977
- var lazyType = ZodLazy.create;
4978
- var literalType = ZodLiteral.create;
4979
- var enumType = ZodEnum.create;
4980
- var nativeEnumType = ZodNativeEnum.create;
4981
- var promiseType = ZodPromise.create;
4982
- var effectsType = ZodEffects.create;
4983
- var optionalType = ZodOptional.create;
4984
- var nullableType = ZodNullable.create;
4985
- var preprocessType = ZodEffects.createWithPreprocess;
4986
- var pipelineType = ZodPipeline.create;
4987
- var ostring = () => stringType().optional();
4988
- var onumber = () => numberType().optional();
4989
- var oboolean = () => booleanType().optional();
4990
- var coerce = {
4991
- string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4992
- number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4993
- boolean: ((arg) => ZodBoolean.create({
4994
- ...arg,
4995
- coerce: true
4996
- })),
4997
- bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4998
- date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4999
- };
5000
- var NEVER = INVALID;
5001
-
5002
- // src/native-transcript-account.ts
5003
- var MAXIMUM_OWNER_DOCUMENT_BYTES = 16384;
5004
- var MAXIMUM_READ_POSITIONS_BYTES = 4 * 1024 * 1024;
5005
- var OWNER_ONLY_FILE_MODE = 384;
5006
- var OWNER_ONLY_DIRECTORY_MODE = 448;
5007
- var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
5008
- var credentialSchema = external_exports.object({
5009
- key: external_exports.string().min(1).max(1024),
5010
- siteID: external_exports.string().min(1),
5011
- machineID: external_exports.string().min(1),
5012
- baseURL: external_exports.string().url(),
5013
- keyScope: external_exports.literal("agent")
5014
- });
5015
- var consentSchema = credentialSchema.pick({ siteID: true, machineID: true, baseURL: true }).extend({ enabled: external_exports.literal(true), grantedAtMs: external_exports.number().int().positive() });
5016
- var readPositionSchema = external_exports.object({
5017
- identity: external_exports.string().nullable(),
5018
- offset: external_exports.number().int().nonnegative(),
5019
- startedBeforeEpoch: external_exports.boolean()
5020
- });
5021
- var readPositionsSchema = external_exports.object({
5022
- epochStartedAtMs: external_exports.number().int().positive(),
5023
- positions: external_exports.record(external_exports.string(), readPositionSchema)
5024
- });
5025
- var ownerDocument = (path, maximumBytes = MAXIMUM_OWNER_DOCUMENT_BYTES) => {
5026
- const info = lstatSync(path);
5027
- if (!info.isFile() || info.nlink !== 1 || info.uid !== process.getuid?.() || (info.mode & 511) !== OWNER_ONLY_FILE_MODE || info.size > maximumBytes) return null;
5028
- return JSON.parse(readFileSync(path, "utf8"));
5029
- };
5030
- var acceptsServer = (baseURL) => {
5031
- const url = new URL(baseURL);
5032
- return url.protocol === "https:" || url.protocol === "http:" && LOOPBACK_HOSTS.has(url.hostname);
5033
- };
5034
- var nativeBridgeAccount = (home = homedir()) => {
5035
- try {
5036
- const root = join4(home, ".pushary");
5037
- const directory = lstatSync(join4(root, "bridge-auth"));
5038
- if (!directory.isDirectory() || directory.uid !== process.getuid?.() || (directory.mode & 511) !== OWNER_ONLY_DIRECTORY_MODE) return null;
5039
- const account = credentialSchema.parse(ownerDocument(join4(root, "bridge-auth", "agent-key.json")));
5040
- const machineId = readFileSync(join4(root, "machine-id"), "utf8").trim();
5041
- if (machineId !== account.machineID || !acceptsServer(account.baseURL)) return null;
5042
- return account;
5043
- } catch {
5044
- return null;
5045
- }
5046
- };
5047
-
5048
958
  // bin/pushary-setup.ts
5049
959
  var CLAUDE_SETTINGS = claudeSettings();
5050
960
  var CLAUDE_JSON = claudeJson();
@@ -5115,7 +1025,7 @@ var isInstalled = (command) => {
5115
1025
  };
5116
1026
  var readJson = (filePath) => {
5117
1027
  try {
5118
- return JSON.parse(readFileSync2(filePath, "utf-8"));
1028
+ return JSON.parse(readFileSync(filePath, "utf-8"));
5119
1029
  } catch {
5120
1030
  return {};
5121
1031
  }
@@ -5143,7 +1053,7 @@ var writeJson = (filePath, data) => {
5143
1053
  var readAgentToml = (filePath) => {
5144
1054
  let raw;
5145
1055
  try {
5146
- raw = readFileSync2(filePath, "utf-8");
1056
+ raw = readFileSync(filePath, "utf-8");
5147
1057
  } catch (err) {
5148
1058
  if (err.code === "ENOENT") return {};
5149
1059
  throw new AgentConfigError("config-unreadable", filePath, `${filePath} could not be read, so it was left untouched.`);
@@ -5206,23 +1116,23 @@ var fetchSkillContent = async () => {
5206
1116
  if (_cachedSkillContent) return _cachedSkillContent;
5207
1117
  const __dirname = dirname3(fileURLToPath(import.meta.url));
5208
1118
  const candidates = [
5209
- join5(__dirname, "..", "..", "data", "SKILL.md"),
5210
- join5(__dirname, "..", "data", "SKILL.md")
1119
+ join4(__dirname, "..", "..", "data", "SKILL.md"),
1120
+ join4(__dirname, "..", "data", "SKILL.md")
5211
1121
  ];
5212
1122
  const source = candidates.find((path) => existsSync(path));
5213
1123
  if (!source) throw new Error("packaged skill not found");
5214
- _cachedSkillContent = readFileSync2(source, "utf-8");
1124
+ _cachedSkillContent = readFileSync(source, "utf-8");
5215
1125
  return _cachedSkillContent;
5216
1126
  };
5217
1127
  var writePackagedSkill = async (dir) => {
5218
1128
  const content = await fetchSkillContent();
5219
1129
  if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
5220
- writeFileSync(join5(dir, "SKILL.md"), content, "utf-8");
1130
+ writeFileSync(join4(dir, "SKILL.md"), content, "utf-8");
5221
1131
  };
5222
- var skillsCliInUse = () => isInstalled("skills") || existsSync(join5(homedir2(), ".agents", "skills"));
1132
+ var skillsCliInUse = () => isInstalled("skills") || existsSync(join4(homedir(), ".agents", "skills"));
5223
1133
  var skillInstallEffects = {
5224
1134
  runSkillsCli: installSkillViaSkillsCli,
5225
- skillModifiedAt: (dir) => statSync(join5(dir, "SKILL.md"), { throwIfNoEntry: false })?.mtimeMs ?? null,
1135
+ skillModifiedAt: (dir) => statSync(join4(dir, "SKILL.md"), { throwIfNoEntry: false })?.mtimeMs ?? null,
5226
1136
  writePackagedSkill,
5227
1137
  now: () => Date.now()
5228
1138
  };
@@ -5328,7 +1238,7 @@ var setupHermes = async (_apiKey) => {
5328
1238
  console.log(` ${dim("To send approvals back to the terminal:")} remove ${bold("security.approval.transport")} from ~/.hermes/config.yaml`);
5329
1239
  console.log(` ${dim("To re-enable terminal questions:")} remove ${bold("clarify")} from ${dim("agent.disabled_toolsets")}`);
5330
1240
  };
5331
- var CODEX_HOOKS_JSON = join5(CODEX_HOME, "hooks.json");
1241
+ var CODEX_HOOKS_JSON = join4(CODEX_HOME, "hooks.json");
5332
1242
  var CODEX_HOOKS_MIN_VERSION = [0, 122, 0];
5333
1243
  var codexOnPath = () => {
5334
1244
  const whichCmd = IS_WINDOWS ? "where" : "which";
@@ -5381,7 +1291,7 @@ var LARGEST_LAUNCHER_BYTES = 64 * 1024;
5381
1291
  var engineBehindPusharyLauncher = (path) => {
5382
1292
  try {
5383
1293
  if (statSync(path).size > LARGEST_LAUNCHER_BYTES) return null;
5384
- return codexEngineBehindLauncher(readFileSync2(path, "utf-8"));
1294
+ return codexEngineBehindLauncher(readFileSync(path, "utf-8"));
5385
1295
  } catch {
5386
1296
  return null;
5387
1297
  }
@@ -5390,7 +1300,7 @@ var codexEngineManifestVersion = (codex) => {
5390
1300
  const manifest = codexEngineManifestBeside(codex);
5391
1301
  if (!manifest) return null;
5392
1302
  try {
5393
- return parseCodexEngineManifestVersion(readFileSync2(manifest, "utf-8"));
1303
+ return parseCodexEngineManifestVersion(readFileSync(manifest, "utf-8"));
5394
1304
  } catch {
5395
1305
  return null;
5396
1306
  }
@@ -5398,14 +1308,14 @@ var codexEngineManifestVersion = (codex) => {
5398
1308
  var bundledCodex = () => findBundledCodex({
5399
1309
  config: () => {
5400
1310
  try {
5401
- return parseTOML(readFileSync2(codexConfigToml(), "utf-8"));
1311
+ return parseTOML(readFileSync(codexConfigToml(), "utf-8"));
5402
1312
  } catch {
5403
1313
  return null;
5404
1314
  }
5405
1315
  },
5406
1316
  exists: existsSync,
5407
1317
  engineBehindPusharyLauncher,
5408
- home: homedir2(),
1318
+ home: homedir(),
5409
1319
  platform: process.platform
5410
1320
  });
5411
1321
  var detectCodexVersion = () => readCodexVersion({
@@ -5413,7 +1323,7 @@ var detectCodexVersion = () => readCodexVersion({
5413
1323
  realpath: codexRealpath,
5414
1324
  readFile: (path) => {
5415
1325
  try {
5416
- return readFileSync2(path, "utf-8");
1326
+ return readFileSync(path, "utf-8");
5417
1327
  } catch {
5418
1328
  return null;
5419
1329
  }
@@ -5439,7 +1349,7 @@ var codexSupportsHooks = (version) => version !== null && compareCodexVersion(ve
5439
1349
  var removeCodexNotifyEntry = (codexConfig) => {
5440
1350
  let raw = "";
5441
1351
  try {
5442
- raw = readFileSync2(codexConfig, "utf-8");
1352
+ raw = readFileSync(codexConfig, "utf-8");
5443
1353
  } catch {
5444
1354
  return;
5445
1355
  }
@@ -5459,7 +1369,7 @@ var addCodexNotifyEntry = (codexConfig) => {
5459
1369
  const pusharyCodexPath = resolveGlobalBinary("pushary-codex") ?? "pushary-codex";
5460
1370
  let raw = "";
5461
1371
  try {
5462
- raw = readFileSync2(codexConfig, "utf-8");
1372
+ raw = readFileSync(codexConfig, "utf-8");
5463
1373
  } catch {
5464
1374
  }
5465
1375
  const config = raw ? parseTOML(raw) : {};
@@ -5529,7 +1439,7 @@ var setupCodex = async (apiKey) => {
5529
1439
  await spinner("Writing trust entries for the Pushary hook", async () => {
5530
1440
  let raw = "";
5531
1441
  try {
5532
- raw = readFileSync2(codexConfig, "utf-8");
1442
+ raw = readFileSync(codexConfig, "utf-8");
5533
1443
  } catch {
5534
1444
  }
5535
1445
  const config = raw ? parseTOML(raw) : {};
@@ -5609,15 +1519,15 @@ var setupCodex = async (apiKey) => {
5609
1519
  var resolveBundledPlugin = () => {
5610
1520
  const dir = dirname3(fileURLToPath(import.meta.url));
5611
1521
  const candidates = [
5612
- join5(dir, "..", "..", "data", "cursor-plugin"),
5613
- join5(dir, "..", "data", "cursor-plugin"),
5614
- join5(dir, "..", "..", "..", "cursor-plugin"),
5615
- join5(dir, "..", "..", "cursor-plugin")
1522
+ join4(dir, "..", "..", "data", "cursor-plugin"),
1523
+ join4(dir, "..", "data", "cursor-plugin"),
1524
+ join4(dir, "..", "..", "..", "cursor-plugin"),
1525
+ join4(dir, "..", "..", "cursor-plugin")
5616
1526
  ];
5617
- return candidates.find((p) => existsSync(join5(p, ".cursor-plugin", "plugin.json"))) ?? null;
1527
+ return candidates.find((p) => existsSync(join4(p, ".cursor-plugin", "plugin.json"))) ?? null;
5618
1528
  };
5619
1529
  var installCursorUserHooks = (gateScript) => {
5620
- const bundled = readJson(join5(CURSOR_PLUGIN_DIR, "hooks", "hooks.json")).hooks ?? {};
1530
+ const bundled = readJson(join4(CURSOR_PLUGIN_DIR, "hooks", "hooks.json")).hooks ?? {};
5621
1531
  let userHooks = {};
5622
1532
  if (existsSync(CURSOR_USER_HOOKS)) {
5623
1533
  const result = readJsonSafe(CURSOR_USER_HOOKS);
@@ -5645,7 +1555,7 @@ var installCursorUserHooks = (gateScript) => {
5645
1555
  writeJson(CURSOR_USER_HOOKS, { ...userHooks, version: userHooks.version ?? 1, hooks });
5646
1556
  };
5647
1557
  var neutralizePluginGate = () => {
5648
- const path = join5(CURSOR_PLUGIN_DIR, "hooks", "hooks.json");
1558
+ const path = join4(CURSOR_PLUGIN_DIR, "hooks", "hooks.json");
5649
1559
  if (!existsSync(path)) return;
5650
1560
  const data = readJson(path);
5651
1561
  if (!data.hooks) return;
@@ -5668,7 +1578,7 @@ var setupCursor = async (apiKey) => {
5668
1578
  const source = resolveBundledPlugin();
5669
1579
  if (!source) throw new Error("bundled Cursor plugin not found in this package");
5670
1580
  await spinner("Installing Pushary plugin", async () => {
5671
- const staging = join5(dirname3(CURSOR_PLUGIN_DIR), `${CURSOR_PLUGIN_STAGING_PREFIX}${process.pid}`);
1581
+ const staging = join4(dirname3(CURSOR_PLUGIN_DIR), `${CURSOR_PLUGIN_STAGING_PREFIX}${process.pid}`);
5672
1582
  const backup = `${CURSOR_PLUGIN_DIR}${CURSOR_PLUGIN_BACKUP_INFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
5673
1583
  rmSync(staging, { recursive: true, force: true });
5674
1584
  try {
@@ -5676,7 +1586,7 @@ var setupCursor = async (apiKey) => {
5676
1586
  recursive: true,
5677
1587
  filter: (p) => !["tools", "node_modules", ".git", ".DS_Store"].includes(basename(p))
5678
1588
  });
5679
- const staged = readJsonSafe(join5(staging, ".cursor-plugin", "plugin.json"));
1589
+ const staged = readJsonSafe(join4(staging, ".cursor-plugin", "plugin.json"));
5680
1590
  if (staged.kind !== "ok") {
5681
1591
  throw new Error("staged Cursor plugin is missing or has an unreadable plugin.json");
5682
1592
  }
@@ -5694,7 +1604,7 @@ var setupCursor = async (apiKey) => {
5694
1604
  }
5695
1605
  });
5696
1606
  await spinner("Linking your API key", async () => {
5697
- const mcpPath = join5(CURSOR_PLUGIN_DIR, "mcp.json");
1607
+ const mcpPath = join4(CURSOR_PLUGIN_DIR, "mcp.json");
5698
1608
  const mcp = readAgentJson(mcpPath);
5699
1609
  const servers = mcp.mcpServers ?? {};
5700
1610
  if (servers.pushary) {
@@ -5704,7 +1614,7 @@ var setupCursor = async (apiKey) => {
5704
1614
  }
5705
1615
  });
5706
1616
  await spinner("Registering permission gate (~/.cursor/hooks.json)", async () => {
5707
- installCursorUserHooks(join5(CURSOR_PLUGIN_DIR, "scripts", "pushary-gate.mjs"));
1617
+ installCursorUserHooks(join4(CURSOR_PLUGIN_DIR, "scripts", "pushary-gate.mjs"));
5708
1618
  neutralizePluginGate();
5709
1619
  });
5710
1620
  console.log();
@@ -5718,16 +1628,16 @@ var setupCursor = async (apiKey) => {
5718
1628
  var resolveBundledVsCodePlugin = () => {
5719
1629
  const dir = dirname3(fileURLToPath(import.meta.url));
5720
1630
  const candidates = [
5721
- join5(dir, "..", "..", "data", "vscode-plugin"),
5722
- join5(dir, "..", "data", "vscode-plugin"),
5723
- join5(dir, "..", "..", "..", "vscode-plugin"),
5724
- join5(dir, "..", "..", "vscode-plugin")
1631
+ join4(dir, "..", "..", "data", "vscode-plugin"),
1632
+ join4(dir, "..", "data", "vscode-plugin"),
1633
+ join4(dir, "..", "..", "..", "vscode-plugin"),
1634
+ join4(dir, "..", "..", "vscode-plugin")
5725
1635
  ];
5726
- return candidates.find((p) => existsSync(join5(p, ".claude-plugin", "plugin.json"))) ?? null;
1636
+ return candidates.find((p) => existsSync(join4(p, ".claude-plugin", "plugin.json"))) ?? null;
5727
1637
  };
5728
1638
  var pinGuardedVsCodeGate = (pluginDir) => {
5729
- const hooksPath = join5(pluginDir, "hooks", "hooks.json");
5730
- const guarded = guardVsCodeGateHooks(readJson(hooksPath), join5(pluginDir, "scripts", CURSOR_GATE_SCRIPT));
1639
+ const hooksPath = join4(pluginDir, "hooks", "hooks.json");
1640
+ const guarded = guardVsCodeGateHooks(readJson(hooksPath), join4(pluginDir, "scripts", CURSOR_GATE_SCRIPT));
5731
1641
  if (guarded.kind === "invalid") throw new Error(guarded.reason);
5732
1642
  writeJson(hooksPath, guarded.document);
5733
1643
  };
@@ -5735,7 +1645,7 @@ var registerVsCodePlugin = (pluginDir) => {
5735
1645
  const written = [];
5736
1646
  const manual = [];
5737
1647
  for (const settingsPath of vscodeSettingsTargets(existsSync)) {
5738
- const current = existsSync(settingsPath) ? readFileSync2(settingsPath, "utf-8") : null;
1648
+ const current = existsSync(settingsPath) ? readFileSync(settingsPath, "utf-8") : null;
5739
1649
  const result = registerPluginLocation(current, pluginDir);
5740
1650
  if (result.kind === "already") continue;
5741
1651
  if (result.kind === "manual") {
@@ -5756,7 +1666,7 @@ var setupVsCode = async (apiKey) => {
5756
1666
  const source = resolveBundledVsCodePlugin();
5757
1667
  if (!source) throw new Error("bundled VS Code plugin not found in this package");
5758
1668
  await spinner("Installing Pushary plugin", async () => {
5759
- const staging = join5(dirname3(VSCODE_PLUGIN_DIR), `.pushary-staging-vscode-${process.pid}`);
1669
+ const staging = join4(dirname3(VSCODE_PLUGIN_DIR), `.pushary-staging-vscode-${process.pid}`);
5760
1670
  const backup = `${VSCODE_PLUGIN_DIR}.pushary-backup-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
5761
1671
  mkdirSync(dirname3(VSCODE_PLUGIN_DIR), { recursive: true });
5762
1672
  rmSync(staging, { recursive: true, force: true });
@@ -5765,7 +1675,7 @@ var setupVsCode = async (apiKey) => {
5765
1675
  recursive: true,
5766
1676
  filter: (p) => !["tools", "node_modules", ".git", ".DS_Store"].includes(basename(p))
5767
1677
  });
5768
- const staged = readJsonSafe(join5(staging, ".claude-plugin", "plugin.json"));
1678
+ const staged = readJsonSafe(join4(staging, ".claude-plugin", "plugin.json"));
5769
1679
  if (staged.kind !== "ok") {
5770
1680
  throw new Error("staged VS Code plugin is missing or has an unreadable plugin.json");
5771
1681
  }
@@ -6097,7 +2007,7 @@ var captureTakeoverReceipt = (agent) => {
6097
2007
  var agentIsWired = (agent) => {
6098
2008
  const readJson2 = (path) => {
6099
2009
  try {
6100
- return JSON.parse(readFileSync2(path, "utf-8"));
2010
+ return JSON.parse(readFileSync(path, "utf-8"));
6101
2011
  } catch {
6102
2012
  return null;
6103
2013
  }
@@ -6107,25 +2017,25 @@ var agentIsWired = (agent) => {
6107
2017
  return claudeWired({
6108
2018
  claudeJson: readJson2(CLAUDE_JSON),
6109
2019
  settings: readJson2(CLAUDE_SETTINGS),
6110
- skillExists: existsSync(join5(CLAUDE_SKILL_DIR, "SKILL.md"))
2020
+ skillExists: existsSync(join4(CLAUDE_SKILL_DIR, "SKILL.md"))
6111
2021
  });
6112
2022
  case "codex": {
6113
2023
  let config = null;
6114
2024
  try {
6115
- config = parseTOML(readFileSync2(join5(CODEX_HOME, "config.toml"), "utf-8"));
2025
+ config = parseTOML(readFileSync(join4(CODEX_HOME, "config.toml"), "utf-8"));
6116
2026
  } catch {
6117
2027
  config = null;
6118
2028
  }
6119
2029
  return codexWired({
6120
2030
  config,
6121
2031
  hooks: readJson2(CODEX_HOOKS_JSON),
6122
- skillExists: existsSync(join5(CODEX_SKILL_DIR, "SKILL.md"))
2032
+ skillExists: existsSync(join4(CODEX_SKILL_DIR, "SKILL.md"))
6123
2033
  });
6124
2034
  }
6125
2035
  case "gemini_cli":
6126
2036
  return geminiWired({ settings: readJson2(GEMINI_SETTINGS) });
6127
2037
  case "cursor":
6128
- return existsSync(join5(CURSOR_PLUGIN_DIR, "mcp.json"));
2038
+ return existsSync(join4(CURSOR_PLUGIN_DIR, "mcp.json"));
6129
2039
  case "vscode":
6130
2040
  return existsSync(VSCODE_PLUGIN_MCP);
6131
2041
  case "opencode":
@@ -6275,8 +2185,8 @@ var offerProjectInstructions = async (agents, options) => {
6275
2185
  });
6276
2186
  if (!wanted) return;
6277
2187
  for (const target of targets) {
6278
- await spinner(`Writing managed block to ${join5(process.cwd(), target.file)}`, async () => {
6279
- writeInstructionBlock(join5(process.cwd(), target.file), renderProjectAgentInstructions(target.label));
2188
+ await spinner(`Writing managed block to ${join4(process.cwd(), target.file)}`, async () => {
2189
+ writeInstructionBlock(join4(process.cwd(), target.file), renderProjectAgentInstructions(target.label));
6280
2190
  }, { optional: true });
6281
2191
  }
6282
2192
  console.log(` ${dim("Commit the file to share it. Teammates without a key fall back to the terminal.")}`);