@fgv/ts-res 4.5.0-3 → 5.0.0-10
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 +5253 -699
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.d.ts +13 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +29 -2
- package/lib/index.js.map +1 -1
- package/lib/packlets/bundle/bundleBuilder.d.ts +41 -0
- package/lib/packlets/bundle/bundleBuilder.d.ts.map +1 -0
- package/lib/packlets/bundle/bundleBuilder.js +134 -0
- package/lib/packlets/bundle/bundleBuilder.js.map +1 -0
- package/lib/packlets/bundle/bundleLoader.d.ts +72 -0
- package/lib/packlets/bundle/bundleLoader.d.ts.map +1 -0
- package/lib/packlets/bundle/bundleLoader.js +105 -0
- package/lib/packlets/bundle/bundleLoader.js.map +1 -0
- package/lib/packlets/bundle/bundleNormalizer.d.ts +73 -0
- package/lib/packlets/bundle/bundleNormalizer.d.ts.map +1 -0
- package/lib/packlets/bundle/bundleNormalizer.js +142 -0
- package/lib/packlets/bundle/bundleNormalizer.js.map +1 -0
- package/lib/packlets/bundle/bundleUtils.d.ts +70 -0
- package/lib/packlets/bundle/bundleUtils.d.ts.map +1 -0
- package/lib/packlets/bundle/bundleUtils.js +117 -0
- package/lib/packlets/bundle/bundleUtils.js.map +1 -0
- package/lib/packlets/bundle/convert.d.ts +33 -0
- package/lib/packlets/bundle/convert.d.ts.map +1 -0
- package/lib/packlets/bundle/convert.js +78 -0
- package/lib/packlets/bundle/convert.js.map +1 -0
- package/lib/packlets/bundle/index.d.ts +21 -0
- package/lib/packlets/bundle/index.d.ts.map +1 -0
- package/lib/packlets/bundle/index.js +83 -0
- package/lib/packlets/bundle/index.js.map +1 -0
- package/lib/packlets/bundle/model.d.ts +100 -0
- package/lib/packlets/bundle/model.d.ts.map +1 -0
- package/lib/packlets/bundle/model.js +24 -0
- package/lib/packlets/bundle/model.js.map +1 -0
- 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/resources.d.ts +8 -0
- package/lib/packlets/common/resources.d.ts.map +1 -1
- package/lib/packlets/common/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 +43 -3
- package/lib/packlets/conditions/conditionSet.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionSet.js +104 -3
- package/lib/packlets/conditions/conditionSet.js.map +1 -1
- package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionSetCollector.js +3 -0
- package/lib/packlets/conditions/conditionSetCollector.js.map +1 -1
- package/lib/packlets/conditions/conditionToken.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionToken.js +2 -1
- package/lib/packlets/conditions/conditionToken.js.map +1 -1
- package/lib/packlets/conditions/convert/decls.js +1 -1
- package/lib/packlets/conditions/convert/decls.js.map +1 -1
- package/lib/packlets/config/common.d.ts +35 -0
- package/lib/packlets/config/common.d.ts.map +1 -0
- package/lib/packlets/config/common.js +96 -0
- package/lib/packlets/config/common.js.map +1 -0
- package/lib/packlets/config/convert.d.ts +14 -0
- package/lib/packlets/config/convert.d.ts.map +1 -0
- package/lib/packlets/config/convert.js +82 -0
- package/lib/packlets/config/convert.js.map +1 -0
- package/lib/packlets/config/index.d.ts +6 -0
- package/lib/packlets/config/index.d.ts.map +1 -0
- package/lib/packlets/config/index.js +67 -0
- package/lib/packlets/config/index.js.map +1 -0
- package/lib/packlets/config/json.d.ts +20 -0
- package/lib/packlets/config/json.d.ts.map +1 -0
- package/lib/packlets/config/json.js +24 -0
- package/lib/packlets/config/json.js.map +1 -0
- package/lib/packlets/config/predefined/default.d.ts +57 -0
- package/lib/packlets/config/predefined/default.d.ts.map +1 -0
- package/lib/packlets/config/predefined/default.js +141 -0
- package/lib/packlets/config/predefined/default.js.map +1 -0
- package/lib/packlets/config/predefined/extended.d.ts +25 -0
- package/lib/packlets/config/predefined/extended.d.ts.map +1 -0
- package/lib/packlets/config/predefined/extended.js +193 -0
- package/lib/packlets/config/predefined/extended.js.map +1 -0
- package/lib/packlets/config/predefined/index.d.ts +4 -0
- package/lib/packlets/config/predefined/index.d.ts.map +1 -0
- package/lib/packlets/config/predefined/index.js +62 -0
- package/lib/packlets/config/predefined/index.js.map +1 -0
- package/lib/packlets/config/systemConfiguration.d.ts +81 -0
- package/lib/packlets/config/systemConfiguration.d.ts.map +1 -0
- package/lib/packlets/config/systemConfiguration.js +172 -0
- package/lib/packlets/config/systemConfiguration.js.map +1 -0
- package/lib/packlets/context/contextDecls.d.ts +49 -0
- package/lib/packlets/context/contextDecls.d.ts.map +1 -0
- package/lib/packlets/context/contextDecls.js +24 -0
- package/lib/packlets/context/contextDecls.js.map +1 -0
- package/lib/packlets/context/contextToken.d.ts +111 -0
- package/lib/packlets/context/contextToken.d.ts.map +1 -0
- package/lib/packlets/context/contextToken.js +206 -0
- package/lib/packlets/context/contextToken.js.map +1 -0
- package/lib/packlets/context/convert/decls.d.ts +37 -0
- package/lib/packlets/context/convert/decls.d.ts.map +1 -0
- package/lib/packlets/context/convert/decls.js +94 -0
- package/lib/packlets/context/convert/decls.js.map +1 -0
- package/lib/packlets/context/convert/index.d.ts +2 -0
- package/lib/packlets/context/convert/index.d.ts.map +1 -0
- package/lib/packlets/context/convert/index.js +39 -0
- package/lib/packlets/context/convert/index.js.map +1 -0
- package/lib/packlets/context/index.d.ts +5 -0
- package/lib/packlets/context/index.d.ts.map +1 -0
- package/lib/packlets/context/index.js +65 -0
- package/lib/packlets/context/index.js.map +1 -0
- package/lib/packlets/decisions/abstractDecision.d.ts +8 -0
- package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -1
- package/lib/packlets/decisions/abstractDecision.js +9 -0
- package/lib/packlets/decisions/abstractDecision.js.map +1 -1
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -1
- package/lib/packlets/decisions/abstractDecisionCollector.js +2 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -1
- package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -1
- package/lib/packlets/decisions/concreteDecision.js +1 -0
- package/lib/packlets/decisions/concreteDecision.js.map +1 -1
- package/lib/packlets/decisions/decision.d.ts.map +1 -1
- package/lib/packlets/decisions/decision.js +4 -0
- package/lib/packlets/decisions/decision.js.map +1 -1
- package/lib/packlets/import/fsItem.d.ts.map +1 -1
- package/lib/packlets/import/fsItem.js +8 -12
- 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 +11 -20
- package/lib/packlets/import/importers/jsonImporter.js.map +1 -1
- package/lib/packlets/import/importers/pathImporter.d.ts +2 -2
- package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -1
- package/lib/packlets/import/importers/pathImporter.js.map +1 -1
- package/lib/packlets/qualifier-types/config/convert.d.ts +44 -0
- package/lib/packlets/qualifier-types/config/convert.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/convert.js +96 -0
- package/lib/packlets/qualifier-types/config/convert.js.map +1 -0
- package/lib/packlets/qualifier-types/config/index.d.ts +4 -0
- package/lib/packlets/qualifier-types/config/index.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/index.js +64 -0
- package/lib/packlets/qualifier-types/config/index.js.map +1 -0
- package/lib/packlets/qualifier-types/config/json.d.ts +69 -0
- package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/json.js +24 -0
- package/lib/packlets/qualifier-types/config/json.js.map +1 -0
- package/lib/packlets/qualifier-types/convert.d.ts +10 -2
- package/lib/packlets/qualifier-types/convert.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/convert.js +15 -0
- package/lib/packlets/qualifier-types/convert.js.map +1 -1
- package/lib/packlets/qualifier-types/helpers.d.ts +27 -0
- package/lib/packlets/qualifier-types/helpers.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/helpers.js +118 -0
- package/lib/packlets/qualifier-types/helpers.js.map +1 -0
- package/lib/packlets/qualifier-types/index.d.ts +4 -1
- package/lib/packlets/qualifier-types/index.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/index.js +5 -1
- package/lib/packlets/qualifier-types/index.js.map +1 -1
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +19 -8
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/languageQualifierType.js +28 -9
- package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +42 -13
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/literalQualifierType.js +58 -10
- package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +114 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.js +228 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts +33 -18
- package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/qualifierType.js +18 -4
- package/lib/packlets/qualifier-types/qualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts +4 -2
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js +2 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -1
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +47 -11
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/territoryQualifierType.js +61 -17
- package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -1
- package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -1
- package/lib/packlets/qualifiers/convert/decls.js +17 -15
- package/lib/packlets/qualifiers/convert/decls.js.map +1 -1
- package/lib/packlets/qualifiers/index.d.ts +2 -0
- package/lib/packlets/qualifiers/index.d.ts.map +1 -1
- package/lib/packlets/qualifiers/index.js +2 -0
- package/lib/packlets/qualifiers/index.js.map +1 -1
- package/lib/packlets/qualifiers/qualifier.d.ts +22 -2
- package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -1
- package/lib/packlets/qualifiers/qualifier.js +26 -1
- package/lib/packlets/qualifiers/qualifier.js.map +1 -1
- package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -1
- package/lib/packlets/qualifiers/qualifierCollector.js +3 -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 +8 -16
- package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -1
- package/lib/packlets/resource-types/jsonResourceType.js +6 -3
- package/lib/packlets/resource-types/jsonResourceType.js.map +1 -1
- package/lib/packlets/resource-types/resourceType.d.ts +45 -35
- 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 +72 -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 +46 -6
- package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -1
- package/lib/packlets/resources/resourceCandidate.js +46 -1
- package/lib/packlets/resources/resourceCandidate.js.map +1 -1
- package/lib/packlets/resources/resourceManagerBuilder.d.ts +347 -0
- package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +1 -0
- package/lib/packlets/resources/resourceManagerBuilder.js +893 -0
- package/lib/packlets/resources/resourceManagerBuilder.js.map +1 -0
- package/lib/packlets/runtime/cacheListener.d.ts +71 -0
- package/lib/packlets/runtime/cacheListener.d.ts.map +1 -0
- package/lib/packlets/runtime/cacheListener.js +62 -0
- package/lib/packlets/runtime/cacheListener.js.map +1 -0
- package/lib/packlets/runtime/cacheMetrics.d.ts +88 -0
- package/lib/packlets/runtime/cacheMetrics.d.ts.map +1 -0
- package/lib/packlets/runtime/cacheMetrics.js +154 -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 +94 -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 +217 -0
- package/lib/packlets/runtime/resourceResolver.d.ts.map +1 -0
- package/lib/packlets/runtime/resourceResolver.js +459 -0
- package/lib/packlets/runtime/resourceResolver.js.map +1 -0
- package/lib/packlets/runtime/validate.d.ts +13 -0
- package/lib/packlets/runtime/validate.d.ts.map +1 -0
- package/lib/packlets/runtime/validate.js +49 -0
- package/lib/packlets/runtime/validate.js.map +1 -0
- package/package.json +76 -75
- package/lib/packlets/resources/resourceManager.d.ts +0 -104
- package/lib/packlets/resources/resourceManager.d.ts.map +0 -1
- package/lib/packlets/resources/resourceManager.js +0 -201
- package/lib/packlets/resources/resourceManager.js.map +0 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Collections, Result } from '@fgv/ts-utils';
|
|
2
|
+
import { ReadOnlyConditionCollector, ReadOnlyConditionSetCollector } from '../conditions';
|
|
3
|
+
import { ReadOnlyAbstractDecisionCollector } from '../decisions';
|
|
4
|
+
import { QualifierCollector } from '../qualifiers';
|
|
5
|
+
import { ResourceType, ResourceTypeCollector } from '../resource-types';
|
|
6
|
+
import { QualifierType, QualifierTypeCollector } from '../qualifier-types';
|
|
7
|
+
import { ResourceId } from '../common';
|
|
8
|
+
import { IResourceManager, IResource } from './iResourceManager';
|
|
9
|
+
import * as ResourceJson from '../resource-json';
|
|
10
|
+
import { IReadOnlyResourceTreeRoot } from './resource-tree';
|
|
11
|
+
import * as Context from '../context';
|
|
12
|
+
/**
|
|
13
|
+
* Interface for parameters to create a {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface ICompiledResourceCollectionCreateParams {
|
|
17
|
+
/**
|
|
18
|
+
* The compiled resource collection data.
|
|
19
|
+
*/
|
|
20
|
+
compiledCollection: ResourceJson.Compiled.ICompiledResourceCollection;
|
|
21
|
+
/**
|
|
22
|
+
* Map of qualifier type names to qualifier type objects.
|
|
23
|
+
*/
|
|
24
|
+
qualifierTypes: Collections.IReadOnlyResultMap<string, QualifierType>;
|
|
25
|
+
/**
|
|
26
|
+
* Map of resource type names to resource type objects.
|
|
27
|
+
*/
|
|
28
|
+
resourceTypes: Collections.IReadOnlyResultMap<string, ResourceType>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A compiled resource collection implements {@link Runtime.IResourceManager | IResourceManager}
|
|
32
|
+
* by reconstructing runtime objects from compiled data. This provides an efficient way to load
|
|
33
|
+
* and use pre-compiled resource collections without rebuilding them from scratch.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare class CompiledResourceCollection implements IResourceManager<IResource> {
|
|
37
|
+
readonly conditions: ReadOnlyConditionCollector;
|
|
38
|
+
readonly conditionSets: ReadOnlyConditionSetCollector;
|
|
39
|
+
readonly decisions: ReadOnlyAbstractDecisionCollector;
|
|
40
|
+
private readonly _qualifierTypes;
|
|
41
|
+
private readonly _qualifiers;
|
|
42
|
+
private readonly _resourceTypes;
|
|
43
|
+
private readonly _builtResources;
|
|
44
|
+
private _cachedResourceTree?;
|
|
45
|
+
/**
|
|
46
|
+
* A {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} which
|
|
47
|
+
* contains the {@link QualifierTypes.QualifierType | qualifier types} used in this collection.
|
|
48
|
+
*/
|
|
49
|
+
get qualifierTypes(): QualifierTypeCollector;
|
|
50
|
+
/**
|
|
51
|
+
* A {@link Qualifiers.QualifierCollector | QualifierCollector} which
|
|
52
|
+
* contains the {@link Qualifiers.Qualifier | qualifiers} used in this collection.
|
|
53
|
+
*/
|
|
54
|
+
get qualifiers(): QualifierCollector;
|
|
55
|
+
/**
|
|
56
|
+
* A {@link ResourceTypes.ResourceTypeCollector | ResourceTypeCollector} which
|
|
57
|
+
* contains the {@link ResourceTypes.ResourceType | resource types} used in this collection.
|
|
58
|
+
*/
|
|
59
|
+
get resourceTypes(): ResourceTypeCollector;
|
|
60
|
+
/**
|
|
61
|
+
* {@inheritdoc Runtime.IResourceManager.builtResources}
|
|
62
|
+
*/
|
|
63
|
+
get builtResources(): Collections.IReadOnlyValidatingResultMap<ResourceId, IResource>;
|
|
64
|
+
/**
|
|
65
|
+
* {@inheritdoc Runtime.IResourceManager.numResources}
|
|
66
|
+
*/
|
|
67
|
+
get numResources(): number;
|
|
68
|
+
protected _numCandidates?: number;
|
|
69
|
+
/**
|
|
70
|
+
* {@inheritdoc Runtime.IResourceManager.numCandidates}
|
|
71
|
+
*/
|
|
72
|
+
get numCandidates(): number;
|
|
73
|
+
/**
|
|
74
|
+
* Constructor for a {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object.
|
|
75
|
+
* @param params - Parameters to create a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
protected constructor(params: ICompiledResourceCollectionCreateParams);
|
|
79
|
+
/**
|
|
80
|
+
* Creates a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object.
|
|
81
|
+
* @param params - Parameters to create a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.
|
|
82
|
+
* @returns `Success` with the new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object if successful,
|
|
83
|
+
* or `Failure` with an error message if not.
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
static create(params: ICompiledResourceCollectionCreateParams): Result<CompiledResourceCollection>;
|
|
87
|
+
/**
|
|
88
|
+
* {@inheritdoc Runtime.IResourceManager.getBuiltResource}
|
|
89
|
+
*/
|
|
90
|
+
getBuiltResource(id: string): Result<IResource>;
|
|
91
|
+
/**
|
|
92
|
+
* {@inheritdoc Runtime.IResourceManager.validateContext}
|
|
93
|
+
*/
|
|
94
|
+
validateContext(context: Context.IContextDecl): Result<Context.IValidatedContextDecl>;
|
|
95
|
+
/**
|
|
96
|
+
* Gets a resource tree built from the resources in this collection.
|
|
97
|
+
* The tree provides hierarchical access to resources based on their ResourceId structure.
|
|
98
|
+
* For example, resources with IDs like "app.messages.welcome" create a tree structure
|
|
99
|
+
* where "app" and "messages" are branch nodes, and "welcome" is a leaf containing the resource.
|
|
100
|
+
*
|
|
101
|
+
* String-based validation is available through the `children.validating` property,
|
|
102
|
+
* allowing callers to use `tree.children.validating.getById(stringId)` for validated access.
|
|
103
|
+
*
|
|
104
|
+
* Uses lazy initialization with caching for performance.
|
|
105
|
+
* @returns Result containing the resource tree root, or failure if tree construction fails
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
getBuiltResourceTree(): Result<IReadOnlyResourceTreeRoot<IResource>>;
|
|
109
|
+
/**
|
|
110
|
+
* Reconstructs a QualifierTypeCollector from compiled data.
|
|
111
|
+
* @param compiled - The compiled resource collection
|
|
112
|
+
* @param qualifierTypes - Map of qualifier type names to qualifier type objects
|
|
113
|
+
* @returns The reconstructed QualifierTypeCollector
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
private _buildQualifierTypes;
|
|
117
|
+
/**
|
|
118
|
+
* Reconstructs a QualifierCollector from compiled data.
|
|
119
|
+
* @param compiled - The compiled resource collection
|
|
120
|
+
* @param qualifierTypes - The reconstructed QualifierTypeCollector
|
|
121
|
+
* @returns The reconstructed QualifierCollector
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
private _buildQualifiers;
|
|
125
|
+
/**
|
|
126
|
+
* Reconstructs a ResourceTypeCollector from compiled data.
|
|
127
|
+
* @param compiled - The compiled resource collection
|
|
128
|
+
* @param resourceTypes - Map of resource type names to resource type objects
|
|
129
|
+
* @returns The reconstructed ResourceTypeCollector
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
private _buildResourceTypes;
|
|
133
|
+
/**
|
|
134
|
+
* Reconstructs a ConditionCollector from compiled data.
|
|
135
|
+
* @param compiled - The compiled resource collection
|
|
136
|
+
* @param qualifiers - The reconstructed QualifierCollector
|
|
137
|
+
* @returns The reconstructed ConditionCollector
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
private _buildConditions;
|
|
141
|
+
/**
|
|
142
|
+
* Reconstructs a ConditionSetCollector from compiled data.
|
|
143
|
+
* @param compiled - The compiled resource collection
|
|
144
|
+
* @param conditions - The reconstructed ConditionCollector
|
|
145
|
+
* @returns The reconstructed ConditionSetCollector
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
private _buildConditionSets;
|
|
149
|
+
/**
|
|
150
|
+
* Reconstructs an AbstractDecisionCollector from compiled data.
|
|
151
|
+
* @param compiled - The compiled resource collection
|
|
152
|
+
* @param conditionSets - The reconstructed ConditionSetCollector
|
|
153
|
+
* @returns The reconstructed AbstractDecisionCollector
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
private _buildDecisions;
|
|
157
|
+
/**
|
|
158
|
+
* Reconstructs a ValidatingResultMap of resources from compiled data.
|
|
159
|
+
* @param compiled - The compiled resource collection
|
|
160
|
+
* @param resourceTypes - The reconstructed ResourceTypeCollector
|
|
161
|
+
* @param decisions - The reconstructed AbstractDecisionCollector
|
|
162
|
+
* @returns The reconstructed ValidatingResultMap of resources
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
private _buildResources;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=compiledResourceCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiledResourceCollection.d.ts","sourceRoot":"","sources":["../../../src/packlets/runtime/compiledResourceCollection.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,WAAW,EAIX,MAAM,EAGP,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAA6B,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAW,UAAU,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAsB,MAAM,oBAAoB,CAAC;AAGrF,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAA4B,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,uCAAuC;IACtD;;OAEG;IACH,kBAAkB,EAAE,YAAY,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IACtE;;OAEG;IACH,cAAc,EAAE,WAAW,CAAC,kBAAkB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACtE;;OAEG;IACH,aAAa,EAAE,WAAW,CAAC,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACrE;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,YAAW,gBAAgB,CAAC,SAAS,CAAC;IAC5E,SAAgB,UAAU,EAAE,0BAA0B,CAAC;IACvD,SAAgB,aAAa,EAAE,6BAA6B,CAAC;IAC7D,SAAgB,SAAS,EAAE,iCAAiC,CAAC;IAE7D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IACzD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAwB;IACvD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6C;IAC7E,OAAO,CAAC,mBAAmB,CAAC,CAAsC;IAElE;;;OAGG;IACH,IAAW,cAAc,IAAI,sBAAsB,CAElD;IAED;;;OAGG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;;OAGG;IACH,IAAW,aAAa,IAAI,qBAAqB,CAEhD;IAED;;OAEG;IACH,IAAW,cAAc,IAAI,WAAW,CAAC,4BAA4B,CAAC,UAAU,EAAE,SAAS,CAAC,CAE3F;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED,SAAS,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,IAAW,aAAa,IAAI,MAAM,CAQjC;IAED;;;;OAIG;IACH,SAAS,aAAa,MAAM,EAAE,uCAAuC;IAgCrE;;;;;;OAMG;WACW,MAAM,CAAC,MAAM,EAAE,uCAAuC,GAAG,MAAM,CAAC,0BAA0B,CAAC;IAIzG;;OAEG;IACI,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC;IAItD;;OAEG;IACI,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC;IAM5F;;;;;;;;;;;;OAYG;IACI,oBAAoB,IAAI,MAAM,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAC;IAkB3E;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAsBxB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IA6DxB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAqD3B;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAqDvB;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;CAkGxB"}
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.CompiledResourceCollection = void 0;
|
|
58
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
59
|
+
const conditions_1 = require("../conditions");
|
|
60
|
+
const decisions_1 = require("../decisions");
|
|
61
|
+
const qualifiers_1 = require("../qualifiers");
|
|
62
|
+
const resource_types_1 = require("../resource-types");
|
|
63
|
+
const qualifier_types_1 = require("../qualifier-types");
|
|
64
|
+
const common_1 = require("../common");
|
|
65
|
+
const ts_json_base_1 = require("@fgv/ts-json-base");
|
|
66
|
+
const decisions_2 = require("../decisions");
|
|
67
|
+
const Validate = __importStar(require("./validate"));
|
|
68
|
+
const resource_tree_1 = require("./resource-tree");
|
|
69
|
+
const Context = __importStar(require("../context"));
|
|
70
|
+
/**
|
|
71
|
+
* A compiled resource collection implements {@link Runtime.IResourceManager | IResourceManager}
|
|
72
|
+
* by reconstructing runtime objects from compiled data. This provides an efficient way to load
|
|
73
|
+
* and use pre-compiled resource collections without rebuilding them from scratch.
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
class CompiledResourceCollection {
|
|
77
|
+
/**
|
|
78
|
+
* A {@link QualifierTypes.QualifierTypeCollector | QualifierTypeCollector} which
|
|
79
|
+
* contains the {@link QualifierTypes.QualifierType | qualifier types} used in this collection.
|
|
80
|
+
*/
|
|
81
|
+
get qualifierTypes() {
|
|
82
|
+
return this._qualifierTypes;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A {@link Qualifiers.QualifierCollector | QualifierCollector} which
|
|
86
|
+
* contains the {@link Qualifiers.Qualifier | qualifiers} used in this collection.
|
|
87
|
+
*/
|
|
88
|
+
get qualifiers() {
|
|
89
|
+
return this._qualifiers;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A {@link ResourceTypes.ResourceTypeCollector | ResourceTypeCollector} which
|
|
93
|
+
* contains the {@link ResourceTypes.ResourceType | resource types} used in this collection.
|
|
94
|
+
*/
|
|
95
|
+
get resourceTypes() {
|
|
96
|
+
return this._resourceTypes;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* {@inheritdoc Runtime.IResourceManager.builtResources}
|
|
100
|
+
*/
|
|
101
|
+
get builtResources() {
|
|
102
|
+
return this._builtResources;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* {@inheritdoc Runtime.IResourceManager.numResources}
|
|
106
|
+
*/
|
|
107
|
+
get numResources() {
|
|
108
|
+
return this._builtResources.size;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* {@inheritdoc Runtime.IResourceManager.numCandidates}
|
|
112
|
+
*/
|
|
113
|
+
get numCandidates() {
|
|
114
|
+
if (this._numCandidates === undefined) {
|
|
115
|
+
this._numCandidates = [...this._builtResources.values()].reduce((acc, resource) => acc + resource.candidates.length, 0);
|
|
116
|
+
}
|
|
117
|
+
return this._numCandidates;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Constructor for a {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object.
|
|
121
|
+
* @param params - Parameters to create a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
constructor(params) {
|
|
125
|
+
// Reconstruct collectors from compiled data
|
|
126
|
+
this._qualifierTypes = this._buildQualifierTypes(params.compiledCollection, params.qualifierTypes).orThrow();
|
|
127
|
+
this._qualifiers = this._buildQualifiers(params.compiledCollection, this._qualifierTypes).orThrow();
|
|
128
|
+
this._resourceTypes = this._buildResourceTypes(params.compiledCollection, params.resourceTypes).orThrow();
|
|
129
|
+
// Build collectors from compiled data
|
|
130
|
+
const conditionCollector = this._buildConditions(params.compiledCollection, this._qualifiers).orThrow();
|
|
131
|
+
const conditionSetCollector = this._buildConditionSets(params.compiledCollection, conditionCollector).orThrow();
|
|
132
|
+
const decisionCollector = this._buildDecisions(params.compiledCollection, conditionSetCollector).orThrow();
|
|
133
|
+
this.conditions = conditionCollector;
|
|
134
|
+
this.conditionSets = conditionSetCollector;
|
|
135
|
+
this.decisions = decisionCollector;
|
|
136
|
+
// Build resources from compiled data
|
|
137
|
+
this._builtResources = this._buildResources(params.compiledCollection, this._resourceTypes, decisionCollector).orThrow();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Creates a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object.
|
|
141
|
+
* @param params - Parameters to create a new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.
|
|
142
|
+
* @returns `Success` with the new {@link Runtime.CompiledResourceCollection | CompiledResourceCollection} object if successful,
|
|
143
|
+
* or `Failure` with an error message if not.
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
static create(params) {
|
|
147
|
+
return (0, ts_utils_1.captureResult)(() => new CompiledResourceCollection(params));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* {@inheritdoc Runtime.IResourceManager.getBuiltResource}
|
|
151
|
+
*/
|
|
152
|
+
getBuiltResource(id) {
|
|
153
|
+
return this._builtResources.validating.get(id);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* {@inheritdoc Runtime.IResourceManager.validateContext}
|
|
157
|
+
*/
|
|
158
|
+
validateContext(context) {
|
|
159
|
+
return Context.Convert.validatedContextDecl.convert(context, {
|
|
160
|
+
qualifiers: this._qualifiers
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Gets a resource tree built from the resources in this collection.
|
|
165
|
+
* The tree provides hierarchical access to resources based on their ResourceId structure.
|
|
166
|
+
* For example, resources with IDs like "app.messages.welcome" create a tree structure
|
|
167
|
+
* where "app" and "messages" are branch nodes, and "welcome" is a leaf containing the resource.
|
|
168
|
+
*
|
|
169
|
+
* String-based validation is available through the `children.validating` property,
|
|
170
|
+
* allowing callers to use `tree.children.validating.getById(stringId)` for validated access.
|
|
171
|
+
*
|
|
172
|
+
* Uses lazy initialization with caching for performance.
|
|
173
|
+
* @returns Result containing the resource tree root, or failure if tree construction fails
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
getBuiltResourceTree() {
|
|
177
|
+
if (this._cachedResourceTree) {
|
|
178
|
+
return (0, ts_utils_1.succeed)(this._cachedResourceTree);
|
|
179
|
+
}
|
|
180
|
+
// Convert all built resources to [ResourceId, IResource] pairs
|
|
181
|
+
const resources = [];
|
|
182
|
+
for (const [id, resource] of this._builtResources.entries()) {
|
|
183
|
+
resources.push([id, resource]);
|
|
184
|
+
}
|
|
185
|
+
// Create the resource tree with lazy initialization
|
|
186
|
+
return resource_tree_1.ReadOnlyResourceTreeRoot.create(resources).onSuccess((tree) => {
|
|
187
|
+
this._cachedResourceTree = tree;
|
|
188
|
+
return (0, ts_utils_1.succeed)(tree);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Reconstructs a QualifierTypeCollector from compiled data.
|
|
193
|
+
* @param compiled - The compiled resource collection
|
|
194
|
+
* @param qualifierTypes - Map of qualifier type names to qualifier type objects
|
|
195
|
+
* @returns The reconstructed QualifierTypeCollector
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
_buildQualifierTypes(compiled, qualifierTypes) {
|
|
199
|
+
return (0, ts_utils_1.mapResults)(compiled.qualifierTypes.map((compiledQualifierType) => qualifierTypes.get(compiledQualifierType.name))).onSuccess((referencedQualifierTypes) => {
|
|
200
|
+
return qualifier_types_1.QualifierTypeCollector.create({
|
|
201
|
+
qualifierTypes: referencedQualifierTypes
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Reconstructs a QualifierCollector from compiled data.
|
|
207
|
+
* @param compiled - The compiled resource collection
|
|
208
|
+
* @param qualifierTypes - The reconstructed QualifierTypeCollector
|
|
209
|
+
* @returns The reconstructed QualifierCollector
|
|
210
|
+
* @internal
|
|
211
|
+
*/
|
|
212
|
+
_buildQualifiers(compiled, qualifierTypes) {
|
|
213
|
+
return (0, ts_utils_1.mapResults)(compiled.qualifiers.map((compiledQualifier) => {
|
|
214
|
+
return qualifierTypes.getAt(compiledQualifier.type).onSuccess((qualifierType) => {
|
|
215
|
+
return (0, ts_utils_1.succeed)({
|
|
216
|
+
name: compiledQualifier.name,
|
|
217
|
+
typeName: qualifierType.name,
|
|
218
|
+
defaultPriority: compiledQualifier.defaultPriority
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
})).onSuccess((qualifierDecls) => {
|
|
222
|
+
return qualifiers_1.QualifierCollector.create({
|
|
223
|
+
qualifierTypes,
|
|
224
|
+
qualifiers: qualifierDecls
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Reconstructs a ResourceTypeCollector from compiled data.
|
|
230
|
+
* @param compiled - The compiled resource collection
|
|
231
|
+
* @param resourceTypes - Map of resource type names to resource type objects
|
|
232
|
+
* @returns The reconstructed ResourceTypeCollector
|
|
233
|
+
* @internal
|
|
234
|
+
*/
|
|
235
|
+
_buildResourceTypes(compiled, resourceTypes) {
|
|
236
|
+
return (0, ts_utils_1.mapResults)(compiled.resourceTypes.map((compiledResourceType) => resourceTypes.get(compiledResourceType.name))).onSuccess((referencedResourceTypes) => {
|
|
237
|
+
return resource_types_1.ResourceTypeCollector.create({
|
|
238
|
+
resourceTypes: referencedResourceTypes
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Reconstructs a ConditionCollector from compiled data.
|
|
244
|
+
* @param compiled - The compiled resource collection
|
|
245
|
+
* @param qualifiers - The reconstructed QualifierCollector
|
|
246
|
+
* @returns The reconstructed ConditionCollector
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
_buildConditions(compiled, qualifiers) {
|
|
250
|
+
var _a;
|
|
251
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
252
|
+
const conditionCollectorResult = conditions_1.ConditionCollector.create({ qualifiers });
|
|
253
|
+
/* c8 ignore next 3 - defensive coding for ConditionCollector creation failure */
|
|
254
|
+
if (conditionCollectorResult.isFailure()) {
|
|
255
|
+
return conditionCollectorResult;
|
|
256
|
+
}
|
|
257
|
+
const conditionCollector = conditionCollectorResult.value;
|
|
258
|
+
for (const [index, compiledCondition] of compiled.conditions.entries()) {
|
|
259
|
+
const qualifierResult = qualifiers.getAt(compiledCondition.qualifierIndex);
|
|
260
|
+
if (qualifierResult.isFailure()) {
|
|
261
|
+
errors.addMessage(`Invalid qualifier index ${compiledCondition.qualifierIndex} at condition ${index}: ${qualifierResult.message}`);
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const qualifier = qualifierResult.value;
|
|
265
|
+
/* c8 ignore next 1 - not really testable atm as "matches" is the only supported operator */
|
|
266
|
+
const operator = (_a = compiledCondition.operator) !== null && _a !== void 0 ? _a : 'matches'; // Default to 'matches' if not provided
|
|
267
|
+
const conditionDecl = {
|
|
268
|
+
qualifierName: qualifier.name,
|
|
269
|
+
value: compiledCondition.value,
|
|
270
|
+
operator,
|
|
271
|
+
priority: compiledCondition.priority,
|
|
272
|
+
scoreAsDefault: compiledCondition.scoreAsDefault
|
|
273
|
+
};
|
|
274
|
+
const conditionResult = conditionCollector.validating.add(conditionDecl);
|
|
275
|
+
/* c8 ignore next 4 - defensive coding for condition addition failure */
|
|
276
|
+
if (conditionResult.isFailure()) {
|
|
277
|
+
errors.addMessage(`Failed to add condition at index ${index}: ${conditionResult.message}`);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const condition = conditionResult.value;
|
|
281
|
+
// Validate that the assigned index matches our expected index
|
|
282
|
+
const expectedIndexResult = common_1.Convert.conditionIndex.convert(index);
|
|
283
|
+
/* c8 ignore next 4 - defensive coding for invalid condition index conversion */
|
|
284
|
+
if (expectedIndexResult.isFailure()) {
|
|
285
|
+
errors.addMessage(`Invalid condition index ${index}: ${expectedIndexResult.message}`);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const expectedIndex = expectedIndexResult.value;
|
|
289
|
+
/* c8 ignore next 5 - defensive coding for condition index mismatch */
|
|
290
|
+
if (condition.index !== expectedIndex) {
|
|
291
|
+
errors.addMessage(`Index mismatch at condition ${index}: expected ${expectedIndex}, got ${condition.index}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return errors.hasMessages ? (0, ts_utils_1.fail)(errors.toString()) : (0, ts_utils_1.succeed)(conditionCollector);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Reconstructs a ConditionSetCollector from compiled data.
|
|
298
|
+
* @param compiled - The compiled resource collection
|
|
299
|
+
* @param conditions - The reconstructed ConditionCollector
|
|
300
|
+
* @returns The reconstructed ConditionSetCollector
|
|
301
|
+
* @internal
|
|
302
|
+
*/
|
|
303
|
+
_buildConditionSets(compiled, conditions) {
|
|
304
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
305
|
+
const conditionSetCollectorResult = conditions_1.ConditionSetCollector.create({ conditions });
|
|
306
|
+
/* c8 ignore next 3 - defensive coding for ConditionSetCollector creation failure */
|
|
307
|
+
if (conditionSetCollectorResult.isFailure()) {
|
|
308
|
+
return conditionSetCollectorResult;
|
|
309
|
+
}
|
|
310
|
+
const conditionSetCollector = conditionSetCollectorResult.value;
|
|
311
|
+
for (const [index, compiledConditionSet] of compiled.conditionSets.entries()) {
|
|
312
|
+
const referencedConditionsResult = (0, ts_utils_1.mapResults)(compiledConditionSet.conditions.map((conditionIndex) => conditions.getAt(conditionIndex)));
|
|
313
|
+
if (referencedConditionsResult.isFailure()) {
|
|
314
|
+
errors.addMessage(`Failed to resolve conditions for condition set ${index}: ${referencedConditionsResult.message}`);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const referencedConditions = referencedConditionsResult.value;
|
|
318
|
+
const conditionSetResult = conditionSetCollector.validating.getOrAdd(referencedConditions);
|
|
319
|
+
/* c8 ignore next 4 - defensive coding for condition set addition failure */
|
|
320
|
+
if (conditionSetResult.isFailure()) {
|
|
321
|
+
errors.addMessage(`Failed to add condition set at index ${index}: ${conditionSetResult.message}`);
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
const conditionSet = conditionSetResult.value;
|
|
325
|
+
// Validate that the assigned index matches our expected index
|
|
326
|
+
const expectedIndexResult = common_1.Convert.conditionSetIndex.convert(index);
|
|
327
|
+
/* c8 ignore next 4 - defensive coding for invalid condition set index conversion */
|
|
328
|
+
if (expectedIndexResult.isFailure()) {
|
|
329
|
+
errors.addMessage(`Invalid condition set index ${index}: ${expectedIndexResult.message}`);
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const expectedIndex = expectedIndexResult.value;
|
|
333
|
+
/* c8 ignore next 5 - defensive coding for condition set index mismatch */
|
|
334
|
+
if (conditionSet.index !== expectedIndex) {
|
|
335
|
+
errors.addMessage(`Index mismatch at condition set ${index}: expected ${expectedIndex}, got ${conditionSet.index}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return errors.hasMessages ? (0, ts_utils_1.fail)(errors.toString()) : (0, ts_utils_1.succeed)(conditionSetCollector);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Reconstructs an AbstractDecisionCollector from compiled data.
|
|
342
|
+
* @param compiled - The compiled resource collection
|
|
343
|
+
* @param conditionSets - The reconstructed ConditionSetCollector
|
|
344
|
+
* @returns The reconstructed AbstractDecisionCollector
|
|
345
|
+
* @internal
|
|
346
|
+
*/
|
|
347
|
+
_buildDecisions(compiled, conditionSets) {
|
|
348
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
349
|
+
const decisionCollectorResult = decisions_1.AbstractDecisionCollector.create({ conditionSets });
|
|
350
|
+
/* c8 ignore next 3 - defensive coding for AbstractDecisionCollector creation failure */
|
|
351
|
+
if (decisionCollectorResult.isFailure()) {
|
|
352
|
+
return decisionCollectorResult;
|
|
353
|
+
}
|
|
354
|
+
const decisionCollector = decisionCollectorResult.value;
|
|
355
|
+
for (const [index, compiledDecision] of compiled.decisions.entries()) {
|
|
356
|
+
const referencedConditionSetsResult = (0, ts_utils_1.mapResults)(compiledDecision.conditionSets.map((conditionSetIndex) => conditionSets.getAt(conditionSetIndex)));
|
|
357
|
+
if (referencedConditionSetsResult.isFailure()) {
|
|
358
|
+
errors.addMessage(`Failed to resolve condition sets for decision ${index}: ${referencedConditionSetsResult.message}`);
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const referencedConditionSets = referencedConditionSetsResult.value;
|
|
362
|
+
const decisionResult = decisionCollector.validating.getOrAdd(referencedConditionSets);
|
|
363
|
+
/* c8 ignore next 4 - defensive coding for decision addition failure */
|
|
364
|
+
if (decisionResult.isFailure()) {
|
|
365
|
+
errors.addMessage(`Failed to add decision at index ${index}: ${decisionResult.message}`);
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
const decision = decisionResult.value;
|
|
369
|
+
// Validate that the assigned index matches our expected index
|
|
370
|
+
const expectedIndexResult = common_1.Convert.decisionIndex.convert(index);
|
|
371
|
+
/* c8 ignore next 4 - defensive coding for invalid decision index conversion */
|
|
372
|
+
if (expectedIndexResult.isFailure()) {
|
|
373
|
+
errors.addMessage(`Invalid decision index ${index}: ${expectedIndexResult.message}`);
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
const expectedIndex = expectedIndexResult.value;
|
|
377
|
+
/* c8 ignore next 5 - defensive coding for decision index mismatch */
|
|
378
|
+
if (decision.index !== expectedIndex) {
|
|
379
|
+
errors.addMessage(`Index mismatch at decision ${index}: expected ${expectedIndex}, got ${decision.index}`);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return errors.hasMessages ? (0, ts_utils_1.fail)(errors.toString()) : (0, ts_utils_1.succeed)(decisionCollector);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Reconstructs a ValidatingResultMap of resources from compiled data.
|
|
386
|
+
* @param compiled - The compiled resource collection
|
|
387
|
+
* @param resourceTypes - The reconstructed ResourceTypeCollector
|
|
388
|
+
* @param decisions - The reconstructed AbstractDecisionCollector
|
|
389
|
+
* @returns The reconstructed ValidatingResultMap of resources
|
|
390
|
+
* @internal
|
|
391
|
+
*/
|
|
392
|
+
_buildResources(compiled, resourceTypes, decisions) {
|
|
393
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
394
|
+
const resourceMap = new ts_utils_1.ValidatingResultMap({
|
|
395
|
+
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
396
|
+
key: common_1.Convert.resourceId,
|
|
397
|
+
value: (from) => {
|
|
398
|
+
return Validate.resource.validate(from);
|
|
399
|
+
}
|
|
400
|
+
})
|
|
401
|
+
});
|
|
402
|
+
for (const compiledResource of compiled.resources) {
|
|
403
|
+
const resourceTypeResult = resourceTypes.getAt(compiledResource.type);
|
|
404
|
+
if (resourceTypeResult.isFailure()) {
|
|
405
|
+
errors.addMessage(`Invalid resource type index ${compiledResource.type} for resource ${compiledResource.id}: ${resourceTypeResult.message}`);
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
const resourceType = resourceTypeResult.value;
|
|
409
|
+
const decisionResult = decisions.getAt(compiledResource.decision);
|
|
410
|
+
if (decisionResult.isFailure()) {
|
|
411
|
+
errors.addMessage(`Invalid decision index ${compiledResource.decision} for resource ${compiledResource.id}: ${decisionResult.message}`);
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
const decision = decisionResult.value;
|
|
415
|
+
// Build candidates from compiled data
|
|
416
|
+
const candidateDeclsResult = (0, ts_utils_1.mapResults)(compiledResource.candidates.map((compiledCandidate) => ts_json_base_1.Converters.jsonObject.convert(compiledCandidate.json).onSuccess((json) => {
|
|
417
|
+
return (0, ts_utils_1.succeed)({
|
|
418
|
+
json,
|
|
419
|
+
isPartial: compiledCandidate.isPartial,
|
|
420
|
+
mergeMethod: compiledCandidate.mergeMethod
|
|
421
|
+
});
|
|
422
|
+
})));
|
|
423
|
+
if (candidateDeclsResult.isFailure()) {
|
|
424
|
+
errors.addMessage(`Failed to convert candidate JSON for resource ${compiledResource.id}: ${candidateDeclsResult.message}`);
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
const candidateDecls = candidateDeclsResult.value;
|
|
428
|
+
// Create minimal candidates that implement IResourceCandidate
|
|
429
|
+
const candidates = candidateDecls.map((candidateDecl) => ({
|
|
430
|
+
json: candidateDecl.json,
|
|
431
|
+
isPartial: candidateDecl.isPartial,
|
|
432
|
+
mergeMethod: candidateDecl.mergeMethod
|
|
433
|
+
}));
|
|
434
|
+
// Create a ConcreteDecision from the abstract decision and candidate values
|
|
435
|
+
const candidatesWithConditionSets = decision.candidates.map((baseCandidate, idx) => ({
|
|
436
|
+
conditionSet: baseCandidate.conditionSet,
|
|
437
|
+
value: candidates[idx].json
|
|
438
|
+
}));
|
|
439
|
+
const concreteDecisionResult = decisions_2.ConcreteDecision.create({
|
|
440
|
+
decisions,
|
|
441
|
+
candidates: candidatesWithConditionSets
|
|
442
|
+
});
|
|
443
|
+
/* c8 ignore next 6 - defensive coding for ConcreteDecision creation failure */
|
|
444
|
+
if (concreteDecisionResult.isFailure()) {
|
|
445
|
+
errors.addMessage(`Failed to create concrete decision for resource ${compiledResource.id}: ${concreteDecisionResult.message}`);
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
const concreteDecision = concreteDecisionResult.value;
|
|
449
|
+
// Create minimal resource that implements IResource
|
|
450
|
+
const resource = {
|
|
451
|
+
id: compiledResource.id,
|
|
452
|
+
resourceType,
|
|
453
|
+
decision: concreteDecision,
|
|
454
|
+
candidates
|
|
455
|
+
};
|
|
456
|
+
const setResult = resourceMap.set(compiledResource.id, resource);
|
|
457
|
+
/* c8 ignore next 3 - defensive coding for resource map set failure */
|
|
458
|
+
if (setResult.isFailure()) {
|
|
459
|
+
errors.addMessage(`Failed to add resource ${compiledResource.id}: ${setResult.message}`);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return errors.hasMessages ? (0, ts_utils_1.fail)(errors.toString()) : (0, ts_utils_1.succeed)(resourceMap);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
exports.CompiledResourceCollection = CompiledResourceCollection;
|
|
466
|
+
//# sourceMappingURL=compiledResourceCollection.js.map
|