You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add `@since` JSDoc annotations — counterpart to `@deprecated`. ([c1ff52b](https://github.com/commercelayer/commercelayer-sdk/commit/c1ff52b1213df610fb4d3d45e15e5542594da6bc))
6
+
* add SDK version to request headers ([0d66f57](https://github.com/commercelayer/commercelayer-sdk/commit/0d66f574fbc7b3770ddde86bfb8fd2fdab58f3cb))
7
+
* add support for `versions` attribute in schema ([a54ba3d](https://github.com/commercelayer/commercelayer-sdk/commit/a54ba3d623a907c62ab5b237e20b8076ffc723fc))
8
+
* isolate client config between multiple instances ([39ee08a](https://github.com/commercelayer/commercelayer-sdk/commit/39ee08a33d3251c3c4a37e49a0b95983378559e2))
9
+
* use `bundle` mode as default. Default one will become the `single-client` version ([788655d](https://github.com/commercelayer/commercelayer-sdk/commit/788655d2faf8a0710e75bb36ab7b2c567be5bf2c))
10
+
* use children type for payment settings, promotions, ([7dc99ed](https://github.com/commercelayer/commercelayer-sdk/commit/7dc99edd823924d967d63a556923e0c40d622a0f))
Copy file name to clipboardExpand all lines: README.md
+20-8Lines changed: 20 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,12 +58,12 @@ All requests to Commerce Layer API must be authenticated with an [OAuth2](https:
58
58
59
59
### Import
60
60
61
-
The SDK supports two import approaches. **Use the bundled client by default**, the selective import pattern is available for specific use cases but comes with important caveats described below.
61
+
The SDK offers two import styles. **The default entry is the bundled client** — use it unless you have a specific reason not to. The selective (tree-shakeable) style lives on a separate subpath and carries an important caveat described below.
All resource accessors are available directly on the client object. This increases your final bundle size but keeps all resource calls scoped to a specific client instance.
76
+
All resource accessors are available directly on the client object. This increases your final bundle size, but every call is scoped to that specific client instance — so you can safely create and use **multiple clients with different access tokens at the same time** (multi-tenant apps, serverless with connection reuse, etc.):
Only the imported resources are included in your bundle. However, imported resources share a single global SDK configuration. If two requests are in-flight simultaneously with different access tokens (common in serverless environments with connection reuse, or in any multi-tenant context), they may silently use the wrong token.
101
+
Only the imported resources are included in your bundle, so it produces the smallest output. The trade-off: imported resources share **a single global SDK configuration**. If two requests are in-flight simultaneously with different access tokens, they may silently use the wrong token — so this style supports only **one active token at a time**.
92
102
93
-
It is a good fit for edge/serverless functions or webhook handlers that use only a few resources and a single token active at a time.
103
+
It is a good fit for edge/serverless functions or webhook handlers that use only a few resources and a single token. When you need multiple concurrent tokens, use the bundled client above.
94
104
95
105
### Options
96
106
@@ -129,6 +139,8 @@ The JavaScript SDK is a wrapper around Commerce Layer API which means you would
129
139
130
140
To show you how things work, we will use the [SKUs](https://docs.commercelayer.io/core/v/api-reference/skus) and [Shipping Categories](https://docs.commercelayer.io/core/v/api-reference/shipping_categories) resource in the following examples. The code snippets below show how to use the SDK when performing the standard CRUD operations provided by our REST API. Kindly check our [API reference](https://docs.commercelayer.io/core/v/api-reference) for the complete list of available **resources** and their **attributes**.
131
141
142
+
> The examples below use the selective style (`skus.create(...)`, imported from `@commercelayer/sdk/single-client`) for brevity. With the default **bundled client**, call the same methods through the client instance instead — e.g. `cl.skus.create(...)`, `cl.shipping_categories.list(...)`.
0 commit comments