@scefira/dfw 1.2.9 → 1.2.11

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/index.d.ts CHANGED
@@ -6,4 +6,6 @@ export { default as DFWCore } from './lib/DFWCore';
6
6
  export { default as DFWUtils } from "./lib/DFWUtils";
7
7
  export { default as DFWModule } from './lib/DFWModule';
8
8
  export { default as DFWService } from './lib/DFWService';
9
+ export { UploadedFile } from "express-fileupload";
10
+ export { SavedFileParams } from "./modules/DFWFileModule";
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAE3B,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAE3B,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA"}
@@ -1,14 +1,34 @@
1
1
  import DFWModule from "../lib/DFWModule";
2
2
  import { UploadedFile } from "express-fileupload";
3
- type SaveFileOptions = {
3
+ import { DFW_FILE_STORAGE } from "@prisma/client";
4
+ export type SavedFileParams = {
4
5
  name?: string;
5
6
  variant?: string;
6
7
  expire?: Date;
7
8
  idParent?: string;
8
- makeUrl: (filePath: string) => string;
9
+ url?: string;
10
+ storage?: DFW_FILE_STORAGE;
11
+ idUser?: string;
9
12
  };
10
13
  declare class DFWFileModule extends DFWModule {
11
- saveUploadedFileAsync: (file: UploadedFile, { name, expire, idParent, variant, makeUrl }: SaveFileOptions) => Promise<{
14
+ createFileRecordAsync: (file: UploadedFile, { name, idUser, url, storage, expire, idParent, variant }?: SavedFileParams, extraFields?: object) => Promise<{
15
+ variant: string | null;
16
+ name: string | null;
17
+ id: string;
18
+ url: string | null;
19
+ metadata: import("@prisma/client/runtime/library").JsonValue | null;
20
+ path: string | null;
21
+ storage: import(".prisma/client").$Enums.DFW_FILE_STORAGE;
22
+ size: number | null;
23
+ createdAt: Date;
24
+ updatedAt: Date;
25
+ idUser: string | null;
26
+ checksum: string | null;
27
+ mimetype: string | null;
28
+ expire: Date | null;
29
+ idParent: string | null;
30
+ }>;
31
+ saveFileLocalAsync: (file: UploadedFile, params?: SavedFileParams) => Promise<{
12
32
  variant: string | null;
13
33
  name: string | null;
14
34
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"DFWFileModule.d.ts","sourceRoot":"","sources":["../../src/modules/DFWFileModule.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQlD,KAAK,eAAe,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,IAAI,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;CACxC,CAAA;AAED,cAAM,aAAc,SAAQ,SAAS;IAEjC,qBAAqB,GAAU,MAAM,YAAY,EAAE,8CAA8C,eAAe;;;;;;;;;;;;;;;;OA0B/G;IAED,oBAAoB,GAAI,SAAS,MAAM,YAEtC;CACJ;AAED,eAAe,aAAa,CAAA"}
1
+ {"version":3,"file":"DFWFileModule.d.ts","sourceRoot":"","sources":["../../src/modules/DFWFileModule.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlD,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,IAAI,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,cAAM,aAAc,SAAQ,SAAS;IAEjC,qBAAqB,GAAU,MAAM,YAAY,EAAE,4DAA2D,eAAoB,EAAE,cAAc,MAAM;;;;;;;;;;;;;;;;OAgBvJ;IAED,kBAAkB,GAAU,MAAM,YAAY,EAAE,SAAQ,eAAoB;;;;;;;;;;;;;;;;OAc3E;IAED,oBAAoB,GAAI,SAAS,MAAM,YAEtC;CACJ;AAED,eAAe,aAAa,CAAA"}
@@ -14,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const DFWModule_1 = __importDefault(require("../lib/DFWModule"));
16
16
  const util_1 = require("util");
17
- const client_1 = require("@prisma/client");
18
17
  const luxon_1 = require("luxon");
19
18
  const path_1 = __importDefault(require("path"));
20
19
  const DFWUtils_1 = __importDefault(require("../lib/DFWUtils"));
@@ -23,7 +22,17 @@ const __1 = require("..");
23
22
  class DFWFileModule extends DFWModule_1.default {
24
23
  constructor() {
25
24
  super(...arguments);
26
- this.saveUploadedFileAsync = (file_1, _a) => __awaiter(this, [file_1, _a], void 0, function* (file, { name, expire, idParent, variant, makeUrl }) {
25
+ this.createFileRecordAsync = (file_1, ...args_1) => __awaiter(this, [file_1, ...args_1], void 0, function* (file, { name, idUser, url, storage, expire, idParent, variant } = {}, extraFields) {
26
+ return this.db.dfw_file.create({
27
+ data: Object.assign({ name: name !== null && name !== void 0 ? name : file.name, size: file.size, mimetype: file.mimetype, checksum: file.md5, url,
28
+ idUser,
29
+ storage,
30
+ expire,
31
+ idParent,
32
+ variant }, extraFields)
33
+ });
34
+ });
35
+ this.saveFileLocalAsync = (file_1, ...args_1) => __awaiter(this, [file_1, ...args_1], void 0, function* (file, params = {}) {
27
36
  const filePath = luxon_1.DateTime.now().toFormat("yyyy/MM");
28
37
  const fileName = DFWUtils_1.default.uuid();
29
38
  const ext = path_1.default.extname(file.name);
@@ -32,20 +41,7 @@ class DFWFileModule extends DFWModule_1.default {
32
41
  const moveAsync = (0, util_1.promisify)(file.mv);
33
42
  fs_1.default.mkdirSync(localPath, { recursive: true });
34
43
  yield moveAsync(localFilePath);
35
- return this.db.dfw_file.create({
36
- data: {
37
- name: name !== null && name !== void 0 ? name : file.name,
38
- size: file.size,
39
- mimetype: file.mimetype,
40
- checksum: file.md5,
41
- url: makeUrl(`${filePath}/${fileName}${ext !== null && ext !== void 0 ? ext : ''}`),
42
- path: localFilePath,
43
- storage: client_1.DFW_FILE_STORAGE.LOCAL,
44
- expire,
45
- idParent,
46
- variant
47
- }
48
- });
44
+ return this.createFileRecordAsync(file, params, { path: localFilePath });
49
45
  });
50
46
  this.generateTempFileName = (posfix) => {
51
47
  return path_1.default.join(this.DFW.tmpDir, `${DFWUtils_1.default.uuid()}${posfix !== null && posfix !== void 0 ? posfix : ""}`);
@@ -1 +1 @@
1
- {"version":3,"file":"DFWFileModule.js","sourceRoot":"","sources":["../../src/modules/DFWFileModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iEAAyC;AACzC,+BAAiC;AAEjC,2CAAkD;AAClD,iCAAiC;AACjC,gDAAwB;AACxB,+DAAuC;AACvC,4CAAoB;AACpB,0BAA6B;AAU7B,MAAM,aAAc,SAAQ,mBAAS;IAArC;;QAEI,0BAAqB,GAAG,aAA0F,EAAE,kDAArF,IAAkB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAmB;YAC5G,MAAM,QAAQ,GAAG,gBAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;YACnD,MAAM,QAAQ,GAAG,kBAAQ,CAAC,IAAI,EAAE,CAAA;YAChC,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACnC,MAAM,SAAS,GAAG,GAAG,WAAO,CAAC,cAAc,IAAI,QAAQ,EAAE,CAAA;YACzD,MAAM,aAAa,GAAG,GAAG,SAAS,IAAI,QAAQ,GAAG,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,EAAE,CAAA;YAC5D,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAEpC,YAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YAE5C,MAAM,SAAS,CAAC,aAAa,CAAC,CAAA;YAE9B,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAC3B,IAAI,EAAE;oBACF,IAAI,EAAE,IA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AAI,EAAE,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,EAAE,CAAC,CAAC;QAC3E,CAAC,CAAA;IACL,CAAC;CAAA;AAED,kBAAe,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,65 +1,66 @@
1
- {
2
- "name": "@scefira/dfw",
3
- "version": "1.2.9",
4
- "description": "NodeJS fast API prototiping framework",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "dist/**/*",
9
- "prisma/**/*"
10
- ],
11
- "author": "Scefira Technologies",
12
- "license": "ISC",
13
- "peerDependencies": {
14
- "@prisma/client": "^6",
15
- "zod": "^4"
16
- },
17
- "prisma": {
18
- "schema": "./prisma/schema"
19
- },
20
- "dependencies": {
21
- "@paralleldrive/cuid2": "^2.2.2",
22
- "@types/express": "^5.0.3",
23
- "@types/express-fileupload": "^1.5.1",
24
- "@types/express-session": "^1.18.2",
25
- "@types/luxon": "^3",
26
- "@types/passport": "^1.0.17",
27
- "bcrypt": "^6.0.0",
28
- "body-parser": "^2.2.0",
29
- "chalk": "^4.1.2",
30
- "cors": "^2.8.5",
31
- "express": "^5.1.0",
32
- "express-fileupload": "^1.5.2",
33
- "express-session": "^1.18.2",
34
- "lru.min": "^1.1.2",
35
- "luxon": "^3",
36
- "md5-file": "^5.0.0",
37
- "mime-types": "^2.1.35",
38
- "passport": "^0.7.0",
39
- "passport-local": "^1.0.0",
40
- "uuid": "^11.0.3"
41
- },
42
- "devDependencies": {
43
- "@types/bcrypt": "^5.0.2",
44
- "@types/body-parser": "^1.19.2",
45
- "@types/busboy": "^1.3.0",
46
- "@types/cookie-parser": "^1.4.2",
47
- "@types/cors": "^2.8.17",
48
- "@types/md5-file": "^5.0.0",
49
- "@types/mime-types": "^2.1.1",
50
- "@types/node": "^20.4.2",
51
- "@types/passport-local": "^1.0.38",
52
- "@types/uuid": "^8.3.4",
53
- "cross-env": "^7.0.3",
54
- "nodemon": "^3.1.4",
55
- "prisma": "^6",
56
- "ts-node": "^10.9.2",
57
- "typescript": "^5.5.4"
58
- },
59
- "scripts": {
60
- "dev": "nodemon",
61
- "dev:prisma": "dotenv -e .env.development -- npx prisma studio",
62
- "build": "tsc",
63
- "sync": "npx prisma db push"
64
- }
1
+ {
2
+ "name": "@scefira/dfw",
3
+ "version": "1.2.11",
4
+ "description": "NodeJS fast API prototiping framework",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*",
9
+ "prisma/**/*"
10
+ ],
11
+ "scripts": {
12
+ "dev": "nodemon",
13
+ "dev:prisma": "dotenv -e .env.development -- npx prisma studio",
14
+ "build": "tsc",
15
+ "sync": "npx prisma db push",
16
+ "prepublishOnly": "npm run build"
17
+ },
18
+ "author": "Scefira Technologies",
19
+ "license": "ISC",
20
+ "peerDependencies": {
21
+ "@prisma/client": "^6",
22
+ "zod": "^4"
23
+ },
24
+ "prisma": {
25
+ "schema": "./prisma/schema"
26
+ },
27
+ "dependencies": {
28
+ "@paralleldrive/cuid2": "^2.2.2",
29
+ "@types/express": "^5.0.3",
30
+ "@types/express-fileupload": "^1.5.1",
31
+ "@types/express-session": "^1.18.2",
32
+ "@types/luxon": "^3",
33
+ "@types/passport": "^1.0.17",
34
+ "bcrypt": "^6.0.0",
35
+ "body-parser": "^2.2.0",
36
+ "chalk": "^4.1.2",
37
+ "cors": "^2.8.5",
38
+ "express": "^5.1.0",
39
+ "express-fileupload": "^1.5.2",
40
+ "express-session": "^1.18.2",
41
+ "lru.min": "^1.1.2",
42
+ "luxon": "^3",
43
+ "md5-file": "^5.0.0",
44
+ "mime-types": "^2.1.35",
45
+ "passport": "^0.7.0",
46
+ "passport-local": "^1.0.0",
47
+ "uuid": "^11.0.3"
48
+ },
49
+ "devDependencies": {
50
+ "@types/bcrypt": "^5.0.2",
51
+ "@types/body-parser": "^1.19.2",
52
+ "@types/busboy": "^1.3.0",
53
+ "@types/cookie-parser": "^1.4.2",
54
+ "@types/cors": "^2.8.17",
55
+ "@types/md5-file": "^5.0.0",
56
+ "@types/mime-types": "^2.1.1",
57
+ "@types/node": "^20.4.2",
58
+ "@types/passport-local": "^1.0.38",
59
+ "@types/uuid": "^8.3.4",
60
+ "cross-env": "^7.0.3",
61
+ "nodemon": "^3.1.4",
62
+ "prisma": "^6",
63
+ "ts-node": "^10.9.2",
64
+ "typescript": "^5.5.4"
65
+ }
65
66
  }