Skip to content

Commit

Permalink
refactor: update exports in index.ts and add ServiceFn type in servic…
Browse files Browse the repository at this point in the history
…es.ts
  • Loading branch information
braden-w committed Dec 23, 2024
1 parent 0cf54d2 commit b4a0bc4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-falcons-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@epicenterhq/result": patch
---

Add ServiceFn type and update exports in index.ts
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { createMutation } from "./mutations";
export { Err, Ok, Result, tryAsync, trySync } from "./result";
export { createMutation, QueryFn } from "./query";
export { createServiceErrorFns } from "./services";
export { ServiceFn, createServiceErrorFns } from "./services";
4 changes: 0 additions & 4 deletions src/query.ts → src/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { Result } from "./result";
import { Ok } from "./result";

export type QueryFn<I, O, ServiceErrorProperties> = (
input: I,
) => Promise<Result<O, ServiceErrorProperties>>;

export function createMutation<I, O, ServiceError, TContext = undefined>({
mutationFn,
onMutate = () => Ok(undefined as TContext),
Expand Down
4 changes: 4 additions & 0 deletions src/services.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { Result } from "./result";
import { Err, tryAsync, trySync } from "./result";

export type ServiceFn<I, O, ServiceErrorProperties> = (
input: I,
) => Promise<Result<O, ServiceErrorProperties>>;

type ServiceErrorFns<ServiceErrorProperties> = {
Err: (props: ServiceErrorProperties) => Err<ServiceErrorProperties>;
trySync: <T>(opts: {
Expand Down

0 comments on commit b4a0bc4

Please sign in to comment.