@capybara-hq/kernel 0.1.0-rc.83 → 0.1.0-rc.85

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 (94) hide show
  1. package/dist/admin/admin.module.js +5 -0
  2. package/dist/admin/health.service.d.ts +2 -2
  3. package/dist/admin/health.service.js +10 -2
  4. package/dist/catalog/admin-catalog.controller.d.ts +2 -1
  5. package/dist/catalog/admin-catalog.controller.js +2 -1
  6. package/dist/catalog/catalog-content.d.ts +5 -15
  7. package/dist/catalog/catalog-content.js +5 -56
  8. package/dist/catalog/catalog-scope.service.d.ts +3 -3
  9. package/dist/catalog/catalog-scope.service.js +4 -3
  10. package/dist/catalog/catalog.module.d.ts +3 -1
  11. package/dist/catalog/catalog.module.js +14 -1
  12. package/dist/catalog/component-scope.service.d.ts +6 -1
  13. package/dist/catalog/component-scope.service.js +16 -2
  14. package/dist/catalog/git-source.d.ts +8 -0
  15. package/dist/catalog/git-source.js +34 -0
  16. package/dist/catalog/job-ids.d.ts +29 -0
  17. package/dist/catalog/job-ids.js +29 -0
  18. package/dist/catalog/jobs.d.ts +12 -3
  19. package/dist/catalog/jobs.js +28 -7
  20. package/dist/catalog/marketplaces.service.d.ts +1 -1
  21. package/dist/catalog/org-catalog.controller.d.ts +2 -30
  22. package/dist/catalog/org-catalog.controller.js +3 -29
  23. package/dist/catalog/org-catalog.schemas.d.ts +9 -46
  24. package/dist/catalog/org-catalog.schemas.js +9 -23
  25. package/dist/catalog/org-catalog.service.js +14 -23
  26. package/dist/catalog/plugin-import.d.ts +21 -0
  27. package/dist/catalog/plugin-import.js +33 -3
  28. package/dist/catalog/plugin-install.d.ts +69 -76
  29. package/dist/catalog/plugin-install.js +156 -234
  30. package/dist/catalog/plugin-upgrade.d.ts +71 -11
  31. package/dist/catalog/plugin-upgrade.js +222 -43
  32. package/dist/catalog/scope-sync.d.ts +22 -20
  33. package/dist/catalog/scope-sync.js +57 -42
  34. package/dist/catalog/template-connector-ensure.d.ts +100 -0
  35. package/dist/catalog/template-connector-ensure.js +285 -0
  36. package/dist/catalog/template-connector-jobs.d.ts +28 -0
  37. package/dist/catalog/template-connector-jobs.js +54 -0
  38. package/dist/catalog/template-connector-reconcile.d.ts +44 -0
  39. package/dist/catalog/template-connector-reconcile.js +114 -0
  40. package/dist/catalog/template-connectors.processor.d.ts +32 -0
  41. package/dist/catalog/template-connectors.processor.js +101 -0
  42. package/dist/db/kernel-schema.d.ts +2 -1
  43. package/dist/extensions/bootstrap.js +5 -1
  44. package/dist/extensions/instance.js +1 -16
  45. package/dist/extensions/org-config.d.ts +6 -1
  46. package/dist/extensions/org-config.js +15 -2
  47. package/dist/git/gateway.js +3 -1
  48. package/dist/infra/outbox/registry.d.ts +28 -0
  49. package/dist/infra/outbox/registry.js +33 -0
  50. package/dist/infra/queue/queue-names.d.ts +1 -1
  51. package/dist/infra/queue/queue-names.js +2 -0
  52. package/dist/lifecycle/kernel-lifecycle.d.ts +8 -1
  53. package/dist/lifecycle/kernel-lifecycle.js +37 -11
  54. package/dist/orgs/org-owner.d.ts +7 -0
  55. package/dist/orgs/org-owner.js +16 -0
  56. package/dist/platform/operation.d.ts +3 -4
  57. package/dist/platform/ops/connectors.ops.js +8 -1
  58. package/dist/platform/ops/org-plugins.ops.d.ts +0 -9
  59. package/dist/platform/ops/org-plugins.ops.js +18 -235
  60. package/dist/platform/ops/plugins.ops.d.ts +0 -1
  61. package/dist/platform/ops/plugins.ops.js +3 -31
  62. package/dist/roles/worker-role.d.ts +9 -4
  63. package/dist/roles/worker-role.js +18 -5
  64. package/dist/roles/worker.module.d.ts +1 -1
  65. package/dist/roles/worker.module.js +8 -1
  66. package/dist/setup/setup-guides.service.d.ts +9 -1
  67. package/dist/setup/setup-guides.service.js +38 -8
  68. package/dist/tools/admin-connectors.d.ts +3 -2
  69. package/dist/tools/admin-connectors.js +5 -4
  70. package/dist/tools/connector-setup.d.ts +28 -0
  71. package/dist/tools/connector-setup.js +33 -0
  72. package/dist/tools/connector-tools-jobs.d.ts +35 -0
  73. package/dist/tools/connector-tools-jobs.js +40 -0
  74. package/dist/tools/connector-tools.processor.d.ts +32 -0
  75. package/dist/tools/connector-tools.processor.js +97 -0
  76. package/dist/tools/connectors.controller.d.ts +1 -0
  77. package/dist/tools/connectors.schemas.d.ts +1 -0
  78. package/dist/tools/connectors.schemas.js +5 -0
  79. package/dist/tools/connectors.service.d.ts +138 -14
  80. package/dist/tools/connectors.service.js +410 -50
  81. package/dist/tools/credentials.d.ts +35 -0
  82. package/dist/tools/credentials.js +89 -1
  83. package/dist/tools/drift.d.ts +5 -0
  84. package/dist/tools/drift.js +21 -2
  85. package/dist/tools/editable-endpoint.d.ts +23 -0
  86. package/dist/tools/editable-endpoint.js +92 -0
  87. package/dist/tools/oauth/flow.d.ts +1 -1
  88. package/dist/tools/oauth/flow.js +3 -2
  89. package/dist/tools/pipeline.js +14 -5
  90. package/dist/tools/registry.d.ts +14 -2
  91. package/dist/tools/registry.js +27 -6
  92. package/dist/tools/tools.module.js +4 -0
  93. package/package.json +3 -3
  94. package/src/migrations/0183_connectors_created_by_nullable.sql +5 -0
@@ -23,22 +23,29 @@ export const setupWebPath = {
23
23
  connector: (id) => `/connectors/${enc(id)}?tab=guide`,
24
24
  /** A member's connector section: the connector's row on their connections page (§9.3). */
25
25
  memberConnections: () => "/account/connections",
26
- template: (itemId) => `/connectors/install?template=${enc(itemId)}`,
26
+ /** A connector's configure page: its credentials tab (the guide, editable endpoint fields, credential). */
27
+ configure: (id) => `/connectors/${enc(id)}?tab=credentials`,
28
+ /** The connectors page: a template on in the org without a connector shows its card there. */
29
+ connectors: () => "/connectors",
27
30
  };
28
31
  /**
29
32
  * The page a rendered guide belongs on: a member's connections page for the member audience, else
30
- * its target's, else where a target is created.
33
+ * its target's, else where a target is created; a connector template's guide without a target goes
34
+ * to the configure page of `templateConnector` (a connector of the org made from the template) when there is
35
+ * one, else to the connectors page.
31
36
  */
32
- function webPathOf(g) {
37
+ function webPathOf(g, templateConnector) {
33
38
  if (g.audience === "member")
34
39
  return setupWebPath.memberConnections();
35
40
  if (g.target?.kind === "channel-connection")
36
41
  return setupWebPath.connection(g.target.id);
37
42
  if (g.target?.kind === "connector")
38
43
  return setupWebPath.connector(g.target.id);
39
- return g.place === "channel-connection"
40
- ? setupWebPath.newConnection()
41
- : setupWebPath.template(g.itemId);
44
+ if (g.place === "channel-connection")
45
+ return setupWebPath.newConnection();
46
+ return templateConnector !== undefined
47
+ ? setupWebPath.configure(templateConnector)
48
+ : setupWebPath.connectors();
42
49
  }
43
50
  /** A fence longer than any run of backticks in the text. */
44
51
  function fenceFor(text) {
@@ -250,13 +257,34 @@ let SetupGuidesService = class SetupGuidesService {
250
257
  id: t.name,
251
258
  name: t.displayName?.en ?? t.name,
252
259
  drift: null,
253
- webPath: setupWebPath.template(t.itemId),
260
+ webPath: setupWebPath.connectors(),
254
261
  checked: false,
255
262
  },
256
263
  });
257
264
  }
258
265
  return out;
259
266
  }
267
+ /**
268
+ * The oldest live connector of the org made from one of the item's platform connector templates
269
+ * `templates` (a template id, or the ids a guide covers), if any.
270
+ */
271
+ async templateConnector(orgId, itemId, templates) {
272
+ const ids = typeof templates === "string" ? [templates] : [...templates];
273
+ if (ids.length === 0)
274
+ return undefined;
275
+ const row = await this.db
276
+ .selectFrom("connectors as c")
277
+ .innerJoin("platform_connector_templates as t", "t.id", "c.platform_template_id")
278
+ .select("c.id")
279
+ .where("c.org_id", "=", orgId)
280
+ .where("c.deleted_at", "is", null)
281
+ .where("t.catalog_item_id", "=", itemId)
282
+ .where("t.template_id", "in", ids)
283
+ .orderBy("c.created_at")
284
+ .orderBy("c.id")
285
+ .executeTakeFirst();
286
+ return row?.id;
287
+ }
260
288
  /**
261
289
  * One guide rendered for the caller as a Markdown document (`setup.read`): the guide route's
262
290
  * rendering (`PluginGuides.render`, its visibility, action and target rules), joined, with the
@@ -264,7 +292,9 @@ let SetupGuidesService = class SetupGuidesService {
264
292
  */
265
293
  async read(caller, itemId, guideId, q) {
266
294
  const g = await this.guides.render({ orgId: caller.orgId, role: caller.role }, itemId, guideId, q);
267
- const webPath = webPathOf(g);
295
+ const webPath = webPathOf(g, g.audience !== "member" && g.target === null && g.place === "connector-template"
296
+ ? await this.templateConnector(caller.orgId, g.itemId, g.template ?? g.templates)
297
+ : undefined);
268
298
  return {
269
299
  itemId: g.itemId,
270
300
  plugin: g.plugin,
@@ -17,8 +17,9 @@ export interface AdminConnectorRow {
17
17
  /** Counts every tool row of the connector, pending and missing ones included. */
18
18
  toolCount: number;
19
19
  toolsSyncedAt: Date | null;
20
- createdBy: string;
21
- createdByName: string;
20
+ /** Null: the kernel created it as no person (a plugin scope sync). */
21
+ createdBy: string | null;
22
+ createdByName: string | null;
22
23
  createdByAvatarUrl: string | null;
23
24
  createdAt: Date;
24
25
  updatedAt: Date;
@@ -28,10 +28,11 @@ let AdminConnectors = class AdminConnectors {
28
28
  return this.kdb.db;
29
29
  }
30
30
  base() {
31
- return this.db
31
+ return (this.db
32
32
  .selectFrom("connectors as c")
33
33
  .innerJoin("orgs as o", "o.id", "c.org_id")
34
- .innerJoin("accounts as a", "a.id", "c.created_by")
34
+ // a connector the kernel created as no person has no creator (ruling R17)
35
+ .leftJoin("accounts as a", "a.id", "c.created_by")
35
36
  .leftJoin("platform_connector_templates as pt", "pt.id", "c.platform_template_id")
36
37
  .select((eb) => [
37
38
  "c.id",
@@ -54,7 +55,7 @@ let AdminConnectors = class AdminConnectors {
54
55
  WHERE t.connector_id = c.id)`.as("tool_count"),
55
56
  ])
56
57
  .where("c.deleted_at", "is", null)
57
- .where("o.deleted_at", "is", null);
58
+ .where("o.deleted_at", "is", null));
58
59
  }
59
60
  /** Live connectors of every live org by id, filtered; `next` is the last id when more follow. */
60
61
  async list(q) {
@@ -131,7 +132,7 @@ function toRow(r) {
131
132
  toolsSyncedAt: r.tools_synced_at,
132
133
  createdBy: r.created_by,
133
134
  createdByName: r.created_by_name,
134
- createdByAvatarUrl: personAvatarUrl(r, "creator", r.created_by),
135
+ createdByAvatarUrl: r.created_by === null ? null : personAvatarUrl(r, "creator", r.created_by),
135
136
  createdAt: r.created_at,
136
137
  updatedAt: r.updated_at,
137
138
  };
@@ -0,0 +1,28 @@
1
+ import type { ConnectorAuth, Credentials } from "./credentials.js";
2
+ /**
3
+ * The org-level input a connector's auth needs (plugin pages spec §5.2.1): `client`, the OAuth
4
+ * client of the client-credentials flow or of an authorization-code flow with a manually
5
+ * registered client; `credential`, a static credential the org owns.
6
+ */
7
+ export type SetupNeed = "client" | "credential";
8
+ /**
9
+ * A connector's setup state, derived on every read and never stored: `needs_config` while the
10
+ * org input its auth needs is absent, `ready` otherwise. Independent of `status`.
11
+ */
12
+ export type ConnectorSetup = "ready" | "needs_config";
13
+ /**
14
+ * The org input `auth` needs, undefined when it needs none (no auth, a personal credential, or an
15
+ * authorization-code flow that registers its client itself). The web's `templateNeed`
16
+ * (apps/web/src/lib/catalog.ts) applies the same rule.
17
+ */
18
+ export declare function setupNeed(auth: ConnectorAuth): SetupNeed | undefined;
19
+ /**
20
+ * The setup states of several connectors of `orgId` at once (one query, key presence only), by
21
+ * connector id.
22
+ */
23
+ export declare function connectorSetups(credentials: Pick<Credentials, "orgInputs">, orgId: string, connectors: readonly {
24
+ id: string;
25
+ auth: ConnectorAuth;
26
+ }[]): Promise<Map<string, ConnectorSetup>>;
27
+ /** The setup state of a connector of `orgId` with `auth`, read from key presence only. */
28
+ export declare function connectorSetup(credentials: Pick<Credentials, "hasOrgInput">, orgId: string, connectorId: string, auth: ConnectorAuth): Promise<ConnectorSetup>;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The org input `auth` needs, undefined when it needs none (no auth, a personal credential, or an
3
+ * authorization-code flow that registers its client itself). The web's `templateNeed`
4
+ * (apps/web/src/lib/catalog.ts) applies the same rule.
5
+ */
6
+ export function setupNeed(auth) {
7
+ if (auth.type === "oauth_client" || (auth.type === "oauth_code" && auth.client === "manual")) {
8
+ return "client";
9
+ }
10
+ if (auth.type !== "none" && auth.type !== "oauth_code" && auth.ownership === "org") {
11
+ return "credential";
12
+ }
13
+ return undefined;
14
+ }
15
+ /**
16
+ * The setup states of several connectors of `orgId` at once (one query, key presence only), by
17
+ * connector id.
18
+ */
19
+ export async function connectorSetups(credentials, orgId, connectors) {
20
+ const inputs = await credentials.orgInputs(orgId, connectors.filter((c) => setupNeed(c.auth) !== undefined).map((c) => c.id));
21
+ return new Map(connectors.map((c) => {
22
+ const need = setupNeed(c.auth);
23
+ const ready = need === undefined || inputs.get(c.id)?.[need] === true;
24
+ return [c.id, ready ? "ready" : "needs_config"];
25
+ }));
26
+ }
27
+ /** The setup state of a connector of `orgId` with `auth`, read from key presence only. */
28
+ export async function connectorSetup(credentials, orgId, connectorId, auth) {
29
+ const need = setupNeed(auth);
30
+ if (need === undefined)
31
+ return "ready";
32
+ return (await credentials.hasOrgInput(orgId, connectorId, need)) ? "ready" : "needs_config";
33
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The queue of connector tool listings that follow a write (plugin pages spec §5.2.1): the
3
+ * listing is an outbound call, so it never runs inside the transaction that owes it.
4
+ */
5
+ export declare const CONNECTOR_TOOLS_QUEUE = "cap-connector-tools";
6
+ /** Lists a connector's tools and stores them through the refresh path's compare-and-write. */
7
+ export declare const CONNECTOR_TOOLS_JOB = "connector-tools-list";
8
+ /**
9
+ * What owed the listing: the connector was `created` ready, it turned ready when an org admin
10
+ * saved its missing input (`configured`), a member saved the first credential of a personal
11
+ * connector with no tool list yet (`connected`), an org admin changed an editable endpoint
12
+ * field of a ready template connector (`endpoint_changed`), or a platform update cleared the
13
+ * credentials of a template connector whose new auth leaves it ready (`template_updated`).
14
+ */
15
+ export type ConnectorToolsTrigger = "created" | "configured" | "connected" | "endpoint_changed" | "template_updated";
16
+ /** Data of a {@link CONNECTOR_TOOLS_JOB}; `accountId` is the member whose credential lists. */
17
+ export interface ConnectorToolsJobData {
18
+ orgId: string;
19
+ connectorId: string;
20
+ accountId?: string;
21
+ }
22
+ /**
23
+ * `connector-tools-<connectorId>-<trigger>[-<accountId>]-<xact>`: `xact` is the owing
24
+ * transaction's id (`pg_current_xact_id()`), so two owings in one transaction are one job and a
25
+ * later transaction's job is never swallowed by an earlier one; a `connected` owing names the
26
+ * member (one id with different data would be refused). Connector and account ids are UUIDs and
27
+ * `xact` is a number: the id has no `:`.
28
+ */
29
+ export declare const connectorToolsJobId: (connectorId: string, trigger: ConnectorToolsTrigger, xact: string, accountId?: string) => string;
30
+ /**
31
+ * The connector tools queue, registered once and shared: imported by `ToolsModule` (every role
32
+ * owes the jobs) and by the admin module (the health overview counts it).
33
+ */
34
+ export declare class ConnectorToolsQueueModule {
35
+ }
@@ -0,0 +1,40 @@
1
+ // The connector tool list jobs' queue, names, ids and data: no service imports, read by
2
+ // ConnectorsService (the producer, through the outbox), ConnectorToolsProcessor (the consumer) and
3
+ // the health overview (which counts the queue).
4
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ };
10
+ import { Module } from "@nestjs/common";
11
+ import { QueueModule } from "../infra/queue/queue.module.js";
12
+ /**
13
+ * The queue of connector tool listings that follow a write (plugin pages spec §5.2.1): the
14
+ * listing is an outbound call, so it never runs inside the transaction that owes it.
15
+ */
16
+ export const CONNECTOR_TOOLS_QUEUE = "cap-connector-tools";
17
+ /** Lists a connector's tools and stores them through the refresh path's compare-and-write. */
18
+ export const CONNECTOR_TOOLS_JOB = "connector-tools-list";
19
+ /**
20
+ * `connector-tools-<connectorId>-<trigger>[-<accountId>]-<xact>`: `xact` is the owing
21
+ * transaction's id (`pg_current_xact_id()`), so two owings in one transaction are one job and a
22
+ * later transaction's job is never swallowed by an earlier one; a `connected` owing names the
23
+ * member (one id with different data would be refused). Connector and account ids are UUIDs and
24
+ * `xact` is a number: the id has no `:`.
25
+ */
26
+ export const connectorToolsJobId = (connectorId, trigger, xact, accountId) => `connector-tools-${connectorId}-${trigger}${accountId === undefined ? "" : `-${accountId}`}-${xact}`;
27
+ const CONNECTOR_TOOLS_QUEUE_REGISTRATION = QueueModule.registerQueue(CONNECTOR_TOOLS_QUEUE);
28
+ /**
29
+ * The connector tools queue, registered once and shared: imported by `ToolsModule` (every role
30
+ * owes the jobs) and by the admin module (the health overview counts it).
31
+ */
32
+ let ConnectorToolsQueueModule = class ConnectorToolsQueueModule {
33
+ };
34
+ ConnectorToolsQueueModule = __decorate([
35
+ Module({
36
+ imports: [CONNECTOR_TOOLS_QUEUE_REGISTRATION],
37
+ exports: [CONNECTOR_TOOLS_QUEUE_REGISTRATION],
38
+ })
39
+ ], ConnectorToolsQueueModule);
40
+ export { ConnectorToolsQueueModule };
@@ -0,0 +1,32 @@
1
+ import { WorkerHost } from "@nestjs/bullmq";
2
+ import { type Job, type Worker } from "bullmq";
3
+ import type { KernelLogger } from "../log.js";
4
+ import { type ConnectorToolsJobData } from "./connector-tools-jobs.js";
5
+ import { ConnectorsService } from "./connectors.service.js";
6
+ /**
7
+ * The consumer of {@link CONNECTOR_TOOLS_QUEUE} (`cap-connector-tools`): each
8
+ * `connector-tools-list` job lists one connector's tools through
9
+ * `ConnectorsService.listToolsForJob` (the refresh path's listing and compare-and-write), inside
10
+ * `runJob`. Worker role only (`ConnectorToolsWorkersModule`); built with `autorun: false` and
11
+ * started by the worker role after the extensions loaded, so a connector extension is there to
12
+ * list with. A failed attempt is retried by the queue (registry `opts`); the last one logs an
13
+ * error with ids only.
14
+ */
15
+ export declare class ConnectorToolsProcessor extends WorkerHost<Worker<ConnectorToolsJobData>> {
16
+ private readonly connectors;
17
+ private readonly log;
18
+ constructor(connectors: Pick<ConnectorsService, "listToolsForJob">, log: KernelLogger);
19
+ process(job: Job<ConnectorToolsJobData>): Promise<unknown>;
20
+ /** Starts consuming (worker role, after the extensions loaded). */
21
+ start(): void;
22
+ /** Closes the worker, waiting for the listings in flight (each bounded by the tool timeout). */
23
+ close(): Promise<void>;
24
+ failed(job: Job<ConnectorToolsJobData> | undefined, err: Error): void;
25
+ error(err: Error): void;
26
+ }
27
+ /**
28
+ * The connector tools queue's consumer; imported only by the worker role (`WorkerModule`). The
29
+ * queue itself is registered by `ToolsModule` (every role owes the jobs).
30
+ */
31
+ export declare class ConnectorToolsWorkersModule {
32
+ }
@@ -0,0 +1,97 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { OnWorkerEvent, Processor, WorkerHost } from "@nestjs/bullmq";
11
+ import { Inject, Injectable, Module } from "@nestjs/common";
12
+ import { UnrecoverableError } from "bullmq";
13
+ import { runJob } from "../infra/queue/run-job.js";
14
+ import { KERNEL_LOGGER } from "../infra/tokens.js";
15
+ import { CONNECTOR_TOOLS_JOB, CONNECTOR_TOOLS_QUEUE, } from "./connector-tools-jobs.js";
16
+ import { ConnectorsService } from "./connectors.service.js";
17
+ import { ToolsModule } from "./tools.module.js";
18
+ /**
19
+ * The consumer of {@link CONNECTOR_TOOLS_QUEUE} (`cap-connector-tools`): each
20
+ * `connector-tools-list` job lists one connector's tools through
21
+ * `ConnectorsService.listToolsForJob` (the refresh path's listing and compare-and-write), inside
22
+ * `runJob`. Worker role only (`ConnectorToolsWorkersModule`); built with `autorun: false` and
23
+ * started by the worker role after the extensions loaded, so a connector extension is there to
24
+ * list with. A failed attempt is retried by the queue (registry `opts`); the last one logs an
25
+ * error with ids only.
26
+ */
27
+ let ConnectorToolsProcessor = class ConnectorToolsProcessor extends WorkerHost {
28
+ connectors;
29
+ log;
30
+ constructor(connectors, log) {
31
+ super();
32
+ this.connectors = connectors;
33
+ this.log = log;
34
+ }
35
+ process(job) {
36
+ return runJob(CONNECTOR_TOOLS_QUEUE, job, async () => {
37
+ if (job.name !== CONNECTOR_TOOLS_JOB) {
38
+ throw new UnrecoverableError(`unknown connector tools job ${job.name}`);
39
+ }
40
+ return this.connectors.listToolsForJob(job.data);
41
+ });
42
+ }
43
+ /** Starts consuming (worker role, after the extensions loaded). */
44
+ start() {
45
+ void this.worker.run().catch((err) => this.error(err));
46
+ }
47
+ /** Closes the worker, waiting for the listings in flight (each bounded by the tool timeout). */
48
+ async close() {
49
+ await this.worker.close();
50
+ }
51
+ failed(job, err) {
52
+ if (!job)
53
+ return;
54
+ const fields = {
55
+ jobId: job.id,
56
+ orgId: job.data.orgId,
57
+ connectorId: job.data.connectorId,
58
+ attempt: job.attemptsMade,
59
+ error: err.message,
60
+ };
61
+ if (job.attemptsMade >= (job.opts.attempts ?? 1)) {
62
+ this.log.error("connector tool listing failed on its last attempt; given up", fields);
63
+ }
64
+ else
65
+ this.log.warn("connector tool listing failed; retrying", fields);
66
+ }
67
+ error(err) {
68
+ this.log.error("connector tools worker error", { err });
69
+ }
70
+ };
71
+ __decorate([
72
+ OnWorkerEvent("failed")
73
+ ], ConnectorToolsProcessor.prototype, "failed", null);
74
+ __decorate([
75
+ OnWorkerEvent("error")
76
+ ], ConnectorToolsProcessor.prototype, "error", null);
77
+ ConnectorToolsProcessor = __decorate([
78
+ Injectable(),
79
+ Processor(CONNECTOR_TOOLS_QUEUE, { autorun: false }),
80
+ __param(0, Inject(ConnectorsService)),
81
+ __param(1, Inject(KERNEL_LOGGER))
82
+ ], ConnectorToolsProcessor);
83
+ export { ConnectorToolsProcessor };
84
+ /**
85
+ * The connector tools queue's consumer; imported only by the worker role (`WorkerModule`). The
86
+ * queue itself is registered by `ToolsModule` (every role owes the jobs).
87
+ */
88
+ let ConnectorToolsWorkersModule = class ConnectorToolsWorkersModule {
89
+ };
90
+ ConnectorToolsWorkersModule = __decorate([
91
+ Module({
92
+ imports: [ToolsModule],
93
+ providers: [ConnectorToolsProcessor],
94
+ exports: [ConnectorToolsProcessor],
95
+ })
96
+ ], ConnectorToolsWorkersModule);
97
+ export { ConnectorToolsWorkersModule };
@@ -181,6 +181,7 @@ declare const UpdateBody: z.ZodObject<{
181
181
  allowUnannotated: z.ZodOptional<z.ZodBoolean>;
182
182
  useForGit: z.ZodOptional<z.ZodBoolean>;
183
183
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
184
+ endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
184
185
  }, z.core.$strict>;
185
186
  declare const ReviewBody: z.ZodObject<{
186
187
  action: z.ZodEnum<{
@@ -199,6 +199,7 @@ export declare const ConnectorUpdateSchema: z.ZodObject<{
199
199
  allowUnannotated: z.ZodOptional<z.ZodBoolean>;
200
200
  useForGit: z.ZodOptional<z.ZodBoolean>;
201
201
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
202
+ endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
202
203
  }, z.core.$strict>;
203
204
  export declare const CONNECTOR_ROUTES: readonly RouteSchemas[];
204
205
  /**
@@ -80,6 +80,11 @@ export const ConnectorUpdateSchema = z
80
80
  useForGit: z.boolean().optional(),
81
81
  /** The connector's own description; null or blank removes it. */
82
82
  description: ConnectorDescription.nullable().optional(),
83
+ /**
84
+ * Endpoint fields of a connector made from a connector template, only at the paths its
85
+ * template lets the org edit (`editableEndpoint`); merged onto the stored endpoint.
86
+ */
87
+ endpoint: z.record(z.string(), z.unknown()).optional(),
83
88
  })
84
89
  .strict();
85
90
  export const CONNECTOR_ROUTES = [