( config: GoogleDriveIntegrationConfig, url: string, init?: RequestInit, tokenStore?: GoogleDriveTokenStore, )
| 432 | }); |
| 433 | |
| 434 | const driveFetch = ( |
| 435 | config: GoogleDriveIntegrationConfig, |
| 436 | url: string, |
| 437 | init?: RequestInit, |
| 438 | tokenStore?: GoogleDriveTokenStore, |
| 439 | ) => |
| 440 | Effect.gen(function* () { |
| 441 | const accessToken = yield* getCachedGoogleDriveAccessToken( |
| 442 | config, |
| 443 | tokenStore, |
| 444 | ); |
| 445 | let response = yield* sendDriveRequest(accessToken, url, init); |
| 446 | if (response.status === 401) { |
| 447 | yield* clearCachedGoogleDriveAccessToken(config, tokenStore); |
| 448 | const refreshedAccessToken = yield* refreshGoogleDriveAccessToken( |
| 449 | config, |
| 450 | tokenStore, |
| 451 | accessToken, |
| 452 | ); |
| 453 | response = yield* sendDriveRequest(refreshedAccessToken, url, init); |
| 454 | } |
| 455 | yield* Effect.tryPromise({ |
| 456 | try: () => assertDriveResponse(response), |
| 457 | catch: (cause) => new Storage.StorageError({ cause }), |
| 458 | }); |
| 459 | return response; |
| 460 | }); |
| 461 | |
| 462 | const getDriveFileName = (key: string) => { |
| 463 | const parts = key.split("/").filter(Boolean); |
no test coverage detected