@scalar/json-magic 0.5.1 → 0.6.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.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +12 -0
- package/dist/bundle/plugins/parse-yaml/index.js +1 -1
- package/dist/bundle/plugins/parse-yaml/index.js.map +2 -2
- package/dist/helpers/normalize.d.ts.map +1 -1
- package/dist/helpers/normalize.js +2 -1
- package/dist/helpers/normalize.js.map +2 -2
- package/package.json +1 -2
- package/src/bundle/bundle.test.ts +11 -4
- package/src/bundle/plugins/parse-yaml/index.ts +1 -1
- package/src/helpers/normalize.ts +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
> @scalar/json-magic@0.
|
|
2
|
+
> @scalar/json-magic@0.6.0 build /home/runner/work/scalar/scalar/packages/json-magic
|
|
3
3
|
> scalar-build-esbuild
|
|
4
4
|
|
|
5
|
-
[34m@scalar/json-magic: Build completed in
|
|
5
|
+
[34m@scalar/json-magic: Build completed in 61.22ms[39m
|
|
6
6
|
|
|
7
|
-
> @scalar/json-magic@0.
|
|
7
|
+
> @scalar/json-magic@0.6.0 types:build /home/runner/work/scalar/scalar/packages/json-magic
|
|
8
8
|
> scalar-types-build
|
|
9
9
|
|
|
10
|
-
[32mTypes build completed in 1.
|
|
10
|
+
[32mTypes build completed in 1.77s[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @scalar/json-magic
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4951456: feat: merge yaml aliases for in-mem representation
|
|
8
|
+
|
|
9
|
+
## 0.5.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 6462733: fix: comment out flaky test for now
|
|
14
|
+
|
|
3
15
|
## 0.5.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/bundle/plugins/parse-yaml/index.ts"],
|
|
4
|
-
"sourcesContent": ["import YAML from 'yaml'\n\nimport type { LoaderPlugin, ResolveResult } from '@/bundle'\nimport { isYaml } from '@/helpers/is-yaml'\n\n/**\n * Creates a plugin that parses YAML strings into JavaScript objects.\n * @returns A plugin object with validate and exec functions\n * @example\n * ```ts\n * const yamlPlugin = parseYaml()\n * const result = yamlPlugin.exec('name: John\\nage: 30')\n * // result = { name: 'John', age: 30 }\n * ```\n */\nexport function parseYaml(): LoaderPlugin {\n return {\n type: 'loader',\n validate: isYaml,\n exec: async (value): Promise<ResolveResult> => {\n try {\n return {\n ok: true,\n data: YAML.parse(value),\n }\n } catch {\n return {\n ok: false,\n }\n }\n },\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,UAAU;AAGjB,SAAS,cAAc;AAYhB,SAAS,YAA0B;AACxC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,MAAM,OAAO,UAAkC;AAC7C,UAAI;AACF,eAAO;AAAA,UACL,IAAI;AAAA,UACJ,MAAM,KAAK,MAAM,
|
|
4
|
+
"sourcesContent": ["import YAML from 'yaml'\n\nimport type { LoaderPlugin, ResolveResult } from '@/bundle'\nimport { isYaml } from '@/helpers/is-yaml'\n\n/**\n * Creates a plugin that parses YAML strings into JavaScript objects.\n * @returns A plugin object with validate and exec functions\n * @example\n * ```ts\n * const yamlPlugin = parseYaml()\n * const result = yamlPlugin.exec('name: John\\nage: 30')\n * // result = { name: 'John', age: 30 }\n * ```\n */\nexport function parseYaml(): LoaderPlugin {\n return {\n type: 'loader',\n validate: isYaml,\n exec: async (value): Promise<ResolveResult> => {\n try {\n return {\n ok: true,\n data: YAML.parse(value, { merge: true, maxAliasCount: 10000 }),\n }\n } catch {\n return {\n ok: false,\n }\n }\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAGjB,SAAS,cAAc;AAYhB,SAAS,YAA0B;AACxC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,IACV,MAAM,OAAO,UAAkC;AAC7C,UAAI;AACF,eAAO;AAAA,UACL,IAAI;AAAA,UACJ,MAAM,KAAK,MAAM,OAAO,EAAE,OAAO,MAAM,eAAe,IAAM,CAAC;AAAA,QAC/D;AAAA,MACF,QAAQ;AACN,eAAO;AAAA,UACL,IAAI;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/helpers/normalize.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/helpers/normalize.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,GAAG,OA6BrC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/normalize.ts"],
|
|
4
|
-
"sourcesContent": ["import { parse } from 'yaml'\n\n/**\n * Normalize a string (YAML, JSON, object) to a JavaScript datatype.\n */\nexport function normalize(content: any) {\n if (content === null) {\n return undefined\n }\n\n if (typeof content === 'string') {\n if (content.trim() === '') {\n return undefined\n }\n\n try {\n return JSON.parse(content)\n } catch (_error) {\n // Does it look like YAML?\n const hasColon = /^[^:]+:/.test(content)\n const isJson = content.slice(0, 50).trimStart().startsWith('{')\n\n if (!hasColon || isJson) {\n return undefined\n }\n\n return parse(content, {\n maxAliasCount: 10000,\n })\n }\n }\n\n return content\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,aAAa;AAKf,SAAS,UAAU,SAAc;AACtC,MAAI,YAAY,MAAM;AACpB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,YAAY,UAAU;AAC/B,QAAI,QAAQ,KAAK,MAAM,IAAI;AACzB,aAAO;AAAA,IACT;AAEA,QAAI;AACF,aAAO,KAAK,MAAM,OAAO;AAAA,IAC3B,SAAS,QAAQ;AAEf,YAAM,WAAW,UAAU,KAAK,OAAO;AACvC,YAAM,SAAS,QAAQ,MAAM,GAAG,EAAE,EAAE,UAAU,EAAE,WAAW,GAAG;AAE9D,UAAI,CAAC,YAAY,QAAQ;AACvB,eAAO;AAAA,MACT;AAEA,aAAO,MAAM,SAAS;AAAA,QACpB,eAAe;AAAA,
|
|
4
|
+
"sourcesContent": ["import { parse } from 'yaml'\n\n/**\n * Normalize a string (YAML, JSON, object) to a JavaScript datatype.\n */\nexport function normalize(content: any) {\n if (content === null) {\n return undefined\n }\n\n if (typeof content === 'string') {\n if (content.trim() === '') {\n return undefined\n }\n\n try {\n return JSON.parse(content)\n } catch (_error) {\n // Does it look like YAML?\n const hasColon = /^[^:]+:/.test(content)\n const isJson = content.slice(0, 50).trimStart().startsWith('{')\n\n if (!hasColon || isJson) {\n return undefined\n }\n\n return parse(content, {\n maxAliasCount: 10000,\n merge: true,\n })\n }\n }\n\n return content\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa;AAKf,SAAS,UAAU,SAAc;AACtC,MAAI,YAAY,MAAM;AACpB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,YAAY,UAAU;AAC/B,QAAI,QAAQ,KAAK,MAAM,IAAI;AACzB,aAAO;AAAA,IACT;AAEA,QAAI;AACF,aAAO,KAAK,MAAM,OAAO;AAAA,IAC3B,SAAS,QAAQ;AAEf,YAAM,WAAW,UAAU,KAAK,OAAO;AACvC,YAAM,SAAS,QAAQ,MAAM,GAAG,EAAE,EAAE,UAAU,EAAE,WAAW,GAAG;AAE9D,UAAI,CAAC,YAAY,QAAQ;AACvB,eAAO;AAAA,MACT;AAEA,aAAO,MAAM,SAAS;AAAA,QACpB,eAAe;AAAA,QACf,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/json-magic"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.
|
|
13
|
+
"version": "0.6.0",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=20"
|
|
16
16
|
},
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"vue": "^3.5.17",
|
|
57
56
|
"yaml": "2.8.0",
|
|
58
57
|
"@scalar/helpers": "0.0.11"
|
|
59
58
|
},
|
|
@@ -1409,7 +1409,7 @@ describe('bundle', () => {
|
|
|
1409
1409
|
content: {
|
|
1410
1410
|
'application/json': {
|
|
1411
1411
|
schema: {
|
|
1412
|
-
$ref: 'https://example.com/root
|
|
1412
|
+
$ref: 'https://example.com/root#user-schema',
|
|
1413
1413
|
},
|
|
1414
1414
|
},
|
|
1415
1415
|
},
|
|
@@ -1421,13 +1421,20 @@ describe('bundle', () => {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
|
|
1423
1423
|
await bundle(input, {
|
|
1424
|
-
plugins: [
|
|
1424
|
+
plugins: [
|
|
1425
|
+
fetchUrls({
|
|
1426
|
+
fetch: async () => {
|
|
1427
|
+
return Response.json({ message: 'should not be called' })
|
|
1428
|
+
},
|
|
1429
|
+
}),
|
|
1430
|
+
readFiles(),
|
|
1431
|
+
],
|
|
1425
1432
|
treeShake: false,
|
|
1426
1433
|
})
|
|
1427
1434
|
|
|
1428
1435
|
// The $ref should remain unchanged because the schema is already defined locally with $anchor
|
|
1429
1436
|
expect(input.paths['/users'].get.responses['200'].content['application/json'].schema.$ref).toBe(
|
|
1430
|
-
'https://example.com/root
|
|
1437
|
+
'https://example.com/root#user-schema',
|
|
1431
1438
|
)
|
|
1432
1439
|
|
|
1433
1440
|
// The external schema should not be bundled into x-ext
|
|
@@ -2056,7 +2063,7 @@ describe('bundle', () => {
|
|
|
2056
2063
|
|
|
2057
2064
|
describe('bundle with a certain depth', () => {
|
|
2058
2065
|
let server: FastifyInstance
|
|
2059
|
-
const PORT =
|
|
2066
|
+
const PORT = 7298
|
|
2060
2067
|
const url = `http://localhost:${PORT}`
|
|
2061
2068
|
|
|
2062
2069
|
beforeEach(() => {
|