@rocicorp/zero 0.11.2025011802 → 0.11.2025012400
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-3JROCHFI.js → chunk-N57WXYAL.js} +316 -263
- package/out/chunk-N57WXYAL.js.map +7 -0
- package/out/datadog/src/datadog-log-sink.d.ts.map +1 -1
- package/out/react.js +37 -10
- package/out/react.js.map +2 -2
- package/out/replicache/src/replicache-impl.d.ts.map +1 -1
- package/out/replicache/src/sync/pull.d.ts.map +1 -1
- package/out/replicache/src/sync/request-id.d.ts.map +1 -1
- package/out/shared/src/custom-key-set.d.ts +25 -0
- package/out/shared/src/custom-key-set.d.ts.map +1 -0
- package/out/shared/src/custom-key-set.js +58 -0
- package/out/shared/src/custom-key-set.js.map +1 -0
- package/out/solid.js +1 -1
- package/out/zero/src/zero-cache-dev.d.ts.map +1 -1
- package/out/zero/src/zero-cache-dev.js +10 -0
- package/out/zero/src/zero-cache-dev.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/db/create.js +1 -1
- package/out/zero-cache/src/db/create.js.map +1 -1
- package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
- package/out/zero-cache/src/db/lite-tables.js +8 -10
- package/out/zero-cache/src/db/lite-tables.js.map +1 -1
- package/out/zero-cache/src/db/pg-to-lite.d.ts +2 -1
- package/out/zero-cache/src/db/pg-to-lite.d.ts.map +1 -1
- package/out/zero-cache/src/db/pg-to-lite.js +6 -8
- package/out/zero-cache/src/db/pg-to-lite.js.map +1 -1
- package/out/zero-cache/src/db/specs.d.ts +2 -1
- package/out/zero-cache/src/db/specs.d.ts.map +1 -1
- package/out/zero-cache/src/db/specs.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js +4 -0
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/life-cycle.d.ts.map +1 -1
- package/out/zero-cache/src/server/life-cycle.js +2 -0
- package/out/zero-cache/src/server/life-cycle.js.map +1 -1
- package/out/zero-cache/src/server/logging.js +1 -0
- package/out/zero-cache/src/server/logging.js.map +1 -1
- package/out/zero-cache/src/server/main.d.ts.map +1 -1
- package/out/zero-cache/src/server/main.js +7 -3
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/multi/runtime.d.ts.map +1 -1
- package/out/zero-cache/src/server/multi/runtime.js +5 -1
- package/out/zero-cache/src/server/multi/runtime.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.js +21 -4
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +4 -0
- 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 +16 -5
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/sync-schema.js +3 -3
- package/out/zero-cache/src/services/change-source/pg/sync-schema.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js +0 -14
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/dispatcher/sync-dispatcher.d.ts +1 -1
- package/out/zero-cache/src/services/dispatcher/sync-dispatcher.d.ts.map +1 -1
- package/out/zero-cache/src/services/dispatcher/sync-dispatcher.js +9 -2
- package/out/zero-cache/src/services/dispatcher/sync-dispatcher.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +16 -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 +73 -26
- 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 +2 -2
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +24 -4
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/key-columns.d.ts +32 -0
- package/out/zero-cache/src/services/view-syncer/key-columns.d.ts.map +1 -0
- package/out/zero-cache/src/services/view-syncer/key-columns.js +73 -0
- package/out/zero-cache/src/services/view-syncer/key-columns.js.map +1 -0
- package/out/zero-cache/src/types/error-for-client.d.ts +3 -1
- package/out/zero-cache/src/types/error-for-client.d.ts.map +1 -1
- package/out/zero-cache/src/types/lite.d.ts +27 -8
- package/out/zero-cache/src/types/lite.d.ts.map +1 -1
- package/out/zero-cache/src/types/lite.js +24 -12
- package/out/zero-cache/src/types/lite.js.map +1 -1
- package/out/zero-cache/src/types/processes.d.ts.map +1 -1
- package/out/zero-cache/src/types/processes.js +0 -4
- package/out/zero-cache/src/types/processes.js.map +1 -1
- package/out/zero-client/src/client/server-error.d.ts +2 -2
- package/out/zero-client/src/client/server-error.d.ts.map +1 -1
- package/out/zero-client/src/client/server-option.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +1 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/mod.d.ts +7 -3
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.d.ts +24 -24
- package/out/zero-protocol/src/ast.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.js +23 -1
- package/out/zero-protocol/src/ast.js.map +1 -1
- package/out/zero-protocol/src/error-kind-enum.d.ts +4 -0
- package/out/zero-protocol/src/error-kind-enum.d.ts.map +1 -1
- package/out/zero-protocol/src/error-kind-enum.js +2 -0
- package/out/zero-protocol/src/error-kind-enum.js.map +1 -1
- package/out/zero-protocol/src/error.d.ts +8 -5
- package/out/zero-protocol/src/error.d.ts.map +1 -1
- package/out/zero-protocol/src/error.js +15 -5
- package/out/zero-protocol/src/error.js.map +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts +1 -1
- package/out/zero-protocol/src/protocol-version.js +1 -1
- package/out/zero-react/src/use-query.d.ts +60 -3
- package/out/zero-react/src/use-query.d.ts.map +1 -1
- package/out/zero-schema/src/builder/schema-builder.d.ts +10 -3
- package/out/zero-schema/src/builder/schema-builder.d.ts.map +1 -1
- package/out/zero-schema/src/builder/schema-builder.js +11 -5
- package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
- package/out/zero-schema/src/permissions.d.ts +4 -5
- package/out/zero-schema/src/permissions.d.ts.map +1 -1
- package/out/zero-schema/src/table-schema.d.ts +2 -2
- package/out/zero-schema/src/table-schema.d.ts.map +1 -1
- package/out/zero.js +1 -1
- package/out/zql/src/builder/builder.d.ts +1 -1
- package/out/zql/src/builder/builder.d.ts.map +1 -1
- package/out/zql/src/builder/builder.js +18 -25
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/ivm/filter-push.d.ts +5 -0
- package/out/zql/src/ivm/filter-push.d.ts.map +1 -0
- package/out/zql/src/ivm/filter-push.js +27 -0
- package/out/zql/src/ivm/filter-push.js.map +1 -0
- package/out/zql/src/ivm/filter.d.ts +1 -7
- package/out/zql/src/ivm/filter.d.ts.map +1 -1
- package/out/zql/src/ivm/filter.js +4 -24
- package/out/zql/src/ivm/filter.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts +1 -1
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +6 -5
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/source.d.ts +3 -3
- package/out/zql/src/ivm/source.d.ts.map +1 -1
- package/out/zql/src/query/expression.d.ts +3 -3
- package/out/zql/src/query/expression.d.ts.map +1 -1
- package/out/zql/src/query/expression.js.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +2 -2
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query.d.ts +4 -3
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zqlite/src/db.d.ts +9 -1
- package/out/zqlite/src/db.d.ts.map +1 -1
- package/out/zqlite/src/db.js +20 -5
- package/out/zqlite/src/db.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts +4 -4
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +18 -13
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +2 -2
- package/out/chunk-3JROCHFI.js.map +0 -7
|
@@ -896,6 +896,7 @@ function dropIDBStore(name) {
|
|
|
896
896
|
}
|
|
897
897
|
|
|
898
898
|
// ../replicache/src/replicache-impl.ts
|
|
899
|
+
import { Lock as Lock2 } from "@rocicorp/lock";
|
|
899
900
|
import { consoleLogSink as consoleLogSink2 } from "@rocicorp/logger";
|
|
900
901
|
import { resolver as resolver6 } from "@rocicorp/resolver";
|
|
901
902
|
|
|
@@ -5111,7 +5112,6 @@ function handlePullResponseV1(lc, store, expectedBaseCookie, response, clientID,
|
|
|
5111
5112
|
);
|
|
5112
5113
|
}
|
|
5113
5114
|
if (Object.keys(response.lastMutationIDChanges).length > 0) {
|
|
5114
|
-
console.log(response.lastMutationIDChanges);
|
|
5115
5115
|
lc.error?.(
|
|
5116
5116
|
`handlePullResponse: cookie ${JSON.stringify(
|
|
5117
5117
|
baseCookie
|
|
@@ -7151,14 +7151,8 @@ function getSessionID() {
|
|
|
7151
7151
|
}
|
|
7152
7152
|
var REQUEST_COUNTERS = /* @__PURE__ */ new Map();
|
|
7153
7153
|
function newRequestID(clientID) {
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
REQUEST_COUNTERS.set(clientID, 0);
|
|
7157
|
-
counter = 0;
|
|
7158
|
-
} else {
|
|
7159
|
-
counter++;
|
|
7160
|
-
REQUEST_COUNTERS.set(clientID, counter);
|
|
7161
|
-
}
|
|
7154
|
+
const counter = REQUEST_COUNTERS.get(clientID) ?? 0;
|
|
7155
|
+
REQUEST_COUNTERS.set(clientID, counter + 1);
|
|
7162
7156
|
return `${clientID}-${getSessionID()}-${counter}`;
|
|
7163
7157
|
}
|
|
7164
7158
|
|
|
@@ -7254,7 +7248,7 @@ var ReplicacheImpl = class {
|
|
|
7254
7248
|
#idbDatabases;
|
|
7255
7249
|
#lc;
|
|
7256
7250
|
#closeAbortController = new AbortController();
|
|
7257
|
-
#
|
|
7251
|
+
#persistLock = new Lock2();
|
|
7258
7252
|
#enableScheduledPersist;
|
|
7259
7253
|
#enableScheduledRefresh;
|
|
7260
7254
|
#enablePullAndPushInOpen;
|
|
@@ -7946,11 +7940,9 @@ var ReplicacheImpl = class {
|
|
|
7946
7940
|
const { syncHead, httpRequestInfo } = beginPullResponse;
|
|
7947
7941
|
return { requestID, syncHead, ok: httpRequestInfo.httpStatusCode === 200 };
|
|
7948
7942
|
}
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
try {
|
|
7953
|
-
const { clientID: clientID2 } = this;
|
|
7943
|
+
persist() {
|
|
7944
|
+
return this.#persistLock.withLock(async () => {
|
|
7945
|
+
const { clientID } = this;
|
|
7954
7946
|
await this.#ready;
|
|
7955
7947
|
if (this.#closed) {
|
|
7956
7948
|
return;
|
|
@@ -7958,29 +7950,26 @@ var ReplicacheImpl = class {
|
|
|
7958
7950
|
try {
|
|
7959
7951
|
await persistDD31(
|
|
7960
7952
|
this.#lc,
|
|
7961
|
-
|
|
7953
|
+
clientID,
|
|
7962
7954
|
this.memdag,
|
|
7963
7955
|
this.perdag,
|
|
7964
7956
|
this.#mutatorRegistry,
|
|
7965
|
-
() => this
|
|
7957
|
+
() => this.#closed,
|
|
7966
7958
|
Latest
|
|
7967
7959
|
);
|
|
7968
7960
|
} catch (e) {
|
|
7969
7961
|
if (e instanceof ClientStateNotFoundError) {
|
|
7970
|
-
this.#clientStateNotFoundOnClient(
|
|
7962
|
+
this.#clientStateNotFoundOnClient(clientID);
|
|
7971
7963
|
} else if (this.#closed) {
|
|
7972
7964
|
this.#lc.debug?.("Exception persisting during close", e);
|
|
7973
7965
|
} else {
|
|
7974
7966
|
throw e;
|
|
7975
7967
|
}
|
|
7976
7968
|
}
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
const clientGroupID = await this.#clientGroupIDPromise;
|
|
7982
|
-
assert(clientGroupID);
|
|
7983
|
-
this.#onPersist({ clientID, clientGroupID });
|
|
7969
|
+
const clientGroupID = await this.#clientGroupIDPromise;
|
|
7970
|
+
assert(clientGroupID);
|
|
7971
|
+
this.#onPersist({ clientID, clientGroupID });
|
|
7972
|
+
});
|
|
7984
7973
|
}
|
|
7985
7974
|
async refresh() {
|
|
7986
7975
|
await this.#ready;
|
|
@@ -8320,6 +8309,176 @@ function getKVStoreProvider(lc, kvStore) {
|
|
|
8320
8309
|
// ../replicache/src/mod.ts
|
|
8321
8310
|
import { consoleLogSink as consoleLogSink3 } from "@rocicorp/logger";
|
|
8322
8311
|
|
|
8312
|
+
// ../zero-schema/src/builder/relationship-builder.ts
|
|
8313
|
+
function relationships(table2, cb) {
|
|
8314
|
+
const relationships2 = cb({ many, one });
|
|
8315
|
+
return {
|
|
8316
|
+
name: table2.schema.name,
|
|
8317
|
+
relationships: relationships2
|
|
8318
|
+
};
|
|
8319
|
+
}
|
|
8320
|
+
function many(...args) {
|
|
8321
|
+
return args.map((arg) => ({
|
|
8322
|
+
sourceField: arg.sourceField,
|
|
8323
|
+
destField: arg.destField,
|
|
8324
|
+
destSchema: arg.destSchema.schema.name,
|
|
8325
|
+
cardinality: "many"
|
|
8326
|
+
}));
|
|
8327
|
+
}
|
|
8328
|
+
function one(...args) {
|
|
8329
|
+
return args.map((arg) => ({
|
|
8330
|
+
sourceField: arg.sourceField,
|
|
8331
|
+
destField: arg.destField,
|
|
8332
|
+
destSchema: arg.destSchema.schema.name,
|
|
8333
|
+
cardinality: "one"
|
|
8334
|
+
}));
|
|
8335
|
+
}
|
|
8336
|
+
|
|
8337
|
+
// ../zero-schema/src/builder/table-builder.ts
|
|
8338
|
+
function table(name) {
|
|
8339
|
+
return new TableBuilder({
|
|
8340
|
+
name,
|
|
8341
|
+
columns: {},
|
|
8342
|
+
primaryKey: []
|
|
8343
|
+
});
|
|
8344
|
+
}
|
|
8345
|
+
function string7() {
|
|
8346
|
+
return new ColumnBuilder({
|
|
8347
|
+
type: "string",
|
|
8348
|
+
optional: false,
|
|
8349
|
+
customType: null
|
|
8350
|
+
});
|
|
8351
|
+
}
|
|
8352
|
+
function number4() {
|
|
8353
|
+
return new ColumnBuilder({
|
|
8354
|
+
type: "number",
|
|
8355
|
+
optional: false,
|
|
8356
|
+
customType: null
|
|
8357
|
+
});
|
|
8358
|
+
}
|
|
8359
|
+
function boolean3() {
|
|
8360
|
+
return new ColumnBuilder({
|
|
8361
|
+
type: "boolean",
|
|
8362
|
+
optional: false,
|
|
8363
|
+
customType: null
|
|
8364
|
+
});
|
|
8365
|
+
}
|
|
8366
|
+
function json() {
|
|
8367
|
+
return new ColumnBuilder({
|
|
8368
|
+
type: "json",
|
|
8369
|
+
optional: false,
|
|
8370
|
+
customType: null
|
|
8371
|
+
});
|
|
8372
|
+
}
|
|
8373
|
+
function enumeration() {
|
|
8374
|
+
return new ColumnBuilder({
|
|
8375
|
+
type: "string",
|
|
8376
|
+
optional: false,
|
|
8377
|
+
customType: null
|
|
8378
|
+
});
|
|
8379
|
+
}
|
|
8380
|
+
var TableBuilder = class {
|
|
8381
|
+
#schema;
|
|
8382
|
+
constructor(schema) {
|
|
8383
|
+
this.#schema = schema;
|
|
8384
|
+
}
|
|
8385
|
+
columns(columns) {
|
|
8386
|
+
const columnSchemas = Object.fromEntries(
|
|
8387
|
+
Object.entries(columns).map(([k, v2]) => [k, v2.schema])
|
|
8388
|
+
);
|
|
8389
|
+
return new TableBuilderWithColumns({
|
|
8390
|
+
...this.#schema,
|
|
8391
|
+
columns: columnSchemas
|
|
8392
|
+
});
|
|
8393
|
+
}
|
|
8394
|
+
};
|
|
8395
|
+
var TableBuilderWithColumns = class _TableBuilderWithColumns {
|
|
8396
|
+
#schema;
|
|
8397
|
+
constructor(schema) {
|
|
8398
|
+
this.#schema = schema;
|
|
8399
|
+
}
|
|
8400
|
+
primaryKey(...pkColumnNames) {
|
|
8401
|
+
return new _TableBuilderWithColumns({
|
|
8402
|
+
...this.#schema,
|
|
8403
|
+
primaryKey: pkColumnNames
|
|
8404
|
+
});
|
|
8405
|
+
}
|
|
8406
|
+
get schema() {
|
|
8407
|
+
return this.#schema;
|
|
8408
|
+
}
|
|
8409
|
+
build() {
|
|
8410
|
+
if (this.#schema.primaryKey.length === 0) {
|
|
8411
|
+
throw new Error(`Table "${this.#schema.name}" is missing a primary key`);
|
|
8412
|
+
}
|
|
8413
|
+
return this.#schema;
|
|
8414
|
+
}
|
|
8415
|
+
};
|
|
8416
|
+
var ColumnBuilder = class _ColumnBuilder {
|
|
8417
|
+
#schema;
|
|
8418
|
+
constructor(schema) {
|
|
8419
|
+
this.#schema = schema;
|
|
8420
|
+
}
|
|
8421
|
+
optional() {
|
|
8422
|
+
return new _ColumnBuilder({
|
|
8423
|
+
...this.#schema,
|
|
8424
|
+
optional: true
|
|
8425
|
+
});
|
|
8426
|
+
}
|
|
8427
|
+
get schema() {
|
|
8428
|
+
return this.#schema;
|
|
8429
|
+
}
|
|
8430
|
+
};
|
|
8431
|
+
|
|
8432
|
+
// ../zero-schema/src/builder/schema-builder.ts
|
|
8433
|
+
function createSchema(version3, options) {
|
|
8434
|
+
const retTables = {};
|
|
8435
|
+
const retRelationships = {};
|
|
8436
|
+
options.tables.forEach((table2) => {
|
|
8437
|
+
if (retTables[table2.schema.name]) {
|
|
8438
|
+
throw new Error(
|
|
8439
|
+
`Table "${table2.schema.name}" is defined more than once in the schema`
|
|
8440
|
+
);
|
|
8441
|
+
}
|
|
8442
|
+
retTables[table2.schema.name] = table2.build();
|
|
8443
|
+
});
|
|
8444
|
+
options.relationships?.forEach((relationships2) => {
|
|
8445
|
+
if (retRelationships[relationships2.name]) {
|
|
8446
|
+
throw new Error(
|
|
8447
|
+
`Relationships for table "${relationships2.name}" are defined more than once in the schema`
|
|
8448
|
+
);
|
|
8449
|
+
}
|
|
8450
|
+
retRelationships[relationships2.name] = relationships2.relationships;
|
|
8451
|
+
checkRelationship(
|
|
8452
|
+
relationships2.relationships,
|
|
8453
|
+
relationships2.name,
|
|
8454
|
+
retTables
|
|
8455
|
+
);
|
|
8456
|
+
});
|
|
8457
|
+
return {
|
|
8458
|
+
version: version3,
|
|
8459
|
+
tables: retTables,
|
|
8460
|
+
relationships: retRelationships
|
|
8461
|
+
};
|
|
8462
|
+
}
|
|
8463
|
+
function checkRelationship(relationships2, tableName, tables) {
|
|
8464
|
+
Object.entries(relationships2).forEach(([name, rel]) => {
|
|
8465
|
+
let source = tables[tableName];
|
|
8466
|
+
rel.forEach((connection) => {
|
|
8467
|
+
if (!tables[connection.destSchema]) {
|
|
8468
|
+
throw new Error(
|
|
8469
|
+
`For relationship "${tableName}"."${name}", destination table "${connection.destSchema}" is missing in the schema`
|
|
8470
|
+
);
|
|
8471
|
+
}
|
|
8472
|
+
if (!source.columns[connection.sourceField[0]]) {
|
|
8473
|
+
throw new Error(
|
|
8474
|
+
`For relationship "${tableName}"."${name}", the source field "${connection.sourceField[0]}" is missing in the table schema "${source.name}"`
|
|
8475
|
+
);
|
|
8476
|
+
}
|
|
8477
|
+
source = tables[connection.destSchema];
|
|
8478
|
+
});
|
|
8479
|
+
});
|
|
8480
|
+
}
|
|
8481
|
+
|
|
8323
8482
|
// ../zero-protocol/src/ast.ts
|
|
8324
8483
|
import { compareUTF8 as compareUTF83 } from "compare-utf8";
|
|
8325
8484
|
|
|
@@ -8400,8 +8559,13 @@ var columnReferenceSchema = readonlyObject({
|
|
|
8400
8559
|
});
|
|
8401
8560
|
var parameterReferenceSchema = readonlyObject({
|
|
8402
8561
|
type: valita_exports.literal("static"),
|
|
8562
|
+
// The "namespace" of the injected parameter.
|
|
8563
|
+
// Write authorization will send the value of a row
|
|
8564
|
+
// prior to the mutation being run (preMutationRow).
|
|
8565
|
+
// Read and write authorization will both send the
|
|
8566
|
+
// current authentication data (authData).
|
|
8403
8567
|
anchor: valita_exports.union(valita_exports.literal("authData"), valita_exports.literal("preMutationRow")),
|
|
8404
|
-
field: valita_exports.string()
|
|
8568
|
+
field: valita_exports.union(valita_exports.string(), valita_exports.array(valita_exports.string()))
|
|
8405
8569
|
});
|
|
8406
8570
|
var conditionValueSchema = valita_exports.union(
|
|
8407
8571
|
literalReferenceSchema,
|
|
@@ -9207,15 +9371,39 @@ function maybeSplitAndPushEditChange(change, predicate, output) {
|
|
|
9207
9371
|
}
|
|
9208
9372
|
}
|
|
9209
9373
|
|
|
9374
|
+
// ../zql/src/ivm/filter-push.ts
|
|
9375
|
+
function filterPush(change, output, predicate) {
|
|
9376
|
+
if (!predicate) {
|
|
9377
|
+
output.push(change);
|
|
9378
|
+
return;
|
|
9379
|
+
}
|
|
9380
|
+
switch (change.type) {
|
|
9381
|
+
case "add":
|
|
9382
|
+
case "remove":
|
|
9383
|
+
if (predicate(change.node.row)) {
|
|
9384
|
+
output.push(change);
|
|
9385
|
+
}
|
|
9386
|
+
break;
|
|
9387
|
+
case "child":
|
|
9388
|
+
if (predicate(change.row)) {
|
|
9389
|
+
output.push(change);
|
|
9390
|
+
}
|
|
9391
|
+
break;
|
|
9392
|
+
case "edit":
|
|
9393
|
+
maybeSplitAndPushEditChange(change, predicate, output);
|
|
9394
|
+
break;
|
|
9395
|
+
default:
|
|
9396
|
+
unreachable(change);
|
|
9397
|
+
}
|
|
9398
|
+
}
|
|
9399
|
+
|
|
9210
9400
|
// ../zql/src/ivm/filter.ts
|
|
9211
9401
|
var Filter = class {
|
|
9212
9402
|
#input;
|
|
9213
|
-
#mode;
|
|
9214
9403
|
#predicate;
|
|
9215
9404
|
#output = throwOutput;
|
|
9216
|
-
constructor(input,
|
|
9405
|
+
constructor(input, predicate) {
|
|
9217
9406
|
this.#input = input;
|
|
9218
|
-
this.#mode = mode;
|
|
9219
9407
|
this.#predicate = predicate;
|
|
9220
9408
|
input.setOutput(this);
|
|
9221
9409
|
}
|
|
@@ -9236,30 +9424,13 @@ var Filter = class {
|
|
|
9236
9424
|
}
|
|
9237
9425
|
*#filter(stream) {
|
|
9238
9426
|
for (const node of stream) {
|
|
9239
|
-
if (this.#
|
|
9427
|
+
if (this.#predicate(node.row)) {
|
|
9240
9428
|
yield node;
|
|
9241
9429
|
}
|
|
9242
9430
|
}
|
|
9243
9431
|
}
|
|
9244
9432
|
push(change) {
|
|
9245
|
-
|
|
9246
|
-
case "add":
|
|
9247
|
-
case "remove":
|
|
9248
|
-
if (this.#predicate(change.node.row)) {
|
|
9249
|
-
this.#output.push(change);
|
|
9250
|
-
}
|
|
9251
|
-
break;
|
|
9252
|
-
case "child":
|
|
9253
|
-
if (this.#predicate(change.row)) {
|
|
9254
|
-
this.#output.push(change);
|
|
9255
|
-
}
|
|
9256
|
-
break;
|
|
9257
|
-
case "edit":
|
|
9258
|
-
maybeSplitAndPushEditChange(change, this.#predicate, this.#output);
|
|
9259
|
-
break;
|
|
9260
|
-
default:
|
|
9261
|
-
unreachable(change);
|
|
9262
|
-
}
|
|
9433
|
+
filterPush(change, this.#output, this.#predicate);
|
|
9263
9434
|
}
|
|
9264
9435
|
};
|
|
9265
9436
|
|
|
@@ -10315,7 +10486,7 @@ function buildPipelineInternal(ast, delegate, partitionKey) {
|
|
|
10315
10486
|
}
|
|
10316
10487
|
const conn = source.connect(must(ast.orderBy), ast.where);
|
|
10317
10488
|
let end = conn;
|
|
10318
|
-
const {
|
|
10489
|
+
const { fullyAppliedFilters } = conn;
|
|
10319
10490
|
ast = uniquifyCorrelatedSubqueryConditionAliases(ast);
|
|
10320
10491
|
if (ast.start) {
|
|
10321
10492
|
end = new Skip(end, ast.start);
|
|
@@ -10323,8 +10494,8 @@ function buildPipelineInternal(ast, delegate, partitionKey) {
|
|
|
10323
10494
|
for (const csq of gatherCorrelatedSubqueryQueriesFromCondition(ast.where)) {
|
|
10324
10495
|
end = applyCorrelatedSubQuery(csq, delegate, end);
|
|
10325
10496
|
}
|
|
10326
|
-
if (ast.where) {
|
|
10327
|
-
end = applyWhere(end, ast.where,
|
|
10497
|
+
if (ast.where && !fullyAppliedFilters) {
|
|
10498
|
+
end = applyWhere(end, ast.where, delegate);
|
|
10328
10499
|
}
|
|
10329
10500
|
if (ast.limit) {
|
|
10330
10501
|
end = new Take(end, delegate.createStorage(), ast.limit, partitionKey);
|
|
@@ -10336,45 +10507,43 @@ function buildPipelineInternal(ast, delegate, partitionKey) {
|
|
|
10336
10507
|
}
|
|
10337
10508
|
return end;
|
|
10338
10509
|
}
|
|
10339
|
-
function applyWhere(input, condition,
|
|
10510
|
+
function applyWhere(input, condition, delegate) {
|
|
10340
10511
|
switch (condition.type) {
|
|
10341
10512
|
case "and":
|
|
10342
|
-
return applyAnd(input, condition,
|
|
10513
|
+
return applyAnd(input, condition, delegate);
|
|
10343
10514
|
case "or":
|
|
10344
|
-
return applyOr(input, condition,
|
|
10515
|
+
return applyOr(input, condition, delegate);
|
|
10345
10516
|
case "correlatedSubquery":
|
|
10346
10517
|
return applyCorrelatedSubqueryCondition(input, condition, delegate);
|
|
10347
10518
|
case "simple":
|
|
10348
|
-
return applySimpleCondition(input, condition
|
|
10519
|
+
return applySimpleCondition(input, condition);
|
|
10349
10520
|
}
|
|
10350
10521
|
}
|
|
10351
|
-
function applyAnd(input, condition,
|
|
10522
|
+
function applyAnd(input, condition, delegate) {
|
|
10352
10523
|
for (const subCondition of condition.conditions) {
|
|
10353
|
-
input = applyWhere(input, subCondition,
|
|
10524
|
+
input = applyWhere(input, subCondition, delegate);
|
|
10354
10525
|
}
|
|
10355
10526
|
return input;
|
|
10356
10527
|
}
|
|
10357
|
-
function applyOr(input, condition,
|
|
10528
|
+
function applyOr(input, condition, delegate) {
|
|
10358
10529
|
const [subqueryConditions, otherConditions] = groupSubqueryConditions(condition);
|
|
10359
10530
|
if (subqueryConditions.length === 0) {
|
|
10360
|
-
return
|
|
10531
|
+
return new Filter(
|
|
10361
10532
|
input,
|
|
10362
|
-
appliedFilters ? "push-only" : "all",
|
|
10363
10533
|
createPredicate({
|
|
10364
10534
|
type: "or",
|
|
10365
10535
|
conditions: otherConditions
|
|
10366
10536
|
})
|
|
10367
|
-
)
|
|
10537
|
+
);
|
|
10368
10538
|
}
|
|
10369
10539
|
const fanOut = new FanOut(input);
|
|
10370
10540
|
const branches = subqueryConditions.map(
|
|
10371
|
-
(subCondition) => applyWhere(fanOut, subCondition,
|
|
10541
|
+
(subCondition) => applyWhere(fanOut, subCondition, delegate)
|
|
10372
10542
|
);
|
|
10373
10543
|
if (otherConditions.length > 0) {
|
|
10374
10544
|
branches.push(
|
|
10375
10545
|
new Filter(
|
|
10376
10546
|
fanOut,
|
|
10377
|
-
appliedFilters ? "push-only" : "all",
|
|
10378
10547
|
createPredicate({
|
|
10379
10548
|
type: "or",
|
|
10380
10549
|
conditions: otherConditions
|
|
@@ -10405,12 +10574,8 @@ function isNotAndDoesNotContainSubquery(condition) {
|
|
|
10405
10574
|
assert(condition.type !== "or", "where conditions are expected to be in DNF");
|
|
10406
10575
|
return true;
|
|
10407
10576
|
}
|
|
10408
|
-
function applySimpleCondition(input, condition
|
|
10409
|
-
return new Filter(
|
|
10410
|
-
input,
|
|
10411
|
-
appliedFilters ? "push-only" : "all",
|
|
10412
|
-
createPredicate(condition)
|
|
10413
|
-
);
|
|
10577
|
+
function applySimpleCondition(input, condition) {
|
|
10578
|
+
return new Filter(input, createPredicate(condition));
|
|
10414
10579
|
}
|
|
10415
10580
|
function applyCorrelatedSubQuery(sq, delegate, end) {
|
|
10416
10581
|
assert(sq.subquery.alias, "Subquery must have an alias");
|
|
@@ -10871,7 +11036,9 @@ var AbstractQuery = class {
|
|
|
10871
11036
|
where(fieldOrExpressionFactory, opOrValue, value) {
|
|
10872
11037
|
let cond;
|
|
10873
11038
|
if (typeof fieldOrExpressionFactory === "function") {
|
|
10874
|
-
cond = fieldOrExpressionFactory(
|
|
11039
|
+
cond = fieldOrExpressionFactory(
|
|
11040
|
+
new ExpressionBuilder(this._exists)
|
|
11041
|
+
);
|
|
10875
11042
|
} else {
|
|
10876
11043
|
assert(opOrValue !== void 0, "Invalid condition");
|
|
10877
11044
|
cond = cmp(fieldOrExpressionFactory, opOrValue, value);
|
|
@@ -11298,162 +11465,6 @@ function baseTracker(anchor) {
|
|
|
11298
11465
|
var authDataRef = baseTracker("authData");
|
|
11299
11466
|
var preMutationRowRef = baseTracker("preMutationRow");
|
|
11300
11467
|
|
|
11301
|
-
// ../zero-schema/src/builder/table-builder.ts
|
|
11302
|
-
function table(name) {
|
|
11303
|
-
return new TableBuilder({
|
|
11304
|
-
name,
|
|
11305
|
-
columns: {},
|
|
11306
|
-
primaryKey: []
|
|
11307
|
-
});
|
|
11308
|
-
}
|
|
11309
|
-
function string8() {
|
|
11310
|
-
return new ColumnBuilder({
|
|
11311
|
-
type: "string",
|
|
11312
|
-
optional: false,
|
|
11313
|
-
customType: null
|
|
11314
|
-
});
|
|
11315
|
-
}
|
|
11316
|
-
function number5() {
|
|
11317
|
-
return new ColumnBuilder({
|
|
11318
|
-
type: "number",
|
|
11319
|
-
optional: false,
|
|
11320
|
-
customType: null
|
|
11321
|
-
});
|
|
11322
|
-
}
|
|
11323
|
-
function boolean4() {
|
|
11324
|
-
return new ColumnBuilder({
|
|
11325
|
-
type: "boolean",
|
|
11326
|
-
optional: false,
|
|
11327
|
-
customType: null
|
|
11328
|
-
});
|
|
11329
|
-
}
|
|
11330
|
-
function json() {
|
|
11331
|
-
return new ColumnBuilder({
|
|
11332
|
-
type: "json",
|
|
11333
|
-
optional: false,
|
|
11334
|
-
customType: null
|
|
11335
|
-
});
|
|
11336
|
-
}
|
|
11337
|
-
function enumeration() {
|
|
11338
|
-
return new ColumnBuilder({
|
|
11339
|
-
type: "string",
|
|
11340
|
-
optional: false,
|
|
11341
|
-
customType: null
|
|
11342
|
-
});
|
|
11343
|
-
}
|
|
11344
|
-
var TableBuilder = class {
|
|
11345
|
-
#schema;
|
|
11346
|
-
constructor(schema) {
|
|
11347
|
-
this.#schema = schema;
|
|
11348
|
-
}
|
|
11349
|
-
columns(columns) {
|
|
11350
|
-
const columnSchemas = Object.fromEntries(
|
|
11351
|
-
Object.entries(columns).map(([k, v2]) => [k, v2.schema])
|
|
11352
|
-
);
|
|
11353
|
-
return new TableBuilderWithColumns({
|
|
11354
|
-
...this.#schema,
|
|
11355
|
-
columns: columnSchemas
|
|
11356
|
-
});
|
|
11357
|
-
}
|
|
11358
|
-
};
|
|
11359
|
-
var TableBuilderWithColumns = class _TableBuilderWithColumns {
|
|
11360
|
-
#schema;
|
|
11361
|
-
constructor(schema) {
|
|
11362
|
-
this.#schema = schema;
|
|
11363
|
-
}
|
|
11364
|
-
primaryKey(...pkColumnNames) {
|
|
11365
|
-
return new _TableBuilderWithColumns({
|
|
11366
|
-
...this.#schema,
|
|
11367
|
-
primaryKey: pkColumnNames
|
|
11368
|
-
});
|
|
11369
|
-
}
|
|
11370
|
-
get schema() {
|
|
11371
|
-
return this.#schema;
|
|
11372
|
-
}
|
|
11373
|
-
build() {
|
|
11374
|
-
if (this.#schema.primaryKey.length === 0) {
|
|
11375
|
-
throw new Error(`Table "${this.#schema.name}" is missing a primary key`);
|
|
11376
|
-
}
|
|
11377
|
-
return this.#schema;
|
|
11378
|
-
}
|
|
11379
|
-
};
|
|
11380
|
-
var ColumnBuilder = class _ColumnBuilder {
|
|
11381
|
-
#schema;
|
|
11382
|
-
constructor(schema) {
|
|
11383
|
-
this.#schema = schema;
|
|
11384
|
-
}
|
|
11385
|
-
optional() {
|
|
11386
|
-
return new _ColumnBuilder({
|
|
11387
|
-
...this.#schema,
|
|
11388
|
-
optional: true
|
|
11389
|
-
});
|
|
11390
|
-
}
|
|
11391
|
-
get schema() {
|
|
11392
|
-
return this.#schema;
|
|
11393
|
-
}
|
|
11394
|
-
};
|
|
11395
|
-
|
|
11396
|
-
// ../zero-schema/src/builder/schema-builder.ts
|
|
11397
|
-
function createSchema(version3, tables, relationships2) {
|
|
11398
|
-
const retTables = {};
|
|
11399
|
-
const retRelationships = {};
|
|
11400
|
-
Object.values(tables).forEach((table2) => {
|
|
11401
|
-
retTables[table2.schema.name] = table2.build();
|
|
11402
|
-
});
|
|
11403
|
-
Object.values(relationships2 ?? {}).forEach((relationship) => {
|
|
11404
|
-
retRelationships[relationship.name] = relationship.relationships;
|
|
11405
|
-
checkRelationship(relationship.relationships, relationship.name, retTables);
|
|
11406
|
-
});
|
|
11407
|
-
return {
|
|
11408
|
-
version: version3,
|
|
11409
|
-
tables: retTables,
|
|
11410
|
-
relationships: retRelationships
|
|
11411
|
-
};
|
|
11412
|
-
}
|
|
11413
|
-
function checkRelationship(relationships2, tableName, tables) {
|
|
11414
|
-
Object.entries(relationships2).forEach(([name, rel]) => {
|
|
11415
|
-
let source = tables[tableName];
|
|
11416
|
-
rel.forEach((connection) => {
|
|
11417
|
-
if (!tables[connection.destSchema]) {
|
|
11418
|
-
throw new Error(
|
|
11419
|
-
`For relationship "${tableName}"."${name}", destination table "${connection.destSchema}" is missing in the schema`
|
|
11420
|
-
);
|
|
11421
|
-
}
|
|
11422
|
-
if (!source.columns[connection.sourceField[0]]) {
|
|
11423
|
-
throw new Error(
|
|
11424
|
-
`For relationship "${tableName}"."${name}", the source field "${connection.sourceField[0]}" is missing in the table schema "${source.name}"`
|
|
11425
|
-
);
|
|
11426
|
-
}
|
|
11427
|
-
source = tables[connection.destSchema];
|
|
11428
|
-
});
|
|
11429
|
-
});
|
|
11430
|
-
}
|
|
11431
|
-
|
|
11432
|
-
// ../zero-schema/src/builder/relationship-builder.ts
|
|
11433
|
-
function relationships(table2, cb) {
|
|
11434
|
-
const relationships2 = cb({ many, one });
|
|
11435
|
-
return {
|
|
11436
|
-
name: table2.schema.name,
|
|
11437
|
-
relationships: relationships2
|
|
11438
|
-
};
|
|
11439
|
-
}
|
|
11440
|
-
function many(...args) {
|
|
11441
|
-
return args.map((arg) => ({
|
|
11442
|
-
sourceField: arg.sourceField,
|
|
11443
|
-
destField: arg.destField,
|
|
11444
|
-
destSchema: arg.destSchema.schema.name,
|
|
11445
|
-
cardinality: "many"
|
|
11446
|
-
}));
|
|
11447
|
-
}
|
|
11448
|
-
function one(...args) {
|
|
11449
|
-
return args.map((arg) => ({
|
|
11450
|
-
sourceField: arg.sourceField,
|
|
11451
|
-
destField: arg.destField,
|
|
11452
|
-
destSchema: arg.destSchema.schema.name,
|
|
11453
|
-
cardinality: "one"
|
|
11454
|
-
}));
|
|
11455
|
-
}
|
|
11456
|
-
|
|
11457
11468
|
// ../zql/src/query/escape-like.ts
|
|
11458
11469
|
function escapeLike(val) {
|
|
11459
11470
|
return val.replace(/[%_]/g, "\\$&");
|
|
@@ -11474,6 +11485,8 @@ var InvalidMessage = "InvalidMessage";
|
|
|
11474
11485
|
var InvalidPush = "InvalidPush";
|
|
11475
11486
|
var MutationFailed = "MutationFailed";
|
|
11476
11487
|
var MutationRateLimited = "MutationRateLimited";
|
|
11488
|
+
var Rebalance = "Rebalance";
|
|
11489
|
+
var Rehome = "Rehome";
|
|
11477
11490
|
var Unauthorized = "Unauthorized";
|
|
11478
11491
|
var VersionNotSupported = "VersionNotSupported";
|
|
11479
11492
|
var SchemaVersionNotSupported = "SchemaVersionNotSupported";
|
|
@@ -11545,7 +11558,7 @@ function encodeSecProtocols(initConnectionMessage, authToken) {
|
|
|
11545
11558
|
}
|
|
11546
11559
|
|
|
11547
11560
|
// ../zero-protocol/src/error.ts
|
|
11548
|
-
var
|
|
11561
|
+
var basicErrorKindSchema = valita_exports.union(
|
|
11549
11562
|
valita_exports.literal(AuthInvalidated),
|
|
11550
11563
|
valita_exports.literal(ClientNotFound),
|
|
11551
11564
|
valita_exports.literal(InvalidConnectionRequest),
|
|
@@ -11562,18 +11575,29 @@ var errorKindSchema = valita_exports.union(
|
|
|
11562
11575
|
valita_exports.literal(Internal)
|
|
11563
11576
|
);
|
|
11564
11577
|
var basicErrorBodySchema = valita_exports.object({
|
|
11565
|
-
kind:
|
|
11578
|
+
kind: basicErrorKindSchema,
|
|
11566
11579
|
message: valita_exports.string()
|
|
11567
11580
|
});
|
|
11568
|
-
var
|
|
11569
|
-
|
|
11581
|
+
var backoffErrorKindSchema = valita_exports.union(
|
|
11582
|
+
valita_exports.literal(Rebalance),
|
|
11583
|
+
valita_exports.literal(Rehome),
|
|
11584
|
+
valita_exports.literal(ServerOverloaded)
|
|
11585
|
+
);
|
|
11586
|
+
var backoffBodySchema = valita_exports.object({
|
|
11587
|
+
kind: backoffErrorKindSchema,
|
|
11570
11588
|
message: valita_exports.string(),
|
|
11571
|
-
minBackoffMs: valita_exports.number().optional()
|
|
11589
|
+
minBackoffMs: valita_exports.number().optional(),
|
|
11590
|
+
maxBackoffMs: valita_exports.number().optional(),
|
|
11591
|
+
// Query parameters to send in the next reconnect. In the event of
|
|
11592
|
+
// a conflict, these will be overridden by the parameters used by
|
|
11593
|
+
// the client; it is the responsibility of the server to avoid
|
|
11594
|
+
// parameter name conflicts.
|
|
11595
|
+
//
|
|
11596
|
+
// The parameters will only be added to the immediately following
|
|
11597
|
+
// reconnect, and not after that.
|
|
11598
|
+
reconnectParams: valita_exports.record(valita_exports.string()).optional()
|
|
11572
11599
|
});
|
|
11573
|
-
var errorBodySchema = valita_exports.union(
|
|
11574
|
-
basicErrorBodySchema,
|
|
11575
|
-
serverOverloadedBodySchema
|
|
11576
|
-
);
|
|
11600
|
+
var errorBodySchema = valita_exports.union(basicErrorBodySchema, backoffBodySchema);
|
|
11577
11601
|
var errorMessageSchema = valita_exports.tuple([
|
|
11578
11602
|
valita_exports.literal("error"),
|
|
11579
11603
|
errorBodySchema
|
|
@@ -11815,7 +11839,7 @@ var upstreamSchema = valita_exports.union(
|
|
|
11815
11839
|
);
|
|
11816
11840
|
|
|
11817
11841
|
// ../zero-protocol/src/protocol-version.ts
|
|
11818
|
-
var PROTOCOL_VERSION =
|
|
11842
|
+
var PROTOCOL_VERSION = 4;
|
|
11819
11843
|
var MIN_SERVER_SUPPORTED_PROTOCOL_VERSION = 2;
|
|
11820
11844
|
assert(MIN_SERVER_SUPPORTED_PROTOCOL_VERSION < PROTOCOL_VERSION);
|
|
11821
11845
|
|
|
@@ -12398,8 +12422,8 @@ var MemorySource = class {
|
|
|
12398
12422
|
compareRows: connection.compareRows
|
|
12399
12423
|
};
|
|
12400
12424
|
}
|
|
12401
|
-
connect(sort,
|
|
12402
|
-
const transformedFilters = transformFilters(
|
|
12425
|
+
connect(sort, filters) {
|
|
12426
|
+
const transformedFilters = transformFilters(filters);
|
|
12403
12427
|
const input = {
|
|
12404
12428
|
getSchema: () => schema,
|
|
12405
12429
|
fetch: (req) => this.#fetch(req, connection),
|
|
@@ -12410,7 +12434,7 @@ var MemorySource = class {
|
|
|
12410
12434
|
destroy: () => {
|
|
12411
12435
|
this.#disconnect(input);
|
|
12412
12436
|
},
|
|
12413
|
-
|
|
12437
|
+
fullyAppliedFilters: !transformedFilters.conditionsRemoved
|
|
12414
12438
|
};
|
|
12415
12439
|
const connection = {
|
|
12416
12440
|
input,
|
|
@@ -12572,10 +12596,13 @@ var MemorySource = class {
|
|
|
12572
12596
|
relationships: {}
|
|
12573
12597
|
}
|
|
12574
12598
|
};
|
|
12575
|
-
for (const [
|
|
12599
|
+
for (const [
|
|
12600
|
+
outputIndex,
|
|
12601
|
+
{ output, filters }
|
|
12602
|
+
] of this.#connections.entries()) {
|
|
12576
12603
|
if (output) {
|
|
12577
12604
|
this.#overlay = { outputIndex, change };
|
|
12578
|
-
|
|
12605
|
+
filterPush(outputChange, output, filters?.predicate);
|
|
12579
12606
|
yield;
|
|
12580
12607
|
}
|
|
12581
12608
|
}
|
|
@@ -13179,7 +13206,7 @@ import {
|
|
|
13179
13206
|
} from "@rocicorp/logger";
|
|
13180
13207
|
|
|
13181
13208
|
// ../datadog/src/datadog-log-sink.ts
|
|
13182
|
-
import { Lock as
|
|
13209
|
+
import { Lock as Lock3 } from "@rocicorp/lock";
|
|
13183
13210
|
var DD_BASE_URL = new URL(
|
|
13184
13211
|
"https://http-intake.logs.datadoghq.com/api/v2/logs"
|
|
13185
13212
|
);
|
|
@@ -13198,7 +13225,7 @@ var DatadogLogSink = class {
|
|
|
13198
13225
|
#interval;
|
|
13199
13226
|
#baseURL;
|
|
13200
13227
|
#timerID = 0;
|
|
13201
|
-
#flushLock = new
|
|
13228
|
+
#flushLock = new Lock3();
|
|
13202
13229
|
constructor(options) {
|
|
13203
13230
|
const {
|
|
13204
13231
|
apiKey,
|
|
@@ -13397,7 +13424,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
13397
13424
|
}
|
|
13398
13425
|
|
|
13399
13426
|
// ../zero-client/src/client/version.ts
|
|
13400
|
-
var version2 = "0.11.
|
|
13427
|
+
var version2 = "0.11.2025012400+d6c57e";
|
|
13401
13428
|
|
|
13402
13429
|
// ../zero-client/src/client/log-options.ts
|
|
13403
13430
|
var LevelFilterLogSink = class {
|
|
@@ -13951,8 +13978,16 @@ function isAuthError(ex) {
|
|
|
13951
13978
|
function isAuthErrorKind(kind) {
|
|
13952
13979
|
return kind === AuthInvalidated || kind === Unauthorized;
|
|
13953
13980
|
}
|
|
13954
|
-
function
|
|
13955
|
-
|
|
13981
|
+
function isBackoffError(ex) {
|
|
13982
|
+
if (isServerError(ex)) {
|
|
13983
|
+
switch (ex.errorBody.kind) {
|
|
13984
|
+
case Rebalance:
|
|
13985
|
+
case Rehome:
|
|
13986
|
+
case ServerOverloaded:
|
|
13987
|
+
return ex.errorBody;
|
|
13988
|
+
}
|
|
13989
|
+
}
|
|
13990
|
+
return void 0;
|
|
13956
13991
|
}
|
|
13957
13992
|
|
|
13958
13993
|
// ../zero-client/src/client/server-option.ts
|
|
@@ -14017,7 +14052,7 @@ function getServer(server) {
|
|
|
14017
14052
|
}
|
|
14018
14053
|
|
|
14019
14054
|
// ../zero-client/src/client/zero-poke-handler.ts
|
|
14020
|
-
import { Lock as
|
|
14055
|
+
import { Lock as Lock4 } from "@rocicorp/lock";
|
|
14021
14056
|
var PokeHandler = class {
|
|
14022
14057
|
#replicachePoke;
|
|
14023
14058
|
#onPokeError;
|
|
@@ -14029,7 +14064,7 @@ var PokeHandler = class {
|
|
|
14029
14064
|
#lastRafPerfTimestamp = 0;
|
|
14030
14065
|
// Serializes calls to this.#replicachePoke otherwise we can cause out of
|
|
14031
14066
|
// order poke errors.
|
|
14032
|
-
#pokeLock = new
|
|
14067
|
+
#pokeLock = new Lock4();
|
|
14033
14068
|
#schema;
|
|
14034
14069
|
#raf = getBrowserGlobalMethod("requestAnimationFrame") ?? rafFallback;
|
|
14035
14070
|
constructor(replicachePoke, onPokeError, clientID, schema, lc) {
|
|
@@ -14860,7 +14895,7 @@ var Zero = class {
|
|
|
14860
14895
|
* is received before the connected message is received or if the connection
|
|
14861
14896
|
* attempt times out.
|
|
14862
14897
|
*/
|
|
14863
|
-
async #connect(l) {
|
|
14898
|
+
async #connect(l, additionalConnectParams) {
|
|
14864
14899
|
assert(this.#server);
|
|
14865
14900
|
assert(this.#connectionState === Disconnected);
|
|
14866
14901
|
const wsid = nanoid();
|
|
@@ -14908,7 +14943,8 @@ var Zero = class {
|
|
|
14908
14943
|
wsid,
|
|
14909
14944
|
this.#options.logLevel === "debug",
|
|
14910
14945
|
l,
|
|
14911
|
-
this.#options.maxHeaderLength
|
|
14946
|
+
this.#options.maxHeaderLength,
|
|
14947
|
+
additionalConnectParams
|
|
14912
14948
|
);
|
|
14913
14949
|
if (this.closed) {
|
|
14914
14950
|
return;
|
|
@@ -15119,6 +15155,7 @@ var Zero = class {
|
|
|
15119
15155
|
let needsReauth = false;
|
|
15120
15156
|
let gotError = false;
|
|
15121
15157
|
let backoffMs = RUN_LOOP_INTERVAL_MS;
|
|
15158
|
+
let additionalConnectParams;
|
|
15122
15159
|
while (!this.closed) {
|
|
15123
15160
|
runLoopCounter++;
|
|
15124
15161
|
let lc = getLogContext();
|
|
@@ -15137,7 +15174,8 @@ var Zero = class {
|
|
|
15137
15174
|
if (reloadScheduled()) {
|
|
15138
15175
|
break;
|
|
15139
15176
|
}
|
|
15140
|
-
await this.#connect(lc);
|
|
15177
|
+
await this.#connect(lc, additionalConnectParams);
|
|
15178
|
+
additionalConnectParams = void 0;
|
|
15141
15179
|
if (this.closed) {
|
|
15142
15180
|
break;
|
|
15143
15181
|
}
|
|
@@ -15219,9 +15257,15 @@ var Zero = class {
|
|
|
15219
15257
|
if (isServerError(ex) || ex instanceof TimedOutError || ex instanceof CloseError) {
|
|
15220
15258
|
gotError = true;
|
|
15221
15259
|
}
|
|
15222
|
-
const
|
|
15223
|
-
if (
|
|
15224
|
-
|
|
15260
|
+
const backoffError = isBackoffError(ex);
|
|
15261
|
+
if (backoffError) {
|
|
15262
|
+
if (backoffError.minBackoffMs !== void 0) {
|
|
15263
|
+
backoffMs = Math.max(backoffMs, backoffError.minBackoffMs);
|
|
15264
|
+
}
|
|
15265
|
+
if (backoffError.maxBackoffMs !== void 0) {
|
|
15266
|
+
backoffMs = Math.min(backoffMs, backoffError.maxBackoffMs);
|
|
15267
|
+
}
|
|
15268
|
+
additionalConnectParams = backoffError.reconnectParams;
|
|
15225
15269
|
}
|
|
15226
15270
|
}
|
|
15227
15271
|
if (gotError) {
|
|
@@ -15361,7 +15405,7 @@ var Zero = class {
|
|
|
15361
15405
|
return rv;
|
|
15362
15406
|
}
|
|
15363
15407
|
};
|
|
15364
|
-
async function createSocket(rep, queryManager, socketOrigin, baseCookie, clientID, clientGroupID, schemaVersion, userID, auth, lmid, wsid, debugPerf, lc, maxHeaderLength = 1024 * 8) {
|
|
15408
|
+
async function createSocket(rep, queryManager, socketOrigin, baseCookie, clientID, clientGroupID, schemaVersion, userID, auth, lmid, wsid, debugPerf, lc, maxHeaderLength = 1024 * 8, additionalConnectParams) {
|
|
15365
15409
|
const url = new URL(
|
|
15366
15410
|
appendPath(socketOrigin, `/sync/v${PROTOCOL_VERSION}/connect`)
|
|
15367
15411
|
);
|
|
@@ -15377,6 +15421,15 @@ async function createSocket(rep, queryManager, socketOrigin, baseCookie, clientI
|
|
|
15377
15421
|
if (debugPerf) {
|
|
15378
15422
|
searchParams.set("debugPerf", true.toString());
|
|
15379
15423
|
}
|
|
15424
|
+
if (additionalConnectParams) {
|
|
15425
|
+
for (const k in additionalConnectParams) {
|
|
15426
|
+
if (searchParams.has(k)) {
|
|
15427
|
+
lc.warn?.(`skipping conflicting parameter ${k}`);
|
|
15428
|
+
} else {
|
|
15429
|
+
searchParams.set(k, additionalConnectParams[k]);
|
|
15430
|
+
}
|
|
15431
|
+
}
|
|
15432
|
+
}
|
|
15380
15433
|
lc.info?.("Connecting to", url.toString());
|
|
15381
15434
|
const WS = mustGetBrowserGlobal("WebSocket");
|
|
15382
15435
|
let queriesPatch = await rep.query(
|
|
@@ -15424,18 +15477,18 @@ export {
|
|
|
15424
15477
|
makeIDBName,
|
|
15425
15478
|
dropDatabase,
|
|
15426
15479
|
dropAllDatabases,
|
|
15427
|
-
|
|
15428
|
-
NOBODY_CAN,
|
|
15429
|
-
definePermissions,
|
|
15480
|
+
relationships,
|
|
15430
15481
|
table,
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15482
|
+
string7 as string,
|
|
15483
|
+
number4 as number,
|
|
15484
|
+
boolean3 as boolean,
|
|
15434
15485
|
json,
|
|
15435
15486
|
enumeration,
|
|
15436
15487
|
createSchema,
|
|
15437
|
-
|
|
15488
|
+
ANYONE_CAN,
|
|
15489
|
+
NOBODY_CAN,
|
|
15490
|
+
definePermissions,
|
|
15438
15491
|
escapeLike,
|
|
15439
15492
|
Zero
|
|
15440
15493
|
};
|
|
15441
|
-
//# sourceMappingURL=chunk-
|
|
15494
|
+
//# sourceMappingURL=chunk-N57WXYAL.js.map
|