@fgv/ts-res 5.1.0-28 → 5.1.0-29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/packlets/conditions/conditionDecls.js.map +1 -1
  2. package/dist/packlets/conditions/conditionSet.js +14 -5
  3. package/dist/packlets/conditions/conditionSet.js.map +1 -1
  4. package/dist/packlets/conditions/conditionSetDecls.js.map +1 -1
  5. package/dist/packlets/conditions/convert/conditionSetDecls.js +50 -6
  6. package/dist/packlets/conditions/convert/conditionSetDecls.js.map +1 -1
  7. package/dist/packlets/conditions/convert/decls.js +61 -5
  8. package/dist/packlets/conditions/convert/decls.js.map +1 -1
  9. package/dist/packlets/qualifiers/qualifierCollector.js +151 -7
  10. package/dist/packlets/qualifiers/qualifierCollector.js.map +1 -1
  11. package/dist/packlets/resource-json/convert.js +225 -0
  12. package/dist/packlets/resource-json/convert.js.map +1 -1
  13. package/dist/packlets/resource-json/json.js +2 -2
  14. package/dist/packlets/resource-json/json.js.map +1 -1
  15. package/dist/packlets/runtime/context/simpleContextQualifierProvider.js +3 -0
  16. package/dist/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -1
  17. package/dist/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +3 -5
  18. package/dist/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -1
  19. package/dist/ts-res.d.ts +442 -52
  20. package/lib/packlets/conditions/conditionDecls.d.ts +6 -1
  21. package/lib/packlets/conditions/conditionDecls.d.ts.map +1 -1
  22. package/lib/packlets/conditions/conditionDecls.js.map +1 -1
  23. package/lib/packlets/conditions/conditionSet.d.ts.map +1 -1
  24. package/lib/packlets/conditions/conditionSet.js +14 -5
  25. package/lib/packlets/conditions/conditionSet.js.map +1 -1
  26. package/lib/packlets/conditions/conditionSetDecls.d.ts +7 -2
  27. package/lib/packlets/conditions/conditionSetDecls.d.ts.map +1 -1
  28. package/lib/packlets/conditions/conditionSetDecls.js.map +1 -1
  29. package/lib/packlets/conditions/convert/conditionSetDecls.d.ts +30 -2
  30. package/lib/packlets/conditions/convert/conditionSetDecls.d.ts.map +1 -1
  31. package/lib/packlets/conditions/convert/conditionSetDecls.js +51 -5
  32. package/lib/packlets/conditions/convert/conditionSetDecls.js.map +1 -1
  33. package/lib/packlets/conditions/convert/decls.d.ts +39 -3
  34. package/lib/packlets/conditions/convert/decls.d.ts.map +1 -1
  35. package/lib/packlets/conditions/convert/decls.js +63 -5
  36. package/lib/packlets/conditions/convert/decls.js.map +1 -1
  37. package/lib/packlets/qualifiers/qualifierCollector.d.ts +104 -6
  38. package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -1
  39. package/lib/packlets/qualifiers/qualifierCollector.js +150 -6
  40. package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -1
  41. package/lib/packlets/resource-json/convert.d.ts +85 -0
  42. package/lib/packlets/resource-json/convert.d.ts.map +1 -1
  43. package/lib/packlets/resource-json/convert.js +237 -0
  44. package/lib/packlets/resource-json/convert.js.map +1 -1
  45. package/lib/packlets/resource-json/json.d.ts +128 -39
  46. package/lib/packlets/resource-json/json.d.ts.map +1 -1
  47. package/lib/packlets/resource-json/json.js +2 -2
  48. package/lib/packlets/resource-json/json.js.map +1 -1
  49. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts +9 -2
  50. package/lib/packlets/runtime/context/simpleContextQualifierProvider.d.ts.map +1 -1
  51. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js +3 -0
  52. package/lib/packlets/runtime/context/simpleContextQualifierProvider.js.map +1 -1
  53. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts +8 -1
  54. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.d.ts.map +1 -1
  55. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js +3 -5
  56. package/lib/packlets/runtime/context/validatingSimpleContextQualifierProvider.js.map +1 -1
  57. package/package.json +9 -9
@@ -2,13 +2,21 @@ import { JsonObject } from '@fgv/ts-json-base';
2
2
  import { ConditionOperator, ResourceValueMergeMethod } from '../common';
3
3
  /**
4
4
  * Non-validated loose declaration of a {@link Conditions.Condition | condition}.
5
+ *
6
+ * @remarks
7
+ * Parameterized on `TQualifierNames` so consumers authoring conditions
8
+ * in code can opt into compile-time axis-name discipline (e.g. via a
9
+ * literal-string union derived from a `qualifiers: ['tone'] as const`
10
+ * decl-array). Defaults to `string`, so existing untyped callers
11
+ * compile unchanged.
12
+ *
5
13
  * @public
6
14
  */
7
- export interface ILooseConditionDecl {
15
+ export interface ILooseConditionDecl<TQualifierNames extends string = string> {
8
16
  /**
9
17
  * The name of the {@link Qualifiers.Qualifier | qualifier} to be compared.
10
18
  */
11
- qualifierName: string;
19
+ qualifierName: TQualifierNames;
12
20
  /**
13
21
  * The value to be compared.
14
22
  */
@@ -51,25 +59,51 @@ export interface IChildConditionDecl {
51
59
  scoreAsDefault?: number;
52
60
  }
53
61
  /**
54
- * Non-validated declaration of a {@link Conditions.Condition | condition}.
62
+ * Non-validated array-form declaration of a {@link Conditions.ConditionSet | condition set}.
63
+ *
64
+ * @remarks
65
+ * Parameterized on `TQualifierNames` via `ILooseConditionDecl`;
66
+ * defaults to `string` for back-compat with existing untyped callers.
67
+ *
55
68
  * @public
56
69
  */
57
- export type ConditionSetDeclAsArray = ReadonlyArray<ILooseConditionDecl>;
70
+ export type ConditionSetDeclAsArray<TQualifierNames extends string = string> = ReadonlyArray<ILooseConditionDecl<TQualifierNames>>;
58
71
  /**
59
- * Non-validated declaration of a {@link Conditions.Condition | condition}.
72
+ * Non-validated record-form declaration of a {@link Conditions.ConditionSet | condition set}.
73
+ *
74
+ * @remarks
75
+ * Parameterized on `TQualifierNames`; defaults to `string` for back-compat with
76
+ * existing untyped callers. Uses `Readonly<Partial<Record<...>>>` to align with
77
+ * runtime reality (missing keys produce `undefined`; the `Partial` makes TypeScript
78
+ * aware of this, which is a strict type-system tightening).
79
+ *
60
80
  * @public
61
81
  */
62
- export type ConditionSetDeclAsRecord = Record<string, string | IChildConditionDecl>;
82
+ export type ConditionSetDeclAsRecord<TQualifierNames extends string = string> = Readonly<Partial<Record<TQualifierNames, string | IChildConditionDecl>>>;
63
83
  /**
64
- * Non-validated declaration of a {@link Conditions.Condition | condition}.
84
+ * Non-validated declaration of a {@link Conditions.ConditionSet | condition set}.
85
+ *
86
+ * @remarks
87
+ * Parameterized on `TQualifierNames`; defaults to `string`. Both the
88
+ * array form (`ConditionSetDeclAsArray`) and the record form
89
+ * (`ConditionSetDeclAsRecord`) inherit the parameter, so a
90
+ * consumer threading a narrow `TQualifierNames` gets compile-time
91
+ * rejection of typo'd axis names in either form.
92
+ *
65
93
  * @public
66
94
  */
67
- export type ConditionSetDecl = ConditionSetDeclAsArray | ConditionSetDeclAsRecord;
95
+ export type ConditionSetDecl<TQualifierNames extends string = string> = ConditionSetDeclAsArray<TQualifierNames> | ConditionSetDeclAsRecord<TQualifierNames>;
68
96
  /**
69
97
  * Non-validated child declaration of a {@link Resources.ResourceCandidate | resource candidate}.
98
+ *
99
+ * @remarks
100
+ * Parameterized on `TQualifierNames` so the `conditions` field can carry a
101
+ * narrowed axis-name set. Defaults to `string` so existing untyped callers
102
+ * compile unchanged.
103
+ *
70
104
  * @public
71
105
  */
72
- export interface IChildResourceCandidateDecl {
106
+ export interface IChildResourceCandidateDecl<TQualifierNames extends string = string> {
73
107
  /**
74
108
  * The JSON value of the resource.
75
109
  */
@@ -77,7 +111,7 @@ export interface IChildResourceCandidateDecl {
77
111
  /**
78
112
  * The conditions that must be met for the resource to be selected.
79
113
  */
80
- readonly conditions?: ConditionSetDecl;
114
+ readonly conditions?: ConditionSetDecl<TQualifierNames>;
81
115
  /**
82
116
  * If true, the resource is only a partial representation of the full resource.
83
117
  */
@@ -91,9 +125,14 @@ export interface IChildResourceCandidateDecl {
91
125
  /**
92
126
  * Non-validated declaration of a resource candidate for import,
93
127
  * which can be either a loose or child resource candidate.
128
+ *
129
+ * @remarks
130
+ * Parameterized on `TQualifierNames`; inherits via `IChildResourceCandidateDecl`.
131
+ * Defaults to `string` for back-compat.
132
+ *
94
133
  * @public
95
134
  */
96
- export interface IImporterResourceCandidateDecl extends IChildResourceCandidateDecl {
135
+ export interface IImporterResourceCandidateDecl<TQualifierNames extends string = string> extends IChildResourceCandidateDecl<TQualifierNames> {
97
136
  /**
98
137
  * The {@link ResourceId | id} of the resource.
99
138
  */
@@ -105,9 +144,14 @@ export interface IImporterResourceCandidateDecl extends IChildResourceCandidateD
105
144
  }
106
145
  /**
107
146
  * Non-validated loose declaration of a {@link Resources.ResourceCandidate | resource candidate}.
147
+ *
148
+ * @remarks
149
+ * Parameterized on `TQualifierNames`; inherits via `IChildResourceCandidateDecl`.
150
+ * Defaults to `string` for back-compat.
151
+ *
108
152
  * @public
109
153
  */
110
- export interface ILooseResourceCandidateDecl extends IChildResourceCandidateDecl {
154
+ export interface ILooseResourceCandidateDecl<TQualifierNames extends string = string> extends IChildResourceCandidateDecl<TQualifierNames> {
111
155
  /**
112
156
  * The {@link ResourceId | id} of the resource.
113
157
  */
@@ -119,7 +163,7 @@ export interface ILooseResourceCandidateDecl extends IChildResourceCandidateDecl
119
163
  /**
120
164
  * The conditions that must be met for the resource to be selected.
121
165
  */
122
- readonly conditions?: ConditionSetDecl;
166
+ readonly conditions?: ConditionSetDecl<TQualifierNames>;
123
167
  /**
124
168
  * If true, the resource is only a partial representation of the full resource.
125
169
  */
@@ -136,9 +180,15 @@ export interface ILooseResourceCandidateDecl extends IChildResourceCandidateDecl
136
180
  }
137
181
  /**
138
182
  * Non-validated child declaration of a {@link Resources.Resource | resource}.
183
+ *
184
+ * @remarks
185
+ * Parameterized on `TQualifierNames` so the `candidates` field threads the
186
+ * narrowed axis-name set down to each candidate. Defaults to `string` for
187
+ * back-compat.
188
+ *
139
189
  * @public
140
190
  */
141
- export interface IChildResourceDecl {
191
+ export interface IChildResourceDecl<TQualifierNames extends string = string> {
142
192
  /**
143
193
  * The name of the type of this resource.
144
194
  */
@@ -146,13 +196,18 @@ export interface IChildResourceDecl {
146
196
  /**
147
197
  * Possible candidates for this value.
148
198
  */
149
- readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;
199
+ readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl<TQualifierNames>>;
150
200
  }
151
201
  /**
152
202
  * Non-validated loose declaration of a {@link Resources.Resource | resource}.
203
+ *
204
+ * @remarks
205
+ * Parameterized on `TQualifierNames`; inherits via `IChildResourceDecl`.
206
+ * Defaults to `string` for back-compat.
207
+ *
153
208
  * @public
154
209
  */
155
- export interface ILooseResourceDecl extends IChildResourceDecl {
210
+ export interface ILooseResourceDecl<TQualifierNames extends string = string> extends IChildResourceDecl<TQualifierNames> {
156
211
  /**
157
212
  * The id of the resource.
158
213
  */
@@ -164,71 +219,105 @@ export interface ILooseResourceDecl extends IChildResourceDecl {
164
219
  /**
165
220
  * Possible candidates for this value.
166
221
  */
167
- readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;
222
+ readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl<TQualifierNames>>;
168
223
  }
169
224
  /**
170
225
  * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree node.
226
+ *
227
+ * @remarks
228
+ * Parameterized on `TQualifierNames` so the `resources` and `children` fields
229
+ * thread the narrowed axis-name set throughout the tree. Defaults to `string` for
230
+ * back-compat.
231
+ *
171
232
  * @public
172
233
  */
173
- export interface IResourceTreeChildNodeDecl {
174
- readonly resources?: Record<string, IChildResourceDecl>;
175
- readonly children?: Record<string, IResourceTreeChildNodeDecl>;
234
+ export interface IResourceTreeChildNodeDecl<TQualifierNames extends string = string> {
235
+ readonly resources?: Record<string, IChildResourceDecl<TQualifierNames>>;
236
+ readonly children?: Record<string, IResourceTreeChildNodeDecl<TQualifierNames>>;
176
237
  }
177
238
  /**
178
239
  * Declared context for a resource container.
240
+ *
241
+ * @remarks
242
+ * Parameterized on `TQualifierNames` so the `conditions` field threads the
243
+ * narrowed axis-name set to the container context. Defaults to `string` for
244
+ * back-compat.
245
+ *
179
246
  * @public
180
247
  */
181
- export interface IContainerContextDecl {
248
+ export interface IContainerContextDecl<TQualifierNames extends string = string> {
182
249
  readonly baseId?: string;
183
- readonly conditions?: ConditionSetDecl;
250
+ readonly conditions?: ConditionSetDecl<TQualifierNames>;
184
251
  readonly mergeMethod?: ResourceValueMergeMethod;
185
252
  }
186
253
  /**
187
254
  * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree root.
255
+ *
256
+ * @remarks
257
+ * Parameterized on `TQualifierNames` so the `context` field threads the
258
+ * narrowed axis-name set to the tree root context. Defaults to `string` for
259
+ * back-compat.
260
+ *
188
261
  * @public
189
262
  */
190
- export interface IResourceTreeRootDecl extends IResourceTreeChildNodeDecl {
191
- readonly context?: IContainerContextDecl;
192
- readonly resources?: Record<string, IChildResourceDecl>;
193
- readonly children?: Record<string, IResourceTreeChildNodeDecl>;
263
+ export interface IResourceTreeRootDecl<TQualifierNames extends string = string> extends IResourceTreeChildNodeDecl<TQualifierNames> {
264
+ readonly context?: IContainerContextDecl<TQualifierNames>;
265
+ readonly resources?: Record<string, IChildResourceDecl<TQualifierNames>>;
266
+ readonly children?: Record<string, IResourceTreeChildNodeDecl<TQualifierNames>>;
194
267
  readonly metadata?: JsonObject;
195
268
  }
196
269
  /**
197
270
  * Non-validated declaration of a collection of resources.
271
+ *
272
+ * @remarks
273
+ * Parameterized on `TQualifierNames` so the `context`, `candidates`, and
274
+ * `resources` fields thread the narrowed axis-name set throughout the
275
+ * collection. Defaults to `string` for back-compat.
276
+ *
198
277
  * @public
199
278
  */
200
- export interface IResourceCollectionDecl {
201
- readonly context?: IContainerContextDecl;
202
- readonly candidates?: ReadonlyArray<ILooseResourceCandidateDecl>;
203
- readonly resources?: ReadonlyArray<ILooseResourceDecl>;
204
- readonly collections?: ReadonlyArray<IResourceCollectionDecl>;
279
+ export interface IResourceCollectionDecl<TQualifierNames extends string = string> {
280
+ readonly context?: IContainerContextDecl<TQualifierNames>;
281
+ readonly candidates?: ReadonlyArray<ILooseResourceCandidateDecl<TQualifierNames>>;
282
+ readonly resources?: ReadonlyArray<ILooseResourceDecl<TQualifierNames>>;
283
+ readonly collections?: ReadonlyArray<IResourceCollectionDecl<TQualifierNames>>;
205
284
  readonly metadata?: JsonObject;
206
285
  }
207
286
  /**
208
287
  * Non-validated declaration of a resource for import,
209
288
  * which can be either a loose or child resource.
289
+ *
290
+ * @remarks
291
+ * Parameterized on `TQualifierNames`; defaults to `string` for back-compat.
292
+ *
210
293
  * @public
211
294
  */
212
- export type IImporterResourceDecl = ILooseResourceDecl | IChildResourceDecl;
295
+ export type IImporterResourceDecl<TQualifierNames extends string = string> = ILooseResourceDecl<TQualifierNames> | IChildResourceDecl<TQualifierNames>;
213
296
  /**
214
297
  * Non-validated declaration of a collection of resources for an importer.
298
+ *
299
+ * @remarks
300
+ * Parameterized on `TQualifierNames` so the `context`, `candidates`, and
301
+ * `resources` fields thread the narrowed axis-name set throughout the
302
+ * importer collection. Defaults to `string` for back-compat.
303
+ *
215
304
  * @public
216
305
  */
217
- export interface IImporterResourceCollectionDecl {
218
- readonly context?: IContainerContextDecl;
219
- readonly candidates?: ReadonlyArray<IImporterResourceCandidateDecl>;
220
- readonly resources?: ReadonlyArray<IImporterResourceDecl>;
221
- readonly collections?: ReadonlyArray<IImporterResourceCollectionDecl>;
306
+ export interface IImporterResourceCollectionDecl<TQualifierNames extends string = string> {
307
+ readonly context?: IContainerContextDecl<TQualifierNames>;
308
+ readonly candidates?: ReadonlyArray<IImporterResourceCandidateDecl<TQualifierNames>>;
309
+ readonly resources?: ReadonlyArray<IImporterResourceDecl<TQualifierNames>>;
310
+ readonly collections?: ReadonlyArray<IImporterResourceCollectionDecl<TQualifierNames>>;
222
311
  readonly metadata?: JsonObject;
223
312
  }
224
313
  /**
225
314
  * Type guard function to check if a resource candidate declaration is a loose resource candidate declaration.
226
315
  * @public
227
316
  */
228
- export declare function isLooseResourceCandidateDecl(decl: IImporterResourceCandidateDecl): decl is ILooseResourceCandidateDecl;
317
+ export declare function isLooseResourceCandidateDecl<TQualifierNames extends string = string>(decl: IImporterResourceCandidateDecl<TQualifierNames>): decl is ILooseResourceCandidateDecl<TQualifierNames>;
229
318
  /**
230
319
  * Type guard function to check if a resource declaration is a loose resource declaration.
231
320
  * @public
232
321
  */
233
- export declare function isLooseResourceDecl(decl: IImporterResourceDecl): decl is ILooseResourceDecl;
322
+ export declare function isLooseResourceDecl<TQualifierNames extends string = string>(decl: IImporterResourceDecl<TQualifierNames>): decl is ILooseResourceDecl<TQualifierNames>;
234
323
  //# sourceMappingURL=json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-json/json.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,aAAa,CAAC,mBAAmB,CAAC,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAA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@ exports.isLooseResourceDecl = isLooseResourceDecl;
28
28
  * @public
29
29
  */
30
30
  function isLooseResourceCandidateDecl(decl) {
31
- return 'id' in decl;
31
+ return 'id' in decl && typeof decl.id === 'string';
32
32
  }
33
33
  /**
34
34
  * Type guard function to check if a resource declaration is a loose resource declaration.
35
35
  * @public
36
36
  */
37
37
  function isLooseResourceDecl(decl) {
38
- return 'id' in decl;
38
+ return 'id' in decl && typeof decl.id === 'string';
39
39
  }
40
40
  //# sourceMappingURL=json.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/packlets/resource-json/json.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAsQH,oEAIC;AAMD,kDAEC;AAhBD;;;GAGG;AACH,SAAgB,4BAA4B,CAC1C,IAAoC;IAEpC,OAAO,IAAI,IAAI,IAAI,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,IAA2B;IAC7D,OAAO,IAAI,IAAI,IAAI,CAAC;AACtB,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject } from '@fgv/ts-json-base';\nimport { ConditionOperator, ResourceValueMergeMethod } from '../common';\n\n/**\n * Non-validated loose declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport interface ILooseConditionDecl {\n /**\n * The name of the {@link Qualifiers.Qualifier | qualifier} to be compared.\n */\n qualifierName: string;\n /**\n * The value to be compared.\n */\n value: string;\n /**\n * The operator to be used in the comparison.\n * Default is 'matches'.\n */\n operator?: ConditionOperator;\n\n /**\n * The priority of the condition. Default is the default priority for the qualifier.\n */\n priority?: number;\n\n /**\n * The score to be used if the condition is used as a default.\n */\n scoreAsDefault?: number;\n}\n\n/**\n * Non-validated child declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport interface IChildConditionDecl {\n /**\n * The value to be compared.\n */\n value: string;\n /**\n * The operator to be used in the comparison.\n * Default is 'matches'.\n */\n operator?: ConditionOperator;\n\n /**\n * The priority of the condition. Default is the default priority for the qualifier.\n */\n priority?: number;\n\n /**\n * The score to be used if the condition is used as a default.\n */\n scoreAsDefault?: number;\n}\n\n/**\n * Non-validated declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport type ConditionSetDeclAsArray = ReadonlyArray<ILooseConditionDecl>;\n\n/**\n * Non-validated declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport type ConditionSetDeclAsRecord = Record<string, string | IChildConditionDecl>;\n\n/**\n * Non-validated declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport type ConditionSetDecl = ConditionSetDeclAsArray | ConditionSetDeclAsRecord;\n\n/**\n * Non-validated child declaration of a {@link Resources.ResourceCandidate | resource candidate}.\n * @public\n */\nexport interface IChildResourceCandidateDecl {\n /**\n * The JSON value of the resource.\n */\n readonly json: JsonObject;\n\n /**\n * The conditions that must be met for the resource to be selected.\n */\n readonly conditions?: ConditionSetDecl;\n\n /**\n * If true, the resource is only a partial representation of the full resource.\n */\n readonly isPartial?: boolean;\n\n /**\n * The merge method to be used when merging the resource into the existing resource.\n * default is 'augment'.\n */\n readonly mergeMethod?: ResourceValueMergeMethod;\n}\n\n/**\n * Non-validated declaration of a resource candidate for import,\n * which can be either a loose or child resource candidate.\n * @public\n */\nexport interface IImporterResourceCandidateDecl extends IChildResourceCandidateDecl {\n /**\n * The {@link ResourceId | id} of the resource.\n */\n readonly id?: string;\n\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName?: string;\n}\n\n/**\n * Non-validated loose declaration of a {@link Resources.ResourceCandidate | resource candidate}.\n * @public\n */\nexport interface ILooseResourceCandidateDecl extends IChildResourceCandidateDecl {\n /**\n * The {@link ResourceId | id} of the resource.\n */\n readonly id: string;\n\n /**\n * The JSON value of the resource.\n */\n readonly json: JsonObject;\n\n /**\n * The conditions that must be met for the resource to be selected.\n */\n readonly conditions?: ConditionSetDecl;\n\n /**\n * If true, the resource is only a partial representation of the full resource.\n */\n readonly isPartial?: boolean;\n\n /**\n * The merge method to be used when merging the resource into the existing resource.\n * default is 'augment'.\n */\n readonly mergeMethod?: ResourceValueMergeMethod;\n\n /**\n * The type of the resource.\n */\n readonly resourceTypeName?: string;\n}\n\n/**\n * Non-validated child declaration of a {@link Resources.Resource | resource}.\n * @public\n */\nexport interface IChildResourceDecl {\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName: string;\n\n /**\n * Possible candidates for this value.\n */\n readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;\n}\n\n/**\n * Non-validated loose declaration of a {@link Resources.Resource | resource}.\n * @public\n */\nexport interface ILooseResourceDecl extends IChildResourceDecl {\n /**\n * The id of the resource.\n */\n readonly id: string;\n\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName: string;\n\n /**\n * Possible candidates for this value.\n */\n readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl>;\n}\n\n/**\n * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree node.\n * @public\n */\nexport interface IResourceTreeChildNodeDecl {\n readonly resources?: Record<string, IChildResourceDecl>;\n readonly children?: Record<string, IResourceTreeChildNodeDecl>;\n}\n\n/**\n * Declared context for a resource container.\n * @public\n */\nexport interface IContainerContextDecl {\n readonly baseId?: string;\n readonly conditions?: ConditionSetDecl;\n readonly mergeMethod?: ResourceValueMergeMethod;\n}\n\n/**\n * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree root.\n * @public\n */\nexport interface IResourceTreeRootDecl extends IResourceTreeChildNodeDecl {\n readonly context?: IContainerContextDecl;\n readonly resources?: Record<string, IChildResourceDecl>;\n readonly children?: Record<string, IResourceTreeChildNodeDecl>;\n readonly metadata?: JsonObject;\n}\n\n/**\n * Non-validated declaration of a collection of resources.\n * @public\n */\nexport interface IResourceCollectionDecl {\n readonly context?: IContainerContextDecl;\n readonly candidates?: ReadonlyArray<ILooseResourceCandidateDecl>;\n readonly resources?: ReadonlyArray<ILooseResourceDecl>;\n readonly collections?: ReadonlyArray<IResourceCollectionDecl>;\n readonly metadata?: JsonObject;\n}\n\n/**\n * Non-validated declaration of a resource for import,\n * which can be either a loose or child resource.\n * @public\n */\nexport type IImporterResourceDecl = ILooseResourceDecl | IChildResourceDecl;\n\n/**\n * Non-validated declaration of a collection of resources for an importer.\n * @public\n */\nexport interface IImporterResourceCollectionDecl {\n readonly context?: IContainerContextDecl;\n readonly candidates?: ReadonlyArray<IImporterResourceCandidateDecl>;\n readonly resources?: ReadonlyArray<IImporterResourceDecl>;\n readonly collections?: ReadonlyArray<IImporterResourceCollectionDecl>;\n readonly metadata?: JsonObject;\n}\n\n/**\n * Type guard function to check if a resource candidate declaration is a loose resource candidate declaration.\n * @public\n */\nexport function isLooseResourceCandidateDecl(\n decl: IImporterResourceCandidateDecl\n): decl is ILooseResourceCandidateDecl {\n return 'id' in decl;\n}\n\n/**\n * Type guard function to check if a resource declaration is a loose resource declaration.\n * @public\n */\nexport function isLooseResourceDecl(decl: IImporterResourceDecl): decl is ILooseResourceDecl {\n return 'id' in decl;\n}\n"]}
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/packlets/resource-json/json.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AA2WH,oEAIC;AAMD,kDAIC;AAlBD;;;GAGG;AACH,SAAgB,4BAA4B,CAC1C,IAAqD;IAErD,OAAO,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,IAA4C;IAE5C,OAAO,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC;AACrD,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject } from '@fgv/ts-json-base';\nimport { ConditionOperator, ResourceValueMergeMethod } from '../common';\n\n/**\n * Non-validated loose declaration of a {@link Conditions.Condition | condition}.\n *\n * @remarks\n * Parameterized on `TQualifierNames` so consumers authoring conditions\n * in code can opt into compile-time axis-name discipline (e.g. via a\n * literal-string union derived from a `qualifiers: ['tone'] as const`\n * decl-array). Defaults to `string`, so existing untyped callers\n * compile unchanged.\n *\n * @public\n */\nexport interface ILooseConditionDecl<TQualifierNames extends string = string> {\n /**\n * The name of the {@link Qualifiers.Qualifier | qualifier} to be compared.\n */\n qualifierName: TQualifierNames;\n /**\n * The value to be compared.\n */\n value: string;\n /**\n * The operator to be used in the comparison.\n * Default is 'matches'.\n */\n operator?: ConditionOperator;\n\n /**\n * The priority of the condition. Default is the default priority for the qualifier.\n */\n priority?: number;\n\n /**\n * The score to be used if the condition is used as a default.\n */\n scoreAsDefault?: number;\n}\n\n/**\n * Non-validated child declaration of a {@link Conditions.Condition | condition}.\n * @public\n */\nexport interface IChildConditionDecl {\n /**\n * The value to be compared.\n */\n value: string;\n /**\n * The operator to be used in the comparison.\n * Default is 'matches'.\n */\n operator?: ConditionOperator;\n\n /**\n * The priority of the condition. Default is the default priority for the qualifier.\n */\n priority?: number;\n\n /**\n * The score to be used if the condition is used as a default.\n */\n scoreAsDefault?: number;\n}\n\n/**\n * Non-validated array-form declaration of a {@link Conditions.ConditionSet | condition set}.\n *\n * @remarks\n * Parameterized on `TQualifierNames` via `ILooseConditionDecl`;\n * defaults to `string` for back-compat with existing untyped callers.\n *\n * @public\n */\nexport type ConditionSetDeclAsArray<TQualifierNames extends string = string> = ReadonlyArray<\n ILooseConditionDecl<TQualifierNames>\n>;\n\n/**\n * Non-validated record-form declaration of a {@link Conditions.ConditionSet | condition set}.\n *\n * @remarks\n * Parameterized on `TQualifierNames`; defaults to `string` for back-compat with\n * existing untyped callers. Uses `Readonly<Partial<Record<...>>>` to align with\n * runtime reality (missing keys produce `undefined`; the `Partial` makes TypeScript\n * aware of this, which is a strict type-system tightening).\n *\n * @public\n */\nexport type ConditionSetDeclAsRecord<TQualifierNames extends string = string> = Readonly<\n Partial<Record<TQualifierNames, string | IChildConditionDecl>>\n>;\n\n/**\n * Non-validated declaration of a {@link Conditions.ConditionSet | condition set}.\n *\n * @remarks\n * Parameterized on `TQualifierNames`; defaults to `string`. Both the\n * array form (`ConditionSetDeclAsArray`) and the record form\n * (`ConditionSetDeclAsRecord`) inherit the parameter, so a\n * consumer threading a narrow `TQualifierNames` gets compile-time\n * rejection of typo'd axis names in either form.\n *\n * @public\n */\nexport type ConditionSetDecl<TQualifierNames extends string = string> =\n | ConditionSetDeclAsArray<TQualifierNames>\n | ConditionSetDeclAsRecord<TQualifierNames>;\n\n/**\n * Non-validated child declaration of a {@link Resources.ResourceCandidate | resource candidate}.\n *\n * @remarks\n * Parameterized on `TQualifierNames` so the `conditions` field can carry a\n * narrowed axis-name set. Defaults to `string` so existing untyped callers\n * compile unchanged.\n *\n * @public\n */\nexport interface IChildResourceCandidateDecl<TQualifierNames extends string = string> {\n /**\n * The JSON value of the resource.\n */\n readonly json: JsonObject;\n\n /**\n * The conditions that must be met for the resource to be selected.\n */\n readonly conditions?: ConditionSetDecl<TQualifierNames>;\n\n /**\n * If true, the resource is only a partial representation of the full resource.\n */\n readonly isPartial?: boolean;\n\n /**\n * The merge method to be used when merging the resource into the existing resource.\n * default is 'augment'.\n */\n readonly mergeMethod?: ResourceValueMergeMethod;\n}\n\n/**\n * Non-validated declaration of a resource candidate for import,\n * which can be either a loose or child resource candidate.\n *\n * @remarks\n * Parameterized on `TQualifierNames`; inherits via `IChildResourceCandidateDecl`.\n * Defaults to `string` for back-compat.\n *\n * @public\n */\nexport interface IImporterResourceCandidateDecl<TQualifierNames extends string = string>\n extends IChildResourceCandidateDecl<TQualifierNames> {\n /**\n * The {@link ResourceId | id} of the resource.\n */\n readonly id?: string;\n\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName?: string;\n}\n\n/**\n * Non-validated loose declaration of a {@link Resources.ResourceCandidate | resource candidate}.\n *\n * @remarks\n * Parameterized on `TQualifierNames`; inherits via `IChildResourceCandidateDecl`.\n * Defaults to `string` for back-compat.\n *\n * @public\n */\nexport interface ILooseResourceCandidateDecl<TQualifierNames extends string = string>\n extends IChildResourceCandidateDecl<TQualifierNames> {\n /**\n * The {@link ResourceId | id} of the resource.\n */\n readonly id: string;\n\n /**\n * The JSON value of the resource.\n */\n readonly json: JsonObject;\n\n /**\n * The conditions that must be met for the resource to be selected.\n */\n readonly conditions?: ConditionSetDecl<TQualifierNames>;\n\n /**\n * If true, the resource is only a partial representation of the full resource.\n */\n readonly isPartial?: boolean;\n\n /**\n * The merge method to be used when merging the resource into the existing resource.\n * default is 'augment'.\n */\n readonly mergeMethod?: ResourceValueMergeMethod;\n\n /**\n * The type of the resource.\n */\n readonly resourceTypeName?: string;\n}\n\n/**\n * Non-validated child declaration of a {@link Resources.Resource | resource}.\n *\n * @remarks\n * Parameterized on `TQualifierNames` so the `candidates` field threads the\n * narrowed axis-name set down to each candidate. Defaults to `string` for\n * back-compat.\n *\n * @public\n */\nexport interface IChildResourceDecl<TQualifierNames extends string = string> {\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName: string;\n\n /**\n * Possible candidates for this value.\n */\n readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl<TQualifierNames>>;\n}\n\n/**\n * Non-validated loose declaration of a {@link Resources.Resource | resource}.\n *\n * @remarks\n * Parameterized on `TQualifierNames`; inherits via `IChildResourceDecl`.\n * Defaults to `string` for back-compat.\n *\n * @public\n */\nexport interface ILooseResourceDecl<TQualifierNames extends string = string>\n extends IChildResourceDecl<TQualifierNames> {\n /**\n * The id of the resource.\n */\n readonly id: string;\n\n /**\n * The name of the type of this resource.\n */\n readonly resourceTypeName: string;\n\n /**\n * Possible candidates for this value.\n */\n readonly candidates?: ReadonlyArray<IChildResourceCandidateDecl<TQualifierNames>>;\n}\n\n/**\n * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree node.\n *\n * @remarks\n * Parameterized on `TQualifierNames` so the `resources` and `children` fields\n * thread the narrowed axis-name set throughout the tree. Defaults to `string` for\n * back-compat.\n *\n * @public\n */\nexport interface IResourceTreeChildNodeDecl<TQualifierNames extends string = string> {\n readonly resources?: Record<string, IChildResourceDecl<TQualifierNames>>;\n readonly children?: Record<string, IResourceTreeChildNodeDecl<TQualifierNames>>;\n}\n\n/**\n * Declared context for a resource container.\n *\n * @remarks\n * Parameterized on `TQualifierNames` so the `conditions` field threads the\n * narrowed axis-name set to the container context. Defaults to `string` for\n * back-compat.\n *\n * @public\n */\nexport interface IContainerContextDecl<TQualifierNames extends string = string> {\n readonly baseId?: string;\n readonly conditions?: ConditionSetDecl<TQualifierNames>;\n readonly mergeMethod?: ResourceValueMergeMethod;\n}\n\n/**\n * Normalized non-validated declaration of a {@link Resources.Resource | resource} tree root.\n *\n * @remarks\n * Parameterized on `TQualifierNames` so the `context` field threads the\n * narrowed axis-name set to the tree root context. Defaults to `string` for\n * back-compat.\n *\n * @public\n */\nexport interface IResourceTreeRootDecl<TQualifierNames extends string = string>\n extends IResourceTreeChildNodeDecl<TQualifierNames> {\n readonly context?: IContainerContextDecl<TQualifierNames>;\n readonly resources?: Record<string, IChildResourceDecl<TQualifierNames>>;\n readonly children?: Record<string, IResourceTreeChildNodeDecl<TQualifierNames>>;\n readonly metadata?: JsonObject;\n}\n\n/**\n * Non-validated declaration of a collection of resources.\n *\n * @remarks\n * Parameterized on `TQualifierNames` so the `context`, `candidates`, and\n * `resources` fields thread the narrowed axis-name set throughout the\n * collection. Defaults to `string` for back-compat.\n *\n * @public\n */\nexport interface IResourceCollectionDecl<TQualifierNames extends string = string> {\n readonly context?: IContainerContextDecl<TQualifierNames>;\n readonly candidates?: ReadonlyArray<ILooseResourceCandidateDecl<TQualifierNames>>;\n readonly resources?: ReadonlyArray<ILooseResourceDecl<TQualifierNames>>;\n readonly collections?: ReadonlyArray<IResourceCollectionDecl<TQualifierNames>>;\n readonly metadata?: JsonObject;\n}\n\n/**\n * Non-validated declaration of a resource for import,\n * which can be either a loose or child resource.\n *\n * @remarks\n * Parameterized on `TQualifierNames`; defaults to `string` for back-compat.\n *\n * @public\n */\nexport type IImporterResourceDecl<TQualifierNames extends string = string> =\n | ILooseResourceDecl<TQualifierNames>\n | IChildResourceDecl<TQualifierNames>;\n\n/**\n * Non-validated declaration of a collection of resources for an importer.\n *\n * @remarks\n * Parameterized on `TQualifierNames` so the `context`, `candidates`, and\n * `resources` fields thread the narrowed axis-name set throughout the\n * importer collection. Defaults to `string` for back-compat.\n *\n * @public\n */\nexport interface IImporterResourceCollectionDecl<TQualifierNames extends string = string> {\n readonly context?: IContainerContextDecl<TQualifierNames>;\n readonly candidates?: ReadonlyArray<IImporterResourceCandidateDecl<TQualifierNames>>;\n readonly resources?: ReadonlyArray<IImporterResourceDecl<TQualifierNames>>;\n readonly collections?: ReadonlyArray<IImporterResourceCollectionDecl<TQualifierNames>>;\n readonly metadata?: JsonObject;\n}\n\n/**\n * Type guard function to check if a resource candidate declaration is a loose resource candidate declaration.\n * @public\n */\nexport function isLooseResourceCandidateDecl<TQualifierNames extends string = string>(\n decl: IImporterResourceCandidateDecl<TQualifierNames>\n): decl is ILooseResourceCandidateDecl<TQualifierNames> {\n return 'id' in decl && typeof decl.id === 'string';\n}\n\n/**\n * Type guard function to check if a resource declaration is a loose resource declaration.\n * @public\n */\nexport function isLooseResourceDecl<TQualifierNames extends string = string>(\n decl: IImporterResourceDecl<TQualifierNames>\n): decl is ILooseResourceDecl<TQualifierNames> {\n return 'id' in decl && typeof decl.id === 'string';\n}\n"]}
@@ -13,8 +13,15 @@ export interface ISimpleContextQualifierProviderCreateParams {
13
13
  qualifiers: IReadOnlyQualifierCollector;
14
14
  /**
15
15
  * Optional record of initial qualifier name-value pairs to populate the provider.
16
- */
17
- qualifierValues?: Record<string, QualifierContextValue>;
16
+ *
17
+ * @remarks
18
+ * Typed as `Readonly<Partial<Record<string, QualifierContextValue>>>` so a
19
+ * caller can naturally express conditional context construction, e.g.
20
+ * `tone === 'formal' ? { tone: 'formal' } : {}`. Entries whose value is
21
+ * `undefined` are skipped on load - semantically equivalent to omitting
22
+ * the key, which is how the candidate selector treats a missing key.
23
+ */
24
+ qualifierValues?: Readonly<Partial<Record<string, QualifierContextValue>>>;
18
25
  }
19
26
  /**
20
27
  * Simple concrete implementation of {@link Runtime.Context.IContextQualifierProvider | IContextQualifierProvider}
@@ -1 +1 @@
1
- {"version":3,"file":"simpleContextQualifierProvider.d.ts","sourceRoot":"","sources":["../../../../src/packlets/runtime/context/simpleContextQualifierProvider.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAoE,MAAM,eAAe,CAAC;AACzG,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,cAAc,EAGf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,2BAA2B,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAExG;;;GAGG;AACH,MAAM,WAAW,2CAA2C;IAC1D;;OAEG;IACH,UAAU,EAAE,2BAA2B,CAAC;IAExC;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CACzD;AAED;;;;GAIG;AACH,qBAAa,8BACX,SAAQ,wBACR,YAAW,gCAAgC;IAE3C;;;OAGG;IACH,SAAgB,OAAO,EAAE,IAAI,CAAiB;IAE9C;;OAEG;IACH,SAAgB,UAAU,EAAE,2BAA2B,CAAC;IAExD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkD;IAEnF;;;OAGG;IACH,SAAS,aAAa,MAAM,EAAE,2CAA2C;IAazE;;;;;;OAMG;WACW,MAAM,CAClB,MAAM,EAAE,2CAA2C,GAClD,MAAM,CAAC,8BAA8B,CAAC;IAIzC;;;;;OAKG;IACI,GAAG,CACR,sBAAsB,EAAE,aAAa,GAAG,cAAc,GAAG,SAAS,GACjE,MAAM,CAAC,qBAAqB,CAAC;IAMhC;;;;;;OAMG;IACI,YAAY,CACjB,sBAAsB,EAAE,aAAa,GAAG,cAAc,GAAG,SAAS,GACjE,MAAM,CAAC,qBAAqB,CAAC;IAQhC;;;;;OAKG;IACI,GAAG,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC;IAIhD;;;;OAIG;IACI,QAAQ,IAAI,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAIvD;;;;;;;OAOG;IACI,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAC;IAK5F;;;;;;OAMG;IACI,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC,qBAAqB,CAAC;IAOjE;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;OAGG;IACI,KAAK,IAAI,IAAI;IAIpB;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAwBzB;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAM7B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,+BAA+B;CAc/C"}
1
+ {"version":3,"file":"simpleContextQualifierProvider.d.ts","sourceRoot":"","sources":["../../../../src/packlets/runtime/context/simpleContextQualifierProvider.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAoE,MAAM,eAAe,CAAC;AACzG,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,cAAc,EAGf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,2BAA2B,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAExG;;;GAGG;AACH,MAAM,WAAW,2CAA2C;IAC1D;;OAEG;IACH,UAAU,EAAE,2BAA2B,CAAC;IAExC;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,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;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,+BAA+B;CAc/C"}
@@ -47,6 +47,9 @@ class SimpleContextQualifierProvider extends contextQualifierProvider_1.ContextQ
47
47
  this._qualifierValues = new ts_utils_1.ResultMap();
48
48
  if (params.qualifierValues) {
49
49
  for (const [name, value] of Object.entries(params.qualifierValues)) {
50
+ if (value === undefined) {
51
+ continue;
52
+ }
50
53
  const qualifierName = common_1.Validate.toQualifierName(name).orThrow();
51
54
  this._qualifierValues.set(qualifierName, value);
52
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"simpleContextQualifierProvider.js","sourceRoot":"","sources":["../../../../src/packlets/runtime/context/simpleContextQualifierProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAyG;AACzG,yCAMsB;AACtB,iDAA0E;AAC1E,yEAAwG;AAkBxG;;;;GAIG;AACH,MAAa,8BACX,SAAQ,mDAAwB;IAmBhC;;;OAGG;IACH,YAAsB,MAAmD;QACvE,KAAK,EAAE,CAAC;QArBV;;;WAGG;QACa,YAAO,GAAS,IAAa,CAAC;QAkB5C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,gBAAgB,GAAG,IAAI,oBAAS,EAAwC,CAAC;QAE9E,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;gBACnE,MAAM,aAAa,GAAG,iBAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;gBAC/D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAClB,MAAmD;QAEnD,OAAO,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,CAAC;aAC3E,eAAe,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,sBAAsB,qCAAqC,CAAC,CAAC;IAChG,CAAC;IAED;;;;;;OAMG;IACK,qBAAqB,CAC3B,sBAAkE;QAElE,OAAO,IAAI,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1G,CAAC;IAED;;;;;;OAMG;IACK,MAAM,CAAC,+BAA+B,CAC5C,sBAAkE;QAElE,OAAO,qBAAU,CAAC,GAAG,CACnB,uBAAuB,EACvB,CAAC,CAAC,EAAgC,EAAE,CAClC,OAAO,CAAC,KAAK,QAAQ;YACrB,CAAC,KAAK,IAAI;YACV,MAAM,IAAI,CAAC;YACX,OAAQ,CAA6B,CAAC,IAAI,KAAK,QAAQ,CAC1D;aACE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;aAC1D,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrC,CAAC;CACF;AAjND,wEAiNC","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, ResultMap, captureResult, succeed, succeedWithDetail, Converters } from '@fgv/ts-utils';\nimport {\n QualifierName,\n QualifierContextValue,\n QualifierIndex,\n Validate,\n Convert as CommonConverters\n} from '../../common';\nimport { IReadOnlyQualifierCollector, Qualifier } from '../../qualifiers';\nimport { ContextQualifierProvider, IMutableContextQualifierProvider } from './contextQualifierProvider';\n\n/**\n * Parameters for creating a {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider}.\n * @public\n */\nexport interface ISimpleContextQualifierProviderCreateParams {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | readonly qualifier collector} that defines and validates qualifiers.\n */\n qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Optional record of initial qualifier name-value pairs to populate the provider.\n */\n qualifierValues?: Record<string, QualifierContextValue>;\n}\n\n/**\n * Simple concrete implementation of {@link Runtime.Context.IContextQualifierProvider | IContextQualifierProvider}\n * using a `ResultMap` for qualifier value storage.\n * @public\n */\nexport class SimpleContextQualifierProvider\n extends ContextQualifierProvider\n implements IMutableContextQualifierProvider\n{\n /**\n * Explicit mutability marker for compile-time type discrimination.\n * Always `true` for mutable providers.\n */\n public readonly mutable: true = true as const;\n\n /**\n * The readonly qualifier collector that defines and validates the qualifiers for this context.\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Internal storage for qualifier values using a ResultMap.\n */\n private readonly _qualifierValues: ResultMap<QualifierName, QualifierContextValue>;\n\n /**\n * Constructor for a {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} object.\n * @param params - {@link Runtime.ISimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.\n */\n protected constructor(params: ISimpleContextQualifierProviderCreateParams) {\n super();\n this.qualifiers = params.qualifiers;\n this._qualifierValues = new ResultMap<QualifierName, QualifierContextValue>();\n\n if (params.qualifierValues) {\n for (const [name, value] of Object.entries(params.qualifierValues)) {\n const qualifierName = Validate.toQualifierName(name).orThrow();\n this._qualifierValues.set(qualifierName, value);\n }\n }\n }\n\n /**\n * Creates a new {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} object.\n * @param params - {@link Runtime.ISimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.\n * @returns `Success` with the new {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(\n params: ISimpleContextQualifierProviderCreateParams\n ): Result<SimpleContextQualifierProvider> {\n return captureResult(() => new SimpleContextQualifierProvider(params));\n }\n\n /**\n * Gets a qualifier value by its name, index, or qualifier object.\n * @param nameOrIndexOrQualifier - The {@link QualifierName | qualifier name}, {@link QualifierIndex | index}, or {@link Qualifiers.Qualifier | qualifier object} to look up.\n * @returns `Success` with the {@link QualifierContextValue | qualifier context value} if found,\n * or `Failure` with an error message if not found or an error occurs.\n */\n public get(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<QualifierContextValue> {\n return this._resolveQualifierName(nameOrIndexOrQualifier).onSuccess((qualifierName) => {\n return this._qualifierValues.get(qualifierName);\n });\n }\n\n /**\n * Gets a validated qualifier context value by its name, index, or qualifier object.\n * TODO: Implement validation logic using qualifier collectors.\n * @param nameOrIndexOrQualifier - The {@link QualifierName | qualifier name}, {@link QualifierIndex | index}, or {@link Qualifiers.Qualifier | qualifier object} to look up.\n * @returns `Success` with the validated {@link QualifierContextValue | qualifier context value} if found,\n * or `Failure` with an error message if not found, invalid, or an error occurs.\n */\n public getValidated(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<QualifierContextValue> {\n return this._resolveQualifier(nameOrIndexOrQualifier).onSuccess((qualifier) => {\n return this._qualifierValues.get(qualifier.name).asResult.onSuccess((value) => {\n return qualifier.validateContextValue(value);\n });\n });\n }\n\n /**\n * Checks if a qualifier value exists with the given name.\n * @param name - The {@link QualifierName | qualifier name} to check.\n * @returns `Success` with `true` if the qualifier value exists, `false` if it doesn't,\n * or `Failure` with an error message if an error occurs during the check.\n */\n public has(name: QualifierName): Result<boolean> {\n return succeed(this._qualifierValues.has(name));\n }\n\n /**\n * Gets all available qualifier names in this context.\n * @returns `Success` with an array of all {@link QualifierName | qualifier names},\n * or `Failure` with an error message if an error occurs.\n */\n public getNames(): Result<ReadonlyArray<QualifierName>> {\n return succeed(Array.from(this._qualifierValues.keys()));\n }\n\n /**\n * Sets a qualifier value in this provider.\n * @param name - The {@link QualifierName | qualifier name} to set.\n * @param value - The {@link QualifierContextValue | qualifier context value} to set.\n * @returns `Success` with the set {@link QualifierContextValue | qualifier context value} if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public set(name: QualifierName, value: QualifierContextValue): Result<QualifierContextValue> {\n this._qualifierValues.set(name, value);\n return succeed(value);\n }\n\n /**\n * Removes a qualifier value from this provider.\n * @param name - The {@link QualifierName | qualifier name} to remove.\n * @returns `Success` with the removed {@link QualifierContextValue | qualifier context value} if successful,\n * or `Failure` with an error message if not found or an error occurs.\n * @public\n */\n public remove(name: QualifierName): Result<QualifierContextValue> {\n return this._qualifierValues.get(name).onSuccess((value) => {\n this._qualifierValues.delete(name);\n return succeedWithDetail(value, 'success');\n });\n }\n\n /**\n * Gets the number of qualifier values in this provider.\n * @returns The count of qualifier values.\n * @public\n */\n public get size(): number {\n return this._qualifierValues.size;\n }\n\n /**\n * Clears all qualifier values from this provider.\n * @public\n */\n public clear(): void {\n this._qualifierValues.clear();\n }\n\n /**\n * Resolves a qualifier from a name, index, or qualifier object.\n * @param nameOrIndexOrQualifier - The input to resolve.\n * @returns `Success` with the {@link Qualifier | qualifier} if successful,\n * or `Failure` with an error message if not found or invalid.\n * @internal\n */\n private _resolveQualifier(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<Qualifier> {\n if (nameOrIndexOrQualifier instanceof Qualifier) {\n return succeed(nameOrIndexOrQualifier);\n }\n /* c8 ignore next 16 - functional code tested but coverage intermittently missed */\n if (typeof nameOrIndexOrQualifier === 'string') {\n return this.qualifiers.validating\n .get(nameOrIndexOrQualifier)\n .withErrorFormat((error) => `${nameOrIndexOrQualifier}: invalid qualifier name.`);\n }\n\n if (typeof nameOrIndexOrQualifier === 'number') {\n return this.qualifiers\n .getAt(nameOrIndexOrQualifier)\n .withErrorFormat((error) => `${nameOrIndexOrQualifier}: invalid qualifier index.`);\n }\n\n return SimpleContextQualifierProvider._qualifierNameFromQualifierLike(nameOrIndexOrQualifier)\n .onSuccess((qualifierName) => this.qualifiers.validating.get(qualifierName))\n .withErrorFormat((error) => `${nameOrIndexOrQualifier}: invalid Qualifier, name or index.`);\n }\n\n /**\n * Resolves a qualifier name from a name, index, or qualifier object.\n * @param nameOrIndexOrQualifier - The input to resolve.\n * @returns `Success` with the {@link QualifierName | qualifier name} if successful,\n * or `Failure` with an error message if not found or invalid.\n * @internal\n */\n private _resolveQualifierName(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<QualifierName> {\n return this._resolveQualifier(nameOrIndexOrQualifier).onSuccess((qualifier) => succeed(qualifier.name));\n }\n\n /**\n * Resolves a qualifier name from a qualifier-like object.\n * @param nameOrIndexOrQualifier - The input to resolve.\n * @returns `Success` with the {@link QualifierName | qualifier name} if successful,\n * or `Failure` with an error message if not found or invalid.\n * @internal\n */\n private static _qualifierNameFromQualifierLike(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<QualifierName> {\n return Converters.isA(\n 'Qualifier-like object',\n (v): v is { name: QualifierName } =>\n typeof v === 'object' &&\n v !== null &&\n 'name' in v &&\n typeof (v as Record<string, unknown>).name === 'string'\n )\n .map((v) => CommonConverters.qualifierName.convert(v.name))\n .convert(nameOrIndexOrQualifier);\n }\n}\n"]}
1
+ {"version":3,"file":"simpleContextQualifierProvider.js","sourceRoot":"","sources":["../../../../src/packlets/runtime/context/simpleContextQualifierProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAyG;AACzG,yCAMsB;AACtB,iDAA0E;AAC1E,yEAAwG;AAyBxG;;;;GAIG;AACH,MAAa,8BACX,SAAQ,mDAAwB;IAmBhC;;;OAGG;IACH,YAAsB,MAAmD;QACvE,KAAK,EAAE,CAAC;QArBV;;;WAGG;QACa,YAAO,GAAS,IAAa,CAAC;QAkB5C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,gBAAgB,GAAG,IAAI,oBAAS,EAAwC,CAAC;QAE9E,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC3B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;gBACnE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACxB,SAAS;gBACX,CAAC;gBACD,MAAM,aAAa,GAAG,iBAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;gBAC/D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAClB,MAAmD;QAEnD,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,8BAA8B,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,CAAC;IAED;;;;;OAKG;IACI,GAAG,CACR,sBAAkE;QAElE,OAAO,IAAI,CAAC,qBAAqB,CAAC,sBAAsB,CAAC,CAAC,SAAS,CAAC,CAAC,aAA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CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1G,CAAC;IAED;;;;;;OAMG;IACK,MAAM,CAAC,+BAA+B,CAC5C,sBAAkE;QAElE,OAAO,qBAAU,CAAC,GAAG,CACnB,uBAAuB,EACvB,CAAC,CAAC,EAAgC,EAAE,CAClC,OAAO,CAAC,KAAK,QAAQ;YACrB,CAAC,KAAK,IAAI;YACV,MAAM,IAAI,CAAC;YACX,OAAQ,CAA6B,CAAC,IAAI,KAAK,QAAQ,CAC1D;aACE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;aAC1D,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrC,CAAC;CACF;AApND,wEAoNC","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, ResultMap, captureResult, succeed, succeedWithDetail, Converters } from '@fgv/ts-utils';\nimport {\n QualifierName,\n QualifierContextValue,\n QualifierIndex,\n Validate,\n Convert as CommonConverters\n} from '../../common';\nimport { IReadOnlyQualifierCollector, Qualifier } from '../../qualifiers';\nimport { ContextQualifierProvider, IMutableContextQualifierProvider } from './contextQualifierProvider';\n\n/**\n * Parameters for creating a {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider}.\n * @public\n */\nexport interface ISimpleContextQualifierProviderCreateParams {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | readonly qualifier collector} that defines and validates qualifiers.\n */\n qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Optional record of initial qualifier name-value pairs to populate the provider.\n *\n * @remarks\n * Typed as `Readonly<Partial<Record<string, QualifierContextValue>>>` so a\n * caller can naturally express conditional context construction, e.g.\n * `tone === 'formal' ? { tone: 'formal' } : {}`. Entries whose value is\n * `undefined` are skipped on load - semantically equivalent to omitting\n * the key, which is how the candidate selector treats a missing key.\n */\n qualifierValues?: Readonly<Partial<Record<string, QualifierContextValue>>>;\n}\n\n/**\n * Simple concrete implementation of {@link Runtime.Context.IContextQualifierProvider | IContextQualifierProvider}\n * using a `ResultMap` for qualifier value storage.\n * @public\n */\nexport class SimpleContextQualifierProvider\n extends ContextQualifierProvider\n implements IMutableContextQualifierProvider\n{\n /**\n * Explicit mutability marker for compile-time type discrimination.\n * Always `true` for mutable providers.\n */\n public readonly mutable: true = true as const;\n\n /**\n * The readonly qualifier collector that defines and validates the qualifiers for this context.\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Internal storage for qualifier values using a ResultMap.\n */\n private readonly _qualifierValues: ResultMap<QualifierName, QualifierContextValue>;\n\n /**\n * Constructor for a {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} object.\n * @param params - {@link Runtime.ISimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.\n */\n protected constructor(params: ISimpleContextQualifierProviderCreateParams) {\n super();\n this.qualifiers = params.qualifiers;\n this._qualifierValues = new ResultMap<QualifierName, QualifierContextValue>();\n\n if (params.qualifierValues) {\n for (const [name, value] of Object.entries(params.qualifierValues)) {\n if (value === undefined) {\n continue;\n }\n const qualifierName = Validate.toQualifierName(name).orThrow();\n this._qualifierValues.set(qualifierName, value);\n }\n }\n }\n\n /**\n * Creates a new {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} object.\n * @param params - {@link Runtime.ISimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.\n * @returns `Success` with the new {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(\n params: ISimpleContextQualifierProviderCreateParams\n ): Result<SimpleContextQualifierProvider> {\n return captureResult(() => new SimpleContextQualifierProvider(params));\n }\n\n /**\n * Gets a qualifier value by its name, index, or qualifier object.\n * @param nameOrIndexOrQualifier - The {@link QualifierName | qualifier name}, {@link QualifierIndex | index}, or {@link Qualifiers.Qualifier | qualifier object} to look up.\n * @returns `Success` with the {@link QualifierContextValue | qualifier context value} if found,\n * or `Failure` with an error message if not found or an error occurs.\n */\n public get(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<QualifierContextValue> {\n return this._resolveQualifierName(nameOrIndexOrQualifier).onSuccess((qualifierName) => {\n return this._qualifierValues.get(qualifierName);\n });\n }\n\n /**\n * Gets a validated qualifier context value by its name, index, or qualifier object.\n * TODO: Implement validation logic using qualifier collectors.\n * @param nameOrIndexOrQualifier - The {@link QualifierName | qualifier name}, {@link QualifierIndex | index}, or {@link Qualifiers.Qualifier | qualifier object} to look up.\n * @returns `Success` with the validated {@link QualifierContextValue | qualifier context value} if found,\n * or `Failure` with an error message if not found, invalid, or an error occurs.\n */\n public getValidated(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<QualifierContextValue> {\n return this._resolveQualifier(nameOrIndexOrQualifier).onSuccess((qualifier) => {\n return this._qualifierValues.get(qualifier.name).asResult.onSuccess((value) => {\n return qualifier.validateContextValue(value);\n });\n });\n }\n\n /**\n * Checks if a qualifier value exists with the given name.\n * @param name - The {@link QualifierName | qualifier name} to check.\n * @returns `Success` with `true` if the qualifier value exists, `false` if it doesn't,\n * or `Failure` with an error message if an error occurs during the check.\n */\n public has(name: QualifierName): Result<boolean> {\n return succeed(this._qualifierValues.has(name));\n }\n\n /**\n * Gets all available qualifier names in this context.\n * @returns `Success` with an array of all {@link QualifierName | qualifier names},\n * or `Failure` with an error message if an error occurs.\n */\n public getNames(): Result<ReadonlyArray<QualifierName>> {\n return succeed(Array.from(this._qualifierValues.keys()));\n }\n\n /**\n * Sets a qualifier value in this provider.\n * @param name - The {@link QualifierName | qualifier name} to set.\n * @param value - The {@link QualifierContextValue | qualifier context value} to set.\n * @returns `Success` with the set {@link QualifierContextValue | qualifier context value} if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public set(name: QualifierName, value: QualifierContextValue): Result<QualifierContextValue> {\n this._qualifierValues.set(name, value);\n return succeed(value);\n }\n\n /**\n * Removes a qualifier value from this provider.\n * @param name - The {@link QualifierName | qualifier name} to remove.\n * @returns `Success` with the removed {@link QualifierContextValue | qualifier context value} if successful,\n * or `Failure` with an error message if not found or an error occurs.\n * @public\n */\n public remove(name: QualifierName): Result<QualifierContextValue> {\n return this._qualifierValues.get(name).onSuccess((value) => {\n this._qualifierValues.delete(name);\n return succeedWithDetail(value, 'success');\n });\n }\n\n /**\n * Gets the number of qualifier values in this provider.\n * @returns The count of qualifier values.\n * @public\n */\n public get size(): number {\n return this._qualifierValues.size;\n }\n\n /**\n * Clears all qualifier values from this provider.\n * @public\n */\n public clear(): void {\n this._qualifierValues.clear();\n }\n\n /**\n * Resolves a qualifier from a name, index, or qualifier object.\n * @param nameOrIndexOrQualifier - The input to resolve.\n * @returns `Success` with the {@link Qualifier | qualifier} if successful,\n * or `Failure` with an error message if not found or invalid.\n * @internal\n */\n private _resolveQualifier(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<Qualifier> {\n if (nameOrIndexOrQualifier instanceof Qualifier) {\n return succeed(nameOrIndexOrQualifier);\n }\n /* c8 ignore next 16 - functional code tested but coverage intermittently missed */\n if (typeof nameOrIndexOrQualifier === 'string') {\n return this.qualifiers.validating\n .get(nameOrIndexOrQualifier)\n .withErrorFormat((error) => `${nameOrIndexOrQualifier}: invalid qualifier name.`);\n }\n\n if (typeof nameOrIndexOrQualifier === 'number') {\n return this.qualifiers\n .getAt(nameOrIndexOrQualifier)\n .withErrorFormat((error) => `${nameOrIndexOrQualifier}: invalid qualifier index.`);\n }\n\n return SimpleContextQualifierProvider._qualifierNameFromQualifierLike(nameOrIndexOrQualifier)\n .onSuccess((qualifierName) => this.qualifiers.validating.get(qualifierName))\n .withErrorFormat((error) => `${nameOrIndexOrQualifier}: invalid Qualifier, name or index.`);\n }\n\n /**\n * Resolves a qualifier name from a name, index, or qualifier object.\n * @param nameOrIndexOrQualifier - The input to resolve.\n * @returns `Success` with the {@link QualifierName | qualifier name} if successful,\n * or `Failure` with an error message if not found or invalid.\n * @internal\n */\n private _resolveQualifierName(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<QualifierName> {\n return this._resolveQualifier(nameOrIndexOrQualifier).onSuccess((qualifier) => succeed(qualifier.name));\n }\n\n /**\n * Resolves a qualifier name from a qualifier-like object.\n * @param nameOrIndexOrQualifier - The input to resolve.\n * @returns `Success` with the {@link QualifierName | qualifier name} if successful,\n * or `Failure` with an error message if not found or invalid.\n * @internal\n */\n private static _qualifierNameFromQualifierLike(\n nameOrIndexOrQualifier: QualifierName | QualifierIndex | Qualifier\n ): Result<QualifierName> {\n return Converters.isA(\n 'Qualifier-like object',\n (v): v is { name: QualifierName } =>\n typeof v === 'object' &&\n v !== null &&\n 'name' in v &&\n typeof (v as Record<string, unknown>).name === 'string'\n )\n .map((v) => CommonConverters.qualifierName.convert(v.name))\n .convert(nameOrIndexOrQualifier);\n }\n}\n"]}
@@ -14,8 +14,15 @@ export interface IValidatingSimpleContextQualifierProviderCreateParams {
14
14
  /**
15
15
  * Optional record of initial qualifier name-value pairs to populate the provider.
16
16
  * Accepts string keys and values which will be converted to strongly-typed values.
17
+ *
18
+ * @remarks
19
+ * Typed as `Readonly<Partial<Record<string, string>>>` so callers can
20
+ * naturally express conditional context construction, e.g.
21
+ * `tone === 'formal' ? { tone: 'formal' } : {}`. Entries whose value is
22
+ * `undefined` are skipped on load - semantically equivalent to omitting
23
+ * the key.
17
24
  */
18
- qualifierValues?: Record<string, string>;
25
+ qualifierValues?: Readonly<Partial<Record<string, string>>>;
19
26
  }
20
27
  /**
21
28
  * A {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} with a
@@ -1 +1 @@
1
- {"version":3,"file":"validatingSimpleContextQualifierProvider.d.ts","sourceRoot":"","sources":["../../../../src/packlets/runtime/context/validatingSimpleContextQualifierProvider.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EACL,yCAAyC,EAE1C,MAAM,qCAAqC,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,qDAAqD;IACpE;;OAEG;IACH,UAAU,EAAE,2BAA2B,CAAC;IAExC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,qBAAa,wCAAyC,SAAQ,8BAA8B;IAC1F;;;OAGG;IACH,SAAgB,UAAU,EAAE,yCAAyC,CAAC;IAEtE;;;OAGG;IACH,SAAS,aAAa,MAAM,EAAE,qDAAqD;IAiBnF;;;;;;OAMG;WACW,MAAM,CAClB,MAAM,EAAE,qDAAqD,GAC5D,MAAM,CAAC,wCAAwC,CAAC;CAGpD"}
1
+ {"version":3,"file":"validatingSimpleContextQualifierProvider.d.ts","sourceRoot":"","sources":["../../../../src/packlets/runtime/context/validatingSimpleContextQualifierProvider.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EACL,yCAAyC,EAE1C,MAAM,qCAAqC,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,qDAAqD;IACpE;;OAEG;IACH,UAAU,EAAE,2BAA2B,CAAC;IAExC;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CAC7D;AAED;;;;;;GAMG;AACH,qBAAa,wCAAyC,SAAQ,8BAA8B;IAC1F;;;OAGG;IACH,SAAgB,UAAU,EAAE,yCAAyC,CAAC;IAEtE;;;OAGG;IACH,SAAS,aAAa,MAAM,EAAE,qDAAqD;IAenF;;;;;;OAMG;WACW,MAAM,CAClB,MAAM,EAAE,qDAAqD,GAC5D,MAAM,CAAC,wCAAwC,CAAC;CAGpD"}
@@ -38,11 +38,9 @@ class ValidatingSimpleContextQualifierProvider extends simpleContextQualifierPro
38
38
  * @param params - {@link Runtime.IValidatingSimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.
39
39
  */
40
40
  constructor(params) {
41
- // Convert string values to QualifierContextValue for the base class
42
- /* c8 ignore next 5 - functional code path tested but coverage intermittently missed */
43
- const convertedValues = params.qualifierValues
44
- ? Object.fromEntries(Object.entries(params.qualifierValues).map(([key, value]) => [key, value]))
45
- : undefined;
41
+ // The branded QualifierContextValue is structurally a string; widen via cast
42
+ // and let the base class skip undefined entries on load.
43
+ const convertedValues = params.qualifierValues;
46
44
  super({
47
45
  qualifiers: params.qualifiers,
48
46
  qualifierValues: convertedValues
@@ -1 +1 @@
1
- {"version":3,"file":"validatingSimpleContextQualifierProvider.js","sourceRoot":"","sources":["../../../../src/packlets/runtime/context/validatingSimpleContextQualifierProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AAGtD,qFAAkF;AAClF,2FAG6C;AAmB7C;;;;;;GAMG;AACH,MAAa,wCAAyC,SAAQ,+DAA8B;IAO1F;;;OAGG;IACH,YAAsB,MAA6D;QACjF,oEAAoE;QACpE,uFAAuF;QACvF,MAAM,eAAe,GAAsD,MAAM,CAAC,eAAe;YAC/F,CAAC,CAAC,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAA8B,CAAC,CAAC,CACpG;YACH,CAAC,CAAC,SAAS,CAAC;QAEd,KAAK,CAAC;YACJ,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,eAAe,EAAE,eAAe;SACjC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,IAAI,4EAAwC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAClB,MAA6D;QAE7D,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,wCAAwC,CAAC,MAAM,CAAC,CAAC,CAAC;IACnF,CAAC;CACF;AAxCD,4FAwCC","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, captureResult } from '@fgv/ts-utils';\nimport { QualifierContextValue } from '../../common';\nimport { IReadOnlyQualifierCollector } from '../../qualifiers';\nimport { SimpleContextQualifierProvider } from './simpleContextQualifierProvider';\nimport {\n IMutableContextQualifierProviderValidator,\n MutableContextQualifierProviderValidator\n} from './contextQualifierProviderValidator';\n\n/**\n * Parameters for creating a {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider}.\n * @public\n */\nexport interface IValidatingSimpleContextQualifierProviderCreateParams {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | readonly qualifier collector} that defines and validates qualifiers.\n */\n qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Optional record of initial qualifier name-value pairs to populate the provider.\n * Accepts string keys and values which will be converted to strongly-typed values.\n */\n qualifierValues?: Record<string, string>;\n}\n\n/**\n * A {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} with a\n * {@link Runtime.Context.MutableContextQualifierProviderValidator | validator} property that enables\n * validated use of the underlying provider with string keys and values.\n * This eliminates the need for type casting in consumer code.\n * @public\n */\nexport class ValidatingSimpleContextQualifierProvider extends SimpleContextQualifierProvider {\n /**\n * A {@link Runtime.Context.MutableContextQualifierProviderValidator | MutableContextQualifierProviderValidator} which validates\n * string inputs before passing them to this provider.\n */\n public readonly validating: IMutableContextQualifierProviderValidator;\n\n /**\n * Constructor for a {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider} object.\n * @param params - {@link Runtime.IValidatingSimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.\n */\n protected constructor(params: IValidatingSimpleContextQualifierProviderCreateParams) {\n // Convert string values to QualifierContextValue for the base class\n /* c8 ignore next 5 - functional code path tested but coverage intermittently missed */\n const convertedValues: Record<string, QualifierContextValue> | undefined = params.qualifierValues\n ? Object.fromEntries(\n Object.entries(params.qualifierValues).map(([key, value]) => [key, value as QualifierContextValue])\n )\n : undefined;\n\n super({\n qualifiers: params.qualifiers,\n qualifierValues: convertedValues\n });\n\n this.validating = new MutableContextQualifierProviderValidator({ provider: this });\n }\n\n /**\n * Creates a new {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider} object.\n * @param params - {@link Runtime.IValidatingSimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.\n * @returns `Success` with the new {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(\n params: IValidatingSimpleContextQualifierProviderCreateParams\n ): Result<ValidatingSimpleContextQualifierProvider> {\n return captureResult(() => new ValidatingSimpleContextQualifierProvider(params));\n }\n}\n"]}
1
+ {"version":3,"file":"validatingSimpleContextQualifierProvider.js","sourceRoot":"","sources":["../../../../src/packlets/runtime/context/validatingSimpleContextQualifierProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AAGtD,qFAAkF;AAClF,2FAG6C;AA0B7C;;;;;;GAMG;AACH,MAAa,wCAAyC,SAAQ,+DAA8B;IAO1F;;;OAGG;IACH,YAAsB,MAA6D;QACjF,6EAA6E;QAC7E,yDAAyD;QACzD,MAAM,eAAe,GAAG,MAAM,CAAC,eAElB,CAAC;QAEd,KAAK,CAAC;YACJ,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,eAAe,EAAE,eAAe;SACjC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,IAAI,4EAAwC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAClB,MAA6D;QAE7D,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,wCAAwC,CAAC,MAAM,CAAC,CAAC,CAAC;IACnF,CAAC;CACF;AAtCD,4FAsCC","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, captureResult } from '@fgv/ts-utils';\nimport { QualifierContextValue } from '../../common';\nimport { IReadOnlyQualifierCollector } from '../../qualifiers';\nimport { SimpleContextQualifierProvider } from './simpleContextQualifierProvider';\nimport {\n IMutableContextQualifierProviderValidator,\n MutableContextQualifierProviderValidator\n} from './contextQualifierProviderValidator';\n\n/**\n * Parameters for creating a {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider}.\n * @public\n */\nexport interface IValidatingSimpleContextQualifierProviderCreateParams {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | readonly qualifier collector} that defines and validates qualifiers.\n */\n qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * Optional record of initial qualifier name-value pairs to populate the provider.\n * Accepts string keys and values which will be converted to strongly-typed values.\n *\n * @remarks\n * Typed as `Readonly<Partial<Record<string, string>>>` so callers can\n * naturally express conditional context construction, e.g.\n * `tone === 'formal' ? { tone: 'formal' } : {}`. Entries whose value is\n * `undefined` are skipped on load - semantically equivalent to omitting\n * the key.\n */\n qualifierValues?: Readonly<Partial<Record<string, string>>>;\n}\n\n/**\n * A {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} with a\n * {@link Runtime.Context.MutableContextQualifierProviderValidator | validator} property that enables\n * validated use of the underlying provider with string keys and values.\n * This eliminates the need for type casting in consumer code.\n * @public\n */\nexport class ValidatingSimpleContextQualifierProvider extends SimpleContextQualifierProvider {\n /**\n * A {@link Runtime.Context.MutableContextQualifierProviderValidator | MutableContextQualifierProviderValidator} which validates\n * string inputs before passing them to this provider.\n */\n public readonly validating: IMutableContextQualifierProviderValidator;\n\n /**\n * Constructor for a {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider} object.\n * @param params - {@link Runtime.IValidatingSimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.\n */\n protected constructor(params: IValidatingSimpleContextQualifierProviderCreateParams) {\n // The branded QualifierContextValue is structurally a string; widen via cast\n // and let the base class skip undefined entries on load.\n const convertedValues = params.qualifierValues as\n | Readonly<Partial<Record<string, QualifierContextValue>>>\n | undefined;\n\n super({\n qualifiers: params.qualifiers,\n qualifierValues: convertedValues\n });\n\n this.validating = new MutableContextQualifierProviderValidator({ provider: this });\n }\n\n /**\n * Creates a new {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider} object.\n * @param params - {@link Runtime.IValidatingSimpleContextQualifierProviderCreateParams | Parameters} used to create the provider.\n * @returns `Success` with the new {@link Runtime.ValidatingSimpleContextQualifierProvider | ValidatingSimpleContextQualifierProvider} object if successful,\n * or `Failure` with an error message if not.\n * @public\n */\n public static create(\n params: IValidatingSimpleContextQualifierProviderCreateParams\n ): Result<ValidatingSimpleContextQualifierProvider> {\n return captureResult(() => new ValidatingSimpleContextQualifierProvider(params));\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-res",
3
- "version": "5.1.0-28",
3
+ "version": "5.1.0-29",
4
4
  "description": "Multi-dimensional Resource Runtime",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-res.d.ts",
@@ -45,18 +45,18 @@
45
45
  "@types/heft-jest": "1.0.6",
46
46
  "eslint-plugin-tsdoc": "~0.5.2",
47
47
  "typedoc": "~0.28.16",
48
- "@fgv/heft-dual-rig": "5.1.0-28",
49
- "@fgv/typedoc-compact-theme": "5.1.0-28",
50
- "@fgv/ts-utils-jest": "5.1.0-28",
51
- "@fgv/ts-extras": "5.1.0-28"
48
+ "@fgv/heft-dual-rig": "5.1.0-29",
49
+ "@fgv/typedoc-compact-theme": "5.1.0-29",
50
+ "@fgv/ts-utils-jest": "5.1.0-29",
51
+ "@fgv/ts-extras": "5.1.0-29"
52
52
  },
53
53
  "dependencies": {
54
54
  "luxon": "^3.7.2",
55
55
  "fflate": "~0.8.2",
56
- "@fgv/ts-utils": "5.1.0-28",
57
- "@fgv/ts-json-base": "5.1.0-28",
58
- "@fgv/ts-bcp47": "5.1.0-28",
59
- "@fgv/ts-json": "5.1.0-28"
56
+ "@fgv/ts-utils": "5.1.0-29",
57
+ "@fgv/ts-json-base": "5.1.0-29",
58
+ "@fgv/ts-bcp47": "5.1.0-29",
59
+ "@fgv/ts-json": "5.1.0-29"
60
60
  },
61
61
  "exports": {
62
62
  ".": {