@commercetools/sync-actions 7.0.0-rc.1 → 7.0.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.
@@ -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
- }
@@ -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
- }
@@ -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
- }