@profullstack/nichedb 0.25.0 → 0.28.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 +15 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/nichedb",
3
- "version": "0.25.0",
3
+ "version": "0.28.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
@@ -15,7 +15,8 @@ import { homedir, tmpdir } from 'node:os';
15
15
  import { join } from 'node:path';
16
16
  import { createInterface } from 'node:readline';
17
17
 
18
- export const VERSION = '0.25.0';
18
+ export const VERSION = '0.28.0';
19
+ const GEO_FLAGS = ['lat', 'long', 'radius', 'unit', 'bbox', 'sort', 'offset'];
19
20
  const DEFAULT_API = process.env.NICHEDB_API ?? 'https://nichedb.dev';
20
21
  const CONFIG_DIR = join(process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'nichedb');
21
22
  const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
@@ -94,7 +95,7 @@ export const COMMANDS = [
94
95
  {
95
96
  name: 'recent',
96
97
  usage:
97
- 'recent [--collection …] [--source …] [--kind …] [--tags a,b] [--from …] [--to …] [--since …] [--sort id|published|updated]',
98
+ 'recent [--collection …] [--source …] [--kind …] [--tags a,b] [--from …] [--to …] [--since …] [--sort id|published|updated|distance]',
98
99
  summary:
99
100
  'Newest items across a collection or source, or a window of them, or what changed since.',
100
101
  options: [
@@ -104,8 +105,11 @@ export const COMMANDS = [
104
105
  '--tags a,b (every one must be on the item)',
105
106
  '--from / --to (ISO, on published_at)',
106
107
  '--since (ISO, on updated_at)',
107
- '--sort id|published|updated',
108
+ '--sort id|published|updated|distance',
108
109
  '--order asc|desc',
110
+ '--lat / --long / --radius / --unit km|mi',
111
+ '--bbox west,south,east,north',
112
+ '--offset (distance pagination)',
109
113
  '--limit',
110
114
  '--json',
111
115
  '--urls',
@@ -597,6 +601,9 @@ export async function run(
597
601
  tags: csv(flags.tags),
598
602
  q: flags.q,
599
603
  upcoming: Boolean(flags.upcoming),
604
+ ...Object.fromEntries(
605
+ GEO_FLAGS.filter((k) => flags[k] !== undefined).map((k) => [k, flags[k]]),
606
+ ),
600
607
  public: !flags.private,
601
608
  });
602
609
  out(
@@ -618,6 +625,7 @@ export async function run(
618
625
  const [slug] = rest;
619
626
  if (!slug) throw new Error('items <feed>');
620
627
  const qs = new URLSearchParams();
628
+ for (const k of GEO_FLAGS) if (flags[k] !== undefined) qs.set(k, flags[k]);
621
629
  if (flags.limit) qs.set('limit', flags.limit);
622
630
  if (flags.before) qs.set('before', flags.before);
623
631
  const { items } = await client.get(`/api/v1/feeds/${slug}/items?${qs}`);
@@ -626,6 +634,7 @@ export async function run(
626
634
  }
627
635
  case 'recent': {
628
636
  const qs = new URLSearchParams();
637
+ for (const k of GEO_FLAGS) if (flags[k] !== undefined) qs.set(k, flags[k]);
629
638
  for (const k of [
630
639
  'collection',
631
640
  'source',
@@ -649,6 +658,7 @@ export async function run(
649
658
  const name = rest.join(' ');
650
659
  if (!name) throw new Error('match <name>');
651
660
  const qs = new URLSearchParams({ q: name });
661
+ for (const k of GEO_FLAGS) if (flags[k] !== undefined) qs.set(k, flags[k]);
652
662
  for (const k of ['collection', 'kind', 'year', 'date', 'tags', 'limit'])
653
663
  if (flags[k]) qs.set(k, flags[k]);
654
664
  const answer = await client.get(`/api/v1/match?${qs}`);
@@ -668,6 +678,7 @@ export async function run(
668
678
  }
669
679
  case 'upcoming': {
670
680
  const qs = new URLSearchParams();
681
+ for (const k of GEO_FLAGS) if (flags[k] !== undefined) qs.set(k, flags[k]);
671
682
  for (const k of ['collection', 'days', 'limit']) if (flags[k]) qs.set(k, flags[k]);
672
683
  const { items } = await client.get(`/api/v1/items/upcoming?${qs}`);
673
684
  printItems(items, { json, urls: flags.urls });
@@ -677,6 +688,7 @@ export async function run(
677
688
  const term = rest.join(' ');
678
689
  if (!term) throw new Error('search <query>');
679
690
  const qs = new URLSearchParams({ q: term });
691
+ for (const k of GEO_FLAGS) if (flags[k] !== undefined) qs.set(k, flags[k]);
680
692
  for (const k of ['collection', 'kind', 'limit']) if (flags[k]) qs.set(k, flags[k]);
681
693
  const { items } = await client.get(`/api/v1/search?${qs}`);
682
694
  printItems(items, { json, urls: flags.urls });