angular-odata
Version:
Client side OData typescript library for Angular
136 lines • 5.07 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CsdlReturnType = exports.CsdlParameter = exports.CsdlActionImport = exports.CsdlFunctionImport = exports.CsdlAction = exports.CsdlFunction = exports.CsdlCallable = exports.BINDING_PARAMETER_NAME = void 0;
const csdl_annotation_1 = require("./csdl-annotation");
exports.BINDING_PARAMETER_NAME = 'bindingParameter';
class CsdlCallable {
constructor(schema, { Name, ReturnType, IsBound, EntitySetPath, Parameter, }) {
this.schema = schema;
this.Name = Name;
this.ReturnType = ReturnType ? new CsdlReturnType(ReturnType) : undefined;
this.IsBound = IsBound;
this.EntitySetPath = EntitySetPath;
this.Parameter = Parameter === null || Parameter === void 0 ? void 0 : Parameter.map((p) => new CsdlParameter(p));
}
toJson() {
const json = {
Name: this.Name,
};
if (this.ReturnType !== undefined) {
json['ReturnType'] = this.ReturnType.toJson();
}
if (this.IsBound !== undefined) {
json['IsBound'] = this.IsBound;
}
if (this.EntitySetPath !== undefined) {
json['EntitySetPath'] = this.EntitySetPath;
}
if (Array.isArray(this.Parameter) && this.Parameter.length > 0) {
json['Parameter'] = this.Parameter.map((p) => p.toJson());
}
return json;
}
name() {
return `${this.Name}`;
}
namespace() {
return `${this.schema.Namespace}`;
}
fullName() {
return `${this.namespace()}.${this.Name}`;
}
}
exports.CsdlCallable = CsdlCallable;
class CsdlFunction extends CsdlCallable {
constructor(schema, { Name, ReturnType, IsBound, EntitySetPath, IsComposable, Parameter, }) {
super(schema, { Name, ReturnType, IsBound, EntitySetPath, Parameter });
this.IsComposable = IsComposable;
}
toJson() {
return Object.assign(Object.assign({}, super.toJson()), { IsComposable: this.IsComposable });
}
}
exports.CsdlFunction = CsdlFunction;
class CsdlAction extends CsdlCallable {
constructor(schema, { Name, ReturnType, IsBound, EntitySetPath, Parameter, }) {
super(schema, { Name, ReturnType, IsBound, EntitySetPath, Parameter });
}
toJson() {
return Object.assign({}, super.toJson());
}
}
exports.CsdlAction = CsdlAction;
class CsdlFunctionImport {
constructor(container, { Name, FunctionName, EntitySet, IncludeInServiceDocument, }) {
this.container = container;
this.Name = Name;
this.FunctionName = FunctionName;
this.EntitySet = EntitySet;
this.IncludeInServiceDocument = IncludeInServiceDocument;
}
toJson() {
return {
Name: this.Name,
FunctionName: this.FunctionName,
EntitySet: this.EntitySet,
IncludeInServiceDocument: this.IncludeInServiceDocument,
};
}
}
exports.CsdlFunctionImport = CsdlFunctionImport;
class CsdlActionImport {
constructor(container, { Name, Action, EntitySet, }) {
this.container = container;
this.Name = Name;
this.Action = Action;
this.EntitySet = EntitySet;
}
toJson() {
return {
Name: this.Name,
Action: this.Action,
EntitySet: this.EntitySet,
};
}
}
exports.CsdlActionImport = CsdlActionImport;
class CsdlParameter extends csdl_annotation_1.CsdlAnnotable {
constructor({ Name, Type, Nullable, MaxLength, Precision, Scale, SRID, Annotation, }) {
super({ Annotation });
this.Name = Name;
this.Collection = Type.startsWith('Collection(');
this.Type = this.Collection ? Type.substring(11, Type.length - 1) : Type;
this.Nullable = Nullable;
this.MaxLength = MaxLength;
this.Precision = Precision;
this.Scale = Scale;
this.SRID = SRID;
}
toJson() {
return Object.assign(Object.assign({}, super.toJson()), { Name: this.Name, Type: this.Collection ? `Collection(${this.Type})` : this.Type, Nullable: this.Nullable, MaxLength: this.MaxLength, Precision: this.Precision, Scale: this.Scale, SRID: this.SRID });
}
}
exports.CsdlParameter = CsdlParameter;
class CsdlReturnType {
constructor({ Type, Nullable, MaxLength, Precision, Scale, SRID, }) {
this.Collection = Type.startsWith('Collection(');
this.Type = this.Collection ? Type.substring(11, Type.length - 1) : Type;
this.Nullable = Nullable;
this.MaxLength = MaxLength;
this.Precision = Precision;
this.Scale = Scale;
this.SRID = SRID;
}
toJson() {
return {
Type: this.Collection ? `Collection(${this.Type})` : this.Type,
Nullable: this.Nullable,
MaxLength: this.MaxLength,
Precision: this.Precision,
Scale: this.Scale,
SRID: this.SRID,
};
}
}
exports.CsdlReturnType = CsdlReturnType;
//# sourceMappingURL=csdl-function-action.js.map