@fgv/ts-res 5.0.0-3 → 5.0.0-31
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 +2671 -355
- 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 +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 +48 -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 +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/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 +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 +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 +189 -11
- package/lib/packlets/resources/resourceManagerBuilder.js +481 -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 +65 -28
- package/lib/packlets/runtime/conditionSetResolutionResult.js +3 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.d.ts +53 -3
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts +82 -37
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.js +49 -77
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +23 -2
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +53 -31
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +4 -4
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +2 -2
- package/lib/packlets/runtime/iResourceManager.d.ts +13 -5
- package/lib/packlets/runtime/index.d.ts +1 -0
- package/lib/packlets/runtime/index.js +1 -0
- package/lib/packlets/runtime/resource-tree/common.d.ts +1 -1
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts +7 -7
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js +5 -5
- package/lib/packlets/runtime/resourceResolver.d.ts +60 -1
- package/lib/packlets/runtime/resourceResolver.js +89 -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 +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 +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
|
@@ -37,8 +37,12 @@ class JsonResourceType extends resourceType_1.ResourceType {
|
|
|
37
37
|
* @param key - The key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
|
|
38
38
|
* @param index - Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
|
|
39
39
|
*/
|
|
40
|
-
constructor(key, index) {
|
|
41
|
-
super(key, index);
|
|
40
|
+
constructor(key, index, template) {
|
|
41
|
+
super(key, index, template);
|
|
42
|
+
/**
|
|
43
|
+
* {@inheritdoc ResourceTypes.ResourceType.systemTypeName}
|
|
44
|
+
*/
|
|
45
|
+
this.systemTypeName = common_1.Convert.resourceTypeName.convert('json').orThrow();
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
|
|
@@ -49,7 +53,7 @@ class JsonResourceType extends resourceType_1.ResourceType {
|
|
|
49
53
|
static create(params) {
|
|
50
54
|
var _a;
|
|
51
55
|
return common_1.Convert.resourceTypeName.convert((_a = params === null || params === void 0 ? void 0 : params.key) !== null && _a !== void 0 ? _a : 'json').onSuccess((key) => {
|
|
52
|
-
return (0, ts_utils_1.captureResult)(() => new JsonResourceType(key, params === null || params === void 0 ? void 0 : params.index));
|
|
56
|
+
return (0, ts_utils_1.captureResult)(() => new JsonResourceType(key, params === null || params === void 0 ? void 0 : params.index, params === null || params === void 0 ? void 0 : params.template));
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
@@ -58,7 +62,7 @@ class JsonResourceType extends resourceType_1.ResourceType {
|
|
|
58
62
|
validateDeclaration(props) {
|
|
59
63
|
return ts_json_base_1.Converters.jsonObject.convert(props.json);
|
|
60
64
|
}
|
|
61
|
-
validate(json,
|
|
65
|
+
validate(json, __completeness) {
|
|
62
66
|
return ts_json_base_1.Converters.jsonObject.convert(json);
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { JsonValue } from '@fgv/ts-json-base';
|
|
1
|
+
import { JsonObject, JsonValue } from '@fgv/ts-json-base';
|
|
2
2
|
import { ICollectible, Result } from '@fgv/ts-utils';
|
|
3
|
-
import { ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod, ResourceId } from '../common';
|
|
3
|
+
import { CandidateCompleteness, ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod, ResourceId, IResourceResolver } from '../common';
|
|
4
|
+
import * as ResourceJson from '../resource-json';
|
|
4
5
|
/**
|
|
5
6
|
* Parameters used to validate a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}.
|
|
6
7
|
* @public
|
|
@@ -12,10 +13,10 @@ export interface IResourceCandidateValidationProperties {
|
|
|
12
13
|
*/
|
|
13
14
|
id: ResourceId;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Describes how complete the candidate value is.
|
|
16
17
|
* @public
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
completeness: CandidateCompleteness;
|
|
19
20
|
/**
|
|
20
21
|
* {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.json}
|
|
21
22
|
* @public
|
|
@@ -27,23 +28,95 @@ export interface IResourceCandidateValidationProperties {
|
|
|
27
28
|
*/
|
|
28
29
|
mergeMethod: ResourceValueMergeMethod;
|
|
29
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Interface for a resource type. Resource types are responsible for
|
|
33
|
+
* validating and converting JSON values into the appropriate strongly-typed
|
|
34
|
+
* resource value.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export interface IResourceType<T = unknown> extends ICollectible<ResourceTypeName, ResourceTypeIndex> {
|
|
38
|
+
/**
|
|
39
|
+
* The key for this resource type.
|
|
40
|
+
*/
|
|
41
|
+
readonly key: ResourceTypeName;
|
|
42
|
+
/**
|
|
43
|
+
* The index for this resource type.
|
|
44
|
+
*/
|
|
45
|
+
readonly index: ResourceTypeIndex | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
|
|
48
|
+
* a resource instance value.
|
|
49
|
+
* @param props - The {@link ResourceTypes.IResourceCandidateValidationProperties | properties } to validate.
|
|
50
|
+
* @returns `Success` with the strongly-typed resource value if the JSON and merge method
|
|
51
|
+
* are valid, `Failure` with an error message otherwise.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
validateDeclaration(props: IResourceCandidateValidationProperties): Result<T | Partial<T>>;
|
|
55
|
+
/**
|
|
56
|
+
* Validates a JSON value for use as a partial resource instance value.
|
|
57
|
+
* @param json - The JSON value to validate.
|
|
58
|
+
* @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
|
|
59
|
+
* @returns `Success` with the strongly-typed partial resource value if the JSON is valid,
|
|
60
|
+
* `Failure` with an error message otherwise.
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
validate(json: JsonValue, completeness: CandidateCompleteness): Result<Partial<T>>;
|
|
64
|
+
/**
|
|
65
|
+
* Validates a JSON value for use as a complete resource instance value.
|
|
66
|
+
* @param json - The JSON value to validate.
|
|
67
|
+
* @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
|
|
68
|
+
* @returns `Success` with the strongly-typed resource value if the JSON is valid,
|
|
69
|
+
* `Failure` with an error message otherwise.
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
validate(json: JsonValue, completeness: 'full'): Result<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Validates a JSON value for use as a partial resource instance value.
|
|
75
|
+
* @param json - The JSON value to validate.
|
|
76
|
+
* @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
|
|
77
|
+
* @returns `Success` with the strongly-typed partial resource value if the JSON is valid,
|
|
78
|
+
* `Failure` with an error message otherwise.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
validate(json: JsonValue, completeness: 'partial'): Result<Partial<T>>;
|
|
82
|
+
/**
|
|
83
|
+
* Sets the index for this resource type. Once set, the index cannot be changed.
|
|
84
|
+
*/
|
|
85
|
+
setIndex(index: number): Result<ResourceTypeIndex>;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a template for a new resource of this type.
|
|
88
|
+
* The template provides a default structure for creating new resource instances.
|
|
89
|
+
* @param resourceId - The id for the new resource.
|
|
90
|
+
* @param init - An optional initial value for the resource.
|
|
91
|
+
* @param resolver - An optional resource resolver that can be used to create the template.
|
|
92
|
+
* @param conditions - An optional set of conditions that must be met for the resource to be selected.
|
|
93
|
+
* @returns A loose resource declaration with default values for this resource type.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
createTemplate(resourceId: ResourceId, init?: JsonValue, conditions?: ResourceJson.Json.ConditionSetDecl, resolver?: IResourceResolver): Result<ResourceJson.Json.ILooseResourceDecl>;
|
|
97
|
+
}
|
|
30
98
|
/**
|
|
31
99
|
* Abstract base class for resource types which are responsible for
|
|
32
100
|
* validating and converting JSON values into the appropriate strongly-typed
|
|
33
101
|
* resource value.
|
|
34
102
|
* @public
|
|
35
103
|
*/
|
|
36
|
-
export declare abstract class ResourceType<T = unknown> implements
|
|
104
|
+
export declare abstract class ResourceType<T = unknown> implements IResourceType<T> {
|
|
37
105
|
private _collectible;
|
|
106
|
+
private _template;
|
|
38
107
|
/**
|
|
39
|
-
*
|
|
108
|
+
* {@inheritdoc ResourceTypes.IResourceType.key}
|
|
40
109
|
*/
|
|
41
110
|
get key(): ResourceTypeName;
|
|
42
111
|
/**
|
|
43
|
-
*
|
|
112
|
+
* Name of the underlying system type.
|
|
113
|
+
*/
|
|
114
|
+
abstract readonly systemTypeName: ResourceTypeName;
|
|
115
|
+
/**
|
|
116
|
+
* {@inheritdoc ResourceTypes.IResourceType.index}
|
|
44
117
|
*/
|
|
45
118
|
get index(): ResourceTypeIndex | undefined;
|
|
46
|
-
protected constructor(key: ResourceTypeName, index?: number);
|
|
119
|
+
protected constructor(key: ResourceTypeName, index?: number, template?: JsonObject);
|
|
47
120
|
/**
|
|
48
121
|
* Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
|
|
49
122
|
* a resource instance value.
|
|
@@ -56,33 +129,61 @@ export declare abstract class ResourceType<T = unknown> implements ICollectible<
|
|
|
56
129
|
/**
|
|
57
130
|
* Validates a JSON value for use as a partial resource instance value.
|
|
58
131
|
* @param json - The JSON value to validate.
|
|
59
|
-
* @param
|
|
132
|
+
* @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
|
|
60
133
|
* @returns `Success` with the strongly-typed partial resource value if the JSON is valid,
|
|
61
134
|
* `Failure` with an error message otherwise.
|
|
62
135
|
* @public
|
|
63
136
|
*/
|
|
64
|
-
abstract validate(json: JsonValue,
|
|
137
|
+
abstract validate(json: JsonValue, completeness: CandidateCompleteness): Result<Partial<T>>;
|
|
65
138
|
/**
|
|
66
139
|
* Validates a JSON value for use as a complete resource instance value.
|
|
67
140
|
* @param json - The JSON value to validate.
|
|
68
|
-
* @param
|
|
141
|
+
* @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
|
|
69
142
|
* @returns `Success` with the strongly-typed resource value if the JSON is valid,
|
|
70
143
|
* `Failure` with an error message otherwise.
|
|
71
144
|
* @public
|
|
72
145
|
*/
|
|
73
|
-
abstract validate(json: JsonValue,
|
|
146
|
+
abstract validate(json: JsonValue, completeness: 'full'): Result<T>;
|
|
147
|
+
/**
|
|
148
|
+
* Validates a JSON value for use as a partial resource instance value.
|
|
149
|
+
* @param json - The JSON value to validate.
|
|
150
|
+
* @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
|
|
151
|
+
* @returns `Success` with the strongly-typed partial resource value if the JSON is valid,
|
|
152
|
+
* `Failure` with an error message otherwise.
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
abstract validate(json: JsonValue, completeness: 'partial'): Result<Partial<T>>;
|
|
74
156
|
/**
|
|
75
157
|
* Validates a JSON value for use as a full or partial resource instance value.
|
|
76
158
|
* @param json - The JSON value to validate.
|
|
77
|
-
* @param
|
|
159
|
+
* @param completeness - Describes {@link CandidateCompleteness | how complete} the candidate value is.
|
|
78
160
|
* @returns `Success` with the strongly-typed full or partial resource value if
|
|
79
161
|
* the JSON is valid, `Failure` with an error message otherwise.
|
|
80
162
|
* @public
|
|
81
163
|
*/
|
|
82
|
-
abstract validate(json: JsonValue,
|
|
164
|
+
abstract validate(json: JsonValue, completeness?: CandidateCompleteness): Result<T | Partial<T>>;
|
|
83
165
|
/**
|
|
84
166
|
* Sets the index for this resource type. Once set, the index cannot be changed.
|
|
85
167
|
*/
|
|
86
168
|
setIndex(index: number): Result<ResourceTypeIndex>;
|
|
169
|
+
/**
|
|
170
|
+
* Creates a template for a new resource of this type.
|
|
171
|
+
* Default implementation provides a basic template.
|
|
172
|
+
* Subclasses can override to provide type-specific templates.
|
|
173
|
+
* @param resourceId - The id for the new resource
|
|
174
|
+
* @param init - An optional initial value for the resource.
|
|
175
|
+
* @param conditions - An optional set of conditions that must be met for the resource to be selected.
|
|
176
|
+
* @param resolver - An optional resource resolver that can be used to create the template.
|
|
177
|
+
* @returns A loose resource declaration with default values for this resource type
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
createTemplate(resourceId: ResourceId, init?: JsonValue, conditions?: ResourceJson.Json.ConditionSetDecl, resolver?: IResourceResolver): Result<ResourceJson.Json.ILooseResourceDecl>;
|
|
181
|
+
/**
|
|
182
|
+
* Gets the default template value for this resource type.
|
|
183
|
+
* Subclasses should override this to provide type-specific default values.
|
|
184
|
+
* @returns The default JSON value for a new resource of this type
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
getDefaultTemplateCandidate(json?: JsonValue, conditions?: ResourceJson.Json.ConditionSetDecl, __resolver?: IResourceResolver): Result<ResourceJson.Json.IChildResourceCandidateDecl>;
|
|
87
188
|
}
|
|
88
189
|
//# sourceMappingURL=resourceType.d.ts.map
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.ResourceType = void 0;
|
|
25
|
+
const ts_json_base_1 = require("@fgv/ts-json-base");
|
|
25
26
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
27
|
const common_1 = require("../common");
|
|
27
28
|
/**
|
|
@@ -32,24 +33,25 @@ const common_1 = require("../common");
|
|
|
32
33
|
*/
|
|
33
34
|
class ResourceType {
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
+
* {@inheritdoc ResourceTypes.IResourceType.key}
|
|
36
37
|
*/
|
|
37
38
|
get key() {
|
|
38
39
|
return this._collectible.key;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* {@inheritdoc ResourceTypes.IResourceType.index}
|
|
42
43
|
*/
|
|
43
44
|
get index() {
|
|
44
45
|
return this._collectible.index;
|
|
45
46
|
}
|
|
46
|
-
constructor(key, index) {
|
|
47
|
+
constructor(key, index, template) {
|
|
47
48
|
this._collectible = new ts_utils_1.Collections.Collectible({
|
|
48
49
|
key,
|
|
49
50
|
/* c8 ignore next 1 - coverage having a rough time */
|
|
50
51
|
index: index !== undefined ? common_1.Validate.toResourceTypeIndex(index).orThrow() : undefined,
|
|
51
52
|
indexConverter: common_1.Convert.resourceTypeIndex
|
|
52
53
|
});
|
|
54
|
+
this._template = template !== null && template !== void 0 ? template : {};
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* Sets the index for this resource type. Once set, the index cannot be changed.
|
|
@@ -57,6 +59,40 @@ class ResourceType {
|
|
|
57
59
|
setIndex(index) {
|
|
58
60
|
return this._collectible.setIndex(index);
|
|
59
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates a template for a new resource of this type.
|
|
64
|
+
* Default implementation provides a basic template.
|
|
65
|
+
* Subclasses can override to provide type-specific templates.
|
|
66
|
+
* @param resourceId - The id for the new resource
|
|
67
|
+
* @param init - An optional initial value for the resource.
|
|
68
|
+
* @param conditions - An optional set of conditions that must be met for the resource to be selected.
|
|
69
|
+
* @param resolver - An optional resource resolver that can be used to create the template.
|
|
70
|
+
* @returns A loose resource declaration with default values for this resource type
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
createTemplate(resourceId, init, conditions, resolver) {
|
|
74
|
+
return this.getDefaultTemplateCandidate(init, conditions, resolver).onSuccess((candidate) => (0, ts_utils_1.succeed)({
|
|
75
|
+
id: resourceId,
|
|
76
|
+
resourceTypeName: this.key,
|
|
77
|
+
candidates: [candidate]
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gets the default template value for this resource type.
|
|
82
|
+
* Subclasses should override this to provide type-specific default values.
|
|
83
|
+
* @returns The default JSON value for a new resource of this type
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
getDefaultTemplateCandidate(json, conditions, __resolver) {
|
|
87
|
+
json = json !== null && json !== void 0 ? json : this._template;
|
|
88
|
+
if (!(0, ts_json_base_1.isJsonObject)(json)) {
|
|
89
|
+
return (0, ts_utils_1.fail)(`${this.key}: Invalid initial value "${json}" must be JSON object.`);
|
|
90
|
+
}
|
|
91
|
+
const candidate = Object.assign(Object.assign({ json }, (conditions ? { conditions } : {})), { mergeMethod: 'replace' });
|
|
92
|
+
return this.validate(json, 'full')
|
|
93
|
+
.onSuccess((json) => (0, ts_utils_1.succeed)(Object.assign(Object.assign({}, candidate), { isPartial: false })))
|
|
94
|
+
.onFailure(() => this.validate(json, 'partial').onSuccess((json) => (0, ts_utils_1.succeed)(Object.assign(Object.assign({}, candidate), { isPartial: true }))));
|
|
95
|
+
}
|
|
60
96
|
}
|
|
61
97
|
exports.ResourceType = ResourceType;
|
|
62
98
|
//# sourceMappingURL=resourceType.js.map
|
|
@@ -132,6 +132,7 @@ class CandidateReducer {
|
|
|
132
132
|
hasCollisions = true;
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
|
+
/* c8 ignore next 12 - complex collision handling for partial candidates rarely triggered */
|
|
135
136
|
// Partial reduced candidate - merge into unchanged and suppress reduced
|
|
136
137
|
const mergedJson = CandidateReducer._mergeJsonValues(unchangedCandidate.originalCandidate.json, reducedCandidate.originalCandidate.json);
|
|
137
138
|
// Update unchanged candidate with merged JSON, keeping its isPartial status
|
|
@@ -142,6 +143,7 @@ class CandidateReducer {
|
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
else {
|
|
146
|
+
/* c8 ignore next 15 - complex collision reversion logic rarely triggered in practice */
|
|
145
147
|
// Complex collision case - revert all reduced candidates to unchanged
|
|
146
148
|
for (const candidateInfo of reducedCandidates) {
|
|
147
149
|
// Revert to original conditions and mark as unchanged
|
|
@@ -224,6 +226,7 @@ class CandidateReducer {
|
|
|
224
226
|
reduceCandidate(candidate) {
|
|
225
227
|
var _a;
|
|
226
228
|
const candidateInfo = this._candidateInfos.find((info) => info.originalCandidate === candidate);
|
|
229
|
+
/* c8 ignore next 3 - defensive coding: candidate should always be found if properly managed */
|
|
227
230
|
if (!candidateInfo) {
|
|
228
231
|
return (0, ts_utils_1.fail)(`Candidate not found in reducer state`);
|
|
229
232
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { JsonValue } from '@fgv/ts-json-base';
|
|
2
|
+
import { Collections, Hash, Result } from '@fgv/ts-utils';
|
|
3
|
+
import { CandidateValueIndex, CandidateValueKey } from '../common';
|
|
4
|
+
/**
|
|
5
|
+
* Interface for a candidate value that can be collected and indexed.
|
|
6
|
+
* Candidate values are normalized JSON values that can be shared across
|
|
7
|
+
* multiple resource candidates to reduce duplication.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface ICandidateValue extends Collections.ICollectible<CandidateValueKey, CandidateValueIndex> {
|
|
11
|
+
/**
|
|
12
|
+
* The unique key for this candidate value, derived from the hash of the normalized JSON.
|
|
13
|
+
*/
|
|
14
|
+
readonly key: CandidateValueKey;
|
|
15
|
+
/**
|
|
16
|
+
* The index of this candidate value in the collection.
|
|
17
|
+
*/
|
|
18
|
+
readonly index: CandidateValueIndex | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The normalized JSON value.
|
|
21
|
+
*/
|
|
22
|
+
readonly json: JsonValue;
|
|
23
|
+
/**
|
|
24
|
+
* Sets the index of this candidate value.
|
|
25
|
+
* @param index - The index to set.
|
|
26
|
+
* @returns `Success` with the index if successful, or `Failure` with an error message if not.
|
|
27
|
+
*/
|
|
28
|
+
setIndex(index: number): Result<CandidateValueIndex>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parameters for creating a {@link Resources.CandidateValue | CandidateValue}.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export interface ICandidateValueCreateParams {
|
|
35
|
+
/**
|
|
36
|
+
* The JSON value to store. Will be normalized during creation.
|
|
37
|
+
*/
|
|
38
|
+
json: JsonValue;
|
|
39
|
+
/**
|
|
40
|
+
* Optional normalizer to use for normalizing the JSON value.
|
|
41
|
+
* If not provided, a default Crc32Normalizer will be used.
|
|
42
|
+
*/
|
|
43
|
+
normalizer?: Hash.Crc32Normalizer;
|
|
44
|
+
/**
|
|
45
|
+
* Optional index if the value is already indexed.
|
|
46
|
+
*/
|
|
47
|
+
index?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Implementation of a candidate value that stores normalized JSON data.
|
|
51
|
+
* The value is normalized on creation and a hash-based key is generated
|
|
52
|
+
* for efficient deduplication.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare class CandidateValue implements ICandidateValue {
|
|
56
|
+
private readonly _collectible;
|
|
57
|
+
private readonly _json;
|
|
58
|
+
/**
|
|
59
|
+
* The unique key for this candidate value.
|
|
60
|
+
*/
|
|
61
|
+
get key(): CandidateValueKey;
|
|
62
|
+
/**
|
|
63
|
+
* The index of this candidate value in the collection.
|
|
64
|
+
*/
|
|
65
|
+
get index(): CandidateValueIndex | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* The normalized JSON value.
|
|
68
|
+
*/
|
|
69
|
+
get json(): JsonValue;
|
|
70
|
+
/**
|
|
71
|
+
* Constructor for a {@link Resources.CandidateValue} object.
|
|
72
|
+
* @param params - Parameters to create the candidate value.
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
protected constructor(params: ICandidateValueCreateParams);
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new {@link Resources.CandidateValue} object.
|
|
78
|
+
* @param params - Parameters to create the candidate value.
|
|
79
|
+
* @returns `Success` with the new candidate value if successful,
|
|
80
|
+
* or `Failure` with an error message if not.
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
static create(params: ICandidateValueCreateParams): Result<CandidateValue>;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the index of this candidate value.
|
|
86
|
+
* @param index - The index to set.
|
|
87
|
+
* @returns `Success` with the index if successful, or `Failure` with an error message if not.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
setIndex(index: number): Result<CandidateValueIndex>;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=candidateValue.d.ts.map
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.CandidateValue = void 0;
|
|
58
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
59
|
+
const common_1 = require("../common");
|
|
60
|
+
const Common = __importStar(require("../common"));
|
|
61
|
+
/**
|
|
62
|
+
* Implementation of a candidate value that stores normalized JSON data.
|
|
63
|
+
* The value is normalized on creation and a hash-based key is generated
|
|
64
|
+
* for efficient deduplication.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
class CandidateValue {
|
|
68
|
+
/**
|
|
69
|
+
* The unique key for this candidate value.
|
|
70
|
+
*/
|
|
71
|
+
get key() {
|
|
72
|
+
return this._collectible.key;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The index of this candidate value in the collection.
|
|
76
|
+
*/
|
|
77
|
+
get index() {
|
|
78
|
+
return this._collectible.index;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The normalized JSON value.
|
|
82
|
+
*/
|
|
83
|
+
get json() {
|
|
84
|
+
return this._json;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Constructor for a {@link Resources.CandidateValue} object.
|
|
88
|
+
* @param params - Parameters to create the candidate value.
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
constructor(params) {
|
|
92
|
+
var _a;
|
|
93
|
+
const normalizer = (_a = params.normalizer) !== null && _a !== void 0 ? _a : new ts_utils_1.Hash.Crc32Normalizer();
|
|
94
|
+
// Normalize the JSON value
|
|
95
|
+
const normalizedResult = normalizer.normalize(params.json);
|
|
96
|
+
this._json = normalizedResult.orThrow();
|
|
97
|
+
// Generate key from the normalized value using computeHash
|
|
98
|
+
const keyResult = normalizer.computeHash(this._json);
|
|
99
|
+
const key = common_1.Convert.candidateValueKey.convert(keyResult.orThrow()).orThrow();
|
|
100
|
+
// Create the collectible with the key and optional index
|
|
101
|
+
this._collectible = new ts_utils_1.Collections.Collectible({
|
|
102
|
+
key,
|
|
103
|
+
index: params.index,
|
|
104
|
+
indexConverter: Common.Convert.candidateValueIndex
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Creates a new {@link Resources.CandidateValue} object.
|
|
109
|
+
* @param params - Parameters to create the candidate value.
|
|
110
|
+
* @returns `Success` with the new candidate value if successful,
|
|
111
|
+
* or `Failure` with an error message if not.
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
static create(params) {
|
|
115
|
+
return (0, ts_utils_1.captureResult)(() => new CandidateValue(params));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Sets the index of this candidate value.
|
|
119
|
+
* @param index - The index to set.
|
|
120
|
+
* @returns `Success` with the index if successful, or `Failure` with an error message if not.
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
setIndex(index) {
|
|
124
|
+
return this._collectible.setIndex(index);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.CandidateValue = CandidateValue;
|
|
128
|
+
//# sourceMappingURL=candidateValue.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { JsonValue } from '@fgv/ts-json-base';
|
|
2
|
+
import { Hash, Result, ValidatingCollector } from '@fgv/ts-utils';
|
|
3
|
+
import { CandidateValue } from './candidateValue';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for creating a {@link Resources.CandidateValueCollector}.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface ICandidateValueCollectorCreateParams {
|
|
9
|
+
/**
|
|
10
|
+
* Optional normalizer to use for normalizing JSON values.
|
|
11
|
+
* If not provided, a default Crc32Normalizer will be used.
|
|
12
|
+
*/
|
|
13
|
+
normalizer?: Hash.HashingNormalizer;
|
|
14
|
+
/**
|
|
15
|
+
* Optional initial candidate values to add to the collection.
|
|
16
|
+
*/
|
|
17
|
+
candidateValues?: (CandidateValue | JsonValue)[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A `ValidatingCollector` for {@link Resources.CandidateValue | CandidateValues},
|
|
21
|
+
* which collects candidate values supplied as either {@link Resources.CandidateValue | CandidateValue} or
|
|
22
|
+
* `JsonValue`.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare class CandidateValueCollector extends ValidatingCollector<CandidateValue> {
|
|
26
|
+
readonly normalizer: Hash.HashingNormalizer;
|
|
27
|
+
/**
|
|
28
|
+
* Constructor for a {@link Resources.CandidateValueCollector} object.
|
|
29
|
+
* @param params - Parameters to create the collector.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
protected constructor(params?: ICandidateValueCollectorCreateParams);
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new {@link Resources.CandidateValueCollector} object.
|
|
35
|
+
* @param params - Parameters to create the collector.
|
|
36
|
+
* @returns `Success` with the new collector if successful,
|
|
37
|
+
* or `Failure` with an error message if not.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
static create(params?: ICandidateValueCollectorCreateParams): Result<CandidateValueCollector>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns an array of JSON values ordered by their indices.
|
|
43
|
+
* @returns Array of JsonValue objects in index order.
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
getValuesByIndex(): JsonValue[];
|
|
47
|
+
/**
|
|
48
|
+
* Converter method to handle CandidateValue | JsonValue.
|
|
49
|
+
* @param from - The value to convert.
|
|
50
|
+
* @returns `Success` with the CandidateValue if successful, or `Failure` with an error message if not.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
private _toCandidateValue;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=candidateValueCollector.d.ts.map
|