@fgv/ts-json-base 5.1.0-2 → 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 (113) 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 +11 -4
  7. package/dist/packlets/file-tree/fileItem.js.map +1 -0
  8. package/dist/packlets/file-tree/fileTree.js.map +1 -0
  9. package/dist/packlets/file-tree/fileTreeAccessors.js.map +1 -0
  10. package/dist/packlets/file-tree/fileTreeHelpers.inMemory.js.map +1 -0
  11. package/dist/packlets/file-tree/fileTreeHelpers.js.map +1 -0
  12. package/dist/packlets/file-tree/filterSpec.js.map +1 -0
  13. package/dist/packlets/file-tree/fsTree.js +44 -13
  14. package/dist/packlets/file-tree/fsTree.js.map +1 -0
  15. package/dist/packlets/file-tree/in-memory/inMemoryTree.js +44 -13
  16. package/dist/packlets/file-tree/in-memory/inMemoryTree.js.map +1 -0
  17. package/dist/packlets/file-tree/in-memory/index.js.map +1 -0
  18. package/dist/packlets/file-tree/in-memory/treeBuilder.js.map +1 -0
  19. package/dist/packlets/file-tree/index.browser.js.map +1 -0
  20. package/dist/packlets/file-tree/index.js.map +1 -0
  21. package/dist/packlets/json/common.js.map +1 -0
  22. package/dist/packlets/json/index.js.map +1 -0
  23. package/dist/packlets/json-compatible/common.js.map +1 -0
  24. package/dist/packlets/json-compatible/converters.js.map +1 -0
  25. package/dist/packlets/json-compatible/index.js.map +1 -0
  26. package/dist/packlets/json-compatible/validators.js.map +1 -0
  27. package/dist/packlets/json-file/file.js.map +1 -0
  28. package/dist/packlets/json-file/index.browser.js.map +1 -0
  29. package/dist/packlets/json-file/index.js.map +1 -0
  30. package/dist/packlets/json-file/jsonFsHelper.js.map +1 -0
  31. package/dist/packlets/json-file/jsonLike.js.map +1 -0
  32. package/dist/packlets/json-file/jsonTreeHelper.js.map +1 -0
  33. package/dist/packlets/validators/index.js.map +1 -0
  34. package/dist/packlets/validators/validators.js.map +1 -0
  35. package/dist/ts-json-base.d.ts +99 -30
  36. package/dist/tsdoc-metadata.json +1 -1
  37. package/lib/index.browser.d.ts.map +1 -0
  38. package/lib/index.browser.js.map +1 -0
  39. package/lib/index.d.ts.map +1 -0
  40. package/lib/index.js.map +1 -0
  41. package/lib/packlets/converters/converters.d.ts.map +1 -0
  42. package/lib/packlets/converters/converters.js.map +1 -0
  43. package/lib/packlets/converters/index.d.ts.map +1 -0
  44. package/lib/packlets/converters/index.js.map +1 -0
  45. package/lib/packlets/file-tree/directoryItem.d.ts.map +1 -0
  46. package/lib/packlets/file-tree/directoryItem.js.map +1 -0
  47. package/lib/packlets/file-tree/fileItem.d.ts +11 -4
  48. package/lib/packlets/file-tree/fileItem.d.ts.map +1 -0
  49. package/lib/packlets/file-tree/fileItem.js +11 -4
  50. package/lib/packlets/file-tree/fileItem.js.map +1 -0
  51. package/lib/packlets/file-tree/fileTree.d.ts.map +1 -0
  52. package/lib/packlets/file-tree/fileTree.js.map +1 -0
  53. package/lib/packlets/file-tree/fileTreeAccessors.d.ts.map +1 -0
  54. package/lib/packlets/file-tree/fileTreeAccessors.js.map +1 -0
  55. package/lib/packlets/file-tree/fileTreeHelpers.d.ts.map +1 -0
  56. package/lib/packlets/file-tree/fileTreeHelpers.inMemory.d.ts.map +1 -0
  57. package/lib/packlets/file-tree/fileTreeHelpers.inMemory.js.map +1 -0
  58. package/lib/packlets/file-tree/fileTreeHelpers.js.map +1 -0
  59. package/lib/packlets/file-tree/filterSpec.d.ts.map +1 -0
  60. package/lib/packlets/file-tree/filterSpec.js.map +1 -0
  61. package/lib/packlets/file-tree/fsTree.d.ts +44 -13
  62. package/lib/packlets/file-tree/fsTree.d.ts.map +1 -0
  63. package/lib/packlets/file-tree/fsTree.js +44 -13
  64. package/lib/packlets/file-tree/fsTree.js.map +1 -0
  65. package/lib/packlets/file-tree/in-memory/inMemoryTree.d.ts +44 -13
  66. package/lib/packlets/file-tree/in-memory/inMemoryTree.d.ts.map +1 -0
  67. package/lib/packlets/file-tree/in-memory/inMemoryTree.js +44 -13
  68. package/lib/packlets/file-tree/in-memory/inMemoryTree.js.map +1 -0
  69. package/lib/packlets/file-tree/in-memory/index.d.ts.map +1 -0
  70. package/lib/packlets/file-tree/in-memory/index.js.map +1 -0
  71. package/lib/packlets/file-tree/in-memory/treeBuilder.d.ts.map +1 -0
  72. package/lib/packlets/file-tree/in-memory/treeBuilder.js.map +1 -0
  73. package/lib/packlets/file-tree/index.browser.d.ts.map +1 -0
  74. package/lib/packlets/file-tree/index.browser.js.map +1 -0
  75. package/lib/packlets/file-tree/index.d.ts.map +1 -0
  76. package/lib/packlets/file-tree/index.js.map +1 -0
  77. package/lib/packlets/json/common.d.ts.map +1 -0
  78. package/lib/packlets/json/common.js.map +1 -0
  79. package/lib/packlets/json/index.d.ts.map +1 -0
  80. package/lib/packlets/json/index.js.map +1 -0
  81. package/lib/packlets/json-compatible/common.d.ts.map +1 -0
  82. package/lib/packlets/json-compatible/common.js.map +1 -0
  83. package/lib/packlets/json-compatible/converters.d.ts.map +1 -0
  84. package/lib/packlets/json-compatible/converters.js.map +1 -0
  85. package/lib/packlets/json-compatible/index.d.ts.map +1 -0
  86. package/lib/packlets/json-compatible/index.js.map +1 -0
  87. package/lib/packlets/json-compatible/validators.d.ts.map +1 -0
  88. package/lib/packlets/json-compatible/validators.js.map +1 -0
  89. package/lib/packlets/json-file/file.d.ts.map +1 -0
  90. package/lib/packlets/json-file/file.js.map +1 -0
  91. package/lib/packlets/json-file/index.browser.d.ts.map +1 -0
  92. package/lib/packlets/json-file/index.browser.js.map +1 -0
  93. package/lib/packlets/json-file/index.d.ts.map +1 -0
  94. package/lib/packlets/json-file/index.js.map +1 -0
  95. package/lib/packlets/json-file/jsonFsHelper.d.ts.map +1 -0
  96. package/lib/packlets/json-file/jsonFsHelper.js.map +1 -0
  97. package/lib/packlets/json-file/jsonLike.d.ts.map +1 -0
  98. package/lib/packlets/json-file/jsonLike.js.map +1 -0
  99. package/lib/packlets/json-file/jsonTreeHelper.d.ts.map +1 -0
  100. package/lib/packlets/json-file/jsonTreeHelper.js.map +1 -0
  101. package/lib/packlets/validators/index.d.ts.map +1 -0
  102. package/lib/packlets/validators/index.js.map +1 -0
  103. package/lib/packlets/validators/validators.d.ts.map +1 -0
  104. package/lib/packlets/validators/validators.js.map +1 -0
  105. package/package.json +22 -20
  106. package/dist/test/fixtures/file-tree/config.json +0 -1
  107. package/dist/test/fixtures/file-tree/data/items.json +0 -1
  108. package/dist/test/unit/data/file/bad/bad3.json +0 -3
  109. package/dist/test/unit/data/file/bad/thing1.json +0 -4
  110. package/dist/test/unit/data/file/bad/thing2.json +0 -3
  111. package/dist/test/unit/data/file/good/thing1.json +0 -4
  112. package/dist/test/unit/data/file/good/thing2.json +0 -3
  113. package/dist/test/unit/json-compatible/helpers.js +0 -32
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,yDAAyD;AACzD,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,yDAAyD;AACzD,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","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.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,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","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.js","sourceRoot":"","sources":["../../../src/packlets/converters/converters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,UAAU,EAEV,UAAU,IAAI,cAAc,EAE5B,eAAe,EACf,aAAa,EACb,IAAI,EACJ,OAAO,EACR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAmD,WAAW,EAAE,YAAY,EA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,CAAC,CAAC;QACxC,CAAC;QAED,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,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,IAAI,CAAC,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.js","sourceRoot":"","sources":["../../../src/packlets/converters/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 './converters';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directoryItem.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAU,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAML,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,MAAM,OAAO,aAAa;IAWxB;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;IAQD;;;;;;OAMG;IACH,YAAsB,IAAY,EAAE,GAA4B;QA9BhE;;WAEG;QACa,SAAI,GAAgB,WAAW,CAAC;QA4B9C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAClB,IAAY,EACZ,GAA4B;QAE5B,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,aAAa,CAAM,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACI,WAAW;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,IAAY,EAAE,QAAgB;QACnD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,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AAC,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","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"]}
@@ -77,7 +77,9 @@ export class FileItem {
77
77
  return captureResult(() => new FileItem(path, hal));
78
78
  }
79
79
  /**
80
- * {@inheritDoc FileTree.IFileTreeFileItem.getIsMutable}
80
+ * Indicates whether this file can be saved.
81
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
82
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
81
83
  */
82
84
  getIsMutable() {
83
85
  if (isMutableAccessors(this._hal)) {
@@ -111,13 +113,17 @@ export class FileItem {
111
113
  this._contentType = contentType;
112
114
  }
113
115
  /**
114
- * {@inheritDoc FileTree.IFileTreeFileItem.setContents}
116
+ * Sets the contents of the file from a JSON value.
117
+ * @param json - The JSON value to serialize and save.
118
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
115
119
  */
116
120
  setContents(json) {
117
121
  return captureResult(() => JSON.stringify(json, null, 2)).onSuccess((contents) => this.setRawContents(contents).onSuccess(() => Success.with(json)));
118
122
  }
119
123
  /**
120
- * {@inheritDoc FileTree.IFileTreeFileItem.setRawContents}
124
+ * Sets the raw contents of the file.
125
+ * @param contents - The string contents to save.
126
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
121
127
  */
122
128
  setRawContents(contents) {
123
129
  if (isMutableAccessors(this._hal)) {
@@ -127,7 +133,8 @@ export class FileItem {
127
133
  return fail(`${this.absolutePath}: mutation not supported`);
128
134
  }
129
135
  /**
130
- * {@inheritDoc FileTree.IFileTreeFileItem.delete}
136
+ * Deletes this file from its backing store.
137
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
131
138
  */
132
139
  delete() {
133
140
  if (!isMutableAccessors(this._hal)) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileItem.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAkB,IAAI,EAAE,cAAc,EAAU,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG9G,OAAO,EAGL,kBAAkB,EAEnB,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,MAAM,OAAO,QAAQ;IAWnB;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;I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,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,uBAAuB,CACnC,QAAgB,EAChB,QAAiB;QAEjB,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,wBAAwB,CACpC,QAAgB,EAChB,QAAc;QAEd,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;CACF","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.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAU,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAQrE;;;GAGG;AACH,MAAM,OAAO,QAAQ;IAOnB;;;;;OAKG;IACH,YAAsB,GAA4B;QAChD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAA8B,GAA4B;QAC5E,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,QAAgB;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,QAAgB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;YAC/C,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACzB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,IAAI,CAAC,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,OAAO,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,aAAa,mBAAmB,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC;CACF","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.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTreeAccessors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAicH,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAkC;IAElC,MAAM,OAAO,GAAG,SAA2C,CAAC;IAC5D,OAAO,CACL,OAAO,OAAO,CAAC,aAAa,KAAK,UAAU;QAC3C,OAAO,OAAO,CAAC,gBAAgB,KAAK,UAAU;QAC9C,OAAO,OAAO,CAAC,UAAU,KAAK,UAAU;QACxC,OAAO,OAAO,CAAC,eAAe,KAAK,UAAU;QAC7C,OAAO,OAAO,CAAC,eAAe,KAAK,UAAU,CAC9C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,SAAkC;IAElC,MAAM,UAAU,GAAG,SAA8C,CAAC;IAClE,oFAAoF;IACpF,OAAO,CACL,kBAAkB,CAAC,SAAS,CAAC;QAC7B,OAAO,UAAU,CAAC,UAAU,KAAK,UAAU;QAC3C,OAAO,UAAU,CAAC,OAAO,KAAK,UAAU;QACxC,OAAO,UAAU,CAAC,aAAa,KAAK,UAAU,CAC/C,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,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,MAAM,UAAU,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.inMemory.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTreeHelpers.inMemory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAiB,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA+BnE,MAAM,UAAU,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,qBAAqB,CAAC,MAAM,CAAM,KAAK,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAA+B,EAAE,EAAE,CACpG,QAAQ,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;AAEH,OAAO,EAAE,aAAa,EAAU,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAwB/C,MAAM,UAAU,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,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAM,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,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.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/filterSpec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;;;;;;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,MAAM,UAAU,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"]}
@@ -44,7 +44,9 @@ export class FsFileTreeAccessors {
44
44
  this._mutable = (_b = params === null || params === void 0 ? void 0 : params.mutable) !== null && _b !== void 0 ? _b : false;
45
45
  }
46
46
  /**
47
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
47
+ * Resolves paths to an absolute path.
48
+ * @param paths - Paths to resolve.
49
+ * @returns The resolved absolute path.
48
50
  */
49
51
  resolveAbsolutePath(...paths) {
50
52
  if (this.prefix && !path.isAbsolute(paths[0])) {
@@ -53,25 +55,34 @@ export class FsFileTreeAccessors {
53
55
  return path.resolve(...paths);
54
56
  }
55
57
  /**
56
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
58
+ * Gets the extension of a path.
59
+ * @param itemPath - Path to get the extension of.
60
+ * @returns The extension of the path.
57
61
  */
58
62
  getExtension(itemPath) {
59
63
  return path.extname(itemPath);
60
64
  }
61
65
  /**
62
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
66
+ * Gets the base name of a path.
67
+ * @param itemPath - Path to get the base name of.
68
+ * @param suffix - Optional suffix to remove from the base name.
69
+ * @returns The base name of the path.
63
70
  */
64
71
  getBaseName(itemPath, suffix) {
65
72
  return path.basename(itemPath, suffix);
66
73
  }
67
74
  /**
68
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
75
+ * Joins paths together.
76
+ * @param paths - Paths to join.
77
+ * @returns The joined paths.
69
78
  */
70
79
  joinPaths(...paths) {
71
80
  return path.join(...paths);
72
81
  }
73
82
  /**
74
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
83
+ * Gets an item from the file tree.
84
+ * @param itemPath - Path of the item to get.
85
+ * @returns The item if it exists.
75
86
  */
76
87
  getItem(itemPath) {
77
88
  return captureResult(() => {
@@ -87,13 +98,18 @@ export class FsFileTreeAccessors {
87
98
  });
88
99
  }
89
100
  /**
90
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
101
+ * Gets the contents of a file in the file tree.
102
+ * @param filePath - Absolute path of the file.
103
+ * @returns The contents of the file.
91
104
  */
92
105
  getFileContents(filePath) {
93
106
  return captureResult(() => fs.readFileSync(this.resolveAbsolutePath(filePath), 'utf8'));
94
107
  }
95
108
  /**
96
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
109
+ * Gets the content type of a file in the file tree.
110
+ * @param filePath - Absolute path of the file.
111
+ * @param provided - Optional supplied content type.
112
+ * @returns The content type of the file.
97
113
  */
98
114
  getFileContentType(filePath, provided) {
99
115
  if (provided !== undefined) {
@@ -103,7 +119,9 @@ export class FsFileTreeAccessors {
103
119
  return this._inferContentType(filePath);
104
120
  }
105
121
  /**
106
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
122
+ * Gets the children of a directory in the file tree.
123
+ * @param dirPath - Path of the directory.
124
+ * @returns The children of the directory.
107
125
  */
108
126
  getChildren(dirPath) {
109
127
  return captureResult(() => {
@@ -122,7 +140,10 @@ export class FsFileTreeAccessors {
122
140
  });
123
141
  }
124
142
  /**
125
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
143
+ * Checks if a file at the given path can be saved.
144
+ * @param path - The path to check.
145
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
146
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
126
147
  */
127
148
  fileIsMutable(path) {
128
149
  const absolutePath = this.resolveAbsolutePath(path);
@@ -155,7 +176,10 @@ export class FsFileTreeAccessors {
155
176
  }
156
177
  }
157
178
  /**
158
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
179
+ * Saves the contents to a file at the given path.
180
+ * @param path - The path of the file to save.
181
+ * @param contents - The string contents to save.
182
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
159
183
  */
160
184
  saveFileContents(path, contents) {
161
185
  return this.fileIsMutable(path).asResult.onSuccess(() => {
@@ -167,7 +191,9 @@ export class FsFileTreeAccessors {
167
191
  });
168
192
  }
169
193
  /**
170
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
194
+ * Deletes a file at the given path.
195
+ * @param path - The path of the file to delete.
196
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
171
197
  */
172
198
  deleteFile(path) {
173
199
  return this.fileIsMutable(path).asResult.onSuccess(() => {
@@ -183,7 +209,9 @@ export class FsFileTreeAccessors {
183
209
  });
184
210
  }
185
211
  /**
186
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
212
+ * Creates a directory at the given path, including any missing parent directories.
213
+ * @param dirPath - The path of the directory to create.
214
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
187
215
  */
188
216
  createDirectory(dirPath) {
189
217
  const absolutePath = this.resolveAbsolutePath(dirPath);
@@ -197,7 +225,10 @@ export class FsFileTreeAccessors {
197
225
  });
198
226
  }
199
227
  /**
200
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
228
+ * Deletes a directory at the given path.
229
+ * The directory must be empty or the operation will fail.
230
+ * @param dirPath - The path of the directory to delete.
231
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
201
232
  */
202
233
  deleteDirectory(dirPath) {
203
234
  return this.fileIsMutable(dirPath).asResult.onSuccess(() => {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fsTree.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fsTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AASH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,aAAa,EAEb,IAAI,EACJ,cAAc,EAEd,OAAO,EACP,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAiB9B;;;;OAIG;IACH,YAAmB,MAAiC;;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,gBAAgB,mCAAI,QAAQ,CAAC,uBAAuB,CAAC;QACtF,mEAAmE;QACnE,IAAI,CAAC,QAAQ,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,mCAAI,KAAK,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACI,mBAAmB,CAAC,GAAG,KAAe;QAC3C,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9C,OAAO,IAAI,CAAC,OAAO,C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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,aAAa,CAAC,GAAG,EAAE;gBACxB,MAAM,IAAI,GAAG,EAAE,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,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBAC3B,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","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"]}
@@ -135,7 +135,9 @@ export class InMemoryTreeAccessors {
135
135
  return captureResult(() => new InMemoryTreeAccessors(files, params));
136
136
  }
137
137
  /**
138
- * {@inheritDoc FileTree.IFileTreeAccessors.resolveAbsolutePath}
138
+ * Resolves paths to an absolute path.
139
+ * @param paths - Paths to resolve.
140
+ * @returns The resolved absolute path.
139
141
  */
140
142
  resolveAbsolutePath(...paths) {
141
143
  const parts = paths[0].startsWith('/') ? paths : [this._tree.prefix, ...paths];
@@ -143,7 +145,9 @@ export class InMemoryTreeAccessors {
143
145
  return `/${joined}`;
144
146
  }
145
147
  /**
146
- * {@inheritDoc FileTree.IFileTreeAccessors.getExtension}
148
+ * Gets the extension of a path.
149
+ * @param path - Path to get the extension of.
150
+ * @returns The extension of the path.
147
151
  */
148
152
  getExtension(path) {
149
153
  const parts = path.split('.');
@@ -153,7 +157,10 @@ export class InMemoryTreeAccessors {
153
157
  return `.${parts.pop()}`;
154
158
  }
155
159
  /**
156
- * {@inheritDoc FileTree.IFileTreeAccessors.getBaseName}
160
+ * Gets the base name of a path.
161
+ * @param path - Path to get the base name of.
162
+ * @param suffix - Optional suffix to remove from the base name.
163
+ * @returns The base name of the path.
157
164
  */
158
165
  getBaseName(path, suffix) {
159
166
  var _a;
@@ -165,7 +172,9 @@ export class InMemoryTreeAccessors {
165
172
  return base;
166
173
  }
167
174
  /**
168
- * {@inheritDoc FileTree.IFileTreeAccessors.joinPaths}
175
+ * Joins paths together.
176
+ * @param paths - Paths to join.
177
+ * @returns The joined paths.
169
178
  */
170
179
  joinPaths(...paths) {
171
180
  var _a;
@@ -173,7 +182,9 @@ export class InMemoryTreeAccessors {
173
182
  return ((_a = paths[0]) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? `/${joined}` : joined;
174
183
  }
175
184
  /**
176
- * {@inheritDoc FileTree.IFileTreeAccessors.getItem}
185
+ * Gets an item from the file tree.
186
+ * @param itemPath - Path of the item to get.
187
+ * @returns The item if it exists.
177
188
  */
178
189
  getItem(itemPath) {
179
190
  const existing = this._tree.byAbsolutePath.get(itemPath);
@@ -188,7 +199,9 @@ export class InMemoryTreeAccessors {
188
199
  return fail(`${itemPath}: not found`);
189
200
  }
190
201
  /**
191
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContents}
202
+ * Gets the contents of a file in the file tree.
203
+ * @param path - Absolute path of the file.
204
+ * @returns The contents of the file.
192
205
  */
193
206
  getFileContents(path) {
194
207
  const absolutePath = this.resolveAbsolutePath(path);
@@ -205,7 +218,10 @@ export class InMemoryTreeAccessors {
205
218
  return captureResult(() => JSON.stringify(item.contents));
206
219
  }
207
220
  /**
208
- * {@inheritDoc FileTree.IFileTreeAccessors.getFileContentType}
221
+ * Gets the content type of a file in the file tree.
222
+ * @param path - Absolute path of the file.
223
+ * @param provided - Optional supplied content type.
224
+ * @returns The content type of the file.
209
225
  */
210
226
  getFileContentType(path, provided) {
211
227
  // If provided contentType is given, use it directly (highest priority)
@@ -228,7 +244,9 @@ export class InMemoryTreeAccessors {
228
244
  return this._inferContentType(path);
229
245
  }
230
246
  /**
231
- * {@inheritDoc FileTree.IFileTreeAccessors.getChildren}
247
+ * Gets the children of a directory in the file tree.
248
+ * @param path - Path of the directory.
249
+ * @returns The children of the directory.
232
250
  */
233
251
  getChildren(path) {
234
252
  const item = this._tree.byAbsolutePath.get(path);
@@ -278,7 +296,9 @@ export class InMemoryTreeAccessors {
278
296
  });
279
297
  }
280
298
  /**
281
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.createDirectory}
299
+ * Creates a directory at the given path, including any missing parent directories.
300
+ * @param dirPath - The path of the directory to create.
301
+ * @returns `Success` with the absolute path if created, or `Failure` with an error message.
282
302
  */
283
303
  createDirectory(dirPath) {
284
304
  const absolutePath = this.resolveAbsolutePath(dirPath);
@@ -309,7 +329,10 @@ export class InMemoryTreeAccessors {
309
329
  return succeed(absolutePath);
310
330
  }
311
331
  /**
312
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.fileIsMutable}
332
+ * Checks if a file at the given path can be saved.
333
+ * @param path - The path to check.
334
+ * @returns `DetailedSuccess` with {@link FileTree.SaveCapability} if the file can be saved,
335
+ * or `DetailedFailure` with {@link FileTree.SaveFailureReason} if it cannot.
313
336
  */
314
337
  fileIsMutable(path) {
315
338
  const absolutePath = this.resolveAbsolutePath(path);
@@ -324,7 +347,9 @@ export class InMemoryTreeAccessors {
324
347
  return succeedWithDetail(true, 'transient');
325
348
  }
326
349
  /**
327
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteFile}
350
+ * Deletes a file at the given path.
351
+ * @param path - The path of the file to delete.
352
+ * @returns `Success` with `true` if the file was deleted, or `Failure` with an error message.
328
353
  */
329
354
  deleteFile(path) {
330
355
  const absolutePath = this.resolveAbsolutePath(path);
@@ -356,7 +381,10 @@ export class InMemoryTreeAccessors {
356
381
  return succeed(true);
357
382
  }
358
383
  /**
359
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.deleteDirectory}
384
+ * Deletes a directory at the given path.
385
+ * The directory must be empty or the operation will fail.
386
+ * @param path - The path of the directory to delete.
387
+ * @returns `Success` with `true` if the directory was deleted, or `Failure` with an error message.
360
388
  */
361
389
  deleteDirectory(path) {
362
390
  const absolutePath = this.resolveAbsolutePath(path);
@@ -396,7 +424,10 @@ export class InMemoryTreeAccessors {
396
424
  return succeed(true);
397
425
  }
398
426
  /**
399
- * {@inheritDoc FileTree.IMutableFileTreeAccessors.saveFileContents}
427
+ * Saves the contents to a file at the given path.
428
+ * @param path - The path of the file to save.
429
+ * @param contents - The string contents to save.
430
+ * @returns `Success` if the file was saved, or `Failure` with an error message.
400
431
  */
401
432
  saveFileContents(path, contents) {
402
433
  const isMutable = this.fileIsMutable(path);