@foxtware/mineral 0.1.12 → 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.
@@ -1,5 +1,5 @@
1
1
  const { randomUUID } = require('crypto');
2
- const { createReadStream } = require('fs');
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
- const {
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('file', createReadStream(filepath));
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
@@ -101,6 +101,7 @@ const xmlResponseParser = (parserOptions = {}) => {
101
101
  };
102
102
 
103
103
  const getResponseParser = (contentType) => {
104
+ if (contentType?.includes('jsonl') || contentType?.includes('ndjson')) return (res) => res.text();
104
105
  if (contentType.includes('application/json')) return (res) => res.json();
105
106
  if (contentType.includes('text/xml')) return xmlResponseParser();
106
107
  if (contentType.includes('application/soap+xml')) return (res) => res.text();
@@ -1181,4 +1182,5 @@ module.exports = {
1181
1182
  sentenceCaseString,
1182
1183
  ArgsWarden,
1183
1184
  gidToId,
1185
+ valueProvided,
1184
1186
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foxtware/mineral",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "bin": {
5
5
  "mineral": "bin/mineral.js"
6
6
  },