@cryptexlabs/codex-nodejs-common 0.1.21 → 0.1.22

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/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptexlabs/codex-nodejs-common",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Common code for Assistant applications",
5
5
  "main": "lib/src/index.js",
6
6
  "repository": "git@gitlab.com:cryptexlabs/public/codex-nodejs-common.git",
@@ -31,6 +31,8 @@
31
31
  "@types/node": "^16.6.1",
32
32
  "dotenv": "^8.2.0",
33
33
  "express": "^4.17.1",
34
+ "fastq": "^1.13.0",
35
+ "glob": "^7.2.0",
34
36
  "i18n": "^0.13.2",
35
37
  "install-peers-cli": "^2.2.0",
36
38
  "joi": "^17.3.0",
@@ -9,6 +9,7 @@ export * from "./logger";
9
9
  export * from "./message";
10
10
  export * from "./pipe";
11
11
  export * from "./response";
12
+ export * from "./result";
12
13
  export * from "./exception";
13
14
  export * from "./locales";
14
15
  export * from "./service";
package/lib/src/index.js CHANGED
@@ -21,6 +21,7 @@ __exportStar(require("./logger"), exports);
21
21
  __exportStar(require("./message"), exports);
22
22
  __exportStar(require("./pipe"), exports);
23
23
  __exportStar(require("./response"), exports);
24
+ __exportStar(require("./result"), exports);
24
25
  __exportStar(require("./exception"), exports);
25
26
  __exportStar(require("./locales"), exports);
26
27
  __exportStar(require("./service"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B;AAC5B,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,6CAA2B;AAC3B,8CAA4B;AAC5B,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,8CAA4B;AAC5B,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,yCAAuB;AACvB,6CAA2B;AAC3B,2CAAyB;AACzB,8CAA4B;AAC5B,4CAA0B;AAC1B,4CAA0B;AAC1B,yCAAuB"}
@@ -0,0 +1,9 @@
1
+ import { HttpStatus } from "@nestjs/common";
2
+ import { LocaleInterface, MessageMetaInterface } from "@cryptexlabs/codex-data-model";
3
+ import { DefaultConfig } from "../config";
4
+ import { MessageMeta } from "../message";
5
+ export declare class HttpPaginatedResponseMeta extends MessageMeta implements MessageMetaInterface {
6
+ readonly status: HttpStatus;
7
+ readonly totalRecords: number;
8
+ constructor(status: HttpStatus, totalRecords: number, type: string, locale: LocaleInterface, config: DefaultConfig, correlationId: string, started: Date);
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpPaginatedResponseMeta = void 0;
4
+ const message_1 = require("../message");
5
+ class HttpPaginatedResponseMeta extends message_1.MessageMeta {
6
+ constructor(status, totalRecords, type, locale, config, correlationId, started) {
7
+ super(type, locale, config, correlationId, started);
8
+ this.status = status;
9
+ this.totalRecords = totalRecords;
10
+ }
11
+ }
12
+ exports.HttpPaginatedResponseMeta = HttpPaginatedResponseMeta;
13
+ //# sourceMappingURL=http-paginated-response-meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-paginated-response-meta.js","sourceRoot":"","sources":["../../../src/response/http-paginated-response-meta.ts"],"names":[],"mappings":";;;AAMA,wCAAyC;AAEzC,MAAa,yBACX,SAAQ,qBAAW;IAGnB,YACkB,MAAkB,EAClB,YAAoB,EACpC,IAAY,EACZ,MAAuB,EACvB,MAAqB,EACrB,aAAqB,EACrB,OAAa;QAEb,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;QARpC,WAAM,GAAN,MAAM,CAAY;QAClB,iBAAY,GAAZ,YAAY,CAAQ;IAQtC,CAAC;CACF;AAfD,8DAeC"}
@@ -6,3 +6,5 @@ export * from "./healthz-response";
6
6
  export * from "./http-response-meta";
7
7
  export * from "./rest.response";
8
8
  export * from "./simple-http.response";
9
+ export * from "./http-paginated-response-meta";
10
+ export * from "./rest.paginated.response";
@@ -18,4 +18,6 @@ __exportStar(require("./healthz-response"), exports);
18
18
  __exportStar(require("./http-response-meta"), exports);
19
19
  __exportStar(require("./rest.response"), exports);
20
20
  __exportStar(require("./simple-http.response"), exports);
21
+ __exportStar(require("./http-paginated-response-meta"), exports);
22
+ __exportStar(require("./rest.paginated.response"), exports);
21
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/response/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAsC;AACtC,kDAAgC;AAChC,kDAAgC;AAChC,6DAA2C;AAC3C,qDAAmC;AACnC,uDAAqC;AACrC,kDAAgC;AAChC,yDAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/response/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wDAAsC;AACtC,kDAAgC;AAChC,kDAAgC;AAChC,6DAA2C;AAC3C,qDAAmC;AACnC,uDAAqC;AACrC,kDAAgC;AAChC,yDAAuC;AACvC,iEAA+C;AAC/C,4DAA0C"}
@@ -0,0 +1,10 @@
1
+ import { HttpStatus } from "@nestjs/common";
2
+ import { MessageInterface, MessageMetaInterface } from "@cryptexlabs/codex-data-model";
3
+ import { JsonSerializableInterface } from "../message";
4
+ import { Context } from "../context";
5
+ export declare class RestPaginatedResponse implements JsonSerializableInterface<MessageInterface<string>> {
6
+ readonly data: any;
7
+ readonly meta: MessageMetaInterface;
8
+ constructor(context: Context, status: HttpStatus, totalRecords: number, type: string, data: any);
9
+ toJSON(): MessageInterface<any>;
10
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RestPaginatedResponse = void 0;
4
+ const http_paginated_response_meta_1 = require("./http-paginated-response-meta");
5
+ class RestPaginatedResponse {
6
+ constructor(context, status, totalRecords, type, data) {
7
+ this.data = data;
8
+ this.meta = new http_paginated_response_meta_1.HttpPaginatedResponseMeta(status, totalRecords, type, context.locale, context.config, context.correlationId, context.started);
9
+ }
10
+ toJSON() {
11
+ return {
12
+ meta: this.meta,
13
+ data: this.data,
14
+ };
15
+ }
16
+ }
17
+ exports.RestPaginatedResponse = RestPaginatedResponse;
18
+ //# sourceMappingURL=rest.paginated.response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest.paginated.response.js","sourceRoot":"","sources":["../../../src/response/rest.paginated.response.ts"],"names":[],"mappings":";;;AAQA,iFAA2E;AAE3E,MAAa,qBAAqB;IAKhC,YACE,OAAgB,EAChB,MAAkB,EAClB,YAAoB,EACpB,IAAY,EACI,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;QAEzB,IAAI,CAAC,IAAI,GAAG,IAAI,wDAAyB,CACvC,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,OAAO,CACQ,CAAC;IAC5B,CAAC;IAEM,MAAM;QACX,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;CACF;AA7BD,sDA6BC"}
@@ -0,0 +1 @@
1
+ export * from "./paginated.results";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./paginated.results"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/result/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAAoC"}
@@ -0,0 +1,4 @@
1
+ export interface PaginatedResults<T> {
2
+ total: number;
3
+ results: T[];
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=paginated.results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginated.results.js","sourceRoot":"","sources":["../../../src/result/paginated.results.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptexlabs/codex-nodejs-common",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Common code for Assistant applications",
5
5
  "main": "lib/src/index.js",
6
6
  "repository": "git@gitlab.com:cryptexlabs/public/codex-nodejs-common.git",
@@ -31,6 +31,8 @@
31
31
  "@types/node": "^16.6.1",
32
32
  "dotenv": "^8.2.0",
33
33
  "express": "^4.17.1",
34
+ "fastq": "^1.13.0",
35
+ "glob": "^7.2.0",
34
36
  "i18n": "^0.13.2",
35
37
  "install-peers-cli": "^2.2.0",
36
38
  "joi": "^17.3.0",
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export * from "./logger";
9
9
  export * from "./message";
10
10
  export * from "./pipe";
11
11
  export * from "./response";
12
+ export * from "./result";
12
13
  export * from "./exception";
13
14
  export * from "./locales";
14
15
  export * from "./service";
@@ -0,0 +1,24 @@
1
+ import { HttpStatus } from "@nestjs/common";
2
+ import {
3
+ LocaleInterface,
4
+ MessageMetaInterface,
5
+ } from "@cryptexlabs/codex-data-model";
6
+ import { DefaultConfig } from "../config";
7
+ import { MessageMeta } from "../message";
8
+
9
+ export class HttpPaginatedResponseMeta
10
+ extends MessageMeta
11
+ implements MessageMetaInterface
12
+ {
13
+ constructor(
14
+ public readonly status: HttpStatus,
15
+ public readonly totalRecords: number,
16
+ type: string,
17
+ locale: LocaleInterface,
18
+ config: DefaultConfig,
19
+ correlationId: string,
20
+ started: Date
21
+ ) {
22
+ super(type, locale, config, correlationId, started);
23
+ }
24
+ }
@@ -6,3 +6,5 @@ export * from "./healthz-response";
6
6
  export * from "./http-response-meta";
7
7
  export * from "./rest.response";
8
8
  export * from "./simple-http.response";
9
+ export * from "./http-paginated-response-meta";
10
+ export * from "./rest.paginated.response";
@@ -0,0 +1,40 @@
1
+ import { HttpStatus } from "@nestjs/common";
2
+ import {
3
+ MessageInterface,
4
+ MessageMetaInterface,
5
+ } from "@cryptexlabs/codex-data-model";
6
+ import { JsonSerializableInterface } from "../message";
7
+ import { Context } from "../context";
8
+ import { HttpResponseMeta } from "./http-response-meta";
9
+ import { HttpPaginatedResponseMeta } from "./http-paginated-response-meta";
10
+
11
+ export class RestPaginatedResponse
12
+ implements JsonSerializableInterface<MessageInterface<string>>
13
+ {
14
+ public readonly meta: MessageMetaInterface;
15
+
16
+ constructor(
17
+ context: Context,
18
+ status: HttpStatus,
19
+ totalRecords: number,
20
+ type: string,
21
+ public readonly data: any
22
+ ) {
23
+ this.meta = new HttpPaginatedResponseMeta(
24
+ status,
25
+ totalRecords,
26
+ type,
27
+ context.locale,
28
+ context.config,
29
+ context.correlationId,
30
+ context.started
31
+ ) as MessageMetaInterface;
32
+ }
33
+
34
+ public toJSON(): MessageInterface<any> {
35
+ return {
36
+ meta: this.meta,
37
+ data: this.data,
38
+ };
39
+ }
40
+ }
@@ -0,0 +1 @@
1
+ export * from "./paginated.results";
@@ -0,0 +1,4 @@
1
+ export interface PaginatedResults<T> {
2
+ total: number;
3
+ results: T[];
4
+ }