@powerlines/schema 0.11.72 → 0.11.73
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/dist/index.cjs +2111 -97
- package/dist/index.d.cts +1841 -11
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1841 -13
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1999 -15
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -5
- package/dist/_virtual/_rolldown/runtime.cjs +0 -37
- package/dist/bundle.cjs +0 -55
- package/dist/bundle.d.cts +0 -21
- package/dist/bundle.d.cts.map +0 -1
- package/dist/bundle.d.mts +0 -23
- package/dist/bundle.d.mts.map +0 -1
- package/dist/bundle.mjs +0 -54
- package/dist/bundle.mjs.map +0 -1
- package/dist/codegen.cjs +0 -81
- package/dist/codegen.d.cts +0 -26
- package/dist/codegen.d.cts.map +0 -1
- package/dist/codegen.d.mts +0 -28
- package/dist/codegen.d.mts.map +0 -1
- package/dist/codegen.mjs +0 -77
- package/dist/codegen.mjs.map +0 -1
- package/dist/constants.cjs +0 -69
- package/dist/constants.d.cts +0 -17
- package/dist/constants.d.cts.map +0 -1
- package/dist/constants.d.mts +0 -19
- package/dist/constants.d.mts.map +0 -1
- package/dist/constants.mjs +0 -65
- package/dist/constants.mjs.map +0 -1
- package/dist/extract.cjs +0 -490
- package/dist/extract.d.cts +0 -125
- package/dist/extract.d.cts.map +0 -1
- package/dist/extract.d.mts +0 -127
- package/dist/extract.d.mts.map +0 -1
- package/dist/extract.mjs +0 -480
- package/dist/extract.mjs.map +0 -1
- package/dist/helpers.cjs +0 -171
- package/dist/helpers.d.cts +0 -111
- package/dist/helpers.d.cts.map +0 -1
- package/dist/helpers.d.mts +0 -113
- package/dist/helpers.d.mts.map +0 -1
- package/dist/helpers.mjs +0 -164
- package/dist/helpers.mjs.map +0 -1
- package/dist/metadata.cjs +0 -61
- package/dist/metadata.d.cts +0 -31
- package/dist/metadata.d.cts.map +0 -1
- package/dist/metadata.d.mts +0 -33
- package/dist/metadata.d.mts.map +0 -1
- package/dist/metadata.mjs +0 -60
- package/dist/metadata.mjs.map +0 -1
- package/dist/persistence.cjs +0 -82
- package/dist/persistence.d.cts +0 -47
- package/dist/persistence.d.cts.map +0 -1
- package/dist/persistence.d.mts +0 -49
- package/dist/persistence.d.mts.map +0 -1
- package/dist/persistence.mjs +0 -79
- package/dist/persistence.mjs.map +0 -1
- package/dist/reflection.cjs +0 -434
- package/dist/reflection.d.cts +0 -11
- package/dist/reflection.d.cts.map +0 -1
- package/dist/reflection.d.mts +0 -13
- package/dist/reflection.d.mts.map +0 -1
- package/dist/reflection.mjs +0 -433
- package/dist/reflection.mjs.map +0 -1
- package/dist/resolve.cjs +0 -113
- package/dist/resolve.d.cts +0 -36
- package/dist/resolve.d.cts.map +0 -1
- package/dist/resolve.d.mts +0 -38
- package/dist/resolve.d.mts.map +0 -1
- package/dist/resolve.mjs +0 -110
- package/dist/resolve.mjs.map +0 -1
- package/dist/type-checks.cjs +0 -642
- package/dist/type-checks.d.cts +0 -316
- package/dist/type-checks.d.cts.map +0 -1
- package/dist/type-checks.d.mts +0 -318
- package/dist/type-checks.d.mts.map +0 -1
- package/dist/type-checks.mjs +0 -603
- package/dist/type-checks.mjs.map +0 -1
- package/dist/types.d.cts +0 -1152
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts +0 -1154
- package/dist/types.d.mts.map +0 -1
- package/dist/validate.cjs +0 -35
- package/dist/validate.mjs +0 -33
- package/dist/validate.mjs.map +0 -1
package/dist/bundle.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import __tsdown_shims_path from 'node:path'
|
|
4
|
-
import __tsdown_shims_url from 'node:url'
|
|
5
|
-
|
|
6
|
-
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
-
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
-
|
|
9
|
-
import { createUnpluginResolver } from "@powerlines/core/lib/unplugin";
|
|
10
|
-
import { resolveOptions } from "@powerlines/unplugin/esbuild";
|
|
11
|
-
import { omit } from "@stryke/helpers/omit";
|
|
12
|
-
import { findFileName } from "@stryke/path/file-path-fns";
|
|
13
|
-
import defu from "defu";
|
|
14
|
-
import { build } from "esbuild";
|
|
15
|
-
import { createEsbuildPlugin } from "unplugin";
|
|
16
|
-
|
|
17
|
-
//#region src/bundle.ts
|
|
18
|
-
/**
|
|
19
|
-
* Bundle a type definition to a module.
|
|
20
|
-
*
|
|
21
|
-
* @param context - The context object containing the environment paths.
|
|
22
|
-
* @param file - The file path to bundle.
|
|
23
|
-
* @param options - Optional overrides for the ESBuild configuration.
|
|
24
|
-
* @returns A promise that resolves to the bundled module.
|
|
25
|
-
*/
|
|
26
|
-
async function bundle(context, file, options = {}) {
|
|
27
|
-
const path = await context.fs.resolve(file);
|
|
28
|
-
if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
|
|
29
|
-
const result = await build(defu({
|
|
30
|
-
entryPoints: [path],
|
|
31
|
-
write: false,
|
|
32
|
-
sourcemap: false,
|
|
33
|
-
splitting: false,
|
|
34
|
-
treeShaking: true,
|
|
35
|
-
bundle: true,
|
|
36
|
-
packages: "bundle",
|
|
37
|
-
platform: "node",
|
|
38
|
-
logLevel: "silent",
|
|
39
|
-
...omit(options, ["name", "resolve"])
|
|
40
|
-
}, resolveOptions(context), { plugins: [createEsbuildPlugin(createUnpluginResolver(context, {
|
|
41
|
-
name: options.name ?? `${findFileName(file)} Bundler`,
|
|
42
|
-
prefix: false,
|
|
43
|
-
overrides: defu(options.resolve ?? {}, { skipNodeModulesBundle: false }, context.config.resolve),
|
|
44
|
-
silenceHookLogging: true
|
|
45
|
-
}))()] }));
|
|
46
|
-
if (result.errors.length > 0) throw new Error(`Failed to bundle ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
|
|
47
|
-
if (result.warnings.length > 0) context.warn(`Warnings while bundling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
|
|
48
|
-
if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
|
|
49
|
-
return result.outputFiles.filter(Boolean)[0];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
export { bundle };
|
|
54
|
-
//# sourceMappingURL=bundle.mjs.map
|
package/dist/bundle.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/esbuild\";\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 } from \"esbuild\";\nimport { build, OutputFile } from \"esbuild\";\nimport { createEsbuildPlugin } from \"unplugin\";\n\nexport type BundleOptions = DeepPartial<BuildOptions> & {\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<OutputFile> {\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 result = await build(\n defu(\n {\n entryPoints: [path],\n write: false,\n sourcemap: false,\n splitting: false,\n treeShaking: true,\n bundle: true,\n packages: \"bundle\",\n platform: \"node\",\n logLevel: \"silent\",\n ...omit(options, [\"name\", \"resolve\"])\n },\n resolveOptions(context),\n {\n plugins: [\n createEsbuildPlugin(\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 ]\n }\n )\n );\n if (result.errors.length > 0) {\n throw new Error(\n `Failed to bundle ${file}: ${result.errors\n .map(error => error.text)\n .join(\", \")}`\n );\n }\n if (result.warnings.length > 0) {\n context.warn(\n `Warnings while bundling ${file}: ${result.warnings\n .map(warning => warning.text)\n .join(\", \")}`\n );\n }\n if (!result.outputFiles || result.outputFiles.filter(Boolean).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\n return result.outputFiles.filter(Boolean)[0]!;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,eAAsB,OACpB,SACA,MACA,UAAyB,CAAC,GACL;CACrB,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,SAAS,MAAM,MACnB,KACE;EACE,aAAa,CAAC,IAAI;EAClB,OAAO;EACP,WAAW;EACX,WAAW;EACX,aAAa;EACb,QAAQ;EACR,UAAU;EACV,UAAU;EACV,UAAU;EACV,GAAG,KAAK,SAAS,CAAC,QAAQ,SAAS,CAAC;CACtC,GACA,eAAe,OAAO,GACtB,EACE,SAAS,CACP,oBACE,uBAAuB,SAAS;EAC9B,MAAM,QAAQ,QAAQ,GAAG,aAAa,IAAI,EAAE;EAC5C,QAAQ;EACR,WAAW,KACT,QAAQ,WAAW,CAAC,GACpB,EAAE,uBAAuB,MAAM,GAC/B,QAAQ,OAAO,OACjB;EACA,oBAAoB;CACtB,CAAC,CACH,EAAE,CACJ,EACF,CACF,CACF;CACA,IAAI,OAAO,OAAO,SAAS,GACzB,MAAM,IAAI,MACR,oBAAoB,KAAK,IAAI,OAAO,OACjC,KAAI,UAAS,MAAM,IAAI,EACvB,KAAK,IAAI,GACd;CAEF,IAAI,OAAO,SAAS,SAAS,GAC3B,QAAQ,KACN,2BAA2B,KAAK,IAAI,OAAO,SACxC,KAAI,YAAW,QAAQ,IAAI,EAC3B,KAAK,IAAI,GACd;CAEF,IAAI,CAAC,OAAO,eAAe,OAAO,YAAY,OAAO,OAAO,EAAE,WAAW,GACvE,MAAM,IAAI,MACR,iCACE,KACD,gDACH;CAGF,OAAO,OAAO,YAAY,OAAO,OAAO,EAAE;AAC5C"}
|
package/dist/codegen.cjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import __tsdown_shims_path from 'node:path'
|
|
4
|
-
import __tsdown_shims_url from 'node:url'
|
|
5
|
-
|
|
6
|
-
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
-
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
-
|
|
9
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
10
|
-
const require_metadata = require('./metadata.cjs');
|
|
11
|
-
const require_type_checks = require('./type-checks.cjs');
|
|
12
|
-
const require_helpers = require('./helpers.cjs');
|
|
13
|
-
const require_validate = require('./validate.cjs');
|
|
14
|
-
let _stryke_convert_to_bool = require("@stryke/convert/to-bool");
|
|
15
|
-
let _stryke_type_checks = require("@stryke/type-checks");
|
|
16
|
-
let _stryke_type_checks_is_boolean = require("@stryke/type-checks/is-boolean");
|
|
17
|
-
let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
18
|
-
let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
19
|
-
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
20
|
-
let _stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
|
|
21
|
-
let ajv_dist_standalone_index_js = require("ajv/dist/standalone/index.js");
|
|
22
|
-
ajv_dist_standalone_index_js = require_runtime.__toESM(ajv_dist_standalone_index_js, 1);
|
|
23
|
-
|
|
24
|
-
//#region src/codegen.ts
|
|
25
|
-
/**
|
|
26
|
-
* Stringifies a value for generated TypeScript code.
|
|
27
|
-
*/
|
|
28
|
-
function stringifyValue(value, type) {
|
|
29
|
-
return (0, _stryke_type_checks_is_undefined.isUndefined)(value) ? "undefined" : (0, _stryke_type_checks_is_null.isNull)(value) ? "null" : type === "boolean" || (0, _stryke_type_checks_is_boolean.isBoolean)(value) ? String((0, _stryke_convert_to_bool.toBool)(value)) : type === "number" || (0, _stryke_type_checks_is_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);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Stringifies a JSON Schema fragment into a TypeScript-like type string.
|
|
33
|
-
*/
|
|
34
|
-
function stringifyType(schema) {
|
|
35
|
-
if (!schema) return "unknown";
|
|
36
|
-
if (typeof schema === "boolean") return schema ? "unknown" : "never";
|
|
37
|
-
const objectSchema = schema;
|
|
38
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(objectSchema.$ref)) return /^#\/(?:definitions|\$defs)\/(.+)$/.exec(objectSchema.$ref)?.[1] ?? objectSchema.$ref;
|
|
39
|
-
const primaryType = require_metadata.getPrimarySchemaType(schema);
|
|
40
|
-
if (primaryType) {
|
|
41
|
-
if (primaryType === "integer" || primaryType === "number") return "number";
|
|
42
|
-
return primaryType;
|
|
43
|
-
}
|
|
44
|
-
if (objectSchema.type === "array" && Array.isArray(objectSchema.enum)) return objectSchema.enum.map((value) => JSON.stringify(value)).join(" | ");
|
|
45
|
-
if (objectSchema.const !== void 0) return JSON.stringify(objectSchema.const);
|
|
46
|
-
if (objectSchema.type === "array" || objectSchema.items) return `${stringifyType(objectSchema.items)}[]`;
|
|
47
|
-
if (objectSchema.type === "object" || objectSchema.properties || objectSchema.additionalProperties) {
|
|
48
|
-
if (require_type_checks.isJsonSchema(objectSchema.additionalProperties)) return `{ [key: string]: ${stringifyType(objectSchema.additionalProperties)} }`;
|
|
49
|
-
if (require_type_checks.isJsonSchemaObject(objectSchema)) {
|
|
50
|
-
const required = objectSchema.required ?? [];
|
|
51
|
-
return `{ ${require_helpers.getPropertiesList(objectSchema).map((property) => {
|
|
52
|
-
const suffix = !required.includes(property.name) || require_helpers.isSchemaNullable(property) ? `${!required.includes(property.name) ? "?" : ""}${require_helpers.isSchemaNullable(property) ? " | null" : ""}` : "";
|
|
53
|
-
return `${property.name}${suffix}: ${stringifyType(property)}`;
|
|
54
|
-
}).join(";\n")} }`;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (objectSchema.oneOf || objectSchema.anyOf) return (objectSchema.oneOf ?? objectSchema.anyOf ?? []).map((branch) => stringifyType(branch)).join(" | ");
|
|
58
|
-
if (objectSchema.allOf) return "object";
|
|
59
|
-
return "unknown";
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.
|
|
63
|
-
*
|
|
64
|
-
* @param value - The value whose type is to be represented as a string.
|
|
65
|
-
* @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.
|
|
66
|
-
*/
|
|
67
|
-
function getJsonSchemaType(value) {
|
|
68
|
-
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;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Generates standalone JSON Schema validation code using Ajv.
|
|
72
|
-
*/
|
|
73
|
-
async function generateCode(schemas, refsOrFuncts) {
|
|
74
|
-
return (0, ajv_dist_standalone_index_js.default)(require_validate.getValidator(schemas), refsOrFuncts);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
exports.generateCode = generateCode;
|
|
79
|
-
exports.getJsonSchemaType = getJsonSchemaType;
|
|
80
|
-
exports.stringifyType = stringifyType;
|
|
81
|
-
exports.stringifyValue = stringifyValue;
|
package/dist/codegen.d.cts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { JsonSchema, JsonSchemaType } from "./types.cjs";
|
|
2
|
-
import standaloneCode from "ajv/dist/standalone/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/codegen.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Stringifies a value for generated TypeScript code.
|
|
7
|
-
*/
|
|
8
|
-
declare function stringifyValue(value?: unknown, type?: JsonSchemaType | string): string;
|
|
9
|
-
/**
|
|
10
|
-
* Stringifies a JSON Schema fragment into a TypeScript-like type string.
|
|
11
|
-
*/
|
|
12
|
-
declare function stringifyType(schema?: JsonSchema): string;
|
|
13
|
-
/**
|
|
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.
|
|
18
|
-
*/
|
|
19
|
-
declare function getJsonSchemaType(value?: unknown): JsonSchemaType | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Generates standalone JSON Schema validation code using Ajv.
|
|
22
|
-
*/
|
|
23
|
-
declare function generateCode(schemas: JsonSchema, refsOrFuncts?: Parameters<typeof standaloneCode>[1]): Promise<string>;
|
|
24
|
-
//#endregion
|
|
25
|
-
export { generateCode, getJsonSchemaType, stringifyType, stringifyValue };
|
|
26
|
-
//# sourceMappingURL=codegen.d.cts.map
|
package/dist/codegen.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/codegen.d.mts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import __tsdown_shims_path from 'node:path';
|
|
2
|
-
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import { JsonSchema, JsonSchemaType } from "./types.mjs";
|
|
4
|
-
import standaloneCode from "ajv/dist/standalone/index.js";
|
|
5
|
-
|
|
6
|
-
//#region src/codegen.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Stringifies a value for generated TypeScript code.
|
|
9
|
-
*/
|
|
10
|
-
declare function stringifyValue(value?: unknown, type?: JsonSchemaType | string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Stringifies a JSON Schema fragment into a TypeScript-like type string.
|
|
13
|
-
*/
|
|
14
|
-
declare function stringifyType(schema?: JsonSchema): string;
|
|
15
|
-
/**
|
|
16
|
-
* Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.
|
|
17
|
-
*
|
|
18
|
-
* @param value - The value whose type is to be represented as a string.
|
|
19
|
-
* @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.
|
|
20
|
-
*/
|
|
21
|
-
declare function getJsonSchemaType(value?: unknown): JsonSchemaType | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Generates standalone JSON Schema validation code using Ajv.
|
|
24
|
-
*/
|
|
25
|
-
declare function generateCode(schemas: JsonSchema, refsOrFuncts?: Parameters<typeof standaloneCode>[1]): Promise<string>;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { generateCode, getJsonSchemaType, stringifyType, stringifyValue };
|
|
28
|
-
//# sourceMappingURL=codegen.d.mts.map
|
package/dist/codegen.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.mts","names":[],"sources":["../src/codegen.ts"],"mappings":";;;;;;;;;iBAiDgB,cAAA,CACd,KAAA,YACA,IAAA,GAAO,cAAc;;;;iBAsBP,aAAA,CAAc,MAAmB,GAAV,UAAU;;;AAxBjD;;;;iBA8GgB,iBAAA,CAAkB,KAAA,aAAkB,cAAc;;;;iBAqB5C,YAAA,CACpB,OAAA,EAAS,UAAA,EACT,YAAA,GAAe,UAAA,QAAkB,cAAA,OAAkB,OAAA"}
|
package/dist/codegen.mjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import __tsdown_shims_path from 'node:path'
|
|
4
|
-
import __tsdown_shims_url from 'node:url'
|
|
5
|
-
|
|
6
|
-
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
-
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
-
|
|
9
|
-
import { getPrimarySchemaType } from "./metadata.mjs";
|
|
10
|
-
import { isJsonSchema, isJsonSchemaObject } from "./type-checks.mjs";
|
|
11
|
-
import { getPropertiesList, isSchemaNullable } from "./helpers.mjs";
|
|
12
|
-
import { getValidator } from "./validate.mjs";
|
|
13
|
-
import { toBool } from "@stryke/convert/to-bool";
|
|
14
|
-
import { isInteger, isObject, isString } from "@stryke/type-checks";
|
|
15
|
-
import { isBoolean as isBoolean$1 } from "@stryke/type-checks/is-boolean";
|
|
16
|
-
import { isNull as isNull$1 } from "@stryke/type-checks/is-null";
|
|
17
|
-
import { isNumber as isNumber$1 } from "@stryke/type-checks/is-number";
|
|
18
|
-
import { isSetString as isSetString$1 } from "@stryke/type-checks/is-set-string";
|
|
19
|
-
import { isUndefined as isUndefined$1 } from "@stryke/type-checks/is-undefined";
|
|
20
|
-
import standaloneCode from "ajv/dist/standalone/index.js";
|
|
21
|
-
|
|
22
|
-
//#region src/codegen.ts
|
|
23
|
-
/**
|
|
24
|
-
* Stringifies a value for generated TypeScript code.
|
|
25
|
-
*/
|
|
26
|
-
function stringifyValue(value, type) {
|
|
27
|
-
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);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Stringifies a JSON Schema fragment into a TypeScript-like type string.
|
|
31
|
-
*/
|
|
32
|
-
function stringifyType(schema) {
|
|
33
|
-
if (!schema) return "unknown";
|
|
34
|
-
if (typeof schema === "boolean") return schema ? "unknown" : "never";
|
|
35
|
-
const objectSchema = schema;
|
|
36
|
-
if (isSetString$1(objectSchema.$ref)) return /^#\/(?:definitions|\$defs)\/(.+)$/.exec(objectSchema.$ref)?.[1] ?? objectSchema.$ref;
|
|
37
|
-
const primaryType = getPrimarySchemaType(schema);
|
|
38
|
-
if (primaryType) {
|
|
39
|
-
if (primaryType === "integer" || primaryType === "number") return "number";
|
|
40
|
-
return primaryType;
|
|
41
|
-
}
|
|
42
|
-
if (objectSchema.type === "array" && Array.isArray(objectSchema.enum)) return objectSchema.enum.map((value) => JSON.stringify(value)).join(" | ");
|
|
43
|
-
if (objectSchema.const !== void 0) return JSON.stringify(objectSchema.const);
|
|
44
|
-
if (objectSchema.type === "array" || objectSchema.items) return `${stringifyType(objectSchema.items)}[]`;
|
|
45
|
-
if (objectSchema.type === "object" || objectSchema.properties || objectSchema.additionalProperties) {
|
|
46
|
-
if (isJsonSchema(objectSchema.additionalProperties)) return `{ [key: string]: ${stringifyType(objectSchema.additionalProperties)} }`;
|
|
47
|
-
if (isJsonSchemaObject(objectSchema)) {
|
|
48
|
-
const required = objectSchema.required ?? [];
|
|
49
|
-
return `{ ${getPropertiesList(objectSchema).map((property) => {
|
|
50
|
-
const suffix = !required.includes(property.name) || isSchemaNullable(property) ? `${!required.includes(property.name) ? "?" : ""}${isSchemaNullable(property) ? " | null" : ""}` : "";
|
|
51
|
-
return `${property.name}${suffix}: ${stringifyType(property)}`;
|
|
52
|
-
}).join(";\n")} }`;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (objectSchema.oneOf || objectSchema.anyOf) return (objectSchema.oneOf ?? objectSchema.anyOf ?? []).map((branch) => stringifyType(branch)).join(" | ");
|
|
56
|
-
if (objectSchema.allOf) return "object";
|
|
57
|
-
return "unknown";
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Returns a string type representation of a value based on its type and an optional JSON Schema primitive type hint.
|
|
61
|
-
*
|
|
62
|
-
* @param value - The value whose type is to be represented as a string.
|
|
63
|
-
* @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.
|
|
64
|
-
*/
|
|
65
|
-
function getJsonSchemaType(value) {
|
|
66
|
-
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;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Generates standalone JSON Schema validation code using Ajv.
|
|
70
|
-
*/
|
|
71
|
-
async function generateCode(schemas, refsOrFuncts) {
|
|
72
|
-
return standaloneCode(getValidator(schemas), refsOrFuncts);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
export { generateCode, getJsonSchemaType, stringifyType, stringifyValue };
|
|
77
|
-
//# sourceMappingURL=codegen.mjs.map
|
package/dist/codegen.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/constants.cjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import __tsdown_shims_path from 'node:path'
|
|
4
|
-
import __tsdown_shims_url from 'node:url'
|
|
5
|
-
|
|
6
|
-
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
-
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//#region src/constants.ts
|
|
11
|
-
const VALID_SOURCE_FILE_EXTENSIONS = [
|
|
12
|
-
"ts",
|
|
13
|
-
"cts",
|
|
14
|
-
"mts",
|
|
15
|
-
"tsx",
|
|
16
|
-
"js",
|
|
17
|
-
"cjs",
|
|
18
|
-
"mjs",
|
|
19
|
-
"jsx",
|
|
20
|
-
"json",
|
|
21
|
-
"jsonc",
|
|
22
|
-
"json5",
|
|
23
|
-
"yaml",
|
|
24
|
-
"yml",
|
|
25
|
-
"toml"
|
|
26
|
-
];
|
|
27
|
-
const JsonSchemaTypeNames = {
|
|
28
|
-
STRING: "string",
|
|
29
|
-
NUMBER: "number",
|
|
30
|
-
INTEGER: "integer",
|
|
31
|
-
BOOLEAN: "boolean",
|
|
32
|
-
NULL: "null",
|
|
33
|
-
OBJECT: "object",
|
|
34
|
-
ARRAY: "array"
|
|
35
|
-
};
|
|
36
|
-
const JSON_SCHEMA_PRIMITIVE_TYPES = [
|
|
37
|
-
JsonSchemaTypeNames.STRING,
|
|
38
|
-
JsonSchemaTypeNames.NUMBER,
|
|
39
|
-
JsonSchemaTypeNames.INTEGER,
|
|
40
|
-
JsonSchemaTypeNames.BOOLEAN,
|
|
41
|
-
JsonSchemaTypeNames.NULL
|
|
42
|
-
];
|
|
43
|
-
const JSON_SCHEMA_TYPES = [
|
|
44
|
-
...JSON_SCHEMA_PRIMITIVE_TYPES,
|
|
45
|
-
JsonSchemaTypeNames.ARRAY,
|
|
46
|
-
JsonSchemaTypeNames.OBJECT
|
|
47
|
-
];
|
|
48
|
-
const JSON_SCHEMA_METADATA_KEYS = [
|
|
49
|
-
"docs",
|
|
50
|
-
"deprecated",
|
|
51
|
-
"title",
|
|
52
|
-
"description",
|
|
53
|
-
"examples",
|
|
54
|
-
"hidden",
|
|
55
|
-
"ignore",
|
|
56
|
-
"internal",
|
|
57
|
-
"runtime",
|
|
58
|
-
"readOnly",
|
|
59
|
-
"writeOnly",
|
|
60
|
-
"alias",
|
|
61
|
-
"tags"
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
//#endregion
|
|
65
|
-
exports.JSON_SCHEMA_METADATA_KEYS = JSON_SCHEMA_METADATA_KEYS;
|
|
66
|
-
exports.JSON_SCHEMA_PRIMITIVE_TYPES = JSON_SCHEMA_PRIMITIVE_TYPES;
|
|
67
|
-
exports.JSON_SCHEMA_TYPES = JSON_SCHEMA_TYPES;
|
|
68
|
-
exports.JsonSchemaTypeNames = JsonSchemaTypeNames;
|
|
69
|
-
exports.VALID_SOURCE_FILE_EXTENSIONS = VALID_SOURCE_FILE_EXTENSIONS;
|
package/dist/constants.d.cts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/constants.d.ts
|
|
2
|
-
declare const VALID_SOURCE_FILE_EXTENSIONS: string[];
|
|
3
|
-
declare const JsonSchemaTypeNames: {
|
|
4
|
-
readonly STRING: "string";
|
|
5
|
-
readonly NUMBER: "number";
|
|
6
|
-
readonly INTEGER: "integer";
|
|
7
|
-
readonly BOOLEAN: "boolean";
|
|
8
|
-
readonly NULL: "null";
|
|
9
|
-
readonly OBJECT: "object";
|
|
10
|
-
readonly ARRAY: "array";
|
|
11
|
-
};
|
|
12
|
-
declare const JSON_SCHEMA_PRIMITIVE_TYPES: readonly ["string", "number", "integer", "boolean", "null"];
|
|
13
|
-
declare const JSON_SCHEMA_TYPES: readonly ["string", "number", "integer", "boolean", "null", "array", "object"];
|
|
14
|
-
declare const JSON_SCHEMA_METADATA_KEYS: ("title" | "description" | "docs" | "examples" | "alias" | "tags" | "deprecated" | "hidden" | "ignore" | "internal" | "runtime" | "readOnly" | "writeOnly")[];
|
|
15
|
-
//#endregion
|
|
16
|
-
export { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames, VALID_SOURCE_FILE_EXTENSIONS };
|
|
17
|
-
//# sourceMappingURL=constants.d.cts.map
|
package/dist/constants.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.cts","names":[],"sources":["../src/constants.ts"],"mappings":";cAoBa,4BAAA;AAAA,cAiBA,mBAAA;EAAA;;;;;;;;cAUA,2BAAA;AAAA,cAQA,iBAAA;AAAA,cAMA,yBAAA"}
|
package/dist/constants.d.mts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import __tsdown_shims_path from 'node:path';
|
|
2
|
-
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
//#region src/constants.d.ts
|
|
4
|
-
declare const VALID_SOURCE_FILE_EXTENSIONS: string[];
|
|
5
|
-
declare const JsonSchemaTypeNames: {
|
|
6
|
-
readonly STRING: "string";
|
|
7
|
-
readonly NUMBER: "number";
|
|
8
|
-
readonly INTEGER: "integer";
|
|
9
|
-
readonly BOOLEAN: "boolean";
|
|
10
|
-
readonly NULL: "null";
|
|
11
|
-
readonly OBJECT: "object";
|
|
12
|
-
readonly ARRAY: "array";
|
|
13
|
-
};
|
|
14
|
-
declare const JSON_SCHEMA_PRIMITIVE_TYPES: readonly ["string", "number", "integer", "boolean", "null"];
|
|
15
|
-
declare const JSON_SCHEMA_TYPES: readonly ["string", "number", "integer", "boolean", "null", "array", "object"];
|
|
16
|
-
declare const JSON_SCHEMA_METADATA_KEYS: ("title" | "description" | "docs" | "examples" | "alias" | "tags" | "deprecated" | "hidden" | "ignore" | "internal" | "runtime" | "readOnly" | "writeOnly")[];
|
|
17
|
-
//#endregion
|
|
18
|
-
export { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames, VALID_SOURCE_FILE_EXTENSIONS };
|
|
19
|
-
//# sourceMappingURL=constants.d.mts.map
|
package/dist/constants.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","names":[],"sources":["../src/constants.ts"],"mappings":";;;cAoBa,4BAAA;AAAA,cAiBA,mBAAA;EAAA;;;;;;;;cAUA,2BAAA;AAAA,cAQA,iBAAA;AAAA,cAMA,yBAAA"}
|
package/dist/constants.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import __tsdown_shims_path from 'node:path'
|
|
4
|
-
import __tsdown_shims_url from 'node:url'
|
|
5
|
-
|
|
6
|
-
const __TSDOWN_SHIM_FILENAME__ = /* @__PURE__ */ __tsdown_shims_url.fileURLToPath(import.meta.url)
|
|
7
|
-
const __TSDOWN_SHIM_DIRNAME__ = /* @__PURE__ */ __tsdown_shims_path.dirname(__TSDOWN_SHIM_FILENAME__)
|
|
8
|
-
|
|
9
|
-
//#region src/constants.ts
|
|
10
|
-
const VALID_SOURCE_FILE_EXTENSIONS = [
|
|
11
|
-
"ts",
|
|
12
|
-
"cts",
|
|
13
|
-
"mts",
|
|
14
|
-
"tsx",
|
|
15
|
-
"js",
|
|
16
|
-
"cjs",
|
|
17
|
-
"mjs",
|
|
18
|
-
"jsx",
|
|
19
|
-
"json",
|
|
20
|
-
"jsonc",
|
|
21
|
-
"json5",
|
|
22
|
-
"yaml",
|
|
23
|
-
"yml",
|
|
24
|
-
"toml"
|
|
25
|
-
];
|
|
26
|
-
const JsonSchemaTypeNames = {
|
|
27
|
-
STRING: "string",
|
|
28
|
-
NUMBER: "number",
|
|
29
|
-
INTEGER: "integer",
|
|
30
|
-
BOOLEAN: "boolean",
|
|
31
|
-
NULL: "null",
|
|
32
|
-
OBJECT: "object",
|
|
33
|
-
ARRAY: "array"
|
|
34
|
-
};
|
|
35
|
-
const JSON_SCHEMA_PRIMITIVE_TYPES = [
|
|
36
|
-
JsonSchemaTypeNames.STRING,
|
|
37
|
-
JsonSchemaTypeNames.NUMBER,
|
|
38
|
-
JsonSchemaTypeNames.INTEGER,
|
|
39
|
-
JsonSchemaTypeNames.BOOLEAN,
|
|
40
|
-
JsonSchemaTypeNames.NULL
|
|
41
|
-
];
|
|
42
|
-
const JSON_SCHEMA_TYPES = [
|
|
43
|
-
...JSON_SCHEMA_PRIMITIVE_TYPES,
|
|
44
|
-
JsonSchemaTypeNames.ARRAY,
|
|
45
|
-
JsonSchemaTypeNames.OBJECT
|
|
46
|
-
];
|
|
47
|
-
const JSON_SCHEMA_METADATA_KEYS = [
|
|
48
|
-
"docs",
|
|
49
|
-
"deprecated",
|
|
50
|
-
"title",
|
|
51
|
-
"description",
|
|
52
|
-
"examples",
|
|
53
|
-
"hidden",
|
|
54
|
-
"ignore",
|
|
55
|
-
"internal",
|
|
56
|
-
"runtime",
|
|
57
|
-
"readOnly",
|
|
58
|
-
"writeOnly",
|
|
59
|
-
"alias",
|
|
60
|
-
"tags"
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
export { JSON_SCHEMA_METADATA_KEYS, JSON_SCHEMA_PRIMITIVE_TYPES, JSON_SCHEMA_TYPES, JsonSchemaTypeNames, VALID_SOURCE_FILE_EXTENSIONS };
|
|
65
|
-
//# sourceMappingURL=constants.mjs.map
|
package/dist/constants.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 VALID_SOURCE_FILE_EXTENSIONS = [\n \"ts\",\n \"cts\",\n \"mts\",\n \"tsx\",\n \"js\",\n \"cjs\",\n \"mjs\",\n \"jsx\",\n \"json\",\n \"jsonc\",\n \"json5\",\n \"yaml\",\n \"yml\",\n \"toml\"\n] as const as string[];\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,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,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"}
|