@standard-community/standard-json 0.3.0-rc.0 → 0.3.0-rc.1

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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const getToJsonSchemaFn$4 = async () => (schema) => schema.toJsonSchema();
3
+ const getToJsonSchemaFn$4 = async () => (schema, options) => schema.toJsonSchema(options);
4
4
 
5
5
  const errorMessageWrapper = (message) => `standard-json: ${message}`;
6
6
  const tryImport = async (result, name) => {
@@ -29,14 +29,15 @@ const getToJsonSchemaFn$2 = async () => {
29
29
 
30
30
  const getToJsonSchemaFn$1 = async () => async (schema, options) => {
31
31
  let handler;
32
- if ("_zod" in schema)
32
+ if ("_zod" in schema) {
33
33
  handler = await tryImport(import('zod/v4/core'), "zod v4").then(
34
34
  (mod) => mod.toJSONSchema
35
35
  );
36
- else
36
+ } else {
37
37
  handler = await tryImport(import('zod-to-json-schema'), "zod v3").then(
38
38
  (mod) => mod.zodToJsonSchema
39
39
  );
40
+ }
40
41
  return handler(schema, options);
41
42
  };
42
43
 
@@ -46,17 +47,17 @@ const vendorToFn = {
46
47
  valibot: getToJsonSchemaFn$2,
47
48
  zod: getToJsonSchemaFn$1
48
49
  };
49
- const getToJsonSchemaFn = async (vendor) => {
50
- const venderConvertor = vendorToFn[vendor];
51
- if (!venderConvertor)
50
+ const getToJsonSchemaFn = (vendor) => {
51
+ const vendorConverter = vendorToFn[vendor];
52
+ if (!vendorConverter)
52
53
  throw new Error(
53
54
  errorMessageWrapper(`Unsupported schema vendor "${vendor}"`)
54
55
  );
55
- return venderConvertor();
56
+ return vendorConverter();
56
57
  };
57
58
 
58
- const toJsonSchema = (schema) => getToJsonSchemaFn(schema["~standard"].vendor).then(
59
- (toJsonSchema2) => toJsonSchema2(schema)
59
+ const toJsonSchema = (schema, options) => getToJsonSchemaFn(schema["~standard"].vendor).then(
60
+ (toJsonSchema2) => toJsonSchema2(schema, options)
60
61
  );
61
62
 
62
63
  exports.toJsonSchema = toJsonSchema;
package/dist/index.d.cts CHANGED
@@ -4,6 +4,6 @@ import { JSONSchema7 } from 'json-schema';
4
4
  /**
5
5
  * Converts a Standard Schema to a JSON schema.
6
6
  */
7
- declare const toJsonSchema: (schema: StandardSchemaV1) => Promise<JSONSchema7>;
7
+ declare const toJsonSchema: (schema: StandardSchemaV1, options?: Record<string, unknown>) => Promise<JSONSchema7>;
8
8
 
9
9
  export { toJsonSchema };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,6 @@ import { JSONSchema7 } from 'json-schema';
4
4
  /**
5
5
  * Converts a Standard Schema to a JSON schema.
6
6
  */
7
- declare const toJsonSchema: (schema: StandardSchemaV1) => Promise<JSONSchema7>;
7
+ declare const toJsonSchema: (schema: StandardSchemaV1, options?: Record<string, unknown>) => Promise<JSONSchema7>;
8
8
 
9
9
  export { toJsonSchema };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const getToJsonSchemaFn$4 = async () => (schema) => schema.toJsonSchema();
1
+ const getToJsonSchemaFn$4 = async () => (schema, options) => schema.toJsonSchema(options);
2
2
 
3
3
  const errorMessageWrapper = (message) => `standard-json: ${message}`;
4
4
  const tryImport = async (result, name) => {
@@ -27,14 +27,15 @@ const getToJsonSchemaFn$2 = async () => {
27
27
 
28
28
  const getToJsonSchemaFn$1 = async () => async (schema, options) => {
29
29
  let handler;
30
- if ("_zod" in schema)
30
+ if ("_zod" in schema) {
31
31
  handler = await tryImport(import('zod/v4/core'), "zod v4").then(
32
32
  (mod) => mod.toJSONSchema
33
33
  );
34
- else
34
+ } else {
35
35
  handler = await tryImport(import('zod-to-json-schema'), "zod v3").then(
36
36
  (mod) => mod.zodToJsonSchema
37
37
  );
38
+ }
38
39
  return handler(schema, options);
39
40
  };
40
41
 
@@ -44,17 +45,17 @@ const vendorToFn = {
44
45
  valibot: getToJsonSchemaFn$2,
45
46
  zod: getToJsonSchemaFn$1
46
47
  };
47
- const getToJsonSchemaFn = async (vendor) => {
48
- const venderConvertor = vendorToFn[vendor];
49
- if (!venderConvertor)
48
+ const getToJsonSchemaFn = (vendor) => {
49
+ const vendorConverter = vendorToFn[vendor];
50
+ if (!vendorConverter)
50
51
  throw new Error(
51
52
  errorMessageWrapper(`Unsupported schema vendor "${vendor}"`)
52
53
  );
53
- return venderConvertor();
54
+ return vendorConverter();
54
55
  };
55
56
 
56
- const toJsonSchema = (schema) => getToJsonSchemaFn(schema["~standard"].vendor).then(
57
- (toJsonSchema2) => toJsonSchema2(schema)
57
+ const toJsonSchema = (schema, options) => getToJsonSchemaFn(schema["~standard"].vendor).then(
58
+ (toJsonSchema2) => toJsonSchema2(schema, options)
58
59
  );
59
60
 
60
61
  export { toJsonSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@standard-community/standard-json",
3
- "version": "0.3.0-rc.0",
3
+ "version": "0.3.0-rc.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs",