@fgv/ts-utils 5.0.0-9 → 5.0.1-1

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 (182) hide show
  1. package/CHANGELOG.json +10 -7
  2. package/dist/ts-utils.d.ts +3042 -3133
  3. package/dist/tsdoc-metadata.json +1 -1
  4. package/eslint.config.js +37 -0
  5. package/lib/index.d.ts +2 -2
  6. package/lib/index.js +3 -3
  7. package/lib/packlets/base/index.d.ts +0 -2
  8. package/lib/packlets/base/index.js +1 -25
  9. package/lib/packlets/base/mapResults.d.ts +8 -1
  10. package/lib/packlets/base/mapResults.js +19 -0
  11. package/lib/packlets/base/result.d.ts +81 -3
  12. package/lib/packlets/base/result.js +71 -3
  13. package/lib/packlets/collections/collector.d.ts +9 -0
  14. package/lib/packlets/collections/collector.js +16 -1
  15. package/lib/packlets/collections/validatingCollector.d.ts +5 -1
  16. package/lib/packlets/conversion/baseConverter.js +0 -1
  17. package/lib/packlets/conversion/converters.js +0 -2
  18. package/lib/packlets/conversion/objectConverter.js +1 -2
  19. package/lib/packlets/hash/hashingNormalizer.js +4 -3
  20. package/lib/packlets/logging/index.d.ts +3 -0
  21. package/lib/packlets/{file-tree/in-memory → logging}/index.js +3 -2
  22. package/lib/packlets/logging/logReporter.d.ts +88 -0
  23. package/lib/packlets/logging/logReporter.js +105 -0
  24. package/lib/packlets/logging/logger.d.ts +205 -0
  25. package/lib/packlets/logging/logger.js +267 -0
  26. package/lib/packlets/validation/array.d.ts +2 -1
  27. package/lib/packlets/validation/array.js +2 -1
  28. package/lib/packlets/validation/common.d.ts +0 -8
  29. package/lib/packlets/validation/field.d.ts +1 -1
  30. package/lib/packlets/validation/field.js +1 -1
  31. package/lib/packlets/validation/genericValidator.d.ts +1 -6
  32. package/lib/packlets/validation/genericValidator.js +11 -11
  33. package/lib/packlets/validation/object.d.ts +1 -1
  34. package/lib/packlets/validation/object.js +1 -2
  35. package/lib/packlets/validation/oneOf.d.ts +2 -1
  36. package/lib/packlets/validation/oneOf.js +2 -1
  37. package/lib/packlets/validation/typeGuard.d.ts +3 -2
  38. package/lib/packlets/validation/typeGuard.js +2 -1
  39. package/lib/packlets/validation/validator.d.ts +7 -0
  40. package/lib/packlets/validation/validatorBase.d.ts +2 -1
  41. package/lib/packlets/validation/validatorBase.js +1 -1
  42. package/lib/packlets/validation/validators.d.ts +2 -2
  43. package/lib/packlets/validation/validators.js +3 -3
  44. package/package.json +16 -16
  45. package/CHANGELOG.md +0 -135
  46. package/lib/index.d.ts.map +0 -1
  47. package/lib/index.js.map +0 -1
  48. package/lib/packlets/base/brand.d.ts.map +0 -1
  49. package/lib/packlets/base/brand.js.map +0 -1
  50. package/lib/packlets/base/index.d.ts.map +0 -1
  51. package/lib/packlets/base/index.js.map +0 -1
  52. package/lib/packlets/base/logger.d.ts +0 -52
  53. package/lib/packlets/base/logger.d.ts.map +0 -1
  54. package/lib/packlets/base/logger.js +0 -128
  55. package/lib/packlets/base/logger.js.map +0 -1
  56. package/lib/packlets/base/mapResults.d.ts.map +0 -1
  57. package/lib/packlets/base/mapResults.js.map +0 -1
  58. package/lib/packlets/base/messageAggregator.d.ts.map +0 -1
  59. package/lib/packlets/base/messageAggregator.js.map +0 -1
  60. package/lib/packlets/base/normalize.d.ts.map +0 -1
  61. package/lib/packlets/base/normalize.js.map +0 -1
  62. package/lib/packlets/base/result.d.ts.map +0 -1
  63. package/lib/packlets/base/result.js.map +0 -1
  64. package/lib/packlets/base/utils.d.ts.map +0 -1
  65. package/lib/packlets/base/utils.js.map +0 -1
  66. package/lib/packlets/collections/collectible.d.ts.map +0 -1
  67. package/lib/packlets/collections/collectible.js.map +0 -1
  68. package/lib/packlets/collections/collector.d.ts.map +0 -1
  69. package/lib/packlets/collections/collector.js.map +0 -1
  70. package/lib/packlets/collections/collectorValidator.d.ts.map +0 -1
  71. package/lib/packlets/collections/collectorValidator.js.map +0 -1
  72. package/lib/packlets/collections/common.d.ts.map +0 -1
  73. package/lib/packlets/collections/common.js.map +0 -1
  74. package/lib/packlets/collections/convertingCollector.d.ts.map +0 -1
  75. package/lib/packlets/collections/convertingCollector.js.map +0 -1
  76. package/lib/packlets/collections/convertingCollectorValidator.d.ts.map +0 -1
  77. package/lib/packlets/collections/convertingCollectorValidator.js.map +0 -1
  78. package/lib/packlets/collections/index.d.ts.map +0 -1
  79. package/lib/packlets/collections/index.js.map +0 -1
  80. package/lib/packlets/collections/keyValueConverters.d.ts.map +0 -1
  81. package/lib/packlets/collections/keyValueConverters.js.map +0 -1
  82. package/lib/packlets/collections/readonlyResultMap.d.ts.map +0 -1
  83. package/lib/packlets/collections/readonlyResultMap.js.map +0 -1
  84. package/lib/packlets/collections/resultMap.d.ts.map +0 -1
  85. package/lib/packlets/collections/resultMap.js.map +0 -1
  86. package/lib/packlets/collections/resultMapValidator.d.ts.map +0 -1
  87. package/lib/packlets/collections/resultMapValidator.js.map +0 -1
  88. package/lib/packlets/collections/utils.d.ts.map +0 -1
  89. package/lib/packlets/collections/utils.js.map +0 -1
  90. package/lib/packlets/collections/validatingCollector.d.ts.map +0 -1
  91. package/lib/packlets/collections/validatingCollector.js.map +0 -1
  92. package/lib/packlets/collections/validatingConvertingCollector.d.ts.map +0 -1
  93. package/lib/packlets/collections/validatingConvertingCollector.js.map +0 -1
  94. package/lib/packlets/collections/validatingResultMap.d.ts.map +0 -1
  95. package/lib/packlets/collections/validatingResultMap.js.map +0 -1
  96. package/lib/packlets/conversion/baseConverter.d.ts.map +0 -1
  97. package/lib/packlets/conversion/baseConverter.js.map +0 -1
  98. package/lib/packlets/conversion/converter.d.ts.map +0 -1
  99. package/lib/packlets/conversion/converter.js.map +0 -1
  100. package/lib/packlets/conversion/converters.d.ts.map +0 -1
  101. package/lib/packlets/conversion/converters.js.map +0 -1
  102. package/lib/packlets/conversion/defaultingConverter.d.ts.map +0 -1
  103. package/lib/packlets/conversion/defaultingConverter.js.map +0 -1
  104. package/lib/packlets/conversion/index.d.ts.map +0 -1
  105. package/lib/packlets/conversion/index.js.map +0 -1
  106. package/lib/packlets/conversion/objectConverter.d.ts.map +0 -1
  107. package/lib/packlets/conversion/objectConverter.js.map +0 -1
  108. package/lib/packlets/conversion/stringConverter.d.ts.map +0 -1
  109. package/lib/packlets/conversion/stringConverter.js.map +0 -1
  110. package/lib/packlets/file-tree/directoryItem.d.ts +0 -47
  111. package/lib/packlets/file-tree/directoryItem.d.ts.map +0 -1
  112. package/lib/packlets/file-tree/directoryItem.js +0 -71
  113. package/lib/packlets/file-tree/directoryItem.js.map +0 -1
  114. package/lib/packlets/file-tree/fileItem.d.ts +0 -64
  115. package/lib/packlets/file-tree/fileItem.d.ts.map +0 -1
  116. package/lib/packlets/file-tree/fileItem.js +0 -93
  117. package/lib/packlets/file-tree/fileItem.js.map +0 -1
  118. package/lib/packlets/file-tree/fileTree.d.ts +0 -84
  119. package/lib/packlets/file-tree/fileTree.d.ts.map +0 -1
  120. package/lib/packlets/file-tree/fileTree.js +0 -135
  121. package/lib/packlets/file-tree/fileTree.js.map +0 -1
  122. package/lib/packlets/file-tree/fileTreeAccessors.d.ts +0 -134
  123. package/lib/packlets/file-tree/fileTreeAccessors.d.ts.map +0 -1
  124. package/lib/packlets/file-tree/fileTreeAccessors.js +0 -24
  125. package/lib/packlets/file-tree/fileTreeAccessors.js.map +0 -1
  126. package/lib/packlets/file-tree/fsTree.d.ts +0 -45
  127. package/lib/packlets/file-tree/fsTree.d.ts.map +0 -1
  128. package/lib/packlets/file-tree/fsTree.js +0 -116
  129. package/lib/packlets/file-tree/fsTree.js.map +0 -1
  130. package/lib/packlets/file-tree/in-memory/inMemoryTree.d.ts +0 -67
  131. package/lib/packlets/file-tree/in-memory/inMemoryTree.d.ts.map +0 -1
  132. package/lib/packlets/file-tree/in-memory/inMemoryTree.js +0 -150
  133. package/lib/packlets/file-tree/in-memory/inMemoryTree.js.map +0 -1
  134. package/lib/packlets/file-tree/in-memory/index.d.ts +0 -2
  135. package/lib/packlets/file-tree/in-memory/index.d.ts.map +0 -1
  136. package/lib/packlets/file-tree/in-memory/index.js.map +0 -1
  137. package/lib/packlets/file-tree/in-memory/treeBuilder.d.ts +0 -106
  138. package/lib/packlets/file-tree/in-memory/treeBuilder.d.ts.map +0 -1
  139. package/lib/packlets/file-tree/in-memory/treeBuilder.js +0 -170
  140. package/lib/packlets/file-tree/in-memory/treeBuilder.js.map +0 -1
  141. package/lib/packlets/file-tree/index.d.ts +0 -8
  142. package/lib/packlets/file-tree/index.d.ts.map +0 -1
  143. package/lib/packlets/file-tree/index.js +0 -46
  144. package/lib/packlets/file-tree/index.js.map +0 -1
  145. package/lib/packlets/hash/crcNormalizer.d.ts.map +0 -1
  146. package/lib/packlets/hash/crcNormalizer.js.map +0 -1
  147. package/lib/packlets/hash/hashingNormalizer.d.ts.map +0 -1
  148. package/lib/packlets/hash/hashingNormalizer.js.map +0 -1
  149. package/lib/packlets/hash/index.d.ts.map +0 -1
  150. package/lib/packlets/hash/index.js.map +0 -1
  151. package/lib/packlets/validation/array.d.ts.map +0 -1
  152. package/lib/packlets/validation/array.js.map +0 -1
  153. package/lib/packlets/validation/boolean.d.ts.map +0 -1
  154. package/lib/packlets/validation/boolean.js.map +0 -1
  155. package/lib/packlets/validation/classes.d.ts.map +0 -1
  156. package/lib/packlets/validation/classes.js.map +0 -1
  157. package/lib/packlets/validation/common.d.ts.map +0 -1
  158. package/lib/packlets/validation/common.js.map +0 -1
  159. package/lib/packlets/validation/field.d.ts.map +0 -1
  160. package/lib/packlets/validation/field.js.map +0 -1
  161. package/lib/packlets/validation/genericValidator.d.ts.map +0 -1
  162. package/lib/packlets/validation/genericValidator.js.map +0 -1
  163. package/lib/packlets/validation/index.d.ts.map +0 -1
  164. package/lib/packlets/validation/index.js.map +0 -1
  165. package/lib/packlets/validation/number.d.ts.map +0 -1
  166. package/lib/packlets/validation/number.js.map +0 -1
  167. package/lib/packlets/validation/object.d.ts.map +0 -1
  168. package/lib/packlets/validation/object.js.map +0 -1
  169. package/lib/packlets/validation/oneOf.d.ts.map +0 -1
  170. package/lib/packlets/validation/oneOf.js.map +0 -1
  171. package/lib/packlets/validation/string.d.ts.map +0 -1
  172. package/lib/packlets/validation/string.js.map +0 -1
  173. package/lib/packlets/validation/traits.d.ts.map +0 -1
  174. package/lib/packlets/validation/traits.js.map +0 -1
  175. package/lib/packlets/validation/typeGuard.d.ts.map +0 -1
  176. package/lib/packlets/validation/typeGuard.js.map +0 -1
  177. package/lib/packlets/validation/validator.d.ts.map +0 -1
  178. package/lib/packlets/validation/validator.js.map +0 -1
  179. package/lib/packlets/validation/validatorBase.d.ts.map +0 -1
  180. package/lib/packlets/validation/validatorBase.js.map +0 -1
  181. package/lib/packlets/validation/validators.d.ts.map +0 -1
  182. package/lib/packlets/validation/validators.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"objectConverter.js","sourceRoot":"","sources":["../../../src/packlets/conversion/objectConverter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAyD;AAEzD,mDAAgD;AAEhD,6CAAoD;AAsCpD;;;;;;;;;GASG;AACH,MAAa,eAAiC,SAAQ,6BAAoB;IA+BxE;;;OAGG;IACH,YAAmB,MAA8B,EAAE,GAA6C;QAC9F,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;QAE7F,KAAK,CAAC,CAAC,IAAa,EAAE,MAAM,EAAE,OAAY,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAEzG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED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AAM,CAAC,KAAK,CAAC;gBAChC,CAAC;qBAAM,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;oBAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YAC5B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;oBACvB,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAA,cAAO,EAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,EAAE,CAAC;wBACrF,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,wCAAwC,CAAC,CAAC;oBAC9D,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC;YACxB,CAAC,CAAC,IAAA,cAAO,EAAC,SAAS,CAAC;YACpB,CAAC,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrG,CAAC;CACF;AAxLD,0CAwLC","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 { fail, isKeyOf, Result, succeed } from '../base';\nimport { Validator } from '../validation';\nimport { BaseConverter } from './baseConverter';\nimport { Converter } from './converter';\nimport { field, optionalField } from './converters';\n\n/**\n * Options for an {@link Conversion.ObjectConverter | ObjectConverter}.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ObjectConverterOptions<T> {\n /**\n * If present, lists optional fields. Missing non-optional fields cause an error.\n */\n optionalFields?: (keyof T)[];\n /**\n * If true, unrecognized fields yield an error. If false or undefined (default),\n * unrecognized fields are ignored.\n */\n strict?: boolean;\n /**\n * Optional description to be included in error messages.\n */\n description?: string;\n\n /**\n * Optional modifier to apply to the converter.\n */\n modifier?: 'partial' | 'required';\n}\n\n/**\n * Per-property converters or validators for each of the properties in type T.\n * @remarks\n * Used to construct a {@link Conversion.ObjectConverter | ObjectConverter}\n * @public\n */\nexport type FieldConverters<T, TC = unknown> = {\n [key in keyof T]: Converter<T[key], TC | unknown> | Validator<T[key], TC>;\n};\n\n/**\n * A {@link Converter | Converter} which converts an object of type `<T>` without changing shape, given\n * a {@link Conversion.FieldConverters | FieldConverters<T>} for the fields in the object.\n * @remarks\n * By default, if all of the required fields exist and can be converted, returns a new object with\n * the converted values under the original key names. If any required fields do not exist or cannot\n * be converted, the entire conversion fails. See {@link Conversion.ObjectConverterOptions | ObjectConverterOptions}\n * for other conversion options.\n * @public\n */\nexport class ObjectConverter<T, TC = unknown> extends BaseConverter<T, TC> {\n /**\n * Fields converted by this {@link Conversion.ObjectConverter | ObjectConverter}.\n */\n public readonly fields: FieldConverters<T, TC>;\n /**\n * Options used to initialize this {@link Conversion.ObjectConverter | ObjectConverter}.\n */\n public readonly options: ObjectConverterOptions<T>;\n\n /**\n * Constructs a new {@link Conversion.ObjectConverter | ObjectConverter<T, TC>} using options\n * supplied in a {@link Conversion.ObjectConverterOptions | ObjectConverterOptions<T>}.\n * @param fields - A {@link Conversion.FieldConverters | FieldConverters<T>} containing\n * a {@link Converter} for each field\n * @param options - An optional @see ObjectConverterOptions to configure the conversion\n * {@label WITH_OPTIONS}\n */\n public constructor(fields: FieldConverters<T, TC>, options?: ObjectConverterOptions<T>);\n\n /**\n * Constructs a new {@link Conversion.ObjectConverter | ObjectConverter<T, TC>} with optional\n * properties specified as an array of `keyof T`.\n * @param fields - A {@link Conversion.FieldConverters | FieldConverters<T>} containing\n * a {@link Converter} for each field.\n * @param optional - An array of `keyof T` listing fields that are not required.\n * {@label WITH_KEYS}\n * @deprecated Use {@link Conversion.Converter.optional | .optional()} on the individual\n * fields, or pass {@link Conversion.ObjectConverterOptions | ObjectConverterOptions<T>} to the constructor.\n */\n public constructor(fields: FieldConverters<T, TC>, optional?: (keyof T)[]);\n /**\n * Concrete implementation of {@link Converters.(ObjectConverter:constructor)}\n * @internal\n */\n public constructor(fields: FieldConverters<T, TC>, opt?: ObjectConverterOptions<T> | (keyof T)[]) {\n const options = Array.isArray(opt) ? { optionalFields: opt } : opt ?? { optionalFields: [] };\n\n super((from: unknown, __self, context?: TC) => ObjectConverter._convert(from, context, fields, options));\n\n this.fields = fields;\n this.options = options;\n }\n\n /**\n * Converts the supplied object using the {@link Conversion.ObjectConverter | ObjectConverter}\n * with all fields optional.\n * @param from - The object to be converted.\n * @param context - An optional context object passed to the field converters.\n * @returns A {@link Result} containing the converted object or an error message.\n */\n public convertPartial(from: unknown, context?: TC): Result<Partial<T>> {\n const options: ObjectConverterOptions<T> = { ...this.options, modifier: 'partial' };\n return ObjectConverter._convert(from, context, this.fields, options);\n }\n\n /**\n * Converts the supplied object using the {@link Conversion.ObjectConverter | ObjectConverter}\n * with all fields required.\n * @param from - The object to be converted.\n * @param context - An optional context object passed to the field converters.\n * @returns A {@link Result} containing the converted object or an error message.\n */\n public convertRequired(from: unknown, context?: TC): Result<Required<T>> {\n const options: ObjectConverterOptions<T> = { ...this.options, modifier: 'required' };\n return ObjectConverter._convert(from, context, this.fields, options) as Result<Required<T>>;\n }\n\n /**\n * Creates a new {@link Conversion.ObjectConverter | ObjectConverter} derived from this one but with\n * all properties optional.\n * @returns A new {@link Conversion.ObjectConverter | ObjectConverter} with the additional optional source properties.\n * {@label WITHOUT_OPTIONS}\n */\n public partial(): ObjectConverter<Partial<T>, TC>;\n\n /**\n * Creates a new {@link Conversion.ObjectConverter | ObjectConverter} derived from this one but with\n * new optional properties as specified by a supplied {@link Conversion.ObjectConverterOptions | ObjectConverterOptions<T>}.\n * @param options - The {@link Conversion.ObjectConverterOptions | options} to be applied to the new\n * converter.\n * @returns A new {@link Conversion.ObjectConverter | ObjectConverter} with the additional optional source properties.\n * {@label WITH_OPTIONS}\n * @deprecated Pass just the keys to be made optional.\n */\n public partial(options: ObjectConverterOptions<T>): ObjectConverter<Partial<T>, TC>;\n\n /**\n * Creates a new {@link Conversion.ObjectConverter | ObjectConverter} derived from this one but with\n * new optional properties as specified by a supplied array of `keyof T`.\n * @param optional - The keys of the source object properties to be made optional.\n * @returns A new {@link Conversion.ObjectConverter | ObjectConverter} with the additional optional source\n * properties.\n * {@label WITH_KEYS}\n */\n public partial(optional: (keyof T)[]): ObjectConverter<Partial<T>, TC>;\n\n /**\n * Concrete implementation of\n * {@link Conversion.ObjectConverter.(partial:1) | ObjectConverter.partial(ObjectConverterOptions)} and\n * {@link Conversion.ObjectConverter.(partial:2) | ObjectConverter.partial((keyof T))[]}.\n * @internal\n */\n public partial(opt?: ObjectConverterOptions<T> | (keyof T)[]): ObjectConverter<Partial<T>, TC> {\n const options: ObjectConverterOptions<Partial<T>> =\n opt === undefined\n ? { ...this.options, modifier: 'partial' }\n : Array.isArray(opt)\n ? { ...this.options, optionalFields: [...opt] }\n : (opt as ObjectConverterOptions<Partial<T>>);\n return new ObjectConverter<Partial<T>, TC>(this.fields as FieldConverters<Partial<T>, TC>, options)._with(\n this._traits()\n );\n }\n\n /**\n * Creates a new {@link Conversion.ObjectConverter | ObjectConverter} derived from this one but with\n * new optional properties as specified by a supplied array of `keyof T`.\n * @param addOptionalProperties - The keys to be made optional.\n * @returns A new {@link Conversion.ObjectConverter | ObjectConverter} with the additional optional source\n * properties.\n */\n public addPartial(addOptionalProperties: (keyof T)[]): ObjectConverter<Partial<T>, TC> {\n /* c8 ignore next 1 - coverage having a bad day */\n const myOptional = this.options.optionalFields ?? [];\n const optional = [...myOptional, ...addOptionalProperties];\n return this.partial(optional)._with(this._traits());\n }\n\n /**\n * Creates a new {@link Conversion.ObjectConverter | ObjectConverter} derived from this one but with\n * all properties required.\n * @returns A new {@link Conversion.ObjectConverter | ObjectConverter} with the additional required source properties.\n */\n public required(): ObjectConverter<Required<T>, TC> {\n const options: ObjectConverterOptions<Required<T>> = { ...this.options, modifier: 'required' };\n return new ObjectConverter<Required<T>, TC>(\n this.fields as FieldConverters<Required<T>, TC>,\n options\n )._with(this._traits());\n }\n\n private static _convert<T, TC>(\n from: unknown,\n context: TC | undefined,\n fields: FieldConverters<T, TC>,\n options: ObjectConverterOptions<T>\n ): Result<T> {\n // eslint bug thinks key is used before defined\n // eslint-disable-next-line no-use-before-define\n const converted = {} as { [key in keyof T]: T[key] };\n const errors: string[] = [];\n for (const key in fields) {\n if (fields[key]) {\n const isOptional =\n options.modifier === 'partial' ||\n (options.modifier !== 'required' &&\n (fields[key].isOptional === true || options.optionalFields?.includes(key) === true));\n const result = isOptional\n ? optionalField(key, fields[key]).convert(from, context)\n : field(key, fields[key]).convert(from, context);\n if (result.isSuccess() && result.value !== undefined) {\n converted[key] = result.value;\n } else if (result.isFailure()) {\n errors.push(result.message);\n }\n }\n }\n\n if (options.strict === true) {\n if (typeof from === 'object' && !Array.isArray(from)) {\n for (const key in from) {\n if (from.hasOwnProperty(key) && (!isKeyOf(key, fields) || fields[key] === undefined)) {\n errors.push(`${key}: unexpected property in source object`);\n }\n }\n } else {\n errors.push('source is not an object');\n }\n }\n return errors.length === 0\n ? succeed(converted)\n : fail(options.description ? `${options.description}: ${errors.join('\\n')}` : errors.join('\\n'));\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stringConverter.d.ts","sourceRoot":"","sources":["../../../src/packlets/conversion/stringConverter.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;GAIG;AAGH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,qBAAa,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,CAAE,SAAQ,aAAa,CAAC,CAAC,EAAE,EAAE,CAAC;IAChG;;;;;OAKG;gBAED,cAAc,CAAC,EAAE,EAAE,EACnB,MAAM,CAAC,EAAE,eAAe,EACxB,SAAS,GAAE,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,KAAK,MAAM,CAAC,CAAC,CAA4B;IAK1G;;OAE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C,CAAC;QACL,CAAC;IACH,CAAC;CACF;AArHD,0CAqHC","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 { Result, fail, succeed } from '../base';\nimport { BaseConverter } from './baseConverter';\nimport { Converter, ConverterTraits } from './converter';\n\n/**\n * Options for {@link Conversion.StringConverter | StringConverter}\n * matching method\n * @public\n */\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface StringMatchOptions {\n /**\n * An optional message to be displayed if a non-matching string\n * is encountered.\n */\n message?: string;\n}\n\n/**\n * The {@link Conversion.StringConverter | StringConverter} class extends\n * {@link Conversion.BaseConverter | BaseConverter} to provide string-specific\n * helper methods.\n * @public\n */\nexport class StringConverter<T extends string = string, TC = unknown> extends BaseConverter<T, TC> {\n /**\n * Construct a new {@link Conversion.StringConverter | StringConverter}.\n * @param defaultContext - Optional context used by the conversion.\n * @param traits - Optional traits to be applied to the conversion.\n * @param converter - Optional conversion function to be used for the conversion.\n */\n public constructor(\n defaultContext?: TC,\n traits?: ConverterTraits,\n converter: (from: unknown, self: Converter<T, TC>, context?: TC) => Result<T> = StringConverter._convert\n ) {\n super(converter, defaultContext, traits);\n }\n\n /**\n * @internal\n */\n protected static _convert<T extends string>(from: unknown): Result<T> {\n return typeof from === 'string' ? succeed(from as T) : fail(`Not a string: ${JSON.stringify(from)}`);\n }\n\n /**\n * @internal\n */\n protected static _wrap<T extends string, TC>(\n wrapped: StringConverter<T, TC>,\n converter: (from: T) => Result<T>,\n traits?: ConverterTraits\n ): StringConverter<T, TC> {\n return new StringConverter<T, TC>(undefined, undefined, (from: unknown) => {\n return wrapped.convert(from).onSuccess(converter);\n })._with(wrapped._traits(traits));\n }\n\n /**\n * Returns a {@link Conversion.StringConverter | StringConverter} which constrains the result to match\n * a supplied string.\n * @param match - The string to be matched\n * @param options - Optional {@link Conversion.StringMatchOptions} for this conversion.\n * @returns {@link Success} with a matching string or {@link Failure} with an informative\n * error if the string does not match.\n * {@label WITH_STRING}\n */\n public matching(match: string, options?: Partial<StringMatchOptions>): StringConverter<T, TC>;\n\n /**\n * Returns a {@link Conversion.StringConverter | StringConverter} which constrains the result to match\n * one of a supplied array of strings.\n * @param match - The array of allowed strings.\n * @param options - Optional {@link Conversion.StringMatchOptions} for this conversion.\n * @returns {@link Success} with a matching string or {@link Failure} with an informative\n * error if the string does not match.\n * {@label WITH_ARRAY}\n */\n public matching(match: string[], options?: Partial<StringMatchOptions>): StringConverter<T, TC>;\n\n /**\n * Returns a {@link Conversion.StringConverter | StringConverter} which constrains the result to match\n * one of a supplied `Set` of strings.\n * @param match - The `Set` of allowed strings.\n * @param options - Optional {@link Conversion.StringMatchOptions} for this conversion.\n * @returns {@link Success} with a matching string or {@link Failure} with an informative\n * error if the string does not match.\n * {@label WITH_SET}\n */\n public matching(match: Set<T>, options?: Partial<StringMatchOptions>): StringConverter<T, TC>;\n\n /**\n * Returns a {@link Conversion.StringConverter | StringConverter} which constrains the result to match\n * a supplied regular expression.\n * @param match - The regular expression to be used as a constraint.\n * @param options - Optional {@link Conversion.StringMatchOptions} for this conversion\n * @returns {@link Success} with a matching string or {@link Failure} with an informative\n * error if the string does not match.\n * {@label WITH_REGEXP}\n */\n public matching(match: RegExp, options?: Partial<StringMatchOptions>): StringConverter<T, TC>;\n\n /**\n * Concrete implementation of {@link Conversion.StringConverter.matching#string | StringConverter.matching(string)},\n * {@link Conversion.StringConverter.matching#array | StringConverter.matching(string[])},\n * {@link Conversion.StringConverter.matching#set | StringConverter.matching(Set<string>)}, and\n * {@link Conversion.StringConverter.matching#regexp | StringConverter.matching(RegExp)}.\n * @internal\n */\n public matching(\n match: string | string[] | Set<T> | RegExp,\n options?: Partial<StringMatchOptions>\n ): StringConverter<T, TC> {\n const message = options?.message;\n if (typeof match === 'string') {\n return StringConverter._wrap<T, TC>(this, (from: T) => {\n return match === from\n ? succeed(from as T)\n : fail(message ? `\"${from}\": ${message}` : `\"${from}\": does not match \"${match}\"`);\n });\n } else if (match instanceof RegExp) {\n return StringConverter._wrap<T, TC>(this, (from: T) => {\n return match.test(from)\n ? succeed(from as T)\n : fail(message ? `\"${from}\": ${message}` : `\"${from}\": does not match \"${match}\"`);\n });\n } else if (match instanceof Set) {\n return StringConverter._wrap<T, TC>(this, (from: T) => {\n return match.has(from)\n ? succeed(from as T)\n : fail(message ? `\"${from}\": ${message}` : `\"${from}\": not found in set`);\n });\n } else {\n return StringConverter._wrap<T, TC>(this, (from: T) => {\n return match.includes(from)\n ? succeed(from as T)\n : fail(message ? `\"${from}\": ${message}` : `\"${from}\": not found in [${match.join(',')}]`);\n });\n }\n }\n}\n"]}
@@ -1,47 +0,0 @@
1
- import { Result } from '../base';
2
- import { FileTreeItem, IFileTreeAccessors, IFileTreeDirectoryItem } from './fileTreeAccessors';
3
- /**
4
- * Class representing a directory in a file tree.
5
- * @public
6
- */
7
- export declare class DirectoryItem implements IFileTreeDirectoryItem {
8
- /**
9
- * {@inheritdoc FileTree.IFileTreeDirectoryItem."type"}
10
- */
11
- readonly type: 'directory';
12
- /**
13
- * {@inheritdoc FileTree.IFileTreeDirectoryItem.absolutePath}
14
- */
15
- readonly absolutePath: string;
16
- /**
17
- * {@inheritdoc FileTree.IFileTreeDirectoryItem.name}
18
- */
19
- get name(): string;
20
- /**
21
- * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.
22
- * @public
23
- */
24
- protected readonly _hal: IFileTreeAccessors;
25
- /**
26
- * Protected constructor for derived classes.
27
- * @param path - Relative path of the directory.
28
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
29
- * file system operations.
30
- * @public
31
- */
32
- protected constructor(path: string, hal: IFileTreeAccessors);
33
- /**
34
- * Creates a new DirectoryItem instance.
35
- * @param path - Relative path of the directory.
36
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
37
- * file system operations.
38
- * @returns A {@link Result | result} containing the new DirectoryItem instance if successful,
39
- * or a failure if an error occurs.
40
- */
41
- static create(path: string, hal: IFileTreeAccessors): Result<DirectoryItem>;
42
- /**
43
- * {@inheritdoc FileTree.IFileTreeDirectoryItem.getChildren}
44
- */
45
- getChildren(): Result<ReadonlyArray<FileTreeItem>>;
46
- }
47
- //# sourceMappingURL=directoryItem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directoryItem.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryItem.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE/F;;;GAGG;AACH,qBAAa,aAAc,YAAW,sBAAsB;IAC1D;;OAEG;IACH,SAAgB,IAAI,EAAE,WAAW,CAAe;IAEhD;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAE5C;;;;;;OAMG;IACH,SAAS,aAAa,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB;IAK3D;;;;;;;OAOG;WACW,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAAC,aAAa,CAAC;IAIlF;;OAEG;IACI,WAAW,IAAI,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;CAG1D"}
@@ -1,71 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025 Erik Fortune
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6
- * of this software and associated documentation files (the "Software"), to deal
7
- * in the Software without restriction, including without limitation the rights
8
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- * copies of the Software, and to permit persons to whom the Software is
10
- * furnished to do so, subject to the following conditions:
11
- *
12
- * The above copyright notice and this permission notice shall be included in all
13
- * copies or substantial portions of the Software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- * SOFTWARE.
22
- */
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.DirectoryItem = void 0;
25
- const base_1 = require("../base");
26
- /**
27
- * Class representing a directory in a file tree.
28
- * @public
29
- */
30
- class DirectoryItem {
31
- /**
32
- * {@inheritdoc FileTree.IFileTreeDirectoryItem.name}
33
- */
34
- get name() {
35
- return this._hal.getBaseName(this.absolutePath);
36
- }
37
- /**
38
- * Protected constructor for derived classes.
39
- * @param path - Relative path of the directory.
40
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
41
- * file system operations.
42
- * @public
43
- */
44
- constructor(path, hal) {
45
- /**
46
- * {@inheritdoc FileTree.IFileTreeDirectoryItem."type"}
47
- */
48
- this.type = 'directory';
49
- this._hal = hal;
50
- this.absolutePath = hal.resolveAbsolutePath(path);
51
- }
52
- /**
53
- * Creates a new DirectoryItem instance.
54
- * @param path - Relative path of the directory.
55
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
56
- * file system operations.
57
- * @returns A {@link Result | result} containing the new DirectoryItem instance if successful,
58
- * or a failure if an error occurs.
59
- */
60
- static create(path, hal) {
61
- return (0, base_1.captureResult)(() => new DirectoryItem(path, hal));
62
- }
63
- /**
64
- * {@inheritdoc FileTree.IFileTreeDirectoryItem.getChildren}
65
- */
66
- getChildren() {
67
- return this._hal.getChildren(this.absolutePath);
68
- }
69
- }
70
- exports.DirectoryItem = DirectoryItem;
71
- //# sourceMappingURL=directoryItem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directoryItem.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/directoryItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAgD;AAGhD;;;GAGG;AACH,MAAa,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,GAAuB;QA9B3D;;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,CAAC,IAAY,EAAE,GAAuB;QACxD,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACI,WAAW;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;CACF;AAtDD,sCAsDC","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 } from '../base';\nimport { FileTreeItem, IFileTreeAccessors, IFileTreeDirectoryItem } from './fileTreeAccessors';\n\n/**\n * Class representing a directory in a file tree.\n * @public\n */\nexport class DirectoryItem implements IFileTreeDirectoryItem {\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;\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) {\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 A {@link Result | result} containing the new DirectoryItem instance if successful,\n * or a failure if an error occurs.\n */\n public static create(path: string, hal: IFileTreeAccessors): Result<DirectoryItem> {\n return captureResult(() => new DirectoryItem(path, hal));\n }\n\n /**\n * {@inheritdoc FileTree.IFileTreeDirectoryItem.getChildren}\n */\n public getChildren(): Result<ReadonlyArray<FileTreeItem>> {\n return this._hal.getChildren(this.absolutePath);\n }\n}\n"]}
@@ -1,64 +0,0 @@
1
- import { Result } from '../base';
2
- import { Converter } from '../conversion';
3
- import { Validator } from '../validation';
4
- import { IFileTreeAccessors, IFileTreeFileItem } from './fileTreeAccessors';
5
- /**
6
- * Class representing a file in a file tree.
7
- * @public
8
- */
9
- export declare class FileItem implements IFileTreeFileItem {
10
- /**
11
- * {@inheritdoc FileTree.IFileTreeFileItem."type"}
12
- */
13
- readonly type: 'file';
14
- /**
15
- * {@inheritdoc FileTree.IFileTreeFileItem.absolutePath}
16
- */
17
- readonly absolutePath: string;
18
- /**
19
- * {@inheritdoc FileTree.IFileTreeFileItem.name}
20
- */
21
- get name(): string;
22
- /**
23
- * {@inheritdoc FileTree.IFileTreeFileItem.baseName}
24
- */
25
- get baseName(): string;
26
- /**
27
- * {@inheritdoc FileTree.IFileTreeFileItem.extension}
28
- */
29
- get extension(): string;
30
- /**
31
- * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.
32
- * @public
33
- */
34
- protected readonly _hal: IFileTreeAccessors;
35
- /**
36
- * Protected constructor for derived classes.
37
- * @param path - Relative path of the file.
38
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
39
- * file system operations.
40
- * @public
41
- */
42
- protected constructor(path: string, hal: IFileTreeAccessors);
43
- /**
44
- * Creates a new {@link FileTree.FileItem | FileItem} instance.
45
- * @param path - Relative path of the file.
46
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
47
- * file system operations.
48
- * @public
49
- */
50
- static create(path: string, hal: IFileTreeAccessors): Result<FileItem>;
51
- /**
52
- * {@inheritdoc FileTree.IFileTreeFileItem.(getContents:1)}
53
- */
54
- getContents(): Result<unknown>;
55
- /**
56
- * {@inheritdoc FileTree.IFileTreeFileItem.(getContents:2)}
57
- */
58
- getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;
59
- /**
60
- * {@inheritdoc FileTree.IFileTreeFileItem.getRawContents}
61
- */
62
- getRawContents(): Result<string>;
63
- }
64
- //# sourceMappingURL=fileItem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileItem.d.ts","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileItem.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAW,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;GAGG;AACH,qBAAa,QAAS,YAAW,iBAAiB;IAChD;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAU;IAEtC;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAE5C;;;;;;OAMG;IACH,SAAS,aAAa,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB;IAK3D;;;;;;OAMG;WACW,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAAC,QAAQ,CAAC;IAI7E;;OAEG;IACI,WAAW,IAAI,MAAM,CAAC,OAAO,CAAC;IACrC;;OAEG;IACI,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAaxE;;OAEG;IACI,cAAc,IAAI,MAAM,CAAC,MAAM,CAAC;CAGxC"}
@@ -1,93 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2025 Erik Fortune
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6
- * of this software and associated documentation files (the "Software"), to deal
7
- * in the Software without restriction, including without limitation the rights
8
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- * copies of the Software, and to permit persons to whom the Software is
10
- * furnished to do so, subject to the following conditions:
11
- *
12
- * The above copyright notice and this permission notice shall be included in all
13
- * copies or substantial portions of the Software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- * SOFTWARE.
22
- */
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.FileItem = void 0;
25
- const base_1 = require("../base");
26
- /**
27
- * Class representing a file in a file tree.
28
- * @public
29
- */
30
- class FileItem {
31
- /**
32
- * {@inheritdoc FileTree.IFileTreeFileItem.name}
33
- */
34
- get name() {
35
- return this._hal.getBaseName(this.absolutePath);
36
- }
37
- /**
38
- * {@inheritdoc FileTree.IFileTreeFileItem.baseName}
39
- */
40
- get baseName() {
41
- return this._hal.getBaseName(this.absolutePath, this.extension);
42
- }
43
- /**
44
- * {@inheritdoc FileTree.IFileTreeFileItem.extension}
45
- */
46
- get extension() {
47
- return this._hal.getExtension(this.absolutePath);
48
- }
49
- /**
50
- * Protected constructor for derived classes.
51
- * @param path - Relative path of the file.
52
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
53
- * file system operations.
54
- * @public
55
- */
56
- constructor(path, hal) {
57
- /**
58
- * {@inheritdoc FileTree.IFileTreeFileItem."type"}
59
- */
60
- this.type = 'file';
61
- this._hal = hal;
62
- this.absolutePath = hal.resolveAbsolutePath(path);
63
- }
64
- /**
65
- * Creates a new {@link FileTree.FileItem | FileItem} instance.
66
- * @param path - Relative path of the file.
67
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
68
- * file system operations.
69
- * @public
70
- */
71
- static create(path, hal) {
72
- return (0, base_1.captureResult)(() => new FileItem(path, hal));
73
- }
74
- getContents(converter) {
75
- return this._hal
76
- .getFileContents(this.absolutePath)
77
- .onSuccess((body) => (0, base_1.captureResult)(() => JSON.parse(body)).onFailure(() => (0, base_1.succeed)(body)))
78
- .onSuccess((parsed) => {
79
- if (converter !== undefined) {
80
- return converter.convert(parsed);
81
- }
82
- return (0, base_1.succeed)(parsed);
83
- });
84
- }
85
- /**
86
- * {@inheritdoc FileTree.IFileTreeFileItem.getRawContents}
87
- */
88
- getRawContents() {
89
- return this._hal.getFileContents(this.absolutePath);
90
- }
91
- }
92
- exports.FileItem = FileItem;
93
- //# sourceMappingURL=fileItem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileItem.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,kCAAyD;AAKzD;;;GAGG;AACH,MAAa,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;IACnD,CAAC;IAQD;;;;;;OAMG;IACH,YAAsB,IAAY,EAAE,GAAuB;QA5C3D;;WAEG;QACa,SAAI,GAAW,MAAM,CAAC;QA0CpC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,GAAuB;QACxD,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IAUM,WAAW,CAAI,SAAuC;QAC3D,OAAO,IAAI,CAAC,IAAI;aACb,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC;aAClC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC,CAAC;aACzF,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;YACpB,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC5B,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;YACD,OAAO,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACtD,CAAC;CACF;AAvFD,4BAuFC","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, succeed } from '../base';\nimport { Converter } from '../conversion';\nimport { Validator } from '../validation';\nimport { IFileTreeAccessors, IFileTreeFileItem } from './fileTreeAccessors';\n\n/**\n * Class representing a file in a file tree.\n * @public\n */\nexport class FileItem implements IFileTreeFileItem {\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 * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.\n * @public\n */\n protected readonly _hal: IFileTreeAccessors;\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) {\n this._hal = hal;\n this.absolutePath = hal.resolveAbsolutePath(path);\n }\n\n /**\n * Creates a new {@link FileTree.FileItem | 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(path: string, hal: IFileTreeAccessors): Result<FileItem> {\n return captureResult(() => new FileItem(path, hal));\n }\n\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.(getContents:1)}\n */\n public getContents(): Result<unknown>;\n /**\n * {@inheritdoc FileTree.IFileTreeFileItem.(getContents:2)}\n */\n public getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;\n public getContents<T>(converter?: Validator<T> | Converter<T>): Result<T | unknown> {\n return this._hal\n .getFileContents(this.absolutePath)\n .onSuccess((body) => captureResult(() => JSON.parse(body)).onFailure(() => succeed(body)))\n .onSuccess((parsed) => {\n if (converter !== undefined) {\n return converter.convert(parsed);\n }\n return succeed(parsed);\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"]}
@@ -1,84 +0,0 @@
1
- import { Result } from '../base';
2
- import { FileTreeItem, IFileTreeAccessors, IFileTreeDirectoryItem, IFileTreeFileItem } from './fileTreeAccessors';
3
- import { IInMemoryFile } from './in-memory';
4
- /**
5
- * Represents a file tree.
6
- * @public
7
- */
8
- export declare class FileTree {
9
- /**
10
- * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.
11
- * @public
12
- */
13
- hal: IFileTreeAccessors;
14
- /**
15
- * Protected constructor for derived classes.
16
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
17
- * file system operations.
18
- * @public
19
- */
20
- protected constructor(hal: IFileTreeAccessors);
21
- /**
22
- * Creates a new {@link FileTree.FileTree | FileTree} instance with the supplied
23
- * accessors.
24
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
25
- * file system operations.
26
- */
27
- static create(hal: IFileTreeAccessors): Result<FileTree>;
28
- /**
29
- * Creates a new {@link FileTree.FileTree | FileTree} instance with accessors
30
- * for the filesystem.
31
- * @param prefix - An optional prefix to prepended to supplied relative
32
- * paths.
33
- */
34
- static forFilesystem(prefix?: string): Result<FileTree>;
35
- /**
36
- * Creates a new {@link FileTree.FileTree | FileTree} instance with accessors
37
- * for an in-memory file tree.
38
- * @param files - An array of {@link FileTree.IInMemoryFile | in-memory files} to
39
- * include in the tree.
40
- * @param prefix - An optional prefix to add to the paths of all files in the tree.
41
- */
42
- static inMemory(files: IInMemoryFile[], prefix?: string): Result<FileTree>;
43
- /**
44
- * Gets an item from the tree.
45
- * @param itemPath - The path to the item.
46
- * @returns {@link Success | Success} with the item if successful,
47
- * or {@link Failure | Failure} with an error message otherwise.
48
- */
49
- getItem(itemPath: string): Result<FileTreeItem>;
50
- /**
51
- * Gets a file item from the tree.
52
- * @param filePath - The path to the file.
53
- * @returns {@link Success | Success} with the {@link FileTree.IFileTreeFileItem | file item}
54
- * if successful, or {@link Failure | Failure} with an error message otherwise.
55
- */
56
- getFile(filePath: string): Result<IFileTreeFileItem>;
57
- /**
58
- * Gets a directory item from the tree.
59
- * @param directoryPath - The path to the directory.
60
- * @returns {@link Success | Success} with the {@link FileTree.IFileTreeDirectoryItem | directory item}
61
- * if successful, or {@link Failure | Failure} with an error message otherwise.
62
- */
63
- getDirectory(directoryPath: string): Result<IFileTreeDirectoryItem>;
64
- }
65
- /**
66
- * Helper function to create a new {@link FileTree.FileTree | FileTree} instance
67
- * with accessors for the filesystem.
68
- * @param prefix - An optional prefix to prepended to supplied relative paths.
69
- * @returns {@link Success | Success} with the new {@link FileTree.FileTree | FileTree} instance
70
- * if successful, or {@link Failure | Failure} with an error message otherwise.
71
- * @public
72
- */
73
- export declare function forFilesystem(prefix?: string): Result<FileTree>;
74
- /**
75
- * Helper function to create a new {@link FileTree.FileTree | FileTree} instance
76
- * with accessors for an in-memory file tree.
77
- * @param files - An array of {@link FileTree.IInMemoryFile | in-memory files} to include in the tree.
78
- * @param prefix - An optional prefix to add to the paths of all files in the tree.
79
- * @returns {@link Success | Success} with the new {@link FileTree.FileTree | FileTree} instance
80
- * if successful, or {@link Failure | Failure} with an error message otherwise.
81
- * @public
82
- */
83
- export declare function inMemory(files: IInMemoryFile[], prefix?: string): Result<FileTree>;
84
- //# sourceMappingURL=fileTree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileTree.d.ts","sourceRoot":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Copyright (c) 2025 Erik Fortune
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6
- * of this software and associated documentation files (the "Software"), to deal
7
- * in the Software without restriction, including without limitation the rights
8
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- * copies of the Software, and to permit persons to whom the Software is
10
- * furnished to do so, subject to the following conditions:
11
- *
12
- * The above copyright notice and this permission notice shall be included in all
13
- * copies or substantial portions of the Software.
14
- *
15
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- * SOFTWARE.
22
- */
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.FileTree = void 0;
25
- exports.forFilesystem = forFilesystem;
26
- exports.inMemory = inMemory;
27
- const base_1 = require("../base");
28
- const fsTree_1 = require("./fsTree");
29
- const in_memory_1 = require("./in-memory");
30
- /**
31
- * Represents a file tree.
32
- * @public
33
- */
34
- class FileTree {
35
- /**
36
- * Protected constructor for derived classes.
37
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
38
- * file system operations.
39
- * @public
40
- */
41
- constructor(hal) {
42
- this.hal = hal;
43
- }
44
- /**
45
- * Creates a new {@link FileTree.FileTree | FileTree} instance with the supplied
46
- * accessors.
47
- * @param hal - The {@link FileTree.IFileTreeAccessors | accessors} to use for
48
- * file system operations.
49
- */
50
- static create(hal) {
51
- return (0, base_1.captureResult)(() => new FileTree(hal));
52
- }
53
- /**
54
- * Creates a new {@link FileTree.FileTree | FileTree} instance with accessors
55
- * for the filesystem.
56
- * @param prefix - An optional prefix to prepended to supplied relative
57
- * paths.
58
- */
59
- static forFilesystem(prefix) {
60
- return (0, base_1.captureResult)(() => new FileTree(new fsTree_1.FsFileTreeAccessors(prefix)));
61
- }
62
- /**
63
- * Creates a new {@link FileTree.FileTree | FileTree} instance with accessors
64
- * for an in-memory file tree.
65
- * @param files - An array of {@link FileTree.IInMemoryFile | in-memory files} to
66
- * include in the tree.
67
- * @param prefix - An optional prefix to add to the paths of all files in the tree.
68
- */
69
- static inMemory(files, prefix) {
70
- return in_memory_1.InMemoryTreeAccessors.create(files, prefix).onSuccess((hal) => (0, base_1.captureResult)(() => new FileTree(hal)));
71
- }
72
- /**
73
- * Gets an item from the tree.
74
- * @param itemPath - The path to the item.
75
- * @returns {@link Success | Success} with the item if successful,
76
- * or {@link Failure | Failure} with an error message otherwise.
77
- */
78
- getItem(itemPath) {
79
- const absolutePath = this.hal.resolveAbsolutePath(itemPath);
80
- return this.hal.getItem(absolutePath);
81
- }
82
- /**
83
- * Gets a file item from the tree.
84
- * @param filePath - The path to the file.
85
- * @returns {@link Success | Success} with the {@link FileTree.IFileTreeFileItem | file item}
86
- * if successful, or {@link Failure | Failure} with an error message otherwise.
87
- */
88
- getFile(filePath) {
89
- return this.getItem(filePath).onSuccess((item) => {
90
- if (item.type === 'file') {
91
- return (0, base_1.succeed)(item);
92
- }
93
- return (0, base_1.fail)(`${filePath}: not a file`);
94
- });
95
- }
96
- /**
97
- * Gets a directory item from the tree.
98
- * @param directoryPath - The path to the directory.
99
- * @returns {@link Success | Success} with the {@link FileTree.IFileTreeDirectoryItem | directory item}
100
- * if successful, or {@link Failure | Failure} with an error message otherwise.
101
- */
102
- getDirectory(directoryPath) {
103
- return this.getItem(directoryPath).onSuccess((item) => {
104
- if (item.type === 'directory') {
105
- return (0, base_1.succeed)(item);
106
- }
107
- return (0, base_1.fail)(`${directoryPath}: not a directory`);
108
- });
109
- }
110
- }
111
- exports.FileTree = FileTree;
112
- /**
113
- * Helper function to create a new {@link FileTree.FileTree | FileTree} instance
114
- * with accessors for the filesystem.
115
- * @param prefix - An optional prefix to prepended to supplied relative paths.
116
- * @returns {@link Success | Success} with the new {@link FileTree.FileTree | FileTree} instance
117
- * if successful, or {@link Failure | Failure} with an error message otherwise.
118
- * @public
119
- */
120
- function forFilesystem(prefix) {
121
- return FileTree.forFilesystem(prefix);
122
- }
123
- /**
124
- * Helper function to create a new {@link FileTree.FileTree | FileTree} instance
125
- * with accessors for an in-memory file tree.
126
- * @param files - An array of {@link FileTree.IInMemoryFile | in-memory files} to include in the tree.
127
- * @param prefix - An optional prefix to add to the paths of all files in the tree.
128
- * @returns {@link Success | Success} with the new {@link FileTree.FileTree | FileTree} instance
129
- * if successful, or {@link Failure | Failure} with an error message otherwise.
130
- * @public
131
- */
132
- function inMemory(files, prefix) {
133
- return FileTree.inMemory(files, prefix);
134
- }
135
- //# sourceMappingURL=fileTree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fileTree.js","sourceRoot":"","sources":["../../../src/packlets/file-tree/fileTree.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAoHH,sCAEC;AAWD,4BAEC;AAjID,kCAA+D;AAO/D,qCAA+C;AAC/C,2CAAmE;AAEnE;;;GAGG;AACH,MAAa,QAAQ;IAOnB;;;;;OAKG;IACH,YAAsB,GAAuB;QAC3C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,GAAuB;QAC1C,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,aAAa,CAAC,MAAe;QACzC,OAAO,IAAA,oBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,C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C;CACF;AA1FD,4BA0FC;AAED;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,MAAe;IAC3C,OAAO,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,QAAQ,CAAC,KAAsB,EAAE,MAAe;IAC9D,OAAO,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC1C,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, fail, succeed } from '../base';\nimport {\n FileTreeItem,\n IFileTreeAccessors,\n IFileTreeDirectoryItem,\n IFileTreeFileItem\n} from './fileTreeAccessors';\nimport { FsFileTreeAccessors } from './fsTree';\nimport { IInMemoryFile, InMemoryTreeAccessors } from './in-memory';\n\n/**\n * Represents a file tree.\n * @public\n */\nexport class FileTree {\n /**\n * The {@link FileTree.IFileTreeAccessors | accessors} to use for file system operations.\n * @public\n */\n public hal: IFileTreeAccessors;\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) {\n this.hal = hal;\n }\n\n /**\n * Creates a new {@link FileTree.FileTree | 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(hal: IFileTreeAccessors): Result<FileTree> {\n return captureResult(() => new FileTree(hal));\n }\n\n /**\n * Creates a new {@link FileTree.FileTree | FileTree} instance with accessors\n * for the filesystem.\n * @param prefix - An optional prefix to prepended to supplied relative\n * paths.\n */\n public static forFilesystem(prefix?: string): Result<FileTree> {\n return captureResult(() => new FileTree(new FsFileTreeAccessors(prefix)));\n }\n\n /**\n * Creates a new {@link FileTree.FileTree | FileTree} instance with accessors\n * for an in-memory file tree.\n * @param files - An array of {@link FileTree.IInMemoryFile | in-memory files} to\n * include in the tree.\n * @param prefix - An optional prefix to add to the paths of all files in the tree.\n */\n public static inMemory(files: IInMemoryFile[], prefix?: string): Result<FileTree> {\n return InMemoryTreeAccessors.create(files, prefix).onSuccess((hal) =>\n captureResult(() => new FileTree(hal))\n );\n }\n\n /**\n * Gets an item from the tree.\n * @param itemPath - The path to the item.\n * @returns {@link Success | Success} with the item if successful,\n * or {@link Failure | Failure} with an error message otherwise.\n */\n public getItem(itemPath: string): Result<FileTreeItem> {\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 {@link Success | Success} with the {@link FileTree.IFileTreeFileItem | file item}\n * if successful, or {@link Failure | Failure} with an error message otherwise.\n */\n public getFile(filePath: string): Result<IFileTreeFileItem> {\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 {@link Success | Success} with the {@link FileTree.IFileTreeDirectoryItem | directory item}\n * if successful, or {@link Failure | Failure} with an error message otherwise.\n */\n public getDirectory(directoryPath: string): Result<IFileTreeDirectoryItem> {\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\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 {@link Success | Success} with the new {@link FileTree.FileTree | FileTree} instance\n * if successful, or {@link Failure | Failure} with an error message otherwise.\n * @public\n */\nexport function forFilesystem(prefix?: string): Result<FileTree> {\n return FileTree.forFilesystem(prefix);\n}\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 {@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 {@link Success | Success} with the new {@link FileTree.FileTree | FileTree} instance\n * if successful, or {@link Failure | Failure} with an error message otherwise.\n * @public\n */\nexport function inMemory(files: IInMemoryFile[], prefix?: string): Result<FileTree> {\n return FileTree.inMemory(files, prefix);\n}\n"]}