@pintahub/shopify-api 2.3.1 → 2.3.3

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.
@@ -7,6 +7,7 @@ import { AdminMenuAPIInterface } from "./admin/menus";
7
7
  import { AdminProductsAPIInterface } from "./admin/products-v2";
8
8
  import { AdminCustomersAPIInterface } from "./admin/customers";
9
9
  import { AdminCollectionAPIInterface } from "./admin/collections-v2";
10
+ import { AdminPaymentsAPIInterface } from "./admin/payments";
10
11
  export declare class AdminAPI {
11
12
  private readonly options;
12
13
  private readonly client?;
@@ -19,6 +20,7 @@ export declare class AdminAPI {
19
20
  readonly collections: AdminCollectionAPIInterface;
20
21
  readonly metaobject: AdminMetaObjectAPIInterface;
21
22
  readonly orders: AdminOrderAPIInterface;
23
+ readonly payments: AdminPaymentsAPIInterface;
22
24
  constructor(options: APIOptions);
23
25
  private _createClient;
24
26
  }
@@ -10,6 +10,7 @@ const menus_1 = require("./admin/menus");
10
10
  const products_v2_1 = require("./admin/products-v2");
11
11
  const customers_1 = require("./admin/customers");
12
12
  const collections_v2_1 = require("./admin/collections-v2");
13
+ const payments_1 = require("./admin/payments");
13
14
  class AdminAPI {
14
15
  constructor(options) {
15
16
  const defaultOptions = {
@@ -22,13 +23,14 @@ class AdminAPI {
22
23
  this.product = new products_1.AdminProductAPI(this.client);
23
24
  this.order = new orders_1.AdminOrderAPI(this.client);
24
25
  }
25
- this.menus = new menus_1.AdminMenuAPI(this._createClient('2024-10'));
26
- this.products = new products_v2_1.AdminProductsAPI(this._createClient('2024-10'));
27
- this.customers = new customers_1.AdminCustomersAPI(this._createClient('2024-10'));
28
- this.collections = new collections_v2_1.AdminCollectionAPI(this._createClient('2024-10'));
29
- this.files = new files_1.AdminFileAPI(this._createClient('2024-10'));
30
- this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this._createClient('2024-10'));
31
- this.orders = new orders_1.AdminOrderAPI(this._createClient('2024-10'));
26
+ this.menus = new menus_1.AdminMenuAPI(this._createClient('2025-01'));
27
+ this.products = new products_v2_1.AdminProductsAPI(this._createClient('2025-01'));
28
+ this.customers = new customers_1.AdminCustomersAPI(this._createClient('2025-01'));
29
+ this.collections = new collections_v2_1.AdminCollectionAPI(this._createClient('2025-01'));
30
+ this.files = new files_1.AdminFileAPI(this._createClient('2025-01'));
31
+ this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this._createClient('2025-01'));
32
+ this.orders = new orders_1.AdminOrderAPI(this._createClient('2025-01'));
33
+ this.payments = new payments_1.AdminPaymentsAPI(this._createClient('2025-07'));
32
34
  }
33
35
  _createClient(apiVersion = '2023-10') {
34
36
  const { shop, accessToken } = this.options;
@@ -0,0 +1,11 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface GetOrderEventsInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetOrderEventsOutput extends Record<string, any> {
7
+ items: any[];
8
+ }
9
+ export declare class GetOrderEvents extends ActionBuilder<AdminApiClient, GetOrderEventsInput, GetOrderEventsOutput> {
10
+ run(args: GetOrderEventsInput): Promise<GetOrderEventsOutput>;
11
+ }
@@ -0,0 +1,51 @@
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.GetOrderEvents = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class GetOrderEvents 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
+ events(first: 10, sortKey: CREATED_AT, reverse: false) {
26
+ nodes {
27
+ id
28
+ message
29
+ ... on BasicEvent {
30
+ action
31
+ arguments
32
+ subjectType
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+ `;
39
+ const { data, errors } = yield this.client.request(query);
40
+ yield (0, handleErrors_1.handleErrors)(errors);
41
+ const { order } = Object.assign({}, data);
42
+ const { events } = Object.assign({}, order);
43
+ const { nodes } = Object.assign({}, events);
44
+ const arr = Array.isArray(nodes) ? nodes : [];
45
+ return {
46
+ items: arr
47
+ };
48
+ });
49
+ }
50
+ }
51
+ exports.GetOrderEvents = GetOrderEvents;
@@ -2,12 +2,15 @@ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types"
2
2
  import { APIBase } from "../../APIBase";
3
3
  import { SearchOrdersInput, SearchOrdersOutput } from "./SearchOrders";
4
4
  import { GetOrderInput, GetOrderOutput } from "./GetOrder";
5
+ import { GetOrderEventsInput, GetOrderEventsOutput } from "./GetOrderEvents";
5
6
  export interface AdminOrderAPIInterface {
6
7
  search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
7
8
  get(args: GetOrderInput): Promise<GetOrderOutput>;
9
+ getEvents(args: GetOrderEventsInput): Promise<GetOrderEventsOutput>;
8
10
  }
9
11
  export declare class AdminOrderAPI extends APIBase<AdminApiClient> implements AdminOrderAPIInterface {
10
12
  private _runAction;
11
13
  search(args?: SearchOrdersInput): Promise<SearchOrdersOutput>;
12
14
  get(args?: GetOrderInput): Promise<GetOrderOutput>;
15
+ getEvents(args?: GetOrderEventsInput): Promise<GetOrderEventsOutput>;
13
16
  }
@@ -13,6 +13,7 @@ exports.AdminOrderAPI = void 0;
13
13
  const APIBase_1 = require("../../APIBase");
14
14
  const SearchOrders_1 = require("./SearchOrders");
15
15
  const GetOrder_1 = require("./GetOrder");
16
+ const GetOrderEvents_1 = require("./GetOrderEvents");
16
17
  class AdminOrderAPI extends APIBase_1.APIBase {
17
18
  _runAction(Action, args) {
18
19
  return __awaiter(this, void 0, void 0, function* () {
@@ -30,5 +31,10 @@ class AdminOrderAPI extends APIBase_1.APIBase {
30
31
  return this._runAction(GetOrder_1.GetOrder, args);
31
32
  });
32
33
  }
34
+ getEvents(args) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return this._runAction(GetOrderEvents_1.GetOrderEvents, args);
37
+ });
38
+ }
33
39
  }
34
40
  exports.AdminOrderAPI = AdminOrderAPI;
@@ -0,0 +1,23 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface GetMenuInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ interface MenuItem extends Record<string, any> {
7
+ id: string;
8
+ title: string;
9
+ url: string;
10
+ type: string;
11
+ items: MenuItem[];
12
+ }
13
+ export interface GetMenuOutput extends Record<string, any> {
14
+ handle: string;
15
+ id: string;
16
+ isDefault: boolean;
17
+ title: string;
18
+ items: MenuItem[];
19
+ }
20
+ export declare class GetMenu extends ActionBuilder<AdminApiClient, GetMenuInput, GetMenuOutput> {
21
+ run(args: GetMenuInput): Promise<GetMenuOutput>;
22
+ }
23
+ export {};
@@ -0,0 +1,58 @@
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.GetMenu = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class GetMenu 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, 'Menu');
21
+ console.log('globalId', globalId);
22
+ const query = `
23
+ {
24
+ menu(id: "${globalId}") {
25
+ handle
26
+ id
27
+ isDefault
28
+ title
29
+ items(limit: 250) {
30
+ id
31
+ title
32
+ url
33
+ type
34
+ items {
35
+ id
36
+ title
37
+ url
38
+ type
39
+ items {
40
+ id
41
+ title
42
+ url
43
+ type
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ `;
50
+ const { data, errors, extensions } = yield this.client.request(query);
51
+ console.log('data', data);
52
+ yield (0, handleErrors_1.handleErrors)(errors);
53
+ const { menu } = Object.assign({}, data);
54
+ return Object.assign({}, menu);
55
+ });
56
+ }
57
+ }
58
+ exports.GetMenu = GetMenu;
@@ -0,0 +1,13 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface SearchMenusInput extends Record<string, any> {
4
+ after?: string;
5
+ limit?: number;
6
+ }
7
+ export interface SearchMenusOutput extends Record<string, any> {
8
+ items: any[];
9
+ pageInfo: any;
10
+ }
11
+ export declare class SearchMenus extends ActionBuilder<AdminApiClient, SearchMenusInput, SearchMenusOutput> {
12
+ run(args?: SearchMenusInput): Promise<SearchMenusOutput>;
13
+ }
@@ -0,0 +1,47 @@
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.SearchMenus = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const handleErrors_1 = require("../../../utils/handleErrors");
15
+ class SearchMenus extends ActionBuilder_1.ActionBuilder {
16
+ run(args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const { limit } = Object.assign({}, args);
19
+ const vLimit = limit || 10;
20
+ const query = `
21
+ {
22
+ menus(first: ${vLimit}) {
23
+ nodes {
24
+ handle
25
+ id
26
+ title
27
+ }
28
+ pageInfo {
29
+ hasNextPage
30
+ endCursor
31
+ }
32
+ }
33
+ }
34
+ `;
35
+ const { data, errors } = yield this.client.request(query);
36
+ yield (0, handleErrors_1.handleErrors)(errors);
37
+ const { menus } = Object.assign({}, data);
38
+ const { nodes, pageInfo } = Object.assign({}, menus);
39
+ const items = Array.isArray(nodes) ? nodes : [];
40
+ return {
41
+ items,
42
+ pageInfo
43
+ };
44
+ });
45
+ }
46
+ }
47
+ exports.SearchMenus = SearchMenus;
@@ -0,0 +1,13 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface SearchPayoutsInput extends Record<string, any> {
4
+ after?: string;
5
+ limit?: number;
6
+ }
7
+ export interface SearchPayoutsOutput extends Record<string, any> {
8
+ items: any[];
9
+ pageInfo: any;
10
+ }
11
+ export declare class SearchPayouts extends ActionBuilder<AdminApiClient, SearchPayoutsInput, SearchPayoutsOutput> {
12
+ run(args?: SearchPayoutsInput): Promise<SearchPayoutsOutput>;
13
+ }
@@ -0,0 +1,55 @@
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.SearchPayouts = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const handleErrors_1 = require("../../../utils/handleErrors");
15
+ class SearchPayouts extends ActionBuilder_1.ActionBuilder {
16
+ run(args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const { limit } = Object.assign({}, args);
19
+ const vLimit = limit || 10;
20
+ const query = `
21
+ query payouts {
22
+ shopifyPaymentsAccount {
23
+ payouts(first: ${vLimit}, sortKey: ISSUED_AT, reverse: true) {
24
+ nodes {
25
+ id
26
+ status
27
+ issuedAt
28
+ net {
29
+ amount
30
+ currencyCode
31
+ }
32
+ transactionType
33
+ }
34
+ pageInfo {
35
+ hasNextPage
36
+ endCursor
37
+ }
38
+ }
39
+ }
40
+ }
41
+ `;
42
+ const { data, errors } = yield this.client.request(query);
43
+ yield (0, handleErrors_1.handleErrors)(errors);
44
+ const { shopifyPaymentsAccount } = Object.assign({}, data);
45
+ const { payouts } = Object.assign({}, shopifyPaymentsAccount);
46
+ const { nodes, pageInfo } = Object.assign({}, payouts);
47
+ const items = Array.isArray(nodes) ? nodes : [];
48
+ return {
49
+ items,
50
+ pageInfo
51
+ };
52
+ });
53
+ }
54
+ }
55
+ exports.SearchPayouts = SearchPayouts;
@@ -0,0 +1,10 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { APIBase } from "../../APIBase";
3
+ import { SearchPayoutsInput, SearchPayoutsOutput } from "./SearchPayouts";
4
+ export interface AdminPaymentsAPIInterface {
5
+ searchPayouts(args: SearchPayoutsInput): Promise<SearchPayoutsOutput>;
6
+ }
7
+ export declare class AdminPaymentsAPI extends APIBase<AdminApiClient> implements AdminPaymentsAPIInterface {
8
+ private _runAction;
9
+ searchPayouts(args?: SearchPayoutsInput): Promise<SearchPayoutsOutput>;
10
+ }
@@ -0,0 +1,28 @@
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.AdminPaymentsAPI = void 0;
13
+ const APIBase_1 = require("../../APIBase");
14
+ const SearchPayouts_1 = require("./SearchPayouts");
15
+ class AdminPaymentsAPI extends APIBase_1.APIBase {
16
+ _runAction(Action, args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const action = new Action(this.client);
19
+ return action.run(args);
20
+ });
21
+ }
22
+ searchPayouts(args) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return this._runAction(SearchPayouts_1.SearchPayouts, args);
25
+ });
26
+ }
27
+ }
28
+ exports.AdminPaymentsAPI = AdminPaymentsAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",