@foxtware/mineral 0.1.13 → 0.1.14
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/api/shopify/shopifyBulkMutationDo.js +10 -5
- package/api/utils.js +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { randomUUID } = require('crypto');
|
|
2
|
-
const {
|
|
2
|
+
const { Blob } = require('buffer');
|
|
3
3
|
const fs = require('fs').promises;
|
|
4
4
|
|
|
5
5
|
const { HOSTED, TEMP_DIR } = require('../constants');
|
|
@@ -61,7 +61,7 @@ const shopifyBulkMutationDo = async (
|
|
|
61
61
|
return rejectResponse;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
let {
|
|
65
65
|
mutation,
|
|
66
66
|
input,
|
|
67
67
|
bulkOperationId,
|
|
@@ -104,11 +104,18 @@ const shopifyBulkMutationDo = async (
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
const { url, parameters } = stagedUploadResponse.data.stagedTargets[0];
|
|
107
|
+
const stagedUploadPath = parameters.find(({ name }) => name === 'key')?.value;
|
|
108
|
+
|
|
109
|
+
const fileBuffer = await fs.readFile(filepath);
|
|
107
110
|
|
|
108
111
|
const formData = objectToFormData(
|
|
109
112
|
Object.fromEntries(parameters.map(({ name, value }) => [name, value])),
|
|
110
113
|
);
|
|
111
|
-
formData.append(
|
|
114
|
+
formData.append(
|
|
115
|
+
'file',
|
|
116
|
+
new Blob([fileBuffer], { type: 'text/jsonl' }),
|
|
117
|
+
filepath.split('/').pop(),
|
|
118
|
+
);
|
|
112
119
|
|
|
113
120
|
const uploadResponse = await customFetch(url, {
|
|
114
121
|
method: 'post',
|
|
@@ -118,8 +125,6 @@ const shopifyBulkMutationDo = async (
|
|
|
118
125
|
return uploadResponse;
|
|
119
126
|
}
|
|
120
127
|
|
|
121
|
-
const stagedUploadPath = uploadResponse.data?.PostResponse?.Key;
|
|
122
|
-
|
|
123
128
|
const mutationRunResponse = await shopifyBulkOperationRunMutation(
|
|
124
129
|
credsPayload,
|
|
125
130
|
mutation,
|
package/api/utils.js
CHANGED