@pintahub/shopify-api 2.5.7 → 2.5.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/classes/ShopAppAPI.d.ts +10 -0
- package/dist/classes/ShopAppAPI.js +62 -0
- package/dist/classes/shop/graphql/StoreReviews.d.ts +1 -0
- package/dist/classes/shop/graphql/StoreReviews.js +82 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/ShopAppOptions.d.ts +4 -0
- package/dist/interfaces/ShopAppOptions.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ShopAppOptions } from "../interfaces/ShopAppOptions";
|
|
2
|
+
export declare class ShopAppAPI {
|
|
3
|
+
private readonly options;
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(options: ShopAppOptions);
|
|
6
|
+
private _createClient;
|
|
7
|
+
getReviews(): Promise<{
|
|
8
|
+
items: any[];
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ShopAppAPI = void 0;
|
|
13
|
+
const axios_1 = require("axios");
|
|
14
|
+
const StoreReviews_1 = require("./shop/graphql/StoreReviews");
|
|
15
|
+
class ShopAppAPI {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.client = this._createClient();
|
|
19
|
+
}
|
|
20
|
+
_createClient() {
|
|
21
|
+
const { cookies } = this.options;
|
|
22
|
+
const url = `https://shop.app`;
|
|
23
|
+
return axios_1.default.create({
|
|
24
|
+
baseURL: url,
|
|
25
|
+
headers: {
|
|
26
|
+
cookie: cookies,
|
|
27
|
+
'x-user-agent': 'ShopWeb desktop',
|
|
28
|
+
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36',
|
|
29
|
+
},
|
|
30
|
+
responseType: 'json',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getReviews() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
const variables = {
|
|
37
|
+
"first": 10,
|
|
38
|
+
"shopId": this.options.shop_id,
|
|
39
|
+
"sortBy": "DATE_DESC"
|
|
40
|
+
};
|
|
41
|
+
const { data } = yield this.client({
|
|
42
|
+
url: '/web/api/graphql',
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: {
|
|
45
|
+
'x-graphql-operation-name': 'StoreReviews',
|
|
46
|
+
},
|
|
47
|
+
data: {
|
|
48
|
+
operationName: 'StoreReviews',
|
|
49
|
+
query: StoreReviews_1.StoreReviewsQuery,
|
|
50
|
+
variables
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const reviewsData = Object.assign({}, (_b = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.shop) === null || _b === void 0 ? void 0 : _b.productReviews);
|
|
54
|
+
const items = reviewsData === null || reviewsData === void 0 ? void 0 : reviewsData.nodes;
|
|
55
|
+
const vItems = Array.isArray(items) ? items : [];
|
|
56
|
+
return {
|
|
57
|
+
items: vItems,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ShopAppAPI = ShopAppAPI;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StoreReviewsQuery = "\nquery StoreReviews($shopId: ID!, $first: Int!, $after: String, $filter: ShopProductReviewsFilterInput, $sortBy: ProductReviewsSortBy) {\n shop(id: $shopId) {\n id\n name\n websiteUrl\n productReviews(filter: $filter, first: $first, after: $after, sortBy: $sortBy) {\n nodes {\n ...StoreProductReview\n __typename\n }\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n __typename\n }\n __typename\n }\n __typename\n }\n}\n\nfragment StoreProductReview on ProductReview {\n id\n syndicated\n reviewer {\n id\n displayName\n __typename\n }\n title\n body\n rating\n product {\n id\n image {\n ...ReducedImage\n __typename\n }\n title\n variantTitle\n slug\n __typename\n }\n submittedAt\n helpfulnessCount\n markedAsHelpfulByMe\n reportedByMe\n publishedVersion {\n id\n merchantReply\n merchantReplySubmittedAt\n createdAt\n __typename\n }\n discoveryProduct {\n id\n url\n title\n images {\n ...ReducedImage\n __typename\n }\n __typename\n }\n __typename\n}\n\nfragment ReducedImage on Image {\n __typename\n url\n altText\n height\n width\n sensitive\n thumbhash\n}\n";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StoreReviewsQuery = void 0;
|
|
4
|
+
exports.StoreReviewsQuery = `
|
|
5
|
+
query StoreReviews($shopId: ID!, $first: Int!, $after: String, $filter: ShopProductReviewsFilterInput, $sortBy: ProductReviewsSortBy) {
|
|
6
|
+
shop(id: $shopId) {
|
|
7
|
+
id
|
|
8
|
+
name
|
|
9
|
+
websiteUrl
|
|
10
|
+
productReviews(filter: $filter, first: $first, after: $after, sortBy: $sortBy) {
|
|
11
|
+
nodes {
|
|
12
|
+
...StoreProductReview
|
|
13
|
+
__typename
|
|
14
|
+
}
|
|
15
|
+
totalCount
|
|
16
|
+
pageInfo {
|
|
17
|
+
hasNextPage
|
|
18
|
+
endCursor
|
|
19
|
+
__typename
|
|
20
|
+
}
|
|
21
|
+
__typename
|
|
22
|
+
}
|
|
23
|
+
__typename
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fragment StoreProductReview on ProductReview {
|
|
28
|
+
id
|
|
29
|
+
syndicated
|
|
30
|
+
reviewer {
|
|
31
|
+
id
|
|
32
|
+
displayName
|
|
33
|
+
__typename
|
|
34
|
+
}
|
|
35
|
+
title
|
|
36
|
+
body
|
|
37
|
+
rating
|
|
38
|
+
product {
|
|
39
|
+
id
|
|
40
|
+
image {
|
|
41
|
+
...ReducedImage
|
|
42
|
+
__typename
|
|
43
|
+
}
|
|
44
|
+
title
|
|
45
|
+
variantTitle
|
|
46
|
+
slug
|
|
47
|
+
__typename
|
|
48
|
+
}
|
|
49
|
+
submittedAt
|
|
50
|
+
helpfulnessCount
|
|
51
|
+
markedAsHelpfulByMe
|
|
52
|
+
reportedByMe
|
|
53
|
+
publishedVersion {
|
|
54
|
+
id
|
|
55
|
+
merchantReply
|
|
56
|
+
merchantReplySubmittedAt
|
|
57
|
+
createdAt
|
|
58
|
+
__typename
|
|
59
|
+
}
|
|
60
|
+
discoveryProduct {
|
|
61
|
+
id
|
|
62
|
+
url
|
|
63
|
+
title
|
|
64
|
+
images {
|
|
65
|
+
...ReducedImage
|
|
66
|
+
__typename
|
|
67
|
+
}
|
|
68
|
+
__typename
|
|
69
|
+
}
|
|
70
|
+
__typename
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
fragment ReducedImage on Image {
|
|
74
|
+
__typename
|
|
75
|
+
url
|
|
76
|
+
altText
|
|
77
|
+
height
|
|
78
|
+
width
|
|
79
|
+
sensitive
|
|
80
|
+
thumbhash
|
|
81
|
+
}
|
|
82
|
+
`;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./classes/StorefrontAPI"), exports);
|
|
18
18
|
__exportStar(require("./classes/AdminAPI"), exports);
|
|
19
19
|
__exportStar(require("./classes/RestAPI"), exports);
|
|
20
|
+
__exportStar(require("./classes/ShopAppAPI"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pintahub/shopify-api",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@shopify/admin-api-client": "^1.0.0",
|
|
19
19
|
"@shopify/storefront-api-client": "^1.0.0",
|
|
20
|
-
"axios": "^1.13.
|
|
20
|
+
"axios": "^1.13.5",
|
|
21
21
|
"p-map": "^4"
|
|
22
22
|
}
|
|
23
23
|
}
|