@forge/object-store 3.0.4-next.0-experimental-1e95696 → 3.1.0-next.2
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.
- package/CHANGELOG.md +11 -3
- package/README.md +50 -0
- package/out/__test__/object-store.test.js +151 -0
- package/out/index.d.ts +2 -2
- package/out/index.d.ts.map +1 -1
- package/out/object-store.d.ts +3 -1
- package/out/object-store.d.ts.map +1 -1
- package/out/object-store.js +12 -0
- package/out/types.d.ts +10 -0
- package/out/types.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
# @forge/object-store
|
|
2
2
|
|
|
3
|
-
## 3.0
|
|
3
|
+
## 3.1.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c1a872c: Add `copy` to create an object copy with independent TTL, overwrite, and CDN bucket options, and `touch` to copy metadata onto the same key to renew TTL. Omitting TTL removes expiry. Both operations share the stored bytes without downloading or re-uploading them.
|
|
8
|
+
|
|
9
|
+
Expose the optional ISO-8601 `expiresAt` timestamp on `ObjectReference`. Objects without expiry omit this field.
|
|
10
|
+
|
|
11
|
+
## 3.0.4-next.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
6
14
|
|
|
7
|
-
- Updated dependencies [
|
|
8
|
-
- @forge/api@8.
|
|
15
|
+
- Updated dependencies [8bb2533]
|
|
16
|
+
- @forge/api@8.5.0-next.3
|
|
9
17
|
|
|
10
18
|
## 3.0.4-next.0
|
|
11
19
|
|
package/README.md
CHANGED
|
@@ -77,3 +77,53 @@ const message = buffer.equals(downloaded)
|
|
|
77
77
|
|
|
78
78
|
console.log(message);
|
|
79
79
|
```
|
|
80
|
+
|
|
81
|
+
## Copy objects and manage TTL
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// Copy within the same installation and bucket, with an independent one-day TTL.
|
|
85
|
+
const copied = await fos.copy({
|
|
86
|
+
sourceKey: 'reports/current.pdf',
|
|
87
|
+
destinationKey: 'reports/archive.pdf',
|
|
88
|
+
ttlSeconds: 86400,
|
|
89
|
+
overwrite: false,
|
|
90
|
+
cdn: false
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Reset TTL at the existing key to one day from now.
|
|
94
|
+
const renewed = await fos.touch('reports/current.pdf', { ttlSeconds: 86400 });
|
|
95
|
+
|
|
96
|
+
// Remove the existing expiry and retain the object indefinitely.
|
|
97
|
+
const permanent = await fos.touch('reports/current.pdf');
|
|
98
|
+
|
|
99
|
+
// Select the CDN bucket when touching a CDN object.
|
|
100
|
+
await fos.touch('assets/logo.png', { cdn: true, ttlSeconds: 86400 });
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Both methods return `ObjectReference | undefined`: destination metadata on success, or `undefined` when the source does not exist, has expired, or has been deleted. Other API failures use the SDK's existing error handling. Metadata includes an optional `expiresAt` ISO-8601 timestamp, omitted when the object has no expiry.
|
|
104
|
+
|
|
105
|
+
`copy` accepts all fields of the service request:
|
|
106
|
+
|
|
107
|
+
| Field | Required | Behavior |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| `sourceKey` | Yes | Source object key. |
|
|
110
|
+
| `destinationKey` | Yes | Destination object key. |
|
|
111
|
+
| `ttlSeconds` | No | Positive integer seconds up to `Number.MAX_SAFE_INTEGER`, measured from the copy time. Omit to remove expiry from the destination. |
|
|
112
|
+
| `overwrite` | No | Defaults to `true`. Set to `false` to reject an existing destination. Equal source and destination keys with `overwrite: false` return 400. |
|
|
113
|
+
| `cdn` | No | Defaults to `false`. Selects the same bucket for both keys. |
|
|
114
|
+
|
|
115
|
+
`touch(key, options?)` calls `copy` with equal source and destination keys and `overwrite: true`. `TouchOptions` accepts `ttlSeconds` and `cdn`. Omitting `ttlSeconds`, including when only `cdn` is provided, removes the object's existing expiry. Touch creates a new metadata version and resets its creation timestamp. It cannot restore an expired or deleted object.
|
|
116
|
+
|
|
117
|
+
Copying shares the stored bytes without downloading or uploading them. Copies at different keys have independent expiry and deletion metadata. Keys are passed through unchanged, including empty or whitespace-only strings.
|
|
118
|
+
|
|
119
|
+
The package exports `CopyBody` and `TouchOptions` for typed callers:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import fos, { CopyBody, TouchOptions } from '@forge/object-store';
|
|
123
|
+
|
|
124
|
+
const copyBody: CopyBody = { sourceKey: 'source', destinationKey: 'destination' };
|
|
125
|
+
const touchOptions: TouchOptions = { ttlSeconds: 3600 };
|
|
126
|
+
|
|
127
|
+
await fos.copy(copyBody);
|
|
128
|
+
await fos.touch('source', touchOptions);
|
|
129
|
+
```
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
3
4
|
const api_1 = require("@forge/api");
|
|
4
5
|
const object_store_1 = require("../object-store");
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
const index_1 = tslib_1.__importDefault(require("../index"));
|
|
8
|
+
const expect_type_1 = require("expect-type");
|
|
5
9
|
jest.mock('@forge/api');
|
|
6
10
|
const DEFAULT_HEADERS = {
|
|
7
11
|
Accept: 'application/json',
|
|
@@ -112,6 +116,23 @@ describe('ObjectStoreClient', () => {
|
|
|
112
116
|
expect(mockResponse.text).toHaveBeenCalled();
|
|
113
117
|
expect(response).toEqual({ message: 'Blåhaj' });
|
|
114
118
|
});
|
|
119
|
+
it.each([undefined, '2026-11-05T01:00:00.000Z'])('returns metadata with optional expiry %s', async (expiresAt) => {
|
|
120
|
+
const metadata = {
|
|
121
|
+
key: 'key',
|
|
122
|
+
checksum: 'checksum',
|
|
123
|
+
size: 123,
|
|
124
|
+
...(expiresAt !== undefined && { expiresAt })
|
|
125
|
+
};
|
|
126
|
+
mockFetch.mockResolvedValue({ ok: true, status: 200, text: createMockBody(JSON.stringify(metadata)) });
|
|
127
|
+
const response = await osClient.get('key');
|
|
128
|
+
expect(response).toEqual(metadata);
|
|
129
|
+
if (expiresAt === undefined) {
|
|
130
|
+
expect(response).not.toHaveProperty('expiresAt');
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
expect(response?.expiresAt).toBe(expiresAt);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
115
136
|
});
|
|
116
137
|
describe('delete', () => {
|
|
117
138
|
it('should send a POST request with the correct headers and body', async () => {
|
|
@@ -149,6 +170,136 @@ describe('ObjectStoreClient', () => {
|
|
|
149
170
|
expect(mockResponse.text).toHaveBeenCalled();
|
|
150
171
|
});
|
|
151
172
|
});
|
|
173
|
+
describe('copy', () => {
|
|
174
|
+
const metadata = {
|
|
175
|
+
key: 'destination',
|
|
176
|
+
checksum: 'checksum',
|
|
177
|
+
size: 123,
|
|
178
|
+
expiresAt: '2026-11-05T01:00:00.000Z'
|
|
179
|
+
};
|
|
180
|
+
it.each([
|
|
181
|
+
{ sourceKey: 'source', destinationKey: 'destination' },
|
|
182
|
+
{ sourceKey: 'source', destinationKey: 'destination', ttlSeconds: 3600, overwrite: false, cdn: true },
|
|
183
|
+
{ sourceKey: 'source', destinationKey: 'destination', overwrite: true, cdn: false },
|
|
184
|
+
{ sourceKey: '', destinationKey: ' \t' },
|
|
185
|
+
{ sourceKey: 'source', destinationKey: 'destination', ttlSeconds: Number.MAX_SAFE_INTEGER }
|
|
186
|
+
])('sends the complete copy request through the existing transport: %j', async (body) => {
|
|
187
|
+
mockFetch.mockResolvedValue({ ok: true, status: 200, text: createMockBody(JSON.stringify(metadata)) });
|
|
188
|
+
const response = await osClient.copy(body);
|
|
189
|
+
expect(api_1.__fetchProduct).toHaveBeenCalledWith({ provider: 'app', remote: 'os', type: 'os' });
|
|
190
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
191
|
+
expect(mockFetch).toHaveBeenCalledWith('api/v1/copy', {
|
|
192
|
+
method: 'POST',
|
|
193
|
+
redirect: 'follow',
|
|
194
|
+
headers: DEFAULT_HEADERS,
|
|
195
|
+
body: JSON.stringify(body)
|
|
196
|
+
});
|
|
197
|
+
expect(response).toEqual(metadata);
|
|
198
|
+
});
|
|
199
|
+
it('omits TTL and overwrite so the service removes expiry and applies its overwrite default', async () => {
|
|
200
|
+
mockFetch.mockResolvedValue({ ok: true, status: 200, text: createMockBody(JSON.stringify(metadata)) });
|
|
201
|
+
await osClient.copy({
|
|
202
|
+
sourceKey: 'source',
|
|
203
|
+
destinationKey: 'destination',
|
|
204
|
+
ttlSeconds: undefined,
|
|
205
|
+
overwrite: undefined
|
|
206
|
+
});
|
|
207
|
+
const body = JSON.parse(mockFetch.mock.calls[0][1].body);
|
|
208
|
+
expect(body).toEqual({ sourceKey: 'source', destinationKey: 'destination' });
|
|
209
|
+
expect(body).not.toHaveProperty('ttlSeconds');
|
|
210
|
+
expect(body).not.toHaveProperty('overwrite');
|
|
211
|
+
});
|
|
212
|
+
it('returns undefined for a missing, expired, or deleted source', async () => {
|
|
213
|
+
const text = jest.fn();
|
|
214
|
+
mockFetch.mockResolvedValue({ ok: false, status: 404, text });
|
|
215
|
+
await expect(osClient.copy({ sourceKey: 'missing', destinationKey: 'destination' })).resolves.toBeUndefined();
|
|
216
|
+
expect(text).not.toHaveBeenCalled();
|
|
217
|
+
});
|
|
218
|
+
it.each([400, 409, 429, 500])('preserves existing API error behavior for status %s', async (status) => {
|
|
219
|
+
mockFetch.mockResolvedValue(new Response(JSON.stringify({ code: 'COPY_FAILED', message: 'Copy failed' }), { status }));
|
|
220
|
+
await expect(osClient.copy({ sourceKey: 'source', destinationKey: 'destination', overwrite: false })).rejects.toBeInstanceOf(errors_1.ForgeObjectStoreAPIError);
|
|
221
|
+
});
|
|
222
|
+
it('propagates transport failures without retrying the mutation', async () => {
|
|
223
|
+
const error = new Error('transport unavailable');
|
|
224
|
+
mockFetch.mockRejectedValue(error);
|
|
225
|
+
await expect(osClient.copy({ sourceKey: 'source', destinationKey: 'destination' })).rejects.toBe(error);
|
|
226
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
describe('touch', () => {
|
|
230
|
+
const metadata = {
|
|
231
|
+
key: 'key',
|
|
232
|
+
checksum: 'checksum',
|
|
233
|
+
size: 123,
|
|
234
|
+
createdAt: '2026-11-05T00:00:00Z',
|
|
235
|
+
expiresAt: '2026-11-05T01:00:00.000Z'
|
|
236
|
+
};
|
|
237
|
+
it.each([
|
|
238
|
+
{ key: 'key', options: undefined, expected: { sourceKey: 'key', destinationKey: 'key', overwrite: true } },
|
|
239
|
+
{ key: 'key', options: {}, expected: { sourceKey: 'key', destinationKey: 'key', overwrite: true } },
|
|
240
|
+
{
|
|
241
|
+
key: 'key',
|
|
242
|
+
options: { ttlSeconds: 3600 },
|
|
243
|
+
expected: { sourceKey: 'key', destinationKey: 'key', overwrite: true, ttlSeconds: 3600 }
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
key: 'key',
|
|
247
|
+
options: { cdn: true },
|
|
248
|
+
expected: { sourceKey: 'key', destinationKey: 'key', overwrite: true, cdn: true }
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
key: 'key',
|
|
252
|
+
options: { ttlSeconds: 60, cdn: true },
|
|
253
|
+
expected: { sourceKey: 'key', destinationKey: 'key', overwrite: true, ttlSeconds: 60, cdn: true }
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
key: '',
|
|
257
|
+
options: { cdn: false },
|
|
258
|
+
expected: { sourceKey: '', destinationKey: '', overwrite: true, cdn: false }
|
|
259
|
+
},
|
|
260
|
+
{ key: ' \t', options: undefined, expected: { sourceKey: ' \t', destinationKey: ' \t', overwrite: true } }
|
|
261
|
+
])('sends one same-key copy without inventing a TTL: %j', async ({ key, options, expected }) => {
|
|
262
|
+
mockFetch.mockResolvedValue({ ok: true, status: 200, text: createMockBody(JSON.stringify(metadata)) });
|
|
263
|
+
const response = await osClient.touch(key, options);
|
|
264
|
+
expect(response).toEqual(metadata);
|
|
265
|
+
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
266
|
+
expect(mockFetch).toHaveBeenCalledWith('api/v1/copy', {
|
|
267
|
+
method: 'POST',
|
|
268
|
+
redirect: 'follow',
|
|
269
|
+
headers: DEFAULT_HEADERS,
|
|
270
|
+
body: expect.any(String)
|
|
271
|
+
});
|
|
272
|
+
expect(JSON.parse(mockFetch.mock.calls[0][1].body)).toEqual(expected);
|
|
273
|
+
});
|
|
274
|
+
it('delegates to copy with overwrite enabled', async () => {
|
|
275
|
+
const copy = jest.spyOn(osClient, 'copy').mockResolvedValue(metadata);
|
|
276
|
+
await expect(osClient.touch('key', { ttlSeconds: 60, cdn: true })).resolves.toEqual(metadata);
|
|
277
|
+
expect(copy).toHaveBeenCalledWith({
|
|
278
|
+
sourceKey: 'key',
|
|
279
|
+
destinationKey: 'key',
|
|
280
|
+
ttlSeconds: 60,
|
|
281
|
+
overwrite: true,
|
|
282
|
+
cdn: true
|
|
283
|
+
});
|
|
284
|
+
expect(mockFetch).not.toHaveBeenCalled();
|
|
285
|
+
});
|
|
286
|
+
it('returns undefined when the source is missing', async () => {
|
|
287
|
+
mockFetch.mockResolvedValue({ ok: false, status: 404 });
|
|
288
|
+
await expect(osClient.touch('missing')).resolves.toBeUndefined();
|
|
289
|
+
});
|
|
290
|
+
it('propagates service errors', async () => {
|
|
291
|
+
mockFetch.mockResolvedValue(new Response(JSON.stringify({ code: 'BAD_REQUEST', message: 'Invalid TTL' }), { status: 400 }));
|
|
292
|
+
await expect(osClient.touch('key', { ttlSeconds: 0 })).rejects.toBeInstanceOf(errors_1.ForgeObjectStoreAPIError);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
it('exports typed copy and touch methods from the public package entry point', () => {
|
|
296
|
+
(0, expect_type_1.expectTypeOf)(index_1.default.copy).parameter(0).toEqualTypeOf();
|
|
297
|
+
(0, expect_type_1.expectTypeOf)().toEqualTypeOf();
|
|
298
|
+
(0, expect_type_1.expectTypeOf)(index_1.default.touch).parameter(0).toEqualTypeOf();
|
|
299
|
+
(0, expect_type_1.expectTypeOf)(index_1.default.touch).parameter(1).toEqualTypeOf();
|
|
300
|
+
(0, expect_type_1.expectTypeOf)().toEqualTypeOf();
|
|
301
|
+
(0, expect_type_1.expectTypeOf)().toEqualTypeOf();
|
|
302
|
+
});
|
|
152
303
|
describe('createUploadUrl', () => {
|
|
153
304
|
it('should send a POST request with the correct headers and body, and return a URL', async () => {
|
|
154
305
|
const mockResponse = {
|
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 { CDNOptions, ObjectReference, UploadUrlBody, PresignedUrlResponse, GetOptions, DeleteOptions, CreateDownloadUrlOptions } from './types';
|
|
5
|
-
export { errorCodes, objectStore, ForgeError, CDNOptions, ObjectReference, UploadUrlBody, PresignedUrlResponse, GetOptions, DeleteOptions, CreateDownloadUrlOptions };
|
|
4
|
+
import { CDNOptions, CopyBody, TouchOptions, ObjectReference, UploadUrlBody, PresignedUrlResponse, GetOptions, DeleteOptions, CreateDownloadUrlOptions } from './types';
|
|
5
|
+
export { errorCodes, objectStore, ForgeError, CDNOptions, CopyBody, TouchOptions, ObjectReference, UploadUrlBody, PresignedUrlResponse, GetOptions, DeleteOptions, CreateDownloadUrlOptions };
|
|
6
6
|
export default objectStore;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -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,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
|
+
{"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,QAAQ,EACR,YAAY,EACZ,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,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,wBAAwB,EACzB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/out/object-store.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { CDNOptions, CreateDownloadUrlOptions, DeleteOptions, GetOptions, ObjectReference, PresignedUrlResponse, UploadUrlBody } from './types';
|
|
1
|
+
import { CDNOptions, CopyBody, CreateDownloadUrlOptions, DeleteOptions, GetOptions, ObjectReference, PresignedUrlResponse, TouchOptions, UploadUrlBody } from './types';
|
|
2
2
|
export declare class ObjectStoreClient {
|
|
3
3
|
private sendRequest;
|
|
4
4
|
private requestJson;
|
|
5
5
|
get(key: string, options?: GetOptions): Promise<ObjectReference | undefined>;
|
|
6
6
|
delete(key: string, options?: DeleteOptions): Promise<void>;
|
|
7
|
+
copy(body: CopyBody): Promise<ObjectReference | undefined>;
|
|
8
|
+
touch(key: string, options?: TouchOptions): Promise<ObjectReference | undefined>;
|
|
7
9
|
createUploadUrl(body: UploadUrlBody): Promise<PresignedUrlResponse | undefined>;
|
|
8
10
|
createPublicUploadUrl(body: UploadUrlBody): Promise<PresignedUrlResponse | undefined>;
|
|
9
11
|
createDownloadUrl(key: string, options?: CreateDownloadUrlOptions): Promise<PresignedUrlResponse | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-store.d.ts","sourceRoot":"","sources":["../src/object-store.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,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,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAkB5E,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"object-store.d.ts","sourceRoot":"","sources":["../src/object-store.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACd,MAAM,SAAS,CAAC;AASjB,qBAAa,iBAAiB;YAEd,WAAW;YASX,WAAW;IAoCZ,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAkB5E,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB3D,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAe1D,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAchF,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAgB/E,qBAAqB,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"}
|
package/out/object-store.js
CHANGED
|
@@ -51,6 +51,18 @@ class ObjectStoreClient {
|
|
|
51
51
|
const cdn = options?.cdn;
|
|
52
52
|
return this.requestJson(ValidHttpMethod.POST, `api/v1/delete`, { Accept: 'application/json', 'Content-Type': 'application/json' }, JSON.stringify({ key, cdn }));
|
|
53
53
|
}
|
|
54
|
+
async copy(body) {
|
|
55
|
+
return this.requestJson(ValidHttpMethod.POST, 'api/v1/copy', { Accept: 'application/json', 'Content-Type': 'application/json' }, JSON.stringify(body));
|
|
56
|
+
}
|
|
57
|
+
async touch(key, options) {
|
|
58
|
+
return this.copy({
|
|
59
|
+
sourceKey: key,
|
|
60
|
+
destinationKey: key,
|
|
61
|
+
ttlSeconds: options?.ttlSeconds,
|
|
62
|
+
overwrite: true,
|
|
63
|
+
cdn: options?.cdn
|
|
64
|
+
});
|
|
65
|
+
}
|
|
54
66
|
async createUploadUrl(body) {
|
|
55
67
|
return this.requestJson(ValidHttpMethod.POST, 'api/v1/upload-url', {
|
|
56
68
|
Accept: 'application/json',
|
package/out/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface ObjectReference {
|
|
|
3
3
|
checksum: string;
|
|
4
4
|
size: number;
|
|
5
5
|
createdAt?: string;
|
|
6
|
+
expiresAt?: string;
|
|
6
7
|
contentType?: string;
|
|
7
8
|
}
|
|
8
9
|
export interface UploadUrlBody {
|
|
@@ -20,6 +21,15 @@ export interface PresignedUrlResponse {
|
|
|
20
21
|
export interface BaseOptions {
|
|
21
22
|
cdn?: boolean;
|
|
22
23
|
}
|
|
24
|
+
export interface CopyBody extends BaseOptions {
|
|
25
|
+
sourceKey: string;
|
|
26
|
+
destinationKey: string;
|
|
27
|
+
ttlSeconds?: number;
|
|
28
|
+
overwrite?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface TouchOptions extends BaseOptions {
|
|
31
|
+
ttlSeconds?: number;
|
|
32
|
+
}
|
|
23
33
|
export type GetOptions = BaseOptions;
|
|
24
34
|
export type DeleteOptions = BaseOptions;
|
|
25
35
|
export type CreateDownloadUrlOptions = BaseOptions;
|
package/out/types.d.ts.map
CHANGED
|
@@ -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,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,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,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC;AACrC,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC;AACxC,MAAM,MAAM,wBAAwB,GAAG,WAAW,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG;IAEvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC"}
|
|
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,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,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,MAAM,WAAW,QAAS,SAAQ,WAAW;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IAEvB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,YAAa,SAAQ,WAAW;IAE/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC;AACrC,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC;AACxC,MAAM,MAAM,wBAAwB,GAAG,WAAW,CAAC;AAEnD,MAAM,MAAM,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": "3.0
|
|
3
|
+
"version": "3.1.0-next.2",
|
|
4
4
|
"description": "Forge Object Store SDK",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"typescript": "5.9.2"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@forge/api": "^8.
|
|
21
|
+
"@forge/api": "^8.5.0-next.3"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"registry": "https://packages.atlassian.com/api/npm/npm-public/"
|