angular-odata
Version:
Client side OData typescript library for Angular
79 lines • 2.84 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Collection = void 0;
const core_1 = require("@angular-devkit/core");
const base_1 = require("./base");
const schematics_1 = require("@angular-devkit/schematics");
class Collection extends base_1.Base {
constructor(pkg, options, edmType, entity, model) {
super(pkg, options);
this.edmType = edmType;
this.entity = entity;
this.model = model;
}
entityType() {
return this.edmType.fullName();
}
template() {
return (0, schematics_1.url)('./files/collection');
}
variables() {
var _a;
return {
type: this.name() + 'Collection',
baseType: this.edmType.BaseType ? this.edmType.BaseType + 'Collection' : null,
entity: this.entity,
model: this.model,
callables: (_a = this.callables) !== null && _a !== void 0 ? _a : [],
functions: [],
};
}
name() {
return core_1.strings.classify(this.edmType.name()) + "Collection";
}
fileName() {
return (core_1.strings.dasherize(this.edmType.name()) + '.collection');
}
directory() {
return this.edmType.namespace().replace(/\./g, '/');
}
fullName() {
return this.edmType.fullName() + "Collection";
}
importTypes() {
var _a, _b, _c, _d, _e;
const imports = [
this.entity.fullName(),
this.model.fullName()
];
if (this.edmType.BaseType) {
imports.push(this.edmType.BaseType);
imports.push(this.edmType.BaseType + 'Collection');
imports.push(this.edmType.BaseType + 'Model');
}
for (let prop of (_b = (_a = this.edmType) === null || _a === void 0 ? void 0 : _a.Property) !== null && _b !== void 0 ? _b : []) {
if (!prop.Type.startsWith('Edm.')) {
imports.push(prop.Type);
imports.push(prop.Type + 'Model');
if (prop.Collection) {
imports.push(prop.Type + 'Collection');
}
}
}
for (let prop of (_d = (_c = this.edmType) === null || _c === void 0 ? void 0 : _c.NavigationProperty) !== null && _d !== void 0 ? _d : []) {
if (!prop.Type.startsWith('Edm.')) {
imports.push(prop.Type);
imports.push(prop.Type + 'Model');
if (prop.Collection) {
imports.push(prop.Type + 'Collection');
}
}
}
for (let callable of (_e = this.callables) !== null && _e !== void 0 ? _e : []) {
imports.push(...callable.importTypes());
}
return imports;
}
}
exports.Collection = Collection;
//# sourceMappingURL=collection.js.map