@pintahub/shopify-api 1.4.1 → 1.4.3
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 +2 -0
- package/dist/classes/AdminAPI.js +2 -0
- package/dist/classes/StorefrontAPI.d.ts +2 -0
- package/dist/classes/StorefrontAPI.js +2 -0
- package/dist/classes/admin/orders/SearchOrders.d.ts +12 -0
- package/dist/classes/admin/orders/SearchOrders.js +50 -0
- package/dist/classes/admin/orders/index.d.ts +10 -0
- package/dist/classes/admin/orders/index.js +28 -0
- package/dist/classes/storefront/cart/GetPage.d.ts +10 -0
- package/dist/classes/storefront/cart/GetPage.js +43 -0
- package/dist/classes/storefront/cart/UpdateBuyerIdentity.d.ts +15 -0
- package/dist/classes/storefront/cart/UpdateBuyerIdentity.js +48 -0
- package/dist/classes/storefront/cart/index.d.ts +10 -0
- package/dist/classes/storefront/cart/index.js +28 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AdminProductAPIInterface } from "./admin/products";
|
|
2
2
|
import { AdminCollectionAPIInterface } from "./admin/collections";
|
|
3
3
|
import { AdminMetaObjectAPIInterface } from "./admin/metaobjects";
|
|
4
|
+
import { AdminOrderAPIInterface } from "./admin/orders";
|
|
4
5
|
export interface APIOptions extends Record<string, any> {
|
|
5
6
|
shop: string;
|
|
6
7
|
accessToken: string;
|
|
@@ -11,6 +12,7 @@ export declare class AdminAPI {
|
|
|
11
12
|
readonly product: AdminProductAPIInterface;
|
|
12
13
|
readonly collection: AdminCollectionAPIInterface;
|
|
13
14
|
readonly metaobject: AdminMetaObjectAPIInterface;
|
|
15
|
+
readonly order: AdminOrderAPIInterface;
|
|
14
16
|
constructor(options: APIOptions);
|
|
15
17
|
private _createClient;
|
|
16
18
|
}
|
package/dist/classes/AdminAPI.js
CHANGED
|
@@ -5,6 +5,7 @@ const admin_api_client_1 = require("@shopify/admin-api-client");
|
|
|
5
5
|
const products_1 = require("./admin/products");
|
|
6
6
|
const collections_1 = require("./admin/collections");
|
|
7
7
|
const metaobjects_1 = require("./admin/metaobjects");
|
|
8
|
+
const orders_1 = require("./admin/orders");
|
|
8
9
|
class AdminAPI {
|
|
9
10
|
constructor(options) {
|
|
10
11
|
this.options = options;
|
|
@@ -12,6 +13,7 @@ class AdminAPI {
|
|
|
12
13
|
this.product = new products_1.AdminProductAPI(this.client);
|
|
13
14
|
this.collection = new collections_1.AdminCollectionAPI(this.client);
|
|
14
15
|
this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this.client);
|
|
16
|
+
this.order = new orders_1.AdminOrderAPI(this.client);
|
|
15
17
|
}
|
|
16
18
|
_createClient() {
|
|
17
19
|
const { shop, accessToken } = this.options;
|
|
@@ -2,12 +2,14 @@ import { StorefrontAPIOptions } from "../interfaces/StorefrontAPI";
|
|
|
2
2
|
import { PageAPIInterface } from "./storefront/pages";
|
|
3
3
|
import { ShopAPIInterface } from "./storefront/shop";
|
|
4
4
|
import { ProductAPIInterface } from "./storefront/products";
|
|
5
|
+
import { CartAPIInterface } from "./storefront/cart";
|
|
5
6
|
export declare class StorefrontAPI {
|
|
6
7
|
private readonly options;
|
|
7
8
|
private readonly client;
|
|
8
9
|
readonly page: PageAPIInterface;
|
|
9
10
|
readonly shop: ShopAPIInterface;
|
|
10
11
|
readonly product: ProductAPIInterface;
|
|
12
|
+
readonly cart: CartAPIInterface;
|
|
11
13
|
constructor(options: StorefrontAPIOptions);
|
|
12
14
|
private _createClient;
|
|
13
15
|
}
|
|
@@ -5,6 +5,7 @@ const storefront_api_client_1 = require("@shopify/storefront-api-client");
|
|
|
5
5
|
const pages_1 = require("./storefront/pages");
|
|
6
6
|
const shop_1 = require("./storefront/shop");
|
|
7
7
|
const products_1 = require("./storefront/products");
|
|
8
|
+
const cart_1 = require("./storefront/cart");
|
|
8
9
|
class StorefrontAPI {
|
|
9
10
|
constructor(options) {
|
|
10
11
|
this.options = options;
|
|
@@ -12,6 +13,7 @@ class StorefrontAPI {
|
|
|
12
13
|
this.page = new pages_1.PageAPI(this.client);
|
|
13
14
|
this.shop = new shop_1.ShopAPI(this.client);
|
|
14
15
|
this.product = new products_1.ProductAPI(this.client);
|
|
16
|
+
this.cart = new cart_1.CartAPI(this.client);
|
|
15
17
|
}
|
|
16
18
|
_createClient() {
|
|
17
19
|
const { shop, accessToken } = this.options;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface SearchOrdersInput extends Record<string, any> {
|
|
4
|
+
after?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SearchOrdersOutput extends Record<string, any> {
|
|
7
|
+
items: any[];
|
|
8
|
+
pageInfo: any;
|
|
9
|
+
}
|
|
10
|
+
export declare class SearchOrders extends ActionBuilder<AdminApiClient, SearchOrdersInput, SearchOrdersOutput> {
|
|
11
|
+
run(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.SearchOrders = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class SearchOrders extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { after } = Object.assign({}, args);
|
|
19
|
+
const query = `
|
|
20
|
+
{
|
|
21
|
+
orders(first: 100, reverse: true) {
|
|
22
|
+
nodes {
|
|
23
|
+
id
|
|
24
|
+
createdAt
|
|
25
|
+
updatedAt
|
|
26
|
+
name
|
|
27
|
+
shippingAddress {
|
|
28
|
+
countryCodeV2
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
pageInfo {
|
|
32
|
+
hasNextPage
|
|
33
|
+
endCursor
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
const { data, errors } = yield this.client.request(query);
|
|
39
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
40
|
+
const { orders } = Object.assign({}, data);
|
|
41
|
+
const { nodes, pageInfo } = Object.assign({}, orders);
|
|
42
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
43
|
+
return {
|
|
44
|
+
items,
|
|
45
|
+
pageInfo
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.SearchOrders = SearchOrders;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { APIBase } from "../../APIBase";
|
|
3
|
+
import { SearchOrdersInput, SearchOrdersOutput } from "./SearchOrders";
|
|
4
|
+
export interface AdminOrderAPIInterface {
|
|
5
|
+
search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
|
|
6
|
+
}
|
|
7
|
+
export declare class AdminOrderAPI extends APIBase<AdminApiClient> implements AdminOrderAPIInterface {
|
|
8
|
+
private _runAction;
|
|
9
|
+
search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
|
|
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.AdminOrderAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const SearchOrders_1 = require("./SearchOrders");
|
|
15
|
+
class AdminOrderAPI 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
|
+
search(args) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return this._runAction(SearchOrders_1.SearchOrders, args);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.AdminOrderAPI = AdminOrderAPI;
|
|
@@ -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,15 @@
|
|
|
1
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
2
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
|
+
interface BuyerIdentity extends Record<string, any> {
|
|
4
|
+
countryCode?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface UpdateBuyerIdentityInput extends Record<string, any> {
|
|
7
|
+
id: string;
|
|
8
|
+
buyerIdentity: BuyerIdentity;
|
|
9
|
+
}
|
|
10
|
+
export interface UpdateBuyerIdentityOutput extends Record<string, any> {
|
|
11
|
+
}
|
|
12
|
+
export declare class UpdateBuyerIdentity extends ActionBuilder<StorefrontApiClient, UpdateBuyerIdentityInput, UpdateBuyerIdentityOutput> {
|
|
13
|
+
run(args: UpdateBuyerIdentityInput): Promise<UpdateBuyerIdentityOutput>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
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.UpdateBuyerIdentity = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
class UpdateBuyerIdentity extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const query = `
|
|
19
|
+
mutation cartBuyerIdentityUpdate($buyerIdentity: CartBuyerIdentityInput!, $cartId: ID!) {
|
|
20
|
+
cartBuyerIdentityUpdate(buyerIdentity: $buyerIdentity, cartId: $cartId) {
|
|
21
|
+
cart {
|
|
22
|
+
id
|
|
23
|
+
buyerIdentity {
|
|
24
|
+
countryCode
|
|
25
|
+
email
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
userErrors {
|
|
29
|
+
field
|
|
30
|
+
message
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
const { id, buyerIdentity } = args;
|
|
36
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Cart');
|
|
37
|
+
const { data } = yield this.client.request(query, {
|
|
38
|
+
variables: {
|
|
39
|
+
cartId: globalId,
|
|
40
|
+
buyerIdentity
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const { cartBuyerIdentityUpdate } = Object.assign({}, data);
|
|
44
|
+
return Object.assign({}, cartBuyerIdentityUpdate);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.UpdateBuyerIdentity = UpdateBuyerIdentity;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { APIBase } from "../../APIBase";
|
|
2
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
|
+
import { UpdateBuyerIdentityInput, UpdateBuyerIdentityOutput } from "./UpdateBuyerIdentity";
|
|
4
|
+
export interface CartAPIInterface {
|
|
5
|
+
updateBuyer(args: UpdateBuyerIdentityInput): Promise<UpdateBuyerIdentityOutput>;
|
|
6
|
+
}
|
|
7
|
+
export declare class CartAPI extends APIBase<StorefrontApiClient> implements CartAPIInterface {
|
|
8
|
+
private _runAction;
|
|
9
|
+
updateBuyer(args: UpdateBuyerIdentityInput): Promise<UpdateBuyerIdentityOutput>;
|
|
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.CartAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const UpdateBuyerIdentity_1 = require("./UpdateBuyerIdentity");
|
|
15
|
+
class CartAPI 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
|
+
updateBuyer(args) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return this._runAction(UpdateBuyerIdentity_1.UpdateBuyerIdentity, args);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.CartAPI = CartAPI;
|