@pintahub/shopify-api 2.2.7 → 2.2.8
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.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
|
|
2
|
+
import { ActionBuilder } from "../../ActionBuilder";
|
|
3
|
+
export interface CreateProductInput extends Record<string, any> {
|
|
4
|
+
title: string;
|
|
5
|
+
descriptionHtml?: string;
|
|
6
|
+
status?: string;
|
|
7
|
+
tags?: string | Array<string>;
|
|
8
|
+
productType?: string;
|
|
9
|
+
options?: Array<string>;
|
|
10
|
+
variants?: Array<Record<string, any>>;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateProductOutput extends Record<string, any> {
|
|
13
|
+
}
|
|
14
|
+
export declare class CreateProduct extends ActionBuilder<AdminApiClient, CreateProductInput, CreateProductOutput> {
|
|
15
|
+
run(args: CreateProductInput): Promise<CreateProductOutput>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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.CreateProduct = void 0;
|
|
13
|
+
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
|
+
class CreateProduct extends ActionBuilder_1.ActionBuilder {
|
|
16
|
+
run(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const query = `
|
|
19
|
+
mutation productCreate($input: ProductInput!) {
|
|
20
|
+
productCreate(input: $input) {
|
|
21
|
+
product {
|
|
22
|
+
id
|
|
23
|
+
title
|
|
24
|
+
handle
|
|
25
|
+
status
|
|
26
|
+
productType
|
|
27
|
+
vendor
|
|
28
|
+
}
|
|
29
|
+
userErrors {
|
|
30
|
+
field
|
|
31
|
+
message
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
const result = yield this.client.request(query, {
|
|
37
|
+
variables: {
|
|
38
|
+
input: args
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const { data, errors } = Object.assign({}, result);
|
|
42
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
43
|
+
const { productCreate } = data;
|
|
44
|
+
const { product } = Object.assign({}, productCreate);
|
|
45
|
+
return Object.assign({}, product);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.CreateProduct = CreateProduct;
|
|
@@ -10,9 +10,11 @@ import { DeleteProductInput, DeleteProductOutput } from "./DeleteProduct";
|
|
|
10
10
|
import { UpdateProductOptionInput, UpdateProductOptionOutput } from "./UpdateProductOption";
|
|
11
11
|
import { GetProductOptionsInput, GetProductOptionsOutput } from "./GetProductOptions";
|
|
12
12
|
import { ReorderMediaInput, ReorderMediaOutput } from "./ReorderMedia";
|
|
13
|
+
import { CreateProductInput, CreateProductOutput } from "./CreateProduct";
|
|
13
14
|
export interface AdminProductsAPIInterface {
|
|
14
15
|
search(args: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
15
16
|
get(args: GetProductInput): Promise<GetProductOutput>;
|
|
17
|
+
create(args: CreateProductInput): Promise<CreateProductOutput>;
|
|
16
18
|
getOptions(args: GetProductOptionsInput): Promise<GetProductOptionsOutput>;
|
|
17
19
|
update(args: UpdateProductInput): Promise<UpdateProductOutput>;
|
|
18
20
|
delete(args: DeleteProductInput): Promise<DeleteProductOutput>;
|
|
@@ -26,6 +28,7 @@ export declare class AdminProductsAPI extends APIBase<AdminApiClient> implements
|
|
|
26
28
|
private _runAction;
|
|
27
29
|
search(args: SearchProductsInput): Promise<SearchProductsOutput>;
|
|
28
30
|
get(args: GetProductInput): Promise<GetProductOutput>;
|
|
31
|
+
create(args: CreateProductInput): Promise<CreateProductOutput>;
|
|
29
32
|
getOptions(args: GetProductOptionsInput): Promise<GetProductOptionsOutput>;
|
|
30
33
|
update(args: UpdateProductInput): Promise<UpdateProductOutput>;
|
|
31
34
|
delete(args: DeleteProductInput): Promise<DeleteProductOutput>;
|
|
@@ -21,6 +21,7 @@ const DeleteProduct_1 = require("./DeleteProduct");
|
|
|
21
21
|
const UpdateProductOption_1 = require("./UpdateProductOption");
|
|
22
22
|
const GetProductOptions_1 = require("./GetProductOptions");
|
|
23
23
|
const ReorderMedia_1 = require("./ReorderMedia");
|
|
24
|
+
const CreateProduct_1 = require("../products/CreateProduct");
|
|
24
25
|
class AdminProductsAPI extends APIBase_1.APIBase {
|
|
25
26
|
_runAction(Action, args) {
|
|
26
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -38,6 +39,11 @@ class AdminProductsAPI extends APIBase_1.APIBase {
|
|
|
38
39
|
return this._runAction(GetProduct_1.GetProduct, args);
|
|
39
40
|
});
|
|
40
41
|
}
|
|
42
|
+
create(args) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return this._runAction(CreateProduct_1.CreateProduct, args);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
41
47
|
getOptions(args) {
|
|
42
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
49
|
return this._runAction(GetProductOptions_1.GetProductOptions, args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pintahub/shopify-api",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@shopify/admin-api-client": "^1.0.0",
|
|
19
19
|
"@shopify/storefront-api-client": "^1.0.0",
|
|
20
|
-
"axios": "^1.
|
|
20
|
+
"axios": "^1.11.0",
|
|
21
21
|
"p-map": "^4"
|
|
22
22
|
}
|
|
23
23
|
}
|