@questwork/q-store-model 0.1.29 → 0.1.30
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/index.min.cjs +78 -12
- package/dist/index.min.js +78 -12
- package/package.json +1 -2
package/dist/index.min.cjs
CHANGED
|
@@ -253,25 +253,93 @@ class Amount {
|
|
|
253
253
|
|
|
254
254
|
;// external "lodash"
|
|
255
255
|
const external_lodash_namespaceObject = require("lodash");
|
|
256
|
-
;// external "@questwork/utilities/lib/stringHelper/index.js"
|
|
257
|
-
const index_js_namespaceObject = require("@questwork/utilities/lib/stringHelper/index.js");
|
|
258
256
|
;// ./lib/helpers/stringHelper/stringHelper.js
|
|
257
|
+
function baseXEncode(num, base = 34) {
|
|
258
|
+
const charset = getBaseCharset(base)
|
|
259
|
+
return encode(num, charset)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function encode(int, charset) {
|
|
263
|
+
let byCode = charset.byCode;
|
|
264
|
+
if (int === 0) {
|
|
265
|
+
return byCode[0];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
var res = "",
|
|
269
|
+
max = charset.length;
|
|
270
|
+
while (int > 0) {
|
|
271
|
+
res = byCode[int % max] + res;
|
|
272
|
+
int = Math.floor(int / max);
|
|
273
|
+
}
|
|
274
|
+
return res;
|
|
275
|
+
}
|
|
259
276
|
|
|
277
|
+
function getBaseCharset(base) {
|
|
278
|
+
let charset = '9876543210ABCDEFGHJKLMNPQRSTUVWXYZ'
|
|
279
|
+
if (base === 58) {
|
|
280
|
+
charset = '9876543210ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz'
|
|
281
|
+
}
|
|
282
|
+
return indexCharset(charset)
|
|
283
|
+
}
|
|
260
284
|
|
|
285
|
+
function indexCharset(str) {
|
|
286
|
+
var byCode = {},
|
|
287
|
+
byChar = {},
|
|
288
|
+
length = str.length,
|
|
289
|
+
i, char;
|
|
290
|
+
for (i = 0; i < length; i++) {
|
|
291
|
+
char = str[i];
|
|
292
|
+
byCode[i] = char;
|
|
293
|
+
byChar[char] = i;
|
|
294
|
+
}
|
|
295
|
+
return { byCode: byCode, byChar: byChar, length: length };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function randomString({ len = 16, pattern = 'a1' } = {}) {
|
|
299
|
+
const A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
300
|
+
const a = 'abcdefghijklmnopqrstuvwxyz'
|
|
301
|
+
const num = '1234567890'
|
|
302
|
+
const mark = '~!@#$%^&*_+-='
|
|
303
|
+
let str = ''
|
|
304
|
+
if (pattern.includes('A')) {
|
|
305
|
+
str += A
|
|
306
|
+
}
|
|
307
|
+
if (pattern.includes('a')) {
|
|
308
|
+
str += a
|
|
309
|
+
}
|
|
310
|
+
if (pattern.includes('1')) {
|
|
311
|
+
str += num
|
|
312
|
+
}
|
|
313
|
+
if (pattern.includes('#')) {
|
|
314
|
+
str += mark
|
|
315
|
+
}
|
|
316
|
+
const chars = [...str]
|
|
317
|
+
return [...Array(len)].map(i => {
|
|
318
|
+
return chars[(Math.random() * chars.length) | 0]
|
|
319
|
+
}).join``
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function reverse(str) {
|
|
323
|
+
if (typeof str !== 'string') {
|
|
324
|
+
str = str.toString()
|
|
325
|
+
}
|
|
326
|
+
const splitString = str.split('')
|
|
327
|
+
const reverseArray = splitString.reverse()
|
|
328
|
+
return reverseArray.join('')
|
|
329
|
+
}
|
|
261
330
|
|
|
262
331
|
function setCode(base = 34) {
|
|
263
332
|
const now = (new Date()).valueOf()
|
|
264
|
-
const random =
|
|
333
|
+
const random = randomString({
|
|
265
334
|
len: 8,
|
|
266
335
|
pattern: '1'
|
|
267
336
|
})
|
|
268
|
-
const str =
|
|
337
|
+
const str = reverse(`${now}${random}`)
|
|
269
338
|
// const str = `${now}${random}`
|
|
270
|
-
return
|
|
339
|
+
return baseXEncode(str, base)
|
|
271
340
|
}
|
|
272
341
|
|
|
273
342
|
const stringHelper = {
|
|
274
|
-
...index_js_namespaceObject.stringHelper,
|
|
275
343
|
setCode
|
|
276
344
|
}
|
|
277
345
|
|
|
@@ -6479,8 +6547,6 @@ function makePaymentResultService({ repo }) {
|
|
|
6479
6547
|
|
|
6480
6548
|
|
|
6481
6549
|
|
|
6482
|
-
;// external "@questwork/utilities/lib/lodashHelper"
|
|
6483
|
-
const lodashHelper_namespaceObject = require("@questwork/utilities/lib/lodashHelper");
|
|
6484
6550
|
;// ./lib/helpers/corHelper/chain.js
|
|
6485
6551
|
|
|
6486
6552
|
class Chain {
|
|
@@ -6600,8 +6666,6 @@ class Chain {
|
|
|
6600
6666
|
|
|
6601
6667
|
|
|
6602
6668
|
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
6669
|
;// ./lib/eventManager/chains/chainCategoryLimit.js
|
|
6606
6670
|
|
|
6607
6671
|
|
|
@@ -6695,6 +6759,7 @@ function calculateUsed(updatedItem, balance, count) {
|
|
|
6695
6759
|
;// ./lib/eventManager/chains/chainGetPrice.js
|
|
6696
6760
|
|
|
6697
6761
|
|
|
6762
|
+
|
|
6698
6763
|
class ChainGetPrice extends Chain {
|
|
6699
6764
|
constructor(options = {}) {
|
|
6700
6765
|
super(options)
|
|
@@ -6708,7 +6773,7 @@ class ChainGetPrice extends Chain {
|
|
|
6708
6773
|
try {
|
|
6709
6774
|
const { lines, user } = chainTarget
|
|
6710
6775
|
// const entitlements = JSON.parse(JSON.stringify(this.entitlements))
|
|
6711
|
-
const entitlements =
|
|
6776
|
+
const entitlements = external_lodash_namespaceObject.cloneDeep(this.entitlements)
|
|
6712
6777
|
lines.forEach((line) => {
|
|
6713
6778
|
const prices = getPricesByTime(line, this.dateTime)
|
|
6714
6779
|
const priceStrategies = getStrategiesByRestrictions(prices, line, user)
|
|
@@ -6937,6 +7002,7 @@ function getStrategiesByRestrictions(prices, line, user) {
|
|
|
6937
7002
|
;// ./lib/eventManager/chains/ChainGetPriceForGroup.js
|
|
6938
7003
|
|
|
6939
7004
|
|
|
7005
|
+
|
|
6940
7006
|
class ChainGetPriceForGroup extends Chain {
|
|
6941
7007
|
constructor(options = {}) {
|
|
6942
7008
|
super(options)
|
|
@@ -6949,7 +7015,7 @@ class ChainGetPriceForGroup extends Chain {
|
|
|
6949
7015
|
async handleRequest(chainTarget) {
|
|
6950
7016
|
try {
|
|
6951
7017
|
const { lines, user } = chainTarget
|
|
6952
|
-
const entitlements =
|
|
7018
|
+
const entitlements = external_lodash_namespaceObject.cloneDeep(this.entitlements)
|
|
6953
7019
|
|
|
6954
7020
|
lines.forEach((line) => {
|
|
6955
7021
|
const prices = ChainGetPriceForGroup_getPricesByTime(line, this.dateTime)
|
package/dist/index.min.js
CHANGED
|
@@ -253,25 +253,93 @@ class Amount {
|
|
|
253
253
|
|
|
254
254
|
;// external "lodash"
|
|
255
255
|
const external_lodash_namespaceObject = require("lodash");
|
|
256
|
-
;// external "@questwork/utilities/lib/stringHelper/index.js"
|
|
257
|
-
const index_js_namespaceObject = require("@questwork/utilities/lib/stringHelper/index.js");
|
|
258
256
|
;// ./lib/helpers/stringHelper/stringHelper.js
|
|
257
|
+
function baseXEncode(num, base = 34) {
|
|
258
|
+
const charset = getBaseCharset(base)
|
|
259
|
+
return encode(num, charset)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function encode(int, charset) {
|
|
263
|
+
let byCode = charset.byCode;
|
|
264
|
+
if (int === 0) {
|
|
265
|
+
return byCode[0];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
var res = "",
|
|
269
|
+
max = charset.length;
|
|
270
|
+
while (int > 0) {
|
|
271
|
+
res = byCode[int % max] + res;
|
|
272
|
+
int = Math.floor(int / max);
|
|
273
|
+
}
|
|
274
|
+
return res;
|
|
275
|
+
}
|
|
259
276
|
|
|
277
|
+
function getBaseCharset(base) {
|
|
278
|
+
let charset = '9876543210ABCDEFGHJKLMNPQRSTUVWXYZ'
|
|
279
|
+
if (base === 58) {
|
|
280
|
+
charset = '9876543210ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz'
|
|
281
|
+
}
|
|
282
|
+
return indexCharset(charset)
|
|
283
|
+
}
|
|
260
284
|
|
|
285
|
+
function indexCharset(str) {
|
|
286
|
+
var byCode = {},
|
|
287
|
+
byChar = {},
|
|
288
|
+
length = str.length,
|
|
289
|
+
i, char;
|
|
290
|
+
for (i = 0; i < length; i++) {
|
|
291
|
+
char = str[i];
|
|
292
|
+
byCode[i] = char;
|
|
293
|
+
byChar[char] = i;
|
|
294
|
+
}
|
|
295
|
+
return { byCode: byCode, byChar: byChar, length: length };
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function randomString({ len = 16, pattern = 'a1' } = {}) {
|
|
299
|
+
const A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
300
|
+
const a = 'abcdefghijklmnopqrstuvwxyz'
|
|
301
|
+
const num = '1234567890'
|
|
302
|
+
const mark = '~!@#$%^&*_+-='
|
|
303
|
+
let str = ''
|
|
304
|
+
if (pattern.includes('A')) {
|
|
305
|
+
str += A
|
|
306
|
+
}
|
|
307
|
+
if (pattern.includes('a')) {
|
|
308
|
+
str += a
|
|
309
|
+
}
|
|
310
|
+
if (pattern.includes('1')) {
|
|
311
|
+
str += num
|
|
312
|
+
}
|
|
313
|
+
if (pattern.includes('#')) {
|
|
314
|
+
str += mark
|
|
315
|
+
}
|
|
316
|
+
const chars = [...str]
|
|
317
|
+
return [...Array(len)].map(i => {
|
|
318
|
+
return chars[(Math.random() * chars.length) | 0]
|
|
319
|
+
}).join``
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function reverse(str) {
|
|
323
|
+
if (typeof str !== 'string') {
|
|
324
|
+
str = str.toString()
|
|
325
|
+
}
|
|
326
|
+
const splitString = str.split('')
|
|
327
|
+
const reverseArray = splitString.reverse()
|
|
328
|
+
return reverseArray.join('')
|
|
329
|
+
}
|
|
261
330
|
|
|
262
331
|
function setCode(base = 34) {
|
|
263
332
|
const now = (new Date()).valueOf()
|
|
264
|
-
const random =
|
|
333
|
+
const random = randomString({
|
|
265
334
|
len: 8,
|
|
266
335
|
pattern: '1'
|
|
267
336
|
})
|
|
268
|
-
const str =
|
|
337
|
+
const str = reverse(`${now}${random}`)
|
|
269
338
|
// const str = `${now}${random}`
|
|
270
|
-
return
|
|
339
|
+
return baseXEncode(str, base)
|
|
271
340
|
}
|
|
272
341
|
|
|
273
342
|
const stringHelper = {
|
|
274
|
-
...index_js_namespaceObject.stringHelper,
|
|
275
343
|
setCode
|
|
276
344
|
}
|
|
277
345
|
|
|
@@ -6479,8 +6547,6 @@ function makePaymentResultService({ repo }) {
|
|
|
6479
6547
|
|
|
6480
6548
|
|
|
6481
6549
|
|
|
6482
|
-
;// external "@questwork/utilities/lib/lodashHelper"
|
|
6483
|
-
const lodashHelper_namespaceObject = require("@questwork/utilities/lib/lodashHelper");
|
|
6484
6550
|
;// ./lib/helpers/corHelper/chain.js
|
|
6485
6551
|
|
|
6486
6552
|
class Chain {
|
|
@@ -6600,8 +6666,6 @@ class Chain {
|
|
|
6600
6666
|
|
|
6601
6667
|
|
|
6602
6668
|
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
6669
|
;// ./lib/eventManager/chains/chainCategoryLimit.js
|
|
6606
6670
|
|
|
6607
6671
|
|
|
@@ -6695,6 +6759,7 @@ function calculateUsed(updatedItem, balance, count) {
|
|
|
6695
6759
|
;// ./lib/eventManager/chains/chainGetPrice.js
|
|
6696
6760
|
|
|
6697
6761
|
|
|
6762
|
+
|
|
6698
6763
|
class ChainGetPrice extends Chain {
|
|
6699
6764
|
constructor(options = {}) {
|
|
6700
6765
|
super(options)
|
|
@@ -6708,7 +6773,7 @@ class ChainGetPrice extends Chain {
|
|
|
6708
6773
|
try {
|
|
6709
6774
|
const { lines, user } = chainTarget
|
|
6710
6775
|
// const entitlements = JSON.parse(JSON.stringify(this.entitlements))
|
|
6711
|
-
const entitlements =
|
|
6776
|
+
const entitlements = external_lodash_namespaceObject.cloneDeep(this.entitlements)
|
|
6712
6777
|
lines.forEach((line) => {
|
|
6713
6778
|
const prices = getPricesByTime(line, this.dateTime)
|
|
6714
6779
|
const priceStrategies = getStrategiesByRestrictions(prices, line, user)
|
|
@@ -6937,6 +7002,7 @@ function getStrategiesByRestrictions(prices, line, user) {
|
|
|
6937
7002
|
;// ./lib/eventManager/chains/ChainGetPriceForGroup.js
|
|
6938
7003
|
|
|
6939
7004
|
|
|
7005
|
+
|
|
6940
7006
|
class ChainGetPriceForGroup extends Chain {
|
|
6941
7007
|
constructor(options = {}) {
|
|
6942
7008
|
super(options)
|
|
@@ -6949,7 +7015,7 @@ class ChainGetPriceForGroup extends Chain {
|
|
|
6949
7015
|
async handleRequest(chainTarget) {
|
|
6950
7016
|
try {
|
|
6951
7017
|
const { lines, user } = chainTarget
|
|
6952
|
-
const entitlements =
|
|
7018
|
+
const entitlements = external_lodash_namespaceObject.cloneDeep(this.entitlements)
|
|
6953
7019
|
|
|
6954
7020
|
lines.forEach((line) => {
|
|
6955
7021
|
const prices = ChainGetPriceForGroup_getPricesByTime(line, this.dateTime)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@questwork/q-store-model",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"description": "Questwork QStore Model",
|
|
5
5
|
"main": "dist/index.min.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@questwork/utilities": "^0.1.51",
|
|
21
20
|
"lodash": "^4.17.21"
|
|
22
21
|
},
|
|
23
22
|
"devDependencies": {
|