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

Function use

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

Source from the content-addressed store, hash-verified

107 });
108
109 const use = <A>(fn: (client: Autumn) => Promise<A>) =>
110 Effect.tryPromise({
111 try: () => fn(client),
112 catch: (cause): AutumnFailure =>
113 isCustomerNotFoundCause(cause)
114 ? new AutumnCustomerNotFoundError({
115 message: "Autumn has no customer for this organization",
116 cause,
117 })
118 : new AutumnError({ message: "Autumn SDK request failed", cause }),
119 // An inline arrow's `name` is "" — not nullish — so `??` left every
120 // Autumn call tracing as the bare span `autumn.`.
121 }).pipe(Effect.withSpan(`autumn.${fn.name || "use"}`));
122
123 const ensureCustomer = (organizationId: string) =>
124 Effect.asVoid(use((c) => c.customers.getOrCreate({ customerId: organizationId })));

Callers 3

ensureCustomerFunction · 0.70
trackExecutionFunction · 0.70
checkExecutionBalanceFunction · 0.70

Calls 1

isCustomerNotFoundCauseFunction · 0.85

Tested by

no test coverage detected