@nocobase/plugin-ai 2.0.0-alpha.53 → 2.0.0-alpha.55

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 (55) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +11 -11
  3. package/dist/node_modules/@langchain/anthropic/package.json +1 -1
  4. package/dist/node_modules/@langchain/core/package.json +1 -1
  5. package/dist/node_modules/@langchain/deepseek/package.json +1 -1
  6. package/dist/node_modules/@langchain/google-genai/package.json +1 -1
  7. package/dist/node_modules/@langchain/ollama/index.cjs +1 -1
  8. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/Options.js +0 -1
  9. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/Refs.js +0 -1
  10. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/index.js +0 -1
  11. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parseDef.js +11 -5
  12. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/any.js +2 -16
  13. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/effects.js +1 -2
  14. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/map.js +2 -3
  15. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/never.js +4 -10
  16. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/object.js +2 -1
  17. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/optional.js +2 -3
  18. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/record.js +1 -2
  19. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/undefined.js +2 -3
  20. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/parsers/unknown.js +2 -3
  21. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/selectParser.js +4 -4
  22. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/zodToJsonSchema.js +3 -24
  23. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/Options.js +0 -1
  24. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/Refs.js +0 -1
  25. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/index.js +0 -1
  26. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parseDef.js +10 -4
  27. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +2 -16
  28. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +1 -2
  29. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +2 -3
  30. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +4 -10
  31. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +2 -1
  32. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +2 -3
  33. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +1 -2
  34. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +2 -3
  35. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +2 -3
  36. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/selectParser.js +4 -4
  37. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +3 -24
  38. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/Options.d.ts +0 -1
  39. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/Refs.d.ts +0 -3
  40. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/errorMessages.d.ts +1 -5
  41. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/index.d.ts +0 -1
  42. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/parsers/any.d.ts +2 -5
  43. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/parsers/never.d.ts +2 -4
  44. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/parsers/undefined.d.ts +2 -4
  45. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/parsers/unknown.d.ts +2 -4
  46. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/package.json +1 -1
  47. package/dist/node_modules/@langchain/ollama/package.json +1 -1
  48. package/dist/node_modules/@langchain/openai/package.json +1 -1
  49. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  50. package/dist/node_modules/zod/package.json +1 -1
  51. package/dist/node_modules/zod-to-json-schema/package.json +1 -1
  52. package/package.json +2 -2
  53. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/cjs/getRelativePath.js +0 -12
  54. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +0 -8
  55. package/dist/node_modules/@langchain/ollama/node_modules/zod-to-json-schema/dist/types/getRelativePath.d.ts +0 -1
@@ -37,7 +37,6 @@ exports.defaultOptions = {
37
37
  emailStrategy: "format:email",
38
38
  base64Strategy: "contentEncoding:base64",
39
39
  nameStrategy: "ref",
40
- openAiAnyTypeName: "OpenAiAnyType"
41
40
  };
42
41
  const getDefaultOptions = (options) => (typeof options === "string"
43
42
  ? {
@@ -9,7 +9,6 @@ const getRefs = (options) => {
9
9
  : _options.basePath;
10
10
  return {
11
11
  ..._options,
12
- flags: { hasReferencedOpenAiAnyType: false },
13
12
  currentPath: currentPath,
14
13
  propertyPath: undefined,
15
14
  seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Options.js"), exports);
18
18
  __exportStar(require("./Refs.js"), exports);
19
19
  __exportStar(require("./errorMessages.js"), exports);
20
- __exportStar(require("./getRelativePath.js"), exports);
21
20
  __exportStar(require("./parseDef.js"), exports);
22
21
  __exportStar(require("./parseTypes.js"), exports);
23
22
  __exportStar(require("./parsers/any.js"), exports);
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseDef = void 0;
4
4
  const Options_js_1 = require("./Options.js");
5
5
  const selectParser_js_1 = require("./selectParser.js");
6
- const getRelativePath_js_1 = require("./getRelativePath.js");
7
- const any_js_1 = require("./parsers/any.js");
8
6
  function parseDef(def, refs, forceResolution = false) {
9
7
  const seenItem = refs.seen.get(def);
10
8
  if (refs.override) {
@@ -43,18 +41,26 @@ const get$ref = (item, refs) => {
43
41
  case "root":
44
42
  return { $ref: item.path.join("/") };
45
43
  case "relative":
46
- return { $ref: (0, getRelativePath_js_1.getRelativePath)(refs.currentPath, item.path) };
44
+ return { $ref: getRelativePath(refs.currentPath, item.path) };
47
45
  case "none":
48
46
  case "seen": {
49
47
  if (item.path.length < refs.currentPath.length &&
50
48
  item.path.every((value, index) => refs.currentPath[index] === value)) {
51
49
  console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
52
- return (0, any_js_1.parseAnyDef)(refs);
50
+ return {};
53
51
  }
54
- return refs.$refStrategy === "seen" ? (0, any_js_1.parseAnyDef)(refs) : undefined;
52
+ return refs.$refStrategy === "seen" ? {} : undefined;
55
53
  }
56
54
  }
57
55
  };
56
+ const getRelativePath = (pathA, pathB) => {
57
+ let i = 0;
58
+ for (; i < pathA.length && i < pathB.length; i++) {
59
+ if (pathA[i] !== pathB[i])
60
+ break;
61
+ }
62
+ return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
63
+ };
58
64
  const addMeta = (def, refs, jsonSchema) => {
59
65
  if (def.description) {
60
66
  jsonSchema.description = def.description;
@@ -1,21 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseAnyDef = void 0;
4
- const getRelativePath_js_1 = require("../getRelativePath.js");
5
- function parseAnyDef(refs) {
6
- if (refs.target !== "openAi") {
7
- return {};
8
- }
9
- const anyDefinitionPath = [
10
- ...refs.basePath,
11
- refs.definitionPath,
12
- refs.openAiAnyTypeName,
13
- ];
14
- refs.flags.hasReferencedOpenAiAnyType = true;
15
- return {
16
- $ref: refs.$refStrategy === "relative"
17
- ? (0, getRelativePath_js_1.getRelativePath)(anyDefinitionPath, refs.currentPath)
18
- : anyDefinitionPath.join("/"),
19
- };
4
+ function parseAnyDef() {
5
+ return {};
20
6
  }
21
7
  exports.parseAnyDef = parseAnyDef;
@@ -2,10 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseEffectsDef = void 0;
4
4
  const parseDef_js_1 = require("../parseDef.js");
5
- const any_js_1 = require("./any.js");
6
5
  function parseEffectsDef(_def, refs) {
7
6
  return refs.effectStrategy === "input"
8
7
  ? (0, parseDef_js_1.parseDef)(_def.schema._def, refs)
9
- : (0, any_js_1.parseAnyDef)(refs);
8
+ : {};
10
9
  }
11
10
  exports.parseEffectsDef = parseEffectsDef;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseMapDef = void 0;
4
4
  const parseDef_js_1 = require("../parseDef.js");
5
5
  const record_js_1 = require("./record.js");
6
- const any_js_1 = require("./any.js");
7
6
  function parseMapDef(def, refs) {
8
7
  if (refs.mapStrategy === "record") {
9
8
  return (0, record_js_1.parseRecordDef)(def, refs);
@@ -11,11 +10,11 @@ function parseMapDef(def, refs) {
11
10
  const keys = (0, parseDef_js_1.parseDef)(def.keyType._def, {
12
11
  ...refs,
13
12
  currentPath: [...refs.currentPath, "items", "items", "0"],
14
- }) || (0, any_js_1.parseAnyDef)(refs);
13
+ }) || {};
15
14
  const values = (0, parseDef_js_1.parseDef)(def.valueType._def, {
16
15
  ...refs,
17
16
  currentPath: [...refs.currentPath, "items", "items", "1"],
18
- }) || (0, any_js_1.parseAnyDef)(refs);
17
+ }) || {};
19
18
  return {
20
19
  type: "array",
21
20
  maxItems: 125,
@@ -1,15 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseNeverDef = void 0;
4
- const any_js_1 = require("./any.js");
5
- function parseNeverDef(refs) {
6
- return refs.target === "openAi"
7
- ? undefined
8
- : {
9
- not: (0, any_js_1.parseAnyDef)({
10
- ...refs,
11
- currentPath: [...refs.currentPath, "not"],
12
- }),
13
- };
4
+ function parseNeverDef() {
5
+ return {
6
+ not: {},
7
+ };
14
8
  }
15
9
  exports.parseNeverDef = parseNeverDef;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseObjectDef = void 0;
4
+ const zod_1 = require("zod");
4
5
  const parseDef_js_1 = require("../parseDef.js");
5
6
  function parseObjectDef(def, refs) {
6
7
  const forceOptionalIntoNullable = refs.target === "openAi";
@@ -17,7 +18,7 @@ function parseObjectDef(def, refs) {
17
18
  }
18
19
  let propOptional = safeIsOptional(propDef);
19
20
  if (propOptional && forceOptionalIntoNullable) {
20
- if (propDef._def.typeName === "ZodOptional") {
21
+ if (propDef instanceof zod_1.ZodOptional) {
21
22
  propDef = propDef._def.innerType;
22
23
  }
23
24
  if (!propDef.isNullable()) {
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseOptionalDef = void 0;
4
4
  const parseDef_js_1 = require("../parseDef.js");
5
- const any_js_1 = require("./any.js");
6
5
  const parseOptionalDef = (def, refs) => {
7
6
  if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
8
7
  return (0, parseDef_js_1.parseDef)(def.innerType._def, refs);
@@ -15,11 +14,11 @@ const parseOptionalDef = (def, refs) => {
15
14
  ? {
16
15
  anyOf: [
17
16
  {
18
- not: (0, any_js_1.parseAnyDef)(refs),
17
+ not: {},
19
18
  },
20
19
  innerSchema,
21
20
  ],
22
21
  }
23
- : (0, any_js_1.parseAnyDef)(refs);
22
+ : {};
24
23
  };
25
24
  exports.parseOptionalDef = parseOptionalDef;
@@ -5,7 +5,6 @@ const zod_1 = require("zod");
5
5
  const parseDef_js_1 = require("../parseDef.js");
6
6
  const string_js_1 = require("./string.js");
7
7
  const branded_js_1 = require("./branded.js");
8
- const any_js_1 = require("./any.js");
9
8
  function parseRecordDef(def, refs) {
10
9
  if (refs.target === "openAi") {
11
10
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
@@ -20,7 +19,7 @@ function parseRecordDef(def, refs) {
20
19
  [key]: (0, parseDef_js_1.parseDef)(def.valueType._def, {
21
20
  ...refs,
22
21
  currentPath: [...refs.currentPath, "properties", key],
23
- }) ?? (0, any_js_1.parseAnyDef)(refs),
22
+ }) ?? {},
24
23
  }), {}),
25
24
  additionalProperties: refs.rejectedAdditionalProperties,
26
25
  };
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseUndefinedDef = void 0;
4
- const any_js_1 = require("./any.js");
5
- function parseUndefinedDef(refs) {
4
+ function parseUndefinedDef() {
6
5
  return {
7
- not: (0, any_js_1.parseAnyDef)(refs),
6
+ not: {},
8
7
  };
9
8
  }
10
9
  exports.parseUndefinedDef = parseUndefinedDef;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseUnknownDef = void 0;
4
- const any_js_1 = require("./any.js");
5
- function parseUnknownDef(refs) {
6
- return (0, any_js_1.parseAnyDef)(refs);
4
+ function parseUnknownDef() {
5
+ return {};
7
6
  }
8
7
  exports.parseUnknownDef = parseUnknownDef;
@@ -47,7 +47,7 @@ const selectParser = (def, typeName, refs) => {
47
47
  case zod_1.ZodFirstPartyTypeKind.ZodDate:
48
48
  return (0, date_js_1.parseDateDef)(def, refs);
49
49
  case zod_1.ZodFirstPartyTypeKind.ZodUndefined:
50
- return (0, undefined_js_1.parseUndefinedDef)(refs);
50
+ return (0, undefined_js_1.parseUndefinedDef)();
51
51
  case zod_1.ZodFirstPartyTypeKind.ZodNull:
52
52
  return (0, null_js_1.parseNullDef)(refs);
53
53
  case zod_1.ZodFirstPartyTypeKind.ZodArray:
@@ -81,13 +81,13 @@ const selectParser = (def, typeName, refs) => {
81
81
  return (0, promise_js_1.parsePromiseDef)(def, refs);
82
82
  case zod_1.ZodFirstPartyTypeKind.ZodNaN:
83
83
  case zod_1.ZodFirstPartyTypeKind.ZodNever:
84
- return (0, never_js_1.parseNeverDef)(refs);
84
+ return (0, never_js_1.parseNeverDef)();
85
85
  case zod_1.ZodFirstPartyTypeKind.ZodEffects:
86
86
  return (0, effects_js_1.parseEffectsDef)(def, refs);
87
87
  case zod_1.ZodFirstPartyTypeKind.ZodAny:
88
- return (0, any_js_1.parseAnyDef)(refs);
88
+ return (0, any_js_1.parseAnyDef)();
89
89
  case zod_1.ZodFirstPartyTypeKind.ZodUnknown:
90
- return (0, unknown_js_1.parseUnknownDef)(refs);
90
+ return (0, unknown_js_1.parseUnknownDef)();
91
91
  case zod_1.ZodFirstPartyTypeKind.ZodDefault:
92
92
  return (0, default_js_1.parseDefaultDef)(def, refs);
93
93
  case zod_1.ZodFirstPartyTypeKind.ZodBranded:
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.zodToJsonSchema = void 0;
4
4
  const parseDef_js_1 = require("./parseDef.js");
5
5
  const Refs_js_1 = require("./Refs.js");
6
- const any_js_1 = require("./parsers/any.js");
7
6
  const zodToJsonSchema = (schema, options) => {
8
7
  const refs = (0, Refs_js_1.getRefs)(options);
9
- let definitions = typeof options === "object" && options.definitions
8
+ const definitions = typeof options === "object" && options.definitions
10
9
  ? Object.entries(options.definitions).reduce((acc, [name, schema]) => ({
11
10
  ...acc,
12
11
  [name]: (0, parseDef_js_1.parseDef)(schema._def, {
13
12
  ...refs,
14
13
  currentPath: [...refs.basePath, refs.definitionPath, name],
15
- }, true) ?? (0, any_js_1.parseAnyDef)(refs),
14
+ }, true) ?? {},
16
15
  }), {})
17
16
  : undefined;
18
17
  const name = typeof options === "string"
@@ -25,7 +24,7 @@ const zodToJsonSchema = (schema, options) => {
25
24
  : {
26
25
  ...refs,
27
26
  currentPath: [...refs.basePath, refs.definitionPath, name],
28
- }, false) ?? (0, any_js_1.parseAnyDef)(refs);
27
+ }, false) ?? {};
29
28
  const title = typeof options === "object" &&
30
29
  options.name !== undefined &&
31
30
  options.nameStrategy === "title"
@@ -34,26 +33,6 @@ const zodToJsonSchema = (schema, options) => {
34
33
  if (title !== undefined) {
35
34
  main.title = title;
36
35
  }
37
- if (refs.flags.hasReferencedOpenAiAnyType) {
38
- if (!definitions) {
39
- definitions = {};
40
- }
41
- if (!definitions[refs.openAiAnyTypeName]) {
42
- definitions[refs.openAiAnyTypeName] = {
43
- // Skipping "object" as no properties can be defined and additionalProperties must be "false"
44
- type: ["string", "number", "integer", "boolean", "array", "null"],
45
- items: {
46
- $ref: refs.$refStrategy === "relative"
47
- ? "1"
48
- : [
49
- ...refs.basePath,
50
- refs.definitionPath,
51
- refs.openAiAnyTypeName,
52
- ].join("/"),
53
- },
54
- };
55
- }
56
- }
57
36
  const combined = name === undefined
58
37
  ? definitions
59
38
  ? {
@@ -33,7 +33,6 @@ export const defaultOptions = {
33
33
  emailStrategy: "format:email",
34
34
  base64Strategy: "contentEncoding:base64",
35
35
  nameStrategy: "ref",
36
- openAiAnyTypeName: "OpenAiAnyType"
37
36
  };
38
37
  export const getDefaultOptions = (options) => (typeof options === "string"
39
38
  ? {
@@ -6,7 +6,6 @@ export const getRefs = (options) => {
6
6
  : _options.basePath;
7
7
  return {
8
8
  ..._options,
9
- flags: { hasReferencedOpenAiAnyType: false },
10
9
  currentPath: currentPath,
11
10
  propertyPath: undefined,
12
11
  seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
@@ -1,7 +1,6 @@
1
1
  export * from "./Options.js";
2
2
  export * from "./Refs.js";
3
3
  export * from "./errorMessages.js";
4
- export * from "./getRelativePath.js";
5
4
  export * from "./parseDef.js";
6
5
  export * from "./parseTypes.js";
7
6
  export * from "./parsers/any.js";
@@ -1,7 +1,5 @@
1
1
  import { ignoreOverride } from "./Options.js";
2
2
  import { selectParser } from "./selectParser.js";
3
- import { getRelativePath } from "./getRelativePath.js";
4
- import { parseAnyDef } from "./parsers/any.js";
5
3
  export function parseDef(def, refs, forceResolution = false) {
6
4
  const seenItem = refs.seen.get(def);
7
5
  if (refs.override) {
@@ -45,12 +43,20 @@ const get$ref = (item, refs) => {
45
43
  if (item.path.length < refs.currentPath.length &&
46
44
  item.path.every((value, index) => refs.currentPath[index] === value)) {
47
45
  console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
48
- return parseAnyDef(refs);
46
+ return {};
49
47
  }
50
- return refs.$refStrategy === "seen" ? parseAnyDef(refs) : undefined;
48
+ return refs.$refStrategy === "seen" ? {} : undefined;
51
49
  }
52
50
  }
53
51
  };
52
+ const getRelativePath = (pathA, pathB) => {
53
+ let i = 0;
54
+ for (; i < pathA.length && i < pathB.length; i++) {
55
+ if (pathA[i] !== pathB[i])
56
+ break;
57
+ }
58
+ return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
59
+ };
54
60
  const addMeta = (def, refs, jsonSchema) => {
55
61
  if (def.description) {
56
62
  jsonSchema.description = def.description;
@@ -1,17 +1,3 @@
1
- import { getRelativePath } from "../getRelativePath.js";
2
- export function parseAnyDef(refs) {
3
- if (refs.target !== "openAi") {
4
- return {};
5
- }
6
- const anyDefinitionPath = [
7
- ...refs.basePath,
8
- refs.definitionPath,
9
- refs.openAiAnyTypeName,
10
- ];
11
- refs.flags.hasReferencedOpenAiAnyType = true;
12
- return {
13
- $ref: refs.$refStrategy === "relative"
14
- ? getRelativePath(anyDefinitionPath, refs.currentPath)
15
- : anyDefinitionPath.join("/"),
16
- };
1
+ export function parseAnyDef() {
2
+ return {};
17
3
  }
@@ -1,7 +1,6 @@
1
1
  import { parseDef } from "../parseDef.js";
2
- import { parseAnyDef } from "./any.js";
3
2
  export function parseEffectsDef(_def, refs) {
4
3
  return refs.effectStrategy === "input"
5
4
  ? parseDef(_def.schema._def, refs)
6
- : parseAnyDef(refs);
5
+ : {};
7
6
  }
@@ -1,6 +1,5 @@
1
1
  import { parseDef } from "../parseDef.js";
2
2
  import { parseRecordDef } from "./record.js";
3
- import { parseAnyDef } from "./any.js";
4
3
  export function parseMapDef(def, refs) {
5
4
  if (refs.mapStrategy === "record") {
6
5
  return parseRecordDef(def, refs);
@@ -8,11 +7,11 @@ export function parseMapDef(def, refs) {
8
7
  const keys = parseDef(def.keyType._def, {
9
8
  ...refs,
10
9
  currentPath: [...refs.currentPath, "items", "items", "0"],
11
- }) || parseAnyDef(refs);
10
+ }) || {};
12
11
  const values = parseDef(def.valueType._def, {
13
12
  ...refs,
14
13
  currentPath: [...refs.currentPath, "items", "items", "1"],
15
- }) || parseAnyDef(refs);
14
+ }) || {};
16
15
  return {
17
16
  type: "array",
18
17
  maxItems: 125,
@@ -1,11 +1,5 @@
1
- import { parseAnyDef } from "./any.js";
2
- export function parseNeverDef(refs) {
3
- return refs.target === "openAi"
4
- ? undefined
5
- : {
6
- not: parseAnyDef({
7
- ...refs,
8
- currentPath: [...refs.currentPath, "not"],
9
- }),
10
- };
1
+ export function parseNeverDef() {
2
+ return {
3
+ not: {},
4
+ };
11
5
  }
@@ -1,3 +1,4 @@
1
+ import { ZodOptional } from "zod";
1
2
  import { parseDef } from "../parseDef.js";
2
3
  export function parseObjectDef(def, refs) {
3
4
  const forceOptionalIntoNullable = refs.target === "openAi";
@@ -14,7 +15,7 @@ export function parseObjectDef(def, refs) {
14
15
  }
15
16
  let propOptional = safeIsOptional(propDef);
16
17
  if (propOptional && forceOptionalIntoNullable) {
17
- if (propDef._def.typeName === "ZodOptional") {
18
+ if (propDef instanceof ZodOptional) {
18
19
  propDef = propDef._def.innerType;
19
20
  }
20
21
  if (!propDef.isNullable()) {
@@ -1,5 +1,4 @@
1
1
  import { parseDef } from "../parseDef.js";
2
- import { parseAnyDef } from "./any.js";
3
2
  export const parseOptionalDef = (def, refs) => {
4
3
  if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
5
4
  return parseDef(def.innerType._def, refs);
@@ -12,10 +11,10 @@ export const parseOptionalDef = (def, refs) => {
12
11
  ? {
13
12
  anyOf: [
14
13
  {
15
- not: parseAnyDef(refs),
14
+ not: {},
16
15
  },
17
16
  innerSchema,
18
17
  ],
19
18
  }
20
- : parseAnyDef(refs);
19
+ : {};
21
20
  };
@@ -2,7 +2,6 @@ import { ZodFirstPartyTypeKind, } from "zod";
2
2
  import { parseDef } from "../parseDef.js";
3
3
  import { parseStringDef } from "./string.js";
4
4
  import { parseBrandedDef } from "./branded.js";
5
- import { parseAnyDef } from "./any.js";
6
5
  export function parseRecordDef(def, refs) {
7
6
  if (refs.target === "openAi") {
8
7
  console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
@@ -17,7 +16,7 @@ export function parseRecordDef(def, refs) {
17
16
  [key]: parseDef(def.valueType._def, {
18
17
  ...refs,
19
18
  currentPath: [...refs.currentPath, "properties", key],
20
- }) ?? parseAnyDef(refs),
19
+ }) ?? {},
21
20
  }), {}),
22
21
  additionalProperties: refs.rejectedAdditionalProperties,
23
22
  };
@@ -1,6 +1,5 @@
1
- import { parseAnyDef } from "./any.js";
2
- export function parseUndefinedDef(refs) {
1
+ export function parseUndefinedDef() {
3
2
  return {
4
- not: parseAnyDef(refs),
3
+ not: {},
5
4
  };
6
5
  }
@@ -1,4 +1,3 @@
1
- import { parseAnyDef } from "./any.js";
2
- export function parseUnknownDef(refs) {
3
- return parseAnyDef(refs);
1
+ export function parseUnknownDef() {
2
+ return {};
4
3
  }
@@ -44,7 +44,7 @@ export const selectParser = (def, typeName, refs) => {
44
44
  case ZodFirstPartyTypeKind.ZodDate:
45
45
  return parseDateDef(def, refs);
46
46
  case ZodFirstPartyTypeKind.ZodUndefined:
47
- return parseUndefinedDef(refs);
47
+ return parseUndefinedDef();
48
48
  case ZodFirstPartyTypeKind.ZodNull:
49
49
  return parseNullDef(refs);
50
50
  case ZodFirstPartyTypeKind.ZodArray:
@@ -78,13 +78,13 @@ export const selectParser = (def, typeName, refs) => {
78
78
  return parsePromiseDef(def, refs);
79
79
  case ZodFirstPartyTypeKind.ZodNaN:
80
80
  case ZodFirstPartyTypeKind.ZodNever:
81
- return parseNeverDef(refs);
81
+ return parseNeverDef();
82
82
  case ZodFirstPartyTypeKind.ZodEffects:
83
83
  return parseEffectsDef(def, refs);
84
84
  case ZodFirstPartyTypeKind.ZodAny:
85
- return parseAnyDef(refs);
85
+ return parseAnyDef();
86
86
  case ZodFirstPartyTypeKind.ZodUnknown:
87
- return parseUnknownDef(refs);
87
+ return parseUnknownDef();
88
88
  case ZodFirstPartyTypeKind.ZodDefault:
89
89
  return parseDefaultDef(def, refs);
90
90
  case ZodFirstPartyTypeKind.ZodBranded:
@@ -1,15 +1,14 @@
1
1
  import { parseDef } from "./parseDef.js";
2
2
  import { getRefs } from "./Refs.js";
3
- import { parseAnyDef } from "./parsers/any.js";
4
3
  const zodToJsonSchema = (schema, options) => {
5
4
  const refs = getRefs(options);
6
- let definitions = typeof options === "object" && options.definitions
5
+ const definitions = typeof options === "object" && options.definitions
7
6
  ? Object.entries(options.definitions).reduce((acc, [name, schema]) => ({
8
7
  ...acc,
9
8
  [name]: parseDef(schema._def, {
10
9
  ...refs,
11
10
  currentPath: [...refs.basePath, refs.definitionPath, name],
12
- }, true) ?? parseAnyDef(refs),
11
+ }, true) ?? {},
13
12
  }), {})
14
13
  : undefined;
15
14
  const name = typeof options === "string"
@@ -22,7 +21,7 @@ const zodToJsonSchema = (schema, options) => {
22
21
  : {
23
22
  ...refs,
24
23
  currentPath: [...refs.basePath, refs.definitionPath, name],
25
- }, false) ?? parseAnyDef(refs);
24
+ }, false) ?? {};
26
25
  const title = typeof options === "object" &&
27
26
  options.name !== undefined &&
28
27
  options.nameStrategy === "title"
@@ -31,26 +30,6 @@ const zodToJsonSchema = (schema, options) => {
31
30
  if (title !== undefined) {
32
31
  main.title = title;
33
32
  }
34
- if (refs.flags.hasReferencedOpenAiAnyType) {
35
- if (!definitions) {
36
- definitions = {};
37
- }
38
- if (!definitions[refs.openAiAnyTypeName]) {
39
- definitions[refs.openAiAnyTypeName] = {
40
- // Skipping "object" as no properties can be defined and additionalProperties must be "false"
41
- type: ["string", "number", "integer", "boolean", "array", "null"],
42
- items: {
43
- $ref: refs.$refStrategy === "relative"
44
- ? "1"
45
- : [
46
- ...refs.basePath,
47
- refs.definitionPath,
48
- refs.openAiAnyTypeName,
49
- ].join("/"),
50
- },
51
- };
52
- }
53
- }
54
33
  const combined = name === undefined
55
34
  ? definitions
56
35
  ? {
@@ -31,7 +31,6 @@ export type Options<Target extends Targets = "jsonSchema7"> = {
31
31
  nameStrategy: "ref" | "title";
32
32
  override?: OverrideCallback;
33
33
  postProcess?: PostProcessCallback;
34
- openAiAnyTypeName: string;
35
34
  };
36
35
  export declare const defaultOptions: Options;
37
36
  export declare const getDefaultOptions: <Target extends Targets>(options: string | Partial<Options<Target>> | undefined) => Options<Target>;
@@ -5,9 +5,6 @@ export type Refs = {
5
5
  seen: Map<ZodTypeDef, Seen>;
6
6
  currentPath: string[];
7
7
  propertyPath: string[] | undefined;
8
- flags: {
9
- hasReferencedOpenAiAnyType: boolean;
10
- };
11
8
  } & Options<Targets>;
12
9
  export type Seen = {
13
10
  def: ZodTypeDef;
@@ -1,10 +1,6 @@
1
1
  import { JsonSchema7TypeUnion } from "./parseTypes.js";
2
2
  import { Refs } from "./Refs.js";
3
- export type ErrorMessages<T extends JsonSchema7TypeUnion | {
4
- format: string;
5
- } | {
6
- pattern: string;
7
- }, OmitProperties extends string = ""> = Partial<Omit<{
3
+ export type ErrorMessages<T extends JsonSchema7TypeUnion, OmitProperties extends string = ""> = Partial<Omit<{
8
4
  [key in keyof T]: string;
9
5
  }, OmitProperties | "type" | "errorMessages">>;
10
6
  export declare function addErrorMessage<T extends {
@@ -1,7 +1,6 @@
1
1
  export * from "./Options.js";
2
2
  export * from "./Refs.js";
3
3
  export * from "./errorMessages.js";
4
- export * from "./getRelativePath.js";
5
4
  export * from "./parseDef.js";
6
5
  export * from "./parseTypes.js";
7
6
  export * from "./parsers/any.js";
@@ -1,5 +1,2 @@
1
- import { Refs } from "../Refs.js";
2
- export type JsonSchema7AnyType = {
3
- $ref?: string;
4
- };
5
- export declare function parseAnyDef(refs: Refs): JsonSchema7AnyType;
1
+ export type JsonSchema7AnyType = {};
2
+ export declare function parseAnyDef(): JsonSchema7AnyType;