@things-factory/attachment-base 5.0.7 → 6.0.0-alpha.0
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/dist-server/attachment-const.js +2 -1
- package/dist-server/attachment-const.js.map +1 -1
- package/dist-server/awb-storage-s3.js +42 -0
- package/dist-server/awb-storage-s3.js.map +1 -0
- package/dist-server/index.js +6 -18
- package/dist-server/index.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/attachment/attachment-mutation.js +63 -75
- package/dist-server/service/attachment/attachment-mutation.js.map +1 -1
- package/dist-server/service/attachment/attachment-query.js +36 -48
- package/dist-server/service/attachment/attachment-query.js.map +1 -1
- package/dist-server/service/attachment/attachment-types.js +40 -52
- package/dist-server/service/attachment/attachment-types.js.map +1 -1
- package/dist-server/service/attachment/attachment.js +41 -50
- package/dist-server/service/attachment/attachment.js.map +1 -1
- package/dist-server/service/attachment/index.js.map +1 -1
- package/dist-server/service/index.js +3 -16
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/storage-file.js +3 -25
- package/dist-server/storage-file.js.map +1 -1
- package/dist-server/storage-s3.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/dist-server/util/index.js +5 -0
- package/dist-server/util/index.js.map +1 -0
- package/dist-server/util/upload-awb.js +12 -0
- package/dist-server/util/upload-awb.js.map +1 -0
- package/package.json +5 -5
- package/server/attachment-const.ts +1 -0
- package/server/awb-storage-s3.ts +44 -0
- package/server/index.ts +1 -0
- package/server/service/attachment/attachment-mutation.ts +25 -19
- package/server/service/attachment/attachment-query.ts +9 -8
- package/server/service/attachment/attachment-types.ts +1 -1
- package/server/service/attachment/attachment.ts +2 -2
- package/server/util/index.ts +1 -0
- package/server/util/upload-awb.ts +11 -0
|
@@ -1,112 +1,100 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
var _a;
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.AttachmentPatch = exports.NewAttachment = exports.UploadURL = exports.AttachmentList = void 0;
|
|
17
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
18
6
|
const type_graphql_1 = require("type-graphql");
|
|
19
7
|
const shell_1 = require("@things-factory/shell");
|
|
20
8
|
const attachment_1 = require("./attachment");
|
|
21
9
|
let AttachmentList = class AttachmentList {
|
|
22
10
|
};
|
|
23
|
-
__decorate([
|
|
11
|
+
tslib_1.__decorate([
|
|
24
12
|
(0, type_graphql_1.Field)(type => [attachment_1.Attachment]),
|
|
25
|
-
__metadata("design:type", Array)
|
|
13
|
+
tslib_1.__metadata("design:type", Array)
|
|
26
14
|
], AttachmentList.prototype, "items", void 0);
|
|
27
|
-
__decorate([
|
|
15
|
+
tslib_1.__decorate([
|
|
28
16
|
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
29
|
-
__metadata("design:type", Number)
|
|
17
|
+
tslib_1.__metadata("design:type", Number)
|
|
30
18
|
], AttachmentList.prototype, "total", void 0);
|
|
31
|
-
AttachmentList = __decorate([
|
|
19
|
+
AttachmentList = tslib_1.__decorate([
|
|
32
20
|
(0, type_graphql_1.ObjectType)()
|
|
33
21
|
], AttachmentList);
|
|
34
22
|
exports.AttachmentList = AttachmentList;
|
|
35
23
|
let UploadURL = class UploadURL {
|
|
36
24
|
};
|
|
37
|
-
__decorate([
|
|
25
|
+
tslib_1.__decorate([
|
|
38
26
|
(0, type_graphql_1.Field)(type => String),
|
|
39
|
-
__metadata("design:type", String)
|
|
27
|
+
tslib_1.__metadata("design:type", String)
|
|
40
28
|
], UploadURL.prototype, "url", void 0);
|
|
41
|
-
__decorate([
|
|
29
|
+
tslib_1.__decorate([
|
|
42
30
|
(0, type_graphql_1.Field)(type => shell_1.ScalarAny),
|
|
43
|
-
__metadata("design:type",
|
|
31
|
+
tslib_1.__metadata("design:type", Object)
|
|
44
32
|
], UploadURL.prototype, "fields", void 0);
|
|
45
|
-
UploadURL = __decorate([
|
|
33
|
+
UploadURL = tslib_1.__decorate([
|
|
46
34
|
(0, type_graphql_1.ObjectType)()
|
|
47
35
|
], UploadURL);
|
|
48
36
|
exports.UploadURL = UploadURL;
|
|
49
37
|
let NewAttachment = class NewAttachment {
|
|
50
38
|
};
|
|
51
|
-
__decorate([
|
|
39
|
+
tslib_1.__decorate([
|
|
52
40
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
53
|
-
__metadata("design:type", String)
|
|
41
|
+
tslib_1.__metadata("design:type", String)
|
|
54
42
|
], NewAttachment.prototype, "category", void 0);
|
|
55
|
-
__decorate([
|
|
43
|
+
tslib_1.__decorate([
|
|
56
44
|
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default),
|
|
57
|
-
__metadata("design:type", Object)
|
|
45
|
+
tslib_1.__metadata("design:type", Object)
|
|
58
46
|
], NewAttachment.prototype, "file", void 0);
|
|
59
|
-
__decorate([
|
|
47
|
+
tslib_1.__decorate([
|
|
60
48
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
61
|
-
__metadata("design:type", String)
|
|
49
|
+
tslib_1.__metadata("design:type", String)
|
|
62
50
|
], NewAttachment.prototype, "description", void 0);
|
|
63
|
-
__decorate([
|
|
51
|
+
tslib_1.__decorate([
|
|
64
52
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
65
|
-
__metadata("design:type", String)
|
|
53
|
+
tslib_1.__metadata("design:type", String)
|
|
66
54
|
], NewAttachment.prototype, "refType", void 0);
|
|
67
|
-
__decorate([
|
|
55
|
+
tslib_1.__decorate([
|
|
68
56
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
69
|
-
__metadata("design:type", String)
|
|
57
|
+
tslib_1.__metadata("design:type", String)
|
|
70
58
|
], NewAttachment.prototype, "refBy", void 0);
|
|
71
|
-
NewAttachment = __decorate([
|
|
59
|
+
NewAttachment = tslib_1.__decorate([
|
|
72
60
|
(0, type_graphql_1.InputType)()
|
|
73
61
|
], NewAttachment);
|
|
74
62
|
exports.NewAttachment = NewAttachment;
|
|
75
63
|
let AttachmentPatch = class AttachmentPatch {
|
|
76
64
|
};
|
|
77
|
-
__decorate([
|
|
65
|
+
tslib_1.__decorate([
|
|
78
66
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
79
|
-
__metadata("design:type", String)
|
|
67
|
+
tslib_1.__metadata("design:type", String)
|
|
80
68
|
], AttachmentPatch.prototype, "name", void 0);
|
|
81
|
-
__decorate([
|
|
69
|
+
tslib_1.__decorate([
|
|
82
70
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
83
|
-
__metadata("design:type", String)
|
|
71
|
+
tslib_1.__metadata("design:type", String)
|
|
84
72
|
], AttachmentPatch.prototype, "description", void 0);
|
|
85
|
-
__decorate([
|
|
73
|
+
tslib_1.__decorate([
|
|
86
74
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
87
|
-
__metadata("design:type", String)
|
|
75
|
+
tslib_1.__metadata("design:type", String)
|
|
88
76
|
], AttachmentPatch.prototype, "mimetype", void 0);
|
|
89
|
-
__decorate([
|
|
77
|
+
tslib_1.__decorate([
|
|
90
78
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
91
|
-
__metadata("design:type", String)
|
|
79
|
+
tslib_1.__metadata("design:type", String)
|
|
92
80
|
], AttachmentPatch.prototype, "encoding", void 0);
|
|
93
|
-
__decorate([
|
|
81
|
+
tslib_1.__decorate([
|
|
94
82
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
95
|
-
__metadata("design:type", String)
|
|
83
|
+
tslib_1.__metadata("design:type", String)
|
|
96
84
|
], AttachmentPatch.prototype, "category", void 0);
|
|
97
|
-
__decorate([
|
|
85
|
+
tslib_1.__decorate([
|
|
98
86
|
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
|
|
99
|
-
__metadata("design:type", Object)
|
|
87
|
+
tslib_1.__metadata("design:type", Object)
|
|
100
88
|
], AttachmentPatch.prototype, "file", void 0);
|
|
101
|
-
__decorate([
|
|
89
|
+
tslib_1.__decorate([
|
|
102
90
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
103
|
-
__metadata("design:type", String)
|
|
91
|
+
tslib_1.__metadata("design:type", String)
|
|
104
92
|
], AttachmentPatch.prototype, "refType", void 0);
|
|
105
|
-
__decorate([
|
|
93
|
+
tslib_1.__decorate([
|
|
106
94
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
107
|
-
__metadata("design:type", String)
|
|
95
|
+
tslib_1.__metadata("design:type", String)
|
|
108
96
|
], AttachmentPatch.prototype, "refBy", void 0);
|
|
109
|
-
AttachmentPatch = __decorate([
|
|
97
|
+
AttachmentPatch = tslib_1.__decorate([
|
|
110
98
|
(0, type_graphql_1.InputType)()
|
|
111
99
|
], AttachmentPatch);
|
|
112
100
|
exports.AttachmentPatch = AttachmentPatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-types.js","sourceRoot":"","sources":["../../../server/service/attachment/attachment-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attachment-types.js","sourceRoot":"","sources":["../../../server/service/attachment/attachment-types.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAgE;AAEhE,iDAAiD;AAEjD,6CAAyC;AAGzC,IAAa,cAAc,GAA3B,MAAa,cAAc;CAM1B,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,uBAAU,CAAC,CAAC;;6CACT;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;6CACN;AALF,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAM1B;AANY,wCAAc;AAS3B,IAAa,SAAS,GAAtB,MAAa,SAAS;CAMrB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;;sCACX;AAGX;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,CAAC;;yCACd;AALA,SAAS;IADrB,IAAA,yBAAU,GAAE;GACA,SAAS,CAMrB;AANY,8BAAS;AAStB,IAAa,aAAa,GAA1B,MAAa,aAAa;CAezB,CAAA;AAbC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACV;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,0BAAa,CAAC;;2CACb;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACP;AAGnB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACX;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACb;AAdF,aAAa;IADzB,IAAA,wBAAS,GAAE;GACC,aAAa,CAezB;AAfY,sCAAa;AAkB1B,IAAa,eAAe,GAA5B,MAAa,eAAe;CAwB3B,CAAA;AAtBC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACd;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACP;AAGnB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACV;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,0BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACjC;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACX;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACb;AAvBF,eAAe;IAD3B,IAAA,wBAAS,GAAE;GACC,eAAe,CAwB3B;AAxBY,0CAAe","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { Field, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { ScalarAny } from '@things-factory/shell'\n\nimport { Attachment } from './attachment'\n\n@ObjectType()\nexport class AttachmentList {\n @Field(type => [Attachment])\n items: Attachment[]\n\n @Field(type => Int)\n total: number\n}\n\n@ObjectType()\nexport class UploadURL {\n @Field(type => String)\n url: string\n\n @Field(type => ScalarAny)\n fields: any\n}\n\n@InputType()\nexport class NewAttachment {\n @Field({ nullable: true })\n category: string\n\n @Field(type => GraphQLUpload)\n file: FileUpload\n\n @Field({ nullable: true })\n description: string\n\n @Field({ nullable: true })\n refType: string\n\n @Field({ nullable: true })\n refBy: string\n}\n\n@InputType()\nexport class AttachmentPatch {\n @Field({ nullable: true })\n name: string\n\n @Field({ nullable: true })\n description: string\n\n @Field({ nullable: true })\n mimetype: string\n\n @Field({ nullable: true })\n encoding: string\n\n @Field({ nullable: true })\n category: string\n\n @Field(type => GraphQLUpload, { nullable: true })\n file: FileUpload\n\n @Field({ nullable: true })\n refType: string\n\n @Field({ nullable: true })\n refBy: string\n}\n"]}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var _a, _b, _c;
|
|
12
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
3
|
exports.Attachment = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
14
5
|
const type_graphql_1 = require("type-graphql");
|
|
15
6
|
const typeorm_1 = require("typeorm");
|
|
16
7
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
@@ -24,99 +15,99 @@ let Attachment = class Attachment {
|
|
|
24
15
|
return `/${attachment_const_1.ATTACHMENT_PATH}/${this.path}`;
|
|
25
16
|
}
|
|
26
17
|
};
|
|
27
|
-
__decorate([
|
|
18
|
+
tslib_1.__decorate([
|
|
28
19
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
29
20
|
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
30
|
-
__metadata("design:type", String)
|
|
21
|
+
tslib_1.__metadata("design:type", String)
|
|
31
22
|
], Attachment.prototype, "id", void 0);
|
|
32
|
-
__decorate([
|
|
23
|
+
tslib_1.__decorate([
|
|
33
24
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain, { nullable: false }),
|
|
34
25
|
(0, type_graphql_1.Field)(type => shell_1.Domain),
|
|
35
|
-
__metadata("design:type",
|
|
26
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
36
27
|
], Attachment.prototype, "domain", void 0);
|
|
37
|
-
__decorate([
|
|
28
|
+
tslib_1.__decorate([
|
|
38
29
|
(0, typeorm_1.RelationId)((attachment) => attachment.domain),
|
|
39
|
-
__metadata("design:type", String)
|
|
30
|
+
tslib_1.__metadata("design:type", String)
|
|
40
31
|
], Attachment.prototype, "domainId", void 0);
|
|
41
|
-
__decorate([
|
|
32
|
+
tslib_1.__decorate([
|
|
42
33
|
(0, typeorm_1.Column)(),
|
|
43
34
|
(0, type_graphql_1.Field)(),
|
|
44
|
-
__metadata("design:type", String)
|
|
35
|
+
tslib_1.__metadata("design:type", String)
|
|
45
36
|
], Attachment.prototype, "name", void 0);
|
|
46
|
-
__decorate([
|
|
37
|
+
tslib_1.__decorate([
|
|
47
38
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
48
39
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
49
|
-
__metadata("design:type", String)
|
|
40
|
+
tslib_1.__metadata("design:type", String)
|
|
50
41
|
], Attachment.prototype, "description", void 0);
|
|
51
|
-
__decorate([
|
|
42
|
+
tslib_1.__decorate([
|
|
52
43
|
(0, typeorm_1.Column)(),
|
|
53
44
|
(0, type_graphql_1.Field)(),
|
|
54
|
-
__metadata("design:type", String)
|
|
45
|
+
tslib_1.__metadata("design:type", String)
|
|
55
46
|
], Attachment.prototype, "mimetype", void 0);
|
|
56
|
-
__decorate([
|
|
47
|
+
tslib_1.__decorate([
|
|
57
48
|
(0, typeorm_1.Column)(),
|
|
58
49
|
(0, type_graphql_1.Field)(),
|
|
59
|
-
__metadata("design:type", String)
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
60
51
|
], Attachment.prototype, "encoding", void 0);
|
|
61
|
-
__decorate([
|
|
52
|
+
tslib_1.__decorate([
|
|
62
53
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
63
54
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
64
|
-
__metadata("design:type", String)
|
|
55
|
+
tslib_1.__metadata("design:type", String)
|
|
65
56
|
], Attachment.prototype, "category", void 0);
|
|
66
|
-
__decorate([
|
|
57
|
+
tslib_1.__decorate([
|
|
67
58
|
(0, typeorm_1.Column)({ nullable: true, default: '' }),
|
|
68
59
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
69
|
-
__metadata("design:type", String)
|
|
60
|
+
tslib_1.__metadata("design:type", String)
|
|
70
61
|
], Attachment.prototype, "refType", void 0);
|
|
71
|
-
__decorate([
|
|
62
|
+
tslib_1.__decorate([
|
|
72
63
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
73
64
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
74
|
-
__metadata("design:type", String)
|
|
65
|
+
tslib_1.__metadata("design:type", String)
|
|
75
66
|
], Attachment.prototype, "refBy", void 0);
|
|
76
|
-
__decorate([
|
|
67
|
+
tslib_1.__decorate([
|
|
77
68
|
(0, typeorm_1.Column)(),
|
|
78
69
|
(0, type_graphql_1.Field)(),
|
|
79
|
-
__metadata("design:type", String)
|
|
70
|
+
tslib_1.__metadata("design:type", String)
|
|
80
71
|
], Attachment.prototype, "path", void 0);
|
|
81
|
-
__decorate([
|
|
72
|
+
tslib_1.__decorate([
|
|
82
73
|
(0, typeorm_1.Column)(),
|
|
83
74
|
(0, type_graphql_1.Field)(),
|
|
84
|
-
__metadata("design:type", String)
|
|
75
|
+
tslib_1.__metadata("design:type", String)
|
|
85
76
|
], Attachment.prototype, "size", void 0);
|
|
86
|
-
__decorate([
|
|
77
|
+
tslib_1.__decorate([
|
|
87
78
|
(0, typeorm_1.CreateDateColumn)(),
|
|
88
79
|
(0, type_graphql_1.Field)(),
|
|
89
|
-
__metadata("design:type", Date)
|
|
80
|
+
tslib_1.__metadata("design:type", Date)
|
|
90
81
|
], Attachment.prototype, "createdAt", void 0);
|
|
91
|
-
__decorate([
|
|
82
|
+
tslib_1.__decorate([
|
|
92
83
|
(0, typeorm_1.UpdateDateColumn)(),
|
|
93
84
|
(0, type_graphql_1.Field)(),
|
|
94
|
-
__metadata("design:type", Date)
|
|
85
|
+
tslib_1.__metadata("design:type", Date)
|
|
95
86
|
], Attachment.prototype, "updatedAt", void 0);
|
|
96
|
-
__decorate([
|
|
87
|
+
tslib_1.__decorate([
|
|
97
88
|
(0, typeorm_1.ManyToOne)(type => auth_base_1.User),
|
|
98
89
|
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
99
|
-
__metadata("design:type",
|
|
90
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
100
91
|
], Attachment.prototype, "creator", void 0);
|
|
101
|
-
__decorate([
|
|
92
|
+
tslib_1.__decorate([
|
|
102
93
|
(0, typeorm_1.RelationId)((attachment) => attachment.creator),
|
|
103
|
-
__metadata("design:type", String)
|
|
94
|
+
tslib_1.__metadata("design:type", String)
|
|
104
95
|
], Attachment.prototype, "creatorId", void 0);
|
|
105
|
-
__decorate([
|
|
96
|
+
tslib_1.__decorate([
|
|
106
97
|
(0, typeorm_1.ManyToOne)(type => auth_base_1.User),
|
|
107
98
|
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
108
|
-
__metadata("design:type",
|
|
99
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
109
100
|
], Attachment.prototype, "updater", void 0);
|
|
110
|
-
__decorate([
|
|
101
|
+
tslib_1.__decorate([
|
|
111
102
|
(0, typeorm_1.RelationId)((attachment) => attachment.updater),
|
|
112
|
-
__metadata("design:type", String)
|
|
103
|
+
tslib_1.__metadata("design:type", String)
|
|
113
104
|
], Attachment.prototype, "updaterId", void 0);
|
|
114
|
-
__decorate([
|
|
105
|
+
tslib_1.__decorate([
|
|
115
106
|
(0, type_graphql_1.Field)(),
|
|
116
|
-
__metadata("design:type", String),
|
|
117
|
-
__metadata("design:paramtypes", [])
|
|
107
|
+
tslib_1.__metadata("design:type", String),
|
|
108
|
+
tslib_1.__metadata("design:paramtypes", [])
|
|
118
109
|
], Attachment.prototype, "fullpath", null);
|
|
119
|
-
Attachment = __decorate([
|
|
110
|
+
Attachment = tslib_1.__decorate([
|
|
120
111
|
(0, typeorm_1.Entity)(),
|
|
121
112
|
(0, typeorm_1.Index)('ix_attachment_0', (attachment) => [attachment.domain, attachment.name], { unique: false }),
|
|
122
113
|
(0, typeorm_1.Index)('ix_attachment_1', (attachment) => [attachment.domain, attachment.category, attachment.name], {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../../server/service/attachment/attachment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../../server/service/attachment/attachment.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAE9C,6DAAwD;AAcxD,IAAa,UAAU,GAAvB,MAAa,UAAU;IAAvB;QAkCE,YAAO,GAAW,EAAE,CAAA;IAwCtB,CAAC;IAHC,IAAI,QAAQ;QACV,OAAO,IAAI,kCAAe,IAAI,IAAI,CAAC,IAAI,EAAE,CAAA;IAC3C,CAAC;CACF,CAAA;AAvEC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,C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UAAU,CAAC,KAAK,CAAC,EAAE;QAC3F,MAAM,EAAE,KAAK;KACd,CAAC;IACD,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE;QAC/G,MAAM,EAAE,KAAK;KACd,CAAC;IACD,IAAA,yBAAU,GAAE;GACA,UAAU,CA0EtB;AA1EY,gCAAU","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\nimport { ATTACHMENT_PATH } from '../../attachment-const'\n\n@Entity()\n@Index('ix_attachment_0', (attachment: Attachment) => [attachment.domain, attachment.name], { unique: false })\n@Index('ix_attachment_1', (attachment: Attachment) => [attachment.domain, attachment.category, attachment.name], {\n unique: false\n})\n@Index('ix_attachment_2', (attachment: Attachment) => [attachment.domain, attachment.refBy], {\n unique: false\n})\n@Index('ix_attachment_3', (attachment: Attachment) => [attachment.domain, attachment.refType, attachment.refBy], {\n unique: false\n})\n@ObjectType()\nexport class Attachment {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain, { nullable: false })\n @Field(type => Domain)\n domain: Domain\n\n @RelationId((attachment: Attachment) => attachment.domain)\n domainId: string\n\n @Column()\n @Field()\n name: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description: string\n\n @Column()\n @Field()\n mimetype: string\n\n @Column()\n @Field()\n encoding: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n category: string\n\n @Column({ nullable: true, default: '' })\n @Field({ nullable: true })\n refType: string = ''\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n refBy: string\n\n @Column()\n @Field()\n path: string\n\n @Column()\n @Field()\n size: string\n\n @CreateDateColumn()\n @Field()\n createdAt: Date\n\n @UpdateDateColumn()\n @Field()\n updatedAt: Date\n\n @ManyToOne(type => User)\n @Field(type => User, { nullable: true })\n creator: User\n\n @RelationId((attachment: Attachment) => attachment.creator)\n creatorId: string\n\n @ManyToOne(type => User)\n @Field(type => User, { nullable: true })\n updater: User\n\n @RelationId((attachment: Attachment) => attachment.updater)\n updaterId: string\n\n @Field()\n get fullpath(): string {\n return `/${ATTACHMENT_PATH}/${this.path}`\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/attachment/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,+DAA0D;AAC1D,yDAAoD;AAEvC,QAAA,QAAQ,GAAG,CAAC,uBAAU,CAAC,CAAA;AACvB,QAAA,SAAS,GAAG,CAAC,kCAAe,EAAE,wCAAkB,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/attachment/index.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,+DAA0D;AAC1D,yDAAoD;AAEvC,QAAA,QAAQ,GAAG,CAAC,uBAAU,CAAC,CAAA;AACvB,QAAA,SAAS,GAAG,CAAC,kCAAe,EAAE,wCAAkB,CAAC,CAAA","sourcesContent":["import { Attachment } from './attachment'\nimport { AttachmentMutation } from './attachment-mutation'\nimport { AttachmentQuery } from './attachment-query'\n\nexport const entities = [Attachment]\nexport const resolvers = [AttachmentQuery, AttachmentMutation]\n"]}
|
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
3
|
exports.schema = exports.entities = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
18
5
|
/* IMPORT ENTITIES AND RESOLVERS */
|
|
19
6
|
const attachment_1 = require("./attachment");
|
|
20
7
|
/* EXPORT ENTITY TYPES */
|
|
21
|
-
__exportStar(require("./attachment/attachment"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./attachment/attachment"), exports);
|
|
22
9
|
/* EXPORT TYPES */
|
|
23
|
-
__exportStar(require("./attachment/attachment-types"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./attachment/attachment-types"), exports);
|
|
24
11
|
exports.entities = [
|
|
25
12
|
/* ENTITIES */
|
|
26
13
|
...attachment_1.entities
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,mCAAmC;AACnC,6CAA6F;AAE7F,yBAAyB;AACzB,kEAAuC;AACvC,kBAAkB;AAClB,wEAA6C;AAEhC,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,qBAAgB;CACpB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,sBAAmB;KACvB;CACF,CAAA","sourcesContent":["/* IMPORT ENTITIES AND RESOLVERS */\nimport { entities as AttachmentEntity, resolvers as AttachmentResolvers } from './attachment'\n\n/* EXPORT ENTITY TYPES */\nexport * from './attachment/attachment'\n/* EXPORT TYPES */\nexport * from './attachment/attachment-types'\n\nexport const entities = [\n /* ENTITIES */\n ...AttachmentEntity\n]\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...AttachmentResolvers\n ]\n}\n"]}
|
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const
|
|
27
|
-
const
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
5
|
+
const mkdirp = tslib_1.__importStar(require("mkdirp"));
|
|
28
6
|
const path_1 = require("path");
|
|
29
7
|
const env_1 = require("@things-factory/env");
|
|
30
8
|
const attachment_const_1 = require("./attachment-const");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-file.js","sourceRoot":"","sources":["../server/storage-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage-file.js","sourceRoot":"","sources":["../server/storage-file.ts"],"names":[],"mappings":";;;AAAA,+CAAwB;AACxB,uDAAgC;AAChC,+BAA8B;AAE9B,6CAAoD;AAEpD,yDAA6D;AAE7D,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAChC,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAEhC,IAAI,0BAAO,IAAI,0BAAO,CAAC,IAAI,IAAI,MAAM,EAAE;IACrC,MAAM,SAAS,GAAG,YAAM,CAAC,OAAO,CAAC,IAAI,EAAE,0BAAO,CAAC,IAAI,IAAI,aAAa,CAAC,CAAA;IAErE,0BAAO,CAAC,UAAU,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC5C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAEtB,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,CAAA;QAC9B,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAA;QACrC,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,SAAS,EAAE,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,SAAS,EAAE,EAAE,CAAC,CAAA;QAC9E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,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AC,QAAQ,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE;QAC1C,MAAM,QAAQ,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,UAAU,CAAC,CAAA;QAE/C,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAC5C,CAAC,CAAA;IAED,0BAAO,CAAC,iBAAiB,GAAG,KAAK,EAAE,IAAY,EAA+D,EAAE;QAC9G,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,CAAA;QAE9B,OAAO,MAAM;YACX,GAAG,EAAE,IAAI,kCAAe,EAAE;YAC1B,MAAM,EAAE,EAAE;SACX,CAAA;IACH,CAAC,CAAA;IAED,YAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAA;CACtC","sourcesContent":["import * as fs from 'fs'\nimport * as mkdirp from 'mkdirp'\nimport { resolve } from 'path'\n\nimport { config, logger } from '@things-factory/env'\n\nimport { ATTACHMENT_PATH, STORAGE } from './attachment-const'\n\nconst crypto = require('crypto')\nconst send = require('koa-send')\n\nif (STORAGE && STORAGE.type == 'file') {\n const uploadDir = config.getPath(null, STORAGE.base || 'attachments')\n\n STORAGE.uploadFile = ({ stream, filename }) => {\n mkdirp.sync(uploadDir)\n\n const id = crypto.randomUUID()\n const ext = filename.split('.').pop()\n const path = ext ? resolve(uploadDir, `${id}.${ext}`) : resolve(uploadDir, id)\n const relativePath = path.split('\\\\').pop().split('/').pop()\n var size: number = 0\n\n return new Promise<{ id: string; path: string; size: number }>((resolve, reject) =>\n stream\n .on('error', error => {\n if (stream.truncated)\n // Delete the truncated file\n fs.unlinkSync(path)\n reject(error)\n })\n .pipe(fs.createWriteStream(path))\n .on('error', error => reject(error))\n .on('data', chunk => (size += chunk.length))\n .on('finish', () => resolve({ id, path: relativePath, size }))\n )\n }\n\n STORAGE.deleteFile = async path => {\n const fullpath = resolve(uploadDir, path)\n\n await fs.unlink(fullpath, logger.error)\n }\n\n STORAGE.sendFile = async (context, attachment, next) => {\n await send(context, attachment, { root: uploadDir })\n }\n\n STORAGE.readFile = (attachment, encoding) => {\n const fullpath = resolve(uploadDir, attachment)\n\n return fs.readFileSync(fullpath, encoding)\n }\n\n STORAGE.generateUploadURL = async (type: string): Promise<{ url: string; fields: { [key: string]: string } }> => {\n const id = crypto.randomUUID()\n\n return await {\n url: `/${ATTACHMENT_PATH}`,\n fields: {}\n }\n }\n\n logger.info('File Storage is Ready.')\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-s3.js","sourceRoot":"","sources":["../server/storage-s3.ts"],"names":[],"mappings":";;AAEA,kDAA2G;AAC3G,sDAA6C;AAC7C,kEAAgE;AAChE,6CAA4C;AAE5C,yDAA4C;AAE5C,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAChC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAE/B,IAAI,0BAAO,IAAI,0BAAO,CAAC,IAAI,IAAI,IAAI,EAAE;IACnC,MAAM,MAAM,GAAG,IAAI,oBAAQ,CAAC;QAC1B,WAAW,EAAE;YACX,WAAW,EAAE,0BAAO,CAAC,WAAW;YAChC,eAAe,EAAE,0BAAO,CAAC,eAAe;SACzC;QACD,MAAM,EAAE,0BAAO,CAAC,MAAM;KACvB,CAAC,CAAA;IAEF,MAAM,cAAc,GAAG,CAAC,MAAgB,EAAE,EAAE,CAC1C,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QAC9C,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,C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M,EAAE;YACvC,MAAM,EAAE,0BAAO,CAAC,UAAU;YAC1B,GAAG,EAAE,EAAE;YACP,OAAO,EAAE,gBAAgB,GAAG,EAAE;YAC9B,UAAU,EAAE,CAAC,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,CAAC,CAAC;SAC5C,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,YAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAA;CAC3C","sourcesContent":["import type { Readable } from 'stream'\n\nimport { DeleteObjectCommand, GetObjectCommand, GetObjectCommandInput, S3Client } from '@aws-sdk/client-s3'\nimport { Upload } from '@aws-sdk/lib-storage'\nimport { createPresignedPost } from '@aws-sdk/s3-presigned-post'\nimport { logger } from '@things-factory/env'\n\nimport { STORAGE } from './attachment-const'\n\nconst crypto = require('crypto')\nconst mime = require('mime')\nconst { fs } = require('memfs')\n\nif (STORAGE && STORAGE.type == 's3') {\n const client = new S3Client({\n credentials: {\n accessKeyId: STORAGE.accessKeyId,\n secretAccessKey: STORAGE.secretAccessKey\n },\n region: STORAGE.region\n })\n\n const streamToBuffer = (stream: Readable) =>\n new Promise<Buffer>((resolve, reject) => {\n const chunks: Buffer[] = []\n stream.on('data', chunk => chunks.push(chunk))\n stream.once('end', () => resolve(Buffer.concat(chunks)))\n stream.once('error', reject)\n })\n\n /* upload file */\n STORAGE.uploadFile = async ({ stream, filename }) => {\n const id = crypto.randomUUID()\n const ext = filename.split('.').pop()\n const key = ext ? `${id}.${ext}` : id\n var size: number = 0\n\n const upload = new Upload({\n client,\n params: {\n Bucket: STORAGE.bucketName,\n Key: key,\n Body: stream\n // ContentType: 'text/plain',\n }\n })\n\n const result = (await upload.done()) as any\n return {\n id,\n path: key,\n size\n }\n }\n\n STORAGE.deleteFile = async (path: string) => {\n const command = new DeleteObjectCommand({\n Bucket: STORAGE.bucketName,\n Key: path\n })\n\n return await client.send(command)\n }\n\n /* TODO Streaming to Streaming 으로 구현하라. */\n STORAGE.sendFile = async (context, attachment, next) => {\n const result = await client.send(\n new GetObjectCommand({\n Bucket: STORAGE.bucketName,\n Key: attachment\n } as GetObjectCommandInput)\n )\n\n context.set({\n 'Content-Length': result.ContentLength,\n 'Content-Type': mime.getType(attachment),\n 'Last-Modified': result.LastModified.toUTCString(),\n ETag: result.ETag,\n 'Cache-Control': 'public, max-age=31556926'\n })\n\n context.body = result.Body\n }\n\n STORAGE.readFile = async (attachment: string, encoding: string) => {\n /*\n * refered to\n * https://transang.me/modern-fetch-and-how-to-get-buffer-output-from-aws-sdk-v3-getobjectcommand/#the-body-type\n */\n const result = await client.send(\n new GetObjectCommand({\n Bucket: STORAGE.bucketName,\n Key: attachment\n } as GetObjectCommandInput)\n )\n\n var body = result.Body as Readable\n var buffer = await streamToBuffer(body)\n\n switch (encoding) {\n case 'base64':\n return buffer.toString('base64')\n default:\n return await buffer\n }\n }\n\n STORAGE.generateUploadURL = async (type: string): Promise<{ url: string; fields: { [key: string]: string } }> => {\n const expiresInMinutes = 1\n const id = crypto.randomUUID()\n\n return await createPresignedPost(client, {\n Bucket: STORAGE.bucketName,\n Key: id,\n Expires: expiresInMinutes * 60,\n Conditions: [['eq', '$Content-Type', type]]\n })\n }\n\n logger.info('S3 Bucket Storage is Ready.')\n}\n"]}
|