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

Function integrationsRegister

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

Source from the content-addressed store, hash-verified

2306 config.onIntegrationChange ? afterCommit(config.onIntegrationChange(event)) : Effect.void;
2307
2308 const integrationsRegister = (
2309 pluginId: string,
2310 input: RegisterIntegrationInput,
2311 ): Effect.Effect<void, StorageFailure> =>
2312 transaction(
2313 Effect.gen(function* () {
2314 const now = new Date();
2315 const existing = yield* findIntegrationRow(input.slug);
2316 const config = input.config === undefined ? null : input.config;
2317 if (existing) {
2318 yield* core.updateMany("integration", {
2319 where: (b: AnyCb) => b("slug", "=", String(input.slug)),
2320 set: {
2321 plugin_id: pluginId,
2322 name: input.name ?? existing.name ?? null,
2323 description: input.description,
2324 config,
2325 can_remove: input.canRemove ?? Boolean(existing.can_remove),
2326 can_refresh: input.canRefresh ?? Boolean(existing.can_refresh),
2327 updated_at: now,
2328 },
2329 });
2330 return false;
2331 }
2332 yield* core.create("integration", {
2333 tenant,
2334 slug: String(input.slug),
2335 plugin_id: pluginId,
2336 name: input.name ?? null,
2337 description: input.description,
2338 config,
2339 can_remove: input.canRemove ?? true,
2340 can_refresh: input.canRefresh ?? false,
2341 created_at: now,
2342 updated_at: now,
2343 });
2344 return true;
2345 }),
2346 ).pipe(
2347 Effect.tap((created) =>
2348 created
2349 ? notifyIntegrationChange({ kind: "added", pluginKey: pluginId, slug: input.slug })
2350 : Effect.void,
2351 ),
2352 Effect.asVoid,
2353 );
2354
2355 const integrationsUpdate = (
2356 slug: IntegrationSlug,

Callers 1

createExecutorFunction · 0.85

Calls 3

findIntegrationRowFunction · 0.85
notifyIntegrationChangeFunction · 0.85
transactionFunction · 0.70

Tested by

no test coverage detected