@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/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 same value is both:
23
+ * Return type of every paginated SDK method. The documented surface is:
24
24
  *
25
- * - a Promise that resolves to the first page (`SdkPage<TItem>`), and
26
- * - an AsyncIterable that yields each page in turn,
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
- * with an `.items()` method that returns an AsyncIterable over individual
29
- * items across all pages. Named so paginated plugin signatures serialize
30
- * as `PaginatedSdkResult<AppItem>` in `.d.ts` rather than expanding the
31
- * full triple-intersection at every callsite.
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
- * - The page-iterable and `.items()` are two views over one page stream, so
39
- * consuming either drains the other: the second view yields nothing (it
40
- * does not replay page 1). To read a result more than once, call the
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>>, AsyncIterable<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
- * One page-at-a-time source for `concatPaginated`: called with that source's
3380
- * own cursor, resolves one page. An SDK paginated method fits directly
3381
- * (`({ cursor }) => sdk.listThings({ cursor })` awaiting a paginated
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 PaginatedSource<TItem> = (options: {
3400
+ type ListSource<TItem> = (options: {
3385
3401
  cursor?: string;
3386
3402
  }) => PromiseLike<PaginatedResult<TItem>>;
3387
3403
  /**
3388
- * Concatenate multiple paginated sources into a single paginated stream.
3389
- * Sources are drained in order, one page per underlying call.
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 source to
3392
- * resume plus that source's own cursor, so a fresh `concatPaginated` call
3393
- * with `cursor` continues exactly where the previous page left off. Sources
3394
- * must therefore produce disjoint items themselves; there is no cross-source
3395
- * dedupe (an in-memory seen-set could not survive the cursor round-trip).
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 source
3398
- * boundaries — e.g. if the first source only has 2 items, they'll be
3399
- * buffered with items from the next source into a full page.
3400
- *
3401
- * The result is a thenable for the first page that also async-iterates
3402
- * pages in-process.
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: PaginatedSource<TItem>[];
3432
+ sources: ListSource<TItem>[];
3406
3433
  pageSize?: number;
3407
- /** Cursor from a previous `concatPaginated` page; resumes the stream. */
3408
3434
  cursor?: string;
3409
- }): PromiseLike<PaginatedResult<TItem>> & AsyncIterable<PaginatedResult<TItem>>;
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 same value is both:
23
+ * Return type of every paginated SDK method. The documented surface is:
24
24
  *
25
- * - a Promise that resolves to the first page (`SdkPage<TItem>`), and
26
- * - an AsyncIterable that yields each page in turn,
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
- * with an `.items()` method that returns an AsyncIterable over individual
29
- * items across all pages. Named so paginated plugin signatures serialize
30
- * as `PaginatedSdkResult<AppItem>` in `.d.ts` rather than expanding the
31
- * full triple-intersection at every callsite.
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
- * - The page-iterable and `.items()` are two views over one page stream, so
39
- * consuming either drains the other: the second view yields nothing (it
40
- * does not replay page 1). To read a result more than once, call the
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>>, AsyncIterable<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
- * One page-at-a-time source for `concatPaginated`: called with that source's
3380
- * own cursor, resolves one page. An SDK paginated method fits directly
3381
- * (`({ cursor }) => sdk.listThings({ cursor })` awaiting a paginated
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 PaginatedSource<TItem> = (options: {
3400
+ type ListSource<TItem> = (options: {
3385
3401
  cursor?: string;
3386
3402
  }) => PromiseLike<PaginatedResult<TItem>>;
3387
3403
  /**
3388
- * Concatenate multiple paginated sources into a single paginated stream.
3389
- * Sources are drained in order, one page per underlying call.
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 source to
3392
- * resume plus that source's own cursor, so a fresh `concatPaginated` call
3393
- * with `cursor` continues exactly where the previous page left off. Sources
3394
- * must therefore produce disjoint items themselves; there is no cross-source
3395
- * dedupe (an in-memory seen-set could not survive the cursor round-trip).
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 source
3398
- * boundaries — e.g. if the first source only has 2 items, they'll be
3399
- * buffered with items from the next source into a full page.
3400
- *
3401
- * The result is a thenable for the first page that also async-iterates
3402
- * pages in-process.
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: PaginatedSource<TItem>[];
3432
+ sources: ListSource<TItem>[];
3406
3433
  pageSize?: number;
3407
- /** Cursor from a previous `concatPaginated` page; resumes the stream. */
3408
3434
  cursor?: string;
3409
- }): PromiseLike<PaginatedResult<TItem>> & AsyncIterable<PaginatedResult<TItem>>;
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 concatPaginated({
448
+ async function concatLists({
449
449
  sources,
450
450
  pageSize = 100,
451
451
  cursor
452
452
  }) {
453
453
  if (sources.length === 0) {
454
- const empty = { data: [] };
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: sourceCursor } = decodeConcatCursor(options.cursor);
457
+ let { index, cursor: listCursor } = decodeConcatCursor(options.cursor);
463
458
  while (index < sources.length) {
464
- const page = await sources[index]({ cursor: sourceCursor });
465
- const hasMoreInSource = page.nextCursor != null;
466
- if (page.data.length === 0 && !hasMoreInSource) {
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
- sourceCursor = void 0;
463
+ listCursor = void 0;
469
464
  continue;
470
465
  }
471
466
  return {
472
467
  data: page.data,
473
- nextCursor: hasMoreInSource ? encodeConcatCursor(index, page.nextCursor) : index < sources.length - 1 ? encodeConcatCursor(index + 1, void 0) : void 0
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 iterator = paginateBuffered(pageFunction, { pageSize, cursor });
479
- const firstPagePromise = iterator.next().then((result) => {
480
- if (result.done) {
481
- return { data: [] };
482
- }
483
- return result.value;
484
- });
485
- return Object.assign(firstPagePromise, {
486
- [Symbol.asyncIterator]: async function* () {
487
- yield await firstPagePromise;
488
- for await (const page of { [Symbol.asyncIterator]: () => iterator }) {
489
- yield page;
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,