Skip to content

Commit 36dcd6b

Browse files
committed
Add dist temporarily to allow installation from branch
1 parent b897c79 commit 36dcd6b

File tree

675 files changed

+93823
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

675 files changed

+93823
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.DS_Store
2-
dist/
32
coverage/
43
node_modules/
54
config.yaml
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Connection from '../connection/index.js';
2+
import { BackupCreateStatusResponse } from '../openapi/types.js';
3+
import { CommandBase } from '../validation/commandBase.js';
4+
import { Backend } from './index.js';
5+
export default class BackupCreateStatusGetter extends CommandBase {
6+
private backend?;
7+
private backupId?;
8+
constructor(client: Connection);
9+
withBackend(backend: Backend): this;
10+
withBackupId(backupId: string): this;
11+
validate: () => void;
12+
do: () => Promise<BackupCreateStatusResponse>;
13+
private _path;
14+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
Object.defineProperty(exports, '__esModule', { value: true });
3+
const errors_js_1 = require('../errors.js');
4+
const commandBase_js_1 = require('../validation/commandBase.js');
5+
const validation_js_1 = require('./validation.js');
6+
class BackupCreateStatusGetter extends commandBase_js_1.CommandBase {
7+
constructor(client) {
8+
super(client);
9+
this.validate = () => {
10+
this.addErrors([
11+
...(0, validation_js_1.validateBackend)(this.backend),
12+
...(0, validation_js_1.validateBackupId)(this.backupId),
13+
]);
14+
};
15+
this.do = () => {
16+
this.validate();
17+
if (this.errors.length > 0) {
18+
return Promise.reject(
19+
new errors_js_1.WeaviateInvalidInputError('invalid usage: ' + this.errors.join(', '))
20+
);
21+
}
22+
return this.client.get(this._path());
23+
};
24+
this._path = () => {
25+
return `/backups/${this.backend}/${this.backupId}`;
26+
};
27+
}
28+
withBackend(backend) {
29+
this.backend = backend;
30+
return this;
31+
}
32+
withBackupId(backupId) {
33+
this.backupId = backupId;
34+
return this;
35+
}
36+
}
37+
exports.default = BackupCreateStatusGetter;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Connection from '../connection/index.js';
2+
import {
3+
BackupConfig,
4+
BackupCreateRequest,
5+
BackupCreateResponse,
6+
BackupCreateStatusResponse,
7+
} from '../openapi/types.js';
8+
import { CommandBase } from '../validation/commandBase.js';
9+
import BackupCreateStatusGetter from './backupCreateStatusGetter.js';
10+
import { Backend } from './index.js';
11+
export default class BackupCreator extends CommandBase {
12+
private backend;
13+
private backupId;
14+
private excludeClassNames?;
15+
private includeClassNames?;
16+
private statusGetter;
17+
private waitForCompletion;
18+
private config?;
19+
constructor(client: Connection, statusGetter: BackupCreateStatusGetter);
20+
withIncludeClassNames(...classNames: string[]): this;
21+
withExcludeClassNames(...classNames: string[]): this;
22+
withBackend(backend: Backend): this;
23+
withBackupId(backupId: string): this;
24+
withWaitForCompletion(waitForCompletion: boolean): this;
25+
withConfig(cfg: BackupConfig): this;
26+
validate: () => void;
27+
do: () => Promise<BackupCreateResponse>;
28+
_create: (payload: BackupCreateRequest) => Promise<BackupCreateResponse>;
29+
_createAndWaitForCompletion: (payload: BackupCreateRequest) => Promise<BackupCreateResponse>;
30+
private _path;
31+
_merge: (
32+
createStatusResponse: BackupCreateStatusResponse,
33+
createResponse: BackupCreateResponse
34+
) => BackupCreateResponse;
35+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
'use strict';
2+
Object.defineProperty(exports, '__esModule', { value: true });
3+
const errors_js_1 = require('../errors.js');
4+
const commandBase_js_1 = require('../validation/commandBase.js');
5+
const validation_js_1 = require('./validation.js');
6+
const WAIT_INTERVAL = 1000;
7+
class BackupCreator extends commandBase_js_1.CommandBase {
8+
constructor(client, statusGetter) {
9+
super(client);
10+
this.validate = () => {
11+
this.addErrors([
12+
...(0, validation_js_1.validateIncludeClassNames)(this.includeClassNames),
13+
...(0, validation_js_1.validateExcludeClassNames)(this.excludeClassNames),
14+
...(0, validation_js_1.validateBackend)(this.backend),
15+
...(0, validation_js_1.validateBackupId)(this.backupId),
16+
]);
17+
};
18+
this.do = () => {
19+
this.validate();
20+
if (this.errors.length > 0) {
21+
return Promise.reject(
22+
new errors_js_1.WeaviateInvalidInputError('invalid usage: ' + this.errors.join(', '))
23+
);
24+
}
25+
const payload = {
26+
id: this.backupId,
27+
config: this.config,
28+
include: this.includeClassNames,
29+
exclude: this.excludeClassNames,
30+
};
31+
if (this.waitForCompletion) {
32+
return this._createAndWaitForCompletion(payload);
33+
}
34+
return this._create(payload);
35+
};
36+
this._create = (payload) => {
37+
return this.client.postReturn(this._path(), payload);
38+
};
39+
this._createAndWaitForCompletion = (payload) => {
40+
return new Promise((resolve, reject) => {
41+
this._create(payload)
42+
.then((createResponse) => {
43+
this.statusGetter.withBackend(this.backend).withBackupId(this.backupId);
44+
const loop = () => {
45+
this.statusGetter
46+
.do()
47+
.then((createStatusResponse) => {
48+
if (createStatusResponse.status == 'SUCCESS' || createStatusResponse.status == 'FAILED') {
49+
resolve(this._merge(createStatusResponse, createResponse));
50+
} else {
51+
setTimeout(loop, WAIT_INTERVAL);
52+
}
53+
})
54+
.catch(reject);
55+
};
56+
loop();
57+
})
58+
.catch(reject);
59+
});
60+
};
61+
this._path = () => {
62+
return `/backups/${this.backend}`;
63+
};
64+
this._merge = (createStatusResponse, createResponse) => {
65+
const merged = {};
66+
if ('id' in createStatusResponse) {
67+
merged.id = createStatusResponse.id;
68+
}
69+
if ('path' in createStatusResponse) {
70+
merged.path = createStatusResponse.path;
71+
}
72+
if ('backend' in createStatusResponse) {
73+
merged.backend = createStatusResponse.backend;
74+
}
75+
if ('status' in createStatusResponse) {
76+
merged.status = createStatusResponse.status;
77+
}
78+
if ('error' in createStatusResponse) {
79+
merged.error = createStatusResponse.error;
80+
}
81+
if ('classes' in createResponse) {
82+
merged.classes = createResponse.classes;
83+
}
84+
return merged;
85+
};
86+
this.statusGetter = statusGetter;
87+
}
88+
withIncludeClassNames(...classNames) {
89+
let cls = classNames;
90+
if (classNames.length && Array.isArray(classNames[0])) {
91+
cls = classNames[0];
92+
}
93+
this.includeClassNames = cls;
94+
return this;
95+
}
96+
withExcludeClassNames(...classNames) {
97+
let cls = classNames;
98+
if (classNames.length && Array.isArray(classNames[0])) {
99+
cls = classNames[0];
100+
}
101+
this.excludeClassNames = cls;
102+
return this;
103+
}
104+
withBackend(backend) {
105+
this.backend = backend;
106+
return this;
107+
}
108+
withBackupId(backupId) {
109+
this.backupId = backupId;
110+
return this;
111+
}
112+
withWaitForCompletion(waitForCompletion) {
113+
this.waitForCompletion = waitForCompletion;
114+
return this;
115+
}
116+
withConfig(cfg) {
117+
this.config = cfg;
118+
return this;
119+
}
120+
}
121+
exports.default = BackupCreator;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Connection from '../connection/index.js';
2+
import { BackupCreateResponse } from '../openapi/types.js';
3+
import { CommandBase } from '../validation/commandBase.js';
4+
import { Backend } from './index.js';
5+
export default class BackupGetter extends CommandBase {
6+
private backend?;
7+
constructor(client: Connection);
8+
withBackend(backend: Backend): this;
9+
validate: () => void;
10+
do: () => Promise<BackupCreateResponse[]>;
11+
private _path;
12+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
Object.defineProperty(exports, '__esModule', { value: true });
3+
const errors_js_1 = require('../errors.js');
4+
const commandBase_js_1 = require('../validation/commandBase.js');
5+
const validation_js_1 = require('./validation.js');
6+
class BackupGetter extends commandBase_js_1.CommandBase {
7+
constructor(client) {
8+
super(client);
9+
this.validate = () => {
10+
this.addErrors((0, validation_js_1.validateBackend)(this.backend));
11+
};
12+
this.do = () => {
13+
this.validate();
14+
if (this.errors.length > 0) {
15+
return Promise.reject(
16+
new errors_js_1.WeaviateInvalidInputError('invalid usage: ' + this.errors.join(', '))
17+
);
18+
}
19+
return this.client.get(this._path());
20+
};
21+
this._path = () => {
22+
return `/backups/${this.backend}`;
23+
};
24+
}
25+
withBackend(backend) {
26+
this.backend = backend;
27+
return this;
28+
}
29+
}
30+
exports.default = BackupGetter;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Connection from '../connection/index.js';
2+
import { BackupRestoreStatusResponse } from '../openapi/types.js';
3+
import { CommandBase } from '../validation/commandBase.js';
4+
import { Backend } from './index.js';
5+
export default class BackupRestoreStatusGetter extends CommandBase {
6+
private backend?;
7+
private backupId?;
8+
constructor(client: Connection);
9+
withBackend(backend: Backend): this;
10+
withBackupId(backupId: string): this;
11+
validate: () => void;
12+
do: () => Promise<BackupRestoreStatusResponse>;
13+
private _path;
14+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
Object.defineProperty(exports, '__esModule', { value: true });
3+
const errors_js_1 = require('../errors.js');
4+
const commandBase_js_1 = require('../validation/commandBase.js');
5+
const validation_js_1 = require('./validation.js');
6+
class BackupRestoreStatusGetter extends commandBase_js_1.CommandBase {
7+
constructor(client) {
8+
super(client);
9+
this.validate = () => {
10+
this.addErrors([
11+
...(0, validation_js_1.validateBackend)(this.backend),
12+
...(0, validation_js_1.validateBackupId)(this.backupId),
13+
]);
14+
};
15+
this.do = () => {
16+
this.validate();
17+
if (this.errors.length > 0) {
18+
return Promise.reject(
19+
new errors_js_1.WeaviateInvalidInputError('invalid usage: ' + this.errors.join(', '))
20+
);
21+
}
22+
return this.client.get(this._path());
23+
};
24+
this._path = () => {
25+
return `/backups/${this.backend}/${this.backupId}/restore`;
26+
};
27+
}
28+
withBackend(backend) {
29+
this.backend = backend;
30+
return this;
31+
}
32+
withBackupId(backupId) {
33+
this.backupId = backupId;
34+
return this;
35+
}
36+
}
37+
exports.default = BackupRestoreStatusGetter;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Connection from '../connection/index.js';
2+
import {
3+
BackupRestoreRequest,
4+
BackupRestoreResponse,
5+
BackupRestoreStatusResponse,
6+
RestoreConfig,
7+
} from '../openapi/types.js';
8+
import { CommandBase } from '../validation/commandBase.js';
9+
import BackupRestoreStatusGetter from './backupRestoreStatusGetter.js';
10+
import { Backend } from './index.js';
11+
export default class BackupRestorer extends CommandBase {
12+
private backend;
13+
private backupId;
14+
private excludeClassNames?;
15+
private includeClassNames?;
16+
private statusGetter;
17+
private waitForCompletion?;
18+
private config?;
19+
constructor(client: Connection, statusGetter: BackupRestoreStatusGetter);
20+
withIncludeClassNames(...classNames: string[]): this;
21+
withExcludeClassNames(...classNames: string[]): this;
22+
withBackend(backend: Backend): this;
23+
withBackupId(backupId: string): this;
24+
withWaitForCompletion(waitForCompletion: boolean): this;
25+
withConfig(cfg: RestoreConfig): this;
26+
validate: () => void;
27+
do: () => Promise<BackupRestoreResponse>;
28+
_restore: (payload: BackupRestoreRequest) => Promise<BackupRestoreResponse>;
29+
_restoreAndWaitForCompletion: (payload: BackupRestoreRequest) => Promise<BackupRestoreResponse>;
30+
private _path;
31+
_merge: (
32+
restoreStatusResponse: BackupRestoreStatusResponse,
33+
restoreResponse: BackupRestoreResponse
34+
) => BackupRestoreResponse;
35+
}

0 commit comments

Comments
 (0)