@powerlines/schema 0.11.44 → 0.11.46

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 (72) hide show
  1. package/dist/bundle.cjs +1 -1
  2. package/dist/bundle.d.cts +1 -1
  3. package/dist/bundle.d.mts +1 -1
  4. package/dist/bundle.mjs +1 -1
  5. package/dist/bundle.mjs.map +1 -1
  6. package/dist/codegen.cjs +28 -22
  7. package/dist/codegen.d.cts +11 -11
  8. package/dist/codegen.d.cts.map +1 -1
  9. package/dist/codegen.d.mts +11 -11
  10. package/dist/codegen.d.mts.map +1 -1
  11. package/dist/codegen.mjs +36 -30
  12. package/dist/codegen.mjs.map +1 -1
  13. package/dist/constants.cjs +15 -11
  14. package/dist/constants.d.cts +4 -3
  15. package/dist/constants.d.cts.map +1 -1
  16. package/dist/constants.d.mts +4 -3
  17. package/dist/constants.d.mts.map +1 -1
  18. package/dist/constants.mjs +13 -10
  19. package/dist/constants.mjs.map +1 -1
  20. package/dist/extract.cjs +158 -20
  21. package/dist/extract.d.cts +55 -16
  22. package/dist/extract.d.cts.map +1 -1
  23. package/dist/extract.d.mts +55 -16
  24. package/dist/extract.d.mts.map +1 -1
  25. package/dist/extract.mjs +158 -22
  26. package/dist/extract.mjs.map +1 -1
  27. package/dist/helpers.cjs +43 -8
  28. package/dist/helpers.d.cts +40 -6
  29. package/dist/helpers.d.cts.map +1 -1
  30. package/dist/helpers.d.mts +40 -6
  31. package/dist/helpers.d.mts.map +1 -1
  32. package/dist/helpers.mjs +43 -10
  33. package/dist/helpers.mjs.map +1 -1
  34. package/dist/index.cjs +39 -7
  35. package/dist/index.d.cts +8 -8
  36. package/dist/index.d.mts +8 -8
  37. package/dist/index.mjs +7 -7
  38. package/dist/metadata.cjs +9 -35
  39. package/dist/metadata.d.cts +5 -26
  40. package/dist/metadata.d.cts.map +1 -1
  41. package/dist/metadata.d.mts +5 -26
  42. package/dist/metadata.d.mts.map +1 -1
  43. package/dist/metadata.mjs +9 -33
  44. package/dist/metadata.mjs.map +1 -1
  45. package/dist/persistence.d.cts +4 -4
  46. package/dist/persistence.d.cts.map +1 -1
  47. package/dist/persistence.d.mts +4 -4
  48. package/dist/persistence.d.mts.map +1 -1
  49. package/dist/persistence.mjs.map +1 -1
  50. package/dist/reflection.cjs +72 -50
  51. package/dist/reflection.d.cts +1 -1
  52. package/dist/reflection.d.cts.map +1 -1
  53. package/dist/reflection.d.mts +1 -1
  54. package/dist/reflection.d.mts.map +1 -1
  55. package/dist/reflection.mjs +74 -52
  56. package/dist/reflection.mjs.map +1 -1
  57. package/dist/resolve.cjs +2 -2
  58. package/dist/resolve.mjs +2 -2
  59. package/dist/resolve.mjs.map +1 -1
  60. package/dist/type-checks.cjs +363 -83
  61. package/dist/type-checks.d.cts +138 -16
  62. package/dist/type-checks.d.cts.map +1 -1
  63. package/dist/type-checks.d.mts +138 -16
  64. package/dist/type-checks.d.mts.map +1 -1
  65. package/dist/type-checks.mjs +336 -85
  66. package/dist/type-checks.mjs.map +1 -1
  67. package/dist/types.d.cts +901 -176
  68. package/dist/types.d.cts.map +1 -1
  69. package/dist/types.d.mts +901 -176
  70. package/dist/types.d.mts.map +1 -1
  71. package/dist/validate.mjs.map +1 -1
  72. package/package.json +5 -5
package/dist/bundle.cjs CHANGED
@@ -15,7 +15,7 @@ let unplugin = require("unplugin");
15
15
  *
16
16
  * @param context - The context object containing the environment paths.
17
17
  * @param file - The file path to bundle.
18
- * @param options - Optional overrides for the ESBuild configuration.
18
+ * @param options - Optional overrides for the Rolldown configuration.
19
19
  * @returns A promise that resolves to the bundled module.
20
20
  */
21
21
  async function bundle(context, file, options = {}) {
package/dist/bundle.d.cts CHANGED
@@ -12,7 +12,7 @@ type BundleOptions = DeepPartial<Omit<BuildOptions, "input" | "write">> & {
12
12
  *
13
13
  * @param context - The context object containing the environment paths.
14
14
  * @param file - The file path to bundle.
15
- * @param options - Optional overrides for the ESBuild configuration.
15
+ * @param options - Optional overrides for the Rolldown configuration.
16
16
  * @returns A promise that resolves to the bundled module.
17
17
  */
18
18
  declare function bundle<TContext extends UnresolvedContext>(context: TContext, file: string, options?: BundleOptions): Promise<OutputChunk>;
package/dist/bundle.d.mts CHANGED
@@ -12,7 +12,7 @@ type BundleOptions = DeepPartial<Omit<BuildOptions, "input" | "write">> & {
12
12
  *
13
13
  * @param context - The context object containing the environment paths.
14
14
  * @param file - The file path to bundle.
15
- * @param options - Optional overrides for the ESBuild configuration.
15
+ * @param options - Optional overrides for the Rolldown configuration.
16
16
  * @returns A promise that resolves to the bundled module.
17
17
  */
18
18
  declare function bundle<TContext extends UnresolvedContext>(context: TContext, file: string, options?: BundleOptions): Promise<OutputChunk>;
package/dist/bundle.mjs CHANGED
@@ -13,7 +13,7 @@ import { createRolldownPlugin } from "unplugin";
13
13
  *
14
14
  * @param context - The context object containing the environment paths.
15
15
  * @param file - The file path to bundle.
16
- * @param options - Optional overrides for the ESBuild configuration.
16
+ * @param options - Optional overrides for the Rolldown configuration.
17
17
  * @returns A promise that resolves to the bundled module.
18
18
  */
19
19
  async function bundle(context, file, options = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.mjs","names":[],"sources":["../src/bundle.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n CreateUnpluginResolverOptions,\n ResolveOptions,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { createUnpluginResolver } from \"@powerlines/core/lib/unplugin\";\nimport { resolveOptions } from \"@powerlines/unplugin/rolldown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { DeepPartial } from \"@stryke/types/base\";\nimport defu from \"defu\";\nimport type { BuildOptions, OutputChunk } from \"rolldown\";\nimport { build } from \"rolldown\";\nimport { createRolldownPlugin } from \"unplugin\";\n\nexport type BundleOptions = DeepPartial<\n Omit<BuildOptions, \"input\" | \"write\">\n> & {\n name?: string;\n resolve?: DeepPartial<ResolveOptions>;\n};\n\n/**\n * Bundle a type definition to a module.\n *\n * @param context - The context object containing the environment paths.\n * @param file - The file path to bundle.\n * @param options - Optional overrides for the ESBuild configuration.\n * @returns A promise that resolves to the bundled module.\n */\nexport async function bundle<TContext extends UnresolvedContext>(\n context: TContext,\n file: string,\n options: BundleOptions = {}\n): Promise<OutputChunk> {\n const path = await context.fs.resolve(file);\n if (!path || !context.fs.existsSync(path)) {\n throw new Error(\n `Module not found: \"${file}\". Please check the path and try again.`\n );\n }\n\n const userOptions = omit(options, [\"name\", \"resolve\", \"plugins\"]);\n const plugins = await Promise.resolve(options.plugins);\n\n const resolvedOptions = resolveOptions(context);\n\n const result = await build({\n bundle: true,\n platform: \"node\",\n ...resolvedOptions,\n ...userOptions,\n logLevel: \"silent\",\n output: {\n dir: context.config.output.path,\n format: \"es\",\n sourcemap: false,\n codeSplitting: false,\n minify: false,\n keepNames: true,\n exports: \"named\",\n ...userOptions.output\n },\n input: [path],\n write: false,\n plugins: [\n ...(plugins ? toArray(plugins) : []),\n createRolldownPlugin(\n createUnpluginResolver(context, {\n name: options.name ?? `${findFileName(file)} Bundler`,\n prefix: false,\n overrides: defu(\n options.resolve ?? {},\n { skipNodeModulesBundle: false },\n context.config.resolve\n ) as CreateUnpluginResolverOptions[\"overrides\"],\n silenceHookLogging: true\n })\n )()\n ].filter(Boolean)\n } as BuildOptions);\n if (!result.output || result.output.length === 0) {\n throw new Error(\n `No output files generated for ${\n file\n }. Please check the configuration and try again.`\n );\n }\n if (result.output.length > 1) {\n context.warn(\n `Multiple output files generated for \"${\n file\n }\". Only the first file will be used. Please check the configuration to ensure only one output file is generated.`\n );\n }\n\n return result.output[0];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiDA,eAAsB,OACpB,SACA,MACA,UAAyB,CAAC,GACJ;CACtB,MAAM,OAAO,MAAM,QAAQ,GAAG,QAAQ,IAAI;CAC1C,IAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,WAAW,IAAI,GACtC,MAAM,IAAI,MACR,sBAAsB,KAAK,wCAC7B;CAGF,MAAM,cAAc,KAAK,SAAS;EAAC;EAAQ;EAAW;CAAS,CAAC;CAChE,MAAM,UAAU,MAAM,QAAQ,QAAQ,QAAQ,OAAO;CAIrD,MAAM,SAAS,MAAM,MAAM;EACzB,QAAQ;EACR,UAAU;EACV,GALsB,eAAe,OAKpB;EACjB,GAAG;EACH,UAAU;EACV,QAAQ;GACN,KAAK,QAAQ,OAAO,OAAO;GAC3B,QAAQ;GACR,WAAW;GACX,eAAe;GACf,QAAQ;GACR,WAAW;GACX,SAAS;GACT,GAAG,YAAY;EACjB;EACA,OAAO,CAAC,IAAI;EACZ,OAAO;EACP,SAAS,CACP,GAAI,UAAU,QAAQ,OAAO,IAAI,CAAC,GAClC,qBACE,uBAAuB,SAAS;GAC9B,MAAM,QAAQ,QAAQ,GAAG,aAAa,IAAI,EAAE;GAC5C,QAAQ;GACR,WAAW,KACT,QAAQ,WAAW,CAAC,GACpB,EAAE,uBAAuB,MAAM,GAC/B,QAAQ,OAAO,OACjB;GACA,oBAAoB;EACtB,CAAC,CACH,EAAE,CACJ,EAAE,OAAO,OAAO;CAClB,CAAiB;CACjB,IAAI,CAAC,OAAO,UAAU,OAAO,OAAO,WAAW,GAC7C,MAAM,IAAI,MACR,iCACE,KACD,gDACH;CAEF,IAAI,OAAO,OAAO,SAAS,GACzB,QAAQ,KACN,wCACE,KACD,iHACH;CAGF,OAAO,OAAO,OAAO;AACvB"}
1
+ {"version":3,"file":"bundle.mjs","names":[],"sources":["../src/bundle.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n CreateUnpluginResolverOptions,\n ResolveOptions,\n UnresolvedContext\n} from \"@powerlines/core\";\nimport { createUnpluginResolver } from \"@powerlines/core/lib/unplugin\";\nimport { resolveOptions } from \"@powerlines/unplugin/rolldown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { DeepPartial } from \"@stryke/types/base\";\nimport defu from \"defu\";\nimport type { BuildOptions, OutputChunk } from \"rolldown\";\nimport { build } from \"rolldown\";\nimport { createRolldownPlugin } from \"unplugin\";\n\nexport type BundleOptions = DeepPartial<\n Omit<BuildOptions, \"input\" | \"write\">\n> & {\n name?: string;\n resolve?: DeepPartial<ResolveOptions>;\n};\n\n/**\n * Bundle a type definition to a module.\n *\n * @param context - The context object containing the environment paths.\n * @param file - The file path to bundle.\n * @param options - Optional overrides for the Rolldown configuration.\n * @returns A promise that resolves to the bundled module.\n */\nexport async function bundle<TContext extends UnresolvedContext>(\n context: TContext,\n file: string,\n options: BundleOptions = {}\n): Promise<OutputChunk> {\n const path = await context.fs.resolve(file);\n if (!path || !context.fs.existsSync(path)) {\n throw new Error(\n `Module not found: \"${file}\". Please check the path and try again.`\n );\n }\n\n const userOptions = omit(options, [\"name\", \"resolve\", \"plugins\"]);\n const plugins = await Promise.resolve(options.plugins);\n\n const resolvedOptions = resolveOptions(context);\n\n const result = await build({\n bundle: true,\n platform: \"node\",\n ...resolvedOptions,\n ...userOptions,\n logLevel: \"silent\",\n output: {\n dir: context.config.output.path,\n format: \"es\",\n sourcemap: false,\n codeSplitting: false,\n minify: false,\n keepNames: true,\n exports: \"named\",\n ...userOptions.output\n },\n input: [path],\n write: false,\n plugins: [\n ...(plugins ? toArray(plugins) : []),\n createRolldownPlugin(\n createUnpluginResolver(context, {\n name: options.name ?? `${findFileName(file)} Bundler`,\n prefix: false,\n overrides: defu(\n options.resolve ?? {},\n { skipNodeModulesBundle: false },\n context.config.resolve\n ) as CreateUnpluginResolverOptions[\"overrides\"],\n silenceHookLogging: true\n })\n )()\n ].filter(Boolean)\n } as BuildOptions);\n if (!result.output || result.output.length === 0) {\n throw new Error(\n `No output files generated for ${\n file\n }. Please check the configuration and try again.`\n );\n }\n if (result.output.length > 1) {\n context.warn(\n `Multiple output files generated for \"${\n file\n }\". Only the first file will be used. Please check the configuration to ensure only one output file is generated.`\n );\n }\n\n return result.output[0];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiDA,eAAsB,OACpB,SACA,MACA,UAAyB,CAAC,GACJ;CACtB,MAAM,OAAO,MAAM,QAAQ,GAAG,QAAQ,IAAI;CAC1C,IAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,WAAW,IAAI,GACtC,MAAM,IAAI,MACR,sBAAsB,KAAK,wCAC7B;CAGF,MAAM,cAAc,KAAK,SAAS;EAAC;EAAQ;EAAW;CAAS,CAAC;CAChE,MAAM,UAAU,MAAM,QAAQ,QAAQ,QAAQ,OAAO;CAIrD,MAAM,SAAS,MAAM,MAAM;EACzB,QAAQ;EACR,UAAU;EACV,GALsB,eAAe,OAKpB;EACjB,GAAG;EACH,UAAU;EACV,QAAQ;GACN,KAAK,QAAQ,OAAO,OAAO;GAC3B,QAAQ;GACR,WAAW;GACX,eAAe;GACf,QAAQ;GACR,WAAW;GACX,SAAS;GACT,GAAG,YAAY;EACjB;EACA,OAAO,CAAC,IAAI;EACZ,OAAO;EACP,SAAS,CACP,GAAI,UAAU,QAAQ,OAAO,IAAI,CAAC,GAClC,qBACE,uBAAuB,SAAS;GAC9B,MAAM,QAAQ,QAAQ,GAAG,aAAa,IAAI,EAAE;GAC5C,QAAQ;GACR,WAAW,KACT,QAAQ,WAAW,CAAC,GACpB,EAAE,uBAAuB,MAAM,GAC/B,QAAQ,OAAO,OACjB;GACA,oBAAoB;EACtB,CAAC,CACH,EAAE,CACJ,EAAE,OAAO,OAAO;CAClB,CAAiB;CACjB,IAAI,CAAC,OAAO,UAAU,OAAO,OAAO,WAAW,GAC7C,MAAM,IAAI,MACR,iCACE,KACD,gDACH;CAEF,IAAI,OAAO,OAAO,SAAS,GACzB,QAAQ,KACN,wCACE,KACD,iHACH;CAGF,OAAO,OAAO,OAAO;AACvB"}
package/dist/codegen.cjs CHANGED
@@ -4,6 +4,7 @@ const require_type_checks = require('./type-checks.cjs');
4
4
  const require_helpers = require('./helpers.cjs');
5
5
  const require_validate = require('./validate.cjs');
6
6
  let _stryke_convert_to_bool = require("@stryke/convert/to-bool");
7
+ let _stryke_type_checks = require("@stryke/type-checks");
7
8
  let _stryke_type_checks_is_boolean = require("@stryke/type-checks/is-boolean");
8
9
  let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
9
10
  let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
@@ -24,44 +25,49 @@ function stringifyValue(value, type) {
24
25
  */
25
26
  function stringifyType(schema) {
26
27
  if (!schema) return "unknown";
27
- if ((0, _stryke_type_checks_is_set_string.isSetString)(schema.$ref)) return /^#\/(?:definitions|\$defs)\/(.+)$/.exec(schema.$ref)?.[1] ?? schema.$ref;
28
+ if (typeof schema === "boolean") return schema ? "unknown" : "never";
29
+ const objectSchema = schema;
30
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(objectSchema.$ref)) return /^#\/(?:definitions|\$defs)\/(.+)$/.exec(objectSchema.$ref)?.[1] ?? objectSchema.$ref;
28
31
  const primaryType = require_metadata.getPrimarySchemaType(schema);
29
32
  if (primaryType) {
30
33
  if (primaryType === "integer" || primaryType === "number") return "number";
31
34
  return primaryType;
32
35
  }
33
- if (schema.type === "array" && Array.isArray(schema.enum)) return schema.enum.map((value) => JSON.stringify(value)).join(" | ");
34
- if (schema.const !== void 0) return JSON.stringify(schema.const);
35
- if (schema.type === "array" || schema.items) return `${stringifyType(Array.isArray(schema.items) ? schema.items[0] : schema.items)}[]`;
36
- if (schema.type === "object" || schema.properties || schema.additionalProperties) {
37
- if (require_type_checks.isJsonSchema(schema.additionalProperties)) return `{ [key: string]: ${stringifyType(schema.additionalProperties)} }`;
38
- if (require_type_checks.isJsonSchemaObject(schema)) return `{ ${require_helpers.getPropertiesList(schema).map((property) => {
39
- const suffix = schema.required?.includes(property.name) || property.nullable ? `${property.optional ? "?" : ""}${property.nullable ? " | null" : ""}` : "";
40
- return `${property.name}${suffix}: ${stringifyType(property)}`;
41
- }).join(";\n")} }`;
36
+ if (objectSchema.type === "array" && Array.isArray(objectSchema.enum)) return objectSchema.enum.map((value) => JSON.stringify(value)).join(" | ");
37
+ if (objectSchema.const !== void 0) return JSON.stringify(objectSchema.const);
38
+ if (objectSchema.type === "array" || objectSchema.items) return `${stringifyType(objectSchema.items)}[]`;
39
+ if (objectSchema.type === "object" || objectSchema.properties || objectSchema.additionalProperties) {
40
+ if (require_type_checks.isJsonSchema(objectSchema.additionalProperties)) return `{ [key: string]: ${stringifyType(objectSchema.additionalProperties)} }`;
41
+ if (require_type_checks.isJsonSchemaObject(objectSchema)) {
42
+ const required = objectSchema.required ?? [];
43
+ return `{ ${require_helpers.getPropertiesList(objectSchema).map((property) => {
44
+ const suffix = !required.includes(property.name) || require_helpers.isSchemaNullable(property) ? `${!required.includes(property.name) ? "?" : ""}${require_helpers.isSchemaNullable(property) ? " | null" : ""}` : "";
45
+ return `${property.name}${suffix}: ${stringifyType(property)}`;
46
+ }).join(";\n")} }`;
47
+ }
42
48
  }
43
- if (schema.oneOf || schema.anyOf) return (schema.oneOf ?? schema.anyOf ?? []).map((branch) => stringifyType(branch)).join(" | ");
44
- if (schema.allOf) return "object";
49
+ if (objectSchema.oneOf || objectSchema.anyOf) return (objectSchema.oneOf ?? objectSchema.anyOf ?? []).map((branch) => stringifyType(branch)).join(" | ");
50
+ if (objectSchema.allOf) return "object";
45
51
  return "unknown";
46
52
  }
47
53
  /**
48
- * Generates standalone JSON Schema validation code using Ajv.
54
+ * Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.
55
+ *
56
+ * @param value - The value whose type is to be represented as a string.
57
+ * @returns A string representation of the value's type, which may be influenced by the provided JSON Schema primitive type hint. The function handles various JavaScript types and formats them accordingly, including special handling for `undefined`, `null`, booleans, numbers (with formatting), strings, objects, and arrays. If a specific type hint is provided, it will take precedence in determining the string representation of the value.
49
58
  */
50
- async function generateCode(schemas, refsOrFuncts) {
51
- return (0, ajv_dist_standalone_index_js.default)(require_validate.getValidator(schemas), refsOrFuncts);
59
+ function getJsonSchemaType(value) {
60
+ return (0, _stryke_type_checks_is_null.isNull)(value) ? "null" : (0, _stryke_type_checks_is_boolean.isBoolean)(value) ? "boolean" : (0, _stryke_type_checks.isInteger)(value) ? "integer" : (0, _stryke_type_checks_is_number.isNumber)(value) ? "number" : (0, _stryke_type_checks.isString)(value) ? "string" : (0, _stryke_type_checks.isObject)(value) ? "object" : Array.isArray(value) ? "array" : void 0;
52
61
  }
53
62
  /**
54
- * A helper function to determine if a JSON Schema fragment is nullable, for use in code generation.
55
- *
56
- * @param schema - The JSON Schema fragment to check.
57
- * @returns `true` if the schema is nullable, otherwise `false`. A schema is considered nullable if it has `nullable: true` or if its `type` includes `"null"`.
63
+ * Generates standalone JSON Schema validation code using Ajv.
58
64
  */
59
- function isNullableSchema(schema) {
60
- return require_metadata.isSchemaNullable(schema);
65
+ async function generateCode(schemas, refsOrFuncts) {
66
+ return (0, ajv_dist_standalone_index_js.default)(require_validate.getValidator(schemas), refsOrFuncts);
61
67
  }
62
68
 
63
69
  //#endregion
64
70
  exports.generateCode = generateCode;
65
- exports.isNullableSchema = isNullableSchema;
71
+ exports.getJsonSchemaType = getJsonSchemaType;
66
72
  exports.stringifyType = stringifyType;
67
73
  exports.stringifyValue = stringifyValue;
@@ -1,26 +1,26 @@
1
- import { JsonSchema, JsonSchemaPrimitiveType } from "./types.cjs";
1
+ import { JsonSchema, JsonSchemaType } from "./types.cjs";
2
2
  import standaloneCode from "ajv/dist/standalone/index.js";
3
3
 
4
4
  //#region src/codegen.d.ts
5
5
  /**
6
6
  * Stringifies a value for generated TypeScript code.
7
7
  */
8
- declare function stringifyValue(value?: unknown, type?: JsonSchemaPrimitiveType | string): string;
8
+ declare function stringifyValue(value?: unknown, type?: JsonSchemaType | string): string;
9
9
  /**
10
10
  * Stringifies a JSON Schema fragment into a TypeScript-like type string.
11
11
  */
12
- declare function stringifyType<T = unknown>(schema?: JsonSchema<T>): string;
12
+ declare function stringifyType(schema?: JsonSchema): string;
13
13
  /**
14
- * Generates standalone JSON Schema validation code using Ajv.
14
+ * Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.
15
+ *
16
+ * @param value - The value whose type is to be represented as a string.
17
+ * @returns A string representation of the value's type, which may be influenced by the provided JSON Schema primitive type hint. The function handles various JavaScript types and formats them accordingly, including special handling for `undefined`, `null`, booleans, numbers (with formatting), strings, objects, and arrays. If a specific type hint is provided, it will take precedence in determining the string representation of the value.
15
18
  */
16
- declare function generateCode<T = unknown>(schemas: JsonSchema<T>, refsOrFuncts?: Parameters<typeof standaloneCode>[1]): Promise<string>;
19
+ declare function getJsonSchemaType(value?: unknown): JsonSchemaType | undefined;
17
20
  /**
18
- * A helper function to determine if a JSON Schema fragment is nullable, for use in code generation.
19
- *
20
- * @param schema - The JSON Schema fragment to check.
21
- * @returns `true` if the schema is nullable, otherwise `false`. A schema is considered nullable if it has `nullable: true` or if its `type` includes `"null"`.
21
+ * Generates standalone JSON Schema validation code using Ajv.
22
22
  */
23
- declare function isNullableSchema(schema?: JsonSchema): boolean;
23
+ declare function generateCode(schemas: JsonSchema, refsOrFuncts?: Parameters<typeof standaloneCode>[1]): Promise<string>;
24
24
  //#endregion
25
- export { generateCode, isNullableSchema, stringifyType, stringifyValue };
25
+ export { generateCode, getJsonSchemaType, stringifyType, stringifyValue };
26
26
  //# sourceMappingURL=codegen.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.d.cts","names":[],"sources":["../src/codegen.ts"],"mappings":";;;;;;AAkCA;iBAAgB,cAAA,CACd,KAAA,YACA,IAAA,GAAO,uBAAuB;;;;iBAsBhB,aAAA,aAAA,CAA2B,MAAA,GAAS,UAAU,CAAC,CAAA;;;AAtBtB;iBA+FnB,YAAA,aAAA,CACpB,OAAA,EAAS,UAAA,CAAW,CAAA,GACpB,YAAA,GAAe,UAAA,QAAkB,cAAA,OAAkB,OAAA;;;;;;;iBAarC,gBAAA,CAAiB,MAAmB,GAAV,UAAU"}
1
+ {"version":3,"file":"codegen.d.cts","names":[],"sources":["../src/codegen.ts"],"mappings":";;;;;;AAiDA;iBAAgB,cAAA,CACd,KAAA,YACA,IAAA,GAAO,cAAc;;;;iBAsBP,aAAA,CAAc,MAAmB,GAAV,UAAU;;;AAtBjB;AAsBhC;;;iBAsFgB,iBAAA,CAAkB,KAAA,aAAkB,cAAc;AAtFjB;AAsFjD;;AAtFiD,iBA2G3B,YAAA,CACpB,OAAA,EAAS,UAAA,EACT,YAAA,GAAe,UAAA,QAAkB,cAAA,OAAkB,OAAA"}
@@ -1,26 +1,26 @@
1
- import { JsonSchema, JsonSchemaPrimitiveType } from "./types.mjs";
1
+ import { JsonSchema, JsonSchemaType } from "./types.mjs";
2
2
  import standaloneCode from "ajv/dist/standalone/index.js";
3
3
 
4
4
  //#region src/codegen.d.ts
5
5
  /**
6
6
  * Stringifies a value for generated TypeScript code.
7
7
  */
8
- declare function stringifyValue(value?: unknown, type?: JsonSchemaPrimitiveType | string): string;
8
+ declare function stringifyValue(value?: unknown, type?: JsonSchemaType | string): string;
9
9
  /**
10
10
  * Stringifies a JSON Schema fragment into a TypeScript-like type string.
11
11
  */
12
- declare function stringifyType<T = unknown>(schema?: JsonSchema<T>): string;
12
+ declare function stringifyType(schema?: JsonSchema): string;
13
13
  /**
14
- * Generates standalone JSON Schema validation code using Ajv.
14
+ * Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.
15
+ *
16
+ * @param value - The value whose type is to be represented as a string.
17
+ * @returns A string representation of the value's type, which may be influenced by the provided JSON Schema primitive type hint. The function handles various JavaScript types and formats them accordingly, including special handling for `undefined`, `null`, booleans, numbers (with formatting), strings, objects, and arrays. If a specific type hint is provided, it will take precedence in determining the string representation of the value.
15
18
  */
16
- declare function generateCode<T = unknown>(schemas: JsonSchema<T>, refsOrFuncts?: Parameters<typeof standaloneCode>[1]): Promise<string>;
19
+ declare function getJsonSchemaType(value?: unknown): JsonSchemaType | undefined;
17
20
  /**
18
- * A helper function to determine if a JSON Schema fragment is nullable, for use in code generation.
19
- *
20
- * @param schema - The JSON Schema fragment to check.
21
- * @returns `true` if the schema is nullable, otherwise `false`. A schema is considered nullable if it has `nullable: true` or if its `type` includes `"null"`.
21
+ * Generates standalone JSON Schema validation code using Ajv.
22
22
  */
23
- declare function isNullableSchema(schema?: JsonSchema): boolean;
23
+ declare function generateCode(schemas: JsonSchema, refsOrFuncts?: Parameters<typeof standaloneCode>[1]): Promise<string>;
24
24
  //#endregion
25
- export { generateCode, isNullableSchema, stringifyType, stringifyValue };
25
+ export { generateCode, getJsonSchemaType, stringifyType, stringifyValue };
26
26
  //# sourceMappingURL=codegen.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.d.mts","names":[],"sources":["../src/codegen.ts"],"mappings":";;;;;;AAkCA;iBAAgB,cAAA,CACd,KAAA,YACA,IAAA,GAAO,uBAAuB;;;;iBAsBhB,aAAA,aAAA,CAA2B,MAAA,GAAS,UAAU,CAAC,CAAA;;;AAtBtB;iBA+FnB,YAAA,aAAA,CACpB,OAAA,EAAS,UAAA,CAAW,CAAA,GACpB,YAAA,GAAe,UAAA,QAAkB,cAAA,OAAkB,OAAA;;;;;;;iBAarC,gBAAA,CAAiB,MAAmB,GAAV,UAAU"}
1
+ {"version":3,"file":"codegen.d.mts","names":[],"sources":["../src/codegen.ts"],"mappings":";;;;;;AAiDA;iBAAgB,cAAA,CACd,KAAA,YACA,IAAA,GAAO,cAAc;;;;iBAsBP,aAAA,CAAc,MAAmB,GAAV,UAAU;;;AAtBjB;AAsBhC;;;iBAsFgB,iBAAA,CAAkB,KAAA,aAAkB,cAAc;AAtFjB;AAsFjD;;AAtFiD,iBA2G3B,YAAA,CACpB,OAAA,EAAS,UAAA,EACT,YAAA,GAAe,UAAA,QAAkB,cAAA,OAAkB,OAAA"}
package/dist/codegen.mjs CHANGED
@@ -1,13 +1,14 @@
1
- import { getPrimarySchemaType, isSchemaNullable } from "./metadata.mjs";
1
+ import { getPrimarySchemaType } from "./metadata.mjs";
2
2
  import { isJsonSchema, isJsonSchemaObject } from "./type-checks.mjs";
3
- import { getPropertiesList } from "./helpers.mjs";
3
+ import { getPropertiesList, isSchemaNullable } from "./helpers.mjs";
4
4
  import { getValidator } from "./validate.mjs";
5
5
  import { toBool } from "@stryke/convert/to-bool";
6
- import { isBoolean } from "@stryke/type-checks/is-boolean";
7
- import { isNull } from "@stryke/type-checks/is-null";
8
- import { isNumber } from "@stryke/type-checks/is-number";
9
- import { isSetString } from "@stryke/type-checks/is-set-string";
10
- import { isUndefined } from "@stryke/type-checks/is-undefined";
6
+ import { isInteger, isObject, isString } from "@stryke/type-checks";
7
+ import { isBoolean as isBoolean$1 } from "@stryke/type-checks/is-boolean";
8
+ import { isNull as isNull$1 } from "@stryke/type-checks/is-null";
9
+ import { isNumber as isNumber$1 } from "@stryke/type-checks/is-number";
10
+ import { isSetString as isSetString$1 } from "@stryke/type-checks/is-set-string";
11
+ import { isUndefined as isUndefined$1 } from "@stryke/type-checks/is-undefined";
11
12
  import standaloneCode from "ajv/dist/standalone/index.js";
12
13
 
13
14
  //#region src/codegen.ts
@@ -15,49 +16,54 @@ import standaloneCode from "ajv/dist/standalone/index.js";
15
16
  * Stringifies a value for generated TypeScript code.
16
17
  */
17
18
  function stringifyValue(value, type) {
18
- return isUndefined(value) ? "undefined" : isNull(value) ? "null" : type === "boolean" || isBoolean(value) ? String(toBool(value)) : type === "number" || isNumber(value) ? Number.parseFloat(String(value)).toLocaleString(void 0, { maximumFractionDigits: 20 }) : type === "integer" ? Number.parseInt(String(value)).toLocaleString() : type === "string" || type === "object" || type === "array" ? JSON.stringify(value) : String(value);
19
+ return isUndefined$1(value) ? "undefined" : isNull$1(value) ? "null" : type === "boolean" || isBoolean$1(value) ? String(toBool(value)) : type === "number" || isNumber$1(value) ? Number.parseFloat(String(value)).toLocaleString(void 0, { maximumFractionDigits: 20 }) : type === "integer" ? Number.parseInt(String(value)).toLocaleString() : type === "string" || type === "object" || type === "array" ? JSON.stringify(value) : String(value);
19
20
  }
20
21
  /**
21
22
  * Stringifies a JSON Schema fragment into a TypeScript-like type string.
22
23
  */
23
24
  function stringifyType(schema) {
24
25
  if (!schema) return "unknown";
25
- if (isSetString(schema.$ref)) return /^#\/(?:definitions|\$defs)\/(.+)$/.exec(schema.$ref)?.[1] ?? schema.$ref;
26
+ if (typeof schema === "boolean") return schema ? "unknown" : "never";
27
+ const objectSchema = schema;
28
+ if (isSetString$1(objectSchema.$ref)) return /^#\/(?:definitions|\$defs)\/(.+)$/.exec(objectSchema.$ref)?.[1] ?? objectSchema.$ref;
26
29
  const primaryType = getPrimarySchemaType(schema);
27
30
  if (primaryType) {
28
31
  if (primaryType === "integer" || primaryType === "number") return "number";
29
32
  return primaryType;
30
33
  }
31
- if (schema.type === "array" && Array.isArray(schema.enum)) return schema.enum.map((value) => JSON.stringify(value)).join(" | ");
32
- if (schema.const !== void 0) return JSON.stringify(schema.const);
33
- if (schema.type === "array" || schema.items) return `${stringifyType(Array.isArray(schema.items) ? schema.items[0] : schema.items)}[]`;
34
- if (schema.type === "object" || schema.properties || schema.additionalProperties) {
35
- if (isJsonSchema(schema.additionalProperties)) return `{ [key: string]: ${stringifyType(schema.additionalProperties)} }`;
36
- if (isJsonSchemaObject(schema)) return `{ ${getPropertiesList(schema).map((property) => {
37
- const suffix = schema.required?.includes(property.name) || property.nullable ? `${property.optional ? "?" : ""}${property.nullable ? " | null" : ""}` : "";
38
- return `${property.name}${suffix}: ${stringifyType(property)}`;
39
- }).join(";\n")} }`;
34
+ if (objectSchema.type === "array" && Array.isArray(objectSchema.enum)) return objectSchema.enum.map((value) => JSON.stringify(value)).join(" | ");
35
+ if (objectSchema.const !== void 0) return JSON.stringify(objectSchema.const);
36
+ if (objectSchema.type === "array" || objectSchema.items) return `${stringifyType(objectSchema.items)}[]`;
37
+ if (objectSchema.type === "object" || objectSchema.properties || objectSchema.additionalProperties) {
38
+ if (isJsonSchema(objectSchema.additionalProperties)) return `{ [key: string]: ${stringifyType(objectSchema.additionalProperties)} }`;
39
+ if (isJsonSchemaObject(objectSchema)) {
40
+ const required = objectSchema.required ?? [];
41
+ return `{ ${getPropertiesList(objectSchema).map((property) => {
42
+ const suffix = !required.includes(property.name) || isSchemaNullable(property) ? `${!required.includes(property.name) ? "?" : ""}${isSchemaNullable(property) ? " | null" : ""}` : "";
43
+ return `${property.name}${suffix}: ${stringifyType(property)}`;
44
+ }).join(";\n")} }`;
45
+ }
40
46
  }
41
- if (schema.oneOf || schema.anyOf) return (schema.oneOf ?? schema.anyOf ?? []).map((branch) => stringifyType(branch)).join(" | ");
42
- if (schema.allOf) return "object";
47
+ if (objectSchema.oneOf || objectSchema.anyOf) return (objectSchema.oneOf ?? objectSchema.anyOf ?? []).map((branch) => stringifyType(branch)).join(" | ");
48
+ if (objectSchema.allOf) return "object";
43
49
  return "unknown";
44
50
  }
45
51
  /**
46
- * Generates standalone JSON Schema validation code using Ajv.
52
+ * Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.
53
+ *
54
+ * @param value - The value whose type is to be represented as a string.
55
+ * @returns A string representation of the value's type, which may be influenced by the provided JSON Schema primitive type hint. The function handles various JavaScript types and formats them accordingly, including special handling for `undefined`, `null`, booleans, numbers (with formatting), strings, objects, and arrays. If a specific type hint is provided, it will take precedence in determining the string representation of the value.
47
56
  */
48
- async function generateCode(schemas, refsOrFuncts) {
49
- return standaloneCode(getValidator(schemas), refsOrFuncts);
57
+ function getJsonSchemaType(value) {
58
+ return isNull$1(value) ? "null" : isBoolean$1(value) ? "boolean" : isInteger(value) ? "integer" : isNumber$1(value) ? "number" : isString(value) ? "string" : isObject(value) ? "object" : Array.isArray(value) ? "array" : void 0;
50
59
  }
51
60
  /**
52
- * A helper function to determine if a JSON Schema fragment is nullable, for use in code generation.
53
- *
54
- * @param schema - The JSON Schema fragment to check.
55
- * @returns `true` if the schema is nullable, otherwise `false`. A schema is considered nullable if it has `nullable: true` or if its `type` includes `"null"`.
61
+ * Generates standalone JSON Schema validation code using Ajv.
56
62
  */
57
- function isNullableSchema(schema) {
58
- return isSchemaNullable(schema);
63
+ async function generateCode(schemas, refsOrFuncts) {
64
+ return standaloneCode(getValidator(schemas), refsOrFuncts);
59
65
  }
60
66
 
61
67
  //#endregion
62
- export { generateCode, isNullableSchema, stringifyType, stringifyValue };
68
+ export { generateCode, getJsonSchemaType, stringifyType, stringifyValue };
63
69
  //# sourceMappingURL=codegen.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.mjs","names":[],"sources":["../src/codegen.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toBool } from \"@stryke/convert/to-bool\";\nimport { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isNull } from \"@stryke/type-checks/is-null\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport standaloneCode from \"ajv/dist/standalone\";\nimport { getPropertiesList } from \"./helpers\";\nimport { getPrimarySchemaType, isSchemaNullable } from \"./metadata\";\nimport { isJsonSchema, isJsonSchemaObject } from \"./type-checks\";\nimport { JsonSchema, JsonSchemaPrimitiveType } from \"./types\";\nimport { getValidator } from \"./validate\";\n\n/**\n * Stringifies a value for generated TypeScript code.\n */\nexport function stringifyValue(\n value?: unknown,\n type?: JsonSchemaPrimitiveType | string\n): string {\n return isUndefined(value)\n ? \"undefined\"\n : isNull(value)\n ? \"null\"\n : type === \"boolean\" || isBoolean(value)\n ? String(toBool(value))\n : type === \"number\" || isNumber(value)\n ? Number.parseFloat(String(value)).toLocaleString(undefined, {\n maximumFractionDigits: 20\n })\n : type === \"integer\"\n ? Number.parseInt(String(value)).toLocaleString()\n : type === \"string\" || type === \"object\" || type === \"array\"\n ? JSON.stringify(value)\n : String(value);\n}\n\n/**\n * Stringifies a JSON Schema fragment into a TypeScript-like type string.\n */\nexport function stringifyType<T = unknown>(schema?: JsonSchema<T>): string {\n if (!schema) {\n return \"unknown\";\n }\n\n if (isSetString(schema.$ref)) {\n const match = /^#\\/(?:definitions|\\$defs)\\/(.+)$/.exec(schema.$ref);\n\n return match?.[1] ?? schema.$ref;\n }\n\n const primaryType = getPrimarySchemaType(schema);\n if (primaryType) {\n if (primaryType === \"integer\" || primaryType === \"number\") {\n return \"number\";\n }\n\n return primaryType;\n }\n\n if (schema.type === \"array\" && Array.isArray(schema.enum)) {\n return schema.enum.map(value => JSON.stringify(value)).join(\" | \");\n }\n\n if (schema.const !== undefined) {\n return JSON.stringify(schema.const);\n }\n\n if (schema.type === \"array\" || schema.items) {\n const items = Array.isArray(schema.items) ? schema.items[0] : schema.items;\n\n return `${stringifyType(items)}[]`;\n }\n\n if (\n schema.type === \"object\" ||\n schema.properties ||\n schema.additionalProperties\n ) {\n if (isJsonSchema(schema.additionalProperties)) {\n return `{ [key: string]: ${stringifyType(schema.additionalProperties)} }`;\n }\n\n if (isJsonSchemaObject(schema)) {\n return `{ ${getPropertiesList(schema as JsonSchema<Record<string, any>>)\n .map(property => {\n const suffix =\n schema.required?.includes(property.name) || property.nullable\n ? `${property.optional ? \"?\" : \"\"}${property.nullable ? \" | null\" : \"\"}`\n : \"\";\n\n return `${property.name}${suffix}: ${stringifyType(property)}`;\n })\n .join(\";\\n\")} }`;\n }\n }\n\n if (schema.oneOf || schema.anyOf) {\n return ((schema.oneOf ?? schema.anyOf ?? []) as JsonSchema<T>[])\n .map(branch => stringifyType(branch))\n .join(\" | \");\n }\n\n if (schema.allOf) {\n return \"object\";\n }\n\n return \"unknown\";\n}\n\n/**\n * Generates standalone JSON Schema validation code using Ajv.\n */\nexport async function generateCode<T = unknown>(\n schemas: JsonSchema<T>,\n refsOrFuncts?: Parameters<typeof standaloneCode>[1]\n) {\n const ajv = getValidator(schemas);\n\n return standaloneCode(ajv, refsOrFuncts);\n}\n\n/**\n * A helper function to determine if a JSON Schema fragment is nullable, for use in code generation.\n *\n * @param schema - The JSON Schema fragment to check.\n * @returns `true` if the schema is nullable, otherwise `false`. A schema is considered nullable if it has `nullable: true` or if its `type` includes `\"null\"`.\n */\nexport function isNullableSchema(schema?: JsonSchema): boolean {\n return isSchemaNullable(schema);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAgB,eACd,OACA,MACQ;CACR,OAAO,YAAY,KAAK,IACpB,cACA,OAAO,KAAK,IACV,SACA,SAAS,aAAa,UAAU,KAAK,IACnC,OAAO,OAAO,KAAK,CAAC,IACpB,SAAS,YAAY,SAAS,KAAK,IACjC,OAAO,WAAW,OAAO,KAAK,CAAC,EAAE,eAAe,QAAW,EACzD,uBAAuB,GACzB,CAAC,IACD,SAAS,YACP,OAAO,SAAS,OAAO,KAAK,CAAC,EAAE,eAAe,IAC9C,SAAS,YAAY,SAAS,YAAY,SAAS,UACjD,KAAK,UAAU,KAAK,IACpB,OAAO,KAAK;AAC5B;;;;AAKA,SAAgB,cAA2B,QAAgC;CACzE,IAAI,CAAC,QACH,OAAO;CAGT,IAAI,YAAY,OAAO,IAAI,GAGzB,OAFc,oCAAoC,KAAK,OAAO,IAEnD,IAAI,MAAM,OAAO;CAG9B,MAAM,cAAc,qBAAqB,MAAM;CAC/C,IAAI,aAAa;EACf,IAAI,gBAAgB,aAAa,gBAAgB,UAC/C,OAAO;EAGT,OAAO;CACT;CAEA,IAAI,OAAO,SAAS,WAAW,MAAM,QAAQ,OAAO,IAAI,GACtD,OAAO,OAAO,KAAK,KAAI,UAAS,KAAK,UAAU,KAAK,CAAC,EAAE,KAAK,KAAK;CAGnE,IAAI,OAAO,UAAU,QACnB,OAAO,KAAK,UAAU,OAAO,KAAK;CAGpC,IAAI,OAAO,SAAS,WAAW,OAAO,OAGpC,OAAO,GAAG,cAFI,MAAM,QAAQ,OAAO,KAAK,IAAI,OAAO,MAAM,KAAK,OAAO,KAExC,EAAE;CAGjC,IACE,OAAO,SAAS,YAChB,OAAO,cACP,OAAO,sBACP;EACA,IAAI,aAAa,OAAO,oBAAoB,GAC1C,OAAO,oBAAoB,cAAc,OAAO,oBAAoB,EAAE;EAGxE,IAAI,mBAAmB,MAAM,GAC3B,OAAO,KAAK,kBAAkB,MAAyC,EACpE,KAAI,aAAY;GACf,MAAM,SACJ,OAAO,UAAU,SAAS,SAAS,IAAI,KAAK,SAAS,WACjD,GAAG,SAAS,WAAW,MAAM,KAAK,SAAS,WAAW,YAAY,OAClE;GAEN,OAAO,GAAG,SAAS,OAAO,OAAO,IAAI,cAAc,QAAQ;EAC7D,CAAC,EACA,KAAK,KAAK,EAAE;CAEnB;CAEA,IAAI,OAAO,SAAS,OAAO,OACzB,QAAS,OAAO,SAAS,OAAO,SAAS,CAAC,GACvC,KAAI,WAAU,cAAc,MAAM,CAAC,EACnC,KAAK,KAAK;CAGf,IAAI,OAAO,OACT,OAAO;CAGT,OAAO;AACT;;;;AAKA,eAAsB,aACpB,SACA,cACA;CAGA,OAAO,eAFK,aAAa,OAED,GAAG,YAAY;AACzC;;;;;;;AAQA,SAAgB,iBAAiB,QAA8B;CAC7D,OAAO,iBAAiB,MAAM;AAChC"}
1
+ {"version":3,"file":"codegen.mjs","names":["isUndefined","isNull","isBoolean","isNumber","isSetString"],"sources":["../src/codegen.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toBool } from \"@stryke/convert/to-bool\";\nimport { isInteger, isObject, isString } from \"@stryke/type-checks\";\nimport { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isNull } from \"@stryke/type-checks/is-null\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport standaloneCode from \"ajv/dist/standalone\";\nimport { getPropertiesList, isSchemaNullable } from \"./helpers\";\nimport { getPrimarySchemaType } from \"./metadata\";\nimport { isJsonSchema, isJsonSchemaObject } from \"./type-checks\";\nimport { JsonSchema, JsonSchemaType } from \"./types\";\nimport { getValidator } from \"./validate\";\n\ninterface JsonSchemaObjectView {\n $ref?: string;\n type?: JsonSchemaType | readonly JsonSchemaType[];\n enum?: readonly unknown[];\n const?: unknown;\n items?: JsonSchema;\n properties?: Record<string, JsonSchema>;\n additionalProperties?: boolean | JsonSchema;\n required?: string[];\n oneOf?: JsonSchema[];\n anyOf?: JsonSchema[];\n allOf?: JsonSchema[];\n}\n\n/**\n * Stringifies a value for generated TypeScript code.\n */\nexport function stringifyValue(\n value?: unknown,\n type?: JsonSchemaType | string\n): string {\n return isUndefined(value)\n ? \"undefined\"\n : isNull(value)\n ? \"null\"\n : type === \"boolean\" || isBoolean(value)\n ? String(toBool(value))\n : type === \"number\" || isNumber(value)\n ? Number.parseFloat(String(value)).toLocaleString(undefined, {\n maximumFractionDigits: 20\n })\n : type === \"integer\"\n ? Number.parseInt(String(value)).toLocaleString()\n : type === \"string\" || type === \"object\" || type === \"array\"\n ? JSON.stringify(value)\n : String(value);\n}\n\n/**\n * Stringifies a JSON Schema fragment into a TypeScript-like type string.\n */\nexport function stringifyType(schema?: JsonSchema): string {\n if (!schema) {\n return \"unknown\";\n }\n\n if (typeof schema === \"boolean\") {\n return schema ? \"unknown\" : \"never\";\n }\n\n const objectSchema = schema as JsonSchemaObjectView;\n\n if (isSetString(objectSchema.$ref)) {\n const match = /^#\\/(?:definitions|\\$defs)\\/(.+)$/.exec(objectSchema.$ref);\n\n return match?.[1] ?? objectSchema.$ref;\n }\n\n const primaryType = getPrimarySchemaType(schema);\n if (primaryType) {\n if (primaryType === \"integer\" || primaryType === \"number\") {\n return \"number\";\n }\n\n return primaryType;\n }\n\n if (objectSchema.type === \"array\" && Array.isArray(objectSchema.enum)) {\n const enumValues = objectSchema.enum as readonly unknown[];\n\n return enumValues\n .map((value: unknown) => JSON.stringify(value))\n .join(\" | \");\n }\n\n if (objectSchema.const !== undefined) {\n return JSON.stringify(objectSchema.const);\n }\n\n if (objectSchema.type === \"array\" || objectSchema.items) {\n return `${stringifyType(objectSchema.items)}[]`;\n }\n\n if (\n objectSchema.type === \"object\" ||\n objectSchema.properties ||\n objectSchema.additionalProperties\n ) {\n if (isJsonSchema(objectSchema.additionalProperties)) {\n return `{ [key: string]: ${stringifyType(objectSchema.additionalProperties)} }`;\n }\n\n if (isJsonSchemaObject(objectSchema)) {\n const required = objectSchema.required ?? [];\n\n return `{ ${getPropertiesList(objectSchema)\n .map(property => {\n const suffix =\n !required.includes(property.name) || isSchemaNullable(property)\n ? `${!required.includes(property.name) ? \"?\" : \"\"}${isSchemaNullable(property) ? \" | null\" : \"\"}`\n : \"\";\n\n return `${property.name}${suffix}: ${stringifyType(property)}`;\n })\n .join(\";\\n\")} }`;\n }\n }\n\n if (objectSchema.oneOf || objectSchema.anyOf) {\n return (objectSchema.oneOf ?? objectSchema.anyOf ?? [])\n .map(branch => stringifyType(branch))\n .join(\" | \");\n }\n\n if (objectSchema.allOf) {\n return \"object\";\n }\n\n return \"unknown\";\n}\n\n/**\n * Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.\n *\n * @param value - The value whose type is to be represented as a string.\n * @returns A string representation of the value's type, which may be influenced by the provided JSON Schema primitive type hint. The function handles various JavaScript types and formats them accordingly, including special handling for `undefined`, `null`, booleans, numbers (with formatting), strings, objects, and arrays. If a specific type hint is provided, it will take precedence in determining the string representation of the value.\n */\nexport function getJsonSchemaType(value?: unknown): JsonSchemaType | undefined {\n return isNull(value)\n ? \"null\"\n : isBoolean(value)\n ? \"boolean\"\n : isInteger(value)\n ? \"integer\"\n : isNumber(value)\n ? \"number\"\n : isString(value)\n ? \"string\"\n : isObject(value)\n ? \"object\"\n : Array.isArray(value)\n ? \"array\"\n : undefined;\n}\n\n/**\n * Generates standalone JSON Schema validation code using Ajv.\n */\nexport async function generateCode(\n schemas: JsonSchema,\n refsOrFuncts?: Parameters<typeof standaloneCode>[1]\n) {\n const ajv = getValidator(schemas);\n\n return standaloneCode(ajv, refsOrFuncts);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiDA,SAAgB,eACd,OACA,MACQ;CACR,OAAOA,cAAY,KAAK,IACpB,cACAC,SAAO,KAAK,IACV,SACA,SAAS,aAAaC,YAAU,KAAK,IACnC,OAAO,OAAO,KAAK,CAAC,IACpB,SAAS,YAAYC,WAAS,KAAK,IACjC,OAAO,WAAW,OAAO,KAAK,CAAC,EAAE,eAAe,QAAW,EACzD,uBAAuB,GACzB,CAAC,IACD,SAAS,YACP,OAAO,SAAS,OAAO,KAAK,CAAC,EAAE,eAAe,IAC9C,SAAS,YAAY,SAAS,YAAY,SAAS,UACjD,KAAK,UAAU,KAAK,IACpB,OAAO,KAAK;AAC5B;;;;AAKA,SAAgB,cAAc,QAA6B;CACzD,IAAI,CAAC,QACH,OAAO;CAGT,IAAI,OAAO,WAAW,WACpB,OAAO,SAAS,YAAY;CAG9B,MAAM,eAAe;CAErB,IAAIC,cAAY,aAAa,IAAI,GAG/B,OAFc,oCAAoC,KAAK,aAAa,IAEzD,IAAI,MAAM,aAAa;CAGpC,MAAM,cAAc,qBAAqB,MAAM;CAC/C,IAAI,aAAa;EACf,IAAI,gBAAgB,aAAa,gBAAgB,UAC/C,OAAO;EAGT,OAAO;CACT;CAEA,IAAI,aAAa,SAAS,WAAW,MAAM,QAAQ,aAAa,IAAI,GAGlE,OAFmB,aAAa,KAG7B,KAAK,UAAmB,KAAK,UAAU,KAAK,CAAC,EAC7C,KAAK,KAAK;CAGf,IAAI,aAAa,UAAU,QACzB,OAAO,KAAK,UAAU,aAAa,KAAK;CAG1C,IAAI,aAAa,SAAS,WAAW,aAAa,OAChD,OAAO,GAAG,cAAc,aAAa,KAAK,EAAE;CAG9C,IACE,aAAa,SAAS,YACtB,aAAa,cACb,aAAa,sBACb;EACA,IAAI,aAAa,aAAa,oBAAoB,GAChD,OAAO,oBAAoB,cAAc,aAAa,oBAAoB,EAAE;EAG9E,IAAI,mBAAmB,YAAY,GAAG;GACpC,MAAM,WAAW,aAAa,YAAY,CAAC;GAE3C,OAAO,KAAK,kBAAkB,YAAY,EACvC,KAAI,aAAY;IACf,MAAM,SACJ,CAAC,SAAS,SAAS,SAAS,IAAI,KAAK,iBAAiB,QAAQ,IAC1D,GAAG,CAAC,SAAS,SAAS,SAAS,IAAI,IAAI,MAAM,KAAK,iBAAiB,QAAQ,IAAI,YAAY,OAC3F;IAEN,OAAO,GAAG,SAAS,OAAO,OAAO,IAAI,cAAc,QAAQ;GAC7D,CAAC,EACA,KAAK,KAAK,EAAE;EACjB;CACF;CAEA,IAAI,aAAa,SAAS,aAAa,OACrC,QAAQ,aAAa,SAAS,aAAa,SAAS,CAAC,GAClD,KAAI,WAAU,cAAc,MAAM,CAAC,EACnC,KAAK,KAAK;CAGf,IAAI,aAAa,OACf,OAAO;CAGT,OAAO;AACT;;;;;;;AAQA,SAAgB,kBAAkB,OAA6C;CAC7E,OAAOH,SAAO,KAAK,IACf,SACAC,YAAU,KAAK,IACb,YACA,UAAU,KAAK,IACb,YACAC,WAAS,KAAK,IACZ,WACA,SAAS,KAAK,IACZ,WACA,SAAS,KAAK,IACZ,WACA,MAAM,QAAQ,KAAK,IACjB,UACA;AAClB;;;;AAKA,eAAsB,aACpB,SACA,cACA;CAGA,OAAO,eAFK,aAAa,OAED,GAAG,YAAY;AACzC"}
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region src/constants.ts
3
- const JsonSchemaTypes = {
3
+ const JsonSchemaTypeNames = {
4
4
  STRING: "string",
5
5
  NUMBER: "number",
6
6
  INTEGER: "integer",
@@ -9,14 +9,17 @@ const JsonSchemaTypes = {
9
9
  OBJECT: "object",
10
10
  ARRAY: "array"
11
11
  };
12
- const JSON_SCHEMA_DATA_TYPES = [
13
- JsonSchemaTypes.STRING,
14
- JsonSchemaTypes.NUMBER,
15
- JsonSchemaTypes.INTEGER,
16
- JsonSchemaTypes.BOOLEAN,
17
- JsonSchemaTypes.ARRAY,
18
- JsonSchemaTypes.OBJECT,
19
- JsonSchemaTypes.NULL
12
+ const JSON_SCHEMA_PRIMITIVE_TYPES = [
13
+ JsonSchemaTypeNames.STRING,
14
+ JsonSchemaTypeNames.NUMBER,
15
+ JsonSchemaTypeNames.INTEGER,
16
+ JsonSchemaTypeNames.BOOLEAN,
17
+ JsonSchemaTypeNames.NULL
18
+ ];
19
+ const JSON_SCHEMA_TYPES = [
20
+ ...JSON_SCHEMA_PRIMITIVE_TYPES,
21
+ JsonSchemaTypeNames.ARRAY,
22
+ JsonSchemaTypeNames.OBJECT
20
23
  ];
21
24
  const JSON_SCHEMA_METADATA_KEYS = [
22
25
  "docs",
@@ -35,6 +38,7 @@ const JSON_SCHEMA_METADATA_KEYS = [
35
38
  ];
36
39
 
37
40
  //#endregion
38
- exports.JSON_SCHEMA_DATA_TYPES = JSON_SCHEMA_DATA_TYPES;
39
41
  exports.JSON_SCHEMA_METADATA_KEYS = JSON_SCHEMA_METADATA_KEYS;
40
- exports.JsonSchemaTypes = JsonSchemaTypes;
42
+ exports.JSON_SCHEMA_PRIMITIVE_TYPES = JSON_SCHEMA_PRIMITIVE_TYPES;
43
+ exports.JSON_SCHEMA_TYPES = JSON_SCHEMA_TYPES;
44
+ exports.JsonSchemaTypeNames = JsonSchemaTypeNames;
@@ -1,5 +1,5 @@
1
1
  //#region src/constants.d.ts
2
- declare const JsonSchemaTypes: {
2
+ declare const JsonSchemaTypeNames: {
3
3
  readonly STRING: "string";
4
4
  readonly NUMBER: "number";
5
5
  readonly INTEGER: "integer";
@@ -8,8 +8,9 @@ declare const JsonSchemaTypes: {
8
8
  readonly OBJECT: "object";
9
9
  readonly ARRAY: "array";
10
10
  };
11
- declare const JSON_SCHEMA_DATA_TYPES: readonly ["string", "number", "integer", "boolean", "array", "object", "null"];
11
+ declare const JSON_SCHEMA_PRIMITIVE_TYPES: readonly ["string", "number", "integer", "boolean", "null"];
12
+ declare const JSON_SCHEMA_TYPES: readonly ["string", "number", "integer", "boolean", "null", "array", "object"];
12
13
  declare const JSON_SCHEMA_METADATA_KEYS: ("title" | "description" | "docs" | "examples" | "alias" | "tags" | "deprecated" | "hidden" | "ignore" | "internal" | "runtime" | "readOnly" | "writeOnly")[];
13
14
  //#endregion
14
- export { JSON_SCHEMA_DATA_TYPES, JSON_SCHEMA_METADATA_KEYS, JsonSchemaTypes };
15
+ export { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames };
15
16
  //# sourceMappingURL=constants.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.cts","names":[],"sources":["../src/constants.ts"],"mappings":";cAoBa,eAAA;EAAA;;;;;;;;cAUA,sBAAA;AAAA,cAUA,yBAAA"}
1
+ {"version":3,"file":"constants.d.cts","names":[],"sources":["../src/constants.ts"],"mappings":";cAoBa,mBAAA;EAAA;;;;;;;;cAUA,2BAAA;AAAA,cAQA,iBAAA;AAAA,cAMA,yBAAA"}
@@ -1,5 +1,5 @@
1
1
  //#region src/constants.d.ts
2
- declare const JsonSchemaTypes: {
2
+ declare const JsonSchemaTypeNames: {
3
3
  readonly STRING: "string";
4
4
  readonly NUMBER: "number";
5
5
  readonly INTEGER: "integer";
@@ -8,8 +8,9 @@ declare const JsonSchemaTypes: {
8
8
  readonly OBJECT: "object";
9
9
  readonly ARRAY: "array";
10
10
  };
11
- declare const JSON_SCHEMA_DATA_TYPES: readonly ["string", "number", "integer", "boolean", "array", "object", "null"];
11
+ declare const JSON_SCHEMA_PRIMITIVE_TYPES: readonly ["string", "number", "integer", "boolean", "null"];
12
+ declare const JSON_SCHEMA_TYPES: readonly ["string", "number", "integer", "boolean", "null", "array", "object"];
12
13
  declare const JSON_SCHEMA_METADATA_KEYS: ("title" | "description" | "docs" | "examples" | "alias" | "tags" | "deprecated" | "hidden" | "ignore" | "internal" | "runtime" | "readOnly" | "writeOnly")[];
13
14
  //#endregion
14
- export { JSON_SCHEMA_DATA_TYPES, JSON_SCHEMA_METADATA_KEYS, JsonSchemaTypes };
15
+ export { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames };
15
16
  //# sourceMappingURL=constants.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.mts","names":[],"sources":["../src/constants.ts"],"mappings":";cAoBa,eAAA;EAAA;;;;;;;;cAUA,sBAAA;AAAA,cAUA,yBAAA"}
1
+ {"version":3,"file":"constants.d.mts","names":[],"sources":["../src/constants.ts"],"mappings":";cAoBa,mBAAA;EAAA;;;;;;;;cAUA,2BAAA;AAAA,cAQA,iBAAA;AAAA,cAMA,yBAAA"}
@@ -1,5 +1,5 @@
1
1
  //#region src/constants.ts
2
- const JsonSchemaTypes = {
2
+ const JsonSchemaTypeNames = {
3
3
  STRING: "string",
4
4
  NUMBER: "number",
5
5
  INTEGER: "integer",
@@ -8,14 +8,17 @@ const JsonSchemaTypes = {
8
8
  OBJECT: "object",
9
9
  ARRAY: "array"
10
10
  };
11
- const JSON_SCHEMA_DATA_TYPES = [
12
- JsonSchemaTypes.STRING,
13
- JsonSchemaTypes.NUMBER,
14
- JsonSchemaTypes.INTEGER,
15
- JsonSchemaTypes.BOOLEAN,
16
- JsonSchemaTypes.ARRAY,
17
- JsonSchemaTypes.OBJECT,
18
- JsonSchemaTypes.NULL
11
+ const JSON_SCHEMA_PRIMITIVE_TYPES = [
12
+ JsonSchemaTypeNames.STRING,
13
+ JsonSchemaTypeNames.NUMBER,
14
+ JsonSchemaTypeNames.INTEGER,
15
+ JsonSchemaTypeNames.BOOLEAN,
16
+ JsonSchemaTypeNames.NULL
17
+ ];
18
+ const JSON_SCHEMA_TYPES = [
19
+ ...JSON_SCHEMA_PRIMITIVE_TYPES,
20
+ JsonSchemaTypeNames.ARRAY,
21
+ JsonSchemaTypeNames.OBJECT
19
22
  ];
20
23
  const JSON_SCHEMA_METADATA_KEYS = [
21
24
  "docs",
@@ -34,5 +37,5 @@ const JSON_SCHEMA_METADATA_KEYS = [
34
37
  ];
35
38
 
36
39
  //#endregion
37
- export { JSON_SCHEMA_DATA_TYPES, JSON_SCHEMA_METADATA_KEYS, JsonSchemaTypes };
40
+ export { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames };
38
41
  //# sourceMappingURL=constants.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { SchemaMetadata } from \"./types\";\n\nexport const JsonSchemaTypes = {\n STRING: \"string\",\n NUMBER: \"number\",\n INTEGER: \"integer\",\n BOOLEAN: \"boolean\",\n NULL: \"null\",\n OBJECT: \"object\",\n ARRAY: \"array\"\n} as const;\n\nexport const JSON_SCHEMA_DATA_TYPES = [\n JsonSchemaTypes.STRING,\n JsonSchemaTypes.NUMBER,\n JsonSchemaTypes.INTEGER,\n JsonSchemaTypes.BOOLEAN,\n JsonSchemaTypes.ARRAY,\n JsonSchemaTypes.OBJECT,\n JsonSchemaTypes.NULL\n] as const;\n\nexport const JSON_SCHEMA_METADATA_KEYS = [\n \"docs\",\n \"deprecated\",\n \"title\",\n \"description\",\n \"examples\",\n \"hidden\",\n \"ignore\",\n \"internal\",\n \"runtime\",\n \"readOnly\",\n \"writeOnly\",\n \"alias\",\n \"tags\"\n] satisfies ReadonlyArray<keyof SchemaMetadata>;\n"],"mappings":";AAoBA,MAAa,kBAAkB;CAC7B,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,MAAM;CACN,QAAQ;CACR,OAAO;AACT;AAEA,MAAa,yBAAyB;CACpC,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;AAClB;AAEA,MAAa,4BAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { JsonSchemaMetadataKeywords } from \"./types\";\n\nexport const JsonSchemaTypeNames = {\n STRING: \"string\",\n NUMBER: \"number\",\n INTEGER: \"integer\",\n BOOLEAN: \"boolean\",\n NULL: \"null\",\n OBJECT: \"object\",\n ARRAY: \"array\"\n} as const;\n\nexport const JSON_SCHEMA_PRIMITIVE_TYPES = [\n JsonSchemaTypeNames.STRING,\n JsonSchemaTypeNames.NUMBER,\n JsonSchemaTypeNames.INTEGER,\n JsonSchemaTypeNames.BOOLEAN,\n JsonSchemaTypeNames.NULL\n] as const;\n\nexport const JSON_SCHEMA_TYPES = [\n ...JSON_SCHEMA_PRIMITIVE_TYPES,\n JsonSchemaTypeNames.ARRAY,\n JsonSchemaTypeNames.OBJECT\n] as const;\n\nexport const JSON_SCHEMA_METADATA_KEYS = [\n \"docs\",\n \"deprecated\",\n \"title\",\n \"description\",\n \"examples\",\n \"hidden\",\n \"ignore\",\n \"internal\",\n \"runtime\",\n \"readOnly\",\n \"writeOnly\",\n \"alias\",\n \"tags\"\n] satisfies ReadonlyArray<keyof JsonSchemaMetadataKeywords>;\n"],"mappings":";AAoBA,MAAa,sBAAsB;CACjC,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,MAAM;CACN,QAAQ;CACR,OAAO;AACT;AAEA,MAAa,8BAA8B;CACzC,oBAAoB;CACpB,oBAAoB;CACpB,oBAAoB;CACpB,oBAAoB;CACpB,oBAAoB;AACtB;AAEA,MAAa,oBAAoB;CAC/B,GAAG;CACH,oBAAoB;CACpB,oBAAoB;AACtB;AAEA,MAAa,4BAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}