(fn: () => Promise<A>, operation: string)
| 147 | }).pipe(timeoutWithOnePasswordError("client setup", timeoutMs)); |
| 148 | |
| 149 | const wrap = <A>(fn: () => Promise<A>, operation: string): Effect.Effect<A, OnePasswordError> => |
| 150 | Effect.tryPromise({ |
| 151 | try: fn, |
| 152 | catch: (cause) => |
| 153 | new OnePasswordError({ |
| 154 | operation, |
| 155 | message: messageWithCause(`1Password SDK ${operation} failed`, cause), |
| 156 | }), |
| 157 | }).pipe( |
| 158 | timeoutWithOnePasswordError(operation, timeoutMs), |
| 159 | Effect.withSpan(`onepassword.sdk.${operation}`), |
| 160 | ); |
| 161 | |
| 162 | return OnePasswordServiceTag.of({ |
| 163 | resolveSecret: (uri) => wrap(() => client.secrets.resolve(uri), "secret resolution"), |
no test coverage detected