@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.
Files changed (93) hide show
  1. package/.creds.yml.sample +16 -7
  2. package/AGENTS.md +3 -0
  3. package/_build_scripts/publish.js +15 -1
  4. package/api/backblaze/backblaze.constants.js +11 -0
  5. package/api/backblaze/backblaze.utils.js +322 -0
  6. package/api/backblaze/backblazeBucketsGet.js +68 -0
  7. package/api/backblaze/backblazeFileDelete.js +62 -0
  8. package/api/backblaze/backblazeFileHide.js +62 -0
  9. package/api/backblaze/backblazeFileUpload.js +142 -0
  10. package/api/backblaze/backblazeFilesGet.js +85 -0
  11. package/api/backblaze/backblazeGet.js +139 -0
  12. package/api/backblaze/docs.md +6 -0
  13. package/api/etsy/etsyListingInventoryUpdate.js +11 -11
  14. package/api/etsy/etsyListingUpdate.js +1 -1
  15. package/api/gorgias/gorgias.constants.js +8 -0
  16. package/api/gorgias/gorgias.utils.js +46 -0
  17. package/api/gorgias/gorgiasAccountGet.js +51 -0
  18. package/api/gorgias/gorgiasCustomerGet.js +70 -0
  19. package/api/gorgias/gorgiasCustomersGet.js +56 -0
  20. package/api/gorgias/gorgiasGet.js +150 -0
  21. package/api/gorgias/gorgiasGetSingle.js +26 -0
  22. package/api/gorgias/gorgiasMessagesGet.js +56 -0
  23. package/api/gorgias/gorgiasTagsGet.js +52 -0
  24. package/api/gorgias/gorgiasTicketCreate.js +66 -0
  25. package/api/gorgias/gorgiasTicketGet.js +70 -0
  26. package/api/gorgias/gorgiasTicketMessageCreate.js +65 -0
  27. package/api/gorgias/gorgiasTicketMessagesGet.js +66 -0
  28. package/api/gorgias/gorgiasTicketUpdate.js +62 -0
  29. package/api/gorgias/gorgiasTicketsGet.js +58 -0
  30. package/api/gorgias/gorgiasUsersGet.js +52 -0
  31. package/api/gorgias/gorgiasViewItemsGet.js +57 -0
  32. package/api/gorgias/gorgiasViewsGet.js +72 -0
  33. package/api/linear/docs.md +6 -0
  34. package/api/linear/linear.constants.js +3 -0
  35. package/api/linear/linear.utils.js +59 -0
  36. package/api/linear/linearAttachmentCreate.js +77 -0
  37. package/api/linear/linearAttachmentDelete.js +68 -0
  38. package/api/linear/linearCommentCreate.js +77 -0
  39. package/api/linear/linearCommentDelete.js +68 -0
  40. package/api/linear/linearCommentGet.js +77 -0
  41. package/api/linear/linearCommentUpdate.js +87 -0
  42. package/api/linear/linearCommentsGet.js +70 -0
  43. package/api/linear/linearCyclesGet.js +67 -0
  44. package/api/linear/linearGet.js +218 -0
  45. package/api/linear/linearIssueAddLabel.js +77 -0
  46. package/api/linear/linearIssueArchive.js +74 -0
  47. package/api/linear/linearIssueCreate.js +94 -0
  48. package/api/linear/linearIssueDelete.js +74 -0
  49. package/api/linear/linearIssueGet.js +87 -0
  50. package/api/linear/linearIssueLabelCreate.js +81 -0
  51. package/api/linear/linearIssueLabelsGet.js +66 -0
  52. package/api/linear/linearIssueRemoveLabel.js +77 -0
  53. package/api/linear/linearIssueUpdate.js +96 -0
  54. package/api/linear/linearIssuesGet.js +39 -63
  55. package/api/linear/linearOrganizationGet.js +64 -0
  56. package/api/linear/linearProjectCreate.js +92 -0
  57. package/api/linear/linearProjectGet.js +74 -0
  58. package/api/linear/linearProjectUpdate.js +80 -0
  59. package/api/linear/linearProjectsGet.js +71 -0
  60. package/api/linear/linearTeamGet.js +71 -0
  61. package/api/linear/linearTeamsGet.js +66 -0
  62. package/api/linear/linearUserGet.js +72 -0
  63. package/api/linear/linearUsersGet.js +71 -0
  64. package/api/linear/linearViewerGet.js +65 -0
  65. package/api/linear/linearWebhookCreate.js +77 -0
  66. package/api/linear/linearWebhookDelete.js +68 -0
  67. package/api/linear/linearWebhooksGet.js +67 -0
  68. package/api/linear/linearWorkflowStatesGet.js +73 -0
  69. package/api/pipe17/pipe17.utils.js +7 -20
  70. package/api/pipe17/pipe17ArrivalGet.js +1 -1
  71. package/api/pipe17/pipe17FulfillmentGet.js +1 -1
  72. package/api/pipe17/pipe17InventoryItemGet.js +1 -1
  73. package/api/pipe17/pipe17JobGet.js +11 -24
  74. package/api/pipe17/pipe17LocationGet.js +1 -1
  75. package/api/pipe17/pipe17OrderGet.js +1 -1
  76. package/api/pipe17/pipe17ProductGet.js +1 -1
  77. package/api/pipe17/pipe17PurchaseGet.js +1 -1
  78. package/api/pipe17/pipe17ReceiptGet.js +1 -1
  79. package/api/pipe17/pipe17ReturnGet.js +1 -1
  80. package/api/shopify/shopifyFileCreate.js +107 -0
  81. package/api/shopify/shopifyMetafieldDefinitionCreate.js +2 -0
  82. package/api/shopify/shopifyMetafieldDefinitionGet.js +108 -0
  83. package/api/shopify/shopifyMetafieldDefinitionPropagate.js +167 -0
  84. package/api/shopify/shopifyThemeFileGet.js +112 -0
  85. package/api/shopify/shopifyThemeFilePropagate.js +410 -0
  86. package/api/shopify/shopifyThemeFilesUpsert.js +88 -0
  87. package/api/starshipit/starshipit.utils.js +1 -0
  88. package/api/starshipit/starshipitOrderGet.js +2 -10
  89. package/api/utils.js +12 -4
  90. package/hosting/deployFromHostingYml.js +2 -2
  91. package/hosting/execCommand.js +19 -2
  92. package/package.json +1 -1
  93. package/server.utils.js +1 -1
@@ -0,0 +1,77 @@
1
+ // https://linear.app/developers/graphql
2
+
3
+ const { ArgsWarden, valueProvided } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { linearClient } = require('../linear/linear.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['input', valueProvided],
10
+ ]);
11
+
12
+ const linearWebhookCreate = async (
13
+ credsPayload,
14
+ input,
15
+ {
16
+ inspect = false,
17
+ fetchClient = linearClient,
18
+ } = {},
19
+ ) => {
20
+
21
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
22
+ credsPayload,
23
+ input,
24
+ });
25
+ if (rejectResponse) {
26
+ return rejectResponse;
27
+ }
28
+
29
+ return fetchClient.fetch({
30
+ requestPayload: {
31
+ body: {
32
+ query: `
33
+ mutation WebhookCreate($input: WebhookCreateInput!) {
34
+ webhookCreate(input: $input) {
35
+ success
36
+ webhook {
37
+ id
38
+ url
39
+ enabled
40
+ }
41
+ }
42
+ }
43
+ `,
44
+ variables: {
45
+ input,
46
+ },
47
+ },
48
+ },
49
+ context: {
50
+ credsPayload,
51
+ resultPath: 'data.webhookCreate',
52
+ },
53
+ inspect,
54
+ });
55
+ };
56
+
57
+ const funcApiConfig = {
58
+ argsWarden,
59
+ };
60
+
61
+ module.exports = {
62
+ linearWebhookCreate,
63
+ funcApiConfig,
64
+ };
65
+
66
+ /*
67
+ curl -X POST "http://localhost:8000/linearWebhookCreate" \
68
+ -H "Content-Type: application/json" \
69
+ -d '{
70
+ "credsPayload": { "credsPath": "linear" },
71
+ "input": {
72
+ "url": "https://example.com/hooks/linear",
73
+ "teamId": "f2387dcd-61ac-49aa-8d7a-7f62a0b5cca0",
74
+ "resourceTypes": ["Issue"]
75
+ }
76
+ }'
77
+ */
@@ -0,0 +1,68 @@
1
+ // https://linear.app/developers/graphql
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { linearClient } = require('../linear/linear.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['id'],
10
+ ]);
11
+
12
+ const linearWebhookDelete = async (
13
+ credsPayload,
14
+ id,
15
+ {
16
+ inspect = false,
17
+ fetchClient = linearClient,
18
+ } = {},
19
+ ) => {
20
+
21
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
22
+ credsPayload,
23
+ id,
24
+ });
25
+ if (rejectResponse) {
26
+ return rejectResponse;
27
+ }
28
+
29
+ return fetchClient.fetch({
30
+ requestPayload: {
31
+ body: {
32
+ query: `
33
+ mutation WebhookDelete($id: String!) {
34
+ webhookDelete(id: $id) {
35
+ success
36
+ }
37
+ }
38
+ `,
39
+ variables: {
40
+ id,
41
+ },
42
+ },
43
+ },
44
+ context: {
45
+ credsPayload,
46
+ resultPath: 'data.webhookDelete',
47
+ },
48
+ inspect,
49
+ });
50
+ };
51
+
52
+ const funcApiConfig = {
53
+ argsWarden,
54
+ };
55
+
56
+ module.exports = {
57
+ linearWebhookDelete,
58
+ funcApiConfig,
59
+ };
60
+
61
+ /*
62
+ curl -X POST "http://localhost:8000/linearWebhookDelete" \
63
+ -H "Content-Type: application/json" \
64
+ -d '{
65
+ "credsPayload": { "credsPath": "linear" },
66
+ "id": "WEBHOOK_ID"
67
+ }'
68
+ */
@@ -0,0 +1,67 @@
1
+ // https://linear.app/developers/graphql
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { linearGet, linearGetter } = require('./linearGet');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const linearWebhooksGet = async (
12
+ returnGetter,
13
+
14
+ credsPayload,
15
+ {
16
+ attrs = `
17
+ id
18
+ url
19
+ enabled
20
+ `,
21
+ filterType = null,
22
+ ...getterOptions
23
+ } = {},
24
+ ) => {
25
+
26
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
27
+ credsPayload,
28
+ });
29
+ if (rejectResponse) {
30
+ return rejectResponse;
31
+ }
32
+
33
+ const getterArgs = [
34
+ credsPayload,
35
+ 'webhook',
36
+ {
37
+ attrs,
38
+ filterType,
39
+ ...getterOptions,
40
+ },
41
+ ];
42
+
43
+ return returnGetter
44
+ ? linearGetter(...getterArgs)
45
+ : linearGet(...getterArgs);
46
+ };
47
+
48
+ const funcApiConfig = {
49
+ argsWarden,
50
+ };
51
+
52
+ module.exports = {
53
+ linearWebhooksGet: linearWebhooksGet.bind(null, false),
54
+ linearWebhooksGetter: linearWebhooksGet.bind(null, true),
55
+ funcApiConfig,
56
+ };
57
+
58
+ /*
59
+ curl -X POST "http://localhost:8000/linearWebhooksGet" \
60
+ -H "Content-Type: application/json" \
61
+ -d '{
62
+ "credsPayload": { "credsPath": "linear" },
63
+ "options": {
64
+ "limit": 10
65
+ }
66
+ }'
67
+ */
@@ -0,0 +1,73 @@
1
+ // https://linear.app/developers/graphql
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { linearGet, linearGetter } = require('./linearGet');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const linearWorkflowStatesGet = async (
12
+ returnGetter,
13
+
14
+ credsPayload,
15
+ {
16
+ attrs = `
17
+ id
18
+ name
19
+ type
20
+ position
21
+ team {
22
+ id
23
+ name
24
+ }
25
+ `,
26
+ ...getterOptions
27
+ } = {},
28
+ ) => {
29
+
30
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
31
+ credsPayload,
32
+ });
33
+ if (rejectResponse) {
34
+ return rejectResponse;
35
+ }
36
+
37
+ const getterArgs = [
38
+ credsPayload,
39
+ 'workflowState',
40
+ {
41
+ attrs,
42
+ ...getterOptions,
43
+ },
44
+ ];
45
+
46
+ return returnGetter
47
+ ? linearGetter(...getterArgs)
48
+ : linearGet(...getterArgs);
49
+ };
50
+
51
+ const funcApiConfig = {
52
+ argsWarden,
53
+ };
54
+
55
+ module.exports = {
56
+ linearWorkflowStatesGet: linearWorkflowStatesGet.bind(null, false),
57
+ linearWorkflowStatesGetter: linearWorkflowStatesGet.bind(null, true),
58
+ funcApiConfig,
59
+ };
60
+
61
+ /*
62
+ curl -X POST "http://localhost:8000/linearWorkflowStatesGet" \
63
+ -H "Content-Type: application/json" \
64
+ -d '{
65
+ "credsPayload": { "credsPath": "linear" },
66
+ "options": {
67
+ "limit": 20,
68
+ "filter": {
69
+ "team": { "id": { "eq": "f2387dcd-61ac-49aa-8d7a-7f62a0b5cca0" } }
70
+ }
71
+ }
72
+ }'
73
+ */
@@ -75,6 +75,7 @@ const pipe17Client = new FetchClient({
75
75
  'fetch',
76
76
  fetchClientCommonSteps.exitEarlyOnNotOk,
77
77
  interpretPipe17Response,
78
+ fetchClientCommonSteps.digToPath,
78
79
  ],
79
80
  });
80
81
 
@@ -83,37 +84,23 @@ const pipe17GetSingle = async (
83
84
  collectionPath,
84
85
  id,
85
86
  {
86
- resultKey,
87
+ resultPath,
87
88
  inspect = false,
88
89
  fetchClient = pipe17Client,
89
90
  } = {},
90
91
  ) => {
91
92
 
92
- const response = await fetchClient.fetch({
93
+ return fetchClient.fetch({
93
94
  requestPayload: {
94
95
  method: 'get',
95
96
  url: `${ collectionPath }/${ id }`,
96
97
  },
97
- context: { credsPayload },
98
+ context: {
99
+ credsPayload,
100
+ resultPath,
101
+ },
98
102
  inspect,
99
103
  });
100
-
101
- if (!response.ok) {
102
- return response;
103
- }
104
-
105
- const resolvedResultKey = resultKey ?? collectionPath.replace(/^\//, '').replace(/s$/, '');
106
- const entity = response.data?.result?.[resolvedResultKey]
107
- ?? response.data?.[resolvedResultKey];
108
-
109
- if (entity !== undefined) {
110
- return {
111
- ...response,
112
- data: entity,
113
- };
114
- }
115
-
116
- return response;
117
104
  };
118
105
 
119
106
  module.exports = {
@@ -52,7 +52,7 @@ const pipe17ArrivalGet = async (
52
52
  '/arrivals',
53
53
  resolveArrivalId(arrivalIdentifier),
54
54
  {
55
- resultKey: 'arrival',
55
+ resultPath: 'result.arrival',
56
56
  inspect,
57
57
  fetchClient,
58
58
  },
@@ -43,7 +43,7 @@ const pipe17FulfillmentGet = async (
43
43
  '/fulfillments',
44
44
  resolveFulfillmentId(fulfillmentIdentifier),
45
45
  {
46
- resultKey: 'fulfillment',
46
+ resultPath: 'result.fulfillment',
47
47
  inspect,
48
48
  fetchClient,
49
49
  },
@@ -31,7 +31,7 @@ const pipe17InventoryItemGet = async (
31
31
  '/inventory',
32
32
  inventoryItemId,
33
33
  {
34
- resultKey: 'inventory',
34
+ resultPath: 'result.inventory',
35
35
  inspect,
36
36
  fetchClient,
37
37
  },
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
- const { pipe17Client } = require('../pipe17/pipe17.utils');
5
+ const { pipe17GetSingle } = require('../pipe17/pipe17.utils');
6
6
 
7
7
  const argsWarden = new ArgsWarden([
8
8
  ['credsPayload', credsValidator],
@@ -14,7 +14,7 @@ const pipe17JobGet = async (
14
14
  jobId,
15
15
  {
16
16
  inspect = false,
17
- fetchClient = pipe17Client,
17
+ fetchClient,
18
18
  } = {},
19
19
  ) => {
20
20
 
@@ -26,29 +26,16 @@ const pipe17JobGet = async (
26
26
  return rejectResponse;
27
27
  }
28
28
 
29
- const response = await fetchClient.fetch({
30
- requestPayload: {
31
- method: 'get',
32
- url: `/jobs/${ jobId }`,
29
+ return pipe17GetSingle(
30
+ credsPayload,
31
+ '/jobs',
32
+ jobId,
33
+ {
34
+ resultPath: 'result.job',
35
+ inspect,
36
+ fetchClient,
33
37
  },
34
- context: { credsPayload },
35
- inspect,
36
- });
37
-
38
- if (!response.ok) {
39
- return response;
40
- }
41
-
42
- const job = response.data?.result?.job
43
- ?? response.data?.job;
44
- if (job !== undefined) {
45
- return {
46
- ...response,
47
- data: job,
48
- };
49
- }
50
-
51
- return response;
38
+ );
52
39
  };
53
40
 
54
41
  const funcApiConfig = {
@@ -31,7 +31,7 @@ const pipe17LocationGet = async (
31
31
  '/locations',
32
32
  locationId,
33
33
  {
34
- resultKey: 'location',
34
+ resultPath: 'result.location',
35
35
  inspect,
36
36
  fetchClient,
37
37
  },
@@ -45,7 +45,7 @@ const pipe17OrderGet = async (
45
45
  '/orders',
46
46
  resolveOrderId(orderIdentifier),
47
47
  {
48
- resultKey: 'order',
48
+ resultPath: 'result.order',
49
49
  inspect,
50
50
  fetchClient,
51
51
  },
@@ -31,7 +31,7 @@ const pipe17ProductGet = async (
31
31
  '/products',
32
32
  productId,
33
33
  {
34
- resultKey: 'product',
34
+ resultPath: 'result.product',
35
35
  inspect,
36
36
  fetchClient,
37
37
  },
@@ -31,7 +31,7 @@ const pipe17PurchaseGet = async (
31
31
  '/purchases',
32
32
  purchaseId,
33
33
  {
34
- resultKey: 'purchase',
34
+ resultPath: 'result.purchase',
35
35
  inspect,
36
36
  fetchClient,
37
37
  },
@@ -31,7 +31,7 @@ const pipe17ReceiptGet = async (
31
31
  '/receipts',
32
32
  receiptId,
33
33
  {
34
- resultKey: 'receipt',
34
+ resultPath: 'result.receipt',
35
35
  inspect,
36
36
  fetchClient,
37
37
  },
@@ -31,7 +31,7 @@ const pipe17ReturnGet = async (
31
31
  '/returns',
32
32
  returnId,
33
33
  {
34
- resultKey: 'return',
34
+ resultPath: 'result.return',
35
35
  inspect,
36
36
  fetchClient,
37
37
  },
@@ -0,0 +1,107 @@
1
+ // https://shopify.dev/docs/api/admin-graphql/latest/mutations/fileCreate
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden, ensureArray, everyIfArray } = require('../utils');
5
+ const { shopifyMutationDo } = require('./shopifyMutationDo');
6
+
7
+ const fileInputValidator = ({ originalSource } = {}) => Boolean(originalSource);
8
+
9
+ const defaultReturnFileAttrs = `
10
+ id
11
+ fileStatus
12
+ alt
13
+ fileErrors {
14
+ code
15
+ details
16
+ message
17
+ }
18
+ preview {
19
+ image {
20
+ url
21
+ }
22
+ }
23
+ ... on MediaImage {
24
+ image {
25
+ url
26
+ }
27
+ }
28
+ ... on GenericFile {
29
+ url
30
+ }
31
+ ... on Video {
32
+ originalSource {
33
+ url
34
+ }
35
+ }
36
+ `.trim();
37
+
38
+ const argsWarden = new ArgsWarden([
39
+ ['credsPayload', credsValidator],
40
+ ['fileInput', (fileInput) => everyIfArray(fileInputValidator, fileInput)],
41
+ ]);
42
+
43
+ const shopifyFileCreate = async (
44
+ credsPayload,
45
+ fileInput,
46
+ {
47
+ apiVersion,
48
+ returnFileAttrs = defaultReturnFileAttrs,
49
+ } = {},
50
+ ) => {
51
+
52
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
53
+ credsPayload,
54
+ fileInput,
55
+ });
56
+ if (rejectResponse) {
57
+ return rejectResponse;
58
+ }
59
+
60
+ return shopifyMutationDo(
61
+ credsPayload,
62
+ 'fileCreate',
63
+ {
64
+ mutationVariables: {
65
+ files: {
66
+ type: '[FileCreateInput!]!',
67
+ value: ensureArray(fileInput).map(({
68
+ filename,
69
+ originalSource,
70
+ contentType,
71
+ alt,
72
+ duplicateResolutionMode,
73
+ }) => ({
74
+ originalSource,
75
+ ...(filename && { filename }),
76
+ ...(contentType && { contentType }),
77
+ ...(alt && { alt }),
78
+ ...(duplicateResolutionMode && { duplicateResolutionMode }),
79
+ })),
80
+ },
81
+ },
82
+ returnSchema: `files { ${ returnFileAttrs } }`,
83
+ apiVersion,
84
+ },
85
+ );
86
+ };
87
+
88
+ const funcApiConfig = {
89
+ argsWarden,
90
+ };
91
+
92
+ module.exports = {
93
+ shopifyFileCreate,
94
+ funcApiConfig,
95
+ };
96
+
97
+ /*
98
+ curl -X POST "http://localhost:8000/shopifyFileCreate" \
99
+ -H "Content-Type: application/json" \
100
+ -d '{
101
+ "credsPayload": { "credsPath": "shopify.au" },
102
+ "fileInput": {
103
+ "originalSource": "https://upload.wikimedia.org/wikipedia/en/5/5f/Original_Doge_meme.jpg",
104
+ "filename": "doge.jpg"
105
+ }
106
+ }'
107
+ */
@@ -39,6 +39,7 @@ const shopifyMetafieldDefinitionCreate = async (
39
39
  pin,
40
40
  useAsCollectionCondition,
41
41
  validations,
42
+ capabilities,
42
43
  returnSchema = defaultReturnSchema,
43
44
  } = {},
44
45
  ) => {
@@ -73,6 +74,7 @@ const shopifyMetafieldDefinitionCreate = async (
73
74
  ...(pin && { pin }),
74
75
  ...(useAsCollectionCondition && { useAsCollectionCondition }),
75
76
  ...(validations && { validations }),
77
+ ...(capabilities && { capabilities }),
76
78
  },
77
79
  },
78
80
  },