@fgv/ts-res 5.1.0-2 → 5.1.0-4

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 (50) 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/qualifier-types/config/convert.js +124 -0
  12. package/dist/packlets/qualifier-types/config/index.js +25 -0
  13. package/dist/packlets/qualifier-types/config/json.js +32 -0
  14. package/dist/packlets/resource-types/config/convert.js +35 -0
  15. package/dist/packlets/resource-types/config/index.js +25 -0
  16. package/dist/packlets/resource-types/config/json.js +23 -0
  17. package/dist/tsdoc-metadata.json +1 -1
  18. package/lib/packlets/config/common.d.ts +35 -0
  19. package/lib/packlets/config/common.js +97 -0
  20. package/lib/packlets/config/configInitFactory.d.ts +217 -0
  21. package/lib/packlets/config/configInitFactory.js +303 -0
  22. package/lib/packlets/config/convert.d.ts +23 -0
  23. package/lib/packlets/config/convert.js +93 -0
  24. package/lib/packlets/config/index.browser.d.ts +7 -0
  25. package/lib/packlets/config/index.browser.js +74 -0
  26. package/lib/packlets/config/index.d.ts +7 -0
  27. package/lib/packlets/config/index.js +68 -0
  28. package/lib/packlets/config/json.d.ts +20 -0
  29. package/lib/packlets/config/json.js +24 -0
  30. package/lib/packlets/config/predefined/default.d.ts +57 -0
  31. package/lib/packlets/config/predefined/default.js +141 -0
  32. package/lib/packlets/config/predefined/extended.d.ts +25 -0
  33. package/lib/packlets/config/predefined/extended.js +193 -0
  34. package/lib/packlets/config/predefined/index.d.ts +4 -0
  35. package/lib/packlets/config/predefined/index.js +62 -0
  36. package/lib/packlets/config/systemConfiguration.d.ts +94 -0
  37. package/lib/packlets/config/systemConfiguration.js +152 -0
  38. package/lib/packlets/qualifier-types/config/convert.d.ts +65 -0
  39. package/lib/packlets/qualifier-types/config/convert.js +161 -0
  40. package/lib/packlets/qualifier-types/config/index.d.ts +4 -0
  41. package/lib/packlets/qualifier-types/config/index.js +64 -0
  42. package/lib/packlets/qualifier-types/config/json.d.ts +91 -0
  43. package/lib/packlets/qualifier-types/config/json.js +35 -0
  44. package/lib/packlets/resource-types/config/convert.d.ts +8 -0
  45. package/lib/packlets/resource-types/config/convert.js +38 -0
  46. package/lib/packlets/resource-types/config/index.d.ts +4 -0
  47. package/lib/packlets/resource-types/config/index.js +64 -0
  48. package/lib/packlets/resource-types/config/json.d.ts +11 -0
  49. package/lib/packlets/resource-types/config/json.js +24 -0
  50. package/package.json +28 -26
@@ -0,0 +1,78 @@
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 { fail } from '@fgv/ts-utils';
23
+ import { SystemConfiguration, updateSystemConfigurationQualifierDefaultValues } from './systemConfiguration';
24
+ import { sanitizeJsonObject } from '@fgv/ts-json-base';
25
+ import { Default, Example } from './predefined';
26
+ /**
27
+ * An array of all well-known predefined system configurations.
28
+ * @public
29
+ */
30
+ export const allPredefinedSystemConfigurations = [
31
+ 'default',
32
+ 'language-priority',
33
+ 'territory-priority',
34
+ 'extended-example'
35
+ ];
36
+ export * from './predefined';
37
+ const predefinedDecls = {
38
+ default: Default.DefaultSystemConfiguration,
39
+ 'language-priority': Default.LanguagePrioritySystemConfiguration,
40
+ 'territory-priority': Default.TerritoryPrioritySystemConfiguration,
41
+ 'extended-example': Example.ExtendedSystemConfiguration
42
+ };
43
+ /**
44
+ * Returns the {@link Config.Model.ISystemConfiguration | system configuration} declaration for the
45
+ * specified predefined system configuration.
46
+ * @param name - The name of the predefined system configuration.
47
+ * @param initParams - Optional {@link Config.ISystemConfigurationInitParams | initialization parameters}.
48
+ * @returns `Success` with the {@link Config.Model.ISystemConfiguration | system configuration}
49
+ * declaration if successful, `Failure` with an error message otherwise.
50
+ * @public
51
+ */
52
+ export function getPredefinedDeclaration(name, initParams) {
53
+ if (name in predefinedDecls) {
54
+ const baseConfig = sanitizeJsonObject(predefinedDecls[name]);
55
+ if (initParams === null || initParams === void 0 ? void 0 : initParams.qualifierDefaultValues) {
56
+ return baseConfig.onSuccess((config) => updateSystemConfigurationQualifierDefaultValues(config, initParams.qualifierDefaultValues));
57
+ }
58
+ return baseConfig;
59
+ }
60
+ /* c8 ignore next 3 - defense in depth */
61
+ return fail(`Unknown predefined system configuration: ${name}`);
62
+ }
63
+ /**
64
+ * Returns the {@link Config.SystemConfiguration | SystemConfiguration} for the specified
65
+ * predefined system configuration.
66
+ * @param name - The name of the predefined system configuration.
67
+ * @param initParams - Optional {@link Config.ISystemConfigurationInitParams | initialization parameters}.
68
+ * @returns `Success` with the {@link Config.SystemConfiguration | SystemConfiguration}
69
+ * if successful, `Failure` with an error message otherwise.
70
+ * @public
71
+ */
72
+ export function getPredefinedSystemConfiguration(name, initParams) {
73
+ if (name in predefinedDecls) {
74
+ return SystemConfiguration.create(predefinedDecls[name], initParams);
75
+ }
76
+ return fail(`Unknown predefined system configuration: ${name}`);
77
+ }
78
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1,258 @@
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 { fail } from '@fgv/ts-utils';
23
+ import * as QualifierTypes from '../qualifier-types';
24
+ import * as ResourceTypes from '../resource-types';
25
+ /**
26
+ * Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a factory function.
27
+ * @param fn - The factory function to wrap.
28
+ * @returns An `IConfigInitFactory` instance that delegates to the function.
29
+ * @public
30
+ */
31
+ export function createQualifierTypeFactory(fn) {
32
+ return {
33
+ create: fn
34
+ };
35
+ }
36
+ /**
37
+ * Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a resource type factory function.
38
+ * @param fn - The factory function to wrap.
39
+ * @returns An `IConfigInitFactory` instance that delegates to the function.
40
+ * @public
41
+ */
42
+ export function createResourceTypeFactory(fn) {
43
+ return {
44
+ create: fn
45
+ };
46
+ }
47
+ /**
48
+ * A factory that chains multiple factories together.
49
+ * @public
50
+ */
51
+ export class ChainedConfigInitFactory {
52
+ /**
53
+ * Constructor for a chained config init factory.
54
+ * @param factories - The factories to chain.
55
+ */
56
+ constructor(factories) {
57
+ this.factories = factories;
58
+ }
59
+ /**
60
+ * Creates a new instance of a configuration object.
61
+ * @param config - The configuration object to create.
62
+ * @returns A result containing the new instance of the configuration object.
63
+ */
64
+ create(config) {
65
+ for (const factory of this.factories) {
66
+ const result = factory.create(config);
67
+ if (result.isSuccess()) {
68
+ return result;
69
+ }
70
+ }
71
+ return fail('No factory was able to create the configuration object');
72
+ }
73
+ }
74
+ /**
75
+ * A factory that creates a {@link QualifierTypes.SystemQualifierType | SystemQualifierType} from
76
+ * {@link QualifierTypes.Config.IAnyQualifierTypeConfig | any qualifier type configuration}.
77
+ * @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}
78
+ * if successful, `Failure` with an error message otherwise.
79
+ * @public
80
+ */
81
+ export class BuiltInQualifierTypeFactory {
82
+ /** {@inheritDoc Config.IConfigInitFactory.create} */
83
+ create(config) {
84
+ if (QualifierTypes.Config.isSystemQualifierTypeConfig(config)) {
85
+ return QualifierTypes.createQualifierTypeFromSystemConfig(config);
86
+ }
87
+ /* c8 ignore next 2 - functional code tested but coverage intermittently missed */
88
+ return fail(`${config.name}: unknown built-in qualifier type (${config.systemType})`);
89
+ }
90
+ }
91
+ /**
92
+ * A factory that creates {@link QualifierTypes.QualifierType | QualifierType} instances from configuration,
93
+ * supporting both built-in system types and custom external types.
94
+ *
95
+ * This factory allows external consumers to extend the qualifier type system with their own custom types
96
+ * while maintaining support for all built-in types (Language, Territory, Literal).
97
+ *
98
+ * @typeParam T - The custom qualifier type(s) to support. Defaults to {@link QualifierTypes.SystemQualifierType | SystemQualifierType}.
99
+ *
100
+ * @example Creating a factory with custom qualifier types
101
+ * ```typescript
102
+ * // Define a custom qualifier type
103
+ * class CustomQualifierType extends QualifierType {
104
+ * // ... implementation
105
+ * }
106
+ *
107
+ * // Define a discriminated union of all types
108
+ * type AppQualifierType = SystemQualifierType | CustomQualifierType;
109
+ *
110
+ * // Create a factory that handles custom types
111
+ * const customFactory: IConfigInitFactory<IAnyQualifierTypeConfig, CustomQualifierType> = {
112
+ * create(config) {
113
+ * // ... handle custom type creation
114
+ * }
115
+ * };
116
+ *
117
+ * // Create the combined factory
118
+ * const qualifierTypeFactory = new QualifierTypeFactory<AppQualifierType>([customFactory]);
119
+ *
120
+ * // The factory returns T | SystemQualifierType, supporting all types
121
+ * const result = qualifierTypeFactory.create(config); // Result<AppQualifierType | SystemQualifierType>
122
+ * ```
123
+ *
124
+ * @remarks
125
+ * - The factory chains custom factories with the built-in factory
126
+ * - Custom factories are tried first, falling back to built-in types
127
+ * - The return type is a union of custom types (T) and system types
128
+ *
129
+ * @public
130
+ */
131
+ export class QualifierTypeFactory extends ChainedConfigInitFactory {
132
+ /**
133
+ * Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.
134
+ * @param factories - Array of factories for custom qualifier types. Can be:
135
+ * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
136
+ * - {@link Config.QualifierTypeFactoryFunction | Factory functions}
137
+ * - A mix of both
138
+ * These are tried in order before falling back to built-in types.
139
+ * @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always appended to handle
140
+ * system qualifier types (Language, Territory, Literal).
141
+ */
142
+ constructor(factories) {
143
+ const normalizedFactories = factories.map((f) => typeof f === 'function' ? createQualifierTypeFactory(f) : f);
144
+ super([...normalizedFactories, new BuiltInQualifierTypeFactory()]);
145
+ }
146
+ }
147
+ /**
148
+ * A factory that validates and creates {@link QualifierTypes.QualifierType | QualifierType} instances
149
+ * from weakly-typed configuration objects. This factory accepts configurations with unvalidated
150
+ * string properties and validates them before delegating to the underlying factory chain.
151
+ *
152
+ * This pattern is useful at package boundaries where type identity issues may occur with
153
+ * branded types across different package instances.
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * // Accept weakly-typed config from external source
158
+ * const validatingFactory = new ValidatingQualifierTypeFactory([customFactory]);
159
+ *
160
+ * // Config can have plain string types instead of branded types
161
+ * const config = {
162
+ * name: 'my-qualifier', // plain string, not QualifierTypeName
163
+ * systemType: 'custom', // plain string
164
+ * configuration: { ... }
165
+ * };
166
+ *
167
+ * const result = validatingFactory.create(config); // Validates and converts internally
168
+ * ```
169
+ *
170
+ * @public
171
+ */
172
+ export class ValidatingQualifierTypeFactory {
173
+ /**
174
+ * Constructor for a validating qualifier type factory.
175
+ * @param factories - Array of factories for custom qualifier types. Can be:
176
+ * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
177
+ * - {@link Config.QualifierTypeFactoryFunction | Factory functions}
178
+ * - A mix of both
179
+ */
180
+ constructor(factories) {
181
+ this._innerFactory = new QualifierTypeFactory(factories);
182
+ }
183
+ /**
184
+ * Creates a qualifier type from a weakly-typed configuration object.
185
+ * @param config - The configuration object to validate and use for creation.
186
+ * @returns A result containing the new qualifier type if successful.
187
+ */
188
+ create(config) {
189
+ return QualifierTypes.Config.Convert.anyQualifierTypeConfig
190
+ .convert(config)
191
+ .onSuccess((validatedConfig) => {
192
+ return this._innerFactory.create(validatedConfig);
193
+ });
194
+ }
195
+ }
196
+ /**
197
+ * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.
198
+ * @public
199
+ */
200
+ export class BuiltInResourceTypeFactory {
201
+ /** {@inheritDoc Config.IConfigInitFactory.create} */
202
+ create(config) {
203
+ return ResourceTypes.createResourceTypeFromConfig(config);
204
+ }
205
+ }
206
+ /**
207
+ * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}
208
+ * by chaining a supplied factory with a {@link Config.BuiltInResourceTypeFactory | built-in factory} that handles built-in resource types.
209
+ * @public
210
+ */
211
+ export class ResourceTypeFactory extends ChainedConfigInitFactory {
212
+ /**
213
+ * Constructor for a resource type factory.
214
+ * @param factories - Array of factories for resource types. Can be:
215
+ * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
216
+ * - {@link Config.ResourceTypeFactoryFunction | Factory functions}
217
+ * - A mix of both
218
+ * @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.
219
+ */
220
+ constructor(factories) {
221
+ factories = factories !== null && factories !== void 0 ? factories : [];
222
+ const normalizedFactories = factories.map((f) => typeof f === 'function' ? createResourceTypeFactory(f) : f);
223
+ super([...normalizedFactories, new BuiltInResourceTypeFactory()]);
224
+ }
225
+ }
226
+ /**
227
+ * A factory that validates and creates {@link ResourceTypes.ResourceType | ResourceType} instances
228
+ * from weakly-typed configuration objects. This factory accepts configurations with unvalidated
229
+ * string properties and validates them before delegating to the underlying factory chain.
230
+ *
231
+ * This pattern is useful at package boundaries where type identity issues may occur with
232
+ * branded types across different package instances.
233
+ *
234
+ * @public
235
+ */
236
+ export class ValidatingResourceTypeFactory {
237
+ /**
238
+ * Constructor for a validating resource type factory.
239
+ * @param factories - Array of factories for resource types. Can be:
240
+ * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
241
+ * - {@link Config.ResourceTypeFactoryFunction | Factory functions}
242
+ * - A mix of both
243
+ */
244
+ constructor(factories) {
245
+ this._innerFactory = new ResourceTypeFactory(factories);
246
+ }
247
+ /**
248
+ * Creates a resource type from a weakly-typed configuration object.
249
+ * @param config - The configuration object to validate and use for creation.
250
+ * @returns A result containing the new resource type if successful.
251
+ */
252
+ create(config) {
253
+ return ResourceTypes.Config.Convert.resourceTypeConfig.convert(config).onSuccess((validatedConfig) => {
254
+ return this._innerFactory.create(validatedConfig);
255
+ });
256
+ }
257
+ }
258
+ //# sourceMappingURL=configInitFactory.js.map
@@ -0,0 +1,56 @@
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 QualifierTypes from '../qualifier-types';
25
+ import * as Qualifiers from '../qualifiers';
26
+ import * as ResourceTypes from '../resource-types';
27
+ import { allPredefinedSystemConfigurations } from './common';
28
+ /**
29
+ * A `Converter` for {@link Config.Model.ISystemConfiguration | ISystemConfiguration} objects.
30
+ * @returns A `Converter` for {@link Config.Model.ISystemConfiguration | ISystemConfiguration} objects.
31
+ * @public
32
+ */
33
+ export const systemConfiguration = Converters.strictObject({
34
+ name: Converters.optionalString,
35
+ description: Converters.optionalString,
36
+ qualifierTypes: Converters.arrayOf(QualifierTypes.Config.Convert.anyQualifierTypeConfig),
37
+ qualifiers: Converters.arrayOf(Qualifiers.Convert.qualifierDecl),
38
+ resourceTypes: Converters.arrayOf(ResourceTypes.Config.Convert.resourceTypeConfig)
39
+ });
40
+ /**
41
+ * A `Converter` for {@link Config.PredefinedSystemConfiguration | PredefinedSystemConfiguration} values.
42
+ * @returns A `Converter` for {@link Config.PredefinedSystemConfiguration | PredefinedSystemConfiguration} values.
43
+ * @public
44
+ */
45
+ export const predefinedSystemConfiguration = Converters.enumeratedValue(allPredefinedSystemConfigurations);
46
+ /**
47
+ * Validate a {@link Config.Model.ISystemConfiguration | ISystemConfiguration} object.
48
+ * @param config - The system configuration to validate
49
+ * @returns `Success` with the validated system configuration if successful,
50
+ * or `Failure` with an error message if validation fails.
51
+ * @public
52
+ */
53
+ export function validateSystemConfiguration(config) {
54
+ return systemConfiguration.convert(config);
55
+ }
56
+ //# sourceMappingURL=convert.js.map
@@ -0,0 +1,34 @@
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
+ // Browser-safe config exports - excludes Node.js filesystem dependencies
23
+ import * as Model from './json';
24
+ import * as Convert from './convert';
25
+ // Export all modules
26
+ export * from './configInitFactory';
27
+ export * from './common';
28
+ // Export SystemConfiguration class but not as wildcard to avoid pulling in loadFromFile
29
+ export { SystemConfiguration } from './systemConfiguration';
30
+ // Export namespaces
31
+ export { Model, Convert };
32
+ // Excluded from browser:
33
+ // - SystemConfiguration.loadFromFile() method (requires Node.js fs via JsonFile)
34
+ //# sourceMappingURL=index.browser.js.map
@@ -0,0 +1,28 @@
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 Model from './json';
23
+ import * as Convert from './convert';
24
+ export * from './configInitFactory';
25
+ export * from './systemConfiguration';
26
+ export * from './common';
27
+ export { Model, Convert };
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,23 @@
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
+ export {};
23
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1,138 @@
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
+ * Default qualifier types.
24
+ * @remarks
25
+ * The default qualifier types are:
26
+ * - language: recognizes BCP 47 language tags, accepts a comma-separated list of language tags in the context
27
+ * - territory: recognizes ISO 3166-1 alpha-2 territory codes, accepts a single code in the context
28
+ * @public
29
+ */
30
+ export const DefaultQualifierTypes = [
31
+ {
32
+ name: 'language',
33
+ systemType: 'language',
34
+ configuration: {
35
+ allowContextList: true
36
+ }
37
+ },
38
+ {
39
+ name: 'territory',
40
+ systemType: 'territory',
41
+ configuration: {
42
+ allowContextList: false
43
+ }
44
+ }
45
+ ];
46
+ /**
47
+ * Qualifier definitions in which territory is the primary qualifier, with
48
+ * language as a secondary qualifier.
49
+ * @remarks
50
+ * The default qualifiers are:
51
+ * - currentTerritory(token: geo): territory qualifier, priority 850
52
+ * - language(token: lang): language qualifier, priority 800
53
+ * @public
54
+ */
55
+ export const TerritoryPriorityQualifiers = [
56
+ {
57
+ name: 'currentTerritory',
58
+ token: 'geo',
59
+ typeName: 'territory',
60
+ defaultPriority: 850
61
+ },
62
+ {
63
+ name: 'language',
64
+ token: 'lang',
65
+ typeName: 'language',
66
+ defaultPriority: 800
67
+ }
68
+ ];
69
+ /**
70
+ * Qualifier definitions in which language is the primary qualifier, with
71
+ * territory as a secondary qualifier.
72
+ * @remarks
73
+ * The default qualifiers are:
74
+ * - language(token: lang): language qualifier, priority 850
75
+ * - currentTerritory(token: geo): territory qualifier, priority 800
76
+ * @public
77
+ */
78
+ export const LanguagePriorityQualifiers = [
79
+ {
80
+ name: 'language',
81
+ token: 'lang',
82
+ typeName: 'language',
83
+ defaultPriority: 850
84
+ },
85
+ {
86
+ name: 'currentTerritory',
87
+ token: 'geo',
88
+ typeName: 'territory',
89
+ defaultPriority: 800
90
+ }
91
+ ];
92
+ /**
93
+ * Default resource types.
94
+ * @public
95
+ */
96
+ export const DefaultResourceTypes = [
97
+ {
98
+ name: 'json',
99
+ typeName: 'json'
100
+ }
101
+ ];
102
+ /**
103
+ * System configuration with territory as the primary qualifier, and
104
+ * language as a secondary qualifier.
105
+ * @public
106
+ */
107
+ export const TerritoryPrioritySystemConfiguration = {
108
+ name: 'territory-priority',
109
+ description: 'Territory priority system configuration',
110
+ qualifierTypes: [...DefaultQualifierTypes],
111
+ qualifiers: [...TerritoryPriorityQualifiers],
112
+ resourceTypes: [...DefaultResourceTypes]
113
+ };
114
+ /**
115
+ * System configuration with language as the primary qualifier, and
116
+ * territory as a secondary qualifier.
117
+ * @public
118
+ */
119
+ export const LanguagePrioritySystemConfiguration = {
120
+ name: 'language-priority',
121
+ description: 'Language priority system configuration',
122
+ qualifierTypes: [...DefaultQualifierTypes],
123
+ qualifiers: [...LanguagePriorityQualifiers],
124
+ resourceTypes: [...DefaultResourceTypes]
125
+ };
126
+ /**
127
+ * The default system configuration gives priority to territory as the primary qualifier,
128
+ * with language as a secondary qualifier.
129
+ * @public
130
+ */
131
+ export const DefaultSystemConfiguration = {
132
+ name: 'default',
133
+ description: 'Default system configuration',
134
+ qualifierTypes: [...DefaultQualifierTypes],
135
+ qualifiers: [...TerritoryPriorityQualifiers],
136
+ resourceTypes: [...DefaultResourceTypes]
137
+ };
138
+ //# sourceMappingURL=default.js.map