@commercetools/sync-actions 7.0.0-rc.2 → 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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,221 @@
1
+ # @commercetools/sync-actions
2
+
3
+ ## 7.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#1930](https://github.com/commercetools/nodejs/pull/1930) [`5a56792`](https://github.com/commercetools/nodejs/commit/5a5679256a4a7e4b90bc47b945b12acb4f70b411) Thanks [@tdeekens](https://github.com/tdeekens)! - # Requires Node.js v18 or later
8
+
9
+ This releases migrates packages to require Node.js v18 or later. Ideally you should be already using Node.js v20 or later. According to [Node.js Releases](https://nodejs.org/en/about/previous-releases) Node.js v18 will be in maintenance and reach End of Life by the end of April.
10
+
11
+ Other than requiring Node.js v18 packages with this releases do not contain any internal breaking changes.
12
+
13
+ ## 6.1.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [#1927](https://github.com/commercetools/nodejs/pull/1927) [`a4705c19`](https://github.com/commercetools/nodejs/commit/a4705c19af234cccde74cb52bfff912bf380c6ba) Thanks [@CarlosCortizasCT](https://github.com/CarlosCortizasCT)! - We found an issue in the way the `jsondiffpatch` was used that made this package not usable in a browser environment.
18
+
19
+ In this version we adjust the way that package is imported and we pin a transitive dependency (`chalk`) to fix the error.
20
+
21
+ ## 6.1.0
22
+
23
+ ### Minor Changes
24
+
25
+ - [#1921](https://github.com/commercetools/nodejs/pull/1921) [`c9d23e86`](https://github.com/commercetools/nodejs/commit/c9d23e86a6013aafb6a3c296121e1c5995d9eab6) Thanks [@kafis](https://github.com/kafis)! - Introducing configuration to control the behaviour regarding generation of UpdateActions in respect to unsetting fields
26
+
27
+ ## 6.0.0
28
+
29
+ ### Major Changes
30
+
31
+ - [#1919](https://github.com/commercetools/nodejs/pull/1919) [`1c867e02`](https://github.com/commercetools/nodejs/commit/1c867e02285f5030d5ef7aebef46ea27e5e8521b) Thanks [@CarlosCortizasCT](https://github.com/CarlosCortizasCT)! - Update the way we import the `jsondiffpath` dependency to use `import` instead of `require`.
32
+
33
+ ## 5.19.2
34
+
35
+ ### Patch Changes
36
+
37
+ - [#1914](https://github.com/commercetools/nodejs/pull/1914) [`6e1195ed`](https://github.com/commercetools/nodejs/commit/6e1195ed05cc3338eac94e47f439f10b7b0e6e75) Thanks [@antoniolodias](https://github.com/antoniolodias)! - fix: filter out unchanged taxrates from changed list
38
+
39
+ ## 5.19.1
40
+
41
+ ### Patch Changes
42
+
43
+ - [#1912](https://github.com/commercetools/nodejs/pull/1912) [`06866537`](https://github.com/commercetools/nodejs/commit/06866537feb04eaf26521d43b654cbc2920bab0d) Thanks [@markus-azer](https://github.com/markus-azer)! - Fix product action groups category order hints
44
+
45
+ ## 5.19.0
46
+
47
+ ### Minor Changes
48
+
49
+ - [#1908](https://github.com/commercetools/nodejs/pull/1908) [`df373a1a`](https://github.com/commercetools/nodejs/commit/df373a1adbcaa2340b0af0656fd0dbab055329f8) Thanks [@ChristianMoll](https://github.com/ChristianMoll)! - Fix action keys for changeMyBusinessUnitStatusOnCreation, setMyBusinessUnitAssociateRoleOnCreation and changeCustomerSearchStatus
50
+
51
+ ## 5.18.0
52
+
53
+ ### Minor Changes
54
+
55
+ - [#1903](https://github.com/commercetools/nodejs/pull/1903) [`164f1ce7`](https://github.com/commercetools/nodejs/commit/164f1ce7526bb15a16f531572518cbb6ddd61098) Thanks [@ChristianMoll](https://github.com/ChristianMoll)! - Add sync actions changeMyBusinessUnitStatusOnCreation, setMyBusinessUnitAssociateRoleOnCreation and changeCustomerSearchStatus
56
+
57
+ ## 5.17.0
58
+
59
+ ### Minor Changes
60
+
61
+ - [#1897](https://github.com/commercetools/nodejs/pull/1897) [`940dd70b`](https://github.com/commercetools/nodejs/commit/940dd70ba53c51e0fb74849aadb688db6add764d) Thanks [@antoniolodias](https://github.com/antoniolodias)! - add changeActive to shipping methods base actions
62
+
63
+ ## 5.16.0
64
+
65
+ ### Minor Changes
66
+
67
+ - [#1892](https://github.com/commercetools/nodejs/pull/1892) [`fb03b746`](https://github.com/commercetools/nodejs/commit/fb03b7463a990934d2b11fd17b784af104431cc4) Thanks [@ragafus](https://github.com/ragafus)! - Add support for DiscountCodes `setKey` action.
68
+
69
+ ## 5.15.0
70
+
71
+ ### Minor Changes
72
+
73
+ - [#1885](https://github.com/commercetools/nodejs/pull/1885) [`d6cb2740`](https://github.com/commercetools/nodejs/commit/d6cb27401279cb42a49366f32802f8ca8c7f01a3) Thanks [@kafis](https://github.com/kafis)! - Add support for 'changeAssetOrder' in (ProductVariants)[https://docs.commercetools.com/api/projects/products#change-asset-order].
74
+
75
+ ## 5.14.0
76
+
77
+ ### Minor Changes
78
+
79
+ - [#1876](https://github.com/commercetools/nodejs/pull/1876) [`27f0d2b6`](https://github.com/commercetools/nodejs/commit/27f0d2b66fefbe082b6a27e7fa940b09e7e6088c) Thanks [@jaikumar-tj](https://github.com/jaikumar-tj)! - Add support for attribute groups `changeName`, `setKey`, `setDescription`, `addAttribute` and `removeAttribute` actions.
80
+
81
+ ## 5.13.0
82
+
83
+ ### Minor Changes
84
+
85
+ - [#1874](https://github.com/commercetools/nodejs/pull/1874) [`69f4501d`](https://github.com/commercetools/nodejs/commit/69f4501dc5401ab2b44f4d3096a978094e402c9f) Thanks [@taylor-knapp](https://github.com/taylor-knapp)! - Handle long text values performantly
86
+
87
+ ## 5.12.2
88
+
89
+ ### Patch Changes
90
+
91
+ - [#1871](https://github.com/commercetools/nodejs/pull/1871) [`4f8ea39b`](https://github.com/commercetools/nodejs/commit/4f8ea39b66ddd5014ac8f923ed980584bd96290c) Thanks [@ARRIOLALEO](https://github.com/ARRIOLALEO)! - rollback setPriceTiers name change
92
+
93
+ ## 5.12.1
94
+
95
+ ### Patch Changes
96
+
97
+ - [#1869](https://github.com/commercetools/nodejs/pull/1869) [`7285a9fb`](https://github.com/commercetools/nodejs/commit/7285a9fbcbcfca6a9460e36ba7b58bb30f34fac6) Thanks [@ARRIOLALEO](https://github.com/ARRIOLALEO)! - Add support for StandalonePrice `setPriceTier`
98
+
99
+ ## 5.12.0
100
+
101
+ ### Minor Changes
102
+
103
+ - [#1863](https://github.com/commercetools/nodejs/pull/1863) [`7ed7a663`](https://github.com/commercetools/nodejs/commit/7ed7a663c1cb3aa87bfb4b4c2c008949a66a62e0) Thanks [@ragafus](https://github.com/ragafus)! - Add support for StandalonePrice `setKey`, `setValidFrom`, `setValidUntil`, `setValidFromAndUntil` and `changeActive` actions.
104
+
105
+ ## 5.11.0
106
+
107
+ ### Minor Changes
108
+
109
+ - [#1864](https://github.com/commercetools/nodejs/pull/1864) [`91f6b617`](https://github.com/commercetools/nodejs/commit/91f6b61794e7d66766097965e452e14c85e40f14) Thanks [@ARRIOLALEO](https://github.com/ARRIOLALEO)! - Add support for StandalonePrice `setPriceTiers`
110
+
111
+ ## 5.10.0
112
+
113
+ ### Minor Changes
114
+
115
+ - [#1856](https://github.com/commercetools/nodejs/pull/1856) [`9a3e3711`](https://github.com/commercetools/nodejs/commit/9a3e3711bf6594deafb5d54a9ce9e32450f9c4d6) Thanks [@qmateub](https://github.com/qmateub)! - orders sync-actions: support action on delivery items `setDeliveryItems`
116
+
117
+ ## 5.9.0
118
+
119
+ ### Minor Changes
120
+
121
+ - [#1853](https://github.com/commercetools/nodejs/pull/1853) [`4bb8f979`](https://github.com/commercetools/nodejs/commit/4bb8f979c317bbce1654ca0f1abc9b4717fdda0b) Thanks [@markus-azer](https://github.com/markus-azer)! - types sync-actions: support the following actions `changeInputHint`, `changeEnumValueLabel`, `changeLocalizedEnumValueLabel`.
122
+
123
+ ## 5.8.0
124
+
125
+ ### Minor Changes
126
+
127
+ - [#1852](https://github.com/commercetools/nodejs/pull/1852) [`94a376c8`](https://github.com/commercetools/nodejs/commit/94a376c89525b7cee58b710154ddf7cb146cd16c) Thanks [@markus-azer](https://github.com/markus-azer)! - types sync-actions: fix action structure for changeFieldDefinitionOrder
128
+ fix internal type sync error by adding optional chaining
129
+
130
+ ## 5.7.0
131
+
132
+ ### Minor Changes
133
+
134
+ - [#1850](https://github.com/commercetools/nodejs/pull/1850) [`330cd9a9`](https://github.com/commercetools/nodejs/commit/330cd9a9b4fca045d479d2d220d2a2a2b966b1f4) Thanks [@markus-azer](https://github.com/markus-azer)! - types sync-actions: fix action structure for changeLocalizedEnumValueOrder, changeEnumValueOrder
135
+
136
+ ## 5.6.0
137
+
138
+ ### Minor Changes
139
+
140
+ - [#1844](https://github.com/commercetools/nodejs/pull/1844) [`23f0529b`](https://github.com/commercetools/nodejs/commit/23f0529bbf359a11500dbf87bdc9e59cb759c89a) Thanks [@markus-azer](https://github.com/markus-azer)! - Add localizedName action to shipping methods
141
+
142
+ ## 5.5.0
143
+
144
+ ### Minor Changes
145
+
146
+ - [#1841](https://github.com/commercetools/nodejs/pull/1841) [`b90c7238`](https://github.com/commercetools/nodejs/commit/b90c7238f0d3d892e1066fd2883cff062b099e66) Thanks [@Rombelirk](https://github.com/Rombelirk)! - Add Custom Fields to Shipping Methods.
147
+
148
+ ## 5.4.1
149
+
150
+ ### Patch Changes
151
+
152
+ - [#1839](https://github.com/commercetools/nodejs/pull/1839) [`d6cadcbc`](https://github.com/commercetools/nodejs/commit/d6cadcbc4b850fa6f438b65c3b63b294a32a58ee) Thanks [@tdeekens](https://github.com/tdeekens)! - Fix failing to sync froozen arrays for prices
153
+
154
+ ## 5.4.0
155
+
156
+ ### Minor Changes
157
+
158
+ - [#1836](https://github.com/commercetools/nodejs/pull/1836) [`ad34d030`](https://github.com/commercetools/nodejs/commit/ad34d03041e7e6b8284da6224dc968fde537a85a) Thanks [@nicolasnieto92](https://github.com/nicolasnieto92)! - Add setAuthenticationMode sync action
159
+
160
+ ## 5.3.1
161
+
162
+ ### Patch Changes
163
+
164
+ - [#1818](https://github.com/commercetools/nodejs/pull/1818) [`856929e3`](https://github.com/commercetools/nodejs/commit/856929e3bc176021a9b52e1ff9c888e51c83cccd) Thanks [@qmateub](https://github.com/qmateub)! - fix(sync-actions/orders): adjust diff calculation of returnInfo items
165
+
166
+ ## 5.3.0
167
+
168
+ ### Minor Changes
169
+
170
+ - [#1820](https://github.com/commercetools/nodejs/pull/1820) [`c3964026`](https://github.com/commercetools/nodejs/commit/c3964026b401cb1c8ae8b581a3fcc4ea692ed3b4) Thanks [@danrleyt](https://github.com/danrleyt)! - Adding support to quote requests and staged quotes
171
+
172
+ ## 5.2.0
173
+
174
+ ### Minor Changes
175
+
176
+ - [`cad54c42`](https://github.com/commercetools/nodejs/commit/cad54c421e18464ae03fb283a30f2ba2f3f6e46a) Thanks [@qmateub](https://github.com/qmateub)! - feat(sync-actions): improve performance for large arrays comparisons"
177
+
178
+ ## 5.1.0
179
+
180
+ ### Minor Changes
181
+
182
+ - [#1803](https://github.com/commercetools/nodejs/pull/1803) [`823985ae`](https://github.com/commercetools/nodejs/commit/823985ae67465673c26f296b68681f255230d571) Thanks [@nicolasnieto92](https://github.com/nicolasnieto92)! - Add createSyncStandalonePrices export to index for supporting prices sync actions
183
+
184
+ ## 5.0.0
185
+
186
+ ### Major Changes
187
+
188
+ - [#1775](https://github.com/commercetools/nodejs/pull/1775) [`35669f30`](https://github.com/commercetools/nodejs/commit/35669f30dbc4b24d59ec3df3f38417b1f2a77837) Thanks [@ajimae](https://github.com/ajimae)! - Drop support for Node `v10` and `v12`. Supported versions now are `v14`, `v16` and `v18`.
189
+
190
+ ## 4.13.0
191
+
192
+ ### Minor Changes
193
+
194
+ - [#1798](https://github.com/commercetools/nodejs/pull/1798) [`850325d0`](https://github.com/commercetools/nodejs/commit/850325d08603764787c387b2341e4009d0c4f788) Thanks [@markus-azer](https://github.com/markus-azer)! - support standalone prices
195
+
196
+ ## 4.12.0
197
+
198
+ ### Minor Changes
199
+
200
+ - [#1796](https://github.com/commercetools/nodejs/pull/1796) [`7aaf91cd`](https://github.com/commercetools/nodejs/commit/7aaf91cdecb7c844943369fc137a5356becdba36) Thanks [@VineetKumarKushwaha](https://github.com/VineetKumarKushwaha)! - Fix custom types sync actions to detect addEnumValue action correctly
201
+
202
+ ## 4.11.0
203
+
204
+ ### Minor Changes
205
+
206
+ - [#1788](https://github.com/commercetools/nodejs/pull/1788) [`f1acfb67`](https://github.com/commercetools/nodejs/commit/f1acfb67708d8253f551481fd65097add48c6686) Thanks [@nicolasnieto92](https://github.com/nicolasnieto92)! - Add setPriceMode sync action for commercetools-importer project
207
+
208
+ ## 4.10.1
209
+
210
+ ### Patch Changes
211
+
212
+ - [#1770](https://github.com/commercetools/nodejs/pull/1770) [`381d1e1f`](https://github.com/commercetools/nodejs/commit/381d1e1f07cc2705962973e3a48934bf7884e309) Thanks [@mohib0306](https://github.com/mohib0306)! - Fix product selection's name update action. `setName` => `changeName`
213
+ Expose `createSyncProductSelections` from `sync-actions` package
214
+
215
+ ## 4.10.0
216
+
217
+ ### Minor Changes
218
+
219
+ - [#1767](https://github.com/commercetools/nodejs/pull/1767) [`1aef3423`](https://github.com/commercetools/nodejs/commit/1aef3423e96da7f5df20fd5f66ec29146cacee83) Thanks [@mohib0306](https://github.com/mohib0306)! - feat(sync-actions/product-selections): add sync action support for product selections
220
+
221
+ As product selections are available via the API, the sync-actions package is updated to support generating update actions for product selections.
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "node": ">=18"
7
7
  },
8
8
  "name": "@commercetools/sync-actions",
9
- "version": "7.0.0-rc.2",
9
+ "version": "7.0.0",
10
10
  "description": "Build API update actions for the commercetools platform.",
11
11
  "keywords": [
12
12
  "commercetools",
@@ -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: 'changeName', key: 'name' },
14
- { action: 'changeCartPredicate', key: 'cartPredicate' },
15
- { action: 'changeSortOrder', key: 'sortOrder' },
16
- { action: 'changeValue', key: 'value' },
17
- { action: 'changeRequiresDiscountCode', key: 'requiresDiscountCode' },
18
- { action: 'changeTarget', key: 'target' },
19
- { action: 'setDescription', key: 'description' },
20
- { action: 'setValidFrom', key: 'validFrom' },
21
- { action: 'setValidUntil', key: 'validUntil' },
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
- }
@@ -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 _cartDiscountsActions = require('./cart-discounts-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 createCartDiscountsMapActions(mapActionGroup) {
49
- return function doMapActions(diff, newObj, oldObj) {
50
- var allActions = []
51
-
52
- allActions.push(
53
- mapActionGroup('base', function() {
54
- return (0, _cartDiscountsActions.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 = createCartDiscountsMapActions(mapActionGroup)
65
- var buildActions = (0, _createBuildActions2.default)(
66
- diffpatcher.diff,
67
- doMapActions
68
- )
69
- return { buildActions: buildActions }
70
- }
package/lib/categories.js DELETED
@@ -1,106 +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 _categoryActions = require('./category-actions')
21
-
22
- var categoryActions = _interopRequireWildcard(_categoryActions)
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 = [
49
- 'base',
50
- 'references',
51
- 'meta',
52
- 'custom',
53
- ])
54
-
55
- function createCategoryMapActions(mapActionGroup) {
56
- return function doMapActions(diff, newObj, oldObj /* , options */) {
57
- var allActions = []
58
-
59
- allActions.push(
60
- mapActionGroup('base', function() {
61
- return categoryActions.actionsMapBase(diff, oldObj, newObj)
62
- })
63
- )
64
-
65
- allActions.push(
66
- mapActionGroup('references', function() {
67
- return categoryActions.actionsMapReferences(diff, oldObj, newObj)
68
- })
69
- )
70
-
71
- allActions.push(
72
- mapActionGroup('meta', function() {
73
- return categoryActions.actionsMapMeta(diff, oldObj, newObj)
74
- })
75
- )
76
-
77
- allActions.push(
78
- mapActionGroup('custom', function() {
79
- return categoryActions.actionsMapCustom(diff, oldObj, newObj)
80
- })
81
- )
82
-
83
- return (0, _lodash2.default)(allActions)
84
- }
85
- }
86
-
87
- exports.default = function(config) {
88
- // config contains information about which action groups
89
- // are white/black listed
90
-
91
- // createMapActionGroup returns function 'mapActionGroup' that takes params:
92
- // - action group name
93
- // - callback function that should return a list of actions that correspond
94
- // to the for the action group
95
-
96
- // this resulting function mapActionGroup will call the callback function
97
- // for whitelisted action groups and return the return value of the callback
98
- // It will return an empty array for blacklisted action groups
99
- var mapActionGroup = (0, _createMapActionGroup2.default)(config)
100
- var doMapActions = createCategoryMapActions(mapActionGroup)
101
- var buildActions = (0, _createBuildActions2.default)(
102
- diffpatcher.diff,
103
- doMapActions
104
- )
105
- return { buildActions: buildActions }
106
- }
@@ -1,117 +0,0 @@
1
- 'use strict'
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true,
5
- })
6
- exports.referenceActionsList = exports.metaActionsList = exports.baseActionsList = undefined
7
- exports.actionsMapBase = actionsMapBase
8
- exports.actionsMapReferences = actionsMapReferences
9
- exports.actionsMapMeta = actionsMapMeta
10
- exports.actionsMapCustom = actionsMapCustom
11
-
12
- var _commonActions = require('./utils/common-actions')
13
-
14
- var _diffpatcher = require('./utils/diffpatcher')
15
-
16
- var diffpatcher = _interopRequireWildcard(_diffpatcher)
17
-
18
- function _interopRequireWildcard(obj) {
19
- if (obj && obj.__esModule) {
20
- return obj
21
- } else {
22
- var newObj = {}
23
- if (obj != null) {
24
- for (var key in obj) {
25
- if (Object.prototype.hasOwnProperty.call(obj, key))
26
- newObj[key] = obj[key]
27
- }
28
- }
29
- newObj.default = obj
30
- return newObj
31
- }
32
- }
33
-
34
- var baseActionsList = (exports.baseActionsList = [
35
- { action: 'changeName', key: 'name' },
36
- { action: 'changeSlug', key: 'slug' },
37
- { action: 'setDescription', key: 'description' },
38
- { action: 'changeOrderHint', key: 'orderHint' },
39
- { action: 'setExternalId', key: 'externalId' },
40
- { action: 'setKey', key: 'key' },
41
- ])
42
-
43
- var metaActionsList = (exports.metaActionsList = [
44
- { action: 'setMetaTitle', key: 'metaTitle' },
45
- { action: 'setMetaKeywords', key: 'metaKeywords' },
46
- { action: 'setMetaDescription', key: 'metaDescription' },
47
- ])
48
-
49
- var referenceActionsList = (exports.referenceActionsList = [
50
- { action: 'changeParent', key: 'parent' },
51
- ])
52
-
53
- /**
54
- * SYNC FUNCTIONS
55
- */
56
-
57
- function actionsMapBase(diff, oldObj, newObj) {
58
- return (0, _commonActions.buildBaseAttributesActions)({
59
- actions: baseActionsList,
60
- diff: diff,
61
- oldObj: oldObj,
62
- newObj: newObj,
63
- })
64
- }
65
-
66
- function actionsMapReferences(diff, oldObj, newObj) {
67
- return (0, _commonActions.buildReferenceActions)({
68
- actions: referenceActionsList,
69
- diff: diff,
70
- oldObj: oldObj,
71
- newObj: newObj,
72
- })
73
- }
74
-
75
- function actionsMapMeta(diff, oldObj, newObj) {
76
- return (0, _commonActions.buildBaseAttributesActions)({
77
- actions: metaActionsList,
78
- diff: diff,
79
- oldObj: oldObj,
80
- newObj: newObj,
81
- })
82
- }
83
-
84
- function actionsMapCustom(diff, oldObj, newObj) {
85
- var actions = []
86
- if (!diff.custom) return actions
87
-
88
- if (diff.custom.type && diff.custom.type.id)
89
- actions.push({
90
- action: 'setCustomType',
91
- type: {
92
- typeId: 'type',
93
- id: Array.isArray(diff.custom.type.id)
94
- ? diffpatcher.getDeltaValue(diff.custom.type.id)
95
- : newObj.custom.type.id,
96
- },
97
- fields: Array.isArray(diff.custom.fields)
98
- ? diffpatcher.getDeltaValue(diff.custom.fields)
99
- : newObj.custom.fields,
100
- })
101
- else if (diff.custom.fields) {
102
- var customFieldsActions = Object.keys(diff.custom.fields).map(function(
103
- name
104
- ) {
105
- return {
106
- action: 'setCustomField',
107
- name: name,
108
- value: Array.isArray(diff.custom.fields[name])
109
- ? diffpatcher.getDeltaValue(diff.custom.fields[name])
110
- : newObj.custom.fields[name],
111
- }
112
- })
113
- actions = actions.concat(customFieldsActions)
114
- }
115
-
116
- return actions
117
- }
package/lib/channels.js DELETED
File without changes
@@ -1,125 +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
- exports.actionsMapAddresses = actionsMapAddresses
10
-
11
- var _commonActions = require('./utils/common-actions')
12
-
13
- var _createBuildArrayActions = require('./utils/create-build-array-actions')
14
-
15
- var _createBuildArrayActions2 = _interopRequireDefault(_createBuildArrayActions)
16
-
17
- function _interopRequireDefault(obj) {
18
- return obj && obj.__esModule ? obj : { default: obj }
19
- }
20
-
21
- function _defineProperty(obj, key, value) {
22
- if (key in obj) {
23
- Object.defineProperty(obj, key, {
24
- value: value,
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- })
29
- } else {
30
- obj[key] = value
31
- }
32
- return obj
33
- }
34
-
35
- var baseActionsList = (exports.baseActionsList = [
36
- { action: 'changeEmail', key: 'email' },
37
- { action: 'setFirstName', key: 'firstName' },
38
- { action: 'setLastName', key: 'lastName' },
39
- { action: 'setMiddleName', key: 'middleName' },
40
- { action: 'setTitle', key: 'title' },
41
- { action: 'setCustomerNumber', key: 'customerNumber' },
42
- { action: 'setExternalId', key: 'externalId' },
43
- { action: 'setCompanyName', key: 'companyName' },
44
- { action: 'setDateOfBirth', key: 'dateOfBirth' },
45
- { action: 'setVatId', key: 'vatId' },
46
- {
47
- action: 'setDefaultBillingAddress',
48
- key: 'defaultBillingAddressId',
49
- actionKey: 'addressId',
50
- },
51
- {
52
- action: 'setDefaultShippingAddress',
53
- key: 'defaultShippingAddressId',
54
- actionKey: 'addressId',
55
- },
56
- ])
57
-
58
- var referenceActionsList = (exports.referenceActionsList = [
59
- { action: 'setCustomerGroup', key: 'customerGroup' },
60
- ])
61
-
62
- /**
63
- * SYNC FUNCTIONS
64
- */
65
-
66
- function actionsMapBase(diff, oldObj, newObj) {
67
- return (0, _commonActions.buildBaseAttributesActions)({
68
- actions: baseActionsList,
69
- diff: diff,
70
- oldObj: oldObj,
71
- newObj: newObj,
72
- })
73
- }
74
-
75
- function actionsMapReferences(diff, oldObj, newObj) {
76
- return (0, _commonActions.buildReferenceActions)({
77
- actions: referenceActionsList,
78
- diff: diff,
79
- oldObj: oldObj,
80
- newObj: newObj,
81
- })
82
- }
83
-
84
- function actionsMapAddresses(diff, oldObj, newObj) {
85
- var _createBuildArrayActi
86
-
87
- var handler = (0, _createBuildArrayActions2.default)(
88
- 'addresses',
89
- ((_createBuildArrayActi = {}),
90
- _defineProperty(
91
- _createBuildArrayActi,
92
- _createBuildArrayActions.ADD_ACTIONS,
93
- function(newObject) {
94
- return {
95
- action: 'addAddress',
96
- address: newObject,
97
- }
98
- }
99
- ),
100
- _defineProperty(
101
- _createBuildArrayActi,
102
- _createBuildArrayActions.REMOVE_ACTIONS,
103
- function(objectToRemove) {
104
- return {
105
- action: 'removeAddress',
106
- addressId: objectToRemove.id,
107
- }
108
- }
109
- ),
110
- _defineProperty(
111
- _createBuildArrayActi,
112
- _createBuildArrayActions.CHANGE_ACTIONS,
113
- function(oldObject, updatedObject) {
114
- return {
115
- action: 'changeAddress',
116
- addressId: oldObject.id,
117
- address: updatedObject,
118
- }
119
- }
120
- ),
121
- _createBuildArrayActi)
122
- )
123
-
124
- return handler(diff, oldObj, newObj)
125
- }