@rowengine/common 1.0.138 → 1.0.140
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/build/interfaces/index.d.ts +1 -0
- package/build/interfaces/index.js +1 -0
- package/build/interfaces/transaction.d.ts +21 -0
- package/build/interfaces/transaction.js +9 -0
- package/build/models/index.d.ts +1 -0
- package/build/models/index.js +1 -0
- package/build/models/transaction.model.d.ts +23 -0
- package/build/models/transaction.model.js +57 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Company } from './company';
|
|
2
|
+
export declare enum TransactionType {
|
|
3
|
+
CREDITS_BOUGHT = "CREDITS_BOUGHT",
|
|
4
|
+
CREDITS_DEBITED = "CREDITS_DEBITED",
|
|
5
|
+
PROJECT_REFUNDED = "PROJECT_REFUNDED"
|
|
6
|
+
}
|
|
7
|
+
export interface TransactionProject {
|
|
8
|
+
name: string;
|
|
9
|
+
area: number;
|
|
10
|
+
timeElapsedInSeconds: number;
|
|
11
|
+
timeOnQueueInSeconds: number;
|
|
12
|
+
createdAt: Date;
|
|
13
|
+
}
|
|
14
|
+
export interface Transaction {
|
|
15
|
+
company: Company;
|
|
16
|
+
userEmail: string;
|
|
17
|
+
currentBalance: number;
|
|
18
|
+
value: number;
|
|
19
|
+
type: TransactionType;
|
|
20
|
+
project?: TransactionProject;
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionType = void 0;
|
|
4
|
+
var TransactionType;
|
|
5
|
+
(function (TransactionType) {
|
|
6
|
+
TransactionType["CREDITS_BOUGHT"] = "CREDITS_BOUGHT";
|
|
7
|
+
TransactionType["CREDITS_DEBITED"] = "CREDITS_DEBITED";
|
|
8
|
+
TransactionType["PROJECT_REFUNDED"] = "PROJECT_REFUNDED";
|
|
9
|
+
})(TransactionType || (exports.TransactionType = TransactionType = {}));
|
package/build/models/index.d.ts
CHANGED
package/build/models/index.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import { CompanyDoc } from './company.model';
|
|
3
|
+
import { TransactionType } from '../interfaces';
|
|
4
|
+
interface TransactionAttrs {
|
|
5
|
+
company: CompanyDoc;
|
|
6
|
+
userEmail: string;
|
|
7
|
+
project?: {
|
|
8
|
+
name: string;
|
|
9
|
+
area: number;
|
|
10
|
+
timeElapsedInSeconds: number;
|
|
11
|
+
timeOnQueueInSeconds: number;
|
|
12
|
+
createdAt: Date;
|
|
13
|
+
};
|
|
14
|
+
currentBalance: number;
|
|
15
|
+
value: number;
|
|
16
|
+
type: TransactionType;
|
|
17
|
+
}
|
|
18
|
+
type TransactionDoc = mongoose.Document & TransactionAttrs;
|
|
19
|
+
interface TransactionModel extends mongoose.Model<TransactionDoc> {
|
|
20
|
+
build(attrs: TransactionAttrs): TransactionDoc;
|
|
21
|
+
}
|
|
22
|
+
declare const TransactionModel: TransactionModel;
|
|
23
|
+
export { TransactionModel, TransactionDoc };
|
|
@@ -0,0 +1,57 @@
|
|
|
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.TransactionModel = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const interfaces_1 = require("../interfaces");
|
|
9
|
+
const transactionSchema = new mongoose_1.default.Schema({
|
|
10
|
+
company: {
|
|
11
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
12
|
+
ref: 'Company',
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
userEmail: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
project: {
|
|
20
|
+
type: Object,
|
|
21
|
+
required: false,
|
|
22
|
+
},
|
|
23
|
+
currentBalance: {
|
|
24
|
+
type: Number,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
value: {
|
|
28
|
+
type: Number,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
type: {
|
|
32
|
+
type: String,
|
|
33
|
+
enum: Object.values(interfaces_1.TransactionType),
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
}, {
|
|
37
|
+
toJSON: {
|
|
38
|
+
transform(doc, ret) {
|
|
39
|
+
ret.id = ret._id;
|
|
40
|
+
delete ret._id;
|
|
41
|
+
delete ret.__v;
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const autoPopulate = function (next) {
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
this.populate('company');
|
|
48
|
+
next();
|
|
49
|
+
};
|
|
50
|
+
transactionSchema.pre('findOne', autoPopulate);
|
|
51
|
+
transactionSchema.pre('find', autoPopulate);
|
|
52
|
+
// Pass the ts interface.
|
|
53
|
+
transactionSchema.statics.build = (attrs) => {
|
|
54
|
+
return new TransactionModel(attrs);
|
|
55
|
+
};
|
|
56
|
+
const TransactionModel = mongoose_1.default.model('Transaction', transactionSchema);
|
|
57
|
+
exports.TransactionModel = TransactionModel;
|