@profullstack/nichedb 0.5.1 → 0.7.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +60 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/nichedb",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "description": "CLI and MCP bridge for NicheDB: browse collections, manage sources and feeds, search items, from any deployment",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -14,7 +14,7 @@ import { homedir } from 'node:os';
14
14
  import { join } from 'node:path';
15
15
  import { createInterface } from 'node:readline';
16
16
 
17
- export const VERSION = '0.5.1';
17
+ export const VERSION = '0.7.0';
18
18
  const DEFAULT_API = process.env.NICHEDB_API ?? 'https://nichedb.dev';
19
19
  const CONFIG_DIR = join(process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'nichedb');
20
20
  const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
@@ -86,9 +86,30 @@ export const COMMANDS = [
86
86
  },
87
87
  {
88
88
  name: 'recent',
89
- usage: 'recent [--collection …] [--source …] [--kind …]',
90
- summary: 'Newest items across a collection or source.',
91
- options: ['--collection', '--source', '--kind', '--limit', '--json', '--urls'],
89
+ usage:
90
+ 'recent [--collection …] [--source …] [--kind …] [--tags a,b] [--from …] [--to …] [--since …] [--sort id|published|updated]',
91
+ summary:
92
+ 'Newest items across a collection or source, or a window of them, or what changed since.',
93
+ options: [
94
+ '--collection',
95
+ '--source',
96
+ '--kind',
97
+ '--tags a,b (every one must be on the item)',
98
+ '--from / --to (ISO, on published_at)',
99
+ '--since (ISO, on updated_at)',
100
+ '--sort id|published|updated',
101
+ '--order asc|desc',
102
+ '--limit',
103
+ '--json',
104
+ '--urls',
105
+ ],
106
+ },
107
+ {
108
+ name: 'match',
109
+ usage: 'match <name> [--collection …] [--kind …] [--year …] [--tags a,b]',
110
+ summary:
111
+ 'Which title, channel or fixture is this name? A release name or a playlist entry, cleaned and matched by similarity.',
112
+ options: ['--collection', '--kind', '--year', '--tags', '--limit', '--json', '--urls'],
92
113
  },
93
114
  {
94
115
  name: 'upcoming',
@@ -496,12 +517,46 @@ export async function run(
496
517
  }
497
518
  case 'recent': {
498
519
  const qs = new URLSearchParams();
499
- for (const k of ['collection', 'source', 'kind', 'limit', 'before'])
520
+ for (const k of [
521
+ 'collection',
522
+ 'source',
523
+ 'kind',
524
+ 'tags',
525
+ 'from',
526
+ 'to',
527
+ 'since',
528
+ 'sort',
529
+ 'order',
530
+ 'limit',
531
+ 'before',
532
+ 'after',
533
+ ])
500
534
  if (flags[k]) qs.set(k, flags[k]);
501
535
  const { items } = await client.get(`/api/v1/items?${qs}`);
502
536
  printItems(items, { json, urls: flags.urls });
503
537
  return 0;
504
538
  }
539
+ case 'match': {
540
+ const name = rest.join(' ');
541
+ if (!name) throw new Error('match <name>');
542
+ const qs = new URLSearchParams({ q: name });
543
+ for (const k of ['collection', 'kind', 'year', 'tags', 'limit'])
544
+ if (flags[k]) qs.set(k, flags[k]);
545
+ const answer = await client.get(`/api/v1/match?${qs}`);
546
+ if (json) {
547
+ console.log(JSON.stringify(answer, null, 2));
548
+ return 0;
549
+ }
550
+ const p = answer.parsed;
551
+ console.log(
552
+ `read as: ${p.name}${p.year ? ` (${p.year})` : ''}${p.season ? ` S${p.season}` : ''}${p.episode ? `E${p.episode}` : ''} · ${p.kind}`,
553
+ );
554
+ printItems(
555
+ answer.items.map((i) => ({ ...i, title: `${(i.score * 100).toFixed(0)}% ${i.title}` })),
556
+ { json: false, urls: flags.urls },
557
+ );
558
+ return 0;
559
+ }
505
560
  case 'upcoming': {
506
561
  const qs = new URLSearchParams();
507
562
  for (const k of ['collection', 'days', 'limit']) if (flags[k]) qs.set(k, flags[k]);