@ebowwa/codespaces-types 1.1.0 → 1.2.0

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 (67) hide show
  1. package/{dist/compile → compile}/index.js +41 -15
  2. package/compile/index.ts +553 -0
  3. package/compile/resources.js +116 -0
  4. package/compile/resources.ts +157 -0
  5. package/compile/schemas/resources.js +127 -0
  6. package/compile/schemas/resources.ts +144 -0
  7. package/{dist/compile → compile}/terminal-websocket.js +4 -1
  8. package/compile/terminal-websocket.ts +133 -0
  9. package/compile/time.js +30 -0
  10. package/compile/time.ts +32 -0
  11. package/{dist/compile → compile}/user/distributions.js +0 -1
  12. package/{dist/compile/user/distributions.d.ts → compile/user/distributions.ts} +0 -1
  13. package/{dist/compile → compile}/validation.js +23 -17
  14. package/compile/validation.ts +98 -0
  15. package/index.js +21 -0
  16. package/index.ts +5 -0
  17. package/package.json +38 -45
  18. package/runtime/ai.js +505 -0
  19. package/runtime/ai.ts +501 -0
  20. package/runtime/api.js +677 -0
  21. package/runtime/api.ts +857 -0
  22. package/runtime/database.js +94 -0
  23. package/runtime/database.ts +107 -0
  24. package/runtime/env.js +63 -0
  25. package/runtime/env.ts +68 -0
  26. package/{dist/runtime → runtime}/glm.js +7 -4
  27. package/runtime/glm.ts +36 -0
  28. package/runtime/index.js +28 -0
  29. package/{dist/runtime/index.js → runtime/index.ts} +1 -0
  30. package/runtime/ssh.js +47 -0
  31. package/runtime/ssh.ts +58 -0
  32. package/README.md +0 -65
  33. package/dist/compile/index.d.ts +0 -437
  34. package/dist/compile/index.d.ts.map +0 -1
  35. package/dist/compile/resources.d.ts +0 -69
  36. package/dist/compile/resources.d.ts.map +0 -1
  37. package/dist/compile/resources.js +0 -113
  38. package/dist/compile/schemas/resources.d.ts +0 -166
  39. package/dist/compile/schemas/resources.d.ts.map +0 -1
  40. package/dist/compile/schemas/resources.js +0 -123
  41. package/dist/compile/terminal-websocket.d.ts +0 -109
  42. package/dist/compile/terminal-websocket.d.ts.map +0 -1
  43. package/dist/compile/time.d.ts +0 -7
  44. package/dist/compile/time.d.ts.map +0 -1
  45. package/dist/compile/time.js +0 -27
  46. package/dist/compile/user/distributions.d.ts.map +0 -1
  47. package/dist/compile/validation.d.ts +0 -44
  48. package/dist/compile/validation.d.ts.map +0 -1
  49. package/dist/runtime/ai.d.ts +0 -1336
  50. package/dist/runtime/ai.d.ts.map +0 -1
  51. package/dist/runtime/ai.js +0 -416
  52. package/dist/runtime/api.d.ts +0 -1304
  53. package/dist/runtime/api.d.ts.map +0 -1
  54. package/dist/runtime/api.js +0 -673
  55. package/dist/runtime/database.d.ts +0 -376
  56. package/dist/runtime/database.d.ts.map +0 -1
  57. package/dist/runtime/database.js +0 -91
  58. package/dist/runtime/env.d.ts +0 -121
  59. package/dist/runtime/env.d.ts.map +0 -1
  60. package/dist/runtime/env.js +0 -54
  61. package/dist/runtime/glm.d.ts +0 -17
  62. package/dist/runtime/glm.d.ts.map +0 -1
  63. package/dist/runtime/index.d.ts +0 -13
  64. package/dist/runtime/index.d.ts.map +0 -1
  65. package/dist/runtime/ssh.d.ts +0 -111
  66. package/dist/runtime/ssh.d.ts.map +0 -1
  67. package/dist/runtime/ssh.js +0 -44
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /**
3
+ * Zod schemas for database operations validation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PluginsUpdateSchema = exports.ActivityUpdateSchema = exports.EnvironmentMetadataSchema = exports.ActivePortSchema = void 0;
7
+ var zod_1 = require("zod");
8
+ /**
9
+ * Active port schema
10
+ */
11
+ exports.ActivePortSchema = zod_1.z.object({
12
+ port: zod_1.z.number().int().min(1).max(65535),
13
+ protocol: zod_1.z.enum(["tcp", "udp"]),
14
+ service: zod_1.z.string().optional(),
15
+ state: zod_1.z.enum(["open", "closed", "filtered"]),
16
+ });
17
+ /**
18
+ * Environment metadata schema for database operations
19
+ */
20
+ exports.EnvironmentMetadataSchema = zod_1.z.object({
21
+ id: zod_1.z.string(),
22
+ description: zod_1.z.string().optional(),
23
+ project: zod_1.z.string().optional(),
24
+ owner: zod_1.z.string().optional(),
25
+ purpose: zod_1.z.string().optional(),
26
+ environmentType: zod_1.z
27
+ .enum(["development", "staging", "production", "testing"])
28
+ .optional(),
29
+ hoursActive: zod_1.z.number().min(0).optional(),
30
+ lastActive: zod_1.z.string().datetime().optional(),
31
+ activePorts: zod_1.z.array(exports.ActivePortSchema).optional(),
32
+ sshKeyPath: zod_1.z.string().optional(), // Path to SSH private key for terminal connections
33
+ bootstrapStatus: zod_1.z.enum(["bootstrapping", "ready", "failed"]).optional(), // Cloud-init bootstrap status
34
+ permissions: zod_1.z
35
+ .object({
36
+ seedConfig: zod_1.z
37
+ .object({
38
+ sourceEnvironmentId: zod_1.z.string().optional(),
39
+ dependencySnapshot: zod_1.z.string().optional(),
40
+ setupScript: zod_1.z.string().optional(),
41
+ })
42
+ .optional(),
43
+ logins: zod_1.z
44
+ .object({
45
+ github: zod_1.z
46
+ .object({
47
+ enabled: zod_1.z.boolean(),
48
+ username: zod_1.z.string().optional(),
49
+ tokenScopes: zod_1.z.array(zod_1.z.string()).optional(),
50
+ })
51
+ .optional(),
52
+ doppler: zod_1.z
53
+ .object({
54
+ enabled: zod_1.z.boolean(),
55
+ project: zod_1.z.string().optional(),
56
+ config: zod_1.z.string().optional(),
57
+ })
58
+ .optional(),
59
+ tailscale: zod_1.z
60
+ .object({
61
+ enabled: zod_1.z.boolean(),
62
+ authKey: zod_1.z.string().optional(),
63
+ hostname: zod_1.z.string().optional(),
64
+ })
65
+ .optional(),
66
+ })
67
+ .optional(),
68
+ vpns: zod_1.z
69
+ .array(zod_1.z.object({
70
+ name: zod_1.z.string(),
71
+ type: zod_1.z.enum(["wireguard", "openvpn", "tailscale"]),
72
+ config: zod_1.z.string(),
73
+ connected: zod_1.z.boolean(),
74
+ }))
75
+ .optional(),
76
+ plugins: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
77
+ })
78
+ .optional(),
79
+ updatedAt: zod_1.z.string().datetime().optional(),
80
+ });
81
+ /**
82
+ * Activity update schema
83
+ */
84
+ exports.ActivityUpdateSchema = zod_1.z.object({
85
+ hoursActive: zod_1.z.number().min(0).optional(),
86
+ lastActive: zod_1.z.string().datetime().optional(),
87
+ activePorts: zod_1.z.array(exports.ActivePortSchema).optional(),
88
+ });
89
+ /**
90
+ * Plugins update schema
91
+ */
92
+ exports.PluginsUpdateSchema = zod_1.z.object({
93
+ plugins: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
94
+ });
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Zod schemas for database operations validation
3
+ */
4
+
5
+ import { z } from "zod";
6
+
7
+ /**
8
+ * Active port schema
9
+ */
10
+ export const ActivePortSchema = z.object({
11
+ port: z.number().int().min(1).max(65535),
12
+ protocol: z.enum(["tcp", "udp"]),
13
+ service: z.string().optional(),
14
+ state: z.enum(["open", "closed", "filtered"]),
15
+ });
16
+
17
+ /**
18
+ * Environment metadata schema for database operations
19
+ */
20
+ export const EnvironmentMetadataSchema = z.object({
21
+ id: z.string(),
22
+ description: z.string().optional(),
23
+ project: z.string().optional(),
24
+ owner: z.string().optional(),
25
+ purpose: z.string().optional(),
26
+ environmentType: z
27
+ .enum(["development", "staging", "production", "testing"])
28
+ .optional(),
29
+ hoursActive: z.number().min(0).optional(),
30
+ lastActive: z.string().datetime().optional(),
31
+ activePorts: z.array(ActivePortSchema).optional(),
32
+ sshKeyPath: z.string().optional(), // Path to SSH private key for terminal connections
33
+ bootstrapStatus: z.enum(["bootstrapping", "ready", "failed"]).optional(), // Cloud-init bootstrap status
34
+ permissions: z
35
+ .object({
36
+ seedConfig: z
37
+ .object({
38
+ sourceEnvironmentId: z.string().optional(),
39
+ dependencySnapshot: z.string().optional(),
40
+ setupScript: z.string().optional(),
41
+ })
42
+ .optional(),
43
+ logins: z
44
+ .object({
45
+ github: z
46
+ .object({
47
+ enabled: z.boolean(),
48
+ username: z.string().optional(),
49
+ tokenScopes: z.array(z.string()).optional(),
50
+ })
51
+ .optional(),
52
+ doppler: z
53
+ .object({
54
+ enabled: z.boolean(),
55
+ project: z.string().optional(),
56
+ config: z.string().optional(),
57
+ })
58
+ .optional(),
59
+ tailscale: z
60
+ .object({
61
+ enabled: z.boolean(),
62
+ authKey: z.string().optional(),
63
+ hostname: z.string().optional(),
64
+ })
65
+ .optional(),
66
+ })
67
+ .optional(),
68
+ vpns: z
69
+ .array(
70
+ z.object({
71
+ name: z.string(),
72
+ type: z.enum(["wireguard", "openvpn", "tailscale"]),
73
+ config: z.string(),
74
+ connected: z.boolean(),
75
+ }),
76
+ )
77
+ .optional(),
78
+ plugins: z.record(z.string(), z.any()).optional(),
79
+ })
80
+ .optional(),
81
+ updatedAt: z.string().datetime().optional(),
82
+ });
83
+
84
+ /**
85
+ * Activity update schema
86
+ */
87
+ export const ActivityUpdateSchema = z.object({
88
+ hoursActive: z.number().min(0).optional(),
89
+ lastActive: z.string().datetime().optional(),
90
+ activePorts: z.array(ActivePortSchema).optional(),
91
+ });
92
+
93
+ /**
94
+ * Plugins update schema
95
+ */
96
+ export const PluginsUpdateSchema = z.object({
97
+ plugins: z.record(z.string(), z.any()).optional(),
98
+ });
99
+
100
+ /**
101
+ * Type exports for TypeScript inference
102
+ */
103
+ export type EnvironmentMetadataInput = z.infer<
104
+ typeof EnvironmentMetadataSchema
105
+ >;
106
+ export type ActivityUpdateInput = z.infer<typeof ActivityUpdateSchema>;
107
+ export type PluginsUpdateInput = z.infer<typeof PluginsUpdateSchema>;
package/runtime/env.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ /**
3
+ * Zod schemas for environment variable validation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EnvSchema = exports.AIEnvSchema = exports.ServerEnvSchema = void 0;
7
+ exports.validateEnv = validateEnv;
8
+ exports.validateServerEnv = validateServerEnv;
9
+ exports.validateAIEnv = validateAIEnv;
10
+ var zod_1 = require("zod");
11
+ /**
12
+ * Server environment variables schema
13
+ */
14
+ exports.ServerEnvSchema = zod_1.z.object({
15
+ TEMP_UPLOAD_DIR: zod_1.z.string().optional().default('/tmp/cheapspaces-uploads'),
16
+ HETZNER_API_TOKEN: zod_1.z.string().min(1).optional(),
17
+ });
18
+ /**
19
+ * AI client environment variables schema
20
+ * At least one API key must be provided
21
+ */
22
+ exports.AIEnvSchema = zod_1.z
23
+ .object({
24
+ Z_AI_API_KEY: zod_1.z.string().min(1).optional(),
25
+ ZAI_API_KEY: zod_1.z.string().min(1).optional(),
26
+ GLM_API_KEY: zod_1.z.string().min(1).optional(),
27
+ })
28
+ .refine(function (data) { return data.Z_AI_API_KEY || data.ZAI_API_KEY || data.GLM_API_KEY; }, {
29
+ message: 'At least one AI API key must be provided (Z_AI_API_KEY, ZAI_API_KEY, or GLM_API_KEY)',
30
+ });
31
+ /**
32
+ * Full environment variables schema
33
+ */
34
+ exports.EnvSchema = zod_1.z.object({
35
+ TEMP_UPLOAD_DIR: zod_1.z.string().optional().default('/tmp/cheapspaces-uploads'),
36
+ HETZNER_API_TOKEN: zod_1.z.string().min(1).optional(),
37
+ Z_AI_API_KEY: zod_1.z.string().min(1).optional(),
38
+ ZAI_API_KEY: zod_1.z.string().min(1).optional(),
39
+ GLM_API_KEY: zod_1.z.string().min(1).optional(),
40
+ }).refine(function (data) { return data.Z_AI_API_KEY || data.ZAI_API_KEY || data.GLM_API_KEY; }, {
41
+ message: 'At least one AI API key must be provided (Z_AI_API_KEY, ZAI_API_KEY, or GLM_API_KEY)',
42
+ });
43
+ /**
44
+ * Validate and parse environment variables
45
+ */
46
+ function validateEnv(env) {
47
+ if (env === void 0) { env = process.env; }
48
+ return exports.EnvSchema.safeParse(env);
49
+ }
50
+ /**
51
+ * Validate and parse server environment variables
52
+ */
53
+ function validateServerEnv(env) {
54
+ if (env === void 0) { env = process.env; }
55
+ return exports.ServerEnvSchema.safeParse(env);
56
+ }
57
+ /**
58
+ * Validate and parse AI environment variables
59
+ */
60
+ function validateAIEnv(env) {
61
+ if (env === void 0) { env = process.env; }
62
+ return exports.AIEnvSchema.safeParse(env);
63
+ }
package/runtime/env.ts ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Zod schemas for environment variable validation
3
+ */
4
+
5
+ import { z } from 'zod'
6
+
7
+ /**
8
+ * Server environment variables schema
9
+ */
10
+ export const ServerEnvSchema = z.object({
11
+ TEMP_UPLOAD_DIR: z.string().optional().default('/tmp/cheapspaces-uploads'),
12
+ HETZNER_API_TOKEN: z.string().min(1).optional(),
13
+ })
14
+
15
+ /**
16
+ * AI client environment variables schema
17
+ * At least one API key must be provided
18
+ */
19
+ export const AIEnvSchema = z
20
+ .object({
21
+ Z_AI_API_KEY: z.string().min(1).optional(),
22
+ ZAI_API_KEY: z.string().min(1).optional(),
23
+ GLM_API_KEY: z.string().min(1).optional(),
24
+ })
25
+ .refine((data) => data.Z_AI_API_KEY || data.ZAI_API_KEY || data.GLM_API_KEY, {
26
+ message: 'At least one AI API key must be provided (Z_AI_API_KEY, ZAI_API_KEY, or GLM_API_KEY)',
27
+ })
28
+
29
+ /**
30
+ * Full environment variables schema
31
+ */
32
+ export const EnvSchema = z.object({
33
+ TEMP_UPLOAD_DIR: z.string().optional().default('/tmp/cheapspaces-uploads'),
34
+ HETZNER_API_TOKEN: z.string().min(1).optional(),
35
+ Z_AI_API_KEY: z.string().min(1).optional(),
36
+ ZAI_API_KEY: z.string().min(1).optional(),
37
+ GLM_API_KEY: z.string().min(1).optional(),
38
+ }).refine((data) => data.Z_AI_API_KEY || data.ZAI_API_KEY || data.GLM_API_KEY, {
39
+ message: 'At least one AI API key must be provided (Z_AI_API_KEY, ZAI_API_KEY, or GLM_API_KEY)',
40
+ })
41
+
42
+ /**
43
+ * Validate and parse environment variables
44
+ */
45
+ export function validateEnv(env: Record<string, string | undefined> = process.env) {
46
+ return EnvSchema.safeParse(env)
47
+ }
48
+
49
+ /**
50
+ * Validate and parse server environment variables
51
+ */
52
+ export function validateServerEnv(env: Record<string, string | undefined> = process.env) {
53
+ return ServerEnvSchema.safeParse(env)
54
+ }
55
+
56
+ /**
57
+ * Validate and parse AI environment variables
58
+ */
59
+ export function validateAIEnv(env: Record<string, string | undefined> = process.env) {
60
+ return AIEnvSchema.safeParse(env)
61
+ }
62
+
63
+ /**
64
+ * Type exports for TypeScript inference
65
+ */
66
+ export type ServerEnv = z.infer<typeof ServerEnvSchema>
67
+ export type AIEnv = z.infer<typeof AIEnvSchema>
68
+ export type Env = z.infer<typeof EnvSchema>
@@ -1,17 +1,20 @@
1
+ "use strict";
1
2
  /**
2
3
  * Zod schemas for Z.AI GLM API
3
4
  *
4
5
  * Provider-specific schemas for Z.AI (GLM) models.
5
6
  * Generic AI schemas (chat messages, streaming, etc.) are in ./ai.ts
6
7
  */
7
- import { z } from "zod";
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.GLMModelSchema = void 0;
10
+ var zod_1 = require("zod");
8
11
  // ============================================================================
9
12
  // Z.AI GLM MODELS
10
13
  // ============================================================================
11
14
  /**
12
15
  * Available GLM models from Z.AI API
13
16
  */
14
- export const GLMModelSchema = z.enum([
17
+ exports.GLMModelSchema = zod_1.z.enum([
15
18
  "GLM-4.7",
16
19
  "GLM-4.6",
17
20
  "GLM-4.5",
@@ -20,6 +23,6 @@ export const GLMModelSchema = z.enum([
20
23
  // ============================================================================
21
24
  // EXPORTS
22
25
  // ============================================================================
23
- export default {
24
- GLMModelSchema,
26
+ exports.default = {
27
+ GLMModelSchema: exports.GLMModelSchema,
25
28
  };
package/runtime/glm.ts ADDED
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Zod schemas for Z.AI GLM API
3
+ *
4
+ * Provider-specific schemas for Z.AI (GLM) models.
5
+ * Generic AI schemas (chat messages, streaming, etc.) are in ./ai.ts
6
+ */
7
+
8
+ import { z } from "zod";
9
+
10
+ // ============================================================================
11
+ // Z.AI GLM MODELS
12
+ // ============================================================================
13
+
14
+ /**
15
+ * Available GLM models from Z.AI API
16
+ */
17
+ export const GLMModelSchema = z.enum([
18
+ "GLM-4.7",
19
+ "GLM-4.6",
20
+ "GLM-4.5",
21
+ "GLM-4.5-air",
22
+ ]);
23
+
24
+ // ============================================================================
25
+ // TYPE INFERENCE
26
+ // ============================================================================
27
+
28
+ export type GLMModel = z.infer<typeof GLMModelSchema>;
29
+
30
+ // ============================================================================
31
+ // EXPORTS
32
+ // ============================================================================
33
+
34
+ export default {
35
+ GLMModelSchema,
36
+ };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Central export point for all Zod schemas
4
+ *
5
+ * Note: Hetzner schemas are in app/backend/shared/lib/hetzner/schemas.ts
6
+ * to keep them with the Hetzner client implementation.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ __exportStar(require("./api.js"), exports);
24
+ __exportStar(require("./ai.js"), exports);
25
+ __exportStar(require("./database.js"), exports);
26
+ __exportStar(require("./env.js"), exports);
27
+ __exportStar(require("./glm.js"), exports);
28
+ __exportStar(require("./ssh.js"), exports);
@@ -4,6 +4,7 @@
4
4
  * Note: Hetzner schemas are in app/backend/shared/lib/hetzner/schemas.ts
5
5
  * to keep them with the Hetzner client implementation.
6
6
  */
7
+
7
8
  export * from "./api.js";
8
9
  export * from "./ai.js";
9
10
  export * from "./database.js";
package/runtime/ssh.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /**
3
+ * Zod schemas for SSH operations validation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FilePreviewOptionsSchema = exports.FilesListOptionsSchema = exports.SCPOptionsSchema = exports.SSHCommandSchema = exports.SSHOptionsSchema = void 0;
7
+ var zod_1 = require("zod");
8
+ /**
9
+ * SSH connection options schema
10
+ */
11
+ exports.SSHOptionsSchema = zod_1.z.object({
12
+ host: zod_1.z.string().min(1, 'Host is required'),
13
+ user: zod_1.z.string().default('root'),
14
+ timeout: zod_1.z.number().int().positive().default(5),
15
+ port: zod_1.z.number().int().positive().max(65535).default(22),
16
+ keyPath: zod_1.z.string().optional(),
17
+ password: zod_1.z.string().optional(),
18
+ });
19
+ /**
20
+ * SSH command validation schema
21
+ */
22
+ exports.SSHCommandSchema = zod_1.z.string().min(1, 'Command cannot be empty');
23
+ /**
24
+ * SCP options schema (extends SSH options)
25
+ */
26
+ exports.SCPOptionsSchema = exports.SSHOptionsSchema.extend({
27
+ source: zod_1.z.string().min(1, 'Source is required'),
28
+ destination: zod_1.z.string().min(1, 'Destination is required'),
29
+ recursive: zod_1.z.boolean().default(false),
30
+ preserve: zod_1.z.boolean().default(false),
31
+ });
32
+ /**
33
+ * Files list options schema
34
+ */
35
+ exports.FilesListOptionsSchema = zod_1.z.object({
36
+ host: zod_1.z.string().min(1, 'Host is required'),
37
+ user: zod_1.z.string().default('root'),
38
+ path: zod_1.z.string().default('.'),
39
+ });
40
+ /**
41
+ * File preview options schema
42
+ */
43
+ exports.FilePreviewOptionsSchema = zod_1.z.object({
44
+ host: zod_1.z.string().min(1, 'Host is required'),
45
+ user: zod_1.z.string().default('root'),
46
+ path: zod_1.z.string().min(1, 'Path is required'),
47
+ });
package/runtime/ssh.ts ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Zod schemas for SSH operations validation
3
+ */
4
+
5
+ import { z } from 'zod'
6
+
7
+ /**
8
+ * SSH connection options schema
9
+ */
10
+ export const SSHOptionsSchema = z.object({
11
+ host: z.string().min(1, 'Host is required'),
12
+ user: z.string().default('root'),
13
+ timeout: z.number().int().positive().default(5),
14
+ port: z.number().int().positive().max(65535).default(22),
15
+ keyPath: z.string().optional(),
16
+ password: z.string().optional(),
17
+ })
18
+
19
+ /**
20
+ * SSH command validation schema
21
+ */
22
+ export const SSHCommandSchema = z.string().min(1, 'Command cannot be empty')
23
+
24
+ /**
25
+ * SCP options schema (extends SSH options)
26
+ */
27
+ export const SCPOptionsSchema = SSHOptionsSchema.extend({
28
+ source: z.string().min(1, 'Source is required'),
29
+ destination: z.string().min(1, 'Destination is required'),
30
+ recursive: z.boolean().default(false),
31
+ preserve: z.boolean().default(false),
32
+ })
33
+
34
+ /**
35
+ * Files list options schema
36
+ */
37
+ export const FilesListOptionsSchema = z.object({
38
+ host: z.string().min(1, 'Host is required'),
39
+ user: z.string().default('root'),
40
+ path: z.string().default('.'),
41
+ })
42
+
43
+ /**
44
+ * File preview options schema
45
+ */
46
+ export const FilePreviewOptionsSchema = z.object({
47
+ host: z.string().min(1, 'Host is required'),
48
+ user: z.string().default('root'),
49
+ path: z.string().min(1, 'Path is required'),
50
+ })
51
+
52
+ /**
53
+ * Type exports for TypeScript inference
54
+ */
55
+ export type SSHOptions = z.infer<typeof SSHOptionsSchema>
56
+ export type SCPOptions = z.infer<typeof SCPOptionsSchema>
57
+ export type FilesListOptions = z.infer<typeof FilesListOptionsSchema>
58
+ export type FilePreviewOptions = z.infer<typeof FilePreviewOptionsSchema>
package/README.md DELETED
@@ -1,65 +0,0 @@
1
- # @ebowwa/codespaces-types
2
-
3
- Shared types and runtime validation schemas for codespaces projects.
4
-
5
- ## Structure
6
-
7
- - **`/runtime`** - Zod schemas for runtime validation
8
- - **`/compile`** - TypeScript type definitions for compile-time checking
9
-
10
- ## Installation
11
-
12
- ```bash
13
- npm install @ebowwa/codespaces-types
14
- ```
15
-
16
- ## Usage
17
-
18
- ### Runtime Validation (Zod Schemas)
19
-
20
- ```typescript
21
- import { CreateEnvironmentRequestSchema } from '@ebowwa/codespaces-types/runtime/api';
22
-
23
- // Validate data at runtime
24
- const result = CreateEnvironmentRequestSchema.parse(userData);
25
- ```
26
-
27
- ### Compile-Time Types
28
-
29
- ```typescript
30
- import type { Environment, HetznerServerType } from '@ebowwa/codespaces-types/compile';
31
-
32
- // Type checking at compile time
33
- const env: Environment = { /* ... */ };
34
- ```
35
-
36
- ### Type Inference (Recommended)
37
-
38
- Runtime schemas automatically export inferred TypeScript types:
39
-
40
- ```typescript
41
- import {
42
- CreateEnvironmentRequestSchema,
43
- type CreateEnvironmentRequest
44
- } from '@ebowwa/codespaces-types/runtime/api';
45
-
46
- const data: CreateEnvironmentRequest = { /* ... */ };
47
- const validated = CreateEnvironmentRequestSchema.parse(data);
48
- ```
49
-
50
- ## Available Exports
51
-
52
- ### Runtime (`./runtime/*`)
53
- - `api` - API request/response validation schemas
54
- - `ai` - AI-related schemas
55
- - `database` - Database validation schemas
56
- - `env` - Environment variable schemas
57
- - `glm` - GLM-specific schemas
58
- - `ssh` - SSH configuration schemas
59
-
60
- ### Compile-Time Types (`./compile/*`)
61
- - `index` - Main type exports (Environment, Hetzner types, etc.)
62
-
63
- ## License
64
-
65
- MIT