@rocicorp/zero 0.18.2025032900 → 0.18.2025040201
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/analyze-query/src/bin.d.ts +2 -0
- package/out/analyze-query/src/bin.d.ts.map +1 -0
- package/out/analyze-query/src/bin.js +178 -0
- package/out/analyze-query/src/bin.js.map +1 -0
- package/out/{chunk-I7LQ2GI3.js → chunk-242YQPIZ.js} +241 -97
- package/out/chunk-242YQPIZ.js.map +7 -0
- package/out/{chunk-NBZURO2P.js → chunk-R7QLNPBS.js} +16 -109
- package/out/{chunk-NBZURO2P.js.map → chunk-R7QLNPBS.js.map} +3 -3
- package/out/inspector-RYBBQ63M.js +394 -0
- package/out/inspector-RYBBQ63M.js.map +7 -0
- package/out/otel/src/test-log-config.d.ts +8 -0
- package/out/otel/src/test-log-config.d.ts.map +1 -0
- package/out/otel/src/test-log-config.js +8 -0
- package/out/otel/src/test-log-config.js.map +1 -0
- package/out/replicache/src/replicache-impl.d.ts.map +1 -1
- package/out/replicache/src/replicache-options.d.ts +12 -0
- package/out/replicache/src/replicache-options.d.ts.map +1 -1
- package/out/shared/src/browser-env.d.ts +2 -0
- package/out/shared/src/browser-env.d.ts.map +1 -1
- package/out/shared/src/logging-test-utils.d.ts +12 -0
- package/out/shared/src/logging-test-utils.d.ts.map +1 -0
- package/out/shared/src/logging-test-utils.js +21 -0
- package/out/shared/src/logging-test-utils.js.map +1 -0
- package/out/solid.js +2 -2
- package/out/z2s/src/compiler.d.ts +5 -4
- package/out/z2s/src/compiler.d.ts.map +1 -1
- package/out/z2s/src/compiler.js +86 -59
- package/out/z2s/src/compiler.js.map +1 -1
- package/out/z2s/src/schema.d.ts +11 -0
- package/out/z2s/src/schema.d.ts.map +1 -0
- package/out/z2s/src/schema.js +2 -0
- package/out/z2s/src/schema.js.map +1 -0
- package/out/z2s/src/sql.d.ts +7 -4
- package/out/z2s/src/sql.d.ts.map +1 -1
- package/out/z2s/src/sql.js +113 -66
- package/out/z2s/src/sql.js.map +1 -1
- package/out/zero/src/analyze-query.d.ts +3 -0
- package/out/zero/src/analyze-query.d.ts.map +1 -0
- package/out/zero/src/analyze-query.js +3 -0
- package/out/zero/src/analyze-query.js.map +1 -0
- package/out/zero-cache/src/db/specs.d.ts +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +5 -5
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +2 -2
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js +10 -6
- package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/change-log.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/change-log.js +17 -16
- package/out/zero-cache/src/services/replicator/schema/change-log.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-schema.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-schema.js +2 -8
- package/out/zero-cache/src/services/view-syncer/client-schema.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 +8 -15
- 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.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +2 -3
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +2 -2
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- 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 +0 -7
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/lite.d.ts +1 -1
- package/out/zero-cache/src/types/lite.d.ts.map +1 -1
- package/out/zero-cache/src/types/lite.js +2 -52
- package/out/zero-cache/src/types/lite.js.map +1 -1
- package/out/zero-cache/src/types/pg.d.ts +2 -0
- package/out/zero-cache/src/types/pg.d.ts.map +1 -1
- package/out/zero-cache/src/types/pg.js +53 -0
- package/out/zero-cache/src/types/pg.js.map +1 -1
- package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/workers/replicator.js +14 -3
- package/out/zero-cache/src/workers/replicator.js.map +1 -1
- package/out/zero-client/src/client/custom.d.ts +6 -10
- package/out/zero-client/src/client/custom.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/inspector.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/types.d.ts +0 -1
- package/out/zero-client/src/client/inspector/types.d.ts.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.d.ts +7 -3
- package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
- package/out/zero-client/src/client/zero-rep.d.ts +6 -2
- package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/mod.d.ts +1 -1
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-pg/src/custom.d.ts +2 -1
- package/out/zero-pg/src/custom.d.ts.map +1 -1
- package/out/zero-pg/src/custom.js +33 -16
- package/out/zero-pg/src/custom.js.map +1 -1
- package/out/zero-pg/src/query.d.ts +3 -2
- package/out/zero-pg/src/query.d.ts.map +1 -1
- package/out/zero-pg/src/query.js +10 -6
- package/out/zero-pg/src/query.js.map +1 -1
- package/out/zero-pg/src/schema.d.ts +13 -0
- package/out/zero-pg/src/schema.d.ts.map +1 -0
- package/out/zero-pg/src/schema.js +59 -0
- package/out/zero-pg/src/schema.js.map +1 -0
- package/out/zero-pg/src/web.d.ts +2 -1
- package/out/zero-pg/src/web.d.ts.map +1 -1
- package/out/zero-pg/src/web.js +19 -10
- package/out/zero-pg/src/web.js.map +1 -1
- package/out/zero-protocol/src/client-schema.d.ts +1 -1
- package/out/zero-protocol/src/client-schema.d.ts.map +1 -1
- package/out/zero-protocol/src/client-schema.js +1 -1
- package/out/zero-protocol/src/client-schema.js.map +1 -1
- package/out/zero-protocol/src/down.d.ts +5 -5
- package/out/zero-protocol/src/protocol-version.d.ts +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
- package/out/zero-protocol/src/protocol-version.js +3 -2
- package/out/zero-protocol/src/protocol-version.js.map +1 -1
- package/out/zero-protocol/src/push.d.ts +16 -16
- package/out/zero-protocol/src/push.d.ts.map +1 -1
- package/out/zero-protocol/src/push.js +8 -5
- package/out/zero-protocol/src/push.js.map +1 -1
- package/out/zero-react/src/mod.d.ts +1 -1
- package/out/zero-react/src/mod.d.ts.map +1 -1
- package/out/zero-schema/src/builder/table-builder.d.ts +0 -12
- package/out/zero-schema/src/builder/table-builder.d.ts.map +1 -1
- package/out/zero-schema/src/builder/table-builder.js +0 -16
- package/out/zero-schema/src/builder/table-builder.js.map +1 -1
- package/out/zero-schema/src/table-schema.d.ts +0 -3
- package/out/zero-schema/src/table-schema.d.ts.map +1 -1
- package/out/zero-schema/src/table-schema.js +0 -3
- package/out/zero-schema/src/table-schema.js.map +1 -1
- package/out/zero-solid/src/mod.d.ts +1 -1
- package/out/zero-solid/src/mod.d.ts.map +1 -1
- package/out/zero.js +4 -8
- package/out/zql/src/ivm/catch.d.ts +51 -0
- package/out/zql/src/ivm/catch.d.ts.map +1 -0
- package/out/zql/src/ivm/catch.js +78 -0
- package/out/zql/src/ivm/catch.js.map +1 -0
- package/out/zql/src/ivm/memory-storage.js +37 -0
- package/out/zql/src/ivm/memory-storage.js.map +1 -0
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +6 -4
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +0 -8
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +4 -3
- package/out/chunk-I7LQ2GI3.js.map +0 -7
- package/out/inspector-SH2ZK7O3.js +0 -835
- package/out/inspector-SH2ZK7O3.js.map +0 -7
|
@@ -34,7 +34,6 @@ import {
|
|
|
34
34
|
clientGroupHasPendingMutations,
|
|
35
35
|
clientGroupIDSchema,
|
|
36
36
|
clientIDSchema,
|
|
37
|
-
clientToServer,
|
|
38
37
|
commitFromHash,
|
|
39
38
|
commitFromHead,
|
|
40
39
|
commitIsLocalDD31,
|
|
@@ -95,7 +94,6 @@ import {
|
|
|
95
94
|
readonlyArray,
|
|
96
95
|
readonlyObject,
|
|
97
96
|
rowSchema,
|
|
98
|
-
serverToClient,
|
|
99
97
|
setClient,
|
|
100
98
|
setClientGroup,
|
|
101
99
|
setClientGroups,
|
|
@@ -116,7 +114,7 @@ import {
|
|
|
116
114
|
withWrite,
|
|
117
115
|
withWriteNoImplicitCommit,
|
|
118
116
|
wrapIterable
|
|
119
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-R7QLNPBS.js";
|
|
120
118
|
import {
|
|
121
119
|
compareTTL,
|
|
122
120
|
hasOwn,
|
|
@@ -299,11 +297,15 @@ function assertPullerResultV1(v) {
|
|
|
299
297
|
import { resolver } from "@rocicorp/resolver";
|
|
300
298
|
|
|
301
299
|
// ../shared/src/browser-env.ts
|
|
300
|
+
var overrides = /* @__PURE__ */ new Map();
|
|
302
301
|
function getBrowserGlobal(name) {
|
|
302
|
+
if (overrides.has(name)) {
|
|
303
|
+
return overrides.get(name);
|
|
304
|
+
}
|
|
303
305
|
return globalThis[name];
|
|
304
306
|
}
|
|
305
307
|
function getBrowserGlobalMethod(name) {
|
|
306
|
-
return
|
|
308
|
+
return getBrowserGlobal(name)?.bind(globalThis);
|
|
307
309
|
}
|
|
308
310
|
function mustGetBrowserGlobal(name) {
|
|
309
311
|
const r = getBrowserGlobal(name);
|
|
@@ -5174,7 +5176,20 @@ var ReplicacheImpl = class {
|
|
|
5174
5176
|
};
|
|
5175
5177
|
#register(name, mutatorImpl) {
|
|
5176
5178
|
this.#mutatorRegistry[name] = mutatorImpl;
|
|
5177
|
-
return (args) =>
|
|
5179
|
+
return (args) => {
|
|
5180
|
+
const trackingData = name === "_zero_crud" ? void 0 : this.#zero?.trackMutation();
|
|
5181
|
+
const result = this.#mutate(
|
|
5182
|
+
trackingData,
|
|
5183
|
+
name,
|
|
5184
|
+
mutatorImpl,
|
|
5185
|
+
args,
|
|
5186
|
+
performance.now()
|
|
5187
|
+
);
|
|
5188
|
+
if (trackingData) {
|
|
5189
|
+
result.server = trackingData.serverPromise;
|
|
5190
|
+
}
|
|
5191
|
+
return result;
|
|
5192
|
+
};
|
|
5178
5193
|
}
|
|
5179
5194
|
#registerMutators(regs) {
|
|
5180
5195
|
const rv = /* @__PURE__ */ Object.create(null);
|
|
@@ -5183,7 +5198,7 @@ var ReplicacheImpl = class {
|
|
|
5183
5198
|
}
|
|
5184
5199
|
return rv;
|
|
5185
5200
|
}
|
|
5186
|
-
async #mutate(name, mutatorImpl, args,
|
|
5201
|
+
async #mutate(trackingData, name, mutatorImpl, args, timestamp) {
|
|
5187
5202
|
const frozenArgs = deepFreeze(args ?? null);
|
|
5188
5203
|
if (this.#subscriptions.hasPendingSubscriptionRuns) {
|
|
5189
5204
|
await Promise.resolve();
|
|
@@ -5192,36 +5207,54 @@ var ReplicacheImpl = class {
|
|
|
5192
5207
|
const { clientID } = this;
|
|
5193
5208
|
return withWriteNoImplicitCommit(this.memdag, async (dagWrite) => {
|
|
5194
5209
|
try {
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
originalHash
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5210
|
+
let result;
|
|
5211
|
+
let newHead;
|
|
5212
|
+
let diffs;
|
|
5213
|
+
let headHash;
|
|
5214
|
+
try {
|
|
5215
|
+
headHash = await mustGetHeadHash(DEFAULT_HEAD_NAME, dagWrite);
|
|
5216
|
+
const originalHash = null;
|
|
5217
|
+
const dbWrite = await newWriteLocal(
|
|
5218
|
+
headHash,
|
|
5219
|
+
name,
|
|
5220
|
+
frozenArgs,
|
|
5221
|
+
originalHash,
|
|
5222
|
+
dagWrite,
|
|
5223
|
+
timestamp,
|
|
5224
|
+
clientID,
|
|
5225
|
+
Latest
|
|
5226
|
+
);
|
|
5227
|
+
const mutationID = await dbWrite.getMutationID();
|
|
5228
|
+
const tx = new WriteTransactionImpl(
|
|
5229
|
+
clientID,
|
|
5230
|
+
mutationID,
|
|
5231
|
+
"initial",
|
|
5232
|
+
await this.#zero?.getTxData(headHash, {
|
|
5233
|
+
openLazyRead: dagWrite
|
|
5234
|
+
}),
|
|
5235
|
+
dbWrite,
|
|
5236
|
+
this.#lc
|
|
5237
|
+
);
|
|
5238
|
+
if (trackingData) {
|
|
5239
|
+
this.#zero?.mutationIDAssigned(
|
|
5240
|
+
trackingData.ephemeralID,
|
|
5241
|
+
mutationID
|
|
5242
|
+
);
|
|
5243
|
+
}
|
|
5244
|
+
result = await mutatorImpl(tx, args);
|
|
5245
|
+
throwIfClosed(dbWrite);
|
|
5246
|
+
const lastMutationID = await dbWrite.getMutationID();
|
|
5247
|
+
[newHead, diffs] = await dbWrite.commitWithDiffs(
|
|
5248
|
+
DEFAULT_HEAD_NAME,
|
|
5249
|
+
this.#subscriptions
|
|
5250
|
+
);
|
|
5251
|
+
this.lastMutationID = lastMutationID;
|
|
5252
|
+
} catch (e) {
|
|
5253
|
+
if (trackingData) {
|
|
5254
|
+
this.#zero?.rejectMutation(trackingData.ephemeralID, e);
|
|
5255
|
+
}
|
|
5256
|
+
throw e;
|
|
5257
|
+
}
|
|
5225
5258
|
this.#zero?.advance(headHash, newHead, diffs.get("") ?? []);
|
|
5226
5259
|
this.#pushConnectionLoop.send(false).catch(() => void 0);
|
|
5227
5260
|
await this.#subscriptions.fire(diffs);
|
|
@@ -5551,9 +5584,7 @@ var valueTypeSchema = valita_exports.union(
|
|
|
5551
5584
|
valita_exports.literal("number"),
|
|
5552
5585
|
valita_exports.literal("boolean"),
|
|
5553
5586
|
valita_exports.literal("null"),
|
|
5554
|
-
valita_exports.literal("json")
|
|
5555
|
-
valita_exports.literal("date"),
|
|
5556
|
-
valita_exports.literal("timestamp")
|
|
5587
|
+
valita_exports.literal("json")
|
|
5557
5588
|
);
|
|
5558
5589
|
var columnSchemaSchema = valita_exports.object({
|
|
5559
5590
|
type: valueTypeSchema
|
|
@@ -5613,20 +5644,6 @@ function json() {
|
|
|
5613
5644
|
customType: null
|
|
5614
5645
|
});
|
|
5615
5646
|
}
|
|
5616
|
-
function date() {
|
|
5617
|
-
return new ColumnBuilder({
|
|
5618
|
-
type: "date",
|
|
5619
|
-
optional: false,
|
|
5620
|
-
customType: null
|
|
5621
|
-
});
|
|
5622
|
-
}
|
|
5623
|
-
function timestamp() {
|
|
5624
|
-
return new ColumnBuilder({
|
|
5625
|
-
type: "timestamp",
|
|
5626
|
-
optional: false,
|
|
5627
|
-
customType: null
|
|
5628
|
-
});
|
|
5629
|
-
}
|
|
5630
5647
|
function enumeration() {
|
|
5631
5648
|
return new ColumnBuilder({
|
|
5632
5649
|
type: "string",
|
|
@@ -5805,6 +5822,87 @@ var StaticQuery = class _StaticQuery extends AbstractQuery {
|
|
|
5805
5822
|
}
|
|
5806
5823
|
};
|
|
5807
5824
|
|
|
5825
|
+
// ../zero-schema/src/name-mapper.ts
|
|
5826
|
+
function clientToServer(tables) {
|
|
5827
|
+
return createMapperFrom("client", tables);
|
|
5828
|
+
}
|
|
5829
|
+
function serverToClient(tables) {
|
|
5830
|
+
return createMapperFrom("server", tables);
|
|
5831
|
+
}
|
|
5832
|
+
function createMapperFrom(src, tables) {
|
|
5833
|
+
const mapping = new Map(
|
|
5834
|
+
Object.entries(tables).map(
|
|
5835
|
+
([tableName, { serverName: serverTableName, columns }]) => {
|
|
5836
|
+
let allColumnsSame = true;
|
|
5837
|
+
const names = {};
|
|
5838
|
+
for (const [name, { serverName }] of Object.entries(columns)) {
|
|
5839
|
+
if (serverName && serverName !== name) {
|
|
5840
|
+
allColumnsSame = false;
|
|
5841
|
+
}
|
|
5842
|
+
if (src === "client") {
|
|
5843
|
+
names[name] = serverName ?? name;
|
|
5844
|
+
} else {
|
|
5845
|
+
names[serverName ?? name] = name;
|
|
5846
|
+
}
|
|
5847
|
+
}
|
|
5848
|
+
return [
|
|
5849
|
+
src === "client" ? tableName : serverTableName ?? tableName,
|
|
5850
|
+
{
|
|
5851
|
+
tableName: src === "client" ? serverTableName ?? tableName : tableName,
|
|
5852
|
+
columns: names,
|
|
5853
|
+
allColumnsSame
|
|
5854
|
+
}
|
|
5855
|
+
];
|
|
5856
|
+
}
|
|
5857
|
+
)
|
|
5858
|
+
);
|
|
5859
|
+
return new NameMapper(mapping);
|
|
5860
|
+
}
|
|
5861
|
+
var NameMapper = class {
|
|
5862
|
+
#tables = /* @__PURE__ */ new Map();
|
|
5863
|
+
constructor(tables) {
|
|
5864
|
+
this.#tables = tables;
|
|
5865
|
+
}
|
|
5866
|
+
#getTable(src, ctx) {
|
|
5867
|
+
const table2 = this.#tables.get(src);
|
|
5868
|
+
if (!table2) {
|
|
5869
|
+
throw new Error(
|
|
5870
|
+
`unknown table "${src}" ${!ctx ? "" : `in ${JSON.stringify(ctx)}`}`
|
|
5871
|
+
);
|
|
5872
|
+
}
|
|
5873
|
+
return table2;
|
|
5874
|
+
}
|
|
5875
|
+
tableName(src, context) {
|
|
5876
|
+
return this.#getTable(src, context).tableName;
|
|
5877
|
+
}
|
|
5878
|
+
columnName(table2, src, ctx) {
|
|
5879
|
+
const dst = this.#getTable(table2, ctx).columns[src];
|
|
5880
|
+
if (!dst) {
|
|
5881
|
+
throw new Error(
|
|
5882
|
+
`unknown column "${src}" of "${table2}" table ${!ctx ? "" : `in ${JSON.stringify(ctx)}`}`
|
|
5883
|
+
);
|
|
5884
|
+
}
|
|
5885
|
+
return dst;
|
|
5886
|
+
}
|
|
5887
|
+
row(table2, row) {
|
|
5888
|
+
const dest = this.#getTable(table2);
|
|
5889
|
+
const { allColumnsSame, columns } = dest;
|
|
5890
|
+
if (allColumnsSame) {
|
|
5891
|
+
return row;
|
|
5892
|
+
}
|
|
5893
|
+
const clientRow = {};
|
|
5894
|
+
for (const col in row) {
|
|
5895
|
+
clientRow[columns[col] ?? col] = row[col];
|
|
5896
|
+
}
|
|
5897
|
+
return clientRow;
|
|
5898
|
+
}
|
|
5899
|
+
columns(table2, cols) {
|
|
5900
|
+
const dest = this.#getTable(table2);
|
|
5901
|
+
const { allColumnsSame, columns } = dest;
|
|
5902
|
+
return cols === void 0 || allColumnsSame ? cols : cols.map((col) => columns[col] ?? col);
|
|
5903
|
+
}
|
|
5904
|
+
};
|
|
5905
|
+
|
|
5808
5906
|
// ../zero-schema/src/permissions.ts
|
|
5809
5907
|
var ANYONE_CAN = [
|
|
5810
5908
|
(_, eb) => eb.and()
|
|
@@ -6304,7 +6402,7 @@ var appErrorSchema = valita_exports.object({
|
|
|
6304
6402
|
details: jsonSchema.optional()
|
|
6305
6403
|
});
|
|
6306
6404
|
var zeroErrorSchema = valita_exports.object({
|
|
6307
|
-
error: valita_exports.literal("
|
|
6405
|
+
error: valita_exports.literal("oooMutation"),
|
|
6308
6406
|
details: jsonSchema.optional()
|
|
6309
6407
|
});
|
|
6310
6408
|
var mutationOkSchema = valita_exports.object({
|
|
@@ -6321,14 +6419,14 @@ var pushOkSchema = valita_exports.object({
|
|
|
6321
6419
|
mutations: valita_exports.array(mutationResponseSchema)
|
|
6322
6420
|
});
|
|
6323
6421
|
var unsupportedPushVersionSchema = valita_exports.object({
|
|
6324
|
-
error: valita_exports.literal("
|
|
6422
|
+
error: valita_exports.literal("unsupportedPushVersion"),
|
|
6325
6423
|
// optional for backwards compatibility
|
|
6326
6424
|
// This field is included so the client knows which mutations
|
|
6327
6425
|
// were not processed by the server.
|
|
6328
6426
|
mutationIDs: valita_exports.array(mutationIDSchema).optional()
|
|
6329
6427
|
});
|
|
6330
6428
|
var unsupportedSchemaVersionSchema = valita_exports.object({
|
|
6331
|
-
error: valita_exports.literal("
|
|
6429
|
+
error: valita_exports.literal("unsupportedSchemaVersion"),
|
|
6332
6430
|
// optional for backwards compatibility
|
|
6333
6431
|
// This field is included so the client knows which mutations
|
|
6334
6432
|
// were not processed by the server.
|
|
@@ -6341,7 +6439,7 @@ var httpErrorSchema = valita_exports.object({
|
|
|
6341
6439
|
mutationIDs: valita_exports.array(mutationIDSchema).optional()
|
|
6342
6440
|
});
|
|
6343
6441
|
var zeroPusherErrorSchema = valita_exports.object({
|
|
6344
|
-
error: valita_exports.literal("
|
|
6442
|
+
error: valita_exports.literal("zeroPusher"),
|
|
6345
6443
|
details: valita_exports.string(),
|
|
6346
6444
|
mutationIDs: valita_exports.array(mutationIDSchema).optional()
|
|
6347
6445
|
});
|
|
@@ -6353,7 +6451,7 @@ var pushErrorSchema = valita_exports.union(
|
|
|
6353
6451
|
);
|
|
6354
6452
|
var pushResponseSchema = valita_exports.union(pushOkSchema, pushErrorSchema);
|
|
6355
6453
|
var pushResponseMessageSchema = valita_exports.tuple([
|
|
6356
|
-
valita_exports.literal("
|
|
6454
|
+
valita_exports.literal("pushResponse"),
|
|
6357
6455
|
pushResponseSchema
|
|
6358
6456
|
]);
|
|
6359
6457
|
var pushParamsSchema = valita_exports.object({
|
|
@@ -6390,7 +6488,7 @@ var downstreamSchema = valita_exports.union(
|
|
|
6390
6488
|
);
|
|
6391
6489
|
|
|
6392
6490
|
// ../zero-protocol/src/protocol-version.ts
|
|
6393
|
-
var PROTOCOL_VERSION =
|
|
6491
|
+
var PROTOCOL_VERSION = 14;
|
|
6394
6492
|
var MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 6;
|
|
6395
6493
|
assert(MIN_SERVER_SUPPORTED_SYNC_PROTOCOL < PROTOCOL_VERSION);
|
|
6396
6494
|
|
|
@@ -7943,17 +8041,10 @@ var TransactionImpl = class {
|
|
|
7943
8041
|
query;
|
|
7944
8042
|
token;
|
|
7945
8043
|
};
|
|
7946
|
-
function makeReplicacheMutator(lc,
|
|
8044
|
+
function makeReplicacheMutator(lc, mutator, schema, slowMaterializeThreshold) {
|
|
7947
8045
|
return async (repTx, args) => {
|
|
7948
8046
|
const tx = new TransactionImpl(lc, repTx, schema, slowMaterializeThreshold);
|
|
7949
8047
|
await mutator(tx, args);
|
|
7950
|
-
if (repTx.reason === "initial") {
|
|
7951
|
-
const serverPromise = mutationTracker.trackMutation(repTx.mutationID);
|
|
7952
|
-
return {
|
|
7953
|
-
server: serverPromise
|
|
7954
|
-
};
|
|
7955
|
-
}
|
|
7956
|
-
return {};
|
|
7957
8048
|
};
|
|
7958
8049
|
}
|
|
7959
8050
|
function makeSchemaCRUD(schema, tx, ivmBranch) {
|
|
@@ -8323,7 +8414,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
8323
8414
|
}
|
|
8324
8415
|
|
|
8325
8416
|
// ../zero-client/src/client/version.ts
|
|
8326
|
-
var version2 = "0.18.
|
|
8417
|
+
var version2 = "0.18.2025040201";
|
|
8327
8418
|
|
|
8328
8419
|
// ../zero-client/src/client/log-options.ts
|
|
8329
8420
|
var LevelFilterLogSink = class {
|
|
@@ -8620,34 +8711,62 @@ var State = class {
|
|
|
8620
8711
|
// ../zero-client/src/client/mutation-tracker.ts
|
|
8621
8712
|
import { resolver as resolver7 } from "@rocicorp/resolver";
|
|
8622
8713
|
var transientPushErrorTypes = [
|
|
8623
|
-
"
|
|
8714
|
+
"zeroPusher",
|
|
8624
8715
|
"http",
|
|
8625
8716
|
// These should never actually be received as they cause the websocket
|
|
8626
8717
|
// connection to be closed.
|
|
8627
|
-
"
|
|
8628
|
-
"
|
|
8718
|
+
"unsupportedPushVersion",
|
|
8719
|
+
"unsupportedSchemaVersion"
|
|
8629
8720
|
];
|
|
8721
|
+
var currentEphemeralID = 0;
|
|
8722
|
+
function nextEphemeralID() {
|
|
8723
|
+
return ++currentEphemeralID;
|
|
8724
|
+
}
|
|
8630
8725
|
var MutationTracker = class {
|
|
8631
8726
|
#outstandingMutations;
|
|
8727
|
+
#ephemeralIDsByMutationID;
|
|
8632
8728
|
#allMutationsConfirmedListeners;
|
|
8729
|
+
#lc;
|
|
8633
8730
|
#clientID;
|
|
8634
|
-
constructor() {
|
|
8731
|
+
constructor(lc) {
|
|
8732
|
+
this.#lc = lc.withContext("MutationTracker");
|
|
8635
8733
|
this.#outstandingMutations = /* @__PURE__ */ new Map();
|
|
8734
|
+
this.#ephemeralIDsByMutationID = /* @__PURE__ */ new Map();
|
|
8636
8735
|
this.#allMutationsConfirmedListeners = /* @__PURE__ */ new Set();
|
|
8637
8736
|
}
|
|
8638
8737
|
set clientID(clientID) {
|
|
8639
8738
|
this.#clientID = clientID;
|
|
8640
8739
|
}
|
|
8641
|
-
trackMutation(
|
|
8642
|
-
|
|
8740
|
+
trackMutation() {
|
|
8741
|
+
const id = nextEphemeralID();
|
|
8643
8742
|
const mutationResolver = resolver7();
|
|
8644
8743
|
this.#outstandingMutations.set(id, {
|
|
8645
8744
|
resolver: mutationResolver
|
|
8646
8745
|
});
|
|
8647
|
-
return mutationResolver.promise;
|
|
8746
|
+
return { ephemeralID: id, serverPromise: mutationResolver.promise };
|
|
8747
|
+
}
|
|
8748
|
+
mutationIDAssigned(id, mutationID) {
|
|
8749
|
+
const entry = this.#outstandingMutations.get(id);
|
|
8750
|
+
if (entry) {
|
|
8751
|
+
entry.mutationID = mutationID;
|
|
8752
|
+
this.#ephemeralIDsByMutationID.set(mutationID, id);
|
|
8753
|
+
}
|
|
8754
|
+
}
|
|
8755
|
+
rejectMutation(id, e) {
|
|
8756
|
+
const entry = this.#outstandingMutations.get(id);
|
|
8757
|
+
if (entry) {
|
|
8758
|
+
this.#settleMutation(id, entry, "reject", {
|
|
8759
|
+
error: "app",
|
|
8760
|
+
details: e instanceof Error ? e.message : String(e)
|
|
8761
|
+
});
|
|
8762
|
+
}
|
|
8648
8763
|
}
|
|
8649
8764
|
processPushResponse(response) {
|
|
8650
8765
|
if ("error" in response) {
|
|
8766
|
+
this.#lc.error?.(
|
|
8767
|
+
"Received an error response when pushing mutations",
|
|
8768
|
+
response
|
|
8769
|
+
);
|
|
8651
8770
|
this.#processPushError(response);
|
|
8652
8771
|
} else {
|
|
8653
8772
|
this.#processPushOk(response);
|
|
@@ -8676,7 +8795,10 @@ var MutationTracker = class {
|
|
|
8676
8795
|
*/
|
|
8677
8796
|
onConnected(lastMutationID) {
|
|
8678
8797
|
for (const [id, entry] of this.#outstandingMutations) {
|
|
8679
|
-
if (
|
|
8798
|
+
if (!entry.mutationID) {
|
|
8799
|
+
continue;
|
|
8800
|
+
}
|
|
8801
|
+
if (entry.mutationID <= lastMutationID) {
|
|
8680
8802
|
this.#settleMutation(id, entry, "resolve", emptyObject);
|
|
8681
8803
|
} else {
|
|
8682
8804
|
break;
|
|
@@ -8712,20 +8834,31 @@ var MutationTracker = class {
|
|
|
8712
8834
|
mid.clientID === this.#clientID,
|
|
8713
8835
|
"received mutation for the wrong client"
|
|
8714
8836
|
);
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8837
|
+
this.#lc.error?.(`Mutation ${mid.id} returned an error`, error);
|
|
8838
|
+
const ephemeralID = this.#ephemeralIDsByMutationID.get(mid.id);
|
|
8839
|
+
assert(
|
|
8840
|
+
ephemeralID,
|
|
8841
|
+
() => "invalid state. An ephemeral id was never assigned to mutation " + mid.id
|
|
8842
|
+
);
|
|
8843
|
+
const entry = this.#outstandingMutations.get(ephemeralID);
|
|
8844
|
+
assert(entry && entry.mutationID === mid.id);
|
|
8845
|
+
this.#settleMutation(ephemeralID, entry, "reject", error);
|
|
8718
8846
|
}
|
|
8719
8847
|
#processMutationOk(result, mid) {
|
|
8720
8848
|
assert(
|
|
8721
8849
|
mid.clientID === this.#clientID,
|
|
8722
8850
|
"received mutation for the wrong client"
|
|
8723
8851
|
);
|
|
8724
|
-
const
|
|
8725
|
-
assert(
|
|
8726
|
-
|
|
8852
|
+
const ephemeralID = this.#ephemeralIDsByMutationID.get(mid.id);
|
|
8853
|
+
assert(
|
|
8854
|
+
ephemeralID,
|
|
8855
|
+
() => "invalid state. An ephemeral id was never assigned to mutation " + mid.id
|
|
8856
|
+
);
|
|
8857
|
+
const entry = this.#outstandingMutations.get(ephemeralID);
|
|
8858
|
+
assert(entry && entry.mutationID === mid.id);
|
|
8859
|
+
this.#settleMutation(ephemeralID, entry, "resolve", result);
|
|
8727
8860
|
}
|
|
8728
|
-
#settleMutation(
|
|
8861
|
+
#settleMutation(ephemeralID, entry, type, result) {
|
|
8729
8862
|
switch (type) {
|
|
8730
8863
|
case "resolve":
|
|
8731
8864
|
assert(!("error" in result));
|
|
@@ -8736,7 +8869,10 @@ var MutationTracker = class {
|
|
|
8736
8869
|
entry.resolver.reject(result);
|
|
8737
8870
|
break;
|
|
8738
8871
|
}
|
|
8739
|
-
const removed = this.#outstandingMutations.delete(
|
|
8872
|
+
const removed = this.#outstandingMutations.delete(ephemeralID);
|
|
8873
|
+
if (entry.mutationID) {
|
|
8874
|
+
this.#ephemeralIDsByMutationID.delete(entry.mutationID);
|
|
8875
|
+
}
|
|
8740
8876
|
if (removed && this.#outstandingMutations.size === 0) {
|
|
8741
8877
|
this.#notifyAllMutationsConfirmedListeners();
|
|
8742
8878
|
}
|
|
@@ -9404,12 +9540,14 @@ var ZeroRep = class {
|
|
|
9404
9540
|
#context;
|
|
9405
9541
|
#ivmMain;
|
|
9406
9542
|
#customMutatorsEnabled;
|
|
9543
|
+
#mutationTracker;
|
|
9407
9544
|
#store;
|
|
9408
9545
|
#auth;
|
|
9409
|
-
constructor(context, ivmMain, customMutatorsEnabled) {
|
|
9546
|
+
constructor(context, ivmMain, customMutatorsEnabled, mutationTracker) {
|
|
9410
9547
|
this.#context = context;
|
|
9411
9548
|
this.#ivmMain = ivmMain;
|
|
9412
9549
|
this.#customMutatorsEnabled = customMutatorsEnabled;
|
|
9550
|
+
this.#mutationTracker = mutationTracker;
|
|
9413
9551
|
}
|
|
9414
9552
|
set auth(auth) {
|
|
9415
9553
|
if (auth === "") {
|
|
@@ -9448,6 +9586,15 @@ var ZeroRep = class {
|
|
|
9448
9586
|
advance = (expectedHash, newHash, diffs) => {
|
|
9449
9587
|
this.#context.processChanges(expectedHash, newHash, diffs);
|
|
9450
9588
|
};
|
|
9589
|
+
trackMutation() {
|
|
9590
|
+
return this.#mutationTracker.trackMutation();
|
|
9591
|
+
}
|
|
9592
|
+
mutationIDAssigned(ephemeralID, mutationID) {
|
|
9593
|
+
this.#mutationTracker.mutationIDAssigned(ephemeralID, mutationID);
|
|
9594
|
+
}
|
|
9595
|
+
rejectMutation(ephemeralID, ex) {
|
|
9596
|
+
this.#mutationTracker.rejectMutation(ephemeralID, ex);
|
|
9597
|
+
}
|
|
9451
9598
|
};
|
|
9452
9599
|
|
|
9453
9600
|
// ../zero-client/src/client/zero.ts
|
|
@@ -9649,7 +9796,7 @@ var Zero = class {
|
|
|
9649
9796
|
);
|
|
9650
9797
|
}
|
|
9651
9798
|
const lc = new LogContext4(logOptions.logLevel, {}, logOptions.logSink);
|
|
9652
|
-
this.#mutationTracker = new MutationTracker();
|
|
9799
|
+
this.#mutationTracker = new MutationTracker(lc);
|
|
9653
9800
|
if (options.mutators) {
|
|
9654
9801
|
for (const [namespaceOrKey, mutatorOrMutators] of Object.entries(
|
|
9655
9802
|
options.mutators
|
|
@@ -9659,7 +9806,6 @@ var Zero = class {
|
|
|
9659
9806
|
assertUnique(key);
|
|
9660
9807
|
replicacheMutators[key] = makeReplicacheMutator(
|
|
9661
9808
|
lc,
|
|
9662
|
-
this.#mutationTracker,
|
|
9663
9809
|
mutatorOrMutators,
|
|
9664
9810
|
schema,
|
|
9665
9811
|
slowMaterializeThreshold
|
|
@@ -9677,7 +9823,6 @@ var Zero = class {
|
|
|
9677
9823
|
assertUnique(key);
|
|
9678
9824
|
replicacheMutators[key] = makeReplicacheMutator(
|
|
9679
9825
|
lc,
|
|
9680
|
-
this.#mutationTracker,
|
|
9681
9826
|
mutator,
|
|
9682
9827
|
schema,
|
|
9683
9828
|
slowMaterializeThreshold
|
|
@@ -9727,7 +9872,8 @@ var Zero = class {
|
|
|
9727
9872
|
zero: new ZeroRep(
|
|
9728
9873
|
this.#zeroContext,
|
|
9729
9874
|
this.#ivmMain,
|
|
9730
|
-
options.mutators !== void 0
|
|
9875
|
+
options.mutators !== void 0,
|
|
9876
|
+
this.#mutationTracker
|
|
9731
9877
|
)
|
|
9732
9878
|
};
|
|
9733
9879
|
const rep = new ReplicacheImpl(replicacheOptions, replicacheImplOptions);
|
|
@@ -10012,7 +10158,7 @@ var Zero = class {
|
|
|
10012
10158
|
return this.#deleteClientsManager.clientsDeletedOnServer(
|
|
10013
10159
|
downMessage[1]
|
|
10014
10160
|
);
|
|
10015
|
-
case "
|
|
10161
|
+
case "pushResponse":
|
|
10016
10162
|
return this.#mutationTracker.processPushResponse(downMessage[1]);
|
|
10017
10163
|
case "inspect":
|
|
10018
10164
|
break;
|
|
@@ -10377,17 +10523,17 @@ var Zero = class {
|
|
|
10377
10523
|
const now = Date.now();
|
|
10378
10524
|
for (let i = start; i < req.mutations.length; i++) {
|
|
10379
10525
|
const m = req.mutations[i];
|
|
10380
|
-
const
|
|
10526
|
+
const timestamp = now - Math.round(performance.now() - m.timestamp);
|
|
10381
10527
|
const zeroM = m.name === CRUD_MUTATION_NAME ? {
|
|
10382
10528
|
type: CRUD,
|
|
10383
|
-
timestamp
|
|
10529
|
+
timestamp,
|
|
10384
10530
|
id: m.id,
|
|
10385
10531
|
clientID: m.clientID,
|
|
10386
10532
|
name: m.name,
|
|
10387
10533
|
args: [mapCRUD(m.args, this.#clientToServer)]
|
|
10388
10534
|
} : {
|
|
10389
10535
|
type: Custom,
|
|
10390
|
-
timestamp
|
|
10536
|
+
timestamp,
|
|
10391
10537
|
id: m.id,
|
|
10392
10538
|
clientID: m.clientID,
|
|
10393
10539
|
name: m.name,
|
|
@@ -10697,7 +10843,7 @@ var Zero = class {
|
|
|
10697
10843
|
*/
|
|
10698
10844
|
async inspect() {
|
|
10699
10845
|
BUNDLE_SIZE: {
|
|
10700
|
-
const m = await import("./inspector-
|
|
10846
|
+
const m = await import("./inspector-RYBBQ63M.js");
|
|
10701
10847
|
return m.newInspector(this.#rep, this.#schema, () => this.#socket);
|
|
10702
10848
|
}
|
|
10703
10849
|
}
|
|
@@ -10807,8 +10953,6 @@ export {
|
|
|
10807
10953
|
number2 as number,
|
|
10808
10954
|
boolean,
|
|
10809
10955
|
json,
|
|
10810
|
-
date,
|
|
10811
|
-
timestamp,
|
|
10812
10956
|
enumeration,
|
|
10813
10957
|
createSchema,
|
|
10814
10958
|
ANYONE_CAN,
|
|
@@ -10818,4 +10962,4 @@ export {
|
|
|
10818
10962
|
escapeLike,
|
|
10819
10963
|
Zero
|
|
10820
10964
|
};
|
|
10821
|
-
//# sourceMappingURL=chunk-
|
|
10965
|
+
//# sourceMappingURL=chunk-242YQPIZ.js.map
|