@standard-community/standard-openapi 0.2.0 → 0.2.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.
@@ -0,0 +1,44 @@
1
+ const errorMessageWrapper = (message) => `standard-openapi: ${message}`;
2
+ const openapiVendorMap = /* @__PURE__ */ new Map();
3
+
4
+ const getToOpenAPISchemaFn = async (vendor) => {
5
+ const cached = openapiVendorMap.get(vendor);
6
+ if (cached) {
7
+ return cached;
8
+ }
9
+ let vendorFnPromise;
10
+ switch (vendor) {
11
+ case "valibot":
12
+ vendorFnPromise = (await import('./valibot-pYvQeYpK.js')).default();
13
+ break;
14
+ case "zod":
15
+ vendorFnPromise = (await import('./zod-FmKJCmIM.js')).default();
16
+ break;
17
+ case "arktype":
18
+ case "effect":
19
+ vendorFnPromise = (await import('./default-B3j_H5mf.js')).default();
20
+ break;
21
+ default:
22
+ throw new Error(
23
+ errorMessageWrapper(`Unsupported schema vendor "${vendor}".`)
24
+ );
25
+ }
26
+ const vendorFn = await vendorFnPromise;
27
+ openapiVendorMap.set(vendor, vendorFn);
28
+ return vendorFn;
29
+ };
30
+
31
+ const toOpenAPISchema = async (schema, context = {}) => {
32
+ const fn = await getToOpenAPISchemaFn(schema["~standard"].vendor);
33
+ const { components = {}, options } = context;
34
+ const _schema = await fn(schema, { components, options });
35
+ return {
36
+ schema: _schema,
37
+ components: Object.keys(components).length > 0 ? components : void 0
38
+ };
39
+ };
40
+ function loadVendor(vendor, fn) {
41
+ openapiVendorMap.set(vendor, fn);
42
+ }
43
+
44
+ export { errorMessageWrapper as e, loadVendor as l, toOpenAPISchema as t };
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var quansync = require('quansync');
4
-
5
3
  const errorMessageWrapper = (message) => `standard-openapi: ${message}`;
6
4
  const openapiVendorMap = /* @__PURE__ */ new Map();
7
5
 
@@ -16,7 +14,7 @@ const getToOpenAPISchemaFn = async (vendor) => {
16
14
  vendorFnPromise = (await Promise.resolve().then(function () { return require('./valibot-CmK54MCp.cjs'); })).default();
17
15
  break;
18
16
  case "zod":
19
- vendorFnPromise = (await Promise.resolve().then(function () { return require('./zod-BX8Nhg6z.cjs'); })).default();
17
+ vendorFnPromise = (await Promise.resolve().then(function () { return require('./zod-Dcc_GKUA.cjs'); })).default();
20
18
  break;
21
19
  case "arktype":
22
20
  case "effect":
@@ -32,33 +30,15 @@ const getToOpenAPISchemaFn = async (vendor) => {
32
30
  return vendorFn;
33
31
  };
34
32
 
35
- const toOpenAPISchema = quansync.quansync({
36
- sync: (schema, context = {}) => {
37
- const fn = openapiVendorMap.get(schema["~standard"].vendor);
38
- if (!fn) {
39
- throw new Error(
40
- errorMessageWrapper(
41
- `Unsupported schema vendor "${schema["~standard"].vendor}".`
42
- )
43
- );
44
- }
45
- const { components = {}, options } = context;
46
- const _schema = fn(schema, { components, options });
47
- return {
48
- schema: _schema,
49
- components: Object.keys(components).length > 0 ? components : void 0
50
- };
51
- },
52
- async: async (schema, context = {}) => {
53
- const fn = await getToOpenAPISchemaFn(schema["~standard"].vendor);
54
- const { components = {}, options } = context;
55
- const _schema = await fn(schema, { components, options });
56
- return {
57
- schema: _schema,
58
- components: Object.keys(components).length > 0 ? components : void 0
59
- };
60
- }
61
- });
33
+ const toOpenAPISchema = async (schema, context = {}) => {
34
+ const fn = await getToOpenAPISchemaFn(schema["~standard"].vendor);
35
+ const { components = {}, options } = context;
36
+ const _schema = await fn(schema, { components, options });
37
+ return {
38
+ schema: _schema,
39
+ components: Object.keys(components).length > 0 ? components : void 0
40
+ };
41
+ };
62
42
  function loadVendor(vendor, fn) {
63
43
  openapiVendorMap.set(vendor, fn);
64
44
  }
package/dist/index.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- require('quansync');
4
- var index = require('./index-lYeS5F9z.cjs');
3
+ var index = require('./index-DbUgUmtU.cjs');
5
4
 
6
5
 
7
6
 
package/dist/index.d.cts CHANGED
@@ -1,4 +1,3 @@
1
- import * as quansync from 'quansync';
2
1
  import * as openapi_types from 'openapi-types';
3
2
  import { OpenAPIV3_1 } from 'openapi-types';
4
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -12,10 +11,10 @@ type ToOpenAPISchemaFn = (schema: StandardSchemaV1, context: ToOpenAPISchemaCont
12
11
  /**
13
12
  * Converts a Standard Schema to a OpenAPI schema.
14
13
  */
15
- declare const toOpenAPISchema: quansync.QuansyncFn<{
16
- schema: openapi_types.OpenAPIV3_1.SchemaObject | Promise<openapi_types.OpenAPIV3_1.SchemaObject>;
14
+ declare const toOpenAPISchema: (schema: StandardSchemaV1, context?: Partial<ToOpenAPISchemaContext>) => Promise<{
15
+ schema: openapi_types.OpenAPIV3_1.SchemaObject;
17
16
  components: openapi_types.OpenAPIV3_1.ComponentsObject | undefined;
18
- }, [schema: StandardSchemaV1<unknown, unknown>, context?: Partial<ToOpenAPISchemaContext> | undefined]>;
17
+ }>;
19
18
  declare function loadVendor(vendor: string, fn: ToOpenAPISchemaFn): void;
20
19
 
21
20
  export { loadVendor, toOpenAPISchema };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as quansync from 'quansync';
2
1
  import * as openapi_types from 'openapi-types';
3
2
  import { OpenAPIV3_1 } from 'openapi-types';
4
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
@@ -12,10 +11,10 @@ type ToOpenAPISchemaFn = (schema: StandardSchemaV1, context: ToOpenAPISchemaCont
12
11
  /**
13
12
  * Converts a Standard Schema to a OpenAPI schema.
14
13
  */
15
- declare const toOpenAPISchema: quansync.QuansyncFn<{
16
- schema: openapi_types.OpenAPIV3_1.SchemaObject | Promise<openapi_types.OpenAPIV3_1.SchemaObject>;
14
+ declare const toOpenAPISchema: (schema: StandardSchemaV1, context?: Partial<ToOpenAPISchemaContext>) => Promise<{
15
+ schema: openapi_types.OpenAPIV3_1.SchemaObject;
17
16
  components: openapi_types.OpenAPIV3_1.ComponentsObject | undefined;
18
- }, [schema: StandardSchemaV1<unknown, unknown>, context?: Partial<ToOpenAPISchemaContext> | undefined]>;
17
+ }>;
19
18
  declare function loadVendor(vendor: string, fn: ToOpenAPISchemaFn): void;
20
19
 
21
20
  export { loadVendor, toOpenAPISchema };
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- import 'quansync';
2
- export { l as loadVendor, t as toOpenAPISchema } from './index-B2FrwPUq.js';
1
+ export { l as loadVendor, t as toOpenAPISchema } from './index-2CxeAJPp.js';
@@ -2,8 +2,7 @@
2
2
 
3
3
  var standardJson = require('@standard-community/standard-json');
4
4
  var convert = require('./convert--bmLap0k.cjs');
5
- var index = require('./index-lYeS5F9z.cjs');
6
- require('quansync');
5
+ var index = require('./index-DbUgUmtU.cjs');
7
6
 
8
7
  async function getToOpenAPISchemaFn() {
9
8
  return async (schema, context) => {
@@ -1,7 +1,6 @@
1
1
  import { toJsonSchema } from '@standard-community/standard-json';
2
2
  import { c as convertToOpenAPISchema } from './convert-BrW5dcj8.js';
3
- import { e as errorMessageWrapper } from './index-B2FrwPUq.js';
4
- import 'quansync';
3
+ import { e as errorMessageWrapper } from './index-2CxeAJPp.js';
5
4
 
6
5
  async function getToOpenAPISchemaFn() {
7
6
  return async (schema, context) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@standard-community/standard-openapi",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs",
@@ -43,7 +43,6 @@
43
43
  "@standard-schema/spec": "^1.0.0",
44
44
  "arktype": "^2.1.20",
45
45
  "openapi-types": "^12.1.3",
46
- "quansync": "^0.2.11",
47
46
  "valibot": "^1.1.0",
48
47
  "zod": "^3.25.0 || ^4.0.0",
49
48
  "zod-openapi": "^4"
@@ -1,64 +0,0 @@
1
- import { quansync } from 'quansync';
2
-
3
- const errorMessageWrapper = (message) => `standard-openapi: ${message}`;
4
- const openapiVendorMap = /* @__PURE__ */ new Map();
5
-
6
- const getToOpenAPISchemaFn = async (vendor) => {
7
- const cached = openapiVendorMap.get(vendor);
8
- if (cached) {
9
- return cached;
10
- }
11
- let vendorFnPromise;
12
- switch (vendor) {
13
- case "valibot":
14
- vendorFnPromise = (await import('./valibot-pYvQeYpK.js')).default();
15
- break;
16
- case "zod":
17
- vendorFnPromise = (await import('./zod-BzrcyUsw.js')).default();
18
- break;
19
- case "arktype":
20
- case "effect":
21
- vendorFnPromise = (await import('./default-B3j_H5mf.js')).default();
22
- break;
23
- default:
24
- throw new Error(
25
- errorMessageWrapper(`Unsupported schema vendor "${vendor}".`)
26
- );
27
- }
28
- const vendorFn = await vendorFnPromise;
29
- openapiVendorMap.set(vendor, vendorFn);
30
- return vendorFn;
31
- };
32
-
33
- const toOpenAPISchema = quansync({
34
- sync: (schema, context = {}) => {
35
- const fn = openapiVendorMap.get(schema["~standard"].vendor);
36
- if (!fn) {
37
- throw new Error(
38
- errorMessageWrapper(
39
- `Unsupported schema vendor "${schema["~standard"].vendor}".`
40
- )
41
- );
42
- }
43
- const { components = {}, options } = context;
44
- const _schema = fn(schema, { components, options });
45
- return {
46
- schema: _schema,
47
- components: Object.keys(components).length > 0 ? components : void 0
48
- };
49
- },
50
- async: async (schema, context = {}) => {
51
- const fn = await getToOpenAPISchemaFn(schema["~standard"].vendor);
52
- const { components = {}, options } = context;
53
- const _schema = await fn(schema, { components, options });
54
- return {
55
- schema: _schema,
56
- components: Object.keys(components).length > 0 ? components : void 0
57
- };
58
- }
59
- });
60
- function loadVendor(vendor, fn) {
61
- openapiVendorMap.set(vendor, fn);
62
- }
63
-
64
- export { errorMessageWrapper as e, loadVendor as l, toOpenAPISchema as t };