@commercetools/history-sdk 1.20.0 → 2.0.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.
- package/CHANGELOG.md +6 -0
- package/README.md +110 -20
- package/dist/commercetools-history-sdk.browser.cjs.js +3 -1
- package/dist/commercetools-history-sdk.browser.esm.js +3 -1
- package/dist/commercetools-history-sdk.cjs.dev.js +3 -1
- package/dist/commercetools-history-sdk.cjs.prod.js +3 -1
- package/dist/commercetools-history-sdk.esm.js +3 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @commercetools/history-sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#154](https://github.com/commercetools/commercetools-sdk-typescript/pull/154) [`25f1dea`](https://github.com/commercetools/commercetools-sdk-typescript/commit/25f1dea23eccdfdda01e9144ec2afe968ead58f2) Thanks [@jherey](https://github.com/jherey)! - This is the first major release of the sdk client
|
|
8
|
+
|
|
3
9
|
## 1.20.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,36 +1,126 @@
|
|
|
1
|
-
# Typescript SDK for commercetools Audit log APIs.
|
|
1
|
+
# Typescript SDK for commercetools Audit log (history) APIs.
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Usage examples
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
npm install --save @commercetools/history-sdk
|
|
7
|
-
```
|
|
5
|
+
### Browser environment
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
```html
|
|
8
|
+
<script src="https://unpkg.com/@commercetools/sdk-client-v2@latest/dist/commercetools-sdk-client-v2.umd.js"></script>
|
|
9
|
+
<script src="https://unpkg.com/@commercetools/history-sdk@latest/dist/commercetools-history-sdk.umd.js"></script>
|
|
10
|
+
```
|
|
10
11
|
|
|
11
12
|
```html
|
|
12
|
-
<script src="https://unpkg.com/browse/@commercetools/history-sdk/dist/history-sdk.umd.js"></script>
|
|
13
13
|
<script>
|
|
14
|
-
// global:
|
|
14
|
+
// global: @commercetools/sdk-client-v2
|
|
15
|
+
// global: @commercetools/history-sdk
|
|
16
|
+
;(function () {
|
|
17
|
+
// We can now access the sdk-client-v2 and history-sdk object as:
|
|
18
|
+
// const { ClientBuilder } = this['@commercetools/sdk-client-v2']
|
|
19
|
+
// const { createApiBuilderFromCtpClient } = this['@commercetools/history-sdk']
|
|
20
|
+
// or
|
|
21
|
+
// const { ClientBuilder } = window['@commercetools/sdk-client-v2']
|
|
22
|
+
// const { createApiBuilderFromCtpClient } = window['@commercetools/history-sdk']
|
|
23
|
+
})()
|
|
15
24
|
</script>
|
|
16
25
|
```
|
|
17
26
|
|
|
18
|
-
###
|
|
27
|
+
### Node environment
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install --save @commercetools/sdk-client-v2
|
|
31
|
+
npm install --save @commercetools/history-sdk
|
|
32
|
+
```
|
|
19
33
|
|
|
20
34
|
```ts
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
const {
|
|
36
|
+
ClientBuilder,
|
|
37
|
+
createAuthForClientCredentialsFlow,
|
|
38
|
+
createHttpClient,
|
|
39
|
+
} = require('@commercetools/sdk-client-v2')
|
|
40
|
+
const { createApiBuilderFromCtpClient } = require('@commercetools/history-sdk')
|
|
41
|
+
const fetch = require('node-fetch')
|
|
42
|
+
|
|
43
|
+
const projectKey = 'mc-project-key'
|
|
44
|
+
const authMiddlewareOptions = {
|
|
45
|
+
host: 'https://auth.europe-west1.gcp.commercetools.com',
|
|
46
|
+
projectKey,
|
|
47
|
+
credentials: {
|
|
48
|
+
clientId: 'mc-client-id',
|
|
49
|
+
clientSecret: 'mc-client-secrets',
|
|
50
|
+
},
|
|
51
|
+
oauthUri: 'https://auth.europe-west1.gcp.commercetools.com',
|
|
52
|
+
scopes: [`manage_project:${projectKey}`],
|
|
53
|
+
fetch,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const httpMiddlewareOptions = {
|
|
57
|
+
host: 'https://history.europe-west1.gcp.commercetools.com',
|
|
58
|
+
fetch,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const client = new ClientBuilder()
|
|
62
|
+
.withProjectKey(projectKey)
|
|
63
|
+
.withMiddleware(createAuthForClientCredentialsFlow(authMiddlewareOptions))
|
|
64
|
+
.withMiddleware(createHttpClient(httpMiddlewareOptions))
|
|
65
|
+
.withUserAgentMiddleware()
|
|
66
|
+
.build()
|
|
67
|
+
|
|
68
|
+
// or
|
|
69
|
+
const client = new ClientBuilder()
|
|
70
|
+
.withProjectKey(projectKey)
|
|
71
|
+
.withClientCredentialsFlow(authMiddlewareOptions)
|
|
72
|
+
.withHttpMiddleware(httpMiddlewareOptions)
|
|
73
|
+
.withUserAgentMiddleware()
|
|
74
|
+
.build()
|
|
75
|
+
|
|
76
|
+
const apiRoot = createApiBuilderFromCtpClient(client)
|
|
77
|
+
|
|
78
|
+
// calling the history-sdk functions
|
|
79
|
+
// get project details
|
|
80
|
+
apiRoot
|
|
81
|
+
.withProjectKey({ projectKey })
|
|
82
|
+
.recommendations()
|
|
83
|
+
.projectCategories()
|
|
84
|
+
.withProductId({
|
|
85
|
+
productId: product.id,
|
|
86
|
+
})
|
|
87
|
+
.get()
|
|
88
|
+
.execute()
|
|
89
|
+
.then((x) => {
|
|
90
|
+
/*...*/
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
apiRoot
|
|
94
|
+
.withProjectKey({ projectKey })
|
|
95
|
+
.imageSearch()
|
|
96
|
+
.post({
|
|
97
|
+
queryArgs: {
|
|
98
|
+
limit: 20,
|
|
99
|
+
},
|
|
100
|
+
body: image,
|
|
101
|
+
headers: {
|
|
102
|
+
'Content-Type': 'image/jpeg',
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
.execute()
|
|
106
|
+
.then((x) => {
|
|
107
|
+
/*...*/
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
// -----------------------------------------------------------------------
|
|
111
|
+
// The sdk-client-v2 also has support for the old syntax
|
|
24
112
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
113
|
+
createClient,
|
|
114
|
+
createHttpClient,
|
|
115
|
+
createAuthForClientCredentialsFlow,
|
|
116
|
+
} from '@commercetools/sdk-client-v2'
|
|
117
|
+
import { createApiBuilderFromCtpClient } from '@commercetools/history-sdk'
|
|
28
118
|
import fetch from 'node-fetch'
|
|
29
119
|
|
|
30
120
|
const projectKey = 'some_project_key'
|
|
31
121
|
|
|
32
|
-
const authMiddleware =
|
|
33
|
-
host: 'https://auth.europe-west1.gcp.commercetools.com
|
|
122
|
+
const authMiddleware = createAuthForClientCredentialsFlow({
|
|
123
|
+
host: 'https://auth.europe-west1.gcp.commercetools.com',
|
|
34
124
|
projectKey,
|
|
35
125
|
credentials: {
|
|
36
126
|
clientId: 'some_id',
|
|
@@ -39,7 +129,7 @@ const authMiddleware = createAuthMiddlewareForClientCredentialsFlow({
|
|
|
39
129
|
fetch,
|
|
40
130
|
})
|
|
41
131
|
|
|
42
|
-
const httpMiddleware =
|
|
132
|
+
const httpMiddleware = createHttpClient({
|
|
43
133
|
host: 'https://history.europe-west1.gcp.commercetools.com',
|
|
44
134
|
fetch,
|
|
45
135
|
})
|
|
@@ -48,10 +138,10 @@ const ctpClient = createClient({
|
|
|
48
138
|
middlewares: [authMiddleware, httpMiddleware],
|
|
49
139
|
})
|
|
50
140
|
|
|
51
|
-
const apiRoot
|
|
141
|
+
const apiRoot = createApiBuilderFromCtpClient(ctpClient)
|
|
52
142
|
|
|
53
143
|
apiRoot
|
|
54
|
-
.
|
|
144
|
+
.withProjectKey({ projectKey })
|
|
55
145
|
.recommendations()
|
|
56
146
|
.projectCategories()
|
|
57
147
|
.withProductId({
|
|
@@ -193,12 +193,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
193
193
|
|
|
194
194
|
class ApiRoot {
|
|
195
195
|
constructor(args) {
|
|
196
|
+
var _args$baseUri;
|
|
197
|
+
|
|
196
198
|
_defineProperty(this, "executeRequest", void 0);
|
|
197
199
|
|
|
198
200
|
_defineProperty(this, "baseUri", void 0);
|
|
199
201
|
|
|
200
202
|
this.executeRequest = args.executeRequest;
|
|
201
|
-
this.baseUri = args.baseUri
|
|
203
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://history.europe-west1.gcp.commercetools.com';
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
withProjectKeyValue(childPathArgs) {
|
|
@@ -189,12 +189,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
189
189
|
|
|
190
190
|
class ApiRoot {
|
|
191
191
|
constructor(args) {
|
|
192
|
+
var _args$baseUri;
|
|
193
|
+
|
|
192
194
|
_defineProperty(this, "executeRequest", void 0);
|
|
193
195
|
|
|
194
196
|
_defineProperty(this, "baseUri", void 0);
|
|
195
197
|
|
|
196
198
|
this.executeRequest = args.executeRequest;
|
|
197
|
-
this.baseUri = args.baseUri
|
|
199
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://history.europe-west1.gcp.commercetools.com';
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
withProjectKeyValue(childPathArgs) {
|
|
@@ -193,12 +193,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
193
193
|
|
|
194
194
|
class ApiRoot {
|
|
195
195
|
constructor(args) {
|
|
196
|
+
var _args$baseUri;
|
|
197
|
+
|
|
196
198
|
_defineProperty(this, "executeRequest", void 0);
|
|
197
199
|
|
|
198
200
|
_defineProperty(this, "baseUri", void 0);
|
|
199
201
|
|
|
200
202
|
this.executeRequest = args.executeRequest;
|
|
201
|
-
this.baseUri = args.baseUri
|
|
203
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://history.europe-west1.gcp.commercetools.com';
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
withProjectKeyValue(childPathArgs) {
|
|
@@ -193,12 +193,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
193
193
|
|
|
194
194
|
class ApiRoot {
|
|
195
195
|
constructor(args) {
|
|
196
|
+
var _args$baseUri;
|
|
197
|
+
|
|
196
198
|
_defineProperty(this, "executeRequest", void 0);
|
|
197
199
|
|
|
198
200
|
_defineProperty(this, "baseUri", void 0);
|
|
199
201
|
|
|
200
202
|
this.executeRequest = args.executeRequest;
|
|
201
|
-
this.baseUri = args.baseUri
|
|
203
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://history.europe-west1.gcp.commercetools.com';
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
withProjectKeyValue(childPathArgs) {
|
|
@@ -189,12 +189,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
189
189
|
|
|
190
190
|
class ApiRoot {
|
|
191
191
|
constructor(args) {
|
|
192
|
+
var _args$baseUri;
|
|
193
|
+
|
|
192
194
|
_defineProperty(this, "executeRequest", void 0);
|
|
193
195
|
|
|
194
196
|
_defineProperty(this, "baseUri", void 0);
|
|
195
197
|
|
|
196
198
|
this.executeRequest = args.executeRequest;
|
|
197
|
-
this.baseUri = args.baseUri
|
|
199
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://history.europe-west1.gcp.commercetools.com';
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
withProjectKeyValue(childPathArgs) {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"name": "@commercetools/history-sdk",
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "2.0.0",
|
|
8
8
|
"description": "Type script sdk for commercetools audit log features",
|
|
9
9
|
"keywords": ["commercetools", "typescript", "sdk", "history"],
|
|
10
10
|
"homepage": "https://github.com/commercetools/commercetools-typescript-sdks/packages/history-sdk",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"querystring": "^0.2.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@commercetools/platform-sdk": "
|
|
34
|
-
"@commercetools/sdk-client-v2": "^0.
|
|
33
|
+
"@commercetools/platform-sdk": "2.0.0",
|
|
34
|
+
"@commercetools/sdk-client-v2": "^1.0.0",
|
|
35
35
|
"@types/uuid": "8.3.3",
|
|
36
36
|
"organize-imports-cli": "0.8.0",
|
|
37
37
|
"tsconfig-replace-paths": "0.0.11",
|