UNPKG

lambdaorm-client-node

Version:
89 lines 3.98 kB
"use strict"; /* eslint-disable @typescript-eslint/ban-types */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.QueryApiService = void 0; const _3xpr_1 = require("3xpr"); class QueryApiService { // eslint-disable-next-line no-useless-constructor constructor(queryApi) { this.queryApi = queryApi; } model(query) { return __awaiter(this, void 0, void 0, function* () { const _query = typeof query !== 'string' ? this.toExpression(query) : query; const result = yield this.queryApi.model({ query: _query }); return result.data; }); } parameters(query) { return __awaiter(this, void 0, void 0, function* () { const _query = typeof query !== 'string' ? this.toExpression(query) : query; const result = yield this.queryApi.parameters({ query: _query }); return result.data; }); } constraints(query) { return __awaiter(this, void 0, void 0, function* () { const _query = typeof query !== 'string' ? this.toExpression(query) : query; const result = yield this.queryApi.constraints({ query: _query }); return result.data; }); } metadata(query) { return __awaiter(this, void 0, void 0, function* () { const _query = typeof query !== 'string' ? this.toExpression(query) : query; const result = yield this.queryApi.metadata({ query: _query }); return result.data; }); } plan(query, options) { return __awaiter(this, void 0, void 0, function* () { const _query = typeof query !== 'string' ? this.toExpression(query) : query; const _options = this.solveOptions(options); const result = yield this.queryApi.plan({ query: _query, options: _options }); return result.data; }); } execute(query_1) { return __awaiter(this, arguments, void 0, function* (query, data = {}, options = undefined) { const _query = typeof query !== 'string' ? this.toExpression(query) : query; const _options = this.solveOptions(options); const result = yield this.queryApi.execute({ query: _query, data, options: _options }); return result.data; }); } executeQueued(query_1, topic_1) { return __awaiter(this, arguments, void 0, function* (query, topic, data = {}, chunk, options = undefined) { const _query = typeof query !== 'string' ? this.toExpression(query) : query; const _options = this.solveOptions(options); const result = yield this.queryApi.executeQueued({ query: _query, data, options: _options, topic, chunk }); return result.data; }); } toExpression(query) { return typeof query !== 'string' ? _3xpr_1.expressions.convert(query, 'function')[0] : query; } solveOptions(options) { if (!options) { options = {}; } if (!options.stage) { options.stage = 'default'; } if (!options.view) { options.view = 'default'; } return options; } } exports.QueryApiService = QueryApiService; //# sourceMappingURL=QueryApiService.js.map