@napp/dti-core 2.1.5 → 3.0.5

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/common.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export interface Serializer<T> {
2
+ encode: (param: T) => string;
3
+ decode: (text: string) => T;
4
+ }
5
+ export interface DtiOption<RES, RQ = void, RB = void> {
6
+ name: string;
7
+ role?: (q: RQ, b: RB) => string;
8
+ path?: string;
9
+ method?: 'get' | 'post';
10
+ /**
11
+ * default: json
12
+ */
13
+ bodyMode?: string;
14
+ /**
15
+ * default: base64
16
+ */
17
+ queryMode?: string;
18
+ checkQ?: (q: RQ) => void;
19
+ checkB?: (b: RB) => void;
20
+ }
File without changes
package/index.d.ts CHANGED
@@ -1,5 +1,2 @@
1
- export * from './adapter.client';
2
- export * from './adapter.server';
3
- export * from './method';
4
- export * from './order';
5
- export * from './pager';
1
+ export * from './common';
2
+ export * from './meta';
package/index.js CHANGED
@@ -10,8 +10,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./adapter.client"), exports);
14
- __exportStar(require("./adapter.server"), exports);
15
- __exportStar(require("./method"), exports);
16
- __exportStar(require("./order"), exports);
17
- __exportStar(require("./pager"), exports);
13
+ __exportStar(require("./common"), exports);
14
+ __exportStar(require("./meta"), exports);
package/meta.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { DtiOption } from "./common";
2
+ export declare class Dti<RES, PQ, PB> {
3
+ private opt;
4
+ constructor(opt: DtiOption<RES, PQ, PB>);
5
+ get name(): string;
6
+ get method(): "get" | "post";
7
+ get path(): string;
8
+ get queryMode(): string;
9
+ get bodyMode(): string;
10
+ checkQ(q: PQ): void;
11
+ checkB(b: PB): void;
12
+ static define<RES, PQ, PB>(opt: DtiOption<RES, PQ, PB>): Dti<RES, PQ, PB>;
13
+ }
package/meta.js ADDED
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dti = void 0;
4
+ var Dti = /** @class */ (function () {
5
+ function Dti(opt) {
6
+ this.opt = opt;
7
+ }
8
+ Object.defineProperty(Dti.prototype, "name", {
9
+ get: function () {
10
+ return this.opt.name;
11
+ },
12
+ enumerable: false,
13
+ configurable: true
14
+ });
15
+ Object.defineProperty(Dti.prototype, "method", {
16
+ get: function () {
17
+ var method = this.opt.method;
18
+ if (method === 'get')
19
+ return 'get';
20
+ if (method === 'post')
21
+ return 'post';
22
+ if (this.opt.checkB)
23
+ return 'post';
24
+ return 'get';
25
+ },
26
+ enumerable: false,
27
+ configurable: true
28
+ });
29
+ Object.defineProperty(Dti.prototype, "path", {
30
+ get: function () {
31
+ var _a = this.opt, name = _a.name, path = _a.path;
32
+ if (path)
33
+ return path;
34
+ return '/' + name;
35
+ },
36
+ enumerable: false,
37
+ configurable: true
38
+ });
39
+ Object.defineProperty(Dti.prototype, "queryMode", {
40
+ get: function () {
41
+ return this.opt.queryMode || '';
42
+ },
43
+ enumerable: false,
44
+ configurable: true
45
+ });
46
+ Object.defineProperty(Dti.prototype, "bodyMode", {
47
+ get: function () {
48
+ return this.opt.bodyMode || '';
49
+ },
50
+ enumerable: false,
51
+ configurable: true
52
+ });
53
+ Dti.prototype.checkQ = function (q) {
54
+ if (this.opt.checkQ) {
55
+ this.opt.checkQ(q);
56
+ }
57
+ };
58
+ Dti.prototype.checkB = function (b) {
59
+ if (this.opt.checkB) {
60
+ this.opt.checkB(b);
61
+ }
62
+ };
63
+ Dti.define = function (opt) {
64
+ return new Dti(opt);
65
+ };
66
+ return Dti;
67
+ }());
68
+ exports.Dti = Dti;
69
+ var m = Dti.define({
70
+ name: ''
71
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napp/dti-core",
3
- "version": "2.1.5",
3
+ "version": "3.0.5",
4
4
  "description": "data transaction interface core library",
5
5
  "types": "index.d.ts",
6
6
  "main": "index.js",
@@ -1,14 +0,0 @@
1
- export interface IClientMethod<REQ, RES> {
2
- call: (param: REQ) => Promise<RES>;
3
- }
4
- export interface IClientBuilder<REQ, RES> {
5
- valid: (handle: (param: REQ) => void) => IClientBuilder<REQ, RES>;
6
- factory: () => IClientMethod<REQ, RES>;
7
- }
8
- export interface IClientAdapter {
9
- get: <REQ, RES>(path: string) => IClientBuilder<REQ, RES>;
10
- post: <REQ, RES>(path: string) => IClientBuilder<REQ, RES>;
11
- put: <REQ, RES>(path: string) => IClientBuilder<REQ, RES>;
12
- patch: <REQ, RES>(path: string) => IClientBuilder<REQ, RES>;
13
- delete: <REQ, RES>(path: string) => IClientBuilder<REQ, RES>;
14
- }
@@ -1,28 +0,0 @@
1
- export interface IMiddleware {
2
- (req: any, res: any, next: any): void;
3
- }
4
- export interface IAction<REQ, RES> {
5
- (param: REQ, ctx: {
6
- req: any;
7
- res: any;
8
- }): Promise<RES>;
9
- }
10
- export interface IParamParser<REQ> {
11
- (req: any): REQ;
12
- }
13
- export interface IServerMethod<REQ, RES> {
14
- before: (befores: Array<IMiddleware>) => IServerMethod<REQ, RES>;
15
- handle: (action: IAction<REQ, RES>) => IServerMethod<REQ, RES>;
16
- }
17
- export interface IServerBuilder<REQ, RES> {
18
- valid: (handle: (param: REQ) => void) => IServerBuilder<REQ, RES>;
19
- paramParser: (handle: IParamParser<REQ>) => IServerBuilder<REQ, RES>;
20
- factory: () => IServerMethod<REQ, RES>;
21
- }
22
- export interface IServerAdapter {
23
- get: <REQ, RES>(path: string) => IServerBuilder<REQ, RES>;
24
- post: <REQ, RES>(path: string) => IServerBuilder<REQ, RES>;
25
- put: <REQ, RES>(path: string) => IServerBuilder<REQ, RES>;
26
- patch: <REQ, RES>(path: string) => IServerBuilder<REQ, RES>;
27
- delete: <REQ, RES>(path: string) => IServerBuilder<REQ, RES>;
28
- }
package/adapter.server.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/method.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare type METHOD = 'get' | 'post' | 'put' | 'patch' | 'delete';
package/method.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/order.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare type OrderType = 'asc' | 'desc' | undefined;
2
- export interface IOrder {
3
- [property: string]: OrderType;
4
- }
package/order.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/pager.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export interface IPager {
2
- limit: number;
3
- page: number;
4
- }
package/pager.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });