ecomcoder-cli 1.3.13 → 1.3.15
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/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/collection/get-product-collections.d.ts +7 -0
- package/dist/commands/collection/get-product-collections.d.ts.map +1 -0
- package/dist/commands/collection/get-product-collections.js +99 -0
- package/dist/commands/collection/get-product-collections.js.map +1 -0
- package/dist/commands/collection/get.d.ts +7 -0
- package/dist/commands/collection/get.d.ts.map +1 -0
- package/dist/commands/collection/get.js +80 -0
- package/dist/commands/collection/get.js.map +1 -0
- package/dist/commands/collection/index.d.ts +10 -0
- package/dist/commands/collection/index.d.ts.map +1 -0
- package/dist/commands/collection/index.js +54 -0
- package/dist/commands/collection/index.js.map +1 -0
- package/dist/commands/collection/list-products.d.ts +7 -0
- package/dist/commands/collection/list-products.d.ts.map +1 -0
- package/dist/commands/collection/list-products.js +105 -0
- package/dist/commands/collection/list-products.js.map +1 -0
- package/dist/commands/collection/list.d.ts +7 -0
- package/dist/commands/collection/list.d.ts.map +1 -0
- package/dist/commands/collection/list.js +105 -0
- package/dist/commands/collection/list.js.map +1 -0
- package/dist/commands/collection/queries.d.ts +32 -0
- package/dist/commands/collection/queries.d.ts.map +1 -0
- package/dist/commands/collection/queries.js +158 -0
- package/dist/commands/collection/queries.js.map +1 -0
- package/dist/commands/collection/service.d.ts +53 -0
- package/dist/commands/collection/service.d.ts.map +1 -0
- package/dist/commands/collection/service.js +232 -0
- package/dist/commands/collection/service.js.map +1 -0
- package/dist/commands/collection/types.d.ts +156 -0
- package/dist/commands/collection/types.d.ts.map +1 -0
- package/dist/commands/collection/types.js +6 -0
- package/dist/commands/collection/types.js.map +1 -0
- package/dist/commands/collection/utils.d.ts +33 -0
- package/dist/commands/collection/utils.d.ts.map +1 -0
- package/dist/commands/collection/utils.js +84 -0
- package/dist/commands/collection/utils.js.map +1 -0
- package/dist/commands/image/generate.d.ts +6 -0
- package/dist/commands/image/generate.d.ts.map +1 -0
- package/dist/commands/image/generate.js +135 -0
- package/dist/commands/image/generate.js.map +1 -0
- package/dist/commands/image/index.d.ts +5 -0
- package/dist/commands/image/index.d.ts.map +1 -0
- package/dist/commands/image/index.js +25 -0
- package/dist/commands/image/index.js.map +1 -0
- package/dist/commands/image/openai.d.ts +19 -0
- package/dist/commands/image/openai.d.ts.map +1 -0
- package/dist/commands/image/openai.js +35 -0
- package/dist/commands/image/openai.js.map +1 -0
- package/dist/commands/image/service.d.ts +31 -0
- package/dist/commands/image/service.d.ts.map +1 -0
- package/dist/commands/image/service.js +72 -0
- package/dist/commands/image/service.js.map +1 -0
- package/dist/lib/approval.d.ts +19 -4
- package/dist/lib/approval.d.ts.map +1 -1
- package/dist/lib/approval.js +26 -5
- package/dist/lib/approval.js.map +1 -1
- package/dist/lib/config.d.ts +52 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +83 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/types.d.ts +5 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +4 -2
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection GraphQL Queries
|
|
3
|
+
* All queries verified against Shopify GraphQL Admin API 2026-01
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Get collection by ID
|
|
7
|
+
*/
|
|
8
|
+
export const GET_COLLECTION = `
|
|
9
|
+
query GetCollection($id: ID!) {
|
|
10
|
+
collection(id: $id) {
|
|
11
|
+
id
|
|
12
|
+
title
|
|
13
|
+
handle
|
|
14
|
+
description
|
|
15
|
+
descriptionHtml
|
|
16
|
+
sortOrder
|
|
17
|
+
productsCount
|
|
18
|
+
updatedAt
|
|
19
|
+
image {
|
|
20
|
+
url
|
|
21
|
+
altText
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
/**
|
|
27
|
+
* Get collection by handle
|
|
28
|
+
*/
|
|
29
|
+
export const GET_COLLECTION_BY_HANDLE = `
|
|
30
|
+
query GetCollectionByHandle($handle: String!) {
|
|
31
|
+
collectionByHandle(handle: $handle) {
|
|
32
|
+
id
|
|
33
|
+
title
|
|
34
|
+
handle
|
|
35
|
+
description
|
|
36
|
+
descriptionHtml
|
|
37
|
+
sortOrder
|
|
38
|
+
productsCount
|
|
39
|
+
updatedAt
|
|
40
|
+
image {
|
|
41
|
+
url
|
|
42
|
+
altText
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
/**
|
|
48
|
+
* Get collection with products
|
|
49
|
+
* Used by list-products command
|
|
50
|
+
*/
|
|
51
|
+
export const GET_COLLECTION_PRODUCTS = `
|
|
52
|
+
query GetCollectionProducts($id: ID!, $first: Int!, $after: String) {
|
|
53
|
+
collection(id: $id) {
|
|
54
|
+
id
|
|
55
|
+
title
|
|
56
|
+
products(first: $first, after: $after) {
|
|
57
|
+
nodes {
|
|
58
|
+
id
|
|
59
|
+
title
|
|
60
|
+
handle
|
|
61
|
+
status
|
|
62
|
+
priceRangeV2 {
|
|
63
|
+
minVariantPrice {
|
|
64
|
+
amount
|
|
65
|
+
currencyCode
|
|
66
|
+
}
|
|
67
|
+
maxVariantPrice {
|
|
68
|
+
amount
|
|
69
|
+
currencyCode
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
pageInfo {
|
|
74
|
+
hasNextPage
|
|
75
|
+
endCursor
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
/**
|
|
82
|
+
* Get collection by handle with products
|
|
83
|
+
*/
|
|
84
|
+
export const GET_COLLECTION_PRODUCTS_BY_HANDLE = `
|
|
85
|
+
query GetCollectionProductsByHandle($handle: String!, $first: Int!, $after: String) {
|
|
86
|
+
collectionByHandle(handle: $handle) {
|
|
87
|
+
id
|
|
88
|
+
title
|
|
89
|
+
products(first: $first, after: $after) {
|
|
90
|
+
nodes {
|
|
91
|
+
id
|
|
92
|
+
title
|
|
93
|
+
handle
|
|
94
|
+
status
|
|
95
|
+
priceRangeV2 {
|
|
96
|
+
minVariantPrice {
|
|
97
|
+
amount
|
|
98
|
+
currencyCode
|
|
99
|
+
}
|
|
100
|
+
maxVariantPrice {
|
|
101
|
+
amount
|
|
102
|
+
currencyCode
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
pageInfo {
|
|
107
|
+
hasNextPage
|
|
108
|
+
endCursor
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
/**
|
|
115
|
+
* Get product's collections
|
|
116
|
+
* Used by get-product-collections command
|
|
117
|
+
*/
|
|
118
|
+
export const GET_PRODUCT_COLLECTIONS = `
|
|
119
|
+
query GetProductCollections($id: ID!, $first: Int!, $after: String) {
|
|
120
|
+
product(id: $id) {
|
|
121
|
+
id
|
|
122
|
+
title
|
|
123
|
+
collections(first: $first, after: $after) {
|
|
124
|
+
nodes {
|
|
125
|
+
id
|
|
126
|
+
title
|
|
127
|
+
handle
|
|
128
|
+
}
|
|
129
|
+
pageInfo {
|
|
130
|
+
hasNextPage
|
|
131
|
+
endCursor
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
/**
|
|
138
|
+
* List all collections
|
|
139
|
+
* Used by list command
|
|
140
|
+
*/
|
|
141
|
+
export const LIST_COLLECTIONS = `
|
|
142
|
+
query ListCollections($first: Int!, $after: String, $query: String, $sortKey: CollectionSortKeys, $reverse: Boolean) {
|
|
143
|
+
collections(first: $first, after: $after, query: $query, sortKey: $sortKey, reverse: $reverse) {
|
|
144
|
+
nodes {
|
|
145
|
+
id
|
|
146
|
+
title
|
|
147
|
+
handle
|
|
148
|
+
productsCount
|
|
149
|
+
updatedAt
|
|
150
|
+
}
|
|
151
|
+
pageInfo {
|
|
152
|
+
hasNextPage
|
|
153
|
+
endCursor
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
`;
|
|
158
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/commands/collection/queries.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;CAiB7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;CAiBvC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BtC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BhD,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;CAkBtC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;CAgB/B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection Service Layer
|
|
3
|
+
*
|
|
4
|
+
* Following Service Pattern - encapsulates business logic for collection operations
|
|
5
|
+
* Follows Dependency Injection - accepts dependencies as parameters
|
|
6
|
+
*/
|
|
7
|
+
import type { ShopifyCredentials } from '../../lib/types.js';
|
|
8
|
+
import type { GetCollectionInput, ListProductsInput, GetProductCollectionsInput, ListCollectionsInput, FormattedCollection, FormattedProduct, PageInfo, CommandResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Collection Service
|
|
11
|
+
*
|
|
12
|
+
* Handles all collection-related business logic
|
|
13
|
+
* Stateless - all state passed as parameters
|
|
14
|
+
*/
|
|
15
|
+
export declare class CollectionService {
|
|
16
|
+
/**
|
|
17
|
+
* Get collection details by ID or handle
|
|
18
|
+
*/
|
|
19
|
+
static getCollection(credentials: ShopifyCredentials, input: GetCollectionInput): Promise<CommandResult<{
|
|
20
|
+
collection: FormattedCollection;
|
|
21
|
+
}>>;
|
|
22
|
+
/**
|
|
23
|
+
* List products in a collection
|
|
24
|
+
*/
|
|
25
|
+
static listProducts(credentials: ShopifyCredentials, input: ListProductsInput): Promise<CommandResult<{
|
|
26
|
+
collection: {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
};
|
|
30
|
+
products: FormattedProduct[];
|
|
31
|
+
pageInfo: PageInfo;
|
|
32
|
+
}>>;
|
|
33
|
+
/**
|
|
34
|
+
* Get which collections a product belongs to
|
|
35
|
+
*/
|
|
36
|
+
static getProductCollections(credentials: ShopifyCredentials, input: GetProductCollectionsInput): Promise<CommandResult<{
|
|
37
|
+
product: {
|
|
38
|
+
id: string;
|
|
39
|
+
title: string;
|
|
40
|
+
};
|
|
41
|
+
collections: FormattedCollection[];
|
|
42
|
+
count: number;
|
|
43
|
+
}>>;
|
|
44
|
+
/**
|
|
45
|
+
* List all collections in store
|
|
46
|
+
*/
|
|
47
|
+
static listCollections(credentials: ShopifyCredentials, input: ListCollectionsInput): Promise<CommandResult<{
|
|
48
|
+
collections: FormattedCollection[];
|
|
49
|
+
pageInfo: PageInfo;
|
|
50
|
+
count: number;
|
|
51
|
+
}>>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/commands/collection/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAiB7D,OAAO,KAAK,EACV,kBA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4
|
+
* Following Service Pattern - encapsulates business logic for collection operations
|
|
5
|
+
* Follows Dependency Injection - accepts dependencies as parameters
|
|
6
|
+
*/
|
|
7
|
+
import { shopifyGraphQL } from '../../lib/shopify-client.js';
|
|
8
|
+
import { GET_COLLECTION, GET_COLLECTION_BY_HANDLE, GET_COLLECTION_PRODUCTS, GET_COLLECTION_PRODUCTS_BY_HANDLE, GET_PRODUCT_COLLECTIONS, LIST_COLLECTIONS } from './queries.js';
|
|
9
|
+
import { normalizeCollectionId, normalizeProductId, formatCollection, hasGraphQLErrors, extractGraphQLErrors } from './utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* Collection Service
|
|
12
|
+
*
|
|
13
|
+
* Handles all collection-related business logic
|
|
14
|
+
* Stateless - all state passed as parameters
|
|
15
|
+
*/
|
|
16
|
+
export class CollectionService {
|
|
17
|
+
/**
|
|
18
|
+
* Get collection details by ID or handle
|
|
19
|
+
*/
|
|
20
|
+
static async getCollection(credentials, input) {
|
|
21
|
+
// Validate input
|
|
22
|
+
if (!input.id && !input.handle) {
|
|
23
|
+
return {
|
|
24
|
+
success: false,
|
|
25
|
+
error: 'Either --id or --handle must be provided'
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// Choose query based on input
|
|
29
|
+
const query = input.id ? GET_COLLECTION : GET_COLLECTION_BY_HANDLE;
|
|
30
|
+
const variables = {};
|
|
31
|
+
if (input.id) {
|
|
32
|
+
const { gid } = normalizeCollectionId(input.id);
|
|
33
|
+
variables.id = gid;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
variables.handle = input.handle;
|
|
37
|
+
}
|
|
38
|
+
// Execute query
|
|
39
|
+
const response = await shopifyGraphQL(credentials, query, variables);
|
|
40
|
+
if (hasGraphQLErrors(response)) {
|
|
41
|
+
return {
|
|
42
|
+
success: false,
|
|
43
|
+
error: `GraphQL error: ${extractGraphQLErrors(response)}`
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// For handle-based queries, the response uses collectionByHandle
|
|
47
|
+
const collection = input.handle
|
|
48
|
+
? response.data?.collectionByHandle
|
|
49
|
+
: response.data?.collection;
|
|
50
|
+
if (!collection) {
|
|
51
|
+
return {
|
|
52
|
+
success: false,
|
|
53
|
+
error: input.id
|
|
54
|
+
? `Collection not found with ID: ${input.id}`
|
|
55
|
+
: `Collection not found with handle: ${input.handle}`
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
success: true,
|
|
60
|
+
data: {
|
|
61
|
+
collection: formatCollection(collection)
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* List products in a collection
|
|
67
|
+
*/
|
|
68
|
+
static async listProducts(credentials, input) {
|
|
69
|
+
// Validate input
|
|
70
|
+
if (!input.id && !input.handle) {
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
error: 'Either --id or --handle must be provided'
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const limit = Math.min(input.limit || 50, 250);
|
|
77
|
+
const query = input.id ? GET_COLLECTION_PRODUCTS : GET_COLLECTION_PRODUCTS_BY_HANDLE;
|
|
78
|
+
const variables = { first: limit };
|
|
79
|
+
if (input.id) {
|
|
80
|
+
const { gid } = normalizeCollectionId(input.id);
|
|
81
|
+
variables.id = gid;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
variables.handle = input.handle;
|
|
85
|
+
}
|
|
86
|
+
if (input.cursor) {
|
|
87
|
+
variables.after = input.cursor;
|
|
88
|
+
}
|
|
89
|
+
// Execute query
|
|
90
|
+
const response = await shopifyGraphQL(credentials, query, variables);
|
|
91
|
+
if (hasGraphQLErrors(response)) {
|
|
92
|
+
return {
|
|
93
|
+
success: false,
|
|
94
|
+
error: `GraphQL error: ${extractGraphQLErrors(response)}`
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// For handle-based queries, the response uses collectionByHandle
|
|
98
|
+
const collection = input.handle
|
|
99
|
+
? response.data?.collectionByHandle
|
|
100
|
+
: response.data?.collection;
|
|
101
|
+
if (!collection) {
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
error: input.id
|
|
105
|
+
? `Collection not found with ID: ${input.id}`
|
|
106
|
+
: `Collection not found with handle: ${input.handle}`
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// Format products
|
|
110
|
+
const formattedProducts = collection.products.nodes.map((product) => ({
|
|
111
|
+
id: product.id,
|
|
112
|
+
title: product.title,
|
|
113
|
+
handle: product.handle,
|
|
114
|
+
status: product.status,
|
|
115
|
+
priceRange: {
|
|
116
|
+
min: product.priceRangeV2.minVariantPrice.amount,
|
|
117
|
+
max: product.priceRangeV2.maxVariantPrice.amount,
|
|
118
|
+
currencyCode: product.priceRangeV2.minVariantPrice.currencyCode
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
return {
|
|
122
|
+
success: true,
|
|
123
|
+
data: {
|
|
124
|
+
collection: {
|
|
125
|
+
id: collection.id,
|
|
126
|
+
title: collection.title
|
|
127
|
+
},
|
|
128
|
+
products: formattedProducts,
|
|
129
|
+
pageInfo: collection.products.pageInfo
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get which collections a product belongs to
|
|
135
|
+
*/
|
|
136
|
+
static async getProductCollections(credentials, input) {
|
|
137
|
+
const { gid } = normalizeProductId(input.productId);
|
|
138
|
+
const limit = Math.min(input.limit || 50, 250);
|
|
139
|
+
const variables = {
|
|
140
|
+
id: gid,
|
|
141
|
+
first: limit
|
|
142
|
+
};
|
|
143
|
+
if (input.cursor) {
|
|
144
|
+
variables.after = input.cursor;
|
|
145
|
+
}
|
|
146
|
+
// Execute query
|
|
147
|
+
const response = await shopifyGraphQL(credentials, GET_PRODUCT_COLLECTIONS, variables);
|
|
148
|
+
if (hasGraphQLErrors(response)) {
|
|
149
|
+
return {
|
|
150
|
+
success: false,
|
|
151
|
+
error: `GraphQL error: ${extractGraphQLErrors(response)}`
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const product = response.data?.product;
|
|
155
|
+
if (!product) {
|
|
156
|
+
return {
|
|
157
|
+
success: false,
|
|
158
|
+
error: `Product not found with ID: ${input.productId}`
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// Format collections (minimal format for this use case)
|
|
162
|
+
const formattedCollections = product.collections.nodes.map((collection) => ({
|
|
163
|
+
id: collection.id,
|
|
164
|
+
title: collection.title,
|
|
165
|
+
handle: collection.handle,
|
|
166
|
+
productsCount: 0, // Not included in this query
|
|
167
|
+
updatedAt: '' // Not included in this query
|
|
168
|
+
}));
|
|
169
|
+
return {
|
|
170
|
+
success: true,
|
|
171
|
+
data: {
|
|
172
|
+
product: {
|
|
173
|
+
id: product.id,
|
|
174
|
+
title: product.title
|
|
175
|
+
},
|
|
176
|
+
collections: formattedCollections,
|
|
177
|
+
count: product.collections.nodes.length
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* List all collections in store
|
|
183
|
+
*/
|
|
184
|
+
static async listCollections(credentials, input) {
|
|
185
|
+
const limit = Math.min(input.limit || 50, 250);
|
|
186
|
+
const variables = { first: limit };
|
|
187
|
+
if (input.cursor) {
|
|
188
|
+
variables.after = input.cursor;
|
|
189
|
+
}
|
|
190
|
+
if (input.query) {
|
|
191
|
+
variables.query = input.query;
|
|
192
|
+
}
|
|
193
|
+
if (input.sortKey) {
|
|
194
|
+
variables.sortKey = input.sortKey;
|
|
195
|
+
}
|
|
196
|
+
if (input.reverse) {
|
|
197
|
+
variables.reverse = input.reverse;
|
|
198
|
+
}
|
|
199
|
+
// Execute query
|
|
200
|
+
const response = await shopifyGraphQL(credentials, LIST_COLLECTIONS, variables);
|
|
201
|
+
if (hasGraphQLErrors(response)) {
|
|
202
|
+
return {
|
|
203
|
+
success: false,
|
|
204
|
+
error: `GraphQL error: ${extractGraphQLErrors(response)}`
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const collections = response.data?.collections;
|
|
208
|
+
if (!collections) {
|
|
209
|
+
return {
|
|
210
|
+
success: false,
|
|
211
|
+
error: 'Failed to fetch collections'
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
// Format collections
|
|
215
|
+
const formattedCollections = collections.nodes.map((collection) => ({
|
|
216
|
+
id: collection.id,
|
|
217
|
+
title: collection.title,
|
|
218
|
+
handle: collection.handle,
|
|
219
|
+
productsCount: collection.productsCount,
|
|
220
|
+
updatedAt: collection.updatedAt
|
|
221
|
+
}));
|
|
222
|
+
return {
|
|
223
|
+
success: true,
|
|
224
|
+
data: {
|
|
225
|
+
collections: formattedCollections,
|
|
226
|
+
pageInfo: collections.pageInfo,
|
|
227
|
+
count: collections.nodes.length
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/commands/collection/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,iCAAiC,EACjC,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAgBpB;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,aAAa,CACxB,WAA+B,EAC/B,KAAyB;QAEzB,iBAAiB;QACjB,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC/B,OA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W,EAAE,CAAC;YACjB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,6BAA6B;aACrC,CAAC;QACJ,CAAC;QAED,qBAAqB;QACrB,MAAM,oBAAoB,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,UAAe,EAAE,EAAE,CAAC,CAAC;YACvE,EAAE,EAAE,UAAU,CAAC,EAAE;YACjB,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,aAAa,EAAE,UAAU,CAAC,aAAa;YACvC,SAAS,EAAE,UAAU,CAAC,SAAS;SAChC,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE;gBACJ,WAAW,EAAE,oBAAoB;gBACjC,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM;aAChC;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection Command Types
|
|
3
|
+
* Type definitions for collection-related commands
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Input types for commands
|
|
7
|
+
*/
|
|
8
|
+
export interface GetCollectionInput {
|
|
9
|
+
id?: string;
|
|
10
|
+
handle?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ListProductsInput {
|
|
13
|
+
id?: string;
|
|
14
|
+
handle?: string;
|
|
15
|
+
limit?: number;
|
|
16
|
+
cursor?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface GetProductCollectionsInput {
|
|
19
|
+
productId: string;
|
|
20
|
+
limit?: number;
|
|
21
|
+
cursor?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ListCollectionsInput {
|
|
24
|
+
limit?: number;
|
|
25
|
+
cursor?: string;
|
|
26
|
+
query?: string;
|
|
27
|
+
sortKey?: 'TITLE' | 'UPDATED_AT' | 'ID';
|
|
28
|
+
reverse?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Formatted output types for CLI responses
|
|
32
|
+
*/
|
|
33
|
+
export interface FormattedCollection {
|
|
34
|
+
id: string;
|
|
35
|
+
title: string;
|
|
36
|
+
handle: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
productsCount: number;
|
|
39
|
+
sortOrder?: string;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
image?: {
|
|
42
|
+
url: string;
|
|
43
|
+
altText?: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface FormattedProduct {
|
|
47
|
+
id: string;
|
|
48
|
+
title: string;
|
|
49
|
+
handle: string;
|
|
50
|
+
status: string;
|
|
51
|
+
priceRange: {
|
|
52
|
+
min: string;
|
|
53
|
+
max: string;
|
|
54
|
+
currencyCode: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface PageInfo {
|
|
58
|
+
hasNextPage: boolean;
|
|
59
|
+
endCursor?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Shopify GraphQL response types
|
|
63
|
+
*/
|
|
64
|
+
export interface ShopifyCollection {
|
|
65
|
+
id: string;
|
|
66
|
+
title: string;
|
|
67
|
+
handle: string;
|
|
68
|
+
description: string;
|
|
69
|
+
descriptionHtml: string;
|
|
70
|
+
sortOrder: string;
|
|
71
|
+
productsCount: number;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
image?: {
|
|
74
|
+
url: string;
|
|
75
|
+
altText?: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export interface CollectionResponse {
|
|
79
|
+
collection: ShopifyCollection | null;
|
|
80
|
+
}
|
|
81
|
+
export interface CollectionProductsResponse {
|
|
82
|
+
collection: {
|
|
83
|
+
id: string;
|
|
84
|
+
title: string;
|
|
85
|
+
products: {
|
|
86
|
+
nodes: Array<{
|
|
87
|
+
id: string;
|
|
88
|
+
title: string;
|
|
89
|
+
handle: string;
|
|
90
|
+
status: string;
|
|
91
|
+
priceRangeV2: {
|
|
92
|
+
minVariantPrice: {
|
|
93
|
+
amount: string;
|
|
94
|
+
currencyCode: string;
|
|
95
|
+
};
|
|
96
|
+
maxVariantPrice: {
|
|
97
|
+
amount: string;
|
|
98
|
+
currencyCode: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
}>;
|
|
102
|
+
pageInfo: {
|
|
103
|
+
hasNextPage: boolean;
|
|
104
|
+
endCursor: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
} | null;
|
|
108
|
+
}
|
|
109
|
+
export interface ProductCollectionsResponse {
|
|
110
|
+
product: {
|
|
111
|
+
id: string;
|
|
112
|
+
title: string;
|
|
113
|
+
collections: {
|
|
114
|
+
nodes: Array<{
|
|
115
|
+
id: string;
|
|
116
|
+
title: string;
|
|
117
|
+
handle: string;
|
|
118
|
+
}>;
|
|
119
|
+
pageInfo: {
|
|
120
|
+
hasNextPage: boolean;
|
|
121
|
+
endCursor: string;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
} | null;
|
|
125
|
+
}
|
|
126
|
+
export interface CollectionsListResponse {
|
|
127
|
+
collections: {
|
|
128
|
+
nodes: Array<{
|
|
129
|
+
id: string;
|
|
130
|
+
title: string;
|
|
131
|
+
handle: string;
|
|
132
|
+
productsCount: number;
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
}>;
|
|
135
|
+
pageInfo: {
|
|
136
|
+
hasNextPage: boolean;
|
|
137
|
+
endCursor: string;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* CLI command result type
|
|
143
|
+
*/
|
|
144
|
+
export interface CommandResult<T = any> {
|
|
145
|
+
success: boolean;
|
|
146
|
+
data?: T;
|
|
147
|
+
error?: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Collection ID normalization result
|
|
151
|
+
*/
|
|
152
|
+
export interface NormalizedId {
|
|
153
|
+
gid: string;
|
|
154
|
+
numeric: string;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/collection/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB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-0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/commands/collection/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection Utility Functions
|
|
3
|
+
* Pure functions for data transformation and validation
|
|
4
|
+
*/
|
|
5
|
+
import type { NormalizedId, FormattedCollection } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Normalize collection ID to both GID and numeric formats
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeCollectionId(id: string): NormalizedId;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize product ID to both GID and numeric formats
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizeProductId(id: string): NormalizedId;
|
|
14
|
+
/**
|
|
15
|
+
* Format collection for CLI output
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatCollection(collection: any): FormattedCollection;
|
|
18
|
+
/**
|
|
19
|
+
* Check if GraphQL response has errors
|
|
20
|
+
*/
|
|
21
|
+
export declare function hasGraphQLErrors(response: any): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Extract GraphQL error messages
|
|
24
|
+
*/
|
|
25
|
+
export declare function extractGraphQLErrors(response: any): string;
|
|
26
|
+
/**
|
|
27
|
+
* Format Shopify user errors
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatUserErrors(errors: Array<{
|
|
30
|
+
field?: string[];
|
|
31
|
+
message: string;
|
|
32
|
+
}>): string;
|
|
33
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/commands/collection/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAqB,MAAM,YAAY,CAAC;AAEvF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAY9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,CAY3D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,GAAG,GAAG,mBAAmB,CAcrE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAEvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,CAQ1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAW7F"}
|