(
ref: ConnectionRef,
)
| 3108 | }); |
| 3109 | |
| 3110 | const connectionsRemove = ( |
| 3111 | ref: ConnectionRef, |
| 3112 | ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> => |
| 3113 | transaction( |
| 3114 | Effect.gen(function* () { |
| 3115 | const row = yield* findConnectionRow(ref); |
| 3116 | if (!row) { |
| 3117 | return yield* new ConnectionNotFoundError({ |
| 3118 | owner: ref.owner, |
| 3119 | integration: ref.integration, |
| 3120 | name: ref.name, |
| 3121 | }); |
| 3122 | } |
| 3123 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 3124 | const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined; |
| 3125 | if (integrationRow && runtime?.plugin.removeConnection) { |
| 3126 | yield* runtime.plugin |
| 3127 | .removeConnection({ |
| 3128 | ctx: runtime.ctx, |
| 3129 | integration: ref.integration, |
| 3130 | connection: ref, |
| 3131 | }) |
| 3132 | .pipe( |
| 3133 | Effect.mapError((cause) => |
| 3134 | pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause), |
| 3135 | ), |
| 3136 | ); |
| 3137 | } |
| 3138 | const where = (b: AnyCb) => |
| 3139 | b.and( |
| 3140 | byOwner(ref.owner)(b), |
| 3141 | b("integration", "=", String(ref.integration)), |
| 3142 | b("connection", "=", String(ref.name)), |
| 3143 | ); |
| 3144 | yield* core.deleteMany("tool", { where }); |
| 3145 | yield* core.deleteMany("definition", { where }); |
| 3146 | yield* core.deleteMany("connection", { |
| 3147 | where: (b: AnyCb) => |
| 3148 | b.and( |
| 3149 | byOwner(ref.owner)(b), |
| 3150 | b("integration", "=", String(ref.integration)), |
| 3151 | b("name", "=", String(ref.name)), |
| 3152 | ), |
| 3153 | }); |
| 3154 | }), |
| 3155 | ); |
| 3156 | |
| 3157 | const connectionsRefresh = ( |
| 3158 | ref: ConnectionRef, |
no test coverage detected