ecomcoder-cli 1.2.15 → 1.3.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/__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 +10 -2
|
@@ -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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AkB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7C,MAAM,cAAc,GAAG,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE7D,MAAM,YAAY,GAAG;YACnB,EAAE,EAAE,GAAG;YACP,cAAc,EAAE,cAAc;SAC/B,CAAC;QAEF,mBAAmB;QACnB,MAAM,QAAQ,GAAG,MAAM,cAAc,CACnC,WAAW,EACX,cAAc,EACd,EAAE,KAAK,EAAE,YAAY,EAAE,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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E,gBAAgB,EAAE,CAAC;KAChC,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,oBAAoB,EAAE;QACpB,cAAc,EAAE;YACd,EAAE,EAAE,MAAM,CAAC;YACX,KAAK,EAAE,MAAM,CAAC;YACd,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;SAC/B,CAAC;QACF,UAAU,EAAE,gBAAgB,EAAE,CAAC;KAChC,CAAC;CACH;AAED,MAAM,WAAW,0BAA0B;IACzC,yBAAyB,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-description.d.ts","sourceRoot":"","sources":["../../../src/commands/product/update-description.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuCH,wBAAsB,GAAG,CAAC,IAAI,GAAE,MAAM,EAA0B,iBAkD/D"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Update Product Description Command
|
|
3
|
+
*
|
|
4
|
+
* Following Command Pattern - thin orchestration layer
|
|
5
|
+
* Delegates business logic to ProductService
|
|
6
|
+
*/
|
|
7
|
+
import { getCredentials, getSessionId } from '../../lib/api-client.js';
|
|
8
|
+
import { parseArgs, hasHelpFlag } from '../../lib/args-parser.js';
|
|
9
|
+
import { ProductService } from './service.js';
|
|
10
|
+
function showHelp() {
|
|
11
|
+
console.log(`
|
|
12
|
+
Update Product Description
|
|
13
|
+
|
|
14
|
+
USAGE:
|
|
15
|
+
ecomcoder product update-description [OPTIONS]
|
|
16
|
+
|
|
17
|
+
OPTIONS:
|
|
18
|
+
--id <id> Product ID (required)
|
|
19
|
+
--description <text> New description (required)
|
|
20
|
+
--html Treat description as HTML (default: plain text wrapped in <p> tags)
|
|
21
|
+
--session-id Session ID (auto-provided via SESSION_ID env var)
|
|
22
|
+
--help, -h Show this help message
|
|
23
|
+
|
|
24
|
+
EXAMPLES:
|
|
25
|
+
# Update plain text description (auto-wrapped in <p> tags)
|
|
26
|
+
ecomcoder product update-description --id=123456789 --description="Premium cotton t-shirt"
|
|
27
|
+
|
|
28
|
+
# Update HTML description
|
|
29
|
+
ecomcoder product update-description --id=123 --description="<p>Premium <strong>cotton</strong> t-shirt</p>" --html
|
|
30
|
+
|
|
31
|
+
# Clear description
|
|
32
|
+
ecomcoder product update-description --id=123 --description=""
|
|
33
|
+
|
|
34
|
+
NOTES:
|
|
35
|
+
- Shopify stores all descriptions as HTML (descriptionHtml field)
|
|
36
|
+
- Plain text is automatically wrapped in <p> tags
|
|
37
|
+
- Use --html flag to prevent auto-wrapping if you're providing full HTML
|
|
38
|
+
- Empty description will clear the product description
|
|
39
|
+
`);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
export async function run(argv = process.argv.slice(2)) {
|
|
43
|
+
if (hasHelpFlag(argv)) {
|
|
44
|
+
showHelp();
|
|
45
|
+
}
|
|
46
|
+
const args = parseArgs(argv);
|
|
47
|
+
// Validate required arguments
|
|
48
|
+
if (!args.id) {
|
|
49
|
+
console.error(JSON.stringify({
|
|
50
|
+
success: false,
|
|
51
|
+
error: 'Missing required argument: --id'
|
|
52
|
+
}));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
if (args.description === undefined) {
|
|
56
|
+
console.error(JSON.stringify({
|
|
57
|
+
success: false,
|
|
58
|
+
error: 'Missing required argument: --description'
|
|
59
|
+
}));
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
// Get credentials
|
|
64
|
+
const sessionId = getSessionId(args.sessionId);
|
|
65
|
+
const credentials = await getCredentials(sessionId, args.backendUrl, args.jwt);
|
|
66
|
+
// Execute update via service
|
|
67
|
+
const result = await ProductService.updateDescription(credentials, {
|
|
68
|
+
id: args.id,
|
|
69
|
+
description: args.description,
|
|
70
|
+
isHtml: !!args.html
|
|
71
|
+
});
|
|
72
|
+
// Output result
|
|
73
|
+
console.log(JSON.stringify(result));
|
|
74
|
+
if (!result.success) {
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.error(JSON.stringify({
|
|
80
|
+
success: false,
|
|
81
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
82
|
+
}));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=update-description.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-description.js","sourceRoot":"","sources":["../../../src/commands/product/update-description.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,SAAS,QAAQ;IACf,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Bb,CAAC,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAiB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9D,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,QAAQ,EAAE,CAAC;IACb,CAAC;IAED,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAE7B,8BAA8B;IAC9B,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YAC3B,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,iCAAiC;SACzC,CAAC,CAAC,CAAC;QACJ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YAC3B,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,0CAA0C;SAClD,CAAC,CAAC,CAAC;QACJ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB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