@fgv/ts-res 4.5.0-2 → 5.0.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +26 -0
- package/CHANGELOG.md +14 -0
- package/CLAUDE.md +186 -0
- package/EXAMPLE_INIT_PARAMS.md +88 -0
- package/PROGRESS_SUMMARY.md +48 -0
- package/README.md +535 -14
- package/dist/ts-res.d.ts +4225 -324
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/packlets/common/conditions.d.ts +30 -0
- package/lib/packlets/common/conditions.d.ts.map +1 -1
- package/lib/packlets/common/conditions.js.map +1 -1
- package/lib/packlets/common/convert.d.ts +22 -2
- package/lib/packlets/common/convert.d.ts.map +1 -1
- package/lib/packlets/common/convert.js +21 -1
- package/lib/packlets/common/convert.js.map +1 -1
- package/lib/packlets/common/helpers/context.d.ts +39 -0
- package/lib/packlets/common/helpers/context.d.ts.map +1 -0
- package/lib/packlets/common/helpers/context.js +108 -0
- package/lib/packlets/common/helpers/context.js.map +1 -0
- package/lib/packlets/common/helpers/index.d.ts +2 -0
- package/lib/packlets/common/helpers/index.d.ts.map +1 -1
- package/lib/packlets/common/helpers/index.js +2 -0
- package/lib/packlets/common/helpers/index.js.map +1 -1
- package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts +39 -0
- package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts.map +1 -0
- package/lib/packlets/common/helpers/qualifierDefaultValues.js +105 -0
- package/lib/packlets/common/helpers/qualifierDefaultValues.js.map +1 -0
- package/lib/packlets/common/helpers/resources.d.ts.map +1 -1
- package/lib/packlets/common/helpers/resources.js +6 -2
- package/lib/packlets/common/helpers/resources.js.map +1 -1
- package/lib/packlets/common/validate/conditions.d.ts +69 -1
- package/lib/packlets/common/validate/conditions.d.ts.map +1 -1
- package/lib/packlets/common/validate/conditions.js +126 -0
- package/lib/packlets/common/validate/conditions.js.map +1 -1
- package/lib/packlets/common/validate/regularExpressions.d.ts +20 -0
- package/lib/packlets/common/validate/regularExpressions.d.ts.map +1 -1
- package/lib/packlets/common/validate/regularExpressions.js +21 -1
- package/lib/packlets/common/validate/regularExpressions.js.map +1 -1
- package/lib/packlets/conditions/condition.d.ts +37 -0
- package/lib/packlets/conditions/condition.d.ts.map +1 -1
- package/lib/packlets/conditions/condition.js +67 -1
- package/lib/packlets/conditions/condition.js.map +1 -1
- package/lib/packlets/conditions/conditionCollector.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionCollector.js +1 -0
- package/lib/packlets/conditions/conditionCollector.js.map +1 -1
- package/lib/packlets/conditions/conditionSet.d.ts +34 -3
- package/lib/packlets/conditions/conditionSet.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionSet.js +31 -3
- package/lib/packlets/conditions/conditionSet.js.map +1 -1
- package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionSetCollector.js +3 -0
- package/lib/packlets/conditions/conditionSetCollector.js.map +1 -1
- package/lib/packlets/conditions/conditionToken.d.ts.map +1 -1
- package/lib/packlets/conditions/conditionToken.js +2 -1
- package/lib/packlets/conditions/conditionToken.js.map +1 -1
- package/lib/packlets/conditions/convert/decls.js +1 -1
- package/lib/packlets/conditions/convert/decls.js.map +1 -1
- package/lib/packlets/config/common.d.ts +35 -0
- package/lib/packlets/config/common.d.ts.map +1 -0
- package/lib/packlets/config/common.js +96 -0
- package/lib/packlets/config/common.js.map +1 -0
- package/lib/packlets/config/convert.d.ts +14 -0
- package/lib/packlets/config/convert.d.ts.map +1 -0
- package/lib/packlets/config/convert.js +82 -0
- package/lib/packlets/config/convert.js.map +1 -0
- package/lib/packlets/config/index.d.ts +6 -0
- package/lib/packlets/config/index.d.ts.map +1 -0
- package/lib/packlets/config/index.js +67 -0
- package/lib/packlets/config/index.js.map +1 -0
- package/lib/packlets/config/json.d.ts +20 -0
- package/lib/packlets/config/json.d.ts.map +1 -0
- package/lib/packlets/config/json.js +24 -0
- package/lib/packlets/config/json.js.map +1 -0
- package/lib/packlets/config/predefined/default.d.ts +57 -0
- package/lib/packlets/config/predefined/default.d.ts.map +1 -0
- package/lib/packlets/config/predefined/default.js +141 -0
- package/lib/packlets/config/predefined/default.js.map +1 -0
- package/lib/packlets/config/predefined/extended.d.ts +25 -0
- package/lib/packlets/config/predefined/extended.d.ts.map +1 -0
- package/lib/packlets/config/predefined/extended.js +193 -0
- package/lib/packlets/config/predefined/extended.js.map +1 -0
- package/lib/packlets/config/predefined/index.d.ts +4 -0
- package/lib/packlets/config/predefined/index.d.ts.map +1 -0
- package/lib/packlets/config/predefined/index.js +62 -0
- package/lib/packlets/config/predefined/index.js.map +1 -0
- package/lib/packlets/config/systemConfiguration.d.ts +81 -0
- package/lib/packlets/config/systemConfiguration.d.ts.map +1 -0
- package/lib/packlets/config/systemConfiguration.js +172 -0
- package/lib/packlets/config/systemConfiguration.js.map +1 -0
- package/lib/packlets/context/contextDecls.d.ts +49 -0
- package/lib/packlets/context/contextDecls.d.ts.map +1 -0
- package/lib/packlets/context/contextDecls.js +24 -0
- package/lib/packlets/context/contextDecls.js.map +1 -0
- package/lib/packlets/context/contextToken.d.ts +111 -0
- package/lib/packlets/context/contextToken.d.ts.map +1 -0
- package/lib/packlets/context/contextToken.js +206 -0
- package/lib/packlets/context/contextToken.js.map +1 -0
- package/lib/packlets/context/convert/decls.d.ts +37 -0
- package/lib/packlets/context/convert/decls.d.ts.map +1 -0
- package/lib/packlets/context/convert/decls.js +94 -0
- package/lib/packlets/context/convert/decls.js.map +1 -0
- package/lib/packlets/context/convert/index.d.ts +2 -0
- package/lib/packlets/context/convert/index.d.ts.map +1 -0
- package/lib/packlets/context/convert/index.js +39 -0
- package/lib/packlets/context/convert/index.js.map +1 -0
- package/lib/packlets/context/index.d.ts +5 -0
- package/lib/packlets/context/index.d.ts.map +1 -0
- package/lib/packlets/context/index.js +65 -0
- package/lib/packlets/context/index.js.map +1 -0
- package/lib/packlets/decisions/abstractDecision.d.ts +8 -0
- package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -1
- package/lib/packlets/decisions/abstractDecision.js +9 -0
- package/lib/packlets/decisions/abstractDecision.js.map +1 -1
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -1
- package/lib/packlets/decisions/abstractDecisionCollector.js +2 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -1
- package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -1
- package/lib/packlets/decisions/concreteDecision.js +3 -2
- package/lib/packlets/decisions/concreteDecision.js.map +1 -1
- package/lib/packlets/decisions/decision.d.ts.map +1 -1
- package/lib/packlets/decisions/decision.js +4 -0
- package/lib/packlets/decisions/decision.js.map +1 -1
- package/lib/packlets/import/fsItem.d.ts.map +1 -1
- package/lib/packlets/import/fsItem.js +1 -0
- package/lib/packlets/import/fsItem.js.map +1 -1
- package/lib/packlets/import/importContext.d.ts +19 -0
- package/lib/packlets/import/importContext.d.ts.map +1 -1
- package/lib/packlets/import/importContext.js +39 -0
- package/lib/packlets/import/importContext.js.map +1 -1
- package/lib/packlets/import/importManager.d.ts +5 -5
- package/lib/packlets/import/importManager.d.ts.map +1 -1
- package/lib/packlets/import/importManager.js.map +1 -1
- package/lib/packlets/import/importers/collectionImporter.d.ts +11 -13
- package/lib/packlets/import/importers/collectionImporter.d.ts.map +1 -1
- package/lib/packlets/import/importers/collectionImporter.js +29 -20
- package/lib/packlets/import/importers/collectionImporter.js.map +1 -1
- package/lib/packlets/import/importers/fsItemImporter.d.ts +2 -2
- package/lib/packlets/import/importers/fsItemImporter.d.ts.map +1 -1
- package/lib/packlets/import/importers/fsItemImporter.js +2 -2
- package/lib/packlets/import/importers/fsItemImporter.js.map +1 -1
- package/lib/packlets/import/importers/importer.d.ts +3 -3
- package/lib/packlets/import/importers/importer.d.ts.map +1 -1
- package/lib/packlets/import/importers/importer.js.map +1 -1
- package/lib/packlets/import/importers/jsonImporter.d.ts +2 -3
- package/lib/packlets/import/importers/jsonImporter.d.ts.map +1 -1
- package/lib/packlets/import/importers/jsonImporter.js +10 -20
- package/lib/packlets/import/importers/jsonImporter.js.map +1 -1
- package/lib/packlets/import/importers/pathImporter.d.ts +2 -2
- package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -1
- package/lib/packlets/import/importers/pathImporter.js.map +1 -1
- package/lib/packlets/qualifier-types/config/convert.d.ts +44 -0
- package/lib/packlets/qualifier-types/config/convert.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/convert.js +96 -0
- package/lib/packlets/qualifier-types/config/convert.js.map +1 -0
- package/lib/packlets/qualifier-types/config/index.d.ts +4 -0
- package/lib/packlets/qualifier-types/config/index.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/index.js +64 -0
- package/lib/packlets/qualifier-types/config/index.js.map +1 -0
- package/lib/packlets/qualifier-types/config/json.d.ts +69 -0
- package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/json.js +24 -0
- package/lib/packlets/qualifier-types/config/json.js.map +1 -0
- package/lib/packlets/qualifier-types/convert.d.ts +10 -2
- package/lib/packlets/qualifier-types/convert.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/convert.js +15 -0
- package/lib/packlets/qualifier-types/convert.js.map +1 -1
- package/lib/packlets/qualifier-types/helpers.d.ts +27 -0
- package/lib/packlets/qualifier-types/helpers.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/helpers.js +118 -0
- package/lib/packlets/qualifier-types/helpers.js.map +1 -0
- package/lib/packlets/qualifier-types/index.d.ts +4 -1
- package/lib/packlets/qualifier-types/index.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/index.js +5 -1
- package/lib/packlets/qualifier-types/index.js.map +1 -1
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +19 -8
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/languageQualifierType.js +28 -9
- package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +38 -13
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/literalQualifierType.js +44 -10
- package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +107 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.js +215 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts +22 -18
- package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/qualifierType.js +9 -4
- package/lib/packlets/qualifier-types/qualifierType.js.map +1 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts +4 -2
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js +2 -1
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -1
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +47 -11
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/territoryQualifierType.js +61 -17
- package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -1
- package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -1
- package/lib/packlets/qualifiers/convert/decls.js +17 -15
- package/lib/packlets/qualifiers/convert/decls.js.map +1 -1
- package/lib/packlets/qualifiers/index.d.ts +2 -0
- package/lib/packlets/qualifiers/index.d.ts.map +1 -1
- package/lib/packlets/qualifiers/index.js +2 -0
- package/lib/packlets/qualifiers/index.js.map +1 -1
- package/lib/packlets/qualifiers/qualifier.d.ts +22 -2
- package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -1
- package/lib/packlets/qualifiers/qualifier.js +26 -1
- package/lib/packlets/qualifiers/qualifier.js.map +1 -1
- package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -1
- package/lib/packlets/qualifiers/qualifierCollector.js +4 -0
- package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -1
- package/lib/packlets/qualifiers/qualifierDecl.d.ts +6 -1
- package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +1 -1
- package/lib/packlets/qualifiers/qualifierDecl.js.map +1 -1
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts +32 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js +24 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts +96 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.js +179 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.js.map +1 -0
- package/lib/packlets/resource-json/compiled/common.d.ts +14 -0
- package/lib/packlets/resource-json/compiled/common.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/common.js +24 -0
- package/lib/packlets/resource-json/compiled/common.js.map +1 -0
- package/lib/packlets/resource-json/compiled/convert.d.ts +63 -0
- package/lib/packlets/resource-json/compiled/convert.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/convert.js +167 -0
- package/lib/packlets/resource-json/compiled/convert.js.map +1 -0
- package/lib/packlets/resource-json/compiled/index.d.ts +5 -0
- package/lib/packlets/resource-json/compiled/index.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/index.js +65 -0
- package/lib/packlets/resource-json/compiled/index.js.map +1 -0
- package/lib/packlets/resource-json/compiled/json.d.ts +204 -0
- package/lib/packlets/resource-json/compiled/json.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/json.js +3 -0
- package/lib/packlets/resource-json/compiled/json.js.map +1 -0
- package/lib/packlets/resource-json/convert.d.ts +16 -0
- package/lib/packlets/resource-json/convert.d.ts.map +1 -1
- package/lib/packlets/resource-json/convert.js +41 -6
- package/lib/packlets/resource-json/convert.js.map +1 -1
- package/lib/packlets/resource-json/helpers.d.ts +82 -3
- package/lib/packlets/resource-json/helpers.d.ts.map +1 -1
- package/lib/packlets/resource-json/helpers.js +185 -2
- package/lib/packlets/resource-json/helpers.js.map +1 -1
- package/lib/packlets/resource-json/index.d.ts +2 -1
- package/lib/packlets/resource-json/index.d.ts.map +1 -1
- package/lib/packlets/resource-json/index.js +3 -1
- package/lib/packlets/resource-json/index.js.map +1 -1
- package/lib/packlets/resource-json/json.d.ts +55 -3
- package/lib/packlets/resource-json/json.d.ts.map +1 -1
- package/lib/packlets/resource-json/json.js +16 -0
- package/lib/packlets/resource-json/json.js.map +1 -1
- package/lib/packlets/resource-json/normalized.d.ts +46 -3
- package/lib/packlets/resource-json/normalized.d.ts.map +1 -1
- package/lib/packlets/resource-json/normalized.js.map +1 -1
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts +14 -10
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +1 -1
- package/lib/packlets/resource-json/resourceDeclCollection.js +18 -14
- package/lib/packlets/resource-json/resourceDeclCollection.js.map +1 -1
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts +15 -2
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +1 -1
- package/lib/packlets/resource-json/resourceDeclContainer.js.map +1 -1
- package/lib/packlets/resource-json/resourceDeclTree.d.ts +6 -2
- package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +1 -1
- package/lib/packlets/resource-json/resourceDeclTree.js +12 -3
- package/lib/packlets/resource-json/resourceDeclTree.js.map +1 -1
- package/lib/packlets/resource-types/config/convert.d.ts +8 -0
- package/lib/packlets/resource-types/config/convert.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/convert.js +36 -0
- package/lib/packlets/resource-types/config/convert.js.map +1 -0
- package/lib/packlets/resource-types/config/index.d.ts +4 -0
- package/lib/packlets/resource-types/config/index.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/index.js +64 -0
- package/lib/packlets/resource-types/config/index.js.map +1 -0
- package/lib/packlets/resource-types/config/json.d.ts +9 -0
- package/lib/packlets/resource-types/config/json.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/json.js +24 -0
- package/lib/packlets/resource-types/config/json.js.map +1 -0
- package/lib/packlets/resource-types/helpers.d.ts +13 -0
- package/lib/packlets/resource-types/helpers.d.ts.map +1 -0
- package/lib/packlets/resource-types/helpers.js +44 -0
- package/lib/packlets/resource-types/helpers.js.map +1 -0
- package/lib/packlets/resource-types/index.d.ts +3 -0
- package/lib/packlets/resource-types/index.d.ts.map +1 -1
- package/lib/packlets/resource-types/index.js +26 -0
- package/lib/packlets/resource-types/index.js.map +1 -1
- package/lib/packlets/resource-types/jsonResourceType.d.ts +5 -13
- package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -1
- package/lib/packlets/resource-types/jsonResourceType.js +5 -2
- package/lib/packlets/resource-types/jsonResourceType.js.map +1 -1
- package/lib/packlets/resource-types/resourceType.d.ts +33 -32
- package/lib/packlets/resource-types/resourceType.d.ts.map +1 -1
- package/lib/packlets/resource-types/resourceType.js.map +1 -1
- package/lib/packlets/resources/candidateReducer.d.ts +98 -0
- package/lib/packlets/resources/candidateReducer.d.ts.map +1 -0
- package/lib/packlets/resources/candidateReducer.js +247 -0
- package/lib/packlets/resources/candidateReducer.js.map +1 -0
- package/lib/packlets/resources/common.d.ts +60 -0
- package/lib/packlets/resources/common.d.ts.map +1 -0
- package/lib/packlets/resources/common.js +24 -0
- package/lib/packlets/resources/common.js.map +1 -0
- package/lib/packlets/resources/index.d.ts +3 -1
- package/lib/packlets/resources/index.d.ts.map +1 -1
- package/lib/packlets/resources/index.js +3 -1
- package/lib/packlets/resources/index.js.map +1 -1
- package/lib/packlets/resources/resource.d.ts +57 -5
- package/lib/packlets/resources/resource.d.ts.map +1 -1
- package/lib/packlets/resources/resource.js +96 -6
- package/lib/packlets/resources/resource.js.map +1 -1
- package/lib/packlets/resources/resourceBuilder.d.ts +14 -0
- package/lib/packlets/resources/resourceBuilder.d.ts.map +1 -1
- package/lib/packlets/resources/resourceBuilder.js +19 -1
- package/lib/packlets/resources/resourceBuilder.js.map +1 -1
- package/lib/packlets/resources/resourceCandidate.d.ts +42 -6
- package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -1
- package/lib/packlets/resources/resourceCandidate.js +40 -1
- package/lib/packlets/resources/resourceCandidate.js.map +1 -1
- package/lib/packlets/resources/resourceManagerBuilder.d.ts +220 -0
- package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +1 -0
- package/lib/packlets/resources/resourceManagerBuilder.js +451 -0
- package/lib/packlets/resources/resourceManagerBuilder.js.map +1 -0
- package/lib/packlets/runtime/cacheListener.d.ts +62 -0
- package/lib/packlets/runtime/cacheListener.d.ts.map +1 -0
- package/lib/packlets/runtime/cacheListener.js +56 -0
- package/lib/packlets/runtime/cacheListener.js.map +1 -0
- package/lib/packlets/runtime/cacheMetrics.d.ts +82 -0
- package/lib/packlets/runtime/cacheMetrics.d.ts.map +1 -0
- package/lib/packlets/runtime/cacheMetrics.js +143 -0
- package/lib/packlets/runtime/cacheMetrics.js.map +1 -0
- package/lib/packlets/runtime/compiledResourceCollection.d.ts +167 -0
- package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +1 -0
- package/lib/packlets/runtime/compiledResourceCollection.js +466 -0
- package/lib/packlets/runtime/compiledResourceCollection.js.map +1 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.d.ts +70 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.d.ts.map +1 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.js +135 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.js.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.d.ts +80 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.d.ts.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.js +33 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts +165 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.js +179 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.js.map +1 -0
- package/lib/packlets/runtime/context/index.d.ts +5 -0
- package/lib/packlets/runtime/context/index.d.ts.map +1 -0
- package/lib/packlets/runtime/context/index.js +42 -0
- package/lib/packlets/runtime/context/index.js.map +1 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +111 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +1 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +177 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +47 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +1 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +64 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/iResourceManager.d.ts +88 -0
- package/lib/packlets/runtime/iResourceManager.d.ts.map +1 -0
- package/lib/packlets/runtime/iResourceManager.js +24 -0
- package/lib/packlets/runtime/iResourceManager.js.map +1 -0
- package/lib/packlets/runtime/index.d.ts +12 -0
- package/lib/packlets/runtime/index.d.ts.map +1 -0
- package/lib/packlets/runtime/index.js +73 -0
- package/lib/packlets/runtime/index.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/common.d.ts +91 -0
- package/lib/packlets/runtime/resource-tree/common.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/common.js +24 -0
- package/lib/packlets/runtime/resource-tree/common.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/index.d.ts +5 -0
- package/lib/packlets/runtime/resource-tree/index.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/index.js +42 -0
- package/lib/packlets/runtime/resource-tree/index.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts +141 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js +224 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts +24 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js +98 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts +99 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js +165 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +1 -0
- package/lib/packlets/runtime/resourceResolver.d.ts +196 -0
- package/lib/packlets/runtime/resourceResolver.d.ts.map +1 -0
- package/lib/packlets/runtime/resourceResolver.js +437 -0
- package/lib/packlets/runtime/resourceResolver.js.map +1 -0
- package/lib/packlets/runtime/validate.d.ts +13 -0
- package/lib/packlets/runtime/validate.d.ts.map +1 -0
- package/lib/packlets/runtime/validate.js +49 -0
- package/lib/packlets/runtime/validate.js.map +1 -0
- package/package.json +76 -75
- package/lib/packlets/resources/resourceManager.d.ts +0 -104
- package/lib/packlets/resources/resourceManager.d.ts.map +0 -1
- package/lib/packlets/resources/resourceManager.js +0 -201
- package/lib/packlets/resources/resourceManager.js.map +0 -1
|
@@ -31,11 +31,37 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
31
31
|
if (k2 === undefined) k2 = k;
|
|
32
32
|
o[k2] = m[k];
|
|
33
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
|
+
})();
|
|
34
56
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
35
57
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
36
58
|
};
|
|
37
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.Config = void 0;
|
|
61
|
+
const Config = __importStar(require("./config"));
|
|
62
|
+
exports.Config = Config;
|
|
38
63
|
__exportStar(require("./resourceType"), exports);
|
|
39
64
|
__exportStar(require("./resourceTypeCollector"), exports);
|
|
40
65
|
__exportStar(require("./jsonResourceType"), exports);
|
|
66
|
+
__exportStar(require("./helpers"), exports);
|
|
41
67
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAmC;AAO1B,wBAAM;AALf,iDAA+B;AAC/B,0DAAwC;AACxC,qDAAmC;AACnC,4CAA0B","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Config from './config';\n\nexport * from './resourceType';\nexport * from './resourceTypeCollector';\nexport * from './jsonResourceType';\nexport * from './helpers';\n\nexport { Config };\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { JsonObject
|
|
2
|
-
import { ResourceType } from './resourceType';
|
|
3
|
-
import { ResourceTypeName
|
|
1
|
+
import { JsonObject } from '@fgv/ts-json-base';
|
|
2
|
+
import { IResourceCandidateValidationProperties, ResourceType } from './resourceType';
|
|
3
|
+
import { ResourceTypeName } from '../common';
|
|
4
4
|
import { Result } from '@fgv/ts-utils';
|
|
5
5
|
/**
|
|
6
6
|
* Parameters to create a {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.
|
|
@@ -38,17 +38,9 @@ export declare class JsonResourceType extends ResourceType<JsonObject> {
|
|
|
38
38
|
*/
|
|
39
39
|
static create(params?: IJsonResourceTypeCreateParams): Result<JsonResourceType>;
|
|
40
40
|
/**
|
|
41
|
-
* {@inheritdoc ResourceTypes.ResourceType.
|
|
41
|
+
* {@inheritdoc ResourceTypes.ResourceType.validateDeclaration}
|
|
42
42
|
*/
|
|
43
|
-
validateDeclaration(
|
|
44
|
-
/**
|
|
45
|
-
* {@inheritdoc ResourceTypes.ResourceType.(validateDeclaration:2)}
|
|
46
|
-
*/
|
|
47
|
-
validateDeclaration(json: JsonValue, isPartial: false, mergeMethod?: ResourceValueMergeMethod): Result<JsonObject>;
|
|
48
|
-
/**
|
|
49
|
-
* {@inheritdoc ResourceTypes.ResourceType.(validateDeclaration:3)}
|
|
50
|
-
*/
|
|
51
|
-
validateDeclaration(json: JsonValue, isPartial: boolean, mergeMethod?: ResourceValueMergeMethod): Result<JsonObject | Partial<JsonObject>>;
|
|
43
|
+
validateDeclaration(props: IResourceCandidateValidationProperties): Result<JsonObject>;
|
|
52
44
|
/**
|
|
53
45
|
* {@inheritdoc ResourceTypes.ResourceType.(validate:1)}
|
|
54
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonResourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAgC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"jsonResourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAgC,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,sCAAsC,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAW,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,UAAU,CAAC;IAC5D;;;;;OAKG;IACH,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAI3D;;;;;OAKG;WACW,MAAM,CAAC,MAAM,CAAC,EAAE,6BAA6B,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAMtF;;OAEG;IAEI,mBAAmB,CAAC,KAAK,EAAE,sCAAsC,GAAG,MAAM,CAAC,UAAU,CAAC;IAI7F;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;IACtE;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;IACvE;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC;CAI1E"}
|
|
@@ -52,8 +52,11 @@ class JsonResourceType extends resourceType_1.ResourceType {
|
|
|
52
52
|
return (0, ts_utils_1.captureResult)(() => new JsonResourceType(key, params === null || params === void 0 ? void 0 : params.index));
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
/**
|
|
56
|
+
* {@inheritdoc ResourceTypes.ResourceType.validateDeclaration}
|
|
57
|
+
*/
|
|
58
|
+
validateDeclaration(props) {
|
|
59
|
+
return ts_json_base_1.Converters.jsonObject.convert(props.json);
|
|
57
60
|
}
|
|
58
61
|
validate(json, __isPartial) {
|
|
59
62
|
return ts_json_base_1.Converters.jsonObject.convert(json);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonResourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"jsonResourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/jsonResourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,oDAA6E;AAC7E,iDAAsF;AACtF,sCAAsD;AACtD,4CAAsD;AAoBtD;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,2BAAwB;IAC5D;;;;;OAKG;IACH,YAAsB,GAAqB,EAAE,KAAc;QACzD,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,MAAsC;;QACzD,OAAO,gBAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/E,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,GAAG,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IAEI,mBAAmB,CAAC,KAA6C;QACtE,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IAcM,QAAQ,CAAC,IAAgB,EAAE,WAAqB;QACrD,OAAO,yBAAc,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF;AA9CD,4CA8CC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Converters as JsonConverters, JsonObject } from '@fgv/ts-json-base';\nimport { IResourceCandidateValidationProperties, ResourceType } from './resourceType';\nimport { Convert, ResourceTypeName } from '../common';\nimport { captureResult, Result } from '@fgv/ts-utils';\n\n/**\n * Parameters to create a {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @public\n */\nexport interface IJsonResourceTypeCreateParams {\n /**\n * Optional key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * Defaults to 'json'.\n */\n key?: string;\n\n /**\n * Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType}\n * instance.\n */\n index?: number;\n}\n\n/**\n * Implementation of a {@link ResourceTypes.ResourceType | ResourceType} for JSON values.\n * @public\n */\nexport class JsonResourceType extends ResourceType<JsonObject> {\n /**\n * Protected {@link ResourceTypes.JsonResourceType | JsonResourceType} constructor for use by subclasses.\n * Use {@link ResourceTypes.JsonResourceType.create | JsonResourceType.create} to create a new instance.\n * @param key - The key for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param index - Optional index for the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n */\n protected constructor(key: ResourceTypeName, index?: number) {\n super(key, index);\n }\n\n /**\n * Factory method to create a new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance.\n * @param params - {@link ResourceTypes.IJsonResourceTypeCreateParams | Parameters} to create the new instance.\n * @returns `Success` with the new {@link ResourceTypes.JsonResourceType | JsonResourceType} instance if successful\n * or `Failure` with an error message if not.\n */\n public static create(params?: IJsonResourceTypeCreateParams): Result<JsonResourceType> {\n return Convert.resourceTypeName.convert(params?.key ?? 'json').onSuccess((key) => {\n return captureResult(() => new JsonResourceType(key, params?.index));\n });\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.validateDeclaration}\n */\n\n public validateDeclaration(props: IResourceCandidateValidationProperties): Result<JsonObject> {\n return JsonConverters.jsonObject.convert(props.json);\n }\n\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:1)}\n */\n public validate(json: JsonObject, isPartial: true): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:2)}\n */\n public validate(json: JsonObject, isPartial: false): Result<JsonObject>;\n /**\n * {@inheritdoc ResourceTypes.ResourceType.(validate:3)}\n */\n public validate(json: JsonObject, isPartial: boolean): Result<JsonObject>;\n public validate(json: JsonObject, __isPartial?: boolean): Result<JsonObject> {\n return JsonConverters.jsonObject.convert(json);\n }\n}\n"]}
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { JsonValue } from '@fgv/ts-json-base';
|
|
2
2
|
import { ICollectible, Result } from '@fgv/ts-utils';
|
|
3
|
-
import { ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod } from '../common';
|
|
3
|
+
import { ResourceTypeIndex, ResourceTypeName, ResourceValueMergeMethod, ResourceId } from '../common';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters used to validate a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface IResourceCandidateValidationProperties {
|
|
9
|
+
/**
|
|
10
|
+
* {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.id}
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
id: ResourceId;
|
|
14
|
+
/**
|
|
15
|
+
* {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.isPartial}
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
isPartial: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.json}
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
json: JsonValue;
|
|
24
|
+
/**
|
|
25
|
+
* {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.mergeMethod}
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
mergeMethod: ResourceValueMergeMethod;
|
|
29
|
+
}
|
|
4
30
|
/**
|
|
5
31
|
* Abstract base class for resource types which are responsible for
|
|
6
32
|
* validating and converting JSON values into the appropriate strongly-typed
|
|
@@ -19,39 +45,14 @@ export declare abstract class ResourceType<T = unknown> implements ICollectible<
|
|
|
19
45
|
get index(): ResourceTypeIndex | undefined;
|
|
20
46
|
protected constructor(key: ResourceTypeName, index?: number);
|
|
21
47
|
/**
|
|
22
|
-
* Validates a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
|
|
23
|
-
* a partial resource instance value.
|
|
24
|
-
* @param json - The JSON value to validate.
|
|
25
|
-
* @param isPartial - `true` indicates that the value is expected to be incomplete.
|
|
26
|
-
* @param mergeMethod - The method to use when merging with previously resolved values.
|
|
27
|
-
* @returns `Success` with the strongly-typed resource value if the JSON and merge
|
|
28
|
-
* method are valid, `Failure` with an error message otherwise.
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
abstract validateDeclaration(json: JsonValue, isPartial: true, mergeMethod?: ResourceValueMergeMethod): Result<Partial<T>>;
|
|
32
|
-
/**
|
|
33
|
-
* Validates a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
|
|
34
|
-
* a complete resource instance value.
|
|
35
|
-
* @param json - The JSON value to validate.
|
|
36
|
-
* @param isPartial - `false` indicates that the value is expected to be complete.
|
|
37
|
-
* @param mergeMethod - The method to use when merging with previously resolved values.
|
|
38
|
-
* @returns `Success` with the strongly-typed resource value if the JSON and merge method
|
|
39
|
-
* are valid, `Failure` with an error message otherwise.
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
abstract validateDeclaration(json: JsonValue, isPartial: false, mergeMethod?: ResourceValueMergeMethod): Result<T>;
|
|
43
|
-
/**
|
|
44
|
-
* Validates a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
|
|
48
|
+
* Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for
|
|
45
49
|
* a resource instance value.
|
|
46
|
-
* @param
|
|
47
|
-
* @param isPartial - Indicates whether the value is expected to be incomplete.
|
|
48
|
-
* @param mergeMethod - The method to use when merging with previously resolved values.
|
|
50
|
+
* @param props - The {@link ResourceTypes.IResourceCandidateValidationProperties | properties } to validate.
|
|
49
51
|
* @returns `Success` with the strongly-typed resource value if the JSON and merge method
|
|
50
52
|
* are valid, `Failure` with an error message otherwise.
|
|
51
53
|
* @public
|
|
52
54
|
*/
|
|
53
|
-
abstract validateDeclaration(
|
|
54
|
-
abstract validateDeclaration(json: JsonValue, isPartial: boolean, mergeMethod?: ResourceValueMergeMethod): Result<T | Partial<T>>;
|
|
55
|
+
abstract validateDeclaration(props: IResourceCandidateValidationProperties): Result<T | Partial<T>>;
|
|
55
56
|
/**
|
|
56
57
|
* Validates a JSON value for use as a partial resource instance value.
|
|
57
58
|
* @param json - The JSON value to validate.
|
|
@@ -60,7 +61,7 @@ export declare abstract class ResourceType<T = unknown> implements ICollectible<
|
|
|
60
61
|
* `Failure` with an error message otherwise.
|
|
61
62
|
* @public
|
|
62
63
|
*/
|
|
63
|
-
abstract validate(json: JsonValue, isPartial: true): Result<T
|
|
64
|
+
abstract validate(json: JsonValue, isPartial: true): Result<Partial<T>>;
|
|
64
65
|
/**
|
|
65
66
|
* Validates a JSON value for use as a complete resource instance value.
|
|
66
67
|
* @param json - The JSON value to validate.
|
|
@@ -69,7 +70,7 @@ export declare abstract class ResourceType<T = unknown> implements ICollectible<
|
|
|
69
70
|
* `Failure` with an error message otherwise.
|
|
70
71
|
* @public
|
|
71
72
|
*/
|
|
72
|
-
abstract validate(json: JsonValue, isPartial: false): Result<
|
|
73
|
+
abstract validate(json: JsonValue, isPartial: false): Result<T>;
|
|
73
74
|
/**
|
|
74
75
|
* Validates a JSON value for use as a full or partial resource instance value.
|
|
75
76
|
* @param json - The JSON value to validate.
|
|
@@ -78,7 +79,7 @@ export declare abstract class ResourceType<T = unknown> implements ICollectible<
|
|
|
78
79
|
* the JSON is valid, `Failure` with an error message otherwise.
|
|
79
80
|
* @public
|
|
80
81
|
*/
|
|
81
|
-
abstract validate(json: JsonValue, isPartial
|
|
82
|
+
abstract validate(json: JsonValue, isPartial?: boolean): Result<T | Partial<T>>;
|
|
82
83
|
/**
|
|
83
84
|
* Sets the index for this resource type. Once set, the index cannot be changed.
|
|
84
85
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAe,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAGL,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"resourceType.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAe,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAGL,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,UAAU,EACX,MAAM,WAAW,CAAC;AAEnB;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD;;;OAGG;IACH,EAAE,EAAE,UAAU,CAAC;IAEf;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,IAAI,EAAE,SAAS,CAAC;IAEhB;;;OAGG;IACH,WAAW,EAAE,wBAAwB,CAAC;CACvC;AAED;;;;;GAKG;AACH,8BAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,YAAY,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAC1G,OAAO,CAAC,YAAY,CAA+D;IACnF;;OAEG;IACH,IAAW,GAAG,IAAI,gBAAgB,CAEjC;IAED;;OAEG;IACH,IAAW,KAAK,IAAI,iBAAiB,GAAG,SAAS,CAEhD;IAED,SAAS,aAAa,GAAG,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM;IAS3D;;;;;;;OAOG;aACa,mBAAmB,CAAC,KAAK,EAAE,sCAAsC,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1G;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE9E;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC;IAEtE;;;;;;;OAOG;aACa,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEtF;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC;CAG1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,4CAAkE;AAClE,
|
|
1
|
+
{"version":3,"file":"resourceType.js","sourceRoot":"","sources":["../../../src/packlets/resource-types/resourceType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,4CAAkE;AAClE,sCAOmB;AAgCnB;;;;;GAKG;AACH,MAAsB,YAAY;IAEhC;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,YAAsB,GAAqB,EAAE,KAAc;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,sBAAW,CAAC,WAAW,CAAsC;YACnF,GAAG;YACH,qDAAqD;YACrD,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;YACtF,cAAc,EAAE,gBAAa,CAAC,iBAAiB;SAChD,CAAC,CAAC;IACL,CAAC;IA0CD;;OAEG;IACI,QAAQ,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACF;AAvED,oCAuEC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonValue } from '@fgv/ts-json-base';\nimport { Collections, ICollectible, Result } from '@fgv/ts-utils';\nimport {\n Convert as CommonConvert,\n Validate,\n ResourceTypeIndex,\n ResourceTypeName,\n ResourceValueMergeMethod,\n ResourceId\n} from '../common';\n\n/**\n * Parameters used to validate a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration}.\n * @public\n */\nexport interface IResourceCandidateValidationProperties {\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.id}\n * @public\n */\n id: ResourceId;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.isPartial}\n * @public\n */\n isPartial: boolean;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.json}\n * @public\n */\n json: JsonValue;\n\n /**\n * {@inheritdoc ResourceJson.Json.ILooseResourceCandidateDecl.mergeMethod}\n * @public\n */\n mergeMethod: ResourceValueMergeMethod;\n}\n\n/**\n * Abstract base class for resource types which are responsible for\n * validating and converting JSON values into the appropriate strongly-typed\n * resource value.\n * @public\n */\nexport abstract class ResourceType<T = unknown> implements ICollectible<ResourceTypeName, ResourceTypeIndex> {\n private _collectible: Collections.Collectible<ResourceTypeName, ResourceTypeIndex>;\n /**\n * The key for this resource type.\n */\n public get key(): ResourceTypeName {\n return this._collectible.key;\n }\n\n /**\n * The index for this resource type.\n */\n public get index(): ResourceTypeIndex | undefined {\n return this._collectible.index;\n }\n\n protected constructor(key: ResourceTypeName, index?: number) {\n this._collectible = new Collections.Collectible<ResourceTypeName, ResourceTypeIndex>({\n key,\n /* c8 ignore next 1 - coverage having a rough time */\n index: index !== undefined ? Validate.toResourceTypeIndex(index).orThrow() : undefined,\n indexConverter: CommonConvert.resourceTypeIndex\n });\n }\n\n /**\n * Validates properties of a {@link ResourceJson.Json.ILooseResourceCandidateDecl | resource candidate declaration} for\n * a resource instance value.\n * @param props - The {@link ResourceTypes.IResourceCandidateValidationProperties | properties } to validate.\n * @returns `Success` with the strongly-typed resource value if the JSON and merge method\n * are valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validateDeclaration(props: IResourceCandidateValidationProperties): Result<T | Partial<T>>;\n\n /**\n * Validates a JSON value for use as a partial resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `true` indicates that the value is expected to be partial.\n * @returns `Success` with the strongly-typed partial resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial: true): Result<Partial<T>>;\n\n /**\n * Validates a JSON value for use as a complete resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - `false` indicates that the value is expected to be complete.\n * @returns `Success` with the strongly-typed resource value if the JSON is valid,\n * `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial: false): Result<T>;\n\n /**\n * Validates a JSON value for use as a full or partial resource instance value.\n * @param json - The JSON value to validate.\n * @param isPartial - Indicates whether the value is expected to be partial.\n * @returns `Success` with the strongly-typed full or partial resource value if\n * the JSON is valid, `Failure` with an error message otherwise.\n * @public\n */\n public abstract validate(json: JsonValue, isPartial?: boolean): Result<T | Partial<T>>;\n\n /**\n * Sets the index for this resource type. Once set, the index cannot be changed.\n */\n public setIndex(index: number): Result<ResourceTypeIndex> {\n return this._collectible.setIndex(index);\n }\n}\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ResourceId, ResourceValueMergeMethod } from '../common';
|
|
2
|
+
import * as Context from '../context';
|
|
3
|
+
import * as ResourceJson from '../resource-json';
|
|
4
|
+
import { ResourceCandidate } from './resourceCandidate';
|
|
5
|
+
import { JsonObject } from '@fgv/ts-json-base';
|
|
6
|
+
import { Result } from '@fgv/ts-utils';
|
|
7
|
+
/**
|
|
8
|
+
* Action taken on a candidate during reduction processing.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export type CandidateAction = 'unchanged' | 'reduced' | 'suppressed';
|
|
12
|
+
/**
|
|
13
|
+
* Information about a candidate being processed by the reducer.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface ICandidateInfo {
|
|
17
|
+
readonly originalCandidate: ResourceCandidate;
|
|
18
|
+
action: CandidateAction;
|
|
19
|
+
conditions: ResourceJson.Json.ILooseConditionDecl[];
|
|
20
|
+
conditionSetKey: string;
|
|
21
|
+
readonly json?: JsonObject;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Represents a reduced candidate after applying reduction logic.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export interface IReducedCandidate {
|
|
28
|
+
readonly candidate: ResourceCandidate;
|
|
29
|
+
readonly conditions: ResourceJson.Json.ConditionSetDecl;
|
|
30
|
+
readonly json?: JsonObject;
|
|
31
|
+
readonly isPartial?: boolean;
|
|
32
|
+
readonly mergeMethod?: ResourceValueMergeMethod;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Manages candidate reduction logic for filtering and qualifier reduction operations.
|
|
36
|
+
* Encapsulates the state and logic needed to consistently process candidates for reduction.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare class CandidateReducer {
|
|
40
|
+
private readonly _candidateInfos;
|
|
41
|
+
private readonly _filterForContext;
|
|
42
|
+
private readonly _qualifiersToReduce;
|
|
43
|
+
/**
|
|
44
|
+
* Constructor for CandidateReducer.
|
|
45
|
+
* @param candidates - The set of candidates to potentially reduce
|
|
46
|
+
* @param filterForContext - Context to filter candidates against
|
|
47
|
+
*/
|
|
48
|
+
constructor(candidates: ReadonlyArray<ResourceCandidate>, filterForContext: Context.IValidatedContextDecl);
|
|
49
|
+
/**
|
|
50
|
+
* Computes a string key for a set of condition declarations for collision detection.
|
|
51
|
+
* @param conditions - The conditions to compute a key for
|
|
52
|
+
* @returns A string key representing the condition set
|
|
53
|
+
*/
|
|
54
|
+
private static _computeConditionSetKey;
|
|
55
|
+
/**
|
|
56
|
+
* Merges a partial candidate's JSON value into a base candidate's JSON value.
|
|
57
|
+
* @param baseJson - The base JSON value to merge into
|
|
58
|
+
* @param partialJson - The partial JSON value to merge from
|
|
59
|
+
* @returns The merged JSON value
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
private static _mergeJsonValues;
|
|
63
|
+
/**
|
|
64
|
+
* Resolves collisions using smart collision resolution rules.
|
|
65
|
+
* - If a reduced candidate collides with an unchanged candidate and only one reduced candidate collides:
|
|
66
|
+
* - If reduced candidate is complete: suppress unchanged, keep reduced
|
|
67
|
+
* - If reduced candidate is partial: merge into unchanged, suppress reduced
|
|
68
|
+
* - Otherwise: revert reduced candidates to unchanged to avoid collisions
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
private _resolveCollisions;
|
|
72
|
+
/**
|
|
73
|
+
* Static convenience method to construct an array of properly reduced
|
|
74
|
+
* {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declarations}
|
|
75
|
+
* from a set of {@link Resources.ResourceCandidate | resource candidates}.
|
|
76
|
+
* @param candidates - The candidates to reduce
|
|
77
|
+
* @param filterForContext - Optional context to filter against
|
|
78
|
+
* @returns Result with array of reduced candidate declarations, or Failure if reduction fails
|
|
79
|
+
*/
|
|
80
|
+
static reduceToChildResourceCandidateDecls(candidates: ReadonlyArray<ResourceCandidate>, filterForContext?: Context.IValidatedContextDecl): Result<ResourceJson.Json.IChildResourceCandidateDecl[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Static convenience method to construct an array of properly reduced
|
|
83
|
+
* {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declarations}
|
|
84
|
+
* from a set of {@link Resources.ResourceCandidate | resource candidates}.
|
|
85
|
+
* @param id - The id of the resource
|
|
86
|
+
* @param candidates - The candidates to reduce
|
|
87
|
+
* @param filterForContext - Optional context to filter against
|
|
88
|
+
* @returns Result with array of reduced candidate declarations, or Failure if reduction fails
|
|
89
|
+
*/
|
|
90
|
+
static reduceToLooseResourceCandidateDecls(id: ResourceId, candidates: ReadonlyArray<ResourceCandidate>, filterForContext?: Context.IValidatedContextDecl): Result<ResourceJson.Json.ILooseResourceCandidateDecl[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Reduces a single candidate according to the configured reduction rules.
|
|
93
|
+
* @param candidate - The candidate to reduce
|
|
94
|
+
* @returns Either a reduced candidate declaration or an error if the candidate is not found
|
|
95
|
+
*/
|
|
96
|
+
reduceCandidate(candidate: ResourceCandidate): Result<IReducedCandidate | undefined>;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=candidateReducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidateReducer.d.ts","sourceRoot":"","sources":["../../../src/packlets/resources/candidateReducer.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,UAAU,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAA6B,MAAM,eAAe,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAC9C,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IACpD,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACxD,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACjD;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmB;IACnD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAgC;IAClE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA6B;IAEjE;;;;OAIG;gBAED,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,gBAAgB,EAAE,OAAO,CAAC,qBAAqB;IAiCjD;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAWtC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAW/B;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IA2E1B;;;;;;;OAOG;WACW,mCAAmC,CAC/C,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC,qBAAqB,GAC/C,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC;IAyB1D;;;;;;;;OAQG;WACW,mCAAmC,CAC/C,EAAE,EAAE,UAAU,EACd,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC,qBAAqB,GAC/C,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC;IA0B1D;;;;OAIG;IACI,eAAe,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,GAAG,SAAS,CAAC;CAuB5F"}
|
|
@@ -0,0 +1,247 @@
|
|
|
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.CandidateReducer = void 0;
|
|
25
|
+
const resourceCandidate_1 = require("./resourceCandidate");
|
|
26
|
+
const ts_json_1 = require("@fgv/ts-json");
|
|
27
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
28
|
+
/**
|
|
29
|
+
* Manages candidate reduction logic for filtering and qualifier reduction operations.
|
|
30
|
+
* Encapsulates the state and logic needed to consistently process candidates for reduction.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
class CandidateReducer {
|
|
34
|
+
/**
|
|
35
|
+
* Constructor for CandidateReducer.
|
|
36
|
+
* @param candidates - The set of candidates to potentially reduce
|
|
37
|
+
* @param filterForContext - Context to filter candidates against
|
|
38
|
+
*/
|
|
39
|
+
constructor(candidates, filterForContext) {
|
|
40
|
+
var _a;
|
|
41
|
+
this._filterForContext = filterForContext;
|
|
42
|
+
// Use existing logic to determine reducible qualifiers
|
|
43
|
+
this._qualifiersToReduce =
|
|
44
|
+
(_a = resourceCandidate_1.ResourceCandidate.findReducibleQualifiers(candidates, filterForContext)) !== null && _a !== void 0 ? _a : new Set();
|
|
45
|
+
// Initialize candidate info array with initial reduction attempts
|
|
46
|
+
this._candidateInfos = candidates.map((candidate) => {
|
|
47
|
+
const filteredConditions = candidate.conditions.conditions.filter((c) => !this._qualifiersToReduce.has(c.qualifier.name));
|
|
48
|
+
const reducedConditions = filteredConditions.map((c) => c.toLooseConditionDecl());
|
|
49
|
+
const conditionSetKey = CandidateReducer._computeConditionSetKey(reducedConditions);
|
|
50
|
+
const action = filteredConditions.length < candidate.conditions.conditions.length ? 'reduced' : 'unchanged';
|
|
51
|
+
return {
|
|
52
|
+
originalCandidate: candidate,
|
|
53
|
+
action,
|
|
54
|
+
conditions: reducedConditions,
|
|
55
|
+
conditionSetKey,
|
|
56
|
+
json: undefined // Will be set later when needed
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
// Resolve collisions by reverting reduced candidates to unchanged when they collide
|
|
60
|
+
this._resolveCollisions();
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Computes a string key for a set of condition declarations for collision detection.
|
|
64
|
+
* @param conditions - The conditions to compute a key for
|
|
65
|
+
* @returns A string key representing the condition set
|
|
66
|
+
*/
|
|
67
|
+
static _computeConditionSetKey(conditions) {
|
|
68
|
+
if (conditions.length === 0) {
|
|
69
|
+
return '{}';
|
|
70
|
+
}
|
|
71
|
+
// Sort conditions by qualifier name for consistent keys
|
|
72
|
+
const sortedConditions = [...conditions].sort((a, b) => a.qualifierName.localeCompare(b.qualifierName));
|
|
73
|
+
const pairs = sortedConditions.map((c) => `${c.qualifierName}:${c.value}`);
|
|
74
|
+
return `{${pairs.join(',')}}`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Merges a partial candidate's JSON value into a base candidate's JSON value.
|
|
78
|
+
* @param baseJson - The base JSON value to merge into
|
|
79
|
+
* @param partialJson - The partial JSON value to merge from
|
|
80
|
+
* @returns The merged JSON value
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
static _mergeJsonValues(baseJson, partialJson) {
|
|
84
|
+
// Create JsonEditor with array replacement behavior for candidate merging
|
|
85
|
+
const editor = ts_json_1.JsonEditor.create({
|
|
86
|
+
merge: {
|
|
87
|
+
arrayMergeBehavior: 'replace'
|
|
88
|
+
}
|
|
89
|
+
}).orThrow(); // Should never fail with valid options
|
|
90
|
+
return editor.mergeObjectsInPlace({}, [baseJson, partialJson]).orThrow(); // Internal method should throw on error - this indicates a serious bug
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Resolves collisions using smart collision resolution rules.
|
|
94
|
+
* - If a reduced candidate collides with an unchanged candidate and only one reduced candidate collides:
|
|
95
|
+
* - If reduced candidate is complete: suppress unchanged, keep reduced
|
|
96
|
+
* - If reduced candidate is partial: merge into unchanged, suppress reduced
|
|
97
|
+
* - Otherwise: revert reduced candidates to unchanged to avoid collisions
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
_resolveCollisions() {
|
|
101
|
+
let hasCollisions = true;
|
|
102
|
+
let iterationCount = 0;
|
|
103
|
+
const maxIterations = this._candidateInfos.length; // Safety limit
|
|
104
|
+
while (hasCollisions && iterationCount < maxIterations) {
|
|
105
|
+
hasCollisions = false;
|
|
106
|
+
iterationCount++;
|
|
107
|
+
// Group candidates by their condition set keys (excluding suppressed)
|
|
108
|
+
const conditionKeyGroups = new Map();
|
|
109
|
+
for (const candidateInfo of this._candidateInfos) {
|
|
110
|
+
if (candidateInfo.action !== 'suppressed') {
|
|
111
|
+
// Don't include suppressed candidates
|
|
112
|
+
const key = candidateInfo.conditionSetKey;
|
|
113
|
+
if (!conditionKeyGroups.has(key)) {
|
|
114
|
+
conditionKeyGroups.set(key, []);
|
|
115
|
+
}
|
|
116
|
+
conditionKeyGroups.get(key).push(candidateInfo);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Apply smart collision resolution
|
|
120
|
+
for (const [, candidatesWithSameKey] of conditionKeyGroups) {
|
|
121
|
+
if (candidatesWithSameKey.length > 1) {
|
|
122
|
+
// Categorize candidates
|
|
123
|
+
const unchangedCandidates = candidatesWithSameKey.filter((c) => c.action === 'unchanged');
|
|
124
|
+
const reducedCandidates = candidatesWithSameKey.filter((c) => c.action === 'reduced');
|
|
125
|
+
if (unchangedCandidates.length === 1 && reducedCandidates.length === 1) {
|
|
126
|
+
// Simple case: one unchanged vs one reduced - apply smart resolution
|
|
127
|
+
const unchangedCandidate = unchangedCandidates[0];
|
|
128
|
+
const reducedCandidate = reducedCandidates[0];
|
|
129
|
+
if (!reducedCandidate.originalCandidate.isPartial) {
|
|
130
|
+
// Complete reduced candidate wins - suppress unchanged
|
|
131
|
+
unchangedCandidate.action = 'suppressed';
|
|
132
|
+
hasCollisions = true;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// Partial reduced candidate - merge into unchanged and suppress reduced
|
|
136
|
+
const mergedJson = CandidateReducer._mergeJsonValues(unchangedCandidate.originalCandidate.json, reducedCandidate.originalCandidate.json);
|
|
137
|
+
// Update unchanged candidate with merged JSON, keeping its isPartial status
|
|
138
|
+
unchangedCandidate.json = mergedJson;
|
|
139
|
+
// Suppress the reduced candidate
|
|
140
|
+
reducedCandidate.action = 'suppressed';
|
|
141
|
+
hasCollisions = true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
// Complex collision case - revert all reduced candidates to unchanged
|
|
146
|
+
for (const candidateInfo of reducedCandidates) {
|
|
147
|
+
// Revert to original conditions and mark as unchanged
|
|
148
|
+
const originalConditions = candidateInfo.originalCandidate.conditions.conditions.map((c) => c.toLooseConditionDecl());
|
|
149
|
+
const originalKey = CandidateReducer._computeConditionSetKey(originalConditions);
|
|
150
|
+
// Update the candidate info to revert to original state
|
|
151
|
+
candidateInfo.action = 'unchanged';
|
|
152
|
+
candidateInfo.conditions = originalConditions;
|
|
153
|
+
candidateInfo.conditionSetKey = originalKey;
|
|
154
|
+
hasCollisions = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Static convenience method to construct an array of properly reduced
|
|
163
|
+
* {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declarations}
|
|
164
|
+
* from a set of {@link Resources.ResourceCandidate | resource candidates}.
|
|
165
|
+
* @param candidates - The candidates to reduce
|
|
166
|
+
* @param filterForContext - Optional context to filter against
|
|
167
|
+
* @returns Result with array of reduced candidate declarations, or Failure if reduction fails
|
|
168
|
+
*/
|
|
169
|
+
static reduceToChildResourceCandidateDecls(candidates, filterForContext) {
|
|
170
|
+
if (!filterForContext || Object.keys(filterForContext).length === 0) {
|
|
171
|
+
return (0, ts_utils_1.succeed)(candidates.map((candidate) => candidate.toChildResourceCandidateDecl()));
|
|
172
|
+
}
|
|
173
|
+
const reducer = new CandidateReducer(candidates, filterForContext);
|
|
174
|
+
const reductionResults = (0, ts_utils_1.mapResults)(candidates.map((candidate) => reducer.reduceCandidate(candidate)));
|
|
175
|
+
return reductionResults.onSuccess((reductions) => {
|
|
176
|
+
const validReductions = reductions.filter((reduction) => reduction !== undefined);
|
|
177
|
+
return (0, ts_utils_1.succeed)(validReductions.map((reduction) => {
|
|
178
|
+
var _a, _b, _c;
|
|
179
|
+
return ({
|
|
180
|
+
/* c8 ignore next 3 -- defense in depth */
|
|
181
|
+
json: (_a = reduction.json) !== null && _a !== void 0 ? _a : reduction.candidate.json,
|
|
182
|
+
isPartial: (_b = reduction.isPartial) !== null && _b !== void 0 ? _b : reduction.candidate.isPartial,
|
|
183
|
+
mergeMethod: (_c = reduction.mergeMethod) !== null && _c !== void 0 ? _c : reduction.candidate.mergeMethod,
|
|
184
|
+
conditions: reduction.conditions
|
|
185
|
+
});
|
|
186
|
+
}));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Static convenience method to construct an array of properly reduced
|
|
191
|
+
* {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declarations}
|
|
192
|
+
* from a set of {@link Resources.ResourceCandidate | resource candidates}.
|
|
193
|
+
* @param id - The id of the resource
|
|
194
|
+
* @param candidates - The candidates to reduce
|
|
195
|
+
* @param filterForContext - Optional context to filter against
|
|
196
|
+
* @returns Result with array of reduced candidate declarations, or Failure if reduction fails
|
|
197
|
+
*/
|
|
198
|
+
static reduceToLooseResourceCandidateDecls(id, candidates, filterForContext) {
|
|
199
|
+
if (!filterForContext || Object.keys(filterForContext).length === 0) {
|
|
200
|
+
return (0, ts_utils_1.succeed)(candidates.map((candidate) => candidate.toLooseResourceCandidateDecl()));
|
|
201
|
+
}
|
|
202
|
+
const reducer = new CandidateReducer(candidates, filterForContext);
|
|
203
|
+
const reductionResults = (0, ts_utils_1.mapResults)(candidates.map((candidate) => reducer.reduceCandidate(candidate)));
|
|
204
|
+
return reductionResults.onSuccess((reductions) => {
|
|
205
|
+
const validReductions = reductions.filter((reduction) => reduction !== undefined);
|
|
206
|
+
return (0, ts_utils_1.succeed)(validReductions.map((reduction) => {
|
|
207
|
+
var _a, _b, _c;
|
|
208
|
+
return ({
|
|
209
|
+
id,
|
|
210
|
+
/* c8 ignore next 3 -- defense in depth */
|
|
211
|
+
json: (_a = reduction.json) !== null && _a !== void 0 ? _a : reduction.candidate.json,
|
|
212
|
+
isPartial: (_b = reduction.isPartial) !== null && _b !== void 0 ? _b : reduction.candidate.isPartial,
|
|
213
|
+
mergeMethod: (_c = reduction.mergeMethod) !== null && _c !== void 0 ? _c : reduction.candidate.mergeMethod,
|
|
214
|
+
conditions: reduction.conditions
|
|
215
|
+
});
|
|
216
|
+
}));
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Reduces a single candidate according to the configured reduction rules.
|
|
221
|
+
* @param candidate - The candidate to reduce
|
|
222
|
+
* @returns Either a reduced candidate declaration or an error if the candidate is not found
|
|
223
|
+
*/
|
|
224
|
+
reduceCandidate(candidate) {
|
|
225
|
+
var _a;
|
|
226
|
+
const candidateInfo = this._candidateInfos.find((info) => info.originalCandidate === candidate);
|
|
227
|
+
if (!candidateInfo) {
|
|
228
|
+
return (0, ts_utils_1.fail)(`Candidate not found in reducer state`);
|
|
229
|
+
}
|
|
230
|
+
if (candidateInfo.action === 'suppressed') {
|
|
231
|
+
return (0, ts_utils_1.succeed)(undefined);
|
|
232
|
+
}
|
|
233
|
+
// Convert array of conditions back to ConditionSetDecl for compatibility
|
|
234
|
+
const conditionsAsRecord = candidateInfo.conditions.reduce((acc, condition) => {
|
|
235
|
+
return Object.assign(Object.assign({}, acc), { [condition.qualifierName]: condition.value });
|
|
236
|
+
}, {});
|
|
237
|
+
return (0, ts_utils_1.succeed)({
|
|
238
|
+
candidate,
|
|
239
|
+
conditions: conditionsAsRecord,
|
|
240
|
+
json: (_a = candidateInfo.json) !== null && _a !== void 0 ? _a : candidate.json,
|
|
241
|
+
isPartial: candidate.isPartial,
|
|
242
|
+
mergeMethod: candidate.mergeMethod
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.CandidateReducer = CandidateReducer;
|
|
247
|
+
//# sourceMappingURL=candidateReducer.js.map
|