@proteinjs/service 1.0.27 → 1.0.29

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 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.28](https://github.com/proteinjs/service/compare/@proteinjs/service@1.0.27...@proteinjs/service@1.0.28) (2024-08-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * refactored to implement new @proteinjs/logger/Logger api ([64960ad](https://github.com/proteinjs/service/commit/64960ade33b0f9f85891e9abaf0dbba35e695d0c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [1.0.23](https://github.com/proteinjs/service/compare/@proteinjs/service@1.0.22...@proteinjs/service@1.0.23) (2024-07-20)
7
18
 
8
19
 
@@ -1,4 +1,5 @@
1
1
  /** Load Dependency Source Graphs */
2
+ import '@proteinjs/logger';
2
3
  import '@proteinjs/reflection';
3
4
  import '@proteinjs/serializer';
4
5
  import '@proteinjs/server-api';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,iBAAiB,CAAC;AAuBzB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,iBAAiB,CAAC;AAuBzB,cAAc,UAAU,CAAC"}
@@ -15,13 +15,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ require("@proteinjs/logger");
18
19
  require("@proteinjs/reflection");
19
20
  require("@proteinjs/serializer");
20
21
  require("@proteinjs/server-api");
21
22
  require("@proteinjs/user-auth");
22
23
  require("@proteinjs/util");
23
24
  /** 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/veronica/Repositories/n3xa-meta-repo/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/veronica/Repositories/n3xa-meta-repo/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
+ 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
26
  /** Generate Source Links */
26
27
  var ServiceRouter_1 = require("../src/ServiceRouter");
27
28
  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,ooLAAooL,CAAC;AAGzpL,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
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,6BAA2B;AAC3B,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"}
@@ -5,7 +5,6 @@ export declare class ServiceClient {
5
5
  private serviceMethod;
6
6
  private debouncer?;
7
7
  private static requestCounter;
8
- private logger;
9
8
  constructor(servicePath: string, serviceMethod: Method, debouncer?: Debouncer | undefined);
10
9
  send(...args: any[]): Promise<any>;
11
10
  private _send;
@@ -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;YA0B1B,KAAK;CAsBpB"}
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,EAAE,MAAM,iBAAiB,CAAC;AAG5C,qBAAa,aAAa;IAItB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS,CAAC;IALpB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAK;gBAGxB,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"}
@@ -38,14 +38,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ServiceClient = void 0;
40
40
  var serializer_1 = require("@proteinjs/serializer");
41
- var util_1 = require("@proteinjs/util");
42
41
  var isVoidReturnType_1 = require("./isVoidReturnType");
43
42
  var ServiceClient = /** @class */ (function () {
44
43
  function ServiceClient(servicePath, serviceMethod, debouncer) {
45
44
  this.servicePath = servicePath;
46
45
  this.serviceMethod = serviceMethod;
47
46
  this.debouncer = debouncer;
48
- this.logger = new util_1.Logger(this.constructor.name, 'info', 2000);
49
47
  }
50
48
  ServiceClient.prototype.send = function () {
51
49
  var args = [];
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceClient.js","sourceRoot":"","sources":["../../src/ServiceClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAmD;AACnD,wCAAoD;AACpD,uDAAsD;AAEtD;IAIE,uBACU,WAAmB,EACnB,aAAqB,EACrB,SAAqB;QAFrB,gBAAW,GAAX,WAAW,CAAQ;QACnB,kBAAa,GAAb,aAAa,CAAQ;QACrB,cAAS,GAAT,SAAS,CAAY;QALvB,WAAM,GAAG,IAAI,aAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAM9D,CAAC;IAEE,4BAAI,GAAV;QAAW,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,yBAAc;;;;;;gBACjB,WAAW,GAAG;;;;;gCACZ,cAAc,GAAG,uBAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gCAC5C,aAAa,GAAG,aAAa,CAAC,cAAc,CAAC;gCACnD,aAAa,CAAC,cAAc,EAAE,CAAC;gCAC/B,OAAO,CAAC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I,CAAC,KAAK,CAAC,CAAC;yBAC7B;wBAED,sBAAO,IAAI,CAAC,gBAAgB,EAAC;;;;KAC9B;IAvDc,4BAAc,GAAG,CAAC,CAAC;IAwDpC,oBAAC;CAAA,AAzDD,IAyDC;AAzDY,sCAAa"}
@@ -6,7 +6,9 @@ export declare class ServiceExecutor {
6
6
  private method;
7
7
  private logger;
8
8
  deserializedArgs: any;
9
+ private serviceMethodName;
9
10
  constructor(service: Service, _interface: Interface, method: Method);
10
11
  execute(requestBody: any): Promise<any>;
12
+ private shouldLogArgsAndReturn;
11
13
  }
12
14
  //# sourceMappingURL=ServiceExecutor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceExecutor.d.ts","sourceRoot":"","sources":["../../src/ServiceExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,qBAAa,eAAe;IAIjB,OAAO,EAAE,OAAO;IACvB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IALhB,OAAO,CAAC,MAAM,CAAS;IAChB,gBAAgB,EAAE,GAAG,CAAC;gBAEpB,OAAO,EAAE,OAAO,EACf,UAAU,EAAE,SAAS,EACrB,MAAM,EAAE,MAAM;IAKlB,OAAO,CAAC,WAAW,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CA8B9C"}
1
+ {"version":3,"file":"ServiceExecutor.d.ts","sourceRoot":"","sources":["../../src/ServiceExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,qBAAa,eAAe;IAKjB,OAAO,EAAE,OAAO;IACvB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,MAAM;IANhB,OAAO,CAAC,MAAM,CAAS;IAChB,gBAAgB,EAAE,GAAG,CAAC;IAC7B,OAAO,CAAC,iBAAiB,CAAS;gBAEzB,OAAO,EAAE,OAAO,EACf,UAAU,EAAE,SAAS,EACrB,MAAM,EAAE,MAAM;IAMlB,OAAO,CAAC,WAAW,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IA4C7C,OAAO,CAAC,sBAAsB;CAG/B"}
@@ -37,16 +37,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ServiceExecutor = void 0;
40
- var util_1 = require("@proteinjs/util");
40
+ var logger_1 = require("@proteinjs/logger");
41
41
  var serializer_1 = require("@proteinjs/serializer");
42
42
  var ServiceAuth_1 = require("./ServiceAuth");
43
43
  var isVoidReturnType_1 = require("./isVoidReturnType");
44
+ var server_api_1 = require("@proteinjs/server-api");
44
45
  var ServiceExecutor = /** @class */ (function () {
45
46
  function ServiceExecutor(service, _interface, method) {
46
47
  this.service = service;
47
48
  this._interface = _interface;
48
49
  this.method = method;
49
- this.logger = new util_1.Logger("".concat(_interface.name, ".").concat(method.name), undefined, 2500);
50
+ this.serviceMethodName = "".concat(_interface.name, ".").concat(method.name);
51
+ this.logger = new logger_1.Logger({ name: this.serviceMethodName });
50
52
  }
51
53
  ServiceExecutor.prototype.execute = function (requestBody) {
52
54
  var _a;
@@ -57,7 +59,9 @@ var ServiceExecutor = /** @class */ (function () {
57
59
  case 0:
58
60
  method = this.service[this.method.name].bind(this.service);
59
61
  deserializedArgs = serializer_1.Serializer.deserialize(requestBody);
60
- this.logger.info("Executing with args:\n".concat(JSON.stringify(deserializedArgs, null, 2)));
62
+ if (this.shouldLogArgsAndReturn()) {
63
+ this.logger.info({ message: "Calling", obj: { functionName: this.serviceMethodName, args: deserializedArgs } });
64
+ }
61
65
  if (!ServiceAuth_1.ServiceAuth.canRunService(this.service, this.method, deserializedArgs)) {
62
66
  error = "User not authorized to run service: ".concat(this._interface.name, ".").concat(this.method.name);
63
67
  throw new Error(error);
@@ -75,20 +79,34 @@ var ServiceExecutor = /** @class */ (function () {
75
79
  case 4: return [3 /*break*/, 6];
76
80
  case 5:
77
81
  error_1 = _b.sent();
78
- this.logger.error("Failed with args:\n".concat(JSON.stringify(requestBody, null, 2)));
82
+ this.logger.error({
83
+ message: "Failed",
84
+ error: error_1,
85
+ obj: { functionName: this.serviceMethodName, args: deserializedArgs },
86
+ });
79
87
  throw error_1;
80
88
  case 6:
81
89
  if ((0, isVoidReturnType_1.isVoidReturnType)(this.method)) {
82
- this.logger.info("Returning: (void)");
90
+ if (this.shouldLogArgsAndReturn()) {
91
+ this.logger.info({
92
+ message: "Returning (void)",
93
+ obj: { functionName: this.serviceMethodName, return: 'void' },
94
+ });
95
+ }
83
96
  return [2 /*return*/, undefined];
84
97
  }
85
98
  serializedReturn = serializer_1.Serializer.serialize(_return);
86
- this.logger.info("Returning:\n".concat(JSON.stringify(_return, null, 2)));
99
+ if (this.shouldLogArgsAndReturn()) {
100
+ this.logger.info({ message: "Returning", obj: { functionName: this.serviceMethodName, return: _return } });
101
+ }
87
102
  return [2 /*return*/, serializedReturn];
88
103
  }
89
104
  });
90
105
  });
91
106
  };
107
+ ServiceExecutor.prototype.shouldLogArgsAndReturn = function () {
108
+ return !server_api_1.EnvInfo.isDev() || process.env.DETAILED_SERVICE_LOGS;
109
+ };
92
110
  return ServiceExecutor;
93
111
  }());
94
112
  exports.ServiceExecutor = ServiceExecutor;
@@ -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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AG,uBAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;wBACvD,IAAI,IAAI,CAAC,sBAAsB,EAAE,EAAE;4BACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;yBAC5G;wBACD,sBAAO,gBAAgB,EAAC;;;;KACzB;IAEO,gDAAsB,GAA9B;QACE,OAAO,CAAC,oBAAO,CAAC,KAAK,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAC/D,CAAC;IACH,sBAAC;AAAD,CAAC,AA5DD,IA4DC;AA5DY,0CAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceRouter.d.ts","sourceRoot":"","sources":["../../src/ServiceRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAM9C,qBAAa,aAAc,YAAW,KAAK;IACzC,OAAO,CAAC,MAAM,CAAqC;IACnD,OAAO,CAAC,kBAAkB,CAAkD;IAC5E,IAAI,SAAe;IACnB,MAAM,EAAE,MAAM,CAAU;IAExB,OAAO,CAAC,qBAAqB;IAqBvB,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAiB3D"}
1
+ {"version":3,"file":"ServiceRouter.d.ts","sourceRoot":"","sources":["../../src/ServiceRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAO9C,qBAAa,aAAc,YAAW,KAAK;IACzC,OAAO,CAAC,MAAM,CAA+C;IAC7D,OAAO,CAAC,kBAAkB,CAAkD;IAC5E,IAAI,SAAe;IACnB,MAAM,EAAE,MAAM,CAAU;IAExB,OAAO,CAAC,qBAAqB;IAqBvB,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAiB3D"}
@@ -40,9 +40,10 @@ exports.ServiceRouter = void 0;
40
40
  var reflection_1 = require("@proteinjs/reflection");
41
41
  var ServiceExecutor_1 = require("./ServiceExecutor");
42
42
  var util_1 = require("@proteinjs/util");
43
+ var logger_1 = require("@proteinjs/logger");
43
44
  var ServiceRouter = /** @class */ (function () {
44
45
  function ServiceRouter() {
45
- this.logger = new util_1.Logger(this.constructor.name);
46
+ this.logger = new logger_1.Logger({ name: this.constructor.name });
46
47
  this.path = 'service/*';
47
48
  this.method = 'post';
48
49
  }
@@ -52,7 +53,7 @@ var ServiceRouter = /** @class */ (function () {
52
53
  var serviceTypes = Object.values(reflection_1.SourceRepository.get().directChildren('@proteinjs/service/Service'));
53
54
  for (var _i = 0, serviceTypes_1 = serviceTypes; _i < serviceTypes_1.length; _i++) {
54
55
  var serviceType = serviceTypes_1[_i];
55
- this.logger.info("Loading service: ".concat(serviceType.qualifiedName));
56
+ this.logger.info({ message: "Loading service: ".concat(serviceType.qualifiedName) });
56
57
  if (!(0, util_1.isInstanceOf)(serviceType, reflection_1.Interface)) {
57
58
  continue;
58
59
  }
@@ -75,7 +76,7 @@ var ServiceRouter = /** @class */ (function () {
75
76
  serviceExecutor = this.getServiceExecutorMap()[request.path];
76
77
  if (!serviceExecutor) {
77
78
  error = "Unable to find service matching path: ".concat(request.path);
78
- this.logger.error(error);
79
+ this.logger.error({ message: error });
79
80
  response.send({ error: error });
80
81
  return [2 /*return*/];
81
82
  }
@@ -89,7 +90,7 @@ var ServiceRouter = /** @class */ (function () {
89
90
  return [3 /*break*/, 4];
90
91
  case 3:
91
92
  error_1 = _a.sent();
92
- this.logger.error(error_1.stack);
93
+ this.logger.error({ error: error_1 });
93
94
  response.send({ error: error_1.message });
94
95
  return [3 /*break*/, 4];
95
96
  case 4: return [2 /*return*/];
@@ -1 +1 @@
1
- {"version":3,"file":"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AAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;4BACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;4BACzB,sBAAO;yBACR;;;;wBAG0B,qBAAM,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAA;;wBAA9D,gBAAgB,GAAG,SAA2C;wBACpE,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,kBAAA,EAAE,CAAC,CAAC;;;;wBAEpC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,SAAA,EAAE,CAAC,CAAC;wBAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAK,CAAC,OAAO,EAAE,CAAC,CAAC;;;;;;KAE3C;IACH,oBAAC;AAAD,CAAC,AA5CD,IA4CC;AA5CY,sCAAa"}
@@ -1,5 +1,6 @@
1
1
  /** Load Dependency Source Graphs */
2
2
 
3
+ import '@proteinjs/logger';
3
4
  import '@proteinjs/reflection';
4
5
  import '@proteinjs/serializer';
5
6
  import '@proteinjs/server-api';
@@ -9,7 +10,7 @@ import '@proteinjs/util';
9
10
 
10
11
  /** Generate Source Graph */
11
12
 
12
- const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/service/Service\",\"value\":{\"packageName\":\"@proteinjs/service\",\"name\":\"Service\",\"filePath\":\"/Users/veronica/Repositories/n3xa-meta-repo/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/veronica/Repositories/n3xa-meta-repo/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
+ 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
14
 
14
15
 
15
16
  /** Generate Source Links */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteinjs/service",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Service api",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -21,14 +21,15 @@
21
21
  "watch": "reflection-watch"
22
22
  },
23
23
  "dependencies": {
24
- "@proteinjs/reflection": "1.1.8",
25
- "@proteinjs/serializer": "1.0.14",
26
- "@proteinjs/server-api": "1.4.1",
27
- "@proteinjs/user-auth": "1.1.0",
28
- "@proteinjs/util": "1.4.0"
24
+ "@proteinjs/logger": "1.0.5",
25
+ "@proteinjs/reflection": "1.1.9",
26
+ "@proteinjs/serializer": "1.0.15",
27
+ "@proteinjs/server-api": "1.4.3",
28
+ "@proteinjs/user-auth": "1.1.1",
29
+ "@proteinjs/util": "1.4.1"
29
30
  },
30
31
  "devDependencies": {
31
- "@proteinjs/reflection-build": "1.0.23",
32
+ "@proteinjs/reflection-build": "1.0.24",
32
33
  "@types/jest": "29.5.5",
33
34
  "@types/node": "14.0.27",
34
35
  "@typescript-eslint/eslint-plugin": "7.8.0",
@@ -42,4 +43,4 @@
42
43
  },
43
44
  "main": "./dist/generated/index.js",
44
45
  "types": "./dist/generated/index.d.ts"
45
- }
46
+ }
@@ -1,11 +1,10 @@
1
1
  import { Method } from '@proteinjs/reflection';
2
2
  import { Serializer } from '@proteinjs/serializer';
3
- import { Debouncer, Logger } from '@proteinjs/util';
3
+ import { Debouncer } from '@proteinjs/util';
4
4
  import { isVoidReturnType } from './isVoidReturnType';
5
5
 
6
6
  export class ServiceClient {
7
7
  private static requestCounter = 1;
8
- private logger = new Logger(this.constructor.name, 'info', 2000);
9
8
 
10
9
  constructor(
11
10
  private servicePath: string,
@@ -1,25 +1,30 @@
1
1
  import { Interface, Method } from '@proteinjs/reflection';
2
2
  import { Service } from './Service';
3
- import { Logger } from '@proteinjs/util';
3
+ import { Logger } from '@proteinjs/logger';
4
4
  import { Serializer } from '@proteinjs/serializer';
5
5
  import { ServiceAuth } from './ServiceAuth';
6
6
  import { isVoidReturnType } from './isVoidReturnType';
7
+ import { EnvInfo } from '@proteinjs/server-api';
7
8
 
8
9
  export class ServiceExecutor {
9
10
  private logger: Logger;
10
11
  public deserializedArgs: any;
12
+ private serviceMethodName: string;
11
13
  constructor(
12
14
  public service: Service,
13
15
  private _interface: Interface,
14
16
  private method: Method
15
17
  ) {
16
- this.logger = new Logger(`${_interface.name}.${method.name}`, undefined, 2500);
18
+ this.serviceMethodName = `${_interface.name}.${method.name}`;
19
+ this.logger = new Logger({ name: this.serviceMethodName });
17
20
  }
18
21
 
19
22
  async execute(requestBody: any): Promise<any> {
20
23
  const method = this.service[this.method.name].bind(this.service);
21
24
  const deserializedArgs = Serializer.deserialize(requestBody);
22
- this.logger.info(`Executing with args:\n${JSON.stringify(deserializedArgs, null, 2)}`);
25
+ if (this.shouldLogArgsAndReturn()) {
26
+ this.logger.info({ message: `Calling`, obj: { functionName: this.serviceMethodName, args: deserializedArgs } });
27
+ }
23
28
  if (!ServiceAuth.canRunService(this.service, this.method, deserializedArgs)) {
24
29
  const error = `User not authorized to run service: ${this._interface.name}.${this.method.name}`;
25
30
  throw new Error(error);
@@ -33,17 +38,32 @@ export class ServiceExecutor {
33
38
  _return = await method(...deserializedArgs);
34
39
  }
35
40
  } catch (error: any) {
36
- this.logger.error(`Failed with args:\n${JSON.stringify(requestBody, null, 2)}`);
41
+ this.logger.error({
42
+ message: `Failed`,
43
+ error,
44
+ obj: { functionName: this.serviceMethodName, args: deserializedArgs },
45
+ });
37
46
  throw error;
38
47
  }
39
48
 
40
49
  if (isVoidReturnType(this.method)) {
41
- this.logger.info(`Returning: (void)`);
50
+ if (this.shouldLogArgsAndReturn()) {
51
+ this.logger.info({
52
+ message: `Returning (void)`,
53
+ obj: { functionName: this.serviceMethodName, return: 'void' },
54
+ });
55
+ }
42
56
  return undefined;
43
57
  }
44
58
 
45
59
  const serializedReturn = Serializer.serialize(_return);
46
- this.logger.info(`Returning:\n${JSON.stringify(_return, null, 2)}`);
60
+ if (this.shouldLogArgsAndReturn()) {
61
+ this.logger.info({ message: `Returning`, obj: { functionName: this.serviceMethodName, return: _return } });
62
+ }
47
63
  return serializedReturn;
48
64
  }
65
+
66
+ private shouldLogArgsAndReturn() {
67
+ return !EnvInfo.isDev() || process.env.DETAILED_SERVICE_LOGS;
68
+ }
49
69
  }
@@ -2,10 +2,11 @@ import { Route } from '@proteinjs/server-api';
2
2
  import { Service } from './Service';
3
3
  import { Interface, SourceRepository } from '@proteinjs/reflection';
4
4
  import { ServiceExecutor } from './ServiceExecutor';
5
- import { Logger, isInstanceOf } from '@proteinjs/util';
5
+ import { isInstanceOf } from '@proteinjs/util';
6
+ import { Logger } from '@proteinjs/logger';
6
7
 
7
8
  export class ServiceRouter implements Route {
8
- private logger = new Logger(this.constructor.name);
9
+ private logger = new Logger({ name: this.constructor.name });
9
10
  private serviceExecutorMap: { [path: string]: ServiceExecutor } | undefined;
10
11
  path = 'service/*';
11
12
  method: 'post' = 'post';
@@ -15,7 +16,7 @@ export class ServiceRouter implements Route {
15
16
  this.serviceExecutorMap = {};
16
17
  const serviceTypes = Object.values(SourceRepository.get().directChildren('@proteinjs/service/Service'));
17
18
  for (const serviceType of serviceTypes) {
18
- this.logger.info(`Loading service: ${serviceType.qualifiedName}`);
19
+ this.logger.info({ message: `Loading service: ${serviceType.qualifiedName}` });
19
20
  if (!isInstanceOf(serviceType, Interface)) {
20
21
  continue;
21
22
  }
@@ -35,7 +36,7 @@ export class ServiceRouter implements Route {
35
36
  const serviceExecutor = this.getServiceExecutorMap()[request.path];
36
37
  if (!serviceExecutor) {
37
38
  const error = `Unable to find service matching path: ${request.path}`;
38
- this.logger.error(error);
39
+ this.logger.error({ message: error });
39
40
  response.send({ error });
40
41
  return;
41
42
  }
@@ -44,7 +45,7 @@ export class ServiceRouter implements Route {
44
45
  const serializedReturn = await serviceExecutor.execute(request.body);
45
46
  response.send({ serializedReturn });
46
47
  } catch (error: any) {
47
- this.logger.error(error.stack);
48
+ this.logger.error({ error });
48
49
  response.send({ error: error.message });
49
50
  }
50
51
  }