(
ref: ConnectionRef,
)
| 3008 | }); |
| 3009 | |
| 3010 | const connectionsRemove = ( |
| 3011 | ref: ConnectionRef, |
| 3012 | ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> => |
| 3013 | transaction( |
| 3014 | Effect.gen(function* () { |
| 3015 | const row = yield* findConnectionRow(ref); |
| 3016 | if (!row) { |
| 3017 | return yield* new ConnectionNotFoundError({ |
| 3018 | owner: ref.owner, |
| 3019 | integration: ref.integration, |
| 3020 | name: ref.name, |
| 3021 | }); |
| 3022 | } |
| 3023 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 3024 | const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined; |
| 3025 | if (integrationRow && runtime?.plugin.removeConnection) { |
| 3026 | yield* runtime.plugin |
| 3027 | .removeConnection({ |
| 3028 | ctx: runtime.ctx, |
| 3029 | integration: ref.integration, |
| 3030 | connection: ref, |
| 3031 | }) |
| 3032 | .pipe( |
| 3033 | Effect.mapError((cause) => |
| 3034 | pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause), |
| 3035 | ), |
| 3036 | ); |
| 3037 | } |
| 3038 | const where = (b: AnyCb) => |
| 3039 | b.and( |
| 3040 | byOwner(ref.owner)(b), |
| 3041 | b("integration", "=", String(ref.integration)), |
| 3042 | b("connection", "=", String(ref.name)), |
| 3043 | ); |
| 3044 | yield* core.deleteMany("tool", { where }); |
| 3045 | yield* core.deleteMany("definition", { where }); |
| 3046 | yield* core.deleteMany("connection", { |
| 3047 | where: (b: AnyCb) => |
| 3048 | b.and( |
| 3049 | byOwner(ref.owner)(b), |
| 3050 | b("integration", "=", String(ref.integration)), |
| 3051 | b("name", "=", String(ref.name)), |
| 3052 | ), |
| 3053 | }); |
| 3054 | }), |
| 3055 | ); |
| 3056 | |
| 3057 | const connectionsRefresh = ( |
| 3058 | ref: ConnectionRef, |
no test coverage detected