@dorsk/tsumikit 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/query/schema.d.ts +12 -1
- package/dist/query/schema.js +8 -1
- package/package.json +1 -1
package/dist/query/schema.d.ts
CHANGED
|
@@ -32,13 +32,24 @@ export interface FieldDef {
|
|
|
32
32
|
/** Static options, or omit and supply `provider` for async lookups. */
|
|
33
33
|
options?: ValueOption[];
|
|
34
34
|
provider?: ValueProvider;
|
|
35
|
+
/**
|
|
36
|
+
* Restrict the operators offered for this field to exactly this set (in
|
|
37
|
+
* catalogue order). When omitted, all operators legal for the field's `type`
|
|
38
|
+
* are offered. Use this to mirror a backend registry's per-field whitelist so
|
|
39
|
+
* the dropdown — and the parser's legal-op check — match what the server
|
|
40
|
+
* actually accepts.
|
|
41
|
+
*/
|
|
42
|
+
operators?: OperatorId[];
|
|
35
43
|
/** Placeholder shown in the value step of the dropdown. */
|
|
36
44
|
valuePlaceholder?: string;
|
|
37
45
|
}
|
|
38
46
|
export interface Schema {
|
|
39
47
|
fields: FieldDef[];
|
|
40
48
|
}
|
|
41
|
-
/** Operators legal for a given field, in catalogue order.
|
|
49
|
+
/** Operators legal for a given field, in catalogue order. When the field
|
|
50
|
+
* declares an explicit `operators` whitelist that takes precedence over the
|
|
51
|
+
* type-derived set (the whitelist is authoritative); otherwise every operator
|
|
52
|
+
* legal for the field's `type` is returned. */
|
|
42
53
|
export declare function operatorsFor(field: FieldDef): Operator[];
|
|
43
54
|
/** The default operator picked when a user selects a field (YouTrack-like). */
|
|
44
55
|
export declare function defaultOperator(field: FieldDef): Operator;
|
package/dist/query/schema.js
CHANGED
|
@@ -19,8 +19,15 @@ export const OPERATORS = [
|
|
|
19
19
|
{ id: 'in', label: 'any of', code: 'in', types: ['enum', 'id'], arity: 'many' },
|
|
20
20
|
{ id: 'range', label: 'in range', code: '..', types: ['date', 'number'], arity: 'two' },
|
|
21
21
|
];
|
|
22
|
-
/** Operators legal for a given field, in catalogue order.
|
|
22
|
+
/** Operators legal for a given field, in catalogue order. When the field
|
|
23
|
+
* declares an explicit `operators` whitelist that takes precedence over the
|
|
24
|
+
* type-derived set (the whitelist is authoritative); otherwise every operator
|
|
25
|
+
* legal for the field's `type` is returned. */
|
|
23
26
|
export function operatorsFor(field) {
|
|
27
|
+
if (field.operators) {
|
|
28
|
+
const allow = new Set(field.operators);
|
|
29
|
+
return OPERATORS.filter((op) => allow.has(op.id));
|
|
30
|
+
}
|
|
24
31
|
return OPERATORS.filter((op) => op.types.includes(field.type));
|
|
25
32
|
}
|
|
26
33
|
/** The default operator picked when a user selects a field (YouTrack-like). */
|
package/package.json
CHANGED