@scalar/oas-utils 0.2.111 → 0.2.114

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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.114
4
+
5
+ ### Patch Changes
6
+
7
+ - fb22645: fix: auth selected security scheme undefined
8
+
9
+ ## 0.2.113
10
+
11
+ ### Patch Changes
12
+
13
+ - a31973c: feat: add ScalarStabilitySchema
14
+ - Updated dependencies [bab7990]
15
+ - Updated dependencies [2c621d4]
16
+ - @scalar/types@0.0.39
17
+ - @scalar/themes@0.9.74
18
+
19
+ ## 0.2.112
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [7f1a40e]
24
+ - @scalar/types@0.0.38
25
+ - @scalar/themes@0.9.73
26
+
3
27
  ## 0.2.111
4
28
 
5
29
  ### Patch Changes
@@ -5,7 +5,7 @@
5
5
  import { type RequestPayload, type Request as RequestType } from './requests.js';
6
6
  export type Operation = RequestType;
7
7
  export type OperationPayload = RequestPayload;
8
- export declare const operationSchema: import("zod").ZodObject<import("zod").objectUtil.extendShape<Omit<{
8
+ export declare const operationSchema: import("zod").ZodObject<import("zod").objectUtil.extendShape<import("zod").objectUtil.extendShape<Omit<{
9
9
  tags: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
10
10
  summary: import("zod").ZodOptional<import("zod").ZodString>;
11
11
  description: import("zod").ZodOptional<import("zod").ZodString>;
@@ -161,6 +161,8 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
161
161
  'x-internal': import("zod").ZodOptional<import("zod").ZodBoolean>;
162
162
  'x-scalar-ignore': import("zod").ZodOptional<import("zod").ZodBoolean>;
163
163
  }, "x-scalar-examples">, {
164
+ 'x-scalar-stability': import("zod").ZodCatch<import("zod").ZodOptional<import("zod").ZodEnum<[import("@scalar/types").XScalarStability.Deprecated, import("@scalar/types").XScalarStability.Experimental, import("@scalar/types").XScalarStability.Stable]>>>;
165
+ }>, {
164
166
  type: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodLiteral<"request">>>;
165
167
  uid: import("zod").ZodBranded<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>, "operation">;
166
168
  path: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>;
@@ -207,6 +209,7 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
207
209
  }[] | undefined;
208
210
  requestBody?: any;
209
211
  responses?: Record<string, any> | undefined;
212
+ 'x-scalar-stability'?: import("@scalar/types").XScalarStability | undefined;
210
213
  }, {
211
214
  path?: string | undefined;
212
215
  type?: "request" | undefined;
@@ -244,6 +247,7 @@ export declare const operationSchema: import("zod").ZodObject<import("zod").obje
244
247
  }[] | undefined;
245
248
  requestBody?: any;
246
249
  responses?: Record<string, any> | undefined;
250
+ 'x-scalar-stability'?: unknown;
247
251
  method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
248
252
  }>;
249
253
  //# sourceMappingURL=operation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,YAAY,CAAA;AAE5F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAgB,CAAA"}
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/operation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,IAAI,WAAW,EAAiB,MAAM,YAAY,CAAA;AAE5F,MAAM,MAAM,SAAS,GAAG,WAAW,CAAA;AACnC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAA;AAC7C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAgB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { XScalarStability } from '@scalar/types';
2
3
  import { type RequestExample } from './request-examples.js';
3
4
  export declare const requestMethods: readonly ["connect", "delete", "get", "head", "options", "patch", "post", "put", "trace"];
4
5
  export type RequestMethod = (typeof requestMethods)[number];
@@ -314,7 +315,7 @@ export declare const oasRequestSchema: z.ZodObject<{
314
315
  }> | undefined;
315
316
  }>;
316
317
  /** Unified request schema for client usage */
317
- export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
318
+ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<Omit<{
318
319
  /**
319
320
  * A list of tags for API documentation control. Tags can be used for logical
320
321
  * grouping of operations by resources or any other qualifier.
@@ -505,6 +506,8 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
505
506
  'x-internal': z.ZodOptional<z.ZodBoolean>;
506
507
  'x-scalar-ignore': z.ZodOptional<z.ZodBoolean>;
507
508
  }, "x-scalar-examples">, {
509
+ 'x-scalar-stability': z.ZodCatch<z.ZodOptional<z.ZodEnum<[XScalarStability.Deprecated, XScalarStability.Experimental, XScalarStability.Stable]>>>;
510
+ }>, {
508
511
  type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"request">>>;
509
512
  uid: z.ZodBranded<z.ZodDefault<z.ZodOptional<z.ZodString>>, "operation">;
510
513
  /** Path Key */
@@ -557,6 +560,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
557
560
  }[] | undefined;
558
561
  requestBody?: any;
559
562
  responses?: Record<string, any> | undefined;
563
+ 'x-scalar-stability'?: XScalarStability | undefined;
560
564
  }, {
561
565
  path?: string | undefined;
562
566
  type?: "request" | undefined;
@@ -594,6 +598,7 @@ export declare const requestSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
594
598
  }[] | undefined;
595
599
  requestBody?: any;
596
600
  responses?: Record<string, any> | undefined;
601
+ 'x-scalar-stability'?: unknown;
597
602
  method?: "options" | "connect" | "delete" | "get" | "head" | "patch" | "post" | "put" | "trace" | undefined;
598
603
  }>;
599
604
  export type Request = z.infer<typeof requestSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/requests.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvC,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,oBAAoB,CAAA;AAI9E,eAAO,MAAM,cAAc,2FAA4F,CAAA;AAEvH,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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEvB,sBAAsB;;;;;;;;IA8BtB,eAAe;;IAEf,qBAAqB;;IAErB,kDAAkD;;IAElD,oCAAoC;;IAEpC,uDAAuD;;IAEvD,+DAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQlC,CAAA;AAE/B,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,5 +1,6 @@
1
1
  import { nanoidSchema, selectedSecuritySchemeUidSchema } from '../shared/utility.js';
2
2
  import { z } from 'zod';
3
+ import { XScalarStability } from '@scalar/types';
3
4
  import { oasParameterSchema } from './parameters.js';
4
5
  import { xScalarExampleSchema } from './request-examples.js';
5
6
  import { oasSecurityRequirementSchema } from './security.js';
@@ -58,6 +59,20 @@ const oasRequestSchema = z.object({
58
59
  'x-internal': z.boolean().optional(),
59
60
  'x-scalar-ignore': z.boolean().optional(),
60
61
  });
62
+ /**
63
+ * An OpenAPI extension to indicate the stability of the operation
64
+ *
65
+ * @example
66
+ * ```yaml
67
+ * x-scalar-stability: deprecated
68
+ * ```
69
+ */
70
+ const ScalarStabilitySchema = z.object({
71
+ 'x-scalar-stability': z
72
+ .enum([XScalarStability.Deprecated, XScalarStability.Experimental, XScalarStability.Stable])
73
+ .optional()
74
+ .catch(undefined),
75
+ });
61
76
  /**
62
77
  * Extended properties added to the spec definition for client usage
63
78
  *
@@ -82,6 +97,9 @@ const extendedRequestSchema = z.object({
82
97
  selectedSecuritySchemeUids: selectedSecuritySchemeUidSchema,
83
98
  });
84
99
  /** Unified request schema for client usage */
85
- const requestSchema = oasRequestSchema.omit({ 'x-scalar-examples': true }).merge(extendedRequestSchema);
100
+ const requestSchema = oasRequestSchema
101
+ .omit({ 'x-scalar-examples': true })
102
+ .merge(ScalarStabilitySchema)
103
+ .merge(extendedRequestSchema);
86
104
 
87
105
  export { oasRequestSchema, requestMethods, requestSchema };
@@ -3,8 +3,8 @@ import { isHttpMethod } from '../helpers/httpMethods.js';
3
3
  import { schemaModel } from '../helpers/schema-model.js';
4
4
  import { keysOf } from '@scalar/object-utils/arrays';
5
5
  import { load, upgrade, dereference } from '@scalar/openapi-parser';
6
- import { serverSchema } from '../entities/spec/server.js';
7
6
  import { isDefined } from '../helpers/is-defined.js';
7
+ import { serverSchema } from '../entities/spec/server.js';
8
8
  import { requestSchema } from '../entities/spec/requests.js';
9
9
  import { tagSchema } from '../entities/spec/spec-objects.js';
10
10
  import { createExampleFromRequest } from '../entities/spec/request-examples.js';
@@ -55,7 +55,9 @@ const getSelectedSecuritySchemeUids = (securityRequirements, preferredSecurityNa
55
55
  // Set the first security requirement if no preferred security schemes are set
56
56
  const names = securityRequirements[0] && !preferredSecurityNames.length ? [securityRequirements[0]] : preferredSecurityNames;
57
57
  // Map names to uids
58
- const uids = names.map((name) => Array.isArray(name) ? name.map((k) => securitySchemeMap[k]) : securitySchemeMap[name]);
58
+ const uids = names
59
+ .map((name) => (Array.isArray(name) ? name.map((k) => securitySchemeMap[k]) : securitySchemeMap[name]))
60
+ .filter(isDefined);
59
61
  return uids;
60
62
  };
61
63
  /**
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.111",
19
+ "version": "0.2.114",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -127,18 +127,18 @@
127
127
  "yaml": "^2.4.5",
128
128
  "zod": "^3.23.8",
129
129
  "@scalar/object-utils": "1.1.13",
130
- "@scalar/types": "0.0.37",
131
130
  "@scalar/openapi-types": "0.1.9",
132
- "@scalar/themes": "0.9.72"
131
+ "@scalar/themes": "0.9.74",
132
+ "@scalar/types": "0.0.39"
133
133
  },
134
134
  "devDependencies": {
135
135
  "type-fest": "^4.20.0",
136
136
  "vite": "^5.4.10",
137
137
  "vitest": "^1.6.0",
138
138
  "zod-to-ts": "github:amritk/zod-to-ts#build",
139
- "@scalar/build-tooling": "0.1.16",
140
- "@scalar/openapi-types": "0.1.9",
141
- "@scalar/openapi-parser": "0.10.9"
139
+ "@scalar/build-tooling": "0.1.17",
140
+ "@scalar/openapi-parser": "0.10.9",
141
+ "@scalar/openapi-types": "0.1.9"
142
142
  },
143
143
  "scripts": {
144
144
  "build": "scalar-build-rollup",