api-core
Version:
Model-based dynamic multi-level APIs for any provider, plus multiple consumption channels
98 lines • 4.49 kB
JavaScript
"use strict";
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.LazyApiEdge = void 0;
class LazyApiEdge {
constructor(api, name, plural, resolver) {
this.actions = [];
this.methods = [];
this.relations = [];
this.external = true;
this.createEntry = (context, entryFields) => __awaiter(this, void 0, void 0, function* () {
return this.realEdge.createEntry(context, entryFields);
});
this.exists = (context) => __awaiter(this, void 0, void 0, function* () {
return this.realEdge.exists(context);
});
this.getEntry = (context) => __awaiter(this, void 0, void 0, function* () {
return this.realEdge.getEntry(context);
});
this.listEntries = (context) => __awaiter(this, void 0, void 0, function* () {
return this.realEdge.listEntries(context);
});
this.patchEntry = (context, entryFields) => __awaiter(this, void 0, void 0, function* () {
return this.realEdge.patchEntry(context, entryFields);
});
this.relation = (name) => __awaiter(this, void 0, void 0, function* () {
return this.realEdge.relation(name);
});
this.removeEntry = (context, entryFields) => __awaiter(this, void 0, void 0, function* () {
return this.realEdge.removeEntry(context, entryFields);
});
this.updateEntry = (context, entryFields) => __awaiter(this, void 0, void 0, function* () {
return this.realEdge.updateEntry(context, entryFields);
});
this.prepare = () => Promise.resolve();
this.metadata = () => this.realEdge.metadata();
this.api = api;
this.resolver = resolver;
if (plural) {
this.pluralName = name;
}
else {
this.name = name;
}
}
resolve() {
return __awaiter(this, void 0, void 0, function* () {
if (!this.realEdge) {
const realEdge = yield this.resolver();
if (realEdge) {
this.realEdge = realEdge;
this.name = realEdge.name;
this.pluralName = realEdge.pluralName;
this.relations = realEdge.relations;
this.methods = realEdge.methods;
this.actions = realEdge.actions;
return true;
}
return false;
}
return true;
});
}
get allowCreate() { return this.realEdge.allowCreate; }
set allowCreate(value) { this.realEdge.allowCreate = value; }
get allowExists() { return this.realEdge.allowExists; }
set allowExists(value) { this.realEdge.allowExists = value; }
get allowGet() { return this.realEdge.allowGet; }
set allowGet(value) { this.realEdge.allowGet = value; }
get allowList() { return this.realEdge.allowList; }
set allowList(value) { this.realEdge.allowList = value; }
get allowPatch() { return this.realEdge.allowPatch; }
set allowPatch(value) { this.realEdge.allowPatch = value; }
get allowRemove() { return this.realEdge.allowRemove; }
set allowRemove(value) { this.realEdge.allowRemove = value; }
get allowUpdate() { return this.realEdge.allowUpdate; }
set allowUpdate(value) { this.realEdge.allowUpdate = value; }
get idField() { return this.realEdge.idField; }
set idField(value) { this.realEdge.idField = value; }
get schema() { return this.realEdge.schema; }
set schema(value) { this.realEdge.schema = value; }
get(key) {
this.realEdge.get(key);
}
set(key, value) {
this.realEdge.set(key, value);
}
}
exports.LazyApiEdge = LazyApiEdge;
//# sourceMappingURL=LazyApiEdge.js.map