@foxtware/mineral 0.1.17 → 0.1.19
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 +4 -0
- package/_build_scripts/createNewFunction.js +10 -5
- 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/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/peoplevox/peoplevox.utils.js +25 -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/shopifyFulfillmentCreate.js +180 -0
- package/api/shopify/shopifyFulfillmentTrackingInfoUpdate.js +92 -0
- package/api/shopify/shopifyMetafieldDefinitionCreate.js +2 -0
- package/api/shopify/shopifyMetafieldDefinitionGet.js +108 -0
- package/api/shopify/shopifyMetafieldDefinitionPropagate.js +93 -86
- package/api/shopify/shopifyOrderFulfill.js +322 -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 +29 -3
- package/api/starshipit/starshipitOrderGet.js +2 -10
- package/api/starshipit/starshipitOrdersGet.js +96 -0
- package/api/utils.js +96 -5
- package/package.json +1 -1
- package/server.utils.js +1 -1
package/api/utils.js
CHANGED
|
@@ -17,11 +17,21 @@ const objHasAny = (obj, keys) => {
|
|
|
17
17
|
return keys.some((key) => obj[key] !== undefined);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
const objHasAll = (obj, keys) => {
|
|
21
|
+
if (obj == null || typeof obj !== 'object') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return keys.every((key) => obj[key] !== undefined);
|
|
26
|
+
};
|
|
27
|
+
|
|
20
28
|
const capitaliseString = (string) => `${ string[0].toUpperCase() }${ string.slice(1) }`;
|
|
21
29
|
const sentenceCaseString = (string) => `${ string[0].toLowerCase() }${ string.slice(1) }`;
|
|
22
30
|
|
|
23
31
|
const normalise = (value) => (value || '').toString().trim().toLowerCase();
|
|
24
32
|
|
|
33
|
+
const valueProvided = (value) => value !== undefined && value !== null;
|
|
34
|
+
|
|
25
35
|
const credsByPath = (credsPath, credsObject) => {
|
|
26
36
|
const pathNodes = pathAsArray(credsPath);
|
|
27
37
|
|
|
@@ -166,6 +176,10 @@ const bodyPassesThrough = (body) => {
|
|
|
166
176
|
return true;
|
|
167
177
|
}
|
|
168
178
|
|
|
179
|
+
if (Buffer.isBuffer(body)) {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
|
|
169
183
|
return typeof body.getHeaders === 'function';
|
|
170
184
|
};
|
|
171
185
|
|
|
@@ -193,7 +207,19 @@ const customFetch = async (url, {
|
|
|
193
207
|
}
|
|
194
208
|
|
|
195
209
|
if (params) {
|
|
196
|
-
const search = new URLSearchParams(
|
|
210
|
+
const search = new URLSearchParams();
|
|
211
|
+
for (const [key, value] of Object.entries(params)) {
|
|
212
|
+
if (value === undefined || value === null) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (Array.isArray(value)) {
|
|
216
|
+
for (const entry of value) {
|
|
217
|
+
search.append(key, entry);
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
search.append(key, value);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
197
223
|
url += (url.includes('?') ? '&' : '?') + search.toString();
|
|
198
224
|
}
|
|
199
225
|
|
|
@@ -394,6 +420,10 @@ const stripGraphqlEdgesAndNodes = (value) => {
|
|
|
394
420
|
return value.edges.map((edge) => stripGraphqlEdgesAndNodes(edge?.node));
|
|
395
421
|
}
|
|
396
422
|
|
|
423
|
+
if (Array.isArray(value.nodes)) {
|
|
424
|
+
return value.nodes.map(stripGraphqlEdgesAndNodes);
|
|
425
|
+
}
|
|
426
|
+
|
|
397
427
|
const output = {};
|
|
398
428
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
399
429
|
output[key] = stripGraphqlEdgesAndNodes(nestedValue);
|
|
@@ -648,14 +678,14 @@ const fetchClientCommonSteps = {
|
|
|
648
678
|
const { resultPath } = context;
|
|
649
679
|
const { data } = response;
|
|
650
680
|
|
|
651
|
-
if (!data || !resultPath) {
|
|
681
|
+
if (!valueProvided(data) || !valueProvided(resultPath)) {
|
|
652
682
|
return {};
|
|
653
683
|
}
|
|
654
684
|
|
|
655
685
|
const resultPathNodes = pathAsArray(resultPath);
|
|
656
686
|
const dataAtPath = objectDigNodeAtPath(data, resultPathNodes);
|
|
657
687
|
|
|
658
|
-
if (
|
|
688
|
+
if (dataAtPath === undefined) {
|
|
659
689
|
return {
|
|
660
690
|
response: {
|
|
661
691
|
ok: false,
|
|
@@ -676,8 +706,6 @@ const fetchClientCommonSteps = {
|
|
|
676
706
|
},
|
|
677
707
|
};
|
|
678
708
|
|
|
679
|
-
const valueProvided = (value) => value !== undefined && value !== null;
|
|
680
|
-
|
|
681
709
|
const ensureArray = (value) => {
|
|
682
710
|
if (Array.isArray(value)) {
|
|
683
711
|
return value;
|
|
@@ -782,6 +810,7 @@ class OperationQueue {
|
|
|
782
810
|
async run({
|
|
783
811
|
interval = false,
|
|
784
812
|
verbose = true,
|
|
813
|
+
inspect = false,
|
|
785
814
|
} = {}) {
|
|
786
815
|
|
|
787
816
|
// Run at interval
|
|
@@ -817,7 +846,18 @@ class OperationQueue {
|
|
|
817
846
|
// Run in sequence
|
|
818
847
|
const results = [];
|
|
819
848
|
for (const op of this.queue) {
|
|
849
|
+
|
|
820
850
|
const result = await op.run();
|
|
851
|
+
|
|
852
|
+
if (inspect !== false && (
|
|
853
|
+
inspect === true
|
|
854
|
+
|| (typeof inspect === 'function' ? inspect(result) : objectMatchesPartial(result, inspect))
|
|
855
|
+
)) {
|
|
856
|
+
inspect && logDeep({ op });
|
|
857
|
+
inspect && logDeep({ result });
|
|
858
|
+
inspect && await askQuestion('Continue?');
|
|
859
|
+
}
|
|
860
|
+
|
|
821
861
|
results.push(result);
|
|
822
862
|
if (verbose) {
|
|
823
863
|
console.log(`${ results.length } / ${ this.queue.length }`);
|
|
@@ -829,6 +869,16 @@ class OperationQueue {
|
|
|
829
869
|
}
|
|
830
870
|
}
|
|
831
871
|
|
|
872
|
+
const operationQueueRunner = async (func, payloads, { queueRunOptions = {} } = {}) => {
|
|
873
|
+
const queue = new OperationQueue(payloads.map(payload => new Operation(
|
|
874
|
+
func,
|
|
875
|
+
{ args: payload },
|
|
876
|
+
)));
|
|
877
|
+
|
|
878
|
+
const queueResponses = await queue.run(queueRunOptions);
|
|
879
|
+
return responseArrayToResponse(queueResponses);
|
|
880
|
+
};
|
|
881
|
+
|
|
832
882
|
const simpleSort = (arr, prop, { reverse } = {}) => {
|
|
833
883
|
return [...arr].sort((a, b) =>
|
|
834
884
|
reverse ? b[prop] - a[prop] : a[prop] - b[prop],
|
|
@@ -1228,10 +1278,48 @@ const gidToId = (gid) => {
|
|
|
1228
1278
|
return gid.split('/').pop();
|
|
1229
1279
|
};
|
|
1230
1280
|
|
|
1281
|
+
const objectToArray = (object, { keyProp } = {}) => {
|
|
1282
|
+
if (!keyProp) {
|
|
1283
|
+
return Object.values(object);
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
return Object.entries(object).map(([key, value]) => ({
|
|
1287
|
+
[keyProp]: key,
|
|
1288
|
+
...value,
|
|
1289
|
+
}));
|
|
1290
|
+
};
|
|
1291
|
+
|
|
1292
|
+
const objectMatchesPartial = (object, partial) => {
|
|
1293
|
+
if (object === partial) {
|
|
1294
|
+
return true;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
if (
|
|
1298
|
+
partial === null
|
|
1299
|
+
|| typeof partial !== 'object'
|
|
1300
|
+
|| object === null
|
|
1301
|
+
|| typeof object !== 'object'
|
|
1302
|
+
) {
|
|
1303
|
+
return false;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
if (Array.isArray(partial)) {
|
|
1307
|
+
if (!Array.isArray(object)) {
|
|
1308
|
+
return false;
|
|
1309
|
+
}
|
|
1310
|
+
return partial.every((item, i) => objectMatchesPartial(object[i], item));
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
return Object.entries(partial).every(([key, value]) => (
|
|
1314
|
+
objectMatchesPartial(object[key], value)
|
|
1315
|
+
));
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1231
1318
|
module.exports = {
|
|
1232
1319
|
wait,
|
|
1233
1320
|
timeMs,
|
|
1234
1321
|
objHasAny,
|
|
1322
|
+
objHasAll,
|
|
1235
1323
|
capitaliseString,
|
|
1236
1324
|
normalise,
|
|
1237
1325
|
credsFromPayload,
|
|
@@ -1256,6 +1344,7 @@ module.exports = {
|
|
|
1256
1344
|
responseResultsByOutcome,
|
|
1257
1345
|
Operation,
|
|
1258
1346
|
OperationQueue,
|
|
1347
|
+
operationQueueRunner,
|
|
1259
1348
|
actionSingleOrMultiple,
|
|
1260
1349
|
Processor,
|
|
1261
1350
|
Getter,
|
|
@@ -1263,4 +1352,6 @@ module.exports = {
|
|
|
1263
1352
|
ArgsWarden,
|
|
1264
1353
|
gidToId,
|
|
1265
1354
|
valueProvided,
|
|
1355
|
+
objectToArray,
|
|
1356
|
+
objectMatchesPartial,
|
|
1266
1357
|
};
|
package/package.json
CHANGED
package/server.utils.js
CHANGED
|
@@ -3,7 +3,7 @@ const { HOSTED } = require('./api/constants');
|
|
|
3
3
|
const { StringDecoder } = require('string_decoder');
|
|
4
4
|
|
|
5
5
|
const respondJson = (res, statusCode, payload) => {
|
|
6
|
-
|
|
6
|
+
!HOSTED && logDeep(payload);
|
|
7
7
|
const body = JSON.stringify(payload);
|
|
8
8
|
res.writeHead(statusCode, {
|
|
9
9
|
'Content-Type': 'application/json',
|