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

Function integrationsRegister

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

Source from the content-addressed store, hash-verified

1960 );
1961
1962 const integrationsRegister = (
1963 pluginId: string,
1964 input: RegisterIntegrationInput,
1965 ): Effect.Effect<void, StorageFailure> =>
1966 transaction(
1967 Effect.gen(function* () {
1968 const now = new Date();
1969 const existing = yield* findIntegrationRow(input.slug);
1970 const config = input.config === undefined ? null : input.config;
1971 if (existing) {
1972 yield* core.updateMany("integration", {
1973 where: (b: AnyCb) => b("slug", "=", String(input.slug)),
1974 set: {
1975 plugin_id: pluginId,
1976 name: input.name ?? existing.name ?? null,
1977 description: input.description,
1978 config,
1979 can_remove: input.canRemove ?? Boolean(existing.can_remove),
1980 can_refresh: input.canRefresh ?? Boolean(existing.can_refresh),
1981 updated_at: now,
1982 },
1983 });
1984 return;
1985 }
1986 yield* core.create("integration", {
1987 tenant,
1988 slug: String(input.slug),
1989 plugin_id: pluginId,
1990 name: input.name ?? null,
1991 description: input.description,
1992 config,
1993 can_remove: input.canRemove ?? true,
1994 can_refresh: input.canRefresh ?? false,
1995 created_at: now,
1996 updated_at: now,
1997 });
1998 }),
1999 );
2000
2001 const integrationsUpdate = (
2002 slug: IntegrationSlug,

Callers 1

createExecutorFunction · 0.85

Calls 2

findIntegrationRowFunction · 0.85
transactionFunction · 0.70

Tested by

no test coverage detected