@celljs/mvc 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/cell.yml +9 -0
- package/lib/common/constants.d.ts +2 -0
- package/lib/common/constants.d.ts.map +1 -0
- package/lib/common/constants.js +5 -0
- package/lib/common/constants.js.map +1 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +18 -0
- package/lib/common/index.js.map +1 -0
- package/lib/node/annotation/body.d.ts +7 -0
- package/lib/node/annotation/body.d.ts.map +1 -0
- package/lib/node/annotation/body.js +20 -0
- package/lib/node/annotation/body.js.map +1 -0
- package/lib/node/annotation/catch.d.ts +10 -0
- package/lib/node/annotation/catch.d.ts.map +1 -0
- package/lib/node/annotation/catch.js +23 -0
- package/lib/node/annotation/catch.js.map +1 -0
- package/lib/node/annotation/controller.d.ts +15 -0
- package/lib/node/annotation/controller.d.ts.map +1 -0
- package/lib/node/annotation/controller.js +35 -0
- package/lib/node/annotation/controller.js.map +1 -0
- package/lib/node/annotation/cookie.d.ts +16 -0
- package/lib/node/annotation/cookie.d.ts.map +1 -0
- package/lib/node/annotation/cookie.js +29 -0
- package/lib/node/annotation/cookie.js.map +1 -0
- package/lib/node/annotation/file.d.ts +3 -0
- package/lib/node/annotation/file.d.ts.map +1 -0
- package/lib/node/annotation/file.js +10 -0
- package/lib/node/annotation/file.js.map +1 -0
- package/lib/node/annotation/header.d.ts +16 -0
- package/lib/node/annotation/header.d.ts.map +1 -0
- package/lib/node/annotation/header.js +29 -0
- package/lib/node/annotation/header.js.map +1 -0
- package/lib/node/annotation/html.d.ts +3 -0
- package/lib/node/annotation/html.d.ts.map +1 -0
- package/lib/node/annotation/html.js +10 -0
- package/lib/node/annotation/html.js.map +1 -0
- package/lib/node/annotation/index.d.ts +17 -0
- package/lib/node/annotation/index.d.ts.map +1 -0
- package/lib/node/annotation/index.js +33 -0
- package/lib/node/annotation/index.js.map +1 -0
- package/lib/node/annotation/json.d.ts +3 -0
- package/lib/node/annotation/json.d.ts.map +1 -0
- package/lib/node/annotation/json.js +10 -0
- package/lib/node/annotation/json.js.map +1 -0
- package/lib/node/annotation/method.d.ts +24 -0
- package/lib/node/annotation/method.d.ts.map +1 -0
- package/lib/node/annotation/method.js +54 -0
- package/lib/node/annotation/method.js.map +1 -0
- package/lib/node/annotation/param.d.ts +7 -0
- package/lib/node/annotation/param.d.ts.map +1 -0
- package/lib/node/annotation/param.js +20 -0
- package/lib/node/annotation/param.js.map +1 -0
- package/lib/node/annotation/query.d.ts +7 -0
- package/lib/node/annotation/query.d.ts.map +1 -0
- package/lib/node/annotation/query.js +20 -0
- package/lib/node/annotation/query.js.map +1 -0
- package/lib/node/annotation/req.d.ts +6 -0
- package/lib/node/annotation/req.d.ts.map +1 -0
- package/lib/node/annotation/req.js +18 -0
- package/lib/node/annotation/req.js.map +1 -0
- package/lib/node/annotation/res.d.ts +6 -0
- package/lib/node/annotation/res.d.ts.map +1 -0
- package/lib/node/annotation/res.js +18 -0
- package/lib/node/annotation/res.js.map +1 -0
- package/lib/node/annotation/session.d.ts +16 -0
- package/lib/node/annotation/session.d.ts.map +1 -0
- package/lib/node/annotation/session.js +29 -0
- package/lib/node/annotation/session.js.map +1 -0
- package/lib/node/annotation/text.d.ts +3 -0
- package/lib/node/annotation/text.d.ts.map +1 -0
- package/lib/node/annotation/text.js +10 -0
- package/lib/node/annotation/text.js.map +1 -0
- package/lib/node/annotation/view.d.ts +13 -0
- package/lib/node/annotation/view.d.ts.map +1 -0
- package/lib/node/annotation/view.js +15 -0
- package/lib/node/annotation/view.js.map +1 -0
- package/lib/node/constants.d.ts +18 -0
- package/lib/node/constants.d.ts.map +1 -0
- package/lib/node/constants.js +21 -0
- package/lib/node/constants.js.map +1 -0
- package/lib/node/error/error-handler.d.ts +10 -0
- package/lib/node/error/error-handler.d.ts.map +1 -0
- package/lib/node/error/error-handler.js +42 -0
- package/lib/node/error/error-handler.js.map +1 -0
- package/lib/node/error/index.d.ts +2 -0
- package/lib/node/error/index.d.ts.map +1 -0
- package/lib/node/error/index.js +18 -0
- package/lib/node/error/index.js.map +1 -0
- package/lib/node/handler/handler-adapter.d.ts +22 -0
- package/lib/node/handler/handler-adapter.d.ts.map +1 -0
- package/lib/node/handler/handler-adapter.js +122 -0
- package/lib/node/handler/handler-adapter.js.map +1 -0
- package/lib/node/handler/handler-protocol.d.ts +38 -0
- package/lib/node/handler/handler-protocol.d.ts.map +1 -0
- package/lib/node/handler/handler-protocol.js +7 -0
- package/lib/node/handler/handler-protocol.js.map +1 -0
- package/lib/node/handler/index.d.ts +6 -0
- package/lib/node/handler/index.d.ts.map +1 -0
- package/lib/node/handler/index.js +22 -0
- package/lib/node/handler/index.js.map +1 -0
- package/lib/node/handler/route-builder.d.ts +29 -0
- package/lib/node/handler/route-builder.d.ts.map +1 -0
- package/lib/node/handler/route-builder.js +117 -0
- package/lib/node/handler/route-builder.js.map +1 -0
- package/lib/node/handler/route-metadata-matcher.d.ts +9 -0
- package/lib/node/handler/route-metadata-matcher.d.ts.map +1 -0
- package/lib/node/handler/route-metadata-matcher.js +60 -0
- package/lib/node/handler/route-metadata-matcher.js.map +1 -0
- package/lib/node/handler/route-provider.d.ts +11 -0
- package/lib/node/handler/route-provider.d.ts.map +1 -0
- package/lib/node/handler/route-provider.js +44 -0
- package/lib/node/handler/route-provider.js.map +1 -0
- package/lib/node/index.d.ts +6 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +22 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/module.d.ts +4 -0
- package/lib/node/module.d.ts.map +1 -0
- package/lib/node/module.js +6 -0
- package/lib/node/module.js.map +1 -0
- package/lib/node/resolver/index.d.ts +8 -0
- package/lib/node/resolver/index.d.ts.map +1 -0
- package/lib/node/resolver/index.js +24 -0
- package/lib/node/resolver/index.js.map +1 -0
- package/lib/node/resolver/method-args-resolver-provider.d.ts +8 -0
- package/lib/node/resolver/method-args-resolver-provider.d.ts.map +1 -0
- package/lib/node/resolver/method-args-resolver-provider.js +35 -0
- package/lib/node/resolver/method-args-resolver-provider.js.map +1 -0
- package/lib/node/resolver/method-args-resolver.d.ts +35 -0
- package/lib/node/resolver/method-args-resolver.d.ts.map +1 -0
- package/lib/node/resolver/method-args-resolver.js +152 -0
- package/lib/node/resolver/method-args-resolver.js.map +1 -0
- package/lib/node/resolver/resolver-protocol.d.ts +15 -0
- package/lib/node/resolver/resolver-protocol.d.ts.map +1 -0
- package/lib/node/resolver/resolver-protocol.js +7 -0
- package/lib/node/resolver/resolver-protocol.js.map +1 -0
- package/lib/node/resolver/response-resolver-provider.d.ts +8 -0
- package/lib/node/resolver/response-resolver-provider.d.ts.map +1 -0
- package/lib/node/resolver/response-resolver-provider.js +35 -0
- package/lib/node/resolver/response-resolver-provider.js.map +1 -0
- package/lib/node/resolver/response-resolver.d.ts +14 -0
- package/lib/node/resolver/response-resolver.d.ts.map +1 -0
- package/lib/node/resolver/response-resolver.js +67 -0
- package/lib/node/resolver/response-resolver.js.map +1 -0
- package/lib/node/resolver/view-resolver-provider.d.ts +8 -0
- package/lib/node/resolver/view-resolver-provider.d.ts.map +1 -0
- package/lib/node/resolver/view-resolver-provider.js +35 -0
- package/lib/node/resolver/view-resolver-provider.js.map +1 -0
- package/lib/node/resolver/view-resolver.d.ts +8 -0
- package/lib/node/resolver/view-resolver.d.ts.map +1 -0
- package/lib/node/resolver/view-resolver.js +44 -0
- package/lib/node/resolver/view-resolver.js.map +1 -0
- package/lib/node/view/file-view.d.ts +19 -0
- package/lib/node/view/file-view.d.ts.map +1 -0
- package/lib/node/view/file-view.js +79 -0
- package/lib/node/view/file-view.js.map +1 -0
- package/lib/node/view/html-view.d.ts +11 -0
- package/lib/node/view/html-view.d.ts.map +1 -0
- package/lib/node/view/html-view.js +48 -0
- package/lib/node/view/html-view.js.map +1 -0
- package/lib/node/view/index.d.ts +7 -0
- package/lib/node/view/index.d.ts.map +1 -0
- package/lib/node/view/index.js +23 -0
- package/lib/node/view/index.js.map +1 -0
- package/lib/node/view/json-view-template-renderer.d.ts +6 -0
- package/lib/node/view/json-view-template-renderer.d.ts.map +1 -0
- package/lib/node/view/json-view-template-renderer.js +39 -0
- package/lib/node/view/json-view-template-renderer.js.map +1 -0
- package/lib/node/view/json-view.d.ts +11 -0
- package/lib/node/view/json-view.d.ts.map +1 -0
- package/lib/node/view/json-view.js +39 -0
- package/lib/node/view/json-view.js.map +1 -0
- package/lib/node/view/text-view.d.ts +10 -0
- package/lib/node/view/text-view.d.ts.map +1 -0
- package/lib/node/view/text-view.js +32 -0
- package/lib/node/view/text-view.js.map +1 -0
- package/lib/node/view/view-protocol.d.ts +12 -0
- package/lib/node/view/view-protocol.d.ts.map +1 -0
- package/lib/node/view/view-protocol.js +6 -0
- package/lib/node/view/view-protocol.js.map +1 -0
- package/lib/node/view/view-provider.d.ts +8 -0
- package/lib/node/view/view-provider.d.ts.map +1 -0
- package/lib/node/view/view-provider.js +35 -0
- package/lib/node/view/view-provider.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +4 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +47 -0
- package/src/common/constants.ts +1 -0
- package/src/common/index.ts +1 -0
- package/src/node/annotation/body.ts +21 -0
- package/src/node/annotation/catch.ts +27 -0
- package/src/node/annotation/controller.ts +44 -0
- package/src/node/annotation/cookie.ts +41 -0
- package/src/node/annotation/file.ts +7 -0
- package/src/node/annotation/header.ts +41 -0
- package/src/node/annotation/html.ts +7 -0
- package/src/node/annotation/index.ts +17 -0
- package/src/node/annotation/json.ts +7 -0
- package/src/node/annotation/method.ts +61 -0
- package/src/node/annotation/param.ts +21 -0
- package/src/node/annotation/query.ts +21 -0
- package/src/node/annotation/req.ts +23 -0
- package/src/node/annotation/res.ts +23 -0
- package/src/node/annotation/session.ts +41 -0
- package/src/node/annotation/text.ts +7 -0
- package/src/node/annotation/view.ts +16 -0
- package/src/node/constants.ts +17 -0
- package/src/node/error/error-handler.ts +27 -0
- package/src/node/error/index.ts +1 -0
- package/src/node/handler/handler-adapter.ts +100 -0
- package/src/node/handler/handler-protocol.ts +62 -0
- package/src/node/handler/index.ts +5 -0
- package/src/node/handler/route-builder.ts +119 -0
- package/src/node/handler/route-metadata-matcher.ts +44 -0
- package/src/node/handler/route-provider.ts +27 -0
- package/src/node/index.ts +5 -0
- package/src/node/module.ts +4 -0
- package/src/node/resolver/index.ts +7 -0
- package/src/node/resolver/method-args-resolver-provider.ts +21 -0
- package/src/node/resolver/method-args-resolver.ts +119 -0
- package/src/node/resolver/resolver-protocol.ts +18 -0
- package/src/node/resolver/response-resolver-provider.ts +21 -0
- package/src/node/resolver/response-resolver.ts +46 -0
- package/src/node/resolver/view-resolver-provider.ts +21 -0
- package/src/node/resolver/view-resolver.ts +29 -0
- package/src/node/view/file-view.ts +68 -0
- package/src/node/view/html-view.ts +34 -0
- package/src/node/view/index.ts +6 -0
- package/src/node/view/json-view-template-renderer.ts +23 -0
- package/src/node/view/json-view.ts +26 -0
- package/src/node/view/text-view.ts +23 -0
- package/src/node/view/view-protocol.ts +14 -0
- package/src/node/view/view-provider.ts +21 -0
- package/src/package.spec.ts +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-view.js","sourceRoot":"","sources":["../../../src/node/view/html-view.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAgD;AAChD,mDAAuC;AACvC,+CAA+C;AAC/C,uCAAyC;AACzC,+BAA4B;AAC5B,uCAAoC;AAEpC,6CAAoD;AACpD,uCAAyC;AAGlC,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAAd;QAEM,gBAAW,GAAG,gBAAS,CAAC,SAAS,CAAC;QAElC,aAAQ,GAAG,GAAG,CAAC;IAkB5B,CAAC;IAbG,KAAK,CAAC,MAAM,CAAC,KAAU,EAAE,EAAE,QAAQ,EAAgB;QAC/C,MAAM,QAAQ,GAAG,cAAO,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC;QAC/C,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,WAAW,EAAE,QAAS,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACpG,IAAI,KAAK,EAAE;YACP,IAAA,gBAAK,EAAC,QAAQ,CAAC,CAAC;SACnB;QACD,QAAQ,CAAC,IAAI,GAAG,IAAA,iBAAM,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAgB;;QACxC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,qBAAc,KAAI,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,QAAQ,CAAC,WAAW,CAAC,CAAA,CAAC,CAAC;IACjG,CAAC;CACJ,CAAA;AAhBG;IAAC,IAAA,YAAK,EAAC,eAAe,CAAC;;yCACS;AAPvB,QAAQ;IADpB,IAAA,gBAAS,EAAC,oBAAI,CAAC;GACH,QAAQ,CAsBpB;AAtBY,4BAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/view/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./json-view"), exports);
|
|
18
|
+
__exportStar(require("./text-view"), exports);
|
|
19
|
+
__exportStar(require("./view-provider"), exports);
|
|
20
|
+
__exportStar(require("./html-view"), exports);
|
|
21
|
+
__exportStar(require("./file-view"), exports);
|
|
22
|
+
__exportStar(require("./json-view-template-renderer"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/view/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,8CAA4B;AAC5B,kDAAgC;AAChC,8CAA4B;AAC5B,8CAA4B;AAC5B,gEAA8C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { JsonViewTemplateRenderer } from './view-protocol';
|
|
2
|
+
export declare class JsonViewTemplateRendererImpl implements JsonViewTemplateRenderer {
|
|
3
|
+
protected readonly jsonViewTemplate?: string;
|
|
4
|
+
render(model?: any, error?: Error): Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=json-view-template-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-view-template-renderer.d.ts","sourceRoot":"","sources":["../../../src/node/view/json-view-template-renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,qBACa,4BAA6B,YAAW,wBAAwB;IAGzE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEvC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;CAa5D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.JsonViewTemplateRendererImpl = void 0;
|
|
13
|
+
const core_1 = require("@celljs/core");
|
|
14
|
+
const view_protocol_1 = require("./view-protocol");
|
|
15
|
+
let JsonViewTemplateRendererImpl = class JsonViewTemplateRendererImpl {
|
|
16
|
+
async render(model, error) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
if (this.jsonViewTemplate) {
|
|
19
|
+
return this.jsonViewTemplate
|
|
20
|
+
.replace('{{model}}', JSON.stringify(model))
|
|
21
|
+
.replace('{{error}}', (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '')
|
|
22
|
+
.replace('{{success}}', error ? 'false' : 'true')
|
|
23
|
+
.replace('{{code}}', (_c = (_b = error === null || error === void 0 ? void 0 : error.code) !== null && _b !== void 0 ? _b : error === null || error === void 0 ? void 0 : error.statusCode) !== null && _c !== void 0 ? _c : '');
|
|
24
|
+
}
|
|
25
|
+
if (error) {
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
return JSON.stringify(model);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, core_1.Value)('cell.mvc.jsonView.template'),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], JsonViewTemplateRendererImpl.prototype, "jsonViewTemplate", void 0);
|
|
35
|
+
JsonViewTemplateRendererImpl = __decorate([
|
|
36
|
+
(0, core_1.Component)(view_protocol_1.JsonViewTemplateRenderer)
|
|
37
|
+
], JsonViewTemplateRendererImpl);
|
|
38
|
+
exports.JsonViewTemplateRendererImpl = JsonViewTemplateRendererImpl;
|
|
39
|
+
//# sourceMappingURL=json-view-template-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-view-template-renderer.js","sourceRoot":"","sources":["../../../src/node/view/json-view-template-renderer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAgD;AAChD,mDAA2D;AAGpD,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAKrC,KAAK,CAAC,MAAM,CAAC,KAAW,EAAE,KAAa;;QACnC,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,OAAO,IAAI,CAAC,gBAAgB;iBACvB,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;iBAC3C,OAAO,CAAC,WAAW,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,EAAE,CAAC;iBAC1C,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;iBAChD,OAAO,CAAC,UAAU,EAAE,MAAA,MAAC,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,IAAI,mCAAK,KAAa,aAAb,KAAK,uBAAL,KAAK,CAAU,UAAU,mCAAI,EAAE,CAAC,CAAC;SACtF;QACD,IAAI,KAAK,EAAE;YACP,MAAM,KAAK,CAAC;SACf;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;CACJ,CAAA;AAhBG;IAAC,IAAA,YAAK,EAAC,4BAA4B,CAAC;;sEACS;AAHpC,4BAA4B;IADxC,IAAA,gBAAS,EAAC,wCAAwB,CAAC;GACvB,4BAA4B,CAkBxC;AAlBY,oEAA4B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JsonViewTemplateRenderer, View } from './view-protocol';
|
|
2
|
+
import { ViewMetadata } from '../annotation/view';
|
|
3
|
+
import { MediaType } from '@celljs/http';
|
|
4
|
+
export declare class JsonView implements View {
|
|
5
|
+
readonly contentType = MediaType.APPLICATION_JSON_UTF8;
|
|
6
|
+
readonly priority = 500;
|
|
7
|
+
protected readonly jsonViewTemplateRenderer: JsonViewTemplateRenderer;
|
|
8
|
+
render(model: any, metadata: ViewMetadata): Promise<void>;
|
|
9
|
+
support({ viewName }: ViewMetadata): Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=json-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-view.d.ts","sourceRoot":"","sources":["../../../src/node/view/json-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,qBACa,QAAS,YAAW,IAAI;IAEjC,QAAQ,CAAC,WAAW,mCAAmC;IAEvD,QAAQ,CAAC,QAAQ,OAAO;IAGxB,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;IAEhE,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/D,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;CAGxD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.JsonView = void 0;
|
|
13
|
+
const core_1 = require("@celljs/core");
|
|
14
|
+
const view_protocol_1 = require("./view-protocol");
|
|
15
|
+
const node_1 = require("@celljs/web/lib/node");
|
|
16
|
+
const json_1 = require("../annotation/json");
|
|
17
|
+
const http_1 = require("@celljs/http");
|
|
18
|
+
let JsonView = class JsonView {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.contentType = http_1.MediaType.APPLICATION_JSON_UTF8;
|
|
21
|
+
this.priority = 500;
|
|
22
|
+
}
|
|
23
|
+
async render(model, metadata) {
|
|
24
|
+
const response = node_1.Context.getCurrent().response;
|
|
25
|
+
response.body = await this.jsonViewTemplateRenderer.render(model);
|
|
26
|
+
}
|
|
27
|
+
support({ viewName }) {
|
|
28
|
+
return Promise.resolve(viewName === json_1.JSON_VIEW_NAME);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, core_1.Autowired)(view_protocol_1.JsonViewTemplateRenderer),
|
|
33
|
+
__metadata("design:type", Object)
|
|
34
|
+
], JsonView.prototype, "jsonViewTemplateRenderer", void 0);
|
|
35
|
+
JsonView = __decorate([
|
|
36
|
+
(0, core_1.Component)(view_protocol_1.View)
|
|
37
|
+
], JsonView);
|
|
38
|
+
exports.JsonView = JsonView;
|
|
39
|
+
//# sourceMappingURL=json-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-view.js","sourceRoot":"","sources":["../../../src/node/view/json-view.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAoD;AACpD,mDAAiE;AACjE,+CAA+C;AAE/C,6CAAoD;AACpD,uCAAyC;AAGlC,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAAd;QAEM,gBAAW,GAAG,gBAAS,CAAC,qBAAqB,CAAC;QAE9C,aAAQ,GAAG,GAAG,CAAC;IAa5B,CAAC;IARG,KAAK,CAAC,MAAM,CAAC,KAAU,EAAE,QAAsB;QAC3C,MAAM,QAAQ,GAAG,cAAO,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC;QAC/C,QAAQ,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,CAAC,EAAE,QAAQ,EAAgB;QAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,qBAAc,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AAXG;IAAC,IAAA,gBAAS,EAAC,wCAAwB,CAAC;;0DACkC;AAP7D,QAAQ;IADpB,IAAA,gBAAS,EAAC,oBAAI,CAAC;GACH,QAAQ,CAiBpB;AAjBY,4BAAQ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { View } from './view-protocol';
|
|
2
|
+
import { ViewMetadata } from '../annotation/view';
|
|
3
|
+
import { MediaType } from '@celljs/http';
|
|
4
|
+
export declare class TextView implements View {
|
|
5
|
+
readonly contentType = MediaType.TEXT_PLAIN;
|
|
6
|
+
readonly priority = 600;
|
|
7
|
+
render(model: any, metadata: ViewMetadata): Promise<void>;
|
|
8
|
+
support({ viewName }: ViewMetadata): Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=text-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-view.d.ts","sourceRoot":"","sources":["../../../src/node/view/text-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,qBACa,QAAS,YAAW,IAAI;IAEjC,QAAQ,CAAC,WAAW,wBAAwB;IAE5C,QAAQ,CAAC,QAAQ,OAAO;IAElB,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/D,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;CAGxD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TextView = void 0;
|
|
10
|
+
const core_1 = require("@celljs/core");
|
|
11
|
+
const view_protocol_1 = require("./view-protocol");
|
|
12
|
+
const node_1 = require("@celljs/web/lib/node");
|
|
13
|
+
const text_1 = require("../annotation/text");
|
|
14
|
+
const http_1 = require("@celljs/http");
|
|
15
|
+
let TextView = class TextView {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.contentType = http_1.MediaType.TEXT_PLAIN;
|
|
18
|
+
this.priority = 600;
|
|
19
|
+
}
|
|
20
|
+
async render(model, metadata) {
|
|
21
|
+
const response = node_1.Context.getCurrent().response;
|
|
22
|
+
response.body = model;
|
|
23
|
+
}
|
|
24
|
+
support({ viewName }) {
|
|
25
|
+
return Promise.resolve(viewName === text_1.TEXT_VIEW_NAME);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
TextView = __decorate([
|
|
29
|
+
(0, core_1.Component)(view_protocol_1.View)
|
|
30
|
+
], TextView);
|
|
31
|
+
exports.TextView = TextView;
|
|
32
|
+
//# sourceMappingURL=text-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-view.js","sourceRoot":"","sources":["../../../src/node/view/text-view.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyC;AACzC,mDAAuC;AACvC,+CAA+C;AAE/C,6CAAoD;AACpD,uCAAyC;AAGlC,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAAd;QAEM,gBAAW,GAAG,gBAAS,CAAC,UAAU,CAAC;QAEnC,aAAQ,GAAG,GAAG,CAAC;IAU5B,CAAC;IARG,KAAK,CAAC,MAAM,CAAC,KAAU,EAAE,QAAsB;QAC3C,MAAM,QAAQ,GAAG,cAAO,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC;QAC/C,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,OAAO,CAAC,EAAE,QAAQ,EAAgB;QAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,qBAAc,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AAdY,QAAQ;IADpB,IAAA,gBAAS,EAAC,oBAAI,CAAC;GACH,QAAQ,CAcpB;AAdY,4BAAQ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ViewMetadata } from '../annotation/view';
|
|
2
|
+
export declare const View: unique symbol;
|
|
3
|
+
export declare const JsonViewTemplateRenderer: unique symbol;
|
|
4
|
+
export interface View {
|
|
5
|
+
readonly contentType: string;
|
|
6
|
+
render(model: any, metadata: ViewMetadata): Promise<void>;
|
|
7
|
+
support(metadata: ViewMetadata): Promise<boolean>;
|
|
8
|
+
}
|
|
9
|
+
export interface JsonViewTemplateRenderer {
|
|
10
|
+
render(model?: any, error?: Error): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=view-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/view/view-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,eAAO,MAAM,IAAI,eAAiB,CAAC;AACnC,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAE3E,MAAM,WAAW,IAAI;IACjB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,wBAAwB;IACrC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonViewTemplateRenderer = exports.View = void 0;
|
|
4
|
+
exports.View = Symbol('View');
|
|
5
|
+
exports.JsonViewTemplateRenderer = Symbol('JsonViewTemplateRenderer');
|
|
6
|
+
//# sourceMappingURL=view-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-protocol.js","sourceRoot":"","sources":["../../../src/node/view/view-protocol.ts"],"names":[],"mappings":";;;AAEa,QAAA,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AACtB,QAAA,wBAAwB,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-provider.d.ts","sourceRoot":"","sources":["../../../src/node/view/view-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,qBACa,YAAY;IAMjB,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE;IAJpC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;gBAIP,KAAK,EAAE,IAAI,EAAE;IAGpC,OAAO,IAAI,IAAI,EAAE;CAOpB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ViewProvider = void 0;
|
|
16
|
+
const core_1 = require("@celljs/core");
|
|
17
|
+
const view_protocol_1 = require("./view-protocol");
|
|
18
|
+
let ViewProvider = class ViewProvider {
|
|
19
|
+
constructor(views) {
|
|
20
|
+
this.views = views;
|
|
21
|
+
}
|
|
22
|
+
provide() {
|
|
23
|
+
if (!this.prioritized) {
|
|
24
|
+
this.prioritized = core_1.Prioritizeable.prioritizeAllSync(this.views).map(c => c.value);
|
|
25
|
+
}
|
|
26
|
+
return this.prioritized;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
ViewProvider = __decorate([
|
|
30
|
+
(0, core_1.Component)(),
|
|
31
|
+
__param(0, (0, core_1.Autowired)(view_protocol_1.View)),
|
|
32
|
+
__metadata("design:paramtypes", [Array])
|
|
33
|
+
], ViewProvider);
|
|
34
|
+
exports.ViewProvider = ViewProvider;
|
|
35
|
+
//# sourceMappingURL=view-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-provider.js","sourceRoot":"","sources":["../../../src/node/view/view-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAoE;AACpE,mDAAuC;AAGhC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAIrB,YAEuB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAChC,CAAC;IAEL,OAAO;QACH,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG,qBAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SACrF;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;CAEJ,CAAA;AAhBY,YAAY;IADxB,IAAA,gBAAS,GAAE;IAMH,WAAA,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAA;;GALX,YAAY,CAgBxB;AAhBY,oCAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=package.spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAEzB,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@celljs/mvc",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "lib/common/index.js",
|
|
6
|
+
"typings": "lib/common/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@celljs/core": "3.0.0",
|
|
9
|
+
"@celljs/http": "3.0.0",
|
|
10
|
+
"@celljs/web": "3.0.0",
|
|
11
|
+
"fs-extra": "^11.1.1",
|
|
12
|
+
"mustache": "^4.2.0",
|
|
13
|
+
"reflect-metadata": "^0.1.13"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"cell-component"
|
|
20
|
+
],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/cellbang/cell.git"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/cellbang/cell/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/cellbang/cell",
|
|
30
|
+
"files": [
|
|
31
|
+
"lib",
|
|
32
|
+
"src",
|
|
33
|
+
"cell.yml"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"lint": "cell-component lint",
|
|
37
|
+
"build": "cell-component build",
|
|
38
|
+
"watch": "cell-component watch",
|
|
39
|
+
"clean": "cell-component clean",
|
|
40
|
+
"test": "cell-component test:js"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@celljs/component": "3.0.0",
|
|
44
|
+
"@types/mustache": "^4.2.2"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "c0ef8d269e33a795406bcbb240cac4b845c6c24c"
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MVC_PATH = 'cell.mvc.path';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './constants';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { METADATA_KEY } from '../constants';
|
|
2
|
+
|
|
3
|
+
export interface BodyMetadata {
|
|
4
|
+
name?: string;
|
|
5
|
+
parameterIndex: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function Body(name?: string): ParameterDecorator {
|
|
9
|
+
return (t, tk, i) => {
|
|
10
|
+
applyBodyDecorator(t, tk, i, name);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function applyBodyDecorator(target: any, targetKey: string | symbol | undefined , parameterIndex: number, name?: string): void {
|
|
15
|
+
if (!targetKey) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const metadatas: BodyMetadata[] = Reflect.getOwnMetadata(METADATA_KEY.controllerBody, target.constructor, targetKey) || [];
|
|
19
|
+
metadatas.push({ name, parameterIndex });
|
|
20
|
+
Reflect.defineMetadata(METADATA_KEY.controllerBody, metadatas, target.constructor, targetKey);
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { METADATA_KEY } from '../constants';
|
|
2
|
+
import { ErrorType } from '@celljs/core';
|
|
3
|
+
|
|
4
|
+
export interface CatchMetadata {
|
|
5
|
+
errorTypes: ErrorType[];
|
|
6
|
+
target: any;
|
|
7
|
+
key: string | symbol;
|
|
8
|
+
descriptor: TypedPropertyDescriptor<any>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Catch(errorTypes: ErrorType | ErrorType[]): MethodDecorator {
|
|
12
|
+
return (t, k, d) => {
|
|
13
|
+
applyCatchDecorator(t, k, d, Array.isArray(errorTypes) ? errorTypes : [ errorTypes ]);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function applyCatchDecorator(target: any, key: string | symbol, descriptor: TypedPropertyDescriptor<any>, errorTypes: ErrorType[]): void {
|
|
18
|
+
const metadata: CatchMetadata = { errorTypes, target, key, descriptor };
|
|
19
|
+
let metadataList: CatchMetadata[] = [];
|
|
20
|
+
|
|
21
|
+
if (!Reflect.hasOwnMetadata(METADATA_KEY.controllerCatch, target.constructor)) {
|
|
22
|
+
Reflect.defineMetadata(METADATA_KEY.controllerCatch, metadataList, target.constructor);
|
|
23
|
+
} else {
|
|
24
|
+
metadataList = Reflect.getOwnMetadata(METADATA_KEY.controllerCatch, target.constructor);
|
|
25
|
+
}
|
|
26
|
+
metadataList.push(metadata);
|
|
27
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { METADATA_KEY } from '../constants';
|
|
2
|
+
import { AnnotationUtil, Component, ComponentId, ComponentOption, parseComponentOption } from '@celljs/core';
|
|
3
|
+
import { AOP_POINTCUT } from '@celljs/web';
|
|
4
|
+
|
|
5
|
+
export const CONTROLLER = Symbol('Controller');
|
|
6
|
+
|
|
7
|
+
export const CONTROLLER_TAG = 'Controller';
|
|
8
|
+
|
|
9
|
+
export interface ControllerOption extends ComponentOption {
|
|
10
|
+
path?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ControllerMetadata {
|
|
14
|
+
path: string;
|
|
15
|
+
target: any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type PathOrControllerOption = string | ControllerOption;
|
|
19
|
+
|
|
20
|
+
export function Controller(pathOrOption?: PathOrControllerOption): ClassDecorator {
|
|
21
|
+
return function (target) {
|
|
22
|
+
const option = parseControllerOption(target, pathOrOption);
|
|
23
|
+
applyControllerDecorator(option, target);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function parseControllerOption(target: any, pathOrOption?: PathOrControllerOption) {
|
|
28
|
+
const option = AnnotationUtil.getValueOrOption<ControllerOption>(pathOrOption, 'path');
|
|
29
|
+
const parsed = <ControllerOption>parseComponentOption(target, option);
|
|
30
|
+
if (option.proxy === undefined) {
|
|
31
|
+
parsed.proxy = true;
|
|
32
|
+
}
|
|
33
|
+
parsed.sysTags!.push(AOP_POINTCUT, CONTROLLER_TAG);
|
|
34
|
+
parsed.path = parsed.path || '';
|
|
35
|
+
(parsed.id as Array<ComponentId>).push(CONTROLLER);
|
|
36
|
+
return parsed;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function applyControllerDecorator(option: ControllerOption, target: any) {
|
|
40
|
+
const metadata: ControllerMetadata = { path: option.path!, target };
|
|
41
|
+
Reflect.defineMetadata(METADATA_KEY.controller, metadata, target);
|
|
42
|
+
Component(option)(target);
|
|
43
|
+
return metadata;
|
|
44
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { METADATA_KEY } from '../constants';
|
|
2
|
+
|
|
3
|
+
export interface RequestCookieMetadata {
|
|
4
|
+
name?: string;
|
|
5
|
+
parameterIndex: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ResponseCookieMetadata {
|
|
9
|
+
name: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CookieDecorator {
|
|
14
|
+
(name?: string): ParameterDecorator;
|
|
15
|
+
(name: string, value: string): MethodDecorator;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Cookie = <CookieDecorator>function (name?: string, value?: string): ParameterDecorator | MethodDecorator {
|
|
20
|
+
if (name && value) {
|
|
21
|
+
return (t: any, tk: string | symbol, d: PropertyDescriptor) => {
|
|
22
|
+
applyResponseCookieDecorator(t, tk, d, name, value);
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
return (t: any, tk: string, i: number) => {
|
|
26
|
+
applyRequestCookieDecorator(t, tk, i, name);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function applyRequestCookieDecorator(target: any, targetKey: string | symbol, parameterIndex: number, name?: string): void {
|
|
32
|
+
const metadatas: RequestCookieMetadata[] = Reflect.getOwnMetadata(METADATA_KEY.controllerRequestCookie, target.constructor, targetKey) || [];
|
|
33
|
+
metadatas.push({ name, parameterIndex });
|
|
34
|
+
Reflect.defineMetadata(METADATA_KEY.controllerRequestCookie, metadatas, target.constructor, targetKey);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function applyResponseCookieDecorator(target: any, targetKey: string | symbol, descriptor: PropertyDescriptor, name: string, value: string): void {
|
|
38
|
+
const metadatas: ResponseCookieMetadata[] = Reflect.getOwnMetadata(METADATA_KEY.controllerResponseCookie, target.constructor, targetKey) || [];
|
|
39
|
+
metadatas.push({ name, value });
|
|
40
|
+
Reflect.defineMetadata(METADATA_KEY.controllerResponseCookie, metadatas, target.constructor, targetKey);
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { METADATA_KEY } from '../constants';
|
|
2
|
+
|
|
3
|
+
export interface RequestHeaderMetadata {
|
|
4
|
+
name?: string;
|
|
5
|
+
parameterIndex: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ResponseHeaderMetadata {
|
|
9
|
+
name: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface HeaderDecorator {
|
|
14
|
+
(name?: string): ParameterDecorator;
|
|
15
|
+
(name: string, value: string): MethodDecorator;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Header = <HeaderDecorator>function (name?: string, value?: string) {
|
|
20
|
+
if (name && value) {
|
|
21
|
+
return (t: any, tk: string | symbol, d: PropertyDescriptor) => {
|
|
22
|
+
applyResponseHeaderDecorator(t, tk, d, name, value);
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
return (t: any, tk: string | symbol, i: number) => {
|
|
26
|
+
applyRequestHeaderDecorator(t, tk, i, name);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function applyRequestHeaderDecorator(target: any, targetKey: string | symbol, parameterIndex: number, name?: string): void {
|
|
32
|
+
const metadatas: RequestHeaderMetadata[] = Reflect.getOwnMetadata(METADATA_KEY.controllerRequestHeader, target.constructor, targetKey) || [];
|
|
33
|
+
metadatas.push({ name, parameterIndex });
|
|
34
|
+
Reflect.defineMetadata(METADATA_KEY.controllerRequestHeader, metadatas, target.constructor, targetKey);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function applyResponseHeaderDecorator(target: any, targetKey: string | symbol, descriptor: PropertyDescriptor, name: string, value: string): void {
|
|
38
|
+
const metadatas: ResponseHeaderMetadata[] = Reflect.getOwnMetadata(METADATA_KEY.controllerResponseHeader, target.constructor, targetKey) || [];
|
|
39
|
+
metadatas.push({ name, value });
|
|
40
|
+
Reflect.defineMetadata(METADATA_KEY.controllerResponseHeader, metadatas, target.constructor, targetKey);
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './body';
|
|
2
|
+
export * from './controller';
|
|
3
|
+
export * from './header';
|
|
4
|
+
export * from './method';
|
|
5
|
+
export * from './param';
|
|
6
|
+
export * from './query';
|
|
7
|
+
export * from './view';
|
|
8
|
+
export * from './cookie';
|
|
9
|
+
export * from './session';
|
|
10
|
+
export * from './catch';
|
|
11
|
+
export * from './file';
|
|
12
|
+
export * from './text';
|
|
13
|
+
export * from './json';
|
|
14
|
+
export * from './html';
|
|
15
|
+
export * from './req';
|
|
16
|
+
export * from './res';
|
|
17
|
+
|