@pintahub/shopify-api 1.3.1 → 1.3.3

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,16 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface MediaObject extends Record<string, any> {
4
+ alt?: string;
5
+ mediaContentType: string;
6
+ originalSource: string;
7
+ }
8
+ export interface CreateProductMediaInput extends Record<string, any> {
9
+ productId: string;
10
+ media: Array<MediaObject>;
11
+ }
12
+ export interface CreateProductMediaOutput extends Record<string, any> {
13
+ }
14
+ export declare class CreateProductMedia extends ActionBuilder<AdminApiClient, CreateProductMediaInput, CreateProductMediaOutput> {
15
+ run(args: CreateProductMediaInput): Promise<CreateProductMediaOutput>;
16
+ }
@@ -0,0 +1,48 @@
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.CreateProductMedia = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ class CreateProductMedia extends ActionBuilder_1.ActionBuilder {
16
+ run(args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const { productId, media } = args;
19
+ const gId = (0, getGlobalID_1.getGlobalID)(productId);
20
+ const query = `
21
+ mutation productCreateMedia($media: [CreateMediaInput!]!, $productId: ID!) {
22
+ productCreateMedia(media: $media, productId: $productId) {
23
+ media {
24
+ id
25
+ status
26
+ }
27
+ mediaUserErrors {
28
+ code
29
+ message
30
+ }
31
+ product {
32
+ id
33
+ }
34
+ }
35
+ }
36
+ `;
37
+ const result = yield this.client.request(query, {
38
+ variables: {
39
+ productId: gId,
40
+ media,
41
+ }
42
+ });
43
+ console.log('result', JSON.stringify(result, null, 2));
44
+ return {};
45
+ });
46
+ }
47
+ }
48
+ exports.CreateProductMedia = CreateProductMedia;
@@ -0,0 +1,11 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface UpdateProductInput extends Record<string, any> {
4
+ id: string;
5
+ status?: string;
6
+ }
7
+ export interface UpdateProductOutput extends Record<string, any> {
8
+ }
9
+ export declare class UpdateProduct extends ActionBuilder<AdminApiClient, UpdateProductInput, UpdateProductOutput> {
10
+ run(args: UpdateProductInput): Promise<UpdateProductOutput>;
11
+ }
@@ -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.UpdateProduct = void 0;
24
+ const ActionBuilder_1 = require("../../ActionBuilder");
25
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
26
+ class UpdateProduct extends ActionBuilder_1.ActionBuilder {
27
+ run(args) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const query = `
30
+ mutation productUpdate($input: ProductInput!) {
31
+ productUpdate(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 { productUpdate } = Object.assign({}, data);
55
+ const { product } = Object.assign({}, productUpdate);
56
+ return Object.assign({}, product);
57
+ });
58
+ }
59
+ }
60
+ exports.UpdateProduct = UpdateProduct;
@@ -5,18 +5,24 @@ import { SearchProductsInput, SearchProductsOutput } from "./SearchProducts";
5
5
  import { GetPublicationsInput, GetPublicationsOutput } from "./GetPublications";
6
6
  import { UpdateVariantInput, UpdateVariantOutput } from "./UpdateVariant";
7
7
  import { CreateProductInput, CreateProductOutput } from "./CreateProduct";
8
+ import { CreateProductMediaInput, CreateProductMediaOutput } from "./CreateProductMedia";
9
+ import { UpdateProductInput, UpdateProductOutput } from "./UpdateProduct";
8
10
  export interface AdminProductAPIInterface {
9
11
  get(args: GetProductInput): Promise<GetProductOutput>;
10
12
  create(args: CreateProductInput): Promise<CreateProductOutput>;
13
+ update(args: UpdateProductInput): Promise<UpdateProductOutput>;
11
14
  getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
12
15
  search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
13
16
  updateVariant(args: UpdateVariantInput): Promise<UpdateVariantOutput>;
17
+ createMedia(args: CreateProductMediaInput): Promise<CreateProductMediaOutput>;
14
18
  }
15
19
  export declare class AdminProductAPI extends APIBase<AdminApiClient> implements AdminProductAPIInterface {
16
20
  private _runAction;
17
21
  get(args: GetProductInput): Promise<GetProductOutput>;
18
22
  create(args: CreateProductInput): Promise<CreateProductOutput>;
23
+ update(args: UpdateProductInput): Promise<UpdateProductOutput>;
19
24
  getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
20
25
  search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
21
26
  updateVariant(args: UpdateVariantInput): Promise<UpdateVariantOutput>;
27
+ createMedia(args: CreateProductMediaInput): Promise<CreateProductMediaOutput>;
22
28
  }
@@ -16,6 +16,8 @@ const SearchProducts_1 = require("./SearchProducts");
16
16
  const GetPublications_1 = require("./GetPublications");
17
17
  const UpdateVariant_1 = require("./UpdateVariant");
18
18
  const CreateProduct_1 = require("./CreateProduct");
19
+ const CreateProductMedia_1 = require("./CreateProductMedia");
20
+ const UpdateProduct_1 = require("./UpdateProduct");
19
21
  class AdminProductAPI extends APIBase_1.APIBase {
20
22
  _runAction(Action, args) {
21
23
  return __awaiter(this, void 0, void 0, function* () {
@@ -33,6 +35,11 @@ class AdminProductAPI extends APIBase_1.APIBase {
33
35
  return this._runAction(CreateProduct_1.CreateProduct, args);
34
36
  });
35
37
  }
38
+ update(args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ return this._runAction(UpdateProduct_1.UpdateProduct, args);
41
+ });
42
+ }
36
43
  getPublications(args) {
37
44
  return __awaiter(this, void 0, void 0, function* () {
38
45
  return this._runAction(GetPublications_1.GetPublications, args);
@@ -48,5 +55,10 @@ class AdminProductAPI extends APIBase_1.APIBase {
48
55
  return this._runAction(UpdateVariant_1.UpdateVariant, args);
49
56
  });
50
57
  }
58
+ createMedia(args) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ return this._runAction(CreateProductMedia_1.CreateProductMedia, args);
61
+ });
62
+ }
51
63
  }
52
64
  exports.AdminProductAPI = AdminProductAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",