@flesh-and-blood/search 5.0.13 → 5.0.15

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.
@@ -0,0 +1,747 @@
1
+ import { Bond, Card, Class, Flow, Foiling, Fusion, Hero, Keyword, Meta, Printing, Rarity, Release, Shorthand, Subtype, Talent, Trait, Treatment, Type } from "@flesh-and-blood/types";
2
+ /**
3
+ * Which filter a key names, rather than how it was spelled: every alias of a
4
+ * filter answers with the one category, and a key naming no filter answers
5
+ * with nothing. The advanced search dialog offers a subset of these under the
6
+ * same strings, so a category is also what an app and the engine agree a query
7
+ * token means.
8
+ */
9
+ export declare const FilterCategory: {
10
+ readonly Arcane: "arcane";
11
+ readonly Artist: "artist";
12
+ readonly Banned: "banned";
13
+ readonly Bond: "bond";
14
+ readonly Chain: "chain";
15
+ readonly Class: "class";
16
+ readonly Cost: "cost";
17
+ readonly Defense: "defense";
18
+ readonly Flow: "flow";
19
+ readonly Foiling: "foiling";
20
+ readonly Fusion: "fusion";
21
+ readonly Intellect: "intellect";
22
+ readonly Is: "is";
23
+ readonly Keyword: "keyword";
24
+ readonly Legal: "legal";
25
+ readonly Life: "life";
26
+ readonly Name: "name";
27
+ readonly Pitch: "pitch";
28
+ readonly Power: "power";
29
+ readonly Print: "print";
30
+ readonly Rarity: "rarity";
31
+ readonly ReferencedBy: "referencedby";
32
+ readonly References: "references";
33
+ readonly Set: "set";
34
+ readonly Shorthand: "shorthand";
35
+ readonly Specialization: "specialization";
36
+ readonly Subtype: "subtype";
37
+ readonly Talent: "talent";
38
+ readonly Text: "text";
39
+ readonly Trait: "trait";
40
+ readonly Treatment: "treatment";
41
+ readonly Type: "type";
42
+ readonly TypeText: "typetext";
43
+ readonly Year: "year";
44
+ };
45
+ export type FilterCategory = (typeof FilterCategory)[keyof typeof FilterCategory];
46
+ /** How a filter reads the value written against it in a query. */
47
+ export declare const FilterKind: {
48
+ /** A number, which the query may put a comparison in front of. */
49
+ readonly Comparator: "comparator";
50
+ /** A whole value, so a fragment of one names nothing. */
51
+ readonly ExactMatch: "exactMatch";
52
+ /** A fragment, which stands for anything it sits inside. */
53
+ readonly PartialMatch: "partialMatch";
54
+ };
55
+ export type FilterKind = (typeof FilterKind)[keyof typeof FilterKind];
56
+ export type Modifier = ">=" | ">" | "<=" | "<";
57
+ export declare const availableModifiers: Modifier[];
58
+ export type Exclusion = "!" | "-";
59
+ export declare const availableExclusions: Exclusion[];
60
+ /** The card field a mapping reads. */
61
+ export type CardPropertyName = keyof Card;
62
+ /**
63
+ * The property of a mapping that reads no card field: a meta filter expands
64
+ * into other filters before any card is read, and a relation filter matches
65
+ * the identifiers the parser resolved.
66
+ */
67
+ export declare const NO_CARD_PROPERTY = "n/a";
68
+ /**
69
+ * The field holding the value a card prints where a number would be, which a
70
+ * numeric filter falls back to for a card carrying no number.
71
+ */
72
+ export type CardSpecialPropertyName = "specialArcane" | "specialCost" | "specialDefense" | "specialLife" | "specialPower";
73
+ /**
74
+ * How a card property is read and compared. The parser builds some of these
75
+ * for itself, expanding a meta filter or matching the cards a relation filter
76
+ * resolved, and those name no filter key, so they carry no grammar.
77
+ */
78
+ export interface CardPropertyMapping {
79
+ nestedProperty?: keyof Printing;
80
+ property: CardPropertyName | typeof NO_CARD_PROPERTY;
81
+ exclusion?: Exclusion;
82
+ isArray?: boolean;
83
+ isNestedPropertyArray?: boolean;
84
+ isNumber?: boolean;
85
+ isString?: boolean;
86
+ isBoolean?: boolean;
87
+ isDate?: boolean;
88
+ /**
89
+ * The card stores this property with markdown emphasis around its keywords,
90
+ * so the matcher strips that from both sides. A searched phrase then reads
91
+ * the text the way the card renders it rather than the way it is stored,
92
+ * and a phrase spanning a keyword boundary still matches.
93
+ */
94
+ hasMarkup?: boolean;
95
+ isMeta?: boolean;
96
+ /**
97
+ * The card stores this property the way a filter value is written, so the
98
+ * matcher compares it as stored instead of stripping punctuation and case
99
+ * from it first.
100
+ */
101
+ isNormalized?: boolean;
102
+ modifier?: Modifier;
103
+ partialMatch?: boolean;
104
+ specialProperty?: CardSpecialPropertyName;
105
+ }
106
+ /**
107
+ * A mapping a filter key names, and what the grammar says about it: which
108
+ * filter it is, the spelling it is named by, how its values are read, and the
109
+ * values a card can carry.
110
+ */
111
+ export interface FilterToPropertyMapping extends CardPropertyMapping {
112
+ category: FilterCategory;
113
+ /**
114
+ * The one spelling that names this filter where a query is composed rather
115
+ * than parsed: a hint, the syntax help, and the text the advanced search
116
+ * dialog writes. Every alias parses, so the choice decides only what gets
117
+ * written, and a reader's saved query carries it. A filter the dialog offers
118
+ * keeps the spelling that dialog already emits; any other filter takes the
119
+ * shortest spelling the syntax help teaches, and its own word where the help
120
+ * teaches none.
121
+ */
122
+ canonicalAlias: string;
123
+ kind: FilterKind;
124
+ /**
125
+ * The values a card carries for this filter, as the enum they come from:
126
+ * what a dialog offers as options and what a hint draws a suggestion from.
127
+ * It is not the set of spellings the parser accepts, which is wider, since
128
+ * the foiling, treatment, rarity, legality and meta resolvers each take
129
+ * abbreviations of their own. A filter reading free text (`artist`, `name`,
130
+ * `text`, `typetext`), a card name (`chain`, `references`, `referencedby`),
131
+ * a set identifier (`print`), a date (`year`) or a number carries none.
132
+ */
133
+ vocabulary?: readonly string[];
134
+ }
135
+ /** Every spelling a query can write, against the filter it names. */
136
+ export declare const filtersToCardPropertyMappings: {
137
+ arcane: {
138
+ category: "arcane";
139
+ canonicalAlias: string;
140
+ kind: "comparator";
141
+ property: "arcane";
142
+ specialProperty: "specialArcane";
143
+ isNumber: true;
144
+ partialMatch: true;
145
+ };
146
+ a: {
147
+ category: "artist";
148
+ canonicalAlias: string;
149
+ kind: "partialMatch";
150
+ property: "artists";
151
+ isArray: true;
152
+ partialMatch: true;
153
+ };
154
+ artist: {
155
+ category: "artist";
156
+ canonicalAlias: string;
157
+ kind: "partialMatch";
158
+ property: "artists";
159
+ isArray: true;
160
+ partialMatch: true;
161
+ };
162
+ art: {
163
+ category: "artist";
164
+ canonicalAlias: string;
165
+ kind: "partialMatch";
166
+ property: "artists";
167
+ isArray: true;
168
+ partialMatch: true;
169
+ };
170
+ attack: {
171
+ category: "power";
172
+ canonicalAlias: string;
173
+ kind: "comparator";
174
+ property: "power";
175
+ specialProperty: "specialPower";
176
+ isNumber: true;
177
+ };
178
+ b: {
179
+ category: "defense";
180
+ canonicalAlias: string;
181
+ kind: "comparator";
182
+ property: "defense";
183
+ specialProperty: "specialDefense";
184
+ isNumber: true;
185
+ };
186
+ block: {
187
+ category: "defense";
188
+ canonicalAlias: string;
189
+ kind: "comparator";
190
+ property: "defense";
191
+ specialProperty: "specialDefense";
192
+ isNumber: true;
193
+ };
194
+ banned: {
195
+ category: "banned";
196
+ canonicalAlias: string;
197
+ kind: "exactMatch";
198
+ vocabulary: readonly string[];
199
+ property: "n/a";
200
+ isMeta: true;
201
+ };
202
+ bond: {
203
+ category: "bond";
204
+ canonicalAlias: string;
205
+ kind: "exactMatch";
206
+ vocabulary: Bond.Earth[];
207
+ property: "bonds";
208
+ isArray: true;
209
+ };
210
+ bonds: {
211
+ category: "bond";
212
+ canonicalAlias: string;
213
+ kind: "exactMatch";
214
+ vocabulary: Bond.Earth[];
215
+ property: "bonds";
216
+ isArray: true;
217
+ };
218
+ c: {
219
+ category: "class";
220
+ canonicalAlias: string;
221
+ kind: "partialMatch";
222
+ vocabulary: Class[];
223
+ property: "classes";
224
+ isArray: true;
225
+ partialMatch: true;
226
+ };
227
+ class: {
228
+ category: "class";
229
+ canonicalAlias: string;
230
+ kind: "partialMatch";
231
+ vocabulary: Class[];
232
+ property: "classes";
233
+ isArray: true;
234
+ partialMatch: true;
235
+ };
236
+ chain: {
237
+ category: "chain";
238
+ canonicalAlias: string;
239
+ kind: "partialMatch";
240
+ property: "n/a";
241
+ };
242
+ co: {
243
+ category: "cost";
244
+ canonicalAlias: string;
245
+ kind: "comparator";
246
+ property: "cost";
247
+ specialProperty: "specialCost";
248
+ isNumber: true;
249
+ partialMatch: true;
250
+ };
251
+ cost: {
252
+ category: "cost";
253
+ canonicalAlias: string;
254
+ kind: "comparator";
255
+ property: "cost";
256
+ specialProperty: "specialCost";
257
+ isNumber: true;
258
+ partialMatch: true;
259
+ };
260
+ color: {
261
+ category: "pitch";
262
+ canonicalAlias: string;
263
+ kind: "comparator";
264
+ property: "pitch";
265
+ isNumber: true;
266
+ };
267
+ d: {
268
+ category: "defense";
269
+ canonicalAlias: string;
270
+ kind: "comparator";
271
+ property: "defense";
272
+ specialProperty: "specialDefense";
273
+ isNumber: true;
274
+ };
275
+ def: {
276
+ category: "defense";
277
+ canonicalAlias: string;
278
+ kind: "comparator";
279
+ property: "defense";
280
+ specialProperty: "specialDefense";
281
+ isNumber: true;
282
+ };
283
+ defense: {
284
+ category: "defense";
285
+ canonicalAlias: string;
286
+ kind: "comparator";
287
+ property: "defense";
288
+ specialProperty: "specialDefense";
289
+ isNumber: true;
290
+ };
291
+ flow: {
292
+ category: "flow";
293
+ canonicalAlias: string;
294
+ kind: "exactMatch";
295
+ vocabulary: Flow.Lightning[];
296
+ property: "flows";
297
+ isArray: true;
298
+ };
299
+ flows: {
300
+ category: "flow";
301
+ canonicalAlias: string;
302
+ kind: "exactMatch";
303
+ vocabulary: Flow.Lightning[];
304
+ property: "flows";
305
+ isArray: true;
306
+ };
307
+ f: {
308
+ category: "fusion";
309
+ canonicalAlias: string;
310
+ kind: "exactMatch";
311
+ vocabulary: Fusion[];
312
+ property: "fusions";
313
+ isArray: true;
314
+ };
315
+ fusion: {
316
+ category: "fusion";
317
+ canonicalAlias: string;
318
+ kind: "exactMatch";
319
+ vocabulary: Fusion[];
320
+ property: "fusions";
321
+ isArray: true;
322
+ };
323
+ foil: {
324
+ category: "foiling";
325
+ canonicalAlias: string;
326
+ kind: "exactMatch";
327
+ vocabulary: Foiling[];
328
+ nestedProperty: "foiling";
329
+ property: "printings";
330
+ isArray: true;
331
+ };
332
+ foiling: {
333
+ category: "foiling";
334
+ canonicalAlias: string;
335
+ kind: "exactMatch";
336
+ vocabulary: Foiling[];
337
+ nestedProperty: "foiling";
338
+ property: "printings";
339
+ isArray: true;
340
+ };
341
+ i: {
342
+ category: "intellect";
343
+ canonicalAlias: string;
344
+ kind: "comparator";
345
+ property: "intellect";
346
+ isNumber: true;
347
+ };
348
+ intellect: {
349
+ category: "intellect";
350
+ canonicalAlias: string;
351
+ kind: "comparator";
352
+ property: "intellect";
353
+ isNumber: true;
354
+ };
355
+ is: {
356
+ category: "is";
357
+ canonicalAlias: string;
358
+ kind: "exactMatch";
359
+ vocabulary: Meta[];
360
+ property: "meta";
361
+ isArray: true;
362
+ };
363
+ k: {
364
+ category: "keyword";
365
+ canonicalAlias: string;
366
+ kind: "exactMatch";
367
+ vocabulary: Keyword[];
368
+ property: "keywords";
369
+ isArray: true;
370
+ };
371
+ keyword: {
372
+ category: "keyword";
373
+ canonicalAlias: string;
374
+ kind: "exactMatch";
375
+ vocabulary: Keyword[];
376
+ property: "keywords";
377
+ isArray: true;
378
+ };
379
+ l: {
380
+ category: "legal";
381
+ canonicalAlias: string;
382
+ kind: "exactMatch";
383
+ vocabulary: readonly string[];
384
+ property: "n/a";
385
+ isMeta: true;
386
+ };
387
+ legal: {
388
+ category: "legal";
389
+ canonicalAlias: string;
390
+ kind: "exactMatch";
391
+ vocabulary: readonly string[];
392
+ property: "n/a";
393
+ isMeta: true;
394
+ };
395
+ hero: {
396
+ category: "legal";
397
+ canonicalAlias: string;
398
+ kind: "exactMatch";
399
+ vocabulary: readonly string[];
400
+ property: "n/a";
401
+ isMeta: true;
402
+ };
403
+ li: {
404
+ category: "life";
405
+ canonicalAlias: string;
406
+ kind: "comparator";
407
+ property: "life";
408
+ specialProperty: "specialLife";
409
+ isNumber: true;
410
+ };
411
+ life: {
412
+ category: "life";
413
+ canonicalAlias: string;
414
+ kind: "comparator";
415
+ property: "life";
416
+ specialProperty: "specialLife";
417
+ isNumber: true;
418
+ };
419
+ meta: {
420
+ category: "is";
421
+ canonicalAlias: string;
422
+ kind: "exactMatch";
423
+ vocabulary: Meta[];
424
+ property: "meta";
425
+ isArray: true;
426
+ };
427
+ n: {
428
+ category: "name";
429
+ canonicalAlias: string;
430
+ kind: "partialMatch";
431
+ property: "name";
432
+ isString: true;
433
+ partialMatch: true;
434
+ };
435
+ name: {
436
+ category: "name";
437
+ canonicalAlias: string;
438
+ kind: "partialMatch";
439
+ property: "name";
440
+ isString: true;
441
+ partialMatch: true;
442
+ };
443
+ p: {
444
+ category: "pitch";
445
+ canonicalAlias: string;
446
+ kind: "comparator";
447
+ property: "pitch";
448
+ isNumber: true;
449
+ };
450
+ pitch: {
451
+ category: "pitch";
452
+ canonicalAlias: string;
453
+ kind: "comparator";
454
+ property: "pitch";
455
+ isNumber: true;
456
+ };
457
+ pwr: {
458
+ category: "power";
459
+ canonicalAlias: string;
460
+ kind: "comparator";
461
+ property: "power";
462
+ specialProperty: "specialPower";
463
+ isNumber: true;
464
+ };
465
+ pow: {
466
+ category: "power";
467
+ canonicalAlias: string;
468
+ kind: "comparator";
469
+ property: "power";
470
+ specialProperty: "specialPower";
471
+ isNumber: true;
472
+ };
473
+ power: {
474
+ category: "power";
475
+ canonicalAlias: string;
476
+ kind: "comparator";
477
+ property: "power";
478
+ specialProperty: "specialPower";
479
+ isNumber: true;
480
+ };
481
+ print: {
482
+ category: "print";
483
+ canonicalAlias: string;
484
+ kind: "partialMatch";
485
+ property: "setIdentifiers";
486
+ isArray: true;
487
+ partialMatch: true;
488
+ };
489
+ r: {
490
+ category: "rarity";
491
+ canonicalAlias: string;
492
+ kind: "exactMatch";
493
+ vocabulary: Rarity[];
494
+ property: "n/a";
495
+ isMeta: true;
496
+ };
497
+ rarity: {
498
+ category: "rarity";
499
+ canonicalAlias: string;
500
+ kind: "exactMatch";
501
+ vocabulary: Rarity[];
502
+ property: "n/a";
503
+ isMeta: true;
504
+ };
505
+ referencedby: {
506
+ category: "referencedby";
507
+ canonicalAlias: string;
508
+ kind: "partialMatch";
509
+ property: "n/a";
510
+ };
511
+ references: {
512
+ category: "references";
513
+ canonicalAlias: string;
514
+ kind: "partialMatch";
515
+ property: "n/a";
516
+ };
517
+ rf: {
518
+ category: "banned";
519
+ canonicalAlias: string;
520
+ kind: "exactMatch";
521
+ vocabulary: readonly string[];
522
+ property: "n/a";
523
+ isMeta: true;
524
+ };
525
+ s: {
526
+ category: "set";
527
+ canonicalAlias: string;
528
+ kind: "partialMatch";
529
+ vocabulary: Release[];
530
+ property: "sets";
531
+ isArray: true;
532
+ partialMatch: true;
533
+ };
534
+ set: {
535
+ category: "set";
536
+ canonicalAlias: string;
537
+ kind: "partialMatch";
538
+ vocabulary: Release[];
539
+ property: "sets";
540
+ isArray: true;
541
+ partialMatch: true;
542
+ };
543
+ short: {
544
+ category: "shorthand";
545
+ canonicalAlias: string;
546
+ kind: "partialMatch";
547
+ vocabulary: Shorthand[];
548
+ property: "shorthands";
549
+ isArray: true;
550
+ partialMatch: true;
551
+ };
552
+ shorthand: {
553
+ category: "shorthand";
554
+ canonicalAlias: string;
555
+ kind: "partialMatch";
556
+ vocabulary: Shorthand[];
557
+ property: "shorthands";
558
+ isArray: true;
559
+ partialMatch: true;
560
+ };
561
+ shorthands: {
562
+ category: "shorthand";
563
+ canonicalAlias: string;
564
+ kind: "partialMatch";
565
+ vocabulary: Shorthand[];
566
+ property: "shorthands";
567
+ isArray: true;
568
+ partialMatch: true;
569
+ };
570
+ sp: {
571
+ category: "specialization";
572
+ canonicalAlias: string;
573
+ kind: "partialMatch";
574
+ vocabulary: Hero[];
575
+ property: "specializations";
576
+ isArray: true;
577
+ partialMatch: true;
578
+ };
579
+ spec: {
580
+ category: "specialization";
581
+ canonicalAlias: string;
582
+ kind: "partialMatch";
583
+ vocabulary: Hero[];
584
+ property: "specializations";
585
+ isArray: true;
586
+ partialMatch: true;
587
+ };
588
+ specialization: {
589
+ category: "specialization";
590
+ canonicalAlias: string;
591
+ kind: "partialMatch";
592
+ vocabulary: Hero[];
593
+ property: "specializations";
594
+ isArray: true;
595
+ partialMatch: true;
596
+ };
597
+ specializations: {
598
+ category: "specialization";
599
+ canonicalAlias: string;
600
+ kind: "partialMatch";
601
+ vocabulary: Hero[];
602
+ property: "specializations";
603
+ isArray: true;
604
+ partialMatch: true;
605
+ };
606
+ st: {
607
+ category: "subtype";
608
+ canonicalAlias: string;
609
+ kind: "exactMatch";
610
+ vocabulary: Subtype[];
611
+ property: "subtypes";
612
+ isArray: true;
613
+ };
614
+ subtype: {
615
+ category: "subtype";
616
+ canonicalAlias: string;
617
+ kind: "exactMatch";
618
+ vocabulary: Subtype[];
619
+ property: "subtypes";
620
+ isArray: true;
621
+ };
622
+ t: {
623
+ category: "type";
624
+ canonicalAlias: string;
625
+ kind: "exactMatch";
626
+ vocabulary: Type[];
627
+ property: "types";
628
+ isArray: true;
629
+ };
630
+ type: {
631
+ category: "type";
632
+ canonicalAlias: string;
633
+ kind: "exactMatch";
634
+ vocabulary: Type[];
635
+ property: "types";
636
+ isArray: true;
637
+ };
638
+ tal: {
639
+ category: "talent";
640
+ canonicalAlias: string;
641
+ kind: "exactMatch";
642
+ vocabulary: Talent[];
643
+ property: "talents";
644
+ isArray: true;
645
+ };
646
+ talent: {
647
+ category: "talent";
648
+ canonicalAlias: string;
649
+ kind: "exactMatch";
650
+ vocabulary: Talent[];
651
+ property: "talents";
652
+ isArray: true;
653
+ };
654
+ text: {
655
+ category: "text";
656
+ canonicalAlias: string;
657
+ kind: "partialMatch";
658
+ property: "functionalText";
659
+ hasMarkup: true;
660
+ isString: true;
661
+ partialMatch: true;
662
+ };
663
+ trait: {
664
+ category: "trait";
665
+ canonicalAlias: string;
666
+ kind: "partialMatch";
667
+ vocabulary: Trait.AgentOfChaos[];
668
+ property: "traits";
669
+ isArray: true;
670
+ partialMatch: true;
671
+ };
672
+ treat: {
673
+ category: "treatment";
674
+ canonicalAlias: string;
675
+ kind: "exactMatch";
676
+ vocabulary: Treatment[];
677
+ nestedProperty: "treatments";
678
+ property: "printings";
679
+ isArray: true;
680
+ isNestedPropertyArray: true;
681
+ };
682
+ treatment: {
683
+ category: "treatment";
684
+ canonicalAlias: string;
685
+ kind: "exactMatch";
686
+ vocabulary: Treatment[];
687
+ nestedProperty: "treatments";
688
+ property: "printings";
689
+ isArray: true;
690
+ isNestedPropertyArray: true;
691
+ };
692
+ var: {
693
+ category: "treatment";
694
+ canonicalAlias: string;
695
+ kind: "exactMatch";
696
+ vocabulary: Treatment[];
697
+ nestedProperty: "treatments";
698
+ property: "printings";
699
+ isArray: true;
700
+ isNestedPropertyArray: true;
701
+ };
702
+ variation: {
703
+ category: "treatment";
704
+ canonicalAlias: string;
705
+ kind: "exactMatch";
706
+ vocabulary: Treatment[];
707
+ nestedProperty: "treatments";
708
+ property: "printings";
709
+ isArray: true;
710
+ isNestedPropertyArray: true;
711
+ };
712
+ x: {
713
+ category: "typetext";
714
+ canonicalAlias: string;
715
+ kind: "partialMatch";
716
+ property: "typeText";
717
+ isString: true;
718
+ partialMatch: true;
719
+ };
720
+ typetext: {
721
+ category: "typetext";
722
+ canonicalAlias: string;
723
+ kind: "partialMatch";
724
+ property: "typeText";
725
+ isString: true;
726
+ partialMatch: true;
727
+ };
728
+ year: {
729
+ category: "year";
730
+ canonicalAlias: string;
731
+ kind: "partialMatch";
732
+ property: "firstReleaseDate";
733
+ isString: true;
734
+ partialMatch: true;
735
+ };
736
+ };
737
+ /**
738
+ * The same mappings, read by a key a query wrote. Filter keys are typed by the
739
+ * searcher, so an unrecognised key is a miss to skip rather than a type error.
740
+ */
741
+ export declare const filtersToCardPropertyMappingsByKey: {
742
+ [key: string]: FilterToPropertyMapping | undefined;
743
+ };
744
+ /** Case-folded, so a key answers however it was capitalised. */
745
+ export declare const getFilterCategory: (key: string) => FilterCategory | undefined;
746
+ /** Every spelling a query can name each filter by. */
747
+ export declare const aliasesByFilterCategory: Record<FilterCategory, readonly string[]>;