@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.
Files changed (38) hide show
  1. package/dist/__tests__/bindings.test.d.ts +10 -0
  2. package/dist/__tests__/bindings.test.d.ts.map +1 -0
  3. package/dist/__tests__/bindings.test.js +124 -0
  4. package/dist/__tests__/container.test.d.ts +12 -0
  5. package/dist/__tests__/container.test.d.ts.map +1 -0
  6. package/dist/__tests__/container.test.js +115 -0
  7. package/dist/__tests__/database.test.d.ts +10 -0
  8. package/dist/__tests__/database.test.d.ts.map +1 -0
  9. package/dist/__tests__/database.test.js +92 -0
  10. package/dist/__tests__/network.test.d.ts +10 -0
  11. package/dist/__tests__/network.test.d.ts.map +1 -0
  12. package/dist/__tests__/network.test.js +44 -0
  13. package/dist/api/index.d.ts +1 -1
  14. package/dist/api/index.d.ts.map +1 -1
  15. package/dist/api/promise.d.ts +8 -0
  16. package/dist/api/promise.d.ts.map +1 -1
  17. package/dist/api/promise.js +109 -4
  18. package/dist/build-strategies/types.d.ts.map +1 -1
  19. package/dist/config-patchers/types.d.ts.map +1 -1
  20. package/dist/dockerfile-transformers/types.d.ts.map +1 -1
  21. package/dist/errors.d.ts.map +1 -1
  22. package/dist/helpers/database.d.ts.map +1 -1
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -2
  26. package/dist/resources/container.d.ts +10 -0
  27. package/dist/resources/container.d.ts.map +1 -1
  28. package/dist/resources/container.js +222 -5
  29. package/dist/resources/image.d.ts +1 -1
  30. package/dist/resources/image.d.ts.map +1 -1
  31. package/dist/resources/index.d.ts +2 -0
  32. package/dist/resources/index.d.ts.map +1 -1
  33. package/dist/resources/index.js +2 -0
  34. package/dist/resources/network.d.ts.map +1 -1
  35. package/dist/resources/schemas.d.ts +120 -0
  36. package/dist/resources/schemas.d.ts.map +1 -0
  37. package/dist/resources/schemas.js +95 -0
  38. package/package.json +7 -4
@@ -0,0 +1,95 @@
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
+ // ============ Container Stats Schema ============
9
+ /**
10
+ * CPU statistics from Docker container
11
+ */
12
+ export const cpuStatsSchema = z.object({
13
+ usage: z.number().min(0).describe('CPU usage in nanoseconds'),
14
+ system: z.number().min(0).describe('System CPU usage in nanoseconds'),
15
+ percent: z.number().min(0).max(100).describe('CPU usage as percentage'),
16
+ cores: z.number().int().min(0).describe('Number of CPU cores available'),
17
+ });
18
+ /**
19
+ * Memory statistics from Docker container
20
+ */
21
+ export const memoryStatsSchema = z.object({
22
+ usage: z.number().min(0).describe('Current memory usage in bytes'),
23
+ limit: z.number().min(0).describe('Memory limit in bytes'),
24
+ percent: z.number().min(0).max(100).describe('Memory usage as percentage'),
25
+ usageMB: z.number().min(0).describe('Current memory usage in megabytes'),
26
+ limitMB: z.number().min(0).describe('Memory limit in megabytes'),
27
+ });
28
+ /**
29
+ * Network I/O statistics from Docker container
30
+ */
31
+ export const networkStatsSchema = z.object({
32
+ rxBytes: z.number().min(0).describe('Bytes received'),
33
+ txBytes: z.number().min(0).describe('Bytes transmitted'),
34
+ rxPackets: z.number().min(0).describe('Packets received'),
35
+ txPackets: z.number().min(0).describe('Packets transmitted'),
36
+ });
37
+ /**
38
+ * Complete container statistics
39
+ */
40
+ export const containerStatsSchema = z.object({
41
+ cpu: cpuStatsSchema,
42
+ memory: memoryStatsSchema,
43
+ network: networkStatsSchema,
44
+ timestamp: z.string().datetime().describe('ISO 8601 timestamp of stats collection'),
45
+ containerId: z.string().describe('Docker container ID'),
46
+ });
47
+ // ============ Exec Schemas ============
48
+ /**
49
+ * Options for executing a command in a container
50
+ */
51
+ export const execOptionsSchema = z.object({
52
+ cmd: z.array(z.string()).min(1).describe('Command and arguments to execute'),
53
+ env: z.record(z.string(), z.string()).optional().describe('Environment variables'),
54
+ workingDir: z.string().optional().describe('Working directory for the command'),
55
+ user: z.string().optional().describe('User to run the command as'),
56
+ privileged: z.boolean().optional().describe('Run with elevated privileges'),
57
+ tty: z.boolean().optional().describe('Allocate a pseudo-TTY'),
58
+ });
59
+ /**
60
+ * Result of executing a command in a container
61
+ */
62
+ export const execResultSchema = z.object({
63
+ exitCode: z.number().int().describe('Exit code of the command'),
64
+ stdout: z.string().describe('Standard output'),
65
+ stderr: z.string().describe('Standard error'),
66
+ durationMs: z.number().min(0).describe('Execution duration in milliseconds'),
67
+ });
68
+ // ============ Log Streaming Schemas ============
69
+ /**
70
+ * Options for streaming container logs
71
+ */
72
+ export const logOptionsSchema = z.object({
73
+ stdout: z.boolean().optional().describe('Include stdout (default: true)'),
74
+ stderr: z.boolean().optional().describe('Include stderr (default: true)'),
75
+ since: z.number().optional().describe('Unix timestamp to start from'),
76
+ until: z.number().optional().describe('Unix timestamp to end at'),
77
+ tail: z.number().int().min(0).optional().describe('Number of lines to tail'),
78
+ timestamps: z.boolean().optional().describe('Include timestamps (default: false)'),
79
+ });
80
+ /**
81
+ * A single log line from a container
82
+ */
83
+ export const logLineSchema = z.object({
84
+ stream: z.enum(['stdout', 'stderr']).describe('Which stream this line came from'),
85
+ timestamp: z.string().datetime().optional().describe('Timestamp if enabled'),
86
+ message: z.string().describe('Log message content'),
87
+ });
88
+ // ============ Stats Options Schema ============
89
+ /**
90
+ * Options for getting container stats
91
+ */
92
+ export const statsOptionsSchema = z.object({
93
+ stream: z.boolean().optional().default(false).describe('Stream continuous stats'),
94
+ oneShot: z.boolean().optional().default(true).describe('Get single stats snapshot'),
95
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docker-harpoon/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "license": "MIT",
5
5
  "description": "Core Docker resource primitives and binding interface",
6
6
  "type": "module",
@@ -12,10 +12,13 @@
12
12
  "import": "./dist/index.js"
13
13
  }
14
14
  },
15
- "files": ["dist"],
15
+ "files": [
16
+ "dist"
17
+ ],
16
18
  "scripts": {
17
- "build": "tsc",
18
- "typecheck": "tsc --noEmit"
19
+ "build": "tsgo",
20
+ "typecheck": "tsgo --noEmit",
21
+ "test": "bun test"
19
22
  },
20
23
  "dependencies": {
21
24
  "dockerode": "^4.0.9",