@pintahub/shopify-api 1.5.4 → 1.5.6
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/admin/files/GetImage.js +6 -7
- package/dist/classes/admin/files/SearchImages.d.ts +12 -0
- package/dist/classes/admin/files/SearchImages.js +50 -0
- package/dist/classes/admin/files/index.d.ts +3 -0
- package/dist/classes/admin/files/index.js +6 -0
- package/dist/classes/admin/products/CreateVariant.d.ts +12 -0
- package/dist/classes/admin/products/CreateVariant.js +56 -0
- package/dist/classes/storefront/cart/GetCart.d.ts +10 -0
- package/dist/classes/storefront/cart/GetCart.js +37 -0
- package/dist/classes/storefront/cart/index.d.ts +3 -0
- package/dist/classes/storefront/cart/index.js +6 -0
- package/dist/fragments/cart.d.ts +1 -0
- package/dist/fragments/cart.js +82 -0
- package/package.json +1 -1
|
@@ -24,19 +24,18 @@ class GetImage extends ActionBuilder_1.ActionBuilder {
|
|
|
24
24
|
id
|
|
25
25
|
... on MediaImage {
|
|
26
26
|
id
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
mimeType
|
|
28
|
+
createdAt
|
|
29
|
+
updatedAt
|
|
29
30
|
image {
|
|
30
31
|
altText
|
|
31
32
|
height
|
|
32
33
|
url
|
|
33
34
|
width
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
createdAt
|
|
39
|
-
updatedAt
|
|
36
|
+
originalSource {
|
|
37
|
+
fileSize
|
|
38
|
+
}
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface SearchImagesInput extends Record<string, any> {
|
|
4
|
+
after?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SearchImagesOutput extends Record<string, any> {
|
|
7
|
+
items: any[];
|
|
8
|
+
pageInfo: any;
|
|
9
|
+
}
|
|
10
|
+
export declare class SearchImages extends ActionBuilder<AdminApiClient, SearchImagesInput, SearchImagesOutput> {
|
|
11
|
+
run(args?: SearchImagesInput): Promise<SearchImagesOutput>;
|
|
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.SearchImages = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class SearchImages 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
|
+
files(
|
|
22
|
+
query: "media_type:IMAGE"
|
|
23
|
+
first: 10
|
|
24
|
+
sortKey: UPDATED_AT
|
|
25
|
+
reverse: true
|
|
26
|
+
${after ? `after: "${after}"` : ''}
|
|
27
|
+
) {
|
|
28
|
+
nodes {
|
|
29
|
+
id
|
|
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 { files } = Object.assign({}, data);
|
|
41
|
+
const { nodes, pageInfo } = Object.assign({}, files);
|
|
42
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
43
|
+
return {
|
|
44
|
+
items,
|
|
45
|
+
pageInfo
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.SearchImages = SearchImages;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
2
|
import { APIBase } from "../../APIBase";
|
|
3
3
|
import { GetImageInput, GetImageOutput } from "./GetImage";
|
|
4
|
+
import { SearchImagesInput, SearchImagesOutput } from "./SearchImages";
|
|
4
5
|
export interface AdminFileAPIInterface {
|
|
6
|
+
searchImages(args: SearchImagesInput): Promise<SearchImagesOutput>;
|
|
5
7
|
getImage(args: GetImageInput): Promise<GetImageOutput>;
|
|
6
8
|
}
|
|
7
9
|
export declare class AdminFileAPI extends APIBase<AdminApiClient> implements AdminFileAPIInterface {
|
|
8
10
|
private _runAction;
|
|
11
|
+
searchImages(args?: SearchImagesInput): Promise<SearchImagesOutput>;
|
|
9
12
|
getImage(args?: GetImageInput): Promise<GetImageOutput>;
|
|
10
13
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.AdminFileAPI = void 0;
|
|
13
13
|
const APIBase_1 = require("../../APIBase");
|
|
14
14
|
const GetImage_1 = require("./GetImage");
|
|
15
|
+
const SearchImages_1 = require("./SearchImages");
|
|
15
16
|
class AdminFileAPI extends APIBase_1.APIBase {
|
|
16
17
|
_runAction(Action, args) {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -19,6 +20,11 @@ class AdminFileAPI extends APIBase_1.APIBase {
|
|
|
19
20
|
return action.run(args);
|
|
20
21
|
});
|
|
21
22
|
}
|
|
23
|
+
searchImages(args) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return this._runAction(SearchImages_1.SearchImages, args);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
22
28
|
getImage(args) {
|
|
23
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
30
|
return this._runAction(GetImage_1.GetImage, args);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface CreateVariantInput extends Record<string, any> {
|
|
4
|
+
productId: string;
|
|
5
|
+
price?: string;
|
|
6
|
+
options?: string[] | string;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateVariantOutput extends Record<string, any> {
|
|
9
|
+
}
|
|
10
|
+
export declare class CreateVariant extends ActionBuilder<AdminApiClient, CreateVariantInput, CreateVariantOutput> {
|
|
11
|
+
run(args: CreateVariantInput): Promise<CreateVariantOutput>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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.CreateVariant = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
16
|
+
class CreateVariant extends ActionBuilder_1.ActionBuilder {
|
|
17
|
+
run(args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { productId } = args;
|
|
20
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(productId, 'Product');
|
|
21
|
+
const input = Object.assign(Object.assign({}, args), { productId: globalId });
|
|
22
|
+
const query = `
|
|
23
|
+
mutation productVariantCreate($input: ProductVariantInput!) {
|
|
24
|
+
productVariantCreate(input: $input) {
|
|
25
|
+
product {
|
|
26
|
+
id
|
|
27
|
+
title
|
|
28
|
+
}
|
|
29
|
+
productVariant {
|
|
30
|
+
id
|
|
31
|
+
createdAt
|
|
32
|
+
displayName
|
|
33
|
+
price
|
|
34
|
+
title
|
|
35
|
+
}
|
|
36
|
+
userErrors {
|
|
37
|
+
field
|
|
38
|
+
message
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
const { data, errors } = yield this.client.request(query, {
|
|
44
|
+
variables: {
|
|
45
|
+
input
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
console.log('data', JSON.stringify(data, null, 2));
|
|
49
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
50
|
+
const { productVariantCreate } = Object.assign({}, data);
|
|
51
|
+
const { productVariant } = Object.assign({}, productVariantCreate);
|
|
52
|
+
return Object.assign({}, productVariant);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.CreateVariant = CreateVariant;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
2
|
+
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
|
+
export interface GetCartInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetCartOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class GetCart extends ActionBuilder<StorefrontApiClient, GetCartInput, GetCartOutput> {
|
|
9
|
+
run(args: GetCartInput): Promise<GetCartOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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.GetCart = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
const cart_1 = require("../../../fragments/cart");
|
|
16
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
17
|
+
class GetCart extends ActionBuilder_1.ActionBuilder {
|
|
18
|
+
run(args) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const { id } = Object.assign({}, args);
|
|
21
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Cart');
|
|
22
|
+
const query = `
|
|
23
|
+
{
|
|
24
|
+
cart(id: "${globalId}") {
|
|
25
|
+
...cart
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
${cart_1.cartFragment}
|
|
29
|
+
`;
|
|
30
|
+
const { data, errors } = yield this.client.request(query);
|
|
31
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
32
|
+
const { cart } = Object.assign({}, data);
|
|
33
|
+
return Object.assign({}, cart);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.GetCart = GetCart;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { APIBase } from "../../APIBase";
|
|
2
2
|
import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
|
|
3
3
|
import { UpdateBuyerIdentityInput, UpdateBuyerIdentityOutput } from "./UpdateBuyerIdentity";
|
|
4
|
+
import { GetCartInput, GetCartOutput } from "./GetCart";
|
|
4
5
|
export interface CartAPIInterface {
|
|
6
|
+
get(args: GetCartInput): Promise<GetCartOutput>;
|
|
5
7
|
updateBuyer(args: UpdateBuyerIdentityInput): Promise<UpdateBuyerIdentityOutput>;
|
|
6
8
|
}
|
|
7
9
|
export declare class CartAPI extends APIBase<StorefrontApiClient> implements CartAPIInterface {
|
|
8
10
|
private _runAction;
|
|
9
11
|
updateBuyer(args: UpdateBuyerIdentityInput): Promise<UpdateBuyerIdentityOutput>;
|
|
12
|
+
get(args: GetCartInput): Promise<GetCartOutput>;
|
|
10
13
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.CartAPI = void 0;
|
|
13
13
|
const APIBase_1 = require("../../APIBase");
|
|
14
14
|
const UpdateBuyerIdentity_1 = require("./UpdateBuyerIdentity");
|
|
15
|
+
const GetCart_1 = require("./GetCart");
|
|
15
16
|
class CartAPI extends APIBase_1.APIBase {
|
|
16
17
|
_runAction(Action, args) {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -24,5 +25,10 @@ class CartAPI extends APIBase_1.APIBase {
|
|
|
24
25
|
return this._runAction(UpdateBuyerIdentity_1.UpdateBuyerIdentity, args);
|
|
25
26
|
});
|
|
26
27
|
}
|
|
28
|
+
get(args) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return this._runAction(GetCart_1.GetCart, args);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
34
|
exports.CartAPI = CartAPI;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cartFragment = "\nfragment cart on Cart {\n id\n cost {\n subtotalAmount {\n amount\n currencyCode\n }\n totalAmount {\n amount\n currencyCode\n }\n }\n totalQuantity\n lines(first: 250, reverse: false) {\n nodes {\n id\n quantity\n attributes {\n value\n key\n }\n merchandise {\n ... on ProductVariant {\n title\n selectedOptions {\n name\n value\n }\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n image {\n url(transform: {maxWidth: 300})\n altText\n width\n height\n }\n product {\n id\n title\n handle\n }\n id\n }\n }\n discountAllocations {\n discountedAmount {\n amount\n currencyCode\n }\n ... on CartAutomaticDiscountAllocation {\n __typename\n title\n }\n }\n }\n }\n discountAllocations {\n discountedAmount {\n amount\n currencyCode\n }\n ... on CartAutomaticDiscountAllocation {\n __typename\n title\n }\n }\n buyerIdentity {\n countryCode\n }\n checkoutUrl\n}\n";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cartFragment = void 0;
|
|
4
|
+
exports.cartFragment = `
|
|
5
|
+
fragment cart on Cart {
|
|
6
|
+
id
|
|
7
|
+
cost {
|
|
8
|
+
subtotalAmount {
|
|
9
|
+
amount
|
|
10
|
+
currencyCode
|
|
11
|
+
}
|
|
12
|
+
totalAmount {
|
|
13
|
+
amount
|
|
14
|
+
currencyCode
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
totalQuantity
|
|
18
|
+
lines(first: 250, reverse: false) {
|
|
19
|
+
nodes {
|
|
20
|
+
id
|
|
21
|
+
quantity
|
|
22
|
+
attributes {
|
|
23
|
+
value
|
|
24
|
+
key
|
|
25
|
+
}
|
|
26
|
+
merchandise {
|
|
27
|
+
... on ProductVariant {
|
|
28
|
+
title
|
|
29
|
+
selectedOptions {
|
|
30
|
+
name
|
|
31
|
+
value
|
|
32
|
+
}
|
|
33
|
+
price {
|
|
34
|
+
amount
|
|
35
|
+
currencyCode
|
|
36
|
+
}
|
|
37
|
+
compareAtPrice {
|
|
38
|
+
amount
|
|
39
|
+
currencyCode
|
|
40
|
+
}
|
|
41
|
+
image {
|
|
42
|
+
url(transform: {maxWidth: 300})
|
|
43
|
+
altText
|
|
44
|
+
width
|
|
45
|
+
height
|
|
46
|
+
}
|
|
47
|
+
product {
|
|
48
|
+
id
|
|
49
|
+
title
|
|
50
|
+
handle
|
|
51
|
+
}
|
|
52
|
+
id
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
discountAllocations {
|
|
56
|
+
discountedAmount {
|
|
57
|
+
amount
|
|
58
|
+
currencyCode
|
|
59
|
+
}
|
|
60
|
+
... on CartAutomaticDiscountAllocation {
|
|
61
|
+
__typename
|
|
62
|
+
title
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
discountAllocations {
|
|
68
|
+
discountedAmount {
|
|
69
|
+
amount
|
|
70
|
+
currencyCode
|
|
71
|
+
}
|
|
72
|
+
... on CartAutomaticDiscountAllocation {
|
|
73
|
+
__typename
|
|
74
|
+
title
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
buyerIdentity {
|
|
78
|
+
countryCode
|
|
79
|
+
}
|
|
80
|
+
checkoutUrl
|
|
81
|
+
}
|
|
82
|
+
`;
|