@zuplo/cli 6.65.8 → 6.66.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/dist/__tests__/import-openapi.test.js +90 -1
- package/dist/__tests__/import-openapi.test.js.map +1 -1
- package/dist/open-api/convert/handler.js +2 -2
- package/dist/open-api/convert/handler.js.map +1 -1
- package/dist/open-api/merge/handler.d.ts +1 -1
- package/dist/open-api/merge/handler.d.ts.map +1 -1
- package/dist/open-api/merge/handler.js +4 -5
- package/dist/open-api/merge/handler.js.map +1 -1
- package/dist/open-api/overlay/handler.js +1 -2
- package/dist/open-api/overlay/handler.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/__tests__/import-openapi-utils.test.d.ts +0 -2
- package/dist/__tests__/import-openapi-utils.test.d.ts.map +0 -1
- package/dist/__tests__/import-openapi-utils.test.js +0 -125
- package/dist/__tests__/import-openapi-utils.test.js.map +0 -1
- package/dist/__tests__/oas-test-data.d.ts +0 -98
- package/dist/__tests__/oas-test-data.d.ts.map +0 -1
- package/dist/__tests__/oas-test-data.js +0 -114
- package/dist/__tests__/oas-test-data.js.map +0 -1
- package/dist/common/file-format.d.ts +0 -25
- package/dist/common/file-format.d.ts.map +0 -1
- package/dist/common/file-format.js +0 -72
- package/dist/common/file-format.js.map +0 -1
- package/dist/common/open-api/constants.d.ts +0 -13
- package/dist/common/open-api/constants.d.ts.map +0 -1
- package/dist/common/open-api/constants.js +0 -16
- package/dist/common/open-api/constants.js.map +0 -1
- package/dist/common/open-api/index.d.ts +0 -3
- package/dist/common/open-api/index.d.ts.map +0 -1
- package/dist/common/open-api/index.js +0 -3
- package/dist/common/open-api/index.js.map +0 -1
- package/dist/common/open-api/validation.d.ts +0 -297
- package/dist/common/open-api/validation.d.ts.map +0 -1
- package/dist/common/open-api/validation.js +0 -88
- package/dist/common/open-api/validation.js.map +0 -1
- package/dist/open-api/convert/convert-engine.d.ts +0 -26
- package/dist/open-api/convert/convert-engine.d.ts.map +0 -1
- package/dist/open-api/convert/convert-engine.js +0 -20
- package/dist/open-api/convert/convert-engine.js.map +0 -1
- package/dist/open-api/convert/convert-engine.spec.d.ts +0 -2
- package/dist/open-api/convert/convert-engine.spec.d.ts.map +0 -1
- package/dist/open-api/convert/convert-engine.spec.js +0 -268
- package/dist/open-api/convert/convert-engine.spec.js.map +0 -1
- package/dist/open-api/merge/ajv.d.ts +0 -34
- package/dist/open-api/merge/ajv.d.ts.map +0 -1
- package/dist/open-api/merge/ajv.js +0 -2
- package/dist/open-api/merge/ajv.js.map +0 -1
- package/dist/open-api/merge/interfaces.d.ts +0 -72
- package/dist/open-api/merge/interfaces.d.ts.map +0 -1
- package/dist/open-api/merge/interfaces.js +0 -5
- package/dist/open-api/merge/interfaces.js.map +0 -1
- package/dist/open-api/merge/merge-engine.d.ts +0 -20
- package/dist/open-api/merge/merge-engine.d.ts.map +0 -1
- package/dist/open-api/merge/merge-engine.js +0 -34
- package/dist/open-api/merge/merge-engine.js.map +0 -1
- package/dist/open-api/merge/merge-engine.spec.d.ts +0 -2
- package/dist/open-api/merge/merge-engine.spec.d.ts.map +0 -1
- package/dist/open-api/merge/merge-engine.spec.js +0 -117
- package/dist/open-api/merge/merge-engine.spec.js.map +0 -1
- package/dist/open-api/merge/utils.d.ts +0 -11
- package/dist/open-api/merge/utils.d.ts.map +0 -1
- package/dist/open-api/merge/utils.js +0 -33
- package/dist/open-api/merge/utils.js.map +0 -1
- package/dist/open-api/overlay/overlay-engine.d.ts +0 -45
- package/dist/open-api/overlay/overlay-engine.d.ts.map +0 -1
- package/dist/open-api/overlay/overlay-engine.js +0 -309
- package/dist/open-api/overlay/overlay-engine.js.map +0 -1
- package/dist/open-api/overlay/overlay-engine.spec.d.ts +0 -2
- package/dist/open-api/overlay/overlay-engine.spec.d.ts.map +0 -1
- package/dist/open-api/overlay/overlay-engine.spec.js +0 -687
- package/dist/open-api/overlay/overlay-engine.spec.js.map +0 -1
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
declare const RemoveConditionSchema: z.ZodEffects<
|
|
3
|
-
z.ZodObject<
|
|
4
|
-
{
|
|
5
|
-
empty: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
-
missing: z.ZodOptional<z.ZodString>;
|
|
7
|
-
},
|
|
8
|
-
"strict",
|
|
9
|
-
z.ZodTypeAny,
|
|
10
|
-
{
|
|
11
|
-
empty?: boolean | undefined;
|
|
12
|
-
missing?: string | undefined;
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
empty?: boolean | undefined;
|
|
16
|
-
missing?: string | undefined;
|
|
17
|
-
}
|
|
18
|
-
>,
|
|
19
|
-
{
|
|
20
|
-
empty?: boolean | undefined;
|
|
21
|
-
missing?: string | undefined;
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
empty?: boolean | undefined;
|
|
25
|
-
missing?: string | undefined;
|
|
26
|
-
}
|
|
27
|
-
>;
|
|
28
|
-
declare const OverlayActionSchema: z.ZodEffects<
|
|
29
|
-
z.ZodObject<
|
|
30
|
-
{
|
|
31
|
-
target: z.ZodString;
|
|
32
|
-
description: z.ZodOptional<z.ZodString>;
|
|
33
|
-
update: z.ZodOptional<z.ZodUnknown>;
|
|
34
|
-
remove: z.ZodOptional<
|
|
35
|
-
z.ZodUnion<
|
|
36
|
-
[
|
|
37
|
-
z.ZodBoolean,
|
|
38
|
-
z.ZodEffects<
|
|
39
|
-
z.ZodObject<
|
|
40
|
-
{
|
|
41
|
-
empty: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
-
missing: z.ZodOptional<z.ZodString>;
|
|
43
|
-
},
|
|
44
|
-
"strict",
|
|
45
|
-
z.ZodTypeAny,
|
|
46
|
-
{
|
|
47
|
-
empty?: boolean | undefined;
|
|
48
|
-
missing?: string | undefined;
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
empty?: boolean | undefined;
|
|
52
|
-
missing?: string | undefined;
|
|
53
|
-
}
|
|
54
|
-
>,
|
|
55
|
-
{
|
|
56
|
-
empty?: boolean | undefined;
|
|
57
|
-
missing?: string | undefined;
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
empty?: boolean | undefined;
|
|
61
|
-
missing?: string | undefined;
|
|
62
|
-
}
|
|
63
|
-
>,
|
|
64
|
-
]
|
|
65
|
-
>
|
|
66
|
-
>;
|
|
67
|
-
},
|
|
68
|
-
"strict",
|
|
69
|
-
z.ZodTypeAny,
|
|
70
|
-
{
|
|
71
|
-
target: string;
|
|
72
|
-
description?: string | undefined;
|
|
73
|
-
update?: unknown;
|
|
74
|
-
remove?:
|
|
75
|
-
| boolean
|
|
76
|
-
| {
|
|
77
|
-
empty?: boolean | undefined;
|
|
78
|
-
missing?: string | undefined;
|
|
79
|
-
}
|
|
80
|
-
| undefined;
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
target: string;
|
|
84
|
-
description?: string | undefined;
|
|
85
|
-
update?: unknown;
|
|
86
|
-
remove?:
|
|
87
|
-
| boolean
|
|
88
|
-
| {
|
|
89
|
-
empty?: boolean | undefined;
|
|
90
|
-
missing?: string | undefined;
|
|
91
|
-
}
|
|
92
|
-
| undefined;
|
|
93
|
-
}
|
|
94
|
-
>,
|
|
95
|
-
{
|
|
96
|
-
target: string;
|
|
97
|
-
description?: string | undefined;
|
|
98
|
-
update?: unknown;
|
|
99
|
-
remove?:
|
|
100
|
-
| boolean
|
|
101
|
-
| {
|
|
102
|
-
empty?: boolean | undefined;
|
|
103
|
-
missing?: string | undefined;
|
|
104
|
-
}
|
|
105
|
-
| undefined;
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
target: string;
|
|
109
|
-
description?: string | undefined;
|
|
110
|
-
update?: unknown;
|
|
111
|
-
remove?:
|
|
112
|
-
| boolean
|
|
113
|
-
| {
|
|
114
|
-
empty?: boolean | undefined;
|
|
115
|
-
missing?: string | undefined;
|
|
116
|
-
}
|
|
117
|
-
| undefined;
|
|
118
|
-
}
|
|
119
|
-
>;
|
|
120
|
-
export declare const OverlayDocumentSchema: z.ZodObject<
|
|
121
|
-
{
|
|
122
|
-
overlay: z.ZodEffects<z.ZodString, string, string>;
|
|
123
|
-
info: z.ZodObject<
|
|
124
|
-
{
|
|
125
|
-
title: z.ZodString;
|
|
126
|
-
version: z.ZodString;
|
|
127
|
-
},
|
|
128
|
-
"strict",
|
|
129
|
-
z.ZodTypeAny,
|
|
130
|
-
{
|
|
131
|
-
version: string;
|
|
132
|
-
title: string;
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
version: string;
|
|
136
|
-
title: string;
|
|
137
|
-
}
|
|
138
|
-
>;
|
|
139
|
-
actions: z.ZodArray<
|
|
140
|
-
z.ZodEffects<
|
|
141
|
-
z.ZodObject<
|
|
142
|
-
{
|
|
143
|
-
target: z.ZodString;
|
|
144
|
-
description: z.ZodOptional<z.ZodString>;
|
|
145
|
-
update: z.ZodOptional<z.ZodUnknown>;
|
|
146
|
-
remove: z.ZodOptional<
|
|
147
|
-
z.ZodUnion<
|
|
148
|
-
[
|
|
149
|
-
z.ZodBoolean,
|
|
150
|
-
z.ZodEffects<
|
|
151
|
-
z.ZodObject<
|
|
152
|
-
{
|
|
153
|
-
empty: z.ZodOptional<z.ZodBoolean>;
|
|
154
|
-
missing: z.ZodOptional<z.ZodString>;
|
|
155
|
-
},
|
|
156
|
-
"strict",
|
|
157
|
-
z.ZodTypeAny,
|
|
158
|
-
{
|
|
159
|
-
empty?: boolean | undefined;
|
|
160
|
-
missing?: string | undefined;
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
empty?: boolean | undefined;
|
|
164
|
-
missing?: string | undefined;
|
|
165
|
-
}
|
|
166
|
-
>,
|
|
167
|
-
{
|
|
168
|
-
empty?: boolean | undefined;
|
|
169
|
-
missing?: string | undefined;
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
empty?: boolean | undefined;
|
|
173
|
-
missing?: string | undefined;
|
|
174
|
-
}
|
|
175
|
-
>,
|
|
176
|
-
]
|
|
177
|
-
>
|
|
178
|
-
>;
|
|
179
|
-
},
|
|
180
|
-
"strict",
|
|
181
|
-
z.ZodTypeAny,
|
|
182
|
-
{
|
|
183
|
-
target: string;
|
|
184
|
-
description?: string | undefined;
|
|
185
|
-
update?: unknown;
|
|
186
|
-
remove?:
|
|
187
|
-
| boolean
|
|
188
|
-
| {
|
|
189
|
-
empty?: boolean | undefined;
|
|
190
|
-
missing?: string | undefined;
|
|
191
|
-
}
|
|
192
|
-
| undefined;
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
target: string;
|
|
196
|
-
description?: string | undefined;
|
|
197
|
-
update?: unknown;
|
|
198
|
-
remove?:
|
|
199
|
-
| boolean
|
|
200
|
-
| {
|
|
201
|
-
empty?: boolean | undefined;
|
|
202
|
-
missing?: string | undefined;
|
|
203
|
-
}
|
|
204
|
-
| undefined;
|
|
205
|
-
}
|
|
206
|
-
>,
|
|
207
|
-
{
|
|
208
|
-
target: string;
|
|
209
|
-
description?: string | undefined;
|
|
210
|
-
update?: unknown;
|
|
211
|
-
remove?:
|
|
212
|
-
| boolean
|
|
213
|
-
| {
|
|
214
|
-
empty?: boolean | undefined;
|
|
215
|
-
missing?: string | undefined;
|
|
216
|
-
}
|
|
217
|
-
| undefined;
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
target: string;
|
|
221
|
-
description?: string | undefined;
|
|
222
|
-
update?: unknown;
|
|
223
|
-
remove?:
|
|
224
|
-
| boolean
|
|
225
|
-
| {
|
|
226
|
-
empty?: boolean | undefined;
|
|
227
|
-
missing?: string | undefined;
|
|
228
|
-
}
|
|
229
|
-
| undefined;
|
|
230
|
-
}
|
|
231
|
-
>,
|
|
232
|
-
"many"
|
|
233
|
-
>;
|
|
234
|
-
extends: z.ZodOptional<z.ZodString>;
|
|
235
|
-
},
|
|
236
|
-
"strict",
|
|
237
|
-
z.ZodTypeAny,
|
|
238
|
-
{
|
|
239
|
-
info: {
|
|
240
|
-
version: string;
|
|
241
|
-
title: string;
|
|
242
|
-
};
|
|
243
|
-
overlay: string;
|
|
244
|
-
actions: {
|
|
245
|
-
target: string;
|
|
246
|
-
description?: string | undefined;
|
|
247
|
-
update?: unknown;
|
|
248
|
-
remove?:
|
|
249
|
-
| boolean
|
|
250
|
-
| {
|
|
251
|
-
empty?: boolean | undefined;
|
|
252
|
-
missing?: string | undefined;
|
|
253
|
-
}
|
|
254
|
-
| undefined;
|
|
255
|
-
}[];
|
|
256
|
-
extends?: string | undefined;
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
info: {
|
|
260
|
-
version: string;
|
|
261
|
-
title: string;
|
|
262
|
-
};
|
|
263
|
-
overlay: string;
|
|
264
|
-
actions: {
|
|
265
|
-
target: string;
|
|
266
|
-
description?: string | undefined;
|
|
267
|
-
update?: unknown;
|
|
268
|
-
remove?:
|
|
269
|
-
| boolean
|
|
270
|
-
| {
|
|
271
|
-
empty?: boolean | undefined;
|
|
272
|
-
missing?: string | undefined;
|
|
273
|
-
}
|
|
274
|
-
| undefined;
|
|
275
|
-
}[];
|
|
276
|
-
extends?: string | undefined;
|
|
277
|
-
}
|
|
278
|
-
>;
|
|
279
|
-
export declare const OpenApiDocumentSchema: z.ZodObject<
|
|
280
|
-
{},
|
|
281
|
-
"passthrough",
|
|
282
|
-
z.ZodTypeAny,
|
|
283
|
-
z.objectOutputType<{}, z.ZodTypeAny, "passthrough">,
|
|
284
|
-
z.objectInputType<{}, z.ZodTypeAny, "passthrough">
|
|
285
|
-
>;
|
|
286
|
-
export type OverlayDocument = z.infer<typeof OverlayDocumentSchema>;
|
|
287
|
-
export type OverlayAction = z.infer<typeof OverlayActionSchema>;
|
|
288
|
-
export type RemoveCondition = z.infer<typeof RemoveConditionSchema>;
|
|
289
|
-
export type OpenApiDocument = z.infer<typeof OpenApiDocumentSchema>;
|
|
290
|
-
export declare function validateOverlayDocument(
|
|
291
|
-
value: unknown
|
|
292
|
-
): OverlayDocument;
|
|
293
|
-
export declare function validateOpenApiDocument(
|
|
294
|
-
value: unknown
|
|
295
|
-
): OpenApiDocument;
|
|
296
|
-
export {};
|
|
297
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/common/open-api/validation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;EAYvB,CAAC;AAKL,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCtB,CAAC;AAMJ,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBvB,CAAC;AAOZ,eAAO,MAAM,qBAAqB,uJAKkB,CAAC;AAKrD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAMpE,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAcvE;AAQD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CASvE"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import semver from "semver";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
const RemoveConditionSchema = z
|
|
4
|
-
.object({
|
|
5
|
-
empty: z.boolean().optional().describe("Remove if object/array is empty"),
|
|
6
|
-
missing: z
|
|
7
|
-
.string()
|
|
8
|
-
.optional()
|
|
9
|
-
.describe("Remove if specified property path is missing"),
|
|
10
|
-
})
|
|
11
|
-
.strict()
|
|
12
|
-
.refine((data) => data.empty !== undefined || data.missing !== undefined, {
|
|
13
|
-
message: "Remove condition must specify either 'empty' or 'missing' property",
|
|
14
|
-
});
|
|
15
|
-
const OverlayActionSchema = z
|
|
16
|
-
.object({
|
|
17
|
-
target: z
|
|
18
|
-
.string()
|
|
19
|
-
.min(1, "Action target cannot be empty")
|
|
20
|
-
.startsWith("$", "Action target must be a valid JSONPath starting with '$'")
|
|
21
|
-
.describe("JSONPath expression pointing to the target element(s) in the OpenAPI document"),
|
|
22
|
-
description: z
|
|
23
|
-
.string()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe("Human-readable description of what this action does"),
|
|
26
|
-
update: z
|
|
27
|
-
.unknown()
|
|
28
|
-
.optional()
|
|
29
|
-
.describe("Value to merge/add at the target location"),
|
|
30
|
-
remove: z
|
|
31
|
-
.union([z.boolean(), RemoveConditionSchema])
|
|
32
|
-
.optional()
|
|
33
|
-
.describe("If true or condition met, remove the target element(s)"),
|
|
34
|
-
})
|
|
35
|
-
.strict()
|
|
36
|
-
.refine((data) => (data.update !== undefined) !== (data.remove !== undefined), {
|
|
37
|
-
message: "Action must specify exactly one of 'update' or 'remove' (not both, not neither)",
|
|
38
|
-
path: ["update", "remove"],
|
|
39
|
-
});
|
|
40
|
-
export const OverlayDocumentSchema = z
|
|
41
|
-
.object({
|
|
42
|
-
overlay: z
|
|
43
|
-
.string()
|
|
44
|
-
.refine((value) => semver.valid(value) !== null, "Overlay version must be a valid semver version (e.g., '1.0.0', '1.0.0-alpha.1', '1.0.0+build.123')")
|
|
45
|
-
.describe("Version of the OpenAPI Overlay specification being used"),
|
|
46
|
-
info: z
|
|
47
|
-
.object({
|
|
48
|
-
title: z.string().min(1, "Overlay title cannot be empty"),
|
|
49
|
-
version: z.string().min(1, "Overlay version cannot be empty"),
|
|
50
|
-
})
|
|
51
|
-
.strict()
|
|
52
|
-
.describe("Metadata about this overlay"),
|
|
53
|
-
actions: z
|
|
54
|
-
.array(OverlayActionSchema)
|
|
55
|
-
.min(1, "Overlay must contain at least one action")
|
|
56
|
-
.describe("Array of modifications to apply to the OpenAPI document"),
|
|
57
|
-
extends: z
|
|
58
|
-
.string()
|
|
59
|
-
.optional()
|
|
60
|
-
.describe("URL or path to another overlay to extend"),
|
|
61
|
-
})
|
|
62
|
-
.strict();
|
|
63
|
-
export const OpenApiDocumentSchema = z
|
|
64
|
-
.object({})
|
|
65
|
-
.passthrough()
|
|
66
|
-
.describe("OpenAPI document (lenient validation)");
|
|
67
|
-
export function validateOverlayDocument(value) {
|
|
68
|
-
const result = OverlayDocumentSchema.safeParse(value);
|
|
69
|
-
if (!result.success) {
|
|
70
|
-
const errors = result.error.errors
|
|
71
|
-
.map((err) => {
|
|
72
|
-
const path = err.path.length > 0 ? ` at '${err.path.join(".")}'` : "";
|
|
73
|
-
return ` • ${err.message}${path}`;
|
|
74
|
-
})
|
|
75
|
-
.join("\n");
|
|
76
|
-
throw new Error(`Invalid OpenAPI Overlay document:\n${errors}\n\nThe overlay must conform to the OpenAPI Overlay Specification v1.0.0`);
|
|
77
|
-
}
|
|
78
|
-
return result.data;
|
|
79
|
-
}
|
|
80
|
-
export function validateOpenApiDocument(value) {
|
|
81
|
-
const result = OpenApiDocumentSchema.safeParse(value);
|
|
82
|
-
if (!result.success) {
|
|
83
|
-
throw new Error(`OpenAPI document must be a valid JSON or YAML object. ` +
|
|
84
|
-
`The file appears to be empty or contains invalid data.`);
|
|
85
|
-
}
|
|
86
|
-
return result.data;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/common/open-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,CAAC,MAAM;aAC/B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACtE,OAAO,OAAO,GAAG,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QACrC,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,KAAK,CACb,sCAAsC,MAAM,0EAA0E,CACvH,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAQD,MAAM,UAAU,uBAAuB,CAAC,KAAc;IACpD,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACtD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,wDAAwD;YACtD,wDAAwD,CAC3D,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Validation schemas for OpenAPI documents and overlays\n * Using Zod for runtime validation with actionable error messages\n */\n\nimport semver from \"semver\";\nimport { z } from \"zod\";\n\n/**\n * Schema for remove condition - used for conditional removal of elements\n */\nconst RemoveConditionSchema = z\n .object({\n empty: z.boolean().optional().describe(\"Remove if object/array is empty\"),\n missing: z\n .string()\n .optional()\n .describe(\"Remove if specified property path is missing\"),\n })\n .strict()\n .refine((data) => data.empty !== undefined || data.missing !== undefined, {\n message:\n \"Remove condition must specify either 'empty' or 'missing' property\",\n });\n\n/**\n * Schema for overlay action - defines a single modification to apply\n */\nconst OverlayActionSchema = z\n .object({\n target: z\n .string()\n .min(1, \"Action target cannot be empty\")\n .startsWith(\n \"$\",\n \"Action target must be a valid JSONPath starting with '$'\"\n )\n .describe(\n \"JSONPath expression pointing to the target element(s) in the OpenAPI document\"\n ),\n description: z\n .string()\n .optional()\n .describe(\"Human-readable description of what this action does\"),\n update: z\n .unknown()\n .optional()\n .describe(\"Value to merge/add at the target location\"),\n remove: z\n .union([z.boolean(), RemoveConditionSchema])\n .optional()\n .describe(\"If true or condition met, remove the target element(s)\"),\n })\n .strict()\n .refine(\n (data) => (data.update !== undefined) !== (data.remove !== undefined),\n {\n message:\n \"Action must specify exactly one of 'update' or 'remove' (not both, not neither)\",\n path: [\"update\", \"remove\"],\n }\n );\n\n/**\n * Schema for OpenAPI Overlay document\n * Based on: https://github.com/OAI/Overlay-Specification v1.0.0\n */\nexport const OverlayDocumentSchema = z\n .object({\n overlay: z\n .string()\n .refine(\n (value) => semver.valid(value) !== null,\n \"Overlay version must be a valid semver version (e.g., '1.0.0', '1.0.0-alpha.1', '1.0.0+build.123')\"\n )\n .describe(\"Version of the OpenAPI Overlay specification being used\"),\n info: z\n .object({\n title: z.string().min(1, \"Overlay title cannot be empty\"),\n version: z.string().min(1, \"Overlay version cannot be empty\"),\n })\n .strict()\n .describe(\"Metadata about this overlay\"),\n actions: z\n .array(OverlayActionSchema)\n .min(1, \"Overlay must contain at least one action\")\n .describe(\"Array of modifications to apply to the OpenAPI document\"),\n extends: z\n .string()\n .optional()\n .describe(\"URL or path to another overlay to extend\"),\n })\n .strict();\n\n/**\n * Schema for OpenAPI document structure\n * This is intentionally lenient to work with imperfect/incomplete OpenAPI files.\n * The overlay tool is often used to fix incomplete specs, so we shouldn't be too strict.\n */\nexport const OpenApiDocumentSchema = z\n .object({\n // Accept any object - we just need it to be valid JSON/YAML that we can manipulate\n })\n .passthrough()\n .describe(\"OpenAPI document (lenient validation)\");\n\n/**\n * Type exports matching Zod schemas\n */\nexport type OverlayDocument = z.infer<typeof OverlayDocumentSchema>;\nexport type OverlayAction = z.infer<typeof OverlayActionSchema>;\nexport type RemoveCondition = z.infer<typeof RemoveConditionSchema>;\nexport type OpenApiDocument = z.infer<typeof OpenApiDocumentSchema>;\n\n/**\n * Validate an OpenAPI Overlay document\n * @throws {Error} with actionable error message if validation fails\n */\nexport function validateOverlayDocument(value: unknown): OverlayDocument {\n const result = OverlayDocumentSchema.safeParse(value);\n if (!result.success) {\n const errors = result.error.errors\n .map((err) => {\n const path = err.path.length > 0 ? ` at '${err.path.join(\".\")}'` : \"\";\n return ` • ${err.message}${path}`;\n })\n .join(\"\\n\");\n throw new Error(\n `Invalid OpenAPI Overlay document:\\n${errors}\\n\\nThe overlay must conform to the OpenAPI Overlay Specification v1.0.0`\n );\n }\n return result.data;\n}\n\n/**\n * Validate an OpenAPI document\n * This validation is intentionally lenient - we only check that it's a valid object.\n * The overlay tool should work with imperfect OpenAPI files.\n * @throws {Error} if the document is not a valid object\n */\nexport function validateOpenApiDocument(value: unknown): OpenApiDocument {\n const result = OpenApiDocumentSchema.safeParse(value);\n if (!result.success) {\n throw new Error(\n `OpenAPI document must be a valid JSON or YAML object. ` +\n `The file appears to be empty or contains invalid data.`\n );\n }\n return result.data;\n}\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
detectFormatFromExtension,
|
|
3
|
-
type FileFormat,
|
|
4
|
-
parseContent,
|
|
5
|
-
serializeContent,
|
|
6
|
-
} from "../../common/file-format.js";
|
|
7
|
-
export type { FileFormat };
|
|
8
|
-
export {
|
|
9
|
-
detectFormatFromExtension as detectFormat,
|
|
10
|
-
parseContent,
|
|
11
|
-
serializeContent,
|
|
12
|
-
};
|
|
13
|
-
export interface ConversionResult {
|
|
14
|
-
content: string;
|
|
15
|
-
format: FileFormat;
|
|
16
|
-
}
|
|
17
|
-
export declare function convertDocument(
|
|
18
|
-
content: string,
|
|
19
|
-
inputFormat: FileFormat,
|
|
20
|
-
outputFormat: FileFormat
|
|
21
|
-
): ConversionResult;
|
|
22
|
-
export declare function generateOutputPath(
|
|
23
|
-
inputPath: string,
|
|
24
|
-
outputFormat: FileFormat
|
|
25
|
-
): string;
|
|
26
|
-
//# sourceMappingURL=convert-engine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-engine.d.ts","sourceRoot":"","sources":["../../../src/open-api/convert/convert-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,KAAK,UAAU,EACf,YAAY,EACZ,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAGrC,YAAY,EAAE,UAAU,EAAE,CAAC;AAC3B,OAAO,EACL,yBAAyB,IAAI,YAAY,EACzC,YAAY,EACZ,gBAAgB,GACjB,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;CACpB;AASD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,UAAU,EACvB,YAAY,EAAE,UAAU,GACvB,gBAAgB,CAWlB;AAKD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,UAAU,GACvB,MAAM,CAYR"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { detectFormatFromExtension, parseContent, serializeContent, } from "../../common/file-format.js";
|
|
2
|
-
export { detectFormatFromExtension as detectFormat, parseContent, serializeContent, };
|
|
3
|
-
export function convertDocument(content, inputFormat, outputFormat) {
|
|
4
|
-
const document = parseContent(content, inputFormat);
|
|
5
|
-
const outputContent = serializeContent(document, outputFormat);
|
|
6
|
-
return {
|
|
7
|
-
content: outputContent,
|
|
8
|
-
format: outputFormat,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function generateOutputPath(inputPath, outputFormat) {
|
|
12
|
-
const lastDotIndex = inputPath.lastIndexOf(".");
|
|
13
|
-
if (lastDotIndex === -1) {
|
|
14
|
-
return `${inputPath}.${outputFormat === "yaml" ? "yaml" : "json"}`;
|
|
15
|
-
}
|
|
16
|
-
const basePath = inputPath.substring(0, lastDotIndex);
|
|
17
|
-
const newExtension = outputFormat === "yaml" ? "yaml" : "json";
|
|
18
|
-
return `${basePath}.${newExtension}`;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=convert-engine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-engine.js","sourceRoot":"","sources":["../../../src/open-api/convert/convert-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAEzB,YAAY,EACZ,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,yBAAyB,IAAI,YAAY,EACzC,YAAY,EACZ,gBAAgB,GACjB,CAAC;AAcF,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,WAAuB,EACvB,YAAwB;IAGxB,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAGpD,MAAM,aAAa,GAAG,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAE/D,OAAO;QACL,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,YAAY;KACrB,CAAC;AACJ,CAAC;AAKD,MAAM,UAAU,kBAAkB,CAChC,SAAiB,EACjB,YAAwB;IAGxB,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAChD,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;QAExB,OAAO,GAAG,SAAS,IAAI,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACrE,CAAC;IAGD,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAC/D,OAAO,GAAG,QAAQ,IAAI,YAAY,EAAE,CAAC;AACvC,CAAC","sourcesContent":["import {\n detectFormatFromExtension,\n type FileFormat,\n parseContent,\n serializeContent,\n} from \"../../common/file-format.js\";\n\n// Re-export common types and functions\nexport type { FileFormat };\nexport {\n detectFormatFromExtension as detectFormat,\n parseContent,\n serializeContent,\n};\n\nexport interface ConversionResult {\n content: string;\n format: FileFormat;\n}\n\n/**\n * Convert document from one format to another\n * @param content The input content as a string\n * @param inputFormat The format of the input content\n * @param outputFormat The desired output format\n * @returns The converted content\n */\nexport function convertDocument(\n content: string,\n inputFormat: FileFormat,\n outputFormat: FileFormat\n): ConversionResult {\n // Parse the input\n const document = parseContent(content, inputFormat);\n\n // Serialize to output format\n const outputContent = serializeContent(document, outputFormat);\n\n return {\n content: outputContent,\n format: outputFormat,\n };\n}\n\n/**\n * Generate output file path by replacing the extension\n */\nexport function generateOutputPath(\n inputPath: string,\n outputFormat: FileFormat\n): string {\n // Find the last dot in the path\n const lastDotIndex = inputPath.lastIndexOf(\".\");\n if (lastDotIndex === -1) {\n // No extension, just append\n return `${inputPath}.${outputFormat === \"yaml\" ? \"yaml\" : \"json\"}`;\n }\n\n // Replace extension\n const basePath = inputPath.substring(0, lastDotIndex);\n const newExtension = outputFormat === \"yaml\" ? \"yaml\" : \"json\";\n return `${basePath}.${newExtension}`;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-engine.spec.d.ts","sourceRoot":"","sources":["../../../src/open-api/convert/convert-engine.spec.ts"],"names":[],"mappings":""}
|