shopify_storefront_sdk 1.0.4 → 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/README.md +136 -70
- package/dist/cjs/client/client.js +110 -22
- package/dist/cjs/generated/shopify.js +25 -49
- package/dist/cjs/helpers/CartManager.js +55 -0
- package/dist/cjs/helpers/CustomerSession.js +41 -0
- package/dist/cjs/index.js +210 -27
- package/dist/cjs/tests/integration/sdk.test.js +266 -0
- package/dist/cjs/tests/unit/cache.test.js +86 -0
- package/dist/cjs/tests/unit/cartManager.test.js +43 -0
- package/dist/cjs/tests/unit/client.test.js +134 -0
- package/dist/cjs/tests/unit/customerSession.test.js +50 -0
- package/dist/cjs/tests/unit/pagination.test.js +41 -0
- package/dist/cjs/tests/unit/webhooks.test.js +41 -0
- package/dist/cjs/utils/cache.js +29 -0
- package/dist/cjs/utils/errors.js +53 -0
- package/dist/cjs/utils/pagination.js +30 -0
- package/dist/cjs/utils/webhooks.js +33 -0
- package/dist/client/client.d.ts +12 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +111 -21
- package/dist/client/client.js.map +1 -1
- package/dist/generated/shopify.d.ts +4048 -2764
- package/dist/generated/shopify.d.ts.map +1 -1
- package/dist/generated/shopify.js +26 -50
- package/dist/generated/shopify.js.map +1 -1
- package/dist/helpers/CartManager.d.ts +32 -0
- package/dist/helpers/CartManager.d.ts.map +1 -0
- package/dist/helpers/CartManager.js +53 -0
- package/dist/helpers/CartManager.js.map +1 -0
- package/dist/helpers/CustomerSession.d.ts +27 -0
- package/dist/helpers/CustomerSession.d.ts.map +1 -0
- package/dist/helpers/CustomerSession.js +40 -0
- package/dist/helpers/CustomerSession.js.map +1 -0
- package/dist/index.d.ts +179 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +204 -28
- package/dist/index.js.map +1 -1
- package/dist/tests/integration/sdk.test.d.ts +2 -0
- package/dist/tests/integration/sdk.test.d.ts.map +1 -0
- package/dist/tests/integration/sdk.test.js +245 -0
- package/dist/tests/integration/sdk.test.js.map +1 -0
- package/dist/tests/unit/cache.test.d.ts +2 -0
- package/dist/tests/unit/cache.test.d.ts.map +1 -0
- package/dist/tests/unit/cache.test.js +85 -0
- package/dist/tests/unit/cache.test.js.map +1 -0
- package/dist/tests/unit/cartManager.test.d.ts +2 -0
- package/dist/tests/unit/cartManager.test.d.ts.map +1 -0
- package/dist/tests/unit/cartManager.test.js +43 -0
- package/dist/tests/unit/cartManager.test.js.map +1 -0
- package/dist/tests/unit/client.test.d.ts +2 -0
- package/dist/tests/unit/client.test.d.ts.map +1 -0
- package/dist/tests/unit/client.test.js +133 -0
- package/dist/tests/unit/client.test.js.map +1 -0
- package/dist/tests/unit/customerSession.test.d.ts +2 -0
- package/dist/tests/unit/customerSession.test.d.ts.map +1 -0
- package/dist/tests/unit/customerSession.test.js +49 -0
- package/dist/tests/unit/customerSession.test.js.map +1 -0
- package/dist/tests/unit/pagination.test.d.ts +2 -0
- package/dist/tests/unit/pagination.test.d.ts.map +1 -0
- package/dist/tests/unit/pagination.test.js +40 -0
- package/dist/tests/unit/pagination.test.js.map +1 -0
- package/dist/tests/unit/webhooks.test.d.ts +2 -0
- package/dist/tests/unit/webhooks.test.d.ts.map +1 -0
- package/dist/tests/unit/webhooks.test.js +40 -0
- package/dist/tests/unit/webhooks.test.js.map +1 -0
- package/dist/utils/cache.d.ts +14 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +24 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/config.d.ts +6 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +30 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +48 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/pagination.d.ts +20 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +28 -0
- package/dist/utils/pagination.js.map +1 -0
- package/dist/utils/webhooks.d.ts +10 -0
- package/dist/utils/webhooks.d.ts.map +1 -0
- package/dist/utils/webhooks.js +31 -0
- package/dist/utils/webhooks.js.map +1 -0
- package/package.json +11 -7
- package/dist/cjs/tests/test.js +0 -201
- package/dist/tests/test.d.ts +0 -34
- package/dist/tests/test.d.ts.map +0 -1
- package/dist/tests/test.js +0 -202
- package/dist/tests/test.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface PageInfo {
|
|
2
|
+
hasNextPage: boolean;
|
|
3
|
+
endCursor?: string | null;
|
|
4
|
+
}
|
|
5
|
+
export interface Edge<TNode> {
|
|
6
|
+
node: TNode;
|
|
7
|
+
}
|
|
8
|
+
export interface Connection<TNode> {
|
|
9
|
+
edges: Edge<TNode>[];
|
|
10
|
+
pageInfo: PageInfo;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Automatically fetches all pages of a Shopify GraphQL Connection and flattens the nodes into an array.
|
|
14
|
+
*
|
|
15
|
+
* @param fetchPage A function that takes an optional cursor and returns a promise of the API response.
|
|
16
|
+
* @param getConnection A selector function that extracts the Connection object from the API response.
|
|
17
|
+
* @returns A flat array of all nodes across all pages.
|
|
18
|
+
*/
|
|
19
|
+
export declare function autoPaginate<TResponse, TNode>(fetchPage: (cursor?: string) => Promise<TResponse>, getConnection: (response: TResponse) => Connection<TNode> | undefined | null): Promise<TNode[]>;
|
|
20
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,IAAI,CAAC,KAAK;IACzB,IAAI,EAAE,KAAK,CAAC;CACb;AAED,MAAM,WAAW,UAAU,CAAC,KAAK;IAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,SAAS,EAAE,KAAK,EACjD,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,EAClD,aAAa,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,UAAU,CAAC,KAAK,CAAC,GAAG,SAAS,GAAG,IAAI,GAC3E,OAAO,CAAC,KAAK,EAAE,CAAC,CAwBlB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatically fetches all pages of a Shopify GraphQL Connection and flattens the nodes into an array.
|
|
3
|
+
*
|
|
4
|
+
* @param fetchPage A function that takes an optional cursor and returns a promise of the API response.
|
|
5
|
+
* @param getConnection A selector function that extracts the Connection object from the API response.
|
|
6
|
+
* @returns A flat array of all nodes across all pages.
|
|
7
|
+
*/
|
|
8
|
+
export async function autoPaginate(fetchPage, getConnection) {
|
|
9
|
+
const results = [];
|
|
10
|
+
let hasNextPage = true;
|
|
11
|
+
let cursor = undefined;
|
|
12
|
+
while (hasNextPage) {
|
|
13
|
+
const response = await fetchPage(cursor);
|
|
14
|
+
const connection = getConnection(response);
|
|
15
|
+
if (!connection || !connection.edges || !connection.pageInfo) {
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
for (const edge of connection.edges) {
|
|
19
|
+
if (edge && edge.node) {
|
|
20
|
+
results.push(edge.node);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
hasNextPage = connection.pageInfo.hasNextPage;
|
|
24
|
+
cursor = connection.pageInfo.endCursor || undefined;
|
|
25
|
+
}
|
|
26
|
+
return results;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/utils/pagination.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,SAAkD,EAClD,aAA4E;IAE5E,MAAM,OAAO,GAAY,EAAE,CAAC;IAC5B,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,IAAI,MAAM,GAAuB,SAAS,CAAC;IAE3C,OAAO,WAAW,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;QAE3C,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;YAC7D,MAAM;QACR,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;YACpC,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC9C,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,SAAS,IAAI,SAAS,CAAC;IACtD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies a Shopify webhook's HMAC signature.
|
|
3
|
+
*
|
|
4
|
+
* @param rawBody The raw, unparsed request body string or buffer.
|
|
5
|
+
* @param hmacHeader The `x-shopify-hmac-sha256` header provided by Shopify.
|
|
6
|
+
* @param secret Your Shopify app or storefront webhook API secret.
|
|
7
|
+
* @returns A boolean indicating whether the webhook signature is valid.
|
|
8
|
+
*/
|
|
9
|
+
export declare function verifyWebhook(rawBody: string | Buffer, hmacHeader: string, secret: string): boolean;
|
|
10
|
+
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/utils/webhooks.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAuBnG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* Verifies a Shopify webhook's HMAC signature.
|
|
4
|
+
*
|
|
5
|
+
* @param rawBody The raw, unparsed request body string or buffer.
|
|
6
|
+
* @param hmacHeader The `x-shopify-hmac-sha256` header provided by Shopify.
|
|
7
|
+
* @param secret Your Shopify app or storefront webhook API secret.
|
|
8
|
+
* @returns A boolean indicating whether the webhook signature is valid.
|
|
9
|
+
*/
|
|
10
|
+
export function verifyWebhook(rawBody, hmacHeader, secret) {
|
|
11
|
+
if (!rawBody || !hmacHeader || !secret) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const generatedHash = crypto
|
|
16
|
+
.createHmac("sha256", secret)
|
|
17
|
+
.update(rawBody)
|
|
18
|
+
.digest("base64");
|
|
19
|
+
const generatedBuffer = Buffer.from(generatedHash);
|
|
20
|
+
const hmacBuffer = Buffer.from(hmacHeader);
|
|
21
|
+
// Use timingSafeEqual to prevent timing attacks
|
|
22
|
+
if (generatedBuffer.length !== hmacBuffer.length) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return crypto.timingSafeEqual(generatedBuffer, hmacBuffer);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/utils/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,OAAwB,EAAE,UAAkB,EAAE,MAAc;IACxF,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,MAAM;aACzB,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC;aAC5B,MAAM,CAAC,OAAO,CAAC;aACf,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEpB,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACnD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAE3C,gDAAgD;QAChD,IAAI,eAAe,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;YACjD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,MAAM,CAAC,eAAe,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shopify_storefront_sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"main": "cjs-wrapper.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,12 +22,14 @@
|
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"scripts": {
|
|
24
24
|
"clean": "rimraf dist",
|
|
25
|
-
"dev": "node --loader ts-node/esm src/tests/test.ts",
|
|
25
|
+
"dev": "node --loader ts-node/esm src/tests/integration/sdk.test.ts",
|
|
26
26
|
"build": "rimraf dist && npm run build:esm && npm run build:cjs",
|
|
27
27
|
"build:esm": "tsc --project tsconfig.json",
|
|
28
28
|
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
29
|
-
"
|
|
30
|
-
"test": "
|
|
29
|
+
"build:docs": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:unit": "vitest run src/tests/unit",
|
|
32
|
+
"test:integration": "vitest run src/tests/integration",
|
|
31
33
|
"codegen": "graphql-codegen --config codegen.yml",
|
|
32
34
|
"prepare": "npm run build"
|
|
33
35
|
},
|
|
@@ -58,10 +60,12 @@
|
|
|
58
60
|
"@graphql-codegen/typescript": "^5.0.5",
|
|
59
61
|
"@graphql-codegen/typescript-graphql-request": "^6.3.0",
|
|
60
62
|
"@graphql-codegen/typescript-operations": "^5.0.5",
|
|
61
|
-
"@types/node": "^24.
|
|
62
|
-
"axios": "^1.13.2",
|
|
63
|
+
"@types/node": "^24.13.3",
|
|
63
64
|
"ts-node": "^10.9.2",
|
|
64
|
-
"
|
|
65
|
+
"typedoc": "^0.28.20",
|
|
66
|
+
"typedoc-plugin-markdown": "^4.13.0",
|
|
67
|
+
"typescript": "^5.9.3",
|
|
68
|
+
"vitest": "^4.1.11"
|
|
65
69
|
},
|
|
66
70
|
"dependencies": {
|
|
67
71
|
"dotenv": "^17.2.3",
|
package/dist/cjs/tests/test.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ========================= SHOPIFY SDK TEST GUIDE =========================
|
|
4
|
-
*
|
|
5
|
-
* To run tests successfully, ensure the following:
|
|
6
|
-
*
|
|
7
|
-
* 1. Your `.env` file contains:
|
|
8
|
-
* - SHOPIFY_STORE_DOMAIN
|
|
9
|
-
* - SHOPIFY_STOREFRONT_TOKEN
|
|
10
|
-
*
|
|
11
|
-
* 2. Your Shopify store has at least one published product.
|
|
12
|
-
*
|
|
13
|
-
* 3. You have an active internet connection.
|
|
14
|
-
*
|
|
15
|
-
* ---------------------------------------------------------------------------
|
|
16
|
-
* ABOUT THIS SDK
|
|
17
|
-
* ---------------------------------------------------------------------------
|
|
18
|
-
*
|
|
19
|
-
* This Node.js Shopify Storefront SDK is designed to help developers build
|
|
20
|
-
* storefront applications faster by providing:
|
|
21
|
-
*
|
|
22
|
-
* - Pre-built GraphQL queries for common Shopify operations
|
|
23
|
-
* (products, collections, carts, customer creation, blogs, articles, and more)
|
|
24
|
-
* - A clean, strongly-typed API wrapper
|
|
25
|
-
* - Automatic request handling + improved developer experience
|
|
26
|
-
*
|
|
27
|
-
* Using this SDK can speed up development by up to **30%**, reduce boilerplate,
|
|
28
|
-
* and simplify communication with Shopify Storefront API.
|
|
29
|
-
*
|
|
30
|
-
* ---------------------------------------------------------------------------
|
|
31
|
-
* This test file demonstrates how to use the SDK in real-world scenarios.
|
|
32
|
-
* ============================================================================
|
|
33
|
-
*/
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
const index_js_1 = require("../index.js");
|
|
36
|
-
const dotenv = require("dotenv");
|
|
37
|
-
dotenv.config();
|
|
38
|
-
const { SHOPIFY_STORE_DOMAIN, SHOPIFY_STOREFRONT_TOKEN } = process.env;
|
|
39
|
-
// Instantiate the SDK once
|
|
40
|
-
const client = new index_js_1.default({
|
|
41
|
-
storeUrl: String(SHOPIFY_STORE_DOMAIN),
|
|
42
|
-
storefrontToken: String(SHOPIFY_STOREFRONT_TOKEN),
|
|
43
|
-
});
|
|
44
|
-
// Test function
|
|
45
|
-
async function runTests() {
|
|
46
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49;
|
|
47
|
-
try {
|
|
48
|
-
/**
|
|
49
|
-
* the Products method gives access to enter the amount of data you need. it includes first, last,after, before and query
|
|
50
|
-
*/
|
|
51
|
-
console.log("\n===== TEST → getProducts() =====");
|
|
52
|
-
const products = await client.getProducts({ first: 10 });
|
|
53
|
-
console.log(JSON.stringify(products, null, 2));
|
|
54
|
-
console.log("\n===== TEST → getProductById() =====");
|
|
55
|
-
const product = await client.getProductById({
|
|
56
|
-
id: (_d = (_c = (_b = (_a = products === null || products === void 0 ? void 0 : products.products) === null || _a === void 0 ? void 0 : _a.edges[0]) === null || _b === void 0 ? void 0 : _b.node) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : "",
|
|
57
|
-
metafields: [],
|
|
58
|
-
});
|
|
59
|
-
console.log(JSON.stringify(product, null, 2));
|
|
60
|
-
console.log("\n===== TEST → getProductByHandle() =====");
|
|
61
|
-
const byHandle = await client.getProductByHandle({
|
|
62
|
-
handle: (_h = (_g = (_f = (_e = products === null || products === void 0 ? void 0 : products.products) === null || _e === void 0 ? void 0 : _e.edges[0]) === null || _f === void 0 ? void 0 : _f.node) === null || _g === void 0 ? void 0 : _g.handle) !== null && _h !== void 0 ? _h : "",
|
|
63
|
-
});
|
|
64
|
-
console.log(JSON.stringify(byHandle, null, 2));
|
|
65
|
-
console.log("\n===== TEST → getAllProductType() =====");
|
|
66
|
-
const types = await client.getAllProductType({ first: 50 });
|
|
67
|
-
console.log(JSON.stringify(types, null, 2));
|
|
68
|
-
console.log("\n===== TEST → getProductTags() =====");
|
|
69
|
-
const productRecommendations = await client.getProductRecommendations({
|
|
70
|
-
productId: (_m = (_l = (_k = (_j = products === null || products === void 0 ? void 0 : products.products) === null || _j === void 0 ? void 0 : _j.edges[0]) === null || _k === void 0 ? void 0 : _k.node) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : "",
|
|
71
|
-
});
|
|
72
|
-
console.log(JSON.stringify(productRecommendations, null, 2));
|
|
73
|
-
console.log("\n===== TEST → getBlogs() =====");
|
|
74
|
-
const blogs = await client.getBlogs({ first: 10 });
|
|
75
|
-
console.log(JSON.stringify(blogs, null, 2));
|
|
76
|
-
console.log("\n===== TEST → getBlogByHandle() =====");
|
|
77
|
-
const blog = await client.getBlog({
|
|
78
|
-
first: 10,
|
|
79
|
-
handle: (_r = (_q = (_p = (_o = blogs === null || blogs === void 0 ? void 0 : blogs.blogs) === null || _o === void 0 ? void 0 : _o.edges[0]) === null || _p === void 0 ? void 0 : _p.node) === null || _q === void 0 ? void 0 : _q.handle) !== null && _r !== void 0 ? _r : "",
|
|
80
|
-
});
|
|
81
|
-
console.log(JSON.stringify(blogs, null, 2));
|
|
82
|
-
console.log("\n===== TEST → getArticles() =====");
|
|
83
|
-
const articles = await client.getArticles({ first: 10 });
|
|
84
|
-
console.log(JSON.stringify(articles, null, 2));
|
|
85
|
-
console.log("\n===== TEST → getArticles() =====");
|
|
86
|
-
const article = await client.getArticle({
|
|
87
|
-
blogHandle: (_v = (_u = (_t = (_s = blogs === null || blogs === void 0 ? void 0 : blogs.blogs) === null || _s === void 0 ? void 0 : _s.edges[0]) === null || _t === void 0 ? void 0 : _t.node) === null || _u === void 0 ? void 0 : _u.handle) !== null && _v !== void 0 ? _v : "",
|
|
88
|
-
articleHandle: (_z = (_y = (_x = (_w = articles === null || articles === void 0 ? void 0 : articles.articles) === null || _w === void 0 ? void 0 : _w.edges[0]) === null || _x === void 0 ? void 0 : _x.node) === null || _y === void 0 ? void 0 : _y.handle) !== null && _z !== void 0 ? _z : "",
|
|
89
|
-
});
|
|
90
|
-
console.log(JSON.stringify(article, null, 2));
|
|
91
|
-
console.log("\n===== TEST → userCreate() =====");
|
|
92
|
-
const user = await client.createUser({
|
|
93
|
-
email: "testuser@example.com",
|
|
94
|
-
password: "Testing123!",
|
|
95
|
-
firstName: "SDK",
|
|
96
|
-
lastName: "User",
|
|
97
|
-
phone: "00000000000",
|
|
98
|
-
});
|
|
99
|
-
console.log(JSON.stringify(user, null, 2));
|
|
100
|
-
console.log("\n===== TEST → userLogin() =====");
|
|
101
|
-
const userLogin = await client.loginUser({
|
|
102
|
-
email: "testuser@example.com",
|
|
103
|
-
password: "Testing123!",
|
|
104
|
-
});
|
|
105
|
-
console.log(JSON.stringify(userLogin, null, 2));
|
|
106
|
-
console.log("\n===== TEST → userLoginTokenVerify() =====");
|
|
107
|
-
const userLoginTokenVerify = await client.verifyUserToken({
|
|
108
|
-
token: String((_1 = (_0 = userLogin === null || userLogin === void 0 ? void 0 : userLogin.customerAccessTokenCreate) === null || _0 === void 0 ? void 0 : _0.customerAccessToken) === null || _1 === void 0 ? void 0 : _1.accessToken),
|
|
109
|
-
});
|
|
110
|
-
console.log(JSON.stringify(userLoginTokenVerify, null, 2));
|
|
111
|
-
console.log("\n===== TEST → cartCreate() =====");
|
|
112
|
-
const cart = await client.createCart({
|
|
113
|
-
input: {
|
|
114
|
-
lines: [
|
|
115
|
-
{
|
|
116
|
-
quantity: 1,
|
|
117
|
-
merchandiseId: (_8 = (_7 = (_6 = (_5 = (_4 = (_3 = (_2 = products === null || products === void 0 ? void 0 : products.products) === null || _2 === void 0 ? void 0 : _2.edges[0]) === null || _3 === void 0 ? void 0 : _3.node) === null || _4 === void 0 ? void 0 : _4.variants) === null || _5 === void 0 ? void 0 : _5.edges[0]) === null || _6 === void 0 ? void 0 : _6.node) === null || _7 === void 0 ? void 0 : _7.id) !== null && _8 !== void 0 ? _8 : "",
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
first: 20,
|
|
122
|
-
});
|
|
123
|
-
console.log(JSON.stringify(cart, null, 2));
|
|
124
|
-
console.log("\n===== TEST → cartBuyerIdentity() =====");
|
|
125
|
-
const buyerIdentity = await client.cartBuyerIdentityUpdate({
|
|
126
|
-
cartId: String((_10 = (_9 = cart === null || cart === void 0 ? void 0 : cart.cartCreate) === null || _9 === void 0 ? void 0 : _9.cart) === null || _10 === void 0 ? void 0 : _10.id),
|
|
127
|
-
buyerIdentity: {
|
|
128
|
-
customerAccessToken: (_13 = (_12 = (_11 = userLogin === null || userLogin === void 0 ? void 0 : userLogin.customerAccessTokenCreate) === null || _11 === void 0 ? void 0 : _11.customerAccessToken) === null || _12 === void 0 ? void 0 : _12.accessToken) !== null && _13 !== void 0 ? _13 : "",
|
|
129
|
-
email: (_15 = (_14 = userLoginTokenVerify === null || userLoginTokenVerify === void 0 ? void 0 : userLoginTokenVerify.customer) === null || _14 === void 0 ? void 0 : _14.email) !== null && _15 !== void 0 ? _15 : "",
|
|
130
|
-
phone: (_17 = (_16 = userLoginTokenVerify === null || userLoginTokenVerify === void 0 ? void 0 : userLoginTokenVerify.customer) === null || _16 === void 0 ? void 0 : _16.phone) !== null && _17 !== void 0 ? _17 : "",
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
console.log(JSON.stringify(buyerIdentity, null, 2));
|
|
134
|
-
console.log("\n===== TEST → getCart() =====");
|
|
135
|
-
const existingCart = await client.getCart({
|
|
136
|
-
cartId: String((_19 = (_18 = cart === null || cart === void 0 ? void 0 : cart.cartCreate) === null || _18 === void 0 ? void 0 : _18.cart) === null || _19 === void 0 ? void 0 : _19.id),
|
|
137
|
-
first: 20,
|
|
138
|
-
});
|
|
139
|
-
console.log(JSON.stringify(existingCart, null, 2));
|
|
140
|
-
console.log("\n===== TEST → CartLineAdd() =====");
|
|
141
|
-
const addToCart = await client.cartLinesAdd({
|
|
142
|
-
cartId: String((_21 = (_20 = cart === null || cart === void 0 ? void 0 : cart.cartCreate) === null || _20 === void 0 ? void 0 : _20.cart) === null || _21 === void 0 ? void 0 : _21.id),
|
|
143
|
-
lines: [
|
|
144
|
-
{
|
|
145
|
-
quantity: 1,
|
|
146
|
-
merchandiseId: (_28 = (_27 = (_26 = (_25 = (_24 = (_23 = (_22 = products === null || products === void 0 ? void 0 : products.products) === null || _22 === void 0 ? void 0 : _22.edges[0]) === null || _23 === void 0 ? void 0 : _23.node) === null || _24 === void 0 ? void 0 : _24.variants) === null || _25 === void 0 ? void 0 : _25.edges[0]) === null || _26 === void 0 ? void 0 : _26.node) === null || _27 === void 0 ? void 0 : _27.id) !== null && _28 !== void 0 ? _28 : "",
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
});
|
|
150
|
-
console.log(JSON.stringify(addToCart, null, 2));
|
|
151
|
-
console.log("\n===== TEST → CartLineUpdate() =====");
|
|
152
|
-
const updatedCart = await client.cartLinesUpdate({
|
|
153
|
-
cartId: String((_30 = (_29 = cart === null || cart === void 0 ? void 0 : cart.cartCreate) === null || _29 === void 0 ? void 0 : _29.cart) === null || _30 === void 0 ? void 0 : _30.id),
|
|
154
|
-
first: 20,
|
|
155
|
-
lines: [
|
|
156
|
-
{
|
|
157
|
-
quantity: 2,
|
|
158
|
-
merchandiseId: (_36 = (_35 = (_34 = (_33 = (_32 = (_31 = existingCart === null || existingCart === void 0 ? void 0 : existingCart.cart) === null || _31 === void 0 ? void 0 : _31.lines) === null || _32 === void 0 ? void 0 : _32.edges[0]) === null || _33 === void 0 ? void 0 : _33.node) === null || _34 === void 0 ? void 0 : _34.merchandise) === null || _35 === void 0 ? void 0 : _35.id) !== null && _36 !== void 0 ? _36 : "",
|
|
159
|
-
id: (_41 = (_40 = (_39 = (_38 = (_37 = existingCart === null || existingCart === void 0 ? void 0 : existingCart.cart) === null || _37 === void 0 ? void 0 : _37.lines) === null || _38 === void 0 ? void 0 : _38.edges[0]) === null || _39 === void 0 ? void 0 : _39.node) === null || _40 === void 0 ? void 0 : _40.id) !== null && _41 !== void 0 ? _41 : "",
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
});
|
|
163
|
-
console.log(JSON.stringify(updatedCart, null, 2));
|
|
164
|
-
console.log("\n===== TEST → CartLineRemove() =====");
|
|
165
|
-
const removeFromCart = await client.cartLinesRemove({
|
|
166
|
-
cartId: String((_43 = (_42 = cart === null || cart === void 0 ? void 0 : cart.cartCreate) === null || _42 === void 0 ? void 0 : _42.cart) === null || _43 === void 0 ? void 0 : _43.id),
|
|
167
|
-
lineIds: [String((_47 = (_46 = (_45 = (_44 = existingCart === null || existingCart === void 0 ? void 0 : existingCart.cart) === null || _44 === void 0 ? void 0 : _44.lines) === null || _45 === void 0 ? void 0 : _45.edges[0]) === null || _46 === void 0 ? void 0 : _46.node) === null || _47 === void 0 ? void 0 : _47.id)],
|
|
168
|
-
});
|
|
169
|
-
console.log(JSON.stringify(removeFromCart, null, 2));
|
|
170
|
-
console.log("\n===== TEST → requestPasswordReset() =====");
|
|
171
|
-
const resetReq = await client.customerRecover({
|
|
172
|
-
email: "testuser@example.com",
|
|
173
|
-
});
|
|
174
|
-
console.log(JSON.stringify(resetReq, null, 2));
|
|
175
|
-
console.log("\n===== TEST → customerOrderList() =====");
|
|
176
|
-
const orderList = await client.getCustomerOrders({
|
|
177
|
-
customerAccessToken: String((_49 = (_48 = userLogin === null || userLogin === void 0 ? void 0 : userLogin.customerAccessTokenCreate) === null || _48 === void 0 ? void 0 : _48.customerAccessToken) === null || _49 === void 0 ? void 0 : _49.accessToken),
|
|
178
|
-
first: 50,
|
|
179
|
-
});
|
|
180
|
-
console.log(JSON.stringify(orderList, null, 2));
|
|
181
|
-
console.log("\n===== TEST → customeQuery() =====");
|
|
182
|
-
const customQuery = await client.customQuery(`query getShopInfo {
|
|
183
|
-
shop {
|
|
184
|
-
name
|
|
185
|
-
description
|
|
186
|
-
paymentSettings {
|
|
187
|
-
currencyCode
|
|
188
|
-
countryCode
|
|
189
|
-
enabledPresentmentCurrencies
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}`, {});
|
|
193
|
-
console.log(JSON.stringify(customQuery, null, 2));
|
|
194
|
-
console.log("Test completed successfully");
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
console.error("\n❌ TEST ERROR:");
|
|
198
|
-
console.error(error);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
runTests();
|
package/dist/tests/test.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ========================= SHOPIFY SDK TEST GUIDE =========================
|
|
3
|
-
*
|
|
4
|
-
* To run tests successfully, ensure the following:
|
|
5
|
-
*
|
|
6
|
-
* 1. Your `.env` file contains:
|
|
7
|
-
* - SHOPIFY_STORE_DOMAIN
|
|
8
|
-
* - SHOPIFY_STOREFRONT_TOKEN
|
|
9
|
-
*
|
|
10
|
-
* 2. Your Shopify store has at least one published product.
|
|
11
|
-
*
|
|
12
|
-
* 3. You have an active internet connection.
|
|
13
|
-
*
|
|
14
|
-
* ---------------------------------------------------------------------------
|
|
15
|
-
* ABOUT THIS SDK
|
|
16
|
-
* ---------------------------------------------------------------------------
|
|
17
|
-
*
|
|
18
|
-
* This Node.js Shopify Storefront SDK is designed to help developers build
|
|
19
|
-
* storefront applications faster by providing:
|
|
20
|
-
*
|
|
21
|
-
* - Pre-built GraphQL queries for common Shopify operations
|
|
22
|
-
* (products, collections, carts, customer creation, blogs, articles, and more)
|
|
23
|
-
* - A clean, strongly-typed API wrapper
|
|
24
|
-
* - Automatic request handling + improved developer experience
|
|
25
|
-
*
|
|
26
|
-
* Using this SDK can speed up development by up to **30%**, reduce boilerplate,
|
|
27
|
-
* and simplify communication with Shopify Storefront API.
|
|
28
|
-
*
|
|
29
|
-
* ---------------------------------------------------------------------------
|
|
30
|
-
* This test file demonstrates how to use the SDK in real-world scenarios.
|
|
31
|
-
* ============================================================================
|
|
32
|
-
*/
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=test.d.ts.map
|
package/dist/tests/test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/tests/test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG"}
|
package/dist/tests/test.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ========================= SHOPIFY SDK TEST GUIDE =========================
|
|
3
|
-
*
|
|
4
|
-
* To run tests successfully, ensure the following:
|
|
5
|
-
*
|
|
6
|
-
* 1. Your `.env` file contains:
|
|
7
|
-
* - SHOPIFY_STORE_DOMAIN
|
|
8
|
-
* - SHOPIFY_STOREFRONT_TOKEN
|
|
9
|
-
*
|
|
10
|
-
* 2. Your Shopify store has at least one published product.
|
|
11
|
-
*
|
|
12
|
-
* 3. You have an active internet connection.
|
|
13
|
-
*
|
|
14
|
-
* ---------------------------------------------------------------------------
|
|
15
|
-
* ABOUT THIS SDK
|
|
16
|
-
* ---------------------------------------------------------------------------
|
|
17
|
-
*
|
|
18
|
-
* This Node.js Shopify Storefront SDK is designed to help developers build
|
|
19
|
-
* storefront applications faster by providing:
|
|
20
|
-
*
|
|
21
|
-
* - Pre-built GraphQL queries for common Shopify operations
|
|
22
|
-
* (products, collections, carts, customer creation, blogs, articles, and more)
|
|
23
|
-
* - A clean, strongly-typed API wrapper
|
|
24
|
-
* - Automatic request handling + improved developer experience
|
|
25
|
-
*
|
|
26
|
-
* Using this SDK can speed up development by up to **30%**, reduce boilerplate,
|
|
27
|
-
* and simplify communication with Shopify Storefront API.
|
|
28
|
-
*
|
|
29
|
-
* ---------------------------------------------------------------------------
|
|
30
|
-
* This test file demonstrates how to use the SDK in real-world scenarios.
|
|
31
|
-
* ============================================================================
|
|
32
|
-
*/
|
|
33
|
-
import ShopifyStoreFront from "../index.js";
|
|
34
|
-
import * as dotenv from "dotenv";
|
|
35
|
-
dotenv.config();
|
|
36
|
-
const { SHOPIFY_STORE_DOMAIN, SHOPIFY_STOREFRONT_TOKEN } = process.env;
|
|
37
|
-
// Instantiate the SDK once
|
|
38
|
-
const client = new ShopifyStoreFront({
|
|
39
|
-
storeUrl: String(SHOPIFY_STORE_DOMAIN),
|
|
40
|
-
storefrontToken: String(SHOPIFY_STOREFRONT_TOKEN),
|
|
41
|
-
});
|
|
42
|
-
// Test function
|
|
43
|
-
async function runTests() {
|
|
44
|
-
try {
|
|
45
|
-
/**
|
|
46
|
-
* the Products method gives access to enter the amount of data you need. it includes first, last,after, before and query
|
|
47
|
-
*/
|
|
48
|
-
console.log("\n===== TEST → getProducts() =====");
|
|
49
|
-
const products = await client.getProducts({ first: 10 });
|
|
50
|
-
console.log(JSON.stringify(products, null, 2));
|
|
51
|
-
console.log("\n===== TEST → getProductById() =====");
|
|
52
|
-
const product = await client.getProductById({
|
|
53
|
-
id: products?.products?.edges[0]?.node?.id ?? "",
|
|
54
|
-
metafields: [],
|
|
55
|
-
});
|
|
56
|
-
console.log(JSON.stringify(product, null, 2));
|
|
57
|
-
console.log("\n===== TEST → getProductByHandle() =====");
|
|
58
|
-
const byHandle = await client.getProductByHandle({
|
|
59
|
-
handle: products?.products?.edges[0]?.node?.handle ?? "",
|
|
60
|
-
});
|
|
61
|
-
console.log(JSON.stringify(byHandle, null, 2));
|
|
62
|
-
console.log("\n===== TEST → getAllProductType() =====");
|
|
63
|
-
const types = await client.getAllProductType({ first: 50 });
|
|
64
|
-
console.log(JSON.stringify(types, null, 2));
|
|
65
|
-
console.log("\n===== TEST → getProductTags() =====");
|
|
66
|
-
const productRecommendations = await client.getProductRecommendations({
|
|
67
|
-
productId: products?.products?.edges[0]?.node?.id ?? "",
|
|
68
|
-
});
|
|
69
|
-
console.log(JSON.stringify(productRecommendations, null, 2));
|
|
70
|
-
console.log("\n===== TEST → getBlogs() =====");
|
|
71
|
-
const blogs = await client.getBlogs({ first: 10 });
|
|
72
|
-
console.log(JSON.stringify(blogs, null, 2));
|
|
73
|
-
console.log("\n===== TEST → getBlogByHandle() =====");
|
|
74
|
-
const blog = await client.getBlog({
|
|
75
|
-
first: 10,
|
|
76
|
-
handle: blogs?.blogs?.edges[0]?.node?.handle ?? "",
|
|
77
|
-
});
|
|
78
|
-
console.log(JSON.stringify(blogs, null, 2));
|
|
79
|
-
console.log("\n===== TEST → getArticles() =====");
|
|
80
|
-
const articles = await client.getArticles({ first: 10 });
|
|
81
|
-
console.log(JSON.stringify(articles, null, 2));
|
|
82
|
-
console.log("\n===== TEST → getArticles() =====");
|
|
83
|
-
const article = await client.getArticle({
|
|
84
|
-
blogHandle: blogs?.blogs?.edges[0]?.node?.handle ?? "",
|
|
85
|
-
articleHandle: articles?.articles?.edges[0]?.node?.handle ?? "",
|
|
86
|
-
});
|
|
87
|
-
console.log(JSON.stringify(article, null, 2));
|
|
88
|
-
console.log("\n===== TEST → userCreate() =====");
|
|
89
|
-
const user = await client.createUser({
|
|
90
|
-
email: "testuser@example.com",
|
|
91
|
-
password: "Testing123!",
|
|
92
|
-
firstName: "SDK",
|
|
93
|
-
lastName: "User",
|
|
94
|
-
phone: "00000000000",
|
|
95
|
-
});
|
|
96
|
-
console.log(JSON.stringify(user, null, 2));
|
|
97
|
-
console.log("\n===== TEST → userLogin() =====");
|
|
98
|
-
const userLogin = await client.loginUser({
|
|
99
|
-
email: "testuser@example.com",
|
|
100
|
-
password: "Testing123!",
|
|
101
|
-
});
|
|
102
|
-
console.log(JSON.stringify(userLogin, null, 2));
|
|
103
|
-
console.log("\n===== TEST → userLoginTokenVerify() =====");
|
|
104
|
-
const userLoginTokenVerify = await client.verifyUserToken({
|
|
105
|
-
token: String(userLogin?.customerAccessTokenCreate?.customerAccessToken?.accessToken),
|
|
106
|
-
});
|
|
107
|
-
console.log(JSON.stringify(userLoginTokenVerify, null, 2));
|
|
108
|
-
console.log("\n===== TEST → cartCreate() =====");
|
|
109
|
-
const cart = await client.createCart({
|
|
110
|
-
input: {
|
|
111
|
-
lines: [
|
|
112
|
-
{
|
|
113
|
-
quantity: 1,
|
|
114
|
-
merchandiseId: products?.products?.edges[0]?.node?.variants?.edges[0]?.node
|
|
115
|
-
?.id ?? "",
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
},
|
|
119
|
-
first: 20,
|
|
120
|
-
});
|
|
121
|
-
console.log(JSON.stringify(cart, null, 2));
|
|
122
|
-
console.log("\n===== TEST → cartBuyerIdentity() =====");
|
|
123
|
-
const buyerIdentity = await client.cartBuyerIdentityUpdate({
|
|
124
|
-
cartId: String(cart?.cartCreate?.cart?.id),
|
|
125
|
-
buyerIdentity: {
|
|
126
|
-
customerAccessToken: userLogin?.customerAccessTokenCreate?.customerAccessToken
|
|
127
|
-
?.accessToken ?? "",
|
|
128
|
-
email: userLoginTokenVerify?.customer?.email ?? "",
|
|
129
|
-
phone: userLoginTokenVerify?.customer?.phone ?? "",
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
console.log(JSON.stringify(buyerIdentity, null, 2));
|
|
133
|
-
console.log("\n===== TEST → getCart() =====");
|
|
134
|
-
const existingCart = await client.getCart({
|
|
135
|
-
cartId: String(cart?.cartCreate?.cart?.id),
|
|
136
|
-
first: 20,
|
|
137
|
-
});
|
|
138
|
-
console.log(JSON.stringify(existingCart, null, 2));
|
|
139
|
-
console.log("\n===== TEST → CartLineAdd() =====");
|
|
140
|
-
const addToCart = await client.cartLinesAdd({
|
|
141
|
-
cartId: String(cart?.cartCreate?.cart?.id),
|
|
142
|
-
lines: [
|
|
143
|
-
{
|
|
144
|
-
quantity: 1,
|
|
145
|
-
merchandiseId: products?.products?.edges[0]?.node?.variants?.edges[0]?.node?.id ??
|
|
146
|
-
"",
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
});
|
|
150
|
-
console.log(JSON.stringify(addToCart, null, 2));
|
|
151
|
-
console.log("\n===== TEST → CartLineUpdate() =====");
|
|
152
|
-
const updatedCart = await client.cartLinesUpdate({
|
|
153
|
-
cartId: String(cart?.cartCreate?.cart?.id),
|
|
154
|
-
first: 20,
|
|
155
|
-
lines: [
|
|
156
|
-
{
|
|
157
|
-
quantity: 2,
|
|
158
|
-
merchandiseId: existingCart?.cart?.lines?.edges[0]?.node?.merchandise?.id ?? "",
|
|
159
|
-
id: existingCart?.cart?.lines?.edges[0]?.node?.id ?? "",
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
});
|
|
163
|
-
console.log(JSON.stringify(updatedCart, null, 2));
|
|
164
|
-
console.log("\n===== TEST → CartLineRemove() =====");
|
|
165
|
-
const removeFromCart = await client.cartLinesRemove({
|
|
166
|
-
cartId: String(cart?.cartCreate?.cart?.id),
|
|
167
|
-
lineIds: [String(existingCart?.cart?.lines?.edges[0]?.node?.id)],
|
|
168
|
-
});
|
|
169
|
-
console.log(JSON.stringify(removeFromCart, null, 2));
|
|
170
|
-
console.log("\n===== TEST → requestPasswordReset() =====");
|
|
171
|
-
const resetReq = await client.customerRecover({
|
|
172
|
-
email: "testuser@example.com",
|
|
173
|
-
});
|
|
174
|
-
console.log(JSON.stringify(resetReq, null, 2));
|
|
175
|
-
console.log("\n===== TEST → customerOrderList() =====");
|
|
176
|
-
const orderList = await client.getCustomerOrders({
|
|
177
|
-
customerAccessToken: String(userLogin?.customerAccessTokenCreate?.customerAccessToken?.accessToken),
|
|
178
|
-
first: 50,
|
|
179
|
-
});
|
|
180
|
-
console.log(JSON.stringify(orderList, null, 2));
|
|
181
|
-
console.log("\n===== TEST → customeQuery() =====");
|
|
182
|
-
const customQuery = await client.customQuery(`query getShopInfo {
|
|
183
|
-
shop {
|
|
184
|
-
name
|
|
185
|
-
description
|
|
186
|
-
paymentSettings {
|
|
187
|
-
currencyCode
|
|
188
|
-
countryCode
|
|
189
|
-
enabledPresentmentCurrencies
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}`, {});
|
|
193
|
-
console.log(JSON.stringify(customQuery, null, 2));
|
|
194
|
-
console.log("Test completed successfully");
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
console.error("\n❌ TEST ERROR:");
|
|
198
|
-
console.error(error);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
runTests();
|
|
202
|
-
//# sourceMappingURL=test.js.map
|
package/dist/tests/test.js.map
DELETED
|
@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