@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
@@ -28,18 +28,49 @@ export interface IReadOnlyQualifierCollector extends Collections.IReadOnlyValida
28
28
  /**
29
29
  * Parameters for creating a new {@link Qualifiers.QualifierCollector}.
30
30
  * @public
31
+ *
32
+ * @remarks
33
+ * `qualifiers` accepts a mixed array of bare axis-name strings and full
34
+ * {@link Qualifiers.IQualifierDecl | declarations}. A string element is
35
+ * sugar for "literal qualifier with this name"; the library synthesizes a
36
+ * {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType} and a
37
+ * declaration `{ name, typeName: name, defaultPriority: <descending> }`.
38
+ *
39
+ * Synthesized priorities are distributed across the
40
+ * `[MinConditionPriority..MaxConditionPriority]` range adaptively to the
41
+ * array length: `step = max(1, floor((Max - Min) / length))`,
42
+ * `priority = max(Min, Max - index * step)`. Earlier elements get higher
43
+ * priority. The formula never overflows the `ConditionPriority` range
44
+ * regardless of input length; for inputs whose length exceeds the range
45
+ * cardinality (\>1000 axes), trailing priorities collapse at
46
+ * `MinConditionPriority` — supply explicit priorities in that regime
47
+ * if uniqueness matters.
48
+ *
49
+ * `qualifierTypes` may be omitted only when every element of `qualifiers`
50
+ * is a string. If any element is an {@link Qualifiers.IQualifierDecl},
51
+ * `qualifierTypes` must be supplied and must contain the referenced
52
+ * {@link Qualifiers.IQualifierDecl.typeName | typeNames}.
31
53
  */
32
54
  export interface IQualifierCollectorCreateParams {
33
55
  /**
34
56
  * The {@link QualifierTypes.QualifierTypeCollector | qualifier types} used to
35
57
  * create {@link Qualifiers.Qualifier | qualifiers} from {@link Qualifiers.IQualifierDecl | declarations}.
58
+ *
59
+ * Optional only when every entry in `qualifiers` is a bare axis-name string
60
+ * (in which case the library synthesizes a literal qualifier type per name).
36
61
  */
37
- qualifierTypes: ReadOnlyQualifierTypeCollector;
62
+ qualifierTypes?: ReadOnlyQualifierTypeCollector;
38
63
  /**
39
- * Optional list of {@link Qualifiers.IQualifierDecl | declarations} for the qualifiers to add to the collection
40
- * upon creation.
64
+ * Optional list of {@link Qualifiers.IQualifierDecl | declarations} or bare
65
+ * axis-name strings for the qualifiers to add to the collection on creation.
66
+ *
67
+ * @remarks
68
+ * A string element `'foo'` is sugar for a literal qualifier:
69
+ * `{ name: 'foo', typeName: 'foo', defaultPriority: <descending> }` backed by
70
+ * a synthesized {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType}
71
+ * named `'foo'`.
41
72
  */
42
- qualifiers?: IQualifierDecl[];
73
+ qualifiers?: ReadonlyArray<string | IQualifierDecl>;
43
74
  }
44
75
  /**
45
76
  * Collects {@link Qualifiers.Qualifier | Qualifiers} from {@link Qualifiers.IQualifierDecl | declarations},
@@ -54,16 +85,83 @@ export declare class QualifierCollector extends ValidatingConvertingCollector<Qu
54
85
  qualifierTypes: ReadOnlyQualifierTypeCollector;
55
86
  /**
56
87
  * Constructor for a {@link Qualifiers.QualifierCollector | QualifierCollector} object.
57
- * @param params - Parameters for creating the collector.
88
+ * @param qualifierTypes - The {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier types}
89
+ * used to validate declarations.
90
+ * @param qualifiers - Optional list of fully-resolved {@link Qualifiers.IQualifierDecl | declarations}.
58
91
  * @public
59
92
  */
60
- protected constructor(params: IQualifierCollectorCreateParams);
93
+ protected constructor(qualifierTypes: ReadOnlyQualifierTypeCollector, qualifiers?: ReadonlyArray<IQualifierDecl>);
61
94
  /**
62
95
  * Creates a new {@link Qualifiers.QualifierCollector | QualifierCollector} object.
63
96
  * @param params - {@link Qualifiers.IQualifierCollectorCreateParams | Parameters} for creating a new {@link Qualifiers.QualifierCollector | QualifierCollector}.
64
97
  * @returns `Success` with the new collector if successful, or `Failure` if not.
98
+ *
99
+ * @remarks
100
+ * Accepts a mixed array of bare axis-name strings and full
101
+ * {@link Qualifiers.IQualifierDecl | declarations}. String elements are sugar
102
+ * for a literal qualifier: the library synthesizes a
103
+ * {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType} named
104
+ * after the string and a declaration `{ name, typeName: name, defaultPriority }`.
105
+ * Synthesized priorities are distributed across the
106
+ * `[MinConditionPriority..MaxConditionPriority]` range adaptively to the
107
+ * input length (`step = max(1, floor((Max - Min) / length))`,
108
+ * `priority = max(Min, Max - index * step)`). Earlier elements get higher
109
+ * priority — matching the "earlier qualifier wins when multiple match"
110
+ * mental model — and the formula never overflows the `ConditionPriority`
111
+ * range regardless of input length.
112
+ *
113
+ * `qualifierTypes` may be omitted only when every element of `qualifiers`
114
+ * is a string. If any element is a declaration, `qualifierTypes` is
115
+ * required (and must include the referenced typeNames); the error message
116
+ * names the offending typeName when it is missing.
65
117
  */
66
118
  static create(params: IQualifierCollectorCreateParams): Result<QualifierCollector>;
119
+ /**
120
+ * Resolves the public {@link Qualifiers.IQualifierCollectorCreateParams | create params}
121
+ * into the concrete `(qualifierTypes, qualifiers)` pair the constructor expects.
122
+ *
123
+ * @remarks
124
+ * Validates the mixed-shape `qualifiers` input through
125
+ * {@link Converters.oneOf} (string vs {@link Qualifiers.IQualifierDecl})
126
+ * at the public-API boundary, then partitions into bare-string and decl
127
+ * buckets to drive type synthesis. If any decl is present and
128
+ * `qualifierTypes` is omitted, fails with an error that names the
129
+ * offending typeNames.
130
+ *
131
+ * @internal
132
+ */
133
+ private static _resolveCreateParams;
134
+ /**
135
+ * Returns the provided {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier-type collector}
136
+ * (or synthesizes a new one) augmented with synthesized literal qualifier types for the supplied
137
+ * string names that are not already present.
138
+ *
139
+ * @internal
140
+ */
141
+ private static _resolveQualifierTypes;
142
+ /**
143
+ * Normalizes a mixed `(string | IQualifierDecl)[]` into a fully-resolved
144
+ * `IQualifierDecl[]`, assigning descending default priorities to synthesized
145
+ * decls within the `[MinConditionPriority..MaxConditionPriority]` range.
146
+ *
147
+ * @remarks
148
+ * Step size is adaptive to input length:
149
+ * `step = max(1, floor((Max - Min) / length))`. Each synthesized priority
150
+ * is `max(Min, Max - index * step)` — clamped at the bottom so length
151
+ * extremes (\>1000 axes) degrade gracefully into a tail of equal-`Min`
152
+ * priorities rather than overflowing the `ConditionPriority` range.
153
+ *
154
+ * @internal
155
+ */
156
+ private static _normalizeQualifierDecls;
157
+ /**
158
+ * Returns an empty {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier-type collector}
159
+ * used as a placeholder when no qualifiers are supplied and the caller omits
160
+ * `qualifierTypes`.
161
+ *
162
+ * @internal
163
+ */
164
+ private static _emptyQualifierTypes;
67
165
  /**
68
166
  * {@inheritDoc Qualifiers.IReadOnlyQualifierCollector.getByNameOrToken}
69
167
  */
@@ -1 +1 @@
1
- {"version":3,"file":"qualifierCollector.d.ts","sourceRoot":"","sources":["../../../src/packlets/qualifiers/qualifierCollector.ts"],"names":[],"mappings":"AAuBA,OAAO,EAEL,WAAW,EAEX,MAAM,EAIN,6BAA6B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAA2B,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,2BAA4B,SAAQ,WAAW,CAAC,4BAA4B,CAAC,SAAS,CAAC;IACtG;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,8BAA8B,CAAC;IAExD;;;;OAIG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAEzD;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,cAAc,EAAE,8BAA8B,CAAC;IAE/C;;;OAGG;IACH,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,qBAAa,kBACX,SAAQ,6BAA6B,CAAC,SAAS,EAAE,cA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Collector = void 0;
58
58
  const Common = __importStar(require("../common"));
59
59
  const ts_utils_1 = require("@fgv/ts-utils");
60
+ const common_1 = require("../common");
60
61
  const qualifier_1 = require("./qualifier");
61
62
  const convert_1 = require("./convert");
63
+ const qualifier_types_1 = require("../qualifier-types");
64
+ /**
65
+ * Converter for a single entry in the mixed-shape
66
+ * {@link Qualifiers.IQualifierCollectorCreateParams.qualifiers | qualifiers}
67
+ * input — either a bare axis-name string or a full
68
+ * {@link Qualifiers.IQualifierDecl | declaration}. Validates the entry
69
+ * shape at the public-API boundary rather than deferring to the
70
+ * internal qualifier factory.
71
+ */
72
+ const _qualifierEntriesConverter = ts_utils_1.Converters.arrayOf(ts_utils_1.Converters.oneOf([ts_utils_1.Converters.string, convert_1.qualifierDecl]));
62
73
  /**
63
74
  * Collects {@link Qualifiers.Qualifier | Qualifiers} from {@link Qualifiers.IQualifierDecl | declarations},
64
75
  * with strongly-typed ({@link QualifierName | QualifierName} and {@link QualifierIndex | QualifierIndex}) key
@@ -68,11 +79,12 @@ const convert_1 = require("./convert");
68
79
  class QualifierCollector extends ts_utils_1.ValidatingConvertingCollector {
69
80
  /**
70
81
  * Constructor for a {@link Qualifiers.QualifierCollector | QualifierCollector} object.
71
- * @param params - Parameters for creating the collector.
82
+ * @param qualifierTypes - The {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier types}
83
+ * used to validate declarations.
84
+ * @param qualifiers - Optional list of fully-resolved {@link Qualifiers.IQualifierDecl | declarations}.
72
85
  * @public
73
86
  */
74
- constructor(params) {
75
- var _a;
87
+ constructor(qualifierTypes, qualifiers) {
76
88
  super({
77
89
  factory: (k, i, v) => this._qualifierFactory(k, i, v),
78
90
  converters: new ts_utils_1.Collections.KeyValueConverters({
@@ -80,17 +92,149 @@ class QualifierCollector extends ts_utils_1.ValidatingConvertingCollector {
80
92
  value: convert_1.qualifierDecl
81
93
  })
82
94
  });
83
- this.qualifierTypes = params.qualifierTypes;
95
+ this.qualifierTypes = qualifierTypes;
84
96
  /* c8 ignore next 1 - coverage misses the branch intermittently */
85
- (_a = params.qualifiers) === null || _a === void 0 ? void 0 : _a.forEach((q) => this.validating.add(q.name, q).orThrow());
97
+ qualifiers === null || qualifiers === void 0 ? void 0 : qualifiers.forEach((q) => this.validating.add(q.name, q).orThrow());
86
98
  }
87
99
  /**
88
100
  * Creates a new {@link Qualifiers.QualifierCollector | QualifierCollector} object.
89
101
  * @param params - {@link Qualifiers.IQualifierCollectorCreateParams | Parameters} for creating a new {@link Qualifiers.QualifierCollector | QualifierCollector}.
90
102
  * @returns `Success` with the new collector if successful, or `Failure` if not.
103
+ *
104
+ * @remarks
105
+ * Accepts a mixed array of bare axis-name strings and full
106
+ * {@link Qualifiers.IQualifierDecl | declarations}. String elements are sugar
107
+ * for a literal qualifier: the library synthesizes a
108
+ * {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType} named
109
+ * after the string and a declaration `{ name, typeName: name, defaultPriority }`.
110
+ * Synthesized priorities are distributed across the
111
+ * `[MinConditionPriority..MaxConditionPriority]` range adaptively to the
112
+ * input length (`step = max(1, floor((Max - Min) / length))`,
113
+ * `priority = max(Min, Max - index * step)`). Earlier elements get higher
114
+ * priority — matching the "earlier qualifier wins when multiple match"
115
+ * mental model — and the formula never overflows the `ConditionPriority`
116
+ * range regardless of input length.
117
+ *
118
+ * `qualifierTypes` may be omitted only when every element of `qualifiers`
119
+ * is a string. If any element is a declaration, `qualifierTypes` is
120
+ * required (and must include the referenced typeNames); the error message
121
+ * names the offending typeName when it is missing.
91
122
  */
92
123
  static create(params) {
93
- return (0, ts_utils_1.captureResult)(() => new QualifierCollector(params));
124
+ return QualifierCollector._resolveCreateParams(params).onSuccess(({ qualifierTypes, qualifiers }) => {
125
+ return (0, ts_utils_1.captureResult)(() => new QualifierCollector(qualifierTypes, qualifiers));
126
+ });
127
+ }
128
+ /**
129
+ * Resolves the public {@link Qualifiers.IQualifierCollectorCreateParams | create params}
130
+ * into the concrete `(qualifierTypes, qualifiers)` pair the constructor expects.
131
+ *
132
+ * @remarks
133
+ * Validates the mixed-shape `qualifiers` input through
134
+ * {@link Converters.oneOf} (string vs {@link Qualifiers.IQualifierDecl})
135
+ * at the public-API boundary, then partitions into bare-string and decl
136
+ * buckets to drive type synthesis. If any decl is present and
137
+ * `qualifierTypes` is omitted, fails with an error that names the
138
+ * offending typeNames.
139
+ *
140
+ * @internal
141
+ */
142
+ static _resolveCreateParams(params) {
143
+ const raw = params.qualifiers;
144
+ if (raw === undefined || raw.length === 0) {
145
+ if (params.qualifierTypes === undefined) {
146
+ return (0, ts_utils_1.succeed)({ qualifierTypes: QualifierCollector._emptyQualifierTypes(), qualifiers: undefined });
147
+ }
148
+ return (0, ts_utils_1.succeed)({ qualifierTypes: params.qualifierTypes, qualifiers: undefined });
149
+ }
150
+ return _qualifierEntriesConverter.convert(raw).onSuccess((entries) => {
151
+ const stringNames = [];
152
+ const declTypeNames = [];
153
+ for (const entry of entries) {
154
+ if (typeof entry === 'string') {
155
+ stringNames.push(entry);
156
+ }
157
+ else {
158
+ declTypeNames.push(entry.typeName);
159
+ }
160
+ }
161
+ if (declTypeNames.length > 0 && params.qualifierTypes === undefined) {
162
+ const unique = Array.from(new Set(declTypeNames));
163
+ return (0, ts_utils_1.fail)(`qualifierTypes must be supplied when qualifiers include declarations; ` +
164
+ `missing types for: ${unique.map((n) => `'${n}'`).join(', ')}`);
165
+ }
166
+ return QualifierCollector._resolveQualifierTypes(params.qualifierTypes, stringNames).onSuccess((qualifierTypes) => {
167
+ const decls = QualifierCollector._normalizeQualifierDecls(entries);
168
+ return (0, ts_utils_1.succeed)({ qualifierTypes, qualifiers: decls });
169
+ });
170
+ });
171
+ }
172
+ /**
173
+ * Returns the provided {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier-type collector}
174
+ * (or synthesizes a new one) augmented with synthesized literal qualifier types for the supplied
175
+ * string names that are not already present.
176
+ *
177
+ * @internal
178
+ */
179
+ static _resolveQualifierTypes(provided, stringNames) {
180
+ if (stringNames.length === 0) {
181
+ // No bare names to synthesize. The all-decls case requires `provided` to be defined
182
+ // (else _resolveCreateParams would have failed before calling us); fall back to an
183
+ // empty type collector only as a defensive measure.
184
+ /* c8 ignore next 1 - defensive: unreachable when called from _resolveCreateParams */
185
+ return (0, ts_utils_1.succeed)(provided !== null && provided !== void 0 ? provided : QualifierCollector._emptyQualifierTypes());
186
+ }
187
+ return (0, ts_utils_1.mapResults)(stringNames.map((name) => qualifier_types_1.LiteralQualifierType.create({ name }))).onSuccess((literalTypes) => {
188
+ return qualifier_types_1.QualifierTypeCollector.create().onSuccess((collector) => {
189
+ const existingAdds = provided !== undefined
190
+ ? Array.from(provided.values()).map((existing) => collector.add(existing))
191
+ : [];
192
+ const literalAdds = literalTypes
193
+ .filter((lit) => !collector.has(lit.name))
194
+ .map((lit) => collector.add(lit));
195
+ return (0, ts_utils_1.mapResults)([...existingAdds, ...literalAdds]).onSuccess(() => (0, ts_utils_1.succeed)(collector));
196
+ });
197
+ });
198
+ }
199
+ /**
200
+ * Normalizes a mixed `(string | IQualifierDecl)[]` into a fully-resolved
201
+ * `IQualifierDecl[]`, assigning descending default priorities to synthesized
202
+ * decls within the `[MinConditionPriority..MaxConditionPriority]` range.
203
+ *
204
+ * @remarks
205
+ * Step size is adaptive to input length:
206
+ * `step = max(1, floor((Max - Min) / length))`. Each synthesized priority
207
+ * is `max(Min, Max - index * step)` — clamped at the bottom so length
208
+ * extremes (\>1000 axes) degrade gracefully into a tail of equal-`Min`
209
+ * priorities rather than overflowing the `ConditionPriority` range.
210
+ *
211
+ * @internal
212
+ */
213
+ static _normalizeQualifierDecls(qualifiers) {
214
+ const range = common_1.MaxConditionPriority - common_1.MinConditionPriority;
215
+ const step = Math.max(1, Math.floor(range / qualifiers.length));
216
+ return qualifiers.map((q, index) => {
217
+ if (typeof q === 'string') {
218
+ const raw = common_1.MaxConditionPriority - index * step;
219
+ return {
220
+ name: q,
221
+ typeName: q,
222
+ defaultPriority: Math.max(common_1.MinConditionPriority, raw)
223
+ };
224
+ }
225
+ return q;
226
+ });
227
+ }
228
+ /**
229
+ * Returns an empty {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier-type collector}
230
+ * used as a placeholder when no qualifiers are supplied and the caller omits
231
+ * `qualifierTypes`.
232
+ *
233
+ * @internal
234
+ */
235
+ static _emptyQualifierTypes() {
236
+ /* c8 ignore next 1 - QualifierTypeCollector.create() is total for the empty case */
237
+ return qualifier_types_1.QualifierTypeCollector.create().orThrow();
94
238
  }
95
239
  /**
96
240
  * {@inheritDoc Qualifiers.IReadOnlyQualifierCollector.getByNameOrToken}
@@ -1 +1 @@
1
- {"version":3,"file":"qualifierCollector.js","sourceRoot":"","sources":["../../../src/packlets/qualifiers/qualifierCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAoC;AACpC,4CASuB;AAGvB,2CAAwC;AACxC,uCAAgG;AA8ChG;;;;;GAKG;AACH,MAAa,kBACX,SAAQ,wCAAwD;IAQhE;;;;OAIG;IACH,YAAsB,MAAuC;;QAC3D,KAAK,CAAC;YACJ,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACrD,UAAU,EAAE,IAAI,sBAAW,CAAC,kBAAkB,CAAC;gBAC7C,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;gBACjC,KAAK,EAAE,uBAAa;aACrB,CAAC;SACH,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;QAC5C,kEAAkE;QAClE,MAAA,MAAM,CAAC,UAAU,0CAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAA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AAC,cAAc;YACnC,cAAc,EAAE,KAAK;SACtB,CAAC;QACF,OAAO,gCAAsB;aAC1B,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC;aAC7B,SAAS,CAAC,CAAC,SAAS,EAAE,EAAE;YACvB,kEAAkE;YAClE,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzC,OAAO,IAAA,eAAI,EACT,oBAAoB,SAAS,CAAC,KAAK,uCAAuC,CAC3E,CAAC;YACJ,CAAC;iBAAM,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/C,OAAO,IAAA,eAAI,EACT,mBAAmB,SAAS,CAAC,IAAI,wCAAwC,CAC1E,CAAC;YACJ,CAAC;YACD,OAAO,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC;aACD,SAAS,CAAC,qBAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF;AAzGD,gDAyGC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Common from '../common';\nimport {\n captureResult,\n Collections,\n failWithDetail,\n Result,\n fail,\n succeed,\n succeedWithDetail,\n ValidatingConvertingCollector\n} from '@fgv/ts-utils';\nimport { IQualifierDecl, IValidatedQualifierDecl } from './qualifierDecl';\nimport { QualifierName } from '../common';\nimport { Qualifier } from './qualifier';\nimport { IQualifierDeclConvertContext, qualifierDecl, validatedQualifierDecl } from './convert';\nimport { ReadOnlyQualifierTypeCollector } from '../qualifier-types';\n\n/**\n * Readonly version of {@link Qualifiers.QualifierCollector | QualifierCollector}.\n * @public\n */\nexport interface IReadOnlyQualifierCollector extends Collections.IReadOnlyValidatingCollector<Qualifier> {\n /**\n * {@inheritDoc Qualifiers.QualifierCollector.qualifierTypes}\n */\n readonly qualifierTypes: ReadOnlyQualifierTypeCollector;\n\n /**\n * Gets a {@link Qualifiers.Qualifier | qualifier} by name or token.\n * @param nameOrToken - The name or token of the qualifier to retrieve.\n * @returns `Success` with the qualifier if found, or `Failure` if not.\n */\n getByNameOrToken(nameOrToken: string): Result<Qualifier>;\n\n /**\n * Checks if a qualifier with a given name or token is in the collection.\n * @param nameOrToken - The name or token of the qualifier to check.\n * @returns `true` if the qualifier is in the collection, `false` if not.\n */\n hasNameOrToken(nameOrToken: string): boolean;\n}\n\n/**\n * Parameters for creating a new {@link Qualifiers.QualifierCollector}.\n * @public\n */\nexport interface IQualifierCollectorCreateParams {\n /**\n * The {@link QualifierTypes.QualifierTypeCollector | qualifier types} used to\n * create {@link Qualifiers.Qualifier | qualifiers} from {@link Qualifiers.IQualifierDecl | declarations}.\n */\n qualifierTypes: ReadOnlyQualifierTypeCollector;\n\n /**\n * Optional list of {@link Qualifiers.IQualifierDecl | declarations} for the qualifiers to add to the collection\n * upon creation.\n */\n qualifiers?: IQualifierDecl[];\n}\n\n/**\n * Collects {@link Qualifiers.Qualifier | Qualifiers} from {@link Qualifiers.IQualifierDecl | declarations},\n * with strongly-typed ({@link QualifierName | QualifierName} and {@link QualifierIndex | QualifierIndex}) key\n * and index.\n * @public\n */\nexport class QualifierCollector\n extends ValidatingConvertingCollector<Qualifier, IQualifierDecl>\n implements IReadOnlyQualifierCollector\n{\n /**\n * The {@link QualifierTypes.QualifierTypeCollector | qualifier types} that this collector uses.\n */\n public qualifierTypes: ReadOnlyQualifierTypeCollector;\n\n /**\n * Constructor for a {@link Qualifiers.QualifierCollector | QualifierCollector} object.\n * @param params - Parameters for creating the collector.\n * @public\n */\n protected constructor(params: IQualifierCollectorCreateParams) {\n super({\n factory: (k, i, v) => this._qualifierFactory(k, i, v),\n converters: new Collections.KeyValueConverters({\n key: Common.Convert.qualifierName,\n value: qualifierDecl\n })\n });\n this.qualifierTypes = params.qualifierTypes;\n /* c8 ignore next 1 - coverage misses the branch intermittently */\n params.qualifiers?.forEach((q) => this.validating.add(q.name, q).orThrow());\n }\n\n /**\n * Creates a new {@link Qualifiers.QualifierCollector | QualifierCollector} object.\n * @param params - {@link Qualifiers.IQualifierCollectorCreateParams | Parameters} for creating a new {@link Qualifiers.QualifierCollector | QualifierCollector}.\n * @returns `Success` with the new collector if successful, or `Failure` if not.\n */\n public static create(params: IQualifierCollectorCreateParams): Result<QualifierCollector> {\n return captureResult(() => new QualifierCollector(params));\n }\n\n /**\n * {@inheritDoc Qualifiers.IReadOnlyQualifierCollector.getByNameOrToken}\n */\n public getByNameOrToken(nameOrToken: string): Result<Qualifier> {\n return this.validating.get(nameOrToken).onFailure((message) => {\n for (const q of this.values()) {\n if (q.token === nameOrToken) {\n return succeedWithDetail(q, 'success');\n }\n }\n return failWithDetail(`Qualifier token '${nameOrToken}' not found`, 'not-found');\n });\n }\n\n /**\n * {@inheritDoc Qualifiers.IReadOnlyQualifierCollector.hasNameOrToken}\n */\n public hasNameOrToken(nameOrToken: string): boolean {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (this.validating.has(nameOrToken)) {\n return true;\n }\n for (const q of this.values()) {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (q.token === nameOrToken) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Gets a read-only view of this collector.\n * @returns A read-only view of this collector.\n */\n public toReadOnly(): IReadOnlyQualifierCollector {\n return this;\n }\n\n /**\n * Factory method for creating a {@link Qualifiers.Qualifier | Qualifier} from a {@link Qualifiers.IQualifierDecl | declaration}.\n * @param __key - The key for the qualifier.\n * @param index - The index of the qualifier.\n * @param decl - The {@link Qualifiers.IQualifierDecl | declaration} for the qualifier.\n * @returns `Success` with the new {@link Qualifiers.Qualifier | Qualifier} if successful, or `Failure` if not.\n * @public\n */\n protected _qualifierFactory(__key: QualifierName, index: number, decl: IQualifierDecl): Result<Qualifier> {\n const convertContext: IQualifierDeclConvertContext = {\n qualifierTypes: this.qualifierTypes,\n qualifierIndex: index\n };\n return validatedQualifierDecl\n .convert(decl, convertContext)\n .onSuccess((validated) => {\n /* c8 ignore next 9 - coverage intermittently misses this block */\n if (this.hasNameOrToken(validated.token)) {\n return fail<IValidatedQualifierDecl>(\n `Qualifier token '${validated.token}' is not unique or collides with name`\n );\n } else if (this.hasNameOrToken(validated.name)) {\n return fail<IValidatedQualifierDecl>(\n `Qualifier name '${validated.name}' is not unique or collides with token`\n );\n }\n return succeed(validated);\n })\n .onSuccess(Qualifier.create);\n }\n}\n"]}
1
+ {"version":3,"file":"qualifierCollector.js","sourceRoot":"","sources":["../../../src/packlets/qualifiers/qualifierCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAoC;AACpC,4CAYuB;AAEvB,sCAAsF;AACtF,2CAAwC;AACxC,uCAAgG;AAChG,wDAI4B;AAE5B;;;;;;;GAOG;AACH,MAAM,0BAA0B,GAAsD,qBAAU,CAAC,OAAO,CACtG,qBAAU,CAAC,KAAK,CAA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AC,IAAI,CAAC,EAAE,CAAC;gBAC/C,OAAO,IAAA,eAAI,EACT,mBAAmB,SAAS,CAAC,IAAI,wCAAwC,CAC1E,CAAC;YACJ,CAAC;YACD,OAAO,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC;aACD,SAAS,CAAC,qBAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;CACF;AA5QD,gDA4QC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Common from '../common';\nimport {\n captureResult,\n Collections,\n Converter,\n Converters,\n failWithDetail,\n mapResults,\n Result,\n fail,\n succeed,\n succeedWithDetail,\n ValidatingConvertingCollector\n} from '@fgv/ts-utils';\nimport { IQualifierDecl, IValidatedQualifierDecl } from './qualifierDecl';\nimport { MaxConditionPriority, MinConditionPriority, QualifierName } from '../common';\nimport { Qualifier } from './qualifier';\nimport { IQualifierDeclConvertContext, qualifierDecl, validatedQualifierDecl } from './convert';\nimport {\n LiteralQualifierType,\n QualifierTypeCollector,\n ReadOnlyQualifierTypeCollector\n} from '../qualifier-types';\n\n/**\n * Converter for a single entry in the mixed-shape\n * {@link Qualifiers.IQualifierCollectorCreateParams.qualifiers | qualifiers}\n * input — either a bare axis-name string or a full\n * {@link Qualifiers.IQualifierDecl | declaration}. Validates the entry\n * shape at the public-API boundary rather than deferring to the\n * internal qualifier factory.\n */\nconst _qualifierEntriesConverter: Converter<ReadonlyArray<string | IQualifierDecl>> = Converters.arrayOf(\n Converters.oneOf<string | IQualifierDecl>([Converters.string, qualifierDecl])\n);\n\n/**\n * Readonly version of {@link Qualifiers.QualifierCollector | QualifierCollector}.\n * @public\n */\nexport interface IReadOnlyQualifierCollector extends Collections.IReadOnlyValidatingCollector<Qualifier> {\n /**\n * {@inheritDoc Qualifiers.QualifierCollector.qualifierTypes}\n */\n readonly qualifierTypes: ReadOnlyQualifierTypeCollector;\n\n /**\n * Gets a {@link Qualifiers.Qualifier | qualifier} by name or token.\n * @param nameOrToken - The name or token of the qualifier to retrieve.\n * @returns `Success` with the qualifier if found, or `Failure` if not.\n */\n getByNameOrToken(nameOrToken: string): Result<Qualifier>;\n\n /**\n * Checks if a qualifier with a given name or token is in the collection.\n * @param nameOrToken - The name or token of the qualifier to check.\n * @returns `true` if the qualifier is in the collection, `false` if not.\n */\n hasNameOrToken(nameOrToken: string): boolean;\n}\n\n/**\n * Parameters for creating a new {@link Qualifiers.QualifierCollector}.\n * @public\n *\n * @remarks\n * `qualifiers` accepts a mixed array of bare axis-name strings and full\n * {@link Qualifiers.IQualifierDecl | declarations}. A string element is\n * sugar for \"literal qualifier with this name\"; the library synthesizes a\n * {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType} and a\n * declaration `{ name, typeName: name, defaultPriority: <descending> }`.\n *\n * Synthesized priorities are distributed across the\n * `[MinConditionPriority..MaxConditionPriority]` range adaptively to the\n * array length: `step = max(1, floor((Max - Min) / length))`,\n * `priority = max(Min, Max - index * step)`. Earlier elements get higher\n * priority. The formula never overflows the `ConditionPriority` range\n * regardless of input length; for inputs whose length exceeds the range\n * cardinality (\\>1000 axes), trailing priorities collapse at\n * `MinConditionPriority` — supply explicit priorities in that regime\n * if uniqueness matters.\n *\n * `qualifierTypes` may be omitted only when every element of `qualifiers`\n * is a string. If any element is an {@link Qualifiers.IQualifierDecl},\n * `qualifierTypes` must be supplied and must contain the referenced\n * {@link Qualifiers.IQualifierDecl.typeName | typeNames}.\n */\nexport interface IQualifierCollectorCreateParams {\n /**\n * The {@link QualifierTypes.QualifierTypeCollector | qualifier types} used to\n * create {@link Qualifiers.Qualifier | qualifiers} from {@link Qualifiers.IQualifierDecl | declarations}.\n *\n * Optional only when every entry in `qualifiers` is a bare axis-name string\n * (in which case the library synthesizes a literal qualifier type per name).\n */\n qualifierTypes?: ReadOnlyQualifierTypeCollector;\n\n /**\n * Optional list of {@link Qualifiers.IQualifierDecl | declarations} or bare\n * axis-name strings for the qualifiers to add to the collection on creation.\n *\n * @remarks\n * A string element `'foo'` is sugar for a literal qualifier:\n * `{ name: 'foo', typeName: 'foo', defaultPriority: <descending> }` backed by\n * a synthesized {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType}\n * named `'foo'`.\n */\n qualifiers?: ReadonlyArray<string | IQualifierDecl>;\n}\n\n/**\n * Collects {@link Qualifiers.Qualifier | Qualifiers} from {@link Qualifiers.IQualifierDecl | declarations},\n * with strongly-typed ({@link QualifierName | QualifierName} and {@link QualifierIndex | QualifierIndex}) key\n * and index.\n * @public\n */\nexport class QualifierCollector\n extends ValidatingConvertingCollector<Qualifier, IQualifierDecl>\n implements IReadOnlyQualifierCollector\n{\n /**\n * The {@link QualifierTypes.QualifierTypeCollector | qualifier types} that this collector uses.\n */\n public qualifierTypes: ReadOnlyQualifierTypeCollector;\n\n /**\n * Constructor for a {@link Qualifiers.QualifierCollector | QualifierCollector} object.\n * @param qualifierTypes - The {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier types}\n * used to validate declarations.\n * @param qualifiers - Optional list of fully-resolved {@link Qualifiers.IQualifierDecl | declarations}.\n * @public\n */\n protected constructor(\n qualifierTypes: ReadOnlyQualifierTypeCollector,\n qualifiers?: ReadonlyArray<IQualifierDecl>\n ) {\n super({\n factory: (k, i, v) => this._qualifierFactory(k, i, v),\n converters: new Collections.KeyValueConverters({\n key: Common.Convert.qualifierName,\n value: qualifierDecl\n })\n });\n this.qualifierTypes = qualifierTypes;\n /* c8 ignore next 1 - coverage misses the branch intermittently */\n qualifiers?.forEach((q) => this.validating.add(q.name, q).orThrow());\n }\n\n /**\n * Creates a new {@link Qualifiers.QualifierCollector | QualifierCollector} object.\n * @param params - {@link Qualifiers.IQualifierCollectorCreateParams | Parameters} for creating a new {@link Qualifiers.QualifierCollector | QualifierCollector}.\n * @returns `Success` with the new collector if successful, or `Failure` if not.\n *\n * @remarks\n * Accepts a mixed array of bare axis-name strings and full\n * {@link Qualifiers.IQualifierDecl | declarations}. String elements are sugar\n * for a literal qualifier: the library synthesizes a\n * {@link QualifierTypes.LiteralQualifierType | LiteralQualifierType} named\n * after the string and a declaration `{ name, typeName: name, defaultPriority }`.\n * Synthesized priorities are distributed across the\n * `[MinConditionPriority..MaxConditionPriority]` range adaptively to the\n * input length (`step = max(1, floor((Max - Min) / length))`,\n * `priority = max(Min, Max - index * step)`). Earlier elements get higher\n * priority — matching the \"earlier qualifier wins when multiple match\"\n * mental model — and the formula never overflows the `ConditionPriority`\n * range regardless of input length.\n *\n * `qualifierTypes` may be omitted only when every element of `qualifiers`\n * is a string. If any element is a declaration, `qualifierTypes` is\n * required (and must include the referenced typeNames); the error message\n * names the offending typeName when it is missing.\n */\n public static create(params: IQualifierCollectorCreateParams): Result<QualifierCollector> {\n return QualifierCollector._resolveCreateParams(params).onSuccess(({ qualifierTypes, qualifiers }) => {\n return captureResult(() => new QualifierCollector(qualifierTypes, qualifiers));\n });\n }\n\n /**\n * Resolves the public {@link Qualifiers.IQualifierCollectorCreateParams | create params}\n * into the concrete `(qualifierTypes, qualifiers)` pair the constructor expects.\n *\n * @remarks\n * Validates the mixed-shape `qualifiers` input through\n * {@link Converters.oneOf} (string vs {@link Qualifiers.IQualifierDecl})\n * at the public-API boundary, then partitions into bare-string and decl\n * buckets to drive type synthesis. If any decl is present and\n * `qualifierTypes` is omitted, fails with an error that names the\n * offending typeNames.\n *\n * @internal\n */\n private static _resolveCreateParams(params: IQualifierCollectorCreateParams): Result<{\n qualifierTypes: ReadOnlyQualifierTypeCollector;\n qualifiers?: ReadonlyArray<IQualifierDecl>;\n }> {\n const raw = params.qualifiers;\n if (raw === undefined || raw.length === 0) {\n if (params.qualifierTypes === undefined) {\n return succeed({ qualifierTypes: QualifierCollector._emptyQualifierTypes(), qualifiers: undefined });\n }\n return succeed({ qualifierTypes: params.qualifierTypes, qualifiers: undefined });\n }\n\n return _qualifierEntriesConverter.convert(raw).onSuccess((entries) => {\n const stringNames: string[] = [];\n const declTypeNames: string[] = [];\n for (const entry of entries) {\n if (typeof entry === 'string') {\n stringNames.push(entry);\n } else {\n declTypeNames.push(entry.typeName);\n }\n }\n\n if (declTypeNames.length > 0 && params.qualifierTypes === undefined) {\n const unique = Array.from(new Set(declTypeNames));\n return fail<{\n qualifierTypes: ReadOnlyQualifierTypeCollector;\n qualifiers?: ReadonlyArray<IQualifierDecl>;\n }>(\n `qualifierTypes must be supplied when qualifiers include declarations; ` +\n `missing types for: ${unique.map((n) => `'${n}'`).join(', ')}`\n );\n }\n\n return QualifierCollector._resolveQualifierTypes(params.qualifierTypes, stringNames).onSuccess(\n (qualifierTypes) => {\n const decls = QualifierCollector._normalizeQualifierDecls(entries);\n return succeed({ qualifierTypes, qualifiers: decls });\n }\n );\n });\n }\n\n /**\n * Returns the provided {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier-type collector}\n * (or synthesizes a new one) augmented with synthesized literal qualifier types for the supplied\n * string names that are not already present.\n *\n * @internal\n */\n private static _resolveQualifierTypes(\n provided: ReadOnlyQualifierTypeCollector | undefined,\n stringNames: ReadonlyArray<string>\n ): Result<ReadOnlyQualifierTypeCollector> {\n if (stringNames.length === 0) {\n // No bare names to synthesize. The all-decls case requires `provided` to be defined\n // (else _resolveCreateParams would have failed before calling us); fall back to an\n // empty type collector only as a defensive measure.\n /* c8 ignore next 1 - defensive: unreachable when called from _resolveCreateParams */\n return succeed(provided ?? QualifierCollector._emptyQualifierTypes());\n }\n return mapResults(stringNames.map((name) => LiteralQualifierType.create({ name }))).onSuccess(\n (literalTypes) => {\n return QualifierTypeCollector.create().onSuccess((collector) => {\n const existingAdds: ReadonlyArray<Result<unknown>> =\n provided !== undefined\n ? Array.from(provided.values()).map((existing) => collector.add(existing))\n : [];\n const literalAdds: ReadonlyArray<Result<unknown>> = literalTypes\n .filter((lit) => !collector.has(lit.name))\n .map((lit) => collector.add(lit));\n return mapResults([...existingAdds, ...literalAdds]).onSuccess(() =>\n succeed(collector as ReadOnlyQualifierTypeCollector)\n );\n });\n }\n );\n }\n\n /**\n * Normalizes a mixed `(string | IQualifierDecl)[]` into a fully-resolved\n * `IQualifierDecl[]`, assigning descending default priorities to synthesized\n * decls within the `[MinConditionPriority..MaxConditionPriority]` range.\n *\n * @remarks\n * Step size is adaptive to input length:\n * `step = max(1, floor((Max - Min) / length))`. Each synthesized priority\n * is `max(Min, Max - index * step)` — clamped at the bottom so length\n * extremes (\\>1000 axes) degrade gracefully into a tail of equal-`Min`\n * priorities rather than overflowing the `ConditionPriority` range.\n *\n * @internal\n */\n private static _normalizeQualifierDecls(\n qualifiers: ReadonlyArray<string | IQualifierDecl>\n ): ReadonlyArray<IQualifierDecl> {\n const range = MaxConditionPriority - MinConditionPriority;\n const step = Math.max(1, Math.floor(range / qualifiers.length));\n return qualifiers.map((q, index) => {\n if (typeof q === 'string') {\n const raw = MaxConditionPriority - index * step;\n return {\n name: q,\n typeName: q,\n defaultPriority: Math.max(MinConditionPriority, raw)\n };\n }\n return q;\n });\n }\n\n /**\n * Returns an empty {@link QualifierTypes.ReadOnlyQualifierTypeCollector | qualifier-type collector}\n * used as a placeholder when no qualifiers are supplied and the caller omits\n * `qualifierTypes`.\n *\n * @internal\n */\n private static _emptyQualifierTypes(): ReadOnlyQualifierTypeCollector {\n /* c8 ignore next 1 - QualifierTypeCollector.create() is total for the empty case */\n return QualifierTypeCollector.create().orThrow();\n }\n\n /**\n * {@inheritDoc Qualifiers.IReadOnlyQualifierCollector.getByNameOrToken}\n */\n public getByNameOrToken(nameOrToken: string): Result<Qualifier> {\n return this.validating.get(nameOrToken).onFailure((message) => {\n for (const q of this.values()) {\n if (q.token === nameOrToken) {\n return succeedWithDetail(q, 'success');\n }\n }\n return failWithDetail(`Qualifier token '${nameOrToken}' not found`, 'not-found');\n });\n }\n\n /**\n * {@inheritDoc Qualifiers.IReadOnlyQualifierCollector.hasNameOrToken}\n */\n public hasNameOrToken(nameOrToken: string): boolean {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (this.validating.has(nameOrToken)) {\n return true;\n }\n for (const q of this.values()) {\n /* c8 ignore next 3 - functional code path tested but coverage intermittently missed */\n if (q.token === nameOrToken) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Gets a read-only view of this collector.\n * @returns A read-only view of this collector.\n */\n public toReadOnly(): IReadOnlyQualifierCollector {\n return this;\n }\n\n /**\n * Factory method for creating a {@link Qualifiers.Qualifier | Qualifier} from a {@link Qualifiers.IQualifierDecl | declaration}.\n * @param __key - The key for the qualifier.\n * @param index - The index of the qualifier.\n * @param decl - The {@link Qualifiers.IQualifierDecl | declaration} for the qualifier.\n * @returns `Success` with the new {@link Qualifiers.Qualifier | Qualifier} if successful, or `Failure` if not.\n * @public\n */\n protected _qualifierFactory(__key: QualifierName, index: number, decl: IQualifierDecl): Result<Qualifier> {\n const convertContext: IQualifierDeclConvertContext = {\n qualifierTypes: this.qualifierTypes,\n qualifierIndex: index\n };\n return validatedQualifierDecl\n .convert(decl, convertContext)\n .onSuccess((validated) => {\n /* c8 ignore next 9 - coverage intermittently misses this block */\n if (this.hasNameOrToken(validated.token)) {\n return fail<IValidatedQualifierDecl>(\n `Qualifier token '${validated.token}' is not unique or collides with name`\n );\n } else if (this.hasNameOrToken(validated.name)) {\n return fail<IValidatedQualifierDecl>(\n `Qualifier name '${validated.name}' is not unique or collides with token`\n );\n }\n return succeed(validated);\n })\n .onSuccess(Qualifier.create);\n }\n}\n"]}
@@ -67,4 +67,89 @@ export declare const resourceCollectionDecl: Converter<Normalized.IResourceColle
67
67
  * @public
68
68
  */
69
69
  export declare const importerResourceCollectionDecl: Converter<Normalized.IImporterResourceCollectionDecl>;
70
+ /**
71
+ * Returns a `Converter` for a `Json.ILooseConditionDecl<TQualifierNames>`
72
+ * narrowed on a supplied `qualifierName` converter.
73
+ *
74
+ * @public
75
+ */
76
+ export declare function typedLooseConditionDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.ILooseConditionDecl<TQualifierNames>>;
77
+ /**
78
+ * Returns a `Converter` for a `Json.ConditionSetDecl<TQualifierNames>`
79
+ * (either array form or record form) narrowed on a supplied `qualifierName`
80
+ * converter.
81
+ *
82
+ * @public
83
+ */
84
+ export declare function typedConditionSetDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.ConditionSetDecl<TQualifierNames>>;
85
+ /**
86
+ * Returns a `Converter` for a `Json.ILooseResourceCandidateDecl<TQualifierNames>`
87
+ * narrowed on a supplied `qualifierName` converter.
88
+ *
89
+ * @public
90
+ */
91
+ export declare function typedLooseResourceCandidateDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.ILooseResourceCandidateDecl<TQualifierNames>>;
92
+ /**
93
+ * Returns a `Converter` for a `Json.IImporterResourceCandidateDecl<TQualifierNames>`
94
+ * narrowed on a supplied `qualifierName` converter.
95
+ *
96
+ * @public
97
+ */
98
+ export declare function typedImporterResourceCandidateDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.IImporterResourceCandidateDecl<TQualifierNames>>;
99
+ /**
100
+ * Returns a `Converter` for a `Json.IChildResourceCandidateDecl<TQualifierNames>`
101
+ * narrowed on a supplied `qualifierName` converter.
102
+ *
103
+ * @public
104
+ */
105
+ export declare function typedChildResourceCandidateDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.IChildResourceCandidateDecl<TQualifierNames>>;
106
+ /**
107
+ * Returns a `Converter` for a `Json.ILooseResourceDecl<TQualifierNames>`
108
+ * narrowed on a supplied `qualifierName` converter.
109
+ *
110
+ * @public
111
+ */
112
+ export declare function typedLooseResourceDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.ILooseResourceDecl<TQualifierNames>>;
113
+ /**
114
+ * Returns a `Converter` for a `Json.IChildResourceDecl<TQualifierNames>`
115
+ * narrowed on a supplied `qualifierName` converter.
116
+ *
117
+ * @public
118
+ */
119
+ export declare function typedChildResourceDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.IChildResourceDecl<TQualifierNames>>;
120
+ /**
121
+ * Returns a `Converter` for a `Json.IContainerContextDecl<TQualifierNames>`
122
+ * narrowed on a supplied `qualifierName` converter.
123
+ *
124
+ * @public
125
+ */
126
+ export declare function typedContainerContextDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.IContainerContextDecl<TQualifierNames>>;
127
+ /**
128
+ * Returns a `Converter` for a `Json.IResourceTreeChildNodeDecl<TQualifierNames>`
129
+ * narrowed on a supplied `qualifierName` converter.
130
+ *
131
+ * @public
132
+ */
133
+ export declare function typedResourceTreeChildNodeDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.IResourceTreeChildNodeDecl<TQualifierNames>>;
134
+ /**
135
+ * Returns a `Converter` for a `Json.IResourceTreeRootDecl<TQualifierNames>`
136
+ * narrowed on a supplied `qualifierName` converter.
137
+ *
138
+ * @public
139
+ */
140
+ export declare function typedResourceTreeRootDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.IResourceTreeRootDecl<TQualifierNames>>;
141
+ /**
142
+ * Returns a `Converter` for a `Json.IResourceCollectionDecl<TQualifierNames>`
143
+ * narrowed on a supplied `qualifierName` converter.
144
+ *
145
+ * @public
146
+ */
147
+ export declare function typedResourceCollectionDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.IResourceCollectionDecl<TQualifierNames>>;
148
+ /**
149
+ * Returns a `Converter` for a `Json.IImporterResourceCollectionDecl<TQualifierNames>`
150
+ * narrowed on a supplied `qualifierName` converter.
151
+ *
152
+ * @public
153
+ */
154
+ export declare function typedImporterResourceCollectionDecl<TQualifierNames extends string>(qualifierNameConverter: Converter<TQualifierNames>): Converter<Json.IImporterResourceCollectionDecl<TQualifierNames>>;
70
155
  //# sourceMappingURL=convert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-json/convert.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAwC,MAAM,eAAe,CAAC;AAGhF,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAO/D,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAM/D,CAAC;AA+BL;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,CAAC,UAAU,CAAC,gBAAgB,CACoC,CAAC;AAEzG;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,CAAC,UAAU,CAAC,2BAA2B,CAQrF,CAAC;AAEL;;;GAGG;AACH,eAAO,MAA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