@things-factory/attachment-base 4.3.582 → 4.3.671

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.
Files changed (38) hide show
  1. package/package.json +4 -4
  2. package/server/storage-s3.ts +2 -1
  3. package/server/util/index.ts +2 -1
  4. package/server/util/upload-storage.ts +11 -0
  5. package/dist-server/attachment-const.js +0 -9
  6. package/dist-server/attachment-const.js.map +0 -1
  7. package/dist-server/awb-storage-s3.js +0 -42
  8. package/dist-server/awb-storage-s3.js.map +0 -1
  9. package/dist-server/index.js +0 -31
  10. package/dist-server/index.js.map +0 -1
  11. package/dist-server/invoice-storage-s3.js +0 -42
  12. package/dist-server/invoice-storage-s3.js.map +0 -1
  13. package/dist-server/migrations/index.js +0 -12
  14. package/dist-server/migrations/index.js.map +0 -1
  15. package/dist-server/routes.js +0 -23
  16. package/dist-server/routes.js.map +0 -1
  17. package/dist-server/service/attachment/attachment-mutation.js +0 -216
  18. package/dist-server/service/attachment/attachment-mutation.js.map +0 -1
  19. package/dist-server/service/attachment/attachment-query.js +0 -57
  20. package/dist-server/service/attachment/attachment-query.js.map +0 -1
  21. package/dist-server/service/attachment/attachment-types.js +0 -102
  22. package/dist-server/service/attachment/attachment-types.js.map +0 -1
  23. package/dist-server/service/attachment/attachment.js +0 -123
  24. package/dist-server/service/attachment/attachment.js.map +0 -1
  25. package/dist-server/service/attachment/index.js +0 -9
  26. package/dist-server/service/attachment/index.js.map +0 -1
  27. package/dist-server/service/index.js +0 -34
  28. package/dist-server/service/index.js.map +0 -1
  29. package/dist-server/storage-file.js +0 -74
  30. package/dist-server/storage-file.js.map +0 -1
  31. package/dist-server/storage-s3.js +0 -99
  32. package/dist-server/storage-s3.js.map +0 -1
  33. package/dist-server/util/index.js +0 -19
  34. package/dist-server/util/index.js.map +0 -1
  35. package/dist-server/util/upload-awb.js +0 -12
  36. package/dist-server/util/upload-awb.js.map +0 -1
  37. package/dist-server/util/upload-invoice.js +0 -12
  38. package/dist-server/util/upload-invoice.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/attachment-base",
3
- "version": "4.3.582",
3
+ "version": "4.3.671",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -27,11 +27,11 @@
27
27
  "@aws-sdk/lib-storage": "^3.46.0",
28
28
  "@aws-sdk/s3-presigned-post": "^3.46.0",
29
29
  "@koa/multer": "^3.0.0",
30
- "@things-factory/auth-base": "^4.3.582",
31
- "@things-factory/env": "^4.3.534",
30
+ "@things-factory/auth-base": "^4.3.671",
31
+ "@things-factory/env": "^4.3.591",
32
32
  "memfs": "^3.0.1",
33
33
  "mime": "^2.4.4",
34
34
  "multer": "^1.3.0"
35
35
  },
36
- "gitHead": "00d138f3862bca8dd019dc457eaff707d38b6b60"
36
+ "gitHead": "ef524cb207378186ec71917d9a8546363d4300b2"
37
37
  }
@@ -49,7 +49,8 @@ if (STORAGE && STORAGE.type == 's3') {
49
49
  return {
50
50
  id,
51
51
  path: key,
52
- size
52
+ size,
53
+ awsUrl: result.Location
53
54
  }
54
55
  }
55
56
 
@@ -1,2 +1,3 @@
1
1
  export * from './upload-awb'
2
- export * from './upload-invoice'
2
+ export * from './upload-invoice'
3
+ export * from './upload-storage'
@@ -0,0 +1,11 @@
1
+ import '../storage-s3'
2
+ import { STORAGE } from '../attachment-const'
3
+
4
+ export async function uploadFile(param: any) {
5
+ const {content, title} = param
6
+
7
+ let result = await STORAGE.uploadFile({ stream : content, filename: title })
8
+
9
+ return result
10
+
11
+ }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ATTACHMENT_PATH = exports.INVSTORAGE = exports.AWBSTORAGE = exports.STORAGE = void 0;
4
- const env_1 = require("@things-factory/env");
5
- exports.STORAGE = env_1.config.get('storage');
6
- exports.AWBSTORAGE = env_1.config.get('awbFileStorage');
7
- exports.INVSTORAGE = env_1.config.get('invoiceFileStorage');
8
- exports.ATTACHMENT_PATH = env_1.config.get('attachmentPath', 'attachment');
9
- //# sourceMappingURL=attachment-const.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment-const.js","sourceRoot":"","sources":["../server/attachment-const.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAEjC,QAAA,OAAO,GAAQ,YAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;AACpC,QAAA,UAAU,GAAQ,YAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;AAC9C,QAAA,UAAU,GAAQ,YAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAChD,QAAA,eAAe,GAAW,YAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAA"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const client_s3_1 = require("@aws-sdk/client-s3");
4
- const lib_storage_1 = require("@aws-sdk/lib-storage");
5
- const env_1 = require("@things-factory/env");
6
- const attachment_const_1 = require("./attachment-const");
7
- if (attachment_const_1.AWBSTORAGE && attachment_const_1.AWBSTORAGE.type == 's3') {
8
- const client = new client_s3_1.S3Client({
9
- credentials: {
10
- accessKeyId: attachment_const_1.AWBSTORAGE.accessKeyId,
11
- secretAccessKey: attachment_const_1.AWBSTORAGE.secretAccessKey
12
- },
13
- region: attachment_const_1.AWBSTORAGE.region
14
- });
15
- /* upload file */
16
- attachment_const_1.AWBSTORAGE.uploadFile = async ({ stream, filename }) => {
17
- const upload = new lib_storage_1.Upload({
18
- client,
19
- params: {
20
- Bucket: attachment_const_1.AWBSTORAGE.bucketName,
21
- Key: `${filename}.pdf`,
22
- Body: stream,
23
- ContentType: 'application/pdf'
24
- }
25
- });
26
- let result;
27
- let url;
28
- try {
29
- result = (await upload.done());
30
- url = `https://${attachment_const_1.AWBSTORAGE.bucketName}.s3.${attachment_const_1.AWBSTORAGE.region}.amazonaws.com/${filename}.pdf`;
31
- }
32
- catch (e) {
33
- console.log(e);
34
- }
35
- return {
36
- result,
37
- url
38
- };
39
- };
40
- env_1.logger.info('operato-awb: S3 Bucket Storage is Ready.');
41
- }
42
- //# sourceMappingURL=awb-storage-s3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"awb-storage-s3.js","sourceRoot":"","sources":["../server/awb-storage-s3.ts"],"names":[],"mappings":";;AAAA,kDAA6C;AAC7C,sDAA6C;AAC7C,6CAA4C;AAE5C,yDAA+C;AAE/C,IAAI,6BAAU,IAAI,6BAAU,CAAC,IAAI,IAAI,IAAI,EAAE;IACzC,MAAM,MAAM,GAAG,IAAI,oBAAQ,CAAC;QAC1B,WAAW,EAAE;YACX,WAAW,EAAE,6BAAU,CAAC,WAAW;YACnC,eAAe,EAAE,6BAAU,CAAC,eAAe;SAC5C;QACD,MAAM,EAAE,6BAAU,CAAC,MAAM;KAC1B,CAAC,CAAA;IAEF,iBAAiB;IACjB,6BAAU,CAAC,UAAU,GAAG,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrD,MAAM,MAAM,GAAG,IAAI,oBAAM,CAAC;YACxB,MAAM;YACN,MAAM,EAAE;gBACN,MAAM,EAAE,6BAAU,CAAC,UAAU;gBAC7B,GAAG,EAAE,GAAG,QAAQ,MAAM;gBACtB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,iBAAiB;aAC/B;SACF,CAAC,CAAA;QAEF,IAAI,MAAM,CAAA;QACV,IAAI,GAAG,CAAA;QACP,IAAI;YACF,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAQ,CAAA;YACrC,GAAG,GAAG,WAAW,6BAAU,CAAC,UAAU,OAAO,6BAAU,CAAC,MAAM,kBAAkB,QAAQ,MAAM,CAAA;SAC/F;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;SACf;QAED,OAAO;YACL,MAAM;YACN,GAAG;SACJ,CAAA;IACH,CAAC,CAAA;IAED,YAAM,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAA;CACxD"}
@@ -1,31 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.singleUpload = exports.multipleUpload = exports.deleteAttachmentsByRef = exports.deleteAttachment = exports.createAttachments = exports.createAttachment = void 0;
18
- __exportStar(require("./attachment-const"), exports);
19
- __exportStar(require("./migrations"), exports);
20
- __exportStar(require("./service"), exports);
21
- var attachment_mutation_1 = require("./service/attachment/attachment-mutation");
22
- Object.defineProperty(exports, "createAttachment", { enumerable: true, get: function () { return attachment_mutation_1.createAttachment; } });
23
- Object.defineProperty(exports, "createAttachments", { enumerable: true, get: function () { return attachment_mutation_1.createAttachments; } });
24
- Object.defineProperty(exports, "deleteAttachment", { enumerable: true, get: function () { return attachment_mutation_1.deleteAttachment; } });
25
- Object.defineProperty(exports, "deleteAttachmentsByRef", { enumerable: true, get: function () { return attachment_mutation_1.deleteAttachmentsByRef; } });
26
- Object.defineProperty(exports, "multipleUpload", { enumerable: true, get: function () { return attachment_mutation_1.multipleUpload; } });
27
- Object.defineProperty(exports, "singleUpload", { enumerable: true, get: function () { return attachment_mutation_1.singleUpload; } });
28
- require("./routes");
29
- __exportStar(require("./attachment-const"), exports);
30
- __exportStar(require("./util"), exports);
31
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAkC;AAClC,+CAA4B;AAC5B,4CAAyB;AACzB,gFAOiD;AAN/C,uHAAA,gBAAgB,OAAA;AAChB,wHAAA,iBAAiB,OAAA;AACjB,uHAAA,gBAAgB,OAAA;AAChB,6HAAA,sBAAsB,OAAA;AACtB,qHAAA,cAAc,OAAA;AACd,mHAAA,YAAY,OAAA;AAGd,oBAAiB;AAEjB,qDAAkC;AAClC,yCAAsB"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const client_s3_1 = require("@aws-sdk/client-s3");
4
- const lib_storage_1 = require("@aws-sdk/lib-storage");
5
- const env_1 = require("@things-factory/env");
6
- const attachment_const_1 = require("./attachment-const");
7
- if (attachment_const_1.INVSTORAGE && attachment_const_1.INVSTORAGE.type == 's3') {
8
- const client = new client_s3_1.S3Client({
9
- credentials: {
10
- accessKeyId: attachment_const_1.INVSTORAGE.accessKeyId,
11
- secretAccessKey: attachment_const_1.INVSTORAGE.secretAccessKey
12
- },
13
- region: attachment_const_1.INVSTORAGE.region
14
- });
15
- // Upload Invoice File
16
- attachment_const_1.INVSTORAGE.uploadInvoiceS3 = async ({ stream, filename }) => {
17
- const upload = new lib_storage_1.Upload({
18
- client,
19
- params: {
20
- Bucket: attachment_const_1.INVSTORAGE.invoiceBucket,
21
- Key: `${filename}.pdf`,
22
- Body: stream,
23
- ContentType: 'application/pdf'
24
- }
25
- });
26
- let result;
27
- let url;
28
- try {
29
- result = (await upload.done());
30
- url = `https://${attachment_const_1.INVSTORAGE.invoiceBucket}.s3.${attachment_const_1.INVSTORAGE.region}.amazonaws.com/${filename}.pdf`;
31
- }
32
- catch (e) {
33
- console.log(e);
34
- }
35
- return {
36
- result,
37
- url
38
- };
39
- };
40
- env_1.logger.info('operato-invoice: S3 Bucket Storage is Ready');
41
- }
42
- //# sourceMappingURL=invoice-storage-s3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invoice-storage-s3.js","sourceRoot":"","sources":["../server/invoice-storage-s3.ts"],"names":[],"mappings":";;AAAA,kDAA6C;AAC7C,sDAA6C;AAC7C,6CAA4C;AAE5C,yDAA+C;AAE/C,IAAI,6BAAU,IAAI,6BAAU,CAAC,IAAI,IAAI,IAAI,EAAE;IACzC,MAAM,MAAM,GAAG,IAAI,oBAAQ,CAAC;QAC1B,WAAW,EAAE;YACX,WAAW,EAAE,6BAAU,CAAC,WAAW;YACnC,eAAe,EAAE,6BAAU,CAAC,eAAe;SAC5C;QACD,MAAM,EAAE,6BAAU,CAAC,MAAM;KAC1B,CAAC,CAAA;IAEF,sBAAsB;IACtB,6BAAU,CAAC,eAAe,GAAG,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1D,MAAM,MAAM,GAAG,IAAI,oBAAM,CAAC;YACxB,MAAM;YACN,MAAM,EAAE;gBACN,MAAM,EAAE,6BAAU,CAAC,aAAa;gBAChC,GAAG,EAAE,GAAG,QAAQ,MAAM;gBACtB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,iBAAiB;aAC/B;SACF,CAAC,CAAA;QAEF,IAAI,MAAM,CAAA;QACV,IAAI,GAAG,CAAA;QACP,IAAI;YACF,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAQ,CAAA;YACrC,GAAG,GAAG,WAAW,6BAAU,CAAC,aAAa,OAAO,6BAAU,CAAC,MAAM,kBAAkB,QAAQ,MAAM,CAAA;SAClG;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;SACf;QAED,OAAO;YACL,MAAM;YACN,GAAG;SACJ,CAAA;IACH,CAAC,CAAA;IAED,YAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAA;CAC3D"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.migrations = void 0;
4
- const glob = require('glob');
5
- const path = require('path');
6
- exports.migrations = [];
7
- glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function (file) {
8
- if (file.indexOf('index.js') !== -1)
9
- return;
10
- exports.migrations = exports.migrations.concat(Object.values(require(path.resolve(file))) || []);
11
- });
12
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("./storage-file");
4
- require("./storage-s3");
5
- const attachment_const_1 = require("./attachment-const");
6
- const multer = require('@koa/multer');
7
- const upload = multer(); // note you can pass `multer` options here
8
- // process.on('bootstrap-module-domain-private-route' as any, (app, routes) => {
9
- process.on('bootstrap-module-global-public-route', (app, routes) => {
10
- // TODO make this secure
11
- routes.get(`/${attachment_const_1.ATTACHMENT_PATH}/:attachment`, async (context, next) => {
12
- await attachment_const_1.STORAGE.sendFile(context, context.params.attachment, next);
13
- });
14
- routes.post(`/${attachment_const_1.ATTACHMENT_PATH}`, async (context, next) => {
15
- const { files } = await upload(context.request);
16
- const result = await Promise.all(files.map(file => attachment_const_1.STORAGE.uploadFile({ stream: file, filename: file.filename })));
17
- context.status = 200;
18
- // Support < IE 10 browser
19
- context.res.setHeader('Content-Type', 'text/html;charset=UTF-8');
20
- context.body = JSON.stringify(result);
21
- });
22
- });
23
- //# sourceMappingURL=routes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,0BAAuB;AACvB,wBAAqB;AAErB,yDAA6D;AAE7D,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AACrC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAA,CAAC,0CAA0C;AAElE,gFAAgF;AAChF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IACxE,wBAAwB;IACxB,MAAM,CAAC,GAAG,CAAC,IAAI,kCAAe,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACpE,MAAM,0BAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAClE,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,IAAI,CAAC,IAAI,kCAAe,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACzD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAE/C,MAAM,MAAM,GAAiD,MAAM,OAAO,CAAC,GAAG,CAC5E,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,0BAAO,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CACjF,CAAA;QAED,OAAO,CAAC,MAAM,GAAG,GAAG,CAAA;QACpB,0BAA0B;QAC1B,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAA;QAChE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,216 +0,0 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- var _a;
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.multipleUpload = exports.singleUpload = exports.generateUploadURL = exports.deleteAttachmentsByRef = exports.deleteAttachment = exports.createAttachments = exports.createAttachment = exports.AttachmentMutation = void 0;
20
- const graphql_upload_1 = require("graphql-upload");
21
- const promises_all_1 = __importDefault(require("promises-all"));
22
- const type_graphql_1 = require("type-graphql");
23
- const typeorm_1 = require("typeorm");
24
- const env_1 = require("@things-factory/env");
25
- const attachment_const_1 = require("../../attachment-const");
26
- const attachment_1 = require("./attachment");
27
- const attachment_types_1 = require("./attachment-types");
28
- let AttachmentMutation = class AttachmentMutation {
29
- async createAttachment(attachment, context) {
30
- return await createAttachment(null, { attachment }, context);
31
- }
32
- async createAttachments(attachments, context) {
33
- return await createAttachments(null, { attachments }, context);
34
- }
35
- async updateAttachment(id, patch, context) {
36
- const attachment = await (0, typeorm_1.getRepository)(attachment_1.Attachment).findOne({
37
- where: {
38
- domain: context.state.domain,
39
- id
40
- }
41
- });
42
- return await (0, typeorm_1.getRepository)(attachment_1.Attachment).save(Object.assign(Object.assign(Object.assign({}, attachment), patch), { updater: context.state.user }));
43
- }
44
- async deleteAttachment(id, context) {
45
- return await deleteAttachment(null, { id }, context);
46
- }
47
- async deleteAttachmentsByRef(refBys, context) {
48
- return await deleteAttachmentsByRef(null, { refBys }, context);
49
- }
50
- async singleUpload(file, context) {
51
- return await singleUpload(null, { file }, context);
52
- }
53
- async multipleUpload(files, context) {
54
- return await multipleUpload(null, { files }, context);
55
- }
56
- async generateUploadURL(type, context) {
57
- return await generateUploadURL(null, { type }, context);
58
- }
59
- };
60
- __decorate([
61
- (0, type_graphql_1.Directive)('@transaction'),
62
- (0, type_graphql_1.Mutation)(returns => attachment_1.Attachment),
63
- __param(0, (0, type_graphql_1.Arg)('attachment', type => attachment_types_1.NewAttachment)),
64
- __param(1, (0, type_graphql_1.Ctx)()),
65
- __metadata("design:type", Function),
66
- __metadata("design:paramtypes", [attachment_types_1.NewAttachment, Object]),
67
- __metadata("design:returntype", Promise)
68
- ], AttachmentMutation.prototype, "createAttachment", null);
69
- __decorate([
70
- (0, type_graphql_1.Directive)('@transaction'),
71
- (0, type_graphql_1.Mutation)(returns => [attachment_1.Attachment]),
72
- __param(0, (0, type_graphql_1.Arg)('attachments', type => [attachment_types_1.NewAttachment])),
73
- __param(1, (0, type_graphql_1.Ctx)()),
74
- __metadata("design:type", Function),
75
- __metadata("design:paramtypes", [Array, Object]),
76
- __metadata("design:returntype", Promise)
77
- ], AttachmentMutation.prototype, "createAttachments", null);
78
- __decorate([
79
- (0, type_graphql_1.Directive)('@transaction'),
80
- (0, type_graphql_1.Mutation)(returns => attachment_1.Attachment),
81
- __param(0, (0, type_graphql_1.Arg)('id')),
82
- __param(1, (0, type_graphql_1.Arg)('patch', type => attachment_types_1.AttachmentPatch)),
83
- __param(2, (0, type_graphql_1.Ctx)()),
84
- __metadata("design:type", Function),
85
- __metadata("design:paramtypes", [String, attachment_types_1.AttachmentPatch, Object]),
86
- __metadata("design:returntype", Promise)
87
- ], AttachmentMutation.prototype, "updateAttachment", null);
88
- __decorate([
89
- (0, type_graphql_1.Directive)('@transaction'),
90
- (0, type_graphql_1.Mutation)(returns => Boolean),
91
- __param(0, (0, type_graphql_1.Arg)('id')),
92
- __param(1, (0, type_graphql_1.Ctx)()),
93
- __metadata("design:type", Function),
94
- __metadata("design:paramtypes", [String, Object]),
95
- __metadata("design:returntype", Promise)
96
- ], AttachmentMutation.prototype, "deleteAttachment", null);
97
- __decorate([
98
- (0, type_graphql_1.Directive)('@transaction'),
99
- (0, type_graphql_1.Mutation)(returns => Boolean),
100
- __param(0, (0, type_graphql_1.Arg)('refBys', type => [String])),
101
- __param(1, (0, type_graphql_1.Ctx)()),
102
- __metadata("design:type", Function),
103
- __metadata("design:paramtypes", [Array, Object]),
104
- __metadata("design:returntype", Promise)
105
- ], AttachmentMutation.prototype, "deleteAttachmentsByRef", null);
106
- __decorate([
107
- (0, type_graphql_1.Directive)('@transaction'),
108
- (0, type_graphql_1.Mutation)(returns => attachment_1.Attachment),
109
- __param(0, (0, type_graphql_1.Arg)('file', type => graphql_upload_1.GraphQLUpload)),
110
- __param(1, (0, type_graphql_1.Ctx)()),
111
- __metadata("design:type", Function),
112
- __metadata("design:paramtypes", [typeof (_a = typeof graphql_upload_1.FileUpload !== "undefined" && graphql_upload_1.FileUpload) === "function" ? _a : Object, Object]),
113
- __metadata("design:returntype", Promise)
114
- ], AttachmentMutation.prototype, "singleUpload", null);
115
- __decorate([
116
- (0, type_graphql_1.Directive)('@transaction'),
117
- (0, type_graphql_1.Mutation)(returns => [attachment_1.Attachment]),
118
- __param(0, (0, type_graphql_1.Arg)('files', type => [graphql_upload_1.GraphQLUpload])),
119
- __param(1, (0, type_graphql_1.Ctx)()),
120
- __metadata("design:type", Function),
121
- __metadata("design:paramtypes", [Array, Object]),
122
- __metadata("design:returntype", Promise)
123
- ], AttachmentMutation.prototype, "multipleUpload", null);
124
- __decorate([
125
- (0, type_graphql_1.Mutation)(returns => attachment_types_1.UploadURL),
126
- __param(0, (0, type_graphql_1.Arg)('type', type => String)),
127
- __param(1, (0, type_graphql_1.Ctx)()),
128
- __metadata("design:type", Function),
129
- __metadata("design:paramtypes", [String, Object]),
130
- __metadata("design:returntype", Promise)
131
- ], AttachmentMutation.prototype, "generateUploadURL", null);
132
- AttachmentMutation = __decorate([
133
- (0, type_graphql_1.Resolver)(attachment_1.Attachment)
134
- ], AttachmentMutation);
135
- exports.AttachmentMutation = AttachmentMutation;
136
- async function createAttachment(_, { attachment }, context) {
137
- const { file, category, refBy, description } = attachment;
138
- const { createReadStream, filename, mimetype, encoding } = await file;
139
- const stream = createReadStream();
140
- const { id, path, size } = await attachment_const_1.STORAGE.uploadFile({ stream, filename });
141
- const { domain, user } = context.state;
142
- return await (0, typeorm_1.getRepository)(attachment_1.Attachment).save({
143
- domain,
144
- creator: user,
145
- updater: user,
146
- id,
147
- description,
148
- name: filename,
149
- mimetype,
150
- encoding,
151
- refBy,
152
- category: category || mimetype.split('/').shift(),
153
- size: size,
154
- path
155
- });
156
- }
157
- exports.createAttachment = createAttachment;
158
- async function createAttachments(_, { attachments }, context) {
159
- const { resolve, reject } = await promises_all_1.default.all(attachments.map(attachment => createAttachment(_, { attachment }, context)));
160
- if (reject.length) {
161
- reject.forEach(({ name, message }) => env_1.logger.error(`${name}: ${message}`));
162
- return reject;
163
- }
164
- return resolve;
165
- }
166
- exports.createAttachments = createAttachments;
167
- async function deleteAttachment(_, { id }, context) {
168
- const repository = (0, typeorm_1.getRepository)(attachment_1.Attachment);
169
- const attachment = await repository.findOne({
170
- where: { domain: context.state.domain, id }
171
- });
172
- if (attachment) {
173
- await repository.delete(attachment.id);
174
- await attachment_const_1.STORAGE.deleteFile(attachment.path);
175
- return true;
176
- }
177
- else {
178
- return false;
179
- }
180
- }
181
- exports.deleteAttachment = deleteAttachment;
182
- async function deleteAttachmentsByRef(_, { refBys }, context) {
183
- const { domain } = context.state;
184
- const repository = (0, typeorm_1.getRepository)(attachment_1.Attachment);
185
- const attachments = await repository.find({
186
- where: { domain, refBy: (0, typeorm_1.In)(refBys) }
187
- });
188
- //remove attachment from repo
189
- await repository.delete({
190
- refBy: (0, typeorm_1.In)(refBys)
191
- });
192
- //remove files from attachments folder
193
- if (attachments.length) {
194
- await Promise.all(attachments.map(async (attachment) => {
195
- await attachment_const_1.STORAGE.deleteFile(attachment.path);
196
- }));
197
- return true;
198
- }
199
- else {
200
- return false;
201
- }
202
- }
203
- exports.deleteAttachmentsByRef = deleteAttachmentsByRef;
204
- async function generateUploadURL(_, { type }, context) {
205
- return await attachment_const_1.STORAGE.generateUploadURL(type);
206
- }
207
- exports.generateUploadURL = generateUploadURL;
208
- async function singleUpload(_, { file }, context) {
209
- return await createAttachment(null, { attachment: { file } }, context);
210
- }
211
- exports.singleUpload = singleUpload;
212
- async function multipleUpload(_, { files }, context) {
213
- return await createAttachments(null, { attachments: { files } }, context);
214
- }
215
- exports.multipleUpload = multipleUpload;
216
- //# sourceMappingURL=attachment-mutation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment-mutation.js","sourceRoot":"","sources":["../../../server/service/attachment/attachment-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,mDAA0D;AAC1D,gEAAsC;AACtC,+CAAsE;AACtE,qCAA2C;AAE3C,6CAA4C;AAE5C,6DAAgD;AAChD,6CAAyC;AACzC,yDAA8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sCAAsC;IACtC,IAAI,WAAW,CAAC,MAAM,EAAE;QACtB,MAAM,OAAO,CAAC,GAAG,CACf,WAAW,CAAC,GAAG,CAAC,KAAK,EAAC,UAAU,EAAC,EAAE;YACjC,MAAM,0BAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAC3C,CAAC,CAAC,CACH,CAAA;QAED,OAAO,IAAI,CAAA;KACZ;SAAM;QACL,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAzBD,wDAyBC;AAEM,KAAK,UAAU,iBAAiB,CACrC,CAAM,EACN,EAAE,IAAI,EAAE,EACR,OAAY;IAEZ,OAAO,MAAM,0BAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;AAC9C,CAAC;AAND,8CAMC;AAEM,KAAK,UAAU,YAAY,CAAC,CAAM,EAAE,EAAE,IAAI,EAAE,EAAE,OAAY;IAC/D,OAAO,MAAM,gBAAgB,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACxE,CAAC;AAFD,oCAEC;AAEM,KAAK,UAAU,cAAc,CAAC,CAAM,EAAE,EAAE,KAAK,EAAE,EAAE,OAAY;IAClE,OAAO,MAAM,iBAAiB,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AAC3E,CAAC;AAFD,wCAEC"}
@@ -1,57 +0,0 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var _a;
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.AttachmentQuery = void 0;
17
- const type_graphql_1 = require("type-graphql");
18
- const typeorm_1 = require("typeorm");
19
- const shell_1 = require("@things-factory/shell");
20
- const __1 = require("../");
21
- const attachment_1 = require("./attachment");
22
- let AttachmentQuery = class AttachmentQuery {
23
- async attachments(context, filters, pagination, sortings) {
24
- const convertedParams = (0, shell_1.convertListParams)({ filters, pagination, sortings }, context.state.domain.id);
25
- const [items, total] = await (0, typeorm_1.getRepository)(attachment_1.Attachment).findAndCount(Object.assign(Object.assign({}, convertedParams), { relations: ['domain', 'creator', 'updater'] }));
26
- return { items, total };
27
- }
28
- async attachment(id, context) {
29
- return await (0, typeorm_1.getRepository)(attachment_1.Attachment).findOne({
30
- where: { domain: context.state.domain, id },
31
- relations: ['domain', 'creator', 'updater']
32
- });
33
- }
34
- };
35
- __decorate([
36
- (0, type_graphql_1.Query)(returns => __1.AttachmentList),
37
- __param(0, (0, type_graphql_1.Ctx)()),
38
- __param(1, (0, type_graphql_1.Arg)('filters', type => [shell_1.Filter], { nullable: true })),
39
- __param(2, (0, type_graphql_1.Arg)('pagination', type => shell_1.Pagination, { nullable: true })),
40
- __param(3, (0, type_graphql_1.Arg)('sortings', type => [shell_1.Sorting], { nullable: true })),
41
- __metadata("design:type", Function),
42
- __metadata("design:paramtypes", [Object, Array, typeof (_a = typeof shell_1.Pagination !== "undefined" && shell_1.Pagination) === "function" ? _a : Object, Array]),
43
- __metadata("design:returntype", Promise)
44
- ], AttachmentQuery.prototype, "attachments", null);
45
- __decorate([
46
- (0, type_graphql_1.Query)(returns => attachment_1.Attachment),
47
- __param(0, (0, type_graphql_1.Arg)('id')),
48
- __param(1, (0, type_graphql_1.Ctx)()),
49
- __metadata("design:type", Function),
50
- __metadata("design:paramtypes", [String, Object]),
51
- __metadata("design:returntype", Promise)
52
- ], AttachmentQuery.prototype, "attachment", null);
53
- AttachmentQuery = __decorate([
54
- (0, type_graphql_1.Resolver)(attachment_1.Attachment)
55
- ], AttachmentQuery);
56
- exports.AttachmentQuery = AttachmentQuery;
57
- //# sourceMappingURL=attachment-query.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment-query.js","sourceRoot":"","sources":["../../../server/service/attachment/attachment-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAAwD;AACxD,qCAAuC;AAEvC,iDAAsF;AAEtF,2BAAoC;AACpC,6CAAyC;AAGlC,IAAM,eAAe,GAArB,MAAM,eAAe;IAEpB,AAAN,KAAK,CAAC,WAAW,CACR,OAAY,EACmC,OAAkB,EACb,UAAuB,EAC1B,QAAoB;QAE5E,MAAM,eAAe,GAAG,IAAA,yBAAiB,EAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACrG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,uBAAa,EAAC,uBAAU,CAAC,CAAC,YAAY,iCAC9D,eAAe,KAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,IAC3C,CAAA;QAEF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGK,AAAN,KAAK,CAAC,UAAU,CAAY,EAAU,EAAS,OAAY;QACzD,OAAO,MAAM,IAAA,uBAAa,EAAC,uBAAU,CAAC,CAAC,OAAO,CAAC;YAC7C,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE;YAC3C,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;SAC5C,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAtBO;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,kBAAc,CAAC;IAE9B,WAAA,IAAA,kBAAG,GAAE,CAAA;IACL,WAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,cAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,WAAA,IAAA,kBAAG,EAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACzD,WAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,eAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;wEADiB,kBAAU,oBAAV,kBAAU;;kDAUnF;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,uBAAU,CAAC;IACX,WAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;iDAK7C;AAvBU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,eAAe,CAwB3B;AAxBY,0CAAe"}
@@ -1,102 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.AttachmentPatch = exports.NewAttachment = exports.UploadURL = exports.AttachmentList = void 0;
14
- const graphql_upload_1 = require("graphql-upload");
15
- const type_graphql_1 = require("type-graphql");
16
- const shell_1 = require("@things-factory/shell");
17
- const attachment_1 = require("./attachment");
18
- let AttachmentList = class AttachmentList {
19
- };
20
- __decorate([
21
- (0, type_graphql_1.Field)(type => [attachment_1.Attachment]),
22
- __metadata("design:type", Array)
23
- ], AttachmentList.prototype, "items", void 0);
24
- __decorate([
25
- (0, type_graphql_1.Field)(type => type_graphql_1.Int),
26
- __metadata("design:type", Number)
27
- ], AttachmentList.prototype, "total", void 0);
28
- AttachmentList = __decorate([
29
- (0, type_graphql_1.ObjectType)()
30
- ], AttachmentList);
31
- exports.AttachmentList = AttachmentList;
32
- let UploadURL = class UploadURL {
33
- };
34
- __decorate([
35
- (0, type_graphql_1.Field)(type => String),
36
- __metadata("design:type", String)
37
- ], UploadURL.prototype, "url", void 0);
38
- __decorate([
39
- (0, type_graphql_1.Field)(type => shell_1.ScalarAny),
40
- __metadata("design:type", typeof (_a = typeof shell_1.ScalarAny !== "undefined" && shell_1.ScalarAny) === "function" ? _a : Object)
41
- ], UploadURL.prototype, "fields", void 0);
42
- UploadURL = __decorate([
43
- (0, type_graphql_1.ObjectType)()
44
- ], UploadURL);
45
- exports.UploadURL = UploadURL;
46
- let NewAttachment = class NewAttachment {
47
- };
48
- __decorate([
49
- (0, type_graphql_1.Field)({ nullable: true }),
50
- __metadata("design:type", String)
51
- ], NewAttachment.prototype, "category", void 0);
52
- __decorate([
53
- (0, type_graphql_1.Field)(type => graphql_upload_1.GraphQLUpload),
54
- __metadata("design:type", typeof (_b = typeof graphql_upload_1.FileUpload !== "undefined" && graphql_upload_1.FileUpload) === "function" ? _b : Object)
55
- ], NewAttachment.prototype, "file", void 0);
56
- __decorate([
57
- (0, type_graphql_1.Field)({ nullable: true }),
58
- __metadata("design:type", String)
59
- ], NewAttachment.prototype, "description", void 0);
60
- __decorate([
61
- (0, type_graphql_1.Field)({ nullable: true }),
62
- __metadata("design:type", String)
63
- ], NewAttachment.prototype, "refBy", void 0);
64
- NewAttachment = __decorate([
65
- (0, type_graphql_1.InputType)()
66
- ], NewAttachment);
67
- exports.NewAttachment = NewAttachment;
68
- let AttachmentPatch = class AttachmentPatch {
69
- };
70
- __decorate([
71
- (0, type_graphql_1.Field)({ nullable: true }),
72
- __metadata("design:type", String)
73
- ], AttachmentPatch.prototype, "name", void 0);
74
- __decorate([
75
- (0, type_graphql_1.Field)({ nullable: true }),
76
- __metadata("design:type", String)
77
- ], AttachmentPatch.prototype, "description", void 0);
78
- __decorate([
79
- (0, type_graphql_1.Field)({ nullable: true }),
80
- __metadata("design:type", String)
81
- ], AttachmentPatch.prototype, "mimetype", void 0);
82
- __decorate([
83
- (0, type_graphql_1.Field)({ nullable: true }),
84
- __metadata("design:type", String)
85
- ], AttachmentPatch.prototype, "encoding", void 0);
86
- __decorate([
87
- (0, type_graphql_1.Field)({ nullable: true }),
88
- __metadata("design:type", String)
89
- ], AttachmentPatch.prototype, "category", void 0);
90
- __decorate([
91
- (0, type_graphql_1.Field)(type => graphql_upload_1.GraphQLUpload, { nullable: true }),
92
- __metadata("design:type", typeof (_c = typeof graphql_upload_1.FileUpload !== "undefined" && graphql_upload_1.FileUpload) === "function" ? _c : Object)
93
- ], AttachmentPatch.prototype, "file", void 0);
94
- __decorate([
95
- (0, type_graphql_1.Field)({ nullable: true }),
96
- __metadata("design:type", String)
97
- ], AttachmentPatch.prototype, "refBy", void 0);
98
- AttachmentPatch = __decorate([
99
- (0, type_graphql_1.InputType)()
100
- ], AttachmentPatch);
101
- exports.AttachmentPatch = AttachmentPatch;
102
- //# sourceMappingURL=attachment-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment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,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACd;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACP;AAEnB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDAC3C,2BAAU,oBAAV,2BAAU;6CAAA;AAEhB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACb;AApBF,eAAe;IAD3B,IAAA,wBAAS,GAAE;GACC,eAAe,CAqB3B;AArBY,0CAAe"}
@@ -1,123 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Attachment = void 0;
14
- const typeorm_1 = require("typeorm");
15
- const type_graphql_1 = require("type-graphql");
16
- const attachment_const_1 = require("../../attachment-const");
17
- const shell_1 = require("@things-factory/shell");
18
- const auth_base_1 = require("@things-factory/auth-base");
19
- let Attachment = class Attachment {
20
- get fullpath() {
21
- return `/${attachment_const_1.ATTACHMENT_PATH}/${this.path}`;
22
- }
23
- };
24
- __decorate([
25
- (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
26
- (0, type_graphql_1.Field)(type => type_graphql_1.ID),
27
- __metadata("design:type", String)
28
- ], Attachment.prototype, "id", void 0);
29
- __decorate([
30
- (0, typeorm_1.ManyToOne)(type => shell_1.Domain, { nullable: false }),
31
- (0, type_graphql_1.Field)(type => shell_1.Domain),
32
- __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
33
- ], Attachment.prototype, "domain", void 0);
34
- __decorate([
35
- (0, typeorm_1.RelationId)((attachment) => attachment.domain),
36
- __metadata("design:type", String)
37
- ], Attachment.prototype, "domainId", void 0);
38
- __decorate([
39
- (0, typeorm_1.Column)(),
40
- (0, type_graphql_1.Field)(),
41
- __metadata("design:type", String)
42
- ], Attachment.prototype, "name", void 0);
43
- __decorate([
44
- (0, typeorm_1.Column)({ nullable: true }),
45
- (0, type_graphql_1.Field)({ nullable: true }),
46
- __metadata("design:type", String)
47
- ], Attachment.prototype, "description", void 0);
48
- __decorate([
49
- (0, typeorm_1.Column)(),
50
- (0, type_graphql_1.Field)(),
51
- __metadata("design:type", String)
52
- ], Attachment.prototype, "mimetype", void 0);
53
- __decorate([
54
- (0, typeorm_1.Column)(),
55
- (0, type_graphql_1.Field)(),
56
- __metadata("design:type", String)
57
- ], Attachment.prototype, "encoding", void 0);
58
- __decorate([
59
- (0, typeorm_1.Column)({ nullable: true }),
60
- (0, type_graphql_1.Field)({ nullable: true }),
61
- __metadata("design:type", String)
62
- ], Attachment.prototype, "category", void 0);
63
- __decorate([
64
- (0, typeorm_1.Column)({ nullable: true }),
65
- (0, type_graphql_1.Field)({ nullable: true }),
66
- __metadata("design:type", String)
67
- ], Attachment.prototype, "refBy", void 0);
68
- __decorate([
69
- (0, typeorm_1.Column)(),
70
- (0, type_graphql_1.Field)(),
71
- __metadata("design:type", String)
72
- ], Attachment.prototype, "path", void 0);
73
- __decorate([
74
- (0, typeorm_1.Column)(),
75
- (0, type_graphql_1.Field)(),
76
- __metadata("design:type", String)
77
- ], Attachment.prototype, "size", void 0);
78
- __decorate([
79
- (0, typeorm_1.CreateDateColumn)(),
80
- (0, type_graphql_1.Field)(),
81
- __metadata("design:type", Date)
82
- ], Attachment.prototype, "createdAt", void 0);
83
- __decorate([
84
- (0, typeorm_1.UpdateDateColumn)(),
85
- (0, type_graphql_1.Field)(),
86
- __metadata("design:type", Date)
87
- ], Attachment.prototype, "updatedAt", void 0);
88
- __decorate([
89
- (0, typeorm_1.ManyToOne)(type => auth_base_1.User),
90
- (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
91
- __metadata("design:type", typeof (_b = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _b : Object)
92
- ], Attachment.prototype, "creator", void 0);
93
- __decorate([
94
- (0, typeorm_1.RelationId)((attachment) => attachment.creator),
95
- __metadata("design:type", String)
96
- ], Attachment.prototype, "creatorId", void 0);
97
- __decorate([
98
- (0, typeorm_1.ManyToOne)(type => auth_base_1.User),
99
- (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
100
- __metadata("design:type", typeof (_c = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _c : Object)
101
- ], Attachment.prototype, "updater", void 0);
102
- __decorate([
103
- (0, typeorm_1.RelationId)((attachment) => attachment.updater),
104
- __metadata("design:type", String)
105
- ], Attachment.prototype, "updaterId", void 0);
106
- __decorate([
107
- (0, type_graphql_1.Field)(),
108
- __metadata("design:type", String),
109
- __metadata("design:paramtypes", [])
110
- ], Attachment.prototype, "fullpath", null);
111
- Attachment = __decorate([
112
- (0, typeorm_1.Entity)(),
113
- (0, typeorm_1.Index)('ix_attachment_0', (attachment) => [attachment.domain, attachment.name], { unique: false }),
114
- (0, typeorm_1.Index)('ix_attachment_1', (attachment) => [attachment.domain, attachment.category, attachment.name], {
115
- unique: false
116
- }),
117
- (0, typeorm_1.Index)('ix_attachment_2', (attachment) => [attachment.domain, attachment.refBy], {
118
- unique: false
119
- }),
120
- (0, type_graphql_1.ObjectType)()
121
- ], Attachment);
122
- exports.Attachment = Attachment;
123
- //# sourceMappingURL=attachment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment.js","sourceRoot":"","sources":["../../../server/service/attachment/attachment.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,qCASgB;AAChB,+CAAoD;AAEpD,6DAAwD;AACxD,iDAA8C;AAC9C,yDAAgD;AAWzC,IAAM,UAAU,GAAhB,MAAM,UAAU;IAkErB,IACI,QAAQ;QACV,OAAO,IAAI,kCAAe,IAAI,IAAI,CAAC,IAAI,EAAE,CAAA;IAC3C,CAAC;CACF,CAAA;AArEC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;sCACC;AAEnB;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC9C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;kDACd,cAAM,oBAAN,cAAM;0CAAA;AAEd;IAAC,IAAA,oBAAU,EAAC,CAAC,UAAsB,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;;4CAC1C;AAEhB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;wCACI;AAEZ;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACP;AAEnB;IAA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EAAC,CAAC,UAAsB,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;;6CAC1C;AAEjB;IAAC,IAAA,oBAAK,GAAE;;;0CAGP;AArEU,UAAU;IATtB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC7G,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE;QAC/G,MAAM,EAAE,KAAK;KACd,CAAC;IACD,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE;QAC3F,MAAM,EAAE,KAAK;KACd,CAAC;IACD,IAAA,yBAAU,GAAE;GACA,UAAU,CAsEtB;AAtEY,gCAAU"}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvers = exports.entities = void 0;
4
- const attachment_1 = require("./attachment");
5
- const attachment_mutation_1 = require("./attachment-mutation");
6
- const attachment_query_1 = require("./attachment-query");
7
- exports.entities = [attachment_1.Attachment];
8
- exports.resolvers = [attachment_query_1.AttachmentQuery, attachment_mutation_1.AttachmentMutation];
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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,34 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.schema = exports.entities = void 0;
18
- /* IMPORT ENTITIES AND RESOLVERS */
19
- const attachment_1 = require("./attachment");
20
- /* EXPORT ENTITY TYPES */
21
- __exportStar(require("./attachment/attachment"), exports);
22
- /* EXPORT TYPES */
23
- __exportStar(require("./attachment/attachment-types"), exports);
24
- exports.entities = [
25
- /* ENTITIES */
26
- ...attachment_1.entities
27
- ];
28
- exports.schema = {
29
- resolverClasses: [
30
- /* RESOLVER CLASSES */
31
- ...attachment_1.resolvers
32
- ]
33
- };
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAmC;AACnC,6CAA6F;AAE7F,yBAAyB;AACzB,0DAAuC;AACvC,kBAAkB;AAClB,gEAA6C;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"}
@@ -1,74 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const fs = __importStar(require("fs"));
27
- const mkdirp = __importStar(require("mkdirp"));
28
- const path_1 = require("path");
29
- const uuid_1 = require("uuid");
30
- const env_1 = require("@things-factory/env");
31
- const attachment_const_1 = require("./attachment-const");
32
- const send = require('koa-send');
33
- if (attachment_const_1.STORAGE && attachment_const_1.STORAGE.type == 'file') {
34
- const uploadDir = env_1.config.getPath(null, attachment_const_1.STORAGE.base || 'attachments');
35
- attachment_const_1.STORAGE.uploadFile = ({ stream, filename }) => {
36
- mkdirp.sync(uploadDir);
37
- const id = (0, uuid_1.v4)();
38
- const ext = filename.split('.').pop();
39
- const path = ext ? (0, path_1.resolve)(uploadDir, `${id}.${ext}`) : (0, path_1.resolve)(uploadDir, id);
40
- const relativePath = path.split('\\').pop().split('/').pop();
41
- var size = 0;
42
- return new Promise((resolve, reject) => stream
43
- .on('error', error => {
44
- if (stream.truncated)
45
- // Delete the truncated file
46
- fs.unlinkSync(path);
47
- reject(error);
48
- })
49
- .pipe(fs.createWriteStream(path))
50
- .on('error', error => reject(error))
51
- .on('data', chunk => (size += chunk.length))
52
- .on('finish', () => resolve({ id, path: relativePath, size })));
53
- };
54
- attachment_const_1.STORAGE.deleteFile = async (path) => {
55
- const fullpath = (0, path_1.resolve)(uploadDir, path);
56
- await fs.unlink(fullpath, env_1.logger.error);
57
- };
58
- attachment_const_1.STORAGE.sendFile = async (context, attachment, next) => {
59
- await send(context, attachment, { root: uploadDir });
60
- };
61
- attachment_const_1.STORAGE.readFile = (attachment, encoding) => {
62
- const fullpath = (0, path_1.resolve)(uploadDir, attachment);
63
- return fs.readFileSync(fullpath, encoding);
64
- };
65
- attachment_const_1.STORAGE.generateUploadURL = async (type) => {
66
- const id = (0, uuid_1.v4)();
67
- return await {
68
- url: `/${attachment_const_1.ATTACHMENT_PATH}`,
69
- fields: {}
70
- };
71
- };
72
- env_1.logger.info('File Storage is Ready.');
73
- }
74
- //# sourceMappingURL=storage-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage-file.js","sourceRoot":"","sources":["../server/storage-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,+CAAgC;AAChC,+BAA8B;AAC9B,+BAAmC;AAEnC,6CAAoD;AAEpD,yDAA6D;AAE7D,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,IAAA,SAAM,GAAE,CAAA;QACnB,MAAM,GA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CAAA;QAEzC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAM,CAAC,KAAK,CAAC,CAAA;IACzC,CAAC,CAAA;IAED,0BAAO,CAAC,QAAQ,GAAG,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;QACrD,MAAM,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IACtD,CAAC,CAAA;IAED,0BAAO,CAAC,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,IAAA,SAAM,GAAE,CAAA;QAEnB,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"}
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const uuid_1 = require("uuid");
4
- const client_s3_1 = require("@aws-sdk/client-s3");
5
- const lib_storage_1 = require("@aws-sdk/lib-storage");
6
- const s3_presigned_post_1 = require("@aws-sdk/s3-presigned-post");
7
- const env_1 = require("@things-factory/env");
8
- const attachment_const_1 = require("./attachment-const");
9
- const mime = require('mime');
10
- const { fs } = require('memfs');
11
- if (attachment_const_1.STORAGE && attachment_const_1.STORAGE.type == 's3') {
12
- const client = new client_s3_1.S3Client({
13
- credentials: {
14
- accessKeyId: attachment_const_1.STORAGE.accessKeyId,
15
- secretAccessKey: attachment_const_1.STORAGE.secretAccessKey
16
- },
17
- region: attachment_const_1.STORAGE.region
18
- });
19
- const streamToBuffer = (stream) => new Promise((resolve, reject) => {
20
- const chunks = [];
21
- stream.on('data', chunk => chunks.push(chunk));
22
- stream.once('end', () => resolve(Buffer.concat(chunks)));
23
- stream.once('error', reject);
24
- });
25
- /* upload file */
26
- attachment_const_1.STORAGE.uploadFile = async ({ stream, filename }) => {
27
- const id = (0, uuid_1.v4)();
28
- const ext = filename.split('.').pop();
29
- const key = ext ? `${id}.${ext}` : id;
30
- var size = 0;
31
- const upload = new lib_storage_1.Upload({
32
- client,
33
- params: {
34
- Bucket: attachment_const_1.STORAGE.bucketName,
35
- Key: key,
36
- Body: stream
37
- // ContentType: 'text/plain',
38
- }
39
- });
40
- const result = (await upload.done());
41
- return {
42
- id,
43
- path: key,
44
- size
45
- };
46
- };
47
- attachment_const_1.STORAGE.deleteFile = async (path) => {
48
- const command = new client_s3_1.DeleteObjectCommand({
49
- Bucket: attachment_const_1.STORAGE.bucketName,
50
- Key: path
51
- });
52
- return await client.send(command);
53
- };
54
- /* TODO Streaming to Streaming 으로 구현하라. */
55
- attachment_const_1.STORAGE.sendFile = async (context, attachment, next) => {
56
- const result = await client.send(new client_s3_1.GetObjectCommand({
57
- Bucket: attachment_const_1.STORAGE.bucketName,
58
- Key: attachment
59
- }));
60
- context.set({
61
- 'Content-Length': result.ContentLength,
62
- 'Content-Type': mime.getType(attachment),
63
- 'Last-Modified': result.LastModified.toUTCString(),
64
- ETag: result.ETag,
65
- 'Cache-Control': 'public, max-age=31556926'
66
- });
67
- context.body = result.Body;
68
- };
69
- attachment_const_1.STORAGE.readFile = async (attachment, encoding) => {
70
- /*
71
- * refered to
72
- * https://transang.me/modern-fetch-and-how-to-get-buffer-output-from-aws-sdk-v3-getobjectcommand/#the-body-type
73
- */
74
- const result = await client.send(new client_s3_1.GetObjectCommand({
75
- Bucket: attachment_const_1.STORAGE.bucketName,
76
- Key: attachment
77
- }));
78
- var body = result.Body;
79
- var buffer = await streamToBuffer(body);
80
- switch (encoding) {
81
- case 'base64':
82
- return buffer.toString('base64');
83
- default:
84
- return await buffer;
85
- }
86
- };
87
- attachment_const_1.STORAGE.generateUploadURL = async (type) => {
88
- const expiresInMinutes = 1;
89
- const id = (0, uuid_1.v4)();
90
- return await (0, s3_presigned_post_1.createPresignedPost)(client, {
91
- Bucket: attachment_const_1.STORAGE.bucketName,
92
- Key: id,
93
- Expires: expiresInMinutes * 60,
94
- Conditions: [['eq', '$Content-Type', type]]
95
- });
96
- };
97
- env_1.logger.info('S3 Bucket Storage is Ready.');
98
- }
99
- //# sourceMappingURL=storage-s3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage-s3.js","sourceRoot":"","sources":["../server/storage-s3.ts"],"names":[],"mappings":";;AACA,+BAAmC;AAEnC,kDAA2G;AAC3G,sDAA6C;AAC7C,kEAAgE;AAChE,6CAA4C;AAE5C,yDAA4C;AAE5C,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;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A,SAAM,GAAE,CAAA;QAEnB,OAAO,MAAM,IAAA,uCAAmB,EAAC,MAAM,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"}
@@ -1,19 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./upload-awb"), exports);
18
- __exportStar(require("./upload-invoice"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/util/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,mDAAgC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadAwb = void 0;
4
- require("../awb-storage-s3");
5
- const attachment_const_1 = require("../attachment-const");
6
- async function uploadAwb(param) {
7
- const { content, title } = param;
8
- let result = await attachment_const_1.AWBSTORAGE.uploadFile({ stream: content, filename: title });
9
- return result;
10
- }
11
- exports.uploadAwb = uploadAwb;
12
- //# sourceMappingURL=upload-awb.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-awb.js","sourceRoot":"","sources":["../../server/util/upload-awb.ts"],"names":[],"mappings":";;;AAAA,6BAA0B;AAE1B,0DAAgD;AAEzC,KAAK,UAAU,SAAS,CAAC,KAAU;IACxC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;IAEhC,IAAI,MAAM,GAAG,MAAM,6BAAU,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;IAE9E,OAAO,MAAM,CAAA;AACf,CAAC;AAND,8BAMC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadInvoice = void 0;
4
- require("../invoice-storage-s3");
5
- const attachment_const_1 = require("../attachment-const");
6
- async function uploadInvoice(param) {
7
- const { content, title } = param;
8
- let result = await attachment_const_1.INVSTORAGE.uploadInvoiceS3({ stream: content, filename: title });
9
- return result;
10
- }
11
- exports.uploadInvoice = uploadInvoice;
12
- //# sourceMappingURL=upload-invoice.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload-invoice.js","sourceRoot":"","sources":["../../server/util/upload-invoice.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAC9B,0DAAgD;AAEzC,KAAK,UAAU,aAAa,CAAC,KAAU;IAC1C,MAAM,EAAC,OAAO,EAAE,KAAK,EAAC,GAAG,KAAK,CAAA;IAE9B,IAAI,MAAM,GAAG,MAAM,6BAAU,CAAC,eAAe,CAAC,EAAE,MAAM,EAAG,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;IAEpF,OAAO,MAAM,CAAA;AAEjB,CAAC;AAPD,sCAOC"}