@stndrds/cli 1.0.0-alpha.227 → 1.0.0-alpha.228

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/dist/bin.mjs +66 -28
  2. package/package.json +1 -1
package/dist/bin.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/program.ts
4
- import chalk6 from "chalk";
4
+ import chalk7 from "chalk";
5
5
  import { Command } from "commander";
6
6
 
7
7
  // src/client.ts
@@ -208,6 +208,43 @@ function registerAutofillCommand(program) {
208
208
  );
209
209
  }
210
210
 
211
+ // src/commands/connectors.ts
212
+ import chalk3 from "chalk";
213
+ var PROVIDERS = ["gmail", "outlook"];
214
+ function resolveScope(scope) {
215
+ return scope === "actor" ? "actor" : "tenant";
216
+ }
217
+ function registerConnectorsCommand(program) {
218
+ const connectors = program.command("connectors").description("Manage email connectors (Gmail / Outlook OAuth connections)");
219
+ connectors.command("list").description("List connector connections").option("--scope <scope>", "connection scope (tenant or actor)", "tenant").action(async (opts, cmd) => {
220
+ const client = getClientFromCommand(cmd);
221
+ const result = await client.get("/connectors/connections", {
222
+ scope: resolveScope(opts.scope)
223
+ });
224
+ formatOutput(result, getFormat(cmd));
225
+ });
226
+ connectors.command("connect").description("Start an OAuth flow and return the authorization URL to open").requiredOption("--provider <provider>", "connector provider (gmail or outlook)").option("--scope <scope>", "connection scope (tenant or actor)", "tenant").action(async (opts, cmd) => {
227
+ if (!PROVIDERS.includes(opts.provider)) {
228
+ throw new Error(`--provider must be one of: ${PROVIDERS.join(", ")}`);
229
+ }
230
+ const client = getClientFromCommand(cmd);
231
+ const result = await client.post("/connectors/auth/start", {
232
+ provider: opts.provider,
233
+ scope: resolveScope(opts.scope)
234
+ });
235
+ formatOutput(result, getFormat(cmd));
236
+ });
237
+ connectors.command("disconnect").description("Disconnect (delete) a connector connection").argument("<id>", "connection ID").option("--yes", "disconnect without confirmation").action(async (id, opts, cmd) => {
238
+ if (!opts.yes) {
239
+ throw new Error('Disconnecting a connector is explicit. Re-run with "--yes" to confirm.');
240
+ }
241
+ const client = getClientFromCommand(cmd);
242
+ await client.delete(`/connectors/connections/${id}`);
243
+ process.stdout.write(`${chalk3.green("\u2713")} Connector connection ${id} disconnected.
244
+ `);
245
+ });
246
+ }
247
+
211
248
  // src/commands/documents.ts
212
249
  function registerDocumentsCommand(program) {
213
250
  const documents = program.command("documents").description("Manage documents");
@@ -304,7 +341,7 @@ function registerFoldersCommand(program) {
304
341
  }
305
342
 
306
343
  // src/commands/keys.ts
307
- import chalk3 from "chalk";
344
+ import chalk4 from "chalk";
308
345
  function registerKeysCommand(program) {
309
346
  const keys = program.command("keys").description("Manage Standards API keys");
310
347
  keys.command("list").description("List API keys").action(async (_opts, cmd) => {
@@ -331,7 +368,7 @@ function registerKeysCommand(program) {
331
368
  }
332
369
  const client = getClientFromCommand(cmd);
333
370
  await client.delete(`/api-keys/${id}`);
334
- process.stdout.write(`${chalk3.green("\u2713")} API key ${id} revoked.
371
+ process.stdout.write(`${chalk4.green("\u2713")} API key ${id} revoked.
335
372
  `);
336
373
  });
337
374
  }
@@ -416,7 +453,7 @@ function registerRecordsCommand(program) {
416
453
  // src/commands/root.ts
417
454
  import { stdin as input, stdout as output } from "process";
418
455
  import { createInterface } from "readline/promises";
419
- import chalk4 from "chalk";
456
+ import chalk5 from "chalk";
420
457
 
421
458
  // src/config.ts
422
459
  import { mkdir, readFile as readFile3, rm, writeFile } from "fs/promises";
@@ -556,7 +593,7 @@ function registerRootCommands(program) {
556
593
  await client.get("/api-keys");
557
594
  await upsertProfile({ name: opts.name, apiUrl: opts.url, apiKey });
558
595
  process.stdout.write(
559
- `${chalk4.green("\u2713")} Standards instance "${opts.name}" saved and selected.
596
+ `${chalk5.green("\u2713")} Standards instance "${opts.name}" saved and selected.
560
597
  `
561
598
  );
562
599
  process.stdout.write(` API URL: ${opts.url}
@@ -568,7 +605,7 @@ function registerRootCommands(program) {
568
605
  });
569
606
  program.command("use").description("Select the active Standards instance").argument("<name>", "instance name").action(async (name) => {
570
607
  await setCurrentProfile(name);
571
- process.stdout.write(`${chalk4.green("\u2713")} Standards instance "${name}" selected.
608
+ process.stdout.write(`${chalk5.green("\u2713")} Standards instance "${name}" selected.
572
609
  `);
573
610
  });
574
611
  program.command("instances").description("List configured Standards instances").action(async (_opts, cmd) => {
@@ -587,7 +624,7 @@ function registerRootCommands(program) {
587
624
  });
588
625
  program.command("logout").description("Remove a Standards instance from local CLI config").argument("[name]", "instance name, defaults to current").action(async (name) => {
589
626
  await removeProfile(name);
590
- process.stdout.write(`${chalk4.green("\u2713")} Standards instance removed.
627
+ process.stdout.write(`${chalk5.green("\u2713")} Standards instance removed.
591
628
  `);
592
629
  });
593
630
  }
@@ -597,7 +634,7 @@ import { createHash } from "crypto";
597
634
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
598
635
  import { join as join2 } from "path";
599
636
  import { fileURLToPath } from "url";
600
- import chalk5 from "chalk";
637
+ import chalk6 from "chalk";
601
638
  function registerSchemaCommand(program) {
602
639
  const schema = program.command("schema").description("Inspect schema objects and attributes");
603
640
  schema.command("list").description("List all schema objects").action(async (_opts, cmd) => {
@@ -624,7 +661,7 @@ function registerSchemaCommand(program) {
624
661
  const result = await fetchDrift(getClientFromCommand(cmd), opts.object);
625
662
  const totalDrift = result.summary.totalCustomObjects + result.summary.totalCustomAttributes;
626
663
  if (totalDrift === 0) {
627
- console.info(chalk5.green("\u2713 No drift detected \u2014 nothing to pull."));
664
+ console.info(chalk6.green("\u2713 No drift detected \u2014 nothing to pull."));
628
665
  process.exit(0);
629
666
  }
630
667
  const globalOpts = cmd.optsWithGlobals();
@@ -632,7 +669,7 @@ function registerSchemaCommand(program) {
632
669
  const shouldSave = opts.save !== false;
633
670
  if (opts.output) {
634
671
  writeFileSync(opts.output, prompt, "utf-8");
635
- console.info(chalk5.green(`\u2713 Prompt written to ${opts.output}`));
672
+ console.info(chalk6.green(`\u2713 Prompt written to ${opts.output}`));
636
673
  return;
637
674
  }
638
675
  if (shouldSave) {
@@ -646,8 +683,8 @@ function registerSchemaCommand(program) {
646
683
  const filename = join2(pullsDir, `${date}-${hash}.md`);
647
684
  writeFileSync(filename, prompt, "utf-8");
648
685
  writeFileSync(join2(diffDir, "latest.json"), JSON.stringify(result, null, 2), "utf-8");
649
- console.info(chalk5.green(`\u2713 Pull prompt written to ${filename}`));
650
- console.info(chalk5.dim(" Copy-paste its contents into your LLM to resolve the drift."));
686
+ console.info(chalk6.green(`\u2713 Pull prompt written to ${filename}`));
687
+ console.info(chalk6.dim(" Copy-paste its contents into your LLM to resolve the drift."));
651
688
  } else {
652
689
  process.stdout.write(prompt);
653
690
  }
@@ -662,46 +699,46 @@ var attrInline = (attr) => {
662
699
  function printDiffOutput(result) {
663
700
  const lines = [];
664
701
  for (const obj of result.customObjects) {
665
- lines.push(chalk5.yellow(`\u26A0 ${obj.name} (${obj.label}) \u2014 custom object, not in code`));
666
- lines.push(chalk5.dim(' \u2192 Run "standards pull" to promote or leave.'));
702
+ lines.push(chalk6.yellow(`\u26A0 ${obj.name} (${obj.label}) \u2014 custom object, not in code`));
703
+ lines.push(chalk6.dim(' \u2192 Run "standards pull" to promote or leave.'));
667
704
  }
668
705
  for (const entry of result.systemObjectDrift) {
669
706
  const unexpected = entry.sealed ? entry.customAttributes.filter((a) => !a.tolerated) : [];
670
707
  const tolerated = entry.customAttributes.filter((a) => a.tolerated);
671
708
  if (entry.sealed && unexpected.length > 0) {
672
709
  lines.push(
673
- chalk5.red(
710
+ chalk6.red(
674
711
  `\u2717 ${entry.objectName} \u2014 ${unexpected.length} unexpected custom attribute(s) (sealed object)`
675
712
  )
676
713
  );
677
- for (const attr of unexpected) lines.push(chalk5.red(attrInline(attr)));
678
- lines.push(chalk5.dim(' \u2192 Run "standards pull" to promote or tolerate these attributes.'));
714
+ for (const attr of unexpected) lines.push(chalk6.red(attrInline(attr)));
715
+ lines.push(chalk6.dim(' \u2192 Run "standards pull" to promote or tolerate these attributes.'));
679
716
  if (tolerated.length > 0) {
680
- lines.push(chalk5.dim(` Also tolerated: ${tolerated.length} attribute(s)`));
681
- for (const attr of tolerated) lines.push(chalk5.dim(attrInline(attr)));
717
+ lines.push(chalk6.dim(` Also tolerated: ${tolerated.length} attribute(s)`));
718
+ for (const attr of tolerated) lines.push(chalk6.dim(attrInline(attr)));
682
719
  }
683
720
  continue;
684
721
  }
685
722
  const okAttrs = entry.sealed ? tolerated : entry.customAttributes;
686
723
  if (okAttrs.length === 0) continue;
687
724
  const okSuffix = entry.sealed ? "tolerated custom attribute(s) (sealed)" : "custom attribute(s) (extensible)";
688
- lines.push(chalk5.green(`\u2713 ${entry.objectName} \u2014 ${okAttrs.length} ${okSuffix}`));
689
- for (const attr of okAttrs) lines.push(chalk5.dim(attrInline(attr)));
725
+ lines.push(chalk6.green(`\u2713 ${entry.objectName} \u2014 ${okAttrs.length} ${okSuffix}`));
726
+ for (const attr of okAttrs) lines.push(chalk6.dim(attrInline(attr)));
690
727
  }
691
728
  if (lines.length === 0) {
692
- console.info(chalk5.green("\u2713 No drift detected."));
729
+ console.info(chalk6.green("\u2713 No drift detected."));
693
730
  return;
694
731
  }
695
732
  console.info(lines.join("\n"));
696
733
  if (result.hasUnexpectedDrift) {
697
734
  console.info(
698
- chalk5.red(
735
+ chalk6.red(
699
736
  `
700
737
  \u2717 Unexpected drift: ${result.summary.totalUnexpected} attribute(s) on sealed object(s).`
701
738
  )
702
739
  );
703
740
  } else {
704
- console.info(chalk5.green("\n\u2713 No unexpected drift."));
741
+ console.info(chalk6.green("\n\u2713 No unexpected drift."));
705
742
  }
706
743
  }
707
744
  function resolveStandardsDir() {
@@ -820,6 +857,7 @@ function createProgram() {
820
857
  registerKeysCommand(program);
821
858
  registerAuthCommand(program);
822
859
  registerAutofillCommand(program);
860
+ registerConnectorsCommand(program);
823
861
  program.hook("preAction", async (_thisCommand, actionCommand) => {
824
862
  const raw = program.opts();
825
863
  const resolved = await resolveCliConfig({
@@ -833,7 +871,7 @@ function createProgram() {
833
871
  program.setOptionValue("tenant", raw.tenant);
834
872
  if (!(resolved.apiKey || isPublicCommand(actionCommand))) {
835
873
  console.error(
836
- chalk6.red(
874
+ chalk7.red(
837
875
  `\u2717 Error: No Standards instance configured. Run "standards login" or pass --api-key.`
838
876
  )
839
877
  );
@@ -847,12 +885,12 @@ async function runProgram(argv = process.argv) {
847
885
  await program.parseAsync(argv).catch((error) => {
848
886
  if (error instanceof ApiClientError) {
849
887
  if (error.statusCode > 0) {
850
- console.error(chalk6.red(`\u2717 Error (${error.statusCode}): ${error.message}`));
888
+ console.error(chalk7.red(`\u2717 Error (${error.statusCode}): ${error.message}`));
851
889
  } else {
852
- console.error(chalk6.red(`\u2717 Error: ${error.message}`));
890
+ console.error(chalk7.red(`\u2717 Error: ${error.message}`));
853
891
  }
854
892
  } else if (error instanceof Error) {
855
- console.error(chalk6.red(`\u2717 Error: ${error.message}`));
893
+ console.error(chalk7.red(`\u2717 Error: ${error.message}`));
856
894
  }
857
895
  process.exit(1);
858
896
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stndrds/cli",
3
- "version": "1.0.0-alpha.227",
3
+ "version": "1.0.0-alpha.228",
4
4
  "description": "CLI tool to interact with Standards API",
5
5
  "type": "module",
6
6
  "bin": {