@fgv/ts-res 5.0.0-9 → 5.0.1-1
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 +2257 -268
- 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 +44 -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/deltaGenerator.d.ts +189 -0
- package/lib/packlets/resources/deltaGenerator.js +344 -0
- package/lib/packlets/resources/index.d.ts +3 -0
- package/lib/packlets/resources/index.js +3 -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 +131 -10
- package/lib/packlets/resources/resourceManagerBuilder.js +289 -45
- package/lib/packlets/runtime/compiledResourceCollection.d.ts +27 -11
- package/lib/packlets/runtime/compiledResourceCollection.js +71 -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 +17 -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 +43 -1
- package/lib/packlets/runtime/resourceResolver.js +56 -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
|
|
@@ -80,6 +91,12 @@ class ResourceManagerBuilder {
|
|
|
80
91
|
get conditions() {
|
|
81
92
|
return this._conditions;
|
|
82
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* The resource IDs that this resource manager can resolve.
|
|
96
|
+
*/
|
|
97
|
+
get resourceIds() {
|
|
98
|
+
return Array.from(this._resources.keys()).sort();
|
|
99
|
+
}
|
|
83
100
|
/**
|
|
84
101
|
* A {@link Conditions.ConditionSetCollector | ConditionSetCollector} which
|
|
85
102
|
* contains the {@link Conditions.ConditionSet | condition sets} used so far by
|
|
@@ -140,6 +157,7 @@ class ResourceManagerBuilder {
|
|
|
140
157
|
this._conditions = conditions_1.ConditionCollector.create({ qualifiers: params.qualifiers }).orThrow();
|
|
141
158
|
this._conditionSets = conditions_1.ConditionSetCollector.create({ conditions: this._conditions }).orThrow();
|
|
142
159
|
this._decisions = decisions_1.AbstractDecisionCollector.create({ conditionSets: this._conditionSets }).orThrow();
|
|
160
|
+
this._candidateValues = candidateValueCollector_1.CandidateValueCollector.create().orThrow();
|
|
143
161
|
this._resources = new ts_utils_1.ValidatingResultMap({
|
|
144
162
|
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
145
163
|
key: common_1.Convert.resourceId,
|
|
@@ -155,6 +173,7 @@ class ResourceManagerBuilder {
|
|
|
155
173
|
})
|
|
156
174
|
});
|
|
157
175
|
this._built = false;
|
|
176
|
+
this._cachedResourceTree = undefined;
|
|
158
177
|
}
|
|
159
178
|
/**
|
|
160
179
|
* Creates a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object.
|
|
@@ -175,13 +194,39 @@ class ResourceManagerBuilder {
|
|
|
175
194
|
* @public
|
|
176
195
|
*/
|
|
177
196
|
static createPredefined(name, qualifierDefaultValues) {
|
|
178
|
-
return Config.getPredefinedSystemConfiguration(name,
|
|
197
|
+
return Config.getPredefinedSystemConfiguration(name,
|
|
198
|
+
/* c8 ignore next 1 - defense in depth */
|
|
199
|
+
qualifierDefaultValues ? { qualifierDefaultValues } : undefined).onSuccess((systemConfig) => {
|
|
179
200
|
return ResourceManagerBuilder.create({
|
|
180
201
|
qualifiers: systemConfig.qualifiers,
|
|
181
202
|
resourceTypes: systemConfig.resourceTypes
|
|
182
203
|
});
|
|
183
204
|
});
|
|
184
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Creates a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} from a
|
|
208
|
+
* {@link ResourceJson.Compiled.ICompiledResourceCollection | compiled resource collection}.
|
|
209
|
+
* This method reconstructs an exactly equivalent builder where all qualifier, condition,
|
|
210
|
+
* condition set, and decision indices match the original compiled collection.
|
|
211
|
+
* @param compiledCollection - The compiled resource collection to reconstruct from.
|
|
212
|
+
* @param systemConfig - The system configuration containing qualifiers and resource types.
|
|
213
|
+
* @returns `Success` with the new manager if successful, or `Failure` with an error message if not.
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
216
|
+
static createFromCompiledResourceCollection(compiledCollection, systemConfig) {
|
|
217
|
+
// Create the base builder with system configuration
|
|
218
|
+
return ResourceManagerBuilder.create({
|
|
219
|
+
qualifiers: systemConfig.qualifiers,
|
|
220
|
+
resourceTypes: systemConfig.resourceTypes
|
|
221
|
+
}).onSuccess((builder) => {
|
|
222
|
+
// Reconstruct all entities in order to preserve indices
|
|
223
|
+
return ResourceManagerBuilder._reconstructConditions(builder, compiledCollection)
|
|
224
|
+
.onSuccess(() => ResourceManagerBuilder._reconstructConditionSets(builder, compiledCollection))
|
|
225
|
+
.onSuccess(() => ResourceManagerBuilder._reconstructDecisions(builder, compiledCollection))
|
|
226
|
+
.onSuccess(() => ResourceManagerBuilder._reconstructResources(builder, compiledCollection))
|
|
227
|
+
.onSuccess(() => (0, ts_utils_1.succeed)(builder));
|
|
228
|
+
});
|
|
229
|
+
}
|
|
185
230
|
/**
|
|
186
231
|
* Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds
|
|
187
232
|
* a {@link Resources.ResourceCandidate | candidate} to the manager.
|
|
@@ -198,7 +243,8 @@ class ResourceManagerBuilder {
|
|
|
198
243
|
id,
|
|
199
244
|
resourceTypes: this.resourceTypes,
|
|
200
245
|
conditionSets: this._conditionSets,
|
|
201
|
-
decisions: this._decisions
|
|
246
|
+
decisions: this._decisions,
|
|
247
|
+
candidateValues: this._candidateValues
|
|
202
248
|
}));
|
|
203
249
|
/* c8 ignore next 6 - defense in depth against internal error */
|
|
204
250
|
if (builderResult.isFailure()) {
|
|
@@ -208,12 +254,14 @@ class ResourceManagerBuilder {
|
|
|
208
254
|
this._builtResources.delete(id);
|
|
209
255
|
this._built = false;
|
|
210
256
|
this._numCandidates = undefined;
|
|
257
|
+
this._cachedResourceTree = undefined;
|
|
211
258
|
return (0, ts_utils_1.succeedWithDetail)(c, d);
|
|
212
259
|
});
|
|
213
260
|
}
|
|
214
261
|
addResource(decl) {
|
|
215
262
|
var _a;
|
|
216
263
|
const { value: id, message } = common_1.Validate.toResourceId(decl.id);
|
|
264
|
+
/* c8 ignore next 3 - defensive coding: resource ID validation should prevent invalid IDs */
|
|
217
265
|
if (message !== undefined) {
|
|
218
266
|
return (0, ts_utils_1.failWithDetail)(`${id}: invalid id - ${message}`, 'failure');
|
|
219
267
|
}
|
|
@@ -222,13 +270,15 @@ class ResourceManagerBuilder {
|
|
|
222
270
|
typeName: decl.resourceTypeName,
|
|
223
271
|
resourceTypes: this.resourceTypes,
|
|
224
272
|
conditionSets: this._conditionSets,
|
|
225
|
-
decisions: this._decisions
|
|
273
|
+
decisions: this._decisions,
|
|
274
|
+
candidateValues: this._candidateValues
|
|
226
275
|
}));
|
|
227
276
|
/* c8 ignore next 3 - defense in depth against internal error */
|
|
228
277
|
if (getOrAddMessage !== undefined) {
|
|
229
278
|
return (0, ts_utils_1.failWithDetail)(`${id}: unable to get or add resource\n${getOrAddMessage}`, detail);
|
|
230
279
|
}
|
|
231
280
|
if (detail === 'exists') {
|
|
281
|
+
/* c8 ignore next 4 - defensive coding: resource type mismatch on existing resources should not occur */
|
|
232
282
|
const { message } = builder.setResourceType(decl.resourceTypeName);
|
|
233
283
|
if (message !== undefined) {
|
|
234
284
|
return (0, ts_utils_1.failWithDetail)(`${id}: unable to set resource type\n${message}`, 'type-mismatch');
|
|
@@ -317,6 +367,36 @@ class ResourceManagerBuilder {
|
|
|
317
367
|
getAllBuiltResources() {
|
|
318
368
|
return this.build().onSuccess((manager) => (0, ts_utils_1.succeed)(Array.from(manager._builtResources.values()).sort((a, b) => a.id.localeCompare(b.id))));
|
|
319
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Builds and returns a hierarchical tree representation of all resources managed by this builder.
|
|
372
|
+
* Resources are organized based on their dot-separated resource IDs (e.g., "app.messages.welcome"
|
|
373
|
+
* becomes a tree with "app" as root, "messages" as branch, and "welcome" as leaf).
|
|
374
|
+
*
|
|
375
|
+
* String-based validation is available through the `children.validating` property,
|
|
376
|
+
* allowing callers to use `tree.children.validating.getById(stringId)` for validated access.
|
|
377
|
+
*
|
|
378
|
+
* Uses lazy initialization with caching for performance.
|
|
379
|
+
* @returns Result containing the resource tree root, or failure if tree construction fails
|
|
380
|
+
* @public
|
|
381
|
+
*/
|
|
382
|
+
getBuiltResourceTree() {
|
|
383
|
+
// Ensure resources are built first
|
|
384
|
+
return this.build().onSuccess((manager) => {
|
|
385
|
+
if (manager._cachedResourceTree) {
|
|
386
|
+
return (0, ts_utils_1.succeed)(manager._cachedResourceTree);
|
|
387
|
+
}
|
|
388
|
+
// Convert all built resources to [ResourceId, Resource] pairs
|
|
389
|
+
const resources = [];
|
|
390
|
+
for (const [id, resource] of manager._builtResources.entries()) {
|
|
391
|
+
resources.push([id, resource]);
|
|
392
|
+
}
|
|
393
|
+
// Create the resource tree with lazy initialization
|
|
394
|
+
return runtime_1.ResourceTree.ReadOnlyResourceTreeRoot.create(resources).onSuccess((tree) => {
|
|
395
|
+
manager._cachedResourceTree = tree;
|
|
396
|
+
return (0, ts_utils_1.succeed)(tree);
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
}
|
|
320
400
|
/**
|
|
321
401
|
* Gets a read-only array of all {@link Resources.Resource | built resources} in the manager.
|
|
322
402
|
* @returns `Success` with an array of resources if successful, or `Failure` with an error message if not.
|
|
@@ -407,6 +487,7 @@ class ResourceManagerBuilder {
|
|
|
407
487
|
getCompiledResourceCollection(options) {
|
|
408
488
|
// Build resources first to ensure all data is available
|
|
409
489
|
const buildResult = this._performBuild();
|
|
490
|
+
/* c8 ignore next 3 - defensive coding: build failure should not occur after successful validation */
|
|
410
491
|
if (buildResult.isFailure()) {
|
|
411
492
|
return (0, ts_utils_1.fail)(`Failed to build resources: ${buildResult.message}`);
|
|
412
493
|
}
|
|
@@ -427,6 +508,7 @@ class ResourceManagerBuilder {
|
|
|
427
508
|
conditions: Array.from(this._conditions.values()).map((c) => c.toCompiled(options)),
|
|
428
509
|
conditionSets: Array.from(this._conditionSets.values()).map((cs) => cs.toCompiled(options)),
|
|
429
510
|
decisions: Array.from(this._decisions.values()).map((d) => d.toCompiled(options)),
|
|
511
|
+
candidateValues: this._candidateValues.getValuesByIndex(),
|
|
430
512
|
resources: Array.from(this._builtResources.values()).map((r) => r.toCompiled(options))
|
|
431
513
|
};
|
|
432
514
|
// Apply validation through the converter
|
|
@@ -467,20 +549,26 @@ class ResourceManagerBuilder {
|
|
|
467
549
|
});
|
|
468
550
|
}
|
|
469
551
|
/**
|
|
470
|
-
* Creates a
|
|
471
|
-
* This
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
* @
|
|
552
|
+
* Creates a clone of this ResourceManagerBuilder with optional configuration overrides.
|
|
553
|
+
* This method creates a new ResourceManagerBuilder that can optionally use different
|
|
554
|
+
* qualifiers and/or resource types than the original. It can also be filtered to include
|
|
555
|
+
* only candidates that match the provided context and apply candidate edits.
|
|
556
|
+
*
|
|
557
|
+
* @param options - Options for the cloning operation:
|
|
558
|
+
* - `qualifiers`: Optional qualifier collector to use instead of the original
|
|
559
|
+
* - `resourceTypes`: Optional resource type collector to use instead of the original
|
|
560
|
+
* - `filterForContext`: Optional context filter for candidates
|
|
561
|
+
* - `candidates`: Optional candidate edits to apply during cloning
|
|
562
|
+
* @returns A Result containing the new ResourceManagerBuilder with the specified configuration.
|
|
476
563
|
* @public
|
|
477
564
|
*/
|
|
478
565
|
/* c8 ignore next 21 - functional code path tested but coverage intermittently missed */
|
|
479
566
|
clone(options) {
|
|
480
567
|
return this.getResourceCollectionDecl(options).onSuccess((collection) => {
|
|
568
|
+
var _a, _b;
|
|
481
569
|
return ResourceManagerBuilder.create({
|
|
482
|
-
qualifiers: this.qualifiers,
|
|
483
|
-
resourceTypes: this.resourceTypes
|
|
570
|
+
qualifiers: (_a = options === null || options === void 0 ? void 0 : options.qualifiers) !== null && _a !== void 0 ? _a : this.qualifiers,
|
|
571
|
+
resourceTypes: (_b = options === null || options === void 0 ? void 0 : options.resourceTypes) !== null && _b !== void 0 ? _b : this.resourceTypes
|
|
484
572
|
}).onSuccess((newManager) => {
|
|
485
573
|
// Check if we have candidates to apply as edits
|
|
486
574
|
const editCandidates = (options === null || options === void 0 ? void 0 : options.candidates) || [];
|
|
@@ -500,6 +588,7 @@ class ResourceManagerBuilder {
|
|
|
500
588
|
return (0, ts_utils_1.fail)(`${resourceDecl.id}: Failed to apply edits: ${editedDeclResult.message}`);
|
|
501
589
|
}
|
|
502
590
|
const addResult = newManager.addResource(editedDeclResult.value);
|
|
591
|
+
/* c8 ignore next 5 - edge case (nearly?) impossible to reproduce */
|
|
503
592
|
if (addResult.isFailure()) {
|
|
504
593
|
return (0, ts_utils_1.fail)(`${resourceDecl.id}: Failed to add resource to cloned manager: ${addResult.message}`);
|
|
505
594
|
}
|
|
@@ -556,36 +645,6 @@ class ResourceManagerBuilder {
|
|
|
556
645
|
* @returns A Result containing the ConditionSet token if successful, or failure if validation fails
|
|
557
646
|
* @internal
|
|
558
647
|
*/
|
|
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
648
|
/**
|
|
590
649
|
* Applies candidate edits to a resource declaration, handling collisions using condition set tokens.
|
|
591
650
|
* If there's no collision, adds the candidate. If there's a collision, replaces the original candidate with the edit.
|
|
@@ -596,7 +655,9 @@ class ResourceManagerBuilder {
|
|
|
596
655
|
* @internal
|
|
597
656
|
*/
|
|
598
657
|
static _applyEditsToResourceDeclaration(resourceDecl, candidatesByResource, conditionCollector) {
|
|
658
|
+
var _a, _b;
|
|
599
659
|
const { value: resourceId, message } = common_1.Validate.toResourceId(resourceDecl.id);
|
|
660
|
+
/* c8 ignore next 3 - defensive validation: resource IDs are validated when added to builder, but this protects against corrupted data */
|
|
600
661
|
if (message !== undefined) {
|
|
601
662
|
return (0, ts_utils_1.fail)(`Invalid resource ID "${resourceDecl.id}": ${message}`);
|
|
602
663
|
}
|
|
@@ -606,9 +667,12 @@ class ResourceManagerBuilder {
|
|
|
606
667
|
}
|
|
607
668
|
// Use Map approach: apply original candidates first, then replace with edits on collision
|
|
608
669
|
const candidatesByConditionKey = new Map();
|
|
670
|
+
/* c8 ignore next 1 - ?? is defense in depth */
|
|
671
|
+
const declCandidates = (_a = resourceDecl.candidates) !== null && _a !== void 0 ? _a : [];
|
|
609
672
|
// First, add all original candidates keyed by their condition set token
|
|
610
|
-
for (const candidate of
|
|
611
|
-
const conditionTokenResult =
|
|
673
|
+
for (const candidate of declCandidates) {
|
|
674
|
+
const conditionTokenResult = conditions_1.ConditionSet.getKeyFromLooseDecl(candidate.conditions, conditionCollector);
|
|
675
|
+
/* c8 ignore next 5 - edge case or internal error (nearly?) impossible to reproduce */
|
|
612
676
|
if (conditionTokenResult.isFailure()) {
|
|
613
677
|
return (0, ts_utils_1.fail)(`Failed to generate condition token for original candidate: ${conditionTokenResult.message}`);
|
|
614
678
|
}
|
|
@@ -617,12 +681,26 @@ class ResourceManagerBuilder {
|
|
|
617
681
|
// Then, apply edits (this replaces any colliding original candidates)
|
|
618
682
|
// Convert edit candidates (which have ids) to child candidates (without ids) for merging
|
|
619
683
|
for (const editCandidate of editCandidates) {
|
|
620
|
-
const conditionTokenResult =
|
|
684
|
+
const conditionTokenResult = conditions_1.ConditionSet.getKeyFromLooseDecl(editCandidate.conditions, conditionCollector);
|
|
621
685
|
if (conditionTokenResult.isFailure()) {
|
|
622
686
|
return (0, ts_utils_1.fail)(`Failed to generate condition token for edit candidate: ${conditionTokenResult.message}`);
|
|
623
687
|
}
|
|
688
|
+
let editedJson = editCandidate.json;
|
|
689
|
+
const previousJson = (_b = candidatesByConditionKey.get(conditionTokenResult.value)) === null || _b === void 0 ? void 0 : _b.json;
|
|
690
|
+
if (previousJson && previousJson !== editedJson) {
|
|
691
|
+
editedJson = ts_json_1.JsonEditor.create({
|
|
692
|
+
merge: {
|
|
693
|
+
arrayMergeBehavior: 'replace',
|
|
694
|
+
nullAsDelete: false
|
|
695
|
+
}
|
|
696
|
+
})
|
|
697
|
+
.onSuccess((editor) => {
|
|
698
|
+
return editor.mergeObjectsInPlace({}, [previousJson, editedJson]);
|
|
699
|
+
})
|
|
700
|
+
.orThrow();
|
|
701
|
+
}
|
|
624
702
|
const childCandidate = {
|
|
625
|
-
json:
|
|
703
|
+
json: editedJson,
|
|
626
704
|
conditions: editCandidate.conditions,
|
|
627
705
|
isPartial: editCandidate.isPartial,
|
|
628
706
|
mergeMethod: editCandidate.mergeMethod
|
|
@@ -647,11 +725,13 @@ class ResourceManagerBuilder {
|
|
|
647
725
|
// Convert candidate declarations to child candidate declarations
|
|
648
726
|
const childCandidates = [];
|
|
649
727
|
// Ensure we have candidates
|
|
728
|
+
/* c8 ignore next 3 - defense in depth against internal error */
|
|
650
729
|
if (candidates.length === 0) {
|
|
651
730
|
return (0, ts_utils_1.fail)('Cannot create resource declaration from empty candidates array');
|
|
652
731
|
}
|
|
653
732
|
// Extract resourceTypeName from the first candidate (all candidates for the same resource should have the same type)
|
|
654
733
|
const resourceTypeName = candidates[0].resourceTypeName;
|
|
734
|
+
/* c8 ignore next 3 - defense in depth */
|
|
655
735
|
if (!resourceTypeName) {
|
|
656
736
|
return (0, ts_utils_1.fail)('resourceTypeName is required for new resource candidates');
|
|
657
737
|
}
|
|
@@ -672,6 +752,170 @@ class ResourceManagerBuilder {
|
|
|
672
752
|
};
|
|
673
753
|
return (0, ts_utils_1.succeed)(newResourceDecl);
|
|
674
754
|
}
|
|
755
|
+
/**
|
|
756
|
+
* Reconstructs conditions from a compiled collection and adds them to the builder.
|
|
757
|
+
* @param builder - The builder to add conditions to.
|
|
758
|
+
* @param compiledCollection - The compiled collection containing conditions.
|
|
759
|
+
* @returns `Success` if all conditions were added successfully, `Failure` otherwise.
|
|
760
|
+
* @internal
|
|
761
|
+
*/
|
|
762
|
+
static _reconstructConditions(builder, compiledCollection) {
|
|
763
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
764
|
+
for (const compiledCondition of compiledCollection.conditions) {
|
|
765
|
+
// Get the qualifier by index
|
|
766
|
+
const qualifierResult = builder.qualifiers.getAt(compiledCondition.qualifierIndex);
|
|
767
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
768
|
+
if (qualifierResult.isFailure()) {
|
|
769
|
+
qualifierResult.aggregateError(errors);
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
// Create condition declaration from compiled condition
|
|
773
|
+
const conditionDecl = {
|
|
774
|
+
qualifierName: qualifierResult.value.name,
|
|
775
|
+
operator: compiledCondition.operator,
|
|
776
|
+
value: compiledCondition.value,
|
|
777
|
+
priority: compiledCondition.priority,
|
|
778
|
+
scoreAsDefault: compiledCondition.scoreAsDefault
|
|
779
|
+
};
|
|
780
|
+
// Add condition to builder (it will get the next sequential index)
|
|
781
|
+
builder.addCondition(conditionDecl).aggregateError(errors);
|
|
782
|
+
}
|
|
783
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Reconstructs condition sets from a compiled collection and adds them to the builder.
|
|
787
|
+
* @param builder - The builder to add condition sets to.
|
|
788
|
+
* @param compiledCollection - The compiled collection containing condition sets.
|
|
789
|
+
* @returns `Success` if all condition sets were added successfully, `Failure` otherwise.
|
|
790
|
+
* @internal
|
|
791
|
+
*/
|
|
792
|
+
static _reconstructConditionSets(builder, compiledCollection) {
|
|
793
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
794
|
+
for (const compiledConditionSet of compiledCollection.conditionSets) {
|
|
795
|
+
// Get conditions by their indices
|
|
796
|
+
const conditionResults = compiledConditionSet.conditions.map((idx) => builder._conditions.getAt(idx));
|
|
797
|
+
// Check for any failures
|
|
798
|
+
const failedIndex = conditionResults.findIndex((r) => r.isFailure());
|
|
799
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
800
|
+
if (failedIndex >= 0) {
|
|
801
|
+
conditionResults[failedIndex].aggregateError(errors);
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
// Create condition set from conditions (not declarations)
|
|
805
|
+
const conditions = conditionResults.map((r) => r.orThrow());
|
|
806
|
+
// Convert conditions to declarations for addConditionSet
|
|
807
|
+
const conditionDecls = conditions.map((c) => c.toLooseConditionDecl());
|
|
808
|
+
builder.addConditionSet(conditionDecls).aggregateError(errors);
|
|
809
|
+
}
|
|
810
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Reconstructs decisions from a compiled collection and adds them to the builder.
|
|
814
|
+
* @param builder - The builder to add decisions to.
|
|
815
|
+
* @param compiledCollection - The compiled collection containing decisions.
|
|
816
|
+
* @returns `Success` if all decisions were added successfully, `Failure` otherwise.
|
|
817
|
+
* @internal
|
|
818
|
+
*/
|
|
819
|
+
static _reconstructDecisions(builder, compiledCollection) {
|
|
820
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
821
|
+
for (const compiledDecision of compiledCollection.decisions) {
|
|
822
|
+
// Get condition sets by their indices
|
|
823
|
+
const conditionSetResults = compiledDecision.conditionSets.map((idx) => builder._conditionSets.getAt(idx));
|
|
824
|
+
// Check for any failures
|
|
825
|
+
const failedIndex = conditionSetResults.findIndex((r) => r.isFailure());
|
|
826
|
+
if (failedIndex >= 0) {
|
|
827
|
+
conditionSetResults[failedIndex].aggregateError(errors);
|
|
828
|
+
continue;
|
|
829
|
+
}
|
|
830
|
+
// Get condition sets from successful results
|
|
831
|
+
const conditionSets = conditionSetResults.map((r) => r.orThrow());
|
|
832
|
+
// Create AbstractDecision from condition sets and add to collector
|
|
833
|
+
decisions_1.AbstractDecision.createAbstractDecision({ conditionSets })
|
|
834
|
+
.onSuccess((decision) => builder._decisions.getOrAdd(decision))
|
|
835
|
+
.aggregateError(errors);
|
|
836
|
+
}
|
|
837
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Reconstructs resources and their candidates from a compiled collection and adds them to the builder.
|
|
841
|
+
* @param builder - The builder to add resources to.
|
|
842
|
+
* @param compiledCollection - The compiled collection containing resources.
|
|
843
|
+
* @returns `Success` if all resources were added successfully, `Failure` otherwise.
|
|
844
|
+
* @internal
|
|
845
|
+
*/
|
|
846
|
+
static _reconstructResources(builder, compiledCollection) {
|
|
847
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
848
|
+
for (const compiledResource of compiledCollection.resources) {
|
|
849
|
+
// Get the resource type by index
|
|
850
|
+
const resourceTypeResult = builder.resourceTypes.getAt(compiledResource.type);
|
|
851
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
852
|
+
if (resourceTypeResult.isFailure()) {
|
|
853
|
+
resourceTypeResult.aggregateError(errors);
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
// Get the decision by index
|
|
857
|
+
const decisionResult = builder._decisions.getAt(compiledResource.decision);
|
|
858
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
859
|
+
if (decisionResult.isFailure()) {
|
|
860
|
+
decisionResult.aggregateError(errors);
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
const decision = decisionResult.value;
|
|
864
|
+
const resourceType = resourceTypeResult.value;
|
|
865
|
+
// Create candidates from the decision's condition sets
|
|
866
|
+
ResourceManagerBuilder._createCandidatesFromDecision(compiledResource, decision, resourceType, builder, compiledCollection.candidateValues).aggregateError(errors);
|
|
867
|
+
}
|
|
868
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Helper method to create candidates from a decision's condition sets.
|
|
872
|
+
* @param compiledResource - The compiled resource containing candidates.
|
|
873
|
+
* @param decision - The decision containing condition sets.
|
|
874
|
+
* @param resourceType - The resource type for the candidates.
|
|
875
|
+
* @param builder - The builder to add candidates to.
|
|
876
|
+
* @param candidateValues - Array of candidate values indexed by valueIndex.
|
|
877
|
+
* @returns `Success` if all candidates were added successfully, `Failure` otherwise.
|
|
878
|
+
* @internal
|
|
879
|
+
*/
|
|
880
|
+
static _createCandidatesFromDecision(compiledResource, decision, resourceType, builder, candidateValues) {
|
|
881
|
+
var _a;
|
|
882
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
883
|
+
// Match each candidate to its corresponding condition set
|
|
884
|
+
for (let i = 0; i < compiledResource.candidates.length; i++) {
|
|
885
|
+
const candidate = compiledResource.candidates[i];
|
|
886
|
+
// Build conditions from the corresponding condition set (if available)
|
|
887
|
+
let conditions;
|
|
888
|
+
if (i < decision.candidates.length) {
|
|
889
|
+
const decisionCandidate = decision.candidates[i];
|
|
890
|
+
conditions = {};
|
|
891
|
+
for (const condition of decisionCandidate.conditionSet.conditions) {
|
|
892
|
+
conditions[condition.qualifier.name] = condition.value;
|
|
893
|
+
}
|
|
894
|
+
/* c8 ignore next 3 - defense in depth */
|
|
895
|
+
if (Object.keys(conditions).length === 0) {
|
|
896
|
+
conditions = undefined;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
// Get json value from candidateValues array using valueIndex
|
|
900
|
+
/* c8 ignore next 1 - defense in depth */
|
|
901
|
+
const rawJson = (_a = candidateValues[candidate.valueIndex]) !== null && _a !== void 0 ? _a : {};
|
|
902
|
+
ts_json_base_1.Converters.jsonObject
|
|
903
|
+
.convert(rawJson)
|
|
904
|
+
.onSuccess((json) => {
|
|
905
|
+
const candidateDecl = {
|
|
906
|
+
id: compiledResource.id,
|
|
907
|
+
json,
|
|
908
|
+
conditions,
|
|
909
|
+
isPartial: candidate.isPartial,
|
|
910
|
+
mergeMethod: candidate.mergeMethod,
|
|
911
|
+
resourceTypeName: resourceType.key
|
|
912
|
+
};
|
|
913
|
+
return builder.addLooseCandidate(candidateDecl).aggregateError(errors);
|
|
914
|
+
})
|
|
915
|
+
.aggregateError(errors);
|
|
916
|
+
}
|
|
917
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
918
|
+
}
|
|
675
919
|
}
|
|
676
920
|
exports.ResourceManagerBuilder = ResourceManagerBuilder;
|
|
677
921
|
//# 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,39 @@ 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;
|
|
57
|
+
/**
|
|
58
|
+
* The resource IDs contained in this compiled resource collection.
|
|
59
|
+
*/
|
|
60
|
+
get resourceIds(): ReadonlyArray<ResourceId>;
|
|
55
61
|
/**
|
|
56
62
|
* A {@link ResourceTypes.ResourceTypeCollector | ResourceTypeCollector} which
|
|
57
63
|
* contains the {@link ResourceTypes.ResourceType | resource types} used in this collection.
|
|
58
64
|
*/
|
|
59
|
-
get resourceTypes():
|
|
65
|
+
get resourceTypes(): ReadOnlyResourceTypeCollector;
|
|
66
|
+
/**
|
|
67
|
+
* The candidate values in the collection.
|
|
68
|
+
*/
|
|
69
|
+
get candidateValues(): ReadonlyArray<JsonValue>;
|
|
60
70
|
/**
|
|
61
71
|
* {@inheritdoc Runtime.IResourceManager.builtResources}
|
|
62
72
|
*/
|
|
@@ -105,7 +115,7 @@ export declare class CompiledResourceCollection implements IResourceManager {
|
|
|
105
115
|
* @returns Result containing the resource tree root, or failure if tree construction fails
|
|
106
116
|
* @public
|
|
107
117
|
*/
|
|
108
|
-
getBuiltResourceTree(): Result<
|
|
118
|
+
getBuiltResourceTree(): Result<ReadOnlyResourceTreeRoot<IResource>>;
|
|
109
119
|
/**
|
|
110
120
|
* Reconstructs a QualifierTypeCollector from compiled data.
|
|
111
121
|
* @param compiled - The compiled resource collection
|
|
@@ -154,6 +164,12 @@ export declare class CompiledResourceCollection implements IResourceManager {
|
|
|
154
164
|
* @internal
|
|
155
165
|
*/
|
|
156
166
|
private _buildDecisions;
|
|
167
|
+
/**
|
|
168
|
+
* Gets a candidate value from the collection.
|
|
169
|
+
* @param valueIndex - The index of the candidate value to get.
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
private _getCandidateValue;
|
|
157
173
|
/**
|
|
158
174
|
* Reconstructs a ValidatingResultMap of resources from compiled data.
|
|
159
175
|
* @param compiled - The compiled resource collection
|