@commercetools/sync-actions 7.0.0-rc.2 → 7.1.0
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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/{sync-actions.cjs.js → commercetools-sync-actions.cjs.dev.js} +323 -1786
- package/dist/commercetools-sync-actions.cjs.js +7 -0
- package/dist/commercetools-sync-actions.cjs.prod.js +3747 -0
- package/dist/{sync-actions.es.js → commercetools-sync-actions.esm.js} +227 -1723
- package/package.json +16 -11
- package/dist/sync-actions.umd.js +0 -5207
- package/dist/sync-actions.umd.min.js +0 -1
- package/lib/cart-discounts-actions.js +0 -31
- package/lib/cart-discounts.js +0 -70
- package/lib/categories.js +0 -106
- package/lib/category-actions.js +0 -117
- package/lib/channels.js +0 -0
- package/lib/customer-actions.js +0 -125
- package/lib/customer-group-actions.js +0 -23
- package/lib/customer-group.js +0 -70
- package/lib/customers.js +0 -95
- package/lib/discount-codes-actions.js +0 -31
- package/lib/discount-codes.js +0 -80
- package/lib/index.js +0 -90
- package/lib/inventories.js +0 -89
- package/lib/inventory-actions.js +0 -42
- package/lib/order-actions.js +0 -71
- package/lib/orders.js +0 -89
- package/lib/product-actions.js +0 -779
- package/lib/product-discounts-actions.js +0 -27
- package/lib/product-discounts.js +0 -71
- package/lib/products.js +0 -208
- package/lib/utils/clone.js +0 -9
- package/lib/utils/common-actions.js +0 -157
- package/lib/utils/create-build-actions.js +0 -74
- package/lib/utils/create-build-array-actions.js +0 -146
- package/lib/utils/create-map-action-group.js +0 -35
- package/lib/utils/diffpatcher.js +0 -93
- package/lib/utils/find-matching-pairs.js +0 -67
package/lib/customer-group.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
})
|
|
6
|
-
exports.actionGroups = undefined
|
|
7
|
-
|
|
8
|
-
var _lodash = require('lodash.flatten')
|
|
9
|
-
|
|
10
|
-
var _lodash2 = _interopRequireDefault(_lodash)
|
|
11
|
-
|
|
12
|
-
var _createBuildActions = require('./utils/create-build-actions')
|
|
13
|
-
|
|
14
|
-
var _createBuildActions2 = _interopRequireDefault(_createBuildActions)
|
|
15
|
-
|
|
16
|
-
var _createMapActionGroup = require('./utils/create-map-action-group')
|
|
17
|
-
|
|
18
|
-
var _createMapActionGroup2 = _interopRequireDefault(_createMapActionGroup)
|
|
19
|
-
|
|
20
|
-
var _customerGroupActions = require('./customer-group-actions')
|
|
21
|
-
|
|
22
|
-
var _diffpatcher = require('./utils/diffpatcher')
|
|
23
|
-
|
|
24
|
-
var diffpatcher = _interopRequireWildcard(_diffpatcher)
|
|
25
|
-
|
|
26
|
-
function _interopRequireWildcard(obj) {
|
|
27
|
-
if (obj && obj.__esModule) {
|
|
28
|
-
return obj
|
|
29
|
-
} else {
|
|
30
|
-
var newObj = {}
|
|
31
|
-
if (obj != null) {
|
|
32
|
-
for (var key in obj) {
|
|
33
|
-
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
34
|
-
newObj[key] = obj[key]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
newObj.default = obj
|
|
38
|
-
return newObj
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _interopRequireDefault(obj) {
|
|
43
|
-
return obj && obj.__esModule ? obj : { default: obj }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
var actionGroups = (exports.actionGroups = ['base'])
|
|
47
|
-
|
|
48
|
-
function createCustomerGroupMapActions(mapActionGroup) {
|
|
49
|
-
return function doMapActions(diff, newObj, oldObj) {
|
|
50
|
-
var allActions = []
|
|
51
|
-
|
|
52
|
-
allActions.push(
|
|
53
|
-
mapActionGroup('base', function() {
|
|
54
|
-
return (0, _customerGroupActions.actionsMapBase)(diff, oldObj, newObj)
|
|
55
|
-
})
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
return (0, _lodash2.default)(allActions)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
exports.default = function(config) {
|
|
63
|
-
var mapActionGroup = (0, _createMapActionGroup2.default)(config)
|
|
64
|
-
var doMapActions = createCustomerGroupMapActions(mapActionGroup)
|
|
65
|
-
var buildActions = (0, _createBuildActions2.default)(
|
|
66
|
-
diffpatcher.diff,
|
|
67
|
-
doMapActions
|
|
68
|
-
)
|
|
69
|
-
return { buildActions: buildActions }
|
|
70
|
-
}
|
package/lib/customers.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
})
|
|
6
|
-
exports.actionGroups = undefined
|
|
7
|
-
|
|
8
|
-
var _lodash = require('lodash.flatten')
|
|
9
|
-
|
|
10
|
-
var _lodash2 = _interopRequireDefault(_lodash)
|
|
11
|
-
|
|
12
|
-
var _createBuildActions = require('./utils/create-build-actions')
|
|
13
|
-
|
|
14
|
-
var _createBuildActions2 = _interopRequireDefault(_createBuildActions)
|
|
15
|
-
|
|
16
|
-
var _createMapActionGroup = require('./utils/create-map-action-group')
|
|
17
|
-
|
|
18
|
-
var _createMapActionGroup2 = _interopRequireDefault(_createMapActionGroup)
|
|
19
|
-
|
|
20
|
-
var _customerActions = require('./customer-actions')
|
|
21
|
-
|
|
22
|
-
var customerActions = _interopRequireWildcard(_customerActions)
|
|
23
|
-
|
|
24
|
-
var _diffpatcher = require('./utils/diffpatcher')
|
|
25
|
-
|
|
26
|
-
var diffpatcher = _interopRequireWildcard(_diffpatcher)
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj) {
|
|
29
|
-
if (obj && obj.__esModule) {
|
|
30
|
-
return obj
|
|
31
|
-
} else {
|
|
32
|
-
var newObj = {}
|
|
33
|
-
if (obj != null) {
|
|
34
|
-
for (var key in obj) {
|
|
35
|
-
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
36
|
-
newObj[key] = obj[key]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
newObj.default = obj
|
|
40
|
-
return newObj
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function _interopRequireDefault(obj) {
|
|
45
|
-
return obj && obj.__esModule ? obj : { default: obj }
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var actionGroups = (exports.actionGroups = ['base', 'references', 'addresses'])
|
|
49
|
-
|
|
50
|
-
function createCustomerMapActions(mapActionGroup) {
|
|
51
|
-
return function doMapActions(diff, newObj, oldObj /* , options */) {
|
|
52
|
-
var allActions = []
|
|
53
|
-
|
|
54
|
-
allActions.push(
|
|
55
|
-
mapActionGroup('base', function() {
|
|
56
|
-
return customerActions.actionsMapBase(diff, oldObj, newObj)
|
|
57
|
-
})
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
allActions.push(
|
|
61
|
-
mapActionGroup('references', function() {
|
|
62
|
-
return customerActions.actionsMapReferences(diff, oldObj, newObj)
|
|
63
|
-
})
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
allActions.push(
|
|
67
|
-
mapActionGroup('addresses', function() {
|
|
68
|
-
return customerActions.actionsMapAddresses(diff, oldObj, newObj)
|
|
69
|
-
})
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
return (0, _lodash2.default)(allActions)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
exports.default = function(config) {
|
|
77
|
-
// config contains information about which action groups
|
|
78
|
-
// are white/black listed
|
|
79
|
-
|
|
80
|
-
// createMapActionGroup returns function 'mapActionGroup' that takes params:
|
|
81
|
-
// - action group name
|
|
82
|
-
// - callback function that should return a list of actions that correspond
|
|
83
|
-
// to the for the action group
|
|
84
|
-
|
|
85
|
-
// this resulting function mapActionGroup will call the callback function
|
|
86
|
-
// for whitelisted action groups and return the return value of the callback
|
|
87
|
-
// It will return an empty array for blacklisted action groups
|
|
88
|
-
var mapActionGroup = (0, _createMapActionGroup2.default)(config)
|
|
89
|
-
var doMapActions = createCustomerMapActions(mapActionGroup)
|
|
90
|
-
var buildActions = (0, _createBuildActions2.default)(
|
|
91
|
-
diffpatcher.diff,
|
|
92
|
-
doMapActions
|
|
93
|
-
)
|
|
94
|
-
return { buildActions: buildActions }
|
|
95
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
})
|
|
6
|
-
exports.baseActionsList = undefined
|
|
7
|
-
exports.actionsMapBase = actionsMapBase
|
|
8
|
-
|
|
9
|
-
var _commonActions = require('./utils/common-actions')
|
|
10
|
-
|
|
11
|
-
var baseActionsList = (exports.baseActionsList = [
|
|
12
|
-
{ action: 'changeIsActive', key: 'isActive' },
|
|
13
|
-
{ action: 'setName', key: 'name' },
|
|
14
|
-
{ action: 'setDescription', key: 'description' },
|
|
15
|
-
{ action: 'setCartPredicate', key: 'cartPredicate' },
|
|
16
|
-
{ action: 'setMaxApplications', key: 'maxApplications' },
|
|
17
|
-
{
|
|
18
|
-
action: 'setMaxApplicationsPerCustomer',
|
|
19
|
-
key: 'maxApplicationsPerCustomer',
|
|
20
|
-
},
|
|
21
|
-
{ action: 'changeCartDiscounts', key: 'cartDiscounts' },
|
|
22
|
-
])
|
|
23
|
-
|
|
24
|
-
function actionsMapBase(diff, oldObj, newObj) {
|
|
25
|
-
return (0, _commonActions.buildBaseAttributesActions)({
|
|
26
|
-
actions: baseActionsList,
|
|
27
|
-
diff: diff,
|
|
28
|
-
oldObj: oldObj,
|
|
29
|
-
newObj: newObj,
|
|
30
|
-
})
|
|
31
|
-
}
|
package/lib/discount-codes.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
})
|
|
6
|
-
exports.actionGroups = undefined
|
|
7
|
-
|
|
8
|
-
var _lodash = require('lodash.flatten')
|
|
9
|
-
|
|
10
|
-
var _lodash2 = _interopRequireDefault(_lodash)
|
|
11
|
-
|
|
12
|
-
var _createBuildActions = require('./utils/create-build-actions')
|
|
13
|
-
|
|
14
|
-
var _createBuildActions2 = _interopRequireDefault(_createBuildActions)
|
|
15
|
-
|
|
16
|
-
var _createMapActionGroup = require('./utils/create-map-action-group')
|
|
17
|
-
|
|
18
|
-
var _createMapActionGroup2 = _interopRequireDefault(_createMapActionGroup)
|
|
19
|
-
|
|
20
|
-
var _discountCodesActions = require('./discount-codes-actions')
|
|
21
|
-
|
|
22
|
-
var _diffpatcher = require('./utils/diffpatcher')
|
|
23
|
-
|
|
24
|
-
var diffpatcher = _interopRequireWildcard(_diffpatcher)
|
|
25
|
-
|
|
26
|
-
function _interopRequireWildcard(obj) {
|
|
27
|
-
if (obj && obj.__esModule) {
|
|
28
|
-
return obj
|
|
29
|
-
} else {
|
|
30
|
-
var newObj = {}
|
|
31
|
-
if (obj != null) {
|
|
32
|
-
for (var key in obj) {
|
|
33
|
-
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
34
|
-
newObj[key] = obj[key]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
newObj.default = obj
|
|
38
|
-
return newObj
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _interopRequireDefault(obj) {
|
|
43
|
-
return obj && obj.__esModule ? obj : { default: obj }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
var actionGroups = (exports.actionGroups = ['base', 'references'])
|
|
47
|
-
|
|
48
|
-
function createDiscountCodesMapActions(mapActionGroup) {
|
|
49
|
-
return function doMapActions(diff, newObj, oldObj) {
|
|
50
|
-
var allActions = []
|
|
51
|
-
|
|
52
|
-
allActions.push(
|
|
53
|
-
mapActionGroup('base', function() {
|
|
54
|
-
return (0, _discountCodesActions.actionsMapBase)(diff, oldObj, newObj)
|
|
55
|
-
})
|
|
56
|
-
)
|
|
57
|
-
return (0, _lodash2.default)(allActions)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
exports.default = function(config) {
|
|
62
|
-
// config contains information about which action groups
|
|
63
|
-
// are white/black listed
|
|
64
|
-
|
|
65
|
-
// createMapActionGroup returns function 'mapActionGroup' that takes params:
|
|
66
|
-
// - action group name
|
|
67
|
-
// - callback function that should return a list of actions that correspond
|
|
68
|
-
// to the for the action group
|
|
69
|
-
|
|
70
|
-
// this resulting function mapActionGroup will call the callback function
|
|
71
|
-
// for whitelisted action groups and return the return value of the callback
|
|
72
|
-
// It will return an empty array for blacklisted action groups
|
|
73
|
-
var mapActionGroup = (0, _createMapActionGroup2.default)(config)
|
|
74
|
-
var doMapActions = createDiscountCodesMapActions(mapActionGroup)
|
|
75
|
-
var buildActions = (0, _createBuildActions2.default)(
|
|
76
|
-
diffpatcher.diff,
|
|
77
|
-
doMapActions
|
|
78
|
-
)
|
|
79
|
-
return { buildActions: buildActions }
|
|
80
|
-
}
|
package/lib/index.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
var _categories = require('./categories')
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, 'createSyncCategories', {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function get() {
|
|
12
|
-
return _interopRequireDefault(_categories).default
|
|
13
|
-
},
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
var _customers = require('./customers')
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(exports, 'createSyncCustomers', {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _interopRequireDefault(_customers).default
|
|
22
|
-
},
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
var _inventories = require('./inventories')
|
|
26
|
-
|
|
27
|
-
Object.defineProperty(exports, 'createSyncInventories', {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function get() {
|
|
30
|
-
return _interopRequireDefault(_inventories).default
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
var _products = require('./products')
|
|
35
|
-
|
|
36
|
-
Object.defineProperty(exports, 'createSyncProducts', {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function get() {
|
|
39
|
-
return _interopRequireDefault(_products).default
|
|
40
|
-
},
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
var _orders = require('./orders')
|
|
44
|
-
|
|
45
|
-
Object.defineProperty(exports, 'createSyncOrders', {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function get() {
|
|
48
|
-
return _interopRequireDefault(_orders).default
|
|
49
|
-
},
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
var _productDiscounts = require('./product-discounts')
|
|
53
|
-
|
|
54
|
-
Object.defineProperty(exports, 'createSyncProductDiscounts', {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function get() {
|
|
57
|
-
return _interopRequireDefault(_productDiscounts).default
|
|
58
|
-
},
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
var _discountCodes = require('./discount-codes')
|
|
62
|
-
|
|
63
|
-
Object.defineProperty(exports, 'createSyncDiscountCodes', {
|
|
64
|
-
enumerable: true,
|
|
65
|
-
get: function get() {
|
|
66
|
-
return _interopRequireDefault(_discountCodes).default
|
|
67
|
-
},
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
var _customerGroup = require('./customer-group')
|
|
71
|
-
|
|
72
|
-
Object.defineProperty(exports, 'createSyncCustomerGroup', {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function get() {
|
|
75
|
-
return _interopRequireDefault(_customerGroup).default
|
|
76
|
-
},
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
var _cartDiscounts = require('./cart-discounts')
|
|
80
|
-
|
|
81
|
-
Object.defineProperty(exports, 'createSyncCartDiscounts', {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
get: function get() {
|
|
84
|
-
return _interopRequireDefault(_cartDiscounts).default
|
|
85
|
-
},
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
function _interopRequireDefault(obj) {
|
|
89
|
-
return obj && obj.__esModule ? obj : { default: obj }
|
|
90
|
-
}
|
package/lib/inventories.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
})
|
|
6
|
-
exports.actionGroups = undefined
|
|
7
|
-
|
|
8
|
-
var _lodash = require('lodash.flatten')
|
|
9
|
-
|
|
10
|
-
var _lodash2 = _interopRequireDefault(_lodash)
|
|
11
|
-
|
|
12
|
-
var _createBuildActions = require('./utils/create-build-actions')
|
|
13
|
-
|
|
14
|
-
var _createBuildActions2 = _interopRequireDefault(_createBuildActions)
|
|
15
|
-
|
|
16
|
-
var _createMapActionGroup = require('./utils/create-map-action-group')
|
|
17
|
-
|
|
18
|
-
var _createMapActionGroup2 = _interopRequireDefault(_createMapActionGroup)
|
|
19
|
-
|
|
20
|
-
var _inventoryActions = require('./inventory-actions')
|
|
21
|
-
|
|
22
|
-
var inventoryActions = _interopRequireWildcard(_inventoryActions)
|
|
23
|
-
|
|
24
|
-
var _diffpatcher = require('./utils/diffpatcher')
|
|
25
|
-
|
|
26
|
-
var diffpatcher = _interopRequireWildcard(_diffpatcher)
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj) {
|
|
29
|
-
if (obj && obj.__esModule) {
|
|
30
|
-
return obj
|
|
31
|
-
} else {
|
|
32
|
-
var newObj = {}
|
|
33
|
-
if (obj != null) {
|
|
34
|
-
for (var key in obj) {
|
|
35
|
-
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
36
|
-
newObj[key] = obj[key]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
newObj.default = obj
|
|
40
|
-
return newObj
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function _interopRequireDefault(obj) {
|
|
45
|
-
return obj && obj.__esModule ? obj : { default: obj }
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var actionGroups = (exports.actionGroups = ['base', 'references'])
|
|
49
|
-
|
|
50
|
-
function createInventoryMapActions(mapActionGroup) {
|
|
51
|
-
return function doMapActions(diff, newObj, oldObj /* , options */) {
|
|
52
|
-
var allActions = []
|
|
53
|
-
|
|
54
|
-
allActions.push(
|
|
55
|
-
mapActionGroup('base', function() {
|
|
56
|
-
return inventoryActions.actionsMapBase(diff, oldObj, newObj)
|
|
57
|
-
})
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
allActions.push(
|
|
61
|
-
mapActionGroup('references', function() {
|
|
62
|
-
return inventoryActions.actionsMapReferences(diff, oldObj, newObj)
|
|
63
|
-
})
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
return (0, _lodash2.default)(allActions)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
exports.default = function(config) {
|
|
71
|
-
// config contains information about which action groups
|
|
72
|
-
// are white/black listed
|
|
73
|
-
|
|
74
|
-
// createMapActionGroup returns function 'mapActionGroup' that takes params:
|
|
75
|
-
// - action group name
|
|
76
|
-
// - callback function that should return a list of actions that correspond
|
|
77
|
-
// to the for the action group
|
|
78
|
-
|
|
79
|
-
// this resulting function mapActionGroup will call the callback function
|
|
80
|
-
// for whitelisted action groups and return the return value of the callback
|
|
81
|
-
// It will return an empty array for blacklisted action groups
|
|
82
|
-
var mapActionGroup = (0, _createMapActionGroup2.default)(config)
|
|
83
|
-
var doMapActions = createInventoryMapActions(mapActionGroup)
|
|
84
|
-
var buildActions = (0, _createBuildActions2.default)(
|
|
85
|
-
diffpatcher.diff,
|
|
86
|
-
doMapActions
|
|
87
|
-
)
|
|
88
|
-
return { buildActions: buildActions }
|
|
89
|
-
}
|
package/lib/inventory-actions.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
})
|
|
6
|
-
exports.referenceActionsList = exports.baseActionsList = undefined
|
|
7
|
-
exports.actionsMapBase = actionsMapBase
|
|
8
|
-
exports.actionsMapReferences = actionsMapReferences
|
|
9
|
-
|
|
10
|
-
var _commonActions = require('./utils/common-actions')
|
|
11
|
-
|
|
12
|
-
var baseActionsList = (exports.baseActionsList = [
|
|
13
|
-
{ action: 'changeQuantity', key: 'quantityOnStock', actionKey: 'quantity' },
|
|
14
|
-
{ action: 'setRestockableInDays', key: 'restockableInDays' },
|
|
15
|
-
{ action: 'setExpectedDelivery', key: 'expectedDelivery' },
|
|
16
|
-
])
|
|
17
|
-
|
|
18
|
-
var referenceActionsList = (exports.referenceActionsList = [
|
|
19
|
-
{ action: 'setSupplyChannel', key: 'supplyChannel' },
|
|
20
|
-
])
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* SYNC FUNCTIONS
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
function actionsMapBase(diff, oldObj, newObj) {
|
|
27
|
-
return (0, _commonActions.buildBaseAttributesActions)({
|
|
28
|
-
actions: baseActionsList,
|
|
29
|
-
diff: diff,
|
|
30
|
-
oldObj: oldObj,
|
|
31
|
-
newObj: newObj,
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function actionsMapReferences(diff, oldObj, newObj) {
|
|
36
|
-
return (0, _commonActions.buildReferenceActions)({
|
|
37
|
-
actions: referenceActionsList,
|
|
38
|
-
diff: diff,
|
|
39
|
-
oldObj: oldObj,
|
|
40
|
-
newObj: newObj,
|
|
41
|
-
})
|
|
42
|
-
}
|
package/lib/order-actions.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
})
|
|
6
|
-
exports.baseActionsList = undefined
|
|
7
|
-
exports.actionsMapBase = actionsMapBase
|
|
8
|
-
exports.actionsMapDeliveries = actionsMapDeliveries
|
|
9
|
-
|
|
10
|
-
var _commonActions = require('./utils/common-actions')
|
|
11
|
-
|
|
12
|
-
var _createBuildArrayActions = require('./utils/create-build-array-actions')
|
|
13
|
-
|
|
14
|
-
var _createBuildArrayActions2 = _interopRequireDefault(_createBuildArrayActions)
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) {
|
|
17
|
-
return obj && obj.__esModule ? obj : { default: obj }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _defineProperty(obj, key, value) {
|
|
21
|
-
if (key in obj) {
|
|
22
|
-
Object.defineProperty(obj, key, {
|
|
23
|
-
value: value,
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
})
|
|
28
|
-
} else {
|
|
29
|
-
obj[key] = value
|
|
30
|
-
}
|
|
31
|
-
return obj
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var baseActionsList = (exports.baseActionsList = [
|
|
35
|
-
{ action: 'changeOrderState', key: 'orderState' },
|
|
36
|
-
{ action: 'changePaymentState', key: 'paymentState' },
|
|
37
|
-
{ action: 'changeShipmentState', key: 'shipmentState' },
|
|
38
|
-
])
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* SYNC FUNCTIONS
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
function actionsMapBase(diff, oldObj, newObj) {
|
|
45
|
-
return (0, _commonActions.buildBaseAttributesActions)({
|
|
46
|
-
actions: baseActionsList,
|
|
47
|
-
diff: diff,
|
|
48
|
-
oldObj: oldObj,
|
|
49
|
-
newObj: newObj,
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function actionsMapDeliveries(diff, oldObj, newObj) {
|
|
54
|
-
var deliveriesDiff = diff.shippingInfo
|
|
55
|
-
if (!deliveriesDiff) return []
|
|
56
|
-
|
|
57
|
-
var handler = (0, _createBuildArrayActions2.default)(
|
|
58
|
-
'deliveries',
|
|
59
|
-
_defineProperty({}, _createBuildArrayActions.ADD_ACTIONS, function(
|
|
60
|
-
newObject
|
|
61
|
-
) {
|
|
62
|
-
return {
|
|
63
|
-
action: 'addDelivery',
|
|
64
|
-
items: newObject.items,
|
|
65
|
-
parcels: newObject.parcels,
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
return handler(deliveriesDiff, oldObj.shippingInfo, newObj.shippingInfo)
|
|
71
|
-
}
|
package/lib/orders.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
})
|
|
6
|
-
exports.actionGroups = undefined
|
|
7
|
-
|
|
8
|
-
var _lodash = require('lodash.flatten')
|
|
9
|
-
|
|
10
|
-
var _lodash2 = _interopRequireDefault(_lodash)
|
|
11
|
-
|
|
12
|
-
var _createBuildActions = require('./utils/create-build-actions')
|
|
13
|
-
|
|
14
|
-
var _createBuildActions2 = _interopRequireDefault(_createBuildActions)
|
|
15
|
-
|
|
16
|
-
var _createMapActionGroup = require('./utils/create-map-action-group')
|
|
17
|
-
|
|
18
|
-
var _createMapActionGroup2 = _interopRequireDefault(_createMapActionGroup)
|
|
19
|
-
|
|
20
|
-
var _orderActions = require('./order-actions')
|
|
21
|
-
|
|
22
|
-
var orderActions = _interopRequireWildcard(_orderActions)
|
|
23
|
-
|
|
24
|
-
var _diffpatcher = require('./utils/diffpatcher')
|
|
25
|
-
|
|
26
|
-
var diffpatcher = _interopRequireWildcard(_diffpatcher)
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj) {
|
|
29
|
-
if (obj && obj.__esModule) {
|
|
30
|
-
return obj
|
|
31
|
-
} else {
|
|
32
|
-
var newObj = {}
|
|
33
|
-
if (obj != null) {
|
|
34
|
-
for (var key in obj) {
|
|
35
|
-
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
36
|
-
newObj[key] = obj[key]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
newObj.default = obj
|
|
40
|
-
return newObj
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function _interopRequireDefault(obj) {
|
|
45
|
-
return obj && obj.__esModule ? obj : { default: obj }
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var actionGroups = (exports.actionGroups = ['base', 'deliveries'])
|
|
49
|
-
|
|
50
|
-
function createOrderMapActions(mapActionGroup) {
|
|
51
|
-
return function doMapActions(diff, newObj, oldObj /* , options */) {
|
|
52
|
-
var allActions = []
|
|
53
|
-
|
|
54
|
-
allActions.push(
|
|
55
|
-
mapActionGroup('base', function() {
|
|
56
|
-
return orderActions.actionsMapBase(diff, oldObj, newObj)
|
|
57
|
-
})
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
allActions.push(
|
|
61
|
-
mapActionGroup('deliveries', function() {
|
|
62
|
-
return orderActions.actionsMapDeliveries(diff, oldObj, newObj)
|
|
63
|
-
})
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
return (0, _lodash2.default)(allActions)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
exports.default = function(config) {
|
|
71
|
-
// config contains information about which action groups
|
|
72
|
-
// are white/black listed
|
|
73
|
-
|
|
74
|
-
// createMapActionGroup returns function 'mapActionGroup' that takes params:
|
|
75
|
-
// - action group name
|
|
76
|
-
// - callback function that should return a list of actions that correspond
|
|
77
|
-
// to the for the action group
|
|
78
|
-
|
|
79
|
-
// this resulting function mapActionGroup will call the callback function
|
|
80
|
-
// for whitelisted action groups and return the return value of the callback
|
|
81
|
-
// It will return an empty array for blacklisted action groups
|
|
82
|
-
var mapActionGroup = (0, _createMapActionGroup2.default)(config)
|
|
83
|
-
var doMapActions = createOrderMapActions(mapActionGroup)
|
|
84
|
-
var buildActions = (0, _createBuildActions2.default)(
|
|
85
|
-
diffpatcher.diff,
|
|
86
|
-
doMapActions
|
|
87
|
-
)
|
|
88
|
-
return { buildActions: buildActions }
|
|
89
|
-
}
|