@arbium/enterprise-agent-connect-client 0.1.1 → 0.1.2-dev.75145ef

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/lib/steps.js CHANGED
@@ -37,10 +37,13 @@ export const askedFields = (fields, values) => {
37
37
  const chosen = choiceValues({ fields }, values);
38
38
  return fields.filter((f) => isChosen(f.requires, chosen));
39
39
  };
40
- /** The steps that apply under the chosen options (a step with `option` only while chosen). */
41
- export function chosenSteps(connector, steps, values) {
40
+ /** The steps that apply under the chosen options (a step with `option` only while chosen)
41
+ * and, given `ticked`, the ticked capabilities (a step with `capabilities` only while one of
42
+ * them is). */
43
+ export function chosenSteps(connector, steps, values, ticked) {
42
44
  const chosen = choiceValues(connector, values);
43
- return steps.filter((s) => isChosen(s.option, chosen));
45
+ return steps.filter((s) => isChosen(s.option, chosen) &&
46
+ (!ticked || !s.capabilities || s.capabilities.some((c) => ticked.includes(c))));
44
47
  }
45
48
  /** Choices that change the permissions the setup steps ask for: made in step 1, with what
46
49
  * agents may do, so the steps after it already show those permissions. */
@@ -83,9 +86,15 @@ export function keysUsing(agents, connectorId) {
83
86
  }
84
87
  /** The values a connected app reported for its discover probe, e.g. Jira project keys. */
85
88
  export function discovered(connector, checks) {
89
+ return discoveredChoices(connector, checks).map((c) => c.value);
90
+ }
91
+ /** The same, each with the label to show for it (the value itself when the app gave none),
92
+ * e.g. a NetSuite subsidiary's name for its id. */
93
+ export function discoveredChoices(connector, checks) {
86
94
  if (!connector.discover || !checks)
87
95
  return [];
88
- return checks.find((c) => c.label === connector.discover.label)?.values ?? [];
96
+ const check = checks.find((c) => c.label === connector.discover.label);
97
+ return (check?.values ?? []).map((value) => ({ value, label: check?.labels?.[value] ?? value }));
89
98
  }
90
99
  /** Parses free-typed list input ("KAN, SAM1") into values. */
91
100
  export function splitList(raw) {
@@ -505,8 +514,8 @@ const numbered = (ns) => ns.length === 1
505
514
  : `steps ${ns.slice(0, -1).join(", ")} and ${ns[ns.length - 1]}`;
506
515
  export function appSteps(input) {
507
516
  const { connector, connection, health, ceiling, marks } = input;
508
- const setup = chosenSteps(connector, connector.setup, input.choices ?? {});
509
- const afterConnect = chosenSteps(connector, connector.afterConnect, input.choices ?? {});
517
+ const setup = chosenSteps(connector, connector.setup, input.choices ?? {}, ceiling);
518
+ const afterConnect = chosenSteps(connector, connector.afterConnect, input.choices ?? {}, ceiling);
510
519
  const on = connection !== null;
511
520
  const changed = on && connection.capabilities.join(",") !== ceiling.join(",");
512
521
  const before = input.providerReady ? {} : { locked: true };
package/lib/types.d.ts CHANGED
@@ -39,13 +39,19 @@ export type InstallTarget = S["InstallTarget"];
39
39
  export type TeamsTrigger = S["TeamsTrigger"];
40
40
  export type TeamsTriggerInput = Body<"setTeamsTrigger">;
41
41
  export type TeamsRun = S["TeamsRun"];
42
+ export type EventSubscription = S["EventSubscription"];
43
+ export type EventSubscriptionInput = Body<"subscribeEvents">;
44
+ export type EventSubscribed = S["EventSubscribed"];
45
+ export type EventTrigger = S["EventTrigger"];
46
+ export type EventTriggerInput = Body<"setEventTrigger">;
47
+ export type EventRun = S["EventRun"];
42
48
  export type ClaudeKey = S["ClaudeKey"];
43
49
  export type ClaudeAgent = S["ClaudeAgent"];
44
50
  export type Step = Connector["setup"][number];
45
51
  export type AgentStep = Provider["addAgent"][number];
46
52
  export type Setting = NonNullable<Step["settings"]>[number];
47
53
  export type ChosenOption = NonNullable<Step["option"]>;
48
- /** A connect form field; a provider's may be left empty (`optional`). */
54
+ /** A connect form field; an `optional` one may be left empty. */
49
55
  export type Field = Connector["fields"][number] & {
50
56
  optional?: boolean;
51
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbium/enterprise-agent-connect-client",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-dev.75145ef",
4
4
  "description": "Typed client for the Agent Connect admin API (v1), and the pure logic admin pages share",
5
5
  "type": "module",
6
6
  "exports": {