ecomcoder-cli 1.3.2 → 1.3.4
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 +0 -23
- package/dist/cli.js +32 -5
- package/dist/cli.js.map +1 -1
- package/dist/commands/product/__tests__/update-description.test.js +1 -0
- package/dist/commands/product/__tests__/update-description.test.js.map +1 -1
- package/dist/commands/product/create-variants.d.ts +8 -0
- package/dist/commands/product/create-variants.d.ts.map +1 -0
- package/dist/commands/product/create-variants.js +160 -0
- package/dist/commands/product/create-variants.js.map +1 -0
- package/dist/commands/product/create.d.ts +8 -0
- package/dist/commands/product/create.d.ts.map +1 -0
- package/dist/commands/product/create.js +166 -0
- package/dist/commands/product/create.js.map +1 -0
- package/dist/commands/product/delete-variants.d.ts +8 -0
- package/dist/commands/product/delete-variants.d.ts.map +1 -0
- package/dist/commands/product/delete-variants.js +105 -0
- package/dist/commands/product/delete-variants.js.map +1 -0
- package/dist/commands/product/get-metafield.d.ts +8 -0
- package/dist/commands/product/get-metafield.d.ts.map +1 -0
- package/dist/commands/product/get-metafield.js +131 -0
- package/dist/commands/product/get-metafield.js.map +1 -0
- package/dist/commands/product/index.d.ts.map +1 -1
- package/dist/commands/product/index.js +62 -0
- package/dist/commands/product/index.js.map +1 -1
- package/dist/commands/product/queries.d.ts +31 -2
- package/dist/commands/product/queries.d.ts.map +1 -1
- package/dist/commands/product/queries.js +184 -0
- package/dist/commands/product/queries.js.map +1 -1
- package/dist/commands/product/service.d.ts +67 -1
- package/dist/commands/product/service.d.ts.map +1 -1
- package/dist/commands/product/service.js +363 -1
- package/dist/commands/product/service.js.map +1 -1
- package/dist/commands/product/set-metafield.d.ts +8 -0
- package/dist/commands/product/set-metafield.d.ts.map +1 -0
- package/dist/commands/product/set-metafield.js +174 -0
- package/dist/commands/product/set-metafield.js.map +1 -0
- package/dist/commands/product/types.d.ts +162 -0
- package/dist/commands/product/types.d.ts.map +1 -1
- package/dist/commands/product/update-status.d.ts +8 -0
- package/dist/commands/product/update-status.d.ts.map +1 -0
- package/dist/commands/product/update-status.js +105 -0
- package/dist/commands/product/update-status.js.map +1 -0
- package/dist/commands/product/utils.d.ts.map +1 -1
- package/dist/commands/product/utils.js +1 -0
- package/dist/commands/product/utils.js.map +1 -1
- package/dist/commands/products/index.d.ts.map +1 -1
- package/dist/commands/products/index.js +0 -10
- package/dist/commands/products/index.js.map +1 -1
- package/dist/commands/shop/get-metafield.d.ts +8 -0
- package/dist/commands/shop/get-metafield.d.ts.map +1 -0
- package/dist/commands/shop/get-metafield.js +117 -0
- package/dist/commands/shop/get-metafield.js.map +1 -0
- package/dist/commands/shop/index.d.ts +10 -0
- package/dist/commands/shop/index.d.ts.map +1 -0
- package/dist/commands/shop/index.js +61 -0
- package/dist/commands/shop/index.js.map +1 -0
- package/dist/commands/shop/queries.d.ts +24 -0
- package/dist/commands/shop/queries.d.ts.map +1 -0
- package/dist/commands/shop/queries.js +83 -0
- package/dist/commands/shop/queries.js.map +1 -0
- package/dist/commands/shop/service.d.ts +30 -0
- package/dist/commands/shop/service.d.ts.map +1 -0
- package/dist/commands/shop/service.js +131 -0
- package/dist/commands/shop/service.js.map +1 -0
- package/dist/commands/shop/set-metafield.d.ts +8 -0
- package/dist/commands/shop/set-metafield.d.ts.map +1 -0
- package/dist/commands/shop/set-metafield.js +174 -0
- package/dist/commands/shop/set-metafield.js.map +1 -0
- package/dist/commands/shop/types.d.ts +84 -0
- package/dist/commands/shop/types.d.ts.map +1 -0
- package/dist/commands/shop/types.js +6 -0
- package/dist/commands/shop/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/commands/shop/queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW,8DAMvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,sRAe9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,gXAmB/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,yVAmB1B,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphQL Queries and Mutations for Shop Operations
|
|
3
|
+
*
|
|
4
|
+
* Following Single Responsibility Principle - this module only contains GraphQL strings
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Get shop ID (needed for metafield mutations)
|
|
8
|
+
*/
|
|
9
|
+
export const GET_SHOP_ID = `
|
|
10
|
+
query getShopId {
|
|
11
|
+
shop {
|
|
12
|
+
id
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
/**
|
|
17
|
+
* Get specific shop metafield by namespace and key
|
|
18
|
+
*/
|
|
19
|
+
export const GET_SHOP_METAFIELD = `
|
|
20
|
+
query getShopMetafield($namespace: String!, $key: String!) {
|
|
21
|
+
shop {
|
|
22
|
+
id
|
|
23
|
+
metafield(namespace: $namespace, key: $key) {
|
|
24
|
+
id
|
|
25
|
+
namespace
|
|
26
|
+
key
|
|
27
|
+
value
|
|
28
|
+
type
|
|
29
|
+
createdAt
|
|
30
|
+
updatedAt
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
/**
|
|
36
|
+
* Get shop metafields (multiple)
|
|
37
|
+
* Used for querying all metafields or by namespace
|
|
38
|
+
*/
|
|
39
|
+
export const GET_SHOP_METAFIELDS = `
|
|
40
|
+
query getShopMetafields($namespace: String, $first: Int) {
|
|
41
|
+
shop {
|
|
42
|
+
id
|
|
43
|
+
metafields(namespace: $namespace, first: $first) {
|
|
44
|
+
edges {
|
|
45
|
+
node {
|
|
46
|
+
id
|
|
47
|
+
namespace
|
|
48
|
+
key
|
|
49
|
+
value
|
|
50
|
+
type
|
|
51
|
+
createdAt
|
|
52
|
+
updatedAt
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
/**
|
|
60
|
+
* Set metafield values for shop
|
|
61
|
+
* Maximum 25 metafields per request, atomic operation
|
|
62
|
+
*/
|
|
63
|
+
export const METAFIELDS_SET = `
|
|
64
|
+
mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) {
|
|
65
|
+
metafieldsSet(metafields: $metafields) {
|
|
66
|
+
metafields {
|
|
67
|
+
id
|
|
68
|
+
namespace
|
|
69
|
+
key
|
|
70
|
+
value
|
|
71
|
+
type
|
|
72
|
+
createdAt
|
|
73
|
+
updatedAt
|
|
74
|
+
}
|
|
75
|
+
userErrors {
|
|
76
|
+
field
|
|
77
|
+
message
|
|
78
|
+
code
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/commands/shop/queries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;CAM1B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;CAejC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;CAmBlC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;CAmB7B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shop Service - Business Logic Layer
|
|
3
|
+
*
|
|
4
|
+
* Following Service Layer Pattern - all shop business logic here
|
|
5
|
+
* Thin command handlers delegate to these methods
|
|
6
|
+
*/
|
|
7
|
+
import type { ShopifyCredentials } from '../../lib/types.js';
|
|
8
|
+
import { CommandResult, SetShopMetafieldInput, GetShopMetafieldInput } from './types.js';
|
|
9
|
+
export declare class ShopService {
|
|
10
|
+
/**
|
|
11
|
+
* Get shop ID
|
|
12
|
+
* Required for metafield mutations (ownerId)
|
|
13
|
+
*/
|
|
14
|
+
static getShopId(credentials: ShopifyCredentials): Promise<CommandResult<{
|
|
15
|
+
shopId: string;
|
|
16
|
+
}>>;
|
|
17
|
+
/**
|
|
18
|
+
* Set shop metafield value
|
|
19
|
+
*/
|
|
20
|
+
static setMetafield(credentials: ShopifyCredentials, input: SetShopMetafieldInput): Promise<CommandResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Get shop metafield(s)
|
|
23
|
+
* Supports:
|
|
24
|
+
* - Specific metafield (namespace + key)
|
|
25
|
+
* - All metafields in namespace (namespace only)
|
|
26
|
+
* - All metafields (no params)
|
|
27
|
+
*/
|
|
28
|
+
static getMetafield(credentials: ShopifyCredentials, input: GetShopMetafieldInput): Promise<CommandResult>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/commands/shop/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAO7D,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EAKtB,MAAM,YAAY,CAAC;AAEpB,qBAAa,WAAW;IACtB;;;OAGG;WACU,SAAS,CAAC,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAsBnG;;OAEG;WACU,YAAY,CACvB,WAAW,EAAE,kBAAkB,EAC/B,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,aAAa,CAAC;IAiEzB;;;;;;OAMG;WACU,YAAY,CACvB,WAAW,EAAE,kBAAkB,EAC/B,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,aAAa,CAAC;CAmD1B"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shop Service - Business Logic Layer
|
|
3
|
+
*
|
|
4
|
+
* Following Service Layer Pattern - all shop business logic here
|
|
5
|
+
* Thin command handlers delegate to these methods
|
|
6
|
+
*/
|
|
7
|
+
import { shopifyGraphQL } from '../../lib/shopify-client.js';
|
|
8
|
+
import { GET_SHOP_ID, GET_SHOP_METAFIELD, GET_SHOP_METAFIELDS, METAFIELDS_SET } from './queries.js';
|
|
9
|
+
export class ShopService {
|
|
10
|
+
/**
|
|
11
|
+
* Get shop ID
|
|
12
|
+
* Required for metafield mutations (ownerId)
|
|
13
|
+
*/
|
|
14
|
+
static async getShopId(credentials) {
|
|
15
|
+
const response = await shopifyGraphQL(credentials, GET_SHOP_ID, {});
|
|
16
|
+
if (!response.data?.shop) {
|
|
17
|
+
return {
|
|
18
|
+
success: false,
|
|
19
|
+
error: 'Shop not found'
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
success: true,
|
|
24
|
+
data: {
|
|
25
|
+
shopId: response.data.shop.id
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Set shop metafield value
|
|
31
|
+
*/
|
|
32
|
+
static async setMetafield(credentials, input) {
|
|
33
|
+
// Get shop ID first
|
|
34
|
+
const shopIdResult = await this.getShopId(credentials);
|
|
35
|
+
if (!shopIdResult.success || !shopIdResult.data) {
|
|
36
|
+
return {
|
|
37
|
+
success: false,
|
|
38
|
+
error: shopIdResult.error || 'Failed to get shop ID'
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const { shopId } = shopIdResult.data;
|
|
42
|
+
// Prepare metafield input
|
|
43
|
+
const metafieldInput = {
|
|
44
|
+
ownerId: shopId,
|
|
45
|
+
namespace: input.namespace,
|
|
46
|
+
key: input.key,
|
|
47
|
+
value: input.value,
|
|
48
|
+
type: input.type
|
|
49
|
+
};
|
|
50
|
+
// Execute mutation
|
|
51
|
+
const response = await shopifyGraphQL(credentials, METAFIELDS_SET, { metafields: [metafieldInput] });
|
|
52
|
+
// Check for user errors
|
|
53
|
+
const userErrors = response.data?.metafieldsSet?.userErrors || [];
|
|
54
|
+
if (userErrors.length > 0) {
|
|
55
|
+
const errors = userErrors
|
|
56
|
+
.map((e) => e.message)
|
|
57
|
+
.join(', ');
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
error: `GraphQL errors: ${errors}`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Return the set metafield
|
|
64
|
+
const metafield = response.data?.metafieldsSet?.metafields?.[0];
|
|
65
|
+
if (!metafield) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
error: 'No metafield returned from mutation'
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
success: true,
|
|
73
|
+
data: {
|
|
74
|
+
metafield: {
|
|
75
|
+
id: metafield.id,
|
|
76
|
+
namespace: metafield.namespace,
|
|
77
|
+
key: metafield.key,
|
|
78
|
+
value: metafield.value,
|
|
79
|
+
type: metafield.type,
|
|
80
|
+
createdAt: metafield.createdAt,
|
|
81
|
+
updatedAt: metafield.updatedAt
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get shop metafield(s)
|
|
88
|
+
* Supports:
|
|
89
|
+
* - Specific metafield (namespace + key)
|
|
90
|
+
* - All metafields in namespace (namespace only)
|
|
91
|
+
* - All metafields (no params)
|
|
92
|
+
*/
|
|
93
|
+
static async getMetafield(credentials, input) {
|
|
94
|
+
// If both namespace and key provided, get specific metafield
|
|
95
|
+
if (input.namespace && input.key) {
|
|
96
|
+
const response = await shopifyGraphQL(credentials, GET_SHOP_METAFIELD, { namespace: input.namespace, key: input.key });
|
|
97
|
+
if (!response.data?.shop) {
|
|
98
|
+
return {
|
|
99
|
+
success: false,
|
|
100
|
+
error: 'Shop not found'
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
success: true,
|
|
105
|
+
data: {
|
|
106
|
+
metafield: response.data.shop.metafield
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// Otherwise, get multiple metafields
|
|
111
|
+
const response = await shopifyGraphQL(credentials, GET_SHOP_METAFIELDS, {
|
|
112
|
+
namespace: input.namespace || undefined,
|
|
113
|
+
first: 250 // Maximum allowed
|
|
114
|
+
});
|
|
115
|
+
if (!response.data?.shop) {
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
error: 'Shop not found'
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const metafields = response.data.shop.metafields.edges.map((edge) => edge.node);
|
|
122
|
+
return {
|
|
123
|
+
success: true,
|
|
124
|
+
data: {
|
|
125
|
+
metafields,
|
|
126
|
+
count: metafields.length
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/commands/shop/service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACf,MAAM,cAAc,CAAC;AAWtB,MAAM,OAAO,WAAW;IACtB;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,WAA+B;QACpD,MAAM,QAAQ,GAAG,MAAM,cAAc,CACnC,WAAW,EACX,WAAW,EACX,EAAE,CACH,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,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ACJ,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,IAAI,EAAE;oBACJ,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS;iBACxC;aACF,CAAC;QACJ,CAAC;QAED,qCAAqC;QACrC,MAAM,QAAQ,GAAG,MAAM,cAAc,CACnC,WAAW,EACX,mBAAmB,EACnB;YACE,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS;YACvC,KAAK,EAAE,GAAG,CAAC,kBAAkB;SAC9B,CACF,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;YACzB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,gBAAgB;aACxB,CAAC;QACJ,CAAC;QAED,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErF,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE;gBACJ,UAAU;gBACV,KAAK,EAAE,UAAU,CAAC,MAAM;aACzB;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-metafield.d.ts","sourceRoot":"","sources":["../../../src/commands/shop/set-metafield.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmIH,wBAAsB,GAAG,CAAC,IAAI,GAAE,MAAM,EAA0B,iBA6C/D"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set Shop Metafield Command
|
|
3
|
+
*
|
|
4
|
+
* Following Command Pattern - thin orchestration layer
|
|
5
|
+
* Delegates business logic to ShopService
|
|
6
|
+
*/
|
|
7
|
+
import { getCredentials, getSessionId } from '../../lib/api-client.js';
|
|
8
|
+
import { parseArgs, hasHelpFlag } from '../../lib/args-parser.js';
|
|
9
|
+
import { ShopService } from './service.js';
|
|
10
|
+
function showHelp() {
|
|
11
|
+
console.log(`
|
|
12
|
+
Set Shop Metafield
|
|
13
|
+
|
|
14
|
+
USAGE:
|
|
15
|
+
ecomcoder shop set-metafield [OPTIONS]
|
|
16
|
+
|
|
17
|
+
REQUIRED OPTIONS:
|
|
18
|
+
--namespace <namespace> Metafield namespace (e.g., 'custom', 'app')
|
|
19
|
+
--key <key> Metafield key/identifier
|
|
20
|
+
--value <value> Metafield value (format depends on type)
|
|
21
|
+
--type <type> Metafield type (see list below)
|
|
22
|
+
|
|
23
|
+
OPTIONAL:
|
|
24
|
+
--session-id Session ID (auto-provided via SESSION_ID env var)
|
|
25
|
+
--help, -h Show this help message
|
|
26
|
+
|
|
27
|
+
SUPPORTED TYPES:
|
|
28
|
+
Text:
|
|
29
|
+
single_line_text_field Single line of text
|
|
30
|
+
multi_line_text_field Multiple lines of text
|
|
31
|
+
rich_text_field Rich text with formatting
|
|
32
|
+
|
|
33
|
+
Numbers:
|
|
34
|
+
number_integer Whole numbers
|
|
35
|
+
number_decimal Decimal numbers
|
|
36
|
+
rating Rating on a scale
|
|
37
|
+
|
|
38
|
+
Boolean:
|
|
39
|
+
boolean True or false value
|
|
40
|
+
|
|
41
|
+
Dates:
|
|
42
|
+
date ISO 8601 date (YYYY-MM-DD)
|
|
43
|
+
date_time ISO 8601 timestamp
|
|
44
|
+
|
|
45
|
+
Measurements:
|
|
46
|
+
dimension Length with unit
|
|
47
|
+
volume Volume with unit
|
|
48
|
+
weight Weight with unit
|
|
49
|
+
|
|
50
|
+
Commerce:
|
|
51
|
+
money Amount with currency
|
|
52
|
+
color Hexadecimal color code
|
|
53
|
+
|
|
54
|
+
References (Links to Shopify Resources):
|
|
55
|
+
product_reference Link to a product
|
|
56
|
+
variant_reference Link to a variant
|
|
57
|
+
collection_reference Link to a collection
|
|
58
|
+
page_reference Link to a page
|
|
59
|
+
file_reference Link to uploaded file
|
|
60
|
+
|
|
61
|
+
Other:
|
|
62
|
+
url URL (https, http, mailto, sms, tel)
|
|
63
|
+
json JSON-serializable value
|
|
64
|
+
link Text and URL pairing
|
|
65
|
+
|
|
66
|
+
Lists (prefix with 'list.'):
|
|
67
|
+
list.single_line_text_field
|
|
68
|
+
list.number_integer
|
|
69
|
+
list.product_reference
|
|
70
|
+
list.color
|
|
71
|
+
(etc. - all types support lists)
|
|
72
|
+
|
|
73
|
+
EXAMPLES:
|
|
74
|
+
# Store-wide announcement
|
|
75
|
+
ecomcoder shop set-metafield \\
|
|
76
|
+
--namespace=custom \\
|
|
77
|
+
--key=announcement \\
|
|
78
|
+
--value="Black Friday Sale!" \\
|
|
79
|
+
--type=single_line_text_field
|
|
80
|
+
|
|
81
|
+
# Free shipping minimum
|
|
82
|
+
ecomcoder shop set-metafield \\
|
|
83
|
+
--namespace=custom \\
|
|
84
|
+
--key=free_shipping_min \\
|
|
85
|
+
--value="50.00" \\
|
|
86
|
+
--type=number_decimal
|
|
87
|
+
|
|
88
|
+
# Featured products (global)
|
|
89
|
+
ecomcoder shop set-metafield \\
|
|
90
|
+
--namespace=custom \\
|
|
91
|
+
--key=featured_products \\
|
|
92
|
+
--value='["gid://shopify/Product/123","gid://shopify/Product/456"]' \\
|
|
93
|
+
--type=list.product_reference
|
|
94
|
+
|
|
95
|
+
# Store settings as JSON
|
|
96
|
+
ecomcoder shop set-metafield \\
|
|
97
|
+
--namespace=custom \\
|
|
98
|
+
--key=settings \\
|
|
99
|
+
--value='{"theme":"dark","currency":"USD"}' \\
|
|
100
|
+
--type=json
|
|
101
|
+
|
|
102
|
+
# Enable feature flag
|
|
103
|
+
ecomcoder shop set-metafield \\
|
|
104
|
+
--namespace=features \\
|
|
105
|
+
--key=show_reviews \\
|
|
106
|
+
--value="true" \\
|
|
107
|
+
--type=boolean
|
|
108
|
+
|
|
109
|
+
OUTPUT FORMAT:
|
|
110
|
+
{
|
|
111
|
+
"success": true,
|
|
112
|
+
"data": {
|
|
113
|
+
"metafield": {
|
|
114
|
+
"id": "gid://shopify/Metafield/123",
|
|
115
|
+
"namespace": "custom",
|
|
116
|
+
"key": "announcement",
|
|
117
|
+
"value": "Black Friday Sale!",
|
|
118
|
+
"type": "single_line_text_field",
|
|
119
|
+
"createdAt": "2024-01-20T10:30:00Z",
|
|
120
|
+
"updatedAt": "2024-01-20T15:45:00Z"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
NOTES:
|
|
126
|
+
- Maximum 25 metafields per request
|
|
127
|
+
- Maximum 10MB total payload size
|
|
128
|
+
- All values stored as strings (validated by type)
|
|
129
|
+
- Reference types use GID format: gid://shopify/Resource/ID
|
|
130
|
+
- List values must be valid JSON arrays
|
|
131
|
+
`);
|
|
132
|
+
process.exit(0);
|
|
133
|
+
}
|
|
134
|
+
export async function run(argv = process.argv.slice(2)) {
|
|
135
|
+
if (hasHelpFlag(argv)) {
|
|
136
|
+
showHelp();
|
|
137
|
+
}
|
|
138
|
+
const args = parseArgs(argv);
|
|
139
|
+
// Validate required arguments
|
|
140
|
+
const requiredArgs = ['namespace', 'key', 'value', 'type'];
|
|
141
|
+
const missing = requiredArgs.filter(arg => !args[arg]);
|
|
142
|
+
if (missing.length > 0) {
|
|
143
|
+
console.error(JSON.stringify({
|
|
144
|
+
success: false,
|
|
145
|
+
error: `Missing required arguments: ${missing.map(a => `--${a}`).join(', ')}`
|
|
146
|
+
}));
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
// Get credentials
|
|
151
|
+
const sessionId = getSessionId(args.sessionId);
|
|
152
|
+
const credentials = await getCredentials(sessionId, args.backendUrl, args.jwt);
|
|
153
|
+
// Execute set metafield via service
|
|
154
|
+
const result = await ShopService.setMetafield(credentials, {
|
|
155
|
+
namespace: args.namespace,
|
|
156
|
+
key: args.key,
|
|
157
|
+
value: args.value,
|
|
158
|
+
type: args.type
|
|
159
|
+
});
|
|
160
|
+
// Output result
|
|
161
|
+
console.log(JSON.stringify(result, null, 2));
|
|
162
|
+
if (!result.success) {
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
console.error(JSON.stringify({
|
|
168
|
+
success: false,
|
|
169
|
+
error: error.message || 'Unknown error occurred'
|
|
170
|
+
}));
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=set-metafield.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-metafield.js","sourceRoot":"","sources":["../../../src/commands/shop/set-metafield.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,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,SAAS,QAAQ;IACf,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwHb,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,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3D,MAAM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B,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,wBAAwB;SACjD,CAAC,CAAC,CAAC;QACJ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shop Command Types
|
|
3
|
+
* Type definitions for shop-related commands
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Shop metafield operations
|
|
7
|
+
*/
|
|
8
|
+
export interface SetShopMetafieldInput {
|
|
9
|
+
namespace: string;
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
type: string;
|
|
13
|
+
}
|
|
14
|
+
export interface GetShopMetafieldInput {
|
|
15
|
+
namespace?: string;
|
|
16
|
+
key?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Shopify GraphQL response types
|
|
20
|
+
*/
|
|
21
|
+
export interface ShopMetafieldResponse {
|
|
22
|
+
shop: {
|
|
23
|
+
id: string;
|
|
24
|
+
metafield: {
|
|
25
|
+
id: string;
|
|
26
|
+
namespace: string;
|
|
27
|
+
key: string;
|
|
28
|
+
value: string;
|
|
29
|
+
type: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
} | null;
|
|
33
|
+
} | null;
|
|
34
|
+
}
|
|
35
|
+
export interface ShopMetafieldsResponse {
|
|
36
|
+
shop: {
|
|
37
|
+
id: string;
|
|
38
|
+
metafields: {
|
|
39
|
+
edges: Array<{
|
|
40
|
+
node: {
|
|
41
|
+
id: string;
|
|
42
|
+
namespace: string;
|
|
43
|
+
key: string;
|
|
44
|
+
value: string;
|
|
45
|
+
type: string;
|
|
46
|
+
createdAt: string;
|
|
47
|
+
updatedAt: string;
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
} | null;
|
|
52
|
+
}
|
|
53
|
+
export interface MetafieldsSetResponse {
|
|
54
|
+
metafieldsSet: {
|
|
55
|
+
metafields: Array<{
|
|
56
|
+
id: string;
|
|
57
|
+
namespace: string;
|
|
58
|
+
key: string;
|
|
59
|
+
value: string;
|
|
60
|
+
type: string;
|
|
61
|
+
createdAt: string;
|
|
62
|
+
updatedAt: string;
|
|
63
|
+
}>;
|
|
64
|
+
userErrors: Array<{
|
|
65
|
+
field: string[] | null;
|
|
66
|
+
message: string;
|
|
67
|
+
code?: string;
|
|
68
|
+
}>;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface ShopIdResponse {
|
|
72
|
+
shop: {
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* CLI command result types
|
|
78
|
+
*/
|
|
79
|
+
export interface CommandResult<T = any> {
|
|
80
|
+
success: boolean;
|
|
81
|
+
data?: T;
|
|
82
|
+
error?: string;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/shop/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE;YACT,EAAE,EAAE,MAAM,CAAC;YACX,SAAS,EAAE,MAAM,CAAC;YAClB,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAA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