@rocicorp/zero 0.14.2025021202 → 0.15.2025021200
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/out/{chunk-JMAJNHHI.js → chunk-VXFHQJ2K.js} +625 -409
- package/out/chunk-VXFHQJ2K.js.map +7 -0
- package/out/replicache/src/deleted-clients.d.ts +26 -0
- package/out/replicache/src/deleted-clients.d.ts.map +1 -0
- package/out/replicache/src/persist/client-gc.d.ts.map +1 -1
- package/out/replicache/src/persist/client-group-gc.d.ts +6 -2
- package/out/replicache/src/persist/client-group-gc.d.ts.map +1 -1
- package/out/replicache/src/persist/clients.d.ts +1 -2
- package/out/replicache/src/persist/clients.d.ts.map +1 -1
- package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
- package/out/replicache/src/replicache-impl.d.ts +1 -1
- package/out/replicache/src/replicache-impl.d.ts.map +1 -1
- package/out/shared/src/immutable.d.ts +1 -1
- package/out/shared/src/immutable.d.ts.map +1 -1
- package/out/shared/src/queue.d.ts +15 -0
- package/out/shared/src/queue.d.ts.map +1 -1
- package/out/shared/src/queue.js +23 -0
- package/out/shared/src/queue.js.map +1 -1
- package/out/shared/src/resolved-promises.d.ts +4 -0
- package/out/shared/src/resolved-promises.d.ts.map +1 -1
- package/out/shared/src/resolved-promises.js +4 -0
- package/out/shared/src/resolved-promises.js.map +1 -1
- package/out/solid.js +1 -1
- package/out/zero/src/build-schema.d.ts +1 -1
- package/out/zero/src/build-schema.d.ts.map +1 -1
- package/out/zero/src/build-schema.js +4 -1
- package/out/zero/src/build-schema.js.map +1 -1
- package/out/zero/src/deploy-permissions.d.ts +3 -0
- package/out/zero/src/deploy-permissions.d.ts.map +1 -0
- package/out/zero/src/deploy-permissions.js +3 -0
- package/out/zero/src/deploy-permissions.js.map +1 -0
- package/out/zero/src/zero-cache-dev.js +48 -47
- package/out/zero/src/zero-cache-dev.js.map +1 -1
- package/out/zero-cache/src/auth/load-permissions.d.ts +16 -0
- package/out/zero-cache/src/auth/load-permissions.d.ts.map +1 -0
- package/out/zero-cache/src/auth/load-permissions.js +58 -0
- package/out/zero-cache/src/auth/load-permissions.js.map +1 -0
- package/out/zero-cache/src/auth/read-authorizer.d.ts +2 -2
- package/out/zero-cache/src/auth/read-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.js +6 -1
- package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts +1 -3
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +11 -7
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +0 -215
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +0 -38
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/scripts/deploy-permissions.d.ts +2 -0
- package/out/zero-cache/src/scripts/deploy-permissions.d.ts.map +1 -0
- package/out/zero-cache/src/scripts/deploy-permissions.js +59 -0
- package/out/zero-cache/src/scripts/deploy-permissions.js.map +1 -0
- package/out/zero-cache/src/scripts/permissions.d.ts +30 -0
- package/out/zero-cache/src/scripts/permissions.d.ts.map +1 -0
- package/out/zero-cache/src/scripts/permissions.js +78 -0
- package/out/zero-cache/src/scripts/permissions.js.map +1 -0
- package/out/zero-cache/src/server/main.d.ts.map +1 -1
- package/out/zero-cache/src/server/main.js +6 -2
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/multi/config.d.ts +4 -10
- package/out/zero-cache/src/server/multi/config.d.ts.map +1 -1
- package/out/zero-cache/src/server/multi/config.js +4 -0
- package/out/zero-cache/src/server/multi/config.js.map +1 -1
- package/out/zero-cache/src/server/multi/run-worker.d.ts.map +1 -1
- package/out/zero-cache/src/server/multi/run-worker.js +4 -2
- package/out/zero-cache/src/server/multi/run-worker.js.map +1 -1
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +3 -5
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/change-source.js +4 -0
- package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +5 -5
- package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +4 -2
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +31 -2
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/sync-schema.js +2 -2
- package/out/zero-cache/src/services/dispatcher/{sync-dispatcher.d.ts → dispatcher.d.ts} +5 -4
- package/out/zero-cache/src/services/dispatcher/dispatcher.d.ts.map +1 -0
- package/out/zero-cache/src/services/dispatcher/dispatcher.js +64 -0
- package/out/zero-cache/src/services/dispatcher/dispatcher.js.map +1 -0
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +1 -3
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +2 -2
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +6 -4
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js +49 -11
- package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.js +18 -3
- package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts +8 -8
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +14 -16
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +6 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +8 -0
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.js +4 -0
- package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +5 -2
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +45 -21
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/pg.d.ts +6 -0
- package/out/zero-cache/src/types/pg.d.ts.map +1 -1
- package/out/zero-cache/src/types/pg.js +15 -2
- package/out/zero-cache/src/types/pg.js.map +1 -1
- package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connection.js +13 -7
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-client/src/client/crud.d.ts.map +1 -1
- package/out/zero-client/src/client/delete-clients-manager.d.ts +35 -0
- package/out/zero-client/src/client/delete-clients-manager.d.ts.map +1 -0
- package/out/zero-client/src/client/query-manager.d.ts +1 -1
- package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/zero-poke-handler.d.ts +1 -0
- package/out/zero-client/src/client/zero-poke-handler.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +7 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.d.ts +8 -0
- package/out/zero-protocol/src/connect.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.js +2 -0
- package/out/zero-protocol/src/connect.js.map +1 -1
- package/out/zero-protocol/src/delete-clients.d.ts +8 -7
- package/out/zero-protocol/src/delete-clients.d.ts.map +1 -1
- package/out/zero-protocol/src/delete-clients.js +4 -3
- package/out/zero-protocol/src/delete-clients.js.map +1 -1
- package/out/zero-protocol/src/down.d.ts +5 -1
- package/out/zero-protocol/src/down.d.ts.map +1 -1
- package/out/zero-protocol/src/down.js +2 -1
- package/out/zero-protocol/src/down.js.map +1 -1
- package/out/zero-protocol/src/poke.d.ts +2 -0
- package/out/zero-protocol/src/poke.d.ts.map +1 -1
- package/out/zero-protocol/src/poke.js +4 -0
- package/out/zero-protocol/src/poke.js.map +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts +11 -3
- package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
- package/out/zero-protocol/src/protocol-version.js +14 -4
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/up.d.ts +8 -3
- package/out/zero-protocol/src/up.d.ts.map +1 -1
- package/out/zero-schema/src/builder/schema-builder.d.ts +0 -1
- package/out/zero-schema/src/builder/schema-builder.d.ts.map +1 -1
- package/out/zero-schema/src/builder/schema-builder.js +0 -49
- package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
- package/out/zero-schema/src/compiled-permissions.d.ts +23 -19
- package/out/zero-schema/src/compiled-permissions.d.ts.map +1 -1
- package/out/zero-schema/src/compiled-permissions.js +7 -4
- package/out/zero-schema/src/compiled-permissions.js.map +1 -1
- package/out/zero-schema/src/mod.d.ts +1 -1
- package/out/zero-schema/src/mod.d.ts.map +1 -1
- package/out/zero-schema/src/permissions.d.ts.map +1 -1
- package/out/zero.js +1 -1
- package/out/zql/src/ivm/join.d.ts.map +1 -1
- package/out/zql/src/ivm/join.js +6 -2
- package/out/zql/src/ivm/join.js.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +2 -2
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +6 -8
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/{auth-query.d.ts → static-query.d.ts} +7 -3
- package/out/zql/src/query/static-query.d.ts.map +1 -0
- package/out/zql/src/query/{auth-query.js → static-query.js} +9 -5
- package/out/zql/src/query/static-query.js.map +1 -0
- package/package.json +4 -5
- package/out/chunk-JMAJNHHI.js.map +0 -7
- package/out/zero-cache/src/auth/load-schema.d.ts +0 -8
- package/out/zero-cache/src/auth/load-schema.d.ts.map +0 -1
- package/out/zero-cache/src/auth/load-schema.js +0 -26
- package/out/zero-cache/src/auth/load-schema.js.map +0 -1
- package/out/zero-cache/src/services/dispatcher/sync-dispatcher.d.ts.map +0 -1
- package/out/zero-cache/src/services/dispatcher/sync-dispatcher.js +0 -54
- package/out/zero-cache/src/services/dispatcher/sync-dispatcher.js.map +0 -1
- package/out/zero-schema/src/build-schema-options.d.ts +0 -17
- package/out/zero-schema/src/build-schema-options.d.ts.map +0 -1
- package/out/zero-schema/src/build-schema-options.js +0 -25
- package/out/zero-schema/src/build-schema-options.js.map +0 -1
- package/out/zero-schema/src/build-schema.d.ts +0 -2
- package/out/zero-schema/src/build-schema.d.ts.map +0 -1
- package/out/zero-schema/src/build-schema.js +0 -27
- package/out/zero-schema/src/build-schema.js.map +0 -1
- package/out/zql/src/query/auth-query.d.ts.map +0 -1
- package/out/zql/src/query/auth-query.js.map +0 -1
|
@@ -397,6 +397,8 @@ var promiseTrue = Promise.resolve(true);
|
|
|
397
397
|
var promiseFalse = Promise.resolve(false);
|
|
398
398
|
var promiseUndefined = Promise.resolve(void 0);
|
|
399
399
|
var promiseVoid = Promise.resolve();
|
|
400
|
+
var promiseNever = new Promise(() => {
|
|
401
|
+
});
|
|
400
402
|
|
|
401
403
|
// ../replicache/src/frozen-json.ts
|
|
402
404
|
var deepFrozenObjects = /* @__PURE__ */ new WeakSet();
|
|
@@ -723,7 +725,7 @@ var AbortError = class extends Error {
|
|
|
723
725
|
// ../shared/src/sleep.ts
|
|
724
726
|
import { resolver as resolver2 } from "@rocicorp/resolver";
|
|
725
727
|
var promiseVoid2 = Promise.resolve();
|
|
726
|
-
var
|
|
728
|
+
var promiseNever2 = new Promise(() => void 0);
|
|
727
729
|
function sleep(ms, signal) {
|
|
728
730
|
const newAbortError = () => new AbortError("Aborted");
|
|
729
731
|
if (signal?.aborted) {
|
|
@@ -749,7 +751,7 @@ function sleep(ms, signal) {
|
|
|
749
751
|
}
|
|
750
752
|
function sleepWithAbort(ms, signal) {
|
|
751
753
|
if (ms === 0) {
|
|
752
|
-
return [promiseVoid2,
|
|
754
|
+
return [promiseVoid2, promiseNever2];
|
|
753
755
|
}
|
|
754
756
|
const { promise: abortedPromise, resolve: abortedResolve } = resolver2();
|
|
755
757
|
const sleepPromise = new Promise((resolve) => {
|
|
@@ -1416,6 +1418,53 @@ var WriteImpl2 = class extends ReadImpl2 {
|
|
|
1416
1418
|
}
|
|
1417
1419
|
};
|
|
1418
1420
|
|
|
1421
|
+
// ../replicache/src/deleted-clients.ts
|
|
1422
|
+
var DELETED_CLIENTS_HEAD_NAME = "deleted-clients";
|
|
1423
|
+
var deletedClientsSchema = readonlyObject({
|
|
1424
|
+
clientIDs: readonlyArray(valita_exports.string()),
|
|
1425
|
+
clientGroupIDs: readonlyArray(valita_exports.string())
|
|
1426
|
+
});
|
|
1427
|
+
async function setDeletedClients(dagWrite, clientIDs, clientGroupIDs) {
|
|
1428
|
+
const data = {
|
|
1429
|
+
clientIDs: normalize(clientIDs),
|
|
1430
|
+
clientGroupIDs: normalize(clientGroupIDs)
|
|
1431
|
+
};
|
|
1432
|
+
const chunkData = deepFreeze(data);
|
|
1433
|
+
const chunk = dagWrite.createChunk(chunkData, []);
|
|
1434
|
+
await dagWrite.putChunk(chunk);
|
|
1435
|
+
await dagWrite.setHead(DELETED_CLIENTS_HEAD_NAME, chunk.hash);
|
|
1436
|
+
return data;
|
|
1437
|
+
}
|
|
1438
|
+
async function getDeletedClients(dagRead) {
|
|
1439
|
+
const hash2 = await dagRead.getHead(DELETED_CLIENTS_HEAD_NAME);
|
|
1440
|
+
if (hash2 === void 0) {
|
|
1441
|
+
return { clientIDs: [], clientGroupIDs: [] };
|
|
1442
|
+
}
|
|
1443
|
+
const chunk = await dagRead.mustGetChunk(hash2);
|
|
1444
|
+
return parse(chunk.data, deletedClientsSchema);
|
|
1445
|
+
}
|
|
1446
|
+
async function addDeletedClients(dagWrite, clientIDs, clientGroupIDs) {
|
|
1447
|
+
const { clientIDs: oldClientIDs, clientGroupIDs: oldClientGroupIDs } = await getDeletedClients(dagWrite);
|
|
1448
|
+
return setDeletedClients(
|
|
1449
|
+
dagWrite,
|
|
1450
|
+
[...oldClientIDs, ...clientIDs],
|
|
1451
|
+
[...oldClientGroupIDs, ...clientGroupIDs]
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
async function removeDeletedClients(dagWrite, clientIDs, clientGroupIDs) {
|
|
1455
|
+
const { clientIDs: oldClientIDs, clientGroupIDs: oldClientGroupIDs } = await getDeletedClients(dagWrite);
|
|
1456
|
+
const newDeletedClients = oldClientIDs.filter(
|
|
1457
|
+
(clientID) => !clientIDs.includes(clientID)
|
|
1458
|
+
);
|
|
1459
|
+
const newDeletedClientGroups = oldClientGroupIDs.filter(
|
|
1460
|
+
(clientGroupID) => !clientGroupIDs.includes(clientGroupID)
|
|
1461
|
+
);
|
|
1462
|
+
return setDeletedClients(dagWrite, newDeletedClients, newDeletedClientGroups);
|
|
1463
|
+
}
|
|
1464
|
+
function normalize(arr) {
|
|
1465
|
+
return [...new Set(arr)].sort();
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1419
1468
|
// ../replicache/src/format-version-enum.ts
|
|
1420
1469
|
var DD31 = 5;
|
|
1421
1470
|
var V6 = 6;
|
|
@@ -5736,7 +5785,7 @@ async function mustGetClient(id, dagRead) {
|
|
|
5736
5785
|
return client;
|
|
5737
5786
|
}
|
|
5738
5787
|
function initClientV6(newClientID, lc, perdag, mutatorNames, indexes, formatVersion, enableClientGroupForking) {
|
|
5739
|
-
return
|
|
5788
|
+
return withWrite(perdag, async (dagWrite) => {
|
|
5740
5789
|
async function setClientsAndClientGroupAndCommit(basisHash, cookieJSON, valueHash2, indexRecords2) {
|
|
5741
5790
|
const newSnapshotData = newSnapshotCommitDataDD31(
|
|
5742
5791
|
basisHash,
|
|
@@ -5770,7 +5819,6 @@ function initClientV6(newClientID, lc, perdag, mutatorNames, indexes, formatVers
|
|
|
5770
5819
|
setClients(newClients, dagWrite),
|
|
5771
5820
|
setClientGroup(newClientGroupID, clientGroup, dagWrite)
|
|
5772
5821
|
]);
|
|
5773
|
-
await dagWrite.commit();
|
|
5774
5822
|
return [newClient, chunk.hash, newClients, true];
|
|
5775
5823
|
}
|
|
5776
5824
|
const clients = await getClients(dagWrite);
|
|
@@ -5785,7 +5833,6 @@ function initClientV6(newClientID, lc, perdag, mutatorNames, indexes, formatVers
|
|
|
5785
5833
|
};
|
|
5786
5834
|
const newClients = new Map(clients).set(newClientID, newClient);
|
|
5787
5835
|
await setClients(newClients, dagWrite);
|
|
5788
|
-
await dagWrite.commit();
|
|
5789
5836
|
return [newClient, headHash, newClients, false];
|
|
5790
5837
|
}
|
|
5791
5838
|
if (!enableClientGroupForking || res.type === FIND_MATCHING_CLIENT_TYPE_NEW) {
|
|
@@ -5973,7 +6020,13 @@ function gcClients(clientID, dagStore, clientMaxInactiveTime, onClientsDeleted)
|
|
|
5973
6020
|
return clients;
|
|
5974
6021
|
}
|
|
5975
6022
|
await setClients(newClients, dagWrite);
|
|
5976
|
-
|
|
6023
|
+
const { clientIDs, clientGroupIDs } = await addDeletedClients(
|
|
6024
|
+
dagWrite,
|
|
6025
|
+
deletedClients,
|
|
6026
|
+
// gcClients does not delete client groups
|
|
6027
|
+
[]
|
|
6028
|
+
);
|
|
6029
|
+
onClientsDeleted(clientIDs, clientGroupIDs);
|
|
5977
6030
|
return newClients;
|
|
5978
6031
|
});
|
|
5979
6032
|
}
|
|
@@ -5981,11 +6034,15 @@ function gcClients(clientID, dagStore, clientMaxInactiveTime, onClientsDeleted)
|
|
|
5981
6034
|
// ../replicache/src/persist/client-group-gc.ts
|
|
5982
6035
|
var GC_INTERVAL_MS = 5 * 60 * 1e3;
|
|
5983
6036
|
var latestGCUpdate2;
|
|
5984
|
-
function initClientGroupGC(dagStore, lc, signal) {
|
|
6037
|
+
function initClientGroupGC(dagStore, enableMutationRecovery, onClientsDeleted, lc, signal) {
|
|
5985
6038
|
initBgIntervalProcess(
|
|
5986
6039
|
"ClientGroupGC",
|
|
5987
6040
|
() => {
|
|
5988
|
-
latestGCUpdate2 = gcClientGroups(
|
|
6041
|
+
latestGCUpdate2 = gcClientGroups(
|
|
6042
|
+
dagStore,
|
|
6043
|
+
enableMutationRecovery,
|
|
6044
|
+
onClientsDeleted
|
|
6045
|
+
);
|
|
5989
6046
|
return latestGCUpdate2;
|
|
5990
6047
|
},
|
|
5991
6048
|
() => GC_INTERVAL_MS,
|
|
@@ -5993,21 +6050,24 @@ function initClientGroupGC(dagStore, lc, signal) {
|
|
|
5993
6050
|
signal
|
|
5994
6051
|
);
|
|
5995
6052
|
}
|
|
5996
|
-
function gcClientGroups(dagStore) {
|
|
6053
|
+
function gcClientGroups(dagStore, enableMutationRecovery, onClientsDeleted) {
|
|
5997
6054
|
return withWrite(dagStore, async (tx) => {
|
|
5998
6055
|
const clients = await getClients(tx);
|
|
5999
6056
|
const clientGroupIDs = /* @__PURE__ */ new Set();
|
|
6000
6057
|
for (const client of clients.values()) {
|
|
6001
|
-
assertClientV6(client);
|
|
6002
6058
|
clientGroupIDs.add(client.clientGroupID);
|
|
6003
6059
|
}
|
|
6004
6060
|
const clientGroups = /* @__PURE__ */ new Map();
|
|
6061
|
+
const removeClientGroups = /* @__PURE__ */ new Set();
|
|
6005
6062
|
for (const [clientGroupID, clientGroup] of await getClientGroups(tx)) {
|
|
6006
|
-
if (clientGroupIDs.has(clientGroupID) || clientGroupHasPendingMutations(clientGroup)) {
|
|
6063
|
+
if (clientGroupIDs.has(clientGroupID) || enableMutationRecovery && clientGroupHasPendingMutations(clientGroup)) {
|
|
6007
6064
|
clientGroups.set(clientGroupID, clientGroup);
|
|
6065
|
+
} else {
|
|
6066
|
+
removeClientGroups.add(clientGroupID);
|
|
6008
6067
|
}
|
|
6009
6068
|
}
|
|
6010
6069
|
await setClientGroups(clientGroups, tx);
|
|
6070
|
+
onClientsDeleted([], [...removeClientGroups].sort());
|
|
6011
6071
|
return clientGroups;
|
|
6012
6072
|
});
|
|
6013
6073
|
}
|
|
@@ -7244,8 +7304,7 @@ var ReplicacheImpl = class {
|
|
|
7244
7304
|
enableScheduledRefresh = true,
|
|
7245
7305
|
enablePullAndPushInOpen = true,
|
|
7246
7306
|
enableClientGroupForking = true,
|
|
7247
|
-
onClientsDeleted = (
|
|
7248
|
-
this.#lc.info?.("ClientIDs deleted", clientIDs);
|
|
7307
|
+
onClientsDeleted = () => {
|
|
7249
7308
|
}
|
|
7250
7309
|
} = implOptions;
|
|
7251
7310
|
this.auth = auth ?? "";
|
|
@@ -7389,7 +7448,13 @@ var ReplicacheImpl = class {
|
|
|
7389
7448
|
this.#lc,
|
|
7390
7449
|
signal
|
|
7391
7450
|
);
|
|
7392
|
-
initClientGroupGC(
|
|
7451
|
+
initClientGroupGC(
|
|
7452
|
+
this.perdag,
|
|
7453
|
+
enableMutationRecovery,
|
|
7454
|
+
onClientsDeleted,
|
|
7455
|
+
this.#lc,
|
|
7456
|
+
signal
|
|
7457
|
+
);
|
|
7393
7458
|
initNewClientChannel(
|
|
7394
7459
|
this.name,
|
|
7395
7460
|
this.idbName,
|
|
@@ -8251,11 +8316,19 @@ async function collectIDBDatabases(idbDatabasesStore, now, maxAge, kvDropStore,
|
|
|
8251
8316
|
)
|
|
8252
8317
|
);
|
|
8253
8318
|
const dbNamesToRemove = [];
|
|
8319
|
+
const dbNamesToKeep = [];
|
|
8254
8320
|
const clientIDsToRemove = [];
|
|
8255
|
-
|
|
8321
|
+
const clientGroupIDsToRemove = [];
|
|
8322
|
+
for (const [
|
|
8323
|
+
dbName,
|
|
8324
|
+
[canCollect, clientIDs, clientGroupIDs]
|
|
8325
|
+
] of collectResults) {
|
|
8256
8326
|
if (canCollect) {
|
|
8257
8327
|
dbNamesToRemove.push(dbName);
|
|
8258
8328
|
clientIDsToRemove.push(...clientIDs);
|
|
8329
|
+
clientGroupIDsToRemove.push(...clientGroupIDs);
|
|
8330
|
+
} else {
|
|
8331
|
+
dbNamesToKeep.push(dbName);
|
|
8259
8332
|
}
|
|
8260
8333
|
}
|
|
8261
8334
|
const { errors } = await dropDatabases(
|
|
@@ -8266,8 +8339,24 @@ async function collectIDBDatabases(idbDatabasesStore, now, maxAge, kvDropStore,
|
|
|
8266
8339
|
if (errors.length) {
|
|
8267
8340
|
throw errors[0];
|
|
8268
8341
|
}
|
|
8269
|
-
if (clientIDsToRemove.length) {
|
|
8270
|
-
|
|
8342
|
+
if (clientIDsToRemove.length || clientGroupIDsToRemove.length) {
|
|
8343
|
+
const newClientIDsToRemove = clientIDsToRemove;
|
|
8344
|
+
const newClientGroupIDsToRemove = clientGroupIDsToRemove;
|
|
8345
|
+
for (const name of dbNamesToKeep) {
|
|
8346
|
+
await withWrite(newDagStore(name), async (dagWrite) => {
|
|
8347
|
+
const { clientIDs, clientGroupIDs } = await addDeletedClients(
|
|
8348
|
+
dagWrite,
|
|
8349
|
+
clientIDsToRemove,
|
|
8350
|
+
clientGroupIDsToRemove
|
|
8351
|
+
);
|
|
8352
|
+
newClientIDsToRemove.push(...clientIDs);
|
|
8353
|
+
newClientGroupIDsToRemove.push(...clientGroupIDs);
|
|
8354
|
+
});
|
|
8355
|
+
}
|
|
8356
|
+
onClientsDeleted(
|
|
8357
|
+
normalize(newClientIDsToRemove),
|
|
8358
|
+
normalize(newClientGroupIDsToRemove)
|
|
8359
|
+
);
|
|
8271
8360
|
}
|
|
8272
8361
|
}
|
|
8273
8362
|
async function dropDatabaseInternal(name, idbDatabasesStore, kvDropStore) {
|
|
@@ -8345,7 +8434,14 @@ function canDatabaseBeCollectedAndGetDeletedClientIDs(enableMutationRecovery, pe
|
|
|
8345
8434
|
}
|
|
8346
8435
|
}
|
|
8347
8436
|
const clients = await getClients(read);
|
|
8348
|
-
|
|
8437
|
+
const { clientIDs, clientGroupIDs } = await getDeletedClients(read);
|
|
8438
|
+
const newClientIDs = [...clientIDs];
|
|
8439
|
+
const newClientGroupIDs = [...clientGroupIDs];
|
|
8440
|
+
for (const [clientID, client] of clients) {
|
|
8441
|
+
newClientIDs.push(clientID);
|
|
8442
|
+
newClientGroupIDs.push(client.clientGroupID);
|
|
8443
|
+
}
|
|
8444
|
+
return [true, newClientIDs, newClientGroupIDs];
|
|
8349
8445
|
});
|
|
8350
8446
|
}
|
|
8351
8447
|
|
|
@@ -8374,87 +8470,6 @@ function one(...args) {
|
|
|
8374
8470
|
}));
|
|
8375
8471
|
}
|
|
8376
8472
|
|
|
8377
|
-
// ../zero-schema/src/name-mapper.ts
|
|
8378
|
-
function clientToServer(tables) {
|
|
8379
|
-
return createMapperFrom("client", tables);
|
|
8380
|
-
}
|
|
8381
|
-
function serverToClient(tables) {
|
|
8382
|
-
return createMapperFrom("server", tables);
|
|
8383
|
-
}
|
|
8384
|
-
function createMapperFrom(src, tables) {
|
|
8385
|
-
const mapping = new Map(
|
|
8386
|
-
Object.entries(tables).map(
|
|
8387
|
-
([tableName, { serverName: serverTableName, columns }]) => {
|
|
8388
|
-
let allColumnsSame = true;
|
|
8389
|
-
const names = {};
|
|
8390
|
-
for (const [name, { serverName }] of Object.entries(columns)) {
|
|
8391
|
-
if (serverName && serverName !== name) {
|
|
8392
|
-
allColumnsSame = false;
|
|
8393
|
-
}
|
|
8394
|
-
if (src === "client") {
|
|
8395
|
-
names[name] = serverName ?? name;
|
|
8396
|
-
} else {
|
|
8397
|
-
names[serverName ?? name] = name;
|
|
8398
|
-
}
|
|
8399
|
-
}
|
|
8400
|
-
return [
|
|
8401
|
-
src === "client" ? tableName : serverTableName ?? tableName,
|
|
8402
|
-
{
|
|
8403
|
-
tableName: src === "client" ? serverTableName ?? tableName : tableName,
|
|
8404
|
-
columns: names,
|
|
8405
|
-
allColumnsSame
|
|
8406
|
-
}
|
|
8407
|
-
];
|
|
8408
|
-
}
|
|
8409
|
-
)
|
|
8410
|
-
);
|
|
8411
|
-
return new NameMapper(mapping);
|
|
8412
|
-
}
|
|
8413
|
-
var NameMapper = class {
|
|
8414
|
-
#tables = /* @__PURE__ */ new Map();
|
|
8415
|
-
constructor(tables) {
|
|
8416
|
-
this.#tables = tables;
|
|
8417
|
-
}
|
|
8418
|
-
#getTable(src, ctx) {
|
|
8419
|
-
const table2 = this.#tables.get(src);
|
|
8420
|
-
if (!table2) {
|
|
8421
|
-
throw new Error(
|
|
8422
|
-
`unknown table "${src}" ${!ctx ? "" : `in ${JSON.stringify(ctx)}`}`
|
|
8423
|
-
);
|
|
8424
|
-
}
|
|
8425
|
-
return table2;
|
|
8426
|
-
}
|
|
8427
|
-
tableName(src, context) {
|
|
8428
|
-
return this.#getTable(src, context).tableName;
|
|
8429
|
-
}
|
|
8430
|
-
columnName(table2, src, ctx) {
|
|
8431
|
-
const dst = this.#getTable(table2, ctx).columns[src];
|
|
8432
|
-
if (!dst) {
|
|
8433
|
-
throw new Error(
|
|
8434
|
-
`unknown column "${src}" of "${table2}" table ${!ctx ? "" : `in ${JSON.stringify(ctx)}`}`
|
|
8435
|
-
);
|
|
8436
|
-
}
|
|
8437
|
-
return dst;
|
|
8438
|
-
}
|
|
8439
|
-
row(table2, row) {
|
|
8440
|
-
const dest = this.#getTable(table2);
|
|
8441
|
-
const { allColumnsSame, columns } = dest;
|
|
8442
|
-
if (allColumnsSame) {
|
|
8443
|
-
return row;
|
|
8444
|
-
}
|
|
8445
|
-
const clientRow = {};
|
|
8446
|
-
for (const col in row) {
|
|
8447
|
-
clientRow[columns[col] ?? col] = row[col];
|
|
8448
|
-
}
|
|
8449
|
-
return clientRow;
|
|
8450
|
-
}
|
|
8451
|
-
columns(table2, cols) {
|
|
8452
|
-
const dest = this.#getTable(table2);
|
|
8453
|
-
const { allColumnsSame, columns } = dest;
|
|
8454
|
-
return cols === void 0 || allColumnsSame ? cols : cols.map((col) => columns[col] ?? col);
|
|
8455
|
-
}
|
|
8456
|
-
};
|
|
8457
|
-
|
|
8458
8473
|
// ../zero-schema/src/builder/table-builder.ts
|
|
8459
8474
|
function table(name) {
|
|
8460
8475
|
return new TableBuilder({
|
|
@@ -8463,7 +8478,7 @@ function table(name) {
|
|
|
8463
8478
|
primaryKey: []
|
|
8464
8479
|
});
|
|
8465
8480
|
}
|
|
8466
|
-
function
|
|
8481
|
+
function string8() {
|
|
8467
8482
|
return new ColumnBuilder({
|
|
8468
8483
|
type: "string",
|
|
8469
8484
|
optional: false,
|
|
@@ -8971,245 +8986,100 @@ function compareUTF8MaybeNull(a, b) {
|
|
|
8971
8986
|
return 0;
|
|
8972
8987
|
}
|
|
8973
8988
|
|
|
8974
|
-
// ../
|
|
8975
|
-
var
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8989
|
+
// ../zero-protocol/src/protocol-version.ts
|
|
8990
|
+
var PROTOCOL_VERSION = 5;
|
|
8991
|
+
var MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 2;
|
|
8992
|
+
assert(MIN_SERVER_SUPPORTED_SYNC_PROTOCOL < PROTOCOL_VERSION);
|
|
8993
|
+
var MIN_SERVER_SUPPORTED_PERMISSIONS_PROTOCOL = 4;
|
|
8994
|
+
assert(MIN_SERVER_SUPPORTED_PERMISSIONS_PROTOCOL < PROTOCOL_VERSION);
|
|
8995
|
+
|
|
8996
|
+
// ../zql/src/query/query-impl.ts
|
|
8997
|
+
import { resolver as resolver7 } from "@rocicorp/resolver";
|
|
8998
|
+
|
|
8999
|
+
// ../shared/src/hash.ts
|
|
9000
|
+
import { xxHash32 } from "js-xxhash";
|
|
9001
|
+
var h64 = (s) => hash(s, 2);
|
|
9002
|
+
var h128 = (s) => hash(s, 4);
|
|
9003
|
+
function hash(str, words) {
|
|
9004
|
+
let hash2 = 0n;
|
|
9005
|
+
for (let i = 0; i < words; i++) {
|
|
9006
|
+
hash2 = (hash2 << 32n) + BigInt(xxHash32(str, i));
|
|
8986
9007
|
}
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
9008
|
+
return hash2;
|
|
9009
|
+
}
|
|
9010
|
+
|
|
9011
|
+
// ../zero-protocol/src/ast-hash.ts
|
|
9012
|
+
var hashCache = /* @__PURE__ */ new WeakMap();
|
|
9013
|
+
function hashOfAST(ast) {
|
|
9014
|
+
const normalized = normalizeAST(ast);
|
|
9015
|
+
const cached = hashCache.get(normalized);
|
|
9016
|
+
if (cached) {
|
|
9017
|
+
return cached;
|
|
8994
9018
|
}
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9019
|
+
const hash2 = h64(JSON.stringify(normalized)).toString(36);
|
|
9020
|
+
hashCache.set(normalized, hash2);
|
|
9021
|
+
return hash2;
|
|
9022
|
+
}
|
|
9023
|
+
|
|
9024
|
+
// ../zero-schema/src/table-schema.ts
|
|
9025
|
+
function isOneHop(r) {
|
|
9026
|
+
return r.length === 1;
|
|
9027
|
+
}
|
|
9028
|
+
function isTwoHop(r) {
|
|
9029
|
+
return r.length === 2;
|
|
9030
|
+
}
|
|
9031
|
+
|
|
9032
|
+
// ../zql/src/ivm/operator.ts
|
|
9033
|
+
var throwOutput = {
|
|
9034
|
+
push(_change) {
|
|
9035
|
+
throw new Error("Output not set");
|
|
9000
9036
|
}
|
|
9001
9037
|
};
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9038
|
+
|
|
9039
|
+
// ../zql/src/ivm/stream.ts
|
|
9040
|
+
function* take(stream, limit) {
|
|
9041
|
+
if (limit < 1) {
|
|
9042
|
+
return;
|
|
9006
9043
|
}
|
|
9007
|
-
|
|
9008
|
-
|
|
9044
|
+
let count = 0;
|
|
9045
|
+
for (const v2 of stream) {
|
|
9046
|
+
yield v2;
|
|
9047
|
+
if (++count === limit) {
|
|
9048
|
+
break;
|
|
9049
|
+
}
|
|
9009
9050
|
}
|
|
9010
|
-
return { type: "and", conditions: expressions };
|
|
9011
9051
|
}
|
|
9012
|
-
function
|
|
9013
|
-
const
|
|
9014
|
-
|
|
9015
|
-
|
|
9052
|
+
function first(stream) {
|
|
9053
|
+
const it = stream[Symbol.iterator]();
|
|
9054
|
+
const { value } = it.next();
|
|
9055
|
+
it.return?.();
|
|
9056
|
+
return value;
|
|
9057
|
+
}
|
|
9058
|
+
|
|
9059
|
+
// ../zql/src/ivm/exists.ts
|
|
9060
|
+
var Exists = class {
|
|
9061
|
+
#input;
|
|
9062
|
+
#relationshipName;
|
|
9063
|
+
#storage;
|
|
9064
|
+
#not;
|
|
9065
|
+
#parentJoinKey;
|
|
9066
|
+
#skipCache;
|
|
9067
|
+
#output = throwOutput;
|
|
9068
|
+
constructor(input, storage, relationshipName, parentJoinKey, type) {
|
|
9069
|
+
this.#input = input;
|
|
9070
|
+
this.#relationshipName = relationshipName;
|
|
9071
|
+
this.#input.setOutput(this);
|
|
9072
|
+
this.#storage = storage;
|
|
9073
|
+
assert(this.#input.getSchema().relationships[relationshipName]);
|
|
9074
|
+
this.#not = type === "NOT EXISTS";
|
|
9075
|
+
this.#parentJoinKey = parentJoinKey;
|
|
9076
|
+
this.#skipCache = areEqual(
|
|
9077
|
+
parentJoinKey,
|
|
9078
|
+
this.#input.getSchema().primaryKey
|
|
9079
|
+
);
|
|
9016
9080
|
}
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
}
|
|
9020
|
-
return { type: "or", conditions: expressions };
|
|
9021
|
-
}
|
|
9022
|
-
function not(expression) {
|
|
9023
|
-
switch (expression.type) {
|
|
9024
|
-
case "and":
|
|
9025
|
-
return {
|
|
9026
|
-
type: "or",
|
|
9027
|
-
conditions: expression.conditions.map(not)
|
|
9028
|
-
};
|
|
9029
|
-
case "or":
|
|
9030
|
-
return {
|
|
9031
|
-
type: "and",
|
|
9032
|
-
conditions: expression.conditions.map(not)
|
|
9033
|
-
};
|
|
9034
|
-
case "correlatedSubquery":
|
|
9035
|
-
return {
|
|
9036
|
-
type: "correlatedSubquery",
|
|
9037
|
-
related: expression.related,
|
|
9038
|
-
op: negateOperator(expression.op)
|
|
9039
|
-
};
|
|
9040
|
-
case "simple":
|
|
9041
|
-
return {
|
|
9042
|
-
type: "simple",
|
|
9043
|
-
op: negateOperator(expression.op),
|
|
9044
|
-
left: expression.left,
|
|
9045
|
-
right: expression.right
|
|
9046
|
-
};
|
|
9047
|
-
}
|
|
9048
|
-
}
|
|
9049
|
-
function cmp(field, opOrValue, value) {
|
|
9050
|
-
let op;
|
|
9051
|
-
if (value === void 0) {
|
|
9052
|
-
value = opOrValue;
|
|
9053
|
-
op = "=";
|
|
9054
|
-
} else {
|
|
9055
|
-
op = opOrValue;
|
|
9056
|
-
}
|
|
9057
|
-
return {
|
|
9058
|
-
type: "simple",
|
|
9059
|
-
left: { type: "column", name: field },
|
|
9060
|
-
right: isParameterReference(value) ? value[toStaticParam]() : { type: "literal", value },
|
|
9061
|
-
op
|
|
9062
|
-
};
|
|
9063
|
-
}
|
|
9064
|
-
function isParameterReference(value) {
|
|
9065
|
-
return value !== null && typeof value === "object" && value[toStaticParam];
|
|
9066
|
-
}
|
|
9067
|
-
var TRUE = {
|
|
9068
|
-
type: "and",
|
|
9069
|
-
conditions: []
|
|
9070
|
-
};
|
|
9071
|
-
var FALSE = {
|
|
9072
|
-
type: "or",
|
|
9073
|
-
conditions: []
|
|
9074
|
-
};
|
|
9075
|
-
function isAlwaysTrue(condition) {
|
|
9076
|
-
return condition.type === "and" && condition.conditions.length === 0;
|
|
9077
|
-
}
|
|
9078
|
-
function isAlwaysFalse(condition) {
|
|
9079
|
-
return condition.type === "or" && condition.conditions.length === 0;
|
|
9080
|
-
}
|
|
9081
|
-
function flatten(type, conditions) {
|
|
9082
|
-
const flattened2 = [];
|
|
9083
|
-
for (const c of conditions) {
|
|
9084
|
-
if (c.type === type) {
|
|
9085
|
-
flattened2.push(...c.conditions);
|
|
9086
|
-
} else {
|
|
9087
|
-
flattened2.push(c);
|
|
9088
|
-
}
|
|
9089
|
-
}
|
|
9090
|
-
return flattened2;
|
|
9091
|
-
}
|
|
9092
|
-
var negateSimpleOperatorMap = {
|
|
9093
|
-
["="]: "!=",
|
|
9094
|
-
["!="]: "=",
|
|
9095
|
-
["<"]: ">=",
|
|
9096
|
-
[">"]: "<=",
|
|
9097
|
-
[">="]: "<",
|
|
9098
|
-
["<="]: ">",
|
|
9099
|
-
["IN"]: "NOT IN",
|
|
9100
|
-
["NOT IN"]: "IN",
|
|
9101
|
-
["LIKE"]: "NOT LIKE",
|
|
9102
|
-
["NOT LIKE"]: "LIKE",
|
|
9103
|
-
["ILIKE"]: "NOT ILIKE",
|
|
9104
|
-
["NOT ILIKE"]: "ILIKE",
|
|
9105
|
-
["IS"]: "IS NOT",
|
|
9106
|
-
["IS NOT"]: "IS"
|
|
9107
|
-
};
|
|
9108
|
-
var negateOperatorMap = {
|
|
9109
|
-
...negateSimpleOperatorMap,
|
|
9110
|
-
["EXISTS"]: "NOT EXISTS",
|
|
9111
|
-
["NOT EXISTS"]: "EXISTS"
|
|
9112
|
-
};
|
|
9113
|
-
function negateOperator(op) {
|
|
9114
|
-
return must(negateOperatorMap[op]);
|
|
9115
|
-
}
|
|
9116
|
-
function filterUndefined(array9) {
|
|
9117
|
-
return array9.filter((e) => e !== void 0);
|
|
9118
|
-
}
|
|
9119
|
-
function filterTrue(conditions) {
|
|
9120
|
-
return conditions.filter((c) => !isAlwaysTrue(c));
|
|
9121
|
-
}
|
|
9122
|
-
function filterFalse(conditions) {
|
|
9123
|
-
return conditions.filter((c) => !isAlwaysFalse(c));
|
|
9124
|
-
}
|
|
9125
|
-
|
|
9126
|
-
// ../zql/src/query/query-impl.ts
|
|
9127
|
-
import { resolver as resolver7 } from "@rocicorp/resolver";
|
|
9128
|
-
|
|
9129
|
-
// ../shared/src/hash.ts
|
|
9130
|
-
import { xxHash32 } from "js-xxhash";
|
|
9131
|
-
var h64 = (s) => hash(s, 2);
|
|
9132
|
-
var h128 = (s) => hash(s, 4);
|
|
9133
|
-
function hash(str, words) {
|
|
9134
|
-
let hash2 = 0n;
|
|
9135
|
-
for (let i = 0; i < words; i++) {
|
|
9136
|
-
hash2 = (hash2 << 32n) + BigInt(xxHash32(str, i));
|
|
9137
|
-
}
|
|
9138
|
-
return hash2;
|
|
9139
|
-
}
|
|
9140
|
-
|
|
9141
|
-
// ../zero-protocol/src/ast-hash.ts
|
|
9142
|
-
var hashCache = /* @__PURE__ */ new WeakMap();
|
|
9143
|
-
function hashOfAST(ast) {
|
|
9144
|
-
const normalized = normalizeAST(ast);
|
|
9145
|
-
const cached = hashCache.get(normalized);
|
|
9146
|
-
if (cached) {
|
|
9147
|
-
return cached;
|
|
9148
|
-
}
|
|
9149
|
-
const hash2 = h64(JSON.stringify(normalized)).toString(36);
|
|
9150
|
-
hashCache.set(normalized, hash2);
|
|
9151
|
-
return hash2;
|
|
9152
|
-
}
|
|
9153
|
-
|
|
9154
|
-
// ../zero-schema/src/table-schema.ts
|
|
9155
|
-
function isOneHop(r) {
|
|
9156
|
-
return r.length === 1;
|
|
9157
|
-
}
|
|
9158
|
-
function isTwoHop(r) {
|
|
9159
|
-
return r.length === 2;
|
|
9160
|
-
}
|
|
9161
|
-
|
|
9162
|
-
// ../zql/src/ivm/operator.ts
|
|
9163
|
-
var throwOutput = {
|
|
9164
|
-
push(_change) {
|
|
9165
|
-
throw new Error("Output not set");
|
|
9166
|
-
}
|
|
9167
|
-
};
|
|
9168
|
-
|
|
9169
|
-
// ../zql/src/ivm/stream.ts
|
|
9170
|
-
function* take(stream, limit) {
|
|
9171
|
-
if (limit < 1) {
|
|
9172
|
-
return;
|
|
9173
|
-
}
|
|
9174
|
-
let count = 0;
|
|
9175
|
-
for (const v2 of stream) {
|
|
9176
|
-
yield v2;
|
|
9177
|
-
if (++count === limit) {
|
|
9178
|
-
break;
|
|
9179
|
-
}
|
|
9180
|
-
}
|
|
9181
|
-
}
|
|
9182
|
-
function first(stream) {
|
|
9183
|
-
const it = stream[Symbol.iterator]();
|
|
9184
|
-
const { value } = it.next();
|
|
9185
|
-
it.return?.();
|
|
9186
|
-
return value;
|
|
9187
|
-
}
|
|
9188
|
-
|
|
9189
|
-
// ../zql/src/ivm/exists.ts
|
|
9190
|
-
var Exists = class {
|
|
9191
|
-
#input;
|
|
9192
|
-
#relationshipName;
|
|
9193
|
-
#storage;
|
|
9194
|
-
#not;
|
|
9195
|
-
#parentJoinKey;
|
|
9196
|
-
#skipCache;
|
|
9197
|
-
#output = throwOutput;
|
|
9198
|
-
constructor(input, storage, relationshipName, parentJoinKey, type) {
|
|
9199
|
-
this.#input = input;
|
|
9200
|
-
this.#relationshipName = relationshipName;
|
|
9201
|
-
this.#input.setOutput(this);
|
|
9202
|
-
this.#storage = storage;
|
|
9203
|
-
assert(this.#input.getSchema().relationships[relationshipName]);
|
|
9204
|
-
this.#not = type === "NOT EXISTS";
|
|
9205
|
-
this.#parentJoinKey = parentJoinKey;
|
|
9206
|
-
this.#skipCache = areEqual(
|
|
9207
|
-
parentJoinKey,
|
|
9208
|
-
this.#input.getSchema().primaryKey
|
|
9209
|
-
);
|
|
9210
|
-
}
|
|
9211
|
-
setOutput(output) {
|
|
9212
|
-
this.#output = output;
|
|
9081
|
+
setOutput(output) {
|
|
9082
|
+
this.#output = output;
|
|
9213
9083
|
}
|
|
9214
9084
|
destroy() {
|
|
9215
9085
|
this.#input.destroy();
|
|
@@ -9619,11 +9489,11 @@ var Join = class {
|
|
|
9619
9489
|
const childSchema = child.getSchema();
|
|
9620
9490
|
this.#schema = {
|
|
9621
9491
|
...parentSchema,
|
|
9622
|
-
isHidden: hidden,
|
|
9623
9492
|
relationships: {
|
|
9624
9493
|
...parentSchema.relationships,
|
|
9625
9494
|
[relationshipName]: {
|
|
9626
9495
|
...childSchema,
|
|
9496
|
+
isHidden: hidden,
|
|
9627
9497
|
system
|
|
9628
9498
|
}
|
|
9629
9499
|
}
|
|
@@ -9686,7 +9556,15 @@ var Join = class {
|
|
|
9686
9556
|
});
|
|
9687
9557
|
break;
|
|
9688
9558
|
case "child":
|
|
9689
|
-
this.#output.push(
|
|
9559
|
+
this.#output.push({
|
|
9560
|
+
type: "child",
|
|
9561
|
+
node: this.#processParentNode(
|
|
9562
|
+
change.node.row,
|
|
9563
|
+
change.node.relationships,
|
|
9564
|
+
"fetch"
|
|
9565
|
+
),
|
|
9566
|
+
child: change.child
|
|
9567
|
+
});
|
|
9690
9568
|
break;
|
|
9691
9569
|
case "edit": {
|
|
9692
9570
|
if (rowEqualsForCompoundKey(
|
|
@@ -10564,11 +10442,11 @@ function createPredicateImpl(rhs, operator) {
|
|
|
10564
10442
|
case "LIKE":
|
|
10565
10443
|
return getLikePredicate(rhs, "");
|
|
10566
10444
|
case "NOT LIKE":
|
|
10567
|
-
return
|
|
10445
|
+
return not(getLikePredicate(rhs, ""));
|
|
10568
10446
|
case "ILIKE":
|
|
10569
10447
|
return getLikePredicate(rhs, "i");
|
|
10570
10448
|
case "NOT ILIKE":
|
|
10571
|
-
return
|
|
10449
|
+
return not(getLikePredicate(rhs, "i"));
|
|
10572
10450
|
case "IN": {
|
|
10573
10451
|
assert(Array.isArray(rhs));
|
|
10574
10452
|
const set = new Set(rhs);
|
|
@@ -10584,7 +10462,7 @@ function createPredicateImpl(rhs, operator) {
|
|
|
10584
10462
|
throw new Error(`Unexpected operator: ${operator}`);
|
|
10585
10463
|
}
|
|
10586
10464
|
}
|
|
10587
|
-
function
|
|
10465
|
+
function not(f) {
|
|
10588
10466
|
return (lhs) => !f(lhs);
|
|
10589
10467
|
}
|
|
10590
10468
|
function transformFilters(filters) {
|
|
@@ -10955,6 +10833,158 @@ var ArrayView = class {
|
|
|
10955
10833
|
}
|
|
10956
10834
|
};
|
|
10957
10835
|
|
|
10836
|
+
// ../zql/src/query/expression.ts
|
|
10837
|
+
var ExpressionBuilder = class {
|
|
10838
|
+
#exists;
|
|
10839
|
+
constructor(exists) {
|
|
10840
|
+
this.#exists = exists;
|
|
10841
|
+
this.exists = this.exists.bind(this);
|
|
10842
|
+
}
|
|
10843
|
+
get eb() {
|
|
10844
|
+
return this;
|
|
10845
|
+
}
|
|
10846
|
+
cmp(field, opOrValue, value) {
|
|
10847
|
+
return cmp(field, opOrValue, value);
|
|
10848
|
+
}
|
|
10849
|
+
cmpLit(left, op, right) {
|
|
10850
|
+
return {
|
|
10851
|
+
type: "simple",
|
|
10852
|
+
left: isParameterReference(left) ? left[toStaticParam]() : { type: "literal", value: left },
|
|
10853
|
+
right: isParameterReference(right) ? right[toStaticParam]() : { type: "literal", value: right },
|
|
10854
|
+
op
|
|
10855
|
+
};
|
|
10856
|
+
}
|
|
10857
|
+
and = and;
|
|
10858
|
+
or = or;
|
|
10859
|
+
not = not2;
|
|
10860
|
+
exists(relationship, cb) {
|
|
10861
|
+
return this.#exists(relationship, cb);
|
|
10862
|
+
}
|
|
10863
|
+
};
|
|
10864
|
+
function and(...conditions) {
|
|
10865
|
+
const expressions = filterTrue(filterUndefined(conditions));
|
|
10866
|
+
if (expressions.length === 1) {
|
|
10867
|
+
return expressions[0];
|
|
10868
|
+
}
|
|
10869
|
+
if (expressions.some(isAlwaysFalse)) {
|
|
10870
|
+
return FALSE;
|
|
10871
|
+
}
|
|
10872
|
+
return { type: "and", conditions: expressions };
|
|
10873
|
+
}
|
|
10874
|
+
function or(...conditions) {
|
|
10875
|
+
const expressions = filterFalse(filterUndefined(conditions));
|
|
10876
|
+
if (expressions.length === 1) {
|
|
10877
|
+
return expressions[0];
|
|
10878
|
+
}
|
|
10879
|
+
if (expressions.some(isAlwaysTrue)) {
|
|
10880
|
+
return TRUE;
|
|
10881
|
+
}
|
|
10882
|
+
return { type: "or", conditions: expressions };
|
|
10883
|
+
}
|
|
10884
|
+
function not2(expression) {
|
|
10885
|
+
switch (expression.type) {
|
|
10886
|
+
case "and":
|
|
10887
|
+
return {
|
|
10888
|
+
type: "or",
|
|
10889
|
+
conditions: expression.conditions.map(not2)
|
|
10890
|
+
};
|
|
10891
|
+
case "or":
|
|
10892
|
+
return {
|
|
10893
|
+
type: "and",
|
|
10894
|
+
conditions: expression.conditions.map(not2)
|
|
10895
|
+
};
|
|
10896
|
+
case "correlatedSubquery":
|
|
10897
|
+
return {
|
|
10898
|
+
type: "correlatedSubquery",
|
|
10899
|
+
related: expression.related,
|
|
10900
|
+
op: negateOperator(expression.op)
|
|
10901
|
+
};
|
|
10902
|
+
case "simple":
|
|
10903
|
+
return {
|
|
10904
|
+
type: "simple",
|
|
10905
|
+
op: negateOperator(expression.op),
|
|
10906
|
+
left: expression.left,
|
|
10907
|
+
right: expression.right
|
|
10908
|
+
};
|
|
10909
|
+
}
|
|
10910
|
+
}
|
|
10911
|
+
function cmp(field, opOrValue, value) {
|
|
10912
|
+
let op;
|
|
10913
|
+
if (value === void 0) {
|
|
10914
|
+
value = opOrValue;
|
|
10915
|
+
op = "=";
|
|
10916
|
+
} else {
|
|
10917
|
+
op = opOrValue;
|
|
10918
|
+
}
|
|
10919
|
+
return {
|
|
10920
|
+
type: "simple",
|
|
10921
|
+
left: { type: "column", name: field },
|
|
10922
|
+
right: isParameterReference(value) ? value[toStaticParam]() : { type: "literal", value },
|
|
10923
|
+
op
|
|
10924
|
+
};
|
|
10925
|
+
}
|
|
10926
|
+
function isParameterReference(value) {
|
|
10927
|
+
return value !== null && typeof value === "object" && value[toStaticParam];
|
|
10928
|
+
}
|
|
10929
|
+
var TRUE = {
|
|
10930
|
+
type: "and",
|
|
10931
|
+
conditions: []
|
|
10932
|
+
};
|
|
10933
|
+
var FALSE = {
|
|
10934
|
+
type: "or",
|
|
10935
|
+
conditions: []
|
|
10936
|
+
};
|
|
10937
|
+
function isAlwaysTrue(condition) {
|
|
10938
|
+
return condition.type === "and" && condition.conditions.length === 0;
|
|
10939
|
+
}
|
|
10940
|
+
function isAlwaysFalse(condition) {
|
|
10941
|
+
return condition.type === "or" && condition.conditions.length === 0;
|
|
10942
|
+
}
|
|
10943
|
+
function flatten(type, conditions) {
|
|
10944
|
+
const flattened2 = [];
|
|
10945
|
+
for (const c of conditions) {
|
|
10946
|
+
if (c.type === type) {
|
|
10947
|
+
flattened2.push(...c.conditions);
|
|
10948
|
+
} else {
|
|
10949
|
+
flattened2.push(c);
|
|
10950
|
+
}
|
|
10951
|
+
}
|
|
10952
|
+
return flattened2;
|
|
10953
|
+
}
|
|
10954
|
+
var negateSimpleOperatorMap = {
|
|
10955
|
+
["="]: "!=",
|
|
10956
|
+
["!="]: "=",
|
|
10957
|
+
["<"]: ">=",
|
|
10958
|
+
[">"]: "<=",
|
|
10959
|
+
[">="]: "<",
|
|
10960
|
+
["<="]: ">",
|
|
10961
|
+
["IN"]: "NOT IN",
|
|
10962
|
+
["NOT IN"]: "IN",
|
|
10963
|
+
["LIKE"]: "NOT LIKE",
|
|
10964
|
+
["NOT LIKE"]: "LIKE",
|
|
10965
|
+
["ILIKE"]: "NOT ILIKE",
|
|
10966
|
+
["NOT ILIKE"]: "ILIKE",
|
|
10967
|
+
["IS"]: "IS NOT",
|
|
10968
|
+
["IS NOT"]: "IS"
|
|
10969
|
+
};
|
|
10970
|
+
var negateOperatorMap = {
|
|
10971
|
+
...negateSimpleOperatorMap,
|
|
10972
|
+
["EXISTS"]: "NOT EXISTS",
|
|
10973
|
+
["NOT EXISTS"]: "EXISTS"
|
|
10974
|
+
};
|
|
10975
|
+
function negateOperator(op) {
|
|
10976
|
+
return must(negateOperatorMap[op]);
|
|
10977
|
+
}
|
|
10978
|
+
function filterUndefined(array9) {
|
|
10979
|
+
return array9.filter((e) => e !== void 0);
|
|
10980
|
+
}
|
|
10981
|
+
function filterTrue(conditions) {
|
|
10982
|
+
return conditions.filter((c) => !isAlwaysTrue(c));
|
|
10983
|
+
}
|
|
10984
|
+
function filterFalse(conditions) {
|
|
10985
|
+
return conditions.filter((c) => !isAlwaysFalse(c));
|
|
10986
|
+
}
|
|
10987
|
+
|
|
10958
10988
|
// ../zql/src/query/dnf.ts
|
|
10959
10989
|
function dnf(condition) {
|
|
10960
10990
|
return unwrap(dnfInner(condition));
|
|
@@ -11009,6 +11039,7 @@ function unwrap(c) {
|
|
|
11009
11039
|
}
|
|
11010
11040
|
|
|
11011
11041
|
// ../zql/src/query/query-impl.ts
|
|
11042
|
+
var astForTestingSymbol = Symbol();
|
|
11012
11043
|
function newQuery(delegate, schema, table2) {
|
|
11013
11044
|
return new QueryImpl(delegate, schema, table2);
|
|
11014
11045
|
}
|
|
@@ -11039,6 +11070,10 @@ var AbstractQuery = class {
|
|
|
11039
11070
|
get format() {
|
|
11040
11071
|
return this.#format;
|
|
11041
11072
|
}
|
|
11073
|
+
// Not part of Query or QueryInternal interface
|
|
11074
|
+
get [astForTestingSymbol]() {
|
|
11075
|
+
return this.#ast;
|
|
11076
|
+
}
|
|
11042
11077
|
hash() {
|
|
11043
11078
|
if (!this.#hash) {
|
|
11044
11079
|
const ast = this._completeAst();
|
|
@@ -11166,6 +11201,7 @@ var AbstractQuery = class {
|
|
|
11166
11201
|
parentField: firstRelation.sourceField,
|
|
11167
11202
|
childField: firstRelation.destField
|
|
11168
11203
|
},
|
|
11204
|
+
hidden: true,
|
|
11169
11205
|
subquery: {
|
|
11170
11206
|
table: junctionSchema,
|
|
11171
11207
|
alias: relationship,
|
|
@@ -11180,7 +11216,6 @@ var AbstractQuery = class {
|
|
|
11180
11216
|
parentField: secondRelation.sourceField,
|
|
11181
11217
|
childField: secondRelation.destField
|
|
11182
11218
|
},
|
|
11183
|
-
hidden: true,
|
|
11184
11219
|
subquery: addPrimaryKeysToAst(
|
|
11185
11220
|
this.#schema.tables[destSchema],
|
|
11186
11221
|
sq.#ast
|
|
@@ -11393,21 +11428,14 @@ var AbstractQuery = class {
|
|
|
11393
11428
|
return this.#completedAST;
|
|
11394
11429
|
}
|
|
11395
11430
|
};
|
|
11396
|
-
var astForTestingSymbol = Symbol();
|
|
11397
11431
|
var completedAstSymbol = Symbol();
|
|
11398
11432
|
var QueryImpl = class extends AbstractQuery {
|
|
11399
11433
|
#delegate;
|
|
11400
|
-
#ast;
|
|
11401
11434
|
constructor(delegate, schema, tableName, ast = { table: tableName }, format) {
|
|
11402
11435
|
super(schema, tableName, ast, format);
|
|
11403
11436
|
this.#delegate = delegate;
|
|
11404
|
-
this.#ast = ast;
|
|
11405
11437
|
}
|
|
11406
11438
|
_system = "client";
|
|
11407
|
-
// Not part of Query or QueryInternal interface
|
|
11408
|
-
get [astForTestingSymbol]() {
|
|
11409
|
-
return this.#ast;
|
|
11410
|
-
}
|
|
11411
11439
|
get [completedAstSymbol]() {
|
|
11412
11440
|
return this._completeAst();
|
|
11413
11441
|
}
|
|
@@ -11498,8 +11526,8 @@ function isCompoundKey(field) {
|
|
|
11498
11526
|
return Array.isArray(field) && field.length >= 1;
|
|
11499
11527
|
}
|
|
11500
11528
|
|
|
11501
|
-
// ../zql/src/query/
|
|
11502
|
-
var
|
|
11529
|
+
// ../zql/src/query/static-query.ts
|
|
11530
|
+
var StaticQuery = class _StaticQuery extends AbstractQuery {
|
|
11503
11531
|
constructor(schema, tableName, ast = { table: tableName }, format) {
|
|
11504
11532
|
super(schema, tableName, ast, format);
|
|
11505
11533
|
}
|
|
@@ -11508,7 +11536,7 @@ var AuthQuery = class _AuthQuery extends AbstractQuery {
|
|
|
11508
11536
|
}
|
|
11509
11537
|
_system = "permissions";
|
|
11510
11538
|
_newQuery(schema, tableName, ast, format) {
|
|
11511
|
-
return new
|
|
11539
|
+
return new _StaticQuery(schema, tableName, ast, format);
|
|
11512
11540
|
}
|
|
11513
11541
|
get ast() {
|
|
11514
11542
|
return this._completeAst();
|
|
@@ -11524,13 +11552,97 @@ var AuthQuery = class _AuthQuery extends AbstractQuery {
|
|
|
11524
11552
|
}
|
|
11525
11553
|
};
|
|
11526
11554
|
|
|
11555
|
+
// ../zero-schema/src/name-mapper.ts
|
|
11556
|
+
function clientToServer(tables) {
|
|
11557
|
+
return createMapperFrom("client", tables);
|
|
11558
|
+
}
|
|
11559
|
+
function serverToClient(tables) {
|
|
11560
|
+
return createMapperFrom("server", tables);
|
|
11561
|
+
}
|
|
11562
|
+
function createMapperFrom(src, tables) {
|
|
11563
|
+
const mapping = new Map(
|
|
11564
|
+
Object.entries(tables).map(
|
|
11565
|
+
([tableName, { serverName: serverTableName, columns }]) => {
|
|
11566
|
+
let allColumnsSame = true;
|
|
11567
|
+
const names = {};
|
|
11568
|
+
for (const [name, { serverName }] of Object.entries(columns)) {
|
|
11569
|
+
if (serverName && serverName !== name) {
|
|
11570
|
+
allColumnsSame = false;
|
|
11571
|
+
}
|
|
11572
|
+
if (src === "client") {
|
|
11573
|
+
names[name] = serverName ?? name;
|
|
11574
|
+
} else {
|
|
11575
|
+
names[serverName ?? name] = name;
|
|
11576
|
+
}
|
|
11577
|
+
}
|
|
11578
|
+
return [
|
|
11579
|
+
src === "client" ? tableName : serverTableName ?? tableName,
|
|
11580
|
+
{
|
|
11581
|
+
tableName: src === "client" ? serverTableName ?? tableName : tableName,
|
|
11582
|
+
columns: names,
|
|
11583
|
+
allColumnsSame
|
|
11584
|
+
}
|
|
11585
|
+
];
|
|
11586
|
+
}
|
|
11587
|
+
)
|
|
11588
|
+
);
|
|
11589
|
+
return new NameMapper(mapping);
|
|
11590
|
+
}
|
|
11591
|
+
var NameMapper = class {
|
|
11592
|
+
#tables = /* @__PURE__ */ new Map();
|
|
11593
|
+
constructor(tables) {
|
|
11594
|
+
this.#tables = tables;
|
|
11595
|
+
}
|
|
11596
|
+
#getTable(src, ctx) {
|
|
11597
|
+
const table2 = this.#tables.get(src);
|
|
11598
|
+
if (!table2) {
|
|
11599
|
+
throw new Error(
|
|
11600
|
+
`unknown table "${src}" ${!ctx ? "" : `in ${JSON.stringify(ctx)}`}`
|
|
11601
|
+
);
|
|
11602
|
+
}
|
|
11603
|
+
return table2;
|
|
11604
|
+
}
|
|
11605
|
+
tableName(src, context) {
|
|
11606
|
+
return this.#getTable(src, context).tableName;
|
|
11607
|
+
}
|
|
11608
|
+
columnName(table2, src, ctx) {
|
|
11609
|
+
const dst = this.#getTable(table2, ctx).columns[src];
|
|
11610
|
+
if (!dst) {
|
|
11611
|
+
throw new Error(
|
|
11612
|
+
`unknown column "${src}" of "${table2}" table ${!ctx ? "" : `in ${JSON.stringify(ctx)}`}`
|
|
11613
|
+
);
|
|
11614
|
+
}
|
|
11615
|
+
return dst;
|
|
11616
|
+
}
|
|
11617
|
+
row(table2, row) {
|
|
11618
|
+
const dest = this.#getTable(table2);
|
|
11619
|
+
const { allColumnsSame, columns } = dest;
|
|
11620
|
+
if (allColumnsSame) {
|
|
11621
|
+
return row;
|
|
11622
|
+
}
|
|
11623
|
+
const clientRow = {};
|
|
11624
|
+
for (const col in row) {
|
|
11625
|
+
clientRow[columns[col] ?? col] = row[col];
|
|
11626
|
+
}
|
|
11627
|
+
return clientRow;
|
|
11628
|
+
}
|
|
11629
|
+
columns(table2, cols) {
|
|
11630
|
+
const dest = this.#getTable(table2);
|
|
11631
|
+
const { allColumnsSame, columns } = dest;
|
|
11632
|
+
return cols === void 0 || allColumnsSame ? cols : cols.map((col) => columns[col] ?? col);
|
|
11633
|
+
}
|
|
11634
|
+
};
|
|
11635
|
+
|
|
11527
11636
|
// ../zero-schema/src/permissions.ts
|
|
11528
11637
|
var ANYONE_CAN = void 0;
|
|
11529
11638
|
var NOBODY_CAN = [];
|
|
11530
11639
|
async function definePermissions(schema, definer) {
|
|
11531
11640
|
const expressionBuilders = {};
|
|
11532
11641
|
for (const name of Object.keys(schema.tables)) {
|
|
11533
|
-
expressionBuilders[name] = new
|
|
11642
|
+
expressionBuilders[name] = new StaticQuery(
|
|
11643
|
+
schema,
|
|
11644
|
+
name
|
|
11645
|
+
).expressionBuilder();
|
|
11534
11646
|
}
|
|
11535
11647
|
const config = await definer();
|
|
11536
11648
|
return compilePermissions(schema, config, expressionBuilders);
|
|
@@ -11540,10 +11652,13 @@ function compilePermissions(schema, authz, expressionBuilders) {
|
|
|
11540
11652
|
return void 0;
|
|
11541
11653
|
}
|
|
11542
11654
|
const nameMapper = clientToServer(schema.tables);
|
|
11543
|
-
const ret = {
|
|
11655
|
+
const ret = {
|
|
11656
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
11657
|
+
tables: {}
|
|
11658
|
+
};
|
|
11544
11659
|
for (const [tableName, tableConfig] of Object.entries(authz)) {
|
|
11545
11660
|
const serverName = schema.tables[tableName].serverName ?? tableName;
|
|
11546
|
-
ret[serverName] = {
|
|
11661
|
+
ret.tables[serverName] = {
|
|
11547
11662
|
row: compileRowConfig(
|
|
11548
11663
|
nameMapper,
|
|
11549
11664
|
tableName,
|
|
@@ -11694,6 +11809,18 @@ function escapeLike(val) {
|
|
|
11694
11809
|
import { LogContext as LogContext4 } from "@rocicorp/logger";
|
|
11695
11810
|
import { resolver as resolver8 } from "@rocicorp/resolver";
|
|
11696
11811
|
|
|
11812
|
+
// ../zero-protocol/src/delete-clients.ts
|
|
11813
|
+
var deleteClientsBodySchema = valita_exports.union(
|
|
11814
|
+
readonlyObject({
|
|
11815
|
+
clientIDs: readonlyArray(valita_exports.string()).optional(),
|
|
11816
|
+
clientGroupIDs: readonlyArray(valita_exports.string()).optional()
|
|
11817
|
+
})
|
|
11818
|
+
);
|
|
11819
|
+
var deleteClientsMessageSchema = valita_exports.tuple([
|
|
11820
|
+
valita_exports.literal("deleteClients"),
|
|
11821
|
+
deleteClientsBodySchema
|
|
11822
|
+
]);
|
|
11823
|
+
|
|
11697
11824
|
// ../zero-protocol/src/queries-patch.ts
|
|
11698
11825
|
var putOpSchema = valita_exports.object({
|
|
11699
11826
|
op: valita_exports.literal("put"),
|
|
@@ -11720,7 +11847,8 @@ var connectedMessageSchema = valita_exports.tuple([
|
|
|
11720
11847
|
connectedBodySchema
|
|
11721
11848
|
]);
|
|
11722
11849
|
var initConnectionBodySchema = valita_exports.object({
|
|
11723
|
-
desiredQueriesPatch: queriesPatchSchema
|
|
11850
|
+
desiredQueriesPatch: queriesPatchSchema,
|
|
11851
|
+
deleted: deleteClientsBodySchema.optional()
|
|
11724
11852
|
});
|
|
11725
11853
|
var initConnectionMessageSchema = valita_exports.tuple([
|
|
11726
11854
|
valita_exports.literal("initConnection"),
|
|
@@ -11895,6 +12023,10 @@ var pokePartBodySchema = valita_exports.object({
|
|
|
11895
12023
|
});
|
|
11896
12024
|
var pokeEndBodySchema = valita_exports.object({
|
|
11897
12025
|
pokeID: valita_exports.string(),
|
|
12026
|
+
// If present, this should be the cookie stored with the client,
|
|
12027
|
+
// instead of the cookie presented in pokeStart.
|
|
12028
|
+
// TODO: Consider making this required and removing it from pokeStart.
|
|
12029
|
+
cookie: versionSchema.optional(),
|
|
11898
12030
|
// If `true`, the poke with id `pokeID` should be discarded without
|
|
11899
12031
|
// applying it.
|
|
11900
12032
|
cancel: valita_exports.boolean().optional()
|
|
@@ -11954,18 +12086,14 @@ var downstreamSchema = valita_exports.union(
|
|
|
11954
12086
|
pokeStartMessageSchema,
|
|
11955
12087
|
pokePartMessageSchema,
|
|
11956
12088
|
pokeEndMessageSchema,
|
|
11957
|
-
pullResponseMessageSchema
|
|
12089
|
+
pullResponseMessageSchema,
|
|
12090
|
+
deleteClientsMessageSchema
|
|
11958
12091
|
);
|
|
11959
12092
|
|
|
11960
12093
|
// ../zero-protocol/src/mutation-type-enum.ts
|
|
11961
12094
|
var CRUD = "crud";
|
|
11962
12095
|
var Custom = "custom";
|
|
11963
12096
|
|
|
11964
|
-
// ../zero-protocol/src/protocol-version.ts
|
|
11965
|
-
var PROTOCOL_VERSION = 4;
|
|
11966
|
-
var MIN_SERVER_SUPPORTED_PROTOCOL_VERSION = 2;
|
|
11967
|
-
assert(MIN_SERVER_SUPPORTED_PROTOCOL_VERSION < PROTOCOL_VERSION);
|
|
11968
|
-
|
|
11969
12097
|
// ../zero-protocol/src/push.ts
|
|
11970
12098
|
var CRUD_MUTATION_NAME = "_zero_crud";
|
|
11971
12099
|
var insertOpSchema = valita_exports.object({
|
|
@@ -13308,48 +13436,28 @@ var ZeroContext = class {
|
|
|
13308
13436
|
// ../zero-client/src/client/crud.ts
|
|
13309
13437
|
function makeCRUDMutate(schema, repMutate) {
|
|
13310
13438
|
const { [CRUD_MUTATION_NAME]: zeroCRUD } = repMutate;
|
|
13311
|
-
let inBatch = false;
|
|
13312
13439
|
const mutateBatch = async (body) => {
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
try {
|
|
13318
|
-
const ops = [];
|
|
13319
|
-
const m = {};
|
|
13320
|
-
for (const name of Object.keys(schema.tables)) {
|
|
13321
|
-
m[name] = makeBatchCRUDMutate(name, schema, ops);
|
|
13322
|
-
}
|
|
13323
|
-
const rv = await body(m);
|
|
13324
|
-
await zeroCRUD({ ops });
|
|
13325
|
-
return rv;
|
|
13326
|
-
} finally {
|
|
13327
|
-
inBatch = false;
|
|
13328
|
-
}
|
|
13329
|
-
};
|
|
13330
|
-
const assertNotInBatch = (tableName, op) => {
|
|
13331
|
-
if (inBatch) {
|
|
13332
|
-
throw new Error(`Cannot call mutate.${tableName}.${op} inside a batch`);
|
|
13440
|
+
const ops = [];
|
|
13441
|
+
const m = {};
|
|
13442
|
+
for (const name of Object.keys(schema.tables)) {
|
|
13443
|
+
m[name] = makeBatchCRUDMutate(name, schema, ops);
|
|
13333
13444
|
}
|
|
13445
|
+
const rv = await body(m);
|
|
13446
|
+
await zeroCRUD({ ops });
|
|
13447
|
+
return rv;
|
|
13334
13448
|
};
|
|
13335
13449
|
const mutate = {};
|
|
13336
13450
|
for (const [name, tableSchema] of Object.entries(schema.tables)) {
|
|
13337
|
-
mutate[name] = makeEntityCRUDMutate(
|
|
13338
|
-
name,
|
|
13339
|
-
tableSchema.primaryKey,
|
|
13340
|
-
zeroCRUD,
|
|
13341
|
-
assertNotInBatch
|
|
13342
|
-
);
|
|
13451
|
+
mutate[name] = makeEntityCRUDMutate(name, tableSchema.primaryKey, zeroCRUD);
|
|
13343
13452
|
}
|
|
13344
13453
|
return {
|
|
13345
13454
|
mutate,
|
|
13346
13455
|
mutateBatch
|
|
13347
13456
|
};
|
|
13348
13457
|
}
|
|
13349
|
-
function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD
|
|
13458
|
+
function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD) {
|
|
13350
13459
|
return {
|
|
13351
13460
|
insert: (value) => {
|
|
13352
|
-
assertNotInBatch(tableName, "insert");
|
|
13353
13461
|
const op = {
|
|
13354
13462
|
op: "insert",
|
|
13355
13463
|
tableName,
|
|
@@ -13359,7 +13467,6 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch)
|
|
|
13359
13467
|
return zeroCRUD({ ops: [op] });
|
|
13360
13468
|
},
|
|
13361
13469
|
upsert: (value) => {
|
|
13362
|
-
assertNotInBatch(tableName, "upsert");
|
|
13363
13470
|
const op = {
|
|
13364
13471
|
op: "upsert",
|
|
13365
13472
|
tableName,
|
|
@@ -13369,7 +13476,6 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch)
|
|
|
13369
13476
|
return zeroCRUD({ ops: [op] });
|
|
13370
13477
|
},
|
|
13371
13478
|
update: (value) => {
|
|
13372
|
-
assertNotInBatch(tableName, "update");
|
|
13373
13479
|
const op = {
|
|
13374
13480
|
op: "update",
|
|
13375
13481
|
tableName,
|
|
@@ -13379,7 +13485,6 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch)
|
|
|
13379
13485
|
return zeroCRUD({ ops: [op] });
|
|
13380
13486
|
},
|
|
13381
13487
|
delete: (id) => {
|
|
13382
|
-
assertNotInBatch(tableName, "delete");
|
|
13383
13488
|
const op = {
|
|
13384
13489
|
op: "delete",
|
|
13385
13490
|
tableName,
|
|
@@ -13630,6 +13735,57 @@ function makeTableCRUD(schema, tableName, tx, ivmBranch) {
|
|
|
13630
13735
|
};
|
|
13631
13736
|
}
|
|
13632
13737
|
|
|
13738
|
+
// ../zero-client/src/client/delete-clients-manager.ts
|
|
13739
|
+
var DeleteClientsManager = class {
|
|
13740
|
+
#send;
|
|
13741
|
+
#lc;
|
|
13742
|
+
#dagStore;
|
|
13743
|
+
constructor(send2, dagStore, lc) {
|
|
13744
|
+
this.#send = send2;
|
|
13745
|
+
this.#dagStore = dagStore;
|
|
13746
|
+
this.#lc = lc;
|
|
13747
|
+
}
|
|
13748
|
+
/**
|
|
13749
|
+
* This gets called by Replicache when it deletes clients from the persistent
|
|
13750
|
+
* storage.
|
|
13751
|
+
*/
|
|
13752
|
+
onClientsDeleted(clientIDs, clientGroupIDs) {
|
|
13753
|
+
this.#lc.debug?.("DeletedClientsManager, send:", clientIDs);
|
|
13754
|
+
this.#send(["deleteClients", { clientIDs, clientGroupIDs }]);
|
|
13755
|
+
}
|
|
13756
|
+
/**
|
|
13757
|
+
* Zero calls this after it connects to ensure that the server knows about all
|
|
13758
|
+
* the clients that might have been deleted locally since the last connection.
|
|
13759
|
+
*/
|
|
13760
|
+
async sendDeletedClientsToServer() {
|
|
13761
|
+
const deleted = await withRead(
|
|
13762
|
+
this.#dagStore,
|
|
13763
|
+
(dagRead) => getDeletedClients(dagRead)
|
|
13764
|
+
);
|
|
13765
|
+
if (deleted.clientIDs.length > 0 || deleted.clientGroupIDs.length > 0) {
|
|
13766
|
+
this.#send(["deleteClients", deleted]);
|
|
13767
|
+
this.#lc.debug?.("DeletedClientsManager, send:", deleted);
|
|
13768
|
+
}
|
|
13769
|
+
}
|
|
13770
|
+
/**
|
|
13771
|
+
* This is called as a response to the server telling us which clients it
|
|
13772
|
+
* actually deleted.
|
|
13773
|
+
*/
|
|
13774
|
+
clientsDeletedOnServer(deletedClients) {
|
|
13775
|
+
const { clientIDs = [], clientGroupIDs = [] } = deletedClients;
|
|
13776
|
+
if (clientIDs.length > 0 || clientGroupIDs.length > 0) {
|
|
13777
|
+
return withWrite(this.#dagStore, async (dagWrite) => {
|
|
13778
|
+
this.#lc.debug?.("clientsDeletedOnServer:", clientIDs, clientGroupIDs);
|
|
13779
|
+
await removeDeletedClients(dagWrite, clientIDs, clientGroupIDs);
|
|
13780
|
+
});
|
|
13781
|
+
}
|
|
13782
|
+
return promiseVoid;
|
|
13783
|
+
}
|
|
13784
|
+
getDeletedClients() {
|
|
13785
|
+
return withRead(this.#dagStore, getDeletedClients);
|
|
13786
|
+
}
|
|
13787
|
+
};
|
|
13788
|
+
|
|
13633
13789
|
// ../zero-client/src/client/enable-analytics.ts
|
|
13634
13790
|
var IPV4_ADDRESS_REGEX = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
|
13635
13791
|
var IPV6_ADDRESS_HOSTNAME_REGEX = /^\[[a-fA-F0-9:]*:[a-fA-F0-9:]*\]$/;
|
|
@@ -13878,7 +14034,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
13878
14034
|
}
|
|
13879
14035
|
|
|
13880
14036
|
// ../zero-client/src/client/version.ts
|
|
13881
|
-
var version2 = "0.
|
|
14037
|
+
var version2 = "0.15.2025021200";
|
|
13882
14038
|
|
|
13883
14039
|
// ../zero-client/src/client/log-options.ts
|
|
13884
14040
|
var LevelFilterLogSink = class {
|
|
@@ -14568,7 +14724,7 @@ var PokeHandler = class {
|
|
|
14568
14724
|
this.#receivingPoke = void 0;
|
|
14569
14725
|
return;
|
|
14570
14726
|
}
|
|
14571
|
-
this.#pokeBuffer.push(this.#receivingPoke);
|
|
14727
|
+
this.#pokeBuffer.push({ ...this.#receivingPoke, pokeEnd });
|
|
14572
14728
|
this.#receivingPoke = void 0;
|
|
14573
14729
|
if (!this.#pokePlaybackLoopRunning) {
|
|
14574
14730
|
this.#startPlaybackLoop();
|
|
@@ -14644,7 +14800,8 @@ function mergePokes(pokeBuffer, schema, serverToClient2) {
|
|
|
14644
14800
|
return void 0;
|
|
14645
14801
|
}
|
|
14646
14802
|
const { baseCookie } = pokeBuffer[0].pokeStart;
|
|
14647
|
-
const
|
|
14803
|
+
const lastPoke = pokeBuffer[pokeBuffer.length - 1];
|
|
14804
|
+
const cookie = lastPoke.pokeEnd.cookie ?? lastPoke.pokeStart.cookie;
|
|
14648
14805
|
const mergedPatch = [];
|
|
14649
14806
|
const mergedLastMutationIDChanges = {};
|
|
14650
14807
|
let prevPokeStart = void 0;
|
|
@@ -14850,6 +15007,7 @@ var Zero = class {
|
|
|
14850
15007
|
#queryManager;
|
|
14851
15008
|
#ivmSources;
|
|
14852
15009
|
#clientToServer;
|
|
15010
|
+
#deleteClientsManager;
|
|
14853
15011
|
/**
|
|
14854
15012
|
* The queries we sent when inside the sec-protocol header when establishing a connection.
|
|
14855
15013
|
* More queries could be registered while we're waiting for the 'connected' message
|
|
@@ -14860,6 +15018,13 @@ var Zero = class {
|
|
|
14860
15018
|
* and an `initConnection` message must be sent to the server after receiving the `connected` message.
|
|
14861
15019
|
*/
|
|
14862
15020
|
#initConnectionQueries;
|
|
15021
|
+
/**
|
|
15022
|
+
* We try to send the deleted clients and (client groups) as part of the
|
|
15023
|
+
* sec-protocol header. If we can't because the header would get too large we
|
|
15024
|
+
* keep track of the deleted clients and send them after the connection is
|
|
15025
|
+
* established.
|
|
15026
|
+
*/
|
|
15027
|
+
#deletedClients;
|
|
14863
15028
|
#lastMutationIDSent = NULL_LAST_MUTATION_ID_SENT;
|
|
14864
15029
|
#onPong = () => void 0;
|
|
14865
15030
|
#online = false;
|
|
@@ -14995,7 +15160,8 @@ var Zero = class {
|
|
|
14995
15160
|
};
|
|
14996
15161
|
const replicacheImplOptions = {
|
|
14997
15162
|
enableClientGroupForking: false,
|
|
14998
|
-
enableMutationRecovery: false
|
|
15163
|
+
enableMutationRecovery: false,
|
|
15164
|
+
onClientsDeleted: (clientIDs, clientGroupIDs) => this.#deleteClientsManager.onClientsDeleted(clientIDs, clientGroupIDs)
|
|
14999
15165
|
};
|
|
15000
15166
|
const rep = new ReplicacheImpl(replicacheOptions, replicacheImplOptions);
|
|
15001
15167
|
this.#rep = rep;
|
|
@@ -15054,6 +15220,11 @@ var Zero = class {
|
|
|
15054
15220
|
maxRecentQueries
|
|
15055
15221
|
);
|
|
15056
15222
|
this.#clientToServer = clientToServer(schema.tables);
|
|
15223
|
+
this.#deleteClientsManager = new DeleteClientsManager(
|
|
15224
|
+
(msg) => this.#send(msg),
|
|
15225
|
+
rep.perdag,
|
|
15226
|
+
this.#lc
|
|
15227
|
+
);
|
|
15057
15228
|
this.#zeroContext = new ZeroContext(
|
|
15058
15229
|
this.#ivmSources.main,
|
|
15059
15230
|
(ast, gotCallback) => this.#queryManager.add(ast, gotCallback),
|
|
@@ -15104,6 +15275,9 @@ var Zero = class {
|
|
|
15104
15275
|
}
|
|
15105
15276
|
}
|
|
15106
15277
|
#sendChangeDesiredQueries(msg) {
|
|
15278
|
+
this.#send(msg);
|
|
15279
|
+
}
|
|
15280
|
+
#send(msg) {
|
|
15107
15281
|
if (this.#socket && this.#connectionState === Connected) {
|
|
15108
15282
|
send(this.#socket, msg);
|
|
15109
15283
|
}
|
|
@@ -15250,6 +15424,10 @@ var Zero = class {
|
|
|
15250
15424
|
return this.#handlePullResponse(lc, downMessage);
|
|
15251
15425
|
case "warm":
|
|
15252
15426
|
break;
|
|
15427
|
+
case "deleteClients":
|
|
15428
|
+
return this.#deleteClientsManager.clientsDeletedOnServer(
|
|
15429
|
+
downMessage[1]
|
|
15430
|
+
);
|
|
15253
15431
|
default:
|
|
15254
15432
|
msgType;
|
|
15255
15433
|
rejectInvalidMessage();
|
|
@@ -15320,8 +15498,8 @@ var Zero = class {
|
|
|
15320
15498
|
this.#metrics.lastConnectError.clear();
|
|
15321
15499
|
const proceedingConnectErrorCount = this.#connectErrorCount;
|
|
15322
15500
|
this.#connectErrorCount = 0;
|
|
15323
|
-
let timeToConnectMs
|
|
15324
|
-
let connectMsgLatencyMs
|
|
15501
|
+
let timeToConnectMs;
|
|
15502
|
+
let connectMsgLatencyMs;
|
|
15325
15503
|
if (this.#connectStart === void 0) {
|
|
15326
15504
|
lc.error?.(
|
|
15327
15505
|
"Got connected message but connect start time is undefined. This should not happen."
|
|
@@ -15332,7 +15510,7 @@ var Zero = class {
|
|
|
15332
15510
|
connectMsgLatencyMs = connectBody.timestamp !== void 0 ? now - connectBody.timestamp : void 0;
|
|
15333
15511
|
this.#connectStart = void 0;
|
|
15334
15512
|
}
|
|
15335
|
-
let totalTimeToConnectMs
|
|
15513
|
+
let totalTimeToConnectMs;
|
|
15336
15514
|
if (this.#totalToConnectStart === void 0) {
|
|
15337
15515
|
lc.error?.(
|
|
15338
15516
|
"Got connected message but total to connect start time is undefined. This should not happen."
|
|
@@ -15352,26 +15530,37 @@ var Zero = class {
|
|
|
15352
15530
|
});
|
|
15353
15531
|
this.#lastMutationIDSent = NULL_LAST_MUTATION_ID_SENT;
|
|
15354
15532
|
lc.debug?.("Resolving connect resolver");
|
|
15355
|
-
|
|
15533
|
+
const socket = must(this.#socket);
|
|
15356
15534
|
const queriesPatch = await this.#rep.query(
|
|
15357
15535
|
(tx) => this.#queryManager.getQueriesPatch(tx, this.#initConnectionQueries)
|
|
15358
15536
|
);
|
|
15537
|
+
const hasDeletedClients = () => skipEmptyArray(this.#deletedClients?.clientIDs) || skipEmptyArray(this.#deletedClients?.clientGroupIDs);
|
|
15538
|
+
const maybeSendDeletedClients = () => {
|
|
15539
|
+
if (hasDeletedClients()) {
|
|
15540
|
+
send(socket, ["deleteClients", this.#deletedClients]);
|
|
15541
|
+
this.#deletedClients = void 0;
|
|
15542
|
+
}
|
|
15543
|
+
};
|
|
15359
15544
|
if (queriesPatch.size > 0 && this.#initConnectionQueries !== void 0) {
|
|
15360
|
-
|
|
15545
|
+
maybeSendDeletedClients();
|
|
15546
|
+
send(socket, [
|
|
15361
15547
|
"changeDesiredQueries",
|
|
15362
15548
|
{
|
|
15363
15549
|
desiredQueriesPatch: [...queriesPatch.values()]
|
|
15364
15550
|
}
|
|
15365
15551
|
]);
|
|
15366
15552
|
} else if (this.#initConnectionQueries === void 0) {
|
|
15367
|
-
send(
|
|
15553
|
+
send(socket, [
|
|
15368
15554
|
"initConnection",
|
|
15369
15555
|
{
|
|
15370
|
-
desiredQueriesPatch: [...queriesPatch.values()]
|
|
15556
|
+
desiredQueriesPatch: [...queriesPatch.values()],
|
|
15557
|
+
deleted: skipEmptyDeletedClients(this.#deletedClients)
|
|
15371
15558
|
}
|
|
15372
15559
|
]);
|
|
15560
|
+
this.#deletedClients = void 0;
|
|
15373
15561
|
}
|
|
15374
15562
|
this.#initConnectionQueries = void 0;
|
|
15563
|
+
maybeSendDeletedClients();
|
|
15375
15564
|
this.#setConnectionState(Connected);
|
|
15376
15565
|
this.#connectResolver.resolve();
|
|
15377
15566
|
}
|
|
@@ -15425,9 +15614,10 @@ var Zero = class {
|
|
|
15425
15614
|
clearTimeout(timeoutID);
|
|
15426
15615
|
};
|
|
15427
15616
|
this.#closeAbortController.signal.addEventListener("abort", abortHandler);
|
|
15428
|
-
const [ws, initConnectionQueries] = await createSocket(
|
|
15617
|
+
const [ws, initConnectionQueries, deletedClients] = await createSocket(
|
|
15429
15618
|
this.#rep,
|
|
15430
15619
|
this.#queryManager,
|
|
15620
|
+
this.#deleteClientsManager,
|
|
15431
15621
|
toWSString(this.#server),
|
|
15432
15622
|
this.#connectCookie,
|
|
15433
15623
|
this.clientID,
|
|
@@ -15446,6 +15636,7 @@ var Zero = class {
|
|
|
15446
15636
|
return;
|
|
15447
15637
|
}
|
|
15448
15638
|
this.#initConnectionQueries = initConnectionQueries;
|
|
15639
|
+
this.#deletedClients = deletedClients;
|
|
15449
15640
|
ws.addEventListener("message", this.#onMessage);
|
|
15450
15641
|
ws.addEventListener("open", this.#onOpen);
|
|
15451
15642
|
ws.addEventListener("close", this.#onClose);
|
|
@@ -15901,7 +16092,7 @@ var Zero = class {
|
|
|
15901
16092
|
return rv;
|
|
15902
16093
|
}
|
|
15903
16094
|
};
|
|
15904
|
-
async function createSocket(rep, queryManager, socketOrigin, baseCookie, clientID, clientGroupID, schemaVersion, userID, auth, lmid, wsid, debugPerf, lc, maxHeaderLength = 1024 * 8, additionalConnectParams) {
|
|
16095
|
+
async function createSocket(rep, queryManager, deleteClientsManager, socketOrigin, baseCookie, clientID, clientGroupID, schemaVersion, userID, auth, lmid, wsid, debugPerf, lc, maxHeaderLength = 1024 * 8, additionalConnectParams) {
|
|
15905
16096
|
const url = new URL(
|
|
15906
16097
|
appendPath(socketOrigin, `/sync/v${PROTOCOL_VERSION}/connect`)
|
|
15907
16098
|
);
|
|
@@ -15928,16 +16119,24 @@ async function createSocket(rep, queryManager, socketOrigin, baseCookie, clientI
|
|
|
15928
16119
|
}
|
|
15929
16120
|
lc.info?.("Connecting to", url.toString());
|
|
15930
16121
|
const WS = mustGetBrowserGlobal("WebSocket");
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
|
|
16122
|
+
const queriesPatchP = rep.query((tx) => queryManager.getQueriesPatch(tx));
|
|
16123
|
+
let deletedClients = await deleteClientsManager.getDeletedClients();
|
|
16124
|
+
let queriesPatch = await queriesPatchP;
|
|
15934
16125
|
let secProtocol = encodeSecProtocols(
|
|
15935
|
-
[
|
|
16126
|
+
[
|
|
16127
|
+
"initConnection",
|
|
16128
|
+
{
|
|
16129
|
+
desiredQueriesPatch: [...queriesPatch.values()],
|
|
16130
|
+
deleted: skipEmptyDeletedClients(deletedClients)
|
|
16131
|
+
}
|
|
16132
|
+
],
|
|
15936
16133
|
auth
|
|
15937
16134
|
);
|
|
15938
16135
|
if (secProtocol.length > maxHeaderLength) {
|
|
15939
16136
|
secProtocol = encodeSecProtocols(void 0, auth);
|
|
15940
16137
|
queriesPatch = void 0;
|
|
16138
|
+
} else {
|
|
16139
|
+
deletedClients = void 0;
|
|
15941
16140
|
}
|
|
15942
16141
|
return [
|
|
15943
16142
|
new WS(
|
|
@@ -15945,9 +16144,26 @@ async function createSocket(rep, queryManager, socketOrigin, baseCookie, clientI
|
|
|
15945
16144
|
url.toString(),
|
|
15946
16145
|
secProtocol
|
|
15947
16146
|
),
|
|
15948
|
-
queriesPatch
|
|
16147
|
+
queriesPatch,
|
|
16148
|
+
skipEmptyDeletedClients(deletedClients)
|
|
15949
16149
|
];
|
|
15950
16150
|
}
|
|
16151
|
+
function skipEmptyArray(arr) {
|
|
16152
|
+
return arr && arr.length > 0 ? arr : void 0;
|
|
16153
|
+
}
|
|
16154
|
+
function skipEmptyDeletedClients(deletedClients) {
|
|
16155
|
+
if (!deletedClients) {
|
|
16156
|
+
return void 0;
|
|
16157
|
+
}
|
|
16158
|
+
const { clientIDs, clientGroupIDs } = deletedClients;
|
|
16159
|
+
if ((!clientIDs || clientIDs.length === 0) && (!clientGroupIDs || clientGroupIDs.length === 0)) {
|
|
16160
|
+
return void 0;
|
|
16161
|
+
}
|
|
16162
|
+
const data = {};
|
|
16163
|
+
data.clientIDs = skipEmptyArray(clientIDs);
|
|
16164
|
+
data.clientGroupIDs = skipEmptyArray(clientGroupIDs);
|
|
16165
|
+
return data;
|
|
16166
|
+
}
|
|
15951
16167
|
function addWebSocketIDFromSocketToLogContext({ url }, lc) {
|
|
15952
16168
|
const wsid = new URL(url).searchParams.get("wsid") ?? nanoid();
|
|
15953
16169
|
return addWebSocketIDToLogContext(wsid, lc);
|
|
@@ -15978,7 +16194,7 @@ export {
|
|
|
15978
16194
|
dropAllDatabases,
|
|
15979
16195
|
relationships,
|
|
15980
16196
|
table,
|
|
15981
|
-
|
|
16197
|
+
string8 as string,
|
|
15982
16198
|
number4 as number,
|
|
15983
16199
|
boolean3 as boolean,
|
|
15984
16200
|
json,
|
|
@@ -15990,4 +16206,4 @@ export {
|
|
|
15990
16206
|
escapeLike,
|
|
15991
16207
|
Zero
|
|
15992
16208
|
};
|
|
15993
|
-
//# sourceMappingURL=chunk-
|
|
16209
|
+
//# sourceMappingURL=chunk-VXFHQJ2K.js.map
|