(
pluginId: string,
input: RegisterIntegrationInput,
)
| 1869 | ); |
| 1870 | |
| 1871 | const integrationsRegister = ( |
| 1872 | pluginId: string, |
| 1873 | input: RegisterIntegrationInput, |
| 1874 | ): Effect.Effect<void, StorageFailure> => |
| 1875 | transaction( |
| 1876 | Effect.gen(function* () { |
| 1877 | const now = new Date(); |
| 1878 | const existing = yield* findIntegrationRow(input.slug); |
| 1879 | const config = input.config === undefined ? null : input.config; |
| 1880 | if (existing) { |
| 1881 | yield* core.updateMany("integration", { |
| 1882 | where: (b: AnyCb) => b("slug", "=", String(input.slug)), |
| 1883 | set: { |
| 1884 | plugin_id: pluginId, |
| 1885 | name: input.name ?? existing.name ?? null, |
| 1886 | description: input.description, |
| 1887 | config, |
| 1888 | can_remove: input.canRemove ?? Boolean(existing.can_remove), |
| 1889 | can_refresh: input.canRefresh ?? Boolean(existing.can_refresh), |
| 1890 | updated_at: now, |
| 1891 | }, |
| 1892 | }); |
| 1893 | return; |
| 1894 | } |
| 1895 | yield* core.create("integration", { |
| 1896 | tenant, |
| 1897 | slug: String(input.slug), |
| 1898 | plugin_id: pluginId, |
| 1899 | name: input.name ?? null, |
| 1900 | description: input.description, |
| 1901 | config, |
| 1902 | can_remove: input.canRemove ?? true, |
| 1903 | can_refresh: input.canRefresh ?? false, |
| 1904 | created_at: now, |
| 1905 | updated_at: now, |
| 1906 | }); |
| 1907 | }), |
| 1908 | ); |
| 1909 | |
| 1910 | const integrationsUpdate = ( |
| 1911 | slug: IntegrationSlug, |
no test coverage detected