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

Function use

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

Source from the content-addressed store, hash-verified

129 });
130
131 const use = <A>(fn: (client: Autumn) => Promise<A>) =>
132 Effect.tryPromise({
133 try: () => fn(client),
134 catch: (cause): AutumnFailure =>
135 isCustomerNotFoundCause(cause)
136 ? new AutumnCustomerNotFoundError({
137 message: "Autumn has no customer for this organization",
138 cause,
139 })
140 : new AutumnError({ message: "Autumn SDK request failed", cause }),
141 // An inline arrow's `name` is "" — not nullish — so `??` left every
142 // Autumn call tracing as the bare span `autumn.`.
143 }).pipe(Effect.withSpan(`autumn.${fn.name || "use"}`));
144
145 const ensureCustomer = (organizationId: string) =>
146 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