@zapier/kitcore 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/index.cjs +38 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +46 -2
- package/dist/index.d.ts +46 -2
- package/dist/index.mjs +38 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -4530,6 +4530,28 @@ declare const attemptHttpRequestPlugin: MethodPlugin<"attemptHttpRequest", Attem
|
|
|
4530
4530
|
*/
|
|
4531
4531
|
declare const initializeHttpRequestPlugin: MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>;
|
|
4532
4532
|
|
|
4533
|
+
/**
|
|
4534
|
+
* Details about a retry the loop has scheduled.
|
|
4535
|
+
*
|
|
4536
|
+
* `request` preserves the caller's request-object identity so observers can
|
|
4537
|
+
* correlate the retry with its originating call. `delayMilliseconds` is the
|
|
4538
|
+
* exact delay selected by the loop.
|
|
4539
|
+
*/
|
|
4540
|
+
interface RetryHttpRequestAttempt {
|
|
4541
|
+
request: HttpRequest;
|
|
4542
|
+
operationId: string;
|
|
4543
|
+
/** 1-based number of the attempt that just failed. */
|
|
4544
|
+
attemptNumber: number;
|
|
4545
|
+
delayMilliseconds: number;
|
|
4546
|
+
/**
|
|
4547
|
+
* The response being retried. Its body is released as soon as the observer
|
|
4548
|
+
* returns, so read status and headers only. Absent when the attempt threw
|
|
4549
|
+
* instead of answering.
|
|
4550
|
+
*/
|
|
4551
|
+
response?: HttpResponse;
|
|
4552
|
+
/** The error the attempt threw, when `retryOnError` is on. */
|
|
4553
|
+
error?: unknown;
|
|
4554
|
+
}
|
|
4533
4555
|
/**
|
|
4534
4556
|
* Options for {@link retryHttpRequestPlugin}, supplied by id like every other
|
|
4535
4557
|
* kitcore configuration value. Absent means the defaults below.
|
|
@@ -4537,7 +4559,13 @@ declare const initializeHttpRequestPlugin: MethodPlugin<"initializeHttpRequest",
|
|
|
4537
4559
|
interface RetryHttpRequestOptions {
|
|
4538
4560
|
/** Total attempts including the first. Default 3. */
|
|
4539
4561
|
maxAttempts?: number;
|
|
4540
|
-
/**
|
|
4562
|
+
/**
|
|
4563
|
+
* Requested ceiling for a retry wait. Default 60 seconds.
|
|
4564
|
+
*
|
|
4565
|
+
* Server-specified delays above this limit stop retrying. Generated backoff
|
|
4566
|
+
* is capped at this value, then raised to `MIN_BACKOFF_MILLISECONDS` when
|
|
4567
|
+
* needed to preserve a minimum wait.
|
|
4568
|
+
*/
|
|
4541
4569
|
maxDelayMilliseconds?: number;
|
|
4542
4570
|
/** Statuses to retry on an idempotent method. Default 429, 500, 502, 503, 504. */
|
|
4543
4571
|
retryStatuses?: readonly number[];
|
|
@@ -4556,6 +4584,22 @@ interface RetryHttpRequestOptions {
|
|
|
4556
4584
|
* choice rather than a default.
|
|
4557
4585
|
*/
|
|
4558
4586
|
retryOnError?: boolean;
|
|
4587
|
+
/**
|
|
4588
|
+
* Called when the loop schedules a retry, after selecting the delay and
|
|
4589
|
+
* before waiting. An abort during that wait can prevent the next attempt, so
|
|
4590
|
+
* a reported retry is one the loop intends to send, not one it has sent.
|
|
4591
|
+
*
|
|
4592
|
+
* Reporting before the wait rather than after is the point: a consumer learns
|
|
4593
|
+
* about a sixty-second retry when it starts, not a minute later.
|
|
4594
|
+
*
|
|
4595
|
+
* Observability only: what it throws is swallowed, because an observer must
|
|
4596
|
+
* not be able to cancel a retry the loop already decided on.
|
|
4597
|
+
*
|
|
4598
|
+
* The `void` return is the contract — the loop does not wait on an observer,
|
|
4599
|
+
* so an `async` one runs detached and cannot delay a retry. TypeScript accepts
|
|
4600
|
+
* an `async` function here regardless, so a rejected promise is swallowed too.
|
|
4601
|
+
*/
|
|
4602
|
+
onRetry?: (attempt: RetryHttpRequestAttempt) => void;
|
|
4559
4603
|
}
|
|
4560
4604
|
declare const RETRY_HTTP_REQUEST_OPTIONS_ID = "kitcore/retryHttpRequestOptions";
|
|
4561
4605
|
declare const retryHttpRequestOptionsPluginRef: PropertyPlugin<"retryHttpRequestOptions", RetryHttpRequestOptions | undefined> & PluginSummary<never, never> & StandInId<"kitcore/retryHttpRequestOptions">;
|
|
@@ -4730,4 +4774,4 @@ declare const normalizeConnectionPlugin: MethodPlugin<"normalizeConnection", Nor
|
|
|
4730
4774
|
*/
|
|
4731
4775
|
declare const resolveConnectionPlugin: MethodPlugin<"resolveConnection", ResolveConnectionInput, string | undefined, readonly [], ResolveConnectionInput> & LeafSummary<"kitcore", "resolveConnection", readonly []>;
|
|
4732
4776
|
|
|
4733
|
-
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type AttemptHttpRequestInput, type AuthorizeHttpRequestInput, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CallContext, type CallOrigin, type CategoryDefinition, type ComposedAnnotator, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DefaultConnectionSchemeInput, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DispatchHttpRequestInput, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, HTTP_FETCH_ID, type HookAnnotator, type HookPlugin, type HttpAttemptContext, type HttpFetchInit, type HttpOperationContext, type HttpOperationStart, type HttpPipelineState, type HttpRequest, type HttpRequestInput, type HttpResponse, type InitializeHttpRequestInput, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAnnotator, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type NegatableMetadata, type NormalizeConnectionInput, type NormalizedConnection, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputDataValidationReport, type OutputFormatter, type OverridableMetaFields, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PrepareHttpRequestInput, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, RETRY_HTTP_REQUEST_OPTIONS_ID, type ReceiveHttpResponseInput, type RegistryResult, type RequiredSdkOf, type ResolveConnectionInput, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverRequirement, type ResolverType, type ResponseMeta, type RetryHttpRequestOptions, STABILITY_LEVELS, STABILITY_TITLES, type Sdk, type SdkContext, type SdkContextCarrier, type SdkPage, type SendHttpRequest, type StabilityLevel, type StabilityNotice, type StabilityNoticeLogger, type StandInId, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, applyStabilityLabel, attemptHttpRequestPlugin, authorizeHttpRequestPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createStabilityNoticeLogger, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultConnectionSchemePlugin, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, dispatchHttpRequestPlugin, disposeSdk, fetchPlugin, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistry, getRegistryPlugin, getSchemaDescription, httpFetchPluginRef, initializeHttpRequestPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, normalizeConnectionPlugin, normalizeStability, objectShapeOf, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, prepareHttpRequestPlugin, receiveHttpResponsePlugin, redactHeaders, redactHttpRequest, resolveConnectionPlugin, resolvePlugin, retryHttpRequestOptionsPluginRef, retryHttpRequestPlugin, runInMethodScope, runWithTelemetryContext, selectExports, sendHttpRequestPlugin, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, unwrapSchema, validateOptions, withOutputSchema, withPositional, withResolver };
|
|
4777
|
+
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type AttemptHttpRequestInput, type AuthorizeHttpRequestInput, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CallContext, type CallOrigin, type CategoryDefinition, type ComposedAnnotator, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DefaultConnectionSchemeInput, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DispatchHttpRequestInput, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, HTTP_FETCH_ID, type HookAnnotator, type HookPlugin, type HttpAttemptContext, type HttpFetchInit, type HttpOperationContext, type HttpOperationStart, type HttpPipelineState, type HttpRequest, type HttpRequestInput, type HttpResponse, type InitializeHttpRequestInput, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAnnotator, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type NegatableMetadata, type NormalizeConnectionInput, type NormalizedConnection, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputDataValidationReport, type OutputFormatter, type OverridableMetaFields, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PrepareHttpRequestInput, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, RETRY_HTTP_REQUEST_OPTIONS_ID, type ReceiveHttpResponseInput, type RegistryResult, type RequiredSdkOf, type ResolveConnectionInput, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverRequirement, type ResolverType, type ResponseMeta, type RetryHttpRequestAttempt, type RetryHttpRequestOptions, STABILITY_LEVELS, STABILITY_TITLES, type Sdk, type SdkContext, type SdkContextCarrier, type SdkPage, type SendHttpRequest, type StabilityLevel, type StabilityNotice, type StabilityNoticeLogger, type StandInId, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, applyStabilityLabel, attemptHttpRequestPlugin, authorizeHttpRequestPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createStabilityNoticeLogger, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultConnectionSchemePlugin, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, dispatchHttpRequestPlugin, disposeSdk, fetchPlugin, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistry, getRegistryPlugin, getSchemaDescription, httpFetchPluginRef, initializeHttpRequestPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, normalizeConnectionPlugin, normalizeStability, objectShapeOf, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, prepareHttpRequestPlugin, receiveHttpResponsePlugin, redactHeaders, redactHttpRequest, resolveConnectionPlugin, resolvePlugin, retryHttpRequestOptionsPluginRef, retryHttpRequestPlugin, runInMethodScope, runWithTelemetryContext, selectExports, sendHttpRequestPlugin, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, unwrapSchema, validateOptions, withOutputSchema, withPositional, withResolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -4530,6 +4530,28 @@ declare const attemptHttpRequestPlugin: MethodPlugin<"attemptHttpRequest", Attem
|
|
|
4530
4530
|
*/
|
|
4531
4531
|
declare const initializeHttpRequestPlugin: MethodPlugin<"initializeHttpRequest", InitializeHttpRequestInput, Promise<HttpOperationContext>, readonly [], InitializeHttpRequestInput> & LeafSummary<"kitcore", "initializeHttpRequest", readonly []>;
|
|
4532
4532
|
|
|
4533
|
+
/**
|
|
4534
|
+
* Details about a retry the loop has scheduled.
|
|
4535
|
+
*
|
|
4536
|
+
* `request` preserves the caller's request-object identity so observers can
|
|
4537
|
+
* correlate the retry with its originating call. `delayMilliseconds` is the
|
|
4538
|
+
* exact delay selected by the loop.
|
|
4539
|
+
*/
|
|
4540
|
+
interface RetryHttpRequestAttempt {
|
|
4541
|
+
request: HttpRequest;
|
|
4542
|
+
operationId: string;
|
|
4543
|
+
/** 1-based number of the attempt that just failed. */
|
|
4544
|
+
attemptNumber: number;
|
|
4545
|
+
delayMilliseconds: number;
|
|
4546
|
+
/**
|
|
4547
|
+
* The response being retried. Its body is released as soon as the observer
|
|
4548
|
+
* returns, so read status and headers only. Absent when the attempt threw
|
|
4549
|
+
* instead of answering.
|
|
4550
|
+
*/
|
|
4551
|
+
response?: HttpResponse;
|
|
4552
|
+
/** The error the attempt threw, when `retryOnError` is on. */
|
|
4553
|
+
error?: unknown;
|
|
4554
|
+
}
|
|
4533
4555
|
/**
|
|
4534
4556
|
* Options for {@link retryHttpRequestPlugin}, supplied by id like every other
|
|
4535
4557
|
* kitcore configuration value. Absent means the defaults below.
|
|
@@ -4537,7 +4559,13 @@ declare const initializeHttpRequestPlugin: MethodPlugin<"initializeHttpRequest",
|
|
|
4537
4559
|
interface RetryHttpRequestOptions {
|
|
4538
4560
|
/** Total attempts including the first. Default 3. */
|
|
4539
4561
|
maxAttempts?: number;
|
|
4540
|
-
/**
|
|
4562
|
+
/**
|
|
4563
|
+
* Requested ceiling for a retry wait. Default 60 seconds.
|
|
4564
|
+
*
|
|
4565
|
+
* Server-specified delays above this limit stop retrying. Generated backoff
|
|
4566
|
+
* is capped at this value, then raised to `MIN_BACKOFF_MILLISECONDS` when
|
|
4567
|
+
* needed to preserve a minimum wait.
|
|
4568
|
+
*/
|
|
4541
4569
|
maxDelayMilliseconds?: number;
|
|
4542
4570
|
/** Statuses to retry on an idempotent method. Default 429, 500, 502, 503, 504. */
|
|
4543
4571
|
retryStatuses?: readonly number[];
|
|
@@ -4556,6 +4584,22 @@ interface RetryHttpRequestOptions {
|
|
|
4556
4584
|
* choice rather than a default.
|
|
4557
4585
|
*/
|
|
4558
4586
|
retryOnError?: boolean;
|
|
4587
|
+
/**
|
|
4588
|
+
* Called when the loop schedules a retry, after selecting the delay and
|
|
4589
|
+
* before waiting. An abort during that wait can prevent the next attempt, so
|
|
4590
|
+
* a reported retry is one the loop intends to send, not one it has sent.
|
|
4591
|
+
*
|
|
4592
|
+
* Reporting before the wait rather than after is the point: a consumer learns
|
|
4593
|
+
* about a sixty-second retry when it starts, not a minute later.
|
|
4594
|
+
*
|
|
4595
|
+
* Observability only: what it throws is swallowed, because an observer must
|
|
4596
|
+
* not be able to cancel a retry the loop already decided on.
|
|
4597
|
+
*
|
|
4598
|
+
* The `void` return is the contract — the loop does not wait on an observer,
|
|
4599
|
+
* so an `async` one runs detached and cannot delay a retry. TypeScript accepts
|
|
4600
|
+
* an `async` function here regardless, so a rejected promise is swallowed too.
|
|
4601
|
+
*/
|
|
4602
|
+
onRetry?: (attempt: RetryHttpRequestAttempt) => void;
|
|
4559
4603
|
}
|
|
4560
4604
|
declare const RETRY_HTTP_REQUEST_OPTIONS_ID = "kitcore/retryHttpRequestOptions";
|
|
4561
4605
|
declare const retryHttpRequestOptionsPluginRef: PropertyPlugin<"retryHttpRequestOptions", RetryHttpRequestOptions | undefined> & PluginSummary<never, never> & StandInId<"kitcore/retryHttpRequestOptions">;
|
|
@@ -4730,4 +4774,4 @@ declare const normalizeConnectionPlugin: MethodPlugin<"normalizeConnection", Nor
|
|
|
4730
4774
|
*/
|
|
4731
4775
|
declare const resolveConnectionPlugin: MethodPlugin<"resolveConnection", ResolveConnectionInput, string | undefined, readonly [], ResolveConnectionInput> & LeafSummary<"kitcore", "resolveConnection", readonly []>;
|
|
4732
4776
|
|
|
4733
|
-
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type AttemptHttpRequestInput, type AuthorizeHttpRequestInput, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CallContext, type CallOrigin, type CategoryDefinition, type ComposedAnnotator, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DefaultConnectionSchemeInput, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DispatchHttpRequestInput, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, HTTP_FETCH_ID, type HookAnnotator, type HookPlugin, type HttpAttemptContext, type HttpFetchInit, type HttpOperationContext, type HttpOperationStart, type HttpPipelineState, type HttpRequest, type HttpRequestInput, type HttpResponse, type InitializeHttpRequestInput, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAnnotator, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type NegatableMetadata, type NormalizeConnectionInput, type NormalizedConnection, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputDataValidationReport, type OutputFormatter, type OverridableMetaFields, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PrepareHttpRequestInput, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, RETRY_HTTP_REQUEST_OPTIONS_ID, type ReceiveHttpResponseInput, type RegistryResult, type RequiredSdkOf, type ResolveConnectionInput, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverRequirement, type ResolverType, type ResponseMeta, type RetryHttpRequestOptions, STABILITY_LEVELS, STABILITY_TITLES, type Sdk, type SdkContext, type SdkContextCarrier, type SdkPage, type SendHttpRequest, type StabilityLevel, type StabilityNotice, type StabilityNoticeLogger, type StandInId, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, applyStabilityLabel, attemptHttpRequestPlugin, authorizeHttpRequestPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createStabilityNoticeLogger, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultConnectionSchemePlugin, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, dispatchHttpRequestPlugin, disposeSdk, fetchPlugin, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistry, getRegistryPlugin, getSchemaDescription, httpFetchPluginRef, initializeHttpRequestPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, normalizeConnectionPlugin, normalizeStability, objectShapeOf, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, prepareHttpRequestPlugin, receiveHttpResponsePlugin, redactHeaders, redactHttpRequest, resolveConnectionPlugin, resolvePlugin, retryHttpRequestOptionsPluginRef, retryHttpRequestPlugin, runInMethodScope, runWithTelemetryContext, selectExports, sendHttpRequestPlugin, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, unwrapSchema, validateOptions, withOutputSchema, withPositional, withResolver };
|
|
4777
|
+
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type Annotations, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type AttemptHttpRequestInput, type AuthorizeHttpRequestInput, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CallContext, type CallOrigin, type CategoryDefinition, type ComposedAnnotator, type ConstantResolver$1 as ConstantResolver, type Controller, type ControllerAction, type ControllerAffordance, type ControllerAnswerFn, type ControllerChoice, type ControllerError, type ControllerIssue, type ControllerListingPage, type ControllerListingPosition, type ControllerMethodDescription, type ControllerMethodSummary, type ControllerPagination, type ControllerParameterDescription, type ControllerPath, type ControllerQuestion, type ControllerResult, type ControllerSdk, type ControllerSelectPage, type ControllerState, type CoreApiError, CoreCancelledSignal, CoreDisposeError, CoreError, CoreErrorCode, type CoreErrorOptions, type CoreOptions, CoreSignal, type CreateSdkOptions, type DefaultConnectionSchemeInput, type DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DispatchHttpRequestInput, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, HTTP_FETCH_ID, type HookAnnotator, type HookPlugin, type HttpAttemptContext, type HttpFetchInit, type HttpOperationContext, type HttpOperationStart, type HttpPipelineState, type HttpRequest, type HttpRequestInput, type HttpResponse, type InitializeHttpRequestInput, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAnnotator, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type NegatableMetadata, type NormalizeConnectionInput, type NormalizedConnection, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputDataValidationReport, type OutputFormatter, type OverridableMetaFields, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PrepareHttpRequestInput, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, RETRY_HTTP_REQUEST_OPTIONS_ID, type ReceiveHttpResponseInput, type RegistryResult, type RequiredSdkOf, type ResolveConnectionInput, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverRequirement, type ResolverType, type ResponseMeta, type RetryHttpRequestAttempt, type RetryHttpRequestOptions, STABILITY_LEVELS, STABILITY_TITLES, type Sdk, type SdkContext, type SdkContextCarrier, type SdkPage, type SendHttpRequest, type StabilityLevel, type StabilityNotice, type StabilityNoticeLogger, type StandInId, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, applyStabilityLabel, attemptHttpRequestPlugin, authorizeHttpRequestPlugin, canonicalInputSchema, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createStabilityNoticeLogger, createValidator, dangerousContextPlugin, declareDefault, declareMethod, declareOptionalMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultConnectionSchemePlugin, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, dispatchHttpRequestPlugin, disposeSdk, fetchPlugin, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getNegatable, getOutputSchema, getRegistry, getRegistryPlugin, getSchemaDescription, httpFetchPluginRef, initializeHttpRequestPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, normalizeConnectionPlugin, normalizeStability, objectShapeOf, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, prepareHttpRequestPlugin, receiveHttpResponsePlugin, redactHeaders, redactHttpRequest, resolveConnectionPlugin, resolvePlugin, retryHttpRequestOptionsPluginRef, retryHttpRequestPlugin, runInMethodScope, runWithTelemetryContext, selectExports, sendHttpRequestPlugin, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, unwrapSchema, validateOptions, withOutputSchema, withPositional, withResolver };
|
package/dist/index.mjs
CHANGED
|
@@ -643,6 +643,11 @@ function toIterable(source) {
|
|
|
643
643
|
return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
+
// src/utils/promise-utils.ts
|
|
647
|
+
function isPromiseLike(value) {
|
|
648
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
649
|
+
}
|
|
650
|
+
|
|
646
651
|
// src/utils/validation.ts
|
|
647
652
|
var parseOrThrow = (schema, input, { adaptError } = {}) => {
|
|
648
653
|
const result = schema.safeParse(input);
|
|
@@ -1111,7 +1116,7 @@ function createRawFunction(coreFn, options) {
|
|
|
1111
1116
|
try {
|
|
1112
1117
|
const parsed = schema ? validateOptions(schema, input, { adaptError }) : input;
|
|
1113
1118
|
const result = coreFn(parsed, context);
|
|
1114
|
-
if (result
|
|
1119
|
+
if (isPromiseLike(result)) {
|
|
1115
1120
|
return result.then(
|
|
1116
1121
|
(value) => {
|
|
1117
1122
|
fireEnd();
|
|
@@ -2443,9 +2448,6 @@ function applyListOutputPolicy(page, policy) {
|
|
|
2443
2448
|
var FRAMEWORK_CONFIGURATION_IDS = /* @__PURE__ */ new Set([
|
|
2444
2449
|
CORE_OPTIONS_ID
|
|
2445
2450
|
]);
|
|
2446
|
-
function isPromiseLike(value) {
|
|
2447
|
-
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
2448
|
-
}
|
|
2449
2451
|
function normalizeOutput(output) {
|
|
2450
2452
|
if (output === void 0) return { type: "raw" };
|
|
2451
2453
|
if (typeof output === "string") return { type: output };
|
|
@@ -4932,6 +4934,7 @@ var DEFAULT_IDEMPOTENT_METHODS = [
|
|
|
4932
4934
|
"TRACE"
|
|
4933
4935
|
];
|
|
4934
4936
|
var BASE_BACKOFF_MILLISECONDS = 1e3;
|
|
4937
|
+
var MIN_BACKOFF_MILLISECONDS = 100;
|
|
4935
4938
|
var JITTER_FACTOR = 0.5;
|
|
4936
4939
|
var EPOCH_THRESHOLD_SECONDS = 1e9;
|
|
4937
4940
|
function directedDelayMilliseconds(response) {
|
|
@@ -4956,6 +4959,12 @@ function backoffMilliseconds(attemptNumber) {
|
|
|
4956
4959
|
const base = BASE_BACKOFF_MILLISECONDS * 2 ** (attemptNumber - 1);
|
|
4957
4960
|
return base + Math.random() * JITTER_FACTOR * base;
|
|
4958
4961
|
}
|
|
4962
|
+
function clampBackoffMilliseconds(attemptNumber, maxDelayMilliseconds) {
|
|
4963
|
+
return Math.max(
|
|
4964
|
+
Math.min(backoffMilliseconds(attemptNumber), maxDelayMilliseconds),
|
|
4965
|
+
MIN_BACKOFF_MILLISECONDS
|
|
4966
|
+
);
|
|
4967
|
+
}
|
|
4959
4968
|
function abortReason(signal) {
|
|
4960
4969
|
const reason = signal?.reason;
|
|
4961
4970
|
return reason ?? new Error("The request was aborted.");
|
|
@@ -4990,6 +4999,20 @@ var retryHttpRequestPlugin = defineHook({
|
|
|
4990
4999
|
const maxDelayMilliseconds = options.maxDelayMilliseconds ?? DEFAULT_MAX_DELAY_MILLISECONDS;
|
|
4991
5000
|
const idempotentMethods = options.idempotentMethods ?? DEFAULT_IDEMPOTENT_METHODS;
|
|
4992
5001
|
const statuses = isIdempotent(input.request, idempotentMethods) ? options.retryStatuses ?? DEFAULT_RETRY_STATUSES : options.nonIdempotentRetryStatuses ?? DEFAULT_NON_IDEMPOTENT_RETRY_STATUSES;
|
|
5002
|
+
const notifyRetry = (notice) => {
|
|
5003
|
+
try {
|
|
5004
|
+
const observed = options.onRetry?.({
|
|
5005
|
+
...notice,
|
|
5006
|
+
request: input.attempt.operation.request,
|
|
5007
|
+
operationId: input.attempt.operation.operationId
|
|
5008
|
+
});
|
|
5009
|
+
if (isPromiseLike(observed)) {
|
|
5010
|
+
void observed.then(void 0, () => {
|
|
5011
|
+
});
|
|
5012
|
+
}
|
|
5013
|
+
} catch {
|
|
5014
|
+
}
|
|
5015
|
+
};
|
|
4993
5016
|
for (let attemptNumber = 1; ; attemptNumber++) {
|
|
4994
5017
|
const attempt = {
|
|
4995
5018
|
...input.attempt,
|
|
@@ -5011,10 +5034,16 @@ var retryHttpRequestPlugin = defineHook({
|
|
|
5011
5034
|
)) {
|
|
5012
5035
|
throw error;
|
|
5013
5036
|
}
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5037
|
+
const errorDelay = clampBackoffMilliseconds(
|
|
5038
|
+
attemptNumber,
|
|
5039
|
+
maxDelayMilliseconds
|
|
5017
5040
|
);
|
|
5041
|
+
notifyRetry({
|
|
5042
|
+
attemptNumber,
|
|
5043
|
+
delayMilliseconds: errorDelay,
|
|
5044
|
+
error
|
|
5045
|
+
});
|
|
5046
|
+
await sleep(errorDelay, attempt.signal);
|
|
5018
5047
|
continue;
|
|
5019
5048
|
}
|
|
5020
5049
|
if (!statuses.includes(response.status) || !canRetry(
|
|
@@ -5027,10 +5056,8 @@ var retryHttpRequestPlugin = defineHook({
|
|
|
5027
5056
|
const directed = directedDelayMilliseconds(response);
|
|
5028
5057
|
if (directed != null && directed > maxDelayMilliseconds)
|
|
5029
5058
|
return response;
|
|
5030
|
-
const delay =
|
|
5031
|
-
|
|
5032
|
-
maxDelayMilliseconds
|
|
5033
|
-
);
|
|
5059
|
+
const delay = directed ?? clampBackoffMilliseconds(attemptNumber, maxDelayMilliseconds);
|
|
5060
|
+
notifyRetry({ attemptNumber, delayMilliseconds: delay, response });
|
|
5034
5061
|
await response.body?.cancel().catch(() => {
|
|
5035
5062
|
});
|
|
5036
5063
|
await sleep(delay, attempt.signal);
|