(
pluginId: string,
input: RegisterIntegrationInput,
)
| 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, |
no test coverage detected