diff --git a/src/sdk.ts b/src/sdk.ts index bc9c93b2a..ecf3ea49e 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -1577,9 +1577,9 @@ export class AxonOps { * @returns {Promise} An array of {@link Axon} instances. */ async list(params?: AxonListParams, options?: Core.RequestOptions): Promise { - const result = await this.client.axons.list(params, options); + const page = await this.client.axons.list(params, options); const axons: Axon[] = []; - for await (const axon of result) { + for (const axon of page.getPaginatedItems()) { axons.push(Axon.fromId(this.client, axon.id)); } return axons; @@ -1789,10 +1789,10 @@ export class NetworkPolicyOps { * @returns {Promise} An array of {@link NetworkPolicy} instances. */ async list(params?: NetworkPolicyListParams, options?: Core.RequestOptions): Promise { - const result = await this.client.networkPolicies.list(params, options); + const page = await this.client.networkPolicies.list(params, options); const policies: NetworkPolicy[] = []; - for await (const policy of result) { + for (const policy of page.getPaginatedItems()) { policies.push(NetworkPolicy.fromId(this.client, policy.id)); } @@ -1900,10 +1900,10 @@ export class GatewayConfigOps { * @returns {Promise} An array of {@link GatewayConfig} instances. */ async list(params?: GatewayConfigListParams, options?: Core.RequestOptions): Promise { - const result = await this.client.gatewayConfigs.list(params, options); + const page = await this.client.gatewayConfigs.list(params, options); const configs: GatewayConfig[] = []; - for await (const config of result) { + for (const config of page.getPaginatedItems()) { configs.push(GatewayConfig.fromId(this.client, config.id)); } @@ -2002,10 +2002,10 @@ export class McpConfigOps { * @returns {Promise} An array of {@link McpConfig} instances. */ async list(params?: McpConfigListParams, options?: Core.RequestOptions): Promise { - const result = await this.client.mcpConfigs.list(params, options); + const page = await this.client.mcpConfigs.list(params, options); const configs: McpConfig[] = []; - for await (const config of result) { + for (const config of page.getPaginatedItems()) { configs.push(McpConfig.fromId(this.client, config.id)); } diff --git a/src/sdk/agent.ts b/src/sdk/agent.ts index cdf530371..3f975c111 100644 --- a/src/sdk/agent.ts +++ b/src/sdk/agent.ts @@ -116,10 +116,10 @@ export class Agent { params?: AgentListParams, options?: Core.RequestOptions, ): Promise { - const agents = await client.agents.list(params, options); + const page = await client.agents.list(params, options); const result: Agent[] = []; - for await (const agent of agents) { + for (const agent of page.getPaginatedItems()) { result.push(new Agent(client, agent.id)); } diff --git a/src/sdk/scorer.ts b/src/sdk/scorer.ts index f7821c51b..1ef071131 100644 --- a/src/sdk/scorer.ts +++ b/src/sdk/scorer.ts @@ -99,10 +99,10 @@ export class Scorer { params?: ScorerListParams, options?: Core.RequestOptions, ): Promise { - const scorers = await client.scenarios.scorers.list(params, options); + const page = await client.scenarios.scorers.list(params, options); const result: Scorer[] = []; - for await (const scorer of scorers) { + for (const scorer of page.getPaginatedItems()) { result.push(Scorer.fromId(client, scorer.id)); } diff --git a/src/sdk/snapshot.ts b/src/sdk/snapshot.ts index 8f6d53c36..6c4a18701 100644 --- a/src/sdk/snapshot.ts +++ b/src/sdk/snapshot.ts @@ -86,10 +86,10 @@ export class Snapshot { params?: DevboxListDiskSnapshotsParams, options?: Core.RequestOptions, ): Promise { - const snapshots = await client.devboxes.listDiskSnapshots(params, options); + const page = await client.devboxes.listDiskSnapshots(params, options); const result: Snapshot[] = []; - for await (const snapshot of snapshots) { + for (const snapshot of page.getPaginatedItems()) { result.push(new Snapshot(client, snapshot.id)); } diff --git a/src/sdk/storage-object.ts b/src/sdk/storage-object.ts index f1bd084a3..68f039d00 100644 --- a/src/sdk/storage-object.ts +++ b/src/sdk/storage-object.ts @@ -161,10 +161,10 @@ export class StorageObject { params?: ObjectListParams, options?: Core.RequestOptions, ): Promise { - const objects = await client.objects.list(params, options); + const page = await client.objects.list(params, options); const result: StorageObject[] = []; - for await (const obj of objects) { + for (const obj of page.getPaginatedItems()) { result.push(new StorageObject(client, obj.id, null)); } diff --git a/tests/objects/agent.test.ts b/tests/objects/agent.test.ts index 1db8632fd..d74900ab0 100644 --- a/tests/objects/agent.test.ts +++ b/tests/objects/agent.test.ts @@ -182,16 +182,11 @@ describe('Agent (SDK)', () => { }, ]; - // Mock async iterator - const asyncIterator = { - async *[Symbol.asyncIterator]() { - for (const agent of mockAgents) { - yield agent; - } - }, + const mockPage = { + getPaginatedItems: () => mockAgents, }; - mockClient.agents.list.mockReturnValue(asyncIterator); + mockClient.agents.list.mockReturnValue(mockPage); const agents = await Agent.list(mockClient); @@ -204,19 +199,19 @@ describe('Agent (SDK)', () => { }); it('should pass filter parameters to list', async () => { - const asyncIterator = { - async *[Symbol.asyncIterator]() { - yield { + const mockPage = { + getPaginatedItems: () => [ + { id: 'agent-001', name: 'filtered-agent', version: '1.0.0', create_time_ms: Date.now(), is_public: false, - }; - }, + }, + ], }; - mockClient.agents.list.mockReturnValue(asyncIterator); + mockClient.agents.list.mockReturnValue(mockPage); await Agent.list(mockClient, { name: 'filtered-agent' }); @@ -224,13 +219,11 @@ describe('Agent (SDK)', () => { }); it('should handle empty list', async () => { - const asyncIterator = { - async *[Symbol.asyncIterator]() { - // Empty iterator - }, + const mockPage = { + getPaginatedItems: () => [], }; - mockClient.agents.list.mockReturnValue(asyncIterator); + mockClient.agents.list.mockReturnValue(mockPage); const agents = await Agent.list(mockClient); diff --git a/tests/objects/scorer.test.ts b/tests/objects/scorer.test.ts index 6cfbdfda1..ddcc82672 100644 --- a/tests/objects/scorer.test.ts +++ b/tests/objects/scorer.test.ts @@ -66,15 +66,11 @@ describe('Scorer', () => { { id: 'scs_003', type: 'third', bash_script: 'echo "0.0"' }, ]; - const asyncIterator = { - async *[Symbol.asyncIterator]() { - for (const scorer of mockScorers) { - yield scorer; - } - }, + const mockPage = { + getPaginatedItems: () => mockScorers, }; - mockClient.scenarios.scorers.list.mockReturnValue(asyncIterator); + mockClient.scenarios.scorers.list.mockReturnValue(mockPage); const scorers = await Scorer.list(mockClient); @@ -87,13 +83,11 @@ describe('Scorer', () => { }); it('should pass filter parameters to list', async () => { - const asyncIterator = { - async *[Symbol.asyncIterator]() { - yield { id: 'scs_001' }; - }, + const mockPage = { + getPaginatedItems: () => [{ id: 'scs_001' }], }; - mockClient.scenarios.scorers.list.mockReturnValue(asyncIterator); + mockClient.scenarios.scorers.list.mockReturnValue(mockPage); await Scorer.list(mockClient, { limit: 10 }); @@ -101,13 +95,11 @@ describe('Scorer', () => { }); it('should handle empty list', async () => { - const asyncIterator = { - async *[Symbol.asyncIterator]() { - // Empty iterator - }, + const mockPage = { + getPaginatedItems: () => [], }; - mockClient.scenarios.scorers.list.mockReturnValue(asyncIterator); + mockClient.scenarios.scorers.list.mockReturnValue(mockPage); const scorers = await Scorer.list(mockClient); diff --git a/tests/objects/snapshot.test.ts b/tests/objects/snapshot.test.ts index 9396c5ebc..2455e4b6b 100644 --- a/tests/objects/snapshot.test.ts +++ b/tests/objects/snapshot.test.ts @@ -89,10 +89,7 @@ describe('Snapshot (New API)', () => { }; const mockPage = { - [Symbol.asyncIterator]: async function* () { - yield snapshot1; - yield snapshot2; - }, + getPaginatedItems: () => [snapshot1, snapshot2], }; mockClient.devboxes.listDiskSnapshots.mockResolvedValue(mockPage as any); @@ -107,9 +104,7 @@ describe('Snapshot (New API)', () => { it('should filter by devbox ID', async () => { const mockPage = { - [Symbol.asyncIterator]: async function* () { - yield mockSnapshotData; - }, + getPaginatedItems: () => [mockSnapshotData], }; mockClient.devboxes.listDiskSnapshots.mockResolvedValue(mockPage as any); @@ -124,9 +119,7 @@ describe('Snapshot (New API)', () => { it('should return empty array when no snapshots found', async () => { const mockPage = { - [Symbol.asyncIterator]: async function* () { - // Empty iterator - }, + getPaginatedItems: () => [], }; mockClient.devboxes.listDiskSnapshots.mockResolvedValue(mockPage as any); diff --git a/tests/objects/storage-object.test.ts b/tests/objects/storage-object.test.ts index 20e2ea4ce..b21be4fce 100644 --- a/tests/objects/storage-object.test.ts +++ b/tests/objects/storage-object.test.ts @@ -195,10 +195,7 @@ describe('StorageObject (New API)', () => { }; const mockPage = { - [Symbol.asyncIterator]: async function* () { - yield obj1; - yield obj2; - }, + getPaginatedItems: () => [obj1, obj2], }; mockClient.objects.list.mockResolvedValue(mockPage as any); @@ -213,9 +210,7 @@ describe('StorageObject (New API)', () => { it('should support filtering', async () => { const mockPage = { - [Symbol.asyncIterator]: async function* () { - yield mockObjectData; - }, + getPaginatedItems: () => [mockObjectData], }; mockClient.objects.list.mockResolvedValue(mockPage as any); diff --git a/tests/sdk/axon-ops.test.ts b/tests/sdk/axon-ops.test.ts index 592f448fc..1b8f728ff 100644 --- a/tests/sdk/axon-ops.test.ts +++ b/tests/sdk/axon-ops.test.ts @@ -79,9 +79,7 @@ describe('AxonOps', () => { describe('list', () => { function mockPageResult(items: AxonView[]) { return { - [Symbol.asyncIterator]: async function* () { - yield* items; - }, + getPaginatedItems: () => items, }; }