@stashfin/mysql2 1.3.0 → 1.3.2

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.
@@ -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
+ }
@@ -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;
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import mysql, { RowDataPacket, PoolOptions, ResultSetHeader } from 'mysql2/promise';
1
+ import mysql, { RowDataPacket, PoolOptions, ResultSetHeader } from 'mysql2';
2
2
  export interface MysqlConnectorOptions extends PoolOptions {
3
3
  }
4
4
  export declare class MysqlConnector {
@@ -6,12 +6,13 @@ export declare class MysqlConnector {
6
6
  private credentials;
7
7
  constructor(credentials: PoolOptions);
8
8
  /** A random method to simulate a step before to get the class methods */
9
- getConnection(): Promise<mysql.PoolConnection>;
9
+ getPoolConnection(): mysql.Pool;
10
+ getConnection(): (callback: (err: NodeJS.ErrnoException | null, connection: import("mysql2/typings/mysql/lib/PoolConnection").PoolConnection) => any) => void;
10
11
  queryRow<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T | undefined>;
11
12
  queryRows<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T[]>;
12
13
  queryArray<T extends RowDataPacket>(sql: string, values?: Array<string | number>): Promise<T[]>;
13
14
  executeResult(sql: string, values?: unknown[]): Promise<ResultSetHeader>;
14
15
  insertData(tableName: string, data: Record<string, string | number>): Promise<ResultSetHeader>;
15
- updateData(tableName: string, data: Record<string, string | number>, condition: string): Promise<ResultSetHeader>;
16
+ updateData(tableName: string, data: Record<string, any>, condition: string, conditionValues?: Array<string | number>): Promise<ResultSetHeader>;
16
17
  close(): Promise<void>;
17
18
  }
package/index.js CHANGED
@@ -4,47 +4,73 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MysqlConnector = void 0;
7
- const promise_1 = __importDefault(require("mysql2/promise"));
7
+ const mysql2_1 = __importDefault(require("mysql2"));
8
8
  //define class
9
9
  class MysqlConnector {
10
10
  pool;
11
11
  credentials;
12
12
  constructor(credentials) {
13
13
  this.credentials = credentials;
14
- this.pool = promise_1.default.createPool(this.credentials);
14
+ this.pool = mysql2_1.default.createPool(this.credentials);
15
15
  }
16
16
  /** A random method to simulate a step before to get the class methods */
17
+ getPoolConnection() {
18
+ if (!this?.pool)
19
+ this.pool = mysql2_1.default.createPool(this.credentials);
20
+ return this.pool;
21
+ }
17
22
  getConnection() {
18
23
  if (!this?.pool)
19
- this.pool = promise_1.default.createPool(this.credentials);
20
- return this.pool.getConnection();
24
+ this.pool = mysql2_1.default.createPool(this.credentials);
25
+ return this.pool.getConnection;
21
26
  }
22
27
  async queryRow(sql, values) {
23
- const connection = await this.getConnection();
24
- const [rows] = await connection.query(sql, values);
25
- return rows[0] || undefined;
28
+ const pool = this.getPoolConnection();
29
+ return new Promise((resolve, reject) => {
30
+ pool.query(sql, values, function (err, results, fields) {
31
+ if (err)
32
+ reject(err);
33
+ // Connection is automatically released when query resolves
34
+ else
35
+ resolve(results[0] || undefined);
36
+ });
37
+ });
26
38
  }
27
39
  async queryRows(sql, values) {
28
- const connection = await this.getConnection();
29
- const [rows] = await connection.query(sql, values);
30
- await connection.release();
31
- return rows;
40
+ const pool = this.getPoolConnection();
41
+ return new Promise((resolve, reject) => {
42
+ pool.query(sql, values, function (err, results, fields) {
43
+ // Connection is automatically released when query resolves
44
+ if (err)
45
+ reject(err);
46
+ else
47
+ resolve(results);
48
+ });
49
+ });
32
50
  }
33
51
  async queryArray(sql, values) {
34
- const connection = await this.getConnection();
35
- const [rows] = await connection.query({
36
- sql,
37
- values,
38
- rowsAsArray: true,
52
+ const pool = this.getPoolConnection();
53
+ return new Promise((resolve, reject) => {
54
+ pool.query({ sql, values, rowsAsArray: true }, function (err, results, fields) {
55
+ // Connection is automatically released when query resolves
56
+ if (err)
57
+ reject(err);
58
+ else
59
+ resolve(results);
60
+ });
39
61
  });
40
- await connection.release();
41
- return rows;
42
62
  }
43
63
  async executeResult(sql, values) {
44
- const connection = await this.pool.getConnection();
45
- const [rows] = await connection.query(sql, values);
46
- await connection.release();
47
- return rows;
64
+ const pool = this.getPoolConnection();
65
+ return new Promise((resolve, reject) => {
66
+ pool.query(sql, values, function (err, results, fields) {
67
+ // Connection is automatically released when query resolves
68
+ if (err)
69
+ reject(err);
70
+ else
71
+ resolve(results || undefined);
72
+ });
73
+ });
48
74
  }
49
75
  async insertData(tableName, data) {
50
76
  const keys = Object.keys(data);
@@ -54,13 +80,16 @@ class MysqlConnector {
54
80
  .join(', ')})`;
55
81
  return this.executeResult(sql, values);
56
82
  }
57
- async updateData(tableName, data, condition) {
83
+ async updateData(tableName,
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
+ data, condition, conditionValues) {
58
86
  const keys = Object.keys(data);
59
87
  const values = Object.values(data);
60
88
  const sql = `UPDATE ${tableName} SET ${keys
61
89
  .map((key) => `${key} = ?`)
62
90
  .join(', ')} WHERE ${condition}`;
63
- return this.executeResult(sql, values);
91
+ const finalValues = [...values, ...(conditionValues || [])];
92
+ return this.executeResult(sql, finalValues);
64
93
  }
65
94
  async close() {
66
95
  await this.pool.end();
@@ -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
+ }
@@ -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,21 @@
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 BannerTable {
9
+ id: number;
10
+ name: string;
11
+ image_url: string;
12
+ web_url?: string | null;
13
+ landing_page?: string | null;
14
+ api_mode?: string | null;
15
+ app_version: number;
16
+ status: string;
17
+ created_at: Date;
18
+ updated_at: Date;
19
+ }
20
+ export interface BannerModel extends BannerTable, RowDataPacket {
21
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,65 +1,98 @@
1
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>;
2
8
  export interface CustomerTable {
3
- id?: number;
9
+ id: number;
4
10
  mobile: string;
5
- email?: string;
6
- firstName?: string;
7
- middleName?: string;
8
- lastName?: string;
9
- fatherName?: string;
10
- motherMaidenName?: string;
11
- dob?: string;
12
- companyName?: string;
13
- pincode?: string;
14
- mpin?: string;
15
- pan?: string;
16
- aadhaar?: string;
17
- mobileVerified?: boolean;
18
- emailVerified?: boolean;
19
- ip?: string;
20
- deviceId?: string;
21
- osVersion?: string;
22
- pushId?: string;
23
- authToken?: string;
24
- appVersion?: string;
25
- biometricEnabled?: boolean;
26
- journeyStep?: number;
27
- category?: string;
28
- locLimit?: number;
29
- status?: 'active' | 'inactive';
30
- source?: string;
31
- tncVersion?: string;
32
- loginDate?: string;
33
- agentId?: number;
34
- createdAt?: string;
35
- updatedAt?: string;
36
- isActive?: boolean;
37
- isDeleted?: boolean;
11
+ email?: string | null;
12
+ first_name?: string | null;
13
+ middle_name?: string | null;
14
+ last_name?: string | null;
15
+ father_name?: string | null;
16
+ mother_maiden_name?: string | null;
17
+ dob?: Date | null;
18
+ company_name?: string | null;
19
+ pincode?: string | null;
20
+ mpin?: string | null;
21
+ pan?: string | null;
22
+ aadhaar?: string | null;
23
+ mobile_verified?: number | null;
24
+ email_verified?: number | null;
25
+ ip?: string | null;
26
+ device_id?: string | null;
27
+ is_registered?: number | null;
28
+ mobile_hash?: string | null;
29
+ email_hash?: string | null;
30
+ os_version?: string | null;
31
+ push_id?: string | null;
32
+ auth_token?: string | null;
33
+ app_version?: string | null;
34
+ biometric_enabled?: number | null;
35
+ journey_sequence?: number | null;
36
+ category?: string | null;
37
+ loc_limit?: number | null;
38
+ /** Defaults to: active. */
39
+ status?: 'active' | 'inactive' | null;
40
+ source?: string | null;
41
+ tnc_version?: string | null;
42
+ login_date?: Date | null;
43
+ agent_id?: number | null;
44
+ /** Defaults to: CURRENT_TIMESTAMP. */
45
+ created_at?: Date | null;
46
+ /** Defaults to: CURRENT_TIMESTAMP. */
47
+ updated_at?: Date | null;
48
+ /** Defaults to: 1. */
49
+ is_active?: number | null;
50
+ /** Defaults to: 0. */
51
+ is_deleted?: number | null;
38
52
  }
39
53
  export interface DemographicsTable {
40
54
  id?: number;
41
- customerId: number;
42
- aadhaarName?: string;
43
- salary?: number;
44
- salaryDate?: string;
45
- salaryMode?: string;
46
- gender?: string;
47
- maritalStatus?: string;
48
- occupation?: string;
49
- photo?: string;
50
- gstNo?: string;
51
- crn?: string;
52
- organizationId?: number;
53
- latitude?: number;
54
- longitude?: number;
55
- language?: string;
56
- residentialAddr?: object;
57
- officeAddr?: object;
58
- device?: object;
59
- createdAt?: string;
60
- updatedAt?: string;
55
+ customer_id: number;
56
+ aadhaar_name?: string | null;
57
+ crn?: string | null;
58
+ device?: JSONValue | null;
59
+ gender?: string | null;
60
+ gst_no?: string | null;
61
+ language?: string | null;
62
+ latitude?: number | null;
63
+ longitude?: number | null;
64
+ marital_status?: string | null;
65
+ occupation?: string | null;
66
+ office_addr?: JSONValue | null;
67
+ organization_id?: number | null;
68
+ pan_url?: string | null;
69
+ perm_addr?: JSONValue | null;
70
+ res_addr?: JSONValue | null;
71
+ salary?: number | null;
72
+ salary_date?: Date | null;
73
+ salary_mode?: string | null;
74
+ selfie_url?: string | null;
75
+ /** Defaults to: CURRENT_TIMESTAMP. */
76
+ created_at?: Date | null;
77
+ updated_at?: Date | null;
78
+ }
79
+ export interface CustomerBanksTable {
80
+ id?: number;
81
+ customer_id: number;
82
+ account_number: string;
83
+ address?: string | null;
84
+ bank_name?: string | null;
85
+ ifsc_code?: string | null;
86
+ /** Defaults to: active. */
87
+ status?: 'active' | 'inactive';
88
+ is_primary?: boolean;
89
+ /** Defaults to: CURRENT_TIMESTAMP. */
90
+ created_at?: Date | null;
91
+ updated_at?: Date | null;
61
92
  }
62
93
  export interface CustomerModel extends CustomerTable, RowDataPacket {
63
94
  }
95
+ export interface CustomerBanksModel extends CustomerBanksTable, RowDataPacket {
96
+ }
64
97
  export interface DemographicsModel extends DemographicsTable, RowDataPacket {
65
98
  }
@@ -0,0 +1,30 @@
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 DashboardBlock {
9
+ block_name: string;
10
+ block_title: string;
11
+ block_code: string;
12
+ text: string;
13
+ image_url: string;
14
+ video_url?: string;
15
+ video_length?: number;
16
+ action_url?: string;
17
+ landing_page?: string;
18
+ api_mode?: string;
19
+ app_version: string;
20
+ old_customers: boolean;
21
+ is_new?: boolean;
22
+ action_type?: string;
23
+ color1?: string;
24
+ color2?: string;
25
+ image_trailing?: boolean;
26
+ tag?: JSONValue;
27
+ overlay_image?: string;
28
+ }
29
+ export interface DashboardBlockModel extends DashboardBlock, RowDataPacket {
30
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -14,9 +14,10 @@ export interface JourneySteps {
14
14
  category: string;
15
15
  step: string;
16
16
  data: JSONValue;
17
+ sequence?: number | null;
18
+ fields?: string | null;
17
19
  /** Defaults to: CURRENT_TIMESTAMP. */
18
20
  created_at?: Date | null;
19
- /** Defaults to: CURRENT_TIMESTAMP. */
20
21
  updated_at?: Date | null;
21
22
  }
22
23
  export interface JourneyStepsModel extends JourneySteps, RowDataPacket {
@@ -0,0 +1,43 @@
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 LoansTable {
9
+ id?: number | null;
10
+ customer_id: number | null;
11
+ category?: string | null;
12
+ ref_id: string | null;
13
+ amount?: number | null;
14
+ disbursal_amount?: number | null;
15
+ bill_amount?: number | null;
16
+ bill_date?: Date | null;
17
+ roi?: number | null;
18
+ tenure: number | null;
19
+ fees?: JSONValue;
20
+ daily_roi?: string | null;
21
+ /** Defaults to: processing_fee. */
22
+ disbursal_mode?: 'IMPS' | 'NEFT' | null;
23
+ /** Defaults to: active. */
24
+ status?: 'pending' | 'active' | 'close' | 'restructured' | 'rejected' | 'approved' | 'cancelled' | null;
25
+ source?: 'app' | 'thirdparty' | null;
26
+ ip?: string | null;
27
+ approval_date?: Date | null;
28
+ disbursal_date?: string | null;
29
+ closure_date?: Date | null;
30
+ is_auto_processing?: number | null;
31
+ remarks?: string | null;
32
+ restructure_id?: number | null;
33
+ emi_start_date?: Date | null;
34
+ created_at?: Date | null;
35
+ /** Defaults to: CURRENT_TIMESTAMP. */
36
+ updated_at?: Date | null;
37
+ /** Defaults to: 1. */
38
+ is_active?: number | null;
39
+ /** Defaults to: 0. */
40
+ is_deleted?: number | null;
41
+ }
42
+ export interface LoansModel extends LoansTable, RowDataPacket {
43
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,51 @@
1
+ import { RowDataPacket } from "mysql2";
2
+ interface Rule {
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
+ interface Stat {
17
+ count: number;
18
+ total: number;
19
+ }
20
+ export interface OfferTable {
21
+ id: number;
22
+ title: string;
23
+ reward_type: string;
24
+ amount: number;
25
+ sc_type: string;
26
+ discount_type: string;
27
+ max_value: number;
28
+ rpu: number;
29
+ budget: number;
30
+ icon: string;
31
+ event_name: string;
32
+ event_sub_type: string;
33
+ description: string;
34
+ redirect_url: string;
35
+ offer_type: string;
36
+ start_required: boolean;
37
+ is_active: boolean;
38
+ deleted: boolean;
39
+ csv_segment: number;
40
+ sc_expiry: Date;
41
+ expiry: Date;
42
+ rules: Rules;
43
+ metaData: MetaData;
44
+ stats: Stat;
45
+ created_at: Date;
46
+ updated_at: Date;
47
+ created_by: string;
48
+ }
49
+ export interface OfferModel extends OfferTable, RowDataPacket {
50
+ }
51
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,29 +2,36 @@ import { RowDataPacket } from 'mysql2';
2
2
  export interface StashCashTable {
3
3
  id?: number;
4
4
  customer_id: number;
5
+ /** Defaults to: 0 */
5
6
  locked: number;
6
7
  unlocked: number;
7
- created_at: Date;
8
- updated_at: Date;
9
- is_active: boolean;
10
- is_deleted: boolean;
8
+ /** Defaults to: CURRENT_TIMESTAMP. */
9
+ created_at?: Date | null;
10
+ updated_at?: Date | null;
11
+ user_guide?: boolean;
12
+ is_active?: boolean;
13
+ is_deleted?: boolean;
11
14
  }
12
15
  export interface StashCashTrascationTable {
13
16
  id?: number;
14
- customer_id: number;
15
- campaign_id: number;
16
- txn_id: number;
17
+ customer_id?: number;
18
+ campaign_id?: number;
19
+ campaign_name: string;
20
+ txn_id: string;
17
21
  sc_type: string;
18
22
  amount: number;
19
- balance: number;
23
+ locked: number;
24
+ unlocked: number;
20
25
  remaining: number;
21
- txn_type: string;
22
- status: string;
23
- expiry: Date;
24
- created_at: Date;
25
- updated_at: Date;
26
- is_active: boolean;
27
- is_deleted: boolean;
26
+ txn_type: 'debit' | 'credit' | 'expired' | 'reversal';
27
+ status?: 'pending' | 'success' | 'failure' | 'reversed';
28
+ expiry?: Date | null;
29
+ is_expired: boolean;
30
+ /** Defaults to: CURRENT_TIMESTAMP. */
31
+ created_at?: Date | null;
32
+ updated_at?: Date | null;
33
+ is_active?: boolean;
34
+ is_deleted?: boolean;
28
35
  }
29
36
  export interface StashCashModel extends StashCashTable, RowDataPacket {
30
37
  }
@@ -7,5 +7,5 @@ export interface UserAuthTokenTable {
7
7
  published: number;
8
8
  device_id: string;
9
9
  }
10
- export interface UserAuthTokenModel extends UserAuthTokenTable, RowDataPacket {
10
+ export interface UserAuthTokenModel extends RowDataPacket {
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import { RowDataPacket } from 'mysql2';
2
2
  export interface UserDetailTable {
3
- id: number;
3
+ id: string;
4
4
  first_name: string;
5
5
  middle_name: string;
6
6
  last_name: string;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@stashfin/mysql2",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc --build",
9
+ "build:ws": "tsc --build && copy package.json dist/",
9
10
  "postbuild": "cp package.json dist/ ",
10
11
  "publish:patch": "npm version patch && npm run build && cd dist && npm publish --access public",
11
12
  "publish:minor": "npm version minor && npm run build && cd dist && npm publish --access public"
@@ -15,5 +16,8 @@
15
16
  "license": "ISC",
16
17
  "dependencies": {
17
18
  "mysql2": "^3.9.9"
19
+ },
20
+ "devDependencies": {
21
+ "cpy-cli": "^5.0.0"
18
22
  }
19
23
  }