@commercetools/history-sdk 3.0.0 → 3.2.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.
@@ -15,7 +15,6 @@ function _defineProperty(obj, key, value) {
15
15
  } else {
16
16
  obj[key] = value;
17
17
  }
18
-
19
18
  return obj;
20
19
  }
21
20
 
@@ -24,56 +23,45 @@ function _defineProperty(obj, key, value) {
24
23
  * 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
24
  * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
26
25
  */
27
-
28
26
  function isDefined(value) {
29
27
  return typeof value !== 'undefined' && value !== null;
30
28
  }
31
-
32
29
  function cleanObject(obj) {
33
30
  return Object.keys(obj).reduce((result, key) => {
34
31
  const value = obj[key];
35
-
36
32
  if (Array.isArray(value)) {
37
33
  const values = value.filter(isDefined);
38
-
39
34
  if (!values.length) {
40
35
  return result;
41
36
  }
42
-
43
- return { ...result,
37
+ return {
38
+ ...result,
44
39
  [key]: values
45
40
  };
46
41
  }
47
-
48
42
  if (isDefined(value)) {
49
- return { ...result,
43
+ return {
44
+ ...result,
50
45
  [key]: value
51
46
  };
52
47
  }
53
-
54
48
  return result;
55
49
  }, {});
56
50
  }
57
-
58
51
  function formatQueryString(variableMap) {
59
52
  const map = cleanObject(variableMap);
60
53
  const result = querystring.stringify(map);
61
-
62
54
  if (result === '') {
63
55
  return '';
64
56
  }
65
-
66
57
  return `?${result}`;
67
58
  }
68
-
69
59
  function buildRelativeUri(commonRequest) {
70
60
  const pathMap = commonRequest.pathVariables;
71
61
  var uri = commonRequest.uriTemplate;
72
-
73
62
  for (const param in pathMap) {
74
63
  uri = uri.replace(`{${param}}`, `${pathMap[param]}`);
75
64
  }
76
-
77
65
  const resQuery = formatQueryString(commonRequest.queryParams || {});
78
66
  return `${uri}${resQuery}`;
79
67
  }
@@ -81,22 +69,18 @@ function buildRelativeUri(commonRequest) {
81
69
  class ApiRequest {
82
70
  constructor(request, requestExecutor) {
83
71
  this.requestExecutor = requestExecutor;
84
-
85
72
  _defineProperty(this, "request", void 0);
86
-
87
- this.request = { ...request,
73
+ this.request = {
74
+ ...request,
88
75
  uri: buildRelativeUri(request)
89
76
  };
90
77
  }
91
-
92
78
  clientRequest() {
93
79
  return this.request;
94
80
  }
95
-
96
81
  execute() {
97
82
  return this.requestExecutor(this.request);
98
83
  }
99
-
100
84
  }
101
85
 
102
86
  /**
@@ -106,24 +90,22 @@ class ApiRequest {
106
90
  */
107
91
  /**
108
92
  **/
109
-
110
93
  class ByProjectKeyByResourceTypeByIDRequestBuilder {
111
94
  constructor(args) {
112
95
  this.args = args;
113
96
  }
114
-
115
97
  get(methodArgs) {
116
98
  return new ApiRequest({
117
99
  baseUri: this.args.baseUri,
118
100
  method: 'GET',
119
101
  uriTemplate: '/{projectKey}/{resourceType}/{ID}',
120
102
  pathVariables: this.args.pathArgs,
121
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
103
+ headers: {
104
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
122
105
  },
123
106
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
124
107
  }, this.args.executeRequest);
125
108
  }
126
-
127
109
  }
128
110
 
129
111
  /**
@@ -133,34 +115,32 @@ class ByProjectKeyByResourceTypeByIDRequestBuilder {
133
115
  */
134
116
  /**
135
117
  **/
136
-
137
118
  class ByProjectKeyByResourceTypeRequestBuilder {
138
119
  constructor(args) {
139
120
  this.args = args;
140
121
  }
141
-
142
122
  withIDValue(childPathArgs) {
143
123
  return new ByProjectKeyByResourceTypeByIDRequestBuilder({
144
- pathArgs: { ...this.args.pathArgs,
124
+ pathArgs: {
125
+ ...this.args.pathArgs,
145
126
  ...childPathArgs
146
127
  },
147
128
  executeRequest: this.args.executeRequest,
148
129
  baseUri: this.args.baseUri
149
130
  });
150
131
  }
151
-
152
132
  get(methodArgs) {
153
133
  return new ApiRequest({
154
134
  baseUri: this.args.baseUri,
155
135
  method: 'GET',
156
136
  uriTemplate: '/{projectKey}/{resourceType}',
157
137
  pathVariables: this.args.pathArgs,
158
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
138
+ headers: {
139
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
159
140
  },
160
141
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
161
142
  }, this.args.executeRequest);
162
143
  }
163
-
164
144
  }
165
145
 
166
146
  /**
@@ -170,55 +150,50 @@ class ByProjectKeyByResourceTypeRequestBuilder {
170
150
  */
171
151
  /**
172
152
  **/
173
-
174
153
  class ByProjectKeyRequestBuilder {
175
154
  constructor(args) {
176
155
  this.args = args;
177
156
  }
178
-
179
157
  withResourceTypeValue(childPathArgs) {
180
158
  return new ByProjectKeyByResourceTypeRequestBuilder({
181
- pathArgs: { ...this.args.pathArgs,
159
+ pathArgs: {
160
+ ...this.args.pathArgs,
182
161
  ...childPathArgs
183
162
  },
184
163
  executeRequest: this.args.executeRequest,
185
164
  baseUri: this.args.baseUri
186
165
  });
187
166
  }
188
-
189
167
  get(methodArgs) {
190
168
  return new ApiRequest({
191
169
  baseUri: this.args.baseUri,
192
170
  method: 'GET',
193
171
  uriTemplate: '/{projectKey}',
194
172
  pathVariables: this.args.pathArgs,
195
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
173
+ headers: {
174
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
196
175
  },
197
176
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
198
177
  }, this.args.executeRequest);
199
178
  }
200
-
201
179
  }
202
180
 
203
181
  class ApiRoot {
204
182
  constructor(args) {
205
183
  _defineProperty(this, "executeRequest", void 0);
206
-
207
184
  _defineProperty(this, "baseUri", void 0);
208
-
209
185
  this.executeRequest = args.executeRequest;
210
186
  this.baseUri = args.baseUri || 'https://history.europe-west1.gcp.commercetools.com';
211
187
  }
212
-
213
188
  withProjectKeyValue(childPathArgs) {
214
189
  return new ByProjectKeyRequestBuilder({
215
- pathArgs: { ...childPathArgs
190
+ pathArgs: {
191
+ ...childPathArgs
216
192
  },
217
193
  executeRequest: this.executeRequest,
218
194
  baseUri: this.baseUri
219
195
  });
220
196
  }
221
-
222
197
  }
223
198
 
224
199
  /**
@@ -226,19 +201,17 @@ class ApiRoot {
226
201
  * 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
202
  * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
228
203
  */
204
+
229
205
  const createExecutorFromMiddlewares = (executor, midds) => {
230
206
  if (!midds || midds.length == 0) {
231
207
  return executor;
232
208
  }
233
-
234
209
  const reduced = midds.reduce(reduceMiddleware);
235
210
  return middlewareToExecutor(reduced, executor);
236
211
  };
237
-
238
212
  function reduceMiddleware(middleware1, middleware2) {
239
213
  return (request, executor) => middleware1(request, middlewareToExecutor(middleware2, executor));
240
214
  }
241
-
242
215
  function middlewareToExecutor(middleware, executor) {
243
216
  return request => middleware(request, executor);
244
217
  }
@@ -15,7 +15,6 @@ function _defineProperty(obj, key, value) {
15
15
  } else {
16
16
  obj[key] = value;
17
17
  }
18
-
19
18
  return obj;
20
19
  }
21
20
 
@@ -24,56 +23,45 @@ function _defineProperty(obj, key, value) {
24
23
  * 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
24
  * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
26
25
  */
27
-
28
26
  function isDefined(value) {
29
27
  return typeof value !== 'undefined' && value !== null;
30
28
  }
31
-
32
29
  function cleanObject(obj) {
33
30
  return Object.keys(obj).reduce((result, key) => {
34
31
  const value = obj[key];
35
-
36
32
  if (Array.isArray(value)) {
37
33
  const values = value.filter(isDefined);
38
-
39
34
  if (!values.length) {
40
35
  return result;
41
36
  }
42
-
43
- return { ...result,
37
+ return {
38
+ ...result,
44
39
  [key]: values
45
40
  };
46
41
  }
47
-
48
42
  if (isDefined(value)) {
49
- return { ...result,
43
+ return {
44
+ ...result,
50
45
  [key]: value
51
46
  };
52
47
  }
53
-
54
48
  return result;
55
49
  }, {});
56
50
  }
57
-
58
51
  function formatQueryString(variableMap) {
59
52
  const map = cleanObject(variableMap);
60
53
  const result = querystring.stringify(map);
61
-
62
54
  if (result === '') {
63
55
  return '';
64
56
  }
65
-
66
57
  return `?${result}`;
67
58
  }
68
-
69
59
  function buildRelativeUri(commonRequest) {
70
60
  const pathMap = commonRequest.pathVariables;
71
61
  var uri = commonRequest.uriTemplate;
72
-
73
62
  for (const param in pathMap) {
74
63
  uri = uri.replace(`{${param}}`, `${pathMap[param]}`);
75
64
  }
76
-
77
65
  const resQuery = formatQueryString(commonRequest.queryParams || {});
78
66
  return `${uri}${resQuery}`;
79
67
  }
@@ -81,22 +69,18 @@ function buildRelativeUri(commonRequest) {
81
69
  class ApiRequest {
82
70
  constructor(request, requestExecutor) {
83
71
  this.requestExecutor = requestExecutor;
84
-
85
72
  _defineProperty(this, "request", void 0);
86
-
87
- this.request = { ...request,
73
+ this.request = {
74
+ ...request,
88
75
  uri: buildRelativeUri(request)
89
76
  };
90
77
  }
91
-
92
78
  clientRequest() {
93
79
  return this.request;
94
80
  }
95
-
96
81
  execute() {
97
82
  return this.requestExecutor(this.request);
98
83
  }
99
-
100
84
  }
101
85
 
102
86
  /**
@@ -106,24 +90,22 @@ class ApiRequest {
106
90
  */
107
91
  /**
108
92
  **/
109
-
110
93
  class ByProjectKeyByResourceTypeByIDRequestBuilder {
111
94
  constructor(args) {
112
95
  this.args = args;
113
96
  }
114
-
115
97
  get(methodArgs) {
116
98
  return new ApiRequest({
117
99
  baseUri: this.args.baseUri,
118
100
  method: 'GET',
119
101
  uriTemplate: '/{projectKey}/{resourceType}/{ID}',
120
102
  pathVariables: this.args.pathArgs,
121
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
103
+ headers: {
104
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
122
105
  },
123
106
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
124
107
  }, this.args.executeRequest);
125
108
  }
126
-
127
109
  }
128
110
 
129
111
  /**
@@ -133,34 +115,32 @@ class ByProjectKeyByResourceTypeByIDRequestBuilder {
133
115
  */
134
116
  /**
135
117
  **/
136
-
137
118
  class ByProjectKeyByResourceTypeRequestBuilder {
138
119
  constructor(args) {
139
120
  this.args = args;
140
121
  }
141
-
142
122
  withIDValue(childPathArgs) {
143
123
  return new ByProjectKeyByResourceTypeByIDRequestBuilder({
144
- pathArgs: { ...this.args.pathArgs,
124
+ pathArgs: {
125
+ ...this.args.pathArgs,
145
126
  ...childPathArgs
146
127
  },
147
128
  executeRequest: this.args.executeRequest,
148
129
  baseUri: this.args.baseUri
149
130
  });
150
131
  }
151
-
152
132
  get(methodArgs) {
153
133
  return new ApiRequest({
154
134
  baseUri: this.args.baseUri,
155
135
  method: 'GET',
156
136
  uriTemplate: '/{projectKey}/{resourceType}',
157
137
  pathVariables: this.args.pathArgs,
158
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
138
+ headers: {
139
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
159
140
  },
160
141
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
161
142
  }, this.args.executeRequest);
162
143
  }
163
-
164
144
  }
165
145
 
166
146
  /**
@@ -170,55 +150,50 @@ class ByProjectKeyByResourceTypeRequestBuilder {
170
150
  */
171
151
  /**
172
152
  **/
173
-
174
153
  class ByProjectKeyRequestBuilder {
175
154
  constructor(args) {
176
155
  this.args = args;
177
156
  }
178
-
179
157
  withResourceTypeValue(childPathArgs) {
180
158
  return new ByProjectKeyByResourceTypeRequestBuilder({
181
- pathArgs: { ...this.args.pathArgs,
159
+ pathArgs: {
160
+ ...this.args.pathArgs,
182
161
  ...childPathArgs
183
162
  },
184
163
  executeRequest: this.args.executeRequest,
185
164
  baseUri: this.args.baseUri
186
165
  });
187
166
  }
188
-
189
167
  get(methodArgs) {
190
168
  return new ApiRequest({
191
169
  baseUri: this.args.baseUri,
192
170
  method: 'GET',
193
171
  uriTemplate: '/{projectKey}',
194
172
  pathVariables: this.args.pathArgs,
195
- headers: { ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
173
+ headers: {
174
+ ...(methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.headers)
196
175
  },
197
176
  queryParams: methodArgs === null || methodArgs === void 0 ? void 0 : methodArgs.queryArgs
198
177
  }, this.args.executeRequest);
199
178
  }
200
-
201
179
  }
202
180
 
203
181
  class ApiRoot {
204
182
  constructor(args) {
205
183
  _defineProperty(this, "executeRequest", void 0);
206
-
207
184
  _defineProperty(this, "baseUri", void 0);
208
-
209
185
  this.executeRequest = args.executeRequest;
210
186
  this.baseUri = args.baseUri || 'https://history.europe-west1.gcp.commercetools.com';
211
187
  }
212
-
213
188
  withProjectKeyValue(childPathArgs) {
214
189
  return new ByProjectKeyRequestBuilder({
215
- pathArgs: { ...childPathArgs
190
+ pathArgs: {
191
+ ...childPathArgs
216
192
  },
217
193
  executeRequest: this.executeRequest,
218
194
  baseUri: this.baseUri
219
195
  });
220
196
  }
221
-
222
197
  }
223
198
 
224
199
  /**
@@ -226,19 +201,17 @@ class ApiRoot {
226
201
  * 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
202
  * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
228
203
  */
204
+
229
205
  const createExecutorFromMiddlewares = (executor, midds) => {
230
206
  if (!midds || midds.length == 0) {
231
207
  return executor;
232
208
  }
233
-
234
209
  const reduced = midds.reduce(reduceMiddleware);
235
210
  return middlewareToExecutor(reduced, executor);
236
211
  };
237
-
238
212
  function reduceMiddleware(middleware1, middleware2) {
239
213
  return (request, executor) => middleware1(request, middlewareToExecutor(middleware2, executor));
240
214
  }
241
-
242
215
  function middlewareToExecutor(middleware, executor) {
243
216
  return request => middleware(request, executor);
244
217
  }