@pintahub/shopify-api 2.0.7 → 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;
@@ -0,0 +1,11 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface DeleteProductMediaInput extends Record<string, any> {
4
+ productId: string;
5
+ mediaIds: Array<string>;
6
+ }
7
+ export interface DeleteProductMediaOutput extends Record<string, any> {
8
+ }
9
+ export declare class DeleteProductMedia extends ActionBuilder<AdminApiClient, DeleteProductMediaInput, DeleteProductMediaOutput> {
10
+ run(args: DeleteProductMediaInput): Promise<DeleteProductMediaOutput>;
11
+ }
@@ -0,0 +1,57 @@
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.DeleteProductMedia = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class DeleteProductMedia extends ActionBuilder_1.ActionBuilder {
17
+ run(args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const query = `
20
+ mutation productDeleteMedia($mediaIds: [ID!]!, $productId: ID!) {
21
+ productDeleteMedia(mediaIds: $mediaIds, productId: $productId) {
22
+ deletedMediaIds
23
+ deletedProductImageIds
24
+ mediaUserErrors {
25
+ field
26
+ message
27
+ }
28
+ product {
29
+ id
30
+ title
31
+ media(first: 5) {
32
+ nodes {
33
+ alt
34
+ mediaContentType
35
+ status
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ `;
42
+ const { productId, mediaIds } = args;
43
+ const { data, errors } = yield this.client.request(query, {
44
+ variables: {
45
+ productId: (0, getGlobalID_1.getGlobalID)(productId, 'Product'),
46
+ mediaIds: mediaIds.map(id => {
47
+ return (0, getGlobalID_1.getGlobalID)(id, 'MediaImage');
48
+ })
49
+ }
50
+ });
51
+ yield (0, handleErrors_1.handleErrors)(errors);
52
+ const { productDeleteMedia } = Object.assign({}, data);
53
+ return Object.assign({}, productDeleteMedia);
54
+ });
55
+ }
56
+ }
57
+ exports.DeleteProductMedia = DeleteProductMedia;
@@ -5,12 +5,14 @@ import { UpdateProductInput, UpdateProductOutput } from "./UpdateProduct";
5
5
  import { GetProductInput, GetProductOutput } from "./GetProduct";
6
6
  import { SearchProductsInput, SearchProductsOutput } from "./SearchProducts";
7
7
  import { GetProductMediaInput, GetProductMediaOutput } from "./GetProductMedia";
8
+ import { DeleteProductMediaInput, DeleteProductMediaOutput } from "./DeleteProductMedia";
8
9
  export interface AdminProductsAPIInterface {
9
10
  search(args: SearchProductsInput): Promise<SearchProductsOutput>;
10
11
  get(args: GetProductInput): Promise<GetProductOutput>;
11
12
  update(args: UpdateProductInput): Promise<UpdateProductOutput>;
12
13
  updateVariants(args: UpdateVariantsInput): Promise<UpdateVariantsOutput>;
13
14
  getMedia(args: GetProductMediaInput): Promise<GetProductMediaOutput>;
15
+ deleteMedia(args: DeleteProductMediaInput): Promise<DeleteProductMediaOutput>;
14
16
  }
15
17
  export declare class AdminProductsAPI extends APIBase<AdminApiClient> implements AdminProductsAPIInterface {
16
18
  private _runAction;
@@ -19,4 +21,5 @@ export declare class AdminProductsAPI extends APIBase<AdminApiClient> implements
19
21
  update(args: UpdateProductInput): Promise<UpdateProductOutput>;
20
22
  updateVariants(args: UpdateVariantsInput): Promise<UpdateVariantsOutput>;
21
23
  getMedia(args: GetProductMediaInput): Promise<GetProductMediaOutput>;
24
+ deleteMedia(args: DeleteProductMediaInput): Promise<DeleteProductMediaOutput>;
22
25
  }
@@ -16,6 +16,7 @@ const UpdateProduct_1 = require("./UpdateProduct");
16
16
  const GetProduct_1 = require("./GetProduct");
17
17
  const SearchProducts_1 = require("./SearchProducts");
18
18
  const GetProductMedia_1 = require("./GetProductMedia");
19
+ const DeleteProductMedia_1 = require("./DeleteProductMedia");
19
20
  class AdminProductsAPI extends APIBase_1.APIBase {
20
21
  _runAction(Action, args) {
21
22
  return __awaiter(this, void 0, void 0, function* () {
@@ -48,5 +49,10 @@ class AdminProductsAPI extends APIBase_1.APIBase {
48
49
  return this._runAction(GetProductMedia_1.GetProductMedia, args);
49
50
  });
50
51
  }
52
+ deleteMedia(args) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ return this._runAction(DeleteProductMedia_1.DeleteProductMedia, args);
55
+ });
56
+ }
51
57
  }
52
58
  exports.AdminProductsAPI = AdminProductsAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",