@pintahub/shopify-api 2.3.5 → 2.3.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.
@@ -0,0 +1,11 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface PublishProductInput extends Record<string, any> {
4
+ id: string;
5
+ publicationId: string;
6
+ }
7
+ export interface PublishProductOutput extends Record<string, any> {
8
+ }
9
+ export declare class PublishProduct extends ActionBuilder<AdminApiClient, PublishProductInput, PublishProductOutput> {
10
+ run(args: PublishProductInput): Promise<PublishProductOutput>;
11
+ }
@@ -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.PublishProduct = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class PublishProduct extends ActionBuilder_1.ActionBuilder {
17
+ run(args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const query = `
20
+ mutation publishablePublish($id: ID!, $input: [PublicationInput!]!) {
21
+ publishablePublish(id: $id, input: $input) {
22
+ publishable {
23
+ availablePublicationsCount {
24
+ count
25
+ }
26
+ resourcePublicationsCount {
27
+ count
28
+ }
29
+ }
30
+ userErrors {
31
+ field
32
+ message
33
+ }
34
+ }
35
+ }
36
+ `;
37
+ const { id, publicationId } = Object.assign({}, args);
38
+ const productId = (0, getGlobalID_1.getGlobalID)(id, 'Product');
39
+ const pubId = (0, getGlobalID_1.getGlobalID)(publicationId, 'Publication');
40
+ const newArgs = {
41
+ id: productId,
42
+ input: {
43
+ publicationId: pubId
44
+ }
45
+ };
46
+ const { data, errors } = yield this.client.request(query, {
47
+ variables: newArgs
48
+ });
49
+ yield (0, handleErrors_1.handleErrors)(errors);
50
+ const { publishablePublish } = Object.assign({}, data);
51
+ const { publishable } = Object.assign({}, publishablePublish);
52
+ return Object.assign({}, publishable);
53
+ });
54
+ }
55
+ }
56
+ exports.PublishProduct = PublishProduct;
@@ -11,6 +11,7 @@ import { UpdateProductOptionInput, UpdateProductOptionOutput } from "./UpdatePro
11
11
  import { GetProductOptionsInput, GetProductOptionsOutput } from "./GetProductOptions";
12
12
  import { ReorderMediaInput, ReorderMediaOutput } from "./ReorderMedia";
13
13
  import { CreateProductInput, CreateProductOutput } from "./CreateProduct";
14
+ import { PublishProductInput, PublishProductOutput } from "./PublishProduct";
14
15
  export interface AdminProductsAPIInterface {
15
16
  search(args: SearchProductsInput): Promise<SearchProductsOutput>;
16
17
  get(args: GetProductInput): Promise<GetProductOutput>;
@@ -23,6 +24,7 @@ export interface AdminProductsAPIInterface {
23
24
  deleteMedia(args: DeleteProductMediaInput): Promise<DeleteProductMediaOutput>;
24
25
  updateOption(args: UpdateProductOptionInput): Promise<UpdateProductOptionOutput>;
25
26
  reorderMedia(args: ReorderMediaInput): Promise<ReorderMediaOutput>;
27
+ publish(args: PublishProductInput): Promise<PublishProductOutput>;
26
28
  }
27
29
  export declare class AdminProductsAPI extends APIBase<AdminApiClient> implements AdminProductsAPIInterface {
28
30
  private _runAction;
@@ -37,4 +39,5 @@ export declare class AdminProductsAPI extends APIBase<AdminApiClient> implements
37
39
  deleteMedia(args: DeleteProductMediaInput): Promise<DeleteProductMediaOutput>;
38
40
  updateOption(args: UpdateProductOptionInput): Promise<UpdateProductOptionOutput>;
39
41
  reorderMedia(args: ReorderMediaInput): Promise<ReorderMediaOutput>;
42
+ publish(args: PublishProductInput): Promise<PublishProductOutput>;
40
43
  }
@@ -22,6 +22,7 @@ const UpdateProductOption_1 = require("./UpdateProductOption");
22
22
  const GetProductOptions_1 = require("./GetProductOptions");
23
23
  const ReorderMedia_1 = require("./ReorderMedia");
24
24
  const CreateProduct_1 = require("./CreateProduct");
25
+ const PublishProduct_1 = require("./PublishProduct");
25
26
  class AdminProductsAPI extends APIBase_1.APIBase {
26
27
  _runAction(Action, args) {
27
28
  return __awaiter(this, void 0, void 0, function* () {
@@ -84,5 +85,10 @@ class AdminProductsAPI extends APIBase_1.APIBase {
84
85
  return this._runAction(ReorderMedia_1.ReorderMedia, args);
85
86
  });
86
87
  }
88
+ publish(args) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ return this._runAction(PublishProduct_1.PublishProduct, args);
91
+ });
92
+ }
87
93
  }
88
94
  exports.AdminProductsAPI = AdminProductsAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",