@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
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.DeltaGenerator = void 0;
|
|
25
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
+
const ts_json_base_1 = require("@fgv/ts-json-base");
|
|
27
|
+
const ts_json_1 = require("@fgv/ts-json");
|
|
28
|
+
/**
|
|
29
|
+
* Class for generating resource deltas between baseline and delta resolvers.
|
|
30
|
+
* Creates partial/augment candidates for updated resources and full/replace candidates for new resources.
|
|
31
|
+
* Uses Diff.jsonThreeWayDiff for efficient delta computation.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
class DeltaGenerator {
|
|
35
|
+
/**
|
|
36
|
+
* Constructor for a {@link Resources.DeltaGenerator | DeltaGenerator} object.
|
|
37
|
+
* @param params - Parameters to create a new {@link Resources.DeltaGenerator | DeltaGenerator}.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
constructor(params) {
|
|
41
|
+
var _a;
|
|
42
|
+
this._baselineResolver = params.baselineResolver;
|
|
43
|
+
this._deltaResolver = params.deltaResolver;
|
|
44
|
+
this._resourceManager = params.resourceManager;
|
|
45
|
+
this._logger = (_a = params.logger) !== null && _a !== void 0 ? _a : new ts_utils_1.Logging.NoOpLogger();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new {@link Resources.DeltaGenerator | DeltaGenerator} object.
|
|
49
|
+
* @param params - Parameters to create a new {@link Resources.DeltaGenerator | DeltaGenerator}.
|
|
50
|
+
* @returns `Success` with the new {@link Resources.DeltaGenerator | DeltaGenerator} object if successful,
|
|
51
|
+
* or `Failure` with an error message if not.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
static create(params) {
|
|
55
|
+
return (0, ts_utils_1.captureResult)(() => new DeltaGenerator(params));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Generates deltas between baseline and delta resolvers.
|
|
59
|
+
* Creates a cloned resource manager with partial/augment candidates for updates
|
|
60
|
+
* and full/replace candidates for new resources.
|
|
61
|
+
*
|
|
62
|
+
* @param options - Options controlling delta generation behavior.
|
|
63
|
+
* @returns `Success` with the updated resource manager if successful,
|
|
64
|
+
* or `Failure` with an error message if not.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
generate(options) {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
this._logger.info('Starting delta generation');
|
|
70
|
+
const context = (_a = options === null || options === void 0 ? void 0 : options.context) !== null && _a !== void 0 ? _a : {};
|
|
71
|
+
const skipUnchanged = (_b = options === null || options === void 0 ? void 0 : options.skipUnchanged) !== null && _b !== void 0 ? _b : true;
|
|
72
|
+
return this._validateContext(context)
|
|
73
|
+
.onSuccess((validatedContext) => this._enumerateTargetResources(options === null || options === void 0 ? void 0 : options.resourceIds, validatedContext))
|
|
74
|
+
.onSuccess((resourceIds) => {
|
|
75
|
+
return this._cloneResourceManager()
|
|
76
|
+
.onSuccess((clonedManager) => this._generateDeltas(clonedManager, resourceIds, context, skipUnchanged))
|
|
77
|
+
.onSuccess((manager) => {
|
|
78
|
+
this._logger.info(`Delta generation completed successfully with ${manager.size} resources`);
|
|
79
|
+
return (0, ts_utils_1.succeed)(manager);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Validates the provided context declaration.
|
|
85
|
+
* @param context - The context declaration to validate.
|
|
86
|
+
* @returns `Success` with the validated context if successful, `Failure` otherwise.
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
_validateContext(context) {
|
|
90
|
+
return this._resourceManager.validateContext(context);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Enumerates target resource IDs for delta generation.
|
|
94
|
+
* If specific resource IDs are provided, uses those. Otherwise, discovers all resources
|
|
95
|
+
* from both the baseline resource manager and the delta resolver to ensure comprehensive
|
|
96
|
+
* coverage of all potential resources.
|
|
97
|
+
*
|
|
98
|
+
* @param requestedIds - Optional array of specific resource IDs to target.
|
|
99
|
+
* @param context - The validated context to use for resource discovery.
|
|
100
|
+
* @returns `Success` with array of resource IDs if successful, `Failure` otherwise.
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
_enumerateTargetResources(requestedIds, context) {
|
|
104
|
+
if (requestedIds && requestedIds.length > 0) {
|
|
105
|
+
this._logger.info(`Using ${requestedIds.length} specified resource IDs`);
|
|
106
|
+
// Validate the requested IDs
|
|
107
|
+
const validatedIds = [];
|
|
108
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
109
|
+
for (const id of requestedIds) {
|
|
110
|
+
const validationResult = this._resourceManager.getBuiltResource(id);
|
|
111
|
+
if (validationResult.isSuccess()) {
|
|
112
|
+
validatedIds.push(id);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
errors.addMessage(`Invalid resource ID "${id}": ${validationResult.message}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (errors.hasMessages) {
|
|
119
|
+
return (0, ts_utils_1.fail)(errors.toString());
|
|
120
|
+
}
|
|
121
|
+
return (0, ts_utils_1.succeed)(validatedIds);
|
|
122
|
+
}
|
|
123
|
+
// Discover resources from both baseline and delta resolvers to ensure comprehensive coverage
|
|
124
|
+
this._logger.info('Discovering resources from both baseline and delta resolvers');
|
|
125
|
+
return this._discoverAllResourceIds().onSuccess((allResourceIds) => {
|
|
126
|
+
this._logger.info(`Discovered ${allResourceIds.length} unique resources across both resolvers`);
|
|
127
|
+
return (0, ts_utils_1.succeed)(allResourceIds);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Discovers all unique resource IDs from both baseline and delta resolvers.
|
|
132
|
+
* Creates a union of resource IDs from the baseline resource manager and delta resolver
|
|
133
|
+
* to ensure comprehensive coverage of all resources.
|
|
134
|
+
*
|
|
135
|
+
* @returns `Success` with array of unique resource IDs if successful, `Failure` otherwise.
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
_discoverAllResourceIds() {
|
|
139
|
+
// Get resource IDs from baseline resource manager
|
|
140
|
+
return this._resourceManager.getAllBuiltResources().onSuccess((baselineResources) => {
|
|
141
|
+
const baselineResourceIds = baselineResources.map((r) => r.id);
|
|
142
|
+
this._logger.detail(`Found ${baselineResourceIds.length} resources in baseline`);
|
|
143
|
+
// Get resource IDs from delta resolver using the public interface
|
|
144
|
+
const deltaResourceIds = this._deltaResolver.resourceIds;
|
|
145
|
+
this._logger.detail(`Found ${deltaResourceIds.length} resources in delta`);
|
|
146
|
+
// Create a union of resource IDs from both sources
|
|
147
|
+
const allResourceIds = new Set();
|
|
148
|
+
// Add baseline resource IDs
|
|
149
|
+
baselineResourceIds.forEach((id) => {
|
|
150
|
+
allResourceIds.add(id);
|
|
151
|
+
});
|
|
152
|
+
// Add delta resource IDs
|
|
153
|
+
deltaResourceIds.forEach((id) => {
|
|
154
|
+
allResourceIds.add(id);
|
|
155
|
+
});
|
|
156
|
+
const uniqueResourceIds = Array.from(allResourceIds);
|
|
157
|
+
this._logger.detail(`Created union of ${uniqueResourceIds.length} unique resource IDs`);
|
|
158
|
+
return (0, ts_utils_1.succeed)(uniqueResourceIds);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Creates a clone of the resource manager for delta operations.
|
|
163
|
+
* @returns `Success` with the cloned resource manager if successful, `Failure` otherwise.
|
|
164
|
+
* @internal
|
|
165
|
+
*/
|
|
166
|
+
_cloneResourceManager() {
|
|
167
|
+
this._logger.info('Cloning resource manager');
|
|
168
|
+
return this._resourceManager.clone();
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Generates deltas for the specified resources and adds them to the cloned manager.
|
|
172
|
+
*
|
|
173
|
+
* @param clonedManager - The cloned resource manager to update.
|
|
174
|
+
* @param resourceIds - Array of resource IDs to process.
|
|
175
|
+
* @param context - The context to use for resource resolution.
|
|
176
|
+
* @param skipUnchanged - Whether to skip resources that haven't changed.
|
|
177
|
+
* @returns `Success` with the updated manager if successful, `Failure` otherwise.
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
_generateDeltas(clonedManager, resourceIds, context, skipUnchanged) {
|
|
181
|
+
this._logger.info(`Generating deltas for ${resourceIds.length} resources`);
|
|
182
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
183
|
+
let processedCount = 0;
|
|
184
|
+
let changedCount = 0;
|
|
185
|
+
let newCount = 0;
|
|
186
|
+
let skippedCount = 0;
|
|
187
|
+
for (const resourceId of resourceIds) {
|
|
188
|
+
this._logger.detail(`Processing resource: ${resourceId}`);
|
|
189
|
+
const result = this._generateResourceDelta(clonedManager, resourceId, context, skipUnchanged);
|
|
190
|
+
if (result.isFailure()) {
|
|
191
|
+
errors.addMessage(`${resourceId}: ${result.message}`);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
processedCount++;
|
|
195
|
+
// Track statistics based on result
|
|
196
|
+
const deltaResult = result.value;
|
|
197
|
+
if (deltaResult.type === 'skipped') {
|
|
198
|
+
skippedCount++;
|
|
199
|
+
}
|
|
200
|
+
else if (deltaResult.type === 'new') {
|
|
201
|
+
newCount++;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
changedCount++;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
this._logger.info(`Processed ${processedCount} resources: ${changedCount} updated, ${newCount} new, ${skippedCount} skipped`);
|
|
208
|
+
if (errors.hasMessages) {
|
|
209
|
+
return (0, ts_utils_1.fail)(`Delta generation failed with errors:\n${errors.toString()}`);
|
|
210
|
+
}
|
|
211
|
+
return (0, ts_utils_1.succeed)(clonedManager);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Generates a delta for a single resource and adds appropriate candidates to the manager.
|
|
215
|
+
*
|
|
216
|
+
* @param manager - The resource manager to update.
|
|
217
|
+
* @param resourceId - The resource ID to process.
|
|
218
|
+
* @param context - The context to use for resource resolution.
|
|
219
|
+
* @param skipUnchanged - Whether to skip resources that haven't changed.
|
|
220
|
+
* @returns `Success` with the resource delta result if successful, `Failure` otherwise.
|
|
221
|
+
* @internal
|
|
222
|
+
*/
|
|
223
|
+
_generateResourceDelta(manager, resourceId, context, skipUnchanged) {
|
|
224
|
+
// Resolve values from both resolvers
|
|
225
|
+
const baselineResult = this._baselineResolver.resolveComposedResourceValue(resourceId);
|
|
226
|
+
const deltaResult = this._deltaResolver.resolveComposedResourceValue(resourceId);
|
|
227
|
+
const baselineExists = baselineResult.isSuccess();
|
|
228
|
+
const deltaExists = deltaResult.isSuccess();
|
|
229
|
+
if (deltaExists && !baselineExists) {
|
|
230
|
+
// New resource - exists in delta but not in baseline
|
|
231
|
+
this._logger.detail(`${resourceId}: New resource detected (exists in delta only)`);
|
|
232
|
+
return this._createNewResourceCandidate(manager, resourceId, deltaResult.value, context).onSuccess(() => (0, ts_utils_1.succeed)({ type: 'new', resourceId }));
|
|
233
|
+
}
|
|
234
|
+
if (baselineExists && !deltaExists) {
|
|
235
|
+
// Baseline-only resource - exists in baseline but not in delta (potential deletion)
|
|
236
|
+
// For now, skip these resources since delete merge method is not yet implemented
|
|
237
|
+
// TODO: When 'delete' merge method is available, create deletion candidates here
|
|
238
|
+
this._logger.detail(`${resourceId}: Baseline-only resource detected, skipping (delete merge method not yet implemented)`);
|
|
239
|
+
return (0, ts_utils_1.succeed)({ type: 'skipped', resourceId });
|
|
240
|
+
}
|
|
241
|
+
if (!baselineExists && !deltaExists) {
|
|
242
|
+
// Resource doesn't exist in either resolver - this shouldn't happen due to enumeration logic
|
|
243
|
+
return (0, ts_utils_1.fail)(`Resource ${resourceId} not found in either baseline or delta resolvers`);
|
|
244
|
+
}
|
|
245
|
+
// Both resolvers have the resource - check for changes
|
|
246
|
+
// At this point, both results are successful so values are guaranteed to exist
|
|
247
|
+
const baselineValue = baselineResult.value; // Safe: baselineExists is true
|
|
248
|
+
const deltaValue = deltaResult.value; // Safe: deltaExists is true
|
|
249
|
+
// Check if values are identical
|
|
250
|
+
if (skipUnchanged && this._areValuesIdentical(baselineValue, deltaValue)) {
|
|
251
|
+
this._logger.detail(`${resourceId}: No changes detected, skipping`);
|
|
252
|
+
return (0, ts_utils_1.succeed)({ type: 'skipped', resourceId });
|
|
253
|
+
}
|
|
254
|
+
// Updated resource - compute delta and create partial/augment candidate
|
|
255
|
+
this._logger.detail(`${resourceId}: Changes detected, computing delta`);
|
|
256
|
+
return this._createDeltaCandidate(manager, resourceId, baselineValue, deltaValue, context).onSuccess(() => (0, ts_utils_1.succeed)({ type: 'updated', resourceId }));
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Checks if two JSON values are identical.
|
|
260
|
+
* @param value1 - First value to compare.
|
|
261
|
+
* @param value2 - Second value to compare.
|
|
262
|
+
* @returns True if values are identical, false otherwise.
|
|
263
|
+
* @internal
|
|
264
|
+
*/
|
|
265
|
+
_areValuesIdentical(value1, value2) {
|
|
266
|
+
return JSON.stringify(value1) === JSON.stringify(value2);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Creates a new resource candidate for a newly discovered resource.
|
|
270
|
+
* Uses full/replace merge method since this is a completely new resource.
|
|
271
|
+
*
|
|
272
|
+
* @param manager - The resource manager to update.
|
|
273
|
+
* @param resourceId - The resource ID for the new resource.
|
|
274
|
+
* @param value - The resolved value for the new resource.
|
|
275
|
+
* @param context - The context used for resolution.
|
|
276
|
+
* @returns `Success` if the candidate was added successfully, `Failure` otherwise.
|
|
277
|
+
* @internal
|
|
278
|
+
*/
|
|
279
|
+
_createNewResourceCandidate(manager, resourceId, value, context) {
|
|
280
|
+
if (!(0, ts_json_base_1.isJsonObject)(value)) {
|
|
281
|
+
return (0, ts_utils_1.fail)(`Resource value must be a JSON object, got ${typeof value}`);
|
|
282
|
+
}
|
|
283
|
+
const candidateDecl = {
|
|
284
|
+
id: resourceId,
|
|
285
|
+
json: value,
|
|
286
|
+
conditions: Object.keys(context).length > 0 ? context : undefined,
|
|
287
|
+
isPartial: false,
|
|
288
|
+
mergeMethod: 'replace',
|
|
289
|
+
resourceTypeName: 'json' // Use 'json' resource type for new JSON resources
|
|
290
|
+
};
|
|
291
|
+
const result = manager.addLooseCandidate(candidateDecl);
|
|
292
|
+
if (result.isFailure()) {
|
|
293
|
+
return (0, ts_utils_1.fail)(result.message);
|
|
294
|
+
}
|
|
295
|
+
return (0, ts_utils_1.succeed)(undefined);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Creates a delta candidate for an updated resource.
|
|
299
|
+
* Computes the difference between baseline and delta values and creates
|
|
300
|
+
* a partial/augment candidate with only the changed properties.
|
|
301
|
+
*
|
|
302
|
+
* @param manager - The resource manager to update.
|
|
303
|
+
* @param resourceId - The resource ID for the updated resource.
|
|
304
|
+
* @param baselineValue - The baseline resolved value.
|
|
305
|
+
* @param deltaValue - The delta resolved value.
|
|
306
|
+
* @param context - The context used for resolution.
|
|
307
|
+
* @returns `Success` if the candidate was added successfully, `Failure` otherwise.
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
_createDeltaCandidate(manager, resourceId, baselineValue, deltaValue, context) {
|
|
311
|
+
// Compute three-way diff to get only the changed properties
|
|
312
|
+
return ts_json_1.Diff.jsonThreeWayDiff(baselineValue, deltaValue).onSuccess((diff) => {
|
|
313
|
+
if (diff.identical) {
|
|
314
|
+
// This shouldn't happen if we checked for identity earlier, but be defensive
|
|
315
|
+
this._logger.warn(`${resourceId}: Diff reports identical values, skipping`);
|
|
316
|
+
return (0, ts_utils_1.succeed)(undefined);
|
|
317
|
+
}
|
|
318
|
+
// Use onlyInB (second object) which contains new/changed properties
|
|
319
|
+
const deltaChanges = diff.onlyInB;
|
|
320
|
+
if (!(0, ts_json_base_1.isJsonObject)(deltaChanges)) {
|
|
321
|
+
return (0, ts_utils_1.fail)(`Delta changes must be a JSON object, got ${typeof deltaChanges}`);
|
|
322
|
+
}
|
|
323
|
+
// TODO: Handle deletions using 'augment' merge method with null values
|
|
324
|
+
// Note: The 'delete' merge type is not yet implemented in ts-res, so we use 'augment'
|
|
325
|
+
// with null values for deletion semantics (as used in ts-res-ui-components).
|
|
326
|
+
// When the 'delete' merge type is available, this should be updated to use it.
|
|
327
|
+
const candidateDecl = {
|
|
328
|
+
id: resourceId,
|
|
329
|
+
json: deltaChanges,
|
|
330
|
+
conditions: Object.keys(context).length > 0 ? context : undefined,
|
|
331
|
+
isPartial: true,
|
|
332
|
+
mergeMethod: 'augment',
|
|
333
|
+
resourceTypeName: undefined // Will be inferred by the manager
|
|
334
|
+
};
|
|
335
|
+
const result = manager.addLooseCandidate(candidateDecl);
|
|
336
|
+
if (result.isFailure()) {
|
|
337
|
+
return (0, ts_utils_1.fail)(result.message);
|
|
338
|
+
}
|
|
339
|
+
return (0, ts_utils_1.succeed)(undefined);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
exports.DeltaGenerator = DeltaGenerator;
|
|
344
|
+
//# sourceMappingURL=deltaGenerator.js.map
|
|
@@ -36,6 +36,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
__exportStar(require("./candidateReducer"), exports);
|
|
39
|
+
__exportStar(require("./candidateValue"), exports);
|
|
40
|
+
__exportStar(require("./candidateValueCollector"), exports);
|
|
41
|
+
__exportStar(require("./deltaGenerator"), exports);
|
|
39
42
|
__exportStar(require("./resourceCandidate"), exports);
|
|
40
43
|
__exportStar(require("./resource"), exports);
|
|
41
44
|
__exportStar(require("./resourceBuilder"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from '@fgv/ts-utils';
|
|
2
|
-
import { ResourceId } from '../common';
|
|
2
|
+
import { ResourceId, ResourceName } from '../common';
|
|
3
3
|
import { ResourceCandidate } from './resourceCandidate';
|
|
4
4
|
import { ResourceType } from '../resource-types';
|
|
5
5
|
import { ConcreteDecision, AbstractDecisionCollector } from '../decisions';
|
|
@@ -40,10 +40,14 @@ export declare class Resource implements IResource {
|
|
|
40
40
|
* The unique {@link ResourceId | id} of the resource.
|
|
41
41
|
*/
|
|
42
42
|
readonly id: ResourceId;
|
|
43
|
+
/**
|
|
44
|
+
* The name of the resource.
|
|
45
|
+
*/
|
|
46
|
+
readonly name: ResourceName;
|
|
43
47
|
/**
|
|
44
48
|
* The {@link ResourceTypes.ResourceType | type} of the resource.
|
|
45
49
|
*/
|
|
46
|
-
readonly
|
|
50
|
+
readonly resourceType: ResourceType;
|
|
47
51
|
/**
|
|
48
52
|
* The array of {@link Resources.ResourceCandidate | candidates} for the resource.
|
|
49
53
|
*/
|
|
@@ -52,10 +56,6 @@ export declare class Resource implements IResource {
|
|
|
52
56
|
* {@link Decisions.ConcreteDecision | Decision} for optimized resource resolution.
|
|
53
57
|
*/
|
|
54
58
|
readonly decision: ConcreteDecision;
|
|
55
|
-
/**
|
|
56
|
-
* Gets the resource type (implements IResource interface).
|
|
57
|
-
*/
|
|
58
|
-
get resourceType(): ResourceType;
|
|
59
59
|
/**
|
|
60
60
|
* Gets the resource type name as a string.
|
|
61
61
|
*/
|
|
@@ -33,17 +33,11 @@ const decisions_1 = require("../decisions");
|
|
|
33
33
|
* @public
|
|
34
34
|
*/
|
|
35
35
|
class Resource {
|
|
36
|
-
/**
|
|
37
|
-
* Gets the resource type (implements IResource interface).
|
|
38
|
-
*/
|
|
39
|
-
get resourceType() {
|
|
40
|
-
return this._resourceType;
|
|
41
|
-
}
|
|
42
36
|
/**
|
|
43
37
|
* Gets the resource type name as a string.
|
|
44
38
|
*/
|
|
45
39
|
get resourceTypeName() {
|
|
46
|
-
return this.
|
|
40
|
+
return this.resourceType.key;
|
|
47
41
|
}
|
|
48
42
|
/**
|
|
49
43
|
* Constructor for a {@link Resources.Resource | Resource} object.
|
|
@@ -53,7 +47,8 @@ class Resource {
|
|
|
53
47
|
constructor(params) {
|
|
54
48
|
const id = params.id ? common_1.Validate.toResourceId(params.id).orThrow() : undefined;
|
|
55
49
|
this.id = Resource._validateCandidateResourceIds(id, params.candidates).orThrow();
|
|
56
|
-
this.
|
|
50
|
+
this.name = common_1.Helpers.getNameForResourceId(this.id).orThrow();
|
|
51
|
+
this.resourceType = resourceCandidate_1.ResourceCandidate.validateResourceTypes(params.candidates, params.resourceType)
|
|
57
52
|
.onSuccess((t) => {
|
|
58
53
|
/* c8 ignore next 3 - functional code path tested but coverage intermittently missed */
|
|
59
54
|
if (t === undefined) {
|
|
@@ -120,9 +115,9 @@ class Resource {
|
|
|
120
115
|
*/
|
|
121
116
|
toCompiled(options) {
|
|
122
117
|
const candidates = this._getMatchingCandidates(options).map((c) => ({
|
|
123
|
-
json: c.json,
|
|
124
118
|
isPartial: c.isPartial,
|
|
125
|
-
mergeMethod: c.mergeMethod
|
|
119
|
+
mergeMethod: c.mergeMethod,
|
|
120
|
+
valueIndex: c.candidateValue.index
|
|
126
121
|
}));
|
|
127
122
|
return {
|
|
128
123
|
id: this.id,
|
|
@@ -5,6 +5,7 @@ import { ReadOnlyResourceTypeCollector, ResourceType } from '../resource-types';
|
|
|
5
5
|
import { Resource } from './resource';
|
|
6
6
|
import { ConditionSetCollector } from '../conditions';
|
|
7
7
|
import { AbstractDecisionCollector } from '../decisions';
|
|
8
|
+
import { CandidateValueCollector } from './candidateValueCollector';
|
|
8
9
|
import * as ResourceJson from '../resource-json';
|
|
9
10
|
import * as Context from '../context';
|
|
10
11
|
/**
|
|
@@ -17,6 +18,7 @@ export interface IResourceBuilderCreateParams {
|
|
|
17
18
|
conditionSets: ConditionSetCollector;
|
|
18
19
|
resourceTypes: ReadOnlyResourceTypeCollector;
|
|
19
20
|
decisions: AbstractDecisionCollector;
|
|
21
|
+
candidateValues: CandidateValueCollector;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Possible result details returned by the resource builder
|
|
@@ -66,6 +68,10 @@ export declare class ResourceBuilder {
|
|
|
66
68
|
* Collector for {@link Decisions.AbstractDecision | abstract decisions}.
|
|
67
69
|
*/
|
|
68
70
|
protected _decisions: AbstractDecisionCollector;
|
|
71
|
+
/**
|
|
72
|
+
* Collector for candidate values.
|
|
73
|
+
*/
|
|
74
|
+
protected _candidateValues: CandidateValueCollector;
|
|
69
75
|
/**
|
|
70
76
|
* Constructor for a {@link Resources.ResourceBuilder | ResourceBuilder} object.
|
|
71
77
|
* @param params - Parameters to construct the new {@link Resources.ResourceBuilder | ResourceBuilder}.
|
|
@@ -56,6 +56,7 @@ class ResourceBuilder {
|
|
|
56
56
|
this._resourceTypes = params.resourceTypes;
|
|
57
57
|
this._conditionSets = params.conditionSets;
|
|
58
58
|
this._decisions = params.decisions;
|
|
59
|
+
this._candidateValues = params.candidateValues;
|
|
59
60
|
this._candidates = new ts_utils_1.ResultMap();
|
|
60
61
|
if (params.typeName) {
|
|
61
62
|
this._resourceType = this._resourceTypes.validating.get(params.typeName).orThrow();
|
|
@@ -93,7 +94,8 @@ class ResourceBuilder {
|
|
|
93
94
|
id: this.id,
|
|
94
95
|
resourceType: this._resourceType,
|
|
95
96
|
decl: childDecl,
|
|
96
|
-
conditionSets: this._conditionSets
|
|
97
|
+
conditionSets: this._conditionSets,
|
|
98
|
+
candidateValues: this._candidateValues
|
|
97
99
|
})
|
|
98
100
|
.withDetail('failure', 'success')
|
|
99
101
|
.onSuccess((candidate) => {
|
|
@@ -101,6 +103,7 @@ class ResourceBuilder {
|
|
|
101
103
|
.getOrAdd(candidate.conditions.toString(), candidate)
|
|
102
104
|
.onSuccess((added, detail) => {
|
|
103
105
|
if (detail === 'exists') {
|
|
106
|
+
/* c8 ignore next 5 - defensive coding: conflicting candidates with same conditions should not occur */
|
|
104
107
|
if (!resourceCandidate_1.ResourceCandidate.equal(added, candidate)) {
|
|
105
108
|
return (0, ts_utils_1.failWithDetail)(`${this.id}: conflicting candidates.`, 'exists');
|
|
106
109
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { JsonObject } from '@fgv/ts-json-base';
|
|
2
|
-
import { QualifierName, ResourceId, ResourceValueMergeMethod } from '../common';
|
|
2
|
+
import { CandidateCompleteness, QualifierName, ResourceId, ResourceValueMergeMethod } from '../common';
|
|
3
3
|
import { Condition, ConditionSet, ConditionSetCollector } from '../conditions';
|
|
4
4
|
import * as ResourceJson from '../resource-json';
|
|
5
5
|
import { ResourceType } from '../resource-types';
|
|
6
|
+
import { CandidateValue } from './candidateValue';
|
|
7
|
+
import { CandidateValueCollector } from './candidateValueCollector';
|
|
6
8
|
import { Result } from '@fgv/ts-utils';
|
|
7
9
|
import * as Context from '../context';
|
|
8
10
|
import { IResourceCandidate } from '../runtime';
|
|
@@ -16,6 +18,7 @@ export interface IResourceCandidateCreateParams {
|
|
|
16
18
|
resourceType?: ResourceType;
|
|
17
19
|
parentConditions?: ReadonlyArray<Condition>;
|
|
18
20
|
conditionSets: ConditionSetCollector;
|
|
21
|
+
candidateValues: CandidateValueCollector;
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
24
|
* Options for creating a {@link Resources.ResourceCandidate | ResourceCandidate} declaration.
|
|
@@ -43,10 +46,16 @@ export declare class ResourceCandidate implements IResourceCandidate {
|
|
|
43
46
|
* is a possible instance.
|
|
44
47
|
*/
|
|
45
48
|
readonly id: ResourceId;
|
|
49
|
+
/**
|
|
50
|
+
* The candidate value that contains the JSON representation of the instance data.
|
|
51
|
+
*/
|
|
52
|
+
readonly candidateValue: CandidateValue;
|
|
46
53
|
/**
|
|
47
54
|
* The JSON representation of the instance data to be applied.
|
|
55
|
+
* @remarks
|
|
56
|
+
* This property provides access to the JSON data from the underlying candidate value.
|
|
48
57
|
*/
|
|
49
|
-
|
|
58
|
+
get json(): JsonObject;
|
|
50
59
|
/**
|
|
51
60
|
* The conditions under which this candidate applies.
|
|
52
61
|
*/
|
|
@@ -64,6 +73,10 @@ export declare class ResourceCandidate implements IResourceCandidate {
|
|
|
64
73
|
* this candidate belongs.
|
|
65
74
|
*/
|
|
66
75
|
readonly resourceType: ResourceType | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The completeness of the candidate value.
|
|
78
|
+
*/
|
|
79
|
+
get completeness(): CandidateCompleteness;
|
|
67
80
|
/**
|
|
68
81
|
* Constructor for a {@link Resources.ResourceCandidate | ResourceCandidate} object.
|
|
69
82
|
* @param params - Parameters to create a new {@link Resources.ResourceCandidate | ResourceCandidate}.
|
|
@@ -66,6 +66,20 @@ const ts_utils_1 = require("@fgv/ts-utils");
|
|
|
66
66
|
* @public
|
|
67
67
|
*/
|
|
68
68
|
class ResourceCandidate {
|
|
69
|
+
/**
|
|
70
|
+
* The JSON representation of the instance data to be applied.
|
|
71
|
+
* @remarks
|
|
72
|
+
* This property provides access to the JSON data from the underlying candidate value.
|
|
73
|
+
*/
|
|
74
|
+
get json() {
|
|
75
|
+
return this.candidateValue.json;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The completeness of the candidate value.
|
|
79
|
+
*/
|
|
80
|
+
get completeness() {
|
|
81
|
+
return this.isPartial ? 'partial' : 'full';
|
|
82
|
+
}
|
|
69
83
|
/**
|
|
70
84
|
* Constructor for a {@link Resources.ResourceCandidate | ResourceCandidate} object.
|
|
71
85
|
* @param params - Parameters to create a new {@link Resources.ResourceCandidate | ResourceCandidate}.
|
|
@@ -74,7 +88,7 @@ class ResourceCandidate {
|
|
|
74
88
|
constructor(params) {
|
|
75
89
|
var _a, _b;
|
|
76
90
|
this.id = common_1.Validate.toResourceId(params.id).orThrow();
|
|
77
|
-
this.
|
|
91
|
+
this.candidateValue = params.candidateValues.validating.getOrAdd(params.decl.json).orThrow();
|
|
78
92
|
this.conditions = ResourceCandidate._mergeConditions(params.conditionSets, params.decl.conditions, params.parentConditions).orThrow();
|
|
79
93
|
this.isPartial = (_a = params.decl.isPartial) !== null && _a !== void 0 ? _a : false;
|
|
80
94
|
this.mergeMethod = (_b = params.decl.mergeMethod) !== null && _b !== void 0 ? _b : 'augment';
|
|
@@ -175,10 +189,8 @@ class ResourceCandidate {
|
|
|
175
189
|
rc1.mergeMethod === rc2.mergeMethod &&
|
|
176
190
|
conditions_1.ConditionSet.compare(rc1.conditions, rc2.conditions) === 0;
|
|
177
191
|
if (equal) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const n2 = normalizer.computeHash(rc2.json).orDefault('(n2 normalization failed)');
|
|
181
|
-
equal = n1 === n2;
|
|
192
|
+
// Compare candidate values by their keys for efficient JSON comparison
|
|
193
|
+
equal = rc1.candidateValue.key === rc2.candidateValue.key;
|
|
182
194
|
}
|
|
183
195
|
return equal;
|
|
184
196
|
}
|