@fgv/ts-res 5.1.0-37 → 5.1.0-39

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 (98) hide show
  1. package/dist/tsdoc-metadata.json +1 -1
  2. package/package.json +9 -9
  3. package/dist/packlets/config/common.js +0 -78
  4. package/dist/packlets/config/common.js.map +0 -1
  5. package/dist/packlets/config/configInitFactory.js +0 -258
  6. package/dist/packlets/config/configInitFactory.js.map +0 -1
  7. package/dist/packlets/config/convert.js +0 -56
  8. package/dist/packlets/config/convert.js.map +0 -1
  9. package/dist/packlets/config/index.browser.js +0 -34
  10. package/dist/packlets/config/index.browser.js.map +0 -1
  11. package/dist/packlets/config/index.js +0 -28
  12. package/dist/packlets/config/index.js.map +0 -1
  13. package/dist/packlets/config/json.js +0 -23
  14. package/dist/packlets/config/json.js.map +0 -1
  15. package/dist/packlets/config/predefined/default.js +0 -138
  16. package/dist/packlets/config/predefined/default.js.map +0 -1
  17. package/dist/packlets/config/predefined/extended.js +0 -190
  18. package/dist/packlets/config/predefined/extended.js.map +0 -1
  19. package/dist/packlets/config/predefined/index.js +0 -25
  20. package/dist/packlets/config/predefined/index.js.map +0 -1
  21. package/dist/packlets/config/systemConfiguration.js +0 -147
  22. package/dist/packlets/config/systemConfiguration.js.map +0 -1
  23. package/dist/packlets/qualifier-types/config/convert.js +0 -124
  24. package/dist/packlets/qualifier-types/config/convert.js.map +0 -1
  25. package/dist/packlets/qualifier-types/config/index.js +0 -25
  26. package/dist/packlets/qualifier-types/config/index.js.map +0 -1
  27. package/dist/packlets/qualifier-types/config/json.js +0 -32
  28. package/dist/packlets/qualifier-types/config/json.js.map +0 -1
  29. package/dist/packlets/resource-types/config/convert.js +0 -35
  30. package/dist/packlets/resource-types/config/convert.js.map +0 -1
  31. package/dist/packlets/resource-types/config/index.js +0 -25
  32. package/dist/packlets/resource-types/config/index.js.map +0 -1
  33. package/dist/packlets/resource-types/config/json.js +0 -23
  34. package/dist/packlets/resource-types/config/json.js.map +0 -1
  35. package/lib/packlets/config/common.d.ts +0 -35
  36. package/lib/packlets/config/common.d.ts.map +0 -1
  37. package/lib/packlets/config/common.js +0 -97
  38. package/lib/packlets/config/common.js.map +0 -1
  39. package/lib/packlets/config/configInitFactory.d.ts +0 -217
  40. package/lib/packlets/config/configInitFactory.d.ts.map +0 -1
  41. package/lib/packlets/config/configInitFactory.js +0 -303
  42. package/lib/packlets/config/configInitFactory.js.map +0 -1
  43. package/lib/packlets/config/convert.d.ts +0 -23
  44. package/lib/packlets/config/convert.d.ts.map +0 -1
  45. package/lib/packlets/config/convert.js +0 -93
  46. package/lib/packlets/config/convert.js.map +0 -1
  47. package/lib/packlets/config/index.browser.d.ts +0 -7
  48. package/lib/packlets/config/index.browser.d.ts.map +0 -1
  49. package/lib/packlets/config/index.browser.js +0 -74
  50. package/lib/packlets/config/index.browser.js.map +0 -1
  51. package/lib/packlets/config/index.d.ts +0 -7
  52. package/lib/packlets/config/index.d.ts.map +0 -1
  53. package/lib/packlets/config/index.js +0 -68
  54. package/lib/packlets/config/index.js.map +0 -1
  55. package/lib/packlets/config/json.d.ts +0 -20
  56. package/lib/packlets/config/json.d.ts.map +0 -1
  57. package/lib/packlets/config/json.js +0 -24
  58. package/lib/packlets/config/json.js.map +0 -1
  59. package/lib/packlets/config/predefined/default.d.ts +0 -57
  60. package/lib/packlets/config/predefined/default.d.ts.map +0 -1
  61. package/lib/packlets/config/predefined/default.js +0 -141
  62. package/lib/packlets/config/predefined/default.js.map +0 -1
  63. package/lib/packlets/config/predefined/extended.d.ts +0 -25
  64. package/lib/packlets/config/predefined/extended.d.ts.map +0 -1
  65. package/lib/packlets/config/predefined/extended.js +0 -193
  66. package/lib/packlets/config/predefined/extended.js.map +0 -1
  67. package/lib/packlets/config/predefined/index.d.ts +0 -4
  68. package/lib/packlets/config/predefined/index.d.ts.map +0 -1
  69. package/lib/packlets/config/predefined/index.js +0 -62
  70. package/lib/packlets/config/predefined/index.js.map +0 -1
  71. package/lib/packlets/config/systemConfiguration.d.ts +0 -94
  72. package/lib/packlets/config/systemConfiguration.d.ts.map +0 -1
  73. package/lib/packlets/config/systemConfiguration.js +0 -152
  74. package/lib/packlets/config/systemConfiguration.js.map +0 -1
  75. package/lib/packlets/qualifier-types/config/convert.d.ts +0 -65
  76. package/lib/packlets/qualifier-types/config/convert.d.ts.map +0 -1
  77. package/lib/packlets/qualifier-types/config/convert.js +0 -161
  78. package/lib/packlets/qualifier-types/config/convert.js.map +0 -1
  79. package/lib/packlets/qualifier-types/config/index.d.ts +0 -4
  80. package/lib/packlets/qualifier-types/config/index.d.ts.map +0 -1
  81. package/lib/packlets/qualifier-types/config/index.js +0 -64
  82. package/lib/packlets/qualifier-types/config/index.js.map +0 -1
  83. package/lib/packlets/qualifier-types/config/json.d.ts +0 -91
  84. package/lib/packlets/qualifier-types/config/json.d.ts.map +0 -1
  85. package/lib/packlets/qualifier-types/config/json.js +0 -35
  86. package/lib/packlets/qualifier-types/config/json.js.map +0 -1
  87. package/lib/packlets/resource-types/config/convert.d.ts +0 -8
  88. package/lib/packlets/resource-types/config/convert.d.ts.map +0 -1
  89. package/lib/packlets/resource-types/config/convert.js +0 -38
  90. package/lib/packlets/resource-types/config/convert.js.map +0 -1
  91. package/lib/packlets/resource-types/config/index.d.ts +0 -4
  92. package/lib/packlets/resource-types/config/index.d.ts.map +0 -1
  93. package/lib/packlets/resource-types/config/index.js +0 -64
  94. package/lib/packlets/resource-types/config/index.js.map +0 -1
  95. package/lib/packlets/resource-types/config/json.d.ts +0 -11
  96. package/lib/packlets/resource-types/config/json.d.ts.map +0 -1
  97. package/lib/packlets/resource-types/config/json.js +0 -24
  98. package/lib/packlets/resource-types/config/json.js.map +0 -1
@@ -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 +0,0 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../../../../src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,2BAA2B,CAAC;IAC5C,aAAa,EAAE,CAAC,GAAG,oBAAoB,CAAC;CACzC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAyB;IACvE,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,wCAAwC;IACrD,cAAc,EAAE,CAAC,GAAG,qBAAqB,CAAC;IAC1C,UAAU,EAAE,CAAC,GAAG,0BAA0B,CAAC;IAC3C,aAAa,EAAE,CAAC,GAAG,oBAAoB,CAAC;CACzC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAyB;IAC9D,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,8BAA8B;IAC3C,cAAc,EAAE,CAAC,GAAG,qBAAqB,CAAC;IAC1C,UAAU,EAAE,CAAC,GAAG,2BAA2B,CAAC;IAC5C,aAAa,EAAE,CAAC,GAAG,oBAAoB,CAAC;CACzC,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { ISystemConfiguration } from '../json';\n\nimport * as QualifierTypes from '../../qualifier-types';\nimport * as Qualifiers from '../../qualifiers';\nimport * as ResourceTypes from '../../resource-types';\n\n/**\n * Default qualifier types.\n * @remarks\n * The default qualifier types are:\n * - language: recognizes BCP 47 language tags, accepts a comma-separated list of language tags in the context\n * - territory: recognizes ISO 3166-1 alpha-2 territory codes, accepts a single code in the context\n * @public\n */\nexport const DefaultQualifierTypes: ReadonlyArray<QualifierTypes.Config.ISystemQualifierTypeConfig> = [\n {\n name: 'language',\n systemType: 'language',\n configuration: {\n allowContextList: true\n }\n },\n {\n name: 'territory',\n systemType: 'territory',\n configuration: {\n allowContextList: false\n }\n }\n];\n\n/**\n * Qualifier definitions in which territory is the primary qualifier, with\n * language as a secondary qualifier.\n * @remarks\n * The default qualifiers are:\n * - currentTerritory(token: geo): territory qualifier, priority 850\n * - language(token: lang): language qualifier, priority 800\n * @public\n */\nexport const TerritoryPriorityQualifiers: ReadonlyArray<Qualifiers.IQualifierDecl> = [\n {\n name: 'currentTerritory',\n token: 'geo',\n typeName: 'territory',\n defaultPriority: 850\n },\n {\n name: 'language',\n token: 'lang',\n typeName: 'language',\n defaultPriority: 800\n }\n];\n\n/**\n * Qualifier definitions in which language is the primary qualifier, with\n * territory as a secondary qualifier.\n * @remarks\n * The default qualifiers are:\n * - language(token: lang): language qualifier, priority 850\n * - currentTerritory(token: geo): territory qualifier, priority 800\n * @public\n */\nexport const LanguagePriorityQualifiers: ReadonlyArray<Qualifiers.IQualifierDecl> = [\n {\n name: 'language',\n token: 'lang',\n typeName: 'language',\n defaultPriority: 850\n },\n {\n name: 'currentTerritory',\n token: 'geo',\n typeName: 'territory',\n defaultPriority: 800\n }\n];\n\n/**\n * Default resource types.\n * @public\n */\nexport const DefaultResourceTypes: ReadonlyArray<ResourceTypes.Config.IResourceTypeConfig> = [\n {\n name: 'json',\n typeName: 'json'\n }\n];\n\n/**\n * System configuration with territory as the primary qualifier, and\n * language as a secondary qualifier.\n * @public\n */\nexport const TerritoryPrioritySystemConfiguration: ISystemConfiguration = {\n name: 'territory-priority',\n description: 'Territory priority system configuration',\n qualifierTypes: [...DefaultQualifierTypes],\n qualifiers: [...TerritoryPriorityQualifiers],\n resourceTypes: [...DefaultResourceTypes]\n};\n\n/**\n * System configuration with language as the primary qualifier, and\n * territory as a secondary qualifier.\n * @public\n */\nexport const LanguagePrioritySystemConfiguration: ISystemConfiguration = {\n name: 'language-priority',\n description: 'Language priority system configuration',\n qualifierTypes: [...DefaultQualifierTypes],\n qualifiers: [...LanguagePriorityQualifiers],\n resourceTypes: [...DefaultResourceTypes]\n};\n\n/**\n * The default system configuration gives priority to territory as the primary qualifier,\n * with language as a secondary qualifier.\n * @public\n */\nexport const DefaultSystemConfiguration: ISystemConfiguration = {\n name: 'default',\n description: 'Default system configuration',\n qualifierTypes: [...DefaultQualifierTypes],\n qualifiers: [...TerritoryPriorityQualifiers],\n resourceTypes: [...DefaultResourceTypes]\n};\n"]}
@@ -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 +0,0 @@
1
- {"version":3,"file":"extended.js","sourceRoot":"","sources":["../../../../src/packlets/config/predefined/extended.ts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,QAAQ,EAAE,MAAM;QAChB,eAAe,EAAE,GAAG;KACrB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,aAAa;QACvB,eAAe,EAAE,GAAG;KACrB;IACD;QACE,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,UAAU;QACpB,eAAe,EAAE,GAAG;KACrB;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA4D;IAC5F;QACE,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,MAAM;KACjB;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAyB;IAC/D,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,6EAA6E;IAC1F,cAAc,EAAE,CAAC,GAAG,sBAAsB,CAAC;IAC3C,UAAU,EAAE,CAAC,GAAG,kBAAkB,CAAC;IACnC,aAAa,EAAE,CAAC,GAAG,qBAAqB,CAAC;CAC1C,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as ResourceTypes from '../../resource-types';\nimport * as QualifierTypes from '../../qualifier-types';\nimport * as Qualifiers from '../../qualifiers';\nimport { ISystemConfiguration } from '../json';\n\n/**\n * Example extended qualifier types.\n * @public\n */\nexport const ExtendedQualifierTypes: ReadonlyArray<QualifierTypes.Config.ISystemQualifierTypeConfig> = [\n {\n name: 'language',\n systemType: 'language',\n configuration: {\n allowContextList: true\n }\n },\n {\n name: 'territory',\n systemType: 'territory',\n configuration: {\n allowContextList: false,\n acceptLowercase: false\n }\n },\n {\n name: 'role',\n systemType: 'literal',\n configuration: {\n enumeratedValues: ['admin', 'agent', 'user', 'guest']\n }\n },\n {\n name: 'environment',\n systemType: 'literal',\n configuration: {\n enumeratedValues: ['production', 'integration', 'development', 'test', 'ephemeral']\n }\n },\n {\n name: 'currency',\n systemType: 'literal',\n configuration: {\n caseSensitive: true,\n enumeratedValues: ['USD', 'EUR', 'GBP', 'JPY', 'CNY']\n }\n },\n {\n name: 'market',\n systemType: 'literal',\n configuration: {\n enumeratedValues: [\n 'world',\n 'americas',\n 'europe',\n 'asia',\n 'oceania',\n 'africa',\n 'middle-east',\n 'latin-america',\n 'caribbean',\n 'central-america',\n 'south-america',\n 'north-america',\n 'nordics',\n 'baltic',\n 'balkans',\n 'eastern-europe',\n 'western-europe',\n 'central-europe',\n 'eastern-africa',\n 'western-africa',\n 'central-africa',\n 'north-africa',\n 'south-africa',\n 'middle-africa',\n 'southeast-asia'\n ],\n hierarchy: {\n americas: 'world',\n europe: 'world',\n asia: 'world',\n oceania: 'world',\n africa: 'world',\n 'middle-east': 'world',\n 'latin-america': 'americas',\n caribbean: 'americas',\n 'central-america': 'americas',\n 'south-america': 'americas',\n 'north-america': 'americas',\n nordics: 'europe',\n baltic: 'europe',\n balkans: 'europe',\n 'eastern-europe': 'europe',\n 'western-europe': 'europe',\n 'central-europe': 'europe',\n 'eastern-africa': 'africa',\n 'western-africa': 'africa',\n 'central-africa': 'africa',\n 'north-africa': 'africa',\n 'south-africa': 'africa',\n 'middle-africa': 'africa',\n 'southeast-asia': 'asia'\n }\n }\n }\n];\n\n/**\n * Example extended qualifiers.\n * @public\n */\nexport const ExtendedQualifiers: ReadonlyArray<Qualifiers.IQualifierDecl> = [\n {\n name: 'homeTerritory',\n token: 'home',\n typeName: 'territory',\n defaultPriority: 900\n },\n {\n name: 'currentTerritory',\n token: 'geo',\n typeName: 'territory',\n defaultPriority: 850\n },\n {\n name: 'language',\n token: 'lang',\n typeName: 'language',\n defaultPriority: 800\n },\n {\n name: 'market',\n typeName: 'market',\n defaultPriority: 750\n },\n {\n name: 'role',\n typeName: 'role',\n defaultPriority: 700\n },\n {\n name: 'environment',\n token: 'env',\n typeName: 'environment',\n defaultPriority: 650\n },\n {\n name: 'currency',\n typeName: 'currency',\n defaultPriority: 600\n }\n];\n\n/**\n * Example resource types.\n * @public\n */\nexport const ExtendedResourceTypes: ReadonlyArray<ResourceTypes.Config.IResourceTypeConfig> = [\n {\n name: 'json',\n typeName: 'json'\n }\n];\n\n/**\n * An example system configuration demonstrating various configuration options.\n * @public\n */\nexport const ExtendedSystemConfiguration: ISystemConfiguration = {\n name: 'extended-example',\n description: 'An example system configuration demonstrating various configuration options',\n qualifierTypes: [...ExtendedQualifierTypes],\n qualifiers: [...ExtendedQualifiers],\n resourceTypes: [...ExtendedResourceTypes]\n};\n"]}
@@ -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 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/config/predefined/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Default from './default';\nimport * as Example from './extended';\n\nexport { Default, Example };\n"]}
@@ -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 +0,0 @@
1
- {"version":3,"file":"systemConfiguration.js","sourceRoot":"","sources":["../../../src/packlets/config/systemConfiguration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAU,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGvF,OAAO,EAAiB,sBAAsB,EAAkC,MAAM,oBAAoB,CAAC;AAC3G,OAAO,EAA+B,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAA+C,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEvG,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,qBAAqB,CAAC;AAiB7B;;;;;;;;GAQG;AACH,MAAM,UAAU,+CAA+C,CAC7D,MAA4B,EAC5B,sBAAqD,CAAC,6CAA6C;;IAEnG,8BAA8B;IAC9B,OAAO,kBAAkB,CAAuB,MAAM,CAA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AAE,sBAAsB,EAAE,CAAC;YACvC,kFAAkF;YAClF,OAAO,+CAA+C,CACpD,MAAM,EACN,UAAU,CAAC,sBAAsB,CAClC,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,EAAE,CAC5B,aAAa,CACX,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAC3F,CACF,CAAC;QACJ,CAAC;QACD,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,YAAY,CACxB,IAAY,EACZ,UAA2C;QAE3C,OAAO,QAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAClF,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAC/C,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,SAAS;QACd,OAAO,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, mapResults, Result, fail, succeed, omit } from '@fgv/ts-utils';\nimport * as QualifierTypes from '../qualifier-types';\nimport * as ResourceTypes from '../resource-types';\nimport { QualifierType, QualifierTypeCollector, ReadOnlyQualifierTypeCollector } from '../qualifier-types';\nimport { IReadOnlyQualifierCollector, QualifierCollector } from '../qualifiers';\nimport { ReadOnlyResourceTypeCollector, ResourceType, ResourceTypeCollector } from '../resource-types';\nimport { ISystemConfiguration } from './json';\nimport { systemConfiguration } from './convert';\nimport { JsonFile, sanitizeJsonObject } from '@fgv/ts-json-base';\nimport {\n BuiltInQualifierTypeFactory,\n BuiltInResourceTypeFactory,\n IConfigInitFactory\n} from './configInitFactory';\n\n/**\n * Parameters used to initialize a {@link Config.SystemConfiguration | SystemConfiguration}.\n * @public\n */\nexport interface ISystemConfigurationInitParams {\n /**\n * Optional map of qualifier names to default values. If provided, qualifiers\n * in the system configuration will be updated with these default values.\n * Use `null` as the value to remove an existing default value.\n */\n qualifierDefaultValues?: Record<string, string | null>; // eslint-disable-line @rushstack/no-new-null\n qualifierTypeFactory?: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType>;\n resourceTypeFactory?: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>;\n}\n\n/**\n * Creates a copy of the provided {@link Config.Model.ISystemConfiguration | system configuration}\n * with updated qualifier default values.\n * @param config - The base {@link Config.Model.ISystemConfiguration | system configuration} to copy.\n * @param qualifierDefaultValues - Map of qualifier names to default values. Use `null` to remove existing values.\n * @returns `Success` with the updated {@link Config.Model.ISystemConfiguration | system configuration}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\nexport function updateSystemConfigurationQualifierDefaultValues(\n config: ISystemConfiguration,\n qualifierDefaultValues: Record<string, string | null> // eslint-disable-line @rushstack/no-new-null\n): Result<ISystemConfiguration> {\n // Create a copy of the config\n return sanitizeJsonObject<ISystemConfiguration>(config).onSuccess((updatedConfig) => {\n // Create a map of existing qualifier names for validation\n const existingQualifierNames = new Set(updatedConfig.qualifiers.map((q) => q.name));\n\n // Validate that all specified qualifiers exist in the configuration\n for (const qualifierName of Object.keys(qualifierDefaultValues)) {\n if (!existingQualifierNames.has(qualifierName)) {\n return fail(`Qualifier '${qualifierName}' not found in system configuration`);\n }\n }\n\n // Update qualifier default values\n updatedConfig.qualifiers = updatedConfig.qualifiers.map((qualifier) => {\n if (qualifier.name in qualifierDefaultValues) {\n const newDefaultValue = qualifierDefaultValues[qualifier.name];\n\n // Create a copy of the qualifier\n const updatedQualifier = { ...qualifier };\n\n if (newDefaultValue === null) {\n // Remove the default value\n delete updatedQualifier.defaultValue;\n } else {\n // Set the new default value\n updatedQualifier.defaultValue = newDefaultValue;\n }\n\n return updatedQualifier;\n }\n return qualifier;\n });\n\n return succeed(updatedConfig);\n });\n}\n\n/**\n * A system configuration for both runtime or build.\n * @public\n */\nexport class SystemConfiguration {\n /**\n * The name of this system configuration.\n */\n public get name(): string | undefined {\n return this._config.name;\n }\n\n /**\n * The description of this system configuration.\n */\n public get description(): string | undefined {\n return this._config.description;\n }\n\n /**\n * The {@link QualifierTypes.QualifierTypeCollector | qualifier types} that this system configuration uses.\n */\n public readonly qualifierTypes: ReadOnlyQualifierTypeCollector;\n\n /**\n * The {@link QualifierTypes.QualifierTypeCollector | qualifier types} that this system configuration uses.\n * @public\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * The {@link ResourceTypes.ResourceTypeCollector | resource types} that this system configuration uses.\n */\n public readonly resourceTypes: ReadOnlyResourceTypeCollector;\n\n private readonly _config: ISystemConfiguration;\n\n /**\n * Constructs a new instance of a {@link Config.SystemConfiguration | SystemConfiguration} from the\n * supplied {@link Config.Model.ISystemConfiguration | system configuration}.\n * @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.\n * @public\n */\n protected constructor(config: ISystemConfiguration, initParams?: ISystemConfigurationInitParams) {\n this._config = config;\n const qualifierTypeFactory = initParams?.qualifierTypeFactory ?? new BuiltInQualifierTypeFactory();\n const resourceTypeFactory = initParams?.resourceTypeFactory ?? new BuiltInResourceTypeFactory();\n\n this.qualifierTypes = QualifierTypeCollector.create({\n qualifierTypes: mapResults(config.qualifierTypes.map((tc) => qualifierTypeFactory.create(tc))).orThrow()\n }).orThrow();\n\n this.qualifiers = QualifierCollector.create({\n qualifierTypes: this.qualifierTypes,\n qualifiers: config.qualifiers\n }).orThrow();\n\n this.resourceTypes = ResourceTypeCollector.create({\n resourceTypes: mapResults(config.resourceTypes.map((rt) => resourceTypeFactory.create(rt))).orThrow()\n }).orThrow();\n }\n\n /**\n * Creates a new {@link Config.SystemConfiguration | SystemConfiguration} from the supplied\n * {@link Config.Model.ISystemConfiguration | system configuration}.\n * @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.\n * @param initParams - Optional {@link Config.ISystemConfigurationInitParams | initialization parameters}.\n * @returns `Success` with the new {@link Config.SystemConfiguration | SystemConfiguration}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\n public static create(\n config: ISystemConfiguration,\n initParams?: ISystemConfigurationInitParams\n ): Result<SystemConfiguration> {\n if (initParams?.qualifierDefaultValues) {\n /* c8 ignore next 9 - functional code tested but coverage intermittently missed */\n return updateSystemConfigurationQualifierDefaultValues(\n config,\n initParams.qualifierDefaultValues\n ).onSuccess((updatedConfig) =>\n captureResult(\n () => new SystemConfiguration(updatedConfig, omit(initParams, ['qualifierDefaultValues']))\n )\n );\n }\n return captureResult(() => new SystemConfiguration(config, initParams));\n }\n\n /**\n * Loads a {@link Config.SystemConfiguration | SystemConfiguration} from a file.\n * @param path - The path to the file to load.\n * @returns `Success` with the {@link Config.SystemConfiguration | SystemConfiguration}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\n public static loadFromFile(\n path: string,\n initParams?: ISystemConfigurationInitParams\n ): Result<SystemConfiguration> {\n return JsonFile.convertJsonFileSync(path, systemConfiguration).onSuccess((config) =>\n SystemConfiguration.create(config, initParams)\n );\n }\n\n /**\n * Returns the {@link Config.Model.ISystemConfiguration | system configuration} that this\n * {@link Config.SystemConfiguration | SystemConfiguration} was created from.\n * @returns `Success` with the {@link Config.Model.ISystemConfiguration | system configuration}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\n public getConfig(): Result<ISystemConfiguration> {\n return systemConfiguration.convert(this._config);\n }\n}\n"]}