ecomcoder-cli 1.2.12 → 1.3.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/README.md +293 -0
- package/dist/__tests__/test-utils.d.ts +123 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/__tests__/test-utils.js +133 -0
- package/dist/__tests__/test-utils.js.map +1 -0
- package/dist/cli.d.ts +8 -7
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +70 -65
- package/dist/cli.js.map +1 -1
- package/dist/commands/docs/index.d.ts +10 -0
- package/dist/commands/docs/index.d.ts.map +1 -0
- package/dist/commands/docs/index.js +43 -0
- package/dist/commands/docs/index.js.map +1 -0
- package/dist/commands/metafield/index.d.ts +10 -0
- package/dist/commands/metafield/index.d.ts.map +1 -0
- package/dist/commands/metafield/index.js +55 -0
- package/dist/commands/metafield/index.js.map +1 -0
- package/dist/commands/product/__tests__/service.test.d.ts +7 -0
- package/dist/commands/product/__tests__/service.test.d.ts.map +1 -0
- package/dist/commands/product/__tests__/service.test.js +299 -0
- package/dist/commands/product/__tests__/service.test.js.map +1 -0
- package/dist/commands/product/__tests__/update-description.test.d.ts +5 -0
- package/dist/commands/product/__tests__/update-description.test.d.ts.map +1 -0
- package/dist/commands/product/__tests__/update-description.test.js +110 -0
- package/dist/commands/product/__tests__/update-description.test.js.map +1 -0
- package/dist/commands/product/get.d.ts +2 -0
- package/dist/commands/product/get.d.ts.map +1 -0
- package/dist/commands/product/get.js +305 -0
- package/dist/commands/product/get.js.map +1 -0
- package/dist/commands/product/index.d.ts +10 -0
- package/dist/commands/product/index.d.ts.map +1 -0
- package/dist/commands/product/index.js +73 -0
- package/dist/commands/product/index.js.map +1 -0
- package/dist/commands/product/queries.d.ts +32 -0
- package/dist/commands/product/queries.d.ts.map +1 -0
- package/dist/commands/product/queries.js +195 -0
- package/dist/commands/product/queries.js.map +1 -0
- package/dist/commands/product/service.d.ts +51 -0
- package/dist/commands/product/service.d.ts.map +1 -0
- package/dist/commands/product/service.js +237 -0
- package/dist/commands/product/service.js.map +1 -0
- package/dist/commands/product/types.d.ts +165 -0
- package/dist/commands/product/types.d.ts.map +1 -0
- package/dist/commands/product/types.js +6 -0
- package/dist/commands/product/types.js.map +1 -0
- package/dist/commands/product/update-description.d.ts +8 -0
- package/dist/commands/product/update-description.d.ts.map +1 -0
- package/dist/commands/product/update-description.js +86 -0
- package/dist/commands/product/update-description.js.map +1 -0
- package/dist/commands/product/update-price.d.ts +8 -0
- package/dist/commands/product/update-price.d.ts.map +1 -0
- package/dist/commands/product/update-price.js +101 -0
- package/dist/commands/product/update-price.js.map +1 -0
- package/dist/commands/product/update-template.d.ts +8 -0
- package/dist/commands/product/update-template.d.ts.map +1 -0
- package/dist/commands/product/update-template.js +114 -0
- package/dist/commands/product/update-template.js.map +1 -0
- package/dist/commands/product/utils.d.ts +69 -0
- package/dist/commands/product/utils.d.ts.map +1 -0
- package/dist/commands/product/utils.js +180 -0
- package/dist/commands/product/utils.js.map +1 -0
- package/dist/commands/products/index.d.ts +10 -0
- package/dist/commands/products/index.d.ts.map +1 -0
- package/dist/commands/products/index.js +62 -0
- package/dist/commands/products/index.js.map +1 -0
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js +11 -0
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/args-parser.d.ts.map +1 -1
- package/dist/lib/args-parser.js +2 -1
- package/dist/lib/args-parser.js.map +1 -1
- package/dist/lib/command-registry.d.ts +64 -0
- package/dist/lib/command-registry.d.ts.map +1 -0
- package/dist/lib/command-registry.js +76 -0
- package/dist/lib/command-registry.js.map +1 -0
- package/package.json +11 -3
- package/dist/lib/gemini-client.d.ts +0 -6
- package/dist/lib/gemini-client.d.ts.map +0 -1
- package/dist/lib/gemini-client.js +0 -27
- package/dist/lib/gemini-client.js.map +0 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphQL Queries and Mutations for Product Operations
|
|
3
|
+
*
|
|
4
|
+
* Following Single Responsibility Principle - this module only contains GraphQL strings
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Fetch product by ID with complete details
|
|
8
|
+
*/
|
|
9
|
+
export const GET_PRODUCT_BY_ID = `
|
|
10
|
+
query getProduct($id: ID!) {
|
|
11
|
+
product(id: $id) {
|
|
12
|
+
id
|
|
13
|
+
title
|
|
14
|
+
description
|
|
15
|
+
descriptionHtml
|
|
16
|
+
handle
|
|
17
|
+
productType
|
|
18
|
+
vendor
|
|
19
|
+
tags
|
|
20
|
+
status
|
|
21
|
+
templateSuffix
|
|
22
|
+
variants(first: 100) {
|
|
23
|
+
edges {
|
|
24
|
+
node {
|
|
25
|
+
id
|
|
26
|
+
title
|
|
27
|
+
sku
|
|
28
|
+
price
|
|
29
|
+
compareAtPrice
|
|
30
|
+
inventoryQuantity
|
|
31
|
+
availableForSale
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
images(first: 10) {
|
|
36
|
+
edges {
|
|
37
|
+
node {
|
|
38
|
+
id
|
|
39
|
+
url
|
|
40
|
+
altText
|
|
41
|
+
width
|
|
42
|
+
height
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
priceRangeV2 {
|
|
47
|
+
minVariantPrice {
|
|
48
|
+
amount
|
|
49
|
+
currencyCode
|
|
50
|
+
}
|
|
51
|
+
maxVariantPrice {
|
|
52
|
+
amount
|
|
53
|
+
currencyCode
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
/**
|
|
60
|
+
* Search products by title
|
|
61
|
+
*/
|
|
62
|
+
export const SEARCH_PRODUCTS_BY_TITLE = `
|
|
63
|
+
query searchProducts($query: String!, $first: Int!) {
|
|
64
|
+
products(first: $first, query: $query) {
|
|
65
|
+
edges {
|
|
66
|
+
node {
|
|
67
|
+
id
|
|
68
|
+
title
|
|
69
|
+
handle
|
|
70
|
+
status
|
|
71
|
+
productType
|
|
72
|
+
vendor
|
|
73
|
+
priceRangeV2 {
|
|
74
|
+
minVariantPrice {
|
|
75
|
+
amount
|
|
76
|
+
currencyCode
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
/**
|
|
85
|
+
* Fetch product by handle
|
|
86
|
+
*/
|
|
87
|
+
export const GET_PRODUCT_BY_HANDLE = `
|
|
88
|
+
query getProductByHandle($handle: String!) {
|
|
89
|
+
productByHandle(handle: $handle) {
|
|
90
|
+
id
|
|
91
|
+
title
|
|
92
|
+
description
|
|
93
|
+
descriptionHtml
|
|
94
|
+
handle
|
|
95
|
+
productType
|
|
96
|
+
vendor
|
|
97
|
+
tags
|
|
98
|
+
status
|
|
99
|
+
templateSuffix
|
|
100
|
+
variants(first: 100) {
|
|
101
|
+
edges {
|
|
102
|
+
node {
|
|
103
|
+
id
|
|
104
|
+
title
|
|
105
|
+
sku
|
|
106
|
+
price
|
|
107
|
+
compareAtPrice
|
|
108
|
+
inventoryQuantity
|
|
109
|
+
availableForSale
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
images(first: 10) {
|
|
114
|
+
edges {
|
|
115
|
+
node {
|
|
116
|
+
id
|
|
117
|
+
url
|
|
118
|
+
altText
|
|
119
|
+
width
|
|
120
|
+
height
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
priceRangeV2 {
|
|
125
|
+
minVariantPrice {
|
|
126
|
+
amount
|
|
127
|
+
currencyCode
|
|
128
|
+
}
|
|
129
|
+
maxVariantPrice {
|
|
130
|
+
amount
|
|
131
|
+
currencyCode
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
/**
|
|
138
|
+
* Update product fields (description, title, template, etc.)
|
|
139
|
+
*/
|
|
140
|
+
export const UPDATE_PRODUCT = `
|
|
141
|
+
mutation productUpdate($input: ProductInput!) {
|
|
142
|
+
productUpdate(input: $input) {
|
|
143
|
+
product {
|
|
144
|
+
id
|
|
145
|
+
title
|
|
146
|
+
description
|
|
147
|
+
descriptionHtml
|
|
148
|
+
templateSuffix
|
|
149
|
+
}
|
|
150
|
+
userErrors {
|
|
151
|
+
field
|
|
152
|
+
message
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
`;
|
|
157
|
+
/**
|
|
158
|
+
* Update product variant (price, compareAtPrice, inventory, etc.)
|
|
159
|
+
* @deprecated Use PRODUCT_VARIANTS_BULK_UPDATE instead
|
|
160
|
+
*/
|
|
161
|
+
export const UPDATE_VARIANT = `
|
|
162
|
+
mutation productVariantUpdate($input: ProductVariantInput!) {
|
|
163
|
+
productVariantUpdate(input: $input) {
|
|
164
|
+
productVariant {
|
|
165
|
+
id
|
|
166
|
+
price
|
|
167
|
+
compareAtPrice
|
|
168
|
+
}
|
|
169
|
+
userErrors {
|
|
170
|
+
field
|
|
171
|
+
message
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
`;
|
|
176
|
+
/**
|
|
177
|
+
* Bulk update product variants (current API for price updates)
|
|
178
|
+
* Replaces deprecated productVariantUpdate mutation
|
|
179
|
+
*/
|
|
180
|
+
export const PRODUCT_VARIANTS_BULK_UPDATE = `
|
|
181
|
+
mutation productVariantsBulkUpdate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
|
|
182
|
+
productVariantsBulkUpdate(productId: $productId, variants: $variants) {
|
|
183
|
+
productVariants {
|
|
184
|
+
id
|
|
185
|
+
price
|
|
186
|
+
compareAtPrice
|
|
187
|
+
}
|
|
188
|
+
userErrors {
|
|
189
|
+
field
|
|
190
|
+
message
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/commands/product/queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDhC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBvC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDpC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;CAgB7B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;CAc7B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;CAc3C,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Service Layer
|
|
3
|
+
*
|
|
4
|
+
* Following Service Pattern - encapsulates business logic for product operations
|
|
5
|
+
* Follows Dependency Injection - accepts dependencies as parameters
|
|
6
|
+
*/
|
|
7
|
+
import type { ShopifyCredentials } from '../../lib/types.js';
|
|
8
|
+
import type { ShopifyProduct, FormattedProduct, UpdateDescriptionInput, UpdatePriceInput, UpdateTemplateInput, CommandResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Product Service
|
|
11
|
+
*
|
|
12
|
+
* Handles all product-related business logic
|
|
13
|
+
* Stateless - all state passed as parameters
|
|
14
|
+
*/
|
|
15
|
+
export declare class ProductService {
|
|
16
|
+
/**
|
|
17
|
+
* Fetch product by ID
|
|
18
|
+
*
|
|
19
|
+
* @throws Error if product not found or GraphQL errors occur
|
|
20
|
+
*/
|
|
21
|
+
static getProductById(credentials: ShopifyCredentials, productId: string): Promise<ShopifyProduct>;
|
|
22
|
+
/**
|
|
23
|
+
* Update product description
|
|
24
|
+
*
|
|
25
|
+
* @returns Formatted result with updated product data
|
|
26
|
+
*/
|
|
27
|
+
static updateDescription(credentials: ShopifyCredentials, input: UpdateDescriptionInput): Promise<CommandResult<{
|
|
28
|
+
product: FormattedProduct;
|
|
29
|
+
}>>;
|
|
30
|
+
/**
|
|
31
|
+
* Update product variant price
|
|
32
|
+
* Uses productVariantsBulkUpdate mutation (current Shopify API)
|
|
33
|
+
*
|
|
34
|
+
* @returns Formatted result with updated variant data
|
|
35
|
+
*/
|
|
36
|
+
static updatePrice(credentials: ShopifyCredentials, input: UpdatePriceInput): Promise<CommandResult<{
|
|
37
|
+
variant?: any;
|
|
38
|
+
variants?: any[];
|
|
39
|
+
product: FormattedProduct;
|
|
40
|
+
updatedCount?: number;
|
|
41
|
+
}>>;
|
|
42
|
+
/**
|
|
43
|
+
* Update product template assignment
|
|
44
|
+
*
|
|
45
|
+
* @returns Formatted result with updated product data
|
|
46
|
+
*/
|
|
47
|
+
static updateTemplate(credentials: ShopifyCredentials, input: UpdateTemplateInput): Promise<CommandResult<{
|
|
48
|
+
product: FormattedProduct;
|
|
49
|
+
}>>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/commands/product/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAiB7D,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EAGnB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,qBAAa,cAAc;IACzB;;;;OAIG;WACU,cAAc,CACzB,WAAW,EAAE,kBAAkB,EAC/B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC;IAkB1B;;;;OAIG;WACU,iBAAiB,CAC5B,WAAW,EAAE,kBAAkB,EAC/B,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,aAAa,CAAC;QAAE,OAAO,EAAE,gBAAgB,CAAA;KAAE,CAAC,CAAC;IAkDxD;;;;;OAKG;WACU,WAAW,CACtB,WAAW,EAAE,kBAAkB,EAC/B,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,aAAa,CAAC;QAAE,OAAO,CAAC,EAAE,GAAG,CAAC;QAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IA+IhH;;;;OAIG;WACU,cAAc,CACzB,WAAW,EAAE,kBAAkB,EAC/B,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,aAAa,CAAC;QAAE,OAAO,EAAE,gBAAgB,CAAA;KAAE,CAAC,CAAC;CA0CzD"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Service Layer
|
|
3
|
+
*
|
|
4
|
+
* Following Service Pattern - encapsulates business logic for product operations
|
|
5
|
+
* Follows Dependency Injection - accepts dependencies as parameters
|
|
6
|
+
*/
|
|
7
|
+
import { shopifyGraphQL } from '../../lib/shopify-client.js';
|
|
8
|
+
import { GET_PRODUCT_BY_ID, UPDATE_PRODUCT, PRODUCT_VARIANTS_BULK_UPDATE } from './queries.js';
|
|
9
|
+
import { normalizeProductId, normalizeVariantId, normalizeTemplateName, formatProduct, isValidPrice, formatUserErrors, hasGraphQLErrors, extractGraphQLErrors } from './utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* Product Service
|
|
12
|
+
*
|
|
13
|
+
* Handles all product-related business logic
|
|
14
|
+
* Stateless - all state passed as parameters
|
|
15
|
+
*/
|
|
16
|
+
export class ProductService {
|
|
17
|
+
/**
|
|
18
|
+
* Fetch product by ID
|
|
19
|
+
*
|
|
20
|
+
* @throws Error if product not found or GraphQL errors occur
|
|
21
|
+
*/
|
|
22
|
+
static async getProductById(credentials, productId) {
|
|
23
|
+
const { gid } = normalizeProductId(productId);
|
|
24
|
+
const response = await shopifyGraphQL(credentials, GET_PRODUCT_BY_ID, { id: gid });
|
|
25
|
+
if (hasGraphQLErrors(response)) {
|
|
26
|
+
throw new Error(`GraphQL error: ${extractGraphQLErrors(response)}`);
|
|
27
|
+
}
|
|
28
|
+
const product = response.data?.product;
|
|
29
|
+
if (!product) {
|
|
30
|
+
throw new Error('Product not found');
|
|
31
|
+
}
|
|
32
|
+
return product;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Update product description
|
|
36
|
+
*
|
|
37
|
+
* @returns Formatted result with updated product data
|
|
38
|
+
*/
|
|
39
|
+
static async updateDescription(credentials, input) {
|
|
40
|
+
const { gid } = normalizeProductId(input.id);
|
|
41
|
+
// Shopify only accepts descriptionHtml field (not description)
|
|
42
|
+
// Wrap plain text in <p> tags if not HTML
|
|
43
|
+
let descriptionHtml = input.description;
|
|
44
|
+
if (!input.isHtml && input.description && !input.description.trim().startsWith('<')) {
|
|
45
|
+
descriptionHtml = `<p>${input.description}</p>`;
|
|
46
|
+
}
|
|
47
|
+
// Build GraphQL input
|
|
48
|
+
const productInput = {
|
|
49
|
+
id: gid,
|
|
50
|
+
descriptionHtml: descriptionHtml
|
|
51
|
+
};
|
|
52
|
+
// Execute mutation
|
|
53
|
+
const response = await shopifyGraphQL(credentials, UPDATE_PRODUCT, { input: productInput });
|
|
54
|
+
if (hasGraphQLErrors(response)) {
|
|
55
|
+
return {
|
|
56
|
+
success: false,
|
|
57
|
+
error: `GraphQL error: ${extractGraphQLErrors(response)}`
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const { product, userErrors } = response.data.productUpdate;
|
|
61
|
+
if (userErrors && userErrors.length > 0) {
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
error: formatUserErrors(userErrors)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Fetch full product details to return complete data
|
|
68
|
+
const fullProduct = await this.getProductById(credentials, product.id);
|
|
69
|
+
return {
|
|
70
|
+
success: true,
|
|
71
|
+
data: {
|
|
72
|
+
product: formatProduct(fullProduct)
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Update product variant price
|
|
78
|
+
* Uses productVariantsBulkUpdate mutation (current Shopify API)
|
|
79
|
+
*
|
|
80
|
+
* @returns Formatted result with updated variant data
|
|
81
|
+
*/
|
|
82
|
+
static async updatePrice(credentials, input) {
|
|
83
|
+
// Validate price format
|
|
84
|
+
if (!isValidPrice(input.price)) {
|
|
85
|
+
return {
|
|
86
|
+
success: false,
|
|
87
|
+
error: 'Invalid price format. Price must be a positive number with max 2 decimal places.'
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// Allow empty string for compareAtPrice (to clear it), otherwise validate
|
|
91
|
+
if (input.compareAtPrice !== undefined && input.compareAtPrice !== '' && !isValidPrice(input.compareAtPrice)) {
|
|
92
|
+
return {
|
|
93
|
+
success: false,
|
|
94
|
+
error: 'Invalid compare-at price format. Price must be a positive number with max 2 decimal places.'
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Get product ID in GID format (required for bulk mutation)
|
|
98
|
+
const { gid: productGid } = normalizeProductId(input.id);
|
|
99
|
+
// Fetch product to get variants
|
|
100
|
+
const product = await this.getProductById(credentials, input.id);
|
|
101
|
+
if (product.variants.edges.length === 0) {
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
error: 'Product has no variants'
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
let variantInputs = [];
|
|
108
|
+
if (input.allVariants) {
|
|
109
|
+
// Update ALL variants
|
|
110
|
+
variantInputs = product.variants.edges.map(e => {
|
|
111
|
+
const variantInput = {
|
|
112
|
+
id: e.node.id,
|
|
113
|
+
price: input.price
|
|
114
|
+
};
|
|
115
|
+
if (input.compareAtPrice !== undefined) {
|
|
116
|
+
variantInput.compareAtPrice = input.compareAtPrice || null;
|
|
117
|
+
}
|
|
118
|
+
return variantInput;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else if (input.variantId) {
|
|
122
|
+
// Update specific variant
|
|
123
|
+
const variantGid = normalizeVariantId(input.variantId).gid;
|
|
124
|
+
const variantInput = {
|
|
125
|
+
id: variantGid,
|
|
126
|
+
price: input.price
|
|
127
|
+
};
|
|
128
|
+
if (input.compareAtPrice !== undefined) {
|
|
129
|
+
variantInput.compareAtPrice = input.compareAtPrice || null;
|
|
130
|
+
}
|
|
131
|
+
variantInputs = [variantInput];
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
// No variant-id and no all-variants flag
|
|
135
|
+
if (product.variants.edges.length > 1) {
|
|
136
|
+
// Multiple variants - inform user
|
|
137
|
+
const variantList = product.variants.edges.map((e, i) => `${i + 1}. ${e.node.title} (ID: ${e.node.id})`).join('\n');
|
|
138
|
+
return {
|
|
139
|
+
success: false,
|
|
140
|
+
error: `Product has multiple variants. Please specify --variant-id or use --all-variants:\n${variantList}`
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// Single variant - update it
|
|
144
|
+
const variantInput = {
|
|
145
|
+
id: product.variants.edges[0].node.id,
|
|
146
|
+
price: input.price
|
|
147
|
+
};
|
|
148
|
+
if (input.compareAtPrice !== undefined) {
|
|
149
|
+
variantInput.compareAtPrice = input.compareAtPrice || null;
|
|
150
|
+
}
|
|
151
|
+
variantInputs = [variantInput];
|
|
152
|
+
}
|
|
153
|
+
// Execute bulk mutation (current API)
|
|
154
|
+
const response = await shopifyGraphQL(credentials, PRODUCT_VARIANTS_BULK_UPDATE, {
|
|
155
|
+
productId: productGid,
|
|
156
|
+
variants: variantInputs
|
|
157
|
+
});
|
|
158
|
+
if (hasGraphQLErrors(response)) {
|
|
159
|
+
return {
|
|
160
|
+
success: false,
|
|
161
|
+
error: `GraphQL error: ${extractGraphQLErrors(response)}`
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const { productVariants, userErrors } = response.data.productVariantsBulkUpdate;
|
|
165
|
+
if (userErrors && userErrors.length > 0) {
|
|
166
|
+
return {
|
|
167
|
+
success: false,
|
|
168
|
+
error: formatUserErrors(userErrors)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if (!productVariants || productVariants.length === 0) {
|
|
172
|
+
return {
|
|
173
|
+
success: false,
|
|
174
|
+
error: 'No variants were updated'
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
// Fetch full product details
|
|
178
|
+
const fullProduct = await this.getProductById(credentials, productGid);
|
|
179
|
+
// Return appropriate response based on update type
|
|
180
|
+
if (input.allVariants) {
|
|
181
|
+
return {
|
|
182
|
+
success: true,
|
|
183
|
+
data: {
|
|
184
|
+
variants: productVariants,
|
|
185
|
+
product: formatProduct(fullProduct),
|
|
186
|
+
updatedCount: productVariants.length
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
return {
|
|
192
|
+
success: true,
|
|
193
|
+
data: {
|
|
194
|
+
variant: productVariants[0],
|
|
195
|
+
product: formatProduct(fullProduct)
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Update product template assignment
|
|
202
|
+
*
|
|
203
|
+
* @returns Formatted result with updated product data
|
|
204
|
+
*/
|
|
205
|
+
static async updateTemplate(credentials, input) {
|
|
206
|
+
const { gid } = normalizeProductId(input.id);
|
|
207
|
+
const templateSuffix = normalizeTemplateName(input.template);
|
|
208
|
+
const productInput = {
|
|
209
|
+
id: gid,
|
|
210
|
+
templateSuffix: templateSuffix
|
|
211
|
+
};
|
|
212
|
+
// Execute mutation
|
|
213
|
+
const response = await shopifyGraphQL(credentials, UPDATE_PRODUCT, { input: productInput });
|
|
214
|
+
if (hasGraphQLErrors(response)) {
|
|
215
|
+
return {
|
|
216
|
+
success: false,
|
|
217
|
+
error: `GraphQL error: ${extractGraphQLErrors(response)}`
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const { product, userErrors } = response.data.productUpdate;
|
|
221
|
+
if (userErrors && userErrors.length > 0) {
|
|
222
|
+
return {
|
|
223
|
+
success: false,
|
|
224
|
+
error: formatUserErrors(userErrors)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
// Fetch full product details
|
|
228
|
+
const fullProduct = await this.getProductById(credentials, product.id);
|
|
229
|
+
return {
|
|
230
|
+
success: true,
|
|
231
|
+
data: {
|
|
232
|
+
product: formatProduct(fullProduct)
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/commands/product/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAYpB;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACzB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,cAAc,CACzB,WAA+B,EAC/B,SAAiB;QAEjB,MAAM,EAAE,GAAG,EAAE,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC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AAE,CACxB,CAAC;QAEF,IAAI,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,kBAAkB,oBAAoB,CAAC,QAAQ,CAAC,EAAE;aAC1D,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC,IAAK,CAAC,aAAa,CAAC;QAE7D,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,gBAAgB,CAAC,UAAU,CAAC;aACpC,CAAC;QACJ,CAAC;QAED,6BAA6B;QAC7B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;QAEvE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE;gBACJ,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC;aACpC;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Command Types
|
|
3
|
+
* Type definitions for product-related commands
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base product information returned from Shopify
|
|
7
|
+
*/
|
|
8
|
+
export interface ShopifyProduct {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
descriptionHtml: string;
|
|
13
|
+
handle: string;
|
|
14
|
+
productType: string;
|
|
15
|
+
vendor: string;
|
|
16
|
+
tags: string[];
|
|
17
|
+
status: 'ACTIVE' | 'ARCHIVED' | 'DRAFT';
|
|
18
|
+
templateSuffix: string | null;
|
|
19
|
+
variants: {
|
|
20
|
+
edges: Array<{
|
|
21
|
+
node: ShopifyVariant;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
images: {
|
|
25
|
+
edges: Array<{
|
|
26
|
+
node: ShopifyImage;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
priceRangeV2: {
|
|
30
|
+
minVariantPrice: ShopifyMoney;
|
|
31
|
+
maxVariantPrice: ShopifyMoney;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface ShopifyVariant {
|
|
35
|
+
id: string;
|
|
36
|
+
title: string;
|
|
37
|
+
sku: string;
|
|
38
|
+
price: string;
|
|
39
|
+
compareAtPrice: string | null;
|
|
40
|
+
inventoryQuantity: number;
|
|
41
|
+
availableForSale: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ShopifyImage {
|
|
44
|
+
id: string;
|
|
45
|
+
url: string;
|
|
46
|
+
altText: string | null;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
}
|
|
50
|
+
export interface ShopifyMoney {
|
|
51
|
+
amount: string;
|
|
52
|
+
currencyCode: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Formatted product output for CLI responses
|
|
56
|
+
*/
|
|
57
|
+
export interface FormattedProduct {
|
|
58
|
+
id: string;
|
|
59
|
+
title: string;
|
|
60
|
+
description: string;
|
|
61
|
+
handle: string;
|
|
62
|
+
status: string;
|
|
63
|
+
productType: string;
|
|
64
|
+
vendor: string;
|
|
65
|
+
template: string;
|
|
66
|
+
tags: string[];
|
|
67
|
+
priceRange: {
|
|
68
|
+
min: ShopifyMoney;
|
|
69
|
+
max: ShopifyMoney;
|
|
70
|
+
};
|
|
71
|
+
variants: FormattedVariant[];
|
|
72
|
+
images: FormattedImage[];
|
|
73
|
+
}
|
|
74
|
+
export interface FormattedVariant {
|
|
75
|
+
id: string;
|
|
76
|
+
title: string;
|
|
77
|
+
price: string;
|
|
78
|
+
compareAtPrice: string | null;
|
|
79
|
+
sku: string;
|
|
80
|
+
inventory: number;
|
|
81
|
+
available: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface FormattedImage {
|
|
84
|
+
id: string;
|
|
85
|
+
url: string;
|
|
86
|
+
altText: string | null;
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Update operation input types
|
|
92
|
+
*/
|
|
93
|
+
export interface UpdateDescriptionInput {
|
|
94
|
+
id: string;
|
|
95
|
+
description: string;
|
|
96
|
+
isHtml?: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface UpdatePriceInput {
|
|
99
|
+
id: string;
|
|
100
|
+
variantId?: string;
|
|
101
|
+
price: string;
|
|
102
|
+
compareAtPrice?: string;
|
|
103
|
+
allVariants?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface UpdateTemplateInput {
|
|
106
|
+
id: string;
|
|
107
|
+
template: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Shopify GraphQL response types
|
|
111
|
+
*/
|
|
112
|
+
export interface ProductUpdateResponse {
|
|
113
|
+
productUpdate: {
|
|
114
|
+
product: {
|
|
115
|
+
id: string;
|
|
116
|
+
title: string;
|
|
117
|
+
description: string;
|
|
118
|
+
templateSuffix: string | null;
|
|
119
|
+
};
|
|
120
|
+
userErrors: ShopifyUserError[];
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export interface VariantUpdateResponse {
|
|
124
|
+
productVariantUpdate: {
|
|
125
|
+
productVariant: {
|
|
126
|
+
id: string;
|
|
127
|
+
price: string;
|
|
128
|
+
compareAtPrice: string | null;
|
|
129
|
+
};
|
|
130
|
+
userErrors: ShopifyUserError[];
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export interface VariantsBulkUpdateResponse {
|
|
134
|
+
productVariantsBulkUpdate: {
|
|
135
|
+
productVariants: Array<{
|
|
136
|
+
id: string;
|
|
137
|
+
price: string;
|
|
138
|
+
compareAtPrice: string | null;
|
|
139
|
+
}>;
|
|
140
|
+
userErrors: ShopifyUserError[];
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export interface ShopifyUserError {
|
|
144
|
+
field: string[] | null;
|
|
145
|
+
message: string;
|
|
146
|
+
code?: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* CLI command result types
|
|
150
|
+
*/
|
|
151
|
+
export interface CommandResult<T = any> {
|
|
152
|
+
success: boolean;
|
|
153
|
+
data?: T;
|
|
154
|
+
error?: string;
|
|
155
|
+
multiple?: boolean;
|
|
156
|
+
count?: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Product ID normalization result
|
|
160
|
+
*/
|
|
161
|
+
export interface NormalizedId {
|
|
162
|
+
gid: string;
|
|
163
|
+
numeric: string;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/product/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IACxC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE;QACR,KAAK,EAAE,KAAK,CAAC;YACX,IAAI,EAAE,cAAc,CAAC;SACtB,CAAC,CAAC;KACJ,CAAC;IACF,MAAM,EAAE;QACN,KAAK,EAAE,KAAK,CAAC;YACX,IAAI,EAAE,YAAY,CAAC;SACpB,CAAC,CAAC;KACJ,CAAC;IACF,YAAY,EAAE;QACZ,eAAe,EAAE,YAAY,CAAC;QAC9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BAAyB,EAAE;QACzB,eAAe,EAAE,KAAK,CAAC;YACrB,EAAE,EAAE,MAAM,CAAC;YACX,KAAK,EAAE,MAAM,CAAC;YACd,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;SAC/B,CAAC,CAAC;QACH,UAAU,EAAE,gBAAgB,EAAE,CAAC;KAChC,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/commands/product/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update Product Description Command
|
|
3
|
+
*
|
|
4
|
+
* Following Command Pattern - thin orchestration layer
|
|
5
|
+
* Delegates business logic to ProductService
|
|
6
|
+
*/
|
|
7
|
+
export declare function run(argv?: string[]): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=update-description.d.ts.map
|