@pintahub/shopify-api 2.0.8 → 2.1.0
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.js +2 -2
- package/dist/classes/admin/files/DeleteFile.d.ts +11 -0
- package/dist/classes/admin/files/DeleteFile.js +46 -0
- package/dist/classes/admin/files/GetVideo.d.ts +22 -0
- package/dist/classes/admin/files/GetVideo.js +58 -0
- package/dist/classes/admin/files/index.d.ts +6 -0
- package/dist/classes/admin/files/index.js +12 -0
- package/package.json +1 -1
package/dist/classes/AdminAPI.js
CHANGED
|
@@ -22,12 +22,12 @@ class AdminAPI {
|
|
|
22
22
|
this.product = new products_1.AdminProductAPI(this.client);
|
|
23
23
|
this.metaobject = new metaobjects_1.AdminMetaObjectAPI(this.client);
|
|
24
24
|
this.order = new orders_1.AdminOrderAPI(this.client);
|
|
25
|
-
this.files = new files_1.AdminFileAPI(this.client); //Start migration with plurality
|
|
26
25
|
}
|
|
27
|
-
this.menus = new menus_1.AdminMenuAPI(this._createClient('2024-
|
|
26
|
+
this.menus = new menus_1.AdminMenuAPI(this._createClient('2024-10'));
|
|
28
27
|
this.products = new products_v2_1.AdminProductsAPI(this._createClient('2024-10'));
|
|
29
28
|
this.customers = new customers_1.AdminCustomersAPI(this._createClient('2024-10'));
|
|
30
29
|
this.collections = new collections_1.AdminCollectionAPI(this._createClient('2024-10'));
|
|
30
|
+
this.files = new files_1.AdminFileAPI(this._createClient('2024-10'));
|
|
31
31
|
}
|
|
32
32
|
_createClient(apiVersion = '2023-10') {
|
|
33
33
|
const { shop, accessToken } = this.options;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface DeleteFileInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DeleteFileOutput extends Record<string, any> {
|
|
7
|
+
ids: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare class DeleteFile extends ActionBuilder<AdminApiClient, DeleteFileInput, DeleteFileOutput> {
|
|
10
|
+
run(args: DeleteFileInput): Promise<DeleteFileOutput>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.DeleteFile = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class DeleteFile extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const { id } = args;
|
|
19
|
+
const query = `
|
|
20
|
+
mutation fileDelete($input: [ID!]!) {
|
|
21
|
+
fileDelete(fileIds: $input) {
|
|
22
|
+
deletedFileIds
|
|
23
|
+
userErrors {
|
|
24
|
+
code
|
|
25
|
+
field
|
|
26
|
+
message
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const { data, errors } = yield this.client.request(query, {
|
|
32
|
+
variables: {
|
|
33
|
+
input: [id]
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
37
|
+
const { fileDelete } = Object.assign({}, data);
|
|
38
|
+
const { deletedFileIds } = Object.assign({}, fileDelete);
|
|
39
|
+
const ids = Array.isArray(deletedFileIds) ? deletedFileIds : [];
|
|
40
|
+
return {
|
|
41
|
+
ids
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.DeleteFile = DeleteFile;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface GetVideoInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
}
|
|
6
|
+
export interface GetVideoOutput extends Record<string, any> {
|
|
7
|
+
id: string;
|
|
8
|
+
filename: string;
|
|
9
|
+
mediaContentType: string;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
originalSource: {
|
|
13
|
+
url: string;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
fileSize: number;
|
|
17
|
+
mimeType: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare class GetVideo extends ActionBuilder<AdminApiClient, GetVideoInput, GetVideoOutput> {
|
|
21
|
+
run(args: GetVideoInput): Promise<GetVideoOutput>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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.GetVideo = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
16
|
+
class GetVideo extends ActionBuilder_1.ActionBuilder {
|
|
17
|
+
run(args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { id } = args;
|
|
20
|
+
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'Video');
|
|
21
|
+
const query = `
|
|
22
|
+
query getVideo($id: ID!) {
|
|
23
|
+
node(id: $id) {
|
|
24
|
+
id
|
|
25
|
+
... on Video {
|
|
26
|
+
id
|
|
27
|
+
filename
|
|
28
|
+
fileStatus
|
|
29
|
+
alt
|
|
30
|
+
createdAt
|
|
31
|
+
duration
|
|
32
|
+
mediaContentType
|
|
33
|
+
status
|
|
34
|
+
updatedAt
|
|
35
|
+
originalSource {
|
|
36
|
+
url
|
|
37
|
+
fileSize
|
|
38
|
+
format
|
|
39
|
+
height
|
|
40
|
+
width
|
|
41
|
+
mimeType
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
const { data, errors } = yield this.client.request(query, {
|
|
48
|
+
variables: {
|
|
49
|
+
id: globalId
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
53
|
+
const { node } = Object.assign({}, data);
|
|
54
|
+
return Object.assign({}, node);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.GetVideo = GetVideo;
|
|
@@ -2,12 +2,18 @@ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types"
|
|
|
2
2
|
import { APIBase } from "../../APIBase";
|
|
3
3
|
import { GetImageInput, GetImageOutput } from "./GetImage";
|
|
4
4
|
import { SearchImagesInput, SearchImagesOutput } from "./SearchImages";
|
|
5
|
+
import { DeleteFileInput, DeleteFileOutput } from "./DeleteFile";
|
|
6
|
+
import { GetVideoInput, GetVideoOutput } from "./GetVideo";
|
|
5
7
|
export interface AdminFileAPIInterface {
|
|
6
8
|
searchImages(args: SearchImagesInput): Promise<SearchImagesOutput>;
|
|
7
9
|
getImage(args: GetImageInput): Promise<GetImageOutput>;
|
|
10
|
+
getVideo(args: GetVideoInput): Promise<GetVideoOutput>;
|
|
11
|
+
delete(args: DeleteFileInput): Promise<DeleteFileOutput>;
|
|
8
12
|
}
|
|
9
13
|
export declare class AdminFileAPI extends APIBase<AdminApiClient> implements AdminFileAPIInterface {
|
|
10
14
|
private _runAction;
|
|
11
15
|
searchImages(args?: SearchImagesInput): Promise<SearchImagesOutput>;
|
|
12
16
|
getImage(args?: GetImageInput): Promise<GetImageOutput>;
|
|
17
|
+
getVideo(args?: GetVideoInput): Promise<GetVideoOutput>;
|
|
18
|
+
delete(args?: DeleteFileInput): Promise<DeleteFileOutput>;
|
|
13
19
|
}
|
|
@@ -13,6 +13,8 @@ exports.AdminFileAPI = void 0;
|
|
|
13
13
|
const APIBase_1 = require("../../APIBase");
|
|
14
14
|
const GetImage_1 = require("./GetImage");
|
|
15
15
|
const SearchImages_1 = require("./SearchImages");
|
|
16
|
+
const DeleteFile_1 = require("./DeleteFile");
|
|
17
|
+
const GetVideo_1 = require("./GetVideo");
|
|
16
18
|
class AdminFileAPI extends APIBase_1.APIBase {
|
|
17
19
|
_runAction(Action, args) {
|
|
18
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -30,5 +32,15 @@ class AdminFileAPI extends APIBase_1.APIBase {
|
|
|
30
32
|
return this._runAction(GetImage_1.GetImage, args);
|
|
31
33
|
});
|
|
32
34
|
}
|
|
35
|
+
getVideo(args) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
return this._runAction(GetVideo_1.GetVideo, args);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
delete(args) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
return this._runAction(DeleteFile_1.DeleteFile, args);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
33
45
|
}
|
|
34
46
|
exports.AdminFileAPI = AdminFileAPI;
|