(
pluginId: string,
input: RegisterIntegrationInput,
)
| 2872 | config.onIntegrationChange ? afterCommit(config.onIntegrationChange(event)) : Effect.void; |
| 2873 | |
| 2874 | const integrationsRegister = ( |
| 2875 | pluginId: string, |
| 2876 | input: RegisterIntegrationInput, |
| 2877 | ): Effect.Effect<void, StorageFailure> => |
| 2878 | transaction( |
| 2879 | Effect.gen(function* () { |
| 2880 | const now = new Date(); |
| 2881 | const existing = yield* findIntegrationRow(input.slug); |
| 2882 | const config = input.config === undefined ? null : input.config; |
| 2883 | if (existing) { |
| 2884 | yield* core.updateMany("integration", { |
| 2885 | where: (b: AnyCb) => b("slug", "=", String(input.slug)), |
| 2886 | set: { |
| 2887 | plugin_id: pluginId, |
| 2888 | name: input.name ?? existing.name ?? null, |
| 2889 | description: input.description, |
| 2890 | config, |
| 2891 | can_remove: input.canRemove ?? Boolean(existing.can_remove), |
| 2892 | can_refresh: input.canRefresh ?? Boolean(existing.can_refresh), |
| 2893 | updated_at: now, |
| 2894 | }, |
| 2895 | }); |
| 2896 | return false; |
| 2897 | } |
| 2898 | yield* core.create("integration", { |
| 2899 | tenant, |
| 2900 | slug: String(input.slug), |
| 2901 | plugin_id: pluginId, |
| 2902 | name: input.name ?? null, |
| 2903 | description: input.description, |
| 2904 | config, |
| 2905 | can_remove: input.canRemove ?? true, |
| 2906 | can_refresh: input.canRefresh ?? false, |
| 2907 | created_at: now, |
| 2908 | updated_at: now, |
| 2909 | }); |
| 2910 | return true; |
| 2911 | }), |
| 2912 | ).pipe( |
| 2913 | Effect.tap((created) => |
| 2914 | created |
| 2915 | ? notifyIntegrationChange({ kind: "added", pluginKey: pluginId, slug: input.slug }) |
| 2916 | : Effect.void, |
| 2917 | ), |
| 2918 | Effect.asVoid, |
| 2919 | ); |
| 2920 | |
| 2921 | const integrationsUpdate = ( |
| 2922 | slug: IntegrationSlug, |
no test coverage detected