Skip to content

Commit 725ebfb

Browse files
committed
Merge branch 'main' of https://github.com/weaviate/typescript-client into snyk-upgrade-a63fa331a63835838a38b91e294853e3
2 parents 77c8d31 + 4a16b35 commit 725ebfb

File tree

13 files changed

+1005
-727
lines changed

13 files changed

+1005
-727
lines changed

package-lock.json

Lines changed: 55 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
},
5252
"homepage": "https://github.com/weaviate/typescript-client#readme",
5353
"dependencies": {
54-
"abort-controller-x": "^0.4.3",
55-
"graphql": "^16.11.0",
54+
"abort-controller-x": "^0.5.0",
55+
"graphql": "^16.12.0",
5656
"graphql-request": "^6.1.0",
5757
"long": "^5.3.2",
5858
"nice-grpc": "^2.1.13",
59-
"nice-grpc-client-middleware-retry": "^3.1.11",
59+
"nice-grpc-client-middleware-retry": "^3.1.12",
6060
"nice-grpc-common": "^2.0.2",
6161
"uuid": "^9.0.1"
6262
},

src/backup/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import BackupRestorer from './backupRestorer.js';
66

77
export type Backend = 'filesystem' | 's3' | 'gcs' | 'azure';
88
export type BackupStatus = 'STARTED' | 'TRANSFERRING' | 'TRANSFERRED' | 'SUCCESS' | 'FAILED';
9-
export type BackupCompressionLevel = 'DefaultCompression' | 'BestSpeed' | 'BestCompression';
9+
export type BackupCompressionLevel =
10+
| 'DefaultCompression'
11+
| 'BestSpeed'
12+
| 'BestCompression'
13+
| 'ZstdBestSpeed'
14+
| 'ZstdDefaultCompression'
15+
| 'ZstdBestCompression'
16+
| 'NoCompression';
1017

1118
export interface Backup {
1219
creator: () => BackupCreator;

src/backup/journey.test.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,6 @@ describe('creates backup with valid compression config values', () => {
693693
.withWaitForCompletion(true)
694694
.withConfig({
695695
CPUPercentage: 80,
696-
ChunkSize: 512,
697696
CompressionLevel: 'BestSpeed',
698697
})
699698
.do()
@@ -754,44 +753,6 @@ describe('fails creating backup with invalid compression config', () => {
754753
});
755754
});
756755

757-
it('fails creating backup with ChunkSize too high', () => {
758-
return client.backup
759-
.creator()
760-
.withIncludeClassNames(PIZZA_CLASS_NAME)
761-
.withBackend(BACKEND)
762-
.withBackupId(BACKUP_ID)
763-
.withConfig({
764-
ChunkSize: 513, // Max is 512
765-
})
766-
.do()
767-
.then(() => {
768-
throw new Error('should fail on create backup');
769-
})
770-
.catch((err: Error) => {
771-
expect(err.message).toContain('422');
772-
expect(err.message).toContain('ChunkSize');
773-
});
774-
});
775-
776-
it('fails creating backup with ChunkSize too low', () => {
777-
return client.backup
778-
.creator()
779-
.withIncludeClassNames(PIZZA_CLASS_NAME)
780-
.withBackend(BACKEND)
781-
.withBackupId(BACKUP_ID)
782-
.withConfig({
783-
ChunkSize: 1, // Min is 2
784-
})
785-
.do()
786-
.then(() => {
787-
throw new Error('should fail on create backup');
788-
})
789-
.catch((err: Error) => {
790-
expect(err.message).toContain('422');
791-
expect(err.message).toContain('ChunkSize');
792-
});
793-
});
794-
795756
it('cleans up', () => cleanupTestFood(client));
796757
});
797758

src/collections/backup/client.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
BackupReturn,
2929
BackupStatusArgs,
3030
BackupStatusReturn,
31+
ListBackupOptions,
3132
} from './types.js';
3233

3334
export const backup = (connection: Connection): Backup => {
@@ -117,7 +118,6 @@ export const backup = (connection: Connection): Backup => {
117118
}
118119
if (args.config) {
119120
builder = builder.withConfig({
120-
ChunkSize: args.config.chunkSize,
121121
CompressionLevel: args.config.compressionLevel,
122122
CPUPercentage: args.config.cpuPercentage,
123123
});
@@ -205,8 +205,12 @@ export const backup = (connection: Connection): Backup => {
205205
}
206206
: parseResponse(res);
207207
},
208-
list: (backend: Backend): Promise<BackupReturn[]> => {
209-
return connection.get<BackupReturn[]>(`/backups/${backend}`);
208+
list: (backend: Backend, opts?: ListBackupOptions): Promise<BackupReturn[]> => {
209+
let url = `/backups/${backend}`;
210+
if (opts?.startedAtAsc) {
211+
url += '?order=asc';
212+
}
213+
return connection.get<BackupReturn[]>(url);
210214
},
211215
};
212216
};
@@ -261,7 +265,8 @@ export interface Backup {
261265
/** List existing backups (completed and in-progress) created in a given backend.
262266
*
263267
* @param {Backend} backend Backend whence to list backups.
268+
* @param {ListBackupOptions} [opts] The options available when listing backups.
264269
* @returns {Promise<BackupReturn[]>} The response from Weaviate.
265-
* */
266-
list(backend: Backend): Promise<BackupReturn[]>;
270+
*/
271+
list(backend: Backend, opts?: ListBackupOptions): Promise<BackupReturn[]>;
267272
}

src/collections/backup/integration.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,36 @@ describe('Integration testing of backups', () => {
228228
});
229229
});
230230

231+
requireAtLeast(1, 33, 2).it('get all backups in ascending order', async () => {
232+
await clientPromise.then(async (client) => {
233+
await client.collections.create({ name: 'TestListBackupsAsc' }).then((col) => col.data.insert());
234+
235+
const wantBackups: string[] = [];
236+
for (let i = 0; i < 3; i++) {
237+
wantBackups.push(
238+
await client.backup
239+
.create({
240+
backupId: randomBackupId(),
241+
backend: 'filesystem',
242+
includeCollections: ['TestListBackupsAsc'],
243+
waitForCompletion: true,
244+
})
245+
.then((res) => res.id)
246+
);
247+
}
248+
249+
const sortAscending = true;
250+
const gotBackups = await client.backup.list('filesystem', { startedAtAsc: sortAscending });
251+
252+
// There may be other backups created in other tests;
253+
expect(gotBackups.length).toBeGreaterThanOrEqual(wantBackups.length);
254+
// Expect the backups to be sorted in ascending order
255+
expect(
256+
gotBackups.every((value, idx, a) => idx === 0 || a[idx - 1].startedAt! <= value.startedAt!)
257+
).toBe(sortAscending);
258+
});
259+
});
260+
231261
function randomBackupId() {
232262
return 'backup-id-' + Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
233263
}

src/collections/backup/types.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ export type BackupReturn = BackupStatusReturn & {
2121
backend: Backend;
2222
/** The collections that were included in the backup */
2323
collections: string[];
24+
/** Timestamp when the backup process started */
25+
startedAt?: Date;
26+
/** Timestamp when the backup process completed (successfully or with failure) */
27+
completedAt?: Date;
28+
/** Size of the backup in Gibs */
29+
size?: number;
2430
};
2531

2632
/** Configuration options available when creating a backup */
2733
export type BackupConfigCreate = {
28-
/** The size of the chunks to use for the backup. */
34+
/** Deprecated: This parameter no longer has any effect. (The size of the chunks to use for the backup.) */
2935
chunkSize?: number;
3036
/** The standard of compression to use for the backup. */
3137
compressionLevel?: BackupCompressionLevel;
@@ -72,3 +78,8 @@ export type BackupCancelArgs = {
7278
/** The backend to use for the backup. */
7379
backend: Backend;
7480
};
81+
82+
/** The options available when listing backups. */
83+
export type ListBackupOptions = {
84+
startedAtAsc?: boolean;
85+
};

0 commit comments

Comments
 (0)