-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
734 additions
and
671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as TE from 'fp-ts/TaskEither'; | ||
import { timeout } from '../timeout'; | ||
|
||
export const timeoutTE = (ms: number) => TE.fromTask(async () => timeout(ms)); | ||
|
||
export const delayTaskEither = | ||
<TE>(time: number) => | ||
(task: TE): TE => | ||
TE.chainFirst(() => async () => { | ||
await timeout(time); | ||
return TE.of(undefined) as any; | ||
})(task as any) as TE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export * from './catch-task-either-tagged-error-te'; | ||
export * from './delay-task-either'; | ||
export * from './tap-task-either-error-te'; | ||
export * from './tap-task-either-error'; | ||
export * from './tap-task-either'; | ||
export * from './try-or-throw'; | ||
export * from './try-tagged-error-task'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { task as T, either as E } from 'fp-ts'; | ||
import { pipe } from 'fp-ts/function'; | ||
|
||
import type { TaskEither } from 'fp-ts/TaskEither'; | ||
|
||
export const tryOrThrow = <E, A>(taskEither: TaskEither<E, A>): T.Task<A> => | ||
pipe( | ||
taskEither, | ||
T.map(either => { | ||
if (E.isLeft(either)) { | ||
throw either.left; | ||
} | ||
|
||
return either.right; | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const timeout = async (ms: number) => | ||
new Promise(resolve => { | ||
setTimeout(resolve, ms); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type CanBePromise<T> = T | Promise<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './can-be-promise.types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type ID = string | number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './tagged-task-either.types'; | ||
export * from './tagged-error.types'; | ||
export * from './tagged-task-either.types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from './can-be'; | ||
export * from './entity.types'; | ||
export * from './fp-ts'; | ||
export * from './value-object.types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
packages/reindex/src/+internal/client/es-monadic-client.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
export type EsDocId = string | number; | ||
import type { ID } from '@searchpunch/core'; | ||
|
||
export type EsDoc<I> = I & { | ||
_id: ID; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export * from './es-monadic-client.error'; | ||
export * from './es-monadic-client'; | ||
export * from './es-monadic-client.types'; | ||
export * from './try-es-task'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { EsDoc } from '+internal'; | ||
import type { CanBePromise, ID } from '@searchpunch/core'; | ||
|
||
export type EsDbAsyncIdIterator = AsyncIterableIterator<ID[]>; | ||
|
||
export type EsIndexDbAdapter<Doc> = { | ||
createAllEntitiesIdsIterator: () => EsDbAsyncIdIterator; | ||
findEntities: (ids: ID[]) => CanBePromise<Array<EsDoc<Doc>>>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { TaggedError } from '@searchpunch/core'; | ||
|
||
export class EsIndexBulkReindexError extends TaggedError.ofLiteral( | ||
'EsIndexBulkReindexError', | ||
) {} | ||
|
||
export class EsIndexStreamReindexError extends TaggedError.ofLiteral( | ||
'EsIndexStreamReindexError', | ||
) {} | ||
|
||
export class EsIndexSingleReindexError extends TaggedError.ofLiteral( | ||
'EsIndexSingleReindexError', | ||
) {} |
Oops, something went wrong.