@figulus/schema 0.4.0-alpha-dev → 0.5.0-alpha-dev-1
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/.openapi-meta/index.ts +12 -0
- package/dist/core/entities/figspec.d.ts +659 -0
- package/dist/core/entities/figspec.d.ts.map +1 -0
- package/dist/core/entities/figspec.js +73 -0
- package/dist/core/entities/figspec.js.map +1 -0
- package/dist/core/entities/figstack.d.ts +139 -0
- package/dist/core/entities/figstack.d.ts.map +1 -0
- package/dist/core/entities/figstack.js +79 -0
- package/dist/core/entities/figstack.js.map +1 -0
- package/dist/core/entities/index.d.ts +3 -0
- package/dist/core/entities/index.d.ts.map +1 -0
- package/dist/core/entities/index.js +3 -0
- package/dist/core/entities/index.js.map +1 -0
- package/dist/core/execute.d.ts +64 -0
- package/dist/core/execute.d.ts.map +1 -0
- package/dist/core/execute.js +45 -0
- package/dist/core/execute.js.map +1 -0
- package/dist/core/generic.d.ts +35 -0
- package/dist/core/generic.d.ts.map +1 -0
- package/dist/core/generic.js +28 -0
- package/dist/core/generic.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/primitives.d.ts +3 -0
- package/dist/core/primitives.d.ts.map +1 -0
- package/dist/core/primitives.js +11 -0
- package/dist/core/primitives.js.map +1 -0
- package/dist/core/volumes.d.ts +160 -0
- package/dist/core/volumes.d.ts.map +1 -0
- package/dist/core/volumes.js +100 -0
- package/dist/core/volumes.js.map +1 -0
- package/dist/engine/deprecated/index.d.ts +2 -0
- package/dist/engine/deprecated/index.d.ts.map +1 -0
- package/dist/engine/deprecated/index.js +2 -0
- package/dist/engine/deprecated/index.js.map +1 -0
- package/dist/engine/deprecated/run-request.d.ts +73 -0
- package/dist/engine/deprecated/run-request.d.ts.map +1 -0
- package/dist/engine/deprecated/run-request.js +47 -0
- package/dist/engine/deprecated/run-request.js.map +1 -0
- package/dist/engine/dry-run.d.ts +15 -0
- package/dist/engine/dry-run.d.ts.map +1 -0
- package/dist/engine/dry-run.js +12 -0
- package/dist/engine/dry-run.js.map +1 -0
- package/dist/engine/health.d.ts +11 -0
- package/dist/engine/health.d.ts.map +1 -0
- package/dist/engine/health.js +9 -0
- package/dist/engine/health.js.map +1 -0
- package/dist/engine/images.d.ts +49 -0
- package/dist/engine/images.d.ts.map +1 -0
- package/dist/engine/images.js +44 -0
- package/dist/engine/images.js.map +1 -0
- package/dist/engine/index.d.ts +9 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +9 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/paths/containers.d.ts +8 -0
- package/dist/engine/paths/containers.d.ts.map +1 -0
- package/dist/engine/paths/containers.js +297 -0
- package/dist/engine/paths/containers.js.map +1 -0
- package/dist/engine/paths/dry-run.d.ts +3 -0
- package/dist/engine/paths/dry-run.d.ts.map +1 -0
- package/dist/engine/paths/dry-run.js +43 -0
- package/dist/engine/paths/dry-run.js.map +1 -0
- package/dist/engine/paths/health.d.ts +3 -0
- package/dist/engine/paths/health.d.ts.map +1 -0
- package/dist/engine/paths/health.js +36 -0
- package/dist/engine/paths/health.js.map +1 -0
- package/dist/engine/paths/images.d.ts +5 -0
- package/dist/engine/paths/images.d.ts.map +1 -0
- package/dist/engine/paths/images.js +144 -0
- package/dist/engine/paths/images.js.map +1 -0
- package/dist/engine/paths/index.d.ts +8 -0
- package/dist/engine/paths/index.d.ts.map +1 -0
- package/dist/engine/paths/index.js +8 -0
- package/dist/engine/paths/index.js.map +1 -0
- package/dist/engine/paths/sessions.d.ts +10 -0
- package/dist/engine/paths/sessions.d.ts.map +1 -0
- package/dist/engine/paths/sessions.js +484 -0
- package/dist/engine/paths/sessions.js.map +1 -0
- package/dist/engine/paths/stacks.d.ts +6 -0
- package/dist/engine/paths/stacks.d.ts.map +1 -0
- package/dist/engine/paths/stacks.js +175 -0
- package/dist/engine/paths/stacks.js.map +1 -0
- package/dist/engine/paths/volumes.d.ts +6 -0
- package/dist/engine/paths/volumes.d.ts.map +1 -0
- package/dist/engine/paths/volumes.js +164 -0
- package/dist/engine/paths/volumes.js.map +1 -0
- package/dist/engine/response.d.ts +8 -0
- package/dist/engine/response.d.ts.map +1 -0
- package/dist/engine/response.js +9 -0
- package/dist/engine/response.js.map +1 -0
- package/dist/engine/sessions.d.ts +343 -0
- package/dist/engine/sessions.d.ts.map +1 -0
- package/dist/engine/sessions.js +118 -0
- package/dist/engine/sessions.js.map +1 -0
- package/dist/engine/volumes.d.ts +52 -0
- package/dist/engine/volumes.d.ts.map +1 -0
- package/dist/engine/volumes.js +39 -0
- package/dist/engine/volumes.js.map +1 -0
- package/dist/index.d.ts +2 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -8
- package/dist/index.js.map +1 -1
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +3 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/json-schema.d.ts +82 -0
- package/dist/registry/json-schema.d.ts.map +1 -0
- package/dist/registry/json-schema.js +149 -0
- package/dist/registry/json-schema.js.map +1 -0
- package/dist/registry/metadata.d.ts +216 -0
- package/dist/registry/metadata.d.ts.map +1 -0
- package/dist/registry/metadata.js +143 -0
- package/dist/registry/metadata.js.map +1 -0
- package/package.json +10 -3
- package/scripts/fix-openapi-3.1.ts +183 -0
- package/scripts/generate-openapi-data.ts +51 -0
- package/scripts/generate-openapi-meta.ts +540 -0
- package/src/core/entities/figspec.ts +94 -0
- package/src/core/entities/figstack.ts +101 -0
- package/src/core/entities/index.ts +2 -0
- package/src/core/execute.ts +66 -0
- package/src/core/generic.ts +38 -0
- package/src/core/index.ts +5 -0
- package/src/core/primitives.ts +12 -0
- package/src/core/volumes.ts +124 -0
- package/src/engine/deprecated/index.ts +1 -0
- package/src/engine/deprecated/run-request.ts +53 -0
- package/src/engine/dry-run.ts +14 -0
- package/src/engine/health.ts +11 -0
- package/src/engine/images.ts +58 -0
- package/src/engine/index.ts +8 -0
- package/src/engine/paths/containers.ts +304 -0
- package/src/engine/paths/dry-run.ts +44 -0
- package/src/engine/paths/health.ts +37 -0
- package/src/engine/paths/images.ts +148 -0
- package/src/engine/paths/index.ts +7 -0
- package/src/engine/paths/sessions.ts +493 -0
- package/src/engine/paths/stacks.ts +179 -0
- package/src/engine/paths/volumes.ts +168 -0
- package/src/engine/response.ts +11 -0
- package/src/engine/sessions.ts +146 -0
- package/src/engine/volumes.ts +53 -0
- package/src/index.ts +2 -8
- package/src/registry/index.ts +2 -0
- package/src/registry/json-schema.ts +178 -0
- package/src/registry/metadata.ts +181 -0
- package/tests/figspec.test.ts +1 -1
- package/tests/schemas.test.ts +31 -31
- package/dist/figspec.d.ts +0 -4394
- package/dist/figspec.d.ts.map +0 -1
- package/dist/figspec.js +0 -214
- package/dist/figspec.js.map +0 -1
- package/dist/figstack.d.ts +0 -419
- package/dist/figstack.d.ts.map +0 -1
- package/dist/figstack.js +0 -72
- package/dist/figstack.js.map +0 -1
- package/dist/health.d.ts +0 -16
- package/dist/health.d.ts.map +0 -1
- package/dist/health.js +0 -7
- package/dist/health.js.map +0 -1
- package/dist/image.d.ts +0 -115
- package/dist/image.d.ts.map +0 -1
- package/dist/image.js +0 -42
- package/dist/image.js.map +0 -1
- package/dist/run-request.d.ts +0 -244
- package/dist/run-request.d.ts.map +0 -1
- package/dist/run-request.js +0 -43
- package/dist/run-request.js.map +0 -1
- package/dist/session.d.ts +0 -447
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js +0 -78
- package/dist/session.js.map +0 -1
- package/dist/shared.d.ts +0 -90
- package/dist/shared.d.ts.map +0 -1
- package/dist/shared.js +0 -41
- package/dist/shared.js.map +0 -1
- package/dist/volume.d.ts +0 -140
- package/dist/volume.d.ts.map +0 -1
- package/dist/volume.js +0 -37
- package/dist/volume.js.map +0 -1
- package/src/figspec.ts +0 -279
- package/src/figstack.ts +0 -92
- package/src/health.ts +0 -8
- package/src/image.ts +0 -55
- package/src/run-request.ts +0 -55
- package/src/session.ts +0 -101
- package/src/shared.ts +0 -56
- package/src/volume.ts +0 -50
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import z, { ZodObject, ZodRawShape } from "zod";
|
|
2
|
+
import { extendZodWithOpenApi } from "@asteasolutions/zod-to-openapi";
|
|
3
|
+
import { parseLicenseId } from "zod-spdx";
|
|
4
|
+
import { JsonSchemaSchema } from "./json-schema.js";
|
|
5
|
+
|
|
6
|
+
extendZodWithOpenApi(z);
|
|
7
|
+
|
|
8
|
+
const ipfsSchema = z.string().startsWith("ipfs:");
|
|
9
|
+
const urlLike = z.union([z.url(), ipfsSchema]);
|
|
10
|
+
|
|
11
|
+
export const namespaceMetadataEditorEntrySchema = z.object({
|
|
12
|
+
username: z.string(),
|
|
13
|
+
// Cannot exceed namespace push limit -- use this for more granular control, otherwise first-in-first-served
|
|
14
|
+
pushLimit: z
|
|
15
|
+
.discriminatedUnion("unit", [
|
|
16
|
+
z.object({
|
|
17
|
+
unit: z.literal("daily"),
|
|
18
|
+
value: z.int(),
|
|
19
|
+
}),
|
|
20
|
+
z.object({
|
|
21
|
+
unit: z.literal("weekly"),
|
|
22
|
+
value: z.int(),
|
|
23
|
+
}),
|
|
24
|
+
])
|
|
25
|
+
.optional(),
|
|
26
|
+
});
|
|
27
|
+
export type NamespaceMetadataEditorEntry = z.infer<
|
|
28
|
+
typeof namespaceMetadataEditorEntrySchema
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
export const namespaceMetadataSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
owner: z.object({
|
|
34
|
+
username: z.string(),
|
|
35
|
+
}),
|
|
36
|
+
editors: namespaceMetadataEditorEntrySchema.array().min(1).max(5),
|
|
37
|
+
})
|
|
38
|
+
.refine(
|
|
39
|
+
(data) => data.editors.some((e) => e.username === data.owner.username),
|
|
40
|
+
{ message: "editors must include the owner", path: ["editors"] },
|
|
41
|
+
)
|
|
42
|
+
.openapi("NamespaceMetadata");
|
|
43
|
+
export type NamespaceMetadata = z.infer<typeof namespaceMetadataSchema>;
|
|
44
|
+
|
|
45
|
+
export const namespaceVerificationsSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
namespace: z.string(),
|
|
48
|
+
verification: z.enum(["figulus-official", "software-official"]),
|
|
49
|
+
})
|
|
50
|
+
.array().openapi("NamespaceVerifications");
|
|
51
|
+
export type NamespaceVerifications = z.infer<
|
|
52
|
+
typeof namespaceVerificationsSchema
|
|
53
|
+
>;
|
|
54
|
+
|
|
55
|
+
// If not included in this list, namespace is limited to default push limit from settings
|
|
56
|
+
// Automated systems shouldn't modify this file -- it must be manually edited by repo owner under special circumstances
|
|
57
|
+
export const pushLimitOverridesSchema = z
|
|
58
|
+
.object({
|
|
59
|
+
namespace: z.string(),
|
|
60
|
+
// Allows for soft-banning/suspension/archival, or increased limits for special accounts
|
|
61
|
+
pushLimit: z.discriminatedUnion("unit", [
|
|
62
|
+
z.object({
|
|
63
|
+
unit: z.literal("daily"),
|
|
64
|
+
value: z.int(),
|
|
65
|
+
}),
|
|
66
|
+
z.object({
|
|
67
|
+
unit: z.literal("weekly"),
|
|
68
|
+
value: z.int(),
|
|
69
|
+
}),
|
|
70
|
+
]),
|
|
71
|
+
})
|
|
72
|
+
.array().openapi("PushLimitOverrides");
|
|
73
|
+
export type PushLimitOverrides = z.infer<typeof pushLimitOverridesSchema>;
|
|
74
|
+
|
|
75
|
+
export const figEntityMetadataBaseSchema = z.object({
|
|
76
|
+
title: z.string(),
|
|
77
|
+
description: z.string(),
|
|
78
|
+
icon: z
|
|
79
|
+
.object({
|
|
80
|
+
svg: urlLike,
|
|
81
|
+
emojiFallback: z.emoji().optional(),
|
|
82
|
+
aspectRatio: z
|
|
83
|
+
.object({
|
|
84
|
+
w: z.number(),
|
|
85
|
+
h: z.number(),
|
|
86
|
+
})
|
|
87
|
+
.optional(),
|
|
88
|
+
})
|
|
89
|
+
.optional(),
|
|
90
|
+
tags: z.array(z.string()).optional(),
|
|
91
|
+
author: z.union([
|
|
92
|
+
z.string(),
|
|
93
|
+
z.string().array(),
|
|
94
|
+
z
|
|
95
|
+
.object({
|
|
96
|
+
type: z.enum([
|
|
97
|
+
"software-author",
|
|
98
|
+
"software-maintainer",
|
|
99
|
+
"fig-author",
|
|
100
|
+
"fig-maintainer",
|
|
101
|
+
]),
|
|
102
|
+
name: z.string(),
|
|
103
|
+
url: z.url().optional(),
|
|
104
|
+
})
|
|
105
|
+
.array(),
|
|
106
|
+
]),
|
|
107
|
+
license: z.union([
|
|
108
|
+
z.string().transform((s, ctx) => {
|
|
109
|
+
const result = parseLicenseId(s, { caseSensitive: false });
|
|
110
|
+
if (!result.success) {
|
|
111
|
+
ctx.addIssue({
|
|
112
|
+
code: "custom",
|
|
113
|
+
message: `Invalid SPDX license ID: ${s}`,
|
|
114
|
+
});
|
|
115
|
+
return z.NEVER;
|
|
116
|
+
}
|
|
117
|
+
return result.data;
|
|
118
|
+
}),
|
|
119
|
+
z.object({
|
|
120
|
+
name: z.string(),
|
|
121
|
+
url: z.url().optional(),
|
|
122
|
+
}),
|
|
123
|
+
]),
|
|
124
|
+
softwareSource: z
|
|
125
|
+
.union([z.url(), z.url().array()])
|
|
126
|
+
.optional(),
|
|
127
|
+
}).openapi("FigEntityMetadataBase");
|
|
128
|
+
|
|
129
|
+
const hexSchema = z.string().regex(/[0-9A-Fa-f]+/);
|
|
130
|
+
|
|
131
|
+
export const blobSchema = z.object({
|
|
132
|
+
contentHash: hexSchema,
|
|
133
|
+
ipfsCid: z.string().optional(),
|
|
134
|
+
}).openapi("Blob");
|
|
135
|
+
|
|
136
|
+
export const variantSchema = z.object({
|
|
137
|
+
blob: blobSchema,
|
|
138
|
+
tag: z.string().optional(),
|
|
139
|
+
createdAt: z.iso.datetime().default(new Date().toISOString()),
|
|
140
|
+
updatedAt: z.iso.datetime().default(new Date().toISOString()),
|
|
141
|
+
}).openapi("Variant");
|
|
142
|
+
|
|
143
|
+
export const parserVariantSchema = variantSchema.extend({
|
|
144
|
+
// Represents the parsed JSON schema — allows any object structure since JsonSchemaSchema is
|
|
145
|
+
// recursively self-referential and cannot be fully represented in OpenAPI
|
|
146
|
+
parsedShape: z.union([z.record(z.string(), z.any()), z.boolean()]).optional(),
|
|
147
|
+
}).openapi("ParserVariant");
|
|
148
|
+
|
|
149
|
+
// Ensure all tags are unique
|
|
150
|
+
function uniqueArray<T extends ZodObject<ZodRawShape>>(schema: T) {
|
|
151
|
+
return schema.array().refine((items) => {
|
|
152
|
+
const tags = items
|
|
153
|
+
.map((item) => (item as { tag?: string }).tag)
|
|
154
|
+
.filter((item) => item !== undefined);
|
|
155
|
+
return new Set(tags).size === tags.length;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const figParserMetadataSchema = figEntityMetadataBaseSchema.extend({
|
|
160
|
+
variants: uniqueArray(parserVariantSchema),
|
|
161
|
+
}).openapi("FigParserMetadata");
|
|
162
|
+
export type FigParserMetadata = z.infer<typeof figParserMetadataSchema>;
|
|
163
|
+
|
|
164
|
+
export const figSpecMetadataSchema = figEntityMetadataBaseSchema.extend({
|
|
165
|
+
variants: uniqueArray(variantSchema),
|
|
166
|
+
}).openapi("FigSpecMetadata");
|
|
167
|
+
export type FigSpecMetadata = z.infer<typeof figSpecMetadataSchema>;
|
|
168
|
+
|
|
169
|
+
export const figStackMetadataSchema = figEntityMetadataBaseSchema.extend({
|
|
170
|
+
variants: uniqueArray(variantSchema),
|
|
171
|
+
}).openapi("FigStackMetadata");
|
|
172
|
+
export type FigStackMetadata = z.infer<typeof figStackMetadataSchema>;
|
|
173
|
+
|
|
174
|
+
export type EntityType = "spec" | "stack" | "parser";
|
|
175
|
+
export type FigEntityMetadata<Type extends EntityType> = Type extends "spec"
|
|
176
|
+
? FigSpecMetadata
|
|
177
|
+
: Type extends "stack"
|
|
178
|
+
? FigStackMetadata
|
|
179
|
+
: Type extends "parser"
|
|
180
|
+
? FigParserMetadata
|
|
181
|
+
: null;
|
package/tests/figspec.test.ts
CHANGED
package/tests/schemas.test.ts
CHANGED
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
|
|
9
9
|
import { describe, it, expect } from 'vitest';
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
runRequestSchema,
|
|
12
|
+
jobStatusSchema,
|
|
13
|
+
createSessionRequestSchema,
|
|
14
|
+
syncFileRequestSchema,
|
|
15
15
|
} from '../src/index.js';
|
|
16
16
|
|
|
17
17
|
describe('Zod Schema Validation', () => {
|
|
18
18
|
describe('RunRequest Schema', () => {
|
|
19
19
|
it('should validate a minimal valid request', () => {
|
|
20
20
|
const valid = { job_id: 'job-001', image: 'node:20-alpine' };
|
|
21
|
-
expect(() =>
|
|
21
|
+
expect(() => runRequestSchema.parse(valid)).not.toThrow();
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
it('should validate a fully populated request', () => {
|
|
@@ -35,37 +35,37 @@ describe('Zod Schema Validation', () => {
|
|
|
35
35
|
network_mode: 'bridge',
|
|
36
36
|
ports: [{ container: 3000, host: 8080 }],
|
|
37
37
|
};
|
|
38
|
-
expect(() =>
|
|
38
|
+
expect(() => runRequestSchema.parse(valid)).not.toThrow();
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
it('should reject missing job_id', () => {
|
|
42
42
|
const invalid = { image: 'node:20-alpine' };
|
|
43
|
-
expect(() =>
|
|
43
|
+
expect(() => runRequestSchema.parse(invalid)).toThrow();
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
it('should reject missing image', () => {
|
|
47
47
|
const invalid = { job_id: 'job-001' };
|
|
48
|
-
expect(() =>
|
|
48
|
+
expect(() => runRequestSchema.parse(invalid)).toThrow();
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
it('should reject empty job_id', () => {
|
|
52
52
|
const invalid = { job_id: '', image: 'node:20-alpine' };
|
|
53
|
-
expect(() =>
|
|
53
|
+
expect(() => runRequestSchema.parse(invalid)).toThrow();
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
it('should reject negative timeout', () => {
|
|
57
57
|
const invalid = { job_id: 'job-001', image: 'node:20', timeout: -1 };
|
|
58
|
-
expect(() =>
|
|
58
|
+
expect(() => runRequestSchema.parse(invalid)).toThrow();
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it('should reject timeout exceeding max', () => {
|
|
62
62
|
const invalid = { job_id: 'job-001', image: 'node:20', timeout: 99999 };
|
|
63
|
-
expect(() =>
|
|
63
|
+
expect(() => runRequestSchema.parse(invalid)).toThrow();
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
it('should reject non-integer timeout', () => {
|
|
67
67
|
const invalid = { job_id: 'job-001', image: 'node:20', timeout: 30.5 };
|
|
68
|
-
expect(() =>
|
|
68
|
+
expect(() => runRequestSchema.parse(invalid)).toThrow();
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
it('should reject invalid port number', () => {
|
|
@@ -74,7 +74,7 @@ describe('Zod Schema Validation', () => {
|
|
|
74
74
|
image: 'node:20',
|
|
75
75
|
ports: [{ container: 99999 }],
|
|
76
76
|
};
|
|
77
|
-
expect(() =>
|
|
77
|
+
expect(() => runRequestSchema.parse(invalid)).toThrow();
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
|
|
@@ -82,21 +82,21 @@ describe('Zod Schema Validation', () => {
|
|
|
82
82
|
it('should accept all valid status values', () => {
|
|
83
83
|
const validValues = ['pending', 'running', 'completed', 'failed', 'timeout', 'awaiting_cleanup'];
|
|
84
84
|
for (const val of validValues) {
|
|
85
|
-
expect(() =>
|
|
85
|
+
expect(() => jobStatusSchema.parse(val)).not.toThrow();
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
it('should reject invalid status values', () => {
|
|
90
|
-
expect(() =>
|
|
91
|
-
expect(() =>
|
|
92
|
-
expect(() =>
|
|
90
|
+
expect(() => jobStatusSchema.parse('cancelled')).toThrow();
|
|
91
|
+
expect(() => jobStatusSchema.parse('done')).toThrow();
|
|
92
|
+
expect(() => jobStatusSchema.parse('')).toThrow();
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
describe('CreateSessionRequest Schema', () => {
|
|
97
97
|
it('should validate a minimal valid request', () => {
|
|
98
98
|
const valid = { image_tag: 'localhost:5000/figulus:sha256-abc123' };
|
|
99
|
-
expect(() =>
|
|
99
|
+
expect(() => createSessionRequestSchema.parse(valid)).not.toThrow();
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
it('should validate a request with config', () => {
|
|
@@ -110,27 +110,27 @@ describe('Zod Schema Validation', () => {
|
|
|
110
110
|
ports: [{ container: 3000 }],
|
|
111
111
|
},
|
|
112
112
|
};
|
|
113
|
-
expect(() =>
|
|
113
|
+
expect(() => createSessionRequestSchema.parse(valid)).not.toThrow();
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
it('should reject missing image_tag', () => {
|
|
117
117
|
const invalid = { ttl: 600 };
|
|
118
|
-
expect(() =>
|
|
118
|
+
expect(() => createSessionRequestSchema.parse(invalid)).toThrow();
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
it('should reject empty image_tag', () => {
|
|
122
122
|
const invalid = { image_tag: '' };
|
|
123
|
-
expect(() =>
|
|
123
|
+
expect(() => createSessionRequestSchema.parse(invalid)).toThrow();
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
it('should reject negative ttl', () => {
|
|
127
127
|
const invalid = { image_tag: 'some-image:latest', ttl: -1 };
|
|
128
|
-
expect(() =>
|
|
128
|
+
expect(() => createSessionRequestSchema.parse(invalid)).toThrow();
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
it('should reject non-integer ttl', () => {
|
|
132
132
|
const invalid = { image_tag: 'some-image:latest', ttl: 60.5 };
|
|
133
|
-
expect(() =>
|
|
133
|
+
expect(() => createSessionRequestSchema.parse(invalid)).toThrow();
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
|
|
@@ -141,7 +141,7 @@ describe('Zod Schema Validation', () => {
|
|
|
141
141
|
content: 'Y29uc29sZS5sb2coImhlbGxvIik=',
|
|
142
142
|
encoding: 'base64',
|
|
143
143
|
};
|
|
144
|
-
expect(() =>
|
|
144
|
+
expect(() => syncFileRequestSchema.parse(valid)).not.toThrow();
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
it('should validate a valid utf8 request', () => {
|
|
@@ -150,38 +150,38 @@ describe('Zod Schema Validation', () => {
|
|
|
150
150
|
content: 'console.log("hello")',
|
|
151
151
|
encoding: 'utf8',
|
|
152
152
|
};
|
|
153
|
-
expect(() =>
|
|
153
|
+
expect(() => syncFileRequestSchema.parse(valid)).not.toThrow();
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
it('should default encoding to base64 when omitted', () => {
|
|
157
157
|
const input = { targetPath: '/app/src/index.ts', content: 'abc' };
|
|
158
|
-
const result =
|
|
158
|
+
const result = syncFileRequestSchema.parse(input);
|
|
159
159
|
expect(result.encoding).toBe('base64');
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
it('should reject missing targetPath', () => {
|
|
163
163
|
const invalid = { content: 'abc', encoding: 'base64' };
|
|
164
|
-
expect(() =>
|
|
164
|
+
expect(() => syncFileRequestSchema.parse(invalid)).toThrow();
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
it('should reject empty targetPath', () => {
|
|
168
168
|
const invalid = { targetPath: '', content: 'abc', encoding: 'base64' };
|
|
169
|
-
expect(() =>
|
|
169
|
+
expect(() => syncFileRequestSchema.parse(invalid)).toThrow();
|
|
170
170
|
});
|
|
171
171
|
|
|
172
172
|
it('should reject missing content', () => {
|
|
173
173
|
const invalid = { targetPath: '/app/file.ts', encoding: 'base64' };
|
|
174
|
-
expect(() =>
|
|
174
|
+
expect(() => syncFileRequestSchema.parse(invalid)).toThrow();
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
it('should reject empty content', () => {
|
|
178
178
|
const invalid = { targetPath: '/app/file.ts', content: '', encoding: 'base64' };
|
|
179
|
-
expect(() =>
|
|
179
|
+
expect(() => syncFileRequestSchema.parse(invalid)).toThrow();
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
it('should reject invalid encoding value', () => {
|
|
183
183
|
const invalid = { targetPath: '/app/file.ts', content: 'abc', encoding: 'hex' };
|
|
184
|
-
expect(() =>
|
|
184
|
+
expect(() => syncFileRequestSchema.parse(invalid)).toThrow();
|
|
185
185
|
});
|
|
186
186
|
});
|
|
187
187
|
});
|