@commercetools-frontend/sdk 22.38.2 → 22.38.3

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.
@@ -165,6 +165,10 @@ var index = /*#__PURE__*/Object.freeze({
165
165
 
166
166
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
167
167
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
168
+ const defaultProps = {
169
+ actionCreatorArgs: [],
170
+ shouldRefetch: (prevArgs, nextArgs) => !fastEquals.deepEqual(prevArgs, nextArgs)
171
+ };
168
172
  let SdkGet = /*#__PURE__*/function (_Component) {
169
173
  _inherits(SdkGet, _Component);
170
174
  var _super = _createSuper(SdkGet);
@@ -183,9 +187,7 @@ let SdkGet = /*#__PURE__*/function (_Component) {
183
187
  isWaitingForCompletionOfFirstRequest: true,
184
188
  requestsInFlight: 0,
185
189
  result: undefined,
186
- error: undefined,
187
- actionCreatorArgs: [],
188
- shouldRefetch: (prevArgs, nextArgs) => !fastEquals.deepEqual(prevArgs, nextArgs)
190
+ error: undefined
189
191
  };
190
192
  _this.isComponentMounted = false;
191
193
  _this.changeRequestsInFlight = delta => {
@@ -200,7 +202,7 @@ let SdkGet = /*#__PURE__*/function (_Component) {
200
202
  onSuccess = _ref.onSuccess,
201
203
  onError = _ref.onError;
202
204
  _this.changeRequestsInFlight(1);
203
- return dispatch(actionCreator(...actionCreatorArgs)).then(result => {
205
+ return dispatch(actionCreator(...(actionCreatorArgs ?? defaultProps.actionCreatorArgs))).then(result => {
204
206
  _this.changeRequestsInFlight(-1);
205
207
  if (_this.isComponentMounted) _this.setState({
206
208
  error: undefined,
@@ -251,13 +253,16 @@ let SdkGet = /*#__PURE__*/function (_Component) {
251
253
  }, {
252
254
  key: "componentDidUpdate",
253
255
  value: function componentDidUpdate(prevProps) {
254
- if (this.props.shouldRefetch(prevProps.actionCreatorArgs, this.props.actionCreatorArgs)) this.fetch({
255
- dispatch: this.props.dispatch,
256
- actionCreator: this.props.actionCreator,
257
- actionCreatorArgs: this.props.actionCreatorArgs,
258
- onSuccess: this.props.onSuccess,
259
- onError: this.props.onError
260
- });
256
+ const shouldRefetch = this.props.shouldRefetch ?? defaultProps.shouldRefetch;
257
+ if (shouldRefetch(prevProps.actionCreatorArgs ?? defaultProps.actionCreatorArgs, this.props.actionCreatorArgs ?? defaultProps.actionCreatorArgs)) {
258
+ this.fetch({
259
+ dispatch: this.props.dispatch,
260
+ actionCreator: this.props.actionCreator,
261
+ actionCreatorArgs: this.props.actionCreatorArgs,
262
+ onSuccess: this.props.onSuccess,
263
+ onError: this.props.onError
264
+ });
265
+ }
261
266
  }
262
267
  }, {
263
268
  key: "componentWillUnmount",
@@ -284,8 +289,8 @@ SdkGet.errorHandler = error => {
284
289
  SdkGet.propTypes = process.env.NODE_ENV !== "production" ? {
285
290
  dispatch: _pt__default["default"].func.isRequired,
286
291
  actionCreator: _pt__default["default"].func.isRequired,
287
- actionCreatorArgs: _pt__default["default"].arrayOf(_pt__default["default"].any).isRequired,
288
- shouldRefetch: _pt__default["default"].func.isRequired,
292
+ actionCreatorArgs: _pt__default["default"].arrayOf(_pt__default["default"].any),
293
+ shouldRefetch: _pt__default["default"].func,
289
294
  onSuccess: _pt__default["default"].func,
290
295
  onError: _pt__default["default"].func,
291
296
  render: _pt__default["default"].func.isRequired
@@ -296,7 +301,7 @@ const mapDispatchToProps = dispatch => ({
296
301
  var SdkGet$1 = reactRedux.connect(null, mapDispatchToProps)(SdkGet);
297
302
 
298
303
  // NOTE: This string will be replaced on build time with the package version.
299
- var version = "22.38.2";
304
+ var version = "22.38.3";
300
305
 
301
306
  /* eslint-disable no-console */
302
307
 
@@ -164,6 +164,10 @@ var index = /*#__PURE__*/Object.freeze({
164
164
 
165
165
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
166
166
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
167
+ const defaultProps = {
168
+ actionCreatorArgs: [],
169
+ shouldRefetch: (prevArgs, nextArgs) => !fastEquals.deepEqual(prevArgs, nextArgs)
170
+ };
167
171
  let SdkGet = /*#__PURE__*/function (_Component) {
168
172
  _inherits(SdkGet, _Component);
169
173
  var _super = _createSuper(SdkGet);
@@ -182,9 +186,7 @@ let SdkGet = /*#__PURE__*/function (_Component) {
182
186
  isWaitingForCompletionOfFirstRequest: true,
183
187
  requestsInFlight: 0,
184
188
  result: undefined,
185
- error: undefined,
186
- actionCreatorArgs: [],
187
- shouldRefetch: (prevArgs, nextArgs) => !fastEquals.deepEqual(prevArgs, nextArgs)
189
+ error: undefined
188
190
  };
189
191
  _this.isComponentMounted = false;
190
192
  _this.changeRequestsInFlight = delta => {
@@ -199,7 +201,7 @@ let SdkGet = /*#__PURE__*/function (_Component) {
199
201
  onSuccess = _ref.onSuccess,
200
202
  onError = _ref.onError;
201
203
  _this.changeRequestsInFlight(1);
202
- return dispatch(actionCreator(...actionCreatorArgs)).then(result => {
204
+ return dispatch(actionCreator(...(actionCreatorArgs ?? defaultProps.actionCreatorArgs))).then(result => {
203
205
  _this.changeRequestsInFlight(-1);
204
206
  if (_this.isComponentMounted) _this.setState({
205
207
  error: undefined,
@@ -250,13 +252,16 @@ let SdkGet = /*#__PURE__*/function (_Component) {
250
252
  }, {
251
253
  key: "componentDidUpdate",
252
254
  value: function componentDidUpdate(prevProps) {
253
- if (this.props.shouldRefetch(prevProps.actionCreatorArgs, this.props.actionCreatorArgs)) this.fetch({
254
- dispatch: this.props.dispatch,
255
- actionCreator: this.props.actionCreator,
256
- actionCreatorArgs: this.props.actionCreatorArgs,
257
- onSuccess: this.props.onSuccess,
258
- onError: this.props.onError
259
- });
255
+ const shouldRefetch = this.props.shouldRefetch ?? defaultProps.shouldRefetch;
256
+ if (shouldRefetch(prevProps.actionCreatorArgs ?? defaultProps.actionCreatorArgs, this.props.actionCreatorArgs ?? defaultProps.actionCreatorArgs)) {
257
+ this.fetch({
258
+ dispatch: this.props.dispatch,
259
+ actionCreator: this.props.actionCreator,
260
+ actionCreatorArgs: this.props.actionCreatorArgs,
261
+ onSuccess: this.props.onSuccess,
262
+ onError: this.props.onError
263
+ });
264
+ }
260
265
  }
261
266
  }, {
262
267
  key: "componentWillUnmount",
@@ -287,7 +292,7 @@ const mapDispatchToProps = dispatch => ({
287
292
  var SdkGet$1 = reactRedux.connect(null, mapDispatchToProps)(SdkGet);
288
293
 
289
294
  // NOTE: This string will be replaced on build time with the package version.
290
- var version = "22.38.2";
295
+ var version = "22.38.3";
291
296
 
292
297
  const mcHostnameRegex = /^mc(-(\d){4,})?\.(.*)$/;
293
298
  const mcPreviewHostnameRegex = /^.*\.mc-preview\.(.*)$/;
@@ -142,6 +142,10 @@ var index = /*#__PURE__*/Object.freeze({
142
142
 
143
143
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
144
144
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
145
+ const defaultProps = {
146
+ actionCreatorArgs: [],
147
+ shouldRefetch: (prevArgs, nextArgs) => !deepEqual(prevArgs, nextArgs)
148
+ };
145
149
  let SdkGet = /*#__PURE__*/function (_Component) {
146
150
  _inherits(SdkGet, _Component);
147
151
  var _super = _createSuper(SdkGet);
@@ -160,9 +164,7 @@ let SdkGet = /*#__PURE__*/function (_Component) {
160
164
  isWaitingForCompletionOfFirstRequest: true,
161
165
  requestsInFlight: 0,
162
166
  result: undefined,
163
- error: undefined,
164
- actionCreatorArgs: [],
165
- shouldRefetch: (prevArgs, nextArgs) => !deepEqual(prevArgs, nextArgs)
167
+ error: undefined
166
168
  };
167
169
  _this.isComponentMounted = false;
168
170
  _this.changeRequestsInFlight = delta => {
@@ -177,7 +179,7 @@ let SdkGet = /*#__PURE__*/function (_Component) {
177
179
  onSuccess = _ref.onSuccess,
178
180
  onError = _ref.onError;
179
181
  _this.changeRequestsInFlight(1);
180
- return dispatch(actionCreator(...actionCreatorArgs)).then(result => {
182
+ return dispatch(actionCreator(...(actionCreatorArgs ?? defaultProps.actionCreatorArgs))).then(result => {
181
183
  _this.changeRequestsInFlight(-1);
182
184
  if (_this.isComponentMounted) _this.setState({
183
185
  error: undefined,
@@ -228,13 +230,16 @@ let SdkGet = /*#__PURE__*/function (_Component) {
228
230
  }, {
229
231
  key: "componentDidUpdate",
230
232
  value: function componentDidUpdate(prevProps) {
231
- if (this.props.shouldRefetch(prevProps.actionCreatorArgs, this.props.actionCreatorArgs)) this.fetch({
232
- dispatch: this.props.dispatch,
233
- actionCreator: this.props.actionCreator,
234
- actionCreatorArgs: this.props.actionCreatorArgs,
235
- onSuccess: this.props.onSuccess,
236
- onError: this.props.onError
237
- });
233
+ const shouldRefetch = this.props.shouldRefetch ?? defaultProps.shouldRefetch;
234
+ if (shouldRefetch(prevProps.actionCreatorArgs ?? defaultProps.actionCreatorArgs, this.props.actionCreatorArgs ?? defaultProps.actionCreatorArgs)) {
235
+ this.fetch({
236
+ dispatch: this.props.dispatch,
237
+ actionCreator: this.props.actionCreator,
238
+ actionCreatorArgs: this.props.actionCreatorArgs,
239
+ onSuccess: this.props.onSuccess,
240
+ onError: this.props.onError
241
+ });
242
+ }
238
243
  }
239
244
  }, {
240
245
  key: "componentWillUnmount",
@@ -261,8 +266,8 @@ SdkGet.errorHandler = error => {
261
266
  SdkGet.propTypes = process.env.NODE_ENV !== "production" ? {
262
267
  dispatch: _pt.func.isRequired,
263
268
  actionCreator: _pt.func.isRequired,
264
- actionCreatorArgs: _pt.arrayOf(_pt.any).isRequired,
265
- shouldRefetch: _pt.func.isRequired,
269
+ actionCreatorArgs: _pt.arrayOf(_pt.any),
270
+ shouldRefetch: _pt.func,
266
271
  onSuccess: _pt.func,
267
272
  onError: _pt.func,
268
273
  render: _pt.func.isRequired
@@ -273,7 +278,7 @@ const mapDispatchToProps = dispatch => ({
273
278
  var SdkGet$1 = connect(null, mapDispatchToProps)(SdkGet);
274
279
 
275
280
  // NOTE: This string will be replaced on build time with the package version.
276
- var version = "22.38.2";
281
+ var version = "22.38.3";
277
282
 
278
283
  /* eslint-disable no-console */
279
284
 
@@ -21,8 +21,8 @@ type DispatchProps = {
21
21
  };
22
22
  type OwnProps = {
23
23
  actionCreator: (...args: TActionCreatorArgs) => TSdkAction;
24
- actionCreatorArgs: TActionCreatorArgs;
25
- shouldRefetch: (prevArgs: TActionCreatorArgs, nextArgs: TActionCreatorArgs) => boolean;
24
+ actionCreatorArgs?: TActionCreatorArgs;
25
+ shouldRefetch?: (prevArgs: TActionCreatorArgs, nextArgs: TActionCreatorArgs) => boolean;
26
26
  onSuccess?: (result: SuccessResult['body']) => void;
27
27
  onError?: (error: TSdkError) => void;
28
28
  render: (options: TRenderOptions) => JSX.Element;
@@ -37,8 +37,6 @@ export declare class SdkGet extends Component<Props, State> {
37
37
  requestsInFlight: number;
38
38
  result: undefined;
39
39
  error: undefined;
40
- actionCreatorArgs: never[];
41
- shouldRefetch: (prevArgs: TActionCreatorArgs, nextArgs: TActionCreatorArgs) => boolean;
42
40
  };
43
41
  isComponentMounted: boolean;
44
42
  changeRequestsInFlight: (delta: number) => void;
@@ -10,8 +10,8 @@ declare const Sdk: {
10
10
  dispatch: (action: import("./types").TSdkAction) => Promise<import("@commercetools/sdk-client").Json>;
11
11
  } & {
12
12
  actionCreator: (...args: unknown[]) => import("./types").TSdkAction;
13
- actionCreatorArgs: unknown[];
14
- shouldRefetch: (prevArgs: unknown[], nextArgs: unknown[]) => boolean;
13
+ actionCreatorArgs?: unknown[] | undefined;
14
+ shouldRefetch?: ((prevArgs: unknown[], nextArgs: unknown[]) => boolean) | undefined;
15
15
  onSuccess?: ((result: import("@commercetools/sdk-client").Json) => void) | undefined;
16
16
  onError?: ((error: Error | import("@commercetools/sdk-client").HttpErrorType) => void) | undefined;
17
17
  render: (options: {
@@ -22,8 +22,8 @@ declare const Sdk: {
22
22
  }) => JSX.Element;
23
23
  }, "dispatch"> & {
24
24
  actionCreator: (...args: unknown[]) => import("./types").TSdkAction;
25
- actionCreatorArgs: unknown[];
26
- shouldRefetch: (prevArgs: unknown[], nextArgs: unknown[]) => boolean;
25
+ actionCreatorArgs?: unknown[] | undefined;
26
+ shouldRefetch?: ((prevArgs: unknown[], nextArgs: unknown[]) => boolean) | undefined;
27
27
  onSuccess?: ((result: import("@commercetools/sdk-client").Json) => void) | undefined;
28
28
  onError?: ((error: Error | import("@commercetools/sdk-client").HttpErrorType) => void) | undefined;
29
29
  render: (options: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools-frontend/sdk",
3
- "version": "22.38.2",
3
+ "version": "22.38.3",
4
4
  "description": "Tools for declarative fetching",
5
5
  "bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@babel/runtime": "^7.22.15",
39
39
  "@babel/runtime-corejs3": "^7.22.15",
40
- "@commercetools-frontend/constants": "22.38.2",
40
+ "@commercetools-frontend/constants": "22.38.3",
41
41
  "@commercetools/api-request-builder": "6.0.0",
42
42
  "@commercetools/http-user-agent": "3.0.0",
43
43
  "@commercetools/sdk-client": "3.0.0",