@pintahub/shopify-api 1.4.3 → 1.4.5

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,10 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface GetOrderInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetOrderOutput extends Record<string, any> {
7
+ }
8
+ export declare class GetOrder extends ActionBuilder<AdminApiClient, GetOrderInput, GetOrderOutput> {
9
+ run(args: GetOrderInput): Promise<GetOrderOutput>;
10
+ }
@@ -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.GetOrder = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class GetOrder extends ActionBuilder_1.ActionBuilder {
17
+ run(args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const { id } = args;
20
+ const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Order');
21
+ const query = `
22
+ {
23
+ order(id: "${globalId}") {
24
+ id
25
+ createdAt
26
+ updatedAt
27
+ name
28
+ shippingAddress {
29
+ name
30
+ countryCodeV2
31
+ }
32
+ displayFulfillmentStatus
33
+ displayFinancialStatus
34
+ totalPriceSet {
35
+ shopMoney {
36
+ amount
37
+ currencyCode
38
+ }
39
+ }
40
+ }
41
+ }
42
+ `;
43
+ const { data, errors, extensions } = yield this.client.request(query);
44
+ yield (0, handleErrors_1.handleErrors)(errors);
45
+ const { order } = Object.assign({}, data);
46
+ return Object.assign({}, order);
47
+ });
48
+ }
49
+ }
50
+ exports.GetOrder = GetOrder;
@@ -0,0 +1,10 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface GetProductInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetProductOutput extends Record<string, any> {
7
+ }
8
+ export declare class GetProduct extends ActionBuilder<AdminApiClient, GetProductInput, GetProductOutput> {
9
+ run(args: GetProductInput): Promise<GetProductOutput>;
10
+ }
@@ -0,0 +1,80 @@
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.GetProduct = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class GetProduct extends ActionBuilder_1.ActionBuilder {
17
+ run(args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const { id } = args;
20
+ const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Product');
21
+ const query = `
22
+ {
23
+ product(id: "${globalId}") {
24
+ id
25
+ handle
26
+ publishedAt
27
+ updatedAt
28
+ status
29
+ featuredImage {
30
+ altText
31
+ url(transform: {preferredContentType: PNG, maxWidth: 1200})
32
+ width
33
+ height
34
+ }
35
+ priceRangeV2 {
36
+ maxVariantPrice {
37
+ amount
38
+ currencyCode
39
+ }
40
+ minVariantPrice {
41
+ amount
42
+ currencyCode
43
+ }
44
+ }
45
+ productType
46
+ title
47
+ description
48
+ descriptionHtml
49
+ tags
50
+ productCategory {
51
+ productTaxonomyNode {
52
+ fullName
53
+ name
54
+ }
55
+ }
56
+ collections(first: 100) {
57
+ nodes {
58
+ id
59
+ }
60
+ }
61
+ metafields(first: 100) {
62
+ nodes {
63
+ key
64
+ value
65
+ type
66
+ }
67
+ }
68
+ }
69
+ }
70
+ `;
71
+ const { data, errors, extensions } = yield this.client.request(query);
72
+ yield (0, handleErrors_1.handleErrors)(errors);
73
+ const { product } = Object.assign({}, data);
74
+ return Object.assign({
75
+ status: 'DELETED'
76
+ }, product);
77
+ });
78
+ }
79
+ }
80
+ exports.GetProduct = GetProduct;
@@ -1,11 +1,13 @@
1
1
  import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
2
  import { ActionBuilder } from "../../ActionBuilder";
3
+ import { PageInfo } from "../../../interfaces/PageInfo";
3
4
  export interface SearchOrdersInput extends Record<string, any> {
4
5
  after?: string;
6
+ limit?: number;
5
7
  }
6
8
  export interface SearchOrdersOutput extends Record<string, any> {
7
9
  items: any[];
8
- pageInfo: any;
10
+ pageInfo: PageInfo;
9
11
  }
10
12
  export declare class SearchOrders extends ActionBuilder<AdminApiClient, SearchOrdersInput, SearchOrdersOutput> {
11
13
  run(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
@@ -15,18 +15,17 @@ const handleErrors_1 = require("../../../utils/handleErrors");
15
15
  class SearchOrders extends ActionBuilder_1.ActionBuilder {
16
16
  run(args) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- const { after } = Object.assign({}, args);
18
+ const { after, limit } = Object.assign({}, args);
19
+ const vLimit = !!limit ? parseInt(limit + '', 10) : 10;
19
20
  const query = `
20
21
  {
21
- orders(first: 100, reverse: true) {
22
+ orders(
23
+ first: ${vLimit},
24
+ reverse: true,
25
+ ${after ? `after: "${after}"` : ''}
26
+ ) {
22
27
  nodes {
23
28
  id
24
- createdAt
25
- updatedAt
26
- name
27
- shippingAddress {
28
- countryCodeV2
29
- }
30
29
  }
31
30
  pageInfo {
32
31
  hasNextPage
@@ -35,7 +34,7 @@ class SearchOrders extends ActionBuilder_1.ActionBuilder {
35
34
  }
36
35
  }
37
36
  `;
38
- const { data, errors } = yield this.client.request(query);
37
+ const { data, errors, extensions } = yield this.client.request(query);
39
38
  yield (0, handleErrors_1.handleErrors)(errors);
40
39
  const { orders } = Object.assign({}, data);
41
40
  const { nodes, pageInfo } = Object.assign({}, orders);
@@ -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 { SearchOrdersInput, SearchOrdersOutput } from "./SearchOrders";
4
+ import { GetOrderInput, GetOrderOutput } from "./GetOrder";
4
5
  export interface AdminOrderAPIInterface {
5
6
  search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
7
+ get(args: GetOrderInput): Promise<GetOrderOutput>;
6
8
  }
7
9
  export declare class AdminOrderAPI extends APIBase<AdminApiClient> implements AdminOrderAPIInterface {
8
10
  private _runAction;
9
11
  search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
12
+ get(args?: GetOrderInput): Promise<GetOrderOutput>;
10
13
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AdminOrderAPI = void 0;
13
13
  const APIBase_1 = require("../../APIBase");
14
14
  const SearchOrders_1 = require("./SearchOrders");
15
+ const GetOrder_1 = require("./GetOrder");
15
16
  class AdminOrderAPI extends APIBase_1.APIBase {
16
17
  _runAction(Action, args) {
17
18
  return __awaiter(this, void 0, void 0, function* () {
@@ -24,5 +25,10 @@ class AdminOrderAPI extends APIBase_1.APIBase {
24
25
  return this._runAction(SearchOrders_1.SearchOrders, args);
25
26
  });
26
27
  }
28
+ get(args) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this._runAction(GetOrder_1.GetOrder, args);
31
+ });
32
+ }
27
33
  }
28
34
  exports.AdminOrderAPI = AdminOrderAPI;
@@ -0,0 +1,4 @@
1
+ export interface PageInfo extends Record<string, any> {
2
+ hasNextPage?: boolean;
3
+ endCursor?: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -14,11 +14,11 @@ const handleErrors = (errors) => __awaiter(void 0, void 0, void 0, function* ()
14
14
  if (!errors)
15
15
  return;
16
16
  const { message, graphQLErrors } = Object.assign({}, errors);
17
- if (message) {
18
- throw new Error(message);
19
- }
20
17
  if (graphQLErrors) {
21
18
  console.error('GraphQL Errors:', graphQLErrors);
22
19
  }
20
+ if (message) {
21
+ throw new Error(message);
22
+ }
23
23
  });
24
24
  exports.handleErrors = handleErrors;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",