Skip to content

Commit 7f81d60

Browse files
committed
feat(migrate): make compile
1 parent 22cf175 commit 7f81d60

File tree

104 files changed

+19411
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+19411
-1
lines changed

packages/sync-actions/CHANGELOG.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# @commercetools/sync-actions
2+
3+
## 5.15.0
4+
5+
### Minor Changes
6+
7+
- [#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].
8+
9+
## 5.14.0
10+
11+
### Minor Changes
12+
13+
- [#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.
14+
15+
## 5.13.0
16+
17+
### Minor Changes
18+
19+
- [#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
20+
21+
## 5.12.2
22+
23+
### Patch Changes
24+
25+
- [#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
26+
27+
## 5.12.1
28+
29+
### Patch Changes
30+
31+
- [#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`
32+
33+
## 5.12.0
34+
35+
### Minor Changes
36+
37+
- [#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.
38+
39+
## 5.11.0
40+
41+
### Minor Changes
42+
43+
- [#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`
44+
45+
## 5.10.0
46+
47+
### Minor Changes
48+
49+
- [#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`
50+
51+
## 5.9.0
52+
53+
### Minor Changes
54+
55+
- [#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`.
56+
57+
## 5.8.0
58+
59+
### Minor Changes
60+
61+
- [#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
62+
fix internal type sync error by adding optional chaining
63+
64+
## 5.7.0
65+
66+
### Minor Changes
67+
68+
- [#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
69+
70+
## 5.6.0
71+
72+
### Minor Changes
73+
74+
- [#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
75+
76+
## 5.5.0
77+
78+
### Minor Changes
79+
80+
- [#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.
81+
82+
## 5.4.1
83+
84+
### Patch Changes
85+
86+
- [#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
87+
88+
## 5.4.0
89+
90+
### Minor Changes
91+
92+
- [#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
93+
94+
## 5.3.1
95+
96+
### Patch Changes
97+
98+
- [#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
99+
100+
## 5.3.0
101+
102+
### Minor Changes
103+
104+
- [#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
105+
106+
## 5.2.0
107+
108+
### Minor Changes
109+
110+
- [`cad54c42`](https://github.com/commercetools/nodejs/commit/cad54c421e18464ae03fb283a30f2ba2f3f6e46a) Thanks [@qmateub](https://github.com/qmateub)! - feat(sync-actions): improve performance for large arrays comparisons"
111+
112+
## 5.1.0
113+
114+
### Minor Changes
115+
116+
- [#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
117+
118+
## 5.0.0
119+
120+
### Major Changes
121+
122+
- [#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`.
123+
124+
## 4.13.0
125+
126+
### Minor Changes
127+
128+
- [#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
129+
130+
## 4.12.0
131+
132+
### Minor Changes
133+
134+
- [#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
135+
136+
## 4.11.0
137+
138+
### Minor Changes
139+
140+
- [#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
141+
142+
## 4.10.1
143+
144+
### Patch Changes
145+
146+
- [#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`
147+
Expose `createSyncProductSelections` from `sync-actions` package
148+
149+
## 4.10.0
150+
151+
### Minor Changes
152+
153+
- [#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
154+
155+
As product selections are available via the API, the sync-actions package is updated to support generating update actions for product selections.

packages/sync-actions/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# commercetools-sync-actions
2+
3+
Construct API update actions, for usage with `@commercetools/sdk-client`.
4+
5+
https://commercetools.github.io/nodejs/sdk/api/syncActions.html
6+
7+
## Install
8+
9+
```bash
10+
npm install --save @commercetools/sync-actions
11+
```

packages/sync-actions/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@commercetools/sync-actions",
3+
"version": "1.0.0",
4+
"engines": {
5+
"node": ">=14"
6+
},
7+
"description": "Build API update actions for the commercetools platform.",
8+
"keywords": ["commercetools", "sync", "actions"],
9+
"homepage": "https://commercetools.github.io/nodejs/",
10+
"license": "MIT",
11+
"directories": {
12+
"lib": "lib",
13+
"test": "test"
14+
},
15+
"publishConfig": {
16+
"access": "public"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/commercetools/commercetools-sdk-typescript.git"
21+
},
22+
"bugs": {
23+
"url": "https://github.com/commercetools/commercetools-sdk-typescript/issues"
24+
},
25+
"dependencies": {
26+
"fast-equals": "^2.0.0",
27+
"jsondiffpatch": "^0.4.0",
28+
"lodash.flatten": "^4.4.0",
29+
"lodash.foreach": "^4.5.0",
30+
"lodash.intersection": "^4.4.0",
31+
"lodash.isequal": "^4.5.0",
32+
"lodash.isnil": "^4.0.0",
33+
"lodash.shuffle": "^4.2.0",
34+
"lodash.sortby": "^4.7.0",
35+
"lodash.uniqwith": "^4.5.0",
36+
"lodash.without": "^4.4.0"
37+
},
38+
"files": ["dist", "CHANGELOG.md"],
39+
"author": "Nicola Molinari <nicola.molinari@commercetools.com> (https://github.com/emmenko)",
40+
"main": "dist/commercetools-sync-actions.cjs.js",
41+
"module": "dist/commercetools-sync-actions.esm.js",
42+
"browser": {
43+
"./dist/commercetools-sync-actions.cjs.js": "./dist/commercetools-sync-actions.browser.cjs.js",
44+
"./dist/commercetools-sync-actions.esm.js": "./dist/commercetools-sync-actions.browser.esm.js"
45+
},
46+
"scripts": {
47+
"organize_imports": "find src -type f -name '*.ts' | xargs organize-imports-cli",
48+
"postbuild": "yarn organize_imports",
49+
"post_process_generate": "yarn organize_imports"
50+
}
51+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import createBuildArrayActions, {
2+
ADD_ACTIONS,
3+
REMOVE_ACTIONS,
4+
CHANGE_ACTIONS,
5+
} from './utils/create-build-array-actions'
6+
7+
function toAssetIdentifier(asset) {
8+
const assetIdentifier = asset.id
9+
? { assetId: asset.id }
10+
: { assetKey: asset.key }
11+
return assetIdentifier
12+
}
13+
14+
export default function actionsMapAssets(diff, oldObj, newObj) {
15+
const handler = createBuildArrayActions('assets', {
16+
[ADD_ACTIONS]: (newAsset) => ({
17+
action: 'addAsset',
18+
asset: newAsset,
19+
}),
20+
[REMOVE_ACTIONS]: (oldAsset) => ({
21+
action: 'removeAsset',
22+
...toAssetIdentifier(oldAsset),
23+
}),
24+
[CHANGE_ACTIONS]: (oldAsset, newAsset) =>
25+
// here we could use more atomic update actions (e.g. changeAssetName)
26+
// but for now we use the simpler approach to first remove and then
27+
// re-add the asset - which reduces the code complexity
28+
[
29+
{
30+
action: 'removeAsset',
31+
...toAssetIdentifier(oldAsset),
32+
},
33+
{
34+
action: 'addAsset',
35+
asset: newAsset,
36+
},
37+
],
38+
})
39+
40+
return handler(diff, oldObj, newObj)
41+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { buildBaseAttributesActions } from './utils/common-actions'
2+
import createBuildArrayActions, {
3+
ADD_ACTIONS,
4+
REMOVE_ACTIONS,
5+
CHANGE_ACTIONS,
6+
} from './utils/create-build-array-actions'
7+
8+
const hasAttribute = (attributes, newValue) =>
9+
attributes.some((attribute) => attribute.key === newValue.key)
10+
11+
export const baseActionsList = [
12+
{ action: 'changeName', key: 'name' },
13+
{ action: 'setKey', key: 'key' },
14+
{ action: 'setDescription', key: 'description' },
15+
]
16+
17+
export function actionsMapBase(
18+
diff,
19+
oldObj,
20+
newObj,
21+
config: { shouldOmitEmptyString?: boolean } = {}
22+
) {
23+
return buildBaseAttributesActions({
24+
actions: baseActionsList,
25+
diff,
26+
oldObj,
27+
newObj,
28+
shouldOmitEmptyString: config.shouldOmitEmptyString,
29+
})
30+
}
31+
32+
export function actionsMapAttributes(diff, oldObj, newObj) {
33+
const handler = createBuildArrayActions('attributes', {
34+
[ADD_ACTIONS]: (newAttribute) => ({
35+
action: 'addAttribute',
36+
attribute: newAttribute,
37+
}),
38+
[REMOVE_ACTIONS]: (oldAttribute) => {
39+
// We only add the action if the attribute is not included in the new object.
40+
return !hasAttribute(newObj.attributes, oldAttribute)
41+
? {
42+
action: 'removeAttribute',
43+
attribute: oldAttribute,
44+
}
45+
: null
46+
},
47+
[CHANGE_ACTIONS]: (oldAttribute, newAttribute) => {
48+
const result = []
49+
// We only remove the attribute in case that the oldAttribute is not
50+
// included in the new object
51+
if (!hasAttribute(newObj.attributes, oldAttribute))
52+
result.push({
53+
action: 'removeAttribute',
54+
attribute: oldAttribute,
55+
})
56+
57+
// We only add the attribute in case that the newAttribute was not
58+
// included in the old object
59+
if (!hasAttribute(oldObj.attributes, newAttribute))
60+
result.push({
61+
action: 'addAttribute',
62+
attribute: newAttribute,
63+
})
64+
65+
return result
66+
},
67+
})
68+
69+
return handler(diff, oldObj, newObj)
70+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* @flow */
2+
import flatten from 'lodash.flatten'
3+
import type {
4+
SyncAction,
5+
ActionGroup,
6+
UpdateAction,
7+
SyncActionConfig,
8+
} from '@commercetools/sdk-client-v2'
9+
import * as attributeGroupsActions from './attribute-groups-actions'
10+
import createBuildActions from './utils/create-build-actions'
11+
import createMapActionGroup from './utils/create-map-action-group'
12+
import * as diffpatcher from './utils/diffpatcher'
13+
14+
function createAttributeGroupsMapActions(
15+
mapActionGroup: (
16+
type: string,
17+
fn: () => Array<UpdateAction>
18+
) => Array<UpdateAction>,
19+
syncActionConfig?: SyncActionConfig
20+
): (diff: any, newObj: any, oldObj: any) => Array<UpdateAction> {
21+
return function doMapActions(
22+
diff: any,
23+
newObj: any,
24+
oldObj: any
25+
): Array<UpdateAction> {
26+
const allActions = []
27+
allActions.push(
28+
mapActionGroup(
29+
'base',
30+
(): Array<UpdateAction> =>
31+
attributeGroupsActions.actionsMapBase(
32+
diff,
33+
oldObj,
34+
newObj,
35+
syncActionConfig
36+
)
37+
)
38+
)
39+
allActions.push(
40+
flatten(
41+
mapActionGroup(
42+
'attributes',
43+
(): Array<UpdateAction> =>
44+
attributeGroupsActions.actionsMapAttributes(diff, oldObj, newObj)
45+
)
46+
)
47+
)
48+
return flatten(allActions)
49+
}
50+
}
51+
52+
export default (
53+
actionGroupList?: Array<ActionGroup>,
54+
syncActionConfig?: SyncActionConfig
55+
): SyncAction => {
56+
const mapActionGroup = createMapActionGroup(actionGroupList)
57+
const doMapActions = createAttributeGroupsMapActions(
58+
mapActionGroup,
59+
syncActionConfig
60+
)
61+
const buildActions = createBuildActions(diffpatcher.diff, doMapActions)
62+
return { buildActions }
63+
}

0 commit comments

Comments
 (0)