@pintahub/shopify-api 1.0.0 → 1.0.1
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/AdminAPI.d.ts +10 -0
- package/dist/classes/AdminAPI.js +82 -0
- package/dist/classes/StorefrontAPI.d.ts +2 -0
- package/dist/classes/StorefrontAPI.js +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/utils/getGlobalID.d.ts +1 -0
- package/dist/utils/getGlobalID.js +13 -0
- package/dist/utils.d.ts +0 -0
- package/dist/utils.js +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,82 @@
|
|
|
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.AdminAPI = void 0;
|
|
13
|
+
const admin_api_client_1 = require("@shopify/admin-api-client");
|
|
14
|
+
const getGlobalID_1 = require("../utils/getGlobalID");
|
|
15
|
+
class AdminAPI {
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
this.options = opts;
|
|
18
|
+
const { shop, accessToken } = this.options;
|
|
19
|
+
this.client = (0, admin_api_client_1.createAdminApiClient)({
|
|
20
|
+
storeDomain: shop,
|
|
21
|
+
accessToken: accessToken,
|
|
22
|
+
apiVersion: '2023-10'
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
getProduct(id) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Product');
|
|
28
|
+
const query = `
|
|
29
|
+
{
|
|
30
|
+
product(id: "${globalId}") {
|
|
31
|
+
id
|
|
32
|
+
handle
|
|
33
|
+
publishedAt
|
|
34
|
+
updatedAt
|
|
35
|
+
status
|
|
36
|
+
featuredImage {
|
|
37
|
+
altText
|
|
38
|
+
url(transform: {preferredContentType: PNG, maxWidth: 1024})
|
|
39
|
+
width
|
|
40
|
+
height
|
|
41
|
+
}
|
|
42
|
+
productType
|
|
43
|
+
title
|
|
44
|
+
priceRangeV2 {
|
|
45
|
+
maxVariantPrice {
|
|
46
|
+
amount
|
|
47
|
+
currencyCode
|
|
48
|
+
}
|
|
49
|
+
minVariantPrice {
|
|
50
|
+
amount
|
|
51
|
+
currencyCode
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
tags
|
|
55
|
+
productCategory {
|
|
56
|
+
productTaxonomyNode {
|
|
57
|
+
fullName
|
|
58
|
+
name
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
collections(first: 100) {
|
|
62
|
+
nodes {
|
|
63
|
+
id
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
metafields(first: 100) {
|
|
67
|
+
nodes {
|
|
68
|
+
key
|
|
69
|
+
value
|
|
70
|
+
type
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
const { data } = yield this.client.request(query);
|
|
77
|
+
console.log('data', data);
|
|
78
|
+
return data;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.AdminAPI = AdminAPI;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -15,3 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./classes/ShopifyAPI"), exports);
|
|
18
|
+
__exportStar(require("./classes/StorefrontAPI"), exports);
|
|
19
|
+
__exportStar(require("./classes/AdminAPI"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getGlobalID: (id: string, type?: string) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGlobalID = void 0;
|
|
4
|
+
const getGlobalID = (id, type = 'Product') => {
|
|
5
|
+
if (!id) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
if (id.includes('gid://')) {
|
|
9
|
+
return id;
|
|
10
|
+
}
|
|
11
|
+
return `gid://shopify/${type}/${id}`;
|
|
12
|
+
};
|
|
13
|
+
exports.getGlobalID = getGlobalID;
|
package/dist/utils.d.ts
ADDED
|
File without changes
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pintahub/shopify-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,5 +12,7 @@
|
|
|
12
12
|
"@types/node": "^20.10.4",
|
|
13
13
|
"dotenv": "^16.3.1"
|
|
14
14
|
},
|
|
15
|
-
"dependencies": {
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@shopify/admin-api-client": "^0.1.0"
|
|
17
|
+
}
|
|
16
18
|
}
|