@pintahub/shopify-api 2.2.2 → 2.2.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.
@@ -1,5 +1,4 @@
1
1
  import { AdminProductAPIInterface } from "./admin/products";
2
- import { AdminCollectionAPIInterface } from "./admin/collections";
3
2
  import { AdminMetaObjectAPIInterface } from "./admin/metaobjects";
4
3
  import { AdminOrderAPIInterface } from "./admin/orders";
5
4
  import { APIOptions } from "../interfaces/APIOptions";
@@ -7,6 +6,7 @@ import { AdminFileAPIInterface } from "./admin/files";
7
6
  import { AdminMenuAPIInterface } from "./admin/menus";
8
7
  import { AdminProductsAPIInterface } from "./admin/products-v2";
9
8
  import { AdminCustomersAPIInterface } from "./admin/customers";
9
+ import { AdminCollectionAPIInterface } from "./admin/collections-v2";
10
10
  export declare class AdminAPI {
11
11
  private readonly options;
12
12
  private readonly client?;
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  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
- const collections_1 = require("./admin/collections");
7
6
  const metaobjects_1 = require("./admin/metaobjects");
8
7
  const orders_1 = require("./admin/orders");
9
8
  const files_1 = require("./admin/files");
10
9
  const menus_1 = require("./admin/menus");
11
10
  const products_v2_1 = require("./admin/products-v2");
12
11
  const customers_1 = require("./admin/customers");
12
+ const collections_v2_1 = require("./admin/collections-v2");
13
13
  class AdminAPI {
14
14
  constructor(options) {
15
15
  const defaultOptions = {
@@ -25,7 +25,7 @@ class AdminAPI {
25
25
  this.menus = new menus_1.AdminMenuAPI(this._createClient('2024-10'));
26
26
  this.products = new products_v2_1.AdminProductsAPI(this._createClient('2024-10'));
27
27
  this.customers = new customers_1.AdminCustomersAPI(this._createClient('2024-10'));
28
- this.collections = new collections_1.AdminCollectionAPI(this._createClient('2024-10'));
28
+ this.collections = new collections_v2_1.AdminCollectionAPI(this._createClient('2024-10'));
29
29
  this.files = new files_1.AdminFileAPI(this._createClient('2024-10'));
30
30
  this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this._createClient('2024-10'));
31
31
  this.orders = new orders_1.AdminOrderAPI(this._createClient('2024-10'));
@@ -0,0 +1,13 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ export interface UpdateCollectionInput extends Record<string, any> {
4
+ id: string;
5
+ handle?: string;
6
+ title?: string;
7
+ descriptionHtml?: string;
8
+ }
9
+ export interface UpdateCollectionOutput extends Record<string, any> {
10
+ }
11
+ export declare class UpdateCollection extends ActionBuilder<AdminApiClient, UpdateCollectionInput, UpdateCollectionOutput> {
12
+ run(args: UpdateCollectionInput): Promise<UpdateCollectionOutput>;
13
+ }
@@ -0,0 +1,61 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.UpdateCollection = void 0;
24
+ const ActionBuilder_1 = require("../../ActionBuilder");
25
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
26
+ const handleErrors_1 = require("../../../utils/handleErrors");
27
+ class UpdateCollection extends ActionBuilder_1.ActionBuilder {
28
+ run(args) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const query = `
31
+ mutation collectionUpdate($input: CollectionInput!) {
32
+ collectionUpdate(input: $input) {
33
+ collection {
34
+ id
35
+ title
36
+ handle
37
+ }
38
+ userErrors {
39
+ field
40
+ message
41
+ }
42
+ }
43
+ }
44
+ `;
45
+ const _a = Object.assign({}, args), { id } = _a, rest = __rest(_a, ["id"]);
46
+ const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Collection');
47
+ const newArgs = Object.assign(Object.assign({}, rest), { id: globalId });
48
+ const result = yield this.client.request(query, {
49
+ variables: {
50
+ input: newArgs
51
+ }
52
+ });
53
+ const { data, errors } = Object.assign({}, result);
54
+ yield (0, handleErrors_1.handleErrors)(errors);
55
+ const { collectionUpdate } = Object.assign({}, data);
56
+ const { collection } = Object.assign({}, collectionUpdate);
57
+ return Object.assign({}, collection);
58
+ });
59
+ }
60
+ }
61
+ exports.UpdateCollection = UpdateCollection;
@@ -2,12 +2,15 @@ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types"
2
2
  import { APIBase } from "../../APIBase";
3
3
  import { SearchCollectionsInput, SearchCollectionsOutput } from "./SearchCollections";
4
4
  import { GetCollectionInput, GetCollectionOutput } from "./GetCollection";
5
+ import { UpdateCollectionInput, UpdateCollectionOutput } from "./UpdateCollection";
5
6
  export interface AdminCollectionAPIInterface {
6
7
  get(args?: GetCollectionInput): Promise<GetCollectionOutput>;
7
8
  search(args?: SearchCollectionsInput): Promise<SearchCollectionsOutput>;
9
+ update(args?: UpdateCollectionInput): Promise<UpdateCollectionOutput>;
8
10
  }
9
11
  export declare class AdminCollectionAPI extends APIBase<AdminApiClient> implements AdminCollectionAPIInterface {
10
12
  private _runAction;
11
13
  get(args: GetCollectionInput): Promise<GetCollectionOutput>;
12
14
  search(args?: SearchCollectionsInput): Promise<SearchCollectionsOutput>;
15
+ update(args?: UpdateCollectionInput): Promise<UpdateCollectionOutput>;
13
16
  }
@@ -13,6 +13,7 @@ exports.AdminCollectionAPI = void 0;
13
13
  const APIBase_1 = require("../../APIBase");
14
14
  const SearchCollections_1 = require("./SearchCollections");
15
15
  const GetCollection_1 = require("./GetCollection");
16
+ const UpdateCollection_1 = require("./UpdateCollection");
16
17
  class AdminCollectionAPI extends APIBase_1.APIBase {
17
18
  _runAction(Action, args) {
18
19
  return __awaiter(this, void 0, void 0, function* () {
@@ -30,5 +31,10 @@ class AdminCollectionAPI extends APIBase_1.APIBase {
30
31
  return this._runAction(SearchCollections_1.SearchCollections, args);
31
32
  });
32
33
  }
34
+ update(args) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ return this._runAction(UpdateCollection_1.UpdateCollection, args);
37
+ });
38
+ }
33
39
  }
34
40
  exports.AdminCollectionAPI = AdminCollectionAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",