(
ref: ConnectionRef,
)
| 3089 | }); |
| 3090 | |
| 3091 | const connectionsRemove = ( |
| 3092 | ref: ConnectionRef, |
| 3093 | ): Effect.Effect<void, ConnectionNotFoundError | StorageFailure> => |
| 3094 | transaction( |
| 3095 | Effect.gen(function* () { |
| 3096 | const row = yield* findConnectionRow(ref); |
| 3097 | if (!row) { |
| 3098 | return yield* new ConnectionNotFoundError({ |
| 3099 | owner: ref.owner, |
| 3100 | integration: ref.integration, |
| 3101 | name: ref.name, |
| 3102 | }); |
| 3103 | } |
| 3104 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 3105 | const runtime = integrationRow ? runtimes.get(integrationRow.plugin_id) : undefined; |
| 3106 | if (integrationRow && runtime?.plugin.removeConnection) { |
| 3107 | yield* runtime.plugin |
| 3108 | .removeConnection({ |
| 3109 | ctx: runtime.ctx, |
| 3110 | integration: ref.integration, |
| 3111 | connection: ref, |
| 3112 | }) |
| 3113 | .pipe( |
| 3114 | Effect.mapError((cause) => |
| 3115 | pluginStorageFailure(integrationRow.plugin_id, "removeConnection", cause), |
| 3116 | ), |
| 3117 | ); |
| 3118 | } |
| 3119 | const where = (b: AnyCb) => |
| 3120 | b.and( |
| 3121 | byOwner(ref.owner)(b), |
| 3122 | b("integration", "=", String(ref.integration)), |
| 3123 | b("connection", "=", String(ref.name)), |
| 3124 | ); |
| 3125 | yield* core.deleteMany("tool", { where }); |
| 3126 | yield* core.deleteMany("definition", { where }); |
| 3127 | yield* core.deleteMany("connection", { |
| 3128 | where: (b: AnyCb) => |
| 3129 | b.and( |
| 3130 | byOwner(ref.owner)(b), |
| 3131 | b("integration", "=", String(ref.integration)), |
| 3132 | b("name", "=", String(ref.name)), |
| 3133 | ), |
| 3134 | }); |
| 3135 | }), |
| 3136 | ); |
| 3137 | |
| 3138 | const connectionsRefresh = ( |
| 3139 | ref: ConnectionRef, |
no test coverage detected