@rocicorp/zero 0.23.2025081901 → 0.23.2025082300

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 (118) hide show
  1. package/out/{chunk-RPVWLROJ.js → chunk-3I7CRZJP.js} +19 -9
  2. package/out/{chunk-RPVWLROJ.js.map → chunk-3I7CRZJP.js.map} +3 -3
  3. package/out/{chunk-DYTMKRKN.js → chunk-4AQ764RO.js} +55 -36
  4. package/out/chunk-4AQ764RO.js.map +7 -0
  5. package/out/{chunk-ZOMIZNT3.js → chunk-CCP3CHEV.js} +7 -5
  6. package/out/{chunk-ZOMIZNT3.js.map → chunk-CCP3CHEV.js.map} +2 -2
  7. package/out/{inspector-NC47TWFX.js → inspector-UIWB2MYC.js} +33 -45
  8. package/out/inspector-UIWB2MYC.js.map +7 -0
  9. package/out/react.js +5 -4
  10. package/out/react.js.map +2 -2
  11. package/out/shared/src/logging.d.ts.map +1 -1
  12. package/out/shared/src/logging.js +1 -2
  13. package/out/shared/src/logging.js.map +1 -1
  14. package/out/shared/src/types.js +2 -0
  15. package/out/shared/src/types.js.map +1 -0
  16. package/out/solid.js +3 -3
  17. package/out/zero/package.json +1 -1
  18. package/out/zero-cache/src/config/zero-config.d.ts +1 -1
  19. package/out/zero-cache/src/config/zero-config.js +2 -2
  20. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  21. package/out/zero-cache/src/custom/fetch.js +1 -1
  22. package/out/zero-cache/src/custom/fetch.js.map +1 -1
  23. package/out/zero-cache/src/custom-queries/transform-query.js +1 -1
  24. package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
  25. package/out/zero-cache/src/db/specs.d.ts +11 -11
  26. package/out/zero-cache/src/server/anonymous-otel-start.d.ts +1 -0
  27. package/out/zero-cache/src/server/anonymous-otel-start.d.ts.map +1 -1
  28. package/out/zero-cache/src/server/anonymous-otel-start.js +13 -0
  29. package/out/zero-cache/src/server/anonymous-otel-start.js.map +1 -1
  30. package/out/zero-cache/src/server/{inspect-metrics-delegate.d.ts → inspector-delegate.d.ts} +6 -4
  31. package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -0
  32. package/out/zero-cache/src/server/{inspect-metrics-delegate.js → inspector-delegate.js} +18 -6
  33. package/out/zero-cache/src/server/inspector-delegate.js.map +1 -0
  34. package/out/zero-cache/src/server/syncer.js +2 -2
  35. package/out/zero-cache/src/server/syncer.js.map +1 -1
  36. package/out/zero-cache/src/services/change-source/pg/change-source.js +1 -1
  37. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  38. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +20 -20
  39. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +8 -8
  40. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +4 -4
  41. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
  42. package/out/zero-cache/src/services/change-source/pg/schema/shard.js +4 -3
  43. package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
  44. package/out/zero-cache/src/services/change-source/pg/schema/validation.d.ts +2 -2
  45. package/out/zero-cache/src/services/change-source/pg/schema/validation.d.ts.map +1 -1
  46. package/out/zero-cache/src/services/change-source/pg/schema/validation.js +11 -2
  47. package/out/zero-cache/src/services/change-source/pg/schema/validation.js.map +1 -1
  48. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +16 -16
  49. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +24 -24
  50. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +8 -8
  51. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +1 -1
  52. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  53. package/out/zero-cache/src/services/view-syncer/cvr.js +12 -8
  54. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  55. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +2 -2
  56. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  57. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +5 -5
  58. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  59. package/out/zero-cache/src/services/view-syncer/schema/types.d.ts +7 -7
  60. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +3 -3
  61. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  62. package/out/zero-cache/src/services/view-syncer/view-syncer.js +36 -22
  63. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  64. package/out/zero-cache/src/types/pg.d.ts +1 -1
  65. package/out/zero-cache/src/types/pg.d.ts.map +1 -1
  66. package/out/zero-cache/src/types/pg.js +14 -2
  67. package/out/zero-cache/src/types/pg.js.map +1 -1
  68. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  69. package/out/zero-cache/src/workers/syncer.js +2 -1
  70. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  71. package/out/zero-client/src/client/inspector/inspector.d.ts +4 -2
  72. package/out/zero-client/src/client/inspector/inspector.d.ts.map +1 -1
  73. package/out/zero-client/src/client/inspector/types.d.ts +2 -3
  74. package/out/zero-client/src/client/inspector/types.d.ts.map +1 -1
  75. package/out/zero-client/src/client/options.d.ts +14 -0
  76. package/out/zero-client/src/client/options.d.ts.map +1 -1
  77. package/out/zero-client/src/client/query-manager.d.ts +4 -3
  78. package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
  79. package/out/zero-client/src/client/zero.d.ts +6 -1
  80. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  81. package/out/zero-protocol/src/connect.d.ts +1 -1
  82. package/out/zero-protocol/src/connect.js +1 -1
  83. package/out/zero-protocol/src/inspect-down.d.ts.map +1 -1
  84. package/out/zero-protocol/src/inspect-down.js +2 -1
  85. package/out/zero-protocol/src/inspect-down.js.map +1 -1
  86. package/out/zero-react/src/use-query.d.ts.map +1 -1
  87. package/out/zero-server/src/process-mutations.d.ts +2 -2
  88. package/out/zero-server/src/process-mutations.d.ts.map +1 -1
  89. package/out/zero-server/src/process-mutations.js +1 -1
  90. package/out/zero-server/src/process-mutations.js.map +1 -1
  91. package/out/zero-server/src/push-processor.js +3 -3
  92. package/out/zero-server/src/push-processor.js.map +1 -1
  93. package/out/zero-server/src/queries/process-queries.d.ts +2 -1
  94. package/out/zero-server/src/queries/process-queries.d.ts.map +1 -1
  95. package/out/zero-server/src/queries/process-queries.js +1 -1
  96. package/out/zero-server/src/queries/process-queries.js.map +1 -1
  97. package/out/zero.js +3 -3
  98. package/out/zql/src/builder/builder.d.ts +1 -1
  99. package/out/zql/src/builder/builder.js +1 -1
  100. package/out/zql/src/query/named.d.ts +2 -2
  101. package/out/zql/src/query/named.d.ts.map +1 -1
  102. package/out/zql/src/query/named.js +4 -2
  103. package/out/zql/src/query/named.js.map +1 -1
  104. package/out/zql/src/query/query-delegate.d.ts +1 -1
  105. package/out/zql/src/query/query-delegate.d.ts.map +1 -1
  106. package/out/zql/src/query/query-impl.d.ts +2 -2
  107. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  108. package/out/zql/src/query/query-impl.js +5 -5
  109. package/out/zql/src/query/query-impl.js.map +1 -1
  110. package/out/zql/src/query/query.d.ts +5 -1
  111. package/out/zql/src/query/query.d.ts.map +1 -1
  112. package/out/zql/src/query/query.js +1 -0
  113. package/out/zql/src/query/query.js.map +1 -1
  114. package/package.json +1 -1
  115. package/out/chunk-DYTMKRKN.js.map +0 -7
  116. package/out/inspector-NC47TWFX.js.map +0 -7
  117. package/out/zero-cache/src/server/inspect-metrics-delegate.d.ts.map +0 -1
  118. package/out/zero-cache/src/server/inspect-metrics-delegate.js.map +0 -1
@@ -51,6 +51,7 @@ import {
51
51
  createPredicate,
52
52
  decodeIndexKey,
53
53
  deepEqual,
54
+ delegateSymbol,
54
55
  desiredQueriesPrefixForClient,
55
56
  diff,
56
57
  diff2,
@@ -126,7 +127,7 @@ import {
126
127
  withWrite,
127
128
  withWriteNoImplicitCommit,
128
129
  wrapIterable
129
- } from "./chunk-RPVWLROJ.js";
130
+ } from "./chunk-3I7CRZJP.js";
130
131
  import {
131
132
  assert,
132
133
  assertArray,
@@ -5973,7 +5974,7 @@ var userQueryMutateParamsSchema = valita_exports.object({
5973
5974
  * This URL must match one of the URLs set in the zero config.
5974
5975
  *
5975
5976
  * E.g., Given the following environment variable:
5976
- * ZERO_QUERY_URL=[https://*.example.com/query]
5977
+ * ZERO_GET_QUERIES_URL=[https://*.example.com/query]
5977
5978
  *
5978
5979
  * Then this URL could be:
5979
5980
  * https://myapp.example.com/query
@@ -8665,7 +8666,7 @@ function makeMessage(message, context, logLevel) {
8665
8666
  }
8666
8667
 
8667
8668
  // ../zero-client/src/client/version.ts
8668
- var version2 = "0.23.2025081901";
8669
+ var version2 = "0.23.2025082300";
8669
8670
 
8670
8671
  // ../zero-client/src/client/log-options.ts
8671
8672
  var LevelFilterLogSink = class {
@@ -9223,6 +9224,7 @@ var Success = 1;
9223
9224
  var QueryManager = class {
9224
9225
  #clientID;
9225
9226
  #clientToServer;
9227
+ #serverToClient;
9226
9228
  #send;
9227
9229
  #queries = /* @__PURE__ */ new Map();
9228
9230
  #recentQueriesMaxSize;
@@ -9241,6 +9243,7 @@ var QueryManager = class {
9241
9243
  this.#lc = lc.withContext("QueryManager");
9242
9244
  this.#clientID = clientID;
9243
9245
  this.#clientToServer = clientToServer(tables);
9246
+ this.#serverToClient = serverToClient(tables);
9244
9247
  this.#recentQueriesMaxSize = recentQueriesMaxSize;
9245
9248
  this.#send = send2;
9246
9249
  this.#mutationTracker = mutationTracker;
@@ -9278,6 +9281,10 @@ var QueryManager = class {
9278
9281
  }
9279
9282
  );
9280
9283
  }
9284
+ getAST(queryID) {
9285
+ const ast = this.#queries.get(queryID)?.normalized;
9286
+ return ast && mapAST(ast, this.#serverToClient);
9287
+ }
9281
9288
  #fireGotCallbacks(queryHash, got) {
9282
9289
  const gotCallbacks = this.#queries.get(queryHash)?.gotCallbacks ?? [];
9283
9290
  for (const gotCallback of gotCallbacks) {
@@ -9316,7 +9323,7 @@ var QueryManager = class {
9316
9323
  patch.set(hash, {
9317
9324
  op: "put",
9318
9325
  hash,
9319
- ast: normalized,
9326
+ ast: name === void 0 ? normalized : void 0,
9320
9327
  name,
9321
9328
  args,
9322
9329
  // We get TTL out of the DagStore so it is possible that the TTL was written
@@ -9341,17 +9348,10 @@ var QueryManager = class {
9341
9348
  }
9342
9349
  return patch;
9343
9350
  }
9344
- addCustom({ name, args }, ttl, gotCallback) {
9351
+ addCustom(ast, { name, args }, ttl, gotCallback) {
9352
+ const normalized = normalizeAST(ast);
9345
9353
  const queryId = hashOfNameAndArgs(name, args);
9346
- return this.#add(
9347
- queryId,
9348
- void 0,
9349
- // normalized is undefined for custom queries
9350
- name,
9351
- args,
9352
- ttl,
9353
- gotCallback
9354
- );
9354
+ return this.#add(queryId, normalized, name, args, ttl, gotCallback);
9355
9355
  }
9356
9356
  addLegacy(ast, ttl, gotCallback) {
9357
9357
  const normalized = normalizeAST(ast);
@@ -9369,16 +9369,14 @@ var QueryManager = class {
9369
9369
  }
9370
9370
  #add(queryId, normalized, name, args, ttl, gotCallback) {
9371
9371
  assert(
9372
- normalized === void 0 && name !== void 0 && args !== void 0 || normalized !== void 0 && name === void 0 && args === void 0,
9373
- "Either normalized or name and args must be defined, but not both."
9372
+ name === void 0 === (args === void 0),
9373
+ "If name is defined, args must be defined"
9374
9374
  );
9375
9375
  ttl = clampTTL(ttl, this.#lc);
9376
9376
  let entry = this.#queries.get(queryId);
9377
9377
  this.#recentQueries.delete(queryId);
9378
9378
  if (!entry) {
9379
- if (normalized !== void 0) {
9380
- normalized = mapAST(normalized, this.#clientToServer);
9381
- }
9379
+ normalized = mapAST(normalized, this.#clientToServer);
9382
9380
  entry = {
9383
9381
  normalized,
9384
9382
  name,
@@ -9391,7 +9389,7 @@ var QueryManager = class {
9391
9389
  this.#queueQueryChange({
9392
9390
  op: "put",
9393
9391
  hash: queryId,
9394
- ast: normalized,
9392
+ ast: name === void 0 ? normalized : void 0,
9395
9393
  name,
9396
9394
  args,
9397
9395
  ttl
@@ -9422,24 +9420,24 @@ var QueryManager = class {
9422
9420
  };
9423
9421
  }
9424
9422
  updateCustom({ name, args }, ttl) {
9425
- const hash = hashOfNameAndArgs(name, args);
9426
- const entry = must(this.#queries.get(hash));
9427
- this.#updateEntry(entry, hash, ttl);
9423
+ const queryID = hashOfNameAndArgs(name, args);
9424
+ const entry = must(this.#queries.get(queryID));
9425
+ this.#updateEntry(entry, queryID, ttl);
9428
9426
  }
9429
9427
  updateLegacy(ast, ttl) {
9430
9428
  const normalized = normalizeAST(ast);
9431
- const astHash = hashOfAST(normalized);
9432
- const entry = must(this.#queries.get(astHash));
9433
- this.#updateEntry(entry, astHash, ttl);
9429
+ const queryID = hashOfAST(normalized);
9430
+ const entry = must(this.#queries.get(queryID));
9431
+ this.#updateEntry(entry, queryID, ttl);
9434
9432
  }
9435
- #updateEntry(entry, hash, ttl) {
9433
+ #updateEntry(entry, queryID, ttl) {
9436
9434
  ttl = clampTTL(ttl, this.#lc);
9437
9435
  if (compareTTL(ttl, entry.ttl) > 0) {
9438
9436
  entry.ttl = ttl;
9439
9437
  this.#queueQueryChange({
9440
9438
  op: "put",
9441
- hash,
9442
- ast: entry.normalized,
9439
+ hash: queryID,
9440
+ ast: entry.name === void 0 ? entry.normalized : void 0,
9443
9441
  name: entry.name,
9444
9442
  args: entry.args,
9445
9443
  ttl
@@ -10291,8 +10289,9 @@ var Zero = class _Zero {
10291
10289
  enableAnalytics: this.#enableAnalytics
10292
10290
  });
10293
10291
  const logOptions = this.#logOptions;
10292
+ const { enableLegacyMutators = true, enableLegacyQueries = true } = options;
10294
10293
  const replicacheMutators = {
10295
- [CRUD_MUTATION_NAME]: makeCRUDMutator(schema)
10294
+ [CRUD_MUTATION_NAME]: enableLegacyMutators ? makeCRUDMutator(schema) : () => Promise.reject(new Error("Zero CRUD mutators are not enabled."))
10296
10295
  };
10297
10296
  this.#ivmMain = new IVMSourceBranch(schema.tables);
10298
10297
  function assertUnique(key) {
@@ -10379,9 +10378,20 @@ var Zero = class _Zero {
10379
10378
  this.#zeroContext = new ZeroContext(
10380
10379
  lc,
10381
10380
  this.#ivmMain,
10382
- (ast, ttl, gotCallback) => this.#queryManager.addLegacy(ast, ttl, gotCallback),
10383
- (customQueryID, ttl, gotCallback) => this.#queryManager.addCustom(customQueryID, ttl, gotCallback),
10384
- (ast, ttl) => this.#queryManager.updateLegacy(ast, ttl),
10381
+ (ast, ttl, gotCallback) => {
10382
+ if (enableLegacyQueries) {
10383
+ return this.#queryManager.addLegacy(ast, ttl, gotCallback);
10384
+ }
10385
+ return emptyFunction;
10386
+ },
10387
+ (ast, customQueryID, ttl, gotCallback) => this.#queryManager.addCustom(ast, customQueryID, ttl, gotCallback),
10388
+ (ast, ttl) => {
10389
+ if (enableLegacyQueries) {
10390
+ this.#queryManager.updateLegacy(ast, ttl);
10391
+ return;
10392
+ }
10393
+ this.#queryManager.updateLegacy(ast, ttl);
10394
+ },
10385
10395
  (customQueryID, ttl) => this.#queryManager.updateCustom(customQueryID, ttl),
10386
10396
  () => this.#queryManager.flushBatch(),
10387
10397
  batchViewUpdates,
@@ -10567,7 +10577,16 @@ var Zero = class _Zero {
10567
10577
  return createLogOptions(options);
10568
10578
  }
10569
10579
  preload(query, options) {
10570
- return query.delegate(this.#zeroContext).preload(options);
10580
+ return query[delegateSymbol](this.#zeroContext).preload(options);
10581
+ }
10582
+ run(query, runOptions) {
10583
+ return query[delegateSymbol](this.#zeroContext).run(runOptions);
10584
+ }
10585
+ materialize(query, factoryOrOptions, maybeOptions) {
10586
+ if (typeof factoryOrOptions === "function") {
10587
+ return query[delegateSymbol](this.#zeroContext).materialize(factoryOrOptions, maybeOptions?.ttl);
10588
+ }
10589
+ return query[delegateSymbol](this.#zeroContext).materialize(factoryOrOptions?.ttl);
10571
10590
  }
10572
10591
  /**
10573
10592
  * The server URL that this Zero instance is configured with.
@@ -11419,7 +11438,7 @@ var Zero = class _Zero {
11419
11438
  */
11420
11439
  async inspect() {
11421
11440
  BUNDLE_SIZE: {
11422
- const m = await import("./inspector-NC47TWFX.js");
11441
+ const m = await import("./inspector-UIWB2MYC.js");
11423
11442
  return m.newInspector(
11424
11443
  this.#rep,
11425
11444
  this.#queryManager,
@@ -11586,4 +11605,4 @@ export {
11586
11605
  update_needed_reason_type_enum_exports,
11587
11606
  Zero
11588
11607
  };
11589
- //# sourceMappingURL=chunk-DYTMKRKN.js.map
11608
+ //# sourceMappingURL=chunk-4AQ764RO.js.map