@fgv/ts-res 5.1.0-0 → 5.1.0-2
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/package.json +24 -24
- package/dist/packlets/config/common.js +0 -78
- package/dist/packlets/config/configInitFactory.js +0 -258
- package/dist/packlets/config/convert.js +0 -56
- package/dist/packlets/config/index.browser.js +0 -34
- package/dist/packlets/config/index.js +0 -28
- package/dist/packlets/config/json.js +0 -23
- package/dist/packlets/config/predefined/default.js +0 -138
- package/dist/packlets/config/predefined/extended.js +0 -190
- package/dist/packlets/config/predefined/index.js +0 -25
- package/dist/packlets/config/systemConfiguration.js +0 -147
- package/dist/packlets/qualifier-types/config/convert.js +0 -124
- package/dist/packlets/qualifier-types/config/index.js +0 -25
- package/dist/packlets/qualifier-types/config/json.js +0 -32
- package/dist/packlets/resource-types/config/convert.js +0 -35
- package/dist/packlets/resource-types/config/index.js +0 -25
- package/dist/packlets/resource-types/config/json.js +0 -23
- package/lib/packlets/config/common.d.ts +0 -35
- package/lib/packlets/config/common.js +0 -97
- package/lib/packlets/config/configInitFactory.d.ts +0 -217
- package/lib/packlets/config/configInitFactory.js +0 -303
- package/lib/packlets/config/convert.d.ts +0 -23
- package/lib/packlets/config/convert.js +0 -93
- package/lib/packlets/config/index.browser.d.ts +0 -7
- package/lib/packlets/config/index.browser.js +0 -74
- package/lib/packlets/config/index.d.ts +0 -7
- package/lib/packlets/config/index.js +0 -68
- package/lib/packlets/config/json.d.ts +0 -20
- package/lib/packlets/config/json.js +0 -24
- package/lib/packlets/config/predefined/default.d.ts +0 -57
- package/lib/packlets/config/predefined/default.js +0 -141
- package/lib/packlets/config/predefined/extended.d.ts +0 -25
- package/lib/packlets/config/predefined/extended.js +0 -193
- package/lib/packlets/config/predefined/index.d.ts +0 -4
- package/lib/packlets/config/predefined/index.js +0 -62
- package/lib/packlets/config/systemConfiguration.d.ts +0 -94
- package/lib/packlets/config/systemConfiguration.js +0 -152
- package/lib/packlets/qualifier-types/config/convert.d.ts +0 -65
- package/lib/packlets/qualifier-types/config/convert.js +0 -161
- package/lib/packlets/qualifier-types/config/index.d.ts +0 -4
- package/lib/packlets/qualifier-types/config/index.js +0 -64
- package/lib/packlets/qualifier-types/config/json.d.ts +0 -91
- package/lib/packlets/qualifier-types/config/json.js +0 -35
- package/lib/packlets/resource-types/config/convert.d.ts +0 -8
- package/lib/packlets/resource-types/config/convert.js +0 -38
- package/lib/packlets/resource-types/config/index.d.ts +0 -4
- package/lib/packlets/resource-types/config/index.js +0 -64
- package/lib/packlets/resource-types/config/json.d.ts +0 -11
- package/lib/packlets/resource-types/config/json.js +0 -24
|
@@ -1,138 +0,0 @@
|
|
|
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
|
|
@@ -1,190 +0,0 @@
|
|
|
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
|
-
* Example extended qualifier types.
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export const ExtendedQualifierTypes = [
|
|
27
|
-
{
|
|
28
|
-
name: 'language',
|
|
29
|
-
systemType: 'language',
|
|
30
|
-
configuration: {
|
|
31
|
-
allowContextList: true
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'territory',
|
|
36
|
-
systemType: 'territory',
|
|
37
|
-
configuration: {
|
|
38
|
-
allowContextList: false,
|
|
39
|
-
acceptLowercase: false
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'role',
|
|
44
|
-
systemType: 'literal',
|
|
45
|
-
configuration: {
|
|
46
|
-
enumeratedValues: ['admin', 'agent', 'user', 'guest']
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'environment',
|
|
51
|
-
systemType: 'literal',
|
|
52
|
-
configuration: {
|
|
53
|
-
enumeratedValues: ['production', 'integration', 'development', 'test', 'ephemeral']
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'currency',
|
|
58
|
-
systemType: 'literal',
|
|
59
|
-
configuration: {
|
|
60
|
-
caseSensitive: true,
|
|
61
|
-
enumeratedValues: ['USD', 'EUR', 'GBP', 'JPY', 'CNY']
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: 'market',
|
|
66
|
-
systemType: 'literal',
|
|
67
|
-
configuration: {
|
|
68
|
-
enumeratedValues: [
|
|
69
|
-
'world',
|
|
70
|
-
'americas',
|
|
71
|
-
'europe',
|
|
72
|
-
'asia',
|
|
73
|
-
'oceania',
|
|
74
|
-
'africa',
|
|
75
|
-
'middle-east',
|
|
76
|
-
'latin-america',
|
|
77
|
-
'caribbean',
|
|
78
|
-
'central-america',
|
|
79
|
-
'south-america',
|
|
80
|
-
'north-america',
|
|
81
|
-
'nordics',
|
|
82
|
-
'baltic',
|
|
83
|
-
'balkans',
|
|
84
|
-
'eastern-europe',
|
|
85
|
-
'western-europe',
|
|
86
|
-
'central-europe',
|
|
87
|
-
'eastern-africa',
|
|
88
|
-
'western-africa',
|
|
89
|
-
'central-africa',
|
|
90
|
-
'north-africa',
|
|
91
|
-
'south-africa',
|
|
92
|
-
'middle-africa',
|
|
93
|
-
'southeast-asia'
|
|
94
|
-
],
|
|
95
|
-
hierarchy: {
|
|
96
|
-
americas: 'world',
|
|
97
|
-
europe: 'world',
|
|
98
|
-
asia: 'world',
|
|
99
|
-
oceania: 'world',
|
|
100
|
-
africa: 'world',
|
|
101
|
-
'middle-east': 'world',
|
|
102
|
-
'latin-america': 'americas',
|
|
103
|
-
caribbean: 'americas',
|
|
104
|
-
'central-america': 'americas',
|
|
105
|
-
'south-america': 'americas',
|
|
106
|
-
'north-america': 'americas',
|
|
107
|
-
nordics: 'europe',
|
|
108
|
-
baltic: 'europe',
|
|
109
|
-
balkans: 'europe',
|
|
110
|
-
'eastern-europe': 'europe',
|
|
111
|
-
'western-europe': 'europe',
|
|
112
|
-
'central-europe': 'europe',
|
|
113
|
-
'eastern-africa': 'africa',
|
|
114
|
-
'western-africa': 'africa',
|
|
115
|
-
'central-africa': 'africa',
|
|
116
|
-
'north-africa': 'africa',
|
|
117
|
-
'south-africa': 'africa',
|
|
118
|
-
'middle-africa': 'africa',
|
|
119
|
-
'southeast-asia': 'asia'
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
];
|
|
124
|
-
/**
|
|
125
|
-
* Example extended qualifiers.
|
|
126
|
-
* @public
|
|
127
|
-
*/
|
|
128
|
-
export const ExtendedQualifiers = [
|
|
129
|
-
{
|
|
130
|
-
name: 'homeTerritory',
|
|
131
|
-
token: 'home',
|
|
132
|
-
typeName: 'territory',
|
|
133
|
-
defaultPriority: 900
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: 'currentTerritory',
|
|
137
|
-
token: 'geo',
|
|
138
|
-
typeName: 'territory',
|
|
139
|
-
defaultPriority: 850
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
name: 'language',
|
|
143
|
-
token: 'lang',
|
|
144
|
-
typeName: 'language',
|
|
145
|
-
defaultPriority: 800
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'market',
|
|
149
|
-
typeName: 'market',
|
|
150
|
-
defaultPriority: 750
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: 'role',
|
|
154
|
-
typeName: 'role',
|
|
155
|
-
defaultPriority: 700
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
name: 'environment',
|
|
159
|
-
token: 'env',
|
|
160
|
-
typeName: 'environment',
|
|
161
|
-
defaultPriority: 650
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
name: 'currency',
|
|
165
|
-
typeName: 'currency',
|
|
166
|
-
defaultPriority: 600
|
|
167
|
-
}
|
|
168
|
-
];
|
|
169
|
-
/**
|
|
170
|
-
* Example resource types.
|
|
171
|
-
* @public
|
|
172
|
-
*/
|
|
173
|
-
export const ExtendedResourceTypes = [
|
|
174
|
-
{
|
|
175
|
-
name: 'json',
|
|
176
|
-
typeName: 'json'
|
|
177
|
-
}
|
|
178
|
-
];
|
|
179
|
-
/**
|
|
180
|
-
* An example system configuration demonstrating various configuration options.
|
|
181
|
-
* @public
|
|
182
|
-
*/
|
|
183
|
-
export const ExtendedSystemConfiguration = {
|
|
184
|
-
name: 'extended-example',
|
|
185
|
-
description: 'An example system configuration demonstrating various configuration options',
|
|
186
|
-
qualifierTypes: [...ExtendedQualifierTypes],
|
|
187
|
-
qualifiers: [...ExtendedQualifiers],
|
|
188
|
-
resourceTypes: [...ExtendedResourceTypes]
|
|
189
|
-
};
|
|
190
|
-
//# sourceMappingURL=extended.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
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 Default from './default';
|
|
23
|
-
import * as Example from './extended';
|
|
24
|
-
export { Default, Example };
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,147 +0,0 @@
|
|
|
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 { captureResult, mapResults, fail, succeed, omit } from '@fgv/ts-utils';
|
|
23
|
-
import { QualifierTypeCollector } from '../qualifier-types';
|
|
24
|
-
import { QualifierCollector } from '../qualifiers';
|
|
25
|
-
import { ResourceTypeCollector } from '../resource-types';
|
|
26
|
-
import { systemConfiguration } from './convert';
|
|
27
|
-
import { JsonFile, sanitizeJsonObject } from '@fgv/ts-json-base';
|
|
28
|
-
import { BuiltInQualifierTypeFactory, BuiltInResourceTypeFactory } from './configInitFactory';
|
|
29
|
-
/**
|
|
30
|
-
* Creates a copy of the provided {@link Config.Model.ISystemConfiguration | system configuration}
|
|
31
|
-
* with updated qualifier default values.
|
|
32
|
-
* @param config - The base {@link Config.Model.ISystemConfiguration | system configuration} to copy.
|
|
33
|
-
* @param qualifierDefaultValues - Map of qualifier names to default values. Use `null` to remove existing values.
|
|
34
|
-
* @returns `Success` with the updated {@link Config.Model.ISystemConfiguration | system configuration}
|
|
35
|
-
* if successful, `Failure` with an error message otherwise.
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
export function updateSystemConfigurationQualifierDefaultValues(config, qualifierDefaultValues // eslint-disable-line @rushstack/no-new-null
|
|
39
|
-
) {
|
|
40
|
-
// Create a copy of the config
|
|
41
|
-
return sanitizeJsonObject(config).onSuccess((updatedConfig) => {
|
|
42
|
-
// Create a map of existing qualifier names for validation
|
|
43
|
-
const existingQualifierNames = new Set(updatedConfig.qualifiers.map((q) => q.name));
|
|
44
|
-
// Validate that all specified qualifiers exist in the configuration
|
|
45
|
-
for (const qualifierName of Object.keys(qualifierDefaultValues)) {
|
|
46
|
-
if (!existingQualifierNames.has(qualifierName)) {
|
|
47
|
-
return fail(`Qualifier '${qualifierName}' not found in system configuration`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Update qualifier default values
|
|
51
|
-
updatedConfig.qualifiers = updatedConfig.qualifiers.map((qualifier) => {
|
|
52
|
-
if (qualifier.name in qualifierDefaultValues) {
|
|
53
|
-
const newDefaultValue = qualifierDefaultValues[qualifier.name];
|
|
54
|
-
// Create a copy of the qualifier
|
|
55
|
-
const updatedQualifier = Object.assign({}, qualifier);
|
|
56
|
-
if (newDefaultValue === null) {
|
|
57
|
-
// Remove the default value
|
|
58
|
-
delete updatedQualifier.defaultValue;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
// Set the new default value
|
|
62
|
-
updatedQualifier.defaultValue = newDefaultValue;
|
|
63
|
-
}
|
|
64
|
-
return updatedQualifier;
|
|
65
|
-
}
|
|
66
|
-
return qualifier;
|
|
67
|
-
});
|
|
68
|
-
return succeed(updatedConfig);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* A system configuration for both runtime or build.
|
|
73
|
-
* @public
|
|
74
|
-
*/
|
|
75
|
-
export class SystemConfiguration {
|
|
76
|
-
/**
|
|
77
|
-
* The name of this system configuration.
|
|
78
|
-
*/
|
|
79
|
-
get name() {
|
|
80
|
-
return this._config.name;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* The description of this system configuration.
|
|
84
|
-
*/
|
|
85
|
-
get description() {
|
|
86
|
-
return this._config.description;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Constructs a new instance of a {@link Config.SystemConfiguration | SystemConfiguration} from the
|
|
90
|
-
* supplied {@link Config.Model.ISystemConfiguration | system configuration}.
|
|
91
|
-
* @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.
|
|
92
|
-
* @public
|
|
93
|
-
*/
|
|
94
|
-
constructor(config, initParams) {
|
|
95
|
-
var _a, _b;
|
|
96
|
-
this._config = config;
|
|
97
|
-
const qualifierTypeFactory = (_a = initParams === null || initParams === void 0 ? void 0 : initParams.qualifierTypeFactory) !== null && _a !== void 0 ? _a : new BuiltInQualifierTypeFactory();
|
|
98
|
-
const resourceTypeFactory = (_b = initParams === null || initParams === void 0 ? void 0 : initParams.resourceTypeFactory) !== null && _b !== void 0 ? _b : new BuiltInResourceTypeFactory();
|
|
99
|
-
this.qualifierTypes = QualifierTypeCollector.create({
|
|
100
|
-
qualifierTypes: mapResults(config.qualifierTypes.map((tc) => qualifierTypeFactory.create(tc))).orThrow()
|
|
101
|
-
}).orThrow();
|
|
102
|
-
this.qualifiers = QualifierCollector.create({
|
|
103
|
-
qualifierTypes: this.qualifierTypes,
|
|
104
|
-
qualifiers: config.qualifiers
|
|
105
|
-
}).orThrow();
|
|
106
|
-
this.resourceTypes = ResourceTypeCollector.create({
|
|
107
|
-
resourceTypes: mapResults(config.resourceTypes.map((rt) => resourceTypeFactory.create(rt))).orThrow()
|
|
108
|
-
}).orThrow();
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Creates a new {@link Config.SystemConfiguration | SystemConfiguration} from the supplied
|
|
112
|
-
* {@link Config.Model.ISystemConfiguration | system configuration}.
|
|
113
|
-
* @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.
|
|
114
|
-
* @param initParams - Optional {@link Config.ISystemConfigurationInitParams | initialization parameters}.
|
|
115
|
-
* @returns `Success` with the new {@link Config.SystemConfiguration | SystemConfiguration}
|
|
116
|
-
* if successful, `Failure` with an error message otherwise.
|
|
117
|
-
* @public
|
|
118
|
-
*/
|
|
119
|
-
static create(config, initParams) {
|
|
120
|
-
if (initParams === null || initParams === void 0 ? void 0 : initParams.qualifierDefaultValues) {
|
|
121
|
-
/* c8 ignore next 9 - functional code tested but coverage intermittently missed */
|
|
122
|
-
return updateSystemConfigurationQualifierDefaultValues(config, initParams.qualifierDefaultValues).onSuccess((updatedConfig) => captureResult(() => new SystemConfiguration(updatedConfig, omit(initParams, ['qualifierDefaultValues']))));
|
|
123
|
-
}
|
|
124
|
-
return captureResult(() => new SystemConfiguration(config, initParams));
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Loads a {@link Config.SystemConfiguration | SystemConfiguration} from a file.
|
|
128
|
-
* @param path - The path to the file to load.
|
|
129
|
-
* @returns `Success` with the {@link Config.SystemConfiguration | SystemConfiguration}
|
|
130
|
-
* if successful, `Failure` with an error message otherwise.
|
|
131
|
-
* @public
|
|
132
|
-
*/
|
|
133
|
-
static loadFromFile(path, initParams) {
|
|
134
|
-
return JsonFile.convertJsonFileSync(path, systemConfiguration).onSuccess((config) => SystemConfiguration.create(config, initParams));
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Returns the {@link Config.Model.ISystemConfiguration | system configuration} that this
|
|
138
|
-
* {@link Config.SystemConfiguration | SystemConfiguration} was created from.
|
|
139
|
-
* @returns `Success` with the {@link Config.Model.ISystemConfiguration | system configuration}
|
|
140
|
-
* if successful, `Failure` with an error message otherwise.
|
|
141
|
-
* @public
|
|
142
|
-
*/
|
|
143
|
-
getConfig() {
|
|
144
|
-
return systemConfiguration.convert(this._config);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
//# sourceMappingURL=systemConfiguration.js.map
|
|
@@ -1,124 +0,0 @@
|
|
|
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
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|