@fgv/ts-res 5.0.0-10 → 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.
Files changed (35) hide show
  1. package/dist/ts-res.d.ts +132 -4
  2. package/lib/packlets/common/helpers/resources.d.ts +7 -0
  3. package/lib/packlets/common/helpers/resources.d.ts.map +1 -1
  4. package/lib/packlets/common/helpers/resources.js +12 -0
  5. package/lib/packlets/common/helpers/resources.js.map +1 -1
  6. package/lib/packlets/config/configInitFactory.d.ts +78 -0
  7. package/lib/packlets/config/configInitFactory.d.ts.map +1 -0
  8. package/lib/packlets/config/configInitFactory.js +147 -0
  9. package/lib/packlets/config/configInitFactory.js.map +1 -0
  10. package/lib/packlets/config/index.d.ts +1 -0
  11. package/lib/packlets/config/index.d.ts.map +1 -1
  12. package/lib/packlets/config/index.js +1 -0
  13. package/lib/packlets/config/index.js.map +1 -1
  14. package/lib/packlets/config/systemConfiguration.d.ts +16 -3
  15. package/lib/packlets/config/systemConfiguration.d.ts.map +1 -1
  16. package/lib/packlets/config/systemConfiguration.js +19 -40
  17. package/lib/packlets/config/systemConfiguration.js.map +1 -1
  18. package/lib/packlets/qualifier-types/config/json.d.ts +13 -0
  19. package/lib/packlets/qualifier-types/config/json.d.ts.map +1 -1
  20. package/lib/packlets/qualifier-types/config/json.js +11 -0
  21. package/lib/packlets/qualifier-types/config/json.js.map +1 -1
  22. package/lib/packlets/resources/resource.d.ts +5 -1
  23. package/lib/packlets/resources/resource.d.ts.map +1 -1
  24. package/lib/packlets/resources/resource.js +1 -0
  25. package/lib/packlets/resources/resource.js.map +1 -1
  26. package/lib/packlets/runtime/compiledResourceCollection.d.ts.map +1 -1
  27. package/lib/packlets/runtime/compiledResourceCollection.js +7 -0
  28. package/lib/packlets/runtime/compiledResourceCollection.js.map +1 -1
  29. package/lib/packlets/runtime/iResourceManager.d.ts +2 -0
  30. package/lib/packlets/runtime/iResourceManager.d.ts.map +1 -1
  31. package/lib/packlets/runtime/iResourceManager.js.map +1 -1
  32. package/lib/packlets/runtime/validate.d.ts.map +1 -1
  33. package/lib/packlets/runtime/validate.js +1 -0
  34. package/lib/packlets/runtime/validate.js.map +1 -1
  35. 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
 
@@ -2488,6 +2533,14 @@ declare class FsItemImporter implements IImporter {
2488
2533
  */
2489
2534
  declare type FsItemResultDetail = 'failed' | 'skipped' | 'succeeded';
2490
2535
 
2536
+ /**
2537
+ * Gets the name for a resource ID.
2538
+ * @param id - The resource ID to get the name for.
2539
+ * @returns The resource name if found, or undefined if not.
2540
+ * @public
2541
+ */
2542
+ declare function getNameForResourceId(id: string | undefined): Result<ResourceName>;
2543
+
2491
2544
  /**
2492
2545
  * Returns the {@link Config.Model.ISystemConfiguration | system configuration} declaration for the
2493
2546
  * specified predefined system configuration.
@@ -2529,7 +2582,8 @@ declare namespace Helpers {
2529
2582
  IQualifierDefaultValueTokenParts,
2530
2583
  splitResourceId,
2531
2584
  joinResourceIds,
2532
- joinOptionalResourceIds
2585
+ joinOptionalResourceIds,
2586
+ getNameForResourceId
2533
2587
  }
2534
2588
  }
2535
2589
  export { Helpers }
@@ -2568,6 +2622,12 @@ declare interface IAbstractDecisionCreateParams {
2568
2622
  index?: number;
2569
2623
  }
2570
2624
 
2625
+ /**
2626
+ * A union of all qualifier type configurations.
2627
+ * @public
2628
+ */
2629
+ declare type IAnyQualifierTypeConfig = IQualifierTypeConfig | ISystemQualifierTypeConfig;
2630
+
2571
2631
  /**
2572
2632
  * A complete resource bundle that encapsulates built resources, configuration, and metadata.
2573
2633
  * Bundles provide a portable, integrity-verified way to distribute pre-compiled resource collections.
@@ -3255,6 +3315,19 @@ declare interface IConditionTokenParts {
3255
3315
  value: string;
3256
3316
  }
3257
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
+
3258
3331
  /**
3259
3332
  * Declared context for a resource container.
3260
3333
  * @public
@@ -4503,6 +4576,8 @@ declare interface IReducedCandidate {
4503
4576
  declare interface IResource {
4504
4577
  /** The resource identifier */
4505
4578
  readonly id: string;
4579
+ /** The resource name */
4580
+ readonly name: string;
4506
4581
  /** The resource type */
4507
4582
  readonly resourceType: ResourceType;
4508
4583
  /** The decision used to select candidates */
@@ -4981,6 +5056,15 @@ declare function isResourceTreeLeafInit<T>(init: ResourceTreeNodeInit<T>): init
4981
5056
  */
4982
5057
  declare function isResourceTreeRootOrNodeInit<T>(init: ResourceTreeNodeInit<T> | IResourceTreeRootInit<T>): init is IResourceTreeBranchInit<T>;
4983
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
+
4984
5068
  /**
4985
5069
  * Determines whether a number is a valid condition index.
4986
5070
  * @param index - the number to validate
@@ -5227,6 +5311,8 @@ declare interface ISystemConfigurationInitParams {
5227
5311
  * Use `null` as the value to remove an existing default value.
5228
5312
  */
5229
5313
  qualifierDefaultValues?: Record<string, string | null>;
5314
+ qualifierTypeFactory?: IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, QualifierType>;
5315
+ resourceTypeFactory?: IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType>;
5230
5316
  }
5231
5317
 
5232
5318
  /**
@@ -5961,6 +6047,7 @@ declare namespace Model {
5961
6047
 
5962
6048
  declare namespace Model_2 {
5963
6049
  export {
6050
+ isSystemQualifierTypeConfig,
5964
6051
  IQualifierTypeConfig,
5965
6052
  ILanguageQualifierTypeConfig,
5966
6053
  ITerritoryQualifierTypeConfig,
@@ -5968,7 +6055,8 @@ declare namespace Model_2 {
5968
6055
  ISystemLanguageQualifierTypeConfig,
5969
6056
  ISystemTerritoryQualifierTypeConfig,
5970
6057
  ISystemLiteralQualifierTypeConfig,
5971
- ISystemQualifierTypeConfig
6058
+ ISystemQualifierTypeConfig,
6059
+ IAnyQualifierTypeConfig
5972
6060
  }
5973
6061
  }
5974
6062
 
@@ -6661,6 +6749,20 @@ declare class QualifierTypeCollector extends ValidatingConvertingCollector<Quali
6661
6749
  protected static _toQualifierType(from: unknown): Result<QualifierType>;
6662
6750
  }
6663
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
+
6664
6766
  /**
6665
6767
  * Branded number representing a validated qualifier type index.
6666
6768
  * @public
@@ -6890,6 +6992,10 @@ export declare class Resource implements IResource {
6890
6992
  * The unique {@link ResourceId | id} of the resource.
6891
6993
  */
6892
6994
  readonly id: ResourceId;
6995
+ /**
6996
+ * The name of the resource.
6997
+ */
6998
+ readonly name: ResourceName;
6893
6999
  /**
6894
7000
  * The {@link ResourceTypes.ResourceType | type} of the resource.
6895
7001
  */
@@ -8140,6 +8246,20 @@ declare class ResourceTypeCollector extends ValidatingCollector<ResourceType> {
8140
8246
  */
8141
8247
  declare const resourceTypeConfig: ObjectConverter<IResourceTypeConfig, unknown>;
8142
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
+
8143
8263
  /**
8144
8264
  * Branded number representing a validated resource type index.
8145
8265
  * @public
@@ -8367,7 +8487,7 @@ declare class SystemConfiguration {
8367
8487
  * @param config - The {@link Config.Model.ISystemConfiguration | system configuration} to use.
8368
8488
  * @public
8369
8489
  */
8370
- protected constructor(config: ISystemConfiguration);
8490
+ protected constructor(config: ISystemConfiguration, initParams?: ISystemConfigurationInitParams);
8371
8491
  /**
8372
8492
  * Creates a new {@link Config.SystemConfiguration | SystemConfiguration} from the supplied
8373
8493
  * {@link Config.Model.ISystemConfiguration | system configuration}.
@@ -8378,6 +8498,14 @@ declare class SystemConfiguration {
8378
8498
  * @public
8379
8499
  */
8380
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>;
8381
8509
  /**
8382
8510
  * Returns the {@link Config.Model.ISystemConfiguration | system configuration} that this
8383
8511
  * {@link Config.SystemConfiguration | SystemConfiguration} was created from.
@@ -31,4 +31,11 @@ export declare function joinResourceIds(...ids: (string | undefined)[]): Result<
31
31
  * @public
32
32
  */
33
33
  export declare function joinOptionalResourceIds(...ids: (string | undefined)[]): Result<ResourceId | undefined>;
34
+ /**
35
+ * Gets the name for a resource ID.
36
+ * @param id - The resource ID to get the name for.
37
+ * @returns The resource name if found, or undefined if not.
38
+ * @public
39
+ */
40
+ export declare function getNameForResourceId(id: string | undefined): Result<ResourceName>;
34
41
  //# sourceMappingURL=resources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../../src/packlets/common/helpers/resources.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAqB,MAAM,EAAuB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGxD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,CAK9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,CAUlF;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC,CAUtG"}
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../../src/packlets/common/helpers/resources.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAqB,MAAM,EAAuB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGxD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,CAK9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,CAUlF;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC,CAUtG;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAIjF"}
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.splitResourceId = splitResourceId;
25
25
  exports.joinResourceIds = joinResourceIds;
26
26
  exports.joinOptionalResourceIds = joinOptionalResourceIds;
27
+ exports.getNameForResourceId = getNameForResourceId;
27
28
  const ts_utils_1 = require("@fgv/ts-utils");
28
29
  const resources_1 = require("../validate/resources");
29
30
  /**
@@ -82,4 +83,15 @@ function joinOptionalResourceIds(...ids) {
82
83
  const id = parts.join('.');
83
84
  return errors.returnOrReport(id ? (0, resources_1.toResourceId)(id) : (0, ts_utils_1.succeed)(undefined));
84
85
  }
86
+ /**
87
+ * Gets the name for a resource ID.
88
+ * @param id - The resource ID to get the name for.
89
+ * @returns The resource name if found, or undefined if not.
90
+ * @public
91
+ */
92
+ function getNameForResourceId(id) {
93
+ return splitResourceId(id).onSuccess((parts) => {
94
+ return parts.length > 0 ? (0, ts_utils_1.succeed)(parts[parts.length - 1]) : fail('Empty id has no name');
95
+ });
96
+ }
85
97
  //# sourceMappingURL=resources.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../../src/packlets/common/helpers/resources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAcH,0CAKC;AAYD,0CAUC;AAYD,0DAUC;AA7DD,4CAA+E;AAE/E,qDAAqE;AAErE;;;;;;;GAOG;AACH,SAAgB,eAAe,C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C1E,CAAC,CAAC,CAAC;IACL,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,IAAA,wBAAY,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC,CAAC;AAC3E,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 { MessageAggregator, Result, mapResults, succeed } from '@fgv/ts-utils';\nimport { ResourceId, ResourceName } from '../resources';\nimport { toResourceId, toResourceName } from '../validate/resources';\n\n/**\n * Splits a {@link ResourceId | resource id} into its component {@link ResourceName | resource names}.\n *\n * @param id - The ID to split.\n * @returns `Success`with an array of {@link ResourceName | ResourceName} objects if the ID is valid, or\n * `Failure` with an error message if not.\n * @public\n */\nexport function splitResourceId(id: string | undefined): Result<ResourceName[]> {\n if (id === undefined) {\n return succeed([]);\n }\n return mapResults(id.split('.').map(toResourceName));\n}\n\n/**\n * Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with\n * to create a new {@link ResourceId | resource ID}. Fails if resulting ID is invalid or empty.\n *\n * @param base - The base name or ID to join.\n * @param names - Additional names to join.\n * @returns `Success` with the new ID if the base and names are valid, or `Failure` with an error message\n * if not.\n * @public\n */\nexport function joinResourceIds(...ids: (string | undefined)[]): Result<ResourceId> {\n const errors: MessageAggregator = new MessageAggregator();\n const parts: ResourceName[] = [];\n ids\n .filter((id) => id !== '')\n .forEach((id) => {\n parts.push(...splitResourceId(id).aggregateError(errors).orDefault([]));\n });\n const id = parts.join('.');\n return errors.returnOrReport(toResourceId(id));\n}\n\n/**\n * Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with\n * to create a new {@link ResourceId | resource ID}. Returns `undefined` if no names are defined.\n *\n * @param base - The base name or ID to join.\n * @param names - Additional names to join.\n * @returns `Success` with the new ID if the base and names are valid, `Success` with `undefined`\n * if names were present, or `Failure` with an error message if the resulting id is invalid.\n * @public\n */\nexport function joinOptionalResourceIds(...ids: (string | undefined)[]): Result<ResourceId | undefined> {\n const errors: MessageAggregator = new MessageAggregator();\n const parts: ResourceName[] = [];\n ids\n .filter((id) => id !== '')\n .forEach((id) => {\n parts.push(...splitResourceId(id).aggregateError(errors).orDefault([]));\n });\n const id = parts.join('.');\n return errors.returnOrReport(id ? toResourceId(id) : succeed(undefined));\n}\n"]}
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../../src/packlets/common/helpers/resources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAcH,0CAKC;AAYD,0CAUC;AAYD,0DAUC;AAQD,oDAIC;AAzED,4CAA+E;AAE/E,qDAAqE;AAErE;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,EAAsB;IACpD,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,OAAO,IA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,GAAG,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,IAAA,wBAAY,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,EAAsB;IACzD,OAAO,eAAe,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,kBAAO,EAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;AACL,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 { MessageAggregator, Result, mapResults, succeed } from '@fgv/ts-utils';\nimport { ResourceId, ResourceName } from '../resources';\nimport { toResourceId, toResourceName } from '../validate/resources';\n\n/**\n * Splits a {@link ResourceId | resource id} into its component {@link ResourceName | resource names}.\n *\n * @param id - The ID to split.\n * @returns `Success`with an array of {@link ResourceName | ResourceName} objects if the ID is valid, or\n * `Failure` with an error message if not.\n * @public\n */\nexport function splitResourceId(id: string | undefined): Result<ResourceName[]> {\n if (id === undefined) {\n return succeed([]);\n }\n return mapResults(id.split('.').map(toResourceName));\n}\n\n/**\n * Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with\n * to create a new {@link ResourceId | resource ID}. Fails if resulting ID is invalid or empty.\n *\n * @param base - The base name or ID to join.\n * @param names - Additional names to join.\n * @returns `Success` with the new ID if the base and names are valid, or `Failure` with an error message\n * if not.\n * @public\n */\nexport function joinResourceIds(...ids: (string | undefined)[]): Result<ResourceId> {\n const errors: MessageAggregator = new MessageAggregator();\n const parts: ResourceName[] = [];\n ids\n .filter((id) => id !== '')\n .forEach((id) => {\n parts.push(...splitResourceId(id).aggregateError(errors).orDefault([]));\n });\n const id = parts.join('.');\n return errors.returnOrReport(toResourceId(id));\n}\n\n/**\n * Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with\n * to create a new {@link ResourceId | resource ID}. Returns `undefined` if no names are defined.\n *\n * @param base - The base name or ID to join.\n * @param names - Additional names to join.\n * @returns `Success` with the new ID if the base and names are valid, `Success` with `undefined`\n * if names were present, or `Failure` with an error message if the resulting id is invalid.\n * @public\n */\nexport function joinOptionalResourceIds(...ids: (string | undefined)[]): Result<ResourceId | undefined> {\n const errors: MessageAggregator = new MessageAggregator();\n const parts: ResourceName[] = [];\n ids\n .filter((id) => id !== '')\n .forEach((id) => {\n parts.push(...splitResourceId(id).aggregateError(errors).orDefault([]));\n });\n const id = parts.join('.');\n return errors.returnOrReport(id ? toResourceId(id) : succeed(undefined));\n}\n\n/**\n * Gets the name for a resource ID.\n * @param id - The resource ID to get the name for.\n * @returns The resource name if found, or undefined if not.\n * @public\n */\nexport function getNameForResourceId(id: string | undefined): Result<ResourceName> {\n return splitResourceId(id).onSuccess((parts) => {\n return parts.length > 0 ? succeed(parts[parts.length - 1]) : fail('Empty id has no name');\n });\n}\n"]}
@@ -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,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAe;QAC3B,KAAK,MAAM,OAAO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;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,5 +1,6 @@
1
1
  import * as Model from './json';
2
2
  import * as Convert from './convert';
3
+ export * from './configInitFactory';
3
4
  export * from './systemConfiguration';
4
5
  export * from './common';
5
6
  export { Model, Convert };
@@ -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;AAMvB,sBAAK;AALd,mDAAqC;AAKrB,0BAAO;AAHvB,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 './systemConfiguration';\nexport * from './common';\n\nexport { Model, Convert };\n"]}
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"]}