prisma 8.0.0-rc.9-dev.79 → 8.1.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +201 -158
  2. package/README.md +58 -101
  3. package/build/child.js +82915 -0
  4. package/build/cli.js +5778 -0
  5. package/build/completion.js +802 -0
  6. package/build/index.js +2 -0
  7. package/build/prisma_schema_build_bg.wasm +0 -0
  8. package/build/query_compiler_fast_bg.cockroachdb.js +2 -0
  9. package/build/query_compiler_fast_bg.cockroachdb.mjs +2 -0
  10. package/build/query_compiler_fast_bg.cockroachdb.wasm +0 -0
  11. package/build/query_compiler_fast_bg.mysql.js +2 -0
  12. package/build/query_compiler_fast_bg.mysql.mjs +2 -0
  13. package/build/query_compiler_fast_bg.mysql.wasm +0 -0
  14. package/build/query_compiler_fast_bg.postgresql.js +2 -0
  15. package/build/query_compiler_fast_bg.postgresql.mjs +2 -0
  16. package/build/query_compiler_fast_bg.postgresql.wasm +0 -0
  17. package/build/query_compiler_fast_bg.sqlite.js +2 -0
  18. package/build/query_compiler_fast_bg.sqlite.mjs +2 -0
  19. package/build/query_compiler_fast_bg.sqlite.wasm +0 -0
  20. package/build/query_compiler_fast_bg.sqlserver.js +2 -0
  21. package/build/query_compiler_fast_bg.sqlserver.mjs +2 -0
  22. package/build/query_compiler_fast_bg.sqlserver.wasm +0 -0
  23. package/build/query_compiler_small_bg.cockroachdb.js +2 -0
  24. package/build/query_compiler_small_bg.cockroachdb.mjs +2 -0
  25. package/build/query_compiler_small_bg.cockroachdb.wasm +0 -0
  26. package/build/query_compiler_small_bg.mysql.js +2 -0
  27. package/build/query_compiler_small_bg.mysql.mjs +2 -0
  28. package/build/query_compiler_small_bg.mysql.wasm +0 -0
  29. package/build/query_compiler_small_bg.postgresql.js +2 -0
  30. package/build/query_compiler_small_bg.postgresql.mjs +2 -0
  31. package/build/query_compiler_small_bg.postgresql.wasm +0 -0
  32. package/build/query_compiler_small_bg.sqlite.js +2 -0
  33. package/build/query_compiler_small_bg.sqlite.mjs +2 -0
  34. package/build/query_compiler_small_bg.sqlite.wasm +0 -0
  35. package/build/query_compiler_small_bg.sqlserver.js +2 -0
  36. package/build/query_compiler_small_bg.sqlserver.mjs +2 -0
  37. package/build/query_compiler_small_bg.sqlserver.wasm +0 -0
  38. package/build/schema_engine_bg.wasm +0 -0
  39. package/build/studio.css +5850 -0
  40. package/build/studio.js +373 -0
  41. package/build/xdg-open +1066 -0
  42. package/config.d.ts +1 -0
  43. package/config.js +30 -0
  44. package/dist/cli/src/config.d.ts +1 -0
  45. package/dist/cli/src/types.d.ts +1 -0
  46. package/package.json +189 -55
  47. package/preinstall/index.js +7 -0
  48. package/scripts/preinstall-entry.js +10 -0
  49. package/dist/config.d.ts +0 -2
  50. package/dist/config.js +0 -2
  51. package/dist/payload-B88Qvzxk-CrtTXSOe.js +0 -34
  52. package/dist/prisma.js +0 -14559
  53. package/dist/sender.js +0 -192
@@ -0,0 +1,802 @@
1
+ "use strict";var Ye=Object.create;var ue=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var he=(e,o)=>()=>(o||e((o={exports:{}}).exports,o),o.exports);var tt=(e,o,t,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Xe(o))!et.call(e,i)&&i!==t&&ue(e,i,{get:()=>o[i],enumerable:!(r=Je(o,i))||r.enumerable});return e};var S=(e,o,t)=>(t=e!=null?Ye(Ze(e)):{},tt(o||!e||!e.__esModule?ue(t,"default",{value:e,enumerable:!0}):t,e));var Ee=he((oo,we)=>{"use strict";var z=Symbol("arg flag"),f=class e extends Error{constructor(o,t){super(o),this.name="ArgError",this.code=t,Object.setPrototypeOf(this,e.prototype)}};function D(e,{argv:o=process.argv.slice(2),permissive:t=!1,stopAtPositional:r=!1}={}){if(!e)throw new f("argument specification object is required","ARG_CONFIG_NO_SPEC");let i={_:[]},n={},m={};for(let s of Object.keys(e)){if(!s)throw new f("argument key cannot be an empty string","ARG_CONFIG_EMPTY_KEY");if(s[0]!=="-")throw new f(`argument key must start with '-' but found: '${s}'`,"ARG_CONFIG_NONOPT_KEY");if(s.length===1)throw new f(`argument key must have a name; singular '-' keys are not allowed: ${s}`,"ARG_CONFIG_NONAME_KEY");if(typeof e[s]=="string"){n[s]=e[s];continue}let d=e[s],h=!1;if(Array.isArray(d)&&d.length===1&&typeof d[0]=="function"){let[$]=d;d=(_,v,C=[])=>(C.push($(_,v,C[C.length-1])),C),h=$===Boolean||$[z]===!0}else if(typeof d=="function")h=d===Boolean||d[z]===!0;else throw new f(`type missing or not a function or valid array type: ${s}`,"ARG_CONFIG_VAD_TYPE");if(s[1]!=="-"&&s.length>2)throw new f(`short argument keys (with a single hyphen) must have only one character: ${s}`,"ARG_CONFIG_SHORTOPT_TOOLONG");m[s]=[d,h]}for(let s=0,d=o.length;s<d;s++){let h=o[s];if(r&&i._.length>0){i._=i._.concat(o.slice(s));break}if(h==="--"){i._=i._.concat(o.slice(s+1));break}if(h.length>1&&h[0]==="-"){let $=h[1]==="-"||h.length===2?[h]:h.slice(1).split("").map(_=>`-${_}`);for(let _=0;_<$.length;_++){let v=$[_],[C,ce]=v[1]==="-"?v.split(/=(.*)/,2):[v,void 0],u=C;for(;u in n;)u=n[u];if(!(u in m))if(t){i._.push(v);continue}else throw new f(`unknown or unexpected option: ${C}`,"ARG_UNKNOWN_OPTION");let[y,de]=m[u];if(!de&&_+1<$.length)throw new f(`option requires argument (but was followed by another short argument): ${C}`,"ARG_MISSING_REQUIRED_SHORTARG");if(de)i[u]=y(!0,u,i[u]);else if(ce===void 0){if(o.length<s+2||o[s+1].length>1&&o[s+1][0]==="-"&&!(o[s+1].match(/^-?\d*(\.(?=\d))?\d*$/)&&(y===Number||typeof BigInt<"u"&&y===BigInt))){let ze=C===u?"":` (alias for ${u})`;throw new f(`option requires argument: ${C}${ze}`,"ARG_MISSING_REQUIRED_LONGARG")}i[u]=y(o[s+1],u,i[u]),++s}else i[u]=y(ce,u,i[u])}}else i._.push(h)}return i}D.flag=e=>(e[z]=!0,e);D.COUNT=D.flag((e,o,t)=>(t||0)+1);D.ArgError=f;we.exports=D});var ke=he((io,Oe)=>{"use strict";Oe.exports=e=>{let o=e.match(/^[ \t]*(?=\S)/gm);return o?o.reduce((t,r)=>Math.min(t,r.length),1/0):0}});var fe=S(require("node:path"));function ge(e=process.argv[1]){let o=e?.replaceAll("\\","/");return(o===void 0?void 0:fe.default.posix.parse(o).name)==="prisma7"?"prisma7":"prisma"}function Ce(e,o){return`#compdef ${e}
2
+ compdef _${e} ${e}
3
+
4
+ # zsh completion for ${e} -*- shell-script -*-
5
+
6
+ __${e}_debug() {
7
+ local file="$BASH_COMP_DEBUG_FILE"
8
+ if [[ -n \${file} ]]; then
9
+ echo "$*" >> "\${file}"
10
+ fi
11
+ }
12
+
13
+ _${e}() {
14
+ local shellCompDirectiveError=${p.ShellCompDirectiveError}
15
+ local shellCompDirectiveNoSpace=${p.ShellCompDirectiveNoSpace}
16
+ local shellCompDirectiveNoFileComp=${p.ShellCompDirectiveNoFileComp}
17
+ local shellCompDirectiveFilterFileExt=${p.ShellCompDirectiveFilterFileExt}
18
+ local shellCompDirectiveFilterDirs=${p.ShellCompDirectiveFilterDirs}
19
+ local shellCompDirectiveKeepOrder=${p.ShellCompDirectiveKeepOrder}
20
+
21
+ local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
22
+ local -a completions
23
+
24
+ __${e}_debug "\\n========= starting completion logic =========="
25
+ __${e}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
26
+
27
+ # The user could have moved the cursor backwards on the command-line.
28
+ # We need to trigger completion from the $CURRENT location, so we need
29
+ # to truncate the command-line ($words) up to the $CURRENT location.
30
+ # (We cannot use $CURSOR as its value does not work when a command is an alias.)
31
+ words=( "\${=words[1,CURRENT]}" )
32
+ __${e}_debug "Truncated words[*]: \${words[*]},"
33
+
34
+ lastParam=\${words[-1]}
35
+ lastChar=\${lastParam[-1]}
36
+ __${e}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
37
+
38
+ # For zsh, when completing a flag with an = (e.g., ${e} -n=<TAB>)
39
+ # completions must be prefixed with the flag
40
+ setopt local_options BASH_REMATCH
41
+ if [[ "\${lastParam}" =~ '-.*=' ]]; then
42
+ # We are dealing with a flag with an =
43
+ flagPrefix="-P \${BASH_REMATCH}"
44
+ fi
45
+
46
+ # Prepare the command to obtain completions, ensuring arguments are quoted for eval
47
+ local -a args_to_quote=("\${(@)words[2,-1]}")
48
+ if [ "\${lastChar}" = "" ] && [ "\${args_to_quote[-1]}" != "" ]; then
49
+ # If the last parameter is complete (there is a space following it)
50
+ # We add an extra empty parameter so we can indicate this to the go completion code.
51
+ __${e}_debug "Adding extra empty parameter"
52
+ args_to_quote+=("")
53
+ fi
54
+
55
+ # Use Zsh's (q) flag to quote each argument safely for eval
56
+ local quoted_args=("\${(@q)args_to_quote}")
57
+
58
+ # Join the main command and the quoted arguments into a single string for eval
59
+ requestComp="${o} complete -- \${quoted_args[*]}"
60
+
61
+ __${e}_debug "About to call: eval \${requestComp}"
62
+
63
+ # Use eval to handle any environment variables and such
64
+ out=$(eval \${requestComp} 2>/dev/null)
65
+ __${e}_debug "completion output: \${out}"
66
+
67
+ # Extract the directive integer following a : from the last line
68
+ local lastLine
69
+ while IFS='
70
+ ' read -r line; do
71
+ lastLine=\${line}
72
+ done < <(printf "%s
73
+ " "\${out[@]}")
74
+ __${e}_debug "last line: \${lastLine}"
75
+
76
+ if [ "\${lastLine[1]}" = : ]; then
77
+ directive=\${lastLine[2,-1]}
78
+ # Remove the directive including the : and the newline
79
+ local suffix
80
+ (( suffix=\${#lastLine}+2))
81
+ out=\${out[1,-$suffix]}
82
+ else
83
+ # There is no directive specified. Leave $out as is.
84
+ __${e}_debug "No directive found. Setting to default"
85
+ directive=0
86
+ fi
87
+
88
+ __${e}_debug "directive: \${directive}"
89
+ __${e}_debug "completions: \${out}"
90
+ __${e}_debug "flagPrefix: \${flagPrefix}"
91
+
92
+ if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
93
+ __${e}_debug "Completion received error. Ignoring completions."
94
+ return
95
+ fi
96
+
97
+ local activeHelpMarker="%"
98
+ local endIndex=\${#activeHelpMarker}
99
+ local startIndex=$((\${#activeHelpMarker}+1))
100
+ local hasActiveHelp=0
101
+ while IFS='
102
+ ' read -r comp; do
103
+ # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
104
+ if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
105
+ __${e}_debug "ActiveHelp found: $comp"
106
+ comp="\${comp[$startIndex,-1]}"
107
+ if [ -n "$comp" ]; then
108
+ compadd -x "\${comp}"
109
+ __${e}_debug "ActiveHelp will need delimiter"
110
+ hasActiveHelp=1
111
+ fi
112
+ continue
113
+ fi
114
+
115
+ if [ -n "$comp" ]; then
116
+ # If requested, completions are returned with a description.
117
+ # The description is preceded by a TAB character.
118
+ # For zsh's _describe, we need to use a : instead of a TAB.
119
+ # We first need to escape any : as part of the completion itself.
120
+ comp=\${comp//:/\\:}
121
+
122
+ local tab="$(printf '\\t')"
123
+ comp=\${comp//$tab/:}
124
+
125
+ __${e}_debug "Adding completion: \${comp}"
126
+ completions+=\${comp}
127
+ lastComp=$comp
128
+ fi
129
+ done < <(printf "%s
130
+ " "\${out[@]}")
131
+
132
+ # Add a delimiter after the activeHelp statements, but only if:
133
+ # - there are completions following the activeHelp statements, or
134
+ # - file completion will be performed (so there will be choices after the activeHelp)
135
+ if [ $hasActiveHelp -eq 1 ]; then
136
+ if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
137
+ __${e}_debug "Adding activeHelp delimiter"
138
+ compadd -x "--"
139
+ hasActiveHelp=0
140
+ fi
141
+ fi
142
+
143
+ if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
144
+ __${e}_debug "Activating nospace."
145
+ noSpace="-S ''"
146
+ fi
147
+
148
+ if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
149
+ __${e}_debug "Activating keep order."
150
+ keepOrder="-V"
151
+ fi
152
+
153
+ if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
154
+ # File extension filtering
155
+ local filteringCmd
156
+ filteringCmd='_files'
157
+ for filter in \${completions[@]}; do
158
+ if [ \${filter[1]} != '*' ]; then
159
+ # zsh requires a glob pattern to do file filtering
160
+ filter="\\*.$filter"
161
+ fi
162
+ filteringCmd+=" -g $filter"
163
+ done
164
+ filteringCmd+=" \${flagPrefix}"
165
+
166
+ __${e}_debug "File filtering command: $filteringCmd"
167
+ _arguments '*:filename:'"$filteringCmd"
168
+ elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
169
+ # File completion for directories only
170
+ local subdir
171
+ subdir="\${completions[1]}"
172
+ if [ -n "$subdir" ]; then
173
+ __${e}_debug "Listing directories in $subdir"
174
+ pushd "\${subdir}" >/dev/null 2>&1
175
+ else
176
+ __${e}_debug "Listing directories in ."
177
+ fi
178
+
179
+ local result
180
+ _arguments '*:dirname:_files -/'" \${flagPrefix}"
181
+ result=$?
182
+ if [ -n "$subdir" ]; then
183
+ popd >/dev/null 2>&1
184
+ fi
185
+ return $result
186
+ else
187
+ __${e}_debug "Calling _describe"
188
+ if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
189
+ __${e}_debug "_describe found some completions"
190
+
191
+ # Return the success of having called _describe
192
+ return 0
193
+ else
194
+ __${e}_debug "_describe did not find completions."
195
+ __${e}_debug "Checking if we should do file completion."
196
+ if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
197
+ __${e}_debug "deactivating file completion"
198
+
199
+ # Return 0 to indicate completion is finished and prevent zsh from
200
+ # trying other completion algorithms (which could cause hanging).
201
+ # We use NoFileComp directive to explicitly disable file completion.
202
+ return 0
203
+ else
204
+ # Perform file completion
205
+ __${e}_debug "Activating file completion"
206
+
207
+ # We must return the result of this command, so it must be the
208
+ # last command, or else we must store its result to return it.
209
+ _arguments '*:filename:_files'" \${flagPrefix}"
210
+ fi
211
+ fi
212
+ fi
213
+ }
214
+
215
+ # don't run the completion function when being sourced or eval-ed
216
+ if [ "\${funcstack[1]}" = "_${e}" ]; then
217
+ _${e}
218
+ fi
219
+ `}function _e(e,o){let t=e.replace(/[-:]/g,"_");return`# bash completion for ${e}
220
+
221
+ # Define shell completion directives
222
+ readonly ShellCompDirectiveError=${p.ShellCompDirectiveError}
223
+ readonly ShellCompDirectiveNoSpace=${p.ShellCompDirectiveNoSpace}
224
+ readonly ShellCompDirectiveNoFileComp=${p.ShellCompDirectiveNoFileComp}
225
+ readonly ShellCompDirectiveFilterFileExt=${p.ShellCompDirectiveFilterFileExt}
226
+ readonly ShellCompDirectiveFilterDirs=${p.ShellCompDirectiveFilterDirs}
227
+ readonly ShellCompDirectiveKeepOrder=${p.ShellCompDirectiveKeepOrder}
228
+
229
+ # Function to debug completion
230
+ __${t}_debug() {
231
+ if [[ -n \${BASH_COMP_DEBUG_FILE:-} ]]; then
232
+ echo "$*" >> "\${BASH_COMP_DEBUG_FILE}"
233
+ fi
234
+ }
235
+
236
+ # Function to handle completions
237
+ __${t}_complete() {
238
+ local cur prev words cword
239
+ _get_comp_words_by_ref -n "=:" cur prev words cword
240
+
241
+ local requestComp out directive
242
+
243
+ # Build the command to get completions
244
+ requestComp="${o} complete -- \${words[@]:1}"
245
+
246
+ # Add an empty parameter if the last parameter is complete
247
+ if [[ -z "$cur" ]]; then
248
+ requestComp="$requestComp ''"
249
+ fi
250
+
251
+ # Get completions from the program
252
+ out=$(eval "$requestComp" 2>/dev/null)
253
+
254
+ # Extract directive if present
255
+ directive=0
256
+ if [[ "$out" == *:* ]]; then
257
+ directive=\${out##*:}
258
+ out=\${out%:*}
259
+ fi
260
+
261
+ # Process completions based on directive
262
+ if [[ $((directive & $ShellCompDirectiveError)) -ne 0 ]]; then
263
+ # Error, no completion
264
+ return
265
+ fi
266
+
267
+ # Apply directives
268
+ if [[ $((directive & $ShellCompDirectiveNoSpace)) -ne 0 ]]; then
269
+ compopt -o nospace
270
+ fi
271
+ if [[ $((directive & $ShellCompDirectiveKeepOrder)) -ne 0 ]]; then
272
+ compopt -o nosort
273
+ fi
274
+ if [[ $((directive & $ShellCompDirectiveNoFileComp)) -ne 0 ]]; then
275
+ compopt +o default
276
+ fi
277
+
278
+ # Handle file extension filtering
279
+ if [[ $((directive & $ShellCompDirectiveFilterFileExt)) -ne 0 ]]; then
280
+ local filter=""
281
+ for ext in $out; do
282
+ filter="$filter|$ext"
283
+ done
284
+ filter="\\.($filter)"
285
+ compopt -o filenames
286
+ COMPREPLY=( $(compgen -f -X "!$filter" -- "$cur") )
287
+ return
288
+ fi
289
+
290
+ # Handle directory filtering
291
+ if [[ $((directive & $ShellCompDirectiveFilterDirs)) -ne 0 ]]; then
292
+ compopt -o dirnames
293
+ COMPREPLY=( $(compgen -d -- "$cur") )
294
+ return
295
+ fi
296
+
297
+ # Process completions
298
+ local IFS=$'\\n'
299
+ local tab=$(printf '\\t')
300
+
301
+ # Parse completions with descriptions
302
+ local completions=()
303
+ while read -r comp; do
304
+ if [[ "$comp" == *$tab* ]]; then
305
+ # Split completion and description
306
+ local value=\${comp%%$tab*}
307
+ local desc=\${comp#*$tab}
308
+ completions+=("$value")
309
+ else
310
+ completions+=("$comp")
311
+ fi
312
+ done <<< "$out"
313
+
314
+ # Return completions
315
+ COMPREPLY=( $(compgen -W "\${completions[*]}" -- "$cur") )
316
+ }
317
+
318
+ # Register completion function
319
+ complete -F __${t}_complete ${e}
320
+ `}function $e(e,o){let t=e.replace(/[-:]/g,"_"),r=p.ShellCompDirectiveError,i=p.ShellCompDirectiveNoSpace,n=p.ShellCompDirectiveNoFileComp,m=p.ShellCompDirectiveFilterFileExt,s=p.ShellCompDirectiveFilterDirs;return`# fish completion for ${e} -*- shell-script -*-
321
+
322
+ function __${t}_debug
323
+ set -l file "$BASH_COMP_DEBUG_FILE"
324
+ if test -n "$file"
325
+ echo "$argv" >> $file
326
+ end
327
+ end
328
+
329
+ function __${t}_perform_completion
330
+ __${t}_debug "Starting __${t}_perform_completion"
331
+
332
+ # Extract all args except the last one
333
+ set -l args (commandline -opc)
334
+ # Extract the token currently being completed (may be empty on a trailing space)
335
+ set -l lastArg (commandline -ct)
336
+
337
+ __${t}_debug "args: $args"
338
+ __${t}_debug "last arg: $lastArg"
339
+
340
+ # Pass each arg as its own token (no string join/eval, which would collapse multi-segment paths); quote "$lastArg" so an empty trailing token is still sent.
341
+ __${t}_debug "Calling ${o} complete -- $args[2..-1] $lastArg"
342
+ set -l results (${o} complete -- $args[2..-1] "$lastArg" 2> /dev/null)
343
+
344
+ # Some programs may output extra empty lines after the directive.
345
+ # Let's ignore them or else it will break completion.
346
+ # Ref: https://github.com/spf13/cobra/issues/1279
347
+ for line in $results[-1..1]
348
+ if test (string trim -- $line) = ""
349
+ # Found an empty line, remove it
350
+ set results $results[1..-2]
351
+ else
352
+ # Found non-empty line, we have our proper output
353
+ break
354
+ end
355
+ end
356
+
357
+ set -l comps $results[1..-2]
358
+ set -l directiveLine $results[-1]
359
+
360
+ # For Fish, when completing a flag with an = (e.g., <program> -n=<TAB>)
361
+ # completions must be prefixed with the flag
362
+ set -l flagPrefix (string match -r -- '-.*=' "$lastArg")
363
+
364
+ __${t}_debug "Comps: $comps"
365
+ __${t}_debug "DirectiveLine: $directiveLine"
366
+ __${t}_debug "flagPrefix: $flagPrefix"
367
+
368
+ for comp in $comps
369
+ printf "%s%s\\n" "$flagPrefix" "$comp"
370
+ end
371
+
372
+ printf "%s\\n" "$directiveLine"
373
+ end
374
+
375
+ # This function limits calls to __${t}_perform_completion, by caching the result
376
+ function __${t}_perform_completion_once
377
+ __${t}_debug "Starting __${t}_perform_completion_once"
378
+
379
+ if test -n "$__${t}_perform_completion_once_result"
380
+ __${t}_debug "Seems like a valid result already exists, skipping __${t}_perform_completion"
381
+ return 0
382
+ end
383
+
384
+ set --global __${t}_perform_completion_once_result (__${t}_perform_completion)
385
+ if test -z "$__${t}_perform_completion_once_result"
386
+ __${t}_debug "No completions, probably due to a failure"
387
+ return 1
388
+ end
389
+
390
+ __${t}_debug "Performed completions and set __${t}_perform_completion_once_result"
391
+ return 0
392
+ end
393
+
394
+ # This function is used to clear the cached result after completions are run
395
+ function __${t}_clear_perform_completion_once_result
396
+ __${t}_debug ""
397
+ __${t}_debug "========= clearing previously set __${t}_perform_completion_once_result variable =========="
398
+ set --erase __${t}_perform_completion_once_result
399
+ __${t}_debug "Successfully erased the variable __${t}_perform_completion_once_result"
400
+ end
401
+
402
+ function __${t}_requires_order_preservation
403
+ __${t}_debug ""
404
+ __${t}_debug "========= checking if order preservation is required =========="
405
+
406
+ __${t}_perform_completion_once
407
+ if test -z "$__${t}_perform_completion_once_result"
408
+ __${t}_debug "Error determining if order preservation is required"
409
+ return 1
410
+ end
411
+
412
+ set -l directive (string sub --start 2 $__${t}_perform_completion_once_result[-1])
413
+ __${t}_debug "Directive is: $directive"
414
+
415
+ set -l shellCompDirectiveKeepOrder ${p.ShellCompDirectiveKeepOrder}
416
+ set -l keeporder (math (math --scale 0 $directive / $shellCompDirectiveKeepOrder) % 2)
417
+ __${t}_debug "Keeporder is: $keeporder"
418
+
419
+ if test $keeporder -ne 0
420
+ __${t}_debug "This does require order preservation"
421
+ return 0
422
+ end
423
+
424
+ __${t}_debug "This doesn't require order preservation"
425
+ return 1
426
+ end
427
+
428
+ # This function does two things:
429
+ # - Obtain the completions and store them in the global __${t}_comp_results
430
+ # - Return false if file completion should be performed
431
+ function __${t}_prepare_completions
432
+ __${t}_debug ""
433
+ __${t}_debug "========= starting completion logic =========="
434
+
435
+ # Start fresh
436
+ set --erase __${t}_comp_results
437
+
438
+ __${t}_perform_completion_once
439
+ __${t}_debug "Completion results: $__${t}_perform_completion_once_result"
440
+
441
+ if test -z "$__${t}_perform_completion_once_result"
442
+ __${t}_debug "No completion, probably due to a failure"
443
+ # Might as well do file completion, in case it helps
444
+ return 1
445
+ end
446
+
447
+ set -l directive (string sub --start 2 $__${t}_perform_completion_once_result[-1])
448
+ set --global __${t}_comp_results $__${t}_perform_completion_once_result[1..-2]
449
+
450
+ __${t}_debug "Completions are: $__${t}_comp_results"
451
+ __${t}_debug "Directive is: $directive"
452
+
453
+ set -l shellCompDirectiveError ${r}
454
+ set -l shellCompDirectiveNoSpace ${i}
455
+ set -l shellCompDirectiveNoFileComp ${n}
456
+ set -l shellCompDirectiveFilterFileExt ${m}
457
+ set -l shellCompDirectiveFilterDirs ${s}
458
+
459
+ if test -z "$directive"
460
+ set directive 0
461
+ end
462
+
463
+ set -l compErr (math (math --scale 0 $directive / $shellCompDirectiveError) % 2)
464
+ if test $compErr -eq 1
465
+ __${t}_debug "Received error directive: aborting."
466
+ # Might as well do file completion, in case it helps
467
+ return 1
468
+ end
469
+
470
+ set -l filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2)
471
+ set -l dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2)
472
+ if test $filefilter -eq 1; or test $dirfilter -eq 1
473
+ __${t}_debug "File extension filtering or directory filtering not supported"
474
+ # Do full file completion instead
475
+ return 1
476
+ end
477
+
478
+ set -l nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) % 2)
479
+ set -l nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) % 2)
480
+
481
+ __${t}_debug "nospace: $nospace, nofiles: $nofiles"
482
+
483
+ # If we want to prevent a space, or if file completion is NOT disabled,
484
+ # we need to count the number of valid completions.
485
+ # To do so, we will filter on prefix as the completions we have received
486
+ # may not already be filtered so as to allow fish to match on different
487
+ # criteria than the prefix.
488
+ if test $nospace -ne 0; or test $nofiles -eq 0
489
+ set -l prefix (commandline -t | string escape --style=regex)
490
+ __${t}_debug "prefix: $prefix"
491
+
492
+ set -l completions (string match -r -- "^$prefix.*" $__${t}_comp_results)
493
+ set --global __${t}_comp_results $completions
494
+ __${t}_debug "Filtered completions are: $__${t}_comp_results"
495
+
496
+ # Important not to quote the variable for count to work
497
+ set -l numComps (count $__${t}_comp_results)
498
+ __${t}_debug "numComps: $numComps"
499
+
500
+ if test $numComps -eq 1; and test $nospace -ne 0
501
+ # We must first split on \\t to get rid of the descriptions to be
502
+ # able to check what the actual completion will be.
503
+ # We don't need descriptions anyway since there is only a single
504
+ # real completion which the shell will expand immediately.
505
+ set -l split (string split --max 1 "\\t" $__${t}_comp_results[1])
506
+
507
+ # Fish won't add a space if the completion ends with any
508
+ # of the following characters: @=/:.,
509
+ set -l lastChar (string sub -s -1 -- $split)
510
+ if not string match -r -q "[@=/:.,]" -- "$lastChar"
511
+ # In other cases, to support the "nospace" directive we trick the shell
512
+ # by outputting an extra, longer completion.
513
+ __${t}_debug "Adding second completion to perform nospace directive"
514
+ set --global __${t}_comp_results $split[1] $split[1].
515
+ __${t}_debug "Completions are now: $__${t}_comp_results"
516
+ end
517
+ end
518
+
519
+ if test $numComps -eq 0; and test $nofiles -eq 0
520
+ # To be consistent with bash and zsh, we only trigger file
521
+ # completion when there are no other completions
522
+ __${t}_debug "Requesting file completion"
523
+ return 1
524
+ end
525
+ end
526
+
527
+ return 0
528
+ end
529
+
530
+ # Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
531
+ # so we can properly delete any completions provided by another script.
532
+ # Only do this if the program can be found, or else fish may print some errors; besides,
533
+ # the existing completions will only be loaded if the program can be found.
534
+ if type -q "${e}"
535
+ # The space after the program name is essential to trigger completion for the program
536
+ # and not completion of the program name itself.
537
+ # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
538
+ complete --do-complete "${e} " > /dev/null 2>&1
539
+ end
540
+
541
+ # Remove any pre-existing completions for the program since we will be handling all of them.
542
+ complete -c ${e} -e
543
+
544
+ # This will get called after the two calls below and clear the cached result
545
+ complete -c ${e} -n '__${t}_clear_perform_completion_once_result'
546
+ # The call to __${t}_prepare_completions will setup __${t}_comp_results
547
+ # which provides the program's completion choices.
548
+ # If this doesn't require order preservation, we don't use the -k flag
549
+ complete -c ${e} -n 'not __${t}_requires_order_preservation && __${t}_prepare_completions' -f -a '$__${t}_comp_results'
550
+ # Otherwise we use the -k flag
551
+ complete -k -c ${e} -n '__${t}_requires_order_preservation && __${t}_prepare_completions' -f -a '$__${t}_comp_results'
552
+ `}function ve(e,o){let t=e.replace(/[-:]/g,"_");return`# powershell completion for ${e} -*- shell-script -*-
553
+
554
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
555
+ function __${e}_debug {
556
+ if ($env:BASH_COMP_DEBUG_FILE) {
557
+ "$args" | Out-File -Append -FilePath "$env:BASH_COMP_DEBUG_FILE"
558
+ }
559
+ }
560
+
561
+ filter __${e}_escapeStringWithSpecialChars {
562
+ $_ -replace '\\s|#|@|\\$|;|,|''|\\{|\\}|\\(|\\)|"|\\||<|>|&','\`$&'
563
+ }
564
+
565
+ [scriptblock]$__${t}CompleterBlock = {
566
+ param(
567
+ $WordToComplete,
568
+ $CommandAst,
569
+ $CursorPosition
570
+ )
571
+
572
+ # Get the current command line and convert into a string
573
+ $Command = $CommandAst.CommandElements
574
+ $Command = "$Command"
575
+
576
+ __${e}_debug ""
577
+ __${e}_debug "========= starting completion logic =========="
578
+ __${e}_debug "WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition"
579
+
580
+ # The user could have moved the cursor backwards on the command-line.
581
+ # We need to trigger completion from the $CursorPosition location, so we need
582
+ # to truncate the command-line ($Command) up to the $CursorPosition location.
583
+ # Make sure the $Command is longer then the $CursorPosition before we truncate.
584
+ # This happens because the $Command does not include the last space.
585
+ if ($Command.Length -gt $CursorPosition) {
586
+ $Command = $Command.Substring(0, $CursorPosition)
587
+ }
588
+ __${e}_debug "Truncated command: $Command"
589
+
590
+ $ShellCompDirectiveError=${p.ShellCompDirectiveError}
591
+ $ShellCompDirectiveNoSpace=${p.ShellCompDirectiveNoSpace}
592
+ $ShellCompDirectiveNoFileComp=${p.ShellCompDirectiveNoFileComp}
593
+ $ShellCompDirectiveFilterFileExt=${p.ShellCompDirectiveFilterFileExt}
594
+ $ShellCompDirectiveFilterDirs=${p.ShellCompDirectiveFilterDirs}
595
+ $ShellCompDirectiveKeepOrder=${p.ShellCompDirectiveKeepOrder}
596
+
597
+ # Prepare the command to request completions for the program.
598
+ # Split the command at the first space to separate the program and arguments.
599
+ $Program, $Arguments = $Command.Split(" ", 2)
600
+
601
+ $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ' '
602
+ __${e}_debug "QuotedArgs: $QuotedArgs"
603
+
604
+ $RequestComp = "& ${o} complete '--' $QuotedArgs"
605
+ __${e}_debug "RequestComp: $RequestComp"
606
+
607
+ # we cannot use $WordToComplete because it
608
+ # has the wrong values if the cursor was moved
609
+ # so use the last argument
610
+ if ($WordToComplete -ne "" ) {
611
+ $WordToComplete = $Arguments.Split(" ")[-1]
612
+ }
613
+ __${e}_debug "New WordToComplete: $WordToComplete"
614
+
615
+
616
+ # Check for flag with equal sign
617
+ $IsEqualFlag = ($WordToComplete -Like "--*=*" )
618
+ if ( $IsEqualFlag ) {
619
+ __${e}_debug "Completing equal sign flag"
620
+ # Remove the flag part
621
+ $Flag, $WordToComplete = $WordToComplete.Split("=", 2)
622
+ }
623
+ $HasTrailingEmptyArg = $QuotedArgs -match "(^| )''$"
624
+ __${e}_debug "HasTrailingEmptyArg: $HasTrailingEmptyArg"
625
+
626
+ if ( $WordToComplete -eq "" -And ( -Not $IsEqualFlag ) -And ( -Not $HasTrailingEmptyArg )) {
627
+ # If the last parameter is complete (there is a space following it)
628
+ # We add an extra empty parameter so we can indicate this to the go method.
629
+ __${e}_debug "Adding extra empty parameter"
630
+ # PowerShell 7.2+ changed the way how the arguments are passed to executables,
631
+ # so for pre-7.2 or when Legacy argument passing is enabled we need to use
632
+ if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or
633
+ ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -or
634
+ (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled("PSNativeCommandArgumentPassing")) -and
635
+ $PSNativeCommandArgumentPassing -eq 'Legacy')) {
636
+ $RequestComp="$RequestComp" + ' \`"\`"'
637
+ } else {
638
+ $RequestComp = "$RequestComp" + ' ""'
639
+ }
640
+ }
641
+
642
+ __${e}_debug "Calling $RequestComp"
643
+ # First disable ActiveHelp which is not supported for Powershell
644
+ $env:ActiveHelp = 0
645
+
646
+ # call the command store the output in $out and redirect stderr and stdout to null
647
+ # $Out is an array contains each line per element
648
+ Invoke-Expression -OutVariable out "$RequestComp" 2>&1 | Out-Null
649
+
650
+ # get directive from last line
651
+ [int]$Directive = $Out[-1].TrimStart(':')
652
+ if ($Directive -eq "") {
653
+ # There is no directive specified
654
+ $Directive = 0
655
+ }
656
+ __${e}_debug "The completion directive is: $Directive"
657
+
658
+ # remove directive (last element) from out
659
+ $Out = $Out | Where-Object { $_ -ne $Out[-1] }
660
+ __${e}_debug "The completions are: $Out"
661
+
662
+ if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {
663
+ # Error code. No completion.
664
+ __${e}_debug "Received error from custom completion go code"
665
+ return
666
+ }
667
+
668
+ $Longest = 0
669
+ [Array]$Values = $Out | ForEach-Object {
670
+ # Split the output in name and description
671
+ $Name, $Description = $_.Split("\`t", 2)
672
+ __${e}_debug "Name: $Name Description: $Description"
673
+
674
+ # Look for the longest completion so that we can format things nicely
675
+ if ($Longest -lt $Name.Length) {
676
+ $Longest = $Name.Length
677
+ }
678
+
679
+ # Set the description to a one space string if there is none set.
680
+ # This is needed because the CompletionResult does not accept an empty string as argument
681
+ if (-Not $Description) {
682
+ $Description = " "
683
+ }
684
+ @{ Name = "$Name"; Description = "$Description" }
685
+ }
686
+
687
+
688
+ $Space = " "
689
+ if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {
690
+ # remove the space here
691
+ __${e}_debug "ShellCompDirectiveNoSpace is called"
692
+ $Space = ""
693
+ }
694
+
695
+ if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or
696
+ (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {
697
+ __${e}_debug "ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported"
698
+
699
+ # return here to prevent the completion of the extensions
700
+ return
701
+ }
702
+
703
+ $Values = $Values | Where-Object {
704
+ # filter the result
705
+ $_.Name -like "$WordToComplete*"
706
+
707
+ # Join the flag back if we have an equal sign flag
708
+ if ( $IsEqualFlag ) {
709
+ __${e}_debug "Join the equal sign flag back to the completion value"
710
+ $_.Name = $Flag + "=" + $_.Name
711
+ }
712
+ }
713
+
714
+ # we sort the values in ascending order by name if keep order isn't passed
715
+ if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {
716
+ $Values = $Values | Sort-Object -Property Name
717
+ }
718
+
719
+ if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {
720
+ __${e}_debug "ShellCompDirectiveNoFileComp is called"
721
+
722
+ if ($Values.Length -eq 0) {
723
+ # Just print an empty string here so the
724
+ # shell does not start to complete paths.
725
+ # We cannot use CompletionResult here because
726
+ # it does not accept an empty string as argument.
727
+ ""
728
+ return
729
+ }
730
+ }
731
+
732
+ # Get the current mode
733
+ $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq "Tab" }).Function
734
+ __${e}_debug "Mode: $Mode"
735
+
736
+ $Values | ForEach-Object {
737
+
738
+ # store temporary because switch will overwrite $_
739
+ $comp = $_
740
+
741
+ # PowerShell supports three different completion modes
742
+ # - TabCompleteNext (default windows style - on each key press the next option is displayed)
743
+ # - Complete (works like bash)
744
+ # - MenuComplete (works like zsh)
745
+ # You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>
746
+
747
+ # CompletionResult Arguments:
748
+ # 1) CompletionText text to be used as the auto completion result
749
+ # 2) ListItemText text to be displayed in the suggestion list
750
+ # 3) ResultType type of completion result
751
+ # 4) ToolTip text for the tooltip with details about the object
752
+
753
+ switch ($Mode) {
754
+
755
+ # bash like
756
+ "Complete" {
757
+
758
+ if ($Values.Length -eq 1) {
759
+ __${e}_debug "Only one completion left"
760
+
761
+ # insert space after value
762
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${e}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
763
+
764
+ } else {
765
+ # Add the proper number of spaces to align the descriptions
766
+ while($comp.Name.Length -lt $Longest) {
767
+ $comp.Name = $comp.Name + " "
768
+ }
769
+
770
+ # Check for empty description and only add parentheses if needed
771
+ if ($($comp.Description) -eq " " ) {
772
+ $Description = ""
773
+ } else {
774
+ $Description = " ($($comp.Description))"
775
+ }
776
+
777
+ [System.Management.Automation.CompletionResult]::new("$($comp.Name)$Description", "$($comp.Name)$Description", 'ParameterValue', "$($comp.Description)")
778
+ }
779
+ }
780
+
781
+ # zsh like
782
+ "MenuComplete" {
783
+ # insert space after value
784
+ # MenuComplete will automatically show the ToolTip of
785
+ # the highlighted value at the bottom of the suggestions.
786
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${e}_escapeStringWithSpecialChars) + $Space, "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
787
+ }
788
+
789
+ # TabCompleteNext and in case we get something unknown
790
+ Default {
791
+ # Like MenuComplete but we don't want to add a space here because
792
+ # the user need to press space anyway to get the completion.
793
+ # Description will not be shown because that's not possible with TabCompleteNext
794
+ [System.Management.Automation.CompletionResult]::new($($comp.Name | __${e}_escapeStringWithSpecialChars), "$($comp.Name)", 'ParameterValue', "$($comp.Description)")
795
+ }
796
+ }
797
+
798
+ }
799
+ }
800
+
801
+ Register-ArgumentCompleter -CommandName '${e}' -ScriptBlock $__${t}CompleterBlock
802
+ `}var ye=S(require("node:assert"),1),p={ShellCompDirectiveError:1,ShellCompDirectiveNoSpace:2,ShellCompDirectiveNoFileComp:4,ShellCompDirectiveFilterFileExt:8,ShellCompDirectiveFilterDirs:16,ShellCompDirectiveKeepOrder:32,shellCompDirectiveMaxValue:64,ShellCompDirectiveDefault:0},ot=class{name;variadic;command;handler;constructor(e,o,t,r=!1){this.command=e,this.name=o,this.handler=t,this.variadic=r}},it=class{value;description;command;handler;alias;isBoolean;constructor(e,o,t,r,i,n){this.command=e,this.value=o,this.description=t,this.handler=r,this.alias=i,this.isBoolean=n}},be=class{value;description;options=new Map;arguments=new Map;parent;constructor(e,o){this.value=e,this.description=o}option(e,o,t,r){let i,n,m;typeof t=="function"?(i=t,n=r,m=!1):typeof t=="string"?(i=void 0,n=t,m=!0):(i=void 0,n=void 0,m=!0);let s=new it(this,e,o,i,n,m);return this.options.set(e,s),this}argument(e,o,t=!1){let r=new ot(this,e,o,t);return this.arguments.set(e,r),this}},rt=class extends be{commands=new Map;completions=[];directive=p.ShellCompDirectiveDefault;constructor(){super("","")}command(e,o){let t=new be(e,o);return this.commands.set(e,t),t}stripOptions(e){let o=[],t=0;for(;t<e.length;){let r=e[t];if(r.startsWith("-")){t++;let i=!1,n=this.findOption(this,r);if(n)i=n.isBoolean??!1;else for(let[,m]of this.commands){let s=this.findOption(m,r);if(s){i=s.isBoolean??!1;break}}!i&&t<e.length&&!e[t].startsWith("-")&&t++}else o.push(r),t++}return o}matchCommand(e){e=this.stripOptions(e);let o=[],t=[],r=null;for(let i=0;i<e.length;i++){let n=e[i];o.push(n);let m=this.commands.get(o.join(" "));if(m)r=m;else{t=e.slice(i,e.length);break}}return[r||this,t]}shouldCompleteFlags(e,o){if(o.startsWith("-"))return!0;if(e?.startsWith("-")){let t=this.findOption(this,e);if(!t){for(let[,r]of this.commands)if(t=this.findOption(r,e),t)break}return!(t&&t.isBoolean)}return!1}shouldCompleteCommands(e){return!e.startsWith("-")}handleFlagCompletion(e,o,t,r){let i;if(t.includes("=")){let[n]=t.split("=");i=n}else if(r?.startsWith("-")){let n=this.findOption(e,r);n&&!n.isBoolean&&(i=r)}if(i){let n=this.findOption(e,i);if(n?.handler){let m=[];n.handler.call(n,(s,d)=>m.push({value:s,description:d}),e.options),this.completions=m}return}if(t.startsWith("-")){let n=t.startsWith("-")&&!t.startsWith("--"),m=t.replace(/^-+/,"");for(let[s,d]of e.options)n&&d.alias&&`-${d.alias}`.startsWith(t)?this.completions.push({value:`-${d.alias}`,description:d.description}):!n&&s.startsWith(m)&&this.completions.push({value:`--${s}`,description:d.description})}}findOption(e,o){let t=e.options.get(o);if(t||(t=e.options.get(o.replace(/^-+/,"")),t))return t;for(let[r,i]of e.options)if(i.alias&&`-${i.alias}`===o)return i}handleCommandCompletion(e,o){let t=this.stripOptions(e);for(let[r,i]of this.commands){if(r==="")continue;let n=r.split(" ");n.slice(0,t.length).every((m,s)=>m===t[s])&&n[t.length]?.startsWith(o)&&this.completions.push({value:n[t.length],description:i.description})}}handlePositionalCompletion(e,o){let t=this.stripOptions(o),r=e.value.split(" ").length,i=Math.max(0,t.length-r),n=Array.from(e.arguments.entries());if(n.length>0){let m;if(i<n.length){let[s,d]=n[i];m=d}else{let s=n[n.length-1][1];s.variadic&&(m=s)}if(m&&m.handler&&typeof m.handler=="function"){let s=[];m.handler.call(m,(d,h)=>s.push({value:d,description:h}),e.options),this.completions.push(...s)}}}complete(e){this.directive=p.ShellCompDirectiveNoFileComp;let o=new Set;this.completions.filter(t=>o.has(t.value)?!1:(o.add(t.value),!0)).filter(t=>{if(e.includes("=")){let[,r]=e.split("=");return t.value.startsWith(r)}return t.value.startsWith(e)}).forEach(t=>console.log(`${t.value} ${t.description??""}`)),console.log(`:${this.directive}`)}parse(e){this.completions=[];let o=e[e.length-1]==="";o&&e.pop();let t=e[e.length-1]||"",r=e.slice(0,-1);o&&(t!==""&&r.push(t),t="");let[i]=this.matchCommand(r),n=r[r.length-1];this.shouldCompleteFlags(n,t)?this.handleFlagCompletion(i,r,t,n):(this.shouldCompleteCommands(t)&&this.handleCommandCompletion(r,t),i&&i.arguments.size>0&&this.handlePositionalCompletion(i,r)),this.complete(t)}setup(e,o,t){switch((0,ye.default)(t==="zsh"||t==="bash"||t==="fish"||t==="powershell","Unsupported shell"),t){case"zsh":{let r=Ce(e,o);console.log(r);break}case"bash":{let r=_e(e,o);console.log(r);break}case"fish":{let r=$e(e,o);console.log(r);break}case"powershell":{let r=ve(e,o);console.log(r);break}}}},w=new rt;var F,xe,Pe,De,Se=!0;typeof process<"u"&&({FORCE_COLOR:F,NODE_DISABLE_COLORS:xe,NO_COLOR:Pe,TERM:De}=process.env||{},Se=process.stdout&&process.stdout.isTTY);var nt={enabled:!xe&&Pe==null&&De!=="dumb"&&(F!=null&&F!=="0"||Se)};function c(e,o){let t=new RegExp(`\\x1b\\[${o}m`,"g"),r=`\x1B[${e}m`,i=`\x1B[${o}m`;return function(n){return!nt.enabled||n==null?n:r+(~(""+n).indexOf(i)?n.replace(t,i+r):n)+i}}var St=c(0,0),st=c(1,22),wt=c(2,22),Et=c(3,23),Ot=c(4,24),kt=c(7,27),Tt=c(8,28),Ft=c(9,29),Nt=c(30,39),at=c(31,39),At=c(32,39),Rt=c(33,39),It=c(34,39),qt=c(35,39),Lt=c(36,39),Mt=c(37,39),Wt=c(90,39),Gt=c(90,39),Ht=c(40,49),Vt=c(41,49),Bt=c(42,49),Ut=c(43,49),jt=c(44,49),Kt=c(45,49),Qt=c(46,49),zt=c(47,49);var l=[{value:"prisma/schema.prisma",description:"Default schema path"},{value:"./schema.prisma",description:"Schema in project root"}],a=[{value:"prisma7.config.ts",description:"Default config path"}],g=[{value:"postgresql://",description:"PostgreSQL connection string"},{value:"mysql://",description:"MySQL connection string"},{value:"file:",description:"SQLite connection string"},{value:"mongodb://",description:"MongoDB connection string"},{value:"sqlserver://",description:"SQL Server connection string"}],x=[{value:"<your-api-key>",description:"Workspace API key"}],P=[{value:"db_",description:"Database ID prefix (e.g. db_abc123)"}],N=[{value:"prisma-client",description:"Prisma Client generator"},{value:"prisma-client-js",description:"Legacy Prisma Client JS generator"}],A=[{value:"./generated/prisma",description:"Common client output path"},{value:"../generated/prisma",description:"Alternative client output path"}],R=[{value:"typedSql",description:"TypedSQL preview feature"}],I=[{value:"./script.sql",description:"SQL script file"}],E=[{value:"prisma/migrations",description:"Default migrations directory"},{value:"./migrations",description:"Custom migrations directory"}],q=[{value:"diff.sql",description:"SQL diff output file"}],L=[{value:"init",description:"Initial migration name"},{value:"add_users",description:"Example migration name"}],O=[{value:"20201231000000_add_users_table",description:"Example migration ID"}],M=[{value:"-1",description:"Infinite depth (default)"},{value:"0",description:"Off"},{value:"2",description:"Two levels deep"}],W=[{value:"public",description:"PostgreSQL default schema"}],G=[{value:"postgresql",description:"PostgreSQL"},{value:"mysql",description:"MySQL"},{value:"sqlite",description:"SQLite"},{value:"mongodb",description:"MongoDB"},{value:"sqlserver",description:"SQL Server"},{value:"cockroachdb",description:"CockroachDB"}],H=[{value:"prisma-client",description:"Prisma Client"},{value:"prisma-client-js",description:"Legacy Prisma Client JS"}],V=[{value:"51212",description:"Default Studio port"},{value:"5555",description:"Common custom port"},{value:"3000",description:"Alternative port"}],B=[{value:"none",description:"Do not open browser"},{value:"chrome",description:"Google Chrome"},{value:"firefox",description:"Mozilla Firefox"},{value:"safari",description:"Safari"}],U=[{value:"default",description:"Default server name"}],j=[{value:"51213",description:"Default HTTP server port"}],K=[{value:"51214",description:"Default database port"}],Q=[{value:"51215",description:"Default shadow database port"}];var b=class e extends Error{constructor(o){super(o),this.name="HelpError",Object.setPrototypeOf(this,e.prototype)}};var Te=S(Ee());var lt=S(ke(),1);function Y(e,o,t=!0,r=!1){try{return(0,Te.default)(o,{argv:e,stopAtPositional:t,permissive:r})}catch(i){return i}}function J(e){return e instanceof Error}var X={name:"db",description:"Manage your database schema and lifecycle",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"schema",description:"Custom path to your Prisma schema",values:l}]};var Z={name:"db execute",description:"Execute SQL or scripts on your database",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"file",description:"Path to a file containing the script to execute",values:I},{name:"stdin",description:"Use terminal standard input as the script to execute"}]};var ee={name:"db pull",description:"Pull the schema from an existing database",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"url",description:"Override the datasource URL from the Prisma config file",values:g},{name:"force",description:"Ignore current Prisma schema file"},{name:"print",description:"Print the introspected Prisma schema to stdout"},{name:"composite-type-depth",description:"Specify the depth for introspecting composite types",values:M},{name:"schemas",description:"Specify database schemas to introspect (overrides datasource block)",values:W}]};var te={name:"db push",description:"Push the Prisma schema state to the database",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"url",description:"Override the datasource URL from the Prisma config file",values:g},{name:"accept-data-loss",description:"Ignore data loss warnings"},{name:"force-reset",description:"Force a reset of the database before push"}]};var oe={name:"db seed",description:"Seed your database",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a}]};var ie={name:"migrate",description:"Migrate your database",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"schema",description:"Custom path to your Prisma schema",values:l}]};var re={name:"migrate deploy",description:"Apply pending migrations to the database",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a}]};var ne={name:"migrate dev",description:"Create and apply migrations in development",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"url",description:"Override the datasource URL from the Prisma config file",values:g},{name:"name",alias:"n",description:"Name the migration",values:L},{name:"create-only",description:"Create a new migration but do not apply it"}]};var se={name:"migrate diff",description:"Compare the database schema from two arbitrary sources",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"output",alias:"o",description:"Write the diff to a file instead of stdout",values:q},{name:"from-empty",description:"Assume the source data model is empty"},{name:"from-schema",description:"Path to a Prisma schema file as the source",values:l},{name:"from-migrations",description:"Path to a Prisma migrations directory as the source",values:E},{name:"from-config-datasource",description:"Use the datasource from the Prisma config file as the source"},{name:"to-empty",description:"Assume the destination data model is empty"},{name:"to-schema",description:"Path to a Prisma schema file as the destination",values:l},{name:"to-migrations",description:"Path to a Prisma migrations directory as the destination",values:E},{name:"to-config-datasource",description:"Use the datasource from the Prisma config file as the destination"},{name:"script",description:"Output a SQL script instead of a human-readable summary"},{name:"exit-code",description:"Change the exit code behavior (Empty=0, Error=1, Not empty=2)"}]};var ae={name:"migrate reset",description:"Reset your database and apply all migrations",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"force",alias:"f",description:"Skip the confirmation prompt"}]};var le={name:"migrate resolve",description:"Mark a migration as applied or rolled back",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"applied",description:"Mark a migration as applied",values:O},{name:"rolled-back",description:"Mark a migration as rolled back",values:O}]};var me={name:"migrate status",description:"Check the status of your database migrations",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a}]};var Fe=[{name:"nextjs",label:"Next.js"},{name:"express",label:"Express"},{name:"hono",label:"Hono"},{name:"fastify",label:"Fastify"},{name:"nuxt",label:"Nuxt"},{name:"sveltekit",label:"SvelteKit"},{name:"remix",label:"Remix"},{name:"react-router-7",label:"React Router 7"},{name:"astro",label:"Astro"},{name:"nest",label:"NestJS"}];var Ne={name:"bootstrap",description:"Bootstrap a Prisma Postgres project",options:[{name:"api-key",description:"Workspace API key (CI / non-interactive)",values:x},{name:"database",description:"Database ID to link to (e.g. db_abc123)",values:P},{name:"template",description:"Starter template name",values:Fe.map(({name:e,label:o})=>({value:e,description:`${o} starter`}))},{name:"force",description:"Re-link even if already linked to Prisma Postgres"}]};var Ae={name:"debug",description:"Displays Prisma debug info",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a}]};var Re={name:"format",description:"Format your Prisma schema",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"check",description:"Check if the schema is formatted"}]};var Ie={name:"generate",description:"Generate artifacts (e.g. Prisma Client)",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"watch",description:"Watch the Prisma schema and rerun after a change"},{name:"generator",description:"Generator to use (may be provided multiple times)",values:N},{name:"no-hints",description:"Hides the hint messages but still outputs errors and warnings"},{name:"require-models",description:"Do not allow generating a client without models"},{name:"sql",description:"Generate TypedSQL module"}]};var qe={name:"init",description:"Set up Prisma for your app",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"url",description:"Define a custom datasource url",values:g},{name:"datasource-provider",description:"Define the datasource provider",values:G},{name:"generator-provider",description:"Define the generator provider",values:H},{name:"preview-feature",description:"Define a preview feature to use (can be specified multiple times)",values:R},{name:"output",description:"Define Prisma Client generator output path",values:A},{name:"with-model",description:"Add an example model to the created schema file"},{name:"db",description:"Provision a fully managed Prisma Postgres database on the Prisma Data Platform"}]};var Le={name:"mcp",description:"Starts an MCP server to use with AI development tools",options:[{name:"early-access",description:"Enable early access features"}]};var Me={name:"platform",description:"Prisma Data Platform commands",options:[{name:"help",alias:"h",description:"Display this help message"}],subcommands:[{name:"platform status",description:"Show Prisma Data Platform service status",options:[{name:"help",alias:"h",description:"Display this help message"}]}]};var We={name:"postgres link",description:"Link a local project to a Prisma Postgres database",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"api-key",description:"Workspace API key (CI / non-interactive)",values:x},{name:"database",description:"Database ID to link to (e.g. db_abc123)",values:P},{name:"force",description:"Re-link even if already linked to Prisma Postgres"}]};var Ge={name:"postgres",description:"Manage Prisma Postgres databases",options:[{name:"help",alias:"h",description:"Display this help message"}]};var He={name:"studio",description:"Browse your data with Prisma Studio",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"config",description:"Custom path to your Prisma config file",values:a},{name:"url",description:"Database connection string (overrides the one in your Prisma config file)",values:g},{name:"port",alias:"p",description:"Port to start Studio on",values:V},{name:"browser",alias:"b",description:"Browser to auto-open Studio in",values:B}]};var Ve={name:"validate",description:"Validate your Prisma schema",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"schema",description:"Custom path to your Prisma schema",values:l},{name:"config",description:"Custom path to your Prisma config file",values:a}]};var Be={name:"version",description:"Displays Prisma version info",options:[{name:"help",alias:"h",description:"Display this help message"},{name:"json",description:"Output version information as JSON"}]};var mt={name:"dev",description:"Start a local Prisma Postgres server for development",options:[{name:"name",alias:"n",description:"Name of the server (helps keep state isolated between different projects)",values:U},{name:"port",alias:"p",description:"Main port number for the HTTP server",values:j},{name:"db-port",alias:"P",description:"Port number for the database server",values:K},{name:"shadow-db-port",description:"Port number for the shadow database server",values:Q},{name:"detach",alias:"d",description:"Run the server in the background"},{name:"debug",description:"Enable debug logging"}]},k={name:"debug",description:"Enable debug logging"},pt={name:"dev ls",description:"List available servers",options:[k]},ct={name:"dev rm",description:"Remove servers",options:[k,{name:"force",description:"Stop any running servers before removing them"}]},dt={name:"dev start",description:"Start one or more stopped servers",options:[k]},ut={name:"dev stop",description:"Stop servers",options:[k]},T=["zsh","bash","fish","powershell"],ht={name:"complete",description:"Generate shell completion script",subcommands:T.map(e=>({name:`complete ${e}`,description:`Generate completion script for ${e}`}))},Ue=[qe,Ne,mt,pt,ct,dt,ut,Ie,He,Ve,Re,Be,Ae,Le,Me,Ge,We,ht,X,Z,ee,te,oe,ie,ne,ae,re,me,le,se];function Ke(e){let o=w.command(e.name,e.description);for(let t of e.options??[])ft(o,t);for(let t of e.subcommands??[])Ke(t)}function ft(e,o){if(o.values===void 0){o.alias!==void 0?e.option(o.name,o.description,o.alias):e.option(o.name,o.description);return}e.option(o.name,o.description,t=>{let r=typeof o.values=="function"?o.values():o.values??[];for(let i of r)t(i.value,i.description??"")},o.alias)}function Qe(e,o){if(e[0]==="--"){je();try{return w.parse(e.slice(1)),""}catch(i){return new Error(`Failed to parse completions: ${i}`)}}let t=Y(e,{});if(J(t))return new b(t.message);let r=t._[0];if(r&&T.includes(r)){je();try{return w.setup(o,o,r),""}catch(i){return new Error(`Failed to setup completions: ${i}`)}}return new b(`Invalid shell type. Must be one of: ${T.join(", ")}`)}function je(){for(let e of Ue)Ke(e)}var pe=Qe(process.argv.slice(3),ge());pe instanceof Error?(console.error(pe.message),process.exitCode=1):console.log(pe);