@ebowwa/codespaces-types 1.4.0 → 1.4.2
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/compile/index.js +245 -111
- package/compile/index.ts +4 -4
- package/compile/resources.js +86 -105
- package/compile/terminal-websocket.js +28 -39
- package/compile/time.js +24 -28
- package/compile/validation.js +40 -80
- package/package.json +1 -1
- package/runtime/ai.js +286 -468
- package/runtime/ai.ts +27 -5
- package/runtime/api.js +452 -677
- package/runtime/database.js +64 -90
- package/runtime/env.js +34 -57
- package/runtime/glm.js +14 -26
- package/runtime/index.js +882 -26
- package/runtime/ssh.js +31 -43
package/compile/time.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.formatElapsedTime = formatElapsedTime;
|
|
4
|
-
/**
|
|
5
|
-
* Format elapsed time since a given date in full precision (e.g., "2d 14h 32m 15s")
|
|
6
|
-
* @param dateString - ISO date string to calculate elapsed time from
|
|
7
|
-
* @returns Formatted elapsed time string
|
|
8
|
-
*/
|
|
1
|
+
// @bun
|
|
2
|
+
// compile/time.ts
|
|
9
3
|
function formatElapsedTime(dateString) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return parts.join(' ');
|
|
4
|
+
const now = Date.now();
|
|
5
|
+
const created = new Date(dateString).getTime();
|
|
6
|
+
const elapsed = now - created;
|
|
7
|
+
const seconds = Math.floor(elapsed / 1000);
|
|
8
|
+
const minutes = Math.floor(seconds / 60);
|
|
9
|
+
const hours = Math.floor(minutes / 60);
|
|
10
|
+
const days = Math.floor(hours / 24);
|
|
11
|
+
const parts = [];
|
|
12
|
+
if (days > 0) {
|
|
13
|
+
parts.push(`${days}d`);
|
|
14
|
+
}
|
|
15
|
+
if (hours % 24 > 0 || days > 0) {
|
|
16
|
+
parts.push(`${hours % 24}h`);
|
|
17
|
+
}
|
|
18
|
+
if (minutes % 60 > 0 || hours > 0) {
|
|
19
|
+
parts.push(`${minutes % 60}m`);
|
|
20
|
+
}
|
|
21
|
+
parts.push(`${seconds % 60}s`);
|
|
22
|
+
return parts.join(" ");
|
|
30
23
|
}
|
|
24
|
+
export {
|
|
25
|
+
formatElapsedTime
|
|
26
|
+
};
|
package/compile/validation.js
CHANGED
|
@@ -1,86 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.validateSSHKeyName = validateSSHKeyName;
|
|
10
|
-
exports.validateAPIToken = validateAPIToken;
|
|
11
|
-
var zod_1 = require("zod");
|
|
12
|
-
/**
|
|
13
|
-
* Zod schema for environment name validation
|
|
14
|
-
* - Must start with a letter or number
|
|
15
|
-
* - Can contain letters, numbers, hyphens, and underscores
|
|
16
|
-
* - 1-64 characters long
|
|
17
|
-
* - Cannot be a reserved word
|
|
18
|
-
*/
|
|
19
|
-
exports.EnvironmentNameSchema = zod_1.z
|
|
20
|
-
.string()
|
|
21
|
-
.min(1, 'Environment name is required')
|
|
22
|
-
.max(64, 'Environment name must be 64 characters or less')
|
|
23
|
-
.regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/, 'Name must start with a letter or number and contain only letters, numbers, hyphens, and underscores')
|
|
24
|
-
.refine(function (name) { return !['ssh', 'ssh-keys', 'docker', 'registry', 'volume', 'network'].includes(name.toLowerCase()); }, {
|
|
25
|
-
message: 'Name is a reserved word',
|
|
26
|
-
})
|
|
27
|
-
.transform(function (val) { return val.trim(); });
|
|
28
|
-
/**
|
|
29
|
-
* Zod schema for SSH key name validation
|
|
30
|
-
*/
|
|
31
|
-
exports.SSHKeyNameSchema = zod_1.z
|
|
32
|
-
.string()
|
|
33
|
-
.min(1, 'SSH key name is required')
|
|
34
|
-
.max(64, 'Name must be 64 characters or less')
|
|
35
|
-
.transform(function (val) { return val.trim(); });
|
|
36
|
-
/**
|
|
37
|
-
* Zod schema for Hetzner API token validation
|
|
38
|
-
*/
|
|
39
|
-
exports.APITokenSchema = zod_1.z
|
|
40
|
-
.string()
|
|
41
|
-
.min(1, 'API token is required')
|
|
42
|
-
.min(32, 'API token appears too short')
|
|
43
|
-
.startsWith('hetzner_', 'Hetzner API tokens typically start with "hetzner_"')
|
|
44
|
-
.transform(function (val) { return val.trim(); });
|
|
45
|
-
/**
|
|
46
|
-
* Validates environment name according to Hetzner naming rules
|
|
47
|
-
* @deprecated Use EnvironmentNameSchema.safeParse() instead
|
|
48
|
-
*/
|
|
1
|
+
// @bun
|
|
2
|
+
// compile/validation.ts
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
var EnvironmentNameSchema = z.string().min(1, "Environment name is required").max(64, "Environment name must be 64 characters or less").regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/, "Name must start with a letter or number and contain only letters, numbers, hyphens, and underscores").refine((name) => !["ssh", "ssh-keys", "docker", "registry", "volume", "network"].includes(name.toLowerCase()), {
|
|
5
|
+
message: "Name is a reserved word"
|
|
6
|
+
}).transform((val) => val.trim());
|
|
7
|
+
var SSHKeyNameSchema = z.string().min(1, "SSH key name is required").max(64, "Name must be 64 characters or less").transform((val) => val.trim());
|
|
8
|
+
var APITokenSchema = z.string().min(1, "API token is required").min(32, "API token appears too short").startsWith("hetzner_", 'Hetzner API tokens typically start with "hetzner_"').transform((val) => val.trim());
|
|
49
9
|
function validateEnvironmentName(name) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
10
|
+
const result = EnvironmentNameSchema.safeParse(name);
|
|
11
|
+
if (result.success) {
|
|
12
|
+
return { isValid: true };
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
isValid: false,
|
|
16
|
+
error: result.error.issues.map((e) => e.message).join(", ")
|
|
17
|
+
};
|
|
58
18
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Validates SSH key name
|
|
61
|
-
* @deprecated Use SSHKeyNameSchema.safeParse() instead
|
|
62
|
-
*/
|
|
63
19
|
function validateSSHKeyName(name) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
20
|
+
const result = SSHKeyNameSchema.safeParse(name);
|
|
21
|
+
if (result.success) {
|
|
22
|
+
return { isValid: true };
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
isValid: false,
|
|
26
|
+
error: result.error.issues.map((e) => e.message).join(", ")
|
|
27
|
+
};
|
|
72
28
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Validates Hetzner API token format
|
|
75
|
-
* @deprecated Use APITokenSchema.safeParse() instead
|
|
76
|
-
*/
|
|
77
29
|
function validateAPIToken(token) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
30
|
+
const result = APITokenSchema.safeParse(token);
|
|
31
|
+
if (result.success) {
|
|
32
|
+
return { isValid: true };
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
isValid: false,
|
|
36
|
+
error: result.error.issues.map((e) => e.message).join(", ")
|
|
37
|
+
};
|
|
86
38
|
}
|
|
39
|
+
export {
|
|
40
|
+
validateSSHKeyName,
|
|
41
|
+
validateEnvironmentName,
|
|
42
|
+
validateAPIToken,
|
|
43
|
+
SSHKeyNameSchema,
|
|
44
|
+
EnvironmentNameSchema,
|
|
45
|
+
APITokenSchema
|
|
46
|
+
};
|