(
pluginId: string,
input: RegisterIntegrationInput,
)
| 3042 | config.onIntegrationChange ? afterCommit(config.onIntegrationChange(event)) : Effect.void; |
| 3043 | |
| 3044 | const integrationsRegister = ( |
| 3045 | pluginId: string, |
| 3046 | input: RegisterIntegrationInput, |
| 3047 | ): Effect.Effect<void, StorageFailure> => |
| 3048 | transaction( |
| 3049 | Effect.gen(function* () { |
| 3050 | const now = new Date(); |
| 3051 | const existing = yield* findIntegrationRow(input.slug); |
| 3052 | const config = input.config === undefined ? null : input.config; |
| 3053 | if (existing) { |
| 3054 | yield* core.updateMany("integration", { |
| 3055 | where: (b: AnyCb) => b("slug", "=", String(input.slug)), |
| 3056 | set: { |
| 3057 | plugin_id: pluginId, |
| 3058 | name: input.name ?? existing.name ?? null, |
| 3059 | description: input.description, |
| 3060 | config, |
| 3061 | can_remove: input.canRemove ?? Boolean(existing.can_remove), |
| 3062 | can_refresh: input.canRefresh ?? Boolean(existing.can_refresh), |
| 3063 | updated_at: now, |
| 3064 | }, |
| 3065 | }); |
| 3066 | return false; |
| 3067 | } |
| 3068 | yield* core.create("integration", { |
| 3069 | tenant, |
| 3070 | slug: String(input.slug), |
| 3071 | plugin_id: pluginId, |
| 3072 | name: input.name ?? null, |
| 3073 | description: input.description, |
| 3074 | config, |
| 3075 | can_remove: input.canRemove ?? true, |
| 3076 | can_refresh: input.canRefresh ?? false, |
| 3077 | created_at: now, |
| 3078 | updated_at: now, |
| 3079 | }); |
| 3080 | return true; |
| 3081 | }), |
| 3082 | ).pipe( |
| 3083 | Effect.tap((created) => |
| 3084 | created |
| 3085 | ? notifyIntegrationChange({ kind: "added", pluginKey: pluginId, slug: input.slug }) |
| 3086 | : Effect.void, |
| 3087 | ), |
| 3088 | Effect.asVoid, |
| 3089 | ); |
| 3090 | |
| 3091 | const integrationsUpdate = ( |
| 3092 | slug: IntegrationSlug, |
no test coverage detected