@pintahub/shopify-api 1.9.2 → 1.9.4
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/StorefrontAPI.d.ts +2 -0
- package/dist/classes/StorefrontAPI.js +5 -3
- package/dist/classes/admin/customers/CreateCustomer.js +1 -1
- package/dist/classes/admin/products-v2/GetProduct.d.ts +10 -0
- package/dist/classes/admin/products-v2/GetProduct.js +90 -0
- package/dist/classes/admin/products-v2/index.d.ts +3 -0
- package/dist/classes/admin/products-v2/index.js +6 -0
- package/dist/classes/storefront/customers/CreateCustomer.d.ts +12 -0
- package/dist/classes/storefront/customers/CreateCustomer.js +46 -0
- package/dist/classes/storefront/customers/index.d.ts +10 -0
- package/dist/classes/storefront/customers/index.js +28 -0
- package/dist/input/CustomerInput.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { ShopAPIInterface } from "./storefront/shop";
|
|
|
4
4
|
import { ProductAPIInterface } from "./storefront/products";
|
|
5
5
|
import { CartAPIInterface } from "./storefront/cart";
|
|
6
6
|
import { PostsAPIInterface } from "./storefront/posts";
|
|
7
|
+
import { CustomersAPIInterface } from "./storefront/customers";
|
|
7
8
|
export declare class StorefrontAPI {
|
|
8
9
|
private readonly options;
|
|
9
10
|
private readonly client;
|
|
@@ -12,6 +13,7 @@ export declare class StorefrontAPI {
|
|
|
12
13
|
readonly product: ProductAPIInterface;
|
|
13
14
|
readonly cart: CartAPIInterface;
|
|
14
15
|
readonly posts: PostsAPIInterface;
|
|
16
|
+
readonly customers: CustomersAPIInterface;
|
|
15
17
|
constructor(options: StorefrontAPIOptions);
|
|
16
18
|
private _createClient;
|
|
17
19
|
}
|
|
@@ -7,21 +7,23 @@ const shop_1 = require("./storefront/shop");
|
|
|
7
7
|
const products_1 = require("./storefront/products");
|
|
8
8
|
const cart_1 = require("./storefront/cart");
|
|
9
9
|
const posts_1 = require("./storefront/posts");
|
|
10
|
+
const customers_1 = require("./storefront/customers");
|
|
10
11
|
class StorefrontAPI {
|
|
11
12
|
constructor(options) {
|
|
12
13
|
this.options = options;
|
|
13
|
-
this.client = this._createClient();
|
|
14
|
+
this.client = this._createClient('2023-10');
|
|
14
15
|
this.page = new pages_1.PageAPI(this.client);
|
|
15
16
|
this.shop = new shop_1.ShopAPI(this.client);
|
|
16
17
|
this.product = new products_1.ProductAPI(this.client);
|
|
17
18
|
this.cart = new cart_1.CartAPI(this.client);
|
|
18
19
|
this.posts = new posts_1.PostsAPI(this.client);
|
|
20
|
+
this.customers = new customers_1.CustomersAPI(this._createClient('2024-10'));
|
|
19
21
|
}
|
|
20
|
-
_createClient() {
|
|
22
|
+
_createClient(version = '2023-10') {
|
|
21
23
|
const { shop, accessToken } = this.options;
|
|
22
24
|
return (0, storefront_api_client_1.createStorefrontApiClient)({
|
|
23
25
|
storeDomain: shop,
|
|
24
|
-
apiVersion:
|
|
26
|
+
apiVersion: version,
|
|
25
27
|
publicAccessToken: accessToken
|
|
26
28
|
});
|
|
27
29
|
}
|
|
@@ -16,7 +16,7 @@ class CreateCustomer extends ActionBuilder_1.ActionBuilder {
|
|
|
16
16
|
run(args) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const query = `
|
|
19
|
-
mutation
|
|
19
|
+
mutation customerCreate($input: CustomerInput!) {
|
|
20
20
|
customerCreate(input: $input) {
|
|
21
21
|
customer {
|
|
22
22
|
id
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/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,90 @@
|
|
|
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
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
16
|
+
class GetProduct extends ActionBuilder_1.ActionBuilder {
|
|
17
|
+
run(args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { id } = args;
|
|
20
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Product');
|
|
21
|
+
const query = `
|
|
22
|
+
{
|
|
23
|
+
product(id: "${globalId}") {
|
|
24
|
+
id
|
|
25
|
+
handle
|
|
26
|
+
publishedAt
|
|
27
|
+
updatedAt
|
|
28
|
+
status
|
|
29
|
+
featuredImage {
|
|
30
|
+
id
|
|
31
|
+
altText
|
|
32
|
+
url
|
|
33
|
+
width
|
|
34
|
+
height
|
|
35
|
+
}
|
|
36
|
+
priceRangeV2 {
|
|
37
|
+
maxVariantPrice {
|
|
38
|
+
amount
|
|
39
|
+
currencyCode
|
|
40
|
+
}
|
|
41
|
+
minVariantPrice {
|
|
42
|
+
amount
|
|
43
|
+
currencyCode
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
productType
|
|
47
|
+
title
|
|
48
|
+
description
|
|
49
|
+
descriptionHtml
|
|
50
|
+
tags
|
|
51
|
+
productCategory {
|
|
52
|
+
productTaxonomyNode {
|
|
53
|
+
fullName
|
|
54
|
+
name
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
collections(first: 100) {
|
|
58
|
+
nodes {
|
|
59
|
+
id
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
metafields(first: 100) {
|
|
63
|
+
nodes {
|
|
64
|
+
key
|
|
65
|
+
value
|
|
66
|
+
type
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
images(first: 100) {
|
|
70
|
+
nodes {
|
|
71
|
+
id
|
|
72
|
+
url
|
|
73
|
+
height
|
|
74
|
+
altText
|
|
75
|
+
width
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
const { data, errors, extensions } = yield this.client.request(query);
|
|
82
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
83
|
+
const { product } = Object.assign({}, data);
|
|
84
|
+
return Object.assign({
|
|
85
|
+
status: 'DELETED'
|
|
86
|
+
}, product);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.GetProduct = GetProduct;
|
|
@@ -2,12 +2,15 @@ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types"
|
|
|
2
2
|
import { APIBase } from "../../APIBase";
|
|
3
3
|
import { UpdateVariantsInput, UpdateVariantsOutput } from "./UpdateVariants";
|
|
4
4
|
import { UpdateProductInput, UpdateProductOutput } from "./UpdateProduct";
|
|
5
|
+
import { GetProductInput, GetProductOutput } from "./GetProduct";
|
|
5
6
|
export interface AdminProductsAPIInterface {
|
|
7
|
+
get(args: GetProductInput): Promise<GetProductOutput>;
|
|
6
8
|
update(args: UpdateProductInput): Promise<UpdateProductOutput>;
|
|
7
9
|
updateVariants(args: UpdateVariantsInput): Promise<UpdateVariantsOutput>;
|
|
8
10
|
}
|
|
9
11
|
export declare class AdminProductsAPI extends APIBase<AdminApiClient> implements AdminProductsAPIInterface {
|
|
10
12
|
private _runAction;
|
|
13
|
+
get(args: GetProductInput): Promise<GetProductOutput>;
|
|
11
14
|
update(args: UpdateProductInput): Promise<UpdateProductOutput>;
|
|
12
15
|
updateVariants(args: UpdateVariantsInput): Promise<UpdateVariantsOutput>;
|
|
13
16
|
}
|
|
@@ -13,6 +13,7 @@ exports.AdminProductsAPI = void 0;
|
|
|
13
13
|
const APIBase_1 = require("../../APIBase");
|
|
14
14
|
const UpdateVariants_1 = require("./UpdateVariants");
|
|
15
15
|
const UpdateProduct_1 = require("./UpdateProduct");
|
|
16
|
+
const GetProduct_1 = require("./GetProduct");
|
|
16
17
|
class AdminProductsAPI extends APIBase_1.APIBase {
|
|
17
18
|
_runAction(Action, args) {
|
|
18
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -20,6 +21,11 @@ class AdminProductsAPI extends APIBase_1.APIBase {
|
|
|
20
21
|
return action.run(args);
|
|
21
22
|
});
|
|
22
23
|
}
|
|
24
|
+
get(args) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return this._runAction(GetProduct_1.GetProduct, args);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
23
29
|
update(args) {
|
|
24
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
31
|
return this._runAction(UpdateProduct_1.UpdateProduct, args);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
2
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
|
+
export interface CreateCustomerInput extends Record<string, any> {
|
|
4
|
+
email?: string;
|
|
5
|
+
acceptsMarketing?: boolean;
|
|
6
|
+
password?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateCustomerOutput extends Record<string, any> {
|
|
9
|
+
}
|
|
10
|
+
export declare class CreateCustomer extends ActionBuilder<StorefrontApiClient, CreateCustomerInput, CreateCustomerOutput> {
|
|
11
|
+
run(args: CreateCustomerInput): Promise<CreateCustomerOutput>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.CreateCustomer = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class CreateCustomer extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const query = `
|
|
19
|
+
mutation customerCreate($input: CustomerCreateInput!) {
|
|
20
|
+
customerCreate(input: $input) {
|
|
21
|
+
customer {
|
|
22
|
+
id
|
|
23
|
+
email
|
|
24
|
+
phone
|
|
25
|
+
}
|
|
26
|
+
userErrors {
|
|
27
|
+
message
|
|
28
|
+
field
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
const result = yield this.client.request(query, {
|
|
34
|
+
variables: {
|
|
35
|
+
input: args
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const { data, errors } = Object.assign({}, result);
|
|
39
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
40
|
+
const { customerCreate } = data;
|
|
41
|
+
const { customer } = Object.assign({}, customerCreate);
|
|
42
|
+
return Object.assign({}, customer);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CreateCustomer = CreateCustomer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { APIBase } from "../../APIBase";
|
|
2
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
|
+
import { CreateCustomerInput, CreateCustomerOutput } from "./CreateCustomer";
|
|
4
|
+
export interface CustomersAPIInterface {
|
|
5
|
+
create(args: CreateCustomerInput): Promise<CreateCustomerOutput>;
|
|
6
|
+
}
|
|
7
|
+
export declare class CustomersAPI extends APIBase<StorefrontApiClient> implements CustomersAPIInterface {
|
|
8
|
+
private _runAction;
|
|
9
|
+
create(args: CreateCustomerInput): Promise<CreateCustomerOutput>;
|
|
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.CustomersAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const CreateCustomer_1 = require("./CreateCustomer");
|
|
15
|
+
class CustomersAPI 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
|
+
create(args) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return this._runAction(CreateCustomer_1.CreateCustomer, args);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.CustomersAPI = CustomersAPI;
|