-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from weaviate/fix/stats-undefined-in-isFilePr…
…omise Resolve `false` for `isFilePromise` if `stats` is undefined
- Loading branch information
Showing
676 changed files
with
93,844 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.DS_Store | ||
dist/ | ||
coverage/ | ||
node_modules/ | ||
config.yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Connection from '../connection/index.js'; | ||
import { BackupCreateStatusResponse } from '../openapi/types.js'; | ||
import { CommandBase } from '../validation/commandBase.js'; | ||
import { Backend } from './index.js'; | ||
export default class BackupCreateStatusGetter extends CommandBase { | ||
private backend?; | ||
private backupId?; | ||
constructor(client: Connection); | ||
withBackend(backend: Backend): this; | ||
withBackupId(backupId: string): this; | ||
validate: () => void; | ||
do: () => Promise<BackupCreateStatusResponse>; | ||
private _path; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const errors_js_1 = require('../errors.js'); | ||
const commandBase_js_1 = require('../validation/commandBase.js'); | ||
const validation_js_1 = require('./validation.js'); | ||
class BackupCreateStatusGetter extends commandBase_js_1.CommandBase { | ||
constructor(client) { | ||
super(client); | ||
this.validate = () => { | ||
this.addErrors([ | ||
...(0, validation_js_1.validateBackend)(this.backend), | ||
...(0, validation_js_1.validateBackupId)(this.backupId), | ||
]); | ||
}; | ||
this.do = () => { | ||
this.validate(); | ||
if (this.errors.length > 0) { | ||
return Promise.reject( | ||
new errors_js_1.WeaviateInvalidInputError('invalid usage: ' + this.errors.join(', ')) | ||
); | ||
} | ||
return this.client.get(this._path()); | ||
}; | ||
this._path = () => { | ||
return `/backups/${this.backend}/${this.backupId}`; | ||
}; | ||
} | ||
withBackend(backend) { | ||
this.backend = backend; | ||
return this; | ||
} | ||
withBackupId(backupId) { | ||
this.backupId = backupId; | ||
return this; | ||
} | ||
} | ||
exports.default = BackupCreateStatusGetter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Connection from '../connection/index.js'; | ||
import { | ||
BackupConfig, | ||
BackupCreateRequest, | ||
BackupCreateResponse, | ||
BackupCreateStatusResponse, | ||
} from '../openapi/types.js'; | ||
import { CommandBase } from '../validation/commandBase.js'; | ||
import BackupCreateStatusGetter from './backupCreateStatusGetter.js'; | ||
import { Backend } from './index.js'; | ||
export default class BackupCreator extends CommandBase { | ||
private backend; | ||
private backupId; | ||
private excludeClassNames?; | ||
private includeClassNames?; | ||
private statusGetter; | ||
private waitForCompletion; | ||
private config?; | ||
constructor(client: Connection, statusGetter: BackupCreateStatusGetter); | ||
withIncludeClassNames(...classNames: string[]): this; | ||
withExcludeClassNames(...classNames: string[]): this; | ||
withBackend(backend: Backend): this; | ||
withBackupId(backupId: string): this; | ||
withWaitForCompletion(waitForCompletion: boolean): this; | ||
withConfig(cfg: BackupConfig): this; | ||
validate: () => void; | ||
do: () => Promise<BackupCreateResponse>; | ||
_create: (payload: BackupCreateRequest) => Promise<BackupCreateResponse>; | ||
_createAndWaitForCompletion: (payload: BackupCreateRequest) => Promise<BackupCreateResponse>; | ||
private _path; | ||
_merge: ( | ||
createStatusResponse: BackupCreateStatusResponse, | ||
createResponse: BackupCreateResponse | ||
) => BackupCreateResponse; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const errors_js_1 = require('../errors.js'); | ||
const commandBase_js_1 = require('../validation/commandBase.js'); | ||
const validation_js_1 = require('./validation.js'); | ||
const WAIT_INTERVAL = 1000; | ||
class BackupCreator extends commandBase_js_1.CommandBase { | ||
constructor(client, statusGetter) { | ||
super(client); | ||
this.validate = () => { | ||
this.addErrors([ | ||
...(0, validation_js_1.validateIncludeClassNames)(this.includeClassNames), | ||
...(0, validation_js_1.validateExcludeClassNames)(this.excludeClassNames), | ||
...(0, validation_js_1.validateBackend)(this.backend), | ||
...(0, validation_js_1.validateBackupId)(this.backupId), | ||
]); | ||
}; | ||
this.do = () => { | ||
this.validate(); | ||
if (this.errors.length > 0) { | ||
return Promise.reject( | ||
new errors_js_1.WeaviateInvalidInputError('invalid usage: ' + this.errors.join(', ')) | ||
); | ||
} | ||
const payload = { | ||
id: this.backupId, | ||
config: this.config, | ||
include: this.includeClassNames, | ||
exclude: this.excludeClassNames, | ||
}; | ||
if (this.waitForCompletion) { | ||
return this._createAndWaitForCompletion(payload); | ||
} | ||
return this._create(payload); | ||
}; | ||
this._create = (payload) => { | ||
return this.client.postReturn(this._path(), payload); | ||
}; | ||
this._createAndWaitForCompletion = (payload) => { | ||
return new Promise((resolve, reject) => { | ||
this._create(payload) | ||
.then((createResponse) => { | ||
this.statusGetter.withBackend(this.backend).withBackupId(this.backupId); | ||
const loop = () => { | ||
this.statusGetter | ||
.do() | ||
.then((createStatusResponse) => { | ||
if (createStatusResponse.status == 'SUCCESS' || createStatusResponse.status == 'FAILED') { | ||
resolve(this._merge(createStatusResponse, createResponse)); | ||
} else { | ||
setTimeout(loop, WAIT_INTERVAL); | ||
} | ||
}) | ||
.catch(reject); | ||
}; | ||
loop(); | ||
}) | ||
.catch(reject); | ||
}); | ||
}; | ||
this._path = () => { | ||
return `/backups/${this.backend}`; | ||
}; | ||
this._merge = (createStatusResponse, createResponse) => { | ||
const merged = {}; | ||
if ('id' in createStatusResponse) { | ||
merged.id = createStatusResponse.id; | ||
} | ||
if ('path' in createStatusResponse) { | ||
merged.path = createStatusResponse.path; | ||
} | ||
if ('backend' in createStatusResponse) { | ||
merged.backend = createStatusResponse.backend; | ||
} | ||
if ('status' in createStatusResponse) { | ||
merged.status = createStatusResponse.status; | ||
} | ||
if ('error' in createStatusResponse) { | ||
merged.error = createStatusResponse.error; | ||
} | ||
if ('classes' in createResponse) { | ||
merged.classes = createResponse.classes; | ||
} | ||
return merged; | ||
}; | ||
this.statusGetter = statusGetter; | ||
} | ||
withIncludeClassNames(...classNames) { | ||
let cls = classNames; | ||
if (classNames.length && Array.isArray(classNames[0])) { | ||
cls = classNames[0]; | ||
} | ||
this.includeClassNames = cls; | ||
return this; | ||
} | ||
withExcludeClassNames(...classNames) { | ||
let cls = classNames; | ||
if (classNames.length && Array.isArray(classNames[0])) { | ||
cls = classNames[0]; | ||
} | ||
this.excludeClassNames = cls; | ||
return this; | ||
} | ||
withBackend(backend) { | ||
this.backend = backend; | ||
return this; | ||
} | ||
withBackupId(backupId) { | ||
this.backupId = backupId; | ||
return this; | ||
} | ||
withWaitForCompletion(waitForCompletion) { | ||
this.waitForCompletion = waitForCompletion; | ||
return this; | ||
} | ||
withConfig(cfg) { | ||
this.config = cfg; | ||
return this; | ||
} | ||
} | ||
exports.default = BackupCreator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Connection from '../connection/index.js'; | ||
import { BackupCreateResponse } from '../openapi/types.js'; | ||
import { CommandBase } from '../validation/commandBase.js'; | ||
import { Backend } from './index.js'; | ||
export default class BackupGetter extends CommandBase { | ||
private backend?; | ||
constructor(client: Connection); | ||
withBackend(backend: Backend): this; | ||
validate: () => void; | ||
do: () => Promise<BackupCreateResponse[]>; | ||
private _path; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const errors_js_1 = require('../errors.js'); | ||
const commandBase_js_1 = require('../validation/commandBase.js'); | ||
const validation_js_1 = require('./validation.js'); | ||
class BackupGetter extends commandBase_js_1.CommandBase { | ||
constructor(client) { | ||
super(client); | ||
this.validate = () => { | ||
this.addErrors((0, validation_js_1.validateBackend)(this.backend)); | ||
}; | ||
this.do = () => { | ||
this.validate(); | ||
if (this.errors.length > 0) { | ||
return Promise.reject( | ||
new errors_js_1.WeaviateInvalidInputError('invalid usage: ' + this.errors.join(', ')) | ||
); | ||
} | ||
return this.client.get(this._path()); | ||
}; | ||
this._path = () => { | ||
return `/backups/${this.backend}`; | ||
}; | ||
} | ||
withBackend(backend) { | ||
this.backend = backend; | ||
return this; | ||
} | ||
} | ||
exports.default = BackupGetter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Connection from '../connection/index.js'; | ||
import { BackupRestoreStatusResponse } from '../openapi/types.js'; | ||
import { CommandBase } from '../validation/commandBase.js'; | ||
import { Backend } from './index.js'; | ||
export default class BackupRestoreStatusGetter extends CommandBase { | ||
private backend?; | ||
private backupId?; | ||
constructor(client: Connection); | ||
withBackend(backend: Backend): this; | ||
withBackupId(backupId: string): this; | ||
validate: () => void; | ||
do: () => Promise<BackupRestoreStatusResponse>; | ||
private _path; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const errors_js_1 = require('../errors.js'); | ||
const commandBase_js_1 = require('../validation/commandBase.js'); | ||
const validation_js_1 = require('./validation.js'); | ||
class BackupRestoreStatusGetter extends commandBase_js_1.CommandBase { | ||
constructor(client) { | ||
super(client); | ||
this.validate = () => { | ||
this.addErrors([ | ||
...(0, validation_js_1.validateBackend)(this.backend), | ||
...(0, validation_js_1.validateBackupId)(this.backupId), | ||
]); | ||
}; | ||
this.do = () => { | ||
this.validate(); | ||
if (this.errors.length > 0) { | ||
return Promise.reject( | ||
new errors_js_1.WeaviateInvalidInputError('invalid usage: ' + this.errors.join(', ')) | ||
); | ||
} | ||
return this.client.get(this._path()); | ||
}; | ||
this._path = () => { | ||
return `/backups/${this.backend}/${this.backupId}/restore`; | ||
}; | ||
} | ||
withBackend(backend) { | ||
this.backend = backend; | ||
return this; | ||
} | ||
withBackupId(backupId) { | ||
this.backupId = backupId; | ||
return this; | ||
} | ||
} | ||
exports.default = BackupRestoreStatusGetter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Connection from '../connection/index.js'; | ||
import { | ||
BackupRestoreRequest, | ||
BackupRestoreResponse, | ||
BackupRestoreStatusResponse, | ||
RestoreConfig, | ||
} from '../openapi/types.js'; | ||
import { CommandBase } from '../validation/commandBase.js'; | ||
import BackupRestoreStatusGetter from './backupRestoreStatusGetter.js'; | ||
import { Backend } from './index.js'; | ||
export default class BackupRestorer extends CommandBase { | ||
private backend; | ||
private backupId; | ||
private excludeClassNames?; | ||
private includeClassNames?; | ||
private statusGetter; | ||
private waitForCompletion?; | ||
private config?; | ||
constructor(client: Connection, statusGetter: BackupRestoreStatusGetter); | ||
withIncludeClassNames(...classNames: string[]): this; | ||
withExcludeClassNames(...classNames: string[]): this; | ||
withBackend(backend: Backend): this; | ||
withBackupId(backupId: string): this; | ||
withWaitForCompletion(waitForCompletion: boolean): this; | ||
withConfig(cfg: RestoreConfig): this; | ||
validate: () => void; | ||
do: () => Promise<BackupRestoreResponse>; | ||
_restore: (payload: BackupRestoreRequest) => Promise<BackupRestoreResponse>; | ||
_restoreAndWaitForCompletion: (payload: BackupRestoreRequest) => Promise<BackupRestoreResponse>; | ||
private _path; | ||
_merge: ( | ||
restoreStatusResponse: BackupRestoreStatusResponse, | ||
restoreResponse: BackupRestoreResponse | ||
) => BackupRestoreResponse; | ||
} |
Oops, something went wrong.