@fgv/ts-res 5.1.0-1 → 5.1.0-11

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.
Files changed (57) hide show
  1. package/dist/packlets/config/common.js +78 -0
  2. package/dist/packlets/config/configInitFactory.js +258 -0
  3. package/dist/packlets/config/convert.js +56 -0
  4. package/dist/packlets/config/index.browser.js +34 -0
  5. package/dist/packlets/config/index.js +28 -0
  6. package/dist/packlets/config/json.js +23 -0
  7. package/dist/packlets/config/predefined/default.js +138 -0
  8. package/dist/packlets/config/predefined/extended.js +190 -0
  9. package/dist/packlets/config/predefined/index.js +25 -0
  10. package/dist/packlets/config/systemConfiguration.js +147 -0
  11. package/dist/packlets/import/importManager.js +7 -3
  12. package/dist/packlets/import/importers/fsItemImporter.js +29 -13
  13. package/dist/packlets/qualifier-types/config/convert.js +124 -0
  14. package/dist/packlets/qualifier-types/config/index.js +25 -0
  15. package/dist/packlets/qualifier-types/config/json.js +32 -0
  16. package/dist/packlets/resource-types/config/convert.js +35 -0
  17. package/dist/packlets/resource-types/config/index.js +25 -0
  18. package/dist/packlets/resource-types/config/json.js +23 -0
  19. package/dist/ts-res.d.ts +26 -1
  20. package/dist/tsdoc-metadata.json +1 -1
  21. package/lib/packlets/config/common.d.ts +35 -0
  22. package/lib/packlets/config/common.js +97 -0
  23. package/lib/packlets/config/configInitFactory.d.ts +217 -0
  24. package/lib/packlets/config/configInitFactory.js +303 -0
  25. package/lib/packlets/config/convert.d.ts +23 -0
  26. package/lib/packlets/config/convert.js +93 -0
  27. package/lib/packlets/config/index.browser.d.ts +7 -0
  28. package/lib/packlets/config/index.browser.js +74 -0
  29. package/lib/packlets/config/index.d.ts +7 -0
  30. package/lib/packlets/config/index.js +68 -0
  31. package/lib/packlets/config/json.d.ts +20 -0
  32. package/lib/packlets/config/json.js +24 -0
  33. package/lib/packlets/config/predefined/default.d.ts +57 -0
  34. package/lib/packlets/config/predefined/default.js +141 -0
  35. package/lib/packlets/config/predefined/extended.d.ts +25 -0
  36. package/lib/packlets/config/predefined/extended.js +193 -0
  37. package/lib/packlets/config/predefined/index.d.ts +4 -0
  38. package/lib/packlets/config/predefined/index.js +62 -0
  39. package/lib/packlets/config/systemConfiguration.d.ts +94 -0
  40. package/lib/packlets/config/systemConfiguration.js +152 -0
  41. package/lib/packlets/import/importManager.d.ts +15 -1
  42. package/lib/packlets/import/importManager.js +7 -3
  43. package/lib/packlets/import/importers/fsItemImporter.d.ts +15 -1
  44. package/lib/packlets/import/importers/fsItemImporter.js +28 -12
  45. package/lib/packlets/qualifier-types/config/convert.d.ts +65 -0
  46. package/lib/packlets/qualifier-types/config/convert.js +161 -0
  47. package/lib/packlets/qualifier-types/config/index.d.ts +4 -0
  48. package/lib/packlets/qualifier-types/config/index.js +64 -0
  49. package/lib/packlets/qualifier-types/config/json.d.ts +91 -0
  50. package/lib/packlets/qualifier-types/config/json.js +35 -0
  51. package/lib/packlets/resource-types/config/convert.d.ts +8 -0
  52. package/lib/packlets/resource-types/config/convert.js +38 -0
  53. package/lib/packlets/resource-types/config/index.d.ts +4 -0
  54. package/lib/packlets/resource-types/config/index.js +64 -0
  55. package/lib/packlets/resource-types/config/json.d.ts +11 -0
  56. package/lib/packlets/resource-types/config/json.js +24 -0
  57. package/package.json +28 -26
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.SystemConfiguration = void 0;
25
+ exports.updateSystemConfigurationQualifierDefaultValues = updateSystemConfigurationQualifierDefaultValues;
26
+ const ts_utils_1 = require("@fgv/ts-utils");
27
+ const qualifier_types_1 = require("../qualifier-types");
28
+ const qualifiers_1 = require("../qualifiers");
29
+ const resource_types_1 = require("../resource-types");
30
+ const convert_1 = require("./convert");
31
+ const ts_json_base_1 = require("@fgv/ts-json-base");
32
+ const configInitFactory_1 = require("./configInitFactory");
33
+ /**
34
+ * Creates a copy of the provided {@link Config.Model.ISystemConfiguration | system configuration}
35
+ * with updated qualifier default values.
36
+ * @param config - The base {@link Config.Model.ISystemConfiguration | system configuration} to copy.
37
+ * @param qualifierDefaultValues - Map of qualifier names to default values. Use `null` to remove existing values.
38
+ * @returns `Success` with the updated {@link Config.Model.ISystemConfiguration | system configuration}
39
+ * if successful, `Failure` with an error message otherwise.
40
+ * @public
41
+ */
42
+ function updateSystemConfigurationQualifierDefaultValues(config, qualifierDefaultValues // eslint-disable-line @rushstack/no-new-null
43
+ ) {
44
+ // Create a copy of the config
45
+ return (0, ts_json_base_1.sanitizeJsonObject)(config).onSuccess((updatedConfig) => {
46
+ // Create a map of existing qualifier names for validation
47
+ const existingQualifierNames = new Set(updatedConfig.qualifiers.map((q) => q.name));
48
+ // Validate that all specified qualifiers exist in the configuration
49
+ for (const qualifierName of Object.keys(qualifierDefaultValues)) {
50
+ if (!existingQualifierNames.has(qualifierName)) {
51
+ return (0, ts_utils_1.fail)(`Qualifier '${qualifierName}' not found in system configuration`);
52
+ }
53
+ }
54
+ // Update qualifier default values
55
+ updatedConfig.qualifiers = updatedConfig.qualifiers.map((qualifier) => {
56
+ if (qualifier.name in qualifierDefaultValues) {
57
+ const newDefaultValue = qualifierDefaultValues[qualifier.name];
58
+ // Create a copy of the qualifier
59
+ const updatedQualifier = Object.assign({}, qualifier);
60
+ if (newDefaultValue === null) {
61
+ // Remove the default value
62
+ delete updatedQualifier.defaultValue;
63
+ }
64
+ else {
65
+ // Set the new default value
66
+ updatedQualifier.defaultValue = newDefaultValue;
67
+ }
68
+ return updatedQualifier;
69
+ }
70
+ return qualifier;
71
+ });
72
+ return (0, ts_utils_1.succeed)(updatedConfig);
73
+ });
74
+ }
75
+ /**
76
+ * A system configuration for both runtime or build.
77
+ * @public
78
+ */
79
+ class SystemConfiguration {
80
+ /**
81
+ * The name of this system configuration.
82
+ */
83
+ get name() {
84
+ return this._config.name;
85
+ }
86
+ /**
87
+ * The description of this system configuration.
88
+ */
89
+ get description() {
90
+ return this._config.description;
91
+ }
92
+ /**
93
+ * Constructs a new instance of a {@link Config.SystemConfiguration | SystemConfiguration} from the
94
+ * supplied {@link Config.Model.ISystemConfiguration | system configuration}.
95
+ * @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.
96
+ * @public
97
+ */
98
+ constructor(config, initParams) {
99
+ var _a, _b;
100
+ this._config = config;
101
+ const qualifierTypeFactory = (_a = initParams === null || initParams === void 0 ? void 0 : initParams.qualifierTypeFactory) !== null && _a !== void 0 ? _a : new configInitFactory_1.BuiltInQualifierTypeFactory();
102
+ const resourceTypeFactory = (_b = initParams === null || initParams === void 0 ? void 0 : initParams.resourceTypeFactory) !== null && _b !== void 0 ? _b : new configInitFactory_1.BuiltInResourceTypeFactory();
103
+ this.qualifierTypes = qualifier_types_1.QualifierTypeCollector.create({
104
+ qualifierTypes: (0, ts_utils_1.mapResults)(config.qualifierTypes.map((tc) => qualifierTypeFactory.create(tc))).orThrow()
105
+ }).orThrow();
106
+ this.qualifiers = qualifiers_1.QualifierCollector.create({
107
+ qualifierTypes: this.qualifierTypes,
108
+ qualifiers: config.qualifiers
109
+ }).orThrow();
110
+ this.resourceTypes = resource_types_1.ResourceTypeCollector.create({
111
+ resourceTypes: (0, ts_utils_1.mapResults)(config.resourceTypes.map((rt) => resourceTypeFactory.create(rt))).orThrow()
112
+ }).orThrow();
113
+ }
114
+ /**
115
+ * Creates a new {@link Config.SystemConfiguration | SystemConfiguration} from the supplied
116
+ * {@link Config.Model.ISystemConfiguration | system configuration}.
117
+ * @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.
118
+ * @param initParams - Optional {@link Config.ISystemConfigurationInitParams | initialization parameters}.
119
+ * @returns `Success` with the new {@link Config.SystemConfiguration | SystemConfiguration}
120
+ * if successful, `Failure` with an error message otherwise.
121
+ * @public
122
+ */
123
+ static create(config, initParams) {
124
+ if (initParams === null || initParams === void 0 ? void 0 : initParams.qualifierDefaultValues) {
125
+ /* c8 ignore next 9 - functional code tested but coverage intermittently missed */
126
+ return updateSystemConfigurationQualifierDefaultValues(config, initParams.qualifierDefaultValues).onSuccess((updatedConfig) => (0, ts_utils_1.captureResult)(() => new SystemConfiguration(updatedConfig, (0, ts_utils_1.omit)(initParams, ['qualifierDefaultValues']))));
127
+ }
128
+ return (0, ts_utils_1.captureResult)(() => new SystemConfiguration(config, initParams));
129
+ }
130
+ /**
131
+ * Loads a {@link Config.SystemConfiguration | SystemConfiguration} from a file.
132
+ * @param path - The path to the file to load.
133
+ * @returns `Success` with the {@link Config.SystemConfiguration | SystemConfiguration}
134
+ * if successful, `Failure` with an error message otherwise.
135
+ * @public
136
+ */
137
+ static loadFromFile(path, initParams) {
138
+ return ts_json_base_1.JsonFile.convertJsonFileSync(path, convert_1.systemConfiguration).onSuccess((config) => SystemConfiguration.create(config, initParams));
139
+ }
140
+ /**
141
+ * Returns the {@link Config.Model.ISystemConfiguration | system configuration} that this
142
+ * {@link Config.SystemConfiguration | SystemConfiguration} was created from.
143
+ * @returns `Success` with the {@link Config.Model.ISystemConfiguration | system configuration}
144
+ * if successful, `Failure` with an error message otherwise.
145
+ * @public
146
+ */
147
+ getConfig() {
148
+ return convert_1.systemConfiguration.convert(this._config);
149
+ }
150
+ }
151
+ exports.SystemConfiguration = SystemConfiguration;
152
+ //# sourceMappingURL=systemConfiguration.js.map
@@ -1,5 +1,7 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
2
  import { FileTree } from '@fgv/ts-json-base';
3
+ import { Converter } from '@fgv/ts-utils';
4
+ import { JsonValue } from '@fgv/ts-json-base';
3
5
  import { ResourceManagerBuilder } from '../resources';
4
6
  import { ImportContext } from './importContext';
5
7
  import { IImportable } from './importable';
@@ -27,6 +29,14 @@ export interface IImporterCreateParams {
27
29
  * An optional list of {@link Import.Importers.IImporter | importers} to use for the import.
28
30
  */
29
31
  importers?: IImporter[];
32
+ /**
33
+ * An optional converter used to pre-process file contents before JSON import validation.
34
+ */
35
+ fileContentConverter?: Converter<JsonValue>;
36
+ /**
37
+ * Optional file extensions which should be parsed using the supplied file content converter.
38
+ */
39
+ fileContentExtensions?: ReadonlyArray<string>;
30
40
  }
31
41
  /**
32
42
  * Class to manage the import of resources from various sources.
@@ -80,9 +90,13 @@ export declare class ImportManager {
80
90
  * and optional `FileTree`.
81
91
  * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} to use for the import.
82
92
  * @param tree - An optional `FileTree` for importing path items.
93
+ * @param fileContentConverter - An optional converter used to pre-process raw file contents before JSON import
94
+ * validation.
95
+ * @param fileContentExtensions - Optional file extensions which should be parsed using the supplied file
96
+ * content converter.
83
97
  * @returns A read-only array of {@link Import.Importers.IImporter | importers}.
84
98
  */
85
- static getDefaultImporters(qualifiers: IReadOnlyQualifierCollector, tree?: FileTree.FileTree): ReadonlyArray<IImporter>;
99
+ static getDefaultImporters(qualifiers: IReadOnlyQualifierCollector, tree?: FileTree.FileTree, fileContentConverter?: Converter<JsonValue>, fileContentExtensions?: ReadonlyArray<string>): ReadonlyArray<IImporter>;
86
100
  /**
87
101
  * Imports any items on the import stack.
88
102
  * @returns `Success` with the {@link Import.ImportManager | ImportManager} if successful,
@@ -48,7 +48,7 @@ class ImportManager {
48
48
  this._importers = [];
49
49
  this.resources = params.resources;
50
50
  this.initialContext = (_a = params.initialContext) !== null && _a !== void 0 ? _a : importContext_1.ImportContext.create().orThrow();
51
- this._importers = Array.from((_b = params.importers) !== null && _b !== void 0 ? _b : ImportManager.getDefaultImporters(this.resources.qualifiers, params.fileTree));
51
+ this._importers = Array.from((_b = params.importers) !== null && _b !== void 0 ? _b : ImportManager.getDefaultImporters(this.resources.qualifiers, params.fileTree, params.fileContentConverter, params.fileContentExtensions));
52
52
  }
53
53
  /**
54
54
  * Factory method to create a new {@link Import.ImportManager | ImportManager}.
@@ -84,12 +84,16 @@ class ImportManager {
84
84
  * and optional `FileTree`.
85
85
  * @param qualifiers - The {@link Qualifiers.IReadOnlyQualifierCollector | qualifiers} to use for the import.
86
86
  * @param tree - An optional `FileTree` for importing path items.
87
+ * @param fileContentConverter - An optional converter used to pre-process raw file contents before JSON import
88
+ * validation.
89
+ * @param fileContentExtensions - Optional file extensions which should be parsed using the supplied file
90
+ * content converter.
87
91
  * @returns A read-only array of {@link Import.Importers.IImporter | importers}.
88
92
  */
89
- static getDefaultImporters(qualifiers, tree) {
93
+ static getDefaultImporters(qualifiers, tree, fileContentConverter, fileContentExtensions) {
90
94
  return [
91
95
  importers_1.PathImporter.create({ qualifiers, tree }).orThrow(),
92
- fsItemImporter_1.FsItemImporter.create({ qualifiers }).orThrow(),
96
+ fsItemImporter_1.FsItemImporter.create({ qualifiers, fileContentConverter, fileContentExtensions }).orThrow(),
93
97
  importers_1.JsonImporter.create().orThrow(),
94
98
  importers_1.CollectionImporter.create().orThrow()
95
99
  ];
@@ -1,4 +1,5 @@
1
- import { DetailedResult, Result } from '@fgv/ts-utils';
1
+ import { DetailedResult, Result, Converter } from '@fgv/ts-utils';
2
+ import { JsonValue } from '@fgv/ts-json-base';
2
3
  import { ResourceManagerBuilder } from '../../resources';
3
4
  import { IImportable } from '../importable';
4
5
  import { IImporter, ImporterResultDetail } from './importer';
@@ -10,6 +11,8 @@ import { FsItem, FsItemResultDetail } from '../fsItem';
10
11
  */
11
12
  export interface IFsItemImporterCreateParams {
12
13
  qualifiers: IReadOnlyQualifierCollector;
14
+ fileContentConverter?: Converter<JsonValue>;
15
+ fileContentExtensions?: ReadonlyArray<string>;
13
16
  }
14
17
  /**
15
18
  * {@link Import.Importers.IImporter | Importer} implementation which imports resources from a `FileTree`.
@@ -20,6 +23,14 @@ export declare class FsItemImporter implements IImporter {
20
23
  * The {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} to use for this importer.
21
24
  */
22
25
  readonly qualifiers: IReadOnlyQualifierCollector;
26
+ /**
27
+ * Optional converter used to parse raw file contents before they are exposed as JSON importables.
28
+ */
29
+ readonly fileContentConverter?: Converter<JsonValue>;
30
+ /**
31
+ * Optional list of file extensions which should be parsed using the file content converter.
32
+ */
33
+ readonly fileContentExtensions?: ReadonlyArray<string>;
23
34
  /**
24
35
  * The types of {@link Import.IImportable | importables} that this importer can handle.
25
36
  */
@@ -39,6 +50,9 @@ export declare class FsItemImporter implements IImporter {
39
50
  * {@inheritdoc Import.Importers.IImporter.import}
40
51
  */
41
52
  import(item: IImportable, __manager: ResourceManagerBuilder): DetailedResult<IImportable[], ImporterResultDetail>;
53
+ private _isSupportedFileExtension;
54
+ private _getJsonContents;
55
+ private _canConvertFileExtension;
42
56
  /**
43
57
  * Gets an {@link Import.FsItem | FsItem} from an {@link Import.IImportable | importable}.
44
58
  * @param item - The importable to convert.
@@ -40,6 +40,8 @@ class FsItemImporter {
40
40
  */
41
41
  this.types = ['fsItem'];
42
42
  this.qualifiers = params.qualifiers;
43
+ this.fileContentConverter = params.fileContentConverter;
44
+ this.fileContentExtensions = params.fileContentExtensions;
43
45
  }
44
46
  /**
45
47
  * Creates a new {@link Import.Importers.FsItemImporter | FsItemImporter}.
@@ -84,23 +86,37 @@ class FsItemImporter {
84
86
  .withDetail('failed', 'processed');
85
87
  }
86
88
  else if (fsItem.item.type === 'file') {
87
- if (fsItem.item.extension === '.json') {
88
- return fsItem.item
89
- .getContents(ts_json_base_1.Converters.jsonValue)
90
- .onSuccess((json) => {
91
- const jsonItem = {
92
- type: 'json',
93
- json,
94
- context
95
- };
96
- return (0, ts_utils_1.succeed)([jsonItem]);
97
- })
98
- .withDetail('failed', 'processed');
89
+ if (!this._isSupportedFileExtension(fsItem.item.extension)) {
90
+ return (0, ts_utils_1.succeedWithDetail)([], 'skipped');
99
91
  }
92
+ return this._getJsonContents(fsItem.item)
93
+ .onSuccess((json) => {
94
+ const jsonItem = {
95
+ type: 'json',
96
+ json,
97
+ context
98
+ };
99
+ return (0, ts_utils_1.succeed)([jsonItem]);
100
+ })
101
+ .withDetail('failed', 'processed');
100
102
  }
101
103
  /* c8 ignore next 2 - defensive coding: fallback case for unsupported file types */
102
104
  return (0, ts_utils_1.succeedWithDetail)([], 'skipped');
103
105
  }
106
+ _isSupportedFileExtension(extension) {
107
+ return extension === '.json' || this._canConvertFileExtension(extension);
108
+ }
109
+ _getJsonContents(file) {
110
+ const converter = this.fileContentConverter;
111
+ if (converter !== undefined) {
112
+ return file.getRawContents().onSuccess((contents) => converter.convert(contents));
113
+ }
114
+ return file.getContents(ts_json_base_1.Converters.jsonValue);
115
+ }
116
+ _canConvertFileExtension(extension) {
117
+ var _a;
118
+ return (this.fileContentConverter !== undefined && ((_a = this.fileContentExtensions) === null || _a === void 0 ? void 0 : _a.includes(extension)) === true);
119
+ }
104
120
  /**
105
121
  * Gets an {@link Import.FsItem | FsItem} from an {@link Import.IImportable | importable}.
106
122
  * @param item - The importable to convert.
@@ -0,0 +1,65 @@
1
+ import { Converter } from '@fgv/ts-utils';
2
+ import * as Model from './json';
3
+ import { Converters as JsonConverters } from '@fgv/ts-json-base';
4
+ /**
5
+ * A `Converter` for {@link QualifierTypes.Config.ILanguageQualifierTypeConfig | LanguageQualifierTypeConfig} objects.
6
+ * @returns A `Converter` for {@link QualifierTypes.Config.ILanguageQualifierTypeConfig | LanguageQualifierTypeConfig} objects.
7
+ * @public
8
+ */
9
+ export declare const languageQualifierTypeConfig: import("@fgv/ts-utils").ObjectConverter<Model.ILanguageQualifierTypeConfig, unknown>;
10
+ /**
11
+ * A `Converter` for {@link QualifierTypes.Config.ITerritoryQualifierTypeConfig | TerritoryQualifierTypeConfig} objects.
12
+ * @returns A `Converter` for {@link QualifierTypes.Config.ITerritoryQualifierTypeConfig | TerritoryQualifierTypeConfig} objects.
13
+ * @public
14
+ */
15
+ export declare const territoryQualifierTypeConfig: import("@fgv/ts-utils").ObjectConverter<Model.ITerritoryQualifierTypeConfig, unknown>;
16
+ /**
17
+ * A `Converter` for {@link QualifierTypes.Config.ILiteralQualifierTypeConfig | LiteralQualifierTypeConfig} objects.
18
+ * @returns A `Converter` for {@link QualifierTypes.Config.ILiteralQualifierTypeConfig | LiteralQualifierTypeConfig} objects.
19
+ * @public
20
+ */
21
+ export declare const literalQualifierTypeConfig: import("@fgv/ts-utils").ObjectConverter<Model.ILiteralQualifierTypeConfig, unknown>;
22
+ /**
23
+ * A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.
24
+ * @returns A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.
25
+ * @public
26
+ */
27
+ export declare const systemLanguageQualifierTypeConfig: import("@fgv/ts-utils").ObjectConverter<Model.ISystemLanguageQualifierTypeConfig, unknown>;
28
+ /**
29
+ * A `Converter` for {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | SystemTerritoryQualifierTypeConfig} objects.
30
+ * @returns A `Converter` for {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | SystemTerritoryQualifierTypeConfig} objects.
31
+ * @public
32
+ */
33
+ export declare const systemTerritoryQualifierTypeConfig: import("@fgv/ts-utils").ObjectConverter<Model.ISystemTerritoryQualifierTypeConfig, unknown>;
34
+ /**
35
+ * A `Converter` for {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | SystemLiteralQualifierTypeConfig} objects.
36
+ * @returns A `Converter` for {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | SystemLiteralQualifierTypeConfig} objects.
37
+ * @public
38
+ */
39
+ export declare const systemLiteralQualifierTypeConfig: import("@fgv/ts-utils").ObjectConverter<Model.ISystemLiteralQualifierTypeConfig, unknown>;
40
+ /**
41
+ * A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.
42
+ * @returns A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.
43
+ * @public
44
+ */
45
+ export declare const systemQualifierTypeConfig: Converter<Model.ISystemQualifierTypeConfig, unknown>;
46
+ /**
47
+ * A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
48
+ * @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
49
+ * @param config - A `Converter` for the configuration object.
50
+ * @public
51
+ */
52
+ export declare function qualifierTypeConfig<T, TD = unknown>(config: Converter<T, TD>): Converter<Model.IQualifierTypeConfig<T>, TD>;
53
+ /**
54
+ * A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
55
+ * @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
56
+ * @public
57
+ */
58
+ export declare const jsonQualifierTypeConfig: Converter<Model.IQualifierTypeConfig<import("@fgv/ts-json-base").JsonObject>, JsonConverters.IJsonConverterContext>;
59
+ /**
60
+ * A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.
61
+ * @returns A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.
62
+ * @public
63
+ */
64
+ export declare const anyQualifierTypeConfig: Converter<Model.IAnyQualifierTypeConfig, unknown>;
65
+ //# sourceMappingURL=convert.d.ts.map
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }) : function(o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = (this && this.__importStar) || (function () {
40
+ var ownKeys = function(o) {
41
+ ownKeys = Object.getOwnPropertyNames || function (o) {
42
+ var ar = [];
43
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
44
+ return ar;
45
+ };
46
+ return ownKeys(o);
47
+ };
48
+ return function (mod) {
49
+ if (mod && mod.__esModule) return mod;
50
+ var result = {};
51
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
52
+ __setModuleDefault(result, mod);
53
+ return result;
54
+ };
55
+ })();
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.anyQualifierTypeConfig = exports.jsonQualifierTypeConfig = exports.systemQualifierTypeConfig = exports.systemLiteralQualifierTypeConfig = exports.systemTerritoryQualifierTypeConfig = exports.systemLanguageQualifierTypeConfig = exports.literalQualifierTypeConfig = exports.territoryQualifierTypeConfig = exports.languageQualifierTypeConfig = void 0;
58
+ exports.qualifierTypeConfig = qualifierTypeConfig;
59
+ /* eslint-disable @rushstack/typedef-var */
60
+ const ts_utils_1 = require("@fgv/ts-utils");
61
+ const Common = __importStar(require("../../common"));
62
+ const ts_json_base_1 = require("@fgv/ts-json-base");
63
+ /**
64
+ * A `Converter` for {@link QualifierTypes.Config.ILanguageQualifierTypeConfig | LanguageQualifierTypeConfig} objects.
65
+ * @returns A `Converter` for {@link QualifierTypes.Config.ILanguageQualifierTypeConfig | LanguageQualifierTypeConfig} objects.
66
+ * @public
67
+ */
68
+ exports.languageQualifierTypeConfig = ts_utils_1.Converters.strictObject({
69
+ allowContextList: ts_utils_1.Converters.boolean.optional()
70
+ });
71
+ /**
72
+ * A `Converter` for {@link QualifierTypes.Config.ITerritoryQualifierTypeConfig | TerritoryQualifierTypeConfig} objects.
73
+ * @returns A `Converter` for {@link QualifierTypes.Config.ITerritoryQualifierTypeConfig | TerritoryQualifierTypeConfig} objects.
74
+ * @public
75
+ */
76
+ exports.territoryQualifierTypeConfig = ts_utils_1.Converters.strictObject({
77
+ allowContextList: ts_utils_1.Converters.boolean,
78
+ acceptLowercase: ts_utils_1.Converters.boolean.optional(),
79
+ allowedTerritories: ts_utils_1.Converters.arrayOf(ts_utils_1.Converters.string).optional(),
80
+ hierarchy: ts_utils_1.Converters.recordOf(ts_utils_1.Converters.string).optional()
81
+ });
82
+ /**
83
+ * A `Converter` for {@link QualifierTypes.Config.ILiteralQualifierTypeConfig | LiteralQualifierTypeConfig} objects.
84
+ * @returns A `Converter` for {@link QualifierTypes.Config.ILiteralQualifierTypeConfig | LiteralQualifierTypeConfig} objects.
85
+ * @public
86
+ */
87
+ exports.literalQualifierTypeConfig = ts_utils_1.Converters.strictObject({
88
+ allowContextList: ts_utils_1.Converters.boolean.optional(),
89
+ caseSensitive: ts_utils_1.Converters.boolean.optional(),
90
+ enumeratedValues: ts_utils_1.Converters.arrayOf(ts_utils_1.Converters.string).optional(),
91
+ hierarchy: ts_utils_1.Converters.recordOf(ts_utils_1.Converters.string).optional()
92
+ });
93
+ /**
94
+ * A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.
95
+ * @returns A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.
96
+ * @public
97
+ */
98
+ exports.systemLanguageQualifierTypeConfig = ts_utils_1.Converters.strictObject({
99
+ name: ts_utils_1.Converters.string,
100
+ systemType: ts_utils_1.Converters.literal('language'),
101
+ configuration: exports.languageQualifierTypeConfig.optional()
102
+ });
103
+ /**
104
+ * A `Converter` for {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | SystemTerritoryQualifierTypeConfig} objects.
105
+ * @returns A `Converter` for {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | SystemTerritoryQualifierTypeConfig} objects.
106
+ * @public
107
+ */
108
+ exports.systemTerritoryQualifierTypeConfig = ts_utils_1.Converters.strictObject({
109
+ name: ts_utils_1.Converters.string,
110
+ systemType: ts_utils_1.Converters.literal('territory'),
111
+ configuration: exports.territoryQualifierTypeConfig.optional()
112
+ });
113
+ /**
114
+ * A `Converter` for {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | SystemLiteralQualifierTypeConfig} objects.
115
+ * @returns A `Converter` for {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | SystemLiteralQualifierTypeConfig} objects.
116
+ * @public
117
+ */
118
+ exports.systemLiteralQualifierTypeConfig = ts_utils_1.Converters.strictObject({
119
+ name: ts_utils_1.Converters.string,
120
+ systemType: ts_utils_1.Converters.literal('literal'),
121
+ configuration: exports.literalQualifierTypeConfig.optional()
122
+ });
123
+ /**
124
+ * A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.
125
+ * @returns A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.
126
+ * @public
127
+ */
128
+ exports.systemQualifierTypeConfig = ts_utils_1.Converters.discriminatedObject('systemType', {
129
+ language: exports.systemLanguageQualifierTypeConfig,
130
+ territory: exports.systemTerritoryQualifierTypeConfig,
131
+ literal: exports.systemLiteralQualifierTypeConfig
132
+ });
133
+ /**
134
+ * A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
135
+ * @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
136
+ * @param config - A `Converter` for the configuration object.
137
+ * @public
138
+ */
139
+ function qualifierTypeConfig(config) {
140
+ return ts_utils_1.Converters.strictObject({
141
+ name: Common.Convert.qualifierTypeName,
142
+ systemType: Common.Convert.qualifierTypeName,
143
+ configuration: config.optional()
144
+ });
145
+ }
146
+ /**
147
+ * A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
148
+ * @returns A `Converter` for {@link QualifierTypes.Config.IQualifierTypeConfig | QualifierTypeConfig} objects.
149
+ * @public
150
+ */
151
+ exports.jsonQualifierTypeConfig = qualifierTypeConfig(ts_json_base_1.Converters.jsonObject);
152
+ /**
153
+ * A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.
154
+ * @returns A `Converter` for {@link QualifierTypes.Config.IAnyQualifierTypeConfig | AnyQualifierTypeConfig} objects.
155
+ * @public
156
+ */
157
+ exports.anyQualifierTypeConfig = ts_utils_1.Converters.oneOf([
158
+ exports.jsonQualifierTypeConfig,
159
+ exports.systemQualifierTypeConfig
160
+ ]);
161
+ //# sourceMappingURL=convert.js.map
@@ -0,0 +1,4 @@
1
+ import * as Convert from './convert';
2
+ export * from './json';
3
+ export { Convert };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }) : function(o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = (this && this.__importStar) || (function () {
40
+ var ownKeys = function(o) {
41
+ ownKeys = Object.getOwnPropertyNames || function (o) {
42
+ var ar = [];
43
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
44
+ return ar;
45
+ };
46
+ return ownKeys(o);
47
+ };
48
+ return function (mod) {
49
+ if (mod && mod.__esModule) return mod;
50
+ var result = {};
51
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
52
+ __setModuleDefault(result, mod);
53
+ return result;
54
+ };
55
+ })();
56
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
57
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
58
+ };
59
+ Object.defineProperty(exports, "__esModule", { value: true });
60
+ exports.Convert = void 0;
61
+ const Convert = __importStar(require("./convert"));
62
+ exports.Convert = Convert;
63
+ __exportStar(require("./json"), exports);
64
+ //# sourceMappingURL=index.js.map