@forge/object-store 1.4.6 → 1.5.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -328,6 +328,50 @@ describe('ObjectStoreClient', () => {
328
328
  expect(mockResponse.text).toHaveBeenCalled();
329
329
  expect(response).toEqual({ url: 'cdn-url' });
330
330
  });
331
+ it('should send a POST request with empty options and return a URL', async () => {
332
+ const mockResponse = {
333
+ ok: true,
334
+ status: 200,
335
+ text: createMockBody(JSON.stringify({ url: 'cdn-url' }))
336
+ };
337
+ mockFetch.mockResolvedValue(mockResponse);
338
+ const objectId = '1';
339
+ const response = await osClient.createCDNUrl(objectId, {});
340
+ expect(mockFetch).toHaveBeenCalledWith('api/v1/cdn-url', {
341
+ method: 'POST',
342
+ redirect: 'follow',
343
+ headers: {
344
+ Accept: 'application/json',
345
+ 'Content-Type': 'application/json'
346
+ },
347
+ body: JSON.stringify({ key: objectId })
348
+ });
349
+ expect(mockResponse.status).toBe(200);
350
+ expect(mockResponse.text).toHaveBeenCalled();
351
+ expect(response).toEqual({ url: 'cdn-url' });
352
+ });
353
+ it('should send a POST request with ttlSeconds option and return a URL', async () => {
354
+ const mockResponse = {
355
+ ok: true,
356
+ status: 200,
357
+ text: createMockBody(JSON.stringify({ url: 'cdn-url' }))
358
+ };
359
+ mockFetch.mockResolvedValue(mockResponse);
360
+ const objectId = '1';
361
+ const response = await osClient.createCDNUrl(objectId, { ttlSeconds: 3600 });
362
+ expect(mockFetch).toHaveBeenCalledWith('api/v1/cdn-url', {
363
+ method: 'POST',
364
+ redirect: 'follow',
365
+ headers: {
366
+ Accept: 'application/json',
367
+ 'Content-Type': 'application/json'
368
+ },
369
+ body: JSON.stringify({ key: objectId, ttlSeconds: 3600 })
370
+ });
371
+ expect(mockResponse.status).toBe(200);
372
+ expect(mockResponse.text).toHaveBeenCalled();
373
+ expect(response).toEqual({ url: 'cdn-url' });
374
+ });
331
375
  it('should return undefined when server returns 404', async () => {
332
376
  const mockResponse = {
333
377
  ok: false,
package/out/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { objectStore } from './object-store';
2
2
  import { errorCodes } from './errorCodes';
3
3
  import { ForgeError } from './errors';
4
- import { ObjectReference, UploadUrlBody, PresignedUrlResponse, GetOptions, DeleteOptions, CreateDownloadUrlOptions } from './types';
5
- export { errorCodes, objectStore, ForgeError, ObjectReference, UploadUrlBody, PresignedUrlResponse, GetOptions, DeleteOptions, CreateDownloadUrlOptions };
4
+ import { CDNOptions, ObjectReference, UploadUrlBody, PresignedUrlResponse, GetOptions, DeleteOptions, CreateDownloadUrlOptions } from './types';
5
+ export { errorCodes, objectStore, ForgeError, CDNOptions, ObjectReference, UploadUrlBody, PresignedUrlResponse, GetOptions, DeleteOptions, CreateDownloadUrlOptions };
6
6
  export default objectStore;
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EACL,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,wBAAwB,EACzB,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EACL,UAAU,EACV,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,wBAAwB,EACzB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,4 +1,4 @@
1
- import { CreateDownloadUrlOptions, DeleteOptions, GetOptions, ObjectReference, PresignedUrlResponse, UploadUrlBody } from './types';
1
+ import { CDNOptions, CreateDownloadUrlOptions, DeleteOptions, GetOptions, ObjectReference, PresignedUrlResponse, UploadUrlBody } from './types';
2
2
  export declare class ObjectStoreClient {
3
3
  private sendRequest;
4
4
  private requestJson;
@@ -8,7 +8,7 @@ export declare class ObjectStoreClient {
8
8
  createPublicUploadUrl(body: UploadUrlBody): Promise<PresignedUrlResponse | undefined>;
9
9
  createDownloadUrl(key: string, options?: CreateDownloadUrlOptions): Promise<PresignedUrlResponse | undefined>;
10
10
  createPublicDownloadUrl(key: string, options?: CreateDownloadUrlOptions): Promise<PresignedUrlResponse | undefined>;
11
- createCDNUrl(key: string): Promise<PresignedUrlResponse | undefined>;
11
+ createCDNUrl(key: string, options?: CDNOptions): Promise<PresignedUrlResponse | undefined>;
12
12
  }
13
13
  export declare const objectStore: ObjectStoreClient;
14
14
  //# sourceMappingURL=object-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"object-store.d.ts","sourceRoot":"","sources":["../src/object-store.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,aAAa,EACd,MAAM,SAAS,CAAC;AASjB,qBAAa,iBAAiB;YAEd,WAAW;YASX,WAAW;IAoCZ,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OA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B,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAiBrF,iBAAiB,CAC5B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAkB/B,uBAAuB,CAClC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAmB/B,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;CAYxG;AAED,eAAO,MAAM,WAAW,mBAA0B,CAAC"}
@@ -77,11 +77,12 @@ class ObjectStoreClient {
77
77
  'Content-Type': 'application/json'
78
78
  }, JSON.stringify({ key, cdn }));
79
79
  }
80
- async createCDNUrl(key) {
80
+ async createCDNUrl(key, options) {
81
+ const ttlSeconds = options?.ttlSeconds;
81
82
  return this.requestJson(ValidHttpMethod.POST, 'api/v1/cdn-url', {
82
83
  Accept: 'application/json',
83
84
  'Content-Type': 'application/json'
84
- }, JSON.stringify({ key }));
85
+ }, JSON.stringify({ key, ttlSeconds }));
85
86
  }
86
87
  }
87
88
  exports.ObjectStoreClient = ObjectStoreClient;
package/out/types.d.ts CHANGED
@@ -24,4 +24,7 @@ export interface BaseOptions {
24
24
  export declare type GetOptions = BaseOptions;
25
25
  export declare type DeleteOptions = BaseOptions;
26
26
  export declare type CreateDownloadUrlOptions = BaseOptions;
27
+ export declare type CDNOptions = {
28
+ ttlSeconds?: number;
29
+ };
27
30
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EA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,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,oBAAY,UAAU,GAAG,WAAW,CAAC;AACrC,oBAAY,aAAa,GAAG,WAAW,CAAC;AACxC,oBAAY,wBAAwB,GAAG,WAAW,CAAC;AAEnD,oBAAY,UAAU,GAAG;IAEvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/object-store",
3
- "version": "1.4.6",
3
+ "version": "1.5.0-next.1",
4
4
  "description": "Forge Object Store SDK",
5
5
  "author": "Atlassian",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -20,7 +20,7 @@
20
20
  "jest-when": "^3.6.0"
21
21
  },
22
22
  "dependencies": {
23
- "@forge/api": "^7.2.2"
23
+ "@forge/api": "^8.0.0-next.0"
24
24
  },
25
25
  "publishConfig": {
26
26
  "registry": "https://packages.atlassian.com/api/npm/npm-public/"