@pintahub/shopify-api 2.1.9 → 2.2.1
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/admin/files/UpdateFile.d.ts +13 -0
- package/dist/classes/admin/files/UpdateFile.js +48 -0
- package/dist/classes/admin/files/index.d.ts +3 -0
- package/dist/classes/admin/files/index.js +6 -0
- package/dist/classes/admin/products-v2/GetProductOptions.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface UpdateFileInput extends Record<string, any> {
|
|
4
|
+
id: string;
|
|
5
|
+
referencesToAdd?: string[];
|
|
6
|
+
referencesToRemove?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface UpdateFileOutput extends Record<string, any> {
|
|
9
|
+
id: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class UpdateFile extends ActionBuilder<AdminApiClient, UpdateFileInput, UpdateFileOutput> {
|
|
12
|
+
run(args: UpdateFileInput): Promise<UpdateFileOutput>;
|
|
13
|
+
}
|
|
@@ -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.UpdateFile = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class UpdateFile extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const query = `
|
|
19
|
+
mutation FileUpdate($input: [FileUpdateInput!]!) {
|
|
20
|
+
fileUpdate(files: $input) {
|
|
21
|
+
userErrors {
|
|
22
|
+
code
|
|
23
|
+
field
|
|
24
|
+
message
|
|
25
|
+
}
|
|
26
|
+
files {
|
|
27
|
+
id
|
|
28
|
+
alt
|
|
29
|
+
createdAt
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const { data, errors } = yield this.client.request(query, {
|
|
35
|
+
variables: {
|
|
36
|
+
input: args
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
40
|
+
const { fileUpdate } = Object.assign({}, data);
|
|
41
|
+
const { files } = Object.assign({}, fileUpdate);
|
|
42
|
+
const arr = Array.isArray(files) ? files : [];
|
|
43
|
+
const [file] = arr;
|
|
44
|
+
return Object.assign({}, file);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.UpdateFile = UpdateFile;
|
|
@@ -4,10 +4,12 @@ import { GetImageInput, GetImageOutput } from "./GetImage";
|
|
|
4
4
|
import { SearchImagesInput, SearchImagesOutput } from "./SearchImages";
|
|
5
5
|
import { DeleteFileInput, DeleteFileOutput } from "./DeleteFile";
|
|
6
6
|
import { GetVideoInput, GetVideoOutput } from "./GetVideo";
|
|
7
|
+
import { UpdateFileInput, UpdateFileOutput } from "./UpdateFile";
|
|
7
8
|
export interface AdminFileAPIInterface {
|
|
8
9
|
searchImages(args: SearchImagesInput): Promise<SearchImagesOutput>;
|
|
9
10
|
getImage(args: GetImageInput): Promise<GetImageOutput>;
|
|
10
11
|
getVideo(args: GetVideoInput): Promise<GetVideoOutput>;
|
|
12
|
+
update(args: UpdateFileInput): Promise<UpdateFileOutput>;
|
|
11
13
|
delete(args: DeleteFileInput): Promise<DeleteFileOutput>;
|
|
12
14
|
}
|
|
13
15
|
export declare class AdminFileAPI extends APIBase<AdminApiClient> implements AdminFileAPIInterface {
|
|
@@ -15,5 +17,6 @@ export declare class AdminFileAPI extends APIBase<AdminApiClient> implements Adm
|
|
|
15
17
|
searchImages(args?: SearchImagesInput): Promise<SearchImagesOutput>;
|
|
16
18
|
getImage(args?: GetImageInput): Promise<GetImageOutput>;
|
|
17
19
|
getVideo(args?: GetVideoInput): Promise<GetVideoOutput>;
|
|
20
|
+
update(args?: UpdateFileInput): Promise<UpdateFileOutput>;
|
|
18
21
|
delete(args?: DeleteFileInput): Promise<DeleteFileOutput>;
|
|
19
22
|
}
|
|
@@ -15,6 +15,7 @@ const GetImage_1 = require("./GetImage");
|
|
|
15
15
|
const SearchImages_1 = require("./SearchImages");
|
|
16
16
|
const DeleteFile_1 = require("./DeleteFile");
|
|
17
17
|
const GetVideo_1 = require("./GetVideo");
|
|
18
|
+
const UpdateFile_1 = require("./UpdateFile");
|
|
18
19
|
class AdminFileAPI extends APIBase_1.APIBase {
|
|
19
20
|
_runAction(Action, args) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -37,6 +38,11 @@ class AdminFileAPI extends APIBase_1.APIBase {
|
|
|
37
38
|
return this._runAction(GetVideo_1.GetVideo, args);
|
|
38
39
|
});
|
|
39
40
|
}
|
|
41
|
+
update(args) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
return this._runAction(UpdateFile_1.UpdateFile, args);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
40
46
|
delete(args) {
|
|
41
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
48
|
return this._runAction(DeleteFile_1.DeleteFile, args);
|
|
@@ -44,8 +44,9 @@ class GetProductOptions extends ActionBuilder_1.ActionBuilder {
|
|
|
44
44
|
yield (0, handleErrors_1.handleErrors)(errors);
|
|
45
45
|
const { product } = Object.assign({}, data);
|
|
46
46
|
const { options } = Object.assign({}, product);
|
|
47
|
+
const arr = Array.isArray(options) ? options : [];
|
|
47
48
|
return {
|
|
48
|
-
options
|
|
49
|
+
options: arr
|
|
49
50
|
};
|
|
50
51
|
});
|
|
51
52
|
}
|