@pintahub/shopify-api 1.1.5 → 1.1.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.
@@ -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,104 @@
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
+ class GetProduct 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, 'Product');
20
+ const query = `
21
+ {
22
+ product(id: "${globalId}") {
23
+ id
24
+ handle
25
+ publishedAt
26
+ updatedAt
27
+ status
28
+ featuredImage {
29
+ altText
30
+ url(transform: {preferredContentType: PNG, maxWidth: 1024})
31
+ width
32
+ height
33
+ }
34
+ productType
35
+ title
36
+ descriptionHtml
37
+ priceRangeV2 {
38
+ maxVariantPrice {
39
+ amount
40
+ currencyCode
41
+ }
42
+ minVariantPrice {
43
+ amount
44
+ currencyCode
45
+ }
46
+ }
47
+ tags
48
+ productCategory {
49
+ productTaxonomyNode {
50
+ fullName
51
+ name
52
+ }
53
+ }
54
+ collections(first: 100) {
55
+ nodes {
56
+ id
57
+ }
58
+ }
59
+ options {
60
+ values
61
+ name
62
+ }
63
+ metafields(first: 100) {
64
+ nodes {
65
+ key
66
+ value
67
+ type
68
+ }
69
+ }
70
+ images(first: 20) {
71
+ nodes {
72
+ id
73
+ url(transform: {maxWidth: 1000, crop: CENTER, preferredContentType: WEBP})
74
+ height
75
+ altText
76
+ width
77
+ }
78
+ }
79
+ variants(first: 250) {
80
+ nodes {
81
+ id
82
+ availableForSale
83
+ selectedOptions {
84
+ name
85
+ value
86
+ }
87
+ price
88
+ compareAtPrice
89
+ image {
90
+ id
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ `;
97
+ const { data } = yield this.client.request(query);
98
+ console.log('data', data);
99
+ const { product } = Object.assign({}, data);
100
+ return Object.assign({}, product);
101
+ });
102
+ }
103
+ }
104
+ exports.GetProduct = GetProduct;
@@ -0,0 +1,11 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface GetPublicationsInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetPublicationsOutput extends Record<string, any> {
7
+ publications: Array<any>;
8
+ }
9
+ export declare class GetPublications extends ActionBuilder<AdminApiClient, GetPublicationsInput, GetPublicationsOutput> {
10
+ run(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
11
+ }
@@ -0,0 +1,48 @@
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.GetPublications = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ class GetPublications 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, 'Product');
20
+ const query = `
21
+ {
22
+ product(id: "${globalId}") {
23
+ id
24
+ resourcePublications(first: 50) {
25
+ nodes {
26
+ isPublished
27
+ publication {
28
+ id
29
+ name
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ `;
36
+ const { data, extensions } = yield this.client.request(query);
37
+ const { product } = Object.assign({}, data);
38
+ const { resourcePublications, id: idResult } = Object.assign({}, product);
39
+ const { nodes } = Object.assign({}, resourcePublications);
40
+ const publications = Array.isArray(nodes) ? nodes : [];
41
+ return {
42
+ id: idResult,
43
+ publications,
44
+ };
45
+ });
46
+ }
47
+ }
48
+ exports.GetPublications = GetPublications;
@@ -2,12 +2,15 @@ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
2
  import { APIBase } from "../../APIBase";
3
3
  import { GetProductInput, GetProductOutput } from "./GetProduct";
4
4
  import { SearchProductsInput, SearchProductsOutput } from "./SearchProducts";
5
+ import { GetPublicationsInput, GetPublicationsOutput } from "./GetPublications";
5
6
  export interface AdminProductAPIInterface {
6
7
  get(args: GetProductInput): Promise<GetProductOutput>;
8
+ getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
7
9
  search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
8
10
  }
9
11
  export declare class AdminProductAPI extends APIBase<AdminApiClient> implements AdminProductAPIInterface {
10
12
  private _runAction;
11
13
  get(args: GetProductInput): Promise<GetProductOutput>;
14
+ getPublications(args: GetPublicationsInput): Promise<GetPublicationsOutput>;
12
15
  search(args?: SearchProductsInput): Promise<SearchProductsOutput>;
13
16
  }
@@ -13,6 +13,7 @@ exports.AdminProductAPI = void 0;
13
13
  const APIBase_1 = require("../../APIBase");
14
14
  const GetProduct_1 = require("./GetProduct");
15
15
  const SearchProducts_1 = require("./SearchProducts");
16
+ const GetPublications_1 = require("./GetPublications");
16
17
  class AdminProductAPI extends APIBase_1.APIBase {
17
18
  _runAction(Action, args) {
18
19
  return __awaiter(this, void 0, void 0, function* () {
@@ -25,6 +26,11 @@ class AdminProductAPI extends APIBase_1.APIBase {
25
26
  return this._runAction(GetProduct_1.GetProduct, args);
26
27
  });
27
28
  }
29
+ getPublications(args) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ return this._runAction(GetPublications_1.GetPublications, args);
32
+ });
33
+ }
28
34
  search(args) {
29
35
  return __awaiter(this, void 0, void 0, function* () {
30
36
  return this._runAction(SearchProducts_1.SearchProducts, args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",