@commercetools/history-sdk 3.1.0 → 3.2.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 CHANGED
@@ -1,5 +1,74 @@
1
1
  # @commercetools/history-sdk
2
2
 
3
+ ## 3.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#453](https://github.com/commercetools/commercetools-sdk-typescript/pull/453) [`a83e653`](https://github.com/commercetools/commercetools-sdk-typescript/commit/a83e653c986e50f31f71546edc721263d29990b5) Thanks [@ajimae](https://github.com/ajimae)! - - Remove all `querystring` dependency
8
+ - Add qs dependency to requiring package
9
+ - Refactor code to accommodate new implementation
10
+ - Updated dependencies [[`a83e653`](https://github.com/commercetools/commercetools-sdk-typescript/commit/a83e653c986e50f31f71546edc721263d29990b5)]:
11
+ - @commercetools/sdk-client-v2@2.1.6
12
+
13
+ ## 3.2.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#371](https://github.com/commercetools/commercetools-sdk-typescript/pull/371) [`f6bd1fe`](https://github.com/commercetools/commercetools-sdk-typescript/commit/f6bd1fe02773974d1e95a50a986e846698a95322) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update generated SDKs
18
+
19
+ #### Summary
20
+
21
+ - The get method of `ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDRequestBuilder` class now supports an optional `stage` property
22
+ - [Diff link](packages/platform-sdk/src/generated/client/product-projections/by-project-key-in-store-key-by-store-key-product-projections-by-id-request-builder.ts)
23
+ - The get method of `ByProjectKeyInStoreKeyByStoreKeyProductProjectionsKeyByKeyRequestBuilder` class now supports an optional `stage` property
24
+ - [Diff link](packages/platform-sdk/src/generated/client/product-projections/by-project-key-in-store-key-by-store-key-product-projections-key-by-key-request-builder.ts)
25
+
26
+ #### Snippet
27
+
28
+ ```diff
29
+ ...
30
+ queryArgs?: {
31
+ + staged?: boolean
32
+ priceCurrency?: string
33
+ priceCountry?: string
34
+ priceCustomerGroup?: string,
35
+ ...
36
+ }
37
+ ...
38
+ }) {}
39
+ ```
40
+
41
+ - The `get`, `post` and `delete` method query args. of `ByProjectKeyProductsByIDRequestBuilder` class now supports optional `localeProjection` property
42
+ - [Diff link](packages/platform-sdk/src/generated/client/products/by-project-key-products-by-id-request-builder.ts)
43
+ - The `get` and `post` method query args. of the `ByProjectKeyProductsRequestBuilder` class now supports an optional `localeProjection` property.
44
+ - [Diff link](packages/platform-sdk/src/generated/client/products/by-project-key-products-request-builder.ts)
45
+
46
+ ```diff
47
+ ...
48
+ queryArgs?: {
49
+ where?: string | string[]
50
+ priceCurrency?: string
51
+ priceCountry?: string
52
+ priceCustomerGroup?: string
53
+ priceChannel?: string
54
+ + localeProjection?: string | string[]
55
+ expand?: string | string[]
56
+ sort?: string | string[]
57
+ limit?: number
58
+ offset?: number
59
+ withTotal?: boolean
60
+ [key: string]: QueryParam
61
+ }
62
+ ...
63
+ ```
64
+
65
+ The complete changes can be found [here](changes.md)
66
+
67
+ ### Patch Changes
68
+
69
+ - Updated dependencies [[`98d2d7c`](https://github.com/commercetools/commercetools-sdk-typescript/commit/98d2d7ce2abad1d8eb3466f4f3df1b877f144920)]:
70
+ - @commercetools/sdk-client-v2@2.1.1
71
+
3
72
  ## 3.1.0
4
73
 
5
74
  ### Minor Changes
@@ -4,7 +4,24 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var querystring = require('querystring');
6
6
 
7
+ function _toPrimitive(input, hint) {
8
+ if (typeof input !== "object" || input === null) return input;
9
+ var prim = input[Symbol.toPrimitive];
10
+ if (prim !== undefined) {
11
+ var res = prim.call(input, hint || "default");
12
+ if (typeof res !== "object") return res;
13
+ throw new TypeError("@@toPrimitive must return a primitive value.");
14
+ }
15
+ return (hint === "string" ? String : Number)(input);
16
+ }
17
+
18
+ function _toPropertyKey(arg) {
19
+ var key = _toPrimitive(arg, "string");
20
+ return typeof key === "symbol" ? key : String(key);
21
+ }
22
+
7
23
  function _defineProperty(obj, key, value) {
24
+ key = _toPropertyKey(key);
8
25
  if (key in obj) {
9
26
  Object.defineProperty(obj, key, {
10
27
  value: value,
@@ -15,7 +32,6 @@ function _defineProperty(obj, key, value) {
15
32
  } else {
16
33
  obj[key] = value;
17
34
  }
18
-
19
35
  return obj;
20
36
  }
21
37
 
@@ -24,56 +40,45 @@ function _defineProperty(obj, key, value) {
24
40
  * Please don't change this file manually but run `rmf-codegen generate <raml_file_path> -o <output_path> -t typescript_client` to update it.
25
41
  * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
26
42
  */
27
-
28
43
  function isDefined(value) {
29
44
  return typeof value !== 'undefined' && value !== null;
30
45
  }
31
-
32
46
  function cleanObject(obj) {
33
47
  return Object.keys(obj).reduce((result, key) => {
34
48
  const value = obj[key];
35
-
36
49
  if (Array.isArray(value)) {
37
50
  const values = value.filter(isDefined);
38
-
39
51
  if (!values.length) {
40
52
  return result;
41
53
  }
42
-
43
- return { ...result,
54
+ return {
55
+ ...result,
44
56
  [key]: values
45
57
  };
46
58
  }
47
-
48
59
  if (isDefined(value)) {
49
- return { ...result,
60
+ return {
61
+ ...result,
50
62
  [key]: value
51
63
  };
52
64
  }
53
-
54
65
  return result;
55
66
  }, {});
56
67
  }
57
-
58
68
  function formatQueryString(variableMap) {
59
69
  const map = cleanObject(variableMap);
60
70
  const result = querystring.stringify(map);
61
-
62
71
  if (result === '') {
63
72
  return '';
64
73
  }
65
-
66
74
  return `?${result}`;
67
75
  }
68
-
69
76
  function buildRelativeUri(commonRequest) {
70
77
  const pathMap = commonRequest.pathVariables;
71
78
  var uri = commonRequest.uriTemplate;
72
-
73
79
  for (const param in pathMap) {
74
80
  uri = uri.replace(`{${param}}`, `${pathMap[param]}`);
75
81
  }
76
-
77
82
  const resQuery = formatQueryString(commonRequest.queryParams || {});
78
83
  return `${uri}${resQuery}`;
79
84
  }
@@ -81,22 +86,18 @@ function buildRelativeUri(commonRequest) {
81
86
  class ApiRequest {
82
87
  constructor(request, requestExecutor) {
83
88
  this.requestExecutor = requestExecutor;
84
-
85
89
  _defineProperty(this, "request", void 0);
86
-
87
- this.request = { ...request,
90
+ this.request = {
91
+ ...request,
88
92
  uri: buildRelativeUri(request)
89
93
  };
90
94
  }
91
-
92
95
  clientRequest() {
93
96
  return this.request;
94
97
  }
95
-
96
98
  execute() {
97
99
  return this.requestExecutor(this.request);
98
100
  }
99
-
100
101
  }
101
102
 
102
103
  /**
@@ -106,24 +107,22 @@ class ApiRequest {
106
107
  */
107
108
  /**
108
109
  **/
109
-
110
110
  class ByProjectKeyByResourceTypeByIDRequestBuilder {
111
111
  constructor(args) {
112
112
  this.args = args;
113
113
  }
114
-
115
114
  get(methodArgs) {
116
115
  return new ApiRequest({
117
116
  baseUri: this.args.baseUri,
118
117
  method: 'GET',
119
118
  uriTemplate: '/{projectKey}/{resourceType}/{ID}',
120
119
  pathVariables: this.args.pathArgs,
121
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
120
+ headers: {
121
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
122
122
  },
123
123
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
124
124
  }, this.args.executeRequest);
125
125
  }
126
-
127
126
  }
128
127
 
129
128
  /**
@@ -133,34 +132,32 @@ class ByProjectKeyByResourceTypeByIDRequestBuilder {
133
132
  */
134
133
  /**
135
134
  **/
136
-
137
135
  class ByProjectKeyByResourceTypeRequestBuilder {
138
136
  constructor(args) {
139
137
  this.args = args;
140
138
  }
141
-
142
139
  withIDValue(childPathArgs) {
143
140
  return new ByProjectKeyByResourceTypeByIDRequestBuilder({
144
- pathArgs: { ...this.args.pathArgs,
141
+ pathArgs: {
142
+ ...this.args.pathArgs,
145
143
  ...childPathArgs
146
144
  },
147
145
  executeRequest: this.args.executeRequest,
148
146
  baseUri: this.args.baseUri
149
147
  });
150
148
  }
151
-
152
149
  get(methodArgs) {
153
150
  return new ApiRequest({
154
151
  baseUri: this.args.baseUri,
155
152
  method: 'GET',
156
153
  uriTemplate: '/{projectKey}/{resourceType}',
157
154
  pathVariables: this.args.pathArgs,
158
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
155
+ headers: {
156
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
159
157
  },
160
158
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
161
159
  }, this.args.executeRequest);
162
160
  }
163
-
164
161
  }
165
162
 
166
163
  /**
@@ -170,55 +167,50 @@ class ByProjectKeyByResourceTypeRequestBuilder {
170
167
  */
171
168
  /**
172
169
  **/
173
-
174
170
  class ByProjectKeyRequestBuilder {
175
171
  constructor(args) {
176
172
  this.args = args;
177
173
  }
178
-
179
174
  withResourceTypeValue(childPathArgs) {
180
175
  return new ByProjectKeyByResourceTypeRequestBuilder({
181
- pathArgs: { ...this.args.pathArgs,
176
+ pathArgs: {
177
+ ...this.args.pathArgs,
182
178
  ...childPathArgs
183
179
  },
184
180
  executeRequest: this.args.executeRequest,
185
181
  baseUri: this.args.baseUri
186
182
  });
187
183
  }
188
-
189
184
  get(methodArgs) {
190
185
  return new ApiRequest({
191
186
  baseUri: this.args.baseUri,
192
187
  method: 'GET',
193
188
  uriTemplate: '/{projectKey}',
194
189
  pathVariables: this.args.pathArgs,
195
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
190
+ headers: {
191
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
196
192
  },
197
193
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
198
194
  }, this.args.executeRequest);
199
195
  }
200
-
201
196
  }
202
197
 
203
198
  class ApiRoot {
204
199
  constructor(args) {
205
200
  _defineProperty(this, "executeRequest", void 0);
206
-
207
201
  _defineProperty(this, "baseUri", void 0);
208
-
209
202
  this.executeRequest = args.executeRequest;
210
203
  this.baseUri = args.baseUri || 'https://history.europe-west1.gcp.commercetools.com';
211
204
  }
212
-
213
205
  withProjectKeyValue(childPathArgs) {
214
206
  return new ByProjectKeyRequestBuilder({
215
- pathArgs: { ...childPathArgs
207
+ pathArgs: {
208
+ ...childPathArgs
216
209
  },
217
210
  executeRequest: this.executeRequest,
218
211
  baseUri: this.baseUri
219
212
  });
220
213
  }
221
-
222
214
  }
223
215
 
224
216
  /**
@@ -226,19 +218,17 @@ class ApiRoot {
226
218
  * Please don't change this file manually but run `rmf-codegen generate <raml_file_path> -o <output_path> -t typescript_client` to update it.
227
219
  * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
228
220
  */
221
+
229
222
  const createExecutorFromMiddlewares = (executor, midds) => {
230
223
  if (!midds || midds.length == 0) {
231
224
  return executor;
232
225
  }
233
-
234
226
  const reduced = midds.reduce(reduceMiddleware);
235
227
  return middlewareToExecutor(reduced, executor);
236
228
  };
237
-
238
229
  function reduceMiddleware(middleware1, middleware2) {
239
230
  return (request, executor) => middleware1(request, middlewareToExecutor(middleware2, executor));
240
231
  }
241
-
242
232
  function middlewareToExecutor(middleware, executor) {
243
233
  return request => middleware(request, executor);
244
234
  }
@@ -1,6 +1,23 @@
1
1
  import { stringify } from 'querystring';
2
2
 
3
+ function _toPrimitive(input, hint) {
4
+ if (typeof input !== "object" || input === null) return input;
5
+ var prim = input[Symbol.toPrimitive];
6
+ if (prim !== undefined) {
7
+ var res = prim.call(input, hint || "default");
8
+ if (typeof res !== "object") return res;
9
+ throw new TypeError("@@toPrimitive must return a primitive value.");
10
+ }
11
+ return (hint === "string" ? String : Number)(input);
12
+ }
13
+
14
+ function _toPropertyKey(arg) {
15
+ var key = _toPrimitive(arg, "string");
16
+ return typeof key === "symbol" ? key : String(key);
17
+ }
18
+
3
19
  function _defineProperty(obj, key, value) {
20
+ key = _toPropertyKey(key);
4
21
  if (key in obj) {
5
22
  Object.defineProperty(obj, key, {
6
23
  value: value,
@@ -11,7 +28,6 @@ function _defineProperty(obj, key, value) {
11
28
  } else {
12
29
  obj[key] = value;
13
30
  }
14
-
15
31
  return obj;
16
32
  }
17
33
 
@@ -20,56 +36,45 @@ function _defineProperty(obj, key, value) {
20
36
  * Please don't change this file manually but run `rmf-codegen generate <raml_file_path> -o <output_path> -t typescript_client` to update it.
21
37
  * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
22
38
  */
23
-
24
39
  function isDefined(value) {
25
40
  return typeof value !== 'undefined' && value !== null;
26
41
  }
27
-
28
42
  function cleanObject(obj) {
29
43
  return Object.keys(obj).reduce((result, key) => {
30
44
  const value = obj[key];
31
-
32
45
  if (Array.isArray(value)) {
33
46
  const values = value.filter(isDefined);
34
-
35
47
  if (!values.length) {
36
48
  return result;
37
49
  }
38
-
39
- return { ...result,
50
+ return {
51
+ ...result,
40
52
  [key]: values
41
53
  };
42
54
  }
43
-
44
55
  if (isDefined(value)) {
45
- return { ...result,
56
+ return {
57
+ ...result,
46
58
  [key]: value
47
59
  };
48
60
  }
49
-
50
61
  return result;
51
62
  }, {});
52
63
  }
53
-
54
64
  function formatQueryString(variableMap) {
55
65
  const map = cleanObject(variableMap);
56
66
  const result = stringify(map);
57
-
58
67
  if (result === '') {
59
68
  return '';
60
69
  }
61
-
62
70
  return `?${result}`;
63
71
  }
64
-
65
72
  function buildRelativeUri(commonRequest) {
66
73
  const pathMap = commonRequest.pathVariables;
67
74
  var uri = commonRequest.uriTemplate;
68
-
69
75
  for (const param in pathMap) {
70
76
  uri = uri.replace(`{${param}}`, `${pathMap[param]}`);
71
77
  }
72
-
73
78
  const resQuery = formatQueryString(commonRequest.queryParams || {});
74
79
  return `${uri}${resQuery}`;
75
80
  }
@@ -77,22 +82,18 @@ function buildRelativeUri(commonRequest) {
77
82
  class ApiRequest {
78
83
  constructor(request, requestExecutor) {
79
84
  this.requestExecutor = requestExecutor;
80
-
81
85
  _defineProperty(this, "request", void 0);
82
-
83
- this.request = { ...request,
86
+ this.request = {
87
+ ...request,
84
88
  uri: buildRelativeUri(request)
85
89
  };
86
90
  }
87
-
88
91
  clientRequest() {
89
92
  return this.request;
90
93
  }
91
-
92
94
  execute() {
93
95
  return this.requestExecutor(this.request);
94
96
  }
95
-
96
97
  }
97
98
 
98
99
  /**
@@ -102,24 +103,22 @@ class ApiRequest {
102
103
  */
103
104
  /**
104
105
  **/
105
-
106
106
  class ByProjectKeyByResourceTypeByIDRequestBuilder {
107
107
  constructor(args) {
108
108
  this.args = args;
109
109
  }
110
-
111
110
  get(methodArgs) {
112
111
  return new ApiRequest({
113
112
  baseUri: this.args.baseUri,
114
113
  method: 'GET',
115
114
  uriTemplate: '/{projectKey}/{resourceType}/{ID}',
116
115
  pathVariables: this.args.pathArgs,
117
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
116
+ headers: {
117
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
118
118
  },
119
119
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
120
120
  }, this.args.executeRequest);
121
121
  }
122
-
123
122
  }
124
123
 
125
124
  /**
@@ -129,34 +128,32 @@ class ByProjectKeyByResourceTypeByIDRequestBuilder {
129
128
  */
130
129
  /**
131
130
  **/
132
-
133
131
  class ByProjectKeyByResourceTypeRequestBuilder {
134
132
  constructor(args) {
135
133
  this.args = args;
136
134
  }
137
-
138
135
  withIDValue(childPathArgs) {
139
136
  return new ByProjectKeyByResourceTypeByIDRequestBuilder({
140
- pathArgs: { ...this.args.pathArgs,
137
+ pathArgs: {
138
+ ...this.args.pathArgs,
141
139
  ...childPathArgs
142
140
  },
143
141
  executeRequest: this.args.executeRequest,
144
142
  baseUri: this.args.baseUri
145
143
  });
146
144
  }
147
-
148
145
  get(methodArgs) {
149
146
  return new ApiRequest({
150
147
  baseUri: this.args.baseUri,
151
148
  method: 'GET',
152
149
  uriTemplate: '/{projectKey}/{resourceType}',
153
150
  pathVariables: this.args.pathArgs,
154
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
151
+ headers: {
152
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
155
153
  },
156
154
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
157
155
  }, this.args.executeRequest);
158
156
  }
159
-
160
157
  }
161
158
 
162
159
  /**
@@ -166,55 +163,50 @@ class ByProjectKeyByResourceTypeRequestBuilder {
166
163
  */
167
164
  /**
168
165
  **/
169
-
170
166
  class ByProjectKeyRequestBuilder {
171
167
  constructor(args) {
172
168
  this.args = args;
173
169
  }
174
-
175
170
  withResourceTypeValue(childPathArgs) {
176
171
  return new ByProjectKeyByResourceTypeRequestBuilder({
177
- pathArgs: { ...this.args.pathArgs,
172
+ pathArgs: {
173
+ ...this.args.pathArgs,
178
174
  ...childPathArgs
179
175
  },
180
176
  executeRequest: this.args.executeRequest,
181
177
  baseUri: this.args.baseUri
182
178
  });
183
179
  }
184
-
185
180
  get(methodArgs) {
186
181
  return new ApiRequest({
187
182
  baseUri: this.args.baseUri,
188
183
  method: 'GET',
189
184
  uriTemplate: '/{projectKey}',
190
185
  pathVariables: this.args.pathArgs,
191
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
186
+ headers: {
187
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
192
188
  },
193
189
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
194
190
  }, this.args.executeRequest);
195
191
  }
196
-
197
192
  }
198
193
 
199
194
  class ApiRoot {
200
195
  constructor(args) {
201
196
  _defineProperty(this, "executeRequest", void 0);
202
-
203
197
  _defineProperty(this, "baseUri", void 0);
204
-
205
198
  this.executeRequest = args.executeRequest;
206
199
  this.baseUri = args.baseUri || 'https://history.europe-west1.gcp.commercetools.com';
207
200
  }
208
-
209
201
  withProjectKeyValue(childPathArgs) {
210
202
  return new ByProjectKeyRequestBuilder({
211
- pathArgs: { ...childPathArgs
203
+ pathArgs: {
204
+ ...childPathArgs
212
205
  },
213
206
  executeRequest: this.executeRequest,
214
207
  baseUri: this.baseUri
215
208
  });
216
209
  }
217
-
218
210
  }
219
211
 
220
212
  /**
@@ -222,19 +214,17 @@ class ApiRoot {
222
214
  * Please don't change this file manually but run `rmf-codegen generate <raml_file_path> -o <output_path> -t typescript_client` to update it.
223
215
  * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
224
216
  */
217
+
225
218
  const createExecutorFromMiddlewares = (executor, midds) => {
226
219
  if (!midds || midds.length == 0) {
227
220
  return executor;
228
221
  }
229
-
230
222
  const reduced = midds.reduce(reduceMiddleware);
231
223
  return middlewareToExecutor(reduced, executor);
232
224
  };
233
-
234
225
  function reduceMiddleware(middleware1, middleware2) {
235
226
  return (request, executor) => middleware1(request, middlewareToExecutor(middleware2, executor));
236
227
  }
237
-
238
228
  function middlewareToExecutor(middleware, executor) {
239
229
  return request => middleware(request, executor);
240
230
  }