@arbium/enterprise-agent-connect-client 0.1.2-dev.d2aa5ca → 0.2.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/lib/index.d.ts CHANGED
@@ -115,6 +115,7 @@ export declare function createClient(options: ClientOptions): {
115
115
  field: string;
116
116
  value: string;
117
117
  };
118
+ capabilities?: string[];
118
119
  }[];
119
120
  afterConnect: {
120
121
  title: string;
@@ -144,6 +145,7 @@ export declare function createClient(options: ClientOptions): {
144
145
  field: string;
145
146
  value: string;
146
147
  };
148
+ capabilities?: string[];
147
149
  }[];
148
150
  fields: {
149
151
  id: string;
@@ -161,6 +163,7 @@ export declare function createClient(options: ClientOptions): {
161
163
  field: string;
162
164
  value: string;
163
165
  };
166
+ optional: boolean;
164
167
  }[];
165
168
  capabilities: {
166
169
  id: string;
@@ -244,6 +247,7 @@ export declare function createClient(options: ClientOptions): {
244
247
  path: string;
245
248
  label: string;
246
249
  show: string;
250
+ name?: string;
247
251
  match?: {
248
252
  [key: string]: string | number | boolean;
249
253
  };
@@ -261,6 +265,7 @@ export declare function createClient(options: ClientOptions): {
261
265
  path: string;
262
266
  label: string;
263
267
  show: string;
268
+ name?: string;
264
269
  match?: {
265
270
  [key: string]: string | number | boolean;
266
271
  };
@@ -616,7 +621,7 @@ export declare function createClient(options: ClientOptions): {
616
621
  deliveryId: string[];
617
622
  types: {
618
623
  type: string;
619
- same?: [string, string];
624
+ since?: string;
620
625
  }[];
621
626
  };
622
627
  };
package/lib/index.js CHANGED
@@ -197,7 +197,7 @@ export function createClient(options) {
197
197
  async appStates(o, connectors, connections) {
198
198
  const apps = connectors.map((connector) => {
199
199
  const connection = connections.find((c) => c.connectorId === connector.id) ?? null;
200
- const liveSteps = chosenSteps(connector, [...connector.setup, ...connector.afterConnect], connection?.config ?? {}).filter((s) => s.live);
200
+ const liveSteps = chosenSteps(connector, [...connector.setup, ...connector.afterConnect], connection?.config ?? {}, connection?.capabilities ?? []).filter((s) => s.live);
201
201
  return { connector, connection, liveSteps };
202
202
  });
203
203
  const liveSteps = apps.flatMap((a) => a.liveSteps);
package/lib/schema.d.ts CHANGED
@@ -965,6 +965,9 @@ export interface components {
965
965
  label: string;
966
966
  values: string[];
967
967
  warning?: string;
968
+ labels?: {
969
+ [key: string]: string;
970
+ };
968
971
  };
969
972
  CheckOutcome: {
970
973
  /** @constant */
@@ -1069,6 +1072,7 @@ export interface components {
1069
1072
  field: string;
1070
1073
  value: string;
1071
1074
  };
1075
+ capabilities?: string[];
1072
1076
  }[];
1073
1077
  afterConnect: {
1074
1078
  title: string;
@@ -1102,6 +1106,7 @@ export interface components {
1102
1106
  field: string;
1103
1107
  value: string;
1104
1108
  };
1109
+ capabilities?: string[];
1105
1110
  }[];
1106
1111
  fields: {
1107
1112
  id: string;
@@ -1119,6 +1124,8 @@ export interface components {
1119
1124
  field: string;
1120
1125
  value: string;
1121
1126
  };
1127
+ /** @default false */
1128
+ optional: boolean;
1122
1129
  }[];
1123
1130
  capabilities: {
1124
1131
  id: string;
@@ -1216,6 +1223,7 @@ export interface components {
1216
1223
  path: string;
1217
1224
  label: string;
1218
1225
  show: string;
1226
+ name?: string;
1219
1227
  match?: {
1220
1228
  [key: string]: string | number | boolean;
1221
1229
  };
@@ -1235,6 +1243,7 @@ export interface components {
1235
1243
  path: string;
1236
1244
  label: string;
1237
1245
  show: string;
1246
+ name?: string;
1238
1247
  match?: {
1239
1248
  [key: string]: string | number | boolean;
1240
1249
  };
@@ -1690,10 +1699,7 @@ export interface components {
1690
1699
  deliveryId: string[];
1691
1700
  types: {
1692
1701
  type: string;
1693
- same?: [
1694
- string,
1695
- string
1696
- ];
1702
+ since?: string;
1697
1703
  }[];
1698
1704
  };
1699
1705
  };
package/lib/steps.d.ts CHANGED
@@ -17,8 +17,10 @@ export declare function choiceValues(connector: {
17
17
  export declare const isChosen: (option: ChosenOption | undefined, chosen: Record<string, string>) => boolean;
18
18
  /** The choice fields shown: one that `requires` an earlier choice only while it is made. */
19
19
  export declare const askedFields: (fields: Field[], values: Record<string, string>) => Field[];
20
- /** The steps that apply under the chosen options (a step with `option` only while chosen). */
21
- export declare function chosenSteps(connector: Connector, steps: Step[], values: Record<string, string>): Step[];
20
+ /** The steps that apply under the chosen options (a step with `option` only while chosen)
21
+ * and, given `ticked`, the ticked capabilities (a step with `capabilities` only while one of
22
+ * them is). */
23
+ export declare function chosenSteps(connector: Connector, steps: Step[], values: Record<string, string>, ticked?: readonly string[]): Step[];
22
24
  /** Choices that change the permissions the setup steps ask for: made in step 1, with what
23
25
  * agents may do, so the steps after it already show those permissions. */
24
26
  export declare function permissionChoices(connector: Connector): Field[];
@@ -39,6 +41,12 @@ export declare function keyApps(agent: Agent, connectors: Connector[]): Connecto
39
41
  export declare function keysUsing(agents: Agent[], connectorId: string): number;
40
42
  /** The values a connected app reported for its discover probe, e.g. Jira project keys. */
41
43
  export declare function discovered(connector: Connector, checks: Check[] | null): string[];
44
+ /** The same, each with the label to show for it (the value itself when the app gave none),
45
+ * e.g. a NetSuite subsidiary's name for its id. */
46
+ export declare function discoveredChoices(connector: Connector, checks: Check[] | null): {
47
+ value: string;
48
+ label: string;
49
+ }[];
42
50
  /** Parses free-typed list input ("KAN, SAM1") into values. */
43
51
  export declare function splitList(raw: string): string[];
44
52
  /** Shown under Click through for a step the vendor offers only as commands. */
@@ -211,6 +219,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
211
219
  field: string;
212
220
  value: string;
213
221
  };
222
+ capabilities?: string[];
214
223
  }[];
215
224
  afterConnect: {
216
225
  title: string;
@@ -240,6 +249,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
240
249
  field: string;
241
250
  value: string;
242
251
  };
252
+ capabilities?: string[];
243
253
  }[];
244
254
  fields: {
245
255
  id: string;
@@ -257,6 +267,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
257
267
  field: string;
258
268
  value: string;
259
269
  };
270
+ optional: boolean;
260
271
  }[];
261
272
  capabilities: {
262
273
  id: string;
@@ -340,13 +351,18 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
340
351
  path: string;
341
352
  label: string;
342
353
  show: string;
354
+ name?: string;
343
355
  match?: {
344
356
  [key: string]: string | number | boolean;
345
357
  };
346
358
  body?: {
347
359
  [key: string]: unknown;
348
360
  };
349
- ifEmpty?: string;
361
+ ifEmpty
362
+ /** A step whose text fills in a value saved at another step waits until it is saved: its
363
+ * words would show the raw {name} and its commands would not run. */
364
+ ? /** A step whose text fills in a value saved at another step waits until it is saved: its
365
+ * words would show the raw {name} and its commands would not run. */: string;
350
366
  } | {
351
367
  label: string;
352
368
  check: string;
@@ -357,6 +373,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
357
373
  path: string;
358
374
  label: string;
359
375
  show: string;
376
+ name?: string;
360
377
  match?: {
361
378
  [key: string]: string | number | boolean;
362
379
  };
@@ -712,7 +729,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
712
729
  deliveryId: string[];
713
730
  types: {
714
731
  type: string;
715
- same?: [string, string];
732
+ since?: string;
716
733
  }[];
717
734
  };
718
735
  };
@@ -790,6 +807,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
790
807
  field: string;
791
808
  value: string;
792
809
  };
810
+ capabilities?: string[];
793
811
  }[];
794
812
  afterConnect: {
795
813
  title: string;
@@ -819,6 +837,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
819
837
  field: string;
820
838
  value: string;
821
839
  };
840
+ capabilities?: string[];
822
841
  }[];
823
842
  fields: {
824
843
  id: string;
@@ -836,6 +855,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
836
855
  field: string;
837
856
  value: string;
838
857
  };
858
+ optional: boolean;
839
859
  }[];
840
860
  capabilities: {
841
861
  id: string;
@@ -919,13 +939,18 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
919
939
  path: string;
920
940
  label: string;
921
941
  show: string;
942
+ name?: string;
922
943
  match?: {
923
944
  [key: string]: string | number | boolean;
924
945
  };
925
946
  body?: {
926
947
  [key: string]: unknown;
927
948
  };
928
- ifEmpty?: string;
949
+ ifEmpty
950
+ /** A step whose text fills in a value saved at another step waits until it is saved: its
951
+ * words would show the raw {name} and its commands would not run. */
952
+ ? /** A step whose text fills in a value saved at another step waits until it is saved: its
953
+ * words would show the raw {name} and its commands would not run. */: string;
929
954
  } | {
930
955
  label: string;
931
956
  check: string;
@@ -936,6 +961,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
936
961
  path: string;
937
962
  label: string;
938
963
  show: string;
964
+ name?: string;
939
965
  match?: {
940
966
  [key: string]: string | number | boolean;
941
967
  };
@@ -1291,7 +1317,7 @@ export declare function newKeySetup(ticked: Connector[], providers: Provider[]):
1291
1317
  deliveryId: string[];
1292
1318
  types: {
1293
1319
  type: string;
1294
- same?: [string, string];
1320
+ since?: string;
1295
1321
  }[];
1296
1322
  };
1297
1323
  };
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
@@ -51,7 +51,7 @@ export type Step = Connector["setup"][number];
51
51
  export type AgentStep = Provider["addAgent"][number];
52
52
  export type Setting = NonNullable<Step["settings"]>[number];
53
53
  export type ChosenOption = NonNullable<Step["option"]>;
54
- /** A connect form field; a provider's may be left empty (`optional`). */
54
+ /** A connect form field; an `optional` one may be left empty. */
55
55
  export type Field = Connector["fields"][number] & {
56
56
  optional?: boolean;
57
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arbium/enterprise-agent-connect-client",
3
- "version": "0.1.2-dev.d2aa5ca",
3
+ "version": "0.2.0",
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": {