exodus-framework 2.0.9996 → 2.0.9998

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ export interface IMetaFile {
2
+ originalName: string;
3
+ extension: string;
4
+ size: number;
5
+ md5: string;
6
+ cachedAt: string;
7
+ }
8
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../src/services/file/contracts/meta.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -35,9 +35,9 @@ class FileService extends _service.default {
35
35
  });
36
36
  }
37
37
  async save(filename, destiny) {
38
- const p = _app.Core.settings.getAppication().filePaths.temporary + '/' + filename;
39
- const d = _app.Core.settings.getAppication().filePaths[destiny] + '/' + filename;
40
- return await fsPromisses.rename(p, d).then(() => d).catch(e => {
38
+ const tempFilePath = _app.Core.settings.getAppication().filePaths.temporary + '/' + filename;
39
+ const saveFilePath = _app.Core.settings.getAppication().filePaths[destiny] + '/' + filename;
40
+ return await fsPromisses.rename(tempFilePath, saveFilePath).then(() => saveFilePath).catch(e => {
41
41
  _logger.default.logger().error({
42
42
  filename,
43
43
  destiny,
@@ -10,5 +10,6 @@ export { default as LoggerService } from './logger';
10
10
  export { default as EcosystemService } from './ecosystem';
11
11
  export { default as TestService } from './test';
12
12
  export { default as DatabaseService } from './database';
13
+ export { default as FileLibraryService } from './file/FileLibrary';
13
14
  export * from './task';
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,YAAY,CAAC;AACxD,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,cAAc,QAAQ,CAAC"}
@@ -15,7 +15,8 @@ var _exportNames = {
15
15
  LoggerService: true,
16
16
  EcosystemService: true,
17
17
  TestService: true,
18
- DatabaseService: true
18
+ DatabaseService: true,
19
+ FileLibraryService: true
19
20
  };
20
21
  Object.defineProperty(exports, "DatabaseService", {
21
22
  enumerable: true,
@@ -35,6 +36,12 @@ Object.defineProperty(exports, "ExpressService", {
35
36
  return _express.default;
36
37
  }
37
38
  });
39
+ Object.defineProperty(exports, "FileLibraryService", {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _FileLibrary.default;
43
+ }
44
+ });
38
45
  Object.defineProperty(exports, "FileService", {
39
46
  enumerable: true,
40
47
  get: function () {
@@ -101,6 +108,7 @@ var _logger = _interopRequireDefault(require("./logger"));
101
108
  var _ecosystem = _interopRequireDefault(require("./ecosystem"));
102
109
  var _test = _interopRequireDefault(require("./test"));
103
110
  var _database = _interopRequireDefault(require("./database"));
111
+ var _FileLibrary = _interopRequireDefault(require("./file/FileLibrary"));
104
112
  var _task = require("./task");
105
113
  Object.keys(_task).forEach(function (key) {
106
114
  if (key === "default" || key === "__esModule") return;
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/utils/database.ts"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AE,EAAE,iBAalD"}
@@ -9,6 +9,7 @@ exports.processFilters = processFilters;
9
9
  var _sequelize = require("sequelize");
10
10
  var _core = _interopRequireDefault(require("../app/core"));
11
11
  var _error = require("../app/error");
12
+ var _dateFns = require("date-fns");
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
14
  const mainDb = exports.mainDb = new _sequelize.Sequelize({
14
15
  database: _core.default.settings.getDatabase().main.database,
@@ -78,9 +79,26 @@ function processDateCondition(key, cond) {
78
79
  simpleWhere[1] = [(0, _sequelize.literal)(`DATE(${key}) < '${cond.lt}'`)];
79
80
  }
80
81
  if (cond.between !== undefined) {
82
+ const start = cond.between[0];
83
+ const end = cond.between[1];
84
+
85
+ // console.log(start, end);
86
+
87
+ let startDate = (0, _dateFns.parseISO)(start);
88
+ if ((0, _dateFns.isValid)(startDate) && !hasTime(start)) {
89
+ // console.log('Ajustando início do dia');
90
+ startDate = (0, _dateFns.startOfDay)(startDate);
91
+ }
92
+ let endDate = (0, _dateFns.parseISO)(end);
93
+ if ((0, _dateFns.isValid)(endDate) && !hasTime(end)) {
94
+ // console.log('Ajustando fim do dia');
95
+ endDate = (0, _dateFns.endOfDay)(endDate);
96
+ }
81
97
  simpleWhere[1] = {
82
- [_sequelize.Op.between]: cond.between.map(d => new Date(d))
98
+ [_sequelize.Op.between]: [startDate, endDate]
83
99
  };
100
+
101
+ // console.log('Condição entre processada:', simpleWhere[1]);
84
102
  }
85
103
  if (cond.notBetween !== undefined) {
86
104
  simpleWhere[1] = {
@@ -154,4 +172,8 @@ async function InsertIndexes(context, tableName, indexes) {
154
172
  console.log('tentativa de adicionar index falhou');
155
173
  }
156
174
  }
175
+ }
176
+ function hasTime(str) {
177
+ const timeRegex = /\b\d{1,2}:\d{2}(:\d{2})?\b/;
178
+ return timeRegex.test(str);
157
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodus-framework",
3
- "version": "2.0.9996",
3
+ "version": "2.0.9998",
4
4
  "description": "Exodus Framework",
5
5
  "author": "jhownpaixao",
6
6
  "license": "ISC",
@@ -38,6 +38,7 @@
38
38
  "express-jwt": "^8.4.1",
39
39
  "express-requests-logger": "^4.0.1",
40
40
  "fs": "^0.0.1-security",
41
+ "fs-extra": "^11.3.0",
41
42
  "install": "^0.13.0",
42
43
  "lodash": "^4.17.21",
43
44
  "mariadb": "^3.3.1",
@@ -69,6 +70,7 @@
69
70
  "@types/cors": "^2.8.17",
70
71
  "@types/express": "^4.17.21",
71
72
  "@types/express-requests-logger": "^4.0.0",
73
+ "@types/fs-extra": "^11.0.4",
72
74
  "@types/lodash": "^4.17.7",
73
75
  "@types/multer": "^1.4.12",
74
76
  "@types/node": "^22.5.0",
@@ -1 +0,0 @@
1
- //# sourceMappingURL=file_new.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file_new.d.ts","sourceRoot":"","sources":["../../src/services/file_new.ts"],"names":[],"mappings":""}
@@ -1,136 +0,0 @@
1
- // import { createHash } from 'crypto';
2
- // import * as fs from 'fs';
3
- // import * as fsPromisses from 'fs/promises';
4
- // import NodeCache from 'node-cache';
5
- // import { Core, ErrorHandler } from '../app';
6
- // import Service from '../app/classes/service';
7
- // import { TFilePathSettings } from '../contracts/settings';
8
- // import LoggerService from './logger';
9
-
10
- // class FileService extends Service {
11
- // protected cache: NodeCache;
12
-
13
- // async onServiceInit() {
14
- // this.cache = new NodeCache();
15
- // await Promise.all([this.checkPaths(), this.cleanTemp()]);
16
- // }
17
-
18
- // //# Managment
19
- // async save(filename: string, destiny: keyof TFilePathSettings) {
20
- // const p = Core.settings.getAppication().filePaths.temporary + '/' + filename;
21
- // const d = Core.settings.getAppication().filePaths[destiny] + '/' + filename;
22
-
23
- // try {
24
- // const md5 = await this.getMD5FromFile(p);
25
-
26
- // if (this.cache.has(md5)) {
27
- // return true;
28
- // }
29
-
30
- // await this.move(p, d);
31
- // this.cache.set(md5, d);
32
-
33
- // return true;
34
- // } catch (error) {
35
- // new ErrorHandler('Não foi possível salva o arquivo', error);
36
- // return false;
37
- // }
38
- // }
39
- // async delete(filename: string, destiny: keyof TFilePathSettings) {
40
- // const d = Core.settings.getAppication().filePaths[destiny] + '/' + filename;
41
- // return await fsPromisses
42
- // .unlink(d)
43
- // .then(() => true)
44
- // .catch((e) => {
45
- // LoggerService.logger().error({ filename, destiny, erro: e }, 'Não foi possível deletar o arquivo');
46
- // return false;
47
- // });
48
- // }
49
- // async move(to: string, from: string) {
50
- // return await fsPromisses
51
- // .rename(to, from)
52
- // .then((d) => d)
53
- // .catch((e) => {
54
- // LoggerService.logger().error({ to, from, erro: e }, 'Não foi possível mover o arquivo');
55
- // return false;
56
- // });
57
- // }
58
-
59
- // //# Getters
60
- // public getBuffer(filename: string, destiny: keyof TFilePathSettings) {
61
- // const d = Core.settings.getAppication().filePaths[destiny] + '/' + filename;
62
-
63
- // return new Promise((resolve, reject) => {
64
- // this.getMD5FromFile(d).then();
65
-
66
- // fsPromisses
67
- // .readFile(path)
68
- // .then(cb)
69
- // .catch((e) => {
70
- // logger.error({ path, erro: e }, 'Não foi possível ler o arquivo', path);
71
- // });
72
- // });
73
- // }
74
- // /* public getStatByMD5(filename: string, destiny: keyof TFilePathSettings) {
75
- // const p = this.getPathByMD5(md5);
76
- // if (!p) return;
77
- // return fs.statSync(p);
78
- // } */
79
-
80
- // //# Utils
81
- // private async checkPaths() {
82
- // for (const path of Object.values(Core.settings.getAppication().filePaths)) {
83
- // !fs.existsSync(path) && fs.mkdirSync(path, { recursive: true });
84
- // }
85
- // }
86
- // private async cleanTemp() {
87
- // this.listFiles('temporary', (files) => {
88
- // for (const file of files) {
89
- // const p = Core.settings.getAppication().filePaths.temporary + '/' + file;
90
- // fs.rmSync(p, { recursive: true });
91
- // }
92
- // });
93
- // }
94
- // public listFiles(origin: keyof TFilePathSettings, cb: (file: string[]) => void) {
95
- // const p = Core.settings.getAppication().filePaths[origin];
96
- // fs.readdir(p, (_, file) => cb(file));
97
- // }
98
-
99
- // //# MD5
100
- // public getMD5FromFile(filePath: string) {
101
- // return new Promise<string>((resolve, reject) => {
102
- // const hash = createHash('md5');
103
- // const stream = fs.createReadStream(filePath);
104
-
105
- // stream.on('data', (dados) => hash.update(dados));
106
- // stream.on('error', (error) => reject(error));
107
- // stream.on('end', () => resolve(hash.digest('hex')));
108
- // });
109
- // }
110
- // public getMD5FromBuffer(buffer: Buffer) {
111
- // const hash = createHash('md5');
112
- // hash.update(buffer);
113
- // return hash.digest('hex');
114
- // }
115
-
116
- // //# Cache
117
- // public loadCache() {}
118
- // public async hasCached(filePath: string) {
119
- // const md5 = await this.getMD5FromFile(filePath);
120
-
121
- // return this.cache.has(md5);
122
- // }
123
- // //!imcomplete
124
- // /* public async loadItem(filename: string, origin: keyof TFilePathSettings) {
125
- // try {
126
- // const p = Core.settings.getAppication().filePaths[origin] + '/' + filename;
127
- // const md5 = await this.getMD5FromFile(p);
128
-
129
- // return md5;
130
- // } catch (error) {
131
- // return;
132
- // }
133
- // } */
134
- // }
135
- // export default FileService;
136
- "use strict";