Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openai-zod-to-json-schema

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openai-zod-to-json-schema - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

dist/index.d.ts

@@ -319,3 +319,3 @@ import { ZodArrayDef, ZodBigIntDef, ZodNumberDef, ZodDateDef, ZodEnumDef, ZodIntersectionDef, ZodLiteralDef, ZodStringDef, ZodRecordDef, ZodTypeAny, ZodMapDef, ZodNativeEnumDef, ZodNullableDef, ZodObjectDef, ZodSetDef, ZodTupleDef, ZodTupleItems, ZodUnionDef, ZodDiscriminatedUnionDef, ZodTypeDef, ZodSchema, ZodBrandedDef, ZodCatchDef, ZodDefaultDef, ZodEffectsDef, ZodOptionalDef, ZodPipelineDef, ZodPromiseDef, ZodReadonlyDef } from 'zod';

declare function parseEffectsDef(_def: ZodEffectsDef, refs: Refs): JsonSchema7Type | undefined;
declare function parseEffectsDef(_def: ZodEffectsDef, refs: Refs, forceResolution: boolean): JsonSchema7Type | undefined;

@@ -322,0 +322,0 @@ declare const parseOptionalDef: (def: ZodOptionalDef, refs: Refs) => JsonSchema7Type | undefined;

@@ -248,4 +248,4 @@ // src/vendor/zod-to-json-schema/Options.ts

// src/vendor/zod-to-json-schema/parsers/effects.ts
function parseEffectsDef(_def, refs) {
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : {};
function parseEffectsDef(_def, refs, forceResolution) {
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs, forceResolution) : {};
}

@@ -1078,3 +1078,3 @@

refs.seen.set(def, newItem);
const jsonSchema = selectParser(def, def.typeName, refs);
const jsonSchema = selectParser(def, def.typeName, refs, forceResolution);
if (jsonSchema) {

@@ -1090,2 +1090,10 @@ addMeta(def, refs, jsonSchema);

return { $ref: item.path.join("/") };
// this case is needed as OpenAI strict mode doesn't support top-level `$ref`s, i.e.
// the top-level schema *must* be `{"type": "object", "properties": {...}}` but if we ever
// need to define a `$ref`, relative `$ref`s aren't supported, so we need to extract
// the schema to `#/definitions/` and reference that.
//
// e.g. if we need to reference a schema at
// `["#","definitions","contactPerson","properties","person1","properties","name"]`
// then we'll extract it out to `contactPerson_properties_person1_properties_name`
case "extract-to-root":

@@ -1116,3 +1124,3 @@ const name = item.path.slice(refs.basePath.length + 1).join("_");

};
var selectParser = (def, typeName, refs) => {
var selectParser = (def, typeName, refs, forceResolution) => {
switch (typeName) {

@@ -1168,3 +1176,3 @@ case ZodFirstPartyTypeKind3.ZodString:

case ZodFirstPartyTypeKind3.ZodEffects:
return parseEffectsDef(def, refs);
return parseEffectsDef(def, refs, forceResolution);
case ZodFirstPartyTypeKind3.ZodAny:

@@ -1171,0 +1179,0 @@ return parseAnyDef();

{
"name": "openai-zod-to-json-schema",
"version": "1.0.2",
"version": "1.0.3",
"description": "Convert Zod schemas to JSON schemas which are optionally compatible with OpenAI's structured outputs.",

@@ -15,2 +15,3 @@ "author": "Travis Fischer <travis@transitivebullsh.it>",

"type": "module",
"main": "./dist/index.js",
"source": "./src/index.ts",

@@ -23,4 +24,3 @@ "types": "./dist/index.d.ts",

"import": "./dist/index.js",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
"require": "./dist/index.cjs"
}

@@ -34,18 +34,16 @@ },

"@types/json-schema": "^7.0.15",
"@types/node": "^22.4.0",
"@types/node": "^22.7.5",
"ajv": "^8.17.1",
"ajv-formats": "^3.0.1",
"del-cli": "^5.1.0",
"eslint": "^8.57.0",
"husky": "^9.1.4",
"del-cli": "^6.0.0",
"eslint": "^8.57.1",
"json-schema": "^0.4.0",
"lint-staged": "^15.2.9",
"local-ref-resolver": "^0.2.0",
"npm-run-all2": "^6.2.2",
"npm-run-all2": "^6.2.3",
"only-allow": "^1.2.1",
"openai": "^4.56.0",
"openai": "^4.67.3",
"prettier": "^3.3.3",
"tsup": "^8.2.4",
"typescript": "^5.5.4",
"vitest": "2.0.5",
"tsup": "^8.3.0",
"typescript": "^5.6.3",
"vitest": "2.1.3",
"zod": "^3.23.8"

@@ -56,8 +54,2 @@ },

},
"lint-staged": {
"*.{ts,tsx}": [
"prettier --ignore-unknown --write",
"eslint --fix"
]
},
"scripts": {

@@ -77,6 +69,4 @@ "build": "tsup",

"vendor": "mkdir -p src/vendor/zod-to-json-schema && cp -r node_modules/openai/src/_vendor/zod-to-json-schema src/vendor",
"release": "np",
"precommit": "lint-staged",
"preinstall": "npx only-allow pnpm"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc