@commercetools/sync-actions 7.3.1 → 8.0.0-alpha.1
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 +265 -0
- package/dist/commercetools-sync-actions.cjs.js +43947 -5
- package/dist/commercetools-sync-actions.esm.js +27861 -3864
- package/dist/commercetools-sync-actions.umd.js +1 -0
- package/dist/commercetools-sync-actions.umd.min.js +1 -0
- package/dist/declarations/api-extensions/api-extensions-actions.d.ts +9 -0
- package/dist/declarations/api-extensions/api-extensions.d.ts +4 -0
- package/dist/declarations/assets/assets-actions.d.ts +2 -0
- package/dist/declarations/attribute-groups/attribute-groups-actions.d.ts +10 -0
- package/dist/declarations/attribute-groups/attribute-groups.d.ts +3 -0
- package/dist/declarations/business-units/business-units-actions.d.ts +10 -0
- package/dist/declarations/business-units/business-units.d.ts +3 -0
- package/dist/declarations/cart-discounts/cart-discounts-actions.d.ts +9 -0
- package/dist/declarations/cart-discounts/cart-discounts.d.ts +4 -0
- package/dist/declarations/categories/categories.d.ts +4 -0
- package/dist/declarations/categories/category-actions.d.ts +18 -0
- package/dist/declarations/channels/channels-actions.d.ts +6 -0
- package/dist/declarations/channels/channels.d.ts +4 -0
- package/dist/declarations/customer-group/customer-group-actions.d.ts +6 -0
- package/dist/declarations/customer-group/customer-group.d.ts +4 -0
- package/dist/declarations/customers/customer-actions.d.ts +25 -0
- package/dist/declarations/customers/customers.d.ts +4 -0
- package/dist/declarations/discount-codes/discount-codes-actions.d.ts +6 -0
- package/dist/declarations/discount-codes/discount-codes.d.ts +6 -0
- package/dist/declarations/index.d.ts +26 -0
- package/dist/declarations/inventories/inventories.d.ts +4 -0
- package/dist/declarations/inventories/inventory-actions.d.ts +13 -0
- package/dist/declarations/orders/order-actions.d.ts +16 -0
- package/dist/declarations/orders/orders.d.ts +4 -0
- package/dist/declarations/prices/prices-actions.d.ts +6 -0
- package/dist/declarations/prices/prices.d.ts +4 -0
- package/dist/declarations/product-discounts/product-discounts-actions.d.ts +9 -0
- package/dist/declarations/product-discounts/product-discounts.d.ts +4 -0
- package/dist/declarations/product-selections/product-selections-actions.d.ts +9 -0
- package/dist/declarations/product-selections/product-selections.d.ts +4 -0
- package/dist/declarations/product-types/product-types-actions.d.ts +11 -0
- package/dist/declarations/product-types/product-types.d.ts +4 -0
- package/dist/declarations/products/product-actions.d.ts +38 -0
- package/dist/declarations/products/products.d.ts +4 -0
- package/dist/declarations/projects/projects-actions.d.ts +17 -0
- package/dist/declarations/projects/projects.d.ts +4 -0
- package/dist/declarations/quotes/quotes-actions.d.ts +6 -0
- package/dist/declarations/quotes/quotes.d.ts +5 -0
- package/dist/declarations/quotes-requests/quote-requests-actions.d.ts +6 -0
- package/dist/declarations/quotes-requests/quote-requests.d.ts +4 -0
- package/dist/declarations/recurring-orders/recurring-orders-actions.d.ts +16 -0
- package/dist/declarations/recurring-orders/recurring-orders.d.ts +5 -0
- package/dist/declarations/shipping-methods/shipping-methods-actions.d.ts +10 -0
- package/dist/declarations/shipping-methods/shipping-methods.d.ts +4 -0
- package/dist/declarations/staged-quotes/staged-quotes-actions.d.ts +6 -0
- package/dist/declarations/staged-quotes/staged-quotes.d.ts +5 -0
- package/dist/declarations/states/state-actions.d.ts +7 -0
- package/dist/declarations/states/states.d.ts +4 -0
- package/dist/declarations/stores/stores-actions.d.ts +6 -0
- package/dist/declarations/stores/stores.d.ts +4 -0
- package/dist/declarations/subscriptions/subscriptions-actions.d.ts +6 -0
- package/dist/declarations/subscriptions/subscriptions.d.ts +4 -0
- package/dist/declarations/tax-categories/tax-categories-actions.d.ts +7 -0
- package/dist/declarations/tax-categories/tax-categories.d.ts +4 -0
- package/dist/declarations/types/types-actions.d.ts +7 -0
- package/dist/declarations/types/types.d.ts +5 -0
- package/dist/declarations/utils/action-map-custom.d.ts +5 -0
- package/dist/declarations/utils/clone.d.ts +6 -0
- package/dist/declarations/utils/combine-validity-actions.d.ts +1 -0
- package/dist/declarations/utils/common-actions.d.ts +46 -0
- package/dist/declarations/utils/copy-empty-array-props.d.ts +9 -0
- package/dist/declarations/utils/create-build-actions.d.ts +4 -0
- package/dist/declarations/utils/create-build-array-actions.d.ts +15 -0
- package/dist/declarations/utils/create-map-action-group.d.ts +2 -0
- package/dist/declarations/utils/diffpatcher.d.ts +11 -0
- package/dist/declarations/utils/extract-matching-pairs.d.ts +4 -0
- package/dist/declarations/utils/find-matching-pairs.d.ts +2 -0
- package/dist/declarations/utils/remove-typename.d.ts +3 -0
- package/dist/declarations/utils/types.d.ts +31 -0
- package/dist/declarations/zones/zones-actions.d.ts +7 -0
- package/dist/declarations/zones/zones.d.ts +4 -0
- package/package.json +20 -29
- package/LICENSE +0 -21
- package/dist/commercetools-sync-actions.cjs.dev.js +0 -3997
- package/dist/commercetools-sync-actions.cjs.prod.js +0 -3997
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @function copyEmptyArrayProps
|
|
3
|
+
* @description Create new key with empty array value on `newobj` for the arrays exist on `oldObj` and doesnt exist on `newobj`
|
|
4
|
+
* One use case is to easily compare two object without generating this error `Cannot read property '0' of undefined`
|
|
5
|
+
* @param {Object} oldObj
|
|
6
|
+
* @param {Object} newObj
|
|
7
|
+
* @returns {Array} Ordered Array [oldObj, newObj]
|
|
8
|
+
*/
|
|
9
|
+
export default function copyEmptyArrayProps(oldObj?: {}, newObj?: {}): {}[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Delta, SyncActionConfig, UpdateAction } from './types';
|
|
2
|
+
type Preprocessor<T> = (before: T, now: T) => Array<T>;
|
|
3
|
+
export default function createBuildActions<S extends object, T extends UpdateAction>(differ: (processedBefore: S, processedNow: S) => Delta, doMapActions: (diffed: Delta, processedNow: S, processedBefore: S, options: SyncActionConfig) => Array<T>, onBeforeDiff?: Preprocessor<S>, buildActionsConfig?: SyncActionConfig): (now: S, before: S, options?: SyncActionConfig) => T[];
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Delta, UpdateAction } from './types';
|
|
2
|
+
export declare const ADD_ACTIONS = "create";
|
|
3
|
+
export declare const REMOVE_ACTIONS = "remove";
|
|
4
|
+
export declare const CHANGE_ACTIONS = "change";
|
|
5
|
+
/**
|
|
6
|
+
* Generate + configure a function to build actions for nested objects
|
|
7
|
+
* @param {string} key key of the attribute containing the array of
|
|
8
|
+
* nested objects
|
|
9
|
+
* @param {object} config configuration object that can contain the keys
|
|
10
|
+
* [ADD_ACTIONS, REMOVE_ACTIONS, CHANGE_ACTIONS], each of
|
|
11
|
+
* which is a function. The function should accept the old + new arrays and
|
|
12
|
+
* return an action object.
|
|
13
|
+
* @return {Array} The generated array of actions
|
|
14
|
+
*/
|
|
15
|
+
export default function createBuildArrayActions(key: string, config: object): <S, T extends UpdateAction>(diff: Delta, oldObj: S, newObj: S) => T[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Delta } from './types';
|
|
2
|
+
type U = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
url: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function objectHash<O extends U, I extends string | number>(obj: O, index: I): string;
|
|
8
|
+
export declare function diff<T>(oldObj: T, newObj: T): Delta;
|
|
9
|
+
export declare function patch<T>(obj: T, delta: Delta): any;
|
|
10
|
+
export declare function getDeltaValue<T extends object = object>(arr: Array<number> | unknown, originalObject?: T): T;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Delta as DiffDelta } from 'jsondiffpatch/dist/jsondiffpatch.cjs';
|
|
2
|
+
export * from '@commercetools/platform-sdk';
|
|
3
|
+
export type Delta = DiffDelta | undefined;
|
|
4
|
+
export type SyncActionConfig = {
|
|
5
|
+
shouldOmitEmptyString?: boolean;
|
|
6
|
+
shouldUnsetOmittedProperties?: boolean;
|
|
7
|
+
shouldPreventUnsettingRequiredFields?: boolean;
|
|
8
|
+
sameForAllAttributeNames?: unknown[];
|
|
9
|
+
enableDiscounted?: boolean;
|
|
10
|
+
withHints?: boolean;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
export type SyncAction<R extends object | undefined, S extends UpdateAction | unknown, T extends object = SyncActionConfig> = {
|
|
14
|
+
buildActions: (now: DeepPartial<R>, before: DeepPartial<R>, config?: T) => Array<S>;
|
|
15
|
+
};
|
|
16
|
+
export type DeepPartial<T> = T extends object ? {
|
|
17
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
18
|
+
} : T;
|
|
19
|
+
export type UpdateAction = {
|
|
20
|
+
action: string | never;
|
|
21
|
+
key?: string;
|
|
22
|
+
actionKey?: string;
|
|
23
|
+
roles?: Array<unknown>;
|
|
24
|
+
value?: string;
|
|
25
|
+
};
|
|
26
|
+
export type ActionGroup = {
|
|
27
|
+
type: string;
|
|
28
|
+
group: 'ignore' | 'allow' | string;
|
|
29
|
+
};
|
|
30
|
+
export type MapActionGroup = (type: string, cb: () => Array<UpdateAction>) => Array<UpdateAction>;
|
|
31
|
+
export type MapAction<T> = (mapActionGroup: MapActionGroup, syncActionConfig?: SyncActionConfig) => (diff: Delta, newObj: T, oldObj: T, config?: SyncActionConfig) => Array<UpdateAction>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Delta, SyncActionConfig, UpdateAction, Zone } from '../utils/types';
|
|
2
|
+
export declare const baseActionsList: Array<UpdateAction>;
|
|
3
|
+
export declare function actionsMapBase(diff: Delta, oldObj: Zone, newObj: Zone, config?: SyncActionConfig): {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
action: string;
|
|
6
|
+
}[];
|
|
7
|
+
export declare function actionsMapLocations(diff: Delta, oldObj: Zone, newObj: Zone): UpdateAction[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SyncAction, ActionGroup, SyncActionConfig, Zone, ZoneUpdateAction } from '../utils/types';
|
|
2
|
+
export declare const actionGroups: string[];
|
|
3
|
+
declare const _default: (actionGroupList?: Array<ActionGroup>, syncActionConfig?: SyncActionConfig) => SyncAction<Zone, ZoneUpdateAction>;
|
|
4
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
+
"name": "@commercetools/sync-actions",
|
|
3
|
+
"version": "8.0.0-alpha.1",
|
|
2
4
|
"publishConfig": {
|
|
3
5
|
"access": "public"
|
|
4
6
|
},
|
|
5
7
|
"engines": {
|
|
6
8
|
"node": ">=18"
|
|
7
9
|
},
|
|
8
|
-
"name": "@commercetools/sync-actions",
|
|
9
|
-
"version": "7.3.1",
|
|
10
10
|
"description": "Build API update actions for the commercetools platform.",
|
|
11
|
-
"keywords": [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
],
|
|
16
|
-
"homepage": "https://commercetools.github.io/nodejs/",
|
|
17
|
-
"bugs": "https://github.com/commercetools/nodejs/issues",
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"author": "Nicola Molinari <nicola.molinari@commercetools.com> (https://github.com/emmenko)",
|
|
11
|
+
"keywords": ["commercetools", "sync", "actions"],
|
|
12
|
+
"homepage": "https://commercetools.github.io/nodejs",
|
|
13
|
+
"bugs": "https://github.com/commercetools/typescript-dev-utilities/issues",
|
|
14
|
+
"author": "",
|
|
20
15
|
"main": "dist/commercetools-sync-actions.cjs.js",
|
|
21
16
|
"module": "dist/commercetools-sync-actions.esm.js",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"entrypoints": [
|
|
25
|
-
"./index.js"
|
|
26
|
-
],
|
|
27
|
-
"umdName": "commercetoolsSyncActions"
|
|
28
|
-
},
|
|
17
|
+
"types": "dist/declarations/index.d.ts",
|
|
18
|
+
"license": "MIT",
|
|
29
19
|
"repository": {
|
|
30
20
|
"type": "git",
|
|
31
|
-
"url": "https://github.com/commercetools/
|
|
21
|
+
"url": "https://github.com/commercetools/typescript-dev-utilities.git"
|
|
22
|
+
},
|
|
23
|
+
"files": ["dist", "CHANGELOG.md"],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"clean": "rm -rf dist",
|
|
26
|
+
"build": "yarn clean;tsc && node esbuild.mjs",
|
|
27
|
+
"prepublishOnly": "yarn build",
|
|
28
|
+
"test": "jest --runInBand"
|
|
32
29
|
},
|
|
33
|
-
"files": [
|
|
34
|
-
"dist",
|
|
35
|
-
"lib"
|
|
36
|
-
],
|
|
37
30
|
"dependencies": {
|
|
31
|
+
"@commercetools/platform-sdk": "latest",
|
|
32
|
+
"esbuild": "^0.25.4",
|
|
38
33
|
"fast-equals": "^2.0.0",
|
|
34
|
+
"jest": "^29.7.0",
|
|
39
35
|
"jsondiffpatch": "0.5.0",
|
|
40
|
-
"lodash.flatten": "^4.4.0",
|
|
41
36
|
"lodash.foreach": "^4.5.0",
|
|
42
37
|
"lodash.intersection": "^4.4.0",
|
|
43
38
|
"lodash.isequal": "^4.5.0",
|
|
@@ -46,9 +41,5 @@
|
|
|
46
41
|
"lodash.sortby": "^4.7.0",
|
|
47
42
|
"lodash.uniqwith": "^4.5.0",
|
|
48
43
|
"lodash.without": "^4.4.0"
|
|
49
|
-
},
|
|
50
|
-
"scripts": {
|
|
51
|
-
"prebuild": "rimraf dist/**",
|
|
52
|
-
"build": "exit 0;"
|
|
53
44
|
}
|
|
54
|
-
}
|
|
45
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 commercetools GmbH
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|