@zapier/kitcore 0.7.0 → 0.8.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 +33 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +62 -33
- package/dist/index.d.ts +62 -33
- package/dist/index.mjs +32 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -20,27 +20,43 @@ interface SdkPage<T = unknown> {
|
|
|
20
20
|
nextCursor?: string;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Return type of every paginated SDK method. The
|
|
23
|
+
* Return type of every paginated SDK method. The documented surface is:
|
|
24
24
|
*
|
|
25
|
-
* -
|
|
26
|
-
* - an AsyncIterable
|
|
25
|
+
* - `await` the result for the first page (`SdkPage<TItem>`),
|
|
26
|
+
* - `.pages()` for an AsyncIterable over pages, and
|
|
27
|
+
* - `.items()` for an AsyncIterable over individual items across pages.
|
|
27
28
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* `.pages()` and `.items()` return plain iterables (not thenables), so they
|
|
30
|
+
* survive being returned from an `async` function; the result itself is a
|
|
31
|
+
* thenable, so an `async` boundary silently collapses it to the first page.
|
|
32
|
+
* Named so paginated plugin signatures serialize as
|
|
33
|
+
* `PaginatedSdkResult<AppItem>` in `.d.ts` rather than expanding the full
|
|
34
|
+
* intersection at every callsite.
|
|
32
35
|
*
|
|
33
36
|
* The faces share one underlying cursor, so a result is consumed once:
|
|
34
37
|
*
|
|
35
38
|
* - `await` / `.then()` read the buffered first page without starting the
|
|
36
39
|
* stream, so awaiting is a repeatable peek and you can still iterate the
|
|
37
40
|
* result afterward.
|
|
38
|
-
* -
|
|
39
|
-
*
|
|
40
|
-
* does not replay page 1). To read a
|
|
41
|
-
* method again for a fresh result.
|
|
41
|
+
* - `.pages()`, `.items()`, and the deprecated bare iteration are views
|
|
42
|
+
* over one page stream, so consuming any view drains the others: the
|
|
43
|
+
* second view yields nothing (it does not replay page 1). To read a
|
|
44
|
+
* result more than once, call the method again for a fresh result.
|
|
42
45
|
*/
|
|
43
|
-
interface PaginatedSdkResult<TItem> extends Promise<SdkPage<TItem
|
|
46
|
+
interface PaginatedSdkResult<TItem> extends Promise<SdkPage<TItem>> {
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Iterate `.pages()` instead. Bare iteration works but is easy
|
|
49
|
+
* to break: because the result is also a thenable, an `async` boundary
|
|
50
|
+
* collapses it to its first page and the iterable is silently lost.
|
|
51
|
+
*
|
|
52
|
+
* Deliberately no runtime deprecation warning: this face is not scheduled
|
|
53
|
+
* for deletion (removing it is a breaking change deferred to a separate
|
|
54
|
+
* decision), and structural consumers such as the CLI's page streaming
|
|
55
|
+
* detect pagination via `Symbol.asyncIterator`, so a warning would fire on
|
|
56
|
+
* the SDK's own machinery.
|
|
57
|
+
*/
|
|
58
|
+
[Symbol.asyncIterator](): AsyncIterator<SdkPage<TItem>>;
|
|
59
|
+
pages(): AsyncIterable<SdkPage<TItem>>;
|
|
44
60
|
items(): AsyncIterable<TItem>;
|
|
45
61
|
}
|
|
46
62
|
type PaginatedSdkFunction<TOptions, TItem> = (options: TOptions) => PaginatedSdkResult<TItem>;
|
|
@@ -3376,41 +3392,54 @@ interface PaginatedResult<TItem> {
|
|
|
3376
3392
|
nextCursor?: string;
|
|
3377
3393
|
}
|
|
3378
3394
|
/**
|
|
3379
|
-
*
|
|
3380
|
-
*
|
|
3381
|
-
* (`({ cursor }) => sdk.listThings({ cursor })
|
|
3395
|
+
* Supplies one list to `concatLists`: called with that list's own cursor,
|
|
3396
|
+
* resolves one page. An SDK paginated method fits directly
|
|
3397
|
+
* (`({ cursor }) => sdk.listThings({ cursor })`; awaiting a paginated
|
|
3382
3398
|
* result yields the requested page).
|
|
3383
3399
|
*/
|
|
3384
|
-
type
|
|
3400
|
+
type ListSource<TItem> = (options: {
|
|
3385
3401
|
cursor?: string;
|
|
3386
3402
|
}) => PromiseLike<PaginatedResult<TItem>>;
|
|
3387
3403
|
/**
|
|
3388
|
-
*
|
|
3389
|
-
*
|
|
3404
|
+
* List one page of several paginated lists joined end to end. Lists are
|
|
3405
|
+
* drained in order; pass a page's `nextCursor` back in to get the next page.
|
|
3390
3406
|
*
|
|
3391
|
-
* Pagination is stateless: every outgoing cursor encodes which
|
|
3392
|
-
* resume plus that
|
|
3393
|
-
*
|
|
3394
|
-
*
|
|
3395
|
-
*
|
|
3407
|
+
* Pagination is stateless: every outgoing cursor encodes which list to
|
|
3408
|
+
* resume plus that list's own cursor, so a fresh `concatLists` call
|
|
3409
|
+
* continues exactly where the previous page left off. A cursor stores its
|
|
3410
|
+
* position by list index, so it is only valid while `sources` keeps the
|
|
3411
|
+
* same lists in the same order. Lists must produce disjoint items
|
|
3412
|
+
* themselves; there is no cross-list dedupe (an in-memory seen-set could
|
|
3413
|
+
* not survive the cursor round-trip).
|
|
3396
3414
|
*
|
|
3397
|
-
* Uses paginateBuffered internally to normalize page sizes across
|
|
3398
|
-
* boundaries
|
|
3399
|
-
*
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3415
|
+
* Uses paginateBuffered internally to normalize page sizes across list
|
|
3416
|
+
* boundaries: if the first list only has 2 items, they'll be buffered with
|
|
3417
|
+
* items from the next list into a full page.
|
|
3418
|
+
*/
|
|
3419
|
+
declare function concatLists<TItem>({ sources, pageSize, cursor, }: {
|
|
3420
|
+
/** The lists to concatenate, each supplied as a page-fetching source. */
|
|
3421
|
+
sources: ListSource<TItem>[];
|
|
3422
|
+
pageSize?: number;
|
|
3423
|
+
/** Cursor from a previous `concatLists` page; resumes there. */
|
|
3424
|
+
cursor?: string;
|
|
3425
|
+
}): Promise<PaginatedResult<TItem>>;
|
|
3426
|
+
/**
|
|
3427
|
+
* @deprecated Use {@link concatLists}; awaiting either yields the same one
|
|
3428
|
+
* page. The page-iterable half of the old return shape is gone; to walk
|
|
3429
|
+
* pages, pass each page's `nextCursor` to a fresh call.
|
|
3403
3430
|
*/
|
|
3404
3431
|
declare function concatPaginated<TItem>({ sources, pageSize, cursor, }: {
|
|
3405
|
-
sources:
|
|
3432
|
+
sources: ListSource<TItem>[];
|
|
3406
3433
|
pageSize?: number;
|
|
3407
|
-
/** Cursor from a previous `concatPaginated` page; resumes the stream. */
|
|
3408
3434
|
cursor?: string;
|
|
3409
|
-
}):
|
|
3435
|
+
}): Promise<PaginatedResult<TItem>>;
|
|
3410
3436
|
/**
|
|
3411
3437
|
* Strip the PromiseLike from an async iterable, returning a plain
|
|
3412
3438
|
* AsyncIterable. This prevents async functions from unwrapping the
|
|
3413
3439
|
* iterable (since async only unwraps PromiseLike, not AsyncIterable).
|
|
3440
|
+
*
|
|
3441
|
+
* @deprecated Call `.pages()` on the paginated result instead; it returns a
|
|
3442
|
+
* plain AsyncIterable over pages with no wrapper needed.
|
|
3414
3443
|
*/
|
|
3415
3444
|
declare function toIterable<T>(source: AsyncIterable<T>): AsyncIterable<T>;
|
|
3416
3445
|
|
|
@@ -3495,4 +3524,4 @@ declare class CoreCancelledSignal extends CoreSignal {
|
|
|
3495
3524
|
constructor(message?: string);
|
|
3496
3525
|
}
|
|
3497
3526
|
|
|
3498
|
-
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CategoryDefinition, 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 DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, type HookPlugin, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputFormatter, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, type RegistryResult, type RequiredSdkOf, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverType, type Sdk, type SdkContext, type SdkPage, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, composePlugins, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createValidator, dangerousContextPlugin, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getOutputSchema, getRegistryPlugin, getSchemaDescription, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };
|
|
3527
|
+
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CategoryDefinition, 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 DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, type HookPlugin, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputFormatter, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, type RegistryResult, type RequiredSdkOf, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverType, type Sdk, type SdkContext, type SdkPage, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createValidator, dangerousContextPlugin, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getOutputSchema, getRegistryPlugin, getSchemaDescription, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,27 +20,43 @@ interface SdkPage<T = unknown> {
|
|
|
20
20
|
nextCursor?: string;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Return type of every paginated SDK method. The
|
|
23
|
+
* Return type of every paginated SDK method. The documented surface is:
|
|
24
24
|
*
|
|
25
|
-
* -
|
|
26
|
-
* - an AsyncIterable
|
|
25
|
+
* - `await` the result for the first page (`SdkPage<TItem>`),
|
|
26
|
+
* - `.pages()` for an AsyncIterable over pages, and
|
|
27
|
+
* - `.items()` for an AsyncIterable over individual items across pages.
|
|
27
28
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* `.pages()` and `.items()` return plain iterables (not thenables), so they
|
|
30
|
+
* survive being returned from an `async` function; the result itself is a
|
|
31
|
+
* thenable, so an `async` boundary silently collapses it to the first page.
|
|
32
|
+
* Named so paginated plugin signatures serialize as
|
|
33
|
+
* `PaginatedSdkResult<AppItem>` in `.d.ts` rather than expanding the full
|
|
34
|
+
* intersection at every callsite.
|
|
32
35
|
*
|
|
33
36
|
* The faces share one underlying cursor, so a result is consumed once:
|
|
34
37
|
*
|
|
35
38
|
* - `await` / `.then()` read the buffered first page without starting the
|
|
36
39
|
* stream, so awaiting is a repeatable peek and you can still iterate the
|
|
37
40
|
* result afterward.
|
|
38
|
-
* -
|
|
39
|
-
*
|
|
40
|
-
* does not replay page 1). To read a
|
|
41
|
-
* method again for a fresh result.
|
|
41
|
+
* - `.pages()`, `.items()`, and the deprecated bare iteration are views
|
|
42
|
+
* over one page stream, so consuming any view drains the others: the
|
|
43
|
+
* second view yields nothing (it does not replay page 1). To read a
|
|
44
|
+
* result more than once, call the method again for a fresh result.
|
|
42
45
|
*/
|
|
43
|
-
interface PaginatedSdkResult<TItem> extends Promise<SdkPage<TItem
|
|
46
|
+
interface PaginatedSdkResult<TItem> extends Promise<SdkPage<TItem>> {
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Iterate `.pages()` instead. Bare iteration works but is easy
|
|
49
|
+
* to break: because the result is also a thenable, an `async` boundary
|
|
50
|
+
* collapses it to its first page and the iterable is silently lost.
|
|
51
|
+
*
|
|
52
|
+
* Deliberately no runtime deprecation warning: this face is not scheduled
|
|
53
|
+
* for deletion (removing it is a breaking change deferred to a separate
|
|
54
|
+
* decision), and structural consumers such as the CLI's page streaming
|
|
55
|
+
* detect pagination via `Symbol.asyncIterator`, so a warning would fire on
|
|
56
|
+
* the SDK's own machinery.
|
|
57
|
+
*/
|
|
58
|
+
[Symbol.asyncIterator](): AsyncIterator<SdkPage<TItem>>;
|
|
59
|
+
pages(): AsyncIterable<SdkPage<TItem>>;
|
|
44
60
|
items(): AsyncIterable<TItem>;
|
|
45
61
|
}
|
|
46
62
|
type PaginatedSdkFunction<TOptions, TItem> = (options: TOptions) => PaginatedSdkResult<TItem>;
|
|
@@ -3376,41 +3392,54 @@ interface PaginatedResult<TItem> {
|
|
|
3376
3392
|
nextCursor?: string;
|
|
3377
3393
|
}
|
|
3378
3394
|
/**
|
|
3379
|
-
*
|
|
3380
|
-
*
|
|
3381
|
-
* (`({ cursor }) => sdk.listThings({ cursor })
|
|
3395
|
+
* Supplies one list to `concatLists`: called with that list's own cursor,
|
|
3396
|
+
* resolves one page. An SDK paginated method fits directly
|
|
3397
|
+
* (`({ cursor }) => sdk.listThings({ cursor })`; awaiting a paginated
|
|
3382
3398
|
* result yields the requested page).
|
|
3383
3399
|
*/
|
|
3384
|
-
type
|
|
3400
|
+
type ListSource<TItem> = (options: {
|
|
3385
3401
|
cursor?: string;
|
|
3386
3402
|
}) => PromiseLike<PaginatedResult<TItem>>;
|
|
3387
3403
|
/**
|
|
3388
|
-
*
|
|
3389
|
-
*
|
|
3404
|
+
* List one page of several paginated lists joined end to end. Lists are
|
|
3405
|
+
* drained in order; pass a page's `nextCursor` back in to get the next page.
|
|
3390
3406
|
*
|
|
3391
|
-
* Pagination is stateless: every outgoing cursor encodes which
|
|
3392
|
-
* resume plus that
|
|
3393
|
-
*
|
|
3394
|
-
*
|
|
3395
|
-
*
|
|
3407
|
+
* Pagination is stateless: every outgoing cursor encodes which list to
|
|
3408
|
+
* resume plus that list's own cursor, so a fresh `concatLists` call
|
|
3409
|
+
* continues exactly where the previous page left off. A cursor stores its
|
|
3410
|
+
* position by list index, so it is only valid while `sources` keeps the
|
|
3411
|
+
* same lists in the same order. Lists must produce disjoint items
|
|
3412
|
+
* themselves; there is no cross-list dedupe (an in-memory seen-set could
|
|
3413
|
+
* not survive the cursor round-trip).
|
|
3396
3414
|
*
|
|
3397
|
-
* Uses paginateBuffered internally to normalize page sizes across
|
|
3398
|
-
* boundaries
|
|
3399
|
-
*
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3415
|
+
* Uses paginateBuffered internally to normalize page sizes across list
|
|
3416
|
+
* boundaries: if the first list only has 2 items, they'll be buffered with
|
|
3417
|
+
* items from the next list into a full page.
|
|
3418
|
+
*/
|
|
3419
|
+
declare function concatLists<TItem>({ sources, pageSize, cursor, }: {
|
|
3420
|
+
/** The lists to concatenate, each supplied as a page-fetching source. */
|
|
3421
|
+
sources: ListSource<TItem>[];
|
|
3422
|
+
pageSize?: number;
|
|
3423
|
+
/** Cursor from a previous `concatLists` page; resumes there. */
|
|
3424
|
+
cursor?: string;
|
|
3425
|
+
}): Promise<PaginatedResult<TItem>>;
|
|
3426
|
+
/**
|
|
3427
|
+
* @deprecated Use {@link concatLists}; awaiting either yields the same one
|
|
3428
|
+
* page. The page-iterable half of the old return shape is gone; to walk
|
|
3429
|
+
* pages, pass each page's `nextCursor` to a fresh call.
|
|
3403
3430
|
*/
|
|
3404
3431
|
declare function concatPaginated<TItem>({ sources, pageSize, cursor, }: {
|
|
3405
|
-
sources:
|
|
3432
|
+
sources: ListSource<TItem>[];
|
|
3406
3433
|
pageSize?: number;
|
|
3407
|
-
/** Cursor from a previous `concatPaginated` page; resumes the stream. */
|
|
3408
3434
|
cursor?: string;
|
|
3409
|
-
}):
|
|
3435
|
+
}): Promise<PaginatedResult<TItem>>;
|
|
3410
3436
|
/**
|
|
3411
3437
|
* Strip the PromiseLike from an async iterable, returning a plain
|
|
3412
3438
|
* AsyncIterable. This prevents async functions from unwrapping the
|
|
3413
3439
|
* iterable (since async only unwraps PromiseLike, not AsyncIterable).
|
|
3440
|
+
*
|
|
3441
|
+
* @deprecated Call `.pages()` on the paginated result instead; it returns a
|
|
3442
|
+
* plain AsyncIterable over pages with no wrapper needed.
|
|
3414
3443
|
*/
|
|
3415
3444
|
declare function toIterable<T>(source: AsyncIterable<T>): AsyncIterable<T>;
|
|
3416
3445
|
|
|
@@ -3495,4 +3524,4 @@ declare class CoreCancelledSignal extends CoreSignal {
|
|
|
3495
3524
|
constructor(message?: string);
|
|
3496
3525
|
}
|
|
3497
3526
|
|
|
3498
|
-
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CategoryDefinition, 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 DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, type HookPlugin, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputFormatter, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, type RegistryResult, type RequiredSdkOf, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverType, type Sdk, type SdkContext, type SdkPage, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, composePlugins, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createValidator, dangerousContextPlugin, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getOutputSchema, getRegistryPlugin, getSchemaDescription, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };
|
|
3527
|
+
export { type AdaptError, type AdaptErrorOptions, type AdaptPage, type AggregatePlugin, type ArrayResolver$1 as ArrayResolver, type AsyncContext, type BoundFormatter, type BoundResolver, CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, type CategoryDefinition, 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 DeprecatedPromptConfigChoice, type DeprecationLogger, type DeprecationWarning, type DisposeFn, type DynamicListResolver, type DynamicMember, type DynamicResolver$1 as DynamicResolver, type DynamicSearchResolver, type FieldsResolver, type FormattedItem, type Formatter, type FunctionDeprecation, type FunctionRegistryEntry, type HookPlugin, type LeafMeta, type LeafSummary, type LegacyMergePlugin, type LegacyPlugin, type ListItemsResult, type ListPromptConfig, type MethodAttachment, type MethodHooks, type MethodOverridePlugin, type MethodPlugin, type MethodScope, type Resolver as ModelResolver, type OnMethodEnd, type OnMethodEndContext, type OnMethodStart, type OnMethodStartContext, type OutputFormatter, type PaginatedSdkFunction, type PaginatedSdkResult, type Plugin, type PluginMeta, type PluginProvides, type PluginStack, type PluginSummary, type PluginSurface, type PositionalMetadata, type PromptConfig, type PromptConfigChoice, type PropertyPlugin, type RegistryResult, type RequiredSdkOf, type Resolver$1 as Resolver, type ResolverConfig, type ResolverFieldItem, type ResolverMetadata, type ResolverPromptConfig, type ResolverType, type Sdk, type SdkContext, type SdkPage, type StaticResolver$1 as StaticResolver, type ValidResolvers, addPlugin, composePlugins, concatLists, concatPaginated, coreOptionsPluginRef, createAsyncContext, createController, createCoreError, createCorePlugin, createDeprecationLogger, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createPrefixedCursor, createSdk, createValidator, dangerousContextPlugin, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, decodeIncomingCursor, defaultLogDeprecation, defineFormatter, defineHook, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCurrentDepth, getCurrentScope, getFieldDescriptions, getOutputSchema, getRegistryPlugin, getSchemaDescription, isCoreError, isCoreSignal, isNestedMethodCall, isPositional, isTelemetryNested, omitExports, openEnum, paginate, paginateBuffered, paginateMaxItems, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, splitPrefixedCursor, toIterable, toSnakeCase, toTitleCase, validateOptions, withOutputSchema, withPositional, withResolver };
|
package/dist/index.mjs
CHANGED
|
@@ -445,53 +445,49 @@ function decodeConcatCursor(incoming) {
|
|
|
445
445
|
}
|
|
446
446
|
return { index: 0, cursor: incoming };
|
|
447
447
|
}
|
|
448
|
-
function
|
|
448
|
+
async function concatLists({
|
|
449
449
|
sources,
|
|
450
450
|
pageSize = 100,
|
|
451
451
|
cursor
|
|
452
452
|
}) {
|
|
453
453
|
if (sources.length === 0) {
|
|
454
|
-
|
|
455
|
-
return Object.assign(Promise.resolve(empty), {
|
|
456
|
-
[Symbol.asyncIterator]: async function* () {
|
|
457
|
-
yield empty;
|
|
458
|
-
}
|
|
459
|
-
});
|
|
454
|
+
return { data: [] };
|
|
460
455
|
}
|
|
461
456
|
const pageFunction = async (options) => {
|
|
462
|
-
let { index, cursor:
|
|
457
|
+
let { index, cursor: listCursor } = decodeConcatCursor(options.cursor);
|
|
463
458
|
while (index < sources.length) {
|
|
464
|
-
const page = await sources[index]({ cursor:
|
|
465
|
-
const
|
|
466
|
-
if (page.data.length === 0 && !
|
|
459
|
+
const page = await sources[index]({ cursor: listCursor });
|
|
460
|
+
const hasMoreInList = page.nextCursor != null;
|
|
461
|
+
if (page.data.length === 0 && !hasMoreInList) {
|
|
467
462
|
index++;
|
|
468
|
-
|
|
463
|
+
listCursor = void 0;
|
|
469
464
|
continue;
|
|
470
465
|
}
|
|
471
466
|
return {
|
|
472
467
|
data: page.data,
|
|
473
|
-
nextCursor:
|
|
468
|
+
nextCursor: hasMoreInList ? encodeConcatCursor(index, page.nextCursor) : index < sources.length - 1 ? encodeConcatCursor(index + 1, void 0) : void 0
|
|
474
469
|
};
|
|
475
470
|
}
|
|
476
471
|
return { data: [] };
|
|
477
472
|
};
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
492
|
-
});
|
|
473
|
+
const result = await paginateBuffered(pageFunction, {
|
|
474
|
+
pageSize,
|
|
475
|
+
cursor
|
|
476
|
+
}).next();
|
|
477
|
+
return result.done ? { data: [] } : result.value;
|
|
478
|
+
}
|
|
479
|
+
function concatPaginated({
|
|
480
|
+
sources,
|
|
481
|
+
pageSize,
|
|
482
|
+
cursor
|
|
483
|
+
}) {
|
|
484
|
+
logDeprecation("concatPaginated() is deprecated. Use concatLists() instead.");
|
|
485
|
+
return concatLists({ sources, pageSize, cursor });
|
|
493
486
|
}
|
|
494
487
|
function toIterable(source) {
|
|
488
|
+
logDeprecation(
|
|
489
|
+
"toIterable() is deprecated. Call .pages() on the paginated result instead."
|
|
490
|
+
);
|
|
495
491
|
return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
|
|
496
492
|
}
|
|
497
493
|
|
|
@@ -846,6 +842,13 @@ function createPaginatedFunction(coreFn, options) {
|
|
|
846
842
|
[Symbol.asyncIterator]() {
|
|
847
843
|
return pageStream;
|
|
848
844
|
},
|
|
845
|
+
pages: function() {
|
|
846
|
+
return {
|
|
847
|
+
[Symbol.asyncIterator]() {
|
|
848
|
+
return pageStream;
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
},
|
|
849
852
|
items: function() {
|
|
850
853
|
return {
|
|
851
854
|
[Symbol.asyncIterator]: async function* () {
|
|
@@ -3668,6 +3671,7 @@ export {
|
|
|
3668
3671
|
CoreSignal,
|
|
3669
3672
|
addPlugin,
|
|
3670
3673
|
composePlugins,
|
|
3674
|
+
concatLists,
|
|
3671
3675
|
concatPaginated,
|
|
3672
3676
|
coreOptionsPluginRef,
|
|
3673
3677
|
createAsyncContext,
|