@rocicorp/zero 0.14.2025021101 → 0.14.2025021202
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-5GWP7BBD.js → chunk-JMAJNHHI.js} +459 -675
- package/out/chunk-JMAJNHHI.js.map +7 -0
- package/out/replicache/src/persist/client-gc.d.ts.map +1 -1
- package/out/replicache/src/persist/client-group-gc.d.ts +2 -6
- package/out/replicache/src/persist/client-group-gc.d.ts.map +1 -1
- package/out/replicache/src/persist/clients.d.ts +2 -1
- 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 +0 -15
- package/out/shared/src/queue.d.ts.map +1 -1
- package/out/shared/src/queue.js +0 -23
- package/out/shared/src/queue.js.map +1 -1
- package/out/shared/src/resolved-promises.d.ts +0 -4
- package/out/shared/src/resolved-promises.d.ts.map +1 -1
- package/out/shared/src/resolved-promises.js +0 -4
- package/out/shared/src/resolved-promises.js.map +1 -1
- package/out/solid.js +1 -1
- package/out/zero-cache/src/auth/load-schema.d.ts +3 -5
- package/out/zero-cache/src/auth/load-schema.d.ts.map +1 -1
- package/out/zero-cache/src/auth/load-schema.js +13 -19
- package/out/zero-cache/src/auth/load-schema.js.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.js +1 -1
- package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts +2 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +6 -11
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +205 -0
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +22 -0
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/server/multi/config.d.ts +0 -4
- package/out/zero-cache/src/server/multi/config.d.ts.map +1 -1
- package/out/zero-cache/src/server/multi/config.js +0 -4
- 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 +2 -4
- 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 -3
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/change-source.js +0 -4
- 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.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +1 -3
- 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 +1 -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 +0 -16
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +2 -1
- 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 +4 -6
- 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 +11 -49
- 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 +3 -18
- 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 +16 -14
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/init.js +0 -8
- package/out/zero-cache/src/services/view-syncer/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +0 -4
- 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 +16 -40
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/pg.d.ts +0 -6
- package/out/zero-cache/src/types/pg.d.ts.map +1 -1
- package/out/zero-cache/src/types/pg.js +2 -15
- 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 +7 -13
- 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/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 +0 -1
- package/out/zero-client/src/client/zero-poke-handler.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +1 -7
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.d.ts +0 -8
- package/out/zero-protocol/src/connect.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.js +0 -2
- package/out/zero-protocol/src/connect.js.map +1 -1
- package/out/zero-protocol/src/delete-clients.d.ts +7 -8
- package/out/zero-protocol/src/delete-clients.d.ts.map +1 -1
- package/out/zero-protocol/src/delete-clients.js +3 -4
- package/out/zero-protocol/src/delete-clients.js.map +1 -1
- package/out/zero-protocol/src/down.d.ts +1 -5
- package/out/zero-protocol/src/down.d.ts.map +1 -1
- package/out/zero-protocol/src/down.js +1 -2
- package/out/zero-protocol/src/down.js.map +1 -1
- package/out/zero-protocol/src/poke.d.ts +0 -2
- package/out/zero-protocol/src/poke.d.ts.map +1 -1
- package/out/zero-protocol/src/poke.js +0 -4
- package/out/zero-protocol/src/poke.js.map +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts +3 -11
- package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
- package/out/zero-protocol/src/protocol-version.js +4 -14
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/up.d.ts +3 -8
- package/out/zero-protocol/src/up.d.ts.map +1 -1
- package/out/zero-schema/src/builder/schema-builder.d.ts +1 -0
- package/out/zero-schema/src/builder/schema-builder.d.ts.map +1 -1
- package/out/zero-schema/src/builder/schema-builder.js +49 -0
- package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
- package/out/zero-schema/src/compiled-permissions.d.ts +19 -23
- package/out/zero-schema/src/compiled-permissions.d.ts.map +1 -1
- package/out/zero-schema/src/compiled-permissions.js +4 -7
- 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 +2 -6
- package/out/zql/src/ivm/join.js.map +1 -1
- package/out/zql/src/query/{static-query.d.ts → auth-query.d.ts} +3 -7
- package/out/zql/src/query/auth-query.d.ts.map +1 -0
- package/out/zql/src/query/{static-query.js → auth-query.js} +5 -9
- package/out/zql/src/query/auth-query.js.map +1 -0
- 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 +8 -6
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/package.json +3 -4
- package/out/chunk-5GWP7BBD.js.map +0 -7
- package/out/replicache/src/deleted-clients.d.ts +0 -26
- package/out/replicache/src/deleted-clients.d.ts.map +0 -1
- package/out/zero/src/deploy-permissions.d.ts +0 -3
- package/out/zero/src/deploy-permissions.d.ts.map +0 -1
- package/out/zero/src/deploy-permissions.js +0 -3
- package/out/zero/src/deploy-permissions.js.map +0 -1
- package/out/zero-cache/src/scripts/deploy-permissions.d.ts +0 -2
- package/out/zero-cache/src/scripts/deploy-permissions.d.ts.map +0 -1
- package/out/zero-cache/src/scripts/deploy-permissions.js +0 -122
- package/out/zero-cache/src/scripts/deploy-permissions.js.map +0 -1
- package/out/zero-client/src/client/delete-clients-manager.d.ts +0 -35
- package/out/zero-client/src/client/delete-clients-manager.d.ts.map +0 -1
- package/out/zql/src/query/static-query.d.ts.map +0 -1
- package/out/zql/src/query/static-query.js.map +0 -1
|
@@ -397,8 +397,6 @@ 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
|
-
});
|
|
402
400
|
|
|
403
401
|
// ../replicache/src/frozen-json.ts
|
|
404
402
|
var deepFrozenObjects = /* @__PURE__ */ new WeakSet();
|
|
@@ -725,7 +723,7 @@ var AbortError = class extends Error {
|
|
|
725
723
|
// ../shared/src/sleep.ts
|
|
726
724
|
import { resolver as resolver2 } from "@rocicorp/resolver";
|
|
727
725
|
var promiseVoid2 = Promise.resolve();
|
|
728
|
-
var
|
|
726
|
+
var promiseNever = new Promise(() => void 0);
|
|
729
727
|
function sleep(ms, signal) {
|
|
730
728
|
const newAbortError = () => new AbortError("Aborted");
|
|
731
729
|
if (signal?.aborted) {
|
|
@@ -751,7 +749,7 @@ function sleep(ms, signal) {
|
|
|
751
749
|
}
|
|
752
750
|
function sleepWithAbort(ms, signal) {
|
|
753
751
|
if (ms === 0) {
|
|
754
|
-
return [promiseVoid2,
|
|
752
|
+
return [promiseVoid2, promiseNever];
|
|
755
753
|
}
|
|
756
754
|
const { promise: abortedPromise, resolve: abortedResolve } = resolver2();
|
|
757
755
|
const sleepPromise = new Promise((resolve) => {
|
|
@@ -1418,53 +1416,6 @@ var WriteImpl2 = class extends ReadImpl2 {
|
|
|
1418
1416
|
}
|
|
1419
1417
|
};
|
|
1420
1418
|
|
|
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
|
-
|
|
1468
1419
|
// ../replicache/src/format-version-enum.ts
|
|
1469
1420
|
var DD31 = 5;
|
|
1470
1421
|
var V6 = 6;
|
|
@@ -5785,7 +5736,7 @@ async function mustGetClient(id, dagRead) {
|
|
|
5785
5736
|
return client;
|
|
5786
5737
|
}
|
|
5787
5738
|
function initClientV6(newClientID, lc, perdag, mutatorNames, indexes, formatVersion, enableClientGroupForking) {
|
|
5788
|
-
return
|
|
5739
|
+
return withWriteNoImplicitCommit(perdag, async (dagWrite) => {
|
|
5789
5740
|
async function setClientsAndClientGroupAndCommit(basisHash, cookieJSON, valueHash2, indexRecords2) {
|
|
5790
5741
|
const newSnapshotData = newSnapshotCommitDataDD31(
|
|
5791
5742
|
basisHash,
|
|
@@ -5819,6 +5770,7 @@ function initClientV6(newClientID, lc, perdag, mutatorNames, indexes, formatVers
|
|
|
5819
5770
|
setClients(newClients, dagWrite),
|
|
5820
5771
|
setClientGroup(newClientGroupID, clientGroup, dagWrite)
|
|
5821
5772
|
]);
|
|
5773
|
+
await dagWrite.commit();
|
|
5822
5774
|
return [newClient, chunk.hash, newClients, true];
|
|
5823
5775
|
}
|
|
5824
5776
|
const clients = await getClients(dagWrite);
|
|
@@ -5833,6 +5785,7 @@ function initClientV6(newClientID, lc, perdag, mutatorNames, indexes, formatVers
|
|
|
5833
5785
|
};
|
|
5834
5786
|
const newClients = new Map(clients).set(newClientID, newClient);
|
|
5835
5787
|
await setClients(newClients, dagWrite);
|
|
5788
|
+
await dagWrite.commit();
|
|
5836
5789
|
return [newClient, headHash, newClients, false];
|
|
5837
5790
|
}
|
|
5838
5791
|
if (!enableClientGroupForking || res.type === FIND_MATCHING_CLIENT_TYPE_NEW) {
|
|
@@ -6020,13 +5973,7 @@ function gcClients(clientID, dagStore, clientMaxInactiveTime, onClientsDeleted)
|
|
|
6020
5973
|
return clients;
|
|
6021
5974
|
}
|
|
6022
5975
|
await setClients(newClients, dagWrite);
|
|
6023
|
-
|
|
6024
|
-
dagWrite,
|
|
6025
|
-
deletedClients,
|
|
6026
|
-
// gcClients does not delete client groups
|
|
6027
|
-
[]
|
|
6028
|
-
);
|
|
6029
|
-
onClientsDeleted(clientIDs, clientGroupIDs);
|
|
5976
|
+
onClientsDeleted(deletedClients);
|
|
6030
5977
|
return newClients;
|
|
6031
5978
|
});
|
|
6032
5979
|
}
|
|
@@ -6034,15 +5981,11 @@ function gcClients(clientID, dagStore, clientMaxInactiveTime, onClientsDeleted)
|
|
|
6034
5981
|
// ../replicache/src/persist/client-group-gc.ts
|
|
6035
5982
|
var GC_INTERVAL_MS = 5 * 60 * 1e3;
|
|
6036
5983
|
var latestGCUpdate2;
|
|
6037
|
-
function initClientGroupGC(dagStore,
|
|
5984
|
+
function initClientGroupGC(dagStore, lc, signal) {
|
|
6038
5985
|
initBgIntervalProcess(
|
|
6039
5986
|
"ClientGroupGC",
|
|
6040
5987
|
() => {
|
|
6041
|
-
latestGCUpdate2 = gcClientGroups(
|
|
6042
|
-
dagStore,
|
|
6043
|
-
enableMutationRecovery,
|
|
6044
|
-
onClientsDeleted
|
|
6045
|
-
);
|
|
5988
|
+
latestGCUpdate2 = gcClientGroups(dagStore);
|
|
6046
5989
|
return latestGCUpdate2;
|
|
6047
5990
|
},
|
|
6048
5991
|
() => GC_INTERVAL_MS,
|
|
@@ -6050,24 +5993,21 @@ function initClientGroupGC(dagStore, enableMutationRecovery, onClientsDeleted, l
|
|
|
6050
5993
|
signal
|
|
6051
5994
|
);
|
|
6052
5995
|
}
|
|
6053
|
-
function gcClientGroups(dagStore
|
|
5996
|
+
function gcClientGroups(dagStore) {
|
|
6054
5997
|
return withWrite(dagStore, async (tx) => {
|
|
6055
5998
|
const clients = await getClients(tx);
|
|
6056
5999
|
const clientGroupIDs = /* @__PURE__ */ new Set();
|
|
6057
6000
|
for (const client of clients.values()) {
|
|
6001
|
+
assertClientV6(client);
|
|
6058
6002
|
clientGroupIDs.add(client.clientGroupID);
|
|
6059
6003
|
}
|
|
6060
6004
|
const clientGroups = /* @__PURE__ */ new Map();
|
|
6061
|
-
const removeClientGroups = /* @__PURE__ */ new Set();
|
|
6062
6005
|
for (const [clientGroupID, clientGroup] of await getClientGroups(tx)) {
|
|
6063
|
-
if (clientGroupIDs.has(clientGroupID) ||
|
|
6006
|
+
if (clientGroupIDs.has(clientGroupID) || clientGroupHasPendingMutations(clientGroup)) {
|
|
6064
6007
|
clientGroups.set(clientGroupID, clientGroup);
|
|
6065
|
-
} else {
|
|
6066
|
-
removeClientGroups.add(clientGroupID);
|
|
6067
6008
|
}
|
|
6068
6009
|
}
|
|
6069
6010
|
await setClientGroups(clientGroups, tx);
|
|
6070
|
-
onClientsDeleted([], [...removeClientGroups].sort());
|
|
6071
6011
|
return clientGroups;
|
|
6072
6012
|
});
|
|
6073
6013
|
}
|
|
@@ -7304,7 +7244,8 @@ var ReplicacheImpl = class {
|
|
|
7304
7244
|
enableScheduledRefresh = true,
|
|
7305
7245
|
enablePullAndPushInOpen = true,
|
|
7306
7246
|
enableClientGroupForking = true,
|
|
7307
|
-
onClientsDeleted = () => {
|
|
7247
|
+
onClientsDeleted = (clientIDs) => {
|
|
7248
|
+
this.#lc.info?.("ClientIDs deleted", clientIDs);
|
|
7308
7249
|
}
|
|
7309
7250
|
} = implOptions;
|
|
7310
7251
|
this.auth = auth ?? "";
|
|
@@ -7448,13 +7389,7 @@ var ReplicacheImpl = class {
|
|
|
7448
7389
|
this.#lc,
|
|
7449
7390
|
signal
|
|
7450
7391
|
);
|
|
7451
|
-
initClientGroupGC(
|
|
7452
|
-
this.perdag,
|
|
7453
|
-
enableMutationRecovery,
|
|
7454
|
-
onClientsDeleted,
|
|
7455
|
-
this.#lc,
|
|
7456
|
-
signal
|
|
7457
|
-
);
|
|
7392
|
+
initClientGroupGC(this.perdag, this.#lc, signal);
|
|
7458
7393
|
initNewClientChannel(
|
|
7459
7394
|
this.name,
|
|
7460
7395
|
this.idbName,
|
|
@@ -8316,19 +8251,11 @@ async function collectIDBDatabases(idbDatabasesStore, now, maxAge, kvDropStore,
|
|
|
8316
8251
|
)
|
|
8317
8252
|
);
|
|
8318
8253
|
const dbNamesToRemove = [];
|
|
8319
|
-
const dbNamesToKeep = [];
|
|
8320
8254
|
const clientIDsToRemove = [];
|
|
8321
|
-
const
|
|
8322
|
-
for (const [
|
|
8323
|
-
dbName,
|
|
8324
|
-
[canCollect, clientIDs, clientGroupIDs]
|
|
8325
|
-
] of collectResults) {
|
|
8255
|
+
for (const [dbName, [canCollect, clientIDs]] of collectResults) {
|
|
8326
8256
|
if (canCollect) {
|
|
8327
8257
|
dbNamesToRemove.push(dbName);
|
|
8328
8258
|
clientIDsToRemove.push(...clientIDs);
|
|
8329
|
-
clientGroupIDsToRemove.push(...clientGroupIDs);
|
|
8330
|
-
} else {
|
|
8331
|
-
dbNamesToKeep.push(dbName);
|
|
8332
8259
|
}
|
|
8333
8260
|
}
|
|
8334
8261
|
const { errors } = await dropDatabases(
|
|
@@ -8339,24 +8266,8 @@ async function collectIDBDatabases(idbDatabasesStore, now, maxAge, kvDropStore,
|
|
|
8339
8266
|
if (errors.length) {
|
|
8340
8267
|
throw errors[0];
|
|
8341
8268
|
}
|
|
8342
|
-
if (clientIDsToRemove.length
|
|
8343
|
-
|
|
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
|
-
);
|
|
8269
|
+
if (clientIDsToRemove.length) {
|
|
8270
|
+
onClientsDeleted(clientIDsToRemove);
|
|
8360
8271
|
}
|
|
8361
8272
|
}
|
|
8362
8273
|
async function dropDatabaseInternal(name, idbDatabasesStore, kvDropStore) {
|
|
@@ -8434,14 +8345,7 @@ function canDatabaseBeCollectedAndGetDeletedClientIDs(enableMutationRecovery, pe
|
|
|
8434
8345
|
}
|
|
8435
8346
|
}
|
|
8436
8347
|
const clients = await getClients(read);
|
|
8437
|
-
|
|
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];
|
|
8348
|
+
return [true, [...clients.keys()]];
|
|
8445
8349
|
});
|
|
8446
8350
|
}
|
|
8447
8351
|
|
|
@@ -8470,6 +8374,87 @@ function one(...args) {
|
|
|
8470
8374
|
}));
|
|
8471
8375
|
}
|
|
8472
8376
|
|
|
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
|
+
|
|
8473
8458
|
// ../zero-schema/src/builder/table-builder.ts
|
|
8474
8459
|
function table(name) {
|
|
8475
8460
|
return new TableBuilder({
|
|
@@ -8478,7 +8463,7 @@ function table(name) {
|
|
|
8478
8463
|
primaryKey: []
|
|
8479
8464
|
});
|
|
8480
8465
|
}
|
|
8481
|
-
function
|
|
8466
|
+
function string7() {
|
|
8482
8467
|
return new ColumnBuilder({
|
|
8483
8468
|
type: "string",
|
|
8484
8469
|
optional: false,
|
|
@@ -8986,122 +8971,267 @@ function compareUTF8MaybeNull(a, b) {
|
|
|
8986
8971
|
return 0;
|
|
8987
8972
|
}
|
|
8988
8973
|
|
|
8989
|
-
// ../
|
|
8990
|
-
var
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
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));
|
|
9007
|
-
}
|
|
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;
|
|
8974
|
+
// ../zql/src/query/expression.ts
|
|
8975
|
+
var ExpressionBuilder = class {
|
|
8976
|
+
#exists;
|
|
8977
|
+
constructor(exists) {
|
|
8978
|
+
this.#exists = exists;
|
|
8979
|
+
this.exists = this.exists.bind(this);
|
|
9018
8980
|
}
|
|
9019
|
-
|
|
9020
|
-
|
|
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");
|
|
8981
|
+
get eb() {
|
|
8982
|
+
return this;
|
|
9036
8983
|
}
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
// ../zql/src/ivm/stream.ts
|
|
9040
|
-
function* take(stream, limit) {
|
|
9041
|
-
if (limit < 1) {
|
|
9042
|
-
return;
|
|
8984
|
+
cmp(field, opOrValue, value) {
|
|
8985
|
+
return cmp(field, opOrValue, value);
|
|
9043
8986
|
}
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
8987
|
+
cmpLit(left, op, right) {
|
|
8988
|
+
return {
|
|
8989
|
+
type: "simple",
|
|
8990
|
+
left: isParameterReference(left) ? left[toStaticParam]() : { type: "literal", value: left },
|
|
8991
|
+
right: isParameterReference(right) ? right[toStaticParam]() : { type: "literal", value: right },
|
|
8992
|
+
op
|
|
8993
|
+
};
|
|
9050
8994
|
}
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
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
|
-
);
|
|
8995
|
+
and = and;
|
|
8996
|
+
or = or;
|
|
8997
|
+
not = not;
|
|
8998
|
+
exists(relationship, cb) {
|
|
8999
|
+
return this.#exists(relationship, cb);
|
|
9080
9000
|
}
|
|
9081
|
-
|
|
9082
|
-
|
|
9001
|
+
};
|
|
9002
|
+
function and(...conditions) {
|
|
9003
|
+
const expressions = filterTrue(filterUndefined(conditions));
|
|
9004
|
+
if (expressions.length === 1) {
|
|
9005
|
+
return expressions[0];
|
|
9083
9006
|
}
|
|
9084
|
-
|
|
9085
|
-
|
|
9007
|
+
if (expressions.some(isAlwaysFalse)) {
|
|
9008
|
+
return FALSE;
|
|
9086
9009
|
}
|
|
9087
|
-
|
|
9088
|
-
|
|
9010
|
+
return { type: "and", conditions: expressions };
|
|
9011
|
+
}
|
|
9012
|
+
function or(...conditions) {
|
|
9013
|
+
const expressions = filterFalse(filterUndefined(conditions));
|
|
9014
|
+
if (expressions.length === 1) {
|
|
9015
|
+
return expressions[0];
|
|
9089
9016
|
}
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
if (this.#filter(node)) {
|
|
9093
|
-
yield node;
|
|
9094
|
-
}
|
|
9095
|
-
}
|
|
9017
|
+
if (expressions.some(isAlwaysTrue)) {
|
|
9018
|
+
return TRUE;
|
|
9096
9019
|
}
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
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;
|
|
9213
|
+
}
|
|
9214
|
+
destroy() {
|
|
9215
|
+
this.#input.destroy();
|
|
9216
|
+
}
|
|
9217
|
+
getSchema() {
|
|
9218
|
+
return this.#input.getSchema();
|
|
9219
|
+
}
|
|
9220
|
+
*fetch(req) {
|
|
9221
|
+
for (const node of this.#input.fetch(req)) {
|
|
9222
|
+
if (this.#filter(node)) {
|
|
9223
|
+
yield node;
|
|
9224
|
+
}
|
|
9225
|
+
}
|
|
9226
|
+
}
|
|
9227
|
+
*cleanup(req) {
|
|
9228
|
+
for (const node of this.#input.cleanup(req)) {
|
|
9229
|
+
if (this.#filter(node)) {
|
|
9230
|
+
yield node;
|
|
9231
|
+
} else {
|
|
9232
|
+
drainStreams(node);
|
|
9233
|
+
}
|
|
9234
|
+
this.#delSize(node);
|
|
9105
9235
|
}
|
|
9106
9236
|
}
|
|
9107
9237
|
push(change) {
|
|
@@ -9489,11 +9619,11 @@ var Join = class {
|
|
|
9489
9619
|
const childSchema = child.getSchema();
|
|
9490
9620
|
this.#schema = {
|
|
9491
9621
|
...parentSchema,
|
|
9622
|
+
isHidden: hidden,
|
|
9492
9623
|
relationships: {
|
|
9493
9624
|
...parentSchema.relationships,
|
|
9494
9625
|
[relationshipName]: {
|
|
9495
9626
|
...childSchema,
|
|
9496
|
-
isHidden: hidden,
|
|
9497
9627
|
system
|
|
9498
9628
|
}
|
|
9499
9629
|
}
|
|
@@ -9556,15 +9686,7 @@ var Join = class {
|
|
|
9556
9686
|
});
|
|
9557
9687
|
break;
|
|
9558
9688
|
case "child":
|
|
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
|
-
});
|
|
9689
|
+
this.#output.push(change);
|
|
9568
9690
|
break;
|
|
9569
9691
|
case "edit": {
|
|
9570
9692
|
if (rowEqualsForCompoundKey(
|
|
@@ -10442,11 +10564,11 @@ function createPredicateImpl(rhs, operator) {
|
|
|
10442
10564
|
case "LIKE":
|
|
10443
10565
|
return getLikePredicate(rhs, "");
|
|
10444
10566
|
case "NOT LIKE":
|
|
10445
|
-
return
|
|
10567
|
+
return not2(getLikePredicate(rhs, ""));
|
|
10446
10568
|
case "ILIKE":
|
|
10447
10569
|
return getLikePredicate(rhs, "i");
|
|
10448
10570
|
case "NOT ILIKE":
|
|
10449
|
-
return
|
|
10571
|
+
return not2(getLikePredicate(rhs, "i"));
|
|
10450
10572
|
case "IN": {
|
|
10451
10573
|
assert(Array.isArray(rhs));
|
|
10452
10574
|
const set = new Set(rhs);
|
|
@@ -10462,7 +10584,7 @@ function createPredicateImpl(rhs, operator) {
|
|
|
10462
10584
|
throw new Error(`Unexpected operator: ${operator}`);
|
|
10463
10585
|
}
|
|
10464
10586
|
}
|
|
10465
|
-
function
|
|
10587
|
+
function not2(f) {
|
|
10466
10588
|
return (lhs) => !f(lhs);
|
|
10467
10589
|
}
|
|
10468
10590
|
function transformFilters(filters) {
|
|
@@ -10798,192 +10920,40 @@ var ArrayView = class {
|
|
|
10798
10920
|
this.#fireListener(listener);
|
|
10799
10921
|
}
|
|
10800
10922
|
}
|
|
10801
|
-
#fireListener(listener) {
|
|
10802
|
-
listener(
|
|
10803
|
-
this.data,
|
|
10804
|
-
this.#complete ? "complete" : "unknown"
|
|
10805
|
-
);
|
|
10806
|
-
}
|
|
10807
|
-
destroy() {
|
|
10808
|
-
this.onDestroy?.();
|
|
10809
|
-
}
|
|
10810
|
-
#hydrate() {
|
|
10811
|
-
this.#dirty = true;
|
|
10812
|
-
for (const node of this.#input.fetch({})) {
|
|
10813
|
-
applyChange(
|
|
10814
|
-
this.#root,
|
|
10815
|
-
{ type: "add", node },
|
|
10816
|
-
this.#schema,
|
|
10817
|
-
"",
|
|
10818
|
-
this.#format
|
|
10819
|
-
);
|
|
10820
|
-
}
|
|
10821
|
-
this.flush();
|
|
10822
|
-
}
|
|
10823
|
-
push(change) {
|
|
10824
|
-
this.#dirty = true;
|
|
10825
|
-
applyChange(this.#root, change, this.#schema, "", this.#format);
|
|
10826
|
-
}
|
|
10827
|
-
flush() {
|
|
10828
|
-
if (!this.#dirty) {
|
|
10829
|
-
return;
|
|
10830
|
-
}
|
|
10831
|
-
this.#dirty = false;
|
|
10832
|
-
this.#fireListeners();
|
|
10833
|
-
}
|
|
10834
|
-
};
|
|
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
|
-
};
|
|
10923
|
+
#fireListener(listener) {
|
|
10924
|
+
listener(
|
|
10925
|
+
this.data,
|
|
10926
|
+
this.#complete ? "complete" : "unknown"
|
|
10927
|
+
);
|
|
10909
10928
|
}
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
let op;
|
|
10913
|
-
if (value === void 0) {
|
|
10914
|
-
value = opOrValue;
|
|
10915
|
-
op = "=";
|
|
10916
|
-
} else {
|
|
10917
|
-
op = opOrValue;
|
|
10929
|
+
destroy() {
|
|
10930
|
+
this.onDestroy?.();
|
|
10918
10931
|
}
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
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);
|
|
10932
|
+
#hydrate() {
|
|
10933
|
+
this.#dirty = true;
|
|
10934
|
+
for (const node of this.#input.fetch({})) {
|
|
10935
|
+
applyChange(
|
|
10936
|
+
this.#root,
|
|
10937
|
+
{ type: "add", node },
|
|
10938
|
+
this.#schema,
|
|
10939
|
+
"",
|
|
10940
|
+
this.#format
|
|
10941
|
+
);
|
|
10950
10942
|
}
|
|
10943
|
+
this.flush();
|
|
10944
|
+
}
|
|
10945
|
+
push(change) {
|
|
10946
|
+
this.#dirty = true;
|
|
10947
|
+
applyChange(this.#root, change, this.#schema, "", this.#format);
|
|
10948
|
+
}
|
|
10949
|
+
flush() {
|
|
10950
|
+
if (!this.#dirty) {
|
|
10951
|
+
return;
|
|
10952
|
+
}
|
|
10953
|
+
this.#dirty = false;
|
|
10954
|
+
this.#fireListeners();
|
|
10951
10955
|
}
|
|
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
10956
|
};
|
|
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
10957
|
|
|
10988
10958
|
// ../zql/src/query/dnf.ts
|
|
10989
10959
|
function dnf(condition) {
|
|
@@ -11039,7 +11009,6 @@ function unwrap(c) {
|
|
|
11039
11009
|
}
|
|
11040
11010
|
|
|
11041
11011
|
// ../zql/src/query/query-impl.ts
|
|
11042
|
-
var astForTestingSymbol = Symbol();
|
|
11043
11012
|
function newQuery(delegate, schema, table2) {
|
|
11044
11013
|
return new QueryImpl(delegate, schema, table2);
|
|
11045
11014
|
}
|
|
@@ -11070,10 +11039,6 @@ var AbstractQuery = class {
|
|
|
11070
11039
|
get format() {
|
|
11071
11040
|
return this.#format;
|
|
11072
11041
|
}
|
|
11073
|
-
// Not part of Query or QueryInternal interface
|
|
11074
|
-
get [astForTestingSymbol]() {
|
|
11075
|
-
return this.#ast;
|
|
11076
|
-
}
|
|
11077
11042
|
hash() {
|
|
11078
11043
|
if (!this.#hash) {
|
|
11079
11044
|
const ast = this._completeAst();
|
|
@@ -11201,7 +11166,6 @@ var AbstractQuery = class {
|
|
|
11201
11166
|
parentField: firstRelation.sourceField,
|
|
11202
11167
|
childField: firstRelation.destField
|
|
11203
11168
|
},
|
|
11204
|
-
hidden: true,
|
|
11205
11169
|
subquery: {
|
|
11206
11170
|
table: junctionSchema,
|
|
11207
11171
|
alias: relationship,
|
|
@@ -11216,6 +11180,7 @@ var AbstractQuery = class {
|
|
|
11216
11180
|
parentField: secondRelation.sourceField,
|
|
11217
11181
|
childField: secondRelation.destField
|
|
11218
11182
|
},
|
|
11183
|
+
hidden: true,
|
|
11219
11184
|
subquery: addPrimaryKeysToAst(
|
|
11220
11185
|
this.#schema.tables[destSchema],
|
|
11221
11186
|
sq.#ast
|
|
@@ -11428,14 +11393,21 @@ var AbstractQuery = class {
|
|
|
11428
11393
|
return this.#completedAST;
|
|
11429
11394
|
}
|
|
11430
11395
|
};
|
|
11396
|
+
var astForTestingSymbol = Symbol();
|
|
11431
11397
|
var completedAstSymbol = Symbol();
|
|
11432
11398
|
var QueryImpl = class extends AbstractQuery {
|
|
11433
11399
|
#delegate;
|
|
11400
|
+
#ast;
|
|
11434
11401
|
constructor(delegate, schema, tableName, ast = { table: tableName }, format) {
|
|
11435
11402
|
super(schema, tableName, ast, format);
|
|
11436
11403
|
this.#delegate = delegate;
|
|
11404
|
+
this.#ast = ast;
|
|
11437
11405
|
}
|
|
11438
11406
|
_system = "client";
|
|
11407
|
+
// Not part of Query or QueryInternal interface
|
|
11408
|
+
get [astForTestingSymbol]() {
|
|
11409
|
+
return this.#ast;
|
|
11410
|
+
}
|
|
11439
11411
|
get [completedAstSymbol]() {
|
|
11440
11412
|
return this._completeAst();
|
|
11441
11413
|
}
|
|
@@ -11526,8 +11498,8 @@ function isCompoundKey(field) {
|
|
|
11526
11498
|
return Array.isArray(field) && field.length >= 1;
|
|
11527
11499
|
}
|
|
11528
11500
|
|
|
11529
|
-
// ../zql/src/query/
|
|
11530
|
-
var
|
|
11501
|
+
// ../zql/src/query/auth-query.ts
|
|
11502
|
+
var AuthQuery = class _AuthQuery extends AbstractQuery {
|
|
11531
11503
|
constructor(schema, tableName, ast = { table: tableName }, format) {
|
|
11532
11504
|
super(schema, tableName, ast, format);
|
|
11533
11505
|
}
|
|
@@ -11536,7 +11508,7 @@ var StaticQuery = class _StaticQuery extends AbstractQuery {
|
|
|
11536
11508
|
}
|
|
11537
11509
|
_system = "permissions";
|
|
11538
11510
|
_newQuery(schema, tableName, ast, format) {
|
|
11539
|
-
return new
|
|
11511
|
+
return new _AuthQuery(schema, tableName, ast, format);
|
|
11540
11512
|
}
|
|
11541
11513
|
get ast() {
|
|
11542
11514
|
return this._completeAst();
|
|
@@ -11552,97 +11524,13 @@ var StaticQuery = class _StaticQuery extends AbstractQuery {
|
|
|
11552
11524
|
}
|
|
11553
11525
|
};
|
|
11554
11526
|
|
|
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
|
-
|
|
11636
11527
|
// ../zero-schema/src/permissions.ts
|
|
11637
11528
|
var ANYONE_CAN = void 0;
|
|
11638
11529
|
var NOBODY_CAN = [];
|
|
11639
11530
|
async function definePermissions(schema, definer) {
|
|
11640
11531
|
const expressionBuilders = {};
|
|
11641
11532
|
for (const name of Object.keys(schema.tables)) {
|
|
11642
|
-
expressionBuilders[name] = new
|
|
11643
|
-
schema,
|
|
11644
|
-
name
|
|
11645
|
-
).expressionBuilder();
|
|
11533
|
+
expressionBuilders[name] = new AuthQuery(schema, name).expressionBuilder();
|
|
11646
11534
|
}
|
|
11647
11535
|
const config = await definer();
|
|
11648
11536
|
return compilePermissions(schema, config, expressionBuilders);
|
|
@@ -11652,13 +11540,10 @@ function compilePermissions(schema, authz, expressionBuilders) {
|
|
|
11652
11540
|
return void 0;
|
|
11653
11541
|
}
|
|
11654
11542
|
const nameMapper = clientToServer(schema.tables);
|
|
11655
|
-
const ret = {
|
|
11656
|
-
protocolVersion: PROTOCOL_VERSION,
|
|
11657
|
-
tables: {}
|
|
11658
|
-
};
|
|
11543
|
+
const ret = {};
|
|
11659
11544
|
for (const [tableName, tableConfig] of Object.entries(authz)) {
|
|
11660
11545
|
const serverName = schema.tables[tableName].serverName ?? tableName;
|
|
11661
|
-
ret
|
|
11546
|
+
ret[serverName] = {
|
|
11662
11547
|
row: compileRowConfig(
|
|
11663
11548
|
nameMapper,
|
|
11664
11549
|
tableName,
|
|
@@ -11809,18 +11694,6 @@ function escapeLike(val) {
|
|
|
11809
11694
|
import { LogContext as LogContext4 } from "@rocicorp/logger";
|
|
11810
11695
|
import { resolver as resolver8 } from "@rocicorp/resolver";
|
|
11811
11696
|
|
|
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
|
-
|
|
11824
11697
|
// ../zero-protocol/src/queries-patch.ts
|
|
11825
11698
|
var putOpSchema = valita_exports.object({
|
|
11826
11699
|
op: valita_exports.literal("put"),
|
|
@@ -11847,8 +11720,7 @@ var connectedMessageSchema = valita_exports.tuple([
|
|
|
11847
11720
|
connectedBodySchema
|
|
11848
11721
|
]);
|
|
11849
11722
|
var initConnectionBodySchema = valita_exports.object({
|
|
11850
|
-
desiredQueriesPatch: queriesPatchSchema
|
|
11851
|
-
deleted: deleteClientsBodySchema.optional()
|
|
11723
|
+
desiredQueriesPatch: queriesPatchSchema
|
|
11852
11724
|
});
|
|
11853
11725
|
var initConnectionMessageSchema = valita_exports.tuple([
|
|
11854
11726
|
valita_exports.literal("initConnection"),
|
|
@@ -12023,10 +11895,6 @@ var pokePartBodySchema = valita_exports.object({
|
|
|
12023
11895
|
});
|
|
12024
11896
|
var pokeEndBodySchema = valita_exports.object({
|
|
12025
11897
|
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(),
|
|
12030
11898
|
// If `true`, the poke with id `pokeID` should be discarded without
|
|
12031
11899
|
// applying it.
|
|
12032
11900
|
cancel: valita_exports.boolean().optional()
|
|
@@ -12086,14 +11954,18 @@ var downstreamSchema = valita_exports.union(
|
|
|
12086
11954
|
pokeStartMessageSchema,
|
|
12087
11955
|
pokePartMessageSchema,
|
|
12088
11956
|
pokeEndMessageSchema,
|
|
12089
|
-
pullResponseMessageSchema
|
|
12090
|
-
deleteClientsMessageSchema
|
|
11957
|
+
pullResponseMessageSchema
|
|
12091
11958
|
);
|
|
12092
11959
|
|
|
12093
11960
|
// ../zero-protocol/src/mutation-type-enum.ts
|
|
12094
11961
|
var CRUD = "crud";
|
|
12095
11962
|
var Custom = "custom";
|
|
12096
11963
|
|
|
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
|
+
|
|
12097
11969
|
// ../zero-protocol/src/push.ts
|
|
12098
11970
|
var CRUD_MUTATION_NAME = "_zero_crud";
|
|
12099
11971
|
var insertOpSchema = valita_exports.object({
|
|
@@ -13436,28 +13308,48 @@ var ZeroContext = class {
|
|
|
13436
13308
|
// ../zero-client/src/client/crud.ts
|
|
13437
13309
|
function makeCRUDMutate(schema, repMutate) {
|
|
13438
13310
|
const { [CRUD_MUTATION_NAME]: zeroCRUD } = repMutate;
|
|
13311
|
+
let inBatch = false;
|
|
13439
13312
|
const mutateBatch = async (body) => {
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13313
|
+
if (inBatch) {
|
|
13314
|
+
throw new Error("Cannot call mutate inside a batch");
|
|
13315
|
+
}
|
|
13316
|
+
inBatch = true;
|
|
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`);
|
|
13444
13333
|
}
|
|
13445
|
-
const rv = await body(m);
|
|
13446
|
-
await zeroCRUD({ ops });
|
|
13447
|
-
return rv;
|
|
13448
13334
|
};
|
|
13449
13335
|
const mutate = {};
|
|
13450
13336
|
for (const [name, tableSchema] of Object.entries(schema.tables)) {
|
|
13451
|
-
mutate[name] = makeEntityCRUDMutate(
|
|
13337
|
+
mutate[name] = makeEntityCRUDMutate(
|
|
13338
|
+
name,
|
|
13339
|
+
tableSchema.primaryKey,
|
|
13340
|
+
zeroCRUD,
|
|
13341
|
+
assertNotInBatch
|
|
13342
|
+
);
|
|
13452
13343
|
}
|
|
13453
13344
|
return {
|
|
13454
13345
|
mutate,
|
|
13455
13346
|
mutateBatch
|
|
13456
13347
|
};
|
|
13457
13348
|
}
|
|
13458
|
-
function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD) {
|
|
13349
|
+
function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch) {
|
|
13459
13350
|
return {
|
|
13460
13351
|
insert: (value) => {
|
|
13352
|
+
assertNotInBatch(tableName, "insert");
|
|
13461
13353
|
const op = {
|
|
13462
13354
|
op: "insert",
|
|
13463
13355
|
tableName,
|
|
@@ -13467,6 +13359,7 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD) {
|
|
|
13467
13359
|
return zeroCRUD({ ops: [op] });
|
|
13468
13360
|
},
|
|
13469
13361
|
upsert: (value) => {
|
|
13362
|
+
assertNotInBatch(tableName, "upsert");
|
|
13470
13363
|
const op = {
|
|
13471
13364
|
op: "upsert",
|
|
13472
13365
|
tableName,
|
|
@@ -13476,6 +13369,7 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD) {
|
|
|
13476
13369
|
return zeroCRUD({ ops: [op] });
|
|
13477
13370
|
},
|
|
13478
13371
|
update: (value) => {
|
|
13372
|
+
assertNotInBatch(tableName, "update");
|
|
13479
13373
|
const op = {
|
|
13480
13374
|
op: "update",
|
|
13481
13375
|
tableName,
|
|
@@ -13485,6 +13379,7 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD) {
|
|
|
13485
13379
|
return zeroCRUD({ ops: [op] });
|
|
13486
13380
|
},
|
|
13487
13381
|
delete: (id) => {
|
|
13382
|
+
assertNotInBatch(tableName, "delete");
|
|
13488
13383
|
const op = {
|
|
13489
13384
|
op: "delete",
|
|
13490
13385
|
tableName,
|
|
@@ -13735,57 +13630,6 @@ function makeTableCRUD(schema, tableName, tx, ivmBranch) {
|
|
|
13735
13630
|
};
|
|
13736
13631
|
}
|
|
13737
13632
|
|
|
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
|
-
|
|
13789
13633
|
// ../zero-client/src/client/enable-analytics.ts
|
|
13790
13634
|
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]?)$/;
|
|
13791
13635
|
var IPV6_ADDRESS_HOSTNAME_REGEX = /^\[[a-fA-F0-9:]*:[a-fA-F0-9:]*\]$/;
|
|
@@ -14034,7 +13878,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
14034
13878
|
}
|
|
14035
13879
|
|
|
14036
13880
|
// ../zero-client/src/client/version.ts
|
|
14037
|
-
var version2 = "0.14.
|
|
13881
|
+
var version2 = "0.14.2025021202";
|
|
14038
13882
|
|
|
14039
13883
|
// ../zero-client/src/client/log-options.ts
|
|
14040
13884
|
var LevelFilterLogSink = class {
|
|
@@ -14724,7 +14568,7 @@ var PokeHandler = class {
|
|
|
14724
14568
|
this.#receivingPoke = void 0;
|
|
14725
14569
|
return;
|
|
14726
14570
|
}
|
|
14727
|
-
this.#pokeBuffer.push(
|
|
14571
|
+
this.#pokeBuffer.push(this.#receivingPoke);
|
|
14728
14572
|
this.#receivingPoke = void 0;
|
|
14729
14573
|
if (!this.#pokePlaybackLoopRunning) {
|
|
14730
14574
|
this.#startPlaybackLoop();
|
|
@@ -14800,8 +14644,7 @@ function mergePokes(pokeBuffer, schema, serverToClient2) {
|
|
|
14800
14644
|
return void 0;
|
|
14801
14645
|
}
|
|
14802
14646
|
const { baseCookie } = pokeBuffer[0].pokeStart;
|
|
14803
|
-
const
|
|
14804
|
-
const cookie = lastPoke.pokeEnd.cookie ?? lastPoke.pokeStart.cookie;
|
|
14647
|
+
const { cookie } = pokeBuffer[pokeBuffer.length - 1].pokeStart;
|
|
14805
14648
|
const mergedPatch = [];
|
|
14806
14649
|
const mergedLastMutationIDChanges = {};
|
|
14807
14650
|
let prevPokeStart = void 0;
|
|
@@ -15007,7 +14850,6 @@ var Zero = class {
|
|
|
15007
14850
|
#queryManager;
|
|
15008
14851
|
#ivmSources;
|
|
15009
14852
|
#clientToServer;
|
|
15010
|
-
#deleteClientsManager;
|
|
15011
14853
|
/**
|
|
15012
14854
|
* The queries we sent when inside the sec-protocol header when establishing a connection.
|
|
15013
14855
|
* More queries could be registered while we're waiting for the 'connected' message
|
|
@@ -15018,13 +14860,6 @@ var Zero = class {
|
|
|
15018
14860
|
* and an `initConnection` message must be sent to the server after receiving the `connected` message.
|
|
15019
14861
|
*/
|
|
15020
14862
|
#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;
|
|
15028
14863
|
#lastMutationIDSent = NULL_LAST_MUTATION_ID_SENT;
|
|
15029
14864
|
#onPong = () => void 0;
|
|
15030
14865
|
#online = false;
|
|
@@ -15160,8 +14995,7 @@ var Zero = class {
|
|
|
15160
14995
|
};
|
|
15161
14996
|
const replicacheImplOptions = {
|
|
15162
14997
|
enableClientGroupForking: false,
|
|
15163
|
-
enableMutationRecovery: false
|
|
15164
|
-
onClientsDeleted: (clientIDs, clientGroupIDs) => this.#deleteClientsManager.onClientsDeleted(clientIDs, clientGroupIDs)
|
|
14998
|
+
enableMutationRecovery: false
|
|
15165
14999
|
};
|
|
15166
15000
|
const rep = new ReplicacheImpl(replicacheOptions, replicacheImplOptions);
|
|
15167
15001
|
this.#rep = rep;
|
|
@@ -15220,11 +15054,6 @@ var Zero = class {
|
|
|
15220
15054
|
maxRecentQueries
|
|
15221
15055
|
);
|
|
15222
15056
|
this.#clientToServer = clientToServer(schema.tables);
|
|
15223
|
-
this.#deleteClientsManager = new DeleteClientsManager(
|
|
15224
|
-
(msg) => this.#send(msg),
|
|
15225
|
-
rep.perdag,
|
|
15226
|
-
this.#lc
|
|
15227
|
-
);
|
|
15228
15057
|
this.#zeroContext = new ZeroContext(
|
|
15229
15058
|
this.#ivmSources.main,
|
|
15230
15059
|
(ast, gotCallback) => this.#queryManager.add(ast, gotCallback),
|
|
@@ -15275,9 +15104,6 @@ var Zero = class {
|
|
|
15275
15104
|
}
|
|
15276
15105
|
}
|
|
15277
15106
|
#sendChangeDesiredQueries(msg) {
|
|
15278
|
-
this.#send(msg);
|
|
15279
|
-
}
|
|
15280
|
-
#send(msg) {
|
|
15281
15107
|
if (this.#socket && this.#connectionState === Connected) {
|
|
15282
15108
|
send(this.#socket, msg);
|
|
15283
15109
|
}
|
|
@@ -15424,10 +15250,6 @@ var Zero = class {
|
|
|
15424
15250
|
return this.#handlePullResponse(lc, downMessage);
|
|
15425
15251
|
case "warm":
|
|
15426
15252
|
break;
|
|
15427
|
-
case "deleteClients":
|
|
15428
|
-
return this.#deleteClientsManager.clientsDeletedOnServer(
|
|
15429
|
-
downMessage[1]
|
|
15430
|
-
);
|
|
15431
15253
|
default:
|
|
15432
15254
|
msgType;
|
|
15433
15255
|
rejectInvalidMessage();
|
|
@@ -15498,8 +15320,8 @@ var Zero = class {
|
|
|
15498
15320
|
this.#metrics.lastConnectError.clear();
|
|
15499
15321
|
const proceedingConnectErrorCount = this.#connectErrorCount;
|
|
15500
15322
|
this.#connectErrorCount = 0;
|
|
15501
|
-
let timeToConnectMs;
|
|
15502
|
-
let connectMsgLatencyMs;
|
|
15323
|
+
let timeToConnectMs = void 0;
|
|
15324
|
+
let connectMsgLatencyMs = void 0;
|
|
15503
15325
|
if (this.#connectStart === void 0) {
|
|
15504
15326
|
lc.error?.(
|
|
15505
15327
|
"Got connected message but connect start time is undefined. This should not happen."
|
|
@@ -15510,7 +15332,7 @@ var Zero = class {
|
|
|
15510
15332
|
connectMsgLatencyMs = connectBody.timestamp !== void 0 ? now - connectBody.timestamp : void 0;
|
|
15511
15333
|
this.#connectStart = void 0;
|
|
15512
15334
|
}
|
|
15513
|
-
let totalTimeToConnectMs;
|
|
15335
|
+
let totalTimeToConnectMs = void 0;
|
|
15514
15336
|
if (this.#totalToConnectStart === void 0) {
|
|
15515
15337
|
lc.error?.(
|
|
15516
15338
|
"Got connected message but total to connect start time is undefined. This should not happen."
|
|
@@ -15530,37 +15352,26 @@ var Zero = class {
|
|
|
15530
15352
|
});
|
|
15531
15353
|
this.#lastMutationIDSent = NULL_LAST_MUTATION_ID_SENT;
|
|
15532
15354
|
lc.debug?.("Resolving connect resolver");
|
|
15533
|
-
|
|
15355
|
+
assert(this.#socket);
|
|
15534
15356
|
const queriesPatch = await this.#rep.query(
|
|
15535
15357
|
(tx) => this.#queryManager.getQueriesPatch(tx, this.#initConnectionQueries)
|
|
15536
15358
|
);
|
|
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
|
-
};
|
|
15544
15359
|
if (queriesPatch.size > 0 && this.#initConnectionQueries !== void 0) {
|
|
15545
|
-
|
|
15546
|
-
send(socket, [
|
|
15360
|
+
send(this.#socket, [
|
|
15547
15361
|
"changeDesiredQueries",
|
|
15548
15362
|
{
|
|
15549
15363
|
desiredQueriesPatch: [...queriesPatch.values()]
|
|
15550
15364
|
}
|
|
15551
15365
|
]);
|
|
15552
15366
|
} else if (this.#initConnectionQueries === void 0) {
|
|
15553
|
-
send(socket, [
|
|
15367
|
+
send(this.#socket, [
|
|
15554
15368
|
"initConnection",
|
|
15555
15369
|
{
|
|
15556
|
-
desiredQueriesPatch: [...queriesPatch.values()]
|
|
15557
|
-
deleted: skipEmptyDeletedClients(this.#deletedClients)
|
|
15370
|
+
desiredQueriesPatch: [...queriesPatch.values()]
|
|
15558
15371
|
}
|
|
15559
15372
|
]);
|
|
15560
|
-
this.#deletedClients = void 0;
|
|
15561
15373
|
}
|
|
15562
15374
|
this.#initConnectionQueries = void 0;
|
|
15563
|
-
maybeSendDeletedClients();
|
|
15564
15375
|
this.#setConnectionState(Connected);
|
|
15565
15376
|
this.#connectResolver.resolve();
|
|
15566
15377
|
}
|
|
@@ -15614,10 +15425,9 @@ var Zero = class {
|
|
|
15614
15425
|
clearTimeout(timeoutID);
|
|
15615
15426
|
};
|
|
15616
15427
|
this.#closeAbortController.signal.addEventListener("abort", abortHandler);
|
|
15617
|
-
const [ws, initConnectionQueries
|
|
15428
|
+
const [ws, initConnectionQueries] = await createSocket(
|
|
15618
15429
|
this.#rep,
|
|
15619
15430
|
this.#queryManager,
|
|
15620
|
-
this.#deleteClientsManager,
|
|
15621
15431
|
toWSString(this.#server),
|
|
15622
15432
|
this.#connectCookie,
|
|
15623
15433
|
this.clientID,
|
|
@@ -15636,7 +15446,6 @@ var Zero = class {
|
|
|
15636
15446
|
return;
|
|
15637
15447
|
}
|
|
15638
15448
|
this.#initConnectionQueries = initConnectionQueries;
|
|
15639
|
-
this.#deletedClients = deletedClients;
|
|
15640
15449
|
ws.addEventListener("message", this.#onMessage);
|
|
15641
15450
|
ws.addEventListener("open", this.#onOpen);
|
|
15642
15451
|
ws.addEventListener("close", this.#onClose);
|
|
@@ -16092,7 +15901,7 @@ var Zero = class {
|
|
|
16092
15901
|
return rv;
|
|
16093
15902
|
}
|
|
16094
15903
|
};
|
|
16095
|
-
async function createSocket(rep, queryManager,
|
|
15904
|
+
async function createSocket(rep, queryManager, socketOrigin, baseCookie, clientID, clientGroupID, schemaVersion, userID, auth, lmid, wsid, debugPerf, lc, maxHeaderLength = 1024 * 8, additionalConnectParams) {
|
|
16096
15905
|
const url = new URL(
|
|
16097
15906
|
appendPath(socketOrigin, `/sync/v${PROTOCOL_VERSION}/connect`)
|
|
16098
15907
|
);
|
|
@@ -16119,24 +15928,16 @@ async function createSocket(rep, queryManager, deleteClientsManager, socketOrigi
|
|
|
16119
15928
|
}
|
|
16120
15929
|
lc.info?.("Connecting to", url.toString());
|
|
16121
15930
|
const WS = mustGetBrowserGlobal("WebSocket");
|
|
16122
|
-
|
|
16123
|
-
|
|
16124
|
-
|
|
15931
|
+
let queriesPatch = await rep.query(
|
|
15932
|
+
(tx) => queryManager.getQueriesPatch(tx)
|
|
15933
|
+
);
|
|
16125
15934
|
let secProtocol = encodeSecProtocols(
|
|
16126
|
-
[
|
|
16127
|
-
"initConnection",
|
|
16128
|
-
{
|
|
16129
|
-
desiredQueriesPatch: [...queriesPatch.values()],
|
|
16130
|
-
deleted: skipEmptyDeletedClients(deletedClients)
|
|
16131
|
-
}
|
|
16132
|
-
],
|
|
15935
|
+
["initConnection", { desiredQueriesPatch: [...queriesPatch.values()] }],
|
|
16133
15936
|
auth
|
|
16134
15937
|
);
|
|
16135
15938
|
if (secProtocol.length > maxHeaderLength) {
|
|
16136
15939
|
secProtocol = encodeSecProtocols(void 0, auth);
|
|
16137
15940
|
queriesPatch = void 0;
|
|
16138
|
-
} else {
|
|
16139
|
-
deletedClients = void 0;
|
|
16140
15941
|
}
|
|
16141
15942
|
return [
|
|
16142
15943
|
new WS(
|
|
@@ -16144,26 +15945,9 @@ async function createSocket(rep, queryManager, deleteClientsManager, socketOrigi
|
|
|
16144
15945
|
url.toString(),
|
|
16145
15946
|
secProtocol
|
|
16146
15947
|
),
|
|
16147
|
-
queriesPatch
|
|
16148
|
-
skipEmptyDeletedClients(deletedClients)
|
|
15948
|
+
queriesPatch
|
|
16149
15949
|
];
|
|
16150
15950
|
}
|
|
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
|
-
}
|
|
16167
15951
|
function addWebSocketIDFromSocketToLogContext({ url }, lc) {
|
|
16168
15952
|
const wsid = new URL(url).searchParams.get("wsid") ?? nanoid();
|
|
16169
15953
|
return addWebSocketIDToLogContext(wsid, lc);
|
|
@@ -16194,7 +15978,7 @@ export {
|
|
|
16194
15978
|
dropAllDatabases,
|
|
16195
15979
|
relationships,
|
|
16196
15980
|
table,
|
|
16197
|
-
|
|
15981
|
+
string7 as string,
|
|
16198
15982
|
number4 as number,
|
|
16199
15983
|
boolean3 as boolean,
|
|
16200
15984
|
json,
|
|
@@ -16206,4 +15990,4 @@ export {
|
|
|
16206
15990
|
escapeLike,
|
|
16207
15991
|
Zero
|
|
16208
15992
|
};
|
|
16209
|
-
//# sourceMappingURL=chunk-
|
|
15993
|
+
//# sourceMappingURL=chunk-JMAJNHHI.js.map
|