@shopnex/cj-plugin 1.0.6 → 1.0.8
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/dist/CjCollection.d.ts +21 -0
- package/dist/CjCollection.js +113 -0
- package/dist/CjCollection.js.map +1 -0
- package/dist/api-client.d.ts +1 -1
- package/dist/api-client.js +5 -5
- package/dist/api-client.js.map +1 -1
- package/dist/error-handler.js.map +1 -1
- package/dist/error-types.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +8 -24
- package/dist/index.js.map +1 -1
- package/dist/rsc/ApiToken.d.ts +1 -1
- package/dist/rsc/ApiToken.js.map +1 -1
- package/dist/rsc/ApiToken.scss +1 -2
- package/dist/sdk/access-token.d.ts +1 -1
- package/dist/sdk/access-token.js +11 -11
- package/dist/sdk/access-token.js.map +1 -1
- package/dist/{auth.js → sdk/auth.js} +11 -12
- package/dist/sdk/auth.js.map +1 -0
- package/dist/sdk/cj-sdk.d.ts +18 -4
- package/dist/sdk/cj-sdk.js +42 -4
- package/dist/sdk/cj-sdk.js.map +1 -1
- package/dist/sdk/dispute/dispute-types.js.map +1 -1
- package/dist/sdk/dispute/dispute.d.ts +2 -2
- package/dist/sdk/dispute/dispute.js +12 -14
- package/dist/sdk/dispute/dispute.js.map +1 -1
- package/dist/sdk/inventory/inventory-types.js.map +1 -1
- package/dist/sdk/inventory/inventory.d.ts +2 -2
- package/dist/sdk/inventory/inventory.js +9 -10
- package/dist/sdk/inventory/inventory.js.map +1 -1
- package/dist/sdk/orders/orders.d.ts +2 -2
- package/dist/sdk/orders/orders.js +32 -32
- package/dist/sdk/orders/orders.js.map +1 -1
- package/dist/sdk/products/product-types.d.ts +14 -3
- package/dist/sdk/products/product-types.js +1 -3
- package/dist/sdk/products/product-types.js.map +1 -1
- package/dist/sdk/products/products.d.ts +7 -1
- package/dist/sdk/products/products.js +51 -2
- package/dist/sdk/products/products.js.map +1 -1
- package/dist/sdk/settings/settings-api.d.ts +1 -1
- package/dist/sdk/settings/settings-api.js +4 -4
- package/dist/sdk/settings/settings-api.js.map +1 -1
- package/dist/sdk/settings/settings-types.js.map +1 -1
- package/dist/sdk/variants/variant-types.js.map +1 -1
- package/dist/sdk/variants/variants.d.ts +2 -2
- package/dist/sdk/variants/variants.js +16 -18
- package/dist/sdk/variants/variants.js.map +1 -1
- package/dist/service/access-token.d.ts +2 -0
- package/dist/service/access-token.js +53 -0
- package/dist/service/access-token.js.map +1 -0
- package/dist/service/create-order.hook.js +5 -2
- package/dist/service/create-order.hook.js.map +1 -1
- package/dist/service/sync-products.d.ts +7 -2
- package/dist/service/sync-products.js +99 -100
- package/dist/service/sync-products.js.map +1 -1
- package/dist/ui/refund-button.d.ts +1 -1
- package/dist/ui/refund-button.js +2 -2
- package/dist/ui/refund-button.js.map +1 -1
- package/dist/util/get-product-id.d.ts +1 -0
- package/dist/util/get-product-id.js +10 -0
- package/dist/util/get-product-id.js.map +1 -0
- package/dist/util/manage-tokens.js.map +1 -1
- package/package.json +5 -2
- package/LICENSE.md +0 -9
- package/dist/auth.js.map +0 -1
- package/dist/cj-settings.d.ts +0 -9
- package/dist/cj-settings.js +0 -99
- package/dist/cj-settings.js.map +0 -1
- /package/dist/{auth.d.ts → sdk/auth.d.ts} +0 -0
@@ -1,17 +1,16 @@
|
|
1
|
-
import { cjApiClient } from
|
2
|
-
import { getCurrentAccessToken } from
|
1
|
+
import { cjApiClient } from "../../api-client";
|
2
|
+
import { getCurrentAccessToken } from "../access-token";
|
3
3
|
export async function createDispute(requestData) {
|
4
4
|
try {
|
5
|
-
const accessToken = await getCurrentAccessToken() // Ensure to populate this with a valid token
|
6
|
-
|
7
|
-
const response = await cjApiClient.post('disputes/create', requestData, {
|
5
|
+
const accessToken = await getCurrentAccessToken(); // Ensure to populate this with a valid token
|
6
|
+
const response = await cjApiClient.post("disputes/create", requestData, {
|
8
7
|
headers: {
|
9
|
-
|
8
|
+
"CJ-Access-Token": accessToken
|
10
9
|
}
|
11
10
|
});
|
12
11
|
if (!response.data.result) {
|
13
12
|
return {
|
14
|
-
error: response.data.message ||
|
13
|
+
error: response.data.message || "Failed to create dispute"
|
15
14
|
};
|
16
15
|
}
|
17
16
|
return {
|
@@ -20,22 +19,21 @@ export async function createDispute(requestData) {
|
|
20
19
|
} catch (error) {
|
21
20
|
console.error(`Error creating dispute [${error.code}]: ${error.message}`);
|
22
21
|
return {
|
23
|
-
error: error.message ||
|
22
|
+
error: error.message || "An unknown error occurred"
|
24
23
|
};
|
25
24
|
}
|
26
25
|
}
|
27
26
|
export async function confirmDispute(requestData) {
|
28
27
|
try {
|
29
|
-
const accessToken = await getCurrentAccessToken() // Ensure to populate this with a valid token
|
30
|
-
|
31
|
-
const response = await cjApiClient.post('disputes/disputeConfirmInfo', requestData, {
|
28
|
+
const accessToken = await getCurrentAccessToken(); // Ensure to populate this with a valid token
|
29
|
+
const response = await cjApiClient.post("disputes/disputeConfirmInfo", requestData, {
|
32
30
|
headers: {
|
33
|
-
|
31
|
+
"CJ-Access-Token": accessToken
|
34
32
|
}
|
35
33
|
});
|
36
34
|
if (!response.data.result) {
|
37
35
|
return {
|
38
|
-
error: response.data.message ||
|
36
|
+
error: response.data.message || "Failed to confirm dispute"
|
39
37
|
};
|
40
38
|
}
|
41
39
|
return {
|
@@ -44,7 +42,7 @@ export async function confirmDispute(requestData) {
|
|
44
42
|
} catch (error) {
|
45
43
|
console.error(`Error confirming dispute [${error.code}]: ${error.message}`);
|
46
44
|
return {
|
47
|
-
error: error.message ||
|
45
|
+
error: error.message || "An unknown error occurred"
|
48
46
|
};
|
49
47
|
}
|
50
48
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/sdk/dispute/dispute.ts"],"sourcesContent":["import type { APIResponse } from
|
1
|
+
{"version":3,"sources":["../../../src/sdk/dispute/dispute.ts"],"sourcesContent":["import type { APIResponse } from \"../../error-types\";\nimport type {\n ConfirmDisputeRequest,\n ConfirmDisputeResponse,\n CreateDisputeRequest,\n DisputeAPIResponse,\n} from \"./dispute-types.ts\";\n\nimport { cjApiClient } from \"../../api-client\";\nimport { getCurrentAccessToken } from \"../access-token\";\n\nexport async function createDispute(\n requestData: CreateDisputeRequest\n): Promise<APIResponse<DisputeAPIResponse>> {\n try {\n const accessToken = await getCurrentAccessToken(); // Ensure to populate this with a valid token\n const response = await cjApiClient.post<DisputeAPIResponse>(\n \"disputes/create\",\n requestData,\n {\n headers: {\n \"CJ-Access-Token\": accessToken,\n },\n }\n );\n\n if (!response.data.result) {\n return {\n error: response.data.message || \"Failed to create dispute\",\n };\n }\n\n return { data: response.data };\n } catch (error: any) {\n console.error(\n `Error creating dispute [${error.code}]: ${error.message}`\n );\n return { error: error.message || \"An unknown error occurred\" };\n }\n}\n\nexport async function confirmDispute(\n requestData: ConfirmDisputeRequest\n): Promise<APIResponse<ConfirmDisputeResponse>> {\n try {\n const accessToken = await getCurrentAccessToken(); // Ensure to populate this with a valid token\n const response = await cjApiClient.post<ConfirmDisputeResponse>(\n \"disputes/disputeConfirmInfo\",\n requestData,\n {\n headers: {\n \"CJ-Access-Token\": accessToken,\n },\n }\n );\n\n if (!response.data.result) {\n return {\n error: response.data.message || \"Failed to confirm dispute\",\n };\n }\n\n return { data: response.data };\n } catch (error: any) {\n console.error(\n `Error confirming dispute [${error.code}]: ${error.message}`\n );\n return { error: error.message || \"An unknown error occurred\" };\n }\n}\n"],"names":["cjApiClient","getCurrentAccessToken","createDispute","requestData","accessToken","response","post","headers","data","result","error","message","console","code","confirmDispute"],"mappings":"AAQA,SAASA,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,qBAAqB,QAAQ,kBAAkB;AAExD,OAAO,eAAeC,cAClBC,WAAiC;IAEjC,IAAI;QACA,MAAMC,cAAc,MAAMH,yBAAyB,6CAA6C;QAChG,MAAMI,WAAW,MAAML,YAAYM,IAAI,CACnC,mBACAH,aACA;YACII,SAAS;gBACL,mBAAmBH;YACvB;QACJ;QAGJ,IAAI,CAACC,SAASG,IAAI,CAACC,MAAM,EAAE;YACvB,OAAO;gBACHC,OAAOL,SAASG,IAAI,CAACG,OAAO,IAAI;YACpC;QACJ;QAEA,OAAO;YAAEH,MAAMH,SAASG,IAAI;QAAC;IACjC,EAAE,OAAOE,OAAY;QACjBE,QAAQF,KAAK,CACT,CAAC,wBAAwB,EAAEA,MAAMG,IAAI,CAAC,GAAG,EAAEH,MAAMC,OAAO,EAAE;QAE9D,OAAO;YAAED,OAAOA,MAAMC,OAAO,IAAI;QAA4B;IACjE;AACJ;AAEA,OAAO,eAAeG,eAClBX,WAAkC;IAElC,IAAI;QACA,MAAMC,cAAc,MAAMH,yBAAyB,6CAA6C;QAChG,MAAMI,WAAW,MAAML,YAAYM,IAAI,CACnC,+BACAH,aACA;YACII,SAAS;gBACL,mBAAmBH;YACvB;QACJ;QAGJ,IAAI,CAACC,SAASG,IAAI,CAACC,MAAM,EAAE;YACvB,OAAO;gBACHC,OAAOL,SAASG,IAAI,CAACG,OAAO,IAAI;YACpC;QACJ;QAEA,OAAO;YAAEH,MAAMH,SAASG,IAAI;QAAC;IACjC,EAAE,OAAOE,OAAY;QACjBE,QAAQF,KAAK,CACT,CAAC,0BAA0B,EAAEA,MAAMG,IAAI,CAAC,GAAG,EAAEH,MAAMC,OAAO,EAAE;QAEhE,OAAO;YAAED,OAAOA,MAAMC,OAAO,IAAI;QAA4B;IACjE;AACJ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/sdk/inventory/inventory-types.ts"],"sourcesContent":["export interface Inventory {\n
|
1
|
+
{"version":3,"sources":["../../../src/sdk/inventory/inventory-types.ts"],"sourcesContent":["export interface Inventory {\n areaEn: string;\n areaId: string;\n countryCode: string;\n storageNum: number;\n vid: string;\n}\n"],"names":[],"mappings":"AAAA,WAMC"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import type { APIResponse } from
|
2
|
-
import type { Inventory } from
|
1
|
+
import type { APIResponse } from "../../error-types";
|
2
|
+
import type { Inventory } from "./inventory-types.ts";
|
3
3
|
export declare function getInventoryByVariantId(vid: string): Promise<APIResponse<Inventory[]>>;
|
@@ -1,17 +1,16 @@
|
|
1
|
-
import { cjApiClient } from
|
2
|
-
import { getCurrentAccessToken } from
|
1
|
+
import { cjApiClient } from "../../api-client";
|
2
|
+
import { getCurrentAccessToken } from "../access-token";
|
3
3
|
export async function getInventoryByVariantId(vid) {
|
4
4
|
if (!vid) {
|
5
5
|
return {
|
6
|
-
error:
|
6
|
+
error: "vid must be provided."
|
7
7
|
};
|
8
8
|
}
|
9
9
|
try {
|
10
|
-
const accessToken = await getCurrentAccessToken() // Ensure you populate this with a valid token
|
11
|
-
|
12
|
-
const response = await cjApiClient.get('product/stock/queryByVid', {
|
10
|
+
const accessToken = await getCurrentAccessToken(); // Ensure you populate this with a valid token
|
11
|
+
const response = await cjApiClient.get("product/stock/queryByVid", {
|
13
12
|
headers: {
|
14
|
-
|
13
|
+
"CJ-Access-Token": accessToken
|
15
14
|
},
|
16
15
|
params: {
|
17
16
|
vid
|
@@ -19,12 +18,12 @@ export async function getInventoryByVariantId(vid) {
|
|
19
18
|
});
|
20
19
|
if (!response.data.result) {
|
21
20
|
return {
|
22
|
-
error: response.data.message ||
|
21
|
+
error: response.data.message || "Failed to fetch inventory"
|
23
22
|
};
|
24
23
|
}
|
25
24
|
if (!response.data.data) {
|
26
25
|
return {
|
27
|
-
error:
|
26
|
+
error: "No inventory found"
|
28
27
|
};
|
29
28
|
}
|
30
29
|
return {
|
@@ -33,7 +32,7 @@ export async function getInventoryByVariantId(vid) {
|
|
33
32
|
} catch (error) {
|
34
33
|
console.error(`Error fetching inventory by variant ID [${error.code}]: ${error.message}`);
|
35
34
|
return {
|
36
|
-
error: error.message ||
|
35
|
+
error: error.message || "An unknown error occurred"
|
37
36
|
};
|
38
37
|
}
|
39
38
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/sdk/inventory/inventory.ts"],"sourcesContent":["import type { APIResponse } from
|
1
|
+
{"version":3,"sources":["../../../src/sdk/inventory/inventory.ts"],"sourcesContent":["import type { APIResponse } from \"../../error-types\";\nimport type { CJApiResponse } from \"../../types\";\nimport type { Inventory } from \"./inventory-types.ts\";\n\nimport { cjApiClient } from \"../../api-client\";\nimport { getCurrentAccessToken } from \"../access-token\";\n\nexport async function getInventoryByVariantId(\n vid: string\n): Promise<APIResponse<Inventory[]>> {\n if (!vid) {\n return { error: \"vid must be provided.\" };\n }\n\n try {\n const accessToken = await getCurrentAccessToken(); // Ensure you populate this with a valid token\n const response = await cjApiClient.get<CJApiResponse<Inventory[]>>(\n \"product/stock/queryByVid\",\n {\n headers: {\n \"CJ-Access-Token\": accessToken,\n },\n params: { vid },\n }\n );\n\n if (!response.data.result) {\n return {\n error: response.data.message || \"Failed to fetch inventory\",\n };\n }\n\n if (!response.data.data) {\n return { error: \"No inventory found\" };\n }\n\n return { data: response.data.data };\n } catch (error: any) {\n console.error(\n `Error fetching inventory by variant ID [${error.code}]: ${error.message}`\n );\n return { error: error.message || \"An unknown error occurred\" };\n }\n}\n"],"names":["cjApiClient","getCurrentAccessToken","getInventoryByVariantId","vid","error","accessToken","response","get","headers","params","data","result","message","console","code"],"mappings":"AAIA,SAASA,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,qBAAqB,QAAQ,kBAAkB;AAExD,OAAO,eAAeC,wBAClBC,GAAW;IAEX,IAAI,CAACA,KAAK;QACN,OAAO;YAAEC,OAAO;QAAwB;IAC5C;IAEA,IAAI;QACA,MAAMC,cAAc,MAAMJ,yBAAyB,8CAA8C;QACjG,MAAMK,WAAW,MAAMN,YAAYO,GAAG,CAClC,4BACA;YACIC,SAAS;gBACL,mBAAmBH;YACvB;YACAI,QAAQ;gBAAEN;YAAI;QAClB;QAGJ,IAAI,CAACG,SAASI,IAAI,CAACC,MAAM,EAAE;YACvB,OAAO;gBACHP,OAAOE,SAASI,IAAI,CAACE,OAAO,IAAI;YACpC;QACJ;QAEA,IAAI,CAACN,SAASI,IAAI,CAACA,IAAI,EAAE;YACrB,OAAO;gBAAEN,OAAO;YAAqB;QACzC;QAEA,OAAO;YAAEM,MAAMJ,SAASI,IAAI,CAACA,IAAI;QAAC;IACtC,EAAE,OAAON,OAAY;QACjBS,QAAQT,KAAK,CACT,CAAC,wCAAwC,EAAEA,MAAMU,IAAI,CAAC,GAAG,EAAEV,MAAMQ,OAAO,EAAE;QAE9E,OAAO;YAAER,OAAOA,MAAMQ,OAAO,IAAI;QAA4B;IACjE;AACJ"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type { APIResponse } from
|
2
|
-
import type { CreateOrderPayload, CreateOrderResponse, ListOrderResponse, QueryOrderParams, QueryOrderResponse } from
|
1
|
+
import type { APIResponse } from "../../error-types";
|
2
|
+
import type { CreateOrderPayload, CreateOrderResponse, ListOrderResponse, QueryOrderParams, QueryOrderResponse } from "./order-types.ts";
|
3
3
|
interface ListOrderParams {
|
4
4
|
orderIds?: string[];
|
5
5
|
pageNum?: number;
|
@@ -1,22 +1,22 @@
|
|
1
|
-
import { cjApiClient } from
|
2
|
-
import { getCurrentAccessToken } from
|
1
|
+
import { cjApiClient } from "../../api-client";
|
2
|
+
import { getCurrentAccessToken } from "../access-token";
|
3
3
|
export async function createOrder(orderData) {
|
4
4
|
try {
|
5
5
|
const accessToken = await getCurrentAccessToken();
|
6
|
-
const response = await cjApiClient.post(
|
6
|
+
const response = await cjApiClient.post("shopping/order/createOrderV2", orderData, {
|
7
7
|
headers: {
|
8
|
-
|
9
|
-
|
8
|
+
"CJ-Access-Token": accessToken,
|
9
|
+
"Content-Type": "application/json"
|
10
10
|
}
|
11
11
|
});
|
12
12
|
if (!response.data.result) {
|
13
13
|
return {
|
14
|
-
error: response.data.message ||
|
14
|
+
error: response.data.message || "Failed to create order"
|
15
15
|
};
|
16
16
|
}
|
17
17
|
if (!response.data.data) {
|
18
18
|
return {
|
19
|
-
error:
|
19
|
+
error: "No order created"
|
20
20
|
};
|
21
21
|
}
|
22
22
|
return {
|
@@ -25,26 +25,26 @@ export async function createOrder(orderData) {
|
|
25
25
|
} catch (error) {
|
26
26
|
console.error(`Error creating order [${error.code}]: ${error.message}`);
|
27
27
|
return {
|
28
|
-
error: error.message ||
|
28
|
+
error: error.message || "An unknown error occurred"
|
29
29
|
};
|
30
30
|
}
|
31
31
|
}
|
32
32
|
export async function listOrders(accessToken, params = {}) {
|
33
33
|
try {
|
34
|
-
const response = await cjApiClient.get(
|
34
|
+
const response = await cjApiClient.get("shopping/order/list", {
|
35
35
|
headers: {
|
36
|
-
|
36
|
+
"CJ-Access-Token": accessToken
|
37
37
|
},
|
38
38
|
params
|
39
39
|
});
|
40
40
|
if (!response.data.result) {
|
41
41
|
return {
|
42
|
-
error: response.data.message ||
|
42
|
+
error: response.data.message || "Failed to retrieve orders"
|
43
43
|
};
|
44
44
|
}
|
45
45
|
if (!response.data.data) {
|
46
46
|
return {
|
47
|
-
error:
|
47
|
+
error: "No orders found"
|
48
48
|
};
|
49
49
|
}
|
50
50
|
return {
|
@@ -53,32 +53,32 @@ export async function listOrders(accessToken, params = {}) {
|
|
53
53
|
} catch (error) {
|
54
54
|
console.error(`Error listing orders [${error.code}]: ${error.message}`);
|
55
55
|
return {
|
56
|
-
error: error.message ||
|
56
|
+
error: error.message || "An unknown error occurred"
|
57
57
|
};
|
58
58
|
}
|
59
59
|
}
|
60
60
|
export async function queryOrder(params) {
|
61
61
|
if (!params.orderId && !params.orderNum) {
|
62
62
|
return {
|
63
|
-
error:
|
63
|
+
error: "Either orderId or orderNum must be provided."
|
64
64
|
};
|
65
65
|
}
|
66
66
|
try {
|
67
67
|
const accessToken = await getCurrentAccessToken();
|
68
|
-
const response = await cjApiClient.get(
|
68
|
+
const response = await cjApiClient.get("shopping/order/getOrderDetail", {
|
69
69
|
headers: {
|
70
|
-
|
70
|
+
"CJ-Access-Token": accessToken
|
71
71
|
},
|
72
72
|
params
|
73
73
|
});
|
74
74
|
if (!response.data.result) {
|
75
75
|
return {
|
76
|
-
error: response.data.message ||
|
76
|
+
error: response.data.message || "Failed to retrieve order details"
|
77
77
|
};
|
78
78
|
}
|
79
79
|
if (!response.data.data) {
|
80
80
|
return {
|
81
|
-
error:
|
81
|
+
error: "No order details found"
|
82
82
|
};
|
83
83
|
}
|
84
84
|
return {
|
@@ -87,21 +87,21 @@ export async function queryOrder(params) {
|
|
87
87
|
} catch (error) {
|
88
88
|
console.error(`Error querying order [${error.code}]: ${error.message}`);
|
89
89
|
return {
|
90
|
-
error: error.message ||
|
90
|
+
error: error.message || "An unknown error occurred"
|
91
91
|
};
|
92
92
|
}
|
93
93
|
}
|
94
94
|
export async function deleteOrder(orderId) {
|
95
95
|
if (!orderId) {
|
96
96
|
return {
|
97
|
-
error:
|
97
|
+
error: "orderId must be provided."
|
98
98
|
};
|
99
99
|
}
|
100
100
|
try {
|
101
101
|
const accessToken = await getCurrentAccessToken();
|
102
|
-
const response = await cjApiClient.delete(
|
102
|
+
const response = await cjApiClient.delete("shopping/order/deleteOrder", {
|
103
103
|
headers: {
|
104
|
-
|
104
|
+
"CJ-Access-Token": accessToken
|
105
105
|
},
|
106
106
|
params: {
|
107
107
|
orderId
|
@@ -109,12 +109,12 @@ export async function deleteOrder(orderId) {
|
|
109
109
|
});
|
110
110
|
if (!response.data.result) {
|
111
111
|
return {
|
112
|
-
error: response.data.message ||
|
112
|
+
error: response.data.message || "Failed to delete order"
|
113
113
|
};
|
114
114
|
}
|
115
115
|
if (!response.data.data) {
|
116
116
|
return {
|
117
|
-
error:
|
117
|
+
error: "Order deletion not confirmed, no data returned"
|
118
118
|
};
|
119
119
|
}
|
120
120
|
return {
|
@@ -123,34 +123,34 @@ export async function deleteOrder(orderId) {
|
|
123
123
|
} catch (error) {
|
124
124
|
console.error(`Error deleting order [${error.code}]: ${error.message}`);
|
125
125
|
return {
|
126
|
-
error: error.message ||
|
126
|
+
error: error.message || "An unknown error occurred"
|
127
127
|
};
|
128
128
|
}
|
129
129
|
}
|
130
130
|
export async function confirmOrder(orderId) {
|
131
131
|
if (!orderId) {
|
132
132
|
return {
|
133
|
-
error:
|
133
|
+
error: "orderId must be provided."
|
134
134
|
};
|
135
135
|
}
|
136
136
|
try {
|
137
137
|
const accessToken = await getCurrentAccessToken();
|
138
|
-
const response = await cjApiClient.patch(
|
138
|
+
const response = await cjApiClient.patch("shopping/order/confirmOrder", {
|
139
139
|
orderId
|
140
140
|
}, {
|
141
141
|
headers: {
|
142
|
-
|
143
|
-
|
142
|
+
"CJ-Access-Token": accessToken,
|
143
|
+
"Content-Type": "application/json"
|
144
144
|
}
|
145
145
|
});
|
146
146
|
if (!response.data.result) {
|
147
147
|
return {
|
148
|
-
error: response.data.message ||
|
148
|
+
error: response.data.message || "Failed to confirm order"
|
149
149
|
};
|
150
150
|
}
|
151
151
|
if (!response.data.data) {
|
152
152
|
return {
|
153
|
-
error:
|
153
|
+
error: "Order confirmation not confirmed, no data returned"
|
154
154
|
};
|
155
155
|
}
|
156
156
|
return {
|
@@ -159,7 +159,7 @@ export async function confirmOrder(orderId) {
|
|
159
159
|
} catch (error) {
|
160
160
|
console.error(`Error confirming order [${error.code}]: ${error.message}`);
|
161
161
|
return {
|
162
|
-
error: error.message ||
|
162
|
+
error: error.message || "An unknown error occurred"
|
163
163
|
};
|
164
164
|
}
|
165
165
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/sdk/orders/orders.ts"],"sourcesContent":["import type { APIResponse } from
|
1
|
+
{"version":3,"sources":["../../../src/sdk/orders/orders.ts"],"sourcesContent":["import type { APIResponse } from \"../../error-types\";\nimport type { CJApiResponse } from \"../../types\";\nimport type {\n CreateOrderPayload,\n CreateOrderResponse,\n ListOrderResponse,\n QueryOrderParams,\n QueryOrderResponse,\n} from \"./order-types.ts\";\n\nimport { cjApiClient } from \"../../api-client\";\nimport { getCurrentAccessToken } from \"../access-token\";\n\ninterface ListOrderParams {\n orderIds?: string[];\n pageNum?: number;\n pageSize?: number;\n status?: string;\n}\n\nexport async function createOrder(\n orderData: CreateOrderPayload\n): Promise<APIResponse<CreateOrderResponse>> {\n try {\n const accessToken = await getCurrentAccessToken();\n const response = await cjApiClient.post<\n CJApiResponse<CreateOrderResponse>\n >(\"shopping/order/createOrderV2\", orderData, {\n headers: {\n \"CJ-Access-Token\": accessToken,\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!response.data.result) {\n return {\n error: response.data.message || \"Failed to create order\",\n };\n }\n\n if (!response.data.data) {\n return { error: \"No order created\" };\n }\n\n return { data: response.data.data };\n } catch (error: any) {\n console.error(`Error creating order [${error.code}]: ${error.message}`);\n return { error: error.message || \"An unknown error occurred\" };\n }\n}\n\nexport async function listOrders(\n accessToken: string,\n params: ListOrderParams = {}\n): Promise<APIResponse<ListOrderResponse>> {\n try {\n const response = await cjApiClient.get<\n CJApiResponse<ListOrderResponse>\n >(\"shopping/order/list\", {\n headers: {\n \"CJ-Access-Token\": accessToken,\n },\n params,\n });\n\n if (!response.data.result) {\n return {\n error: response.data.message || \"Failed to retrieve orders\",\n };\n }\n\n if (!response.data.data) {\n return { error: \"No orders found\" };\n }\n\n return { data: response.data.data };\n } catch (error: any) {\n console.error(`Error listing orders [${error.code}]: ${error.message}`);\n return { error: error.message || \"An unknown error occurred\" };\n }\n}\n\nexport async function queryOrder(\n params: QueryOrderParams\n): Promise<APIResponse<QueryOrderResponse>> {\n if (!params.orderId && !params.orderNum) {\n return { error: \"Either orderId or orderNum must be provided.\" };\n }\n\n try {\n const accessToken = await getCurrentAccessToken();\n const response = await cjApiClient.get<\n CJApiResponse<QueryOrderResponse>\n >(\"shopping/order/getOrderDetail\", {\n headers: {\n \"CJ-Access-Token\": accessToken,\n },\n params,\n });\n\n if (!response.data.result) {\n return {\n error:\n response.data.message || \"Failed to retrieve order details\",\n };\n }\n\n if (!response.data.data) {\n return { error: \"No order details found\" };\n }\n\n return { data: response.data.data };\n } catch (error: any) {\n console.error(`Error querying order [${error.code}]: ${error.message}`);\n return { error: error.message || \"An unknown error occurred\" };\n }\n}\n\nexport async function deleteOrder(\n orderId: string\n): Promise<APIResponse<{ data: string }>> {\n if (!orderId) {\n return { error: \"orderId must be provided.\" };\n }\n\n try {\n const accessToken = await getCurrentAccessToken();\n const response = await cjApiClient.delete<\n CJApiResponse<{ data: string }>\n >(\"shopping/order/deleteOrder\", {\n headers: {\n \"CJ-Access-Token\": accessToken,\n },\n params: { orderId },\n });\n\n if (!response.data.result) {\n return {\n error: response.data.message || \"Failed to delete order\",\n };\n }\n\n if (!response.data.data) {\n return { error: \"Order deletion not confirmed, no data returned\" };\n }\n\n return { data: response.data.data };\n } catch (error: any) {\n console.error(`Error deleting order [${error.code}]: ${error.message}`);\n return { error: error.message || \"An unknown error occurred\" };\n }\n}\n\nexport async function confirmOrder(\n orderId: string\n): Promise<APIResponse<string>> {\n if (!orderId) {\n return { error: \"orderId must be provided.\" };\n }\n\n try {\n const accessToken = await getCurrentAccessToken();\n const response = await cjApiClient.patch<CJApiResponse<string>>(\n \"shopping/order/confirmOrder\",\n { orderId },\n {\n headers: {\n \"CJ-Access-Token\": accessToken,\n \"Content-Type\": \"application/json\",\n },\n }\n );\n\n if (!response.data.result) {\n return {\n error: response.data.message || \"Failed to confirm order\",\n };\n }\n\n if (!response.data.data) {\n return {\n error: \"Order confirmation not confirmed, no data returned\",\n };\n }\n\n return { data: response.data.data };\n } catch (error: any) {\n console.error(\n `Error confirming order [${error.code}]: ${error.message}`\n );\n return { error: error.message || \"An unknown error occurred\" };\n }\n}\n"],"names":["cjApiClient","getCurrentAccessToken","createOrder","orderData","accessToken","response","post","headers","data","result","error","message","console","code","listOrders","params","get","queryOrder","orderId","orderNum","deleteOrder","delete","confirmOrder","patch"],"mappings":"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"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { CJApiResponse } from
|
1
|
+
import type { CJApiResponse } from "../../types";
|
2
2
|
/**
|
3
3
|
* API Request Parameters for CJ Dropshipping Product List
|
4
4
|
*/
|
@@ -144,11 +144,11 @@ export interface ProductDetails {
|
|
144
144
|
productName: string[];
|
145
145
|
productNameEn: string;
|
146
146
|
productSku: string;
|
147
|
-
productType:
|
147
|
+
productType: "ORDINARY_PRODUCT" | "PACKAGING_PRODUCT" | "SERVICE_PRODUCT" | "SUPPLIER_PRODUCT" | "SUPPLIER_SHIPPED_PRODUCT";
|
148
148
|
productUnit: string;
|
149
149
|
productWeight: number;
|
150
150
|
sellPrice: number;
|
151
|
-
status:
|
151
|
+
status: "0" | "1" | "2" | "3" | "4" | "5" | "6";
|
152
152
|
suggestSellPrice?: string;
|
153
153
|
supplierId?: string;
|
154
154
|
supplierName?: string;
|
@@ -183,4 +183,15 @@ export type ProductListResponse = CJApiResponse<{
|
|
183
183
|
* API response format for product query.
|
184
184
|
*/
|
185
185
|
export type ProductQueryResponse = CJApiResponse<ProductDetails>;
|
186
|
+
export interface StockInfo {
|
187
|
+
vid?: string;
|
188
|
+
areaId: number;
|
189
|
+
areaEn: string;
|
190
|
+
countryCode: string;
|
191
|
+
countryNameEn?: string;
|
192
|
+
storageNum?: number;
|
193
|
+
totalInventoryNum: number;
|
194
|
+
cjInventoryNum: number;
|
195
|
+
factoryInventoryNum: number;
|
196
|
+
}
|
186
197
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/sdk/products/product-types.ts"],"sourcesContent":["import type { CJApiResponse } from
|
1
|
+
{"version":3,"sources":["../../../src/sdk/products/product-types.ts"],"sourcesContent":["import type { CJApiResponse } from \"../../types\";\n\n/**\n * API Request Parameters for CJ Dropshipping Product List\n */\nexport interface ProductListParams {\n /** Brand ID filter */\n brandOpenId?: number;\n /** Category ID for filtering */\n categoryId?: string;\n /** Country code, e.g., CN, US */\n countryCode?: string;\n /** Start creation time, format: yyyy-MM-dd hh:mm:ss */\n createTimeFrom?: string;\n /** End creation time, format: yyyy-MM-dd hh:mm:ss */\n createTimeTo?: string;\n /** Delivery time in hours, values: 24, 48, 72 */\n deliveryTime?: string;\n /** Maximum inventory filter */\n endInventory?: number;\n /** Maximum listed number */\n maxListedNum?: number;\n /** Maximum price filter */\n maxPrice?: number;\n /** Minimum listed number */\n minListedNum?: number;\n /** Minimum price filter */\n minPrice?: number;\n /** Sort field: createAt/listedNum, default is createAt */\n orderBy?: string;\n /** Page number\n * @default 1\n * @example 1\n */\n pageNum?: number;\n /** Quantity of results on each page, default is 20 */\n pageSize?: number;\n /** Product ID for specific lookup */\n pid?: string;\n /** Product name for search */\n productName?: string;\n /** Product name in English */\n productNameEn?: string;\n /** Product SKU for specific lookup */\n productSku?: string;\n /** Product type, values: ORDINARY_PRODUCT, SUPPLIER_PRODUCT */\n productType?: string;\n /** Search type: 0 = All, 2 = Trending, 21 = Trending View More */\n searchType?: number;\n /** Sort order: asc/desc, default is desc */\n sort?: string;\n /** Minimum inventory filter */\n startInventory?: number;\n /** Verified inventory type: 1 = Verified, 2 = Unverified */\n verifiedWarehouse?: number;\n}\n\n/**\n * Product Data Structure\n */\nexport interface Product {\n addMarkStatus?: boolean;\n categoryId: string;\n categoryName: string;\n createTime?: string;\n isVideo?: number;\n listedNum?: number;\n listingCount?: number;\n pid: string;\n productImage: string;\n productName: string[];\n productNameEn: string;\n productSku: string;\n productType: null | string;\n productUnit: string;\n productWeight: number;\n saleStatus?: number;\n sellPrice: number;\n sourceFrom?: string;\n supplierId?: string;\n supplierName?: string;\n}\n\n/**\n * Parameters for querying product details.\n */\nexport interface ProductQueryParams {\n /** Product ID\n * @example \"000B9312-456A-4D31-94BD-B083E2A198E8\"\n */\n pid?: string;\n\n /** Product SKU\n * @example \"CJJJJTJT05843\"\n */\n productSku?: string;\n\n /** Variant SKU\n * @example \"CJJJJTJT05843-Black\"\n */\n variantSku?: string;\n}\n\n/**\n * Variant details of a product.\n */\nexport interface ProductVariant {\n createTime?: string;\n pid: string;\n variantHeight?: number;\n variantImage?: string;\n variantKey?: string;\n variantLength?: number;\n variantName?: string;\n variantNameEn: string;\n variantProperty?: string;\n variantSellPrice?: number;\n variantSku: string;\n variantStandard?: string;\n variantSugSellPrice?: number;\n variantUnit?: string;\n variantVolume?: number;\n variantWeight?: number;\n variantWidth?: number;\n vid: string;\n}\n\n/**\n * Product details.\n */\nexport interface ProductDetails {\n categoryId: string;\n categoryName: string;\n createrTime?: string;\n description?: string;\n entryCode?: string;\n entryName?: string;\n entryNameEn?: string;\n listedNum: number;\n materialKey?: string[];\n materialName?: string[];\n materialNameEn?: string[];\n packingKey?: string[];\n packingName?: string[];\n packingNameEn?: string[];\n packingWeight?: number;\n pid: string;\n productImage: string;\n productKey?: string[];\n productKeyEn?: string;\n productName: string[];\n productNameEn: string;\n productSku: string;\n productType:\n | \"ORDINARY_PRODUCT\"\n | \"PACKAGING_PRODUCT\"\n | \"SERVICE_PRODUCT\"\n | \"SUPPLIER_PRODUCT\"\n | \"SUPPLIER_SHIPPED_PRODUCT\";\n productUnit: string;\n productWeight: number;\n sellPrice: number;\n status: \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\";\n suggestSellPrice?: string;\n supplierId?: string;\n supplierName?: string;\n variants?: ProductVariant[];\n}\n\nexport interface CategoryThirdLevel {\n categoryId: string;\n categoryName: string;\n}\n\ninterface CategorySecondLevel {\n categorySecondList: CategoryThirdLevel[];\n categorySecondName: string;\n}\n\nexport interface CategoryFirstLevel {\n categoryFirstList: CategorySecondLevel[];\n categoryFirstName: string;\n}\n/**\n * API Response Structure for CJ Dropshipping Category List\n */\nexport type CategoryListResponse = CJApiResponse<CategoryFirstLevel[]>;\n\n/**\n * API Response Structure for CJ Dropshipping Product List\n */\nexport type ProductListResponse = CJApiResponse<{\n list: Product[];\n pageNum: number;\n pageSize: number;\n total: number;\n}>;\n\n/**\n * API response format for product query.\n */\nexport type ProductQueryResponse = CJApiResponse<ProductDetails>;\n\nexport interface StockInfo {\n vid?: string;\n areaId: number;\n areaEn: string;\n countryCode: string;\n countryNameEn?: string;\n storageNum?: number;\n totalInventoryNum: number;\n cjInventoryNum: number;\n factoryInventoryNum: number;\n}\n"],"names":[],"mappings":"AA2MA,WAUC"}
|
@@ -1,9 +1,15 @@
|
|
1
1
|
import type { APIResponse } from "../../error-types";
|
2
|
-
import type { CategoryFirstLevel, Product, ProductDetails } from "./product-types.ts";
|
2
|
+
import type { CategoryFirstLevel, Product, ProductDetails, StockInfo } from "./product-types.ts";
|
3
3
|
export declare function getProductCategory(accessToken: string, params: any): Promise<APIResponse<CategoryFirstLevel[]>>;
|
4
4
|
export declare function getProductList(params?: Record<string, any>): Promise<APIResponse<Product[]>>;
|
5
5
|
export declare function getProductDetails(queryParams: {
|
6
|
+
accessToken: string;
|
6
7
|
pid?: string;
|
7
8
|
productSku?: string;
|
8
9
|
variantSku?: string;
|
9
10
|
}): Promise<APIResponse<ProductDetails>>;
|
11
|
+
export declare function getProductStockByVid({ vid, accessToken, }: {
|
12
|
+
vid: string;
|
13
|
+
accessToken: string;
|
14
|
+
}): Promise<APIResponse<StockInfo[]>>;
|
15
|
+
export declare function getProductStockBySku(sku: string, accessToken: string): Promise<APIResponse<StockInfo[]>>;
|
@@ -63,14 +63,13 @@ export async function getProductList(params = {}) {
|
|
63
63
|
}
|
64
64
|
}
|
65
65
|
export async function getProductDetails(queryParams) {
|
66
|
-
const { pid, productSku, variantSku } = queryParams;
|
66
|
+
const { pid, productSku, variantSku, accessToken } = queryParams;
|
67
67
|
if (!pid && !productSku && !variantSku) {
|
68
68
|
return {
|
69
69
|
error: "One of pid, productSku, or variantSku must be provided."
|
70
70
|
};
|
71
71
|
}
|
72
72
|
try {
|
73
|
-
const accessToken = await getCurrentAccessToken();
|
74
73
|
const response = await cjApiClient.get("https://developers.cjdropshipping.com/api2.0/v1/product/query", {
|
75
74
|
headers: {
|
76
75
|
"CJ-Access-Token": accessToken
|
@@ -90,5 +89,55 @@ export async function getProductDetails(queryParams) {
|
|
90
89
|
throw new Error(error.message);
|
91
90
|
}
|
92
91
|
}
|
92
|
+
export async function getProductStockByVid({ vid, accessToken }) {
|
93
|
+
try {
|
94
|
+
const response = await cjApiClient.get("/product/stock/queryByVid", {
|
95
|
+
headers: {
|
96
|
+
"CJ-Access-Token": accessToken
|
97
|
+
},
|
98
|
+
params: {
|
99
|
+
vid
|
100
|
+
}
|
101
|
+
});
|
102
|
+
if (!response.data.result) {
|
103
|
+
return {
|
104
|
+
error: response.data.message || "Failed to fetch stock information"
|
105
|
+
};
|
106
|
+
}
|
107
|
+
return {
|
108
|
+
data: response.data.data
|
109
|
+
};
|
110
|
+
} catch (error) {
|
111
|
+
console.error(`Error fetching stock by VID [${error.code}]: ${error.message}`);
|
112
|
+
return {
|
113
|
+
error: error.message || "Failed to fetch stock information"
|
114
|
+
};
|
115
|
+
}
|
116
|
+
}
|
117
|
+
export async function getProductStockBySku(sku, accessToken) {
|
118
|
+
try {
|
119
|
+
const response = await cjApiClient.get("/product/stock/queryBySku", {
|
120
|
+
headers: {
|
121
|
+
"CJ-Access-Token": accessToken
|
122
|
+
},
|
123
|
+
params: {
|
124
|
+
sku
|
125
|
+
}
|
126
|
+
});
|
127
|
+
if (!response.data.result) {
|
128
|
+
return {
|
129
|
+
error: response.data.message || "Failed to fetch stock information"
|
130
|
+
};
|
131
|
+
}
|
132
|
+
return {
|
133
|
+
data: response.data.data
|
134
|
+
};
|
135
|
+
} catch (error) {
|
136
|
+
console.error(`Error fetching stock by SKU [${error.code}]: ${error.message}`);
|
137
|
+
return {
|
138
|
+
error: error.message || "Failed to fetch stock information"
|
139
|
+
};
|
140
|
+
}
|
141
|
+
}
|
93
142
|
|
94
143
|
//# sourceMappingURL=products.js.map
|