@pintahub/shopify-api 2.0.8 → 2.0.9

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 DeleteFileInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface DeleteFileOutput extends Record<string, any> {
7
+ ids: string[];
8
+ }
9
+ export declare class DeleteFile extends ActionBuilder<AdminApiClient, DeleteFileInput, DeleteFileOutput> {
10
+ run(args: DeleteFileInput): Promise<DeleteFileOutput>;
11
+ }
@@ -0,0 +1,46 @@
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.DeleteFile = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const handleErrors_1 = require("../../../utils/handleErrors");
15
+ class DeleteFile extends ActionBuilder_1.ActionBuilder {
16
+ run(args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const { id } = args;
19
+ const query = `
20
+ mutation fileDelete($input: [ID!]!) {
21
+ fileDelete(fileIds: $input) {
22
+ deletedFileIds
23
+ userErrors {
24
+ code
25
+ field
26
+ message
27
+ }
28
+ }
29
+ }
30
+ `;
31
+ const { data, errors } = yield this.client.request(query, {
32
+ variables: {
33
+ input: [id]
34
+ }
35
+ });
36
+ yield (0, handleErrors_1.handleErrors)(errors);
37
+ const { fileDelete } = Object.assign({}, data);
38
+ const { deletedFileIds } = Object.assign({}, fileDelete);
39
+ const ids = Array.isArray(deletedFileIds) ? deletedFileIds : [];
40
+ return {
41
+ ids
42
+ };
43
+ });
44
+ }
45
+ }
46
+ exports.DeleteFile = DeleteFile;
@@ -2,12 +2,15 @@ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types"
2
2
  import { APIBase } from "../../APIBase";
3
3
  import { GetImageInput, GetImageOutput } from "./GetImage";
4
4
  import { SearchImagesInput, SearchImagesOutput } from "./SearchImages";
5
+ import { DeleteFileInput, DeleteFileOutput } from "./DeleteFile";
5
6
  export interface AdminFileAPIInterface {
6
7
  searchImages(args: SearchImagesInput): Promise<SearchImagesOutput>;
7
8
  getImage(args: GetImageInput): Promise<GetImageOutput>;
9
+ delete(args: DeleteFileInput): Promise<DeleteFileOutput>;
8
10
  }
9
11
  export declare class AdminFileAPI extends APIBase<AdminApiClient> implements AdminFileAPIInterface {
10
12
  private _runAction;
11
13
  searchImages(args?: SearchImagesInput): Promise<SearchImagesOutput>;
12
14
  getImage(args?: GetImageInput): Promise<GetImageOutput>;
15
+ delete(args?: DeleteFileInput): Promise<DeleteFileOutput>;
13
16
  }
@@ -13,6 +13,7 @@ exports.AdminFileAPI = void 0;
13
13
  const APIBase_1 = require("../../APIBase");
14
14
  const GetImage_1 = require("./GetImage");
15
15
  const SearchImages_1 = require("./SearchImages");
16
+ const DeleteFile_1 = require("./DeleteFile");
16
17
  class AdminFileAPI extends APIBase_1.APIBase {
17
18
  _runAction(Action, args) {
18
19
  return __awaiter(this, void 0, void 0, function* () {
@@ -30,5 +31,10 @@ class AdminFileAPI extends APIBase_1.APIBase {
30
31
  return this._runAction(GetImage_1.GetImage, args);
31
32
  });
32
33
  }
34
+ delete(args) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return this._runAction(DeleteFile_1.DeleteFile, args);
37
+ });
38
+ }
33
39
  }
34
40
  exports.AdminFileAPI = AdminFileAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",