@kipicore/dbcore 1.1.3 → 1.1.5
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/helpers/utils.d.ts +1 -1
- package/dist/helpers/utils.js +7 -7
- package/dist/models/mongodb/subjectIndexModel.js +3 -3
- package/dist/models/mongodb/subscriptionPlanModel.d.ts +2 -2
- package/dist/models/mongodb/subscriptionPlanModel.js +6 -3
- package/dist/models/mongodb/taskManagementModel.js +2 -2
- package/dist/models/psql/userModel.js +2 -2
- package/package.json +2 -2
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare function groupByFieldOrFields<T>(array: T[], fields: keyof T | (k
|
|
|
21
21
|
export declare const isTimeWithinRange: (time: Date, rangeStart: Date, rangeEnd: Date) => boolean;
|
|
22
22
|
export declare const isDateWithinRange: (date: Date | string, rangeStart: Date | string, rangeEnd: Date | string) => boolean;
|
|
23
23
|
export declare const startOfDay: (date: string | Date) => Date;
|
|
24
|
-
export declare const generateUuidToNumber: (
|
|
24
|
+
export declare const generateUuidToNumber: (uuid1?: string) => string;
|
|
25
25
|
export declare const endOfDay: (date: string | Date) => Date;
|
|
26
26
|
type GroupByFields<T> = (array: T[], fields: keyof T | (keyof T)[]) => Record<string, T[]>;
|
|
27
27
|
export declare const groupByFields: GroupByFields<any>;
|
package/dist/helpers/utils.js
CHANGED
|
@@ -48,7 +48,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
48
48
|
const dateFunction = __importStar(require("date-fns"));
|
|
49
49
|
const app_js_1 = require("../constants/app.js");
|
|
50
50
|
const joi_1 = __importDefault(require("joi"));
|
|
51
|
-
const uuid_1 = require("uuid");
|
|
51
|
+
const uuid_1 = __importDefault(require("uuid"));
|
|
52
52
|
const crypto_1 = __importDefault(require("crypto"));
|
|
53
53
|
const sequelize_1 = require("sequelize");
|
|
54
54
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -230,11 +230,11 @@ const startOfDay = (date) => {
|
|
|
230
230
|
return dateFunction.startOfDay(dateFunction.parseISO(new Date(date).toISOString()));
|
|
231
231
|
};
|
|
232
232
|
exports.startOfDay = startOfDay;
|
|
233
|
-
const generateUuidToNumber = (
|
|
234
|
-
if (!
|
|
235
|
-
|
|
233
|
+
const generateUuidToNumber = (uuid1) => {
|
|
234
|
+
if (!uuid1)
|
|
235
|
+
uuid1 = uuid_1.default.v4();
|
|
236
236
|
// Remove dashes from the UUID
|
|
237
|
-
let numericId =
|
|
237
|
+
let numericId = uuid1.replace(/-/g, '');
|
|
238
238
|
// Convert hex characters to numbers (keeping only digits)
|
|
239
239
|
numericId = BigInt('0x' + numericId).toString();
|
|
240
240
|
return numericId;
|
|
@@ -470,9 +470,9 @@ const removeFalsyValues = (obj) => {
|
|
|
470
470
|
};
|
|
471
471
|
exports.removeFalsyValues = removeFalsyValues;
|
|
472
472
|
const isValidUUID = (id, expectedVersion) => {
|
|
473
|
-
if (!
|
|
473
|
+
if (!uuid_1.default.validate(id))
|
|
474
474
|
return false;
|
|
475
|
-
if (expectedVersion &&
|
|
475
|
+
if (expectedVersion && uuid_1.default.version(id) !== expectedVersion)
|
|
476
476
|
return false;
|
|
477
477
|
return true;
|
|
478
478
|
};
|
|
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
40
40
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
41
41
|
const app_js_1 = require("../../constants/app.js");
|
|
42
|
-
const uuid_1 = require("uuid");
|
|
42
|
+
const uuid_1 = __importDefault(require("uuid"));
|
|
43
43
|
const utils_js_1 = require("../../helpers/utils.js");
|
|
44
44
|
const sequelize_1 = require("sequelize");
|
|
45
45
|
const env_js_1 = require("../../configs/env.js");
|
|
@@ -351,7 +351,7 @@ const creatOrUpdateHook = async (subjectIndex) => {
|
|
|
351
351
|
}
|
|
352
352
|
for (const chapterIndex of subjectIndex.chapterIndex) {
|
|
353
353
|
if (!chapterIndex.id)
|
|
354
|
-
chapterIndex.id =
|
|
354
|
+
chapterIndex.id = uuid_1.default.v4();
|
|
355
355
|
if (chapterIndex.type !== app_js_1.CHAPTER_INDEX_TYPE.CHAPTER) {
|
|
356
356
|
const parentChapterIndex = subjectIndex.chapterIndex.find((index) => index.id === chapterIndex.parentId);
|
|
357
357
|
if (!parentChapterIndex)
|
|
@@ -373,7 +373,7 @@ const creatOrUpdateHook = async (subjectIndex) => {
|
|
|
373
373
|
// }
|
|
374
374
|
chapterIndex.files = chapterIndex.files.map((file) => {
|
|
375
375
|
if (!file.id)
|
|
376
|
-
file.id =
|
|
376
|
+
file.id = uuid_1.default.v4();
|
|
377
377
|
return file;
|
|
378
378
|
});
|
|
379
379
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model } from
|
|
2
|
-
import { ISubscriptionPlanModelAttributes } from
|
|
1
|
+
import { Model } from "mongoose";
|
|
2
|
+
import { ISubscriptionPlanModelAttributes } from "../../interfaces/subscriptionPlanInterface.js";
|
|
3
3
|
declare const SubscriptionPlanModel: Model<ISubscriptionPlanModelAttributes>;
|
|
4
4
|
export default SubscriptionPlanModel;
|
|
@@ -32,9 +32,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
37
|
-
const uuid_1 = require("uuid");
|
|
40
|
+
const uuid_1 = __importDefault(require("uuid"));
|
|
38
41
|
const app_js_1 = require("../../constants/app.js");
|
|
39
42
|
const subscriptionPlanFilesSchema = new mongoose_1.Schema({
|
|
40
43
|
type: {
|
|
@@ -55,7 +58,7 @@ const subscriptionPlanModelSchema = new mongoose_1.Schema({
|
|
|
55
58
|
uuid: {
|
|
56
59
|
type: String,
|
|
57
60
|
required: true,
|
|
58
|
-
default: uuid_1.v4,
|
|
61
|
+
default: uuid_1.default.v4(),
|
|
59
62
|
},
|
|
60
63
|
title: {
|
|
61
64
|
type: String,
|
|
@@ -129,5 +132,5 @@ const subscriptionPlanModelSchema = new mongoose_1.Schema({
|
|
|
129
132
|
timestamps: true,
|
|
130
133
|
versionKey: false,
|
|
131
134
|
});
|
|
132
|
-
const SubscriptionPlanModel = mongoose_1.default.model(
|
|
135
|
+
const SubscriptionPlanModel = mongoose_1.default.model("subscription_plans", subscriptionPlanModelSchema);
|
|
133
136
|
exports.default = SubscriptionPlanModel;
|
|
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
40
|
-
const uuid_1 = require("uuid");
|
|
40
|
+
const uuid_1 = __importDefault(require("uuid"));
|
|
41
41
|
const app_js_1 = require("../../constants/app.js");
|
|
42
42
|
const sequelize_1 = require("sequelize");
|
|
43
43
|
const errorMessages_js_1 = require("../../constants/errorMessages.js");
|
|
@@ -46,7 +46,7 @@ const userModel_js_1 = __importDefault(require("../psql/userModel.js"));
|
|
|
46
46
|
const TaskConversationsSchema = new mongoose_1.Schema({
|
|
47
47
|
messageId: {
|
|
48
48
|
type: String,
|
|
49
|
-
default: uuid_1.v4,
|
|
49
|
+
default: uuid_1.default.v4(),
|
|
50
50
|
},
|
|
51
51
|
userId: {
|
|
52
52
|
type: String,
|
|
@@ -10,7 +10,7 @@ const countryModel_js_1 = __importDefault(require("./countryModel.js"));
|
|
|
10
10
|
const stateModel_js_1 = __importDefault(require("./stateModel.js"));
|
|
11
11
|
const cityModel_js_1 = __importDefault(require("./cityModel.js"));
|
|
12
12
|
const tokenModel_js_1 = __importDefault(require("./tokenModel.js"));
|
|
13
|
-
const uuid_1 = require("uuid");
|
|
13
|
+
const uuid_1 = __importDefault(require("uuid"));
|
|
14
14
|
const areaModel_js_1 = __importDefault(require("./areaModel.js"));
|
|
15
15
|
const utils_js_1 = require("../../helpers/utils.js");
|
|
16
16
|
const uniqueNumberCounterModel_js_1 = __importDefault(require("../mongodb/uniqueNumberCounterModel.js"));
|
|
@@ -361,7 +361,7 @@ const userBeforeCreateHook = async (user) => {
|
|
|
361
361
|
if (user.type) {
|
|
362
362
|
user.globalId = await generateGlobalUniqueNumber(app_js_1.TYPE_OF_USER.USER, user.type);
|
|
363
363
|
}
|
|
364
|
-
user.uuid =
|
|
364
|
+
user.uuid = uuid_1.default.v4();
|
|
365
365
|
const where = {
|
|
366
366
|
email: user.email,
|
|
367
367
|
uuid: { [sequelize_1.Op.ne]: null }, // uuid must not be null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kipicore/dbcore",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"mongoose": "^8.5.2",
|
|
33
33
|
"pg": "^8.12.0",
|
|
34
34
|
"sequelize": "^6.37.3",
|
|
35
|
-
"uuid": "^
|
|
35
|
+
"uuid": "^8.3.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/mongoose": "^5.11.97",
|