(
pluginId: string,
input: RegisterIntegrationInput,
)
| 1842 | ); |
| 1843 | |
| 1844 | const integrationsRegister = ( |
| 1845 | pluginId: string, |
| 1846 | input: RegisterIntegrationInput, |
| 1847 | ): Effect.Effect<void, StorageFailure> => |
| 1848 | transaction( |
| 1849 | Effect.gen(function* () { |
| 1850 | const now = new Date(); |
| 1851 | const existing = yield* findIntegrationRow(input.slug); |
| 1852 | const config = input.config === undefined ? null : input.config; |
| 1853 | if (existing) { |
| 1854 | yield* core.updateMany("integration", { |
| 1855 | where: (b: AnyCb) => b("slug", "=", String(input.slug)), |
| 1856 | set: { |
| 1857 | plugin_id: pluginId, |
| 1858 | name: input.name ?? existing.name ?? null, |
| 1859 | description: input.description, |
| 1860 | config, |
| 1861 | can_remove: input.canRemove ?? Boolean(existing.can_remove), |
| 1862 | can_refresh: input.canRefresh ?? Boolean(existing.can_refresh), |
| 1863 | updated_at: now, |
| 1864 | }, |
| 1865 | }); |
| 1866 | return; |
| 1867 | } |
| 1868 | yield* core.create("integration", { |
| 1869 | tenant, |
| 1870 | slug: String(input.slug), |
| 1871 | plugin_id: pluginId, |
| 1872 | name: input.name ?? null, |
| 1873 | description: input.description, |
| 1874 | config, |
| 1875 | can_remove: input.canRemove ?? true, |
| 1876 | can_refresh: input.canRefresh ?? false, |
| 1877 | created_at: now, |
| 1878 | updated_at: now, |
| 1879 | }); |
| 1880 | }), |
| 1881 | ); |
| 1882 | |
| 1883 | const integrationsUpdate = ( |
| 1884 | slug: IntegrationSlug, |
no test coverage detected