@gscdump/engine-sqlite 0.33.0 → 0.33.3
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/index.mjs +33 -4
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -20,6 +20,7 @@ function createCachedManifestStore(inner, options = {}) {
|
|
|
20
20
|
const userId = String(scope.userId);
|
|
21
21
|
if (scope.siteId && scope.table && scope.searchType !== void 0) {
|
|
22
22
|
cache.delete(`${userId}\0${scope.siteId}\0${scope.table}\0${scope.searchType}`);
|
|
23
|
+
cache.delete(`${userId}\0${scope.siteId}\0${scope.table}\0`);
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
26
|
const prefix = scope.siteId && scope.table ? `${userId}\0${scope.siteId}\0${scope.table}\0` : scope.siteId ? `${userId}\0${scope.siteId}\0` : `${userId}\0`;
|
|
@@ -48,6 +49,12 @@ function createCachedManifestStore(inner, options = {}) {
|
|
|
48
49
|
table: entry.table,
|
|
49
50
|
searchType: entry.searchType
|
|
50
51
|
});
|
|
52
|
+
for (const e of superseding ?? []) bust({
|
|
53
|
+
userId: e.userId,
|
|
54
|
+
siteId: e.siteId ?? "",
|
|
55
|
+
table: e.table,
|
|
56
|
+
searchType: e.searchType
|
|
57
|
+
});
|
|
51
58
|
},
|
|
52
59
|
registerVersions: async (entries, superseding) => {
|
|
53
60
|
await inner.registerVersions(entries, superseding);
|
|
@@ -57,15 +64,36 @@ function createCachedManifestStore(inner, options = {}) {
|
|
|
57
64
|
table: e.table,
|
|
58
65
|
searchType: e.searchType
|
|
59
66
|
});
|
|
67
|
+
for (const e of superseding ?? []) bust({
|
|
68
|
+
userId: e.userId,
|
|
69
|
+
siteId: e.siteId ?? "",
|
|
70
|
+
table: e.table,
|
|
71
|
+
searchType: e.searchType
|
|
72
|
+
});
|
|
60
73
|
},
|
|
61
74
|
listRetired: inner.listRetired.bind(inner),
|
|
62
|
-
delete:
|
|
75
|
+
delete: async (entries) => {
|
|
76
|
+
await inner.delete(entries);
|
|
77
|
+
for (const e of entries) bust({
|
|
78
|
+
userId: e.userId,
|
|
79
|
+
siteId: e.siteId ?? "",
|
|
80
|
+
table: e.table,
|
|
81
|
+
searchType: e.searchType
|
|
82
|
+
});
|
|
83
|
+
},
|
|
63
84
|
getWatermarks: inner.getWatermarks.bind(inner),
|
|
64
85
|
bumpWatermark: inner.bumpWatermark.bind(inner),
|
|
65
86
|
getSyncStates: inner.getSyncStates.bind(inner),
|
|
66
87
|
setSyncState: inner.setSyncState.bind(inner),
|
|
67
88
|
withLock: inner.withLock.bind(inner),
|
|
68
|
-
purgeTenant:
|
|
89
|
+
purgeTenant: async (filter) => {
|
|
90
|
+
const result = await inner.purgeTenant(filter);
|
|
91
|
+
bust({
|
|
92
|
+
userId: filter.userId,
|
|
93
|
+
siteId: filter.siteId
|
|
94
|
+
});
|
|
95
|
+
return result;
|
|
96
|
+
},
|
|
69
97
|
bust,
|
|
70
98
|
clear: () => cache.clear(),
|
|
71
99
|
stats: () => ({ size: cache.size })
|
|
@@ -412,7 +440,8 @@ function createD1ManifestStore(db) {
|
|
|
412
440
|
}
|
|
413
441
|
if (filter.searchType !== void 0) baseConds.push(filter.searchType === "web" ? or(eq$1(r2Manifest.searchType, "web"), isNull(r2Manifest.searchType)) : eq$1(r2Manifest.searchType, filter.searchType));
|
|
414
442
|
const PARTITION_CHUNK = 80;
|
|
415
|
-
if (filter.partitions
|
|
443
|
+
if (filter.partitions) {
|
|
444
|
+
if (filter.partitions.length === 0) return [];
|
|
416
445
|
const statements = [];
|
|
417
446
|
for (let i = 0; i < filter.partitions.length; i += PARTITION_CHUNK) {
|
|
418
447
|
const slice = filter.partitions.slice(i, i + PARTITION_CHUNK);
|
|
@@ -498,7 +527,7 @@ function createD1ManifestStore(db) {
|
|
|
498
527
|
set: {
|
|
499
528
|
newestDateSynced: sql$1`CASE WHEN excluded.newest_date_synced > newest_date_synced THEN excluded.newest_date_synced ELSE newest_date_synced END`,
|
|
500
529
|
oldestDateSynced: sql$1`CASE WHEN excluded.oldest_date_synced < oldest_date_synced THEN excluded.oldest_date_synced ELSE oldest_date_synced END`,
|
|
501
|
-
lastSyncAt: sql$1`excluded.last_sync_at`
|
|
530
|
+
lastSyncAt: sql$1`CASE WHEN excluded.last_sync_at > last_sync_at THEN excluded.last_sync_at ELSE last_sync_at END`
|
|
502
531
|
}
|
|
503
532
|
}).run();
|
|
504
533
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/engine-sqlite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.33.
|
|
4
|
+
"version": "0.33.3",
|
|
5
5
|
"description": "SQLite / D1 engine adapter for @gscdump/analysis — typed analytics over sqlite-proxy executors (Cloudflare D1, libsql).",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"drizzle-orm": "1.0.0-rc.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"gscdump": "0.33.
|
|
48
|
-
"
|
|
47
|
+
"@gscdump/engine": "0.33.3",
|
|
48
|
+
"gscdump": "0.33.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"drizzle-orm": "1.0.0-rc.3",
|