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

Function integrationsRegister

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

Source from the content-addressed store, hash-verified

2292 config.onIntegrationChange ? afterCommit(config.onIntegrationChange(event)) : Effect.void;
2293
2294 const integrationsRegister = (
2295 pluginId: string,
2296 input: RegisterIntegrationInput,
2297 ): Effect.Effect<void, StorageFailure> =>
2298 transaction(
2299 Effect.gen(function* () {
2300 const now = new Date();
2301 const existing = yield* findIntegrationRow(input.slug);
2302 const config = input.config === undefined ? null : input.config;
2303 if (existing) {
2304 yield* core.updateMany("integration", {
2305 where: (b: AnyCb) => b("slug", "=", String(input.slug)),
2306 set: {
2307 plugin_id: pluginId,
2308 name: input.name ?? existing.name ?? null,
2309 description: input.description,
2310 config,
2311 can_remove: input.canRemove ?? Boolean(existing.can_remove),
2312 can_refresh: input.canRefresh ?? Boolean(existing.can_refresh),
2313 updated_at: now,
2314 },
2315 });
2316 return false;
2317 }
2318 yield* core.create("integration", {
2319 tenant,
2320 slug: String(input.slug),
2321 plugin_id: pluginId,
2322 name: input.name ?? null,
2323 description: input.description,
2324 config,
2325 can_remove: input.canRemove ?? true,
2326 can_refresh: input.canRefresh ?? false,
2327 created_at: now,
2328 updated_at: now,
2329 });
2330 return true;
2331 }),
2332 ).pipe(
2333 Effect.tap((created) =>
2334 created
2335 ? notifyIntegrationChange({ kind: "added", pluginKey: pluginId, slug: input.slug })
2336 : Effect.void,
2337 ),
2338 Effect.asVoid,
2339 );
2340
2341 const integrationsUpdate = (
2342 slug: IntegrationSlug,

Callers 1

createExecutorFunction · 0.85

Calls 3

findIntegrationRowFunction · 0.85
notifyIntegrationChangeFunction · 0.85
transactionFunction · 0.70

Tested by

no test coverage detected