@nmshd/connector-types 6.17.0 → 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.
- package/README.md +3 -3
- package/dist/infrastructure/httpServer/BaseController.d.ts +14 -0
- package/dist/infrastructure/httpServer/BaseController.d.ts.map +1 -0
- package/dist/infrastructure/httpServer/BaseController.js +51 -0
- package/dist/infrastructure/httpServer/BaseController.js.map +1 -0
- package/dist/infrastructure/httpServer/common/Mimetype.d.ts +9 -0
- package/dist/infrastructure/httpServer/common/Mimetype.d.ts.map +1 -0
- package/dist/infrastructure/httpServer/common/Mimetype.js +22 -0
- package/dist/infrastructure/httpServer/common/Mimetype.js.map +1 -0
- package/dist/infrastructure/httpServer/common/index.d.ts +1 -0
- package/dist/infrastructure/httpServer/common/index.d.ts.map +1 -1
- package/dist/infrastructure/httpServer/common/index.js +1 -0
- package/dist/infrastructure/httpServer/common/index.js.map +1 -1
- package/dist/infrastructure/httpServer/index.d.ts +1 -0
- package/dist/infrastructure/httpServer/index.d.ts.map +1 -1
- package/dist/infrastructure/httpServer/index.js +1 -0
- package/dist/infrastructure/httpServer/index.js.map +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
>
|
|
7
7
|
> This package is still in development and should not be used yet.
|
|
8
8
|
|
|
9
|
-
This package provides TypeScript types for writing
|
|
9
|
+
This package provides TypeScript types for writing Connector modules.
|
|
10
10
|
|
|
11
11
|
## Documentation
|
|
12
12
|
|
|
@@ -18,11 +18,11 @@ To get started developing in this repository, see the [developer's guide](README
|
|
|
18
18
|
|
|
19
19
|
Please file any bugs or feature requests by creating an [issue](https://github.com/nmshd/feedback/issues).
|
|
20
20
|
|
|
21
|
-
Share your feedback with the
|
|
21
|
+
Share your feedback with the enmeshed team by contributing to the [discussions](https://github.com/nmshd/feedback/discussions).
|
|
22
22
|
|
|
23
23
|
## Contribute
|
|
24
24
|
|
|
25
|
-
Contribution to this project is highly
|
|
25
|
+
Contribution to this project is highly appreciated. Head over to our [contribution guide](https://github.com/nmshd/.github/blob/main/CONTRIBUTING.md) to learn more.
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
@@ -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,m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["../../../../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 +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 +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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nmshd/connector-types",
|
|
3
|
-
"description": "the enmeshed
|
|
3
|
+
"description": "the enmeshed Connector types",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"enmeshed",
|
|
6
6
|
"connector"
|
|
@@ -24,19 +24,22 @@
|
|
|
24
24
|
"build:ci": "tsc",
|
|
25
25
|
"build:watch": "tsc --watch"
|
|
26
26
|
},
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"@nmshd/runtime": "^6.32.0"
|
|
29
|
-
},
|
|
30
27
|
"devDependencies": {
|
|
31
28
|
"@js-soft/logging-abstractions": "^1.0.1",
|
|
32
29
|
"@types/express": "^5.0.1",
|
|
33
30
|
"@types/luxon": "^3.4.2",
|
|
34
|
-
"@types/node": "^22.13.
|
|
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.
|
|
44
|
+
"version": "6.17.2"
|
|
42
45
|
}
|