@fgv/ts-res 5.1.0-3 → 5.1.0-30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.js.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/packlets/bundle/bundleBuilder.js.map +1 -0
- package/dist/packlets/bundle/bundleLoader.js.map +1 -0
- package/dist/packlets/bundle/bundleNormalizer.js.map +1 -0
- package/dist/packlets/bundle/bundleUtils.js.map +1 -0
- package/dist/packlets/bundle/convert.js.map +1 -0
- package/dist/packlets/bundle/index.js.map +1 -0
- package/dist/packlets/bundle/model.js.map +1 -0
- package/dist/packlets/common/conditions.js.map +1 -0
- package/dist/packlets/common/convert.js.map +1 -0
- package/dist/packlets/common/helpers/conditions.js.map +1 -0
- package/dist/packlets/common/helpers/context.js.map +1 -0
- package/dist/packlets/common/helpers/index.js.map +1 -0
- package/dist/packlets/common/helpers/qualifierDefaultValues.js.map +1 -0
- package/dist/packlets/common/helpers/resources.js +2 -4
- package/dist/packlets/common/helpers/resources.js.map +1 -0
- package/dist/packlets/common/index.js.map +1 -0
- package/dist/packlets/common/resources.js.map +1 -0
- package/dist/packlets/common/validate/conditions.js +4 -4
- package/dist/packlets/common/validate/conditions.js.map +1 -0
- package/dist/packlets/common/validate/index.js.map +1 -0
- package/dist/packlets/common/validate/regularExpressions.js +2 -2
- package/dist/packlets/common/validate/regularExpressions.js.map +1 -0
- package/dist/packlets/common/validate/resources.js +1 -1
- package/dist/packlets/common/validate/resources.js.map +1 -0
- package/dist/packlets/conditions/condition.js +3 -7
- package/dist/packlets/conditions/condition.js.map +1 -0
- package/dist/packlets/conditions/conditionCollector.js.map +1 -0
- package/dist/packlets/conditions/conditionDecls.js.map +1 -0
- package/dist/packlets/conditions/conditionSet.js +14 -5
- package/dist/packlets/conditions/conditionSet.js.map +1 -0
- package/dist/packlets/conditions/conditionSetCollector.js.map +1 -0
- package/dist/packlets/conditions/conditionSetDecls.js.map +1 -0
- package/dist/packlets/conditions/conditionToken.js.map +1 -0
- package/dist/packlets/conditions/convert/conditionSetDecls.js +50 -6
- package/dist/packlets/conditions/convert/conditionSetDecls.js.map +1 -0
- package/dist/packlets/conditions/convert/decls.js +61 -5
- package/dist/packlets/conditions/convert/decls.js.map +1 -0
- package/dist/packlets/conditions/convert/index.js.map +1 -0
- package/dist/packlets/conditions/index.js.map +1 -0
- package/dist/packlets/config/common.js.map +1 -0
- package/dist/packlets/config/configInitFactory.js.map +1 -0
- package/dist/packlets/config/convert.js.map +1 -0
- package/dist/packlets/config/index.browser.js.map +1 -0
- package/dist/packlets/config/index.js.map +1 -0
- package/dist/packlets/config/json.js.map +1 -0
- package/dist/packlets/config/predefined/default.js.map +1 -0
- package/dist/packlets/config/predefined/extended.js.map +1 -0
- package/dist/packlets/config/predefined/index.js.map +1 -0
- package/dist/packlets/config/systemConfiguration.js.map +1 -0
- package/dist/packlets/context/contextDecls.js.map +1 -0
- package/dist/packlets/context/contextToken.js.map +1 -0
- package/dist/packlets/context/convert/decls.js.map +1 -0
- package/dist/packlets/context/convert/index.js.map +1 -0
- package/dist/packlets/context/index.js.map +1 -0
- package/dist/packlets/decisions/abstractDecision.js.map +1 -0
- package/dist/packlets/decisions/abstractDecisionCollector.js.map +1 -0
- package/dist/packlets/decisions/candidate.js.map +1 -0
- package/dist/packlets/decisions/common.js.map +1 -0
- package/dist/packlets/decisions/concreteDecision.js.map +1 -0
- package/dist/packlets/decisions/decision.js +1 -1
- package/dist/packlets/decisions/decision.js.map +1 -0
- package/dist/packlets/decisions/index.js.map +1 -0
- package/dist/packlets/import/fsItem.js +1 -4
- package/dist/packlets/import/fsItem.js.map +1 -0
- package/dist/packlets/import/importContext.js +3 -3
- package/dist/packlets/import/importContext.js.map +1 -0
- package/dist/packlets/import/importManager.js +7 -3
- package/dist/packlets/import/importManager.js.map +1 -0
- package/dist/packlets/import/importable.js.map +1 -0
- package/dist/packlets/import/importers/collectionImporter.js +2 -2
- package/dist/packlets/import/importers/collectionImporter.js.map +1 -0
- package/dist/packlets/import/importers/fsItemImporter.js +30 -14
- package/dist/packlets/import/importers/fsItemImporter.js.map +1 -0
- package/dist/packlets/import/importers/importer.js.map +1 -0
- package/dist/packlets/import/importers/index.browser.js.map +1 -0
- package/dist/packlets/import/importers/index.js.map +1 -0
- package/dist/packlets/import/importers/jsonImporter.js +2 -2
- package/dist/packlets/import/importers/jsonImporter.js.map +1 -0
- package/dist/packlets/import/importers/pathImporter.js +1 -1
- package/dist/packlets/import/importers/pathImporter.js.map +1 -0
- package/dist/packlets/import/index.browser.js.map +1 -0
- package/dist/packlets/import/index.js.map +1 -0
- package/dist/packlets/qualifier-types/config/convert.js.map +1 -0
- package/dist/packlets/qualifier-types/config/index.js.map +1 -0
- package/dist/packlets/qualifier-types/config/json.js.map +1 -0
- package/dist/packlets/qualifier-types/convert.js.map +1 -0
- package/dist/packlets/qualifier-types/helpers.js.map +1 -0
- package/dist/packlets/qualifier-types/index.js.map +1 -0
- package/dist/packlets/qualifier-types/languageQualifierType.js +6 -7
- package/dist/packlets/qualifier-types/languageQualifierType.js.map +1 -0
- package/dist/packlets/qualifier-types/literalQualifierType.js +7 -10
- package/dist/packlets/qualifier-types/literalQualifierType.js.map +1 -0
- package/dist/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
- package/dist/packlets/qualifier-types/qualifierType.js +12 -13
- package/dist/packlets/qualifier-types/qualifierType.js.map +1 -0
- package/dist/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -0
- package/dist/packlets/qualifier-types/territoryQualifierType.js +5 -5
- package/dist/packlets/qualifier-types/territoryQualifierType.js.map +1 -0
- package/dist/packlets/qualifiers/convert/decls.js.map +1 -0
- package/dist/packlets/qualifiers/convert/index.js.map +1 -0
- package/dist/packlets/qualifiers/convert/qualifier.js.map +1 -0
- package/dist/packlets/qualifiers/index.js.map +1 -0
- package/dist/packlets/qualifiers/qualifier.js +6 -7
- package/dist/packlets/qualifiers/qualifier.js.map +1 -0
- package/dist/packlets/qualifiers/qualifierCollector.js +153 -9
- package/dist/packlets/qualifiers/qualifierCollector.js.map +1 -0
- package/dist/packlets/qualifiers/qualifierDecl.js.map +1 -0
- package/dist/packlets/qualifiers/qualifierDefaultValueDecls.js.map +1 -0
- package/dist/packlets/qualifiers/qualifierDefaultValueToken.js.map +1 -0
- package/dist/packlets/resource-json/compiled/common.js.map +1 -0
- package/dist/packlets/resource-json/compiled/convert.js.map +1 -0
- package/dist/packlets/resource-json/compiled/index.js.map +1 -0
- package/dist/packlets/resource-json/compiled/json.js.map +1 -0
- package/dist/packlets/resource-json/convert.js +225 -0
- package/dist/packlets/resource-json/convert.js.map +1 -0
- package/dist/packlets/resource-json/helpers.js.map +1 -0
- package/dist/packlets/resource-json/index.js.map +1 -0
- package/dist/packlets/resource-json/json.js +2 -2
- package/dist/packlets/resource-json/json.js.map +1 -0
- package/dist/packlets/resource-json/normalized.js.map +1 -0
- package/dist/packlets/resource-json/resourceDeclCollection.js +1 -1
- package/dist/packlets/resource-json/resourceDeclCollection.js.map +1 -0
- package/dist/packlets/resource-json/resourceDeclContainer.js.map +1 -0
- package/dist/packlets/resource-json/resourceDeclTree.js +1 -1
- package/dist/packlets/resource-json/resourceDeclTree.js.map +1 -0
- package/dist/packlets/resource-types/config/convert.js.map +1 -0
- package/dist/packlets/resource-types/config/index.js.map +1 -0
- package/dist/packlets/resource-types/config/json.js.map +1 -0
- package/dist/packlets/resource-types/helpers.js.map +1 -0
- package/dist/packlets/resource-types/index.js.map +1 -0
- package/dist/packlets/resource-types/jsonResourceType.js +2 -2
- package/dist/packlets/resource-types/jsonResourceType.js.map +1 -0
- package/dist/packlets/resource-types/resourceType.js +2 -2
- package/dist/packlets/resource-types/resourceType.js.map +1 -0
- package/dist/packlets/resource-types/resourceTypeCollector.js.map +1 -0
- package/dist/packlets/resources/candidateReducer.js.map +1 -0
- package/dist/packlets/resources/candidateValue.js.map +1 -0
- package/dist/packlets/resources/candidateValueCollector.js.map +1 -0
- package/dist/packlets/resources/common.js.map +1 -0
- package/dist/packlets/resources/deltaGenerator.js.map +1 -0
- package/dist/packlets/resources/index.js.map +1 -0
- package/dist/packlets/resources/resource.js.map +1 -0
- package/dist/packlets/resources/resourceBuilder.js +2 -2
- package/dist/packlets/resources/resourceBuilder.js.map +1 -0
- package/dist/packlets/resources/resourceCandidate.js.map +1 -0
- package/dist/packlets/resources/resourceManagerBuilder.js +5 -5
- package/dist/packlets/resources/resourceManagerBuilder.js.map +1 -0
- package/dist/packlets/runtime/cacheListener.js.map +1 -0
- package/dist/packlets/runtime/cacheMetrics.js.map +1 -0
- package/dist/packlets/runtime/compiledResourceCollection.js +5 -5
- package/dist/packlets/runtime/compiledResourceCollection.js.map +1 -0
- package/dist/packlets/runtime/conditionSetResolutionResult.js.map +1 -0
- package/dist/packlets/runtime/context/contextQualifierProvider.js.map +1 -0
- package/dist/packlets/runtime/context/contextQualifierProviderValidator.js.map +1 -0
- package/dist/packlets/runtime/context/index.js.map +1 -0
- package/dist/packlets/runtime/context/simpleContextQualifierProvider.js +3 -0
- package/dist/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -0
- package/dist/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +3 -5
- package/dist/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -0
- package/dist/packlets/runtime/iResourceManager.js.map +1 -0
- package/dist/packlets/runtime/index.js.map +1 -0
- package/dist/packlets/runtime/resource-tree/common.js.map +1 -0
- package/dist/packlets/runtime/resource-tree/index.js.map +1 -0
- package/dist/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +1 -0
- package/dist/packlets/runtime/resource-tree/resourceTreeChildren.js.map +1 -0
- package/dist/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +1 -0
- package/dist/packlets/runtime/resourceResolver.js.map +1 -0
- package/dist/packlets/runtime/resourceTreeResolver.js.map +1 -0
- package/dist/packlets/runtime/validate.js.map +1 -0
- package/dist/packlets/zip-archive/convert.js.map +1 -0
- package/dist/packlets/zip-archive/index.browser.js.map +1 -0
- package/dist/packlets/zip-archive/index.js.map +1 -0
- package/dist/packlets/zip-archive/json.js.map +1 -0
- package/dist/packlets/zip-archive/types.js.map +1 -0
- package/dist/packlets/zip-archive/zipArchiveCreator.js.map +1 -0
- package/dist/packlets/zip-archive/zipArchiveFormat.js.map +1 -0
- package/dist/packlets/zip-archive/zipArchiveLoader.js.map +1 -0
- package/dist/ts-res.d.ts +576 -164
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.browser.d.ts.map +1 -0
- package/lib/index.browser.js.map +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js.map +1 -0
- package/lib/packlets/bundle/bundleBuilder.d.ts.map +1 -0
- package/lib/packlets/bundle/bundleBuilder.js.map +1 -0
- package/lib/packlets/bundle/bundleLoader.d.ts.map +1 -0
- package/lib/packlets/bundle/bundleLoader.js.map +1 -0
- package/lib/packlets/bundle/bundleNormalizer.d.ts.map +1 -0
- package/lib/packlets/bundle/bundleNormalizer.js.map +1 -0
- package/lib/packlets/bundle/bundleUtils.d.ts.map +1 -0
- package/lib/packlets/bundle/bundleUtils.js.map +1 -0
- package/lib/packlets/bundle/convert.d.ts.map +1 -0
- package/lib/packlets/bundle/convert.js.map +1 -0
- package/lib/packlets/bundle/index.d.ts.map +1 -0
- package/lib/packlets/bundle/index.js.map +1 -0
- package/lib/packlets/bundle/model.d.ts.map +1 -0
- package/lib/packlets/bundle/model.js.map +1 -0
- package/lib/packlets/common/conditions.d.ts.map +1 -0
- package/lib/packlets/common/conditions.js.map +1 -0
- package/lib/packlets/common/convert.d.ts.map +1 -0
- package/lib/packlets/common/convert.js.map +1 -0
- package/lib/packlets/common/helpers/conditions.d.ts.map +1 -0
- package/lib/packlets/common/helpers/conditions.js.map +1 -0
- package/lib/packlets/common/helpers/context.d.ts.map +1 -0
- package/lib/packlets/common/helpers/context.js.map +1 -0
- package/lib/packlets/common/helpers/index.d.ts.map +1 -0
- package/lib/packlets/common/helpers/index.js.map +1 -0
- package/lib/packlets/common/helpers/qualifierDefaultValues.d.ts.map +1 -0
- package/lib/packlets/common/helpers/qualifierDefaultValues.js.map +1 -0
- package/lib/packlets/common/helpers/resources.d.ts +2 -4
- package/lib/packlets/common/helpers/resources.d.ts.map +1 -0
- package/lib/packlets/common/helpers/resources.js +2 -4
- package/lib/packlets/common/helpers/resources.js.map +1 -0
- package/lib/packlets/common/index.d.ts.map +1 -0
- package/lib/packlets/common/index.js.map +1 -0
- package/lib/packlets/common/resources.d.ts.map +1 -0
- package/lib/packlets/common/resources.js.map +1 -0
- package/lib/packlets/common/validate/conditions.d.ts +4 -4
- package/lib/packlets/common/validate/conditions.d.ts.map +1 -0
- package/lib/packlets/common/validate/conditions.js +4 -4
- package/lib/packlets/common/validate/conditions.js.map +1 -0
- package/lib/packlets/common/validate/index.d.ts.map +1 -0
- package/lib/packlets/common/validate/index.js.map +1 -0
- package/lib/packlets/common/validate/regularExpressions.d.ts +2 -2
- package/lib/packlets/common/validate/regularExpressions.d.ts.map +1 -0
- package/lib/packlets/common/validate/regularExpressions.js +2 -2
- package/lib/packlets/common/validate/regularExpressions.js.map +1 -0
- package/lib/packlets/common/validate/resources.d.ts +1 -1
- package/lib/packlets/common/validate/resources.d.ts.map +1 -0
- package/lib/packlets/common/validate/resources.js +1 -1
- package/lib/packlets/common/validate/resources.js.map +1 -0
- package/lib/packlets/conditions/condition.d.ts +3 -7
- package/lib/packlets/conditions/condition.d.ts.map +1 -0
- package/lib/packlets/conditions/condition.js +3 -7
- package/lib/packlets/conditions/condition.js.map +1 -0
- package/lib/packlets/conditions/conditionCollector.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionCollector.js.map +1 -0
- package/lib/packlets/conditions/conditionDecls.d.ts +6 -1
- package/lib/packlets/conditions/conditionDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionDecls.js.map +1 -0
- package/lib/packlets/conditions/conditionSet.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSet.js +14 -5
- package/lib/packlets/conditions/conditionSet.js.map +1 -0
- package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSetCollector.js.map +1 -0
- package/lib/packlets/conditions/conditionSetDecls.d.ts +7 -2
- package/lib/packlets/conditions/conditionSetDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSetDecls.js.map +1 -0
- package/lib/packlets/conditions/conditionToken.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionToken.js.map +1 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.d.ts +30 -2
- package/lib/packlets/conditions/convert/conditionSetDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.js +51 -5
- package/lib/packlets/conditions/convert/conditionSetDecls.js.map +1 -0
- package/lib/packlets/conditions/convert/decls.d.ts +39 -3
- package/lib/packlets/conditions/convert/decls.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/decls.js +63 -5
- package/lib/packlets/conditions/convert/decls.js.map +1 -0
- package/lib/packlets/conditions/convert/index.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/index.js.map +1 -0
- package/lib/packlets/conditions/index.d.ts.map +1 -0
- package/lib/packlets/conditions/index.js.map +1 -0
- package/lib/packlets/config/common.d.ts.map +1 -0
- package/lib/packlets/config/common.js.map +1 -0
- package/lib/packlets/config/configInitFactory.d.ts.map +1 -0
- package/lib/packlets/config/configInitFactory.js.map +1 -0
- package/lib/packlets/config/convert.d.ts.map +1 -0
- package/lib/packlets/config/convert.js.map +1 -0
- package/lib/packlets/config/index.browser.d.ts.map +1 -0
- package/lib/packlets/config/index.browser.js.map +1 -0
- package/lib/packlets/config/index.d.ts.map +1 -0
- package/lib/packlets/config/index.js.map +1 -0
- package/lib/packlets/config/json.d.ts.map +1 -0
- package/lib/packlets/config/json.js.map +1 -0
- package/lib/packlets/config/predefined/default.d.ts.map +1 -0
- package/lib/packlets/config/predefined/default.js.map +1 -0
- package/lib/packlets/config/predefined/extended.d.ts.map +1 -0
- package/lib/packlets/config/predefined/extended.js.map +1 -0
- package/lib/packlets/config/predefined/index.d.ts.map +1 -0
- package/lib/packlets/config/predefined/index.js.map +1 -0
- package/lib/packlets/config/systemConfiguration.d.ts.map +1 -0
- package/lib/packlets/config/systemConfiguration.js.map +1 -0
- package/lib/packlets/context/contextDecls.d.ts.map +1 -0
- package/lib/packlets/context/contextDecls.js.map +1 -0
- package/lib/packlets/context/contextToken.d.ts.map +1 -0
- package/lib/packlets/context/contextToken.js.map +1 -0
- package/lib/packlets/context/convert/decls.d.ts.map +1 -0
- package/lib/packlets/context/convert/decls.js.map +1 -0
- package/lib/packlets/context/convert/index.d.ts.map +1 -0
- package/lib/packlets/context/convert/index.js.map +1 -0
- package/lib/packlets/context/index.d.ts.map +1 -0
- package/lib/packlets/context/index.js.map +1 -0
- package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -0
- package/lib/packlets/decisions/abstractDecision.js.map +1 -0
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -0
- package/lib/packlets/decisions/candidate.d.ts.map +1 -0
- package/lib/packlets/decisions/candidate.js.map +1 -0
- package/lib/packlets/decisions/common.d.ts.map +1 -0
- package/lib/packlets/decisions/common.js.map +1 -0
- package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -0
- package/lib/packlets/decisions/concreteDecision.js.map +1 -0
- package/lib/packlets/decisions/decision.d.ts +1 -1
- package/lib/packlets/decisions/decision.d.ts.map +1 -0
- package/lib/packlets/decisions/decision.js +1 -1
- package/lib/packlets/decisions/decision.js.map +1 -0
- package/lib/packlets/decisions/index.d.ts.map +1 -0
- package/lib/packlets/decisions/index.js.map +1 -0
- package/lib/packlets/import/fsItem.d.ts +1 -4
- package/lib/packlets/import/fsItem.d.ts.map +1 -0
- package/lib/packlets/import/fsItem.js +1 -4
- package/lib/packlets/import/fsItem.js.map +1 -0
- package/lib/packlets/import/importContext.d.ts +5 -5
- package/lib/packlets/import/importContext.d.ts.map +1 -0
- package/lib/packlets/import/importContext.js +3 -3
- package/lib/packlets/import/importContext.js.map +1 -0
- package/lib/packlets/import/importManager.d.ts +15 -1
- package/lib/packlets/import/importManager.d.ts.map +1 -0
- package/lib/packlets/import/importManager.js +7 -3
- package/lib/packlets/import/importManager.js.map +1 -0
- package/lib/packlets/import/importable.d.ts.map +1 -0
- package/lib/packlets/import/importable.js.map +1 -0
- package/lib/packlets/import/importers/collectionImporter.d.ts +2 -2
- package/lib/packlets/import/importers/collectionImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/collectionImporter.js +2 -2
- package/lib/packlets/import/importers/collectionImporter.js.map +1 -0
- package/lib/packlets/import/importers/fsItemImporter.d.ts +16 -2
- package/lib/packlets/import/importers/fsItemImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/fsItemImporter.js +29 -13
- package/lib/packlets/import/importers/fsItemImporter.js.map +1 -0
- package/lib/packlets/import/importers/importer.d.ts.map +1 -0
- package/lib/packlets/import/importers/importer.js.map +1 -0
- package/lib/packlets/import/importers/index.browser.d.ts.map +1 -0
- package/lib/packlets/import/importers/index.browser.js.map +1 -0
- package/lib/packlets/import/importers/index.d.ts.map +1 -0
- package/lib/packlets/import/importers/index.js.map +1 -0
- package/lib/packlets/import/importers/jsonImporter.d.ts +2 -2
- package/lib/packlets/import/importers/jsonImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/jsonImporter.js +2 -2
- package/lib/packlets/import/importers/jsonImporter.js.map +1 -0
- package/lib/packlets/import/importers/pathImporter.d.ts +1 -1
- package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/pathImporter.js +1 -1
- package/lib/packlets/import/importers/pathImporter.js.map +1 -0
- package/lib/packlets/import/index.browser.d.ts.map +1 -0
- package/lib/packlets/import/index.browser.js.map +1 -0
- package/lib/packlets/import/index.d.ts.map +1 -0
- package/lib/packlets/import/index.js.map +1 -0
- package/lib/packlets/qualifier-types/config/convert.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/convert.js.map +1 -0
- package/lib/packlets/qualifier-types/config/index.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/index.js.map +1 -0
- package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/json.js.map +1 -0
- package/lib/packlets/qualifier-types/convert.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/convert.js.map +1 -0
- package/lib/packlets/qualifier-types/helpers.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/helpers.js.map +1 -0
- package/lib/packlets/qualifier-types/index.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/index.js.map +1 -0
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +6 -7
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/languageQualifierType.js +6 -7
- package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +7 -10
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/literalQualifierType.js +7 -10
- package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/literalValueHierarchy.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts +17 -18
- package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.js +12 -13
- package/lib/packlets/qualifier-types/qualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +8 -8
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.js +5 -5
- package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -0
- package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/decls.js.map +1 -0
- package/lib/packlets/qualifiers/convert/index.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/index.js.map +1 -0
- package/lib/packlets/qualifiers/convert/qualifier.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/qualifier.js.map +1 -0
- package/lib/packlets/qualifiers/index.d.ts.map +1 -0
- package/lib/packlets/qualifiers/index.js.map +1 -0
- package/lib/packlets/qualifiers/qualifier.d.ts +6 -7
- package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifier.js +6 -7
- package/lib/packlets/qualifiers/qualifier.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierCollector.d.ts +107 -9
- package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierCollector.js +152 -8
- package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDecl.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueDecls.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDefaultValueToken.js.map +1 -0
- package/lib/packlets/resource-json/compiled/common.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/common.js.map +1 -0
- package/lib/packlets/resource-json/compiled/convert.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/convert.js.map +1 -0
- package/lib/packlets/resource-json/compiled/index.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/index.js.map +1 -0
- package/lib/packlets/resource-json/compiled/json.d.ts.map +1 -0
- package/lib/packlets/resource-json/compiled/json.js.map +1 -0
- package/lib/packlets/resource-json/convert.d.ts +85 -0
- package/lib/packlets/resource-json/convert.d.ts.map +1 -0
- package/lib/packlets/resource-json/convert.js +237 -0
- package/lib/packlets/resource-json/convert.js.map +1 -0
- package/lib/packlets/resource-json/helpers.d.ts.map +1 -0
- package/lib/packlets/resource-json/helpers.js.map +1 -0
- package/lib/packlets/resource-json/index.d.ts.map +1 -0
- package/lib/packlets/resource-json/index.js.map +1 -0
- package/lib/packlets/resource-json/json.d.ts +128 -39
- package/lib/packlets/resource-json/json.d.ts.map +1 -0
- package/lib/packlets/resource-json/json.js +2 -2
- package/lib/packlets/resource-json/json.js.map +1 -0
- package/lib/packlets/resource-json/normalized.d.ts.map +1 -0
- package/lib/packlets/resource-json/normalized.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts +1 -1
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclCollection.js +1 -1
- package/lib/packlets/resource-json/resourceDeclCollection.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclContainer.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclTree.d.ts +1 -1
- package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclTree.js +1 -1
- package/lib/packlets/resource-json/resourceDeclTree.js.map +1 -0
- package/lib/packlets/resource-types/config/convert.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/convert.js.map +1 -0
- package/lib/packlets/resource-types/config/index.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/index.js.map +1 -0
- package/lib/packlets/resource-types/config/json.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/json.js.map +1 -0
- package/lib/packlets/resource-types/helpers.d.ts.map +1 -0
- package/lib/packlets/resource-types/helpers.js.map +1 -0
- package/lib/packlets/resource-types/index.d.ts.map +1 -0
- package/lib/packlets/resource-types/index.js.map +1 -0
- package/lib/packlets/resource-types/jsonResourceType.d.ts +17 -5
- package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -0
- package/lib/packlets/resource-types/jsonResourceType.js +2 -2
- package/lib/packlets/resource-types/jsonResourceType.js.map +1 -0
- package/lib/packlets/resource-types/resourceType.d.ts +5 -5
- package/lib/packlets/resource-types/resourceType.d.ts.map +1 -0
- package/lib/packlets/resource-types/resourceType.js +2 -2
- package/lib/packlets/resource-types/resourceType.js.map +1 -0
- package/lib/packlets/resource-types/resourceTypeCollector.d.ts.map +1 -0
- package/lib/packlets/resource-types/resourceTypeCollector.js.map +1 -0
- package/lib/packlets/resources/candidateReducer.d.ts.map +1 -0
- package/lib/packlets/resources/candidateReducer.js.map +1 -0
- package/lib/packlets/resources/candidateValue.d.ts.map +1 -0
- package/lib/packlets/resources/candidateValue.js.map +1 -0
- package/lib/packlets/resources/candidateValueCollector.d.ts.map +1 -0
- package/lib/packlets/resources/candidateValueCollector.js.map +1 -0
- package/lib/packlets/resources/common.d.ts.map +1 -0
- package/lib/packlets/resources/common.js.map +1 -0
- package/lib/packlets/resources/deltaGenerator.d.ts.map +1 -0
- package/lib/packlets/resources/deltaGenerator.js.map +1 -0
- package/lib/packlets/resources/index.d.ts.map +1 -0
- package/lib/packlets/resources/index.js.map +1 -0
- package/lib/packlets/resources/resource.d.ts.map +1 -0
- package/lib/packlets/resources/resource.js.map +1 -0
- package/lib/packlets/resources/resourceBuilder.d.ts +2 -2
- package/lib/packlets/resources/resourceBuilder.d.ts.map +1 -0
- package/lib/packlets/resources/resourceBuilder.js +2 -2
- package/lib/packlets/resources/resourceBuilder.js.map +1 -0
- package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -0
- package/lib/packlets/resources/resourceCandidate.js.map +1 -0
- package/lib/packlets/resources/resourceManagerBuilder.d.ts +5 -5
- package/lib/packlets/resources/resourceManagerBuilder.d.ts.map +1 -0
- package/lib/packlets/resources/resourceManagerBuilder.js +5 -5
- package/lib/packlets/resources/resourceManagerBuilder.js.map +1 -0
- package/lib/packlets/runtime/cacheListener.d.ts.map +1 -0
- package/lib/packlets/runtime/cacheListener.js.map +1 -0
- package/lib/packlets/runtime/cacheMetrics.d.ts.map +1 -0
- package/lib/packlets/runtime/cacheMetrics.js.map +1 -0
- package/lib/packlets/runtime/compiledResourceCollection.d.ts +5 -5
- package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +1 -0
- package/lib/packlets/runtime/compiledResourceCollection.js +5 -5
- package/lib/packlets/runtime/compiledResourceCollection.js.map +1 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.d.ts.map +1 -0
- package/lib/packlets/runtime/conditionSetResolutionResult.js.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.d.ts.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.d.ts.map +1 -0
- package/lib/packlets/runtime/context/contextQualifierProviderValidator.js.map +1 -0
- package/lib/packlets/runtime/context/index.d.ts.map +1 -0
- package/lib/packlets/runtime/context/index.js.map +1 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +9 -2
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +1 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +3 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +8 -1
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +1 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +3 -5
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/iResourceManager.d.ts.map +1 -0
- package/lib/packlets/runtime/iResourceManager.js.map +1 -0
- package/lib/packlets/runtime/index.d.ts.map +1 -0
- package/lib/packlets/runtime/index.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/common.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/common.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/index.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/index.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/readOnlyResourceTree.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildren.js.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.d.ts.map +1 -0
- package/lib/packlets/runtime/resource-tree/resourceTreeChildrenValidator.js.map +1 -0
- package/lib/packlets/runtime/resourceResolver.d.ts.map +1 -0
- package/lib/packlets/runtime/resourceResolver.js.map +1 -0
- package/lib/packlets/runtime/resourceTreeResolver.d.ts.map +1 -0
- package/lib/packlets/runtime/resourceTreeResolver.js.map +1 -0
- package/lib/packlets/runtime/validate.d.ts.map +1 -0
- package/lib/packlets/runtime/validate.js.map +1 -0
- package/lib/packlets/zip-archive/convert.d.ts.map +1 -0
- package/lib/packlets/zip-archive/convert.js.map +1 -0
- package/lib/packlets/zip-archive/index.browser.d.ts.map +1 -0
- package/lib/packlets/zip-archive/index.browser.js.map +1 -0
- package/lib/packlets/zip-archive/index.d.ts.map +1 -0
- package/lib/packlets/zip-archive/index.js.map +1 -0
- package/lib/packlets/zip-archive/json.d.ts.map +1 -0
- package/lib/packlets/zip-archive/json.js.map +1 -0
- package/lib/packlets/zip-archive/types.d.ts.map +1 -0
- package/lib/packlets/zip-archive/types.js.map +1 -0
- package/lib/packlets/zip-archive/zipArchiveCreator.d.ts.map +1 -0
- package/lib/packlets/zip-archive/zipArchiveCreator.js.map +1 -0
- package/lib/packlets/zip-archive/zipArchiveFormat.d.ts.map +1 -0
- package/lib/packlets/zip-archive/zipArchiveFormat.js.map +1 -0
- package/lib/packlets/zip-archive/zipArchiveLoader.d.ts.map +1 -0
- package/lib/packlets/zip-archive/zipArchiveLoader.js.map +1 -0
- package/package.json +12 -10
- package/dist/test/data/sample.json +0 -32
- package/dist/test/unit/qualifier-types/testQualifierType.js +0 -76
- package/dist/test/unit/resource-types/testDerivedResourceType.js +0 -109
- package/dist/test/unit/resources/deltaGenerator.helpers.js +0 -282
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionCollector.js","sourceRoot":"","sources":["../../../src/packlets/conditions/conditionCollector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAU,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGjG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAgB,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAmBnD;;;;;GAKG;AACH,MAAM,OAAO,kBAAmB,SAAQ,mBAA8B;IAQpE;;;;OAIG;IACH,YAAsB,MAAuC;;QAC3D,KAAK,CAAC;YACJ,UAAU,EAAE,IAAI,WAAW,CAAC,kBAAkB,CAA0B;gBACtE,GAAG,EAAE,aAAa,CAAC,YAAY;gBAC/B,KAAK,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;aAClD,CAAC;SACH,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,8CAA8C;QAC9C,MAAA,MAAM,CAAC,UAAU,0CAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,MAAuC;QAC1D,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC;IAEO,YAAY,CAAC,IAAa;QAChC,IAAI,IAAI,YAAY,SAAS,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,sBAAsB;aAC1B,OAAO,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;aACzE,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;CACF","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 { captureResult, Collections, Result, succeed, ValidatingCollector } from '@fgv/ts-utils';\nimport { IReadOnlyQualifierCollector } from '../qualifiers';\nimport { IConditionDecl } from './conditionDecls';\nimport { Condition } from './condition';\nimport { Convert as CommonConvert, ConditionKey } from '../common';\nimport { validatedConditionDecl } from './convert';\n\n/**\n * Parameters for creating a {@link Conditions.ConditionCollector | ConditionCollector}.\n * @public\n */\nexport interface IConditionCollectorCreateParams {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | ReadOnlyQualifierCollector} used to\n * create conditions in this collector.\n */\n qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Optional array of condition declarations to add to the collector.\n */\n conditions?: IConditionDecl[];\n}\n\n/**\n * A `ValidatingCollector` for {@link Conditions.Condition | Conditions},\n * which collects conditions supplied as either {@link Conditions.Condition | Condition} or\n * {@link Conditions.IConditionDecl | IConditionDecl}.\n * @public\n */\nexport class ConditionCollector extends ValidatingCollector<Condition> {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | ReadOnlyQualifierCollector} used to create conditions\n * in this collector.\n * @public\n */\n public qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Constructor for a {@link Conditions.ConditionCollector | ConditionCollector} object.\n * @param params - Required {@link Conditions.IConditionCollectorCreateParams | parameters} for\n * creating the collector.\n */\n protected constructor(params: IConditionCollectorCreateParams) {\n super({\n converters: new Collections.KeyValueConverters<ConditionKey, Condition>({\n key: CommonConvert.conditionKey,\n value: (from: unknown) => this._toCondition(from)\n })\n });\n this.qualifiers = params.qualifiers;\n /* c8 ignore next 1 - ? is defense in depth */\n params.conditions?.forEach((c) => this.validating.add(c).orThrow());\n }\n\n /**\n * Creates a new {@link Conditions.ConditionCollector | ConditionCollector} object.\n * @param params - Required {@link Conditions.IConditionCollectorCreateParams | parameters} for\n * creating the collector.\n * @returns `Success` with the new collector if successful, or `Failure` with\n * an error message if not.\n */\n public static create(params: IConditionCollectorCreateParams): Result<ConditionCollector> {\n return captureResult(() => new ConditionCollector(params));\n }\n\n private _toCondition(from: unknown): Result<Condition> {\n if (from instanceof Condition) {\n return succeed(from);\n }\n return validatedConditionDecl\n .convert(from, { qualifiers: this.qualifiers, conditionIndex: this.size })\n .onSuccess((c) => Condition.create(c));\n }\n}\n\n/**\n * Type alias for a read-only {@link Conditions.ConditionCollector | ConditionCollector}.\n * @public\n */\nexport type ReadOnlyConditionCollector = Collections.IReadOnlyValidatingCollector<Condition>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionDecls.js","sourceRoot":"","sources":["../../../src/packlets/conditions/conditionDecls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","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 {\n ConditionIndex,\n ConditionOperator,\n ConditionPriority,\n QualifierConditionValue,\n QualifierMatchScore\n} from '../common';\nimport { Qualifier } from '../qualifiers';\nimport * as ResourceJson from '../resource-json';\n\n/**\n * Non-validated declaration of a {@link Conditions.Condition | condition}.\n *\n * @remarks\n * Parameterized on `TQualifierNames` (defaulting to `string`) so consumers\n * authoring conditions in code can opt into compile-time axis-name discipline.\n *\n * @public\n */\nexport type IConditionDecl<TQualifierNames extends string = string> =\n ResourceJson.Json.ILooseConditionDecl<TQualifierNames>;\n\n/**\n * Validated declaration of a {@link Conditions.Condition | condition} with all defaults applied.\n * @public\n */\nexport interface IValidatedConditionDecl {\n qualifier: Qualifier;\n value: QualifierConditionValue;\n operator: ConditionOperator;\n priority: ConditionPriority;\n scoreAsDefault?: QualifierMatchScore;\n index?: ConditionIndex;\n}\n"]}
|
|
@@ -145,16 +145,25 @@ export class ConditionSet {
|
|
|
145
145
|
conditionSetDecl = { conditions: conditionSet };
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
|
-
// ConditionSetDeclAsRecord: Record<string, string | IChildConditionDecl
|
|
149
|
-
|
|
148
|
+
// ConditionSetDeclAsRecord: Readonly<Partial<Record<string, string | IChildConditionDecl>>>.
|
|
149
|
+
// The record-form type is `Readonly<Partial<Record<..., V>>>`, so
|
|
150
|
+
// `Object.entries` produces `[string, V | undefined]` — runtime
|
|
151
|
+
// `undefined` values (a key explicitly set to undefined) skip;
|
|
152
|
+
// they're semantically equivalent to omitting the key.
|
|
153
|
+
const conditions = [];
|
|
154
|
+
for (const [qualifierName, value] of Object.entries(conditionSet)) {
|
|
155
|
+
/* c8 ignore next 3 - defensive: explicit-undefined-value entries skipped */
|
|
156
|
+
if (value === undefined) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
150
159
|
if (typeof value === 'string') {
|
|
151
|
-
|
|
160
|
+
conditions.push({ qualifierName, value });
|
|
152
161
|
/* c8 ignore next 3 - edge case */
|
|
153
162
|
}
|
|
154
163
|
else {
|
|
155
|
-
|
|
164
|
+
conditions.push(Object.assign({ qualifierName }, value));
|
|
156
165
|
}
|
|
157
|
-
}
|
|
166
|
+
}
|
|
158
167
|
conditionSetDecl = { conditions };
|
|
159
168
|
}
|
|
160
169
|
// Validate and convert to IValidatedConditionSetDecl
|
|
@@ -0,0 +1 @@
|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,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAM,CAAC,IAC7C,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,MAAK,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAC7E;IACJ,CAAC;;AA/OD;;GAEG;AACW,6BAAgB,GAAoB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC","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 { captureResult, Collections, Hash, mapResults, Result, succeed } from '@fgv/ts-utils';\nimport { Condition } from './condition';\nimport {\n Convert as CommonConvert,\n ConditionSetIndex,\n ConditionSetKey,\n QualifierName,\n Validate\n} from '../common';\nimport { IValidatedConditionSetDecl } from './conditionSetDecls';\nimport * as ConditionsConvert from './convert';\nimport { ConditionCollector } from './conditionCollector';\nimport * as ResourceJson from '../resource-json';\nimport * as Context from '../context';\n\n/**\n * Options for creating a {@link Conditions.ConditionSet | ConditionSet} declaration.\n * @remarks\n * This interface extends the {@link ResourceJson.Helpers.IDeclarationOptions | declaration options}\n * interface to include a `reduceQualifiers` option.\n * @public\n */\nexport interface IConditionSetDeclOptions extends ResourceJson.Helpers.IDeclarationOptions {\n /**\n * If provided, reduces the qualifiers of the condition set by removing qualifiers that are made\n * irrelevant by the filterForContext.\n */\n qualifiersToReduce?: ReadonlySet<QualifierName>;\n}\n\n/**\n * Represents a set of {@link Conditions.Condition | conditions} that must all be met in some runtime\n * context for a resource instance to be valid.\n * @public\n */\nexport class ConditionSet implements IValidatedConditionSetDecl {\n protected readonly _collectible: Collections.Collectible<ConditionSetKey, ConditionSetIndex>;\n /**\n * The {@link Conditions.Condition | conditions} that make up this condition\n * set.\n * @public\n */\n public readonly conditions: ReadonlyArray<Condition>;\n\n /**\n * The key for this condition set.\n */\n public get key(): ConditionSetKey {\n return this._collectible.key;\n }\n\n /**\n * The number of conditions in this condition set.\n */\n public get size(): number {\n return this.conditions.length;\n }\n\n /**\n * The index for this condition set.\n */\n public get index(): ConditionSetIndex | undefined {\n return this._collectible.index;\n }\n\n /**\n * The key for an unconditional condition set.\n */\n public static UnconditionalKey: ConditionSetKey = Validate.toConditionSetKey('').orThrow();\n\n /**\n * Constructor for a {@link Conditions.ConditionSet | ConditionSet} object.\n * @param params - {@link Conditions.IValidatedConditionSetDecl | Validated declaration}\n * used to create the condition set.\n */\n protected constructor(params: IValidatedConditionSetDecl) {\n const qualifiers = new Map<QualifierName, Condition>();\n for (const condition of params.conditions) {\n /* c8 ignore next 9 - there's a test for this but coverage is having a bad day */\n if (qualifiers.has(condition.qualifier.name)) {\n const existing = qualifiers.get(condition.qualifier.name)?.toString() ?? 'unknown';\n throw new Error(\n `${\n condition.qualifier.name\n }: Duplicate conditions ${existing} and ${condition.toString()} are not supported.`\n );\n }\n qualifiers.set(condition.qualifier.name, condition);\n }\n this.conditions = Array.from(params.conditions).sort(Condition.compare).reverse();\n this._collectible = new Collections.Collectible({\n key: this.toKey(),\n index: params.index,\n indexConverter: CommonConvert.conditionSetIndex\n });\n }\n\n /**\n * Creates a new {@link Conditions.ConditionSet | ConditionSet} object.\n * @param params - {@link Conditions.IValidatedConditionSetDecl | Validated declaration}\n * used to create the condition set.\n * @returns `Success` with the new {@link Conditions.ConditionSet | ConditionSet} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(params: IValidatedConditionSetDecl): Result<ConditionSet> {\n return captureResult(() => new ConditionSet(params));\n }\n\n /**\n * Compares two {@link Conditions.ConditionSet | ConditionSets} for sorting purposes.\n * @param cs1 - The first {@link Conditions.ConditionSet | ConditionSet} to compare.\n * @param cs2 - The second {@link Conditions.ConditionSet | ConditionSet} to compare.\n * @returns A negative number if `cs1` should come before `cs2`, a positive\n * number if `cs1` should come after `cs2`, or zero if they are equivalent.\n * @public\n */\n public static compare(cs1: ConditionSet, cs2: ConditionSet): number {\n const len = Math.min(cs1.conditions.length, cs2.conditions.length);\n for (let i = 0; i < len; i++) {\n const diff = Condition.compare(cs1.conditions[i], cs2.conditions[i]);\n if (diff !== 0) {\n return diff;\n }\n }\n return cs1.conditions.length - cs2.conditions.length;\n }\n\n /**\n * Sets the global index for this condition set. Once set, the index cannot be changed.\n * @param index - The index to set for this condition set.\n * @returns `Success` with the index if successful, `Failure` otherwise.\n */\n public setIndex(index: number): Result<ConditionSetIndex> {\n return this._collectible.setIndex(index);\n }\n\n /**\n * Determines if this condition set can match a supplied context, even if the context is partial.\n * Returns true if all conditions in the set can match the context (using canMatchPartialContext).\n * Returns false otherwise.\n * @param context - The context to match.\n * @param options - Options to use when matching.\n * @returns `true` if all conditions can match the context, `false` otherwise.\n */\n public canMatchPartialContext(\n context: Context.IValidatedContextDecl,\n options?: Context.IContextMatchOptions\n ): boolean {\n return this.conditions.every((c) => c.canMatchPartialContext(context, options));\n }\n\n /**\n * Gets the {@link ConditionSetKey | key} for a supplied {@link Conditions.IValidatedConditionSetDecl | condition set declaration}.\n * @param decl - The {@link Conditions.IValidatedConditionSetDecl | condition set declaration} for which to get the key.\n * @returns `Success` with the condition set key if successful, `Failure` otherwise.\n * @public\n */\n public static getKeyForDecl(decl: IValidatedConditionSetDecl): Result<ConditionSetKey> {\n return Validate.toConditionSetKey(decl.conditions.map((c) => c.toKey()).join('+'));\n }\n\n /**\n * Gets a condition set key from a loose condition set declaration.\n * @param conditionSet - The loose condition set declaration to convert.\n * @param conditionCollector - The condition collector used for validation.\n * @returns `Success` with the condition set key if successful, `Failure` otherwise.\n * @public\n */\n public static getKeyFromLooseDecl(\n conditionSet: ResourceJson.Json.ConditionSetDecl | undefined,\n conditionCollector: ConditionCollector\n ): Result<ConditionSetKey> {\n if (!conditionSet) {\n return succeed(ConditionSet.UnconditionalKey);\n }\n\n // Convert ConditionSetDecl to IConditionSetDecl format\n let conditionSetDecl: { conditions: ResourceJson.Json.ILooseConditionDecl[] };\n\n if (Array.isArray(conditionSet)) {\n // ConditionSetDeclAsArray: array of ILooseConditionDecl\n conditionSetDecl = { conditions: conditionSet };\n } else {\n // ConditionSetDeclAsRecord: Readonly<Partial<Record<string, string | IChildConditionDecl>>>.\n // The record-form type is `Readonly<Partial<Record<..., V>>>`, so\n // `Object.entries` produces `[string, V | undefined]` — runtime\n // `undefined` values (a key explicitly set to undefined) skip;\n // they're semantically equivalent to omitting the key.\n const conditions: ResourceJson.Json.ILooseConditionDecl[] = [];\n for (const [qualifierName, value] of Object.entries(conditionSet)) {\n /* c8 ignore next 3 - defensive: explicit-undefined-value entries skipped */\n if (value === undefined) {\n continue;\n }\n if (typeof value === 'string') {\n conditions.push({ qualifierName, value });\n /* c8 ignore next 3 - edge case */\n } else {\n conditions.push({ qualifierName, ...value });\n }\n }\n conditionSetDecl = { conditions };\n }\n\n // Validate and convert to IValidatedConditionSetDecl\n return ConditionsConvert.validatedConditionSetDecl\n .convert(conditionSetDecl, { conditions: conditionCollector })\n .onSuccess((validatedDecl) => {\n // Use proper ConditionSet.getKeyForDecl method to generate the key\n return ConditionSet.getKeyForDecl(validatedDecl);\n });\n }\n\n /**\n * Gets a {@link ConditionSetToken | condition set token} for this condition set,\n * if possible.\n * @param terse - If true, the token will be terse, omitting qualifier names where\n * possible.\n * @returns `Success` with the {@link ConditionSetToken | condition set token} if successful,\n * `Failure` with an error message otherwise.\n * @public\n */\n public toToken(terse?: boolean): Result<string> {\n return mapResults(this.conditions.map((c) => c.toToken(terse))).onSuccess((tokens) => {\n return Validate.toConditionSetToken(tokens.join(','));\n });\n }\n\n /**\n * Gets the {@link ConditionSetKey | key} for this condition set.\n * @returns The key for this condition set.\n */\n public toKey(): ConditionSetKey {\n return ConditionSet.getKeyForDecl(this).orThrow();\n }\n\n /**\n * Gets a hash of this condition set.\n * @returns A hash of this condition\n * set key.\n * @public\n */\n public toHash(): string {\n return Hash.Crc32Normalizer.crc32Hash([this.key]).padStart(8, '0');\n }\n\n /**\n * Gets a human-readable string representation of this condition set.\n * @returns A string representation of this condition set.\n */\n public toString(): string {\n return this.toKey();\n }\n\n /**\n * Gets the {@link ResourceJson.Json.ConditionSetDeclAsRecord | condition set declaration as a record} for this condition set.\n * @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} for the condition set declaration.\n * @returns The {@link ResourceJson.Json.ConditionSetDeclAsRecord | condition set declaration as a record} for this condition set.\n */\n public toConditionSetRecordDecl(\n options?: IConditionSetDeclOptions\n ): ResourceJson.Json.ConditionSetDeclAsRecord {\n const qualifiersToReduce = options?.qualifiersToReduce;\n const conditions = qualifiersToReduce\n ? /* c8 ignore next 1 - coverage intermittently misses the next line */\n this.conditions.filter((c) => !qualifiersToReduce.has(c.qualifier.name))\n : this.conditions;\n return Object.fromEntries(\n conditions.map((c): [string, ResourceJson.Json.IChildConditionDecl | string] => {\n return [c.qualifier.name, c.toValueOrChildConditionDecl(options)];\n })\n );\n }\n\n /**\n * Gets the {@link ResourceJson.Json.ConditionSetDeclAsArray | condition set declaration as an array} for this condition set.\n * @param options - {@link ResourceJson.Helpers.IDeclarationOptions | options} for the condition set declaration.\n * @returns The {@link ResourceJson.Json.ConditionSetDeclAsArray | condition set declaration as an array} for this condition set.\n */\n public toConditionSetArrayDecl(\n options?: IConditionSetDeclOptions\n ): ResourceJson.Json.ConditionSetDeclAsArray {\n /* c8 ignore next 1 - defense in depth */\n const qualifiersToReduce = options?.qualifiersToReduce;\n const conditions = qualifiersToReduce\n ? this.conditions.filter((c) => !qualifiersToReduce.has(c.qualifier.name))\n : this.conditions;\n return conditions.map((c) => c.toLooseConditionDecl(options));\n }\n\n /**\n * Converts this condition set to a compiled condition set representation.\n * @param options - Optional compilation options controlling the output format.\n * @returns A compiled condition set object that can be used for serialization or runtime processing.\n * @public\n */\n public toCompiled(\n options?: ResourceJson.Compiled.ICompiledResourceOptions\n ): ResourceJson.Compiled.ICompiledConditionSet {\n return {\n conditions: this.conditions.map((c) => c.index!),\n ...(options?.includeMetadata === true ? { metadata: { key: this.key } } : {})\n };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionSetCollector.js","sourceRoot":"","sources":["../../../src/packlets/conditions/conditionSetCollector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAU,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAG7G,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAmB,OAAO,IAAI,aAAa,EAAqB,QAAQ,EAAE,MAAM,WAAW,CAAC;AAoBnG;;;;;;GAMG;AACH,MAAM,OAAO,qBAAsB,SAAQ,mBAAiC;IAO1E;;;OAGG;IACH,IAAW,yBAAyB;QAClC,OAAO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QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CACxF,CAAC,UAAU,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CACpD,CAAC;QACJ,CAAC;QACD,uFAAuF;QACvF,OAAO,yBAAyB;aAC7B,OAAO,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,iBAAiB,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;aAC5E,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;;AAlDD;;GAEG;AACW,wCAAkB,GAAsB,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC","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 { captureResult, Collections, mapResults, Result, succeed, ValidatingCollector } from '@fgv/ts-utils';\nimport { ConditionCollector } from './conditionCollector';\nimport { IConditionSetDecl } from './conditionSetDecls';\nimport { ConditionSet } from './conditionSet';\nimport { validatedConditionSetDecl } from './convert';\nimport { ConditionSetKey, Convert as CommonConvert, ConditionSetIndex, Validate } from '../common';\n\n/**\n * Parameters for creating a {@link Conditions.ConditionSetCollector | ConditionSetCollector}.\n * @public\n */\nexport interface IConditionSetCollectorCreateParams {\n /**\n * The {@link Conditions.ConditionCollector | ConditionCollector} used to create conditions\n * for conditions in this collector.\n */\n conditions: ConditionCollector;\n\n /**\n * Optional array of {@link Conditions.IConditionSetDecl | condition set declarations} to add to\n * the collector.\n */\n conditionSets?: IConditionSetDecl[];\n}\n\n/**\n * A `ValidatingCollector` for {@link Conditions.ConditionSet | ConditionSets},\n * which collects condition sets supplied as {@link Conditions.ConditionSet | ConditionSet} or\n * as {@link Conditions.IConditionSetDecl | IConditionSetDecl} via the methods on the\n * `validating` property.\n * @public\n */\nexport class ConditionSetCollector extends ValidatingCollector<ConditionSet> {\n /**\n * Gets the {@link Conditions.ConditionCollector | ConditionCollector} used to create conditions\n * for conditions in this collector.\n */\n public conditions: ConditionCollector;\n\n /**\n * Gets the {@link Conditions.ConditionSet | ConditionSet} at the unconditional\n * condition set index.\n */\n public get unconditionalConditionSet(): ConditionSet {\n return this.getAt(ConditionSetCollector.UnconditionalIndex).orThrow();\n }\n\n /**\n * The index of the unconditional condition set.\n */\n public static UnconditionalIndex: ConditionSetIndex = Validate.toConditionSetIndex(0).orThrow();\n\n /**\n * Creates a new {@link Conditions.ConditionSetCollector | ConditionSetCollector}.\n * @param params - {@link Conditions.IConditionSetCollectorCreateParams | Parameters} used to create\n * the collector.\n */\n protected constructor(params: IConditionSetCollectorCreateParams) {\n super({\n converters: new Collections.KeyValueConverters<ConditionSetKey, ConditionSet>({\n key: CommonConvert.conditionSetKey,\n /* c8 ignore next 1 - there's a test but coverage is having a bad day */\n value: (from: unknown) => this._toConditionSet(from)\n })\n });\n this.conditions = params.conditions;\n // it's very helpful for debugging if the unconditional condition set is always\n // in position 0\n this.validating.add(ConditionSet.create({ conditions: [] }).orThrow()).orThrow();\n /* c8 ignore next 1 - ? is defense in depth */\n params.conditionSets?.forEach((item) => this.validating.add(item).orThrow());\n }\n\n /**\n * Creates a new {@link Conditions.ConditionSetCollector | ConditionSetCollector}.\n * @param params - {@link Conditions.IConditionSetCollectorCreateParams | Parameters} used to create\n * the collector.\n * @returns `Success` with the new collector if successful, or `Failure` with an error message\n * if not.\n */\n public static create(params: IConditionSetCollectorCreateParams): Result<ConditionSetCollector> {\n return captureResult(() => new ConditionSetCollector(params));\n }\n\n private _toConditionSet(from: unknown): Result<ConditionSet> {\n if (from instanceof ConditionSet) {\n return succeed(from);\n }\n if (Array.isArray(from)) {\n return mapResults(from.map((item) => this.conditions.validating.getOrAdd(item))).onSuccess(\n (conditions) => ConditionSet.create({ conditions })\n );\n }\n /* c8 ignore next 4 - functional code path tested but coverage intermittently missed */\n return validatedConditionSetDecl\n .convert(from, { conditions: this.conditions, conditionSetIndex: this.size })\n .onSuccess((c) => ConditionSet.create(c));\n }\n}\n\n/**\n * A read-only {@link Conditions.ConditionSetCollector | ConditionSetCollector}.\n * @public\n */\nexport type ReadOnlyConditionSetCollector = Collections.IReadOnlyValidatingCollector<ConditionSet>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionSetDecls.js","sourceRoot":"","sources":["../../../src/packlets/conditions/conditionSetDecls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","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 { Condition } from './condition';\nimport { IConditionDecl } from './conditionDecls';\n\n/**\n * Non-validated declaration of a {@link Conditions.ConditionSet | set of conditions}.\n *\n * @remarks\n * Parameterized on `TQualifierNames` (defaulting to `string`) so consumers can\n * opt into compile-time axis-name discipline by supplying a literal-string union.\n *\n * @public\n */\nexport interface IConditionSetDecl<TQualifierNames extends string = string> {\n conditions: IConditionDecl<TQualifierNames>[];\n}\n\n/**\n * Validated declaration of a {@link Conditions.ConditionSet | set of conditions}.\n * @public\n */\nexport interface IValidatedConditionSetDecl {\n conditions: ReadonlyArray<Condition>;\n index?: number;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionToken.js","sourceRoot":"","sources":["../../../src/packlets/conditions/conditionToken.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAU,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAqB,MAAM,WAAW,CAAC;AAIxE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAO1B;;;OAGG;IACH,YAAmB,UAAuC;QACxD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IA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GAAG,KAAK,kCAAkC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClG,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF","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 { mapResults, Result, fail, succeed } from '@fgv/ts-utils';\nimport { Helpers as CommonHelpers, ConditionOperator } from '../common';\nimport { IValidatedConditionDecl } from './conditionDecls';\nimport { IReadOnlyQualifierCollector, Qualifier } from '../qualifiers';\n\n/**\n * Helper class to parse and validate condition tokens.\n * @public\n */\nexport class ConditionTokens {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} used to validate\n * qualifier names and values.\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Constructs a new {@link Conditions.ConditionTokens | ConditionTokens } instance.\n * @param qualifiers - the {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} to use\n */\n public constructor(qualifiers: IReadOnlyQualifierCollector) {\n this.qualifiers = qualifiers;\n }\n\n /**i\n * Parses a {@link ConditionToken | condition token} string and validates the parts\n * against the qualifiers present in the {@link Conditions.ConditionTokens.qualifiers | qualifier collector}.\n * @param token - the token string to parse.\n * @returns `Success` with the {@link Conditions.IValidatedConditionDecl | validated condition declaration}\n * if successful, `Failure` with an error message if not.\n */\n public parseConditionToken(token: string): Result<IValidatedConditionDecl> {\n return ConditionTokens.parseConditionToken(token, this.qualifiers);\n }\n\n /**\n * Parses a {@link ConditionSetToken | condition set token} string and validates the parts\n * against the qualifiers present in the {@link Conditions.ConditionTokens.qualifiers | qualifier collector}.\n * @param token - the token string to parse.\n * @returns `Success` with the array of {@link Conditions.IValidatedConditionDecl | validated condition declarations}\n * if successful, `Failure` with an error message if not.\n */\n public parseConditionSetToken(token: string): Result<IValidatedConditionDecl[]> {\n return ConditionTokens.parseConditionSetToken(token, this.qualifiers);\n }\n\n /**\n * Validates the {@link Helpers.IConditionTokenParts | parts} of a {@link ConditionToken | condition token}.\n * @param parts - the parts to validate\n * @returns `Success` with the validated declaration if successful, `Failure` with an error message if not.\n */\n public validateConditionTokenParts(\n parts: CommonHelpers.IConditionTokenParts\n ): Result<IValidatedConditionDecl> {\n return ConditionTokens.validateConditionTokenParts(parts, this.qualifiers);\n }\n\n /**\n * Given a value, finds a single token-optional qualifier that matches the value.\n * Fails if no qualifiers match, or if more than one qualifier matches.\n * @param value - the value to match.\n * @returns `Success` with the matching qualifier if successful, `Failure` with an error message if not.\n */\n public findQualifierForValue(value: string): Result<Qualifier> {\n return ConditionTokens.findQualifierForValue(value, this.qualifiers);\n }\n\n /**\n * Parses a {@link ConditionToken | condition token} and validates it against the qualifiers\n * present in the supplied {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector}.\n * @param token - the token string to parse.\n * @param qualifiers - the {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} to use\n * @returns `Success` with a {@link Conditions.IValidatedConditionDecl | validated condition declaration} if successful,\n * `Failure` with an error message if not.\n */\n public static parseConditionToken(\n token: string,\n qualifiers: IReadOnlyQualifierCollector\n ): Result<IValidatedConditionDecl> {\n return CommonHelpers.parseConditionTokenParts(token).onSuccess((parts) => {\n return ConditionTokens.validateConditionTokenParts(parts, qualifiers);\n });\n }\n\n /**\n * Parses a {@link ConditionSetToken | condition set token} and validates it against the qualifiers\n * present in the supplied {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector}.\n * @param token - the token string to parse.\n * @param qualifiers - the {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} to use\n * @returns `Success` with an array of {@link Conditions.IValidatedConditionDecl | validated condition declarations}\n * if successful, `Failure` with an error message if not\n */\n public static parseConditionSetToken(\n token: string,\n qualifiers: IReadOnlyQualifierCollector\n ): Result<IValidatedConditionDecl[]> {\n return CommonHelpers.parseConditionSetTokenParts(token).onSuccess((parts) => {\n return mapResults(parts.map((part) => ConditionTokens.validateConditionTokenParts(part, qualifiers)));\n });\n }\n\n /**\n * Validates the parts of a condition token against the qualifiers present in the supplied\n * {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector}.\n * @param parts - the {@link Helpers.IConditionTokenParts | condition token parts} to validate.\n * @param qualifiers - the {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} used to\n * validate qualifier names and values.\n * @returns `Success` with a {@link Conditions.IValidatedConditionDecl | validated condition declaration} if successful,\n * `Failure` with an error message if not.\n */\n public static validateConditionTokenParts(\n parts: CommonHelpers.IConditionTokenParts,\n qualifiers: IReadOnlyQualifierCollector\n ): Result<IValidatedConditionDecl> {\n const qualifierLookup =\n parts.qualifier === undefined\n ? ConditionTokens.findQualifierForValue(parts.value, qualifiers)\n : qualifiers.getByNameOrToken(parts.qualifier);\n\n return qualifierLookup.onSuccess((qualifier) => {\n return qualifier.type\n .validateCondition(parts.value)\n .onSuccess((value) => {\n const operator: ConditionOperator = 'matches';\n const priority = qualifier.defaultPriority;\n return succeed({ qualifier, value, operator, priority });\n })\n .withDetail('failure', 'success');\n });\n }\n\n /**\n * Given a value and a set of qualifiers, finds a single token-optional qualifier that matches the value.\n * Fails if no qualifiers match, or if more than one qualifier matches.\n * @param value - the value to match.\n * @param qualifiers - the qualifiers to match against.\n * @returns `Success` with the matching qualifier if successful, `Failure` with an error message if not.\n */\n public static findQualifierForValue(\n value: string,\n qualifiers: IReadOnlyQualifierCollector\n ): Result<Qualifier> {\n const matched: Qualifier[] = [];\n for (const qualifier of qualifiers.values()) {\n if (qualifier.tokenIsOptional && qualifier.validateCondition(value).isSuccess()) {\n matched.push(qualifier);\n }\n }\n if (matched.length === 0) {\n return fail(`${value}: does not match any qualifier`);\n }\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (matched.length > 1) {\n return fail(`${value}: matches multiple qualifiers (${matched.map((q) => q.name).join(', ')})`);\n }\n return succeed(matched[0]);\n }\n}\n"]}
|
|
@@ -20,32 +20,76 @@
|
|
|
20
20
|
* SOFTWARE.
|
|
21
21
|
*/
|
|
22
22
|
import { Converters, fail, mapResults, succeed } from '@fgv/ts-utils';
|
|
23
|
-
import { conditionDecl } from './decls';
|
|
23
|
+
import { conditionDecl, typedConditionDecl } from './decls';
|
|
24
24
|
/* eslint-disable @rushstack/typedef-var */
|
|
25
25
|
/**
|
|
26
26
|
* Converter which converts to a {@link Conditions.IConditionSetDecl | condition set declaration}.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Accepts any string as the qualifier name of each contained condition. Use
|
|
30
|
+
* `typedConditionSetDecl` to narrow the accepted set of qualifier names to a literal-string union.
|
|
31
|
+
*
|
|
27
32
|
* @public
|
|
28
33
|
*/
|
|
29
34
|
export const conditionSetDecl = Converters.strictObject({
|
|
30
35
|
conditions: Converters.arrayOf(conditionDecl)
|
|
31
36
|
});
|
|
32
37
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
38
|
+
* Returns a `Converter` for an `IConditionSetDecl<TQualifierNames>` narrowed on a supplied
|
|
39
|
+
* `qualifierName` converter.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Each contained condition is converted via `typedConditionDecl(qualifierNameConverter)`.
|
|
43
|
+
*
|
|
36
44
|
* @public
|
|
37
45
|
*/
|
|
38
|
-
|
|
46
|
+
// Keep the field list below in sync with `conditionSetDecl` above; the
|
|
47
|
+
// duplication preserves the `ObjectConverter` return type on the default.
|
|
48
|
+
export function typedConditionSetDecl(qualifierNameConverter) {
|
|
49
|
+
return Converters.strictObject({
|
|
50
|
+
conditions: Converters.arrayOf(typedConditionDecl(qualifierNameConverter))
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function _validatedConditionSetDeclBody(innerConditionSetDecl, from, context) {
|
|
39
54
|
/* c8 ignore next 3 - coverage is having a bad day */
|
|
40
55
|
if (!context) {
|
|
41
56
|
return fail('validatedConditionSetDecl converter requires a context');
|
|
42
57
|
}
|
|
43
|
-
return
|
|
58
|
+
return innerConditionSetDecl.convert(from).onSuccess((decl) => {
|
|
44
59
|
return mapResults(decl.conditions.map((condition) => context.conditions.validating.getOrAdd(condition))).onSuccess((conditions) => {
|
|
45
60
|
/* c8 ignore next 1 - coverage having issues */
|
|
46
61
|
const index = context.conditionSetIndex ? context.conditionSetIndex++ : undefined;
|
|
47
62
|
return succeed({ conditions, index });
|
|
48
63
|
});
|
|
49
64
|
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Converter which constructs a {@link Conditions.IValidatedConditionSetDecl | validated condition set declaration}
|
|
68
|
+
* from a {@link Conditions.IConditionSetDecl | condition set declaration}, instantiating qualifiers by name
|
|
69
|
+
* from a supplied {@link Conditions.Convert.IConditionSetDeclConvertContext | conversion context}.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Accepts any string as the qualifier name. Use `typedValidatedConditionSetDecl` to layer
|
|
73
|
+
* literal-string narrowing on top of the collector-membership check.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export const validatedConditionSetDecl = Converters.generic((from, __self, context) => {
|
|
78
|
+
return _validatedConditionSetDeclBody(conditionSetDecl, from, context);
|
|
50
79
|
});
|
|
80
|
+
/**
|
|
81
|
+
* Returns a `Converter` for an `IValidatedConditionSetDecl` narrowed on a supplied
|
|
82
|
+
* `qualifierName` converter.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
// Shares the `_validatedConditionSetDeclBody` helper with
|
|
87
|
+
// `validatedConditionSetDecl` above, so the body cannot drift; only the inner
|
|
88
|
+
// condition-set-decl converter differs.
|
|
89
|
+
export function typedValidatedConditionSetDecl(qualifierNameConverter) {
|
|
90
|
+
const inner = typedConditionSetDecl(qualifierNameConverter);
|
|
91
|
+
return Converters.generic((from, __self, context) => {
|
|
92
|
+
return _validatedConditionSetDeclBody(inner, from, context);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
51
95
|
//# sourceMappingURL=conditionSetDecls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditionSetDecls.js","sourceRoot":"","sources":["../../../../src/packlets/conditions/convert/conditionSetDecls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAa,UAAU,EAAU,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEzF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG5D,2CAA2C;AAE3C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC,YAAY,CAAoB;IACzE,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC;CAC9C,CAAC,CAAC;AAEH;;;;;;;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C;AACxC,MAAM,UAAU,8BAA8B,CAC5C,sBAAkD;IAElD,MAAM,KAAK,GAAG,qBAAqB,CAAC,sBAAsB,CAAC,CAAC;IAC5D,OAAO,UAAU,CAAC,OAAO,CACvB,CACE,IAAa,EACb,MAAM,EACN,OAAyC,EACL,EAAE;QACtC,OAAO,8BAA8B,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC,CACF,CAAC;AACJ,CAAC","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 { Converter, Converters, Result, fail, mapResults, succeed } from '@fgv/ts-utils';\nimport { IConditionSetDecl, IValidatedConditionSetDecl } from '../conditionSetDecls';\nimport { conditionDecl, typedConditionDecl } from './decls';\nimport { ConditionCollector } from '../conditionCollector';\n\n/* eslint-disable @rushstack/typedef-var */\n\n/**\n * Converter which converts to a {@link Conditions.IConditionSetDecl | condition set declaration}.\n *\n * @remarks\n * Accepts any string as the qualifier name of each contained condition. Use\n * `typedConditionSetDecl` to narrow the accepted set of qualifier names to a literal-string union.\n *\n * @public\n */\nexport const conditionSetDecl = Converters.strictObject<IConditionSetDecl>({\n conditions: Converters.arrayOf(conditionDecl)\n});\n\n/**\n * Returns a `Converter` for an `IConditionSetDecl<TQualifierNames>` narrowed on a supplied\n * `qualifierName` converter.\n *\n * @remarks\n * Each contained condition is converted via `typedConditionDecl(qualifierNameConverter)`.\n *\n * @public\n */\n// Keep the field list below in sync with `conditionSetDecl` above; the\n// duplication preserves the `ObjectConverter` return type on the default.\nexport function typedConditionSetDecl<TQualifierNames extends string>(\n qualifierNameConverter: Converter<TQualifierNames>\n): Converter<IConditionSetDecl<TQualifierNames>> {\n return Converters.strictObject<IConditionSetDecl<TQualifierNames>>({\n conditions: Converters.arrayOf(typedConditionDecl(qualifierNameConverter))\n });\n}\n\n/**\n * Context for converting a {@link Conditions.IConditionSetDecl | condition set declaration}\n * into an instantiated {@link Conditions.ConditionSet | condition set} object.\n * @public\n */\nexport interface IConditionSetDeclConvertContext {\n readonly conditions: ConditionCollector;\n conditionSetIndex?: number;\n}\n\nfunction _validatedConditionSetDeclBody<TQualifierNames extends string>(\n innerConditionSetDecl: Converter<IConditionSetDecl<TQualifierNames>>,\n from: unknown,\n context?: IConditionSetDeclConvertContext\n): Result<IValidatedConditionSetDecl> {\n /* c8 ignore next 3 - coverage is having a bad day */\n if (!context) {\n return fail('validatedConditionSetDecl converter requires a context');\n }\n\n return innerConditionSetDecl.convert(from).onSuccess((decl) => {\n return mapResults(\n decl.conditions.map((condition) => context.conditions.validating.getOrAdd(condition))\n ).onSuccess((conditions) => {\n /* c8 ignore next 1 - coverage having issues */\n const index = context.conditionSetIndex ? context.conditionSetIndex++ : undefined;\n return succeed({ conditions, index });\n });\n });\n}\n\n/**\n * Converter which constructs a {@link Conditions.IValidatedConditionSetDecl | validated condition set declaration}\n * from a {@link Conditions.IConditionSetDecl | condition set declaration}, instantiating qualifiers by name\n * from a supplied {@link Conditions.Convert.IConditionSetDeclConvertContext | conversion context}.\n *\n * @remarks\n * Accepts any string as the qualifier name. Use `typedValidatedConditionSetDecl` to layer\n * literal-string narrowing on top of the collector-membership check.\n *\n * @public\n */\nexport const validatedConditionSetDecl = Converters.generic<\n IValidatedConditionSetDecl,\n IConditionSetDeclConvertContext\n>((from: unknown, __self, context?: IConditionSetDeclConvertContext): Result<IValidatedConditionSetDecl> => {\n return _validatedConditionSetDeclBody(conditionSetDecl, from, context);\n});\n\n/**\n * Returns a `Converter` for an `IValidatedConditionSetDecl` narrowed on a supplied\n * `qualifierName` converter.\n *\n * @public\n */\n// Shares the `_validatedConditionSetDeclBody` helper with\n// `validatedConditionSetDecl` above, so the body cannot drift; only the inner\n// condition-set-decl converter differs.\nexport function typedValidatedConditionSetDecl<TQualifierNames extends string>(\n qualifierNameConverter: Converter<TQualifierNames>\n): Converter<IValidatedConditionSetDecl, IConditionSetDeclConvertContext> {\n const inner = typedConditionSetDecl(qualifierNameConverter);\n return Converters.generic<IValidatedConditionSetDecl, IConditionSetDeclConvertContext>(\n (\n from: unknown,\n __self,\n context?: IConditionSetDeclConvertContext\n ): Result<IValidatedConditionSetDecl> => {\n return _validatedConditionSetDeclBody(inner, from, context);\n }\n );\n}\n"]}
|
|
@@ -24,6 +24,11 @@ import { Converters, populateObject, fail, succeed } from '@fgv/ts-utils';
|
|
|
24
24
|
/* eslint-disable @rushstack/typedef-var */
|
|
25
25
|
/**
|
|
26
26
|
* Converter for a {@link Conditions.IConditionDecl | condition declaration}.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Accepts any string as the `qualifierName`. Use `typedConditionDecl` to narrow the
|
|
30
|
+
* accepted set of qualifier names to a literal-string union.
|
|
31
|
+
*
|
|
27
32
|
* @public
|
|
28
33
|
*/
|
|
29
34
|
export const conditionDecl = Converters.strictObject({
|
|
@@ -34,17 +39,34 @@ export const conditionDecl = Converters.strictObject({
|
|
|
34
39
|
scoreAsDefault: Converters.number.optional()
|
|
35
40
|
});
|
|
36
41
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
42
|
+
* Returns a `Converter` for an `IConditionDecl<TQualifierNames>` narrowed on a supplied
|
|
43
|
+
* `qualifierName` converter.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Pass e.g. `Converters.enumeratedValue(['tone', 'language'] as const)` to reject
|
|
47
|
+
* typo'd qualifier names at convert time and to narrow the resulting
|
|
48
|
+
* `IConditionDecl<T>` type to the same literal-string union. The default
|
|
49
|
+
* `conditionDecl` is the `Converters.string` instantiation of this shape.
|
|
50
|
+
*
|
|
40
51
|
* @public
|
|
41
52
|
*/
|
|
42
|
-
|
|
53
|
+
// Keep the field list below in sync with `conditionDecl` above; the
|
|
54
|
+
// duplication preserves the `ObjectConverter` return type on the default.
|
|
55
|
+
export function typedConditionDecl(qualifierNameConverter) {
|
|
56
|
+
return Converters.strictObject({
|
|
57
|
+
qualifierName: qualifierNameConverter,
|
|
58
|
+
value: Converters.string,
|
|
59
|
+
operator: Common.Convert.conditionOperator.optional(),
|
|
60
|
+
priority: Converters.number.optional(),
|
|
61
|
+
scoreAsDefault: Converters.number.optional()
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function _validatedConditionDeclBody(innerConditionDecl, from, context) {
|
|
43
65
|
/* c8 ignore next 3 - coverage is having a bad day */
|
|
44
66
|
if (!context) {
|
|
45
67
|
return fail('validatedConditionDecl converter requires a context');
|
|
46
68
|
}
|
|
47
|
-
return
|
|
69
|
+
return innerConditionDecl.convert(from).onSuccess((decl) => {
|
|
48
70
|
var _a;
|
|
49
71
|
const operator = (_a = decl.operator) !== null && _a !== void 0 ? _a : 'matches';
|
|
50
72
|
return context.qualifiers.validating.get(decl.qualifierName).onSuccess((qualifier) => {
|
|
@@ -71,5 +93,39 @@ export const validatedConditionDecl = Converters.generic((from, __self, context)
|
|
|
71
93
|
.withDetail('success');
|
|
72
94
|
});
|
|
73
95
|
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Converter which constructs a {@link Conditions.IValidatedConditionDecl | validated condition declaration}
|
|
99
|
+
* from a {@link Conditions.IConditionDecl | condition declaration}, instantiating qualifiers by name
|
|
100
|
+
* from a supplied {@link Conditions.Convert.IConditionDeclConvertContext | conversion context}.
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* Accepts any string as the `qualifierName`; the collector membership check still rejects unknown
|
|
104
|
+
* names. Use `typedValidatedConditionDecl` to layer literal-string narrowing on top of the
|
|
105
|
+
* collector check.
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export const validatedConditionDecl = Converters.generic((from, __self, context) => {
|
|
110
|
+
return _validatedConditionDeclBody(conditionDecl, from, context);
|
|
74
111
|
});
|
|
112
|
+
/**
|
|
113
|
+
* Returns a `Converter` for an `IValidatedConditionDecl` narrowed on a supplied
|
|
114
|
+
* `qualifierName` converter.
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* The typed sibling layers literal-string narrowing on top of the existing
|
|
118
|
+
* collector-membership check performed by `validatedConditionDecl`.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
// Shares the `_validatedConditionDeclBody` helper with `validatedConditionDecl`
|
|
123
|
+
// above, so the populate-object body cannot drift; only the inner condition-decl
|
|
124
|
+
// converter differs.
|
|
125
|
+
export function typedValidatedConditionDecl(qualifierNameConverter) {
|
|
126
|
+
const inner = typedConditionDecl(qualifierNameConverter);
|
|
127
|
+
return Converters.generic((from, __self, context) => {
|
|
128
|
+
return _validatedConditionDeclBody(inner, from, context);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
75
131
|
//# sourceMappingURL=decls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decls.js","sourceRoot":"","sources":["../../../../src/packlets/conditions/convert/decls.ts"],"names":[],"mappings":"AAAA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UAAU,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,CAGtD,CAAC,IAAa,EAAE,MAAM,EAAE,OAAsC,EAAmC,EAAE;IACnG,OAAO,2BAA2B,CAAC,aAAa,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,gFAAgF;AAChF,iFAAiF;AACjF,qBAAqB;AACrB,MAAM,UAAU,2BAA2B,CACzC,sBAAkD;IAElD,MAAM,KAAK,GAAG,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC,OAAO,CACvB,CAAC,IAAa,EAAE,MAAM,EAAE,OAAsC,EAAmC,EAAE;QACjG,OAAO,2BAA2B,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC,CACF,CAAC;AACJ,CAAC","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 Common from '../../common';\nimport { Converter, Converters, populateObject, Result, fail, succeed } from '@fgv/ts-utils';\nimport { IConditionDecl, IValidatedConditionDecl } from '../conditionDecls';\nimport { IReadOnlyQualifierCollector } from '../../qualifiers';\n\n/* eslint-disable @rushstack/typedef-var */\n\n/**\n * Converter for a {@link Conditions.IConditionDecl | condition declaration}.\n *\n * @remarks\n * Accepts any string as the `qualifierName`. Use `typedConditionDecl` to narrow the\n * accepted set of qualifier names to a literal-string union.\n *\n * @public\n */\nexport const conditionDecl = Converters.strictObject<IConditionDecl>({\n qualifierName: Converters.string,\n value: Converters.string,\n operator: Common.Convert.conditionOperator.optional(),\n priority: Converters.number.optional(),\n scoreAsDefault: Converters.number.optional()\n});\n\n/**\n * Returns a `Converter` for an `IConditionDecl<TQualifierNames>` narrowed on a supplied\n * `qualifierName` converter.\n *\n * @remarks\n * Pass e.g. `Converters.enumeratedValue(['tone', 'language'] as const)` to reject\n * typo'd qualifier names at convert time and to narrow the resulting\n * `IConditionDecl<T>` type to the same literal-string union. The default\n * `conditionDecl` is the `Converters.string` instantiation of this shape.\n *\n * @public\n */\n// Keep the field list below in sync with `conditionDecl` above; the\n// duplication preserves the `ObjectConverter` return type on the default.\nexport function typedConditionDecl<TQualifierNames extends string>(\n qualifierNameConverter: Converter<TQualifierNames>\n): Converter<IConditionDecl<TQualifierNames>> {\n return Converters.strictObject<IConditionDecl<TQualifierNames>>({\n qualifierName: qualifierNameConverter,\n value: Converters.string,\n operator: Common.Convert.conditionOperator.optional(),\n priority: Converters.number.optional(),\n scoreAsDefault: Converters.number.optional()\n });\n}\n\n/**\n * Conversion context to uses when converting\n * a {@link Conditions.IValidatedConditionDecl | validated condition declaration}.\n * @public\n */\nexport interface IConditionDeclConvertContext {\n readonly qualifiers: IReadOnlyQualifierCollector;\n conditionIndex?: number;\n}\n\nfunction _validatedConditionDeclBody<TQualifierNames extends string>(\n innerConditionDecl: Converter<IConditionDecl<TQualifierNames>>,\n from: unknown,\n context?: IConditionDeclConvertContext\n): Result<IValidatedConditionDecl> {\n /* c8 ignore next 3 - coverage is having a bad day */\n if (!context) {\n return fail('validatedConditionDecl converter requires a context');\n }\n return innerConditionDecl.convert(from).onSuccess((decl) => {\n const operator = decl.operator ?? 'matches';\n return context.qualifiers.validating.get(decl.qualifierName).onSuccess((qualifier) => {\n return populateObject<IValidatedConditionDecl>({\n qualifier: () => succeed(qualifier),\n value: () => qualifier.validateCondition(decl.value, operator),\n operator: () => succeed(operator),\n priority: () =>\n decl.priority\n ? Common.Convert.conditionPriority.convert(decl.priority)\n : succeed(qualifier.defaultPriority),\n scoreAsDefault: () =>\n decl.scoreAsDefault\n ? Common.Convert.qualifierMatchScore.convert(decl.scoreAsDefault)\n : succeed(undefined),\n index: () =>\n context.conditionIndex\n ? Common.Convert.conditionIndex.convert(context.conditionIndex)\n : succeed(undefined)\n })\n .onSuccess((result) => {\n if (context.conditionIndex !== undefined) {\n context.conditionIndex++;\n }\n return succeed(result);\n })\n .withDetail('success');\n });\n });\n}\n\n/**\n * Converter which constructs a {@link Conditions.IValidatedConditionDecl | validated condition declaration}\n * from a {@link Conditions.IConditionDecl | condition declaration}, instantiating qualifiers by name\n * from a supplied {@link Conditions.Convert.IConditionDeclConvertContext | conversion context}.\n *\n * @remarks\n * Accepts any string as the `qualifierName`; the collector membership check still rejects unknown\n * names. Use `typedValidatedConditionDecl` to layer literal-string narrowing on top of the\n * collector check.\n *\n * @public\n */\nexport const validatedConditionDecl = Converters.generic<\n IValidatedConditionDecl,\n IConditionDeclConvertContext\n>((from: unknown, __self, context?: IConditionDeclConvertContext): Result<IValidatedConditionDecl> => {\n return _validatedConditionDeclBody(conditionDecl, from, context);\n});\n\n/**\n * Returns a `Converter` for an `IValidatedConditionDecl` narrowed on a supplied\n * `qualifierName` converter.\n *\n * @remarks\n * The typed sibling layers literal-string narrowing on top of the existing\n * collector-membership check performed by `validatedConditionDecl`.\n *\n * @public\n */\n// Shares the `_validatedConditionDeclBody` helper with `validatedConditionDecl`\n// above, so the populate-object body cannot drift; only the inner condition-decl\n// converter differs.\nexport function typedValidatedConditionDecl<TQualifierNames extends string>(\n qualifierNameConverter: Converter<TQualifierNames>\n): Converter<IValidatedConditionDecl, IConditionDeclConvertContext> {\n const inner = typedConditionDecl(qualifierNameConverter);\n return Converters.generic<IValidatedConditionDecl, IConditionDeclConvertContext>(\n (from: unknown, __self, context?: IConditionDeclConvertContext): Result<IValidatedConditionDecl> => {\n return _validatedConditionDeclBody(inner, from, context);\n }\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/conditions/convert/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC","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\nexport * from './decls';\nexport * from './conditionSetDecls';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/conditions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,CAAC","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 Convert from './convert';\n\nexport * from './condition';\nexport * from './conditionCollector';\nexport * from './conditionDecls';\nexport * from './conditionSet';\nexport * from './conditionSetCollector';\nexport * from './conditionSetDecls';\nexport * from './conditionToken';\n\nexport { Convert };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/packlets/config/common.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAU,IAAI,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EACL,mBAAmB,EAEnB,+CAA+C,EAChD,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAYhD;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAiD;IAC7F,SAAS;IACT,mBAAmB;IACnB,oBAAoB;IACpB,kBAAkB;CACnB,CAAC;AAEF,cAAc,cAAc,CAAC;AAE7B,MAAM,eAAe,GAAgE;IACnF,OAAO,EAAE,OAAO,CAAC,0BAA0B;IAC3C,mBAAmB,EAAE,OAAO,CAAC,mCAAmC;IAChE,oBAAoB,EAAE,OAAO,CAAC,oCAAoC;IAClE,kBAAkB,EAAE,OAAO,CAAC,2BAA2B;CACxD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAmC,EACnC,UAA2C;IAE3C,IAAI,IAAI,IAAI,eAAe,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7D,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,sBAAsB,EAAE,CAAC;YACvC,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CACrC,+CAA+C,CAAC,MAAM,EAAE,UAAU,CAAC,sBAAuB,CAAC,CAC5F,CAAC;QACJ,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,yCAAyC;IACzC,OAAO,IAAI,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gCAAgC,CAC9C,IAAmC,EACnC,UAA2C;IAE3C,IAAI,IAAI,IAAI,eAAe,EAAE,CAAC;QAC5B,OAAO,mBAAmB,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,IAAI,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC","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 { Result, fail } from '@fgv/ts-utils';\nimport { ISystemConfiguration } from './json';\nimport {\n SystemConfiguration,\n ISystemConfigurationInitParams,\n updateSystemConfigurationQualifierDefaultValues\n} from './systemConfiguration';\nimport { sanitizeJsonObject } from '@fgv/ts-json-base';\nimport { Default, Example } from './predefined';\n\n/**\n * A `string` literal type representing a well-known predefined system configuration.\n * @public\n */\nexport type PredefinedSystemConfiguration =\n | 'default'\n | 'language-priority'\n | 'territory-priority'\n | 'extended-example';\n\n/**\n * An array of all well-known predefined system configurations.\n * @public\n */\nexport const allPredefinedSystemConfigurations: ReadonlyArray<PredefinedSystemConfiguration> = [\n 'default',\n 'language-priority',\n 'territory-priority',\n 'extended-example'\n];\n\nexport * from './predefined';\n\nconst predefinedDecls: Record<PredefinedSystemConfiguration, ISystemConfiguration> = {\n default: Default.DefaultSystemConfiguration,\n 'language-priority': Default.LanguagePrioritySystemConfiguration,\n 'territory-priority': Default.TerritoryPrioritySystemConfiguration,\n 'extended-example': Example.ExtendedSystemConfiguration\n};\n\n/**\n * Returns the {@link Config.Model.ISystemConfiguration | system configuration} declaration for the\n * specified predefined system configuration.\n * @param name - The name of the predefined system configuration.\n * @param initParams - Optional {@link Config.ISystemConfigurationInitParams | initialization parameters}.\n * @returns `Success` with the {@link Config.Model.ISystemConfiguration | system configuration}\n * declaration if successful, `Failure` with an error message otherwise.\n * @public\n */\nexport function getPredefinedDeclaration(\n name: PredefinedSystemConfiguration,\n initParams?: ISystemConfigurationInitParams\n): Result<ISystemConfiguration> {\n if (name in predefinedDecls) {\n const baseConfig = sanitizeJsonObject(predefinedDecls[name]);\n if (initParams?.qualifierDefaultValues) {\n return baseConfig.onSuccess((config) =>\n updateSystemConfigurationQualifierDefaultValues(config, initParams.qualifierDefaultValues!)\n );\n }\n return baseConfig;\n }\n /* c8 ignore next 3 - defense in depth */\n return fail(`Unknown predefined system configuration: ${name}`);\n}\n\n/**\n * Returns the {@link Config.SystemConfiguration | SystemConfiguration} for the specified\n * predefined system configuration.\n * @param name - The name of the predefined system configuration.\n * @param initParams - Optional {@link Config.ISystemConfigurationInitParams | initialization parameters}.\n * @returns `Success` with the {@link Config.SystemConfiguration | SystemConfiguration}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\nexport function getPredefinedSystemConfiguration(\n name: PredefinedSystemConfiguration,\n initParams?: ISystemConfigurationInitParams\n): Result<SystemConfiguration> {\n if (name in predefinedDecls) {\n return SystemConfiguration.create(predefinedDecls[name], initParams);\n }\n\n return fail(`Unknown predefined system configuration: ${name}`);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configInitFactory.js","sourceRoot":"","sources":["../../../src/packlets/config/configInitFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAU,IAAI,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AAgCnD;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACxC,EAAmC;IAEnC,OAAO;QACL,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,EAA+B;IAE/B,OAAO;QACL,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAGnC;;;OAGG;IACH,YAAmB,SAA2C;QAC5D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAe;QAC3B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACtC,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;gBACvB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,wDAAwD,CAAC,CAAC;IACxE,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,2BAA2B;IAGtC,qDAAq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AM,CAAC,MAAgD;QAC5D,OAAO,aAAa,CAAC,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,wBAGxC;IACC;;;;;;;OAOG;IACH,YACE,SAEC;QAED,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC;QAC5B,MAAM,mBAAmB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9C,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3D,CAAC;QACF,KAAK,CAAC,CAAC,GAAG,mBAAmB,EAAE,IAAI,0BAA0B,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,6BAA6B;IAGxC;;;;;;OAMG;IACH,YACE,SAEC;QAED,IAAI,CAAC,aAAa,GAAG,IAAI,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAe;QAC3B,OAAO,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,EAAE;YACnG,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;CACF","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 { Result, fail } from '@fgv/ts-utils';\nimport { QualifierType, SystemQualifierType } from '../qualifier-types';\nimport * as QualifierTypes from '../qualifier-types';\nimport * as ResourceTypes from '../resource-types';\nimport { ResourceType } from '../resource-types';\n\n/**\n * Function signature for creating a qualifier type from configuration.\n * @public\n */\nexport type QualifierTypeFactoryFunction<T extends QualifierType = QualifierType> = (\n config: QualifierTypes.Config.IAnyQualifierTypeConfig\n) => Result<T>;\n\n/**\n * Function signature for creating a resource type from configuration.\n * @public\n */\nexport type ResourceTypeFactoryFunction = (\n config: ResourceTypes.Config.IResourceTypeConfig\n) => Result<ResourceType>;\n\n/**\n * Interface for a factory that creates a new instance of a configuration object.\n * @public\n */\nexport interface IConfigInitFactory<TConfig, T> {\n /**\n * Creates a new instance of a configuration object.\n * @param config - The configuration object to create.\n * @returns A result containing the new instance of the configuration object.\n */\n create(config: TConfig): Result<T>;\n}\n\n/**\n * Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a factory function.\n * @param fn - The factory function to wrap.\n * @returns An `IConfigInitFactory` instance that delegates to the function.\n * @public\n */\nexport function createQualifierTypeFactory<T extends QualifierType = QualifierType>(\n fn: QualifierTypeFactoryFunction<T>\n): IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> {\n return {\n create: fn\n };\n}\n\n/**\n * Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a resource type factory function.\n * @param fn - The factory function to wrap.\n * @returns An `IConfigInitFactory` instance that delegates to the function.\n * @public\n */\nexport function createResourceTypeFactory(\n fn: ResourceTypeFactoryFunction\n): IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {\n return {\n create: fn\n };\n}\n\n/**\n * A factory that chains multiple factories together.\n * @public\n */\nexport class ChainedConfigInitFactory<TConfig, T> implements IConfigInitFactory<TConfig, T> {\n public readonly factories: IConfigInitFactory<TConfig, T>[];\n\n /**\n * Constructor for a chained config init factory.\n * @param factories - The factories to chain.\n */\n public constructor(factories: IConfigInitFactory<TConfig, T>[]) {\n this.factories = factories;\n }\n\n /**\n * Creates a new instance of a configuration object.\n * @param config - The configuration object to create.\n * @returns A result containing the new instance of the configuration object.\n */\n public create(config: TConfig): Result<T> {\n for (const factory of this.factories) {\n const result = factory.create(config);\n if (result.isSuccess()) {\n return result;\n }\n }\n return fail('No factory was able to create the configuration object');\n }\n}\n\n/**\n * A factory that creates a {@link QualifierTypes.SystemQualifierType | SystemQualifierType} from\n * {@link QualifierTypes.Config.IAnyQualifierTypeConfig | any qualifier type configuration}.\n * @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\nexport class BuiltInQualifierTypeFactory\n implements IConfigInitFactory<QualifierTypes.Config.ISystemQualifierTypeConfig, SystemQualifierType>\n{\n /** {@inheritDoc Config.IConfigInitFactory.create} */\n public create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<SystemQualifierType> {\n if (QualifierTypes.Config.isSystemQualifierTypeConfig(config)) {\n return QualifierTypes.createQualifierTypeFromSystemConfig(config);\n }\n /* c8 ignore next 2 - functional code tested but coverage intermittently missed */\n return fail(`${config.name}: unknown built-in qualifier type (${config.systemType})`);\n }\n}\n\n/**\n * A factory that creates {@link QualifierTypes.QualifierType | QualifierType} instances from configuration,\n * supporting both built-in system types and custom external types.\n *\n * This factory allows external consumers to extend the qualifier type system with their own custom types\n * while maintaining support for all built-in types (Language, Territory, Literal).\n *\n * @typeParam T - The custom qualifier type(s) to support. Defaults to {@link QualifierTypes.SystemQualifierType | SystemQualifierType}.\n *\n * @example Creating a factory with custom qualifier types\n * ```typescript\n * // Define a custom qualifier type\n * class CustomQualifierType extends QualifierType {\n * // ... implementation\n * }\n *\n * // Define a discriminated union of all types\n * type AppQualifierType = SystemQualifierType | CustomQualifierType;\n *\n * // Create a factory that handles custom types\n * const customFactory: IConfigInitFactory<IAnyQualifierTypeConfig, CustomQualifierType> = {\n * create(config) {\n * // ... handle custom type creation\n * }\n * };\n *\n * // Create the combined factory\n * const qualifierTypeFactory = new QualifierTypeFactory<AppQualifierType>([customFactory]);\n *\n * // The factory returns T | SystemQualifierType, supporting all types\n * const result = qualifierTypeFactory.create(config); // Result<AppQualifierType | SystemQualifierType>\n * ```\n *\n * @remarks\n * - The factory chains custom factories with the built-in factory\n * - Custom factories are tried first, falling back to built-in types\n * - The return type is a union of custom types (T) and system types\n *\n * @public\n */\nexport class QualifierTypeFactory<\n T extends QualifierType = SystemQualifierType\n> extends ChainedConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T | SystemQualifierType> {\n /**\n * Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.\n * @param factories - Array of factories for custom qualifier types. Can be:\n * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances\n * - {@link Config.QualifierTypeFactoryFunction | Factory functions}\n * - A mix of both\n * These are tried in order before falling back to built-in types.\n * @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always appended to handle\n * system qualifier types (Language, Territory, Literal).\n */\n public constructor(\n factories: Array<\n IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> | QualifierTypeFactoryFunction<T>\n >\n ) {\n const normalizedFactories = factories.map((f) =>\n typeof f === 'function' ? createQualifierTypeFactory(f) : f\n );\n super([...normalizedFactories, new BuiltInQualifierTypeFactory()]);\n }\n}\n\n/**\n * A factory that validates and creates {@link QualifierTypes.QualifierType | QualifierType} instances\n * from weakly-typed configuration objects. This factory accepts configurations with unvalidated\n * string properties and validates them before delegating to the underlying factory chain.\n *\n * This pattern is useful at package boundaries where type identity issues may occur with\n * branded types across different package instances.\n *\n * @example\n * ```typescript\n * // Accept weakly-typed config from external source\n * const validatingFactory = new ValidatingQualifierTypeFactory([customFactory]);\n *\n * // Config can have plain string types instead of branded types\n * const config = {\n * name: 'my-qualifier', // plain string, not QualifierTypeName\n * systemType: 'custom', // plain string\n * configuration: { ... }\n * };\n *\n * const result = validatingFactory.create(config); // Validates and converts internally\n * ```\n *\n * @public\n */\nexport class ValidatingQualifierTypeFactory<T extends QualifierType = SystemQualifierType>\n implements IConfigInitFactory<unknown, T | SystemQualifierType>\n{\n private readonly _innerFactory: QualifierTypeFactory<T>;\n\n /**\n * Constructor for a validating qualifier type factory.\n * @param factories - Array of factories for custom qualifier types. Can be:\n * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances\n * - {@link Config.QualifierTypeFactoryFunction | Factory functions}\n * - A mix of both\n */\n public constructor(\n factories: Array<\n IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> | QualifierTypeFactoryFunction<T>\n >\n ) {\n this._innerFactory = new QualifierTypeFactory(factories);\n }\n\n /**\n * Creates a qualifier type from a weakly-typed configuration object.\n * @param config - The configuration object to validate and use for creation.\n * @returns A result containing the new qualifier type if successful.\n */\n public create(config: unknown): Result<T | SystemQualifierType> {\n return QualifierTypes.Config.Convert.anyQualifierTypeConfig\n .convert(config)\n .onSuccess((validatedConfig) => {\n return this._innerFactory.create(validatedConfig);\n });\n }\n}\n\n/**\n * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.\n * @public\n */\nexport class BuiltInResourceTypeFactory\n implements IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>\n{\n /** {@inheritDoc Config.IConfigInitFactory.create} */\n public create(config: ResourceTypes.Config.IResourceTypeConfig): Result<ResourceType> {\n return ResourceTypes.createResourceTypeFromConfig(config);\n }\n}\n\n/**\n * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}\n * by chaining a supplied factory with a {@link Config.BuiltInResourceTypeFactory | built-in factory} that handles built-in resource types.\n * @public\n */\nexport class ResourceTypeFactory extends ChainedConfigInitFactory<\n ResourceTypes.Config.IResourceTypeConfig,\n ResourceType\n> {\n /**\n * Constructor for a resource type factory.\n * @param factories - Array of factories for resource types. Can be:\n * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances\n * - {@link Config.ResourceTypeFactoryFunction | Factory functions}\n * - A mix of both\n * @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.\n */\n public constructor(\n factories: Array<\n IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> | ResourceTypeFactoryFunction\n >\n ) {\n factories = factories ?? [];\n const normalizedFactories = factories.map((f) =>\n typeof f === 'function' ? createResourceTypeFactory(f) : f\n );\n super([...normalizedFactories, new BuiltInResourceTypeFactory()]);\n }\n}\n\n/**\n * A factory that validates and creates {@link ResourceTypes.ResourceType | ResourceType} instances\n * from weakly-typed configuration objects. This factory accepts configurations with unvalidated\n * string properties and validates them before delegating to the underlying factory chain.\n *\n * This pattern is useful at package boundaries where type identity issues may occur with\n * branded types across different package instances.\n *\n * @public\n */\nexport class ValidatingResourceTypeFactory implements IConfigInitFactory<unknown, ResourceType> {\n private readonly _innerFactory: ResourceTypeFactory;\n\n /**\n * Constructor for a validating resource type factory.\n * @param factories - Array of factories for resource types. Can be:\n * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances\n * - {@link Config.ResourceTypeFactoryFunction | Factory functions}\n * - A mix of both\n */\n public constructor(\n factories: Array<\n IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> | ResourceTypeFactoryFunction\n >\n ) {\n this._innerFactory = new ResourceTypeFactory(factories);\n }\n\n /**\n * Creates a resource type from a weakly-typed configuration object.\n * @param config - The configuration object to validate and use for creation.\n * @returns A result containing the new resource type if successful.\n */\n public create(config: unknown): Result<ResourceType> {\n return ResourceTypes.Config.Convert.resourceTypeConfig.convert(config).onSuccess((validatedConfig) => {\n return this._innerFactory.create(validatedConfig);\n });\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/packlets/config/convert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,2CAA2C;AAE3C,OAAO,EAAE,UAAU,EAAU,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC,YAAY,CAAuB;IAC/E,IAAI,EAAE,UAAU,CAAC,cAAc;IAC/B,WAAW,EAAE,UAAU,CAAC,cAAc;IACtC,cAAc,EAAE,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC;IACxF,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC;IAChE,aAAa,EAAE,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC;CACnF,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAC,eAAe,CAAC,iCAAiC,CAAC,CAAC;AAE3G;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAe;IACzD,OAAO,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC","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\n/* eslint-disable @rushstack/typedef-var */\n\nimport { Converters, Result } from '@fgv/ts-utils';\nimport { ISystemConfiguration } from './json';\nimport * as QualifierTypes from '../qualifier-types';\nimport * as Qualifiers from '../qualifiers';\nimport * as ResourceTypes from '../resource-types';\nimport { allPredefinedSystemConfigurations } from './common';\n\n/**\n * A `Converter` for {@link Config.Model.ISystemConfiguration | ISystemConfiguration} objects.\n * @returns A `Converter` for {@link Config.Model.ISystemConfiguration | ISystemConfiguration} objects.\n * @public\n */\nexport const systemConfiguration = Converters.strictObject<ISystemConfiguration>({\n name: Converters.optionalString,\n description: Converters.optionalString,\n qualifierTypes: Converters.arrayOf(QualifierTypes.Config.Convert.anyQualifierTypeConfig),\n qualifiers: Converters.arrayOf(Qualifiers.Convert.qualifierDecl),\n resourceTypes: Converters.arrayOf(ResourceTypes.Config.Convert.resourceTypeConfig)\n});\n\n/**\n * A `Converter` for {@link Config.PredefinedSystemConfiguration | PredefinedSystemConfiguration} values.\n * @returns A `Converter` for {@link Config.PredefinedSystemConfiguration | PredefinedSystemConfiguration} values.\n * @public\n */\nexport const predefinedSystemConfiguration = Converters.enumeratedValue(allPredefinedSystemConfigurations);\n\n/**\n * Validate a {@link Config.Model.ISystemConfiguration | ISystemConfiguration} object.\n * @param config - The system configuration to validate\n * @returns `Success` with the validated system configuration if successful,\n * or `Failure` with an error message if validation fails.\n * @public\n */\nexport function validateSystemConfiguration(config: unknown): Result<ISystemConfiguration> {\n return systemConfiguration.convert(config);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/packlets/config/index.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,yEAAyE;AAEzE,OAAO,KAAK,KAAK,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,qBAAqB;AACrB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AAEzB,wFAAwF;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,oBAAoB;AACpB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAE1B,yBAAyB;AACzB,iFAAiF","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\n// Browser-safe config exports - excludes Node.js filesystem dependencies\n\nimport * as Model from './json';\nimport * as Convert from './convert';\n\n// Export all modules\nexport * from './configInitFactory';\nexport * from './common';\n\n// Export SystemConfiguration class but not as wildcard to avoid pulling in loadFromFile\nexport { SystemConfiguration } from './systemConfiguration';\n\n// Export namespaces\nexport { Model, Convert };\n\n// Excluded from browser:\n// - SystemConfiguration.loadFromFile() method (requires Node.js fs via JsonFile)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,KAAK,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC","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 Model from './json';\nimport * as Convert from './convert';\n\nexport * from './configInitFactory';\nexport * from './systemConfiguration';\nexport * from './common';\n\nexport { Model, Convert };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/packlets/config/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","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 QualifierTypes from '../qualifier-types';\nimport * as Qualifiers from '../qualifiers';\nimport * as ResourceTypes from '../resource-types';\n\n/**\n * System configuration for both runtime or build.\n * @public\n */\nexport interface ISystemConfiguration {\n /** Optional human-readable name for the configuration. */\n\n name?: string;\n /** Optional description explaining the purpose and use case of the configuration. */\n description?: string;\n /** Qualifier type configurations that define the available qualifier types in the system. */\n qualifierTypes: QualifierTypes.Config.IAnyQualifierTypeConfig[];\n /** Qualifier declarations that define the available qualifiers in the system. */\n qualifiers: Qualifiers.IQualifierDecl[];\n /** Resource type configurations that define the available resource types in the system. */\n resourceTypes: ResourceTypes.Config.IResourceTypeConfig[];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../../src/packlets/config/predefined/default.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAoE;IACpG;QACE,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,UAAU;QACtB,aAAa,EAAE;YACb,gBAAgB,EAAE,IAAI;SACvB;KACF;IACD;QACE,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE,WAAW;QACvB,aAAa,EAAE;YACb,gBAAgB,EAAE,KAAK;SACxB;KACF;CACF,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAA6C;IACnF;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,WAAW;QACrB,eAAe,EAAE,GAAG;KACrB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,MAAM;QACb,QAAQ,E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esContent":["/*\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 { ISystemConfiguration } from '../json';\n\nimport * as QualifierTypes from '../../qualifier-types';\nimport * as Qualifiers from '../../qualifiers';\nimport * as ResourceTypes from '../../resource-types';\n\n/**\n * Default qualifier types.\n * @remarks\n * The default qualifier types are:\n * - language: recognizes BCP 47 language tags, accepts a comma-separated list of language tags in the context\n * - territory: recognizes ISO 3166-1 alpha-2 territory codes, accepts a single code in the context\n * @public\n */\nexport const DefaultQualifierTypes: ReadonlyArray<QualifierTypes.Config.ISystemQualifierTypeConfig> = [\n {\n name: 'language',\n systemType: 'language',\n configuration: {\n allowContextList: true\n }\n },\n {\n name: 'territory',\n systemType: 'territory',\n configuration: {\n allowContextList: false\n }\n }\n];\n\n/**\n * Qualifier definitions in which territory is the primary qualifier, with\n * language as a secondary qualifier.\n * @remarks\n * The default qualifiers are:\n * - currentTerritory(token: geo): territory qualifier, priority 850\n * - language(token: lang): language qualifier, priority 800\n * @public\n */\nexport const TerritoryPriorityQualifiers: ReadonlyArray<Qualifiers.IQualifierDecl> = [\n {\n name: 'currentTerritory',\n token: 'geo',\n typeName: 'territory',\n defaultPriority: 850\n },\n {\n name: 'language',\n token: 'lang',\n typeName: 'language',\n defaultPriority: 800\n }\n];\n\n/**\n * Qualifier definitions in which language is the primary qualifier, with\n * territory as a secondary qualifier.\n * @remarks\n * The default qualifiers are:\n * - language(token: lang): language qualifier, priority 850\n * - currentTerritory(token: geo): territory qualifier, priority 800\n * @public\n */\nexport const LanguagePriorityQualifiers: ReadonlyArray<Qualifiers.IQualifierDecl> = [\n {\n name: 'language',\n token: 'lang',\n typeName: 'language',\n defaultPriority: 850\n },\n {\n name: 'currentTerritory',\n token: 'geo',\n typeName: 'territory',\n defaultPriority: 800\n }\n];\n\n/**\n * Default resource types.\n * @public\n */\nexport const DefaultResourceTypes: ReadonlyArray<ResourceTypes.Config.IResourceTypeConfig> = [\n {\n name: 'json',\n typeName: 'json'\n }\n];\n\n/**\n * System configuration with territory as the primary qualifier, and\n * language as a secondary qualifier.\n * @public\n */\nexport const TerritoryPrioritySystemConfiguration: ISystemConfiguration = {\n name: 'territory-priority',\n description: 'Territory priority system configuration',\n qualifierTypes: [...DefaultQualifierTypes],\n qualifiers: [...TerritoryPriorityQualifiers],\n resourceTypes: [...DefaultResourceTypes]\n};\n\n/**\n * System configuration with language as the primary qualifier, and\n * territory as a secondary qualifier.\n * @public\n */\nexport const LanguagePrioritySystemConfiguration: ISystemConfiguration = {\n name: 'language-priority',\n description: 'Language priority system configuration',\n qualifierTypes: [...DefaultQualifierTypes],\n qualifiers: [...LanguagePriorityQualifiers],\n resourceTypes: [...DefaultResourceTypes]\n};\n\n/**\n * The default system configuration gives priority to territory as the primary qualifier,\n * with language as a secondary qualifier.\n * @public\n */\nexport const DefaultSystemConfiguration: ISystemConfiguration = {\n name: 'default',\n description: 'Default system configuration',\n qualifierTypes: [...DefaultQualifierTypes],\n qualifiers: [...TerritoryPriorityQualifiers],\n resourceTypes: [...DefaultResourceTypes]\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extended.js","sourceRoot":"","sources":["../../../../src/packlets/config/predefined/extended.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAoE;IACrG;QACE,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,UAAU;QACtB,aAAa,EAAE;YACb,gBAAgB,EAAE,IAAI;SACvB;KACF;IACD;QACE,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE,WAAW;QACvB,aAAa,EAAE;YACb,gBAAgB,EAAE,KAAK;YACvB,eAAe,EAAE,KAAK;SACvB;KACF;IACD;QACE,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,SAAS;QACrB,aAAa,EAAE;YACb,gBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;SACtD;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,UAAU,EAAE,SAAS;QACrB,aAAa,EAAE;YACb,gBAAgB,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC;SACpF;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,SAAS;QACrB,aAAa,EAAE;YACb,aAAa,EAAE,IAAI;YACnB,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;SACtD;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,SAAS;QACrB,aAAa,EAAE;YACb,gBAAgB,EAAE;gBAChB,OAAO;gBACP,UAAU;gBACV,QAAQ;gBACR,MAAM;gBACN,SAAS;gBACT,QAAQ;gBACR,aAAa;gBACb,eAAe;gBACf,WAAW;gBACX,iBAAiB;gBACjB,eAAe;gBACf,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QACpB,eAAe,EAAE,GAAG;KACrB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,QAAQ;QAClB,eAAe,EAAE,GAAG;KACrB;IACD;QACE,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,MAAM;QAChB,eAAe,EAAE,GAAG;KACrB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,aAAa;QACvB,eAAe,EAAE,GAAG;KACrB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,UAAU;QACpB,eAAe,EAAE,GAAG;KACrB;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA4D;IAC5F;QACE,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,MAAM;KACjB;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAyB;IAC/D,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,6EAA6E;IAC1F,cAAc,EAAE,CAAC,GAAG,sBAAsB,CAAC;IAC3C,UAAU,EAAE,CAAC,GAAG,kBAAkB,CAAC;IACnC,aAAa,EAAE,CAAC,GAAG,qBAAqB,CAAC;CAC1C,CAAC","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 ResourceTypes from '../../resource-types';\nimport * as QualifierTypes from '../../qualifier-types';\nimport * as Qualifiers from '../../qualifiers';\nimport { ISystemConfiguration } from '../json';\n\n/**\n * Example extended qualifier types.\n * @public\n */\nexport const ExtendedQualifierTypes: ReadonlyArray<QualifierTypes.Config.ISystemQualifierTypeConfig> = [\n {\n name: 'language',\n systemType: 'language',\n configuration: {\n allowContextList: true\n }\n },\n {\n name: 'territory',\n systemType: 'territory',\n configuration: {\n allowContextList: false,\n acceptLowercase: false\n }\n },\n {\n name: 'role',\n systemType: 'literal',\n configuration: {\n enumeratedValues: ['admin', 'agent', 'user', 'guest']\n }\n },\n {\n name: 'environment',\n systemType: 'literal',\n configuration: {\n enumeratedValues: ['production', 'integration', 'development', 'test', 'ephemeral']\n }\n },\n {\n name: 'currency',\n systemType: 'literal',\n configuration: {\n caseSensitive: true,\n enumeratedValues: ['USD', 'EUR', 'GBP', 'JPY', 'CNY']\n }\n },\n {\n name: 'market',\n systemType: 'literal',\n configuration: {\n enumeratedValues: [\n 'world',\n 'americas',\n 'europe',\n 'asia',\n 'oceania',\n 'africa',\n 'middle-east',\n 'latin-america',\n 'caribbean',\n 'central-america',\n 'south-america',\n 'north-america',\n 'nordics',\n 'baltic',\n 'balkans',\n 'eastern-europe',\n 'western-europe',\n 'central-europe',\n 'eastern-africa',\n 'western-africa',\n 'central-africa',\n 'north-africa',\n 'south-africa',\n 'middle-africa',\n 'southeast-asia'\n ],\n hierarchy: {\n americas: 'world',\n europe: 'world',\n asia: 'world',\n oceania: 'world',\n africa: 'world',\n 'middle-east': 'world',\n 'latin-america': 'americas',\n caribbean: 'americas',\n 'central-america': 'americas',\n 'south-america': 'americas',\n 'north-america': 'americas',\n nordics: 'europe',\n baltic: 'europe',\n balkans: 'europe',\n 'eastern-europe': 'europe',\n 'western-europe': 'europe',\n 'central-europe': 'europe',\n 'eastern-africa': 'africa',\n 'western-africa': 'africa',\n 'central-africa': 'africa',\n 'north-africa': 'africa',\n 'south-africa': 'africa',\n 'middle-africa': 'africa',\n 'southeast-asia': 'asia'\n }\n }\n }\n];\n\n/**\n * Example extended qualifiers.\n * @public\n */\nexport const ExtendedQualifiers: ReadonlyArray<Qualifiers.IQualifierDecl> = [\n {\n name: 'homeTerritory',\n token: 'home',\n typeName: 'territory',\n defaultPriority: 900\n },\n {\n name: 'currentTerritory',\n token: 'geo',\n typeName: 'territory',\n defaultPriority: 850\n },\n {\n name: 'language',\n token: 'lang',\n typeName: 'language',\n defaultPriority: 800\n },\n {\n name: 'market',\n typeName: 'market',\n defaultPriority: 750\n },\n {\n name: 'role',\n typeName: 'role',\n defaultPriority: 700\n },\n {\n name: 'environment',\n token: 'env',\n typeName: 'environment',\n defaultPriority: 650\n },\n {\n name: 'currency',\n typeName: 'currency',\n defaultPriority: 600\n }\n];\n\n/**\n * Example resource types.\n * @public\n */\nexport const ExtendedResourceTypes: ReadonlyArray<ResourceTypes.Config.IResourceTypeConfig> = [\n {\n name: 'json',\n typeName: 'json'\n }\n];\n\n/**\n * An example system configuration demonstrating various configuration options.\n * @public\n */\nexport const ExtendedSystemConfiguration: ISystemConfiguration = {\n name: 'extended-example',\n description: 'An example system configuration demonstrating various configuration options',\n qualifierTypes: [...ExtendedQualifierTypes],\n qualifiers: [...ExtendedQualifiers],\n resourceTypes: [...ExtendedResourceTypes]\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/config/predefined/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC","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 Default from './default';\nimport * as Example from './extended';\n\nexport { Default, Example };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemConfiguration.js","sourceRoot":"","sources":["../../../src/packlets/config/systemConfiguration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAU,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGvF,OAAO,EAAiB,sBAAsB,EAAkC,MAAM,oBAAoB,CAAC;AAC3G,OAAO,EAA+B,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAA+C,qBAAqB,EAAE,MAA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AAqB,CAAC,MAAM,CAAC;YAChD,aAAa,EAAE,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE;SACtG,CAAC,CAAC,OAAO,EAAE,CAAC;IACf,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,MAAM,CAClB,MAA4B,EAC5B,UAA2C;QAE3C,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,sBAAsB,EAAE,CAAC;YACvC,kFAAkF;YAClF,OAAO,+CAA+C,CACpD,MAAM,EACN,UAAU,CAAC,sBAAsB,CAClC,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,EAAE,CAC5B,aAAa,CACX,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAC3F,CACF,CAAC;QACJ,CAAC;QACD,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,YAAY,CACxB,IAAY,EACZ,UAA2C;QAE3C,OAAO,QAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAClF,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAC/C,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,SAAS;QACd,OAAO,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;CACF","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 { captureResult, mapResults, Result, fail, succeed, omit } from '@fgv/ts-utils';\nimport * as QualifierTypes from '../qualifier-types';\nimport * as ResourceTypes from '../resource-types';\nimport { QualifierType, QualifierTypeCollector, ReadOnlyQualifierTypeCollector } from '../qualifier-types';\nimport { IReadOnlyQualifierCollector, QualifierCollector } from '../qualifiers';\nimport { ReadOnlyResourceTypeCollector, ResourceType, ResourceTypeCollector } from '../resource-types';\nimport { ISystemConfiguration } from './json';\nimport { systemConfiguration } from './convert';\nimport { JsonFile, sanitizeJsonObject } from '@fgv/ts-json-base';\nimport {\n BuiltInQualifierTypeFactory,\n BuiltInResourceTypeFactory,\n IConfigInitFactory\n} from './configInitFactory';\n\n/**\n * Parameters used to initialize a {@link Config.SystemConfiguration | SystemConfiguration}.\n * @public\n */\nexport interface ISystemConfigurationInitParams {\n /**\n * Optional map of qualifier names to default values. If provided, qualifiers\n * in the system configuration will be updated with these default values.\n * Use `null` as the value to remove an existing default value.\n */\n qualifierDefaultValues?: Record<string, string | null>; // eslint-disable-line @rushstack/no-new-null\n qualifierTypeFactory?: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType>;\n resourceTypeFactory?: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>;\n}\n\n/**\n * Creates a copy of the provided {@link Config.Model.ISystemConfiguration | system configuration}\n * with updated qualifier default values.\n * @param config - The base {@link Config.Model.ISystemConfiguration | system configuration} to copy.\n * @param qualifierDefaultValues - Map of qualifier names to default values. Use `null` to remove existing values.\n * @returns `Success` with the updated {@link Config.Model.ISystemConfiguration | system configuration}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\nexport function updateSystemConfigurationQualifierDefaultValues(\n config: ISystemConfiguration,\n qualifierDefaultValues: Record<string, string | null> // eslint-disable-line @rushstack/no-new-null\n): Result<ISystemConfiguration> {\n // Create a copy of the config\n return sanitizeJsonObject<ISystemConfiguration>(config).onSuccess((updatedConfig) => {\n // Create a map of existing qualifier names for validation\n const existingQualifierNames = new Set(updatedConfig.qualifiers.map((q) => q.name));\n\n // Validate that all specified qualifiers exist in the configuration\n for (const qualifierName of Object.keys(qualifierDefaultValues)) {\n if (!existingQualifierNames.has(qualifierName)) {\n return fail(`Qualifier '${qualifierName}' not found in system configuration`);\n }\n }\n\n // Update qualifier default values\n updatedConfig.qualifiers = updatedConfig.qualifiers.map((qualifier) => {\n if (qualifier.name in qualifierDefaultValues) {\n const newDefaultValue = qualifierDefaultValues[qualifier.name];\n\n // Create a copy of the qualifier\n const updatedQualifier = { ...qualifier };\n\n if (newDefaultValue === null) {\n // Remove the default value\n delete updatedQualifier.defaultValue;\n } else {\n // Set the new default value\n updatedQualifier.defaultValue = newDefaultValue;\n }\n\n return updatedQualifier;\n }\n return qualifier;\n });\n\n return succeed(updatedConfig);\n });\n}\n\n/**\n * A system configuration for both runtime or build.\n * @public\n */\nexport class SystemConfiguration {\n /**\n * The name of this system configuration.\n */\n public get name(): string | undefined {\n return this._config.name;\n }\n\n /**\n * The description of this system configuration.\n */\n public get description(): string | undefined {\n return this._config.description;\n }\n\n /**\n * The {@link QualifierTypes.QualifierTypeCollector | qualifier types} that this system configuration uses.\n */\n public readonly qualifierTypes: ReadOnlyQualifierTypeCollector;\n\n /**\n * The {@link QualifierTypes.QualifierTypeCollector | qualifier types} that this system configuration uses.\n * @public\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * The {@link ResourceTypes.ResourceTypeCollector | resource types} that this system configuration uses.\n */\n public readonly resourceTypes: ReadOnlyResourceTypeCollector;\n\n private readonly _config: ISystemConfiguration;\n\n /**\n * Constructs a new instance of a {@link Config.SystemConfiguration | SystemConfiguration} from the\n * supplied {@link Config.Model.ISystemConfiguration | system configuration}.\n * @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.\n * @public\n */\n protected constructor(config: ISystemConfiguration, initParams?: ISystemConfigurationInitParams) {\n this._config = config;\n const qualifierTypeFactory = initParams?.qualifierTypeFactory ?? new BuiltInQualifierTypeFactory();\n const resourceTypeFactory = initParams?.resourceTypeFactory ?? new BuiltInResourceTypeFactory();\n\n this.qualifierTypes = QualifierTypeCollector.create({\n qualifierTypes: mapResults(config.qualifierTypes.map((tc) => qualifierTypeFactory.create(tc))).orThrow()\n }).orThrow();\n\n this.qualifiers = QualifierCollector.create({\n qualifierTypes: this.qualifierTypes,\n qualifiers: config.qualifiers\n }).orThrow();\n\n this.resourceTypes = ResourceTypeCollector.create({\n resourceTypes: mapResults(config.resourceTypes.map((rt) => resourceTypeFactory.create(rt))).orThrow()\n }).orThrow();\n }\n\n /**\n * Creates a new {@link Config.SystemConfiguration | SystemConfiguration} from the supplied\n * {@link Config.Model.ISystemConfiguration | system configuration}.\n * @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.\n * @param initParams - Optional {@link Config.ISystemConfigurationInitParams | initialization parameters}.\n * @returns `Success` with the new {@link Config.SystemConfiguration | SystemConfiguration}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\n public static create(\n config: ISystemConfiguration,\n initParams?: ISystemConfigurationInitParams\n ): Result<SystemConfiguration> {\n if (initParams?.qualifierDefaultValues) {\n /* c8 ignore next 9 - functional code tested but coverage intermittently missed */\n return updateSystemConfigurationQualifierDefaultValues(\n config,\n initParams.qualifierDefaultValues\n ).onSuccess((updatedConfig) =>\n captureResult(\n () => new SystemConfiguration(updatedConfig, omit(initParams, ['qualifierDefaultValues']))\n )\n );\n }\n return captureResult(() => new SystemConfiguration(config, initParams));\n }\n\n /**\n * Loads a {@link Config.SystemConfiguration | SystemConfiguration} from a file.\n * @param path - The path to the file to load.\n * @returns `Success` with the {@link Config.SystemConfiguration | SystemConfiguration}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\n public static loadFromFile(\n path: string,\n initParams?: ISystemConfigurationInitParams\n ): Result<SystemConfiguration> {\n return JsonFile.convertJsonFileSync(path, systemConfiguration).onSuccess((config) =>\n SystemConfiguration.create(config, initParams)\n );\n }\n\n /**\n * Returns the {@link Config.Model.ISystemConfiguration | system configuration} that this\n * {@link Config.SystemConfiguration | SystemConfiguration} was created from.\n * @returns `Success` with the {@link Config.Model.ISystemConfiguration | system configuration}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\n public getConfig(): Result<ISystemConfiguration> {\n return systemConfiguration.convert(this._config);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextDecls.js","sourceRoot":"","sources":["../../../src/packlets/context/contextDecls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","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 { QualifierContextValue, QualifierName } from '../common';\nimport { Qualifier } from '../qualifiers';\n\n/**\n * Options to control matching of conditions against a context.\n * @public\n */\nexport interface IContextMatchOptions {\n /**\n * If true, then conditions which would otherwise yield\n * {@link NoMatch | NoMatch} but have a defined {@link Conditions.Condition.scoreAsDefault | scoreAsDefault}\n * will yield `scoreAsDefault`instead of `NoMatch`.\n */\n acceptDefaultScore?: boolean;\n\n /**\n * If true, then conditions for which a corresponding values is not present in the\n * context being matched will yield `undefined` instead of `NoMatch`.\n */\n partialContextMatch?: boolean;\n}\n\n/**\n * Non-validated declaration of a single context qualifier value.\n * @public\n */\nexport interface IContextQualifierValueDecl {\n qualifier: string;\n value: string;\n}\n\n/**\n * Non-validated declaration of a context, consisting of named\n * values.\n * @public\n */\nexport type IContextDecl = Record<string, string>;\n\n/**\n * Validated declaration of a single context qualifier value.\n * @public\n */\nexport interface IValidatedContextQualifierValueDecl {\n qualifier: Qualifier;\n value: QualifierContextValue;\n}\n\n/**\n * Validated declaration of a context, a record with strongly-typed\n * {@link QualifierTypeName | qualifier type names} as keys and\n * {@link QualifierContextValue | qualifier context values} as values.\n * @public\n */\nexport type IValidatedContextDecl = Record<QualifierName, QualifierContextValue>;\n"]}
|