@pintahub/shopify-api 1.9.8 → 1.9.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,18 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface SearchProductsInput extends Record<string, any> {
4
+ first?: number;
5
+ last?: number;
6
+ sortKey?: string;
7
+ before?: string;
8
+ after?: string;
9
+ query?: string;
10
+ reverse?: boolean;
11
+ }
12
+ export interface SearchProductsOutput extends Record<string, any> {
13
+ items: any[];
14
+ pageInfo: any;
15
+ }
16
+ export declare class SearchProducts extends ActionBuilder<AdminApiClient, SearchProductsInput, SearchProductsOutput> {
17
+ run(args?: SearchProductsInput): Promise<SearchProductsOutput>;
18
+ }
@@ -0,0 +1,66 @@
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.SearchProducts = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const handleErrors_1 = require("../../../utils/handleErrors");
15
+ class SearchProducts extends ActionBuilder_1.ActionBuilder {
16
+ run(args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const vArgs = Object.assign({
19
+ first: 10,
20
+ sortKey: 'UPDATED_AT',
21
+ reverse: true
22
+ }, args);
23
+ const query = `
24
+ query searchProducts($first: Int, $last: Int, $query: String,
25
+ $before: String, $after: String,
26
+ $reverse: Boolean, $sortKey: ProductSortKeys,
27
+ ) {
28
+ products(
29
+ first: $first
30
+ sortKey: $sortKey
31
+ reverse: $reverse
32
+ query: $query
33
+ before: $before
34
+ after: $after
35
+ last: $last
36
+ ) {
37
+ nodes {
38
+ id
39
+ handle
40
+ title
41
+ status
42
+ productType
43
+ vendor
44
+ }
45
+ pageInfo {
46
+ hasNextPage
47
+ endCursor
48
+ }
49
+ }
50
+ }
51
+ `;
52
+ const { data, errors } = yield this.client.request(query, {
53
+ variables: vArgs
54
+ });
55
+ yield (0, handleErrors_1.handleErrors)(errors);
56
+ const { products } = Object.assign({}, data);
57
+ const { nodes, pageInfo } = Object.assign({}, products);
58
+ const items = Array.isArray(nodes) ? nodes : [];
59
+ return {
60
+ items,
61
+ pageInfo
62
+ };
63
+ });
64
+ }
65
+ }
66
+ exports.SearchProducts = SearchProducts;
@@ -3,13 +3,16 @@ import { APIBase } from "../../APIBase";
3
3
  import { UpdateVariantsInput, UpdateVariantsOutput } from "./UpdateVariants";
4
4
  import { UpdateProductInput, UpdateProductOutput } from "./UpdateProduct";
5
5
  import { GetProductInput, GetProductOutput } from "./GetProduct";
6
+ import { SearchProductsInput, SearchProductsOutput } from "./SearchProducts";
6
7
  export interface AdminProductsAPIInterface {
8
+ search(args: SearchProductsInput): Promise<SearchProductsOutput>;
7
9
  get(args: GetProductInput): Promise<GetProductOutput>;
8
10
  update(args: UpdateProductInput): Promise<UpdateProductOutput>;
9
11
  updateVariants(args: UpdateVariantsInput): Promise<UpdateVariantsOutput>;
10
12
  }
11
13
  export declare class AdminProductsAPI extends APIBase<AdminApiClient> implements AdminProductsAPIInterface {
12
14
  private _runAction;
15
+ search(args: SearchProductsInput): Promise<SearchProductsOutput>;
13
16
  get(args: GetProductInput): Promise<GetProductOutput>;
14
17
  update(args: UpdateProductInput): Promise<UpdateProductOutput>;
15
18
  updateVariants(args: UpdateVariantsInput): Promise<UpdateVariantsOutput>;
@@ -14,6 +14,7 @@ const APIBase_1 = require("../../APIBase");
14
14
  const UpdateVariants_1 = require("./UpdateVariants");
15
15
  const UpdateProduct_1 = require("./UpdateProduct");
16
16
  const GetProduct_1 = require("./GetProduct");
17
+ const SearchProducts_1 = require("./SearchProducts");
17
18
  class AdminProductsAPI extends APIBase_1.APIBase {
18
19
  _runAction(Action, args) {
19
20
  return __awaiter(this, void 0, void 0, function* () {
@@ -21,6 +22,11 @@ class AdminProductsAPI extends APIBase_1.APIBase {
21
22
  return action.run(args);
22
23
  });
23
24
  }
25
+ search(args) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return this._runAction(SearchProducts_1.SearchProducts, args);
28
+ });
29
+ }
24
30
  get(args) {
25
31
  return __awaiter(this, void 0, void 0, function* () {
26
32
  return this._runAction(GetProduct_1.GetProduct, args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.9.8",
3
+ "version": "1.9.9",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",