@pintahub/shopify-api 1.1.9 → 1.2.2

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.
@@ -1,5 +1,6 @@
1
1
  import { AdminProductAPIInterface } from "./admin/products";
2
2
  import { AdminCollectionAPIInterface } from "./admin/collections";
3
+ import { AdminMetaObjectAPIInterface } from "./admin/metaobjects";
3
4
  export interface APIOptions extends Record<string, any> {
4
5
  shop: string;
5
6
  accessToken: string;
@@ -9,6 +10,7 @@ export declare class AdminAPI {
9
10
  private readonly client;
10
11
  readonly product: AdminProductAPIInterface;
11
12
  readonly collection: AdminCollectionAPIInterface;
13
+ readonly metaobject: AdminMetaObjectAPIInterface;
12
14
  constructor(options: APIOptions);
13
15
  private _createClient;
14
16
  }
@@ -4,12 +4,14 @@ exports.AdminAPI = void 0;
4
4
  const admin_api_client_1 = require("@shopify/admin-api-client");
5
5
  const products_1 = require("./admin/products");
6
6
  const collections_1 = require("./admin/collections");
7
+ const metaobjects_1 = require("./admin/metaobjects");
7
8
  class AdminAPI {
8
9
  constructor(options) {
9
10
  this.options = options;
10
11
  this.client = this._createClient();
11
12
  this.product = new products_1.AdminProductAPI(this.client);
12
13
  this.collection = new collections_1.AdminCollectionAPI(this.client);
14
+ this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this.client);
13
15
  }
14
16
  _createClient() {
15
17
  const { shop, accessToken } = this.options;
@@ -0,0 +1,10 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface GetMetaObjectInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetMetaObjectOutput extends Record<string, any> {
7
+ }
8
+ export declare class GetMetaObject extends ActionBuilder<AdminApiClient, GetMetaObjectInput, GetMetaObjectOutput> {
9
+ run(args: GetMetaObjectInput): Promise<GetMetaObjectOutput>;
10
+ }
@@ -0,0 +1,41 @@
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.GetMetaObject = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ class GetMetaObject extends ActionBuilder_1.ActionBuilder {
16
+ run(args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const { id } = args;
19
+ const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Metaobject');
20
+ const query = `
21
+ {
22
+ metaobject(id: "${globalId}") {
23
+ id
24
+ handle
25
+ displayName
26
+ type
27
+ fields {
28
+ key
29
+ type
30
+ value
31
+ }
32
+ }
33
+ }
34
+ `;
35
+ const { data } = yield this.client.request(query);
36
+ const { metaobject } = Object.assign({}, data);
37
+ return Object.assign({}, metaobject);
38
+ });
39
+ }
40
+ }
41
+ exports.GetMetaObject = GetMetaObject;
@@ -0,0 +1,12 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface SearchMetaObjectsInput extends Record<string, any> {
4
+ type: String;
5
+ }
6
+ export interface SearchMetaObjectsOutput extends Record<string, any> {
7
+ items: any[];
8
+ pageInfo: any;
9
+ }
10
+ export declare class SearchMetaObjects extends ActionBuilder<AdminApiClient, SearchMetaObjectsInput, SearchMetaObjectsOutput> {
11
+ run(args: SearchMetaObjectsInput): Promise<SearchMetaObjectsOutput>;
12
+ }
@@ -0,0 +1,42 @@
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.SearchMetaObjects = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ class SearchMetaObjects extends ActionBuilder_1.ActionBuilder {
15
+ run(args) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const { type } = Object.assign({}, args);
18
+ const query = `
19
+ {
20
+ metaobjects(type: "${type}", first: 100) {
21
+ nodes {
22
+ id
23
+ }
24
+ pageInfo {
25
+ endCursor
26
+ hasNextPage
27
+ }
28
+ }
29
+ }
30
+ `;
31
+ const { data } = yield this.client.request(query);
32
+ const { metaobjects } = Object.assign({}, data);
33
+ const { nodes, pageInfo } = Object.assign({}, metaobjects);
34
+ const items = Array.isArray(nodes) ? nodes : [];
35
+ return {
36
+ items,
37
+ pageInfo
38
+ };
39
+ });
40
+ }
41
+ }
42
+ exports.SearchMetaObjects = SearchMetaObjects;
@@ -0,0 +1,13 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { APIBase } from "../../APIBase";
3
+ import { SearchMetaObjectsInput, SearchMetaObjectsOutput } from "./SearchMetaObjects";
4
+ import { GetMetaObjectInput, GetMetaObjectOutput } from "./GetMetaObject";
5
+ export interface AdminMetaObjectAPIInterface {
6
+ get(args: GetMetaObjectInput): Promise<GetMetaObjectOutput>;
7
+ search(args: SearchMetaObjectsInput): Promise<SearchMetaObjectsOutput>;
8
+ }
9
+ export declare class AdminMetaObjectAPI extends APIBase<AdminApiClient> implements AdminMetaObjectAPIInterface {
10
+ private _runAction;
11
+ get(args: GetMetaObjectInput): Promise<GetMetaObjectOutput>;
12
+ search(args: SearchMetaObjectsInput): Promise<SearchMetaObjectsOutput>;
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.AdminMetaObjectAPI = void 0;
13
+ const APIBase_1 = require("../../APIBase");
14
+ const SearchMetaObjects_1 = require("./SearchMetaObjects");
15
+ const GetMetaObject_1 = require("./GetMetaObject");
16
+ class AdminMetaObjectAPI 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
+ get(args) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return this._runAction(GetMetaObject_1.GetMetaObject, args);
26
+ });
27
+ }
28
+ search(args) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this._runAction(SearchMetaObjects_1.SearchMetaObjects, args);
31
+ });
32
+ }
33
+ }
34
+ exports.AdminMetaObjectAPI = AdminMetaObjectAPI;
@@ -31,6 +31,16 @@ class GetProduct extends ActionBuilder_1.ActionBuilder {
31
31
  width
32
32
  height
33
33
  }
34
+ priceRangeV2 {
35
+ maxVariantPrice {
36
+ amount
37
+ currencyCode
38
+ }
39
+ minVariantPrice {
40
+ amount
41
+ currencyCode
42
+ }
43
+ }
34
44
  productType
35
45
  title
36
46
  descriptionHtml
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.1.9",
3
+ "version": "1.2.2",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",