@scefira/dfw 0.1.15 → 0.2.1

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 (42) hide show
  1. package/lib/DFWInstance.d.ts +20 -20
  2. package/lib/DFWInstance.js +55 -55
  3. package/lib/DFWUtils.d.ts +27 -27
  4. package/lib/DFWUtils.js +63 -63
  5. package/lib/DFWUtils.js.map +1 -1
  6. package/lib/index.d.ts +10 -10
  7. package/lib/index.js +25 -25
  8. package/lib/manager/APIManager.d.ts +47 -47
  9. package/lib/manager/APIManager.d.ts.map +1 -1
  10. package/lib/manager/APIManager.js +207 -233
  11. package/lib/manager/APIManager.js.map +1 -1
  12. package/lib/manager/DFWModule.d.ts +13 -13
  13. package/lib/manager/DFWModule.js +19 -19
  14. package/lib/manager/DatabaseManager.d.ts +8 -8
  15. package/lib/manager/DatabaseManager.js +24 -24
  16. package/lib/manager/FileManager.d.ts +130 -130
  17. package/lib/manager/FileManager.js +254 -254
  18. package/lib/manager/SecurityManager.d.ts +50 -50
  19. package/lib/manager/SecurityManager.d.ts.map +1 -1
  20. package/lib/manager/SecurityManager.js +187 -191
  21. package/lib/manager/SecurityManager.js.map +1 -1
  22. package/lib/manager/SessionManager.d.ts +40 -40
  23. package/lib/manager/SessionManager.d.ts.map +1 -1
  24. package/lib/manager/SessionManager.js +195 -173
  25. package/lib/manager/SessionManager.js.map +1 -1
  26. package/lib/manager/UserManager.d.ts +42 -42
  27. package/lib/manager/UserManager.js +62 -62
  28. package/lib/test.d.ts +1 -1
  29. package/lib/test.js +70 -70
  30. package/lib/test.js.map +1 -1
  31. package/lib/types/APIListenerConfig.d.ts +52 -52
  32. package/lib/types/APIListenerConfig.js +2 -2
  33. package/lib/types/DFWBoot.d.ts +18 -18
  34. package/lib/types/DFWBoot.d.ts.map +1 -1
  35. package/lib/types/DFWBoot.js +2 -2
  36. package/lib/types/DFWConfig.d.ts +54 -54
  37. package/lib/types/DFWConfig.js +2 -2
  38. package/lib/types/DFWRequestScheme.d.ts +33 -37
  39. package/lib/types/DFWRequestScheme.d.ts.map +1 -1
  40. package/lib/types/DFWRequestScheme.js +2 -2
  41. package/package.json +4 -3
  42. package/prisma/schema.prisma +5 -27
package/lib/test.js CHANGED
@@ -1,71 +1,71 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const _1 = require(".");
13
- var DFW = _1.DFWCore.createInstance({
14
- session: {
15
- cookieOptions: {
16
- sameSite: "lax",
17
- secure: false,
18
- httpOnly: true,
19
- domain: "localhost",
20
- maxAge: 60 * 1000 * 60 * 24 * 365 // 365 days
21
- }
22
- }
23
- });
24
- //DFW.DatabaseManager.database.sync();
25
- DFW.APIManager.startServer(300);
26
- DFW.APIManager.addListener("/", (req, res) => __awaiter(void 0, void 0, void 0, function* () {
27
- return DFW.FileManager.removeFileAsync(1);
28
- }));
29
- DFW.APIManager.addListener("/login", (req, res, dfw) => __awaiter(void 0, void 0, void 0, function* () {
30
- yield dfw.SessionManager.loginAsync(req, "aldodelacomarca@gmail.com", "Aldo1234");
31
- return dfw.boot();
32
- }));
33
- DFW.APIManager.addListener("/logout", (req, res, dfw) => __awaiter(void 0, void 0, void 0, function* () {
34
- yield req.dfw.SessionManager.logoutAsync(req);
35
- return dfw.boot();
36
- }));
37
- DFW.APIManager.addListener("/security", (req, res, dfw) => __awaiter(void 0, void 0, void 0, function* () {
38
- console.log("Esto no debería haber pasado de aqui");
39
- return dfw.boot();
40
- }), {
41
- security: {
42
- session: true
43
- }
44
- });
45
- DFW.APIManager.addListener("/boot", (req, res) => __awaiter(void 0, void 0, void 0, function* () {
46
- return req.dfw.boot();
47
- }));
48
- DFW.APIManager.addListener("/file", (req, res) => __awaiter(void 0, void 0, void 0, function* () {
49
- return req.dfw.FileManager.flushUpload(req, "file", { description: "File test" });
50
- }), { method: "post", upload: true, security: { session: true } });
51
- DFW.APIManager.addListener("/error", (req, res, dfw) => __awaiter(void 0, void 0, void 0, function* () {
52
- return yield dfw.db.$transaction((db) => __awaiter(void 0, void 0, void 0, function* () {
53
- let t1 = performance.now();
54
- yield dfw.UserManager.use(db).createCredentiaASync("DUMMY-1");
55
- console.log(performance.now() - t1);
56
- throw new Error("ERROR");
57
- yield dfw.UserManager.use(db).createCredentiaASync("DUMMY-2");
58
- yield dfw.UserManager.use(db).createCredentiaASync("DUMMY-2");
59
- })).catch((e) => {
60
- throw e.message;
61
- console.log(Object.keys(e));
62
- });
63
- }));
64
- DFW.APIManager.addListener("/strap", ({ dfw }, res) => __awaiter(void 0, void 0, void 0, function* () {
65
- let newUser = yield dfw.UserManager.createUserAsync("aldodelacomarca@gmail.com", "zerozelta", "Aldo1234");
66
- let newCredential = yield dfw.SecurityManager.createCredentialAsync("ADMIN");
67
- let user = yield dfw.db.dfw_user.findUnique({ where: { id: 1 } });
68
- let credential = yield dfw.UserManager.assignCredentialAsync(user, ["ADMIN", "TESTER"]);
69
- return { credential };
70
- }));
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const _1 = require(".");
13
+ var DFW = _1.DFWCore.createInstance({
14
+ session: {
15
+ cookieOptions: {
16
+ sameSite: "lax",
17
+ secure: false,
18
+ httpOnly: true,
19
+ domain: "localhost",
20
+ maxAge: 60 * 1000 * 60 * 24 * 365 // 365 days
21
+ }
22
+ }
23
+ });
24
+ //DFW.DatabaseManager.database.sync();
25
+ DFW.APIManager.startServer(300);
26
+ DFW.APIManager.addListener("/", (req, res) => __awaiter(void 0, void 0, void 0, function* () {
27
+ return DFW.FileManager.removeFileAsync(1);
28
+ }));
29
+ DFW.APIManager.addListener("/login", (req, res, dfw) => __awaiter(void 0, void 0, void 0, function* () {
30
+ yield dfw.SessionManager.loginAsync(req, "aldodelacomarca@gmail.com", "Aldo1234");
31
+ return dfw.boot();
32
+ }));
33
+ DFW.APIManager.addListener("/logout", (req, res, dfw) => __awaiter(void 0, void 0, void 0, function* () {
34
+ yield req.dfw.SessionManager.logoutAsync(req);
35
+ return dfw.boot();
36
+ }));
37
+ DFW.APIManager.addListener("/security", (req, res, dfw) => __awaiter(void 0, void 0, void 0, function* () {
38
+ console.log("Esto no debería haber pasado de aqui");
39
+ return dfw.boot();
40
+ }), {
41
+ security: {
42
+ session: true
43
+ }
44
+ });
45
+ DFW.APIManager.addListener("/boot", (req, res) => __awaiter(void 0, void 0, void 0, function* () {
46
+ return req.dfw.boot();
47
+ }));
48
+ DFW.APIManager.addListener("/file", (req, res) => __awaiter(void 0, void 0, void 0, function* () {
49
+ return req.dfw.FileManager.flushUpload(req, "file", { description: "File test" });
50
+ }), { method: "post", upload: true, security: { session: true } });
51
+ DFW.APIManager.addListener("/error", (req, res, dfw) => __awaiter(void 0, void 0, void 0, function* () {
52
+ return yield dfw.db.$transaction((db) => __awaiter(void 0, void 0, void 0, function* () {
53
+ let t1 = performance.now();
54
+ yield dfw.UserManager.use(db).createCredentiaASync("DUMMY-1");
55
+ console.log(performance.now() - t1);
56
+ throw new Error("ERROR");
57
+ yield dfw.UserManager.use(db).createCredentiaASync("DUMMY-2");
58
+ yield dfw.UserManager.use(db).createCredentiaASync("DUMMY-2");
59
+ })).catch((e) => {
60
+ throw e.message;
61
+ console.log(Object.keys(e));
62
+ });
63
+ }));
64
+ DFW.APIManager.addListener("/strap", ({ dfw }, res) => __awaiter(void 0, void 0, void 0, function* () {
65
+ let newUser = yield dfw.UserManager.createUserAsync("test3@gmail.com", "test3", "test");
66
+ //let newCredential = await dfw.SecurityManager.createCredentialAsync("TESTER");
67
+ let user = yield dfw.db.dfw_user.findUnique({ where: { id: newUser.id } });
68
+ let credential = yield dfw.UserManager.assignCredentialAsync(user, ["ADMIN", "TESTER"]);
69
+ return { credential };
70
+ }));
71
71
  //# sourceMappingURL=test.js.map
package/lib/test.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,wBAA4B;AAE5B,IAAI,GAAG,GAAG,UAAO,CAAC,cAAc,CAAC;IAC7B,OAAO,EAAE;QACL,aAAa,EAAE;YACX,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,WAAW;SAChD;KACJ;CACJ,CAAC,CAAC;AAEH,uCAAuC;AAEvC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AAEhC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;IAC/C,OAAO,GAAG,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAA,CAAC,CAAA;AAEF,GAAG,CAAC,UAAU,CAAC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AAC,WAAW,CAAC,qBAAqB,CAAC,IAAK,EAAE,CAAC,OAAO,EAAC,QAAQ,CAAC,CAAC,CAAC;IACxF,OAAO,EAAE,UAAU,EAAE,CAAA;AACzB,CAAC,CAAA,CAAC,CAAC"}
@@ -1,53 +1,53 @@
1
- import { RequestHandler } from "express";
2
- import fileUpload from "express-fileupload";
3
- import { APIMethods } from "../manager/APIManager";
4
- import { DFWRequest } from "./DFWRequestScheme";
5
- export type APIListenerConfig = {
6
- /**
7
- *
8
- */
9
- method?: APIMethods;
10
- /**
11
- *
12
- */
13
- middleware?: RequestHandler | RequestHandler[];
14
- /**
15
- *
16
- */
17
- security?: ListenerSecurityConfig;
18
- /**
19
- * By default DFW-Express parses the request body
20
- * if parseBody is false Disables the body parse
21
- *
22
- */
23
- parseBody?: boolean;
24
- /**
25
- * allow/disallow to upload files
26
- * @default false
27
- */
28
- upload?: true | fileUpload.Options;
29
- /**
30
- * Disable the autosend system, allows you to specify what send to the clien and when
31
- */
32
- autoSend?: boolean;
33
- /**
34
- * if false the session system will be disabled for this api endpoint
35
- * @default true
36
- */
37
- noSession?: boolean;
38
- /**
39
- * Callback function after the server responses to the client (after the connection was closed)
40
- */
41
- callback?: (req: DFWRequest, objResponse: any) => Promise<void>;
42
- };
43
- export interface ListenerSecurityConfig {
44
- session?: boolean;
45
- validation?: {
46
- body?: string[];
47
- query?: string[];
48
- };
49
- bindings?: [number, any][];
50
- credentials?: number[] | string[];
51
- access?: number[] | string[];
52
- }
1
+ import { RequestHandler } from "express";
2
+ import fileUpload from "express-fileupload";
3
+ import { APIMethods } from "../manager/APIManager";
4
+ import { DFWRequest } from "./DFWRequestScheme";
5
+ export type APIListenerConfig = {
6
+ /**
7
+ *
8
+ */
9
+ method?: APIMethods;
10
+ /**
11
+ *
12
+ */
13
+ middleware?: RequestHandler | RequestHandler[];
14
+ /**
15
+ *
16
+ */
17
+ security?: ListenerSecurityConfig;
18
+ /**
19
+ * By default DFW-Express parses the request body
20
+ * if parseBody is false Disables the body parse
21
+ *
22
+ */
23
+ parseBody?: boolean;
24
+ /**
25
+ * allow/disallow to upload files
26
+ * @default false
27
+ */
28
+ upload?: true | fileUpload.Options;
29
+ /**
30
+ * Disable the autosend system, allows you to specify what send to the clien and when
31
+ */
32
+ autoSend?: boolean;
33
+ /**
34
+ * if false the session system will be disabled for this api endpoint
35
+ * @default true
36
+ */
37
+ noSession?: boolean;
38
+ /**
39
+ * Callback function after the server responses to the client (after the connection was closed)
40
+ */
41
+ callback?: (req: DFWRequest, objResponse: any) => Promise<void>;
42
+ };
43
+ export interface ListenerSecurityConfig {
44
+ session?: boolean;
45
+ validation?: {
46
+ body?: string[];
47
+ query?: string[];
48
+ };
49
+ bindings?: [number, any][];
50
+ credentials?: number[] | string[];
51
+ access?: number[] | string[];
52
+ }
53
53
  //# sourceMappingURL=APIListenerConfig.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=APIListenerConfig.js.map
@@ -1,19 +1,19 @@
1
- export type DFWBoot = {
2
- session: {
3
- user?: {
4
- id: number;
5
- nick?: string;
6
- email?: string;
7
- };
8
- credentials: {
9
- id: number;
10
- name: string;
11
- }[];
12
- access: {
13
- id: number;
14
- name: string;
15
- }[];
16
- };
17
- };
18
- export default DFWBoot;
1
+ export type DFWBoot = {
2
+ session: {
3
+ user?: {
4
+ id: number;
5
+ nick?: string;
6
+ email?: string;
7
+ credentials: {
8
+ id: number;
9
+ name: string;
10
+ access: {
11
+ id: number;
12
+ name: string;
13
+ }[];
14
+ }[];
15
+ };
16
+ };
17
+ };
18
+ export default DFWBoot;
19
19
  //# sourceMappingURL=DFWBoot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DFWBoot.d.ts","sourceRoot":"","sources":["../../src/types/DFWBoot.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IAClB,OAAO,EAAC;QACJ,IAAI,CAAC,EAAC;YACF,EAAE,EAAC,MAAM,CAAC;YACV,IAAI,CAAC,EAAC,MAAM,CAAC;YACb,KAAK,CAAC,EAAC,MAAM,CAAC;SACjB,CAAA;QACD,WAAW,EAAC;YACR,EAAE,EAAC,MAAM,CAAC;YACV,IAAI,EAAC,MAAM,CAAC;SACf,EAAE,CAAC;QACJ,MAAM,EAAC;YACH,EAAE,EAAC,MAAM,CAAC;YACV,IAAI,EAAC,MAAM,CAAC;SACf,EAAE,CAAA;KACN,CAAA;CACJ,CAAA;AAED,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"DFWBoot.d.ts","sourceRoot":"","sources":["../../src/types/DFWBoot.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IAClB,OAAO,EAAE;QACL,IAAI,CAAC,EAAE;YACH,EAAE,EAAE,MAAM,CAAC;YACX,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,WAAW,EAAE;gBACT,EAAE,EAAE,MAAM,CAAC;gBACX,IAAI,EAAE,MAAM,CAAC;gBACb,MAAM,EAAE;oBACJ,EAAE,EAAE,MAAM,CAAC;oBACX,IAAI,EAAE,MAAM,CAAC;iBAChB,EAAE,CAAA;aACN,EAAE,CAAC;SACP,CAAA;KACJ,CAAA;CACJ,CAAA;AAED,eAAe,OAAO,CAAC"}
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=DFWBoot.js.map
@@ -1,55 +1,55 @@
1
- import { CookieOptions } from "express";
2
- export type DFWConfig = {
3
- /**
4
- *
5
- */
6
- session?: {
7
- /**
8
- * Session token name space in cookie
9
- */
10
- stk?: string;
11
- /**
12
- * Session id name space in cookie
13
- */
14
- sid?: string;
15
- /**
16
- * Default days to expire session in database (only in database cookie will not be affected)
17
- */
18
- daysToExpire?: number;
19
- /**
20
- * If session expiration will be rehidrated eachtime the user have an activity with the server
21
- */
22
- persistent?: boolean;
23
- /**
24
- * Cookie options (for sessions)
25
- */
26
- cookieOptions?: CookieOptions;
27
- };
28
- /**
29
- *
30
- */
31
- upload?: {
32
- localPrivateUploadDir?: string;
33
- localUploadDir?: string;
34
- staticUploadPath?: string;
35
- tempDir?: string;
36
- headers?: any;
37
- highWaterMark?: number;
38
- fileHwm?: number;
39
- defCharset?: string;
40
- preservePath?: boolean;
41
- limits?: {
42
- fieldNameSize?: number;
43
- fieldSize?: number;
44
- fields?: number;
45
- fileSize?: number;
46
- files?: number;
47
- parts?: number;
48
- headerPairs?: number;
49
- };
50
- };
51
- database?: {
52
- log?: boolean;
53
- };
54
- };
1
+ import { CookieOptions } from "express";
2
+ export type DFWConfig = {
3
+ /**
4
+ *
5
+ */
6
+ session?: {
7
+ /**
8
+ * Session token name space in cookie
9
+ */
10
+ stk?: string;
11
+ /**
12
+ * Session id name space in cookie
13
+ */
14
+ sid?: string;
15
+ /**
16
+ * Default days to expire session in database (only in database cookie will not be affected)
17
+ */
18
+ daysToExpire?: number;
19
+ /**
20
+ * If session expiration will be rehidrated eachtime the user have an activity with the server
21
+ */
22
+ persistent?: boolean;
23
+ /**
24
+ * Cookie options (for sessions)
25
+ */
26
+ cookieOptions?: CookieOptions;
27
+ };
28
+ /**
29
+ *
30
+ */
31
+ upload?: {
32
+ localPrivateUploadDir?: string;
33
+ localUploadDir?: string;
34
+ staticUploadPath?: string;
35
+ tempDir?: string;
36
+ headers?: any;
37
+ highWaterMark?: number;
38
+ fileHwm?: number;
39
+ defCharset?: string;
40
+ preservePath?: boolean;
41
+ limits?: {
42
+ fieldNameSize?: number;
43
+ fieldSize?: number;
44
+ fields?: number;
45
+ fileSize?: number;
46
+ files?: number;
47
+ parts?: number;
48
+ headerPairs?: number;
49
+ };
50
+ };
51
+ database?: {
52
+ log?: boolean;
53
+ };
54
+ };
55
55
  //# sourceMappingURL=DFWConfig.d.ts.map
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=DFWConfig.js.map
@@ -1,38 +1,34 @@
1
- import DFWInstance from "../DFWInstance";
2
- import { Request } from "express";
3
- import SecurityManager from "../manager/SecurityManager";
4
- import UserManager from "../manager/UserManager";
5
- import SessionManager from "../manager/SessionManager";
6
- import FileManager from "../manager/FileManager";
7
- import DFWBoot from "./DFWBoot";
8
- import { dfw_session, dfw_user, PrismaClient } from "@prisma/client";
9
- import { APIListenerConfig } from "./APIListenerConfig";
10
- export type DFWRequest = {
11
- dfw: DFWRequestScheme;
12
- } & Request;
13
- export type DFWRequestScheme = {
14
- __meta: {
15
- config: APIListenerConfig;
16
- };
17
- req: DFWRequest;
18
- res: Response;
19
- instance: DFWInstance;
20
- session: {
21
- isLogged: boolean;
22
- user?: dfw_user;
23
- record: dfw_session & {
24
- user?: {
25
- id: number;
26
- nick: any;
27
- email: any;
28
- } | null;
29
- };
30
- };
31
- db: PrismaClient;
32
- boot: () => Promise<DFWBoot>;
33
- SecurityManager: SecurityManager;
34
- SessionManager: SessionManager;
35
- FileManager: FileManager;
36
- UserManager: UserManager;
37
- };
1
+ import DFWInstance from "../DFWInstance";
2
+ import { Request } from "express";
3
+ import SecurityManager from "../manager/SecurityManager";
4
+ import UserManager from "../manager/UserManager";
5
+ import SessionManager from "../manager/SessionManager";
6
+ import FileManager from "../manager/FileManager";
7
+ import DFWBoot from "./DFWBoot";
8
+ import { dfw_session, dfw_user, PrismaClient } from "@prisma/client";
9
+ import { APIListenerConfig } from "./APIListenerConfig";
10
+ export type DFWRequest = {
11
+ dfw: DFWRequestScheme;
12
+ } & Request;
13
+ export type DFWRequestScheme = {
14
+ __meta: {
15
+ config: APIListenerConfig;
16
+ };
17
+ req: DFWRequest;
18
+ res: Response;
19
+ instance: DFWInstance;
20
+ session: {
21
+ isLogged: boolean;
22
+ user?: dfw_user;
23
+ record: dfw_session & {
24
+ user?: dfw_user | null;
25
+ };
26
+ };
27
+ db: PrismaClient;
28
+ boot: () => Promise<DFWBoot>;
29
+ SecurityManager: SecurityManager;
30
+ SessionManager: SessionManager;
31
+ FileManager: FileManager;
32
+ UserManager: UserManager;
33
+ };
38
34
  //# sourceMappingURL=DFWRequestScheme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DFWRequestScheme.d.ts","sourceRoot":"","sources":["../../src/types/DFWRequestScheme.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IACrB,GAAG,EAAE,gBAAgB,CAAC;CACzB,GAAG,OAAO,CAAA;AAEX,MAAM,MAAM,gBAAgB,GAAG;IAC3B,MAAM,EAAE;QACJ,MAAM,EAAE,iBAAiB,CAAA;KAC5B,CAAC;IACF,GAAG,EAAC,UAAU,CAAA;IACd,GAAG,EAAC,QAAQ,CAAA;IACZ,QAAQ,EAAE,WAAW,CAAA;IACrB,OAAO,EAAE;QACL,QAAQ,EAAE,OAAO,CAAA;QACjB,IAAI,CAAC,EAAE,QAAQ,CAAA;QACf,MAAM,EAAE,WAAW,GAAG;YAAE,IAAI,CAAC,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAC;gBAAC,IAAI,EA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GAAG,IAAI,CAAA;SAAE,CAAA;KACnD,CAAC;IAEF,EAAE,EAAE,YAAY,CAAC;IAEjB,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IAG5B,eAAe,EAAE,eAAe,CAAA;IAChC,cAAc,EAAE,cAAc,CAAA;IAC9B,WAAW,EAAE,WAAW,CAAA;IACxB,WAAW,EAAE,WAAW,CAAA;CAC3B,CAAA"}
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=DFWRequestScheme.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scefira/dfw",
3
- "version": "0.1.15",
3
+ "version": "0.2.1",
4
4
  "description": "nodejs express fast prototype library",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -10,6 +10,7 @@
10
10
  ],
11
11
  "scripts": {
12
12
  "dev": "nodemon",
13
+ "dev:prisma": "dotenv -e .env.development -- npx prisma studio",
13
14
  "build": "tsc",
14
15
  "start": "cross-env NODE_ENV=production node lib/index.js",
15
16
  "sync": "npx prisma db push",
@@ -45,7 +46,7 @@
45
46
  "cross-env": "^7.0.3",
46
47
  "nodemon": "^2.0.15",
47
48
  "prisma": "^5.2.0",
48
- "ts-node": "^10.5.0",
49
- "typescript": "^4.7.0"
49
+ "ts-node": "^10.9.1",
50
+ "typescript": "^5.2.2"
50
51
  }
51
52
  }
@@ -16,7 +16,7 @@ model dfw_access {
16
16
  createdAt DateTime @default(now())
17
17
  updatedAt DateTime @updatedAt
18
18
 
19
- credentials dfw_credentials_access[]
19
+ credentials dfw_credential[]
20
20
 
21
21
  @@index([name])
22
22
  }
@@ -29,8 +29,8 @@ model dfw_credential {
29
29
  createdAt DateTime @default(now())
30
30
  updatedAt DateTime @updatedAt
31
31
 
32
- users dfw_users_credentials[]
33
- access dfw_credentials_access[]
32
+ users dfw_user[]
33
+ access dfw_access[]
34
34
 
35
35
  @@index([name])
36
36
  }
@@ -89,31 +89,9 @@ model dfw_user {
89
89
  updatedAt DateTime @updatedAt
90
90
 
91
91
  sessions dfw_session[]
92
- credentials dfw_users_credentials[]
92
+ credentials dfw_credential[]
93
93
  files dfw_file[]
94
94
 
95
95
  @@index([email])
96
96
  @@index([nick])
97
- }
98
-
99
- // Pivot tables
100
-
101
- model dfw_credentials_access {
102
- idAccess Int @db.UnsignedInt
103
- idCredential Int @db.UnsignedInt
104
-
105
- credentials dfw_credential @relation(fields: [idCredential] , references: [id])
106
- access dfw_access @relation(fields: [idAccess] , references: [id])
107
-
108
- @@id([idAccess, idCredential])
109
- }
110
-
111
- model dfw_users_credentials {
112
- idUser Int @db.UnsignedInt
113
- idCredential Int @db.UnsignedInt
114
-
115
- user dfw_user @relation(fields: [idUser], references: [id])
116
- credential dfw_credential @relation(fields: [idCredential], references: [id])
117
-
118
- @@id([idUser, idCredential])
119
- }
97
+ }