@fgv/ts-res 4.5.0-3 → 5.0.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +26 -0
- package/CHANGELOG.md +14 -0
- package/CLAUDE.md +186 -0
- package/EXAMPLE_INIT_PARAMS.md +88 -0
- package/PROGRESS_SUMMARY.md +48 -0
- package/README.md +535 -14
- package/dist/ts-res.d.ts +4223 -322
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/packlets/common/conditions.d.ts +30 -0
- package/lib/packlets/common/conditions.d.ts.map +1 -1
- package/lib/packlets/common/conditions.js.map +1 -1
- package/lib/packlets/common/convert.d.ts +22 -2
- package/lib/packlets/common/convert.d.ts.map +1 -1
- package/lib/packlets/common/convert.js +21 -1
- package/lib/packlets/common/convert.js.map +1 -1
- package/lib/packlets/common/helpers/context.d.ts +39 -0
- package/lib/packlets/common/helpers/context.d.ts.map +1 -0
- package/lib/packlets/common/helpers/context.js +108 -0
- package/lib/packlets/common/helpers/context.js.map +1 -0
- package/lib/packlets/common/helpers/index.d.ts +2 -0
- package/lib/packlets/common/helpers/index.d.ts.map +1 -1
- package/lib/packlets/common/helpers/index.js +2 -0
- package/lib/packlets/common/helpers/index.js.map +1 -1
- package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts +39 -0
- package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts.map +1 -0
- package/lib/packlets/common/helpers/qualifierDefaultValues.js +105 -0
- package/lib/packlets/common/helpers/qualifierDefaultValues.js.map +1 -0
- package/lib/packlets/common/helpers/resources.d.ts.map +1 -1
- package/lib/packlets/common/helpers/resources.js +6 -2
- package/lib/packlets/common/helpers/resources.js.map +1 -1
- package/lib/packlets/common/validate/conditions.d.ts +69 -1
- package/lib/packlets/common/validate/conditions.d.ts.map +1 -1
- package/lib/packlets/common/validate/conditions.js +126 -0
- package/lib/packlets/common/validate/conditions.js.map +1 -1
- package/lib/packlets/common/validate/regularExpressions.d.ts +20 -0
- package/lib/packlets/common/validate/regularExpressions.d.ts.map +1 -1
- package/lib/packlets/common/validate/regularExpressions.js +21 -1
- package/lib/packlets/common/validate/regularExpressions.js.map +1 -1
- package/lib/packlets/conditions/condition.d.ts +37 -0
- package/lib/packlets/conditions/condition.d.ts.map +1 -1
- package/lib/packlets/conditions/condition.js +67 -1
- package/lib/packlets/conditions/condition.js.map +1 -1
- package/lib/packlets/conditions/conditionCollector.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionCollector.js +1 -0
- package/lib/packlets/conditions/conditionCollector.js.map +1 -1
- package/lib/packlets/conditions/conditionSet.d.ts +34 -3
- package/lib/packlets/conditions/conditionSet.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionSet.js +31 -3
- package/lib/packlets/conditions/conditionSet.js.map +1 -1
- package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionSetCollector.js +3 -0
- package/lib/packlets/conditions/conditionSetCollector.js.map +1 -1
- package/lib/packlets/conditions/conditionToken.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionToken.js +2 -1
- package/lib/packlets/conditions/conditionToken.js.map +1 -1
- package/lib/packlets/conditions/convert/decls.js +1 -1
- package/lib/packlets/conditions/convert/decls.js.map +1 -1
- package/lib/packlets/config/common.d.ts +35 -0
- package/lib/packlets/config/common.d.ts.map +1 -0
- package/lib/packlets/config/common.js +96 -0
- package/lib/packlets/config/common.js.map +1 -0
- package/lib/packlets/config/convert.d.ts +14 -0
- package/lib/packlets/config/convert.d.ts.map +1 -0
- package/lib/packlets/config/convert.js +82 -0
- package/lib/packlets/config/convert.js.map +1 -0
- package/lib/packlets/config/index.d.ts +6 -0
- package/lib/packlets/config/index.d.ts.map +1 -0
- package/lib/packlets/config/index.js +67 -0
- package/lib/packlets/config/index.js.map +1 -0
- package/lib/packlets/config/json.d.ts +20 -0
- package/lib/packlets/config/json.d.ts.map +1 -0
- package/lib/packlets/config/json.js +24 -0
- package/lib/packlets/config/json.js.map +1 -0
- package/lib/packlets/config/predefined/default.d.ts +57 -0
- package/lib/packlets/config/predefined/default.d.ts.map +1 -0
- package/lib/packlets/config/predefined/default.js +141 -0
- package/lib/packlets/config/predefined/default.js.map +1 -0
- package/lib/packlets/config/predefined/extended.d.ts +25 -0
- package/lib/packlets/config/predefined/extended.d.ts.map +1 -0
- package/lib/packlets/config/predefined/extended.js +193 -0
- package/lib/packlets/config/predefined/extended.js.map +1 -0
- package/lib/packlets/config/predefined/index.d.ts +4 -0
- package/lib/packlets/config/predefined/index.d.ts.map +1 -0
- package/lib/packlets/config/predefined/index.js +62 -0
- package/lib/packlets/config/predefined/index.js.map +1 -0
- package/lib/packlets/config/systemConfiguration.d.ts +81 -0
- package/lib/packlets/config/systemConfiguration.d.ts.map +1 -0
- package/lib/packlets/config/systemConfiguration.js +172 -0
- package/lib/packlets/config/systemConfiguration.js.map +1 -0
- package/lib/packlets/context/contextDecls.d.ts +49 -0
- package/lib/packlets/context/contextDecls.d.ts.map +1 -0
- package/lib/packlets/context/contextDecls.js +24 -0
- package/lib/packlets/context/contextDecls.js.map +1 -0
- package/lib/packlets/context/contextToken.d.ts +111 -0
- package/lib/packlets/context/contextToken.d.ts.map +1 -0
- package/lib/packlets/context/contextToken.js +206 -0
- package/lib/packlets/context/contextToken.js.map +1 -0
- package/lib/packlets/context/convert/decls.d.ts +37 -0
- package/lib/packlets/context/convert/decls.d.ts.map +1 -0
- package/lib/packlets/context/convert/decls.js +94 -0
- package/lib/packlets/context/convert/decls.js.map +1 -0
- package/lib/packlets/context/convert/index.d.ts +2 -0
- package/lib/packlets/context/convert/index.d.ts.map +1 -0
- package/lib/packlets/context/convert/index.js +39 -0
- package/lib/packlets/context/convert/index.js.map +1 -0
- package/lib/packlets/context/index.d.ts +5 -0
- package/lib/packlets/context/index.d.ts.map +1 -0
- package/lib/packlets/context/index.js +65 -0
- package/lib/packlets/context/index.js.map +1 -0
- package/lib/packlets/decisions/abstractDecision.d.ts +8 -0
- package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -1
- package/lib/packlets/decisions/abstractDecision.js +9 -0
- package/lib/packlets/decisions/abstractDecision.js.map +1 -1
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -1
- package/lib/packlets/decisions/abstractDecisionCollector.js +2 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -1
- package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -1
- package/lib/packlets/decisions/concreteDecision.js +1 -0
- package/lib/packlets/decisions/concreteDecision.js.map +1 -1
- package/lib/packlets/decisions/decision.d.ts.map +1 -1
- package/lib/packlets/decisions/decision.js +4 -0
- package/lib/packlets/decisions/decision.js.map +1 -1
- package/lib/packlets/import/fsItem.d.ts.map +1 -1
- package/lib/packlets/import/fsItem.js +1 -0
- package/lib/packlets/import/fsItem.js.map +1 -1
- package/lib/packlets/import/importContext.d.ts +19 -0
- package/lib/packlets/import/importContext.d.ts.map +1 -1
- package/lib/packlets/import/importContext.js +39 -0
- package/lib/packlets/import/importContext.js.map +1 -1
- package/lib/packlets/import/importManager.d.ts +5 -5
- package/lib/packlets/import/importManager.d.ts.map +1 -1
- package/lib/packlets/import/importManager.js.map +1 -1
- package/lib/packlets/import/importers/collectionImporter.d.ts +11 -13
- package/lib/packlets/import/importers/collectionImporter.d.ts.map +1 -1
- package/lib/packlets/import/importers/collectionImporter.js +29 -20
- package/lib/packlets/import/importers/collectionImporter.js.map +1 -1
- package/lib/packlets/import/importers/fsItemImporter.d.ts +2 -2
- package/lib/packlets/import/importers/fsItemImporter.d.ts.map +1 -1
- package/lib/packlets/import/importers/fsItemImporter.js +2 -2
- package/lib/packlets/import/importers/fsItemImporter.js.map +1 -1
- package/lib/packlets/import/importers/importer.d.ts +3 -3
- package/lib/packlets/import/importers/importer.d.ts.map +1 -1
- package/lib/packlets/import/importers/importer.js.map +1 -1
- package/lib/packlets/import/importers/jsonImporter.d.ts +2 -3
- package/lib/packlets/import/importers/jsonImporter.d.ts.map +1 -1
- package/lib/packlets/import/importers/jsonImporter.js +10 -20
- package/lib/packlets/import/importers/jsonImporter.js.map +1 -1
- package/lib/packlets/import/importers/pathImporter.d.ts +2 -2
- package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -1
- package/lib/packlets/import/importers/pathImporter.js.map +1 -1
- package/lib/packlets/qualifier-types/config/convert.d.ts +44 -0
- package/lib/packlets/qualifier-types/config/convert.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/convert.js +96 -0
- package/lib/packlets/qualifier-types/config/convert.js.map +1 -0
- package/lib/packlets/qualifier-types/config/index.d.ts +4 -0
- package/lib/packlets/qualifier-types/config/index.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/index.js +64 -0
- package/lib/packlets/qualifier-types/config/index.js.map +1 -0
- package/lib/packlets/qualifier-types/config/json.d.ts +69 -0
- package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/json.js +24 -0
- package/lib/packlets/qualifier-types/config/json.js.map +1 -0
- package/lib/packlets/qualifier-types/convert.d.ts +10 -2
- package/lib/packlets/qualifier-types/convert.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/convert.js +15 -0
- package/lib/packlets/qualifier-types/convert.js.map +1 -1
- package/lib/packlets/qualifier-types/helpers.d.ts +27 -0
- package/lib/packlets/qualifier-types/helpers.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/helpers.js +118 -0
- package/lib/packlets/qualifier-types/helpers.js.map +1 -0
- package/lib/packlets/qualifier-types/index.d.ts +4 -1
- package/lib/packlets/qualifier-types/index.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/index.js +5 -1
- package/lib/packlets/qualifier-types/index.js.map +1 -1
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +19 -8
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/languageQualifierType.js +28 -9
- package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +38 -13
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/literalQualifierType.js +44 -10
- package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +107 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.js +215 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts +22 -18
- package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/qualifierType.js +9 -4
- package/lib/packlets/qualifier-types/qualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts +4 -2
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js +2 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -1
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +47 -11
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/territoryQualifierType.js +61 -17
- package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -1
- package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -1
- package/lib/packlets/qualifiers/convert/decls.js +17 -15
- package/lib/packlets/qualifiers/convert/decls.js.map +1 -1
- package/lib/packlets/qualifiers/index.d.ts +2 -0
- package/lib/packlets/qualifiers/index.d.ts.map +1 -1
- package/lib/packlets/qualifiers/index.js +2 -0
- package/lib/packlets/qualifiers/index.js.map +1 -1
- package/lib/packlets/qualifiers/qualifier.d.ts +22 -2
- package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -1
- package/lib/packlets/qualifiers/qualifier.js +26 -1
- package/lib/packlets/qualifiers/qualifier.js.map +1 -1
- package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -1
- package/lib/packlets/qualifiers/qualifierCollector.js +4 -0
- package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -1
- package/lib/packlets/qualifiers/qualifierDecl.d.ts +6 -1
- package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +1 -1
- package/lib/packlets/qualifiers/qualifierDecl.js.map +1 -1
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts +32 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js +24 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts +96 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.js +179 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.js.map +1 -0
- package/lib/packlets/resource-json/compiled/common.d.ts +14 -0
- package/lib/packlets/resource-json/compiled/common.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/common.js +24 -0
- package/lib/packlets/resource-json/compiled/common.js.map +1 -0
- package/lib/packlets/resource-json/compiled/convert.d.ts +63 -0
- package/lib/packlets/resource-json/compiled/convert.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/convert.js +167 -0
- package/lib/packlets/resource-json/compiled/convert.js.map +1 -0
- package/lib/packlets/resource-json/compiled/index.d.ts +5 -0
- package/lib/packlets/resource-json/compiled/index.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/index.js +65 -0
- package/lib/packlets/resource-json/compiled/index.js.map +1 -0
- package/lib/packlets/resource-json/compiled/json.d.ts +204 -0
- package/lib/packlets/resource-json/compiled/json.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/json.js +3 -0
- package/lib/packlets/resource-json/compiled/json.js.map +1 -0
- package/lib/packlets/resource-json/convert.d.ts +16 -0
- package/lib/packlets/resource-json/convert.d.ts.map +1 -1
- package/lib/packlets/resource-json/convert.js +41 -6
- package/lib/packlets/resource-json/convert.js.map +1 -1
- package/lib/packlets/resource-json/helpers.d.ts +82 -3
- package/lib/packlets/resource-json/helpers.d.ts.map +1 -1
- package/lib/packlets/resource-json/helpers.js +185 -2
- package/lib/packlets/resource-json/helpers.js.map +1 -1
- package/lib/packlets/resource-json/index.d.ts +2 -1
- package/lib/packlets/resource-json/index.d.ts.map +1 -1
- package/lib/packlets/resource-json/index.js +3 -1
- package/lib/packlets/resource-json/index.js.map +1 -1
- package/lib/packlets/resource-json/json.d.ts +55 -3
- package/lib/packlets/resource-json/json.d.ts.map +1 -1
- package/lib/packlets/resource-json/json.js +16 -0
- package/lib/packlets/resource-json/json.js.map +1 -1
- package/lib/packlets/resource-json/normalized.d.ts +46 -3
- package/lib/packlets/resource-json/normalized.d.ts.map +1 -1
- package/lib/packlets/resource-json/normalized.js.map +1 -1
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts +14 -10
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +1 -1
- package/lib/packlets/resource-json/resourceDeclCollection.js +18 -14
- package/lib/packlets/resource-json/resourceDeclCollection.js.map +1 -1
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts +15 -2
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +1 -1
- package/lib/packlets/resource-json/resourceDeclContainer.js.map +1 -1
- package/lib/packlets/resource-json/resourceDeclTree.d.ts +6 -2
- package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +1 -1
- package/lib/packlets/resource-json/resourceDeclTree.js +12 -3
- package/lib/packlets/resource-json/resourceDeclTree.js.map +1 -1
- package/lib/packlets/resource-types/config/convert.d.ts +8 -0
- package/lib/packlets/resource-types/config/convert.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/convert.js +36 -0
- package/lib/packlets/resource-types/config/convert.js.map +1 -0
- package/lib/packlets/resource-types/config/index.d.ts +4 -0
- package/lib/packlets/resource-types/config/index.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/index.js +64 -0
- package/lib/packlets/resource-types/config/index.js.map +1 -0
- package/lib/packlets/resource-types/config/json.d.ts +9 -0
- package/lib/packlets/resource-types/config/json.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/json.js +24 -0
- package/lib/packlets/resource-types/config/json.js.map +1 -0
- package/lib/packlets/resource-types/helpers.d.ts +13 -0
- package/lib/packlets/resource-types/helpers.d.ts.map +1 -0
- package/lib/packlets/resource-types/helpers.js +44 -0
- package/lib/packlets/resource-types/helpers.js.map +1 -0
- package/lib/packlets/resource-types/index.d.ts +3 -0
- package/lib/packlets/resource-types/index.d.ts.map +1 -1
- package/lib/packlets/resource-types/index.js +26 -0
- package/lib/packlets/resource-types/index.js.map +1 -1
- package/lib/packlets/resource-types/jsonResourceType.d.ts +5 -13
- package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -1
- package/lib/packlets/resource-types/jsonResourceType.js +5 -2
- package/lib/packlets/resource-types/jsonResourceType.js.map +1 -1
- package/lib/packlets/resource-types/resourceType.d.ts +31 -30
- package/lib/packlets/resource-types/resourceType.d.ts.map +1 -1
- package/lib/packlets/resource-types/resourceType.js.map +1 -1
- package/lib/packlets/resources/candidateReducer.d.ts +98 -0
- package/lib/packlets/resources/candidateReducer.d.ts.map +1 -0
- package/lib/packlets/resources/candidateReducer.js +247 -0
- package/lib/packlets/resources/candidateReducer.js.map +1 -0
- package/lib/packlets/resources/common.d.ts +60 -0
- package/lib/packlets/resources/common.d.ts.map +1 -0
- package/lib/packlets/resources/common.js +24 -0
- package/lib/packlets/resources/common.js.map +1 -0
- package/lib/packlets/resources/index.d.ts +3 -1
- package/lib/packlets/resources/index.d.ts.map +1 -1
- package/lib/packlets/resources/index.js +3 -1
- package/lib/packlets/resources/index.js.map +1 -1
- package/lib/packlets/resources/resource.d.ts +57 -5
- package/lib/packlets/resources/resource.d.ts.map +1 -1
- package/lib/packlets/resources/resource.js +96 -6
- package/lib/packlets/resources/resource.js.map +1 -1
- package/lib/packlets/resources/resourceBuilder.d.ts +14 -0
- package/lib/packlets/resources/resourceBuilder.d.ts.map +1 -1
- package/lib/packlets/resources/resourceBuilder.js +19 -1
- package/lib/packlets/resources/resourceBuilder.js.map +1 -1
- package/lib/packlets/resources/resourceCandidate.d.ts +42 -6
- package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -1
- package/lib/packlets/resources/resourceCandidate.js +40 -1
- package/lib/packlets/resources/resourceCandidate.js.map +1 -1
- package/lib/packlets/resources/resourceManagerBuilder.d.ts +220 -0
- package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +1 -0
- package/lib/packlets/resources/resourceManagerBuilder.js +451 -0
- package/lib/packlets/resources/resourceManagerBuilder.js.map +1 -0
- package/lib/packlets/runtime/cacheListener.d.ts +62 -0
- package/lib/packlets/runtime/cacheListener.d.ts.map +1 -0
- package/lib/packlets/runtime/cacheListener.js +56 -0
- package/lib/packlets/runtime/cacheListener.js.map +1 -0
- package/lib/packlets/runtime/cacheMetrics.d.ts +82 -0
- package/lib/packlets/runtime/cacheMetrics.d.ts.map +1 -0
- package/lib/packlets/runtime/cacheMetrics.js +143 -0
- package/lib/packlets/runtime/cacheMetrics.js.map +1 -0
- package/lib/packlets/runtime/compiledResourceCollection.d.ts +167 -0
- package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +1 -0
- package/lib/packlets/runtime/compiledResourceCollection.js +466 -0
- package/lib/packlets/runtime/compiledResourceCollection.js.map +1 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.d.ts +70 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.d.ts.map +1 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.js +135 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.js.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.d.ts +80 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.d.ts.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.js +33 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts +165 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.js +179 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.js.map +1 -0
- package/lib/packlets/runtime/context/index.d.ts +5 -0
- package/lib/packlets/runtime/context/index.d.ts.map +1 -0
- package/lib/packlets/runtime/context/index.js +42 -0
- package/lib/packlets/runtime/context/index.js.map +1 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +111 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +1 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +177 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +47 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +1 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +64 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/iResourceManager.d.ts +88 -0
- package/lib/packlets/runtime/iResourceManager.d.ts.map +1 -0
- package/lib/packlets/runtime/iResourceManager.js +24 -0
- package/lib/packlets/runtime/iResourceManager.js.map +1 -0
- package/lib/packlets/runtime/index.d.ts +12 -0
- package/lib/packlets/runtime/index.d.ts.map +1 -0
- package/lib/packlets/runtime/index.js +73 -0
- package/lib/packlets/runtime/index.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/common.d.ts +91 -0
- package/lib/packlets/runtime/resource-tree/common.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/common.js +24 -0
- package/lib/packlets/runtime/resource-tree/common.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/index.d.ts +5 -0
- package/lib/packlets/runtime/resource-tree/index.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/index.js +42 -0
- package/lib/packlets/runtime/resource-tree/index.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts +141 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js +224 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts +24 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js +98 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts +99 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js +165 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +1 -0
- package/lib/packlets/runtime/resourceResolver.d.ts +196 -0
- package/lib/packlets/runtime/resourceResolver.d.ts.map +1 -0
- package/lib/packlets/runtime/resourceResolver.js +437 -0
- package/lib/packlets/runtime/resourceResolver.js.map +1 -0
- package/lib/packlets/runtime/validate.d.ts +13 -0
- package/lib/packlets/runtime/validate.d.ts.map +1 -0
- package/lib/packlets/runtime/validate.js +49 -0
- package/lib/packlets/runtime/validate.js.map +1 -0
- package/package.json +76 -75
- package/lib/packlets/resources/resourceManager.d.ts +0 -104
- package/lib/packlets/resources/resourceManager.d.ts.map +0 -1
- package/lib/packlets/resources/resourceManager.js +0 -201
- package/lib/packlets/resources/resourceManager.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,76 +1,77 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
2
|
+
"name": "@fgv/ts-res",
|
|
3
|
+
"version": "5.0.0-0",
|
|
4
|
+
"description": "Multi-dimensional Resource Runtime",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "dist/ts-res.d.ts",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"resource",
|
|
9
|
+
"internationalization",
|
|
10
|
+
"globalization",
|
|
11
|
+
"i18n"
|
|
12
|
+
],
|
|
13
|
+
"author": "Erik Fortune",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/ErikFortune/fgv/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/ErikFortune/fgv/tree/main/libraries/ts-res#readme",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@microsoft/api-documenter": "^7.26.29",
|
|
22
|
+
"@microsoft/api-extractor": "^7.49.1",
|
|
23
|
+
"@types/jest": "^29.5.14",
|
|
24
|
+
"@types/luxon": "^3.6.2",
|
|
25
|
+
"@types/node": "^20.14.9",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^7.14.1",
|
|
27
|
+
"@typescript-eslint/parser": "^7.14.1",
|
|
28
|
+
"eslint": "^8.57.0",
|
|
29
|
+
"eslint-config-prettier": "^10.1.5",
|
|
30
|
+
"eslint-plugin-import": "^2.32.0",
|
|
31
|
+
"eslint-plugin-node": "^11.1.0",
|
|
32
|
+
"eslint-plugin-prettier": "^5.5.1",
|
|
33
|
+
"eslint-plugin-promise": "^6.2.0",
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"prettier": "^3.6.2",
|
|
36
|
+
"rimraf": "^5.0.7",
|
|
37
|
+
"ts-jest": "^29.4.0",
|
|
38
|
+
"ts-node": "^10.9.2",
|
|
39
|
+
"typescript": "^5.7.3",
|
|
40
|
+
"eslint-plugin-n": "^16.6.2",
|
|
41
|
+
"@rushstack/eslint-config": "~4.4.0",
|
|
42
|
+
"@rushstack/heft": "~0.74.0",
|
|
43
|
+
"@rushstack/heft-jest-plugin": "~0.16.9",
|
|
44
|
+
"@rushstack/heft-node-rig": "~2.9.0",
|
|
45
|
+
"@types/heft-jest": "1.0.6",
|
|
46
|
+
"eslint-plugin-tsdoc": "~0.4.0",
|
|
47
|
+
"@fgv/ts-utils": "5.0.0-0",
|
|
48
|
+
"@fgv/ts-utils-jest": "5.0.0-0",
|
|
49
|
+
"@fgv/ts-json-base": "5.0.0-0",
|
|
50
|
+
"@fgv/ts-bcp47": "5.0.0-0",
|
|
51
|
+
"@fgv/ts-extras": "5.0.0-0",
|
|
52
|
+
"@fgv/ts-json": "5.0.0-0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"luxon": "^3.6.1"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@fgv/ts-utils": "5.0.0-0",
|
|
59
|
+
"@fgv/ts-extras": "5.0.0-0",
|
|
60
|
+
"@fgv/ts-json": "5.0.0-0",
|
|
61
|
+
"@fgv/ts-json-base": "5.0.0-0",
|
|
62
|
+
"@fgv/ts-bcp47": "5.0.0-0"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "heft build --clean",
|
|
66
|
+
"clean": "heft clean",
|
|
67
|
+
"test": "heft test --clean",
|
|
68
|
+
"test-ts-res": "heft test --clean",
|
|
69
|
+
"build-docs": "api-documenter markdown --input-folder ./temp --output-folder docs",
|
|
70
|
+
"build-all": "rushx build; rushx build-docs",
|
|
71
|
+
"test-handles": "heft test --detect-open-handles",
|
|
72
|
+
"clean-jest": "heft test --clean",
|
|
73
|
+
"coverage": "heft test --clean --max-workers 1 --detect-open-handles",
|
|
74
|
+
"lint": "eslint src --ext .ts",
|
|
75
|
+
"fixlint": "eslint src --ext .ts --fix"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { Collections, DetailedResult, Result, ValidatingResultMap } from '@fgv/ts-utils';
|
|
2
|
-
import { ConditionCollector, ConditionSetCollector, ReadOnlyConditionCollector, ReadOnlyConditionSetCollector } from '../conditions';
|
|
3
|
-
import { AbstractDecisionCollector, ReadOnlyAbstractDecisionCollector } from '../decisions';
|
|
4
|
-
import { IReadOnlyQualifierCollector } from '../qualifiers';
|
|
5
|
-
import { ReadOnlyResourceTypeCollector } from '../resource-types';
|
|
6
|
-
import { ResourceId } from '../common';
|
|
7
|
-
import { ResourceBuilder, ResourceBuilderResultDetail } from './resourceBuilder';
|
|
8
|
-
import { Resource } from './resource';
|
|
9
|
-
import { ResourceCandidate } from './resourceCandidate';
|
|
10
|
-
import * as ResourceJson from '../resource-json';
|
|
11
|
-
/**
|
|
12
|
-
* Interface for parameters to the {@link Resources.ResourceManager.create | ResourceManager create method}.
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export interface IResourceManagerCreateParams {
|
|
16
|
-
qualifiers: IReadOnlyQualifierCollector;
|
|
17
|
-
resourceTypes: ReadOnlyResourceTypeCollector;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Error details that can be returned by a {@link Resources.ResourceManager | ResourceManager}.
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
export type ResourceManagerResultDetail = Collections.ResultMapResultDetail | ResourceBuilderResultDetail;
|
|
24
|
-
/**
|
|
25
|
-
* Represents a manager for a collection of {@link Resources.Resource | resources}. Collects
|
|
26
|
-
* {@link Resources.ResourceCandidate | candidates} for each resource into a
|
|
27
|
-
* {@link Resources.ResourceBuilder | ResourceBuilder} per resource, validates them against each other,
|
|
28
|
-
* and builds a collection of {@link Resources.Resource | resources} once all candidates are collected.
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
export declare class ResourceManager {
|
|
32
|
-
readonly qualifiers: IReadOnlyQualifierCollector;
|
|
33
|
-
readonly resourceTypes: ReadOnlyResourceTypeCollector;
|
|
34
|
-
protected readonly _conditions: ConditionCollector;
|
|
35
|
-
protected readonly _conditionSets: ConditionSetCollector;
|
|
36
|
-
protected readonly _decisions: AbstractDecisionCollector;
|
|
37
|
-
protected readonly _resources: ValidatingResultMap<ResourceId, ResourceBuilder>;
|
|
38
|
-
protected readonly _builtResources: ValidatingResultMap<ResourceId, Resource>;
|
|
39
|
-
protected _built: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
42
|
-
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
43
|
-
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
44
|
-
*/
|
|
45
|
-
get conditions(): ReadOnlyConditionCollector;
|
|
46
|
-
/**
|
|
47
|
-
* A {@link Conditions.ConditionSetCollector | ConditionSetCollector} which
|
|
48
|
-
* contains the {@link Conditions.ConditionSet | condition sets} used so far by
|
|
49
|
-
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
50
|
-
*/
|
|
51
|
-
get conditionSets(): ReadOnlyConditionSetCollector;
|
|
52
|
-
/**
|
|
53
|
-
* A {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} which
|
|
54
|
-
* contains the {@link Decisions.Decision | abstract decisions} used so far by
|
|
55
|
-
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
56
|
-
*/
|
|
57
|
-
get decisions(): ReadOnlyAbstractDecisionCollector;
|
|
58
|
-
/**
|
|
59
|
-
* A read-only map of {@link Resources.ResourceBuilder | resource builders} used by the manager.
|
|
60
|
-
*/
|
|
61
|
-
get resources(): Collections.IReadOnlyValidatingResultMap<ResourceId, ResourceBuilder>;
|
|
62
|
-
/**
|
|
63
|
-
* The number of {@link Resources.Resource | resources} contained by the manager.
|
|
64
|
-
*/
|
|
65
|
-
get size(): number;
|
|
66
|
-
/**
|
|
67
|
-
* Constructor for a {@link Resources.ResourceManager | ResourceManager} object.
|
|
68
|
-
* @param params - Parameters to create a new {@link Resources.ResourceManager | ResourceManager}.
|
|
69
|
-
* @public
|
|
70
|
-
*/
|
|
71
|
-
protected constructor(params: IResourceManagerCreateParams);
|
|
72
|
-
/**
|
|
73
|
-
* Creates a new {@link Resources.ResourceManager | ResourceManager} object.
|
|
74
|
-
* @param params - Parameters to create a new {@link Resources.ResourceManager | ResourceManager}.
|
|
75
|
-
* @returns `Success` with the new {@link Resources.ResourceManager | ResourceManager} object if successful,
|
|
76
|
-
* or `Failure` with an error message if not.
|
|
77
|
-
* @public
|
|
78
|
-
*/
|
|
79
|
-
static create(params: IResourceManagerCreateParams): Result<ResourceManager>;
|
|
80
|
-
/**
|
|
81
|
-
* Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds
|
|
82
|
-
* a {@link Resources.ResourceCandidate | candidate} to the manager.
|
|
83
|
-
* @param candidate - The {@link Resources.ResourceCandidate | candidate} to add.
|
|
84
|
-
* @returns `Success` with the candidate if successful, or `Failure` with an error message if not.
|
|
85
|
-
* @public
|
|
86
|
-
*/
|
|
87
|
-
addLooseCandidate(decl: ResourceJson.Json.ILooseResourceCandidateDecl): DetailedResult<ResourceCandidate, ResourceManagerResultDetail>;
|
|
88
|
-
addResource(decl: ResourceJson.Json.ILooseResourceDecl): DetailedResult<ResourceBuilder, ResourceManagerResultDetail>;
|
|
89
|
-
/**
|
|
90
|
-
* Gets an individual {@link Resources.Resource | built resource} from the manager.
|
|
91
|
-
* @param id - The {@link ResourceId | id} of the resource to get.
|
|
92
|
-
* @returns `Success` with the resource if successful, or `Failure` with an error message if not.
|
|
93
|
-
* @public
|
|
94
|
-
*/
|
|
95
|
-
getBuiltResource(id: string): Result<Resource>;
|
|
96
|
-
/**
|
|
97
|
-
* Builds the {@link Resources.Resource | resources} from the collected {@link Resources.ResourceCandidate | candidates}.
|
|
98
|
-
* @returns `Success` with a read-only map of {@link Resources.Resource | resources} if successful,
|
|
99
|
-
* or `Failure` with an error message if not.
|
|
100
|
-
* @public
|
|
101
|
-
*/
|
|
102
|
-
build(): Result<Collections.IReadOnlyValidatingResultMap<ResourceId, Resource>>;
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=resourceManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resourceManager.d.ts","sourceRoot":"","sources":["../../../src/packlets/resources/resourceManager.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,WAAW,EACX,cAAc,EAKd,MAAM,EAGN,mBAAmB,EACp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AC,MAAM,EAAE,OAAO,CAAC;IAE1B;;;;OAIG;IACH,IAAW,UAAU,IAAI,0BAA0B,CAElD;IAED;;;;OAIG;IACH,IAAW,aAAa,IAAI,6BAA6B,CAExD;IAED;;;;OAIG;IACH,IAAW,SAAS,IAAI,iCAAiC,CAExD;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,WAAW,CAAC,4BAA4B,CAAC,UAAU,EAAE,eAAe,CAAC,CAE5F;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;OAIG;IACH,SAAS,aAAa,MAAM,EAAE,4BAA4B;IAwB1D;;;;;;OAMG;WACW,MAAM,CAAC,MAAM,EAAE,4BAA4B,GAAG,MAAM,CAAC,eAAe,CAAC;IAInF;;;;;;OAMG;IACI,iBAAiB,CACtB,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,2BAA2B,GAClD,cAAc,CAAC,iBAAiB,EAAE,2BAA2B,CAAC;IA2B1D,WAAW,CAChB,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,kBAAkB,GACzC,cAAc,CAAC,eAAe,EAAE,2BAA2B,CAAC;IAsC/D;;;;;OAKG;IACI,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;IAMrD;;;;;OAKG;IACI,KAAK,IAAI,MAAM,CAAC,WAAW,CAAC,4BAA4B,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;CAcvF"}
|
|
@@ -1,201 +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.ResourceManager = void 0;
|
|
25
|
-
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
-
const conditions_1 = require("../conditions");
|
|
27
|
-
const decisions_1 = require("../decisions");
|
|
28
|
-
const common_1 = require("../common");
|
|
29
|
-
const resourceBuilder_1 = require("./resourceBuilder");
|
|
30
|
-
const resource_1 = require("./resource");
|
|
31
|
-
/**
|
|
32
|
-
* Represents a manager for a collection of {@link Resources.Resource | resources}. Collects
|
|
33
|
-
* {@link Resources.ResourceCandidate | candidates} for each resource into a
|
|
34
|
-
* {@link Resources.ResourceBuilder | ResourceBuilder} per resource, validates them against each other,
|
|
35
|
-
* and builds a collection of {@link Resources.Resource | resources} once all candidates are collected.
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
class ResourceManager {
|
|
39
|
-
/**
|
|
40
|
-
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
41
|
-
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
42
|
-
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
43
|
-
*/
|
|
44
|
-
get conditions() {
|
|
45
|
-
return this._conditions;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A {@link Conditions.ConditionSetCollector | ConditionSetCollector} which
|
|
49
|
-
* contains the {@link Conditions.ConditionSet | condition sets} used so far by
|
|
50
|
-
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
51
|
-
*/
|
|
52
|
-
get conditionSets() {
|
|
53
|
-
return this._conditionSets;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* A {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} which
|
|
57
|
-
* contains the {@link Decisions.Decision | abstract decisions} used so far by
|
|
58
|
-
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
59
|
-
*/
|
|
60
|
-
get decisions() {
|
|
61
|
-
return this._decisions;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A read-only map of {@link Resources.ResourceBuilder | resource builders} used by the manager.
|
|
65
|
-
*/
|
|
66
|
-
get resources() {
|
|
67
|
-
return this._resources;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* The number of {@link Resources.Resource | resources} contained by the manager.
|
|
71
|
-
*/
|
|
72
|
-
get size() {
|
|
73
|
-
return this._resources.size;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Constructor for a {@link Resources.ResourceManager | ResourceManager} object.
|
|
77
|
-
* @param params - Parameters to create a new {@link Resources.ResourceManager | ResourceManager}.
|
|
78
|
-
* @public
|
|
79
|
-
*/
|
|
80
|
-
constructor(params) {
|
|
81
|
-
this.qualifiers = params.qualifiers;
|
|
82
|
-
this.resourceTypes = params.resourceTypes;
|
|
83
|
-
this._conditions = conditions_1.ConditionCollector.create({ qualifiers: params.qualifiers }).orThrow();
|
|
84
|
-
this._conditionSets = conditions_1.ConditionSetCollector.create({ conditions: this._conditions }).orThrow();
|
|
85
|
-
this._decisions = decisions_1.AbstractDecisionCollector.create({ conditionSets: this._conditionSets }).orThrow();
|
|
86
|
-
this._resources = new ts_utils_1.ValidatingResultMap({
|
|
87
|
-
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
88
|
-
key: common_1.Convert.resourceId,
|
|
89
|
-
/* c8 ignore next 2 - defense in depth against internal error */
|
|
90
|
-
value: (from) => from instanceof resourceBuilder_1.ResourceBuilder ? (0, ts_utils_1.succeed)(from) : (0, ts_utils_1.fail)('not a resource builder')
|
|
91
|
-
})
|
|
92
|
-
});
|
|
93
|
-
this._builtResources = new ts_utils_1.ValidatingResultMap({
|
|
94
|
-
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
95
|
-
key: common_1.Convert.resourceId,
|
|
96
|
-
/* c8 ignore next 1 - defense in depth against internal error */
|
|
97
|
-
value: (from) => (from instanceof resource_1.Resource ? (0, ts_utils_1.succeed)(from) : (0, ts_utils_1.fail)('not a resource'))
|
|
98
|
-
})
|
|
99
|
-
});
|
|
100
|
-
this._built = false;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Creates a new {@link Resources.ResourceManager | ResourceManager} object.
|
|
104
|
-
* @param params - Parameters to create a new {@link Resources.ResourceManager | ResourceManager}.
|
|
105
|
-
* @returns `Success` with the new {@link Resources.ResourceManager | ResourceManager} object if successful,
|
|
106
|
-
* or `Failure` with an error message if not.
|
|
107
|
-
* @public
|
|
108
|
-
*/
|
|
109
|
-
static create(params) {
|
|
110
|
-
return (0, ts_utils_1.captureResult)(() => new ResourceManager(params));
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds
|
|
114
|
-
* a {@link Resources.ResourceCandidate | candidate} to the manager.
|
|
115
|
-
* @param candidate - The {@link Resources.ResourceCandidate | candidate} to add.
|
|
116
|
-
* @returns `Success` with the candidate if successful, or `Failure` with an error message if not.
|
|
117
|
-
* @public
|
|
118
|
-
*/
|
|
119
|
-
addLooseCandidate(decl) {
|
|
120
|
-
const { value: id, message } = common_1.Validate.toResourceId(decl.id);
|
|
121
|
-
if (message !== undefined) {
|
|
122
|
-
return (0, ts_utils_1.failWithDetail)(`${id}: invalid id - ${message}`, 'failure');
|
|
123
|
-
}
|
|
124
|
-
const builderResult = this._resources.getOrAdd(id, () => resourceBuilder_1.ResourceBuilder.create({
|
|
125
|
-
id,
|
|
126
|
-
resourceTypes: this.resourceTypes,
|
|
127
|
-
conditionSets: this._conditionSets
|
|
128
|
-
}));
|
|
129
|
-
/* c8 ignore next 6 - defense in depth against internal error */
|
|
130
|
-
if (builderResult.isFailure()) {
|
|
131
|
-
return (0, ts_utils_1.failWithDetail)(`${id}: unable to get or add resource\n${builderResult.message}`, builderResult.detail);
|
|
132
|
-
}
|
|
133
|
-
return builderResult.value.addLooseCandidate(decl).onSuccess((c, d) => {
|
|
134
|
-
this._builtResources.delete(id);
|
|
135
|
-
this._built = false;
|
|
136
|
-
return (0, ts_utils_1.succeedWithDetail)(c, d);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
addResource(decl) {
|
|
140
|
-
var _a;
|
|
141
|
-
const { value: id, message } = common_1.Validate.toResourceId(decl.id);
|
|
142
|
-
if (message !== undefined) {
|
|
143
|
-
return (0, ts_utils_1.failWithDetail)(`${id}: invalid id - ${message}`, 'failure');
|
|
144
|
-
}
|
|
145
|
-
const { value: builder, message: getOrAddMessage, detail } = this._resources.getOrAdd(id, () => resourceBuilder_1.ResourceBuilder.create({
|
|
146
|
-
id,
|
|
147
|
-
typeName: decl.resourceTypeName,
|
|
148
|
-
resourceTypes: this.resourceTypes,
|
|
149
|
-
conditionSets: this._conditionSets
|
|
150
|
-
}));
|
|
151
|
-
/* c8 ignore next 3 - defense in depth against internal error */
|
|
152
|
-
if (getOrAddMessage !== undefined) {
|
|
153
|
-
return (0, ts_utils_1.failWithDetail)(`${id}: unable to get or add resource\n${getOrAddMessage}`, detail);
|
|
154
|
-
}
|
|
155
|
-
if (detail === 'exists') {
|
|
156
|
-
const { message } = builder.setResourceType(decl.resourceTypeName);
|
|
157
|
-
if (message !== undefined) {
|
|
158
|
-
return (0, ts_utils_1.failWithDetail)(`${id}: unable to set resource type\n${message}`, 'type-mismatch');
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const candidates = (_a = decl.candidates) !== null && _a !== void 0 ? _a : [];
|
|
162
|
-
return (0, ts_utils_1.mapResults)(candidates.map((c) => builder.addChildCandidate(c)))
|
|
163
|
-
.onSuccess(() => {
|
|
164
|
-
return (0, ts_utils_1.succeed)(builder);
|
|
165
|
-
})
|
|
166
|
-
.withDetail('failure', detail);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Gets an individual {@link Resources.Resource | built resource} from the manager.
|
|
170
|
-
* @param id - The {@link ResourceId | id} of the resource to get.
|
|
171
|
-
* @returns `Success` with the resource if successful, or `Failure` with an error message if not.
|
|
172
|
-
* @public
|
|
173
|
-
*/
|
|
174
|
-
getBuiltResource(id) {
|
|
175
|
-
return this._resources.validating
|
|
176
|
-
.get(id)
|
|
177
|
-
.onSuccess((builder) => this._builtResources.validating.getOrAdd(id, () => builder.build()));
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Builds the {@link Resources.Resource | resources} from the collected {@link Resources.ResourceCandidate | candidates}.
|
|
181
|
-
* @returns `Success` with a read-only map of {@link Resources.Resource | resources} if successful,
|
|
182
|
-
* or `Failure` with an error message if not.
|
|
183
|
-
* @public
|
|
184
|
-
*/
|
|
185
|
-
build() {
|
|
186
|
-
if (!this._built) {
|
|
187
|
-
const errors = new ts_utils_1.MessageAggregator();
|
|
188
|
-
this._resources.forEach((r, id) => {
|
|
189
|
-
this._builtResources.getOrAdd(id, () => r.build()).aggregateError(errors);
|
|
190
|
-
});
|
|
191
|
-
/* c8 ignore next 3 - defense in depth against internal error */
|
|
192
|
-
if (errors.hasMessages) {
|
|
193
|
-
return (0, ts_utils_1.fail)(`build failed: ${errors.toString()}`);
|
|
194
|
-
}
|
|
195
|
-
this._built = true;
|
|
196
|
-
}
|
|
197
|
-
return (0, ts_utils_1.succeed)(this._builtResources);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
exports.ResourceManager = ResourceManager;
|
|
201
|
-
//# sourceMappingURL=resourceManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resourceManager.js","sourceRoot":"","sources":["../../../src/packlets/resources/resourceManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAYuB;AACvB,8CAKuB;AACvB,4CAA4F;AAG5F,sCAA0D;AAC1D,uDAAiF;AACjF,yCAAsC;AAmBtC;;;;;;GAMG;AACH,MAAa,eAAe;IAW1B;;;;OAIG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,YAAsB,MAAoC;QACxD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,+BAAkB,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAC1F,I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UAAU,CAAC,UAAU;aAC9B,GAAG,CAAC,EAAE,CAAC;aACP,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjG,CAAC;IAED;;;;;OAKG;IACI,KAAK;QACV,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,MAAM,GAAsB,IAAI,4BAAiB,EAAE,CAAC;YAC1D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE;gBAChC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;YAC5E,CAAC,CAAC,CAAC;YACH,gEAAgE;YAChE,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;gBACvB,OAAO,IAAA,eAAI,EAAC,iBAAiB,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACpD,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACvC,CAAC;CACF;AAxMD,0CAwMC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n captureResult,\n Collections,\n DetailedResult,\n fail,\n failWithDetail,\n mapResults,\n MessageAggregator,\n Result,\n succeed,\n succeedWithDetail,\n ValidatingResultMap\n} from '@fgv/ts-utils';\nimport {\n ConditionCollector,\n ConditionSetCollector,\n ReadOnlyConditionCollector,\n ReadOnlyConditionSetCollector\n} from '../conditions';\nimport { AbstractDecisionCollector, ReadOnlyAbstractDecisionCollector } from '../decisions';\nimport { IReadOnlyQualifierCollector } from '../qualifiers';\nimport { ReadOnlyResourceTypeCollector } from '../resource-types';\nimport { Convert, ResourceId, Validate } from '../common';\nimport { ResourceBuilder, ResourceBuilderResultDetail } from './resourceBuilder';\nimport { Resource } from './resource';\nimport { ResourceCandidate } from './resourceCandidate';\nimport * as ResourceJson from '../resource-json';\n\n/**\n * Interface for parameters to the {@link Resources.ResourceManager.create | ResourceManager create method}.\n * @public\n */\nexport interface IResourceManagerCreateParams {\n qualifiers: IReadOnlyQualifierCollector;\n resourceTypes: ReadOnlyResourceTypeCollector;\n}\n\n/**\n * Error details that can be returned by a {@link Resources.ResourceManager | ResourceManager}.\n * @public\n */\nexport type ResourceManagerResultDetail = Collections.ResultMapResultDetail | ResourceBuilderResultDetail;\n\n/**\n * Represents a manager for a collection of {@link Resources.Resource | resources}. Collects\n * {@link Resources.ResourceCandidate | candidates} for each resource into a\n * {@link Resources.ResourceBuilder | ResourceBuilder} per resource, validates them against each other,\n * and builds a collection of {@link Resources.Resource | resources} once all candidates are collected.\n * @public\n */\nexport class ResourceManager {\n public readonly qualifiers: IReadOnlyQualifierCollector;\n public readonly resourceTypes: ReadOnlyResourceTypeCollector;\n\n protected readonly _conditions: ConditionCollector;\n protected readonly _conditionSets: ConditionSetCollector;\n protected readonly _decisions: AbstractDecisionCollector;\n protected readonly _resources: ValidatingResultMap<ResourceId, ResourceBuilder>;\n protected readonly _builtResources: ValidatingResultMap<ResourceId, Resource>;\n protected _built: boolean;\n\n /**\n * A {@link Conditions.ConditionCollector | ConditionCollector} which\n * contains the {@link Conditions.Condition | conditions} used so far by\n * the {@link Resources.ResourceCandidate | resource candidates} in this manager.\n */\n public get conditions(): ReadOnlyConditionCollector {\n return this._conditions;\n }\n\n /**\n * A {@link Conditions.ConditionSetCollector | ConditionSetCollector} which\n * contains the {@link Conditions.ConditionSet | condition sets} used so far by\n * the {@link Resources.ResourceCandidate | resource candidates} in this manager.\n */\n public get conditionSets(): ReadOnlyConditionSetCollector {\n return this._conditionSets;\n }\n\n /**\n * A {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} which\n * contains the {@link Decisions.Decision | abstract decisions} used so far by\n * the {@link Resources.ResourceCandidate | resource candidates} in this manager.\n */\n public get decisions(): ReadOnlyAbstractDecisionCollector {\n return this._decisions;\n }\n\n /**\n * A read-only map of {@link Resources.ResourceBuilder | resource builders} used by the manager.\n */\n public get resources(): Collections.IReadOnlyValidatingResultMap<ResourceId, ResourceBuilder> {\n return this._resources;\n }\n\n /**\n * The number of {@link Resources.Resource | resources} contained by the manager.\n */\n public get size(): number {\n return this._resources.size;\n }\n\n /**\n * Constructor for a {@link Resources.ResourceManager | ResourceManager} object.\n * @param params - Parameters to create a new {@link Resources.ResourceManager | ResourceManager}.\n * @public\n */\n protected constructor(params: IResourceManagerCreateParams) {\n this.qualifiers = params.qualifiers;\n this.resourceTypes = params.resourceTypes;\n this._conditions = ConditionCollector.create({ qualifiers: params.qualifiers }).orThrow();\n this._conditionSets = ConditionSetCollector.create({ conditions: this._conditions }).orThrow();\n this._decisions = AbstractDecisionCollector.create({ conditionSets: this._conditionSets }).orThrow();\n this._resources = new ValidatingResultMap({\n converters: new Collections.KeyValueConverters<ResourceId, ResourceBuilder>({\n key: Convert.resourceId,\n /* c8 ignore next 2 - defense in depth against internal error */\n value: (from: unknown) =>\n from instanceof ResourceBuilder ? succeed(from) : fail('not a resource builder')\n })\n });\n this._builtResources = new ValidatingResultMap({\n converters: new Collections.KeyValueConverters<ResourceId, Resource>({\n key: Convert.resourceId,\n /* c8 ignore next 1 - defense in depth against internal error */\n value: (from: unknown) => (from instanceof Resource ? succeed(from) : fail('not a resource'))\n })\n });\n this._built = false;\n }\n\n /**\n * Creates a new {@link Resources.ResourceManager | ResourceManager} object.\n * @param params - Parameters to create a new {@link Resources.ResourceManager | ResourceManager}.\n * @returns `Success` with the new {@link Resources.ResourceManager | ResourceManager} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IResourceManagerCreateParams): Result<ResourceManager> {\n return captureResult(() => new ResourceManager(params));\n }\n\n /**\n * Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds\n * a {@link Resources.ResourceCandidate | candidate} to the manager.\n * @param candidate - The {@link Resources.ResourceCandidate | candidate} to add.\n * @returns `Success` with the candidate if successful, or `Failure` with an error message if not.\n * @public\n */\n public addLooseCandidate(\n decl: ResourceJson.Json.ILooseResourceCandidateDecl\n ): DetailedResult<ResourceCandidate, ResourceManagerResultDetail> {\n const { value: id, message } = Validate.toResourceId(decl.id);\n if (message !== undefined) {\n return failWithDetail(`${id}: invalid id - ${message}`, 'failure');\n }\n\n const builderResult = this._resources.getOrAdd(id, () =>\n ResourceBuilder.create({\n id,\n resourceTypes: this.resourceTypes,\n conditionSets: this._conditionSets\n })\n );\n /* c8 ignore next 6 - defense in depth against internal error */\n if (builderResult.isFailure()) {\n return failWithDetail(\n `${id}: unable to get or add resource\\n${builderResult.message}`,\n builderResult.detail\n );\n }\n return builderResult.value.addLooseCandidate(decl).onSuccess((c, d) => {\n this._builtResources.delete(id);\n this._built = false;\n return succeedWithDetail(c, d);\n });\n }\n\n public addResource(\n decl: ResourceJson.Json.ILooseResourceDecl\n ): DetailedResult<ResourceBuilder, ResourceManagerResultDetail> {\n const { value: id, message } = Validate.toResourceId(decl.id);\n if (message !== undefined) {\n return failWithDetail(`${id}: invalid id - ${message}`, 'failure');\n }\n\n const {\n value: builder,\n message: getOrAddMessage,\n detail\n } = this._resources.getOrAdd(id, () =>\n ResourceBuilder.create({\n id,\n typeName: decl.resourceTypeName,\n resourceTypes: this.resourceTypes,\n conditionSets: this._conditionSets\n })\n );\n /* c8 ignore next 3 - defense in depth against internal error */\n if (getOrAddMessage !== undefined) {\n return failWithDetail(`${id}: unable to get or add resource\\n${getOrAddMessage}`, detail);\n }\n\n if (detail === 'exists') {\n const { message } = builder.setResourceType(decl.resourceTypeName);\n if (message !== undefined) {\n return failWithDetail(`${id}: unable to set resource type\\n${message}`, 'type-mismatch');\n }\n }\n\n const candidates = decl.candidates ?? [];\n return mapResults(candidates.map((c) => builder.addChildCandidate(c)))\n .onSuccess(() => {\n return succeed(builder);\n })\n .withDetail('failure', detail);\n }\n\n /**\n * Gets an individual {@link Resources.Resource | built resource} from the manager.\n * @param id - The {@link ResourceId | id} of the resource to get.\n * @returns `Success` with the resource if successful, or `Failure` with an error message if not.\n * @public\n */\n public getBuiltResource(id: string): Result<Resource> {\n return this._resources.validating\n .get(id)\n .onSuccess((builder) => this._builtResources.validating.getOrAdd(id, () => builder.build()));\n }\n\n /**\n * Builds the {@link Resources.Resource | resources} from the collected {@link Resources.ResourceCandidate | candidates}.\n * @returns `Success` with a read-only map of {@link Resources.Resource | resources} if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public build(): Result<Collections.IReadOnlyValidatingResultMap<ResourceId, Resource>> {\n if (!this._built) {\n const errors: MessageAggregator = new MessageAggregator();\n this._resources.forEach((r, id) => {\n this._builtResources.getOrAdd(id, () => r.build()).aggregateError(errors);\n });\n /* c8 ignore next 3 - defense in depth against internal error */\n if (errors.hasMessages) {\n return fail(`build failed: ${errors.toString()}`);\n }\n this._built = true;\n }\n return succeed(this._builtResources);\n }\n}\n"]}
|