@foxtware/mineral 0.1.0 → 0.1.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/.creds.yml.sample +5 -0
- package/README.md +1 -1
- package/_build_scripts/publish.js +85 -0
- package/api/logiwa/logiwa.constants.js +8 -0
- package/api/logiwa/logiwa.utils.js +53 -0
- package/api/logiwa/logiwaAuthGet.js +86 -0
- package/api/logiwa/logiwaInventoriesGet.js +67 -0
- package/api/logiwa/logiwaOrderGet.js +54 -0
- package/api/logiwa/logiwaOrdersGet.js +92 -0
- package/api/logiwa/logiwaProductGet.js +54 -0
- package/api/logiwa/logiwaProductsGet.js +80 -0
- package/api/logiwa/logiwaReportGetAvailableToPromise.js +179 -0
- package/api/logiwa/logiwaReportGetInventoryCalculation.js +62 -0
- package/api/logiwa/logiwaReportGetInventorySnapshot.js +66 -0
- package/api/logiwa/logiwaReportGetTotalInventory.js +72 -0
- package/api/logiwa/logiwaWebhookStatusGet.js +54 -0
- package/api/logiwa/logiwaWebhookSubscribe.js +64 -0
- package/api/logiwa/logiwaWebhookUnsubscribe.js +54 -0
- package/api/logiwa/logiwaWebhooksGet.js +48 -0
- package/api/shopify/_example.get.js +46 -0
- package/api/shopify/shopifyAbandonedCheckoutsGet.js +46 -0
- package/api/shopify/shopifyArticlesGet.js +46 -0
- package/api/shopify/shopifyBlogsGet.js +46 -0
- package/api/shopify/shopifyBulkOperationsGet.js +46 -0
- package/api/shopify/shopifyCatalogsGet.js +46 -0
- package/api/shopify/shopifyChannelsGet.js +46 -0
- package/api/shopify/shopifyCheckoutAndAccountsConfigurationsGet.js +46 -0
- package/api/shopify/shopifyCollectionsGet.js +46 -0
- package/api/shopify/shopifyCustomersGet.js +2 -0
- package/api/shopify/shopifyDeliveryCustomizationsGet.js +46 -0
- package/api/shopify/shopifyDeliveryProfilesGet.js +46 -0
- package/api/shopify/shopifyDiscountNodesGet.js +46 -0
- package/api/shopify/shopifyDisputesGet.js +46 -0
- package/api/shopify/shopifyDraftOrdersGet.js +46 -0
- package/api/shopify/shopifyEventsGet.js +46 -0
- package/api/shopify/shopifyFilesGet.js +46 -0
- package/api/shopify/shopifyFulfillmentOrdersGet.js +46 -0
- package/api/shopify/shopifyGiftCardsGet.js +46 -0
- package/api/shopify/shopifyInventoryItemsGet.js +46 -0
- package/api/shopify/shopifyLocationsGet.js +46 -0
- package/api/shopify/shopifyMarketingEventsGet.js +46 -0
- package/api/shopify/shopifyMarketsGet.js +46 -0
- package/api/shopify/shopifyMenusGet.js +46 -0
- package/api/shopify/shopifyMetafieldDefinitionsGet.js +50 -0
- package/api/shopify/shopifyMetaobjectDefinitionsGet.js +46 -0
- package/api/shopify/shopifyMetaobjectsGet.js +50 -0
- package/api/shopify/shopifyPagesGet.js +46 -0
- package/api/shopify/shopifyPaymentCustomizationsGet.js +46 -0
- package/api/shopify/shopifyProductFeedsGet.js +46 -0
- package/api/shopify/shopifyProductVariantsGet.js +46 -0
- package/api/shopify/shopifyProductsGet.js +46 -0
- package/api/shopify/shopifyPublicationsGet.js +46 -0
- package/api/shopify/shopifySegmentsGet.js +46 -0
- package/api/shopify/shopifyUrlRedirectsGet.js +46 -0
- package/api/shopify/shopifyWebhookSubscriptionsGet.js +46 -0
- package/api/utils.js +4 -3
- package/api/workspace.js +43 -0
- package/package.json +5 -3
- package/server.js +205 -105
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/products
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { shopifyGet } = require('./shopifyGet');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const shopifyProductsGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
...getterOptions // e.g. limit
|
|
15
|
+
} = {},
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
19
|
+
credsPayload,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return await shopifyGet(credsPayload, 'product', { ...getterOptions });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const funcApiConfig = {
|
|
29
|
+
argsWarden,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
shopifyProductsGet,
|
|
34
|
+
funcApiConfig,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
curl -X POST "http://localhost:8000/shopifyProductsGet" \
|
|
39
|
+
-H "Content-Type: application/json" \
|
|
40
|
+
-d '{
|
|
41
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
42
|
+
"options": {
|
|
43
|
+
"limit": 10
|
|
44
|
+
}
|
|
45
|
+
}'
|
|
46
|
+
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/publications
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { shopifyGet } = require('./shopifyGet');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const shopifyPublicationsGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
...getterOptions // e.g. limit
|
|
15
|
+
} = {},
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
19
|
+
credsPayload,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return await shopifyGet(credsPayload, 'publication', { ...getterOptions });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const funcApiConfig = {
|
|
29
|
+
argsWarden,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
shopifyPublicationsGet,
|
|
34
|
+
funcApiConfig,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
curl -X POST "http://localhost:8000/shopifyPublicationsGet" \
|
|
39
|
+
-H "Content-Type: application/json" \
|
|
40
|
+
-d '{
|
|
41
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
42
|
+
"options": {
|
|
43
|
+
"limit": 10
|
|
44
|
+
}
|
|
45
|
+
}'
|
|
46
|
+
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/segments
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { shopifyGet } = require('./shopifyGet');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const shopifySegmentsGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
...getterOptions // e.g. limit
|
|
15
|
+
} = {},
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
19
|
+
credsPayload,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return await shopifyGet(credsPayload, 'segment', { ...getterOptions });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const funcApiConfig = {
|
|
29
|
+
argsWarden,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
shopifySegmentsGet,
|
|
34
|
+
funcApiConfig,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
curl -X POST "http://localhost:8000/shopifySegmentsGet" \
|
|
39
|
+
-H "Content-Type: application/json" \
|
|
40
|
+
-d '{
|
|
41
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
42
|
+
"options": {
|
|
43
|
+
"limit": 10
|
|
44
|
+
}
|
|
45
|
+
}'
|
|
46
|
+
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/urlRedirects
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { shopifyGet } = require('./shopifyGet');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const shopifyUrlRedirectsGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
...getterOptions // e.g. limit
|
|
15
|
+
} = {},
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
19
|
+
credsPayload,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return await shopifyGet(credsPayload, 'urlRedirect', { ...getterOptions });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const funcApiConfig = {
|
|
29
|
+
argsWarden,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
shopifyUrlRedirectsGet,
|
|
34
|
+
funcApiConfig,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
curl -X POST "http://localhost:8000/shopifyUrlRedirectsGet" \
|
|
39
|
+
-H "Content-Type: application/json" \
|
|
40
|
+
-d '{
|
|
41
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
42
|
+
"options": {
|
|
43
|
+
"limit": 10
|
|
44
|
+
}
|
|
45
|
+
}'
|
|
46
|
+
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/webhookSubscriptions
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { shopifyGet } = require('./shopifyGet');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const shopifyWebhookSubscriptionsGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
...getterOptions // e.g. limit
|
|
15
|
+
} = {},
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
19
|
+
credsPayload,
|
|
20
|
+
});
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return await shopifyGet(credsPayload, 'webhookSubscription', { ...getterOptions });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const funcApiConfig = {
|
|
29
|
+
argsWarden,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
shopifyWebhookSubscriptionsGet,
|
|
34
|
+
funcApiConfig,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
curl -X POST "http://localhost:8000/shopifyWebhookSubscriptionsGet" \
|
|
39
|
+
-H "Content-Type: application/json" \
|
|
40
|
+
-d '{
|
|
41
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
42
|
+
"options": {
|
|
43
|
+
"limit": 10
|
|
44
|
+
}
|
|
45
|
+
}'
|
|
46
|
+
*/
|
package/api/utils.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require('dotenv').config();
|
|
2
|
-
|
|
3
1
|
const xml2js = require('xml2js');
|
|
4
2
|
const readline = require('readline');
|
|
5
3
|
const fs = require('fs').promises;
|
|
@@ -7,6 +5,7 @@ const yaml = require('yaml');
|
|
|
7
5
|
const { EventEmitter } = require('events');
|
|
8
6
|
|
|
9
7
|
const { HOSTED } = require('./constants');
|
|
8
|
+
const { getWorkspace } = require('./workspace');
|
|
10
9
|
|
|
11
10
|
const wait = (ms) => new Promise((resolve, reject) => setTimeout(resolve, ms));
|
|
12
11
|
|
|
@@ -73,7 +72,7 @@ const credsFromPayload = async (credsPayload) => {
|
|
|
73
72
|
throw new Error(`Malformed CREDS environment variable: ${ err }`);
|
|
74
73
|
}
|
|
75
74
|
} else {
|
|
76
|
-
const credsText = await fs.readFile(
|
|
75
|
+
const credsText = await fs.readFile(`${ getWorkspace() }/.creds.yml`, 'utf8');
|
|
77
76
|
credsYmlAsObject = yaml.parse(credsText);
|
|
78
77
|
}
|
|
79
78
|
|
|
@@ -414,6 +413,8 @@ class Chain {
|
|
|
414
413
|
}
|
|
415
414
|
}
|
|
416
415
|
|
|
416
|
+
// TODO: client wrapper enabling auth and retrying with different auth
|
|
417
|
+
|
|
417
418
|
class FetchClient {
|
|
418
419
|
constructor({
|
|
419
420
|
context, // necessary data for preparer and interpreters to refer to
|
package/api/workspace.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const dotenv = require('dotenv');
|
|
3
|
+
|
|
4
|
+
let workspace = process.cwd();
|
|
5
|
+
|
|
6
|
+
// Turn ".", "geode", or "/full/path" into an absolute directory.
|
|
7
|
+
const toAbsolutePath = (dir) => {
|
|
8
|
+
if (!dir || dir === '.') {
|
|
9
|
+
return process.cwd();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (dir.startsWith('/')) {
|
|
13
|
+
return dir;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return `${ process.cwd() }/${ dir }`;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getWorkspace = () => workspace;
|
|
20
|
+
|
|
21
|
+
const setWorkspace = (dir) => {
|
|
22
|
+
workspace = toAbsolutePath(dir);
|
|
23
|
+
process.env.MINERAL_WORKSPACE = workspace;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const loadWorkspaceEnv = () => {
|
|
27
|
+
const envFile = `${ workspace }/.env`;
|
|
28
|
+
if (!fs.existsSync(envFile)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
dotenv.config({
|
|
33
|
+
path: envFile,
|
|
34
|
+
override: true,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
getWorkspace,
|
|
40
|
+
setWorkspace,
|
|
41
|
+
loadWorkspaceEnv,
|
|
42
|
+
toAbsolutePath,
|
|
43
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxtware/mineral",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"bin": {
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"bin": {
|
|
5
|
+
"mineral": "bin/mineral.js"
|
|
6
|
+
},
|
|
5
7
|
"main": "server.js",
|
|
6
8
|
"publishConfig": {
|
|
7
9
|
"access": "public"
|
|
@@ -12,7 +14,7 @@
|
|
|
12
14
|
"new": "node _build_scripts/createNewFunction.js",
|
|
13
15
|
"serve": "PORT=8100 node server.js",
|
|
14
16
|
"start": "node server.js",
|
|
15
|
-
"npm:publish": "
|
|
17
|
+
"npm:publish": "node _build_scripts/publish.js"
|
|
16
18
|
},
|
|
17
19
|
"dependencies": {
|
|
18
20
|
"csvtojson": "^2.0.14",
|