@pintahub/shopify-api 1.8.5 → 1.8.7

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.
@@ -35,7 +35,6 @@ class AppendMedia extends ActionBuilder_1.ActionBuilder {
35
35
  };
36
36
  })
37
37
  };
38
- console.log('args', JSON.stringify(newArgs, null, 2));
39
38
  const { data, errors } = yield this.client.request(query, {
40
39
  variables: newArgs
41
40
  });
@@ -10,6 +10,7 @@ export interface CreateProductMediaInput extends Record<string, any> {
10
10
  media: Array<MediaObject>;
11
11
  }
12
12
  export interface CreateProductMediaOutput extends Record<string, any> {
13
+ media: Array<Record<string, any>>;
13
14
  }
14
15
  export declare class CreateProductMedia extends ActionBuilder<AdminApiClient, CreateProductMediaInput, CreateProductMediaOutput> {
15
16
  run(args: CreateProductMediaInput): Promise<CreateProductMediaOutput>;
@@ -0,0 +1,11 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface GetVariantsInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetVariantsOutput extends Record<string, any> {
7
+ variants: Array<Record<string, any>>;
8
+ }
9
+ export declare class GetVariants extends ActionBuilder<AdminApiClient, GetVariantsInput, GetVariantsOutput> {
10
+ run(args: GetVariantsInput): Promise<GetVariantsOutput>;
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.GetVariants = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class GetVariants 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
+ variants(first: 250) {
26
+ nodes {
27
+ id
28
+ availableForSale
29
+ selectedOptions {
30
+ name
31
+ value
32
+ }
33
+ image {
34
+ id
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ `;
41
+ const { data, errors } = yield this.client.request(query);
42
+ yield (0, handleErrors_1.handleErrors)(errors);
43
+ const { product } = Object.assign({}, data);
44
+ const { variants, id: productId } = Object.assign({}, product);
45
+ if (!productId) {
46
+ throw new Error('Product not found!');
47
+ }
48
+ const { nodes } = Object.assign({}, variants);
49
+ const arr = Array.isArray(nodes) ? nodes : [];
50
+ return {
51
+ variants: arr
52
+ };
53
+ });
54
+ }
55
+ }
56
+ exports.GetVariants = GetVariants;
@@ -10,6 +10,7 @@ import { UpdateProductInput, UpdateProductOutput } from "./UpdateProduct";
10
10
  import { PublishProductInput, PublishProductOutput } from "./PublishProduct";
11
11
  import { DeleteProductInput, DeleteProductOutput } from "./DeleteProduct";
12
12
  import { AppendMediaInput, AppendMediaOutput } from "./AppendMedia";
13
+ import { GetVariantsInput, GetVariantsOutput } from "./GetVariants";
13
14
  export interface AdminProductAPIInterface {
14
15
  get(args: GetProductInput): Promise<GetProductOutput>;
15
16
  create(args: CreateProductInput): Promise<CreateProductOutput>;
@@ -18,6 +19,7 @@ export interface AdminProductAPIInterface {
18
19
  publish(args: PublishProductInput): Promise<PublishProductOutput>;
19
20
  getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
20
21
  search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
22
+ getVariants(args: GetVariantsInput): Promise<GetVariantsOutput>;
21
23
  updateVariant(args: UpdateVariantInput): Promise<UpdateVariantOutput>;
22
24
  createMedia(args: CreateProductMediaInput): Promise<CreateProductMediaOutput>;
23
25
  appendMedia(args: AppendMediaInput): Promise<AppendMediaOutput>;
@@ -31,6 +33,7 @@ export declare class AdminProductAPI extends APIBase<AdminApiClient> implements
31
33
  publish(args: PublishProductInput): Promise<PublishProductOutput>;
32
34
  getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
33
35
  search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
36
+ getVariants(args: GetVariantsInput): Promise<GetVariantsOutput>;
34
37
  updateVariant(args: UpdateVariantInput): Promise<UpdateVariantOutput>;
35
38
  createMedia(args: CreateProductMediaInput): Promise<CreateProductMediaOutput>;
36
39
  appendMedia(args: AppendMediaInput): Promise<AppendMediaOutput>;
@@ -21,6 +21,7 @@ const UpdateProduct_1 = require("./UpdateProduct");
21
21
  const PublishProduct_1 = require("./PublishProduct");
22
22
  const DeleteProduct_1 = require("./DeleteProduct");
23
23
  const AppendMedia_1 = require("./AppendMedia");
24
+ const GetVariants_1 = require("./GetVariants");
24
25
  class AdminProductAPI extends APIBase_1.APIBase {
25
26
  _runAction(Action, args) {
26
27
  return __awaiter(this, void 0, void 0, function* () {
@@ -63,6 +64,11 @@ class AdminProductAPI extends APIBase_1.APIBase {
63
64
  return this._runAction(SearchProducts_1.SearchProducts, args);
64
65
  });
65
66
  }
67
+ getVariants(args) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ return this._runAction(GetVariants_1.GetVariants, args);
70
+ });
71
+ }
66
72
  updateVariant(args) {
67
73
  return __awaiter(this, void 0, void 0, function* () {
68
74
  return this._runAction(UpdateVariant_1.UpdateVariant, args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.8.5",
3
+ "version": "1.8.7",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -11,6 +11,7 @@
11
11
  "devDependencies": {
12
12
  "@types/bluebird": "^3.5.42",
13
13
  "@types/node": "^20.10.4",
14
+ "bluebird": "^3.7.2",
14
15
  "dotenv": "^16.3.1"
15
16
  },
16
17
  "dependencies": {