@quenk/frontend 0.20.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.
Files changed (38) hide show
  1. package/README.md +19 -0
  2. package/lib/app/display.d.ts +140 -0
  3. package/lib/app/display.js +167 -0
  4. package/lib/app/display.js.map +1 -0
  5. package/lib/app/index.d.ts +26 -0
  6. package/lib/app/index.js +29 -0
  7. package/lib/app/index.js.map +1 -0
  8. package/lib/app/model/http.d.ts +147 -0
  9. package/lib/app/model/http.js +184 -0
  10. package/lib/app/model/http.js.map +1 -0
  11. package/lib/app/model/index.d.ts +36 -0
  12. package/lib/app/model/index.js +3 -0
  13. package/lib/app/model/index.js.map +1 -0
  14. package/lib/app/router/hash.d.ts +143 -0
  15. package/lib/app/router/hash.js +178 -0
  16. package/lib/app/router/hash.js.map +1 -0
  17. package/lib/app/router/index.d.ts +49 -0
  18. package/lib/app/router/index.js +3 -0
  19. package/lib/app/router/index.js.map +1 -0
  20. package/lib/app/scene/dialog/alert.d.ts +13 -0
  21. package/lib/app/scene/dialog/alert.js +18 -0
  22. package/lib/app/scene/dialog/alert.js.map +1 -0
  23. package/lib/app/scene/dialog/confirm.d.ts +39 -0
  24. package/lib/app/scene/dialog/confirm.js +36 -0
  25. package/lib/app/scene/dialog/confirm.js.map +1 -0
  26. package/lib/app/scene/dialog/index.d.ts +65 -0
  27. package/lib/app/scene/dialog/index.js +71 -0
  28. package/lib/app/scene/dialog/index.js.map +1 -0
  29. package/lib/app/scene/director.d.ts +90 -0
  30. package/lib/app/scene/director.js +111 -0
  31. package/lib/app/scene/director.js.map +1 -0
  32. package/lib/app/scene/index.d.ts +66 -0
  33. package/lib/app/scene/index.js +50 -0
  34. package/lib/app/scene/index.js.map +1 -0
  35. package/lib/app/search/filters.d.ts +258 -0
  36. package/lib/app/search/filters.js +372 -0
  37. package/lib/app/search/filters.js.map +1 -0
  38. package/package.json +35 -0
@@ -0,0 +1,258 @@
1
+ import * as types from '@quenk/search-filters/lib/compile/policy';
2
+ import { Value } from '@quenk/noni/lib/data/jsonx';
3
+ import { Record } from '@quenk/noni/lib/data/record';
4
+ import { Maybe } from '@quenk/noni/lib/data/maybe';
5
+ import { ValueType } from '@quenk/search-filters/lib/compile/policy';
6
+ import { Except, Source } from '@quenk/search-filters/lib/compile';
7
+ import { FieldName, Operator } from '@quenk/search-filters/lib/compile/term';
8
+ export { ValueType, types };
9
+ /**
10
+ * SearchFilterString is a @quenk/search-filters compatible string.
11
+ */
12
+ export type SearchFilterString = Source;
13
+ /**
14
+ * SearchFilter is a class that holds the parts of a @quenk/search-filters filter
15
+ * as an object.
16
+ *
17
+ * Similar to parsed nodes except these are used before parsing for the purpose
18
+ * of building up a list of filters that can be manipulated before the final
19
+ * query string is formed.
20
+ */
21
+ export declare abstract class SearchFilter {
22
+ name: FieldName;
23
+ operator: Operator;
24
+ value: Value;
25
+ /**
26
+ * type to treat the filter value before conversion.
27
+ */
28
+ abstract type: ValueType;
29
+ /**
30
+ * @param name - The name of the filter.
31
+ * @param operator - The operator to use for this filter.
32
+ * @param value - The value to use for the filter.
33
+ */
34
+ constructor(name: FieldName, operator: Operator, value: Value);
35
+ /**
36
+ * getFormattedValue can be overridden by child classes to specify the way
37
+ * the value part is turned into a string.
38
+ *
39
+ * If the value cannot be successfully converted an error should be
40
+ * returned.
41
+ */
42
+ getFormattedValue(): Except<string>;
43
+ /**
44
+ * getSearchFilterString converts the filter to a search-filters compatible
45
+ * string.
46
+ */
47
+ getSearchFilterString(): Except<SearchFilterString>;
48
+ }
49
+ /**
50
+ * NumberSearchFilter converts its value to a number.
51
+ */
52
+ export declare class NumberSearchFilter extends SearchFilter {
53
+ type: string;
54
+ getFormattedValue(): Except<string>;
55
+ }
56
+ /**
57
+ * BooleanSearchFilter converts its value to a boolean.
58
+ */
59
+ export declare class BooleanSearchFilter extends SearchFilter {
60
+ type: string;
61
+ getFormattedValue(): Except<string>;
62
+ }
63
+ /**
64
+ * StringSearchFilter converts its value to a string.
65
+ */
66
+ export declare class StringSearchFilter extends SearchFilter {
67
+ type: string;
68
+ getFormattedValue(): Except<string>;
69
+ }
70
+ /**
71
+ * DateSearchFilter converts its value to a ISO8601 date string.
72
+ */
73
+ export declare class DateSearchFilter extends SearchFilter {
74
+ type: string;
75
+ static pattern: RegExp;
76
+ getFormattedValue(): Except<string>;
77
+ }
78
+ /**
79
+ * NumberListSearchFilter converts the value into a list of numbers.
80
+ */
81
+ export declare class NumberListSearchFilter extends SearchFilter {
82
+ type: string;
83
+ getFormattedValue(): Except<string>;
84
+ }
85
+ /**
86
+ * StringListSearchFilter converts the value into a list of strings.
87
+ */
88
+ export declare class StringListSearchFilter extends SearchFilter {
89
+ type: string;
90
+ getFormattedValue(): Except<string>;
91
+ }
92
+ /**
93
+ * SearchFilterSet is an abstraction over a @quenk/search-filters string that
94
+ * allows for multiple strings to be chained together in a way that they can
95
+ * be manipulated before parsing.
96
+ *
97
+ * Filters are stored as SearchFilter objects identified by their key name and
98
+ * operator allowing multiple filters for the same key to exist (but must have
99
+ * different operators).
100
+ */
101
+ export declare class SearchFilterSet {
102
+ filters: SearchFilter[];
103
+ constructor(filters?: SearchFilter[]);
104
+ /**
105
+ * length provides the number of filters in the set.
106
+ */
107
+ get length(): number;
108
+ /**
109
+ * add a SearchFilter to the set.
110
+ *
111
+ * Any search filters already added to the chain matching this filter will
112
+ * first be removed.
113
+ */
114
+ add(filter: SearchFilter): SearchFilterSet;
115
+ /**
116
+ * addMany filters to the set at once.
117
+ */
118
+ addMany(list: SearchFilter[]): SearchFilterSet;
119
+ /**
120
+ * addNumber constructs and adds a NumberSearchFilter to the set.
121
+ */
122
+ addNumber(name: FieldName, op: Operator, value: Value): SearchFilterSet;
123
+ /**
124
+ * addBoolean constructs and adds a BooleanSearchFilter to the set.
125
+ */
126
+ addBoolean(name: FieldName, op: Operator, value: Value): SearchFilterSet;
127
+ /**
128
+ * addString constructs and adds a StringSearchFilter to the set.
129
+ */
130
+ addString(name: FieldName, op: Operator, value: Value): SearchFilterSet;
131
+ /**
132
+ * addDate constructs and adds a DateSearchFilter to the set.
133
+ */
134
+ addDate(name: FieldName, op: Operator, value: Value): SearchFilterSet;
135
+ /**
136
+ * addNumberList creates a NumberListSearchFilter and adds it to the set.
137
+ */
138
+ addNumberList(name: FieldName, op: Operator, value: Value): SearchFilterSet;
139
+ /**
140
+ * addStringList creates a StringListSearchFilter and adds it to the set.
141
+ */
142
+ addStringList(name: FieldName, op: Operator, value: Value): SearchFilterSet;
143
+ /**
144
+ * get a SearchFilter given its name and operator.
145
+ */
146
+ get(name: FieldName, op: Operator): Maybe<SearchFilter>;
147
+ /**
148
+ * remove a filter from the list given its name and operator.
149
+ */
150
+ remove(name: FieldName, op: Operator): SearchFilterSet;
151
+ /**
152
+ * removeAny filter that has the given name.
153
+ */
154
+ removeAny(name: FieldName): SearchFilterSet;
155
+ _to(): Except<SearchFilterString[]>;
156
+ /**
157
+ * toAnd combines the list of filters into a single "and" chain.
158
+ */
159
+ toAnd(): Except<SearchFilterString>;
160
+ /**
161
+ * toOr combines the list of filters into a single "or" chain.
162
+ */
163
+ toOr(): Except<SearchFilterString>;
164
+ /**
165
+ * clear removes all the search filters in the set.
166
+ */
167
+ clear(): SearchFilterSet;
168
+ }
169
+ /**
170
+ * SearchFilterSpecPtr is a string that can be resolved to a SearchFilterSpec
171
+ * against a SearchFilterSpecMap.
172
+ */
173
+ export type SearchFilterSpecPtr = string;
174
+ /**
175
+ * SearchFilterSpecMap where the keys are pointers to SearchFilterSpecs.
176
+ */
177
+ export type SearchFilterSpecMap = Record<SearchFilterSpec>;
178
+ /**
179
+ * SearchFilterSetBuilderOptions affect the behaviour of a
180
+ * SearchFilterSetBuilder.
181
+ */
182
+ export interface SearchFilterSetBuilderOptions {
183
+ /**
184
+ * filters is the SearchFilterSpecMap used to determine how to handle values
185
+ * added to the set.
186
+ */
187
+ filters: SearchFilterSpecMap;
188
+ /**
189
+ * dropEmpty if true, indicates that empty strings or array values should be
190
+ * treated as a call to remove the target filter. Defaults to false.
191
+ */
192
+ dropEmpty: boolean;
193
+ }
194
+ /**
195
+ * SearchFilterSpec describes the parameters for a single search filter.
196
+ */
197
+ export interface SearchFilterSpec {
198
+ /**
199
+ * key that will be used in the filter.
200
+ */
201
+ key: FieldName;
202
+ /**
203
+ * type of the filter value.
204
+ */
205
+ type: ValueType;
206
+ /**
207
+ * operator to use for the query.
208
+ */
209
+ operator: Operator;
210
+ }
211
+ /**
212
+ * SearchFilterSetBuilder is a wrapper around a SearchFilterSet to further ease
213
+ * the burden of create a malleable filter chain.
214
+ *
215
+ * This class is designed with the idea of having only one name per filter
216
+ * regardless of the operator. This allows filter form elements to have their
217
+ * values collected much like other wml form elements.
218
+ *
219
+ * Each expected filter form control should be given a unique name reflected in
220
+ * the provided "options.filters" map when its value changes, this map is
221
+ * consulted to determine the actual key and operator to apply. In this way,
222
+ * all event handler code has to do is call the set() method and the details
223
+ * of how and what filter to add to the chain is handled automatically.
224
+ */
225
+ export declare class SearchFilterSetBuilder {
226
+ specs: SearchFilterSpecMap;
227
+ dropEmpty: boolean;
228
+ filterSet: SearchFilterSet;
229
+ /**
230
+ * Use SearchFilterSetBuilder.create() instead.
231
+ * @private
232
+ */
233
+ constructor(specs: SearchFilterSpecMap, dropEmpty: boolean, filterSet: SearchFilterSet);
234
+ /**
235
+ * create a new instance.
236
+ *
237
+ * This is the preferred method to create an instance because it allows for
238
+ * partial specs to be specified.
239
+ */
240
+ static create(specs: Record<Partial<SearchFilterSpec>>, dropEmpty?: boolean, set?: SearchFilterSet): SearchFilterSetBuilder;
241
+ /**
242
+ * set the value for a search filter described in the constructor.
243
+ *
244
+ * If the value does not appear in the spec list it is ignored.
245
+ */
246
+ set(name: SearchFilterSpecPtr, value: Value): SearchFilterSetBuilder;
247
+ /**
248
+ * getValue attempts to provide the value of a SearchFilter within the set.
249
+ *
250
+ * Note that this will return null instead of Maybe for a missing value
251
+ * because it is intended to be used in wml files.
252
+ */
253
+ getValue(name: SearchFilterSpecPtr): Value;
254
+ /**
255
+ * remove a search filter based on its spec definition.
256
+ */
257
+ remove(name: SearchFilterSpecPtr): SearchFilterSetBuilder;
258
+ }
@@ -0,0 +1,372 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SearchFilterSetBuilder = exports.SearchFilterSet = exports.StringListSearchFilter = exports.NumberListSearchFilter = exports.DateSearchFilter = exports.StringSearchFilter = exports.BooleanSearchFilter = exports.NumberSearchFilter = exports.SearchFilter = exports.types = void 0;
4
+ const types = require("@quenk/search-filters/lib/compile/policy");
5
+ exports.types = types;
6
+ const record_1 = require("@quenk/noni/lib/data/record");
7
+ const maybe_1 = require("@quenk/noni/lib/data/maybe");
8
+ const type_1 = require("@quenk/noni/lib/data/type");
9
+ const either_1 = require("@quenk/noni/lib/data/either");
10
+ const match_1 = require("@quenk/noni/lib/control/match");
11
+ /**
12
+ * SearchFilter is a class that holds the parts of a @quenk/search-filters filter
13
+ * as an object.
14
+ *
15
+ * Similar to parsed nodes except these are used before parsing for the purpose
16
+ * of building up a list of filters that can be manipulated before the final
17
+ * query string is formed.
18
+ */
19
+ class SearchFilter {
20
+ /**
21
+ * @param name - The name of the filter.
22
+ * @param operator - The operator to use for this filter.
23
+ * @param value - The value to use for the filter.
24
+ */
25
+ constructor(name, operator, value) {
26
+ this.name = name;
27
+ this.operator = operator;
28
+ this.value = value;
29
+ }
30
+ /**
31
+ * getFormattedValue can be overridden by child classes to specify the way
32
+ * the value part is turned into a string.
33
+ *
34
+ * If the value cannot be successfully converted an error should be
35
+ * returned.
36
+ */
37
+ getFormattedValue() {
38
+ return (0, either_1.right)(String(this.value));
39
+ }
40
+ /**
41
+ * getSearchFilterString converts the filter to a search-filters compatible
42
+ * string.
43
+ */
44
+ getSearchFilterString() {
45
+ return this
46
+ .getFormattedValue()
47
+ .map(value => `${this.name}:${this.operator}${value}`);
48
+ }
49
+ }
50
+ exports.SearchFilter = SearchFilter;
51
+ /**
52
+ * NumberSearchFilter converts its value to a number.
53
+ */
54
+ class NumberSearchFilter extends SearchFilter {
55
+ constructor() {
56
+ super(...arguments);
57
+ this.type = types.TYPE_NUMBER;
58
+ }
59
+ getFormattedValue() {
60
+ let val = Number(this.value);
61
+ return isNaN(val) ?
62
+ (0, either_1.left)(new Error(`${this.name}: value "${val}" is not a number!`)) :
63
+ (0, either_1.right)(`${val}`);
64
+ }
65
+ }
66
+ exports.NumberSearchFilter = NumberSearchFilter;
67
+ /**
68
+ * BooleanSearchFilter converts its value to a boolean.
69
+ */
70
+ class BooleanSearchFilter extends SearchFilter {
71
+ constructor() {
72
+ super(...arguments);
73
+ this.type = types.TYPE_BOOLEAN;
74
+ }
75
+ getFormattedValue() {
76
+ return (0, either_1.right)(`${Boolean(this.value)}`);
77
+ }
78
+ }
79
+ exports.BooleanSearchFilter = BooleanSearchFilter;
80
+ /**
81
+ * StringSearchFilter converts its value to a string.
82
+ */
83
+ class StringSearchFilter extends SearchFilter {
84
+ constructor() {
85
+ super(...arguments);
86
+ this.type = types.TYPE_STRING;
87
+ }
88
+ getFormattedValue() {
89
+ return (0, either_1.right)(`"${String((this.value == null) ? '' : this.value)}"`);
90
+ }
91
+ }
92
+ exports.StringSearchFilter = StringSearchFilter;
93
+ /**
94
+ * DateSearchFilter converts its value to a ISO8601 date string.
95
+ */
96
+ class DateSearchFilter extends SearchFilter {
97
+ constructor() {
98
+ super(...arguments);
99
+ this.type = types.TYPE_DATE;
100
+ }
101
+ getFormattedValue() {
102
+ if (!DateSearchFilter.pattern.test(String(this.value)))
103
+ return (0, either_1.left)(new Error(`${this.name}: value "${this.value}"` +
104
+ ` is not a valid date!`));
105
+ return (0, either_1.right)(`${String((this.value == null) ? '' : this.value)}`);
106
+ }
107
+ }
108
+ exports.DateSearchFilter = DateSearchFilter;
109
+ DateSearchFilter.pattern = /^\d{4}-\d{2}-\d{2}$/;
110
+ /**
111
+ * NumberListSearchFilter converts the value into a list of numbers.
112
+ */
113
+ class NumberListSearchFilter extends SearchFilter {
114
+ constructor() {
115
+ super(...arguments);
116
+ this.type = types.TYPE_LIST_NUMBER;
117
+ }
118
+ getFormattedValue() {
119
+ let { name, value } = this;
120
+ let val;
121
+ if ((0, type_1.isString)(value))
122
+ val = value.split(',').map(Number);
123
+ else if (Array.isArray(value))
124
+ val = value.map(Number);
125
+ else
126
+ val = [NaN];
127
+ let isValid = val.every(el => !isNaN(el));
128
+ if (!isValid)
129
+ return (0, either_1.left)(new Error(`${name}: "${value}" ` +
130
+ `is not a valid number list!`));
131
+ return (0, either_1.right)(`[${val.join(',')}]`);
132
+ }
133
+ }
134
+ exports.NumberListSearchFilter = NumberListSearchFilter;
135
+ /**
136
+ * StringListSearchFilter converts the value into a list of strings.
137
+ */
138
+ class StringListSearchFilter extends SearchFilter {
139
+ constructor() {
140
+ super(...arguments);
141
+ this.type = types.TYPE_LIST_STRING;
142
+ }
143
+ getFormattedValue() {
144
+ let { value } = this;
145
+ let val = [];
146
+ if (Array.isArray(value))
147
+ val = value;
148
+ else if ((0, type_1.isString)(value))
149
+ val = value.split(',');
150
+ else if (value != null)
151
+ val = [String(val)];
152
+ val = val.map(el => (el == null) ? '""' : `"${el}"`);
153
+ return (0, either_1.right)(`[${val.join(',')}]`);
154
+ }
155
+ }
156
+ exports.StringListSearchFilter = StringListSearchFilter;
157
+ /**
158
+ * SearchFilterSet is an abstraction over a @quenk/search-filters string that
159
+ * allows for multiple strings to be chained together in a way that they can
160
+ * be manipulated before parsing.
161
+ *
162
+ * Filters are stored as SearchFilter objects identified by their key name and
163
+ * operator allowing multiple filters for the same key to exist (but must have
164
+ * different operators).
165
+ */
166
+ class SearchFilterSet {
167
+ constructor(filters = []) {
168
+ this.filters = filters;
169
+ }
170
+ /**
171
+ * length provides the number of filters in the set.
172
+ */
173
+ get length() {
174
+ return this.filters.length;
175
+ }
176
+ /**
177
+ * add a SearchFilter to the set.
178
+ *
179
+ * Any search filters already added to the chain matching this filter will
180
+ * first be removed.
181
+ */
182
+ add(filter) {
183
+ this.filters = this.filters
184
+ .filter(n => !((n.operator == filter.operator) &&
185
+ (n.name == filter.name)))
186
+ .concat(filter);
187
+ return this;
188
+ }
189
+ /**
190
+ * addMany filters to the set at once.
191
+ */
192
+ addMany(list) {
193
+ list.forEach(filter => this.add(filter));
194
+ return this;
195
+ }
196
+ /**
197
+ * addNumber constructs and adds a NumberSearchFilter to the set.
198
+ */
199
+ addNumber(name, op, value) {
200
+ return this.add(new NumberSearchFilter(name, op, value));
201
+ }
202
+ /**
203
+ * addBoolean constructs and adds a BooleanSearchFilter to the set.
204
+ */
205
+ addBoolean(name, op, value) {
206
+ return this.add(new BooleanSearchFilter(name, op, value));
207
+ }
208
+ /**
209
+ * addString constructs and adds a StringSearchFilter to the set.
210
+ */
211
+ addString(name, op, value) {
212
+ return this.add(new StringSearchFilter(name, op, value));
213
+ }
214
+ /**
215
+ * addDate constructs and adds a DateSearchFilter to the set.
216
+ */
217
+ addDate(name, op, value) {
218
+ return this.add(new DateSearchFilter(name, op, value));
219
+ }
220
+ /**
221
+ * addNumberList creates a NumberListSearchFilter and adds it to the set.
222
+ */
223
+ addNumberList(name, op, value) {
224
+ return this.add(new NumberListSearchFilter(name, op, value));
225
+ }
226
+ /**
227
+ * addStringList creates a StringListSearchFilter and adds it to the set.
228
+ */
229
+ addStringList(name, op, value) {
230
+ return this.add(new StringListSearchFilter(name, op, value));
231
+ }
232
+ /**
233
+ * get a SearchFilter given its name and operator.
234
+ */
235
+ get(name, op) {
236
+ return this.filters.reduce((prev, curr) => ((curr.name === name) && (curr.operator === op)) ?
237
+ (0, maybe_1.just)(curr) :
238
+ prev, (0, maybe_1.nothing)());
239
+ }
240
+ /**
241
+ * remove a filter from the list given its name and operator.
242
+ */
243
+ remove(name, op) {
244
+ this.filters = this.filters.filter(target => !((target.name === name) && (target.operator === op)));
245
+ return this;
246
+ }
247
+ /**
248
+ * removeAny filter that has the given name.
249
+ */
250
+ removeAny(name) {
251
+ this.filters = this.filters.filter(target => !(target.name === name));
252
+ return this;
253
+ }
254
+ _to() {
255
+ let result = [];
256
+ for (let filter of this.filters) {
257
+ let e = filter.getSearchFilterString();
258
+ if (e.isLeft())
259
+ return e;
260
+ result.push(`(${e.takeRight()})`);
261
+ }
262
+ return (0, either_1.right)(result);
263
+ }
264
+ /**
265
+ * toAnd combines the list of filters into a single "and" chain.
266
+ */
267
+ toAnd() {
268
+ return this._to().map(list => list.join(','));
269
+ }
270
+ /**
271
+ * toOr combines the list of filters into a single "or" chain.
272
+ */
273
+ toOr() {
274
+ return this._to().map(list => list.join('|'));
275
+ }
276
+ /**
277
+ * clear removes all the search filters in the set.
278
+ */
279
+ clear() {
280
+ this.filters = [];
281
+ return this;
282
+ }
283
+ }
284
+ exports.SearchFilterSet = SearchFilterSet;
285
+ const defaultSpec = { type: types.TYPE_STRING, operator: '=' };
286
+ /**
287
+ * SearchFilterSetBuilder is a wrapper around a SearchFilterSet to further ease
288
+ * the burden of create a malleable filter chain.
289
+ *
290
+ * This class is designed with the idea of having only one name per filter
291
+ * regardless of the operator. This allows filter form elements to have their
292
+ * values collected much like other wml form elements.
293
+ *
294
+ * Each expected filter form control should be given a unique name reflected in
295
+ * the provided "options.filters" map when its value changes, this map is
296
+ * consulted to determine the actual key and operator to apply. In this way,
297
+ * all event handler code has to do is call the set() method and the details
298
+ * of how and what filter to add to the chain is handled automatically.
299
+ */
300
+ class SearchFilterSetBuilder {
301
+ /**
302
+ * Use SearchFilterSetBuilder.create() instead.
303
+ * @private
304
+ */
305
+ constructor(specs, dropEmpty, filterSet) {
306
+ this.specs = specs;
307
+ this.dropEmpty = dropEmpty;
308
+ this.filterSet = filterSet;
309
+ }
310
+ /**
311
+ * create a new instance.
312
+ *
313
+ * This is the preferred method to create an instance because it allows for
314
+ * partial specs to be specified.
315
+ */
316
+ static create(specs, dropEmpty = false, set = new SearchFilterSet()) {
317
+ return new SearchFilterSetBuilder((0, record_1.map)(specs, (spec, key) => (0, record_1.merge3)(defaultSpec, { key }, spec)), dropEmpty, set);
318
+ }
319
+ /**
320
+ * set the value for a search filter described in the constructor.
321
+ *
322
+ * If the value does not appear in the spec list it is ignored.
323
+ */
324
+ set(name, value) {
325
+ let { filterSet, dropEmpty } = this;
326
+ let spec = this.specs[name];
327
+ if (spec) {
328
+ let { key, type, operator } = spec;
329
+ if (dropEmpty && ((Array.isArray(value) && (0, record_1.empty)(value))
330
+ || (value == '')
331
+ || (value == null)))
332
+ return this.remove(spec.key);
333
+ (0, match_1.match)(type)
334
+ .caseOf(types.TYPE_NUMBER, () => filterSet.addNumber(key, operator, value))
335
+ .caseOf(types.TYPE_BOOLEAN, () => filterSet.addBoolean(key, operator, value))
336
+ .caseOf(types.TYPE_STRING, () => filterSet.addString(key, operator, value))
337
+ .caseOf(types.TYPE_DATE, () => filterSet.addDate(key, operator, value))
338
+ .caseOf(types.TYPE_LIST_NUMBER, () => filterSet.addNumberList(key, operator, value))
339
+ .caseOf(types.TYPE_LIST_STRING, () => filterSet.addStringList(key, operator, value))
340
+ .end();
341
+ }
342
+ return this;
343
+ }
344
+ /**
345
+ * getValue attempts to provide the value of a SearchFilter within the set.
346
+ *
347
+ * Note that this will return null instead of Maybe for a missing value
348
+ * because it is intended to be used in wml files.
349
+ */
350
+ getValue(name) {
351
+ let spec = this.specs[name];
352
+ if (!spec)
353
+ return null;
354
+ return this
355
+ .filterSet
356
+ .get(spec.key, spec.operator)
357
+ .map(f => f.value)
358
+ .orJust(() => null)
359
+ .get();
360
+ }
361
+ /**
362
+ * remove a search filter based on its spec definition.
363
+ */
364
+ remove(name) {
365
+ let spec = this.specs[name];
366
+ if (spec)
367
+ this.filterSet.remove(spec.key, spec.operator);
368
+ return this;
369
+ }
370
+ }
371
+ exports.SearchFilterSetBuilder = SearchFilterSetBuilder;
372
+ //# sourceMappingURL=filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../src/app/search/filters.ts"],"names":[],"mappings":";;;AAAA,kEAAkE;AAa9C,sB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IAEf,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAyB;QAE5B,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE5B,IAAI,IAAI;YACJ,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC;IAEhB,CAAC;CAEJ;AA3GD,wDA2GC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@quenk/frontend",
3
+ "version": "0.20.1",
4
+ "description": "Actor oriented client side toolkit for Quenk Technologies.",
5
+ "author": [
6
+ "Quenk Technologies Limited <info@quenk.com> (https://quenk.com)"
7
+ ],
8
+ "main": "lib/app/index.js",
9
+ "files": [
10
+ "lib"
11
+ ],
12
+ "type": "lib/app/index.d.ts",
13
+ "license": "Apache-2.0",
14
+ "devDependencies": {
15
+ "@quenk/test": "^2.4.0",
16
+ "@quenk/wml": "^2.13.2",
17
+ "@types/mocha": "^10.0.0",
18
+ "@types/node": "^18.11.7",
19
+ "@types/qs": "^6.9.7",
20
+ "browserify": "^17.0.0",
21
+ "prettier": "^3.5.3",
22
+ "typescript": "^5.8.3"
23
+ },
24
+ "dependencies": {
25
+ "@quenk/jhr": "^2.6.26",
26
+ "@quenk/noni": "^1.46.1",
27
+ "@quenk/potoo": "^4.1.5",
28
+ "@quenk/preconditions": "^5.5.0",
29
+ "@quenk/search-filters": "^2.8.0",
30
+ "@quenk/wml-widgets": "^1.29.4",
31
+ "@types/json-stringify-safe": "^5.0.0",
32
+ "path-to-regexp": "^6.2.1",
33
+ "qs": "^6.11.1"
34
+ }
35
+ }