the-moby-effect 1.45.0-alpha.20 → 1.45.0-alpha.21
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/dist/cjs/MobyConnection.js.map +1 -1
- package/dist/cjs/demux/Demux.js +18 -6
- package/dist/cjs/demux/Demux.js.map +1 -1
- package/dist/cjs/engines/Dind.js +6 -1
- package/dist/cjs/engines/Dind.js.map +1 -1
- package/dist/cjs/engines/Docker.js +6 -1
- package/dist/cjs/engines/Docker.js.map +1 -1
- package/dist/cjs/engines/DockerCompose.js +7 -1
- package/dist/cjs/engines/DockerCompose.js.map +1 -1
- package/dist/cjs/engines/Moby.js +8 -1
- package/dist/cjs/engines/Moby.js.map +1 -1
- package/dist/cjs/engines/Podman.js +6 -1
- package/dist/cjs/engines/Podman.js.map +1 -1
- package/dist/cjs/platforms/Agnostic.js +17 -25
- package/dist/cjs/platforms/Agnostic.js.map +1 -1
- package/dist/dts/MobyConnection.d.ts +33 -1
- package/dist/dts/MobyConnection.d.ts.map +1 -1
- package/dist/dts/demux/Demux.d.ts.map +1 -1
- package/dist/dts/endpoints/Configs.d.ts +1 -1
- package/dist/dts/endpoints/Containers.d.ts +1 -1
- package/dist/dts/endpoints/Distribution.d.ts +1 -1
- package/dist/dts/endpoints/Execs.d.ts +1 -1
- package/dist/dts/endpoints/Images.d.ts +1 -1
- package/dist/dts/endpoints/Networks.d.ts +1 -1
- package/dist/dts/endpoints/Nodes.d.ts +1 -1
- package/dist/dts/endpoints/Plugins.d.ts +1 -1
- package/dist/dts/endpoints/Secrets.d.ts +1 -1
- package/dist/dts/endpoints/Services.d.ts +1 -1
- package/dist/dts/endpoints/Session.d.ts +1 -1
- package/dist/dts/endpoints/Swarm.d.ts +1 -1
- package/dist/dts/endpoints/System.d.ts +1 -1
- package/dist/dts/endpoints/Tasks.d.ts +1 -1
- package/dist/dts/endpoints/Volumes.d.ts +1 -1
- package/dist/dts/engines/Dind.d.ts +5 -0
- package/dist/dts/engines/Dind.d.ts.map +1 -1
- package/dist/dts/engines/Docker.d.ts +5 -0
- package/dist/dts/engines/Docker.d.ts.map +1 -1
- package/dist/dts/engines/DockerCompose.d.ts +5 -0
- package/dist/dts/engines/DockerCompose.d.ts.map +1 -1
- package/dist/dts/engines/Moby.d.ts +5 -0
- package/dist/dts/engines/Moby.d.ts.map +1 -1
- package/dist/dts/engines/Podman.d.ts +5 -0
- package/dist/dts/engines/Podman.d.ts.map +1 -1
- package/dist/dts/platforms/Agnostic.d.ts.map +1 -1
- package/dist/esm/MobyConnection.js.map +1 -1
- package/dist/esm/demux/Demux.js +18 -6
- package/dist/esm/demux/Demux.js.map +1 -1
- package/dist/esm/engines/Dind.js +5 -0
- package/dist/esm/engines/Dind.js.map +1 -1
- package/dist/esm/engines/Docker.js +5 -0
- package/dist/esm/engines/Docker.js.map +1 -1
- package/dist/esm/engines/DockerCompose.js +5 -0
- package/dist/esm/engines/DockerCompose.js.map +1 -1
- package/dist/esm/engines/Moby.js +6 -0
- package/dist/esm/engines/Moby.js.map +1 -1
- package/dist/esm/engines/Podman.js +5 -0
- package/dist/esm/engines/Podman.js.map +1 -1
- package/dist/esm/platforms/Agnostic.js +17 -25
- package/dist/esm/platforms/Agnostic.js.map +1 -1
- package/package.json +7 -7
- package/src/MobyConnection.ts +13 -3
- package/src/demux/Demux.ts +36 -6
- package/src/engines/Dind.ts +7 -0
- package/src/engines/Docker.ts +8 -0
- package/src/engines/DockerCompose.ts +9 -0
- package/src/engines/Moby.ts +8 -0
- package/src/engines/Podman.ts +8 -0
- package/src/platforms/Agnostic.ts +26 -32
package/src/engines/Docker.ts
CHANGED
|
@@ -85,6 +85,14 @@ export const layerUndici: (connectionOptions: MobyConnectionOptions) => DockerLa
|
|
|
85
85
|
export const layerWeb: (connectionOptions: HttpConnectionOptionsTagged | HttpsConnectionOptionsTagged) => DockerLayer =
|
|
86
86
|
Moby.layerWeb;
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* @since 1.0.0
|
|
90
|
+
* @category Layers
|
|
91
|
+
*/
|
|
92
|
+
export const layerFetch: (
|
|
93
|
+
connectionOptions: HttpConnectionOptionsTagged | HttpsConnectionOptionsTagged
|
|
94
|
+
) => DockerLayer = Moby.layerFetch;
|
|
95
|
+
|
|
88
96
|
/**
|
|
89
97
|
* @since 1.0.0
|
|
90
98
|
* @category Layers
|
|
@@ -279,6 +279,15 @@ export const layerWeb = (
|
|
|
279
279
|
): Layer.Layer<DockerCompose, SystemsError | ContainersError, never> =>
|
|
280
280
|
Layer.provide(Layer.scoped(DockerCompose, make), DockerEngine.layerWeb(connectionOptions));
|
|
281
281
|
|
|
282
|
+
/**
|
|
283
|
+
* @since 1.0.0
|
|
284
|
+
* @category Layers
|
|
285
|
+
*/
|
|
286
|
+
export const layerFetch = (
|
|
287
|
+
connectionOptions: HttpConnectionOptionsTagged | HttpsConnectionOptionsTagged
|
|
288
|
+
): Layer.Layer<DockerCompose, SystemsError | ContainersError, never> =>
|
|
289
|
+
Layer.provide(Layer.scoped(DockerCompose, make), DockerEngine.layerFetch(connectionOptions));
|
|
290
|
+
|
|
282
291
|
/**
|
|
283
292
|
* @since 1.0.0
|
|
284
293
|
* @category Layers
|
package/src/engines/Moby.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { Volumes, VolumesLayer } from "../endpoints/Volumes.js";
|
|
|
32
32
|
import { makeAgnosticHttpClientLayer } from "../platforms/Agnostic.js";
|
|
33
33
|
import { makeBunHttpClientLayer } from "../platforms/Bun.js";
|
|
34
34
|
import { makeDenoHttpClientLayer } from "../platforms/Deno.js";
|
|
35
|
+
import { makeFetchHttpClientLayer } from "../platforms/Fetch.js";
|
|
35
36
|
import { makeNodeHttpClientLayer } from "../platforms/Node.js";
|
|
36
37
|
import { makeUndiciHttpClientLayer } from "../platforms/Undici.js";
|
|
37
38
|
import { makeWebHttpClientLayer } from "../platforms/Web.js";
|
|
@@ -132,6 +133,13 @@ export const layerUndici = (connectionOptions: MobyConnectionOptions): MobyLayer
|
|
|
132
133
|
export const layerWeb = (connectionOptions: HttpConnectionOptionsTagged | HttpsConnectionOptionsTagged): MobyLayer =>
|
|
133
134
|
Layer.provide(layerWithoutHttpCLient, makeWebHttpClientLayer(connectionOptions));
|
|
134
135
|
|
|
136
|
+
/**
|
|
137
|
+
* @since 1.0.0
|
|
138
|
+
* @category Layers
|
|
139
|
+
*/
|
|
140
|
+
export const layerFetch = (connectionOptions: HttpConnectionOptionsTagged | HttpsConnectionOptionsTagged): MobyLayer =>
|
|
141
|
+
Layer.provide(layerWithoutHttpCLient, makeFetchHttpClientLayer(connectionOptions));
|
|
142
|
+
|
|
135
143
|
/**
|
|
136
144
|
* @since 1.0.0
|
|
137
145
|
* @category Layers
|
package/src/engines/Podman.ts
CHANGED
|
@@ -88,6 +88,14 @@ export const layerUndici: (connectionOptions: MobyConnectionOptions) => PodmanLa
|
|
|
88
88
|
export const layerWeb: (connectionOptions: HttpConnectionOptionsTagged | HttpsConnectionOptionsTagged) => PodmanLayer =
|
|
89
89
|
Moby.layerWeb;
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @since 1.0.0
|
|
93
|
+
* @category Layers
|
|
94
|
+
*/
|
|
95
|
+
export const layerFetch: (
|
|
96
|
+
connectionOptions: HttpConnectionOptionsTagged | HttpsConnectionOptionsTagged
|
|
97
|
+
) => PodmanLayer = Moby.layerFetch;
|
|
98
|
+
|
|
91
99
|
/**
|
|
92
100
|
* @since 1.0.0
|
|
93
101
|
* @category Layers
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
* @since 1.0.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as assert from "node:assert";
|
|
8
|
-
|
|
9
7
|
import * as HttpClient from "@effect/platform/HttpClient";
|
|
10
8
|
import * as HttpClientError from "@effect/platform/HttpClientError";
|
|
11
9
|
import * as HttpClientRequest from "@effect/platform/HttpClientRequest";
|
|
@@ -15,30 +13,33 @@ import * as Context from "effect/Context";
|
|
|
15
13
|
import * as Effect from "effect/Effect";
|
|
16
14
|
import * as Function from "effect/Function";
|
|
17
15
|
import * as Layer from "effect/Layer";
|
|
16
|
+
import * as Predicate from "effect/Predicate";
|
|
18
17
|
import * as Scope from "effect/Scope";
|
|
18
|
+
import * as Types from "effect/Types";
|
|
19
19
|
|
|
20
20
|
import { MobyConnectionOptions } from "../MobyConnection.js";
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
/** @internal */
|
|
23
|
+
const makeVersionPath = (connectionOptions: MobyConnectionOptions): string =>
|
|
24
|
+
Predicate.isNotUndefined(connectionOptions.version) ? `/v${connectionOptions.version}` : "";
|
|
25
|
+
|
|
26
|
+
/** @internal */
|
|
26
27
|
const makeHttpRequestUrl: (connectionOptions: MobyConnectionOptions) => string = MobyConnectionOptions.$match({
|
|
27
|
-
ssh: () =>
|
|
28
|
-
socket: () =>
|
|
29
|
-
http: (options) =>
|
|
30
|
-
|
|
28
|
+
ssh: (options) => `http://0.0.0.0${makeVersionPath(options)}` as const,
|
|
29
|
+
socket: (options) => `http://0.0.0.0${makeVersionPath(options)}` as const,
|
|
30
|
+
http: (options) =>
|
|
31
|
+
`http://${options.host}:${options.port}${options.path ?? ""}${makeVersionPath(options)}` as const,
|
|
32
|
+
https: (options) =>
|
|
33
|
+
`https://${options.host}:${options.port}${options.path ?? ""}${makeVersionPath(options)}` as const,
|
|
31
34
|
});
|
|
32
35
|
|
|
33
|
-
/**
|
|
34
|
-
* @since 1.0.0
|
|
35
|
-
* @category Helpers
|
|
36
|
-
*/
|
|
36
|
+
/** @internal */
|
|
37
37
|
const makeWebsocketRequestUrl: (connectionOptions: MobyConnectionOptions) => string = MobyConnectionOptions.$match({
|
|
38
|
-
ssh: () =>
|
|
39
|
-
socket: (options) => `ws+unix://${options.socketPath}:` as const,
|
|
40
|
-
http: (options) => `ws://${options.host}:${options.port}${options.path ?? ""}` as const,
|
|
41
|
-
https: (options) =>
|
|
38
|
+
ssh: (options) => `ws://0.0.0.0${makeVersionPath(options)}` as const,
|
|
39
|
+
socket: (options) => `ws+unix://${options.socketPath}${makeVersionPath(options)}:` as const,
|
|
40
|
+
http: (options) => `ws://${options.host}:${options.port}${options.path ?? ""}${makeVersionPath(options)}` as const,
|
|
41
|
+
https: (options) =>
|
|
42
|
+
`wss://${options.host}:${options.port}${options.path ?? ""}${makeVersionPath(options)}` as const,
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
/** @internal */
|
|
@@ -48,7 +49,7 @@ const HttpClientMobyConnectionOptions: unique symbol = Symbol.for(
|
|
|
48
49
|
|
|
49
50
|
/** @internal */
|
|
50
51
|
interface HttpClientExtension<E = HttpClientError.HttpClientError, R = Scope.Scope>
|
|
51
|
-
extends HttpClient.HttpClient<E, R> {
|
|
52
|
+
extends HttpClient.HttpClient.With<E, R> {
|
|
52
53
|
readonly [HttpClientMobyConnectionOptions]: MobyConnectionOptions;
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -61,7 +62,9 @@ export const websocketRequest = (
|
|
|
61
62
|
|
|
62
63
|
const { hash, url, urlParams } = request;
|
|
63
64
|
const { [HttpClientMobyConnectionOptions]: connectionOptions } = client as HttpClientExtension;
|
|
64
|
-
|
|
65
|
+
if (Predicate.isUndefined(connectionOptions)) {
|
|
66
|
+
return yield* Effect.dieMessage("What happened to the connection options?");
|
|
67
|
+
}
|
|
65
68
|
|
|
66
69
|
const websocketUrl = yield* UrlParams.makeUrl(
|
|
67
70
|
`${makeWebsocketRequestUrl(connectionOptions)}${url}`,
|
|
@@ -94,20 +97,10 @@ export const makeAgnosticHttpClientLayer = (
|
|
|
94
97
|
})
|
|
95
98
|
),
|
|
96
99
|
Layer.map((context) => {
|
|
97
|
-
const tag
|
|
98
|
-
HttpClient.HttpClient<HttpClientError.HttpClientError, Scope.Scope>,
|
|
99
|
-
HttpClient.HttpClient<HttpClientError.HttpClientError, Scope.Scope>
|
|
100
|
-
> = HttpClient.HttpClient;
|
|
100
|
+
const tag = HttpClient.HttpClient;
|
|
101
101
|
const oldClient = Context.get(context, tag);
|
|
102
|
-
|
|
103
|
-
(oldClient as Mutable<HttpClientExtension>)[HttpClientMobyConnectionOptions] = connectionOptions;
|
|
102
|
+
(oldClient as Types.Mutable<HttpClientExtension>)[HttpClientMobyConnectionOptions] = connectionOptions;
|
|
104
103
|
return Context.make(tag, oldClient);
|
|
105
|
-
}),
|
|
106
|
-
Layer.tap((context) => {
|
|
107
|
-
const client = Context.get(context, HttpClient.HttpClient);
|
|
108
|
-
const { [HttpClientMobyConnectionOptions]: savedConnectionOptions } = client as HttpClientExtension;
|
|
109
|
-
assert.deepStrictEqual(savedConnectionOptions, connectionOptions);
|
|
110
|
-
return Effect.void;
|
|
111
104
|
})
|
|
112
105
|
);
|
|
113
106
|
|
|
@@ -124,6 +117,7 @@ export const makeAgnosticWebsocketLayer = (
|
|
|
124
117
|
Layer.effect(
|
|
125
118
|
Socket.WebSocketConstructor,
|
|
126
119
|
Effect.gen(function* () {
|
|
120
|
+
// Only the ws package supports unix socket connection options
|
|
127
121
|
if (MobyConnectionOptions.$is("socket")(connectionOptions)) {
|
|
128
122
|
const ws = yield* Effect.promise(() => import("ws"));
|
|
129
123
|
return (url, protocols) => new ws.WebSocket(url, protocols) as unknown as globalThis.WebSocket;
|