@fgv/ts-res 4.5.0-2 → 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 +4225 -324
- 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 +3 -2
- 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 +33 -32
- 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
|
@@ -55,6 +55,7 @@ class ResourceBuilder {
|
|
|
55
55
|
this.id = common_1.Validate.toResourceId(params.id).orThrow();
|
|
56
56
|
this._resourceTypes = params.resourceTypes;
|
|
57
57
|
this._conditionSets = params.conditionSets;
|
|
58
|
+
this._decisions = params.decisions;
|
|
58
59
|
this._candidates = new ts_utils_1.ResultMap();
|
|
59
60
|
if (params.typeName) {
|
|
60
61
|
this._resourceType = this._resourceTypes.validating.get(params.typeName).orThrow();
|
|
@@ -70,6 +71,15 @@ class ResourceBuilder {
|
|
|
70
71
|
static create(params) {
|
|
71
72
|
return (0, ts_utils_1.captureResult)(() => new ResourceBuilder(params));
|
|
72
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets the {@link Resources.ResourceCandidate | candidates} that match a given {@link Context.IValidatedContextDecl | context}.
|
|
76
|
+
* @param context - The {@link Context.IValidatedContextDecl | context} to get candidates for.
|
|
77
|
+
* @param options - Optional {@link Context.IContextMatchOptions | context match options} to use when matching candidates.
|
|
78
|
+
* @returns An array of {@link Resources.ResourceCandidate | candidates} that match the given context.
|
|
79
|
+
*/
|
|
80
|
+
getCandidatesForContext(context, options) {
|
|
81
|
+
return Array.from(this._candidates.values()).filter((candidate) => candidate.canMatchPartialContext(context, options));
|
|
82
|
+
}
|
|
73
83
|
/**
|
|
74
84
|
* Given a {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}, creates and adds a
|
|
75
85
|
* {@link Resources.ResourceCandidate | candidate} to the resource being built.
|
|
@@ -111,6 +121,7 @@ class ResourceBuilder {
|
|
|
111
121
|
* existing candidate if the candidate to be added is identical to an existing candidate.
|
|
112
122
|
*/
|
|
113
123
|
addLooseCandidate(decl) {
|
|
124
|
+
/* c8 ignore next 6 - functional code path tested but coverage intermittently missed */
|
|
114
125
|
if (decl.id !== this.id) {
|
|
115
126
|
return (0, ts_utils_1.failWithDetail)(`${this.id}: mismatched candidate id ${decl.id}.`, 'id-mismatch');
|
|
116
127
|
}
|
|
@@ -149,13 +160,20 @@ class ResourceBuilder {
|
|
|
149
160
|
* or if the resource type is not defined.
|
|
150
161
|
*/
|
|
151
162
|
build() {
|
|
163
|
+
/* c8 ignore next 3 - functional code path tested but coverage intermittently missed */
|
|
152
164
|
if (this._candidates.size === 0) {
|
|
153
165
|
return (0, ts_utils_1.fail)(`${this.id}: no candidates supplied.`);
|
|
154
166
|
}
|
|
167
|
+
/* c8 ignore next 3 - functional code path tested but coverage intermittently missed */
|
|
155
168
|
if (this._resourceType === undefined) {
|
|
156
169
|
return (0, ts_utils_1.fail)(`${this.id}: no resource type supplied or inferred.`);
|
|
157
170
|
}
|
|
158
|
-
return resource_1.Resource.create({
|
|
171
|
+
return resource_1.Resource.create({
|
|
172
|
+
id: this.id,
|
|
173
|
+
resourceType: this._resourceType,
|
|
174
|
+
candidates: this.candidates,
|
|
175
|
+
decisions: this._decisions
|
|
176
|
+
});
|
|
159
177
|
}
|
|
160
178
|
}
|
|
161
179
|
exports.ResourceBuilder = ResourceBuilder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceBuilder.js","sourceRoot":"","sources":["../../../src/packlets/resources/resourceBuilder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAUuB;AACvB,sCAAiD;AACjD,2DAAwD;AAExD,yCAAsC;AAsBtC;;;;;GAKG;AACH,MAAa,eAAe;IAM1B;;;;OAIG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,qCAAiB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;IACzF,CAAC;IAuBD;;;OAGG;IACH,YAAsB,MAAoC;QACxD,IAAI,CAAC,EAAE,GAAG,iBAAQ,CAAC,YAAY,CAAC,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C,CAAC,YAAY,EAAE,EAAE;YACrF,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;YAClC,OAAO,IAAA,4BAAiB,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK;QACV,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO,IAAA,eAAI,EAAC,GAAG,IAAI,CAAC,EAAE,2BAA2B,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,IAAA,eAAI,EAAC,GAAG,IAAI,CAAC,EAAE,0CAA0C,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,mBAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACzG,CAAC;CACF;AA3KD,0CA2KC","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 Collections,\n DetailedResult,\n Result,\n ResultMap,\n captureResult,\n fail,\n failWithDetail,\n succeed,\n succeedWithDetail\n} from '@fgv/ts-utils';\nimport { ResourceId, Validate } from '../common';\nimport { ResourceCandidate } from './resourceCandidate';\nimport { ReadOnlyResourceTypeCollector, ResourceType } from '../resource-types';\nimport { Resource } from './resource';\nimport { ConditionSetCollector } from '../conditions';\nimport * as ResourceJson from '../resource-json';\n\n/**\n * Parameters for creating a {@link Resources.ResourceBuilder}.\n * @public\n */\nexport interface IResourceBuilderCreateParams {\n id: string;\n typeName?: string;\n conditionSets: ConditionSetCollector;\n resourceTypes: ReadOnlyResourceTypeCollector;\n}\n\n/**\n * Possible result details returned by the resource builder\n * {@link Resources.ResourceBuilder.addLooseCandidate | addLooseCandidate} method.\n * @public\n */\nexport type ResourceBuilderResultDetail = Collections.ResultMapResultDetail | 'id-mismatch' | 'type-mismatch';\n\n/**\n * Represents a builder for a single logical {@link Resources.Resource | resource}. Collects candidates\n * with a common resource ID, validates them against each other and builds a {@link Resources.Resource | resource}\n * object once all candidates are collected.\n * @public\n */\nexport class ResourceBuilder {\n /**\n * The unique {@link ResourceId | id} of the resource being built.\n */\n public readonly id: ResourceId;\n\n /**\n * Supplied or inferred {@link ResourceTypes.ResourceType | type} of the resource being built.\n * If no type is supplied, the type will be inferred from the candidates - at least one candidate must\n * define resource type and all candidates must be of the same type.\n */\n public get resourceType(): ResourceType | undefined {\n return this._resourceType;\n }\n\n /**\n * Array of {@link Resources.ResourceCandidate | candidates} for the resource being built.\n */\n public get candidates(): ReadonlyArray<ResourceCandidate> {\n return Array.from(this._candidates.values()).sort(ResourceCandidate.compare).reverse();\n }\n\n /**\n * The supplied or inferred {@link ResourceTypes.ResourceType | type} of the resource\n * being built.\n */\n protected _resourceType: ResourceType | undefined;\n\n /**\n * Map of {@link Resources.ResourceCandidate | candidates} for the resource being built.\n */\n protected _candidates: ResultMap<string, ResourceCandidate>;\n\n /**\n * Map of all known {@link ResourceTypes.ResourceType | resource types}.\n */\n protected _resourceTypes: ReadOnlyResourceTypeCollector;\n\n /**\n * Common collector for {@link Conditions.ConditionSet | condition sets}.\n */\n protected _conditionSets: ConditionSetCollector;\n\n /**\n * Constructor for a {@link Resources.ResourceBuilder | ResourceBuilder} object.\n * @param params - Parameters to construct the new {@link Resources.ResourceBuilder | ResourceBuilder}.\n */\n protected constructor(params: IResourceBuilderCreateParams) {\n this.id = Validate.toResourceId(params.id).orThrow();\n this._resourceTypes = params.resourceTypes;\n this._conditionSets = params.conditionSets;\n this._candidates = new ResultMap<string, ResourceCandidate>();\n if (params.typeName) {\n this._resourceType = this._resourceTypes.validating.get(params.typeName).orThrow();\n }\n }\n\n /**\n * Creates a new {@link Resources.ResourceBuilder | ResourceBuilder} object.\n * @param params - Parameters to create a new {@link Resources.ResourceBuilder | ResourceBuilder}.\n * @returns `Success` with the new {@link Resources.ResourceBuilder | ResourceBuilder} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IResourceBuilderCreateParams): Result<ResourceBuilder> {\n return captureResult(() => new ResourceBuilder(params));\n }\n\n /**\n * Given a {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}, creates and adds a\n * {@link Resources.ResourceCandidate | candidate} to the resource being built.\n * @param candidate - The {@link ResourceJson.Json.IChildResourceCandidateDecl | IChildResourceCandidateDecl} to add to the\n * resource being built.\n * @returns `Success` with the added {@link Resources.ResourceCandidate | candidate} if successful,\n * or `Failure` with an error message if not.\n */\n public addChildCandidate(\n childDecl: ResourceJson.Json.IChildResourceCandidateDecl\n ): DetailedResult<ResourceCandidate, ResourceBuilderResultDetail> {\n return ResourceCandidate.create({\n id: this.id,\n resourceType: this._resourceType,\n decl: childDecl,\n conditionSets: this._conditionSets\n })\n .withDetail<ResourceBuilderResultDetail>('failure', 'success')\n .onSuccess((candidate) => {\n return this._candidates\n .getOrAdd(candidate.conditions.toString(), candidate)\n .onSuccess((added, detail) => {\n if (detail === 'exists') {\n if (!ResourceCandidate.equal(added, candidate)) {\n return failWithDetail<ResourceCandidate, Collections.ResultMapResultDetail>(\n `${this.id}: conflicting candidates.`,\n 'exists'\n );\n }\n }\n return succeedWithDetail(added, detail);\n });\n });\n }\n\n /**\n * Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, creates and adds a\n * {@link Resources.ResourceCandidate | candidate} to the resource being built.\n * @param candidate - The {@link ResourceJson.Json.ILooseResourceCandidateDecl | IResourceCandidateDecl} to add to the\n * resource being built.\n * @returns `Success` with the added {@link Resources.ResourceCandidate | candidate} if successful,\n * or `Failure` with an error message if not. Fails with error detail 'type-mismatch' if the candidate\n * specifies a different resource type than previously added candidates, or with 'exists' if a candidate\n * already exists with the same conditions but different values. Succeeds with 'exists' and returns the\n * existing candidate if the candidate to be added is identical to an existing candidate.\n */\n public addLooseCandidate(\n decl: ResourceJson.Json.ILooseResourceCandidateDecl\n ): DetailedResult<ResourceCandidate, ResourceBuilderResultDetail> {\n if (decl.id !== this.id) {\n return failWithDetail<ResourceCandidate, ResourceBuilderResultDetail>(\n `${this.id}: mismatched candidate id ${decl.id}.`,\n 'id-mismatch'\n );\n }\n\n if (decl.resourceTypeName !== undefined) {\n const rt = this.setResourceType(decl.resourceTypeName);\n if (rt.isFailure()) {\n return failWithDetail<ResourceCandidate, ResourceBuilderResultDetail>(rt.message, 'type-mismatch');\n }\n }\n\n return this.addChildCandidate(decl);\n }\n\n /**\n * Sets the resource type for the resource being built. Fails if a resource type has already been set\n * and it does not match the new resource type.\n * @param resourceTypeName - The name of the resource type to set.\n * @returns `Success` with the updated {@link Resources.ResourceBuilder | ResourceBuilder} object if successful,\n * or `Failure` with an error message if not.\n */\n public setResourceType(resourceTypeName: string): Result<ResourceBuilder> {\n if (this._resourceType?.key === resourceTypeName) {\n return succeed(this);\n } else if (this._resourceType !== undefined) {\n return fail(\n `${this.id}: conflicting resource types ${this._resourceType.key} !== ${resourceTypeName}.`\n );\n }\n return this._resourceTypes.validating.get(resourceTypeName).onSuccess((resourceType) => {\n this._resourceType = resourceType;\n return succeedWithDetail(this, 'success');\n });\n }\n\n /**\n * Builds the {@link Resources.Resource | resource} object from this builder.\n * @returns `Success` with the new {@link Resources.Resource | Resource} object if successful,\n * or `Failure` with an error message if not. Fails if no candidates have been added\n * or if the resource type is not defined.\n */\n public build(): Result<Resource> {\n if (this._candidates.size === 0) {\n return fail(`${this.id}: no candidates supplied.`);\n }\n\n if (this._resourceType === undefined) {\n return fail(`${this.id}: no resource type supplied or inferred.`);\n }\n return Resource.create({ id: this.id, resourceType: this._resourceType, candidates: this.candidates });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resourceBuilder.js","sourceRoot":"","sources":["../../../src/packlets/resources/resourceBuilder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAUuB;AACvB,sCAAiD;AACjD,2DAAwD;AAExD,yCAAsC;AAyBtC;;;;;GAKG;AACH,MAAa,eAAe;IAM1B;;;;OAIG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,qCAAiB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;IACzF,CAAC;IA4BD;;;OAGG;IACH,YAAsB,MAAoC;QACxD,IAAI,CAAC,EAAE,GAAG,iBAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,cAAc,GA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AAG,IAAI,CAAC,EAAE,gCAAgC,IAAI,CAAC,aAAa,CAAC,GAAG,QAAQ,gBAAgB,GAAG,CAC5F,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,EAAE;YACrF,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;YAClC,OAAO,IAAA,4BAAiB,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK;QACV,uFAAuF;QACvF,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO,IAAA,eAAI,EAAC,GAAG,IAAI,CAAC,EAAE,2BAA2B,CAAC,CAAC;QACrD,CAAC;QAED,uFAAuF;QACvF,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACrC,OAAO,IAAA,eAAI,EAAC,GAAG,IAAI,CAAC,EAAE,0CAA0C,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,mBAAQ,CAAC,MAAM,CAAC;YACrB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC,CAAC;IACL,CAAC;CACF;AAzMD,0CAyMC","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 Collections,\n DetailedResult,\n Result,\n ResultMap,\n captureResult,\n fail,\n failWithDetail,\n succeed,\n succeedWithDetail\n} from '@fgv/ts-utils';\nimport { ResourceId, Validate } from '../common';\nimport { ResourceCandidate } from './resourceCandidate';\nimport { ReadOnlyResourceTypeCollector, ResourceType } from '../resource-types';\nimport { Resource } from './resource';\nimport { ConditionSetCollector } from '../conditions';\nimport { AbstractDecisionCollector } from '../decisions';\nimport * as ResourceJson from '../resource-json';\nimport * as Context from '../context';\n\n/**\n * Parameters for creating a {@link Resources.ResourceBuilder}.\n * @public\n */\nexport interface IResourceBuilderCreateParams {\n id: string;\n typeName?: string;\n conditionSets: ConditionSetCollector;\n resourceTypes: ReadOnlyResourceTypeCollector;\n decisions: AbstractDecisionCollector;\n}\n\n/**\n * Possible result details returned by the resource builder\n * {@link Resources.ResourceBuilder.addLooseCandidate | addLooseCandidate} method.\n * @public\n */\nexport type ResourceBuilderResultDetail = Collections.ResultMapResultDetail | 'id-mismatch' | 'type-mismatch';\n\n/**\n * Represents a builder for a single logical {@link Resources.Resource | resource}. Collects candidates\n * with a common resource ID, validates them against each other and builds a {@link Resources.Resource | resource}\n * object once all candidates are collected.\n * @public\n */\nexport class ResourceBuilder {\n /**\n * The unique {@link ResourceId | id} of the resource being built.\n */\n public readonly id: ResourceId;\n\n /**\n * Supplied or inferred {@link ResourceTypes.ResourceType | type} of the resource being built.\n * If no type is supplied, the type will be inferred from the candidates - at least one candidate must\n * define resource type and all candidates must be of the same type.\n */\n public get resourceType(): ResourceType | undefined {\n return this._resourceType;\n }\n\n /**\n * Array of {@link Resources.ResourceCandidate | candidates} for the resource being built.\n */\n public get candidates(): ReadonlyArray<ResourceCandidate> {\n return Array.from(this._candidates.values()).sort(ResourceCandidate.compare).reverse();\n }\n\n /**\n * The supplied or inferred {@link ResourceTypes.ResourceType | type} of the resource\n * being built.\n */\n protected _resourceType: ResourceType | undefined;\n\n /**\n * Map of {@link Resources.ResourceCandidate | candidates} for the resource being built.\n */\n protected _candidates: ResultMap<string, ResourceCandidate>;\n\n /**\n * Map of all known {@link ResourceTypes.ResourceType | resource types}.\n */\n protected _resourceTypes: ReadOnlyResourceTypeCollector;\n\n /**\n * Common collector for {@link Conditions.ConditionSet | condition sets}.\n */\n protected _conditionSets: ConditionSetCollector;\n\n /**\n * Collector for {@link Decisions.AbstractDecision | abstract decisions}.\n */\n protected _decisions: AbstractDecisionCollector;\n\n /**\n * Constructor for a {@link Resources.ResourceBuilder | ResourceBuilder} object.\n * @param params - Parameters to construct the new {@link Resources.ResourceBuilder | ResourceBuilder}.\n */\n protected constructor(params: IResourceBuilderCreateParams) {\n this.id = Validate.toResourceId(params.id).orThrow();\n this._resourceTypes = params.resourceTypes;\n this._conditionSets = params.conditionSets;\n this._decisions = params.decisions;\n this._candidates = new ResultMap<string, ResourceCandidate>();\n if (params.typeName) {\n this._resourceType = this._resourceTypes.validating.get(params.typeName).orThrow();\n }\n }\n\n /**\n * Creates a new {@link Resources.ResourceBuilder | ResourceBuilder} object.\n * @param params - Parameters to create a new {@link Resources.ResourceBuilder | ResourceBuilder}.\n * @returns `Success` with the new {@link Resources.ResourceBuilder | ResourceBuilder} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IResourceBuilderCreateParams): Result<ResourceBuilder> {\n return captureResult(() => new ResourceBuilder(params));\n }\n\n /**\n * Gets the {@link Resources.ResourceCandidate | candidates} that match a given {@link Context.IValidatedContextDecl | context}.\n * @param context - The {@link Context.IValidatedContextDecl | context} to get candidates for.\n * @param options - Optional {@link Context.IContextMatchOptions | context match options} to use when matching candidates.\n * @returns An array of {@link Resources.ResourceCandidate | candidates} that match the given context.\n */\n public getCandidatesForContext(\n context: Context.IValidatedContextDecl,\n options?: Context.IContextMatchOptions\n ): ReadonlyArray<ResourceCandidate> {\n return Array.from(this._candidates.values()).filter((candidate) =>\n candidate.canMatchPartialContext(context, options)\n );\n }\n\n /**\n * Given a {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}, creates and adds a\n * {@link Resources.ResourceCandidate | candidate} to the resource being built.\n * @param candidate - The {@link ResourceJson.Json.IChildResourceCandidateDecl | IChildResourceCandidateDecl} to add to the\n * resource being built.\n * @returns `Success` with the added {@link Resources.ResourceCandidate | candidate} if successful,\n * or `Failure` with an error message if not.\n */\n public addChildCandidate(\n childDecl: ResourceJson.Json.IChildResourceCandidateDecl\n ): DetailedResult<ResourceCandidate, ResourceBuilderResultDetail> {\n return ResourceCandidate.create({\n id: this.id,\n resourceType: this._resourceType,\n decl: childDecl,\n conditionSets: this._conditionSets\n })\n .withDetail<ResourceBuilderResultDetail>('failure', 'success')\n .onSuccess((candidate) => {\n return this._candidates\n .getOrAdd(candidate.conditions.toString(), candidate)\n .onSuccess((added, detail) => {\n if (detail === 'exists') {\n if (!ResourceCandidate.equal(added, candidate)) {\n return failWithDetail<ResourceCandidate, Collections.ResultMapResultDetail>(\n `${this.id}: conflicting candidates.`,\n 'exists'\n );\n }\n }\n return succeedWithDetail(added, detail);\n });\n });\n }\n\n /**\n * Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, creates and adds a\n * {@link Resources.ResourceCandidate | candidate} to the resource being built.\n * @param candidate - The {@link ResourceJson.Json.ILooseResourceCandidateDecl | IResourceCandidateDecl} to add to the\n * resource being built.\n * @returns `Success` with the added {@link Resources.ResourceCandidate | candidate} if successful,\n * or `Failure` with an error message if not. Fails with error detail 'type-mismatch' if the candidate\n * specifies a different resource type than previously added candidates, or with 'exists' if a candidate\n * already exists with the same conditions but different values. Succeeds with 'exists' and returns the\n * existing candidate if the candidate to be added is identical to an existing candidate.\n */\n public addLooseCandidate(\n decl: ResourceJson.Json.ILooseResourceCandidateDecl\n ): DetailedResult<ResourceCandidate, ResourceBuilderResultDetail> {\n /* c8 ignore next 6 - functional code path tested but coverage intermittently missed */\n if (decl.id !== this.id) {\n return failWithDetail<ResourceCandidate, ResourceBuilderResultDetail>(\n `${this.id}: mismatched candidate id ${decl.id}.`,\n 'id-mismatch'\n );\n }\n\n if (decl.resourceTypeName !== undefined) {\n const rt = this.setResourceType(decl.resourceTypeName);\n if (rt.isFailure()) {\n return failWithDetail<ResourceCandidate, ResourceBuilderResultDetail>(rt.message, 'type-mismatch');\n }\n }\n\n return this.addChildCandidate(decl);\n }\n\n /**\n * Sets the resource type for the resource being built. Fails if a resource type has already been set\n * and it does not match the new resource type.\n * @param resourceTypeName - The name of the resource type to set.\n * @returns `Success` with the updated {@link Resources.ResourceBuilder | ResourceBuilder} object if successful,\n * or `Failure` with an error message if not.\n */\n public setResourceType(resourceTypeName: string): Result<ResourceBuilder> {\n if (this._resourceType?.key === resourceTypeName) {\n return succeed(this);\n } else if (this._resourceType !== undefined) {\n return fail(\n `${this.id}: conflicting resource types ${this._resourceType.key} !== ${resourceTypeName}.`\n );\n }\n return this._resourceTypes.validating.get(resourceTypeName).onSuccess((resourceType) => {\n this._resourceType = resourceType;\n return succeedWithDetail(this, 'success');\n });\n }\n\n /**\n * Builds the {@link Resources.Resource | resource} object from this builder.\n * @returns `Success` with the new {@link Resources.Resource | Resource} object if successful,\n * or `Failure` with an error message if not. Fails if no candidates have been added\n * or if the resource type is not defined.\n */\n public build(): Result<Resource> {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (this._candidates.size === 0) {\n return fail(`${this.id}: no candidates supplied.`);\n }\n\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (this._resourceType === undefined) {\n return fail(`${this.id}: no resource type supplied or inferred.`);\n }\n\n return Resource.create({\n id: this.id,\n resourceType: this._resourceType,\n candidates: this.candidates,\n decisions: this._decisions\n });\n }\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ResourceId, ResourceValueMergeMethod } from '../common';
|
|
1
|
+
import { JsonObject } from '@fgv/ts-json-base';
|
|
2
|
+
import { QualifierName, ResourceId, ResourceValueMergeMethod } from '../common';
|
|
3
3
|
import { Condition, ConditionSet, ConditionSetCollector } from '../conditions';
|
|
4
4
|
import * as ResourceJson from '../resource-json';
|
|
5
5
|
import { ResourceType } from '../resource-types';
|
|
6
6
|
import { Result } from '@fgv/ts-utils';
|
|
7
|
+
import * as Context from '../context';
|
|
8
|
+
import { IResourceCandidate } from '../runtime';
|
|
7
9
|
/**
|
|
8
10
|
* Parameters to create a {@link Resources.ResourceCandidate | ResourceCandidate}.
|
|
9
11
|
* @public
|
|
@@ -15,13 +17,27 @@ export interface IResourceCandidateCreateParams {
|
|
|
15
17
|
parentConditions?: ReadonlyArray<Condition>;
|
|
16
18
|
conditionSets: ConditionSetCollector;
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for creating a {@link Resources.ResourceCandidate | ResourceCandidate} declaration.
|
|
22
|
+
* @remarks
|
|
23
|
+
* This interface extends the {@link ResourceJson.Helpers.IDeclarationOptions | declaration options}
|
|
24
|
+
* interface to include a `reduceQualifiers` option.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export interface ICandidateDeclOptions extends ResourceJson.Helpers.IDeclarationOptions {
|
|
28
|
+
/**
|
|
29
|
+
* If provided, reduces the qualifiers of the candidate by removing qualifiers that are made
|
|
30
|
+
* irrelevant by the filterForContext.
|
|
31
|
+
*/
|
|
32
|
+
qualifiersToReduce?: ReadonlySet<QualifierName>;
|
|
33
|
+
}
|
|
18
34
|
/**
|
|
19
35
|
* A {@link Resources.ResourceCandidate | resource candidate} represents a single possible
|
|
20
36
|
* instance value for some resource, with the conditions under which it applies
|
|
21
37
|
* and instructions on how to merge it with other instances.
|
|
22
38
|
* @public
|
|
23
39
|
*/
|
|
24
|
-
export declare class ResourceCandidate {
|
|
40
|
+
export declare class ResourceCandidate implements IResourceCandidate {
|
|
25
41
|
/**
|
|
26
42
|
* The unique identifier of the resource for which this candidate
|
|
27
43
|
* is a possible instance.
|
|
@@ -30,7 +46,7 @@ export declare class ResourceCandidate {
|
|
|
30
46
|
/**
|
|
31
47
|
* The JSON representation of the instance data to be applied.
|
|
32
48
|
*/
|
|
33
|
-
readonly json:
|
|
49
|
+
readonly json: JsonObject;
|
|
34
50
|
/**
|
|
35
51
|
* The conditions under which this candidate applies.
|
|
36
52
|
*/
|
|
@@ -62,20 +78,27 @@ export declare class ResourceCandidate {
|
|
|
62
78
|
* @public
|
|
63
79
|
*/
|
|
64
80
|
static create(params: IResourceCandidateCreateParams): Result<ResourceCandidate>;
|
|
81
|
+
/**
|
|
82
|
+
* Determines if this candidate can match the supplied context (possibly partial).
|
|
83
|
+
* @param context - The context to match.
|
|
84
|
+
* @param options - Options to use when matching.
|
|
85
|
+
* @returns `true` if the candidate can match the context, `false` otherwise.
|
|
86
|
+
*/
|
|
87
|
+
canMatchPartialContext(context: Context.IValidatedContextDecl, options?: Context.IContextMatchOptions): boolean;
|
|
65
88
|
/**
|
|
66
89
|
* Gets the {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}
|
|
67
90
|
* for this candidate.
|
|
68
91
|
* @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} to use when creating the declaration.
|
|
69
92
|
* @returns The {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}.
|
|
70
93
|
*/
|
|
71
|
-
toChildResourceCandidateDecl(options?:
|
|
94
|
+
toChildResourceCandidateDecl(options?: ICandidateDeclOptions): ResourceJson.Json.IChildResourceCandidateDecl;
|
|
72
95
|
/**
|
|
73
96
|
* Gets the {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration}
|
|
74
97
|
* for this candidate.
|
|
75
98
|
* @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} to use when creating the declaration.
|
|
76
99
|
* @returns The {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration}.
|
|
77
100
|
*/
|
|
78
|
-
toLooseResourceCandidateDecl(options?:
|
|
101
|
+
toLooseResourceCandidateDecl(options?: ICandidateDeclOptions): ResourceJson.Json.ILooseResourceCandidateDecl;
|
|
79
102
|
/**
|
|
80
103
|
* Extracts the {@link ResourceTypes.ResourceType | resource type} from a list of {@link Resources.ResourceCandidate | resource candidates},
|
|
81
104
|
* if present.
|
|
@@ -112,5 +135,18 @@ export declare class ResourceCandidate {
|
|
|
112
135
|
* @internal
|
|
113
136
|
*/
|
|
114
137
|
private static _mergeConditions;
|
|
138
|
+
/**
|
|
139
|
+
* Finds the qualifiers that are made irrelevant by the supplied filterForContext.
|
|
140
|
+
* @param candidates - The candidates to find the reducible qualifiers for.
|
|
141
|
+
* @param filterForContext - The filter for context to use.
|
|
142
|
+
* @returns The qualifiers that are made irrelevant by the filterForContext.
|
|
143
|
+
* @remarks
|
|
144
|
+
* For any given set of candidates, qualifiers that match every candidate perfectly
|
|
145
|
+
* are irrelevant to the filtered content and can be removed. Qualifiers that do not
|
|
146
|
+
* match, that are not in the filterForContext, or which partially match at least one
|
|
147
|
+
* candidate remain relevant and must not be removed.
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
static findReducibleQualifiers(candidates: ReadonlyArray<ResourceCandidate>, filterForContext: Context.IValidatedContextDecl): ReadonlySet<QualifierName> | undefined;
|
|
115
151
|
}
|
|
116
152
|
//# sourceMappingURL=resourceCandidate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceCandidate.d.ts","sourceRoot":"","sources":["../../../src/packlets/resources/resourceCandidate.ts"],"names":[],"mappings":"AAsBA,OAAO,
|
|
1
|
+
{"version":3,"file":"resourceCandidate.d.ts","sourceRoot":"","sources":["../../../src/packlets/resources/resourceCandidate.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAgB,aAAa,EAAE,UAAU,EAAE,wBAAwB,EAAY,MAAM,WAAW,CAAC;AACxG,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAsD,MAAM,EAAiB,MAAM,eAAe,CAAC;AAC1G,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,2BAA2B,CAAC;IACpD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAC5C,aAAa,EAAE,qBAAqB,CAAC;CACtC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAsB,SAAQ,YAAY,CAAC,OAAO,CAAC,mBAAmB;IACrF;;;OAGG;IACH,kBAAkB,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;CACjD;AAED;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAC1D;;;OAGG;IACH,SAAgB,EAAE,EAAE,UAAU,CAAC;IAE/B;;OAEG;IACH,SAAgB,IAAI,EAAE,UAAU,CAAC;IAEjC;;OAEG;IACH,SAAgB,UAAU,EAAE,YAAY,CAAC;IAEz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 -80,7 +80,7 @@ class ResourceCandidate {
|
|
|
80
80
|
this.mergeMethod = (_b = params.decl.mergeMethod) !== null && _b !== void 0 ? _b : 'augment';
|
|
81
81
|
this.resourceType = params.resourceType;
|
|
82
82
|
if (this.resourceType) {
|
|
83
|
-
this.resourceType.validateDeclaration(this
|
|
83
|
+
this.resourceType.validateDeclaration(this).orThrow();
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
@@ -93,6 +93,15 @@ class ResourceCandidate {
|
|
|
93
93
|
static create(params) {
|
|
94
94
|
return (0, ts_utils_1.captureResult)(() => new ResourceCandidate(params));
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Determines if this candidate can match the supplied context (possibly partial).
|
|
98
|
+
* @param context - The context to match.
|
|
99
|
+
* @param options - Options to use when matching.
|
|
100
|
+
* @returns `true` if the candidate can match the context, `false` otherwise.
|
|
101
|
+
*/
|
|
102
|
+
canMatchPartialContext(context, options) {
|
|
103
|
+
return this.conditions.canMatchPartialContext(context, options);
|
|
104
|
+
}
|
|
96
105
|
/**
|
|
97
106
|
* Gets the {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}
|
|
98
107
|
* for this candidate.
|
|
@@ -128,9 +137,11 @@ class ResourceCandidate {
|
|
|
128
137
|
let selectedType = expectedType;
|
|
129
138
|
for (const candidate of candidates) {
|
|
130
139
|
if (selectedType === undefined) {
|
|
140
|
+
/* c8 ignore next 1 - functional code path tested but coverage intermittently missed */
|
|
131
141
|
selectedType = candidate.resourceType;
|
|
132
142
|
}
|
|
133
143
|
else if (candidate.resourceType && selectedType !== candidate.resourceType) {
|
|
144
|
+
/* c8 ignore next 4 - functional code path tested but coverage intermittently missed */
|
|
134
145
|
errors.addMessage(`${candidate.id}: resource type mismatch (${selectedType.key} != ${candidate.resourceType.key})`);
|
|
135
146
|
}
|
|
136
147
|
}
|
|
@@ -155,6 +166,7 @@ class ResourceCandidate {
|
|
|
155
166
|
* @public
|
|
156
167
|
*/
|
|
157
168
|
static equal(rc1, rc2) {
|
|
169
|
+
/* c8 ignore next 3 - functional code path tested but coverage intermittently missed */
|
|
158
170
|
if (rc1 === rc2) {
|
|
159
171
|
return true;
|
|
160
172
|
}
|
|
@@ -184,6 +196,7 @@ class ResourceCandidate {
|
|
|
184
196
|
declared = declared !== null && declared !== void 0 ? declared : {};
|
|
185
197
|
parent = parent !== null && parent !== void 0 ? parent : [];
|
|
186
198
|
const { value: conditionDecls, message } = ResourceJson.Convert.conditionSetDecl.convert(declared);
|
|
199
|
+
/* c8 ignore next 3 - functional code path tested but coverage intermittently missed */
|
|
187
200
|
if (message !== undefined) {
|
|
188
201
|
return (0, ts_utils_1.fail)(message);
|
|
189
202
|
}
|
|
@@ -197,6 +210,32 @@ class ResourceCandidate {
|
|
|
197
210
|
});
|
|
198
211
|
});
|
|
199
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Finds the qualifiers that are made irrelevant by the supplied filterForContext.
|
|
215
|
+
* @param candidates - The candidates to find the reducible qualifiers for.
|
|
216
|
+
* @param filterForContext - The filter for context to use.
|
|
217
|
+
* @returns The qualifiers that are made irrelevant by the filterForContext.
|
|
218
|
+
* @remarks
|
|
219
|
+
* For any given set of candidates, qualifiers that match every candidate perfectly
|
|
220
|
+
* are irrelevant to the filtered content and can be removed. Qualifiers that do not
|
|
221
|
+
* match, that are not in the filterForContext, or which partially match at least one
|
|
222
|
+
* candidate remain relevant and must not be removed.
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
static findReducibleQualifiers(candidates, filterForContext) {
|
|
226
|
+
const qualifiersToReduce = new Set(Object.keys(filterForContext));
|
|
227
|
+
for (const candidate of candidates) {
|
|
228
|
+
for (const condition of candidate.conditions.conditions) {
|
|
229
|
+
if (qualifiersToReduce.has(condition.qualifier.name)) {
|
|
230
|
+
const match = condition.qualifier.type.matches(condition.value, filterForContext[condition.qualifier.name], 'matches');
|
|
231
|
+
if (match !== common_1.PerfectMatch) {
|
|
232
|
+
qualifiersToReduce.delete(condition.qualifier.name);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return qualifiersToReduce.size > 0 ? qualifiersToReduce : undefined;
|
|
238
|
+
}
|
|
200
239
|
}
|
|
201
240
|
exports.ResourceCandidate = ResourceCandidate;
|
|
202
241
|
//# sourceMappingURL=resourceCandidate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceCandidate.js","sourceRoot":"","sources":["../../../src/packlets/resources/resourceCandidate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,sCAA2E;AAC3E,8CAA+E;AAC/E,+DAAiD;AAEjD,4CAA0G;AAc1G;;;;;GAKG;AACH,MAAa,iBAAiB;IAiC5B;;;;OAIG;IACH,YAAsB,MAAsC;;QAC1D,IAAI,CAAC,EAAE,GAAG,iBAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,iBAAiB,CAAC,gBAAgB,CAClD,MAAM,CAAC,aAAa,EACpB,MAAM,CAAC,IAAI,CAAC,UAAU,EACtB,MAAM,CAAC,gBAAgB,CACxB,CAAC,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC,SAAS,GAAG,MAAA,MAAM,CAAC,IAAI,CAAC,SAAS,mCAAI,KAAK,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,MAAA,MAAM,CAAC,IAAI,CAAC,WAAW,mCAAI,SAAS,CAAC;QACxD,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,YAAY,CAAC,mBAAm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AAU;QACf,kEAAkE;QAClE,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACjF,CAAC,SAAS,CAAC,CAAC,kBAAkB,EAAE,EAAE;YACjC,4EAA4E;YAC5E,OAAO,IAAA,qBAAU,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAClF,CAAC,gBAAgB,EAAE,EAAE;gBACnB,MAAM,UAAU,GAAG,CAAC,GAAG,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,CAAC;gBAChE,OAAO,aAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YACvD,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3MD,8CA2MC","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 { JsonObject, JsonValue } from '@fgv/ts-json-base';\nimport { ResourceId, ResourceValueMergeMethod, Validate } from '../common';\nimport { Condition, ConditionSet, ConditionSetCollector } from '../conditions';\nimport * as ResourceJson from '../resource-json';\nimport { ResourceType } from '../resource-types';\nimport { captureResult, mapResults, Hash, MessageAggregator, Result, fail, succeed } from '@fgv/ts-utils';\n\n/**\n * Parameters to create a {@link Resources.ResourceCandidate | ResourceCandidate}.\n * @public\n */\nexport interface IResourceCandidateCreateParams {\n id: string;\n decl: ResourceJson.Json.IChildResourceCandidateDecl;\n resourceType?: ResourceType;\n parentConditions?: ReadonlyArray<Condition>;\n conditionSets: ConditionSetCollector;\n}\n\n/**\n * A {@link Resources.ResourceCandidate | resource candidate} represents a single possible\n * instance value for some resource, with the conditions under which it applies\n * and instructions on how to merge it with other instances.\n * @public\n */\nexport class ResourceCandidate {\n /**\n * The unique identifier of the resource for which this candidate\n * is a possible instance.\n */\n public readonly id: ResourceId;\n\n /**\n * The JSON representation of the instance data to be applied.\n */\n public readonly json: JsonValue;\n\n /**\n * The conditions under which this candidate applies.\n */\n public readonly conditions: ConditionSet;\n\n /**\n * True if this candidate is a partial instance.\n */\n public readonly isPartial: boolean;\n\n /**\n * The method to use when merging this candidate with other instances.\n */\n public readonly mergeMethod: ResourceValueMergeMethod;\n\n /**\n * The {@link ResourceTypes.ResourceType | resource type} for the resource to which\n * this candidate belongs.\n */\n public readonly resourceType: ResourceType | undefined;\n\n /**\n * Constructor for a {@link Resources.ResourceCandidate | ResourceCandidate} object.\n * @param params - Parameters to create a new {@link Resources.ResourceCandidate | ResourceCandidate}.\n * @public\n */\n protected constructor(params: IResourceCandidateCreateParams) {\n this.id = Validate.toResourceId(params.id).orThrow();\n this.json = params.decl.json;\n this.conditions = ResourceCandidate._mergeConditions(\n params.conditionSets,\n params.decl.conditions,\n params.parentConditions\n ).orThrow();\n this.isPartial = params.decl.isPartial ?? false;\n this.mergeMethod = params.decl.mergeMethod ?? 'augment';\n this.resourceType = params.resourceType;\n if (this.resourceType) {\n this.resourceType.validateDeclaration(this.json, this.isPartial, this.mergeMethod).orThrow();\n }\n }\n\n /**\n * Creates a new {@link Resources.ResourceCandidate | ResourceCandidate} object.\n * @param params - Parameters to create a new {@link Resources.ResourceCandidate | ResourceCandidate}.\n * @returns `Success` with the new {@link Resources.ResourceCandidate | ResourceCandidate} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IResourceCandidateCreateParams): Result<ResourceCandidate> {\n return captureResult(() => new ResourceCandidate(params));\n }\n\n /**\n * Gets the {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}\n * for this candidate.\n * @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} to use when creating the declaration.\n * @returns The {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}.\n */\n public toChildResourceCandidateDecl(\n options?: ResourceJson.Helpers.IDeclarationOptions\n ): ResourceJson.Json.IChildResourceCandidateDecl {\n const showDefaults = options?.showDefaults === true;\n return {\n json: this.json as JsonObject,\n conditions: this.conditions.toConditionSetRecordDecl(options),\n ...(showDefaults || this.isPartial ? { isPartial: this.isPartial } : {}),\n ...(showDefaults || this.mergeMethod !== 'augment' ? { mergeMethod: this.mergeMethod } : {})\n };\n }\n\n /**\n * Gets the {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration}\n * for this candidate.\n * @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} to use when creating the declaration.\n * @returns The {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration}.\n */\n public toLooseResourceCandidateDecl(\n options?: ResourceJson.Helpers.IDeclarationOptions\n ): ResourceJson.Json.ILooseResourceCandidateDecl {\n const showDefaults = options?.showDefaults === true;\n const resourceTypeName = this.resourceType?.key;\n return {\n id: this.id.toString(),\n json: this.json as JsonObject,\n conditions: this.conditions.toConditionSetRecordDecl(options),\n ...(showDefaults || this.isPartial ? { isPartial: this.isPartial } : {}),\n ...(showDefaults || this.mergeMethod !== 'augment' ? { mergeMethod: this.mergeMethod } : {}),\n ...(resourceTypeName ? { resourceTypeName } : {})\n };\n }\n\n /**\n * Extracts the {@link ResourceTypes.ResourceType | resource type} from a list of {@link Resources.ResourceCandidate | resource candidates},\n * if present.\n * @param candidates - The list of candidates from which to extract the resource type.\n * @returns `Success` with the resource type if successful, `Success` with `undefined` if none of the candidates\n * specify a resource tap, and `Failure` with an error message if clients specify conflicting resource types.\n * @public\n */\n public static validateResourceTypes(\n candidates: ReadonlyArray<ResourceCandidate>,\n expectedType?: ResourceType\n ): Result<ResourceType | undefined> {\n const errors = new MessageAggregator();\n let selectedType: ResourceType | undefined = expectedType;\n for (const candidate of candidates) {\n if (selectedType === undefined) {\n selectedType = candidate.resourceType;\n } else if (candidate.resourceType && selectedType !== candidate.resourceType) {\n errors.addMessage(\n `${candidate.id}: resource type mismatch (${selectedType.key} != ${candidate.resourceType.key})`\n );\n }\n }\n return errors.returnOrReport(succeed(selectedType));\n }\n\n /**\n * Compares two {@link Resources.ResourceCandidate | ResourceCandidates} for sorting purposes.\n * @param rc1 - The first candidate to compare.\n * @param rc2 - The second candidate to compare.\n * @returns A negative number if `rc1` should come before `rc2`, a positive number if `rc2` should come before `rc1`,\n * or zero if they are equivalent.\n * @public\n */\n public static compare(rc1: ResourceCandidate, rc2: ResourceCandidate): number {\n return ConditionSet.compare(rc1.conditions, rc2.conditions);\n }\n\n /**\n * Compares two {@link Resources.ResourceCandidate | ResourceCandidates} for equality.\n * @param rc1 - The first candidate to compare.\n * @param rc2 - The second candidate to compare.\n * @returns `true` if the candidates are equal, `false` otherwise.\n * @public\n */\n public static equal(rc1: ResourceCandidate, rc2: ResourceCandidate): boolean {\n if (rc1 === rc2) {\n return true;\n }\n let equal =\n rc1.id === rc2.id &&\n rc1.isPartial === rc2.isPartial &&\n rc1.mergeMethod === rc2.mergeMethod &&\n ConditionSet.compare(rc1.conditions, rc2.conditions) === 0;\n if (equal) {\n const normalizer = new Hash.Crc32Normalizer();\n const n1 = normalizer.computeHash(rc1.json).orDefault('(n1 normalization failed)');\n const n2 = normalizer.computeHash(rc2.json).orDefault('(n2 normalization failed)');\n equal = n1 === n2;\n }\n return equal;\n }\n\n /**\n * Validates declared conditions and merges them with parent conditions.\n * @param conditionSets - The {@link Conditions.ConditionSetCollector | condition set collector}\n * to use for this candidate.\n * @param declared - The declared conditions for the candidate.\n * @param parent - The parent conditions to merge with the declared conditions.\n * @returns `Success` with the merged conditions if successful, `Failure` otherwise.\n * @internal\n */\n private static _mergeConditions(\n conditionSets: ConditionSetCollector,\n declared: ResourceJson.Json.ConditionSetDecl | undefined,\n parent: ReadonlyArray<Condition> | undefined\n ): Result<ConditionSet> {\n /* c8 ignore next 2 - code coverage is flaky */\n declared = declared ?? {};\n parent = parent ?? [];\n\n const { value: conditionDecls, message } = ResourceJson.Convert.conditionSetDecl.convert(declared);\n if (message !== undefined) {\n return fail(message);\n }\n\n return mapResults(\n // get or add all declared conditions from our condition collector\n conditionDecls.map((decl) => conditionSets.conditions.validating.getOrAdd(decl))\n ).onSuccess((declaredConditions) => {\n // make sure our parent conditions all come from our condition collector too\n return mapResults(parent.map((c) => conditionSets.conditions.getOrAdd(c))).onSuccess(\n (parentConditions) => {\n const conditions = [...parentConditions, ...declaredConditions];\n return conditionSets.validating.getOrAdd(conditions);\n }\n );\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resourceCandidate.js","sourceRoot":"","sources":["../../../src/packlets/resources/resourceCandidate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,sCAAwG;AACxG,8CAA+E;AAC/E,+DAAiD;AAEjD,4CAA0G;AA+B1G;;;;;GAKG;AACH,MAAa,iBAAiB;IAiC5B;;;;OAIG;IACH,YAAsB,MAAs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AC,GAAG,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,CAAC;gBAChE,OAAO,aAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YACvD,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,uBAAuB,CACnC,UAA4C,EAC5C,gBAA+C;QAE/C,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAgB,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAoB,CAAC,CAAC;QACpG,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;gBACxD,IAAI,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;oBACrD,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAC5C,SAAS,CAAC,KAAK,EACf,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAC1C,SAAS,CACV,CAAC;oBACF,IAAI,KAAK,KAAK,qBAAY,EAAE,CAAC;wBAC3B,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;oBACtD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,kBAAkB,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,CAAC;CACF;AA9PD,8CA8PC","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 { JsonObject } from '@fgv/ts-json-base';\nimport { PerfectMatch, QualifierName, ResourceId, ResourceValueMergeMethod, Validate } from '../common';\nimport { Condition, ConditionSet, ConditionSetCollector } from '../conditions';\nimport * as ResourceJson from '../resource-json';\nimport { ResourceType } from '../resource-types';\nimport { captureResult, mapResults, Hash, MessageAggregator, Result, fail, succeed } from '@fgv/ts-utils';\nimport * as Context from '../context';\nimport { IResourceCandidate } from '../runtime';\n\n/**\n * Parameters to create a {@link Resources.ResourceCandidate | ResourceCandidate}.\n * @public\n */\nexport interface IResourceCandidateCreateParams {\n id: string;\n decl: ResourceJson.Json.IChildResourceCandidateDecl;\n resourceType?: ResourceType;\n parentConditions?: ReadonlyArray<Condition>;\n conditionSets: ConditionSetCollector;\n}\n\n/**\n * Options for creating a {@link Resources.ResourceCandidate | ResourceCandidate} declaration.\n * @remarks\n * This interface extends the {@link ResourceJson.Helpers.IDeclarationOptions | declaration options}\n * interface to include a `reduceQualifiers` option.\n * @public\n */\nexport interface ICandidateDeclOptions extends ResourceJson.Helpers.IDeclarationOptions {\n /**\n * If provided, reduces the qualifiers of the candidate by removing qualifiers that are made\n * irrelevant by the filterForContext.\n */\n qualifiersToReduce?: ReadonlySet<QualifierName>;\n}\n\n/**\n * A {@link Resources.ResourceCandidate | resource candidate} represents a single possible\n * instance value for some resource, with the conditions under which it applies\n * and instructions on how to merge it with other instances.\n * @public\n */\nexport class ResourceCandidate implements IResourceCandidate {\n /**\n * The unique identifier of the resource for which this candidate\n * is a possible instance.\n */\n public readonly id: ResourceId;\n\n /**\n * The JSON representation of the instance data to be applied.\n */\n public readonly json: JsonObject;\n\n /**\n * The conditions under which this candidate applies.\n */\n public readonly conditions: ConditionSet;\n\n /**\n * True if this candidate is a partial instance.\n */\n public readonly isPartial: boolean;\n\n /**\n * The method to use when merging this candidate with other instances.\n */\n public readonly mergeMethod: ResourceValueMergeMethod;\n\n /**\n * The {@link ResourceTypes.ResourceType | resource type} for the resource to which\n * this candidate belongs.\n */\n public readonly resourceType: ResourceType | undefined;\n\n /**\n * Constructor for a {@link Resources.ResourceCandidate | ResourceCandidate} object.\n * @param params - Parameters to create a new {@link Resources.ResourceCandidate | ResourceCandidate}.\n * @public\n */\n protected constructor(params: IResourceCandidateCreateParams) {\n this.id = Validate.toResourceId(params.id).orThrow();\n this.json = params.decl.json;\n this.conditions = ResourceCandidate._mergeConditions(\n params.conditionSets,\n params.decl.conditions,\n params.parentConditions\n ).orThrow();\n this.isPartial = params.decl.isPartial ?? false;\n this.mergeMethod = params.decl.mergeMethod ?? 'augment';\n this.resourceType = params.resourceType;\n if (this.resourceType) {\n this.resourceType.validateDeclaration(this).orThrow();\n }\n }\n\n /**\n * Creates a new {@link Resources.ResourceCandidate | ResourceCandidate} object.\n * @param params - Parameters to create a new {@link Resources.ResourceCandidate | ResourceCandidate}.\n * @returns `Success` with the new {@link Resources.ResourceCandidate | ResourceCandidate} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IResourceCandidateCreateParams): Result<ResourceCandidate> {\n return captureResult(() => new ResourceCandidate(params));\n }\n\n /**\n * Determines if this candidate can match the supplied context (possibly partial).\n * @param context - The context to match.\n * @param options - Options to use when matching.\n * @returns `true` if the candidate can match the context, `false` otherwise.\n */\n public canMatchPartialContext(\n context: Context.IValidatedContextDecl,\n options?: Context.IContextMatchOptions\n ): boolean {\n return this.conditions.canMatchPartialContext(context, options);\n }\n\n /**\n * Gets the {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}\n * for this candidate.\n * @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} to use when creating the declaration.\n * @returns The {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}.\n */\n public toChildResourceCandidateDecl(\n options?: ICandidateDeclOptions\n ): ResourceJson.Json.IChildResourceCandidateDecl {\n const showDefaults = options?.showDefaults === true;\n return {\n json: this.json as JsonObject,\n conditions: this.conditions.toConditionSetRecordDecl(options),\n ...(showDefaults || this.isPartial ? { isPartial: this.isPartial } : {}),\n ...(showDefaults || this.mergeMethod !== 'augment' ? { mergeMethod: this.mergeMethod } : {})\n };\n }\n\n /**\n * Gets the {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration}\n * for this candidate.\n * @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} to use when creating the declaration.\n * @returns The {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration}.\n */\n public toLooseResourceCandidateDecl(\n options?: ICandidateDeclOptions\n ): ResourceJson.Json.ILooseResourceCandidateDecl {\n const showDefaults = options?.showDefaults === true;\n const resourceTypeName = this.resourceType?.key;\n return {\n id: this.id.toString(),\n json: this.json as JsonObject,\n conditions: this.conditions.toConditionSetRecordDecl(options),\n ...(showDefaults || this.isPartial ? { isPartial: this.isPartial } : {}),\n ...(showDefaults || this.mergeMethod !== 'augment' ? { mergeMethod: this.mergeMethod } : {}),\n ...(resourceTypeName ? { resourceTypeName } : {})\n };\n }\n\n /**\n * Extracts the {@link ResourceTypes.ResourceType | resource type} from a list of {@link Resources.ResourceCandidate | resource candidates},\n * if present.\n * @param candidates - The list of candidates from which to extract the resource type.\n * @returns `Success` with the resource type if successful, `Success` with `undefined` if none of the candidates\n * specify a resource tap, and `Failure` with an error message if clients specify conflicting resource types.\n * @public\n */\n public static validateResourceTypes(\n candidates: ReadonlyArray<ResourceCandidate>,\n expectedType?: ResourceType\n ): Result<ResourceType | undefined> {\n const errors = new MessageAggregator();\n let selectedType: ResourceType | undefined = expectedType;\n for (const candidate of candidates) {\n if (selectedType === undefined) {\n /* c8 ignore next 1 - functional code path tested but coverage intermittently missed */\n selectedType = candidate.resourceType;\n } else if (candidate.resourceType && selectedType !== candidate.resourceType) {\n /* c8 ignore next 4 - functional code path tested but coverage intermittently missed */\n errors.addMessage(\n `${candidate.id}: resource type mismatch (${selectedType.key} != ${candidate.resourceType.key})`\n );\n }\n }\n return errors.returnOrReport(succeed(selectedType));\n }\n\n /**\n * Compares two {@link Resources.ResourceCandidate | ResourceCandidates} for sorting purposes.\n * @param rc1 - The first candidate to compare.\n * @param rc2 - The second candidate to compare.\n * @returns A negative number if `rc1` should come before `rc2`, a positive number if `rc2` should come before `rc1`,\n * or zero if they are equivalent.\n * @public\n */\n public static compare(rc1: ResourceCandidate, rc2: ResourceCandidate): number {\n return ConditionSet.compare(rc1.conditions, rc2.conditions);\n }\n\n /**\n * Compares two {@link Resources.ResourceCandidate | ResourceCandidates} for equality.\n * @param rc1 - The first candidate to compare.\n * @param rc2 - The second candidate to compare.\n * @returns `true` if the candidates are equal, `false` otherwise.\n * @public\n */\n public static equal(rc1: ResourceCandidate, rc2: ResourceCandidate): boolean {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (rc1 === rc2) {\n return true;\n }\n let equal =\n rc1.id === rc2.id &&\n rc1.isPartial === rc2.isPartial &&\n rc1.mergeMethod === rc2.mergeMethod &&\n ConditionSet.compare(rc1.conditions, rc2.conditions) === 0;\n if (equal) {\n const normalizer = new Hash.Crc32Normalizer();\n const n1 = normalizer.computeHash(rc1.json).orDefault('(n1 normalization failed)');\n const n2 = normalizer.computeHash(rc2.json).orDefault('(n2 normalization failed)');\n equal = n1 === n2;\n }\n return equal;\n }\n\n /**\n * Validates declared conditions and merges them with parent conditions.\n * @param conditionSets - The {@link Conditions.ConditionSetCollector | condition set collector}\n * to use for this candidate.\n * @param declared - The declared conditions for the candidate.\n * @param parent - The parent conditions to merge with the declared conditions.\n * @returns `Success` with the merged conditions if successful, `Failure` otherwise.\n * @internal\n */\n private static _mergeConditions(\n conditionSets: ConditionSetCollector,\n declared: ResourceJson.Json.ConditionSetDecl | undefined,\n parent: ReadonlyArray<Condition> | undefined\n ): Result<ConditionSet> {\n /* c8 ignore next 2 - code coverage is flaky */\n declared = declared ?? {};\n parent = parent ?? [];\n\n const { value: conditionDecls, message } = ResourceJson.Convert.conditionSetDecl.convert(declared);\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (message !== undefined) {\n return fail(message);\n }\n\n return mapResults(\n // get or add all declared conditions from our condition collector\n conditionDecls.map((decl) => conditionSets.conditions.validating.getOrAdd(decl))\n ).onSuccess((declaredConditions) => {\n // make sure our parent conditions all come from our condition collector too\n return mapResults(parent.map((c) => conditionSets.conditions.getOrAdd(c))).onSuccess(\n (parentConditions) => {\n const conditions = [...parentConditions, ...declaredConditions];\n return conditionSets.validating.getOrAdd(conditions);\n }\n );\n });\n }\n\n /**\n * Finds the qualifiers that are made irrelevant by the supplied filterForContext.\n * @param candidates - The candidates to find the reducible qualifiers for.\n * @param filterForContext - The filter for context to use.\n * @returns The qualifiers that are made irrelevant by the filterForContext.\n * @remarks\n * For any given set of candidates, qualifiers that match every candidate perfectly\n * are irrelevant to the filtered content and can be removed. Qualifiers that do not\n * match, that are not in the filterForContext, or which partially match at least one\n * candidate remain relevant and must not be removed.\n * @public\n */\n public static findReducibleQualifiers(\n candidates: ReadonlyArray<ResourceCandidate>,\n filterForContext: Context.IValidatedContextDecl\n ): ReadonlySet<QualifierName> | undefined {\n const qualifiersToReduce = new Set<QualifierName>(Object.keys(filterForContext) as QualifierName[]);\n for (const candidate of candidates) {\n for (const condition of candidate.conditions.conditions) {\n if (qualifiersToReduce.has(condition.qualifier.name)) {\n const match = condition.qualifier.type.matches(\n condition.value,\n filterForContext[condition.qualifier.name],\n 'matches'\n );\n if (match !== PerfectMatch) {\n qualifiersToReduce.delete(condition.qualifier.name);\n }\n }\n }\n }\n return qualifiersToReduce.size > 0 ? qualifiersToReduce : undefined;\n }\n}\n"]}
|
|
@@ -0,0 +1,220 @@
|
|
|
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 { IResourceManager } from '../runtime';
|
|
8
|
+
import { ResourceBuilder, ResourceBuilderResultDetail } from './resourceBuilder';
|
|
9
|
+
import { Resource } from './resource';
|
|
10
|
+
import { ResourceCandidate } from './resourceCandidate';
|
|
11
|
+
import { IResourceDeclarationOptions } from './common';
|
|
12
|
+
import * as ResourceJson from '../resource-json';
|
|
13
|
+
import * as Context from '../context';
|
|
14
|
+
/**
|
|
15
|
+
* Interface for parameters to the {@link Resources.ResourceManagerBuilder.create | ResourceManagerBuilder create method}.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export interface IResourceManagerBuilderCreateParams {
|
|
19
|
+
qualifiers: IReadOnlyQualifierCollector;
|
|
20
|
+
resourceTypes: ReadOnlyResourceTypeCollector;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Error details that can be returned by a {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder}.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export type ResourceManagerBuilderResultDetail = Collections.ResultMapResultDetail | ResourceBuilderResultDetail;
|
|
27
|
+
/**
|
|
28
|
+
* Builder for a collection of {@link Resources.Resource | resources}. Collects
|
|
29
|
+
* {@link Resources.ResourceCandidate | candidates} for each resource into a
|
|
30
|
+
* {@link Resources.ResourceBuilder | ResourceBuilder} per resource, validates them against each other,
|
|
31
|
+
* and builds a collection of {@link Resources.Resource | resources} once all candidates are collected.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare class ResourceManagerBuilder implements IResourceManager {
|
|
35
|
+
readonly qualifiers: IReadOnlyQualifierCollector;
|
|
36
|
+
readonly resourceTypes: ReadOnlyResourceTypeCollector;
|
|
37
|
+
protected readonly _conditions: ConditionCollector;
|
|
38
|
+
protected readonly _conditionSets: ConditionSetCollector;
|
|
39
|
+
protected readonly _decisions: AbstractDecisionCollector;
|
|
40
|
+
protected readonly _resources: ValidatingResultMap<ResourceId, ResourceBuilder>;
|
|
41
|
+
readonly _builtResources: ValidatingResultMap<ResourceId, Resource>;
|
|
42
|
+
protected _built: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
45
|
+
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
46
|
+
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
47
|
+
*/
|
|
48
|
+
get conditions(): ReadOnlyConditionCollector;
|
|
49
|
+
/**
|
|
50
|
+
* A {@link Conditions.ConditionSetCollector | ConditionSetCollector} which
|
|
51
|
+
* contains the {@link Conditions.ConditionSet | condition sets} used so far by
|
|
52
|
+
* the {@link Resources.ResourceCandidate | resource candidates} in this manager.
|
|
53
|
+
*/
|
|
54
|
+
get conditionSets(): ReadOnlyConditionSetCollector;
|
|
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(): ReadOnlyAbstractDecisionCollector;
|
|
61
|
+
/**
|
|
62
|
+
* A read-only map of {@link Resources.ResourceBuilder | resource builders} used by the manager.
|
|
63
|
+
*/
|
|
64
|
+
get resources(): Collections.IReadOnlyValidatingResultMap<ResourceId, ResourceBuilder>;
|
|
65
|
+
/**
|
|
66
|
+
* The number of {@link Resources.Resource | resources} contained by the manager.
|
|
67
|
+
*/
|
|
68
|
+
get size(): number;
|
|
69
|
+
/**
|
|
70
|
+
* {@inheritdoc Runtime.IResourceManager.numResources}
|
|
71
|
+
*/
|
|
72
|
+
get numResources(): number;
|
|
73
|
+
/**
|
|
74
|
+
* The number of candidates in this resource manager.
|
|
75
|
+
*/
|
|
76
|
+
protected _numCandidates?: number;
|
|
77
|
+
/**
|
|
78
|
+
* {@inheritdoc Runtime.IResourceManager.numCandidates}
|
|
79
|
+
*/
|
|
80
|
+
get numCandidates(): number;
|
|
81
|
+
/**
|
|
82
|
+
* {@inheritdoc Runtime.IResourceManager.builtResources}
|
|
83
|
+
*/
|
|
84
|
+
get builtResources(): Collections.IReadOnlyValidatingResultMap<ResourceId, Resource>;
|
|
85
|
+
/**
|
|
86
|
+
* Constructor for a {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object.
|
|
87
|
+
* @param params - Parameters to create a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder}.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
protected constructor(params: IResourceManagerBuilderCreateParams);
|
|
91
|
+
/**
|
|
92
|
+
* Creates a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object.
|
|
93
|
+
* @param params - Parameters to create a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder}.
|
|
94
|
+
* @returns `Success` with the new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object if successful,
|
|
95
|
+
* or `Failure` with an error message if not.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
static create(params: IResourceManagerBuilderCreateParams): Result<ResourceManagerBuilder>;
|
|
99
|
+
/**
|
|
100
|
+
* Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds
|
|
101
|
+
* a {@link Resources.ResourceCandidate | candidate} to the manager.
|
|
102
|
+
* @param candidate - The {@link Resources.ResourceCandidate | candidate} to add.
|
|
103
|
+
* @returns `Success` with the candidate if successful, or `Failure` with an error message if not.
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
addLooseCandidate(decl: ResourceJson.Json.ILooseResourceCandidateDecl): DetailedResult<ResourceCandidate, ResourceBuilderResultDetail>;
|
|
107
|
+
addResource(decl: ResourceJson.Json.ILooseResourceDecl): DetailedResult<ResourceBuilder, ResourceBuilderResultDetail>;
|
|
108
|
+
/**
|
|
109
|
+
* Gets a read-only array of all {@link Resources.ResourceBuilder | resource builders} present in the manager.
|
|
110
|
+
* @returns `Success` with the {@link Resources.ResourceBuilder | resource builder} if successful,
|
|
111
|
+
* or `Failure` with an error message if not.
|
|
112
|
+
*/
|
|
113
|
+
getAllResources(): ReadonlyArray<ResourceBuilder>;
|
|
114
|
+
/**
|
|
115
|
+
* Gets a read-only array of all {@link Resources.ResourceCandidate | resource candidates} present in the manager.
|
|
116
|
+
*/
|
|
117
|
+
getAllCandidates(): ReadonlyArray<ResourceCandidate>;
|
|
118
|
+
/**
|
|
119
|
+
* Gets an individual {@link Resources.Resource | built resource} from the manager.
|
|
120
|
+
* @param id - The {@link ResourceId | id} of the resource to get.
|
|
121
|
+
* @returns `Success` with the resource if successful, or `Failure` with an error message if not.
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
getBuiltResource(id: string): Result<Resource>;
|
|
125
|
+
/**
|
|
126
|
+
* Validates a context declaration against the qualifiers managed by this resource manager.
|
|
127
|
+
* @param context - The context declaration to validate
|
|
128
|
+
* @returns Success with the validated context if successful, Failure otherwise
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
validateContext(context: Context.IContextDecl): Result<Context.IValidatedContextDecl>;
|
|
132
|
+
/**
|
|
133
|
+
* Gets a read-only array of all {@link Resources.Resource | built resources} in the manager.
|
|
134
|
+
* @returns `Success` with an array of resources if successful, or `Failure` with an error message if not.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
getAllBuiltResources(): Result<ReadonlyArray<Resource>>;
|
|
138
|
+
/**
|
|
139
|
+
* Gets a read-only array of all {@link Resources.Resource | built resources} in the manager.
|
|
140
|
+
* @returns `Success` with an array of resources if successful, or `Failure` with an error message if not.
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
getAllBuiltCandidates(): Result<ReadonlyArray<ResourceCandidate>>;
|
|
144
|
+
/**
|
|
145
|
+
* Internal helper method that performs the actual building of resources.
|
|
146
|
+
* @returns `Success` with the built resources if all resources were built successfully, `Failure` otherwise.
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
_performBuild(): Result<Collections.IReadOnlyValidatingResultMap<ResourceId, Resource>>;
|
|
150
|
+
/**
|
|
151
|
+
* Builds the {@link Resources.Resource | resources} from the collected {@link Resources.ResourceCandidate | candidates}.
|
|
152
|
+
* @returns `Success` with the {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object if successful,
|
|
153
|
+
* or `Failure` with an error message if not.
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
build(): Result<this>;
|
|
157
|
+
/**
|
|
158
|
+
* Gets a read-only array of all {@link Resources.ResourceCandidate | resource candidates} that can match the supplied context.
|
|
159
|
+
* @param context - The {@link Context.IValidatedContextDecl | context} to match against.
|
|
160
|
+
* @param options - {@link Context.IContextMatchOptions | options} for the context match.
|
|
161
|
+
* @returns A read-only array of {@link Resources.ResourceCandidate | candidates} that can match the context.
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
getCandidatesForContext(context: Context.IValidatedContextDecl, options?: Context.IContextMatchOptions): ReadonlyArray<ResourceCandidate>;
|
|
165
|
+
/**
|
|
166
|
+
* Gets a read-only array of all {@link Resources.ResourceBuilder | resource builders} that have at least one candidate
|
|
167
|
+
* that can match the supplied context.
|
|
168
|
+
* @param context - The {@link Context.IValidatedContextDecl | context} to match against.
|
|
169
|
+
* @param options - {@link Context.IContextMatchOptions | options} for the context match.
|
|
170
|
+
* @returns A read-only array of {@link Resources.ResourceBuilder | resource builders} with matching candidates.
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
getResourcesForContext(context: Context.IValidatedContextDecl, options?: Context.IContextMatchOptions): ReadonlyArray<ResourceBuilder>;
|
|
174
|
+
/**
|
|
175
|
+
* Gets a read-only array of all {@link Resources.ResourceCandidate | built resource candidates} that can match the supplied context.
|
|
176
|
+
* @param context - The {@link Context.IValidatedContextDecl | context} to match against.
|
|
177
|
+
* @param options - {@link Context.IContextMatchOptions | options} for the context match.
|
|
178
|
+
* @returns `Success` with an array of {@link Resources.ResourceCandidate | candidates} if successful, or `Failure` with an error message if not.
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
getBuiltCandidatesForContext(context: Context.IValidatedContextDecl, options?: Context.IContextMatchOptions): Result<ReadonlyArray<ResourceCandidate>>;
|
|
182
|
+
/**
|
|
183
|
+
* Gets a read-only array of all {@link Resources.Resource | built resources} that have at least one candidate
|
|
184
|
+
* that can match the supplied context.
|
|
185
|
+
* @param context - The {@link Context.IValidatedContextDecl | context} to match against.
|
|
186
|
+
* @param options - {@link Context.IContextMatchOptions | options} for the context match.
|
|
187
|
+
* @returns `Success` with an array of {@link Resources.Resource | resources} if successful, or `Failure` with an error message if not.
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
getBuiltResourcesForContext(context: Context.IValidatedContextDecl, options?: Context.IContextMatchOptions): Result<ReadonlyArray<Resource>>;
|
|
191
|
+
/**
|
|
192
|
+
* Gets a compiled resource collection from the current state of the resource manager builder.
|
|
193
|
+
* This method generates an optimized, index-based representation of all resources, conditions,
|
|
194
|
+
* and decisions that can be used for serialization or efficient runtime processing.
|
|
195
|
+
* @param options - Optional compilation options controlling the output format.
|
|
196
|
+
* @returns Success with the compiled resource collection if successful, Failure otherwise.
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
getCompiledResourceCollection(options?: ResourceJson.Compiled.ICompiledResourceOptions): Result<ResourceJson.Compiled.ICompiledResourceCollection>;
|
|
200
|
+
/**
|
|
201
|
+
* Gets a resource collection declaration containing all built resources in a flat array structure.
|
|
202
|
+
* This method returns all built resources as an {@link ResourceJson.Normalized.IResourceCollectionDecl | IResourceCollectionDecl}
|
|
203
|
+
* that can be used for serialization, export, or re-import. Resources are sorted by ID for consistent ordering.
|
|
204
|
+
* @param options - Optional {@link Resources.IResourceDeclarationOptions | declaration options} controlling the output format.
|
|
205
|
+
* If `options.normalized` is `true`, applies hash-based normalization for additional consistency guarantees.
|
|
206
|
+
* @returns Success with the resource collection declaration if successful, Failure otherwise.
|
|
207
|
+
* @public
|
|
208
|
+
*/
|
|
209
|
+
getResourceCollectionDecl(options?: IResourceDeclarationOptions): Result<ResourceJson.Normalized.IResourceCollectionDecl>;
|
|
210
|
+
/**
|
|
211
|
+
* Creates a filtered clone of this ResourceManagerBuilder using the specified context.
|
|
212
|
+
* This is a convenience method that creates a new ResourceManagerBuilder with the same
|
|
213
|
+
* configuration but filtered to include only candidates that match the provided context.
|
|
214
|
+
* @param options - Options for the cloning operation, including the strongly-typed filterForContext property.
|
|
215
|
+
* @returns A Result containing the new filtered ResourceManagerBuilder.
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
clone(options?: IResourceDeclarationOptions): Result<ResourceManagerBuilder>;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=resourceManagerBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resourceManagerBuilder.d.ts","sourceRoot":"","sources":["../../../src/packlets/resources/resourceManagerBuilder.ts"],"names":[],"mappings":"AAsBA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