@fgv/ts-res 5.0.0-9 → 5.0.1-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 +21 -0
- package/CHANGELOG.md +14 -1
- package/README.md +794 -137
- package/dist/ts-res.d.ts +2054 -276
- package/dist/tsdoc-metadata.json +1 -1
- package/eslint.config.js +16 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/packlets/bundle/bundleBuilder.js +7 -4
- package/lib/packlets/bundle/bundleLoader.js +1 -0
- package/lib/packlets/bundle/bundleUtils.js +14 -16
- package/lib/packlets/bundle/index.d.ts +3 -1
- package/lib/packlets/bundle/index.js +14 -3
- package/lib/packlets/common/convert.d.ts +15 -0
- package/lib/packlets/common/convert.js +16 -1
- package/lib/packlets/common/helpers/context.js +1 -0
- package/lib/packlets/common/helpers/resources.d.ts +7 -0
- package/lib/packlets/common/helpers/resources.js +13 -0
- package/lib/packlets/common/resources.d.ts +40 -1
- package/lib/packlets/common/validate/conditions.d.ts +17 -1
- package/lib/packlets/common/validate/conditions.js +32 -6
- package/lib/packlets/common/validate/regularExpressions.d.ts +4 -0
- package/lib/packlets/common/validate/regularExpressions.js +5 -1
- package/lib/packlets/common/validate/resources.d.ts +35 -1
- package/lib/packlets/common/validate/resources.js +55 -0
- package/lib/packlets/conditions/condition.js +1 -0
- package/lib/packlets/conditions/conditionSet.d.ts +9 -0
- package/lib/packlets/conditions/conditionSet.js +75 -1
- package/lib/packlets/config/configInitFactory.d.ts +217 -0
- package/lib/packlets/config/configInitFactory.js +302 -0
- package/lib/packlets/config/convert.d.ts +9 -0
- package/lib/packlets/config/convert.js +12 -1
- package/lib/packlets/config/index.d.ts +1 -0
- package/lib/packlets/config/index.js +1 -0
- package/lib/packlets/config/json.d.ts +1 -1
- package/lib/packlets/config/systemConfiguration.d.ts +16 -3
- package/lib/packlets/config/systemConfiguration.js +19 -40
- package/lib/packlets/import/fsItem.d.ts +2 -1
- package/lib/packlets/import/fsItem.js +9 -13
- package/lib/packlets/import/importManager.d.ts +2 -1
- package/lib/packlets/import/importers/jsonImporter.js +1 -0
- package/lib/packlets/import/importers/pathImporter.d.ts +2 -1
- package/lib/packlets/import/importers/pathImporter.js +2 -1
- package/lib/packlets/qualifier-types/config/convert.d.ts +22 -1
- package/lib/packlets/qualifier-types/config/convert.js +67 -2
- package/lib/packlets/qualifier-types/config/json.d.ts +24 -2
- package/lib/packlets/qualifier-types/config/json.js +11 -0
- package/lib/packlets/qualifier-types/convert.d.ts +1 -1
- package/lib/packlets/qualifier-types/helpers.d.ts +14 -5
- package/lib/packlets/qualifier-types/helpers.js +2 -2
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +28 -2
- package/lib/packlets/qualifier-types/languageQualifierType.js +73 -0
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +31 -5
- package/lib/packlets/qualifier-types/literalQualifierType.js +75 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +7 -11
- package/lib/packlets/qualifier-types/literalValueHierarchy.js +12 -1
- package/lib/packlets/qualifier-types/qualifierType.d.ts +31 -2
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +31 -5
- package/lib/packlets/qualifier-types/territoryQualifierType.js +80 -0
- package/lib/packlets/qualifiers/qualifierCollector.js +1 -2
- package/lib/packlets/resource-json/compiled/convert.js +2 -1
- package/lib/packlets/resource-json/compiled/json.d.ts +6 -2
- package/lib/packlets/resource-types/config/convert.d.ts +1 -1
- package/lib/packlets/resource-types/config/convert.js +3 -1
- package/lib/packlets/resource-types/config/json.d.ts +3 -1
- package/lib/packlets/resource-types/jsonResourceType.d.ts +10 -1
- package/lib/packlets/resource-types/jsonResourceType.js +7 -3
- package/lib/packlets/resource-types/resourceType.d.ts +100 -8
- package/lib/packlets/resource-types/resourceType.js +39 -3
- package/lib/packlets/resources/candidateReducer.js +3 -0
- package/lib/packlets/resources/candidateValue.d.ts +92 -0
- package/lib/packlets/resources/candidateValue.js +128 -0
- package/lib/packlets/resources/candidateValueCollector.d.ts +55 -0
- package/lib/packlets/resources/candidateValueCollector.js +96 -0
- package/lib/packlets/resources/common.d.ts +14 -0
- package/lib/packlets/resources/index.d.ts +2 -0
- package/lib/packlets/resources/index.js +2 -0
- package/lib/packlets/resources/resource.d.ts +6 -6
- package/lib/packlets/resources/resource.js +5 -10
- package/lib/packlets/resources/resourceBuilder.d.ts +6 -0
- package/lib/packlets/resources/resourceBuilder.js +4 -1
- package/lib/packlets/resources/resourceCandidate.d.ts +15 -2
- package/lib/packlets/resources/resourceCandidate.js +17 -5
- package/lib/packlets/resources/resourceManagerBuilder.d.ts +127 -10
- package/lib/packlets/resources/resourceManagerBuilder.js +283 -45
- package/lib/packlets/runtime/compiledResourceCollection.d.ts +23 -11
- package/lib/packlets/runtime/compiledResourceCollection.js +65 -28
- package/lib/packlets/runtime/conditionSetResolutionResult.js +3 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.d.ts +53 -3
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts +82 -37
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.js +49 -77
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +23 -2
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +53 -31
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +4 -4
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +2 -2
- package/lib/packlets/runtime/iResourceManager.d.ts +13 -5
- package/lib/packlets/runtime/index.d.ts +1 -0
- package/lib/packlets/runtime/index.js +1 -0
- package/lib/packlets/runtime/resource-tree/common.d.ts +1 -1
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts +7 -7
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js +5 -5
- package/lib/packlets/runtime/resourceResolver.d.ts +39 -1
- package/lib/packlets/runtime/resourceResolver.js +50 -28
- package/lib/packlets/runtime/resourceTreeResolver.d.ts +152 -0
- package/lib/packlets/runtime/resourceTreeResolver.js +222 -0
- package/lib/packlets/runtime/validate.js +1 -0
- package/lib/packlets/zip-archive/convert.d.ts +52 -0
- package/lib/packlets/zip-archive/convert.js +103 -0
- package/lib/packlets/zip-archive/index.d.ts +23 -0
- package/lib/packlets/zip-archive/index.js +95 -0
- package/lib/packlets/zip-archive/json.d.ts +64 -0
- package/lib/packlets/zip-archive/json.js +24 -0
- package/lib/packlets/zip-archive/types.d.ts +98 -0
- package/lib/packlets/zip-archive/types.js +39 -0
- package/lib/packlets/zip-archive/zipArchiveCreator.d.ts +35 -0
- package/lib/packlets/zip-archive/zipArchiveCreator.js +195 -0
- package/lib/packlets/zip-archive/zipArchiveFormat.d.ts +70 -0
- package/lib/packlets/zip-archive/zipArchiveFormat.js +184 -0
- package/lib/packlets/zip-archive/zipArchiveLoader.d.ts +70 -0
- package/lib/packlets/zip-archive/zipArchiveLoader.js +286 -0
- package/package.json +26 -32
- package/CLAUDE.md +0 -186
- package/EXAMPLE_INIT_PARAMS.md +0 -88
- package/PROGRESS_SUMMARY.md +0 -48
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/packlets/bundle/bundleBuilder.d.ts.map +0 -1
- package/lib/packlets/bundle/bundleBuilder.js.map +0 -1
- package/lib/packlets/bundle/bundleLoader.d.ts.map +0 -1
- package/lib/packlets/bundle/bundleLoader.js.map +0 -1
- package/lib/packlets/bundle/bundleNormalizer.d.ts.map +0 -1
- package/lib/packlets/bundle/bundleNormalizer.js.map +0 -1
- package/lib/packlets/bundle/bundleUtils.d.ts.map +0 -1
- package/lib/packlets/bundle/bundleUtils.js.map +0 -1
- package/lib/packlets/bundle/convert.d.ts.map +0 -1
- package/lib/packlets/bundle/convert.js.map +0 -1
- package/lib/packlets/bundle/index.d.ts.map +0 -1
- package/lib/packlets/bundle/index.js.map +0 -1
- package/lib/packlets/bundle/model.d.ts.map +0 -1
- package/lib/packlets/bundle/model.js.map +0 -1
- package/lib/packlets/common/conditions.d.ts.map +0 -1
- package/lib/packlets/common/conditions.js.map +0 -1
- package/lib/packlets/common/convert.d.ts.map +0 -1
- package/lib/packlets/common/convert.js.map +0 -1
- package/lib/packlets/common/helpers/conditions.d.ts.map +0 -1
- package/lib/packlets/common/helpers/conditions.js.map +0 -1
- package/lib/packlets/common/helpers/context.d.ts.map +0 -1
- package/lib/packlets/common/helpers/context.js.map +0 -1
- package/lib/packlets/common/helpers/index.d.ts.map +0 -1
- package/lib/packlets/common/helpers/index.js.map +0 -1
- package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts.map +0 -1
- package/lib/packlets/common/helpers/qualifierDefaultValues.js.map +0 -1
- package/lib/packlets/common/helpers/resources.d.ts.map +0 -1
- package/lib/packlets/common/helpers/resources.js.map +0 -1
- package/lib/packlets/common/index.d.ts.map +0 -1
- package/lib/packlets/common/index.js.map +0 -1
- package/lib/packlets/common/resources.d.ts.map +0 -1
- package/lib/packlets/common/resources.js.map +0 -1
- package/lib/packlets/common/validate/conditions.d.ts.map +0 -1
- package/lib/packlets/common/validate/conditions.js.map +0 -1
- package/lib/packlets/common/validate/index.d.ts.map +0 -1
- package/lib/packlets/common/validate/index.js.map +0 -1
- package/lib/packlets/common/validate/regularExpressions.d.ts.map +0 -1
- package/lib/packlets/common/validate/regularExpressions.js.map +0 -1
- package/lib/packlets/common/validate/resources.d.ts.map +0 -1
- package/lib/packlets/common/validate/resources.js.map +0 -1
- package/lib/packlets/conditions/condition.d.ts.map +0 -1
- package/lib/packlets/conditions/condition.js.map +0 -1
- package/lib/packlets/conditions/conditionCollector.d.ts.map +0 -1
- package/lib/packlets/conditions/conditionCollector.js.map +0 -1
- package/lib/packlets/conditions/conditionDecls.d.ts.map +0 -1
- package/lib/packlets/conditions/conditionDecls.js.map +0 -1
- package/lib/packlets/conditions/conditionSet.d.ts.map +0 -1
- package/lib/packlets/conditions/conditionSet.js.map +0 -1
- package/lib/packlets/conditions/conditionSetCollector.d.ts.map +0 -1
- package/lib/packlets/conditions/conditionSetCollector.js.map +0 -1
- package/lib/packlets/conditions/conditionSetDecls.d.ts.map +0 -1
- package/lib/packlets/conditions/conditionSetDecls.js.map +0 -1
- package/lib/packlets/conditions/conditionToken.d.ts.map +0 -1
- package/lib/packlets/conditions/conditionToken.js.map +0 -1
- package/lib/packlets/conditions/convert/conditionSetDecls.d.ts.map +0 -1
- package/lib/packlets/conditions/convert/conditionSetDecls.js.map +0 -1
- package/lib/packlets/conditions/convert/decls.d.ts.map +0 -1
- package/lib/packlets/conditions/convert/decls.js.map +0 -1
- package/lib/packlets/conditions/convert/index.d.ts.map +0 -1
- package/lib/packlets/conditions/convert/index.js.map +0 -1
- package/lib/packlets/conditions/index.d.ts.map +0 -1
- package/lib/packlets/conditions/index.js.map +0 -1
- package/lib/packlets/config/common.d.ts.map +0 -1
- package/lib/packlets/config/common.js.map +0 -1
- package/lib/packlets/config/convert.d.ts.map +0 -1
- package/lib/packlets/config/convert.js.map +0 -1
- package/lib/packlets/config/index.d.ts.map +0 -1
- package/lib/packlets/config/index.js.map +0 -1
- package/lib/packlets/config/json.d.ts.map +0 -1
- package/lib/packlets/config/json.js.map +0 -1
- package/lib/packlets/config/predefined/default.d.ts.map +0 -1
- package/lib/packlets/config/predefined/default.js.map +0 -1
- package/lib/packlets/config/predefined/extended.d.ts.map +0 -1
- package/lib/packlets/config/predefined/extended.js.map +0 -1
- package/lib/packlets/config/predefined/index.d.ts.map +0 -1
- package/lib/packlets/config/predefined/index.js.map +0 -1
- package/lib/packlets/config/systemConfiguration.d.ts.map +0 -1
- package/lib/packlets/config/systemConfiguration.js.map +0 -1
- package/lib/packlets/context/contextDecls.d.ts.map +0 -1
- package/lib/packlets/context/contextDecls.js.map +0 -1
- package/lib/packlets/context/contextToken.d.ts.map +0 -1
- package/lib/packlets/context/contextToken.js.map +0 -1
- package/lib/packlets/context/convert/decls.d.ts.map +0 -1
- package/lib/packlets/context/convert/decls.js.map +0 -1
- package/lib/packlets/context/convert/index.d.ts.map +0 -1
- package/lib/packlets/context/convert/index.js.map +0 -1
- package/lib/packlets/context/index.d.ts.map +0 -1
- package/lib/packlets/context/index.js.map +0 -1
- package/lib/packlets/decisions/abstractDecision.d.ts.map +0 -1
- package/lib/packlets/decisions/abstractDecision.js.map +0 -1
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +0 -1
- package/lib/packlets/decisions/abstractDecisionCollector.js.map +0 -1
- package/lib/packlets/decisions/candidate.d.ts.map +0 -1
- package/lib/packlets/decisions/candidate.js.map +0 -1
- package/lib/packlets/decisions/common.d.ts.map +0 -1
- package/lib/packlets/decisions/common.js.map +0 -1
- package/lib/packlets/decisions/concreteDecision.d.ts.map +0 -1
- package/lib/packlets/decisions/concreteDecision.js.map +0 -1
- package/lib/packlets/decisions/decision.d.ts.map +0 -1
- package/lib/packlets/decisions/decision.js.map +0 -1
- package/lib/packlets/decisions/index.d.ts.map +0 -1
- package/lib/packlets/decisions/index.js.map +0 -1
- package/lib/packlets/import/fsItem.d.ts.map +0 -1
- package/lib/packlets/import/fsItem.js.map +0 -1
- package/lib/packlets/import/importContext.d.ts.map +0 -1
- package/lib/packlets/import/importContext.js.map +0 -1
- package/lib/packlets/import/importManager.d.ts.map +0 -1
- package/lib/packlets/import/importManager.js.map +0 -1
- package/lib/packlets/import/importable.d.ts.map +0 -1
- package/lib/packlets/import/importable.js.map +0 -1
- package/lib/packlets/import/importers/collectionImporter.d.ts.map +0 -1
- package/lib/packlets/import/importers/collectionImporter.js.map +0 -1
- package/lib/packlets/import/importers/fsItemImporter.d.ts.map +0 -1
- package/lib/packlets/import/importers/fsItemImporter.js.map +0 -1
- package/lib/packlets/import/importers/importer.d.ts.map +0 -1
- package/lib/packlets/import/importers/importer.js.map +0 -1
- package/lib/packlets/import/importers/index.d.ts.map +0 -1
- package/lib/packlets/import/importers/index.js.map +0 -1
- package/lib/packlets/import/importers/jsonImporter.d.ts.map +0 -1
- package/lib/packlets/import/importers/jsonImporter.js.map +0 -1
- package/lib/packlets/import/importers/pathImporter.d.ts.map +0 -1
- package/lib/packlets/import/importers/pathImporter.js.map +0 -1
- package/lib/packlets/import/index.d.ts.map +0 -1
- package/lib/packlets/import/index.js.map +0 -1
- package/lib/packlets/qualifier-types/config/convert.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/config/convert.js.map +0 -1
- package/lib/packlets/qualifier-types/config/index.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/config/index.js.map +0 -1
- package/lib/packlets/qualifier-types/config/json.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/config/json.js.map +0 -1
- package/lib/packlets/qualifier-types/convert.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/convert.js.map +0 -1
- package/lib/packlets/qualifier-types/helpers.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/helpers.js.map +0 -1
- package/lib/packlets/qualifier-types/index.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/index.js.map +0 -1
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/languageQualifierType.js.map +0 -1
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/literalQualifierType.js.map +0 -1
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +0 -1
- package/lib/packlets/qualifier-types/qualifierType.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/qualifierType.js.map +0 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +0 -1
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +0 -1
- package/lib/packlets/qualifier-types/territoryQualifierType.js.map +0 -1
- package/lib/packlets/qualifiers/convert/decls.d.ts.map +0 -1
- package/lib/packlets/qualifiers/convert/decls.js.map +0 -1
- package/lib/packlets/qualifiers/convert/index.d.ts.map +0 -1
- package/lib/packlets/qualifiers/convert/index.js.map +0 -1
- package/lib/packlets/qualifiers/convert/qualifier.d.ts.map +0 -1
- package/lib/packlets/qualifiers/convert/qualifier.js.map +0 -1
- package/lib/packlets/qualifiers/index.d.ts.map +0 -1
- package/lib/packlets/qualifiers/index.js.map +0 -1
- package/lib/packlets/qualifiers/qualifier.d.ts.map +0 -1
- package/lib/packlets/qualifiers/qualifier.js.map +0 -1
- package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +0 -1
- package/lib/packlets/qualifiers/qualifierCollector.js.map +0 -1
- package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +0 -1
- package/lib/packlets/qualifiers/qualifierDecl.js.map +0 -1
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts.map +0 -1
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js.map +0 -1
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts.map +0 -1
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.js.map +0 -1
- package/lib/packlets/resource-json/compiled/common.d.ts.map +0 -1
- package/lib/packlets/resource-json/compiled/common.js.map +0 -1
- package/lib/packlets/resource-json/compiled/convert.d.ts.map +0 -1
- package/lib/packlets/resource-json/compiled/convert.js.map +0 -1
- package/lib/packlets/resource-json/compiled/index.d.ts.map +0 -1
- package/lib/packlets/resource-json/compiled/index.js.map +0 -1
- package/lib/packlets/resource-json/compiled/json.d.ts.map +0 -1
- package/lib/packlets/resource-json/compiled/json.js.map +0 -1
- package/lib/packlets/resource-json/convert.d.ts.map +0 -1
- package/lib/packlets/resource-json/convert.js.map +0 -1
- package/lib/packlets/resource-json/helpers.d.ts.map +0 -1
- package/lib/packlets/resource-json/helpers.js.map +0 -1
- package/lib/packlets/resource-json/index.d.ts.map +0 -1
- package/lib/packlets/resource-json/index.js.map +0 -1
- package/lib/packlets/resource-json/json.d.ts.map +0 -1
- package/lib/packlets/resource-json/json.js.map +0 -1
- package/lib/packlets/resource-json/normalized.d.ts.map +0 -1
- package/lib/packlets/resource-json/normalized.js.map +0 -1
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +0 -1
- package/lib/packlets/resource-json/resourceDeclCollection.js.map +0 -1
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +0 -1
- package/lib/packlets/resource-json/resourceDeclContainer.js.map +0 -1
- package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +0 -1
- package/lib/packlets/resource-json/resourceDeclTree.js.map +0 -1
- package/lib/packlets/resource-types/config/convert.d.ts.map +0 -1
- package/lib/packlets/resource-types/config/convert.js.map +0 -1
- package/lib/packlets/resource-types/config/index.d.ts.map +0 -1
- package/lib/packlets/resource-types/config/index.js.map +0 -1
- package/lib/packlets/resource-types/config/json.d.ts.map +0 -1
- package/lib/packlets/resource-types/config/json.js.map +0 -1
- package/lib/packlets/resource-types/helpers.d.ts.map +0 -1
- package/lib/packlets/resource-types/helpers.js.map +0 -1
- package/lib/packlets/resource-types/index.d.ts.map +0 -1
- package/lib/packlets/resource-types/index.js.map +0 -1
- package/lib/packlets/resource-types/jsonResourceType.d.ts.map +0 -1
- package/lib/packlets/resource-types/jsonResourceType.js.map +0 -1
- package/lib/packlets/resource-types/resourceType.d.ts.map +0 -1
- package/lib/packlets/resource-types/resourceType.js.map +0 -1
- package/lib/packlets/resource-types/resourceTypeCollector.d.ts.map +0 -1
- package/lib/packlets/resource-types/resourceTypeCollector.js.map +0 -1
- package/lib/packlets/resources/candidateReducer.d.ts.map +0 -1
- package/lib/packlets/resources/candidateReducer.js.map +0 -1
- package/lib/packlets/resources/common.d.ts.map +0 -1
- package/lib/packlets/resources/common.js.map +0 -1
- package/lib/packlets/resources/index.d.ts.map +0 -1
- package/lib/packlets/resources/index.js.map +0 -1
- package/lib/packlets/resources/resource.d.ts.map +0 -1
- package/lib/packlets/resources/resource.js.map +0 -1
- package/lib/packlets/resources/resourceBuilder.d.ts.map +0 -1
- package/lib/packlets/resources/resourceBuilder.js.map +0 -1
- package/lib/packlets/resources/resourceCandidate.d.ts.map +0 -1
- package/lib/packlets/resources/resourceCandidate.js.map +0 -1
- package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +0 -1
- package/lib/packlets/resources/resourceManagerBuilder.js.map +0 -1
- package/lib/packlets/runtime/cacheListener.d.ts.map +0 -1
- package/lib/packlets/runtime/cacheListener.js.map +0 -1
- package/lib/packlets/runtime/cacheMetrics.d.ts.map +0 -1
- package/lib/packlets/runtime/cacheMetrics.js.map +0 -1
- package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +0 -1
- package/lib/packlets/runtime/compiledResourceCollection.js.map +0 -1
- package/lib/packlets/runtime/conditionSetResolutionResult.d.ts.map +0 -1
- package/lib/packlets/runtime/conditionSetResolutionResult.js.map +0 -1
- package/lib/packlets/runtime/context/contextQualifierProvider.d.ts.map +0 -1
- package/lib/packlets/runtime/context/contextQualifierProvider.js.map +0 -1
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts.map +0 -1
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.js.map +0 -1
- package/lib/packlets/runtime/context/index.d.ts.map +0 -1
- package/lib/packlets/runtime/context/index.js.map +0 -1
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +0 -1
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +0 -1
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +0 -1
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +0 -1
- package/lib/packlets/runtime/iResourceManager.d.ts.map +0 -1
- package/lib/packlets/runtime/iResourceManager.js.map +0 -1
- package/lib/packlets/runtime/index.d.ts.map +0 -1
- package/lib/packlets/runtime/index.js.map +0 -1
- package/lib/packlets/runtime/resource-tree/common.d.ts.map +0 -1
- package/lib/packlets/runtime/resource-tree/common.js.map +0 -1
- package/lib/packlets/runtime/resource-tree/index.d.ts.map +0 -1
- package/lib/packlets/runtime/resource-tree/index.js.map +0 -1
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts.map +0 -1
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +0 -1
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts.map +0 -1
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js.map +0 -1
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts.map +0 -1
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +0 -1
- package/lib/packlets/runtime/resourceResolver.d.ts.map +0 -1
- package/lib/packlets/runtime/resourceResolver.js.map +0 -1
- package/lib/packlets/runtime/validate.d.ts.map +0 -1
- package/lib/packlets/runtime/validate.js.map +0 -1
|
@@ -56,14 +56,18 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
56
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
57
|
exports.ResourceManagerBuilder = void 0;
|
|
58
58
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
59
|
+
const ts_json_base_1 = require("@fgv/ts-json-base");
|
|
59
60
|
const conditions_1 = require("../conditions");
|
|
60
61
|
const decisions_1 = require("../decisions");
|
|
61
62
|
const common_1 = require("../common");
|
|
63
|
+
const runtime_1 = require("../runtime");
|
|
62
64
|
const resourceBuilder_1 = require("./resourceBuilder");
|
|
63
65
|
const resource_1 = require("./resource");
|
|
66
|
+
const candidateValueCollector_1 = require("./candidateValueCollector");
|
|
64
67
|
const ResourceJson = __importStar(require("../resource-json"));
|
|
65
68
|
const Context = __importStar(require("../context"));
|
|
66
69
|
const Config = __importStar(require("../config"));
|
|
70
|
+
const ts_json_1 = require("@fgv/ts-json");
|
|
67
71
|
/**
|
|
68
72
|
* Builder for a collection of {@link Resources.Resource | resources}. Collects
|
|
69
73
|
* {@link Resources.ResourceCandidate | candidates} for each resource into a
|
|
@@ -72,6 +76,13 @@ const Config = __importStar(require("../config"));
|
|
|
72
76
|
* @public
|
|
73
77
|
*/
|
|
74
78
|
class ResourceManagerBuilder {
|
|
79
|
+
/**
|
|
80
|
+
* The {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier types} used by this resource manager.
|
|
81
|
+
*/
|
|
82
|
+
get qualifierTypes() {
|
|
83
|
+
/* c8 ignore next 1 - functional code tested but coverage intermittently missed */
|
|
84
|
+
return this.qualifiers.qualifierTypes;
|
|
85
|
+
}
|
|
75
86
|
/**
|
|
76
87
|
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
77
88
|
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
@@ -140,6 +151,7 @@ class ResourceManagerBuilder {
|
|
|
140
151
|
this._conditions = conditions_1.ConditionCollector.create({ qualifiers: params.qualifiers }).orThrow();
|
|
141
152
|
this._conditionSets = conditions_1.ConditionSetCollector.create({ conditions: this._conditions }).orThrow();
|
|
142
153
|
this._decisions = decisions_1.AbstractDecisionCollector.create({ conditionSets: this._conditionSets }).orThrow();
|
|
154
|
+
this._candidateValues = candidateValueCollector_1.CandidateValueCollector.create().orThrow();
|
|
143
155
|
this._resources = new ts_utils_1.ValidatingResultMap({
|
|
144
156
|
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
145
157
|
key: common_1.Convert.resourceId,
|
|
@@ -155,6 +167,7 @@ class ResourceManagerBuilder {
|
|
|
155
167
|
})
|
|
156
168
|
});
|
|
157
169
|
this._built = false;
|
|
170
|
+
this._cachedResourceTree = undefined;
|
|
158
171
|
}
|
|
159
172
|
/**
|
|
160
173
|
* Creates a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object.
|
|
@@ -175,13 +188,39 @@ class ResourceManagerBuilder {
|
|
|
175
188
|
* @public
|
|
176
189
|
*/
|
|
177
190
|
static createPredefined(name, qualifierDefaultValues) {
|
|
178
|
-
return Config.getPredefinedSystemConfiguration(name,
|
|
191
|
+
return Config.getPredefinedSystemConfiguration(name,
|
|
192
|
+
/* c8 ignore next 1 - defense in depth */
|
|
193
|
+
qualifierDefaultValues ? { qualifierDefaultValues } : undefined).onSuccess((systemConfig) => {
|
|
179
194
|
return ResourceManagerBuilder.create({
|
|
180
195
|
qualifiers: systemConfig.qualifiers,
|
|
181
196
|
resourceTypes: systemConfig.resourceTypes
|
|
182
197
|
});
|
|
183
198
|
});
|
|
184
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Creates a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} from a
|
|
202
|
+
* {@link ResourceJson.Compiled.ICompiledResourceCollection | compiled resource collection}.
|
|
203
|
+
* This method reconstructs an exactly equivalent builder where all qualifier, condition,
|
|
204
|
+
* condition set, and decision indices match the original compiled collection.
|
|
205
|
+
* @param compiledCollection - The compiled resource collection to reconstruct from.
|
|
206
|
+
* @param systemConfig - The system configuration containing qualifiers and resource types.
|
|
207
|
+
* @returns `Success` with the new manager if successful, or `Failure` with an error message if not.
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
210
|
+
static createFromCompiledResourceCollection(compiledCollection, systemConfig) {
|
|
211
|
+
// Create the base builder with system configuration
|
|
212
|
+
return ResourceManagerBuilder.create({
|
|
213
|
+
qualifiers: systemConfig.qualifiers,
|
|
214
|
+
resourceTypes: systemConfig.resourceTypes
|
|
215
|
+
}).onSuccess((builder) => {
|
|
216
|
+
// Reconstruct all entities in order to preserve indices
|
|
217
|
+
return ResourceManagerBuilder._reconstructConditions(builder, compiledCollection)
|
|
218
|
+
.onSuccess(() => ResourceManagerBuilder._reconstructConditionSets(builder, compiledCollection))
|
|
219
|
+
.onSuccess(() => ResourceManagerBuilder._reconstructDecisions(builder, compiledCollection))
|
|
220
|
+
.onSuccess(() => ResourceManagerBuilder._reconstructResources(builder, compiledCollection))
|
|
221
|
+
.onSuccess(() => (0, ts_utils_1.succeed)(builder));
|
|
222
|
+
});
|
|
223
|
+
}
|
|
185
224
|
/**
|
|
186
225
|
* Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds
|
|
187
226
|
* a {@link Resources.ResourceCandidate | candidate} to the manager.
|
|
@@ -198,7 +237,8 @@ class ResourceManagerBuilder {
|
|
|
198
237
|
id,
|
|
199
238
|
resourceTypes: this.resourceTypes,
|
|
200
239
|
conditionSets: this._conditionSets,
|
|
201
|
-
decisions: this._decisions
|
|
240
|
+
decisions: this._decisions,
|
|
241
|
+
candidateValues: this._candidateValues
|
|
202
242
|
}));
|
|
203
243
|
/* c8 ignore next 6 - defense in depth against internal error */
|
|
204
244
|
if (builderResult.isFailure()) {
|
|
@@ -208,12 +248,14 @@ class ResourceManagerBuilder {
|
|
|
208
248
|
this._builtResources.delete(id);
|
|
209
249
|
this._built = false;
|
|
210
250
|
this._numCandidates = undefined;
|
|
251
|
+
this._cachedResourceTree = undefined;
|
|
211
252
|
return (0, ts_utils_1.succeedWithDetail)(c, d);
|
|
212
253
|
});
|
|
213
254
|
}
|
|
214
255
|
addResource(decl) {
|
|
215
256
|
var _a;
|
|
216
257
|
const { value: id, message } = common_1.Validate.toResourceId(decl.id);
|
|
258
|
+
/* c8 ignore next 3 - defensive coding: resource ID validation should prevent invalid IDs */
|
|
217
259
|
if (message !== undefined) {
|
|
218
260
|
return (0, ts_utils_1.failWithDetail)(`${id}: invalid id - ${message}`, 'failure');
|
|
219
261
|
}
|
|
@@ -222,13 +264,15 @@ class ResourceManagerBuilder {
|
|
|
222
264
|
typeName: decl.resourceTypeName,
|
|
223
265
|
resourceTypes: this.resourceTypes,
|
|
224
266
|
conditionSets: this._conditionSets,
|
|
225
|
-
decisions: this._decisions
|
|
267
|
+
decisions: this._decisions,
|
|
268
|
+
candidateValues: this._candidateValues
|
|
226
269
|
}));
|
|
227
270
|
/* c8 ignore next 3 - defense in depth against internal error */
|
|
228
271
|
if (getOrAddMessage !== undefined) {
|
|
229
272
|
return (0, ts_utils_1.failWithDetail)(`${id}: unable to get or add resource\n${getOrAddMessage}`, detail);
|
|
230
273
|
}
|
|
231
274
|
if (detail === 'exists') {
|
|
275
|
+
/* c8 ignore next 4 - defensive coding: resource type mismatch on existing resources should not occur */
|
|
232
276
|
const { message } = builder.setResourceType(decl.resourceTypeName);
|
|
233
277
|
if (message !== undefined) {
|
|
234
278
|
return (0, ts_utils_1.failWithDetail)(`${id}: unable to set resource type\n${message}`, 'type-mismatch');
|
|
@@ -317,6 +361,36 @@ class ResourceManagerBuilder {
|
|
|
317
361
|
getAllBuiltResources() {
|
|
318
362
|
return this.build().onSuccess((manager) => (0, ts_utils_1.succeed)(Array.from(manager._builtResources.values()).sort((a, b) => a.id.localeCompare(b.id))));
|
|
319
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Builds and returns a hierarchical tree representation of all resources managed by this builder.
|
|
366
|
+
* Resources are organized based on their dot-separated resource IDs (e.g., "app.messages.welcome"
|
|
367
|
+
* becomes a tree with "app" as root, "messages" as branch, and "welcome" as leaf).
|
|
368
|
+
*
|
|
369
|
+
* String-based validation is available through the `children.validating` property,
|
|
370
|
+
* allowing callers to use `tree.children.validating.getById(stringId)` for validated access.
|
|
371
|
+
*
|
|
372
|
+
* Uses lazy initialization with caching for performance.
|
|
373
|
+
* @returns Result containing the resource tree root, or failure if tree construction fails
|
|
374
|
+
* @public
|
|
375
|
+
*/
|
|
376
|
+
getBuiltResourceTree() {
|
|
377
|
+
// Ensure resources are built first
|
|
378
|
+
return this.build().onSuccess((manager) => {
|
|
379
|
+
if (manager._cachedResourceTree) {
|
|
380
|
+
return (0, ts_utils_1.succeed)(manager._cachedResourceTree);
|
|
381
|
+
}
|
|
382
|
+
// Convert all built resources to [ResourceId, Resource] pairs
|
|
383
|
+
const resources = [];
|
|
384
|
+
for (const [id, resource] of manager._builtResources.entries()) {
|
|
385
|
+
resources.push([id, resource]);
|
|
386
|
+
}
|
|
387
|
+
// Create the resource tree with lazy initialization
|
|
388
|
+
return runtime_1.ResourceTree.ReadOnlyResourceTreeRoot.create(resources).onSuccess((tree) => {
|
|
389
|
+
manager._cachedResourceTree = tree;
|
|
390
|
+
return (0, ts_utils_1.succeed)(tree);
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
}
|
|
320
394
|
/**
|
|
321
395
|
* Gets a read-only array of all {@link Resources.Resource | built resources} in the manager.
|
|
322
396
|
* @returns `Success` with an array of resources if successful, or `Failure` with an error message if not.
|
|
@@ -407,6 +481,7 @@ class ResourceManagerBuilder {
|
|
|
407
481
|
getCompiledResourceCollection(options) {
|
|
408
482
|
// Build resources first to ensure all data is available
|
|
409
483
|
const buildResult = this._performBuild();
|
|
484
|
+
/* c8 ignore next 3 - defensive coding: build failure should not occur after successful validation */
|
|
410
485
|
if (buildResult.isFailure()) {
|
|
411
486
|
return (0, ts_utils_1.fail)(`Failed to build resources: ${buildResult.message}`);
|
|
412
487
|
}
|
|
@@ -427,6 +502,7 @@ class ResourceManagerBuilder {
|
|
|
427
502
|
conditions: Array.from(this._conditions.values()).map((c) => c.toCompiled(options)),
|
|
428
503
|
conditionSets: Array.from(this._conditionSets.values()).map((cs) => cs.toCompiled(options)),
|
|
429
504
|
decisions: Array.from(this._decisions.values()).map((d) => d.toCompiled(options)),
|
|
505
|
+
candidateValues: this._candidateValues.getValuesByIndex(),
|
|
430
506
|
resources: Array.from(this._builtResources.values()).map((r) => r.toCompiled(options))
|
|
431
507
|
};
|
|
432
508
|
// Apply validation through the converter
|
|
@@ -467,20 +543,26 @@ class ResourceManagerBuilder {
|
|
|
467
543
|
});
|
|
468
544
|
}
|
|
469
545
|
/**
|
|
470
|
-
* Creates a
|
|
471
|
-
* This
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
* @
|
|
546
|
+
* Creates a clone of this ResourceManagerBuilder with optional configuration overrides.
|
|
547
|
+
* This method creates a new ResourceManagerBuilder that can optionally use different
|
|
548
|
+
* qualifiers and/or resource types than the original. It can also be filtered to include
|
|
549
|
+
* only candidates that match the provided context and apply candidate edits.
|
|
550
|
+
*
|
|
551
|
+
* @param options - Options for the cloning operation:
|
|
552
|
+
* - `qualifiers`: Optional qualifier collector to use instead of the original
|
|
553
|
+
* - `resourceTypes`: Optional resource type collector to use instead of the original
|
|
554
|
+
* - `filterForContext`: Optional context filter for candidates
|
|
555
|
+
* - `candidates`: Optional candidate edits to apply during cloning
|
|
556
|
+
* @returns A Result containing the new ResourceManagerBuilder with the specified configuration.
|
|
476
557
|
* @public
|
|
477
558
|
*/
|
|
478
559
|
/* c8 ignore next 21 - functional code path tested but coverage intermittently missed */
|
|
479
560
|
clone(options) {
|
|
480
561
|
return this.getResourceCollectionDecl(options).onSuccess((collection) => {
|
|
562
|
+
var _a, _b;
|
|
481
563
|
return ResourceManagerBuilder.create({
|
|
482
|
-
qualifiers: this.qualifiers,
|
|
483
|
-
resourceTypes: this.resourceTypes
|
|
564
|
+
qualifiers: (_a = options === null || options === void 0 ? void 0 : options.qualifiers) !== null && _a !== void 0 ? _a : this.qualifiers,
|
|
565
|
+
resourceTypes: (_b = options === null || options === void 0 ? void 0 : options.resourceTypes) !== null && _b !== void 0 ? _b : this.resourceTypes
|
|
484
566
|
}).onSuccess((newManager) => {
|
|
485
567
|
// Check if we have candidates to apply as edits
|
|
486
568
|
const editCandidates = (options === null || options === void 0 ? void 0 : options.candidates) || [];
|
|
@@ -500,6 +582,7 @@ class ResourceManagerBuilder {
|
|
|
500
582
|
return (0, ts_utils_1.fail)(`${resourceDecl.id}: Failed to apply edits: ${editedDeclResult.message}`);
|
|
501
583
|
}
|
|
502
584
|
const addResult = newManager.addResource(editedDeclResult.value);
|
|
585
|
+
/* c8 ignore next 5 - edge case (nearly?) impossible to reproduce */
|
|
503
586
|
if (addResult.isFailure()) {
|
|
504
587
|
return (0, ts_utils_1.fail)(`${resourceDecl.id}: Failed to add resource to cloned manager: ${addResult.message}`);
|
|
505
588
|
}
|
|
@@ -556,36 +639,6 @@ class ResourceManagerBuilder {
|
|
|
556
639
|
* @returns A Result containing the ConditionSet token if successful, or failure if validation fails
|
|
557
640
|
* @internal
|
|
558
641
|
*/
|
|
559
|
-
static _getConditionSetToken(conditionSet, conditionCollector) {
|
|
560
|
-
if (!conditionSet) {
|
|
561
|
-
return (0, ts_utils_1.succeed)(conditions_1.ConditionSet.UnconditionalKey);
|
|
562
|
-
}
|
|
563
|
-
// Convert ConditionSetDecl to IConditionSetDecl format
|
|
564
|
-
let conditionSetDecl;
|
|
565
|
-
if (Array.isArray(conditionSet)) {
|
|
566
|
-
// ConditionSetDeclAsArray: array of ILooseConditionDecl
|
|
567
|
-
conditionSetDecl = { conditions: conditionSet };
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
570
|
-
// ConditionSetDeclAsRecord: Record<string, string | IChildConditionDecl>
|
|
571
|
-
const conditions = Object.entries(conditionSet).map(([qualifierName, value]) => {
|
|
572
|
-
if (typeof value === 'string') {
|
|
573
|
-
return { qualifierName, value };
|
|
574
|
-
}
|
|
575
|
-
else {
|
|
576
|
-
return Object.assign({ qualifierName }, value);
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
conditionSetDecl = { conditions };
|
|
580
|
-
}
|
|
581
|
-
// Validate and convert to IValidatedConditionSetDecl
|
|
582
|
-
return conditions_1.Convert.validatedConditionSetDecl
|
|
583
|
-
.convert(conditionSetDecl, { conditions: conditionCollector })
|
|
584
|
-
.onSuccess((validatedDecl) => {
|
|
585
|
-
// Use proper ConditionSet.getKeyForDecl method to generate the token
|
|
586
|
-
return conditions_1.ConditionSet.getKeyForDecl(validatedDecl);
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
642
|
/**
|
|
590
643
|
* Applies candidate edits to a resource declaration, handling collisions using condition set tokens.
|
|
591
644
|
* If there's no collision, adds the candidate. If there's a collision, replaces the original candidate with the edit.
|
|
@@ -596,7 +649,9 @@ class ResourceManagerBuilder {
|
|
|
596
649
|
* @internal
|
|
597
650
|
*/
|
|
598
651
|
static _applyEditsToResourceDeclaration(resourceDecl, candidatesByResource, conditionCollector) {
|
|
652
|
+
var _a, _b;
|
|
599
653
|
const { value: resourceId, message } = common_1.Validate.toResourceId(resourceDecl.id);
|
|
654
|
+
/* c8 ignore next 3 - defensive validation: resource IDs are validated when added to builder, but this protects against corrupted data */
|
|
600
655
|
if (message !== undefined) {
|
|
601
656
|
return (0, ts_utils_1.fail)(`Invalid resource ID "${resourceDecl.id}": ${message}`);
|
|
602
657
|
}
|
|
@@ -606,9 +661,12 @@ class ResourceManagerBuilder {
|
|
|
606
661
|
}
|
|
607
662
|
// Use Map approach: apply original candidates first, then replace with edits on collision
|
|
608
663
|
const candidatesByConditionKey = new Map();
|
|
664
|
+
/* c8 ignore next 1 - ?? is defense in depth */
|
|
665
|
+
const declCandidates = (_a = resourceDecl.candidates) !== null && _a !== void 0 ? _a : [];
|
|
609
666
|
// First, add all original candidates keyed by their condition set token
|
|
610
|
-
for (const candidate of
|
|
611
|
-
const conditionTokenResult =
|
|
667
|
+
for (const candidate of declCandidates) {
|
|
668
|
+
const conditionTokenResult = conditions_1.ConditionSet.getKeyFromLooseDecl(candidate.conditions, conditionCollector);
|
|
669
|
+
/* c8 ignore next 5 - edge case or internal error (nearly?) impossible to reproduce */
|
|
612
670
|
if (conditionTokenResult.isFailure()) {
|
|
613
671
|
return (0, ts_utils_1.fail)(`Failed to generate condition token for original candidate: ${conditionTokenResult.message}`);
|
|
614
672
|
}
|
|
@@ -617,12 +675,26 @@ class ResourceManagerBuilder {
|
|
|
617
675
|
// Then, apply edits (this replaces any colliding original candidates)
|
|
618
676
|
// Convert edit candidates (which have ids) to child candidates (without ids) for merging
|
|
619
677
|
for (const editCandidate of editCandidates) {
|
|
620
|
-
const conditionTokenResult =
|
|
678
|
+
const conditionTokenResult = conditions_1.ConditionSet.getKeyFromLooseDecl(editCandidate.conditions, conditionCollector);
|
|
621
679
|
if (conditionTokenResult.isFailure()) {
|
|
622
680
|
return (0, ts_utils_1.fail)(`Failed to generate condition token for edit candidate: ${conditionTokenResult.message}`);
|
|
623
681
|
}
|
|
682
|
+
let editedJson = editCandidate.json;
|
|
683
|
+
const previousJson = (_b = candidatesByConditionKey.get(conditionTokenResult.value)) === null || _b === void 0 ? void 0 : _b.json;
|
|
684
|
+
if (previousJson && previousJson !== editedJson) {
|
|
685
|
+
editedJson = ts_json_1.JsonEditor.create({
|
|
686
|
+
merge: {
|
|
687
|
+
arrayMergeBehavior: 'replace',
|
|
688
|
+
nullAsDelete: false
|
|
689
|
+
}
|
|
690
|
+
})
|
|
691
|
+
.onSuccess((editor) => {
|
|
692
|
+
return editor.mergeObjectsInPlace({}, [previousJson, editedJson]);
|
|
693
|
+
})
|
|
694
|
+
.orThrow();
|
|
695
|
+
}
|
|
624
696
|
const childCandidate = {
|
|
625
|
-
json:
|
|
697
|
+
json: editedJson,
|
|
626
698
|
conditions: editCandidate.conditions,
|
|
627
699
|
isPartial: editCandidate.isPartial,
|
|
628
700
|
mergeMethod: editCandidate.mergeMethod
|
|
@@ -647,11 +719,13 @@ class ResourceManagerBuilder {
|
|
|
647
719
|
// Convert candidate declarations to child candidate declarations
|
|
648
720
|
const childCandidates = [];
|
|
649
721
|
// Ensure we have candidates
|
|
722
|
+
/* c8 ignore next 3 - defense in depth against internal error */
|
|
650
723
|
if (candidates.length === 0) {
|
|
651
724
|
return (0, ts_utils_1.fail)('Cannot create resource declaration from empty candidates array');
|
|
652
725
|
}
|
|
653
726
|
// Extract resourceTypeName from the first candidate (all candidates for the same resource should have the same type)
|
|
654
727
|
const resourceTypeName = candidates[0].resourceTypeName;
|
|
728
|
+
/* c8 ignore next 3 - defense in depth */
|
|
655
729
|
if (!resourceTypeName) {
|
|
656
730
|
return (0, ts_utils_1.fail)('resourceTypeName is required for new resource candidates');
|
|
657
731
|
}
|
|
@@ -672,6 +746,170 @@ class ResourceManagerBuilder {
|
|
|
672
746
|
};
|
|
673
747
|
return (0, ts_utils_1.succeed)(newResourceDecl);
|
|
674
748
|
}
|
|
749
|
+
/**
|
|
750
|
+
* Reconstructs conditions from a compiled collection and adds them to the builder.
|
|
751
|
+
* @param builder - The builder to add conditions to.
|
|
752
|
+
* @param compiledCollection - The compiled collection containing conditions.
|
|
753
|
+
* @returns `Success` if all conditions were added successfully, `Failure` otherwise.
|
|
754
|
+
* @internal
|
|
755
|
+
*/
|
|
756
|
+
static _reconstructConditions(builder, compiledCollection) {
|
|
757
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
758
|
+
for (const compiledCondition of compiledCollection.conditions) {
|
|
759
|
+
// Get the qualifier by index
|
|
760
|
+
const qualifierResult = builder.qualifiers.getAt(compiledCondition.qualifierIndex);
|
|
761
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
762
|
+
if (qualifierResult.isFailure()) {
|
|
763
|
+
qualifierResult.aggregateError(errors);
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
766
|
+
// Create condition declaration from compiled condition
|
|
767
|
+
const conditionDecl = {
|
|
768
|
+
qualifierName: qualifierResult.value.name,
|
|
769
|
+
operator: compiledCondition.operator,
|
|
770
|
+
value: compiledCondition.value,
|
|
771
|
+
priority: compiledCondition.priority,
|
|
772
|
+
scoreAsDefault: compiledCondition.scoreAsDefault
|
|
773
|
+
};
|
|
774
|
+
// Add condition to builder (it will get the next sequential index)
|
|
775
|
+
builder.addCondition(conditionDecl).aggregateError(errors);
|
|
776
|
+
}
|
|
777
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Reconstructs condition sets from a compiled collection and adds them to the builder.
|
|
781
|
+
* @param builder - The builder to add condition sets to.
|
|
782
|
+
* @param compiledCollection - The compiled collection containing condition sets.
|
|
783
|
+
* @returns `Success` if all condition sets were added successfully, `Failure` otherwise.
|
|
784
|
+
* @internal
|
|
785
|
+
*/
|
|
786
|
+
static _reconstructConditionSets(builder, compiledCollection) {
|
|
787
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
788
|
+
for (const compiledConditionSet of compiledCollection.conditionSets) {
|
|
789
|
+
// Get conditions by their indices
|
|
790
|
+
const conditionResults = compiledConditionSet.conditions.map((idx) => builder._conditions.getAt(idx));
|
|
791
|
+
// Check for any failures
|
|
792
|
+
const failedIndex = conditionResults.findIndex((r) => r.isFailure());
|
|
793
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
794
|
+
if (failedIndex >= 0) {
|
|
795
|
+
conditionResults[failedIndex].aggregateError(errors);
|
|
796
|
+
continue;
|
|
797
|
+
}
|
|
798
|
+
// Create condition set from conditions (not declarations)
|
|
799
|
+
const conditions = conditionResults.map((r) => r.orThrow());
|
|
800
|
+
// Convert conditions to declarations for addConditionSet
|
|
801
|
+
const conditionDecls = conditions.map((c) => c.toLooseConditionDecl());
|
|
802
|
+
builder.addConditionSet(conditionDecls).aggregateError(errors);
|
|
803
|
+
}
|
|
804
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Reconstructs decisions from a compiled collection and adds them to the builder.
|
|
808
|
+
* @param builder - The builder to add decisions to.
|
|
809
|
+
* @param compiledCollection - The compiled collection containing decisions.
|
|
810
|
+
* @returns `Success` if all decisions were added successfully, `Failure` otherwise.
|
|
811
|
+
* @internal
|
|
812
|
+
*/
|
|
813
|
+
static _reconstructDecisions(builder, compiledCollection) {
|
|
814
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
815
|
+
for (const compiledDecision of compiledCollection.decisions) {
|
|
816
|
+
// Get condition sets by their indices
|
|
817
|
+
const conditionSetResults = compiledDecision.conditionSets.map((idx) => builder._conditionSets.getAt(idx));
|
|
818
|
+
// Check for any failures
|
|
819
|
+
const failedIndex = conditionSetResults.findIndex((r) => r.isFailure());
|
|
820
|
+
if (failedIndex >= 0) {
|
|
821
|
+
conditionSetResults[failedIndex].aggregateError(errors);
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
// Get condition sets from successful results
|
|
825
|
+
const conditionSets = conditionSetResults.map((r) => r.orThrow());
|
|
826
|
+
// Create AbstractDecision from condition sets and add to collector
|
|
827
|
+
decisions_1.AbstractDecision.createAbstractDecision({ conditionSets })
|
|
828
|
+
.onSuccess((decision) => builder._decisions.getOrAdd(decision))
|
|
829
|
+
.aggregateError(errors);
|
|
830
|
+
}
|
|
831
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Reconstructs resources and their candidates from a compiled collection and adds them to the builder.
|
|
835
|
+
* @param builder - The builder to add resources to.
|
|
836
|
+
* @param compiledCollection - The compiled collection containing resources.
|
|
837
|
+
* @returns `Success` if all resources were added successfully, `Failure` otherwise.
|
|
838
|
+
* @internal
|
|
839
|
+
*/
|
|
840
|
+
static _reconstructResources(builder, compiledCollection) {
|
|
841
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
842
|
+
for (const compiledResource of compiledCollection.resources) {
|
|
843
|
+
// Get the resource type by index
|
|
844
|
+
const resourceTypeResult = builder.resourceTypes.getAt(compiledResource.type);
|
|
845
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
846
|
+
if (resourceTypeResult.isFailure()) {
|
|
847
|
+
resourceTypeResult.aggregateError(errors);
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
// Get the decision by index
|
|
851
|
+
const decisionResult = builder._decisions.getAt(compiledResource.decision);
|
|
852
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
853
|
+
if (decisionResult.isFailure()) {
|
|
854
|
+
decisionResult.aggregateError(errors);
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
const decision = decisionResult.value;
|
|
858
|
+
const resourceType = resourceTypeResult.value;
|
|
859
|
+
// Create candidates from the decision's condition sets
|
|
860
|
+
ResourceManagerBuilder._createCandidatesFromDecision(compiledResource, decision, resourceType, builder, compiledCollection.candidateValues).aggregateError(errors);
|
|
861
|
+
}
|
|
862
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Helper method to create candidates from a decision's condition sets.
|
|
866
|
+
* @param compiledResource - The compiled resource containing candidates.
|
|
867
|
+
* @param decision - The decision containing condition sets.
|
|
868
|
+
* @param resourceType - The resource type for the candidates.
|
|
869
|
+
* @param builder - The builder to add candidates to.
|
|
870
|
+
* @param candidateValues - Array of candidate values indexed by valueIndex.
|
|
871
|
+
* @returns `Success` if all candidates were added successfully, `Failure` otherwise.
|
|
872
|
+
* @internal
|
|
873
|
+
*/
|
|
874
|
+
static _createCandidatesFromDecision(compiledResource, decision, resourceType, builder, candidateValues) {
|
|
875
|
+
var _a;
|
|
876
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
877
|
+
// Match each candidate to its corresponding condition set
|
|
878
|
+
for (let i = 0; i < compiledResource.candidates.length; i++) {
|
|
879
|
+
const candidate = compiledResource.candidates[i];
|
|
880
|
+
// Build conditions from the corresponding condition set (if available)
|
|
881
|
+
let conditions;
|
|
882
|
+
if (i < decision.candidates.length) {
|
|
883
|
+
const decisionCandidate = decision.candidates[i];
|
|
884
|
+
conditions = {};
|
|
885
|
+
for (const condition of decisionCandidate.conditionSet.conditions) {
|
|
886
|
+
conditions[condition.qualifier.name] = condition.value;
|
|
887
|
+
}
|
|
888
|
+
/* c8 ignore next 3 - defense in depth */
|
|
889
|
+
if (Object.keys(conditions).length === 0) {
|
|
890
|
+
conditions = undefined;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
// Get json value from candidateValues array using valueIndex
|
|
894
|
+
/* c8 ignore next 1 - defense in depth */
|
|
895
|
+
const rawJson = (_a = candidateValues[candidate.valueIndex]) !== null && _a !== void 0 ? _a : {};
|
|
896
|
+
ts_json_base_1.Converters.jsonObject
|
|
897
|
+
.convert(rawJson)
|
|
898
|
+
.onSuccess((json) => {
|
|
899
|
+
const candidateDecl = {
|
|
900
|
+
id: compiledResource.id,
|
|
901
|
+
json,
|
|
902
|
+
conditions,
|
|
903
|
+
isPartial: candidate.isPartial,
|
|
904
|
+
mergeMethod: candidate.mergeMethod,
|
|
905
|
+
resourceTypeName: resourceType.key
|
|
906
|
+
};
|
|
907
|
+
return builder.addLooseCandidate(candidateDecl).aggregateError(errors);
|
|
908
|
+
})
|
|
909
|
+
.aggregateError(errors);
|
|
910
|
+
}
|
|
911
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
912
|
+
}
|
|
675
913
|
}
|
|
676
914
|
exports.ResourceManagerBuilder = ResourceManagerBuilder;
|
|
677
915
|
//# sourceMappingURL=resourceManagerBuilder.js.map
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Collections, Result } from '@fgv/ts-utils';
|
|
2
2
|
import { ReadOnlyConditionCollector, ReadOnlyConditionSetCollector } from '../conditions';
|
|
3
3
|
import { ReadOnlyAbstractDecisionCollector } from '../decisions';
|
|
4
|
-
import {
|
|
5
|
-
import { ResourceType,
|
|
6
|
-
import { QualifierType,
|
|
4
|
+
import { IReadOnlyQualifierCollector } from '../qualifiers';
|
|
5
|
+
import { ResourceType, ReadOnlyResourceTypeCollector } from '../resource-types';
|
|
6
|
+
import { QualifierType, ReadOnlyQualifierTypeCollector } from '../qualifier-types';
|
|
7
7
|
import { ResourceId } from '../common';
|
|
8
|
+
import { JsonValue } from '@fgv/ts-json-base';
|
|
8
9
|
import { IResourceManager, IResource } from './iResourceManager';
|
|
9
10
|
import * as ResourceJson from '../resource-json';
|
|
10
|
-
import {
|
|
11
|
+
import { ReadOnlyResourceTreeRoot } from './resource-tree';
|
|
11
12
|
import * as Context from '../context';
|
|
12
13
|
/**
|
|
13
14
|
* Interface for parameters to create a {@link Runtime.CompiledResourceCollection | CompiledResourceCollection}.
|
|
@@ -33,30 +34,35 @@ export interface ICompiledResourceCollectionCreateParams {
|
|
|
33
34
|
* and use pre-compiled resource collections without rebuilding them from scratch.
|
|
34
35
|
* @public
|
|
35
36
|
*/
|
|
36
|
-
export declare class CompiledResourceCollection implements IResourceManager {
|
|
37
|
+
export declare class CompiledResourceCollection implements IResourceManager<IResource> {
|
|
37
38
|
readonly conditions: ReadOnlyConditionCollector;
|
|
38
39
|
readonly conditionSets: ReadOnlyConditionSetCollector;
|
|
39
40
|
readonly decisions: ReadOnlyAbstractDecisionCollector;
|
|
40
41
|
private readonly _qualifierTypes;
|
|
41
42
|
private readonly _qualifiers;
|
|
42
43
|
private readonly _resourceTypes;
|
|
44
|
+
private readonly _candidateValues;
|
|
43
45
|
private readonly _builtResources;
|
|
44
46
|
private _cachedResourceTree?;
|
|
45
47
|
/**
|
|
46
|
-
* A {@link QualifierTypes.
|
|
48
|
+
* A {@link QualifierTypes.ReadOnlyQualifierTypeCollector | ReadOnlyQualifierTypeCollector} which
|
|
47
49
|
* contains the {@link QualifierTypes.QualifierType | qualifier types} used in this collection.
|
|
48
50
|
*/
|
|
49
|
-
get qualifierTypes():
|
|
51
|
+
get qualifierTypes(): ReadOnlyQualifierTypeCollector;
|
|
50
52
|
/**
|
|
51
|
-
* A {@link Qualifiers.
|
|
53
|
+
* A {@link Qualifiers.IReadOnlyQualifierCollector | ReadOnlyQualifierCollector} which
|
|
52
54
|
* contains the {@link Qualifiers.Qualifier | qualifiers} used in this collection.
|
|
53
55
|
*/
|
|
54
|
-
get qualifiers():
|
|
56
|
+
get qualifiers(): IReadOnlyQualifierCollector;
|
|
55
57
|
/**
|
|
56
58
|
* A {@link ResourceTypes.ResourceTypeCollector | ResourceTypeCollector} which
|
|
57
59
|
* contains the {@link ResourceTypes.ResourceType | resource types} used in this collection.
|
|
58
60
|
*/
|
|
59
|
-
get resourceTypes():
|
|
61
|
+
get resourceTypes(): ReadOnlyResourceTypeCollector;
|
|
62
|
+
/**
|
|
63
|
+
* The candidate values in the collection.
|
|
64
|
+
*/
|
|
65
|
+
get candidateValues(): ReadonlyArray<JsonValue>;
|
|
60
66
|
/**
|
|
61
67
|
* {@inheritdoc Runtime.IResourceManager.builtResources}
|
|
62
68
|
*/
|
|
@@ -105,7 +111,7 @@ export declare class CompiledResourceCollection implements IResourceManager {
|
|
|
105
111
|
* @returns Result containing the resource tree root, or failure if tree construction fails
|
|
106
112
|
* @public
|
|
107
113
|
*/
|
|
108
|
-
getBuiltResourceTree(): Result<
|
|
114
|
+
getBuiltResourceTree(): Result<ReadOnlyResourceTreeRoot<IResource>>;
|
|
109
115
|
/**
|
|
110
116
|
* Reconstructs a QualifierTypeCollector from compiled data.
|
|
111
117
|
* @param compiled - The compiled resource collection
|
|
@@ -154,6 +160,12 @@ export declare class CompiledResourceCollection implements IResourceManager {
|
|
|
154
160
|
* @internal
|
|
155
161
|
*/
|
|
156
162
|
private _buildDecisions;
|
|
163
|
+
/**
|
|
164
|
+
* Gets a candidate value from the collection.
|
|
165
|
+
* @param valueIndex - The index of the candidate value to get.
|
|
166
|
+
* @returns
|
|
167
|
+
*/
|
|
168
|
+
private _getCandidateValue;
|
|
157
169
|
/**
|
|
158
170
|
* Reconstructs a ValidatingResultMap of resources from compiled data.
|
|
159
171
|
* @param compiled - The compiled resource collection
|