@fgv/ts-res 5.1.0-2 → 5.1.0-21
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.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.map +1 -0
- 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 +78 -0
- package/dist/packlets/config/common.js.map +1 -0
- package/dist/packlets/config/configInitFactory.js +258 -0
- package/dist/packlets/config/configInitFactory.js.map +1 -0
- package/dist/packlets/config/convert.js +56 -0
- package/dist/packlets/config/convert.js.map +1 -0
- package/dist/packlets/config/index.browser.js +34 -0
- package/dist/packlets/config/index.browser.js.map +1 -0
- package/dist/packlets/config/index.js +28 -0
- package/dist/packlets/config/index.js.map +1 -0
- package/dist/packlets/config/json.js +23 -0
- package/dist/packlets/config/json.js.map +1 -0
- package/dist/packlets/config/predefined/default.js +138 -0
- package/dist/packlets/config/predefined/default.js.map +1 -0
- package/dist/packlets/config/predefined/extended.js +190 -0
- package/dist/packlets/config/predefined/extended.js.map +1 -0
- package/dist/packlets/config/predefined/index.js +25 -0
- package/dist/packlets/config/predefined/index.js.map +1 -0
- package/dist/packlets/config/systemConfiguration.js +147 -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 +124 -0
- package/dist/packlets/qualifier-types/config/convert.js.map +1 -0
- package/dist/packlets/qualifier-types/config/index.js +25 -0
- package/dist/packlets/qualifier-types/config/index.js.map +1 -0
- package/dist/packlets/qualifier-types/config/json.js +32 -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 +2 -2
- 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.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.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 +35 -0
- package/dist/packlets/resource-types/config/convert.js.map +1 -0
- package/dist/packlets/resource-types/config/index.js +25 -0
- package/dist/packlets/resource-types/config/index.js.map +1 -0
- package/dist/packlets/resource-types/config/json.js +23 -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.map +1 -0
- 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 +134 -112
- 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.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.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.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.map +1 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.js.map +1 -0
- package/lib/packlets/conditions/convert/decls.d.ts.map +1 -0
- 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 +35 -0
- package/lib/packlets/config/common.d.ts.map +1 -0
- package/lib/packlets/config/common.js +97 -0
- package/lib/packlets/config/common.js.map +1 -0
- package/lib/packlets/config/configInitFactory.d.ts +217 -0
- package/lib/packlets/config/configInitFactory.d.ts.map +1 -0
- package/lib/packlets/config/configInitFactory.js +303 -0
- package/lib/packlets/config/configInitFactory.js.map +1 -0
- package/lib/packlets/config/convert.d.ts +23 -0
- package/lib/packlets/config/convert.d.ts.map +1 -0
- package/lib/packlets/config/convert.js +93 -0
- package/lib/packlets/config/convert.js.map +1 -0
- package/lib/packlets/config/index.browser.d.ts +7 -0
- package/lib/packlets/config/index.browser.d.ts.map +1 -0
- package/lib/packlets/config/index.browser.js +74 -0
- package/lib/packlets/config/index.browser.js.map +1 -0
- package/lib/packlets/config/index.d.ts +7 -0
- package/lib/packlets/config/index.d.ts.map +1 -0
- package/lib/packlets/config/index.js +68 -0
- package/lib/packlets/config/index.js.map +1 -0
- package/lib/packlets/config/json.d.ts +20 -0
- package/lib/packlets/config/json.d.ts.map +1 -0
- package/lib/packlets/config/json.js +24 -0
- package/lib/packlets/config/json.js.map +1 -0
- package/lib/packlets/config/predefined/default.d.ts +57 -0
- package/lib/packlets/config/predefined/default.d.ts.map +1 -0
- package/lib/packlets/config/predefined/default.js +141 -0
- package/lib/packlets/config/predefined/default.js.map +1 -0
- package/lib/packlets/config/predefined/extended.d.ts +25 -0
- package/lib/packlets/config/predefined/extended.d.ts.map +1 -0
- package/lib/packlets/config/predefined/extended.js +193 -0
- package/lib/packlets/config/predefined/extended.js.map +1 -0
- package/lib/packlets/config/predefined/index.d.ts +4 -0
- package/lib/packlets/config/predefined/index.d.ts.map +1 -0
- package/lib/packlets/config/predefined/index.js +62 -0
- package/lib/packlets/config/predefined/index.js.map +1 -0
- package/lib/packlets/config/systemConfiguration.d.ts +94 -0
- package/lib/packlets/config/systemConfiguration.d.ts.map +1 -0
- package/lib/packlets/config/systemConfiguration.js +152 -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 +65 -0
- package/lib/packlets/qualifier-types/config/convert.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/convert.js +161 -0
- package/lib/packlets/qualifier-types/config/convert.js.map +1 -0
- package/lib/packlets/qualifier-types/config/index.d.ts +4 -0
- package/lib/packlets/qualifier-types/config/index.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/index.js +64 -0
- package/lib/packlets/qualifier-types/config/index.js.map +1 -0
- package/lib/packlets/qualifier-types/config/json.d.ts +91 -0
- package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/config/json.js +35 -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 +3 -3
- package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierCollector.js +2 -2
- 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.map +1 -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.map +1 -0
- 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 +8 -0
- package/lib/packlets/resource-types/config/convert.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/convert.js +38 -0
- package/lib/packlets/resource-types/config/convert.js.map +1 -0
- package/lib/packlets/resource-types/config/index.d.ts +4 -0
- package/lib/packlets/resource-types/config/index.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/index.js +64 -0
- package/lib/packlets/resource-types/config/index.js.map +1 -0
- package/lib/packlets/resource-types/config/json.d.ts +11 -0
- package/lib/packlets/resource-types/config/json.d.ts.map +1 -0
- package/lib/packlets/resource-types/config/json.js +24 -0
- package/lib/packlets/resource-types/config/json.js.map +1 -0
- package/lib/packlets/resource-types/helpers.d.ts.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.map +1 -0
- package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -0
- package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +1 -0
- 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 +28 -26
- 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
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
20
|
* SOFTWARE.
|
|
21
21
|
*/
|
|
22
|
-
import { captureResult, failWithDetail, succeed, succeedWithDetail
|
|
22
|
+
import { captureResult, failWithDetail, MessageAggregator, succeed, succeedWithDetail } from '@fgv/ts-utils';
|
|
23
23
|
import { Converters as JsonConverters } from '@fgv/ts-json-base';
|
|
24
24
|
import { FsItem } from '../fsItem';
|
|
25
25
|
/**
|
|
@@ -37,6 +37,8 @@ export class FsItemImporter {
|
|
|
37
37
|
*/
|
|
38
38
|
this.types = ['fsItem'];
|
|
39
39
|
this.qualifiers = params.qualifiers;
|
|
40
|
+
this.fileContentConverter = params.fileContentConverter;
|
|
41
|
+
this.fileContentExtensions = params.fileContentExtensions;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* Creates a new {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
@@ -47,7 +49,7 @@ export class FsItemImporter {
|
|
|
47
49
|
return captureResult(() => new FsItemImporter(params));
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
|
-
* {@
|
|
52
|
+
* {@inheritDoc Import.Importers.IImporter.import}
|
|
51
53
|
*/
|
|
52
54
|
import(item, __manager) {
|
|
53
55
|
const { value: fsItem, message: getTreeMessage, detail: getTreeDetail } = this._getFileTreeItemFromImportable(item);
|
|
@@ -81,23 +83,37 @@ export class FsItemImporter {
|
|
|
81
83
|
.withDetail('failed', 'processed');
|
|
82
84
|
}
|
|
83
85
|
else if (fsItem.item.type === 'file') {
|
|
84
|
-
if (fsItem.item.extension
|
|
85
|
-
return
|
|
86
|
-
.getContents(JsonConverters.jsonValue)
|
|
87
|
-
.onSuccess((json) => {
|
|
88
|
-
const jsonItem = {
|
|
89
|
-
type: 'json',
|
|
90
|
-
json,
|
|
91
|
-
context
|
|
92
|
-
};
|
|
93
|
-
return succeed([jsonItem]);
|
|
94
|
-
})
|
|
95
|
-
.withDetail('failed', 'processed');
|
|
86
|
+
if (!this._isSupportedFileExtension(fsItem.item.extension)) {
|
|
87
|
+
return succeedWithDetail([], 'skipped');
|
|
96
88
|
}
|
|
89
|
+
return this._getJsonContents(fsItem.item)
|
|
90
|
+
.onSuccess((json) => {
|
|
91
|
+
const jsonItem = {
|
|
92
|
+
type: 'json',
|
|
93
|
+
json,
|
|
94
|
+
context
|
|
95
|
+
};
|
|
96
|
+
return succeed([jsonItem]);
|
|
97
|
+
})
|
|
98
|
+
.withDetail('failed', 'processed');
|
|
97
99
|
}
|
|
98
100
|
/* c8 ignore next 2 - defensive coding: fallback case for unsupported file types */
|
|
99
101
|
return succeedWithDetail([], 'skipped');
|
|
100
102
|
}
|
|
103
|
+
_isSupportedFileExtension(extension) {
|
|
104
|
+
return extension === '.json' || this._canConvertFileExtension(extension);
|
|
105
|
+
}
|
|
106
|
+
_getJsonContents(file) {
|
|
107
|
+
const converter = this.fileContentConverter;
|
|
108
|
+
if (converter !== undefined) {
|
|
109
|
+
return file.getRawContents().onSuccess((contents) => converter.convert(contents));
|
|
110
|
+
}
|
|
111
|
+
return file.getContents(JsonConverters.jsonValue);
|
|
112
|
+
}
|
|
113
|
+
_canConvertFileExtension(extension) {
|
|
114
|
+
var _a;
|
|
115
|
+
return (this.fileContentConverter !== undefined && ((_a = this.fileContentExtensions) === null || _a === void 0 ? void 0 : _a.includes(extension)) === true);
|
|
116
|
+
}
|
|
101
117
|
/**
|
|
102
118
|
* Gets an {@link Import.FsItem | FsItem} from an {@link Import.IImportable | importable}.
|
|
103
119
|
* @param item - The importable to convert.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsItemImporter.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/fsItemImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,aAAa,EAEb,cAAc,EACd,iBAAiB,EAEjB,OAAO,EACP,iBAAiB,EAElB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,IAAI,cAAc,EAAuB,MAAM,mBAAmB,CAAC;AAKtF,OAAO,EAAE,MAAM,EAAsB,MAAM,WAAW,CAAC;AAYvD;;;GAGG;AACH,MAAM,OAAO,cAAc;IAqBzB;;;OAGG;IACH,YAAsB,MAAmC;QATzD;;WAEG;QACa,UAAK,GAA0B,CAAC,QAAQ,CAAC,CAAC;QAOxD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAA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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 captureResult,\n DetailedResult,\n failWithDetail,\n MessageAggregator,\n Result,\n succeed,\n succeedWithDetail,\n Converter\n} from '@fgv/ts-utils';\nimport { Converters as JsonConverters, FileTree, JsonValue } from '@fgv/ts-json-base';\nimport { ResourceManagerBuilder } from '../../resources';\nimport { IImportable, IImportableJson, Importable } from '../importable';\nimport { IImporter, ImporterResultDetail } from './importer';\nimport { IReadOnlyQualifierCollector } from '../../qualifiers';\nimport { FsItem, FsItemResultDetail } from '../fsItem';\n\n/**\n * Parameters for creating a {@link Import.Importers.FsItemImporter | FsItemImporter}.\n * @public\n */\nexport interface IFsItemImporterCreateParams {\n qualifiers: IReadOnlyQualifierCollector;\n fileContentConverter?: Converter<JsonValue>;\n fileContentExtensions?: ReadonlyArray<string>;\n}\n\n/**\n * {@link Import.Importers.IImporter | Importer} implementation which imports resources from a `FileTree`.\n * @public\n */\nexport class FsItemImporter implements IImporter {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} to use for this importer.\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Optional converter used to parse raw file contents before they are exposed as JSON importables.\n */\n public readonly fileContentConverter?: Converter<JsonValue>;\n\n /**\n * Optional list of file extensions which should be parsed using the file content converter.\n */\n public readonly fileContentExtensions?: ReadonlyArray<string>;\n\n /**\n * The types of {@link Import.IImportable | importables} that this importer can handle.\n */\n public readonly types: ReadonlyArray<string> = ['fsItem'];\n\n /**\n * Protected constructor for the {@link Import.Importers.FsItemImporter | FsItemImporter}.\n * @param params - Parameters for creating the {@link Import.Importers.FsItemImporter | FsItemImporter}.\n */\n protected constructor(params: IFsItemImporterCreateParams) {\n this.qualifiers = params.qualifiers;\n this.fileContentConverter = params.fileContentConverter;\n this.fileContentExtensions = params.fileContentExtensions;\n }\n\n /**\n * Creates a new {@link Import.Importers.FsItemImporter | FsItemImporter}.\n * @param params - Parameters for creating the {@link Import.Importers.FsItemImporter | FsItemImporter}.\n * @returns `Success` with the new `FsItemImporter` if successful, `Failure` with an error message if not.\n */\n public static create(params: IFsItemImporterCreateParams): Result<FsItemImporter> {\n return captureResult(() => new FsItemImporter(params));\n }\n\n /**\n * {@inheritDoc Import.Importers.IImporter.import}\n */\n public import(\n item: IImportable,\n __manager: ResourceManagerBuilder\n ): DetailedResult<IImportable[], ImporterResultDetail> {\n const {\n value: fsItem,\n message: getTreeMessage,\n detail: getTreeDetail\n } = this._getFileTreeItemFromImportable(item);\n if (getTreeMessage !== undefined) {\n return failWithDetail(getTreeMessage, getTreeDetail === 'skipped' ? 'skipped' : 'failed');\n }\n\n const { value: context, message: getContextMessage } = fsItem.getContext().onSuccess((fsItemContext) => {\n return item.context ? item.context.extend(fsItemContext) : succeed(fsItemContext);\n });\n\n /* c8 ignore next 3 - defensive coding: getContext failure is extremely rare in practice */\n if (getContextMessage) {\n return failWithDetail(getContextMessage, 'failed');\n }\n\n if (fsItem.item.type === 'directory') {\n return fsItem.item\n .getChildren()\n .onSuccess((children) => {\n const errors = new MessageAggregator();\n const items: Importable[] = [];\n for (const child of children) {\n const { value: item, message, detail } = FsItem.createForItem(child, this.qualifiers);\n if (item) {\n items.push({ type: 'fsItem', item, context });\n } else if (detail !== 'skipped') {\n errors.addMessage(message);\n }\n }\n return errors.returnOrReport(succeed(items));\n })\n .withDetail('failed', 'processed');\n } else if (fsItem.item.type === 'file') {\n if (!this._isSupportedFileExtension(fsItem.item.extension)) {\n return succeedWithDetail([], 'skipped');\n }\n\n return this._getJsonContents(fsItem.item)\n .onSuccess((json) => {\n const jsonItem: IImportableJson = {\n type: 'json',\n json,\n context\n };\n return succeed([jsonItem]);\n })\n .withDetail('failed', 'processed');\n }\n /* c8 ignore next 2 - defensive coding: fallback case for unsupported file types */\n return succeedWithDetail([], 'skipped');\n }\n\n private _isSupportedFileExtension(extension: string): boolean {\n return extension === '.json' || this._canConvertFileExtension(extension);\n }\n\n private _getJsonContents(file: FileTree.IFileTreeFileItem): Result<JsonValue> {\n const converter = this.fileContentConverter;\n if (converter !== undefined) {\n return file.getRawContents().onSuccess((contents) => converter.convert(contents));\n }\n\n return file.getContents(JsonConverters.jsonValue);\n }\n\n private _canConvertFileExtension(extension: string): boolean {\n return (\n this.fileContentConverter !== undefined && this.fileContentExtensions?.includes(extension) === true\n );\n }\n\n /**\n * Gets an {@link Import.FsItem | FsItem} from an {@link Import.IImportable | importable}.\n * @param item - The importable to convert.\n * @returns `Success` containing the `FsItem` if successful, `Failure` with an error message if not.\n */\n protected _getFileTreeItemFromImportable(item: IImportable): DetailedResult<FsItem, FsItemResultDetail> {\n if (item.type === 'fsItem') {\n if ('item' in item && item.item instanceof FsItem) {\n return succeedWithDetail(item.item, 'succeeded');\n }\n return failWithDetail(`malformed fsItem importable does not contain a valid item`, 'failed');\n }\n return failWithDetail(`${item.type}: invalid importable type for an FsItemImporter`, 'skipped');\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importer.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/importer.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 { DetailedResult } from '@fgv/ts-utils';\nimport { IImportable } from '../importable';\nimport { ResourceManagerBuilder } from '../../resources';\n\n/**\n * Possible results of an import operation.\n * @public\n */\nexport type ImporterResultDetail = 'consumed' | 'processed' | 'skipped' | 'failed';\n\n/**\n * Generic interface for an importer than accepts a typed\n * {@link Import.IImportable | importable} item, extracts any resources\n * or candidates from it, and returns an optional list of\n * additional importable items derived from the original.\n * @public\n */\nexport interface IImporter {\n /**\n * The types of {@link Import.Importable | importable} items that this importer can process.\n */\n readonly types: ReadonlyArray<string>;\n\n /**\n * Imports an item, extracting any resources or candidates from it and returns an optional\n * list of additional importable items derived from it.\n * @param item - The {@link Import.IImportable | importable} item to import.\n * @param manager - The {@link Resources.ResourceManagerBuilder | resource manager builder} to use for the import.\n * @returns `Success` with a list of additional importable items derived from the original, or\n * `Failure` with an error message and a {@link Import.Importers.ImporterResultDetail | result detail}.\n */\n import(\n item: IImportable,\n manager: ResourceManagerBuilder\n ): DetailedResult<IImportable[], ImporterResultDetail>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/index.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,oEAAoE;AAEpE,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAE/B,yBAAyB;AACzB,gDAAgD;AAChD,oEAAoE","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 importers - excludes Node.js filesystem dependencies\n\nexport * from './importer';\nexport * from './collectionImporter';\nexport * from './jsonImporter';\n\n// Excluded from browser:\n// - fsItemImporter (processes filesystem items)\n// - pathImporter (requires Node.js fs via FileTree.forFilesystem())\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,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 './importer';\nexport * from './collectionImporter';\nexport * from './fsItemImporter';\nexport * from './jsonImporter';\nexport * from './pathImporter';\n"]}
|
|
@@ -32,7 +32,7 @@ export class JsonImporter {
|
|
|
32
32
|
*/
|
|
33
33
|
constructor() {
|
|
34
34
|
/**
|
|
35
|
-
* {@
|
|
35
|
+
* {@inheritDoc Import.Importers.IImporter.types}
|
|
36
36
|
*/
|
|
37
37
|
this.types = ['json'];
|
|
38
38
|
}
|
|
@@ -45,7 +45,7 @@ export class JsonImporter {
|
|
|
45
45
|
return captureResult(() => new JsonImporter());
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* {@
|
|
48
|
+
* {@inheritDoc Import.Importers.IImporter.import}
|
|
49
49
|
*/
|
|
50
50
|
import(item, manager) {
|
|
51
51
|
var _a, _b;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonImporter.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/jsonImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAkB,cAAc,EAAU,OAAO,EAAE,MAAM,eAAe,CAAC;AAG/F,OAAO,EAA4C,YAAY,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAC;AAEpD;;;GAGG;AACH,MAAM,OAAO,YAAY;IAMvB;;OAEG;IACH;QARA;;WAEG;QACa,UAAK,GAA0B,CAAC,MAAM,CAAC,CAAC;IAK/B,CAAC;IAE1B;;;;OAIG;IACI,MAAM,CAAC,MAAM;QAClB,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACI,MAAM,CACX,IAAiB,EACjB,OAA+B;;QAE/B,qEAAqE;QACrE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAChD,uFAAuF;YACvF,MAAM,IAAI,GAAG,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,mCAAI,SAAS,CAAC;YAC/C,OAAO,cAAc,CAAC,GAAG,IAAI,8BAA8B,IAAI,CAAC,IAAI,GAAG,EAAE,SAAS,CAAC,CAAC;QACtF,CAAC;QACD,OAAO,CACL,IA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ted, 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, DetailedResult, failWithDetail, Result, succeed } from '@fgv/ts-utils';\nimport { IImporter, ImporterResultDetail } from './importer';\nimport { ResourceManagerBuilder } from '../../resources';\nimport { IImportable, IImportableJson, Importable, isImportable } from '../importable';\nimport * as ResourceJson from '../../resource-json';\n\n/**\n * {@link Import.Importers.IImporter | Importer} implementation which imports resources from a JSON object.\n * @public\n */\nexport class JsonImporter implements IImporter {\n /**\n * {@inheritDoc Import.Importers.IImporter.types}\n */\n public readonly types: ReadonlyArray<string> = ['json'];\n\n /**\n * Protected {@link Import.Importers.JsonImporter | JsonImporter} constructor for derived classes.\n */\n protected constructor() {}\n\n /**\n * Creates a new {@link Import.Importers.JsonImporter | JsonImporter} instance.\n * @returns `Success` with the new {@link Import.Importers.JsonImporter | JsonImporter} if successful,\n * `Failure` otherwise.\n */\n public static create(): Result<JsonImporter> {\n return captureResult(() => new JsonImporter());\n }\n\n /**\n * {@inheritDoc Import.Importers.IImporter.import}\n */\n public import(\n item: IImportable,\n manager: ResourceManagerBuilder\n ): DetailedResult<IImportable[], ImporterResultDetail> {\n /* c8 ignore next 1 - coverage intermittently misses the next line */\n if (!isImportable(item) || item.type !== 'json') {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n const name = item.context?.baseId ?? 'unknown';\n return failWithDetail(`${name}: invalid JSON importable (${item.type})`, 'skipped');\n }\n return (\n this._tryImportResourceCollection(item)\n .onFailure(() => this._tryImportResourceTree(item))\n // experimenting with this, accepting any JSON object here makes it\n // very hard to distinguish a collection or tree with a typo from a\n // legitimate single loose resource, which yields extremely confusing\n // error messages. Disabled until/unless we come up with a better plan.\n //.onFailure(() => this._tryImportResource(item, manager));\n .onFailure(() =>\n /* c8 ignore next 1 - defense in depth */\n failWithDetail(`${item.context?.baseId ?? 'unknown'}: unrecognized JSON format.`, 'failed')\n )\n );\n }\n\n private _tryImportResourceCollection(\n item: IImportableJson\n ): DetailedResult<IImportable[], ImporterResultDetail> {\n return ResourceJson.ResourceDeclCollection.create(item.json)\n .onSuccess((collection) => {\n const importable: Importable = {\n type: 'resourceCollection',\n collection,\n context: item.context\n };\n return succeed([importable]);\n })\n .withDetail('skipped', 'consumed');\n }\n\n private _tryImportResourceTree(item: IImportableJson): DetailedResult<IImportable[], ImporterResultDetail> {\n return ResourceJson.ResourceDeclTree.create(item.json)\n .onSuccess((tree) => {\n const importable: Importable = {\n type: 'resourceTree',\n tree,\n context: item.context\n };\n return succeed([importable]);\n })\n .withDetail('skipped', 'consumed');\n }\n\n /* \n * This is disabled for now because it's too easy to accidentally import\n * a single loose resource as a collection or tree, which yields extremely\n * confusing error messages.\n\n private _tryImportResource(\n item: IImportableJson,\n manager: ResourceManagerBuilder\n ): DetailedResult<IImportable[], ImporterResultDetail> {\n return JsonConverters.jsonObject\n .convert(item.json)\n .onSuccess((json) => {\n // c8 ignore next 2 - defense in depth\n const id = item.context?.baseId ?? '';\n const conditions = item.context?.conditions;\n const candidate: ResourceJson.Json.ILooseResourceCandidateDecl = { id, conditions, json };\n return manager.addLooseCandidate(candidate);\n })\n .onSuccess(() => {\n return succeed([]);\n })\n .withDetail('failed', 'consumed');\n }\n */\n}\n"]}
|
|
@@ -51,7 +51,7 @@ export class PathImporter {
|
|
|
51
51
|
return captureResult(() => new PathImporter(params));
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* {@
|
|
54
|
+
* {@inheritDoc Import.Importers.IImporter.import}
|
|
55
55
|
*/
|
|
56
56
|
import(item, __manager) {
|
|
57
57
|
const { value: fsItem, message: getTreeMessage, detail: getTreeDetail } = this._getFileTreeItemFromImportable(item);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathImporter.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/pathImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAkB,cAAc,EAAU,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7C,OAAO,EAAE,MAAM,EAAsB,MAAM,WAAW,CAAC;AAYvD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAsBvB;;;OAGG;IACH,YAAsB,MAAiC;;QAfvD;;WAEG;QACa,UAAK,GAA0B,CAAC,MAAM,CAAC,CAAC;QAatD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,MAAA,MAAM,CAAC,IAAI,mCAAI,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,CAAC;QAC9D,IAAI,CAAC,eAAe,GAAG,MAAA,MAAM,CAAC,eAAe,mCAAI,EAAE,CAAC;IACtD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,MAAiC;QACpD,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,CAA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I,8CAA8C,EAAE,SAAS,CAAC,CAAC;IAC/F,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, DetailedResult, failWithDetail, Result, succeedWithDetail } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport { ResourceManagerBuilder } from '../../resources';\nimport { IImportable } from '../importable';\nimport { IImporter, ImporterResultDetail } from './importer';\nimport { IReadOnlyQualifierCollector } from '../../qualifiers';\nimport { FsItem, FsItemResultDetail } from '../fsItem';\n\n/**\n * Parameters for creating a {@link Import.Importers.PathImporter | PathImporter}.\n * @public\n */\nexport interface IPathImporterCreateParams {\n qualifiers: IReadOnlyQualifierCollector;\n tree?: FileTree.FileTree;\n ignoreFileTypes?: string[];\n}\n\n/**\n * {@link Import.Importers.IImporter | Importer} implementation which imports resources from a `FileTree`\n * given a path.\n * @public\n */\nexport class PathImporter implements IImporter {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} to use for this importer.\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * The `FileTree` from which resources will be imported.\n */\n public readonly tree: FileTree.FileTree;\n\n /**\n * The types of {@link Import.IImportable | importables} that this importer can handle.\n */\n public readonly types: ReadonlyArray<string> = ['path'];\n\n /**\n * The types of files to ignore when importing. Any file not ignored is converted\n * to an {@link Import.IImportableFsItem | IImportableFsItem}.\n */\n public readonly ignoreFileTypes: string[];\n\n /**\n * Protected constructor for the {@link Import.Importers.PathImporter | PathImporter}.\n * @param params - Parameters for creating the {@link Import.Importers.PathImporter | PathImporter}.\n */\n protected constructor(params: IPathImporterCreateParams) {\n this.qualifiers = params.qualifiers;\n this.tree = params.tree ?? FileTree.forFilesystem().orThrow();\n this.ignoreFileTypes = params.ignoreFileTypes ?? [];\n }\n\n /**\n * Creates a new {@link Import.Importers.PathImporter | PathImporter}.\n * @param params - Parameters for creating the {@link Import.Importers.PathImporter | dirPathImporter}.\n * @returns `Success` with the new `PathImporter` if successful, `Failure` with an error message if not.\n */\n public static create(params: IPathImporterCreateParams): Result<PathImporter> {\n return captureResult(() => new PathImporter(params));\n }\n\n /**\n * {@inheritDoc Import.Importers.IImporter.import}\n */\n public import(\n item: IImportable,\n __manager: ResourceManagerBuilder\n ): DetailedResult<IImportable[], ImporterResultDetail> {\n const {\n value: fsItem,\n message: getTreeMessage,\n detail: getTreeDetail\n } = this._getFileTreeItemFromImportable(item);\n if (getTreeMessage !== undefined) {\n return failWithDetail(getTreeMessage, getTreeDetail === 'skipped' ? 'skipped' : 'failed');\n }\n\n if (fsItem.item.type === 'file' && this.ignoreFileTypes.includes(fsItem.item.extension)) {\n return succeedWithDetail([], 'processed');\n }\n\n // extracted characteristics are in the fsItem so add them to the context when\n // that is imported instead of now.\n const context = item.context;\n\n return succeedWithDetail([{ type: 'fsItem', item: fsItem, context }], 'processed');\n }\n\n /**\n * Gets an {@link Import.FsItem | FsItem} from an {@link Import.IImportable | importable}.\n * @param item - The importable to convert.\n * @returns `Success` containing the `FsItem` if successful, `Failure` with an error message if not.\n */\n protected _getFileTreeItemFromImportable(item: IImportable): DetailedResult<FsItem, FsItemResultDetail> {\n if (item.type === 'path') {\n if ('path' in item && typeof item.path === 'string') {\n return FsItem.createForPath(item.path, this.qualifiers, this.tree);\n }\n return failWithDetail(`malformed path importable does not contain a string path`, 'failed');\n }\n return failWithDetail(`${item.type}: invalid importable type for a PathImporter`, 'skipped');\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/packlets/import/index.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,yEAAyE;AAEzE,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAEhC,kEAAkE;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,mCAAmC;AACnC,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,yBAAyB;AACzB,4FAA4F;AAC5F,qEAAqE","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 import exports - excludes Node.js filesystem dependencies\n\nexport * from './importContext';\nexport * from './importable';\nexport * from './importManager';\n\n// Export FsItem class (browser-safe for in-memory FileTree usage)\nexport { FsItem } from './fsItem';\n\n// Use browser-safe importers index\nimport * as Importers from './importers/index.browser';\nexport { Importers };\n\n// Excluded from browser:\n// - FsItem.createForPath() static method (requires Node.js fs via FileTree.forFilesystem())\n// - PathImporter and FsItemImporter (via importers/index.browser.ts)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/import/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAEhC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,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\nexport * from './importContext';\nexport * from './importable';\nexport * from './fsItem';\nexport * from './importManager';\n\nimport * as Importers from './importers';\nexport { Importers };\n"]}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
/* eslint-disable @rushstack/typedef-var */
|
|
23
|
+
import { Converters } from '@fgv/ts-utils';
|
|
24
|
+
import * as Common from '../../common';
|
|
25
|
+
import { Converters as JsonConverters } from '@fgv/ts-json-base';
|
|
26
|
+
/**
|
|
27
|
+
* A `Converter` for {@link QualifierTypes.Config.ILanguageQualifierTypeConfig | LanguageQualifierTypeConfig} objects.
|
|
28
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.ILanguageQualifierTypeConfig | LanguageQualifierTypeConfig} objects.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export const languageQualifierTypeConfig = Converters.strictObject({
|
|
32
|
+
allowContextList: Converters.boolean.optional()
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* A `Converter` for {@link QualifierTypes.Config.ITerritoryQualifierTypeConfig | TerritoryQualifierTypeConfig} objects.
|
|
36
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.ITerritoryQualifierTypeConfig | TerritoryQualifierTypeConfig} objects.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export const territoryQualifierTypeConfig = Converters.strictObject({
|
|
40
|
+
allowContextList: Converters.boolean,
|
|
41
|
+
acceptLowercase: Converters.boolean.optional(),
|
|
42
|
+
allowedTerritories: Converters.arrayOf(Converters.string).optional(),
|
|
43
|
+
hierarchy: Converters.recordOf(Converters.string).optional()
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* A `Converter` for {@link QualifierTypes.Config.ILiteralQualifierTypeConfig | LiteralQualifierTypeConfig} objects.
|
|
47
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.ILiteralQualifierTypeConfig | LiteralQualifierTypeConfig} objects.
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export const literalQualifierTypeConfig = Converters.strictObject({
|
|
51
|
+
allowContextList: Converters.boolean.optional(),
|
|
52
|
+
caseSensitive: Converters.boolean.optional(),
|
|
53
|
+
enumeratedValues: Converters.arrayOf(Converters.string).optional(),
|
|
54
|
+
hierarchy: Converters.recordOf(Converters.string).optional()
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.
|
|
58
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export const systemLanguageQualifierTypeConfig = Converters.strictObject({
|
|
62
|
+
name: Converters.string,
|
|
63
|
+
systemType: Converters.literal('language'),
|
|
64
|
+
configuration: languageQualifierTypeConfig.optional()
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* A `Converter` for {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | SystemTerritoryQualifierTypeConfig} objects.
|
|
68
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | SystemTerritoryQualifierTypeConfig} objects.
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export const systemTerritoryQualifierTypeConfig = Converters.strictObject({
|
|
72
|
+
name: Converters.string,
|
|
73
|
+
systemType: Converters.literal('territory'),
|
|
74
|
+
configuration: territoryQualifierTypeConfig.optional()
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* A `Converter` for {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | SystemLiteralQualifierTypeConfig} objects.
|
|
78
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | SystemLiteralQualifierTypeConfig} objects.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export const systemLiteralQualifierTypeConfig = Converters.strictObject({
|
|
82
|
+
name: Converters.string,
|
|
83
|
+
systemType: Converters.literal('literal'),
|
|
84
|
+
configuration: literalQualifierTypeConfig.optional()
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.
|
|
88
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
export const systemQualifierTypeConfig = Converters.discriminatedObject('systemType', {
|
|
92
|
+
language: systemLanguageQualifierTypeConfig,
|
|
93
|
+
territory: systemTerritoryQualifierTypeConfig,
|
|
94
|
+
literal: systemLiteralQualifierTypeConfig
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
|
|
98
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
|
|
99
|
+
* @param config - A `Converter` for the configuration object.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
export function qualifierTypeConfig(config) {
|
|
103
|
+
return Converters.strictObject({
|
|
104
|
+
name: Common.Convert.qualifierTypeName,
|
|
105
|
+
systemType: Common.Convert.qualifierTypeName,
|
|
106
|
+
configuration: config.optional()
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
|
|
111
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
export const jsonQualifierTypeConfig = qualifierTypeConfig(JsonConverters.jsonObject);
|
|
115
|
+
/**
|
|
116
|
+
* A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.
|
|
117
|
+
* @returns A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export const anyQualifierTypeConfig = Converters.oneOf([
|
|
121
|
+
jsonQualifierTypeConfig,
|
|
122
|
+
systemQualifierTypeConfig
|
|
123
|
+
]);
|
|
124
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../../src/packlets/qualifier-types/config/convert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,2CAA2C;AAE3C,OAAO,EAAa,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAAC,YAAY,CAAqC;IACrG,gBAAgB,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE;CAChD,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAAC,YAAY,CAAsC;IACvG,gBAAgB,EAAE,UAAU,CAAC,OAAO;IACpC,eAAe,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE;IAC9C,kBAAkB,EAAE,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;IACpE,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;CAC7D,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAAC,YAAY,CAAoC;IACnG,gBAAgB,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE;IAC/C,aAAa,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE;IAC5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C,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB;QAC5C,aAAa,EAAE,MAAM,CAAC,QAAQ,EAAE;KACjC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;AAEtF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC,KAAK,CAAgC;IACpF,uBAAuB;IACvB,yBAAyB;CAC1B,CAAC,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 { Converter, Converters } from '@fgv/ts-utils';\nimport * as Model from './json';\nimport * as Common from '../../common';\nimport { Converters as JsonConverters } from '@fgv/ts-json-base';\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.ILanguageQualifierTypeConfig | LanguageQualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.ILanguageQualifierTypeConfig | LanguageQualifierTypeConfig} objects.\n * @public\n */\nexport const languageQualifierTypeConfig = Converters.strictObject<Model.ILanguageQualifierTypeConfig>({\n allowContextList: Converters.boolean.optional()\n});\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.ITerritoryQualifierTypeConfig | TerritoryQualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.ITerritoryQualifierTypeConfig | TerritoryQualifierTypeConfig} objects.\n * @public\n */\nexport const territoryQualifierTypeConfig = Converters.strictObject<Model.ITerritoryQualifierTypeConfig>({\n allowContextList: Converters.boolean,\n acceptLowercase: Converters.boolean.optional(),\n allowedTerritories: Converters.arrayOf(Converters.string).optional(),\n hierarchy: Converters.recordOf(Converters.string).optional()\n});\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.ILiteralQualifierTypeConfig | LiteralQualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.ILiteralQualifierTypeConfig | LiteralQualifierTypeConfig} objects.\n * @public\n */\nexport const literalQualifierTypeConfig = Converters.strictObject<Model.ILiteralQualifierTypeConfig>({\n allowContextList: Converters.boolean.optional(),\n caseSensitive: Converters.boolean.optional(),\n enumeratedValues: Converters.arrayOf(Converters.string).optional(),\n hierarchy: Converters.recordOf(Converters.string).optional()\n});\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.\n * @public\n */\nexport const systemLanguageQualifierTypeConfig =\n Converters.strictObject<Model.ISystemLanguageQualifierTypeConfig>({\n name: Converters.string,\n systemType: Converters.literal('language'),\n configuration: languageQualifierTypeConfig.optional()\n });\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | SystemTerritoryQualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | SystemTerritoryQualifierTypeConfig} objects.\n * @public\n */\nexport const systemTerritoryQualifierTypeConfig =\n Converters.strictObject<Model.ISystemTerritoryQualifierTypeConfig>({\n name: Converters.string,\n systemType: Converters.literal('territory'),\n configuration: territoryQualifierTypeConfig.optional()\n });\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | SystemLiteralQualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | SystemLiteralQualifierTypeConfig} objects.\n * @public\n */\nexport const systemLiteralQualifierTypeConfig =\n Converters.strictObject<Model.ISystemLiteralQualifierTypeConfig>({\n name: Converters.string,\n systemType: Converters.literal('literal'),\n configuration: literalQualifierTypeConfig.optional()\n });\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.\n * @public\n */\nexport const systemQualifierTypeConfig = Converters.discriminatedObject<Model.ISystemQualifierTypeConfig>(\n 'systemType',\n {\n language: systemLanguageQualifierTypeConfig,\n territory: systemTerritoryQualifierTypeConfig,\n literal: systemLiteralQualifierTypeConfig\n }\n);\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.\n * @param config - A `Converter` for the configuration object.\n * @public\n */\nexport function qualifierTypeConfig<T, TD = unknown>(\n config: Converter<T, TD>\n): Converter<Model.IQualifierTypeConfig<T>, TD> {\n return Converters.strictObject<Model.IQualifierTypeConfig<T>, TD>({\n name: Common.Convert.qualifierTypeName,\n systemType: Common.Convert.qualifierTypeName,\n configuration: config.optional()\n });\n}\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.\n * @public\n */\nexport const jsonQualifierTypeConfig = qualifierTypeConfig(JsonConverters.jsonObject);\n\n/**\n * A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.\n * @returns A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.\n * @public\n */\nexport const anyQualifierTypeConfig = Converters.oneOf<Model.IAnyQualifierTypeConfig>([\n jsonQualifierTypeConfig,\n systemQualifierTypeConfig\n]);\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import * as Convert from './convert';
|
|
23
|
+
export * from './json';
|
|
24
|
+
export { Convert };
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/qualifier-types/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,cAAc,QAAQ,CAAC;AAEvB,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 './json';\n\nexport { Convert };\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Checks if a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} is a
|
|
24
|
+
* {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.
|
|
25
|
+
* @param config - The {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} to check.
|
|
26
|
+
* @returns `true` if the configuration is a system qualifier type configuration, `false` otherwise.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export function isSystemQualifierTypeConfig(config) {
|
|
30
|
+
return (config.systemType === 'language' || config.systemType === 'territory' || config.systemType === 'literal');
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../../src/packlets/qualifier-types/config/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAsGH;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAA+B;IAE/B,OAAO,CACL,MAAM,CAAC,UAAU,KAAK,UAAU,IAAI,MAAM,CAAC,UAAU,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,CACzG,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 { JsonObject } from '@fgv/ts-json-base';\n\n/**\n * Templated configuration for {@link QualifierTypes.QualifierType | qualifier type} configuration.\n * @public\n */\nexport interface IQualifierTypeConfig<T = JsonObject> {\n name: string;\n systemType: string;\n configuration?: T;\n}\n\n/**\n * Configuration for {@link QualifierTypes.LanguageQualifierType | language qualifier type} configuration.\n * @public\n */\nexport interface ILanguageQualifierTypeConfig {\n allowContextList?: boolean;\n}\n\n/**\n * Declares a hierarchy of literal values. The keys are the names of the values, and the\n * values are the names of their parents.\n * @remarks\n * The hierarchy is defined as a tree, where each value can have multiple children but\n * only one parent. The root of the tree has no parent. The hierarchy is used to\n * determine the relationship between values when matching conditions and contexts.\n * @public\n */\nexport type LiteralValueHierarchyDecl<T extends string> = Record<T, T>;\n\n/**\n * Configuration for {@link QualifierTypes.TerritoryQualifierType | territory qualifier type} configuration.\n * @public\n */\nexport interface ITerritoryQualifierTypeConfig {\n allowContextList?: boolean;\n\n acceptLowercase?: boolean;\n allowedTerritories?: string[];\n\n /**\n * Optional {@link QualifierTypes.Config.LiteralValueHierarchyDecl | hierarchy declaration}\n * of territory values to use for matching. If not provided, no hierarchy will be used.\n */\n hierarchy?: LiteralValueHierarchyDecl<string>;\n}\n\n/**\n * Configuration for {@link QualifierTypes.LiteralQualifierType | literal qualifier type} configuration.\n * @public\n */\nexport interface ILiteralQualifierTypeConfig {\n allowContextList?: boolean;\n caseSensitive?: boolean;\n enumeratedValues?: string[];\n hierarchy?: LiteralValueHierarchyDecl<string>;\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.LanguageQualifierType | language qualifier type} configuration.\n * @public\n */\nexport interface ISystemLanguageQualifierTypeConfig\n extends IQualifierTypeConfig<ILanguageQualifierTypeConfig> {\n systemType: 'language';\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.TerritoryQualifierType | territory qualifier type} configuration.\n * @public\n */\nexport interface ISystemTerritoryQualifierTypeConfig\n extends IQualifierTypeConfig<ITerritoryQualifierTypeConfig> {\n systemType: 'territory';\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.LiteralQualifierType | literal qualifier type} configuration.\n * @public\n */\nexport interface ISystemLiteralQualifierTypeConfig extends IQualifierTypeConfig<ILiteralQualifierTypeConfig> {\n systemType: 'literal';\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.QualifierType | qualifier type} configuration.\n * @public\n */\nexport type ISystemQualifierTypeConfig =\n | ISystemLanguageQualifierTypeConfig\n | ISystemTerritoryQualifierTypeConfig\n | ISystemLiteralQualifierTypeConfig;\n\n/**\n * A union of all qualifier type configurations.\n * @public\n */\nexport type IAnyQualifierTypeConfig = IQualifierTypeConfig | ISystemQualifierTypeConfig;\n\n/**\n * Checks if a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} is a\n * {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.\n * @param config - The {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} to check.\n * @returns `true` if the configuration is a system qualifier type configuration, `false` otherwise.\n * @public\n */\nexport function isSystemQualifierTypeConfig(\n config: IAnyQualifierTypeConfig\n): config is ISystemQualifierTypeConfig {\n return (\n config.systemType === 'language' || config.systemType === 'territory' || config.systemType === 'literal'\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/packlets/qualifier-types/convert.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAa,UAAU,EAAU,IAAI,EAAE,MAAM,eAAe,CAAC;AAcpE;;;;;GAKG;AACH,kDAAkD;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAC7C,CACE,IAAa,EACb,MAA8D,EAC9D,OAAsC,EACf,EAAE;IACzB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;SAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,IAAI,CAAC,qDAAqD,CAAC,CAAC;AACrE,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAC/C,cAA4B;IAE5B,OAAO,UAAU,CAAC,MAAM,CAAwC;QAC9D,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC;QAC1C,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,cAAc,EAAE;YAC7C,YAAY,EAAE,cAAc;SAC7B,CAAC;KACH,CAAC,CAAC;AACL,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 } from '@fgv/ts-utils';\nimport { QualifierType } from './qualifierType';\nimport { ReadOnlyQualifierTypeCollector } from './qualifierTypeCollector';\nimport { ILiteralValueHierarchyCreateParams } from './literalValueHierarchy';\n\n/**\n * Context necessary to convert a qualifier name or number to an instantiated\n * {@link QualifierTypes.QualifierType}.\n * @public\n */\nexport interface IQualifierTypeConvertContext {\n qualifierTypes: ReadOnlyQualifierTypeCollector;\n}\n\n/**\n * Converter for {@link QualifierTypes.QualifierType | QualifierType} objects,\n * retrieves a {@link QualifierTypes.QualifierType | QualifierType} by name or\n * index from a supplied {@link QualifierTypes.Convert.IQualifierTypeConvertContext | conversion context}.\n * @public\n */\n// eslint-disable-next-line @rushstack/typedef-var\nexport const qualifierType = Converters.generic<QualifierType, IQualifierTypeConvertContext>(\n (\n from: unknown,\n __self: Converter<QualifierType, IQualifierTypeConvertContext>,\n context?: IQualifierTypeConvertContext\n ): Result<QualifierType> => {\n if (!context) {\n return fail('qualifierType converter requires a context');\n }\n if (typeof from === 'string') {\n return context.qualifierTypes.validating.get(from);\n } else if (typeof from === 'number') {\n return context.qualifierTypes.getAt(from);\n }\n return fail('qualifierType converter requires a string or number');\n }\n);\n\n/**\n * Gets a converter for {@link QualifierTypes.ILiteralValueHierarchyCreateParams | ILiteralValueHierarchyCreateParams}\n * objects with values validated by a supplied value converter.\n * @param valueConverter - Converter for the literal value type.\n * @public\n */\nexport function literalValueHierarchyCreateParams<T extends string>(\n valueConverter: Converter<T>\n): Converter<ILiteralValueHierarchyCreateParams<T>> {\n return Converters.object<ILiteralValueHierarchyCreateParams<T>>({\n values: Converters.arrayOf(valueConverter),\n hierarchy: Converters.recordOf(valueConverter, {\n keyConverter: valueConverter\n })\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/packlets/qualifier-types/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,IAAI,EAAU,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,MAAM,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AAE,CAAC;QACnB,KAAK,UAAU;YACb,OAAO,qBAAqB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC5D,KAAK,WAAW;YACd,OAAO,sBAAsB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC7D,KAAK,SAAS;YACZ,OAAO,oBAAoB,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;IACD,0CAA0C;IAC1C,mBAAmB;IACnB,OAAO,IAAI,CAAC,GAAG,UAAU,kCAAkC,CAAC,CAAC;AAC/D,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 { fail, Result } from '@fgv/ts-utils';\nimport * as Config from './config';\nimport { QualifierType } from './qualifierType';\nimport { LanguageQualifierType } from './languageQualifierType';\nimport { TerritoryQualifierType } from './territoryQualifierType';\nimport { LiteralQualifierType } from './literalQualifierType';\n\n/**\n * A discriminated union of all system qualifier types.\n * This allows TypeScript to properly discriminate between specific qualifier type implementations\n * and access their specific methods like getConfiguration().\n * @public\n */\nexport type SystemQualifierType = LanguageQualifierType | TerritoryQualifierType | LiteralQualifierType;\n\n/**\n * Creates a {@link QualifierTypes.QualifierType | QualifierType} from a configuration object.\n * This factory function determines the appropriate qualifier type based on the systemType\n * and delegates to the appropriate type-specific createFromConfig method.\n * @param typeConfig - The {@link QualifierTypes.Config.IQualifierTypeConfig | configuration object}\n * containing the name, systemType, and optional type-specific configuration.\n * @returns `Success` with the new {@link QualifierTypes.QualifierType | QualifierType}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\nexport function createQualifierTypeFromConfig(\n typeConfig: Config.IAnyQualifierTypeConfig\n): Result<QualifierType> {\n /* c8 ignore next 1 - defense in depth */\n const childConfig = typeConfig.configuration ?? {};\n switch (typeConfig.systemType) {\n case 'language':\n return Config.Convert.languageQualifierTypeConfig\n .convert(childConfig)\n .onSuccess((configuration) =>\n LanguageQualifierType.createFromConfig({ ...typeConfig, configuration })\n );\n case 'territory':\n return Config.Convert.territoryQualifierTypeConfig\n .convert(childConfig)\n .onSuccess((configuration) =>\n TerritoryQualifierType.createFromConfig({ ...typeConfig, configuration })\n );\n case 'literal':\n return Config.Convert.literalQualifierTypeConfig\n .convert(childConfig)\n .onSuccess((configuration) =>\n LiteralQualifierType.createFromConfig({ ...typeConfig, configuration })\n );\n }\n /* c8 ignore next 1 - defense in depth */\n return fail(`Unknown qualifier type: ${typeConfig.systemType}`);\n}\n\n/**\n * Creates a {@link QualifierTypes.SystemQualifierType | SystemQualifierType} from a system configuration object.\n * This factory function determines the appropriate qualifier type based on the systemType\n * and delegates to the appropriate type-specific createFromConfig method.\n * @param typeConfig - The {@link QualifierTypes.Config.ISystemQualifierTypeConfig | configuration object}\n * containing the name, systemType, and optional type-specific configuration.\n * @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\nexport function createQualifierTypeFromSystemConfig(\n typeConfig: Config.ISystemQualifierTypeConfig\n): Result<SystemQualifierType> {\n const { systemType } = typeConfig;\n switch (systemType) {\n case 'language':\n return LanguageQualifierType.createFromConfig(typeConfig);\n case 'territory':\n return TerritoryQualifierType.createFromConfig(typeConfig);\n case 'literal':\n return LiteralQualifierType.createFromConfig(typeConfig);\n }\n /* c8 ignore next 3 - should not happen */\n // @ts-expect-error\n return fail(`${systemType}: Unknown system qualifier type.`);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/qualifier-types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC;AAE1B,OAAO,EAAE,MAAM,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 Config from './config';\nimport * as Convert from './convert';\n\nexport * from './qualifierType';\nexport * from './languageQualifierType';\nexport * from './literalQualifierType';\nexport * from './literalValueHierarchy';\nexport * from './territoryQualifierType';\nexport * from './qualifierTypeCollector';\nexport * from './helpers';\n\nexport { Config, Convert };\n"]}
|
|
@@ -34,9 +34,8 @@ import { sanitizeJsonObject } from '@fgv/ts-json-base';
|
|
|
34
34
|
export class LanguageQualifierType extends QualifierType {
|
|
35
35
|
/**
|
|
36
36
|
* Creates a new instance of a {@link QualifierTypes.LanguageQualifierType | language qualifier type}.
|
|
37
|
-
* @param
|
|
38
|
-
*
|
|
39
|
-
* list of values. Defaults to `true`.
|
|
37
|
+
* @param params - The {@link QualifierTypes.ILanguageQualifierTypeCreateParams | create parameters}
|
|
38
|
+
* for this qualifier type.
|
|
40
39
|
* @public
|
|
41
40
|
*/
|
|
42
41
|
constructor({ name, allowContextList, index }) {
|
|
@@ -47,7 +46,7 @@ export class LanguageQualifierType extends QualifierType {
|
|
|
47
46
|
super(Object.assign({ name,
|
|
48
47
|
allowContextList }, validated));
|
|
49
48
|
/**
|
|
50
|
-
* {@
|
|
49
|
+
* {@inheritDoc QualifierTypes.IQualifierType.systemTypeName}
|
|
51
50
|
*/
|
|
52
51
|
this.systemTypeName = Convert.qualifierTypeName.convert('language').orThrow();
|
|
53
52
|
}
|
|
@@ -79,7 +78,7 @@ export class LanguageQualifierType extends QualifierType {
|
|
|
79
78
|
}).onSuccess(LanguageQualifierType.create);
|
|
80
79
|
}
|
|
81
80
|
/**
|
|
82
|
-
* {@
|
|
81
|
+
* {@inheritDoc QualifierTypes.IQualifierType.isValidConditionValue}
|
|
83
82
|
*/
|
|
84
83
|
isValidConditionValue(value) {
|
|
85
84
|
return Bcp47.tag(value)
|
|
@@ -95,7 +94,7 @@ export class LanguageQualifierType extends QualifierType {
|
|
|
95
94
|
return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemLanguageQualifierTypeConfig.convert(json));
|
|
96
95
|
}
|
|
97
96
|
/**
|
|
98
|
-
* {@
|
|
97
|
+
* {@inheritDoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
99
98
|
*/
|
|
100
99
|
getConfigurationJson() {
|
|
101
100
|
return succeed({
|
|
@@ -107,7 +106,7 @@ export class LanguageQualifierType extends QualifierType {
|
|
|
107
106
|
});
|
|
108
107
|
}
|
|
109
108
|
/**
|
|
110
|
-
* {@
|
|
109
|
+
* {@inheritDoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
111
110
|
*/
|
|
112
111
|
validateConfigurationJson(from) {
|
|
113
112
|
return Config.Convert.systemLanguageQualifierTypeConfig.convert(from);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languageQualifierType.js","sourceRoot":"","sources":["../../../src/packlets/qualifier-types/languageQualifierType.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAU,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAEL,OAAO,EACP,OAAO,EAKP,QAAQ,EACT,MAAM,WAAW,CAAC;AACnB,OAAO,EAA8B,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAsB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAoB3E;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAE1C;IAMC;;;;;OAKG;IACH,YAAsB,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAsC;QACzF,gBAAgB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AgB;QACrB,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CACpD,MAAM,CAAC,OAAO,CAAC,iCAAiC,CAAC,OAAO,CAAC,IAAI,CAAC,CAC/D,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,oBAAoB;QACzB,OAAO,OAAO,CAAC;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,UAAmB;YAC/B,aAAa,EAAE;gBACb,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;aACxC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,yBAAyB,CAC9B,IAAa;QAEb,OAAO,MAAM,CAAC,OAAO,CAAC,iCAAiC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,CAAC;IAED;;;;;OAKG;IACI,qBAAqB,CAAC,IAAa;QACxC,OAAO,MAAM,CAAC,OAAO,CAAC,iCAAiC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,CAAC;IAED;;;;;;;OAOG;IACO,SAAS,CACjB,SAAkC,EAClC,OAA8B,EAC9B,QAA2B;QAE3B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAC5F,IAAI,UAAU,GAAG,GAAG,IAAI,QAAQ,CAAC,0BAA0B,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxE,OAAO,UAAU,CAAC;YACpB,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,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, captureResult, succeed } from '@fgv/ts-utils';\nimport { Bcp47 } from '@fgv/ts-bcp47';\nimport {\n ConditionOperator,\n Convert,\n NoMatch,\n QualifierConditionValue,\n QualifierContextValue,\n QualifierMatchScore,\n QualifierTypeName,\n Validate\n} from '../common';\nimport { IQualifierTypeCreateParams, QualifierType } from './qualifierType';\nimport * as Config from './config';\nimport { JsonCompatibleType, sanitizeJsonObject } from '@fgv/ts-json-base';\n\n/**\n * Interface defining the parameters that can be used to create a new\n * {@link QualifierTypes.LanguageQualifierType | LanguageQualifierType}.\n * @public\n */\nexport interface ILanguageQualifierTypeCreateParams extends Partial<IQualifierTypeCreateParams> {\n /**\n * Optional name for the qualifier type. Defaults to 'language'.\n */\n name?: string;\n\n /**\n * Optional flag indicating whether the context can be a list of values.\n * Defaults to `true`.\n */\n allowContextList?: boolean;\n}\n\n/**\n * {@link QualifierTypes.QualifierType | Qualifier type} which matches BCP-47 language tags\n * applying {@link https://github.com/ErikFortune/fgv/tree/main/libraries/ts-bcp47#tag-matching | similarity matching}.\n * Accepts a list of language tags in the context by default.\n * @public\n */\nexport class LanguageQualifierType extends QualifierType<\n JsonCompatibleType<Config.ILanguageQualifierTypeConfig>\n> {\n /**\n * {@inheritDoc QualifierTypes.IQualifierType.systemTypeName}\n */\n public readonly systemTypeName: QualifierTypeName = Convert.qualifierTypeName.convert('language').orThrow();\n\n /**\n * Creates a new instance of a {@link QualifierTypes.LanguageQualifierType | language qualifier type}.\n * @param params - The {@link QualifierTypes.ILanguageQualifierTypeCreateParams | create parameters}\n * for this qualifier type.\n * @public\n */\n protected constructor({ name, allowContextList, index }: ILanguageQualifierTypeCreateParams) {\n allowContextList = allowContextList !== false;\n /* c8 ignore next 2 - coverage intermittently drops these two lines even though they're tested */\n name = name ?? 'language';\n const validated = index ? { index: Convert.qualifierTypeIndex.convert(index).orThrow() } : {};\n\n super({\n name,\n allowContextList,\n ...validated\n });\n }\n\n /**\n * Creates a new instance of a {@link QualifierTypes.LanguageQualifierType | language qualifier type}.\n * @param params - Optional {@link QualifierTypes.ILanguageQualifierTypeCreateParams | parameters}\n * to use when creating the new instance.\n * @returns `Success` with the new {@link QualifierTypes.LanguageQualifierType | language qualifier type}\n * if successful, `Failure` otherwise.\n */\n public static create(params?: ILanguageQualifierTypeCreateParams): Result<LanguageQualifierType> {\n /* c8 ignore next 1 - coverage seems to intermittently miss the branch even though it's tested */\n params = params ?? {};\n return captureResult(() => new LanguageQualifierType(params));\n }\n\n /**\n * Creates a new {@link QualifierTypes.LanguageQualifierType | LanguageQualifierType} from a configuration object.\n * @param config - The {@link QualifierTypes.Config.IQualifierTypeConfig | configuration object} containing\n * the name, systemType, and optional language-specific configuration.\n * @returns `Success` with the new {@link QualifierTypes.LanguageQualifierType | LanguageQualifierType}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\n public static createFromConfig(\n config: Config.IQualifierTypeConfig<Config.ILanguageQualifierTypeConfig>\n ): Result<LanguageQualifierType> {\n return sanitizeJsonObject<ILanguageQualifierTypeCreateParams>({\n name: config.name,\n allowContextList: config.configuration?.allowContextList === true\n }).onSuccess(LanguageQualifierType.create);\n }\n\n /**\n * {@inheritDoc QualifierTypes.IQualifierType.isValidConditionValue}\n */\n public isValidConditionValue(value: string): value is QualifierConditionValue {\n return Bcp47.tag(value)\n .onSuccess((tag) => succeed(tag.isValid))\n .orDefault(false);\n }\n\n /**\n * Gets a {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | strongly typed configuration object}\n * for this qualifier type.\n * @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.\n */\n public getConfiguration(): Result<Config.ISystemLanguageQualifierTypeConfig> {\n return this.getConfigurationJson().onSuccess((json) =>\n Config.Convert.systemLanguageQualifierTypeConfig.convert(json)\n );\n }\n\n /**\n * {@inheritDoc QualifierTypes.IQualifierType.getConfigurationJson}\n */\n public getConfigurationJson(): Result<JsonCompatibleType<Config.ISystemLanguageQualifierTypeConfig>> {\n return succeed({\n name: this.name,\n systemType: 'language' as const,\n configuration: {\n allowContextList: this.allowContextList\n }\n });\n }\n\n /**\n * {@inheritDoc QualifierTypes.IQualifierType.validateConfigurationJson}\n */\n public validateConfigurationJson(\n from: unknown\n ): Result<JsonCompatibleType<Config.ISystemLanguageQualifierTypeConfig>> {\n return Config.Convert.systemLanguageQualifierTypeConfig.convert(from);\n }\n\n /**\n * Validates a {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | strongly typed configuration object}\n * for this qualifier type.\n * @param from - The unknown data to validate as a configuration object.\n * @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.\n */\n public validateConfiguration(from: unknown): Result<Config.ISystemLanguageQualifierTypeConfig> {\n return Config.Convert.systemLanguageQualifierTypeConfig.convert(from);\n }\n\n /**\n * Matches a single language condition against a single language context value using\n * {@link https://github.com/ErikFortune/fgv/tree/main/libraries/ts-bcp47#tag-matching | similarity matching}.\n * @param condition - The language condition value to match.\n * @param context - The language context value to match against.\n * @param operator - The operator to use for the match. Must be 'matches'.\n * @returns The match score, or `noMatch` if the match fails.\n */\n protected _matchOne(\n condition: QualifierConditionValue,\n context: QualifierContextValue,\n operator: ConditionOperator\n ): QualifierMatchScore {\n if (operator === 'matches') {\n const similarity = Bcp47.similarity(condition, context).orDefault(Bcp47.tagSimilarity.none);\n if (similarity > 0.0 && Validate.isValidQualifierMatchScore(similarity)) {\n return similarity;\n }\n }\n return NoMatch;\n }\n}\n"]}
|
|
@@ -33,11 +33,8 @@ import { sanitizeJsonObject } from '@fgv/ts-json-base';
|
|
|
33
33
|
export class LiteralQualifierType extends QualifierType {
|
|
34
34
|
/**
|
|
35
35
|
* Constructs a new {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType}.
|
|
36
|
-
* @param
|
|
37
|
-
*
|
|
38
|
-
* case-sensitive. Defaults to `false`.
|
|
39
|
-
* @param allowContextList - Optional flag indicating whether the context can be a
|
|
40
|
-
* list of values. Defaults to `false`.
|
|
36
|
+
* @param params - The {@link QualifierTypes.ILiteralQualifierTypeCreateParams | create parameters}
|
|
37
|
+
* for this qualifier type.
|
|
41
38
|
* @public
|
|
42
39
|
*/
|
|
43
40
|
constructor({ name, caseSensitive, allowContextList, enumeratedValues, hierarchy, index }) {
|
|
@@ -48,7 +45,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
48
45
|
index: index !== undefined ? Convert.qualifierTypeIndex.convert(index).orThrow() : undefined
|
|
49
46
|
});
|
|
50
47
|
/**
|
|
51
|
-
* {@
|
|
48
|
+
* {@inheritDoc QualifierTypes.IQualifierType.systemTypeName}
|
|
52
49
|
*/
|
|
53
50
|
this.systemTypeName = Convert.qualifierTypeName.convert('literal').orThrow();
|
|
54
51
|
this.caseSensitive = caseSensitive === true;
|
|
@@ -80,7 +77,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
80
77
|
return LiteralQualifierType.isValidLiteralConditionValue(value);
|
|
81
78
|
}
|
|
82
79
|
/**
|
|
83
|
-
* {@
|
|
80
|
+
* {@inheritDoc QualifierTypes.IQualifierType.isPotentialMatch}
|
|
84
81
|
*/
|
|
85
82
|
isPotentialMatch(conditionValue, contextValue) {
|
|
86
83
|
if (this.isValidConditionValue(conditionValue) && this.isValidContextValue(contextValue)) {
|
|
@@ -102,7 +99,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
102
99
|
return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemLiteralQualifierTypeConfig.convert(json));
|
|
103
100
|
}
|
|
104
101
|
/**
|
|
105
|
-
* {@
|
|
102
|
+
* {@inheritDoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
106
103
|
*/
|
|
107
104
|
getConfigurationJson() {
|
|
108
105
|
const hierarchy = this.hierarchy ? { hierarchy: this.hierarchy.asRecord() } : {};
|
|
@@ -116,7 +113,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
116
113
|
});
|
|
117
114
|
}
|
|
118
115
|
/**
|
|
119
|
-
* {@
|
|
116
|
+
* {@inheritDoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
120
117
|
*/
|
|
121
118
|
validateConfigurationJson(from) {
|
|
122
119
|
return Config.Convert.systemLiteralQualifierTypeConfig.convert(from);
|
|
@@ -131,7 +128,7 @@ export class LiteralQualifierType extends QualifierType {
|
|
|
131
128
|
return Config.Convert.systemLiteralQualifierTypeConfig.convert(from);
|
|
132
129
|
}
|
|
133
130
|
/**
|
|
134
|
-
* {@
|
|
131
|
+
* {@inheritDoc QualifierTypes.QualifierType._matchOne}
|
|
135
132
|
*/
|
|
136
133
|
_matchOne(condition, context, __operator) {
|
|
137
134
|
if (this.hierarchy) {
|