@kipicore/dbcore 1.1.667 → 1.1.669
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.
|
@@ -7,6 +7,6 @@ export declare const paginationValidators: {
|
|
|
7
7
|
order: Joi.ArraySchema<string[][]>;
|
|
8
8
|
sort: Joi.StringSchema<string>;
|
|
9
9
|
};
|
|
10
|
-
export declare const enumAlternatives: (enumObj: Record<string, string>, isRequired?: boolean, allowArray?: boolean) => Joi.
|
|
10
|
+
export declare const enumAlternatives: (enumObj: Record<string, string>, isRequired?: boolean, allowArray?: boolean) => Joi.StringSchema<string> | Joi.AlternativesSchema<any>;
|
|
11
11
|
export declare const objectIdAlternatives: (isRequired?: boolean, allowArray?: boolean) => Joi.AlternativesSchema<any> | undefined;
|
|
12
12
|
export declare const uuidIdAlternatives: (isRequired?: boolean, allowArray?: boolean) => Joi.AlternativesSchema<any> | undefined;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sendPushNotification = void 0;
|
|
4
|
-
const
|
|
4
|
+
const app_1 = require("firebase-admin/app");
|
|
5
|
+
const messaging_1 = require("firebase-admin/messaging");
|
|
5
6
|
const env_1 = require("../configs/env");
|
|
6
7
|
// Initialize Firebase if not already initialized
|
|
7
|
-
if (!
|
|
8
|
-
|
|
9
|
-
credential:
|
|
8
|
+
if (!(0, app_1.getApps)().length) {
|
|
9
|
+
(0, app_1.initializeApp)({
|
|
10
|
+
credential: (0, app_1.cert)({
|
|
10
11
|
projectId: env_1.ENV_VARIABLE.FIREBASE_PROJECT_ID,
|
|
11
12
|
clientEmail: env_1.ENV_VARIABLE.FIREBASE_CLIENT_EMAIL,
|
|
12
13
|
privateKey: env_1.ENV_VARIABLE.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n'),
|
|
@@ -22,13 +23,12 @@ const sendPushNotification = async (deviceToken, notification) => {
|
|
|
22
23
|
},
|
|
23
24
|
token: deviceToken,
|
|
24
25
|
};
|
|
25
|
-
const response = await
|
|
26
|
+
const response = await (0, messaging_1.getMessaging)().send(payload);
|
|
26
27
|
return response;
|
|
27
28
|
}
|
|
28
29
|
catch (error) {
|
|
29
30
|
console.error('Error sending push notification:', error);
|
|
30
31
|
return;
|
|
31
|
-
// throw error;
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
exports.sendPushNotification = sendPushNotification;
|
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Request } from 'express';
|
|
2
|
+
import { TCustomHeaders } from '../types/commonType';
|
|
1
3
|
import { GRADE } from '../constants/app';
|
|
2
4
|
import Joi from 'joi';
|
|
3
5
|
import { OrderItem } from 'sequelize';
|
|
@@ -178,4 +180,5 @@ export declare const calculateGrade: (subject: {
|
|
|
178
180
|
export declare const getOverallGrade: (subjects: Subject[]) => GRADE;
|
|
179
181
|
export declare const readEmailTemplate: (templateName: string) => Promise<string>;
|
|
180
182
|
export declare const readEmailTemplateWithOutGlobal: (data: any, templateName?: string) => Promise<string>;
|
|
183
|
+
export declare const assignHeaderValues: <T extends Record<string, any>>(bodyData: T, req: Request, fields: Array<keyof TCustomHeaders>) => T;
|
|
181
184
|
export {};
|
package/dist/helpers/utils.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.readEmailTemplateWithOutGlobal = exports.readEmailTemplate = exports.getOverallGrade = exports.calculateGrade = exports.getNextLetter = exports.getCityAreas = exports.generateVoucherCode = exports.verifyHmacSHA256 = exports.generateHmacSHA256 = exports.customPagination = exports.fromSnakeCaseToNormalText = exports.normalizeToArray = exports.capitalizeFirst = exports.parseOrderOptions = exports.isValidUUID = exports.removeFalsyValues = exports.flattenNestedStructure = exports.buildNestedStructure = exports.getParentsByChildrenId = exports.getChildrenByParentId = exports.sortArray = exports.groupByFields = exports.endOfDay = exports.generateUuidToNumber = exports.startOfDay = exports.isDateWithinRange = exports.isTimeWithinRange = exports.keyByFieldOrFields = exports.getUniqueArrayByFields = exports.generateTempPassword = exports.generateAlphaNumericCode = exports.generateOtp = exports.ensureDirectoryExists = exports.omit = exports.isValidMongoDbId = exports.pick = void 0;
|
|
39
|
+
exports.assignHeaderValues = exports.readEmailTemplateWithOutGlobal = exports.readEmailTemplate = exports.getOverallGrade = exports.calculateGrade = exports.getNextLetter = exports.getCityAreas = exports.generateVoucherCode = exports.verifyHmacSHA256 = exports.generateHmacSHA256 = exports.customPagination = exports.fromSnakeCaseToNormalText = exports.normalizeToArray = exports.capitalizeFirst = exports.parseOrderOptions = exports.isValidUUID = exports.removeFalsyValues = exports.flattenNestedStructure = exports.buildNestedStructure = exports.getParentsByChildrenId = exports.getChildrenByParentId = exports.sortArray = exports.groupByFields = exports.endOfDay = exports.generateUuidToNumber = exports.startOfDay = exports.isDateWithinRange = exports.isTimeWithinRange = exports.keyByFieldOrFields = exports.getUniqueArrayByFields = exports.generateTempPassword = exports.generateAlphaNumericCode = exports.generateOtp = exports.ensureDirectoryExists = exports.omit = exports.isValidMongoDbId = exports.pick = void 0;
|
|
40
40
|
exports.groupByFieldOrFields = groupByFieldOrFields;
|
|
41
41
|
exports.slugify = slugify;
|
|
42
42
|
exports.assignNonNull = assignNonNull;
|
|
@@ -776,3 +776,15 @@ const readEmailTemplateWithOutGlobal = async (data, templateName) => {
|
|
|
776
776
|
});
|
|
777
777
|
};
|
|
778
778
|
exports.readEmailTemplateWithOutGlobal = readEmailTemplateWithOutGlobal;
|
|
779
|
+
const assignHeaderValues = (bodyData, req, fields) => {
|
|
780
|
+
fields.forEach(field => {
|
|
781
|
+
const key = field;
|
|
782
|
+
if (bodyData[key] !== undefined && bodyData[key] !== null)
|
|
783
|
+
return;
|
|
784
|
+
if (req.customHeaders?.[field] !== undefined && req.customHeaders?.[field] !== null) {
|
|
785
|
+
bodyData[key] = req.customHeaders[field];
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
return bodyData;
|
|
789
|
+
};
|
|
790
|
+
exports.assignHeaderValues = assignHeaderValues;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
|
+
import { APP_TYPE } from '../constants/app';
|
|
3
|
+
export type TCustomHeaders = {
|
|
4
|
+
appType?: APP_TYPE;
|
|
5
|
+
token?: string;
|
|
6
|
+
deviceId?: string;
|
|
7
|
+
deviceToken?: string;
|
|
8
|
+
academicCalendarId?: string;
|
|
9
|
+
instituteId?: string;
|
|
10
|
+
};
|
|
2
11
|
export type TPaginationOptions<T> = {
|
|
3
12
|
limit: number | undefined;
|
|
4
13
|
totalRecords: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kipicore/dbcore",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.669",
|
|
4
4
|
"description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"date-fns": "^4.1.0",
|
|
49
49
|
"dotenv": "^17.2.2",
|
|
50
50
|
"ejs": "^3.1.10",
|
|
51
|
-
"firebase-admin": "^
|
|
51
|
+
"firebase-admin": "^13.4.0",
|
|
52
52
|
"ioredis": "^5.11.1",
|
|
53
53
|
"joi": "^18.0.1",
|
|
54
54
|
"mongoose": "^8.5.2",
|
|
@@ -80,4 +80,4 @@
|
|
|
80
80
|
"LICENSE",
|
|
81
81
|
".sequelizerc"
|
|
82
82
|
]
|
|
83
|
-
}
|
|
83
|
+
}
|