@powerlines/schema 0.11.71 → 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 +14 -14
- 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/helpers.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":["defu"],"sources":["../src/helpers.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 { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileExtensionSafe } from \"@stryke/path/find\";\nimport { isSetObject } from \"@stryke/type-checks\";\nimport { defu } from \"defu\";\nimport { VALID_SOURCE_FILE_EXTENSIONS } from \"./constants\";\nimport { readSchemaTypes } from \"./metadata\";\nimport { isJsonSchema, isJsonSchemaObject, isSchema } from \"./type-checks\";\nimport { JsonSchema, JsonSchemaLike, JsonSchemaObject, Schema } from \"./types\";\n\nexport type GetPropertiesResult = JsonSchema & {\n name: string;\n required: boolean;\n default?: unknown;\n};\n\n/**\n * Retrieves the JSON Schema from a Schema wrapper or returns the input if it's already a JSON Schema.\n *\n * @remarks\n * This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.\n *\n * @param input - The input which can be either a Schema wrapper or a JSON Schema object.\n * @returns The JSON Schema object.\n * @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.\n */\nexport function getJsonSchema(input: Schema | JsonSchema): JsonSchema {\n const schema = isSchema(input) ? input.schema : input;\n if (!isJsonSchema(schema)) {\n throw new TypeError(\n `The provided input is not a valid JSON Schema: ${JSON.stringify(\n schema,\n null,\n 2\n )}`\n );\n }\n\n return schema;\n}\n\n/**\n * Retrieves the JSON Schema in Object form from a Schema wrapper or returns the input if it's already a JSON Schema.\n *\n * @remarks\n * This function checks if the input is a Schema wrapper (an object with a `schema` property) and returns the `schema` if it is. If the input is already a JSON Schema object, it returns it directly. This allows for flexibility in handling both raw JSON Schema objects and wrapped schemas without needing to check the type at every usage point.\n *\n * @param input - The input which can be either a Schema wrapper or a JSON Schema object.\n * @returns The JSON Schema object.\n * @throws Will throw a TypeError if the input is neither a valid Schema wrapper nor a valid JSON Schema object.\n */\nexport function getJsonSchemaObject(\n input: Schema | JsonSchema\n): JsonSchemaObject {\n const schema = getJsonSchema(input);\n if (!isJsonSchemaObject(schema)) {\n throw new TypeError(\n `The provided input is not a valid JSON Schema object: ${JSON.stringify(schema, null, 2)}`\n );\n }\n\n return schema;\n}\n\n/**\n * Extracts object properties from a JSON Schema object form.\n *\n * @remarks\n * This function returns an empty object if the schema is not an object form or if it has no properties.\n *\n * @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.\n * @returns An object mapping property names to their corresponding JSON Schema fragments, including metadata.\n */\nexport function getProperties(\n obj: Schema | JsonSchemaObject\n): Record<\n string,\n JsonSchema & { name: string; required: boolean; default?: unknown }\n> {\n const properties: Record<\n string,\n JsonSchema & { name: string; required: boolean; default?: unknown }\n > = {};\n\n const schema = getJsonSchemaObject(obj);\n if (!isSetObject(schema.properties)) {\n return properties;\n }\n\n for (const [key, value] of Object.entries(schema.properties)) {\n const propertySchema: Record<string, unknown> = {};\n\n if (typeof value !== \"boolean\") {\n Object.assign(propertySchema, value);\n }\n\n properties[key] = {\n ...propertySchema,\n name: key,\n required: !isPropertyOptional(schema, key),\n default: schema.default?.[key] ?? propertySchema.default\n };\n }\n\n return properties;\n}\n\n/**\n * Returns object properties as an array.\n *\n * @remarks\n * This is a convenience function that extracts properties using `getProperties` and returns them as an array.\n *\n * @param obj - The JSON Schema object form or a Schema wrapper to extract properties from.\n * @returns An array of JSON Schema fragments representing the properties, each including metadata.\n */\nexport function getPropertiesList(obj: Schema | JsonSchemaObject) {\n return Object.values(getProperties(obj));\n}\n\n/**\n * Adds a property to a JSON Schema object form.\n *\n * @remarks\n * This function modifies the provided schema in place by adding a new property with the specified name and schema. It also updates the `required` array based on the `optional` flag of the property. If the property is marked as optional, it will be removed from the `required` array; otherwise, it will be added to it.\n *\n * @param obj - The JSON Schema object form or a Schema wrapper to which the property should be added.\n * @param name - The name of the property to add.\n * @param property - The JSON Schema fragment representing the property's schema, including metadata.\n * @throws Will throw an error if the provided schema is not an object form.\n */\nexport function addProperty(\n obj: Schema | JsonSchemaObject,\n name: string,\n property: JsonSchema\n): void {\n const schema = getJsonSchemaObject(obj);\n\n schema.properties ??= {};\n schema.required ??= [];\n\n schema.properties[name] = { ...property, name };\n if (!schema.required.includes(name)) {\n schema.required.push(name);\n }\n\n if (schema.required.length === 0) {\n delete schema.required;\n }\n}\n\n/**\n * Merges multiple JSON Schemas into one.\n *\n * @remarks\n * This function takes multiple JSON Schemas or Schema wrappers and merges them into a single JSON Schema object. The merging process combines properties and metadata from all provided schemas, with later schemas in the arguments list taking precedence over earlier ones in case of conflicts. The resulting schema will include all unique properties and metadata from the input schemas.\n *\n * @param schemas - An array of JSON Schemas or Schema wrappers to merge.\n * @returns A new JSON Schema that is the result of merging all input schemas.\n */\nexport function merge(...schemas: (JsonSchema | Schema)[]): JsonSchema {\n let result: JsonSchema = {};\n for (const schema of schemas.reverse()) {\n if (\n !(result as JsonSchemaLike).type ||\n (result as JsonSchemaLike).type === (schema as JsonSchemaLike).type\n ) {\n result = defu(result, getJsonSchema(schema)) as JsonSchema;\n if (isJsonSchemaObject(result)) {\n result.required = getUnique(result.required ?? []);\n }\n }\n }\n\n return result;\n}\n\n/**\n * Returns whether a JSON Schema fragment accepts `null`.\n *\n * @remarks\n * This is true if the schema has `nullable: true` or if its `type` includes `\"null\"`.\n *\n * @param schema - The JSON Schema fragment to check.\n * @returns `true` if the schema accepts `null`, otherwise `false`.\n */\nexport function isSchemaNullable(schema?: JsonSchema): boolean {\n if (!isSetObject(schema)) {\n return false;\n }\n\n if ((schema as { nullable?: true }).nullable === true) {\n return true;\n }\n\n return readSchemaTypes(schema).includes(\"null\");\n}\n\n/**\n * Returns whether an object property is optional (not listed in `required`).\n *\n * @remarks\n * In JSON Schema, object properties are optional by default unless they are listed in the `required` array of the parent schema. This function checks whether a given property name is not included in the `required` array of its parent schema, indicating that it is optional.\n *\n * @param parent - The parent JSON Schema object containing the property.\n * @param propertyName - The name of the property to check for optionality.\n * @returns `true` if the property is optional, otherwise `false`.\n */\nexport function isPropertyOptional(\n parent: JsonSchemaObject,\n propertyName: string\n): boolean {\n if (!parent.properties?.[propertyName]) {\n throw new Error(\n `The property \"${propertyName}\" does not exist in the parent schema.`\n );\n }\n\n return !(parent.required ?? []).includes(propertyName);\n}\n\n/**\n * Checks if a given file name has a valid schema input file extension.\n *\n * @param fileName - The file name to check for a valid schema input extension.\n * @returns `true` if the file name has a valid schema input extension, otherwise `false`.\n */\nexport function isValidSchemaInputFile(fileName: string): boolean {\n return VALID_SOURCE_FILE_EXTENSIONS.includes(findFileExtensionSafe(fileName));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,cAAc,OAAwC;CACpE,MAAM,SAAS,SAAS,KAAK,IAAI,MAAM,SAAS;CAChD,IAAI,CAAC,aAAa,MAAM,GACtB,MAAM,IAAI,UACR,kDAAkD,KAAK,UACrD,QACA,MACA,CACF,GACF;CAGF,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,oBACd,OACkB;CAClB,MAAM,SAAS,cAAc,KAAK;CAClC,IAAI,CAAC,mBAAmB,MAAM,GAC5B,MAAM,IAAI,UACR,yDAAyD,KAAK,UAAU,QAAQ,MAAM,CAAC,GACzF;CAGF,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,cACd,KAIA;CACA,MAAM,aAGF,CAAC;CAEL,MAAM,SAAS,oBAAoB,GAAG;CACtC,IAAI,CAAC,YAAY,OAAO,UAAU,GAChC,OAAO;CAGT,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,UAAU,GAAG;EAC5D,MAAM,iBAA0C,CAAC;EAEjD,IAAI,OAAO,UAAU,WACnB,OAAO,OAAO,gBAAgB,KAAK;EAGrC,WAAW,OAAO;GAChB,GAAG;GACH,MAAM;GACN,UAAU,CAAC,mBAAmB,QAAQ,GAAG;GACzC,SAAS,OAAO,UAAU,QAAQ,eAAe;EACnD;CACF;CAEA,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,kBAAkB,KAAgC;CAChE,OAAO,OAAO,OAAO,cAAc,GAAG,CAAC;AACzC;;;;;;;;;;;;AAaA,SAAgB,YACd,KACA,MACA,UACM;CACN,MAAM,SAAS,oBAAoB,GAAG;CAEtC,OAAO,eAAe,CAAC;CACvB,OAAO,aAAa,CAAC;CAErB,OAAO,WAAW,QAAQ;EAAE,GAAG;EAAU;CAAK;CAC9C,IAAI,CAAC,OAAO,SAAS,SAAS,IAAI,GAChC,OAAO,SAAS,KAAK,IAAI;CAG3B,IAAI,OAAO,SAAS,WAAW,GAC7B,OAAO,OAAO;AAElB;;;;;;;;;;AAWA,SAAgB,MAAM,GAAG,SAA8C;CACrE,IAAI,SAAqB,CAAC;CAC1B,KAAK,MAAM,UAAU,QAAQ,QAAQ,GACnC,IACE,CAAE,OAA0B,QAC3B,OAA0B,SAAU,OAA0B,MAC/D;EACA,SAASA,OAAK,QAAQ,cAAc,MAAM,CAAC;EAC3C,IAAI,mBAAmB,MAAM,GAC3B,OAAO,WAAW,UAAU,OAAO,YAAY,CAAC,CAAC;CAErD;CAGF,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,iBAAiB,QAA8B;CAC7D,IAAI,CAAC,YAAY,MAAM,GACrB,OAAO;CAGT,IAAK,OAA+B,aAAa,MAC/C,OAAO;CAGT,OAAO,gBAAgB,MAAM,EAAE,SAAS,MAAM;AAChD;;;;;;;;;;;AAYA,SAAgB,mBACd,QACA,cACS;CACT,IAAI,CAAC,OAAO,aAAa,eACvB,MAAM,IAAI,MACR,iBAAiB,aAAa,uCAChC;CAGF,OAAO,EAAE,OAAO,YAAY,CAAC,GAAG,SAAS,YAAY;AACvD;;;;;;;AAQA,SAAgB,uBAAuB,UAA2B;CAChE,OAAO,6BAA6B,SAAS,sBAAsB,QAAQ,CAAC;AAC9E"}
|
package/dist/metadata.cjs
DELETED
|
@@ -1,61 +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_constants = require('./constants.cjs');
|
|
10
|
-
let _stryke_type_checks = require("@stryke/type-checks");
|
|
11
|
-
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
12
|
-
|
|
13
|
-
//#region src/metadata.ts
|
|
14
|
-
/**
|
|
15
|
-
* Applies Powerlines schema metadata onto a JSON Schema fragment.
|
|
16
|
-
*
|
|
17
|
-
* @param schema - The JSON Schema fragment to apply metadata to.
|
|
18
|
-
* @param metadata - The Powerlines schema metadata to apply.
|
|
19
|
-
* @returns A new JSON Schema fragment with the metadata applied.
|
|
20
|
-
*/
|
|
21
|
-
function applyJsonSchemaMetadata(schema, metadata) {
|
|
22
|
-
if (!metadata || !(0, _stryke_type_checks_is_set_object.isSetObject)(schema)) return schema;
|
|
23
|
-
const result = { ...schema };
|
|
24
|
-
const mutableResult = result;
|
|
25
|
-
for (const key of require_constants.JSON_SCHEMA_METADATA_KEYS) {
|
|
26
|
-
const value = metadata[key];
|
|
27
|
-
if (value !== void 0 && value !== null) mutableResult[key] = value;
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Normalizes the JSON Schema `type` keyword to a string array.
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
|
|
36
|
-
*
|
|
37
|
-
* @param schema - The JSON Schema fragment to read types from.
|
|
38
|
-
* @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
|
|
39
|
-
*/
|
|
40
|
-
function readSchemaTypes(schema) {
|
|
41
|
-
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(schema)) return [];
|
|
42
|
-
const objectSchema = schema;
|
|
43
|
-
if (Array.isArray(objectSchema.type)) return objectSchema.type.filter((type) => (0, _stryke_type_checks.isSetString)(type));
|
|
44
|
-
if ((0, _stryke_type_checks.isSetString)(objectSchema.type) && objectSchema.type !== "object" && objectSchema.type !== "array") return [objectSchema.type];
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Returns the primary non-null JSON Schema type name for a fragment.
|
|
49
|
-
*
|
|
50
|
-
* @param schema - The JSON Schema fragment to check.
|
|
51
|
-
* @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
|
|
52
|
-
*/
|
|
53
|
-
function getPrimarySchemaType(schema) {
|
|
54
|
-
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(schema)) return;
|
|
55
|
-
return readSchemaTypes(schema).find((type) => type !== "null");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
exports.applyJsonSchemaMetadata = applyJsonSchemaMetadata;
|
|
60
|
-
exports.getPrimarySchemaType = getPrimarySchemaType;
|
|
61
|
-
exports.readSchemaTypes = readSchemaTypes;
|
package/dist/metadata.d.cts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { JsonSchema, JsonSchemaMetadataKeywords, JsonSchemaPrimitiveType } from "./types.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/metadata.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Applies Powerlines schema metadata onto a JSON Schema fragment.
|
|
6
|
-
*
|
|
7
|
-
* @param schema - The JSON Schema fragment to apply metadata to.
|
|
8
|
-
* @param metadata - The Powerlines schema metadata to apply.
|
|
9
|
-
* @returns A new JSON Schema fragment with the metadata applied.
|
|
10
|
-
*/
|
|
11
|
-
declare function applyJsonSchemaMetadata(schema: JsonSchema, metadata: JsonSchemaMetadataKeywords | undefined): JsonSchema;
|
|
12
|
-
/**
|
|
13
|
-
* Normalizes the JSON Schema `type` keyword to a string array.
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
16
|
-
* This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
|
|
17
|
-
*
|
|
18
|
-
* @param schema - The JSON Schema fragment to read types from.
|
|
19
|
-
* @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
|
|
20
|
-
*/
|
|
21
|
-
declare function readSchemaTypes(schema?: JsonSchema): JsonSchemaPrimitiveType[];
|
|
22
|
-
/**
|
|
23
|
-
* Returns the primary non-null JSON Schema type name for a fragment.
|
|
24
|
-
*
|
|
25
|
-
* @param schema - The JSON Schema fragment to check.
|
|
26
|
-
* @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
|
|
27
|
-
*/
|
|
28
|
-
declare function getPrimarySchemaType(schema?: JsonSchema): JsonSchemaPrimitiveType | undefined;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes };
|
|
31
|
-
//# sourceMappingURL=metadata.d.cts.map
|
package/dist/metadata.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.cts","names":[],"sources":["../src/metadata.ts"],"mappings":";;;;;AAuCA;;;;;iBAAgB,uBAAA,CACd,MAAA,EAAQ,UAAA,EACR,QAAA,EAAU,0BAAA,eACT,UAAA;;;;;;;;;AAAU;iBA0BG,eAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB;;;;;;;iBA6BV,oBAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB"}
|
package/dist/metadata.d.mts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import __tsdown_shims_path from 'node:path';
|
|
2
|
-
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import { JsonSchema, JsonSchemaMetadataKeywords, JsonSchemaPrimitiveType } from "./types.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/metadata.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Applies Powerlines schema metadata onto a JSON Schema fragment.
|
|
8
|
-
*
|
|
9
|
-
* @param schema - The JSON Schema fragment to apply metadata to.
|
|
10
|
-
* @param metadata - The Powerlines schema metadata to apply.
|
|
11
|
-
* @returns A new JSON Schema fragment with the metadata applied.
|
|
12
|
-
*/
|
|
13
|
-
declare function applyJsonSchemaMetadata(schema: JsonSchema, metadata: JsonSchemaMetadataKeywords | undefined): JsonSchema;
|
|
14
|
-
/**
|
|
15
|
-
* Normalizes the JSON Schema `type` keyword to a string array.
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
|
|
19
|
-
*
|
|
20
|
-
* @param schema - The JSON Schema fragment to read types from.
|
|
21
|
-
* @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
|
|
22
|
-
*/
|
|
23
|
-
declare function readSchemaTypes(schema?: JsonSchema): JsonSchemaPrimitiveType[];
|
|
24
|
-
/**
|
|
25
|
-
* Returns the primary non-null JSON Schema type name for a fragment.
|
|
26
|
-
*
|
|
27
|
-
* @param schema - The JSON Schema fragment to check.
|
|
28
|
-
* @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
|
|
29
|
-
*/
|
|
30
|
-
declare function getPrimarySchemaType(schema?: JsonSchema): JsonSchemaPrimitiveType | undefined;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes };
|
|
33
|
-
//# sourceMappingURL=metadata.d.mts.map
|
package/dist/metadata.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.mts","names":[],"sources":["../src/metadata.ts"],"mappings":";;;;;;;;;;;;iBAuCgB,uBAAA,CACd,MAAA,EAAQ,UAAA,EACR,QAAA,EAAU,0BAAA,eACT,UAAA;;;AAHH;;;;;;;iBA6BgB,eAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB;;;;;;;iBA6BV,oBAAA,CACd,MAAA,GAAS,UAAA,GACR,uBAAuB"}
|
package/dist/metadata.mjs
DELETED
|
@@ -1,60 +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 { JSON_SCHEMA_METADATA_KEYS } from "./constants.mjs";
|
|
10
|
-
import { isSetString } from "@stryke/type-checks";
|
|
11
|
-
import { isSetObject as isSetObject$1 } from "@stryke/type-checks/is-set-object";
|
|
12
|
-
|
|
13
|
-
//#region src/metadata.ts
|
|
14
|
-
/**
|
|
15
|
-
* Applies Powerlines schema metadata onto a JSON Schema fragment.
|
|
16
|
-
*
|
|
17
|
-
* @param schema - The JSON Schema fragment to apply metadata to.
|
|
18
|
-
* @param metadata - The Powerlines schema metadata to apply.
|
|
19
|
-
* @returns A new JSON Schema fragment with the metadata applied.
|
|
20
|
-
*/
|
|
21
|
-
function applyJsonSchemaMetadata(schema, metadata) {
|
|
22
|
-
if (!metadata || !isSetObject$1(schema)) return schema;
|
|
23
|
-
const result = { ...schema };
|
|
24
|
-
const mutableResult = result;
|
|
25
|
-
for (const key of JSON_SCHEMA_METADATA_KEYS) {
|
|
26
|
-
const value = metadata[key];
|
|
27
|
-
if (value !== void 0 && value !== null) mutableResult[key] = value;
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Normalizes the JSON Schema `type` keyword to a string array.
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.
|
|
36
|
-
*
|
|
37
|
-
* @param schema - The JSON Schema fragment to read types from.
|
|
38
|
-
* @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.
|
|
39
|
-
*/
|
|
40
|
-
function readSchemaTypes(schema) {
|
|
41
|
-
if (!isSetObject$1(schema)) return [];
|
|
42
|
-
const objectSchema = schema;
|
|
43
|
-
if (Array.isArray(objectSchema.type)) return objectSchema.type.filter((type) => isSetString(type));
|
|
44
|
-
if (isSetString(objectSchema.type) && objectSchema.type !== "object" && objectSchema.type !== "array") return [objectSchema.type];
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Returns the primary non-null JSON Schema type name for a fragment.
|
|
49
|
-
*
|
|
50
|
-
* @param schema - The JSON Schema fragment to check.
|
|
51
|
-
* @returns The primary non-null JSON Schema type name, or `undefined` if none is found.
|
|
52
|
-
*/
|
|
53
|
-
function getPrimarySchemaType(schema) {
|
|
54
|
-
if (!isSetObject$1(schema)) return;
|
|
55
|
-
return readSchemaTypes(schema).find((type) => type !== "null");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
export { applyJsonSchemaMetadata, getPrimarySchemaType, readSchemaTypes };
|
|
60
|
-
//# sourceMappingURL=metadata.mjs.map
|
package/dist/metadata.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.mjs","names":["isSetObject"],"sources":["../src/metadata.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 { isSetString } from \"@stryke/type-checks\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { JSON_SCHEMA_METADATA_KEYS } from \"./constants\";\nimport {\n JsonSchema,\n JsonSchemaMetadataKeywords,\n JsonSchemaPrimitiveType,\n JsonSchemaType\n} from \"./types\";\n\ninterface JsonSchemaTypeView {\n type?: JsonSchemaType | readonly JsonSchemaType[];\n}\n\n/**\n * Applies Powerlines schema metadata onto a JSON Schema fragment.\n *\n * @param schema - The JSON Schema fragment to apply metadata to.\n * @param metadata - The Powerlines schema metadata to apply.\n * @returns A new JSON Schema fragment with the metadata applied.\n */\nexport function applyJsonSchemaMetadata(\n schema: JsonSchema,\n metadata: JsonSchemaMetadataKeywords | undefined\n): JsonSchema {\n if (!metadata || !isSetObject(schema)) {\n return schema;\n }\n\n const result: JsonSchema = { ...schema };\n const mutableResult = result as Record<string, unknown>;\n for (const key of JSON_SCHEMA_METADATA_KEYS) {\n const value = metadata[key];\n if (value !== undefined && value !== null) {\n mutableResult[key] = value;\n }\n }\n\n return result;\n}\n\n/**\n * Normalizes the JSON Schema `type` keyword to a string array.\n *\n * @remarks\n * This function ensures that the `type` keyword of a JSON Schema fragment is always represented as an array of strings, even if it was originally defined as a single string. This normalization simplifies type checking and processing of JSON Schemas by providing a consistent format for the `type` information.\n *\n * @param schema - The JSON Schema fragment to read types from.\n * @returns An array of JSON Schema primitive type names defined in the `type` keyword, or an empty array if no valid types are found.\n */\nexport function readSchemaTypes(\n schema?: JsonSchema\n): JsonSchemaPrimitiveType[] {\n if (!isSetObject(schema)) {\n return [];\n }\n\n const objectSchema = schema as JsonSchemaTypeView;\n\n if (Array.isArray(objectSchema.type)) {\n return objectSchema.type.filter(\n (type: JsonSchemaPrimitiveType): type is JsonSchemaPrimitiveType =>\n isSetString(type)\n );\n }\n if (\n isSetString(objectSchema.type) &&\n objectSchema.type !== \"object\" &&\n objectSchema.type !== \"array\"\n ) {\n return [objectSchema.type];\n }\n return [];\n}\n\n/**\n * Returns the primary non-null JSON Schema type name for a fragment.\n *\n * @param schema - The JSON Schema fragment to check.\n * @returns The primary non-null JSON Schema type name, or `undefined` if none is found.\n */\nexport function getPrimarySchemaType(\n schema?: JsonSchema\n): JsonSchemaPrimitiveType | undefined {\n if (!isSetObject(schema)) {\n return undefined;\n }\n\n return readSchemaTypes(schema).find(type => type !== \"null\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBACd,QACA,UACY;CACZ,IAAI,CAAC,YAAY,CAACA,cAAY,MAAM,GAClC,OAAO;CAGT,MAAM,SAAqB,EAAE,GAAG,OAAO;CACvC,MAAM,gBAAgB;CACtB,KAAK,MAAM,OAAO,2BAA2B;EAC3C,MAAM,QAAQ,SAAS;EACvB,IAAI,UAAU,UAAa,UAAU,MACnC,cAAc,OAAO;CAEzB;CAEA,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,gBACd,QAC2B;CAC3B,IAAI,CAACA,cAAY,MAAM,GACrB,OAAO,CAAC;CAGV,MAAM,eAAe;CAErB,IAAI,MAAM,QAAQ,aAAa,IAAI,GACjC,OAAO,aAAa,KAAK,QACtB,SACC,YAAY,IAAI,CACpB;CAEF,IACE,YAAY,aAAa,IAAI,KAC7B,aAAa,SAAS,YACtB,aAAa,SAAS,SAEtB,OAAO,CAAC,aAAa,IAAI;CAE3B,OAAO,CAAC;AACV;;;;;;;AAQA,SAAgB,qBACd,QACqC;CACrC,IAAI,CAACA,cAAY,MAAM,GACrB;CAGF,OAAO,gBAAgB,MAAM,EAAE,MAAK,SAAQ,SAAS,MAAM;AAC7D"}
|
package/dist/persistence.cjs
DELETED
|
@@ -1,82 +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_type_checks = require('./type-checks.cjs');
|
|
10
|
-
const require_extract = require('./extract.cjs');
|
|
11
|
-
let _stryke_path_join = require("@stryke/path/join");
|
|
12
|
-
|
|
13
|
-
//#region src/persistence.ts
|
|
14
|
-
/**
|
|
15
|
-
* A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
|
|
16
|
-
*
|
|
17
|
-
* @param context - The context object providing access to the cache path.
|
|
18
|
-
* @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
|
|
19
|
-
*/
|
|
20
|
-
function getCacheDirectory(context) {
|
|
21
|
-
return (0, _stryke_path_join.joinPaths)(context.cachePath, "schemas");
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* A helper function to get the file path for a cached schema based on the provided context and schema input. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file by joining the cache directory path (obtained from the `getCacheDirectory` function) with a filename derived from the extracted hash. The resulting file path points to where the cached schema should be stored or retrieved from in the file system. This function is essential for ensuring that all operations related to caching schemas use a consistent method for determining the correct file path based on the schema's unique identifier (hash).
|
|
25
|
-
*
|
|
26
|
-
* @param context - The context object providing access to the cache path.
|
|
27
|
-
* @param input - The input schema from which to extract the variant and hash for constructing the cache file path.
|
|
28
|
-
* @returns The file path to the cached schema JSON file, constructed by joining the cache directory path with a filename derived from the extracted hash of the schema input.
|
|
29
|
-
*/
|
|
30
|
-
function getCacheFilePath(context, input) {
|
|
31
|
-
const hash = require_extract.extractHash(require_extract.extractVariant(input), input);
|
|
32
|
-
return (0, _stryke_path_join.joinPaths)(getCacheDirectory(context), `${hash}.json`);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Writes a given schema to the file system using the provided context. This function first checks if the input is a valid schema using the `isSchema` type guard. If the input is not a valid schema, it throws an error indicating that the provided input is invalid. If the input is valid, it proceeds to write the schema to a JSON file in the cache directory specified by the context. The file is named using the hash of the schema to ensure uniqueness and easy retrieval in future operations. The schema is serialized to JSON format before being written to the file system. This function is asynchronous and returns a promise that resolves once the writing operation is complete.
|
|
36
|
-
*
|
|
37
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
38
|
-
* @param schema - The schema to be written to the file system, which must be a valid schema object containing a `variant`, `schema`, and `hash` property.
|
|
39
|
-
* @throws Will throw an error if the provided input is not a valid schema.
|
|
40
|
-
*/
|
|
41
|
-
async function writeSchema(context, schema) {
|
|
42
|
-
if (!require_type_checks.isSchema(schema)) throw new Error(`The provided input is not a valid schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);
|
|
43
|
-
await context.fs.write(getCacheFilePath(context, schema), JSON.stringify(schema.schema));
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* A helper function to read a schema from the file system using the provided context. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file based on the cache path provided in the context and the extracted hash. The function checks if the file exists in the cache; if it does not exist, it returns `undefined`. If the file exists, it reads the contents of the file, parses it as JSON, and returns the resulting object. This function is asynchronous and returns a promise that resolves to either the parsed schema object or `undefined` if the schema is not found in the cache.
|
|
47
|
-
*
|
|
48
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
49
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
50
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or `undefined` if the schema does not exist in the cache.
|
|
51
|
-
*/
|
|
52
|
-
async function readSchemaSafe(context, input) {
|
|
53
|
-
const cacheFilePath = getCacheFilePath(context, input);
|
|
54
|
-
if (!await context.fs.exists(cacheFilePath)) return;
|
|
55
|
-
const data = await context.fs.read(cacheFilePath);
|
|
56
|
-
if (!data) return;
|
|
57
|
-
return JSON.parse(data);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Reads a schema from the file system using the provided context and input. This function first attempts to read the schema using the `readSchemaSafe` helper function, which returns `undefined` if the schema is not found in the cache. If the schema is not found, this function throws an error indicating that the schema with the specified variant and hash does not exist in the cache. The error message suggests that this may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. It advises ensuring that the schema is properly written to the cache before attempting to read it. If the schema is successfully read from the cache, it is returned as a parsed object. This function is asynchronous and returns a promise that resolves to the parsed schema object if found, or throws an error if the schema is not found in the cache.
|
|
61
|
-
*
|
|
62
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
63
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
64
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or throws an error if the schema does not exist in the cache.
|
|
65
|
-
* @throws Will throw an error if the schema with the specified variant and hash does not exist in the cache.
|
|
66
|
-
*/
|
|
67
|
-
async function readSchema(context, input) {
|
|
68
|
-
const schema = await readSchemaSafe(context, input);
|
|
69
|
-
if (!schema) {
|
|
70
|
-
const variant = require_extract.extractVariant(input);
|
|
71
|
-
const hash = require_extract.extractHash(variant, input);
|
|
72
|
-
throw new Error(`The ${variant} schema with hash "${hash}" does not exist in the cache. This may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. Please ensure that the schema is properly written to the cache before attempting to read it.`);
|
|
73
|
-
}
|
|
74
|
-
return schema;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
exports.getCacheDirectory = getCacheDirectory;
|
|
79
|
-
exports.getCacheFilePath = getCacheFilePath;
|
|
80
|
-
exports.readSchema = readSchema;
|
|
81
|
-
exports.readSchemaSafe = readSchemaSafe;
|
|
82
|
-
exports.writeSchema = writeSchema;
|
package/dist/persistence.d.cts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Schema, SchemaInput } from "./types.cjs";
|
|
2
|
-
import { Context } from "@powerlines/core";
|
|
3
|
-
|
|
4
|
-
//#region src/persistence.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
|
|
7
|
-
*
|
|
8
|
-
* @param context - The context object providing access to the cache path.
|
|
9
|
-
* @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
|
|
10
|
-
*/
|
|
11
|
-
declare function getCacheDirectory(context: Context): string;
|
|
12
|
-
/**
|
|
13
|
-
* A helper function to get the file path for a cached schema based on the provided context and schema input. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file by joining the cache directory path (obtained from the `getCacheDirectory` function) with a filename derived from the extracted hash. The resulting file path points to where the cached schema should be stored or retrieved from in the file system. This function is essential for ensuring that all operations related to caching schemas use a consistent method for determining the correct file path based on the schema's unique identifier (hash).
|
|
14
|
-
*
|
|
15
|
-
* @param context - The context object providing access to the cache path.
|
|
16
|
-
* @param input - The input schema from which to extract the variant and hash for constructing the cache file path.
|
|
17
|
-
* @returns The file path to the cached schema JSON file, constructed by joining the cache directory path with a filename derived from the extracted hash of the schema input.
|
|
18
|
-
*/
|
|
19
|
-
declare function getCacheFilePath(context: Context, input: SchemaInput): string;
|
|
20
|
-
/**
|
|
21
|
-
* Writes a given schema to the file system using the provided context. This function first checks if the input is a valid schema using the `isSchema` type guard. If the input is not a valid schema, it throws an error indicating that the provided input is invalid. If the input is valid, it proceeds to write the schema to a JSON file in the cache directory specified by the context. The file is named using the hash of the schema to ensure uniqueness and easy retrieval in future operations. The schema is serialized to JSON format before being written to the file system. This function is asynchronous and returns a promise that resolves once the writing operation is complete.
|
|
22
|
-
*
|
|
23
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
24
|
-
* @param schema - The schema to be written to the file system, which must be a valid schema object containing a `variant`, `schema`, and `hash` property.
|
|
25
|
-
* @throws Will throw an error if the provided input is not a valid schema.
|
|
26
|
-
*/
|
|
27
|
-
declare function writeSchema(context: Context, schema: Schema): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* A helper function to read a schema from the file system using the provided context. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file based on the cache path provided in the context and the extracted hash. The function checks if the file exists in the cache; if it does not exist, it returns `undefined`. If the file exists, it reads the contents of the file, parses it as JSON, and returns the resulting object. This function is asynchronous and returns a promise that resolves to either the parsed schema object or `undefined` if the schema is not found in the cache.
|
|
30
|
-
*
|
|
31
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
32
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
33
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or `undefined` if the schema does not exist in the cache.
|
|
34
|
-
*/
|
|
35
|
-
declare function readSchemaSafe(context: Context, input: SchemaInput): Promise<Schema | undefined>;
|
|
36
|
-
/**
|
|
37
|
-
* Reads a schema from the file system using the provided context and input. This function first attempts to read the schema using the `readSchemaSafe` helper function, which returns `undefined` if the schema is not found in the cache. If the schema is not found, this function throws an error indicating that the schema with the specified variant and hash does not exist in the cache. The error message suggests that this may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. It advises ensuring that the schema is properly written to the cache before attempting to read it. If the schema is successfully read from the cache, it is returned as a parsed object. This function is asynchronous and returns a promise that resolves to the parsed schema object if found, or throws an error if the schema is not found in the cache.
|
|
38
|
-
*
|
|
39
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
40
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
41
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or throws an error if the schema does not exist in the cache.
|
|
42
|
-
* @throws Will throw an error if the schema with the specified variant and hash does not exist in the cache.
|
|
43
|
-
*/
|
|
44
|
-
declare function readSchema(context: Context, input: SchemaInput): Promise<Schema>;
|
|
45
|
-
//#endregion
|
|
46
|
-
export { getCacheDirectory, getCacheFilePath, readSchema, readSchemaSafe, writeSchema };
|
|
47
|
-
//# sourceMappingURL=persistence.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.cts","names":[],"sources":["../src/persistence.ts"],"mappings":";;;;;;AA8BA;;;;iBAAgB,iBAAA,CAAkB,OAAgB,EAAP,OAAO;AAWlD;;;;;;;AAAA,iBAAgB,gBAAA,CAAiB,OAAA,EAAS,OAAA,EAAS,KAAA,EAAO,WAAW;;AAAA;AAcrE;;;;;iBAAsB,WAAA,CAAY,OAAA,EAAS,OAAA,EAAS,MAAA,EAAQ,MAAA,GAAM,OAAA;;;;;;;;iBAoB5C,cAAA,CACpB,OAAA,EAAS,OAAA,EACT,KAAA,EAAO,WAAA,GACN,OAAA,CAAQ,MAAA;AAvBuD;AAoBlE;;;;;;;AApBkE,iBA6C5C,UAAA,CACpB,OAAA,EAAS,OAAA,EACT,KAAA,EAAO,WAAA,GACN,OAAA,CAAQ,MAAA"}
|
package/dist/persistence.d.mts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import __tsdown_shims_path from 'node:path';
|
|
2
|
-
import __tsdown_shims_url from 'node:url';
|
|
3
|
-
import { Schema, SchemaInput } from "./types.mjs";
|
|
4
|
-
import { Context } from "@powerlines/core";
|
|
5
|
-
|
|
6
|
-
//#region src/persistence.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
|
|
9
|
-
*
|
|
10
|
-
* @param context - The context object providing access to the cache path.
|
|
11
|
-
* @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
|
|
12
|
-
*/
|
|
13
|
-
declare function getCacheDirectory(context: Context): string;
|
|
14
|
-
/**
|
|
15
|
-
* A helper function to get the file path for a cached schema based on the provided context and schema input. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file by joining the cache directory path (obtained from the `getCacheDirectory` function) with a filename derived from the extracted hash. The resulting file path points to where the cached schema should be stored or retrieved from in the file system. This function is essential for ensuring that all operations related to caching schemas use a consistent method for determining the correct file path based on the schema's unique identifier (hash).
|
|
16
|
-
*
|
|
17
|
-
* @param context - The context object providing access to the cache path.
|
|
18
|
-
* @param input - The input schema from which to extract the variant and hash for constructing the cache file path.
|
|
19
|
-
* @returns The file path to the cached schema JSON file, constructed by joining the cache directory path with a filename derived from the extracted hash of the schema input.
|
|
20
|
-
*/
|
|
21
|
-
declare function getCacheFilePath(context: Context, input: SchemaInput): string;
|
|
22
|
-
/**
|
|
23
|
-
* Writes a given schema to the file system using the provided context. This function first checks if the input is a valid schema using the `isSchema` type guard. If the input is not a valid schema, it throws an error indicating that the provided input is invalid. If the input is valid, it proceeds to write the schema to a JSON file in the cache directory specified by the context. The file is named using the hash of the schema to ensure uniqueness and easy retrieval in future operations. The schema is serialized to JSON format before being written to the file system. This function is asynchronous and returns a promise that resolves once the writing operation is complete.
|
|
24
|
-
*
|
|
25
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
26
|
-
* @param schema - The schema to be written to the file system, which must be a valid schema object containing a `variant`, `schema`, and `hash` property.
|
|
27
|
-
* @throws Will throw an error if the provided input is not a valid schema.
|
|
28
|
-
*/
|
|
29
|
-
declare function writeSchema(context: Context, schema: Schema): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* A helper function to read a schema from the file system using the provided context. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file based on the cache path provided in the context and the extracted hash. The function checks if the file exists in the cache; if it does not exist, it returns `undefined`. If the file exists, it reads the contents of the file, parses it as JSON, and returns the resulting object. This function is asynchronous and returns a promise that resolves to either the parsed schema object or `undefined` if the schema is not found in the cache.
|
|
32
|
-
*
|
|
33
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
34
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
35
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or `undefined` if the schema does not exist in the cache.
|
|
36
|
-
*/
|
|
37
|
-
declare function readSchemaSafe(context: Context, input: SchemaInput): Promise<Schema | undefined>;
|
|
38
|
-
/**
|
|
39
|
-
* Reads a schema from the file system using the provided context and input. This function first attempts to read the schema using the `readSchemaSafe` helper function, which returns `undefined` if the schema is not found in the cache. If the schema is not found, this function throws an error indicating that the schema with the specified variant and hash does not exist in the cache. The error message suggests that this may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. It advises ensuring that the schema is properly written to the cache before attempting to read it. If the schema is successfully read from the cache, it is returned as a parsed object. This function is asynchronous and returns a promise that resolves to the parsed schema object if found, or throws an error if the schema is not found in the cache.
|
|
40
|
-
*
|
|
41
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
42
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
43
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or throws an error if the schema does not exist in the cache.
|
|
44
|
-
* @throws Will throw an error if the schema with the specified variant and hash does not exist in the cache.
|
|
45
|
-
*/
|
|
46
|
-
declare function readSchema(context: Context, input: SchemaInput): Promise<Schema>;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { getCacheDirectory, getCacheFilePath, readSchema, readSchemaSafe, writeSchema };
|
|
49
|
-
//# sourceMappingURL=persistence.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.mts","names":[],"sources":["../src/persistence.ts"],"mappings":";;;;;;;;;;;;iBA8BgB,iBAAA,CAAkB,OAAgB,EAAP,OAAO;;;;AAAlD;;;;iBAWgB,gBAAA,CAAiB,OAAA,EAAS,OAAA,EAAS,KAAA,EAAO,WAAW;AAArE;;;;;;;AAAA,iBAcsB,WAAA,CAAY,OAAA,EAAS,OAAA,EAAS,MAAA,EAAQ,MAAA,GAAM,OAAA;;AAdG;AAcrE;;;;;iBAoBsB,cAAA,CACpB,OAAA,EAAS,OAAA,EACT,KAAA,EAAO,WAAA,GACN,OAAA,CAAQ,MAAA;;;;;;;;;iBAsBW,UAAA,CACpB,OAAA,EAAS,OAAA,EACT,KAAA,EAAO,WAAA,GACN,OAAA,CAAQ,MAAA"}
|
package/dist/persistence.mjs
DELETED
|
@@ -1,79 +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 { isSchema } from "./type-checks.mjs";
|
|
10
|
-
import { extractHash, extractVariant } from "./extract.mjs";
|
|
11
|
-
import { joinPaths } from "@stryke/path/join";
|
|
12
|
-
|
|
13
|
-
//#region src/persistence.ts
|
|
14
|
-
/**
|
|
15
|
-
* A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named "schemas". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.
|
|
16
|
-
*
|
|
17
|
-
* @param context - The context object providing access to the cache path.
|
|
18
|
-
* @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the "schemas" subdirectory.
|
|
19
|
-
*/
|
|
20
|
-
function getCacheDirectory(context) {
|
|
21
|
-
return joinPaths(context.cachePath, "schemas");
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* A helper function to get the file path for a cached schema based on the provided context and schema input. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file by joining the cache directory path (obtained from the `getCacheDirectory` function) with a filename derived from the extracted hash. The resulting file path points to where the cached schema should be stored or retrieved from in the file system. This function is essential for ensuring that all operations related to caching schemas use a consistent method for determining the correct file path based on the schema's unique identifier (hash).
|
|
25
|
-
*
|
|
26
|
-
* @param context - The context object providing access to the cache path.
|
|
27
|
-
* @param input - The input schema from which to extract the variant and hash for constructing the cache file path.
|
|
28
|
-
* @returns The file path to the cached schema JSON file, constructed by joining the cache directory path with a filename derived from the extracted hash of the schema input.
|
|
29
|
-
*/
|
|
30
|
-
function getCacheFilePath(context, input) {
|
|
31
|
-
const hash = extractHash(extractVariant(input), input);
|
|
32
|
-
return joinPaths(getCacheDirectory(context), `${hash}.json`);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Writes a given schema to the file system using the provided context. This function first checks if the input is a valid schema using the `isSchema` type guard. If the input is not a valid schema, it throws an error indicating that the provided input is invalid. If the input is valid, it proceeds to write the schema to a JSON file in the cache directory specified by the context. The file is named using the hash of the schema to ensure uniqueness and easy retrieval in future operations. The schema is serialized to JSON format before being written to the file system. This function is asynchronous and returns a promise that resolves once the writing operation is complete.
|
|
36
|
-
*
|
|
37
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
38
|
-
* @param schema - The schema to be written to the file system, which must be a valid schema object containing a `variant`, `schema`, and `hash` property.
|
|
39
|
-
* @throws Will throw an error if the provided input is not a valid schema.
|
|
40
|
-
*/
|
|
41
|
-
async function writeSchema(context, schema) {
|
|
42
|
-
if (!isSchema(schema)) throw new Error(`The provided input is not a valid schema. A valid schema must have a "variant" property indicating the type of the input and a "schema" property containing the parsed JSON Schema object.`);
|
|
43
|
-
await context.fs.write(getCacheFilePath(context, schema), JSON.stringify(schema.schema));
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* A helper function to read a schema from the file system using the provided context. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file based on the cache path provided in the context and the extracted hash. The function checks if the file exists in the cache; if it does not exist, it returns `undefined`. If the file exists, it reads the contents of the file, parses it as JSON, and returns the resulting object. This function is asynchronous and returns a promise that resolves to either the parsed schema object or `undefined` if the schema is not found in the cache.
|
|
47
|
-
*
|
|
48
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
49
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
50
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or `undefined` if the schema does not exist in the cache.
|
|
51
|
-
*/
|
|
52
|
-
async function readSchemaSafe(context, input) {
|
|
53
|
-
const cacheFilePath = getCacheFilePath(context, input);
|
|
54
|
-
if (!await context.fs.exists(cacheFilePath)) return;
|
|
55
|
-
const data = await context.fs.read(cacheFilePath);
|
|
56
|
-
if (!data) return;
|
|
57
|
-
return JSON.parse(data);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Reads a schema from the file system using the provided context and input. This function first attempts to read the schema using the `readSchemaSafe` helper function, which returns `undefined` if the schema is not found in the cache. If the schema is not found, this function throws an error indicating that the schema with the specified variant and hash does not exist in the cache. The error message suggests that this may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. It advises ensuring that the schema is properly written to the cache before attempting to read it. If the schema is successfully read from the cache, it is returned as a parsed object. This function is asynchronous and returns a promise that resolves to the parsed schema object if found, or throws an error if the schema is not found in the cache.
|
|
61
|
-
*
|
|
62
|
-
* @param context - The context object providing access to the file system and cache path.
|
|
63
|
-
* @param input - The input schema from which to extract the variant and hash for locating the cached schema file.
|
|
64
|
-
* @returns A promise that resolves to the parsed schema object if found in the cache, or throws an error if the schema does not exist in the cache.
|
|
65
|
-
* @throws Will throw an error if the schema with the specified variant and hash does not exist in the cache.
|
|
66
|
-
*/
|
|
67
|
-
async function readSchema(context, input) {
|
|
68
|
-
const schema = await readSchemaSafe(context, input);
|
|
69
|
-
if (!schema) {
|
|
70
|
-
const variant = extractVariant(input);
|
|
71
|
-
const hash = extractHash(variant, input);
|
|
72
|
-
throw new Error(`The ${variant} schema with hash "${hash}" does not exist in the cache. This may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. Please ensure that the schema is properly written to the cache before attempting to read it.`);
|
|
73
|
-
}
|
|
74
|
-
return schema;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
export { getCacheDirectory, getCacheFilePath, readSchema, readSchemaSafe, writeSchema };
|
|
79
|
-
//# sourceMappingURL=persistence.mjs.map
|
package/dist/persistence.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.mjs","names":[],"sources":["../src/persistence.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 { Context } from \"@powerlines/core\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { extractHash, extractVariant } from \"./extract\";\nimport { isSchema } from \"./type-checks\";\nimport { Schema, SchemaInput } from \"./types\";\n\n/**\n * A helper function to get the cache directory path for storing schemas. This function takes a context object as input and returns the path to the cache directory where schemas are stored. The cache directory is constructed by joining the `cachePath` property from the context with a subdirectory named \"schemas\". This function is useful for centralizing the logic for determining where schema files should be cached, ensuring that all schema-related file operations use a consistent location for storing and retrieving cached schemas.\n *\n * @param context - The context object providing access to the cache path.\n * @returns The path to the cache directory for storing schemas, constructed by joining the context's `cachePath` with the \"schemas\" subdirectory.\n */\nexport function getCacheDirectory(context: Context): string {\n return joinPaths(context.cachePath, \"schemas\");\n}\n\n/**\n * A helper function to get the file path for a cached schema based on the provided context and schema input. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file by joining the cache directory path (obtained from the `getCacheDirectory` function) with a filename derived from the extracted hash. The resulting file path points to where the cached schema should be stored or retrieved from in the file system. This function is essential for ensuring that all operations related to caching schemas use a consistent method for determining the correct file path based on the schema's unique identifier (hash).\n *\n * @param context - The context object providing access to the cache path.\n * @param input - The input schema from which to extract the variant and hash for constructing the cache file path.\n * @returns The file path to the cached schema JSON file, constructed by joining the cache directory path with a filename derived from the extracted hash of the schema input.\n */\nexport function getCacheFilePath(context: Context, input: SchemaInput): string {\n const variant = extractVariant(input);\n const hash = extractHash(variant, input);\n\n return joinPaths(getCacheDirectory(context), `${hash}.json`);\n}\n\n/**\n * Writes a given schema to the file system using the provided context. This function first checks if the input is a valid schema using the `isSchema` type guard. If the input is not a valid schema, it throws an error indicating that the provided input is invalid. If the input is valid, it proceeds to write the schema to a JSON file in the cache directory specified by the context. The file is named using the hash of the schema to ensure uniqueness and easy retrieval in future operations. The schema is serialized to JSON format before being written to the file system. This function is asynchronous and returns a promise that resolves once the writing operation is complete.\n *\n * @param context - The context object providing access to the file system and cache path.\n * @param schema - The schema to be written to the file system, which must be a valid schema object containing a `variant`, `schema`, and `hash` property.\n * @throws Will throw an error if the provided input is not a valid schema.\n */\nexport async function writeSchema(context: Context, schema: Schema) {\n if (!isSchema(schema)) {\n throw new Error(\n `The provided input is not a valid schema. A valid schema must have a \"variant\" property indicating the type of the input and a \"schema\" property containing the parsed JSON Schema object.`\n );\n }\n\n await context.fs.write(\n getCacheFilePath(context, schema),\n JSON.stringify(schema.schema)\n );\n}\n\n/**\n * A helper function to read a schema from the file system using the provided context. This function first extracts the variant and hash from the input schema using the `extractVariant` and `extractHash` functions, respectively. It then constructs the file path to the cached schema JSON file based on the cache path provided in the context and the extracted hash. The function checks if the file exists in the cache; if it does not exist, it returns `undefined`. If the file exists, it reads the contents of the file, parses it as JSON, and returns the resulting object. This function is asynchronous and returns a promise that resolves to either the parsed schema object or `undefined` if the schema is not found in the cache.\n *\n * @param context - The context object providing access to the file system and cache path.\n * @param input - The input schema from which to extract the variant and hash for locating the cached schema file.\n * @returns A promise that resolves to the parsed schema object if found in the cache, or `undefined` if the schema does not exist in the cache.\n */\nexport async function readSchemaSafe(\n context: Context,\n input: SchemaInput\n): Promise<Schema | undefined> {\n const cacheFilePath = getCacheFilePath(context, input);\n if (!(await context.fs.exists(cacheFilePath))) {\n return undefined;\n }\n\n const data = await context.fs.read(cacheFilePath);\n if (!data) {\n return undefined;\n }\n\n return JSON.parse(data);\n}\n\n/**\n * Reads a schema from the file system using the provided context and input. This function first attempts to read the schema using the `readSchemaSafe` helper function, which returns `undefined` if the schema is not found in the cache. If the schema is not found, this function throws an error indicating that the schema with the specified variant and hash does not exist in the cache. The error message suggests that this may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. It advises ensuring that the schema is properly written to the cache before attempting to read it. If the schema is successfully read from the cache, it is returned as a parsed object. This function is asynchronous and returns a promise that resolves to the parsed schema object if found, or throws an error if the schema is not found in the cache.\n *\n * @param context - The context object providing access to the file system and cache path.\n * @param input - The input schema from which to extract the variant and hash for locating the cached schema file.\n * @returns A promise that resolves to the parsed schema object if found in the cache, or throws an error if the schema does not exist in the cache.\n * @throws Will throw an error if the schema with the specified variant and hash does not exist in the cache.\n */\nexport async function readSchema(\n context: Context,\n input: SchemaInput\n): Promise<Schema> {\n const schema = await readSchemaSafe(context, input);\n if (!schema) {\n const variant = extractVariant(input);\n const hash = extractHash(variant, input);\n\n throw new Error(\n `The ${variant} schema with hash \"${\n hash\n }\" does not exist in the cache. This may be due to a missing or corrupted cache file, or because the schema has not been written to the cache yet. Please ensure that the schema is properly written to the cache before attempting to read it.`\n );\n }\n\n return schema;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,kBAAkB,SAA0B;CAC1D,OAAO,UAAU,QAAQ,WAAW,SAAS;AAC/C;;;;;;;;AASA,SAAgB,iBAAiB,SAAkB,OAA4B;CAE7E,MAAM,OAAO,YADG,eAAe,KACA,GAAG,KAAK;CAEvC,OAAO,UAAU,kBAAkB,OAAO,GAAG,GAAG,KAAK,MAAM;AAC7D;;;;;;;;AASA,eAAsB,YAAY,SAAkB,QAAgB;CAClE,IAAI,CAAC,SAAS,MAAM,GAClB,MAAM,IAAI,MACR,4LACF;CAGF,MAAM,QAAQ,GAAG,MACf,iBAAiB,SAAS,MAAM,GAChC,KAAK,UAAU,OAAO,MAAM,CAC9B;AACF;;;;;;;;AASA,eAAsB,eACpB,SACA,OAC6B;CAC7B,MAAM,gBAAgB,iBAAiB,SAAS,KAAK;CACrD,IAAI,CAAE,MAAM,QAAQ,GAAG,OAAO,aAAa,GACzC;CAGF,MAAM,OAAO,MAAM,QAAQ,GAAG,KAAK,aAAa;CAChD,IAAI,CAAC,MACH;CAGF,OAAO,KAAK,MAAM,IAAI;AACxB;;;;;;;;;AAUA,eAAsB,WACpB,SACA,OACiB;CACjB,MAAM,SAAS,MAAM,eAAe,SAAS,KAAK;CAClD,IAAI,CAAC,QAAQ;EACX,MAAM,UAAU,eAAe,KAAK;EACpC,MAAM,OAAO,YAAY,SAAS,KAAK;EAEvC,MAAM,IAAI,MACR,OAAO,QAAQ,qBACb,KACD,+OACH;CACF;CAEA,OAAO;AACT"}
|