@stashfin/mysql2 1.4.31 → 1.4.35
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/index copy.d.ts +17 -0
- package/index copy.js +73 -0
- package/models/Common.d.ts +18 -0
- package/models/Common.js +2 -0
- package/models/Customer.d.ts +9 -1
- package/models/Offer.d.ts +1 -19
- package/models/PanDetails.d.ts +2 -1
- package/models/ReferAndEarn.d.ts +2 -20
- package/models/location.d.ts +19 -0
- package/models/location.js +2 -0
- package/package.json +1 -1
package/index copy.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import mysql, { RowDataPacket, PoolOptions, ResultSetHeader } from 'mysql2/promise';
|
|
2
|
+
export interface MysqlConnectorOptions extends PoolOptions {
|
|
3
|
+
}
|
|
4
|
+
export declare class MysqlConnector {
|
|
5
|
+
private pool;
|
|
6
|
+
private credentials;
|
|
7
|
+
constructor(credentials: PoolOptions);
|
|
8
|
+
/** A random method to simulate a step before to get the class methods */
|
|
9
|
+
getConnection(): Promise<mysql.PoolConnection>;
|
|
10
|
+
queryRow<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T | undefined>;
|
|
11
|
+
queryRows<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T[]>;
|
|
12
|
+
queryArray<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T[]>;
|
|
13
|
+
executeResult(sql: string, values?: unknown[]): Promise<ResultSetHeader>;
|
|
14
|
+
insertData(tableName: string, data: Record<string, string | number>): Promise<ResultSetHeader>;
|
|
15
|
+
updateData(tableName: string, data: Record<string, any>, condition: string, conditionValues?: Array<string | number>): Promise<ResultSetHeader>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
package/index copy.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
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.MysqlConnector = void 0;
|
|
7
|
+
const promise_1 = __importDefault(require("mysql2/promise"));
|
|
8
|
+
//define class
|
|
9
|
+
class MysqlConnector {
|
|
10
|
+
pool;
|
|
11
|
+
credentials;
|
|
12
|
+
constructor(credentials) {
|
|
13
|
+
this.credentials = credentials;
|
|
14
|
+
this.pool = promise_1.default.createPool(this.credentials);
|
|
15
|
+
}
|
|
16
|
+
/** A random method to simulate a step before to get the class methods */
|
|
17
|
+
getConnection() {
|
|
18
|
+
if (!this?.pool)
|
|
19
|
+
this.pool = promise_1.default.createPool(this.credentials);
|
|
20
|
+
return this.pool.getConnection();
|
|
21
|
+
}
|
|
22
|
+
async queryRow(sql, values) {
|
|
23
|
+
const connection = await this.getConnection();
|
|
24
|
+
const [rows] = await connection.query(sql, values);
|
|
25
|
+
await connection.release();
|
|
26
|
+
return rows[0] || undefined;
|
|
27
|
+
}
|
|
28
|
+
async queryRows(sql, values) {
|
|
29
|
+
const connection = await this.getConnection();
|
|
30
|
+
const [rows] = await connection.query(sql, values);
|
|
31
|
+
await connection.release();
|
|
32
|
+
return rows;
|
|
33
|
+
}
|
|
34
|
+
async queryArray(sql, values) {
|
|
35
|
+
const connection = await this.getConnection();
|
|
36
|
+
const [rows] = await connection.query({
|
|
37
|
+
sql,
|
|
38
|
+
values,
|
|
39
|
+
rowsAsArray: true,
|
|
40
|
+
});
|
|
41
|
+
await connection.release();
|
|
42
|
+
return rows;
|
|
43
|
+
}
|
|
44
|
+
async executeResult(sql, values) {
|
|
45
|
+
const connection = await this.pool.getConnection();
|
|
46
|
+
const [rows] = await connection.query(sql, values);
|
|
47
|
+
await connection.release();
|
|
48
|
+
return rows;
|
|
49
|
+
}
|
|
50
|
+
async insertData(tableName, data) {
|
|
51
|
+
const keys = Object.keys(data);
|
|
52
|
+
const values = Object.values(data);
|
|
53
|
+
const sql = `INSERT INTO ${tableName} (${keys.join(', ')}) VALUES (${keys
|
|
54
|
+
.map(() => '?')
|
|
55
|
+
.join(', ')})`;
|
|
56
|
+
return this.executeResult(sql, values);
|
|
57
|
+
}
|
|
58
|
+
async updateData(tableName,
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
data, condition, conditionValues) {
|
|
61
|
+
const keys = Object.keys(data);
|
|
62
|
+
const values = Object.values(data);
|
|
63
|
+
const sql = `UPDATE ${tableName} SET ${keys
|
|
64
|
+
.map((key) => `${key} = ?`)
|
|
65
|
+
.join(', ')} WHERE ${condition}`;
|
|
66
|
+
const finalValues = [...values, ...(conditionValues || [])];
|
|
67
|
+
return this.executeResult(sql, finalValues);
|
|
68
|
+
}
|
|
69
|
+
async close() {
|
|
70
|
+
await this.pool.end();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.MysqlConnector = MysqlConnector;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface Rule {
|
|
2
|
+
key: string;
|
|
3
|
+
value: string | number;
|
|
4
|
+
operator: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Rules {
|
|
7
|
+
data: Rule[];
|
|
8
|
+
}
|
|
9
|
+
export interface MetaData {
|
|
10
|
+
icon: string;
|
|
11
|
+
title: string;
|
|
12
|
+
eligibilityCriteria: string;
|
|
13
|
+
steps: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface Stat {
|
|
16
|
+
count: number;
|
|
17
|
+
total: number;
|
|
18
|
+
}
|
package/models/Common.js
ADDED
package/models/Customer.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export interface CustomerTable {
|
|
|
60
60
|
is_active?: number | null;
|
|
61
61
|
/** Defaults to: 0. */
|
|
62
62
|
is_deleted?: number | null;
|
|
63
|
+
journey_updated_at?: Date | null;
|
|
63
64
|
}
|
|
64
65
|
export interface DemographicsTable {
|
|
65
66
|
id?: number;
|
|
@@ -75,7 +76,7 @@ export interface DemographicsTable {
|
|
|
75
76
|
marital_status?: string | null;
|
|
76
77
|
occupation?: string | null;
|
|
77
78
|
office_addr?: JSONValue | null;
|
|
78
|
-
|
|
79
|
+
organization?: string | null;
|
|
79
80
|
pan_url?: string | null;
|
|
80
81
|
perm_addr?: JSONValue | null;
|
|
81
82
|
res_addr?: JSONValue | null;
|
|
@@ -90,6 +91,13 @@ export interface DemographicsTable {
|
|
|
90
91
|
/** Defaults to: CURRENT_TIMESTAMP. */
|
|
91
92
|
created_at?: Date | null;
|
|
92
93
|
updated_at?: Date | null;
|
|
94
|
+
nsdl_dob_matched?: number | null;
|
|
95
|
+
okyc_dob?: string | null;
|
|
96
|
+
dob_attempts?: number | null;
|
|
97
|
+
is_upgradable?: number | null;
|
|
98
|
+
has_imps?: number | null;
|
|
99
|
+
journey_inactive?: number | null;
|
|
100
|
+
repeat_journey?: number | null;
|
|
93
101
|
}
|
|
94
102
|
export interface CustomerBanksTable {
|
|
95
103
|
id?: number;
|
package/models/Offer.d.ts
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import { RowDataPacket } from "mysql2";
|
|
2
|
-
|
|
3
|
-
key: string;
|
|
4
|
-
value: string | number;
|
|
5
|
-
operator: string;
|
|
6
|
-
}
|
|
7
|
-
interface Rules {
|
|
8
|
-
data: Rule[];
|
|
9
|
-
}
|
|
10
|
-
interface MetaData {
|
|
11
|
-
icon: string;
|
|
12
|
-
title: string;
|
|
13
|
-
eligibilityCriteria: string;
|
|
14
|
-
steps: string[];
|
|
15
|
-
}
|
|
16
|
-
export interface Stat {
|
|
17
|
-
count: number;
|
|
18
|
-
total: number;
|
|
19
|
-
}
|
|
2
|
+
import { MetaData, Rules, Stat } from "./Common";
|
|
20
3
|
export interface OfferTable {
|
|
21
4
|
id: number;
|
|
22
5
|
title: string;
|
|
@@ -48,4 +31,3 @@ export interface OfferTable {
|
|
|
48
31
|
}
|
|
49
32
|
export interface OfferModel extends OfferTable, RowDataPacket {
|
|
50
33
|
}
|
|
51
|
-
export {};
|
package/models/PanDetails.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type JSONObject = {
|
|
|
7
7
|
export type JSONArray = Array<JSONValue>;
|
|
8
8
|
export interface PanDetailsTable {
|
|
9
9
|
id?: number;
|
|
10
|
+
pan?: string | null;
|
|
10
11
|
customer_id?: number | null;
|
|
11
12
|
response?: JSONValue | null;
|
|
12
13
|
/** Defaults to: CURRENT_TIMESTAMP. */
|
|
@@ -14,5 +15,5 @@ export interface PanDetailsTable {
|
|
|
14
15
|
/** Defaults to: CURRENT_TIMESTAMP. */
|
|
15
16
|
updated_at?: Date | null;
|
|
16
17
|
}
|
|
17
|
-
export interface
|
|
18
|
+
export interface PanDetailsModel extends PanDetailsTable, RowDataPacket {
|
|
18
19
|
}
|
package/models/ReferAndEarn.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RowDataPacket } from "mysql2";
|
|
2
|
+
import { MetaData, Rules, Stat } from "./Common";
|
|
2
3
|
export interface ReferEarnTrackingTable {
|
|
3
4
|
id?: number;
|
|
4
5
|
referrer_id: number;
|
|
@@ -11,28 +12,10 @@ export interface ReferEarnTrackingTable {
|
|
|
11
12
|
created_at: Date;
|
|
12
13
|
updated_at: Date;
|
|
13
14
|
}
|
|
14
|
-
interface
|
|
15
|
-
key: string;
|
|
16
|
-
value: string | number;
|
|
17
|
-
operator: string;
|
|
18
|
-
}
|
|
19
|
-
interface CommissionRule {
|
|
15
|
+
export interface CommissionRule {
|
|
20
16
|
first: number;
|
|
21
17
|
trailing: number;
|
|
22
18
|
}
|
|
23
|
-
interface Rules {
|
|
24
|
-
data: Rule[];
|
|
25
|
-
}
|
|
26
|
-
interface MetaData {
|
|
27
|
-
icon: string;
|
|
28
|
-
title: string;
|
|
29
|
-
eligibilityCriteria: string;
|
|
30
|
-
steps: string[];
|
|
31
|
-
}
|
|
32
|
-
export interface Stat {
|
|
33
|
-
count: number;
|
|
34
|
-
total: number;
|
|
35
|
-
}
|
|
36
19
|
export interface ReferralOfferTable {
|
|
37
20
|
id: number;
|
|
38
21
|
title: string;
|
|
@@ -61,4 +44,3 @@ export interface ReferEarnTrackingModel extends ReferEarnTrackingTable, RowDataP
|
|
|
61
44
|
}
|
|
62
45
|
export interface ReferralOfferModel extends ReferralOfferTable, RowDataPacket {
|
|
63
46
|
}
|
|
64
|
-
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RowDataPacket } from 'mysql2';
|
|
2
|
+
export type JSONPrimitive = string | number | boolean | null;
|
|
3
|
+
export type JSONValue = JSONObject | JSONArray;
|
|
4
|
+
export type JSONObject = {
|
|
5
|
+
[member: string]: JSONPrimitive;
|
|
6
|
+
};
|
|
7
|
+
export type JSONArray = Array<JSONValue>;
|
|
8
|
+
export interface State {
|
|
9
|
+
id: number;
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
export interface City {
|
|
13
|
+
id: number;
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
export interface StateModel extends State, RowDataPacket {
|
|
17
|
+
}
|
|
18
|
+
export interface CityModel extends City, RowDataPacket {
|
|
19
|
+
}
|