UNPKG

weaviate-client

Version:
32 lines (31 loc) • 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const commandBase_js_1 = require("../validation/commandBase.js"); const string_js_1 = require("../validation/string.js"); class ClassGetter extends commandBase_js_1.CommandBase { className; constructor(client) { super(client); } withClassName = (className) => { this.className = className; return this; }; validateClassName = () => { if (!(0, string_js_1.isValidStringProperty)(this.className)) { this.addError('className must be set - set with .withClassName(className)'); } }; validate = () => { this.validateClassName(); }; do = () => { this.validate(); if (this.errors.length > 0) { return Promise.reject(new Error('invalid usage: ' + this.errors.join(', '))); } const path = `/schema/${this.className}`; return this.client.get(path); }; } exports.default = ClassGetter;