@corsair-dev/cli 0.1.17 → 0.1.19

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/index.js CHANGED
@@ -1882,6 +1882,7 @@ async function ensureIntegration(database, pluginId, kek) {
1882
1882
  const encryptedDek = await encryptDEK(dek, kek);
1883
1883
  const row = await orm.integrations.create({
1884
1884
  name: pluginId,
1885
+ config: {},
1885
1886
  dek: encryptedDek
1886
1887
  });
1887
1888
  return { id: row.id };
@@ -1898,6 +1899,7 @@ async function ensureAccount(database, integrationId, tenantId, kek) {
1898
1899
  await orm.accounts.create({
1899
1900
  tenant_id: tenantId,
1900
1901
  integration_id: integrationId,
1902
+ config: {},
1901
1903
  dek: encryptedDek
1902
1904
  });
1903
1905
  }
@@ -2354,7 +2356,7 @@ import { fileURLToPath } from "url";
2354
2356
  import { Command } from "commander";
2355
2357
 
2356
2358
  // package.json
2357
- var version = "0.1.17";
2359
+ var version = "0.1.19";
2358
2360
 
2359
2361
  // src/utils/subscription.ts
2360
2362
  async function runWebhookSubscription(cwd, pluginId) {
@@ -2405,8 +2407,12 @@ var BaseCommand = class {
2405
2407
  getSubCommands() {
2406
2408
  return [];
2407
2409
  }
2410
+ /** When true, unknown flags (e.g. `--slack`) are passed through to the action. */
2411
+ allowUnknownOptions() {
2412
+ return false;
2413
+ }
2408
2414
  prepare = (program) => {
2409
- const command = program.command(this.getName()).description(this.getDescription());
2415
+ const command = program.command(this.getName()).description(this.getDescription()).allowUnknownOption(this.allowUnknownOptions());
2410
2416
  const usage = this.getUsage();
2411
2417
  if (usage) {
2412
2418
  command.usage(usage);
@@ -2622,9 +2628,80 @@ var ScriptCommand = class extends BaseCommand {
2622
2628
  };
2623
2629
 
2624
2630
  // src/commands/setup.command.ts
2625
- init_corsair_instance();
2626
2631
  import { setupCorsair } from "corsair";
2632
+
2633
+ // src/lib/setup-credentials.ts
2634
+ var SETUP_FLAGS_WITH_VALUE = /* @__PURE__ */ new Set(["--tenant", "-t", "--plugin", "-p"]);
2635
+ function parseSetupCredentials(rawArgs, pluginIds) {
2636
+ const pluginSet = new Set(pluginIds);
2637
+ const result = {};
2638
+ let currentPlugin = null;
2639
+ for (let i = 0; i < rawArgs.length; i++) {
2640
+ const arg = rawArgs[i];
2641
+ if (arg === "--backfill" || arg === "-b" || arg === "-backfill") {
2642
+ continue;
2643
+ }
2644
+ if (SETUP_FLAGS_WITH_VALUE.has(arg)) {
2645
+ const value2 = rawArgs[++i];
2646
+ if (arg === "--plugin" || arg === "-p") {
2647
+ if (value2 && pluginSet.has(value2)) {
2648
+ currentPlugin = value2;
2649
+ result[value2] ??= {};
2650
+ }
2651
+ }
2652
+ continue;
2653
+ }
2654
+ if (arg.startsWith("--tenant=") || arg.startsWith("-t=")) {
2655
+ continue;
2656
+ }
2657
+ if (arg.startsWith("--plugin=")) {
2658
+ const pluginId = arg.slice("--plugin=".length);
2659
+ if (pluginSet.has(pluginId)) {
2660
+ currentPlugin = pluginId;
2661
+ result[pluginId] ??= {};
2662
+ }
2663
+ continue;
2664
+ }
2665
+ if (arg.startsWith("--")) {
2666
+ const flagBody = arg.slice(2);
2667
+ const eqIdx2 = flagBody.indexOf("=");
2668
+ if (eqIdx2 > 0) {
2669
+ const name = flagBody.slice(0, eqIdx2);
2670
+ const value2 = flagBody.slice(eqIdx2 + 1);
2671
+ if (name === "plugin" && pluginSet.has(value2)) {
2672
+ currentPlugin = value2;
2673
+ result[value2] ??= {};
2674
+ }
2675
+ continue;
2676
+ }
2677
+ if (pluginSet.has(flagBody)) {
2678
+ currentPlugin = flagBody;
2679
+ result[flagBody] ??= {};
2680
+ }
2681
+ continue;
2682
+ }
2683
+ const eqIdx = arg.indexOf("=");
2684
+ if (eqIdx <= 0) continue;
2685
+ const field = arg.slice(0, eqIdx);
2686
+ const value = arg.slice(eqIdx + 1);
2687
+ if (!field || !value || !currentPlugin) continue;
2688
+ const bucket = result[currentPlugin] ??= {};
2689
+ bucket[field] = value;
2690
+ }
2691
+ return result;
2692
+ }
2693
+ function getSetupRawArgs(argv = process.argv) {
2694
+ const setupIdx = argv.indexOf("setup");
2695
+ return setupIdx >= 0 ? argv.slice(setupIdx + 1) : [];
2696
+ }
2697
+
2698
+ // src/commands/setup.command.ts
2699
+ init_corsair();
2700
+ init_corsair_instance();
2627
2701
  var SetupCommand = class extends BaseCommand {
2702
+ allowUnknownOptions() {
2703
+ return true;
2704
+ }
2628
2705
  getName() {
2629
2706
  return "setup";
2630
2707
  }
@@ -2663,9 +2740,15 @@ var SetupCommand = class extends BaseCommand {
2663
2740
  const backfill = options.backfill || this.hasLegacyBackfillFlag();
2664
2741
  const tenantId = options.tenant;
2665
2742
  const instance = await getCorsairInstance({ cwd });
2743
+ const internal = await extractInternalConfig(cwd);
2744
+ const credentials = parseSetupCredentials(
2745
+ getSetupRawArgs(),
2746
+ internal.plugins.map((p13) => p13.id)
2747
+ );
2666
2748
  await setupCorsair(instance, {
2667
2749
  backfill,
2668
2750
  tenantId,
2751
+ credentials,
2669
2752
  caller: "cli"
2670
2753
  });
2671
2754
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AA0pBA,wBAAsB,OAAO,CAAC,EAC7B,GAAG,EACH,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,eAAuB,EACpC,MAAM,EAAE,UAAkB,EAC1B,OAAO,EAAE,WAAmB,EAC5B,SAAS,GACT,EAAE;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iFAAiF;IACjF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgJhB"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AA4pBA,wBAAsB,OAAO,CAAC,EAC7B,GAAG,EACH,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,eAAuB,EACpC,MAAM,EAAE,UAAkB,EAC1B,OAAO,EAAE,WAAmB,EAC5B,SAAS,GACT,EAAE;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iFAAiF;IACjF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgJhB"}
@@ -9,6 +9,8 @@ export default abstract class BaseCommand {
9
9
  getOptions(): CommandOption[];
10
10
  getUsage(): string;
11
11
  getSubCommands(): BaseCommand[];
12
+ /** When true, unknown flags (e.g. `--slack`) are passed through to the action. */
13
+ protected allowUnknownOptions(): boolean;
12
14
  readonly prepare: (program: Command) => void;
13
15
  }
14
16
  //# sourceMappingURL=base.command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.command.d.ts","sourceRoot":"","sources":["../../../src/commands/base.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,WAAW;IACxC,QAAQ,CAAC,OAAO,IAAI,MAAM;IAE1B,QAAQ,CAAC,cAAc,IAAI,MAAM;IAEjC,MAAM,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAEnD,UAAU,IAAI,MAAM,EAAE;IAItB,YAAY,IAAI,eAAe,EAAE;IAIjC,UAAU,IAAI,aAAa,EAAE;IAI7B,QAAQ,IAAI,MAAM;IAIlB,cAAc,IAAI,WAAW,EAAE;IAI/B,QAAQ,CAAC,OAAO,GAAI,SAAS,OAAO,KAAG,IAAI,CAuCzC;CACF"}
1
+ {"version":3,"file":"base.command.d.ts","sourceRoot":"","sources":["../../../src/commands/base.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,WAAW;IACxC,QAAQ,CAAC,OAAO,IAAI,MAAM;IAE1B,QAAQ,CAAC,cAAc,IAAI,MAAM;IAEjC,MAAM,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAEnD,UAAU,IAAI,MAAM,EAAE;IAItB,YAAY,IAAI,eAAe,EAAE;IAIjC,UAAU,IAAI,aAAa,EAAE;IAI7B,QAAQ,IAAI,MAAM;IAIlB,cAAc,IAAI,WAAW,EAAE;IAI/B,kFAAkF;IAClF,SAAS,CAAC,mBAAmB,IAAI,OAAO;IAIxC,QAAQ,CAAC,OAAO,GAAI,SAAS,OAAO,KAAG,IAAI,CAwCzC;CACF"}
@@ -1,6 +1,7 @@
1
1
  import type { CommandActionData, CommandArgument, CommandOption } from '../index.types';
2
2
  import BaseCommand from './base.command';
3
3
  export default class SetupCommand extends BaseCommand {
4
+ protected allowUnknownOptions(): boolean;
4
5
  getName(): string;
5
6
  getDescription(): string;
6
7
  getOptions(): CommandOption[];
@@ -1 +1 @@
1
- {"version":3,"file":"setup.command.d.ts","sourceRoot":"","sources":["../../../src/commands/setup.command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IACpD,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIxB,UAAU,IAAI,aAAa,EAAE;IAoB7B,YAAY,IAAI,eAAe,EAAE;IAS3B,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,iBAAiB;IAa3C,OAAO,CAAC,qBAAqB;CAK7B"}
1
+ {"version":3,"file":"setup.command.d.ts","sourceRoot":"","sources":["../../../src/commands/setup.command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,MAAM,gBAAgB,CAAC;AAOxB,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IACpD,SAAS,CAAC,mBAAmB,IAAI,OAAO;IAIxC,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIxB,UAAU,IAAI,aAAa,EAAE;IAoB7B,YAAY,IAAI,eAAe,EAAE;IAS3B,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,iBAAiB;IAmB3C,OAAO,CAAC,qBAAqB;CAK7B"}
@@ -0,0 +1,8 @@
1
+ import type { SetupCredentials } from 'corsair/setup';
2
+ /**
3
+ * Parses `corsair setup --<plugin> field=value ...` from argv (after "setup").
4
+ * Supports `--plugin=<id>`, `--plugin <id>`, and `--<pluginId>` plugin selectors.
5
+ */
6
+ export declare function parseSetupCredentials(rawArgs: readonly string[], pluginIds: readonly string[]): SetupCredentials;
7
+ export declare function getSetupRawArgs(argv?: string[]): string[];
8
+ //# sourceMappingURL=setup-credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-credentials.d.ts","sourceRoot":"","sources":["../../../src/lib/setup-credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,SAAS,EAAE,SAAS,MAAM,EAAE,GAC1B,gBAAgB,CAmElB;AAED,wBAAgB,eAAe,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,MAAM,EAAE,CAGvE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corsair-dev/cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "c12": "^3.3.3",
25
25
  "commander": "^14.0.3",
26
26
  "zod": "^4.1.13",
27
- "corsair": "0.1.72"
27
+ "corsair": "0.1.74"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/jest": "^29.5.14",