xsschema 0.3.0-beta.7 → 0.3.0-beta.9

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.
@@ -1,4 +1,4 @@
1
- import { t as tryImport } from './index-CISmcbXk.js';
1
+ import { t as tryImport } from './index-WDGOcgH7.js';
2
2
 
3
3
  const getToJsonSchemaFn = async () => {
4
4
  const { JSONSchema } = await tryImport(import('effect'), "effect");
@@ -1,3 +1,9 @@
1
+ const jsonSchema = (schema) => schema;
2
+ const strictJsonSchema = (schema) => ({
3
+ ...schema,
4
+ additionalProperties: false
5
+ });
6
+
1
7
  const missingDependenciesUrl = "https://xsai.js.org/docs/packages-top/xsschema#missing-dependencies";
2
8
  const tryImport = async (result, name) => {
3
9
  try {
@@ -11,13 +17,13 @@ const getToJsonSchemaFn = async (vendor) => {
11
17
  case "arktype":
12
18
  return import('./arktype-C-GObzDh.js').then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
13
19
  case "effect":
14
- return import('./effect-WSjEuzC9.js').then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
20
+ return import('./effect-DBSVVF8G.js').then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
15
21
  case "sury":
16
- return import('./sury-DmrZ3_Oj.js').then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
22
+ return import('./sury-GtnkadyM.js').then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
17
23
  case "valibot":
18
- return import('./valibot-CQk-M5rL.js').then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
24
+ return import('./valibot-CbgwcZn_.js').then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
19
25
  case "zod":
20
- return import('./zod-Db63SLXj.js').then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
26
+ return import('./zod-CD8IEU5z.js').then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
21
27
  default:
22
28
  throw new Error(`xsschema: Unsupported schema vendor "${vendor}". see https://xsai.js.org/docs/packages-top/xsschema#unsupported-schema-vendor`);
23
29
  }
@@ -47,4 +53,4 @@ const validate = async (schema, input) => {
47
53
  return result.value;
48
54
  };
49
55
 
50
- export { toJsonSchema as a, toJsonSchemaSync as b, initToJsonSchemaSyncVendor as i, missingDependenciesUrl as m, tryImport as t, validate as v };
56
+ export { toJsonSchema as a, toJsonSchemaSync as b, initToJsonSchemaSyncVendor as i, jsonSchema as j, missingDependenciesUrl as m, strictJsonSchema as s, tryImport as t, validate as v };
package/dist/index.d.ts CHANGED
@@ -222,6 +222,12 @@ interface JSONSchema7 {
222
222
  examples?: JSONSchema7Type | undefined;
223
223
  }
224
224
 
225
+ type Infer<T extends StandardSchemaV1> = StandardSchemaV1.InferOutput<T>;
226
+ type InferIn<T extends StandardSchemaV1> = StandardSchemaV1.InferInput<T>;
227
+
228
+ declare const jsonSchema: (schema: JSONSchema7) => JSONSchema7;
229
+ declare const strictJsonSchema: (schema: JSONSchema7) => JSONSchema7;
230
+
225
231
  /**
226
232
  * Converts a Standard Schema to a JSON schema.
227
233
  *
@@ -236,10 +242,7 @@ declare const initToJsonSchemaSyncVendor: (vendor: string) => Promise<Map<string
236
242
  /** @experimental */
237
243
  declare const toJsonSchemaSync: (schema: StandardSchemaV1) => JSONSchema7;
238
244
 
239
- type Infer<T extends StandardSchemaV1> = StandardSchemaV1.InferOutput<T>;
240
- type InferIn<T extends StandardSchemaV1> = StandardSchemaV1.InferInput<T>;
241
-
242
245
  /** @see {@link https://github.com/standard-schema/standard-schema#how-do-i-accept-standard-schemas-in-my-library} */
243
246
  declare const validate: <T extends StandardSchemaV1>(schema: T, input: StandardSchemaV1.InferInput<T>) => Promise<StandardSchemaV1.InferOutput<T>>;
244
247
 
245
- export { type Infer, type InferIn, type JSONSchema7 as JsonSchema, StandardSchemaV1 as Schema, initToJsonSchemaSyncVendor, toJsonSchema, toJsonSchemaSync, validate };
248
+ export { type Infer, type InferIn, type JSONSchema7 as JsonSchema, StandardSchemaV1 as Schema, initToJsonSchemaSyncVendor, jsonSchema, strictJsonSchema, toJsonSchema, toJsonSchemaSync, validate };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { i as initToJsonSchemaSyncVendor, a as toJsonSchema, b as toJsonSchemaSync, v as validate } from './index-CISmcbXk.js';
1
+ export { i as initToJsonSchemaSyncVendor, j as jsonSchema, s as strictJsonSchema, a as toJsonSchema, b as toJsonSchemaSync, v as validate } from './index-WDGOcgH7.js';
@@ -1,4 +1,4 @@
1
- import { t as tryImport } from './index-CISmcbXk.js';
1
+ import { t as tryImport } from './index-WDGOcgH7.js';
2
2
 
3
3
  const getToJsonSchemaFn = async () => {
4
4
  const { toJSONSchema } = await tryImport(import('sury'), "sury");
@@ -1,4 +1,4 @@
1
- import { t as tryImport } from './index-CISmcbXk.js';
1
+ import { t as tryImport } from './index-WDGOcgH7.js';
2
2
 
3
3
  const getToJsonSchemaFn = async () => {
4
4
  const { toJsonSchema } = await tryImport(import('@valibot/to-json-schema'), "@valibot/to-json-schema");
@@ -1,4 +1,4 @@
1
- import { m as missingDependenciesUrl } from './index-CISmcbXk.js';
1
+ import { m as missingDependenciesUrl } from './index-WDGOcgH7.js';
2
2
 
3
3
  const getToJsonSchemaFn = async () => {
4
4
  let zodV4toJSONSchema = (_schema) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xsschema",
3
3
  "type": "module",
4
- "version": "0.3.0-beta.7",
4
+ "version": "0.3.0-beta.9",
5
5
  "description": "extra-small, Standard Schema-based alternative to typeschema.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",