@fplpool/fpl-models 1.0.0 → 1.1.1
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/config/index.d.ts +34 -0
- package/dist/config/index.d.ts.map +1 -0
- package/{src/config/index.ts → dist/config/index.js} +7 -8
- package/dist/config/index.js.map +1 -0
- package/dist/enums/status-code.enum.d.ts +32 -0
- package/dist/enums/status-code.enum.d.ts.map +1 -0
- package/dist/enums/status-code.enum.js +36 -0
- package/dist/enums/status-code.enum.js.map +1 -0
- package/dist/enums/status.enum.d.ts +7 -0
- package/dist/enums/status.enum.d.ts.map +1 -0
- package/dist/enums/status.enum.js +10 -0
- package/dist/enums/status.enum.js.map +1 -0
- package/dist/errors/advanced.error.d.ts +5 -0
- package/dist/errors/advanced.error.d.ts.map +1 -0
- package/dist/errors/advanced.error.js +10 -0
- package/dist/errors/advanced.error.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/models/card.model.d.ts +22 -0
- package/dist/models/card.model.d.ts.map +1 -0
- package/{src/models/card.model.ts → dist/models/card.model.js} +20 -35
- package/dist/models/card.model.js.map +1 -0
- package/dist/models/config.model.d.ts +21 -0
- package/dist/models/config.model.d.ts.map +1 -0
- package/{src/models/config.model.ts → dist/models/config.model.js} +8 -23
- package/dist/models/config.model.js.map +1 -0
- package/dist/models/invoice.model.d.ts +35 -0
- package/dist/models/invoice.model.d.ts.map +1 -0
- package/dist/models/invoice.model.js +79 -0
- package/dist/models/invoice.model.js.map +1 -0
- package/dist/models/job.model.d.ts +26 -0
- package/dist/models/job.model.d.ts.map +1 -0
- package/dist/models/job.model.js +48 -0
- package/dist/models/job.model.js.map +1 -0
- package/dist/models/pool-gameweek-deadline.model.d.ts +22 -0
- package/dist/models/pool-gameweek-deadline.model.d.ts.map +1 -0
- package/dist/models/pool-gameweek-deadline.model.js +42 -0
- package/dist/models/pool-gameweek-deadline.model.js.map +1 -0
- package/dist/models/pool-gameweek-winner.model.d.ts +24 -0
- package/dist/models/pool-gameweek-winner.model.d.ts.map +1 -0
- package/dist/models/pool-gameweek-winner.model.js +43 -0
- package/dist/models/pool-gameweek-winner.model.js.map +1 -0
- package/dist/models/pool-gameweek.model.d.ts +27 -0
- package/dist/models/pool-gameweek.model.d.ts.map +1 -0
- package/dist/models/pool-gameweek.model.js +99 -0
- package/dist/models/pool-gameweek.model.js.map +1 -0
- package/dist/models/pool-invite.model.d.ts +26 -0
- package/dist/models/pool-invite.model.d.ts.map +1 -0
- package/dist/models/pool-invite.model.js +54 -0
- package/dist/models/pool-invite.model.js.map +1 -0
- package/dist/models/pool-member.model.d.ts +22 -0
- package/dist/models/pool-member.model.d.ts.map +1 -0
- package/dist/models/pool-member.model.js +45 -0
- package/dist/models/pool-member.model.js.map +1 -0
- package/dist/models/pool-transaction.model.d.ts +31 -0
- package/dist/models/pool-transaction.model.d.ts.map +1 -0
- package/dist/models/pool-transaction.model.js +109 -0
- package/dist/models/pool-transaction.model.js.map +1 -0
- package/dist/models/pool-wallet.model.d.ts +18 -0
- package/dist/models/pool-wallet.model.d.ts.map +1 -0
- package/dist/models/pool-wallet.model.js +86 -0
- package/dist/models/pool-wallet.model.js.map +1 -0
- package/dist/models/pool.model.d.ts +42 -0
- package/dist/models/pool.model.d.ts.map +1 -0
- package/{src/models/pool.model.ts → dist/models/pool.model.js} +33 -65
- package/dist/models/pool.model.js.map +1 -0
- package/dist/models/session.model.d.ts +19 -0
- package/dist/models/session.model.d.ts.map +1 -0
- package/dist/models/session.model.js +28 -0
- package/dist/models/session.model.js.map +1 -0
- package/dist/models/transaction.model.d.ts +32 -0
- package/dist/models/transaction.model.d.ts.map +1 -0
- package/{src/models/transaction.model.ts → dist/models/transaction.model.js} +38 -65
- package/dist/models/transaction.model.js.map +1 -0
- package/dist/models/user-settings.model.d.ts +20 -0
- package/dist/models/user-settings.model.d.ts.map +1 -0
- package/{src/models/user-settings.model.ts → dist/models/user-settings.model.js} +14 -29
- package/dist/models/user-settings.model.js.map +1 -0
- package/dist/models/user.model.d.ts +23 -0
- package/dist/models/user.model.d.ts.map +1 -0
- package/{src/models/user.model.ts → dist/models/user.model.js} +20 -37
- package/dist/models/user.model.js.map +1 -0
- package/dist/models/wallet.model.d.ts +23 -0
- package/dist/models/wallet.model.d.ts.map +1 -0
- package/dist/models/wallet.model.js +141 -0
- package/dist/models/wallet.model.js.map +1 -0
- package/dist/repositories/generic.repository.d.ts +17 -0
- package/dist/repositories/generic.repository.d.ts.map +1 -0
- package/dist/repositories/generic.repository.js +55 -0
- package/dist/repositories/generic.repository.js.map +1 -0
- package/dist/types/pool.d.ts +6 -0
- package/dist/types/pool.d.ts.map +1 -0
- package/dist/types/pool.js +10 -0
- package/dist/types/pool.js.map +1 -0
- package/dist/types/wallet.d.ts +16 -0
- package/dist/types/wallet.d.ts.map +1 -0
- package/dist/types/wallet.js +22 -0
- package/dist/types/wallet.js.map +1 -0
- package/package.json +11 -4
- package/src/index.ts +0 -19
- package/src/models/invoice.model.ts +0 -100
- package/src/models/job.model.ts +0 -62
- package/src/models/pool-gameweek-deadline.model.ts +0 -46
- package/src/models/pool-gameweek-winner.model.ts +0 -55
- package/src/models/pool-gameweek.model.ts +0 -114
- package/src/models/pool-invite.model.ts +0 -65
- package/src/models/pool-member.model.ts +0 -53
- package/src/models/pool-transaction.model.ts +0 -130
- package/src/models/pool-wallet.model.ts +0 -89
- package/src/models/session.model.ts +0 -45
- package/src/models/wallet.model.ts +0 -154
- package/src/repositories/generic.repository.ts +0 -86
- package/tsconfig.json +0 -103
|
@@ -0,0 +1,109 @@
|
|
|
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.poolAmountPattern = void 0;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
const mongoose_1 = require("mongoose");
|
|
9
|
+
const config_1 = __importDefault(require("../config"));
|
|
10
|
+
const wallet_1 = require("../types/wallet");
|
|
11
|
+
exports.poolAmountPattern = /^\d+(\.\d{1,2})?$/;
|
|
12
|
+
const poolTransactionSchema = new mongoose_1.Schema({
|
|
13
|
+
wallet: {
|
|
14
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
15
|
+
ref: config_1.default.models.poolWallet,
|
|
16
|
+
},
|
|
17
|
+
member: {
|
|
18
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
19
|
+
ref: config_1.default.models.poolMember
|
|
20
|
+
},
|
|
21
|
+
key: {
|
|
22
|
+
type: mongoose_1.Schema.Types.UUID,
|
|
23
|
+
required: false,
|
|
24
|
+
unique: true,
|
|
25
|
+
default: () => new mongoose_1.Types.UUID((0, node_crypto_1.randomUUID)())
|
|
26
|
+
},
|
|
27
|
+
paymentIntentId: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: false
|
|
30
|
+
},
|
|
31
|
+
amount: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: false,
|
|
34
|
+
default: "0.00",
|
|
35
|
+
set: function (value) {
|
|
36
|
+
// If value already looks like a float (has a .), ensure two decimals
|
|
37
|
+
if (typeof value === "string") {
|
|
38
|
+
if (exports.poolAmountPattern.test(value)) {
|
|
39
|
+
// If it has a dot but is not two decimals, pad right
|
|
40
|
+
if (value.indexOf('.') !== -1) {
|
|
41
|
+
let [whole, decimals] = value.split('.');
|
|
42
|
+
if (decimals === undefined)
|
|
43
|
+
return whole + ".00";
|
|
44
|
+
if (decimals.length === 1)
|
|
45
|
+
return whole + "." + decimals + "0";
|
|
46
|
+
if (decimals.length === 2)
|
|
47
|
+
return value;
|
|
48
|
+
if (decimals.length > 2)
|
|
49
|
+
return whole + "." + decimals.slice(0, 2);
|
|
50
|
+
}
|
|
51
|
+
// No decimal: add .00
|
|
52
|
+
return value + ".00";
|
|
53
|
+
}
|
|
54
|
+
// If it's an integer, add .00
|
|
55
|
+
if (/^\d+$/.test(value)) {
|
|
56
|
+
return value + ".00";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
description: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: true
|
|
65
|
+
},
|
|
66
|
+
method: {
|
|
67
|
+
type: String,
|
|
68
|
+
enum: wallet_1.TransactionMethod,
|
|
69
|
+
default: wallet_1.TransactionMethod.Wallet,
|
|
70
|
+
required: true
|
|
71
|
+
},
|
|
72
|
+
metadata: {
|
|
73
|
+
cardId: {
|
|
74
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
75
|
+
ref: config_1.default.models.card,
|
|
76
|
+
required: false,
|
|
77
|
+
default: null
|
|
78
|
+
},
|
|
79
|
+
receiver: {
|
|
80
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
81
|
+
ref: config_1.default.models.user,
|
|
82
|
+
required: false,
|
|
83
|
+
default: null
|
|
84
|
+
},
|
|
85
|
+
gameweeks: {
|
|
86
|
+
type: (Array),
|
|
87
|
+
required: false,
|
|
88
|
+
default: null
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
type: {
|
|
92
|
+
type: String,
|
|
93
|
+
enum: wallet_1.TransactionType,
|
|
94
|
+
required: true
|
|
95
|
+
},
|
|
96
|
+
status: {
|
|
97
|
+
type: String,
|
|
98
|
+
enum: wallet_1.TransactionStatus,
|
|
99
|
+
required: true,
|
|
100
|
+
default: wallet_1.TransactionStatus.Pending
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
timestamps: true,
|
|
104
|
+
toJSON: { virtuals: true },
|
|
105
|
+
toObject: { virtuals: true }
|
|
106
|
+
});
|
|
107
|
+
const PoolTransaction = (0, mongoose_1.model)(config_1.default.models.poolTransaction, poolTransactionSchema);
|
|
108
|
+
exports.default = PoolTransaction;
|
|
109
|
+
//# sourceMappingURL=pool-transaction.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-transaction.model.js","sourceRoot":"","sources":["../../src/models/pool-transaction.model.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAyC;AAEzC,uCAA0D;AAE1D,uDAA+B;AAC/B,4CAAwF;AA0B3E,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AAErD,MAAM,qBAAqB,GAAG,IAAI,iBAAM,CAAmB;IACvD,MAAM,EAAE;QACJ,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,QAAQ;QAC3B,GAAG,EAAE,gBAAM,CAAC,MAAM,CAAC,UAAU;KAChC;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,QAAQ;QAC3B,GAAG,EAAE,gBAAM,CAAC,MAAM,CAAC,UAAU;KAChC;IACD,GAAG,EAAE;QACD,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,IAAI;QACvB,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,gBAAK,CAAC,IAAI,CAAC,IAAA,wBAAU,GAAE,CAAC;KAC9C;IACD,eAAe,EAAE;QACb,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;KAClB;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,MAAM;QACf,GAAG,EAAE,UAAS,KAAa;YACvB,qEAAqE;YACrE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC5B,IAAI,yBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBAChC,qDAAqD;oBACrD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;wBAC5B,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,G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ACf,OAAO,EAAE,IAAI;SAChB;QACD,SAAS,EAAE;YACP,IAAI,EAAE,CAAA,KAAa,CAAA;YACnB,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,IAAI;SAChB;KACJ;IACD,IAAI,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,wBAAe;QACrB,QAAQ,EAAE,IAAI;KACjB;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,0BAAiB;QACvB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,0BAAiB,CAAC,OAAO;KACrC;CACJ,EAAE;IACC,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC;IACxB,QAAQ,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC;CAC7B,CAAC,CAAA;AAGF,MAAM,eAAe,GAAG,IAAA,gBAAK,EAAmB,gBAAM,CAAC,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;AAGtG,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Types, Document } from "mongoose";
|
|
2
|
+
export interface IPoolWallet extends Document {
|
|
3
|
+
_id: Types.ObjectId;
|
|
4
|
+
pool: Types.ObjectId;
|
|
5
|
+
balance: string;
|
|
6
|
+
availableBalance: string;
|
|
7
|
+
createdAt: Date;
|
|
8
|
+
updatedAt: Date;
|
|
9
|
+
}
|
|
10
|
+
declare const PoolWallet: import("mongoose").Model<IPoolWallet, {}, {}, {}, Document<unknown, {}, IPoolWallet, {}, import("mongoose").DefaultSchemaOptions> & IPoolWallet & Required<{
|
|
11
|
+
_id: Types.ObjectId;
|
|
12
|
+
}> & {
|
|
13
|
+
__v: number;
|
|
14
|
+
} & {
|
|
15
|
+
id: string;
|
|
16
|
+
}, any, IPoolWallet>;
|
|
17
|
+
export default PoolWallet;
|
|
18
|
+
//# sourceMappingURL=pool-wallet.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-wallet.model.d.ts","sourceRoot":"","sources":["../../src/models/pool-wallet.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAM1D,MAAM,WAAW,WAAY,SAAQ,QAAQ;IACzC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACnB;AAyED,QAAA,MAAM,UAAU;;;;;;oBAAiE,CAAC;AAElF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
const mongoose_1 = require("mongoose");
|
|
7
|
+
const config_1 = __importDefault(require("../config"));
|
|
8
|
+
const pool_transaction_model_1 = require("./pool-transaction.model");
|
|
9
|
+
const poolWalletSchema = new mongoose_1.Schema({
|
|
10
|
+
pool: {
|
|
11
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
12
|
+
ref: config_1.default.models.pool,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
balance: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
match: pool_transaction_model_1.poolAmountPattern,
|
|
19
|
+
set: function (value) {
|
|
20
|
+
// If value already looks like a float (has a .), ensure two decimals
|
|
21
|
+
if (typeof value === "string") {
|
|
22
|
+
if (pool_transaction_model_1.poolAmountPattern.test(value)) {
|
|
23
|
+
// If it has a dot but is not two decimals, pad right
|
|
24
|
+
if (value.indexOf('.') !== -1) {
|
|
25
|
+
let [whole, decimals] = value.split('.');
|
|
26
|
+
if (decimals === undefined)
|
|
27
|
+
return whole + ".00";
|
|
28
|
+
if (decimals.length === 1)
|
|
29
|
+
return whole + "." + decimals + "0";
|
|
30
|
+
if (decimals.length === 2)
|
|
31
|
+
return value;
|
|
32
|
+
if (decimals.length > 2)
|
|
33
|
+
return whole + "." + decimals.slice(0, 2);
|
|
34
|
+
}
|
|
35
|
+
// No decimal: add .00
|
|
36
|
+
return value + ".00";
|
|
37
|
+
}
|
|
38
|
+
// If it's an integer, add .00
|
|
39
|
+
if (/^\d+$/.test(value)) {
|
|
40
|
+
return value + ".00";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
},
|
|
45
|
+
default: "0.00"
|
|
46
|
+
},
|
|
47
|
+
availableBalance: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: false,
|
|
50
|
+
match: pool_transaction_model_1.poolAmountPattern,
|
|
51
|
+
set: function (value) {
|
|
52
|
+
// If value already looks like a float (has a .), ensure two decimals
|
|
53
|
+
if (typeof value === "string") {
|
|
54
|
+
if (pool_transaction_model_1.poolAmountPattern.test(value)) {
|
|
55
|
+
// If it has a dot but is not two decimals, pad right
|
|
56
|
+
if (value.indexOf('.') !== -1) {
|
|
57
|
+
let [whole, decimals] = value.split('.');
|
|
58
|
+
if (decimals === undefined)
|
|
59
|
+
return whole + ".00";
|
|
60
|
+
if (decimals.length === 1)
|
|
61
|
+
return whole + "." + decimals + "0";
|
|
62
|
+
if (decimals.length === 2)
|
|
63
|
+
return value;
|
|
64
|
+
if (decimals.length > 2)
|
|
65
|
+
return whole + "." + decimals.slice(0, 2);
|
|
66
|
+
}
|
|
67
|
+
// No decimal: add .00
|
|
68
|
+
return value + ".00";
|
|
69
|
+
}
|
|
70
|
+
// If it's an integer, add .00
|
|
71
|
+
if (/^\d+$/.test(value)) {
|
|
72
|
+
return value + ".00";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
},
|
|
77
|
+
default: "0.00"
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
timestamps: true,
|
|
81
|
+
toJSON: { virtuals: true },
|
|
82
|
+
toObject: { virtuals: true }
|
|
83
|
+
});
|
|
84
|
+
const PoolWallet = (0, mongoose_1.model)(config_1.default.models.poolWallet, poolWalletSchema);
|
|
85
|
+
exports.default = PoolWallet;
|
|
86
|
+
//# sourceMappingURL=pool-wallet.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool-wallet.model.js","sourceRoot":"","sources":["../../src/models/pool-wallet.model.ts"],"names":[],"mappings":";;;;;AAAA,uCAA0D;AAC1D,uDAA+B;AAC/B,qEAA6D;AAa7D,MAAM,gBAAgB,GAAG,IAAI,iBAAM,CAAc;IAC7C,IAAI,EAAE;QACF,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,QAAQ;QAC3B,GAAG,EAAE,gBAAM,CAAC,MAAM,CAAC,IAAI;QACvB,QAAQ,EAAE,IAAI;KACjB;IACD,OAAO,EAAE;QACL,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,0CAAiB;QACxB,GAAG,EAAE,UAAS,KAAa;YACvB,qEAAqE;YACrE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC5B,IAAI,0CAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBAChC,qDAAqD;oBACrD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;wBAC5B,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;wBACzC,IAAI,QAAQ,KAAK,SAAS;4BAAE,OAAO,KAAK,GAAG,KAAK,CAAC;wBACjD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;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,CAAC;wBACxC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;4BAAE,OAAO,KAAK,GAAG,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;oBACtE,CAAC;oBACD,sBAAsB;oBACtB,OAAO,KAAK,GAAG,KAAK,CAAC;gBACzB,CAAC;gBACD,8BAA8B;gBAC9B,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBACtB,OAAO,KAAK,GAAG,KAAK,CAAC;gBACzB,CAAC;YACL,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,OAAO,EAAE,MAAM;KAClB;CACJ,EAAE;IACC,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC;IACxB,QAAQ,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC;CAC7B,CAAC,CAAA;AAKF,MAAM,UAAU,GAAG,IAAA,gBAAK,EAAc,gBAAM,CAAC,MAAM,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;AAElF,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Document, Types } from "mongoose";
|
|
2
|
+
import { PoolType } from "../types/pool";
|
|
3
|
+
export interface IPool extends Document {
|
|
4
|
+
_id: Types.ObjectId;
|
|
5
|
+
uid: string | null;
|
|
6
|
+
admin: Types.ObjectId;
|
|
7
|
+
code: string;
|
|
8
|
+
private: boolean;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
amount: number;
|
|
12
|
+
startGameweek: number;
|
|
13
|
+
currency: string;
|
|
14
|
+
members: number;
|
|
15
|
+
maxMembers: number;
|
|
16
|
+
type: PoolType;
|
|
17
|
+
status: PoolStatus;
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
updatedAt: Date;
|
|
20
|
+
settings: PoolSettings;
|
|
21
|
+
}
|
|
22
|
+
export interface PoolSettings {
|
|
23
|
+
poolType: PoolSettingsType;
|
|
24
|
+
percentages: number[];
|
|
25
|
+
}
|
|
26
|
+
export declare enum PoolSettingsType {
|
|
27
|
+
WinnerTakesAll = "winner-takes-all",
|
|
28
|
+
Top3 = "top-3-split"
|
|
29
|
+
}
|
|
30
|
+
export declare enum PoolStatus {
|
|
31
|
+
Active = "active",
|
|
32
|
+
Inactive = "inactive"
|
|
33
|
+
}
|
|
34
|
+
declare const Pool: import("mongoose").Model<IPool, {}, {}, {}, Document<unknown, {}, IPool, {}, import("mongoose").DefaultSchemaOptions> & IPool & Required<{
|
|
35
|
+
_id: Types.ObjectId;
|
|
36
|
+
}> & {
|
|
37
|
+
__v: number;
|
|
38
|
+
} & {
|
|
39
|
+
id: string;
|
|
40
|
+
}, any, IPool>;
|
|
41
|
+
export default Pool;
|
|
42
|
+
//# sourceMappingURL=pool.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.model.d.ts","sourceRoot":"","sources":["../../src/models/pool.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAU,KAAK,EAAS,MAAM,UAAU,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKzC,MAAM,WAAW,KAAM,SAAQ,QAAQ;IACnC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,oBAAY,gBAAgB;IACxB,cAAc,qBAAqB;IACnC,IAAI,gBAAgB;CACvB;AAED,oBAAY,UAAU;IAClB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACxB;AAqGD,QAAA,MAAM,IAAI;;;;;;cAA+C,CAAC;AAG1D,eAAe,IAAI,CAAC"}
|
|
@@ -1,56 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
maxMembers: number;
|
|
22
|
-
type: PoolType;
|
|
23
|
-
status: PoolStatus;
|
|
24
|
-
createdAt: Date;
|
|
25
|
-
updatedAt: Date;
|
|
26
|
-
settings: PoolSettings;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface PoolSettings {
|
|
30
|
-
poolType: PoolSettingsType,
|
|
31
|
-
percentages: number[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export enum PoolSettingsType {
|
|
35
|
-
WinnerTakesAll = 'winner-takes-all',
|
|
36
|
-
Top3 = 'top-3-split'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export enum PoolStatus {
|
|
40
|
-
Active = "active",
|
|
41
|
-
Inactive = "inactive"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const poolSchema = new Schema<IPool>({
|
|
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.PoolStatus = exports.PoolSettingsType = void 0;
|
|
7
|
+
const mongoose_1 = require("mongoose");
|
|
8
|
+
const config_1 = __importDefault(require("../config"));
|
|
9
|
+
const pool_1 = require("../types/pool");
|
|
10
|
+
var PoolSettingsType;
|
|
11
|
+
(function (PoolSettingsType) {
|
|
12
|
+
PoolSettingsType["WinnerTakesAll"] = "winner-takes-all";
|
|
13
|
+
PoolSettingsType["Top3"] = "top-3-split";
|
|
14
|
+
})(PoolSettingsType || (exports.PoolSettingsType = PoolSettingsType = {}));
|
|
15
|
+
var PoolStatus;
|
|
16
|
+
(function (PoolStatus) {
|
|
17
|
+
PoolStatus["Active"] = "active";
|
|
18
|
+
PoolStatus["Inactive"] = "inactive";
|
|
19
|
+
})(PoolStatus || (exports.PoolStatus = PoolStatus = {}));
|
|
20
|
+
const poolSchema = new mongoose_1.Schema({
|
|
46
21
|
uid: {
|
|
47
22
|
type: String,
|
|
48
23
|
required: false,
|
|
49
24
|
default: null
|
|
50
25
|
},
|
|
51
26
|
admin: {
|
|
52
|
-
type: Schema.Types.ObjectId,
|
|
53
|
-
ref:
|
|
27
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
28
|
+
ref: config_1.default.models.user,
|
|
54
29
|
required: true
|
|
55
30
|
},
|
|
56
31
|
code: {
|
|
@@ -104,8 +79,8 @@ const poolSchema = new Schema<IPool>({
|
|
|
104
79
|
type: {
|
|
105
80
|
type: String,
|
|
106
81
|
required: [true, 'Type is required'],
|
|
107
|
-
enum: PoolType,
|
|
108
|
-
default: PoolType.Weekly
|
|
82
|
+
enum: pool_1.PoolType,
|
|
83
|
+
default: pool_1.PoolType.Weekly
|
|
109
84
|
},
|
|
110
85
|
status: {
|
|
111
86
|
type: String,
|
|
@@ -121,26 +96,19 @@ const poolSchema = new Schema<IPool>({
|
|
|
121
96
|
default: PoolSettingsType.WinnerTakesAll
|
|
122
97
|
},
|
|
123
98
|
percentages: [{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
99
|
+
type: Number,
|
|
100
|
+
required: [true, 'Percentage is required']
|
|
101
|
+
}]
|
|
127
102
|
},
|
|
128
103
|
}, {
|
|
129
104
|
timestamps: true,
|
|
130
|
-
toJSON: {virtuals: true},
|
|
131
|
-
toObject: {virtuals: true}
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
|
|
105
|
+
toJSON: { virtuals: true },
|
|
106
|
+
toObject: { virtuals: true }
|
|
107
|
+
});
|
|
135
108
|
// poolSchema.method("generateLink", async function(){
|
|
136
109
|
// const link = await poolService.getPoolInviteLink(this);
|
|
137
110
|
// return link;
|
|
138
111
|
// })
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const Pool = model<IPool>(config.models.pool, poolSchema);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
export default Pool;
|
|
112
|
+
const Pool = (0, mongoose_1.model)(config_1.default.models.pool, poolSchema);
|
|
113
|
+
exports.default = Pool;
|
|
114
|
+
//# sourceMappingURL=pool.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.model.js","sourceRoot":"","sources":["../../src/models/pool.model.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA0D;AAC1D,uDAA+B;AAC/B,wCAAyC;AA8BzC,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,uDAAmC,CAAA;IACnC,wCAAoB,CAAA;AACxB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;AACzB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAGD,M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CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Types, Document } from "mongoose";
|
|
2
|
+
export interface ISession extends Document {
|
|
3
|
+
_id: Types.ObjectId;
|
|
4
|
+
user: Types.ObjectId;
|
|
5
|
+
userAgent: String;
|
|
6
|
+
device: Object;
|
|
7
|
+
expired: Boolean;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
updatedAt: Date;
|
|
10
|
+
}
|
|
11
|
+
declare const Session: import("mongoose").Model<ISession, {}, {}, {}, Document<unknown, {}, ISession, {}, import("mongoose").DefaultSchemaOptions> & ISession & Required<{
|
|
12
|
+
_id: Types.ObjectId;
|
|
13
|
+
}> & {
|
|
14
|
+
__v: number;
|
|
15
|
+
} & {
|
|
16
|
+
id: string;
|
|
17
|
+
}, any, ISession>;
|
|
18
|
+
export default Session;
|
|
19
|
+
//# sourceMappingURL=session.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.model.d.ts","sourceRoot":"","sources":["../../src/models/session.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAC;AAOxD,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACtC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACnB;AA0BD,QAAA,MAAM,OAAO;;;;;;iBAAwD,CAAC;AAGtE,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
const mongoose_1 = require("mongoose");
|
|
7
|
+
const config_1 = __importDefault(require("../config"));
|
|
8
|
+
const sessionSchema = new mongoose_1.Schema({
|
|
9
|
+
user: {
|
|
10
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
11
|
+
ref: config_1.default.models.user,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
device: Object,
|
|
15
|
+
userAgent: String,
|
|
16
|
+
expired: {
|
|
17
|
+
required: true,
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
}, {
|
|
22
|
+
timestamps: true,
|
|
23
|
+
toJSON: { virtuals: true },
|
|
24
|
+
toObject: { virtuals: true }
|
|
25
|
+
});
|
|
26
|
+
const Session = (0, mongoose_1.model)(config_1.default.models.session, sessionSchema);
|
|
27
|
+
exports.default = Session;
|
|
28
|
+
//# sourceMappingURL=session.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.model.js","sourceRoot":"","sources":["../../src/models/session.model.ts"],"names":[],"mappings":";;;;;AAAA,uCAAwD;AAExD,uDAA+B;AAgB/B,MAAM,aAAa,GAAG,IAAI,iBAAM,CAAW;IACvC,IAAI,EAAE;QACF,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,QAAQ;QAC3B,GAAG,EAAE,gBAAM,CAAC,MAAM,CAAC,IAAI;QACvB,QAAQ,EAAE,IAAI;KACjB;IACD,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,MAAM;IACjB,OAAO,EAAE;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,KAAK;KACjB;CACJ,EACD;IACI,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC;IACxB,QAAQ,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC;CAC7B,CAAC,CAAC;AAKH,MAAM,OAAO,GAAG,IAAA,gBAAK,EAAW,gBAAM,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAGtE,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Types, Document } from "mongoose";
|
|
2
|
+
import { TransactionMethod, TransactionStatus, TransactionType } from "../types/wallet";
|
|
3
|
+
export interface ITransaction extends Document {
|
|
4
|
+
_id: Types.ObjectId;
|
|
5
|
+
key: Types.UUID;
|
|
6
|
+
wallet: Types.ObjectId;
|
|
7
|
+
type: TransactionType;
|
|
8
|
+
paymentIntentId?: string;
|
|
9
|
+
description: string;
|
|
10
|
+
amount: string;
|
|
11
|
+
method: TransactionMethod;
|
|
12
|
+
metadata: {
|
|
13
|
+
address?: string;
|
|
14
|
+
hash?: string;
|
|
15
|
+
chainId?: number;
|
|
16
|
+
token?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
cardId?: Types.ObjectId;
|
|
19
|
+
};
|
|
20
|
+
status: TransactionStatus;
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
updatedAt: Date;
|
|
23
|
+
}
|
|
24
|
+
declare const Transaction: import("mongoose").Model<ITransaction, {}, {}, {}, Document<unknown, {}, ITransaction, {}, import("mongoose").DefaultSchemaOptions> & ITransaction & Required<{
|
|
25
|
+
_id: Types.ObjectId;
|
|
26
|
+
}> & {
|
|
27
|
+
__v: number;
|
|
28
|
+
} & {
|
|
29
|
+
id: string;
|
|
30
|
+
}, any, ITransaction>;
|
|
31
|
+
export default Transaction;
|
|
32
|
+
//# sourceMappingURL=transaction.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.model.d.ts","sourceRoot":"","sources":["../../src/models/transaction.model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAI1D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMxF,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC1C,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC;IACpB,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC;IAChB,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC;IACvB,IAAI,EAAE,eAAe,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IAEf,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE;QACN,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC;KAC3B,CAAC;IACF,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACnB;AA4GD,QAAA,MAAM,WAAW;;;;;;qBAAoE,CAAC;AAEtF,eAAe,WAAW,CAAC"}
|
|
@@ -1,55 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export interface ITransaction extends Document {
|
|
14
|
-
_id: Types.ObjectId;
|
|
15
|
-
key: Types.UUID;
|
|
16
|
-
wallet: Types.ObjectId;
|
|
17
|
-
type: TransactionType;
|
|
18
|
-
paymentIntentId?: string;
|
|
19
|
-
description: string;
|
|
20
|
-
amount: string;
|
|
21
|
-
// currency: string;
|
|
22
|
-
method: TransactionMethod;
|
|
23
|
-
metadata: {
|
|
24
|
-
address?: string;
|
|
25
|
-
hash?: string;
|
|
26
|
-
chainId?: number;
|
|
27
|
-
token?: string;
|
|
28
|
-
value?: string;
|
|
29
|
-
cardId?: Types.ObjectId;
|
|
30
|
-
};
|
|
31
|
-
status: TransactionStatus;
|
|
32
|
-
createdAt: Date;
|
|
33
|
-
updatedAt: Date;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const transactionSchema = new Schema<ITransaction>({
|
|
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
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const mongoose_1 = require("mongoose");
|
|
8
|
+
const config_1 = __importDefault(require("../config"));
|
|
9
|
+
const pool_transaction_model_1 = require("./pool-transaction.model");
|
|
10
|
+
const wallet_1 = require("../types/wallet");
|
|
11
|
+
const transactionSchema = new mongoose_1.Schema({
|
|
39
12
|
wallet: {
|
|
40
|
-
type: Schema.Types.ObjectId,
|
|
41
|
-
ref:
|
|
13
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
14
|
+
ref: config_1.default.models.wallet,
|
|
42
15
|
required: true
|
|
43
16
|
},
|
|
44
17
|
key: {
|
|
45
|
-
type: Schema.Types.UUID,
|
|
18
|
+
type: mongoose_1.Schema.Types.UUID,
|
|
46
19
|
required: false,
|
|
47
20
|
unique: true,
|
|
48
|
-
default: () => new Types.UUID(randomUUID())
|
|
21
|
+
default: () => new mongoose_1.Types.UUID((0, node_crypto_1.randomUUID)())
|
|
49
22
|
},
|
|
50
23
|
type: {
|
|
51
24
|
type: String,
|
|
52
|
-
enum: TransactionType,
|
|
25
|
+
enum: wallet_1.TransactionType,
|
|
53
26
|
required: true
|
|
54
27
|
},
|
|
55
28
|
description: {
|
|
@@ -66,17 +39,21 @@ const transactionSchema = new Schema<ITransaction>({
|
|
|
66
39
|
type: String,
|
|
67
40
|
required: false,
|
|
68
41
|
default: "0.00",
|
|
69
|
-
set: function(value
|
|
42
|
+
set: function (value) {
|
|
70
43
|
// If value already looks like a float (has a .), ensure two decimals
|
|
71
44
|
if (typeof value === "string") {
|
|
72
|
-
if (poolAmountPattern.test(value)) {
|
|
45
|
+
if (pool_transaction_model_1.poolAmountPattern.test(value)) {
|
|
73
46
|
// If it has a dot but is not two decimals, pad right
|
|
74
47
|
if (value.indexOf('.') !== -1) {
|
|
75
48
|
let [whole, decimals] = value.split('.');
|
|
76
|
-
if (decimals === undefined)
|
|
77
|
-
|
|
78
|
-
if (decimals.length ===
|
|
79
|
-
|
|
49
|
+
if (decimals === undefined)
|
|
50
|
+
return whole + ".00";
|
|
51
|
+
if (decimals.length === 1)
|
|
52
|
+
return whole + "." + decimals + "0";
|
|
53
|
+
if (decimals.length === 2)
|
|
54
|
+
return value;
|
|
55
|
+
if (decimals.length > 2)
|
|
56
|
+
return whole + "." + decimals.slice(0, 2);
|
|
80
57
|
}
|
|
81
58
|
// No decimal: add .00
|
|
82
59
|
return value + ".00";
|
|
@@ -91,14 +68,14 @@ const transactionSchema = new Schema<ITransaction>({
|
|
|
91
68
|
},
|
|
92
69
|
method: {
|
|
93
70
|
type: String,
|
|
94
|
-
enum: TransactionMethod,
|
|
71
|
+
enum: wallet_1.TransactionMethod,
|
|
95
72
|
required: false,
|
|
96
|
-
default: TransactionMethod.Card
|
|
73
|
+
default: wallet_1.TransactionMethod.Card
|
|
97
74
|
},
|
|
98
75
|
metadata: {
|
|
99
76
|
cardId: {
|
|
100
|
-
type: Schema.Types.ObjectId,
|
|
101
|
-
ref:
|
|
77
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
78
|
+
ref: config_1.default.models.card,
|
|
102
79
|
required: false,
|
|
103
80
|
default: null
|
|
104
81
|
},
|
|
@@ -125,20 +102,16 @@ const transactionSchema = new Schema<ITransaction>({
|
|
|
125
102
|
},
|
|
126
103
|
status: {
|
|
127
104
|
type: String,
|
|
128
|
-
enum: TransactionStatus,
|
|
105
|
+
enum: wallet_1.TransactionStatus,
|
|
129
106
|
required: false,
|
|
130
|
-
default: TransactionStatus.Pending
|
|
107
|
+
default: wallet_1.TransactionStatus.Pending
|
|
131
108
|
}
|
|
132
109
|
}, {
|
|
133
110
|
timestamps: true,
|
|
134
|
-
toJSON: {virtuals: true},
|
|
135
|
-
toObject: {virtuals: true}
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
|
|
111
|
+
toJSON: { virtuals: true },
|
|
112
|
+
toObject: { virtuals: true }
|
|
113
|
+
});
|
|
139
114
|
// transactionSchema.index({paymentIntentId: 1}, {unique: true});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
export default Transaction;
|
|
115
|
+
const Transaction = (0, mongoose_1.model)(config_1.default.models.transaction, transactionSchema);
|
|
116
|
+
exports.default = Transaction;
|
|
117
|
+
//# sourceMappingURL=transaction.model.js.map
|