@pintahub/shopify-api 2.5.8 → 2.6.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.
@@ -0,0 +1,10 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(git add:*)",
5
+ "Bash(git reset:*)",
6
+ "Bash(git commit:*)",
7
+ "Bash(git push:*)"
8
+ ]
9
+ }
10
+ }
@@ -0,0 +1,13 @@
1
+ import { AdminApiClient } from "@shopify/admin-api-client/dist/ts/graphql/types";
2
+ import { ActionBuilder } from "../../ActionBuilder";
3
+ import { OptionCreateInput } from "../../../input/OptionCreateInput";
4
+ export interface CreateProductOptionInput extends Record<string, any> {
5
+ productId: string;
6
+ options: OptionCreateInput[];
7
+ variantStrategy?: 'LEAVE_AS_IS' | 'CREATE';
8
+ }
9
+ export interface CreateProductOptionOutput extends Record<string, any> {
10
+ }
11
+ export declare class CreateProductOption extends ActionBuilder<AdminApiClient, CreateProductOptionInput, CreateProductOptionOutput> {
12
+ run(args: CreateProductOptionInput): Promise<CreateProductOptionOutput>;
13
+ }
@@ -0,0 +1,63 @@
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.CreateProductOption = void 0;
13
+ const ActionBuilder_1 = require("../../ActionBuilder");
14
+ const getGlobalID_1 = require("../../../utils/getGlobalID");
15
+ const handleErrors_1 = require("../../../utils/handleErrors");
16
+ class CreateProductOption extends ActionBuilder_1.ActionBuilder {
17
+ run(args) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const query = `
20
+ mutation productOptionsCreate($productId: ID!, $options: [OptionCreateInput!]!, $variantStrategy: ProductOptionCreateVariantStrategy) {
21
+ productOptionsCreate(productId: $productId, options: $options, variantStrategy: $variantStrategy) {
22
+ userErrors {
23
+ field
24
+ message
25
+ code
26
+ }
27
+ product {
28
+ id
29
+ options {
30
+ id
31
+ name
32
+ values
33
+ position
34
+ }
35
+ variants(first: 250) {
36
+ nodes {
37
+ id
38
+ title
39
+ selectedOptions {
40
+ name
41
+ value
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ `;
49
+ const { productId } = Object.assign({}, args);
50
+ const globalId = (0, getGlobalID_1.getGlobalID)(productId);
51
+ const newArgs = Object.assign(Object.assign({}, args), { productId: globalId });
52
+ const result = yield this.client.request(query, {
53
+ variables: newArgs
54
+ });
55
+ const { data, errors } = Object.assign({}, result);
56
+ yield (0, handleErrors_1.handleErrors)(errors);
57
+ const { productOptionsCreate } = Object.assign({}, data);
58
+ const { product: updatedProduct } = Object.assign({}, productOptionsCreate);
59
+ return Object.assign({}, updatedProduct);
60
+ });
61
+ }
62
+ }
63
+ exports.CreateProductOption = CreateProductOption;
@@ -25,6 +25,9 @@ class GetVariants extends ActionBuilder_1.ActionBuilder {
25
25
  variants(first: 250) {
26
26
  nodes {
27
27
  id
28
+ title
29
+ price
30
+ compareAtPrice
28
31
  availableForSale
29
32
  selectedOptions {
30
33
  name
@@ -15,6 +15,7 @@ import { PublishProductInput, PublishProductOutput } from "./PublishProduct";
15
15
  import { NextCreateProductInput, NextCreateProductOutput } from "./NextCreateProduct";
16
16
  import { GetVariantsInput, GetVariantsOutput } from "./GetVariants";
17
17
  import { AppendMediaInput, AppendMediaOutput } from "./AppendMedia";
18
+ import { CreateProductOptionInput, CreateProductOptionOutput } from "./CreateProductOption";
18
19
  export interface AdminProductsAPIInterface {
19
20
  search(args: SearchProductsInput): Promise<SearchProductsOutput>;
20
21
  get(args: GetProductInput): Promise<GetProductOutput>;
@@ -28,6 +29,7 @@ export interface AdminProductsAPIInterface {
28
29
  getMedia(args: GetProductMediaInput): Promise<GetProductMediaOutput>;
29
30
  deleteMedia(args: DeleteProductMediaInput): Promise<DeleteProductMediaOutput>;
30
31
  updateOption(args: UpdateProductOptionInput): Promise<UpdateProductOptionOutput>;
32
+ createOption(args: CreateProductOptionInput): Promise<CreateProductOptionOutput>;
31
33
  reorderMedia(args: ReorderMediaInput): Promise<ReorderMediaOutput>;
32
34
  publish(args: PublishProductInput): Promise<PublishProductOutput>;
33
35
  appendMedia(args: AppendMediaInput): Promise<AppendMediaOutput>;
@@ -46,6 +48,7 @@ export declare class AdminProductsAPI extends APIBase<AdminApiClient> implements
46
48
  getMedia(args: GetProductMediaInput): Promise<GetProductMediaOutput>;
47
49
  deleteMedia(args: DeleteProductMediaInput): Promise<DeleteProductMediaOutput>;
48
50
  updateOption(args: UpdateProductOptionInput): Promise<UpdateProductOptionOutput>;
51
+ createOption(args: CreateProductOptionInput): Promise<CreateProductOptionOutput>;
49
52
  reorderMedia(args: ReorderMediaInput): Promise<ReorderMediaOutput>;
50
53
  publish(args: PublishProductInput): Promise<PublishProductOutput>;
51
54
  appendMedia(args: AppendMediaInput): Promise<AppendMediaOutput>;
@@ -26,6 +26,7 @@ const PublishProduct_1 = require("./PublishProduct");
26
26
  const NextCreateProduct_1 = require("./NextCreateProduct");
27
27
  const GetVariants_1 = require("./GetVariants");
28
28
  const AppendMedia_1 = require("./AppendMedia");
29
+ const CreateProductOption_1 = require("./CreateProductOption");
29
30
  class AdminProductsAPI extends APIBase_1.APIBase {
30
31
  _runAction(Action, args) {
31
32
  return __awaiter(this, void 0, void 0, function* () {
@@ -93,6 +94,11 @@ class AdminProductsAPI extends APIBase_1.APIBase {
93
94
  return this._runAction(UpdateProductOption_1.UpdateProductOption, args);
94
95
  });
95
96
  }
97
+ createOption(args) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ return this._runAction(CreateProductOption_1.CreateProductOption, args);
100
+ });
101
+ }
96
102
  reorderMedia(args) {
97
103
  return __awaiter(this, void 0, void 0, function* () {
98
104
  return this._runAction(ReorderMedia_1.ReorderMedia, args);
@@ -0,0 +1,13 @@
1
+ export interface OptionValueCreateInput extends Record<string, any> {
2
+ name: string;
3
+ linkedMetafieldValue?: string;
4
+ }
5
+ export interface OptionCreateInput extends Record<string, any> {
6
+ name: string;
7
+ position?: number;
8
+ values: Array<OptionValueCreateInput>;
9
+ linkedMetafield?: {
10
+ namespace: string;
11
+ key: string;
12
+ };
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@pintahub/shopify-api",
3
- "version": "2.5.8",
3
+ "version": "2.6.0",
4
4
  "description": "",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
- "scripts": {},
7
+ "scripts": {
8
+ "dev": "nodemon"
9
+ },
8
10
  "keywords": [],
9
11
  "author": "",
10
12
  "license": "ISC",
@@ -12,7 +14,8 @@
12
14
  "@types/bluebird": "^3.5.42",
13
15
  "@types/node": "^20",
14
16
  "bluebird": "^3.7.2",
15
- "dotenv": "^16.3.1"
17
+ "dotenv": "^16.3.1",
18
+ "typescript": "^5"
16
19
  },
17
20
  "dependencies": {
18
21
  "@shopify/admin-api-client": "^1.0.0",