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

Function integrationsRegister

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

Source from the content-addressed store, hash-verified

2211 config.onIntegrationChange ? afterCommit(config.onIntegrationChange(event)) : Effect.void;
2212
2213 const integrationsRegister = (
2214 pluginId: string,
2215 input: RegisterIntegrationInput,
2216 ): Effect.Effect<void, StorageFailure> =>
2217 transaction(
2218 Effect.gen(function* () {
2219 const now = new Date();
2220 const existing = yield* findIntegrationRow(input.slug);
2221 const config = input.config === undefined ? null : input.config;
2222 if (existing) {
2223 yield* core.updateMany("integration", {
2224 where: (b: AnyCb) => b("slug", "=", String(input.slug)),
2225 set: {
2226 plugin_id: pluginId,
2227 name: input.name ?? existing.name ?? null,
2228 description: input.description,
2229 config,
2230 can_remove: input.canRemove ?? Boolean(existing.can_remove),
2231 can_refresh: input.canRefresh ?? Boolean(existing.can_refresh),
2232 updated_at: now,
2233 },
2234 });
2235 return false;
2236 }
2237 yield* core.create("integration", {
2238 tenant,
2239 slug: String(input.slug),
2240 plugin_id: pluginId,
2241 name: input.name ?? null,
2242 description: input.description,
2243 config,
2244 can_remove: input.canRemove ?? true,
2245 can_refresh: input.canRefresh ?? false,
2246 created_at: now,
2247 updated_at: now,
2248 });
2249 return true;
2250 }),
2251 ).pipe(
2252 Effect.tap((created) =>
2253 created
2254 ? notifyIntegrationChange({ kind: "added", pluginKey: pluginId, slug: input.slug })
2255 : Effect.void,
2256 ),
2257 Effect.asVoid,
2258 );
2259
2260 const integrationsUpdate = (
2261 slug: IntegrationSlug,

Callers 1

createExecutorFunction · 0.85

Calls 3

findIntegrationRowFunction · 0.85
notifyIntegrationChangeFunction · 0.85
transactionFunction · 0.70

Tested by

no test coverage detected