-
Notifications
You must be signed in to change notification settings - Fork 311
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
1 parent
8bfe287
commit 24c38cf
Showing
47 changed files
with
566 additions
and
518 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
examples/__outputs__/20_output/output_envelope_envelope-error__envelope-error.output.txt
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,20 +1,20 @@ | ||
---------------------------------------- SHOW ---------------------------------------- | ||
{ | ||
errors: [ | ||
ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode". | ||
ContextualError: There was an error in the interceptor "anonymous" (use named functions to improve this error message) while running hook "encode". | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX:18) | ||
at async Object.run (/some/path/to/main.ts:XX:XX:22) | ||
at async Object.run (/some/path/to/runner.ts:XX:XX:20) | ||
at async executeDocument (/some/path/to/requestMethods.ts:XX:XX:18) | ||
at async executeRootField (/some/path/to/requestMethods.ts:XX:XX:18) | ||
at async <anonymous> (/some/path/to/output_envelope_envelope-error__envelope-error.ts:XX:XX:16) { | ||
context: { | ||
hookName: 'encode', | ||
source: 'extension', | ||
extensionName: 'anonymous' | ||
interceptorName: 'anonymous' | ||
}, | ||
cause: Error: Something went wrong. | ||
at <anonymous> (/some/path/to/output_envelope_envelope-error__envelope-error.ts:XX:XX:11) | ||
at applyBody (/some/path/to/main.ts:XX:XX:28) | ||
at applyBody (/some/path/to/runner.ts:XX:XX:28) | ||
} | ||
] | ||
} |
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
8 changes: 4 additions & 4 deletions
8
examples/__outputs__/20_output/output_return-error.output.txt
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,16 +1,16 @@ | ||
---------------------------------------- SHOW ---------------------------------------- | ||
ContextualError: There was an error in the extension "anonymous" (use named functions to improve this error message) while running hook "encode". | ||
ContextualError: There was an error in the interceptor "anonymous" (use named functions to improve this error message) while running hook "encode". | ||
at runPipeline (/some/path/to/runPipeline.ts:XX:XX:18) | ||
at async Object.run (/some/path/to/main.ts:XX:XX:22) | ||
at async Object.run (/some/path/to/runner.ts:XX:XX:20) | ||
at async executeDocument (/some/path/to/requestMethods.ts:XX:XX:18) | ||
at async executeRootField (/some/path/to/requestMethods.ts:XX:XX:18) | ||
at async <anonymous> (/some/path/to/output_return-error.ts:XX:XX:18) { | ||
context: { | ||
hookName: 'encode', | ||
source: 'extension', | ||
extensionName: 'anonymous' | ||
interceptorName: 'anonymous' | ||
}, | ||
cause: Error: Something went wrong. | ||
at <anonymous> (/some/path/to/output_return-error.ts:XX:XX:11) | ||
at applyBody (/some/path/to/main.ts:XX:XX:28) | ||
at applyBody (/some/path/to/runner.ts:XX:XX:28) | ||
} |
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
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,62 @@ | ||
import type { Deferred, MaybePromise } from '../prelude.js' | ||
import type { Private } from '../private.js' | ||
import type { InferPublicHooks, SomePublicHookEnvelope } from './hook/public.js' | ||
import type { Pipeline } from './Pipeline.js' | ||
|
||
export type InterceptorOptions = { | ||
retrying: boolean | ||
} | ||
|
||
export type Interceptor< | ||
$Core extends Pipeline = Pipeline, | ||
$Options extends InterceptorOptions = InterceptorOptions, | ||
> = ( | ||
hooks: InferPublicHooks< | ||
Private.Get<$Core>['hookSequence'], | ||
Private.Get<$Core>['hookMap'], | ||
Private.Get<$Core>['result'], | ||
$Options | ||
>, | ||
) => Promise< | ||
| Private.Get<$Core>['result'] | ||
| SomePublicHookEnvelope | ||
> | ||
|
||
export type InterceptorGeneric = NonRetryingInterceptor | RetryingInterceptor | ||
|
||
export type NonRetryingInterceptor = { | ||
retrying: false | ||
name: string | ||
entrypoint: string | ||
body: Deferred<unknown> | ||
currentChunk: Deferred<SomePublicHookEnvelope /* | unknown (result) */> | ||
} | ||
|
||
export type RetryingInterceptor = { | ||
retrying: true | ||
name: string | ||
entrypoint: string | ||
body: Deferred<unknown> | ||
currentChunk: Deferred<SomePublicHookEnvelope | Error /* | unknown (result) */> | ||
} | ||
|
||
export const createRetryingInterceptor = (extension: NonRetryingInterceptorInput): RetryingInterceptorInput => { | ||
return { | ||
retrying: true, | ||
run: extension, | ||
} | ||
} | ||
|
||
// export type ExtensionInput<$Input extends object = object> = (input: $Input) => MaybePromise<unknown> | ||
export type InterceptorInput<$Input extends object = any> = | ||
| NonRetryingInterceptorInput<$Input> | ||
| RetryingInterceptorInput<$Input> | ||
|
||
export type NonRetryingInterceptorInput<$Input extends object = any> = ( | ||
input: $Input, | ||
) => MaybePromise<unknown> | ||
|
||
export type RetryingInterceptorInput<$Input extends object = any> = { | ||
retrying: boolean | ||
run: (input: $Input) => MaybePromise<unknown> | ||
} |
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
Oops, something went wrong.