@finbheara/archive-client 0.23.0 → 0.25.0

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/cli.js CHANGED
@@ -21,152 +21,437 @@ import {
21
21
  latestCheck2,
22
22
  within,
23
23
  staleWarning2
24
- } from "./chunks/index-vsk6837c.js";
24
+ } from "./chunks/index-2ms980hc.js";
25
25
  import"./chunks/index-hghdy980.js";
26
26
 
27
- var USAGE = `usage: idq <verb> [--cache <dir>] [--repo <owner/name>] [--json] [--live]
28
-
29
- config repo <owner/name> set the user-local repository the releases come from
30
- config keep <N> how many of the newest releases a prune keeps (default 2)
31
- list [--remote] the cached releases (size, files, indexes, the pin), and
32
- with --remote the published tags
33
- fetch [--release <spec>] [--assets results,majors,<file>...]
34
- download, verify and cache a release (default: results)
35
- update [--assets ...] [--keep N] [--no-prune]
36
- move to the newest published release: fetch it (verified),
37
- build its indexes, pin it, then prune the cache to the N
38
- newest releases (default: config keep, else 2), keeping the
39
- new pin and the one before it
40
- use <spec> [--assets ...] [--keep N] [--no-prune]
41
- the same for the release a spec names
42
- pin <spec> the user-local pin: what a bare open (spec "pinned") opens
43
- unpin remove the pin (a bare open is then "latest")
44
- current the pin, and whether it is cached
45
- add <dir> --tag <tag> add a release built locally (its MANIFEST.json and files)
46
- to the cache under its tag
47
- index [--release <spec>] [<name>...] [--force]
48
- build the per-tag indexes (default: every one)
49
- verify [--release <spec>] re-hash every cached file against its receipt
50
- capabilities [--release <spec>] what the release carries of what the client reads, from
51
- its own schema: each feature full or missing (its calls
52
- refuse, naming the first cut that publishes it)
53
- prune [--keep N] [--dry-run] remove all but the N newest cached releases (default:
54
- config keep, else 2) and the pinned one
55
- rm <tag> [--dry-run] remove one cached release (not the pinned one)
56
- drop-indexes [<tag>] [--dry-run] remove the index files (of one release, or of every one)
57
- feis [--release <spec>] [--platform <p>] [--code <c>] [--id <id>] [--name <glob>] [--year <y>]
58
- the feises a query names
59
- series [--release <spec>] <name|host code|feis id>
60
- the series a name, a host code (fweb:ABC) or any feis id
61
- names: its years, hosts, codes and next instance
62
- school [--release <spec>] <print|school_id> [--region <code>]
63
- a school print or id to the published schools
64
- dancer [--release <spec>] <name> | --surname <s> | --like <glob> | --id <dancer_id>
65
- [--order surname-first|given-first] [--school <print|id>]
66
- [--yob <y> | --band <U10> [--year <y>] | --comp <competition>] [--as-of <date>]
67
- [--population girls|boys] [--oireachtas <region>[:<year>]] [--rows]
68
- the dancers a name reaches, each with its evidence
69
- (name level, age, school, population, region) and the arm;
70
- --oireachtas is the regional the roster is for, its region in
71
- the release's spelling (SRO, MAO), its year the --as-of year
72
- where none is given; the results of
73
- the one dancer where one answers (or --rows for each)
74
- results [--release <spec>] [--dancer <id>] [--feis <id>] [--comp <competition>]
75
- [--school <print|id>] [--year <y>] [--limit <n>]
76
- the published result rows, prints and ids
77
- majors [--release <spec>] [--event <e>] [--year <y>] [--comp <competition>] [--dancer <id>]
78
- the majors: every event and its years; an event's
79
- competitions; a competition's, an event's or a dancer's rows
80
- stream [--release <spec>] --scope majors|transcribed|platform|all [--entries] [--event <e,...>]
81
- [--year <y> | --year <from>..<to>] [--tier <t,...>] [--category <c,...>]
82
- [--level <feis_level,...>] [--dancer <id,...>] [--school <school_id>] [--primary]
83
- every row a scope holds, one JSON line each, never the
84
- whole table in memory; --entries one per address (the row
85
- it stands for, with its recall order)
86
- records [--release <spec>] [--dancer <id,...>]
87
- every dancer's record: display, appearances, birth window,
88
- populations
89
- records --years [--release <spec>] [--dancer <id,...>] [--year <y>]
90
- each dancer's region, nationals and place per year
91
- feis-dates [--release <spec>] every feis's first and last day
92
- tabulated [--release <spec>] [--min-round <n>]
93
- the majors addresses the marks sheets tabulate to round n
94
- or later (default 3)
95
- teams [--release <spec>] [--event <e>] [--year <y>] [--rosters | --joins]
96
- the team result rows of an event-year; with --rosters its
97
- roster teams and their dancers; with --joins how each roster
98
- team meets the results
99
- events [--release <spec>] [--event <e>] [--year <y>]
100
- each event-year's dates and place
101
- teacher [--release <spec>] <name|TD number>
102
- the staff lists' people: where they taught, the register,
103
- where they sat
104
- adjudicator [--release <spec>] <name|TD number>
105
- the register's and the panels' people: the same answer
106
- comp [--release <spec>] <feis> <code> [--year <y>] [--title <t>]
107
- a feis's own comp code to the comp it names, through that
108
- feis's syllabus (the prior year's only where the platform
109
- numbers every feis alike; elsewhere the title)
110
- syllabus [--release <spec>] <feis> [year]
111
- one feis-year's comps, in printed order
112
- syllabus [--release <spec>] --for <series> [year]
113
- a series' syllabus for a year: that year's where held,
114
- else the newest, saying which and what it is read from
115
- resolve comp [<feis> <code>] [--year <y>] [--title <t>]
116
- resolve dancer [<name>] [--school <s>] [--comp <feis>/<code> | --yob <y> | --band <b> --year <y>]
117
- [--order <o>] [--as-of <date>] [--population girls|boys]
118
- [--oireachtas <region>[:<year>]]
119
- resolve registrations
120
- JSONL out, one answer per line; with no positional the
121
- questions are JSONL on stdin, one per line (a comp:
122
- {feis, code, year?, title?}, a dancer: {name, school?, age?,
123
- population?, oireachtas?}, a registration: {name, school?,
124
- codes[], feis, year?, population?, oireachtas?})
125
-
126
- A query on the default spec prints one warning line on stderr when its release is older than
127
- the newest published one (the remote asked at most once per hour, <cache>/LATEST.json); the
128
- answer and the exit code are unchanged, and an offline check says nothing.
129
-
130
- Where the caller names local builds (a wrapper's option), a query with no --release answers
131
- from the newest COMPLETE build newer than the pinned release, and says so in one line on
132
- stderr; --release <spec> names a release, and --live forces the pinned one.
27
+ var USAGE_HEADER = "usage: idq <verb> [--cache <dir>] [--repo <owner/name>] [--json] [--live]";
28
+ var GLOBAL_FLAGS = {
29
+ value: ["--cache", "--repo"],
30
+ bool: ["--json", "--live"]
31
+ };
32
+ var VERBS = [
33
+ {
34
+ verb: "config",
35
+ value: [],
36
+ bool: [],
37
+ usage: [
38
+ " config repo <owner/name> set the user-local repository the releases come from",
39
+ " config keep <N> how many of the newest releases a prune keeps (default 2)"
40
+ ]
41
+ },
42
+ {
43
+ verb: "list",
44
+ value: [],
45
+ bool: ["--remote"],
46
+ usage: [
47
+ " list [--remote] the cached releases (size, files, indexes, the pin), and",
48
+ " with --remote the published tags"
49
+ ]
50
+ },
51
+ {
52
+ verb: "fetch",
53
+ value: ["--release", "--assets"],
54
+ bool: [],
55
+ usage: [
56
+ " fetch [--release <spec>] [--assets results,majors,<file>...]",
57
+ " download, verify and cache a release (default: results)"
58
+ ]
59
+ },
60
+ {
61
+ verb: "update",
62
+ value: ["--assets", "--keep"],
63
+ bool: ["--no-prune"],
64
+ usage: [
65
+ " update [--assets ...] [--keep N] [--no-prune]",
66
+ " move to the newest published release: fetch it (verified),",
67
+ " build its indexes, pin it, then prune the cache to the N",
68
+ " newest releases (default: config keep, else 2), keeping the",
69
+ " new pin and the one before it"
70
+ ]
71
+ },
72
+ {
73
+ verb: "use",
74
+ value: ["--assets", "--keep"],
75
+ bool: ["--no-prune"],
76
+ usage: [
77
+ " use <spec> [--assets ...] [--keep N] [--no-prune]",
78
+ " the same for the release a spec names"
79
+ ]
80
+ },
81
+ {
82
+ verb: "pin",
83
+ value: [],
84
+ bool: [],
85
+ usage: [
86
+ ' pin <spec> the user-local pin: what a bare open (spec "pinned") opens'
87
+ ]
88
+ },
89
+ {
90
+ verb: "unpin",
91
+ value: [],
92
+ bool: [],
93
+ usage: [' unpin remove the pin (a bare open is then "latest")']
94
+ },
95
+ {
96
+ verb: "current",
97
+ value: [],
98
+ bool: [],
99
+ usage: [" current the pin, and whether it is cached"]
100
+ },
101
+ {
102
+ verb: "add",
103
+ value: ["--tag"],
104
+ bool: [],
105
+ usage: [
106
+ " add <dir> --tag <tag> add a release built locally (its MANIFEST.json and files)",
107
+ " to the cache under its tag"
108
+ ]
109
+ },
110
+ {
111
+ verb: "index",
112
+ value: ["--release"],
113
+ bool: ["--force"],
114
+ usage: [
115
+ " index [--release <spec>] [<name>...] [--force]",
116
+ " build the per-tag indexes (default: every one)"
117
+ ]
118
+ },
119
+ {
120
+ verb: "verify",
121
+ value: ["--release"],
122
+ bool: [],
123
+ usage: [" verify [--release <spec>] re-hash every cached file against its receipt"]
124
+ },
125
+ {
126
+ verb: "capabilities",
127
+ value: ["--release"],
128
+ bool: [],
129
+ usage: [
130
+ " capabilities [--release <spec>] what the release carries of what the client reads, from",
131
+ " its own schema: each feature full or missing (its calls",
132
+ " refuse, naming the first cut that publishes it)"
133
+ ]
134
+ },
135
+ {
136
+ verb: "prune",
137
+ value: ["--keep"],
138
+ bool: ["--dry-run"],
139
+ usage: [
140
+ " prune [--keep N] [--dry-run] remove all but the N newest cached releases (default:",
141
+ " config keep, else 2) and the pinned one"
142
+ ]
143
+ },
144
+ {
145
+ verb: "rm",
146
+ value: [],
147
+ bool: ["--dry-run"],
148
+ usage: [" rm <tag> [--dry-run] remove one cached release (not the pinned one)"]
149
+ },
150
+ {
151
+ verb: "drop-indexes",
152
+ value: [],
153
+ bool: ["--dry-run"],
154
+ usage: [
155
+ " drop-indexes [<tag>] [--dry-run] remove the index files (of one release, or of every one)"
156
+ ]
157
+ },
158
+ {
159
+ verb: "feis",
160
+ value: ["--release", "--platform", "--code", "--id", "--name", "--year"],
161
+ bool: [],
162
+ usage: [
163
+ " feis [--release <spec>] [--platform <p>] [--code <c>] [--id <id>] [--name <glob>] [--year <y>]",
164
+ " the feises a query names"
165
+ ]
166
+ },
167
+ {
168
+ verb: "series",
169
+ value: ["--release"],
170
+ bool: [],
171
+ usage: [
172
+ " series [--release <spec>] <name|host code|feis id>",
173
+ " the series a name, a host code (fweb:ABC) or any feis id",
174
+ " names: its years, hosts, codes and next instance"
175
+ ]
176
+ },
177
+ {
178
+ verb: "school",
179
+ value: ["--release", "--region"],
180
+ bool: [],
181
+ usage: [
182
+ " school [--release <spec>] <print|school_id> [--region <code>]",
183
+ " a school print or id to the published schools"
184
+ ]
185
+ },
186
+ {
187
+ verb: "dancer",
188
+ value: [
189
+ "--release",
190
+ "--surname",
191
+ "--like",
192
+ "--id",
193
+ "--order",
194
+ "--school",
195
+ "--yob",
196
+ "--band",
197
+ "--year",
198
+ "--comp",
199
+ "--as-of",
200
+ "--population",
201
+ "--oireachtas"
202
+ ],
203
+ bool: ["--rows"],
204
+ usage: [
205
+ " dancer [--release <spec>] <name> | --surname <s> | --like <glob> | --id <dancer_id>",
206
+ " [--order surname-first|given-first] [--school <print|id>]",
207
+ " [--yob <y> | --band <U10> [--year <y>] | --comp <competition>] [--as-of <date>]",
208
+ " [--population girls|boys] [--oireachtas <region>[:<year>]] [--rows]",
209
+ " the dancers a name reaches, each with its evidence",
210
+ " (name level, age, school, population, region) and the arm;",
211
+ " --oireachtas is the regional the roster is for, its region in",
212
+ " the release's spelling (SRO, MAO), its year the --as-of year",
213
+ " where none is given; the results of",
214
+ " the one dancer where one answers (or --rows for each)"
215
+ ]
216
+ },
217
+ {
218
+ verb: "results",
219
+ value: ["--release", "--dancer", "--feis", "--comp", "--school", "--year", "--limit"],
220
+ bool: [],
221
+ usage: [
222
+ " results [--release <spec>] [--dancer <id>] [--feis <id>] [--comp <competition>]",
223
+ " [--school <print|id>] [--year <y>] [--limit <n>]",
224
+ " the published result rows, prints and ids"
225
+ ]
226
+ },
227
+ {
228
+ verb: "majors",
229
+ value: ["--release", "--event", "--year", "--comp", "--dancer"],
230
+ bool: [],
231
+ usage: [
232
+ " majors [--release <spec>] [--event <e>] [--year <y>] [--comp <competition>] [--dancer <id>]",
233
+ " the majors: every event and its years; an event's",
234
+ " competitions; a competition's, an event's or a dancer's rows"
235
+ ]
236
+ },
237
+ {
238
+ verb: "stream",
239
+ value: [
240
+ "--release",
241
+ "--scope",
242
+ "--event",
243
+ "--year",
244
+ "--tier",
245
+ "--category",
246
+ "--level",
247
+ "--dancer",
248
+ "--school"
249
+ ],
250
+ bool: ["--entries", "--primary"],
251
+ usage: [
252
+ " stream [--release <spec>] --scope majors|transcribed|platform|all [--entries] [--event <e,...>]",
253
+ " [--year <y> | --year <from>..<to>] [--tier <t,...>] [--category <c,...>]",
254
+ " [--level <feis_level,...>] [--dancer <id,...>] [--school <school_id>] [--primary]",
255
+ " every row a scope holds, one JSON line each, never the",
256
+ " whole table in memory; --entries one per address (the row",
257
+ " it stands for, with its recall order)"
258
+ ]
259
+ },
260
+ {
261
+ verb: "records",
262
+ value: ["--release", "--dancer", "--year"],
263
+ bool: ["--years"],
264
+ usage: [
265
+ " records [--release <spec>] [--dancer <id,...>]",
266
+ " every dancer's record: display, appearances, birth window,",
267
+ " populations",
268
+ " records --years [--release <spec>] [--dancer <id,...>] [--year <y>]",
269
+ " each dancer's region, nationals and place per year"
270
+ ]
271
+ },
272
+ {
273
+ verb: "feis-dates",
274
+ value: ["--release"],
275
+ bool: [],
276
+ usage: [" feis-dates [--release <spec>] every feis's first and last day"]
277
+ },
278
+ {
279
+ verb: "tabulated",
280
+ value: ["--release", "--min-round"],
281
+ bool: [],
282
+ usage: [
283
+ " tabulated [--release <spec>] [--min-round <n>]",
284
+ " the majors addresses the marks sheets tabulate to round n",
285
+ " or later (default 3)"
286
+ ]
287
+ },
288
+ {
289
+ verb: "tabs",
290
+ value: ["--release", "--comp", "--address", "--round", "--event", "--year", "--tier"],
291
+ bool: ["--stream"],
292
+ usage: [
293
+ " tabs [--release <spec>] --comp <competition> | --address <address> [--round <r>]",
294
+ " a marks sheet (or one card of it): every seat's mark,",
295
+ " place and points, with the judge",
296
+ " tabs --stream [--release <spec>] [--comp <c,...>] [--event <e,...>]",
297
+ " [--year <y> | --year <from>..<to>] [--tier <t,...>]",
298
+ " every cell of every sheet named, one JSON line each"
299
+ ]
300
+ },
301
+ {
302
+ verb: "panels",
303
+ value: ["--release", "--comp"],
304
+ bool: [],
305
+ usage: [
306
+ " panels [--release <spec>] [--comp <competition>]",
307
+ " who sat a major's competition (every one's, with no --comp)"
308
+ ]
309
+ },
310
+ {
311
+ verb: "feis-panels",
312
+ value: ["--release", "--address", "--platform"],
313
+ bool: [],
314
+ usage: [
315
+ " feis-panels [--release <spec>] [--address <feis competition>] [--platform <p>]",
316
+ " who sat a feis's competition (fweb:ABC24.105)"
317
+ ]
318
+ },
319
+ {
320
+ verb: "register",
321
+ value: ["--release", "--year", "--td"],
322
+ bool: [],
323
+ usage: [
324
+ " register [--release <spec>] [--year <y>] [--td <TD number>]",
325
+ " the adjudicator register's rows: category, country,",
326
+ " region, geohash, per year"
327
+ ]
328
+ },
329
+ {
330
+ verb: "schools",
331
+ value: ["--release", "--event", "--year", "--school"],
332
+ bool: ["--prints", "--redirects", "--lineage", "--associations"],
333
+ usage: [
334
+ " schools [--release <spec>] every school the registry lists: display, regions, places",
335
+ " schools --prints [--release <spec>] [--event <e>] [--year <y>]",
336
+ " the (print, school_id) pairs the rows attach, per event-year",
337
+ " schools --redirects | --lineage [--release <spec>]",
338
+ " the retired ids; the lineage edges",
339
+ " schools --associations [--release <spec>] [--school <school_id>]",
340
+ " the people a directory lists beside a school"
341
+ ]
342
+ },
343
+ {
344
+ verb: "teams",
345
+ value: ["--release", "--event", "--year"],
346
+ bool: ["--rosters", "--joins"],
347
+ usage: [
348
+ " teams [--release <spec>] [--event <e>] [--year <y>] [--rosters | --joins]",
349
+ " the team result rows of an event-year; with --rosters its",
350
+ " roster teams and their dancers; with --joins how each roster",
351
+ " team meets the results"
352
+ ]
353
+ },
354
+ {
355
+ verb: "events",
356
+ value: ["--release", "--event", "--year"],
357
+ bool: [],
358
+ usage: [
359
+ " events [--release <spec>] [--event <e>] [--year <y>]",
360
+ " each event-year's dates and place"
361
+ ]
362
+ },
363
+ {
364
+ verb: "teacher",
365
+ value: ["--release"],
366
+ bool: [],
367
+ usage: [
368
+ " teacher [--release <spec>] <name|TD number>",
369
+ " the staff lists' people: where they taught, the register,",
370
+ " where they sat"
371
+ ]
372
+ },
373
+ {
374
+ verb: "adjudicator",
375
+ value: ["--release"],
376
+ bool: [],
377
+ usage: [
378
+ " adjudicator [--release <spec>] <name|TD number>",
379
+ " the register's and the panels' people: the same answer"
380
+ ]
381
+ },
382
+ {
383
+ verb: "comp",
384
+ value: ["--release", "--year", "--title"],
385
+ bool: [],
386
+ usage: [
387
+ " comp [--release <spec>] <feis> <code> [--year <y>] [--title <t>]",
388
+ " a feis's own comp code to the comp it names, through that",
389
+ " feis's syllabus (the prior year's only where the platform",
390
+ " numbers every feis alike; elsewhere the title)"
391
+ ]
392
+ },
393
+ {
394
+ verb: "syllabus",
395
+ value: ["--release", "--for"],
396
+ bool: [],
397
+ usage: [
398
+ " syllabus [--release <spec>] <feis> [year]",
399
+ " one feis-year's comps, in printed order",
400
+ " syllabus [--release <spec>] --for <series> [year]",
401
+ " a series' syllabus for a year: that year's where held,",
402
+ " else the newest, saying which and what it is read from"
403
+ ]
404
+ },
405
+ {
406
+ verb: "resolve",
407
+ value: [
408
+ "--year",
409
+ "--title",
410
+ "--school",
411
+ "--comp",
412
+ "--yob",
413
+ "--band",
414
+ "--order",
415
+ "--as-of",
416
+ "--population",
417
+ "--oireachtas"
418
+ ],
419
+ bool: [],
420
+ usage: [
421
+ " resolve comp [<feis> <code>] [--year <y>] [--title <t>]",
422
+ " resolve dancer [<name>] [--school <s>] [--comp <feis>/<code> | --yob <y> | --band <b> --year <y>]",
423
+ " [--order <o>] [--as-of <date>] [--population girls|boys]",
424
+ " [--oireachtas <region>[:<year>]]",
425
+ " resolve registrations",
426
+ " JSONL out, one answer per line; with no positional the",
427
+ " questions are JSONL on stdin, one per line (a comp:",
428
+ " {feis, code, year?, title?}, a dancer: {name, school?, age?,",
429
+ " population?, oireachtas?}, a registration: {name, school?,",
430
+ " codes[], feis, year?, population?, oireachtas?})"
431
+ ]
432
+ }
433
+ ];
434
+ var USAGE_FOOTER = [
435
+ " A query on the default spec prints one warning line on stderr when its release is older than",
436
+ " the newest published one (the remote asked at most once per hour, <cache>/LATEST.json); the",
437
+ " answer and the exit code are unchanged, and an offline check says nothing.",
438
+ "",
439
+ " Where the caller names local builds (a wrapper's option), a query with no --release answers",
440
+ " from the newest COMPLETE build newer than the pinned release, and says so in one line on",
441
+ " stderr; --release <spec> names a release, and --live forces the pinned one.",
442
+ "",
443
+ " <spec>: pinned (the default) | latest | a cut (42, 42.1) | a tag (archive-YYYY.MM.DD-N)"
444
+ ];
445
+ function renderUsage() {
446
+ return [USAGE_HEADER, "", ...VERBS.flatMap((v) => v.usage), "", ...USAGE_FOOTER].join(`
447
+ `);
448
+ }
449
+ function valueFlags() {
450
+ return new Set([...GLOBAL_FLAGS.value, ...VERBS.flatMap((v) => v.value)]);
451
+ }
133
452
 
134
- <spec>: pinned (the default) | latest | a cut (42, 42.1) | a tag (archive-YYYY.MM.DD-N)`;
135
- var VALUE = new Set([
136
- "--cache",
137
- "--repo",
138
- "--release",
139
- "--assets",
140
- "--tag",
141
- "--keep",
142
- "--platform",
143
- "--code",
144
- "--id",
145
- "--name",
146
- "--year",
147
- "--region",
148
- "--order",
149
- "--surname",
150
- "--like",
151
- "--school",
152
- "--yob",
153
- "--band",
154
- "--comp",
155
- "--as-of",
156
- "--population",
157
- "--oireachtas",
158
- "--dancer",
159
- "--feis",
160
- "--limit",
161
- "--event",
162
- "--title",
163
- "--for",
164
- "--scope",
165
- "--tier",
166
- "--category",
167
- "--level",
168
- "--min-round"
169
- ]);
453
+ var USAGE = renderUsage();
454
+ var VALUE = valueFlags();
170
455
  function parseArgs(argv) {
171
456
  const positional = [];
172
457
  const flags = new Map;
@@ -432,6 +717,27 @@ function streamQueryOf(p) {
432
717
  q.primary = true;
433
718
  return q;
434
719
  }
720
+ function tabStreamQueryOf(p) {
721
+ const q = {};
722
+ const comp = p.flags.get("--comp");
723
+ if (comp !== undefined)
724
+ q.competition = listOf(comp);
725
+ const event = p.flags.get("--event");
726
+ if (event !== undefined)
727
+ q.event = listOf(event);
728
+ const tier = p.flags.get("--tier");
729
+ if (tier !== undefined)
730
+ q.tier = listOf(tier);
731
+ const year = p.flags.get("--year");
732
+ if (year !== undefined) {
733
+ const m = /^(\d{4})\.\.(\d{4})$/.exec(year);
734
+ q.year = m === null ? Number(year) : [Number(m[1]), Number(m[2])];
735
+ if (typeof q.year === "number" && !Number.isInteger(q.year))
736
+ throw new Error(`--year takes a year or <from>..<to>, not "${year}"`);
737
+ }
738
+ return q;
739
+ }
740
+ var tabLine = (t) => ` ${t.address} ${t.round} seat ${t.seat_index}/${t.panel_size} ${t.judge_clrg ?? t.judge_id ?? "-"} ${t.judge_name_printed ?? "-"} mark ${t.mark_printed ?? "-"} place ${t.place_printed ?? "-"}${t.tie === 1 ? "=" : ""} points ${t.points_printed ?? "-"}`;
435
741
  function eventYearOf(p) {
436
742
  const event = p.flags.get("--event");
437
743
  const year = p.flags.get("--year");
@@ -453,6 +759,11 @@ var ANSWERING = new Set([
453
759
  "records",
454
760
  "feis-dates",
455
761
  "tabulated",
762
+ "tabs",
763
+ "panels",
764
+ "feis-panels",
765
+ "register",
766
+ "schools",
456
767
  "teams",
457
768
  "events",
458
769
  "teacher",
@@ -933,6 +1244,145 @@ async function main(argv, io = {}) {
933
1244
  rel.close();
934
1245
  }
935
1246
  }
1247
+ case "tabs": {
1248
+ const stream = p.bools.has("--stream");
1249
+ const tq = stream ? tabStreamQueryOf(p) : null;
1250
+ const comp = p.flags.get("--comp");
1251
+ const address = p.flags.get("--address");
1252
+ if (!stream && comp === undefined && address === undefined) {
1253
+ log("tabs --comp <competition> | --address <address> [--round <r>], or tabs --stream");
1254
+ return 2;
1255
+ }
1256
+ const rel = await open(spec, { ...opts, assets: [] });
1257
+ try {
1258
+ if (tq !== null) {
1259
+ let n = 0;
1260
+ for await (const t of rel.tabs.stream(tq)) {
1261
+ say(JSON.stringify(t));
1262
+ n++;
1263
+ }
1264
+ log(`${n} cell(s) in ${rel.tag}`);
1265
+ return n === 0 ? 1 : 0;
1266
+ }
1267
+ const round = p.flags.get("--round");
1268
+ const a = await rel.tabs.query({
1269
+ ...address !== undefined ? { address } : { competition: comp },
1270
+ ...round !== undefined ? { round } : {}
1271
+ });
1272
+ out(a, () => {
1273
+ for (const t of a.rows)
1274
+ say(tabLine(t));
1275
+ say(`${a.rows.length} cell(s) in ${a.tag}`);
1276
+ });
1277
+ return a.rows.length === 0 ? 1 : 0;
1278
+ } finally {
1279
+ rel.close();
1280
+ }
1281
+ }
1282
+ case "panels": {
1283
+ const rel = await open(spec, { ...opts, assets: [] });
1284
+ try {
1285
+ const comp = p.flags.get("--comp");
1286
+ const a = await rel.panels.query(comp !== undefined ? { competition: comp } : {});
1287
+ out(a, () => {
1288
+ for (const s of a.seats)
1289
+ say(` ${s.competition} ${s.panel} ${s.round} seat ${s.seat_index} ${s.judge_clrg ?? s.judge_id ?? "-"} ${s.judge_name_printed ?? "-"}${s.judge_unmatched === null ? "" : ` (${s.judge_unmatched})`}`);
1290
+ say(`${a.seats.length} seat(s) in ${a.tag}`);
1291
+ });
1292
+ return a.seats.length === 0 ? 1 : 0;
1293
+ } finally {
1294
+ rel.close();
1295
+ }
1296
+ }
1297
+ case "feis-panels": {
1298
+ const rel = await open(spec, { ...opts, assets: [] });
1299
+ try {
1300
+ const address = p.flags.get("--address");
1301
+ const platform = p.flags.get("--platform");
1302
+ const a = await rel.feisPanels.query({
1303
+ ...address !== undefined ? { address } : {},
1304
+ ...platform !== undefined ? { platform } : {}
1305
+ });
1306
+ out(a, () => {
1307
+ for (const s of a.seats)
1308
+ say(` ${s.address} ${s.round} seat ${s.seat_index}/${s.panel_size} ${s.judge_clrg ?? s.judge_id ?? "-"} ${s.judge_name_printed}${s.judge_basis === null ? "" : ` (${s.judge_basis})`}`);
1309
+ say(`${a.seats.length} seat(s) in ${a.tag}`);
1310
+ });
1311
+ return a.seats.length === 0 ? 1 : 0;
1312
+ } finally {
1313
+ rel.close();
1314
+ }
1315
+ }
1316
+ case "register": {
1317
+ const rel = await open(spec, { ...opts, assets: [] });
1318
+ try {
1319
+ const year = p.flags.get("--year");
1320
+ const td = p.flags.get("--td");
1321
+ const a = await rel.staff.adjudicators({
1322
+ ...year !== undefined ? { year: Number(year) } : {},
1323
+ ...td !== undefined ? { judge_clrg: Number(td) } : {}
1324
+ });
1325
+ out(a, () => {
1326
+ for (const r of a.rows)
1327
+ say(` ${r.judge_clrg} ${r.year} ${r.cat} ${r.name_printed} ${r.country_code ?? r.country} ${r.region_code ?? r.region} ${r.geohash ?? "-"}`);
1328
+ say(`${a.rows.length} register row(s) in ${a.tag}`);
1329
+ });
1330
+ return a.rows.length === 0 ? 1 : 0;
1331
+ } finally {
1332
+ rel.close();
1333
+ }
1334
+ }
1335
+ case "schools": {
1336
+ const rel = await open(spec, { ...opts, assets: [] });
1337
+ try {
1338
+ if (p.bools.has("--prints")) {
1339
+ const a = await rel.schools.prints(eventYearOf(p));
1340
+ out(a, () => {
1341
+ for (const x of a.prints)
1342
+ say(` ${x.year ?? "?"} ${x.event} ${x.school_id} "${x.print}" ${x.rows} rows`);
1343
+ say(`${a.prints.length} pair(s) in ${a.tag}`);
1344
+ });
1345
+ return a.prints.length === 0 ? 1 : 0;
1346
+ }
1347
+ if (p.bools.has("--redirects")) {
1348
+ const a = await rel.schools.redirects();
1349
+ out(a, () => {
1350
+ for (const r of a.redirects)
1351
+ say(` ${r.old_id} -> ${r.new_id} ${r.kind}${r.since === null ? "" : ` since ${r.since}`}`);
1352
+ say(`${a.redirects.length} redirect(s) in ${a.tag}`);
1353
+ });
1354
+ return a.redirects.length === 0 ? 1 : 0;
1355
+ }
1356
+ if (p.bools.has("--lineage")) {
1357
+ const a = await rel.schools.lineage();
1358
+ out(a, () => {
1359
+ for (const e of a.edges)
1360
+ say(` ${e.id} ${e.direction} ${e.other} ${e.shape} ${e.year ?? "?"}${e.provisional ? " provisional" : ""}`);
1361
+ say(`${a.edges.length} edge end(s) in ${a.tag}`);
1362
+ });
1363
+ return a.edges.length === 0 ? 1 : 0;
1364
+ }
1365
+ if (p.bools.has("--associations")) {
1366
+ const school = p.flags.get("--school");
1367
+ const a = await rel.schools.associations(school !== undefined ? { school_id: school } : {});
1368
+ out(a, () => {
1369
+ for (const x of a.associations)
1370
+ say(` ${x.school_id ?? "(no id)"} "${x.school_printed ?? ""}" ${x.person_printed} (${x.person_type ?? "-"}${x.credentials === null ? "" : `, ${x.credentials}`}) ${x.date ?? "-"} ${x.src_type ?? ""}`);
1371
+ say(`${a.associations.length} association(s) in ${a.tag}`);
1372
+ });
1373
+ return a.associations.length === 0 ? 1 : 0;
1374
+ }
1375
+ const a = await rel.schools.list();
1376
+ out(a, () => {
1377
+ for (const s of a.schools)
1378
+ say(` ${s.school_id} ${s.display} ${s.regions.join(",") || "-"} ${s.places.join(",") || "-"}`);
1379
+ say(`${a.schools.length} school(s) in ${a.tag}`);
1380
+ });
1381
+ return a.schools.length === 0 ? 1 : 0;
1382
+ } finally {
1383
+ rel.close();
1384
+ }
1385
+ }
936
1386
  case "teams": {
937
1387
  const rel = await open(spec, { ...opts, assets: [] });
938
1388
  try {
@@ -1080,9 +1530,16 @@ async function main(argv, io = {}) {
1080
1530
  if (import.meta.main)
1081
1531
  process.exit(await main(process.argv.slice(2)));
1082
1532
  export {
1533
+ GLOBAL_FLAGS,
1083
1534
  USAGE,
1535
+ USAGE_FOOTER,
1536
+ USAGE_HEADER,
1537
+ VERBS,
1084
1538
  jsonLines,
1085
1539
  main,
1086
1540
  parseArgs,
1087
- streamQueryOf
1541
+ renderUsage,
1542
+ streamQueryOf,
1543
+ tabStreamQueryOf,
1544
+ valueFlags
1088
1545
  };