@rocicorp/zero 0.25.0-canary.18 → 0.25.0-canary.21

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 (228) hide show
  1. package/out/replicache/src/persist/idb-databases-store.d.ts +1 -0
  2. package/out/replicache/src/persist/idb-databases-store.d.ts.map +1 -1
  3. package/out/replicache/src/persist/idb-databases-store.js +13 -2
  4. package/out/replicache/src/persist/idb-databases-store.js.map +1 -1
  5. package/out/zero/package.json.js +1 -1
  6. package/out/zero/src/adapters/drizzle.d.ts +1 -1
  7. package/out/zero/src/adapters/drizzle.d.ts.map +1 -1
  8. package/out/zero/src/adapters/drizzle.js +4 -1
  9. package/out/zero/src/bindings.d.ts +2 -0
  10. package/out/zero/src/bindings.d.ts.map +1 -0
  11. package/out/zero/src/bindings.js +27 -0
  12. package/out/zero/src/bindings.js.map +1 -0
  13. package/out/zero/src/react.js +2 -4
  14. package/out/zero/src/react.js.map +1 -1
  15. package/out/zero/src/solid.js +2 -2
  16. package/out/zero/src/zero.js +3 -5
  17. package/out/zero-cache/src/auth/read-authorizer.d.ts +1 -1
  18. package/out/zero-cache/src/auth/read-authorizer.d.ts.map +1 -1
  19. package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
  20. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
  21. package/out/zero-cache/src/auth/write-authorizer.js +5 -4
  22. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  23. package/out/zero-cache/src/config/zero-config.d.ts +24 -0
  24. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  25. package/out/zero-cache/src/config/zero-config.js +23 -4
  26. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  27. package/out/zero-cache/src/server/anonymous-otel-start.d.ts +10 -1
  28. package/out/zero-cache/src/server/anonymous-otel-start.d.ts.map +1 -1
  29. package/out/zero-cache/src/server/anonymous-otel-start.js +34 -18
  30. package/out/zero-cache/src/server/anonymous-otel-start.js.map +1 -1
  31. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  32. package/out/zero-cache/src/server/syncer.js +1 -0
  33. package/out/zero-cache/src/server/syncer.js.map +1 -1
  34. package/out/zero-cache/src/services/analyze.d.ts +1 -1
  35. package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
  36. package/out/zero-cache/src/services/analyze.js +5 -5
  37. package/out/zero-cache/src/services/analyze.js.map +1 -1
  38. package/out/zero-cache/src/services/mutagen/pusher.d.ts +4 -4
  39. package/out/zero-cache/src/services/view-syncer/active-users-gauge.d.ts +2 -1
  40. package/out/zero-cache/src/services/view-syncer/active-users-gauge.d.ts.map +1 -1
  41. package/out/zero-cache/src/services/view-syncer/active-users-gauge.js +26 -13
  42. package/out/zero-cache/src/services/view-syncer/active-users-gauge.js.map +1 -1
  43. package/out/zero-cache/src/services/view-syncer/cvr-purger.d.ts +1 -1
  44. package/out/zero-cache/src/services/view-syncer/cvr-purger.d.ts.map +1 -1
  45. package/out/zero-cache/src/services/view-syncer/cvr-purger.js +39 -15
  46. package/out/zero-cache/src/services/view-syncer/cvr-purger.js.map +1 -1
  47. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +4 -1
  48. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
  49. package/out/zero-cache/src/services/view-syncer/cvr-store.js +31 -9
  50. package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
  51. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +3 -0
  52. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  53. package/out/zero-cache/src/services/view-syncer/cvr.js +11 -0
  54. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  55. package/out/zero-cache/src/services/view-syncer/inspect-handler.js +1 -1
  56. package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
  57. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +1 -2
  58. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  59. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +6 -6
  60. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  61. package/out/zero-cache/src/services/view-syncer/schema/cvr.d.ts +1 -0
  62. package/out/zero-cache/src/services/view-syncer/schema/cvr.d.ts.map +1 -1
  63. package/out/zero-cache/src/services/view-syncer/schema/cvr.js +23 -10
  64. package/out/zero-cache/src/services/view-syncer/schema/cvr.js.map +1 -1
  65. package/out/zero-cache/src/services/view-syncer/schema/init.d.ts.map +1 -1
  66. package/out/zero-cache/src/services/view-syncer/schema/init.js +31 -1
  67. package/out/zero-cache/src/services/view-syncer/schema/init.js.map +1 -1
  68. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +1 -0
  69. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  70. package/out/zero-cache/src/services/view-syncer/view-syncer.js +20 -16
  71. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  72. package/out/zero-cache/src/workers/connect-params.d.ts +1 -0
  73. package/out/zero-cache/src/workers/connect-params.d.ts.map +1 -1
  74. package/out/zero-cache/src/workers/connect-params.js +2 -0
  75. package/out/zero-cache/src/workers/connect-params.js.map +1 -1
  76. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
  77. package/out/zero-cache/src/workers/syncer-ws-message-handler.js +2 -0
  78. package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
  79. package/out/zero-client/src/client/bindings.d.ts +12 -41
  80. package/out/zero-client/src/client/bindings.d.ts.map +1 -1
  81. package/out/zero-client/src/client/custom.d.ts +3 -0
  82. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  83. package/out/zero-client/src/client/custom.js +3 -0
  84. package/out/zero-client/src/client/custom.js.map +1 -1
  85. package/out/zero-client/src/client/delete-clients-manager.d.ts +1 -1
  86. package/out/zero-client/src/client/delete-clients-manager.d.ts.map +1 -1
  87. package/out/zero-client/src/client/delete-clients-manager.js +30 -3
  88. package/out/zero-client/src/client/delete-clients-manager.js.map +1 -1
  89. package/out/zero-client/src/client/make-replicache-mutators.js +1 -3
  90. package/out/zero-client/src/client/make-replicache-mutators.js.map +1 -1
  91. package/out/zero-client/src/client/options.d.ts +1 -1
  92. package/out/zero-client/src/client/options.js.map +1 -1
  93. package/out/zero-client/src/client/version.js +1 -1
  94. package/out/zero-client/src/client/zero.d.ts +1 -0
  95. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  96. package/out/zero-client/src/client/zero.js +43 -26
  97. package/out/zero-client/src/client/zero.js.map +1 -1
  98. package/out/zero-client/src/mod.d.ts +6 -4
  99. package/out/zero-client/src/mod.d.ts.map +1 -1
  100. package/out/zero-protocol/src/analyze-query-result.d.ts +2 -2
  101. package/out/zero-protocol/src/analyze-query-result.js +2 -2
  102. package/out/zero-protocol/src/analyze-query-result.js.map +1 -1
  103. package/out/zero-protocol/src/down.d.ts +2 -2
  104. package/out/zero-protocol/src/inspect-down.d.ts +6 -6
  105. package/out/zero-protocol/src/inspect-up.d.ts +4 -4
  106. package/out/zero-protocol/src/inspect-up.js +1 -1
  107. package/out/zero-protocol/src/inspect-up.js.map +1 -1
  108. package/out/zero-protocol/src/protocol-version.d.ts +1 -1
  109. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  110. package/out/zero-protocol/src/protocol-version.js +1 -1
  111. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  112. package/out/zero-protocol/src/up.d.ts +1 -1
  113. package/out/zero-react/src/bindings.d.ts +2 -0
  114. package/out/zero-react/src/bindings.d.ts.map +1 -0
  115. package/out/zero-react/src/mod.d.ts +1 -10
  116. package/out/zero-react/src/mod.d.ts.map +1 -1
  117. package/out/zero-react/src/{use-zero-connection-state.d.ts → use-connection-state.d.ts} +3 -3
  118. package/out/zero-react/src/use-connection-state.d.ts.map +1 -0
  119. package/out/zero-react/src/{use-zero-connection-state.js → use-connection-state.js} +3 -3
  120. package/out/zero-react/src/use-connection-state.js.map +1 -0
  121. package/out/zero-react/src/use-query.d.ts +2 -10
  122. package/out/zero-react/src/use-query.d.ts.map +1 -1
  123. package/out/zero-react/src/use-query.js +24 -22
  124. package/out/zero-react/src/use-query.js.map +1 -1
  125. package/out/zero-react/src/use-zero-online.d.ts +1 -1
  126. package/out/zero-react/src/use-zero-online.js.map +1 -1
  127. package/out/zero-react/src/zero-provider.d.ts +1 -5
  128. package/out/zero-react/src/zero-provider.d.ts.map +1 -1
  129. package/out/zero-react/src/zero-provider.js +16 -0
  130. package/out/zero-react/src/zero-provider.js.map +1 -1
  131. package/out/zero-react/src/zero.d.ts +2 -0
  132. package/out/zero-react/src/zero.d.ts.map +1 -0
  133. package/out/zero-schema/src/permissions.d.ts.map +1 -1
  134. package/out/zero-schema/src/permissions.js +2 -8
  135. package/out/zero-schema/src/permissions.js.map +1 -1
  136. package/out/zero-server/src/custom.d.ts +3 -0
  137. package/out/zero-server/src/custom.d.ts.map +1 -1
  138. package/out/zero-server/src/custom.js +3 -0
  139. package/out/zero-server/src/custom.js.map +1 -1
  140. package/out/zero-solid/src/bindings.d.ts +2 -0
  141. package/out/zero-solid/src/bindings.d.ts.map +1 -0
  142. package/out/zero-solid/src/mod.d.ts +1 -8
  143. package/out/zero-solid/src/mod.d.ts.map +1 -1
  144. package/out/zero-solid/src/solid-view.d.ts +1 -8
  145. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  146. package/out/zero-solid/src/solid-view.js +31 -0
  147. package/out/zero-solid/src/solid-view.js.map +1 -1
  148. package/out/zero-solid/src/{use-zero-connection-state.d.ts → use-connection-state.d.ts} +3 -3
  149. package/out/zero-solid/src/use-connection-state.d.ts.map +1 -0
  150. package/out/zero-solid/src/{use-zero-connection-state.js → use-connection-state.js} +3 -3
  151. package/out/zero-solid/src/use-connection-state.js.map +1 -0
  152. package/out/zero-solid/src/use-query.d.ts +1 -7
  153. package/out/zero-solid/src/use-query.d.ts.map +1 -1
  154. package/out/zero-solid/src/use-query.js +43 -12
  155. package/out/zero-solid/src/use-query.js.map +1 -1
  156. package/out/zero-solid/src/use-zero-online.d.ts +1 -1
  157. package/out/zero-solid/src/use-zero-online.js.map +1 -1
  158. package/out/zero-solid/src/use-zero.d.ts +1 -5
  159. package/out/zero-solid/src/use-zero.d.ts.map +1 -1
  160. package/out/zero-solid/src/use-zero.js +16 -0
  161. package/out/zero-solid/src/use-zero.js.map +1 -1
  162. package/out/zero-solid/src/zero.d.ts +2 -0
  163. package/out/zero-solid/src/zero.d.ts.map +1 -0
  164. package/out/zql/src/ivm/flipped-join.d.ts.map +1 -1
  165. package/out/zql/src/ivm/flipped-join.js +29 -27
  166. package/out/zql/src/ivm/flipped-join.js.map +1 -1
  167. package/out/zql/src/ivm/join-utils.d.ts +7 -1
  168. package/out/zql/src/ivm/join-utils.d.ts.map +1 -1
  169. package/out/zql/src/ivm/join-utils.js +12 -0
  170. package/out/zql/src/ivm/join-utils.js.map +1 -1
  171. package/out/zql/src/ivm/join.d.ts.map +1 -1
  172. package/out/zql/src/ivm/join.js +11 -25
  173. package/out/zql/src/ivm/join.js.map +1 -1
  174. package/out/zql/src/mutate/custom.d.ts +3 -0
  175. package/out/zql/src/mutate/custom.d.ts.map +1 -1
  176. package/out/zql/src/mutate/custom.js.map +1 -1
  177. package/out/zql/src/mutate/mutator-registry.d.ts +2 -2
  178. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
  179. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  180. package/out/zql/src/mutate/mutator.d.ts +1 -1
  181. package/out/zql/src/mutate/mutator.d.ts.map +1 -1
  182. package/out/zql/src/mutate/mutator.js.map +1 -1
  183. package/out/zql/src/planner/planner-debug.d.ts +3 -3
  184. package/out/zql/src/planner/planner-debug.js.map +1 -1
  185. package/out/zql/src/query/create-builder.d.ts +2 -1
  186. package/out/zql/src/query/create-builder.d.ts.map +1 -1
  187. package/out/zql/src/query/create-builder.js +3 -0
  188. package/out/zql/src/query/create-builder.js.map +1 -1
  189. package/out/zql/src/query/query-impl.d.ts +39 -6
  190. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  191. package/out/zql/src/query/query-impl.js +414 -23
  192. package/out/zql/src/query/query-impl.js.map +1 -1
  193. package/out/zql/src/query/query-registry.d.ts +2 -2
  194. package/out/zql/src/query/query-registry.d.ts.map +1 -1
  195. package/out/zql/src/query/query-registry.js.map +1 -1
  196. package/out/zql/src/query/runnable-query-impl.d.ts +2 -2
  197. package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
  198. package/out/zql/src/query/runnable-query-impl.js +2 -2
  199. package/out/zql/src/query/runnable-query-impl.js.map +1 -1
  200. package/out/zql/src/query/schema-query.d.ts +4 -2
  201. package/out/zql/src/query/schema-query.d.ts.map +1 -1
  202. package/out/zql/src/query/static-query.d.ts +2 -16
  203. package/out/zql/src/query/static-query.d.ts.map +1 -1
  204. package/out/zql/src/query/static-query.js +10 -37
  205. package/out/zql/src/query/static-query.js.map +1 -1
  206. package/package.json +7 -3
  207. package/out/zero-client/src/client/bindings.js +0 -33
  208. package/out/zero-client/src/client/bindings.js.map +0 -1
  209. package/out/zero-react/src/components/inspector.d.ts +0 -9
  210. package/out/zero-react/src/components/inspector.d.ts.map +0 -1
  211. package/out/zero-react/src/components/inspector.js +0 -38
  212. package/out/zero-react/src/components/inspector.js.map +0 -1
  213. package/out/zero-react/src/components/mark-icon.d.ts +0 -3
  214. package/out/zero-react/src/components/mark-icon.d.ts.map +0 -1
  215. package/out/zero-react/src/components/mark-icon.js +0 -28
  216. package/out/zero-react/src/components/mark-icon.js.map +0 -1
  217. package/out/zero-react/src/components/zero-inspector.d.ts +0 -8
  218. package/out/zero-react/src/components/zero-inspector.d.ts.map +0 -1
  219. package/out/zero-react/src/components/zero-inspector.js +0 -44
  220. package/out/zero-react/src/components/zero-inspector.js.map +0 -1
  221. package/out/zero-react/src/use-zero-connection-state.d.ts.map +0 -1
  222. package/out/zero-react/src/use-zero-connection-state.js.map +0 -1
  223. package/out/zero-solid/src/use-zero-connection-state.d.ts.map +0 -1
  224. package/out/zero-solid/src/use-zero-connection-state.js.map +0 -1
  225. package/out/zql/src/query/abstract-query.d.ts +0 -42
  226. package/out/zql/src/query/abstract-query.d.ts.map +0 -1
  227. package/out/zql/src/query/abstract-query.js +0 -405
  228. package/out/zql/src/query/abstract-query.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"syncer-ws-message-handler.js","sources":["../../../../../zero-cache/src/workers/syncer-ws-message-handler.ts"],"sourcesContent":["import {trace} from '@opentelemetry/api';\nimport {Lock} from '@rocicorp/lock';\nimport type {LogContext} from '@rocicorp/logger';\nimport type {JWTPayload} from 'jose';\nimport {startAsyncSpan, startSpan} from '../../../otel/src/span.ts';\nimport {version} from '../../../otel/src/version.ts';\nimport {assert, unreachable} from '../../../shared/src/asserts.ts';\nimport {ErrorKind} from '../../../zero-protocol/src/error-kind.ts';\nimport type {ErrorBody} from '../../../zero-protocol/src/error.ts';\nimport type {Upstream} from '../../../zero-protocol/src/up.ts';\nimport type {Mutagen} from '../services/mutagen/mutagen.ts';\nimport type {Pusher} from '../services/mutagen/pusher.ts';\nimport type {\n SyncContext,\n TokenData,\n ViewSyncer,\n} from '../services/view-syncer/view-syncer.ts';\nimport type {ConnectParams} from './connect-params.ts';\nimport type {HandlerResult, MessageHandler} from './connection.ts';\nimport {ErrorOrigin} from '../../../zero-protocol/src/error-origin.ts';\n\nconst tracer = trace.getTracer('syncer-ws-server', version);\n\nexport class SyncerWsMessageHandler implements MessageHandler {\n readonly #viewSyncer: ViewSyncer;\n readonly #mutagen: Mutagen;\n readonly #mutationLock: Lock;\n readonly #lc: LogContext;\n readonly #authData: JWTPayload | undefined;\n readonly #clientGroupID: string;\n readonly #syncContext: SyncContext;\n readonly #pusher: Pusher | undefined;\n // DEPRECATED: remove #token\n // and forward auth and cookie headers that were\n // sent with the push.\n readonly #token: string | undefined;\n\n constructor(\n lc: LogContext,\n connectParams: ConnectParams,\n tokenData: TokenData | undefined,\n viewSyncer: ViewSyncer,\n mutagen: Mutagen,\n pusher: Pusher | undefined,\n ) {\n const {\n clientGroupID,\n clientID,\n wsID,\n baseCookie,\n protocolVersion,\n schemaVersion,\n httpCookie,\n } = connectParams;\n this.#viewSyncer = viewSyncer;\n this.#mutagen = mutagen;\n this.#mutationLock = new Lock();\n this.#lc = lc\n .withContext('connection')\n .withContext('clientID', clientID)\n .withContext('clientGroupID', clientGroupID)\n .withContext('wsID', wsID);\n this.#authData = tokenData?.decoded;\n this.#token = tokenData?.raw;\n this.#clientGroupID = clientGroupID;\n this.#pusher = pusher;\n this.#syncContext = {\n clientID,\n wsID,\n baseCookie,\n protocolVersion,\n schemaVersion,\n tokenData,\n httpCookie,\n };\n }\n\n async handleMessage(msg: Upstream): Promise<HandlerResult[]> {\n const lc = this.#lc;\n const msgType = msg[0];\n const viewSyncer = this.#viewSyncer;\n switch (msgType) {\n case 'ping':\n lc.error?.('Ping is not supported at this layer by Zero');\n break;\n case 'pull':\n lc.error?.('Pull is not supported by Zero');\n break;\n case 'push': {\n return startAsyncSpan<HandlerResult[]>(\n tracer,\n 'connection.push',\n async () => {\n const {clientGroupID, mutations, schemaVersion} = msg[1];\n if (clientGroupID !== this.#clientGroupID) {\n return [\n {\n type: 'fatal',\n error: {\n kind: ErrorKind.InvalidPush,\n message:\n `clientGroupID in mutation \"${clientGroupID}\" does not match ` +\n `clientGroupID of connection \"${this.#clientGroupID}`,\n origin: ErrorOrigin.ZeroCache,\n },\n } satisfies HandlerResult,\n ];\n }\n\n if (mutations.length === 0) {\n return [\n {\n type: 'ok',\n },\n ];\n }\n\n // The client only ever sends 1 mutation per push.\n // #pusher will throw if it sees a CRUD mutation.\n // #mutagen will throw if it see a custom mutation.\n if (mutations[0].type === 'custom') {\n assert(\n this.#pusher,\n 'A ZERO_MUTATE_URL must be set in order to process custom mutations.',\n );\n return [\n this.#pusher.enqueuePush(\n this.#syncContext.clientID,\n msg[1],\n this.#token,\n this.#syncContext.httpCookie,\n ),\n ];\n }\n\n // Hold a connection-level lock while processing mutations so that:\n // 1. Mutations are processed in the order in which they are received and\n // 2. A single view syncer connection cannot hog multiple upstream connections.\n const ret = await this.#mutationLock.withLock(async () => {\n const errors: ErrorBody[] = [];\n for (const mutation of mutations) {\n const maybeError = await this.#mutagen.processMutation(\n mutation,\n this.#authData,\n schemaVersion,\n this.#pusher !== undefined,\n );\n if (maybeError !== undefined) {\n errors.push({\n kind: maybeError[0],\n message: maybeError[1],\n origin: ErrorOrigin.ZeroCache,\n });\n }\n }\n if (errors.length > 0) {\n return {type: 'transient', errors} satisfies HandlerResult;\n }\n return {type: 'ok'} satisfies HandlerResult;\n });\n return [ret];\n },\n );\n }\n case 'changeDesiredQueries':\n await startAsyncSpan(tracer, 'connection.changeDesiredQueries', () =>\n viewSyncer.changeDesiredQueries(this.#syncContext, msg),\n );\n break;\n case 'deleteClients':\n await startAsyncSpan(tracer, 'connection.deleteClients', () =>\n viewSyncer.deleteClients(this.#syncContext, msg),\n );\n break;\n case 'initConnection': {\n const ret: HandlerResult[] = [\n {\n type: 'stream',\n source: 'viewSyncer',\n stream: startSpan(tracer, 'connection.initConnection', () =>\n viewSyncer.initConnection(this.#syncContext, msg),\n ),\n },\n ];\n\n // Given we support both CRUD and Custom mutators,\n // we do not initialize the `pusher` unless the user has opted\n // into custom mutations. We detect that by checking\n // if the pushURL has been set.\n if (this.#pusher) {\n ret.push({\n type: 'stream',\n source: 'pusher',\n stream: this.#pusher.initConnection(\n this.#syncContext.clientID,\n this.#syncContext.wsID,\n msg[1].userPushURL,\n ),\n });\n }\n\n return ret;\n }\n case 'closeConnection':\n // This message is deprecated and no longer used.\n break;\n\n case 'inspect':\n await startAsyncSpan(tracer, 'connection.inspect', () =>\n viewSyncer.inspect(this.#syncContext, msg),\n );\n break;\n\n case 'ackMutationResponses':\n if (this.#pusher) {\n await this.#pusher.ackMutationResponses(msg[1]);\n }\n break;\n\n default:\n unreachable(msgType);\n }\n\n return [{type: 'ok'}];\n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D;AAAA,MACF,KAAK;AACH,cAAM;AAAA,UAAe;AAAA,UAAQ;AAAA,UAA4B,MACvD,WAAW,cAAc,KAAK,cAAc,GAAG;AAAA,QAAA;AAEjD;AAAA,MACF,KAAK,kBAAkB;AACrB,cAAM,MAAuB;AAAA,UAC3B;AAAA,YACE,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,QAAQ;AAAA,cAAU;AAAA,cAAQ;AAAA,cAA6B,MACrD,WAAW,eAAe,KAAK,cAAc,GAAG;AAAA,YAAA;AAAA,UAClD;AAAA,QACF;AAOF,YAAI,KAAK,SAAS;AAChB,cAAI,KAAK;AAAA,YACP,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,QAAQ,KAAK,QAAQ;AAAA,cACnB,KAAK,aAAa;AAAA,cAClB,KAAK,aAAa;AAAA,cAClB,IAAI,CAAC,EAAE;AAAA,YAAA;AAAA,UACT,CACD;AAAA,QACH;AAEA,eAAO;AAAA,MACT;AAAA,MACA,KAAK;AAEH;AAAA,MAEF,KAAK;AACH,cAAM;AAAA,UAAe;AAAA,UAAQ;AAAA,UAAsB,MACjD,WAAW,QAAQ,KAAK,cAAc,GAAG;AAAA,QAAA;AAE3C;AAAA,MAEF,KAAK;AACH,YAAI,KAAK,SAAS;AAChB,gBAAM,KAAK,QAAQ,qBAAqB,IAAI,CAAC,CAAC;AAAA,QAChD;AACA;AAAA,MAEF;AACE,oBAAmB;AAAA,IAAA;AAGvB,WAAO,CAAC,EAAC,MAAM,MAAK;AAAA,EACtB;AACF;"}
1
+ {"version":3,"file":"syncer-ws-message-handler.js","sources":["../../../../../zero-cache/src/workers/syncer-ws-message-handler.ts"],"sourcesContent":["import {trace} from '@opentelemetry/api';\nimport {Lock} from '@rocicorp/lock';\nimport type {LogContext} from '@rocicorp/logger';\nimport type {JWTPayload} from 'jose';\nimport {startAsyncSpan, startSpan} from '../../../otel/src/span.ts';\nimport {version} from '../../../otel/src/version.ts';\nimport {assert, unreachable} from '../../../shared/src/asserts.ts';\nimport {ErrorKind} from '../../../zero-protocol/src/error-kind.ts';\nimport {ErrorOrigin} from '../../../zero-protocol/src/error-origin.ts';\nimport type {ErrorBody} from '../../../zero-protocol/src/error.ts';\nimport type {Upstream} from '../../../zero-protocol/src/up.ts';\nimport type {Mutagen} from '../services/mutagen/mutagen.ts';\nimport type {Pusher} from '../services/mutagen/pusher.ts';\nimport type {\n SyncContext,\n TokenData,\n ViewSyncer,\n} from '../services/view-syncer/view-syncer.ts';\nimport type {ConnectParams} from './connect-params.ts';\nimport type {HandlerResult, MessageHandler} from './connection.ts';\n\nconst tracer = trace.getTracer('syncer-ws-server', version);\n\nexport class SyncerWsMessageHandler implements MessageHandler {\n readonly #viewSyncer: ViewSyncer;\n readonly #mutagen: Mutagen;\n readonly #mutationLock: Lock;\n readonly #lc: LogContext;\n readonly #authData: JWTPayload | undefined;\n readonly #clientGroupID: string;\n readonly #syncContext: SyncContext;\n readonly #pusher: Pusher | undefined;\n // DEPRECATED: remove #token\n // and forward auth and cookie headers that were\n // sent with the push.\n readonly #token: string | undefined;\n\n constructor(\n lc: LogContext,\n connectParams: ConnectParams,\n tokenData: TokenData | undefined,\n viewSyncer: ViewSyncer,\n mutagen: Mutagen,\n pusher: Pusher | undefined,\n ) {\n const {\n clientGroupID,\n clientID,\n profileID,\n wsID,\n baseCookie,\n protocolVersion,\n schemaVersion,\n httpCookie,\n } = connectParams;\n this.#viewSyncer = viewSyncer;\n this.#mutagen = mutagen;\n this.#mutationLock = new Lock();\n this.#lc = lc\n .withContext('connection')\n .withContext('clientID', clientID)\n .withContext('clientGroupID', clientGroupID)\n .withContext('wsID', wsID);\n this.#authData = tokenData?.decoded;\n this.#token = tokenData?.raw;\n this.#clientGroupID = clientGroupID;\n this.#pusher = pusher;\n this.#syncContext = {\n clientID,\n profileID,\n wsID,\n baseCookie,\n protocolVersion,\n schemaVersion,\n tokenData,\n httpCookie,\n };\n }\n\n async handleMessage(msg: Upstream): Promise<HandlerResult[]> {\n const lc = this.#lc;\n const msgType = msg[0];\n const viewSyncer = this.#viewSyncer;\n switch (msgType) {\n case 'ping':\n lc.error?.('Ping is not supported at this layer by Zero');\n break;\n case 'pull':\n lc.error?.('Pull is not supported by Zero');\n break;\n case 'push': {\n return startAsyncSpan<HandlerResult[]>(\n tracer,\n 'connection.push',\n async () => {\n const {clientGroupID, mutations, schemaVersion} = msg[1];\n if (clientGroupID !== this.#clientGroupID) {\n return [\n {\n type: 'fatal',\n error: {\n kind: ErrorKind.InvalidPush,\n message:\n `clientGroupID in mutation \"${clientGroupID}\" does not match ` +\n `clientGroupID of connection \"${this.#clientGroupID}`,\n origin: ErrorOrigin.ZeroCache,\n },\n } satisfies HandlerResult,\n ];\n }\n\n if (mutations.length === 0) {\n return [\n {\n type: 'ok',\n },\n ];\n }\n\n // The client only ever sends 1 mutation per push.\n // #pusher will throw if it sees a CRUD mutation.\n // #mutagen will throw if it see a custom mutation.\n if (mutations[0].type === 'custom') {\n assert(\n this.#pusher,\n 'A ZERO_MUTATE_URL must be set in order to process custom mutations.',\n );\n return [\n this.#pusher.enqueuePush(\n this.#syncContext.clientID,\n msg[1],\n this.#token,\n this.#syncContext.httpCookie,\n ),\n ];\n }\n\n // Hold a connection-level lock while processing mutations so that:\n // 1. Mutations are processed in the order in which they are received and\n // 2. A single view syncer connection cannot hog multiple upstream connections.\n const ret = await this.#mutationLock.withLock(async () => {\n const errors: ErrorBody[] = [];\n for (const mutation of mutations) {\n const maybeError = await this.#mutagen.processMutation(\n mutation,\n this.#authData,\n schemaVersion,\n this.#pusher !== undefined,\n );\n if (maybeError !== undefined) {\n errors.push({\n kind: maybeError[0],\n message: maybeError[1],\n origin: ErrorOrigin.ZeroCache,\n });\n }\n }\n if (errors.length > 0) {\n return {type: 'transient', errors} satisfies HandlerResult;\n }\n return {type: 'ok'} satisfies HandlerResult;\n });\n return [ret];\n },\n );\n }\n case 'changeDesiredQueries':\n await startAsyncSpan(tracer, 'connection.changeDesiredQueries', () =>\n viewSyncer.changeDesiredQueries(this.#syncContext, msg),\n );\n break;\n case 'deleteClients':\n await startAsyncSpan(tracer, 'connection.deleteClients', () =>\n viewSyncer.deleteClients(this.#syncContext, msg),\n );\n break;\n case 'initConnection': {\n const ret: HandlerResult[] = [\n {\n type: 'stream',\n source: 'viewSyncer',\n stream: startSpan(tracer, 'connection.initConnection', () =>\n viewSyncer.initConnection(this.#syncContext, msg),\n ),\n },\n ];\n\n // Given we support both CRUD and Custom mutators,\n // we do not initialize the `pusher` unless the user has opted\n // into custom mutations. We detect that by checking\n // if the pushURL has been set.\n if (this.#pusher) {\n ret.push({\n type: 'stream',\n source: 'pusher',\n stream: this.#pusher.initConnection(\n this.#syncContext.clientID,\n this.#syncContext.wsID,\n msg[1].userPushURL,\n ),\n });\n }\n\n return ret;\n }\n case 'closeConnection':\n // This message is deprecated and no longer used.\n break;\n\n case 'inspect':\n await startAsyncSpan(tracer, 'connection.inspect', () =>\n viewSyncer.inspect(this.#syncContext, msg),\n );\n break;\n\n case 'ackMutationResponses':\n if (this.#pusher) {\n await this.#pusher.ackMutationResponses(msg[1]);\n }\n break;\n\n default:\n unreachable(msgType);\n }\n\n return [{type: 'ok'}];\n }\n}\n"],"names":["ErrorKind.InvalidPush","ErrorOrigin.ZeroCache"],"mappings":";;;;;;;AAqBA,MAAM,SAAS,MAAM,UAAU,oBAAoB,OAAO;AAEnD,MAAM,uBAAiD;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA,EAET,YACE,IACA,eACA,WACA,YACA,SACA,QACA;AACA,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,IACE;AACJ,SAAK,cAAc;AACnB,SAAK,WAAW;AAChB,SAAK,gBAAgB,IAAI,KAAA;AACzB,SAAK,MAAM,GACR,YAAY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B,KAAK,aAAa;AAAA,cAClB,IAAI,CAAC,EAAE;AAAA,YAAA;AAAA,UACT,CACD;AAAA,QACH;AAEA,eAAO;AAAA,MACT;AAAA,MACA,KAAK;AAEH;AAAA,MAEF,KAAK;AACH,cAAM;AAAA,UAAe;AAAA,UAAQ;AAAA,UAAsB,MACjD,WAAW,QAAQ,KAAK,cAAc,GAAG;AAAA,QAAA;AAE3C;AAAA,MAEF,KAAK;AACH,YAAI,KAAK,SAAS;AAChB,gBAAM,KAAK,QAAQ,qBAAqB,IAAI,CAAC,CAAC;AAAA,QAChD;AACA;AAAA,MAEF;AACE,oBAAmB;AAAA,IAAA;AAGvB,WAAO,CAAC,EAAC,MAAM,MAAK;AAAA,EACtB;AACF;"}
@@ -1,42 +1,13 @@
1
- import type { Schema } from '../../../zero-types/src/schema.ts';
2
- import type { Format, ViewFactory } from '../../../zql/src/ivm/view.ts';
3
- import type { QueryDelegate } from '../../../zql/src/query/query-delegate.ts';
4
- import type { HumanReadable, MaterializeOptions, Query } from '../../../zql/src/query/query.ts';
5
- import type { TypedView } from '../../../zql/src/query/typed-view.ts';
6
- import type { CustomMutatorDefs } from './custom.ts';
7
- import type { Zero } from './zero.ts';
8
- export declare function registerZeroDelegate<TSchema extends Schema, MD extends CustomMutatorDefs | undefined, TContext>(zero: Zero<TSchema, MD, TContext>, delegate: QueryDelegate): void;
9
- /**
10
- * Bindings interface for Zero instances, providing methods to materialize queries
11
- * and extract query metadata.
12
- *
13
- * @internal This API is for bindings only, not end users.
14
- */
15
- export interface BindingsForZero<TSchema extends Schema> {
16
- /**
17
- * Materialize a query into a reactive view without a custom factory.
18
- * Returns a TypedView that automatically updates when underlying data changes.
19
- */
20
- materialize<TTable extends keyof TSchema['tables'] & string, TReturn>(query: Query<TTable, TSchema, TReturn>, factory?: undefined, options?: MaterializeOptions): TypedView<HumanReadable<TReturn>>;
21
- /**
22
- * Materialize a query into a reactive view using a custom factory.
23
- * The factory can transform the view into a framework-specific reactive object.
24
- */
25
- materialize<TTable extends keyof TSchema['tables'] & string, TReturn, T>(query: Query<TTable, TSchema, TReturn>, factory: ViewFactory<TTable, TSchema, TReturn, T>, options?: MaterializeOptions): T;
26
- /**
27
- * Compute the hash of a query for caching and deduplication purposes.
28
- */
29
- hash<TTable extends keyof TSchema['tables'] & string, TReturn>(query: Query<TTable, TSchema, TReturn>): string;
30
- /**
31
- * Get the format/schema of a query's result set.
32
- */
33
- format<TTable extends keyof TSchema['tables'] & string, TReturn>(query: Query<TTable, TSchema, TReturn>): Format;
34
- }
35
- /**
36
- * Create a bindings object for a Zero instance.
37
- * This provides low-level access to query materialization and metadata extraction.
38
- *
39
- * @internal This API is for bindings only, not end users.
40
- */
41
- export declare function bindingsForZero<TSchema extends Schema, MD extends CustomMutatorDefs | undefined, TContext>(zero: Zero<TSchema, MD, TContext>): BindingsForZero<TSchema>;
1
+ export { assert, unreachable } from '../../../shared/src/asserts.ts';
2
+ export { deepClone } from '../../../shared/src/deep-clone.ts';
3
+ export type { Immutable } from '../../../shared/src/immutable.ts';
4
+ export { must } from '../../../shared/src/must.ts';
5
+ export { skipYields } from '../../../zql/src/ivm/operator.ts';
6
+ export { consume } from '../../../zql/src/ivm/stream.ts';
7
+ export { applyChange, idSymbol, refCountSymbol, type ViewChange, } from '../../../zql/src/ivm/view-apply-change.ts';
8
+ export type { QueryDelegate } from '../../../zql/src/query/query-delegate.ts';
9
+ export { newQuery, type QueryImpl } from '../../../zql/src/query/query-impl.ts';
10
+ export { asQueryInternals, queryInternalsTag, } from '../../../zql/src/query/query-internals.ts';
11
+ export { addContextToQuery } from '../../../zql/src/query/query-registry.ts';
12
+ export { DEFAULT_TTL_MS } from '../../../zql/src/query/ttl.ts';
42
13
  //# sourceMappingURL=bindings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/bindings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAA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gBAAgB,EAChB,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC"}
@@ -55,6 +55,9 @@ export declare class TransactionImpl<TSchema extends Schema = DefaultSchema> imp
55
55
  #private;
56
56
  readonly location = "client";
57
57
  readonly mutate: MutateCRUD<TSchema>;
58
+ /**
59
+ * @deprecated Use {@linkcode createBuilder} with `tx.run(zql.table.where(...))` instead.
60
+ */
58
61
  readonly query: SchemaQuery<TSchema>;
59
62
  constructor(lc: LogContext, repTx: WriteTransaction, schema: TSchema);
60
63
  get clientID(): ClientID;
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/custom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,+CAA+C,CAAC;AAI9E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAGnE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAE9D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACZ,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,wCAAwC,CAAC;AACxE,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAIvD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAE9B,CAAC,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ED,IAAI,MAAM,IAAI,YAAY,GAAG,QAAQ,CAEpC;IAED,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,GAAG,CAAC,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAAE,OAAO,EAC1D,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EACtC,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;CAGnC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,UAAU,CAMjE;AAED,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,MAAM,EAChB,mBAAmB,EACnB,OAAO,EAEP,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE,mBAAmB,CAAC,EAClD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,OAAO,GACf,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAQrE"}
@@ -10,6 +10,9 @@ import { makeCRUDExecutor } from "./crud.js";
10
10
  class TransactionImpl {
11
11
  location = "client";
12
12
  mutate;
13
+ /**
14
+ * @deprecated Use {@linkcode createBuilder} with `tx.run(zql.table.where(...))` instead.
15
+ */
13
16
  query;
14
17
  #repTx;
15
18
  #zeroContext;
@@ -1 +1 @@
1
- {"version":3,"file":"custom.js","sources":["../../../../../zero-client/src/client/custom.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {ZeroTxData} from '../../../replicache/src/replicache-options.ts';\nimport type {WriteTransactionImpl} from '../../../replicache/src/transactions.ts';\nimport {zeroData} from '../../../replicache/src/transactions.ts';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {emptyFunction} from '../../../shared/src/sentinels.ts';\nimport type {DefaultSchema} from '../../../zero-types/src/default-types.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {makeMutateCRUDFunction} from '../../../zql/src/mutate/crud.ts';\nimport type {\n ClientTransaction,\n MutateCRUD,\n Transaction,\n} from '../../../zql/src/mutate/custom.ts';\nimport {createRunnableBuilder} from '../../../zql/src/query/create-builder.ts';\nimport {\n type HumanReadable,\n type Query,\n type RunOptions,\n} from '../../../zql/src/query/query.ts';\nimport type {SchemaQuery} from '../../../zql/src/query/schema-query.ts';\nimport type {ClientID} from '../types/client-state.ts';\nimport {ZeroContext} from './context.ts';\nimport {makeCRUDExecutor} from './crud.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\n/**\n * The shape which a user's custom mutator definitions must conform to.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type CustomMutatorDefs = {\n // oxlint-disable-next-line no-explicit-any\n [namespaceOrKey: string]: CustomMutatorImpl<any> | CustomMutatorDefs;\n};\n\nexport type MutatorResultDetails =\n | {\n readonly type: 'success';\n }\n | {\n readonly type: 'error';\n readonly error:\n | {\n readonly type: 'app';\n readonly message: string;\n readonly details: ReadonlyJSONValue | undefined;\n }\n | {\n readonly type: 'zero';\n readonly message: string;\n };\n };\n\nexport type MutatorResultSuccessDetails = Extract<\n MutatorResultDetails,\n {type: 'success'}\n>;\nexport type MutatorResultErrorDetails = Extract<\n MutatorResultDetails,\n {type: 'error'}\n>;\n\nexport type MutatorResult = {\n client: Promise<MutatorResultDetails & {}>;\n server: Promise<MutatorResultDetails & {}>;\n} & {};\n\nexport type CustomMutatorImpl<\n S extends Schema,\n TWrappedTransaction = unknown,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs = any,\n Context = unknown,\n> = (\n tx: Transaction<S, TWrappedTransaction>,\n // TODO: many args. See commit: 52657c2f934b4a458d628ea77e56ce92b61eb3c6 which did have many args.\n // The issue being that it will be a protocol change to support varargs.\n args: TArgs,\n ctx: Context,\n) => Promise<void>;\n\n/**\n * The shape exposed on the `Zero.mutate` instance.\n * The signature of a custom mutator takes a `transaction` as its first arg\n * but the user does not provide this arg when calling the mutator.\n *\n * This utility strips the `tx` arg from the user's custom mutator signatures.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type MakeCustomMutatorInterfaces<\n S extends Schema,\n MD extends CustomMutatorDefs,\n TContext,\n> = {\n readonly [NamespaceOrName in keyof MD]: MD[NamespaceOrName] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[NamespaceOrName] extends CustomMutatorDefs\n ? MakeCustomMutatorInterfaces<S, MD[NamespaceOrName], TContext>\n : never;\n};\n\nexport type MakeCustomMutatorInterface<TSchema extends Schema, F> = F extends (\n tx: ClientTransaction<TSchema>,\n ...args: infer Args\n) => Promise<void>\n ? (...args: Args) => MutatorResult\n : never;\n\nexport class TransactionImpl<TSchema extends Schema = DefaultSchema>\n implements ClientTransaction<TSchema>\n{\n readonly location = 'client';\n readonly mutate: MutateCRUD<TSchema>;\n readonly query: SchemaQuery<TSchema>;\n readonly #repTx: WriteTransaction;\n readonly #zeroContext: ZeroContext;\n\n constructor(lc: LogContext, repTx: WriteTransaction, schema: TSchema) {\n must(repTx.reason === 'initial' || repTx.reason === 'rebase');\n const txData = getZeroTxData(repTx);\n const ivmBranch = txData.ivmSources as IVMSourceBranch;\n\n this.#repTx = repTx;\n\n const executor = makeCRUDExecutor(repTx, schema, ivmBranch);\n this.mutate = makeMutateCRUDFunction(schema, executor);\n\n const zeroContext = newZeroContext(\n lc,\n txData.ivmSources as IVMSourceBranch,\n );\n\n this.query = createRunnableBuilder(zeroContext, schema);\n this.#zeroContext = zeroContext;\n }\n\n get clientID(): ClientID {\n return this.#repTx.clientID;\n }\n\n get mutationID(): number {\n return this.#repTx.mutationID;\n }\n\n get reason(): 'optimistic' | 'rebase' {\n return this.#repTx.reason === 'initial' ? 'optimistic' : 'rebase';\n }\n\n get token(): string | undefined {\n return (this.#repTx as WriteTransactionImpl)[zeroData]?.token;\n }\n\n run<TTable extends keyof TSchema['tables'] & string, TReturn>(\n query: Query<TTable, TSchema, TReturn>,\n options?: RunOptions,\n ): Promise<HumanReadable<TReturn>> {\n return this.#zeroContext.run(query, options);\n }\n}\n\nexport function getZeroTxData(repTx: WriteTransaction): ZeroTxData {\n const txData = must(\n (repTx as WriteTransactionImpl)[zeroData],\n 'zero was not set on replicache internal options!',\n );\n return txData as ZeroTxData;\n}\n\nexport function makeReplicacheMutator<\n S extends Schema,\n TWrappedTransaction,\n Context,\n>(\n lc: LogContext,\n mutator: CustomMutatorImpl<S, TWrappedTransaction>,\n schema: S,\n context: Context,\n): (repTx: WriteTransaction, args: ReadonlyJSONValue) => Promise<void> {\n return async (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n await mutator(tx, args, context);\n };\n}\n\nfunction assertValidRunOptions(options: RunOptions | undefined): void {\n // TODO(arv): We should enforce this with the type system too.\n assert(\n options?.type !== 'complete',\n 'Cannot wait for complete results in custom mutations',\n );\n}\n\nfunction newZeroContext(lc: LogContext, ivmBranch: IVMSourceBranch) {\n return new ZeroContext(\n lc,\n ivmBranch,\n () => emptyFunction,\n () => emptyFunction,\n emptyFunction,\n emptyFunction,\n emptyFunction,\n applyViewUpdates => applyViewUpdates(),\n emptyFunction,\n assertValidRunOptions,\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAkHO,MAAM,gBAEb;AAAA,EACW,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,IAAgB,OAAyB,QAAiB;AACpE,SAAK,MAAM,WAAW,aAAa,MAAM,WAAW,QAAQ;AAC5D,UAAM,SAAS,cAAc,KAAK;AAClC,UAAM,YAAY,OAAO;AAEzB,SAAK,SAAS;AAEd,UAAM,WAAW,iBAAiB,OAAO,QAAQ,SAAS;AAC1D,SAAK,SAAS,uBAAuB,QAAQ,QAAQ;AAErD,UAAM,cAAc;AAAA,MAClB;AAAA,MACA,OAAO;AAAA,IAAA;AAGT,SAAK,QAAQ,sBAAsB,aAAa,MAAM;AACtD,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,IAAI,WAAqB;AACvB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,aAAqB;AACvB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,SAAkC;AACpC,WAAO,KAAK,OAAO,WAAW,YAAY,eAAe;AAAA,EAC3D;AAAA,EAEA,IAAI,QAA4B;AAC9B,WAAQ,KAAK,OAAgC,QAAQ,GAAG;AAAA,EAC1D;AAAA,EAEA,IACE,OACA,SACiC;AACjC,WAAO,KAAK,aAAa,IAAI,OAAO,OAAO;AAAA,EAC7C;AACF;AAEO,SAAS,cAAc,OAAqC;AACjE,QAAM,SAAS;AAAA,IACZ,MAA+B,QAAQ;AAAA,IACxC;AAAA,EAAA;AAEF,SAAO;AACT;AAEO,SAAS,sBAKd,IACA,SACA,QACA,SACqE;AACrE,SAAO,OACL,OACA,SACkB;AAClB,UAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,UAAM,QAAQ,IAAI,MAAM,OAAO;AAAA,EACjC;AACF;AAEA,SAAS,sBAAsB,SAAuC;AAEpE;AAAA,IACE,SAAS,SAAS;AAAA,IAClB;AAAA,EAAA;AAEJ;AAEA,SAAS,eAAe,IAAgB,WAA4B;AAClE,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAoB,iBAAA;AAAA,IACpB;AAAA,IACA;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"custom.js","sources":["../../../../../zero-client/src/client/custom.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {ZeroTxData} from '../../../replicache/src/replicache-options.ts';\nimport type {WriteTransactionImpl} from '../../../replicache/src/transactions.ts';\nimport {zeroData} from '../../../replicache/src/transactions.ts';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {emptyFunction} from '../../../shared/src/sentinels.ts';\nimport type {DefaultSchema} from '../../../zero-types/src/default-types.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {makeMutateCRUDFunction} from '../../../zql/src/mutate/crud.ts';\nimport type {\n ClientTransaction,\n MutateCRUD,\n Transaction,\n} from '../../../zql/src/mutate/custom.ts';\nimport {createRunnableBuilder} from '../../../zql/src/query/create-builder.ts';\nimport {\n type HumanReadable,\n type Query,\n type RunOptions,\n} from '../../../zql/src/query/query.ts';\nimport type {SchemaQuery} from '../../../zql/src/query/schema-query.ts';\nimport type {ClientID} from '../types/client-state.ts';\nimport {ZeroContext} from './context.ts';\nimport {makeCRUDExecutor} from './crud.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\n/**\n * The shape which a user's custom mutator definitions must conform to.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type CustomMutatorDefs = {\n // oxlint-disable-next-line no-explicit-any\n [namespaceOrKey: string]: CustomMutatorImpl<any> | CustomMutatorDefs;\n};\n\nexport type MutatorResultDetails =\n | {\n readonly type: 'success';\n }\n | {\n readonly type: 'error';\n readonly error:\n | {\n readonly type: 'app';\n readonly message: string;\n readonly details: ReadonlyJSONValue | undefined;\n }\n | {\n readonly type: 'zero';\n readonly message: string;\n };\n };\n\nexport type MutatorResultSuccessDetails = Extract<\n MutatorResultDetails,\n {type: 'success'}\n>;\nexport type MutatorResultErrorDetails = Extract<\n MutatorResultDetails,\n {type: 'error'}\n>;\n\nexport type MutatorResult = {\n client: Promise<MutatorResultDetails & {}>;\n server: Promise<MutatorResultDetails & {}>;\n} & {};\n\nexport type CustomMutatorImpl<\n S extends Schema,\n TWrappedTransaction = unknown,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs = any,\n Context = unknown,\n> = (\n tx: Transaction<S, TWrappedTransaction>,\n // TODO: many args. See commit: 52657c2f934b4a458d628ea77e56ce92b61eb3c6 which did have many args.\n // The issue being that it will be a protocol change to support varargs.\n args: TArgs,\n ctx: Context,\n) => Promise<void>;\n\n/**\n * The shape exposed on the `Zero.mutate` instance.\n * The signature of a custom mutator takes a `transaction` as its first arg\n * but the user does not provide this arg when calling the mutator.\n *\n * This utility strips the `tx` arg from the user's custom mutator signatures.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type MakeCustomMutatorInterfaces<\n S extends Schema,\n MD extends CustomMutatorDefs,\n TContext,\n> = {\n readonly [NamespaceOrName in keyof MD]: MD[NamespaceOrName] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[NamespaceOrName] extends CustomMutatorDefs\n ? MakeCustomMutatorInterfaces<S, MD[NamespaceOrName], TContext>\n : never;\n};\n\nexport type MakeCustomMutatorInterface<TSchema extends Schema, F> = F extends (\n tx: ClientTransaction<TSchema>,\n ...args: infer Args\n) => Promise<void>\n ? (...args: Args) => MutatorResult\n : never;\n\nexport class TransactionImpl<TSchema extends Schema = DefaultSchema>\n implements ClientTransaction<TSchema>\n{\n readonly location = 'client';\n readonly mutate: MutateCRUD<TSchema>;\n /**\n * @deprecated Use {@linkcode createBuilder} with `tx.run(zql.table.where(...))` instead.\n */\n readonly query: SchemaQuery<TSchema>;\n\n readonly #repTx: WriteTransaction;\n readonly #zeroContext: ZeroContext;\n\n constructor(lc: LogContext, repTx: WriteTransaction, schema: TSchema) {\n must(repTx.reason === 'initial' || repTx.reason === 'rebase');\n const txData = getZeroTxData(repTx);\n const ivmBranch = txData.ivmSources as IVMSourceBranch;\n\n this.#repTx = repTx;\n\n const executor = makeCRUDExecutor(repTx, schema, ivmBranch);\n this.mutate = makeMutateCRUDFunction(schema, executor);\n\n const zeroContext = newZeroContext(\n lc,\n txData.ivmSources as IVMSourceBranch,\n );\n\n this.query = createRunnableBuilder(zeroContext, schema);\n\n this.#zeroContext = zeroContext;\n }\n\n get clientID(): ClientID {\n return this.#repTx.clientID;\n }\n\n get mutationID(): number {\n return this.#repTx.mutationID;\n }\n\n get reason(): 'optimistic' | 'rebase' {\n return this.#repTx.reason === 'initial' ? 'optimistic' : 'rebase';\n }\n\n get token(): string | undefined {\n return (this.#repTx as WriteTransactionImpl)[zeroData]?.token;\n }\n\n run<TTable extends keyof TSchema['tables'] & string, TReturn>(\n query: Query<TTable, TSchema, TReturn>,\n options?: RunOptions,\n ): Promise<HumanReadable<TReturn>> {\n return this.#zeroContext.run(query, options);\n }\n}\n\nexport function getZeroTxData(repTx: WriteTransaction): ZeroTxData {\n const txData = must(\n (repTx as WriteTransactionImpl)[zeroData],\n 'zero was not set on replicache internal options!',\n );\n return txData as ZeroTxData;\n}\n\nexport function makeReplicacheMutator<\n S extends Schema,\n TWrappedTransaction,\n Context,\n>(\n lc: LogContext,\n mutator: CustomMutatorImpl<S, TWrappedTransaction>,\n schema: S,\n context: Context,\n): (repTx: WriteTransaction, args: ReadonlyJSONValue) => Promise<void> {\n return async (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n await mutator(tx, args, context);\n };\n}\n\nfunction assertValidRunOptions(options: RunOptions | undefined): void {\n // TODO(arv): We should enforce this with the type system too.\n assert(\n options?.type !== 'complete',\n 'Cannot wait for complete results in custom mutations',\n );\n}\n\nfunction newZeroContext(lc: LogContext, ivmBranch: IVMSourceBranch) {\n return new ZeroContext(\n lc,\n ivmBranch,\n () => emptyFunction,\n () => emptyFunction,\n emptyFunction,\n emptyFunction,\n emptyFunction,\n applyViewUpdates => applyViewUpdates(),\n emptyFunction,\n assertValidRunOptions,\n );\n}\n"],"names":[],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;AAEJ;AAEA,SAAS,eAAe,IAAgB,WAA4B;AAClE,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAoB,iBAAA;AAAA,IACpB;AAAA,IACA;AAAA,EAAA;AAEJ;"}
@@ -14,7 +14,7 @@ import type { DeleteClientsBody, DeleteClientsMessage } from '../../../zero-prot
14
14
  */
15
15
  export declare class DeleteClientsManager {
16
16
  #private;
17
- constructor(send: (msg: DeleteClientsMessage) => void, dagStore: Store, lc: LogContext, clientGroupID: Promise<ClientGroupID>);
17
+ constructor(send: (msg: DeleteClientsMessage) => void, dagStore: Store, lc: LogContext, clientGroupID: Promise<ClientGroupID>, clientID: string);
18
18
  /**
19
19
  * This gets called by Replicache when it deletes clients from the persistent
20
20
  * storage.
@@ -1 +1 @@
1
- {"version":3,"file":"delete-clients-manager.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/delete-clients-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,qCAAqC,CAAC;AAMvE,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,8CAA8C,CAAC;AAEtD;;;;;;;;GAQG;AACH,qBAAa,oBAAoB;;gBAO7B,IAAI,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,IAAI,EACzC,QAAQ,EAAE,KAAK,EACf,EAAE,EAAE,UAAU,EACd,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IAQvC;;;OAGG;IACG,gBAAgB,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAarE;;;OAGG;IACG,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBjD;;;OAGG;IACH,sBAAsB,CAAC,cAAc,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAalE,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;CAOnD"}
1
+ {"version":3,"file":"delete-clients-manager.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/delete-clients-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,qCAAqC,CAAC;AAOvE,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,8CAA8C,CAAC;AAiBtD;;;;;;;;GAQG;AACH,qBAAa,oBAAoB;;gBAQ7B,IAAI,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,IAAI,EACzC,QAAQ,EAAE,KAAK,EACf,EAAE,EAAE,UAAU,EACd,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,EACrC,QAAQ,EAAE,MAAM;IASlB;;;OAGG;IACG,gBAAgB,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBrE;;;OAGG;IACG,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBjD;;;OAGG;IACH,sBAAsB,CAAC,cAAc,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAalE,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;CAanD"}
@@ -1,16 +1,26 @@
1
1
  import { getDeletedClients, confirmDeletedClients } from "../../../replicache/src/deleted-clients.js";
2
2
  import { withRead, withWrite } from "../../../replicache/src/with-transactions.js";
3
+ import { assert } from "../../../shared/src/asserts.js";
3
4
  import { promiseVoid } from "../../../shared/src/resolved-promises.js";
5
+ function filterAndAssert(deletedClients, clientGroupID, clientID, caller) {
6
+ const clientIDs = deletedClients.filter((dc) => dc.clientGroupID === clientGroupID).map((dc) => dc.clientID);
7
+ for (const cid of clientIDs) {
8
+ assert(cid !== clientID, `cannot delete self in ${caller}`);
9
+ }
10
+ return clientIDs;
11
+ }
4
12
  class DeleteClientsManager {
5
13
  #send;
6
14
  #lc;
7
15
  #dagStore;
8
16
  #clientGroupID;
9
- constructor(send, dagStore, lc, clientGroupID) {
17
+ #clientID;
18
+ constructor(send, dagStore, lc, clientGroupID, clientID) {
10
19
  this.#send = send;
11
20
  this.#dagStore = dagStore;
12
21
  this.#lc = lc;
13
22
  this.#clientGroupID = clientGroupID;
23
+ this.#clientID = clientID;
14
24
  }
15
25
  /**
16
26
  * This gets called by Replicache when it deletes clients from the persistent
@@ -19,10 +29,16 @@ class DeleteClientsManager {
19
29
  async onClientsDeleted(deletedClients) {
20
30
  this.#lc.debug?.("DeletedClientsManager, send:", deletedClients);
21
31
  const clientGroupID = await this.#clientGroupID;
32
+ const clientIDs = filterAndAssert(
33
+ deletedClients,
34
+ clientGroupID,
35
+ this.#clientID,
36
+ "onClientsDeleted"
37
+ );
22
38
  this.#send([
23
39
  "deleteClients",
24
40
  {
25
- clientIDs: deletedClients.filter((dc) => dc.clientGroupID === clientGroupID).map((dc) => dc.clientID)
41
+ clientIDs
26
42
  }
27
43
  ]);
28
44
  }
@@ -36,7 +52,12 @@ class DeleteClientsManager {
36
52
  this.#dagStore,
37
53
  (dagRead) => getDeletedClients(dagRead)
38
54
  );
39
- const clientIDs = deleted.filter((d) => d.clientGroupID === clientGroupID).map((d) => d.clientID);
55
+ const clientIDs = filterAndAssert(
56
+ deleted,
57
+ clientGroupID,
58
+ this.#clientID,
59
+ "sendDeletedClientsToServer"
60
+ );
40
61
  if (clientIDs.length > 0) {
41
62
  this.#send(["deleteClients", { clientIDs }]);
42
63
  this.#lc.debug?.("DeletedClientsManager, send:", deleted);
@@ -62,6 +83,12 @@ class DeleteClientsManager {
62
83
  (read) => getDeletedClients(read)
63
84
  );
64
85
  const clientGroupID = await this.#clientGroupID;
86
+ filterAndAssert(
87
+ deletedClients,
88
+ clientGroupID,
89
+ this.#clientID,
90
+ "getDeletedClients"
91
+ );
65
92
  return deletedClients.filter((d) => d.clientGroupID === clientGroupID);
66
93
  }
67
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"delete-clients-manager.js","sources":["../../../../../zero-client/src/client/delete-clients-manager.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {Store} from '../../../replicache/src/dag/store.ts';\nimport {\n confirmDeletedClients,\n getDeletedClients,\n type DeletedClients,\n} from '../../../replicache/src/deleted-clients.ts';\nimport type {ClientGroupID} from '../../../replicache/src/sync/ids.ts';\nimport {\n withRead,\n withWrite,\n} from '../../../replicache/src/with-transactions.ts';\nimport {promiseVoid} from '../../../shared/src/resolved-promises.ts';\nimport type {\n DeleteClientsBody,\n DeleteClientsMessage,\n} from '../../../zero-protocol/src/delete-clients.ts';\n\n/**\n * Replicache will tell us when it deletes clients from the persistent storage\n * due to GC. When this happens we tell the server about the deleted clients.\n * Replicache also store the deleted clients in IDB in case the server is\n * currently offline.\n *\n * The server will reply with the client it actually deleted. When we get that\n * we remove those IDs from our local storage.\n */\nexport class DeleteClientsManager {\n readonly #send: (msg: DeleteClientsMessage) => void;\n readonly #lc: LogContext;\n readonly #dagStore: Store;\n readonly #clientGroupID: Promise<ClientGroupID>;\n\n constructor(\n send: (msg: DeleteClientsMessage) => void,\n dagStore: Store,\n lc: LogContext,\n clientGroupID: Promise<ClientGroupID>,\n ) {\n this.#send = send;\n this.#dagStore = dagStore;\n this.#lc = lc;\n this.#clientGroupID = clientGroupID;\n }\n\n /**\n * This gets called by Replicache when it deletes clients from the persistent\n * storage.\n */\n async onClientsDeleted(deletedClients: DeletedClients): Promise<void> {\n this.#lc.debug?.('DeletedClientsManager, send:', deletedClients);\n const clientGroupID = await this.#clientGroupID;\n this.#send([\n 'deleteClients',\n {\n clientIDs: deletedClients\n .filter(dc => dc.clientGroupID === clientGroupID)\n .map(dc => dc.clientID),\n },\n ]);\n }\n\n /**\n * Zero calls this after it connects to ensure that the server knows about all\n * the clients that might have been deleted locally since the last connection.\n */\n async sendDeletedClientsToServer(): Promise<void> {\n const clientGroupID = await this.#clientGroupID;\n const deleted = await withRead(this.#dagStore, dagRead =>\n getDeletedClients(dagRead),\n );\n\n // Only send client ids that belong to this client group\n const clientIDs = deleted\n .filter(d => d.clientGroupID === clientGroupID)\n .map(d => d.clientID);\n\n if (clientIDs.length > 0) {\n this.#send(['deleteClients', {clientIDs}]);\n this.#lc.debug?.('DeletedClientsManager, send:', deleted);\n }\n }\n\n /**\n * This is called as a response to the server telling us which clients it\n * actually deleted.\n */\n clientsDeletedOnServer(deletedClients: DeleteClientsBody): Promise<void> {\n const {clientIDs = [], clientGroupIDs = []} = deletedClients;\n if (clientIDs.length > 0 || clientGroupIDs.length > 0) {\n // Get the deleted clients from the dag and remove the ones from the server.\n // then write them back to the dag.\n return withWrite(this.#dagStore, async dagWrite => {\n this.#lc.debug?.('clientsDeletedOnServer:', clientIDs, clientGroupIDs);\n await confirmDeletedClients(dagWrite, clientIDs, clientGroupIDs);\n });\n }\n return promiseVoid;\n }\n\n async getDeletedClients(): Promise<DeletedClients> {\n const deletedClients = await withRead(this.#dagStore, read =>\n getDeletedClients(read),\n );\n const clientGroupID = await this.#clientGroupID;\n return deletedClients.filter(d => d.clientGroupID === clientGroupID);\n }\n}\n"],"names":[],"mappings":";;;AA2BO,MAAM,qBAAqB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACE,MACA,UACA,IACA,eACA;AACA,SAAK,QAAQ;AACb,SAAK,YAAY;AACjB,SAAK,MAAM;AACX,SAAK,iBAAiB;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,iBAAiB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,aAAa;AAAA,EACrE;AACF;"}
1
+ {"version":3,"file":"delete-clients-manager.js","sources":["../../../../../zero-client/src/client/delete-clients-manager.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {Store} from '../../../replicache/src/dag/store.ts';\nimport {\n confirmDeletedClients,\n getDeletedClients,\n type DeletedClients,\n} from '../../../replicache/src/deleted-clients.ts';\nimport type {ClientGroupID} from '../../../replicache/src/sync/ids.ts';\nimport {\n withRead,\n withWrite,\n} from '../../../replicache/src/with-transactions.ts';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport {promiseVoid} from '../../../shared/src/resolved-promises.ts';\nimport type {\n DeleteClientsBody,\n DeleteClientsMessage,\n} from '../../../zero-protocol/src/delete-clients.ts';\n\nfunction filterAndAssert(\n deletedClients: DeletedClients,\n clientGroupID: ClientGroupID,\n clientID: string,\n caller: string,\n): string[] {\n const clientIDs = deletedClients\n .filter(dc => dc.clientGroupID === clientGroupID)\n .map(dc => dc.clientID);\n for (const cid of clientIDs) {\n assert(cid !== clientID, `cannot delete self in ${caller}`);\n }\n return clientIDs;\n}\n\n/**\n * Replicache will tell us when it deletes clients from the persistent storage\n * due to GC. When this happens we tell the server about the deleted clients.\n * Replicache also store the deleted clients in IDB in case the server is\n * currently offline.\n *\n * The server will reply with the client it actually deleted. When we get that\n * we remove those IDs from our local storage.\n */\nexport class DeleteClientsManager {\n readonly #send: (msg: DeleteClientsMessage) => void;\n readonly #lc: LogContext;\n readonly #dagStore: Store;\n readonly #clientGroupID: Promise<ClientGroupID>;\n readonly #clientID: string;\n\n constructor(\n send: (msg: DeleteClientsMessage) => void,\n dagStore: Store,\n lc: LogContext,\n clientGroupID: Promise<ClientGroupID>,\n clientID: string,\n ) {\n this.#send = send;\n this.#dagStore = dagStore;\n this.#lc = lc;\n this.#clientGroupID = clientGroupID;\n this.#clientID = clientID;\n }\n\n /**\n * This gets called by Replicache when it deletes clients from the persistent\n * storage.\n */\n async onClientsDeleted(deletedClients: DeletedClients): Promise<void> {\n this.#lc.debug?.('DeletedClientsManager, send:', deletedClients);\n const clientGroupID = await this.#clientGroupID;\n const clientIDs = filterAndAssert(\n deletedClients,\n clientGroupID,\n this.#clientID,\n 'onClientsDeleted',\n );\n this.#send([\n 'deleteClients',\n {\n clientIDs,\n },\n ]);\n }\n\n /**\n * Zero calls this after it connects to ensure that the server knows about all\n * the clients that might have been deleted locally since the last connection.\n */\n async sendDeletedClientsToServer(): Promise<void> {\n const clientGroupID = await this.#clientGroupID;\n const deleted = await withRead(this.#dagStore, dagRead =>\n getDeletedClients(dagRead),\n );\n\n const clientIDs = filterAndAssert(\n deleted,\n clientGroupID,\n this.#clientID,\n 'sendDeletedClientsToServer',\n );\n\n if (clientIDs.length > 0) {\n this.#send(['deleteClients', {clientIDs}]);\n this.#lc.debug?.('DeletedClientsManager, send:', deleted);\n }\n }\n\n /**\n * This is called as a response to the server telling us which clients it\n * actually deleted.\n */\n clientsDeletedOnServer(deletedClients: DeleteClientsBody): Promise<void> {\n const {clientIDs = [], clientGroupIDs = []} = deletedClients;\n if (clientIDs.length > 0 || clientGroupIDs.length > 0) {\n // Get the deleted clients from the dag and remove the ones from the server.\n // then write them back to the dag.\n return withWrite(this.#dagStore, async dagWrite => {\n this.#lc.debug?.('clientsDeletedOnServer:', clientIDs, clientGroupIDs);\n await confirmDeletedClients(dagWrite, clientIDs, clientGroupIDs);\n });\n }\n return promiseVoid;\n }\n\n async getDeletedClients(): Promise<DeletedClients> {\n const deletedClients = await withRead(this.#dagStore, read =>\n getDeletedClients(read),\n );\n const clientGroupID = await this.#clientGroupID;\n filterAndAssert(\n deletedClients,\n clientGroupID,\n this.#clientID,\n 'getDeletedClients',\n );\n return deletedClients.filter(d => d.clientGroupID === clientGroupID);\n }\n}\n"],"names":[],"mappings":";;;;AAmBA,SAAS,gBACP,gBACA,eACA,UACA,QACU;AACV,QAAM,YAAY,eACf,OAAO,CAAA,OAAM,GAAG,kBAAkB,aAAa,EAC/C,IAAI,CAAA,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WAAW,OAAM,aAAY;AACjD,aAAK,IAAI,QAAQ,2BAA2B,WAAW,cAAc;AACrE,cAAM,sBAAsB,UAAU,WAAW,cAAc;AAAA,MACjE,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,oBAA6C;AACjD,UAAM,iBAAiB,MAAM;AAAA,MAAS,KAAK;AAAA,MAAW,CAAA,SACpD,kBAAkB,IAAI;AAAA,IAAA;AAExB,UAAM,gBAAgB,MAAM,KAAK;AACjC;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK;AAAA,MACL;AAAA,IAAA;AAEF,WAAO,eAAe,OAAO,CAAA,MAAK,EAAE,kBAAkB,aAAa;AAAA,EACrE;AACF;"}
@@ -1,6 +1,7 @@
1
1
  import { CRUD_MUTATION_NAME } from "../../../zero-protocol/src/push.js";
2
2
  import { customMutatorKey } from "../../../zql/src/mutate/custom.js";
3
3
  import { isMutatorRegistry } from "../../../zql/src/mutate/mutator-registry.js";
4
+ import { isMutator } from "../../../zql/src/mutate/mutator.js";
4
5
  import { Internal } from "./client-error-kind-enum.js";
5
6
  import { makeCRUDMutator } from "./crud.js";
6
7
  import { TransactionImpl, makeReplicacheMutator as makeReplicacheMutator$1 } from "./custom.js";
@@ -82,9 +83,6 @@ function makeReplicacheMutators(schema, mutators, context, lc) {
82
83
  }
83
84
  return replicacheMutators;
84
85
  }
85
- function isMutator(value) {
86
- return typeof value === "function" && "mutatorName" in value && typeof value.mutatorName === "string" && "fn" in value && typeof value.fn === "function";
87
- }
88
86
  function extendFromMutatorRegistry(lc, context, registry, schema, mutateObject) {
89
87
  const walk = (node) => {
90
88
  if (typeof node !== "object" || node === null) {
@@ -1 +1 @@
1
- {"version":3,"file":"make-replicache-mutators.js","sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {MutatorDefs} from '../../../replicache/src/types.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {CRUD_MUTATION_NAME} from '../../../zero-protocol/src/push.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {customMutatorKey} from '../../../zql/src/mutate/custom.ts';\nimport {\n isMutatorRegistry,\n type AnyMutatorRegistry,\n} from '../../../zql/src/mutate/mutator-registry.ts';\nimport {type Mutator} from '../../../zql/src/mutate/mutator.ts';\nimport {ClientErrorKind} from './client-error-kind.ts';\nimport {makeCRUDMutator, type CRUDMutator} from './crud.ts';\nimport type {CustomMutatorDefs, CustomMutatorImpl} from './custom.ts';\nimport {\n makeReplicacheMutator as makeReplicacheMutatorLegacy,\n TransactionImpl,\n} from './custom.ts';\nimport {ClientError} from './error.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\nexport function extendReplicacheMutators<S extends Schema, C>(\n lc: LogContext,\n context: C,\n mutators: AnyMutatorRegistry | CustomMutatorDefs,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n // Recursively process mutator definitions at arbitrary depth\n const processMutators = (mutators: object, path: string[]) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n if (key === '~') {\n // Skip phantom type\n continue;\n }\n\n path.push(key);\n if (isMutator(mutator)) {\n const fullKey = customMutatorKey('.', path);\n mutateObject[fullKey] = makeReplicacheMutator(\n lc,\n mutator,\n schema,\n context,\n );\n } else if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[fullKey] = makeReplicacheMutatorLegacy(\n lc,\n // oxlint-disable-next-line no-explicit-any\n mutator as CustomMutatorImpl<any>,\n schema,\n context,\n );\n } else if (mutator !== null && typeof mutator === 'object') {\n processMutators(mutator, path);\n }\n path.pop();\n }\n };\n\n processMutators(mutators, []);\n}\n\nfunction makeReplicacheMutator<\n TArgs extends ReadonlyJSONValue | undefined,\n TSchema extends Schema,\n TContext,\n TWrappedTransaction,\n>(\n lc: LogContext,\n mutator: Mutator<TArgs, TSchema, TContext, TWrappedTransaction>,\n schema: TSchema,\n context: TContext,\n): (repTx: WriteTransaction, args: ReadonlyJSONValue) => Promise<void> {\n return async (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n // fn does input validation internally\n await mutator.fn({\n args: args as TArgs,\n ctx: context,\n tx: tx,\n });\n };\n}\n\n/**\n * Creates Replicache mutators from mutator definitions.\n *\n * This function processes mutator definitions at arbitrary depth, supporting both\n * new-style mutator definitions and legacy custom mutator implementations. It creates\n * a mutator object with the CRUD mutator and any provided custom mutators, with keys\n * generated based on their path in the mutator definition hierarchy.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The type of the context object passed to mutators\n *\n * @param schema - The schema instance used for validation and type checking\n * @param mutators - The mutator definitions to process, can be nested objects or custom mutator definitions\n * @param context - The context to be passed to mutators\n * @param lc - The log context used for logging operations\n *\n * @returns A mutator definitions object containing the CRUD mutator and any custom mutators\n *\n * @remarks\n * - New-style mutator definitions use '.' as a separator in their keys\n * - Legacy custom mutator implementations use '|' as a separator in their keys\n * - The CRUD mutator can be disabled by setting `enableLegacyMutators: false` in the schema\n */\nexport function makeReplicacheMutators<const S extends Schema, C>(\n schema: S,\n mutators: AnyMutatorRegistry | CustomMutatorDefs | undefined,\n context: C,\n lc: LogContext,\n): MutatorDefs & {_zero_crud: CRUDMutator} {\n const {enableLegacyMutators = false} = schema;\n\n const replicacheMutators = {\n [CRUD_MUTATION_NAME]: enableLegacyMutators\n ? makeCRUDMutator(schema)\n : // TODO(arv): This code is unreachable since the public API prevents\n // calling CRUD mutators when enableLegacyMutators is false. Remove this.\n () =>\n Promise.reject(\n new ClientError({\n kind: ClientErrorKind.Internal,\n message: 'Zero CRUD mutators are not enabled.',\n }),\n ),\n };\n\n if (mutators) {\n if (isMutatorRegistry(mutators)) {\n extendFromMutatorRegistry(\n lc,\n context,\n mutators,\n schema,\n replicacheMutators,\n );\n } else {\n extendReplicacheMutators(\n lc,\n context,\n mutators as CustomMutatorDefs,\n schema,\n replicacheMutators,\n );\n }\n }\n\n return replicacheMutators;\n}\n\n/**\n * Checks if a value is a Mutator (from MutatorRegistry).\n * Mutators have `mutatorName` and `fn` properties.\n */\nfunction isMutator(\n value: unknown,\n // oxlint-disable-next-line no-explicit-any\n): value is Mutator<any, any, any> {\n return (\n typeof value === 'function' &&\n 'mutatorName' in value &&\n typeof value.mutatorName === 'string' &&\n 'fn' in value &&\n typeof value.fn === 'function'\n );\n}\n\n/**\n * Extends replicache mutators from a MutatorRegistry.\n * Walks the registry tree and wraps each Mutator.fn for Replicache.\n */\nfunction extendFromMutatorRegistry<S extends Schema, C>(\n lc: LogContext,\n context: C,\n registry: AnyMutatorRegistry,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n const walk = (node: unknown) => {\n if (typeof node !== 'object' || node === null) {\n return;\n }\n for (const value of Object.values(node)) {\n if (isMutator(value)) {\n // Mutator.fn already handles validation internally\n mutateObject[value.mutatorName] = (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n return value.fn({args, ctx: context, tx});\n };\n } else if (typeof value === 'object' && value !== null) {\n // Nested namespace\n walk(value);\n }\n }\n };\n walk(registry);\n}\n"],"names":["mutators","makeReplicacheMutatorLegacy","ClientErrorKind.Internal"],"mappings":";;;;;;;AAqBO,SAAS,yBACd,IACA,SACA,UACA,QACA,cACM;AAEN,QAAM,kBAAkB,CAACA,WAAkB,SAAmB;AAC5D,eAAW,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQA,SAAQ,GAAG;AACrD,UAAI,QAAQ,KAAK;AAEf;AAAA,MACF;AAEA,WAAK,KAAK,GAAG;AACb,UAAI,UAAU,OAAO,GAAG;AACtB,cAAM,UAAU,iBAAiB,KAAK,IAAI;AAC1C,qBAAa,OAAO,IAAI;AAAA,UACtB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ,WAAW,OAAO,YAAY,YAAY;AACxC,cAAM,UAA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AAO,CAAC,SAAkB;AAC9B,QAAI,OAAO,SAAS,YAAY,SAAS,MAAM;AAC7C;AAAA,IACF;AACA,eAAW,SAAS,OAAO,OAAO,IAAI,GAAG;AACvC,UAAI,UAAU,KAAK,GAAG;AAEpB,qBAAa,MAAM,WAAW,IAAI,CAChC,OACA,SACkB;AAClB,gBAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,iBAAO,MAAM,GAAG,EAAC,MAAM,KAAK,SAAS,IAAG;AAAA,QAC1C;AAAA,MACF,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AAEtD,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACA,OAAK,QAAQ;AACf;"}
1
+ {"version":3,"file":"make-replicache-mutators.js","sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {MutatorDefs} from '../../../replicache/src/types.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {CRUD_MUTATION_NAME} from '../../../zero-protocol/src/push.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {customMutatorKey} from '../../../zql/src/mutate/custom.ts';\nimport {\n isMutatorRegistry,\n type AnyMutatorRegistry,\n} from '../../../zql/src/mutate/mutator-registry.ts';\nimport {isMutator, type Mutator} from '../../../zql/src/mutate/mutator.ts';\nimport {ClientErrorKind} from './client-error-kind.ts';\nimport {makeCRUDMutator, type CRUDMutator} from './crud.ts';\nimport type {CustomMutatorDefs, CustomMutatorImpl} from './custom.ts';\nimport {\n makeReplicacheMutator as makeReplicacheMutatorLegacy,\n TransactionImpl,\n} from './custom.ts';\nimport {ClientError} from './error.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\nexport function extendReplicacheMutators<S extends Schema, C>(\n lc: LogContext,\n context: C,\n mutators: AnyMutatorRegistry | CustomMutatorDefs,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n // Recursively process mutator definitions at arbitrary depth\n const processMutators = (mutators: object, path: string[]) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n if (key === '~') {\n // Skip phantom type\n continue;\n }\n\n path.push(key);\n if (isMutator(mutator)) {\n const fullKey = customMutatorKey('.', path);\n mutateObject[fullKey] = makeReplicacheMutator(\n lc,\n mutator,\n schema,\n context,\n );\n } else if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[fullKey] = makeReplicacheMutatorLegacy(\n lc,\n // oxlint-disable-next-line no-explicit-any\n mutator as CustomMutatorImpl<any>,\n schema,\n context,\n );\n } else if (mutator !== null && typeof mutator === 'object') {\n processMutators(mutator, path);\n }\n path.pop();\n }\n };\n\n processMutators(mutators, []);\n}\n\nfunction makeReplicacheMutator<\n TArgs extends ReadonlyJSONValue | undefined,\n TSchema extends Schema,\n TContext,\n TWrappedTransaction,\n>(\n lc: LogContext,\n mutator: Mutator<TArgs, TSchema, TContext, TWrappedTransaction>,\n schema: TSchema,\n context: TContext,\n): (repTx: WriteTransaction, args: ReadonlyJSONValue) => Promise<void> {\n return async (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n // fn does input validation internally\n await mutator.fn({\n args: args as TArgs,\n ctx: context,\n tx: tx,\n });\n };\n}\n\n/**\n * Creates Replicache mutators from mutator definitions.\n *\n * This function processes mutator definitions at arbitrary depth, supporting both\n * new-style mutator definitions and legacy custom mutator implementations. It creates\n * a mutator object with the CRUD mutator and any provided custom mutators, with keys\n * generated based on their path in the mutator definition hierarchy.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The type of the context object passed to mutators\n *\n * @param schema - The schema instance used for validation and type checking\n * @param mutators - The mutator definitions to process, can be nested objects or custom mutator definitions\n * @param context - The context to be passed to mutators\n * @param lc - The log context used for logging operations\n *\n * @returns A mutator definitions object containing the CRUD mutator and any custom mutators\n *\n * @remarks\n * - New-style mutator definitions use '.' as a separator in their keys\n * - Legacy custom mutator implementations use '|' as a separator in their keys\n * - The CRUD mutator can be disabled by setting `enableLegacyMutators: false` in the schema\n */\nexport function makeReplicacheMutators<const S extends Schema, C>(\n schema: S,\n mutators: AnyMutatorRegistry | CustomMutatorDefs | undefined,\n context: C,\n lc: LogContext,\n): MutatorDefs & {_zero_crud: CRUDMutator} {\n const {enableLegacyMutators = false} = schema;\n\n const replicacheMutators = {\n [CRUD_MUTATION_NAME]: enableLegacyMutators\n ? makeCRUDMutator(schema)\n : // TODO(arv): This code is unreachable since the public API prevents\n // calling CRUD mutators when enableLegacyMutators is false. Remove this.\n () =>\n Promise.reject(\n new ClientError({\n kind: ClientErrorKind.Internal,\n message: 'Zero CRUD mutators are not enabled.',\n }),\n ),\n };\n\n if (mutators) {\n if (isMutatorRegistry(mutators)) {\n extendFromMutatorRegistry(\n lc,\n context,\n mutators,\n schema,\n replicacheMutators,\n );\n } else {\n extendReplicacheMutators(\n lc,\n context,\n mutators as CustomMutatorDefs,\n schema,\n replicacheMutators,\n );\n }\n }\n\n return replicacheMutators;\n}\n\n/**\n * Extends replicache mutators from a MutatorRegistry.\n * Walks the registry tree and wraps each Mutator.fn for Replicache.\n */\nfunction extendFromMutatorRegistry<S extends Schema, C>(\n lc: LogContext,\n context: C,\n registry: AnyMutatorRegistry,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n const walk = (node: unknown) => {\n if (typeof node !== 'object' || node === null) {\n return;\n }\n for (const value of Object.values(node)) {\n if (isMutator<S>(value)) {\n // Mutator.fn already handles validation internally\n mutateObject[value.mutatorName] = (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n return value.fn({args, ctx: context, tx});\n };\n } else if (typeof value === 'object' && value !== null) {\n // Nested namespace\n walk(value);\n }\n }\n };\n walk(registry);\n}\n"],"names":["mutators","makeReplicacheMutatorLegacy","ClientErrorKind.Internal"],"mappings":";;;;;;;;AAqBO,SAAS,yB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AAQ,GAAG;AAC/B;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ,OAAO;AACL;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEA,SAAO;AACT;AAMA,SAAS,0BACP,IACA,SACA,UACA,QACA,cACM;AACN,QAAM,OAAO,CAAC,SAAkB;AAC9B,QAAI,OAAO,SAAS,YAAY,SAAS,MAAM;AAC7C;AAAA,IACF;AACA,eAAW,SAAS,OAAO,OAAO,IAAI,GAAG;AACvC,UAAI,UAAa,KAAK,GAAG;AAEvB,qBAAa,MAAM,WAAW,IAAI,CAChC,OACA,SACkB;AAClB,gBAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,iBAAO,MAAM,GAAG,EAAC,MAAM,KAAK,SAAS,IAAG;AAAA,QAC1C;AAAA,MACF,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AAEtD,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACA,OAAK,QAAQ;AACf;"}
@@ -142,7 +142,7 @@ export interface ZeroOptions<S extends Schema = DefaultSchema, MD extends Custom
142
142
  * });
143
143
  * ```
144
144
  *
145
- * Or use a hook like {@linkcode useZeroConnectionState} to subscribe to state changes.
145
+ * Or use a hook like {@linkcode useConnectionState} to subscribe to state changes.
146
146
  */
147
147
  onOnlineChange?: ((online: boolean) => void) | undefined;
148
148
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sources":["../../../../../zero-client/src/client/options.ts"],"sourcesContent":["import type {LogLevel} from '@rocicorp/logger';\nimport type {StoreProvider} from '../../../replicache/src/kv/store.ts';\nimport * as v from '../../../shared/src/valita.ts';\nimport type {\n DefaultContext,\n DefaultSchema,\n} from '../../../zero-types/src/default-types.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport type {AnyMutatorRegistry} from '../../../zql/src/mutate/mutator-registry.ts';\nimport type {CustomMutatorDefs} from './custom.ts';\nimport {UpdateNeededReasonType} from './update-needed-reason-type.ts';\n\n/**\n * Configuration for {@linkcode Zero}.\n */\nexport interface ZeroOptions<\n S extends Schema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n C = DefaultContext,\n> {\n /**\n * URL to the zero-cache. This can be a simple hostname, e.g.\n * - \"https://myapp-myteam.zero.ms\"\n * or a prefix with a single path component, e.g.\n * - \"https://myapp-myteam.zero.ms/zero\"\n * - \"https://myapp-myteam.zero.ms/db\"\n *\n * The latter is useful for configuring routing rules (e.g. \"/zero/\\*\") when\n * the zero-cache is hosted on the same domain as the application. **Note that\n * only a single path segment is allowed (e.g. it cannot be \"/proxy/zero/\\*\")**.\n */\n cacheURL?: string | null | undefined;\n\n /**\n * @deprecated Use {@linkcode cacheURL} instead.\n */\n server?: string | null | undefined;\n\n /**\n * A token to identify and authenticate the user.\n *\n * Set `auth` to `null` or `undefined` if there is no logged in user.\n *\n * When a 401 or 403 HTTP status code is received from your server, Zero will\n * transition to the `needs-auth` connection state. The app should call\n * `zero.connection.connect({auth: newToken})` with a new token to reconnect.\n *\n * The call to `connect` is handled automatically by the ZeroProvider component\n * for React and SolidJS when the `auth` prop changes.\n */\n auth?: string | null | undefined;\n\n /**\n * A unique identifier for the user. Must be non-empty.\n *\n * Each userID gets its own client-side storage so that the app can switch\n * between users without losing state.\n *\n * This must match the `sub` claim of the `auth` token if\n * `auth` is provided.\n */\n userID: string;\n\n /**\n * Distinguishes the storage used by this Zero instance from that of other\n * instances with the same userID. Useful in the case where the app wants to\n * have multiple Zero instances for the same user for different parts of the\n * app.\n */\n storageKey?: string | undefined;\n\n /**\n * Determines the level of detail at which Zero logs messages about\n * its operation. Messages are logged to the `console`.\n *\n * When this is set to `'debug'`, `'info'` and `'error'` messages are also\n * logged. When set to `'info'`, `'info'` and `'error'` but not\n * `'debug'` messages are logged. When set to `'error'` only `'error'`\n * messages are logged.\n *\n * Default is `'error'`.\n */\n logLevel?: LogLevel | undefined;\n\n /**\n * This defines the schema of the tables used in Zero and their relationships\n * to one another.\n */\n schema: S;\n\n /**\n * `mutators` is a map of custom mutator definitions. The keys are\n * namespaces or names of the mutators. The values are the mutator\n * implementations. Client side mutators must be idempotent as a\n * mutation can be rebased multiple times when folding in authoritative\n * changes from the server to the client.\n *\n * Define mutators using the `defineMutator` function to create type-safe,\n * parameterized mutations. Mutators can be top-level or grouped in namespaces.\n *\n * @example\n * ```ts\n * import {defineMutator} from '@rocicorp/zero';\n *\n * const z = new Zero({\n * schema,\n * userID,\n * mutators: {\n * // Top-level mutator\n * increment: defineMutator(({tx, args}: {tx: Transaction<Schema>, args: {id: string}}) =>\n * tx.mutate.counter.update({id: args.id, value: tx.query.counter.where('id', '=', args.id).value + 1})\n * ),\n * // Namespace with multiple mutators\n * issues: {\n * create: defineMutator(({tx, args}: {tx: Transaction<Schema>, args: {title: string}}) =>\n * tx.mutate.issues.insert({id: nanoid(), title: args.title, status: 'open'})\n * ),\n * close: defineMutator(({tx, args}: {tx: Transaction<Schema>, args: {id: string}}) =>\n * tx.mutate.issues.update({id: args.id, status: 'closed'})\n * ),\n * },\n * },\n * });\n *\n * // Usage\n * await z.mutate.increment({id: 'counter-1'}).client;\n * await z.mutate.issues.create({title: 'New issue'}).client;\n * await z.mutate.issues.close({id: 'issue-123'}).client;\n * ```\n */\n mutators?: MD extends CustomMutatorDefs ? MD : AnyMutatorRegistry | undefined;\n\n /**\n * Custom URL for mutation requests sent to your API server.\n * If not provided, uses the default configured in zero-cache.\n */\n mutateURL?: string | undefined;\n\n /**\n * Custom URL for query requests sent to your API server.\n * If not provided, uses the default configured in zero-cache.\n *\n * @deprecated Use {@linkcode queryURL} instead.\n */\n getQueriesURL?: string | undefined;\n\n /**\n * Custom URL for query requests sent to your API server.\n * If not provided, uses the default configured in zero-cache.\n */\n queryURL?: string | undefined;\n\n /**\n * `onOnlineChange` is called when the Zero instance's online status changes.\n *\n * @deprecated Use {@linkcode Connection.state.subscribe} on the Zero instance instead. e.g.\n * ```ts\n * const zero = new Zero({...});\n * zero.connection.state.subscribe((state) => {\n * console.log('Connection state:', state.name);\n * });\n * ```\n *\n * Or use a hook like {@linkcode useZeroConnectionState} to subscribe to state changes.\n */\n onOnlineChange?: ((online: boolean) => void) | undefined;\n\n /**\n * `onUpdateNeeded` is called when a client code update is needed.\n *\n * See {@link UpdateNeededReason} for why updates can be needed.\n *\n * The default behavior is to reload the page (using `location.reload()`).\n * Provide your own function to prevent the page from\n * reloading automatically. You may want to display a toast to inform the end\n * user there is a new version of your app available and prompt them to\n * refresh.\n */\n onUpdateNeeded?: ((reason: UpdateNeededReason) => void) | undefined;\n\n /**\n * `onClientStateNotFound` is called when this client is no longer able\n * to sync with the zero-cache due to missing synchronization state. This\n * can be because:\n * - the local persistent synchronization state has been garbage collected.\n * This can happen if the client has no pending mutations and has not been\n * used for a while (e.g. the client's tab has been hidden for a long time).\n * - the zero-cache fails to find the server side synchronization state for\n * this client.\n *\n * The default behavior is to reload the page (using `location.reload()`).\n * Provide your own function to prevent the page from reloading automatically.\n */\n onClientStateNotFound?: (() => void) | undefined;\n\n /**\n * The number of milliseconds to wait before disconnecting a Zero\n * instance whose tab has become hidden.\n *\n * Instances in hidden tabs are disconnected to save resources.\n *\n * Default is 5_000.\n */\n hiddenTabDisconnectDelay?: number | undefined;\n\n /**\n * The number of milliseconds to wait before disconnecting a Zero\n * instance when the connection to the server has timed out.\n *\n * Default is 5 minutes.\n */\n disconnectTimeoutMs?: number | undefined;\n\n /**\n * The timeout in milliseconds for ping operations. This value is used for:\n * - How long to wait in idle before sending a ping to the server\n * - How long to wait for a pong response after sending a ping\n *\n * Total time to detect a dead connection is 2 × pingTimeoutMs.\n *\n * Default is 5_000.\n */\n pingTimeoutMs?: number | undefined;\n\n /**\n * Determines what kind of storage implementation to use on the client.\n *\n * Defaults to `'idb'` which means that Zero uses an IndexedDB storage\n * implementation. This allows the data to be persisted on the client and\n * enables faster syncs between application restarts.\n *\n * By setting this to `'mem'`, Zero uses an in memory storage and\n * the data is not persisted on the client.\n *\n * You can also set this to a function that is used to create new KV stores,\n * allowing a custom implementation of the underlying storage layer.\n */\n kvStore?: 'mem' | 'idb' | StoreProvider | undefined;\n\n /**\n * The maximum number of bytes to allow in a single header.\n *\n * Zero adds some extra information to headers on initialization if possible.\n * This speeds up data synchronization. This number should be kept less than\n * or equal to the maximum header size allowed by the zero-cache and any load\n * balancers.\n *\n * Default value: 8kb.\n */\n maxHeaderLength?: number | undefined;\n\n /**\n * The maximum amount of milliseconds to wait for a materialization to\n * complete (including network/server time) before printing a warning to the\n * console.\n *\n * Default value: 5_000.\n */\n slowMaterializeThreshold?: number | undefined;\n\n /**\n * UI rendering libraries will often provide a utility for batching multiple\n * state updates into a single render. Some examples are React's\n * `unstable_batchedUpdates`, and solid-js's `batch`.\n *\n * This option enables integrating these batch utilities with Zero.\n *\n * When `batchViewUpdates` is provided, Zero will call it whenever\n * it updates query view state with an `applyViewUpdates` function\n * that performs the actual state updates.\n *\n * Zero updates query view state when:\n * 1. creating a new view\n * 2. updating all existing queries' views to a new consistent state\n *\n * When creating a new view, that single view's creation will be wrapped\n * in a `batchViewUpdates` call.\n *\n * When updating existing queries, all queries will be updated in a single\n * `batchViewUpdates` call, so that the transition to the new consistent\n * state can be done in a single render.\n *\n * Implementations must always call `applyViewUpdates` synchronously.\n */\n batchViewUpdates?: ((applyViewUpdates: () => void) => void) | undefined;\n\n /**\n * The maximum number of recent queries, no longer subscribed to by a preload\n * or view, to continue syncing.\n *\n * Defaults is 0.\n *\n * @deprecated Use ttl instead\n */\n maxRecentQueries?: number | undefined;\n\n /**\n * Changes to queries are sent to server in batches. This option controls\n * the number of milliseconds to wait before sending the next batch.\n *\n * Defaults is 10.\n */\n queryChangeThrottleMs?: number | undefined;\n\n /**\n * Context is passed to Synced Queries when they are executed\n */\n // TODO(arv): Mutators should also get context.\n context?: C | undefined;\n}\n\n/**\n * @deprecated Use {@link ZeroOptions} instead.\n */\nexport interface ZeroAdvancedOptions<\n S extends Schema,\n MD extends CustomMutatorDefs | undefined,\n Context,\n> extends ZeroOptions<S, MD, Context> {}\n\ntype UpdateNeededReasonBase = {\n message?: string;\n};\n\nexport type UpdateNeededReason =\n | ({type: UpdateNeededReasonType.NewClientGroup} & UpdateNeededReasonBase)\n | ({\n type: UpdateNeededReasonType.VersionNotSupported;\n } & UpdateNeededReasonBase)\n | ({\n type: UpdateNeededReasonType.SchemaVersionNotSupported;\n } & UpdateNeededReasonBase);\n\nexport const updateNeededReasonTypeSchema: v.Type<UpdateNeededReason['type']> =\n v.literalUnion(\n UpdateNeededReasonType.NewClientGroup,\n UpdateNeededReasonType.VersionNotSupported,\n UpdateNeededReasonType.SchemaVersionNotSupported,\n );\n"],"names":["v.literalUnion","UpdateNeededReasonType.NewClientGroup","UpdateNeededReasonType.VersionNotSupported","UpdateNeededReasonType.SchemaVersionNotSupported"],"mappings":";;AA6UO,MAAM,+BACXA;AAAAA,EACEC;AAAAA,EACAC;AAAAA,EACAC;AACF;"}
1
+ {"version":3,"file":"options.js","sources":["../../../../../zero-client/src/client/options.ts"],"sourcesContent":["import type {LogLevel} from '@rocicorp/logger';\nimport type {StoreProvider} from '../../../replicache/src/kv/store.ts';\nimport * as v from '../../../shared/src/valita.ts';\nimport type {\n DefaultContext,\n DefaultSchema,\n} from '../../../zero-types/src/default-types.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport type {AnyMutatorRegistry} from '../../../zql/src/mutate/mutator-registry.ts';\nimport type {CustomMutatorDefs} from './custom.ts';\nimport {UpdateNeededReasonType} from './update-needed-reason-type.ts';\n\n/**\n * Configuration for {@linkcode Zero}.\n */\nexport interface ZeroOptions<\n S extends Schema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n C = DefaultContext,\n> {\n /**\n * URL to the zero-cache. This can be a simple hostname, e.g.\n * - \"https://myapp-myteam.zero.ms\"\n * or a prefix with a single path component, e.g.\n * - \"https://myapp-myteam.zero.ms/zero\"\n * - \"https://myapp-myteam.zero.ms/db\"\n *\n * The latter is useful for configuring routing rules (e.g. \"/zero/\\*\") when\n * the zero-cache is hosted on the same domain as the application. **Note that\n * only a single path segment is allowed (e.g. it cannot be \"/proxy/zero/\\*\")**.\n */\n cacheURL?: string | null | undefined;\n\n /**\n * @deprecated Use {@linkcode cacheURL} instead.\n */\n server?: string | null | undefined;\n\n /**\n * A token to identify and authenticate the user.\n *\n * Set `auth` to `null` or `undefined` if there is no logged in user.\n *\n * When a 401 or 403 HTTP status code is received from your server, Zero will\n * transition to the `needs-auth` connection state. The app should call\n * `zero.connection.connect({auth: newToken})` with a new token to reconnect.\n *\n * The call to `connect` is handled automatically by the ZeroProvider component\n * for React and SolidJS when the `auth` prop changes.\n */\n auth?: string | null | undefined;\n\n /**\n * A unique identifier for the user. Must be non-empty.\n *\n * Each userID gets its own client-side storage so that the app can switch\n * between users without losing state.\n *\n * This must match the `sub` claim of the `auth` token if\n * `auth` is provided.\n */\n userID: string;\n\n /**\n * Distinguishes the storage used by this Zero instance from that of other\n * instances with the same userID. Useful in the case where the app wants to\n * have multiple Zero instances for the same user for different parts of the\n * app.\n */\n storageKey?: string | undefined;\n\n /**\n * Determines the level of detail at which Zero logs messages about\n * its operation. Messages are logged to the `console`.\n *\n * When this is set to `'debug'`, `'info'` and `'error'` messages are also\n * logged. When set to `'info'`, `'info'` and `'error'` but not\n * `'debug'` messages are logged. When set to `'error'` only `'error'`\n * messages are logged.\n *\n * Default is `'error'`.\n */\n logLevel?: LogLevel | undefined;\n\n /**\n * This defines the schema of the tables used in Zero and their relationships\n * to one another.\n */\n schema: S;\n\n /**\n * `mutators` is a map of custom mutator definitions. The keys are\n * namespaces or names of the mutators. The values are the mutator\n * implementations. Client side mutators must be idempotent as a\n * mutation can be rebased multiple times when folding in authoritative\n * changes from the server to the client.\n *\n * Define mutators using the `defineMutator` function to create type-safe,\n * parameterized mutations. Mutators can be top-level or grouped in namespaces.\n *\n * @example\n * ```ts\n * import {defineMutator} from '@rocicorp/zero';\n *\n * const z = new Zero({\n * schema,\n * userID,\n * mutators: {\n * // Top-level mutator\n * increment: defineMutator(({tx, args}: {tx: Transaction<Schema>, args: {id: string}}) =>\n * tx.mutate.counter.update({id: args.id, value: tx.query.counter.where('id', '=', args.id).value + 1})\n * ),\n * // Namespace with multiple mutators\n * issues: {\n * create: defineMutator(({tx, args}: {tx: Transaction<Schema>, args: {title: string}}) =>\n * tx.mutate.issues.insert({id: nanoid(), title: args.title, status: 'open'})\n * ),\n * close: defineMutator(({tx, args}: {tx: Transaction<Schema>, args: {id: string}}) =>\n * tx.mutate.issues.update({id: args.id, status: 'closed'})\n * ),\n * },\n * },\n * });\n *\n * // Usage\n * await z.mutate.increment({id: 'counter-1'}).client;\n * await z.mutate.issues.create({title: 'New issue'}).client;\n * await z.mutate.issues.close({id: 'issue-123'}).client;\n * ```\n */\n mutators?: MD extends CustomMutatorDefs ? MD : AnyMutatorRegistry | undefined;\n\n /**\n * Custom URL for mutation requests sent to your API server.\n * If not provided, uses the default configured in zero-cache.\n */\n mutateURL?: string | undefined;\n\n /**\n * Custom URL for query requests sent to your API server.\n * If not provided, uses the default configured in zero-cache.\n *\n * @deprecated Use {@linkcode queryURL} instead.\n */\n getQueriesURL?: string | undefined;\n\n /**\n * Custom URL for query requests sent to your API server.\n * If not provided, uses the default configured in zero-cache.\n */\n queryURL?: string | undefined;\n\n /**\n * `onOnlineChange` is called when the Zero instance's online status changes.\n *\n * @deprecated Use {@linkcode Connection.state.subscribe} on the Zero instance instead. e.g.\n * ```ts\n * const zero = new Zero({...});\n * zero.connection.state.subscribe((state) => {\n * console.log('Connection state:', state.name);\n * });\n * ```\n *\n * Or use a hook like {@linkcode useConnectionState} to subscribe to state changes.\n */\n onOnlineChange?: ((online: boolean) => void) | undefined;\n\n /**\n * `onUpdateNeeded` is called when a client code update is needed.\n *\n * See {@link UpdateNeededReason} for why updates can be needed.\n *\n * The default behavior is to reload the page (using `location.reload()`).\n * Provide your own function to prevent the page from\n * reloading automatically. You may want to display a toast to inform the end\n * user there is a new version of your app available and prompt them to\n * refresh.\n */\n onUpdateNeeded?: ((reason: UpdateNeededReason) => void) | undefined;\n\n /**\n * `onClientStateNotFound` is called when this client is no longer able\n * to sync with the zero-cache due to missing synchronization state. This\n * can be because:\n * - the local persistent synchronization state has been garbage collected.\n * This can happen if the client has no pending mutations and has not been\n * used for a while (e.g. the client's tab has been hidden for a long time).\n * - the zero-cache fails to find the server side synchronization state for\n * this client.\n *\n * The default behavior is to reload the page (using `location.reload()`).\n * Provide your own function to prevent the page from reloading automatically.\n */\n onClientStateNotFound?: (() => void) | undefined;\n\n /**\n * The number of milliseconds to wait before disconnecting a Zero\n * instance whose tab has become hidden.\n *\n * Instances in hidden tabs are disconnected to save resources.\n *\n * Default is 5_000.\n */\n hiddenTabDisconnectDelay?: number | undefined;\n\n /**\n * The number of milliseconds to wait before disconnecting a Zero\n * instance when the connection to the server has timed out.\n *\n * Default is 5 minutes.\n */\n disconnectTimeoutMs?: number | undefined;\n\n /**\n * The timeout in milliseconds for ping operations. This value is used for:\n * - How long to wait in idle before sending a ping to the server\n * - How long to wait for a pong response after sending a ping\n *\n * Total time to detect a dead connection is 2 × pingTimeoutMs.\n *\n * Default is 5_000.\n */\n pingTimeoutMs?: number | undefined;\n\n /**\n * Determines what kind of storage implementation to use on the client.\n *\n * Defaults to `'idb'` which means that Zero uses an IndexedDB storage\n * implementation. This allows the data to be persisted on the client and\n * enables faster syncs between application restarts.\n *\n * By setting this to `'mem'`, Zero uses an in memory storage and\n * the data is not persisted on the client.\n *\n * You can also set this to a function that is used to create new KV stores,\n * allowing a custom implementation of the underlying storage layer.\n */\n kvStore?: 'mem' | 'idb' | StoreProvider | undefined;\n\n /**\n * The maximum number of bytes to allow in a single header.\n *\n * Zero adds some extra information to headers on initialization if possible.\n * This speeds up data synchronization. This number should be kept less than\n * or equal to the maximum header size allowed by the zero-cache and any load\n * balancers.\n *\n * Default value: 8kb.\n */\n maxHeaderLength?: number | undefined;\n\n /**\n * The maximum amount of milliseconds to wait for a materialization to\n * complete (including network/server time) before printing a warning to the\n * console.\n *\n * Default value: 5_000.\n */\n slowMaterializeThreshold?: number | undefined;\n\n /**\n * UI rendering libraries will often provide a utility for batching multiple\n * state updates into a single render. Some examples are React's\n * `unstable_batchedUpdates`, and solid-js's `batch`.\n *\n * This option enables integrating these batch utilities with Zero.\n *\n * When `batchViewUpdates` is provided, Zero will call it whenever\n * it updates query view state with an `applyViewUpdates` function\n * that performs the actual state updates.\n *\n * Zero updates query view state when:\n * 1. creating a new view\n * 2. updating all existing queries' views to a new consistent state\n *\n * When creating a new view, that single view's creation will be wrapped\n * in a `batchViewUpdates` call.\n *\n * When updating existing queries, all queries will be updated in a single\n * `batchViewUpdates` call, so that the transition to the new consistent\n * state can be done in a single render.\n *\n * Implementations must always call `applyViewUpdates` synchronously.\n */\n batchViewUpdates?: ((applyViewUpdates: () => void) => void) | undefined;\n\n /**\n * The maximum number of recent queries, no longer subscribed to by a preload\n * or view, to continue syncing.\n *\n * Defaults is 0.\n *\n * @deprecated Use ttl instead\n */\n maxRecentQueries?: number | undefined;\n\n /**\n * Changes to queries are sent to server in batches. This option controls\n * the number of milliseconds to wait before sending the next batch.\n *\n * Defaults is 10.\n */\n queryChangeThrottleMs?: number | undefined;\n\n /**\n * Context is passed to Synced Queries when they are executed\n */\n // TODO(arv): Mutators should also get context.\n context?: C | undefined;\n}\n\n/**\n * @deprecated Use {@link ZeroOptions} instead.\n */\nexport interface ZeroAdvancedOptions<\n S extends Schema,\n MD extends CustomMutatorDefs | undefined,\n Context,\n> extends ZeroOptions<S, MD, Context> {}\n\ntype UpdateNeededReasonBase = {\n message?: string;\n};\n\nexport type UpdateNeededReason =\n | ({type: UpdateNeededReasonType.NewClientGroup} & UpdateNeededReasonBase)\n | ({\n type: UpdateNeededReasonType.VersionNotSupported;\n } & UpdateNeededReasonBase)\n | ({\n type: UpdateNeededReasonType.SchemaVersionNotSupported;\n } & UpdateNeededReasonBase);\n\nexport const updateNeededReasonTypeSchema: v.Type<UpdateNeededReason['type']> =\n v.literalUnion(\n UpdateNeededReasonType.NewClientGroup,\n UpdateNeededReasonType.VersionNotSupported,\n UpdateNeededReasonType.SchemaVersionNotSupported,\n );\n"],"names":["v.literalUnion","UpdateNeededReasonType.NewClientGroup","UpdateNeededReasonType.VersionNotSupported","UpdateNeededReasonType.SchemaVersionNotSupported"],"mappings":";;AA6UO,MAAM,+BACXA;AAAAA,EACEC;AAAAA,EACAC;AAAAA,EACAC;AACF;"}
@@ -1,4 +1,4 @@
1
- const version = "0.25.0-canary.18";
1
+ const version = "0.25.0-canary.21";
2
2
  export {
3
3
  version
4
4
  };
@@ -311,4 +311,5 @@ export declare function createSocket(rep: ReplicacheImpl, queryManager: QueryMan
311
311
  Map<string, UpQueriesPatchOp> | undefined,
312
312
  DeleteClientsBody | undefined
313
313
  ]>;
314
+ export declare function createConnectionURL(socketOrigin: HTTPString | WSString, clientID: string, clientGroupID: string, userID: string, baseCookie: string | null, lmid: number, wsid: string, rep: Pick<ReplicacheImpl<{}>, 'profileID'>, debugPerf: boolean, additionalConnectParams: Record<string, string> | undefined, lc: LogContext<unknown[], unknown[], unknown[], unknown[]>): Promise<URL>;
314
315
  //# sourceMappingURL=zero.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zero.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/zero.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAgB,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,KAAK,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,cAAc,EAEf,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAC,MAAM,EAAe,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAC,MAAM,EAAe,MAAM,mCAAmC,CAAC;AAE5E,OAAO,KAAK,EACV,aAAa,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