@rocicorp/zero 1.8.0 → 1.9.0-canary.1

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 (179) hide show
  1. package/out/shared/src/cache.d.ts +8 -1
  2. package/out/shared/src/cache.d.ts.map +1 -1
  3. package/out/shared/src/cache.js +25 -9
  4. package/out/shared/src/cache.js.map +1 -1
  5. package/out/shared/src/objects.d.ts +6 -1
  6. package/out/shared/src/objects.d.ts.map +1 -1
  7. package/out/shared/src/objects.js +19 -4
  8. package/out/shared/src/objects.js.map +1 -1
  9. package/out/z2s/src/compiler.d.ts.map +1 -1
  10. package/out/z2s/src/compiler.js +1 -22
  11. package/out/z2s/src/compiler.js.map +1 -1
  12. package/out/zero/package.js +2 -19
  13. package/out/zero/package.js.map +1 -1
  14. package/out/zero-cache/src/config/zero-config.d.ts +4 -0
  15. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  16. package/out/zero-cache/src/config/zero-config.js +21 -6
  17. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  18. package/out/zero-cache/src/custom/fetch.js +1 -1
  19. package/out/zero-cache/src/custom/fetch.js.map +1 -1
  20. package/out/zero-cache/src/custom-queries/transform-query.d.ts +6 -0
  21. package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +1 -1
  22. package/out/zero-cache/src/custom-queries/transform-query.js +8 -0
  23. package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
  24. package/out/zero-cache/src/db/migration-lite.d.ts.map +1 -1
  25. package/out/zero-cache/src/db/migration-lite.js +5 -2
  26. package/out/zero-cache/src/db/migration-lite.js.map +1 -1
  27. package/out/zero-cache/src/db/migration.d.ts.map +1 -1
  28. package/out/zero-cache/src/db/migration.js +3 -1
  29. package/out/zero-cache/src/db/migration.js.map +1 -1
  30. package/out/zero-cache/src/db/sqlite-corruption.d.ts +11 -0
  31. package/out/zero-cache/src/db/sqlite-corruption.d.ts.map +1 -0
  32. package/out/zero-cache/src/db/sqlite-corruption.js +191 -0
  33. package/out/zero-cache/src/db/sqlite-corruption.js.map +1 -0
  34. package/out/zero-cache/src/server/anonymous-otel-start.d.ts +1 -1
  35. package/out/zero-cache/src/server/anonymous-otel-start.js.map +1 -1
  36. package/out/zero-cache/src/server/backup-watermark-reader.js +1 -1
  37. package/out/zero-cache/src/server/backup-watermark-reader.js.map +1 -1
  38. package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
  39. package/out/zero-cache/src/server/change-streamer.js +7 -2
  40. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  41. package/out/zero-cache/src/server/logging.d.ts +8 -0
  42. package/out/zero-cache/src/server/logging.d.ts.map +1 -1
  43. package/out/zero-cache/src/server/logging.js +27 -5
  44. package/out/zero-cache/src/server/logging.js.map +1 -1
  45. package/out/zero-cache/src/server/main.d.ts.map +1 -1
  46. package/out/zero-cache/src/server/main.js +6 -1
  47. package/out/zero-cache/src/server/main.js.map +1 -1
  48. package/out/zero-cache/src/server/mutator.js +1 -1
  49. package/out/zero-cache/src/server/mutator.js.map +1 -1
  50. package/out/zero-cache/src/server/otel-log-sink.d.ts +7 -1
  51. package/out/zero-cache/src/server/otel-log-sink.d.ts.map +1 -1
  52. package/out/zero-cache/src/server/otel-log-sink.js +7 -2
  53. package/out/zero-cache/src/server/otel-log-sink.js.map +1 -1
  54. package/out/zero-cache/src/server/reaper.js +1 -1
  55. package/out/zero-cache/src/server/reaper.js.map +1 -1
  56. package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
  57. package/out/zero-cache/src/server/replicator.js +11 -1
  58. package/out/zero-cache/src/server/replicator.js.map +1 -1
  59. package/out/zero-cache/src/server/shadow-syncer.js +1 -1
  60. package/out/zero-cache/src/server/shadow-syncer.js.map +1 -1
  61. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  62. package/out/zero-cache/src/server/syncer.js +6 -1
  63. package/out/zero-cache/src/server/syncer.js.map +1 -1
  64. package/out/zero-cache/src/services/change-source/common/replica-schema.d.ts.map +1 -1
  65. package/out/zero-cache/src/services/change-source/common/replica-schema.js +8 -5
  66. package/out/zero-cache/src/services/change-source/common/replica-schema.js.map +1 -1
  67. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +36 -2
  68. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
  69. package/out/zero-cache/src/services/change-source/pg/change-source.js +76 -33
  70. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  71. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +15 -0
  72. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
  73. package/out/zero-cache/src/services/change-source/pg/initial-sync.js +41 -10
  74. package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
  75. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts +21 -0
  76. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts.map +1 -1
  77. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js +34 -5
  78. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js.map +1 -1
  79. package/out/zero-cache/src/services/change-source/pg/replication-slots.d.ts +2 -2
  80. package/out/zero-cache/src/services/change-source/pg/replication-slots.d.ts.map +1 -1
  81. package/out/zero-cache/src/services/change-source/pg/replication-slots.js.map +1 -1
  82. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +61 -87
  83. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
  84. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +17 -12
  85. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
  86. package/out/zero-cache/src/services/life-cycle.d.ts +1 -1
  87. package/out/zero-cache/src/services/life-cycle.d.ts.map +1 -1
  88. package/out/zero-cache/src/services/life-cycle.js +15 -3
  89. package/out/zero-cache/src/services/life-cycle.js.map +1 -1
  90. package/out/zero-cache/src/services/litestream/commands.d.ts.map +1 -1
  91. package/out/zero-cache/src/services/litestream/commands.js +26 -23
  92. package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
  93. package/out/zero-cache/src/services/litestream/config.yml +3 -2
  94. package/out/zero-cache/src/services/litestream/vfs-watermark-reader.js +2 -2
  95. package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
  96. package/out/zero-cache/src/services/mutagen/mutagen.js +4 -1
  97. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  98. package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -1
  99. package/out/zero-cache/src/services/replicator/change-processor.js +29 -16
  100. package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
  101. package/out/zero-cache/src/services/replicator/reporter/recorder.d.ts +1 -1
  102. package/out/zero-cache/src/services/replicator/reporter/recorder.d.ts.map +1 -1
  103. package/out/zero-cache/src/services/replicator/reporter/recorder.js +5 -12
  104. package/out/zero-cache/src/services/replicator/reporter/recorder.js.map +1 -1
  105. package/out/zero-cache/src/services/replicator/write-worker.js +38 -7
  106. package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -1
  107. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  108. package/out/zero-cache/src/services/view-syncer/cvr.js +8 -1
  109. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  110. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  111. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +66 -26
  112. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  113. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts +28 -0
  114. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts.map +1 -0
  115. package/out/zero-cache/src/services/view-syncer/query-covering.js +159 -0
  116. package/out/zero-cache/src/services/view-syncer/query-covering.js.map +1 -0
  117. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
  118. package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
  119. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +2 -0
  120. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  121. package/out/zero-cache/src/services/view-syncer/view-syncer.js +71 -1
  122. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  123. package/out/zero-cache/src/types/lite.d.ts.map +1 -1
  124. package/out/zero-cache/src/types/lite.js +4 -1
  125. package/out/zero-cache/src/types/lite.js.map +1 -1
  126. package/out/zero-cache/src/types/pg.d.ts +18 -0
  127. package/out/zero-cache/src/types/pg.d.ts.map +1 -1
  128. package/out/zero-cache/src/types/pg.js +50 -0
  129. package/out/zero-cache/src/types/pg.js.map +1 -1
  130. package/out/zero-cache/src/workers/syncer.d.ts +1 -1
  131. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  132. package/out/zero-cache/src/workers/syncer.js +1 -0
  133. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  134. package/out/zero-client/src/client/crud.d.ts.map +1 -1
  135. package/out/zero-client/src/client/crud.js +3 -4
  136. package/out/zero-client/src/client/crud.js.map +1 -1
  137. package/out/zero-client/src/client/version.js +1 -1
  138. package/out/zero-client/src/client/zero.d.ts +6 -7
  139. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  140. package/out/zero-client/src/client/zero.js +125 -85
  141. package/out/zero-client/src/client/zero.js.map +1 -1
  142. package/out/zero-schema/src/builder/relationship-builder.d.ts.map +1 -1
  143. package/out/zero-schema/src/builder/relationship-builder.js +3 -2
  144. package/out/zero-schema/src/builder/relationship-builder.js.map +1 -1
  145. package/out/zero-schema/src/builder/schema-builder.d.ts.map +1 -1
  146. package/out/zero-schema/src/builder/schema-builder.js +7 -7
  147. package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
  148. package/out/zero-schema/src/builder/table-builder.d.ts.map +1 -1
  149. package/out/zero-schema/src/builder/table-builder.js +2 -1
  150. package/out/zero-schema/src/builder/table-builder.js.map +1 -1
  151. package/out/zero-server/src/custom.js +10 -3
  152. package/out/zero-server/src/custom.js.map +1 -1
  153. package/out/zero-server/src/schema.d.ts +8 -0
  154. package/out/zero-server/src/schema.d.ts.map +1 -1
  155. package/out/zero-server/src/schema.js +63 -24
  156. package/out/zero-server/src/schema.js.map +1 -1
  157. package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
  158. package/out/zql/src/ivm/view-apply-change.js +2 -1
  159. package/out/zql/src/ivm/view-apply-change.js.map +1 -1
  160. package/out/zql/src/mutate/crud.d.ts +10 -8
  161. package/out/zql/src/mutate/crud.d.ts.map +1 -1
  162. package/out/zql/src/mutate/crud.js +3 -4
  163. package/out/zql/src/mutate/crud.js.map +1 -1
  164. package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
  165. package/out/zql/src/query/query-delegate-base.js +5 -1
  166. package/out/zql/src/query/query-delegate-base.js.map +1 -1
  167. package/out/zqlite/src/db.js +2 -2
  168. package/out/zqlite/src/internal/statement-cache.d.ts +25 -1
  169. package/out/zqlite/src/internal/statement-cache.d.ts.map +1 -1
  170. package/out/zqlite/src/internal/statement-cache.js +48 -18
  171. package/out/zqlite/src/internal/statement-cache.js.map +1 -1
  172. package/out/zqlite/src/query-builder.js +3 -3
  173. package/out/zqlite/src/query-builder.js.map +1 -1
  174. package/out/zqlite/src/resolve-scalar-subqueries.d.ts.map +1 -1
  175. package/out/zqlite/src/resolve-scalar-subqueries.js +13 -1
  176. package/out/zqlite/src/resolve-scalar-subqueries.js.map +1 -1
  177. package/out/zqlite/src/sqlite-cost-model.js +5 -5
  178. package/out/zqlite/src/table-source.js +3 -3
  179. package/package.json +2 -33
@@ -3,7 +3,14 @@
3
3
  * Does not update the expiration time on retrieval.
4
4
  * Values are automatically removed from the cache after the TTL expires.
5
5
  * The cache is cleaned up periodically based on the TTL so it does
6
- * not grow indefinitely.
6
+ * not grow indefinitely. The cleanup interval is started lazily on the
7
+ * first `set()` and is `unref`ed (where supported) so it never keeps
8
+ * the process alive.
9
+ *
10
+ * Call `destroy()` to stop the cleanup interval and release the cached
11
+ * values. `destroy()` is idempotent, and a destroyed cache is inert:
12
+ * `get()` always misses, `set()` is a no-op, and the cleanup interval
13
+ * is never restarted.
7
14
  */
8
15
  export declare class TimedCache<T> {
9
16
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../shared/src/cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,UAAU,CAAC,CAAC;;gBAKX,KAAK,EAAE,MAAM;IAazB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAKhC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAS/B,OAAO,IAAI,IAAI;CAIhB"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../shared/src/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,qBAAa,UAAU,CAAC,CAAC;;gBAMX,KAAK,EAAE,MAAM;IAKzB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAehC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAkB/B,OAAO,IAAI,IAAI;CAQhB"}
@@ -4,26 +4,34 @@
4
4
  * Does not update the expiration time on retrieval.
5
5
  * Values are automatically removed from the cache after the TTL expires.
6
6
  * The cache is cleaned up periodically based on the TTL so it does
7
- * not grow indefinitely.
7
+ * not grow indefinitely. The cleanup interval is started lazily on the
8
+ * first `set()` and is `unref`ed (where supported) so it never keeps
9
+ * the process alive.
10
+ *
11
+ * Call `destroy()` to stop the cleanup interval and release the cached
12
+ * values. `destroy()` is idempotent, and a destroyed cache is inert:
13
+ * `get()` always misses, `set()` is a no-op, and the cleanup interval
14
+ * is never restarted.
8
15
  */
9
16
  var TimedCache = class {
10
17
  #cache;
11
18
  #ttlMs;
12
19
  #intervalHandle;
20
+ #destroyed = false;
13
21
  constructor(ttlMs) {
14
22
  this.#cache = /* @__PURE__ */ new Map();
15
23
  this.#ttlMs = ttlMs;
16
- this.#intervalHandle = setInterval(() => {
17
- const now = Date.now();
18
- for (const [key, entry] of this.#cache.entries()) if (entry.expiresAt < now) this.#cache.delete(key);
19
- }, ttlMs * 2);
20
24
  }
21
25
  set(key, value) {
22
- const entry = {
26
+ if (this.#destroyed) return;
27
+ if (this.#intervalHandle === void 0) {
28
+ this.#intervalHandle = setInterval(() => this.#removeExpired(), this.#ttlMs * 2);
29
+ this.#intervalHandle.unref?.();
30
+ }
31
+ this.#cache.set(key, {
23
32
  value,
24
33
  expiresAt: Date.now() + this.#ttlMs
25
- };
26
- this.#cache.set(key, entry);
34
+ });
27
35
  }
28
36
  get(key) {
29
37
  const entry = this.#cache.get(key);
@@ -33,8 +41,16 @@ var TimedCache = class {
33
41
  }
34
42
  return entry.value;
35
43
  }
44
+ #removeExpired() {
45
+ const now = Date.now();
46
+ for (const [key, entry] of this.#cache.entries()) if (entry.expiresAt < now) this.#cache.delete(key);
47
+ }
36
48
  destroy() {
37
- clearInterval(this.#intervalHandle);
49
+ this.#destroyed = true;
50
+ if (this.#intervalHandle !== void 0) {
51
+ clearInterval(this.#intervalHandle);
52
+ this.#intervalHandle = void 0;
53
+ }
38
54
  this.#cache.clear();
39
55
  }
40
56
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","names":["#cache","#ttlMs","#intervalHandle"],"sources":["../../../../shared/src/cache.ts"],"sourcesContent":["/**\n * Stores values with an expiration time at time of insertion.\n * Does not update the expiration time on retrieval.\n * Values are automatically removed from the cache after the TTL expires.\n * The cache is cleaned up periodically based on the TTL so it does\n * not grow indefinitely.\n */\nexport class TimedCache<T> {\n readonly #cache: Map<string, {value: T; expiresAt: number}>;\n readonly #ttlMs: number;\n readonly #intervalHandle: NodeJS.Timeout;\n\n constructor(ttlMs: number) {\n this.#cache = new Map();\n this.#ttlMs = ttlMs;\n this.#intervalHandle = setInterval(() => {\n const now = Date.now();\n for (const [key, entry] of this.#cache.entries()) {\n if (entry.expiresAt < now) {\n this.#cache.delete(key);\n }\n }\n }, ttlMs * 2);\n }\n\n set(key: string, value: T): void {\n const entry = {value, expiresAt: Date.now() + this.#ttlMs};\n this.#cache.set(key, entry);\n }\n\n get(key: string): T | undefined {\n const entry = this.#cache.get(key);\n if (entry === undefined || entry.expiresAt < Date.now()) {\n this.#cache.delete(key);\n return undefined;\n }\n return entry.value;\n }\n\n destroy(): void {\n clearInterval(this.#intervalHandle);\n this.#cache.clear();\n }\n}\n"],"mappings":";;;;;;;;AAOA,IAAa,aAAb,MAA2B;CACzB;CACA;CACA;CAEA,YAAY,OAAe;EACzB,KAAKA,yBAAS,IAAI,IAAI;EACtB,KAAKC,SAAS;EACd,KAAKC,kBAAkB,kBAAkB;GACvC,MAAM,MAAM,KAAK,IAAI;GACrB,KAAK,MAAM,CAAC,KAAK,UAAU,KAAKF,OAAO,QAAQ,GAC7C,IAAI,MAAM,YAAY,KACpB,KAAKA,OAAO,OAAO,GAAG;EAG5B,GAAG,QAAQ,CAAC;CACd;CAEA,IAAI,KAAa,OAAgB;EAC/B,MAAM,QAAQ;GAAC;GAAO,WAAW,KAAK,IAAI,IAAI,KAAKC;EAAM;EACzD,KAAKD,OAAO,IAAI,KAAK,KAAK;CAC5B;CAEA,IAAI,KAA4B;EAC9B,MAAM,QAAQ,KAAKA,OAAO,IAAI,GAAG;EACjC,IAAI,UAAU,KAAA,KAAa,MAAM,YAAY,KAAK,IAAI,GAAG;GACvD,KAAKA,OAAO,OAAO,GAAG;GACtB;EACF;EACA,OAAO,MAAM;CACf;CAEA,UAAgB;EACd,cAAc,KAAKE,eAAe;EAClC,KAAKF,OAAO,MAAM;CACpB;AACF"}
1
+ {"version":3,"file":"cache.js","names":["#cache","#ttlMs","#destroyed","#intervalHandle","#removeExpired"],"sources":["../../../../shared/src/cache.ts"],"sourcesContent":["/**\n * Stores values with an expiration time at time of insertion.\n * Does not update the expiration time on retrieval.\n * Values are automatically removed from the cache after the TTL expires.\n * The cache is cleaned up periodically based on the TTL so it does\n * not grow indefinitely. The cleanup interval is started lazily on the\n * first `set()` and is `unref`ed (where supported) so it never keeps\n * the process alive.\n *\n * Call `destroy()` to stop the cleanup interval and release the cached\n * values. `destroy()` is idempotent, and a destroyed cache is inert:\n * `get()` always misses, `set()` is a no-op, and the cleanup interval\n * is never restarted.\n */\nexport class TimedCache<T> {\n readonly #cache: Map<string, {value: T; expiresAt: number}>;\n readonly #ttlMs: number;\n #intervalHandle: ReturnType<typeof setInterval> | undefined;\n #destroyed = false;\n\n constructor(ttlMs: number) {\n this.#cache = new Map();\n this.#ttlMs = ttlMs;\n }\n\n set(key: string, value: T): void {\n if (this.#destroyed) {\n return;\n }\n if (this.#intervalHandle === undefined) {\n this.#intervalHandle = setInterval(\n () => this.#removeExpired(),\n this.#ttlMs * 2,\n );\n // In browsers setInterval returns a number, which has no unref.\n this.#intervalHandle.unref?.();\n }\n this.#cache.set(key, {value, expiresAt: Date.now() + this.#ttlMs});\n }\n\n get(key: string): T | undefined {\n const entry = this.#cache.get(key);\n if (entry === undefined || entry.expiresAt < Date.now()) {\n this.#cache.delete(key);\n return undefined;\n }\n return entry.value;\n }\n\n #removeExpired(): void {\n const now = Date.now();\n for (const [key, entry] of this.#cache.entries()) {\n if (entry.expiresAt < now) {\n this.#cache.delete(key);\n }\n }\n }\n\n destroy(): void {\n this.#destroyed = true;\n if (this.#intervalHandle !== undefined) {\n clearInterval(this.#intervalHandle);\n this.#intervalHandle = undefined;\n }\n this.#cache.clear();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,IAAa,aAAb,MAA2B;CACzB;CACA;CACA;CACA,aAAa;CAEb,YAAY,OAAe;EACzB,KAAKA,yBAAS,IAAI,IAAI;EACtB,KAAKC,SAAS;CAChB;CAEA,IAAI,KAAa,OAAgB;EAC/B,IAAI,KAAKC,YACP;EAEF,IAAI,KAAKC,oBAAoB,KAAA,GAAW;GACtC,KAAKA,kBAAkB,kBACf,KAAKC,eAAe,GAC1B,KAAKH,SAAS,CAChB;GAEA,KAAKE,gBAAgB,QAAQ;EAC/B;EACA,KAAKH,OAAO,IAAI,KAAK;GAAC;GAAO,WAAW,KAAK,IAAI,IAAI,KAAKC;EAAM,CAAC;CACnE;CAEA,IAAI,KAA4B;EAC9B,MAAM,QAAQ,KAAKD,OAAO,IAAI,GAAG;EACjC,IAAI,UAAU,KAAA,KAAa,MAAM,YAAY,KAAK,IAAI,GAAG;GACvD,KAAKA,OAAO,OAAO,GAAG;GACtB;EACF;EACA,OAAO,MAAM;CACf;CAEA,iBAAuB;EACrB,MAAM,MAAM,KAAK,IAAI;EACrB,KAAK,MAAM,CAAC,KAAK,UAAU,KAAKA,OAAO,QAAQ,GAC7C,IAAI,MAAM,YAAY,KACpB,KAAKA,OAAO,OAAO,GAAG;CAG5B;CAEA,UAAgB;EACd,KAAKE,aAAa;EAClB,IAAI,KAAKC,oBAAoB,KAAA,GAAW;GACtC,cAAc,KAAKA,eAAe;GAClC,KAAKA,kBAAkB,KAAA;EACzB;EACA,KAAKH,OAAO,MAAM;CACpB;AACF"}
@@ -1,6 +1,11 @@
1
- export declare function mapValues<T extends Record<string, unknown>, U>(input: T, mapper: (value: T[keyof T]) => U): {
1
+ export declare function mapValues<T extends Record<string, unknown>, U>(input: T, mapper: (value: T[keyof T], key: keyof T & string) => U): {
2
2
  [K in keyof T]: U;
3
3
  };
4
+ /**
5
+ * Safe function of `[[Set]]`/assign that prevents invoking the legacy
6
+ * `__proto__` setter. This is used to avoid prototype pollution attacks.
7
+ */
8
+ export declare function assignProperty<K extends string | number | symbol, T>(object: Record<K, T>, key: K, value: T): void;
4
9
  export declare function mapEntries<T, U>(input: Record<string, T>, mapper: (key: string, val: T) => [key: string, val: U]): Record<string, U>;
5
10
  export declare function mapAllEntries<T, U>(input: Record<string, T>, mapper: (entries: [key: string, val: T][]) => [key: string, val: U][]): Record<string, U>;
6
11
  //# sourceMappingURL=objects.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../../shared/src/objects.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,EAC5D,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAC/B;KAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC;CAAC,CAIrB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EACxB,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GACrD,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAYnB;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EACxB,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GACpE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAQnB"}
1
+ {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../../shared/src/objects.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,EAC5D,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,MAAM,KAAK,CAAC,GACtD;KAAE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC;CAAC,CAWrB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EAClE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,GACP,IAAI,CAeN;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EACxB,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GACrD,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CASnB;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EACxB,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,GACpE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAQnB"}
@@ -1,21 +1,36 @@
1
1
  //#region ../shared/src/objects.ts
2
2
  function mapValues(input, mapper) {
3
- return mapEntries(input, (k, v) => [k, mapper(v)]);
3
+ const output = {};
4
+ for (const entry of Object.entries(input)) assignProperty(output, entry[0], mapper(entry[1], entry[0]));
5
+ return output;
6
+ }
7
+ /**
8
+ * Safe function of `[[Set]]`/assign that prevents invoking the legacy
9
+ * `__proto__` setter. This is used to avoid prototype pollution attacks.
10
+ */
11
+ function assignProperty(object, key, value) {
12
+ if (key === "__proto__") Object.defineProperty(object, key, {
13
+ value,
14
+ writable: true,
15
+ enumerable: true,
16
+ configurable: true
17
+ });
18
+ object[key] = value;
4
19
  }
5
20
  function mapEntries(input, mapper) {
6
21
  const output = {};
7
22
  for (const entry of Object.entries(input)) {
8
23
  const mapped = mapper(entry[0], entry[1]);
9
- output[mapped[0]] = mapped[1];
24
+ assignProperty(output, mapped[0], mapped[1]);
10
25
  }
11
26
  return output;
12
27
  }
13
28
  function mapAllEntries(input, mapper) {
14
29
  const output = {};
15
- for (const mapped of mapper(Object.entries(input))) output[mapped[0]] = mapped[1];
30
+ for (const [key, val] of mapper(Object.entries(input))) assignProperty(output, key, val);
16
31
  return output;
17
32
  }
18
33
  //#endregion
19
- export { mapAllEntries, mapEntries, mapValues };
34
+ export { assignProperty, mapAllEntries, mapEntries, mapValues };
20
35
 
21
36
  //# sourceMappingURL=objects.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"objects.js","names":[],"sources":["../../../../shared/src/objects.ts"],"sourcesContent":["export function mapValues<T extends Record<string, unknown>, U>(\n input: T,\n mapper: (value: T[keyof T]) => U,\n): {[K in keyof T]: U} {\n return mapEntries(input, (k, v) => [k, mapper(v as T[keyof T])]) as {\n [K in keyof T]: U;\n };\n}\n\nexport function mapEntries<T, U>(\n input: Record<string, T>,\n mapper: (key: string, val: T) => [key: string, val: U],\n): Record<string, U> {\n // Direct assignment is faster than Object.fromEntries()\n // https://github.com/rocicorp/mono/pull/3927#issuecomment-2706059475\n const output: Record<string, U> = {};\n\n // In chrome Object.entries is faster than for-in (13x) or Object.keys (15x)\n // https://gist.github.com/arv/1b4e113724f6a14e2d4742bcc760d1fa\n for (const entry of Object.entries(input)) {\n const mapped = mapper(entry[0], entry[1]);\n output[mapped[0]] = mapped[1];\n }\n return output;\n}\n\nexport function mapAllEntries<T, U>(\n input: Record<string, T>,\n mapper: (entries: [key: string, val: T][]) => [key: string, val: U][],\n): Record<string, U> {\n // Direct assignment is faster than Object.fromEntries()\n // https://github.com/rocicorp/mono/pull/3927#issuecomment-2706059475\n const output: Record<string, U> = {};\n for (const mapped of mapper(Object.entries(input))) {\n output[mapped[0]] = mapped[1];\n }\n return output;\n}\n"],"mappings":";AAAA,SAAgB,UACd,OACA,QACqB;CACrB,OAAO,WAAW,QAAQ,GAAG,MAAM,CAAC,GAAG,OAAO,CAAe,CAAC,CAAC;AAGjE;AAEA,SAAgB,WACd,OACA,QACmB;CAGnB,MAAM,SAA4B,CAAC;CAInC,KAAK,MAAM,SAAS,OAAO,QAAQ,KAAK,GAAG;EACzC,MAAM,SAAS,OAAO,MAAM,IAAI,MAAM,EAAE;EACxC,OAAO,OAAO,MAAM,OAAO;CAC7B;CACA,OAAO;AACT;AAEA,SAAgB,cACd,OACA,QACmB;CAGnB,MAAM,SAA4B,CAAC;CACnC,KAAK,MAAM,UAAU,OAAO,OAAO,QAAQ,KAAK,CAAC,GAC/C,OAAO,OAAO,MAAM,OAAO;CAE7B,OAAO;AACT"}
1
+ {"version":3,"file":"objects.js","names":[],"sources":["../../../../shared/src/objects.ts"],"sourcesContent":["export function mapValues<T extends Record<string, unknown>, U>(\n input: T,\n mapper: (value: T[keyof T], key: keyof T & string) => U,\n): {[K in keyof T]: U} {\n const output = {} as {[K in keyof T]: U};\n\n for (const entry of Object.entries(input) as [\n keyof T & string,\n T[keyof T],\n ][]) {\n assignProperty(output, entry[0], mapper(entry[1], entry[0]));\n }\n\n return output;\n}\n\n/**\n * Safe function of `[[Set]]`/assign that prevents invoking the legacy\n * `__proto__` setter. This is used to avoid prototype pollution attacks.\n */\nexport function assignProperty<K extends string | number | symbol, T>(\n object: Record<K, T>,\n key: K,\n value: T,\n): void {\n if (key === '__proto__') {\n // Shadow the `__proto__` property on the object to prevent prototype\n // pollution.\n Object.defineProperty(object, key, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n });\n // fall through to the normal assignment to ensure that potentional Proxy\n // traps are invoked.\n }\n\n object[key] = value;\n}\n\nexport function mapEntries<T, U>(\n input: Record<string, T>,\n mapper: (key: string, val: T) => [key: string, val: U],\n): Record<string, U> {\n const output: Record<string, U> = {};\n\n for (const entry of Object.entries(input)) {\n const mapped = mapper(entry[0], entry[1]);\n assignProperty(output, mapped[0], mapped[1]);\n }\n\n return output;\n}\n\nexport function mapAllEntries<T, U>(\n input: Record<string, T>,\n mapper: (entries: [key: string, val: T][]) => [key: string, val: U][],\n): Record<string, U> {\n const output: Record<string, U> = {};\n\n for (const [key, val] of mapper(Object.entries(input))) {\n assignProperty(output, key, val);\n }\n\n return output;\n}\n"],"mappings":";AAAA,SAAgB,UACd,OACA,QACqB;CACrB,MAAM,SAAS,CAAC;CAEhB,KAAK,MAAM,SAAS,OAAO,QAAQ,KAAK,GAItC,eAAe,QAAQ,MAAM,IAAI,OAAO,MAAM,IAAI,MAAM,EAAE,CAAC;CAG7D,OAAO;AACT;;;;;AAMA,SAAgB,eACd,QACA,KACA,OACM;CACN,IAAI,QAAQ,aAGV,OAAO,eAAe,QAAQ,KAAK;EACjC;EACA,UAAU;EACV,YAAY;EACZ,cAAc;CAChB,CAAC;CAKH,OAAO,OAAO;AAChB;AAEA,SAAgB,WACd,OACA,QACmB;CACnB,MAAM,SAA4B,CAAC;CAEnC,KAAK,MAAM,SAAS,OAAO,QAAQ,KAAK,GAAG;EACzC,MAAM,SAAS,OAAO,MAAM,IAAI,MAAM,EAAE;EACxC,eAAe,QAAQ,OAAO,IAAI,OAAO,EAAE;CAC7C;CAEA,OAAO;AACT;AAEA,SAAgB,cACd,OACA,QACmB;CACnB,MAAM,SAA4B,CAAC;CAEnC,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,OAAO,QAAQ,KAAK,CAAC,GACnD,eAAe,QAAQ,KAAK,GAAG;CAGjC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../../z2s/src/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAQ7C,OAAO,EAAC,KAA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MAAM,GAAG,SAAS,CAAA;KAAC;CACpE,CAsBA;AAyED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAMhE"}
@@ -125,9 +125,7 @@ function where(spec, condition, table) {
125
125
  switch (condition.type) {
126
126
  case "and": return sql`(${sql.join(condition.conditions.map((c) => where(spec, c, table)), " AND ")})`;
127
127
  case "or": return sql`(${sql.join(condition.conditions.map((c) => where(spec, c, table)), " OR ")})`;
128
- case "correlatedSubquery":
129
- if (condition.scalar) return scalarSubquery(spec, condition, table);
130
- return exists(spec, condition, table);
128
+ case "correlatedSubquery": return exists(spec, condition, table);
131
129
  case "simple": return simple(spec, condition, table);
132
130
  }
133
131
  }
@@ -143,25 +141,6 @@ function exists(spec, condition, parentTable) {
143
141
  })), condition.related.correlation.childField))})`;
144
142
  }
145
143
  }
146
- function scalarSubquery(spec, condition, parentTable) {
147
- const parentField = condition.related.correlation.parentField[0];
148
- const childField = condition.related.correlation.childField[0];
149
- const subqueryAST = condition.related.subquery;
150
- const parentCol = colIdent(spec.server, {
151
- table: parentTable,
152
- zql: parentField
153
- });
154
- const subqueryTable = makeTable(spec, subqueryAST.table);
155
- const childCol = colIdent(spec.server, {
156
- table: subqueryTable,
157
- zql: childField
158
- });
159
- const op = sql.__dangerous__rawValue(condition.op === "EXISTS" ? "=" : "IS NOT");
160
- const subqueryConditions = subqueryAST.where ? [where(spec, subqueryAST.where, subqueryTable)] : [];
161
- if (subqueryAST.start) subqueryConditions.push(start(spec, subqueryAST.start, subqueryAST.orderBy, subqueryTable));
162
- const subqueryOrderBy = orderBy(spec, subqueryAST.orderBy, subqueryTable);
163
- return sql`${parentCol} ${op} (SELECT ${childCol} FROM ${fromIdent(spec.server, subqueryTable)} ${subqueryConditions.length > 0 ? sql`WHERE ${sql.join(subqueryConditions, " AND ")}` : sql``} ${subqueryOrderBy} LIMIT 1)`;
164
- }
165
144
  function makeCorrelator(spec, parentFields, childZqlFields) {
166
145
  return (childTable) => {
167
146
  const childFields = childZqlFields.map((zqlField) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.js","names":[],"sources":["../../../../z2s/src/compiler.ts"],"sourcesContent":["import type {SQLQuery} from '@databases/sql';\nimport {last, zip} from '../../shared/src/arrays.ts';\nimport {assert, unreachable} from '../../shared/src/asserts.ts';\nimport {\n parse as parseBigIntJson,\n type JSONValue as BigIntJSONValue,\n} from '../../shared/src/bigint-json.ts';\nimport {hasOwn} from '../../shared/src/has-own.ts';\nimport {type JSONValue} from '../../shared/src/json.ts';\nimport {must} from '../../shared/src/must.ts';\nimport type {\n AST,\n Bound,\n Condition,\n CorrelatedSubquery,\n CorrelatedSubqueryCondition,\n Correlation,\n LiteralReference,\n Ordering,\n SimpleCondition,\n ValuePosition,\n} from '../../zero-protocol/src/ast.ts';\nimport {\n clientToServer,\n type NameMapper,\n} from '../../zero-schema/src/name-mapper.ts';\nimport type {Schema} from '../../zero-types/src/schema.ts';\nimport type {ServerSchema} from '../../zero-types/src/server-schema.ts';\nimport type {Format} from '../../zql/src/ivm/view.ts';\nimport {completeOrdering} from '../../zql/src/query/complete-ordering.ts';\nimport {\n sql,\n sqlConvertColumnArg,\n sqlConvertPluralLiteralArg,\n sqlConvertSingularLiteralArg,\n type PluralLiteralType,\n} from './sql.ts';\n\ntype Table = {\n zql: string;\n alias: string;\n};\n\ntype QualifiedColumn = {\n table: Table;\n zql: string;\n};\n\ntype ServerSpec = {\n schema: ServerSchema;\n // maps zql names to server names\n mapper: NameMapper;\n};\n\nexport type Spec = {\n server: ServerSpec;\n zql: Schema['tables'];\n aliasCount: number;\n};\n\nconst ZQL_RESULT_KEY = 'zql_result';\nconst ZQL_RESULT_KEY_IDENT = sql.ident(ZQL_RESULT_KEY);\n\nconst ZQL_RESULT_TABLE_KEY = 'zql_root';\nconst ZQL_RESULT_TABLE_IDENT = sql.ident(ZQL_RESULT_TABLE_KEY);\n\nexport function compile(\n serverSchema: ServerSchema,\n zqlSchema: Schema,\n ast: AST,\n format?: Format,\n): SQLQuery {\n ast = completeOrdering(\n ast,\n tableName => zqlSchema.tables[tableName].primaryKey,\n );\n const spec: Spec = {\n aliasCount: 0,\n server: {\n schema: serverSchema,\n mapper: clientToServer(zqlSchema.tables),\n },\n zql: zqlSchema.tables,\n };\n return sql`SELECT \n ${toJSON(ZQL_RESULT_TABLE_KEY, format?.singular)}::text AS ${ZQL_RESULT_KEY_IDENT}\n FROM (${select(spec, ast, format)}) ${ZQL_RESULT_TABLE_IDENT}`;\n}\n\nfunction select(\n spec: Spec,\n ast: AST,\n format: Format | undefined,\n correlate?: (childTable: Table) => SQLQuery,\n): SQLQuery {\n const table = makeTable(spec, ast.table);\n const selectionSet = related(spec, ast.related ?? [], format, table);\n const tableSchema = spec.zql[ast.table];\n const usedAliases = new Set<string>(\n ast.related?.map(r => r.subquery.alias ?? ''),\n );\n for (const column of Object.keys(tableSchema.columns)) {\n if (!usedAliases.has(column)) {\n selectionSet.push(\n selectIdent(spec.server, {\n table,\n zql: column,\n }),\n );\n }\n }\n\n let appliedWhere = false;\n function maybeWhere(test: unknown) {\n if (!test) {\n return sql``;\n }\n\n const ret = appliedWhere ? sql`AND` : sql`WHERE`;\n appliedWhere = true;\n return ret;\n }\n\n return sql`SELECT ${sql.join(selectionSet, ',')}\n FROM ${fromIdent(spec.server, table)}\n ${maybeWhere(ast.where)} ${where(spec, ast.where, table)}${\n ast.start\n ? sql`\n ${maybeWhere(ast.start)} ${start(spec, ast.start, ast.orderBy, table)}`\n : sql``\n }\n ${maybeWhere(correlate)} ${correlate ? correlate(table) : sql``}\n ${orderBy(spec, ast.orderBy, table)}\n ${limit(ast.limit, format?.singular)}`;\n}\n\nexport function limit(\n limit: number | undefined,\n singular: boolean | undefined,\n): SQLQuery {\n if (limit === 0) {\n return sql`LIMIT 0`;\n }\n if (singular) {\n return sql`LIMIT 1`;\n }\n if (limit === undefined) {\n return sql``;\n }\n return sql`LIMIT ${sqlConvertSingularLiteralArg(limit)}`;\n}\n\nfunction makeTable(spec: Spec, zql: string, alias?: string): Table {\n alias = alias ?? zql + '_' + spec.aliasCount++;\n return {\n zql,\n alias,\n };\n}\n\nexport function orderBy(\n spec: Spec,\n orderBy: Ordering | undefined,\n table: Table,\n): SQLQuery {\n if (!orderBy) {\n return sql``;\n }\n return sql`ORDER BY ${sql.join(\n orderBy.map(([col, dir]) =>\n dir === 'asc'\n ? // Oh postgres. The table must be referred to by client name but the column by server name.\n // E.g., `SELECT server_col as client_col FROM server_table as client_table ORDER BY client_Table.server_col`\n sql`${colIdent(spec.server, {\n table,\n zql: col,\n })} ASC NULLS FIRST`\n : sql`${colIdent(spec.server, {\n table,\n zql: col,\n })} DESC NULLS LAST`,\n ),\n ', ',\n )}`;\n}\n\nexport function start(\n spec: Spec,\n bound: Bound | undefined,\n orderBy: Ordering | undefined,\n table: Table,\n): SQLQuery {\n if (!bound) {\n return sql``;\n }\n assert(\n orderBy !== undefined && orderBy.length > 0,\n 'start requires ordering',\n );\n\n const constraints: SQLQuery[] = [];\n for (let i = 0; i < orderBy.length; i++) {\n const group: SQLQuery[] = [];\n const [iField, iDirection] = orderBy[i];\n for (let j = 0; j <= i; j++) {\n const [field] = orderBy[j];\n if (j === i) {\n group.push(\n startRangeComparison(\n spec,\n table,\n iField,\n bound.row[iField] ?? null,\n iDirection === 'asc' ? '>' : '<',\n ),\n );\n } else {\n group.push(startEquality(spec, table, field, bound.row[field] ?? null));\n }\n }\n constraints.push(sql`(${sql.join(group, ' AND ')})`);\n }\n\n if (!bound.exclusive) {\n constraints.push(\n sql`(${sql.join(\n orderBy.map(([field]) =>\n startEquality(spec, table, field, bound.row[field] ?? null),\n ),\n ' AND ',\n )})`,\n );\n }\n\n return sql`(${sql.join(constraints, ' OR ')})`;\n}\n\nfunction related(\n spec: Spec,\n relationships: readonly CorrelatedSubquery[],\n format: Format | undefined,\n parentTable: Table,\n): SQLQuery[] {\n return relationships.map(relationship =>\n relationshipSubquery(\n spec,\n relationship,\n format?.relationships[must(relationship.subquery.alias)],\n parentTable,\n ),\n );\n}\n\nfunction relationshipSubquery(\n spec: Spec,\n relationship: CorrelatedSubquery,\n format: Format | undefined,\n parentTable: Table,\n): SQLQuery {\n const innerAlias = `inner_${relationship.subquery.alias}`;\n if (relationship.hidden) {\n const {join, participatingTables} = makeJunctionJoin(spec, relationship);\n const lastTable = must(last(participatingTables)).table;\n\n assert(\n relationship.subquery.related,\n 'hidden relationship must be a junction',\n );\n const nestedAst = relationship.subquery.related[0].subquery;\n const selectionSet = related(\n spec,\n nestedAst.related ?? [],\n format,\n lastTable,\n );\n const tableSchema = spec.zql[nestedAst.table];\n for (const column of Object.keys(tableSchema.columns)) {\n selectionSet.push(\n selectIdent(spec.server, {\n table: lastTable,\n zql: column,\n }),\n );\n }\n\n return sql`(\n SELECT ${toJSON(innerAlias, format?.singular)} FROM (SELECT ${sql.join(\n selectionSet,\n ',',\n )} FROM ${join} WHERE (${makeCorrelator(\n spec,\n relationship.correlation.parentField.map(f => ({\n table: parentTable,\n zql: f,\n })),\n relationship.correlation.childField,\n )(participatingTables[0].table)}) ${\n nestedAst.where\n ? sql`AND ${where(spec, nestedAst.where, lastTable)}`\n : sql``\n }${\n nestedAst.start\n ? sql` AND ${start(\n spec,\n nestedAst.start,\n nestedAst.orderBy,\n lastTable,\n )}`\n : sql``\n } ${orderBy(spec, nestedAst.orderBy, lastTable)} ${limit(\n last(participatingTables)?.limit,\n format?.singular,\n )} ) ${sql.ident(innerAlias)}\n ) as ${sql.ident(relationship.subquery.alias)}`;\n }\n\n return sql`(\n SELECT ${toJSON(innerAlias, format?.singular)} FROM (${select(\n spec,\n relationship.subquery,\n format,\n makeCorrelator(\n spec,\n relationship.correlation.parentField.map(f => ({\n table: parentTable,\n zql: f,\n })),\n relationship.correlation.childField,\n ),\n )}) ${sql.ident(innerAlias)}\n ) as ${sql.ident(relationship.subquery.alias)}`;\n}\n\nfunction where(\n spec: Spec,\n condition: Condition | undefined,\n table: Table,\n): SQLQuery {\n if (!condition) {\n return sql``;\n }\n\n switch (condition.type) {\n case 'and':\n return sql`(${sql.join(\n condition.conditions.map(c => where(spec, c, table)),\n ' AND ',\n )})`;\n case 'or':\n return sql`(${sql.join(\n condition.conditions.map(c => where(spec, c, table)),\n ' OR ',\n )})`;\n case 'correlatedSubquery':\n if (condition.scalar) {\n return scalarSubquery(spec, condition, table);\n }\n return exists(spec, condition, table);\n case 'simple':\n return simple(spec, condition, table);\n }\n}\n\nfunction exists(\n spec: Spec,\n condition: CorrelatedSubqueryCondition,\n parentTable: Table,\n): SQLQuery {\n switch (condition.op) {\n case 'EXISTS':\n return sql`EXISTS (${select(\n spec,\n condition.related.subquery,\n undefined,\n makeCorrelator(\n spec,\n condition.related.correlation.parentField.map(f => ({\n table: parentTable,\n zql: f,\n })),\n condition.related.correlation.childField,\n ),\n )})`;\n case 'NOT EXISTS':\n return sql`NOT EXISTS (${select(\n spec,\n condition.related.subquery,\n undefined,\n makeCorrelator(\n spec,\n condition.related.correlation.parentField.map(f => ({\n table: parentTable,\n zql: f,\n })),\n condition.related.correlation.childField,\n ),\n )})`;\n }\n}\n\nfunction scalarSubquery(\n spec: Spec,\n condition: CorrelatedSubqueryCondition,\n parentTable: Table,\n): SQLQuery {\n const parentField = condition.related.correlation.parentField[0];\n const childField = condition.related.correlation.childField[0];\n const subqueryAST = condition.related.subquery;\n\n const parentCol = colIdent(spec.server, {\n table: parentTable,\n zql: parentField,\n });\n\n const subqueryTable = makeTable(spec, subqueryAST.table);\n const childCol = colIdent(spec.server, {\n table: subqueryTable,\n zql: childField,\n });\n\n const op = sql.__dangerous__rawValue(\n condition.op === 'EXISTS' ? '=' : 'IS NOT',\n );\n\n const subqueryConditions = subqueryAST.where\n ? [where(spec, subqueryAST.where, subqueryTable)]\n : [];\n if (subqueryAST.start) {\n subqueryConditions.push(\n start(spec, subqueryAST.start, subqueryAST.orderBy, subqueryTable),\n );\n }\n const subqueryOrderBy = orderBy(spec, subqueryAST.orderBy, subqueryTable);\n\n return sql`${parentCol} ${op} (SELECT ${childCol} FROM ${fromIdent(spec.server, subqueryTable)} ${\n subqueryConditions.length > 0\n ? sql`WHERE ${sql.join(subqueryConditions, ' AND ')}`\n : sql``\n } ${subqueryOrderBy} LIMIT 1)`;\n}\n\nexport function makeCorrelator(\n spec: Spec,\n parentFields: readonly QualifiedColumn[],\n childZqlFields: readonly string[],\n): (childTable: Table) => SQLQuery {\n return (childTable: Table) => {\n const childFields = childZqlFields.map(zqlField => ({\n table: childTable,\n zql: zqlField,\n }));\n return sql.join(\n zip(parentFields, childFields).map(\n ([parentColumn, childColumn]) =>\n sql`${colIdent(spec.server, parentColumn)} = ${colIdent(\n spec.server,\n childColumn,\n )}`,\n ),\n ' AND ',\n );\n };\n}\n\nexport function simple(\n spec: Spec,\n condition: SimpleCondition,\n table: Table,\n): SQLQuery {\n switch (condition.op) {\n case '!=':\n case '<':\n case '<=':\n case '=':\n case '>':\n case '>=':\n case 'ILIKE':\n case 'LIKE':\n case 'NOT ILIKE':\n case 'NOT LIKE':\n return sql`${valueComparison(\n spec,\n condition.left,\n table,\n condition.right,\n false,\n )} ${sql.__dangerous__rawValue(condition.op)} ${valueComparison(\n spec,\n condition.right,\n table,\n condition.left,\n false,\n )}`;\n case 'NOT IN':\n case 'IN':\n return any(spec, condition, table);\n case 'IS':\n case 'IS NOT':\n return distinctFrom(spec, condition, table);\n }\n}\n\nexport function any(\n spec: Spec,\n condition: SimpleCondition,\n table: Table,\n): SQLQuery {\n return sql`${condition.op === 'NOT IN' ? sql`NOT` : sql``}\n (\n ${valueComparison(spec, condition.left, table, condition.right, false)} = ANY \n (${valueComparison(spec, condition.right, table, condition.left, true)})\n )`;\n}\n\nexport function distinctFrom(\n spec: Spec,\n condition: SimpleCondition,\n table: Table,\n): SQLQuery {\n return sql`${valueComparison(spec, condition.left, table, condition.right, false)} ${\n condition.op === 'IS' ? sql`IS NOT DISTINCT FROM` : sql`IS DISTINCT FROM`\n } ${valueComparison(spec, condition.right, table, condition.left, false)}`;\n}\n\nfunction startEquality(\n spec: Spec,\n table: Table,\n field: string,\n value: unknown,\n): SQLQuery {\n return sql`${colIdent(spec.server, {\n table,\n zql: field,\n })} IS NOT DISTINCT FROM ${startValue(spec, table, field, value)}`;\n}\n\nfunction startRangeComparison(\n spec: Spec,\n table: Table,\n field: string,\n value: unknown,\n operator: '>' | '<',\n): SQLQuery {\n const column = colIdent(spec.server, {table, zql: field});\n if (value === null) {\n return operator === '>' ? sql`${column} IS NOT NULL` : sql`FALSE`;\n }\n const typedValue = startValue(spec, table, field, value);\n return operator === '>'\n ? sql`${column} > ${typedValue}`\n : sql`(${column} IS NULL OR ${column} < ${typedValue})`;\n}\n\nfunction startValue(\n spec: Spec,\n table: Table,\n field: string,\n value: unknown,\n): SQLQuery {\n return sqlConvertColumnArg(\n getServerColumn(spec.server, table, field),\n value,\n false,\n true,\n );\n}\n\nfunction valueComparison(\n spec: Spec,\n valuePos: ValuePosition,\n table: Table,\n otherValuePos: ValuePosition,\n plural: boolean,\n): SQLQuery {\n const valuePosType = valuePos.type;\n switch (valuePosType) {\n case 'column': {\n const qualified: QualifiedColumn = {\n table,\n zql: valuePos.name,\n };\n return colIdent(spec.server, qualified);\n }\n case 'literal':\n return literalValueComparison(\n spec,\n valuePos,\n table,\n otherValuePos,\n plural,\n );\n case 'static':\n throw new Error(\n 'Static parameters must be bound to a value before compiling to SQL',\n );\n default:\n unreachable(valuePosType);\n break;\n }\n}\n\nfunction literalValueComparison(\n spec: Spec,\n valuePos: LiteralReference,\n table: Table,\n otherValuePos: ValuePosition,\n plural: boolean,\n): SQLQuery {\n const otherType = otherValuePos.type;\n switch (otherType) {\n case 'column':\n return sqlConvertColumnArg(\n getServerColumn(spec.server, table, otherValuePos.name),\n valuePos.value,\n plural,\n true,\n );\n case 'literal': {\n assert(\n plural === Array.isArray(valuePos.value),\n 'Expected plural flag to match whether value is an array',\n );\n if (Array.isArray(valuePos.value)) {\n if (valuePos.value.length > 0) {\n // If the array is non-empty base its type on its first\n // element\n return sqlConvertPluralLiteralArg(\n typeof valuePos.value[0] as PluralLiteralType,\n valuePos.value as PluralLiteralType[],\n );\n }\n // If the array is empty, base its type on the other value\n // position's type (as long as the other value position is non-null,\n // cannot have a null[]).\n if (otherValuePos.value !== null) {\n return sqlConvertPluralLiteralArg(\n typeof otherValuePos.value as PluralLiteralType,\n [],\n );\n }\n // If the other value position is null, it can be compared to any\n // type of empty array, chose 'string' arbitrarily.\n return sqlConvertPluralLiteralArg('string', []);\n }\n if (\n typeof valuePos.value === 'string' ||\n typeof valuePos.value === 'number' ||\n typeof valuePos.value === 'boolean'\n ) {\n return sqlConvertSingularLiteralArg(valuePos.value);\n }\n throw new Error(\n `Literal of unexpected type. ${valuePos.value} of type ${typeof valuePos.value}`,\n );\n }\n case 'static':\n throw new Error(\n 'Static parameters must be bound to a value before compiling to SQL',\n );\n default:\n unreachable(otherType);\n }\n}\n\nexport function makeJunctionJoin(\n spec: Spec,\n relationship: CorrelatedSubquery,\n): {\n join: SQLQuery;\n participatingTables: ReturnType<typeof pullTablesForJunction>;\n} {\n const participatingTables = pullTablesForJunction(spec, relationship);\n const joins: SQLQuery[] = [];\n\n for (const {table} of participatingTables) {\n if (joins.length === 0) {\n joins.push(fromIdent(spec.server, table));\n continue;\n }\n joins.push(\n sql` JOIN ${fromIdent(spec.server, table)} ON ${makeCorrelator(\n spec,\n participatingTables[joins.length].correlation.parentField.map(f => ({\n table: participatingTables[joins.length - 1].table,\n zql: f,\n })),\n participatingTables[joins.length].correlation.childField,\n )(participatingTables[joins.length].table)}`,\n );\n }\n\n return {\n join: sql`${sql.join(joins, '')}`,\n participatingTables,\n // lastTable: participatingTables[participatingTables.length - 1].table,\n // lastLimit: participatingTables[participatingTables.length - 1].limit,\n };\n}\n\nexport function pullTablesForJunction(\n spec: Spec,\n relationship: CorrelatedSubquery,\n): [\n {\n table: Table;\n correlation: Correlation;\n limit: number | undefined;\n },\n {table: Table; correlation: Correlation; limit: number | undefined},\n] {\n assert(\n relationship.subquery.related?.length === 1,\n 'Too many related tables for a junction edge',\n );\n const otherRelationship = relationship.subquery.related[0];\n assert(\n !otherRelationship.hidden,\n 'Expected junction edge relationship to not be hidden',\n );\n return [\n {\n table: makeTable(spec, relationship.subquery.table),\n correlation: relationship.correlation,\n limit: relationship.subquery.limit,\n },\n {\n table: makeTable(spec, otherRelationship.subquery.table),\n correlation: otherRelationship.correlation,\n limit: otherRelationship.subquery.limit,\n },\n ];\n}\n\nfunction toJSON(table: string, singular = false): SQLQuery {\n return sql`${\n singular ? sql`` : sql`COALESCE(json_agg`\n }(row_to_json(${sql.ident(table)}))${singular ? sql`` : sql`, '[]'::json)`}`;\n}\n\nfunction selectIdent(server: ServerSpec, column: QualifiedColumn): SQLQuery {\n const serverColumnSchema =\n server.schema[server.mapper.tableName(column.table.zql)][\n server.mapper.columnName(column.table.zql, column.zql)\n ];\n const serverType = serverColumnSchema.type;\n if (!serverColumnSchema.isEnum) {\n let needsNormalization = false;\n switch (serverType) {\n case 'timestamptz':\n // @ts-expect-error Fallthrough intended\n case 'timetz':\n needsNormalization = true;\n // fallthrough\n\n case 'date':\n case 'time':\n case 'time without time zone':\n case 'time with time zone':\n case 'timestamp':\n case 'timestamp without time zone':\n case 'timestamp with time zone': {\n // EXTRACT(EPOCH FROM timetz) can be negative when the UTC offset is\n // positive (e.g. 01:00+02 = 23:00 UTC prev day = -3600s). Wrap with\n // modular arithmetic to normalize to 0..86400000.\n const toMs = (epochExpr: SQLQuery): SQLQuery =>\n needsNormalization\n ? sql`((${epochExpr})::bigint + 86400000) % 86400000`\n : epochExpr;\n\n if (serverColumnSchema.isArray) {\n const col = colIdent(server, column);\n return sql`CASE WHEN ${col} IS NULL THEN NULL ELSE ARRAY(SELECT ${toMs(\n sql`EXTRACT(EPOCH FROM unnest(${col})) * 1000`,\n )}) END as ${sql.ident(column.zql)}`;\n }\n\n return sql`${toMs(\n sql`EXTRACT(EPOCH FROM ${colIdent(server, column)}) * 1000`,\n )} as ${sql.ident(column.zql)}`;\n }\n }\n }\n\n return sql`${colIdent(server, column)} as ${sql.ident(column.zql)}`;\n}\n\nfunction colIdent(server: ServerSpec, column: QualifiedColumn) {\n return sql.ident(\n column.table.alias,\n server.mapper.columnName(column.table.zql, column.zql),\n );\n}\n\nfunction fromIdent(server: ServerSpec, table: Table) {\n return sql`${sql.ident(server.mapper.tableName(table.zql))} AS ${sql.ident(table.alias)}`;\n}\n\nfunction getServerColumn(spec: ServerSpec, table: Table, zqlColumn: string) {\n return spec.schema[spec.mapper.tableName(table.zql)][\n spec.mapper.columnName(table.zql, zqlColumn)\n ];\n}\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport function extractZqlResult(pgResult: Array<any>): JSONValue {\n const bigIntJson: BigIntJSONValue = parseBigIntJson(\n pgResult[0][ZQL_RESULT_KEY],\n );\n assertJSONValue(bigIntJson);\n return bigIntJson;\n}\n\nfunction assertJSONValue(v: BigIntJSONValue): asserts v is JSONValue {\n const path = findPathToBigInt(v);\n if (path) {\n throw new Error(`Value exceeds safe Number range. ${path}`);\n }\n}\n\nfunction findPathToBigInt(v: BigIntJSONValue): string | undefined {\n const typeOfV = typeof v;\n switch (typeOfV) {\n case 'bigint':\n return ` = ${v}`;\n case 'object': {\n if (v === null) {\n return;\n }\n if (Array.isArray(v)) {\n for (let i = 0; i < v.length; i++) {\n const path = findPathToBigInt(v[i]);\n if (path) {\n return `[${i}]${path}`;\n }\n }\n return undefined;\n }\n\n const o = v as Record<string, BigIntJSONValue>;\n for (const k in o) {\n if (hasOwn(o, k)) {\n const path = findPathToBigInt(o[k]);\n if (path) {\n return `['${k}']${path}`;\n }\n }\n }\n return undefined;\n }\n case 'number':\n return undefined;\n case 'boolean':\n return undefined;\n default:\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;AA4DA,IAAM,iBAAiB;AACvB,IAAM,uBAAuB,IAAI,MAAM,cAAc;AAErD,IAAM,uBAAuB;AAC7B,IAAM,yBAAyB,I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MAAM,KAAK;AACxF;AAEA,SAAS,gBAAgB,MAAkB,OAAc,WAAmB;CAC1E,OAAO,KAAK,OAAO,KAAK,OAAO,UAAU,MAAM,GAAG,GAChD,KAAK,OAAO,WAAW,MAAM,KAAK,SAAS;AAE/C;AAGA,SAAgB,iBAAiB,UAAiC;CAChE,MAAM,aAA8B,MAClC,SAAS,GAAG,eACd;CACA,gBAAgB,UAAU;CAC1B,OAAO;AACT;AAEA,SAAS,gBAAgB,GAA4C;CACnE,MAAM,OAAO,iBAAiB,CAAC;CAC/B,IAAI,MACF,MAAM,IAAI,MAAM,oCAAoC,MAAM;AAE9D;AAEA,SAAS,iBAAiB,GAAwC;CAEhE,QAAQ,OADe,GACvB;EACE,KAAK,UACH,OAAO,MAAM;EACf,KAAK,UAAU;GACb,IAAI,MAAM,MACR;GAEF,IAAI,MAAM,QAAQ,CAAC,GAAG;IACpB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;KACjC,MAAM,OAAO,iBAAiB,EAAE,EAAE;KAClC,IAAI,MACF,OAAO,IAAI,EAAE,GAAG;IAEpB;IACA;GACF;GAEA,MAAM,IAAI;GACV,KAAK,MAAM,KAAK,GACd,IAAI,OAAO,GAAG,CAAC,GAAG;IAChB,MAAM,OAAO,iBAAiB,EAAE,EAAE;IAClC,IAAI,MACF,OAAO,KAAK,EAAE,IAAI;GAEtB;GAEF;EACF;EACA,KAAK,UACH;EACF,KAAK,WACH;EACF,SACE;CACJ;AACF"}
1
+ {"version":3,"file":"compiler.js","names":[],"sources":["../../../../z2s/src/compiler.ts"],"sourcesContent":["import type {SQLQuery} from '@databases/sql';\nimport {last, zip} from '../../shared/src/arrays.ts';\nimport {assert, unreachable} from '../../shared/src/asserts.ts';\nimport {\n parse as parseBigIntJson,\n type JSONValue as BigIntJSONValue,\n} from '../../shared/src/bigint-json.ts';\nimport {hasOwn} from '../../shared/src/has-own.ts';\nimport {type JSONValue} from '../../shared/src/json.ts';\nimport {must} from '../../shared/src/must.ts';\nimport type {\n AST,\n Bound,\n Condition,\n CorrelatedSubquery,\n CorrelatedSubqueryCondition,\n Correlation,\n LiteralReference,\n Ordering,\n SimpleCondition,\n ValuePosition,\n} from '../../zero-protocol/src/ast.ts';\nimport {\n clientToServer,\n type NameMapper,\n} from '../../zero-schema/src/name-mapper.ts';\nimport type {Schema} from '../../zero-types/src/schema.ts';\nimport type {ServerSchema} from '../../zero-types/src/server-schema.ts';\nimport type {Format} from '../../zql/src/ivm/view.ts';\nimport {completeOrdering} from '../../zql/src/query/complete-ordering.ts';\nimport {\n sql,\n sqlConvertColumnArg,\n sqlConvertPluralLiteralArg,\n sqlConvertSingularLiteralArg,\n type PluralLiteralType,\n} from './sql.ts';\n\ntype Table = {\n zql: string;\n alias: string;\n};\n\ntype QualifiedColumn = {\n table: Table;\n zql: string;\n};\n\ntype ServerSpec = {\n schema: ServerSchema;\n // maps zql names to server names\n mapper: NameMapper;\n};\n\nexport type Spec = {\n server: ServerSpec;\n zql: Schema['tables'];\n aliasCount: number;\n};\n\nconst ZQL_RESULT_KEY = 'zql_result';\nconst ZQL_RESULT_KEY_IDENT = sql.ident(ZQL_RESULT_KEY);\n\nconst ZQL_RESULT_TABLE_KEY = 'zql_root';\nconst ZQL_RESULT_TABLE_IDENT = sql.ident(ZQL_RESULT_TABLE_KEY);\n\nexport function compile(\n serverSchema: ServerSchema,\n zqlSchema: Schema,\n ast: AST,\n format?: Format,\n): SQLQuery {\n ast = completeOrdering(\n ast,\n tableName => zqlSchema.tables[tableName].primaryKey,\n );\n const spec: Spec = {\n aliasCount: 0,\n server: {\n schema: serverSchema,\n mapper: clientToServer(zqlSchema.tables),\n },\n zql: zqlSchema.tables,\n };\n return sql`SELECT \n ${toJSON(ZQL_RESULT_TABLE_KEY, format?.singular)}::text AS ${ZQL_RESULT_KEY_IDENT}\n FROM (${select(spec, ast, format)}) ${ZQL_RESULT_TABLE_IDENT}`;\n}\n\nfunction select(\n spec: Spec,\n ast: AST,\n format: Format | undefined,\n correlate?: (childTable: Table) => SQLQuery,\n): SQLQuery {\n const table = makeTable(spec, ast.table);\n const selectionSet = related(spec, ast.related ?? [], format, table);\n const tableSchema = spec.zql[ast.table];\n const usedAliases = new Set<string>(\n ast.related?.map(r => r.subquery.alias ?? ''),\n );\n for (const column of Object.keys(tableSchema.columns)) {\n if (!usedAliases.has(column)) {\n selectionSet.push(\n selectIdent(spec.server, {\n table,\n zql: column,\n }),\n );\n }\n }\n\n let appliedWhere = false;\n function maybeWhere(test: unknown) {\n if (!test) {\n return sql``;\n }\n\n const ret = appliedWhere ? sql`AND` : sql`WHERE`;\n appliedWhere = true;\n return ret;\n }\n\n return sql`SELECT ${sql.join(selectionSet, ',')}\n FROM ${fromIdent(spec.server, table)}\n ${maybeWhere(ast.where)} ${where(spec, ast.where, table)}${\n ast.start\n ? sql`\n ${maybeWhere(ast.start)} ${start(spec, ast.start, ast.orderBy, table)}`\n : sql``\n }\n ${maybeWhere(correlate)} ${correlate ? correlate(table) : sql``}\n ${orderBy(spec, ast.orderBy, table)}\n ${limit(ast.limit, format?.singular)}`;\n}\n\nexport function limit(\n limit: number | undefined,\n singular: boolean | undefined,\n): SQLQuery {\n if (limit === 0) {\n return sql`LIMIT 0`;\n }\n if (singular) {\n return sql`LIMIT 1`;\n }\n if (limit === undefined) {\n return sql``;\n }\n return sql`LIMIT ${sqlConvertSingularLiteralArg(limit)}`;\n}\n\nfunction makeTable(spec: Spec, zql: string, alias?: string): Table {\n alias = alias ?? zql + '_' + spec.aliasCount++;\n return {\n zql,\n alias,\n };\n}\n\nexport function orderBy(\n spec: Spec,\n orderBy: Ordering | undefined,\n table: Table,\n): SQLQuery {\n if (!orderBy) {\n return sql``;\n }\n return sql`ORDER BY ${sql.join(\n orderBy.map(([col, dir]) =>\n dir === 'asc'\n ? // Oh postgres. The table must be referred to by client name but the column by server name.\n // E.g., `SELECT server_col as client_col FROM server_table as client_table ORDER BY client_Table.server_col`\n sql`${colIdent(spec.server, {\n table,\n zql: col,\n })} ASC NULLS FIRST`\n : sql`${colIdent(spec.server, {\n table,\n zql: col,\n })} DESC NULLS LAST`,\n ),\n ', ',\n )}`;\n}\n\nexport function start(\n spec: Spec,\n bound: Bound | undefined,\n orderBy: Ordering | undefined,\n table: Table,\n): SQLQuery {\n if (!bound) {\n return sql``;\n }\n assert(\n orderBy !== undefined && orderBy.length > 0,\n 'start requires ordering',\n );\n\n const constraints: SQLQuery[] = [];\n for (let i = 0; i < orderBy.length; i++) {\n const group: SQLQuery[] = [];\n const [iField, iDirection] = orderBy[i];\n for (let j = 0; j <= i; j++) {\n const [field] = orderBy[j];\n if (j === i) {\n group.push(\n startRangeComparison(\n spec,\n table,\n iField,\n bound.row[iField] ?? null,\n iDirection === 'asc' ? '>' : '<',\n ),\n );\n } else {\n group.push(startEquality(spec, table, field, bound.row[field] ?? null));\n }\n }\n constraints.push(sql`(${sql.join(group, ' AND ')})`);\n }\n\n if (!bound.exclusive) {\n constraints.push(\n sql`(${sql.join(\n orderBy.map(([field]) =>\n startEquality(spec, table, field, bound.row[field] ?? null),\n ),\n ' AND ',\n )})`,\n );\n }\n\n return sql`(${sql.join(constraints, ' OR ')})`;\n}\n\nfunction related(\n spec: Spec,\n relationships: readonly CorrelatedSubquery[],\n format: Format | undefined,\n parentTable: Table,\n): SQLQuery[] {\n return relationships.map(relationship =>\n relationshipSubquery(\n spec,\n relationship,\n format?.relationships[must(relationship.subquery.alias)],\n parentTable,\n ),\n );\n}\n\nfunction relationshipSubquery(\n spec: Spec,\n relationship: CorrelatedSubquery,\n format: Format | undefined,\n parentTable: Table,\n): SQLQuery {\n const innerAlias = `inner_${relationship.subquery.alias}`;\n if (relationship.hidden) {\n const {join, participatingTables} = makeJunctionJoin(spec, relationship);\n const lastTable = must(last(participatingTables)).table;\n\n assert(\n relationship.subquery.related,\n 'hidden relationship must be a junction',\n );\n const nestedAst = relationship.subquery.related[0].subquery;\n const selectionSet = related(\n spec,\n nestedAst.related ?? [],\n format,\n lastTable,\n );\n const tableSchema = spec.zql[nestedAst.table];\n for (const column of Object.keys(tableSchema.columns)) {\n selectionSet.push(\n selectIdent(spec.server, {\n table: lastTable,\n zql: column,\n }),\n );\n }\n\n return sql`(\n SELECT ${toJSON(innerAlias, format?.singular)} FROM (SELECT ${sql.join(\n selectionSet,\n ',',\n )} FROM ${join} WHERE (${makeCorrelator(\n spec,\n relationship.correlation.parentField.map(f => ({\n table: parentTable,\n zql: f,\n })),\n relationship.correlation.childField,\n )(participatingTables[0].table)}) ${\n nestedAst.where\n ? sql`AND ${where(spec, nestedAst.where, lastTable)}`\n : sql``\n }${\n nestedAst.start\n ? sql` AND ${start(\n spec,\n nestedAst.start,\n nestedAst.orderBy,\n lastTable,\n )}`\n : sql``\n } ${orderBy(spec, nestedAst.orderBy, lastTable)} ${limit(\n last(participatingTables)?.limit,\n format?.singular,\n )} ) ${sql.ident(innerAlias)}\n ) as ${sql.ident(relationship.subquery.alias)}`;\n }\n\n return sql`(\n SELECT ${toJSON(innerAlias, format?.singular)} FROM (${select(\n spec,\n relationship.subquery,\n format,\n makeCorrelator(\n spec,\n relationship.correlation.parentField.map(f => ({\n table: parentTable,\n zql: f,\n })),\n relationship.correlation.childField,\n ),\n )}) ${sql.ident(innerAlias)}\n ) as ${sql.ident(relationship.subquery.alias)}`;\n}\n\nfunction where(\n spec: Spec,\n condition: Condition | undefined,\n table: Table,\n): SQLQuery {\n if (!condition) {\n return sql``;\n }\n\n switch (condition.type) {\n case 'and':\n return sql`(${sql.join(\n condition.conditions.map(c => where(spec, c, table)),\n ' AND ',\n )})`;\n case 'or':\n return sql`(${sql.join(\n condition.conditions.map(c => where(spec, c, table)),\n ' OR ',\n )})`;\n case 'correlatedSubquery':\n // `scalar` is deliberately ignored here. It is a planner hint for the\n // IVM engines, which have no cost-based planner and benefit from\n // pre-resolving an at-most-one-row subquery to a literal comparison\n // (see zqlite's `resolveSimpleScalarSubqueries`). Postgres decorrelates\n // EXISTS into a semi-join on its own, so the hint buys nothing here —\n // and honoring it as `parentField = (SELECT childField … LIMIT 1)` is\n // only sound when the subquery matches at most one row *globally*.\n // Applying it unconditionally silently dropped rows whenever the\n // subquery was not pinned to a unique key.\n return exists(spec, condition, table);\n case 'simple':\n return simple(spec, condition, table);\n }\n}\n\nfunction exists(\n spec: Spec,\n condition: CorrelatedSubqueryCondition,\n parentTable: Table,\n): SQLQuery {\n switch (condition.op) {\n case 'EXISTS':\n return sql`EXISTS (${select(\n spec,\n condition.related.subquery,\n undefined,\n makeCorrelator(\n spec,\n condition.related.correlation.parentField.map(f => ({\n table: parentTable,\n zql: f,\n })),\n condition.related.correlation.childField,\n ),\n )})`;\n case 'NOT EXISTS':\n return sql`NOT EXISTS (${select(\n spec,\n condition.related.subquery,\n undefined,\n makeCorrelator(\n spec,\n condition.related.correlation.parentField.map(f => ({\n table: parentTable,\n zql: f,\n })),\n condition.related.correlation.childField,\n ),\n )})`;\n }\n}\n\nexport function makeCorrelator(\n spec: Spec,\n parentFields: readonly QualifiedColumn[],\n childZqlFields: readonly string[],\n): (childTable: Table) => SQLQuery {\n return (childTable: Table) => {\n const childFields = childZqlFields.map(zqlField => ({\n table: childTable,\n zql: zqlField,\n }));\n return sql.join(\n zip(parentFields, childFields).map(\n ([parentColumn, childColumn]) =>\n sql`${colIdent(spec.server, parentColumn)} = ${colIdent(\n spec.server,\n childColumn,\n )}`,\n ),\n ' AND ',\n );\n };\n}\n\nexport function simple(\n spec: Spec,\n condition: SimpleCondition,\n table: Table,\n): SQLQuery {\n switch (condition.op) {\n case '!=':\n case '<':\n case '<=':\n case '=':\n case '>':\n case '>=':\n case 'ILIKE':\n case 'LIKE':\n case 'NOT ILIKE':\n case 'NOT LIKE':\n return sql`${valueComparison(\n spec,\n condition.left,\n table,\n condition.right,\n false,\n )} ${sql.__dangerous__rawValue(condition.op)} ${valueComparison(\n spec,\n condition.right,\n table,\n condition.left,\n false,\n )}`;\n case 'NOT IN':\n case 'IN':\n return any(spec, condition, table);\n case 'IS':\n case 'IS NOT':\n return distinctFrom(spec, condition, table);\n }\n}\n\nexport function any(\n spec: Spec,\n condition: SimpleCondition,\n table: Table,\n): SQLQuery {\n return sql`${condition.op === 'NOT IN' ? sql`NOT` : sql``}\n (\n ${valueComparison(spec, condition.left, table, condition.right, false)} = ANY \n (${valueComparison(spec, condition.right, table, condition.left, true)})\n )`;\n}\n\nexport function distinctFrom(\n spec: Spec,\n condition: SimpleCondition,\n table: Table,\n): SQLQuery {\n return sql`${valueComparison(spec, condition.left, table, condition.right, false)} ${\n condition.op === 'IS' ? sql`IS NOT DISTINCT FROM` : sql`IS DISTINCT FROM`\n } ${valueComparison(spec, condition.right, table, condition.left, false)}`;\n}\n\nfunction startEquality(\n spec: Spec,\n table: Table,\n field: string,\n value: unknown,\n): SQLQuery {\n return sql`${colIdent(spec.server, {\n table,\n zql: field,\n })} IS NOT DISTINCT FROM ${startValue(spec, table, field, value)}`;\n}\n\nfunction startRangeComparison(\n spec: Spec,\n table: Table,\n field: string,\n value: unknown,\n operator: '>' | '<',\n): SQLQuery {\n const column = colIdent(spec.server, {table, zql: field});\n if (value === null) {\n return operator === '>' ? sql`${column} IS NOT NULL` : sql`FALSE`;\n }\n const typedValue = startValue(spec, table, field, value);\n return operator === '>'\n ? sql`${column} > ${typedValue}`\n : sql`(${column} IS NULL OR ${column} < ${typedValue})`;\n}\n\nfunction startValue(\n spec: Spec,\n table: Table,\n field: string,\n value: unknown,\n): SQLQuery {\n return sqlConvertColumnArg(\n getServerColumn(spec.server, table, field),\n value,\n false,\n true,\n );\n}\n\nfunction valueComparison(\n spec: Spec,\n valuePos: ValuePosition,\n table: Table,\n otherValuePos: ValuePosition,\n plural: boolean,\n): SQLQuery {\n const valuePosType = valuePos.type;\n switch (valuePosType) {\n case 'column': {\n const qualified: QualifiedColumn = {\n table,\n zql: valuePos.name,\n };\n return colIdent(spec.server, qualified);\n }\n case 'literal':\n return literalValueComparison(\n spec,\n valuePos,\n table,\n otherValuePos,\n plural,\n );\n case 'static':\n throw new Error(\n 'Static parameters must be bound to a value before compiling to SQL',\n );\n default:\n unreachable(valuePosType);\n break;\n }\n}\n\nfunction literalValueComparison(\n spec: Spec,\n valuePos: LiteralReference,\n table: Table,\n otherValuePos: ValuePosition,\n plural: boolean,\n): SQLQuery {\n const otherType = otherValuePos.type;\n switch (otherType) {\n case 'column':\n return sqlConvertColumnArg(\n getServerColumn(spec.server, table, otherValuePos.name),\n valuePos.value,\n plural,\n true,\n );\n case 'literal': {\n assert(\n plural === Array.isArray(valuePos.value),\n 'Expected plural flag to match whether value is an array',\n );\n if (Array.isArray(valuePos.value)) {\n if (valuePos.value.length > 0) {\n // If the array is non-empty base its type on its first\n // element\n return sqlConvertPluralLiteralArg(\n typeof valuePos.value[0] as PluralLiteralType,\n valuePos.value as PluralLiteralType[],\n );\n }\n // If the array is empty, base its type on the other value\n // position's type (as long as the other value position is non-null,\n // cannot have a null[]).\n if (otherValuePos.value !== null) {\n return sqlConvertPluralLiteralArg(\n typeof otherValuePos.value as PluralLiteralType,\n [],\n );\n }\n // If the other value position is null, it can be compared to any\n // type of empty array, chose 'string' arbitrarily.\n return sqlConvertPluralLiteralArg('string', []);\n }\n if (\n typeof valuePos.value === 'string' ||\n typeof valuePos.value === 'number' ||\n typeof valuePos.value === 'boolean'\n ) {\n return sqlConvertSingularLiteralArg(valuePos.value);\n }\n throw new Error(\n `Literal of unexpected type. ${valuePos.value} of type ${typeof valuePos.value}`,\n );\n }\n case 'static':\n throw new Error(\n 'Static parameters must be bound to a value before compiling to SQL',\n );\n default:\n unreachable(otherType);\n }\n}\n\nexport function makeJunctionJoin(\n spec: Spec,\n relationship: CorrelatedSubquery,\n): {\n join: SQLQuery;\n participatingTables: ReturnType<typeof pullTablesForJunction>;\n} {\n const participatingTables = pullTablesForJunction(spec, relationship);\n const joins: SQLQuery[] = [];\n\n for (const {table} of participatingTables) {\n if (joins.length === 0) {\n joins.push(fromIdent(spec.server, table));\n continue;\n }\n joins.push(\n sql` JOIN ${fromIdent(spec.server, table)} ON ${makeCorrelator(\n spec,\n participatingTables[joins.length].correlation.parentField.map(f => ({\n table: participatingTables[joins.length - 1].table,\n zql: f,\n })),\n participatingTables[joins.length].correlation.childField,\n )(participatingTables[joins.length].table)}`,\n );\n }\n\n return {\n join: sql`${sql.join(joins, '')}`,\n participatingTables,\n // lastTable: participatingTables[participatingTables.length - 1].table,\n // lastLimit: participatingTables[participatingTables.length - 1].limit,\n };\n}\n\nexport function pullTablesForJunction(\n spec: Spec,\n relationship: CorrelatedSubquery,\n): [\n {\n table: Table;\n correlation: Correlation;\n limit: number | undefined;\n },\n {table: Table; correlation: Correlation; limit: number | undefined},\n] {\n assert(\n relationship.subquery.related?.length === 1,\n 'Too many related tables for a junction edge',\n );\n const otherRelationship = relationship.subquery.related[0];\n assert(\n !otherRelationship.hidden,\n 'Expected junction edge relationship to not be hidden',\n );\n return [\n {\n table: makeTable(spec, relationship.subquery.table),\n correlation: relationship.correlation,\n limit: relationship.subquery.limit,\n },\n {\n table: makeTable(spec, otherRelationship.subquery.table),\n correlation: otherRelationship.correlation,\n limit: otherRelationship.subquery.limit,\n },\n ];\n}\n\nfunction toJSON(table: string, singular = false): SQLQuery {\n return sql`${\n singular ? sql`` : sql`COALESCE(json_agg`\n }(row_to_json(${sql.ident(table)}))${singular ? sql`` : sql`, '[]'::json)`}`;\n}\n\nfunction selectIdent(server: ServerSpec, column: QualifiedColumn): SQLQuery {\n const serverColumnSchema =\n server.schema[server.mapper.tableName(column.table.zql)][\n server.mapper.columnName(column.table.zql, column.zql)\n ];\n const serverType = serverColumnSchema.type;\n if (!serverColumnSchema.isEnum) {\n let needsNormalization = false;\n switch (serverType) {\n case 'timestamptz':\n // @ts-expect-error Fallthrough intended\n case 'timetz':\n needsNormalization = true;\n // fallthrough\n\n case 'date':\n case 'time':\n case 'time without time zone':\n case 'time with time zone':\n case 'timestamp':\n case 'timestamp without time zone':\n case 'timestamp with time zone': {\n // EXTRACT(EPOCH FROM timetz) can be negative when the UTC offset is\n // positive (e.g. 01:00+02 = 23:00 UTC prev day = -3600s). Wrap with\n // modular arithmetic to normalize to 0..86400000.\n const toMs = (epochExpr: SQLQuery): SQLQuery =>\n needsNormalization\n ? sql`((${epochExpr})::bigint + 86400000) % 86400000`\n : epochExpr;\n\n if (serverColumnSchema.isArray) {\n const col = colIdent(server, column);\n return sql`CASE WHEN ${col} IS NULL THEN NULL ELSE ARRAY(SELECT ${toMs(\n sql`EXTRACT(EPOCH FROM unnest(${col})) * 1000`,\n )}) END as ${sql.ident(column.zql)}`;\n }\n\n return sql`${toMs(\n sql`EXTRACT(EPOCH FROM ${colIdent(server, column)}) * 1000`,\n )} as ${sql.ident(column.zql)}`;\n }\n }\n }\n\n return sql`${colIdent(server, column)} as ${sql.ident(column.zql)}`;\n}\n\nfunction colIdent(server: ServerSpec, column: QualifiedColumn) {\n return sql.ident(\n column.table.alias,\n server.mapper.columnName(column.table.zql, column.zql),\n );\n}\n\nfunction fromIdent(server: ServerSpec, table: Table) {\n return sql`${sql.ident(server.mapper.tableName(table.zql))} AS ${sql.ident(table.alias)}`;\n}\n\nfunction getServerColumn(spec: ServerSpec, table: Table, zqlColumn: string) {\n return spec.schema[spec.mapper.tableName(table.zql)][\n spec.mapper.columnName(table.zql, zqlColumn)\n ];\n}\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport function extractZqlResult(pgResult: Array<any>): JSONValue {\n const bigIntJson: BigIntJSONValue = parseBigIntJson(\n pgResult[0][ZQL_RESULT_KEY],\n );\n assertJSONValue(bigIntJson);\n return bigIntJson;\n}\n\nfunction assertJSONValue(v: BigIntJSONValue): asserts v is JSONValue {\n const path = findPathToBigInt(v);\n if (path) {\n throw new Error(`Value exceeds safe Number range. ${path}`);\n }\n}\n\nfunction findPathToBigInt(v: BigIntJSONValue): string | undefined {\n const typeOfV = typeof v;\n switch (typeOfV) {\n case 'bigint':\n return ` = ${v}`;\n case 'object': {\n if (v === null) {\n return;\n }\n if (Array.isArray(v)) {\n for (let i = 0; i < v.length; i++) {\n const path = findPathToBigInt(v[i]);\n if (path) {\n return `[${i}]${path}`;\n }\n }\n return undefined;\n }\n\n const o = v as Record<string, BigIntJSONValue>;\n for (const k in o) {\n if (hasOwn(o, k)) {\n const path = findPathToBigInt(o[k]);\n if (path) {\n return `['${k}']${path}`;\n }\n }\n }\n return undefined;\n }\n case 'number':\n return undefined;\n case 'boolean':\n return undefined;\n default:\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;AA4DA,IAAM,iBAAiB;AACvB,IAAM,uBAAuB,IAAI,MAAM,cAAc;AAErD,IAAM,uBAAuB;AAC7B,IAAM,yBAAyB,IAAI,MAAM,oBAAoB;AAE7D,SAAgB,QACd,cACA,WACA,KACA,QACU;CACV,MAAM,iBACJ,MACA,cAAa,UAAU,OAAO,WAAW,UAC3C;CACA,MAAM,OAAa;EACjB,YAAY;EACZ,QAAQ;GACN,QAAQ;GACR,QAAQ,eAAe,UAAU,MAAM;EACzC;EACA,KAAK,UAAU;CACjB;CACA,OAAO,GAAG;MACN,OAAO,sBAAsB,QAAQ,QAAQ,EAAE,YAAY,qBAAqB;YAC1E,OAAO,MAAM,KAAK,MAAM,EAAE,IAAI;AAC1C;AAEA,SAAS,OACP,MACA,KACA,QACA,WACU;CACV,MAAM,QAAQ,UAAU,MAAM,IAAI,KAAK;CACvC,MAAM,eAAe,QAAQ,MAAM,IAAI,WAAW,CAAC,GAAG,QAAQ,KAAK;CACnE,MAAM,cAAc,KAAK,IAAI,IAAI;CACjC,MAAM,cAAc,IAAI,IACtB,IAAI,SAAS,KAAI,MAAK,EAAE,SAAS,SAAS,EAAE,CAC9C;CACA,KAAK,MAAM,UAAU,OAAO,KAAK,YAAY,OAAO,GAClD,IAAI,CAAC,YAAY,IAAI,MAAM,GACzB,aAAa,KACX,YAAY,KAAK,QAAQ;EACvB;EACA,KAAK;CACP,CAAC,CACH;CAIJ,IAAI,eAAe;CACnB,SAAS,WAAW,MAAe;EACjC,IAAI,CAAC,MAC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AM;EACf,KAAK,UAAU;GACb,IAAI,MAAM,MACR;GAEF,IAAI,MAAM,QAAQ,CAAC,GAAG;IACpB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;KACjC,MAAM,OAAO,iBAAiB,EAAE,EAAE;KAClC,IAAI,MACF,OAAO,IAAI,EAAE,GAAG;IAEpB;IACA;GACF;GAEA,MAAM,IAAI;GACV,KAAK,MAAM,KAAK,GACd,IAAI,OAAO,GAAG,CAAC,GAAG;IAChB,MAAM,OAAO,iBAAiB,EAAE,EAAE;IAClC,IAAI,MACF,OAAO,KAAK,EAAE,IAAI;GAEtB;GAEF;EACF;EACA,KAAK,UACH;EACF,KAAK,WACH;EACF,SACE;CACJ;AACF"}
@@ -1,6 +1,6 @@
1
1
  var package_default = {
2
2
  name: "@rocicorp/zero",
3
- version: "1.8.0",
3
+ version: "1.9.0-canary.1",
4
4
  description: "Zero is a web framework for serverless web development.",
5
5
  homepage: "https://zero.rocicorp.dev",
6
6
  bugs: { "url": "https://bugs.rocicorp.dev" },
@@ -171,6 +171,7 @@ var package_default = {
171
171
  "analyze-query": "workspace:*",
172
172
  "ast-to-zql": "workspace:*",
173
173
  "expo-sqlite": ">=15",
174
+ "oxc-parser": "^0.129.0",
174
175
  "replicache": "workspace:*",
175
176
  "shared": "workspace:*",
176
177
  "syncpack": "^14.3.0",
@@ -187,24 +188,6 @@ var package_default = {
187
188
  "zero-solid": "workspace:*",
188
189
  "zqlite": "workspace:*"
189
190
  },
190
- peerDependencies: {
191
- "@op-engineering/op-sqlite": ">=15",
192
- "drizzle-orm": "^0.45.2",
193
- "expo-sqlite": ">=15",
194
- "kysely": "^0.28.17",
195
- "pg": "^8.16.3",
196
- "react": "^19.2.6",
197
- "solid-js": "^1.9.4"
198
- },
199
- peerDependenciesMeta: {
200
- "@op-engineering/op-sqlite": { "optional": true },
201
- "drizzle-orm": { "optional": true },
202
- "expo-sqlite": { "optional": true },
203
- "kysely": { "optional": true },
204
- "pg": { "optional": true },
205
- "react": { "optional": true },
206
- "solid-js": { "optional": true }
207
- },
208
191
  engines: { "node": ">=22" },
209
192
  packageManager: "pnpm@11.5.3"
210
193
  };
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@rocicorp/zero\",\n \"version\": \"1.8.0\",\n \"description\": \"Zero is a web framework for serverless web development.\",\n \"homepage\": \"https://zero.rocicorp.dev\",\n \"bugs\": {\n \"url\": \"https://bugs.rocicorp.dev\"\n },\n \"license\": \"Apache-2.0\",\n \"author\": \"Rocicorp, Inc.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/rocicorp/mono.git\",\n \"directory\": \"packages/zero\"\n },\n \"bin\": {\n \"analyze-query\": \"./out/zero/src/analyze-query.js\",\n \"ast-to-zql\": \"./out/zero/src/ast-to-zql.js\",\n \"transform-query\": \"./out/zero/src/transform-query.js\",\n \"zero-build-schema\": \"./out/zero/src/build-schema.js\",\n \"zero-cache\": \"./out/zero/src/cli.js\",\n \"zero-cache-dev\": \"./out/zero/src/zero-cache-dev.js\",\n \"zero-deploy-permissions\": \"./out/zero/src/deploy-permissions.js\",\n \"zero-out\": \"./out/zero/src/zero-out.js\"\n },\n \"files\": [\n \"out\",\n \"!*.tsbuildinfo\"\n ],\n \"type\": \"module\",\n \"main\": \"out/zero/src/zero.js\",\n \"module\": \"out/zero/src/zero.js\",\n \"types\": \"out/zero/src/zero.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./out/zero/src/zero.d.ts\",\n \"default\": \"./out/zero/src/zero.js\"\n },\n \"./analyze\": {\n \"types\": \"./out/zero/src/analyze.d.ts\",\n \"default\": \"./out/zero/src/analyze.js\"\n },\n \"./bindings\": {\n \"types\": \"./out/zero/src/bindings.d.ts\",\n \"default\": \"./out/zero/src/bindings.js\"\n },\n \"./change-protocol/v0\": {\n \"types\": \"./out/zero/src/change-protocol/v0.d.ts\",\n \"default\": \"./out/zero/src/change-protocol/v0.js\"\n },\n \"./expo-sqlite\": {\n \"types\": \"./out/zero/src/expo-sqlite.d.ts\",\n \"default\": \"./out/zero/src/expo-sqlite.js\"\n },\n \"./op-sqlite\": {\n \"types\": \"./out/zero/src/op-sqlite.d.ts\",\n \"default\": \"./out/zero/src/op-sqlite.js\"\n },\n \"./pg\": {\n \"types\": \"./out/zero/src/pg.d.ts\",\n \"default\": \"./out/zero/src/pg.js\"\n },\n \"./react\": {\n \"types\": \"./out/zero/src/react.d.ts\",\n \"default\": \"./out/zero/src/react.js\"\n },\n \"./react-native\": {\n \"types\": \"./out/zero/src/react-native.d.ts\",\n \"default\": \"./out/zero/src/react-native.js\"\n },\n \"./server\": {\n \"types\": \"./out/zero/src/server.d.ts\",\n \"default\": \"./out/zero/src/server.js\"\n },\n \"./server/adapters/drizzle\": {\n \"types\": \"./out/zero/src/adapters/drizzle.d.ts\",\n \"default\": \"./out/zero/src/adapters/drizzle.js\"\n },\n \"./server/adapters/kysely\": {\n \"types\": \"./out/zero/src/adapters/kysely.d.ts\",\n \"default\": \"./out/zero/src/adapters/kysely.js\"\n },\n \"./server/adapters/prisma\": {\n \"types\": \"./out/zero/src/adapters/prisma.d.ts\",\n \"default\": \"./out/zero/src/adapters/prisma.js\"\n },\n \"./server/adapters/pg\": {\n \"types\": \"./out/zero/src/adapters/pg.d.ts\",\n \"default\": \"./out/zero/src/adapters/pg.js\"\n },\n \"./server/adapters/postgresjs\": {\n \"types\": \"./out/zero/src/adapters/postgresjs.d.ts\",\n \"default\": \"./out/zero/src/adapters/postgresjs.js\"\n },\n \"./solid\": {\n \"types\": \"./out/zero/src/solid.d.ts\",\n \"default\": \"./out/zero/src/solid.js\"\n },\n \"./sqlite\": {\n \"types\": \"./out/zero/src/sqlite.d.ts\",\n \"default\": \"./out/zero/src/sqlite.js\"\n },\n \"./zqlite\": {\n \"types\": \"./out/zero/src/zqlite.d.ts\",\n \"default\": \"./out/zero/src/zqlite.js\"\n }\n },\n \"scripts\": {\n \"build\": \"node --experimental-strip-types --no-warnings tool/build.ts\",\n \"build:watch\": \"node --experimental-strip-types --no-warnings tool/build.ts --watch\",\n \"check-types\": \"tsc -p tsconfig.client.json && tsc -p tsconfig.server.json\",\n \"check-types:client:watch\": \"tsc -p tsconfig.client.json --watch\",\n \"check-types:server:watch\": \"tsc -p tsconfig.server.json --watch\",\n \"format\": \"oxfmt .\",\n \"check-format\": \"oxfmt --check .\",\n \"lint\": \"oxlint --quiet --config ../../oxlint.config.ts src/\",\n \"docs\": \"node --experimental-strip-types --no-warnings tool/generate-docs.ts\",\n \"docs:server\": \"node --watch --experimental-strip-types --no-warnings tool/generate-docs.ts --server\",\n \"fmt\": \"oxfmt .\",\n \"check-fmt\": \"oxfmt --check .\"\n },\n \"dependencies\": {\n \"@badrap/valita\": \"0.3.11\",\n \"@databases/escape-identifier\": \"^1.0.3\",\n \"@databases/sql\": \"^3.3.0\",\n \"@dotenvx/dotenvx\": \"^1.39.0\",\n \"@drdgvhbh/postgres-error-codes\": \"^0.0.6\",\n \"@fastify/cors\": \"^10.0.0\",\n \"@fastify/websocket\": \"^11.0.0\",\n \"@google-cloud/precise-date\": \"^4.0.0\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/api-logs\": \"^0.218.0\",\n \"@opentelemetry/auto-instrumentations-node\": \"^0.76.0\",\n \"@opentelemetry/exporter-metrics-otlp-http\": \"^0.218.0\",\n \"@opentelemetry/resources\": \"^2.7.1\",\n \"@opentelemetry/sdk-metrics\": \"^2.7.1\",\n \"@opentelemetry/sdk-node\": \"^0.218.0\",\n \"@opentelemetry/sdk-trace-node\": \"^2.7.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.41.1\",\n \"@postgresql-typed/oids\": \"^0.2.0\",\n \"@rocicorp/lock\": \"^1.0.4\",\n \"@rocicorp/logger\": \"^6.1.0\",\n \"@rocicorp/resolver\": \"^1.0.2\",\n \"@rocicorp/zero-sqlite3\": \"^1.1.2\",\n \"@standard-schema/spec\": \"^1.0.0\",\n \"@types/basic-auth\": \"^1.1.8\",\n \"@types/ws\": \"^8.5.12\",\n \"basic-auth\": \"^2.0.1\",\n \"chalk-template\": \"^1.1.0\",\n \"chokidar\": \"^4.0.1\",\n \"cloudevents\": \"^10.0.0\",\n \"command-line-args\": \"^6.0.1\",\n \"command-line-usage\": \"^7.0.3\",\n \"compare-utf8\": \"^0.2.0\",\n \"defu\": \"^6.1.4\",\n \"eventemitter3\": \"^5.0.1\",\n \"fastify\": \"^5.0.0\",\n \"is-in-subnet\": \"^4.0.1\",\n \"jose\": \"^5.9.3\",\n \"js-xxhash\": \"^4.0.0\",\n \"json-custom-numbers\": \"^3.1.1\",\n \"kasi\": \"^1.1.0\",\n \"nanoid\": \"^5.1.2\",\n \"oxfmt\": \"^0.45.0\",\n \"parse-prometheus-text-format\": \"^1.1.1\",\n \"pg-format\": \"npm:pg-format-fix@^1.0.5\",\n \"postgres\": \"3.4.7\",\n \"semver\": \"^7.5.4\",\n \"url-pattern\": \"^1.0.3\",\n \"urlpattern-polyfill\": \"^10.1.0\",\n \"ws\": \"^8.18.1\"\n },\n \"devDependencies\": {\n \"@op-engineering/op-sqlite\": \">=15\",\n \"@vitest/runner\": \"^4.1.6\",\n \"analyze-query\": \"workspace:*\",\n \"ast-to-zql\": \"workspace:*\",\n \"expo-sqlite\": \">=15\",\n \"replicache\": \"workspace:*\",\n \"shared\": \"workspace:*\",\n \"syncpack\": \"^14.3.0\",\n \"typedoc\": \"^0.28.17\",\n \"typedoc-plugin-markdown\": \"^4.10.0\",\n \"typescript\": \"~6.0.2\",\n \"vite\": \"^8.0.13\",\n \"vitest\": \"^4.1.6\",\n \"zero-cache\": \"workspace:*\",\n \"zero-client\": \"workspace:*\",\n \"zero-pg\": \"workspace:*\",\n \"zero-react\": \"workspace:*\",\n \"zero-server\": \"workspace:*\",\n \"zero-solid\": \"workspace:*\",\n \"zqlite\": \"workspace:*\"\n },\n \"peerDependencies\": {\n \"@op-engineering/op-sqlite\": \">=15\",\n \"drizzle-orm\": \"^0.45.2\",\n \"expo-sqlite\": \">=15\",\n \"kysely\": \"^0.28.17\",\n \"pg\": \"^8.16.3\",\n \"react\": \"^19.2.6\",\n \"solid-js\": \"^1.9.4\"\n },\n \"peerDependenciesMeta\": {\n \"@op-engineering/op-sqlite\": {\n \"optional\": true\n },\n \"drizzle-orm\": {\n \"optional\": true\n },\n \"expo-sqlite\": {\n \"optional\": true\n },\n \"kysely\": {\n \"optional\": true\n },\n \"pg\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"solid-js\": {\n \"optional\": true\n }\n },\n \"engines\": {\n \"node\": \">=22\"\n },\n \"packageManager\": \"pnpm@11.5.3\"\n}\n"],"mappings":""}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@rocicorp/zero\",\n \"version\": \"1.9.0-canary.1\",\n \"description\": \"Zero is a web framework for serverless web development.\",\n \"homepage\": \"https://zero.rocicorp.dev\",\n \"bugs\": {\n \"url\": \"https://bugs.rocicorp.dev\"\n },\n \"license\": \"Apache-2.0\",\n \"author\": \"Rocicorp, Inc.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/rocicorp/mono.git\",\n \"directory\": \"packages/zero\"\n },\n \"bin\": {\n \"analyze-query\": \"./out/zero/src/analyze-query.js\",\n \"ast-to-zql\": \"./out/zero/src/ast-to-zql.js\",\n \"transform-query\": \"./out/zero/src/transform-query.js\",\n \"zero-build-schema\": \"./out/zero/src/build-schema.js\",\n \"zero-cache\": \"./out/zero/src/cli.js\",\n \"zero-cache-dev\": \"./out/zero/src/zero-cache-dev.js\",\n \"zero-deploy-permissions\": \"./out/zero/src/deploy-permissions.js\",\n \"zero-out\": \"./out/zero/src/zero-out.js\"\n },\n \"files\": [\n \"out\",\n \"!*.tsbuildinfo\"\n ],\n \"type\": \"module\",\n \"main\": \"out/zero/src/zero.js\",\n \"module\": \"out/zero/src/zero.js\",\n \"types\": \"out/zero/src/zero.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./out/zero/src/zero.d.ts\",\n \"default\": \"./out/zero/src/zero.js\"\n },\n \"./analyze\": {\n \"types\": \"./out/zero/src/analyze.d.ts\",\n \"default\": \"./out/zero/src/analyze.js\"\n },\n \"./bindings\": {\n \"types\": \"./out/zero/src/bindings.d.ts\",\n \"default\": \"./out/zero/src/bindings.js\"\n },\n \"./change-protocol/v0\": {\n \"types\": \"./out/zero/src/change-protocol/v0.d.ts\",\n \"default\": \"./out/zero/src/change-protocol/v0.js\"\n },\n \"./expo-sqlite\": {\n \"types\": \"./out/zero/src/expo-sqlite.d.ts\",\n \"default\": \"./out/zero/src/expo-sqlite.js\"\n },\n \"./op-sqlite\": {\n \"types\": \"./out/zero/src/op-sqlite.d.ts\",\n \"default\": \"./out/zero/src/op-sqlite.js\"\n },\n \"./pg\": {\n \"types\": \"./out/zero/src/pg.d.ts\",\n \"default\": \"./out/zero/src/pg.js\"\n },\n \"./react\": {\n \"types\": \"./out/zero/src/react.d.ts\",\n \"default\": \"./out/zero/src/react.js\"\n },\n \"./react-native\": {\n \"types\": \"./out/zero/src/react-native.d.ts\",\n \"default\": \"./out/zero/src/react-native.js\"\n },\n \"./server\": {\n \"types\": \"./out/zero/src/server.d.ts\",\n \"default\": \"./out/zero/src/server.js\"\n },\n \"./server/adapters/drizzle\": {\n \"types\": \"./out/zero/src/adapters/drizzle.d.ts\",\n \"default\": \"./out/zero/src/adapters/drizzle.js\"\n },\n \"./server/adapters/kysely\": {\n \"types\": \"./out/zero/src/adapters/kysely.d.ts\",\n \"default\": \"./out/zero/src/adapters/kysely.js\"\n },\n \"./server/adapters/prisma\": {\n \"types\": \"./out/zero/src/adapters/prisma.d.ts\",\n \"default\": \"./out/zero/src/adapters/prisma.js\"\n },\n \"./server/adapters/pg\": {\n \"types\": \"./out/zero/src/adapters/pg.d.ts\",\n \"default\": \"./out/zero/src/adapters/pg.js\"\n },\n \"./server/adapters/postgresjs\": {\n \"types\": \"./out/zero/src/adapters/postgresjs.d.ts\",\n \"default\": \"./out/zero/src/adapters/postgresjs.js\"\n },\n \"./solid\": {\n \"types\": \"./out/zero/src/solid.d.ts\",\n \"default\": \"./out/zero/src/solid.js\"\n },\n \"./sqlite\": {\n \"types\": \"./out/zero/src/sqlite.d.ts\",\n \"default\": \"./out/zero/src/sqlite.js\"\n },\n \"./zqlite\": {\n \"types\": \"./out/zero/src/zqlite.d.ts\",\n \"default\": \"./out/zero/src/zqlite.js\"\n }\n },\n \"scripts\": {\n \"build\": \"node --experimental-strip-types --no-warnings tool/build.ts\",\n \"build:watch\": \"node --experimental-strip-types --no-warnings tool/build.ts --watch\",\n \"check-types\": \"tsc -p tsconfig.client.json && tsc -p tsconfig.server.json\",\n \"check-types:client:watch\": \"tsc -p tsconfig.client.json --watch\",\n \"check-types:server:watch\": \"tsc -p tsconfig.server.json --watch\",\n \"format\": \"oxfmt .\",\n \"check-format\": \"oxfmt --check .\",\n \"lint\": \"oxlint --quiet --config ../../oxlint.config.ts src/\",\n \"docs\": \"node --experimental-strip-types --no-warnings tool/generate-docs.ts\",\n \"docs:server\": \"node --watch --experimental-strip-types --no-warnings tool/generate-docs.ts --server\",\n \"fmt\": \"oxfmt .\",\n \"check-fmt\": \"oxfmt --check .\"\n },\n \"dependencies\": {\n \"@badrap/valita\": \"0.3.11\",\n \"@databases/escape-identifier\": \"^1.0.3\",\n \"@databases/sql\": \"^3.3.0\",\n \"@dotenvx/dotenvx\": \"^1.39.0\",\n \"@drdgvhbh/postgres-error-codes\": \"^0.0.6\",\n \"@fastify/cors\": \"^10.0.0\",\n \"@fastify/websocket\": \"^11.0.0\",\n \"@google-cloud/precise-date\": \"^4.0.0\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/api-logs\": \"^0.218.0\",\n \"@opentelemetry/auto-instrumentations-node\": \"^0.76.0\",\n \"@opentelemetry/exporter-metrics-otlp-http\": \"^0.218.0\",\n \"@opentelemetry/resources\": \"^2.7.1\",\n \"@opentelemetry/sdk-metrics\": \"^2.7.1\",\n \"@opentelemetry/sdk-node\": \"^0.218.0\",\n \"@opentelemetry/sdk-trace-node\": \"^2.7.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.41.1\",\n \"@postgresql-typed/oids\": \"^0.2.0\",\n \"@rocicorp/lock\": \"^1.0.4\",\n \"@rocicorp/logger\": \"^6.1.0\",\n \"@rocicorp/resolver\": \"^1.0.2\",\n \"@rocicorp/zero-sqlite3\": \"^1.1.2\",\n \"@standard-schema/spec\": \"^1.0.0\",\n \"@types/basic-auth\": \"^1.1.8\",\n \"@types/ws\": \"^8.5.12\",\n \"basic-auth\": \"^2.0.1\",\n \"chalk-template\": \"^1.1.0\",\n \"chokidar\": \"^4.0.1\",\n \"cloudevents\": \"^10.0.0\",\n \"command-line-args\": \"^6.0.1\",\n \"command-line-usage\": \"^7.0.3\",\n \"compare-utf8\": \"^0.2.0\",\n \"defu\": \"^6.1.4\",\n \"eventemitter3\": \"^5.0.1\",\n \"fastify\": \"^5.0.0\",\n \"is-in-subnet\": \"^4.0.1\",\n \"jose\": \"^5.9.3\",\n \"js-xxhash\": \"^4.0.0\",\n \"json-custom-numbers\": \"^3.1.1\",\n \"kasi\": \"^1.1.0\",\n \"nanoid\": \"^5.1.2\",\n \"oxfmt\": \"^0.45.0\",\n \"parse-prometheus-text-format\": \"^1.1.1\",\n \"pg-format\": \"npm:pg-format-fix@^1.0.5\",\n \"postgres\": \"3.4.7\",\n \"semver\": \"^7.5.4\",\n \"url-pattern\": \"^1.0.3\",\n \"urlpattern-polyfill\": \"^10.1.0\",\n \"ws\": \"^8.18.1\"\n },\n \"devDependencies\": {\n \"@op-engineering/op-sqlite\": \">=15\",\n \"@vitest/runner\": \"^4.1.6\",\n \"analyze-query\": \"workspace:*\",\n \"ast-to-zql\": \"workspace:*\",\n \"expo-sqlite\": \">=15\",\n \"oxc-parser\": \"^0.129.0\",\n \"replicache\": \"workspace:*\",\n \"shared\": \"workspace:*\",\n \"syncpack\": \"^14.3.0\",\n \"typedoc\": \"^0.28.17\",\n \"typedoc-plugin-markdown\": \"^4.10.0\",\n \"typescript\": \"~6.0.2\",\n \"vite\": \"^8.0.13\",\n \"vitest\": \"^4.1.6\",\n \"zero-cache\": \"workspace:*\",\n \"zero-client\": \"workspace:*\",\n \"zero-pg\": \"workspace:*\",\n \"zero-react\": \"workspace:*\",\n \"zero-server\": \"workspace:*\",\n \"zero-solid\": \"workspace:*\",\n \"zqlite\": \"workspace:*\"\n },\n \"engines\": {\n \"node\": \">=22\"\n },\n \"packageManager\": \"pnpm@11.5.3\"\n}\n"],"mappings":""}
@@ -260,6 +260,10 @@ export declare const zeroOptions: {
260
260
  type: v.Type<boolean>;
261
261
  desc: string[];
262
262
  };
263
+ enableQueryCovering: {
264
+ type: v.Type<boolean>;
265
+ desc: string[];
266
+ };
263
267
  yieldThresholdMs: {
264
268
  type: v.Type<number>;
265
269
  desc: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"zero-config.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/config/zero-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AAUnD,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAC,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAEhE,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C,eAAO,MAAM,UAAU;;;;;;;;;CA+CtB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;CAwBxB,CAAC;AAEF,QAAA,MAAM,cAAc;;;;;;;;;CAmBnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,O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C,UAAU,CAaZ;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,GAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAM,GAC7C,oBAAoB,CAItB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,GAAG,SAAS,GACpD,MAAM,CAER;AAED,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,UAAU,EACd,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,eAAe,CAAC,EACnD,QAAQ,EAAE,MAAM,GAAG,SAAS,WAwC7B;AAYD,wBAAgB,kBAAkB,SAEjC"}
@@ -358,6 +358,17 @@ var zeroOptions = {
358
358
  `You can disable the planner if it is picking bad strategies.`
359
359
  ]
360
360
  },
361
+ enableQueryCovering: {
362
+ type: valita_exports.boolean().default(true),
363
+ desc: [
364
+ `Enable shadow-mode query covering detection during query hydration.`,
365
+ ``,
366
+ `When enabled, view-syncers compare newly hydrated queries against running`,
367
+ `queries with the same root table and log aggregate coverage stats.`,
368
+ ``,
369
+ `You can disable this if covering detection adds too much CPU overhead.`
370
+ ]
371
+ },
361
372
  yieldThresholdMs: {
362
373
  type: valita_exports.number().default(10),
363
374
  desc: [
@@ -583,10 +594,10 @@ var zeroOptions = {
583
594
  type: valita_exports.number().default(3e4),
584
595
  desc: [
585
596
  `The minimum interval at which replication lag reports are written upstream and`,
586
- `reported via the {bold zero.replication.total_lag} opentelemetry metric. Because`,
587
- `replication lag reports are only issued after the previous one was received, the`,
588
- `actual interval between reports may be longer when there is a backlog in the`,
589
- `replication stream. A negative or 0 value disables lag reporting.`,
597
+ `reported via the {bold zero.replication.total_lag} opentelemetry metric. If`,
598
+ `an expected report is not received before the next interval, Zero retries with`,
599
+ `a new report and increments {bold zero.replication.lag_report_retries}. A`,
600
+ `negative or 0 value disables lag reporting.`,
590
601
  ``,
591
602
  `This monitoring feature is only support on the postgres upstream type.`
592
603
  ]
@@ -652,8 +663,12 @@ var zeroOptions = {
652
663
  ]
653
664
  },
654
665
  restoreUsingV5: {
655
- type: valita_exports.boolean().default(false),
656
- desc: [`Restores the backup using the {bold ZERO_LITESTREAM_EXECUTABLE_V5} if specified.`]
666
+ type: valita_exports.boolean().default(true),
667
+ desc: [
668
+ `Restores the backup using the {bold ZERO_LITESTREAM_EXECUTABLE_V5} if specified.`,
669
+ `This provides a recovery path if rolling back from {bold ZERO_LITESTREAM_BACKUP_USING_V5}`,
670
+ `as v5 restores from both v3 and v5 backups (whichever is more recent).`
671
+ ]
657
672
  },
658
673
  backupUsingV5: {
659
674
  type: valita_exports.boolean().default(false),