@foxtware/mineral 0.1.35 → 0.1.37
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 +9 -0
- package/api/marketingcloud/docs.md +6 -0
- package/api/marketingcloud/marketingcloud.constants.js +5 -0
- package/api/marketingcloud/marketingcloud.utils.js +67 -0
- package/api/marketingcloud/marketingcloudAttributesSearch.js +87 -0
- package/api/marketingcloud/marketingcloudAuthGet.js +111 -0
- package/api/marketingcloud/marketingcloudContactGet.js +79 -0
- package/api/marketingcloud/marketingcloudContactSearch.js +87 -0
- package/api/marketingcloud/marketingcloudSmsSubscriptionsGet.js +79 -0
- package/api/peoplevox/peoplevoxItemEdit.js +59 -22
- package/api/peoplevox/peoplevoxOrderEdit.js +49 -25
- package/api/shopify/shopifyInventoryItemUpdate.js +22 -16
- package/api/shopify/shopifyInventoryItemsUpdateBulk.js +79 -0
- package/api/shopify/shopifyMetafieldsSetBulk.js +87 -0
- package/api/shopify/shopifyProductGet.js +1 -0
- package/api/shopify/shopifyProductUpdate.js +136 -0
- package/api/shopify/shopifyProductUpdateTrigger.js +96 -0
- package/api/snowflake/docs.md +8 -2
- package/api/snowflake/snowflake.constants.js +19 -0
- package/api/snowflake/snowflake.utils.js +326 -0
- package/api/snowflake/snowflakeAuthGet.js +73 -0
- package/api/snowflake/snowflakeDatabasesGet.js +62 -0
- package/api/snowflake/snowflakeDynamicTablesGet.js +72 -0
- package/api/snowflake/snowflakeEventTablesGet.js +72 -0
- package/api/snowflake/snowflakeGet.js +153 -0
- package/api/snowflake/snowflakeIntegrationsGet.js +59 -0
- package/api/snowflake/snowflakeQuery.js +227 -0
- package/api/snowflake/snowflakeSchemasGet.js +69 -0
- package/api/snowflake/snowflakeStatementCancel.js +75 -0
- package/api/snowflake/snowflakeStatementExecute.js +105 -0
- package/api/snowflake/snowflakeStatementGet.js +80 -0
- package/api/snowflake/snowflakeTablesGet.js +72 -0
- package/api/snowflake/snowflakeUsersGet.js +60 -0
- package/api/snowflake/snowflakeWarehousesGet.js +43 -0
- package/api/starshipit/starshipitProductUpdate.js +1 -1
- package/api/starshipit/starshipitProductsGet.js +13 -6
- package/api/utils.js +63 -3
- package/package.json +1 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
const { json2csv } = require('json-2-csv');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
|
-
const {
|
|
3
|
+
const {
|
|
4
|
+
ensureArray,
|
|
5
|
+
everyIfArray,
|
|
6
|
+
ArgsWarden,
|
|
7
|
+
arrayToChunks,
|
|
8
|
+
groupObjectsByFields,
|
|
9
|
+
actionSingleOrMultiple,
|
|
10
|
+
} = require('../utils');
|
|
4
11
|
const { peoplevoxClient } = require('../peoplevox/peoplevox.utils');
|
|
5
12
|
const { MAX_REQUEST_ITEMS } = require('../peoplevox/peoplevox.constants');
|
|
6
13
|
|
|
@@ -11,36 +18,15 @@ const argsWarden = new ArgsWarden([
|
|
|
11
18
|
['orderPayload', (i) => everyIfArray(orderPayloadValidator, i)],
|
|
12
19
|
]);
|
|
13
20
|
|
|
14
|
-
const
|
|
21
|
+
const peoplevoxOrderEditChunk = async (
|
|
15
22
|
credsPayload,
|
|
16
|
-
|
|
23
|
+
orderPayloads,
|
|
17
24
|
{
|
|
18
25
|
fetchClient = peoplevoxClient,
|
|
19
26
|
} = {},
|
|
20
27
|
) => {
|
|
21
28
|
|
|
22
|
-
const
|
|
23
|
-
credsPayload,
|
|
24
|
-
orderPayload,
|
|
25
|
-
});
|
|
26
|
-
if (rejectResponse) {
|
|
27
|
-
return rejectResponse;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// TODO: Consider making CSV transformation a request preparer step
|
|
31
|
-
const csvData = await json2csv(ensureArray(orderPayload));
|
|
32
|
-
|
|
33
|
-
// TODO: Handle by chunking
|
|
34
|
-
// TODO: Chunk objects by common fields so that each call has a consistent schema - bedrock groupObjectsByFields
|
|
35
|
-
if (csvData.length > MAX_REQUEST_ITEMS) {
|
|
36
|
-
return {
|
|
37
|
-
ok: false,
|
|
38
|
-
error: {
|
|
39
|
-
code: 'MAX_REQUEST_ITEMS_EXCEEDED',
|
|
40
|
-
message: `Max request items exceeded. Max is ${ MAX_REQUEST_ITEMS }.`,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
29
|
+
const csvData = await json2csv(orderPayloads);
|
|
44
30
|
|
|
45
31
|
return fetchClient.fetch({
|
|
46
32
|
requestPayload: {
|
|
@@ -59,6 +45,44 @@ const peoplevoxOrderEdit = async (
|
|
|
59
45
|
});
|
|
60
46
|
};
|
|
61
47
|
|
|
48
|
+
const peoplevoxOrderEdit = async (
|
|
49
|
+
credsPayload,
|
|
50
|
+
orderPayload,
|
|
51
|
+
{
|
|
52
|
+
fetchClient = peoplevoxClient,
|
|
53
|
+
queueRunOptions,
|
|
54
|
+
} = {},
|
|
55
|
+
) => {
|
|
56
|
+
|
|
57
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
58
|
+
credsPayload,
|
|
59
|
+
orderPayload,
|
|
60
|
+
});
|
|
61
|
+
if (rejectResponse) {
|
|
62
|
+
return rejectResponse;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// TODO: Consider making CSV transformation a request preparer step
|
|
66
|
+
const orderPayloads = ensureArray(orderPayload);
|
|
67
|
+
|
|
68
|
+
// Sort into buckets of matching field sets so json2csv does not pad missing keys,
|
|
69
|
+
// then chunk each bucket by max size
|
|
70
|
+
const buckets = groupObjectsByFields(orderPayloads);
|
|
71
|
+
const chunksByBucket = buckets.map((bucket) => arrayToChunks(bucket, MAX_REQUEST_ITEMS));
|
|
72
|
+
const chunks = chunksByBucket.flat();
|
|
73
|
+
|
|
74
|
+
return actionSingleOrMultiple(
|
|
75
|
+
chunks,
|
|
76
|
+
peoplevoxOrderEditChunk,
|
|
77
|
+
(chunk) => ({
|
|
78
|
+
args: [credsPayload, chunk, { fetchClient }],
|
|
79
|
+
}),
|
|
80
|
+
{
|
|
81
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
62
86
|
const funcApiConfig = {
|
|
63
87
|
argsWarden,
|
|
64
88
|
};
|
|
@@ -9,30 +9,39 @@ const {
|
|
|
9
9
|
} = require('../utils');
|
|
10
10
|
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const inventoryItemUpdateValidator = (inventoryItemUpdate) => {
|
|
13
|
+
const {
|
|
14
|
+
inventoryItemId,
|
|
15
|
+
...updatePayload
|
|
16
|
+
} = inventoryItemUpdate;
|
|
17
|
+
|
|
18
|
+
return valueProvided(inventoryItemId)
|
|
19
|
+
&& valueProvided(updatePayload)
|
|
14
20
|
&& typeof updatePayload === 'object'
|
|
15
21
|
&& !Array.isArray(updatePayload);
|
|
16
22
|
};
|
|
17
23
|
|
|
18
24
|
const argsWarden = new ArgsWarden([
|
|
19
25
|
['credsPayload', credsValidator],
|
|
20
|
-
['
|
|
21
|
-
['updatePayload', (payload) => everyIfArray(inventoryItemUpdatePayloadValidator, payload)],
|
|
26
|
+
['inventoryItemUpdate', (p) => everyIfArray(inventoryItemUpdateValidator, p)],
|
|
22
27
|
]);
|
|
23
28
|
|
|
24
29
|
const defaultReturnInventoryItemAttrs = 'id countryCodeOfOrigin harmonizedSystemCode';
|
|
25
30
|
|
|
26
31
|
const shopifyInventoryItemUpdateSingle = async (
|
|
27
32
|
credsPayload,
|
|
28
|
-
|
|
29
|
-
updatePayload,
|
|
33
|
+
inventoryItemUpdate,
|
|
30
34
|
{
|
|
31
35
|
apiVersion,
|
|
32
36
|
returnInventoryItemAttrs = defaultReturnInventoryItemAttrs,
|
|
33
37
|
} = {},
|
|
34
38
|
) => {
|
|
35
39
|
|
|
40
|
+
const {
|
|
41
|
+
inventoryItemId,
|
|
42
|
+
...updatePayload
|
|
43
|
+
} = inventoryItemUpdate;
|
|
44
|
+
|
|
36
45
|
return shopifyMutationDo(
|
|
37
46
|
credsPayload,
|
|
38
47
|
'inventoryItemUpdate',
|
|
@@ -55,8 +64,7 @@ const shopifyInventoryItemUpdateSingle = async (
|
|
|
55
64
|
|
|
56
65
|
const shopifyInventoryItemUpdate = async (
|
|
57
66
|
credsPayload,
|
|
58
|
-
inventoryItemId
|
|
59
|
-
updatePayload,
|
|
67
|
+
inventoryItemUpdate, // update payload with inventoryItemId included
|
|
60
68
|
{
|
|
61
69
|
queueRunOptions,
|
|
62
70
|
apiVersion,
|
|
@@ -66,21 +74,19 @@ const shopifyInventoryItemUpdate = async (
|
|
|
66
74
|
|
|
67
75
|
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
68
76
|
credsPayload,
|
|
69
|
-
|
|
70
|
-
updatePayload,
|
|
77
|
+
inventoryItemUpdate,
|
|
71
78
|
});
|
|
72
79
|
if (rejectResponse) {
|
|
73
80
|
return rejectResponse;
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
return actionSingleOrMultiple(
|
|
77
|
-
[
|
|
84
|
+
[inventoryItemUpdate],
|
|
78
85
|
shopifyInventoryItemUpdateSingle,
|
|
79
|
-
(
|
|
86
|
+
(inventoryItemUpdateItem) => ({
|
|
80
87
|
args: [
|
|
81
88
|
credsPayload,
|
|
82
|
-
|
|
83
|
-
updatePayloadItem,
|
|
89
|
+
inventoryItemUpdateItem,
|
|
84
90
|
{
|
|
85
91
|
apiVersion,
|
|
86
92
|
returnInventoryItemAttrs,
|
|
@@ -107,8 +113,8 @@ curl -X POST "http://localhost:8000/shopifyInventoryItemUpdate" \
|
|
|
107
113
|
-H "Content-Type: application/json" \
|
|
108
114
|
-d '{
|
|
109
115
|
"credsPayload": { "credsPath": "shopify.au" },
|
|
110
|
-
"
|
|
111
|
-
|
|
116
|
+
"inventoryItemUpdate": {
|
|
117
|
+
"inventoryItemId": "43729076",
|
|
112
118
|
"countryCodeOfOrigin": "US",
|
|
113
119
|
"harmonizedSystemCode": "621710"
|
|
114
120
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/inventoryitemupdate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyBulkMutationDo } = require('./shopifyBulkMutationDo');
|
|
6
|
+
|
|
7
|
+
const inventoryItemsUpdateBulkMutation = `
|
|
8
|
+
mutation call($id: ID!, $input: InventoryItemInput!) {
|
|
9
|
+
inventoryItemUpdate(id: $id, input: $input) {
|
|
10
|
+
inventoryItem {
|
|
11
|
+
id
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
field
|
|
15
|
+
message
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`.trim();
|
|
20
|
+
|
|
21
|
+
const argsWarden = new ArgsWarden([
|
|
22
|
+
['credsPayload', credsValidator],
|
|
23
|
+
['inventoryItemUpdates', Array.isArray], // TODO: Real validator mandating inventoryItemId
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const shopifyInventoryItemsUpdateBulk = async (
|
|
27
|
+
credsPayload,
|
|
28
|
+
inventoryItemUpdates,
|
|
29
|
+
{
|
|
30
|
+
...bulkMutationOptions
|
|
31
|
+
} = {},
|
|
32
|
+
) => {
|
|
33
|
+
|
|
34
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
35
|
+
credsPayload,
|
|
36
|
+
inventoryItemUpdates,
|
|
37
|
+
});
|
|
38
|
+
if (rejectResponse) {
|
|
39
|
+
return rejectResponse;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return shopifyBulkMutationDo(
|
|
43
|
+
credsPayload,
|
|
44
|
+
{
|
|
45
|
+
mutation: inventoryItemsUpdateBulkMutation,
|
|
46
|
+
input: {
|
|
47
|
+
data: inventoryItemUpdates.map(({ inventoryItemId, ...input }) => ({
|
|
48
|
+
id: `gid://shopify/InventoryItem/${ inventoryItemId }`,
|
|
49
|
+
input,
|
|
50
|
+
})),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
bulkMutationOptions,
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const funcApiConfig = {
|
|
58
|
+
argsWarden,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
shopifyInventoryItemsUpdateBulk,
|
|
63
|
+
funcApiConfig,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
curl -X POST "http://localhost:8000/shopifyInventoryItemsUpdateBulk" \
|
|
68
|
+
-H "Content-Type: application/json" \
|
|
69
|
+
-d '{
|
|
70
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
71
|
+
"inventoryItemUpdates": [
|
|
72
|
+
{
|
|
73
|
+
"inventoryItemId": "43729076",
|
|
74
|
+
"countryCodeOfOrigin": "US",
|
|
75
|
+
"harmonizedSystemCode": "621710"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}'
|
|
79
|
+
*/
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/metafieldsset
|
|
2
|
+
// https://shopify.dev/docs/api/usage/bulk-operations/imports
|
|
3
|
+
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { ArgsWarden } = require('../utils');
|
|
6
|
+
const { shopifyBulkMutationDo } = require('./shopifyBulkMutationDo');
|
|
7
|
+
|
|
8
|
+
const metafieldsSetBulkMutation = `
|
|
9
|
+
mutation call($metafields: [MetafieldsSetInput!]!) {
|
|
10
|
+
metafieldsSet(metafields: $metafields) {
|
|
11
|
+
metafields {
|
|
12
|
+
id
|
|
13
|
+
namespace
|
|
14
|
+
key
|
|
15
|
+
type
|
|
16
|
+
value
|
|
17
|
+
}
|
|
18
|
+
userErrors {
|
|
19
|
+
field
|
|
20
|
+
message
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`.trim();
|
|
25
|
+
|
|
26
|
+
const metafieldsValidator = (metafields) => {
|
|
27
|
+
return Array.isArray(metafields) && metafields.length > 0;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const argsWarden = new ArgsWarden([
|
|
31
|
+
['credsPayload', credsValidator],
|
|
32
|
+
['metafields', metafieldsValidator],
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
const shopifyMetafieldsSetBulk = async (
|
|
36
|
+
credsPayload,
|
|
37
|
+
metafields,
|
|
38
|
+
{
|
|
39
|
+
...bulkMutationOptions
|
|
40
|
+
} = {},
|
|
41
|
+
) => {
|
|
42
|
+
|
|
43
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
44
|
+
credsPayload,
|
|
45
|
+
metafields,
|
|
46
|
+
});
|
|
47
|
+
if (rejectResponse) {
|
|
48
|
+
return rejectResponse;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return shopifyBulkMutationDo(
|
|
52
|
+
credsPayload,
|
|
53
|
+
{
|
|
54
|
+
mutation: metafieldsSetBulkMutation,
|
|
55
|
+
input: {
|
|
56
|
+
data: metafields.map((metafield) => ({
|
|
57
|
+
metafields: [metafield],
|
|
58
|
+
})),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
bulkMutationOptions,
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const funcApiConfig = {
|
|
66
|
+
argsWarden,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
module.exports = {
|
|
70
|
+
shopifyMetafieldsSetBulk,
|
|
71
|
+
funcApiConfig,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/*
|
|
75
|
+
curl -X POST "http://localhost:8000/shopifyMetafieldsSetBulk" \
|
|
76
|
+
-H "Content-Type: application/json" \
|
|
77
|
+
-d '{
|
|
78
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
79
|
+
"metafields": [{
|
|
80
|
+
"ownerId": "gid://shopify/Customer/2111702204488",
|
|
81
|
+
"namespace": "facts",
|
|
82
|
+
"key": "birth_date",
|
|
83
|
+
"type": "date",
|
|
84
|
+
"value": "1990-01-01"
|
|
85
|
+
}]
|
|
86
|
+
}'
|
|
87
|
+
*/
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/productUpdate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const {
|
|
5
|
+
actionSingleOrMultiple,
|
|
6
|
+
everyIfArray,
|
|
7
|
+
ArgsWarden,
|
|
8
|
+
valueProvided,
|
|
9
|
+
} = require('../utils');
|
|
10
|
+
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
11
|
+
|
|
12
|
+
const productUpdateValidator = (productUpdate) => {
|
|
13
|
+
const {
|
|
14
|
+
productIdentifier,
|
|
15
|
+
media,
|
|
16
|
+
product,
|
|
17
|
+
} = productUpdate || {};
|
|
18
|
+
|
|
19
|
+
return valueProvided(productIdentifier) && (media || product);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const argsWarden = new ArgsWarden([
|
|
23
|
+
['credsPayload', credsValidator],
|
|
24
|
+
['productUpdate', (p) => everyIfArray(productUpdateValidator, p)],
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const defaultReturnProductAttrs = 'id handle';
|
|
28
|
+
|
|
29
|
+
const shopifyProductUpdateSingle = async (
|
|
30
|
+
credsPayload,
|
|
31
|
+
productUpdate,
|
|
32
|
+
{
|
|
33
|
+
apiVersion,
|
|
34
|
+
returnProductAttrs = defaultReturnProductAttrs,
|
|
35
|
+
} = {},
|
|
36
|
+
) => {
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
productIdentifier,
|
|
40
|
+
media,
|
|
41
|
+
product,
|
|
42
|
+
} = productUpdate;
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
productId,
|
|
46
|
+
handle,
|
|
47
|
+
customId,
|
|
48
|
+
} = productIdentifier;
|
|
49
|
+
|
|
50
|
+
return shopifyMutationDo(
|
|
51
|
+
credsPayload,
|
|
52
|
+
'productUpdate',
|
|
53
|
+
{
|
|
54
|
+
mutationVariables: {
|
|
55
|
+
identifier: {
|
|
56
|
+
type: 'ProductUpdateIdentifiers',
|
|
57
|
+
value: {
|
|
58
|
+
...((productId) && { id: `gid://shopify/Product/${ productId }` }),
|
|
59
|
+
...(handle && { handle }),
|
|
60
|
+
...(customId && { customId }),
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
...(product && { product: {
|
|
64
|
+
type: 'ProductUpdateInput!',
|
|
65
|
+
value: product,
|
|
66
|
+
}}),
|
|
67
|
+
...(media && { media: {
|
|
68
|
+
type: '[CreateMediaInput!]',
|
|
69
|
+
value: media,
|
|
70
|
+
}}),
|
|
71
|
+
},
|
|
72
|
+
returnSchema: `product { ${ returnProductAttrs } }`,
|
|
73
|
+
apiVersion,
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const shopifyProductUpdate = async (
|
|
79
|
+
credsPayload,
|
|
80
|
+
productUpdate,
|
|
81
|
+
{
|
|
82
|
+
queueRunOptions,
|
|
83
|
+
apiVersion,
|
|
84
|
+
returnProductAttrs = defaultReturnProductAttrs,
|
|
85
|
+
} = {},
|
|
86
|
+
) => {
|
|
87
|
+
|
|
88
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
89
|
+
credsPayload,
|
|
90
|
+
productUpdate,
|
|
91
|
+
});
|
|
92
|
+
if (rejectResponse) {
|
|
93
|
+
return rejectResponse;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return actionSingleOrMultiple(
|
|
97
|
+
[productUpdate],
|
|
98
|
+
shopifyProductUpdateSingle,
|
|
99
|
+
(productUpdateItem) => ({
|
|
100
|
+
args: [
|
|
101
|
+
credsPayload,
|
|
102
|
+
productUpdateItem,
|
|
103
|
+
{
|
|
104
|
+
apiVersion,
|
|
105
|
+
returnProductAttrs,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
}),
|
|
109
|
+
{
|
|
110
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const funcApiConfig = {
|
|
116
|
+
argsWarden,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
module.exports = {
|
|
120
|
+
shopifyProductUpdate,
|
|
121
|
+
funcApiConfig,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/*
|
|
125
|
+
curl -X POST "http://localhost:8000/shopifyProductUpdate" \
|
|
126
|
+
-H "Content-Type: application/json" \
|
|
127
|
+
-d '{
|
|
128
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
129
|
+
"productUpdate": {
|
|
130
|
+
"productIdentifier": "104188477512",
|
|
131
|
+
"product": {
|
|
132
|
+
"title": "Example"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}'
|
|
136
|
+
*/
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// "Artificially" fires a product update webhook by appending a space to the product title, which Shopify strips.
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
|
|
6
|
+
const { shopifyProductGet, productIdentifierValidator } = require('../shopify/shopifyProductGet');
|
|
7
|
+
const { shopifyProductUpdate } = require('../shopify/shopifyProductUpdate');
|
|
8
|
+
|
|
9
|
+
const argsWarden = new ArgsWarden([
|
|
10
|
+
['credsPayload', credsValidator],
|
|
11
|
+
['productIdentifier', productIdentifierValidator],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const shopifyProductUpdateTrigger = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
productIdentifier,
|
|
17
|
+
{
|
|
18
|
+
apiVersion,
|
|
19
|
+
productTitle,
|
|
20
|
+
} = {},
|
|
21
|
+
) => {
|
|
22
|
+
|
|
23
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
24
|
+
credsPayload,
|
|
25
|
+
productIdentifier,
|
|
26
|
+
});
|
|
27
|
+
if (rejectResponse) {
|
|
28
|
+
return rejectResponse;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!productTitle) {
|
|
32
|
+
const productResponse = await shopifyProductGet(
|
|
33
|
+
credsPayload,
|
|
34
|
+
productIdentifier,
|
|
35
|
+
{
|
|
36
|
+
attrs: 'title',
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
ok: productOk,
|
|
42
|
+
data: productData,
|
|
43
|
+
} = productResponse;
|
|
44
|
+
if (!productOk) {
|
|
45
|
+
return productResponse;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
({ title: productTitle } = productData);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!productTitle) {
|
|
52
|
+
return {
|
|
53
|
+
ok: false,
|
|
54
|
+
error: 'Product title not found',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return shopifyProductUpdate(
|
|
59
|
+
credsPayload,
|
|
60
|
+
{
|
|
61
|
+
productIdentifier,
|
|
62
|
+
product: {
|
|
63
|
+
title: `${ productTitle } `,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
apiVersion,
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const funcApiConfig = {
|
|
73
|
+
argsWarden,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
module.exports = {
|
|
77
|
+
shopifyProductUpdateTrigger,
|
|
78
|
+
funcApiConfig,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/*
|
|
82
|
+
curl -X POST "http://localhost:8000/shopifyProductUpdateTrigger" \
|
|
83
|
+
-H "Content-Type: application/json" \
|
|
84
|
+
-d '{
|
|
85
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
86
|
+
"productIdentifier": { "productId": "1234567890" }
|
|
87
|
+
}'
|
|
88
|
+
|
|
89
|
+
curl -X POST "http://localhost:8000/shopifyProductUpdateTrigger" \
|
|
90
|
+
-H "Content-Type: application/json" \
|
|
91
|
+
-d '{
|
|
92
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
93
|
+
"productIdentifier": { "productId": "1234567890" },
|
|
94
|
+
"options": { "productTitle": "Ultra Strength Freeze Ray" }
|
|
95
|
+
}'
|
|
96
|
+
*/
|
package/api/snowflake/docs.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
- [Developer documentation](https://docs.snowflake.com/en/developer-guide)
|
|
4
4
|
- [SQL API](https://docs.snowflake.com/en/developer-guide/sql-api/index)
|
|
5
5
|
- [SQL API reference](https://docs.snowflake.com/en/developer-guide/sql-api/reference)
|
|
6
|
-
- [
|
|
6
|
+
- [Snowflake REST APIs](https://docs.snowflake.com/en/developer-guide/snowflake-rest-api)
|
|
7
|
+
- [Authenticating](https://docs.snowflake.com/en/developer-guide/sql-api/authenticating)
|
|
7
8
|
|
|
8
|
-
Account-scoped HTTPS JSON
|
|
9
|
+
Account-scoped HTTPS JSON APIs at `https://{account_identifier}.snowflakecomputing.com`:
|
|
10
|
+
|
|
11
|
+
- **SQL API** (`/api/v2/statements`) — submit SQL, poll handles, cancel runs, partitioned result sets
|
|
12
|
+
- **REST APIs** (`/api/v2/databases`, schemas, tables, users, …) — manage and list account objects with `showLimit` / `fromName` pagination
|
|
13
|
+
|
|
14
|
+
Auth: OAuth access token, programmatic access token, or key-pair JWT. Optional OAuth client + refresh token can mint access tokens without Upstash.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const SQL_API_PATH = '/api/v2/statements';
|
|
2
|
+
const REST_API_VERSION = 'v2';
|
|
3
|
+
const DEFAULT_STATEMENT_TIMEOUT_SECONDS = 60;
|
|
4
|
+
const DEFAULT_POLL_INTERVAL_MS = 1000;
|
|
5
|
+
const DEFAULT_POLL_MAX_ATTEMPTS = 120;
|
|
6
|
+
const JWT_LIFETIME_SECONDS = 59 * 60; // max 1 hour; stay under
|
|
7
|
+
const DEFAULT_SHOW_LIMIT = 100;
|
|
8
|
+
const MAX_SHOW_LIMIT = 10000;
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
SQL_API_PATH,
|
|
12
|
+
REST_API_VERSION,
|
|
13
|
+
DEFAULT_STATEMENT_TIMEOUT_SECONDS,
|
|
14
|
+
DEFAULT_POLL_INTERVAL_MS,
|
|
15
|
+
DEFAULT_POLL_MAX_ATTEMPTS,
|
|
16
|
+
JWT_LIFETIME_SECONDS,
|
|
17
|
+
DEFAULT_SHOW_LIMIT,
|
|
18
|
+
MAX_SHOW_LIMIT,
|
|
19
|
+
};
|