@docker-harpoon/core 0.1.0 → 0.1.3
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/__tests__/bindings.test.d.ts +10 -0
- package/dist/__tests__/bindings.test.d.ts.map +1 -0
- package/dist/__tests__/bindings.test.js +124 -0
- package/dist/__tests__/container.test.d.ts +12 -0
- package/dist/__tests__/container.test.d.ts.map +1 -0
- package/dist/__tests__/container.test.js +115 -0
- package/dist/__tests__/database.test.d.ts +10 -0
- package/dist/__tests__/database.test.d.ts.map +1 -0
- package/dist/__tests__/database.test.js +92 -0
- package/dist/__tests__/network.test.d.ts +10 -0
- package/dist/__tests__/network.test.d.ts.map +1 -0
- package/dist/__tests__/network.test.js +44 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/promise.d.ts +8 -0
- package/dist/api/promise.d.ts.map +1 -1
- package/dist/api/promise.js +109 -4
- package/dist/build-strategies/types.d.ts.map +1 -1
- package/dist/config-patchers/types.d.ts.map +1 -1
- package/dist/dockerfile-transformers/types.d.ts.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/helpers/database.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/resources/container.d.ts +10 -0
- package/dist/resources/container.d.ts.map +1 -1
- package/dist/resources/container.js +222 -5
- package/dist/resources/image.d.ts +1 -1
- package/dist/resources/image.d.ts.map +1 -1
- package/dist/resources/index.d.ts +2 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +2 -0
- package/dist/resources/network.d.ts.map +1 -1
- package/dist/resources/schemas.d.ts +120 -0
- package/dist/resources/schemas.d.ts.map +1 -0
- package/dist/resources/schemas.js +95 -0
- package/package.json +7 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config-patchers/types.ts"],"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AC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnC,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,0CAA0C;IAC1C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAyDD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,QAAQ,+GAqCjB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @harpoon/core
|
|
2
|
+
* @docker-harpoon/core
|
|
3
3
|
*
|
|
4
4
|
* Infrastructure as Code for Docker testing environments.
|
|
5
5
|
*
|
|
6
6
|
* Simple Promise-based API:
|
|
7
7
|
*
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import { Network, Container, database } from '@harpoon/core';
|
|
9
|
+
* import { Network, Container, database } from '@docker-harpoon/core';
|
|
10
10
|
*
|
|
11
11
|
* const network = await Network("my-net");
|
|
12
12
|
* const db = await database("postgres", { image: "postgres:16" });
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* - Binding interface for env var injection and lifecycle hooks
|
|
28
28
|
* - BuildBinding interface for Dockerfile transformations
|
|
29
29
|
*/
|
|
30
|
-
export { Network, Container, database, Image, setDocker, resetDocker, destroyAll, type NetworkConfig, type NetworkResource, type ContainerConfig, type ContainerResource, type PortMapping, type ShutdownMetadata, type DatabaseConfig, type DatabaseResource, type ImageConfig, type ImageResource, } from './api';
|
|
30
|
+
export { Network, Container, database, Image, setDocker, resetDocker, destroyAll, type NetworkConfig, type NetworkResource, type ContainerConfig, type ContainerResource, type PortMapping, type ShutdownMetadata, type DatabaseConfig, type DatabaseResource, type ImageConfig, type ImageResource, type ContainerStats, type ExecOptions, type ExecResult, type LogOptions, type LogLine, } from './api';
|
|
31
31
|
export type { Binding, BuildBinding, BindingsEnv, FlatBindingsEnv, } from './bindings';
|
|
32
32
|
export { isBuildBinding, mergeBindingsEnv, createEnvBinding, } from './bindings';
|
|
33
33
|
export { HarpoonError, NetworkError, ImageError, ContainerError, ScopeError, BindingError, toHarpoonError, asCause, isHarpoonError, isNetworkError, isImageError, isContainerError, isScopeError, isBindingError, } from './errors';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAEL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,KAAK,EAGL,SAAS,EACT,WAAW,EACX,UAAU,EAGV,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAEL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,KAAK,EAGL,SAAS,EACT,WAAW,EACX,UAAU,EAGV,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAA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BAA2B,CAAC;AAEnC,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,GAChB,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @harpoon/core
|
|
2
|
+
* @docker-harpoon/core
|
|
3
3
|
*
|
|
4
4
|
* Infrastructure as Code for Docker testing environments.
|
|
5
5
|
*
|
|
6
6
|
* Simple Promise-based API:
|
|
7
7
|
*
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import { Network, Container, database } from '@harpoon/core';
|
|
9
|
+
* import { Network, Container, database } from '@docker-harpoon/core';
|
|
10
10
|
*
|
|
11
11
|
* const network = await Network("my-net");
|
|
12
12
|
* const db = await database("postgres", { image: "postgres:16" });
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { Effect, Scope } from 'effect';
|
|
10
10
|
import Docker from 'dockerode';
|
|
11
11
|
import type { Binding } from '../bindings/types';
|
|
12
|
+
import { type ContainerStats, type ExecOptions, type ExecResult, type LogOptions, type LogLine } from './schemas';
|
|
12
13
|
export interface PortMapping {
|
|
13
14
|
internal: number;
|
|
14
15
|
external: number;
|
|
@@ -34,9 +35,18 @@ export interface ShutdownMetadata {
|
|
|
34
35
|
export interface ContainerResource {
|
|
35
36
|
readonly id: string;
|
|
36
37
|
readonly name: string;
|
|
38
|
+
/** Wait for a log pattern to appear */
|
|
37
39
|
readonly waitForLog: (pattern: string | RegExp, timeoutMs?: number) => Effect.Effect<void, Error>;
|
|
40
|
+
/** Stop container gracefully with signal */
|
|
38
41
|
readonly stopGracefully: (signal?: string, timeoutMs?: number) => Effect.Effect<ShutdownMetadata, Error>;
|
|
42
|
+
/** Get container IP in a specific network */
|
|
39
43
|
readonly getIp: (networkName: string) => Effect.Effect<string, Error>;
|
|
44
|
+
/** Get container resource statistics (CPU, memory, network) */
|
|
45
|
+
readonly stats: () => Effect.Effect<ContainerStats, Error>;
|
|
46
|
+
/** Execute a command inside the container */
|
|
47
|
+
readonly exec: (options: ExecOptions) => Effect.Effect<ExecResult, Error>;
|
|
48
|
+
/** Stream container logs as an async iterable */
|
|
49
|
+
readonly streamLogs: (options?: LogOptions) => Effect.Effect<AsyncIterable<LogLine>, Error>;
|
|
40
50
|
}
|
|
41
51
|
export declare const Container: (resourceId: string, config: ContainerConfig, docker: Docker) => Effect.Effect<ContainerResource, Error, Scope.Scope>;
|
|
42
52
|
//# sourceMappingURL=container.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/resources/container.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/resources/container.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAA0B,MAAM,QAAQ,CAAC;AAC/D,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,GAA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AAa,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;CAC7F;AA6ED,eAAO,MAAM,SAAS,uHA2hBnB,CAAC"}
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
import { Effect, Schedule, Exit } from 'effect';
|
|
10
10
|
import { toHarpoonError, ContainerError } from '../errors';
|
|
11
11
|
import { mergeBindingsEnv } from '../bindings/types';
|
|
12
|
-
|
|
12
|
+
import { containerStatsSchema, execOptionsSchema, execResultSchema, logOptionsSchema, } from './schemas';
|
|
13
|
+
const CLEANUP_TIMEOUT_MS = 30_000; // 30 seconds for database graceful shutdown
|
|
13
14
|
const safeRemoveContainer = async (docker, containerId, containerName) => {
|
|
14
15
|
const container = docker.getContainer(containerId);
|
|
15
16
|
try {
|
|
@@ -19,16 +20,27 @@ const safeRemoveContainer = async (docker, containerId, containerName) => {
|
|
|
19
20
|
try {
|
|
20
21
|
await container.kill({ signal: 'SIGTERM' });
|
|
21
22
|
await new Promise((resolve) => {
|
|
23
|
+
let resolved = false;
|
|
24
|
+
const safeResolve = () => {
|
|
25
|
+
if (!resolved) {
|
|
26
|
+
resolved = true;
|
|
27
|
+
clearTimeout(timeout);
|
|
28
|
+
resolve();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
22
31
|
const checkStopped = async () => {
|
|
32
|
+
if (resolved)
|
|
33
|
+
return;
|
|
23
34
|
try {
|
|
24
35
|
const state = await container.inspect();
|
|
25
36
|
if (!state.State.Running) {
|
|
26
|
-
|
|
37
|
+
safeResolve();
|
|
27
38
|
return;
|
|
28
39
|
}
|
|
29
40
|
}
|
|
30
41
|
catch {
|
|
31
|
-
|
|
42
|
+
// Container gone or error - consider it stopped
|
|
43
|
+
safeResolve();
|
|
32
44
|
return;
|
|
33
45
|
}
|
|
34
46
|
setTimeout(checkStopped, 100);
|
|
@@ -36,9 +48,9 @@ const safeRemoveContainer = async (docker, containerId, containerName) => {
|
|
|
36
48
|
const timeout = setTimeout(() => {
|
|
37
49
|
console.warn(`[Cleanup] Container ${containerName} did not stop gracefully, forcing`);
|
|
38
50
|
container.kill({ signal: 'SIGKILL' }).catch(() => { });
|
|
39
|
-
|
|
51
|
+
safeResolve();
|
|
40
52
|
}, 5000);
|
|
41
|
-
checkStopped()
|
|
53
|
+
checkStopped();
|
|
42
54
|
});
|
|
43
55
|
}
|
|
44
56
|
catch (e) {
|
|
@@ -222,6 +234,211 @@ export const Container = (resourceId, config, docker) => Effect.acquireRelease(E
|
|
|
222
234
|
},
|
|
223
235
|
catch: (e) => new Error(`getIp failed: ${e}`),
|
|
224
236
|
}),
|
|
237
|
+
/**
|
|
238
|
+
* Get container resource statistics (CPU, memory, network).
|
|
239
|
+
* Uses dockerode stats() with one-shot mode for a single snapshot.
|
|
240
|
+
*/
|
|
241
|
+
stats: () => Effect.tryPromise({
|
|
242
|
+
try: async () => {
|
|
243
|
+
const statsData = await container.stats({ stream: false });
|
|
244
|
+
// Calculate CPU percentage
|
|
245
|
+
const cpuDelta = statsData.cpu_stats.cpu_usage.total_usage -
|
|
246
|
+
statsData.precpu_stats.cpu_usage.total_usage;
|
|
247
|
+
const systemDelta = statsData.cpu_stats.system_cpu_usage -
|
|
248
|
+
statsData.precpu_stats.system_cpu_usage;
|
|
249
|
+
const cpuCores = statsData.cpu_stats.online_cpus || 1;
|
|
250
|
+
const cpuPercent = systemDelta > 0
|
|
251
|
+
? (cpuDelta / systemDelta) * cpuCores * 100
|
|
252
|
+
: 0;
|
|
253
|
+
// Calculate memory stats
|
|
254
|
+
const memUsage = statsData.memory_stats?.usage ?? 0;
|
|
255
|
+
const memLimit = statsData.memory_stats?.limit ?? 0;
|
|
256
|
+
const memPercent = memLimit > 0 ? (memUsage / memLimit) * 100 : 0;
|
|
257
|
+
// Calculate network stats (sum all interfaces)
|
|
258
|
+
const networks = statsData.networks ?? {};
|
|
259
|
+
let rxBytes = 0;
|
|
260
|
+
let txBytes = 0;
|
|
261
|
+
let rxPackets = 0;
|
|
262
|
+
let txPackets = 0;
|
|
263
|
+
for (const iface of Object.values(networks)) {
|
|
264
|
+
rxBytes += iface.rx_bytes ?? 0;
|
|
265
|
+
txBytes += iface.tx_bytes ?? 0;
|
|
266
|
+
rxPackets += iface.rx_packets ?? 0;
|
|
267
|
+
txPackets += iface.tx_packets ?? 0;
|
|
268
|
+
}
|
|
269
|
+
const result = {
|
|
270
|
+
cpu: {
|
|
271
|
+
usage: statsData.cpu_stats.cpu_usage.total_usage,
|
|
272
|
+
system: statsData.cpu_stats.system_cpu_usage,
|
|
273
|
+
percent: Math.round(cpuPercent * 100) / 100,
|
|
274
|
+
cores: cpuCores,
|
|
275
|
+
},
|
|
276
|
+
memory: {
|
|
277
|
+
usage: memUsage,
|
|
278
|
+
limit: memLimit,
|
|
279
|
+
percent: Math.round(memPercent * 100) / 100,
|
|
280
|
+
usageMB: Math.round((memUsage / 1024 / 1024) * 100) / 100,
|
|
281
|
+
limitMB: Math.round((memLimit / 1024 / 1024) * 100) / 100,
|
|
282
|
+
},
|
|
283
|
+
network: {
|
|
284
|
+
rxBytes,
|
|
285
|
+
txBytes,
|
|
286
|
+
rxPackets,
|
|
287
|
+
txPackets,
|
|
288
|
+
},
|
|
289
|
+
timestamp: new Date().toISOString(),
|
|
290
|
+
containerId: container.id,
|
|
291
|
+
};
|
|
292
|
+
// Validate with Zod schema
|
|
293
|
+
return containerStatsSchema.parse(result);
|
|
294
|
+
},
|
|
295
|
+
catch: (e) => new Error(`stats failed: ${e}`),
|
|
296
|
+
}),
|
|
297
|
+
/**
|
|
298
|
+
* Execute a command inside the container.
|
|
299
|
+
* Returns stdout, stderr, and exit code.
|
|
300
|
+
*/
|
|
301
|
+
exec: (options) => Effect.tryPromise({
|
|
302
|
+
try: async () => {
|
|
303
|
+
const startTime = Date.now();
|
|
304
|
+
// Validate input with Zod
|
|
305
|
+
const validated = execOptionsSchema.parse(options);
|
|
306
|
+
// Create exec instance
|
|
307
|
+
const exec = await container.exec({
|
|
308
|
+
Cmd: validated.cmd,
|
|
309
|
+
AttachStdout: true,
|
|
310
|
+
AttachStderr: true,
|
|
311
|
+
Env: validated.env
|
|
312
|
+
? Object.entries(validated.env).map(([k, v]) => `${k}=${v}`)
|
|
313
|
+
: undefined,
|
|
314
|
+
WorkingDir: validated.workingDir,
|
|
315
|
+
User: validated.user,
|
|
316
|
+
Privileged: validated.privileged,
|
|
317
|
+
Tty: validated.tty,
|
|
318
|
+
});
|
|
319
|
+
// Start exec and capture output
|
|
320
|
+
const stream = await exec.start({ Detach: false, Tty: validated.tty ?? false });
|
|
321
|
+
// Collect output chunks
|
|
322
|
+
const stdoutChunks = [];
|
|
323
|
+
const stderrChunks = [];
|
|
324
|
+
await new Promise((resolve, reject) => {
|
|
325
|
+
// Docker multiplexes stdout/stderr in the stream
|
|
326
|
+
// First 8 bytes of each frame indicate stream type and size
|
|
327
|
+
stream.on('data', (chunk) => {
|
|
328
|
+
// For TTY mode, all output goes to stdout
|
|
329
|
+
if (validated.tty) {
|
|
330
|
+
stdoutChunks.push(chunk);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
// Parse multiplexed stream (Docker stream format)
|
|
334
|
+
let offset = 0;
|
|
335
|
+
while (offset < chunk.length) {
|
|
336
|
+
if (offset + 8 > chunk.length)
|
|
337
|
+
break;
|
|
338
|
+
const streamType = chunk.readUInt8(offset);
|
|
339
|
+
const size = chunk.readUInt32BE(offset + 4);
|
|
340
|
+
const payload = chunk.slice(offset + 8, offset + 8 + size);
|
|
341
|
+
if (streamType === 1) {
|
|
342
|
+
stdoutChunks.push(payload);
|
|
343
|
+
}
|
|
344
|
+
else if (streamType === 2) {
|
|
345
|
+
stderrChunks.push(payload);
|
|
346
|
+
}
|
|
347
|
+
offset += 8 + size;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
stream.on('end', resolve);
|
|
351
|
+
stream.on('error', reject);
|
|
352
|
+
});
|
|
353
|
+
// Get exit code
|
|
354
|
+
const inspection = await exec.inspect();
|
|
355
|
+
const exitCode = inspection.ExitCode ?? 0;
|
|
356
|
+
const durationMs = Date.now() - startTime;
|
|
357
|
+
const result = {
|
|
358
|
+
exitCode,
|
|
359
|
+
stdout: Buffer.concat(stdoutChunks).toString('utf-8'),
|
|
360
|
+
stderr: Buffer.concat(stderrChunks).toString('utf-8'),
|
|
361
|
+
durationMs,
|
|
362
|
+
};
|
|
363
|
+
// Validate output with Zod
|
|
364
|
+
return execResultSchema.parse(result);
|
|
365
|
+
},
|
|
366
|
+
catch: (e) => new Error(`exec failed: ${e}`),
|
|
367
|
+
}),
|
|
368
|
+
/**
|
|
369
|
+
* Stream container logs as an async iterable.
|
|
370
|
+
* Yields LogLine objects with stream type and message.
|
|
371
|
+
*/
|
|
372
|
+
streamLogs: (options) => Effect.tryPromise({
|
|
373
|
+
try: async () => {
|
|
374
|
+
// Validate and apply defaults
|
|
375
|
+
const opts = logOptionsSchema.parse(options ?? {});
|
|
376
|
+
const stdout = opts.stdout ?? true;
|
|
377
|
+
const stderr = opts.stderr ?? true;
|
|
378
|
+
const timestamps = opts.timestamps ?? false;
|
|
379
|
+
const stream = await container.logs({
|
|
380
|
+
follow: true,
|
|
381
|
+
stdout,
|
|
382
|
+
stderr,
|
|
383
|
+
since: opts.since,
|
|
384
|
+
until: opts.until,
|
|
385
|
+
tail: opts.tail,
|
|
386
|
+
timestamps,
|
|
387
|
+
});
|
|
388
|
+
// Create a wrapper to make the stream async iterable
|
|
389
|
+
const readable = stream;
|
|
390
|
+
// Convert NodeJS.ReadableStream to AsyncIterable<LogLine>
|
|
391
|
+
async function* logIterator() {
|
|
392
|
+
const chunks = [];
|
|
393
|
+
// Use Promise-based iteration for ReadableStream
|
|
394
|
+
for await (const chunk of readable) {
|
|
395
|
+
// Parse Docker log format (8-byte header + payload)
|
|
396
|
+
let offset = 0;
|
|
397
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
398
|
+
while (offset < buffer.length) {
|
|
399
|
+
if (offset + 8 > buffer.length) {
|
|
400
|
+
// Incomplete header, yield rest as stdout
|
|
401
|
+
yield {
|
|
402
|
+
stream: 'stdout',
|
|
403
|
+
message: buffer.slice(offset).toString('utf-8').trim(),
|
|
404
|
+
};
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
const streamType = buffer.readUInt8(offset);
|
|
408
|
+
const size = buffer.readUInt32BE(offset + 4);
|
|
409
|
+
if (offset + 8 + size > buffer.length) {
|
|
410
|
+
// Incomplete payload
|
|
411
|
+
yield {
|
|
412
|
+
stream: streamType === 2 ? 'stderr' : 'stdout',
|
|
413
|
+
message: buffer.slice(offset + 8).toString('utf-8').trim(),
|
|
414
|
+
};
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
const payload = buffer.slice(offset + 8, offset + 8 + size);
|
|
418
|
+
const message = payload.toString('utf-8');
|
|
419
|
+
// Parse timestamp if present (format: "2024-01-14T21:00:00.000000000Z message")
|
|
420
|
+
let timestamp;
|
|
421
|
+
let content = message;
|
|
422
|
+
if (timestamps) {
|
|
423
|
+
const match = message.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z)\s+(.*)$/s);
|
|
424
|
+
if (match) {
|
|
425
|
+
timestamp = match[1];
|
|
426
|
+
content = match[2] ?? '';
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
yield {
|
|
430
|
+
stream: streamType === 2 ? 'stderr' : 'stdout',
|
|
431
|
+
timestamp,
|
|
432
|
+
message: content.trim(),
|
|
433
|
+
};
|
|
434
|
+
offset += 8 + size;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return logIterator();
|
|
439
|
+
},
|
|
440
|
+
catch: (e) => new Error(`streamLogs failed: ${e}`),
|
|
441
|
+
}),
|
|
225
442
|
};
|
|
226
443
|
// Call onStart hooks for bindings
|
|
227
444
|
// This is done in Effect context for proper error handling
|
|
@@ -33,5 +33,5 @@ export interface ImageResource {
|
|
|
33
33
|
* @param config Image build configuration
|
|
34
34
|
* @returns Effect yielding the built image resource
|
|
35
35
|
*/
|
|
36
|
-
export declare const Image: (tag: string, config: ImageConfig) => Effect.Effect<ImageResource, Error>;
|
|
36
|
+
export declare const Image: (tag: string, config: ImageConfig) => Effect.Effect<ImageResource, Error, never>;
|
|
37
37
|
//# sourceMappingURL=image.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/resources/image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/resources/image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,kFA4HmD,CAAC"}
|
|
@@ -7,6 +7,8 @@ export { Network } from './network';
|
|
|
7
7
|
export type { NetworkConfig, NetworkResource } from './network';
|
|
8
8
|
export { Container } from './container';
|
|
9
9
|
export type { ContainerConfig, ContainerResource, PortMapping, ShutdownMetadata, } from './container';
|
|
10
|
+
export { containerStatsSchema, execOptionsSchema, execResultSchema, logOptionsSchema, logLineSchema, cpuStatsSchema, memoryStatsSchema, networkStatsSchema, statsOptionsSchema, } from './schemas';
|
|
11
|
+
export type { ContainerStats, CpuStats, MemoryStats, NetworkStats, ExecOptions, ExecResult, LogOptions, LogLine, StatsOptions, } from './schemas';
|
|
10
12
|
export { Image } from './image';
|
|
11
13
|
export type { ImageConfig, ImageResource } from './image';
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,gBAAgB,GACjB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,cAAc,EACd,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,UAAU,EACV,OAAO,EACP,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/resources/index.js
CHANGED
|
@@ -5,4 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { Network } from './network';
|
|
7
7
|
export { Container } from './container';
|
|
8
|
+
// Container resource schemas and types
|
|
9
|
+
export { containerStatsSchema, execOptionsSchema, execResultSchema, logOptionsSchema, logLineSchema, cpuStatsSchema, memoryStatsSchema, networkStatsSchema, statsOptionsSchema, } from './schemas';
|
|
8
10
|
export { Image } from './image';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/resources/network.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAQ,MAAM,QAAQ,CAAC;AAC7C,OAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAiCD;;GAEG;AACH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/resources/network.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAQ,MAAM,QAAQ,CAAC;AAC7C,OAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAiCD;;GAEG;AACH,eAAO,MAAM,OAAO,mHAmFjB,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod Schemas for Container Resources
|
|
3
|
+
*
|
|
4
|
+
* Defines validation schemas for container stats, exec, and log streaming.
|
|
5
|
+
* Following Alchemy.run patterns for declarative resource definitions.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* CPU statistics from Docker container
|
|
10
|
+
*/
|
|
11
|
+
export declare const cpuStatsSchema: z.ZodObject<{
|
|
12
|
+
usage: z.ZodNumber;
|
|
13
|
+
system: z.ZodNumber;
|
|
14
|
+
percent: z.ZodNumber;
|
|
15
|
+
cores: z.ZodNumber;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
/**
|
|
18
|
+
* Memory statistics from Docker container
|
|
19
|
+
*/
|
|
20
|
+
export declare const memoryStatsSchema: z.ZodObject<{
|
|
21
|
+
usage: z.ZodNumber;
|
|
22
|
+
limit: z.ZodNumber;
|
|
23
|
+
percent: z.ZodNumber;
|
|
24
|
+
usageMB: z.ZodNumber;
|
|
25
|
+
limitMB: z.ZodNumber;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
/**
|
|
28
|
+
* Network I/O statistics from Docker container
|
|
29
|
+
*/
|
|
30
|
+
export declare const networkStatsSchema: z.ZodObject<{
|
|
31
|
+
rxBytes: z.ZodNumber;
|
|
32
|
+
txBytes: z.ZodNumber;
|
|
33
|
+
rxPackets: z.ZodNumber;
|
|
34
|
+
txPackets: z.ZodNumber;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
/**
|
|
37
|
+
* Complete container statistics
|
|
38
|
+
*/
|
|
39
|
+
export declare const containerStatsSchema: z.ZodObject<{
|
|
40
|
+
cpu: z.ZodObject<{
|
|
41
|
+
usage: z.ZodNumber;
|
|
42
|
+
system: z.ZodNumber;
|
|
43
|
+
percent: z.ZodNumber;
|
|
44
|
+
cores: z.ZodNumber;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
memory: z.ZodObject<{
|
|
47
|
+
usage: z.ZodNumber;
|
|
48
|
+
limit: z.ZodNumber;
|
|
49
|
+
percent: z.ZodNumber;
|
|
50
|
+
usageMB: z.ZodNumber;
|
|
51
|
+
limitMB: z.ZodNumber;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
network: z.ZodObject<{
|
|
54
|
+
rxBytes: z.ZodNumber;
|
|
55
|
+
txBytes: z.ZodNumber;
|
|
56
|
+
rxPackets: z.ZodNumber;
|
|
57
|
+
txPackets: z.ZodNumber;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
timestamp: z.ZodString;
|
|
60
|
+
containerId: z.ZodString;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type ContainerStats = z.infer<typeof containerStatsSchema>;
|
|
63
|
+
export type CpuStats = z.infer<typeof cpuStatsSchema>;
|
|
64
|
+
export type MemoryStats = z.infer<typeof memoryStatsSchema>;
|
|
65
|
+
export type NetworkStats = z.infer<typeof networkStatsSchema>;
|
|
66
|
+
/**
|
|
67
|
+
* Options for executing a command in a container
|
|
68
|
+
*/
|
|
69
|
+
export declare const execOptionsSchema: z.ZodObject<{
|
|
70
|
+
cmd: z.ZodArray<z.ZodString>;
|
|
71
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
72
|
+
workingDir: z.ZodOptional<z.ZodString>;
|
|
73
|
+
user: z.ZodOptional<z.ZodString>;
|
|
74
|
+
privileged: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
tty: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
/**
|
|
78
|
+
* Result of executing a command in a container
|
|
79
|
+
*/
|
|
80
|
+
export declare const execResultSchema: z.ZodObject<{
|
|
81
|
+
exitCode: z.ZodNumber;
|
|
82
|
+
stdout: z.ZodString;
|
|
83
|
+
stderr: z.ZodString;
|
|
84
|
+
durationMs: z.ZodNumber;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
export type ExecOptions = z.infer<typeof execOptionsSchema>;
|
|
87
|
+
export type ExecResult = z.infer<typeof execResultSchema>;
|
|
88
|
+
/**
|
|
89
|
+
* Options for streaming container logs
|
|
90
|
+
*/
|
|
91
|
+
export declare const logOptionsSchema: z.ZodObject<{
|
|
92
|
+
stdout: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
+
stderr: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
since: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
until: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
tail: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
timestamps: z.ZodOptional<z.ZodBoolean>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
/**
|
|
100
|
+
* A single log line from a container
|
|
101
|
+
*/
|
|
102
|
+
export declare const logLineSchema: z.ZodObject<{
|
|
103
|
+
stream: z.ZodEnum<{
|
|
104
|
+
stderr: "stderr";
|
|
105
|
+
stdout: "stdout";
|
|
106
|
+
}>;
|
|
107
|
+
timestamp: z.ZodOptional<z.ZodString>;
|
|
108
|
+
message: z.ZodString;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
export type LogOptions = z.infer<typeof logOptionsSchema>;
|
|
111
|
+
export type LogLine = z.infer<typeof logLineSchema>;
|
|
112
|
+
/**
|
|
113
|
+
* Options for getting container stats
|
|
114
|
+
*/
|
|
115
|
+
export declare const statsOptionsSchema: z.ZodObject<{
|
|
116
|
+
stream: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
117
|
+
oneShot: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
export type StatsOptions = z.infer<typeof statsOptionsSchema>;
|
|
120
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/resources/schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;iBAKzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;iBAM5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;iBAK7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;iBAM/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACtD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CA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