@pintahub/shopify-api 1.6.4 → 1.6.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.
@@ -4,6 +4,7 @@ import { AdminMetaObjectAPIInterface } from "./admin/metaobjects";
4
4
  import { AdminOrderAPIInterface } from "./admin/orders";
5
5
  import { APIOptions } from "../interfaces/APIOptions";
6
6
  import { AdminFileAPIInterface } from "./admin/files";
7
+ import { AdminMenuAPIInterface } from "./admin/menus";
7
8
  export declare class AdminAPI {
8
9
  private readonly options;
9
10
  private readonly client;
@@ -12,6 +13,7 @@ export declare class AdminAPI {
12
13
  readonly metaobject: AdminMetaObjectAPIInterface;
13
14
  readonly order: AdminOrderAPIInterface;
14
15
  readonly files: AdminFileAPIInterface;
16
+ readonly menus: AdminMenuAPIInterface;
15
17
  constructor(options: APIOptions);
16
18
  private _createClient;
17
19
  }
@@ -7,6 +7,7 @@ const collections_1 = require("./admin/collections");
7
7
  const metaobjects_1 = require("./admin/metaobjects");
8
8
  const orders_1 = require("./admin/orders");
9
9
  const files_1 = require("./admin/files");
10
+ const menus_1 = require("./admin/menus");
10
11
  class AdminAPI {
11
12
  constructor(options) {
12
13
  this.options = options;
@@ -16,13 +17,14 @@ class AdminAPI {
16
17
  this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this.client);
17
18
  this.order = new orders_1.AdminOrderAPI(this.client);
18
19
  this.files = new files_1.AdminFileAPI(this.client); //Start migration with plurality
20
+ this.menus = new menus_1.AdminMenuAPI(this._createClient('2024-07'));
19
21
  }
20
- _createClient() {
22
+ _createClient(apiVersion = '2023-10') {
21
23
  const { shop, accessToken } = this.options;
22
24
  return (0, admin_api_client_1.createAdminApiClient)({
23
25
  storeDomain: shop,
24
26
  accessToken: accessToken,
25
- apiVersion: '2023-10'
27
+ apiVersion: apiVersion
26
28
  });
27
29
  }
28
30
  }
@@ -0,0 +1,23 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/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,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.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
+ const query = `
22
+ {
23
+ menu(id: "${globalId}") {
24
+ handle
25
+ id
26
+ isDefault
27
+ title
28
+ items(limit: 250) {
29
+ id
30
+ title
31
+ url
32
+ type
33
+ items {
34
+ id
35
+ title
36
+ url
37
+ type
38
+ items {
39
+ id
40
+ title
41
+ url
42
+ type
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ `;
49
+ const { data, errors, extensions } = yield this.client.request(query);
50
+ yield (0, handleErrors_1.handleErrors)(errors);
51
+ const { menu } = Object.assign({}, data);
52
+ return Object.assign({}, menu);
53
+ });
54
+ }
55
+ }
56
+ exports.GetMenu = GetMenu;
@@ -0,0 +1,13 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/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/types";
2
+ import { APIBase } from "../../APIBase";
3
+ import { SearchMenusInput, SearchMenusOutput } from "./SearchMenus";
4
+ import { GetMenuInput, GetMenuOutput } from "./GetMenu";
5
+ export interface AdminMenuAPIInterface {
6
+ search(args: SearchMenusInput): Promise<SearchMenusOutput>;
7
+ get(args: GetMenuInput): Promise<GetMenuOutput>;
8
+ }
9
+ export declare class AdminMenuAPI extends APIBase<AdminApiClient> implements AdminMenuAPIInterface {
10
+ private _runAction;
11
+ search(args?: SearchMenusInput): Promise<SearchMenusOutput>;
12
+ get(args?: GetMenuInput): Promise<GetMenuOutput>;
13
+ }
@@ -0,0 +1,34 @@
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.AdminMenuAPI = void 0;
13
+ const APIBase_1 = require("../../APIBase");
14
+ const SearchMenus_1 = require("./SearchMenus");
15
+ const GetMenu_1 = require("./GetMenu");
16
+ class AdminMenuAPI extends APIBase_1.APIBase {
17
+ _runAction(Action, args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const action = new Action(this.client);
20
+ return action.run(args);
21
+ });
22
+ }
23
+ search(args) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return this._runAction(SearchMenus_1.SearchMenus, args);
26
+ });
27
+ }
28
+ get(args) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this._runAction(GetMenu_1.GetMenu, args);
31
+ });
32
+ }
33
+ }
34
+ exports.AdminMenuAPI = AdminMenuAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",