@scalar/oas-utils 0.10.13 → 0.10.15
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/CHANGELOG.md +4 -0
- package/dist/entities/spec/requests.d.ts +5 -3
- package/dist/entities/spec/requests.d.ts.map +1 -1
- package/dist/entities/spec/requests.js +17 -3
- package/dist/entities/spec/spec-objects.d.ts.map +1 -1
- package/dist/entities/spec/spec-objects.js +12 -2
- package/dist/helpers/operation-stability.d.ts +2 -2
- package/dist/helpers/operation-stability.d.ts.map +1 -1
- package/dist/helpers/operation-stability.js +6 -8
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { type PostResponseSchema, XPostResponseSchema } from '@scalar/openapi-types/schemas/extensions';
|
|
2
1
|
import { XScalarStability } from '@scalar/types/legacy';
|
|
2
|
+
import type { XPostResponse } from '@scalar/workspace-store/schemas/extensions/operation/x-post-response';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { type RequestExample } from './request-examples.js';
|
|
5
|
+
/** The code to execute */
|
|
6
|
+
declare const postResponseSchema: z.ZodString;
|
|
5
7
|
declare const requestMethods: readonly ["delete", "get", "head", "options", "patch", "post", "put", "trace"];
|
|
6
8
|
export type RequestMethod = (typeof requestMethods)[number];
|
|
7
9
|
/** A single set of populated values for a sent request */
|
|
@@ -35,8 +37,8 @@ export type RequestEvent = {
|
|
|
35
37
|
response: ResponseInstance;
|
|
36
38
|
timestamp: number;
|
|
37
39
|
};
|
|
38
|
-
export type PostResponseScript = z.infer<typeof
|
|
39
|
-
export type PostResponseScripts =
|
|
40
|
+
export type PostResponseScript = z.infer<typeof postResponseSchema>;
|
|
41
|
+
export type PostResponseScripts = XPostResponse['x-post-response'];
|
|
40
42
|
/** Unified request schema for client usage */
|
|
41
43
|
export declare const requestSchema: z.ZodObject<{
|
|
42
44
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/requests.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/requests.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAGvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sEAAsE,CAAA;AAEzG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,oBAAoB,CAAA;AAe9E,0BAA0B;AAC1B,QAAA,MAAM,kBAAkB,aAAa,CAAA;AAMrC,QAAA,MAAM,cAAc,gFAAiF,CAAA;AAErG,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3D,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG;IACzD,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,wCAAwC;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,0BAA0B;IAC1B,MAAM,EAAE,aAAa,CAAA;IACrB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,CACE;IACE,wBAAwB;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,qDAAqD;IACrD,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAA;CAChD,CACJ,CAAA;AAEH,iEAAiE;AACjE,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,cAAc,CAAA;IACvB,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAoGD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AACnE,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAA;AAElE,8CAA8C;AAC9C,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKG,CAAA;AAE7B,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { XCodeSamplesSchema, XPostResponseSchema, } from '@scalar/openapi-types/schemas/extensions';
|
|
2
1
|
import { oasSecurityRequirementSchema } from '@scalar/types/entities';
|
|
3
2
|
import { XScalarStability } from '@scalar/types/legacy';
|
|
4
3
|
import { nanoidSchema } from '@scalar/types/utils';
|
|
@@ -7,6 +6,21 @@ import { selectedSecuritySchemeUidSchema } from '../../entities/shared/utility.j
|
|
|
7
6
|
import { oasParameterSchema } from './parameters.js';
|
|
8
7
|
import { xScalarExampleSchema } from './request-examples.js';
|
|
9
8
|
import { oasExternalDocumentationSchema } from './spec-objects.js';
|
|
9
|
+
const xCodeSampleSchema = z.object({
|
|
10
|
+
lang: z.string().optional().catch(undefined),
|
|
11
|
+
label: z.string().optional().catch(undefined),
|
|
12
|
+
source: z.string(),
|
|
13
|
+
});
|
|
14
|
+
const xCodeSamplesSchema = z.object({
|
|
15
|
+
'x-codeSamples': xCodeSampleSchema.array().optional().catch(undefined),
|
|
16
|
+
'x-code-samples': xCodeSampleSchema.array().optional().catch(undefined),
|
|
17
|
+
'x-custom-examples': xCodeSampleSchema.array().optional().catch(undefined),
|
|
18
|
+
});
|
|
19
|
+
/** The code to execute */
|
|
20
|
+
const postResponseSchema = z.string();
|
|
21
|
+
const xPostResponseSchema = z.object({
|
|
22
|
+
'x-post-response': postResponseSchema.optional(),
|
|
23
|
+
});
|
|
10
24
|
const requestMethods = ['delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace'];
|
|
11
25
|
const requestBodySchema = z.any();
|
|
12
26
|
/** Open API Compliant Request Validator */
|
|
@@ -103,7 +117,7 @@ const extendedRequestSchema = z.object({
|
|
|
103
117
|
/** Unified request schema for client usage */
|
|
104
118
|
export const requestSchema = oasRequestSchema
|
|
105
119
|
.omit({ 'x-scalar-examples': true })
|
|
106
|
-
.merge(
|
|
120
|
+
.merge(xCodeSamplesSchema)
|
|
107
121
|
.merge(ScalarStabilitySchema)
|
|
108
122
|
.merge(extendedRequestSchema)
|
|
109
|
-
.merge(
|
|
123
|
+
.merge(xPostResponseSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-objects.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/spec-objects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spec-objects.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/spec-objects.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAcvB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;GAWI,CAAA;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;GASI,CAAA;AAEjC;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqBO,CAAA;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;GAOV,CAAA;AAqCjC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;iBAMpB,CAAA;AAEF,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAC3C,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { omitUndefinedValues } from '@scalar/helpers/object/omit-undefined-values';
|
|
2
|
-
import { XScalarSdkInstallationSchema } from '@scalar/openapi-types/schemas/extensions';
|
|
3
2
|
import { nanoidSchema } from '@scalar/types/utils';
|
|
4
3
|
import { z } from 'zod';
|
|
4
|
+
const xScalarSdkInstallationSchema = z.object({
|
|
5
|
+
'x-scalar-sdk-installation': z
|
|
6
|
+
.object({
|
|
7
|
+
lang: z.string(),
|
|
8
|
+
source: z.string().optional().catch(undefined),
|
|
9
|
+
description: z.string().optional().catch(undefined),
|
|
10
|
+
})
|
|
11
|
+
.array()
|
|
12
|
+
.optional()
|
|
13
|
+
.catch(undefined),
|
|
14
|
+
});
|
|
5
15
|
/**
|
|
6
16
|
* License Object
|
|
7
17
|
*
|
|
@@ -66,7 +76,7 @@ export const oasInfoSchema = z
|
|
|
66
76
|
*/
|
|
67
77
|
version: z.string().catch('1.0'),
|
|
68
78
|
})
|
|
69
|
-
.merge(
|
|
79
|
+
.merge(xScalarSdkInstallationSchema)
|
|
70
80
|
.transform(omitUndefinedValues);
|
|
71
81
|
/**
|
|
72
82
|
* External Documentation Object
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { XScalarStability } from '@scalar/types/legacy';
|
|
2
2
|
type OperationStability = {
|
|
3
3
|
deprecated?: boolean;
|
|
4
4
|
'x-scalar-stability'?: unknown;
|
|
@@ -10,7 +10,7 @@ export declare const isOperationDeprecated: (operation: OperationStability) => b
|
|
|
10
10
|
/**
|
|
11
11
|
* Get operation stability from deprecated or x-scalar-stability
|
|
12
12
|
*/
|
|
13
|
-
export declare const getOperationStability: (operation: OperationStability) =>
|
|
13
|
+
export declare const getOperationStability: (operation: OperationStability) => XScalarStability | undefined;
|
|
14
14
|
/**
|
|
15
15
|
* Get Operation stability tailwind color class
|
|
16
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-stability.d.ts","sourceRoot":"","sources":["../../src/helpers/operation-stability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"operation-stability.d.ts","sourceRoot":"","sources":["../../src/helpers/operation-stability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD,KAAK,kBAAkB,GAAG;IACxB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,WAAW,kBAAkB,KAAG,OACmB,CAAA;AAEzF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,WAAW,kBAAkB,KAAG,gBAAgB,GAAG,SAC+B,CAAA;AAExH;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,WAAW,kBAAkB,KAAG,MAW1E,CAAA"}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { XScalarStability } from '@scalar/types/legacy';
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if an operation is considered deprecated.
|
|
4
4
|
*/
|
|
5
|
-
export const isOperationDeprecated = (operation) => operation.deprecated || operation['x-scalar-stability'] ===
|
|
5
|
+
export const isOperationDeprecated = (operation) => operation.deprecated || operation['x-scalar-stability'] === XScalarStability.Deprecated;
|
|
6
6
|
/**
|
|
7
7
|
* Get operation stability from deprecated or x-scalar-stability
|
|
8
8
|
*/
|
|
9
|
-
export const getOperationStability = (operation) => operation.deprecated
|
|
10
|
-
? XScalarStabilityValues.Deprecated
|
|
11
|
-
: operation['x-scalar-stability'];
|
|
9
|
+
export const getOperationStability = (operation) => operation.deprecated ? XScalarStability.Deprecated : operation['x-scalar-stability'];
|
|
12
10
|
/**
|
|
13
11
|
* Get Operation stability tailwind color class
|
|
14
12
|
*/
|
|
15
13
|
export const getOperationStabilityColor = (operation) => {
|
|
16
14
|
switch (getOperationStability(operation)) {
|
|
17
|
-
case
|
|
15
|
+
case XScalarStability.Deprecated:
|
|
18
16
|
return 'text-red';
|
|
19
|
-
case
|
|
17
|
+
case XScalarStability.Experimental:
|
|
20
18
|
return 'text-orange';
|
|
21
|
-
case
|
|
19
|
+
case XScalarStability.Stable:
|
|
22
20
|
return 'text-green';
|
|
23
21
|
default:
|
|
24
22
|
return '';
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.10.
|
|
19
|
+
"version": "0.10.15",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=22"
|
|
22
22
|
},
|
|
@@ -88,17 +88,17 @@
|
|
|
88
88
|
"flatted": "^3.3.3",
|
|
89
89
|
"github-slugger": "2.0.0",
|
|
90
90
|
"type-fest": "^5.3.1",
|
|
91
|
-
"vue": "^3.5.
|
|
91
|
+
"vue": "^3.5.30",
|
|
92
92
|
"yaml": "^2.8.0",
|
|
93
93
|
"zod": "^4.3.5",
|
|
94
|
-
"@scalar/helpers": "0.4.
|
|
95
|
-
"@scalar/json-magic": "0.12.
|
|
96
|
-
"@scalar/object-utils": "1.3.
|
|
97
|
-
"@scalar/openapi-parser": "0.25.
|
|
98
|
-
"@scalar/
|
|
99
|
-
"@scalar/
|
|
100
|
-
"@scalar/types": "0.7.
|
|
101
|
-
"@scalar/workspace-store": "0.
|
|
94
|
+
"@scalar/helpers": "0.4.3",
|
|
95
|
+
"@scalar/json-magic": "0.12.5",
|
|
96
|
+
"@scalar/object-utils": "1.3.4",
|
|
97
|
+
"@scalar/openapi-parser": "0.25.8",
|
|
98
|
+
"@scalar/themes": "0.15.2",
|
|
99
|
+
"@scalar/types": "0.7.6",
|
|
100
|
+
"@scalar/openapi-types": "0.7.0",
|
|
101
|
+
"@scalar/workspace-store": "0.43.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@types/node": "^24.1.0",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"vite": "8.0.0",
|
|
107
107
|
"vitest": "4.1.0",
|
|
108
108
|
"zod-to-ts": "github:amritk/zod-to-ts#build",
|
|
109
|
-
"@scalar/openapi-types": "0.
|
|
109
|
+
"@scalar/openapi-types": "0.7.0"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
112
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|