From bd873f36403425b9ec5831ccdc5c62064970e23b Mon Sep 17 00:00:00 2001 From: Michael Goberling Date: Wed, 24 Apr 2024 12:04:50 -0400 Subject: [PATCH 1/3] fix: inherit secrets in nodejs ci workflow (#154) --- .github/workflows/node.js.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 967f5c2..c7ce1db 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -11,4 +11,5 @@ on: jobs: build: - uses: adobe/aio-reusable-workflows/.github/workflows/node.js.yml@main \ No newline at end of file + uses: adobe/aio-reusable-workflows/.github/workflows/node.js.yml@main + secrets: inherit From fede88502368f5e44cdeff48fe1079d1794aa10c Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Mon, 24 Jun 2024 18:29:50 -0700 Subject: [PATCH 2/3] limit file list results to 1000 items (#155) --- lib/impl/AzureBlobFiles.js | 7 +++---- test/impl/AzureBlobFiles.test.js | 34 +++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/lib/impl/AzureBlobFiles.js b/lib/impl/AzureBlobFiles.js index e523519..676d847 100644 --- a/lib/impl/AzureBlobFiles.js +++ b/lib/impl/AzureBlobFiles.js @@ -348,10 +348,9 @@ class AzureBlobFiles extends Files { async _listFolder (filePath) { const __listFolder = async (_filePath, /** @type {AzureProps} */azureProps) => { const elements = [] - const prefix = _filePath - // listBlobsFlat is using the '/' delimiter by default - // error handling (wrap)? - for await (const item of azureProps.containerClient.listBlobsFlat({ prefix })) { + const iterator = azureProps.containerClient.listBlobsFlat({ prefix: _filePath }).byPage({ maxPageSize: 1000 }) + const response = (await iterator.next()).value + for (const item of response.segment.blobItems) { elements.push({ name: item.name, creationTime: item.properties.createdOn, diff --git a/test/impl/AzureBlobFiles.test.js b/test/impl/AzureBlobFiles.test.js index 56c7570..c3616ef 100644 --- a/test/impl/AzureBlobFiles.test.js +++ b/test/impl/AzureBlobFiles.test.js @@ -294,7 +294,19 @@ describe('_listFolder', () => { azure.ContainerClient.mockImplementation(url => { const containerMockList = url.includes('public') ? mockContainerPublicList : mockContainerPrivateList return { - listBlobsFlat: containerMockList, + listBlobsFlat: () => { + return { + byPage: () => { + return { + next: () => { + return { + value: containerMockList() + } + } + } + } + } + }, getBlockBlobClient: () => ({ url: 'some/url?asdklk' }) @@ -308,8 +320,16 @@ describe('_listFolder', () => { async function testListFolder (filePath, listsPublic, listsPrivate, isRoot) { const publicFiles = fakeFiles.map(f => publicDir + f) const privateFiles = fakeFiles2.map(f => privateDir + f) - mockContainerPublicList.mockReturnValue(fakeAzureListResponse(publicFiles)) - mockContainerPrivateList.mockReturnValue(fakeAzureListResponse(privateFiles)) + mockContainerPublicList.mockReturnValue({ + segment: { + blobItems: fakeAzureListResponse(publicFiles) + } + }) + mockContainerPrivateList.mockReturnValue({ + segment: { + blobItems: fakeAzureListResponse(privateFiles) + } + }) const fileList = await files._listFolder(filePath) expect(fileList).toStrictEqual(expect.arrayContaining([expect.objectContaining({ name: expect.any(String) })])) @@ -318,14 +338,6 @@ describe('_listFolder', () => { expect(mockContainerPublicList).toHaveBeenCalledTimes(listsPublic ? 1 : 0) expect(mockContainerPrivateList).toHaveBeenCalledTimes(listsPrivate ? 1 : 0) - - if (listsPublic) { - expect(mockContainerPublicList).toHaveBeenCalledWith({ prefix: isRoot ? 'public' : filePath }) - } - - if (listsPrivate) { - expect(mockContainerPrivateList).toHaveBeenCalledWith({ prefix: filePath }) - } } test('when it is the root (empty string)', async () => { From 204e2256a8be89595afea38128a67142f9c3f460 Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen Date: Tue, 25 Jun 2024 18:19:37 -0700 Subject: [PATCH 3/3] 4.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 36563ff..be90a68 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/aio-lib-files", - "version": "4.0.1", + "version": "4.1.0", "description": "An abstraction on top of blob cloud storage exposing a file like API", "main": "lib/init.js", "directories": {