@pintahub/shopify-api 1.9.5 → 1.9.7
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.
- package/dist/classes/AdminAPI.d.ts +1 -1
- package/dist/classes/AdminAPI.js +1 -1
- package/dist/classes/admin/collections/GetCollection.js +12 -2
- package/dist/classes/admin/collections/SearchCollections.js +2 -0
- package/dist/classes/admin/collections-v2/GetCollection.d.ts +10 -0
- package/dist/classes/admin/collections-v2/GetCollection.js +51 -0
- package/dist/classes/admin/collections-v2/SearchCollections.d.ts +11 -0
- package/dist/classes/admin/collections-v2/SearchCollections.js +41 -0
- package/dist/classes/admin/collections-v2/index.d.ts +13 -0
- package/dist/classes/admin/collections-v2/index.js +34 -0
- package/package.json +1 -1
|
@@ -11,13 +11,13 @@ export declare class AdminAPI {
|
|
|
11
11
|
private readonly options;
|
|
12
12
|
private readonly client;
|
|
13
13
|
readonly product: AdminProductAPIInterface;
|
|
14
|
-
readonly collection: AdminCollectionAPIInterface;
|
|
15
14
|
readonly metaobject: AdminMetaObjectAPIInterface;
|
|
16
15
|
readonly order: AdminOrderAPIInterface;
|
|
17
16
|
readonly files: AdminFileAPIInterface;
|
|
18
17
|
readonly menus: AdminMenuAPIInterface;
|
|
19
18
|
readonly products: AdminProductsAPIInterface;
|
|
20
19
|
readonly customers: AdminCustomersAPIInterface;
|
|
20
|
+
readonly collections: AdminCollectionAPIInterface;
|
|
21
21
|
constructor(options: APIOptions);
|
|
22
22
|
private _createClient;
|
|
23
23
|
}
|
package/dist/classes/AdminAPI.js
CHANGED
|
@@ -15,13 +15,13 @@ class AdminAPI {
|
|
|
15
15
|
this.options = options;
|
|
16
16
|
this.client = this._createClient();
|
|
17
17
|
this.product = new products_1.AdminProductAPI(this.client);
|
|
18
|
-
this.collection = new collections_1.AdminCollectionAPI(this.client);
|
|
19
18
|
this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this.client);
|
|
20
19
|
this.order = new orders_1.AdminOrderAPI(this.client);
|
|
21
20
|
this.files = new files_1.AdminFileAPI(this.client); //Start migration with plurality
|
|
22
21
|
this.menus = new menus_1.AdminMenuAPI(this._createClient('2024-07'));
|
|
23
22
|
this.products = new products_v2_1.AdminProductsAPI(this._createClient('2024-10'));
|
|
24
23
|
this.customers = new customers_1.AdminCustomersAPI(this._createClient('2024-10'));
|
|
24
|
+
this.collections = new collections_1.AdminCollectionAPI(this._createClient('2024-10'));
|
|
25
25
|
}
|
|
26
26
|
_createClient(apiVersion = '2023-10') {
|
|
27
27
|
const { shop, accessToken } = this.options;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.GetCollection = void 0;
|
|
13
13
|
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
14
|
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
16
|
class GetCollection extends ActionBuilder_1.ActionBuilder {
|
|
16
17
|
run(args) {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -22,8 +23,12 @@ class GetCollection extends ActionBuilder_1.ActionBuilder {
|
|
|
22
23
|
title
|
|
23
24
|
updatedAt
|
|
24
25
|
id
|
|
26
|
+
sortOrder
|
|
27
|
+
description
|
|
25
28
|
descriptionHtml
|
|
26
|
-
productsCount
|
|
29
|
+
productsCount {
|
|
30
|
+
count
|
|
31
|
+
}
|
|
27
32
|
image {
|
|
28
33
|
id
|
|
29
34
|
url
|
|
@@ -31,16 +36,21 @@ class GetCollection extends ActionBuilder_1.ActionBuilder {
|
|
|
31
36
|
height
|
|
32
37
|
width
|
|
33
38
|
}
|
|
39
|
+
seo {
|
|
40
|
+
description
|
|
41
|
+
title
|
|
42
|
+
}
|
|
34
43
|
}
|
|
35
44
|
}
|
|
36
45
|
`;
|
|
37
46
|
const { id } = args;
|
|
38
47
|
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Collection');
|
|
39
|
-
const { data } = yield this.client.request(query, {
|
|
48
|
+
const { data, errors } = yield this.client.request(query, {
|
|
40
49
|
variables: {
|
|
41
50
|
id: globalId
|
|
42
51
|
}
|
|
43
52
|
});
|
|
53
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
44
54
|
const { collection } = Object.assign({}, data);
|
|
45
55
|
return Object.assign({}, collection);
|
|
46
56
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface GetCollectionInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetCollectionOutput extends Record<string, any> {
|
|
7
|
+
}
|
|
8
|
+
export declare class GetCollection extends ActionBuilder<AdminApiClient, GetCollectionInput, GetCollectionOutput> {
|
|
9
|
+
run(args: GetCollectionInput): Promise<GetCollectionOutput>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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.GetCollection = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
16
|
+
class GetCollection extends ActionBuilder_1.ActionBuilder {
|
|
17
|
+
run(args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const query = `
|
|
20
|
+
query ($id: ID!) {
|
|
21
|
+
collection(id: $id) {
|
|
22
|
+
handle
|
|
23
|
+
title
|
|
24
|
+
updatedAt
|
|
25
|
+
id
|
|
26
|
+
descriptionHtml
|
|
27
|
+
productsCount
|
|
28
|
+
image {
|
|
29
|
+
id
|
|
30
|
+
url
|
|
31
|
+
altText
|
|
32
|
+
height
|
|
33
|
+
width
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
const { id } = args;
|
|
39
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Collection');
|
|
40
|
+
const { data, errors } = yield this.client.request(query, {
|
|
41
|
+
variables: {
|
|
42
|
+
id: globalId
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
46
|
+
const { collection } = Object.assign({}, data);
|
|
47
|
+
return Object.assign({}, collection);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.GetCollection = GetCollection;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface SearchCollectionsInput extends Record<string, any> {
|
|
4
|
+
}
|
|
5
|
+
export interface SearchCollectionsOutput extends Record<string, any> {
|
|
6
|
+
items: any[];
|
|
7
|
+
pageInfo: any;
|
|
8
|
+
}
|
|
9
|
+
export declare class SearchCollections extends ActionBuilder<AdminApiClient, SearchCollectionsInput, SearchCollectionsOutput> {
|
|
10
|
+
run(args?: SearchCollectionsInput): Promise<SearchCollectionsOutput>;
|
|
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.SearchCollections = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
class SearchCollections extends ActionBuilder_1.ActionBuilder {
|
|
15
|
+
run(args) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const query = `
|
|
18
|
+
{
|
|
19
|
+
collections(first: 100, reverse: false, 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 { collections } = Object.assign({}, data);
|
|
32
|
+
const { nodes, pageInfo } = Object.assign({}, collections);
|
|
33
|
+
const items = Array.isArray(nodes) ? nodes : [];
|
|
34
|
+
return {
|
|
35
|
+
items,
|
|
36
|
+
pageInfo
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.SearchCollections = SearchCollections;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { APIBase } from "../../APIBase";
|
|
3
|
+
import { SearchCollectionsInput, SearchCollectionsOutput } from "./SearchCollections";
|
|
4
|
+
import { GetCollectionInput, GetCollectionOutput } from "./GetCollection";
|
|
5
|
+
export interface AdminCollectionAPIInterface {
|
|
6
|
+
get(args?: GetCollectionInput): Promise<GetCollectionOutput>;
|
|
7
|
+
search(args?: SearchCollectionsInput): Promise<SearchCollectionsOutput>;
|
|
8
|
+
}
|
|
9
|
+
export declare class AdminCollectionAPI extends APIBase<AdminApiClient> implements AdminCollectionAPIInterface {
|
|
10
|
+
private _runAction;
|
|
11
|
+
get(args: GetCollectionInput): Promise<GetCollectionOutput>;
|
|
12
|
+
search(args?: SearchCollectionsInput): Promise<SearchCollectionsOutput>;
|
|
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.AdminCollectionAPI = void 0;
|
|
13
|
+
const APIBase_1 = require("../../APIBase");
|
|
14
|
+
const SearchCollections_1 = require("./SearchCollections");
|
|
15
|
+
const GetCollection_1 = require("./GetCollection");
|
|
16
|
+
class AdminCollectionAPI 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(GetCollection_1.GetCollection, args);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
search(args) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return this._runAction(SearchCollections_1.SearchCollections, args);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.AdminCollectionAPI = AdminCollectionAPI;
|