mnfst 0.5.293 → 0.5.294
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/lib/manifest.data.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
(function () {
|
|
4
4
|
|
|
5
|
-
const MANIFEST_BUILD_VERSION = '0.5.
|
|
5
|
+
const MANIFEST_BUILD_VERSION = '0.5.294';
|
|
6
6
|
|
|
7
7
|
/* Manifest Data Sources - Configuration */
|
|
8
8
|
|
|
@@ -7289,7 +7289,9 @@ function createReactiveFileManager(tableName, entryId, bucketName, columnName) {
|
|
|
7289
7289
|
|
|
7290
7290
|
// Get files for a specific table entry (generic - works with any table)
|
|
7291
7291
|
// Supports any scope (user/team/teams) - files are filtered by permissions automatically
|
|
7292
|
-
|
|
7292
|
+
// options.isCurrent: false once the caller's identity is gone (gates the stale-id cleanup)
|
|
7293
|
+
async function getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn = 'fileIds', options = {}) {
|
|
7294
|
+
const isCurrent = identityGuard(tableName, options.isCurrent);
|
|
7293
7295
|
const manifest = await window.ManifestDataConfig.ensureManifest();
|
|
7294
7296
|
const tableDataSource = manifest?.data?.[tableName];
|
|
7295
7297
|
|
|
@@ -7469,15 +7471,15 @@ async function getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn = 'f
|
|
|
7469
7471
|
}
|
|
7470
7472
|
}
|
|
7471
7473
|
|
|
7472
|
-
// Clean up confirmed-missing fileIds from the database entry
|
|
7473
|
-
if (confirmedMissingFileIds.length > 0) {
|
|
7474
|
+
// Clean up confirmed-missing fileIds from the database entry, only for the identity that read them
|
|
7475
|
+
if (confirmedMissingFileIds.length > 0 && isCurrent()) {
|
|
7474
7476
|
try {
|
|
7475
7477
|
const unlinkFileFromEntry = window.ManifestDataProxiesFiles?.unlinkFileFromEntry;
|
|
7476
7478
|
if (unlinkFileFromEntry) {
|
|
7477
7479
|
// Remove all confirmed-missing fileIds in parallel
|
|
7478
7480
|
await Promise.all(
|
|
7479
7481
|
confirmedMissingFileIds.map(fileId =>
|
|
7480
|
-
unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn)
|
|
7482
|
+
unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn, { isCurrent })
|
|
7481
7483
|
.catch(err => {
|
|
7482
7484
|
console.warn('[Manifest Data] Failed to unlink stale fileId:', {
|
|
7483
7485
|
fileId,
|
|
@@ -7670,7 +7672,7 @@ async function unlinkFileFromAllEntries(fileId, options = {}) {
|
|
|
7670
7672
|
return {};
|
|
7671
7673
|
}
|
|
7672
7674
|
|
|
7673
|
-
const fileIds = (Array.isArray(fileId) ? fileId : [fileId]).map(
|
|
7675
|
+
const fileIds = (Array.isArray(fileId) ? fileId : [fileId]).map(fileIdOf).filter(Boolean);
|
|
7674
7676
|
if (!fileIds.length) {
|
|
7675
7677
|
return {};
|
|
7676
7678
|
}
|
|
@@ -7702,9 +7704,7 @@ async function unlinkFileFromAllEntries(fileId, options = {}) {
|
|
|
7702
7704
|
|
|
7703
7705
|
const columns = fileLinkColumns(manifest, tableName, tableConfig, options.bucketId);
|
|
7704
7706
|
const affected = new Set();
|
|
7705
|
-
const
|
|
7706
|
-
const isCurrent = () => (!options.isCurrent || options.isCurrent())
|
|
7707
|
-
&& window.ManifestDataStore?.sourceGeneration?.(tableName) === generation;
|
|
7707
|
+
const isCurrent = identityGuard(tableName, options.isCurrent);
|
|
7708
7708
|
|
|
7709
7709
|
for (const entry of entries) {
|
|
7710
7710
|
for (const column of columns) {
|
|
@@ -7737,8 +7737,21 @@ async function unlinkFileFromAllEntries(fileId, options = {}) {
|
|
|
7737
7737
|
|
|
7738
7738
|
// Unlink a file from a table entry by removing the file ID from the entry's fileIds array
|
|
7739
7739
|
// Generic function - works with any table and any scope
|
|
7740
|
+
// The table's generation is captured at the call, so a queued write never lands for a later identity
|
|
7740
7741
|
function unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn = 'fileIds', options = {}) {
|
|
7741
|
-
|
|
7742
|
+
const isCurrent = identityGuard(tableName, options.isCurrent);
|
|
7743
|
+
return queueEntryFileWrite(tableName, entryId, fileIdsColumn, () => writeFileUnlink(tableName, entryId, fileId, fileIdsColumn, { ...options, isCurrent }));
|
|
7744
|
+
}
|
|
7745
|
+
|
|
7746
|
+
// A file reference as its id (none for an object without $id)
|
|
7747
|
+
function fileIdOf(id) {
|
|
7748
|
+
return id && typeof id === 'object' ? id.$id : id;
|
|
7749
|
+
}
|
|
7750
|
+
|
|
7751
|
+
// True while the source's generation (bumped on sign-out / account switch) and the caller's guard hold
|
|
7752
|
+
function identityGuard(dataSourceName, outer) {
|
|
7753
|
+
const generation = window.ManifestDataStore?.sourceGeneration?.(dataSourceName);
|
|
7754
|
+
return () => (!outer || outer()) && window.ManifestDataStore?.sourceGeneration?.(dataSourceName) === generation;
|
|
7742
7755
|
}
|
|
7743
7756
|
|
|
7744
7757
|
// options.isCurrent: false once the identity that started the write is gone
|
|
@@ -7996,6 +8009,7 @@ window.ManifestDataProxiesFiles.getFilesForEntry = getFilesForEntry;
|
|
|
7996
8009
|
window.ManifestDataProxiesFiles.linkFileToEntry = linkFileToEntry;
|
|
7997
8010
|
window.ManifestDataProxiesFiles.unlinkFileFromEntry = unlinkFileFromEntry;
|
|
7998
8011
|
window.ManifestDataProxiesFiles.unlinkFileFromAllEntries = unlinkFileFromAllEntries;
|
|
8012
|
+
window.ManifestDataProxiesFiles.identityGuard = identityGuard;
|
|
7999
8013
|
window.ManifestDataProxiesFiles.buildStoragePermissions = buildStoragePermissions;
|
|
8000
8014
|
window.ManifestDataProxiesFiles.reactiveFileManagers = reactiveFileManagers; // Legacy - will be removed
|
|
8001
8015
|
|
|
@@ -8483,6 +8497,9 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
|
|
|
8483
8497
|
|
|
8484
8498
|
// Handle storage operations
|
|
8485
8499
|
if (bucketId) {
|
|
8500
|
+
// Link writes a call starts land only for the identity that started it
|
|
8501
|
+
const bucketCurrent = () => window.ManifestDataProxiesFiles?.identityGuard?.(dataSourceName) || (() => true);
|
|
8502
|
+
|
|
8486
8503
|
// $delete / $remove: delete each file, land successes locally, then unlink them
|
|
8487
8504
|
const deleteBucketFiles = async (fileId) => {
|
|
8488
8505
|
const ids = (Array.isArray(fileId) ? fileId : [fileId]).map(id => id && typeof id === 'object' ? id.$id : id);
|
|
@@ -8999,7 +9016,7 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
|
|
|
8999
9016
|
if (!getFilesForEntry) {
|
|
9000
9017
|
throw new Error('[Manifest Data] File management functions not available');
|
|
9001
9018
|
}
|
|
9002
|
-
return await getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn || 'fileIds');
|
|
9019
|
+
return await getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn || 'fileIds', { isCurrent: bucketCurrent() });
|
|
9003
9020
|
} else if (method === '$preview') {
|
|
9004
9021
|
const [fileId, widthOrOptions, height] = args;
|
|
9005
9022
|
// Extract file ID - handle both object with $id property and string ID
|
|
@@ -9101,7 +9118,8 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
|
|
|
9101
9118
|
throw error;
|
|
9102
9119
|
}
|
|
9103
9120
|
} else if (method === '$unlinkFrom') {
|
|
9104
|
-
const [tableName, entryId,
|
|
9121
|
+
const [tableName, entryId, fileRef, fileIdsColumn] = args;
|
|
9122
|
+
const fileId = fileRef && typeof fileRef === 'object' ? fileRef.$id : fileRef;
|
|
9105
9123
|
if (!tableName || !entryId || !fileId) {
|
|
9106
9124
|
throw new Error('[Manifest Data] $unlinkFrom requires table name, entry ID, and file ID');
|
|
9107
9125
|
}
|
|
@@ -9109,25 +9127,27 @@ function createAppwriteMethodsHandler(dataSourceName, reloadDataSource) {
|
|
|
9109
9127
|
if (!unlinkFileFromEntry) {
|
|
9110
9128
|
throw new Error('[Manifest Data] File management functions not available');
|
|
9111
9129
|
}
|
|
9112
|
-
return await unlinkFileFromEntry(tableName, entryId, fileId
|
|
9130
|
+
return await unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn || 'fileIds', { isCurrent: bucketCurrent() });
|
|
9113
9131
|
} else if (method === '$removeFrom') {
|
|
9114
9132
|
// Convenience method: unlink file from entry with automatic refresh
|
|
9115
9133
|
// Usage: $x.assets.$removeFrom('projects', projectId, fileId)
|
|
9116
9134
|
// Automatically refreshes and returns the files list for that table/entry
|
|
9117
|
-
const [tableName, entryId,
|
|
9135
|
+
const [tableName, entryId, fileRef, fileIdsColumn] = args;
|
|
9136
|
+
const fileId = fileRef && typeof fileRef === 'object' ? fileRef.$id : fileRef;
|
|
9118
9137
|
if (!tableName || !entryId || !fileId) {
|
|
9119
9138
|
throw new Error('[Manifest Data] $removeFrom requires table name, entry ID, and file ID');
|
|
9120
9139
|
}
|
|
9121
9140
|
|
|
9141
|
+
const isCurrent = bucketCurrent();
|
|
9122
9142
|
const unlinkFileFromEntry = window.ManifestDataProxiesFiles?.unlinkFileFromEntry;
|
|
9123
9143
|
if (unlinkFileFromEntry) {
|
|
9124
|
-
await unlinkFileFromEntry(tableName, entryId, fileId
|
|
9144
|
+
await unlinkFileFromEntry(tableName, entryId, fileId, fileIdsColumn || 'fileIds', { isCurrent });
|
|
9125
9145
|
}
|
|
9126
9146
|
|
|
9127
9147
|
// Return the entry's refreshed files list
|
|
9128
9148
|
const getFilesForEntry = window.ManifestDataProxiesFiles?.getFilesForEntry;
|
|
9129
9149
|
if (getFilesForEntry) {
|
|
9130
|
-
return await getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn || 'fileIds');
|
|
9150
|
+
return await getFilesForEntry(tableName, entryId, bucketId, fileIdsColumn || 'fileIds', { isCurrent });
|
|
9131
9151
|
}
|
|
9132
9152
|
return null;
|
|
9133
9153
|
} else if (method === '$remove') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest.appwrite.auth.js": "sha384-gWLSeVPqCLMiUZB8MU7GqMg3x2yULFUsp8nTTZrPp/9Dlkix42rBn9yIimvwrHqZ",
|
|
3
|
-
"manifest.appwrite.data.js": "sha384-
|
|
3
|
+
"manifest.appwrite.data.js": "sha384-D4IDXhPPTWazy1vPyx9ueWuH2Y6Yf6xb4Dfs/BYeylYbMZZB8QHAnePWHrlinvS+",
|
|
4
4
|
"manifest.appwrite.presences.js": "sha384-LINPhIPTCK+rA8zd+HPUzMSEgH6Sl2vQMEyItT97bnEE2FYGYKqjXX+CWdt6nl9z",
|
|
5
5
|
"manifest.bindings.js": "sha384-lPtMf8Ykaic9gNVZKq8Scia1881ZeMAyxer3WCIkUNwwrgzGBWto1OXADUwjvORF",
|
|
6
6
|
"manifest.charts.js": "sha384-AFbP7mQnigy7DU1s+YE30yKTeQAKfgNazhbfSNbfd9ZpLgeulZKaPi/fAq3gJHDO",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"manifest.combobox.js": "sha384-/lJo6vaxKjgnBSRs/dzkhK1dzGk3GBw8FISoNJZB70mwAVwu1k5veZyBXjOb4keS",
|
|
12
12
|
"manifest.components.js": "sha384-7lu4Nw2GqpAUn63c3gYEvgfM58PYsdoPv3wzqPQfZ5bravqOY/lfE8HFKHsKflQj",
|
|
13
13
|
"manifest.computed.js": "sha384-GYML/e81gQfN+iDbqhPUgny8bINCyL+SrbTofoGk4hlCnLLjv51mCv42JMqq+ku5",
|
|
14
|
-
"manifest.data.js": "sha384-
|
|
14
|
+
"manifest.data.js": "sha384-FHjyoAiA9YsEYv1ptbFBidS1QjHwZT0kPhqsaT55TlhNUnHWPLh4WQa0fc3QPvl0",
|
|
15
15
|
"manifest.datepicker.js": "sha384-EzlMwvIxlla/0BuyhAEqxN0M8TGcWIWgEIg840V0akKQQK1uY648wPWMkobvtq/o",
|
|
16
16
|
"manifest.defer.js": "sha384-PRp7+dCZHnnl55rX2xrHutLrQnszHo7o5o9Tq28M/yjLZPuXDzcwQNxCdvbtCYSz",
|
|
17
17
|
"manifest.device.js": "sha384-YeQaS56L8IILqrQNBSeAOLwIh5DuAOrE60cYLK1+46qJtUrXlAvqGe2j5mbV4Vq7",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"manifest.status.js": "sha384-ofu7nBnVIGZ1U1o2R9d2H3V8aEMPUCVbl5FO3gIToXqi0oa36fTviEdh5UU7Kitw",
|
|
30
30
|
"manifest.submissions.js": "sha384-v9eS47ytAfTGIKAyVnbd0QWegucVS7yduvigqfsxxoqXmbaEoy0M2y+BiI4xeZBd",
|
|
31
31
|
"manifest.svg.js": "sha384-qr/8H9+2cIhSXNbRWRtIdrDlTOxKlNJqwEefHvCYoiBNW/kKhPTFa109Orv/EBnb",
|
|
32
|
-
"manifest.sw.js": "sha384-
|
|
32
|
+
"manifest.sw.js": "sha384-35dDeHB4G6W8nej4SWrNaDIlayoLDnlbK3/52ZGdBAHibtG5GwFMq5gsas+rqxfh",
|
|
33
33
|
"manifest.tabs.js": "sha384-otU09H7jnawVKQdLAYpMCd3jx00tgyPVr42D2hLIBzN5dG4se505YesavdnMqEi1",
|
|
34
34
|
"manifest.tailwind.js": "sha384-yuP3LEvWU+QVjxjkZ0YhErtC9RrGmhOmHjjFjhS9obqZbp5/KTIEnSR0CXDvHE0B",
|
|
35
35
|
"manifest.toasts.js": "sha384-UpOz9fAdGeGUhL0NamBg5iPepEfIy73p9HYdcxfOQC5b7CVsl7Our0skdZzaLNcC",
|
package/lib/manifest.sw.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
// Build stamps the published version here; unstamped (dev) falls back to the
|
|
18
18
|
// registration URL's `v`, then 'dev'.
|
|
19
|
-
const BUILD_VERSION = '0.5.
|
|
19
|
+
const BUILD_VERSION = '0.5.294';
|
|
20
20
|
const CACHE_PREFIX = 'mnfst-sw:';
|
|
21
21
|
const META_CACHE = CACHE_PREFIX + 'meta';
|
|
22
22
|
// Sized to hold a full precache.json warm-up (PRECACHE_MAX_ENTRIES server-side)
|