(
pluginId: string,
input: RegisterIntegrationInput,
)
| 1885 | ); |
| 1886 | |
| 1887 | const integrationsRegister = ( |
| 1888 | pluginId: string, |
| 1889 | input: RegisterIntegrationInput, |
| 1890 | ): Effect.Effect<void, StorageFailure> => |
| 1891 | transaction( |
| 1892 | Effect.gen(function* () { |
| 1893 | const now = new Date(); |
| 1894 | const existing = yield* findIntegrationRow(input.slug); |
| 1895 | const config = input.config === undefined ? null : input.config; |
| 1896 | if (existing) { |
| 1897 | yield* core.updateMany("integration", { |
| 1898 | where: (b: AnyCb) => b("slug", "=", String(input.slug)), |
| 1899 | set: { |
| 1900 | plugin_id: pluginId, |
| 1901 | name: input.name ?? existing.name ?? null, |
| 1902 | description: input.description, |
| 1903 | config, |
| 1904 | can_remove: input.canRemove ?? Boolean(existing.can_remove), |
| 1905 | can_refresh: input.canRefresh ?? Boolean(existing.can_refresh), |
| 1906 | updated_at: now, |
| 1907 | }, |
| 1908 | }); |
| 1909 | return; |
| 1910 | } |
| 1911 | yield* core.create("integration", { |
| 1912 | tenant, |
| 1913 | slug: String(input.slug), |
| 1914 | plugin_id: pluginId, |
| 1915 | name: input.name ?? null, |
| 1916 | description: input.description, |
| 1917 | config, |
| 1918 | can_remove: input.canRemove ?? true, |
| 1919 | can_refresh: input.canRefresh ?? false, |
| 1920 | created_at: now, |
| 1921 | updated_at: now, |
| 1922 | }); |
| 1923 | }), |
| 1924 | ); |
| 1925 | |
| 1926 | const integrationsUpdate = ( |
| 1927 | slug: IntegrationSlug, |
no test coverage detected