(fn: (client: Autumn) => Promise<A>)
| 118 | }); |
| 119 | |
| 120 | const use = <A>(fn: (client: Autumn) => Promise<A>) => |
| 121 | Effect.tryPromise({ |
| 122 | try: () => fn(client), |
| 123 | catch: (cause): AutumnFailure => |
| 124 | isCustomerNotFoundCause(cause) |
| 125 | ? new AutumnCustomerNotFoundError({ |
| 126 | message: "Autumn has no customer for this organization", |
| 127 | cause, |
| 128 | }) |
| 129 | : new AutumnError({ message: "Autumn SDK request failed", cause }), |
| 130 | // An inline arrow's `name` is "" — not nullish — so `??` left every |
| 131 | // Autumn call tracing as the bare span `autumn.`. |
| 132 | }).pipe(Effect.withSpan(`autumn.${fn.name || "use"}`)); |
| 133 | |
| 134 | const ensureCustomer = (organizationId: string) => |
| 135 | Effect.asVoid(use((c) => c.customers.getOrCreate({ customerId: organizationId }))); |
no test coverage detected