@pintahub/shopify-api 1.5.5 → 1.5.6

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.
@@ -24,19 +24,18 @@ class GetImage extends ActionBuilder_1.ActionBuilder {
24
24
  id
25
25
  ... on MediaImage {
26
26
  id
27
- alt
28
- fileStatus
27
+ mimeType
28
+ createdAt
29
+ updatedAt
29
30
  image {
30
31
  altText
31
32
  height
32
33
  url
33
34
  width
34
35
  }
35
- mediaContentType
36
- mimeType
37
- status
38
- createdAt
39
- updatedAt
36
+ originalSource {
37
+ fileSize
38
+ }
40
39
  }
41
40
  }
42
41
  }
@@ -0,0 +1,12 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface SearchImagesInput extends Record<string, any> {
4
+ after?: string;
5
+ }
6
+ export interface SearchImagesOutput extends Record<string, any> {
7
+ items: any[];
8
+ pageInfo: any;
9
+ }
10
+ export declare class SearchImages extends ActionBuilder<AdminApiClient, SearchImagesInput, SearchImagesOutput> {
11
+ run(args?: SearchImagesInput): Promise<SearchImagesOutput>;
12
+ }
@@ -0,0 +1,50 @@
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.SearchImages = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const handleErrors_1 = require("../../../utils/handleErrors");
15
+ class SearchImages extends ActionBuilder_1.ActionBuilder {
16
+ run(args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const { after } = Object.assign({}, args);
19
+ const query = `
20
+ {
21
+ files(
22
+ query: "media_type:IMAGE"
23
+ first: 10
24
+ sortKey: UPDATED_AT
25
+ reverse: true
26
+ ${after ? `after: "${after}"` : ''}
27
+ ) {
28
+ nodes {
29
+ id
30
+ }
31
+ pageInfo {
32
+ hasNextPage
33
+ endCursor
34
+ }
35
+ }
36
+ }
37
+ `;
38
+ const { data, errors } = yield this.client.request(query);
39
+ yield (0, handleErrors_1.handleErrors)(errors);
40
+ const { files } = Object.assign({}, data);
41
+ const { nodes, pageInfo } = Object.assign({}, files);
42
+ const items = Array.isArray(nodes) ? nodes : [];
43
+ return {
44
+ items,
45
+ pageInfo
46
+ };
47
+ });
48
+ }
49
+ }
50
+ exports.SearchImages = SearchImages;
@@ -1,10 +1,13 @@
1
1
  import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
2
  import { APIBase } from "../../APIBase";
3
3
  import { GetImageInput, GetImageOutput } from "./GetImage";
4
+ import { SearchImagesInput, SearchImagesOutput } from "./SearchImages";
4
5
  export interface AdminFileAPIInterface {
6
+ searchImages(args: SearchImagesInput): Promise<SearchImagesOutput>;
5
7
  getImage(args: GetImageInput): Promise<GetImageOutput>;
6
8
  }
7
9
  export declare class AdminFileAPI extends APIBase<AdminApiClient> implements AdminFileAPIInterface {
8
10
  private _runAction;
11
+ searchImages(args?: SearchImagesInput): Promise<SearchImagesOutput>;
9
12
  getImage(args?: GetImageInput): Promise<GetImageOutput>;
10
13
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AdminFileAPI = void 0;
13
13
  const APIBase_1 = require("../../APIBase");
14
14
  const GetImage_1 = require("./GetImage");
15
+ const SearchImages_1 = require("./SearchImages");
15
16
  class AdminFileAPI extends APIBase_1.APIBase {
16
17
  _runAction(Action, args) {
17
18
  return __awaiter(this, void 0, void 0, function* () {
@@ -19,6 +20,11 @@ class AdminFileAPI extends APIBase_1.APIBase {
19
20
  return action.run(args);
20
21
  });
21
22
  }
23
+ searchImages(args) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return this._runAction(SearchImages_1.SearchImages, args);
26
+ });
27
+ }
22
28
  getImage(args) {
23
29
  return __awaiter(this, void 0, void 0, function* () {
24
30
  return this._runAction(GetImage_1.GetImage, args);
@@ -0,0 +1,12 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface CreateVariantInput extends Record<string, any> {
4
+ productId: string;
5
+ price?: string;
6
+ options?: string[] | string;
7
+ }
8
+ export interface CreateVariantOutput extends Record<string, any> {
9
+ }
10
+ export declare class CreateVariant extends ActionBuilder<AdminApiClient, CreateVariantInput, CreateVariantOutput> {
11
+ run(args: CreateVariantInput): Promise<CreateVariantOutput>;
12
+ }
@@ -0,0 +1,56 @@
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.CreateVariant = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class CreateVariant extends ActionBuilder_1.ActionBuilder {
17
+ run(args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const { productId } = args;
20
+ const globalId = (0, getGlobalID_1.getGlobalID)(productId, 'Product');
21
+ const input = Object.assign(Object.assign({}, args), { productId: globalId });
22
+ const query = `
23
+ mutation productVariantCreate($input: ProductVariantInput!) {
24
+ productVariantCreate(input: $input) {
25
+ product {
26
+ id
27
+ title
28
+ }
29
+ productVariant {
30
+ id
31
+ createdAt
32
+ displayName
33
+ price
34
+ title
35
+ }
36
+ userErrors {
37
+ field
38
+ message
39
+ }
40
+ }
41
+ }
42
+ `;
43
+ const { data, errors } = yield this.client.request(query, {
44
+ variables: {
45
+ input
46
+ }
47
+ });
48
+ console.log('data', JSON.stringify(data, null, 2));
49
+ yield (0, handleErrors_1.handleErrors)(errors);
50
+ const { productVariantCreate } = Object.assign({}, data);
51
+ const { productVariant } = Object.assign({}, productVariantCreate);
52
+ return Object.assign({}, productVariant);
53
+ });
54
+ }
55
+ }
56
+ exports.CreateVariant = CreateVariant;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",