service-model
Version:
An object oriented web service framework inspired by Windows Communication Foundation.
162 lines (161 loc) • 5.33 kB
JavaScript
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var urlTemplate_1 = require("./urlTemplate");
/**
* Metadata that indicates a contract implemented by a service.
* @hidden
*/
var ContractAnnotation = (function () {
/**
* Constructs a contract annotation.
* @param name The name of the contract.
*/
function ContractAnnotation(name) {
this.name = name;
}
return ContractAnnotation;
})();
exports.ContractAnnotation = ContractAnnotation;
/**
* Metadata that describes a method on a service as part of a service contract.
* @hidden
*/
var OperationAnnotation = (function () {
function OperationAnnotation(args) {
if (args) {
this.name = args.name;
this.isOneWay = args.isOneWay;
this.timeout = args.timeout;
this.contract = args.contract;
}
}
return OperationAnnotation;
})();
exports.OperationAnnotation = OperationAnnotation;
/**
* Options for indicating that an operation is callable via a REST api.
*/
var WebInvokeOptions = (function () {
function WebInvokeOptions() {
}
return WebInvokeOptions;
})();
exports.WebInvokeOptions = WebInvokeOptions;
/**
* Metadata that indicates an operation is callable via a REST api.
* @hidden
*/
var WebInvokeAnnotation = (function () {
/**
* Constructs a WebInvokeAnnotation.
* @param options Options for operation that is callable ia a REST api.
*/
function WebInvokeAnnotation(options) {
if (!options) {
throw new Error("Missing required argument 'options'.");
}
if (!options.method) {
throw new Error("Missing required argument 'options.method'.");
}
if (!options.template) {
throw new Error("Missing required argument 'options.template'.");
}
this.method = options.method.toUpperCase();
this.template = new urlTemplate_1.UrlTemplate(options.template);
}
return WebInvokeAnnotation;
})();
exports.WebInvokeAnnotation = WebInvokeAnnotation;
/**
* Metadata that indicates an operation is callable an HTTP GET request.
* @hidden
*/
var WebGetAnnotation = (function (_super) {
__extends(WebGetAnnotation, _super);
/**
* Constructs a WebGetAnnotation.
* @param template The URL template for the operation. For more information, see [[UrlTemplate]].
*/
function WebGetAnnotation(template) {
_super.call(this, { method: "GET", template: template });
}
return WebGetAnnotation;
})(WebInvokeAnnotation);
exports.WebGetAnnotation = WebGetAnnotation;
/**
* Metadata that indicates an operation is callable an HTTP PUT request.
* @hidden
*/
var WebPutAnnotation = (function (_super) {
__extends(WebPutAnnotation, _super);
/**
* Constructs a WebPutAnnotation.
* @param template The URL template for the operation. For more information, see [[UrlTemplate]].
*/
function WebPutAnnotation(template) {
_super.call(this, { method: "PUT", template: template });
}
return WebPutAnnotation;
})(WebInvokeAnnotation);
exports.WebPutAnnotation = WebPutAnnotation;
/**
* Metadata that indicates an operation is callable an HTTP POST request.
* @hidden
*/
var WebPostAnnotation = (function (_super) {
__extends(WebPostAnnotation, _super);
/**
* Constructs a WebPostAnnotation.
* @param template The URL template for the operation. For more information, see [[UrlTemplate]].
*/
function WebPostAnnotation(template) {
_super.call(this, { method: "POST", template: template });
}
return WebPostAnnotation;
})(WebInvokeAnnotation);
exports.WebPostAnnotation = WebPostAnnotation;
/**
* Metadata that indicates an operation is callable an HTTP DELETE request.
* @hidden
*/
var WebDeleteAnnotation = (function (_super) {
__extends(WebDeleteAnnotation, _super);
/**
* Constructs a WebDeleteAnnotation.
* @param template The URL template for the operation. For more information, see [[UrlTemplate]].
*/
function WebDeleteAnnotation(template) {
_super.call(this, { method: "DELETE", template: template });
}
return WebDeleteAnnotation;
})(WebInvokeAnnotation);
exports.WebDeleteAnnotation = WebDeleteAnnotation;
/**
* Metadata that indicates an operation is callable an HTTP HEAD request.
* @hidden
*/
var WebHeadAnnotation = (function (_super) {
__extends(WebHeadAnnotation, _super);
/**
* Constructs a WebHeadAnnotation.
* @param template The URL template for the operation. For more information, see [[UrlTemplate]].
*/
function WebHeadAnnotation(template) {
_super.call(this, { method: "HEAD", template: template });
}
return WebHeadAnnotation;
})(WebInvokeAnnotation);
exports.WebHeadAnnotation = WebHeadAnnotation;
/**
* Metadata indicates that the body of the message should be mapped to the operation parameter.
* @hidden
*/
var InjectBodyAnnotation = (function () {
function InjectBodyAnnotation() {
}
return InjectBodyAnnotation;
})();
exports.InjectBodyAnnotation = InjectBodyAnnotation;