@scalar/oas-utils 0.2.106 → 0.2.108

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/entities/cookie/cookie.d.ts +2 -2
  3. package/dist/entities/cookie/cookie.js +1 -1
  4. package/dist/entities/environment/environment.d.ts +2 -2
  5. package/dist/entities/environment/environment.js +1 -1
  6. package/dist/entities/shared/utility.d.ts +13 -1
  7. package/dist/entities/shared/utility.d.ts.map +1 -1
  8. package/dist/entities/shared/utility.js +4 -1
  9. package/dist/entities/spec/collection.d.ts +199 -155
  10. package/dist/entities/spec/collection.d.ts.map +1 -1
  11. package/dist/entities/spec/collection.js +15 -17
  12. package/dist/entities/spec/index.js +1 -1
  13. package/dist/entities/spec/operation.d.ts +34 -28
  14. package/dist/entities/spec/operation.d.ts.map +1 -1
  15. package/dist/entities/spec/parameters.d.ts +4 -4
  16. package/dist/entities/spec/request-examples.d.ts +5 -5
  17. package/dist/entities/spec/request-examples.d.ts.map +1 -1
  18. package/dist/entities/spec/request-examples.js +37 -71
  19. package/dist/entities/spec/requests.d.ts +54 -42
  20. package/dist/entities/spec/requests.d.ts.map +1 -1
  21. package/dist/entities/spec/requests.js +6 -18
  22. package/dist/entities/spec/security.d.ts +22 -22
  23. package/dist/entities/spec/security.d.ts.map +1 -1
  24. package/dist/entities/spec/security.js +7 -22
  25. package/dist/entities/spec/server.d.ts +2 -2
  26. package/dist/entities/spec/server.d.ts.map +1 -1
  27. package/dist/entities/spec/server.js +3 -5
  28. package/dist/entities/spec/spec-objects.d.ts +150 -78
  29. package/dist/entities/spec/spec-objects.d.ts.map +1 -1
  30. package/dist/entities/spec/spec-objects.js +68 -45
  31. package/dist/entities/spec/x-scalar-secrets.d.ts +4 -4
  32. package/dist/entities/spec/x-scalar-secrets.d.ts.map +1 -1
  33. package/dist/entities/workspace/workspace.d.ts +7 -7
  34. package/dist/entities/workspace/workspace.d.ts.map +1 -1
  35. package/dist/entities/workspace/workspace.js +5 -5
  36. package/dist/helpers/fetchSpecFromUrl.d.ts.map +1 -1
  37. package/dist/helpers/fetchSpecFromUrl.js +1 -1
  38. package/dist/helpers/fetchWithProxyFallback.d.ts.map +1 -1
  39. package/dist/helpers/findVariables.d.ts.map +1 -1
  40. package/dist/helpers/findVariables.js +1 -1
  41. package/dist/helpers/httpMethods.d.ts.map +1 -1
  42. package/dist/helpers/is-defined.d.ts.map +1 -1
  43. package/dist/helpers/iterateTitle.d.ts.map +1 -1
  44. package/dist/helpers/json2xml.d.ts.map +1 -1
  45. package/dist/helpers/json2xml.js +3 -7
  46. package/dist/helpers/makeUrlAbsolute.d.ts.map +1 -1
  47. package/dist/helpers/makeUrlAbsolute.js +1 -4
  48. package/dist/helpers/merge-urls.d.ts.map +1 -1
  49. package/dist/helpers/normalizeMimeTypeObject.d.ts +1 -0
  50. package/dist/helpers/normalizeMimeTypeObject.d.ts.map +1 -1
  51. package/dist/helpers/object.d.ts.map +1 -1
  52. package/dist/helpers/parse.d.ts.map +1 -1
  53. package/dist/helpers/prettyPrintJson.d.ts.map +1 -1
  54. package/dist/helpers/replaceVariables.d.ts.map +1 -1
  55. package/dist/helpers/replaceVariables.js +1 -3
  56. package/dist/helpers/ssrState.d.ts.map +1 -1
  57. package/dist/helpers/ssrState.js +1 -3
  58. package/dist/migrations/local-storage.d.ts.map +1 -1
  59. package/dist/migrations/migrator.d.ts +1 -1
  60. package/dist/migrations/migrator.d.ts.map +1 -1
  61. package/dist/migrations/semver.d.ts.map +1 -1
  62. package/dist/migrations/semver.js +1 -3
  63. package/dist/migrations/v-0.0.0/types.generated.d.ts.map +1 -1
  64. package/dist/migrations/v-2.1.0/migration.d.ts.map +1 -1
  65. package/dist/migrations/v-2.1.0/migration.js +1 -4
  66. package/dist/migrations/v-2.1.0/types.generated.d.ts.map +1 -1
  67. package/dist/migrations/v-2.2.0/migration.d.ts.map +1 -1
  68. package/dist/migrations/v-2.2.0/migration.js +2 -4
  69. package/dist/migrations/v-2.2.0/types.generated.d.ts.map +1 -1
  70. package/dist/migrations/v-2.3.0/migration.d.ts.map +1 -1
  71. package/dist/migrations/v-2.3.0/migration.js +3 -8
  72. package/dist/migrations/v-2.3.0/types.generated.d.ts.map +1 -1
  73. package/dist/migrations/v-2.4.0/migration.d.ts.map +1 -1
  74. package/dist/migrations/v-2.4.0/types.generated.d.ts.map +1 -1
  75. package/dist/migrations/v-2.5.0/migration.d.ts +1 -1
  76. package/dist/migrations/v-2.5.0/migration.d.ts.map +1 -1
  77. package/dist/migrations/v-2.5.0/migration.js +70 -3
  78. package/dist/migrations/v-2.5.0/types.generated.d.ts +17 -17
  79. package/dist/migrations/v-2.5.0/types.generated.d.ts.map +1 -1
  80. package/dist/spec-getters/getExampleFromSchema.d.ts.map +1 -1
  81. package/dist/spec-getters/getExampleFromSchema.js +8 -22
  82. package/dist/spec-getters/getParametersFromOperation.d.ts.map +1 -1
  83. package/dist/spec-getters/getParametersFromOperation.js +1 -4
  84. package/dist/spec-getters/getRequestBodyFromOperation.d.ts.map +1 -1
  85. package/dist/spec-getters/getRequestBodyFromOperation.js +4 -9
  86. package/dist/spec-getters/getServerVariableExamples.js +3 -1
  87. package/dist/transforms/import-spec.d.ts +2 -1
  88. package/dist/transforms/import-spec.d.ts.map +1 -1
  89. package/dist/transforms/import-spec.js +13 -35
  90. package/dist/transforms/index.d.ts +0 -1
  91. package/dist/transforms/index.d.ts.map +1 -1
  92. package/dist/transforms/index.js +0 -1
  93. package/package.json +7 -7
  94. package/dist/transforms/export-spec.d.ts +0 -17
  95. package/dist/transforms/export-spec.d.ts.map +0 -1
  96. package/dist/transforms/export-spec.js +0 -73
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -1,2 +1 @@
1
1
  export { getSelectedSecuritySchemeUids, getServersFromOpenApiDocument, importSpecToWorkspace, parseSchema } from './import-spec.js';
2
- export { exportSpecFromWorkspace } from './export-spec.js';
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.106",
19
+ "version": "0.2.108",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -126,19 +126,19 @@
126
126
  "nanoid": "^5.0.9",
127
127
  "yaml": "^2.4.5",
128
128
  "zod": "^3.23.8",
129
- "@scalar/openapi-types": "0.1.7",
130
129
  "@scalar/object-utils": "1.1.13",
131
- "@scalar/types": "0.0.33",
132
- "@scalar/themes": "0.9.67"
130
+ "@scalar/themes": "0.9.69",
131
+ "@scalar/openapi-types": "0.1.9",
132
+ "@scalar/types": "0.0.35"
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.13",
140
- "@scalar/openapi-parser": "0.10.7",
141
- "@scalar/openapi-types": "0.1.7"
139
+ "@scalar/build-tooling": "0.1.15",
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",
@@ -1,17 +0,0 @@
1
- import { type Collection, type Request, type RequestExample, type SecurityScheme, type Tag } from '../entities/spec/index.js';
2
- import type { OpenAPIV3_1 } from '@scalar/types';
3
- type WithRequired<T, K extends keyof T> = T & {
4
- [P in K]-?: T[P];
5
- };
6
- /**
7
- * Convert a workspace collection into an OpenAPI document
8
- */
9
- export declare function exportSpecFromWorkspace({ collection, requests, requestExamples, tags, securitySchemes, }: {
10
- collection: Collection;
11
- requests: Record<string, Request>;
12
- requestExamples: Record<string, RequestExample>;
13
- tags: Record<string, Tag>;
14
- securitySchemes: Record<string, SecurityScheme>;
15
- }): WithRequired<OpenAPIV3_1.Document<{}>, "paths" | "components" | "tags">;
16
- export {};
17
- //# sourceMappingURL=export-spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"export-spec.d.ts","sourceRoot":"","sources":["../../src/transforms/export-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,GAAG,EAMT,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA;AAElE;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,QAAQ,EACR,eAAe,EACf,IAAI,EACJ,eAAe,GAChB,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IAC/C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACzB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;CAChD,2EAyEA"}
@@ -1,73 +0,0 @@
1
- import { oasCollectionSchema } from '../entities/spec/collection.js';
2
- import { oasTagSchema } from '../entities/spec/spec-objects.js';
3
- import { oasRequestSchema } from '../entities/spec/requests.js';
4
- import { convertExampleToXScalar } from '../entities/spec/request-examples.js';
5
- import { oasSecuritySchemeSchema } from '../entities/spec/security.js';
6
-
7
- /**
8
- * Convert a workspace collection into an OpenAPI document
9
- */
10
- function exportSpecFromWorkspace({ collection, requests, requestExamples, tags, securitySchemes, }) {
11
- const parsedCollection = oasCollectionSchema.parse(collection);
12
- const spec = {
13
- ...parsedCollection,
14
- openapi: parsedCollection.openapi,
15
- tags: [],
16
- paths: {},
17
- webhooks: {},
18
- components: {
19
- securitySchemes: {},
20
- },
21
- };
22
- /** Add all of the tags into the collection */
23
- Object.values(tags).forEach((tag) => {
24
- const oasTag = oasTagSchema.parse(tag);
25
- if (!oasTag['x-scalar-children']?.length)
26
- delete oasTag['x-scalar-children'];
27
- spec.tags.push(oasTag);
28
- });
29
- /** Add all of the requests into the collection as operations */
30
- Object.values(requests).forEach((request) => {
31
- const oasRequest = oasRequestSchema.parse(request);
32
- // Currently the request has tags added by name. Should this move to UID association?
33
- oasRequest.tags = request.tags;
34
- // If the request has examples we add them all as extensions
35
- const exampleNames = new Set();
36
- /** Increment non-unique names */
37
- function checkName(name) {
38
- if (exampleNames.has(name)) {
39
- const base = name.split(' ');
40
- const end = Number.parseInt(base.at(-1) ?? 'NaN', 10);
41
- if (Number.isNaN(end)) {
42
- base.push('1');
43
- }
44
- else {
45
- base[base.length - 1] = `${end + 1}`;
46
- }
47
- return checkName(base.join(' '));
48
- }
49
- exampleNames.add(name);
50
- return name;
51
- }
52
- if (request.examples.length) {
53
- oasRequest['x-scalar-examples'] = {};
54
- request.examples.forEach((uid) => {
55
- const requestExample = requestExamples[uid];
56
- oasRequest['x-scalar-examples'][checkName(requestExample.name)] =
57
- convertExampleToXScalar(requestExample);
58
- });
59
- }
60
- /** Insert the request as an operation in the spec */
61
- if (!spec.paths[request.path])
62
- spec.paths[request.path] = {};
63
- spec.paths[request.path][request.method] = oasRequest;
64
- });
65
- /** Add all of the security schemes into the collection */
66
- Object.values(securitySchemes).forEach((securityScheme) => {
67
- const oasScheme = oasSecuritySchemeSchema.parse(securityScheme);
68
- spec.components.securitySchemes[securityScheme.nameKey] = oasScheme;
69
- });
70
- return spec;
71
- }
72
-
73
- export { exportSpecFromWorkspace };