@nmshd/connector-types 6.17.1 → 6.17.2

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.
@@ -0,0 +1,14 @@
1
+ import { Result } from "@js-soft/ts-utils";
2
+ import { Return } from "@nmshd/typescript-rest";
3
+ import express from "express";
4
+ import { Envelope } from "./common/Envelope";
5
+ import { Mimetype } from "./common/Mimetype";
6
+ export declare abstract class BaseController {
7
+ protected created<T>(result: Result<T>): Return.NewResource<Envelope>;
8
+ protected ok<T>(result: Result<T>): Envelope;
9
+ protected noContent<T>(result: Result<T>): void;
10
+ private json;
11
+ private guard;
12
+ protected file<T extends Result<any>>(result: T, contentPredicate: (result: T) => Buffer | string | Uint8Array | undefined, filenamePredicate: (result: T) => string, mimetypePredicate: (result: T) => Mimetype, response: express.Response, status: number): void;
13
+ }
14
+ //# sourceMappingURL=BaseController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseController.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/BaseController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,8BAAsB,cAAc;IAChC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC;IAIrE,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ;IAI5C,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAK/C,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,KAAK;IAMb,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,EAChC,MAAM,EAAE,CAAC,EACT,gBAAgB,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,EACzE,iBAAiB,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,EACxC,iBAAiB,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,QAAQ,EAC1C,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,MAAM,EAAE,MAAM,GACf,IAAI;CAwBV"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseController = void 0;
4
+ const typescript_rest_1 = require("@nmshd/typescript-rest");
5
+ const Envelope_1 = require("./common/Envelope");
6
+ class BaseController {
7
+ created(result) {
8
+ return new typescript_rest_1.Return.NewResource("_", this.json(result));
9
+ }
10
+ ok(result) {
11
+ return this.json(result);
12
+ }
13
+ noContent(result) {
14
+ this.guard(result);
15
+ return;
16
+ }
17
+ json(result) {
18
+ this.guard(result);
19
+ return Envelope_1.Envelope.ok(result.value);
20
+ }
21
+ guard(result) {
22
+ if (result.isError) {
23
+ throw result.error;
24
+ }
25
+ }
26
+ file(result, contentPredicate, filenamePredicate, mimetypePredicate, response, status) {
27
+ this.guard(result);
28
+ const content = contentPredicate(result);
29
+ const filename = filenamePredicate(result);
30
+ const mimetype = mimetypePredicate(result);
31
+ if (!content)
32
+ throw new Error("'content' cannot be undefined");
33
+ let buffer;
34
+ if (content instanceof Buffer) {
35
+ buffer = content;
36
+ }
37
+ else if (content instanceof Uint8Array) {
38
+ buffer = Buffer.from(content);
39
+ }
40
+ else {
41
+ buffer = Buffer.from(content, "base64");
42
+ }
43
+ response
44
+ .status(status)
45
+ .setHeader("content-type", mimetype.value)
46
+ .setHeader("content-disposition", `attachment;filename=${encodeURIComponent(filename)}`)
47
+ .send(buffer);
48
+ }
49
+ }
50
+ exports.BaseController = BaseController;
51
+ //# sourceMappingURL=BaseController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseController.js","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/BaseController.ts"],"names":[],"mappings":";;;AACA,4DAAgD;AAEhD,gDAA6C;AAG7C,MAAsB,cAAc;IACtB,OAAO,CAAI,MAAiB;QAClC,OAAO,IAAI,wBAAM,CAAC,WAAW,CAAW,GAAG,EAAE,IAAI,CAAC,IAAI,CAAI,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,EAAE,CAAI,MAAiB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAES,SAAS,CAAI,MAAiB;QACpC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO;IACX,CAAC;IAEO,IAAI,CAAI,MAAiB;QAC7B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO,mBAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAI,MAAiB;QAC9B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,MAAM,CAAC,KAAK,CAAC;QACvB,CAAC;IACL,CAAC;IAES,IAAI,CACV,MAAS,EACT,gBAAyE,EACzE,iBAAwC,EACxC,iBAA0C,EAC1C,QAA0B,EAC1B,MAAc;QAEd,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEnB,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAE3C,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAE/D,IAAI,MAAc,CAAC;QACnB,IAAI,OAAO,YAAY,MAAM,EAAE,CAAC;YAC5B,MAAM,GAAG,OAAO,CAAC;QACrB,CAAC;aAAM,IAAI,OAAO,YAAY,UAAU,EAAE,CAAC;YACvC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACJ,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;QAED,QAAQ;aACH,MAAM,CAAC,MAAM,CAAC;aACd,SAAS,CAAC,cAAc,EAAE,QAAQ,CAAC,KAAK,CAAC;aACzC,SAAS,CAAC,qBAAqB,EAAE,uBAAuB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;aACvF,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;CACJ;AAxDD,wCAwDC"}
@@ -0,0 +1,9 @@
1
+ export declare class Mimetype {
2
+ value: string;
3
+ constructor(value: string);
4
+ static png(): Mimetype;
5
+ static jpeg(): Mimetype;
6
+ static json(): Mimetype;
7
+ static pdf(): Mimetype;
8
+ }
9
+ //# sourceMappingURL=Mimetype.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mimetype.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/Mimetype.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACS,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;WAEzB,GAAG,IAAI,QAAQ;WAIf,IAAI,IAAI,QAAQ;WAIhB,IAAI,IAAI,QAAQ;WAIhB,GAAG,IAAI,QAAQ;CAGhC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Mimetype = void 0;
4
+ class Mimetype {
5
+ constructor(value) {
6
+ this.value = value;
7
+ }
8
+ static png() {
9
+ return new Mimetype("image/png");
10
+ }
11
+ static jpeg() {
12
+ return new Mimetype("image/png");
13
+ }
14
+ static json() {
15
+ return new Mimetype("application/json");
16
+ }
17
+ static pdf() {
18
+ return new Mimetype("application/pdf");
19
+ }
20
+ }
21
+ exports.Mimetype = Mimetype;
22
+ //# sourceMappingURL=Mimetype.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mimetype.js","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/Mimetype.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAQ;IACjB,YAA0B,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAEpC,MAAM,CAAC,GAAG;QACb,OAAO,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;IAEM,MAAM,CAAC,IAAI;QACd,OAAO,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;IAEM,MAAM,CAAC,IAAI;QACd,OAAO,IAAI,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC5C,CAAC;IAEM,MAAM,CAAC,GAAG;QACb,OAAO,IAAI,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC3C,CAAC;CACJ;AAlBD,4BAkBC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./Envelope";
2
2
  export * from "./HttpError";
3
3
  export * from "./HttpErrors";
4
+ export * from "./Mimetype";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Envelope"), exports);
18
18
  __exportStar(require("./HttpError"), exports);
19
19
  __exportStar(require("./HttpErrors"), exports);
20
+ __exportStar(require("./Mimetype"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/httpServer/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,6CAA2B"}
@@ -1,3 +1,4 @@
1
+ export * from "./BaseController";
1
2
  export * from "./common";
2
3
  export * from "./HttpMethod";
3
4
  export * from "./IHttpServer";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./BaseController"), exports);
17
18
  __exportStar(require("./common"), exports);
18
19
  __exportStar(require("./HttpMethod"), exports);
19
20
  __exportStar(require("./IHttpServer"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B;AAC7B,gDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/httpServer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,2CAAyB;AACzB,+CAA6B;AAC7B,gDAA8B"}
package/package.json CHANGED
@@ -24,9 +24,6 @@
24
24
  "build:ci": "tsc",
25
25
  "build:watch": "tsc --watch"
26
26
  },
27
- "peerDependencies": {
28
- "@nmshd/runtime": "^6.33.0"
29
- },
30
27
  "devDependencies": {
31
28
  "@js-soft/logging-abstractions": "^1.0.1",
32
29
  "@types/express": "^5.0.1",
@@ -34,9 +31,15 @@
34
31
  "@types/node": "^22.13.13",
35
32
  "typescript": "^5.8.2"
36
33
  },
34
+ "peerDependencies": {
35
+ "@js-soft/ts-utils": "^2.3.3",
36
+ "@nmshd/runtime": "^6.33.0",
37
+ "@nmshd/typescript-rest": "^3.1.1",
38
+ "express": "^4.21.2"
39
+ },
37
40
  "publishConfig": {
38
41
  "access": "public",
39
42
  "provenance": true
40
43
  },
41
- "version": "6.17.1"
44
+ "version": "6.17.2"
42
45
  }