@foxtware/mineral 0.1.8 → 0.1.10
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 +43 -1
- package/AGENTS.md +6 -1
- package/README.md +1 -1
- package/api/bleckmann/.gitkeep +0 -0
- package/api/bleckmann/bleckmann.constants.js +8 -0
- package/api/bleckmann/bleckmann.utils.js +32 -0
- package/api/bleckmann/bleckmannAsnGet.js +52 -0
- package/api/bleckmann/bleckmannAsnsGet.js +65 -0
- package/api/constants.js +2 -1
- package/api/github/github.constants.js +11 -0
- package/api/github/github.utils.js +65 -0
- package/api/github/githubGet.js +144 -0
- package/api/github/githubIssueCreate.js +71 -0
- package/api/github/githubIssueGet.js +65 -0
- package/api/github/githubIssueUpdate.js +71 -0
- package/api/github/githubIssuesGet.js +74 -0
- package/api/github/githubPullRequestCreate.js +74 -0
- package/api/github/githubPullRequestGet.js +65 -0
- package/api/github/githubPullRequestMerge.js +77 -0
- package/api/github/githubPullRequestUpdate.js +72 -0
- package/api/github/githubPullRequestsGet.js +74 -0
- package/api/github/githubRepoCreate.js +80 -0
- package/api/github/githubRepoDelete.js +60 -0
- package/api/github/githubRepoGet.js +61 -0
- package/api/github/githubRepoUpdate.js +68 -0
- package/api/github/githubReposGet.js +69 -0
- package/api/github/githubUserGet.js +64 -0
- package/api/linear/linear.utils.js +9 -14
- package/api/linear/linearIssuesGet.js +9 -9
- package/api/logiwa/logiwa.utils.js +27 -25
- package/api/logiwa/logiwaInventoriesGet.js +5 -3
- package/api/logiwa/logiwaOrderGet.js +4 -2
- package/api/logiwa/logiwaOrdersGet.js +5 -3
- package/api/logiwa/logiwaProductGet.js +4 -2
- package/api/logiwa/logiwaProductsGet.js +5 -3
- package/api/logiwa/logiwaReportGetAvailableToPromise.js +5 -3
- package/api/logiwa/logiwaReportGetInventoryCalculation.js +5 -3
- package/api/logiwa/logiwaReportGetInventorySnapshot.js +5 -3
- package/api/logiwa/logiwaReportGetTotalInventory.js +5 -3
- package/api/logiwa/logiwaWebhookStatusGet.js +4 -2
- package/api/logiwa/logiwaWebhookSubscribe.js +8 -6
- package/api/logiwa/logiwaWebhookUnsubscribe.js +4 -2
- package/api/logiwa/logiwaWebhooksGet.js +4 -2
- package/api/loop/loop.constants.js +7 -0
- package/api/loop/loop.utils.js +37 -0
- package/api/loop/loopAllowlistItemsGet.js +42 -0
- package/api/loop/loopBlocklistItemsGet.js +46 -0
- package/api/loop/loopDestinationsGet.js +42 -0
- package/api/loop/loopGet.js +139 -0
- package/api/loop/loopReturnGet.js +73 -0
- package/api/loop/loopReturnsGet.js +46 -0
- package/api/peoplevox/peoplevox.constants.js +1 -1
- package/api/peoplevox/peoplevox.sessions.js +54 -0
- package/api/peoplevox/peoplevox.utils.js +67 -31
- package/api/peoplevox/peoplevoxGetSingle.js +7 -5
- package/api/peoplevox/peoplevoxOrderEdit.js +7 -5
- package/api/peoplevox/peoplevoxReportGet.js +11 -9
- package/api/pipelineSteps.js +49 -0
- package/api/shopify/shopify.utils.js +18 -24
- package/api/shopify/shopifyBulkMutationDo.js +211 -0
- package/api/shopify/shopifyBulkOperationGet.js +86 -0
- package/api/shopify/shopifyBulkOperationRunMutation.js +83 -0
- package/api/shopify/shopifyCheckoutAndAccountsConfigurationUpdate.js +79 -0
- package/api/shopify/shopifyCollectionGet.js +7 -7
- package/api/shopify/shopifyCustomerGet.js +6 -6
- package/api/shopify/shopifyGet.js +18 -13
- package/api/shopify/shopifyGetSingle.js +9 -9
- package/api/shopify/shopifyMutationDo.js +6 -6
- package/api/shopify/shopifyOrdersGet.js +11 -11
- package/api/shopify/shopifyStagedUploadCreate.js +96 -0
- package/api/shopify/shopifyTagsAdd.js +1 -1
- package/api/shopify/shopifyTagsAddBulk.js +90 -0
- package/api/shopify/shopifyTagsRemove.js +1 -1
- package/api/slack/slack.utils.js +10 -19
- package/api/slack/slackMessagePost.js +11 -11
- package/api/starshipit/starshipit.constants.js +8 -0
- package/api/starshipit/starshipit.utils.js +71 -0
- package/api/starshipit/starshipitAddressCreate.js +77 -0
- package/api/starshipit/starshipitAddressDelete.js +55 -0
- package/api/starshipit/starshipitAddressUpdate.js +69 -0
- package/api/starshipit/starshipitAddressesGet.js +52 -0
- package/api/starshipit/starshipitGet.js +146 -0
- package/api/starshipit/starshipitOrderDelete.js +102 -0
- package/api/starshipit/starshipitOrderGet.js +74 -0
- package/api/starshipit/starshipitOrderUpdate.js +109 -0
- package/api/starshipit/starshipitOrdersListShipped.js +64 -0
- package/api/starshipit/starshipitProductAdd.js +100 -0
- package/api/starshipit/starshipitProductsDelete.js +57 -0
- package/api/starshipit/starshipitProductsGet.js +49 -0
- package/api/starshipit/starshipitTrackingGet.js +69 -0
- package/api/stripe/_example.js +48 -0
- package/api/stripe/stripe.constants.js +5 -0
- package/api/stripe/stripe.utils.js +42 -0
- package/api/stripe/stripeCardCharge.js +98 -0
- package/api/stripe/stripeCardTokenCreate.js +70 -0
- package/api/stripe/stripeChargeCapture.js +63 -0
- package/api/stripe/stripeChargeCreate.js +70 -0
- package/api/stripe/stripeChargeGet.js +51 -0
- package/api/stripe/stripeChargesGet.js +52 -0
- package/api/stripe/stripeRefundCreate.js +64 -0
- package/api/stripe/stripeRefundGet.js +51 -0
- package/api/stripe/stripeRefundsGet.js +52 -0
- package/api/stripe/stripeTokenGet.js +51 -0
- package/api/stylearcade/stylearcade.constants.js +5 -0
- package/api/stylearcade/stylearcade.utils.js +40 -0
- package/api/stylearcade/stylearcadeDataGet.js +62 -0
- package/api/stylearcade/stylearcadeGet.js +133 -0
- package/api/stylearcade/stylearcadeMetadataGet.js +47 -0
- package/api/supabase/supabase.utils.js +52 -0
- package/api/supabase/supabaseRowDelete.js +95 -0
- package/api/supabase/supabaseRowGet.js +58 -0
- package/api/supabase/supabaseRowInsert.js +56 -0
- package/api/supabase/supabaseRowUpdate.js +58 -0
- package/api/supabase/supabaseRpc.js +61 -0
- package/api/supabase/supabaseTableGet.js +44 -0
- package/api/supabase/supabaseTableGetAll.js +86 -0
- package/api/threeclicks/threeclicks.constants.js +8 -0
- package/api/threeclicks/threeclicks.utils.js +119 -0
- package/api/threeclicks/threeclicksCollectionsGet.js +40 -0
- package/api/threeclicks/threeclicksGet.js +138 -0
- package/api/threeclicks/threeclicksKeycodeCreate.js +55 -0
- package/api/threeclicks/threeclicksKeycodeGet.js +47 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantitiesGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdate.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdateBulk.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderUpdate.js +35 -0
- package/api/threeclicks/threeclicksPurchaseOrdersGet.js +30 -0
- package/api/threeclicks/threeclicksShipmentCreate.js +34 -0
- package/api/threeclicks/threeclicksShipmentGet.js +33 -0
- package/api/threeclicks/threeclicksShipmentOrderAdd.js +38 -0
- package/api/threeclicks/threeclicksShipmentOrderQuantityCreate.js +35 -0
- package/api/threeclicks/threeclicksShipmentQuantityUpdate.js +35 -0
- package/api/threeclicks/threeclicksShipmentStatusUpdate.js +45 -0
- package/api/threeclicks/threeclicksShipmentsGet.js +52 -0
- package/api/threeclicks/threeclicksSignatureCalculate.js +73 -0
- package/api/threeclicks/threeclicksStyleCodesGet.js +46 -0
- package/api/threeclicks/threeclicksStyleColourCreate.js +47 -0
- package/api/threeclicks/threeclicksStyleColourDelete.js +34 -0
- package/api/threeclicks/threeclicksStyleCreate.js +44 -0
- package/api/threeclicks/threeclicksStyleDelete.js +33 -0
- package/api/threeclicks/threeclicksStyleGet.js +43 -0
- package/api/threeclicks/threeclicksStylePriceUpdate.js +70 -0
- package/api/threeclicks/threeclicksStyleUpdate.js +47 -0
- package/api/threeclicks/threeclicksStylesGet.js +45 -0
- package/api/upstash/upstash.utils.js +36 -0
- package/api/upstash/upstashDel.js +46 -0
- package/api/upstash/upstashExists.js +46 -0
- package/api/upstash/upstashGet.js +46 -0
- package/api/upstash/upstashSet.js +64 -0
- package/api/utils.js +90 -76
- package/api/validators.js +1 -1
- package/api/workable/workable.constants.js +3 -0
- package/api/workable/workable.utils.js +41 -0
- package/api/workable/workableGet.js +151 -0
- package/api/workable/workableJobCandidateCreate.js +87 -0
- package/api/workable/workableJobGet.js +52 -0
- package/api/workable/workableJobMembersGet.js +52 -0
- package/api/workable/workableJobStagesGet.js +52 -0
- package/api/workable/workableJobsGet.js +78 -0
- package/api/yotpo/yotpo.utils.js +17 -22
- package/api/yotpo/yotpoCampaignsGet.js +6 -6
- package/api/yotpo/yotpoCustomerActionRecord.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversaryGet.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversarySet.js +7 -7
- package/api/yotpo/yotpoCustomerBirthdaySet.js +7 -7
- package/api/yotpo/yotpoCustomerGet.js +6 -6
- package/api/yotpo/yotpoCustomerPointsAdjust.js +7 -7
- package/api/yotpo/yotpoCustomerUpsert.js +7 -7
- package/api/yotpo/yotpoCustomersRecentGet.js +6 -6
- package/api/yotpo/yotpoRedemptionCreate.js +7 -7
- package/api/yotpo/yotpoRedemptionOptionsGet.js +6 -6
- package/api/yotpo/yotpoVipTiersGet.js +5 -5
- package/api/youtube/youtube.constants.js +5 -0
- package/api/youtube/youtube.utils.js +77 -0
- package/api/youtube/youtubeChannelVideosGet.js +25 -70
- package/hosting/.hosting.yml.sample +9 -11
- package/hosting/copyCredsToEnv.js +58 -2
- package/hosting/deployFromHostingYml.js +9 -2
- package/hosting/hosting.utils.js +3 -2
- package/package.json +3 -1
- package/server.utils.js +1 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
const { randomUUID } = require('crypto');
|
|
2
|
+
const { createReadStream } = require('fs');
|
|
3
|
+
const fs = require('fs').promises;
|
|
4
|
+
|
|
5
|
+
const { HOSTED, TEMP_DIR } = require('../constants');
|
|
6
|
+
const { credsValidator } = require('../validators');
|
|
7
|
+
const {
|
|
8
|
+
ArgsWarden,
|
|
9
|
+
customFetch,
|
|
10
|
+
gidToId,
|
|
11
|
+
objectToFormData,
|
|
12
|
+
objHasAny,
|
|
13
|
+
objectArrayToJsonl,
|
|
14
|
+
jsonlToObjectArray,
|
|
15
|
+
wait,
|
|
16
|
+
valueProvided,
|
|
17
|
+
} = require('../utils');
|
|
18
|
+
const { shopifyStagedUploadCreate } = require('./shopifyStagedUploadCreate');
|
|
19
|
+
const { shopifyBulkOperationRunMutation } = require('./shopifyBulkOperationRunMutation');
|
|
20
|
+
const { shopifyBulkOperationGet } = require('./shopifyBulkOperationGet');
|
|
21
|
+
|
|
22
|
+
const bulkOpAttrs = `
|
|
23
|
+
id
|
|
24
|
+
status
|
|
25
|
+
type
|
|
26
|
+
objectCount
|
|
27
|
+
url
|
|
28
|
+
errorCode
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const createOrResumeBulkOpPayloadValidator = (payload) => {
|
|
32
|
+
const { mutation, input, bulkOperationId } = payload;
|
|
33
|
+
|
|
34
|
+
if (valueProvided(bulkOperationId)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return valueProvided(mutation) && objHasAny(input, ['data', 'filepath']);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const argsWarden = new ArgsWarden([
|
|
42
|
+
['credsPayload', credsValidator],
|
|
43
|
+
['createOrResumeBulkOpPayload', createOrResumeBulkOpPayloadValidator],
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
const shopifyBulkMutationDo = async (
|
|
47
|
+
credsPayload,
|
|
48
|
+
createOrResumeBulkOpPayload,
|
|
49
|
+
{
|
|
50
|
+
apiVersion,
|
|
51
|
+
clientIdentifier,
|
|
52
|
+
waitForResult = true,
|
|
53
|
+
} = {},
|
|
54
|
+
) => {
|
|
55
|
+
|
|
56
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
57
|
+
credsPayload,
|
|
58
|
+
createOrResumeBulkOpPayload,
|
|
59
|
+
});
|
|
60
|
+
if (rejectResponse) {
|
|
61
|
+
return rejectResponse;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const {
|
|
65
|
+
mutation,
|
|
66
|
+
input,
|
|
67
|
+
bulkOperationId,
|
|
68
|
+
} = createOrResumeBulkOpPayload;
|
|
69
|
+
|
|
70
|
+
let bulkOperation;
|
|
71
|
+
|
|
72
|
+
if (!bulkOperationId) {
|
|
73
|
+
|
|
74
|
+
if (HOSTED) {
|
|
75
|
+
return {
|
|
76
|
+
ok: false,
|
|
77
|
+
error: 'This function is only available locally',
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let {
|
|
82
|
+
data,
|
|
83
|
+
filepath,
|
|
84
|
+
} = input;
|
|
85
|
+
|
|
86
|
+
if (!filepath) {
|
|
87
|
+
await fs.mkdir(TEMP_DIR, { recursive: true });
|
|
88
|
+
filepath = `${ TEMP_DIR }/shopifyBulkMutationDo_${ randomUUID() }.jsonl`;
|
|
89
|
+
await fs.writeFile(filepath, objectArrayToJsonl(data));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const stagedUploadResponse = await shopifyStagedUploadCreate(
|
|
93
|
+
credsPayload,
|
|
94
|
+
{
|
|
95
|
+
resource: 'BULK_MUTATION_VARIABLES',
|
|
96
|
+
filename: filepath.split('/').pop(),
|
|
97
|
+
mimeType: 'text/jsonl',
|
|
98
|
+
httpMethod: 'POST',
|
|
99
|
+
},
|
|
100
|
+
{ apiVersion },
|
|
101
|
+
);
|
|
102
|
+
if (!stagedUploadResponse.ok) {
|
|
103
|
+
return stagedUploadResponse;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const { url, parameters } = stagedUploadResponse.data.stagedTargets[0];
|
|
107
|
+
|
|
108
|
+
const formData = objectToFormData(
|
|
109
|
+
Object.fromEntries(parameters.map(({ name, value }) => [name, value])),
|
|
110
|
+
);
|
|
111
|
+
formData.append('file', createReadStream(filepath));
|
|
112
|
+
|
|
113
|
+
const uploadResponse = await customFetch(url, {
|
|
114
|
+
method: 'post',
|
|
115
|
+
body: formData,
|
|
116
|
+
});
|
|
117
|
+
if (!uploadResponse.ok) {
|
|
118
|
+
return uploadResponse;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const stagedUploadPath = uploadResponse.data?.PostResponse?.Key;
|
|
122
|
+
|
|
123
|
+
const mutationRunResponse = await shopifyBulkOperationRunMutation(
|
|
124
|
+
credsPayload,
|
|
125
|
+
mutation,
|
|
126
|
+
stagedUploadPath,
|
|
127
|
+
{
|
|
128
|
+
apiVersion,
|
|
129
|
+
clientIdentifier,
|
|
130
|
+
returnAttrs: bulkOpAttrs,
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
if (!waitForResult) {
|
|
135
|
+
return mutationRunResponse;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const { ok: mutationRunOk, data: mutationRunData } = mutationRunResponse;
|
|
139
|
+
if (!mutationRunOk) {
|
|
140
|
+
return mutationRunResponse;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
bulkOperation = mutationRunData.bulkOperation;
|
|
144
|
+
bulkOperationId = gidToId(bulkOperation.id);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
while (['CREATED', 'RUNNING'].includes(bulkOperation?.status)) {
|
|
148
|
+
|
|
149
|
+
if (bulkOperation) {
|
|
150
|
+
await wait(5000);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const operationResponse = await shopifyBulkOperationGet(
|
|
154
|
+
credsPayload,
|
|
155
|
+
bulkOperationId,
|
|
156
|
+
{
|
|
157
|
+
apiVersion,
|
|
158
|
+
attrs: bulkOpAttrs,
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
if (!operationResponse.ok) {
|
|
162
|
+
return operationResponse;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
bulkOperation = operationResponse.data;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (bulkOperation.status !== 'COMPLETED') {
|
|
169
|
+
return {
|
|
170
|
+
ok: false,
|
|
171
|
+
error: {
|
|
172
|
+
code: 'BULK_OPERATION_FAILED',
|
|
173
|
+
message: `Bulk operation failed with status ${ bulkOperation.status }`,
|
|
174
|
+
details: bulkOperation,
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const resultsResponse = await customFetch(bulkOperation.url);
|
|
180
|
+
if (!resultsResponse.ok) {
|
|
181
|
+
return resultsResponse;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const results = jsonlToObjectArray(resultsResponse.data);
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
ok: true,
|
|
188
|
+
data: results,
|
|
189
|
+
meta: {
|
|
190
|
+
bulkOperation,
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const funcApiConfig = {
|
|
196
|
+
argsWarden,
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
module.exports = {
|
|
200
|
+
shopifyBulkMutationDo,
|
|
201
|
+
funcApiConfig,
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/*
|
|
205
|
+
curl -X POST "http://localhost:8000/shopifyBulkMutationDo" \
|
|
206
|
+
-H "Content-Type: application/json" \
|
|
207
|
+
-d '{
|
|
208
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
209
|
+
"arg": "1234"
|
|
210
|
+
}'
|
|
211
|
+
*/
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/queries/bulkOperation
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden, actionSingleOrMultiple } = require('../utils');
|
|
5
|
+
const { shopifyGetSingle } = require('./shopifyGetSingle');
|
|
6
|
+
|
|
7
|
+
const defaultAttrs = `
|
|
8
|
+
id
|
|
9
|
+
status
|
|
10
|
+
type
|
|
11
|
+
objectCount
|
|
12
|
+
url
|
|
13
|
+
errorCode
|
|
14
|
+
`.trim();
|
|
15
|
+
|
|
16
|
+
const argsWarden = new ArgsWarden([
|
|
17
|
+
['credsPayload', credsValidator],
|
|
18
|
+
['bulkOperationId'],
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const shopifyBulkOperationGetSingle = async (
|
|
22
|
+
credsPayload,
|
|
23
|
+
bulkOperationId,
|
|
24
|
+
{
|
|
25
|
+
apiVersion,
|
|
26
|
+
attrs = defaultAttrs,
|
|
27
|
+
} = {},
|
|
28
|
+
) => {
|
|
29
|
+
return shopifyGetSingle(
|
|
30
|
+
credsPayload,
|
|
31
|
+
'bulkOperation',
|
|
32
|
+
bulkOperationId,
|
|
33
|
+
{
|
|
34
|
+
apiVersion,
|
|
35
|
+
attrs,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const shopifyBulkOperationGet = async (
|
|
41
|
+
credsPayload,
|
|
42
|
+
bulkOperationId,
|
|
43
|
+
{
|
|
44
|
+
queueRunOptions,
|
|
45
|
+
apiVersion,
|
|
46
|
+
attrs = defaultAttrs,
|
|
47
|
+
} = {},
|
|
48
|
+
) => {
|
|
49
|
+
|
|
50
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
51
|
+
credsPayload,
|
|
52
|
+
bulkOperationId,
|
|
53
|
+
});
|
|
54
|
+
if (rejectResponse) {
|
|
55
|
+
return rejectResponse;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return actionSingleOrMultiple(
|
|
59
|
+
bulkOperationId,
|
|
60
|
+
shopifyBulkOperationGetSingle,
|
|
61
|
+
(bulkOperationIdItem) => ({
|
|
62
|
+
args: [credsPayload, bulkOperationIdItem, { apiVersion, attrs }],
|
|
63
|
+
}),
|
|
64
|
+
{
|
|
65
|
+
...(queueRunOptions ? { queueRunOptions } : {}),
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const funcApiConfig = {
|
|
71
|
+
argsWarden,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
shopifyBulkOperationGet,
|
|
76
|
+
funcApiConfig,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
curl -X POST "http://localhost:8000/shopifyBulkOperationGet" \
|
|
81
|
+
-H "Content-Type: application/json" \
|
|
82
|
+
-d '{
|
|
83
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
84
|
+
"bulkOperationId": "3525975375944"
|
|
85
|
+
}'
|
|
86
|
+
*/
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/bulkOperationRunMutation
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('./shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const defaultReturnAttrs = `
|
|
8
|
+
id
|
|
9
|
+
type
|
|
10
|
+
status
|
|
11
|
+
objectCount
|
|
12
|
+
url
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
const argsWarden = new ArgsWarden([
|
|
16
|
+
['credsPayload', credsValidator],
|
|
17
|
+
['mutation'],
|
|
18
|
+
['stagedUploadPath'],
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const shopifyBulkOperationRunMutation = async (
|
|
22
|
+
credsPayload,
|
|
23
|
+
mutation,
|
|
24
|
+
stagedUploadPath,
|
|
25
|
+
{
|
|
26
|
+
apiVersion,
|
|
27
|
+
returnAttrs = defaultReturnAttrs,
|
|
28
|
+
clientIdentifier,
|
|
29
|
+
} = {},
|
|
30
|
+
) => {
|
|
31
|
+
|
|
32
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
33
|
+
credsPayload,
|
|
34
|
+
mutation,
|
|
35
|
+
stagedUploadPath,
|
|
36
|
+
});
|
|
37
|
+
if (rejectResponse) {
|
|
38
|
+
return rejectResponse;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return shopifyMutationDo(
|
|
42
|
+
credsPayload,
|
|
43
|
+
'bulkOperationRunMutation',
|
|
44
|
+
{
|
|
45
|
+
mutationVariables: {
|
|
46
|
+
mutation: {
|
|
47
|
+
type: 'String!',
|
|
48
|
+
value: mutation,
|
|
49
|
+
},
|
|
50
|
+
stagedUploadPath: {
|
|
51
|
+
type: 'String!',
|
|
52
|
+
value: stagedUploadPath,
|
|
53
|
+
},
|
|
54
|
+
...clientIdentifier && {
|
|
55
|
+
clientIdentifier: {
|
|
56
|
+
type: 'String',
|
|
57
|
+
value: clientIdentifier,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
returnSchema: `bulkOperation { ${ returnAttrs } }`,
|
|
62
|
+
apiVersion,
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const funcApiConfig = {
|
|
68
|
+
argsWarden,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
module.exports = {
|
|
72
|
+
shopifyBulkOperationRunMutation,
|
|
73
|
+
funcApiConfig,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
curl -X POST "http://localhost:8000/shopifyBulkOperationRunMutation" \
|
|
78
|
+
-H "Content-Type: application/json" \
|
|
79
|
+
-d '{
|
|
80
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
81
|
+
"arg": "1234"
|
|
82
|
+
}'
|
|
83
|
+
*/
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/admin-graphql/latest/mutations/checkoutAndAccountsConfigurationUpdate
|
|
2
|
+
|
|
3
|
+
const { credsValidator } = require('../validators');
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { shopifyMutationDo } = require('../shopify/shopifyMutationDo');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['configurationId'],
|
|
10
|
+
['updatePayload'],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const defaultReturnConfigurationAttrs = 'id name isPublished updatedAt';
|
|
14
|
+
|
|
15
|
+
const shopifyCheckoutAndAccountsConfigurationUpdate = async (
|
|
16
|
+
credsPayload,
|
|
17
|
+
configurationId,
|
|
18
|
+
updatePayload,
|
|
19
|
+
{
|
|
20
|
+
apiVersion,
|
|
21
|
+
returnConfigurationAttrs = defaultReturnConfigurationAttrs,
|
|
22
|
+
} = {},
|
|
23
|
+
) => {
|
|
24
|
+
|
|
25
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
26
|
+
credsPayload,
|
|
27
|
+
configurationId,
|
|
28
|
+
updatePayload,
|
|
29
|
+
});
|
|
30
|
+
if (rejectResponse) {
|
|
31
|
+
return rejectResponse;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return shopifyMutationDo(
|
|
35
|
+
credsPayload,
|
|
36
|
+
'checkoutAndAccountsConfigurationUpdate',
|
|
37
|
+
{
|
|
38
|
+
mutationVariables: {
|
|
39
|
+
id: {
|
|
40
|
+
type: 'ID!',
|
|
41
|
+
value: `gid://shopify/CheckoutAndAccountsConfiguration/${ configurationId }`,
|
|
42
|
+
},
|
|
43
|
+
configuration: {
|
|
44
|
+
type: 'CheckoutAndAccountsConfigurationInput!',
|
|
45
|
+
value: updatePayload,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
returnSchema: `configuration { ${ returnConfigurationAttrs } }`,
|
|
49
|
+
apiVersion,
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const funcApiConfig = {
|
|
55
|
+
argsWarden,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
shopifyCheckoutAndAccountsConfigurationUpdate,
|
|
60
|
+
funcApiConfig,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
curl -X POST "http://localhost:8000/shopifyCheckoutAndAccountsConfigurationUpdate" \
|
|
65
|
+
-H "Content-Type: application/json" \
|
|
66
|
+
-d '{
|
|
67
|
+
"credsPayload": { "credsPath": "shopify.au" },
|
|
68
|
+
"configurationId": "123456789",
|
|
69
|
+
"updatePayload": {
|
|
70
|
+
"branding": {
|
|
71
|
+
"designTokens": {
|
|
72
|
+
"cornerRadius": {
|
|
73
|
+
"large": "LARGE"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}'
|
|
79
|
+
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://shopify.dev/docs/api/admin-graphql/latest/queries/collection
|
|
2
2
|
|
|
3
3
|
const { credsValidator } = require('../validators');
|
|
4
|
-
const { ArgsWarden, objHasAny
|
|
4
|
+
const { ArgsWarden, objHasAny } = require('../utils');
|
|
5
5
|
const { shopifyGetSingle } = require('../shopify/shopifyGetSingle');
|
|
6
6
|
const { shopifyClient } = require('../shopify/shopify.utils');
|
|
7
7
|
|
|
@@ -42,8 +42,6 @@ const shopifyCollectionGet = async (
|
|
|
42
42
|
|
|
43
43
|
if (!id) {
|
|
44
44
|
|
|
45
|
-
const creds = await credsFromPayload(credsPayload);
|
|
46
|
-
|
|
47
45
|
const query = `
|
|
48
46
|
query GetCollectionByIdentifier ($identifier: CollectionIdentifierInput!) {
|
|
49
47
|
collection: collectionByIdentifier(identifier: $identifier) {
|
|
@@ -60,10 +58,12 @@ const shopifyCollectionGet = async (
|
|
|
60
58
|
};
|
|
61
59
|
|
|
62
60
|
const response = await shopifyClient.fetch({
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
requestPayload: {
|
|
62
|
+
method: 'post',
|
|
63
|
+
body: { query, variables },
|
|
64
|
+
},
|
|
65
65
|
context: {
|
|
66
|
-
|
|
66
|
+
credsPayload,
|
|
67
67
|
apiVersion,
|
|
68
68
|
resultPath: 'data.collection',
|
|
69
69
|
},
|
|
@@ -75,7 +75,7 @@ const shopifyCollectionGet = async (
|
|
|
75
75
|
return shopifyGetSingle(
|
|
76
76
|
credsPayload,
|
|
77
77
|
'collection',
|
|
78
|
-
|
|
78
|
+
id,
|
|
79
79
|
{
|
|
80
80
|
apiVersion,
|
|
81
81
|
attrs,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// https://shopify.dev/docs/api/admin-graphql/latest/queries/customer
|
|
2
2
|
|
|
3
3
|
const { credsValidator } = require('../validators');
|
|
4
|
-
const { objHasAny,
|
|
4
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
5
5
|
const { shopifyGetSingle } = require('../shopify/shopifyGetSingle');
|
|
6
6
|
const { shopifyClient } = require('../shopify/shopify.utils');
|
|
7
7
|
|
|
@@ -44,8 +44,6 @@ const shopifyCustomerGet = async (
|
|
|
44
44
|
|
|
45
45
|
if (!customerId) {
|
|
46
46
|
|
|
47
|
-
const creds = await credsFromPayload(credsPayload);
|
|
48
|
-
|
|
49
47
|
const query = `
|
|
50
48
|
query GetCustomerByIdentifier ($identifier: CustomerIdentifierInput!) {
|
|
51
49
|
customer: customerByIdentifier(identifier: $identifier) {
|
|
@@ -63,10 +61,12 @@ const shopifyCustomerGet = async (
|
|
|
63
61
|
};
|
|
64
62
|
|
|
65
63
|
const response = await shopifyClient.fetch({
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
requestPayload: {
|
|
65
|
+
method: 'post',
|
|
66
|
+
body: { query, variables },
|
|
67
|
+
},
|
|
68
68
|
context: {
|
|
69
|
-
|
|
69
|
+
credsPayload,
|
|
70
70
|
apiVersion,
|
|
71
71
|
resultPath: 'data.customer',
|
|
72
72
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Getter, capitaliseString, ArgsWarden } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { shopifyClient } = require('./shopify.utils');
|
|
4
4
|
const { MAX_PER_PAGE } = require('./shopify.constants');
|
|
@@ -11,7 +11,7 @@ const argsWarden = new ArgsWarden([
|
|
|
11
11
|
const shopifyGetPacket = async (
|
|
12
12
|
// options on the main function can become args on the packet get if they have defaults
|
|
13
13
|
// TODO: Consider where defaults should lie
|
|
14
|
-
|
|
14
|
+
credsPayload,
|
|
15
15
|
resource,
|
|
16
16
|
resources,
|
|
17
17
|
attrs,
|
|
@@ -108,9 +108,10 @@ const shopifyGetPacket = async (
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
return await shopifyClient.fetch({
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
requestPayload: {
|
|
112
|
+
method: 'post',
|
|
113
|
+
body: {
|
|
114
|
+
query: `
|
|
114
115
|
query Get${ Resources } (
|
|
115
116
|
${ queryTypeDeclaration }
|
|
116
117
|
) {
|
|
@@ -129,10 +130,11 @@ const shopifyGetPacket = async (
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
`,
|
|
132
|
-
|
|
133
|
+
variables,
|
|
134
|
+
},
|
|
133
135
|
},
|
|
134
136
|
context: {
|
|
135
|
-
|
|
137
|
+
credsPayload,
|
|
136
138
|
apiVersion,
|
|
137
139
|
resultPath: `data.${ resources }`,
|
|
138
140
|
},
|
|
@@ -231,14 +233,12 @@ const shopifyGet = async (
|
|
|
231
233
|
return rejectResponse;
|
|
232
234
|
}
|
|
233
235
|
|
|
234
|
-
const creds = await credsFromPayload(credsPayload);
|
|
235
|
-
|
|
236
236
|
const getter = new Getter(
|
|
237
237
|
{
|
|
238
238
|
args: [
|
|
239
|
-
|
|
240
|
-
resource,
|
|
241
|
-
resources,
|
|
239
|
+
credsPayload,
|
|
240
|
+
resource,
|
|
241
|
+
resources,
|
|
242
242
|
attrs,
|
|
243
243
|
],
|
|
244
244
|
options: {
|
|
@@ -276,7 +276,12 @@ const shopifyGet = async (
|
|
|
276
276
|
return getter;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
-
|
|
279
|
+
const data = await getter.run({ returnAll: true });
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
ok: true,
|
|
283
|
+
data,
|
|
284
|
+
};
|
|
280
285
|
};
|
|
281
286
|
|
|
282
287
|
const funcApiConfig = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { capitaliseString, ArgsWarden } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { shopifyClient } = require('./shopify.utils');
|
|
4
4
|
|
|
@@ -35,8 +35,6 @@ const shopifyGetSingle = async (
|
|
|
35
35
|
return rejectResponse;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const creds = await credsFromPayload(credsPayload);
|
|
39
|
-
|
|
40
38
|
const Resource = capitaliseString(resource);
|
|
41
39
|
const usesId = !resourcesNotRequiringId.includes(resource);
|
|
42
40
|
|
|
@@ -49,15 +47,17 @@ const shopifyGetSingle = async (
|
|
|
49
47
|
`;
|
|
50
48
|
|
|
51
49
|
const response = await shopifyClient.fetch({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
requestPayload: {
|
|
51
|
+
method: 'post',
|
|
52
|
+
body: {
|
|
53
|
+
query,
|
|
54
|
+
variables: {
|
|
55
|
+
...(usesId ? { id: `gid://shopify/${ gidType || Resource }/${ id }` } : {}),
|
|
56
|
+
},
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
59
|
context: {
|
|
60
|
-
|
|
60
|
+
credsPayload,
|
|
61
61
|
apiVersion,
|
|
62
62
|
resultPath: `data.${ resource }`,
|
|
63
63
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { logDeep, ArgsWarden } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { shopifyClient } = require('./shopify.utils');
|
|
4
4
|
|
|
@@ -27,8 +27,6 @@ const shopifyMutationDo = async (
|
|
|
27
27
|
returnSchema += ' userErrors { field message }';
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const creds = await credsFromPayload(credsPayload);
|
|
31
|
-
|
|
32
30
|
const mutation = `
|
|
33
31
|
mutation ${ mutationName }(${ Object.entries(mutationVariables).map(([name, { type }]) => `$${ name }: ${ type }`).join(', ') }) {
|
|
34
32
|
${ mutationName }(${ Object.keys(mutationVariables).map(name => `${ name }: $${ name }`).join(', ') }) {
|
|
@@ -47,10 +45,12 @@ const shopifyMutationDo = async (
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
const response = await shopifyClient.fetch({
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
requestPayload: {
|
|
49
|
+
method: 'post',
|
|
50
|
+
body: { query: mutation, variables },
|
|
51
|
+
},
|
|
52
52
|
context: {
|
|
53
|
-
|
|
53
|
+
credsPayload,
|
|
54
54
|
apiVersion,
|
|
55
55
|
resultPath: `data.${ mutationName }`,
|
|
56
56
|
},
|