@effect/platform-node-shared 4.0.0-beta.99 → 4.0.0-rc.109
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.
- package/AGENTS.md +395 -0
- package/CLAUDE.md +395 -0
- package/README.md +10 -3
- package/ai-docs/README.md +44 -0
- package/ai-docs/package.json +36 -0
- package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
- package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
- package/ai-docs/src/01_effect/01_basics/index.md +5 -0
- package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
- package/ai-docs/src/01_effect/02_schema/index.md +7 -0
- package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
- package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
- package/ai-docs/src/01_effect/03_services/index.md +5 -0
- package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
- package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
- package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
- package/ai-docs/src/01_effect/04_errors/index.md +1 -0
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
- package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
- package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
- package/ai-docs/src/01_effect/05_resources/index.md +3 -0
- package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
- package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
- package/ai-docs/src/01_effect/06_running/index.md +1 -0
- package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
- package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
- package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
- package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
- package/ai-docs/src/03_stream/30_encoding.ts +165 -0
- package/ai-docs/src/03_stream/index.md +4 -0
- package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
- package/ai-docs/src/04_integration/index.md +5 -0
- package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
- package/ai-docs/src/05_batching/index.md +3 -0
- package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
- package/ai-docs/src/06_schedule/index.md +3 -0
- package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
- package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
- package/ai-docs/src/07_datetime/index.md +5 -0
- package/ai-docs/src/08_observability/10_logging.ts +66 -0
- package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
- package/ai-docs/src/08_observability/index.md +7 -0
- package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
- package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
- package/ai-docs/src/09_testing/index.md +1 -0
- package/ai-docs/src/10_predicate/01_basics.ts +14 -0
- package/ai-docs/src/10_predicate/index.md +9 -0
- package/ai-docs/src/40_sql/10_basics.ts +175 -0
- package/ai-docs/src/40_sql/index.md +6 -0
- package/ai-docs/src/50_http-client/10_basics.ts +102 -0
- package/ai-docs/src/50_http-client/index.md +3 -0
- package/ai-docs/src/51_http-server/10_basics.ts +118 -0
- package/ai-docs/src/51_http-server/20_testing.ts +100 -0
- package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
- package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
- package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
- package/ai-docs/src/51_http-server/fixtures/api/Users.ts +107 -0
- package/ai-docs/src/51_http-server/fixtures/domain/User.ts +21 -0
- package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
- package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +37 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +80 -0
- package/ai-docs/src/51_http-server/fixtures/server/Users.ts +183 -0
- package/ai-docs/src/51_http-server/index.md +3 -0
- package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
- package/ai-docs/src/60_child-process/index.md +3 -0
- package/ai-docs/src/70_cli/10_basics.ts +160 -0
- package/ai-docs/src/70_cli/index.md +5 -0
- package/ai-docs/src/71_ai/10_language-model.ts +156 -0
- package/ai-docs/src/71_ai/20_tools.ts +226 -0
- package/ai-docs/src/71_ai/30_chat.ts +158 -0
- package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
- package/ai-docs/src/71_ai/index.md +5 -0
- package/ai-docs/src/80_cluster/10_entities.ts +97 -0
- package/ai-docs/src/80_cluster/index.md +4 -0
- package/ai-docs/src/index.md +10 -0
- package/ai-docs/tsconfig.json +24 -0
- package/dist/NodeChildProcessSpawner.d.ts.map +1 -1
- package/dist/NodeChildProcessSpawner.js +14 -10
- package/dist/NodeChildProcessSpawner.js.map +1 -1
- package/dist/NodeClusterSocket.js.map +1 -1
- package/dist/NodeCrypto.js.map +1 -1
- package/dist/NodeFileSystem.d.ts.map +1 -1
- package/dist/NodeFileSystem.js +7 -7
- package/dist/NodeFileSystem.js.map +1 -1
- package/dist/NodeHttpCompression.d.ts +36 -0
- package/dist/NodeHttpCompression.d.ts.map +1 -0
- package/dist/NodeHttpCompression.js +146 -0
- package/dist/NodeHttpCompression.js.map +1 -0
- package/dist/NodePath.d.ts.map +1 -1
- package/dist/NodePath.js +23 -20
- package/dist/NodePath.js.map +1 -1
- package/dist/NodeRuntime.js.map +1 -1
- package/dist/NodeSink.js.map +1 -1
- package/dist/NodeSocket.js.map +1 -1
- package/dist/NodeSocketServer.d.ts.map +1 -1
- package/dist/NodeSocketServer.js +29 -19
- package/dist/NodeSocketServer.js.map +1 -1
- package/dist/NodeStdio.d.ts.map +1 -1
- package/dist/NodeStdio.js +2 -0
- package/dist/NodeStdio.js.map +1 -1
- package/dist/NodeStream.d.ts.map +1 -1
- package/dist/NodeStream.js +10 -7
- package/dist/NodeStream.js.map +1 -1
- package/dist/NodeTerminal.d.ts.map +1 -1
- package/dist/NodeTerminal.js +63 -11
- package/dist/NodeTerminal.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/nodeChildProcessSpawner.d.ts +4 -0
- package/dist/internal/nodeChildProcessSpawner.d.ts.map +1 -0
- package/dist/internal/nodeChildProcessSpawner.js +10 -0
- package/dist/internal/nodeChildProcessSpawner.js.map +1 -0
- package/dist/internal/utils.js.map +1 -1
- package/package.json +11 -9
- package/src/NodeChildProcessSpawner.ts +19 -12
- package/src/NodeFileSystem.ts +16 -12
- package/src/NodeHttpCompression.ts +153 -0
- package/src/NodePath.ts +25 -27
- package/src/NodeSocketServer.ts +32 -19
- package/src/NodeStdio.ts +2 -0
- package/src/NodeStream.ts +10 -7
- package/src/NodeTerminal.ts +62 -13
- package/src/index.ts +5 -0
- package/src/internal/nodeChildProcessSpawner.ts +16 -0
- package/src/internal/utils.ts +1 -1
package/dist/NodeTerminal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTerminal.js","names":[
|
|
1
|
+
{"version":3,"file":"NodeTerminal.js","names":[],"sources":["../src/NodeTerminal.ts"],"sourcesContent":[null],"mappings":"AAYA,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,SAAS,WAAW,QAA4B,sBAAsB;AACtE,OAAO,KAAK,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc;AAErC,OAAO,KAAK,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAK,Q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AAK,CAAC,CAAC,CAAC;IAChF,MAAM,EAAE,MAAM,CAAC;GAChB,CAAC,CAAC,EACH,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAClD,CACF;EAED,MAAM,OAAO,GAAI,MAAc,IAC7B,MAAM,CAAC,eAAe,CACpB,MAAM,CAAC,QAAQ,CAAuB,MAAM,IAAI;IAC9C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAG,GAAG,IACvB,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,GACpB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GACnB,MAAM,CAAC,MAAM,CAAC,IAAI,CAClB,WAAW,CAAC;MACV,MAAM,EAAE,UAAU;MAClB,MAAM,EAAE,SAAS;MACjB,WAAW,EAAE,kCAAkC;MAC/C,KAAK,EAAE;KACR,CAAC,CACH,CAAC,CAAC;EACT,CAAC,CAAC,CACH;EAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACnB,OAAO;IACP,IAAI;IACJ,SAAS;IACT,QAAQ;IACR;GACD,CAAC;AACJ,CAAC,CACF;AAED;;;;;;;AAOA,OAAO,MAAM,KAAK,gBAAmC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,eAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;AAE7G,SAAS,iBAAiB,CAAC,KAAyB;EAClD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC;AAC7E","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export * as NodeCrypto from "./NodeCrypto.ts";
|
|
|
17
17
|
* @since 4.0.0
|
|
18
18
|
*/
|
|
19
19
|
export * as NodeFileSystem from "./NodeFileSystem.ts";
|
|
20
|
+
/**
|
|
21
|
+
* @since 4.0.0
|
|
22
|
+
*/
|
|
23
|
+
export * as NodeHttpCompression from "./NodeHttpCompression.ts";
|
|
20
24
|
/**
|
|
21
25
|
* @since 4.0.0
|
|
22
26
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,OAAO,KAAK,uBAAuB,MAAM,8BAA8B,CAAA;AAEvE;;GAEG;AACH,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAE3D;;GAEG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;GAEG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;GAEG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;GAEG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAE/C;;GAEG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;GAEG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;GAEG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAEzD;;GAEG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;GAEG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;GAEG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,OAAO,KAAK,uBAAuB,MAAM,8BAA8B,CAAA;AAEvE;;GAEG;AACH,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAE3D;;GAEG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;GAEG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;GAEG;AACH,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAA;AAE/D;;GAEG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;GAEG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAE/C;;GAEG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;GAEG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;GAEG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAEzD;;GAEG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;GAEG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;GAEG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,10 @@ export * as NodeCrypto from "./NodeCrypto.js";
|
|
|
18
18
|
* @since 4.0.0
|
|
19
19
|
*/
|
|
20
20
|
export * as NodeFileSystem from "./NodeFileSystem.js";
|
|
21
|
+
/**
|
|
22
|
+
* @since 4.0.0
|
|
23
|
+
*/
|
|
24
|
+
export * as NodeHttpCompression from "./NodeHttpCompression.js";
|
|
21
25
|
/**
|
|
22
26
|
* @since 4.0.0
|
|
23
27
|
*/
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;AAGA,OAAO,KAAK,uBAAuB,MAAM,8BAA8B;AAEvE;;;AAGA,OAAO,KAAK,iBAAiB,MAAM,wBAAwB;AAE3D;;;AAGA,OAAO,KAAK,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAK,cAAc,MAAM,qBAAqB;AAErD;;;AAGA,OAAO,KAAK,mBAAmB,MAAM,0BAA0B;AAE/D;;;AAGA,OAAO,KAAK,QAAQ,MAAM,eAAe;AAEzC;;;AAGA,OAAO,KAAK,WAAW,MAAM,kBAAkB;AAE/C;;;AAGA,OAAO,KAAK,QAAQ,MAAM,eAAe;AAEzC;;;AAGA,OAAO,KAAK,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAK,gBAAgB,MAAM,uBAAuB;AAEzD;;;AAGA,OAAO,KAAK,SAAS,MAAM,gBAAgB;AAE3C;;;AAGA,OAAO,KAAK,UAAU,MAAM,iBAAiB;AAE7C;;;AAGA,OAAO,KAAK,YAAY,MAAM,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type * as ChildProcess from "effect/unstable/process/ChildProcess";
|
|
2
|
+
import type * as NodeChildProcess from "node:child_process";
|
|
3
|
+
export declare const buildSpawnOptions: (options: ChildProcess.CommandOptions, base: Pick<NodeChildProcess.SpawnOptions, "cwd" | "env" | "stdio">, platform: NodeJS.Platform) => NodeChildProcess.SpawnOptions;
|
|
4
|
+
//# sourceMappingURL=nodeChildProcessSpawner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeChildProcessSpawner.d.ts","sourceRoot":"","sources":["../../src/internal/nodeChildProcessSpawner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,sCAAsC,CAAA;AACzE,OAAO,KAAK,KAAK,gBAAgB,MAAM,oBAAoB,CAAA;AAE3D,eAAO,MAAM,iBAAiB,YACnB,YAAY,CAAC,cAAc,QAC9B,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC,YACxD,MAAM,CAAC,QAAQ,KACxB,gBAAgB,CAAC,YAQnB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const buildSpawnOptions = (options, base, platform) => {
|
|
2
|
+
const detached = options.detached ?? platform !== "win32";
|
|
3
|
+
return {
|
|
4
|
+
...base,
|
|
5
|
+
detached,
|
|
6
|
+
shell: options.shell,
|
|
7
|
+
windowsHide: options.windowsHide ?? !detached
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=nodeChildProcessSpawner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeChildProcessSpawner.js","names":[],"sources":["../../src/internal/nodeChildProcessSpawner.ts"],"sourcesContent":[null],"mappings":"AAGA,OAAO,MAAM,iBAAiB,GAAG,CAC/B,OAAoC,EACpC,IAAkE,EAClE,QAAyB,KACQ;EACjC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,KAAK,OAAO;EACzD,OAAO;IACL,GAAG,IAAI;IACP,QAAQ;IACR,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,CAAC;GACtC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/internal/utils.ts"],"sourcesContent":[null],"mappings":"AACA,OAAO,KAAK,aAAa,MAAM,sBAAsB;AAGrD;AACA,OAAO,MAAM,oBAAoB,GAAG,CAAC,MAA6B,EAAE,MAAc,KAClF,CACE,GAA0B,EAC1B,CAAC,IAAI,CAAkF,KACxD;EAC/B,IAAI,MAAM,GAAmB,SAAS;EAEtC,QAAQ,GAAG,CAAC,IAAI;IACd,KAAK,QAAQ;MACX,MAAM,GAAG,UAAU;MACnB;IAEF,KAAK,QAAQ;MACX,MAAM,GAAG,kBAAkB;MAC3B;IAEF,KAAK,QAAQ;MACX,MAAM,GAAG,eAAe;MACxB;IAEF,KAAK,QAAQ;MACX,MAAM,GAAG,aAAa;MACtB;IAEF,KAAK,SAAS;MACZ,MAAM,GAAG,aAAa;MACtB;IAEF,KAAK,OAAO;MACV,MAAM,GAAG,MAAM;MACf;IAEF,KAAK,OAAO;MACV,MAAM,GAAG,aAAa;MACtB;EACJ;EAEA,OAAO,aAAa,CAAC,WAAW,CAAC;IAC/B,IAAI,EAAE,MAAM;IACZ,MAAM;IACN,MAAM;IACN,gBAAgB,EAAE,IAAuB;IACzC,OAAO,EAAE,GAAG,CAAC,OAAO;IACpB,KAAK,EAAE;GACR,CAAC;AACJ,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform-node-shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-
|
|
4
|
+
"version": "4.0.0-rc.109",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Unified interfaces for common platform-specific services",
|
|
7
7
|
"homepage": "https://effect.website",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/Effect-TS/effect.git",
|
|
11
|
-
"directory": "packages/platform
|
|
11
|
+
"directory": "packages/platform/node-shared"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/Effect-TS/effect/issues"
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
".": "./dist/index.js",
|
|
33
33
|
"./*": "./dist/*.js",
|
|
34
34
|
"./internal/*": null,
|
|
35
|
+
"./index": null,
|
|
35
36
|
"./*/index": null
|
|
36
37
|
},
|
|
37
38
|
"files": [
|
|
@@ -39,19 +40,22 @@
|
|
|
39
40
|
"dist/**/*.js",
|
|
40
41
|
"dist/**/*.js.map",
|
|
41
42
|
"dist/**/*.d.ts",
|
|
42
|
-
"dist/**/*.d.ts.map"
|
|
43
|
+
"dist/**/*.d.ts.map",
|
|
44
|
+
"AGENTS.md",
|
|
45
|
+
"CLAUDE.md",
|
|
46
|
+
"ai-docs/**/*"
|
|
43
47
|
],
|
|
44
48
|
"publishConfig": {
|
|
45
49
|
"access": "public",
|
|
46
50
|
"provenance": true
|
|
47
51
|
},
|
|
48
52
|
"peerDependencies": {
|
|
49
|
-
"effect": "^4.0.0-
|
|
53
|
+
"effect": "^4.0.0-rc.109"
|
|
50
54
|
},
|
|
51
55
|
"devDependencies": {
|
|
52
|
-
"@types/node": "^26.1.
|
|
56
|
+
"@types/node": "^26.1.2",
|
|
53
57
|
"tar": "^7.5.19",
|
|
54
|
-
"effect": "^4.0.0-
|
|
58
|
+
"effect": "^4.0.0-rc.109"
|
|
55
59
|
},
|
|
56
60
|
"dependencies": {
|
|
57
61
|
"@types/ws": "^8.18.1",
|
|
@@ -61,8 +65,6 @@
|
|
|
61
65
|
"codegen": "effect-utils codegen",
|
|
62
66
|
"build": "tsc -b tsconfig.json && pnpm babel",
|
|
63
67
|
"babel": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
|
|
64
|
-
"check": "tsc -b tsconfig.json"
|
|
65
|
-
"test": "vitest",
|
|
66
|
-
"coverage": "vitest --coverage"
|
|
68
|
+
"check": "tsc -b tsconfig.json"
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
} from "effect/unstable/process/ChildProcessSpawner"
|
|
41
41
|
import * as NodeChildProcess from "node:child_process"
|
|
42
42
|
import { PassThrough } from "node:stream"
|
|
43
|
+
import { buildSpawnOptions } from "./internal/nodeChildProcessSpawner.ts"
|
|
43
44
|
import { handleErrnoException } from "./internal/utils.ts"
|
|
44
45
|
import * as NodeSink from "./NodeSink.ts"
|
|
45
46
|
import * as NodeStream from "./NodeStream.ts"
|
|
@@ -65,6 +66,17 @@ const toPlatformError = (
|
|
|
65
66
|
type ExitCodeWithSignal = readonly [code: number | null, signal: NodeJS.Signals | null]
|
|
66
67
|
type ExitSignal = Deferred.Deferred<ExitCodeWithSignal>
|
|
67
68
|
|
|
69
|
+
const taskkill = (
|
|
70
|
+
childProcess: NodeChildProcess.ChildProcess,
|
|
71
|
+
onExit: (error: NodeChildProcess.ExecException | null) => void = () => {}
|
|
72
|
+
) =>
|
|
73
|
+
NodeChildProcess.execFile(
|
|
74
|
+
"taskkill",
|
|
75
|
+
["/pid", String(childProcess.pid!), "/T", "/F"],
|
|
76
|
+
{ windowsHide: true },
|
|
77
|
+
onExit
|
|
78
|
+
)
|
|
79
|
+
|
|
68
80
|
const make = Effect.gen(function*() {
|
|
69
81
|
const fs = yield* FileSystem.FileSystem
|
|
70
82
|
const path = yield* Path.Path
|
|
@@ -354,7 +366,7 @@ const make = Effect.gen(function*() {
|
|
|
354
366
|
) => {
|
|
355
367
|
if (globalThis.process.platform === "win32") {
|
|
356
368
|
return Effect.callback<void, PlatformError.PlatformError>((resume) => {
|
|
357
|
-
|
|
369
|
+
taskkill(childProcess, (error) => {
|
|
358
370
|
if (error) {
|
|
359
371
|
resume(Effect.fail(toPlatformError("kill", toError(error), command)))
|
|
360
372
|
} else {
|
|
@@ -376,9 +388,8 @@ const make = Effect.gen(function*() {
|
|
|
376
388
|
signal: NodeJS.Signals
|
|
377
389
|
): void => {
|
|
378
390
|
if (globalThis.process.platform === "win32") {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
})
|
|
391
|
+
// ignore errors during best-effort cleanup
|
|
392
|
+
taskkill(childProcess)
|
|
382
393
|
return
|
|
383
394
|
}
|
|
384
395
|
try {
|
|
@@ -471,13 +482,7 @@ const make = Effect.gen(function*() {
|
|
|
471
482
|
const stdio = buildStdioArray(stdinConfig, stdoutConfig, stderrConfig, resolvedAdditionalFds)
|
|
472
483
|
|
|
473
484
|
const [childProcess, exitSignal] = yield* Effect.acquireRelease(
|
|
474
|
-
spawn(cmd, {
|
|
475
|
-
cwd,
|
|
476
|
-
env,
|
|
477
|
-
stdio,
|
|
478
|
-
detached: cmd.options.detached ?? process.platform !== "win32",
|
|
479
|
-
shell: cmd.options.shell
|
|
480
|
-
}),
|
|
485
|
+
spawn(cmd, buildSpawnOptions(cmd.options, { cwd, env, stdio }, process.platform)),
|
|
481
486
|
Effect.fnUntraced(function*([childProcess, exitSignal]) {
|
|
482
487
|
const exited = yield* Deferred.isDone(exitSignal)
|
|
483
488
|
const killWithTimeout = withTimeout(childProcess, cmd, cmd.options)
|
|
@@ -619,6 +624,8 @@ const make = Effect.gen(function*() {
|
|
|
619
624
|
}
|
|
620
625
|
|
|
621
626
|
const handle = handles[handles.length - 1]
|
|
627
|
+
const kill = (options?: ChildProcess.KillOptions | undefined) =>
|
|
628
|
+
Effect.forEach([...handles].reverse(), (handle) => Effect.ignore(handle.kill(options)), { discard: true })
|
|
622
629
|
const unref = Effect.gen(function*() {
|
|
623
630
|
const rerefs: Array<Effect.Effect<void, PlatformError.PlatformError>> = []
|
|
624
631
|
for (const handle of handles) {
|
|
@@ -631,7 +638,7 @@ const make = Effect.gen(function*() {
|
|
|
631
638
|
pid: handle.pid,
|
|
632
639
|
exitCode: handle.exitCode,
|
|
633
640
|
isRunning: handle.isRunning,
|
|
634
|
-
kill
|
|
641
|
+
kill,
|
|
635
642
|
stdin: handle.stdin,
|
|
636
643
|
stdout: handle.stdout,
|
|
637
644
|
stderr: handle.stderr,
|
package/src/NodeFileSystem.ts
CHANGED
|
@@ -210,7 +210,7 @@ const openFactory = (method: string): FileSystem.FileSystem["open"] => {
|
|
|
210
210
|
nodeOpen(path, options?.flag ?? "r", options?.mode),
|
|
211
211
|
(fd) => Effect.orDie(nodeClose(fd))
|
|
212
212
|
),
|
|
213
|
-
Effect.map((fd) => makeFile(
|
|
213
|
+
Effect.map((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false))
|
|
214
214
|
)
|
|
215
215
|
}
|
|
216
216
|
const open = openFactory("open")
|
|
@@ -252,13 +252,13 @@ const makeFile = (() => {
|
|
|
252
252
|
|
|
253
253
|
class FileImpl implements FileSystem.File {
|
|
254
254
|
readonly [FileSystem.FileTypeId]: typeof FileSystem.FileTypeId
|
|
255
|
-
readonly fd:
|
|
255
|
+
readonly fd: number
|
|
256
256
|
private readonly append: boolean
|
|
257
257
|
|
|
258
258
|
private position: bigint = BigInt(0)
|
|
259
259
|
|
|
260
260
|
constructor(
|
|
261
|
-
fd:
|
|
261
|
+
fd: number,
|
|
262
262
|
append: boolean
|
|
263
263
|
) {
|
|
264
264
|
this[FileSystem.FileTypeId] = FileSystem.FileTypeId
|
|
@@ -283,7 +283,7 @@ const makeFile = (() => {
|
|
|
283
283
|
this.position = this.position + offsetSize
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
return this.position
|
|
286
|
+
return FileSystem.Size(this.position)
|
|
287
287
|
})
|
|
288
288
|
}
|
|
289
289
|
|
|
@@ -386,7 +386,7 @@ const makeFile = (() => {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
-
return (fd:
|
|
389
|
+
return (fd: number, append: boolean): FileSystem.File => new FileImpl(fd, append)
|
|
390
390
|
})()
|
|
391
391
|
|
|
392
392
|
// == makeTempFile
|
|
@@ -550,12 +550,12 @@ const utimes = (() => {
|
|
|
550
550
|
|
|
551
551
|
// == watch
|
|
552
552
|
|
|
553
|
-
const watchNode = (path: string) =>
|
|
553
|
+
const watchNode = (path: string, options?: FileSystem.WatchOptions) =>
|
|
554
554
|
Stream.callback<FileSystem.WatchEvent, Error.PlatformError>((queue) =>
|
|
555
555
|
Effect.acquireRelease(
|
|
556
556
|
Effect.sync(() => {
|
|
557
557
|
const watcher = NFS.watch(path, {
|
|
558
|
-
recursive:
|
|
558
|
+
recursive: options?.recursive ?? false
|
|
559
559
|
}, (event, path) => {
|
|
560
560
|
if (!path) return
|
|
561
561
|
switch (event) {
|
|
@@ -595,12 +595,16 @@ const watchNode = (path: string) =>
|
|
|
595
595
|
)
|
|
596
596
|
)
|
|
597
597
|
|
|
598
|
-
const watch = (
|
|
598
|
+
const watch = (
|
|
599
|
+
backend: Option.Option<FileSystem.WatchBackend["Service"]>,
|
|
600
|
+
path: string,
|
|
601
|
+
options?: FileSystem.WatchOptions
|
|
602
|
+
) =>
|
|
599
603
|
stat(path).pipe(
|
|
600
604
|
Effect.map((stat) =>
|
|
601
605
|
backend.pipe(
|
|
602
|
-
Option.flatMap((_) => _.register(path, stat)),
|
|
603
|
-
Option.getOrElse(() => watchNode(path))
|
|
606
|
+
Option.flatMap((_) => _.register(path, stat, options)),
|
|
607
|
+
Option.getOrElse(() => watchNode(path, options))
|
|
604
608
|
)
|
|
605
609
|
),
|
|
606
610
|
Stream.unwrap
|
|
@@ -652,8 +656,8 @@ const makeFileSystem = Effect.map(Effect.serviceOption(FileSystem.WatchBackend),
|
|
|
652
656
|
symlink,
|
|
653
657
|
truncate,
|
|
654
658
|
utimes,
|
|
655
|
-
watch(path) {
|
|
656
|
-
return watch(backend, path)
|
|
659
|
+
watch(path, options) {
|
|
660
|
+
return watch(backend, path, options)
|
|
657
661
|
},
|
|
658
662
|
writeFile
|
|
659
663
|
}))
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP response compression backed by `node:zlib`, shared by the Node.js, Bun,
|
|
3
|
+
* and Deno platforms.
|
|
4
|
+
*
|
|
5
|
+
* Byte-array bodies are compressed in one shot with the asynchronous
|
|
6
|
+
* `node:zlib` APIs, preserving an exact `Content-Length`. Streaming bodies go
|
|
7
|
+
* through `node:zlib` transform streams that flush each input chunk.
|
|
8
|
+
*
|
|
9
|
+
* @since 4.0.0
|
|
10
|
+
*/
|
|
11
|
+
import * as Effect from "effect/Effect"
|
|
12
|
+
import * as HttpBody from "effect/unstable/http/HttpBody"
|
|
13
|
+
import type * as Platform from "effect/unstable/http/HttpPlatform"
|
|
14
|
+
import * as Response from "effect/unstable/http/HttpServerResponse"
|
|
15
|
+
import type { Duplex } from "node:stream"
|
|
16
|
+
import { Readable } from "node:stream"
|
|
17
|
+
import * as Zlib from "node:zlib"
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The compression algorithms supported by the runtime's `node:zlib`. `zstd`
|
|
21
|
+
* requires Node.js 22.15 or newer.
|
|
22
|
+
*
|
|
23
|
+
* @category constants
|
|
24
|
+
* @since 4.0.0
|
|
25
|
+
*/
|
|
26
|
+
export const algorithms: ReadonlySet<Platform.CompressionAlgorithm> = new Set(
|
|
27
|
+
typeof Zlib.zstdCompress === "function"
|
|
28
|
+
? ["gzip", "deflate", "br", "zstd"]
|
|
29
|
+
: ["gzip", "deflate", "br"]
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const brotliParams = (level: number | undefined, sizeHint?: number): Zlib.BrotliOptions => {
|
|
33
|
+
const params: Record<number, number> = {}
|
|
34
|
+
if (level !== undefined) {
|
|
35
|
+
params[Zlib.constants.BROTLI_PARAM_QUALITY] = level
|
|
36
|
+
}
|
|
37
|
+
if (sizeHint !== undefined) {
|
|
38
|
+
params[Zlib.constants.BROTLI_PARAM_SIZE_HINT] = sizeHint
|
|
39
|
+
}
|
|
40
|
+
return { params }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const zstdParams = (level: number | undefined): Zlib.ZstdOptions | undefined =>
|
|
44
|
+
level === undefined || level === 3 ? undefined : { params: { [Zlib.constants.ZSTD_c_compressionLevel]: level } }
|
|
45
|
+
|
|
46
|
+
const compress = (
|
|
47
|
+
data: Uint8Array,
|
|
48
|
+
algorithm: Platform.CompressionAlgorithm,
|
|
49
|
+
options?: Platform.CompressionOptions | undefined
|
|
50
|
+
): Effect.Effect<Uint8Array> =>
|
|
51
|
+
Effect.callback((resume) => {
|
|
52
|
+
const complete = (error: Error | null, result: Uint8Array) =>
|
|
53
|
+
resume(error === null ? Effect.succeed(result) : Effect.die(error))
|
|
54
|
+
switch (algorithm) {
|
|
55
|
+
case "gzip": {
|
|
56
|
+
Zlib.gzip(data, { level: options?.level }, complete)
|
|
57
|
+
break
|
|
58
|
+
}
|
|
59
|
+
case "deflate": {
|
|
60
|
+
Zlib.deflate(data, { level: options?.level }, complete)
|
|
61
|
+
break
|
|
62
|
+
}
|
|
63
|
+
case "br": {
|
|
64
|
+
Zlib.brotliCompress(data, brotliParams(options?.level, data.byteLength), complete)
|
|
65
|
+
break
|
|
66
|
+
}
|
|
67
|
+
case "zstd": {
|
|
68
|
+
const params = zstdParams(options?.level)
|
|
69
|
+
if (params === undefined) {
|
|
70
|
+
Zlib.zstdCompress(data, complete)
|
|
71
|
+
} else {
|
|
72
|
+
Zlib.zstdCompress(data, params, complete)
|
|
73
|
+
}
|
|
74
|
+
break
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Creates a `Compression` that compresses byte-array bodies in one shot with
|
|
81
|
+
* the asynchronous `node:zlib` APIs, setting the exact `Content-Length` of the
|
|
82
|
+
* compressed body. All other bodies are delegated to `fallback`.
|
|
83
|
+
*
|
|
84
|
+
* @category constructors
|
|
85
|
+
* @since 4.0.0
|
|
86
|
+
*/
|
|
87
|
+
export const make = (fallback: Platform.Compression): Platform.Compression => ({
|
|
88
|
+
algorithms: fallback.algorithms,
|
|
89
|
+
compressResponse(response, algorithm, options) {
|
|
90
|
+
const body = response.body
|
|
91
|
+
if (body._tag !== "Uint8Array") {
|
|
92
|
+
return fallback.compressResponse(response, algorithm, options)
|
|
93
|
+
}
|
|
94
|
+
return Effect.map(compress(body.body, algorithm, options), (result) =>
|
|
95
|
+
Response.setHeader(
|
|
96
|
+
Response.setBody(response, HttpBody.uint8Array(result, body.contentType)),
|
|
97
|
+
"content-length",
|
|
98
|
+
result.byteLength.toString()
|
|
99
|
+
))
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Creates a `node:zlib` compression transform stream that flushes each input
|
|
105
|
+
* chunk, for streaming response bodies.
|
|
106
|
+
*
|
|
107
|
+
* @category constructors
|
|
108
|
+
* @since 4.0.0
|
|
109
|
+
*/
|
|
110
|
+
export const compressTransform = (
|
|
111
|
+
algorithm: Platform.CompressionAlgorithm,
|
|
112
|
+
options?: Platform.CompressionOptions | undefined
|
|
113
|
+
): Duplex => {
|
|
114
|
+
switch (algorithm) {
|
|
115
|
+
case "gzip": {
|
|
116
|
+
return Zlib.createGzip({ level: options?.level, flush: Zlib.constants.Z_SYNC_FLUSH })
|
|
117
|
+
}
|
|
118
|
+
case "deflate": {
|
|
119
|
+
return Zlib.createDeflate({ level: options?.level, flush: Zlib.constants.Z_SYNC_FLUSH })
|
|
120
|
+
}
|
|
121
|
+
case "br": {
|
|
122
|
+
return Zlib.createBrotliCompress({
|
|
123
|
+
...brotliParams(options?.level),
|
|
124
|
+
flush: Zlib.constants.BROTLI_OPERATION_FLUSH
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
case "zstd": {
|
|
128
|
+
return Zlib.createZstdCompress({
|
|
129
|
+
...zstdParams(options?.level),
|
|
130
|
+
flush: Zlib.constants.ZSTD_e_flush
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A Web `ReadableStream` version of `compressTransform`, for platforms that
|
|
138
|
+
* stream response bodies as Web streams.
|
|
139
|
+
*
|
|
140
|
+
* @category constructors
|
|
141
|
+
* @since 4.0.0
|
|
142
|
+
*/
|
|
143
|
+
export const compressTransformWeb = (
|
|
144
|
+
algorithm: Platform.CompressionAlgorithm,
|
|
145
|
+
options?: Platform.CompressionOptions | undefined
|
|
146
|
+
) =>
|
|
147
|
+
(stream: ReadableStream<Uint8Array>): ReadableStream<Uint8Array> => {
|
|
148
|
+
const transform = compressTransform(algorithm, options)
|
|
149
|
+
const source = Readable.fromWeb(stream as any)
|
|
150
|
+
source.on("error", (cause) => transform.destroy(cause))
|
|
151
|
+
transform.on("close", () => source.destroy())
|
|
152
|
+
return Readable.toWeb(source.pipe(transform)) as unknown as ReadableStream<Uint8Array>
|
|
153
|
+
}
|
package/src/NodePath.ts
CHANGED
|
@@ -15,27 +15,28 @@ import { BadArgument } from "effect/PlatformError"
|
|
|
15
15
|
import * as NodePath from "node:path"
|
|
16
16
|
import * as NodeUrl from "node:url"
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
Effect.
|
|
20
|
-
try
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
18
|
+
const fileUrlOps = (windows: boolean | undefined) => ({
|
|
19
|
+
fromFileUrl: (url: URL): Effect.Effect<string, BadArgument> =>
|
|
20
|
+
Effect.try({
|
|
21
|
+
try: () => NodeUrl.fileURLToPath(url, { windows }),
|
|
22
|
+
catch: (cause) =>
|
|
23
|
+
new BadArgument({
|
|
24
|
+
module: "Path",
|
|
25
|
+
method: "fromFileUrl",
|
|
26
|
+
cause
|
|
27
|
+
})
|
|
28
|
+
}),
|
|
29
|
+
toFileUrl: (path: string): Effect.Effect<URL, BadArgument> =>
|
|
30
|
+
Effect.try({
|
|
31
|
+
try: () => NodeUrl.pathToFileURL(path, { windows }),
|
|
32
|
+
catch: (cause) =>
|
|
33
|
+
new BadArgument({
|
|
34
|
+
module: "Path",
|
|
35
|
+
method: "toFileUrl",
|
|
36
|
+
cause
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* Provides the `Path` service using Node's POSIX path implementation plus
|
|
@@ -47,8 +48,7 @@ const toFileUrl = (path: string): Effect.Effect<URL, BadArgument> =>
|
|
|
47
48
|
export const layerPosix: Layer.Layer<Path> = Layer.succeed(Path)({
|
|
48
49
|
[TypeId]: TypeId,
|
|
49
50
|
...NodePath.posix,
|
|
50
|
-
|
|
51
|
-
toFileUrl
|
|
51
|
+
...fileUrlOps(false)
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -61,8 +61,7 @@ export const layerPosix: Layer.Layer<Path> = Layer.succeed(Path)({
|
|
|
61
61
|
export const layerWin32: Layer.Layer<Path> = Layer.succeed(Path)({
|
|
62
62
|
[TypeId]: TypeId,
|
|
63
63
|
...NodePath.win32,
|
|
64
|
-
|
|
65
|
-
toFileUrl
|
|
64
|
+
...fileUrlOps(true)
|
|
66
65
|
})
|
|
67
66
|
|
|
68
67
|
/**
|
|
@@ -75,6 +74,5 @@ export const layerWin32: Layer.Layer<Path> = Layer.succeed(Path)({
|
|
|
75
74
|
export const layer: Layer.Layer<Path> = Layer.succeed(Path)({
|
|
76
75
|
[TypeId]: TypeId,
|
|
77
76
|
...NodePath,
|
|
78
|
-
|
|
79
|
-
toFileUrl
|
|
77
|
+
...fileUrlOps(undefined)
|
|
80
78
|
})
|