@fgv/ts-res 5.0.0-27 → 5.0.0-29
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 +200 -37
- package/lib/packlets/config/configInitFactory.d.ts +151 -12
- package/lib/packlets/config/configInitFactory.js +164 -9
- package/lib/packlets/qualifier-types/config/json.d.ts +1 -1
- package/lib/packlets/qualifier-types/convert.d.ts +1 -1
- package/lib/packlets/qualifier-types/helpers.d.ts +13 -3
- package/lib/packlets/qualifier-types/helpers.js +2 -2
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +4 -4
- package/lib/packlets/qualifier-types/languageQualifierType.js +2 -4
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +4 -4
- package/lib/packlets/qualifier-types/literalQualifierType.js +2 -4
- package/lib/packlets/qualifier-types/literalValueHierarchy.d.ts +1 -1
- package/lib/packlets/qualifier-types/qualifierType.d.ts +8 -7
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +7 -5
- package/lib/packlets/qualifier-types/territoryQualifierType.js +4 -4
- package/lib/packlets/resource-types/config/convert.d.ts +1 -1
- package/lib/packlets/resource-types/config/json.d.ts +2 -2
- package/package.json +7 -7
package/dist/ts-res.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { FileTree } from '@fgv/ts-utils';
|
|
|
7
7
|
import { Hash } from '@fgv/ts-utils';
|
|
8
8
|
import { ICollectible } from '@fgv/ts-utils';
|
|
9
9
|
import { IReadOnlyResultMap } from '@fgv/ts-utils';
|
|
10
|
+
import { JsonCompatible } from '@fgv/ts-json-base';
|
|
10
11
|
import { JsonObject } from '@fgv/ts-json-base';
|
|
11
12
|
import { JsonValue } from '@fgv/ts-json-base';
|
|
12
13
|
import { ObjectConverter } from '@fgv/ts-utils';
|
|
@@ -189,12 +190,15 @@ declare function buildQualifierDefaultValuesToken(parts: ReadonlyArray<IQualifie
|
|
|
189
190
|
declare function buildQualifierDefaultValueToken({ qualifier, value }: IQualifierDefaultValueTokenParts): Result<QualifierDefaultValueToken>;
|
|
190
191
|
|
|
191
192
|
/**
|
|
192
|
-
* A factory that creates a {@link QualifierTypes.
|
|
193
|
+
* A factory that creates a {@link QualifierTypes.SystemQualifierType | SystemQualifierType} from
|
|
194
|
+
* {@link QualifierTypes.Config.IAnyQualifierTypeConfig | any qualifier type configuration}.
|
|
195
|
+
* @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}
|
|
196
|
+
* if successful, `Failure` with an error message otherwise.
|
|
193
197
|
* @public
|
|
194
198
|
*/
|
|
195
|
-
declare class BuiltInQualifierTypeFactory implements IConfigInitFactory<QualifierTypes.Config.
|
|
199
|
+
declare class BuiltInQualifierTypeFactory implements IConfigInitFactory<QualifierTypes.Config.ISystemQualifierTypeConfig, SystemQualifierType> {
|
|
196
200
|
/** {@inheritDoc Config.IConfigInitFactory.create} */
|
|
197
|
-
create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<
|
|
201
|
+
create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<SystemQualifierType>;
|
|
198
202
|
}
|
|
199
203
|
|
|
200
204
|
/**
|
|
@@ -1824,12 +1828,18 @@ declare namespace Config {
|
|
|
1824
1828
|
export {
|
|
1825
1829
|
Model,
|
|
1826
1830
|
Convert_9 as Convert,
|
|
1831
|
+
createQualifierTypeFactory,
|
|
1832
|
+
createResourceTypeFactory,
|
|
1833
|
+
QualifierTypeFactoryFunction,
|
|
1834
|
+
ResourceTypeFactoryFunction,
|
|
1827
1835
|
IConfigInitFactory,
|
|
1828
1836
|
ChainedConfigInitFactory,
|
|
1829
1837
|
BuiltInQualifierTypeFactory,
|
|
1830
1838
|
QualifierTypeFactory,
|
|
1839
|
+
ValidatingQualifierTypeFactory,
|
|
1831
1840
|
BuiltInResourceTypeFactory,
|
|
1832
1841
|
ResourceTypeFactory,
|
|
1842
|
+
ValidatingResourceTypeFactory,
|
|
1833
1843
|
updateSystemConfigurationQualifierDefaultValues,
|
|
1834
1844
|
ISystemConfigurationInitParams,
|
|
1835
1845
|
SystemConfiguration,
|
|
@@ -2345,6 +2355,14 @@ declare namespace Convert_9 {
|
|
|
2345
2355
|
}
|
|
2346
2356
|
}
|
|
2347
2357
|
|
|
2358
|
+
/**
|
|
2359
|
+
* Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a factory function.
|
|
2360
|
+
* @param fn - The factory function to wrap.
|
|
2361
|
+
* @returns An `IConfigInitFactory` instance that delegates to the function.
|
|
2362
|
+
* @public
|
|
2363
|
+
*/
|
|
2364
|
+
declare function createQualifierTypeFactory<T extends QualifierType = QualifierType>(fn: QualifierTypeFactoryFunction<T>): IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T>;
|
|
2365
|
+
|
|
2348
2366
|
/**
|
|
2349
2367
|
* Creates a {@link QualifierTypes.QualifierType | QualifierType} from a configuration object.
|
|
2350
2368
|
* This factory function determines the appropriate qualifier type based on the systemType
|
|
@@ -2358,16 +2376,24 @@ declare namespace Convert_9 {
|
|
|
2358
2376
|
declare function createQualifierTypeFromConfig(typeConfig: Config_2.IAnyQualifierTypeConfig): Result<QualifierType>;
|
|
2359
2377
|
|
|
2360
2378
|
/**
|
|
2361
|
-
* Creates a {@link QualifierTypes.
|
|
2379
|
+
* Creates a {@link QualifierTypes.SystemQualifierType | SystemQualifierType} from a system configuration object.
|
|
2362
2380
|
* This factory function determines the appropriate qualifier type based on the systemType
|
|
2363
2381
|
* and delegates to the appropriate type-specific createFromConfig method.
|
|
2364
2382
|
* @param typeConfig - The {@link QualifierTypes.Config.ISystemQualifierTypeConfig | configuration object}
|
|
2365
2383
|
* containing the name, systemType, and optional type-specific configuration.
|
|
2366
|
-
* @returns `Success` with the new {@link QualifierTypes.
|
|
2384
|
+
* @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}
|
|
2367
2385
|
* if successful, `Failure` with an error message otherwise.
|
|
2368
2386
|
* @public
|
|
2369
2387
|
*/
|
|
2370
|
-
declare function createQualifierTypeFromSystemConfig(typeConfig: Config_2.ISystemQualifierTypeConfig): Result<
|
|
2388
|
+
declare function createQualifierTypeFromSystemConfig(typeConfig: Config_2.ISystemQualifierTypeConfig): Result<SystemQualifierType>;
|
|
2389
|
+
|
|
2390
|
+
/**
|
|
2391
|
+
* Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a resource type factory function.
|
|
2392
|
+
* @param fn - The factory function to wrap.
|
|
2393
|
+
* @returns An `IConfigInitFactory` instance that delegates to the function.
|
|
2394
|
+
* @public
|
|
2395
|
+
*/
|
|
2396
|
+
declare function createResourceTypeFactory(fn: ResourceTypeFactoryFunction): IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>;
|
|
2371
2397
|
|
|
2372
2398
|
/**
|
|
2373
2399
|
* Creates a {@link ResourceTypes.ResourceType | ResourceType} from a configuration object.
|
|
@@ -4144,7 +4170,7 @@ declare interface ILiteralValue<T extends string> {
|
|
|
4144
4170
|
*/
|
|
4145
4171
|
declare interface ILiteralValueHierarchyCreateParams<T extends string = string> {
|
|
4146
4172
|
values: ReadonlyArray<T>;
|
|
4147
|
-
hierarchy?: LiteralValueHierarchyDecl<T
|
|
4173
|
+
hierarchy?: Partial<LiteralValueHierarchyDecl<T>>;
|
|
4148
4174
|
}
|
|
4149
4175
|
|
|
4150
4176
|
/**
|
|
@@ -4574,7 +4600,7 @@ declare interface IQualifierDefaultValueTokenParts {
|
|
|
4574
4600
|
* territories, etc).
|
|
4575
4601
|
* @public
|
|
4576
4602
|
*/
|
|
4577
|
-
declare interface IQualifierType extends ICollectible<QualifierTypeName, QualifierTypeIndex> {
|
|
4603
|
+
declare interface IQualifierType<TCFGJSON extends JsonObject = JsonObject> extends ICollectible<QualifierTypeName, QualifierTypeIndex> {
|
|
4578
4604
|
/**
|
|
4579
4605
|
* The name of the qualifier type.
|
|
4580
4606
|
*/
|
|
@@ -4649,13 +4675,13 @@ declare interface IQualifierType extends ICollectible<QualifierTypeName, Qualifi
|
|
|
4649
4675
|
* Gets the configuration for this qualifier type.
|
|
4650
4676
|
* @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
|
|
4651
4677
|
*/
|
|
4652
|
-
getConfigurationJson(): Result<
|
|
4678
|
+
getConfigurationJson(): Result<JsonCompatible<Config_2.IQualifierTypeConfig<TCFGJSON>>>;
|
|
4653
4679
|
/**
|
|
4654
4680
|
* Validates configuration JSON data for this qualifier type.
|
|
4655
4681
|
* @param from - The unknown data to validate as configuration JSON.
|
|
4656
4682
|
* @returns `Success` with validated JSON configuration if valid, `Failure` with an error message otherwise.
|
|
4657
4683
|
*/
|
|
4658
|
-
validateConfigurationJson(from: unknown): Result<
|
|
4684
|
+
validateConfigurationJson(from: unknown): Result<JsonCompatible<Config_2.IQualifierTypeConfig<TCFGJSON>>>;
|
|
4659
4685
|
}
|
|
4660
4686
|
|
|
4661
4687
|
/**
|
|
@@ -5465,10 +5491,10 @@ declare interface IResourceType<T = unknown> extends ICollectible<ResourceTypeNa
|
|
|
5465
5491
|
* Configuration for a {@link ResourceTypes.ResourceType | resource type}.
|
|
5466
5492
|
* @public
|
|
5467
5493
|
*/
|
|
5468
|
-
declare interface IResourceTypeConfig {
|
|
5494
|
+
declare interface IResourceTypeConfig<T extends JsonObject = JsonObject> {
|
|
5469
5495
|
name: string;
|
|
5470
5496
|
typeName: string;
|
|
5471
|
-
template?:
|
|
5497
|
+
template?: T;
|
|
5472
5498
|
}
|
|
5473
5499
|
|
|
5474
5500
|
/**
|
|
@@ -6272,7 +6298,7 @@ declare const LanguagePrioritySystemConfiguration: ISystemConfiguration;
|
|
|
6272
6298
|
* Accepts a list of language tags in the context by default.
|
|
6273
6299
|
* @public
|
|
6274
6300
|
*/
|
|
6275
|
-
declare class LanguageQualifierType extends QualifierType {
|
|
6301
|
+
declare class LanguageQualifierType extends QualifierType<JsonCompatible<Config_2.ILanguageQualifierTypeConfig>> {
|
|
6276
6302
|
/**
|
|
6277
6303
|
* {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
|
|
6278
6304
|
*/
|
|
@@ -6315,11 +6341,11 @@ declare class LanguageQualifierType extends QualifierType {
|
|
|
6315
6341
|
/**
|
|
6316
6342
|
* {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
6317
6343
|
*/
|
|
6318
|
-
getConfigurationJson(): Result<
|
|
6344
|
+
getConfigurationJson(): Result<JsonCompatible<Config_2.ISystemLanguageQualifierTypeConfig>>;
|
|
6319
6345
|
/**
|
|
6320
6346
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
6321
6347
|
*/
|
|
6322
|
-
validateConfigurationJson(from: unknown): Result<
|
|
6348
|
+
validateConfigurationJson(from: unknown): Result<JsonCompatible<Config_2.ISystemLanguageQualifierTypeConfig>>;
|
|
6323
6349
|
/**
|
|
6324
6350
|
* Validates a {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | strongly typed configuration object}
|
|
6325
6351
|
* for this qualifier type.
|
|
@@ -6350,7 +6376,7 @@ declare const languageQualifierTypeConfig: ObjectConverter<Model_2.ILanguageQual
|
|
|
6350
6376
|
* optionally case-sensitive or matching against an ordered list of values at runtime.
|
|
6351
6377
|
* @public
|
|
6352
6378
|
*/
|
|
6353
|
-
declare class LiteralQualifierType extends QualifierType {
|
|
6379
|
+
declare class LiteralQualifierType extends QualifierType<JsonCompatible<Config_2.ILiteralQualifierTypeConfig>> {
|
|
6354
6380
|
/**
|
|
6355
6381
|
* {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
|
|
6356
6382
|
*/
|
|
@@ -6399,11 +6425,11 @@ declare class LiteralQualifierType extends QualifierType {
|
|
|
6399
6425
|
/**
|
|
6400
6426
|
* {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
6401
6427
|
*/
|
|
6402
|
-
getConfigurationJson(): Result<
|
|
6428
|
+
getConfigurationJson(): Result<JsonCompatible<Config_2.ISystemLiteralQualifierTypeConfig>>;
|
|
6403
6429
|
/**
|
|
6404
6430
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
6405
6431
|
*/
|
|
6406
|
-
validateConfigurationJson(from: unknown): Result<
|
|
6432
|
+
validateConfigurationJson(from: unknown): Result<JsonCompatible<Config_2.ISystemLiteralQualifierTypeConfig>>;
|
|
6407
6433
|
/**
|
|
6408
6434
|
* Validates a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
|
|
6409
6435
|
* for this qualifier type.
|
|
@@ -6564,7 +6590,7 @@ declare function literalValueHierarchyCreateParams<T extends string>(valueConver
|
|
|
6564
6590
|
* determine the relationship between values when matching conditions and contexts.
|
|
6565
6591
|
* @public
|
|
6566
6592
|
*/
|
|
6567
|
-
declare type LiteralValueHierarchyDecl<T extends string> =
|
|
6593
|
+
declare type LiteralValueHierarchyDecl<T extends string> = Record<T, T>;
|
|
6568
6594
|
|
|
6569
6595
|
/**
|
|
6570
6596
|
* `Converter` for a normalized {@link ResourceJson.Json.ILooseConditionDecl | loose condition declaration}.
|
|
@@ -7325,7 +7351,7 @@ export { Qualifiers }
|
|
|
7325
7351
|
* the {@link QualifierTypes.IQualifierType | IQualifierType} interface.
|
|
7326
7352
|
* @public
|
|
7327
7353
|
*/
|
|
7328
|
-
export declare abstract class QualifierType implements IQualifierType {
|
|
7354
|
+
export declare abstract class QualifierType<TCFGJSON extends JsonObject = JsonObject> implements IQualifierType<TCFGJSON> {
|
|
7329
7355
|
/**
|
|
7330
7356
|
* {@inheritdoc QualifierTypes.IQualifierType.name}
|
|
7331
7357
|
*/
|
|
@@ -7382,11 +7408,11 @@ export declare abstract class QualifierType implements IQualifierType {
|
|
|
7382
7408
|
/**
|
|
7383
7409
|
* {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
7384
7410
|
*/
|
|
7385
|
-
abstract getConfigurationJson(): Result<
|
|
7411
|
+
abstract getConfigurationJson(): Result<JsonCompatible<Config_2.IQualifierTypeConfig<TCFGJSON>>>;
|
|
7386
7412
|
/**
|
|
7387
7413
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
7388
7414
|
*/
|
|
7389
|
-
abstract validateConfigurationJson(from: unknown): Result<
|
|
7415
|
+
abstract validateConfigurationJson(from: unknown): Result<JsonCompatible<Config_2.IQualifierTypeConfig<TCFGJSON>>>;
|
|
7390
7416
|
/**
|
|
7391
7417
|
* {@inheritdoc QualifierTypes.IQualifierType.setIndex}
|
|
7392
7418
|
*/
|
|
@@ -7442,7 +7468,7 @@ export declare abstract class QualifierType implements IQualifierType {
|
|
|
7442
7468
|
* index from a supplied {@link QualifierTypes.Convert.IQualifierTypeConvertContext | conversion context}.
|
|
7443
7469
|
* @public
|
|
7444
7470
|
*/
|
|
7445
|
-
declare const qualifierType: Converter<QualifierType
|
|
7471
|
+
declare const qualifierType: Converter<QualifierType<JsonObject>, IQualifierTypeConvertContext>;
|
|
7446
7472
|
|
|
7447
7473
|
/**
|
|
7448
7474
|
* Collector for {@link QualifierTypes.QualifierType | QualifierType} objects.
|
|
@@ -7475,19 +7501,65 @@ declare class QualifierTypeCollector extends ValidatingConvertingCollector<Quali
|
|
|
7475
7501
|
declare function qualifierTypeConfig<T, TD = unknown>(config: Converter<T, TD>): Converter<Model_2.IQualifierTypeConfig<T>, TD>;
|
|
7476
7502
|
|
|
7477
7503
|
/**
|
|
7478
|
-
* A factory that creates
|
|
7479
|
-
*
|
|
7504
|
+
* A factory that creates {@link QualifierTypes.QualifierType | QualifierType} instances from configuration,
|
|
7505
|
+
* supporting both built-in system types and custom external types.
|
|
7506
|
+
*
|
|
7507
|
+
* This factory allows external consumers to extend the qualifier type system with their own custom types
|
|
7508
|
+
* while maintaining support for all built-in types (Language, Territory, Literal).
|
|
7509
|
+
*
|
|
7510
|
+
* @typeParam T - The custom qualifier type(s) to support. Defaults to {@link QualifierTypes.SystemQualifierType | SystemQualifierType}.
|
|
7511
|
+
*
|
|
7512
|
+
* @example Creating a factory with custom qualifier types
|
|
7513
|
+
* ```typescript
|
|
7514
|
+
* // Define a custom qualifier type
|
|
7515
|
+
* class CustomQualifierType extends QualifierType {
|
|
7516
|
+
* // ... implementation
|
|
7517
|
+
* }
|
|
7518
|
+
*
|
|
7519
|
+
* // Define a discriminated union of all types
|
|
7520
|
+
* type AppQualifierType = SystemQualifierType | CustomQualifierType;
|
|
7521
|
+
*
|
|
7522
|
+
* // Create a factory that handles custom types
|
|
7523
|
+
* const customFactory: IConfigInitFactory<IAnyQualifierTypeConfig, CustomQualifierType> = {
|
|
7524
|
+
* create(config) {
|
|
7525
|
+
* // ... handle custom type creation
|
|
7526
|
+
* }
|
|
7527
|
+
* };
|
|
7528
|
+
*
|
|
7529
|
+
* // Create the combined factory
|
|
7530
|
+
* const qualifierTypeFactory = new QualifierTypeFactory<AppQualifierType>([customFactory]);
|
|
7531
|
+
*
|
|
7532
|
+
* // The factory returns T | SystemQualifierType, supporting all types
|
|
7533
|
+
* const result = qualifierTypeFactory.create(config); // Result<AppQualifierType | SystemQualifierType>
|
|
7534
|
+
* ```
|
|
7535
|
+
*
|
|
7536
|
+
* @remarks
|
|
7537
|
+
* - The factory chains custom factories with the built-in factory
|
|
7538
|
+
* - Custom factories are tried first, falling back to built-in types
|
|
7539
|
+
* - The return type is a union of custom types (T) and system types
|
|
7540
|
+
*
|
|
7480
7541
|
* @public
|
|
7481
7542
|
*/
|
|
7482
|
-
declare class QualifierTypeFactory extends ChainedConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig,
|
|
7543
|
+
declare class QualifierTypeFactory<T extends QualifierType = SystemQualifierType> extends ChainedConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T | SystemQualifierType> {
|
|
7483
7544
|
/**
|
|
7484
7545
|
* Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.
|
|
7485
|
-
* @param factories -
|
|
7486
|
-
*
|
|
7546
|
+
* @param factories - Array of factories for custom qualifier types. Can be:
|
|
7547
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
7548
|
+
* - {@link Config.QualifierTypeFactoryFunction | Factory functions}
|
|
7549
|
+
* - A mix of both
|
|
7550
|
+
* These are tried in order before falling back to built-in types.
|
|
7551
|
+
* @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always appended to handle
|
|
7552
|
+
* system qualifier types (Language, Territory, Literal).
|
|
7487
7553
|
*/
|
|
7488
|
-
constructor(factories: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig,
|
|
7554
|
+
constructor(factories: Array<IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> | QualifierTypeFactoryFunction<T>>);
|
|
7489
7555
|
}
|
|
7490
7556
|
|
|
7557
|
+
/**
|
|
7558
|
+
* Function signature for creating a qualifier type from configuration.
|
|
7559
|
+
* @public
|
|
7560
|
+
*/
|
|
7561
|
+
declare type QualifierTypeFactoryFunction<T extends QualifierType = QualifierType> = (config: QualifierTypes.Config.IAnyQualifierTypeConfig) => Result<T>;
|
|
7562
|
+
|
|
7491
7563
|
/**
|
|
7492
7564
|
* Branded number representing a validated qualifier type index.
|
|
7493
7565
|
* @public
|
|
@@ -7532,7 +7604,8 @@ declare namespace QualifierTypes {
|
|
|
7532
7604
|
QualifierTypeCollector,
|
|
7533
7605
|
ReadOnlyQualifierTypeCollector,
|
|
7534
7606
|
createQualifierTypeFromConfig,
|
|
7535
|
-
createQualifierTypeFromSystemConfig
|
|
7607
|
+
createQualifierTypeFromSystemConfig,
|
|
7608
|
+
SystemQualifierType
|
|
7536
7609
|
}
|
|
7537
7610
|
}
|
|
7538
7611
|
export { QualifierTypes }
|
|
@@ -9205,7 +9278,7 @@ declare class ResourceTypeCollector extends ValidatingCollector<ResourceType> {
|
|
|
9205
9278
|
* @returns A `Converter` for {@link ResourceTypes.Config.IResourceTypeConfig | ResourceTypeConfig} objects.
|
|
9206
9279
|
* @public
|
|
9207
9280
|
*/
|
|
9208
|
-
declare const resourceTypeConfig: ObjectConverter<IResourceTypeConfig
|
|
9281
|
+
declare const resourceTypeConfig: ObjectConverter<IResourceTypeConfig<JsonObject>, unknown>;
|
|
9209
9282
|
|
|
9210
9283
|
/**
|
|
9211
9284
|
* A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}
|
|
@@ -9215,12 +9288,21 @@ declare const resourceTypeConfig: ObjectConverter<IResourceTypeConfig, unknown>;
|
|
|
9215
9288
|
declare class ResourceTypeFactory extends ChainedConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {
|
|
9216
9289
|
/**
|
|
9217
9290
|
* Constructor for a resource type factory.
|
|
9218
|
-
* @param factories -
|
|
9291
|
+
* @param factories - Array of factories for resource types. Can be:
|
|
9292
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
9293
|
+
* - {@link Config.ResourceTypeFactoryFunction | Factory functions}
|
|
9294
|
+
* - A mix of both
|
|
9219
9295
|
* @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.
|
|
9220
9296
|
*/
|
|
9221
|
-
constructor(factories: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>
|
|
9297
|
+
constructor(factories: Array<IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> | ResourceTypeFactoryFunction>);
|
|
9222
9298
|
}
|
|
9223
9299
|
|
|
9300
|
+
/**
|
|
9301
|
+
* Function signature for creating a resource type from configuration.
|
|
9302
|
+
* @public
|
|
9303
|
+
*/
|
|
9304
|
+
declare type ResourceTypeFactoryFunction = (config: ResourceTypes.Config.IResourceTypeConfig) => Result<ResourceType>;
|
|
9305
|
+
|
|
9224
9306
|
/**
|
|
9225
9307
|
* Branded number representing a validated resource type index.
|
|
9226
9308
|
* @public
|
|
@@ -9518,6 +9600,14 @@ declare const systemLanguageQualifierTypeConfig: ObjectConverter<Model_2.ISystem
|
|
|
9518
9600
|
*/
|
|
9519
9601
|
declare const systemLiteralQualifierTypeConfig: ObjectConverter<Model_2.ISystemLiteralQualifierTypeConfig, unknown>;
|
|
9520
9602
|
|
|
9603
|
+
/**
|
|
9604
|
+
* A discriminated union of all system qualifier types.
|
|
9605
|
+
* This allows TypeScript to properly discriminate between specific qualifier type implementations
|
|
9606
|
+
* and access their specific methods like getConfiguration().
|
|
9607
|
+
* @public
|
|
9608
|
+
*/
|
|
9609
|
+
declare type SystemQualifierType = LanguageQualifierType | TerritoryQualifierType | LiteralQualifierType;
|
|
9610
|
+
|
|
9521
9611
|
/**
|
|
9522
9612
|
* A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.
|
|
9523
9613
|
* @returns A `Converter` for {@link QualifierTypes.Config.ISystemQualifierTypeConfig | SystemQualifierTypeConfig} objects.
|
|
@@ -9561,7 +9651,7 @@ declare const TerritoryPrioritySystemConfiguration: ISystemConfiguration;
|
|
|
9561
9651
|
* implementation handles incorrect casing.
|
|
9562
9652
|
* @public
|
|
9563
9653
|
*/
|
|
9564
|
-
declare class TerritoryQualifierType extends QualifierType {
|
|
9654
|
+
declare class TerritoryQualifierType extends QualifierType<JsonCompatible<Config_2.ITerritoryQualifierTypeConfig>> {
|
|
9565
9655
|
/**
|
|
9566
9656
|
* {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
|
|
9567
9657
|
*/
|
|
@@ -9608,17 +9698,19 @@ declare class TerritoryQualifierType extends QualifierType {
|
|
|
9608
9698
|
*/
|
|
9609
9699
|
static createFromConfig(config: Config_2.IQualifierTypeConfig<Config_2.ITerritoryQualifierTypeConfig>): Result<TerritoryQualifierType>;
|
|
9610
9700
|
/**
|
|
9611
|
-
* {@
|
|
9701
|
+
* Gets the {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration}
|
|
9702
|
+
* for this qualifier type.
|
|
9703
|
+
* @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
|
|
9612
9704
|
*/
|
|
9613
9705
|
getConfiguration(): Result<Config_2.ISystemTerritoryQualifierTypeConfig>;
|
|
9614
9706
|
/**
|
|
9615
9707
|
* {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
9616
9708
|
*/
|
|
9617
|
-
getConfigurationJson(): Result<
|
|
9709
|
+
getConfigurationJson(): Result<JsonCompatible<Config_2.ISystemTerritoryQualifierTypeConfig>>;
|
|
9618
9710
|
/**
|
|
9619
9711
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
9620
9712
|
*/
|
|
9621
|
-
validateConfigurationJson(from: unknown): Result<
|
|
9713
|
+
validateConfigurationJson(from: unknown): Result<JsonCompatible<Config_2.ISystemTerritoryQualifierTypeConfig>>;
|
|
9622
9714
|
/**
|
|
9623
9715
|
* Validates a {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration object}
|
|
9624
9716
|
* for this qualifier type.
|
|
@@ -10048,6 +10140,77 @@ declare function validateSystemConfiguration(config: unknown): Result<ISystemCon
|
|
|
10048
10140
|
*/
|
|
10049
10141
|
declare function validateZipArchiveManifest(manifest: unknown): Result<Json_2.IZipArchiveManifest>;
|
|
10050
10142
|
|
|
10143
|
+
/**
|
|
10144
|
+
* A factory that validates and creates {@link QualifierTypes.QualifierType | QualifierType} instances
|
|
10145
|
+
* from weakly-typed configuration objects. This factory accepts configurations with unvalidated
|
|
10146
|
+
* string properties and validates them before delegating to the underlying factory chain.
|
|
10147
|
+
*
|
|
10148
|
+
* This pattern is useful at package boundaries where type identity issues may occur with
|
|
10149
|
+
* branded types across different package instances.
|
|
10150
|
+
*
|
|
10151
|
+
* @example
|
|
10152
|
+
* ```typescript
|
|
10153
|
+
* // Accept weakly-typed config from external source
|
|
10154
|
+
* const validatingFactory = new ValidatingQualifierTypeFactory([customFactory]);
|
|
10155
|
+
*
|
|
10156
|
+
* // Config can have plain string types instead of branded types
|
|
10157
|
+
* const config = {
|
|
10158
|
+
* name: 'my-qualifier', // plain string, not QualifierTypeName
|
|
10159
|
+
* systemType: 'custom', // plain string
|
|
10160
|
+
* configuration: { ... }
|
|
10161
|
+
* };
|
|
10162
|
+
*
|
|
10163
|
+
* const result = validatingFactory.create(config); // Validates and converts internally
|
|
10164
|
+
* ```
|
|
10165
|
+
*
|
|
10166
|
+
* @public
|
|
10167
|
+
*/
|
|
10168
|
+
declare class ValidatingQualifierTypeFactory<T extends QualifierType = SystemQualifierType> implements IConfigInitFactory<unknown, T | SystemQualifierType> {
|
|
10169
|
+
private readonly _innerFactory;
|
|
10170
|
+
/**
|
|
10171
|
+
* Constructor for a validating qualifier type factory.
|
|
10172
|
+
* @param factories - Array of factories for custom qualifier types. Can be:
|
|
10173
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
10174
|
+
* - {@link Config.QualifierTypeFactoryFunction | Factory functions}
|
|
10175
|
+
* - A mix of both
|
|
10176
|
+
*/
|
|
10177
|
+
constructor(factories: Array<IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> | QualifierTypeFactoryFunction<T>>);
|
|
10178
|
+
/**
|
|
10179
|
+
* Creates a qualifier type from a weakly-typed configuration object.
|
|
10180
|
+
* @param config - The configuration object to validate and use for creation.
|
|
10181
|
+
* @returns A result containing the new qualifier type if successful.
|
|
10182
|
+
*/
|
|
10183
|
+
create(config: unknown): Result<T | SystemQualifierType>;
|
|
10184
|
+
}
|
|
10185
|
+
|
|
10186
|
+
/**
|
|
10187
|
+
* A factory that validates and creates {@link ResourceTypes.ResourceType | ResourceType} instances
|
|
10188
|
+
* from weakly-typed configuration objects. This factory accepts configurations with unvalidated
|
|
10189
|
+
* string properties and validates them before delegating to the underlying factory chain.
|
|
10190
|
+
*
|
|
10191
|
+
* This pattern is useful at package boundaries where type identity issues may occur with
|
|
10192
|
+
* branded types across different package instances.
|
|
10193
|
+
*
|
|
10194
|
+
* @public
|
|
10195
|
+
*/
|
|
10196
|
+
declare class ValidatingResourceTypeFactory implements IConfigInitFactory<unknown, ResourceType> {
|
|
10197
|
+
private readonly _innerFactory;
|
|
10198
|
+
/**
|
|
10199
|
+
* Constructor for a validating resource type factory.
|
|
10200
|
+
* @param factories - Array of factories for resource types. Can be:
|
|
10201
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
10202
|
+
* - {@link Config.ResourceTypeFactoryFunction | Factory functions}
|
|
10203
|
+
* - A mix of both
|
|
10204
|
+
*/
|
|
10205
|
+
constructor(factories: Array<IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> | ResourceTypeFactoryFunction>);
|
|
10206
|
+
/**
|
|
10207
|
+
* Creates a resource type from a weakly-typed configuration object.
|
|
10208
|
+
* @param config - The configuration object to validate and use for creation.
|
|
10209
|
+
* @returns A result containing the new resource type if successful.
|
|
10210
|
+
*/
|
|
10211
|
+
create(config: unknown): Result<ResourceType>;
|
|
10212
|
+
}
|
|
10213
|
+
|
|
10051
10214
|
/**
|
|
10052
10215
|
* A {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} with a
|
|
10053
10216
|
* {@link Runtime.Context.ContextQualifierProviderValidator | validator} property that enables
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { Result } from '@fgv/ts-utils';
|
|
2
|
-
import { QualifierType } from '../qualifier-types';
|
|
2
|
+
import { QualifierType, SystemQualifierType } from '../qualifier-types';
|
|
3
3
|
import * as QualifierTypes from '../qualifier-types';
|
|
4
4
|
import * as ResourceTypes from '../resource-types';
|
|
5
5
|
import { ResourceType } from '../resource-types';
|
|
6
|
+
/**
|
|
7
|
+
* Function signature for creating a qualifier type from configuration.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type QualifierTypeFactoryFunction<T extends QualifierType = QualifierType> = (config: QualifierTypes.Config.IAnyQualifierTypeConfig) => Result<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Function signature for creating a resource type from configuration.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export type ResourceTypeFactoryFunction = (config: ResourceTypes.Config.IResourceTypeConfig) => Result<ResourceType>;
|
|
6
16
|
/**
|
|
7
17
|
* Interface for a factory that creates a new instance of a configuration object.
|
|
8
18
|
* @public
|
|
@@ -15,6 +25,20 @@ export interface IConfigInitFactory<TConfig, T> {
|
|
|
15
25
|
*/
|
|
16
26
|
create(config: TConfig): Result<T>;
|
|
17
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a factory function.
|
|
30
|
+
* @param fn - The factory function to wrap.
|
|
31
|
+
* @returns An `IConfigInitFactory` instance that delegates to the function.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare function createQualifierTypeFactory<T extends QualifierType = QualifierType>(fn: QualifierTypeFactoryFunction<T>): IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T>;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a resource type factory function.
|
|
37
|
+
* @param fn - The factory function to wrap.
|
|
38
|
+
* @returns An `IConfigInitFactory` instance that delegates to the function.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare function createResourceTypeFactory(fn: ResourceTypeFactoryFunction): IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>;
|
|
18
42
|
/**
|
|
19
43
|
* A factory that chains multiple factories together.
|
|
20
44
|
* @public
|
|
@@ -34,25 +58,110 @@ export declare class ChainedConfigInitFactory<TConfig, T> implements IConfigInit
|
|
|
34
58
|
create(config: TConfig): Result<T>;
|
|
35
59
|
}
|
|
36
60
|
/**
|
|
37
|
-
* A factory that creates a {@link QualifierTypes.
|
|
61
|
+
* A factory that creates a {@link QualifierTypes.SystemQualifierType | SystemQualifierType} from
|
|
62
|
+
* {@link QualifierTypes.Config.IAnyQualifierTypeConfig | any qualifier type configuration}.
|
|
63
|
+
* @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}
|
|
64
|
+
* if successful, `Failure` with an error message otherwise.
|
|
38
65
|
* @public
|
|
39
66
|
*/
|
|
40
|
-
export declare class BuiltInQualifierTypeFactory implements IConfigInitFactory<QualifierTypes.Config.
|
|
67
|
+
export declare class BuiltInQualifierTypeFactory implements IConfigInitFactory<QualifierTypes.Config.ISystemQualifierTypeConfig, SystemQualifierType> {
|
|
41
68
|
/** {@inheritDoc Config.IConfigInitFactory.create} */
|
|
42
|
-
create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<
|
|
69
|
+
create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<SystemQualifierType>;
|
|
43
70
|
}
|
|
44
71
|
/**
|
|
45
|
-
* A factory that creates
|
|
46
|
-
*
|
|
72
|
+
* A factory that creates {@link QualifierTypes.QualifierType | QualifierType} instances from configuration,
|
|
73
|
+
* supporting both built-in system types and custom external types.
|
|
74
|
+
*
|
|
75
|
+
* This factory allows external consumers to extend the qualifier type system with their own custom types
|
|
76
|
+
* while maintaining support for all built-in types (Language, Territory, Literal).
|
|
77
|
+
*
|
|
78
|
+
* @typeParam T - The custom qualifier type(s) to support. Defaults to {@link QualifierTypes.SystemQualifierType | SystemQualifierType}.
|
|
79
|
+
*
|
|
80
|
+
* @example Creating a factory with custom qualifier types
|
|
81
|
+
* ```typescript
|
|
82
|
+
* // Define a custom qualifier type
|
|
83
|
+
* class CustomQualifierType extends QualifierType {
|
|
84
|
+
* // ... implementation
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* // Define a discriminated union of all types
|
|
88
|
+
* type AppQualifierType = SystemQualifierType | CustomQualifierType;
|
|
89
|
+
*
|
|
90
|
+
* // Create a factory that handles custom types
|
|
91
|
+
* const customFactory: IConfigInitFactory<IAnyQualifierTypeConfig, CustomQualifierType> = {
|
|
92
|
+
* create(config) {
|
|
93
|
+
* // ... handle custom type creation
|
|
94
|
+
* }
|
|
95
|
+
* };
|
|
96
|
+
*
|
|
97
|
+
* // Create the combined factory
|
|
98
|
+
* const qualifierTypeFactory = new QualifierTypeFactory<AppQualifierType>([customFactory]);
|
|
99
|
+
*
|
|
100
|
+
* // The factory returns T | SystemQualifierType, supporting all types
|
|
101
|
+
* const result = qualifierTypeFactory.create(config); // Result<AppQualifierType | SystemQualifierType>
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* - The factory chains custom factories with the built-in factory
|
|
106
|
+
* - Custom factories are tried first, falling back to built-in types
|
|
107
|
+
* - The return type is a union of custom types (T) and system types
|
|
108
|
+
*
|
|
47
109
|
* @public
|
|
48
110
|
*/
|
|
49
|
-
export declare class QualifierTypeFactory extends ChainedConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig,
|
|
111
|
+
export declare class QualifierTypeFactory<T extends QualifierType = SystemQualifierType> extends ChainedConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T | SystemQualifierType> {
|
|
50
112
|
/**
|
|
51
113
|
* Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.
|
|
52
|
-
* @param factories -
|
|
53
|
-
*
|
|
114
|
+
* @param factories - Array of factories for custom qualifier types. Can be:
|
|
115
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
116
|
+
* - {@link Config.QualifierTypeFactoryFunction | Factory functions}
|
|
117
|
+
* - A mix of both
|
|
118
|
+
* These are tried in order before falling back to built-in types.
|
|
119
|
+
* @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always appended to handle
|
|
120
|
+
* system qualifier types (Language, Territory, Literal).
|
|
121
|
+
*/
|
|
122
|
+
constructor(factories: Array<IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> | QualifierTypeFactoryFunction<T>>);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A factory that validates and creates {@link QualifierTypes.QualifierType | QualifierType} instances
|
|
126
|
+
* from weakly-typed configuration objects. This factory accepts configurations with unvalidated
|
|
127
|
+
* string properties and validates them before delegating to the underlying factory chain.
|
|
128
|
+
*
|
|
129
|
+
* This pattern is useful at package boundaries where type identity issues may occur with
|
|
130
|
+
* branded types across different package instances.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* // Accept weakly-typed config from external source
|
|
135
|
+
* const validatingFactory = new ValidatingQualifierTypeFactory([customFactory]);
|
|
136
|
+
*
|
|
137
|
+
* // Config can have plain string types instead of branded types
|
|
138
|
+
* const config = {
|
|
139
|
+
* name: 'my-qualifier', // plain string, not QualifierTypeName
|
|
140
|
+
* systemType: 'custom', // plain string
|
|
141
|
+
* configuration: { ... }
|
|
142
|
+
* };
|
|
143
|
+
*
|
|
144
|
+
* const result = validatingFactory.create(config); // Validates and converts internally
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* @public
|
|
148
|
+
*/
|
|
149
|
+
export declare class ValidatingQualifierTypeFactory<T extends QualifierType = SystemQualifierType> implements IConfigInitFactory<unknown, T | SystemQualifierType> {
|
|
150
|
+
private readonly _innerFactory;
|
|
151
|
+
/**
|
|
152
|
+
* Constructor for a validating qualifier type factory.
|
|
153
|
+
* @param factories - Array of factories for custom qualifier types. Can be:
|
|
154
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
155
|
+
* - {@link Config.QualifierTypeFactoryFunction | Factory functions}
|
|
156
|
+
* - A mix of both
|
|
54
157
|
*/
|
|
55
|
-
constructor(factories: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig,
|
|
158
|
+
constructor(factories: Array<IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> | QualifierTypeFactoryFunction<T>>);
|
|
159
|
+
/**
|
|
160
|
+
* Creates a qualifier type from a weakly-typed configuration object.
|
|
161
|
+
* @param config - The configuration object to validate and use for creation.
|
|
162
|
+
* @returns A result containing the new qualifier type if successful.
|
|
163
|
+
*/
|
|
164
|
+
create(config: unknown): Result<T | SystemQualifierType>;
|
|
56
165
|
}
|
|
57
166
|
/**
|
|
58
167
|
* A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.
|
|
@@ -70,9 +179,39 @@ export declare class BuiltInResourceTypeFactory implements IConfigInitFactory<Re
|
|
|
70
179
|
export declare class ResourceTypeFactory extends ChainedConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {
|
|
71
180
|
/**
|
|
72
181
|
* Constructor for a resource type factory.
|
|
73
|
-
* @param factories -
|
|
182
|
+
* @param factories - Array of factories for resource types. Can be:
|
|
183
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
184
|
+
* - {@link Config.ResourceTypeFactoryFunction | Factory functions}
|
|
185
|
+
* - A mix of both
|
|
74
186
|
* @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.
|
|
75
187
|
*/
|
|
76
|
-
constructor(factories: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>
|
|
188
|
+
constructor(factories: Array<IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> | ResourceTypeFactoryFunction>);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A factory that validates and creates {@link ResourceTypes.ResourceType | ResourceType} instances
|
|
192
|
+
* from weakly-typed configuration objects. This factory accepts configurations with unvalidated
|
|
193
|
+
* string properties and validates them before delegating to the underlying factory chain.
|
|
194
|
+
*
|
|
195
|
+
* This pattern is useful at package boundaries where type identity issues may occur with
|
|
196
|
+
* branded types across different package instances.
|
|
197
|
+
*
|
|
198
|
+
* @public
|
|
199
|
+
*/
|
|
200
|
+
export declare class ValidatingResourceTypeFactory implements IConfigInitFactory<unknown, ResourceType> {
|
|
201
|
+
private readonly _innerFactory;
|
|
202
|
+
/**
|
|
203
|
+
* Constructor for a validating resource type factory.
|
|
204
|
+
* @param factories - Array of factories for resource types. Can be:
|
|
205
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
206
|
+
* - {@link Config.ResourceTypeFactoryFunction | Factory functions}
|
|
207
|
+
* - A mix of both
|
|
208
|
+
*/
|
|
209
|
+
constructor(factories: Array<IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> | ResourceTypeFactoryFunction>);
|
|
210
|
+
/**
|
|
211
|
+
* Creates a resource type from a weakly-typed configuration object.
|
|
212
|
+
* @param config - The configuration object to validate and use for creation.
|
|
213
|
+
* @returns A result containing the new resource type if successful.
|
|
214
|
+
*/
|
|
215
|
+
create(config: unknown): Result<ResourceType>;
|
|
77
216
|
}
|
|
78
217
|
//# sourceMappingURL=configInitFactory.d.ts.map
|
|
@@ -54,10 +54,34 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
54
54
|
};
|
|
55
55
|
})();
|
|
56
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.ResourceTypeFactory = exports.BuiltInResourceTypeFactory = exports.QualifierTypeFactory = exports.BuiltInQualifierTypeFactory = exports.ChainedConfigInitFactory = void 0;
|
|
57
|
+
exports.ValidatingResourceTypeFactory = exports.ResourceTypeFactory = exports.BuiltInResourceTypeFactory = exports.ValidatingQualifierTypeFactory = exports.QualifierTypeFactory = exports.BuiltInQualifierTypeFactory = exports.ChainedConfigInitFactory = void 0;
|
|
58
|
+
exports.createQualifierTypeFactory = createQualifierTypeFactory;
|
|
59
|
+
exports.createResourceTypeFactory = createResourceTypeFactory;
|
|
58
60
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
59
61
|
const QualifierTypes = __importStar(require("../qualifier-types"));
|
|
60
62
|
const ResourceTypes = __importStar(require("../resource-types"));
|
|
63
|
+
/**
|
|
64
|
+
* Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a factory function.
|
|
65
|
+
* @param fn - The factory function to wrap.
|
|
66
|
+
* @returns An `IConfigInitFactory` instance that delegates to the function.
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
function createQualifierTypeFactory(fn) {
|
|
70
|
+
return {
|
|
71
|
+
create: fn
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a resource type factory function.
|
|
76
|
+
* @param fn - The factory function to wrap.
|
|
77
|
+
* @returns An `IConfigInitFactory` instance that delegates to the function.
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
function createResourceTypeFactory(fn) {
|
|
81
|
+
return {
|
|
82
|
+
create: fn
|
|
83
|
+
};
|
|
84
|
+
}
|
|
61
85
|
/**
|
|
62
86
|
* A factory that chains multiple factories together.
|
|
63
87
|
* @public
|
|
@@ -87,7 +111,10 @@ class ChainedConfigInitFactory {
|
|
|
87
111
|
}
|
|
88
112
|
exports.ChainedConfigInitFactory = ChainedConfigInitFactory;
|
|
89
113
|
/**
|
|
90
|
-
* A factory that creates a {@link QualifierTypes.
|
|
114
|
+
* A factory that creates a {@link QualifierTypes.SystemQualifierType | SystemQualifierType} from
|
|
115
|
+
* {@link QualifierTypes.Config.IAnyQualifierTypeConfig | any qualifier type configuration}.
|
|
116
|
+
* @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}
|
|
117
|
+
* if successful, `Failure` with an error message otherwise.
|
|
91
118
|
* @public
|
|
92
119
|
*/
|
|
93
120
|
class BuiltInQualifierTypeFactory {
|
|
@@ -101,21 +128,112 @@ class BuiltInQualifierTypeFactory {
|
|
|
101
128
|
}
|
|
102
129
|
exports.BuiltInQualifierTypeFactory = BuiltInQualifierTypeFactory;
|
|
103
130
|
/**
|
|
104
|
-
* A factory that creates
|
|
105
|
-
*
|
|
131
|
+
* A factory that creates {@link QualifierTypes.QualifierType | QualifierType} instances from configuration,
|
|
132
|
+
* supporting both built-in system types and custom external types.
|
|
133
|
+
*
|
|
134
|
+
* This factory allows external consumers to extend the qualifier type system with their own custom types
|
|
135
|
+
* while maintaining support for all built-in types (Language, Territory, Literal).
|
|
136
|
+
*
|
|
137
|
+
* @typeParam T - The custom qualifier type(s) to support. Defaults to {@link QualifierTypes.SystemQualifierType | SystemQualifierType}.
|
|
138
|
+
*
|
|
139
|
+
* @example Creating a factory with custom qualifier types
|
|
140
|
+
* ```typescript
|
|
141
|
+
* // Define a custom qualifier type
|
|
142
|
+
* class CustomQualifierType extends QualifierType {
|
|
143
|
+
* // ... implementation
|
|
144
|
+
* }
|
|
145
|
+
*
|
|
146
|
+
* // Define a discriminated union of all types
|
|
147
|
+
* type AppQualifierType = SystemQualifierType | CustomQualifierType;
|
|
148
|
+
*
|
|
149
|
+
* // Create a factory that handles custom types
|
|
150
|
+
* const customFactory: IConfigInitFactory<IAnyQualifierTypeConfig, CustomQualifierType> = {
|
|
151
|
+
* create(config) {
|
|
152
|
+
* // ... handle custom type creation
|
|
153
|
+
* }
|
|
154
|
+
* };
|
|
155
|
+
*
|
|
156
|
+
* // Create the combined factory
|
|
157
|
+
* const qualifierTypeFactory = new QualifierTypeFactory<AppQualifierType>([customFactory]);
|
|
158
|
+
*
|
|
159
|
+
* // The factory returns T | SystemQualifierType, supporting all types
|
|
160
|
+
* const result = qualifierTypeFactory.create(config); // Result<AppQualifierType | SystemQualifierType>
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @remarks
|
|
164
|
+
* - The factory chains custom factories with the built-in factory
|
|
165
|
+
* - Custom factories are tried first, falling back to built-in types
|
|
166
|
+
* - The return type is a union of custom types (T) and system types
|
|
167
|
+
*
|
|
106
168
|
* @public
|
|
107
169
|
*/
|
|
108
170
|
class QualifierTypeFactory extends ChainedConfigInitFactory {
|
|
109
171
|
/**
|
|
110
172
|
* Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.
|
|
111
|
-
* @param factories -
|
|
112
|
-
*
|
|
173
|
+
* @param factories - Array of factories for custom qualifier types. Can be:
|
|
174
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
175
|
+
* - {@link Config.QualifierTypeFactoryFunction | Factory functions}
|
|
176
|
+
* - A mix of both
|
|
177
|
+
* These are tried in order before falling back to built-in types.
|
|
178
|
+
* @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always appended to handle
|
|
179
|
+
* system qualifier types (Language, Territory, Literal).
|
|
113
180
|
*/
|
|
114
181
|
constructor(factories) {
|
|
115
|
-
|
|
182
|
+
const normalizedFactories = factories.map((f) => typeof f === 'function' ? createQualifierTypeFactory(f) : f);
|
|
183
|
+
super([...normalizedFactories, new BuiltInQualifierTypeFactory()]);
|
|
116
184
|
}
|
|
117
185
|
}
|
|
118
186
|
exports.QualifierTypeFactory = QualifierTypeFactory;
|
|
187
|
+
/**
|
|
188
|
+
* A factory that validates and creates {@link QualifierTypes.QualifierType | QualifierType} instances
|
|
189
|
+
* from weakly-typed configuration objects. This factory accepts configurations with unvalidated
|
|
190
|
+
* string properties and validates them before delegating to the underlying factory chain.
|
|
191
|
+
*
|
|
192
|
+
* This pattern is useful at package boundaries where type identity issues may occur with
|
|
193
|
+
* branded types across different package instances.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* // Accept weakly-typed config from external source
|
|
198
|
+
* const validatingFactory = new ValidatingQualifierTypeFactory([customFactory]);
|
|
199
|
+
*
|
|
200
|
+
* // Config can have plain string types instead of branded types
|
|
201
|
+
* const config = {
|
|
202
|
+
* name: 'my-qualifier', // plain string, not QualifierTypeName
|
|
203
|
+
* systemType: 'custom', // plain string
|
|
204
|
+
* configuration: { ... }
|
|
205
|
+
* };
|
|
206
|
+
*
|
|
207
|
+
* const result = validatingFactory.create(config); // Validates and converts internally
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @public
|
|
211
|
+
*/
|
|
212
|
+
class ValidatingQualifierTypeFactory {
|
|
213
|
+
/**
|
|
214
|
+
* Constructor for a validating qualifier type factory.
|
|
215
|
+
* @param factories - Array of factories for custom qualifier types. Can be:
|
|
216
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
217
|
+
* - {@link Config.QualifierTypeFactoryFunction | Factory functions}
|
|
218
|
+
* - A mix of both
|
|
219
|
+
*/
|
|
220
|
+
constructor(factories) {
|
|
221
|
+
this._innerFactory = new QualifierTypeFactory(factories);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Creates a qualifier type from a weakly-typed configuration object.
|
|
225
|
+
* @param config - The configuration object to validate and use for creation.
|
|
226
|
+
* @returns A result containing the new qualifier type if successful.
|
|
227
|
+
*/
|
|
228
|
+
create(config) {
|
|
229
|
+
return QualifierTypes.Config.Convert.anyQualifierTypeConfig
|
|
230
|
+
.convert(config)
|
|
231
|
+
.onSuccess((validatedConfig) => {
|
|
232
|
+
return this._innerFactory.create(validatedConfig);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.ValidatingQualifierTypeFactory = ValidatingQualifierTypeFactory;
|
|
119
237
|
/**
|
|
120
238
|
* A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.
|
|
121
239
|
* @public
|
|
@@ -135,13 +253,50 @@ exports.BuiltInResourceTypeFactory = BuiltInResourceTypeFactory;
|
|
|
135
253
|
class ResourceTypeFactory extends ChainedConfigInitFactory {
|
|
136
254
|
/**
|
|
137
255
|
* Constructor for a resource type factory.
|
|
138
|
-
* @param factories -
|
|
256
|
+
* @param factories - Array of factories for resource types. Can be:
|
|
257
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
258
|
+
* - {@link Config.ResourceTypeFactoryFunction | Factory functions}
|
|
259
|
+
* - A mix of both
|
|
139
260
|
* @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.
|
|
140
261
|
*/
|
|
141
262
|
constructor(factories) {
|
|
142
263
|
factories = factories !== null && factories !== void 0 ? factories : [];
|
|
143
|
-
|
|
264
|
+
const normalizedFactories = factories.map((f) => typeof f === 'function' ? createResourceTypeFactory(f) : f);
|
|
265
|
+
super([...normalizedFactories, new BuiltInResourceTypeFactory()]);
|
|
144
266
|
}
|
|
145
267
|
}
|
|
146
268
|
exports.ResourceTypeFactory = ResourceTypeFactory;
|
|
269
|
+
/**
|
|
270
|
+
* A factory that validates and creates {@link ResourceTypes.ResourceType | ResourceType} instances
|
|
271
|
+
* from weakly-typed configuration objects. This factory accepts configurations with unvalidated
|
|
272
|
+
* string properties and validates them before delegating to the underlying factory chain.
|
|
273
|
+
*
|
|
274
|
+
* This pattern is useful at package boundaries where type identity issues may occur with
|
|
275
|
+
* branded types across different package instances.
|
|
276
|
+
*
|
|
277
|
+
* @public
|
|
278
|
+
*/
|
|
279
|
+
class ValidatingResourceTypeFactory {
|
|
280
|
+
/**
|
|
281
|
+
* Constructor for a validating resource type factory.
|
|
282
|
+
* @param factories - Array of factories for resource types. Can be:
|
|
283
|
+
* - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
|
|
284
|
+
* - {@link Config.ResourceTypeFactoryFunction | Factory functions}
|
|
285
|
+
* - A mix of both
|
|
286
|
+
*/
|
|
287
|
+
constructor(factories) {
|
|
288
|
+
this._innerFactory = new ResourceTypeFactory(factories);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Creates a resource type from a weakly-typed configuration object.
|
|
292
|
+
* @param config - The configuration object to validate and use for creation.
|
|
293
|
+
* @returns A result containing the new resource type if successful.
|
|
294
|
+
*/
|
|
295
|
+
create(config) {
|
|
296
|
+
return ResourceTypes.Config.Convert.resourceTypeConfig.convert(config).onSuccess((validatedConfig) => {
|
|
297
|
+
return this._innerFactory.create(validatedConfig);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
exports.ValidatingResourceTypeFactory = ValidatingResourceTypeFactory;
|
|
147
302
|
//# sourceMappingURL=configInitFactory.js.map
|
|
@@ -24,7 +24,7 @@ export interface ILanguageQualifierTypeConfig {
|
|
|
24
24
|
* determine the relationship between values when matching conditions and contexts.
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
|
-
export type LiteralValueHierarchyDecl<T extends string> =
|
|
27
|
+
export type LiteralValueHierarchyDecl<T extends string> = Record<T, T>;
|
|
28
28
|
/**
|
|
29
29
|
* Configuration for {@link QualifierTypes.TerritoryQualifierType | territory qualifier type} configuration.
|
|
30
30
|
* @public
|
|
@@ -16,7 +16,7 @@ export interface IQualifierTypeConvertContext {
|
|
|
16
16
|
* index from a supplied {@link QualifierTypes.Convert.IQualifierTypeConvertContext | conversion context}.
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
|
-
export declare const qualifierType: Converter<QualifierType
|
|
19
|
+
export declare const qualifierType: Converter<QualifierType<import("@fgv/ts-json-base").JsonObject>, IQualifierTypeConvertContext>;
|
|
20
20
|
/**
|
|
21
21
|
* Gets a converter for {@link QualifierTypes.ILiteralValueHierarchyCreateParams | ILiteralValueHierarchyCreateParams}
|
|
22
22
|
* objects with values validated by a supplied value converter.
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { Result } from '@fgv/ts-utils';
|
|
2
2
|
import * as Config from './config';
|
|
3
3
|
import { QualifierType } from './qualifierType';
|
|
4
|
+
import { LanguageQualifierType } from './languageQualifierType';
|
|
5
|
+
import { TerritoryQualifierType } from './territoryQualifierType';
|
|
6
|
+
import { LiteralQualifierType } from './literalQualifierType';
|
|
7
|
+
/**
|
|
8
|
+
* A discriminated union of all system qualifier types.
|
|
9
|
+
* This allows TypeScript to properly discriminate between specific qualifier type implementations
|
|
10
|
+
* and access their specific methods like getConfiguration().
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export type SystemQualifierType = LanguageQualifierType | TerritoryQualifierType | LiteralQualifierType;
|
|
4
14
|
/**
|
|
5
15
|
* Creates a {@link QualifierTypes.QualifierType | QualifierType} from a configuration object.
|
|
6
16
|
* This factory function determines the appropriate qualifier type based on the systemType
|
|
@@ -13,14 +23,14 @@ import { QualifierType } from './qualifierType';
|
|
|
13
23
|
*/
|
|
14
24
|
export declare function createQualifierTypeFromConfig(typeConfig: Config.IAnyQualifierTypeConfig): Result<QualifierType>;
|
|
15
25
|
/**
|
|
16
|
-
* Creates a {@link QualifierTypes.
|
|
26
|
+
* Creates a {@link QualifierTypes.SystemQualifierType | SystemQualifierType} from a system configuration object.
|
|
17
27
|
* This factory function determines the appropriate qualifier type based on the systemType
|
|
18
28
|
* and delegates to the appropriate type-specific createFromConfig method.
|
|
19
29
|
* @param typeConfig - The {@link QualifierTypes.Config.ISystemQualifierTypeConfig | configuration object}
|
|
20
30
|
* containing the name, systemType, and optional type-specific configuration.
|
|
21
|
-
* @returns `Success` with the new {@link QualifierTypes.
|
|
31
|
+
* @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}
|
|
22
32
|
* if successful, `Failure` with an error message otherwise.
|
|
23
33
|
* @public
|
|
24
34
|
*/
|
|
25
|
-
export declare function createQualifierTypeFromSystemConfig(typeConfig: Config.ISystemQualifierTypeConfig): Result<
|
|
35
|
+
export declare function createQualifierTypeFromSystemConfig(typeConfig: Config.ISystemQualifierTypeConfig): Result<SystemQualifierType>;
|
|
26
36
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -93,12 +93,12 @@ function createQualifierTypeFromConfig(typeConfig) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
|
-
* Creates a {@link QualifierTypes.
|
|
96
|
+
* Creates a {@link QualifierTypes.SystemQualifierType | SystemQualifierType} from a system configuration object.
|
|
97
97
|
* This factory function determines the appropriate qualifier type based on the systemType
|
|
98
98
|
* and delegates to the appropriate type-specific createFromConfig method.
|
|
99
99
|
* @param typeConfig - The {@link QualifierTypes.Config.ISystemQualifierTypeConfig | configuration object}
|
|
100
100
|
* containing the name, systemType, and optional type-specific configuration.
|
|
101
|
-
* @returns `Success` with the new {@link QualifierTypes.
|
|
101
|
+
* @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}
|
|
102
102
|
* if successful, `Failure` with an error message otherwise.
|
|
103
103
|
* @public
|
|
104
104
|
*/
|
|
@@ -2,7 +2,7 @@ import { Result } from '@fgv/ts-utils';
|
|
|
2
2
|
import { ConditionOperator, QualifierConditionValue, QualifierContextValue, QualifierMatchScore, QualifierTypeName } from '../common';
|
|
3
3
|
import { IQualifierTypeCreateParams, QualifierType } from './qualifierType';
|
|
4
4
|
import * as Config from './config';
|
|
5
|
-
import {
|
|
5
|
+
import { JsonCompatible } from '@fgv/ts-json-base';
|
|
6
6
|
/**
|
|
7
7
|
* Interface defining the parameters that can be used to create a new
|
|
8
8
|
* {@link QualifierTypes.LanguageQualifierType | LanguageQualifierType}.
|
|
@@ -25,7 +25,7 @@ export interface ILanguageQualifierTypeCreateParams extends Partial<IQualifierTy
|
|
|
25
25
|
* Accepts a list of language tags in the context by default.
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
|
-
export declare class LanguageQualifierType extends QualifierType {
|
|
28
|
+
export declare class LanguageQualifierType extends QualifierType<JsonCompatible<Config.ILanguageQualifierTypeConfig>> {
|
|
29
29
|
/**
|
|
30
30
|
* {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
|
|
31
31
|
*/
|
|
@@ -68,11 +68,11 @@ export declare class LanguageQualifierType extends QualifierType {
|
|
|
68
68
|
/**
|
|
69
69
|
* {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
70
70
|
*/
|
|
71
|
-
getConfigurationJson(): Result<
|
|
71
|
+
getConfigurationJson(): Result<JsonCompatible<Config.ISystemLanguageQualifierTypeConfig>>;
|
|
72
72
|
/**
|
|
73
73
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
74
74
|
*/
|
|
75
|
-
validateConfigurationJson(from: unknown): Result<
|
|
75
|
+
validateConfigurationJson(from: unknown): Result<JsonCompatible<Config.ISystemLanguageQualifierTypeConfig>>;
|
|
76
76
|
/**
|
|
77
77
|
* Validates a {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | strongly typed configuration object}
|
|
78
78
|
* for this qualifier type.
|
|
@@ -146,9 +146,7 @@ class LanguageQualifierType extends qualifierType_1.QualifierType {
|
|
|
146
146
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
147
147
|
*/
|
|
148
148
|
validateConfigurationJson(from) {
|
|
149
|
-
return Config.Convert.systemLanguageQualifierTypeConfig
|
|
150
|
-
.convert(from)
|
|
151
|
-
.onSuccess((config) => (0, ts_utils_1.succeed)(config));
|
|
149
|
+
return Config.Convert.systemLanguageQualifierTypeConfig.convert(from);
|
|
152
150
|
}
|
|
153
151
|
/**
|
|
154
152
|
* Validates a {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | strongly typed configuration object}
|
|
@@ -157,7 +155,7 @@ class LanguageQualifierType extends qualifierType_1.QualifierType {
|
|
|
157
155
|
* @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
|
|
158
156
|
*/
|
|
159
157
|
validateConfiguration(from) {
|
|
160
|
-
return
|
|
158
|
+
return Config.Convert.systemLanguageQualifierTypeConfig.convert(from);
|
|
161
159
|
}
|
|
162
160
|
/**
|
|
163
161
|
* Matches a single language condition against a single language context value using
|
|
@@ -3,7 +3,7 @@ import { ConditionOperator, QualifierConditionValue, QualifierContextValue, Qual
|
|
|
3
3
|
import { QualifierType } from './qualifierType';
|
|
4
4
|
import { LiteralValueHierarchy } from './literalValueHierarchy';
|
|
5
5
|
import * as Config from './config';
|
|
6
|
-
import {
|
|
6
|
+
import { JsonCompatible } from '@fgv/ts-json-base';
|
|
7
7
|
/**
|
|
8
8
|
* Interface defining the parameters that can be used to create a new
|
|
9
9
|
* {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType}.
|
|
@@ -44,7 +44,7 @@ export interface ILiteralQualifierTypeCreateParams {
|
|
|
44
44
|
* optionally case-sensitive or matching against an ordered list of values at runtime.
|
|
45
45
|
* @public
|
|
46
46
|
*/
|
|
47
|
-
export declare class LiteralQualifierType extends QualifierType {
|
|
47
|
+
export declare class LiteralQualifierType extends QualifierType<JsonCompatible<Config.ILiteralQualifierTypeConfig>> {
|
|
48
48
|
/**
|
|
49
49
|
* {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
|
|
50
50
|
*/
|
|
@@ -93,11 +93,11 @@ export declare class LiteralQualifierType extends QualifierType {
|
|
|
93
93
|
/**
|
|
94
94
|
* {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
95
95
|
*/
|
|
96
|
-
getConfigurationJson(): Result<
|
|
96
|
+
getConfigurationJson(): Result<JsonCompatible<Config.ISystemLiteralQualifierTypeConfig>>;
|
|
97
97
|
/**
|
|
98
98
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
99
99
|
*/
|
|
100
|
-
validateConfigurationJson(from: unknown): Result<
|
|
100
|
+
validateConfigurationJson(from: unknown): Result<JsonCompatible<Config.ISystemLiteralQualifierTypeConfig>>;
|
|
101
101
|
/**
|
|
102
102
|
* Validates a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
|
|
103
103
|
* for this qualifier type.
|
|
@@ -155,9 +155,7 @@ class LiteralQualifierType extends qualifierType_1.QualifierType {
|
|
|
155
155
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
156
156
|
*/
|
|
157
157
|
validateConfigurationJson(from) {
|
|
158
|
-
return Config.Convert.systemLiteralQualifierTypeConfig
|
|
159
|
-
.convert(from)
|
|
160
|
-
.onSuccess((config) => (0, ts_utils_1.succeed)(config));
|
|
158
|
+
return Config.Convert.systemLiteralQualifierTypeConfig.convert(from);
|
|
161
159
|
}
|
|
162
160
|
/**
|
|
163
161
|
* Validates a {@link QualifierTypes.Config.ISystemLiteralQualifierTypeConfig | strongly typed configuration object}
|
|
@@ -166,7 +164,7 @@ class LiteralQualifierType extends qualifierType_1.QualifierType {
|
|
|
166
164
|
* @returns `Success` with the validated configuration if successful, `Failure` with an error message otherwise.
|
|
167
165
|
*/
|
|
168
166
|
validateConfiguration(from) {
|
|
169
|
-
return
|
|
167
|
+
return Config.Convert.systemLiteralQualifierTypeConfig.convert(from);
|
|
170
168
|
}
|
|
171
169
|
/**
|
|
172
170
|
* {@inheritdoc QualifierTypes.QualifierType._matchOne}
|
|
@@ -17,7 +17,7 @@ export interface ILiteralValue<T extends string> {
|
|
|
17
17
|
*/
|
|
18
18
|
export interface ILiteralValueHierarchyCreateParams<T extends string = string> {
|
|
19
19
|
values: ReadonlyArray<T>;
|
|
20
|
-
hierarchy?: LiteralValueHierarchyDecl<T
|
|
20
|
+
hierarchy?: Partial<LiteralValueHierarchyDecl<T>>;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* A class that implements a hierarchy of literal values. The hierarchy is defined as a
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Collections, ICollectible, Result } from '@fgv/ts-utils';
|
|
2
2
|
import { ConditionOperator, QualifierConditionValue, QualifierContextValue, QualifierMatchScore, QualifierTypeIndex, QualifierTypeName } from '../common';
|
|
3
|
-
import { JsonObject } from '@fgv/ts-json-base';
|
|
3
|
+
import { JsonCompatible, JsonObject } from '@fgv/ts-json-base';
|
|
4
|
+
import * as Config from './config';
|
|
4
5
|
/**
|
|
5
6
|
* Interface for a qualifier type. A qualifier type implements the build and
|
|
6
7
|
* runtime semantics for some class of related qualifiers (e.g. language,
|
|
7
8
|
* territories, etc).
|
|
8
9
|
* @public
|
|
9
10
|
*/
|
|
10
|
-
export interface IQualifierType extends ICollectible<QualifierTypeName, QualifierTypeIndex> {
|
|
11
|
+
export interface IQualifierType<TCFGJSON extends JsonObject = JsonObject> extends ICollectible<QualifierTypeName, QualifierTypeIndex> {
|
|
11
12
|
/**
|
|
12
13
|
* The name of the qualifier type.
|
|
13
14
|
*/
|
|
@@ -82,13 +83,13 @@ export interface IQualifierType extends ICollectible<QualifierTypeName, Qualifie
|
|
|
82
83
|
* Gets the configuration for this qualifier type.
|
|
83
84
|
* @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
|
|
84
85
|
*/
|
|
85
|
-
getConfigurationJson(): Result<
|
|
86
|
+
getConfigurationJson(): Result<JsonCompatible<Config.IQualifierTypeConfig<TCFGJSON>>>;
|
|
86
87
|
/**
|
|
87
88
|
* Validates configuration JSON data for this qualifier type.
|
|
88
89
|
* @param from - The unknown data to validate as configuration JSON.
|
|
89
90
|
* @returns `Success` with validated JSON configuration if valid, `Failure` with an error message otherwise.
|
|
90
91
|
*/
|
|
91
|
-
validateConfigurationJson(from: unknown): Result<
|
|
92
|
+
validateConfigurationJson(from: unknown): Result<JsonCompatible<Config.IQualifierTypeConfig<TCFGJSON>>>;
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* Parameters used to create a base {@link QualifierTypes.QualifierType | qualifier type}.
|
|
@@ -114,7 +115,7 @@ export interface IQualifierTypeCreateParams {
|
|
|
114
115
|
* the {@link QualifierTypes.IQualifierType | IQualifierType} interface.
|
|
115
116
|
* @public
|
|
116
117
|
*/
|
|
117
|
-
export declare abstract class QualifierType implements IQualifierType {
|
|
118
|
+
export declare abstract class QualifierType<TCFGJSON extends JsonObject = JsonObject> implements IQualifierType<TCFGJSON> {
|
|
118
119
|
/**
|
|
119
120
|
* {@inheritdoc QualifierTypes.IQualifierType.name}
|
|
120
121
|
*/
|
|
@@ -171,11 +172,11 @@ export declare abstract class QualifierType implements IQualifierType {
|
|
|
171
172
|
/**
|
|
172
173
|
* {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
173
174
|
*/
|
|
174
|
-
abstract getConfigurationJson(): Result<
|
|
175
|
+
abstract getConfigurationJson(): Result<JsonCompatible<Config.IQualifierTypeConfig<TCFGJSON>>>;
|
|
175
176
|
/**
|
|
176
177
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
177
178
|
*/
|
|
178
|
-
abstract validateConfigurationJson(from: unknown): Result<
|
|
179
|
+
abstract validateConfigurationJson(from: unknown): Result<JsonCompatible<Config.IQualifierTypeConfig<TCFGJSON>>>;
|
|
179
180
|
/**
|
|
180
181
|
* {@inheritdoc QualifierTypes.IQualifierType.setIndex}
|
|
181
182
|
*/
|
|
@@ -3,7 +3,7 @@ import { QualifierConditionValue, QualifierContextValue, QualifierMatchScore, Co
|
|
|
3
3
|
import { QualifierType } from './qualifierType';
|
|
4
4
|
import { LiteralValueHierarchy } from './literalValueHierarchy';
|
|
5
5
|
import * as Config from './config';
|
|
6
|
-
import {
|
|
6
|
+
import { JsonCompatible } from '@fgv/ts-json-base';
|
|
7
7
|
/**
|
|
8
8
|
* Parameters used to create a new {@link QualifierTypes.TerritoryQualifierType | TerritoryQualifierType} instance.
|
|
9
9
|
* @public
|
|
@@ -42,7 +42,7 @@ export interface ITerritoryQualifierTypeCreateParams {
|
|
|
42
42
|
* implementation handles incorrect casing.
|
|
43
43
|
* @public
|
|
44
44
|
*/
|
|
45
|
-
export declare class TerritoryQualifierType extends QualifierType {
|
|
45
|
+
export declare class TerritoryQualifierType extends QualifierType<JsonCompatible<Config.ITerritoryQualifierTypeConfig>> {
|
|
46
46
|
/**
|
|
47
47
|
* {@inheritdoc QualifierTypes.IQualifierType.systemTypeName}
|
|
48
48
|
*/
|
|
@@ -89,17 +89,19 @@ export declare class TerritoryQualifierType extends QualifierType {
|
|
|
89
89
|
*/
|
|
90
90
|
static createFromConfig(config: Config.IQualifierTypeConfig<Config.ITerritoryQualifierTypeConfig>): Result<TerritoryQualifierType>;
|
|
91
91
|
/**
|
|
92
|
-
* {@
|
|
92
|
+
* Gets the {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration}
|
|
93
|
+
* for this qualifier type.
|
|
94
|
+
* @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
|
|
93
95
|
*/
|
|
94
96
|
getConfiguration(): Result<Config.ISystemTerritoryQualifierTypeConfig>;
|
|
95
97
|
/**
|
|
96
98
|
* {@inheritdoc QualifierTypes.IQualifierType.getConfigurationJson}
|
|
97
99
|
*/
|
|
98
|
-
getConfigurationJson(): Result<
|
|
100
|
+
getConfigurationJson(): Result<JsonCompatible<Config.ISystemTerritoryQualifierTypeConfig>>;
|
|
99
101
|
/**
|
|
100
102
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
101
103
|
*/
|
|
102
|
-
validateConfigurationJson(from: unknown): Result<
|
|
104
|
+
validateConfigurationJson(from: unknown): Result<JsonCompatible<Config.ISystemTerritoryQualifierTypeConfig>>;
|
|
103
105
|
/**
|
|
104
106
|
* Validates a {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration object}
|
|
105
107
|
* for this qualifier type.
|
|
@@ -147,7 +147,9 @@ class TerritoryQualifierType extends qualifierType_1.QualifierType {
|
|
|
147
147
|
}).onSuccess(TerritoryQualifierType.create);
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
* {@
|
|
150
|
+
* Gets the {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration}
|
|
151
|
+
* for this qualifier type.
|
|
152
|
+
* @returns `Success` with the configuration if successful, `Failure` with an error message otherwise.
|
|
151
153
|
*/
|
|
152
154
|
getConfiguration() {
|
|
153
155
|
return this.getConfigurationJson().onSuccess((json) => Config.Convert.systemTerritoryQualifierTypeConfig.convert(json));
|
|
@@ -170,9 +172,7 @@ class TerritoryQualifierType extends qualifierType_1.QualifierType {
|
|
|
170
172
|
* {@inheritdoc QualifierTypes.IQualifierType.validateConfigurationJson}
|
|
171
173
|
*/
|
|
172
174
|
validateConfigurationJson(from) {
|
|
173
|
-
return Config.Convert.systemTerritoryQualifierTypeConfig
|
|
174
|
-
.convert(from)
|
|
175
|
-
.onSuccess((config) => (0, ts_utils_1.succeed)(config));
|
|
175
|
+
return Config.Convert.systemTerritoryQualifierTypeConfig.convert(from);
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* Validates a {@link QualifierTypes.Config.ISystemTerritoryQualifierTypeConfig | strongly typed configuration object}
|
|
@@ -4,5 +4,5 @@ import { IResourceTypeConfig } from './json';
|
|
|
4
4
|
* @returns A `Converter` for {@link ResourceTypes.Config.IResourceTypeConfig | ResourceTypeConfig} objects.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export declare const resourceTypeConfig: import("@fgv/ts-utils").ObjectConverter<IResourceTypeConfig
|
|
7
|
+
export declare const resourceTypeConfig: import("@fgv/ts-utils").ObjectConverter<IResourceTypeConfig<import("@fgv/ts-json-base").JsonObject>, unknown>;
|
|
8
8
|
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -3,9 +3,9 @@ import { JsonObject } from '@fgv/ts-json-base';
|
|
|
3
3
|
* Configuration for a {@link ResourceTypes.ResourceType | resource type}.
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export interface IResourceTypeConfig {
|
|
6
|
+
export interface IResourceTypeConfig<T extends JsonObject = JsonObject> {
|
|
7
7
|
name: string;
|
|
8
8
|
typeName: string;
|
|
9
|
-
template?:
|
|
9
|
+
template?: T;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=json.d.ts.map
|
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-29",
|
|
4
4
|
"description": "Multi-dimensional Resource Runtime",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-res.d.ts",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"@rushstack/heft-node-rig": "2.9.5",
|
|
45
45
|
"@types/heft-jest": "1.0.6",
|
|
46
46
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
47
|
-
"@fgv/ts-utils-jest": "5.0.0-
|
|
48
|
-
"@fgv/ts-extras": "5.0.0-
|
|
47
|
+
"@fgv/ts-utils-jest": "5.0.0-29",
|
|
48
|
+
"@fgv/ts-extras": "5.0.0-29"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"luxon": "^3.7.2",
|
|
52
52
|
"fflate": "~0.8.2",
|
|
53
|
-
"@fgv/ts-utils": "5.0.0-
|
|
54
|
-
"@fgv/ts-
|
|
55
|
-
"@fgv/ts-
|
|
56
|
-
"@fgv/ts-json": "5.0.0-
|
|
53
|
+
"@fgv/ts-utils": "5.0.0-29",
|
|
54
|
+
"@fgv/ts-json-base": "5.0.0-29",
|
|
55
|
+
"@fgv/ts-bcp47": "5.0.0-29",
|
|
56
|
+
"@fgv/ts-json": "5.0.0-29"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "heft build --clean",
|