@fgv/ts-res 5.0.0-3 → 5.0.0-30
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/README.md +794 -137
- package/dist/ts-res.d.ts +2344 -187
- package/dist/tsdoc-metadata.json +1 -1
- package/eslint.config.js +16 -0
- package/lib/index.d.ts +11 -2
- package/lib/index.js +25 -2
- package/lib/packlets/bundle/bundleBuilder.d.ts +41 -0
- package/lib/packlets/bundle/bundleBuilder.js +134 -0
- package/lib/packlets/bundle/bundleLoader.d.ts +72 -0
- package/lib/packlets/bundle/bundleLoader.js +105 -0
- package/lib/packlets/bundle/bundleNormalizer.d.ts +73 -0
- package/lib/packlets/bundle/bundleNormalizer.js +142 -0
- package/lib/packlets/bundle/bundleUtils.d.ts +70 -0
- package/lib/packlets/bundle/bundleUtils.js +117 -0
- package/lib/packlets/bundle/convert.d.ts +33 -0
- package/lib/packlets/bundle/convert.js +78 -0
- package/lib/packlets/bundle/index.d.ts +21 -0
- package/lib/packlets/bundle/index.js +83 -0
- package/lib/packlets/bundle/model.d.ts +100 -0
- package/lib/packlets/bundle/model.js +24 -0
- package/lib/packlets/common/convert.d.ts +10 -0
- package/lib/packlets/common/convert.js +11 -1
- package/lib/packlets/common/helpers/resources.d.ts +7 -0
- package/lib/packlets/common/helpers/resources.js +12 -0
- package/lib/packlets/common/resources.d.ts +48 -1
- 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 +54 -0
- package/lib/packlets/conditions/conditionSet.d.ts +9 -0
- package/lib/packlets/conditions/conditionSet.js +74 -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.js +8 -13
- package/lib/packlets/import/importers/jsonImporter.js +1 -0
- 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 +11 -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 +77 -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 +14 -5
- package/lib/packlets/resource-types/jsonResourceType.js +8 -4
- package/lib/packlets/resource-types/resourceType.d.ts +115 -14
- package/lib/packlets/resource-types/resourceType.js +39 -3
- 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 +26 -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 +3 -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 +189 -11
- package/lib/packlets/resources/resourceManagerBuilder.js +478 -17
- package/lib/packlets/runtime/cacheListener.d.ts +9 -0
- package/lib/packlets/runtime/cacheListener.js +6 -0
- package/lib/packlets/runtime/cacheMetrics.d.ts +6 -0
- package/lib/packlets/runtime/cacheMetrics.js +11 -0
- package/lib/packlets/runtime/compiledResourceCollection.d.ts +23 -11
- package/lib/packlets/runtime/compiledResourceCollection.js +32 -4
- 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 +60 -1
- package/lib/packlets/runtime/resourceResolver.js +84 -45
- 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 +194 -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 +285 -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/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,13 +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"));
|
|
69
|
+
const Config = __importStar(require("../config"));
|
|
70
|
+
const ts_json_1 = require("@fgv/ts-json");
|
|
66
71
|
/**
|
|
67
72
|
* Builder for a collection of {@link Resources.Resource | resources}. Collects
|
|
68
73
|
* {@link Resources.ResourceCandidate | candidates} for each resource into a
|
|
@@ -71,6 +76,13 @@ const Context = __importStar(require("../context"));
|
|
|
71
76
|
* @public
|
|
72
77
|
*/
|
|
73
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
|
+
}
|
|
74
86
|
/**
|
|
75
87
|
* A {@link Conditions.ConditionCollector | ConditionCollector} which
|
|
76
88
|
* contains the {@link Conditions.Condition | conditions} used so far by
|
|
@@ -139,6 +151,7 @@ class ResourceManagerBuilder {
|
|
|
139
151
|
this._conditions = conditions_1.ConditionCollector.create({ qualifiers: params.qualifiers }).orThrow();
|
|
140
152
|
this._conditionSets = conditions_1.ConditionSetCollector.create({ conditions: this._conditions }).orThrow();
|
|
141
153
|
this._decisions = decisions_1.AbstractDecisionCollector.create({ conditionSets: this._conditionSets }).orThrow();
|
|
154
|
+
this._candidateValues = candidateValueCollector_1.CandidateValueCollector.create().orThrow();
|
|
142
155
|
this._resources = new ts_utils_1.ValidatingResultMap({
|
|
143
156
|
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
144
157
|
key: common_1.Convert.resourceId,
|
|
@@ -154,6 +167,7 @@ class ResourceManagerBuilder {
|
|
|
154
167
|
})
|
|
155
168
|
});
|
|
156
169
|
this._built = false;
|
|
170
|
+
this._cachedResourceTree = undefined;
|
|
157
171
|
}
|
|
158
172
|
/**
|
|
159
173
|
* Creates a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object.
|
|
@@ -165,6 +179,48 @@ class ResourceManagerBuilder {
|
|
|
165
179
|
static create(params) {
|
|
166
180
|
return (0, ts_utils_1.captureResult)(() => new ResourceManagerBuilder(params));
|
|
167
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Creates a new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object from a predefined system configuration.
|
|
184
|
+
* @param name - The name of the predefined system configuration to use.
|
|
185
|
+
* @param qualifierDefaultValues - Optional default values for qualifiers.
|
|
186
|
+
* @returns `Success` with the new {@link Resources.ResourceManagerBuilder | ResourceManagerBuilder} object if successful,
|
|
187
|
+
* or `Failure` with an error message if not.
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
static createPredefined(name, qualifierDefaultValues) {
|
|
191
|
+
return Config.getPredefinedSystemConfiguration(name,
|
|
192
|
+
/* c8 ignore next 1 - defense in depth */
|
|
193
|
+
qualifierDefaultValues ? { qualifierDefaultValues } : undefined).onSuccess((systemConfig) => {
|
|
194
|
+
return ResourceManagerBuilder.create({
|
|
195
|
+
qualifiers: systemConfig.qualifiers,
|
|
196
|
+
resourceTypes: systemConfig.resourceTypes
|
|
197
|
+
});
|
|
198
|
+
});
|
|
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
|
+
}
|
|
168
224
|
/**
|
|
169
225
|
* Given a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}, builds and adds
|
|
170
226
|
* a {@link Resources.ResourceCandidate | candidate} to the manager.
|
|
@@ -181,7 +237,8 @@ class ResourceManagerBuilder {
|
|
|
181
237
|
id,
|
|
182
238
|
resourceTypes: this.resourceTypes,
|
|
183
239
|
conditionSets: this._conditionSets,
|
|
184
|
-
decisions: this._decisions
|
|
240
|
+
decisions: this._decisions,
|
|
241
|
+
candidateValues: this._candidateValues
|
|
185
242
|
}));
|
|
186
243
|
/* c8 ignore next 6 - defense in depth against internal error */
|
|
187
244
|
if (builderResult.isFailure()) {
|
|
@@ -191,6 +248,7 @@ class ResourceManagerBuilder {
|
|
|
191
248
|
this._builtResources.delete(id);
|
|
192
249
|
this._built = false;
|
|
193
250
|
this._numCandidates = undefined;
|
|
251
|
+
this._cachedResourceTree = undefined;
|
|
194
252
|
return (0, ts_utils_1.succeedWithDetail)(c, d);
|
|
195
253
|
});
|
|
196
254
|
}
|
|
@@ -205,7 +263,8 @@ class ResourceManagerBuilder {
|
|
|
205
263
|
typeName: decl.resourceTypeName,
|
|
206
264
|
resourceTypes: this.resourceTypes,
|
|
207
265
|
conditionSets: this._conditionSets,
|
|
208
|
-
decisions: this._decisions
|
|
266
|
+
decisions: this._decisions,
|
|
267
|
+
candidateValues: this._candidateValues
|
|
209
268
|
}));
|
|
210
269
|
/* c8 ignore next 3 - defense in depth against internal error */
|
|
211
270
|
if (getOrAddMessage !== undefined) {
|
|
@@ -224,6 +283,37 @@ class ResourceManagerBuilder {
|
|
|
224
283
|
})
|
|
225
284
|
.withDetail('failure', detail);
|
|
226
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Adds a condition to the manager.
|
|
288
|
+
* @param decl - The condition declaration to add.
|
|
289
|
+
* @returns `Success` with the condition if successful, or `Failure` with an error message if not.
|
|
290
|
+
* @public
|
|
291
|
+
*/
|
|
292
|
+
addCondition(decl) {
|
|
293
|
+
return conditions_1.Convert.validatedConditionDecl
|
|
294
|
+
.convert(decl, { qualifiers: this.qualifiers })
|
|
295
|
+
.onSuccess((validated) => {
|
|
296
|
+
return conditions_1.Condition.getKeyForDecl(validated).onSuccess((key) => {
|
|
297
|
+
return this._conditions.validating.getOrAdd(key, () => conditions_1.Condition.create(validated));
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Adds a condition set to the manager.
|
|
303
|
+
* @param decl - The condition set declaration to add.
|
|
304
|
+
* @returns `Success` with the condition set if successful, or `Failure` with an error message if not.
|
|
305
|
+
* @public
|
|
306
|
+
*/
|
|
307
|
+
addConditionSet(conditions) {
|
|
308
|
+
const decl = { conditions: [...conditions] };
|
|
309
|
+
return conditions_1.Convert.validatedConditionSetDecl
|
|
310
|
+
.convert(decl, { conditions: this._conditions })
|
|
311
|
+
.onSuccess((validated) => {
|
|
312
|
+
return conditions_1.ConditionSet.getKeyForDecl(validated).onSuccess((key) => {
|
|
313
|
+
return this._conditionSets.validating.getOrAdd(key, () => conditions_1.ConditionSet.create(validated));
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
}
|
|
227
317
|
/**
|
|
228
318
|
* Gets a read-only array of all {@link Resources.ResourceBuilder | resource builders} present in the manager.
|
|
229
319
|
* @returns `Success` with the {@link Resources.ResourceBuilder | resource builder} if successful,
|
|
@@ -269,6 +359,36 @@ class ResourceManagerBuilder {
|
|
|
269
359
|
getAllBuiltResources() {
|
|
270
360
|
return this.build().onSuccess((manager) => (0, ts_utils_1.succeed)(Array.from(manager._builtResources.values()).sort((a, b) => a.id.localeCompare(b.id))));
|
|
271
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Builds and returns a hierarchical tree representation of all resources managed by this builder.
|
|
364
|
+
* Resources are organized based on their dot-separated resource IDs (e.g., "app.messages.welcome"
|
|
365
|
+
* becomes a tree with "app" as root, "messages" as branch, and "welcome" as leaf).
|
|
366
|
+
*
|
|
367
|
+
* String-based validation is available through the `children.validating` property,
|
|
368
|
+
* allowing callers to use `tree.children.validating.getById(stringId)` for validated access.
|
|
369
|
+
*
|
|
370
|
+
* Uses lazy initialization with caching for performance.
|
|
371
|
+
* @returns Result containing the resource tree root, or failure if tree construction fails
|
|
372
|
+
* @public
|
|
373
|
+
*/
|
|
374
|
+
getBuiltResourceTree() {
|
|
375
|
+
// Ensure resources are built first
|
|
376
|
+
return this.build().onSuccess((manager) => {
|
|
377
|
+
if (manager._cachedResourceTree) {
|
|
378
|
+
return (0, ts_utils_1.succeed)(manager._cachedResourceTree);
|
|
379
|
+
}
|
|
380
|
+
// Convert all built resources to [ResourceId, Resource] pairs
|
|
381
|
+
const resources = [];
|
|
382
|
+
for (const [id, resource] of manager._builtResources.entries()) {
|
|
383
|
+
resources.push([id, resource]);
|
|
384
|
+
}
|
|
385
|
+
// Create the resource tree with lazy initialization
|
|
386
|
+
return runtime_1.ResourceTree.ReadOnlyResourceTreeRoot.create(resources).onSuccess((tree) => {
|
|
387
|
+
manager._cachedResourceTree = tree;
|
|
388
|
+
return (0, ts_utils_1.succeed)(tree);
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
}
|
|
272
392
|
/**
|
|
273
393
|
* Gets a read-only array of all {@link Resources.Resource | built resources} in the manager.
|
|
274
394
|
* @returns `Success` with an array of resources if successful, or `Failure` with an error message if not.
|
|
@@ -379,6 +499,7 @@ class ResourceManagerBuilder {
|
|
|
379
499
|
conditions: Array.from(this._conditions.values()).map((c) => c.toCompiled(options)),
|
|
380
500
|
conditionSets: Array.from(this._conditionSets.values()).map((cs) => cs.toCompiled(options)),
|
|
381
501
|
decisions: Array.from(this._decisions.values()).map((d) => d.toCompiled(options)),
|
|
502
|
+
candidateValues: this._candidateValues.getValuesByIndex(),
|
|
382
503
|
resources: Array.from(this._builtResources.values()).map((r) => r.toCompiled(options))
|
|
383
504
|
};
|
|
384
505
|
// Apply validation through the converter
|
|
@@ -419,33 +540,373 @@ class ResourceManagerBuilder {
|
|
|
419
540
|
});
|
|
420
541
|
}
|
|
421
542
|
/**
|
|
422
|
-
* Creates a
|
|
423
|
-
* This
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
543
|
+
* Creates a clone of this ResourceManagerBuilder with optional configuration overrides.
|
|
544
|
+
* This method creates a new ResourceManagerBuilder that can optionally use different
|
|
545
|
+
* qualifiers and/or resource types than the original. It can also be filtered to include
|
|
546
|
+
* only candidates that match the provided context and apply candidate edits.
|
|
547
|
+
*
|
|
548
|
+
* @param options - Options for the cloning operation:
|
|
549
|
+
* - `qualifiers`: Optional qualifier collector to use instead of the original
|
|
550
|
+
* - `resourceTypes`: Optional resource type collector to use instead of the original
|
|
551
|
+
* - `filterForContext`: Optional context filter for candidates
|
|
552
|
+
* - `candidates`: Optional candidate edits to apply during cloning
|
|
553
|
+
* @returns A Result containing the new ResourceManagerBuilder with the specified configuration.
|
|
427
554
|
* @public
|
|
428
555
|
*/
|
|
429
556
|
/* c8 ignore next 21 - functional code path tested but coverage intermittently missed */
|
|
430
557
|
clone(options) {
|
|
431
558
|
return this.getResourceCollectionDecl(options).onSuccess((collection) => {
|
|
559
|
+
var _a, _b;
|
|
432
560
|
return ResourceManagerBuilder.create({
|
|
433
|
-
qualifiers: this.qualifiers,
|
|
434
|
-
resourceTypes: this.resourceTypes
|
|
561
|
+
qualifiers: (_a = options === null || options === void 0 ? void 0 : options.qualifiers) !== null && _a !== void 0 ? _a : this.qualifiers,
|
|
562
|
+
resourceTypes: (_b = options === null || options === void 0 ? void 0 : options.resourceTypes) !== null && _b !== void 0 ? _b : this.resourceTypes
|
|
435
563
|
}).onSuccess((newManager) => {
|
|
436
|
-
//
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
564
|
+
// Check if we have candidates to apply as edits
|
|
565
|
+
const editCandidates = (options === null || options === void 0 ? void 0 : options.candidates) || [];
|
|
566
|
+
const candidatesByResourceResult = editCandidates.length > 0
|
|
567
|
+
? ResourceManagerBuilder._createCandidatesByResourceMap(editCandidates)
|
|
568
|
+
: (0, ts_utils_1.succeed)(new Map());
|
|
569
|
+
return candidatesByResourceResult.onSuccess((candidatesByResource) => {
|
|
570
|
+
// Track which resource IDs have been processed from the original collection
|
|
571
|
+
const processedResourceIds = new Set();
|
|
572
|
+
// Add each resource from the filtered collection to the new manager
|
|
573
|
+
if (collection.resources) {
|
|
574
|
+
for (const resourceDecl of collection.resources) {
|
|
575
|
+
processedResourceIds.add(resourceDecl.id);
|
|
576
|
+
// Apply edits if there are candidates for this resource
|
|
577
|
+
const editedDeclResult = ResourceManagerBuilder._applyEditsToResourceDeclaration(resourceDecl, candidatesByResource, this._conditions);
|
|
578
|
+
if (editedDeclResult.isFailure()) {
|
|
579
|
+
return (0, ts_utils_1.fail)(`${resourceDecl.id}: Failed to apply edits: ${editedDeclResult.message}`);
|
|
580
|
+
}
|
|
581
|
+
const addResult = newManager.addResource(editedDeclResult.value);
|
|
582
|
+
/* c8 ignore next 5 - edge case (nearly?) impossible to reproduce */
|
|
583
|
+
if (addResult.isFailure()) {
|
|
584
|
+
return (0, ts_utils_1.fail)(`${resourceDecl.id}: Failed to add resource to cloned manager: ${addResult.message}`);
|
|
585
|
+
}
|
|
442
586
|
}
|
|
443
587
|
}
|
|
444
|
-
|
|
445
|
-
|
|
588
|
+
// Handle any remaining candidates that target new resources not in the original collection
|
|
589
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
590
|
+
for (const [resourceId, candidates] of candidatesByResource) {
|
|
591
|
+
if (!processedResourceIds.has(resourceId)) {
|
|
592
|
+
// Create a new resource declaration for candidates targeting a new resource ID
|
|
593
|
+
ResourceManagerBuilder._createResourceDeclFromCandidates(resourceId, candidates, this._conditions)
|
|
594
|
+
.withErrorFormat((e) => `${resourceId}: Failed to create new resource from candidates: ${e}`)
|
|
595
|
+
.onSuccess((newResourceDecl) => {
|
|
596
|
+
return newManager
|
|
597
|
+
.addResource(newResourceDecl)
|
|
598
|
+
.withErrorFormat((e) => `${resourceId}: Failed to add new resource to cloned manager: ${e}`);
|
|
599
|
+
})
|
|
600
|
+
.aggregateError(errors);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(newManager));
|
|
604
|
+
});
|
|
446
605
|
});
|
|
447
606
|
});
|
|
448
607
|
}
|
|
608
|
+
/**
|
|
609
|
+
* Creates a resource ID keyed map from an array of loose resource candidate declarations.
|
|
610
|
+
* This enables efficient detection of edit collisions by grouping candidates by their target resource.
|
|
611
|
+
* @param candidates - Array of loose resource candidate declarations to organize
|
|
612
|
+
* @returns A Result containing a Map where keys are validated ResourceIds and values are arrays of candidates for that resource
|
|
613
|
+
* @internal
|
|
614
|
+
*/
|
|
615
|
+
static _createCandidatesByResourceMap(candidates) {
|
|
616
|
+
const candidatesByResource = new Map();
|
|
617
|
+
for (const candidate of candidates) {
|
|
618
|
+
const { value: resourceId, message } = common_1.Validate.toResourceId(candidate.id);
|
|
619
|
+
if (message !== undefined) {
|
|
620
|
+
return (0, ts_utils_1.fail)(`Invalid resource ID "${candidate.id}": ${message}`);
|
|
621
|
+
}
|
|
622
|
+
const existingCandidates = candidatesByResource.get(resourceId);
|
|
623
|
+
if (existingCandidates) {
|
|
624
|
+
existingCandidates.push(candidate);
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
candidatesByResource.set(resourceId, [candidate]);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return (0, ts_utils_1.succeed)(candidatesByResource);
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Generates a proper ConditionSet token for collision detection using the existing ConditionSet.getKeyForDecl method.
|
|
634
|
+
* @param conditionSet - The condition set to generate a token for
|
|
635
|
+
* @param conditionCollector - The condition collector needed for validation context
|
|
636
|
+
* @returns A Result containing the ConditionSet token if successful, or failure if validation fails
|
|
637
|
+
* @internal
|
|
638
|
+
*/
|
|
639
|
+
/**
|
|
640
|
+
* Applies candidate edits to a resource declaration, handling collisions using condition set tokens.
|
|
641
|
+
* If there's no collision, adds the candidate. If there's a collision, replaces the original candidate with the edit.
|
|
642
|
+
* @param resourceDecl - The original resource declaration to potentially modify
|
|
643
|
+
* @param candidatesByResource - Map of resource IDs to arrays of candidate edits
|
|
644
|
+
* @param conditionCollector - The condition collector needed for generating condition tokens
|
|
645
|
+
* @returns A Result containing the resource declaration to use (original or modified)
|
|
646
|
+
* @internal
|
|
647
|
+
*/
|
|
648
|
+
static _applyEditsToResourceDeclaration(resourceDecl, candidatesByResource, conditionCollector) {
|
|
649
|
+
var _a, _b;
|
|
650
|
+
const { value: resourceId, message } = common_1.Validate.toResourceId(resourceDecl.id);
|
|
651
|
+
/* c8 ignore next 3 - defensive validation: resource IDs are validated when added to builder, but this protects against corrupted data */
|
|
652
|
+
if (message !== undefined) {
|
|
653
|
+
return (0, ts_utils_1.fail)(`Invalid resource ID "${resourceDecl.id}": ${message}`);
|
|
654
|
+
}
|
|
655
|
+
const editCandidates = candidatesByResource.get(resourceId);
|
|
656
|
+
if (!editCandidates || editCandidates.length === 0) {
|
|
657
|
+
return (0, ts_utils_1.succeed)(resourceDecl);
|
|
658
|
+
}
|
|
659
|
+
// Use Map approach: apply original candidates first, then replace with edits on collision
|
|
660
|
+
const candidatesByConditionKey = new Map();
|
|
661
|
+
/* c8 ignore next 1 - ?? is defense in depth */
|
|
662
|
+
const declCandidates = (_a = resourceDecl.candidates) !== null && _a !== void 0 ? _a : [];
|
|
663
|
+
// First, add all original candidates keyed by their condition set token
|
|
664
|
+
for (const candidate of declCandidates) {
|
|
665
|
+
const conditionTokenResult = conditions_1.ConditionSet.getKeyFromLooseDecl(candidate.conditions, conditionCollector);
|
|
666
|
+
/* c8 ignore next 5 - edge case or internal error (nearly?) impossible to reproduce */
|
|
667
|
+
if (conditionTokenResult.isFailure()) {
|
|
668
|
+
return (0, ts_utils_1.fail)(`Failed to generate condition token for original candidate: ${conditionTokenResult.message}`);
|
|
669
|
+
}
|
|
670
|
+
candidatesByConditionKey.set(conditionTokenResult.value, candidate);
|
|
671
|
+
}
|
|
672
|
+
// Then, apply edits (this replaces any colliding original candidates)
|
|
673
|
+
// Convert edit candidates (which have ids) to child candidates (without ids) for merging
|
|
674
|
+
for (const editCandidate of editCandidates) {
|
|
675
|
+
const conditionTokenResult = conditions_1.ConditionSet.getKeyFromLooseDecl(editCandidate.conditions, conditionCollector);
|
|
676
|
+
if (conditionTokenResult.isFailure()) {
|
|
677
|
+
return (0, ts_utils_1.fail)(`Failed to generate condition token for edit candidate: ${conditionTokenResult.message}`);
|
|
678
|
+
}
|
|
679
|
+
let editedJson = editCandidate.json;
|
|
680
|
+
const previousJson = (_b = candidatesByConditionKey.get(conditionTokenResult.value)) === null || _b === void 0 ? void 0 : _b.json;
|
|
681
|
+
if (previousJson && previousJson !== editedJson) {
|
|
682
|
+
editedJson = ts_json_1.JsonEditor.create({
|
|
683
|
+
merge: {
|
|
684
|
+
arrayMergeBehavior: 'replace',
|
|
685
|
+
nullAsDelete: false
|
|
686
|
+
}
|
|
687
|
+
})
|
|
688
|
+
.onSuccess((editor) => {
|
|
689
|
+
return editor.mergeObjectsInPlace({}, [previousJson, editedJson]);
|
|
690
|
+
})
|
|
691
|
+
.orThrow();
|
|
692
|
+
}
|
|
693
|
+
const childCandidate = {
|
|
694
|
+
json: editedJson,
|
|
695
|
+
conditions: editCandidate.conditions,
|
|
696
|
+
isPartial: editCandidate.isPartial,
|
|
697
|
+
mergeMethod: editCandidate.mergeMethod
|
|
698
|
+
};
|
|
699
|
+
candidatesByConditionKey.set(conditionTokenResult.value, childCandidate);
|
|
700
|
+
}
|
|
701
|
+
// Extract the final merged candidate list
|
|
702
|
+
const mergedCandidates = Array.from(candidatesByConditionKey.values());
|
|
703
|
+
const modifiedDecl = Object.assign(Object.assign({}, resourceDecl), { candidates: mergedCandidates });
|
|
704
|
+
return (0, ts_utils_1.succeed)(modifiedDecl);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Creates a new resource declaration from an array of candidate declarations.
|
|
708
|
+
* This is used when cloning to create new resources that don't exist in the original manager.
|
|
709
|
+
* @param resourceId - The validated resource ID for the new resource
|
|
710
|
+
* @param candidates - Array of loose candidate declarations for the new resource
|
|
711
|
+
* @param conditionCollector - The condition collector for validation context
|
|
712
|
+
* @returns A Result containing the new resource declaration if successful, or failure if validation fails
|
|
713
|
+
* @internal
|
|
714
|
+
*/
|
|
715
|
+
static _createResourceDeclFromCandidates(resourceId, candidates, conditionCollector) {
|
|
716
|
+
// Convert candidate declarations to child candidate declarations
|
|
717
|
+
const childCandidates = [];
|
|
718
|
+
// Ensure we have candidates
|
|
719
|
+
/* c8 ignore next 3 - defense in depth against internal error */
|
|
720
|
+
if (candidates.length === 0) {
|
|
721
|
+
return (0, ts_utils_1.fail)('Cannot create resource declaration from empty candidates array');
|
|
722
|
+
}
|
|
723
|
+
// Extract resourceTypeName from the first candidate (all candidates for the same resource should have the same type)
|
|
724
|
+
const resourceTypeName = candidates[0].resourceTypeName;
|
|
725
|
+
/* c8 ignore next 3 - defense in depth */
|
|
726
|
+
if (!resourceTypeName) {
|
|
727
|
+
return (0, ts_utils_1.fail)('resourceTypeName is required for new resource candidates');
|
|
728
|
+
}
|
|
729
|
+
for (const candidate of candidates) {
|
|
730
|
+
const childCandidate = {
|
|
731
|
+
json: candidate.json,
|
|
732
|
+
conditions: candidate.conditions,
|
|
733
|
+
isPartial: candidate.isPartial,
|
|
734
|
+
mergeMethod: candidate.mergeMethod
|
|
735
|
+
};
|
|
736
|
+
childCandidates.push(childCandidate);
|
|
737
|
+
}
|
|
738
|
+
// Create the new resource declaration
|
|
739
|
+
const newResourceDecl = {
|
|
740
|
+
id: resourceId,
|
|
741
|
+
candidates: childCandidates,
|
|
742
|
+
resourceTypeName
|
|
743
|
+
};
|
|
744
|
+
return (0, ts_utils_1.succeed)(newResourceDecl);
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Reconstructs conditions from a compiled collection and adds them to the builder.
|
|
748
|
+
* @param builder - The builder to add conditions to.
|
|
749
|
+
* @param compiledCollection - The compiled collection containing conditions.
|
|
750
|
+
* @returns `Success` if all conditions were added successfully, `Failure` otherwise.
|
|
751
|
+
* @internal
|
|
752
|
+
*/
|
|
753
|
+
static _reconstructConditions(builder, compiledCollection) {
|
|
754
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
755
|
+
for (const compiledCondition of compiledCollection.conditions) {
|
|
756
|
+
// Get the qualifier by index
|
|
757
|
+
const qualifierResult = builder.qualifiers.getAt(compiledCondition.qualifierIndex);
|
|
758
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
759
|
+
if (qualifierResult.isFailure()) {
|
|
760
|
+
qualifierResult.aggregateError(errors);
|
|
761
|
+
continue;
|
|
762
|
+
}
|
|
763
|
+
// Create condition declaration from compiled condition
|
|
764
|
+
const conditionDecl = {
|
|
765
|
+
qualifierName: qualifierResult.value.name,
|
|
766
|
+
operator: compiledCondition.operator,
|
|
767
|
+
value: compiledCondition.value,
|
|
768
|
+
priority: compiledCondition.priority,
|
|
769
|
+
scoreAsDefault: compiledCondition.scoreAsDefault
|
|
770
|
+
};
|
|
771
|
+
// Add condition to builder (it will get the next sequential index)
|
|
772
|
+
builder.addCondition(conditionDecl).aggregateError(errors);
|
|
773
|
+
}
|
|
774
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Reconstructs condition sets from a compiled collection and adds them to the builder.
|
|
778
|
+
* @param builder - The builder to add condition sets to.
|
|
779
|
+
* @param compiledCollection - The compiled collection containing condition sets.
|
|
780
|
+
* @returns `Success` if all condition sets were added successfully, `Failure` otherwise.
|
|
781
|
+
* @internal
|
|
782
|
+
*/
|
|
783
|
+
static _reconstructConditionSets(builder, compiledCollection) {
|
|
784
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
785
|
+
for (const compiledConditionSet of compiledCollection.conditionSets) {
|
|
786
|
+
// Get conditions by their indices
|
|
787
|
+
const conditionResults = compiledConditionSet.conditions.map((idx) => builder._conditions.getAt(idx));
|
|
788
|
+
// Check for any failures
|
|
789
|
+
const failedIndex = conditionResults.findIndex((r) => r.isFailure());
|
|
790
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
791
|
+
if (failedIndex >= 0) {
|
|
792
|
+
conditionResults[failedIndex].aggregateError(errors);
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
// Create condition set from conditions (not declarations)
|
|
796
|
+
const conditions = conditionResults.map((r) => r.orThrow());
|
|
797
|
+
// Convert conditions to declarations for addConditionSet
|
|
798
|
+
const conditionDecls = conditions.map((c) => c.toLooseConditionDecl());
|
|
799
|
+
builder.addConditionSet(conditionDecls).aggregateError(errors);
|
|
800
|
+
}
|
|
801
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Reconstructs decisions from a compiled collection and adds them to the builder.
|
|
805
|
+
* @param builder - The builder to add decisions to.
|
|
806
|
+
* @param compiledCollection - The compiled collection containing decisions.
|
|
807
|
+
* @returns `Success` if all decisions were added successfully, `Failure` otherwise.
|
|
808
|
+
* @internal
|
|
809
|
+
*/
|
|
810
|
+
static _reconstructDecisions(builder, compiledCollection) {
|
|
811
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
812
|
+
for (const compiledDecision of compiledCollection.decisions) {
|
|
813
|
+
// Get condition sets by their indices
|
|
814
|
+
const conditionSetResults = compiledDecision.conditionSets.map((idx) => builder._conditionSets.getAt(idx));
|
|
815
|
+
// Check for any failures
|
|
816
|
+
const failedIndex = conditionSetResults.findIndex((r) => r.isFailure());
|
|
817
|
+
if (failedIndex >= 0) {
|
|
818
|
+
conditionSetResults[failedIndex].aggregateError(errors);
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
// Get condition sets from successful results
|
|
822
|
+
const conditionSets = conditionSetResults.map((r) => r.orThrow());
|
|
823
|
+
// Create AbstractDecision from condition sets and add to collector
|
|
824
|
+
decisions_1.AbstractDecision.createAbstractDecision({ conditionSets })
|
|
825
|
+
.onSuccess((decision) => builder._decisions.getOrAdd(decision))
|
|
826
|
+
.aggregateError(errors);
|
|
827
|
+
}
|
|
828
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Reconstructs resources and their candidates from a compiled collection and adds them to the builder.
|
|
832
|
+
* @param builder - The builder to add resources to.
|
|
833
|
+
* @param compiledCollection - The compiled collection containing resources.
|
|
834
|
+
* @returns `Success` if all resources were added successfully, `Failure` otherwise.
|
|
835
|
+
* @internal
|
|
836
|
+
*/
|
|
837
|
+
static _reconstructResources(builder, compiledCollection) {
|
|
838
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
839
|
+
for (const compiledResource of compiledCollection.resources) {
|
|
840
|
+
// Get the resource type by index
|
|
841
|
+
const resourceTypeResult = builder.resourceTypes.getAt(compiledResource.type);
|
|
842
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
843
|
+
if (resourceTypeResult.isFailure()) {
|
|
844
|
+
resourceTypeResult.aggregateError(errors);
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
// Get the decision by index
|
|
848
|
+
const decisionResult = builder._decisions.getAt(compiledResource.decision);
|
|
849
|
+
/* c8 ignore next 4 - edge case or internal error (nearly?) impossible to reproduce */
|
|
850
|
+
if (decisionResult.isFailure()) {
|
|
851
|
+
decisionResult.aggregateError(errors);
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
const decision = decisionResult.value;
|
|
855
|
+
const resourceType = resourceTypeResult.value;
|
|
856
|
+
// Create candidates from the decision's condition sets
|
|
857
|
+
ResourceManagerBuilder._createCandidatesFromDecision(compiledResource, decision, resourceType, builder, compiledCollection.candidateValues).aggregateError(errors);
|
|
858
|
+
}
|
|
859
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Helper method to create candidates from a decision's condition sets.
|
|
863
|
+
* @param compiledResource - The compiled resource containing candidates.
|
|
864
|
+
* @param decision - The decision containing condition sets.
|
|
865
|
+
* @param resourceType - The resource type for the candidates.
|
|
866
|
+
* @param builder - The builder to add candidates to.
|
|
867
|
+
* @param candidateValues - Array of candidate values indexed by valueIndex.
|
|
868
|
+
* @returns `Success` if all candidates were added successfully, `Failure` otherwise.
|
|
869
|
+
* @internal
|
|
870
|
+
*/
|
|
871
|
+
static _createCandidatesFromDecision(compiledResource, decision, resourceType, builder, candidateValues) {
|
|
872
|
+
var _a;
|
|
873
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
874
|
+
// Match each candidate to its corresponding condition set
|
|
875
|
+
for (let i = 0; i < compiledResource.candidates.length; i++) {
|
|
876
|
+
const candidate = compiledResource.candidates[i];
|
|
877
|
+
// Build conditions from the corresponding condition set (if available)
|
|
878
|
+
let conditions;
|
|
879
|
+
if (i < decision.candidates.length) {
|
|
880
|
+
const decisionCandidate = decision.candidates[i];
|
|
881
|
+
conditions = {};
|
|
882
|
+
for (const condition of decisionCandidate.conditionSet.conditions) {
|
|
883
|
+
conditions[condition.qualifier.name] = condition.value;
|
|
884
|
+
}
|
|
885
|
+
/* c8 ignore next 3 - defense in depth */
|
|
886
|
+
if (Object.keys(conditions).length === 0) {
|
|
887
|
+
conditions = undefined;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
// Get json value from candidateValues array using valueIndex
|
|
891
|
+
/* c8 ignore next 1 - defense in depth */
|
|
892
|
+
const rawJson = (_a = candidateValues[candidate.valueIndex]) !== null && _a !== void 0 ? _a : {};
|
|
893
|
+
ts_json_base_1.Converters.jsonObject
|
|
894
|
+
.convert(rawJson)
|
|
895
|
+
.onSuccess((json) => {
|
|
896
|
+
const candidateDecl = {
|
|
897
|
+
id: compiledResource.id,
|
|
898
|
+
json,
|
|
899
|
+
conditions,
|
|
900
|
+
isPartial: candidate.isPartial,
|
|
901
|
+
mergeMethod: candidate.mergeMethod,
|
|
902
|
+
resourceTypeName: resourceType.key
|
|
903
|
+
};
|
|
904
|
+
return builder.addLooseCandidate(candidateDecl).aggregateError(errors);
|
|
905
|
+
})
|
|
906
|
+
.aggregateError(errors);
|
|
907
|
+
}
|
|
908
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(true));
|
|
909
|
+
}
|
|
449
910
|
}
|
|
450
911
|
exports.ResourceManagerBuilder = ResourceManagerBuilder;
|
|
451
912
|
//# sourceMappingURL=resourceManagerBuilder.js.map
|
|
@@ -31,6 +31,11 @@ export interface IResourceResolverCacheListener {
|
|
|
31
31
|
* @param index - The index of the cache that had an error.
|
|
32
32
|
*/
|
|
33
33
|
onCacheError(cache: ResourceResolverCacheType, index: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* Called when a context error occurs.
|
|
36
|
+
* @param error - The error that occurred.
|
|
37
|
+
*/
|
|
38
|
+
onContextError(qualifier: string, error: string): void;
|
|
34
39
|
/**
|
|
35
40
|
* Called when a cache is cleared.
|
|
36
41
|
* @param cache - The type of cache that was cleared.
|
|
@@ -54,6 +59,10 @@ export declare class NoOpResourceResolverCacheListener implements IResourceResol
|
|
|
54
59
|
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheError}
|
|
55
60
|
*/
|
|
56
61
|
onCacheError(cache: ResourceResolverCacheType, index: number): void;
|
|
62
|
+
/**
|
|
63
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onContextError}
|
|
64
|
+
*/
|
|
65
|
+
onContextError(qualifier: string, error: string): void;
|
|
57
66
|
/**
|
|
58
67
|
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheClear}
|
|
59
68
|
*/
|
|
@@ -45,6 +45,12 @@ class NoOpResourceResolverCacheListener {
|
|
|
45
45
|
onCacheError(cache, index) {
|
|
46
46
|
// no-op
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onContextError}
|
|
50
|
+
*/
|
|
51
|
+
onContextError(qualifier, error) {
|
|
52
|
+
// no-op
|
|
53
|
+
}
|
|
48
54
|
/**
|
|
49
55
|
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheClear}
|
|
50
56
|
*/
|
|
@@ -51,6 +51,8 @@ export type OverallCacheMetrics<TM extends ICacheMetrics = ICacheMetrics> = Reco
|
|
|
51
51
|
*/
|
|
52
52
|
export declare class ResourceResolverCacheMetricsListener<TM extends ICacheMetrics> implements IResourceResolverCacheListener {
|
|
53
53
|
private readonly _metrics;
|
|
54
|
+
private _contextErrors;
|
|
55
|
+
get numContextErrors(): number;
|
|
54
56
|
constructor(factory: () => TM);
|
|
55
57
|
constructor(metrics: OverallCacheMetrics<TM>);
|
|
56
58
|
/**
|
|
@@ -70,6 +72,10 @@ export declare class ResourceResolverCacheMetricsListener<TM extends ICacheMetri
|
|
|
70
72
|
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheError}
|
|
71
73
|
*/
|
|
72
74
|
onCacheError(cache: ResourceResolverCacheType, index: number): void;
|
|
75
|
+
/**
|
|
76
|
+
* {@inheritDoc Runtime.IResourceResolverCacheListener.onContextError}
|
|
77
|
+
*/
|
|
78
|
+
onContextError(qualifier: string, error: string): void;
|
|
73
79
|
/**
|
|
74
80
|
* {@inheritDoc Runtime.IResourceResolverCacheListener.onCacheClear}
|
|
75
81
|
*/
|