@arbium/enterprise-agent-connect 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.
Files changed (119) hide show
  1. package/README.md +9 -4
  2. package/dist/connectors/dynamics-365/connector.json +16 -1
  3. package/dist/connectors/dynamics-365/index.d.ts +1 -4
  4. package/dist/connectors/dynamics-365/index.js.map +1 -1
  5. package/dist/connectors/entra/index.d.ts +1 -1
  6. package/dist/connectors/gong/vendor.d.ts +1 -1
  7. package/dist/connectors/gong/vendor.js +24 -32
  8. package/dist/connectors/gong/vendor.js.map +1 -1
  9. package/dist/connectors/http/index.d.ts +2 -6
  10. package/dist/connectors/http/index.js +4 -1
  11. package/dist/connectors/http/index.js.map +1 -1
  12. package/dist/connectors/intune/index.d.ts +1 -1
  13. package/dist/connectors/jamf/vendor.js +5 -1
  14. package/dist/connectors/jamf/vendor.js.map +1 -1
  15. package/dist/connectors/jira/connector.json +3 -3
  16. package/dist/connectors/jira/vendor.d.ts +1 -1
  17. package/dist/connectors/jira/vendor.js +8 -2
  18. package/dist/connectors/jira/vendor.js.map +1 -1
  19. package/dist/connectors/microsoft/client.d.ts +11 -3
  20. package/dist/connectors/microsoft/client.js +62 -8
  21. package/dist/connectors/microsoft/client.js.map +1 -1
  22. package/dist/connectors/netsuite/connector.json +4 -2
  23. package/dist/connectors/netsuite/vendor.d.ts +1 -1
  24. package/dist/connectors/netsuite/vendor.js +5 -6
  25. package/dist/connectors/netsuite/vendor.js.map +1 -1
  26. package/dist/connectors/odata/index.d.ts +1 -4
  27. package/dist/connectors/odata/index.js.map +1 -1
  28. package/dist/connectors/okta/connector.json +3 -2
  29. package/dist/connectors/okta/vendor.d.ts +1 -1
  30. package/dist/connectors/okta/vendor.js +7 -6
  31. package/dist/connectors/okta/vendor.js.map +1 -1
  32. package/dist/connectors/outlook-calendar/index.d.ts +1 -1
  33. package/dist/connectors/outlook-mail/index.d.ts +1 -1
  34. package/dist/connectors/salesforce/vendor.d.ts +1 -1
  35. package/dist/connectors/salesforce/vendor.js +9 -3
  36. package/dist/connectors/salesforce/vendor.js.map +1 -1
  37. package/dist/connectors/sap-s4hana/connector.json +1 -0
  38. package/dist/connectors/servicenow/vendor.d.ts +0 -1
  39. package/dist/connectors/servicenow/vendor.js +7 -10
  40. package/dist/connectors/servicenow/vendor.js.map +1 -1
  41. package/dist/connectors/sharepoint-files/connector.json +34 -3
  42. package/dist/connectors/sharepoint-files/documents.d.ts +7 -0
  43. package/dist/connectors/sharepoint-files/documents.js +212 -0
  44. package/dist/connectors/sharepoint-files/documents.js.map +1 -0
  45. package/dist/connectors/sharepoint-files/docx-worker.d.ts +7 -0
  46. package/dist/connectors/sharepoint-files/docx-worker.js +41 -0
  47. package/dist/connectors/sharepoint-files/docx-worker.js.map +1 -0
  48. package/dist/connectors/sharepoint-files/docx.d.ts +96 -0
  49. package/dist/connectors/sharepoint-files/docx.js +823 -0
  50. package/dist/connectors/sharepoint-files/docx.js.map +1 -0
  51. package/dist/connectors/sharepoint-files/index.d.ts +1 -4
  52. package/dist/connectors/sharepoint-files/index.js +2 -1
  53. package/dist/connectors/sharepoint-files/index.js.map +1 -1
  54. package/dist/connectors/sharepoint-files/ooxml.d.ts +19 -0
  55. package/dist/connectors/sharepoint-files/ooxml.js +179 -0
  56. package/dist/connectors/sharepoint-files/ooxml.js.map +1 -0
  57. package/dist/connectors/sharepoint-files/paging.d.ts +15 -0
  58. package/dist/connectors/sharepoint-files/paging.js +87 -0
  59. package/dist/connectors/sharepoint-files/paging.js.map +1 -0
  60. package/dist/connectors/sharepoint-files/parse-host.mjs +78 -0
  61. package/dist/connectors/sharepoint-files/pdf-worker.mjs +108 -0
  62. package/dist/connectors/sharepoint-files/pdf.d.ts +16 -0
  63. package/dist/connectors/sharepoint-files/pdf.js +19 -0
  64. package/dist/connectors/sharepoint-files/pdf.js.map +1 -0
  65. package/dist/connectors/sharepoint-files/sandbox.d.ts +19 -0
  66. package/dist/connectors/sharepoint-files/sandbox.js +176 -0
  67. package/dist/connectors/sharepoint-files/sandbox.js.map +1 -0
  68. package/dist/connectors/sharepoint-files/tools.d.ts +6 -0
  69. package/dist/connectors/sharepoint-files/tools.js +79 -4
  70. package/dist/connectors/sharepoint-files/tools.js.map +1 -1
  71. package/dist/connectors/slack/vendor.d.ts +1 -1
  72. package/dist/connectors/slack/vendor.js +32 -38
  73. package/dist/connectors/slack/vendor.js.map +1 -1
  74. package/dist/connectors/soap/index.d.ts +1 -4
  75. package/dist/connectors/sql/index.d.ts +1 -4
  76. package/dist/connectors/sql/index.js +2 -0
  77. package/dist/connectors/sql/index.js.map +1 -1
  78. package/dist/connectors/teams/index.d.ts +1 -1
  79. package/dist/connectors/teams/tools.d.ts +6 -1
  80. package/dist/connectors/teams/tools.js +3 -2
  81. package/dist/connectors/teams/tools.js.map +1 -1
  82. package/dist/connectors/workday/connector.json +6 -4
  83. package/dist/connectors/workday/vendor.d.ts +1 -1
  84. package/dist/connectors/workday/vendor.js +8 -4
  85. package/dist/connectors/workday/vendor.js.map +1 -1
  86. package/dist/packages/connector-kit/src/common.d.ts +4 -5
  87. package/dist/packages/connector-kit/src/common.js +4 -1
  88. package/dist/packages/connector-kit/src/common.js.map +1 -1
  89. package/dist/packages/connector-kit/src/connector.d.ts +37 -27
  90. package/dist/packages/connector-kit/src/connector.js +50 -11
  91. package/dist/packages/connector-kit/src/connector.js.map +1 -1
  92. package/dist/packages/connector-kit/src/fetch.d.ts +6 -0
  93. package/dist/packages/connector-kit/src/fetch.js +44 -0
  94. package/dist/packages/connector-kit/src/fetch.js.map +1 -0
  95. package/dist/packages/connector-kit/src/index.d.ts +3 -3
  96. package/dist/packages/connector-kit/src/index.js +1 -0
  97. package/dist/packages/connector-kit/src/index.js.map +1 -1
  98. package/dist/packages/connector-kit/src/oauth.d.ts +1 -1
  99. package/dist/packages/connector-kit/src/oauth.js +4 -2
  100. package/dist/packages/connector-kit/src/oauth.js.map +1 -1
  101. package/dist/packages/connector-kit/src/types.d.ts +4 -1
  102. package/dist/packages/connector-kit/src/types.js.map +1 -1
  103. package/dist/packages/server/src/api.d.ts +47 -31
  104. package/dist/packages/server/src/api.js +2 -0
  105. package/dist/packages/server/src/api.js.map +1 -1
  106. package/dist/packages/server/src/builtin.d.ts +4 -3
  107. package/dist/packages/server/src/builtin.js.map +1 -1
  108. package/dist/packages/server/src/events/runtime.js +17 -10
  109. package/dist/packages/server/src/events/runtime.js.map +1 -1
  110. package/dist/packages/server/src/events/store.d.ts +2 -2
  111. package/dist/packages/server/src/index.d.ts +3 -3
  112. package/dist/packages/server/src/index.js +5 -4
  113. package/dist/packages/server/src/index.js.map +1 -1
  114. package/dist/packages/server/src/service.d.ts +21 -14
  115. package/dist/packages/server/src/service.js +10 -3
  116. package/dist/packages/server/src/service.js.map +1 -1
  117. package/dist/packages/server/src/store.d.ts +2 -3
  118. package/dist/packages/server/src/store.js.map +1 -1
  119. package/package.json +4 -1
@@ -1,5 +1,4 @@
1
1
  import { z } from "zod";
2
- import type { MicrosoftClient } from "../../../connectors/microsoft/client.js";
3
2
  import type { Toolset } from "./common.js";
4
3
  import type { Vendor } from "./types.js";
5
4
  declare const settingSchema: z.ZodObject<{
@@ -27,8 +26,8 @@ export declare const setupStep: z.ZodObject<{
27
26
  click: z.ZodOptional<z.ZodArray<z.ZodString>>;
28
27
  clickUnavailable: z.ZodOptional<z.ZodLiteral<true>>;
29
28
  siteRole: z.ZodOptional<z.ZodEnum<{
30
- write: "write";
31
29
  read: "read";
30
+ write: "write";
32
31
  }>>;
33
32
  agentCheck: z.ZodOptional<z.ZodBoolean>;
34
33
  confirm: z.ZodOptional<z.ZodString>;
@@ -53,6 +52,7 @@ declare const probeSchema: z.ZodUnion<readonly [z.ZodObject<{
53
52
  path: z.ZodString;
54
53
  label: z.ZodString;
55
54
  show: z.ZodString;
55
+ name: z.ZodOptional<z.ZodString>;
56
56
  match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
57
57
  body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
58
58
  ifEmpty: z.ZodOptional<z.ZodString>;
@@ -133,8 +133,8 @@ declare const httpSchema: z.ZodObject<{
133
133
  }>;
134
134
  description: z.ZodString;
135
135
  in: z.ZodEnum<{
136
- path: "path";
137
136
  body: "body";
137
+ path: "path";
138
138
  query: "query";
139
139
  }>;
140
140
  name: z.ZodOptional<z.ZodString>;
@@ -286,9 +286,9 @@ declare const odataSchema: z.ZodObject<{
286
286
  string: "string";
287
287
  number: "number";
288
288
  boolean: "boolean";
289
+ guid: "guid";
289
290
  integer: "integer";
290
291
  decimal: "decimal";
291
- guid: "guid";
292
292
  datetime: "datetime";
293
293
  datetimeoffset: "datetimeoffset";
294
294
  }>;
@@ -302,9 +302,9 @@ declare const odataSchema: z.ZodObject<{
302
302
  string: "string";
303
303
  number: "number";
304
304
  boolean: "boolean";
305
+ guid: "guid";
305
306
  integer: "integer";
306
307
  decimal: "decimal";
307
- guid: "guid";
308
308
  datetime: "datetime";
309
309
  datetimeoffset: "datetimeoffset";
310
310
  }>;
@@ -328,9 +328,9 @@ declare const odataSchema: z.ZodObject<{
328
328
  string: "string";
329
329
  number: "number";
330
330
  boolean: "boolean";
331
+ guid: "guid";
331
332
  integer: "integer";
332
333
  decimal: "decimal";
333
- guid: "guid";
334
334
  datetime: "datetime";
335
335
  datetimeoffset: "datetimeoffset";
336
336
  }>;
@@ -344,9 +344,9 @@ declare const odataSchema: z.ZodObject<{
344
344
  string: "string";
345
345
  number: "number";
346
346
  boolean: "boolean";
347
+ guid: "guid";
347
348
  integer: "integer";
348
349
  decimal: "decimal";
349
- guid: "guid";
350
350
  datetime: "datetime";
351
351
  datetimeoffset: "datetimeoffset";
352
352
  }>;
@@ -472,8 +472,8 @@ declare const eventsSchema: z.ZodObject<{
472
472
  click: z.ZodOptional<z.ZodArray<z.ZodString>>;
473
473
  clickUnavailable: z.ZodOptional<z.ZodLiteral<true>>;
474
474
  siteRole: z.ZodOptional<z.ZodEnum<{
475
- write: "write";
476
475
  read: "read";
476
+ write: "write";
477
477
  }>>;
478
478
  agentCheck: z.ZodOptional<z.ZodBoolean>;
479
479
  confirm: z.ZodOptional<z.ZodString>;
@@ -531,7 +531,7 @@ declare const eventsSchema: z.ZodObject<{
531
531
  deliveryId: z.ZodArray<z.ZodString>;
532
532
  types: z.ZodArray<z.ZodObject<{
533
533
  type: z.ZodString;
534
- same: z.ZodOptional<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
534
+ since: z.ZodOptional<z.ZodString>;
535
535
  }, z.core.$strict>>;
536
536
  }, z.core.$strict>>;
537
537
  }, z.core.$strict>;
@@ -569,8 +569,8 @@ export declare const connectorSchema: z.ZodObject<{
569
569
  click: z.ZodOptional<z.ZodArray<z.ZodString>>;
570
570
  clickUnavailable: z.ZodOptional<z.ZodLiteral<true>>;
571
571
  siteRole: z.ZodOptional<z.ZodEnum<{
572
- write: "write";
573
572
  read: "read";
573
+ write: "write";
574
574
  }>>;
575
575
  agentCheck: z.ZodOptional<z.ZodBoolean>;
576
576
  confirm: z.ZodOptional<z.ZodString>;
@@ -586,6 +586,7 @@ export declare const connectorSchema: z.ZodObject<{
586
586
  field: z.ZodString;
587
587
  value: z.ZodString;
588
588
  }, z.core.$strict>>;
589
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
589
590
  }, z.core.$strict>>;
590
591
  afterConnect: z.ZodArray<z.ZodObject<{
591
592
  title: z.ZodString;
@@ -604,8 +605,8 @@ export declare const connectorSchema: z.ZodObject<{
604
605
  click: z.ZodOptional<z.ZodArray<z.ZodString>>;
605
606
  clickUnavailable: z.ZodOptional<z.ZodLiteral<true>>;
606
607
  siteRole: z.ZodOptional<z.ZodEnum<{
607
- write: "write";
608
608
  read: "read";
609
+ write: "write";
609
610
  }>>;
610
611
  agentCheck: z.ZodOptional<z.ZodBoolean>;
611
612
  confirm: z.ZodOptional<z.ZodString>;
@@ -621,6 +622,7 @@ export declare const connectorSchema: z.ZodObject<{
621
622
  field: z.ZodString;
622
623
  value: z.ZodString;
623
624
  }, z.core.$strict>>;
625
+ capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
624
626
  }, z.core.$strict>>;
625
627
  fields: z.ZodArray<z.ZodObject<{
626
628
  id: z.ZodString;
@@ -638,6 +640,7 @@ export declare const connectorSchema: z.ZodObject<{
638
640
  field: z.ZodString;
639
641
  value: z.ZodString;
640
642
  }, z.core.$strict>>;
643
+ optional: z.ZodDefault<z.ZodBoolean>;
641
644
  }, z.core.$strict>>;
642
645
  capabilities: z.ZodArray<z.ZodObject<{
643
646
  id: z.ZodString;
@@ -686,8 +689,8 @@ export declare const connectorSchema: z.ZodObject<{
686
689
  click: z.ZodOptional<z.ZodArray<z.ZodString>>;
687
690
  clickUnavailable: z.ZodOptional<z.ZodLiteral<true>>;
688
691
  siteRole: z.ZodOptional<z.ZodEnum<{
689
- write: "write";
690
692
  read: "read";
693
+ write: "write";
691
694
  }>>;
692
695
  agentCheck: z.ZodOptional<z.ZodBoolean>;
693
696
  confirm: z.ZodOptional<z.ZodString>;
@@ -734,6 +737,7 @@ export declare const connectorSchema: z.ZodObject<{
734
737
  path: z.ZodString;
735
738
  label: z.ZodString;
736
739
  show: z.ZodString;
740
+ name: z.ZodOptional<z.ZodString>;
737
741
  match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
738
742
  body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
739
743
  ifEmpty: z.ZodOptional<z.ZodString>;
@@ -750,6 +754,7 @@ export declare const connectorSchema: z.ZodObject<{
750
754
  path: z.ZodString;
751
755
  label: z.ZodString;
752
756
  show: z.ZodString;
757
+ name: z.ZodOptional<z.ZodString>;
753
758
  match: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
754
759
  body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
755
760
  ifEmpty: z.ZodOptional<z.ZodString>;
@@ -806,8 +811,8 @@ export declare const connectorSchema: z.ZodObject<{
806
811
  }>;
807
812
  description: z.ZodString;
808
813
  in: z.ZodEnum<{
809
- path: "path";
810
814
  body: "body";
815
+ path: "path";
811
816
  query: "query";
812
817
  }>;
813
818
  name: z.ZodOptional<z.ZodString>;
@@ -956,9 +961,9 @@ export declare const connectorSchema: z.ZodObject<{
956
961
  string: "string";
957
962
  number: "number";
958
963
  boolean: "boolean";
964
+ guid: "guid";
959
965
  integer: "integer";
960
966
  decimal: "decimal";
961
- guid: "guid";
962
967
  datetime: "datetime";
963
968
  datetimeoffset: "datetimeoffset";
964
969
  }>;
@@ -972,9 +977,9 @@ export declare const connectorSchema: z.ZodObject<{
972
977
  string: "string";
973
978
  number: "number";
974
979
  boolean: "boolean";
980
+ guid: "guid";
975
981
  integer: "integer";
976
982
  decimal: "decimal";
977
- guid: "guid";
978
983
  datetime: "datetime";
979
984
  datetimeoffset: "datetimeoffset";
980
985
  }>;
@@ -998,9 +1003,9 @@ export declare const connectorSchema: z.ZodObject<{
998
1003
  string: "string";
999
1004
  number: "number";
1000
1005
  boolean: "boolean";
1006
+ guid: "guid";
1001
1007
  integer: "integer";
1002
1008
  decimal: "decimal";
1003
- guid: "guid";
1004
1009
  datetime: "datetime";
1005
1010
  datetimeoffset: "datetimeoffset";
1006
1011
  }>;
@@ -1014,9 +1019,9 @@ export declare const connectorSchema: z.ZodObject<{
1014
1019
  string: "string";
1015
1020
  number: "number";
1016
1021
  boolean: "boolean";
1022
+ guid: "guid";
1017
1023
  integer: "integer";
1018
1024
  decimal: "decimal";
1019
- guid: "guid";
1020
1025
  datetime: "datetime";
1021
1026
  datetimeoffset: "datetimeoffset";
1022
1027
  }>;
@@ -1139,8 +1144,8 @@ export declare const connectorSchema: z.ZodObject<{
1139
1144
  click: z.ZodOptional<z.ZodArray<z.ZodString>>;
1140
1145
  clickUnavailable: z.ZodOptional<z.ZodLiteral<true>>;
1141
1146
  siteRole: z.ZodOptional<z.ZodEnum<{
1142
- write: "write";
1143
1147
  read: "read";
1148
+ write: "write";
1144
1149
  }>>;
1145
1150
  agentCheck: z.ZodOptional<z.ZodBoolean>;
1146
1151
  confirm: z.ZodOptional<z.ZodString>;
@@ -1198,7 +1203,7 @@ export declare const connectorSchema: z.ZodObject<{
1198
1203
  deliveryId: z.ZodArray<z.ZodString>;
1199
1204
  types: z.ZodArray<z.ZodObject<{
1200
1205
  type: z.ZodString;
1201
- same: z.ZodOptional<z.ZodTuple<[z.ZodString, z.ZodString], null>>;
1206
+ since: z.ZodOptional<z.ZodString>;
1202
1207
  }, z.core.$strict>>;
1203
1208
  }, z.core.$strict>>;
1204
1209
  }, z.core.$strict>>;
@@ -1233,8 +1238,8 @@ export declare const providerSchema: z.ZodObject<{
1233
1238
  click: z.ZodOptional<z.ZodArray<z.ZodString>>;
1234
1239
  clickUnavailable: z.ZodOptional<z.ZodLiteral<true>>;
1235
1240
  siteRole: z.ZodOptional<z.ZodEnum<{
1236
- write: "write";
1237
1241
  read: "read";
1242
+ write: "write";
1238
1243
  }>>;
1239
1244
  agentCheck: z.ZodOptional<z.ZodBoolean>;
1240
1245
  confirm: z.ZodOptional<z.ZodString>;
@@ -1286,8 +1291,8 @@ export declare const providerSchema: z.ZodObject<{
1286
1291
  click: z.ZodOptional<z.ZodArray<z.ZodString>>;
1287
1292
  clickUnavailable: z.ZodOptional<z.ZodLiteral<true>>;
1288
1293
  siteRole: z.ZodOptional<z.ZodEnum<{
1289
- write: "write";
1290
1294
  read: "read";
1295
+ write: "write";
1291
1296
  }>>;
1292
1297
  agentCheck: z.ZodOptional<z.ZodBoolean>;
1293
1298
  confirm: z.ZodOptional<z.ZodString>;
@@ -1308,14 +1313,16 @@ export declare const providerSchema: z.ZodObject<{
1308
1313
  revoke: z.ZodString;
1309
1314
  }, z.core.$strict>;
1310
1315
  export type Provider = z.infer<typeof providerSchema>;
1316
+ /** What a module's `create` is given: its connector.json, parsed and with the branding
1317
+ * filled in. Built-in apps get more (BuiltinContext, in the server). */
1318
+ export type ConnectorContext = {
1319
+ connector: Connector;
1320
+ };
1311
1321
  /** The code behind one connector: its vendor client and its tools. */
1312
- export type ConnectorModule = {
1322
+ export type ConnectorModule<Context extends ConnectorContext = ConnectorContext> = {
1313
1323
  id: string;
1314
1324
  connector?: ConnectorJson;
1315
- create(ctx: {
1316
- microsoft: MicrosoftClient;
1317
- connector: Connector;
1318
- }): {
1325
+ create(ctx: Context): {
1319
1326
  vendor: Vendor;
1320
1327
  toolset: Toolset;
1321
1328
  };
@@ -1324,7 +1331,8 @@ export type ConnectorModule = {
1324
1331
  export declare const CONNECTORS_DIR: import("node:url").URL;
1325
1332
  /** A definition given inline rather than in a folder, checked as loadConnectors checks one. */
1326
1333
  export declare const parseConnector: (raw: unknown, where: string) => Connector;
1327
- export declare function loadConnectors(dir?: import("node:url").URL): Connector[];
1334
+ /** `only`: the folder ids to read, so an app not offered is never parsed. */
1335
+ export declare function loadConnectors(dir?: import("node:url").URL, only?: (id: string) => boolean): Connector[];
1328
1336
  export declare function loadProviders(dir?: import("node:url").URL): Provider[];
1329
1337
  /** The ids of an app's choice fields: what its connection keeps from the admin's form. */
1330
1338
  export declare const choiceFields: (connector: Connector) => string[];
@@ -1343,4 +1351,6 @@ export declare function effectiveCapabilities(connector: Connector, grant: reado
1343
1351
  export declare function providerSettings(connectors: Connector[], provider: string): Map<string, Setting>;
1344
1352
  export declare function expandCopy(lines: string[], scopes: string[]): string;
1345
1353
  export declare function pickDisplay(data: unknown, path: string, match?: Record<string, unknown>): string[];
1354
+ /** Each value `show` picks, with its label `name` picks from the same list item. */
1355
+ export declare function pickLabels(data: unknown, show: string, name: string, match?: Record<string, unknown>): Record<string, string>;
1346
1356
  export {};
@@ -74,6 +74,12 @@ const clickRule = [
74
74
  ];
75
75
  export const setupStep = stepSchema.refine(...clickRule);
76
76
  const step = setupStep;
77
+ // An app's own setup step, which may be shown only while one of `capabilities` is ticked
78
+ // (e.g. a script only saved searches need).
79
+ const appStep = stepSchema
80
+ .extend({ capabilities: z.array(slug).min(1).optional() })
81
+ .strict()
82
+ .refine(...clickRule);
77
83
  const agentStep = agentStepSchema.refine(...clickRule);
78
84
  // A field with `options` is a choice (the first is the default), stored in the app's config
79
85
  // under its id. An option's `scopes` are vendor permissions the app then needs too, e.g.
@@ -92,6 +98,8 @@ const fieldSchema = z
92
98
  // Asked only while an earlier choice is this option; otherwise a choice's first option
93
99
  // holds and a text field is not asked (e.g. a password only for that sign-in method).
94
100
  requires: chosenSchema.optional(),
101
+ // May be left empty.
102
+ optional: z.boolean().default(false),
95
103
  })
96
104
  .strict();
97
105
  // "map": one optional value per value of the list limit `keys`, e.g. a folder per site.
@@ -110,19 +118,27 @@ const limitSchema = z
110
118
  .refine((l) => (l.kind === "map") === Boolean(l.keys), {
111
119
  message: "A map limit names the list limit it is keyed by (keys), and only it",
112
120
  });
121
+ // The path up to and including its last list (`items[]` of `items[].id`), or "" without one.
122
+ const listPrefix = (path) => path.includes("[]") ? path.slice(0, path.lastIndexOf("[]") + 2) : "";
113
123
  const httpProbeSchema = z
114
124
  .object({
115
125
  method: z.enum(["GET", "POST"]),
116
126
  path: z.string().startsWith("/"),
117
127
  label: text,
118
128
  show: text,
129
+ // Each value's label for the admin, read from the same list item as `show` (e.g. show
130
+ // "items[].id", name "items[].name").
131
+ name: text.optional(),
119
132
  // Keeps only list items whose fields equal these values, e.g. objects agents can query.
120
133
  match: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
121
134
  body: z.record(z.string(), z.unknown()).optional(),
122
135
  // Shown to the admin when the probe finds nothing, e.g. a missing project permission.
123
136
  ifEmpty: text.optional(),
124
137
  })
125
- .strict();
138
+ .strict()
139
+ .refine((p) => !p.name || listPrefix(p.name) === listPrefix(p.show), {
140
+ message: "A probe's name is read from the same list as its show",
141
+ });
126
142
  // A check no single API call answers, e.g. the permissions inside a token. The vendor client
127
143
  // implements it under this name (Vendor.checks).
128
144
  const vendorProbeSchema = z
@@ -663,7 +679,9 @@ const eventsSchema = z
663
679
  // the cursor, rounded up, plus one) {cursor} and {filter} (the subscription's filter put
664
680
  // into `filter`'s {value}, or nothing); `items` the list in the answer, each kept under
665
681
  // `wrap` so the webhook's paths fit; `cursor` the item's change time; `deliveryId` the
666
- // paths joined into an id; `types` the first whose `same` paths are equal (or that has none).
682
+ // paths joined into an id; `types` the first whose `since` time is after the cursor the poll
683
+ // started from (or that has none): a record created since the last poll is new, whatever
684
+ // its change time says (Jira stamps an issue's update just after its creation).
667
685
  poll: z
668
686
  .object({
669
687
  request: eventRequest,
@@ -673,7 +691,7 @@ const eventsSchema = z
673
691
  cursor: eventPath,
674
692
  deliveryId: z.array(eventPath).min(1),
675
693
  types: z
676
- .array(z.object({ type: eventId, same: z.tuple([eventPath, eventPath]).optional() }).strict())
694
+ .array(z.object({ type: eventId, since: eventPath.optional() }).strict())
677
695
  .min(1),
678
696
  })
679
697
  .strict()
@@ -710,8 +728,8 @@ export const connectorSchema = z
710
728
  // Vendor scopes every ceiling needs, whatever is ticked (e.g. what adding agents' Teams
711
729
  // bots takes), filled into {scope}/{scopes} with the capabilities' own.
712
730
  scopes: z.array(text).optional(),
713
- setup: z.array(step),
714
- afterConnect: z.array(step),
731
+ setup: z.array(appStep),
732
+ afterConnect: z.array(appStep),
715
733
  fields: z.array(fieldSchema),
716
734
  capabilities: z
717
735
  .array(z
@@ -848,6 +866,7 @@ export const connectorSchema = z
848
866
  return ([...c.setup, ...c.afterConnect].every((s) => !s.option || isOption(s.option, c.fields)) &&
849
867
  c.fields.every((f, i) => !f.requires || isOption(f.requires, c.fields.slice(0, i))));
850
868
  }, { message: "A step's option and a field's requires name an option of an earlier choice" })
869
+ .refine((c) => [...c.setup, ...c.afterConnect].every((s) => !s.capabilities || s.capabilities.every((id) => c.capabilities.some((x) => x.id === id))), { message: "A step's capabilities name capabilities of its connector" })
851
870
  .refine((c) => c.provider !== undefined || c.fields.length > 0, {
852
871
  message: "A guided connector needs connect form fields",
853
872
  })
@@ -921,7 +940,7 @@ export const providerSchema = z
921
940
  // The service can make a key pair whose certificate the admin uploads to their app.
922
941
  certificate: z.boolean(),
923
942
  setup: z.array(step),
924
- fields: z.array(fieldSchema.extend({ optional: z.boolean().default(false) }).strict()).min(1),
943
+ fields: z.array(fieldSchema).min(1),
925
944
  // What one more agent needs outside the service (e.g. its mailbox), shown when its API key is
926
945
  // made with one of the apps each step names.
927
946
  addAgent: z.array(agentStep).default([]),
@@ -947,9 +966,9 @@ function parse(raw, where, schema) {
947
966
  export const parseConnector = (raw, where) => parse(raw, where, connectorSchema);
948
967
  // Each subfolder of dir holding `file` is one definition, whose id is the folder's name.
949
968
  // Subfolders may be links: Kubernetes mounts ConfigMap and Secret folders that way.
950
- function loadDir(dir, file, schema) {
969
+ function loadDir(dir, file, schema, only = () => true) {
951
970
  return readdirSync(dir)
952
- .filter((name) => existsSync(new URL(`${name}/${file}`, dir)))
971
+ .filter((name) => only(name) && existsSync(new URL(`${name}/${file}`, dir)))
953
972
  .sort()
954
973
  .map((name) => {
955
974
  const where = `${name}/${file}`;
@@ -959,8 +978,9 @@ function loadDir(dir, file, schema) {
959
978
  return data;
960
979
  });
961
980
  }
962
- export function loadConnectors(dir = CONNECTORS_DIR) {
963
- return loadDir(dir, "connector.json", connectorSchema);
981
+ /** `only`: the folder ids to read, so an app not offered is never parsed. */
982
+ export function loadConnectors(dir = CONNECTORS_DIR, only) {
983
+ return loadDir(dir, "connector.json", connectorSchema, only);
964
984
  }
965
985
  export function loadProviders(dir = CONNECTORS_DIR) {
966
986
  return loadDir(dir, "provider.json", providerSchema);
@@ -1019,6 +1039,25 @@ export function expandCopy(lines, scopes) {
1019
1039
  }
1020
1040
  // Reads `a.b` / `values[].name` paths out of a JSON response for display.
1021
1041
  export function pickDisplay(data, path, match = {}) {
1042
+ return pick(data, path, match)
1043
+ .filter((v) => v !== undefined && v !== null)
1044
+ .map(String);
1045
+ }
1046
+ /** Each value `show` picks, with its label `name` picks from the same list item. */
1047
+ export function pickLabels(data, show, name, match = {}) {
1048
+ const prefix = listPrefix(show);
1049
+ const items = prefix ? pick(data, prefix, match) : [data];
1050
+ const rest = (path) => path.slice(prefix.length).replace(/^\./, "");
1051
+ const out = {};
1052
+ for (const item of items) {
1053
+ const [value] = rest(show) ? pick(item, rest(show)) : [item];
1054
+ const [label] = rest(name) ? pick(item, rest(name)) : [item];
1055
+ if (value != null && label != null)
1056
+ out[String(value)] = String(label);
1057
+ }
1058
+ return out;
1059
+ }
1060
+ function pick(data, path, match = {}) {
1022
1061
  const matches = (v) => Object.entries(match).every(([k, want]) => v && typeof v === "object" && v[k] === want);
1023
1062
  let values = [data];
1024
1063
  for (const part of path.split(".")) {
@@ -1029,6 +1068,6 @@ export function pickDisplay(data, path, match = {}) {
1029
1068
  return many ? (Array.isArray(next) ? next.filter(matches) : []) : [next];
1030
1069
  });
1031
1070
  }
1032
- return values.filter((v) => v !== undefined && v !== null).map(String);
1071
+ return values;
1033
1072
  }
1034
1073
  //# sourceMappingURL=connector.js.map