MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / use

Function use

apps/cloud/src/extensions/billing/service.ts:165–177  ·  view source on GitHub ↗
(fn: (client: Autumn) => Promise<A>)

Source from the content-addressed store, hash-verified

163 });
164
165 const use = <A>(fn: (client: Autumn) => Promise<A>) =>
166 Effect.tryPromise({
167 try: () => fn(client),
168 catch: (cause): AutumnFailure =>
169 isCustomerNotFoundCause(cause)
170 ? new AutumnCustomerNotFoundError({
171 message: "Autumn has no customer for this organization",
172 cause,
173 })
174 : new AutumnError({ message: "Autumn SDK request failed", cause }),
175 // An inline arrow's `name` is "" — not nullish — so `??` left every
176 // Autumn call tracing as the bare span `autumn.`.
177 }).pipe(Effect.withSpan(`autumn.${fn.name || "use"}`));
178
179 const ensureCustomer = (organizationId: string) =>
180 Effect.asVoid(use((c) => c.customers.getOrCreate({ customerId: organizationId })));

Callers 4

ensureCustomerFunction · 0.70
trackExecutionFunction · 0.70
setMemberSeatsFunction · 0.70
checkExecutionBalanceFunction · 0.70

Calls 1

isCustomerNotFoundCauseFunction · 0.85

Tested by

no test coverage detected