MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / integrationsRegister

Function integrationsRegister

packages/core/sdk/src/executor.ts:2354–2399  ·  view source on GitHub ↗
(
      pluginId: string,
      input: RegisterIntegrationInput,
    )

Source from the content-addressed store, hash-verified

2352 config.onIntegrationChange ? afterCommit(config.onIntegrationChange(event)) : Effect.void;
2353
2354 const integrationsRegister = (
2355 pluginId: string,
2356 input: RegisterIntegrationInput,
2357 ): Effect.Effect<void, StorageFailure> =>
2358 transaction(
2359 Effect.gen(function* () {
2360 const now = new Date();
2361 const existing = yield* findIntegrationRow(input.slug);
2362 const config = input.config === undefined ? null : input.config;
2363 if (existing) {
2364 yield* core.updateMany("integration", {
2365 where: (b: AnyCb) => b("slug", "=", String(input.slug)),
2366 set: {
2367 plugin_id: pluginId,
2368 name: input.name ?? existing.name ?? null,
2369 description: input.description,
2370 config,
2371 can_remove: input.canRemove ?? Boolean(existing.can_remove),
2372 can_refresh: input.canRefresh ?? Boolean(existing.can_refresh),
2373 updated_at: now,
2374 },
2375 });
2376 return false;
2377 }
2378 yield* core.create("integration", {
2379 tenant,
2380 slug: String(input.slug),
2381 plugin_id: pluginId,
2382 name: input.name ?? null,
2383 description: input.description,
2384 config,
2385 can_remove: input.canRemove ?? true,
2386 can_refresh: input.canRefresh ?? false,
2387 created_at: now,
2388 updated_at: now,
2389 });
2390 return true;
2391 }),
2392 ).pipe(
2393 Effect.tap((created) =>
2394 created
2395 ? notifyIntegrationChange({ kind: "added", pluginKey: pluginId, slug: input.slug })
2396 : Effect.void,
2397 ),
2398 Effect.asVoid,
2399 );
2400
2401 const integrationsUpdate = (
2402 slug: IntegrationSlug,

Callers 1

createExecutorFunction · 0.85

Calls 3

findIntegrationRowFunction · 0.85
notifyIntegrationChangeFunction · 0.85
transactionFunction · 0.70

Tested by

no test coverage detected