@pintahub/shopify-api 1.0.3 → 1.0.5
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/actions/admin/GetProduct.d.ts +10 -0
- package/dist/actions/admin/GetProduct.js +74 -0
- package/dist/actions/admin/SearchProducts.d.ts +12 -0
- package/dist/actions/admin/SearchProducts.js +45 -0
- package/dist/actions/admin/products/GetProduct.d.ts +10 -0
- package/dist/actions/admin/products/GetProduct.js +74 -0
- package/dist/actions/admin/products/SearchProducts.d.ts +12 -0
- package/dist/actions/admin/products/SearchProducts.js +45 -0
- package/dist/actions/storefront/getProductByHandle.d.ts +11 -0
- package/dist/actions/storefront/getProductByHandle.js +39 -0
- package/dist/classes/APIBase.d.ts +4 -0
- package/dist/classes/APIBase.js +9 -0
- package/dist/classes/ActionBase.d.ts +2 -0
- package/dist/classes/ActionBase.js +6 -0
- package/dist/classes/ActionBuilder.d.ts +11 -0
- package/dist/classes/ActionBuilder.js +9 -0
- package/dist/classes/AdminAPI.d.ts +7 -4
- package/dist/classes/AdminAPI.js +10 -98
- package/dist/classes/StorefrontAPI.d.ts +7 -0
- package/dist/classes/StorefrontAPI.js +15 -0
- package/dist/classes/admin/collections/GetCollection.d.ts +10 -0
- package/dist/classes/admin/collections/GetCollection.js +49 -0
- package/dist/classes/admin/collections/SearchCollections.d.ts +11 -0
- package/dist/classes/admin/collections/SearchCollections.js +41 -0
- package/dist/classes/admin/collections/index.d.ts +13 -0
- package/dist/classes/admin/collections/index.js +34 -0
- package/dist/classes/admin/pages/SearchPages.d.ts +11 -0
- package/dist/classes/admin/pages/SearchPages.js +24 -0
- package/dist/classes/admin/pages/index.d.ts +10 -0
- package/dist/classes/admin/pages/index.js +28 -0
- package/dist/classes/admin/products/GetProduct.d.ts +10 -0
- package/dist/classes/admin/products/GetProduct.js +74 -0
- package/dist/classes/admin/products/SearchProducts.d.ts +11 -0
- package/dist/classes/admin/products/SearchProducts.js +45 -0
- package/dist/classes/admin/products/index.d.ts +13 -0
- package/dist/classes/admin/products/index.js +34 -0
- package/dist/classes/storefront/pages/GetPage.d.ts +10 -0
- package/dist/classes/storefront/pages/GetPage.js +43 -0
- package/dist/classes/storefront/pages/SearchPages.d.ts +11 -0
- package/dist/classes/storefront/pages/SearchPages.js +41 -0
- package/dist/classes/storefront/pages/index.d.ts +13 -0
- package/dist/classes/storefront/pages/index.js +34 -0
- package/dist/interfaces/StorefrontAPI.d.ts +4 -0
- package/dist/interfaces/StorefrontAPI.js +2 -0
- package/package.json +3 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../classes/ActionBuilder";
|
|
3
|
+
export interface GetProductInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetProductOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class GetProduct extends ActionBuilder<AdminApiClient, GetProductInput, GetProductOutput> {
|
|
9
|
+
run(args: GetProductInput): Promise<GetProductOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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.GetProduct = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../classes/ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../utils/getGlobalID");
|
|
15
|
+
class GetProduct extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { id } = args;
|
|
19
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Product');
|
|
20
|
+
const query = `
|
|
21
|
+
{
|
|
22
|
+
product(id: "${globalId}") {
|
|
23
|
+
id
|
|
24
|
+
handle
|
|
25
|
+
publishedAt
|
|
26
|
+
updatedAt
|
|
27
|
+
status
|
|
28
|
+
featuredImage {
|
|
29
|
+
altText
|
|
30
|
+
url(transform: {preferredContentType: PNG, maxWidth: 1024})
|
|
31
|
+
width
|
|
32
|
+
height
|
|
33
|
+
}
|
|
34
|
+
productType
|
|
35
|
+
title
|
|
36
|
+
priceRangeV2 {
|
|
37
|
+
maxVariantPrice {
|
|
38
|
+
amount
|
|
39
|
+
currencyCode
|
|
40
|
+
}
|
|
41
|
+
minVariantPrice {
|
|
42
|
+
amount
|
|
43
|
+
currencyCode
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
tags
|
|
47
|
+
productCategory {
|
|
48
|
+
productTaxonomyNode {
|
|
49
|
+
fullName
|
|
50
|
+
name
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
collections(first: 100) {
|
|
54
|
+
nodes {
|
|
55
|
+
id
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
metafields(first: 100) {
|
|
59
|
+
nodes {
|
|
60
|
+
key
|
|
61
|
+
value
|
|
62
|
+
type
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
const { data } = yield this.client.request(query);
|
|
69
|
+
const { product } = Object.assign({}, data);
|
|
70
|
+
return Object.assign({}, product);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.GetProduct = GetProduct;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../classes/ActionBuilder";
|
|
3
|
+
export interface SearchProductsInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SearchProductsOutput extends Record<string, any> {
|
|
7
|
+
items: any[];
|
|
8
|
+
pageInfo: any;
|
|
9
|
+
}
|
|
10
|
+
export declare class SearchProducts extends ActionBuilder<AdminApiClient, SearchProductsInput, SearchProductsOutput> {
|
|
11
|
+
run(args?: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.SearchProducts = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../classes/ActionBuilder");
|
|
14
|
+
class SearchProducts extends ActionBuilder_1.ActionBuilder {
|
|
15
|
+
run(args) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const query = `
|
|
18
|
+
{
|
|
19
|
+
products(
|
|
20
|
+
first: 100
|
|
21
|
+
sortKey: UPDATED_AT
|
|
22
|
+
reverse: true
|
|
23
|
+
) {
|
|
24
|
+
nodes {
|
|
25
|
+
id
|
|
26
|
+
}
|
|
27
|
+
pageInfo {
|
|
28
|
+
hasNextPage
|
|
29
|
+
endCursor
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const { data } = yield this.client.request(query);
|
|
35
|
+
const { products } = Object.assign({}, data);
|
|
36
|
+
const { nodes, pageInfo } = Object.assign({}, products);
|
|
37
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
38
|
+
return {
|
|
39
|
+
items,
|
|
40
|
+
pageInfo
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.SearchProducts = SearchProducts;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../../classes/ActionBuilder";
|
|
3
|
+
export interface GetProductInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetProductOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class GetProduct extends ActionBuilder<AdminApiClient, GetProductInput, GetProductOutput> {
|
|
9
|
+
run(args: GetProductInput): Promise<GetProductOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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.GetProduct = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../../classes/ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
class GetProduct extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { id } = args;
|
|
19
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Product');
|
|
20
|
+
const query = `
|
|
21
|
+
{
|
|
22
|
+
product(id: "${globalId}") {
|
|
23
|
+
id
|
|
24
|
+
handle
|
|
25
|
+
publishedAt
|
|
26
|
+
updatedAt
|
|
27
|
+
status
|
|
28
|
+
featuredImage {
|
|
29
|
+
altText
|
|
30
|
+
url(transform: {preferredContentType: PNG, maxWidth: 1024})
|
|
31
|
+
width
|
|
32
|
+
height
|
|
33
|
+
}
|
|
34
|
+
productType
|
|
35
|
+
title
|
|
36
|
+
priceRangeV2 {
|
|
37
|
+
maxVariantPrice {
|
|
38
|
+
amount
|
|
39
|
+
currencyCode
|
|
40
|
+
}
|
|
41
|
+
minVariantPrice {
|
|
42
|
+
amount
|
|
43
|
+
currencyCode
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
tags
|
|
47
|
+
productCategory {
|
|
48
|
+
productTaxonomyNode {
|
|
49
|
+
fullName
|
|
50
|
+
name
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
collections(first: 100) {
|
|
54
|
+
nodes {
|
|
55
|
+
id
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
metafields(first: 100) {
|
|
59
|
+
nodes {
|
|
60
|
+
key
|
|
61
|
+
value
|
|
62
|
+
type
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
const { data } = yield this.client.request(query);
|
|
69
|
+
const { product } = Object.assign({}, data);
|
|
70
|
+
return Object.assign({}, product);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.GetProduct = GetProduct;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../../classes/ActionBuilder";
|
|
3
|
+
export interface SearchProductsInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SearchProductsOutput extends Record<string, any> {
|
|
7
|
+
items: any[];
|
|
8
|
+
pageInfo: any;
|
|
9
|
+
}
|
|
10
|
+
export declare class SearchProducts extends ActionBuilder<AdminApiClient, SearchProductsInput, SearchProductsOutput> {
|
|
11
|
+
run(args?: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.SearchProducts = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../../classes/ActionBuilder");
|
|
14
|
+
class SearchProducts extends ActionBuilder_1.ActionBuilder {
|
|
15
|
+
run(args) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const query = `
|
|
18
|
+
{
|
|
19
|
+
products(
|
|
20
|
+
first: 100
|
|
21
|
+
sortKey: UPDATED_AT
|
|
22
|
+
reverse: true
|
|
23
|
+
) {
|
|
24
|
+
nodes {
|
|
25
|
+
id
|
|
26
|
+
}
|
|
27
|
+
pageInfo {
|
|
28
|
+
hasNextPage
|
|
29
|
+
endCursor
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const { data } = yield this.client.request(query);
|
|
35
|
+
const { products } = Object.assign({}, data);
|
|
36
|
+
const { nodes, pageInfo } = Object.assign({}, products);
|
|
37
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
38
|
+
return {
|
|
39
|
+
items,
|
|
40
|
+
pageInfo
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.SearchProducts = SearchProducts;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionBuilder } from "../../classes/ActionBuilder";
|
|
2
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
|
+
export interface GetProductInput extends Record<string, any> {
|
|
4
|
+
handle: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetProductOutput extends Record<string, any> {
|
|
7
|
+
product: any;
|
|
8
|
+
}
|
|
9
|
+
export declare class GetProductByHandle extends ActionBuilder<StorefrontApiClient, GetProductInput, GetProductOutput> {
|
|
10
|
+
run(args: GetProductInput): Promise<GetProductOutput>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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.GetProductByHandle = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../classes/ActionBuilder");
|
|
14
|
+
class GetProductByHandle extends ActionBuilder_1.ActionBuilder {
|
|
15
|
+
run(args) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const productQuery = `
|
|
18
|
+
query ($handle: String) {
|
|
19
|
+
product(handle: $handle) {
|
|
20
|
+
id
|
|
21
|
+
title
|
|
22
|
+
handle
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
const { handle } = args;
|
|
27
|
+
const { data } = yield this.client.request(productQuery, {
|
|
28
|
+
variables: {
|
|
29
|
+
handle
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const { product } = Object.assign({}, data);
|
|
33
|
+
return {
|
|
34
|
+
product,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.GetProductByHandle = GetProductByHandle;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ActionBuilderInterface<Client, Input, Output> {
|
|
2
|
+
run(args?: Input): Promise<Output>;
|
|
3
|
+
}
|
|
4
|
+
export interface ActionBuilderConstructor<Client, Input, Output> {
|
|
5
|
+
new (client: Client): ActionBuilderInterface<Client, Input, Output>;
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class ActionBuilder<Client, Input, Output> {
|
|
8
|
+
protected readonly client: Client;
|
|
9
|
+
constructor(client: Client);
|
|
10
|
+
abstract run(args?: Input): Promise<Output>;
|
|
11
|
+
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { AdminProductAPIInterface } from "./admin/products";
|
|
2
|
+
import { AdminCollectionAPIInterface } from "./admin/collections";
|
|
1
3
|
export interface APIOptions extends Record<string, any> {
|
|
2
4
|
shop: string;
|
|
3
5
|
accessToken: string;
|
|
4
6
|
}
|
|
5
7
|
export declare class AdminAPI {
|
|
6
8
|
private readonly options;
|
|
7
|
-
private client;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
private readonly client;
|
|
10
|
+
readonly product: AdminProductAPIInterface;
|
|
11
|
+
readonly collection: AdminCollectionAPIInterface;
|
|
12
|
+
constructor(options: APIOptions);
|
|
13
|
+
private _createClient;
|
|
11
14
|
}
|
package/dist/classes/AdminAPI.js
CHANGED
|
@@ -1,111 +1,23 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.AdminAPI = void 0;
|
|
13
4
|
const admin_api_client_1 = require("@shopify/admin-api-client");
|
|
14
|
-
const
|
|
5
|
+
const products_1 = require("./admin/products");
|
|
6
|
+
const collections_1 = require("./admin/collections");
|
|
15
7
|
class AdminAPI {
|
|
16
|
-
constructor(
|
|
17
|
-
this.options =
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.client = this._createClient();
|
|
11
|
+
this.product = new products_1.AdminProductAPI(this.client);
|
|
12
|
+
this.collection = new collections_1.AdminCollectionAPI(this.client);
|
|
13
|
+
}
|
|
14
|
+
_createClient() {
|
|
18
15
|
const { shop, accessToken } = this.options;
|
|
19
|
-
|
|
16
|
+
return (0, admin_api_client_1.createAdminApiClient)({
|
|
20
17
|
storeDomain: shop,
|
|
21
18
|
accessToken: accessToken,
|
|
22
19
|
apiVersion: '2023-10'
|
|
23
20
|
});
|
|
24
21
|
}
|
|
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
|
-
const { product } = Object.assign({}, data);
|
|
78
|
-
return Object.assign({}, product);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
getProducts() {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const query = `
|
|
84
|
-
{
|
|
85
|
-
products(
|
|
86
|
-
first: 100
|
|
87
|
-
sortKey: UPDATED_AT
|
|
88
|
-
reverse: true
|
|
89
|
-
) {
|
|
90
|
-
nodes {
|
|
91
|
-
id
|
|
92
|
-
}
|
|
93
|
-
pageInfo {
|
|
94
|
-
hasNextPage
|
|
95
|
-
endCursor
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
`;
|
|
100
|
-
const { data } = yield this.client.request(query);
|
|
101
|
-
const { products } = Object.assign({}, data);
|
|
102
|
-
const { nodes, pageInfo } = Object.assign({}, products);
|
|
103
|
-
const items = Array.isArray(nodes) ? nodes : [];
|
|
104
|
-
return {
|
|
105
|
-
items,
|
|
106
|
-
pageInfo
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
22
|
}
|
|
111
23
|
exports.AdminAPI = AdminAPI;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
import { StorefrontAPIOptions } from "../interfaces/StorefrontAPI";
|
|
2
|
+
import { PageAPIInterface } from "./storefront/pages";
|
|
1
3
|
export declare class StorefrontAPI {
|
|
4
|
+
private readonly options;
|
|
5
|
+
private readonly client;
|
|
6
|
+
readonly page: PageAPIInterface;
|
|
7
|
+
constructor(options: StorefrontAPIOptions);
|
|
8
|
+
private _createClient;
|
|
2
9
|
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorefrontAPI = void 0;
|
|
4
|
+
const storefront_api_client_1 = require("@shopify/storefront-api-client");
|
|
5
|
+
const pages_1 = require("./storefront/pages");
|
|
4
6
|
class StorefrontAPI {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.client = this._createClient();
|
|
10
|
+
this.page = new pages_1.PageAPI(this.client);
|
|
11
|
+
}
|
|
12
|
+
_createClient() {
|
|
13
|
+
const { shop, accessToken } = this.options;
|
|
14
|
+
return (0, storefront_api_client_1.createStorefrontApiClient)({
|
|
15
|
+
storeDomain: shop,
|
|
16
|
+
apiVersion: '2023-10',
|
|
17
|
+
publicAccessToken: accessToken
|
|
18
|
+
});
|
|
19
|
+
}
|
|
5
20
|
}
|
|
6
21
|
exports.StorefrontAPI = StorefrontAPI;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface GetCollectionInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetCollectionOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class GetCollection extends ActionBuilder<AdminApiClient, GetCollectionInput, GetCollectionOutput> {
|
|
9
|
+
run(args: GetCollectionInput): Promise<GetCollectionOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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.GetCollection = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
class GetCollection extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const query = `
|
|
19
|
+
query ($id: ID!) {
|
|
20
|
+
collection(id: $id) {
|
|
21
|
+
handle
|
|
22
|
+
title
|
|
23
|
+
updatedAt
|
|
24
|
+
id
|
|
25
|
+
descriptionHtml
|
|
26
|
+
productsCount
|
|
27
|
+
image {
|
|
28
|
+
id
|
|
29
|
+
url
|
|
30
|
+
altText
|
|
31
|
+
height
|
|
32
|
+
width
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
const { id } = args;
|
|
38
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Collection');
|
|
39
|
+
const { data } = yield this.client.request(query, {
|
|
40
|
+
variables: {
|
|
41
|
+
id: globalId
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const { collection } = Object.assign({}, data);
|
|
45
|
+
return Object.assign({}, collection);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.GetCollection = GetCollection;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface SearchCollectionsInput extends Record<string, any> {
|
|
4
|
+
}
|
|
5
|
+
export interface SearchCollectionsOutput extends Record<string, any> {
|
|
6
|
+
items: any[];
|
|
7
|
+
pageInfo: any;
|
|
8
|
+
}
|
|
9
|
+
export declare class SearchCollections extends ActionBuilder<AdminApiClient, SearchCollectionsInput, SearchCollectionsOutput> {
|
|
10
|
+
run(args?: SearchCollectionsInput): Promise<SearchCollectionsOutput>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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.SearchCollections = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
class SearchCollections extends ActionBuilder_1.ActionBuilder {
|
|
15
|
+
run(args) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const query = `
|
|
18
|
+
{
|
|
19
|
+
collections(first: 100, reverse: false, sortKey: UPDATED_AT) {
|
|
20
|
+
nodes {
|
|
21
|
+
id
|
|
22
|
+
}
|
|
23
|
+
pageInfo {
|
|
24
|
+
endCursor
|
|
25
|
+
hasNextPage
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
const { data } = yield this.client.request(query);
|
|
31
|
+
const { collections } = Object.assign({}, data);
|
|
32
|
+
const { nodes, pageInfo } = Object.assign({}, collections);
|
|
33
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
34
|
+
return {
|
|
35
|
+
items,
|
|
36
|
+
pageInfo
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.SearchCollections = SearchCollections;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { APIBase } from "../../APIBase";
|
|
3
|
+
import { SearchCollectionsInput, SearchCollectionsOutput } from "./SearchCollections";
|
|
4
|
+
import { GetCollectionInput, GetCollectionOutput } from "./GetCollection";
|
|
5
|
+
export interface AdminCollectionAPIInterface {
|
|
6
|
+
get(args?: GetCollectionInput): Promise<GetCollectionOutput>;
|
|
7
|
+
search(args?: SearchCollectionsInput): Promise<SearchCollectionsOutput>;
|
|
8
|
+
}
|
|
9
|
+
export declare class AdminCollectionAPI extends APIBase<AdminApiClient> implements AdminCollectionAPIInterface {
|
|
10
|
+
private _runAction;
|
|
11
|
+
get(args: GetCollectionInput): Promise<GetCollectionOutput>;
|
|
12
|
+
search(args?: SearchCollectionsInput): Promise<SearchCollectionsOutput>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.AdminCollectionAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const SearchCollections_1 = require("./SearchCollections");
|
|
15
|
+
const GetCollection_1 = require("./GetCollection");
|
|
16
|
+
class AdminCollectionAPI extends APIBase_1.APIBase {
|
|
17
|
+
_runAction(Action, args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const action = new Action(this.client);
|
|
20
|
+
return action.run(args);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
get(args) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return this._runAction(GetCollection_1.GetCollection, args);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
search(args) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return this._runAction(SearchCollections_1.SearchCollections, args);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.AdminCollectionAPI = AdminCollectionAPI;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface SearchPagesInput extends Record<string, any> {
|
|
4
|
+
}
|
|
5
|
+
export interface SearchPagesOutput extends Record<string, any> {
|
|
6
|
+
items: any[];
|
|
7
|
+
pageInfo: any;
|
|
8
|
+
}
|
|
9
|
+
export declare class SearchPages extends ActionBuilder<AdminApiClient, SearchPagesInput, SearchPagesOutput> {
|
|
10
|
+
run(args?: SearchPagesInput): Promise<SearchPagesOutput>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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.SearchPages = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
class SearchPages extends ActionBuilder_1.ActionBuilder {
|
|
15
|
+
run(args) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
return {
|
|
18
|
+
items: [],
|
|
19
|
+
pageInfo: ''
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.SearchPages = SearchPages;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { APIBase } from "../../APIBase";
|
|
3
|
+
import { SearchPagesInput, SearchPagesOutput } from "./SearchPages";
|
|
4
|
+
export interface AdminPageAPIInterface {
|
|
5
|
+
searchPages(args?: SearchPagesInput): Promise<SearchPagesOutput>;
|
|
6
|
+
}
|
|
7
|
+
export declare class AdminPageAPI extends APIBase<AdminApiClient> implements AdminPageAPIInterface {
|
|
8
|
+
private _runAction;
|
|
9
|
+
searchPages(args?: SearchPagesInput): Promise<SearchPagesOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.AdminPageAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const SearchPages_1 = require("./SearchPages");
|
|
15
|
+
class AdminPageAPI extends APIBase_1.APIBase {
|
|
16
|
+
_runAction(Action, args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const action = new Action(this.client);
|
|
19
|
+
return action.run(args);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
searchPages(args) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return this._runAction(SearchPages_1.SearchPages, args);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AdminPageAPI = AdminPageAPI;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface GetProductInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetProductOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class GetProduct extends ActionBuilder<AdminApiClient, GetProductInput, GetProductOutput> {
|
|
9
|
+
run(args: GetProductInput): Promise<GetProductOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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.GetProduct = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
class GetProduct extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { id } = args;
|
|
19
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Product');
|
|
20
|
+
const query = `
|
|
21
|
+
{
|
|
22
|
+
product(id: "${globalId}") {
|
|
23
|
+
id
|
|
24
|
+
handle
|
|
25
|
+
publishedAt
|
|
26
|
+
updatedAt
|
|
27
|
+
status
|
|
28
|
+
featuredImage {
|
|
29
|
+
altText
|
|
30
|
+
url(transform: {preferredContentType: PNG, maxWidth: 1024})
|
|
31
|
+
width
|
|
32
|
+
height
|
|
33
|
+
}
|
|
34
|
+
productType
|
|
35
|
+
title
|
|
36
|
+
priceRangeV2 {
|
|
37
|
+
maxVariantPrice {
|
|
38
|
+
amount
|
|
39
|
+
currencyCode
|
|
40
|
+
}
|
|
41
|
+
minVariantPrice {
|
|
42
|
+
amount
|
|
43
|
+
currencyCode
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
tags
|
|
47
|
+
productCategory {
|
|
48
|
+
productTaxonomyNode {
|
|
49
|
+
fullName
|
|
50
|
+
name
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
collections(first: 100) {
|
|
54
|
+
nodes {
|
|
55
|
+
id
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
metafields(first: 100) {
|
|
59
|
+
nodes {
|
|
60
|
+
key
|
|
61
|
+
value
|
|
62
|
+
type
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
const { data } = yield this.client.request(query);
|
|
69
|
+
const { product } = Object.assign({}, data);
|
|
70
|
+
return Object.assign({}, product);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.GetProduct = GetProduct;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface SearchProductsInput extends Record<string, any> {
|
|
4
|
+
}
|
|
5
|
+
export interface SearchProductsOutput extends Record<string, any> {
|
|
6
|
+
items: any[];
|
|
7
|
+
pageInfo: any;
|
|
8
|
+
}
|
|
9
|
+
export declare class SearchProducts extends ActionBuilder<AdminApiClient, SearchProductsInput, SearchProductsOutput> {
|
|
10
|
+
run(args?: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.SearchProducts = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
class SearchProducts extends ActionBuilder_1.ActionBuilder {
|
|
15
|
+
run(args) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const query = `
|
|
18
|
+
{
|
|
19
|
+
products(
|
|
20
|
+
first: 100
|
|
21
|
+
sortKey: UPDATED_AT
|
|
22
|
+
reverse: true
|
|
23
|
+
) {
|
|
24
|
+
nodes {
|
|
25
|
+
id
|
|
26
|
+
}
|
|
27
|
+
pageInfo {
|
|
28
|
+
hasNextPage
|
|
29
|
+
endCursor
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const { data } = yield this.client.request(query);
|
|
35
|
+
const { products } = Object.assign({}, data);
|
|
36
|
+
const { nodes, pageInfo } = Object.assign({}, products);
|
|
37
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
38
|
+
return {
|
|
39
|
+
items,
|
|
40
|
+
pageInfo
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.SearchProducts = SearchProducts;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { APIBase } from "../../APIBase";
|
|
3
|
+
import { GetProductInput, GetProductOutput } from "./GetProduct";
|
|
4
|
+
import { SearchProductsInput, SearchProductsOutput } from "./SearchProducts";
|
|
5
|
+
export interface AdminProductAPIInterface {
|
|
6
|
+
getProduct(args: GetProductInput): Promise<GetProductOutput>;
|
|
7
|
+
searchProducts(args?: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
8
|
+
}
|
|
9
|
+
export declare class AdminProductAPI extends APIBase<AdminApiClient> implements AdminProductAPIInterface {
|
|
10
|
+
private _runAction;
|
|
11
|
+
getProduct(args: GetProductInput): Promise<GetProductOutput>;
|
|
12
|
+
searchProducts(args?: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.AdminProductAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const GetProduct_1 = require("./GetProduct");
|
|
15
|
+
const SearchProducts_1 = require("./SearchProducts");
|
|
16
|
+
class AdminProductAPI extends APIBase_1.APIBase {
|
|
17
|
+
_runAction(Action, args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const action = new Action(this.client);
|
|
20
|
+
return action.run(args);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
getProduct(args) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return this._runAction(GetProduct_1.GetProduct, args);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
searchProducts(args) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return this._runAction(SearchProducts_1.SearchProducts, args);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.AdminProductAPI = AdminProductAPI;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
2
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
|
+
export interface GetPageInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetPageOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class GetPage extends ActionBuilder<StorefrontApiClient, GetPageInput, GetPageOutput> {
|
|
9
|
+
run(args: GetPageInput): Promise<GetPageOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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.GetPage = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
class GetPage extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const query = `
|
|
19
|
+
query ($id: ID){
|
|
20
|
+
page(id: $id) {
|
|
21
|
+
body
|
|
22
|
+
handle
|
|
23
|
+
id
|
|
24
|
+
title
|
|
25
|
+
onlineStoreUrl
|
|
26
|
+
bodySummary
|
|
27
|
+
updatedAt
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const { id } = args;
|
|
32
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id);
|
|
33
|
+
const { data } = yield this.client.request(query, {
|
|
34
|
+
variables: {
|
|
35
|
+
id: globalId
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const { page } = Object.assign({}, data);
|
|
39
|
+
return Object.assign({}, page);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.GetPage = GetPage;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
2
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
|
+
export interface SearchPagesInput extends Record<string, any> {
|
|
4
|
+
}
|
|
5
|
+
export interface SearchPagesOutput extends Record<string, any> {
|
|
6
|
+
items: any[];
|
|
7
|
+
pageInfo: any;
|
|
8
|
+
}
|
|
9
|
+
export declare class SearchPages extends ActionBuilder<StorefrontApiClient, SearchPagesInput, SearchPagesOutput> {
|
|
10
|
+
run(args?: SearchPagesInput): Promise<SearchPagesOutput>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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.SearchPages = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
class SearchPages extends ActionBuilder_1.ActionBuilder {
|
|
15
|
+
run(args) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const query = `
|
|
18
|
+
{
|
|
19
|
+
pages(first: 100, reverse: true, sortKey: UPDATED_AT) {
|
|
20
|
+
nodes {
|
|
21
|
+
id
|
|
22
|
+
}
|
|
23
|
+
pageInfo {
|
|
24
|
+
endCursor
|
|
25
|
+
hasNextPage
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
const { data } = yield this.client.request(query);
|
|
31
|
+
const { pages } = Object.assign({}, data);
|
|
32
|
+
const { nodes, pageInfo } = Object.assign({}, pages);
|
|
33
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
34
|
+
return {
|
|
35
|
+
items,
|
|
36
|
+
pageInfo,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.SearchPages = SearchPages;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { APIBase } from "../../APIBase";
|
|
2
|
+
import { SearchPagesInput, SearchPagesOutput } from "./SearchPages";
|
|
3
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
4
|
+
import { GetPageInput, GetPageOutput } from "./GetPage";
|
|
5
|
+
export interface PageAPIInterface {
|
|
6
|
+
searchPages(args?: SearchPagesInput): Promise<SearchPagesOutput>;
|
|
7
|
+
getPage(args: GetPageInput): Promise<GetPageOutput>;
|
|
8
|
+
}
|
|
9
|
+
export declare class PageAPI extends APIBase<StorefrontApiClient> implements PageAPIInterface {
|
|
10
|
+
private _runAction;
|
|
11
|
+
searchPages(args?: SearchPagesInput): Promise<SearchPagesOutput>;
|
|
12
|
+
getPage(args: GetPageInput): Promise<GetPageOutput>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.PageAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const SearchPages_1 = require("./SearchPages");
|
|
15
|
+
const GetPage_1 = require("./GetPage");
|
|
16
|
+
class PageAPI extends APIBase_1.APIBase {
|
|
17
|
+
_runAction(Action, args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const action = new Action(this.client);
|
|
20
|
+
return action.run(args);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
searchPages(args) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return this._runAction(SearchPages_1.SearchPages, args);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
getPage(args) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return this._runAction(GetPage_1.GetPage, args);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.PageAPI = PageAPI;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pintahub/shopify-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"dotenv": "^16.3.1"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@shopify/admin-api-client": "^0.1.0"
|
|
16
|
+
"@shopify/admin-api-client": "^0.1.0",
|
|
17
|
+
"@shopify/storefront-api-client": "^0.1.1"
|
|
17
18
|
}
|
|
18
19
|
}
|