@scalar/oas-utils 0.2.91 → 0.2.93
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 +12 -0
- package/dist/helpers/httpMethods.d.ts +1 -1
- package/dist/helpers/httpMethods.d.ts.map +1 -1
- package/dist/helpers/httpMethods.js +1 -1
- package/dist/migrations/data-version.d.ts +3 -1
- package/dist/migrations/data-version.d.ts.map +1 -1
- package/dist/migrations/data-version.js +3 -1
- package/dist/migrations/migrator.d.ts +2 -2
- package/dist/migrations/migrator.d.ts.map +1 -1
- package/dist/migrations/migrator.js +4 -0
- package/dist/migrations/v-2.4.0/index.d.ts +3 -0
- package/dist/migrations/v-2.4.0/index.d.ts.map +1 -0
- package/dist/migrations/v-2.4.0/index.js +1 -0
- package/dist/migrations/v-2.4.0/migration.d.ts +5 -0
- package/dist/migrations/v-2.4.0/migration.d.ts.map +1 -0
- package/dist/migrations/v-2.4.0/migration.js +29 -0
- package/dist/migrations/v-2.4.0/types.generated.d.ts +38 -0
- package/dist/migrations/v-2.4.0/types.generated.d.ts.map +1 -0
- package/package.json +10 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @scalar/oas-utils
|
|
2
2
|
|
|
3
|
+
## 0.2.93
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ca2d98b: chore: adds drafts server migration
|
|
8
|
+
|
|
9
|
+
## 0.2.92
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 02b4201: fix(api-client): strict TS config (enable noUncheckedIndexedAccess)
|
|
14
|
+
|
|
3
15
|
## 0.2.91
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -24,6 +24,6 @@ export declare const getHttpMethodInfo: (methodName: string) => {
|
|
|
24
24
|
backgroundColor: string;
|
|
25
25
|
};
|
|
26
26
|
/** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */
|
|
27
|
-
export declare const isHttpMethod: (method
|
|
27
|
+
export declare const isHttpMethod: (method?: string | undefined) => method is RequestMethod;
|
|
28
28
|
export {};
|
|
29
29
|
//# sourceMappingURL=httpMethods.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpMethods.d.ts","sourceRoot":"","sources":["../../src/helpers/httpMethods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,0BAA0B,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE;KAC3B,CAAC,IAAI,aAAa,GAAG;QACpB,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;QACb,eAAe,EAAE,MAAM,CAAA;KACxB;CA+CO,CAAA;AAEV,yCAAyC;AACzC,QAAA,MAAM,YAAY,6CAA8C,CAAA;AAChE,KAAK,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,WACpB,aAAa,KACpB,MAAM,IAAI,UAAyD,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,iBAAiB,eAAgB,MAAM;WAhEzC,MAAM;WACN,MAAM;qBACI,MAAM;CAuE1B,CAAA;AAED,yFAAyF;AACzF,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"httpMethods.d.ts","sourceRoot":"","sources":["../../src/helpers/httpMethods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,0BAA0B,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE;KAC3B,CAAC,IAAI,aAAa,GAAG;QACpB,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;QACb,eAAe,EAAE,MAAM,CAAA;KACxB;CA+CO,CAAA;AAEV,yCAAyC;AACzC,QAAA,MAAM,YAAY,6CAA8C,CAAA;AAChE,KAAK,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,WACpB,aAAa,KACpB,MAAM,IAAI,UAAyD,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,iBAAiB,eAAgB,MAAM;WAhEzC,MAAM;WACN,MAAM;qBACI,MAAM;CAuE1B,CAAA;AAED,yFAAyF;AACzF,eAAO,MAAM,YAAY,YACd,MAAM,GAAG,SAAS,KAC1B,MAAM,IAAI,aACsD,CAAA"}
|
|
@@ -67,6 +67,6 @@ const getHttpMethodInfo = (methodName) => {
|
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
69
|
/** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */
|
|
70
|
-
const isHttpMethod = (method) => requestMethods.includes(method);
|
|
70
|
+
const isHttpMethod = (method) => method ? requestMethods.includes(method) : false;
|
|
71
71
|
|
|
72
72
|
export { REQUEST_METHODS, canMethodHaveBody, getHttpMethodInfo, isHttpMethod };
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* - 0.0.0
|
|
7
7
|
* - 2.1.0 - refactor
|
|
8
8
|
* - 2.2.0 - auth compliancy
|
|
9
|
+
* - 2.3.0 - environments
|
|
10
|
+
* - 2.4.0 - draft collection servers
|
|
9
11
|
*/
|
|
10
|
-
export declare const DATA_VERSION = "2.
|
|
12
|
+
export declare const DATA_VERSION = "2.4.0";
|
|
11
13
|
/** The localStorage key under which the data version is stored */
|
|
12
14
|
export declare const DATA_VERSION_LS_LEY = "scalar_api_client_data_version";
|
|
13
15
|
//# sourceMappingURL=data-version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-version.d.ts","sourceRoot":"","sources":["../../src/migrations/data-version.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"data-version.d.ts","sourceRoot":"","sources":["../../src/migrations/data-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,UAAU,CAAA;AAEnC,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,mCAAmC,CAAA"}
|
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* - 0.0.0
|
|
7
7
|
* - 2.1.0 - refactor
|
|
8
8
|
* - 2.2.0 - auth compliancy
|
|
9
|
+
* - 2.3.0 - environments
|
|
10
|
+
* - 2.4.0 - draft collection servers
|
|
9
11
|
*/
|
|
10
|
-
const DATA_VERSION = '2.
|
|
12
|
+
const DATA_VERSION = '2.4.0';
|
|
11
13
|
/** The localStorage key under which the data version is stored */
|
|
12
14
|
const DATA_VERSION_LS_LEY = 'scalar_api_client_data_version';
|
|
13
15
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type v_2_4_0 } from '../migrations/v-2.4.0/index.js';
|
|
2
2
|
/** Handles all data migrations per entity */
|
|
3
|
-
export declare const migrator: () =>
|
|
3
|
+
export declare const migrator: () => v_2_4_0.DataArray;
|
|
4
4
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrator.d.ts","sourceRoot":"","sources":["../../src/migrations/migrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrator.d.ts","sourceRoot":"","sources":["../../src/migrations/migrator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAmB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEpE,6CAA6C;AAC7C,eAAO,MAAM,QAAQ,QAAO,OAAO,CAAC,SAwCnC,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { semverLessThan } from './semver.js';
|
|
|
3
3
|
import { migrate_v_2_1_0 } from './v-2.1.0/migration.js';
|
|
4
4
|
import { migrate_v_2_2_0 } from './v-2.2.0/migration.js';
|
|
5
5
|
import { migrate_v_2_3_0 } from './v-2.3.0/migration.js';
|
|
6
|
+
import { migrate_v_2_4_0 } from './v-2.4.0/migration.js';
|
|
6
7
|
|
|
7
8
|
/** Handles all data migrations per entity */
|
|
8
9
|
const migrator = () => {
|
|
@@ -29,6 +30,9 @@ const migrator = () => {
|
|
|
29
30
|
// 2.2.0 -> 2.3.0 migration
|
|
30
31
|
if (semverLessThan(dataVersion, '2.3.0'))
|
|
31
32
|
data = migrate_v_2_3_0(data);
|
|
33
|
+
// 2.3.0 -> 2.4.0 migration
|
|
34
|
+
if (semverLessThan(dataVersion, '2.4.0'))
|
|
35
|
+
data = migrate_v_2_4_0(data);
|
|
32
36
|
// Convert to data array
|
|
33
37
|
data = {
|
|
34
38
|
collections: Object.values(data.collections),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.4.0/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { migrate_v_2_4_0 } from './migration.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { v_2_3_0 } from '../../migrations/v-2.3.0/types.generated';
|
|
2
|
+
import type { v_2_4_0 } from './types.generated';
|
|
3
|
+
/** V-2.3.0 to V-2.4.0 migration */
|
|
4
|
+
export declare const migrate_v_2_4_0: (data: v_2_3_0.DataRecord) => v_2_4_0.DataRecord;
|
|
5
|
+
//# sourceMappingURL=migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.4.0/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEhD,mCAAmC;AACnC,eAAO,MAAM,eAAe,SACpB,OAAO,CAAC,UAAU,KACvB,OAAO,CAAC,UA8BV,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** V-2.3.0 to V-2.4.0 migration */
|
|
2
|
+
const migrate_v_2_4_0 = (data) => {
|
|
3
|
+
console.info('Performing data migration v-2.3.0 to v-2.4.0');
|
|
4
|
+
const collections = Object.values(data.collections).reduce((prev, c) => {
|
|
5
|
+
if (c.info?.title === 'Drafts') {
|
|
6
|
+
// Remove the servers from the draft collection
|
|
7
|
+
c.servers = [];
|
|
8
|
+
Object.values(data.requests).forEach((request) => {
|
|
9
|
+
if (request.selectedServerUid && c.requests.includes(request.uid)) {
|
|
10
|
+
const server = data.servers[request.selectedServerUid];
|
|
11
|
+
if (server) {
|
|
12
|
+
// Update the request paths to include the server URL
|
|
13
|
+
request.path = `${server.url}${request.path}`;
|
|
14
|
+
}
|
|
15
|
+
// Remove the selected server UID from the draft request
|
|
16
|
+
request.selectedServerUid = '';
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
prev[c.uid] = c;
|
|
21
|
+
return prev;
|
|
22
|
+
}, {});
|
|
23
|
+
return {
|
|
24
|
+
...data,
|
|
25
|
+
collections,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { migrate_v_2_4_0 };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Cookie as Ck } from '../../entities/cookie/index.js';
|
|
2
|
+
import type { Environment as E } from '../../entities/environment/index.js';
|
|
3
|
+
import type { Collection as Co, Request as R, RequestExample as RE, Server as S, SecurityScheme as SS, Tag as T } from '../../entities/spec/index.js';
|
|
4
|
+
import type { Workspace as W } from '../../entities/workspace/index.js';
|
|
5
|
+
export declare namespace v_2_4_0 {
|
|
6
|
+
type Cookie = Ck;
|
|
7
|
+
type Environment = E;
|
|
8
|
+
type Collection = Co;
|
|
9
|
+
type Request = R;
|
|
10
|
+
type RequestExample = RE;
|
|
11
|
+
type SecurityScheme = SS;
|
|
12
|
+
type Server = S;
|
|
13
|
+
type Tag = T;
|
|
14
|
+
type Workspace = W;
|
|
15
|
+
type DataRecord = {
|
|
16
|
+
collections: Record<string, Collection>;
|
|
17
|
+
cookies: Record<string, Cookie>;
|
|
18
|
+
environments: Record<string, Environment>;
|
|
19
|
+
requestExamples: Record<string, RequestExample>;
|
|
20
|
+
requests: Record<string, Request>;
|
|
21
|
+
securitySchemes: Record<string, SecurityScheme>;
|
|
22
|
+
servers: Record<string, Server>;
|
|
23
|
+
tags: Record<string, Tag>;
|
|
24
|
+
workspaces: Record<string, Workspace>;
|
|
25
|
+
};
|
|
26
|
+
type DataArray = {
|
|
27
|
+
collections: Collection[];
|
|
28
|
+
cookies: Cookie[];
|
|
29
|
+
environments: Environment[];
|
|
30
|
+
requestExamples: RequestExample[];
|
|
31
|
+
requests: Request[];
|
|
32
|
+
securitySchemes: SecurityScheme[];
|
|
33
|
+
servers: Server[];
|
|
34
|
+
tags: Tag[];
|
|
35
|
+
workspaces: Workspace[];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=types.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.generated.d.ts","sourceRoot":"","sources":["../../../src/migrations/v-2.4.0/types.generated.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,EAAE,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,IAAI,CAAC,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EACV,UAAU,IAAI,EAAE,EAChB,OAAO,IAAI,CAAC,EACZ,cAAc,IAAI,EAAE,EACpB,MAAM,IAAI,CAAC,EACX,cAAc,IAAI,EAAE,EACpB,GAAG,IAAI,CAAC,EACT,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,SAAS,IAAI,CAAC,EAAE,MAAM,sBAAsB,CAAA;AAE1D,yBAAiB,OAAO,CAAC;IACvB,KAAY,MAAM,GAAG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E,CAAA;KACxB,CAAA;CACF"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"specification",
|
|
17
17
|
"yaml"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.93",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"types": "./dist/migrations/index.d.ts",
|
|
39
39
|
"default": "./dist/migrations/index.js"
|
|
40
40
|
},
|
|
41
|
+
"./migrations/v-2.4.0": {
|
|
42
|
+
"import": "./dist/migrations/v-2.4.0/index.js",
|
|
43
|
+
"types": "./dist/migrations/v-2.4.0/index.d.ts",
|
|
44
|
+
"default": "./dist/migrations/v-2.4.0/index.js"
|
|
45
|
+
},
|
|
41
46
|
"./migrations/v-2.3.0": {
|
|
42
47
|
"import": "./dist/migrations/v-2.3.0/index.js",
|
|
43
48
|
"types": "./dist/migrations/v-2.3.0/index.d.ts",
|
|
@@ -116,10 +121,10 @@
|
|
|
116
121
|
"nanoid": "^5.0.7",
|
|
117
122
|
"yaml": "^2.4.5",
|
|
118
123
|
"zod": "^3.23.8",
|
|
119
|
-
"@scalar/object-utils": "1.1.12",
|
|
120
|
-
"@scalar/themes": "0.9.58",
|
|
121
124
|
"@scalar/openapi-types": "0.1.5",
|
|
122
|
-
"@scalar/
|
|
125
|
+
"@scalar/object-utils": "1.1.12",
|
|
126
|
+
"@scalar/types": "0.0.25",
|
|
127
|
+
"@scalar/themes": "0.9.58"
|
|
123
128
|
},
|
|
124
129
|
"devDependencies": {
|
|
125
130
|
"type-fest": "^4.20.0",
|
|
@@ -127,7 +132,7 @@
|
|
|
127
132
|
"vitest": "^1.6.0",
|
|
128
133
|
"zod-to-ts": "github:amritk/zod-to-ts#build",
|
|
129
134
|
"@scalar/build-tooling": "0.1.12",
|
|
130
|
-
"@scalar/openapi-parser": "0.10.
|
|
135
|
+
"@scalar/openapi-parser": "0.10.2",
|
|
131
136
|
"@scalar/openapi-types": "0.1.5"
|
|
132
137
|
},
|
|
133
138
|
"scripts": {
|