@scalar/openapi-parser 0.18.2 → 0.19.0

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 (46) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +0 -202
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +0 -2
  6. package/dist/index.js.map +2 -2
  7. package/dist/utils/openapi/utils/workThroughQueue.d.ts.map +1 -1
  8. package/dist/utils/openapi/utils/workThroughQueue.js +1 -0
  9. package/dist/utils/openapi/utils/workThroughQueue.js.map +2 -2
  10. package/package.json +6 -26
  11. package/dist/plugins-browser.d.ts +0 -4
  12. package/dist/plugins-browser.d.ts.map +0 -1
  13. package/dist/plugins-browser.js +0 -9
  14. package/dist/plugins-browser.js.map +0 -7
  15. package/dist/plugins.d.ts +0 -5
  16. package/dist/plugins.d.ts.map +0 -1
  17. package/dist/plugins.js +0 -11
  18. package/dist/plugins.js.map +0 -7
  19. package/dist/utils/bundle/bundle.d.ts +0 -286
  20. package/dist/utils/bundle/bundle.d.ts.map +0 -1
  21. package/dist/utils/bundle/bundle.js +0 -251
  22. package/dist/utils/bundle/bundle.js.map +0 -7
  23. package/dist/utils/bundle/create-limiter.d.ts +0 -21
  24. package/dist/utils/bundle/create-limiter.d.ts.map +0 -1
  25. package/dist/utils/bundle/create-limiter.js +0 -31
  26. package/dist/utils/bundle/create-limiter.js.map +0 -7
  27. package/dist/utils/bundle/plugins/fetch-urls/index.d.ts +0 -39
  28. package/dist/utils/bundle/plugins/fetch-urls/index.d.ts.map +0 -1
  29. package/dist/utils/bundle/plugins/fetch-urls/index.js +0 -48
  30. package/dist/utils/bundle/plugins/fetch-urls/index.js.map +0 -7
  31. package/dist/utils/bundle/plugins/parse-json/index.d.ts +0 -13
  32. package/dist/utils/bundle/plugins/parse-json/index.d.ts.map +0 -1
  33. package/dist/utils/bundle/plugins/parse-json/index.js +0 -22
  34. package/dist/utils/bundle/plugins/parse-json/index.js.map +0 -7
  35. package/dist/utils/bundle/plugins/parse-yaml/index.d.ts +0 -13
  36. package/dist/utils/bundle/plugins/parse-yaml/index.d.ts.map +0 -1
  37. package/dist/utils/bundle/plugins/parse-yaml/index.js +0 -23
  38. package/dist/utils/bundle/plugins/parse-yaml/index.js.map +0 -7
  39. package/dist/utils/bundle/plugins/read-files/index.d.ts +0 -29
  40. package/dist/utils/bundle/plugins/read-files/index.d.ts.map +0 -1
  41. package/dist/utils/bundle/plugins/read-files/index.js +0 -30
  42. package/dist/utils/bundle/plugins/read-files/index.js.map +0 -7
  43. package/dist/utils/bundle/value-generator.d.ts +0 -79
  44. package/dist/utils/bundle/value-generator.d.ts.map +0 -1
  45. package/dist/utils/bundle/value-generator.js +0 -55
  46. package/dist/utils/bundle/value-generator.js.map +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @scalar/openapi-parser
2
2
 
3
+ ## 0.19.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 952bde2: feat(json-magic): move json tooling to the new package
8
+ - 2888e18: feat(openapi-parser): partial bundle to a depth
9
+
10
+ ## 0.18.3
11
+
12
+ ### Patch Changes
13
+
14
+ - c345d2c: fix: added dependency on @scalar/openapi-types
15
+ - Updated dependencies [ccf875a]
16
+ - @scalar/openapi-types@0.3.7
17
+
3
18
  ## 0.18.2
4
19
 
5
20
  ### Patch Changes
package/README.md CHANGED
@@ -55,208 +55,6 @@ const specification = `{
55
55
  const { schema, errors } = await dereference(specification)
56
56
  ```
57
57
 
58
- ### Bundle external references
59
-
60
- The OpenAPI specification allows to point to external files (URLs or files). But sometimes, you just want to combine all files into one.
61
-
62
- #### Plugins
63
-
64
- If you are on a browser environment import plugins from `@scalar/openapi-parser/plugins-browser` while if you are on a node environment you can import from `@scalar/openapi-parser/plugins`
65
-
66
- ##### fetchUrls
67
- This plugins handles all external urls. It works for both node.js and browser environment
68
-
69
- ```ts
70
- import { bundle } from '@scalar/openapi-parser'
71
- import { fetchUrls } from '@scalar/openapi-parser/plugins-browser'
72
-
73
- const document = {
74
- openapi: '3.1.0',
75
- info: { title: 'Bundled API', version: '1.0.0' },
76
- paths: {},
77
- components: {
78
- schemas: {
79
- User: { $ref: 'https://example.com/user-schema.json#' }
80
- }
81
- }
82
- }
83
-
84
- // This will bundle all external documents and turn all references from external into internal
85
- await bundle(document, {
86
- plugins: [fetchUrls()],
87
- treeShake: true // <------ This flag will try to remove any unused part of the external document
88
- })
89
-
90
- console.log(document)
91
- ```
92
-
93
- ###### Limiting the number of concurrent requests
94
-
95
- ```ts
96
- await bundle(document, {
97
- plugins: [
98
- fetchUrls({
99
- limit: 10, // it should run at most 10 requests at the same time
100
- }),
101
- ],
102
- treeShake: false
103
- })
104
-
105
- ```
106
-
107
- ###### Custom headers
108
- To pass custom headers to requests for specific domains you can configure the fetch plugin like the example
109
-
110
- ```ts
111
- await bundle(
112
- document,
113
- {
114
- plugins: [
115
- fetchUrls({
116
- // Pass custom headers
117
- // The header will only be attached to the list of domains
118
- headers: [
119
- {
120
- domains: ['example.com'],
121
- headers: {
122
- 'Authorization': 'Bearer <TOKEN>'
123
- }
124
- }
125
- ]
126
- }),
127
- readFiles(),
128
- ],
129
- treeShake: false
130
- },
131
- )
132
- ```
133
-
134
- ###### Custom fetch function
135
- For advanced use cases like proxying requests or implementing custom network logic, you can provide your own fetch implementation. This allows you to handle things like CORS restrictions, custom authentication flows, or request/response transformations.
136
-
137
- ```ts
138
- await bundle(
139
- document,
140
- {
141
- plugins: [
142
- fetchUrls({
143
- // Custom fetcher function
144
- fetch: async (input, init) => {
145
- console.log('Custom fetch logic')
146
- return fetch(input, init)
147
- },
148
- })
149
- readFiles(),
150
- ],
151
- treeShake: false
152
- },
153
- )
154
- ```
155
-
156
- ###### Bundle from remote url
157
-
158
- ```ts
159
- const result = await bundle(
160
- 'https://example.com/openapi.json',
161
- {
162
- plugins: [
163
- fetchUrls(),
164
- ],
165
- treeShake: false
166
- },
167
- )
168
-
169
- // Bundled document
170
- console.log(result)
171
- ```
172
-
173
- ##### readFiles
174
- This plugins handles local files. Only works on node.js environment
175
-
176
- ```ts
177
- import { bundle } from '@scalar/openapi-parser'
178
- import { readFiles } from '@scalar/openapi-parser/plugins-browser'
179
-
180
- const document = {
181
- openapi: '3.1.0',
182
- info: { title: 'Bundled API', version: '1.0.0' },
183
- paths: {},
184
- components: {
185
- schemas: {
186
- User: { $ref: './user-schema.json#' }
187
- }
188
- }
189
- }
190
-
191
- // This will bundle all external documents and turn all references from external into internal
192
- await bundle(document, {
193
- plugins: [readFiles()],
194
- treeShake: false
195
- })
196
-
197
- console.log(document)
198
- ```
199
-
200
- ###### Bundle from local file
201
- You can pass the file path directly but make sure to have the correct plugins to handle reading from the local files
202
-
203
- ```ts
204
- const result = await bundle(
205
- './input.json',
206
- {
207
- plugins: [
208
- readFiles(),
209
- ],
210
- treeShake: false
211
- },
212
- )
213
-
214
- // Bundled document
215
- console.log(result)
216
- ```
217
-
218
- ##### parseJson
219
-
220
- You can pass raw json string as input
221
- ```ts
222
- import { bundle } from '@scalar/openapi-parser'
223
- import { parseJson } from '@scalar/openapi-parser/plugins-browser'
224
-
225
- const result = await bundle(
226
- '{ "openapi": "3.1.1" }',
227
- {
228
- plugins: [
229
- parseJson(),
230
- ],
231
- treeShake: false
232
- },
233
- )
234
-
235
- // Bundled document
236
- console.log(result)
237
- ```
238
-
239
- ##### parseYaml
240
-
241
- You can pass raw yaml string as input
242
- ```ts
243
- import { bundle } from '@scalar/openapi-parser'
244
- import { parseYaml } from '@scalar/openapi-parser/plugins-browser'
245
-
246
- const result = await bundle(
247
- 'openapi: "3.1.1"\n',
248
- {
249
- plugins: [
250
- parseYaml(),
251
- ],
252
- treeShake: false
253
- },
254
- )
255
-
256
- // Bundled document
257
- console.log(result)
258
- ```
259
-
260
58
  ### Track references
261
59
 
262
60
  The `dereference` function accepts an `onDereference` callback option that gets called whenever a reference is resolved. This can be useful for tracking which schemas are being dereferenced:
package/dist/index.d.ts CHANGED
@@ -14,7 +14,6 @@ export { upgrade } from './utils/upgrade.js';
14
14
  export { upgradeFromThreeToThreeOne } from './utils/upgrade-from-three-to-three-one.js';
15
15
  export { upgradeFromTwoToThree } from './utils/upgrade-from-two-to-three.js';
16
16
  export { validate } from './utils/validate.js';
17
- export { bundle } from './utils/bundle/bundle.js';
18
17
  export type { LoadResult, Filesystem, AnyObject, ErrorObject } from './types/index.js';
19
18
  export { openapi } from './utils/openapi/openapi.js';
20
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA"}
package/dist/index.js CHANGED
@@ -14,10 +14,8 @@ import { upgrade } from "./utils/upgrade.js";
14
14
  import { upgradeFromThreeToThreeOne } from "./utils/upgrade-from-three-to-three-one.js";
15
15
  import { upgradeFromTwoToThree } from "./utils/upgrade-from-two-to-three.js";
16
16
  import { validate } from "./utils/validate.js";
17
- import { bundle } from "./utils/bundle/bundle.js";
18
17
  import { openapi } from "./utils/openapi/openapi.js";
19
18
  export {
20
- bundle,
21
19
  dereference,
22
20
  escapeJsonPointer,
23
21
  filter,
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["export { dereference } from './utils/dereference'\nexport { escapeJsonPointer } from './utils/escape-json-pointer'\nexport { filter } from './utils/filter'\nexport { isJson } from './utils/is-json'\nexport { isYaml } from './utils/is-yaml'\nexport { load } from './utils/load'\nexport { normalize } from './utils/normalize'\nexport { sanitize } from './utils/transform/sanitize'\nexport { toJson } from './utils/to-json'\nexport { toYaml } from './utils/to-yaml'\nexport { traverse } from './utils/traverse'\nexport { unescapeJsonPointer } from './utils/unescape-json-pointer'\nexport { upgrade } from './utils/upgrade'\nexport { upgradeFromThreeToThreeOne } from './utils/upgrade-from-three-to-three-one'\nexport { upgradeFromTwoToThree } from './utils/upgrade-from-two-to-three'\nexport { validate } from './utils/validate'\nexport { bundle } from './utils/bundle/bundle'\nexport type { LoadResult, Filesystem, AnyObject, ErrorObject } from './types'\nexport { openapi } from './utils/openapi/openapi'\n"],
5
- "mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AACpC,SAAS,eAAe;AACxB,SAAS,kCAAkC;AAC3C,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAEvB,SAAS,eAAe;",
4
+ "sourcesContent": ["export { dereference } from './utils/dereference'\nexport { escapeJsonPointer } from './utils/escape-json-pointer'\nexport { filter } from './utils/filter'\nexport { isJson } from './utils/is-json'\nexport { isYaml } from './utils/is-yaml'\nexport { load } from './utils/load'\nexport { normalize } from './utils/normalize'\nexport { sanitize } from './utils/transform/sanitize'\nexport { toJson } from './utils/to-json'\nexport { toYaml } from './utils/to-yaml'\nexport { traverse } from './utils/traverse'\nexport { unescapeJsonPointer } from './utils/unescape-json-pointer'\nexport { upgrade } from './utils/upgrade'\nexport { upgradeFromThreeToThreeOne } from './utils/upgrade-from-three-to-three-one'\nexport { upgradeFromTwoToThree } from './utils/upgrade-from-two-to-three'\nexport { validate } from './utils/validate'\nexport type { LoadResult, Filesystem, AnyObject, ErrorObject } from './types'\nexport { openapi } from './utils/openapi/openapi'\n"],
5
+ "mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AACpC,SAAS,eAAe;AACxB,SAAS,kCAAkC;AAC3C,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AAEzB,SAAS,eAAe;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"workThroughQueue.d.ts","sourceRoot":"","sources":["../../../../src/utils/openapi/utils/workThroughQueue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAS,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAOrE;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAkElG"}
1
+ {"version":3,"file":"workThroughQueue.d.ts","sourceRoot":"","sources":["../../../../src/utils/openapi/utils/workThroughQueue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAS,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAOrE;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAqElG"}
@@ -42,6 +42,7 @@ async function workThroughQueue(queue) {
42
42
  };
43
43
  } else {
44
44
  const _ = name;
45
+ const nada = _;
45
46
  }
46
47
  }
47
48
  return result;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/utils/openapi/utils/workThroughQueue.ts"],
4
- "sourcesContent": ["import type { CommandChain, Merge, Queue, Task } from '@/types/index'\nimport { dereference } from '@/utils/dereference'\nimport { filter } from '@/utils/filter'\nimport { load } from '@/utils/load/load'\nimport { upgrade } from '@/utils/upgrade'\nimport { validate } from '@/utils/validate'\n\n/**\n * Takes a queue of tasks and works through them\n */\nexport async function workThroughQueue<T extends Task[]>(queue: Queue<T>): Promise<CommandChain<T>> {\n const { input } = {\n ...queue,\n }\n let result = {} as CommandChain<T>\n\n // Work through the whole queue\n for (const task of queue.tasks) {\n const name: keyof Commands = task.name\n const options: any = 'options' in task ? task.options : undefined\n\n // Use the result of the previous task, or fall back to the original input\n const currentSpecification = result.specification\n ? result.specification\n : typeof input === 'object'\n ? // Detach from the original object\n structuredClone(input)\n : input\n\n // load\n if (name === 'load') {\n result = {\n ...result,\n ...(await load(input, options as Commands['load']['task']['options'])),\n } as Merge<typeof result, Awaited<typeof load>>\n }\n\n // validate\n else if (name === 'filter') {\n result = {\n ...result,\n ...filter(currentSpecification, options as Commands['filter']['task']['options']),\n } as Merge<typeof result, ReturnType<typeof filter>>\n }\n\n // dereference\n else if (name === 'dereference') {\n result = {\n ...result,\n ...(await dereference(currentSpecification, options as Commands['dereference']['task']['options'])),\n } as Merge<typeof result, Awaited<typeof dereference>>\n }\n\n // upgrade\n else if (name === 'upgrade') {\n result = {\n ...result,\n ...upgrade(currentSpecification),\n } as Merge<typeof result, ReturnType<typeof upgrade>>\n }\n\n // validate\n else if (name === 'validate') {\n result = {\n ...result,\n ...(await validate(currentSpecification, options as Commands['validate']['task']['options'])),\n } as Merge<typeof result, Awaited<typeof validate>>\n }\n\n // Make TS complain when we forgot to handle a command.\n else {\n const _: never = name\n }\n }\n\n return result\n}\n"],
5
- "mappings": "AACA,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAKzB,eAAsB,iBAAmC,OAA2C;AAClG,QAAM,EAAE,MAAM,IAAI;AAAA,IAChB,GAAG;AAAA,EACL;AACA,MAAI,SAAS,CAAC;AAGd,aAAW,QAAQ,MAAM,OAAO;AAC9B,UAAM,OAAuB,KAAK;AAClC,UAAM,UAAe,aAAa,OAAO,KAAK,UAAU;AAGxD,UAAM,uBAAuB,OAAO,gBAChC,OAAO,gBACP,OAAO,UAAU;AAAA;AAAA,MAEf,gBAAgB,KAAK;AAAA,QACrB;AAGN,QAAI,SAAS,QAAQ;AACnB,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAI,MAAM,KAAK,OAAO,OAA8C;AAAA,MACtE;AAAA,IACF,WAGS,SAAS,UAAU;AAC1B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAG,OAAO,sBAAsB,OAAgD;AAAA,MAClF;AAAA,IACF,WAGS,SAAS,eAAe;AAC/B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAI,MAAM,YAAY,sBAAsB,OAAqD;AAAA,MACnG;AAAA,IACF,WAGS,SAAS,WAAW;AAC3B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAG,QAAQ,oBAAoB;AAAA,MACjC;AAAA,IACF,WAGS,SAAS,YAAY;AAC5B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAI,MAAM,SAAS,sBAAsB,OAAkD;AAAA,MAC7F;AAAA,IACF,OAGK;AACH,YAAM,IAAW;AAAA,IACnB;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { CommandChain, Merge, Queue, Task } from '@/types/index'\nimport { dereference } from '@/utils/dereference'\nimport { filter } from '@/utils/filter'\nimport { load } from '@/utils/load/load'\nimport { upgrade } from '@/utils/upgrade'\nimport { validate } from '@/utils/validate'\n\n/**\n * Takes a queue of tasks and works through them\n */\nexport async function workThroughQueue<T extends Task[]>(queue: Queue<T>): Promise<CommandChain<T>> {\n const { input } = {\n ...queue,\n }\n let result = {} as CommandChain<T>\n\n // Work through the whole queue\n for (const task of queue.tasks) {\n const name: keyof Commands = task.name\n const options: any = 'options' in task ? task.options : undefined\n\n // Use the result of the previous task, or fall back to the original input\n const currentSpecification = result.specification\n ? result.specification\n : typeof input === 'object'\n ? // Detach from the original object\n structuredClone(input)\n : input\n\n // load\n if (name === 'load') {\n result = {\n ...result,\n ...(await load(input, options as Commands['load']['task']['options'])),\n } as Merge<typeof result, Awaited<typeof load>>\n }\n\n // validate\n else if (name === 'filter') {\n result = {\n ...result,\n ...filter(currentSpecification, options as Commands['filter']['task']['options']),\n } as Merge<typeof result, ReturnType<typeof filter>>\n }\n\n // dereference\n else if (name === 'dereference') {\n result = {\n ...result,\n ...(await dereference(currentSpecification, options as Commands['dereference']['task']['options'])),\n } as Merge<typeof result, Awaited<typeof dereference>>\n }\n\n // upgrade\n else if (name === 'upgrade') {\n result = {\n ...result,\n ...upgrade(currentSpecification),\n } as Merge<typeof result, ReturnType<typeof upgrade>>\n }\n\n // validate\n else if (name === 'validate') {\n result = {\n ...result,\n ...(await validate(currentSpecification, options as Commands['validate']['task']['options'])),\n } as Merge<typeof result, Awaited<typeof validate>>\n }\n\n // Make TS complain when we forgot to handle a command.\n else {\n const _: never = name\n\n // @ts-expect-error Needed to allow the unused type to still be checked\n const nada = _\n }\n }\n\n return result\n}\n"],
5
+ "mappings": "AACA,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,gBAAgB;AAKzB,eAAsB,iBAAmC,OAA2C;AAClG,QAAM,EAAE,MAAM,IAAI;AAAA,IAChB,GAAG;AAAA,EACL;AACA,MAAI,SAAS,CAAC;AAGd,aAAW,QAAQ,MAAM,OAAO;AAC9B,UAAM,OAAuB,KAAK;AAClC,UAAM,UAAe,aAAa,OAAO,KAAK,UAAU;AAGxD,UAAM,uBAAuB,OAAO,gBAChC,OAAO,gBACP,OAAO,UAAU;AAAA;AAAA,MAEf,gBAAgB,KAAK;AAAA,QACrB;AAGN,QAAI,SAAS,QAAQ;AACnB,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAI,MAAM,KAAK,OAAO,OAA8C;AAAA,MACtE;AAAA,IACF,WAGS,SAAS,UAAU;AAC1B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAG,OAAO,sBAAsB,OAAgD;AAAA,MAClF;AAAA,IACF,WAGS,SAAS,eAAe;AAC/B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAI,MAAM,YAAY,sBAAsB,OAAqD;AAAA,MACnG;AAAA,IACF,WAGS,SAAS,WAAW;AAC3B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAG,QAAQ,oBAAoB;AAAA,MACjC;AAAA,IACF,WAGS,SAAS,YAAY;AAC5B,eAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAI,MAAM,SAAS,sBAAsB,OAAkD;AAAA,MAC7F;AAAA,IACF,OAGK;AACH,YAAM,IAAW;AAGjB,YAAM,OAAO;AAAA,IACf;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "parser",
18
18
  "typescript"
19
19
  ],
20
- "version": "0.18.2",
20
+ "version": "0.19.0",
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
@@ -29,26 +29,6 @@
29
29
  "import": "./dist/index.js",
30
30
  "types": "./dist/index.d.ts",
31
31
  "default": "./dist/index.js"
32
- },
33
- "./plugins": {
34
- "import": "./dist/plugins.js",
35
- "types": "./dist/plugins.d.ts",
36
- "default": "./dist/plugins.js"
37
- },
38
- "./plugins-browser": {
39
- "import": "./dist/plugins-browser.js",
40
- "types": "./dist/plugins-browser.d.ts",
41
- "default": "./dist/plugins-browser.js"
42
- },
43
- "./plugins/fetch-urls": {
44
- "import": "./dist/plugins/fetch-urls/index.js",
45
- "types": "./dist/plugins/fetch-urls/index.d.ts",
46
- "default": "./dist/plugins/fetch-urls/index.js"
47
- },
48
- "./plugins/read-files": {
49
- "import": "./dist/plugins/read-files/index.js",
50
- "types": "./dist/plugins/read-files/index.d.ts",
51
- "default": "./dist/plugins/read-files/index.js"
52
32
  }
53
33
  },
54
34
  "files": [
@@ -63,7 +43,8 @@
63
43
  "ajv-formats": "^3.0.1",
64
44
  "jsonpointer": "^5.0.1",
65
45
  "leven": "^4.0.0",
66
- "yaml": "2.8.0"
46
+ "yaml": "2.8.0",
47
+ "@scalar/openapi-types": "0.3.7"
67
48
  },
68
49
  "devDependencies": {
69
50
  "@apidevtools/swagger-parser": "^10.1.0",
@@ -72,10 +53,9 @@
72
53
  "json-to-ast": "^2.1.0",
73
54
  "just-diff": "^6.0.2",
74
55
  "tinybench": "^2.8.0",
75
- "vite": "5.4.19",
76
- "@scalar/build-tooling": "0.2.4",
77
- "@scalar/openapi-types": "0.3.6",
78
- "@scalar/types": "0.2.10"
56
+ "vite": "6.1.6",
57
+ "@scalar/types": "0.2.11",
58
+ "@scalar/build-tooling": "0.2.4"
79
59
  },
80
60
  "scripts": {
81
61
  "build": "scalar-build-esbuild",
@@ -1,4 +0,0 @@
1
- export { fetchUrls } from './utils/bundle/plugins/fetch-urls/index.js';
2
- export { parseJson } from './utils/bundle/plugins/parse-json/index.js';
3
- export { parseYaml } from './utils/bundle/plugins/parse-yaml/index.js';
4
- //# sourceMappingURL=plugins-browser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins-browser.d.ts","sourceRoot":"","sources":["../src/plugins-browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA"}
@@ -1,9 +0,0 @@
1
- import { fetchUrls } from "./utils/bundle/plugins/fetch-urls/index.js";
2
- import { parseJson } from "./utils/bundle/plugins/parse-json/index.js";
3
- import { parseYaml } from "./utils/bundle/plugins/parse-yaml/index.js";
4
- export {
5
- fetchUrls,
6
- parseJson,
7
- parseYaml
8
- };
9
- //# sourceMappingURL=plugins-browser.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/plugins-browser.ts"],
4
- "sourcesContent": ["export { fetchUrls } from './utils/bundle/plugins/fetch-urls'\nexport { parseJson } from './utils/bundle/plugins/parse-json'\nexport { parseYaml } from './utils/bundle/plugins/parse-yaml'\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;",
6
- "names": []
7
- }
package/dist/plugins.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { fetchUrls } from './utils/bundle/plugins/fetch-urls/index.js';
2
- export { readFiles } from './utils/bundle/plugins/read-files/index.js';
3
- export { parseJson } from './utils/bundle/plugins/parse-json/index.js';
4
- export { parseYaml } from './utils/bundle/plugins/parse-yaml/index.js';
5
- //# sourceMappingURL=plugins.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA"}
package/dist/plugins.js DELETED
@@ -1,11 +0,0 @@
1
- import { fetchUrls } from "./utils/bundle/plugins/fetch-urls/index.js";
2
- import { readFiles } from "./utils/bundle/plugins/read-files/index.js";
3
- import { parseJson } from "./utils/bundle/plugins/parse-json/index.js";
4
- import { parseYaml } from "./utils/bundle/plugins/parse-yaml/index.js";
5
- export {
6
- fetchUrls,
7
- parseJson,
8
- parseYaml,
9
- readFiles
10
- };
11
- //# sourceMappingURL=plugins.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/plugins.ts"],
4
- "sourcesContent": ["export { fetchUrls } from './utils/bundle/plugins/fetch-urls'\nexport { readFiles } from './utils/bundle/plugins/read-files'\nexport { parseJson } from './utils/bundle/plugins/parse-json'\nexport { parseYaml } from './utils/bundle/plugins/parse-yaml'\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;",
6
- "names": []
7
- }