@pintahub/shopify-api 1.3.3 → 1.3.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/classes/admin/products/GetProduct.js +8 -2
- package/dist/classes/admin/products/PublishProduct.d.ts +14 -0
- package/dist/classes/admin/products/PublishProduct.js +60 -0
- package/dist/classes/admin/products/index.d.ts +3 -0
- package/dist/classes/admin/products/index.js +6 -0
- package/package.json +1 -1
|
@@ -27,7 +27,7 @@ class GetProduct extends ActionBuilder_1.ActionBuilder {
|
|
|
27
27
|
status
|
|
28
28
|
featuredImage {
|
|
29
29
|
altText
|
|
30
|
-
url(transform: {preferredContentType: PNG, maxWidth:
|
|
30
|
+
url(transform: {preferredContentType: PNG, maxWidth: 1200})
|
|
31
31
|
width
|
|
32
32
|
height
|
|
33
33
|
}
|
|
@@ -67,7 +67,13 @@ class GetProduct extends ActionBuilder_1.ActionBuilder {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
`;
|
|
70
|
-
const { data } = yield this.client.request(query);
|
|
70
|
+
const { data, errors, extensions } = yield this.client.request(query);
|
|
71
|
+
if (errors) {
|
|
72
|
+
const { message } = Object.assign({}, errors);
|
|
73
|
+
if (message) {
|
|
74
|
+
throw new Error(message);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
71
77
|
const { product } = Object.assign({}, data);
|
|
72
78
|
return Object.assign({
|
|
73
79
|
status: 'DELETED'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface PublicationObject extends Record<string, any> {
|
|
4
|
+
publicationId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PublishProductInput extends Record<string, any> {
|
|
7
|
+
id: string;
|
|
8
|
+
productPublications: Array<PublicationObject>;
|
|
9
|
+
}
|
|
10
|
+
export interface PublishProductOutput extends Record<string, any> {
|
|
11
|
+
}
|
|
12
|
+
export declare class PublishProduct extends ActionBuilder<AdminApiClient, PublishProductInput, PublishProductOutput> {
|
|
13
|
+
run(args: PublishProductInput): Promise<PublishProductOutput>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.PublishProduct = void 0;
|
|
24
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
25
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
26
|
+
class PublishProduct extends ActionBuilder_1.ActionBuilder {
|
|
27
|
+
run(args) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const query = `
|
|
30
|
+
mutation productPublish($input: ProductPublishInput!) {
|
|
31
|
+
productPublish(input: $input) {
|
|
32
|
+
product {
|
|
33
|
+
id
|
|
34
|
+
status
|
|
35
|
+
title
|
|
36
|
+
handle
|
|
37
|
+
}
|
|
38
|
+
userErrors {
|
|
39
|
+
field
|
|
40
|
+
message
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
const _a = Object.assign({}, args), { id } = _a, rest = __rest(_a, ["id"]);
|
|
46
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id);
|
|
47
|
+
const newArgs = Object.assign(Object.assign({}, rest), { id: globalId });
|
|
48
|
+
const result = yield this.client.request(query, {
|
|
49
|
+
variables: {
|
|
50
|
+
input: newArgs
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const { data } = Object.assign({}, result);
|
|
54
|
+
const { productPublish } = Object.assign({}, data);
|
|
55
|
+
const { product } = Object.assign({}, productPublish);
|
|
56
|
+
return Object.assign({}, product);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.PublishProduct = PublishProduct;
|
|
@@ -7,10 +7,12 @@ import { UpdateVariantInput, UpdateVariantOutput } from "./UpdateVariant";
|
|
|
7
7
|
import { CreateProductInput, CreateProductOutput } from "./CreateProduct";
|
|
8
8
|
import { CreateProductMediaInput, CreateProductMediaOutput } from "./CreateProductMedia";
|
|
9
9
|
import { UpdateProductInput, UpdateProductOutput } from "./UpdateProduct";
|
|
10
|
+
import { PublishProductInput, PublishProductOutput } from "./PublishProduct";
|
|
10
11
|
export interface AdminProductAPIInterface {
|
|
11
12
|
get(args: GetProductInput): Promise<GetProductOutput>;
|
|
12
13
|
create(args: CreateProductInput): Promise<CreateProductOutput>;
|
|
13
14
|
update(args: UpdateProductInput): Promise<UpdateProductOutput>;
|
|
15
|
+
publish(args: PublishProductInput): Promise<PublishProductOutput>;
|
|
14
16
|
getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
|
|
15
17
|
search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
16
18
|
updateVariant(args: UpdateVariantInput): Promise<UpdateVariantOutput>;
|
|
@@ -21,6 +23,7 @@ export declare class AdminProductAPI extends APIBase<AdminApiClient> implements
|
|
|
21
23
|
get(args: GetProductInput): Promise<GetProductOutput>;
|
|
22
24
|
create(args: CreateProductInput): Promise<CreateProductOutput>;
|
|
23
25
|
update(args: UpdateProductInput): Promise<UpdateProductOutput>;
|
|
26
|
+
publish(args: PublishProductInput): Promise<PublishProductOutput>;
|
|
24
27
|
getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
|
|
25
28
|
search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
26
29
|
updateVariant(args: UpdateVariantInput): Promise<UpdateVariantOutput>;
|
|
@@ -18,6 +18,7 @@ const UpdateVariant_1 = require("./UpdateVariant");
|
|
|
18
18
|
const CreateProduct_1 = require("./CreateProduct");
|
|
19
19
|
const CreateProductMedia_1 = require("./CreateProductMedia");
|
|
20
20
|
const UpdateProduct_1 = require("./UpdateProduct");
|
|
21
|
+
const PublishProduct_1 = require("./PublishProduct");
|
|
21
22
|
class AdminProductAPI extends APIBase_1.APIBase {
|
|
22
23
|
_runAction(Action, args) {
|
|
23
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40,6 +41,11 @@ class AdminProductAPI extends APIBase_1.APIBase {
|
|
|
40
41
|
return this._runAction(UpdateProduct_1.UpdateProduct, args);
|
|
41
42
|
});
|
|
42
43
|
}
|
|
44
|
+
publish(args) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return this._runAction(PublishProduct_1.PublishProduct, args);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
43
49
|
getPublications(args) {
|
|
44
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
51
|
return this._runAction(GetPublications_1.GetPublications, args);
|