Skip to content

Commit d693f87

Browse files
deps: update commercelayer sdk to the latest
1 parent cd9961e commit d693f87

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

packages/drop-in/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"dependencies": {
4848
"@commercelayer/js-auth": "^7.0.0",
4949
"@commercelayer/organization-config": "^2.4.0",
50-
"@commercelayer/sdk": "^6.49.0",
50+
"@commercelayer/sdk": "^7.3.0",
5151
"@types/lodash-es": "^4.17.12",
5252
"iframe-resizer": "4.3.11",
5353
"js-cookie": "^3.0.5",

packages/drop-in/src/apis/commercelayer/client.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { makeSalesChannel } from "@commercelayer/js-auth"
22
import CommerceLayer, {
3-
type CommerceLayerClient,
3+
bundles,
44
type Customer,
5+
customers,
6+
line_items,
7+
orders,
8+
organization,
9+
prices,
10+
skus,
511
} from "@commercelayer/sdk"
612
import Cookies from "js-cookie"
713
import { memoize } from "lodash-es"
@@ -93,15 +99,23 @@ export const getAccessToken = memoize(
9399
(clientCredentials) => JSON.stringify(clientCredentials),
94100
)
95101

96-
export async function createClient(
97-
config: Config,
98-
): Promise<CommerceLayerClient> {
102+
export async function createClient(config: Config) {
99103
const token = await getAccessToken(config)
100104

101-
return CommerceLayer({
105+
CommerceLayer({
102106
accessToken: token.accessToken,
103107
domain: config.domain,
104108
})
109+
110+
return {
111+
bundles,
112+
customers,
113+
line_items,
114+
orders,
115+
organization,
116+
prices,
117+
skus,
118+
}
105119
}
106120

107121
export const customerFields = [

packages/drop-in/src/components/cl-cart-link/cl-cart-link.spec.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { CommerceLayerClient } from "@commercelayer/sdk"
1+
import type {
2+
orders as sdkOrders,
3+
organization as sdkOrganization,
4+
} from "@commercelayer/sdk"
25
import { newSpecPage } from "@stencil/core/testing"
36
import { waitFor } from "jest.spec.helpers"
47
import * as cart from "@/apis/commercelayer/cart"
@@ -20,7 +23,7 @@ describe("cl-cart-link.spec", () => {
2023
jest.spyOn(client, "createClient").mockResolvedValue({
2124
orders,
2225
organization,
23-
} as unknown as CommerceLayerClient)
26+
} as unknown as ReturnType<(typeof client)["createClient"]>)
2427

2528
const { root, waitForChanges } = await newSpecPage({
2629
components: [ClCartLink],
@@ -53,7 +56,7 @@ describe("cl-cart-link.spec", () => {
5356
jest.spyOn(client, "createClient").mockResolvedValue({
5457
orders,
5558
organization,
56-
} as unknown as CommerceLayerClient)
59+
} as unknown as ReturnType<(typeof client)["createClient"]>)
5760
jest.spyOn(cart, "getCart").mockResolvedValue({
5861
type: "orders",
5962
id: "order-123",
@@ -90,7 +93,7 @@ describe("cl-cart-link.spec", () => {
9093
jest.spyOn(client, "createClient").mockResolvedValue({
9194
orders,
9295
organization,
93-
} as unknown as CommerceLayerClient)
96+
} as unknown as ReturnType<(typeof client)["createClient"]>)
9497

9598
const { root, waitForChanges } = await newSpecPage({
9699
components: [ClCartLink],
@@ -129,7 +132,7 @@ describe("cl-cart-link.spec", () => {
129132
const accessToken =
130133
"eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCIsImtpZCI6IjliN2JiZmVlMzQzZDVkNDQ5ZGFkODhmMjg0MGEyZTM3YzhkZWFlZTg5NjM4MGQ1ODA2YTc4NWVkMWQ1OTc5ZjAifQ.eyJvcmdhbml6YXRpb24iOnsiaWQiOiJPblZOcUZPTUpuIiwic2x1ZyI6ImRyb3AtaW4tanMiLCJlbnRlcnByaXNlIjp0cnVlLCJyZWdpb24iOiJldS13ZXN0LTEifSwiYXBwbGljYXRpb24iOnsiaWQiOiJkTm5XbWl4eEtHIiwiY2xpZW50X2lkIjoia3VTS1BiZUtiVTlMRzlMam5kemllS1dSY2ZpWEZ1RWZPME9ZSFhLSDlKOCIsImtpbmQiOiJzYWxlc19jaGFubmVs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132-
const orders: Partial<CommerceLayerClient["orders"]> = {
135+
const orders: Partial<typeof sdkOrders> = {
133136
create: jest.fn().mockResolvedValue({
134137
type: "orders",
135138
id: "order-123",
@@ -138,7 +141,7 @@ const orders: Partial<CommerceLayerClient["orders"]> = {
138141
}),
139142
}
140143

141-
const organization: Partial<CommerceLayerClient["organization"]> = {
144+
const organization: Partial<typeof sdkOrganization> = {
142145
retrieve: jest.fn().mockResolvedValue({
143146
type: "organizations",
144147
id: "organization-123",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)