@pintahub/shopify-api 1.0.3 → 1.0.4

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.
Files changed (39) hide show
  1. package/dist/actions/admin/GetProduct.d.ts +10 -0
  2. package/dist/actions/admin/GetProduct.js +74 -0
  3. package/dist/actions/admin/SearchProducts.d.ts +12 -0
  4. package/dist/actions/admin/SearchProducts.js +45 -0
  5. package/dist/actions/admin/products/GetProduct.d.ts +10 -0
  6. package/dist/actions/admin/products/GetProduct.js +74 -0
  7. package/dist/actions/admin/products/SearchProducts.d.ts +12 -0
  8. package/dist/actions/admin/products/SearchProducts.js +45 -0
  9. package/dist/actions/storefront/getProductByHandle.d.ts +11 -0
  10. package/dist/actions/storefront/getProductByHandle.js +39 -0
  11. package/dist/classes/APIBase.d.ts +4 -0
  12. package/dist/classes/APIBase.js +9 -0
  13. package/dist/classes/ActionBase.d.ts +2 -0
  14. package/dist/classes/ActionBase.js +6 -0
  15. package/dist/classes/ActionBuilder.d.ts +11 -0
  16. package/dist/classes/ActionBuilder.js +9 -0
  17. package/dist/classes/AdminAPI.d.ts +5 -4
  18. package/dist/classes/AdminAPI.js +8 -98
  19. package/dist/classes/StorefrontAPI.d.ts +7 -0
  20. package/dist/classes/StorefrontAPI.js +15 -0
  21. package/dist/classes/admin/pages/SearchPages.d.ts +11 -0
  22. package/dist/classes/admin/pages/SearchPages.js +24 -0
  23. package/dist/classes/admin/pages/index.d.ts +10 -0
  24. package/dist/classes/admin/pages/index.js +28 -0
  25. package/dist/classes/admin/products/GetProduct.d.ts +10 -0
  26. package/dist/classes/admin/products/GetProduct.js +74 -0
  27. package/dist/classes/admin/products/SearchProducts.d.ts +11 -0
  28. package/dist/classes/admin/products/SearchProducts.js +45 -0
  29. package/dist/classes/admin/products/index.d.ts +13 -0
  30. package/dist/classes/admin/products/index.js +34 -0
  31. package/dist/classes/storefront/pages/GetPage.d.ts +10 -0
  32. package/dist/classes/storefront/pages/GetPage.js +43 -0
  33. package/dist/classes/storefront/pages/SearchPages.d.ts +11 -0
  34. package/dist/classes/storefront/pages/SearchPages.js +41 -0
  35. package/dist/classes/storefront/pages/index.d.ts +13 -0
  36. package/dist/classes/storefront/pages/index.js +34 -0
  37. package/dist/interfaces/StorefrontAPI.d.ts +4 -0
  38. package/dist/interfaces/StorefrontAPI.js +2 -0
  39. package/package.json +3 -2
@@ -0,0 +1,10 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../classes/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,74 @@
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("../../classes/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
+ priceRangeV2 {
37
+ maxVariantPrice {
38
+ amount
39
+ currencyCode
40
+ }
41
+ minVariantPrice {
42
+ amount
43
+ currencyCode
44
+ }
45
+ }
46
+ tags
47
+ productCategory {
48
+ productTaxonomyNode {
49
+ fullName
50
+ name
51
+ }
52
+ }
53
+ collections(first: 100) {
54
+ nodes {
55
+ id
56
+ }
57
+ }
58
+ metafields(first: 100) {
59
+ nodes {
60
+ key
61
+ value
62
+ type
63
+ }
64
+ }
65
+ }
66
+ }
67
+ `;
68
+ const { data } = yield this.client.request(query);
69
+ const { product } = Object.assign({}, data);
70
+ return Object.assign({}, product);
71
+ });
72
+ }
73
+ }
74
+ exports.GetProduct = GetProduct;
@@ -0,0 +1,12 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../classes/ActionBuilder";
3
+ export interface SearchProductsInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface SearchProductsOutput extends Record<string, any> {
7
+ items: any[];
8
+ pageInfo: any;
9
+ }
10
+ export declare class SearchProducts extends ActionBuilder<AdminApiClient, SearchProductsInput, SearchProductsOutput> {
11
+ run(args?: SearchProductsInput): Promise<SearchProductsOutput>;
12
+ }
@@ -0,0 +1,45 @@
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.SearchProducts = void 0;
13
+ const ActionBuilder_1 = require("../../classes/ActionBuilder");
14
+ class SearchProducts extends ActionBuilder_1.ActionBuilder {
15
+ run(args) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const query = `
18
+ {
19
+ products(
20
+ first: 100
21
+ sortKey: UPDATED_AT
22
+ reverse: true
23
+ ) {
24
+ nodes {
25
+ id
26
+ }
27
+ pageInfo {
28
+ hasNextPage
29
+ endCursor
30
+ }
31
+ }
32
+ }
33
+ `;
34
+ const { data } = yield this.client.request(query);
35
+ const { products } = Object.assign({}, data);
36
+ const { nodes, pageInfo } = Object.assign({}, products);
37
+ const items = Array.isArray(nodes) ? nodes : [];
38
+ return {
39
+ items,
40
+ pageInfo
41
+ };
42
+ });
43
+ }
44
+ }
45
+ exports.SearchProducts = SearchProducts;
@@ -0,0 +1,10 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../../classes/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,74 @@
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("../../../classes/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
+ priceRangeV2 {
37
+ maxVariantPrice {
38
+ amount
39
+ currencyCode
40
+ }
41
+ minVariantPrice {
42
+ amount
43
+ currencyCode
44
+ }
45
+ }
46
+ tags
47
+ productCategory {
48
+ productTaxonomyNode {
49
+ fullName
50
+ name
51
+ }
52
+ }
53
+ collections(first: 100) {
54
+ nodes {
55
+ id
56
+ }
57
+ }
58
+ metafields(first: 100) {
59
+ nodes {
60
+ key
61
+ value
62
+ type
63
+ }
64
+ }
65
+ }
66
+ }
67
+ `;
68
+ const { data } = yield this.client.request(query);
69
+ const { product } = Object.assign({}, data);
70
+ return Object.assign({}, product);
71
+ });
72
+ }
73
+ }
74
+ exports.GetProduct = GetProduct;
@@ -0,0 +1,12 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../../classes/ActionBuilder";
3
+ export interface SearchProductsInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface SearchProductsOutput extends Record<string, any> {
7
+ items: any[];
8
+ pageInfo: any;
9
+ }
10
+ export declare class SearchProducts extends ActionBuilder<AdminApiClient, SearchProductsInput, SearchProductsOutput> {
11
+ run(args?: SearchProductsInput): Promise<SearchProductsOutput>;
12
+ }
@@ -0,0 +1,45 @@
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.SearchProducts = void 0;
13
+ const ActionBuilder_1 = require("../../../classes/ActionBuilder");
14
+ class SearchProducts extends ActionBuilder_1.ActionBuilder {
15
+ run(args) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const query = `
18
+ {
19
+ products(
20
+ first: 100
21
+ sortKey: UPDATED_AT
22
+ reverse: true
23
+ ) {
24
+ nodes {
25
+ id
26
+ }
27
+ pageInfo {
28
+ hasNextPage
29
+ endCursor
30
+ }
31
+ }
32
+ }
33
+ `;
34
+ const { data } = yield this.client.request(query);
35
+ const { products } = Object.assign({}, data);
36
+ const { nodes, pageInfo } = Object.assign({}, products);
37
+ const items = Array.isArray(nodes) ? nodes : [];
38
+ return {
39
+ items,
40
+ pageInfo
41
+ };
42
+ });
43
+ }
44
+ }
45
+ exports.SearchProducts = SearchProducts;
@@ -0,0 +1,11 @@
1
+ import { ActionBuilder } from "../../classes/ActionBuilder";
2
+ import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
3
+ export interface GetProductInput extends Record<string, any> {
4
+ handle: string;
5
+ }
6
+ export interface GetProductOutput extends Record<string, any> {
7
+ product: any;
8
+ }
9
+ export declare class GetProductByHandle extends ActionBuilder<StorefrontApiClient, GetProductInput, GetProductOutput> {
10
+ run(args: GetProductInput): Promise<GetProductOutput>;
11
+ }
@@ -0,0 +1,39 @@
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.GetProductByHandle = void 0;
13
+ const ActionBuilder_1 = require("../../classes/ActionBuilder");
14
+ class GetProductByHandle extends ActionBuilder_1.ActionBuilder {
15
+ run(args) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const productQuery = `
18
+ query ($handle: String) {
19
+ product(handle: $handle) {
20
+ id
21
+ title
22
+ handle
23
+ }
24
+ }
25
+ `;
26
+ const { handle } = args;
27
+ const { data } = yield this.client.request(productQuery, {
28
+ variables: {
29
+ handle
30
+ }
31
+ });
32
+ const { product } = Object.assign({}, data);
33
+ return {
34
+ product,
35
+ };
36
+ });
37
+ }
38
+ }
39
+ exports.GetProductByHandle = GetProductByHandle;
@@ -0,0 +1,4 @@
1
+ export declare abstract class APIBase<Client> {
2
+ protected readonly client: Client;
3
+ constructor(client: Client);
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APIBase = void 0;
4
+ class APIBase {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ }
9
+ exports.APIBase = APIBase;
@@ -0,0 +1,2 @@
1
+ export declare abstract class ActionBase {
2
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionBase = void 0;
4
+ class ActionBase {
5
+ }
6
+ exports.ActionBase = ActionBase;
@@ -0,0 +1,11 @@
1
+ export interface ActionBuilderInterface<Client, Input, Output> {
2
+ run(args?: Input): Promise<Output>;
3
+ }
4
+ export interface ActionBuilderConstructor<Client, Input, Output> {
5
+ new (client: Client): ActionBuilderInterface<Client, Input, Output>;
6
+ }
7
+ export declare abstract class ActionBuilder<Client, Input, Output> {
8
+ protected readonly client: Client;
9
+ constructor(client: Client);
10
+ abstract run(args?: Input): Promise<Output>;
11
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionBuilder = void 0;
4
+ class ActionBuilder {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ }
9
+ exports.ActionBuilder = ActionBuilder;
@@ -1,11 +1,12 @@
1
+ import { AdminProductAPIInterface } from "./admin/products";
1
2
  export interface APIOptions extends Record<string, any> {
2
3
  shop: string;
3
4
  accessToken: string;
4
5
  }
5
6
  export declare class AdminAPI {
6
7
  private readonly options;
7
- private client;
8
- constructor(opts: APIOptions);
9
- getProduct(id: string): Promise<any>;
10
- getProducts(): Promise<any>;
8
+ private readonly client;
9
+ readonly product: AdminProductAPIInterface;
10
+ constructor(options: APIOptions);
11
+ private _createClient;
11
12
  }
@@ -1,111 +1,21 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.AdminAPI = void 0;
13
4
  const admin_api_client_1 = require("@shopify/admin-api-client");
14
- const getGlobalID_1 = require("../utils/getGlobalID");
5
+ const products_1 = require("./admin/products");
15
6
  class AdminAPI {
16
- constructor(opts) {
17
- this.options = opts;
7
+ constructor(options) {
8
+ this.options = options;
9
+ this.client = this._createClient();
10
+ this.product = new products_1.AdminProductAPI(this.client);
11
+ }
12
+ _createClient() {
18
13
  const { shop, accessToken } = this.options;
19
- this.client = (0, admin_api_client_1.createAdminApiClient)({
14
+ return (0, admin_api_client_1.createAdminApiClient)({
20
15
  storeDomain: shop,
21
16
  accessToken: accessToken,
22
17
  apiVersion: '2023-10'
23
18
  });
24
19
  }
25
- getProduct(id) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Product');
28
- const query = `
29
- {
30
- product(id: "${globalId}") {
31
- id
32
- handle
33
- publishedAt
34
- updatedAt
35
- status
36
- featuredImage {
37
- altText
38
- url(transform: {preferredContentType: PNG, maxWidth: 1024})
39
- width
40
- height
41
- }
42
- productType
43
- title
44
- priceRangeV2 {
45
- maxVariantPrice {
46
- amount
47
- currencyCode
48
- }
49
- minVariantPrice {
50
- amount
51
- currencyCode
52
- }
53
- }
54
- tags
55
- productCategory {
56
- productTaxonomyNode {
57
- fullName
58
- name
59
- }
60
- }
61
- collections(first: 100) {
62
- nodes {
63
- id
64
- }
65
- }
66
- metafields(first: 100) {
67
- nodes {
68
- key
69
- value
70
- type
71
- }
72
- }
73
- }
74
- }
75
- `;
76
- const { data } = yield this.client.request(query);
77
- const { product } = Object.assign({}, data);
78
- return Object.assign({}, product);
79
- });
80
- }
81
- getProducts() {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- const query = `
84
- {
85
- products(
86
- first: 100
87
- sortKey: UPDATED_AT
88
- reverse: true
89
- ) {
90
- nodes {
91
- id
92
- }
93
- pageInfo {
94
- hasNextPage
95
- endCursor
96
- }
97
- }
98
- }
99
- `;
100
- const { data } = yield this.client.request(query);
101
- const { products } = Object.assign({}, data);
102
- const { nodes, pageInfo } = Object.assign({}, products);
103
- const items = Array.isArray(nodes) ? nodes : [];
104
- return {
105
- items,
106
- pageInfo
107
- };
108
- });
109
- }
110
20
  }
111
21
  exports.AdminAPI = AdminAPI;
@@ -1,2 +1,9 @@
1
+ import { StorefrontAPIOptions } from "../interfaces/StorefrontAPI";
2
+ import { PageAPIInterface } from "./storefront/pages";
1
3
  export declare class StorefrontAPI {
4
+ private readonly options;
5
+ private readonly client;
6
+ readonly page: PageAPIInterface;
7
+ constructor(options: StorefrontAPIOptions);
8
+ private _createClient;
2
9
  }
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StorefrontAPI = void 0;
4
+ const storefront_api_client_1 = require("@shopify/storefront-api-client");
5
+ const pages_1 = require("./storefront/pages");
4
6
  class StorefrontAPI {
7
+ constructor(options) {
8
+ this.options = options;
9
+ this.client = this._createClient();
10
+ this.page = new pages_1.PageAPI(this.client);
11
+ }
12
+ _createClient() {
13
+ const { shop, accessToken } = this.options;
14
+ return (0, storefront_api_client_1.createStorefrontApiClient)({
15
+ storeDomain: shop,
16
+ apiVersion: '2023-10',
17
+ publicAccessToken: accessToken
18
+ });
19
+ }
5
20
  }
6
21
  exports.StorefrontAPI = StorefrontAPI;
@@ -0,0 +1,11 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface SearchPagesInput extends Record<string, any> {
4
+ }
5
+ export interface SearchPagesOutput extends Record<string, any> {
6
+ items: any[];
7
+ pageInfo: any;
8
+ }
9
+ export declare class SearchPages extends ActionBuilder<AdminApiClient, SearchPagesInput, SearchPagesOutput> {
10
+ run(args?: SearchPagesInput): Promise<SearchPagesOutput>;
11
+ }
@@ -0,0 +1,24 @@
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.SearchPages = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ class SearchPages extends ActionBuilder_1.ActionBuilder {
15
+ run(args) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ return {
18
+ items: [],
19
+ pageInfo: ''
20
+ };
21
+ });
22
+ }
23
+ }
24
+ exports.SearchPages = SearchPages;
@@ -0,0 +1,10 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { APIBase } from "../../APIBase";
3
+ import { SearchPagesInput, SearchPagesOutput } from "./SearchPages";
4
+ export interface AdminPageAPIInterface {
5
+ searchPages(args?: SearchPagesInput): Promise<SearchPagesOutput>;
6
+ }
7
+ export declare class AdminPageAPI extends APIBase<AdminApiClient> implements AdminPageAPIInterface {
8
+ private _runAction;
9
+ searchPages(args?: SearchPagesInput): Promise<SearchPagesOutput>;
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.AdminPageAPI = void 0;
13
+ const APIBase_1 = require("../../APIBase");
14
+ const SearchPages_1 = require("./SearchPages");
15
+ class AdminPageAPI 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
+ searchPages(args) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return this._runAction(SearchPages_1.SearchPages, args);
25
+ });
26
+ }
27
+ }
28
+ exports.AdminPageAPI = AdminPageAPI;
@@ -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,74 @@
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
+ priceRangeV2 {
37
+ maxVariantPrice {
38
+ amount
39
+ currencyCode
40
+ }
41
+ minVariantPrice {
42
+ amount
43
+ currencyCode
44
+ }
45
+ }
46
+ tags
47
+ productCategory {
48
+ productTaxonomyNode {
49
+ fullName
50
+ name
51
+ }
52
+ }
53
+ collections(first: 100) {
54
+ nodes {
55
+ id
56
+ }
57
+ }
58
+ metafields(first: 100) {
59
+ nodes {
60
+ key
61
+ value
62
+ type
63
+ }
64
+ }
65
+ }
66
+ }
67
+ `;
68
+ const { data } = yield this.client.request(query);
69
+ const { product } = Object.assign({}, data);
70
+ return Object.assign({}, product);
71
+ });
72
+ }
73
+ }
74
+ 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 SearchProductsInput extends Record<string, any> {
4
+ }
5
+ export interface SearchProductsOutput extends Record<string, any> {
6
+ items: any[];
7
+ pageInfo: any;
8
+ }
9
+ export declare class SearchProducts extends ActionBuilder<AdminApiClient, SearchProductsInput, SearchProductsOutput> {
10
+ run(args?: SearchProductsInput): Promise<SearchProductsOutput>;
11
+ }
@@ -0,0 +1,45 @@
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.SearchProducts = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ class SearchProducts extends ActionBuilder_1.ActionBuilder {
15
+ run(args) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const query = `
18
+ {
19
+ products(
20
+ first: 100
21
+ sortKey: UPDATED_AT
22
+ reverse: true
23
+ ) {
24
+ nodes {
25
+ id
26
+ }
27
+ pageInfo {
28
+ hasNextPage
29
+ endCursor
30
+ }
31
+ }
32
+ }
33
+ `;
34
+ const { data } = yield this.client.request(query);
35
+ const { products } = Object.assign({}, data);
36
+ const { nodes, pageInfo } = Object.assign({}, products);
37
+ const items = Array.isArray(nodes) ? nodes : [];
38
+ return {
39
+ items,
40
+ pageInfo
41
+ };
42
+ });
43
+ }
44
+ }
45
+ exports.SearchProducts = SearchProducts;
@@ -0,0 +1,13 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/types";
2
+ import { APIBase } from "../../APIBase";
3
+ import { GetProductInput, GetProductOutput } from "./GetProduct";
4
+ import { SearchProductsInput, SearchProductsOutput } from "./SearchProducts";
5
+ export interface AdminProductAPIInterface {
6
+ getProduct(args: GetProductInput): Promise<GetProductOutput>;
7
+ searchProducts(args?: SearchProductsInput): Promise<SearchProductsOutput>;
8
+ }
9
+ export declare class AdminProductAPI extends APIBase<AdminApiClient> implements AdminProductAPIInterface {
10
+ private _runAction;
11
+ getProduct(args: GetProductInput): Promise<GetProductOutput>;
12
+ searchProducts(args?: SearchProductsInput): Promise<SearchProductsOutput>;
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.AdminProductAPI = void 0;
13
+ const APIBase_1 = require("../../APIBase");
14
+ const GetProduct_1 = require("./GetProduct");
15
+ const SearchProducts_1 = require("./SearchProducts");
16
+ class AdminProductAPI 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
+ getProduct(args) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return this._runAction(GetProduct_1.GetProduct, args);
26
+ });
27
+ }
28
+ searchProducts(args) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this._runAction(SearchProducts_1.SearchProducts, args);
31
+ });
32
+ }
33
+ }
34
+ exports.AdminProductAPI = AdminProductAPI;
@@ -0,0 +1,10 @@
1
+ import { ActionBuilder } from "../../ActionBuilder";
2
+ import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
3
+ export interface GetPageInput extends Record<string, any> {
4
+ id: string;
5
+ }
6
+ export interface GetPageOutput extends Record<string, any> {
7
+ }
8
+ export declare class GetPage extends ActionBuilder<StorefrontApiClient, GetPageInput, GetPageOutput> {
9
+ run(args: GetPageInput): Promise<GetPageOutput>;
10
+ }
@@ -0,0 +1,43 @@
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.GetPage = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ class GetPage extends ActionBuilder_1.ActionBuilder {
16
+ run(args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const query = `
19
+ query ($id: ID){
20
+ page(id: $id) {
21
+ body
22
+ handle
23
+ id
24
+ title
25
+ onlineStoreUrl
26
+ bodySummary
27
+ updatedAt
28
+ }
29
+ }
30
+ `;
31
+ const { id } = args;
32
+ const globalId = (0, getGlobalID_1.getGlobalID)(id);
33
+ const { data } = yield this.client.request(query, {
34
+ variables: {
35
+ id: globalId
36
+ }
37
+ });
38
+ const { page } = Object.assign({}, data);
39
+ return Object.assign({}, page);
40
+ });
41
+ }
42
+ }
43
+ exports.GetPage = GetPage;
@@ -0,0 +1,11 @@
1
+ import { ActionBuilder } from "../../ActionBuilder";
2
+ import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
3
+ export interface SearchPagesInput extends Record<string, any> {
4
+ }
5
+ export interface SearchPagesOutput extends Record<string, any> {
6
+ items: any[];
7
+ pageInfo: any;
8
+ }
9
+ export declare class SearchPages extends ActionBuilder<StorefrontApiClient, SearchPagesInput, SearchPagesOutput> {
10
+ run(args?: SearchPagesInput): Promise<SearchPagesOutput>;
11
+ }
@@ -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.SearchPages = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ class SearchPages extends ActionBuilder_1.ActionBuilder {
15
+ run(args) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const query = `
18
+ {
19
+ pages(first: 100, reverse: true, sortKey: UPDATED_AT) {
20
+ nodes {
21
+ id
22
+ }
23
+ pageInfo {
24
+ endCursor
25
+ hasNextPage
26
+ }
27
+ }
28
+ }
29
+ `;
30
+ const { data } = yield this.client.request(query);
31
+ const { pages } = Object.assign({}, data);
32
+ const { nodes, pageInfo } = Object.assign({}, pages);
33
+ const items = Array.isArray(nodes) ? nodes : [];
34
+ return {
35
+ items,
36
+ pageInfo,
37
+ };
38
+ });
39
+ }
40
+ }
41
+ exports.SearchPages = SearchPages;
@@ -0,0 +1,13 @@
1
+ import { APIBase } from "../../APIBase";
2
+ import { SearchPagesInput, SearchPagesOutput } from "./SearchPages";
3
+ import { StorefrontApiClient } from "@shopify/storefront-api-client/dist/ts/types";
4
+ import { GetPageInput, GetPageOutput } from "./GetPage";
5
+ export interface PageAPIInterface {
6
+ searchPages(args?: SearchPagesInput): Promise<SearchPagesOutput>;
7
+ getPage(args: GetPageInput): Promise<GetPageOutput>;
8
+ }
9
+ export declare class PageAPI extends APIBase<StorefrontApiClient> implements PageAPIInterface {
10
+ private _runAction;
11
+ searchPages(args?: SearchPagesInput): Promise<SearchPagesOutput>;
12
+ getPage(args: GetPageInput): Promise<GetPageOutput>;
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.PageAPI = void 0;
13
+ const APIBase_1 = require("../../APIBase");
14
+ const SearchPages_1 = require("./SearchPages");
15
+ const GetPage_1 = require("./GetPage");
16
+ class PageAPI 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
+ searchPages(args) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return this._runAction(SearchPages_1.SearchPages, args);
26
+ });
27
+ }
28
+ getPage(args) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this._runAction(GetPage_1.GetPage, args);
31
+ });
32
+ }
33
+ }
34
+ exports.PageAPI = PageAPI;
@@ -0,0 +1,4 @@
1
+ export interface StorefrontAPIOptions extends Record<string, any> {
2
+ shop: string;
3
+ accessToken: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -13,6 +13,7 @@
13
13
  "dotenv": "^16.3.1"
14
14
  },
15
15
  "dependencies": {
16
- "@shopify/admin-api-client": "^0.1.0"
16
+ "@shopify/admin-api-client": "^0.1.0",
17
+ "@shopify/storefront-api-client": "^0.1.1"
17
18
  }
18
19
  }