Skip to content

Commit a190b72

Browse files
authored
refactor!: rename expiresInMillis to expiresInSecs in create storage content URL (#733)
This PR changes `expiresInMillis` to `expiresInSecs` and moves it to options in create storage content URLs: - `KeyValueStore.createKeysPublicUrl(options)` - `Dataset.createItemsPublicUrl(options)` Note: I'm aware that this can potentially be breaking change, but we suppose that no one started using it yet. More context: https://apify.slack.com/archives/C01VBUV81UZ/p1756111935325179
1 parent 0ec9f36 commit a190b72

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/resource_clients/dataset.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ export class DatasetClient<
170170
* If the client has permission to access the dataset's URL signing key,
171171
* the URL will include a signature which will allow the link to work even without authentication.
172172
*
173-
* You can optionally control how long the signed URL should be valid using the `expiresInMillis` option.
174-
* This value sets the expiration duration in milliseconds from the time the URL is generated.
173+
* You can optionally control how long the signed URL should be valid using the `expiresInSecs` option.
174+
* This value sets the expiration duration in seconds from the time the URL is generated.
175175
* If not provided, the URL will not expire.
176176
*
177177
* Any other options (like `limit` or `prefix`) will be included as query parameters in the URL.
178178
*/
179-
async createItemsPublicUrl(options: DatasetClientListItemOptions = {}, expiresInMillis?: number): Promise<string> {
179+
async createItemsPublicUrl(options: DatasetClientCreateItemsUrlOptions = {}): Promise<string> {
180180
ow(
181181
options,
182182
ow.object.exactShape({
@@ -191,6 +191,7 @@ export class DatasetClient<
191191
skipHidden: ow.optional.boolean,
192192
unwind: ow.optional.any(ow.string, ow.array.ofType(ow.string)),
193193
view: ow.optional.string,
194+
expiresInSecs: ow.optional.number,
194195
}),
195196
);
196197

@@ -202,7 +203,7 @@ export class DatasetClient<
202203
const signature = createStorageContentSignature({
203204
resourceId: dataset.id,
204205
urlSigningSecretKey: dataset.urlSigningSecretKey,
205-
expiresInMillis,
206+
expiresInMillis: options.expiresInSecs ? options.expiresInSecs * 1000 : undefined,
206207
});
207208
createdItemsPublicUrl.searchParams.set('signature', signature);
208209
}
@@ -271,6 +272,10 @@ export interface DatasetClientListItemOptions {
271272
view?: string;
272273
}
273274

275+
export interface DatasetClientCreateItemsUrlOptions extends DatasetClientListItemOptions {
276+
expiresInSecs?: number;
277+
}
278+
274279
export enum DownloadItemsFormat {
275280
JSON = 'json',
276281
JSONL = 'jsonl',

src/resource_clients/key_value_store.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,21 @@ export class KeyValueStoreClient extends ResourceClient {
112112
* If the client has permission to access the key-value store's URL signing key,
113113
* the URL will include a signature which will allow the link to work even without authentication.
114114
*
115-
* You can optionally control how long the signed URL should be valid using the `expiresInMillis` option.
116-
* This value sets the expiration duration in milliseconds from the time the URL is generated.
115+
* You can optionally control how long the signed URL should be valid using the `expiresInSecs` option.
116+
* This value sets the expiration duration in seconds from the time the URL is generated.
117117
* If not provided, the URL will not expire.
118118
*
119119
* Any other options (like `limit` or `prefix`) will be included as query parameters in the URL.
120120
*/
121-
async createKeysPublicUrl(options: KeyValueClientListKeysOptions = {}, expiresInMillis?: number) {
121+
async createKeysPublicUrl(options: KeyValueClientCreateKeysUrlOptions = {}) {
122122
ow(
123123
options,
124124
ow.object.exactShape({
125125
limit: ow.optional.number,
126126
exclusiveStartKey: ow.optional.string,
127127
collection: ow.optional.string,
128128
prefix: ow.optional.string,
129+
expiresInSecs: ow.optional.number,
129130
}),
130131
);
131132

@@ -137,7 +138,7 @@ export class KeyValueStoreClient extends ResourceClient {
137138
const signature = createStorageContentSignature({
138139
resourceId: store.id,
139140
urlSigningSecretKey: store.urlSigningSecretKey,
140-
expiresInMillis,
141+
expiresInMillis: options.expiresInSecs ? options.expiresInSecs * 1000 : undefined,
141142
});
142143
createdPublicKeysUrl.searchParams.set('signature', signature);
143144
}
@@ -352,6 +353,10 @@ export interface KeyValueClientListKeysOptions {
352353
prefix?: string;
353354
}
354355

356+
export interface KeyValueClientCreateKeysUrlOptions extends KeyValueClientListKeysOptions {
357+
expiresInSecs?: number;
358+
}
359+
355360
export interface KeyValueClientListKeysResult {
356361
count: number;
357362
limit: number;

0 commit comments

Comments
 (0)