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

Function use

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

Source from the content-addressed store, hash-verified

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 })));

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