effect 4.0.0-beta.106 → 4.0.0-beta.107

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 (62) hide show
  1. package/dist/Channel.d.ts +26 -0
  2. package/dist/Channel.d.ts.map +1 -1
  3. package/dist/Channel.js +47 -0
  4. package/dist/Channel.js.map +1 -1
  5. package/dist/Duration.d.ts.map +1 -1
  6. package/dist/Duration.js +13 -1
  7. package/dist/Duration.js.map +1 -1
  8. package/dist/SchemaRepresentation.d.ts +29 -4
  9. package/dist/SchemaRepresentation.d.ts.map +1 -1
  10. package/dist/SchemaRepresentation.js +7 -2
  11. package/dist/SchemaRepresentation.js.map +1 -1
  12. package/dist/Stream.d.ts +10 -0
  13. package/dist/Stream.d.ts.map +1 -1
  14. package/dist/Stream.js +12 -23
  15. package/dist/Stream.js.map +1 -1
  16. package/dist/internal/schema/fromJsonSchemaDocument.js +22 -10
  17. package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
  18. package/dist/unstable/ai/McpSchema.d.ts +88 -88
  19. package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
  20. package/dist/unstable/cli/Argument.d.ts +6 -3
  21. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  22. package/dist/unstable/cli/Argument.js +2 -1
  23. package/dist/unstable/cli/Argument.js.map +1 -1
  24. package/dist/unstable/cli/CliError.d.ts +20 -1
  25. package/dist/unstable/cli/CliError.d.ts.map +1 -1
  26. package/dist/unstable/cli/CliError.js +26 -2
  27. package/dist/unstable/cli/CliError.js.map +1 -1
  28. package/dist/unstable/cli/Command.d.ts +23 -0
  29. package/dist/unstable/cli/Command.d.ts.map +1 -1
  30. package/dist/unstable/cli/Command.js +23 -4
  31. package/dist/unstable/cli/Command.js.map +1 -1
  32. package/dist/unstable/http/Multipart.d.ts +2 -0
  33. package/dist/unstable/http/Multipart.d.ts.map +1 -1
  34. package/dist/unstable/http/Multipart.js +4 -12
  35. package/dist/unstable/http/Multipart.js.map +1 -1
  36. package/dist/unstable/http/MultipartParser/internal/headers.d.ts.map +1 -1
  37. package/dist/unstable/http/MultipartParser/internal/headers.js +16 -2
  38. package/dist/unstable/http/MultipartParser/internal/headers.js.map +1 -1
  39. package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -1
  40. package/dist/unstable/http/MultipartParser/internal/multipart.js +13 -10
  41. package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -1
  42. package/dist/unstable/process/ChildProcess.d.ts +8 -0
  43. package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
  44. package/dist/unstable/process/ChildProcess.js.map +1 -1
  45. package/dist/unstable/sql/Migrator.d.ts +9 -1
  46. package/dist/unstable/sql/Migrator.d.ts.map +1 -1
  47. package/dist/unstable/sql/Migrator.js +15 -2
  48. package/dist/unstable/sql/Migrator.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/Channel.ts +58 -0
  51. package/src/Duration.ts +12 -1
  52. package/src/SchemaRepresentation.ts +29 -4
  53. package/src/Stream.ts +12 -30
  54. package/src/internal/schema/fromJsonSchemaDocument.ts +17 -4
  55. package/src/unstable/cli/Argument.ts +6 -3
  56. package/src/unstable/cli/CliError.ts +28 -2
  57. package/src/unstable/cli/Command.ts +44 -4
  58. package/src/unstable/http/Multipart.ts +4 -13
  59. package/src/unstable/http/MultipartParser/internal/headers.ts +16 -387
  60. package/src/unstable/http/MultipartParser/internal/multipart.ts +14 -10
  61. package/src/unstable/process/ChildProcess.ts +8 -0
  62. package/src/unstable/sql/Migrator.ts +22 -9
@@ -12,394 +12,23 @@ type State = (typeof State)[keyof typeof State]
12
12
 
13
13
  const constContinue: Continue = { _tag: "Continue" }
14
14
 
15
- const constNameChars = [
16
- 0,
17
- 0,
18
- 0,
19
- 0,
20
- 0,
21
- 0,
22
- 0,
23
- 0,
24
- 0,
25
- 0,
26
- 0,
27
- 0,
28
- 0,
29
- 0,
30
- 0,
31
- 0,
32
- 0,
33
- 0,
34
- 0,
35
- 0,
36
- 0,
37
- 0,
38
- 0,
39
- 0,
40
- 0,
41
- 0,
42
- 0,
43
- 0,
44
- 0,
45
- 0,
46
- 0,
47
- 0,
48
- 0,
49
- 1,
50
- 0,
51
- 1,
52
- 1,
53
- 1,
54
- 1,
55
- 1,
56
- 0,
57
- 0,
58
- 1,
59
- 1,
60
- 0,
61
- 1,
62
- 1,
63
- 0,
64
- 1,
65
- 1,
66
- 1,
67
- 1,
68
- 1,
69
- 1,
70
- 1,
71
- 1,
72
- 1,
73
- 1,
74
- 0,
75
- 0,
76
- 0,
77
- 0,
78
- 0,
79
- 0,
80
- 0,
81
- 1,
82
- 1,
83
- 1,
84
- 1,
85
- 1,
86
- 1,
87
- 1,
88
- 1,
89
- 1,
90
- 1,
91
- 1,
92
- 1,
93
- 1,
94
- 1,
95
- 1,
96
- 1,
97
- 1,
98
- 1,
99
- 1,
100
- 1,
101
- 1,
102
- 1,
103
- 1,
104
- 1,
105
- 1,
106
- 1,
107
- 0,
108
- 0,
109
- 0,
110
- 1,
111
- 1,
112
- 1,
113
- 1,
114
- 1,
115
- 1,
116
- 1,
117
- 1,
118
- 1,
119
- 1,
120
- 1,
121
- 1,
122
- 1,
123
- 1,
124
- 1,
125
- 1,
126
- 1,
127
- 1,
128
- 1,
129
- 1,
130
- 1,
131
- 1,
132
- 1,
133
- 1,
134
- 1,
135
- 1,
136
- 1,
137
- 1,
138
- 1,
139
- 0,
140
- 1,
141
- 0,
142
- 1
143
- ]
15
+ // RFC 7230 token characters, allowed in header names
16
+ // The previous table stopped at byte 126; zero-filled entries for bytes 127-255
17
+ // preserve its rejection behavior because callers accept only entries equal to 1.
18
+ const constNameChars = new Uint8Array(256)
19
+ for (const char of "!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") {
20
+ constNameChars[char.charCodeAt(0)] = 1
21
+ }
144
22
 
145
- const constValueChars = [
146
- 0,
147
- 0,
148
- 0,
149
- 0,
150
- 0,
151
- 0,
152
- 0,
153
- 0,
154
- 0,
155
- 1,
156
- 0,
157
- 0,
158
- 0,
159
- 0,
160
- 0,
161
- 0,
162
- 0,
163
- 0,
164
- 0,
165
- 0,
166
- 0,
167
- 0,
168
- 0,
169
- 0,
170
- 0,
171
- 0,
172
- 0,
173
- 0,
174
- 0,
175
- 0,
176
- 0,
177
- 0,
178
- 1,
179
- 1,
180
- 1,
181
- 1,
182
- 1,
183
- 1,
184
- 1,
185
- 1,
186
- 1,
187
- 1,
188
- 1,
189
- 1,
190
- 1,
191
- 1,
192
- 1,
193
- 1,
194
- 1,
195
- 1,
196
- 1,
197
- 1,
198
- 1,
199
- 1,
200
- 1,
201
- 1,
202
- 1,
203
- 1,
204
- 1,
205
- 1,
206
- 1,
207
- 1,
208
- 1,
209
- 1,
210
- 1,
211
- 1,
212
- 1,
213
- 1,
214
- 1,
215
- 1,
216
- 1,
217
- 1,
218
- 1,
219
- 1,
220
- 1,
221
- 1,
222
- 1,
223
- 1,
224
- 1,
225
- 1,
226
- 1,
227
- 1,
228
- 1,
229
- 1,
230
- 1,
231
- 1,
232
- 1,
233
- 1,
234
- 1,
235
- 1,
236
- 1,
237
- 1,
238
- 1,
239
- 1,
240
- 1,
241
- 1,
242
- 1,
243
- 1,
244
- 1,
245
- 1,
246
- 1,
247
- 1,
248
- 1,
249
- 1,
250
- 1,
251
- 1,
252
- 1,
253
- 1,
254
- 1,
255
- 1,
256
- 1,
257
- 1,
258
- 1,
259
- 1,
260
- 1,
261
- 1,
262
- 1,
263
- 1,
264
- 1,
265
- 1,
266
- 1,
267
- 1,
268
- 1,
269
- 1,
270
- 1,
271
- 1,
272
- 1,
273
- 0,
274
- 1,
275
- 1,
276
- 1,
277
- 1,
278
- 1,
279
- 1,
280
- 1,
281
- 1,
282
- 1,
283
- 1,
284
- 1,
285
- 1,
286
- 1,
287
- 1,
288
- 1,
289
- 1,
290
- 1,
291
- 1,
292
- 1,
293
- 1,
294
- 1,
295
- 1,
296
- 1,
297
- 1,
298
- 1,
299
- 1,
300
- 1,
301
- 1,
302
- 1,
303
- 1,
304
- 1,
305
- 1,
306
- 1,
307
- 1,
308
- 1,
309
- 1,
310
- 1,
311
- 1,
312
- 1,
313
- 1,
314
- 1,
315
- 1,
316
- 1,
317
- 1,
318
- 1,
319
- 1,
320
- 1,
321
- 1,
322
- 1,
323
- 1,
324
- 1,
325
- 1,
326
- 1,
327
- 1,
328
- 1,
329
- 1,
330
- 1,
331
- 1,
332
- 1,
333
- 1,
334
- 1,
335
- 1,
336
- 1,
337
- 1,
338
- 1,
339
- 1,
340
- 1,
341
- 1,
342
- 1,
343
- 1,
344
- 1,
345
- 1,
346
- 1,
347
- 1,
348
- 1,
349
- 1,
350
- 1,
351
- 1,
352
- 1,
353
- 1,
354
- 1,
355
- 1,
356
- 1,
357
- 1,
358
- 1,
359
- 1,
360
- 1,
361
- 1,
362
- 1,
363
- 1,
364
- 1,
365
- 1,
366
- 1,
367
- 1,
368
- 1,
369
- 1,
370
- 1,
371
- 1,
372
- 1,
373
- 1,
374
- 1,
375
- 1,
376
- 1,
377
- 1,
378
- 1,
379
- 1,
380
- 1,
381
- 1,
382
- 1,
383
- 1,
384
- 1,
385
- 1,
386
- 1,
387
- 1,
388
- 1,
389
- 1,
390
- 1,
391
- 1,
392
- 1,
393
- 1,
394
- 1,
395
- 1,
396
- 1,
397
- 1,
398
- 1,
399
- 1,
400
- 1,
401
- 1
402
- ]
23
+ // HTAB, visible ASCII and obs-text, allowed in header values
24
+ const constValueChars = new Uint8Array(256)
25
+ constValueChars[9] = 1
26
+ for (let i = 32; i <= 126; i++) {
27
+ constValueChars[i] = 1
28
+ }
29
+ for (let i = 128; i <= 255; i++) {
30
+ constValueChars[i] = 1
31
+ }
403
32
 
404
33
  export function make() {
405
34
  const decoder = new TextDecoder()
@@ -84,6 +84,14 @@ export function make({
84
84
  state.onChunk = noopOnChunk
85
85
  }
86
86
 
87
+ function stop(error: MultipartError) {
88
+ state.stopped = true
89
+ if (state.state === State.body && state.isFile) {
90
+ state.onChunk(null)
91
+ }
92
+ onError(error)
93
+ }
94
+
87
95
  const headerParser = HP.make()
88
96
 
89
97
  const split = Search.make(
@@ -132,14 +140,12 @@ export function make({
132
140
 
133
141
  state.parts++
134
142
  if (state.parts > maxParts) {
135
- state.stopped = true
136
- return onError(errMaxParts)
143
+ return stop(errMaxParts)
137
144
  }
138
145
  }
139
146
 
140
147
  if ((state.partSize += chunk.length) > maxPartSize) {
141
- state.stopped = true
142
- return onError(errMaxPartSize)
148
+ return stop(errMaxPartSize)
143
149
  }
144
150
 
145
151
  if (state.state === State.headers) {
@@ -206,8 +212,7 @@ export function make({
206
212
  } else {
207
213
  const buf = chunk.subarray(result.endPosition)
208
214
  if ((state.fieldSize += buf.length) > maxFieldSize) {
209
- state.stopped = true
210
- return onError(errMaxFieldSize)
215
+ return stop(errMaxFieldSize)
211
216
  }
212
217
  state.fieldChunks.push(buf)
213
218
  }
@@ -216,8 +221,7 @@ export function make({
216
221
  state.onChunk(chunk)
217
222
  } else {
218
223
  if ((state.fieldSize += chunk.length) > maxFieldSize) {
219
- state.stopped = true
220
- return onError(errMaxFieldSize)
224
+ return stop(errMaxFieldSize)
221
225
  }
222
226
  state.fieldChunks.push(chunk)
223
227
  }
@@ -232,14 +236,14 @@ export function make({
232
236
  return
233
237
  }
234
238
  if ((state.totalSize += chunk.length) > maxTotalSize) {
235
- return onError(errMaxTotalSize)
239
+ return stop(errMaxTotalSize)
236
240
  }
237
241
  return split.write(chunk)
238
242
  },
239
243
  end() {
240
244
  split.end()
241
245
  if (!state.done && !state.stopped) {
242
- onError(errEndNotReached)
246
+ stop(errEndNotReached)
243
247
  }
244
248
 
245
249
  state.state = State.headers
@@ -432,6 +432,14 @@ export interface CommandOptions extends KillOptions {
432
432
  * Defaults to `true` on non-Windows platforms and `false` on Windows platforms.
433
433
  */
434
434
  readonly detached?: boolean | undefined
435
+ /**
436
+ * If set to `true`, prevents the child process's console or GUI window from
437
+ * becoming visible on Windows.
438
+ *
439
+ * Defaults to `true` unless `detached` is set to `true`. This option has no
440
+ * effect on non-Windows platforms.
441
+ */
442
+ readonly windowsHide?: boolean | undefined
435
443
  /**
436
444
  * Configuration options for the standard input stream for the child process.
437
445
  */
@@ -15,6 +15,7 @@ import { FileSystem } from "../../FileSystem.ts"
15
15
  import { pipe } from "../../Function.ts"
16
16
  import * as Option from "../../Option.ts"
17
17
  import * as Order from "../../Order.ts"
18
+ import { Path } from "../../Path.ts"
18
19
  import * as Client from "./SqlClient.ts"
19
20
  import type { SqlError } from "./SqlError.ts"
20
21
 
@@ -400,11 +401,19 @@ export const fromRecord = (migrations: Record<string, Effect.Effect<void, unknow
400
401
  * files named `<id>_<name>.js`, `<id>_<name>.ts`,
401
402
  * `<id>_<name>.mjs`, or `<id>_<name>.mts`, and sorts migrations by id.
402
403
  *
404
+ * **Details**
405
+ *
406
+ * Requires a `Path` service appropriate for the migration directory's path
407
+ * syntax. On Windows, prefer a platform-aware implementation such as
408
+ * `NodePath.layer`; the core `Path.layer` uses POSIX semantics and does not
409
+ * preserve Windows drive-letter paths.
410
+ *
403
411
  * @category loaders
404
412
  * @since 4.0.0
405
413
  */
406
- export const fromFileSystem: (directory: string) => Loader<FileSystem> = Effect.fnUntraced(function*(directory) {
414
+ export const fromFileSystem: (directory: string) => Loader<FileSystem | Path> = Effect.fnUntraced(function*(directory) {
407
415
  const Fs = yield* FileSystem
416
+ const path = yield* Path
408
417
  const files = yield* Effect.mapError(
409
418
  Fs.readDirectory(directory),
410
419
  (cause) =>
@@ -424,14 +433,18 @@ export const fromFileSystem: (directory: string) => Loader<FileSystem> = Effect.
424
433
  [
425
434
  Number(id),
426
435
  name,
427
- Effect.promise(
428
- () =>
429
- import(
430
- /* @vite-ignore */
431
- /* webpackIgnore: true */
432
- `${directory}/${basename}`
433
- )
434
- )
436
+ // `import` needs a file URL: on Windows an absolute path such as
437
+ // `D:\migrations\1_init.ts` is rejected by the ESM loader. `orDie` keeps the
438
+ // failure a defect so `loadMigration` reports it as an import error.
439
+ Effect.flatMap(Effect.orDie(path.toFileUrl(path.join(directory, basename))), (url) =>
440
+ Effect.promise(
441
+ () =>
442
+ import(
443
+ /* @vite-ignore */
444
+ /* webpackIgnore: true */
445
+ url.href
446
+ )
447
+ ))
435
448
  ]
436
449
  ] as const
437
450
  })