@aigne/core 1.33.1 → 1.33.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/CHANGELOG.md +7 -0
- package/lib/cjs/loader/schema.js +27 -23
- package/lib/esm/loader/schema.js +27 -23
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* dependencies
|
|
13
13
|
* @aigne/observability bumped to 0.1.0
|
|
14
14
|
|
|
15
|
+
## [1.33.2](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.33.1...core-v1.33.2) (2025-07-14)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **core:** fix error of external schema with array type ([#251](https://github.com/AIGNE-io/aigne-framework/issues/251)) ([bd80921](https://github.com/AIGNE-io/aigne-framework/commit/bd80921bbbe8385645eb7c52fd719ce48d672da9))
|
|
21
|
+
|
|
15
22
|
## [1.33.1](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.33.0...core-v1.33.1) (2025-07-14)
|
|
16
23
|
|
|
17
24
|
|
package/lib/cjs/loader/schema.js
CHANGED
|
@@ -6,6 +6,32 @@ const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
|
|
|
6
6
|
const yaml_1 = require("yaml");
|
|
7
7
|
const zod_1 = require("zod");
|
|
8
8
|
const inputOutputSchema = ({ path }) => {
|
|
9
|
+
const includeExternalSchema = async (schema) => {
|
|
10
|
+
if (schema?.type === "object" && schema.properties) {
|
|
11
|
+
return {
|
|
12
|
+
...schema,
|
|
13
|
+
properties: Object.fromEntries(await Promise.all(Object.entries(schema.properties).map(async ([key, value]) => [
|
|
14
|
+
key,
|
|
15
|
+
await includeExternalSchema(value),
|
|
16
|
+
]))),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (schema?.type === "array" && schema.items) {
|
|
20
|
+
return { ...schema, items: await includeExternalSchema(schema.items) };
|
|
21
|
+
}
|
|
22
|
+
// Load nested schemas from file
|
|
23
|
+
if (typeof schema === "string") {
|
|
24
|
+
const raw = await index_js_1.nodejs.fs.readFile(index_js_1.nodejs.path.join(index_js_1.nodejs.path.dirname(path), schema), "utf8");
|
|
25
|
+
return nestedJsonSchema.parseAsync((0, yaml_1.parse)(raw));
|
|
26
|
+
}
|
|
27
|
+
return schema;
|
|
28
|
+
};
|
|
29
|
+
const nestedJsonSchema = zod_1.z
|
|
30
|
+
.object({
|
|
31
|
+
type: zod_1.z.string(),
|
|
32
|
+
})
|
|
33
|
+
.passthrough()
|
|
34
|
+
.transform((v) => includeExternalSchema(v));
|
|
9
35
|
const jsonSchemaSchema = zod_1.z
|
|
10
36
|
.object({
|
|
11
37
|
type: zod_1.z.literal("object"),
|
|
@@ -13,29 +39,7 @@ const inputOutputSchema = ({ path }) => {
|
|
|
13
39
|
required: zod_1.z.array(zod_1.z.string()).optional(),
|
|
14
40
|
additionalProperties: zod_1.z.boolean().optional(),
|
|
15
41
|
})
|
|
16
|
-
.transform((v) =>
|
|
17
|
-
const t = async (schema) => {
|
|
18
|
-
if (schema?.type === "object" && schema.properties) {
|
|
19
|
-
return {
|
|
20
|
-
...schema,
|
|
21
|
-
properties: Object.fromEntries(await Promise.all(Object.entries(schema.properties).map(async ([key, value]) => [
|
|
22
|
-
key,
|
|
23
|
-
await t(value),
|
|
24
|
-
]))),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
if (schema?.type === "array" && schema.items) {
|
|
28
|
-
return { ...schema, items: await t(schema.items) };
|
|
29
|
-
}
|
|
30
|
-
// Load nested schemas from file
|
|
31
|
-
if (typeof schema === "string") {
|
|
32
|
-
const raw = await index_js_1.nodejs.fs.readFile(index_js_1.nodejs.path.join(index_js_1.nodejs.path.dirname(path), schema), "utf8");
|
|
33
|
-
return jsonSchemaSchema.parseAsync((0, yaml_1.parse)(raw));
|
|
34
|
-
}
|
|
35
|
-
return schema;
|
|
36
|
-
};
|
|
37
|
-
return t(v);
|
|
38
|
-
});
|
|
42
|
+
.transform((v) => includeExternalSchema(v));
|
|
39
43
|
return zod_1.z.union([
|
|
40
44
|
zod_1.z
|
|
41
45
|
.string()
|
package/lib/esm/loader/schema.js
CHANGED
|
@@ -2,6 +2,32 @@ import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
|
|
|
2
2
|
import { parse } from "yaml";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
export const inputOutputSchema = ({ path }) => {
|
|
5
|
+
const includeExternalSchema = async (schema) => {
|
|
6
|
+
if (schema?.type === "object" && schema.properties) {
|
|
7
|
+
return {
|
|
8
|
+
...schema,
|
|
9
|
+
properties: Object.fromEntries(await Promise.all(Object.entries(schema.properties).map(async ([key, value]) => [
|
|
10
|
+
key,
|
|
11
|
+
await includeExternalSchema(value),
|
|
12
|
+
]))),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
if (schema?.type === "array" && schema.items) {
|
|
16
|
+
return { ...schema, items: await includeExternalSchema(schema.items) };
|
|
17
|
+
}
|
|
18
|
+
// Load nested schemas from file
|
|
19
|
+
if (typeof schema === "string") {
|
|
20
|
+
const raw = await nodejs.fs.readFile(nodejs.path.join(nodejs.path.dirname(path), schema), "utf8");
|
|
21
|
+
return nestedJsonSchema.parseAsync(parse(raw));
|
|
22
|
+
}
|
|
23
|
+
return schema;
|
|
24
|
+
};
|
|
25
|
+
const nestedJsonSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
type: z.string(),
|
|
28
|
+
})
|
|
29
|
+
.passthrough()
|
|
30
|
+
.transform((v) => includeExternalSchema(v));
|
|
5
31
|
const jsonSchemaSchema = z
|
|
6
32
|
.object({
|
|
7
33
|
type: z.literal("object"),
|
|
@@ -9,29 +35,7 @@ export const inputOutputSchema = ({ path }) => {
|
|
|
9
35
|
required: z.array(z.string()).optional(),
|
|
10
36
|
additionalProperties: z.boolean().optional(),
|
|
11
37
|
})
|
|
12
|
-
.transform((v) =>
|
|
13
|
-
const t = async (schema) => {
|
|
14
|
-
if (schema?.type === "object" && schema.properties) {
|
|
15
|
-
return {
|
|
16
|
-
...schema,
|
|
17
|
-
properties: Object.fromEntries(await Promise.all(Object.entries(schema.properties).map(async ([key, value]) => [
|
|
18
|
-
key,
|
|
19
|
-
await t(value),
|
|
20
|
-
]))),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
if (schema?.type === "array" && schema.items) {
|
|
24
|
-
return { ...schema, items: await t(schema.items) };
|
|
25
|
-
}
|
|
26
|
-
// Load nested schemas from file
|
|
27
|
-
if (typeof schema === "string") {
|
|
28
|
-
const raw = await nodejs.fs.readFile(nodejs.path.join(nodejs.path.dirname(path), schema), "utf8");
|
|
29
|
-
return jsonSchemaSchema.parseAsync(parse(raw));
|
|
30
|
-
}
|
|
31
|
-
return schema;
|
|
32
|
-
};
|
|
33
|
-
return t(v);
|
|
34
|
-
});
|
|
38
|
+
.transform((v) => includeExternalSchema(v));
|
|
35
39
|
return z.union([
|
|
36
40
|
z
|
|
37
41
|
.string()
|