@stashfin/mysql2 1.4.28 → 1.4.31
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/models/ReferAndEarn.d.ts +49 -0
- package/models/WealthUser.d.ts +7 -0
- package/package.json +1 -1
- package/index copy.d.ts +0 -17
- package/index copy.js +0 -73
- package/models/location.d.ts +0 -19
- package/models/location.js +0 -2
package/models/ReferAndEarn.d.ts
CHANGED
|
@@ -11,5 +11,54 @@ export interface ReferEarnTrackingTable {
|
|
|
11
11
|
created_at: Date;
|
|
12
12
|
updated_at: Date;
|
|
13
13
|
}
|
|
14
|
+
interface Rule {
|
|
15
|
+
key: string;
|
|
16
|
+
value: string | number;
|
|
17
|
+
operator: string;
|
|
18
|
+
}
|
|
19
|
+
interface CommissionRule {
|
|
20
|
+
first: number;
|
|
21
|
+
trailing: number;
|
|
22
|
+
}
|
|
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
|
+
export interface ReferralOfferTable {
|
|
37
|
+
id: number;
|
|
38
|
+
title: string;
|
|
39
|
+
reward_type: string;
|
|
40
|
+
amount: number;
|
|
41
|
+
sc_type: string;
|
|
42
|
+
icon: string;
|
|
43
|
+
product_name: string;
|
|
44
|
+
product_sub_type: string;
|
|
45
|
+
description: string;
|
|
46
|
+
redirect_url: string;
|
|
47
|
+
is_active: boolean;
|
|
48
|
+
deleted: boolean;
|
|
49
|
+
csv_segment: number;
|
|
50
|
+
sc_expiry: Date;
|
|
51
|
+
expiry: Date;
|
|
52
|
+
commission_rule: CommissionRule;
|
|
53
|
+
rules: Rules;
|
|
54
|
+
metaData: MetaData;
|
|
55
|
+
stats: Stat;
|
|
56
|
+
created_at: Date;
|
|
57
|
+
updated_at: Date;
|
|
58
|
+
created_by: string;
|
|
59
|
+
}
|
|
14
60
|
export interface ReferEarnTrackingModel extends ReferEarnTrackingTable, RowDataPacket {
|
|
15
61
|
}
|
|
62
|
+
export interface ReferralOfferModel extends ReferralOfferTable, RowDataPacket {
|
|
63
|
+
}
|
|
64
|
+
export {};
|
package/models/WealthUser.d.ts
CHANGED
|
@@ -19,7 +19,14 @@ export interface WealthTransactionTable {
|
|
|
19
19
|
kyc_status?: 'pending' | 'rejected' | 'completed';
|
|
20
20
|
kyc_last_completed_step?: string;
|
|
21
21
|
}
|
|
22
|
+
export interface WealthEarningTable {
|
|
23
|
+
id: number;
|
|
24
|
+
earnings: number;
|
|
25
|
+
customer_id: number;
|
|
26
|
+
}
|
|
22
27
|
export interface WealthUserModel extends WealthUserTable, RowDataPacket {
|
|
23
28
|
}
|
|
24
29
|
export interface WealthTransactionModel extends WealthTransactionTable, RowDataPacket {
|
|
25
30
|
}
|
|
31
|
+
export interface WealthEarningModel extends WealthEarningTable, RowDataPacket {
|
|
32
|
+
}
|
package/package.json
CHANGED
package/index copy.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
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;
|
package/models/location.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
package/models/location.js
DELETED