@pintahub/shopify-api 2.1.7 → 2.1.8

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,10 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface GetProductOptionsInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetProductOptionsOutput extends Record<string, any> {
7
+ }
8
+ export declare class GetProductOptions extends ActionBuilder<AdminApiClient, GetProductOptionsInput, GetProductOptionsOutput> {
9
+ run(args: GetProductOptionsInput): Promise<GetProductOptionsOutput>;
10
+ }
@@ -0,0 +1,53 @@
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.GetProductOptions = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class GetProductOptions 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
+ options {
26
+ id
27
+ name
28
+ values
29
+ position
30
+ linkedMetafield {
31
+ key
32
+ namespace
33
+ }
34
+ optionValues {
35
+ id
36
+ name
37
+ linkedMetafieldValue
38
+ }
39
+ }
40
+ }
41
+ }
42
+ `;
43
+ const { data, errors } = yield this.client.request(query);
44
+ yield (0, handleErrors_1.handleErrors)(errors);
45
+ const { product } = Object.assign({}, data);
46
+ const { options } = Object.assign({}, product);
47
+ return {
48
+ options
49
+ };
50
+ });
51
+ }
52
+ }
53
+ exports.GetProductOptions = GetProductOptions;
@@ -0,0 +1,15 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ import { OptionUpdateInput } from "../../../input/OptionUpdateInput";
4
+ import { OptionValueUpdateInput } from "../../../input/OptionValueUpdateInput";
5
+ export interface UpdateProductOptionInput extends Record<string, any> {
6
+ productId: string;
7
+ option: OptionUpdateInput;
8
+ optionValuesToUpdate?: OptionValueUpdateInput[];
9
+ optionValuesToDelete?: string[];
10
+ }
11
+ export interface UpdateProductOptionOutput extends Record<string, any> {
12
+ }
13
+ export declare class UpdateProductOption extends ActionBuilder<AdminApiClient, UpdateProductOptionInput, UpdateProductOptionOutput> {
14
+ run(args: UpdateProductOptionInput): Promise<UpdateProductOptionOutput>;
15
+ }
@@ -0,0 +1,53 @@
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.UpdateProductOption = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class UpdateProductOption extends ActionBuilder_1.ActionBuilder {
17
+ run(args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const query = `
20
+ mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {
21
+ productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {
22
+ userErrors {
23
+ field
24
+ message
25
+ code
26
+ }
27
+ product {
28
+ id
29
+ options {
30
+ id
31
+ name
32
+ values
33
+ position
34
+ }
35
+ }
36
+ }
37
+ }
38
+ `;
39
+ const { productId } = Object.assign({}, args);
40
+ const globalId = (0, getGlobalID_1.getGlobalID)(productId);
41
+ const newArgs = Object.assign(Object.assign({}, args), { productId: globalId });
42
+ const result = yield this.client.request(query, {
43
+ variables: newArgs
44
+ });
45
+ const { data, errors } = Object.assign({}, result);
46
+ yield (0, handleErrors_1.handleErrors)(errors);
47
+ const { productOptionUpdate } = Object.assign({}, data);
48
+ const { product: updatedProduct } = Object.assign({}, productOptionUpdate);
49
+ return Object.assign({}, updatedProduct);
50
+ });
51
+ }
52
+ }
53
+ exports.UpdateProductOption = UpdateProductOption;
@@ -7,22 +7,28 @@ import { SearchProductsInput, SearchProductsOutput } from "./SearchProducts";
7
7
  import { GetProductMediaInput, GetProductMediaOutput } from "./GetProductMedia";
8
8
  import { DeleteProductMediaInput, DeleteProductMediaOutput } from "./DeleteProductMedia";
9
9
  import { DeleteProductInput, DeleteProductOutput } from "./DeleteProduct";
10
+ import { UpdateProductOptionInput, UpdateProductOptionOutput } from "./UpdateProductOption";
11
+ import { GetProductOptionsInput, GetProductOptionsOutput } from "./GetProductOptions";
10
12
  export interface AdminProductsAPIInterface {
11
13
  search(args: SearchProductsInput): Promise<SearchProductsOutput>;
12
14
  get(args: GetProductInput): Promise<GetProductOutput>;
15
+ getOptions(args: GetProductOptionsInput): Promise<GetProductOptionsOutput>;
13
16
  update(args: UpdateProductInput): Promise<UpdateProductOutput>;
14
17
  delete(args: DeleteProductInput): Promise<DeleteProductOutput>;
15
18
  updateVariants(args: UpdateVariantsInput): Promise<UpdateVariantsOutput>;
16
19
  getMedia(args: GetProductMediaInput): Promise<GetProductMediaOutput>;
17
20
  deleteMedia(args: DeleteProductMediaInput): Promise<DeleteProductMediaOutput>;
21
+ updateOption(args: UpdateProductOptionInput): Promise<UpdateProductOptionOutput>;
18
22
  }
19
23
  export declare class AdminProductsAPI extends APIBase<AdminApiClient> implements AdminProductsAPIInterface {
20
24
  private _runAction;
21
25
  search(args: SearchProductsInput): Promise<SearchProductsOutput>;
22
26
  get(args: GetProductInput): Promise<GetProductOutput>;
27
+ getOptions(args: GetProductOptionsInput): Promise<GetProductOptionsOutput>;
23
28
  update(args: UpdateProductInput): Promise<UpdateProductOutput>;
24
29
  delete(args: DeleteProductInput): Promise<DeleteProductOutput>;
25
30
  updateVariants(args: UpdateVariantsInput): Promise<UpdateVariantsOutput>;
26
31
  getMedia(args: GetProductMediaInput): Promise<GetProductMediaOutput>;
27
32
  deleteMedia(args: DeleteProductMediaInput): Promise<DeleteProductMediaOutput>;
33
+ updateOption(args: UpdateProductOptionInput): Promise<UpdateProductOptionOutput>;
28
34
  }
@@ -18,6 +18,8 @@ const SearchProducts_1 = require("./SearchProducts");
18
18
  const GetProductMedia_1 = require("./GetProductMedia");
19
19
  const DeleteProductMedia_1 = require("./DeleteProductMedia");
20
20
  const DeleteProduct_1 = require("./DeleteProduct");
21
+ const UpdateProductOption_1 = require("./UpdateProductOption");
22
+ const GetProductOptions_1 = require("./GetProductOptions");
21
23
  class AdminProductsAPI extends APIBase_1.APIBase {
22
24
  _runAction(Action, args) {
23
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -35,6 +37,11 @@ class AdminProductsAPI extends APIBase_1.APIBase {
35
37
  return this._runAction(GetProduct_1.GetProduct, args);
36
38
  });
37
39
  }
40
+ getOptions(args) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ return this._runAction(GetProductOptions_1.GetProductOptions, args);
43
+ });
44
+ }
38
45
  update(args) {
39
46
  return __awaiter(this, void 0, void 0, function* () {
40
47
  return this._runAction(UpdateProduct_1.UpdateProduct, args);
@@ -60,5 +67,10 @@ class AdminProductsAPI extends APIBase_1.APIBase {
60
67
  return this._runAction(DeleteProductMedia_1.DeleteProductMedia, args);
61
68
  });
62
69
  }
70
+ updateOption(args) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ return this._runAction(UpdateProductOption_1.UpdateProductOption, args);
73
+ });
74
+ }
63
75
  }
64
76
  exports.AdminProductsAPI = AdminProductsAPI;
@@ -0,0 +1,4 @@
1
+ export interface LinkedMetafieldUpdateInput extends Record<string, any> {
2
+ key: string;
3
+ namespace: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { LinkedMetafieldUpdateInput } from "./LinkedMetafieldUpdateInput";
2
+ export interface OptionUpdateInput extends Record<string, any> {
3
+ id: string;
4
+ linkedMetafield?: LinkedMetafieldUpdateInput;
5
+ name?: string;
6
+ position?: number;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export interface OptionValueUpdateInput extends Record<string, any> {
2
+ id: string;
3
+ linkedMetafieldValue?: string;
4
+ name?: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",