weaviate-client
Version:
JS/TS client for Weaviate
45 lines (44 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const commandBase_js_1 = require("../validation/commandBase.js");
const string_js_1 = require("../validation/string.js");
class ReferencePayloadBuilder extends commandBase_js_1.CommandBase {
className;
id;
constructor(client) {
super(client);
}
withId = (id) => {
this.id = id;
return this;
};
withClassName(className) {
this.className = className;
return this;
}
validateIsSet = (prop, name, setter) => {
if (prop == undefined || prop == null || prop.length == 0) {
this.addError(`${name} must be set - set with ${setter}`);
}
};
validate = () => {
this.validateIsSet(this.id, 'id', '.withId(id)');
};
payload = () => {
this.validate();
if (this.errors.length > 0) {
throw new Error(this.errors.join(', '));
}
let beacon = `weaviate://localhost`;
if ((0, string_js_1.isValidStringProperty)(this.className)) {
beacon = `${beacon}/${this.className}`;
}
return {
beacon: `${beacon}/${this.id}`,
};
};
do() {
return Promise.reject(new Error('Should never be called'));
}
}
exports.default = ReferencePayloadBuilder;