@scalar/oas-utils 0.2.135 → 0.2.137

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,24 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.137
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [62c4ce3]
8
+ - @scalar/types@0.1.12
9
+ - @scalar/themes@0.10.4
10
+ - @scalar/object-utils@1.1.13
11
+ - @scalar/openapi-types@0.2.1
12
+
13
+ ## 0.2.136
14
+
15
+ ### Patch Changes
16
+
17
+ - eb4854d: fix: falsy values in auth config reactivity
18
+ - Updated dependencies [eb4854d]
19
+ - @scalar/types@0.1.11
20
+ - @scalar/themes@0.10.3
21
+
3
22
  ## 0.2.135
4
23
 
5
24
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export declare const environmentSchema: z.ZodObject<{
3
- uid: z.ZodBranded<z.ZodDefault<z.ZodOptional<z.ZodString>>, "environment">;
3
+ uid: z.ZodBranded<z.ZodString, "environment">;
4
4
  name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5
5
  color: z.ZodDefault<z.ZodOptional<z.ZodString>>;
6
6
  value: z.ZodDefault<z.ZodString>;
@@ -12,7 +12,7 @@ export declare const environmentSchema: z.ZodObject<{
12
12
  color: string;
13
13
  isDefault?: boolean | undefined;
14
14
  }, {
15
- uid?: string | undefined;
15
+ uid: string;
16
16
  name?: string | undefined;
17
17
  value?: string | undefined;
18
18
  color?: string | undefined;
@@ -1,10 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { nanoidSchema } from '@scalar/types/utils';
3
2
 
4
3
  const environmentSchema = z.object({
5
- uid: nanoidSchema.brand(),
4
+ uid: z.string().brand(),
6
5
  name: z.string().optional().default('Default Environment'),
7
- color: z.string().optional().default('#0082D0'),
6
+ color: z.string().optional().default('#FFFFFF'),
8
7
  value: z.string().default(''),
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AEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,GAAG,aAAa,EAC5B,EACE,cAAc,EACd,aAAa,EACb,WAAW,EACX,OAAO,EAAE,iBAAiB,EAC1B,qBAA6B,EAC7B,IAAI,EACJ,UAAU,EACV,SAAiB,GAClB,GAAE,yBAA8B,GAChC,OAAO,CACN;IACE,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAA;IAC5B,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe,EAAE,cAAc,EAAE,CAAA;CAClC,GACD;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,SAAS,CAAA;CAAE,CACnE,CAmYA;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE,GAAG,SAAS,EAC/C,EAAE,aAAa,EAAE,GAAE,IAAI,CAAC,yBAAyB,EAAE,eAAe,CAAM,GACvE,MAAM,EAAE,CA0CV"}
@@ -107,7 +107,7 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
107
107
  // ---------------------------------------------------------------------------
108
108
  // SECURITY HANDLING
109
109
  const security = schema.components?.securitySchemes ?? schema?.securityDefinitions ?? {};
110
- // Toss out a deprecated warning for the old authentication state
110
+ // @ts-expect-error - Toss out a deprecated warning for the old authentication state
111
111
  if (authentication?.oAuth2 || authentication?.apiKey || authentication?.http) {
112
112
  console.warn(`DEPRECATION WARNING: It looks like you're using legacy authentication config. Please migrate to use the updated config. See https://github.com/scalar/scalar/blob/main/documentation/configuration.md#authentication-partial This will be removed in a future version.`);
113
113
  }
@@ -124,30 +124,40 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
124
124
  if (payload.type === 'oauth2' && payload.flows) {
125
125
  const flowKeys = Object.keys(payload.flows);
126
126
  flowKeys.forEach((key) => {
127
- if (!payload.flows?.[key]) {
127
+ if (!payload.flows?.[key] || _scheme.type !== 'oauth2') {
128
128
  return;
129
129
  }
130
+ const authFlow = authentication?.securitySchemes?.[nameKey]?.flows?.[key] ?? {};
130
131
  // This part handles setting of flows via the new auth config, the rest can be removed in a future version
131
132
  payload.flows[key] = {
132
133
  ...(_scheme.flows?.[key] ?? {}),
133
- ...(authentication?.securitySchemes?.[nameKey]?.flows?.[key] ?? {}),
134
+ ...authFlow,
134
135
  };
135
136
  const flow = payload.flows[key];
136
137
  // Set the type
137
138
  flow.type = key;
138
139
  // Prefill values from authorization config - old deprecated config
140
+ // @ts-expect-error - deprecated
139
141
  if (authentication?.oAuth2) {
142
+ // @ts-expect-error - deprecated
140
143
  if (authentication.oAuth2.accessToken) {
144
+ // @ts-expect-error - deprecated
141
145
  flow.token = authentication.oAuth2.accessToken;
142
146
  }
147
+ // @ts-expect-error - deprecated
143
148
  if (authentication.oAuth2.clientId) {
149
+ // @ts-expect-error - deprecated
144
150
  flow['x-scalar-client-id'] = authentication.oAuth2.clientId;
145
151
  }
152
+ // @ts-expect-error - deprecated
146
153
  if (authentication.oAuth2.scopes) {
154
+ // @ts-expect-error - deprecated
147
155
  flow.selectedScopes = authentication.oAuth2.scopes;
148
156
  }
149
157
  if (flow.type === 'password') {
158
+ // @ts-expect-error - deprecated
150
159
  flow.username = authentication.oAuth2.username;
160
+ // @ts-expect-error - deprecated
151
161
  flow.password = authentication.oAuth2.password;
152
162
  }
153
163
  }
@@ -164,17 +174,24 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
164
174
  // Otherwise we just prefill - old deprecated config
165
175
  else if (authentication) {
166
176
  // ApiKey
177
+ // @ts-expect-error - deprecated
167
178
  if (payload.type === 'apiKey' && authentication.apiKey?.token) {
179
+ // @ts-expect-error - deprecated
168
180
  payload.value = authentication.apiKey.token;
169
181
  }
170
182
  // HTTP
171
183
  else if (payload.type === 'http') {
184
+ // @ts-expect-error - deprecated
172
185
  if (payload.scheme === 'basic' && authentication.http?.basic) {
186
+ // @ts-expect-error - deprecated
173
187
  payload.username = authentication.http.basic.username ?? '';
188
+ // @ts-expect-error - deprecated
174
189
  payload.password = authentication.http.basic.password ?? '';
175
190
  }
176
191
  // Bearer
192
+ // @ts-expect-error - deprecated
177
193
  else if (payload.scheme === 'bearer' && authentication.http?.bearer?.token) {
194
+ // @ts-expect-error - deprecated
178
195
  payload.token = authentication.http.bearer.token ?? '';
179
196
  }
180
197
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.135",
19
+ "version": "0.2.137",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -87,10 +87,10 @@
87
87
  "type-fest": "^4.20.0",
88
88
  "yaml": "^2.4.5",
89
89
  "zod": "^3.23.8",
90
- "@scalar/object-utils": "1.1.13",
91
90
  "@scalar/openapi-types": "0.2.1",
92
- "@scalar/themes": "0.10.2",
93
- "@scalar/types": "0.1.10"
91
+ "@scalar/types": "0.1.12",
92
+ "@scalar/themes": "0.10.4",
93
+ "@scalar/object-utils": "1.1.13"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@types/node": "^20.17.10",
@@ -98,8 +98,8 @@
98
98
  "vite": "^5.4.10",
99
99
  "vitest": "^1.6.0",
100
100
  "zod-to-ts": "github:amritk/zod-to-ts#build",
101
+ "@scalar/build-tooling": "0.1.18",
101
102
  "@scalar/openapi-parser": "0.10.16",
102
- "@scalar/build-tooling": "0.1.17",
103
103
  "@scalar/openapi-types": "0.2.1"
104
104
  },
105
105
  "scripts": {