@commercetools/importapi-sdk 1.21.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 +100 -18
- package/dist/commercetools-importapi-sdk.browser.cjs.js +3 -1
- package/dist/commercetools-importapi-sdk.browser.esm.js +3 -1
- package/dist/commercetools-importapi-sdk.cjs.dev.js +3 -1
- package/dist/commercetools-importapi-sdk.cjs.prod.js +3 -1
- package/dist/commercetools-importapi-sdk.esm.js +3 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @commercetools/importapi-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.21.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,36 +1,108 @@
|
|
|
1
1
|
# Typescript SDK for commercetools import API
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Usage examples
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
npm install --save @commercetools/importapi-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/importapi-sdk@latest/dist/commercetools-importapi-sdk.umd.js"></script>
|
|
10
|
+
```
|
|
10
11
|
|
|
11
12
|
```html
|
|
12
|
-
<script src="https://unpkg.com/browse/@commercetools/importapi-sdk/dist/importapi-sdk.umd.js"></script>
|
|
13
13
|
<script>
|
|
14
|
-
// global:
|
|
14
|
+
// global: @commercetools/sdk-client-v2
|
|
15
|
+
// global: @commercetools/importapi-sdk
|
|
16
|
+
;(function () {
|
|
17
|
+
// We can now access the sdk-client-v2 and importapi-sdk object as:
|
|
18
|
+
// const { ClientBuilder } = this['@commercetools/sdk-client-v2']
|
|
19
|
+
// const { createApiBuilderFromCtpClient } = this['@commercetools/importapi-sdk']
|
|
20
|
+
// or
|
|
21
|
+
// const { ClientBuilder } = window['@commercetools/sdk-client-v2']
|
|
22
|
+
// const { createApiBuilderFromCtpClient } = window['@commercetools/importapi-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/importapi-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/importapi-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://api.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
|
+
|
|
77
|
+
const apiRoot = createApiBuilderFromCtpClient(client)
|
|
78
|
+
|
|
79
|
+
// calling the importapi functions
|
|
80
|
+
// get project details
|
|
81
|
+
apiRoot
|
|
82
|
+
.withProjectKey({
|
|
83
|
+
projectKey,
|
|
84
|
+
})
|
|
85
|
+
.get()
|
|
86
|
+
.execute()
|
|
87
|
+
.then((x) => {
|
|
88
|
+
/*...*/
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
// -----------------------------------------------------------------------
|
|
93
|
+
// The sdk-client-v2 also has support for the old syntax
|
|
24
94
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
95
|
+
createClient,
|
|
96
|
+
createHttpClient,
|
|
97
|
+
createAuthForClientCredentialsFlow,
|
|
98
|
+
} from '@commercetools/sdk-client-v2'
|
|
99
|
+
import { createApiBuilderFromCtpClient } from '@commercetools/importapi-sdk')
|
|
28
100
|
import fetch from 'node-fetch'
|
|
29
101
|
|
|
30
102
|
const projectKey = 'some_project_key'
|
|
31
103
|
|
|
32
|
-
const authMiddleware =
|
|
33
|
-
host: 'https://auth.europe-west1.gcp.commercetools.com
|
|
104
|
+
const authMiddleware = createAuthForClientCredentialsFlow({
|
|
105
|
+
host: 'https://auth.europe-west1.gcp.commercetools.com',
|
|
34
106
|
projectKey,
|
|
35
107
|
credentials: {
|
|
36
108
|
clientId: 'some_id',
|
|
@@ -39,7 +111,7 @@ const authMiddleware = createAuthMiddlewareForClientCredentialsFlow({
|
|
|
39
111
|
fetch,
|
|
40
112
|
})
|
|
41
113
|
|
|
42
|
-
const httpMiddleware =
|
|
114
|
+
const httpMiddleware = createHttpClient({
|
|
43
115
|
host: 'https://import.europe-west1.gcp.commercetools.com',
|
|
44
116
|
fetch,
|
|
45
117
|
})
|
|
@@ -48,5 +120,15 @@ const ctpClient = createClient({
|
|
|
48
120
|
middlewares: [authMiddleware, httpMiddleware],
|
|
49
121
|
})
|
|
50
122
|
|
|
51
|
-
const apiRoot
|
|
123
|
+
const apiRoot = createApiBuilderFromCtpClient(ctpClient)
|
|
124
|
+
|
|
125
|
+
apiRoot
|
|
126
|
+
.withProjectKey({
|
|
127
|
+
projectKey,
|
|
128
|
+
})
|
|
129
|
+
.get()
|
|
130
|
+
.execute()
|
|
131
|
+
.then((x) => {
|
|
132
|
+
/*...*/
|
|
133
|
+
})
|
|
52
134
|
```
|
|
@@ -2728,12 +2728,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
2728
2728
|
|
|
2729
2729
|
class ApiRoot {
|
|
2730
2730
|
constructor(args) {
|
|
2731
|
+
var _args$baseUri;
|
|
2732
|
+
|
|
2731
2733
|
_defineProperty(this, "executeRequest", void 0);
|
|
2732
2734
|
|
|
2733
2735
|
_defineProperty(this, "baseUri", void 0);
|
|
2734
2736
|
|
|
2735
2737
|
this.executeRequest = args.executeRequest;
|
|
2736
|
-
this.baseUri = args.baseUri
|
|
2738
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://import.europe-west1.gcp.commercetools.com';
|
|
2737
2739
|
}
|
|
2738
2740
|
|
|
2739
2741
|
withProjectKeyValue(childPathArgs) {
|
|
@@ -2724,12 +2724,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
2724
2724
|
|
|
2725
2725
|
class ApiRoot {
|
|
2726
2726
|
constructor(args) {
|
|
2727
|
+
var _args$baseUri;
|
|
2728
|
+
|
|
2727
2729
|
_defineProperty(this, "executeRequest", void 0);
|
|
2728
2730
|
|
|
2729
2731
|
_defineProperty(this, "baseUri", void 0);
|
|
2730
2732
|
|
|
2731
2733
|
this.executeRequest = args.executeRequest;
|
|
2732
|
-
this.baseUri = args.baseUri
|
|
2734
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://import.europe-west1.gcp.commercetools.com';
|
|
2733
2735
|
}
|
|
2734
2736
|
|
|
2735
2737
|
withProjectKeyValue(childPathArgs) {
|
|
@@ -2728,12 +2728,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
2728
2728
|
|
|
2729
2729
|
class ApiRoot {
|
|
2730
2730
|
constructor(args) {
|
|
2731
|
+
var _args$baseUri;
|
|
2732
|
+
|
|
2731
2733
|
_defineProperty(this, "executeRequest", void 0);
|
|
2732
2734
|
|
|
2733
2735
|
_defineProperty(this, "baseUri", void 0);
|
|
2734
2736
|
|
|
2735
2737
|
this.executeRequest = args.executeRequest;
|
|
2736
|
-
this.baseUri = args.baseUri
|
|
2738
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://import.europe-west1.gcp.commercetools.com';
|
|
2737
2739
|
}
|
|
2738
2740
|
|
|
2739
2741
|
withProjectKeyValue(childPathArgs) {
|
|
@@ -2728,12 +2728,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
2728
2728
|
|
|
2729
2729
|
class ApiRoot {
|
|
2730
2730
|
constructor(args) {
|
|
2731
|
+
var _args$baseUri;
|
|
2732
|
+
|
|
2731
2733
|
_defineProperty(this, "executeRequest", void 0);
|
|
2732
2734
|
|
|
2733
2735
|
_defineProperty(this, "baseUri", void 0);
|
|
2734
2736
|
|
|
2735
2737
|
this.executeRequest = args.executeRequest;
|
|
2736
|
-
this.baseUri = args.baseUri
|
|
2738
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://import.europe-west1.gcp.commercetools.com';
|
|
2737
2739
|
}
|
|
2738
2740
|
|
|
2739
2741
|
withProjectKeyValue(childPathArgs) {
|
|
@@ -2724,12 +2724,14 @@ class ByProjectKeyRequestBuilder {
|
|
|
2724
2724
|
|
|
2725
2725
|
class ApiRoot {
|
|
2726
2726
|
constructor(args) {
|
|
2727
|
+
var _args$baseUri;
|
|
2728
|
+
|
|
2727
2729
|
_defineProperty(this, "executeRequest", void 0);
|
|
2728
2730
|
|
|
2729
2731
|
_defineProperty(this, "baseUri", void 0);
|
|
2730
2732
|
|
|
2731
2733
|
this.executeRequest = args.executeRequest;
|
|
2732
|
-
this.baseUri = args.baseUri
|
|
2734
|
+
this.baseUri = (_args$baseUri = args.baseUri) !== null && _args$baseUri !== void 0 ? _args$baseUri : 'https://import.europe-west1.gcp.commercetools.com';
|
|
2733
2735
|
}
|
|
2734
2736
|
|
|
2735
2737
|
withProjectKeyValue(childPathArgs) {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"name": "@commercetools/importapi-sdk",
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "2.0.0",
|
|
8
8
|
"description": "Type script sdk for commercetools import features",
|
|
9
9
|
"keywords": ["commercetools", "typescript", "sdk", "import"],
|
|
10
10
|
"homepage": "https://github.com/commercetools/commercetools-sdk-typescript/packages/importapi-sdk",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"querystring": "^0.2.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@commercetools/sdk-client-v2": "^0.
|
|
33
|
+
"@commercetools/sdk-client-v2": "^1.0.0",
|
|
34
34
|
"@types/uuid": "8.3.3",
|
|
35
35
|
"organize-imports-cli": "0.8.0",
|
|
36
36
|
"tsconfig-replace-paths": "0.0.11",
|