@proteinjs/service 1.0.22 → 1.0.24
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/CHANGELOG.md +11 -0
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/src/ServiceClient.d.ts.map +1 -1
- package/dist/src/ServiceClient.js +5 -4
- package/dist/src/ServiceClient.js.map +1 -1
- package/dist/src/ServiceExecutor.js +2 -2
- package/dist/src/ServiceExecutor.js.map +1 -1
- package/generated/index.ts +1 -1
- package/package.json +3 -3
- package/src/ServiceClient.ts +4 -3
- package/src/ServiceExecutor.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.23](https://github.com/proteinjs/service/compare/@proteinjs/service@1.0.22...@proteinjs/service@1.0.23) (2024-07-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* updated service logging to log objects without serialization metadata ([8614452](https://github.com/proteinjs/service/commit/86144527b48c35ed95fe6e337f29b027195399ee))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.0.17](https://github.com/proteinjs/service/compare/@proteinjs/service@1.0.16...@proteinjs/service@1.0.17) (2024-05-23)
|
|
7
18
|
|
|
8
19
|
|
package/dist/generated/index.js
CHANGED
|
@@ -21,7 +21,7 @@ require("@proteinjs/server-api");
|
|
|
21
21
|
require("@proteinjs/user-auth");
|
|
22
22
|
require("@proteinjs/util");
|
|
23
23
|
/** Generate Source Graph */
|
|
24
|
-
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/service/Service\",\"value\":{\"packageName\":\"@proteinjs/service\",\"name\":\"Service\",\"filePath\":\"/Users/
|
|
24
|
+
var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/service/Service\",\"value\":{\"packageName\":\"@proteinjs/service\",\"name\":\"Service\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/service/packages/service/src/Service.ts\",\"qualifiedName\":\"@proteinjs/service/Service\",\"properties\":[{\"name\":\"serviceMetadata\",\"type\":{\"packageName\":\"@proteinjs/service\",\"name\":\"{\\n auth?: {\\n /** If true, the user does not need to be logged in or have any roles to call this service. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to call this service, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to call this service. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n /**\\n * Custom auth function. If provided, all other auth properties are ignored.\\n * @param methodName the name of the service method to be executed\\n * @param args the args[] that will be passed into the method\\n * @return true if the user can access the service method\\n */\\n canAccess?: (methodName: string, args: any[]) => boolean;\\n };\\n /** Don't await the service's execution, return a response to the client immediately */\\n doNotAwait?: boolean;\\n }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/service/{\\n auth?: {\\n /** If true, the user does not need to be logged in or have any roles to call this service. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to call this service, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to call this service. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n /**\\n * Custom auth function. If provided, all other auth properties are ignored.\\n * @param methodName the name of the service method to be executed\\n * @param args the args[] that will be passed into the method\\n * @return true if the user can access the service method\\n */\\n canAccess?: (methodName: string, args: any[]) => boolean;\\n };\\n /** Don't await the service's execution, return a response to the client immediately */\\n doNotAwait?: boolean;\\n }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/reflection\",\"name\":\"Loadable\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/reflection/Loadable\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"@proteinjs/reflection/Loadable\"},{\"v\":\"@proteinjs/service/ServiceRouter\",\"value\":{\"packageName\":\"@proteinjs/service\",\"name\":\"ServiceRouter\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/service/packages/service/src/ServiceRouter.ts\",\"qualifiedName\":\"@proteinjs/service/ServiceRouter\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"logger\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"serviceExecutorMap\",\"type\":{\"packageName\":\"@proteinjs/service\",\"name\":\"{ [path: string]: ServiceExecutor } | undefined\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/service/{ [path: string]: ServiceExecutor } | undefined\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"path\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"method\",\"type\":{\"packageName\":\"\",\"name\":\"'post'\",\"filePath\":null,\"qualifiedName\":\"/'post'\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"getServiceExecutorMap\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]},{\"name\":\"onRequest\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<any>\",\"filePath\":null,\"qualifiedName\":\"/Promise<any>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"request\",\"type\":{\"packageName\":\"\",\"name\":\"any\",\"filePath\":null,\"qualifiedName\":\"/any\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"response\",\"type\":{\"packageName\":\"\",\"name\":\"any\",\"filePath\":null,\"qualifiedName\":\"/any\",\"typeParameters\":null,\"directParents\":null}}]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/server-api/Route\"}],\"edges\":[{\"v\":\"@proteinjs/service/Service\",\"w\":\"@proteinjs/reflection/Loadable\",\"value\":\"extends interface\"},{\"v\":\"@proteinjs/service/ServiceRouter\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"implements interface\"}]}";
|
|
25
25
|
/** Generate Source Links */
|
|
26
26
|
var ServiceRouter_1 = require("../src/ServiceRouter");
|
|
27
27
|
var sourceLinks = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,iCAA+B;AAC/B,iCAA+B;AAC/B,iCAA+B;AAC/B,gCAA8B;AAC9B,2BAAyB;AAGzB,4BAA4B;AAE5B,IAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,iCAA+B;AAC/B,iCAA+B;AAC/B,iCAA+B;AAC/B,gCAA8B;AAC9B,2BAAyB;AAGzB,4BAA4B;AAE5B,IAAM,WAAW,GAAG,gnLAAgnL,CAAC;AAGroL,4BAA4B;AAE5B,sDAAqD;AAErD,IAAM,WAAW,GAAG;IACnB,kCAAkC,EAAE,6BAAa;CACjD,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceClient.d.ts","sourceRoot":"","sources":["../../src/ServiceClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAU,MAAM,iBAAiB,CAAC;AAGpD,qBAAa,aAAa;IAKtB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS,CAAC;IANpB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAK;IAClC,OAAO,CAAC,MAAM,CAAmD;gBAGvD,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,uBAAW;IAGzB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"ServiceClient.d.ts","sourceRoot":"","sources":["../../src/ServiceClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAU,MAAM,iBAAiB,CAAC;AAGpD,qBAAa,aAAa;IAKtB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS,CAAC;IANpB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAK;IAClC,OAAO,CAAC,MAAM,CAAmD;gBAGvD,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,uBAAW;IAGzB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;YA0B1B,KAAK;CAsBpB"}
|
|
@@ -57,7 +57,7 @@ var ServiceClient = /** @class */ (function () {
|
|
|
57
57
|
var _this = this;
|
|
58
58
|
return __generator(this, function (_a) {
|
|
59
59
|
sendRequest = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
60
|
-
var serializedArgs, requestNumber, serializedReturn;
|
|
60
|
+
var serializedArgs, requestNumber, serializedReturn, deserializedReturn;
|
|
61
61
|
return __generator(this, function (_a) {
|
|
62
62
|
switch (_a.label) {
|
|
63
63
|
case 0:
|
|
@@ -65,15 +65,16 @@ var ServiceClient = /** @class */ (function () {
|
|
|
65
65
|
requestNumber = ServiceClient.requestCounter;
|
|
66
66
|
ServiceClient.requestCounter++;
|
|
67
67
|
console.groupCollapsed("[#".concat(requestNumber, "] Sending service request: ").concat(this.servicePath, ", args:"));
|
|
68
|
-
console.log(
|
|
68
|
+
console.log(args);
|
|
69
69
|
console.groupEnd();
|
|
70
70
|
return [4 /*yield*/, this._send(this.servicePath, serializedArgs)];
|
|
71
71
|
case 1:
|
|
72
72
|
serializedReturn = _a.sent();
|
|
73
|
+
deserializedReturn = serializer_1.Serializer.deserialize(serializedReturn);
|
|
73
74
|
console.groupCollapsed("[#".concat(requestNumber, "] Received service response: ").concat(this.servicePath, ", return:").concat((0, isVoidReturnType_1.isVoidReturnType)(this.serviceMethod) ? ' (void)' : ''));
|
|
74
|
-
console.log(
|
|
75
|
+
console.log(deserializedReturn);
|
|
75
76
|
console.groupEnd();
|
|
76
|
-
return [2 /*return*/,
|
|
77
|
+
return [2 /*return*/, deserializedReturn];
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
80
|
}); };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceClient.js","sourceRoot":"","sources":["../../src/ServiceClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAmD;AACnD,wC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CAAC;wBACc,qBAAM,KAAK,CAAC,OAAO,CAAC,EAAA;;wBAA/B,QAAQ,GAAG,SAAoB;wBACrC,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE;4BAC1B,MAAM,IAAI,KAAK,CAAC,6CAAsC,WAAW,sBAAY,QAAQ,CAAC,UAAU,CAAE,CAAC,CAAC;yBACrG;wBAEY,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAA5B,IAAI,GAAG,SAAqB;wBAClC,IAAI,IAAI,CAAC,KAAK,EAAE;4BACd,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBAC7B;wBAED,sBAAO,IAAI,CAAC,gBAAgB,EAAC;;;;KAC9B;IAxDc,4BAAc,GAAG,CAAC,AAAJ,CAAK;IAyDpC,oBAAC;CAAA,AA1DD,IA0DC;AA1DY,sCAAa"}
|
|
@@ -55,9 +55,9 @@ var ServiceExecutor = /** @class */ (function () {
|
|
|
55
55
|
return __generator(this, function (_b) {
|
|
56
56
|
switch (_b.label) {
|
|
57
57
|
case 0:
|
|
58
|
-
this.logger.info("Executing with args:\n".concat(JSON.stringify(requestBody, null, 2)));
|
|
59
58
|
method = this.service[this.method.name].bind(this.service);
|
|
60
59
|
deserializedArgs = serializer_1.Serializer.deserialize(requestBody);
|
|
60
|
+
this.logger.info("Executing with args:\n".concat(JSON.stringify(deserializedArgs, null, 2)));
|
|
61
61
|
if (!ServiceAuth_1.ServiceAuth.canRunService(this.service, this.method, deserializedArgs)) {
|
|
62
62
|
error = "User not authorized to run service: ".concat(this._interface.name, ".").concat(this.method.name);
|
|
63
63
|
throw new Error(error);
|
|
@@ -83,7 +83,7 @@ var ServiceExecutor = /** @class */ (function () {
|
|
|
83
83
|
return [2 /*return*/, undefined];
|
|
84
84
|
}
|
|
85
85
|
serializedReturn = serializer_1.Serializer.serialize(_return);
|
|
86
|
-
this.logger.info("Returning:\n".concat(
|
|
86
|
+
this.logger.info("Returning:\n".concat(JSON.stringify(_return, null, 2)));
|
|
87
87
|
return [2 /*return*/, serializedReturn];
|
|
88
88
|
}
|
|
89
89
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceExecutor.js","sourceRoot":"","sources":["../../src/ServiceExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wCAAyC;AACzC,oDAAmD;AACnD,6CAA4C;AAC5C,uDAAsD;AAEtD;IAGE,yBACS,OAAgB,EACf,UAAqB,EACrB,MAAc;QAFf,YAAO,GAAP,OAAO,CAAS;QACf,eAAU,GAAV,UAAU,CAAW;QACrB,WAAM,GAAN,MAAM,CAAQ;QAEtB,IAAI,CAAC,MAAM,GAAG,IAAI,aAAM,CAAC,UAAG,UAAU,CAAC,IAAI,cAAI,MAAM,CAAC,IAAI,CAAE,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACjF,CAAC;IAEK,iCAAO,GAAb,UAAc,WAAgB;;;;;;;
|
|
1
|
+
{"version":3,"file":"ServiceExecutor.js","sourceRoot":"","sources":["../../src/ServiceExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wCAAyC;AACzC,oDAAmD;AACnD,6CAA4C;AAC5C,uDAAsD;AAEtD;IAGE,yBACS,OAAgB,EACf,UAAqB,EACrB,MAAc;QAFf,YAAO,GAAP,OAAO,CAAS;QACf,eAAU,GAAV,UAAU,CAAW;QACrB,WAAM,GAAN,MAAM,CAAQ;QAEtB,IAAI,CAAC,MAAM,GAAG,IAAI,aAAM,CAAC,UAAG,UAAU,CAAC,IAAI,cAAI,MAAM,CAAC,IAAI,CAAE,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACjF,CAAC;IAEK,iCAAO,GAAb,UAAc,WAAgB;;;;;;;wBACtB,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC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AC,CAAC;wBACpE,sBAAO,gBAAgB,EAAC;;;;KACzB;IACH,sBAAC;AAAD,CAAC,AAzCD,IAyCC;AAzCY,0CAAe"}
|
package/generated/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import '@proteinjs/util';
|
|
|
9
9
|
|
|
10
10
|
/** Generate Source Graph */
|
|
11
11
|
|
|
12
|
-
const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/service/Service\",\"value\":{\"packageName\":\"@proteinjs/service\",\"name\":\"Service\",\"filePath\":\"/Users/
|
|
12
|
+
const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/service/Service\",\"value\":{\"packageName\":\"@proteinjs/service\",\"name\":\"Service\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/service/packages/service/src/Service.ts\",\"qualifiedName\":\"@proteinjs/service/Service\",\"properties\":[{\"name\":\"serviceMetadata\",\"type\":{\"packageName\":\"@proteinjs/service\",\"name\":\"{\\n auth?: {\\n /** If true, the user does not need to be logged in or have any roles to call this service. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to call this service, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to call this service. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n /**\\n * Custom auth function. If provided, all other auth properties are ignored.\\n * @param methodName the name of the service method to be executed\\n * @param args the args[] that will be passed into the method\\n * @return true if the user can access the service method\\n */\\n canAccess?: (methodName: string, args: any[]) => boolean;\\n };\\n /** Don't await the service's execution, return a response to the client immediately */\\n doNotAwait?: boolean;\\n }\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/service/{\\n auth?: {\\n /** If true, the user does not need to be logged in or have any roles to call this service. If blank, defaults to false. */\\n public?: boolean;\\n /** If true, the user does not need to have any roles to call this service, but must be logged in. If blank, defaults to false. */\\n allUsers?: boolean;\\n /** The user must be logged in and have these roles to call this service. If blank, defaults to requiring the 'admin' role. */\\n roles?: string[];\\n /**\\n * Custom auth function. If provided, all other auth properties are ignored.\\n * @param methodName the name of the service method to be executed\\n * @param args the args[] that will be passed into the method\\n * @return true if the user can access the service method\\n */\\n canAccess?: (methodName: string, args: any[]) => boolean;\\n };\\n /** Don't await the service's execution, return a response to the client immediately */\\n doNotAwait?: boolean;\\n }\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":true,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[],\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/reflection\",\"name\":\"Loadable\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/reflection/Loadable\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"sourceType\":3}},{\"v\":\"@proteinjs/reflection/Loadable\"},{\"v\":\"@proteinjs/service/ServiceRouter\",\"value\":{\"packageName\":\"@proteinjs/service\",\"name\":\"ServiceRouter\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/service/packages/service/src/ServiceRouter.ts\",\"qualifiedName\":\"@proteinjs/service/ServiceRouter\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"logger\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"serviceExecutorMap\",\"type\":{\"packageName\":\"@proteinjs/service\",\"name\":\"{ [path: string]: ServiceExecutor } | undefined\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/service/{ [path: string]: ServiceExecutor } | undefined\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\"},{\"name\":\"path\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"method\",\"type\":{\"packageName\":\"\",\"name\":\"'post'\",\"filePath\":null,\"qualifiedName\":\"/'post'\",\"typeParameters\":null,\"directParents\":null},\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"getServiceExecutorMap\",\"returnType\":null,\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]},{\"name\":\"onRequest\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<any>\",\"filePath\":null,\"qualifiedName\":\"/Promise<any>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"request\",\"type\":{\"packageName\":\"\",\"name\":\"any\",\"filePath\":null,\"qualifiedName\":\"/any\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"response\",\"type\":{\"packageName\":\"\",\"name\":\"any\",\"filePath\":null,\"qualifiedName\":\"/any\",\"typeParameters\":null,\"directParents\":null}}]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/server-api/Route\"}],\"edges\":[{\"v\":\"@proteinjs/service/Service\",\"w\":\"@proteinjs/reflection/Loadable\",\"value\":\"extends interface\"},{\"v\":\"@proteinjs/service/ServiceRouter\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"implements interface\"}]}";
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
/** Generate Source Links */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/service",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "Service api",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@proteinjs/reflection": "1.1.7",
|
|
25
25
|
"@proteinjs/serializer": "1.0.13",
|
|
26
|
-
"@proteinjs/server-api": "1.3.
|
|
27
|
-
"@proteinjs/user-auth": "1.0.
|
|
26
|
+
"@proteinjs/server-api": "1.3.5",
|
|
27
|
+
"@proteinjs/user-auth": "1.0.15",
|
|
28
28
|
"@proteinjs/util": "1.3.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/src/ServiceClient.ts
CHANGED
|
@@ -19,16 +19,17 @@ export class ServiceClient {
|
|
|
19
19
|
const requestNumber = ServiceClient.requestCounter;
|
|
20
20
|
ServiceClient.requestCounter++;
|
|
21
21
|
console.groupCollapsed(`[#${requestNumber}] Sending service request: ${this.servicePath}, args:`);
|
|
22
|
-
console.log(
|
|
22
|
+
console.log(args);
|
|
23
23
|
console.groupEnd();
|
|
24
24
|
const serializedReturn = await this._send(this.servicePath, serializedArgs);
|
|
25
|
+
const deserializedReturn = Serializer.deserialize(serializedReturn);
|
|
25
26
|
console.groupCollapsed(
|
|
26
27
|
`[#${requestNumber}] Received service response: ${this.servicePath}, return:${isVoidReturnType(this.serviceMethod) ? ' (void)' : ''}`
|
|
27
28
|
);
|
|
28
|
-
console.log(
|
|
29
|
+
console.log(deserializedReturn);
|
|
29
30
|
console.groupEnd();
|
|
30
31
|
|
|
31
|
-
return
|
|
32
|
+
return deserializedReturn;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
if (this.debouncer) {
|
package/src/ServiceExecutor.ts
CHANGED
|
@@ -17,9 +17,9 @@ export class ServiceExecutor {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async execute(requestBody: any): Promise<any> {
|
|
20
|
-
this.logger.info(`Executing with args:\n${JSON.stringify(requestBody, null, 2)}`);
|
|
21
20
|
const method = this.service[this.method.name].bind(this.service);
|
|
22
21
|
const deserializedArgs = Serializer.deserialize(requestBody);
|
|
22
|
+
this.logger.info(`Executing with args:\n${JSON.stringify(deserializedArgs, null, 2)}`);
|
|
23
23
|
if (!ServiceAuth.canRunService(this.service, this.method, deserializedArgs)) {
|
|
24
24
|
const error = `User not authorized to run service: ${this._interface.name}.${this.method.name}`;
|
|
25
25
|
throw new Error(error);
|
|
@@ -43,7 +43,7 @@ export class ServiceExecutor {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const serializedReturn = Serializer.serialize(_return);
|
|
46
|
-
this.logger.info(`Returning:\n${
|
|
46
|
+
this.logger.info(`Returning:\n${JSON.stringify(_return, null, 2)}`);
|
|
47
47
|
return serializedReturn;
|
|
48
48
|
}
|
|
49
49
|
}
|