@constructive-io/sheets 0.13.0 → 0.13.1
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/dist/advanced.cjs +42 -5
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.js +2 -2
- package/dist/{chunk-CBXNKMN6.js → chunk-5QPNOKMA.js} +2 -2
- package/dist/{chunk-26J3DVW7.js → chunk-AYMXT3ME.js} +43 -6
- package/dist/chunk-AYMXT3ME.js.map +1 -0
- package/dist/{chunk-HETVHNMD.js → chunk-ZKANUG3F.js} +2 -2
- package/dist/index.cjs +42 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/testing.cjs +42 -5
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-26J3DVW7.js.map +0 -1
- /package/dist/{chunk-CBXNKMN6.js.map → chunk-5QPNOKMA.js.map} +0 -0
- /package/dist/{chunk-HETVHNMD.js.map → chunk-ZKANUG3F.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
useSheetsTable,
|
|
25
25
|
useSheetsTableCursor,
|
|
26
26
|
validateOrderByVariables
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-5QPNOKMA.js";
|
|
28
28
|
import {
|
|
29
29
|
SheetsAuthGate,
|
|
30
30
|
useSheetsForgotPassword,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from "./chunk-MXVNIKES.js";
|
|
35
35
|
import {
|
|
36
36
|
SheetsProvider
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-ZKANUG3F.js";
|
|
38
38
|
import {
|
|
39
39
|
ConstructiveError,
|
|
40
40
|
createSheetsExecute,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
resolveDownloadUrl,
|
|
44
44
|
reuseSheetsPlaceholderData,
|
|
45
45
|
sheetsQueryKeys
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-AYMXT3ME.js";
|
|
47
47
|
import "./chunk-4EZ6A23C.js";
|
|
48
48
|
import {
|
|
49
49
|
SheetsContext,
|
package/dist/testing.cjs
CHANGED
|
@@ -131,11 +131,39 @@ function resolveUploadCapability(schema) {
|
|
|
131
131
|
throw import_data.createError.badRequest("Uploads are not enabled for this endpoint.");
|
|
132
132
|
}
|
|
133
133
|
const downloadById = resolveDownloadByIdField(schema, typeByName, queryType, upload.uploadFieldName);
|
|
134
|
+
const uploadedTypeName = upload.uploadFieldName.replace(/^upload/, "");
|
|
135
|
+
const fileTypeName = typeByName.has(uploadedTypeName) ? uploadedTypeName : downloadById.fileTypeName;
|
|
136
|
+
let remove = {};
|
|
137
|
+
for (const field of mutationType?.fields ?? []) {
|
|
138
|
+
const inputArg = field.args.find((a) => a.name === "input");
|
|
139
|
+
const inputTypeName = namedTypeName(inputArg?.type);
|
|
140
|
+
const inputFields = inputTypeName ? typeByName.get(inputTypeName)?.inputFields : null;
|
|
141
|
+
if (!inputTypeName || !inputFields?.some((f) => f.name === PK_FIELD_NAME)) continue;
|
|
142
|
+
if (!inputFields.every((f) => f.name === PK_FIELD_NAME || f.name === "clientMutationId")) continue;
|
|
143
|
+
const payload = typeByName.get(namedTypeName(field.type) ?? "");
|
|
144
|
+
if (payload?.fields?.some((f) => namedTypeName(f.type) === fileTypeName)) {
|
|
145
|
+
remove = { deleteFieldName: field.name, deleteInputTypeName: inputTypeName };
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
134
149
|
return {
|
|
135
150
|
...upload,
|
|
136
|
-
...downloadById
|
|
151
|
+
...downloadById,
|
|
152
|
+
...remove
|
|
137
153
|
};
|
|
138
154
|
}
|
|
155
|
+
async function deleteUploadedFileRow(execute, cap, fileId) {
|
|
156
|
+
if (!cap.deleteFieldName || !cap.deleteInputTypeName) return;
|
|
157
|
+
const mutation = `
|
|
158
|
+
mutation SheetsUploadCleanup($input: ${cap.deleteInputTypeName}!) {
|
|
159
|
+
${cap.deleteFieldName}(input: $input) { __typename }
|
|
160
|
+
}
|
|
161
|
+
`.trim();
|
|
162
|
+
try {
|
|
163
|
+
await execute(mutation, { input: { [PK_FIELD_NAME]: fileId } });
|
|
164
|
+
} catch {
|
|
165
|
+
}
|
|
166
|
+
}
|
|
139
167
|
function resolveDownloadByIdField(schema, typeByName, queryType, uploadFieldName) {
|
|
140
168
|
const fileTypesWithDownloadUrl = /* @__PURE__ */ new Set();
|
|
141
169
|
for (const t of schema.types) {
|
|
@@ -253,6 +281,10 @@ async function callUploadOp(execute, cap, input) {
|
|
|
253
281
|
}
|
|
254
282
|
return payload;
|
|
255
283
|
}
|
|
284
|
+
var STORAGE_UPLOAD_BLOCKED_MESSAGE = "Upload failed: the storage server didn't accept the upload from this site. Check the bucket's allowed origins (CORS) and your connection.";
|
|
285
|
+
function storageUnreachableError() {
|
|
286
|
+
return import_data.createError.graphql(STORAGE_UPLOAD_BLOCKED_MESSAGE, "STORAGE_UPLOAD_BLOCKED");
|
|
287
|
+
}
|
|
256
288
|
async function presignedPut(url, buffer, contentType, onProgress) {
|
|
257
289
|
const total = buffer.byteLength;
|
|
258
290
|
if (onProgress && typeof XMLHttpRequest !== "undefined") {
|
|
@@ -266,8 +298,8 @@ async function presignedPut(url, buffer, contentType, onProgress) {
|
|
|
266
298
|
headers: { "Content-Type": contentType },
|
|
267
299
|
body: buffer
|
|
268
300
|
});
|
|
269
|
-
} catch
|
|
270
|
-
throw
|
|
301
|
+
} catch {
|
|
302
|
+
throw storageUnreachableError();
|
|
271
303
|
}
|
|
272
304
|
if (!response.ok) {
|
|
273
305
|
const body = await response.text().catch(() => "");
|
|
@@ -297,7 +329,7 @@ function putWithXHR(url, buffer, contentType, total, onProgress) {
|
|
|
297
329
|
reject(import_data.createError.badRequest(`Upload failed: ${xhr.status} ${xhr.statusText}${xhr.responseText ? ` \u2014 ${xhr.responseText}` : ""}`));
|
|
298
330
|
}
|
|
299
331
|
});
|
|
300
|
-
xhr.addEventListener("error", () => reject(
|
|
332
|
+
xhr.addEventListener("error", () => reject(storageUnreachableError()));
|
|
301
333
|
xhr.send(buffer);
|
|
302
334
|
});
|
|
303
335
|
}
|
|
@@ -481,7 +513,12 @@ function createSheetsUpload(config, getToken) {
|
|
|
481
513
|
if (!payload.uploadUrl) {
|
|
482
514
|
throw import_data2.createError.badRequest("Upload failed: server returned no uploadUrl for a non-deduplicated file.");
|
|
483
515
|
}
|
|
484
|
-
|
|
516
|
+
try {
|
|
517
|
+
await presignedPut(payload.uploadUrl, buffer, contentType, options?.onProgress);
|
|
518
|
+
} catch (error) {
|
|
519
|
+
await deleteUploadedFileRow(execute, cap, payload.fileId);
|
|
520
|
+
throw error;
|
|
521
|
+
}
|
|
485
522
|
} else {
|
|
486
523
|
options?.onProgress?.({ loaded: file.size, total: file.size, percentage: 100 });
|
|
487
524
|
}
|