diff --git a/CHANGELOG.md b/CHANGELOG.md index fcf7ac26..39ff89d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +1.2.5 / 2021/06/15 +=================== +- Enabled access to actor run storages via `RunClient` + 1.2.4 / 2021/06/01 =================== - use new `apify-shared` packages to reduce bundle size diff --git a/README.md b/README.md index 153e4676..2a2b9ae1 100644 --- a/README.md +++ b/README.md @@ -308,7 +308,7 @@ https://docs.apify.com/api/v2#/reference/request-queues/queue #### [](#ApifyClient+run) `apifyClient.run(id)` ⇒ [RunClient](#RunClient) -https://docs.apify.com/api/v2#/reference/actor-runs/run-object +https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages | Param | Type | @@ -1432,8 +1432,9 @@ https://docs.apify.com/api/v2#/reference/actor-runs/abort-run/abort-run #### [](#RunClient+dataset) `runClient.dataset()` ⇒ [DatasetClient](#DatasetClient) -Currently this works only through `actor.lastRun().dataset()`. It will become -available for all runs once API supports it. +https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages + +This also works through `actorClient.lastRun().dataset()`. https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages @@ -1458,8 +1459,9 @@ https://docs.apify.com/api/v2#/reference/actor-runs/run-object/get-run #### [](#RunClient+keyValueStore) `runClient.keyValueStore()` ⇒ [KeyValueStoreClient](#KeyValueStoreClient) -Currently this works only through `actorClient.lastRun().dataset()`. It will become -available for all runs once API supports it. +https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages + +This also works through `actorClient.lastRun().keyValueStore()`. https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages @@ -1469,8 +1471,9 @@ https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages #### [](#RunClient+log) `runClient.log()` ⇒ [LogClient](#LogClient) -Currently this works only through `actorClient.lastRun().dataset()`. It will become -available for all runs once API supports it. +https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages + +This also works through `actorClient.lastRun().log()`. https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages @@ -1498,8 +1501,9 @@ https://docs.apify.com/api/v2#/reference/actor-runs/metamorph-run/metamorph-run #### [](#RunClient+requestQueue) `runClient.requestQueue()` ⇒ [RequestQueueClient](#RequestQueueClient) -Currently this works only through `actorClient.lastRun().dataset()`. It will become -available for all runs once API supports it. +https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages + +This also works through `actorClient.lastRun().requestQueue()`. https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages diff --git a/package.json b/package.json index e9815845..ee101f5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apify-client", - "version": "1.2.4", + "version": "1.2.5", "description": "Apify API client for JavaScript", "main": "src/index.js", "keywords": [ diff --git a/src/index.js b/src/index.js index b7420eee..2ee8c0fd 100644 --- a/src/index.js +++ b/src/index.js @@ -223,7 +223,7 @@ class ApifyClient { // } /** - * https://docs.apify.com/api/v2#/reference/actor-runs/run-object + * https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages * @param {string} id * @return {RunClient} */ diff --git a/src/resource_clients/run.js b/src/resource_clients/run.js index 71bd99bd..bf6db8a9 100644 --- a/src/resource_clients/run.js +++ b/src/resource_clients/run.js @@ -144,8 +144,9 @@ class RunClient extends ResourceClient { } /** - * Currently this works only through `actor.lastRun().dataset()`. It will become - * available for all runs once API supports it. + * https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages + * + * This also works through `actorClient.lastRun().dataset()`. * https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages * @return {DatasetClient} */ @@ -156,8 +157,9 @@ class RunClient extends ResourceClient { } /** - * Currently this works only through `actorClient.lastRun().dataset()`. It will become - * available for all runs once API supports it. + * https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages + * + * This also works through `actorClient.lastRun().keyValueStore()`. * https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages * @return {KeyValueStoreClient} */ @@ -168,8 +170,9 @@ class RunClient extends ResourceClient { } /** - * Currently this works only through `actorClient.lastRun().dataset()`. It will become - * available for all runs once API supports it. + * https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages + * + * This also works through `actorClient.lastRun().requestQueue()`. * https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages * @return {RequestQueueClient} */ @@ -180,8 +183,9 @@ class RunClient extends ResourceClient { } /** - * Currently this works only through `actorClient.lastRun().dataset()`. It will become - * available for all runs once API supports it. + * https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages + * + * This also works through `actorClient.lastRun().log()`. * https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages * @return {LogClient} */ diff --git a/test/mock_server/routes/runs.js b/test/mock_server/routes/runs.js index 0838dd8a..3a8ca37e 100644 --- a/test/mock_server/routes/runs.js +++ b/test/mock_server/routes/runs.js @@ -8,6 +8,10 @@ const ROUTES = [ { id: 'abort-run', method: 'POST', path: '/:runId/abort' }, { id: 'metamorph-run', method: 'POST', path: '/:runId/metamorph' }, { id: 'resurrect-run', method: 'POST', path: '/:runId/resurrect' }, + { id: 'run-dataset', method: 'GET', path: '/:runId/dataset' }, + { id: 'run-keyValueStore', method: 'GET', path: '/:runId/key-value-store' }, + { id: 'run-requestQueue', method: 'GET', path: '/:runId/request-queue' }, + { id: 'run-log', method: 'GET', path: '/:runId/log', type: 'text' }, ]; addRoutes(runs, ROUTES); diff --git a/test/runs.test.js b/test/runs.test.js index 36e3e4a5..4b0fc55c 100644 --- a/test/runs.test.js +++ b/test/runs.test.js @@ -201,19 +201,55 @@ describe('Run methods', () => { validateRequest({ waitForFinish: 0 }, { runId }); }); - test.skip('dataset().get() works', async () => { + test('dataset().get() works', async () => { + const runId = 'some-run-id'; + + const res = await client.run(runId).dataset().get(); + expect(res.id).toEqual('run-dataset'); + + validateRequest({}, { runId }); + const browserRes = await page.evaluate((rId) => client.run(rId).dataset().get(), runId); + expect(browserRes).toEqual(res); + validateRequest({}, { runId }); }); - test.skip('keyValueStore().get() works', async () => { + test('keyValueStore().get() works', async () => { + const runId = 'some-run-id'; + + const res = await client.run(runId).keyValueStore().get(); + expect(res.id).toEqual('run-keyValueStore'); + + validateRequest({}, { runId }); + const browserRes = await page.evaluate((rId) => client.run(rId).keyValueStore().get(), runId); + expect(browserRes).toEqual(res); + validateRequest({}, { runId }); }); - test.skip('requestQueue().get() works', async () => { + test('requestQueue().get() works', async () => { + const runId = 'some-run-id'; + + const res = await client.run(runId).requestQueue().get(); + expect(res.id).toEqual('run-requestQueue'); + + validateRequest({}, { runId }); + const browserRes = await page.evaluate((rId) => client.run(rId).requestQueue().get(), runId); + expect(browserRes).toEqual(res); + validateRequest({}, { runId }); }); - test.skip('log().get() works', async () => { + test('log().get() works', async () => { + const runId = 'some-run-id'; + + const res = await client.run(runId).log().get(); + expect(res).toEqual('run-log'); + + validateRequest({}, { runId }); + const browserRes = await page.evaluate((rId) => client.run(rId).log().get(), runId); + expect(browserRes).toEqual(res); + validateRequest({}, { runId }); }); });