@fgv/ts-res 5.0.0-11 → 5.0.0-12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ts-res.d.ts +116 -3
- package/lib/packlets/config/configInitFactory.d.ts +78 -0
- package/lib/packlets/config/configInitFactory.d.ts.map +1 -0
- package/lib/packlets/config/configInitFactory.js +147 -0
- package/lib/packlets/config/configInitFactory.js.map +1 -0
- package/lib/packlets/config/index.d.ts +1 -0
- package/lib/packlets/config/index.d.ts.map +1 -1
- package/lib/packlets/config/index.js +1 -0
- package/lib/packlets/config/index.js.map +1 -1
- package/lib/packlets/config/systemConfiguration.d.ts +16 -3
- package/lib/packlets/config/systemConfiguration.d.ts.map +1 -1
- package/lib/packlets/config/systemConfiguration.js +19 -40
- package/lib/packlets/config/systemConfiguration.js.map +1 -1
- package/lib/packlets/qualifier-types/config/json.d.ts +13 -0
- package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -1
- package/lib/packlets/qualifier-types/config/json.js +11 -0
- package/lib/packlets/qualifier-types/config/json.js.map +1 -1
- package/package.json +12 -12
package/dist/ts-res.d.ts
CHANGED
|
@@ -179,6 +179,24 @@ declare function buildQualifierDefaultValuesToken(parts: ReadonlyArray<IQualifie
|
|
|
179
179
|
*/
|
|
180
180
|
declare function buildQualifierDefaultValueToken({ qualifier, value }: IQualifierDefaultValueTokenParts): Result<QualifierDefaultValueToken>;
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* A factory that creates a {@link QualifierTypes.QualifierType | QualifierType} from a {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.
|
|
184
|
+
* @public
|
|
185
|
+
*/
|
|
186
|
+
declare class BuiltInQualifierTypeFactory implements IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType> {
|
|
187
|
+
/** {@inheritDoc Config.IConfigInitFactory.create} */
|
|
188
|
+
create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<QualifierType>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
declare class BuiltInResourceTypeFactory implements IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {
|
|
196
|
+
/** {@inheritDoc Config.IConfigInitFactory.create} */
|
|
197
|
+
create(config: ResourceTypes.Config.IResourceTypeConfig): Result<ResourceType>;
|
|
198
|
+
}
|
|
199
|
+
|
|
182
200
|
declare namespace Bundle {
|
|
183
201
|
export {
|
|
184
202
|
IBundleMetadata,
|
|
@@ -558,6 +576,25 @@ declare class CandidateReducer {
|
|
|
558
576
|
reduceCandidate(candidate: ResourceCandidate): Result<IReducedCandidate | undefined>;
|
|
559
577
|
}
|
|
560
578
|
|
|
579
|
+
/**
|
|
580
|
+
* A factory that chains multiple factories together.
|
|
581
|
+
* @public
|
|
582
|
+
*/
|
|
583
|
+
declare class ChainedConfigInitFactory<TConfig, T> implements IConfigInitFactory<TConfig, T> {
|
|
584
|
+
readonly factories: IConfigInitFactory<TConfig, T>[];
|
|
585
|
+
/**
|
|
586
|
+
* Constructor for a chained config init factory.
|
|
587
|
+
* @param factories - The factories to chain.
|
|
588
|
+
*/
|
|
589
|
+
constructor(factories: IConfigInitFactory<TConfig, T>[]);
|
|
590
|
+
/**
|
|
591
|
+
* Creates a new instance of a configuration object.
|
|
592
|
+
* @param config - The configuration object to create.
|
|
593
|
+
* @returns A result containing the new instance of the configuration object.
|
|
594
|
+
*/
|
|
595
|
+
create(config: TConfig): Result<T>;
|
|
596
|
+
}
|
|
597
|
+
|
|
561
598
|
/**
|
|
562
599
|
* `Converter` for a normalized {@link ResourceJson.Json.IChildConditionDecl | child condition declaration}.
|
|
563
600
|
* @public
|
|
@@ -1650,6 +1687,12 @@ declare namespace Config {
|
|
|
1650
1687
|
export {
|
|
1651
1688
|
Model,
|
|
1652
1689
|
Convert_9 as Convert,
|
|
1690
|
+
IConfigInitFactory,
|
|
1691
|
+
ChainedConfigInitFactory,
|
|
1692
|
+
BuiltInQualifierTypeFactory,
|
|
1693
|
+
QualifierTypeFactory,
|
|
1694
|
+
BuiltInResourceTypeFactory,
|
|
1695
|
+
ResourceTypeFactory,
|
|
1653
1696
|
updateSystemConfigurationQualifierDefaultValues,
|
|
1654
1697
|
ISystemConfigurationInitParams,
|
|
1655
1698
|
SystemConfiguration,
|
|
@@ -1666,6 +1709,7 @@ export { Config }
|
|
|
1666
1709
|
declare namespace Config_2 {
|
|
1667
1710
|
export {
|
|
1668
1711
|
Convert_2 as Convert,
|
|
1712
|
+
isSystemQualifierTypeConfig,
|
|
1669
1713
|
IQualifierTypeConfig,
|
|
1670
1714
|
ILanguageQualifierTypeConfig,
|
|
1671
1715
|
ITerritoryQualifierTypeConfig,
|
|
@@ -1673,7 +1717,8 @@ declare namespace Config_2 {
|
|
|
1673
1717
|
ISystemLanguageQualifierTypeConfig,
|
|
1674
1718
|
ISystemTerritoryQualifierTypeConfig,
|
|
1675
1719
|
ISystemLiteralQualifierTypeConfig,
|
|
1676
|
-
ISystemQualifierTypeConfig
|
|
1720
|
+
ISystemQualifierTypeConfig,
|
|
1721
|
+
IAnyQualifierTypeConfig
|
|
1677
1722
|
}
|
|
1678
1723
|
}
|
|
1679
1724
|
|
|
@@ -2577,6 +2622,12 @@ declare interface IAbstractDecisionCreateParams {
|
|
|
2577
2622
|
index?: number;
|
|
2578
2623
|
}
|
|
2579
2624
|
|
|
2625
|
+
/**
|
|
2626
|
+
* A union of all qualifier type configurations.
|
|
2627
|
+
* @public
|
|
2628
|
+
*/
|
|
2629
|
+
declare type IAnyQualifierTypeConfig = IQualifierTypeConfig | ISystemQualifierTypeConfig;
|
|
2630
|
+
|
|
2580
2631
|
/**
|
|
2581
2632
|
* A complete resource bundle that encapsulates built resources, configuration, and metadata.
|
|
2582
2633
|
* Bundles provide a portable, integrity-verified way to distribute pre-compiled resource collections.
|
|
@@ -3264,6 +3315,19 @@ declare interface IConditionTokenParts {
|
|
|
3264
3315
|
value: string;
|
|
3265
3316
|
}
|
|
3266
3317
|
|
|
3318
|
+
/**
|
|
3319
|
+
* Interface for a factory that creates a new instance of a configuration object.
|
|
3320
|
+
* @public
|
|
3321
|
+
*/
|
|
3322
|
+
declare interface IConfigInitFactory<TConfig, T> {
|
|
3323
|
+
/**
|
|
3324
|
+
* Creates a new instance of a configuration object.
|
|
3325
|
+
* @param config - The configuration object to create.
|
|
3326
|
+
* @returns A result containing the new instance of the configuration object.
|
|
3327
|
+
*/
|
|
3328
|
+
create(config: TConfig): Result<T>;
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3267
3331
|
/**
|
|
3268
3332
|
* Declared context for a resource container.
|
|
3269
3333
|
* @public
|
|
@@ -4992,6 +5056,15 @@ declare function isResourceTreeLeafInit<T>(init: ResourceTreeNodeInit<T>): init
|
|
|
4992
5056
|
*/
|
|
4993
5057
|
declare function isResourceTreeRootOrNodeInit<T>(init: ResourceTreeNodeInit<T> | IResourceTreeRootInit<T>): init is IResourceTreeBranchInit<T>;
|
|
4994
5058
|
|
|
5059
|
+
/**
|
|
5060
|
+
* Checks if a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} is a
|
|
5061
|
+
* {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.
|
|
5062
|
+
* @param config - The {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} to check.
|
|
5063
|
+
* @returns `true` if the configuration is a system qualifier type configuration, `false` otherwise.
|
|
5064
|
+
* @public
|
|
5065
|
+
*/
|
|
5066
|
+
declare function isSystemQualifierTypeConfig(config: IAnyQualifierTypeConfig): config is ISystemQualifierTypeConfig;
|
|
5067
|
+
|
|
4995
5068
|
/**
|
|
4996
5069
|
* Determines whether a number is a valid condition index.
|
|
4997
5070
|
* @param index - the number to validate
|
|
@@ -5238,6 +5311,8 @@ declare interface ISystemConfigurationInitParams {
|
|
|
5238
5311
|
* Use `null` as the value to remove an existing default value.
|
|
5239
5312
|
*/
|
|
5240
5313
|
qualifierDefaultValues?: Record<string, string | null>;
|
|
5314
|
+
qualifierTypeFactory?: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType>;
|
|
5315
|
+
resourceTypeFactory?: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>;
|
|
5241
5316
|
}
|
|
5242
5317
|
|
|
5243
5318
|
/**
|
|
@@ -5972,6 +6047,7 @@ declare namespace Model {
|
|
|
5972
6047
|
|
|
5973
6048
|
declare namespace Model_2 {
|
|
5974
6049
|
export {
|
|
6050
|
+
isSystemQualifierTypeConfig,
|
|
5975
6051
|
IQualifierTypeConfig,
|
|
5976
6052
|
ILanguageQualifierTypeConfig,
|
|
5977
6053
|
ITerritoryQualifierTypeConfig,
|
|
@@ -5979,7 +6055,8 @@ declare namespace Model_2 {
|
|
|
5979
6055
|
ISystemLanguageQualifierTypeConfig,
|
|
5980
6056
|
ISystemTerritoryQualifierTypeConfig,
|
|
5981
6057
|
ISystemLiteralQualifierTypeConfig,
|
|
5982
|
-
ISystemQualifierTypeConfig
|
|
6058
|
+
ISystemQualifierTypeConfig,
|
|
6059
|
+
IAnyQualifierTypeConfig
|
|
5983
6060
|
}
|
|
5984
6061
|
}
|
|
5985
6062
|
|
|
@@ -6672,6 +6749,20 @@ declare class QualifierTypeCollector extends ValidatingConvertingCollector<Quali
|
|
|
6672
6749
|
protected static _toQualifierType(from: unknown): Result<QualifierType>;
|
|
6673
6750
|
}
|
|
6674
6751
|
|
|
6752
|
+
/**
|
|
6753
|
+
* A factory that creates a {@link QualifierTypes.QualifierType | QualifierType} from a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | system qualifier type configuration}
|
|
6754
|
+
* by chaining a supplied factory with a {@link Config.BuiltInQualifierTypeFactory | built-in factory} that handles built-in qualifier types.
|
|
6755
|
+
* @public
|
|
6756
|
+
*/
|
|
6757
|
+
declare class QualifierTypeFactory extends ChainedConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType> {
|
|
6758
|
+
/**
|
|
6759
|
+
* Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.
|
|
6760
|
+
* @param factories - The {@link Config.IConfigInitFactory | factories} to chain.
|
|
6761
|
+
* @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always added to the end of the chain.
|
|
6762
|
+
*/
|
|
6763
|
+
constructor(factories: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType>[]);
|
|
6764
|
+
}
|
|
6765
|
+
|
|
6675
6766
|
/**
|
|
6676
6767
|
* Branded number representing a validated qualifier type index.
|
|
6677
6768
|
* @public
|
|
@@ -8155,6 +8246,20 @@ declare class ResourceTypeCollector extends ValidatingCollector<ResourceType> {
|
|
|
8155
8246
|
*/
|
|
8156
8247
|
declare const resourceTypeConfig: ObjectConverter<IResourceTypeConfig, unknown>;
|
|
8157
8248
|
|
|
8249
|
+
/**
|
|
8250
|
+
* A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}
|
|
8251
|
+
* by chaining a supplied factory with a {@link Config.BuiltInResourceTypeFactory | built-in factory} that handles built-in resource types.
|
|
8252
|
+
* @public
|
|
8253
|
+
*/
|
|
8254
|
+
declare class ResourceTypeFactory extends ChainedConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {
|
|
8255
|
+
/**
|
|
8256
|
+
* Constructor for a resource type factory.
|
|
8257
|
+
* @param factories - The {@link Config.IConfigInitFactory | factories} to chain.
|
|
8258
|
+
* @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.
|
|
8259
|
+
*/
|
|
8260
|
+
constructor(factories: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>[]);
|
|
8261
|
+
}
|
|
8262
|
+
|
|
8158
8263
|
/**
|
|
8159
8264
|
* Branded number representing a validated resource type index.
|
|
8160
8265
|
* @public
|
|
@@ -8382,7 +8487,7 @@ declare class SystemConfiguration {
|
|
|
8382
8487
|
* @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.
|
|
8383
8488
|
* @public
|
|
8384
8489
|
*/
|
|
8385
|
-
protected constructor(config: ISystemConfiguration);
|
|
8490
|
+
protected constructor(config: ISystemConfiguration, initParams?: ISystemConfigurationInitParams);
|
|
8386
8491
|
/**
|
|
8387
8492
|
* Creates a new {@link Config.SystemConfiguration | SystemConfiguration} from the supplied
|
|
8388
8493
|
* {@link Config.Model.ISystemConfiguration | system configuration}.
|
|
@@ -8393,6 +8498,14 @@ declare class SystemConfiguration {
|
|
|
8393
8498
|
* @public
|
|
8394
8499
|
*/
|
|
8395
8500
|
static create(config: ISystemConfiguration, initParams?: ISystemConfigurationInitParams): Result<SystemConfiguration>;
|
|
8501
|
+
/**
|
|
8502
|
+
* Loads a {@link Config.SystemConfiguration | SystemConfiguration} from a file.
|
|
8503
|
+
* @param path - The path to the file to load.
|
|
8504
|
+
* @returns `Success` with the {@link Config.SystemConfiguration | SystemConfiguration}
|
|
8505
|
+
* if successful, `Failure` with an error message otherwise.
|
|
8506
|
+
* @public
|
|
8507
|
+
*/
|
|
8508
|
+
static loadFromFile(path: string, initParams?: ISystemConfigurationInitParams): Result<SystemConfiguration>;
|
|
8396
8509
|
/**
|
|
8397
8510
|
* Returns the {@link Config.Model.ISystemConfiguration | system configuration} that this
|
|
8398
8511
|
* {@link Config.SystemConfiguration | SystemConfiguration} was created from.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import { QualifierType } from '../qualifier-types';
|
|
3
|
+
import * as QualifierTypes from '../qualifier-types';
|
|
4
|
+
import * as ResourceTypes from '../resource-types';
|
|
5
|
+
import { ResourceType } from '../resource-types';
|
|
6
|
+
/**
|
|
7
|
+
* Interface for a factory that creates a new instance of a configuration object.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface IConfigInitFactory<TConfig, T> {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new instance of a configuration object.
|
|
13
|
+
* @param config - The configuration object to create.
|
|
14
|
+
* @returns A result containing the new instance of the configuration object.
|
|
15
|
+
*/
|
|
16
|
+
create(config: TConfig): Result<T>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A factory that chains multiple factories together.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare class ChainedConfigInitFactory<TConfig, T> implements IConfigInitFactory<TConfig, T> {
|
|
23
|
+
readonly factories: IConfigInitFactory<TConfig, T>[];
|
|
24
|
+
/**
|
|
25
|
+
* Constructor for a chained config init factory.
|
|
26
|
+
* @param factories - The factories to chain.
|
|
27
|
+
*/
|
|
28
|
+
constructor(factories: IConfigInitFactory<TConfig, T>[]);
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new instance of a configuration object.
|
|
31
|
+
* @param config - The configuration object to create.
|
|
32
|
+
* @returns A result containing the new instance of the configuration object.
|
|
33
|
+
*/
|
|
34
|
+
create(config: TConfig): Result<T>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A factory that creates a {@link QualifierTypes.QualifierType | QualifierType} from a {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare class BuiltInQualifierTypeFactory implements IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType> {
|
|
41
|
+
/** {@inheritDoc Config.IConfigInitFactory.create} */
|
|
42
|
+
create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<QualifierType>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A factory that creates a {@link QualifierTypes.QualifierType | QualifierType} from a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | system qualifier type configuration}
|
|
46
|
+
* by chaining a supplied factory with a {@link Config.BuiltInQualifierTypeFactory | built-in factory} that handles built-in qualifier types.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare class QualifierTypeFactory extends ChainedConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType> {
|
|
50
|
+
/**
|
|
51
|
+
* Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.
|
|
52
|
+
* @param factories - The {@link Config.IConfigInitFactory | factories} to chain.
|
|
53
|
+
* @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always added to the end of the chain.
|
|
54
|
+
*/
|
|
55
|
+
constructor(factories: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType>[]);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export declare class BuiltInResourceTypeFactory implements IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {
|
|
62
|
+
/** {@inheritDoc Config.IConfigInitFactory.create} */
|
|
63
|
+
create(config: ResourceTypes.Config.IResourceTypeConfig): Result<ResourceType>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}
|
|
67
|
+
* by chaining a supplied factory with a {@link Config.BuiltInResourceTypeFactory | built-in factory} that handles built-in resource types.
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export declare class ResourceTypeFactory extends ChainedConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {
|
|
71
|
+
/**
|
|
72
|
+
* Constructor for a resource type factory.
|
|
73
|
+
* @param factories - The {@link Config.IConfigInitFactory | factories} to chain.
|
|
74
|
+
* @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.
|
|
75
|
+
*/
|
|
76
|
+
constructor(factories: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>[]);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=configInitFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configInitFactory.d.ts","sourceRoot":"","sources":["../../../src/packlets/config/configInitFactory.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAQ,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,EAAE,CAAC;IAC5C;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,qBAAa,wBAAwB,CAAC,OAAO,EAAE,CAAC,CAAE,YAAW,kBAAkB,CAAC,OAAO,EAAE,CAAC,CAAC;IACzF,SAAgB,SAAS,EAAE,kBAAkB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC;IAE5D;;;OAGG;gBACgB,SAAS,EAAE,kBAAkB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE;IAI9D;;;;OAIG;IACI,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;CAS1C;AAED;;;GAGG;AACH,qBAAa,2BACX,YAAW,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,uBAAuB,EAAE,aAAa,CAAC;IAE3F,qDAAqD;IAC9C,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,uBAAuB,GAAG,MAAM,CAAC,aAAa,CAAC;CAM5F;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,wBAAwB,CAChE,cAAc,CAAC,MAAM,CAAC,uBAAuB,EAC7C,aAAa,CACd;IACC;;;;OAIG;gBAED,SAAS,EAAE,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,uBAAuB,EAAE,aAAa,CAAC,EAAE;CAIhG;AAED;;;GAGG;AACH,qBAAa,0BACX,YAAW,kBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC,mBAAmB,EAAE,YAAY,CAAC;IAErF,qDAAqD;IAC9C,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,mBAAmB,GAAG,MAAM,CAAC,YAAY,CAAC;CAGtF;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,wBAAwB,CAC/D,aAAa,CAAC,MAAM,CAAC,mBAAmB,EACxC,YAAY,CACb;IACC;;;;OAIG;gBAED,SAAS,EAAE,kBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC,mBAAmB,EAAE,YAAY,CAAC,EAAE;CAK1F"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.ResourceTypeFactory = exports.BuiltInResourceTypeFactory = exports.QualifierTypeFactory = exports.BuiltInQualifierTypeFactory = exports.ChainedConfigInitFactory = void 0;
|
|
58
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
59
|
+
const QualifierTypes = __importStar(require("../qualifier-types"));
|
|
60
|
+
const ResourceTypes = __importStar(require("../resource-types"));
|
|
61
|
+
/**
|
|
62
|
+
* A factory that chains multiple factories together.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
class ChainedConfigInitFactory {
|
|
66
|
+
/**
|
|
67
|
+
* Constructor for a chained config init factory.
|
|
68
|
+
* @param factories - The factories to chain.
|
|
69
|
+
*/
|
|
70
|
+
constructor(factories) {
|
|
71
|
+
this.factories = factories;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Creates a new instance of a configuration object.
|
|
75
|
+
* @param config - The configuration object to create.
|
|
76
|
+
* @returns A result containing the new instance of the configuration object.
|
|
77
|
+
*/
|
|
78
|
+
create(config) {
|
|
79
|
+
for (const factory of this.factories) {
|
|
80
|
+
const result = factory.create(config);
|
|
81
|
+
if (result.isSuccess()) {
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return (0, ts_utils_1.fail)('No factory was able to create the configuration object');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.ChainedConfigInitFactory = ChainedConfigInitFactory;
|
|
89
|
+
/**
|
|
90
|
+
* A factory that creates a {@link QualifierTypes.QualifierType | QualifierType} from a {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
class BuiltInQualifierTypeFactory {
|
|
94
|
+
/** {@inheritDoc Config.IConfigInitFactory.create} */
|
|
95
|
+
create(config) {
|
|
96
|
+
if (QualifierTypes.Config.isSystemQualifierTypeConfig(config)) {
|
|
97
|
+
return QualifierTypes.createQualifierTypeFromSystemConfig(config);
|
|
98
|
+
}
|
|
99
|
+
return (0, ts_utils_1.fail)(`${config.name}: unknown built-in qualifier type (${config.systemType})`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.BuiltInQualifierTypeFactory = BuiltInQualifierTypeFactory;
|
|
103
|
+
/**
|
|
104
|
+
* A factory that creates a {@link QualifierTypes.QualifierType | QualifierType} from a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | system qualifier type configuration}
|
|
105
|
+
* by chaining a supplied factory with a {@link Config.BuiltInQualifierTypeFactory | built-in factory} that handles built-in qualifier types.
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
class QualifierTypeFactory extends ChainedConfigInitFactory {
|
|
109
|
+
/**
|
|
110
|
+
* Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.
|
|
111
|
+
* @param factories - The {@link Config.IConfigInitFactory | factories} to chain.
|
|
112
|
+
* @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always added to the end of the chain.
|
|
113
|
+
*/
|
|
114
|
+
constructor(factories) {
|
|
115
|
+
super([...factories, new BuiltInQualifierTypeFactory()]);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.QualifierTypeFactory = QualifierTypeFactory;
|
|
119
|
+
/**
|
|
120
|
+
* A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
class BuiltInResourceTypeFactory {
|
|
124
|
+
/** {@inheritDoc Config.IConfigInitFactory.create} */
|
|
125
|
+
create(config) {
|
|
126
|
+
return ResourceTypes.createResourceTypeFromConfig(config);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.BuiltInResourceTypeFactory = BuiltInResourceTypeFactory;
|
|
130
|
+
/**
|
|
131
|
+
* A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}
|
|
132
|
+
* by chaining a supplied factory with a {@link Config.BuiltInResourceTypeFactory | built-in factory} that handles built-in resource types.
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
class ResourceTypeFactory extends ChainedConfigInitFactory {
|
|
136
|
+
/**
|
|
137
|
+
* Constructor for a resource type factory.
|
|
138
|
+
* @param factories - The {@link Config.IConfigInitFactory | factories} to chain.
|
|
139
|
+
* @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.
|
|
140
|
+
*/
|
|
141
|
+
constructor(factories) {
|
|
142
|
+
factories = factories !== null && factories !== void 0 ? factories : [];
|
|
143
|
+
super([...factories, new BuiltInResourceTypeFactory()]);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.ResourceTypeFactory = ResourceTypeFactory;
|
|
147
|
+
//# sourceMappingURL=configInitFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configInitFactory.js","sourceRoot":"","sources":["../../../src/packlets/config/configInitFactory.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAA6C;AAE7C,mEAAqD;AACrD,iEAAmD;AAenD;;;GAGG;AACH,MAAa,wBAAwB;IAGnC;;;OAGG;IACH,YAAmB,SAA2C;QAC5D,IAAI,CAAC,SAAS,GAAG,SAAS,CA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AAC,GAAG,SAAS,EAAE,IAAI,0BAA0B,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;CACF;AAfD,kDAeC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, fail } from '@fgv/ts-utils';\nimport { QualifierType } from '../qualifier-types';\nimport * as QualifierTypes from '../qualifier-types';\nimport * as ResourceTypes from '../resource-types';\nimport { ResourceType } from '../resource-types';\n/**\n * Interface for a factory that creates a new instance of a configuration object.\n * @public\n */\nexport interface IConfigInitFactory<TConfig, T> {\n /**\n * Creates a new instance of a configuration object.\n * @param config - The configuration object to create.\n * @returns A result containing the new instance of the configuration object.\n */\n create(config: TConfig): Result<T>;\n}\n\n/**\n * A factory that chains multiple factories together.\n * @public\n */\nexport class ChainedConfigInitFactory<TConfig, T> implements IConfigInitFactory<TConfig, T> {\n public readonly factories: IConfigInitFactory<TConfig, T>[];\n\n /**\n * Constructor for a chained config init factory.\n * @param factories - The factories to chain.\n */\n public constructor(factories: IConfigInitFactory<TConfig, T>[]) {\n this.factories = factories;\n }\n\n /**\n * Creates a new instance of a configuration object.\n * @param config - The configuration object to create.\n * @returns A result containing the new instance of the configuration object.\n */\n public create(config: TConfig): Result<T> {\n for (const factory of this.factories) {\n const result = factory.create(config);\n if (result.isSuccess()) {\n return result;\n }\n }\n return fail('No factory was able to create the configuration object');\n }\n}\n\n/**\n * A factory that creates a {@link QualifierTypes.QualifierType | QualifierType} from a {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.\n * @public\n */\nexport class BuiltInQualifierTypeFactory\n implements IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType>\n{\n /** {@inheritDoc Config.IConfigInitFactory.create} */\n public create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<QualifierType> {\n if (QualifierTypes.Config.isSystemQualifierTypeConfig(config)) {\n return QualifierTypes.createQualifierTypeFromSystemConfig(config);\n }\n return fail(`${config.name}: unknown built-in qualifier type (${config.systemType})`);\n }\n}\n\n/**\n * A factory that creates a {@link QualifierTypes.QualifierType | QualifierType} from a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | system qualifier type configuration}\n * by chaining a supplied factory with a {@link Config.BuiltInQualifierTypeFactory | built-in factory} that handles built-in qualifier types.\n * @public\n */\nexport class QualifierTypeFactory extends ChainedConfigInitFactory<\n QualifierTypes.Config.IAnyQualifierTypeConfig,\n QualifierType\n> {\n /**\n * Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.\n * @param factories - The {@link Config.IConfigInitFactory | factories} to chain.\n * @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always added to the end of the chain.\n */\n public constructor(\n factories: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType>[]\n ) {\n super([...factories, new BuiltInQualifierTypeFactory()]);\n }\n}\n\n/**\n * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.\n * @public\n */\nexport class BuiltInResourceTypeFactory\n implements IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>\n{\n /** {@inheritDoc Config.IConfigInitFactory.create} */\n public create(config: ResourceTypes.Config.IResourceTypeConfig): Result<ResourceType> {\n return ResourceTypes.createResourceTypeFromConfig(config);\n }\n}\n\n/**\n * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}\n * by chaining a supplied factory with a {@link Config.BuiltInResourceTypeFactory | built-in factory} that handles built-in resource types.\n * @public\n */\nexport class ResourceTypeFactory extends ChainedConfigInitFactory<\n ResourceTypes.Config.IResourceTypeConfig,\n ResourceType\n> {\n /**\n * Constructor for a resource type factory.\n * @param factories - The {@link Config.IConfigInitFactory | factories} to chain.\n * @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.\n */\n public constructor(\n factories: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>[]\n ) {\n factories = factories ?? [];\n super([...factories, new BuiltInResourceTypeFactory()]);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/config/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,KAAK,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/config/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,KAAK,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -62,6 +62,7 @@ const Model = __importStar(require("./json"));
|
|
|
62
62
|
exports.Model = Model;
|
|
63
63
|
const Convert = __importStar(require("./convert"));
|
|
64
64
|
exports.Convert = Convert;
|
|
65
|
+
__exportStar(require("./configInitFactory"), exports);
|
|
65
66
|
__exportStar(require("./systemConfiguration"), exports);
|
|
66
67
|
__exportStar(require("./common"), exports);
|
|
67
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/config/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8CAAgC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/config/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8CAAgC;AAOvB,sBAAK;AANd,mDAAqC;AAMrB,0BAAO;AAJvB,sDAAoC;AACpC,wDAAsC;AACtC,2CAAyB","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 Model from './json';\nimport * as Convert from './convert';\n\nexport * from './configInitFactory';\nexport * from './systemConfiguration';\nexport * from './common';\n\nexport { Model, Convert };\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Result } from '@fgv/ts-utils';
|
|
2
|
-
import
|
|
2
|
+
import * as QualifierTypes from '../qualifier-types';
|
|
3
|
+
import * as ResourceTypes from '../resource-types';
|
|
4
|
+
import { QualifierType, ReadOnlyQualifierTypeCollector } from '../qualifier-types';
|
|
3
5
|
import { IReadOnlyQualifierCollector } from '../qualifiers';
|
|
4
|
-
import { ReadOnlyResourceTypeCollector } from '../resource-types';
|
|
6
|
+
import { ReadOnlyResourceTypeCollector, ResourceType } from '../resource-types';
|
|
5
7
|
import { ISystemConfiguration } from './json';
|
|
8
|
+
import { IConfigInitFactory } from './configInitFactory';
|
|
6
9
|
/**
|
|
7
10
|
* Parameters used to initialize a {@link Config.SystemConfiguration | SystemConfiguration}.
|
|
8
11
|
* @public
|
|
@@ -14,6 +17,8 @@ export interface ISystemConfigurationInitParams {
|
|
|
14
17
|
* Use `null` as the value to remove an existing default value.
|
|
15
18
|
*/
|
|
16
19
|
qualifierDefaultValues?: Record<string, string | null>;
|
|
20
|
+
qualifierTypeFactory?: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType>;
|
|
21
|
+
resourceTypeFactory?: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>;
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
24
|
* Creates a copy of the provided {@link Config.Model.ISystemConfiguration | system configuration}
|
|
@@ -58,7 +63,7 @@ export declare class SystemConfiguration {
|
|
|
58
63
|
* @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.
|
|
59
64
|
* @public
|
|
60
65
|
*/
|
|
61
|
-
protected constructor(config: ISystemConfiguration);
|
|
66
|
+
protected constructor(config: ISystemConfiguration, initParams?: ISystemConfigurationInitParams);
|
|
62
67
|
/**
|
|
63
68
|
* Creates a new {@link Config.SystemConfiguration | SystemConfiguration} from the supplied
|
|
64
69
|
* {@link Config.Model.ISystemConfiguration | system configuration}.
|
|
@@ -69,6 +74,14 @@ export declare class SystemConfiguration {
|
|
|
69
74
|
* @public
|
|
70
75
|
*/
|
|
71
76
|
static create(config: ISystemConfiguration, initParams?: ISystemConfigurationInitParams): Result<SystemConfiguration>;
|
|
77
|
+
/**
|
|
78
|
+
* Loads a {@link Config.SystemConfiguration | SystemConfiguration} from a file.
|
|
79
|
+
* @param path - The path to the file to load.
|
|
80
|
+
* @returns `Success` with the {@link Config.SystemConfiguration | SystemConfiguration}
|
|
81
|
+
* if successful, `Failure` with an error message otherwise.
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
static loadFromFile(path: string, initParams?: ISystemConfigurationInitParams): Result<SystemConfiguration>;
|
|
72
85
|
/**
|
|
73
86
|
* Returns the {@link Config.Model.ISystemConfiguration | system configuration} that this
|
|
74
87
|
* {@link Config.SystemConfiguration | SystemConfiguration} was created from.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemConfiguration.d.ts","sourceRoot":"","sources":["../../../src/packlets/config/systemConfiguration.ts"],"names":[],"mappings":"AAsBA,OAAO,EAA6B,MAAM,
|
|
1
|
+
{"version":3,"file":"systemConfiguration.d.ts","sourceRoot":"","sources":["../../../src/packlets/config/systemConfiguration.ts"],"names":[],"mappings":"AAsBA,OAAO,EAA6B,MAAM,EAAuB,MAAM,eAAe,CAAC;AACvF,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AACrD,O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,aAAa,MAAM,EAAE,oBAAoB,EAAE,UAAU,CAAC,EAAE,8BAA8B;IAmB/F;;;;;;;;OAQG;WACW,MAAM,CAClB,MAAM,EAAE,oBAAoB,EAC5B,UAAU,CAAC,EAAE,8BAA8B,GAC1C,MAAM,CAAC,mBAAmB,CAAC;IAc9B;;;;;;OAMG;WACW,YAAY,CACxB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,8BAA8B,GAC1C,MAAM,CAAC,mBAAmB,CAAC;IAM9B;;;;;;OAMG;IACI,SAAS,IAAI,MAAM,CAAC,oBAAoB,CAAC;CAGjD"}
|
|
@@ -20,50 +20,16 @@
|
|
|
20
20
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
* SOFTWARE.
|
|
22
22
|
*/
|
|
23
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
-
if (k2 === undefined) k2 = k;
|
|
25
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
-
}
|
|
29
|
-
Object.defineProperty(o, k2, desc);
|
|
30
|
-
}) : (function(o, m, k, k2) {
|
|
31
|
-
if (k2 === undefined) k2 = k;
|
|
32
|
-
o[k2] = m[k];
|
|
33
|
-
}));
|
|
34
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
-
}) : function(o, v) {
|
|
37
|
-
o["default"] = v;
|
|
38
|
-
});
|
|
39
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
-
var ownKeys = function(o) {
|
|
41
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
-
var ar = [];
|
|
43
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
-
return ar;
|
|
45
|
-
};
|
|
46
|
-
return ownKeys(o);
|
|
47
|
-
};
|
|
48
|
-
return function (mod) {
|
|
49
|
-
if (mod && mod.__esModule) return mod;
|
|
50
|
-
var result = {};
|
|
51
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
-
__setModuleDefault(result, mod);
|
|
53
|
-
return result;
|
|
54
|
-
};
|
|
55
|
-
})();
|
|
56
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
24
|
exports.SystemConfiguration = void 0;
|
|
58
25
|
exports.updateSystemConfigurationQualifierDefaultValues = updateSystemConfigurationQualifierDefaultValues;
|
|
59
26
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
60
|
-
const QualifierTypes = __importStar(require("../qualifier-types"));
|
|
61
|
-
const ResourceTypes = __importStar(require("../resource-types"));
|
|
62
27
|
const qualifier_types_1 = require("../qualifier-types");
|
|
63
28
|
const qualifiers_1 = require("../qualifiers");
|
|
64
29
|
const resource_types_1 = require("../resource-types");
|
|
65
30
|
const convert_1 = require("./convert");
|
|
66
31
|
const ts_json_base_1 = require("@fgv/ts-json-base");
|
|
32
|
+
const configInitFactory_1 = require("./configInitFactory");
|
|
67
33
|
/**
|
|
68
34
|
* Creates a copy of the provided {@link Config.Model.ISystemConfiguration | system configuration}
|
|
69
35
|
* with updated qualifier default values.
|
|
@@ -129,17 +95,20 @@ class SystemConfiguration {
|
|
|
129
95
|
* @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.
|
|
130
96
|
* @public
|
|
131
97
|
*/
|
|
132
|
-
constructor(config) {
|
|
98
|
+
constructor(config, initParams) {
|
|
99
|
+
var _a, _b;
|
|
133
100
|
this._config = config;
|
|
101
|
+
const qualifierTypeFactory = (_a = initParams === null || initParams === void 0 ? void 0 : initParams.qualifierTypeFactory) !== null && _a !== void 0 ? _a : new configInitFactory_1.BuiltInQualifierTypeFactory();
|
|
102
|
+
const resourceTypeFactory = (_b = initParams === null || initParams === void 0 ? void 0 : initParams.resourceTypeFactory) !== null && _b !== void 0 ? _b : new configInitFactory_1.BuiltInResourceTypeFactory();
|
|
134
103
|
this.qualifierTypes = qualifier_types_1.QualifierTypeCollector.create({
|
|
135
|
-
qualifierTypes: (0, ts_utils_1.mapResults)(config.qualifierTypes.map(
|
|
104
|
+
qualifierTypes: (0, ts_utils_1.mapResults)(config.qualifierTypes.map((tc) => qualifierTypeFactory.create(tc))).orThrow()
|
|
136
105
|
}).orThrow();
|
|
137
106
|
this.qualifiers = qualifiers_1.QualifierCollector.create({
|
|
138
107
|
qualifierTypes: this.qualifierTypes,
|
|
139
108
|
qualifiers: config.qualifiers
|
|
140
109
|
}).orThrow();
|
|
141
110
|
this.resourceTypes = resource_types_1.ResourceTypeCollector.create({
|
|
142
|
-
resourceTypes: (0, ts_utils_1.mapResults)(config.resourceTypes.map(
|
|
111
|
+
resourceTypes: (0, ts_utils_1.mapResults)(config.resourceTypes.map((rt) => resourceTypeFactory.create(rt))).orThrow()
|
|
143
112
|
}).orThrow();
|
|
144
113
|
}
|
|
145
114
|
/**
|
|
@@ -153,9 +122,19 @@ class SystemConfiguration {
|
|
|
153
122
|
*/
|
|
154
123
|
static create(config, initParams) {
|
|
155
124
|
if (initParams === null || initParams === void 0 ? void 0 : initParams.qualifierDefaultValues) {
|
|
156
|
-
return updateSystemConfigurationQualifierDefaultValues(config, initParams.qualifierDefaultValues).onSuccess((updatedConfig) => (0, ts_utils_1.captureResult)(() => new SystemConfiguration(updatedConfig)));
|
|
125
|
+
return updateSystemConfigurationQualifierDefaultValues(config, initParams.qualifierDefaultValues).onSuccess((updatedConfig) => (0, ts_utils_1.captureResult)(() => new SystemConfiguration(updatedConfig, (0, ts_utils_1.omit)(initParams, ['qualifierDefaultValues']))));
|
|
157
126
|
}
|
|
158
|
-
return (0, ts_utils_1.captureResult)(() => new SystemConfiguration(config));
|
|
127
|
+
return (0, ts_utils_1.captureResult)(() => new SystemConfiguration(config, initParams));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Loads a {@link Config.SystemConfiguration | SystemConfiguration} from a file.
|
|
131
|
+
* @param path - The path to the file to load.
|
|
132
|
+
* @returns `Success` with the {@link Config.SystemConfiguration | SystemConfiguration}
|
|
133
|
+
* if successful, `Failure` with an error message otherwise.
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
136
|
+
static loadFromFile(path, initParams) {
|
|
137
|
+
return ts_json_base_1.JsonFile.convertJsonFileSync(path, convert_1.systemConfiguration).onSuccess((config) => SystemConfiguration.create(config, initParams));
|
|
159
138
|
}
|
|
160
139
|
/**
|
|
161
140
|
* Returns the {@link Config.Model.ISystemConfiguration | system configuration} that this
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemConfiguration.js","sourceRoot":"","sources":["../../../src/packlets/config/systemConfiguration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH,0GAuCC;AAvED,4CAAiF;AACjF,mEAAqD;AACrD,iEAAmD;AACnD,wDAA4F;AAC5F,8CAAgF;AAChF,sDAAyF;AAEzF,uCAAgD;AAChD,oDAAuD;AAevD;;;;;;;;GAQG;AACH,SAAgB,+CAA+C,CAC7D,MAA4B,EAC5B,sBAAqD,CAAC,6CAA6C;;IAEnG,8BAA8B;IAC9B,OAAO,IAAA,iCAAkB,EAAuB,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,EAAE;QAClF,0DAA0D;QAC1D,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAEpF,oEAAoE;QACpE,KAAK,MAAM,aAA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AC;YAClD,cAAc,EAAE,IAAA,qBAAU,EACxB,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,mCAAmC,CAAC,CAC9E,CAAC,OAAO,EAAE;SACZ,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,IAAI,CAAC,UAAU,GAAG,+BAAkB,CAAC,MAAM,CAAC;YAC1C,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,IAAI,CAAC,aAAa,GAAG,sCAAqB,CAAC,MAAM,CAAC;YAChD,aAAa,EAAE,IAAA,qBAAU,EACvB,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,4BAA4B,CAAC,CACrE,CAAC,OAAO,EAAE;SACZ,CAAC,CAAC,OAAO,EAAE,CAAC;IACf,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,MAAM,CAClB,MAA4B,EAC5B,UAA2C;QAE3C,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,sBAAsB,EAAE,CAAC;YACvC,OAAO,+CAA+C,CACpD,MAAM,EACN,UAAU,CAAC,sBAAsB,CAClC,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC9F,CAAC;QACD,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;OAMG;IACI,SAAS;QACd,OAAO,6BAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;CACF;AA5FD,kDA4FC","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 } from '@fgv/ts-utils';\nimport * as QualifierTypes from '../qualifier-types';\nimport * as ResourceTypes from '../resource-types';\nimport { QualifierTypeCollector, ReadOnlyQualifierTypeCollector } from '../qualifier-types';\nimport { IReadOnlyQualifierCollector, QualifierCollector } from '../qualifiers';\nimport { ReadOnlyResourceTypeCollector, ResourceTypeCollector } from '../resource-types';\nimport { ISystemConfiguration } from './json';\nimport { systemConfiguration } from './convert';\nimport { sanitizeJsonObject } from '@fgv/ts-json-base';\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}\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) {\n this._config = config;\n\n this.qualifierTypes = QualifierTypeCollector.create({\n qualifierTypes: mapResults(\n config.qualifierTypes.map(QualifierTypes.createQualifierTypeFromSystemConfig)\n ).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(\n config.resourceTypes.map(ResourceTypes.createResourceTypeFromConfig)\n ).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 return updateSystemConfigurationQualifierDefaultValues(\n config,\n initParams.qualifierDefaultValues\n ).onSuccess((updatedConfig) => captureResult(() => new SystemConfiguration(updatedConfig)));\n }\n return captureResult(() => new SystemConfiguration(config));\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"]}
|
|
1
|
+
{"version":3,"file":"systemConfiguration.js","sourceRoot":"","sources":["../../../src/packlets/config/systemConfiguration.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAyCH,0GAuCC;AA9ED,4CAAuF;AAGvF,wDAA2G;AAC3G,8CAAgF;AAChF,sDAAuG;AAEvG,uCAAgD;AAChD,oDAAiE;AACjE,2DAI6B;AAiB7B;;;;;;;;GAQG;AACH,SAAgB,+CAA+C,CAC7D,MAA4B,EAC5B,sBAAqD,CAAC,6CAA6C;;IAEnG,8BAA8B;IAC9B,OAAO,IAAA,iCAAkB,EAAuB,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,EAAE;QAClF,0DAA0D;QAC1D,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAEpF,oEAAoE;QACpE,KAAK,MAAM,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,EAAE,CAAC;YAChE,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC/C,OAAO,IAAA,eAAI,EAAC,cAAc,aAAa,qCAAqC,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;QAED,kCAAkC;QAClC,aAAa,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YACpE,IAAI,SAAS,CAAC,IAAI,IAAI,sBAAsB,EAAE,CAAC;gBAC7C,MAAM,eAAe,GAAG,sBAAsB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBAE/D,iCAAiC;gBACjC,MAAM,gBAAgB,qBAAQ,SAAS,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CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;CACF;AA9GD,kDA8GC","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 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"]}
|
|
@@ -66,4 +66,17 @@ export interface ISystemLiteralQualifierTypeConfig extends IQualifierTypeConfig<
|
|
|
66
66
|
* @public
|
|
67
67
|
*/
|
|
68
68
|
export type ISystemQualifierTypeConfig = ISystemLanguageQualifierTypeConfig | ISystemTerritoryQualifierTypeConfig | ISystemLiteralQualifierTypeConfig;
|
|
69
|
+
/**
|
|
70
|
+
* A union of all qualifier type configurations.
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export type IAnyQualifierTypeConfig = IQualifierTypeConfig | ISystemQualifierTypeConfig;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} is a
|
|
76
|
+
* {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.
|
|
77
|
+
* @param config - The {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} to check.
|
|
78
|
+
* @returns `true` if the configuration is a system qualifier type configuration, `false` otherwise.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare function isSystemQualifierTypeConfig(config: IAnyQualifierTypeConfig): config is ISystemQualifierTypeConfig;
|
|
69
82
|
//# sourceMappingURL=json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../../src/packlets/qualifier-types/config/json.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,UAAU;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE9B;;;OAGG;IACH,SAAS,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,gBAAgB,CAAC,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,yBAAyB,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,kCACf,SAAQ,oBAAoB,CAAC,4BAA4B,CAAC;IAC1D,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,mCACf,SAAQ,oBAAoB,CAAC,6BAA6B,CAAC;IAC3D,UAAU,EAAE,WAAW,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,iCAAkC,SAAQ,oBAAoB,CAAC,2BAA2B,CAAC;IAC1G,UAAU,EAAE,SAAS,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAClC,kCAAkC,GAClC,mCAAmC,GACnC,iCAAiC,CAAC;AAEtC;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GAAG,0BAA0B,CAAC;AAExF;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,uBAAuB,GAC9B,MAAM,IAAI,0BAA0B,CAItC"}
|
|
@@ -21,4 +21,15 @@
|
|
|
21
21
|
* SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.isSystemQualifierTypeConfig = isSystemQualifierTypeConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} is a
|
|
27
|
+
* {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.
|
|
28
|
+
* @param config - The {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} to check.
|
|
29
|
+
* @returns `true` if the configuration is a system qualifier type configuration, `false` otherwise.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
function isSystemQualifierTypeConfig(config) {
|
|
33
|
+
return (config.systemType === 'language' || config.systemType === 'territory' || config.systemType === 'literal');
|
|
34
|
+
}
|
|
24
35
|
//# sourceMappingURL=json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../../src/packlets/qualifier-types/config/json.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject } from '@fgv/ts-json-base';\nimport { LiteralValueHierarchyDecl } from '../literalValueHierarchy';\n\n/**\n * Templated configuration for {@link QualifierTypes.QualifierType | qualifier type} configuration.\n * @public\n */\nexport interface IQualifierTypeConfig<T = JsonObject> {\n name: string;\n systemType: string;\n configuration?: T;\n}\n\n/**\n * Configuration for {@link QualifierTypes.LanguageQualifierType | language qualifier type} configuration.\n * @public\n */\nexport interface ILanguageQualifierTypeConfig {\n allowContextList?: boolean;\n}\n\n/**\n * Configuration for {@link QualifierTypes.TerritoryQualifierType | territory qualifier type} configuration.\n * @public\n */\nexport interface ITerritoryQualifierTypeConfig {\n allowContextList?: boolean;\n\n acceptLowercase?: boolean;\n allowedTerritories?: string[];\n\n /**\n * Optional {@link QualifierTypes.LiteralValueHierarchyDecl | hierarchy declaration}\n * of territory values to use for matching. If not provided, no hierarchy will be used.\n */\n hierarchy?: LiteralValueHierarchyDecl<string>;\n}\n\n/**\n * Configuration for {@link QualifierTypes.LiteralQualifierType | literal qualifier type} configuration.\n * @public\n */\nexport interface ILiteralQualifierTypeConfig {\n allowContextList?: boolean;\n caseSensitive?: boolean;\n enumeratedValues?: string[];\n hierarchy?: LiteralValueHierarchyDecl<string>;\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.LanguageQualifierType | language qualifier type} configuration.\n * @public\n */\nexport interface ISystemLanguageQualifierTypeConfig\n extends IQualifierTypeConfig<ILanguageQualifierTypeConfig> {\n systemType: 'language';\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.TerritoryQualifierType | territory qualifier type} configuration.\n * @public\n */\nexport interface ISystemTerritoryQualifierTypeConfig\n extends IQualifierTypeConfig<ITerritoryQualifierTypeConfig> {\n systemType: 'territory';\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.LiteralQualifierType | literal qualifier type} configuration.\n * @public\n */\nexport interface ISystemLiteralQualifierTypeConfig extends IQualifierTypeConfig<ILiteralQualifierTypeConfig> {\n systemType: 'literal';\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.QualifierType | qualifier type} configuration.\n * @public\n */\nexport type ISystemQualifierTypeConfig =\n | ISystemLanguageQualifierTypeConfig\n | ISystemTerritoryQualifierTypeConfig\n | ISystemLiteralQualifierTypeConfig;\n"]}
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../../src/packlets/qualifier-types/config/json.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAmGH,kEAMC;AAbD;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,MAA+B;IAE/B,OAAO,CACL,MAAM,CAAC,UAAU,KAAK,UAAU,IAAI,MAAM,CAAC,UAAU,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,CACzG,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject } from '@fgv/ts-json-base';\nimport { LiteralValueHierarchyDecl } from '../literalValueHierarchy';\n\n/**\n * Templated configuration for {@link QualifierTypes.QualifierType | qualifier type} configuration.\n * @public\n */\nexport interface IQualifierTypeConfig<T = JsonObject> {\n name: string;\n systemType: string;\n configuration?: T;\n}\n\n/**\n * Configuration for {@link QualifierTypes.LanguageQualifierType | language qualifier type} configuration.\n * @public\n */\nexport interface ILanguageQualifierTypeConfig {\n allowContextList?: boolean;\n}\n\n/**\n * Configuration for {@link QualifierTypes.TerritoryQualifierType | territory qualifier type} configuration.\n * @public\n */\nexport interface ITerritoryQualifierTypeConfig {\n allowContextList?: boolean;\n\n acceptLowercase?: boolean;\n allowedTerritories?: string[];\n\n /**\n * Optional {@link QualifierTypes.LiteralValueHierarchyDecl | hierarchy declaration}\n * of territory values to use for matching. If not provided, no hierarchy will be used.\n */\n hierarchy?: LiteralValueHierarchyDecl<string>;\n}\n\n/**\n * Configuration for {@link QualifierTypes.LiteralQualifierType | literal qualifier type} configuration.\n * @public\n */\nexport interface ILiteralQualifierTypeConfig {\n allowContextList?: boolean;\n caseSensitive?: boolean;\n enumeratedValues?: string[];\n hierarchy?: LiteralValueHierarchyDecl<string>;\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.LanguageQualifierType | language qualifier type} configuration.\n * @public\n */\nexport interface ISystemLanguageQualifierTypeConfig\n extends IQualifierTypeConfig<ILanguageQualifierTypeConfig> {\n systemType: 'language';\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.TerritoryQualifierType | territory qualifier type} configuration.\n * @public\n */\nexport interface ISystemTerritoryQualifierTypeConfig\n extends IQualifierTypeConfig<ITerritoryQualifierTypeConfig> {\n systemType: 'territory';\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.LiteralQualifierType | literal qualifier type} configuration.\n * @public\n */\nexport interface ISystemLiteralQualifierTypeConfig extends IQualifierTypeConfig<ILiteralQualifierTypeConfig> {\n systemType: 'literal';\n}\n\n/**\n * Discriminated configuration for {@link QualifierTypes.QualifierType | qualifier type} configuration.\n * @public\n */\nexport type ISystemQualifierTypeConfig =\n | ISystemLanguageQualifierTypeConfig\n | ISystemTerritoryQualifierTypeConfig\n | ISystemLiteralQualifierTypeConfig;\n\n/**\n * A union of all qualifier type configurations.\n * @public\n */\nexport type IAnyQualifierTypeConfig = IQualifierTypeConfig | ISystemQualifierTypeConfig;\n\n/**\n * Checks if a {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} is a\n * {@link QualifierTypes.Config.ISystemQualifierTypeConfig | system qualifier type configuration}.\n * @param config - The {@link QualifierTypes.Config.IAnyQualifierTypeConfig | qualifier type configuration} to check.\n * @returns `true` if the configuration is a system qualifier type configuration, `false` otherwise.\n * @public\n */\nexport function isSystemQualifierTypeConfig(\n config: IAnyQualifierTypeConfig\n): config is ISystemQualifierTypeConfig {\n return (\n config.systemType === 'language' || config.systemType === 'territory' || config.systemType === 'literal'\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-res",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-12",
|
|
4
4
|
"description": "Multi-dimensional Resource Runtime",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-res.d.ts",
|
|
@@ -44,22 +44,22 @@
|
|
|
44
44
|
"@rushstack/heft-node-rig": "~2.9.0",
|
|
45
45
|
"@types/heft-jest": "1.0.6",
|
|
46
46
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
47
|
-
"@fgv/ts-utils
|
|
48
|
-
"@fgv/ts-
|
|
49
|
-
"@fgv/ts-
|
|
50
|
-
"@fgv/ts-
|
|
51
|
-
"@fgv/ts-
|
|
52
|
-
"@fgv/ts-json
|
|
47
|
+
"@fgv/ts-utils": "5.0.0-12",
|
|
48
|
+
"@fgv/ts-utils-jest": "5.0.0-12",
|
|
49
|
+
"@fgv/ts-json-base": "5.0.0-12",
|
|
50
|
+
"@fgv/ts-extras": "5.0.0-12",
|
|
51
|
+
"@fgv/ts-bcp47": "5.0.0-12",
|
|
52
|
+
"@fgv/ts-json": "5.0.0-12"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"luxon": "^3.6.1"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@fgv/ts-utils": "5.0.0-
|
|
59
|
-
"@fgv/ts-
|
|
60
|
-
"@fgv/ts-
|
|
61
|
-
"@fgv/ts-bcp47": "5.0.0-
|
|
62
|
-
"@fgv/ts-json": "5.0.0-
|
|
58
|
+
"@fgv/ts-utils": "5.0.0-12",
|
|
59
|
+
"@fgv/ts-extras": "5.0.0-12",
|
|
60
|
+
"@fgv/ts-json-base": "5.0.0-12",
|
|
61
|
+
"@fgv/ts-bcp47": "5.0.0-12",
|
|
62
|
+
"@fgv/ts-json": "5.0.0-12"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "heft build --clean",
|