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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/tsdoc-metadata.json +1 -1
  2. package/package.json +9 -9
  3. package/dist/packlets/config/common.js +0 -78
  4. package/dist/packlets/config/common.js.map +0 -1
  5. package/dist/packlets/config/configInitFactory.js +0 -258
  6. package/dist/packlets/config/configInitFactory.js.map +0 -1
  7. package/dist/packlets/config/convert.js +0 -56
  8. package/dist/packlets/config/convert.js.map +0 -1
  9. package/dist/packlets/config/index.browser.js +0 -34
  10. package/dist/packlets/config/index.browser.js.map +0 -1
  11. package/dist/packlets/config/index.js +0 -28
  12. package/dist/packlets/config/index.js.map +0 -1
  13. package/dist/packlets/config/json.js +0 -23
  14. package/dist/packlets/config/json.js.map +0 -1
  15. package/dist/packlets/config/predefined/default.js +0 -138
  16. package/dist/packlets/config/predefined/default.js.map +0 -1
  17. package/dist/packlets/config/predefined/extended.js +0 -190
  18. package/dist/packlets/config/predefined/extended.js.map +0 -1
  19. package/dist/packlets/config/predefined/index.js +0 -25
  20. package/dist/packlets/config/predefined/index.js.map +0 -1
  21. package/dist/packlets/config/systemConfiguration.js +0 -147
  22. package/dist/packlets/config/systemConfiguration.js.map +0 -1
  23. package/dist/packlets/qualifier-types/config/convert.js +0 -124
  24. package/dist/packlets/qualifier-types/config/convert.js.map +0 -1
  25. package/dist/packlets/qualifier-types/config/index.js +0 -25
  26. package/dist/packlets/qualifier-types/config/index.js.map +0 -1
  27. package/dist/packlets/qualifier-types/config/json.js +0 -32
  28. package/dist/packlets/qualifier-types/config/json.js.map +0 -1
  29. package/dist/packlets/resource-types/config/convert.js +0 -35
  30. package/dist/packlets/resource-types/config/convert.js.map +0 -1
  31. package/dist/packlets/resource-types/config/index.js +0 -25
  32. package/dist/packlets/resource-types/config/index.js.map +0 -1
  33. package/dist/packlets/resource-types/config/json.js +0 -23
  34. package/dist/packlets/resource-types/config/json.js.map +0 -1
  35. package/lib/packlets/config/common.d.ts +0 -35
  36. package/lib/packlets/config/common.d.ts.map +0 -1
  37. package/lib/packlets/config/common.js +0 -97
  38. package/lib/packlets/config/common.js.map +0 -1
  39. package/lib/packlets/config/configInitFactory.d.ts +0 -217
  40. package/lib/packlets/config/configInitFactory.d.ts.map +0 -1
  41. package/lib/packlets/config/configInitFactory.js +0 -303
  42. package/lib/packlets/config/configInitFactory.js.map +0 -1
  43. package/lib/packlets/config/convert.d.ts +0 -23
  44. package/lib/packlets/config/convert.d.ts.map +0 -1
  45. package/lib/packlets/config/convert.js +0 -93
  46. package/lib/packlets/config/convert.js.map +0 -1
  47. package/lib/packlets/config/index.browser.d.ts +0 -7
  48. package/lib/packlets/config/index.browser.d.ts.map +0 -1
  49. package/lib/packlets/config/index.browser.js +0 -74
  50. package/lib/packlets/config/index.browser.js.map +0 -1
  51. package/lib/packlets/config/index.d.ts +0 -7
  52. package/lib/packlets/config/index.d.ts.map +0 -1
  53. package/lib/packlets/config/index.js +0 -68
  54. package/lib/packlets/config/index.js.map +0 -1
  55. package/lib/packlets/config/json.d.ts +0 -20
  56. package/lib/packlets/config/json.d.ts.map +0 -1
  57. package/lib/packlets/config/json.js +0 -24
  58. package/lib/packlets/config/json.js.map +0 -1
  59. package/lib/packlets/config/predefined/default.d.ts +0 -57
  60. package/lib/packlets/config/predefined/default.d.ts.map +0 -1
  61. package/lib/packlets/config/predefined/default.js +0 -141
  62. package/lib/packlets/config/predefined/default.js.map +0 -1
  63. package/lib/packlets/config/predefined/extended.d.ts +0 -25
  64. package/lib/packlets/config/predefined/extended.d.ts.map +0 -1
  65. package/lib/packlets/config/predefined/extended.js +0 -193
  66. package/lib/packlets/config/predefined/extended.js.map +0 -1
  67. package/lib/packlets/config/predefined/index.d.ts +0 -4
  68. package/lib/packlets/config/predefined/index.d.ts.map +0 -1
  69. package/lib/packlets/config/predefined/index.js +0 -62
  70. package/lib/packlets/config/predefined/index.js.map +0 -1
  71. package/lib/packlets/config/systemConfiguration.d.ts +0 -94
  72. package/lib/packlets/config/systemConfiguration.d.ts.map +0 -1
  73. package/lib/packlets/config/systemConfiguration.js +0 -152
  74. package/lib/packlets/config/systemConfiguration.js.map +0 -1
  75. package/lib/packlets/qualifier-types/config/convert.d.ts +0 -65
  76. package/lib/packlets/qualifier-types/config/convert.d.ts.map +0 -1
  77. package/lib/packlets/qualifier-types/config/convert.js +0 -161
  78. package/lib/packlets/qualifier-types/config/convert.js.map +0 -1
  79. package/lib/packlets/qualifier-types/config/index.d.ts +0 -4
  80. package/lib/packlets/qualifier-types/config/index.d.ts.map +0 -1
  81. package/lib/packlets/qualifier-types/config/index.js +0 -64
  82. package/lib/packlets/qualifier-types/config/index.js.map +0 -1
  83. package/lib/packlets/qualifier-types/config/json.d.ts +0 -91
  84. package/lib/packlets/qualifier-types/config/json.d.ts.map +0 -1
  85. package/lib/packlets/qualifier-types/config/json.js +0 -35
  86. package/lib/packlets/qualifier-types/config/json.js.map +0 -1
  87. package/lib/packlets/resource-types/config/convert.d.ts +0 -8
  88. package/lib/packlets/resource-types/config/convert.d.ts.map +0 -1
  89. package/lib/packlets/resource-types/config/convert.js +0 -38
  90. package/lib/packlets/resource-types/config/convert.js.map +0 -1
  91. package/lib/packlets/resource-types/config/index.d.ts +0 -4
  92. package/lib/packlets/resource-types/config/index.d.ts.map +0 -1
  93. package/lib/packlets/resource-types/config/index.js +0 -64
  94. package/lib/packlets/resource-types/config/index.js.map +0 -1
  95. package/lib/packlets/resource-types/config/json.d.ts +0 -11
  96. package/lib/packlets/resource-types/config/json.d.ts.map +0 -1
  97. package/lib/packlets/resource-types/config/json.js +0 -24
  98. package/lib/packlets/resource-types/config/json.js.map +0 -1
@@ -1,217 +0,0 @@
1
- import { Result } from '@fgv/ts-utils';
2
- import { QualifierType, SystemQualifierType } 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
- * 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>;
16
- /**
17
- * Interface for a factory that creates a new instance of a configuration object.
18
- * @public
19
- */
20
- export interface IConfigInitFactory<TConfig, T> {
21
- /**
22
- * Creates a new instance of a configuration object.
23
- * @param config - The configuration object to create.
24
- * @returns A result containing the new instance of the configuration object.
25
- */
26
- create(config: TConfig): Result<T>;
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>;
42
- /**
43
- * A factory that chains multiple factories together.
44
- * @public
45
- */
46
- export declare class ChainedConfigInitFactory<TConfig, T> implements IConfigInitFactory<TConfig, T> {
47
- readonly factories: IConfigInitFactory<TConfig, T>[];
48
- /**
49
- * Constructor for a chained config init factory.
50
- * @param factories - The factories to chain.
51
- */
52
- constructor(factories: IConfigInitFactory<TConfig, T>[]);
53
- /**
54
- * Creates a new instance of a configuration object.
55
- * @param config - The configuration object to create.
56
- * @returns A result containing the new instance of the configuration object.
57
- */
58
- create(config: TConfig): Result<T>;
59
- }
60
- /**
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.
65
- * @public
66
- */
67
- export declare class BuiltInQualifierTypeFactory implements IConfigInitFactory<QualifierTypes.Config.ISystemQualifierTypeConfig, SystemQualifierType> {
68
- /** {@inheritDoc Config.IConfigInitFactory.create} */
69
- create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<SystemQualifierType>;
70
- }
71
- /**
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
- *
109
- * @public
110
- */
111
- export declare class QualifierTypeFactory<T extends QualifierType = SystemQualifierType> extends ChainedConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T | SystemQualifierType> {
112
- /**
113
- * Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.
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
157
- */
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>;
165
- }
166
- /**
167
- * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.
168
- * @public
169
- */
170
- export declare class BuiltInResourceTypeFactory implements IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {
171
- /** {@inheritDoc Config.IConfigInitFactory.create} */
172
- create(config: ResourceTypes.Config.IResourceTypeConfig): Result<ResourceType>;
173
- }
174
- /**
175
- * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}
176
- * by chaining a supplied factory with a {@link Config.BuiltInResourceTypeFactory | built-in factory} that handles built-in resource types.
177
- * @public
178
- */
179
- export declare class ResourceTypeFactory extends ChainedConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {
180
- /**
181
- * Constructor for a resource type factory.
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
186
- * @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.
187
- */
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>;
216
- }
217
- //# sourceMappingURL=configInitFactory.d.ts.map
@@ -1 +0,0 @@
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,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,aAAa,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAAI,CAClF,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,uBAAuB,KAClD,MAAM,CAAC,CAAC,CAAC,CAAC;AAEf;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACxC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,mBAAmB,KAC7C,MAAM,CAAC,YAAY,CAAC,CAAC;AAE1B;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,EAA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MG;gBAED,SAAS,EAAE,KAAK,CACd,kBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC,mBAAmB,EAAE,YAAY,CAAC,GAAG,2BAA2B,CACzG;IAKH;;;;OAIG;IACI,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC;CAKrD"}
@@ -1,303 +0,0 @@
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.ValidatingResourceTypeFactory = exports.ResourceTypeFactory = exports.BuiltInResourceTypeFactory = exports.ValidatingQualifierTypeFactory = exports.QualifierTypeFactory = exports.BuiltInQualifierTypeFactory = exports.ChainedConfigInitFactory = void 0;
58
- exports.createQualifierTypeFactory = createQualifierTypeFactory;
59
- exports.createResourceTypeFactory = createResourceTypeFactory;
60
- const ts_utils_1 = require("@fgv/ts-utils");
61
- const QualifierTypes = __importStar(require("../qualifier-types"));
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
- }
85
- /**
86
- * A factory that chains multiple factories together.
87
- * @public
88
- */
89
- class ChainedConfigInitFactory {
90
- /**
91
- * Constructor for a chained config init factory.
92
- * @param factories - The factories to chain.
93
- */
94
- constructor(factories) {
95
- this.factories = factories;
96
- }
97
- /**
98
- * Creates a new instance of a configuration object.
99
- * @param config - The configuration object to create.
100
- * @returns A result containing the new instance of the configuration object.
101
- */
102
- create(config) {
103
- for (const factory of this.factories) {
104
- const result = factory.create(config);
105
- if (result.isSuccess()) {
106
- return result;
107
- }
108
- }
109
- return (0, ts_utils_1.fail)('No factory was able to create the configuration object');
110
- }
111
- }
112
- exports.ChainedConfigInitFactory = ChainedConfigInitFactory;
113
- /**
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.
118
- * @public
119
- */
120
- class BuiltInQualifierTypeFactory {
121
- /** {@inheritDoc Config.IConfigInitFactory.create} */
122
- create(config) {
123
- if (QualifierTypes.Config.isSystemQualifierTypeConfig(config)) {
124
- return QualifierTypes.createQualifierTypeFromSystemConfig(config);
125
- }
126
- /* c8 ignore next 2 - functional code tested but coverage intermittently missed */
127
- return (0, ts_utils_1.fail)(`${config.name}: unknown built-in qualifier type (${config.systemType})`);
128
- }
129
- }
130
- exports.BuiltInQualifierTypeFactory = BuiltInQualifierTypeFactory;
131
- /**
132
- * A factory that creates {@link QualifierTypes.QualifierType | QualifierType} instances from configuration,
133
- * supporting both built-in system types and custom external types.
134
- *
135
- * This factory allows external consumers to extend the qualifier type system with their own custom types
136
- * while maintaining support for all built-in types (Language, Territory, Literal).
137
- *
138
- * @typeParam T - The custom qualifier type(s) to support. Defaults to {@link QualifierTypes.SystemQualifierType | SystemQualifierType}.
139
- *
140
- * @example Creating a factory with custom qualifier types
141
- * ```typescript
142
- * // Define a custom qualifier type
143
- * class CustomQualifierType extends QualifierType {
144
- * // ... implementation
145
- * }
146
- *
147
- * // Define a discriminated union of all types
148
- * type AppQualifierType = SystemQualifierType | CustomQualifierType;
149
- *
150
- * // Create a factory that handles custom types
151
- * const customFactory: IConfigInitFactory<IAnyQualifierTypeConfig, CustomQualifierType> = {
152
- * create(config) {
153
- * // ... handle custom type creation
154
- * }
155
- * };
156
- *
157
- * // Create the combined factory
158
- * const qualifierTypeFactory = new QualifierTypeFactory<AppQualifierType>([customFactory]);
159
- *
160
- * // The factory returns T | SystemQualifierType, supporting all types
161
- * const result = qualifierTypeFactory.create(config); // Result<AppQualifierType | SystemQualifierType>
162
- * ```
163
- *
164
- * @remarks
165
- * - The factory chains custom factories with the built-in factory
166
- * - Custom factories are tried first, falling back to built-in types
167
- * - The return type is a union of custom types (T) and system types
168
- *
169
- * @public
170
- */
171
- class QualifierTypeFactory extends ChainedConfigInitFactory {
172
- /**
173
- * Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.
174
- * @param factories - Array of factories for custom qualifier types. Can be:
175
- * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
176
- * - {@link Config.QualifierTypeFactoryFunction | Factory functions}
177
- * - A mix of both
178
- * These are tried in order before falling back to built-in types.
179
- * @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always appended to handle
180
- * system qualifier types (Language, Territory, Literal).
181
- */
182
- constructor(factories) {
183
- const normalizedFactories = factories.map((f) => typeof f === 'function' ? createQualifierTypeFactory(f) : f);
184
- super([...normalizedFactories, new BuiltInQualifierTypeFactory()]);
185
- }
186
- }
187
- exports.QualifierTypeFactory = QualifierTypeFactory;
188
- /**
189
- * A factory that validates and creates {@link QualifierTypes.QualifierType | QualifierType} instances
190
- * from weakly-typed configuration objects. This factory accepts configurations with unvalidated
191
- * string properties and validates them before delegating to the underlying factory chain.
192
- *
193
- * This pattern is useful at package boundaries where type identity issues may occur with
194
- * branded types across different package instances.
195
- *
196
- * @example
197
- * ```typescript
198
- * // Accept weakly-typed config from external source
199
- * const validatingFactory = new ValidatingQualifierTypeFactory([customFactory]);
200
- *
201
- * // Config can have plain string types instead of branded types
202
- * const config = {
203
- * name: 'my-qualifier', // plain string, not QualifierTypeName
204
- * systemType: 'custom', // plain string
205
- * configuration: { ... }
206
- * };
207
- *
208
- * const result = validatingFactory.create(config); // Validates and converts internally
209
- * ```
210
- *
211
- * @public
212
- */
213
- class ValidatingQualifierTypeFactory {
214
- /**
215
- * Constructor for a validating qualifier type factory.
216
- * @param factories - Array of factories for custom qualifier types. Can be:
217
- * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
218
- * - {@link Config.QualifierTypeFactoryFunction | Factory functions}
219
- * - A mix of both
220
- */
221
- constructor(factories) {
222
- this._innerFactory = new QualifierTypeFactory(factories);
223
- }
224
- /**
225
- * Creates a qualifier type from a weakly-typed configuration object.
226
- * @param config - The configuration object to validate and use for creation.
227
- * @returns A result containing the new qualifier type if successful.
228
- */
229
- create(config) {
230
- return QualifierTypes.Config.Convert.anyQualifierTypeConfig
231
- .convert(config)
232
- .onSuccess((validatedConfig) => {
233
- return this._innerFactory.create(validatedConfig);
234
- });
235
- }
236
- }
237
- exports.ValidatingQualifierTypeFactory = ValidatingQualifierTypeFactory;
238
- /**
239
- * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}.
240
- * @public
241
- */
242
- class BuiltInResourceTypeFactory {
243
- /** {@inheritDoc Config.IConfigInitFactory.create} */
244
- create(config) {
245
- return ResourceTypes.createResourceTypeFromConfig(config);
246
- }
247
- }
248
- exports.BuiltInResourceTypeFactory = BuiltInResourceTypeFactory;
249
- /**
250
- * A factory that creates a {@link ResourceTypes.ResourceType | ResourceType} from a {@link ResourceTypes.Config.IResourceTypeConfig | resource type configuration}
251
- * by chaining a supplied factory with a {@link Config.BuiltInResourceTypeFactory | built-in factory} that handles built-in resource types.
252
- * @public
253
- */
254
- class ResourceTypeFactory extends ChainedConfigInitFactory {
255
- /**
256
- * Constructor for a resource type factory.
257
- * @param factories - Array of factories for resource types. Can be:
258
- * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
259
- * - {@link Config.ResourceTypeFactoryFunction | Factory functions}
260
- * - A mix of both
261
- * @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.
262
- */
263
- constructor(factories) {
264
- factories = factories !== null && factories !== void 0 ? factories : [];
265
- const normalizedFactories = factories.map((f) => typeof f === 'function' ? createResourceTypeFactory(f) : f);
266
- super([...normalizedFactories, new BuiltInResourceTypeFactory()]);
267
- }
268
- }
269
- exports.ResourceTypeFactory = ResourceTypeFactory;
270
- /**
271
- * A factory that validates and creates {@link ResourceTypes.ResourceType | ResourceType} instances
272
- * from weakly-typed configuration objects. This factory accepts configurations with unvalidated
273
- * string properties and validates them before delegating to the underlying factory chain.
274
- *
275
- * This pattern is useful at package boundaries where type identity issues may occur with
276
- * branded types across different package instances.
277
- *
278
- * @public
279
- */
280
- class ValidatingResourceTypeFactory {
281
- /**
282
- * Constructor for a validating resource type factory.
283
- * @param factories - Array of factories for resource types. Can be:
284
- * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances
285
- * - {@link Config.ResourceTypeFactoryFunction | Factory functions}
286
- * - A mix of both
287
- */
288
- constructor(factories) {
289
- this._innerFactory = new ResourceTypeFactory(factories);
290
- }
291
- /**
292
- * Creates a resource type from a weakly-typed configuration object.
293
- * @param config - The configuration object to validate and use for creation.
294
- * @returns A result containing the new resource type if successful.
295
- */
296
- create(config) {
297
- return ResourceTypes.Config.Convert.resourceTypeConfig.convert(config).onSuccess((validatedConfig) => {
298
- return this._innerFactory.create(validatedConfig);
299
- });
300
- }
301
- }
302
- exports.ValidatingResourceTypeFactory = ValidatingResourceTypeFactory;
303
- //# sourceMappingURL=configInitFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configInitFactory.js","sourceRoot":"","sources":["../../../src/packlets/config/config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,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9C,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3D,CAAC;QACF,KAAK,CAAC,CAAC,GAAG,mBAAmB,EAAE,IAAI,0BAA0B,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;CACF;AAvBD,kDAuBC;AAED;;;;;;;;;GASG;AACH,MAAa,6BAA6B;IAGxC;;;;;;OAMG;IACH,YACE,SAEC;QAED,IAAI,CAAC,aAAa,GAAG,IAAI,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAe;QAC3B,OAAO,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,EAAE;YACnG,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA5BD,sEA4BC","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, SystemQualifierType } from '../qualifier-types';\nimport * as QualifierTypes from '../qualifier-types';\nimport * as ResourceTypes from '../resource-types';\nimport { ResourceType } from '../resource-types';\n\n/**\n * Function signature for creating a qualifier type from configuration.\n * @public\n */\nexport type QualifierTypeFactoryFunction<T extends QualifierType = QualifierType> = (\n config: QualifierTypes.Config.IAnyQualifierTypeConfig\n) => Result<T>;\n\n/**\n * Function signature for creating a resource type from configuration.\n * @public\n */\nexport type ResourceTypeFactoryFunction = (\n config: ResourceTypes.Config.IResourceTypeConfig\n) => Result<ResourceType>;\n\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 * Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a factory function.\n * @param fn - The factory function to wrap.\n * @returns An `IConfigInitFactory` instance that delegates to the function.\n * @public\n */\nexport function createQualifierTypeFactory<T extends QualifierType = QualifierType>(\n fn: QualifierTypeFactoryFunction<T>\n): IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> {\n return {\n create: fn\n };\n}\n\n/**\n * Creates a {@link Config.IConfigInitFactory | IConfigInitFactory} from a resource type factory function.\n * @param fn - The factory function to wrap.\n * @returns An `IConfigInitFactory` instance that delegates to the function.\n * @public\n */\nexport function createResourceTypeFactory(\n fn: ResourceTypeFactoryFunction\n): IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> {\n return {\n create: fn\n };\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.SystemQualifierType | SystemQualifierType} from\n * {@link QualifierTypes.Config.IAnyQualifierTypeConfig | any qualifier type configuration}.\n * @returns `Success` with the new {@link QualifierTypes.SystemQualifierType | SystemQualifierType}\n * if successful, `Failure` with an error message otherwise.\n * @public\n */\nexport class BuiltInQualifierTypeFactory\n implements IConfigInitFactory<QualifierTypes.Config.ISystemQualifierTypeConfig, SystemQualifierType>\n{\n /** {@inheritDoc Config.IConfigInitFactory.create} */\n public create(config: QualifierTypes.Config.IAnyQualifierTypeConfig): Result<SystemQualifierType> {\n if (QualifierTypes.Config.isSystemQualifierTypeConfig(config)) {\n return QualifierTypes.createQualifierTypeFromSystemConfig(config);\n }\n /* c8 ignore next 2 - functional code tested but coverage intermittently missed */\n return fail(`${config.name}: unknown built-in qualifier type (${config.systemType})`);\n }\n}\n\n/**\n * A factory that creates {@link QualifierTypes.QualifierType | QualifierType} instances from configuration,\n * supporting both built-in system types and custom external types.\n *\n * This factory allows external consumers to extend the qualifier type system with their own custom types\n * while maintaining support for all built-in types (Language, Territory, Literal).\n *\n * @typeParam T - The custom qualifier type(s) to support. Defaults to {@link QualifierTypes.SystemQualifierType | SystemQualifierType}.\n *\n * @example Creating a factory with custom qualifier types\n * ```typescript\n * // Define a custom qualifier type\n * class CustomQualifierType extends QualifierType {\n * // ... implementation\n * }\n *\n * // Define a discriminated union of all types\n * type AppQualifierType = SystemQualifierType | CustomQualifierType;\n *\n * // Create a factory that handles custom types\n * const customFactory: IConfigInitFactory<IAnyQualifierTypeConfig, CustomQualifierType> = {\n * create(config) {\n * // ... handle custom type creation\n * }\n * };\n *\n * // Create the combined factory\n * const qualifierTypeFactory = new QualifierTypeFactory<AppQualifierType>([customFactory]);\n *\n * // The factory returns T | SystemQualifierType, supporting all types\n * const result = qualifierTypeFactory.create(config); // Result<AppQualifierType | SystemQualifierType>\n * ```\n *\n * @remarks\n * - The factory chains custom factories with the built-in factory\n * - Custom factories are tried first, falling back to built-in types\n * - The return type is a union of custom types (T) and system types\n *\n * @public\n */\nexport class QualifierTypeFactory<\n T extends QualifierType = SystemQualifierType\n> extends ChainedConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T | SystemQualifierType> {\n /**\n * Constructor for a {@link Config.QualifierTypeFactory | qualifier type factory}.\n * @param factories - Array of factories for custom qualifier types. Can be:\n * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances\n * - {@link Config.QualifierTypeFactoryFunction | Factory functions}\n * - A mix of both\n * These are tried in order before falling back to built-in types.\n * @remarks The {@link Config.BuiltInQualifierTypeFactory | built-in factory} is always appended to handle\n * system qualifier types (Language, Territory, Literal).\n */\n public constructor(\n factories: Array<\n IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> | QualifierTypeFactoryFunction<T>\n >\n ) {\n const normalizedFactories = factories.map((f) =>\n typeof f === 'function' ? createQualifierTypeFactory(f) : f\n );\n super([...normalizedFactories, new BuiltInQualifierTypeFactory()]);\n }\n}\n\n/**\n * A factory that validates and creates {@link QualifierTypes.QualifierType | QualifierType} instances\n * from weakly-typed configuration objects. This factory accepts configurations with unvalidated\n * string properties and validates them before delegating to the underlying factory chain.\n *\n * This pattern is useful at package boundaries where type identity issues may occur with\n * branded types across different package instances.\n *\n * @example\n * ```typescript\n * // Accept weakly-typed config from external source\n * const validatingFactory = new ValidatingQualifierTypeFactory([customFactory]);\n *\n * // Config can have plain string types instead of branded types\n * const config = {\n * name: 'my-qualifier', // plain string, not QualifierTypeName\n * systemType: 'custom', // plain string\n * configuration: { ... }\n * };\n *\n * const result = validatingFactory.create(config); // Validates and converts internally\n * ```\n *\n * @public\n */\nexport class ValidatingQualifierTypeFactory<T extends QualifierType = SystemQualifierType>\n implements IConfigInitFactory<unknown, T | SystemQualifierType>\n{\n private readonly _innerFactory: QualifierTypeFactory<T>;\n\n /**\n * Constructor for a validating qualifier type factory.\n * @param factories - Array of factories for custom qualifier types. Can be:\n * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances\n * - {@link Config.QualifierTypeFactoryFunction | Factory functions}\n * - A mix of both\n */\n public constructor(\n factories: Array<\n IConfigInitFactory<QualifierTypes.Config.IAnyQualifierTypeConfig, T> | QualifierTypeFactoryFunction<T>\n >\n ) {\n this._innerFactory = new QualifierTypeFactory(factories);\n }\n\n /**\n * Creates a qualifier type from a weakly-typed configuration object.\n * @param config - The configuration object to validate and use for creation.\n * @returns A result containing the new qualifier type if successful.\n */\n public create(config: unknown): Result<T | SystemQualifierType> {\n return QualifierTypes.Config.Convert.anyQualifierTypeConfig\n .convert(config)\n .onSuccess((validatedConfig) => {\n return this._innerFactory.create(validatedConfig);\n });\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 - Array of factories for resource types. Can be:\n * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances\n * - {@link Config.ResourceTypeFactoryFunction | Factory functions}\n * - A mix of both\n * @remarks The {@link Config.BuiltInResourceTypeFactory | built-in factory} is always added to the end of the chain.\n */\n public constructor(\n factories: Array<\n IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> | ResourceTypeFactoryFunction\n >\n ) {\n factories = factories ?? [];\n const normalizedFactories = factories.map((f) =>\n typeof f === 'function' ? createResourceTypeFactory(f) : f\n );\n super([...normalizedFactories, new BuiltInResourceTypeFactory()]);\n }\n}\n\n/**\n * A factory that validates and creates {@link ResourceTypes.ResourceType | ResourceType} instances\n * from weakly-typed configuration objects. This factory accepts configurations with unvalidated\n * string properties and validates them before delegating to the underlying factory chain.\n *\n * This pattern is useful at package boundaries where type identity issues may occur with\n * branded types across different package instances.\n *\n * @public\n */\nexport class ValidatingResourceTypeFactory implements IConfigInitFactory<unknown, ResourceType> {\n private readonly _innerFactory: ResourceTypeFactory;\n\n /**\n * Constructor for a validating resource type factory.\n * @param factories - Array of factories for resource types. Can be:\n * - {@link Config.IConfigInitFactory | IConfigInitFactory} instances\n * - {@link Config.ResourceTypeFactoryFunction | Factory functions}\n * - A mix of both\n */\n public constructor(\n factories: Array<\n IConfigInitFactory<ResourceTypes.Config.IResourceTypeConfig, ResourceType> | ResourceTypeFactoryFunction\n >\n ) {\n this._innerFactory = new ResourceTypeFactory(factories);\n }\n\n /**\n * Creates a resource type from a weakly-typed configuration object.\n * @param config - The configuration object to validate and use for creation.\n * @returns A result containing the new resource type if successful.\n */\n public create(config: unknown): Result<ResourceType> {\n return ResourceTypes.Config.Convert.resourceTypeConfig.convert(config).onSuccess((validatedConfig) => {\n return this._innerFactory.create(validatedConfig);\n });\n }\n}\n"]}
@@ -1,23 +0,0 @@
1
- import { Result } from '@fgv/ts-utils';
2
- import { ISystemConfiguration } from './json';
3
- /**
4
- * A `Converter` for {@link Config.Model.ISystemConfiguration | ISystemConfiguration} objects.
5
- * @returns A `Converter` for {@link Config.Model.ISystemConfiguration | ISystemConfiguration} objects.
6
- * @public
7
- */
8
- export declare const systemConfiguration: import("@fgv/ts-utils").ObjectConverter<ISystemConfiguration, unknown>;
9
- /**
10
- * A `Converter` for {@link Config.PredefinedSystemConfiguration | PredefinedSystemConfiguration} values.
11
- * @returns A `Converter` for {@link Config.PredefinedSystemConfiguration | PredefinedSystemConfiguration} values.
12
- * @public
13
- */
14
- export declare const predefinedSystemConfiguration: import("@fgv/ts-utils").Converter<import("./common").PredefinedSystemConfiguration, readonly import("./common").PredefinedSystemConfiguration[]>;
15
- /**
16
- * Validate a {@link Config.Model.ISystemConfiguration | ISystemConfiguration} object.
17
- * @param config - The system configuration to validate
18
- * @returns `Success` with the validated system configuration if successful,
19
- * or `Failure` with an error message if validation fails.
20
- * @public
21
- */
22
- export declare function validateSystemConfiguration(config: unknown): Result<ISystemConfiguration>;
23
- //# sourceMappingURL=convert.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/packlets/config/convert.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAc,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAM9C;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,wEAM9B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,kJAAgE,CAAC;AAE3G;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAEzF"}