@trafficgroup/knex-rel 0.0.26 → 0.0.27
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/.claude/settings.local.json +9 -0
- package/CLAUDE.md +63 -0
- package/dist/KnexConnection.d.ts +17 -0
- package/dist/KnexConnection.js +99 -0
- package/dist/KnexConnection.js.map +1 -0
- package/dist/d.types.d.ts +17 -0
- package/dist/d.types.js +3 -0
- package/dist/d.types.js.map +1 -0
- package/dist/dao/auth/auth.dao.d.ts +13 -0
- package/dist/dao/auth/auth.dao.js +82 -0
- package/dist/dao/auth/auth.dao.js.map +1 -0
- package/dist/dao/chat/chat.dao.d.ts +13 -0
- package/dist/dao/chat/chat.dao.js +138 -0
- package/dist/dao/chat/chat.dao.js.map +1 -0
- package/dist/dao/folder/folder.dao.d.ts +11 -0
- package/dist/dao/folder/folder.dao.js +84 -0
- package/dist/dao/folder/folder.dao.js.map +1 -0
- package/dist/dao/message/message.dao.d.ts +13 -0
- package/dist/dao/message/message.dao.js +118 -0
- package/dist/dao/message/message.dao.js.map +1 -0
- package/dist/dao/study/study.dao.d.ts +11 -0
- package/dist/dao/study/study.dao.js +84 -0
- package/dist/dao/study/study.dao.js.map +1 -0
- package/dist/dao/user/user.dao.d.ts +12 -0
- package/dist/dao/user/user.dao.js +76 -0
- package/dist/dao/user/user.dao.js.map +1 -0
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.d.ts +14 -0
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js +87 -0
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js.map +1 -0
- package/dist/dao/video/video.dao.d.ts +13 -0
- package/dist/dao/video/video.dao.js +88 -0
- package/dist/dao/video/video.dao.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/auth/auth.interfaces.d.ts +11 -0
- package/dist/interfaces/auth/auth.interfaces.js +3 -0
- package/dist/interfaces/auth/auth.interfaces.js.map +1 -0
- package/dist/interfaces/chat/chat.interfaces.d.ts +18 -0
- package/dist/interfaces/chat/chat.interfaces.js +3 -0
- package/dist/interfaces/chat/chat.interfaces.js.map +1 -0
- package/dist/interfaces/folder/folder.interfaces.d.ts +12 -0
- package/dist/interfaces/folder/folder.interfaces.js +3 -0
- package/dist/interfaces/folder/folder.interfaces.js.map +1 -0
- package/dist/interfaces/message/message.interfaces.d.ts +16 -0
- package/dist/interfaces/message/message.interfaces.js +3 -0
- package/dist/interfaces/message/message.interfaces.js.map +1 -0
- package/dist/interfaces/study/study.interfaces.d.ts +11 -0
- package/dist/interfaces/study/study.interfaces.js +3 -0
- package/dist/interfaces/study/study.interfaces.js.map +1 -0
- package/dist/interfaces/user/user.interfaces.d.ts +11 -0
- package/dist/interfaces/user/user.interfaces.js +3 -0
- package/dist/interfaces/user/user.interfaces.js.map +1 -0
- package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.d.ts +10 -0
- package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.js +3 -0
- package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.js.map +1 -0
- package/dist/interfaces/video/video.interfaces.d.ts +20 -0
- package/dist/interfaces/video/video.interfaces.js +3 -0
- package/dist/interfaces/video/video.interfaces.js.map +1 -0
- package/knexfile.ts +5 -5
- package/migrations/20250717173228_migration.ts +9 -0
- package/migrations/20250717204731_migration.ts +13 -0
- package/migrations/20250722210109_migration.ts +60 -0
- package/migrations/20250722211019_migration.ts +15 -0
- package/migrations/20250723153852_migration.ts +19 -0
- package/migrations/20250723162257_migration.ts +16 -0
- package/migrations/20250723171109_migration.ts +16 -0
- package/migrations/20250723205331_migration.ts +18 -0
- package/migrations/20250724191345_migration.ts +18 -0
- package/migrations/20250730180932_migration.ts +22 -0
- package/migrations/20250730213625_migration.ts +18 -0
- package/migrations/20250804124509_migration.ts +43 -0
- package/migrations/20250804132053_migration.ts +18 -0
- package/package.json +47 -47
- package/src/d.types.ts +7 -7
- package/src/dao/auth/auth.dao.ts +61 -0
- package/src/dao/chat/chat.dao.ts +124 -0
- package/src/dao/folder/folder.dao.ts +66 -0
- package/src/dao/message/message.dao.ts +102 -0
- package/src/dao/study/study.dao.ts +66 -0
- package/src/dao/user/user.dao.ts +14 -10
- package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +65 -0
- package/src/dao/video/video.dao.ts +71 -0
- package/src/index.ts +23 -8
- package/src/interfaces/auth/auth.interfaces.ts +11 -0
- package/src/interfaces/chat/chat.interfaces.ts +20 -0
- package/src/interfaces/folder/folder.interfaces.ts +3 -0
- package/src/interfaces/message/message.interfaces.ts +18 -0
- package/src/interfaces/study/study.interfaces.ts +3 -0
- package/src/interfaces/user/user.interfaces.ts +2 -0
- package/src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts +10 -0
- package/src/interfaces/video/video.interfaces.ts +9 -1
- package/.env +0 -5
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MessageDAO = void 0;
|
|
16
|
+
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
+
class MessageDAO {
|
|
18
|
+
constructor() {
|
|
19
|
+
this._knex = KnexConnection_1.default.getConnection();
|
|
20
|
+
}
|
|
21
|
+
create(item) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const [result] = yield this._knex('message')
|
|
24
|
+
.insert(item)
|
|
25
|
+
.returning('*');
|
|
26
|
+
return result;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
getById(id) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const result = yield this._knex('message')
|
|
32
|
+
.where('id', id)
|
|
33
|
+
.first();
|
|
34
|
+
return result || null;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getByUuid(uuid) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
// Message table doesn't have uuid column, returning null
|
|
40
|
+
return null;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getAll() {
|
|
44
|
+
return __awaiter(this, arguments, void 0, function* (page = 1, limit = 10) {
|
|
45
|
+
const offset = (page - 1) * limit;
|
|
46
|
+
const [results, [{ count }]] = yield Promise.all([
|
|
47
|
+
this._knex('message')
|
|
48
|
+
.orderBy('created_at', 'asc')
|
|
49
|
+
.limit(limit)
|
|
50
|
+
.offset(offset),
|
|
51
|
+
this._knex('message').count('* as count')
|
|
52
|
+
]);
|
|
53
|
+
const totalCount = parseInt(count);
|
|
54
|
+
return {
|
|
55
|
+
success: true,
|
|
56
|
+
data: results,
|
|
57
|
+
page,
|
|
58
|
+
limit,
|
|
59
|
+
count: results.length,
|
|
60
|
+
totalCount,
|
|
61
|
+
totalPages: Math.ceil(totalCount / limit)
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
update(id, item) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const [result] = yield this._knex('message')
|
|
68
|
+
.where('id', id)
|
|
69
|
+
.update(Object.assign(Object.assign({}, item), { updated_at: new Date() }))
|
|
70
|
+
.returning('*');
|
|
71
|
+
return result || null;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
delete(id) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const result = yield this._knex('message')
|
|
77
|
+
.where('id', id)
|
|
78
|
+
.delete();
|
|
79
|
+
return result > 0;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
getByChatId(chatId_1) {
|
|
83
|
+
return __awaiter(this, arguments, void 0, function* (chatId, page = 1, limit = 50) {
|
|
84
|
+
const offset = (page - 1) * limit;
|
|
85
|
+
const [results, [{ count }]] = yield Promise.all([
|
|
86
|
+
this._knex('message')
|
|
87
|
+
.where('chatId', chatId)
|
|
88
|
+
.orderBy('created_at', 'asc')
|
|
89
|
+
.limit(limit)
|
|
90
|
+
.offset(offset),
|
|
91
|
+
this._knex('message')
|
|
92
|
+
.where('chatId', chatId)
|
|
93
|
+
.count('* as count')
|
|
94
|
+
]);
|
|
95
|
+
const totalCount = parseInt(count);
|
|
96
|
+
return {
|
|
97
|
+
success: true,
|
|
98
|
+
data: results,
|
|
99
|
+
page,
|
|
100
|
+
limit,
|
|
101
|
+
count: results.length,
|
|
102
|
+
totalCount,
|
|
103
|
+
totalPages: Math.ceil(totalCount / limit)
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
getLatestMessages(chatId_1) {
|
|
108
|
+
return __awaiter(this, arguments, void 0, function* (chatId, limit = 50) {
|
|
109
|
+
return yield this._knex('message')
|
|
110
|
+
.where('chatId', chatId)
|
|
111
|
+
.orderBy('created_at', 'desc')
|
|
112
|
+
.limit(limit)
|
|
113
|
+
.then((messages) => messages.reverse());
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.MessageDAO = MessageDAO;
|
|
118
|
+
//# sourceMappingURL=message.dao.js.map
|
|
@@ -0,0 +1 @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;gBACjB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;qBAClB,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;qBACvB,KAAK,CAAC,YAAY,CAAC;aACvB,CAAC,CAAC;YAEH,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAe,CAAC,CAAC;YAC7C,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,OAAO;gBACb,IAAI;gBACJ,KAAK;gBACL,KAAK,EAAE,OAAO,CAAC,MAAM;gBACrB,UAAU;gBACV,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;aAC1C,CAAC;QACJ,CAAC;KAAA;IAEK,iBAAiB;6DAAC,MAAc,EAAE,KAAK,GAAG,EAAE;YAChD,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;iBAC/B,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC;iBACvB,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC;iBAC7B,KAAK,CAAC,KAAK,CAAC;iBACZ,IAAI,CAAC,CAAC,QAAoB,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACxD,CAAC;KAAA;CACF;AAhGD,gCAgGC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IBaseDAO, IDataPaginator } from "../../d.types";
|
|
2
|
+
import { IStudy } from "../../interfaces/study/study.interfaces";
|
|
3
|
+
export declare class StudyDAO implements IBaseDAO<IStudy> {
|
|
4
|
+
private _knex;
|
|
5
|
+
create(item: IStudy): Promise<IStudy>;
|
|
6
|
+
getById(id: number): Promise<IStudy | null>;
|
|
7
|
+
getByUuid(uuid: string): Promise<IStudy | null>;
|
|
8
|
+
update(id: number, item: Partial<IStudy>): Promise<IStudy | null>;
|
|
9
|
+
delete(id: number): Promise<boolean>;
|
|
10
|
+
getAll(page: number, limit: number, createdBy?: number | null): Promise<IDataPaginator<IStudy>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.StudyDAO = void 0;
|
|
16
|
+
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
+
class StudyDAO {
|
|
18
|
+
constructor() {
|
|
19
|
+
this._knex = KnexConnection_1.default.getConnection();
|
|
20
|
+
}
|
|
21
|
+
create(item) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const [createdStudy] = yield this._knex("study").insert(item).returning("*");
|
|
24
|
+
return createdStudy;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getById(id) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const study = yield this._knex("study as s")
|
|
30
|
+
.innerJoin("users as u", "s.createdBy", "u.id")
|
|
31
|
+
.select("s.*", this._knex.raw("to_jsonb(u.*) as user"))
|
|
32
|
+
.where("s.id", id)
|
|
33
|
+
.first();
|
|
34
|
+
return study || null;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getByUuid(uuid) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const study = yield this._knex("study as s")
|
|
40
|
+
.innerJoin("users as u", "s.createdBy", "u.id")
|
|
41
|
+
.select("s.*", this._knex.raw("to_jsonb(u.*) as user"))
|
|
42
|
+
.where("s.uuid", uuid)
|
|
43
|
+
.first();
|
|
44
|
+
return study || null;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
update(id, item) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const [updatedStudy] = yield this._knex("study").where({ id }).update(item).returning("*");
|
|
50
|
+
return updatedStudy || null;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
delete(id) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const result = yield this._knex("study").where({ id }).del();
|
|
56
|
+
return result > 0;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getAll(page, limit, createdBy) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const offset = (page - 1) * limit;
|
|
62
|
+
const query = this._knex("study as s")
|
|
63
|
+
.innerJoin("users as u", "s.createdBy", "u.id")
|
|
64
|
+
.select("s.*", this._knex.raw("to_jsonb(u.*) as user"));
|
|
65
|
+
if (createdBy !== undefined && createdBy !== null) {
|
|
66
|
+
query.where("s.createdBy", createdBy);
|
|
67
|
+
}
|
|
68
|
+
const [countResult] = yield query.clone().clearSelect().count("* as count");
|
|
69
|
+
const totalCount = +countResult.count;
|
|
70
|
+
const studies = yield query.clone().limit(limit).offset(offset);
|
|
71
|
+
return {
|
|
72
|
+
success: true,
|
|
73
|
+
data: studies,
|
|
74
|
+
page,
|
|
75
|
+
limit,
|
|
76
|
+
count: studies.length,
|
|
77
|
+
totalCount,
|
|
78
|
+
totalPages: Math.ceil(totalCount / limit),
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.StudyDAO = StudyDAO;
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EhE,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,OAAO;gBACb,IAAI;gBACJ,KAAK;gBACL,KAAK,EAAE,OAAO,CAAC,MAAM;gBACrB,UAAU;gBACV,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;aAC5C,CAAC;QACN,CAAC;KAAA;CACJ;AA5DD,4BA4DC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IBaseDAO, IDataPaginator } from "../../d.types";
|
|
2
|
+
import { IUser } from "../../interfaces/user/user.interfaces";
|
|
3
|
+
export declare class UserDAO implements IBaseDAO<IUser> {
|
|
4
|
+
private _knex;
|
|
5
|
+
create(item: IUser): Promise<IUser>;
|
|
6
|
+
getById(id: number): Promise<IUser | null>;
|
|
7
|
+
getByUuid(uuid: string): Promise<IUser | null>;
|
|
8
|
+
getByEmail(email: string): Promise<IUser | null>;
|
|
9
|
+
update(id: number, item: Partial<IUser>): Promise<IUser | null>;
|
|
10
|
+
delete(id: number): Promise<boolean>;
|
|
11
|
+
getAll(page: number, limit: number): Promise<IDataPaginator<IUser>>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UserDAO = void 0;
|
|
16
|
+
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
+
class UserDAO {
|
|
18
|
+
constructor() {
|
|
19
|
+
this._knex = KnexConnection_1.default.getConnection();
|
|
20
|
+
}
|
|
21
|
+
create(item) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const [createdUser] = yield this._knex("users").insert(item).returning("*");
|
|
24
|
+
return createdUser;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getById(id) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const user = yield this._knex("users").where({ id }).first();
|
|
30
|
+
return user || null;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getByUuid(uuid) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const user = yield this._knex("users").where({ uuid }).first();
|
|
36
|
+
return user || null;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getByEmail(email) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const user = yield this._knex("users").where({ email }).first();
|
|
42
|
+
return user || null;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
update(id, item) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const [updatedUser] = yield this._knex("users").where({ id }).update(item).returning("*");
|
|
48
|
+
return updatedUser || null;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
delete(id) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const result = yield this._knex("users").where({ id }).del();
|
|
54
|
+
return result > 0;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getAll(page, limit) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const offset = (page - 1) * limit;
|
|
60
|
+
const [countResult] = yield this._knex("users").count("* as count");
|
|
61
|
+
const totalCount = +countResult.count;
|
|
62
|
+
const users = yield this._knex("users").limit(limit).offset(offset);
|
|
63
|
+
return {
|
|
64
|
+
success: true,
|
|
65
|
+
data: users,
|
|
66
|
+
page,
|
|
67
|
+
limit,
|
|
68
|
+
count: users.length,
|
|
69
|
+
totalCount,
|
|
70
|
+
totalPages: Math.ceil(totalCount / limit),
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.UserDAO = UserDAO;
|
|
76
|
+
//# sourceMappingURL=user.dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.dao.js","sourceRoot":"","sources":["../../../src/dao/user/user.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,0EAA+C;AAE/C,MAAa,OAAO;IAApB;QACY,UAAK,GAAyB,wBAAW,CAAC,aAAa,EAAE,CAAC;IAkDtE,CAAC;IAhDS,MAAM,CAAC,IAAW;;YACpB,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAC5E,OAAO,WAAW,CAAC;QACvB,CAAC;KAAA;IAEK,OAAO,CAAC,EAAU;;YACpB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;YAC7D,OAAO,IAAI,IAAI,IAAI,CAAC;QACxB,CAAC;KAAA;IAEK,SAAS,CAAC,IAAY;;YACxB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CA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KAAK;gBACX,IAAI;gBACJ,KAAK;gBACL,KAAK,EAAE,KAAK,CAAC,MAAM;gBACnB,UAAU;gBACV,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;aAC5C,CAAC;QACN,CAAC;KAAA;CACJ;AAnDD,0BAmDC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IBaseDAO, IDataPaginator } from "../../d.types";
|
|
2
|
+
import { IUserPushNotificationToken } from "../../interfaces/user-push-notification-token/user-push-notification-token.interfaces";
|
|
3
|
+
export declare class UserPushNotificationTokenDAO implements IBaseDAO<IUserPushNotificationToken> {
|
|
4
|
+
private _knex;
|
|
5
|
+
create(item: IUserPushNotificationToken): Promise<IUserPushNotificationToken>;
|
|
6
|
+
getById(id: number): Promise<IUserPushNotificationToken | null>;
|
|
7
|
+
getByUuid(uuid: string): Promise<IUserPushNotificationToken | null>;
|
|
8
|
+
getByUserId(userId: number): Promise<IUserPushNotificationToken[]>;
|
|
9
|
+
getByToken(token: string): Promise<IUserPushNotificationToken | null>;
|
|
10
|
+
getAvailableByUserId(userId: number): Promise<IUserPushNotificationToken[]>;
|
|
11
|
+
update(id: number, item: Partial<IUserPushNotificationToken>): Promise<IUserPushNotificationToken | null>;
|
|
12
|
+
delete(id: number): Promise<boolean>;
|
|
13
|
+
getAll(page: number, limit: number): Promise<IDataPaginator<IUserPushNotificationToken>>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UserPushNotificationTokenDAO = void 0;
|
|
16
|
+
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
+
class UserPushNotificationTokenDAO {
|
|
18
|
+
constructor() {
|
|
19
|
+
this._knex = KnexConnection_1.default.getConnection();
|
|
20
|
+
}
|
|
21
|
+
create(item) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const [createdToken] = yield this._knex("user_push_notification_token").insert(item).returning("*");
|
|
24
|
+
return createdToken;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getById(id) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const token = yield this._knex("user_push_notification_token").where({ id }).first();
|
|
30
|
+
return token || null;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getByUuid(uuid) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
throw new Error("Method not implemented. UserPushNotificationToken does not have UUID field.");
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
getByUserId(userId) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const tokens = yield this._knex("user_push_notification_token").where({ userId });
|
|
41
|
+
return tokens;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
getByToken(token) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const tokenRecord = yield this._knex("user_push_notification_token").where({ token }).first();
|
|
47
|
+
return tokenRecord || null;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getAvailableByUserId(userId) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const tokens = yield this._knex("user_push_notification_token").where({ userId, available: true });
|
|
53
|
+
return tokens;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
update(id, item) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const [updatedToken] = yield this._knex("user_push_notification_token").where({ id }).update(item).returning("*");
|
|
59
|
+
return updatedToken || null;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
delete(id) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const result = yield this._knex("user_push_notification_token").where({ id }).del();
|
|
65
|
+
return result > 0;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
getAll(page, limit) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const offset = (page - 1) * limit;
|
|
71
|
+
const [countResult] = yield this._knex("user_push_notification_token").count("* as count");
|
|
72
|
+
const totalCount = +countResult.count;
|
|
73
|
+
const tokens = yield this._knex("user_push_notification_token").limit(limit).offset(offset);
|
|
74
|
+
return {
|
|
75
|
+
success: true,
|
|
76
|
+
data: tokens,
|
|
77
|
+
page,
|
|
78
|
+
limit,
|
|
79
|
+
count: tokens.length,
|
|
80
|
+
totalCount,
|
|
81
|
+
totalPages: Math.ceil(totalCount / limit),
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.UserPushNotificationTokenDAO = UserPushNotificationTokenDAO;
|
|
87
|
+
//# sourceMappingURL=user-push-notification-token.dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-push-notification-token.dao.js","sourceRoot":"","sources":["../../../src/dao/user-push-notification-token/user-push-notification-token.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,0EAA+C;AAE/C,MAAa,4BAA4B;IAA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"../../d.types";
|
|
3
|
+
import { IVideo } from "../../interfaces/video/video.interfaces";
|
|
4
|
+
export declare class VideoDAO implements IBaseDAO<IVideo> {
|
|
5
|
+
private _knex;
|
|
6
|
+
static getInstance(): Knex<any, unknown[]>;
|
|
7
|
+
create(item: IVideo): Promise<IVideo>;
|
|
8
|
+
getById(id: number): Promise<IVideo | null>;
|
|
9
|
+
getByUuid(uuid: string): Promise<IVideo | null>;
|
|
10
|
+
update(id: number, item: Partial<IVideo>): Promise<IVideo | null>;
|
|
11
|
+
delete(id: number): Promise<boolean>;
|
|
12
|
+
getAll(page: number, limit: number, folderId?: number | null): Promise<IDataPaginator<IVideo>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.VideoDAO = void 0;
|
|
16
|
+
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
+
class VideoDAO {
|
|
18
|
+
constructor() {
|
|
19
|
+
this._knex = KnexConnection_1.default.getConnection();
|
|
20
|
+
}
|
|
21
|
+
static getInstance() {
|
|
22
|
+
return KnexConnection_1.default.getConnection();
|
|
23
|
+
}
|
|
24
|
+
create(item) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const [createdVideo] = yield this._knex("video").insert(item).returning("*");
|
|
27
|
+
return createdVideo;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getById(id) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const video = yield this._knex("video as v")
|
|
33
|
+
.innerJoin("folders as f", "v.folderId", "f.id")
|
|
34
|
+
.select("v.*", this._knex.raw("to_jsonb(f.*) as folder"))
|
|
35
|
+
.where("v.id", id)
|
|
36
|
+
.first();
|
|
37
|
+
return video || null;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
getByUuid(uuid) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const video = yield this._knex("video as v")
|
|
43
|
+
.innerJoin("folders as f", "v.folderId", "f.id")
|
|
44
|
+
.select("v.*", this._knex.raw("to_jsonb(f.*) as folder"))
|
|
45
|
+
.where("v.uuid", uuid)
|
|
46
|
+
.first();
|
|
47
|
+
return video || null;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
update(id, item) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const [updatedVideo] = yield this._knex("video").where({ id }).update(item).returning("*");
|
|
53
|
+
return updatedVideo || null;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
delete(id) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const result = yield this._knex("video").where({ id }).del();
|
|
59
|
+
return result > 0;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// entityId corresponde al id del folder al que pertenece el video
|
|
63
|
+
getAll(page, limit, folderId) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const offset = (page - 1) * limit;
|
|
66
|
+
const query = this._knex("video as v")
|
|
67
|
+
.innerJoin("folders as f", "v.folderId", "f.id")
|
|
68
|
+
.select("v.*", this._knex.raw("to_jsonb(f.*) as folder"));
|
|
69
|
+
if (folderId !== undefined && folderId !== null) {
|
|
70
|
+
query.where("v.folderId", folderId);
|
|
71
|
+
}
|
|
72
|
+
const [countResult] = yield query.clone().clearSelect().count("* as count");
|
|
73
|
+
const totalCount = +countResult.count;
|
|
74
|
+
const videos = yield query.clone().limit(limit).offset(offset);
|
|
75
|
+
return {
|
|
76
|
+
success: true,
|
|
77
|
+
data: videos,
|
|
78
|
+
page,
|
|
79
|
+
limit,
|
|
80
|
+
count: videos.length,
|
|
81
|
+
totalCount,
|
|
82
|
+
totalPages: Math.ceil(totalCount / limit),
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.VideoDAO = VideoDAO;
|
|
88
|
+
//# sourceMappingURL=video.dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.dao.js","sourceRoot":"","sources":["../../../src/dao/video/video.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA,0EAA+C;AAE/C,MAAa,QAAQ;IAArB;QACY,UAAK,GAAyB,wBAAW,CAAC,aAAa,EAAE,CAAC;IAgEtE,CAAC;IA9DG,MAAM,CAAC,WAAW;QACd,OAAO,wBAAW,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC;IAEK,MAAM,CAAC,IAAY;;YACrB,MAAM,CAAC,YAAY,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAC7E,OAAO,YAAY,CAAC;QACxB,CAAC;KAAA;IAEK,OAAO,CAAC,EAAU;;YACpB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;iBACvC,SAAS,CAAC,cAAc,EAAE,YAAY,EAAE,MAAM,CAA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I,CAAC,KAAK,CAAC,YAAY,CAAC;iBACjC,SAAS,CAAC,cAAc,EAAE,YAAY,EAAE,MAAM,CAAC;iBAC/C,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC;YAC9D,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAC9C,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YACxC,CAAC;YAED,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAC5E,MAAM,UAAU,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAE/D,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE,MAAM;gBACZ,IAAI;gBACJ,KAAK;gBACL,KAAK,EAAE,MAAM,CAAC,MAAM;gBACpB,UAAU;gBACV,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;aAC5C,CAAC;QACN,CAAC;KAAA;CACJ;AAjED,4BAiEC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { UserDAO } from "./dao/user/user.dao";
|
|
2
|
+
export { StudyDAO } from "./dao/study/study.dao";
|
|
3
|
+
export { FolderDAO } from "./dao/folder/folder.dao";
|
|
4
|
+
export { VideoDAO } from "./dao/video/video.dao";
|
|
5
|
+
export { AuthDAO } from "./dao/auth/auth.dao";
|
|
6
|
+
export { UserPushNotificationTokenDAO } from "./dao/user-push-notification-token/user-push-notification-token.dao";
|
|
7
|
+
export { ChatDAO } from "./dao/chat/chat.dao";
|
|
8
|
+
export { MessageDAO } from "./dao/message/message.dao";
|
|
9
|
+
export { IDataPaginator } from "./d.types";
|
|
10
|
+
export { IUser } from "./interfaces/user/user.interfaces";
|
|
11
|
+
export { IStudy } from "./interfaces/study/study.interfaces";
|
|
12
|
+
export { IFolder } from "./interfaces/folder/folder.interfaces";
|
|
13
|
+
export { IVideo } from "./interfaces/video/video.interfaces";
|
|
14
|
+
export { IAuth } from "./interfaces/auth/auth.interfaces";
|
|
15
|
+
export { IUserPushNotificationToken } from "./interfaces/user-push-notification-token/user-push-notification-token.interfaces";
|
|
16
|
+
export { IChat, IChatCreate, IChatUpdate } from "./interfaces/chat/chat.interfaces";
|
|
17
|
+
export { IMessage, IMessageCreate, IMessageUpdate } from "./interfaces/message/message.interfaces";
|
|
18
|
+
import KnexManager from "./KnexConnection";
|
|
19
|
+
export { KnexManager };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.KnexManager = exports.MessageDAO = exports.ChatDAO = exports.UserPushNotificationTokenDAO = exports.AuthDAO = exports.VideoDAO = exports.FolderDAO = exports.StudyDAO = exports.UserDAO = void 0;
|
|
7
|
+
// DAOs
|
|
8
|
+
var user_dao_1 = require("./dao/user/user.dao");
|
|
9
|
+
Object.defineProperty(exports, "UserDAO", { enumerable: true, get: function () { return user_dao_1.UserDAO; } });
|
|
10
|
+
var study_dao_1 = require("./dao/study/study.dao");
|
|
11
|
+
Object.defineProperty(exports, "StudyDAO", { enumerable: true, get: function () { return study_dao_1.StudyDAO; } });
|
|
12
|
+
var folder_dao_1 = require("./dao/folder/folder.dao");
|
|
13
|
+
Object.defineProperty(exports, "FolderDAO", { enumerable: true, get: function () { return folder_dao_1.FolderDAO; } });
|
|
14
|
+
var video_dao_1 = require("./dao/video/video.dao");
|
|
15
|
+
Object.defineProperty(exports, "VideoDAO", { enumerable: true, get: function () { return video_dao_1.VideoDAO; } });
|
|
16
|
+
var auth_dao_1 = require("./dao/auth/auth.dao");
|
|
17
|
+
Object.defineProperty(exports, "AuthDAO", { enumerable: true, get: function () { return auth_dao_1.AuthDAO; } });
|
|
18
|
+
var user_push_notification_token_dao_1 = require("./dao/user-push-notification-token/user-push-notification-token.dao");
|
|
19
|
+
Object.defineProperty(exports, "UserPushNotificationTokenDAO", { enumerable: true, get: function () { return user_push_notification_token_dao_1.UserPushNotificationTokenDAO; } });
|
|
20
|
+
var chat_dao_1 = require("./dao/chat/chat.dao");
|
|
21
|
+
Object.defineProperty(exports, "ChatDAO", { enumerable: true, get: function () { return chat_dao_1.ChatDAO; } });
|
|
22
|
+
var message_dao_1 = require("./dao/message/message.dao");
|
|
23
|
+
Object.defineProperty(exports, "MessageDAO", { enumerable: true, get: function () { return message_dao_1.MessageDAO; } });
|
|
24
|
+
const KnexConnection_1 = __importDefault(require("./KnexConnection"));
|
|
25
|
+
exports.KnexManager = KnexConnection_1.default;
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO;AACP,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,sDAAoD;AAA3C,uGAAA,SAAS,OAAA;AAClB,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,wHAAmH;AAA1G,gJAAA,4BAA4B,OAAA;AACrC,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,yDAAuD;AAA9C,yGAAA,UAAU,OAAA;AAanB,sEAA2C;AAClC,sBADF,wBAAW,CACE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/auth/auth.interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface IChat {
|
|
2
|
+
id?: number;
|
|
3
|
+
uuid?: string;
|
|
4
|
+
userId: number;
|
|
5
|
+
title: string;
|
|
6
|
+
status?: 'active' | 'archived';
|
|
7
|
+
created_at?: Date;
|
|
8
|
+
updated_at?: Date;
|
|
9
|
+
}
|
|
10
|
+
export interface IChatCreate {
|
|
11
|
+
userId: number;
|
|
12
|
+
title: string;
|
|
13
|
+
status?: 'active' | 'archived';
|
|
14
|
+
}
|
|
15
|
+
export interface IChatUpdate {
|
|
16
|
+
title?: string;
|
|
17
|
+
status?: 'active' | 'archived';
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/chat/chat.interfaces.ts"],"names":[],"mappings":""}
|