@fgv/ts-res 4.5.0-3 → 5.0.0-2
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 +4241 -318
- 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 +42 -13
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/literalQualifierType.js +58 -10
- package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +114 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.js +228 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts +33 -18
- package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/qualifierType.js +18 -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
|
@@ -0,0 +1,451 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.ResourceManagerBuilder = void 0;
|
|
58
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
59
|
+
const conditions_1 = require("../conditions");
|
|
60
|
+
const decisions_1 = require("../decisions");
|
|
61
|
+
const common_1 = require("../common");
|
|
62
|
+
const resourceBuilder_1 = require("./resourceBuilder");
|
|
63
|
+
const resource_1 = require("./resource");
|
|
64
|
+
const ResourceJson = __importStar(require("../resource-json"));
|
|
65
|
+
const Context = __importStar(require("../context"));
|
|
66
|
+
/**
|
|
67
|
+
* Builder for a collection of {@link Resources.Resource | resources}. Collects
|
|
68
|
+
* {@link Resources.ResourceCandidate | candidates} for each resource into a
|
|
69
|
+
* {@link Resources.ResourceBuilder | ResourceBuilder} per resource, validates them against each other,
|
|
70
|
+
* and builds a collection of {@link Resources.Resource | resources} once all candidates are collected.
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
class ResourceManagerBuilder {
|
|
74
|
+
/**
|
|
75
|
+
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
76
|
+
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
77
|
+
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
78
|
+
*/
|
|
79
|
+
get conditions() {
|
|
80
|
+
return this._conditions;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A {@link Conditions.ConditionSetCollector | ConditionSetCollector} which
|
|
84
|
+
* contains the {@link Conditions.ConditionSet | condition sets} used so far by
|
|
85
|
+
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
86
|
+
*/
|
|
87
|
+
get conditionSets() {
|
|
88
|
+
return this._conditionSets;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector} which
|
|
92
|
+
* contains the {@link Decisions.Decision | abstract decisions} used so far by
|
|
93
|
+
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
94
|
+
*/
|
|
95
|
+
get decisions() {
|
|
96
|
+
return this._decisions;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A read-only map of {@link Resources.ResourceBuilder | resource builders} used by the manager.
|
|
100
|
+
*/
|
|
101
|
+
get resources() {
|
|
102
|
+
return this._resources;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The number of {@link Resources.Resource | resources} contained by the manager.
|
|
106
|
+
*/
|
|
107
|
+
get size() {
|
|
108
|
+
return this._resources.size;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* {@inheritdoc Runtime.IResourceManager.numResources}
|
|
112
|
+
*/
|
|
113
|
+
get numResources() {
|
|
114
|
+
return this._resources.size;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* {@inheritdoc Runtime.IResourceManager.numCandidates}
|
|
118
|
+
*/
|
|
119
|
+
get numCandidates() {
|
|
120
|
+
if (this._numCandidates === undefined) {
|
|
121
|
+
this._numCandidates = this.getAllCandidates().length;
|
|
122
|
+
}
|
|
123
|
+
return this._numCandidates;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* {@inheritdoc Runtime.IResourceManager.builtResources}
|
|
127
|
+
*/
|
|
128
|
+
get builtResources() {
|
|
129
|
+
return this._performBuild().orThrow();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Constructor for a {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object.
|
|
133
|
+
* @param params - Parameters to create a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder}.
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
constructor(params) {
|
|
137
|
+
this.qualifiers = params.qualifiers;
|
|
138
|
+
this.resourceTypes = params.resourceTypes;
|
|
139
|
+
this._conditions = conditions_1.ConditionCollector.create({ qualifiers: params.qualifiers }).orThrow();
|
|
140
|
+
this._conditionSets = conditions_1.ConditionSetCollector.create({ conditions: this._conditions }).orThrow();
|
|
141
|
+
this._decisions = decisions_1.AbstractDecisionCollector.create({ conditionSets: this._conditionSets }).orThrow();
|
|
142
|
+
this._resources = new ts_utils_1.ValidatingResultMap({
|
|
143
|
+
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
144
|
+
key: common_1.Convert.resourceId,
|
|
145
|
+
/* c8 ignore next 2 - defense in depth against internal error */
|
|
146
|
+
value: (from) => from instanceof resourceBuilder_1.ResourceBuilder ? (0, ts_utils_1.succeed)(from) : (0, ts_utils_1.fail)('not a resource builder')
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
this._builtResources = new ts_utils_1.ValidatingResultMap({
|
|
150
|
+
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
151
|
+
key: common_1.Convert.resourceId,
|
|
152
|
+
/* c8 ignore next 1 - defense in depth against internal error */
|
|
153
|
+
value: (from) => (from instanceof resource_1.Resource ? (0, ts_utils_1.succeed)(from) : (0, ts_utils_1.fail)('not a resource'))
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
this._built = false;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Creates a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object.
|
|
160
|
+
* @param params - Parameters to create a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder}.
|
|
161
|
+
* @returns `Success` with the new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object if successful,
|
|
162
|
+
* or `Failure` with an error message if not.
|
|
163
|
+
* @public
|
|
164
|
+
*/
|
|
165
|
+
static create(params) {
|
|
166
|
+
return (0, ts_utils_1.captureResult)(() => new ResourceManagerBuilder(params));
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds
|
|
170
|
+
* a {@link Resources.ResourceCandidate | candidate} to the manager.
|
|
171
|
+
* @param candidate - The {@link Resources.ResourceCandidate | candidate} to add.
|
|
172
|
+
* @returns `Success` with the candidate if successful, or `Failure` with an error message if not.
|
|
173
|
+
* @public
|
|
174
|
+
*/
|
|
175
|
+
addLooseCandidate(decl) {
|
|
176
|
+
const { value: id, message } = common_1.Validate.toResourceId(decl.id);
|
|
177
|
+
if (message !== undefined) {
|
|
178
|
+
return (0, ts_utils_1.failWithDetail)(`${id}: invalid id - ${message}`, 'failure');
|
|
179
|
+
}
|
|
180
|
+
const builderResult = this._resources.getOrAdd(id, () => resourceBuilder_1.ResourceBuilder.create({
|
|
181
|
+
id,
|
|
182
|
+
resourceTypes: this.resourceTypes,
|
|
183
|
+
conditionSets: this._conditionSets,
|
|
184
|
+
decisions: this._decisions
|
|
185
|
+
}));
|
|
186
|
+
/* c8 ignore next 6 - defense in depth against internal error */
|
|
187
|
+
if (builderResult.isFailure()) {
|
|
188
|
+
return (0, ts_utils_1.failWithDetail)(`${id}: unable to get or add resource\n${builderResult.message}`, builderResult.detail);
|
|
189
|
+
}
|
|
190
|
+
return builderResult.value.addLooseCandidate(decl).onSuccess((c, d) => {
|
|
191
|
+
this._builtResources.delete(id);
|
|
192
|
+
this._built = false;
|
|
193
|
+
this._numCandidates = undefined;
|
|
194
|
+
return (0, ts_utils_1.succeedWithDetail)(c, d);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
addResource(decl) {
|
|
198
|
+
var _a;
|
|
199
|
+
const { value: id, message } = common_1.Validate.toResourceId(decl.id);
|
|
200
|
+
if (message !== undefined) {
|
|
201
|
+
return (0, ts_utils_1.failWithDetail)(`${id}: invalid id - ${message}`, 'failure');
|
|
202
|
+
}
|
|
203
|
+
const { value: builder, message: getOrAddMessage, detail } = this._resources.getOrAdd(id, () => resourceBuilder_1.ResourceBuilder.create({
|
|
204
|
+
id,
|
|
205
|
+
typeName: decl.resourceTypeName,
|
|
206
|
+
resourceTypes: this.resourceTypes,
|
|
207
|
+
conditionSets: this._conditionSets,
|
|
208
|
+
decisions: this._decisions
|
|
209
|
+
}));
|
|
210
|
+
/* c8 ignore next 3 - defense in depth against internal error */
|
|
211
|
+
if (getOrAddMessage !== undefined) {
|
|
212
|
+
return (0, ts_utils_1.failWithDetail)(`${id}: unable to get or add resource\n${getOrAddMessage}`, detail);
|
|
213
|
+
}
|
|
214
|
+
if (detail === 'exists') {
|
|
215
|
+
const { message } = builder.setResourceType(decl.resourceTypeName);
|
|
216
|
+
if (message !== undefined) {
|
|
217
|
+
return (0, ts_utils_1.failWithDetail)(`${id}: unable to set resource type\n${message}`, 'type-mismatch');
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const candidates = (_a = decl.candidates) !== null && _a !== void 0 ? _a : [];
|
|
221
|
+
return (0, ts_utils_1.mapResults)(candidates.map((c) => builder.addChildCandidate(c)))
|
|
222
|
+
.onSuccess(() => {
|
|
223
|
+
return (0, ts_utils_1.succeed)(builder);
|
|
224
|
+
})
|
|
225
|
+
.withDetail('failure', detail);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Gets a read-only array of all {@link Resources.ResourceBuilder | resource builders} present in the manager.
|
|
229
|
+
* @returns `Success` with the {@link Resources.ResourceBuilder | resource builder} if successful,
|
|
230
|
+
* or `Failure` with an error message if not.
|
|
231
|
+
*/
|
|
232
|
+
getAllResources() {
|
|
233
|
+
return Array.from(this._resources.values()).sort((a, b) => a.id.localeCompare(b.id));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Gets a read-only array of all {@link Resources.ResourceCandidate | resource candidates} present in the manager.
|
|
237
|
+
*/
|
|
238
|
+
getAllCandidates() {
|
|
239
|
+
return this.getAllResources().flatMap((r) => r.candidates);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Gets an individual {@link Resources.Resource | built resource} from the manager.
|
|
243
|
+
* @param id - The {@link ResourceId | id} of the resource to get.
|
|
244
|
+
* @returns `Success` with the resource if successful, or `Failure` with an error message if not.
|
|
245
|
+
* @public
|
|
246
|
+
*/
|
|
247
|
+
getBuiltResource(id) {
|
|
248
|
+
return this._resources.validating
|
|
249
|
+
.get(id)
|
|
250
|
+
.onSuccess((builder) => this._builtResources.validating.getOrAdd(id, () => builder.build()));
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Validates a context declaration against the qualifiers managed by this resource manager.
|
|
254
|
+
* @param context - The context declaration to validate
|
|
255
|
+
* @returns Success with the validated context if successful, Failure otherwise
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
258
|
+
/* c8 ignore next 5 - functional code path tested but coverage intermittently missed */
|
|
259
|
+
validateContext(context) {
|
|
260
|
+
return Context.Convert.validatedContextDecl.convert(context, {
|
|
261
|
+
qualifiers: this.qualifiers
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Gets a read-only array of all {@link Resources.Resource | built resources} in the manager.
|
|
266
|
+
* @returns `Success` with an array of resources if successful, or `Failure` with an error message if not.
|
|
267
|
+
* @public
|
|
268
|
+
*/
|
|
269
|
+
getAllBuiltResources() {
|
|
270
|
+
return this.build().onSuccess((manager) => (0, ts_utils_1.succeed)(Array.from(manager._builtResources.values()).sort((a, b) => a.id.localeCompare(b.id))));
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Gets a read-only array of all {@link Resources.Resource | built resources} in the manager.
|
|
274
|
+
* @returns `Success` with an array of resources if successful, or `Failure` with an error message if not.
|
|
275
|
+
* @public
|
|
276
|
+
*/
|
|
277
|
+
getAllBuiltCandidates() {
|
|
278
|
+
return this.getAllBuiltResources().onSuccess((built) => (0, ts_utils_1.succeed)(built.flatMap((r) => r.candidates)));
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Internal helper method that performs the actual building of resources.
|
|
282
|
+
* @returns `Success` with the built resources if all resources were built successfully, `Failure` otherwise.
|
|
283
|
+
* @internal
|
|
284
|
+
*/
|
|
285
|
+
_performBuild() {
|
|
286
|
+
if (this._built) {
|
|
287
|
+
return (0, ts_utils_1.succeed)(this._builtResources);
|
|
288
|
+
}
|
|
289
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
290
|
+
this._resources.forEach((r, id) => {
|
|
291
|
+
this._builtResources.getOrAdd(id, () => r.build()).aggregateError(errors);
|
|
292
|
+
});
|
|
293
|
+
/* c8 ignore next 3 - defense in depth against internal error */
|
|
294
|
+
if (errors.hasMessages) {
|
|
295
|
+
return (0, ts_utils_1.fail)(`build failed: ${errors.toString()}`);
|
|
296
|
+
}
|
|
297
|
+
this._built = true;
|
|
298
|
+
return (0, ts_utils_1.succeed)(this._builtResources);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Builds the {@link Resources.Resource | resources} from the collected {@link Resources.ResourceCandidate | candidates}.
|
|
302
|
+
* @returns `Success` with the {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object if successful,
|
|
303
|
+
* or `Failure` with an error message if not.
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
build() {
|
|
307
|
+
return this._performBuild().onSuccess(() => (0, ts_utils_1.succeed)(this));
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Gets a read-only array of all {@link Resources.ResourceCandidate | resource candidates} that can match the supplied context.
|
|
311
|
+
* @param context - The {@link Context.IValidatedContextDecl | context} to match against.
|
|
312
|
+
* @param options - {@link Context.IContextMatchOptions | options} for the context match.
|
|
313
|
+
* @returns A read-only array of {@link Resources.ResourceCandidate | candidates} that can match the context.
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
getCandidatesForContext(context, options) {
|
|
317
|
+
return this.getAllCandidates().filter((candidate) => candidate.canMatchPartialContext(context, options));
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Gets a read-only array of all {@link Resources.ResourceBuilder | resource builders} that have at least one candidate
|
|
321
|
+
* that can match the supplied context.
|
|
322
|
+
* @param context - The {@link Context.IValidatedContextDecl | context} to match against.
|
|
323
|
+
* @param options - {@link Context.IContextMatchOptions | options} for the context match.
|
|
324
|
+
* @returns A read-only array of {@link Resources.ResourceBuilder | resource builders} with matching candidates.
|
|
325
|
+
* @public
|
|
326
|
+
*/
|
|
327
|
+
getResourcesForContext(context, options) {
|
|
328
|
+
return this.getAllResources().filter((resource) => resource.getCandidatesForContext(context, options).length > 0);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Gets a read-only array of all {@link Resources.ResourceCandidate | built resource candidates} that can match the supplied context.
|
|
332
|
+
* @param context - The {@link Context.IValidatedContextDecl | context} to match against.
|
|
333
|
+
* @param options - {@link Context.IContextMatchOptions | options} for the context match.
|
|
334
|
+
* @returns `Success` with an array of {@link Resources.ResourceCandidate | candidates} if successful, or `Failure` with an error message if not.
|
|
335
|
+
* @public
|
|
336
|
+
*/
|
|
337
|
+
getBuiltCandidatesForContext(context, options) {
|
|
338
|
+
return this.getAllBuiltCandidates().onSuccess((candidates) => (0, ts_utils_1.succeed)(candidates.filter((candidate) => candidate.canMatchPartialContext(context, options))));
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Gets a read-only array of all {@link Resources.Resource | built resources} that have at least one candidate
|
|
342
|
+
* that can match the supplied context.
|
|
343
|
+
* @param context - The {@link Context.IValidatedContextDecl | context} to match against.
|
|
344
|
+
* @param options - {@link Context.IContextMatchOptions | options} for the context match.
|
|
345
|
+
* @returns `Success` with an array of {@link Resources.Resource | resources} if successful, or `Failure` with an error message if not.
|
|
346
|
+
* @public
|
|
347
|
+
*/
|
|
348
|
+
getBuiltResourcesForContext(context, options) {
|
|
349
|
+
return this.getAllBuiltResources().onSuccess((resources) => (0, ts_utils_1.succeed)(resources.filter((resource) => resource.getCandidatesForContext(context, options).length > 0)));
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Gets a compiled resource collection from the current state of the resource manager builder.
|
|
353
|
+
* This method generates an optimized, index-based representation of all resources, conditions,
|
|
354
|
+
* and decisions that can be used for serialization or efficient runtime processing.
|
|
355
|
+
* @param options - Optional compilation options controlling the output format.
|
|
356
|
+
* @returns Success with the compiled resource collection if successful, Failure otherwise.
|
|
357
|
+
* @public
|
|
358
|
+
*/
|
|
359
|
+
getCompiledResourceCollection(options) {
|
|
360
|
+
// Build resources first to ensure all data is available
|
|
361
|
+
const buildResult = this._performBuild();
|
|
362
|
+
if (buildResult.isFailure()) {
|
|
363
|
+
return (0, ts_utils_1.fail)(`Failed to build resources: ${buildResult.message}`);
|
|
364
|
+
}
|
|
365
|
+
// Generate compiled data from internal collections using the new toCompiled methods
|
|
366
|
+
// Note: All objects have a defined index property due to the collector pattern - indices are assigned during collection building
|
|
367
|
+
const compiledData = {
|
|
368
|
+
qualifierTypes: Array.from(this.qualifiers.qualifierTypes.values()).map((qt) => ({
|
|
369
|
+
name: qt.name
|
|
370
|
+
})),
|
|
371
|
+
qualifiers: Array.from(this.qualifiers.values()).map((q) => ({
|
|
372
|
+
name: q.name,
|
|
373
|
+
type: q.type.index,
|
|
374
|
+
defaultPriority: q.defaultPriority
|
|
375
|
+
})),
|
|
376
|
+
resourceTypes: Array.from(this.resourceTypes.values()).map((rt) => ({
|
|
377
|
+
name: rt.key
|
|
378
|
+
})),
|
|
379
|
+
conditions: Array.from(this._conditions.values()).map((c) => c.toCompiled(options)),
|
|
380
|
+
conditionSets: Array.from(this._conditionSets.values()).map((cs) => cs.toCompiled(options)),
|
|
381
|
+
decisions: Array.from(this._decisions.values()).map((d) => d.toCompiled(options)),
|
|
382
|
+
resources: Array.from(this._builtResources.values()).map((r) => r.toCompiled(options))
|
|
383
|
+
};
|
|
384
|
+
// Apply validation through the converter
|
|
385
|
+
return ResourceJson.Compiled.Convert.compiledResourceCollection.convert(compiledData);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Gets a resource collection declaration containing all built resources in a flat array structure.
|
|
389
|
+
* This method returns all built resources as an {@link ResourceJson.Normalized.IResourceCollectionDecl | IResourceCollectionDecl}
|
|
390
|
+
* that can be used for serialization, export, or re-import. Resources are sorted by ID for consistent ordering.
|
|
391
|
+
* @param options - Optional {@link Resources.IResourceDeclarationOptions | declaration options} controlling the output format.
|
|
392
|
+
* If `options.normalized` is `true`, applies hash-based normalization for additional consistency guarantees.
|
|
393
|
+
* @returns Success with the resource collection declaration if successful, Failure otherwise.
|
|
394
|
+
* @public
|
|
395
|
+
*/
|
|
396
|
+
getResourceCollectionDecl(options) {
|
|
397
|
+
return this._performBuild().onSuccess(() => {
|
|
398
|
+
// Get all built resources and convert to loose resource declarations
|
|
399
|
+
const resources = Array.from(this._builtResources.values()).map((resource) => resource.toLooseResourceDecl(options));
|
|
400
|
+
// Sort resources by ID for consistent ordering
|
|
401
|
+
resources.sort((a, b) => a.id.localeCompare(b.id));
|
|
402
|
+
// Create the collection declaration structure
|
|
403
|
+
const collectionData = {
|
|
404
|
+
resources
|
|
405
|
+
};
|
|
406
|
+
// Convert and validate using the normalized converter
|
|
407
|
+
return ResourceJson.Convert.resourceCollectionDecl
|
|
408
|
+
.convert(collectionData)
|
|
409
|
+
.onSuccess((compiledCollection) => {
|
|
410
|
+
// Apply hash-based normalization only if requested
|
|
411
|
+
if ((options === null || options === void 0 ? void 0 : options.normalized) === true) {
|
|
412
|
+
const normalizer = new ts_utils_1.Hash.Crc32Normalizer();
|
|
413
|
+
return normalizer
|
|
414
|
+
.normalize(compiledCollection)
|
|
415
|
+
.withErrorFormat((e) => `Failed to normalize resource collection: ${e}`);
|
|
416
|
+
}
|
|
417
|
+
return (0, ts_utils_1.succeed)(compiledCollection);
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Creates a filtered clone of this ResourceManagerBuilder using the specified context.
|
|
423
|
+
* This is a convenience method that creates a new ResourceManagerBuilder with the same
|
|
424
|
+
* configuration but filtered to include only candidates that match the provided context.
|
|
425
|
+
* @param options - Options for the cloning operation, including the strongly-typed filterForContext property.
|
|
426
|
+
* @returns A Result containing the new filtered ResourceManagerBuilder.
|
|
427
|
+
* @public
|
|
428
|
+
*/
|
|
429
|
+
/* c8 ignore next 21 - functional code path tested but coverage intermittently missed */
|
|
430
|
+
clone(options) {
|
|
431
|
+
return this.getResourceCollectionDecl(options).onSuccess((collection) => {
|
|
432
|
+
return ResourceManagerBuilder.create({
|
|
433
|
+
qualifiers: this.qualifiers,
|
|
434
|
+
resourceTypes: this.resourceTypes
|
|
435
|
+
}).onSuccess((newManager) => {
|
|
436
|
+
// Add each resource from the filtered collection to the new manager
|
|
437
|
+
if (collection.resources) {
|
|
438
|
+
for (const resourceDecl of collection.resources) {
|
|
439
|
+
const addResult = newManager.addResource(resourceDecl);
|
|
440
|
+
if (addResult.isFailure()) {
|
|
441
|
+
return (0, ts_utils_1.fail)(`${resourceDecl.id}: Failed to add resource to cloned manager: ${addResult.message}`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return (0, ts_utils_1.succeed)(newManager);
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
exports.ResourceManagerBuilder = ResourceManagerBuilder;
|
|
451
|
+
//# sourceMappingURL=resourceManagerBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceManagerBuilder.js","sourceRoot":"","sources":["../../../src/packlets/resources/resourceManagerBuilder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAauB;AACvB,8CAKuB;AACvB,4CAA4F;AAG5F,sCAA0D;AAE1D,uDAAiF;AACjF,yCAAsC;AAGtC,+DAAiD;AACjD,oDAAsC;AAmBtC;;;;;;GAMG;AACH,MAAa,sBAAsB;IAYjC;;;;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;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAOD;;OAEG;IACH,IAAW,aAAa;QACtB,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC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C,CAAC;wBACvD,IAAI,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC;4BAC1B,OAAO,IAAA,eAAI,EACT,GAAG,YAAY,CAAC,EAAE,+CAA+C,SAAS,CAAC,OAAO,EAAE,CACrF,CAAC;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,OAAO,IAAA,kBAAO,EAAC,UAAU,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAvdD,wDAudC","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 Hash,\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 { IResourceManager } from '../runtime';\nimport { ResourceBuilder, ResourceBuilderResultDetail } from './resourceBuilder';\nimport { Resource } from './resource';\nimport { ResourceCandidate } from './resourceCandidate';\nimport { IResourceDeclarationOptions } from './common';\nimport * as ResourceJson from '../resource-json';\nimport * as Context from '../context';\n\n/**\n * Interface for parameters to the {@link Resources.ResourceManagerBuilder.create | ResourceManagerBuilder create method}.\n * @public\n */\nexport interface IResourceManagerBuilderCreateParams {\n qualifiers: IReadOnlyQualifierCollector;\n resourceTypes: ReadOnlyResourceTypeCollector;\n}\n\n/**\n * Error details that can be returned by a {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder}.\n * @public\n */\nexport type ResourceManagerBuilderResultDetail =\n | Collections.ResultMapResultDetail\n | ResourceBuilderResultDetail;\n\n/**\n * Builder 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 ResourceManagerBuilder implements IResourceManager {\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 public readonly _builtResources: ValidatingResultMap<ResourceId, Resource>;\n\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 * {@inheritdoc Runtime.IResourceManager.numResources}\n */\n public get numResources(): number {\n return this._resources.size;\n }\n\n /**\n * The number of candidates in this resource manager.\n */\n protected _numCandidates?: number;\n\n /**\n * {@inheritdoc Runtime.IResourceManager.numCandidates}\n */\n public get numCandidates(): number {\n if (this._numCandidates === undefined) {\n this._numCandidates = this.getAllCandidates().length;\n }\n return this._numCandidates;\n }\n\n /**\n * {@inheritdoc Runtime.IResourceManager.builtResources}\n */\n public get builtResources(): Collections.IReadOnlyValidatingResultMap<ResourceId, Resource> {\n return this._performBuild().orThrow();\n }\n\n /**\n * Constructor for a {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object.\n * @param params - Parameters to create a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder}.\n * @public\n */\n protected constructor(params: IResourceManagerBuilderCreateParams) {\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.ResourceManagerBuilder | ResourceManagerBuilder} object.\n * @param params - Parameters to create a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder}.\n * @returns `Success` with the new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IResourceManagerBuilderCreateParams): Result<ResourceManagerBuilder> {\n return captureResult(() => new ResourceManagerBuilder(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, ResourceBuilderResultDetail> {\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 decisions: this._decisions\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 this._numCandidates = undefined;\n return succeedWithDetail(c, d);\n });\n }\n\n public addResource(\n decl: ResourceJson.Json.ILooseResourceDecl\n ): DetailedResult<ResourceBuilder, ResourceBuilderResultDetail> {\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 decisions: this._decisions\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 a read-only array of all {@link Resources.ResourceBuilder | resource builders} present in the manager.\n * @returns `Success` with the {@link Resources.ResourceBuilder | resource builder} if successful,\n * or `Failure` with an error message if not.\n */\n public getAllResources(): ReadonlyArray<ResourceBuilder> {\n return Array.from(this._resources.values()).sort((a, b) => a.id.localeCompare(b.id));\n }\n\n /**\n * Gets a read-only array of all {@link Resources.ResourceCandidate | resource candidates} present in the manager.\n */\n public getAllCandidates(): ReadonlyArray<ResourceCandidate> {\n return this.getAllResources().flatMap((r) => r.candidates);\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 * Validates a context declaration against the qualifiers managed by this resource manager.\n * @param context - The context declaration to validate\n * @returns Success with the validated context if successful, Failure otherwise\n * @public\n */\n /* c8 ignore next 5 - functional code path tested but coverage intermittently missed */\n public validateContext(context: Context.IContextDecl): Result<Context.IValidatedContextDecl> {\n return Context.Convert.validatedContextDecl.convert(context, {\n qualifiers: this.qualifiers\n });\n }\n\n /**\n * Gets a read-only array of all {@link Resources.Resource | built resources} in the manager.\n * @returns `Success` with an array of resources if successful, or `Failure` with an error message if not.\n * @public\n */\n public getAllBuiltResources(): Result<ReadonlyArray<Resource>> {\n return this.build().onSuccess((manager) =>\n succeed(Array.from(manager._builtResources.values()).sort((a, b) => a.id.localeCompare(b.id)))\n );\n }\n\n /**\n * Gets a read-only array of all {@link Resources.Resource | built resources} in the manager.\n * @returns `Success` with an array of resources if successful, or `Failure` with an error message if not.\n * @public\n */\n public getAllBuiltCandidates(): Result<ReadonlyArray<ResourceCandidate>> {\n return this.getAllBuiltResources().onSuccess((built) => succeed(built.flatMap((r) => r.candidates)));\n }\n\n /**\n * Internal helper method that performs the actual building of resources.\n * @returns `Success` with the built resources if all resources were built successfully, `Failure` otherwise.\n * @internal\n */\n public _performBuild(): Result<Collections.IReadOnlyValidatingResultMap<ResourceId, Resource>> {\n if (this._built) {\n return succeed(this._builtResources);\n }\n\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 return succeed(this._builtResources);\n }\n\n /**\n * Builds the {@link Resources.Resource | resources} from the collected {@link Resources.ResourceCandidate | candidates}.\n * @returns `Success` with the {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public build(): Result<this> {\n return this._performBuild().onSuccess(() => succeed(this));\n }\n\n /**\n * Gets a read-only array of all {@link Resources.ResourceCandidate | resource candidates} that can match the supplied context.\n * @param context - The {@link Context.IValidatedContextDecl | context} to match against.\n * @param options - {@link Context.IContextMatchOptions | options} for the context match.\n * @returns A read-only array of {@link Resources.ResourceCandidate | candidates} that can match the context.\n * @public\n */\n public getCandidatesForContext(\n context: Context.IValidatedContextDecl,\n options?: Context.IContextMatchOptions\n ): ReadonlyArray<ResourceCandidate> {\n return this.getAllCandidates().filter((candidate) => candidate.canMatchPartialContext(context, options));\n }\n\n /**\n * Gets a read-only array of all {@link Resources.ResourceBuilder | resource builders} that have at least one candidate\n * that can match the supplied context.\n * @param context - The {@link Context.IValidatedContextDecl | context} to match against.\n * @param options - {@link Context.IContextMatchOptions | options} for the context match.\n * @returns A read-only array of {@link Resources.ResourceBuilder | resource builders} with matching candidates.\n * @public\n */\n public getResourcesForContext(\n context: Context.IValidatedContextDecl,\n options?: Context.IContextMatchOptions\n ): ReadonlyArray<ResourceBuilder> {\n return this.getAllResources().filter(\n (resource) => resource.getCandidatesForContext(context, options).length > 0\n );\n }\n\n /**\n * Gets a read-only array of all {@link Resources.ResourceCandidate | built resource candidates} that can match the supplied context.\n * @param context - The {@link Context.IValidatedContextDecl | context} to match against.\n * @param options - {@link Context.IContextMatchOptions | options} for the context match.\n * @returns `Success` with an array of {@link Resources.ResourceCandidate | candidates} if successful, or `Failure` with an error message if not.\n * @public\n */\n public getBuiltCandidatesForContext(\n context: Context.IValidatedContextDecl,\n options?: Context.IContextMatchOptions\n ): Result<ReadonlyArray<ResourceCandidate>> {\n return this.getAllBuiltCandidates().onSuccess((candidates) =>\n succeed(candidates.filter((candidate) => candidate.canMatchPartialContext(context, options)))\n );\n }\n\n /**\n * Gets a read-only array of all {@link Resources.Resource | built resources} that have at least one candidate\n * that can match the supplied context.\n * @param context - The {@link Context.IValidatedContextDecl | context} to match against.\n * @param options - {@link Context.IContextMatchOptions | options} for the context match.\n * @returns `Success` with an array of {@link Resources.Resource | resources} if successful, or `Failure` with an error message if not.\n * @public\n */\n public getBuiltResourcesForContext(\n context: Context.IValidatedContextDecl,\n options?: Context.IContextMatchOptions\n ): Result<ReadonlyArray<Resource>> {\n return this.getAllBuiltResources().onSuccess((resources) =>\n succeed(resources.filter((resource) => resource.getCandidatesForContext(context, options).length > 0))\n );\n }\n\n /**\n * Gets a compiled resource collection from the current state of the resource manager builder.\n * This method generates an optimized, index-based representation of all resources, conditions,\n * and decisions that can be used for serialization or efficient runtime processing.\n * @param options - Optional compilation options controlling the output format.\n * @returns Success with the compiled resource collection if successful, Failure otherwise.\n * @public\n */\n public getCompiledResourceCollection(\n options?: ResourceJson.Compiled.ICompiledResourceOptions\n ): Result<ResourceJson.Compiled.ICompiledResourceCollection> {\n // Build resources first to ensure all data is available\n const buildResult = this._performBuild();\n if (buildResult.isFailure()) {\n return fail(`Failed to build resources: ${buildResult.message}`);\n }\n\n // Generate compiled data from internal collections using the new toCompiled methods\n // Note: All objects have a defined index property due to the collector pattern - indices are assigned during collection building\n const compiledData = {\n qualifierTypes: Array.from(this.qualifiers.qualifierTypes.values()).map((qt) => ({\n name: qt.name\n })),\n qualifiers: Array.from(this.qualifiers.values()).map((q) => ({\n name: q.name,\n type: q.type.index!,\n defaultPriority: q.defaultPriority\n })),\n resourceTypes: Array.from(this.resourceTypes.values()).map((rt) => ({\n name: rt.key\n })),\n conditions: Array.from(this._conditions.values()).map((c) => c.toCompiled(options)),\n conditionSets: Array.from(this._conditionSets.values()).map((cs) => cs.toCompiled(options)),\n decisions: Array.from(this._decisions.values()).map((d) => d.toCompiled(options)),\n resources: Array.from(this._builtResources.values()).map((r) => r.toCompiled(options))\n };\n\n // Apply validation through the converter\n return ResourceJson.Compiled.Convert.compiledResourceCollection.convert(compiledData);\n }\n\n /**\n * Gets a resource collection declaration containing all built resources in a flat array structure.\n * This method returns all built resources as an {@link ResourceJson.Normalized.IResourceCollectionDecl | IResourceCollectionDecl}\n * that can be used for serialization, export, or re-import. Resources are sorted by ID for consistent ordering.\n * @param options - Optional {@link Resources.IResourceDeclarationOptions | declaration options} controlling the output format.\n * If `options.normalized` is `true`, applies hash-based normalization for additional consistency guarantees.\n * @returns Success with the resource collection declaration if successful, Failure otherwise.\n * @public\n */\n public getResourceCollectionDecl(\n options?: IResourceDeclarationOptions\n ): Result<ResourceJson.Normalized.IResourceCollectionDecl> {\n return this._performBuild().onSuccess(() => {\n // Get all built resources and convert to loose resource declarations\n const resources = Array.from(this._builtResources.values()).map((resource) =>\n resource.toLooseResourceDecl(options)\n );\n\n // Sort resources by ID for consistent ordering\n resources.sort((a, b) => a.id.localeCompare(b.id));\n\n // Create the collection declaration structure\n const collectionData = {\n resources\n };\n\n // Convert and validate using the normalized converter\n return ResourceJson.Convert.resourceCollectionDecl\n .convert(collectionData)\n .onSuccess((compiledCollection) => {\n // Apply hash-based normalization only if requested\n if (options?.normalized === true) {\n const normalizer = new Hash.Crc32Normalizer();\n return normalizer\n .normalize(compiledCollection)\n .withErrorFormat((e) => `Failed to normalize resource collection: ${e}`);\n }\n return succeed(compiledCollection);\n });\n });\n }\n\n /**\n * Creates a filtered clone of this ResourceManagerBuilder using the specified context.\n * This is a convenience method that creates a new ResourceManagerBuilder with the same\n * configuration but filtered to include only candidates that match the provided context.\n * @param options - Options for the cloning operation, including the strongly-typed filterForContext property.\n * @returns A Result containing the new filtered ResourceManagerBuilder.\n * @public\n */\n /* c8 ignore next 21 - functional code path tested but coverage intermittently missed */\n public clone(options?: IResourceDeclarationOptions): Result<ResourceManagerBuilder> {\n return this.getResourceCollectionDecl(options).onSuccess((collection) => {\n return ResourceManagerBuilder.create({\n qualifiers: this.qualifiers,\n resourceTypes: this.resourceTypes\n }).onSuccess((newManager) => {\n // Add each resource from the filtered collection to the new manager\n if (collection.resources) {\n for (const resourceDecl of collection.resources) {\n const addResult = newManager.addResource(resourceDecl);\n if (addResult.isFailure()) {\n return fail(\n `${resourceDecl.id}: Failed to add resource to cloned manager: ${addResult.message}`\n );\n }\n }\n }\n return succeed(newManager);\n });\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type indicating which {@link Runtime.ResourceResolver | ResourceResolver} cache is affected.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export type ResourceResolverCacheType = 'condition' | 'conditionSet' | 'decision';
|
|
6
|
+
/**
|
|
7
|
+
* Type indicating the action performed on a {@link Runtime.ResourceResolver | ResourceResolver} cache.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type ResourceResolverCacheActivity = 'hit' | 'miss' | 'error' | 'clear';
|
|
11
|
+
/**
|
|
12
|
+
* A listener for {@link Runtime.ResourceResolver | ResourceResolver} cache activity.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface IResourceResolverCacheListener {
|
|
16
|
+
/**
|
|
17
|
+
* Called when a cache hit occurs.
|
|
18
|
+
* @param cache - The type of cache that was hit.
|
|
19
|
+
* @param index - The index of the cache that was hit.
|
|
20
|
+
*/
|
|
21
|
+
onCacheHit(cache: ResourceResolverCacheType, index: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Called when a cache miss occurs.
|
|
24
|
+
* @param cache - The type of cache that was missed.
|
|
25
|
+
* @param index - The index of the cache that was missed.
|
|
26
|
+
*/
|
|
27
|
+
onCacheMiss(cache: ResourceResolverCacheType, index: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* Called when a cache error occurs.
|
|
30
|
+
* @param cache - The type of cache that had an error.
|
|
31
|
+
* @param index - The index of the cache that had an error.
|
|
32
|
+
*/
|
|
33
|
+
onCacheError(cache: ResourceResolverCacheType, index: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* Called when a cache is cleared.
|
|
36
|
+
* @param cache - The type of cache that was cleared.
|
|
37
|
+
*/
|
|
38
|
+
onCacheClear(cache: ResourceResolverCacheType): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A no-op implementation of {@link Runtime.IResourceResolverCacheListener}.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare class NoOpResourceResolverCacheListener implements IResourceResolverCacheListener {
|
|
45
|
+
/**
|
|
46
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheHit}
|
|
47
|
+
*/
|
|
48
|
+
onCacheHit(cache: ResourceResolverCacheType, index: number): void;
|
|
49
|
+
/**
|
|
50
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheMiss}
|
|
51
|
+
*/
|
|
52
|
+
onCacheMiss(cache: ResourceResolverCacheType, index: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheError}
|
|
55
|
+
*/
|
|
56
|
+
onCacheError(cache: ResourceResolverCacheType, index: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheClear}
|
|
59
|
+
*/
|
|
60
|
+
onCacheClear(cache: ResourceResolverCacheType): void;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=cacheListener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheListener.d.ts","sourceRoot":"","sources":["../../../src/packlets/runtime/cacheListener.ts"],"names":[],"mappings":"AAsBA;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,WAAW,GAAG,cAAc,GAAG,UAAU,CAAC;AAElF;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE/E;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAElE;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnE;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpE;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,yBAAyB,GAAG,IAAI,CAAC;CACtD;AAED;;;GAGG;AACH,qBAAa,iCAAkC,YAAW,8BAA8B;IACtF;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIxE;;OAEG;IACI,WAAW,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIzE;;OAEG;IACI,YAAY,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAI1E;;OAEG;IACI,YAAY,CAAC,KAAK,EAAE,yBAAyB,GAAG,IAAI;CAG5D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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.NoOpResourceResolverCacheListener = void 0;
|
|
25
|
+
/**
|
|
26
|
+
* A no-op implementation of {@link Runtime.IResourceResolverCacheListener}.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
class NoOpResourceResolverCacheListener {
|
|
30
|
+
/**
|
|
31
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheHit}
|
|
32
|
+
*/
|
|
33
|
+
onCacheHit(cache, index) {
|
|
34
|
+
// no-op
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheMiss}
|
|
38
|
+
*/
|
|
39
|
+
onCacheMiss(cache, index) {
|
|
40
|
+
// no-op
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheError}
|
|
44
|
+
*/
|
|
45
|
+
onCacheError(cache, index) {
|
|
46
|
+
// no-op
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheClear}
|
|
50
|
+
*/
|
|
51
|
+
onCacheClear(cache) {
|
|
52
|
+
// no-op
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.NoOpResourceResolverCacheListener = NoOpResourceResolverCacheListener;
|
|
56
|
+
//# sourceMappingURL=cacheListener.js.map
|