@pintahub/shopify-api 2.2.0 → 2.2.2

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,13 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface UpdateFileInput extends Record<string, any> {
4
+ id: string;
5
+ referencesToAdd?: string[];
6
+ referencesToRemove?: string[];
7
+ }
8
+ export interface UpdateFileOutput extends Record<string, any> {
9
+ id: string;
10
+ }
11
+ export declare class UpdateFile extends ActionBuilder<AdminApiClient, UpdateFileInput, UpdateFileOutput> {
12
+ run(args: UpdateFileInput): Promise<UpdateFileOutput>;
13
+ }
@@ -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.UpdateFile = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const handleErrors_1 = require("../../../utils/handleErrors");
15
+ class UpdateFile extends ActionBuilder_1.ActionBuilder {
16
+ run(args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const query = `
19
+ mutation FileUpdate($input: [FileUpdateInput!]!) {
20
+ fileUpdate(files: $input) {
21
+ userErrors {
22
+ code
23
+ field
24
+ message
25
+ }
26
+ files {
27
+ id
28
+ alt
29
+ createdAt
30
+ }
31
+ }
32
+ }
33
+ `;
34
+ const { data, errors } = yield this.client.request(query, {
35
+ variables: {
36
+ input: args
37
+ }
38
+ });
39
+ yield (0, handleErrors_1.handleErrors)(errors);
40
+ const { fileUpdate } = Object.assign({}, data);
41
+ const { files } = Object.assign({}, fileUpdate);
42
+ const arr = Array.isArray(files) ? files : [];
43
+ const [file] = arr;
44
+ return Object.assign({}, file);
45
+ });
46
+ }
47
+ }
48
+ exports.UpdateFile = UpdateFile;
@@ -4,10 +4,12 @@ import { GetImageInput, GetImageOutput } from "./GetImage";
4
4
  import { SearchImagesInput, SearchImagesOutput } from "./SearchImages";
5
5
  import { DeleteFileInput, DeleteFileOutput } from "./DeleteFile";
6
6
  import { GetVideoInput, GetVideoOutput } from "./GetVideo";
7
+ import { UpdateFileInput, UpdateFileOutput } from "./UpdateFile";
7
8
  export interface AdminFileAPIInterface {
8
9
  searchImages(args: SearchImagesInput): Promise<SearchImagesOutput>;
9
10
  getImage(args: GetImageInput): Promise<GetImageOutput>;
10
11
  getVideo(args: GetVideoInput): Promise<GetVideoOutput>;
12
+ update(args: UpdateFileInput): Promise<UpdateFileOutput>;
11
13
  delete(args: DeleteFileInput): Promise<DeleteFileOutput>;
12
14
  }
13
15
  export declare class AdminFileAPI extends APIBase<AdminApiClient> implements AdminFileAPIInterface {
@@ -15,5 +17,6 @@ export declare class AdminFileAPI extends APIBase<AdminApiClient> implements Adm
15
17
  searchImages(args?: SearchImagesInput): Promise<SearchImagesOutput>;
16
18
  getImage(args?: GetImageInput): Promise<GetImageOutput>;
17
19
  getVideo(args?: GetVideoInput): Promise<GetVideoOutput>;
20
+ update(args?: UpdateFileInput): Promise<UpdateFileOutput>;
18
21
  delete(args?: DeleteFileInput): Promise<DeleteFileOutput>;
19
22
  }
@@ -15,6 +15,7 @@ const GetImage_1 = require("./GetImage");
15
15
  const SearchImages_1 = require("./SearchImages");
16
16
  const DeleteFile_1 = require("./DeleteFile");
17
17
  const GetVideo_1 = require("./GetVideo");
18
+ const UpdateFile_1 = require("./UpdateFile");
18
19
  class AdminFileAPI extends APIBase_1.APIBase {
19
20
  _runAction(Action, args) {
20
21
  return __awaiter(this, void 0, void 0, function* () {
@@ -37,6 +38,11 @@ class AdminFileAPI extends APIBase_1.APIBase {
37
38
  return this._runAction(GetVideo_1.GetVideo, args);
38
39
  });
39
40
  }
41
+ update(args) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ return this._runAction(UpdateFile_1.UpdateFile, args);
44
+ });
45
+ }
40
46
  delete(args) {
41
47
  return __awaiter(this, void 0, void 0, function* () {
42
48
  return this._runAction(DeleteFile_1.DeleteFile, args);
@@ -28,8 +28,8 @@ class UpdateProduct extends ActionBuilder_1.ActionBuilder {
28
28
  run(args) {
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
30
  const query = `
31
- mutation productUpdate($product: ProductUpdateInput!) {
32
- productUpdate(product: $product) {
31
+ mutation productUpdate($product: ProductUpdateInput!, $media: [CreateMediaInput!]) {
32
+ productUpdate(product: $product, media: $media) {
33
33
  product {
34
34
  id
35
35
  status
@@ -38,6 +38,15 @@ class UpdateProduct extends ActionBuilder_1.ActionBuilder {
38
38
  vendor
39
39
  productType
40
40
  tags
41
+ media(first: 100) {
42
+ nodes {
43
+ alt
44
+ mediaContentType
45
+ preview {
46
+ status
47
+ }
48
+ }
49
+ }
41
50
  }
42
51
  userErrors {
43
52
  field
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",