@rocicorp/zero 0.11.2025011801 → 0.11.2025012200

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.
Files changed (104) hide show
  1. package/out/{chunk-QV5ZN4MA.js → chunk-5OVHF6ZM.js} +250 -235
  2. package/out/chunk-5OVHF6ZM.js.map +7 -0
  3. package/out/datadog/src/datadog-log-sink.d.ts.map +1 -1
  4. package/out/react.js +36 -10
  5. package/out/react.js.map +2 -2
  6. package/out/replicache/src/replicache-impl.d.ts.map +1 -1
  7. package/out/replicache/src/sync/pull.d.ts.map +1 -1
  8. package/out/shared/src/custom-key-set.d.ts +25 -0
  9. package/out/shared/src/custom-key-set.d.ts.map +1 -0
  10. package/out/shared/src/custom-key-set.js +58 -0
  11. package/out/shared/src/custom-key-set.js.map +1 -0
  12. package/out/solid.js +1 -1
  13. package/out/zero/src/zero-cache-dev.d.ts.map +1 -1
  14. package/out/zero/src/zero-cache-dev.js +10 -0
  15. package/out/zero/src/zero-cache-dev.js.map +1 -1
  16. package/out/zero-cache/src/db/create.js +1 -1
  17. package/out/zero-cache/src/db/create.js.map +1 -1
  18. package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
  19. package/out/zero-cache/src/db/lite-tables.js +8 -10
  20. package/out/zero-cache/src/db/lite-tables.js.map +1 -1
  21. package/out/zero-cache/src/db/pg-to-lite.d.ts +2 -1
  22. package/out/zero-cache/src/db/pg-to-lite.d.ts.map +1 -1
  23. package/out/zero-cache/src/db/pg-to-lite.js +6 -8
  24. package/out/zero-cache/src/db/pg-to-lite.js.map +1 -1
  25. package/out/zero-cache/src/db/specs.d.ts +2 -1
  26. package/out/zero-cache/src/db/specs.d.ts.map +1 -1
  27. package/out/zero-cache/src/db/specs.js.map +1 -1
  28. package/out/zero-cache/src/server/life-cycle.d.ts.map +1 -1
  29. package/out/zero-cache/src/server/life-cycle.js +2 -0
  30. package/out/zero-cache/src/server/life-cycle.js.map +1 -1
  31. package/out/zero-cache/src/server/logging.js +1 -0
  32. package/out/zero-cache/src/server/logging.js.map +1 -1
  33. package/out/zero-cache/src/server/main.d.ts.map +1 -1
  34. package/out/zero-cache/src/server/main.js +4 -2
  35. package/out/zero-cache/src/server/main.js.map +1 -1
  36. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
  37. package/out/zero-cache/src/services/change-source/pg/change-source.js +21 -4
  38. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  39. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +4 -0
  40. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
  41. package/out/zero-cache/src/services/change-source/pg/schema/shard.js +16 -5
  42. package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
  43. package/out/zero-cache/src/services/change-source/pg/sync-schema.js +3 -3
  44. package/out/zero-cache/src/services/change-source/pg/sync-schema.js.map +1 -1
  45. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +16 -1
  46. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
  47. package/out/zero-cache/src/services/view-syncer/cvr-store.js +73 -26
  48. package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
  49. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +2 -2
  50. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  51. package/out/zero-cache/src/services/view-syncer/cvr.js +24 -4
  52. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  53. package/out/zero-cache/src/services/view-syncer/key-columns.d.ts +32 -0
  54. package/out/zero-cache/src/services/view-syncer/key-columns.d.ts.map +1 -0
  55. package/out/zero-cache/src/services/view-syncer/key-columns.js +73 -0
  56. package/out/zero-cache/src/services/view-syncer/key-columns.js.map +1 -0
  57. package/out/zero-cache/src/types/lite.d.ts +27 -8
  58. package/out/zero-cache/src/types/lite.d.ts.map +1 -1
  59. package/out/zero-cache/src/types/lite.js +24 -12
  60. package/out/zero-cache/src/types/lite.js.map +1 -1
  61. package/out/zero-cache/src/types/processes.d.ts.map +1 -1
  62. package/out/zero-cache/src/types/processes.js +0 -4
  63. package/out/zero-cache/src/types/processes.js.map +1 -1
  64. package/out/zero-client/src/client/server-option.d.ts.map +1 -1
  65. package/out/zero-client/src/mod.d.ts +6 -3
  66. package/out/zero-client/src/mod.d.ts.map +1 -1
  67. package/out/zero-protocol/src/ast.d.ts +5 -7
  68. package/out/zero-protocol/src/ast.d.ts.map +1 -1
  69. package/out/zero-protocol/src/ast.js.map +1 -1
  70. package/out/zero-react/src/use-query.d.ts +60 -3
  71. package/out/zero-react/src/use-query.d.ts.map +1 -1
  72. package/out/zero-schema/src/builder/schema-builder.d.ts +10 -3
  73. package/out/zero-schema/src/builder/schema-builder.d.ts.map +1 -1
  74. package/out/zero-schema/src/builder/schema-builder.js +11 -5
  75. package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
  76. package/out/zero-schema/src/permissions.d.ts +4 -5
  77. package/out/zero-schema/src/permissions.d.ts.map +1 -1
  78. package/out/zero.js +1 -1
  79. package/out/zql/src/builder/builder.d.ts +1 -1
  80. package/out/zql/src/builder/builder.d.ts.map +1 -1
  81. package/out/zql/src/builder/builder.js +18 -25
  82. package/out/zql/src/builder/builder.js.map +1 -1
  83. package/out/zql/src/ivm/filter-push.d.ts +5 -0
  84. package/out/zql/src/ivm/filter-push.d.ts.map +1 -0
  85. package/out/zql/src/ivm/filter-push.js +27 -0
  86. package/out/zql/src/ivm/filter-push.js.map +1 -0
  87. package/out/zql/src/ivm/filter.d.ts +1 -7
  88. package/out/zql/src/ivm/filter.d.ts.map +1 -1
  89. package/out/zql/src/ivm/filter.js +4 -24
  90. package/out/zql/src/ivm/filter.js.map +1 -1
  91. package/out/zql/src/ivm/memory-source.d.ts +1 -1
  92. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  93. package/out/zql/src/ivm/memory-source.js +6 -5
  94. package/out/zql/src/ivm/memory-source.js.map +1 -1
  95. package/out/zql/src/ivm/source.d.ts +3 -3
  96. package/out/zql/src/ivm/source.d.ts.map +1 -1
  97. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  98. package/out/zql/src/query/query-impl.js.map +1 -1
  99. package/out/zqlite/src/table-source.d.ts +8 -7
  100. package/out/zqlite/src/table-source.d.ts.map +1 -1
  101. package/out/zqlite/src/table-source.js +36 -20
  102. package/out/zqlite/src/table-source.js.map +1 -1
  103. package/package.json +2 -2
  104. package/out/chunk-QV5ZN4MA.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
@@ -7254,7 +7254,7 @@ var ReplicacheImpl = class {
7254
7254
  #idbDatabases;
7255
7255
  #lc;
7256
7256
  #closeAbortController = new AbortController();
7257
- #persistIsRunning = false;
7257
+ #persistLock = new Lock2();
7258
7258
  #enableScheduledPersist;
7259
7259
  #enableScheduledRefresh;
7260
7260
  #enablePullAndPushInOpen;
@@ -7946,11 +7946,9 @@ var ReplicacheImpl = class {
7946
7946
  const { syncHead, httpRequestInfo } = beginPullResponse;
7947
7947
  return { requestID, syncHead, ok: httpRequestInfo.httpStatusCode === 200 };
7948
7948
  }
7949
- async persist() {
7950
- assert(!this.#persistIsRunning);
7951
- this.#persistIsRunning = true;
7952
- try {
7953
- const { clientID: clientID2 } = this;
7949
+ persist() {
7950
+ return this.#persistLock.withLock(async () => {
7951
+ const { clientID } = this;
7954
7952
  await this.#ready;
7955
7953
  if (this.#closed) {
7956
7954
  return;
@@ -7958,29 +7956,26 @@ var ReplicacheImpl = class {
7958
7956
  try {
7959
7957
  await persistDD31(
7960
7958
  this.#lc,
7961
- clientID2,
7959
+ clientID,
7962
7960
  this.memdag,
7963
7961
  this.perdag,
7964
7962
  this.#mutatorRegistry,
7965
- () => this.closed,
7963
+ () => this.#closed,
7966
7964
  Latest
7967
7965
  );
7968
7966
  } catch (e) {
7969
7967
  if (e instanceof ClientStateNotFoundError) {
7970
- this.#clientStateNotFoundOnClient(clientID2);
7968
+ this.#clientStateNotFoundOnClient(clientID);
7971
7969
  } else if (this.#closed) {
7972
7970
  this.#lc.debug?.("Exception persisting during close", e);
7973
7971
  } else {
7974
7972
  throw e;
7975
7973
  }
7976
7974
  }
7977
- } finally {
7978
- this.#persistIsRunning = false;
7979
- }
7980
- const { clientID } = this;
7981
- const clientGroupID = await this.#clientGroupIDPromise;
7982
- assert(clientGroupID);
7983
- this.#onPersist({ clientID, clientGroupID });
7975
+ const clientGroupID = await this.#clientGroupIDPromise;
7976
+ assert(clientGroupID);
7977
+ this.#onPersist({ clientID, clientGroupID });
7978
+ });
7984
7979
  }
7985
7980
  async refresh() {
7986
7981
  await this.#ready;
@@ -8320,6 +8315,176 @@ function getKVStoreProvider(lc, kvStore) {
8320
8315
  // ../replicache/src/mod.ts
8321
8316
  import { consoleLogSink as consoleLogSink3 } from "@rocicorp/logger";
8322
8317
 
8318
+ // ../zero-schema/src/builder/relationship-builder.ts
8319
+ function relationships(table2, cb) {
8320
+ const relationships2 = cb({ many, one });
8321
+ return {
8322
+ name: table2.schema.name,
8323
+ relationships: relationships2
8324
+ };
8325
+ }
8326
+ function many(...args) {
8327
+ return args.map((arg) => ({
8328
+ sourceField: arg.sourceField,
8329
+ destField: arg.destField,
8330
+ destSchema: arg.destSchema.schema.name,
8331
+ cardinality: "many"
8332
+ }));
8333
+ }
8334
+ function one(...args) {
8335
+ return args.map((arg) => ({
8336
+ sourceField: arg.sourceField,
8337
+ destField: arg.destField,
8338
+ destSchema: arg.destSchema.schema.name,
8339
+ cardinality: "one"
8340
+ }));
8341
+ }
8342
+
8343
+ // ../zero-schema/src/builder/table-builder.ts
8344
+ function table(name) {
8345
+ return new TableBuilder({
8346
+ name,
8347
+ columns: {},
8348
+ primaryKey: []
8349
+ });
8350
+ }
8351
+ function string7() {
8352
+ return new ColumnBuilder({
8353
+ type: "string",
8354
+ optional: false,
8355
+ customType: null
8356
+ });
8357
+ }
8358
+ function number4() {
8359
+ return new ColumnBuilder({
8360
+ type: "number",
8361
+ optional: false,
8362
+ customType: null
8363
+ });
8364
+ }
8365
+ function boolean3() {
8366
+ return new ColumnBuilder({
8367
+ type: "boolean",
8368
+ optional: false,
8369
+ customType: null
8370
+ });
8371
+ }
8372
+ function json() {
8373
+ return new ColumnBuilder({
8374
+ type: "json",
8375
+ optional: false,
8376
+ customType: null
8377
+ });
8378
+ }
8379
+ function enumeration() {
8380
+ return new ColumnBuilder({
8381
+ type: "string",
8382
+ optional: false,
8383
+ customType: null
8384
+ });
8385
+ }
8386
+ var TableBuilder = class {
8387
+ #schema;
8388
+ constructor(schema) {
8389
+ this.#schema = schema;
8390
+ }
8391
+ columns(columns) {
8392
+ const columnSchemas = Object.fromEntries(
8393
+ Object.entries(columns).map(([k, v2]) => [k, v2.schema])
8394
+ );
8395
+ return new TableBuilderWithColumns({
8396
+ ...this.#schema,
8397
+ columns: columnSchemas
8398
+ });
8399
+ }
8400
+ };
8401
+ var TableBuilderWithColumns = class _TableBuilderWithColumns {
8402
+ #schema;
8403
+ constructor(schema) {
8404
+ this.#schema = schema;
8405
+ }
8406
+ primaryKey(...pkColumnNames) {
8407
+ return new _TableBuilderWithColumns({
8408
+ ...this.#schema,
8409
+ primaryKey: pkColumnNames
8410
+ });
8411
+ }
8412
+ get schema() {
8413
+ return this.#schema;
8414
+ }
8415
+ build() {
8416
+ if (this.#schema.primaryKey.length === 0) {
8417
+ throw new Error(`Table "${this.#schema.name}" is missing a primary key`);
8418
+ }
8419
+ return this.#schema;
8420
+ }
8421
+ };
8422
+ var ColumnBuilder = class _ColumnBuilder {
8423
+ #schema;
8424
+ constructor(schema) {
8425
+ this.#schema = schema;
8426
+ }
8427
+ optional() {
8428
+ return new _ColumnBuilder({
8429
+ ...this.#schema,
8430
+ optional: true
8431
+ });
8432
+ }
8433
+ get schema() {
8434
+ return this.#schema;
8435
+ }
8436
+ };
8437
+
8438
+ // ../zero-schema/src/builder/schema-builder.ts
8439
+ function createSchema(version3, options) {
8440
+ const retTables = {};
8441
+ const retRelationships = {};
8442
+ options.tables.forEach((table2) => {
8443
+ if (retTables[table2.schema.name]) {
8444
+ throw new Error(
8445
+ `Table "${table2.schema.name}" is defined more than once in the schema`
8446
+ );
8447
+ }
8448
+ retTables[table2.schema.name] = table2.build();
8449
+ });
8450
+ options.relationships?.forEach((relationships2) => {
8451
+ if (retRelationships[relationships2.name]) {
8452
+ throw new Error(
8453
+ `Relationships for table "${relationships2.name}" are defined more than once in the schema`
8454
+ );
8455
+ }
8456
+ retRelationships[relationships2.name] = relationships2.relationships;
8457
+ checkRelationship(
8458
+ relationships2.relationships,
8459
+ relationships2.name,
8460
+ retTables
8461
+ );
8462
+ });
8463
+ return {
8464
+ version: version3,
8465
+ tables: retTables,
8466
+ relationships: retRelationships
8467
+ };
8468
+ }
8469
+ function checkRelationship(relationships2, tableName, tables) {
8470
+ Object.entries(relationships2).forEach(([name, rel]) => {
8471
+ let source = tables[tableName];
8472
+ rel.forEach((connection) => {
8473
+ if (!tables[connection.destSchema]) {
8474
+ throw new Error(
8475
+ `For relationship "${tableName}"."${name}", destination table "${connection.destSchema}" is missing in the schema`
8476
+ );
8477
+ }
8478
+ if (!source.columns[connection.sourceField[0]]) {
8479
+ throw new Error(
8480
+ `For relationship "${tableName}"."${name}", the source field "${connection.sourceField[0]}" is missing in the table schema "${source.name}"`
8481
+ );
8482
+ }
8483
+ source = tables[connection.destSchema];
8484
+ });
8485
+ });
8486
+ }
8487
+
8323
8488
  // ../zero-protocol/src/ast.ts
8324
8489
  import { compareUTF8 as compareUTF83 } from "compare-utf8";
8325
8490
 
@@ -9207,15 +9372,39 @@ function maybeSplitAndPushEditChange(change, predicate, output) {
9207
9372
  }
9208
9373
  }
9209
9374
 
9375
+ // ../zql/src/ivm/filter-push.ts
9376
+ function filterPush(change, output, predicate) {
9377
+ if (!predicate) {
9378
+ output.push(change);
9379
+ return;
9380
+ }
9381
+ switch (change.type) {
9382
+ case "add":
9383
+ case "remove":
9384
+ if (predicate(change.node.row)) {
9385
+ output.push(change);
9386
+ }
9387
+ break;
9388
+ case "child":
9389
+ if (predicate(change.row)) {
9390
+ output.push(change);
9391
+ }
9392
+ break;
9393
+ case "edit":
9394
+ maybeSplitAndPushEditChange(change, predicate, output);
9395
+ break;
9396
+ default:
9397
+ unreachable(change);
9398
+ }
9399
+ }
9400
+
9210
9401
  // ../zql/src/ivm/filter.ts
9211
9402
  var Filter = class {
9212
9403
  #input;
9213
- #mode;
9214
9404
  #predicate;
9215
9405
  #output = throwOutput;
9216
- constructor(input, mode, predicate) {
9406
+ constructor(input, predicate) {
9217
9407
  this.#input = input;
9218
- this.#mode = mode;
9219
9408
  this.#predicate = predicate;
9220
9409
  input.setOutput(this);
9221
9410
  }
@@ -9236,30 +9425,13 @@ var Filter = class {
9236
9425
  }
9237
9426
  *#filter(stream) {
9238
9427
  for (const node of stream) {
9239
- if (this.#mode === "push-only" || this.#predicate(node.row)) {
9428
+ if (this.#predicate(node.row)) {
9240
9429
  yield node;
9241
9430
  }
9242
9431
  }
9243
9432
  }
9244
9433
  push(change) {
9245
- switch (change.type) {
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
- }
9434
+ filterPush(change, this.#output, this.#predicate);
9263
9435
  }
9264
9436
  };
9265
9437
 
@@ -10315,7 +10487,7 @@ function buildPipelineInternal(ast, delegate, partitionKey) {
10315
10487
  }
10316
10488
  const conn = source.connect(must(ast.orderBy), ast.where);
10317
10489
  let end = conn;
10318
- const { appliedFilters } = conn;
10490
+ const { fullyAppliedFilters } = conn;
10319
10491
  ast = uniquifyCorrelatedSubqueryConditionAliases(ast);
10320
10492
  if (ast.start) {
10321
10493
  end = new Skip(end, ast.start);
@@ -10323,8 +10495,8 @@ function buildPipelineInternal(ast, delegate, partitionKey) {
10323
10495
  for (const csq of gatherCorrelatedSubqueryQueriesFromCondition(ast.where)) {
10324
10496
  end = applyCorrelatedSubQuery(csq, delegate, end);
10325
10497
  }
10326
- if (ast.where) {
10327
- end = applyWhere(end, ast.where, appliedFilters, delegate);
10498
+ if (ast.where && !fullyAppliedFilters) {
10499
+ end = applyWhere(end, ast.where, delegate);
10328
10500
  }
10329
10501
  if (ast.limit) {
10330
10502
  end = new Take(end, delegate.createStorage(), ast.limit, partitionKey);
@@ -10336,45 +10508,43 @@ function buildPipelineInternal(ast, delegate, partitionKey) {
10336
10508
  }
10337
10509
  return end;
10338
10510
  }
10339
- function applyWhere(input, condition, appliedFilters, delegate) {
10511
+ function applyWhere(input, condition, delegate) {
10340
10512
  switch (condition.type) {
10341
10513
  case "and":
10342
- return applyAnd(input, condition, appliedFilters, delegate);
10514
+ return applyAnd(input, condition, delegate);
10343
10515
  case "or":
10344
- return applyOr(input, condition, appliedFilters, delegate);
10516
+ return applyOr(input, condition, delegate);
10345
10517
  case "correlatedSubquery":
10346
10518
  return applyCorrelatedSubqueryCondition(input, condition, delegate);
10347
10519
  case "simple":
10348
- return applySimpleCondition(input, condition, appliedFilters);
10520
+ return applySimpleCondition(input, condition);
10349
10521
  }
10350
10522
  }
10351
- function applyAnd(input, condition, appliedFilters, delegate) {
10523
+ function applyAnd(input, condition, delegate) {
10352
10524
  for (const subCondition of condition.conditions) {
10353
- input = applyWhere(input, subCondition, appliedFilters, delegate);
10525
+ input = applyWhere(input, subCondition, delegate);
10354
10526
  }
10355
10527
  return input;
10356
10528
  }
10357
- function applyOr(input, condition, appliedFilters, delegate) {
10529
+ function applyOr(input, condition, delegate) {
10358
10530
  const [subqueryConditions, otherConditions] = groupSubqueryConditions(condition);
10359
10531
  if (subqueryConditions.length === 0) {
10360
- return otherConditions.length > 0 ? new Filter(
10532
+ return new Filter(
10361
10533
  input,
10362
- appliedFilters ? "push-only" : "all",
10363
10534
  createPredicate({
10364
10535
  type: "or",
10365
10536
  conditions: otherConditions
10366
10537
  })
10367
- ) : new FanIn(new FanOut(input), []);
10538
+ );
10368
10539
  }
10369
10540
  const fanOut = new FanOut(input);
10370
10541
  const branches = subqueryConditions.map(
10371
- (subCondition) => applyWhere(fanOut, subCondition, appliedFilters, delegate)
10542
+ (subCondition) => applyWhere(fanOut, subCondition, delegate)
10372
10543
  );
10373
10544
  if (otherConditions.length > 0) {
10374
10545
  branches.push(
10375
10546
  new Filter(
10376
10547
  fanOut,
10377
- appliedFilters ? "push-only" : "all",
10378
10548
  createPredicate({
10379
10549
  type: "or",
10380
10550
  conditions: otherConditions
@@ -10405,12 +10575,8 @@ function isNotAndDoesNotContainSubquery(condition) {
10405
10575
  assert(condition.type !== "or", "where conditions are expected to be in DNF");
10406
10576
  return true;
10407
10577
  }
10408
- function applySimpleCondition(input, condition, appliedFilters) {
10409
- return new Filter(
10410
- input,
10411
- appliedFilters ? "push-only" : "all",
10412
- createPredicate(condition)
10413
- );
10578
+ function applySimpleCondition(input, condition) {
10579
+ return new Filter(input, createPredicate(condition));
10414
10580
  }
10415
10581
  function applyCorrelatedSubQuery(sq, delegate, end) {
10416
10582
  assert(sq.subquery.alias, "Subquery must have an alias");
@@ -10871,7 +11037,9 @@ var AbstractQuery = class {
10871
11037
  where(fieldOrExpressionFactory, opOrValue, value) {
10872
11038
  let cond;
10873
11039
  if (typeof fieldOrExpressionFactory === "function") {
10874
- cond = fieldOrExpressionFactory(new ExpressionBuilder(this._exists));
11040
+ cond = fieldOrExpressionFactory(
11041
+ new ExpressionBuilder(this._exists)
11042
+ );
10875
11043
  } else {
10876
11044
  assert(opOrValue !== void 0, "Invalid condition");
10877
11045
  cond = cmp(fieldOrExpressionFactory, opOrValue, value);
@@ -11298,162 +11466,6 @@ function baseTracker(anchor) {
11298
11466
  var authDataRef = baseTracker("authData");
11299
11467
  var preMutationRowRef = baseTracker("preMutationRow");
11300
11468
 
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
11469
  // ../zql/src/query/escape-like.ts
11458
11470
  function escapeLike(val) {
11459
11471
  return val.replace(/[%_]/g, "\\$&");
@@ -12398,8 +12410,8 @@ var MemorySource = class {
12398
12410
  compareRows: connection.compareRows
12399
12411
  };
12400
12412
  }
12401
- connect(sort, optionalFilters) {
12402
- const transformedFilters = transformFilters(optionalFilters);
12413
+ connect(sort, filters) {
12414
+ const transformedFilters = transformFilters(filters);
12403
12415
  const input = {
12404
12416
  getSchema: () => schema,
12405
12417
  fetch: (req) => this.#fetch(req, connection),
@@ -12410,7 +12422,7 @@ var MemorySource = class {
12410
12422
  destroy: () => {
12411
12423
  this.#disconnect(input);
12412
12424
  },
12413
- appliedFilters: !transformedFilters.conditionsRemoved
12425
+ fullyAppliedFilters: !transformedFilters.conditionsRemoved
12414
12426
  };
12415
12427
  const connection = {
12416
12428
  input,
@@ -12572,10 +12584,13 @@ var MemorySource = class {
12572
12584
  relationships: {}
12573
12585
  }
12574
12586
  };
12575
- for (const [outputIndex, { output }] of this.#connections.entries()) {
12587
+ for (const [
12588
+ outputIndex,
12589
+ { output, filters }
12590
+ ] of this.#connections.entries()) {
12576
12591
  if (output) {
12577
12592
  this.#overlay = { outputIndex, change };
12578
- output.push(outputChange);
12593
+ filterPush(outputChange, output, filters?.predicate);
12579
12594
  yield;
12580
12595
  }
12581
12596
  }
@@ -13179,7 +13194,7 @@ import {
13179
13194
  } from "@rocicorp/logger";
13180
13195
 
13181
13196
  // ../datadog/src/datadog-log-sink.ts
13182
- import { Lock as Lock2 } from "@rocicorp/lock";
13197
+ import { Lock as Lock3 } from "@rocicorp/lock";
13183
13198
  var DD_BASE_URL = new URL(
13184
13199
  "https://http-intake.logs.datadoghq.com/api/v2/logs"
13185
13200
  );
@@ -13198,7 +13213,7 @@ var DatadogLogSink = class {
13198
13213
  #interval;
13199
13214
  #baseURL;
13200
13215
  #timerID = 0;
13201
- #flushLock = new Lock2();
13216
+ #flushLock = new Lock3();
13202
13217
  constructor(options) {
13203
13218
  const {
13204
13219
  apiKey,
@@ -13397,7 +13412,7 @@ function makeMessage(message, context, logLevel) {
13397
13412
  }
13398
13413
 
13399
13414
  // ../zero-client/src/client/version.ts
13400
- var version2 = "0.11.2025011801+0c3f2d";
13415
+ var version2 = "0.11.2025012200+592c81";
13401
13416
 
13402
13417
  // ../zero-client/src/client/log-options.ts
13403
13418
  var LevelFilterLogSink = class {
@@ -14017,7 +14032,7 @@ function getServer(server) {
14017
14032
  }
14018
14033
 
14019
14034
  // ../zero-client/src/client/zero-poke-handler.ts
14020
- import { Lock as Lock3 } from "@rocicorp/lock";
14035
+ import { Lock as Lock4 } from "@rocicorp/lock";
14021
14036
  var PokeHandler = class {
14022
14037
  #replicachePoke;
14023
14038
  #onPokeError;
@@ -14029,7 +14044,7 @@ var PokeHandler = class {
14029
14044
  #lastRafPerfTimestamp = 0;
14030
14045
  // Serializes calls to this.#replicachePoke otherwise we can cause out of
14031
14046
  // order poke errors.
14032
- #pokeLock = new Lock3();
14047
+ #pokeLock = new Lock4();
14033
14048
  #schema;
14034
14049
  #raf = getBrowserGlobalMethod("requestAnimationFrame") ?? rafFallback;
14035
14050
  constructor(replicachePoke, onPokeError, clientID, schema, lc) {
@@ -15424,18 +15439,18 @@ export {
15424
15439
  makeIDBName,
15425
15440
  dropDatabase,
15426
15441
  dropAllDatabases,
15427
- ANYONE_CAN,
15428
- NOBODY_CAN,
15429
- definePermissions,
15442
+ relationships,
15430
15443
  table,
15431
- string8 as string,
15432
- number5 as number,
15433
- boolean4 as boolean,
15444
+ string7 as string,
15445
+ number4 as number,
15446
+ boolean3 as boolean,
15434
15447
  json,
15435
15448
  enumeration,
15436
15449
  createSchema,
15437
- relationships,
15450
+ ANYONE_CAN,
15451
+ NOBODY_CAN,
15452
+ definePermissions,
15438
15453
  escapeLike,
15439
15454
  Zero
15440
15455
  };
15441
- //# sourceMappingURL=chunk-QV5ZN4MA.js.map
15456
+ //# sourceMappingURL=chunk-5OVHF6ZM.js.map