@questwork/q-store-model 0.1.36 → 0.1.38
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/.github/workflows/publish.yml +46 -0
- package/dist/index.min.cjs +33 -4
- package/dist/q-store-model.min.js +33 -4
- package/package.json +9 -9
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: Publish to npm on Tag
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
tags:
|
|
5
|
+
- 'v*'
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
packages: write
|
|
13
|
+
# environment: production
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0 # Needed to get tag information
|
|
18
|
+
|
|
19
|
+
- name: Install pnpm
|
|
20
|
+
uses: pnpm/action-setup@v4
|
|
21
|
+
with:
|
|
22
|
+
version: 9
|
|
23
|
+
|
|
24
|
+
- uses: actions/setup-node@v4
|
|
25
|
+
with:
|
|
26
|
+
node-version: '20.x'
|
|
27
|
+
registry-url: https://registry.npmjs.org/
|
|
28
|
+
cache: 'pnpm'
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: pnpm install
|
|
32
|
+
|
|
33
|
+
- name: Build
|
|
34
|
+
run: |
|
|
35
|
+
BUILD_COMMAND=$(node -p "(require('./package.json').scripts || {}).build")
|
|
36
|
+
if [ "$BUILD_COMMAND" = "undefined" ]; then
|
|
37
|
+
echo "::notice::Can't find a build script in package.json, skip."
|
|
38
|
+
else
|
|
39
|
+
pnpm run build
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
- name: Publish to npm
|
|
43
|
+
# if: steps.version-check.outputs.should_publish == 'true'
|
|
44
|
+
run: pnpm publish --no-git-checks --access public
|
|
45
|
+
env:
|
|
46
|
+
NODE_AUTH_TOKEN: ${{ secrets.QW_NPM_TOKEN }}
|
package/dist/index.min.cjs
CHANGED
|
@@ -1809,12 +1809,14 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1809
1809
|
this.merchandiseCategoryCodes = options.merchandiseCategoryCodes || []
|
|
1810
1810
|
this.merchandiseCode = merchandise_setCode(options, 'merchandiseCode')
|
|
1811
1811
|
this.merchandiseOptions = initMerchandiseOptions(this, options)
|
|
1812
|
+
this.merchandiseType = options.merchandiseType || 'merchandise'
|
|
1812
1813
|
this.name = options.name || ''
|
|
1813
1814
|
this.prices = this._Price.initOnlyValidFromArray(options.prices)
|
|
1814
1815
|
this.productCodes = options.productCodes || []
|
|
1815
1816
|
this.priority = options.priority || 100
|
|
1816
1817
|
this.sku = options.sku || ''
|
|
1817
1818
|
this.stock = options.stock || 0
|
|
1819
|
+
this.targets = options.targets || []
|
|
1818
1820
|
}
|
|
1819
1821
|
|
|
1820
1822
|
// Class Mehtods
|
|
@@ -1884,6 +1886,12 @@ class Merchandise extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
1884
1886
|
get isAvailableByDate() {
|
|
1885
1887
|
return !this.afterEnd && !this.beforeBegin
|
|
1886
1888
|
}
|
|
1889
|
+
get isForPersonal() {
|
|
1890
|
+
return !Array.isArray(this.targets) || this.targets.length === 0
|
|
1891
|
+
}
|
|
1892
|
+
get isForGroup() {
|
|
1893
|
+
return Array.isArray(this.targets) && this.targets.includes('GROUP')
|
|
1894
|
+
}
|
|
1887
1895
|
get isPrintable() {
|
|
1888
1896
|
return this.printOut.isPrintable
|
|
1889
1897
|
}
|
|
@@ -2431,6 +2439,7 @@ class Status {
|
|
|
2431
2439
|
this.onHold = options.onHold || null
|
|
2432
2440
|
this.processing = options.processing || null
|
|
2433
2441
|
this.paid = options.paid || null
|
|
2442
|
+
this.payLater = options.payLater || null
|
|
2434
2443
|
this.pending = options.pending
|
|
2435
2444
|
this.redeemed = options.redeemed || null
|
|
2436
2445
|
this.refunded = options.refunded || null
|
|
@@ -2438,6 +2447,7 @@ class Status {
|
|
|
2438
2447
|
this.rejected = options.rejected || null
|
|
2439
2448
|
this.shared = options.shared || null
|
|
2440
2449
|
this.submitted = options.submitted || null
|
|
2450
|
+
this.terminated = options.terminated || null
|
|
2441
2451
|
this.used = options.used || null
|
|
2442
2452
|
this.waived = options.waived || null
|
|
2443
2453
|
}
|
|
@@ -2510,6 +2520,9 @@ class Status {
|
|
|
2510
2520
|
get isPaid() {
|
|
2511
2521
|
return this.paid !== null
|
|
2512
2522
|
}
|
|
2523
|
+
get isPayLater() {
|
|
2524
|
+
return this.payLater !== null
|
|
2525
|
+
}
|
|
2513
2526
|
get isPending() {
|
|
2514
2527
|
return !this.isSettled && !this.isCancelled && !this.isRefundRequested
|
|
2515
2528
|
}
|
|
@@ -2534,6 +2547,9 @@ class Status {
|
|
|
2534
2547
|
get isSubmitted() {
|
|
2535
2548
|
return this.submitted !== null
|
|
2536
2549
|
}
|
|
2550
|
+
get isTerminated() {
|
|
2551
|
+
return this.terminated !== null
|
|
2552
|
+
}
|
|
2537
2553
|
get isUsed() {
|
|
2538
2554
|
return this.used !== null
|
|
2539
2555
|
}
|
|
@@ -2633,6 +2649,10 @@ class Status {
|
|
|
2633
2649
|
this.waived = null
|
|
2634
2650
|
return this
|
|
2635
2651
|
}
|
|
2652
|
+
setPayLater(value) {
|
|
2653
|
+
this.payLater = value || (new Date()).valueOf()
|
|
2654
|
+
return this
|
|
2655
|
+
}
|
|
2636
2656
|
setPending(value) {
|
|
2637
2657
|
this.pending = value || (new Date()).valueOf()
|
|
2638
2658
|
return this
|
|
@@ -2661,6 +2681,10 @@ class Status {
|
|
|
2661
2681
|
this.submitted = value || (new Date()).valueOf()
|
|
2662
2682
|
return this
|
|
2663
2683
|
}
|
|
2684
|
+
setTerminated(value) {
|
|
2685
|
+
this.terminated = value || (new Date()).valueOf()
|
|
2686
|
+
return this
|
|
2687
|
+
}
|
|
2664
2688
|
setUsed(value) {
|
|
2665
2689
|
this.used = value || (new Date()).valueOf()
|
|
2666
2690
|
this.delivered = this.delivered || this.used
|
|
@@ -2910,6 +2934,9 @@ class Cart extends q_utilities_namespaceObject.TenantAwareEntity {
|
|
|
2910
2934
|
// }, [])
|
|
2911
2935
|
// return initWalletItems
|
|
2912
2936
|
// }
|
|
2937
|
+
getRelatedRegistrationGroupCode() {
|
|
2938
|
+
return q_utilities_namespaceObject.KeyValueObject.getValueByKey(this.remarks || [], 'registrationGroupCode')
|
|
2939
|
+
}
|
|
2913
2940
|
setCartItems(cartItems) {
|
|
2914
2941
|
this.cartItems = this._CartItem.initOnlyValidFromArray(cartItems)
|
|
2915
2942
|
return this
|
|
@@ -5406,7 +5433,7 @@ class ChainCategoryLimit extends Chain {
|
|
|
5406
5433
|
function groupCategory(categories = [], walletItems = []) {
|
|
5407
5434
|
return categories.reduce((acc, category) => {
|
|
5408
5435
|
const {
|
|
5409
|
-
categoryCode, name, max, min, productCodes = [],
|
|
5436
|
+
categoryCode, codes, name, max, min, productCodes = [],
|
|
5410
5437
|
} = category
|
|
5411
5438
|
const filtered = walletItems.filter((w) => {
|
|
5412
5439
|
if (w.status.cancelled !== null) {
|
|
@@ -5416,6 +5443,7 @@ function groupCategory(categories = [], walletItems = []) {
|
|
|
5416
5443
|
})
|
|
5417
5444
|
acc.push({
|
|
5418
5445
|
categoryCode,
|
|
5446
|
+
codes,
|
|
5419
5447
|
max,
|
|
5420
5448
|
min,
|
|
5421
5449
|
name,
|
|
@@ -5431,7 +5459,7 @@ function handleCategory(line, groupedCategory) {
|
|
|
5431
5459
|
const { productsQty, updatedItem } = line
|
|
5432
5460
|
// const productsQty = merchandise.getProductsQty(item.qty)
|
|
5433
5461
|
Object.keys(productsQty).forEach((key) => {
|
|
5434
|
-
const found = groupedCategory.find((g) => g.productCodes.includes(key))
|
|
5462
|
+
const found = groupedCategory.find((g) => g.productCodes.includes(key) && g.codes.includes(updatedItem.merchandiseCode))
|
|
5435
5463
|
if (found) {
|
|
5436
5464
|
const balance = found.max - (found.used + found.owned)
|
|
5437
5465
|
if (balance === 0) {
|
|
@@ -6632,11 +6660,12 @@ function _calculateAmountChainsFactoryforGroup(payload) {
|
|
|
6632
6660
|
|
|
6633
6661
|
|
|
6634
6662
|
;// ./lib/helpers/adminSettle/adminSettle.js
|
|
6635
|
-
function adminSettle({ component, invoice, payeeName, payeeAddress, payeeCountry, cb }) {
|
|
6663
|
+
function adminSettle({ component, eventRegistration, invoice, payeeName, payeeAddress, payeeCountry, cb }) {
|
|
6664
|
+
const _eventRegistration = eventRegistration || component.registration
|
|
6636
6665
|
component.invoice = invoice
|
|
6637
6666
|
component.adminSettleFormData = {
|
|
6638
6667
|
...invoice,
|
|
6639
|
-
email:
|
|
6668
|
+
email: _eventRegistration ? _eventRegistration.getEmail() || '' : '',
|
|
6640
6669
|
payeeName,
|
|
6641
6670
|
payeeAddress,
|
|
6642
6671
|
payeeCountry,
|
|
@@ -1847,12 +1847,14 @@ class Merchandise extends q_utilities_.TenantAwareEntity {
|
|
|
1847
1847
|
this.merchandiseCategoryCodes = options.merchandiseCategoryCodes || []
|
|
1848
1848
|
this.merchandiseCode = merchandise_setCode(options, 'merchandiseCode')
|
|
1849
1849
|
this.merchandiseOptions = initMerchandiseOptions(this, options)
|
|
1850
|
+
this.merchandiseType = options.merchandiseType || 'merchandise'
|
|
1850
1851
|
this.name = options.name || ''
|
|
1851
1852
|
this.prices = this._Price.initOnlyValidFromArray(options.prices)
|
|
1852
1853
|
this.productCodes = options.productCodes || []
|
|
1853
1854
|
this.priority = options.priority || 100
|
|
1854
1855
|
this.sku = options.sku || ''
|
|
1855
1856
|
this.stock = options.stock || 0
|
|
1857
|
+
this.targets = options.targets || []
|
|
1856
1858
|
}
|
|
1857
1859
|
|
|
1858
1860
|
// Class Mehtods
|
|
@@ -1922,6 +1924,12 @@ class Merchandise extends q_utilities_.TenantAwareEntity {
|
|
|
1922
1924
|
get isAvailableByDate() {
|
|
1923
1925
|
return !this.afterEnd && !this.beforeBegin
|
|
1924
1926
|
}
|
|
1927
|
+
get isForPersonal() {
|
|
1928
|
+
return !Array.isArray(this.targets) || this.targets.length === 0
|
|
1929
|
+
}
|
|
1930
|
+
get isForGroup() {
|
|
1931
|
+
return Array.isArray(this.targets) && this.targets.includes('GROUP')
|
|
1932
|
+
}
|
|
1925
1933
|
get isPrintable() {
|
|
1926
1934
|
return this.printOut.isPrintable
|
|
1927
1935
|
}
|
|
@@ -2469,6 +2477,7 @@ class Status {
|
|
|
2469
2477
|
this.onHold = options.onHold || null
|
|
2470
2478
|
this.processing = options.processing || null
|
|
2471
2479
|
this.paid = options.paid || null
|
|
2480
|
+
this.payLater = options.payLater || null
|
|
2472
2481
|
this.pending = options.pending
|
|
2473
2482
|
this.redeemed = options.redeemed || null
|
|
2474
2483
|
this.refunded = options.refunded || null
|
|
@@ -2476,6 +2485,7 @@ class Status {
|
|
|
2476
2485
|
this.rejected = options.rejected || null
|
|
2477
2486
|
this.shared = options.shared || null
|
|
2478
2487
|
this.submitted = options.submitted || null
|
|
2488
|
+
this.terminated = options.terminated || null
|
|
2479
2489
|
this.used = options.used || null
|
|
2480
2490
|
this.waived = options.waived || null
|
|
2481
2491
|
}
|
|
@@ -2548,6 +2558,9 @@ class Status {
|
|
|
2548
2558
|
get isPaid() {
|
|
2549
2559
|
return this.paid !== null
|
|
2550
2560
|
}
|
|
2561
|
+
get isPayLater() {
|
|
2562
|
+
return this.payLater !== null
|
|
2563
|
+
}
|
|
2551
2564
|
get isPending() {
|
|
2552
2565
|
return !this.isSettled && !this.isCancelled && !this.isRefundRequested
|
|
2553
2566
|
}
|
|
@@ -2572,6 +2585,9 @@ class Status {
|
|
|
2572
2585
|
get isSubmitted() {
|
|
2573
2586
|
return this.submitted !== null
|
|
2574
2587
|
}
|
|
2588
|
+
get isTerminated() {
|
|
2589
|
+
return this.terminated !== null
|
|
2590
|
+
}
|
|
2575
2591
|
get isUsed() {
|
|
2576
2592
|
return this.used !== null
|
|
2577
2593
|
}
|
|
@@ -2671,6 +2687,10 @@ class Status {
|
|
|
2671
2687
|
this.waived = null
|
|
2672
2688
|
return this
|
|
2673
2689
|
}
|
|
2690
|
+
setPayLater(value) {
|
|
2691
|
+
this.payLater = value || (new Date()).valueOf()
|
|
2692
|
+
return this
|
|
2693
|
+
}
|
|
2674
2694
|
setPending(value) {
|
|
2675
2695
|
this.pending = value || (new Date()).valueOf()
|
|
2676
2696
|
return this
|
|
@@ -2699,6 +2719,10 @@ class Status {
|
|
|
2699
2719
|
this.submitted = value || (new Date()).valueOf()
|
|
2700
2720
|
return this
|
|
2701
2721
|
}
|
|
2722
|
+
setTerminated(value) {
|
|
2723
|
+
this.terminated = value || (new Date()).valueOf()
|
|
2724
|
+
return this
|
|
2725
|
+
}
|
|
2702
2726
|
setUsed(value) {
|
|
2703
2727
|
this.used = value || (new Date()).valueOf()
|
|
2704
2728
|
this.delivered = this.delivered || this.used
|
|
@@ -2948,6 +2972,9 @@ class Cart extends q_utilities_.TenantAwareEntity {
|
|
|
2948
2972
|
// }, [])
|
|
2949
2973
|
// return initWalletItems
|
|
2950
2974
|
// }
|
|
2975
|
+
getRelatedRegistrationGroupCode() {
|
|
2976
|
+
return q_utilities_.KeyValueObject.getValueByKey(this.remarks || [], 'registrationGroupCode')
|
|
2977
|
+
}
|
|
2951
2978
|
setCartItems(cartItems) {
|
|
2952
2979
|
this.cartItems = this._CartItem.initOnlyValidFromArray(cartItems)
|
|
2953
2980
|
return this
|
|
@@ -5444,7 +5471,7 @@ class ChainCategoryLimit extends Chain {
|
|
|
5444
5471
|
function groupCategory(categories = [], walletItems = []) {
|
|
5445
5472
|
return categories.reduce((acc, category) => {
|
|
5446
5473
|
const {
|
|
5447
|
-
categoryCode, name, max, min, productCodes = [],
|
|
5474
|
+
categoryCode, codes, name, max, min, productCodes = [],
|
|
5448
5475
|
} = category
|
|
5449
5476
|
const filtered = walletItems.filter((w) => {
|
|
5450
5477
|
if (w.status.cancelled !== null) {
|
|
@@ -5454,6 +5481,7 @@ function groupCategory(categories = [], walletItems = []) {
|
|
|
5454
5481
|
})
|
|
5455
5482
|
acc.push({
|
|
5456
5483
|
categoryCode,
|
|
5484
|
+
codes,
|
|
5457
5485
|
max,
|
|
5458
5486
|
min,
|
|
5459
5487
|
name,
|
|
@@ -5469,7 +5497,7 @@ function handleCategory(line, groupedCategory) {
|
|
|
5469
5497
|
const { productsQty, updatedItem } = line
|
|
5470
5498
|
// const productsQty = merchandise.getProductsQty(item.qty)
|
|
5471
5499
|
Object.keys(productsQty).forEach((key) => {
|
|
5472
|
-
const found = groupedCategory.find((g) => g.productCodes.includes(key))
|
|
5500
|
+
const found = groupedCategory.find((g) => g.productCodes.includes(key) && g.codes.includes(updatedItem.merchandiseCode))
|
|
5473
5501
|
if (found) {
|
|
5474
5502
|
const balance = found.max - (found.used + found.owned)
|
|
5475
5503
|
if (balance === 0) {
|
|
@@ -6670,11 +6698,12 @@ function _calculateAmountChainsFactoryforGroup(payload) {
|
|
|
6670
6698
|
|
|
6671
6699
|
|
|
6672
6700
|
;// ./lib/helpers/adminSettle/adminSettle.js
|
|
6673
|
-
function adminSettle({ component, invoice, payeeName, payeeAddress, payeeCountry, cb }) {
|
|
6701
|
+
function adminSettle({ component, eventRegistration, invoice, payeeName, payeeAddress, payeeCountry, cb }) {
|
|
6702
|
+
const _eventRegistration = eventRegistration || component.registration
|
|
6674
6703
|
component.invoice = invoice
|
|
6675
6704
|
component.adminSettleFormData = {
|
|
6676
6705
|
...invoice,
|
|
6677
|
-
email:
|
|
6706
|
+
email: _eventRegistration ? _eventRegistration.getEmail() || '' : '',
|
|
6678
6707
|
payeeName,
|
|
6679
6708
|
payeeAddress,
|
|
6680
6709
|
payeeCountry,
|
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.38",
|
|
4
4
|
"description": "Questwork QStore Model",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -9,13 +9,6 @@
|
|
|
9
9
|
"default": "./dist/q-store-model.min.js"
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "cross-env NODE_ENV=production minimize=false gulp",
|
|
14
|
-
"build:umd": "cross-env NODE_ENV=production minimize=false gulp umd",
|
|
15
|
-
"build:wp": "cross-env NODE_ENV=production minimize=false gulp wp",
|
|
16
|
-
"lint": "eslint .",
|
|
17
|
-
"test:models": "NODE_ENV=test mocha --exit 'lib/models/test.setup.js' 'lib/models/**/*.spec.js'"
|
|
18
|
-
},
|
|
19
12
|
"author": {
|
|
20
13
|
"name": "Questwork Consulting Limited",
|
|
21
14
|
"email": "info@questwork.com",
|
|
@@ -44,5 +37,12 @@
|
|
|
44
37
|
},
|
|
45
38
|
"engines": {
|
|
46
39
|
"node": ">=10.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "cross-env NODE_ENV=production minimize=false gulp",
|
|
43
|
+
"build:umd": "cross-env NODE_ENV=production minimize=false gulp umd",
|
|
44
|
+
"build:wp": "cross-env NODE_ENV=production minimize=false gulp wp",
|
|
45
|
+
"lint": "eslint .",
|
|
46
|
+
"test:models": "NODE_ENV=test mocha --exit 'lib/models/test.setup.js' 'lib/models/**/*.spec.js'"
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|