UNPKG

weaviate-client

Version:
31 lines (30 loc) • 916 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const commandBase_js_1 = require("../validation/commandBase.js"); class ClassCreator extends commandBase_js_1.CommandBase { class; constructor(client) { super(client); } withClass = (classObj) => { this.class = classObj; return this; }; validateClass = () => { if (this.class == undefined || this.class == null) { this.addError('class object must be set - set with .withClass(class)'); } }; validate() { this.validateClass(); } do = () => { this.validateClass(); if (this.errors.length > 0) { return Promise.reject(new Error('invalid usage: ' + this.errors.join(', '))); } const path = `/schema`; return this.client.postReturn(path, this.class); }; } exports.default = ClassCreator;