@fgv/ts-json-base 5.1.0-19 → 5.1.0-20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/index.browser.js.map +1 -0
  2. package/dist/index.js.map +1 -0
  3. package/dist/packlets/converters/converters.js.map +1 -0
  4. package/dist/packlets/converters/index.js.map +1 -0
  5. package/dist/packlets/file-tree/directoryItem.js.map +1 -0
  6. package/dist/packlets/file-tree/fileItem.js.map +1 -0
  7. package/dist/packlets/file-tree/fileTree.js.map +1 -0
  8. package/dist/packlets/file-tree/fileTreeAccessors.js.map +1 -0
  9. package/dist/packlets/file-tree/fileTreeHelpers.inMemory.js.map +1 -0
  10. package/dist/packlets/file-tree/fileTreeHelpers.js.map +1 -0
  11. package/dist/packlets/file-tree/filterSpec.js.map +1 -0
  12. package/dist/packlets/file-tree/fsTree.js.map +1 -0
  13. package/dist/packlets/file-tree/in-memory/inMemoryTree.js.map +1 -0
  14. package/dist/packlets/file-tree/in-memory/index.js.map +1 -0
  15. package/dist/packlets/file-tree/in-memory/treeBuilder.js.map +1 -0
  16. package/dist/packlets/file-tree/index.browser.js.map +1 -0
  17. package/dist/packlets/file-tree/index.js.map +1 -0
  18. package/dist/packlets/json/common.js.map +1 -0
  19. package/dist/packlets/json/index.js.map +1 -0
  20. package/dist/packlets/json-compatible/common.js.map +1 -0
  21. package/dist/packlets/json-compatible/converters.js.map +1 -0
  22. package/dist/packlets/json-compatible/index.js.map +1 -0
  23. package/dist/packlets/json-compatible/validators.js.map +1 -0
  24. package/dist/packlets/json-file/file.js.map +1 -0
  25. package/dist/packlets/json-file/index.browser.js.map +1 -0
  26. package/dist/packlets/json-file/index.js.map +1 -0
  27. package/dist/packlets/json-file/jsonFsHelper.js.map +1 -0
  28. package/dist/packlets/json-file/jsonLike.js.map +1 -0
  29. package/dist/packlets/json-file/jsonTreeHelper.js.map +1 -0
  30. package/dist/packlets/validators/index.js.map +1 -0
  31. package/dist/packlets/validators/validators.js.map +1 -0
  32. package/lib/index.browser.d.ts.map +1 -0
  33. package/lib/index.browser.js.map +1 -0
  34. package/lib/index.d.ts.map +1 -0
  35. package/lib/index.js.map +1 -0
  36. package/lib/packlets/converters/converters.d.ts.map +1 -0
  37. package/lib/packlets/converters/converters.js.map +1 -0
  38. package/lib/packlets/converters/index.d.ts.map +1 -0
  39. package/lib/packlets/converters/index.js.map +1 -0
  40. package/lib/packlets/file-tree/directoryItem.d.ts.map +1 -0
  41. package/lib/packlets/file-tree/directoryItem.js.map +1 -0
  42. package/lib/packlets/file-tree/fileItem.d.ts.map +1 -0
  43. package/lib/packlets/file-tree/fileItem.js.map +1 -0
  44. package/lib/packlets/file-tree/fileTree.d.ts.map +1 -0
  45. package/lib/packlets/file-tree/fileTree.js.map +1 -0
  46. package/lib/packlets/file-tree/fileTreeAccessors.d.ts.map +1 -0
  47. package/lib/packlets/file-tree/fileTreeAccessors.js.map +1 -0
  48. package/lib/packlets/file-tree/fileTreeHelpers.d.ts.map +1 -0
  49. package/lib/packlets/file-tree/fileTreeHelpers.inMemory.d.ts.map +1 -0
  50. package/lib/packlets/file-tree/fileTreeHelpers.inMemory.js.map +1 -0
  51. package/lib/packlets/file-tree/fileTreeHelpers.js.map +1 -0
  52. package/lib/packlets/file-tree/filterSpec.d.ts.map +1 -0
  53. package/lib/packlets/file-tree/filterSpec.js.map +1 -0
  54. package/lib/packlets/file-tree/fsTree.d.ts.map +1 -0
  55. package/lib/packlets/file-tree/fsTree.js.map +1 -0
  56. package/lib/packlets/file-tree/in-memory/inMemoryTree.d.ts.map +1 -0
  57. package/lib/packlets/file-tree/in-memory/inMemoryTree.js.map +1 -0
  58. package/lib/packlets/file-tree/in-memory/index.d.ts.map +1 -0
  59. package/lib/packlets/file-tree/in-memory/index.js.map +1 -0
  60. package/lib/packlets/file-tree/in-memory/treeBuilder.d.ts.map +1 -0
  61. package/lib/packlets/file-tree/in-memory/treeBuilder.js.map +1 -0
  62. package/lib/packlets/file-tree/index.browser.d.ts.map +1 -0
  63. package/lib/packlets/file-tree/index.browser.js.map +1 -0
  64. package/lib/packlets/file-tree/index.d.ts.map +1 -0
  65. package/lib/packlets/file-tree/index.js.map +1 -0
  66. package/lib/packlets/json/common.d.ts.map +1 -0
  67. package/lib/packlets/json/common.js.map +1 -0
  68. package/lib/packlets/json/index.d.ts.map +1 -0
  69. package/lib/packlets/json/index.js.map +1 -0
  70. package/lib/packlets/json-compatible/common.d.ts.map +1 -0
  71. package/lib/packlets/json-compatible/common.js.map +1 -0
  72. package/lib/packlets/json-compatible/converters.d.ts.map +1 -0
  73. package/lib/packlets/json-compatible/converters.js.map +1 -0
  74. package/lib/packlets/json-compatible/index.d.ts.map +1 -0
  75. package/lib/packlets/json-compatible/index.js.map +1 -0
  76. package/lib/packlets/json-compatible/validators.d.ts.map +1 -0
  77. package/lib/packlets/json-compatible/validators.js.map +1 -0
  78. package/lib/packlets/json-file/file.d.ts.map +1 -0
  79. package/lib/packlets/json-file/file.js.map +1 -0
  80. package/lib/packlets/json-file/index.browser.d.ts.map +1 -0
  81. package/lib/packlets/json-file/index.browser.js.map +1 -0
  82. package/lib/packlets/json-file/index.d.ts.map +1 -0
  83. package/lib/packlets/json-file/index.js.map +1 -0
  84. package/lib/packlets/json-file/jsonFsHelper.d.ts.map +1 -0
  85. package/lib/packlets/json-file/jsonFsHelper.js.map +1 -0
  86. package/lib/packlets/json-file/jsonLike.d.ts.map +1 -0
  87. package/lib/packlets/json-file/jsonLike.js.map +1 -0
  88. package/lib/packlets/json-file/jsonTreeHelper.d.ts.map +1 -0
  89. package/lib/packlets/json-file/jsonTreeHelper.js.map +1 -0
  90. package/lib/packlets/validators/index.d.ts.map +1 -0
  91. package/lib/packlets/validators/index.js.map +1 -0
  92. package/lib/packlets/validators/validators.d.ts.map +1 -0
  93. package/lib/packlets/validators/validators.js.map +1 -0
  94. package/package.json +6 -6
  95. package/dist/test/fixtures/file-tree/config.json +0 -1
  96. package/dist/test/fixtures/file-tree/data/items.json +0 -1
  97. package/dist/test/fixtures/file-tree/docs/api/reference.json +0 -1
  98. package/dist/test/unit/data/file/bad/bad3.json +0 -3
  99. package/dist/test/unit/data/file/bad/thing1.json +0 -4
  100. package/dist/test/unit/data/file/bad/thing2.json +0 -3
  101. package/dist/test/unit/data/file/good/thing1.json +0 -4
  102. package/dist/test/unit/data/file/good/thing2.json +0 -3
  103. package/dist/test/unit/json-compatible/helpers.js +0 -32
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonTreeHelper.js","sourceRoot":"","sources":["../../../src/packlets/json-file/jsonTreeHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAgC,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGlF,OAAO,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAGxD;;;GAGG;AACH,MAAM,OAAO,cAAc;IAMzB;;;;OAIG;IACH,YAAmB,IAAgB;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,eAAe,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACI,gBAAgB,CAAC,QAA2B,EAAE,QAAgB;QACnE,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YACnD,0FAA0F;YAC1F,OAAO,IAAI,CAAC,WAAW,EAAuB,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACI,mBAAmB,CACxB,QAA2B,EAC3B,QAAgB,EAChB,EAAuC,EACvC,OAAY;QAEZ,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YAClE,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACnC,CAAC,CAAC,CA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GAAG,EAAa,CAAC;YACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;gBACtD,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAmB,IAAI,cAAc,EAAE,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Converter, Result, Validator, mapResults, succeed } from '@fgv/ts-utils';\nimport * as FileTree from '../file-tree';\nimport { JsonValue } from '../json';\nimport { DefaultJsonLike, IJsonLike } from './jsonLike';\nimport { IReadDirectoryItem } from './jsonFsHelper';\n\n/**\n * Helper class to work with JSON files using FileTree API (web-compatible).\n * @public\n */\nexport class JsonTreeHelper {\n /**\n * Configuration for this JsonTreeHelper.\n */\n public readonly json: IJsonLike;\n\n /**\n * Construct a new JsonTreeHelper.\n * @param json - Optional {@link JsonFile.IJsonLike | IJsonLike} used to process strings\n * and JSON values.\n */\n public constructor(json?: IJsonLike) {\n this.json = json ?? DefaultJsonLike;\n }\n\n /**\n * Read type-safe JSON from a file in a FileTree.\n * @param fileTree - The FileTree to read from\n * @param filePath - Path of the file to read within the tree\n * @returns `Success` with a {@link JsonValue | JsonValue} or `Failure`\n * with a message if an error occurs.\n */\n public readJsonFromTree(fileTree: FileTree.FileTree, filePath: string): Result<JsonValue> {\n return fileTree.getFile(filePath).onSuccess((file) => {\n // Now getContents() returns JsonCompatibleType<unknown> which is assignable to JsonValue!\n return file.getContents() as Result<JsonValue>;\n });\n }\n\n /**\n * Read a JSON file from a FileTree and apply a supplied converter or validator.\n * @param fileTree - The FileTree to read from\n * @param filePath - Path of the file to read within the tree\n * @param cv - Converter or validator used to process the file.\n * @param context - Optional context for the converter/validator\n * @returns `Success` with a result of type `<T>`, or `Failure`\n * with a message if an error occurs.\n */\n public convertJsonFromTree<T, TC = unknown>(\n fileTree: FileTree.FileTree,\n filePath: string,\n cv: Converter<T, TC> | Validator<T, TC>,\n context?: TC\n ): Result<T> {\n return this.readJsonFromTree(fileTree, filePath).onSuccess((json) => {\n return cv.convert(json, context);\n });\n }\n\n /**\n * Reads all JSON files from a directory in a FileTree and applies a converter or validator.\n * @param fileTree - The FileTree to read from\n * @param dirPath - The path of the directory within the tree\n * @param cv - Converter or validator to apply to each JSON file\n * @param filePattern - Optional regex pattern to filter files (defaults to .json files)\n * @param context - Optional context for the converter/validator\n * @returns Array of items with filename and converted content\n */\n public convertJsonDirectoryFromTree<T, TC = unknown>(\n fileTree: FileTree.FileTree,\n dirPath: string,\n cv: Converter<T, TC> | Validator<T, TC>,\n filePattern?: RegExp,\n context?: TC\n ): Result<IReadDirectoryItem<T>[]> {\n const pattern = filePattern ?? /\\.json$/;\n\n return fileTree.getDirectory(dirPath).onSuccess((dir) => {\n return dir.getChildren().onSuccess((children) => {\n const results = children\n .filter((child) => child.type === 'file' && pattern.test(child.name))\n .map((file) => {\n return this.convertJsonFromTree(fileTree, file.absolutePath, cv, context).onSuccess((item) => {\n return succeed<IReadDirectoryItem<T>>({\n filename: file.name,\n item\n });\n });\n });\n return mapResults(results);\n });\n });\n }\n\n /**\n * Reads and converts all JSON files from a directory in a FileTree,\n * returning a Map indexed by file base name.\n * @param fileTree - The FileTree to read from\n * @param dirPath - The path of the directory within the tree\n * @param cv - Converter or validator to apply to each JSON file\n * @param filePattern - Optional regex pattern to filter files\n * @param context - Optional context for the converter/validator\n * @returns Map of basename to converted content\n */\n public convertJsonDirectoryToMapFromTree<T, TC = unknown>(\n fileTree: FileTree.FileTree,\n dirPath: string,\n cv: Converter<T, TC> | Validator<T, TC>,\n filePattern?: RegExp,\n context?: TC\n ): Result<Map<string, T>> {\n return this.convertJsonDirectoryFromTree(fileTree, dirPath, cv, filePattern, context).onSuccess(\n (items) => {\n const map = new Map<string, T>();\n for (const item of items) {\n const basename = item.filename.replace(/\\.json$/, '');\n map.set(basename, item.item);\n }\n return succeed(map);\n }\n );\n }\n}\n\n/**\n * @public\n */\nexport const DefaultJsonTreeHelper: JsonTreeHelper = new JsonTreeHelper();\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/validators/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,cAAc,cAAc,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './validators';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/packlets/validators/validators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAW,UAAU,EAAa,IAAI,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAmD,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAYrG;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,IAAI,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACnC,SAAS,EAAE,CACT,IAAa,EACb,GAA2B,EAC3B,IAAsD,EACpB,EAAE;QACpC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,QAAQ,OAAO,IAAI,EAAE,CAAC;YACpB,KAAK,SAAS,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC;YACd,KAAK,QAAQ;gBACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxB,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,MAAM;QACV,CAAC;QACD,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SAAS,EAAE,CAAC,IAAa,EAAE,OAAkD,EAAwB,EAAE;YACrG,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,OAA4B,CAAC,CAAC,CAAC,MAAM,CAAC;YACxF,MAAM,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,IAAS,CAAC,CAAC;YACjD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,4BAA4B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7E,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Failure, Validation, Validator, fail } from '@fgv/ts-utils';\nimport { JsonArray, JsonObject, JsonPrimitive, JsonValue, isJsonArray, isJsonObject } from '../json';\n\n/* eslint-disable @typescript-eslint/no-use-before-define */\n\n/**\n * Validation context for in-place JSON validators.\n * @public\n */\nexport interface IJsonValidatorContext {\n ignoreUndefinedProperties?: boolean;\n}\n\n/**\n * An in-place validator which validates that a supplied `unknown` value is\n * a valid {@link JsonPrimitive | JsonPrimitive}.\n * @public\n */\nexport const jsonPrimitive: Validator<JsonPrimitive, IJsonValidatorContext> =\n new Validation.Base.GenericValidator({\n validator: (\n from: unknown,\n ctx?: IJsonValidatorContext,\n self?: Validator<JsonPrimitive, IJsonValidatorContext>\n ): boolean | Failure<JsonPrimitive> => {\n if (from === null) {\n return true;\n }\n switch (typeof from) {\n case 'boolean':\n case 'string':\n return true;\n case 'number':\n if (!Number.isNaN(from)) {\n return true;\n }\n break;\n }\n if (from === undefined && ctx?.ignoreUndefinedProperties === true) {\n return true;\n }\n return fail(`\"${String(from)}\": invalid JSON primitive.`);\n }\n });\n\n/**\n * An in-place validator which validates that a supplied `unknown` value is\n * a valid {@link JsonObject | JsonObject}. Fails by default if any properties or array elements\n * are `undefined` - this default behavior can be overridden by supplying an appropriate\n * {@link Validators.IJsonValidatorContext | context} at runtime.\n * @public\n */\nexport const jsonObject: Validator<JsonObject, IJsonValidatorContext> = new Validation.Base.GenericValidator({\n validator: (\n from: unknown,\n ctx?: IJsonValidatorContext,\n self?: Validator<JsonObject, IJsonValidatorContext>\n ) => {\n if (!isJsonObject(from)) {\n return fail('invalid JSON object.');\n }\n const errors: string[] = [];\n for (const [name, value] of Object.entries(from)) {\n jsonValue.validate(value, ctx).onFailure((m) => {\n errors.push(`${name}: ${m}`);\n return fail(m);\n });\n }\n if (errors.length > 0) {\n return fail(`invalid JSON object:\\n${errors.join('\\n')}`);\n }\n return true;\n }\n});\n\n/**\n * An in-place validator which validates that a supplied `unknown` value is\n * a valid {@link JsonArray | JsonArray}. Fails by default if any properties or array elements\n * are `undefined` - this default behavior can be overridden by supplying an appropriate\n * {@link Validators.IJsonValidatorContext | context} at runtime.\n * @public\n */\nexport const jsonArray: Validator<JsonArray, IJsonValidatorContext> = new Validation.Base.GenericValidator({\n validator: (\n from: unknown,\n ctx?: IJsonValidatorContext,\n self?: Validator<JsonArray, IJsonValidatorContext>\n ) => {\n if (!isJsonArray(from)) {\n return fail('not an array');\n }\n const errors: string[] = [];\n for (let i = 0; i < from.length; i++) {\n const value = from[i];\n jsonValue.validate(value, ctx).onFailure((m) => {\n errors.push(`${i}: ${m}`);\n return fail(m);\n });\n }\n if (errors.length > 0) {\n return fail(`array contains non-json elements:\\n${errors.join('\\n')}`);\n }\n return true;\n }\n});\n\n/**\n * An in-place validator which validates that a supplied `unknown` value is\n * a valid {@link JsonValue | JsonValue}. Fails by default if any properties or array elements\n * are `undefined` - this default behavior can be overridden by supplying an appropriate\n * {@link Validators.IJsonValidatorContext | context} at runtime.\n * @public\n */\nexport const jsonValue: Validator<JsonValue, IJsonValidatorContext> = new Validation.Base.GenericValidator<\n JsonValue,\n IJsonValidatorContext\n>({\n validator: (\n from: unknown,\n ctx?: IJsonValidatorContext,\n self?: Validator<JsonValue, IJsonValidatorContext>\n ) => {\n if (isJsonArray(from)) {\n const result = jsonArray.validate(from, ctx);\n return result.success === true ? true : result;\n } else if (isJsonObject(from)) {\n const result = jsonObject.validate(from, ctx);\n return result.success === true ? true : result;\n }\n const result = jsonPrimitive.validate(from, ctx);\n return result.success === true ? true : result;\n }\n});\n\n/**\n * A `StringValidator` which validates a string in place.\n * Accepts {@link Validators.IJsonValidatorContext | IJsonValidatorContext} but ignores it.\n * @public\n */\nexport const string: Validation.Classes.StringValidator<string, IJsonValidatorContext> =\n new Validation.Classes.StringValidator<string, IJsonValidatorContext>();\n\n/**\n * A `NumberValidator` which validates a number in place.\n * Accepts {@link Validators.IJsonValidatorContext | IJsonValidatorContext} but ignores it.\n * @public\n */\nexport const number: Validation.Classes.NumberValidator<number, IJsonValidatorContext> =\n new Validation.Classes.NumberValidator<number, IJsonValidatorContext>();\n\n/**\n * A `BooleanValidator` which validates a boolean in place.\n * Accepts `IJsonValidatorContext` but ignores it.\n * @public\n */\nexport const boolean: Validator<boolean, IJsonValidatorContext> =\n new Validation.Classes.BooleanValidator<IJsonValidatorContext>();\n\n/**\n * Helper to create a validator for a literal value.\n * Accepts `IJsonValidatorContext` but ignores it.\n * Mirrors the behavior of `@fgv/ts-utils`.\n * @public\n */\nexport function literal<T>(value: T): Validator<T, IJsonValidatorContext> {\n return new Validation.Base.GenericValidator<T, IJsonValidatorContext>({\n validator: (from: unknown): boolean | Failure<T> => {\n return from === value ? true : fail(`Expected literal ${String(value)}, found ${JSON.stringify(from)}`);\n }\n });\n}\n\n/**\n * Helper function to create a `Validator` which validates `unknown` to one of a set of\n * supplied enumerated values. Anything else fails.\n *\n * @remarks\n * This JSON variant accepts an `IJsonValidatorContext` OR\n * a `ReadonlyArray<T>` as its validation context. If the context is an array, it is used to override the\n * allowed values for that validation; otherwise, the original `values` supplied at creation time are used.\n *\n * @param values - Array of allowed values.\n * @param message - Optional custom failure message.\n * @returns A new `Validator` returning `<T>`.\n * @public\n */\nexport function enumeratedValue<T>(\n values: ReadonlyArray<T>,\n message?: string\n): Validator<T, IJsonValidatorContext | ReadonlyArray<T>> {\n return new Validation.Base.GenericValidator<T, IJsonValidatorContext | ReadonlyArray<T>>({\n validator: (from: unknown, context?: IJsonValidatorContext | ReadonlyArray<T>): boolean | Failure<T> => {\n const effectiveValues = Array.isArray(context) ? (context as ReadonlyArray<T>) : values;\n const index = effectiveValues.indexOf(from as T);\n if (index >= 0) {\n return true;\n }\n return fail(message ?? `Invalid enumerated value ${JSON.stringify(from)}`);\n }\n });\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AAEpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAoD;AAS3C,gCAAU;AARnB,yDAAyD;AACzD,6EAA+D;AAO1C,4BAAQ;AAN7B,2EAA6D;AAM9B,wCAAc;AAL7C,yDAAyD;AACzD,6EAA+D;AAIhB,4BAAQ;AAHvD,kEAAoD;AAGK,gCAAU;AADnE,kDAAgC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Converters from './packlets/converters';\n// eslint-disable-next-line @rushstack/packlets/mechanics\nimport * as FileTree from './packlets/file-tree/index.browser';\nimport * as JsonCompatible from './packlets/json-compatible';\n// eslint-disable-next-line @rushstack/packlets/mechanics\nimport * as JsonFile from './packlets/json-file/index.browser';\nimport * as Validators from './packlets/validators';\n\nexport * from './packlets/json';\nexport { Converters, FileTree, JsonCompatible, JsonFile, Validators };\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AAEpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAoD;AAO3C,gCAAU;AANnB,+DAAiD;AAM5B,4BAAQ;AAL7B,2EAA6D;AAK9B,wCAAc;AAJ7C,+DAAiD;AAIF,4BAAQ;AAHvD,kEAAoD;AAGK,gCAAU;AADnE,kDAAgC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Converters from './packlets/converters';\nimport * as FileTree from './packlets/file-tree';\nimport * as JsonCompatible from './packlets/json-compatible';\nimport * as JsonFile from './packlets/json-file';\nimport * as Validators from './packlets/validators';\n\nexport * from './packlets/json';\nexport { Converters, FileTree, JsonCompatible, JsonFile, Validators };\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/packlets/converters/converters.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,SAAS,EAGT,eAAe,EAIhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAA6B,MAAM,SAAS,CAAC;AAIrG;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,CAAC,aAAa,EAAE,qBAAqB,CAqBzE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,qBAAqB,CAgCnE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS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CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC;YAC5B,OAAO,IAAA,eAAI,EAAC,yBAAyB,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC;QACjC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAClD,OAAO,IAAA,eAAI,EAAC,sDAAsD,CAAC,CAAC;QACtE,CAAC;QAED,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n Conversion,\n Converter,\n Converters as BaseConverters,\n Result,\n StringConverter,\n captureResult,\n fail,\n succeed\n} from '@fgv/ts-utils';\nimport { JsonArray, JsonObject, JsonPrimitive, JsonValue, isJsonArray, isJsonObject } from '../json';\n\n/* eslint-disable @typescript-eslint/no-use-before-define */\n\n/**\n * Conversion context for JSON converters.\n * @public\n */\nexport interface IJsonConverterContext {\n ignoreUndefinedProperties?: boolean;\n}\n\n/**\n * An converter which converts a supplied `unknown` value to a valid {@link JsonPrimitive | JsonPrimitive}.\n * @public\n */\nexport const jsonPrimitive: Converter<JsonPrimitive, IJsonConverterContext> = new Conversion.BaseConverter(\n (\n from: unknown,\n __self: Converter<JsonPrimitive, IJsonConverterContext>,\n ctx?: IJsonConverterContext\n ): Result<JsonPrimitive> => {\n if (from === null) {\n return succeed(null);\n }\n switch (typeof from) {\n case 'boolean':\n case 'string':\n return succeed(from);\n case 'number':\n if (!Number.isNaN(from)) {\n return succeed(from);\n }\n break;\n }\n return fail(`\"${String(from)}\": invalid JSON primitive.`);\n }\n);\n\n/**\n * An copying converter which converts a supplied `unknown` value into\n * a valid {@link JsonObject | JsonObject}. Fails by default if any properties or array elements\n * are `undefined` - this default behavior can be overridden by supplying an appropriate\n * `IJsonConverterContext` at runtime.\n *\n * Guaranteed to return a new object.\n * @public\n */\nexport const jsonObject: Converter<JsonObject, IJsonConverterContext> = new Conversion.BaseConverter(\n (\n from: unknown,\n __self: Converter<JsonObject, IJsonConverterContext>,\n ctx?: IJsonConverterContext\n ): Result<JsonObject> => {\n if (!isJsonObject(from)) {\n return fail('invalid JSON object.');\n }\n const obj: JsonObject = {};\n const errors: string[] = [];\n for (const [name, value] of Object.entries(from)) {\n if (value === undefined && ctx?.ignoreUndefinedProperties === true) {\n // optionally ignore undefined values\n continue;\n }\n jsonValue\n .convert(value, ctx)\n .onSuccess((v: JsonValue) => {\n obj[name] = v;\n return succeed(v);\n })\n .onFailure((m) => {\n errors.push(`${name}: ${m}`);\n return fail(m);\n });\n }\n if (errors.length > 0) {\n return fail(`invalid JSON object:\\n${errors.join('\\n')}`);\n }\n return succeed(obj);\n }\n);\n\n/**\n * An copying converter which converts a supplied `unknown` value to\n * a valid {@link JsonArray | JsonArray}. Fails by default if any properties or array elements\n * are `undefined` - this default behavior can be overridden by supplying an appropriate\n * `IJsonConverterContext` at runtime.\n *\n * Guaranteed to return a new array.\n * @public\n */\nexport const jsonArray: Converter<JsonArray, IJsonConverterContext> = new Conversion.BaseConverter(\n (\n from: unknown,\n __self: Converter<JsonArray, IJsonConverterContext>,\n ctx?: IJsonConverterContext\n ): Result<JsonArray> => {\n if (!isJsonArray(from)) {\n return fail('not an array');\n }\n const arr: JsonValue[] = [];\n const errors: string[] = [];\n for (let i = 0; i < from.length; i++) {\n const value = from[i];\n if (value === undefined && ctx?.ignoreUndefinedProperties === true) {\n // convert undefined to 'null' for parity with JSON.stringify\n arr.push(null);\n continue;\n }\n jsonValue\n .convert(value, ctx)\n .onSuccess((v) => {\n arr.push(v);\n return succeed(v);\n })\n .onFailure((m) => {\n errors.push(`${i}: ${m}`);\n return fail(m);\n });\n }\n if (errors.length > 0) {\n return fail(`array contains non-json elements:\\n${errors.join('\\n')}`);\n }\n return succeed(arr);\n }\n);\n\n/**\n * An copying converter which converts a supplied `unknown` value to a\n * valid {@link JsonValue | JsonValue}. Fails by default if any properties or array elements\n * are `undefined` - this default behavior can be overridden by supplying an appropriate\n * `IJsonConverterContext` at runtime.\n * @public\n */\nexport const jsonValue: Converter<JsonValue, IJsonConverterContext> = new Conversion.BaseConverter<\n JsonValue,\n IJsonConverterContext\n>(\n (\n from: unknown,\n __self: Converter<JsonValue, IJsonConverterContext>,\n ctx?: IJsonConverterContext\n ): Result<JsonValue> => {\n if (isJsonArray(from)) {\n return jsonArray.convert(from, ctx);\n } else if (isJsonObject(from)) {\n return jsonObject.convert(from, ctx);\n }\n return jsonPrimitive.convert(from, ctx);\n }\n);\n\n/**\n * A `StringConverter` which converts `unknown` to a `string`.\n * Accepts `IJsonConverterContext` but ignores it.\n * @public\n */\nexport const string: StringConverter<string, IJsonConverterContext> = new StringConverter<\n string,\n IJsonConverterContext\n>();\n\n/**\n * A `Converter` which converts `unknown` to a `number`.\n * Accepts `IJsonConverterContext` but ignores it.\n * Mirrors the behavior of `@fgv/ts-utils`.\n * @public\n */\nexport const number: Converter<number, IJsonConverterContext> = new Conversion.BaseConverter<\n number,\n IJsonConverterContext\n>((from: unknown): Result<number> => BaseConverters.number.convert(from));\n\n/**\n * A `Converter` which converts `unknown` to a `boolean`.\n * Accepts `IJsonConverterContext` but ignores it.\n * Mirrors the behavior of `@fgv/ts-utils`.\n * @public\n */\nexport const boolean: Converter<boolean, IJsonConverterContext> = new Conversion.BaseConverter<\n boolean,\n IJsonConverterContext\n>((from: unknown): Result<boolean> => BaseConverters.boolean.convert(from));\n\n/**\n * Helper to create a converter for a literal value.\n * Accepts `IJsonConverterContext` but ignores it.\n * Mirrors the behavior of `@fgv/ts-utils`.\n * @public\n */\nexport function literal<T>(value: T): Converter<T, IJsonConverterContext> {\n return BaseConverters.literal<T, IJsonConverterContext>(value);\n}\n\n/**\n * Helper function to create a `Converter` which converts `unknown` to one of a set of\n * supplied enumerated values. Anything else fails.\n *\n * @remarks\n * This JSON variant accepts an `IJsonConverterContext` OR\n * a `ReadonlyArray<T>` as its conversion context. If the context is an array, it is used to override the\n * allowed values for that conversion; otherwise, the original `values` supplied at creation time are used.\n *\n * @param values - Array of allowed values.\n * @param message - Optional custom failure message.\n * @returns A new `Converter` returning `<T>`.\n * @public\n */\nexport function enumeratedValue<T>(\n values: ReadonlyArray<T>,\n message?: string\n): Converter<T, IJsonConverterContext | ReadonlyArray<T>> {\n return new Conversion.BaseConverter<T, IJsonConverterContext | ReadonlyArray<T>>(\n (\n from: unknown,\n __self: Converter<T, IJsonConverterContext | ReadonlyArray<T>>,\n context?: IJsonConverterContext | ReadonlyArray<T>\n ): Result<T> => {\n const effectiveValues = Array.isArray(context) ? (context as ReadonlyArray<T>) : values;\n const index = effectiveValues.indexOf(from as T);\n if (index >= 0) {\n return succeed(effectiveValues[index]);\n }\n return fail(message ?? `Invalid enumerated value ${JSON.stringify(from)}`);\n }\n );\n}\n\n/**\n * Creates a converter that parses JSON string content and then applies the supplied converter.\n * @param converter - Converter to apply to the parsed JSON\n * @returns Converter that parses JSON then validates\n * @public\n */\nexport function jsonConverter<T>(converter: Converter<T>): Converter<T> {\n return new Conversion.BaseConverter<T>((from: unknown): Result<T> => {\n if (typeof from !== 'string') {\n return fail('Input must be a string');\n }\n\n const parseResult = captureResult(() => JSON.parse(from));\n if (parseResult.isFailure()) {\n return fail(`Failed to parse JSON: ${parseResult.message}`);\n }\n\n const parsed = parseResult.value;\n if (typeof parsed !== 'object' || parsed === null) {\n return fail('Failed to parse JSON: JSON content must be an object');\n }\n\n return converter.convert(parsed);\n });\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/converters/index.ts"],"names":[],"mappings":"AAsBA,cAAc,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/converters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,+CAA6B","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './converters';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directoryItem.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryItem.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAgC,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,6BAA6B,EAC7B,wBAAwB,EAGzB,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,qBAAa,aAAa,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,CAAE,YAAW,6BAA6B,CAAC,GAAG,CAAC;IACnG;;OAEG;IACH,SAAgB,IAAI,EAAE,WAAW,CAAe;IAEhD;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAEjD;;;;;;OAMG;IACH,SAAS,aAAa,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,CAAC,GAAG,CAAC;IAKhE;;;;;;;OAOG;WACW,MAAM,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,EAC9C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAC3B,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAI7B;;OAEG;IACI,WAAW,IAAI,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAI9D;;OAEG;IACI,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG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AG,IAAI,CAAC,IAAI,CAAC;QACtB,mEAAmE;QACnE,IAAI,CAAC,IAAA,sCAAkB,EAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAA,eAAI,EAAC,GAAG,OAAO,0BAA0B,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE;YACrD,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;gBAC7B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBAC1B,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;oBAClD,6EAA6E;oBAC7E,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;wBACvB,OAAO,MAAM,CAAC;oBAChB,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;oBACzD,6EAA6E;oBAC7E,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;wBACvB,OAAO,MAAM,CAAC;oBAChB,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhKD,sCAgKC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport {\n FileTreeItem,\n IDeleteChildOptions,\n IFileTreeAccessors,\n IMutableFileTreeDirectoryItem,\n IMutableFileTreeFileItem,\n isMutableAccessors,\n isMutableFileItem\n} from './fileTreeAccessors';\n\n/**\n * Class representing a directory in a file tree.\n * @public\n */\nexport class DirectoryItem<TCT extends string = string> implements IMutableFileTreeDirectoryItem<TCT> {\n /**\n * {@inheritDoc FileTree.IFileTreeDirectoryItem.\"type\"}\n */\n public readonly type: 'directory' = 'directory';\n\n /**\n * {@inheritDoc FileTree.IFileTreeDirectoryItem.absolutePath}\n */\n public readonly absolutePath: string;\n\n /**\n * {@inheritDoc FileTree.IFileTreeDirectoryItem.name}\n */\n public get name(): string {\n return this._hal.getBaseName(this.absolutePath);\n }\n\n /**\n * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.\n * @public\n */\n protected readonly _hal: IFileTreeAccessors<TCT>;\n\n /**\n * Protected constructor for derived classes.\n * @param path - Relative path of the directory.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n * @public\n */\n protected constructor(path: string, hal: IFileTreeAccessors<TCT>) {\n this._hal = hal;\n this.absolutePath = hal.resolveAbsolutePath(path);\n }\n\n /**\n * Creates a new DirectoryItem instance.\n * @param path - Relative path of the directory.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n * @returns `Success` with the new {@link FileTree.DirectoryItem | DirectoryItem} instance if successful,\n * or `Failure` with an error message otherwise.\n */\n public static create<TCT extends string = string>(\n path: string,\n hal: IFileTreeAccessors<TCT>\n ): Result<DirectoryItem<TCT>> {\n return captureResult(() => new DirectoryItem<TCT>(path, hal));\n }\n\n /**\n * {@inheritDoc FileTree.IFileTreeDirectoryItem.getChildren}\n */\n public getChildren(): Result<ReadonlyArray<FileTreeItem<TCT>>> {\n return this._hal.getChildren(this.absolutePath);\n }\n\n /**\n * {@inheritDoc FileTree.IMutableFileTreeDirectoryItem.createChildFile}\n */\n public createChildFile(name: string, contents: string): Result<IMutableFileTreeFileItem<TCT>> {\n const hal = this._hal;\n if (!isMutableAccessors(hal)) {\n /* c8 ignore next 2 - defensive: all current accessor implementations support mutation interface */\n return fail(`${this.absolutePath}: mutation not supported`);\n }\n\n const filePath = hal.joinPaths(this.absolutePath, name);\n return hal.saveFileContents(filePath, contents).onSuccess(() =>\n hal.getItem(filePath).onSuccess((item) => {\n /* c8 ignore next 3 - defensive: verifies accessor returned correct item type after save */\n if (!isMutableFileItem(item)) {\n return fail(`${filePath}: expected mutable file but got ${item.type}`);\n }\n return succeed(item);\n })\n );\n }\n\n /**\n * {@inheritDoc FileTree.IMutableFileTreeDirectoryItem.createChildDirectory}\n */\n public createChildDirectory(name: string): Result<IMutableFileTreeDirectoryItem<TCT>> {\n const hal = this._hal;\n if (!isMutableAccessors(hal)) {\n /* c8 ignore next 2 - defensive: all current accessor implementations support mutation interface */\n return fail(`${this.absolutePath}: mutation not supported`);\n }\n\n const dirPath = hal.joinPaths(this.absolutePath, name);\n return hal.createDirectory(dirPath).onSuccess(() => DirectoryItem.create(dirPath, hal));\n }\n\n /**\n * {@inheritDoc FileTree.IMutableFileTreeDirectoryItem.deleteChild}\n */\n public deleteChild(name: string, options?: IDeleteChildOptions): Result<boolean> {\n const hal = this._hal;\n if (!isMutableAccessors(hal)) {\n /* c8 ignore next 2 - defensive: all current accessor implementations support mutation interface */\n return fail(`${this.absolutePath}: mutation not supported`);\n }\n\n const childPath = hal.joinPaths(this.absolutePath, name);\n return hal.getItem(childPath).onSuccess((item) => {\n if (item.type === 'file') {\n return hal.deleteFile(childPath);\n }\n // Directory child\n if (options?.recursive) {\n return this._deleteRecursive(childPath);\n }\n return hal.deleteDirectory(childPath);\n });\n }\n\n /**\n * {@inheritDoc FileTree.IMutableFileTreeDirectoryItem.delete}\n */\n public delete(): Result<boolean> {\n const hal = this._hal;\n if (!isMutableAccessors(hal)) {\n /* c8 ignore next 2 - defensive: all current accessor implementations support mutation interface */\n return fail(`${this.absolutePath}: mutation not supported`);\n }\n return hal.deleteDirectory(this.absolutePath);\n }\n\n /**\n * Recursively deletes all children of a directory and then the directory itself.\n * @param dirPath - The absolute path of the directory to delete.\n * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.\n * @internal\n */\n private _deleteRecursive(dirPath: string): Result<boolean> {\n const hal = this._hal;\n /* c8 ignore next 3 - defensive: caller already verified mutable */\n if (!isMutableAccessors(hal)) {\n return fail(`${dirPath}: mutation not supported`);\n }\n return hal.getChildren(dirPath).onSuccess((children) => {\n for (const child of children) {\n if (child.type === 'file') {\n const result = hal.deleteFile(child.absolutePath);\n /* c8 ignore next 3 - defensive: error propagation during recursive delete */\n if (result.isFailure()) {\n return result;\n }\n } else {\n const result = this._deleteRecursive(child.absolutePath);\n /* c8 ignore next 3 - defensive: error propagation during recursive delete */\n if (result.isFailure()) {\n return result;\n }\n }\n }\n return hal.deleteDirectory(dirPath);\n });\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileItem.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileItem.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,cAAc,EAAwB,MAAM,EAAoB,MAAM,eAAe,CAAC;AAC9G,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MA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,YAAY,0BAA0B,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,uBAAuB,CACnC,QAAgB,EAChB,QAAiB;QAEjB,OAAO,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,wBAAwB,CACpC,QAAgB,EAChB,QAAc;QAEd,OAAO,IAAA,kBAAO,EAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;CACF;AAjMD,4BAiMC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, DetailedResult, fail, failWithDetail, Result, succeed, Success } from '@fgv/ts-utils';\nimport { Converter, Validator } from '@fgv/ts-utils';\nimport { JsonValue } from '../json';\nimport {\n IFileTreeAccessors,\n IMutableFileTreeFileItem,\n isMutableAccessors,\n SaveDetail\n} from './fileTreeAccessors';\n\n/**\n * Class representing a file in a file tree.\n * @public\n */\nexport class FileItem<TCT extends string = string> implements IMutableFileTreeFileItem<TCT> {\n /**\n * {@inheritDoc FileTree.IFileTreeFileItem.\"type\"}\n */\n public readonly type: 'file' = 'file';\n\n /**\n * {@inheritDoc FileTree.IFileTreeFileItem.absolutePath}\n */\n public readonly absolutePath: string;\n\n /**\n * {@inheritDoc FileTree.IFileTreeFileItem.name}\n */\n public get name(): string {\n return this._hal.getBaseName(this.absolutePath);\n }\n\n /**\n * {@inheritDoc FileTree.IFileTreeFileItem.baseName}\n */\n public get baseName(): string {\n return this._hal.getBaseName(this.absolutePath, this.extension);\n }\n\n /**\n * {@inheritDoc FileTree.IFileTreeFileItem.extension}\n */\n public get extension(): string {\n return this._hal.getExtension(this.absolutePath);\n }\n\n /**\n * {@inheritDoc FileTree.IFileTreeFileItem.contentType}\n */\n public get contentType(): TCT | undefined {\n return this._contentType;\n }\n\n /**\n * Mutable content type of the file.\n * @public\n */\n private _contentType: TCT | undefined;\n\n /**\n * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.\n * @public\n */\n protected readonly _hal: IFileTreeAccessors<TCT>;\n\n /**\n * Protected constructor for derived classes.\n * @param path - Relative path of the file.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n * @public\n */\n protected constructor(path: string, hal: IFileTreeAccessors<TCT>) {\n this._hal = hal;\n this.absolutePath = hal.resolveAbsolutePath(path);\n this._contentType = hal.getFileContentType(this.absolutePath).orDefault();\n }\n\n /**\n * Creates a new {@link FileTree.FileItem} instance.\n * @param path - Relative path of the file.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n * @public\n */\n public static create<TCT extends string = string>(\n path: string,\n hal: IFileTreeAccessors<TCT>\n ): Result<FileItem<TCT>> {\n return captureResult(() => new FileItem(path, hal));\n }\n\n /**\n * Indicates whether this file can be saved.\n * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,\n * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.\n */\n public getIsMutable(): DetailedResult<boolean, SaveDetail> {\n if (isMutableAccessors(this._hal)) {\n return this._hal.fileIsMutable(this.absolutePath);\n }\n /* c8 ignore next 2 - defensive: all current accessor implementations support mutation interface */\n return failWithDetail(`${this.absolutePath}: mutation not supported`, 'not-supported');\n }\n\n /**\n * {@inheritDoc FileTree.IFileTreeFileItem.getContents}\n */\n public getContents(): Result<JsonValue>;\n /**\n * {@inheritDoc FileTree.IFileTreeFileItem.getContents}\n */\n public getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;\n public getContents<T>(converter?: Validator<T> | Converter<T>): Result<T | JsonValue> {\n return this._hal\n .getFileContents(this.absolutePath)\n .onSuccess((body) => captureResult(() => JSON.parse(body)).onFailure(() => succeed(body)))\n .onSuccess<T | JsonValue>((parsed) => {\n if (converter !== undefined) {\n return converter.convert(parsed);\n }\n return succeed(parsed as JsonValue);\n });\n }\n\n /**\n * {@inheritDoc FileTree.IFileTreeFileItem.getRawContents}\n */\n public getRawContents(): Result<string> {\n return this._hal.getFileContents(this.absolutePath);\n }\n\n /**\n * Sets the content type of the file.\n * @param contentType - The content type of the file.\n */\n public setContentType(contentType: TCT | undefined): void {\n this._contentType = contentType;\n }\n\n /**\n * Sets the contents of the file from a JSON value.\n * @param json - The JSON value to serialize and save.\n * @returns `Success` if the file was saved, or `Failure` with an error message.\n */\n public setContents(json: JsonValue): Result<JsonValue> {\n return captureResult(() => JSON.stringify(json, null, 2)).onSuccess((contents) =>\n this.setRawContents(contents).onSuccess(() => Success.with(json))\n );\n }\n\n /**\n * Sets the raw contents of the file.\n * @param contents - The string contents to save.\n * @returns `Success` if the file was saved, or `Failure` with an error message.\n */\n public setRawContents(contents: string): Result<string> {\n if (isMutableAccessors(this._hal)) {\n return this._hal.saveFileContents(this.absolutePath, contents);\n }\n /* c8 ignore next 2 - defensive: all current accessor implementations support mutation interface */\n return fail(`${this.absolutePath}: mutation not supported`);\n }\n\n /**\n * Deletes this file from its backing store.\n * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.\n */\n public delete(): Result<boolean> {\n if (!isMutableAccessors(this._hal)) {\n /* c8 ignore next 2 - defensive: all current accessor implementations support mutation interface */\n return fail(`${this.absolutePath}: mutation not supported`);\n }\n return this._hal.deleteFile(this.absolutePath);\n }\n\n /**\n * Default function to infer the content type of a file.\n * @param filePath - The path of the file.\n * @param provided - Optional supplied content type.\n * @returns `Success` with the content type of the file if successful, or\n * `Failure` with an error message otherwise.\n * @remarks This default implementation always returns `Success` with `undefined`.\n * @public\n */\n public static defaultInferContentType<TCT extends string = string>(\n filePath: string,\n provided?: string\n ): Result<TCT | undefined> {\n return succeed(undefined);\n }\n\n /**\n * Default function to accept the content type of a file.\n * @param filePath - The path of the file.\n * @param provided - Optional supplied content type.\n * @returns `Success` with the content type of the file if successful, or\n * `Failure` with an error message otherwise.\n * @remarks This default implementation always returns `Success` with `undefined`.\n * @public\n */\n public static defaultAcceptContentType<TCT extends string = string>(\n filePath: string,\n provided?: TCT\n ): Result<TCT | undefined> {\n return succeed(provided);\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileTree.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTree.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAiB,MAAM,eAAe,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,qBAAa,QAAQ,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM;IAC/C;;;OAGG;IACI,GAAG,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAEpC;;;;;OAKG;IACH,SAAS,aAAa,GAAG,EAAE,kBAAkB,CAAC,GAAG,CAAC;IAIlD;;;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AAE;YAC/C,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACzB,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,IAAA,eAAI,EAAC,GAAG,QAAQ,cAAc,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,aAAqB;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YACpD,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC9B,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,IAAA,eAAI,EAAC,GAAG,aAAa,mBAAmB,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnED,4BAmEC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Result, fail, succeed } from '@fgv/ts-utils';\nimport {\n FileTreeItem,\n IFileTreeAccessors,\n IFileTreeDirectoryItem,\n IFileTreeFileItem\n} from './fileTreeAccessors';\n\n/**\n * Represents a file tree.\n * @public\n */\nexport class FileTree<TCT extends string = string> {\n /**\n * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.\n * @public\n */\n public hal: IFileTreeAccessors<TCT>;\n\n /**\n * Protected constructor for derived classes.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n * @public\n */\n protected constructor(hal: IFileTreeAccessors<TCT>) {\n this.hal = hal;\n }\n\n /**\n * Creates a new {@link FileTree} instance with the supplied\n * accessors.\n * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for\n * file system operations.\n */\n public static create<TCT extends string = string>(hal: IFileTreeAccessors<TCT>): Result<FileTree<TCT>> {\n return captureResult(() => new FileTree(hal));\n }\n\n /**\n * Gets an item from the tree.\n * @param itemPath - The path to the item.\n * @returns `Success` with the item if successful,\n * or `Failure` with an error message otherwise.\n */\n public getItem(itemPath: string): Result<FileTreeItem<TCT>> {\n const absolutePath = this.hal.resolveAbsolutePath(itemPath);\n return this.hal.getItem(absolutePath);\n }\n\n /**\n * Gets a file item from the tree.\n * @param filePath - The path to the file.\n * @returns `Success` with the {@link FileTree.IFileTreeFileItem | file item}\n * if successful, or `Failure` with an error message otherwise.\n */\n public getFile(filePath: string): Result<IFileTreeFileItem<TCT>> {\n return this.getItem(filePath).onSuccess((item) => {\n if (item.type === 'file') {\n return succeed(item);\n }\n return fail(`${filePath}: not a file`);\n });\n }\n\n /**\n * Gets a directory item from the tree.\n * @param directoryPath - The path to the directory.\n * @returns `Success` with the {@link FileTree.IFileTreeDirectoryItem | directory item}\n * if successful, or `Failure` with an error message otherwise.\n */\n public getDirectory(directoryPath: string): Result<IFileTreeDirectoryItem<TCT>> {\n return this.getItem(directoryPath).onSuccess((item) => {\n if (item.type === 'directory') {\n return succeed(item);\n }\n return fail(`${directoryPath}: not a directory`);\n });\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileTreeAccessors.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTreeAccessors.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,WAAW,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GACzB,eAAe,GACf,WAAW,GACX,aAAa,GACb,eAAe,GACf,mBAAmB,CAAC;AAExB;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,iBAAiB,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAE9B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,MAAM,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,IAAI,CAC5D,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,KACd,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;AAE7B;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,kBAAkB,CAAC,GAA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,UAAU;QACxC,OAAO,UAAU,CAAC,aAAa,KAAK,UAAU,CAC/C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,IAAkD;IAElD,MAAM,OAAO,GAAG,IAAqC,CAAC;IACtD,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,MAAM;QACvB,OAAO,OAAO,CAAC,YAAY,KAAK,UAAU;QAC1C,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU;QACzC,OAAO,OAAO,CAAC,cAAc,KAAK,UAAU;QAC5C,OAAO,OAAO,CAAC,MAAM,KAAK,UAAU,CACrC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CACpC,IAAuD;IAEvD,MAAM,OAAO,GAAG,IAA0C,CAAC;IAC3D,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,WAAW;QAC5B,OAAO,OAAO,CAAC,eAAe,KAAK,UAAU;QAC7C,OAAO,OAAO,CAAC,oBAAoB,KAAK,UAAU;QAClD,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU;QACzC,OAAO,OAAO,CAAC,MAAM,KAAK,UAAU,CACrC,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { DetailedResult, Result } from '@fgv/ts-utils';\nimport { Converter, Validator } from '@fgv/ts-utils';\nimport { JsonValue } from '../json';\n\n/**\n * Indicates the persistence capability of a save operation.\n * - `persistent`: Changes are saved to durable storage (e.g., file system).\n * - `transient`: Changes are saved in memory only and will be lost on reload.\n * @public\n */\nexport type SaveCapability = 'persistent' | 'transient';\n\n/**\n * Indicates the reason a save operation cannot be performed.\n * - `not-supported`: The accessors do not support mutation.\n * - `read-only`: The file or file system is read-only.\n * - `not-mutable`: Mutability is disabled in configuration.\n * - `path-excluded`: The path is excluded by the mutability filter.\n * - `permission-denied`: Insufficient permissions to write.\n * @public\n */\nexport type SaveFailureReason =\n | 'not-supported'\n | 'read-only'\n | 'not-mutable'\n | 'path-excluded'\n | 'permission-denied';\n\n/**\n * Detail type for getIsMutable results.\n * @public\n */\nexport type SaveDetail = SaveCapability | SaveFailureReason;\n\n/**\n * Filter specification for controlling which paths are mutable.\n * @public\n */\nexport interface IFilterSpec {\n /**\n * Paths or patterns to include. If specified, only matching paths are mutable.\n */\n include?: (string | RegExp)[];\n\n /**\n * Paths or patterns to exclude. Matching paths are not mutable.\n */\n exclude?: (string | RegExp)[];\n}\n\n/**\n * Type of item in a file tree.\n * @public\n */\nexport type FileTreeItemType = 'directory' | 'file';\n\n/**\n * Type of function to infer the content type of a file.\n * @public\n */\nexport type ContentTypeFactory<TCT extends string = string> = (\n filePath: string,\n provided?: string\n) => Result<TCT | undefined>;\n\n/**\n * Initialization parameters for a file tree.\n * @public\n */\nexport interface IFileTreeInitParams<TCT extends string = string> {\n prefix?: string;\n inferContentType?: ContentTypeFactory<TCT>;\n\n /**\n * Controls mutability of the file tree.\n * - `undefined` or `false`: No files are mutable.\n * - `true`: All files are mutable.\n * - `IFilterSpec`: Only files matching the filter are mutable.\n */\n mutable?: boolean | IFilterSpec;\n}\n\n/**\n * Options for deleting a child item from a directory.\n * @public\n */\nexport interface IDeleteChildOptions {\n /**\n * If true, recursively delete directory children and their contents.\n * Default: false (fail if directory is non-empty).\n */\n recursive?: boolean;\n}\n\n// ============================================================================\n// File Item Interfaces\n// ============================================================================\n\n/**\n * Interface for a read-only file in a file tree.\n * @public\n */\nexport interface IFileTreeFileItem<TCT extends string = string> {\n /**\n * Indicates that this {@link FileTree.FileTreeItem | file tree item} is a file.\n */\n readonly type: 'file';\n\n /**\n * The absolute path of the file.\n */\n readonly absolutePath: string;\n\n /**\n * The name of the file\n */\n readonly name: string;\n\n /**\n * The base name of the file (without extension)\n */\n readonly baseName: string;\n\n /**\n * The extension of the file\n */\n readonly extension: string;\n\n /**\n * An optional content type (e.g. mime type) for the file.\n */\n readonly contentType: TCT | undefined;\n\n /**\n * Gets the contents of the file as parsed JSON.\n * @returns `Success` with the parsed JSON-compatible contents if successful, or\n * `Failure` with an error message otherwise.\n */\n getContents(): Result<JsonValue>;\n\n /**\n * Gets the contents of the file as parsed JSON, converted to a specific type.\n * @param converter - A `Validator` or `Converter`\n * to convert the parsed JSON contents to the desired type.\n * @returns `Success` with the converted contents if successful, or\n * `Failure` with an error message otherwise.\n */\n getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;\n\n /**\n * Gets the raw contents of the file as a string.\n * @returns `Success` with the raw contents if successful, or\n * `Failure` with an error message otherwise.\n */\n getRawContents(): Result<string>;\n}\n\n/**\n * Extended file item interface that supports mutation operations.\n * Use {@link FileTree.isMutableFileItem | isMutableFileItem} type guard to narrow.\n * @public\n */\nexport interface IMutableFileTreeFileItem<TCT extends string = string> extends IFileTreeFileItem<TCT> {\n /**\n * Indicates whether this file can be saved.\n * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,\n * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.\n */\n getIsMutable(): DetailedResult<boolean, SaveDetail>;\n\n /**\n * Sets the contents of the file from a JSON value.\n * @param json - The JSON value to serialize and save.\n * @returns `Success` if the file was saved, or `Failure` with an error message.\n */\n setContents(json: JsonValue): Result<JsonValue>;\n\n /**\n * Sets the raw contents of the file.\n * @param contents - The string contents to save.\n * @returns `Success` if the file was saved, or `Failure` with an error message.\n */\n setRawContents(contents: string): Result<string>;\n\n /**\n * Deletes this file from its backing store.\n * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.\n */\n delete(): Result<boolean>;\n}\n\n// ============================================================================\n// Directory Item Interfaces\n// ============================================================================\n\n/**\n * Interface for a read-only directory in a file tree.\n * @public\n */\nexport interface IFileTreeDirectoryItem<TCT extends string = string> {\n /**\n * Indicates that this {@link FileTree.FileTreeItem | file tree item} is a directory\n */\n readonly type: 'directory';\n\n /**\n * The absolute path of the directory.\n */\n readonly absolutePath: string;\n\n /**\n * The name of the directory\n */\n readonly name: string;\n\n /**\n * Gets the children of the directory.\n * @returns `Success` with the children of the directory if successful,\n * or `Failure` with an error message otherwise.\n */\n getChildren(): Result<ReadonlyArray<FileTreeItem<TCT>>>;\n}\n\n/**\n * Extended directory item interface that supports mutation operations.\n * Use {@link FileTree.isMutableDirectoryItem | isMutableDirectoryItem} type guard to narrow.\n * @public\n */\nexport interface IMutableFileTreeDirectoryItem<TCT extends string = string>\n extends IFileTreeDirectoryItem<TCT> {\n /**\n * Creates a new file as a child of this directory.\n * @param name - The file name to create.\n * @param contents - The string contents to write.\n * @returns `Success` with the new file item, or `Failure` with an error message.\n */\n createChildFile(name: string, contents: string): Result<IMutableFileTreeFileItem<TCT>>;\n\n /**\n * Creates a new subdirectory as a child of this directory.\n * @param name - The directory name to create.\n * @returns `Success` with the new directory item, or `Failure` with an error message.\n */\n createChildDirectory(name: string): Result<IMutableFileTreeDirectoryItem<TCT>>;\n\n /**\n * Deletes a child item from this directory.\n * @param name - The name of the child to delete.\n * @param options - Optional {@link FileTree.IDeleteChildOptions | options} controlling deletion behavior.\n * @returns `Success` with `true` if the child was deleted, or `Failure` with an error message.\n */\n deleteChild(name: string, options?: IDeleteChildOptions): Result<boolean>;\n\n /**\n * Deletes this directory from its backing store.\n * The directory must be empty or the operation will fail.\n * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.\n */\n delete(): Result<boolean>;\n}\n\n// ============================================================================\n// Union Types\n// ============================================================================\n\n/**\n * Type for an item in a file tree.\n * @public\n */\nexport type FileTreeItem<TCT extends string = string> = IFileTreeFileItem<TCT> | IFileTreeDirectoryItem<TCT>;\n\n/**\n * Type for a mutable item in a file tree.\n * @public\n */\nexport type MutableFileTreeItem<TCT extends string = string> =\n | IMutableFileTreeFileItem<TCT>\n | IMutableFileTreeDirectoryItem<TCT>;\n\n/**\n * A file item that may or may not be mutable at runtime.\n *\n * Use this type for parameters or fields where the code checks for mutability\n * and handles the read-only case gracefully. Use {@link FileTree.IMutableFileTreeFileItem}\n * when mutation is required.\n *\n * Narrow with {@link FileTree.isMutableFileItem} to access mutation methods.\n * @public\n */\nexport type AnyFileTreeFileItem<TCT extends string = string> =\n | IFileTreeFileItem<TCT>\n | IMutableFileTreeFileItem<TCT>;\n\n/**\n * A directory item that may or may not be mutable at runtime.\n *\n * Use this type for parameters or fields where the code checks for mutability\n * and handles the read-only case gracefully. Use {@link FileTree.IMutableFileTreeDirectoryItem}\n * when mutation is required.\n *\n * Narrow with {@link FileTree.isMutableDirectoryItem} to access mutation methods.\n * @public\n */\nexport type AnyFileTreeDirectoryItem<TCT extends string = string> =\n | IFileTreeDirectoryItem<TCT>\n | IMutableFileTreeDirectoryItem<TCT>;\n\n// ============================================================================\n// Accessor Interfaces\n// ============================================================================\n\n/**\n * Common abstraction layer interface for a tree of files\n * (e.g. a file system or a zip file).\n * @public\n */\nexport interface IFileTreeAccessors<TCT extends string = string> {\n /**\n * Resolves paths to an absolute path.\n * @param paths - Paths to resolve.\n * @returns The resolved absolute path.\n */\n resolveAbsolutePath(...paths: string[]): string;\n\n /**\n * Gets the extension of a path.\n * @param path - Path to get the extension of.\n * @returns The extension of the path.\n */\n getExtension(path: string): string;\n\n /**\n * Gets the base name of a path.\n * @param path - Path to get the base name of.\n * @param suffix - Optional suffix to remove from the base name.\n * @returns The base name of the path.\n */\n getBaseName(path: string, suffix?: string): string;\n\n /**\n * Joins paths together.\n * @param paths - Paths to join.\n * @returns The joined paths.\n */\n joinPaths(...paths: string[]): string;\n\n /**\n * Gets an item from the file tree.\n * @param path - Path of the item to get.\n * @returns The item if it exists.\n */\n getItem(path: string): Result<FileTreeItem<TCT>>;\n\n /**\n * Gets the contents of a file in the file tree.\n * @param path - Absolute path of the file.\n * @returns The contents of the file.\n */\n getFileContents(path: string): Result<string>;\n\n /**\n * Gets the content type of a file in the file tree.\n * @param path - Absolute path of the file.\n * @param provided - Optional supplied content type.\n * @returns The content type of the file.\n */\n getFileContentType(path: string, provided?: string): Result<TCT | undefined>;\n\n /**\n * Gets the children of a directory in the file tree.\n * @param path - Path of the directory.\n * @returns The children of the directory.\n */\n getChildren(path: string): Result<ReadonlyArray<FileTreeItem<TCT>>>;\n}\n\n/**\n * Extended accessors interface that supports mutation operations.\n * All mutation methods are required — use {@link FileTree.isMutableAccessors | isMutableAccessors}\n * type guard to check if an accessor supports mutation.\n * @public\n */\nexport interface IMutableFileTreeAccessors<TCT extends string = string> extends IFileTreeAccessors<TCT> {\n /**\n * Checks if a file at the given path can be saved.\n * @param path - The path to check.\n * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,\n * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.\n */\n fileIsMutable(path: string): DetailedResult<boolean, SaveDetail>;\n\n /**\n * Saves the contents to a file at the given path.\n * @param path - The path of the file to save.\n * @param contents - The string contents to save.\n * @returns `Success` if the file was saved, or `Failure` with an error message.\n */\n saveFileContents(path: string, contents: string): Result<string>;\n\n /**\n * Deletes a file at the given path.\n * @param path - The path of the file to delete.\n * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.\n */\n deleteFile(path: string): Result<boolean>;\n\n /**\n * Creates a directory at the given path, including any missing parent directories.\n * @param path - The path of the directory to create.\n * @returns `Success` with the absolute path if created, or `Failure` with an error message.\n */\n createDirectory(path: string): Result<string>;\n\n /**\n * Deletes a directory at the given path.\n * The directory must be empty or the operation will fail.\n * @param path - The path of the directory to delete.\n * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.\n */\n deleteDirectory(path: string): Result<boolean>;\n}\n\n/**\n * Extended accessors interface that supports persistence operations.\n * @public\n */\nexport interface IPersistentFileTreeAccessors<TCT extends string = string>\n extends IMutableFileTreeAccessors<TCT> {\n /**\n * Synchronize all dirty files to persistent storage.\n * @returns Promise resolving to success or failure\n */\n syncToDisk(): Promise<Result<void>>;\n\n /**\n * Check if there are unsaved changes.\n * @returns True if there are dirty files\n */\n isDirty(): boolean;\n\n /**\n * Get paths of all files with unsaved changes.\n * @returns Array of dirty file paths\n */\n getDirtyPaths(): string[];\n}\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Type guard to check if accessors support mutation.\n * @param accessors - The accessors to check.\n * @returns `true` if the accessors implement {@link FileTree.IMutableFileTreeAccessors}.\n * @public\n */\nexport function isMutableAccessors<TCT extends string = string>(\n accessors: IFileTreeAccessors<TCT>\n): accessors is IMutableFileTreeAccessors<TCT> {\n const mutable = accessors as IMutableFileTreeAccessors<TCT>;\n return (\n typeof mutable.fileIsMutable === 'function' &&\n typeof mutable.saveFileContents === 'function' &&\n typeof mutable.deleteFile === 'function' &&\n typeof mutable.createDirectory === 'function' &&\n typeof mutable.deleteDirectory === 'function'\n );\n}\n\n/**\n * Type guard to check if accessors support persistence.\n * @param accessors - The accessors to check.\n * @returns `true` if the accessors implement {@link FileTree.IPersistentFileTreeAccessors}.\n * @public\n */\nexport function isPersistentAccessors<TCT extends string = string>(\n accessors: IFileTreeAccessors<TCT>\n): accessors is IPersistentFileTreeAccessors<TCT> {\n const persistent = accessors as IPersistentFileTreeAccessors<TCT>;\n /* c8 ignore next 6 - no current accessor implements IPersistentFileTreeAccessors */\n return (\n isMutableAccessors(accessors) &&\n typeof persistent.syncToDisk === 'function' &&\n typeof persistent.isDirty === 'function' &&\n typeof persistent.getDirtyPaths === 'function'\n );\n}\n\n/**\n * Type guard to check if a file item supports mutation.\n * @param item - The file item to check.\n * @returns `true` if the item implements {@link FileTree.IMutableFileTreeFileItem}.\n * @public\n */\nexport function isMutableFileItem<TCT extends string = string>(\n item: AnyFileTreeFileItem<TCT> | FileTreeItem<TCT>\n): item is IMutableFileTreeFileItem<TCT> {\n const mutable = item as IMutableFileTreeFileItem<TCT>;\n return (\n mutable.type === 'file' &&\n typeof mutable.getIsMutable === 'function' &&\n typeof mutable.setContents === 'function' &&\n typeof mutable.setRawContents === 'function' &&\n typeof mutable.delete === 'function'\n );\n}\n\n/**\n * Type guard to check if a directory item supports mutation.\n * @param item - The directory item to check.\n * @returns `true` if the item implements {@link FileTree.IMutableFileTreeDirectoryItem}.\n * @public\n */\nexport function isMutableDirectoryItem<TCT extends string = string>(\n item: AnyFileTreeDirectoryItem<TCT> | FileTreeItem<TCT>\n): item is IMutableFileTreeDirectoryItem<TCT> {\n const mutable = item as IMutableFileTreeDirectoryItem<TCT>;\n return (\n mutable.type === 'directory' &&\n typeof mutable.createChildFile === 'function' &&\n typeof mutable.createChildDirectory === 'function' &&\n typeof mutable.deleteChild === 'function' &&\n typeof mutable.delete === 'function'\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileTreeHelpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTreeHelpers.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnG;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,EACvD,MAAM,CAAC,EAAE,mBAAmB,CAAC,GAAG,CAAC,GAChC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileTreeHelpers.inMemory.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTreeHelpers.inMemory.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAyB,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,EAClD,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,EAC3B,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAEzB;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,EAClD,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,EAC3B,MAAM,CAAC,EAAE,mBAAmB,CAAC,GAAG,CAAC,GAChC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileTreeHelpers.inMemory.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTreeHelpers.inMemory.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAmCH,4BAQC;AAxCD,yCAAsC;AACtC,2CAAmE;AA+BnE,SAAgB,QAAQ,CACtB,KAA2B,EAC3B,MAA0C;IAE1C,MAAM,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAClE,OAAO,iCAAqB,CAAC,MAAM,CAAM,KAAK,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAA+B,EAAE,EAAE,CACpG,mBAAQ,CAAC,MAAM,CAAM,GAAG,CAAC,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result } from '@fgv/ts-utils';\nimport { FileTree } from './fileTree';\nimport { IInMemoryFile, InMemoryTreeAccessors } from './in-memory';\nimport { IFileTreeInitParams } from './fileTreeAccessors';\n\n/**\n * Helper function to create a new {@link FileTree.FileTree | FileTree} instance\n * with accessors for an in-memory file tree.\n * @param files - An array of File |{@link FileTree.IInMemoryFile | in-memory files} to include in the tree.\n * @param prefix - An optional prefix to add to the paths of all files in the tree.\n * @returns `Success` with the new {@link FileTree.FileTree | FileTree} instance\n * if successful, or `Failure` with an error message otherwise.\n * @public\n */\nexport function inMemory<TCT extends string = string>(\n files: IInMemoryFile<TCT>[],\n prefix?: string\n): Result<FileTree<TCT>>;\n\n/**\n * Helper function to create a new {@link FileTree.FileTree | FileTree} instance\n * with accessors for an in-memory file tree.\n * @param files - An array of File |{@link FileTree.IInMemoryFile | in-memory files} to include in the tree.\n * @param params - Optional {@link FileTree.IFileTreeInitParams | initialization parameters} for the file tree.\n * @returns `Success` with the new {@link FileTree.FileTree | FileTree} instance\n * if successful, or `Failure` with an error message otherwise.\n * @public\n */\nexport function inMemory<TCT extends string = string>(\n files: IInMemoryFile<TCT>[],\n params?: IFileTreeInitParams<TCT>\n): Result<FileTree<TCT>>;\n\nexport function inMemory<TCT extends string = string>(\n files: IInMemoryFile<TCT>[],\n params?: IFileTreeInitParams<TCT> | string\n): Result<FileTree<TCT>> {\n params = typeof params === 'string' ? { prefix: params } : params;\n return InMemoryTreeAccessors.create<TCT>(files, params).onSuccess((hal: InMemoryTreeAccessors<TCT>) =>\n FileTree.create<TCT>(hal)\n );\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileTreeHelpers.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTreeHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AA4BH,sCAKC;AA/BD,4CAAsD;AACtD,yCAAsC;AACtC,qCAA+C;AAwB/C,SAAgB,aAAa,CAC3B,MAA0C;IAE1C,MAAM,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAClE,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,4BAAmB,CAAM,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5G,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Result } from '@fgv/ts-utils';\nimport { FileTree } from './fileTree';\nimport { FsFileTreeAccessors } from './fsTree';\nimport { IFileTreeInitParams } from './fileTreeAccessors';\n\n/**\n * Helper function to create a new {@link FileTree.FileTree | FileTree} instance\n * with accessors for the filesystem.\n * @param prefix - An optional prefix to prepended to supplied relative paths.\n * @returns `Success` with the new {@link FileTree.FileTree | FileTree} instance\n * if successful, or `Failure` with an error message otherwise.\n * @public\n */\nexport function forFilesystem<TCT extends string = string>(prefix?: string): Result<FileTree<TCT>>;\n\n/**\n * Helper function to create a new {@link FileTree.FileTree | FileTree} instance\n * with accessors for the filesystem.\n * @param params - Optional {@link FileTree.IFileTreeInitParams | initialization parameters} for the file tree.\n * @returns `Success` with the new {@link FileTree.FileTree | FileTree} instance\n * if successful, or `Failure` with an error message otherwise.\n * @public\n */\nexport function forFilesystem<TCT extends string = string>(\n params?: IFileTreeInitParams<TCT>\n): Result<FileTree<TCT>>;\nexport function forFilesystem<TCT extends string = string>(\n params?: IFileTreeInitParams<TCT> | string\n): Result<FileTree<TCT>> {\n params = typeof params === 'string' ? { prefix: params } : params;\n return captureResult(() => new FsFileTreeAccessors<TCT>(params)).onSuccess((hal) => FileTree.create(hal));\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterSpec.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/filterSpec.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AA8BlD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAuB/F"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterSpec.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/filterSpec.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAuCH,sCAuBC;AA1DD;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,IAAY,EAAE,OAAwB;IAC5D,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,IAAY,EAAE,QAAyC;IACzE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,IAAY,EAAE,OAA0C;IACpF,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAErC,uEAAuE;IACvE,IAAI,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,kEAAkE;IAClE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,OAAO,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,iEAAiE;IACjE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { IFilterSpec } from './fileTreeAccessors';\n\n/**\n * Checks if a path matches a single pattern (string or RegExp).\n * @param path - The path to check.\n * @param pattern - The pattern to match against.\n * @returns `true` if the path matches the pattern.\n * @internal\n */\nfunction matchesPattern(path: string, pattern: string | RegExp): boolean {\n if (typeof pattern === 'string') {\n return path === pattern || path.startsWith(pattern + '/') || path.includes(pattern);\n }\n return pattern.test(path);\n}\n\n/**\n * Checks if a path matches any pattern in an array.\n * @param path - The path to check.\n * @param patterns - The patterns to match against.\n * @returns `true` if the path matches any pattern.\n * @internal\n */\nfunction matchesAny(path: string, patterns: (string | RegExp)[] | undefined): boolean {\n if (!patterns || patterns.length === 0) {\n return false;\n }\n return patterns.some((pattern) => matchesPattern(path, pattern));\n}\n\n/**\n * Checks if a path is allowed by a mutability configuration.\n * @param path - The path to check.\n * @param mutable - The mutability configuration.\n * @returns `true` if the path is mutable according to the configuration.\n * @public\n */\nexport function isPathMutable(path: string, mutable: boolean | IFilterSpec | undefined): boolean {\n if (mutable === undefined || mutable === false) {\n return false;\n }\n\n if (mutable === true) {\n return true;\n }\n\n const { include, exclude } = mutable;\n\n // If exclude patterns are specified and path matches, it's not mutable\n if (matchesAny(path, exclude)) {\n return false;\n }\n\n // If include patterns are specified, path must match at least one\n if (include && include.length > 0) {\n return matchesAny(path, include);\n }\n\n // No include patterns means all paths (not excluded) are mutable\n return true;\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fsTree.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/fsTree.ts"],"names":[],"mapp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,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;YACxB,YAAE,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAChD,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,eAAe,CAAC,OAAe;QACpC,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE;YACzD,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;YACvD,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;gBACxB,MAAM,IAAI,GAAG,YAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;gBACvC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;oBACxB,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,mBAAmB,CAAC,CAAC;gBACtD,CAAC;gBACD,kEAAkE;gBAClE,YAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBAC3B,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnPD,kDAmPC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n FileTreeItem,\n IFileTreeInitParams,\n IFilterSpec,\n IMutableFileTreeAccessors,\n SaveDetail\n} from './fileTreeAccessors';\nimport path from 'path';\nimport fs from 'fs';\nimport {\n captureResult,\n DetailedResult,\n fail,\n failWithDetail,\n Result,\n succeed,\n succeedWithDetail\n} from '@fgv/ts-utils';\nimport { DirectoryItem } from './directoryItem';\nimport { FileItem } from './fileItem';\nimport { isPathMutable } from './filterSpec';\n\n/**\n * Implementation of {@link FileTree.IMutableFileTreeAccessors} that uses the\n * file system to access and modify files and directories.\n * @public\n */\nexport class FsFileTreeAccessors<TCT extends string = string> implements IMutableFileTreeAccessors<TCT> {\n /**\n * Optional path prefix to prepend to all paths.\n */\n public readonly prefix: string | undefined;\n\n /**\n * Function to infer the content type of a file.\n * @public\n */\n protected readonly _inferContentType: (filePath: string) => Result<TCT | undefined>;\n\n /**\n * The mutability configuration.\n */\n private readonly _mutable: boolean | IFilterSpec;\n\n /**\n * Construct a new instance of the {@link FileTree.FsFileTreeAccessors | FsFileTreeAccessors} class.\n * @param params - Optional {@link FileTree.IFileTreeInitParams | initialization parameters}.\n * @public\n */\n public constructor(params?: IFileTreeInitParams<TCT>) {\n this.prefix = params?.prefix;\n this._inferContentType = params?.inferContentType ?? FileItem.defaultInferContentType;\n /* c8 ignore next 1 - defensive default when params is undefined */\n this._mutable = params?.mutable ?? false;\n }\n\n /**\n * Resolves paths to an absolute path.\n * @param paths - Paths to resolve.\n * @returns The resolved absolute path.\n */\n public resolveAbsolutePath(...paths: string[]): string {\n if (this.prefix && !path.isAbsolute(paths[0])) {\n return path.resolve(this.prefix, ...paths);\n }\n return path.resolve(...paths);\n }\n\n /**\n * Gets the extension of a path.\n * @param itemPath - Path to get the extension of.\n * @returns The extension of the path.\n */\n public getExtension(itemPath: string): string {\n return path.extname(itemPath);\n }\n\n /**\n * Gets the base name of a path.\n * @param itemPath - Path to get the base name of.\n * @param suffix - Optional suffix to remove from the base name.\n * @returns The base name of the path.\n */\n public getBaseName(itemPath: string, suffix?: string): string {\n return path.basename(itemPath, suffix);\n }\n\n /**\n * Joins paths together.\n * @param paths - Paths to join.\n * @returns The joined paths.\n */\n public joinPaths(...paths: string[]): string {\n return path.join(...paths);\n }\n\n /**\n * Gets an item from the file tree.\n * @param itemPath - Path of the item to get.\n * @returns The item if it exists.\n */\n public getItem(itemPath: string): Result<FileTreeItem<TCT>> {\n return captureResult(() => {\n const stat = fs.statSync(this.resolveAbsolutePath(itemPath));\n if (stat.isDirectory()) {\n return DirectoryItem.create<TCT>(itemPath, this).orThrow();\n } else if (stat.isFile()) {\n return FileItem.create(itemPath, this).orThrow();\n }\n /* c8 ignore next 1 - defensive coding: filesystem items should be file or directory */\n throw new Error(`${itemPath}: not a file or directory`);\n });\n }\n\n /**\n * Gets the contents of a file in the file tree.\n * @param filePath - Absolute path of the file.\n * @returns The contents of the file.\n */\n public getFileContents(filePath: string): Result<string> {\n return captureResult(() => fs.readFileSync(this.resolveAbsolutePath(filePath), 'utf8'));\n }\n\n /**\n * Gets the content type of a file in the file tree.\n * @param filePath - Absolute path of the file.\n * @param provided - Optional supplied content type.\n * @returns The content type of the file.\n */\n public getFileContentType(filePath: string, provided?: string): Result<TCT | undefined> {\n if (provided !== undefined) {\n return succeed(provided as TCT);\n }\n /* c8 ignore next 2 - coverage has intermittent issues in the build - local tests show coverage of this line */\n return this._inferContentType(filePath);\n }\n\n /**\n * Gets the children of a directory in the file tree.\n * @param dirPath - Path of the directory.\n * @returns The children of the directory.\n */\n public getChildren(dirPath: string): Result<ReadonlyArray<FileTreeItem<TCT>>> {\n return captureResult(() => {\n const children: FileTreeItem<TCT>[] = [];\n const files = fs.readdirSync(this.resolveAbsolutePath(dirPath), { withFileTypes: true });\n files.forEach((file) => {\n const fullPath = this.resolveAbsolutePath(dirPath, file.name);\n if (file.isDirectory()) {\n children.push(DirectoryItem.create<TCT>(fullPath, this).orThrow());\n } else if (file.isFile()) {\n children.push(FileItem.create<TCT>(fullPath, this).orThrow());\n }\n });\n return children;\n });\n }\n\n /**\n * Checks if a file at the given path can be saved.\n * @param path - The path to check.\n * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,\n * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.\n */\n public fileIsMutable(path: string): DetailedResult<boolean, SaveDetail> {\n const absolutePath = this.resolveAbsolutePath(path);\n\n // Check if mutability is disabled\n if (this._mutable === false) {\n return failWithDetail(`${absolutePath}: mutability is disabled`, 'not-mutable');\n }\n\n // Check if path is excluded by filter\n if (!isPathMutable(absolutePath, this._mutable)) {\n return failWithDetail(`${absolutePath}: path is excluded by filter`, 'path-excluded');\n }\n\n // Check file system permissions\n try {\n // Check if file exists\n if (fs.existsSync(absolutePath)) {\n fs.accessSync(absolutePath, fs.constants.W_OK);\n } else {\n // Check if parent directory is writable\n const parentDir = absolutePath.substring(0, absolutePath.lastIndexOf('/'));\n if (parentDir && fs.existsSync(parentDir)) {\n fs.accessSync(parentDir, fs.constants.W_OK);\n }\n }\n return succeedWithDetail(true, 'persistent');\n /* c8 ignore next 3 - unreachable when running as root (CI), tested in mutableFsTree.test.ts */\n } catch {\n return failWithDetail(`${absolutePath}: permission denied`, 'permission-denied');\n }\n }\n\n /**\n * Saves the contents to a file at the given path.\n * @param path - The path of the file to save.\n * @param contents - The string contents to save.\n * @returns `Success` if the file was saved, or `Failure` with an error message.\n */\n public saveFileContents(path: string, contents: string): Result<string> {\n return this.fileIsMutable(path).asResult.onSuccess(() => {\n const absolutePath = this.resolveAbsolutePath(path);\n return captureResult(() => {\n fs.writeFileSync(absolutePath, contents, 'utf8');\n return contents;\n });\n });\n }\n\n /**\n * Deletes a file at the given path.\n * @param path - The path of the file to delete.\n * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.\n */\n public deleteFile(path: string): Result<boolean> {\n return this.fileIsMutable(path).asResult.onSuccess(() => {\n const absolutePath = this.resolveAbsolutePath(path);\n return captureResult(() => {\n const stat = fs.statSync(absolutePath);\n if (!stat.isFile()) {\n throw new Error(`${absolutePath}: not a file`);\n }\n fs.unlinkSync(absolutePath);\n return true;\n });\n });\n }\n\n /**\n * Creates a directory at the given path, including any missing parent directories.\n * @param dirPath - The path of the directory to create.\n * @returns `Success` with the absolute path if created, or `Failure` with an error message.\n */\n public createDirectory(dirPath: string): Result<string> {\n const absolutePath = this.resolveAbsolutePath(dirPath);\n\n // Check if mutability is disabled\n if (this._mutable === false) {\n return fail(`${absolutePath}: mutability is disabled`);\n }\n\n return captureResult(() => {\n fs.mkdirSync(absolutePath, { recursive: true });\n return absolutePath;\n });\n }\n\n /**\n * Deletes a directory at the given path.\n * The directory must be empty or the operation will fail.\n * @param dirPath - The path of the directory to delete.\n * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.\n */\n public deleteDirectory(dirPath: string): Result<boolean> {\n return this.fileIsMutable(dirPath).asResult.onSuccess(() => {\n const absolutePath = this.resolveAbsolutePath(dirPath);\n return captureResult(() => {\n const stat = fs.statSync(absolutePath);\n if (!stat.isDirectory()) {\n throw new Error(`${absolutePath}: not a directory`);\n }\n // fs.rmdirSync fails if directory is non-empty (desired behavior)\n fs.rmdirSync(absolutePath);\n return true;\n });\n });\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inMemoryTree.d.ts","sourceRoot":"","sources":["../../../../src/packlets/file-tree/in-memory/inMemoryTree.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,cAAc,EAGd,MAAM,EAGP,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,YAAY,EACZ,mBAAmB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C,IAAI,CAAC,YAAY,CAAC;QAC3D,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAG,CAAC;YAC5B,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;gBACvB,OAAO,IAAA,eAAI,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC9B,CAAC;YACD,GAAG,GAAG,MAAM,CAAC,KAAsC,CAAC;YACpD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC/C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QAED,8CAA8C;QAC9C,OAAO,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YAChE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,IAAgC,CAAC,CAAC;YAE7E,qEAAqE;YACrE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;gBACtD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YAClD,CAAC;YAED,OAAO,IAAA,kBAAO,EAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AApbD,sDAobC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n captureResult,\n DetailedResult,\n fail,\n failWithDetail,\n Result,\n succeed,\n succeedWithDetail\n} from '@fgv/ts-utils';\nimport { DirectoryItem } from '../directoryItem';\nimport { FileItem } from '../fileItem';\nimport {\n FileTreeItem,\n IFileTreeInitParams,\n IFilterSpec,\n IMutableFileTreeAccessors,\n SaveDetail\n} from '../fileTreeAccessors';\nimport { InMemoryDirectory, InMemoryFile, TreeBuilder } from './treeBuilder';\nimport { isPathMutable } from '../filterSpec';\n\n/**\n * Represents a single file in an in-memory {@link FileTree | file tree}.\n * @public\n */\nexport interface IInMemoryFile<TCT extends string = string> {\n /**\n * The absolute path of the file in the tree.\n */\n readonly path: string;\n\n /**\n * The contents of the file\n */\n readonly contents: unknown;\n\n /**\n * The content type of the file.\n */\n readonly contentType?: TCT;\n}\n\n/**\n * A mutable in-memory file that allows updating contents.\n * @internal\n */\nclass MutableInMemoryFile<TCT extends string = string> {\n public readonly absolutePath: string;\n public readonly contentType?: TCT;\n private _contents: unknown;\n\n public constructor(absolutePath: string, contents: unknown, contentType?: TCT) {\n this.absolutePath = absolutePath;\n this._contents = contents;\n this.contentType = contentType;\n }\n\n public get contents(): unknown {\n return this._contents;\n }\n\n public setContents(contents: unknown): void {\n this._contents = contents;\n }\n}\n\n/**\n * A mutable in-memory directory that creates mutable files.\n * @internal\n */\nclass MutableInMemoryDirectory<TCT extends string = string> {\n public readonly absolutePath: string;\n protected _children: Map<string, MutableInMemoryDirectory<TCT> | MutableInMemoryFile<TCT>>;\n\n /* c8 ignore next 3 - internal getter used by tree traversal */\n public get children(): ReadonlyMap<string, MutableInMemoryDirectory<TCT> | MutableInMemoryFile<TCT>> {\n return this._children;\n }\n\n public constructor(absolutePath: string) {\n this.absolutePath = absolutePath;\n this._children = new Map();\n }\n\n public getChildPath(name: string): string {\n if (this.absolutePath === '/') {\n return `/${name}`;\n }\n return [this.absolutePath, name].join('/');\n }\n\n public addFile(name: string, contents: unknown, contentType?: TCT): Result<MutableInMemoryFile<TCT>> {\n /* c8 ignore next 3 - defensive: duplicate detection during construction */\n if (this._children.has(name)) {\n return fail(`${name}: already exists`);\n }\n const child = new MutableInMemoryFile<TCT>(this.getChildPath(name), contents, contentType);\n this._children.set(name, child);\n return succeed(child);\n }\n\n public getOrAddDirectory(name: string): Result<MutableInMemoryDirectory<TCT>> {\n const existing = this._children.get(name);\n if (existing) {\n if (existing instanceof MutableInMemoryDirectory) {\n return succeed(existing);\n }\n return fail(`${name}: not a directory`);\n }\n const child = new MutableInMemoryDirectory<TCT>(this.getChildPath(name));\n this._children.set(name, child);\n return succeed(child);\n }\n\n public updateOrAddFile(\n name: string,\n contents: unknown,\n contentType?: TCT\n ): Result<MutableInMemoryFile<TCT>> {\n const existing = this._children.get(name);\n if (existing) {\n if (existing instanceof MutableInMemoryFile) {\n existing.setContents(contents);\n return succeed(existing);\n }\n return fail(`${name}: not a file`);\n }\n return this.addFile(name, contents, contentType);\n }\n\n public removeChild(name: string): boolean {\n return this._children.delete(name);\n }\n}\n\n/**\n * Implementation of {@link FileTree.IMutableFileTreeAccessors} that uses an in-memory\n * tree to access and modify files and directories.\n * @public\n */\nexport class InMemoryTreeAccessors<TCT extends string = string> implements IMutableFileTreeAccessors<TCT> {\n private readonly _tree: TreeBuilder<TCT>;\n private readonly _inferContentType: (filePath: string) => Result<TCT | undefined>;\n private readonly _mutable: boolean | IFilterSpec;\n private readonly _mutableByPath: Map<string, MutableInMemoryDirectory<TCT> | MutableInMemoryFile<TCT>>;\n private readonly _mutableRoot: MutableInMemoryDirectory<TCT>;\n\n /**\n * Protected constructor for derived classes.\n * @param files - An array of {@link FileTree.IInMemoryFile | in-memory files} to include in the tree.\n * @param params - Optional params for the tree.\n * @public\n */\n protected constructor(files: IInMemoryFile<TCT>[], params?: IFileTreeInitParams<TCT>) {\n this._tree = TreeBuilder.create<TCT>(params?.prefix).orThrow();\n this._inferContentType = params?.inferContentType ?? FileItem.defaultInferContentType;\n this._mutable = params?.mutable ?? false;\n this._mutableByPath = new Map();\n const prefix = params?.prefix ?? '/';\n this._mutableRoot = new MutableInMemoryDirectory<TCT>(\n prefix.endsWith('/') ? prefix.slice(0, -1) || '/' : prefix\n );\n this._mutableByPath.set(this._mutableRoot.absolutePath, this._mutableRoot);\n\n for (const file of files) {\n const contentType = file.contentType ?? this._inferContentType(file.path).orDefault();\n this._tree.addFile(file.path, file.contents, contentType).orThrow();\n this._addMutableFile(file.path, file.contents, contentType);\n }\n }\n\n /**\n * Creates a new {@link FileTree.InMemoryTreeAccessors | InMemoryTreeAccessors} instance with the supplied\n * in-memory files.\n * @param files - An array of {@link FileTree.IInMemoryFile | in-memory files} to include in the tree.\n * @param prefix - Optional prefix for the tree.\n */\n public static create<TCT extends string = string>(\n files: IInMemoryFile<TCT>[],\n prefix?: string\n ): Result<InMemoryTreeAccessors<TCT>>;\n\n /**\n * Creates a new {@link FileTree.InMemoryTreeAccessors | InMemoryTreeAccessors} instance with the supplied\n * in-memory files.\n * @param files - An array of {@link FileTree.IInMemoryFile | in-memory files} to include in the tree.\n * @param params - Optional params for the tree.\n */\n public static create<TCT extends string = string>(\n files: IInMemoryFile<TCT>[],\n params?: IFileTreeInitParams<TCT>\n ): Result<InMemoryTreeAccessors<TCT>>;\n\n /**\n * Creates a new {@link FileTree.InMemoryTreeAccessors | InMemoryTreeAccessors} instance with the supplied\n * in-memory files.\n * @param files - An array of {@link FileTree.IInMemoryFile | in-memory files} to include in the tree.\n * @param params - Optional params for the tree.\n */\n public static create<TCT extends string = string>(\n files: IInMemoryFile<TCT>[],\n params?: IFileTreeInitParams<TCT> | string\n ): Result<InMemoryTreeAccessors<TCT>> {\n /* c8 ignore next 2 - tested but code coverage has intermittent issues */\n params = typeof params === 'string' ? { prefix: params } : params;\n return captureResult(() => new InMemoryTreeAccessors(files, params));\n }\n\n /**\n * Resolves paths to an absolute path.\n * @param paths - Paths to resolve.\n * @returns The resolved absolute path.\n */\n public resolveAbsolutePath(...paths: string[]): string {\n const parts = paths[0].startsWith('/') ? paths : [this._tree.prefix, ...paths];\n const joined = parts.flatMap((p) => p.split('/').filter((s) => s.length > 0)).join('/');\n return `/${joined}`;\n }\n\n /**\n * Gets the extension of a path.\n * @param path - Path to get the extension of.\n * @returns The extension of the path.\n */\n public getExtension(path: string): string {\n const parts = path.split('.');\n if (parts.length === 1) {\n return '';\n }\n return `.${parts.pop()}`;\n }\n\n /**\n * Gets the base name of a path.\n * @param path - Path to get the base name of.\n * @param suffix - Optional suffix to remove from the base name.\n * @returns The base name of the path.\n */\n public getBaseName(path: string, suffix?: string): string {\n /* c8 ignore next 1 - ?? is defense in depth should never happen */\n const base = path.split('/').pop() ?? '';\n if (suffix && base.endsWith(suffix)) {\n return base.slice(0, base.length - suffix.length);\n }\n return base;\n }\n\n /**\n * Joins paths together.\n * @param paths - Paths to join.\n * @returns The joined paths.\n */\n public joinPaths(...paths: string[]): string {\n const joined = paths.flatMap((p) => p.split('/').filter((s) => s.length > 0)).join('/');\n return paths[0]?.startsWith('/') ? `/${joined}` : joined;\n }\n\n /**\n * Gets an item from the file tree.\n * @param itemPath - Path of the item to get.\n * @returns The item if it exists.\n */\n public getItem(itemPath: string): Result<FileTreeItem<TCT>> {\n const existing = this._tree.byAbsolutePath.get(itemPath);\n if (existing) {\n if (existing instanceof InMemoryFile) {\n return FileItem.create<TCT>(existing.absolutePath, this);\n } else if (existing instanceof InMemoryDirectory) {\n return DirectoryItem.create<TCT>(existing.absolutePath, this);\n }\n }\n return fail(`${itemPath}: not found`);\n }\n\n /**\n * Gets the contents of a file in the file tree.\n * @param path - Absolute path of the file.\n * @returns The contents of the file.\n */\n public getFileContents(path: string): Result<string> {\n const absolutePath = this.resolveAbsolutePath(path);\n const item = this._mutableByPath.get(absolutePath);\n if (item === undefined) {\n return fail(`${absolutePath}: not found`);\n }\n if (!(item instanceof MutableInMemoryFile)) {\n return fail(`${absolutePath}: not a file`);\n }\n if (typeof item.contents === 'string') {\n return succeed(item.contents);\n }\n return captureResult(() => JSON.stringify(item.contents));\n }\n\n /**\n * Gets the content type of a file in the file tree.\n * @param path - Absolute path of the file.\n * @param provided - Optional supplied content type.\n * @returns The content type of the file.\n */\n public getFileContentType(path: string, provided?: string): Result<TCT | undefined> {\n // If provided contentType is given, use it directly (highest priority)\n if (provided !== undefined) {\n return succeed(provided as TCT);\n }\n\n const item = this._tree.byAbsolutePath.get(path);\n if (item === undefined) {\n // If file doesn't exist, still try to infer content type from path\n return this._inferContentType(path);\n }\n if (!(item instanceof InMemoryFile)) {\n // For directories, return undefined\n return succeed(undefined);\n }\n // Return stored contentType if it exists, otherwise infer\n if (item.contentType !== undefined) {\n return succeed(item.contentType);\n }\n return this._inferContentType(path);\n }\n\n /**\n * Gets the children of a directory in the file tree.\n * @param path - Path of the directory.\n * @returns The children of the directory.\n */\n public getChildren(path: string): Result<ReadonlyArray<FileTreeItem<TCT>>> {\n const item = this._tree.byAbsolutePath.get(path);\n if (item === undefined) {\n return fail(`${path}: not found`);\n }\n /* c8 ignore next 3 - local coverage is 100% but build coverage has intermittent issues */\n if (!(item instanceof InMemoryDirectory)) {\n return fail(`${path}: not a directory`);\n }\n return captureResult(() => {\n const children: FileTreeItem<TCT>[] = [];\n for (const child of item.children.values()) {\n if (child instanceof InMemoryFile) {\n children.push(FileItem.create<TCT>(child.absolutePath, this).orThrow());\n } else if (child instanceof InMemoryDirectory) {\n children.push(DirectoryItem.create<TCT>(child.absolutePath, this).orThrow());\n }\n }\n return children;\n });\n }\n\n private _addMutableFile(\n path: string,\n contents: unknown,\n contentType?: TCT\n ): Result<MutableInMemoryFile<TCT>> {\n const absolutePath = this.resolveAbsolutePath(path);\n const parts = absolutePath.split('/').filter((p) => p.length > 0);\n /* c8 ignore next 3 - defensive: invalid path detection */\n if (parts.length === 0) {\n return fail(`${absolutePath}: invalid file path`);\n }\n\n let dir: MutableInMemoryDirectory<TCT> = this._mutableRoot;\n while (parts.length > 1) {\n const part = parts.shift()!;\n const result = dir.getOrAddDirectory(part);\n /* c8 ignore next 3 - defensive: directory conflict during construction */\n if (result.isFailure()) {\n return fail(result.message);\n }\n dir = result.value as MutableInMemoryDirectory<TCT>;\n if (!this._mutableByPath.has(dir.absolutePath)) {\n this._mutableByPath.set(dir.absolutePath, dir);\n }\n }\n\n return dir.addFile(parts[0], contents, contentType).onSuccess((file) => {\n this._mutableByPath.set(file.absolutePath, file as MutableInMemoryFile<TCT>);\n return succeed(file as MutableInMemoryFile<TCT>);\n });\n }\n\n /**\n * Creates a directory at the given path, including any missing parent directories.\n * @param dirPath - The path of the directory to create.\n * @returns `Success` with the absolute path if created, or `Failure` with an error message.\n */\n public createDirectory(dirPath: string): Result<string> {\n const absolutePath = this.resolveAbsolutePath(dirPath);\n\n // Check if mutability is disabled\n if (this._mutable === false) {\n return fail(`${absolutePath}: mutability is disabled`);\n }\n\n // Add to the TreeBuilder (read layer)\n const treeResult = this._tree.addDirectory(absolutePath);\n /* c8 ignore next 3 - defensive: read layer failure would indicate internal inconsistency */\n if (treeResult.isFailure()) {\n return fail(treeResult.message);\n }\n\n // Add to the mutable layer\n const parts = absolutePath.split('/').filter((p) => p.length > 0);\n let dir: MutableInMemoryDirectory<TCT> = this._mutableRoot;\n for (const part of parts) {\n const result = dir.getOrAddDirectory(part);\n /* c8 ignore next 3 - defensive: mutable layer should match read layer state */\n if (result.isFailure()) {\n return fail(result.message);\n }\n dir = result.value as MutableInMemoryDirectory<TCT>;\n if (!this._mutableByPath.has(dir.absolutePath)) {\n this._mutableByPath.set(dir.absolutePath, dir);\n }\n }\n\n return succeed(absolutePath);\n }\n\n /**\n * Checks if a file at the given path can be saved.\n * @param path - The path to check.\n * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,\n * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.\n */\n public fileIsMutable(path: string): DetailedResult<boolean, SaveDetail> {\n const absolutePath = this.resolveAbsolutePath(path);\n\n // Check if mutability is disabled\n if (this._mutable === false) {\n return failWithDetail(`${absolutePath}: mutability is disabled`, 'not-mutable');\n }\n\n // Check if path is excluded by filter\n if (!isPathMutable(absolutePath, this._mutable)) {\n return failWithDetail(`${absolutePath}: path is excluded by filter`, 'path-excluded');\n }\n\n return succeedWithDetail(true, 'transient');\n }\n\n /**\n * Deletes a file at the given path.\n * @param path - The path of the file to delete.\n * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.\n */\n public deleteFile(path: string): Result<boolean> {\n const absolutePath = this.resolveAbsolutePath(path);\n const parts = absolutePath.split('/').filter((p) => p.length > 0);\n if (parts.length === 0) {\n return fail(`${absolutePath}: invalid file path`);\n }\n\n const fileName = parts.pop()!;\n\n // Navigate to parent directory\n let dir: MutableInMemoryDirectory<TCT> = this._mutableRoot;\n for (const part of parts) {\n const child = dir.children.get(part);\n if (!child || !(child instanceof MutableInMemoryDirectory)) {\n return fail(`${absolutePath}: parent directory not found`);\n }\n dir = child;\n }\n\n if (!dir.removeChild(fileName)) {\n return fail(`${absolutePath}: file not found`);\n }\n\n // Also remove from the read layer's directory children and path index\n const parentPath = parts.length === 0 ? '/' : '/' + parts.join('/');\n const readParent = this._tree.byAbsolutePath.get(parentPath);\n if (readParent instanceof InMemoryDirectory) {\n readParent.removeChild(fileName);\n }\n this._tree.byAbsolutePath.delete(absolutePath);\n this._mutableByPath.delete(absolutePath);\n\n return succeed(true);\n }\n\n /**\n * Deletes a directory at the given path.\n * The directory must be empty or the operation will fail.\n * @param path - The path of the directory to delete.\n * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.\n */\n public deleteDirectory(path: string): Result<boolean> {\n const absolutePath = this.resolveAbsolutePath(path);\n const parts = absolutePath.split('/').filter((p) => p.length > 0);\n if (parts.length === 0) {\n return fail(`${absolutePath}: invalid directory path`);\n }\n\n const dirName = parts.pop()!;\n\n // Navigate to parent directory\n let parentDir: MutableInMemoryDirectory<TCT> = this._mutableRoot;\n for (const part of parts) {\n const child = parentDir.children.get(part);\n if (!child || !(child instanceof MutableInMemoryDirectory)) {\n return fail(`${absolutePath}: parent directory not found`);\n }\n parentDir = child;\n }\n\n // Verify target is a directory\n const target = parentDir.children.get(dirName);\n if (!target || !(target instanceof MutableInMemoryDirectory)) {\n return fail(`${absolutePath}: not a directory`);\n }\n\n // Check non-empty\n if (target.children.size > 0) {\n return fail(`${absolutePath}: directory is not empty`);\n }\n\n parentDir.removeChild(dirName);\n\n // Also remove from the read layer\n /* c8 ignore next 1 - defensive: branch for top-level directory deletion */\n const readParentPath = parts.length === 0 ? '/' : '/' + parts.join('/');\n const readParent = this._tree.byAbsolutePath.get(readParentPath);\n if (readParent instanceof InMemoryDirectory) {\n readParent.removeChild(dirName);\n }\n this._tree.byAbsolutePath.delete(absolutePath);\n this._mutableByPath.delete(absolutePath);\n\n return succeed(true);\n }\n\n /**\n * Saves the contents to a file at the given path.\n * @param path - The path of the file to save.\n * @param contents - The string contents to save.\n * @returns `Success` if the file was saved, or `Failure` with an error message.\n */\n public saveFileContents(path: string, contents: string): Result<string> {\n const isMutable = this.fileIsMutable(path);\n if (isMutable.isFailure()) {\n return fail(isMutable.message);\n }\n\n const absolutePath = this.resolveAbsolutePath(path);\n const parts = absolutePath.split('/').filter((p) => p.length > 0);\n if (parts.length === 0) {\n return fail(`${absolutePath}: invalid file path`);\n }\n\n // Navigate to parent directory, creating directories as needed\n let dir: MutableInMemoryDirectory<TCT> = this._mutableRoot;\n while (parts.length > 1) {\n const part = parts.shift()!;\n const result = dir.getOrAddDirectory(part);\n if (result.isFailure()) {\n return fail(result.message);\n }\n dir = result.value as MutableInMemoryDirectory<TCT>;\n if (!this._mutableByPath.has(dir.absolutePath)) {\n this._mutableByPath.set(dir.absolutePath, dir);\n }\n }\n\n // Update or add the file in the mutable layer\n return dir.updateOrAddFile(parts[0], contents).onSuccess((file) => {\n this._mutableByPath.set(file.absolutePath, file as MutableInMemoryFile<TCT>);\n\n // Also register in the read layer so getItem/getChildren can find it\n if (!this._tree.byAbsolutePath.has(file.absolutePath)) {\n this._tree.addFile(file.absolutePath, contents);\n }\n\n return succeed(contents);\n });\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packlets/file-tree/in-memory/index.ts"],"names":[],"mappings":"AAsBA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/file-tree/in-memory/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,iDAA+B","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './inMemoryTree';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeBuilder.d.ts","sourceRoot":"","sources":["../../../../src/packlets/file-tree/in-memory/treeBuilder.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAgC,MAAM,eAAe,CAAC;AAErE;;;GAGG;AACH,qBAAa,YAAY,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM;IACnD;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC;;OAEG;IACH,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAElC;;OAEG;IACH,SAAgB,WAAW,CAAC,EAAE,GAAG,CAAC;IAElC;;;;;OAKG;gBACgB,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,GAAG;CAK9E;AAED;;;GAGG;AACH,qBAAa,iBAAiB,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM;IACxD;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAE7E;;OAEG;IACH,IAAW,QAAQ,IAAI,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAErF;IAED;;;OAGG;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AG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QACD,OAAO,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;IACtB,CAAC;CACF;AAxGD,kCAwGC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, fail, succeed } from '@fgv/ts-utils';\n\n/**\n * Represents a file in an in-memory file tree.\n * @public\n */\nexport class InMemoryFile<TCT extends string = string> {\n /**\n * The absolute path of the file.\n */\n public readonly absolutePath: string;\n /**\n * The contents of the file.\n */\n public readonly contents: unknown;\n\n /**\n * The content type of the file.\n */\n public readonly contentType?: TCT;\n\n /**\n * Creates a new {@link FileTree.InMemoryFile | InMemoryFile} instance.\n * @param absolutePath - The absolute path of the file.\n * @param contents - The contents of the file.\n * @param contentType - Optional content type of the file.\n */\n public constructor(absolutePath: string, contents: unknown, contentType?: TCT) {\n this.absolutePath = absolutePath;\n this.contents = contents;\n this.contentType = contentType;\n }\n}\n\n/**\n * Represents a directory in an in-memory file tree.\n * @public\n */\nexport class InMemoryDirectory<TCT extends string = string> {\n /**\n * The absolute path of the directory.\n */\n public readonly absolutePath: string;\n protected _children: Map<string, InMemoryDirectory<TCT> | InMemoryFile<TCT>>;\n\n /**\n * The children of the directory.\n */\n public get children(): ReadonlyMap<string, InMemoryDirectory<TCT> | InMemoryFile<TCT>> {\n return this._children;\n }\n\n /**\n * Creates an empty new {@link FileTree.InMemoryDirectory | InMemoryDirectory} instance.\n * @param absolutePath - The absolute path of the directory.\n */\n public constructor(absolutePath: string) {\n this.absolutePath = absolutePath;\n this._children = new Map<string, InMemoryDirectory<TCT> | InMemoryFile<TCT>>();\n }\n\n /**\n * Gets or adds a child directory with the specified name.\n * @param name - The name of the child directory.\n * @returns `Success` with the child directory if successful, or\n * `Failure` with an error message otherwise.\n */\n public getOrAddDirectory(name: string): Result<InMemoryDirectory<TCT>> {\n const existing = this._children.get(name);\n if (existing) {\n if (existing instanceof InMemoryDirectory) {\n return succeed(existing);\n }\n return fail(`${name}: not a directory`);\n }\n const child = new InMemoryDirectory<TCT>(this.getChildPath(name));\n this._children.set(name, child);\n return succeed(child);\n }\n\n /**\n * Adds a file to the directory.\n * @param name - The name of the file.\n * @param contents - The contents of the file.\n * @param contentType - Optional content type of the file.\n * @returns `Success` with the new file if successful, or\n * `Failure` with an error message otherwise.\n */\n public addFile(name: string, contents: unknown, contentType?: TCT): Result<InMemoryFile<TCT>> {\n if (this._children.has(name)) {\n return fail(`${name}: already exists`);\n }\n const child = new InMemoryFile<TCT>(this.getChildPath(name), contents, contentType);\n this._children.set(name, child);\n return succeed(child);\n }\n\n /**\n * Removes a child from the directory.\n * @param name - The name of the child to remove.\n * @returns `true` if the child was found and removed, `false` otherwise.\n */\n public removeChild(name: string): boolean {\n return this._children.delete(name);\n }\n\n /**\n * Gets the absolute path for a child of this directory with the supplied\n * name.\n * @param name - The name of the child.\n * @returns `Success` with the absolute path if successful, or\n * `Failure` with an error message otherwise.\n */\n public getChildPath(name: string): string {\n if (this.absolutePath === '/') {\n return `/${name}`;\n }\n return [this.absolutePath, name].join('/');\n }\n}\n\n/**\n * Helper class to build an in-memory file tree.\n * @public\n */\nexport class TreeBuilder<TCT extends string = string> {\n /**\n * The prefix for all paths in the tree.\n */\n public readonly prefix: string;\n\n /**\n * The root directory of the tree.\n */\n public readonly root: InMemoryDirectory<TCT>;\n\n /**\n * A map of all directories and files in the tree by absolute path.\n */\n public readonly byAbsolutePath: Map<string, InMemoryDirectory<TCT> | InMemoryFile<TCT>>;\n\n /**\n * Protected constructor for derived classes.\n * @param prefix - The prefix for all paths in the tree.\n * @public\n */\n protected constructor(prefix?: string) {\n this.prefix = prefix ?? '/';\n if (!this.prefix.startsWith('/')) {\n throw new Error(`${prefix}: not an absolute path`);\n }\n\n // Normalize the prefix to remove trailing slashes (except for root)\n /* c8 ignore next 3 - tested but code coverage has intermittent issues */\n if (this.prefix !== '/' && this.prefix.endsWith('/')) {\n this.prefix = this.prefix.slice(0, -1);\n }\n\n this.root = new InMemoryDirectory<TCT>(this.prefix);\n this.byAbsolutePath = new Map<string, InMemoryDirectory<TCT> | InMemoryFile<TCT>>();\n this.byAbsolutePath.set(this.prefix, this.root);\n }\n\n /**\n * Creates a new {@link TreeBuilder} instance.\n * @param prefix - The prefix for all paths in the tree.\n * @returns `Success` with the new {@link TreeBuilder} instance if successful,\n * or `Failure` with an error message otherwise.\n * @public\n */\n public static create<TCT extends string = string>(prefix?: string): Result<TreeBuilder<TCT>> {\n return captureResult(() => new TreeBuilder(prefix));\n }\n\n /**\n * Adds a file to the tree.\n * @param absolutePath - The absolute path of the file.\n * @param contents - The contents of the file.\n * @param contentType - The content type of the file.\n * @returns `Success` with the new file if successful, or\n * `Failure` with an error message otherwise.\n * @public\n */\n public addFile(absolutePath: string, contents: unknown, contentType?: TCT): Result<InMemoryFile<TCT>> {\n const parts = absolutePath.split('/').filter((p) => p.length > 0);\n if (parts.length === 0) {\n return fail(`${absolutePath}: invalid file path`);\n }\n let dir = this.root;\n while (parts.length > 1) {\n const part = parts.shift()!;\n const result = dir.getOrAddDirectory(part);\n if (result.isFailure()) {\n return fail(result.message);\n }\n dir = result.value;\n if (!this.byAbsolutePath.has(dir.absolutePath)) {\n this.byAbsolutePath.set(dir.absolutePath, dir);\n }\n }\n return dir.addFile(parts[0], contents, contentType).onSuccess((file: InMemoryFile<TCT>) => {\n this.byAbsolutePath.set(file.absolutePath, file);\n return succeed(file);\n });\n }\n\n /**\n * Ensures a directory exists at the given absolute path, creating\n * intermediate directories as needed.\n * @param absolutePath - The absolute path of the directory.\n * @returns `Success` with the directory if successful, or\n * `Failure` with an error message otherwise.\n * @public\n */\n public addDirectory(absolutePath: string): Result<InMemoryDirectory<TCT>> {\n const parts = absolutePath.split('/').filter((p) => p.length > 0);\n let dir = this.root;\n for (const part of parts) {\n const result = dir.getOrAddDirectory(part);\n if (result.isFailure()) {\n return fail(result.message);\n }\n dir = result.value;\n if (!this.byAbsolutePath.has(dir.absolutePath)) {\n this.byAbsolutePath.set(dir.absolutePath, dir);\n }\n }\n return succeed(dir);\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/index.browser.ts"],"names":[],"mappings":"AAyBA,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAG7B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/index.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;AAEH,2EAA2E;AAE3E,qCAAqC;AACrC,sDAAoC;AACpC,6CAA2B;AAC3B,kDAAgC;AAChC,6CAA2B;AAC3B,+CAA6B;AAE7B,yDAAyD;AACzD,8CAA4B;AAC5B,uEAAsD;AAA7C,oHAAA,QAAQ,OAAA;AAEjB,WAAW;AACX,sCAAsC;AACtC,qCAAqC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Browser-safe FileTree exports - excludes Node.js filesystem dependencies\n\n// Export core interfaces and classes\nexport * from './fileTreeAccessors';\nexport * from './fileTree';\nexport * from './directoryItem';\nexport * from './fileItem';\nexport * from './filterSpec';\n\n// Export in-memory implementations for web compatibility\nexport * from './in-memory';\nexport { inMemory } from './fileTreeHelpers.inMemory';\n\n// Exclude:\n// - fsTree (requires Node.js fs/path)\n// - fileTreeHelpers (imports fsTree)\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/index.ts"],"names":[],"mappings":"AAuBA,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAG7B,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGtD,cAAc,aAAa,CAAC;AAI5B,cAAc,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;AAEH,qCAAqC;AACrC,sDAAoC;AACpC,6CAA2B;AAC3B,kDAAgC;AAChC,6CAA2B;AAC3B,+CAA6B;AAE7B,iFAAiF;AACjF,oDAAkC;AAClC,uEAAsD;AAA7C,oHAAA,QAAQ,OAAA;AAEjB,yDAAyD;AACzD,8CAA4B;AAE5B,uEAAuE;AACvE,4EAA4E;AAC5E,2CAAyB","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Export core interfaces and classes\nexport * from './fileTreeAccessors';\nexport * from './fileTree';\nexport * from './directoryItem';\nexport * from './fileItem';\nexport * from './filterSpec';\n\n// Export tree-shakeable helpers (filesystem ones will be shaken out if not used)\nexport * from './fileTreeHelpers';\nexport { inMemory } from './fileTreeHelpers.inMemory';\n\n// Export in-memory implementations for web compatibility\nexport * from './in-memory';\n\n// Note: FsFileTreeAccessors is now only imported by fileTreeHelpers.ts\n// Web apps that don't use forFilesystem() won't bundle fs/path dependencies\nexport * from './fsTree';\n"]}