@ai4b-team/fsaos-gateway-sdk 4.2.2 → 4.3.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/README.md +5 -0
- package/dist/iife/gateway.js +4 -4
- package/dist/iife/gateway.js.map +3 -3
- package/dist/iife/ui.js +1 -1
- package/dist/index.cjs +31 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3142,6 +3142,8 @@ interface UploadOptions {
|
|
|
3142
3142
|
parentPath: string;
|
|
3143
3143
|
/** Override the file name (defaults to File.name). */
|
|
3144
3144
|
name?: string;
|
|
3145
|
+
/** On a name collision, save a numbered sibling (default) or return NAME_TAKEN. */
|
|
3146
|
+
collisionPolicy?: 'keep_both' | 'fail';
|
|
3145
3147
|
/** Override item_type (defaults to 'file'). */
|
|
3146
3148
|
itemType?: string;
|
|
3147
3149
|
/** Additional type_data fields to merge onto the created item. */
|
package/dist/index.d.ts
CHANGED
|
@@ -3142,6 +3142,8 @@ interface UploadOptions {
|
|
|
3142
3142
|
parentPath: string;
|
|
3143
3143
|
/** Override the file name (defaults to File.name). */
|
|
3144
3144
|
name?: string;
|
|
3145
|
+
/** On a name collision, save a numbered sibling (default) or return NAME_TAKEN. */
|
|
3146
|
+
collisionPolicy?: 'keep_both' | 'fail';
|
|
3145
3147
|
/** Override item_type (defaults to 'file'). */
|
|
3146
3148
|
itemType?: string;
|
|
3147
3149
|
/** Additional type_data fields to merge onto the created item. */
|
package/dist/index.js
CHANGED
|
@@ -1339,6 +1339,9 @@ function resubscribeAll(isReconnect = false) {
|
|
|
1339
1339
|
sendPathSubscribe(sub.path, sub.event_types);
|
|
1340
1340
|
}
|
|
1341
1341
|
if (!isReconnect) return;
|
|
1342
|
+
catchUpAfterGap("reconnect");
|
|
1343
|
+
}
|
|
1344
|
+
function catchUpAfterGap(reason) {
|
|
1342
1345
|
try {
|
|
1343
1346
|
const qc = getQueryClient();
|
|
1344
1347
|
refreshInfiniteItemsAfterReconnect(qc);
|
|
@@ -1347,9 +1350,9 @@ function resubscribeAll(isReconnect = false) {
|
|
|
1347
1350
|
void qc.invalidateQueries({ queryKey: vfsKeys.item(sub.path) });
|
|
1348
1351
|
void qc.invalidateQueries({ queryKey: vfsKeys.children(sub.path) });
|
|
1349
1352
|
}
|
|
1350
|
-
log("
|
|
1353
|
+
log("catchUpAfterGap:", reason, "- invalidated", activePaths.size, "paths");
|
|
1351
1354
|
} catch (err) {
|
|
1352
|
-
log("
|
|
1355
|
+
log("catchUpAfterGap: cache invalidation skipped", err);
|
|
1353
1356
|
}
|
|
1354
1357
|
}
|
|
1355
1358
|
function sendMessage(msg) {
|
|
@@ -1372,6 +1375,10 @@ function handleMessage(raw) {
|
|
|
1372
1375
|
console.warn("[WS] Server error:", msg.message);
|
|
1373
1376
|
return;
|
|
1374
1377
|
}
|
|
1378
|
+
if (msg.type === "resync") {
|
|
1379
|
+
catchUpAfterGap(typeof msg.reason === "string" ? msg.reason : "resync");
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1375
1382
|
if (msg.type === "event" || msg.event_type) {
|
|
1376
1383
|
const eventType = msg.event_type || "message";
|
|
1377
1384
|
const data = msg.data || msg;
|
|
@@ -5627,14 +5634,27 @@ function getRequiredFormFields(typeDef) {
|
|
|
5627
5634
|
(f) => required.has(f.key) || f.default_value === void 0
|
|
5628
5635
|
);
|
|
5629
5636
|
}
|
|
5630
|
-
var _idCounter = 0;
|
|
5631
5637
|
function generateUploadId() {
|
|
5632
|
-
return
|
|
5638
|
+
if (globalThis.crypto?.randomUUID) return globalThis.crypto.randomUUID();
|
|
5639
|
+
const bytes = new Uint8Array(16);
|
|
5640
|
+
if (globalThis.crypto?.getRandomValues) {
|
|
5641
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
5642
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
5643
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
5644
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
5645
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
5646
|
+
}
|
|
5647
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
5648
|
+
const n = Math.floor(Math.random() * 16);
|
|
5649
|
+
return (c === "x" ? n : n & 3 | 8).toString(16);
|
|
5650
|
+
});
|
|
5633
5651
|
}
|
|
5634
5652
|
async function uploadFile(file, options, onProgress, signal2) {
|
|
5635
5653
|
const fileName = options.name || (file instanceof File ? file.name : `file-${Date.now()}`);
|
|
5636
5654
|
const contentType = file.type || "application/octet-stream";
|
|
5637
5655
|
const itemType = options.itemType || "file";
|
|
5656
|
+
const collisionPolicy = options.collisionPolicy || "keep_both";
|
|
5657
|
+
const uploadId = collisionPolicy === "keep_both" ? generateUploadId() : void 0;
|
|
5638
5658
|
const createParams = {
|
|
5639
5659
|
parent_path: options.parentPath,
|
|
5640
5660
|
item_type: itemType,
|
|
@@ -5643,7 +5663,9 @@ async function uploadFile(file, options, onProgress, signal2) {
|
|
|
5643
5663
|
...options.typeData || {},
|
|
5644
5664
|
file_source: {
|
|
5645
5665
|
type: "upload",
|
|
5646
|
-
content_type: contentType
|
|
5666
|
+
content_type: contentType,
|
|
5667
|
+
collision_policy: collisionPolicy,
|
|
5668
|
+
...uploadId ? { upload_id: uploadId } : {}
|
|
5647
5669
|
}
|
|
5648
5670
|
}
|
|
5649
5671
|
};
|
|
@@ -5745,6 +5767,7 @@ function useFileUpload() {
|
|
|
5745
5767
|
const fileName = options.name || file.name;
|
|
5746
5768
|
const contentType = file.type || "application/octet-stream";
|
|
5747
5769
|
const itemType = options.itemType || "file";
|
|
5770
|
+
const collisionPolicy = options.collisionPolicy || "keep_both";
|
|
5748
5771
|
let itemId = existingState?.itemId || null;
|
|
5749
5772
|
let itemPath = existingState?.itemPath || null;
|
|
5750
5773
|
let storageKey = existingState?.storageKey || null;
|
|
@@ -5761,7 +5784,9 @@ function useFileUpload() {
|
|
|
5761
5784
|
...options.typeData || {},
|
|
5762
5785
|
file_source: {
|
|
5763
5786
|
type: "upload",
|
|
5764
|
-
content_type: contentType
|
|
5787
|
+
content_type: contentType,
|
|
5788
|
+
collision_policy: collisionPolicy,
|
|
5789
|
+
...collisionPolicy === "keep_both" ? { upload_id: uploadId } : {}
|
|
5765
5790
|
}
|
|
5766
5791
|
}
|
|
5767
5792
|
});
|