@foxtware/mineral 0.1.16 → 0.1.18
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/.creds.yml.sample +16 -7
- package/AGENTS.md +3 -0
- package/_build_scripts/publish.js +15 -1
- package/api/backblaze/backblaze.constants.js +11 -0
- package/api/backblaze/backblaze.utils.js +322 -0
- package/api/backblaze/backblazeBucketsGet.js +68 -0
- package/api/backblaze/backblazeFileDelete.js +62 -0
- package/api/backblaze/backblazeFileHide.js +62 -0
- package/api/backblaze/backblazeFileUpload.js +142 -0
- package/api/backblaze/backblazeFilesGet.js +85 -0
- package/api/backblaze/backblazeGet.js +139 -0
- package/api/backblaze/docs.md +6 -0
- package/api/etsy/etsyListingInventoryUpdate.js +11 -11
- package/api/etsy/etsyListingUpdate.js +1 -1
- package/api/gorgias/gorgias.constants.js +8 -0
- package/api/gorgias/gorgias.utils.js +46 -0
- package/api/gorgias/gorgiasAccountGet.js +51 -0
- package/api/gorgias/gorgiasCustomerGet.js +70 -0
- package/api/gorgias/gorgiasCustomersGet.js +56 -0
- package/api/gorgias/gorgiasGet.js +150 -0
- package/api/gorgias/gorgiasGetSingle.js +26 -0
- package/api/gorgias/gorgiasMessagesGet.js +56 -0
- package/api/gorgias/gorgiasTagsGet.js +52 -0
- package/api/gorgias/gorgiasTicketCreate.js +66 -0
- package/api/gorgias/gorgiasTicketGet.js +70 -0
- package/api/gorgias/gorgiasTicketMessageCreate.js +65 -0
- package/api/gorgias/gorgiasTicketMessagesGet.js +66 -0
- package/api/gorgias/gorgiasTicketUpdate.js +62 -0
- package/api/gorgias/gorgiasTicketsGet.js +58 -0
- package/api/gorgias/gorgiasUsersGet.js +52 -0
- package/api/gorgias/gorgiasViewItemsGet.js +57 -0
- package/api/gorgias/gorgiasViewsGet.js +72 -0
- package/api/linear/docs.md +6 -0
- package/api/linear/linear.constants.js +3 -0
- package/api/linear/linear.utils.js +59 -0
- package/api/linear/linearAttachmentCreate.js +77 -0
- package/api/linear/linearAttachmentDelete.js +68 -0
- package/api/linear/linearCommentCreate.js +77 -0
- package/api/linear/linearCommentDelete.js +68 -0
- package/api/linear/linearCommentGet.js +77 -0
- package/api/linear/linearCommentUpdate.js +87 -0
- package/api/linear/linearCommentsGet.js +70 -0
- package/api/linear/linearCyclesGet.js +67 -0
- package/api/linear/linearGet.js +218 -0
- package/api/linear/linearIssueAddLabel.js +77 -0
- package/api/linear/linearIssueArchive.js +74 -0
- package/api/linear/linearIssueCreate.js +94 -0
- package/api/linear/linearIssueDelete.js +74 -0
- package/api/linear/linearIssueGet.js +87 -0
- package/api/linear/linearIssueLabelCreate.js +81 -0
- package/api/linear/linearIssueLabelsGet.js +66 -0
- package/api/linear/linearIssueRemoveLabel.js +77 -0
- package/api/linear/linearIssueUpdate.js +96 -0
- package/api/linear/linearIssuesGet.js +39 -63
- package/api/linear/linearOrganizationGet.js +64 -0
- package/api/linear/linearProjectCreate.js +92 -0
- package/api/linear/linearProjectGet.js +74 -0
- package/api/linear/linearProjectUpdate.js +80 -0
- package/api/linear/linearProjectsGet.js +71 -0
- package/api/linear/linearTeamGet.js +71 -0
- package/api/linear/linearTeamsGet.js +66 -0
- package/api/linear/linearUserGet.js +72 -0
- package/api/linear/linearUsersGet.js +71 -0
- package/api/linear/linearViewerGet.js +65 -0
- package/api/linear/linearWebhookCreate.js +77 -0
- package/api/linear/linearWebhookDelete.js +68 -0
- package/api/linear/linearWebhooksGet.js +67 -0
- package/api/linear/linearWorkflowStatesGet.js +73 -0
- package/api/pipe17/pipe17.utils.js +7 -20
- package/api/pipe17/pipe17ArrivalGet.js +1 -1
- package/api/pipe17/pipe17FulfillmentGet.js +1 -1
- package/api/pipe17/pipe17InventoryItemGet.js +1 -1
- package/api/pipe17/pipe17JobGet.js +11 -24
- package/api/pipe17/pipe17LocationGet.js +1 -1
- package/api/pipe17/pipe17OrderGet.js +1 -1
- package/api/pipe17/pipe17ProductGet.js +1 -1
- package/api/pipe17/pipe17PurchaseGet.js +1 -1
- package/api/pipe17/pipe17ReceiptGet.js +1 -1
- package/api/pipe17/pipe17ReturnGet.js +1 -1
- package/api/shopify/shopifyFileCreate.js +107 -0
- package/api/shopify/shopifyMetafieldDefinitionCreate.js +2 -0
- package/api/shopify/shopifyMetafieldDefinitionGet.js +108 -0
- package/api/shopify/shopifyMetafieldDefinitionPropagate.js +167 -0
- package/api/shopify/shopifyThemeFileGet.js +112 -0
- package/api/shopify/shopifyThemeFilePropagate.js +410 -0
- package/api/shopify/shopifyThemeFilesUpsert.js +88 -0
- package/api/starshipit/starshipit.utils.js +1 -0
- package/api/starshipit/starshipitOrderGet.js +2 -10
- package/api/utils.js +12 -4
- package/hosting/deployFromHostingYml.js +2 -2
- package/hosting/execCommand.js +19 -2
- package/package.json +1 -1
- package/server.utils.js +1 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/metafieldDefinition
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
5
|
+
const { shopifyClient } = require('./shopify.utils');
|
|
6
|
+
|
|
7
|
+
const metafieldDefinitionIdentifierValidator = (metafieldDefinitionIdentifier) => {
|
|
8
|
+
return objHasAny(metafieldDefinitionIdentifier, [
|
|
9
|
+
'ownerType',
|
|
10
|
+
'namespace',
|
|
11
|
+
'key',
|
|
12
|
+
]);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const argsWarden = new ArgsWarden([
|
|
16
|
+
['credsPayload', credsValidator],
|
|
17
|
+
['metafieldDefinitionIdentifier', metafieldDefinitionIdentifierValidator],
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
const defaultAttrs = `
|
|
21
|
+
name
|
|
22
|
+
namespace
|
|
23
|
+
key
|
|
24
|
+
description
|
|
25
|
+
ownerType
|
|
26
|
+
pinnedPosition
|
|
27
|
+
type {
|
|
28
|
+
name
|
|
29
|
+
}
|
|
30
|
+
validations {
|
|
31
|
+
name
|
|
32
|
+
value
|
|
33
|
+
}
|
|
34
|
+
capabilities {
|
|
35
|
+
adminFilterable {
|
|
36
|
+
enabled
|
|
37
|
+
}
|
|
38
|
+
smartCollectionCondition {
|
|
39
|
+
enabled
|
|
40
|
+
}
|
|
41
|
+
uniqueValues {
|
|
42
|
+
enabled
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`.trim();
|
|
46
|
+
|
|
47
|
+
const shopifyMetafieldDefinitionGet = async (
|
|
48
|
+
credsPayload,
|
|
49
|
+
metafieldDefinitionIdentifier,
|
|
50
|
+
{
|
|
51
|
+
apiVersion,
|
|
52
|
+
attrs = defaultAttrs,
|
|
53
|
+
} = {},
|
|
54
|
+
) => {
|
|
55
|
+
|
|
56
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
57
|
+
credsPayload,
|
|
58
|
+
metafieldDefinitionIdentifier,
|
|
59
|
+
});
|
|
60
|
+
if (rejectResponse) {
|
|
61
|
+
return rejectResponse;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return shopifyClient.fetch({
|
|
65
|
+
requestPayload: {
|
|
66
|
+
method: 'post',
|
|
67
|
+
body: {
|
|
68
|
+
query: `
|
|
69
|
+
query GetMetafieldDefinition($identifier: MetafieldDefinitionIdentifierInput!) {
|
|
70
|
+
metafieldDefinition(identifier: $identifier) {
|
|
71
|
+
${ attrs }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`,
|
|
75
|
+
variables: {
|
|
76
|
+
identifier: metafieldDefinitionIdentifier,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
context: {
|
|
81
|
+
credsPayload,
|
|
82
|
+
apiVersion,
|
|
83
|
+
resultPath: 'data.metafieldDefinition',
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const funcApiConfig = {
|
|
89
|
+
argsWarden,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
shopifyMetafieldDefinitionGet,
|
|
94
|
+
funcApiConfig,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
curl -X POST "http://localhost:8000/shopifyMetafieldDefinitionGet" \
|
|
99
|
+
-H "Content-Type: application/json" \
|
|
100
|
+
-d '{
|
|
101
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
102
|
+
"metafieldDefinitionIdentifier": {
|
|
103
|
+
"ownerType": "PRODUCT",
|
|
104
|
+
"namespace": "custom",
|
|
105
|
+
"key": "outfit_builder_image"
|
|
106
|
+
}
|
|
107
|
+
}'
|
|
108
|
+
*/
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/metafieldDefinitionCreate
|
|
2
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/metafieldDefinition
|
|
3
|
+
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
6
|
+
const { shopifyMetafieldDefinitionGet } = require('./shopifyMetafieldDefinitionGet');
|
|
7
|
+
const { shopifyMetafieldDefinitionCreate } = require('./shopifyMetafieldDefinitionCreate');
|
|
8
|
+
|
|
9
|
+
const defaultReturnCreatedDefinitionAttrs = 'id name namespace key ownerType type { name }';
|
|
10
|
+
|
|
11
|
+
const metafieldDefinitionIdentifierValidator = (metafieldDefinitionIdentifier) => {
|
|
12
|
+
return objHasAny(metafieldDefinitionIdentifier, [
|
|
13
|
+
'ownerType',
|
|
14
|
+
'namespace',
|
|
15
|
+
'key',
|
|
16
|
+
]);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const argsWarden = new ArgsWarden([
|
|
20
|
+
['fromStoreCredsPayload', credsValidator],
|
|
21
|
+
['toStoreCredsPayload', credsValidator],
|
|
22
|
+
['metafieldDefinitionIdentifier', metafieldDefinitionIdentifierValidator],
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
const metafieldDefinitionInputFromDefinition = (sourceDefinition) => {
|
|
26
|
+
const {
|
|
27
|
+
name,
|
|
28
|
+
namespace,
|
|
29
|
+
key,
|
|
30
|
+
description,
|
|
31
|
+
ownerType,
|
|
32
|
+
type,
|
|
33
|
+
validations,
|
|
34
|
+
capabilities,
|
|
35
|
+
pinnedPosition,
|
|
36
|
+
} = sourceDefinition;
|
|
37
|
+
|
|
38
|
+
const definitionInput = {
|
|
39
|
+
name,
|
|
40
|
+
namespace,
|
|
41
|
+
key,
|
|
42
|
+
ownerType,
|
|
43
|
+
type: type?.name,
|
|
44
|
+
...(description && { description }),
|
|
45
|
+
...(pinnedPosition != null && { pin: true }),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (Array.isArray(validations) && validations.length) {
|
|
49
|
+
definitionInput.validations = validations.map(({ name: validationName, value }) => ({
|
|
50
|
+
name: validationName,
|
|
51
|
+
value,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (capabilities) {
|
|
56
|
+
definitionInput.capabilities = {
|
|
57
|
+
...(capabilities.adminFilterable && {
|
|
58
|
+
adminFilterable: { enabled: capabilities.adminFilterable.enabled },
|
|
59
|
+
}),
|
|
60
|
+
...(capabilities.smartCollectionCondition && {
|
|
61
|
+
smartCollectionCondition: { enabled: capabilities.smartCollectionCondition.enabled },
|
|
62
|
+
}),
|
|
63
|
+
...(capabilities.uniqueValues && {
|
|
64
|
+
uniqueValues: { enabled: capabilities.uniqueValues.enabled },
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return definitionInput;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const shopifyMetafieldDefinitionPropagate = async (
|
|
73
|
+
fromStoreCredsPayload,
|
|
74
|
+
toStoreCredsPayload,
|
|
75
|
+
metafieldDefinitionIdentifier,
|
|
76
|
+
{
|
|
77
|
+
apiVersion,
|
|
78
|
+
returnCreatedDefinitionAttrs = defaultReturnCreatedDefinitionAttrs,
|
|
79
|
+
} = {},
|
|
80
|
+
) => {
|
|
81
|
+
|
|
82
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
83
|
+
fromStoreCredsPayload,
|
|
84
|
+
toStoreCredsPayload,
|
|
85
|
+
metafieldDefinitionIdentifier,
|
|
86
|
+
});
|
|
87
|
+
if (rejectResponse) {
|
|
88
|
+
return rejectResponse;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const sourceResponse = await shopifyMetafieldDefinitionGet(
|
|
92
|
+
fromStoreCredsPayload,
|
|
93
|
+
metafieldDefinitionIdentifier,
|
|
94
|
+
{ apiVersion },
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
if (!sourceResponse.ok) {
|
|
98
|
+
return sourceResponse;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!sourceResponse.data) {
|
|
102
|
+
return {
|
|
103
|
+
ok: false,
|
|
104
|
+
error: {
|
|
105
|
+
code: 'NOT_FOUND',
|
|
106
|
+
message: 'Metafield definition not found on source store.',
|
|
107
|
+
details: metafieldDefinitionIdentifier,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const definitionInput = metafieldDefinitionInputFromDefinition(sourceResponse.data);
|
|
113
|
+
|
|
114
|
+
const {
|
|
115
|
+
ownerType,
|
|
116
|
+
namespace,
|
|
117
|
+
key,
|
|
118
|
+
name,
|
|
119
|
+
type,
|
|
120
|
+
description,
|
|
121
|
+
pin,
|
|
122
|
+
validations,
|
|
123
|
+
capabilities,
|
|
124
|
+
} = definitionInput;
|
|
125
|
+
|
|
126
|
+
return shopifyMetafieldDefinitionCreate(
|
|
127
|
+
toStoreCredsPayload,
|
|
128
|
+
ownerType,
|
|
129
|
+
namespace,
|
|
130
|
+
key,
|
|
131
|
+
name,
|
|
132
|
+
type,
|
|
133
|
+
{
|
|
134
|
+
apiVersion,
|
|
135
|
+
...(description && { description }),
|
|
136
|
+
...(pin != null && { pin }),
|
|
137
|
+
...(validations && { validations }),
|
|
138
|
+
...(capabilities && { capabilities }),
|
|
139
|
+
returnSchema: `
|
|
140
|
+
createdDefinition { ${ returnCreatedDefinitionAttrs } }
|
|
141
|
+
`.trim(),
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const funcApiConfig = {
|
|
147
|
+
argsWarden,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
module.exports = {
|
|
151
|
+
shopifyMetafieldDefinitionPropagate,
|
|
152
|
+
funcApiConfig,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/*
|
|
156
|
+
curl -X POST "http://localhost:8000/shopifyMetafieldDefinitionPropagate" \
|
|
157
|
+
-H "Content-Type: application/json" \
|
|
158
|
+
-d '{
|
|
159
|
+
"fromStoreCredsPayload": { "credsPath": "shopify.au" },
|
|
160
|
+
"toStoreCredsPayload": { "credsPath": "shopify.us" },
|
|
161
|
+
"metafieldDefinitionIdentifier": {
|
|
162
|
+
"ownerType": "PRODUCT",
|
|
163
|
+
"namespace": "custom",
|
|
164
|
+
"key": "outfit_builder_image"
|
|
165
|
+
}
|
|
166
|
+
}'
|
|
167
|
+
*/
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/theme
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, ensureArray } = require('../utils');
|
|
5
|
+
const { shopifyClient } = require('./shopify.utils');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = `
|
|
8
|
+
filename
|
|
9
|
+
contentType
|
|
10
|
+
size
|
|
11
|
+
body {
|
|
12
|
+
... on OnlineStoreThemeFileBodyText {
|
|
13
|
+
content
|
|
14
|
+
}
|
|
15
|
+
... on OnlineStoreThemeFileBodyBase64 {
|
|
16
|
+
contentBase64
|
|
17
|
+
}
|
|
18
|
+
... on OnlineStoreThemeFileBodyUrl {
|
|
19
|
+
url
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`.trim();
|
|
23
|
+
|
|
24
|
+
const argsWarden = new ArgsWarden([
|
|
25
|
+
['credsPayload', credsValidator],
|
|
26
|
+
['themeId'],
|
|
27
|
+
['filenames'],
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
const shopifyThemeFileGet = async (
|
|
31
|
+
credsPayload,
|
|
32
|
+
themeId,
|
|
33
|
+
filenames,
|
|
34
|
+
{
|
|
35
|
+
apiVersion,
|
|
36
|
+
attrs = defaultAttrs,
|
|
37
|
+
} = {},
|
|
38
|
+
) => {
|
|
39
|
+
|
|
40
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
41
|
+
credsPayload,
|
|
42
|
+
themeId,
|
|
43
|
+
filenames,
|
|
44
|
+
});
|
|
45
|
+
if (rejectResponse) {
|
|
46
|
+
return rejectResponse;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const filenamesList = ensureArray(filenames);
|
|
50
|
+
|
|
51
|
+
const response = await shopifyClient.fetch({
|
|
52
|
+
requestPayload: {
|
|
53
|
+
method: 'post',
|
|
54
|
+
body: {
|
|
55
|
+
query: `
|
|
56
|
+
query ThemeFiles($themeId: ID!, $filenames: [String!]!) {
|
|
57
|
+
theme(id: $themeId) {
|
|
58
|
+
files(filenames: $filenames) {
|
|
59
|
+
nodes {
|
|
60
|
+
${ attrs }
|
|
61
|
+
}
|
|
62
|
+
userErrors {
|
|
63
|
+
code
|
|
64
|
+
filename
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`,
|
|
70
|
+
variables: {
|
|
71
|
+
themeId: `gid://shopify/OnlineStoreTheme/${ themeId }`,
|
|
72
|
+
filenames: filenamesList,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
context: {
|
|
77
|
+
credsPayload,
|
|
78
|
+
apiVersion,
|
|
79
|
+
resultPath: 'data.theme.files',
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (!response.ok) {
|
|
84
|
+
return response;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// stripEdgesAndNodes turns files.nodes into an array (userErrors on the
|
|
88
|
+
// connection are dropped by the shared Shopify client pipeline).
|
|
89
|
+
return {
|
|
90
|
+
ok: true,
|
|
91
|
+
data: ensureArray(response.data),
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const funcApiConfig = {
|
|
96
|
+
argsWarden,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
module.exports = {
|
|
100
|
+
shopifyThemeFileGet,
|
|
101
|
+
funcApiConfig,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
curl -X POST "http://localhost:8000/shopifyThemeFileGet" \
|
|
106
|
+
-H "Content-Type: application/json" \
|
|
107
|
+
-d '{
|
|
108
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
109
|
+
"themeId": "129840808008",
|
|
110
|
+
"filenames": "templates/page.sign_up_beauty.json"
|
|
111
|
+
}'
|
|
112
|
+
*/
|