@dayofweek/dcli 1.9.1 → 1.10.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/bin/dcli.js CHANGED
@@ -430,6 +430,71 @@ brainSource
430
430
  }
431
431
  output(await getClient().scopeBrainSource(sourceId, opts.actor ?? null));
432
432
  });
433
+ const brainTags = brain
434
+ .command("tags")
435
+ .description("Work with an area's tag vocabulary and resource couplings");
436
+ brainTags
437
+ .command("list")
438
+ .description("List an area's tags (predefined hierarchical set + user-defined)")
439
+ .requiredOption("--area <areaId>", "Area id (from `brain list`)")
440
+ .action(async (opts) => {
441
+ output(await getClient().listBrainTags(opts.area));
442
+ });
443
+ brainTags
444
+ .command("add")
445
+ .description("Add a user-defined tag (idempotent on the derived key)")
446
+ .requiredOption("--area <areaId>", "Area id (from `brain list`)")
447
+ .requiredOption("--label <label>", "Tag label")
448
+ .option("--parent <key>", "Parent tag key (makes this a child tag)")
449
+ .option("--description <text>", "What the tag means")
450
+ .action(async (opts) => {
451
+ output(await getClient().createBrainTag({
452
+ areaId: opts.area,
453
+ label: opts.label,
454
+ parentKey: opts.parent,
455
+ description: opts.description,
456
+ }));
457
+ });
458
+ brainTags
459
+ .command("couplings")
460
+ .description("List tag/actor couplings — filter by actor, tag, source or note")
461
+ .requiredOption("--area <areaId>", "Area id (from `brain list`)")
462
+ .option("--tag <key>", "Resources coupled to this tag")
463
+ .option("--actor <actorId>", "Resources coupled to this actor")
464
+ .option("--source <sourceId>", "One source's tags and actors")
465
+ .option("--note <noteId>", "One note/page's tags and actors")
466
+ .action(async (opts) => {
467
+ output(await getClient().listBrainCouplings({
468
+ areaId: opts.area,
469
+ tag: opts.tag,
470
+ actor: opts.actor,
471
+ source: opts.source,
472
+ note: opts.note,
473
+ }));
474
+ });
475
+ brainTags
476
+ .command("couple")
477
+ .description("Couple a source/note to a tag or an actor (--remove uncouples)")
478
+ .option("--source <sourceId>", "Source to couple")
479
+ .option("--note <noteId>", "Note/page to couple")
480
+ .option("--tag <key>", "Tag key (from `brain tags list`)")
481
+ .option("--actor <actorId>", "Actor id (from `brain actors list`)")
482
+ .option("--remove", "Remove the coupling instead of adding it")
483
+ .action(async (opts) => {
484
+ if (Boolean(opts.source) === Boolean(opts.note)) {
485
+ throw new Error("Pass exactly one of --source <sourceId> or --note <noteId>");
486
+ }
487
+ if (Boolean(opts.tag) === Boolean(opts.actor)) {
488
+ throw new Error("Pass exactly one of --tag <key> or --actor <actorId>");
489
+ }
490
+ output(await getClient().coupleBrainResource({
491
+ sourceId: opts.source,
492
+ noteId: opts.note,
493
+ tagKey: opts.tag,
494
+ actorId: opts.actor,
495
+ remove: opts.remove,
496
+ }));
497
+ });
433
498
  auth
434
499
  .command("devices")
435
500
  .description("List your agent tokens")
@@ -4518,6 +4518,27 @@ var DayOfWeekClient = class {
4518
4518
  async scopeBrainSource(sourceId, actorId) {
4519
4519
  return this.patch(`/brain/sources/${encodeURIComponent(sourceId)}/actor`, { actorId });
4520
4520
  }
4521
+ /** The area's tag vocabulary: predefined hierarchical set + user-defined. */
4522
+ async listBrainTags(areaId) {
4523
+ return this.get(`/brain/tags?area=${encodeURIComponent(areaId)}`);
4524
+ }
4525
+ /** Add a user-defined tag to an area's vocabulary. Idempotent on the key. */
4526
+ async createBrainTag(input) {
4527
+ return this.post("/brain/tags", input);
4528
+ }
4529
+ /** Tag/actor couplings, filterable by actor, tag, source or note. */
4530
+ async listBrainCouplings(input) {
4531
+ const params = new URLSearchParams({ area: input.areaId });
4532
+ if (input.tag) params.set("tag", input.tag);
4533
+ if (input.actor) params.set("actor", input.actor);
4534
+ if (input.source) params.set("source", input.source);
4535
+ if (input.note) params.set("note", input.note);
4536
+ return this.get(`/brain/tags/couplings?${params.toString()}`);
4537
+ }
4538
+ /** Couple (or uncouple, with remove) a source/note to a tag or an actor. */
4539
+ async coupleBrainResource(input) {
4540
+ return this.post("/brain/tags/couplings", input);
4541
+ }
4521
4542
  /** Entities with an active customer role and no investor/partner/producer role. */
4522
4543
  async adminCustomersOnly() {
4523
4544
  return this.get("/admin/customers-only");
@@ -5144,7 +5165,7 @@ var import_promises4 = require("node:readline/promises");
5144
5165
  // package.json
5145
5166
  var package_default = {
5146
5167
  name: "@dayofweek/dcli",
5147
- version: "1.9.1",
5168
+ version: "1.10.0",
5148
5169
  description: "CLI for the Day of Week AgTech platform \u2014 read data and submit proposals for review",
5149
5170
  license: "MIT",
5150
5171
  type: "module",
@@ -5532,6 +5553,42 @@ brainSource.command("scope <sourceId>").description("Scope a source to an actor
5532
5553
  }
5533
5554
  output(await getClient().scopeBrainSource(sourceId, opts.actor ?? null));
5534
5555
  });
5556
+ var brainTags = brain.command("tags").description("Work with an area's tag vocabulary and resource couplings");
5557
+ brainTags.command("list").description("List an area's tags (predefined hierarchical set + user-defined)").requiredOption("--area <areaId>", "Area id (from `brain list`)").action(async (opts) => {
5558
+ output(await getClient().listBrainTags(opts.area));
5559
+ });
5560
+ brainTags.command("add").description("Add a user-defined tag (idempotent on the derived key)").requiredOption("--area <areaId>", "Area id (from `brain list`)").requiredOption("--label <label>", "Tag label").option("--parent <key>", "Parent tag key (makes this a child tag)").option("--description <text>", "What the tag means").action(async (opts) => {
5561
+ output(await getClient().createBrainTag({
5562
+ areaId: opts.area,
5563
+ label: opts.label,
5564
+ parentKey: opts.parent,
5565
+ description: opts.description
5566
+ }));
5567
+ });
5568
+ brainTags.command("couplings").description("List tag/actor couplings \u2014 filter by actor, tag, source or note").requiredOption("--area <areaId>", "Area id (from `brain list`)").option("--tag <key>", "Resources coupled to this tag").option("--actor <actorId>", "Resources coupled to this actor").option("--source <sourceId>", "One source's tags and actors").option("--note <noteId>", "One note/page's tags and actors").action(async (opts) => {
5569
+ output(await getClient().listBrainCouplings({
5570
+ areaId: opts.area,
5571
+ tag: opts.tag,
5572
+ actor: opts.actor,
5573
+ source: opts.source,
5574
+ note: opts.note
5575
+ }));
5576
+ });
5577
+ brainTags.command("couple").description("Couple a source/note to a tag or an actor (--remove uncouples)").option("--source <sourceId>", "Source to couple").option("--note <noteId>", "Note/page to couple").option("--tag <key>", "Tag key (from `brain tags list`)").option("--actor <actorId>", "Actor id (from `brain actors list`)").option("--remove", "Remove the coupling instead of adding it").action(async (opts) => {
5578
+ if (Boolean(opts.source) === Boolean(opts.note)) {
5579
+ throw new Error("Pass exactly one of --source <sourceId> or --note <noteId>");
5580
+ }
5581
+ if (Boolean(opts.tag) === Boolean(opts.actor)) {
5582
+ throw new Error("Pass exactly one of --tag <key> or --actor <actorId>");
5583
+ }
5584
+ output(await getClient().coupleBrainResource({
5585
+ sourceId: opts.source,
5586
+ noteId: opts.note,
5587
+ tagKey: opts.tag,
5588
+ actorId: opts.actor,
5589
+ remove: opts.remove
5590
+ }));
5591
+ });
5535
5592
  auth.command("devices").description("List your agent tokens").action(async () => {
5536
5593
  const client = getClient();
5537
5594
  const devices = await client.listDevices();
package/dist/client.d.ts CHANGED
@@ -251,6 +251,31 @@ export declare class DayOfWeekClient {
251
251
  }): Promise<any>;
252
252
  /** Scope a source to an actor (actorId null returns it to area level). */
253
253
  scopeBrainSource(sourceId: string, actorId: string | null): Promise<any>;
254
+ /** The area's tag vocabulary: predefined hierarchical set + user-defined. */
255
+ listBrainTags(areaId: string): Promise<any>;
256
+ /** Add a user-defined tag to an area's vocabulary. Idempotent on the key. */
257
+ createBrainTag(input: {
258
+ areaId: string;
259
+ label: string;
260
+ parentKey?: string;
261
+ description?: string;
262
+ }): Promise<any>;
263
+ /** Tag/actor couplings, filterable by actor, tag, source or note. */
264
+ listBrainCouplings(input: {
265
+ areaId: string;
266
+ tag?: string;
267
+ actor?: string;
268
+ source?: string;
269
+ note?: string;
270
+ }): Promise<any>;
271
+ /** Couple (or uncouple, with remove) a source/note to a tag or an actor. */
272
+ coupleBrainResource(input: {
273
+ sourceId?: string;
274
+ noteId?: string;
275
+ tagKey?: string;
276
+ actorId?: string;
277
+ remove?: boolean;
278
+ }): Promise<any>;
254
279
  /** Entities with an active customer role and no investor/partner/producer role. */
255
280
  adminCustomersOnly(): Promise<any>;
256
281
  /** Tips mailed to press@mail.dayofweek.com, read by the press-scan skill. */
package/dist/client.js CHANGED
@@ -378,6 +378,31 @@ export class DayOfWeekClient {
378
378
  async scopeBrainSource(sourceId, actorId) {
379
379
  return this.patch(`/brain/sources/${encodeURIComponent(sourceId)}/actor`, { actorId });
380
380
  }
381
+ /** The area's tag vocabulary: predefined hierarchical set + user-defined. */
382
+ async listBrainTags(areaId) {
383
+ return this.get(`/brain/tags?area=${encodeURIComponent(areaId)}`);
384
+ }
385
+ /** Add a user-defined tag to an area's vocabulary. Idempotent on the key. */
386
+ async createBrainTag(input) {
387
+ return this.post("/brain/tags", input);
388
+ }
389
+ /** Tag/actor couplings, filterable by actor, tag, source or note. */
390
+ async listBrainCouplings(input) {
391
+ const params = new URLSearchParams({ area: input.areaId });
392
+ if (input.tag)
393
+ params.set("tag", input.tag);
394
+ if (input.actor)
395
+ params.set("actor", input.actor);
396
+ if (input.source)
397
+ params.set("source", input.source);
398
+ if (input.note)
399
+ params.set("note", input.note);
400
+ return this.get(`/brain/tags/couplings?${params.toString()}`);
401
+ }
402
+ /** Couple (or uncouple, with remove) a source/note to a tag or an actor. */
403
+ async coupleBrainResource(input) {
404
+ return this.post("/brain/tags/couplings", input);
405
+ }
381
406
  /** Entities with an active customer role and no investor/partner/producer role. */
382
407
  async adminCustomersOnly() {
383
408
  return this.get("/admin/customers-only");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dayofweek/dcli",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "description": "CLI for the Day of Week AgTech platform \u2014 read data and submit proposals for review",
5
5
  "license": "MIT",
6
6
  "type": "module",