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

@workflowai/schema

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@workflowai/schema - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

dist/cjs/__tests__/json-schema-refs.test.d.ts

2

dist/cjs/definitions.d.ts

@@ -5,3 +5,3 @@ import { z } from './zod';

export type Definition = {
jsonSchemaTitle: string;
jsonSchemaDefinitionKey: string;
zodSchema: {

@@ -8,0 +8,0 @@ input: ZodExtensionName;

@@ -6,3 +6,3 @@ "use strict";

{
jsonSchemaTitle: 'DatetimeLocal',
jsonSchemaDefinitionKey: 'DatetimeLocal',
zodSchema: {

@@ -14,3 +14,3 @@ input: 'datetimeLocal',

{
jsonSchemaTitle: 'Image',
jsonSchemaDefinitionKey: 'Image',
zodSchema: {

@@ -17,0 +17,0 @@ input: 'imageInput',

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.outputSchemaToZod = exports.inputSchemaToZod = void 0;
const json_refs_1 = require("json-refs");
const json_schema_to_zod_1 = require("json-schema-to-zod");
const definitions_1 = require("./definitions");
const json_schema_refs_1 = require("./json-schema-refs");
const makeParserOverride = (type) => (schema, _refs) => {
if (schema.title) {
const definition = definitions_1.definitions.find(({ jsonSchemaTitle }) => jsonSchemaTitle === schema.title);
if (schema.$ref) {
const definition = definitions_1.definitions.find(({ jsonSchemaDefinitionKey }) => jsonSchemaDefinitionKey === schema.$ref.split('/$defs/').pop());
if (definition) {

@@ -19,3 +19,3 @@ return `z.${definition.zodSchema[type]}()`;

const schemaToZod = async (jsonSchema, parserOverride) => {
const { resolved: resolvedJsonSchema } = await (0, json_refs_1.resolveRefs)(jsonSchema);
const resolvedJsonSchema = (0, json_schema_refs_1.hydrateRefs)(jsonSchema, { keepRefs: true });
return (0, json_schema_to_zod_1.jsonSchemaToZod)(resolvedJsonSchema, { parserOverride });

@@ -22,0 +22,0 @@ };

@@ -7,10 +7,10 @@ "use strict";

const zod_1 = require("./zod");
const { input: inputSchemaDefinitions, output: outputSchemaDefinitions } = definitions_1.definitions.reduce((result, { jsonSchemaTitle, zodSchema }) => ({
const { input: inputSchemaDefinitions, output: outputSchemaDefinitions } = definitions_1.definitions.reduce((result, { jsonSchemaDefinitionKey, zodSchema }) => ({
input: {
...result.input,
[jsonSchemaTitle]: zod_1.z[zodSchema.input](),
[jsonSchemaDefinitionKey]: zod_1.z[zodSchema.input](),
},
output: {
...result.output,
[jsonSchemaTitle]: zod_1.z[zodSchema.output](),
[jsonSchemaDefinitionKey]: zod_1.z[zodSchema.output](),
},

@@ -17,0 +17,0 @@ }), { input: {}, output: {} });

export const definitions = [
{
jsonSchemaTitle: 'DatetimeLocal',
jsonSchemaDefinitionKey: 'DatetimeLocal',
zodSchema: {

@@ -10,3 +10,3 @@ input: 'datetimeLocal',

{
jsonSchemaTitle: 'Image',
jsonSchemaDefinitionKey: 'Image',
zodSchema: {

@@ -13,0 +13,0 @@ input: 'imageInput',

@@ -1,7 +0,7 @@

import { resolveRefs } from 'json-refs';
import { jsonSchemaToZod, } from 'json-schema-to-zod';
import { definitions } from './definitions';
import { hydrateRefs } from './json-schema-refs';
const makeParserOverride = (type) => (schema, _refs) => {
if (schema.title) {
const definition = definitions.find(({ jsonSchemaTitle }) => jsonSchemaTitle === schema.title);
if (schema.$ref) {
const definition = definitions.find(({ jsonSchemaDefinitionKey }) => jsonSchemaDefinitionKey === schema.$ref.split('/$defs/').pop());
if (definition) {

@@ -16,3 +16,3 @@ return `z.${definition.zodSchema[type]}()`;

const schemaToZod = async (jsonSchema, parserOverride) => {
const { resolved: resolvedJsonSchema } = await resolveRefs(jsonSchema);
const resolvedJsonSchema = hydrateRefs(jsonSchema, { keepRefs: true });
return jsonSchemaToZod(resolvedJsonSchema, { parserOverride });

@@ -19,0 +19,0 @@ };

import { zodToJsonSchema } from 'zod-to-json-schema';
import { definitions } from './definitions';
import { z } from './zod';
const { input: inputSchemaDefinitions, output: outputSchemaDefinitions } = definitions.reduce((result, { jsonSchemaTitle, zodSchema }) => ({
const { input: inputSchemaDefinitions, output: outputSchemaDefinitions } = definitions.reduce((result, { jsonSchemaDefinitionKey, zodSchema }) => ({
input: {
...result.input,
[jsonSchemaTitle]: z[zodSchema.input](),
[jsonSchemaDefinitionKey]: z[zodSchema.input](),
},
output: {
...result.output,
[jsonSchemaTitle]: z[zodSchema.output](),
[jsonSchemaDefinitionKey]: z[zodSchema.output](),
},

@@ -13,0 +13,0 @@ }), { input: {}, output: {} });

@@ -5,3 +5,3 @@ import { z } from './zod';

export type Definition = {
jsonSchemaTitle: string;
jsonSchemaDefinitionKey: string;
zodSchema: {

@@ -8,0 +8,0 @@ input: ZodExtensionName;

{
"name": "@workflowai/schema",
"version": "1.0.2",
"version": "1.0.3",
"description": "workflowAI schema helpers",

@@ -44,7 +44,5 @@ "author": "workflowAI",

"dry": "npm run build && npm pub --dry-run",
"prepublishOnly--DISABLED": "npm run test && npm run build",
"prepublishOnly": "npm run build"
},
"dependencies": {
"json-refs": "^3.0.15",
"json-schema-to-zod": "^2.1.0",

@@ -51,0 +49,0 @@ "zod": "^3.23.7",

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