Skip to content

Commit 02c8db6

Browse files
committed
refactor: clean up
1 parent 3b96703 commit 02c8db6

File tree

4 files changed

+21
-57
lines changed

4 files changed

+21
-57
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"@skyra/jaro-winkler": "^1.1.1",
8080
"adm-zip": "~0.5.15",
8181
"ajv": "~8.17.1",
82-
"apify-client": "^2.13.0",
82+
"apify-client": "^2.14.0",
8383
"archiver": "~7.0.1",
8484
"axios": "^1.11.0",
8585
"chalk": "~5.5.0",

src/commands/actor/get-public-url.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { ACTOR_ENV_VARS, APIFY_ENV_VARS } from '@apify/consts';
2-
import { createHmacSignature } from '@apify/utilities';
32

43
import { getApifyStorageClient } from '../../lib/actor.js';
54
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
@@ -27,8 +26,6 @@ export class ActorGetPublicUrlCommand extends ApifyCommand<typeof ActorGetPublic
2726
process.exitCode = CommandExitCodes.NotImplemented;
2827
return;
2928
}
30-
31-
const apiBase = process.env[APIFY_ENV_VARS.API_PUBLIC_BASE_URL];
3229
const storeId = process.env[ACTOR_ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID];
3330

3431
// This should never happen, but handle it gracefully to prevent crashes.
@@ -43,8 +40,6 @@ export class ActorGetPublicUrlCommand extends ApifyCommand<typeof ActorGetPublic
4340
const apifyClient = await getApifyStorageClient();
4441
const store = await apifyClient.keyValueStore(storeId).get();
4542

46-
const publicUrl = new URL(`${apiBase}/v2/key-value-stores/${storeId}/records/${key}`);
47-
4843
if (!store) {
4944
error({
5045
message: `Key-Value store with ID '${storeId}' was not found. Ensure the store exists and that the correct ID is set in ${ACTOR_ENV_VARS.DEFAULT_KEY_VALUE_STORE_ID}.`,
@@ -53,13 +48,8 @@ export class ActorGetPublicUrlCommand extends ApifyCommand<typeof ActorGetPublic
5348
return;
5449
}
5550

56-
// @ts-expect-error Add types to client
57-
const { urlSigningSecretKey } = store;
58-
59-
if (urlSigningSecretKey) {
60-
publicUrl.searchParams.append('signature', createHmacSignature(urlSigningSecretKey as string, key));
61-
}
51+
const publicTarballUrl = await apifyClient.keyValueStore(storeId).getRecordPublicUrl(key);
6252

63-
console.log(publicUrl.toString());
53+
console.log(publicTarballUrl);
6454
}
6555
}

test/api/commands/push.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mkdir, writeFile } from 'node:fs/promises';
33

44
import type { ActorCollectionCreateOptions } from 'apify-client';
55

6-
import { ACTOR_SOURCE_TYPES, SOURCE_FILE_FORMATS } from '@apify/consts';
6+
import { ACTOR_SOURCE_TYPES, SOURCE_FILE_FORMATS, STORAGE_GENERAL_ACCESS } from '@apify/consts';
77
import { createHmacSignature } from '@apify/utilities';
88

99
import { testRunCommand } from '../../../src/lib/command-framework/apify-command.js';
@@ -238,10 +238,19 @@ describe('[api] apify push', () => {
238238
const testActorVersion = await testActorClient.version(actorJson.version).get();
239239
const store = await testUserClient.keyValueStores().getOrCreate(`actor-${testActor.id}-source`);
240240

241+
// Update the store's general access to RESTRICTED
242+
await testUserClient.keyValueStore(store.id).update({ generalAccess: STORAGE_GENERAL_ACCESS.RESTRICTED });
243+
241244
expect(store.urlSigningSecretKey).toBeDefined();
242245
const signature = createHmacSignature(store.urlSigningSecretKey!, `version-${actorJson.version}.zip`);
243246

244-
await testUserClient.keyValueStore(store.id).delete(); // We just needed the store ID, we can clean up now
247+
// Check if the tarball URL is accessible
248+
await expect(fetch((testActorVersion as { tarballUrl: string }).tarballUrl)).resolves.toHaveProperty(
249+
'status',
250+
200,
251+
);
252+
253+
await testUserClient.keyValueStore(store.id).delete();
245254

246255
if (testActor) await testActorClient.delete();
247256

yarn.lock

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,7 @@ __metadata:
117117
languageName: node
118118
linkType: hard
119119

120-
"@apify/utilities@npm:^2.13.0, @apify/utilities@npm:^2.17.0, @apify/utilities@npm:^2.7.10":
121-
version: 2.17.0
122-
resolution: "@apify/utilities@npm:2.17.0"
123-
dependencies:
124-
"@apify/consts": "npm:^2.43.0"
125-
"@apify/log": "npm:^2.5.20"
126-
checksum: 10c0/673cf27daa31558f305a9b2aa6e8493a254f828fc8797a35dd9aa6810ecac8001ccffb6a2b3dd991176cd3c4f2c14c08c7794a34fd778330968e13e9a6326587
127-
languageName: node
128-
linkType: hard
129-
130-
"@apify/utilities@npm:^2.18.0":
120+
"@apify/utilities@npm:^2.13.0, @apify/utilities@npm:^2.17.0, @apify/utilities@npm:^2.18.0, @apify/utilities@npm:^2.7.10":
131121
version: 2.18.0
132122
resolution: "@apify/utilities@npm:2.18.0"
133123
dependencies:
@@ -2288,7 +2278,7 @@ __metadata:
22882278
adm-zip: "npm:~0.5.15"
22892279
ajv: "npm:~8.17.1"
22902280
apify: "npm:^3.2.4"
2291-
apify-client: "npm:^2.13.0"
2281+
apify-client: "npm:^2.14.0"
22922282
archiver: "npm:~7.0.1"
22932283
axios: "npm:^1.11.0"
22942284
chai: "npm:^4.4.1"
@@ -2340,27 +2330,9 @@ __metadata:
23402330
languageName: unknown
23412331
linkType: soft
23422332

2343-
"apify-client@npm:^2.12.1":
2344-
version: 2.12.6
2345-
resolution: "apify-client@npm:2.12.6"
2346-
dependencies:
2347-
"@apify/consts": "npm:^2.25.0"
2348-
"@apify/log": "npm:^2.2.6"
2349-
"@crawlee/types": "npm:^3.3.0"
2350-
agentkeepalive: "npm:^4.2.1"
2351-
async-retry: "npm:^1.3.3"
2352-
axios: "npm:^1.6.7"
2353-
content-type: "npm:^1.0.5"
2354-
ow: "npm:^0.28.2"
2355-
tslib: "npm:^2.5.0"
2356-
type-fest: "npm:^4.0.0"
2357-
checksum: 10c0/0310242ef5878c6ecc636ba159c82f73c8b07fd3db6c7cbcb42a17032f63fd3d8a258f4b0ddeaaffa138c1ef088f86fe6f7962ff74a52459c4bd7332f945c581
2358-
languageName: node
2359-
linkType: hard
2360-
2361-
"apify-client@npm:^2.13.0":
2362-
version: 2.13.0
2363-
resolution: "apify-client@npm:2.13.0"
2333+
"apify-client@npm:^2.12.1, apify-client@npm:^2.14.0":
2334+
version: 2.14.0
2335+
resolution: "apify-client@npm:2.14.0"
23642336
dependencies:
23652337
"@apify/consts": "npm:^2.25.0"
23662338
"@apify/log": "npm:^2.2.6"
@@ -2373,7 +2345,7 @@ __metadata:
23732345
ow: "npm:^0.28.2"
23742346
tslib: "npm:^2.5.0"
23752347
type-fest: "npm:^4.0.0"
2376-
checksum: 10c0/0596ba6aa4a534fc514e4d32b5ed232f1be7fd49cd3759380332edd136f5697add34a9e2ff3f8e98088f9945faf64ea5a7ebe53eb3d7b3886333ab3eddddfa32
2348+
checksum: 10c0/05eec1e28baa5ff8c8b4273e2671c8075aee1f53b40dad2d00d9d6ac96fdda2e1fe9a62708efa7f8bfc89c09719108822c71dd20ff0e44d5339c35a1ece37578
23772349
languageName: node
23782350
linkType: hard
23792351

@@ -2945,14 +2917,7 @@ __metadata:
29452917
languageName: node
29462918
linkType: hard
29472919

2948-
"chalk@npm:^5.4.1":
2949-
version: 5.4.1
2950-
resolution: "chalk@npm:5.4.1"
2951-
checksum: 10c0/b23e88132c702f4855ca6d25cb5538b1114343e41472d5263ee8a37cccfccd9c4216d111e1097c6a27830407a1dc81fecdf2a56f2c63033d4dbbd88c10b0dcef
2952-
languageName: node
2953-
linkType: hard
2954-
2955-
"chalk@npm:~5.5.0":
2920+
"chalk@npm:^5.4.1, chalk@npm:~5.5.0":
29562921
version: 5.5.0
29572922
resolution: "chalk@npm:5.5.0"
29582923
checksum: 10c0/23063b544f7c2fe57d25ff814807de561f8adfff72e4f0051051eaa606f772586470507ccd38d89166300eeaadb0164acde8bb8a0716a0f2d56ccdf3761d5e4f

0 commit comments

Comments
 (0)