@rocicorp/zero 1.2.0-canary.12 → 1.2.0-canary.14

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 (122) hide show
  1. package/out/shared/src/sorted-entries.d.ts +2 -0
  2. package/out/shared/src/sorted-entries.d.ts.map +1 -0
  3. package/out/shared/src/sorted-entries.js +9 -0
  4. package/out/shared/src/sorted-entries.js.map +1 -0
  5. package/out/zero/package.js +1 -1
  6. package/out/zero/package.js.map +1 -1
  7. package/out/zero-cache/src/auth/auth.d.ts +8 -26
  8. package/out/zero-cache/src/auth/auth.d.ts.map +1 -1
  9. package/out/zero-cache/src/auth/auth.js +57 -82
  10. package/out/zero-cache/src/auth/auth.js.map +1 -1
  11. package/out/zero-cache/src/auth/jwt.d.ts +3 -3
  12. package/out/zero-cache/src/auth/jwt.d.ts.map +1 -1
  13. package/out/zero-cache/src/auth/jwt.js.map +1 -1
  14. package/out/zero-cache/src/config/zero-config.d.ts +22 -2
  15. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  16. package/out/zero-cache/src/config/zero-config.js +21 -0
  17. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  18. package/out/zero-cache/src/custom/fetch.d.ts +2 -9
  19. package/out/zero-cache/src/custom/fetch.d.ts.map +1 -1
  20. package/out/zero-cache/src/custom/fetch.js +9 -4
  21. package/out/zero-cache/src/custom/fetch.js.map +1 -1
  22. package/out/zero-cache/src/custom-queries/transform-query.d.ts +20 -9
  23. package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +1 -1
  24. package/out/zero-cache/src/custom-queries/transform-query.js +71 -37
  25. package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
  26. package/out/zero-cache/src/db/transaction-pool.d.ts.map +1 -1
  27. package/out/zero-cache/src/db/transaction-pool.js +3 -0
  28. package/out/zero-cache/src/db/transaction-pool.js.map +1 -1
  29. package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
  30. package/out/zero-cache/src/server/change-streamer.js +4 -1
  31. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  32. package/out/zero-cache/src/server/inspector-delegate.d.ts +2 -2
  33. package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
  34. package/out/zero-cache/src/server/inspector-delegate.js +4 -4
  35. package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
  36. package/out/zero-cache/src/server/reaper.d.ts.map +1 -1
  37. package/out/zero-cache/src/server/reaper.js +4 -1
  38. package/out/zero-cache/src/server/reaper.js.map +1 -1
  39. package/out/zero-cache/src/server/runner/run-worker.js +1 -1
  40. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  41. package/out/zero-cache/src/server/syncer.js +34 -11
  42. package/out/zero-cache/src/server/syncer.js.map +1 -1
  43. package/out/zero-cache/src/services/change-source/custom/change-source.js +2 -2
  44. package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
  45. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
  46. package/out/zero-cache/src/services/change-source/pg/change-source.js +4 -3
  47. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  48. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +2 -1
  49. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
  50. package/out/zero-cache/src/services/change-source/pg/initial-sync.js +7 -5
  51. package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
  52. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +3 -3
  53. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  54. package/out/zero-cache/src/services/mutagen/pusher.d.ts +20 -20
  55. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
  56. package/out/zero-cache/src/services/mutagen/pusher.js +91 -104
  57. package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
  58. package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts +168 -0
  59. package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts.map +1 -0
  60. package/out/zero-cache/src/services/view-syncer/connection-context-manager.js +385 -0
  61. package/out/zero-cache/src/services/view-syncer/connection-context-manager.js.map +1 -0
  62. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +2 -3
  63. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +1 -1
  64. package/out/zero-cache/src/services/view-syncer/inspect-handler.js +3 -3
  65. package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
  66. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +20 -26
  67. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  68. package/out/zero-cache/src/services/view-syncer/view-syncer.js +203 -114
  69. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  70. package/out/zero-cache/src/types/pg-versions.d.ts +3 -0
  71. package/out/zero-cache/src/types/pg-versions.d.ts.map +1 -0
  72. package/out/zero-cache/src/types/pg-versions.js +7 -0
  73. package/out/zero-cache/src/types/pg-versions.js.map +1 -0
  74. package/out/zero-cache/src/workers/connect-params.d.ts +1 -1
  75. package/out/zero-cache/src/workers/connect-params.d.ts.map +1 -1
  76. package/out/zero-cache/src/workers/connect-params.js +1 -1
  77. package/out/zero-cache/src/workers/connect-params.js.map +1 -1
  78. package/out/zero-cache/src/workers/connection.js +4 -4
  79. package/out/zero-cache/src/workers/connection.js.map +1 -1
  80. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts +2 -1
  81. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
  82. package/out/zero-cache/src/workers/syncer-ws-message-handler.js +46 -36
  83. package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
  84. package/out/zero-cache/src/workers/syncer.d.ts +2 -1
  85. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  86. package/out/zero-cache/src/workers/syncer.js +53 -26
  87. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  88. package/out/zero-client/src/client/connection.d.ts +4 -4
  89. package/out/zero-client/src/client/connection.d.ts.map +1 -1
  90. package/out/zero-client/src/client/connection.js.map +1 -1
  91. package/out/zero-client/src/client/options.d.ts +34 -5
  92. package/out/zero-client/src/client/options.d.ts.map +1 -1
  93. package/out/zero-client/src/client/options.js.map +1 -1
  94. package/out/zero-client/src/client/version.js +1 -1
  95. package/out/zero-client/src/client/zero.d.ts +4 -3
  96. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  97. package/out/zero-client/src/client/zero.js +33 -11
  98. package/out/zero-client/src/client/zero.js.map +1 -1
  99. package/out/zero-protocol/src/change-desired-queries.d.ts +4 -0
  100. package/out/zero-protocol/src/change-desired-queries.d.ts.map +1 -1
  101. package/out/zero-protocol/src/change-desired-queries.js +4 -1
  102. package/out/zero-protocol/src/change-desired-queries.js.map +1 -1
  103. package/out/zero-protocol/src/connect.d.ts +4 -0
  104. package/out/zero-protocol/src/connect.d.ts.map +1 -1
  105. package/out/zero-protocol/src/connect.js +2 -1
  106. package/out/zero-protocol/src/connect.js.map +1 -1
  107. package/out/zero-protocol/src/protocol-version.d.ts +1 -1
  108. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  109. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  110. package/out/zero-protocol/src/push.d.ts +4 -0
  111. package/out/zero-protocol/src/push.d.ts.map +1 -1
  112. package/out/zero-protocol/src/push.js +2 -1
  113. package/out/zero-protocol/src/push.js.map +1 -1
  114. package/out/zero-protocol/src/up.d.ts +3 -0
  115. package/out/zero-protocol/src/up.d.ts.map +1 -1
  116. package/out/zero-react/src/zero-provider.d.ts.map +1 -1
  117. package/out/zero-react/src/zero-provider.js +11 -5
  118. package/out/zero-react/src/zero-provider.js.map +1 -1
  119. package/out/zero-solid/src/use-zero.d.ts.map +1 -1
  120. package/out/zero-solid/src/use-zero.js +8 -9
  121. package/out/zero-solid/src/use-zero.js.map +1 -1
  122. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"change-desired-queries.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/change-desired-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAGhD,QAAA,MAAM,8BAA8B;;;;;;;;;;;;;;;aAElC,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;eAG5C,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC"}
1
+ {"version":3,"file":"change-desired-queries.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/change-desired-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAGhD,QAAA,MAAM,8BAA8B;;;;;;;;;;;;;;;IAElC,sDAAsD;;aAEtD,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;IAJ5C,sDAAsD;;eAOtD,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC"}
@@ -1,7 +1,10 @@
1
1
  import { valita_exports } from "../../shared/src/valita.js";
2
2
  import { upQueriesPatchSchema } from "./queries-patch.js";
3
3
  //#region ../zero-protocol/src/change-desired-queries.ts
4
- var changeDesiredQueriesBodySchema = valita_exports.object({ desiredQueriesPatch: upQueriesPatchSchema });
4
+ var changeDesiredQueriesBodySchema = valita_exports.object({
5
+ desiredQueriesPatch: upQueriesPatchSchema,
6
+ traceparent: valita_exports.string().optional()
7
+ });
5
8
  var changeDesiredQueriesMessageSchema = valita_exports.tuple([valita_exports.literal("changeDesiredQueries"), changeDesiredQueriesBodySchema]);
6
9
  //#endregion
7
10
  export { changeDesiredQueriesMessageSchema };
@@ -1 +1 @@
1
- {"version":3,"file":"change-desired-queries.js","names":[],"sources":["../../../../zero-protocol/src/change-desired-queries.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\nconst changeDesiredQueriesBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n});\n\nexport const changeDesiredQueriesMessageSchema = v.tuple([\n v.literal('changeDesiredQueries'),\n changeDesiredQueriesBodySchema,\n]);\n\nexport type ChangeDesiredQueriesBody = v.Infer<\n typeof changeDesiredQueriesBodySchema\n>;\nexport type ChangeDesiredQueriesMessage = v.Infer<\n typeof changeDesiredQueriesMessageSchema\n>;\n"],"mappings":";;;AAGA,IAAM,iCAAiC,eAAE,OAAO,EAC9C,qBAAqB,sBACtB,CAAC;AAEF,IAAa,oCAAoC,eAAE,MAAM,CACvD,eAAE,QAAQ,uBAAuB,EACjC,+BACD,CAAC"}
1
+ {"version":3,"file":"change-desired-queries.js","names":[],"sources":["../../../../zero-protocol/src/change-desired-queries.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\nconst changeDesiredQueriesBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n /** W3C traceparent header for distributed tracing. */\n traceparent: v.string().optional(),\n});\n\nexport const changeDesiredQueriesMessageSchema = v.tuple([\n v.literal('changeDesiredQueries'),\n changeDesiredQueriesBodySchema,\n]);\n\nexport type ChangeDesiredQueriesBody = v.Infer<\n typeof changeDesiredQueriesBodySchema\n>;\nexport type ChangeDesiredQueriesMessage = v.Infer<\n typeof changeDesiredQueriesMessageSchema\n>;\n"],"mappings":";;;AAGA,IAAM,iCAAiC,eAAE,OAAO;CAC9C,qBAAqB;CAErB,aAAa,eAAE,QAAQ,CAAC,UAAU;CACnC,CAAC;AAEF,IAAa,oCAAoC,eAAE,MAAM,CACvD,eAAE,QAAQ,uBAAuB,EACjC,+BACD,CAAC"}
@@ -52,6 +52,8 @@ declare const initConnectionBodySchema: v.ObjectType<{
52
52
  * queries from inactive clients.
53
53
  */
54
54
  activeClients: v.Optional<string[]>;
55
+ /** W3C traceparent header for distributed tracing. */
56
+ traceparent: v.Optional<string>;
55
57
  }, undefined>;
56
58
  export declare const initConnectionMessageSchema: v.TupleType<[v.Type<"initConnection">, v.ObjectType<{
57
59
  desiredQueriesPatch: v.ArrayType<v.UnionType<[v.ObjectType<Omit<{
@@ -91,6 +93,8 @@ export declare const initConnectionMessageSchema: v.TupleType<[v.Type<"initConne
91
93
  * queries from inactive clients.
92
94
  */
93
95
  activeClients: v.Optional<string[]>;
96
+ /** W3C traceparent header for distributed tracing. */
97
+ traceparent: v.Optional<string>;
94
98
  }, undefined>]>;
95
99
  export type ConnectedBody = v.Infer<typeof connectedBodySchema>;
96
100
  export type ConnectedMessage = v.Infer<typeof connectedMessageSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAKhD;;;;;;GAMG;AAEH,eAAO,MAAM,mBAAmB;;;aAG9B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;eAGjC,CAAC;AAEH,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAe5B;;;;;OAKG;;aAEH,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IATtC;;;;;OAKG;;eAOH,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,kBAAkB,GA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B,EAAE,qBAAqB,GAAG,SAAS,EACxD,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,MAAM,CAgBR;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG;IACvD,qBAAqB,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACzD,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAIA"}
@@ -23,7 +23,8 @@ var initConnectionBodySchema = valita_exports.object({
23
23
  userPushHeaders: valita_exports.record(valita_exports.string()).optional(),
24
24
  userQueryURL: valita_exports.string().optional(),
25
25
  userQueryHeaders: valita_exports.record(valita_exports.string()).optional(),
26
- activeClients: valita_exports.array(valita_exports.string()).optional()
26
+ activeClients: valita_exports.array(valita_exports.string()).optional(),
27
+ traceparent: valita_exports.string().optional()
27
28
  });
28
29
  var initConnectionMessageSchema = valita_exports.tuple([valita_exports.literal("initConnection"), initConnectionBodySchema]);
29
30
  function encodeSecProtocols(initConnectionMessage, authToken) {
@@ -1 +1 @@
1
- {"version":3,"file":"connect.js","names":[],"sources":["../../../../zero-protocol/src/connect.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {clientSchemaSchema} from './client-schema.ts';\nimport {deleteClientsBodySchema} from './delete-clients.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\n/**\n * After opening a websocket the client waits for a `connected` message\n * from the server. It then sends an `initConnection` message to the\n * server. The server waits for the `initConnection` message before\n * beginning to send pokes to the newly connected client, so as to avoid\n * syncing lots of queries which are no longer desired by the client.\n */\n\nexport const connectedBodySchema = v.object({\n wsid: v.string(),\n timestamp: v.number().optional(),\n});\n\nexport const connectedMessageSchema = v.tuple([\n v.literal('connected'),\n connectedBodySchema,\n]);\n\nconst initConnectionBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n // As the schema can be large, client only sends when it does not have a\n // server snapshot (i.e. a snapshot with a cookie). Once it has a server\n // snapshot it will assume the zero-cache already has the schema for this\n // client's client group in the CVR store.\n clientSchema: clientSchemaSchema.optional(),\n deleted: deleteClientsBodySchema.optional(),\n // parameters to configure the mutate endpoint\n userPushURL: v.string().optional(),\n userPushHeaders: v.record(v.string()).optional(),\n // parameters to configure the query endpoint\n userQueryURL: v.string().optional(),\n userQueryHeaders: v.record(v.string()).optional(),\n\n /**\n * `activeClients` is an optional array of client IDs that are currently active\n * in the client group. This is used to inform the server about the clients\n * that are currently active (aka running, aka alive), so it can inactive\n * queries from inactive clients.\n */\n activeClients: v.array(v.string()).optional(),\n});\n\nexport const initConnectionMessageSchema = v.tuple([\n v.literal('initConnection'),\n initConnectionBodySchema,\n]);\n\nexport type ConnectedBody = v.Infer<typeof connectedBodySchema>;\nexport type ConnectedMessage = v.Infer<typeof connectedMessageSchema>;\nexport type InitConnectionBody = v.Infer<typeof initConnectionBodySchema>;\nexport type InitConnectionMessage = v.Infer<typeof initConnectionMessageSchema>;\n\nexport function encodeSecProtocols(\n initConnectionMessage: InitConnectionMessage | undefined,\n authToken: string | undefined,\n): string {\n const protocols = {\n initConnectionMessage,\n authToken,\n };\n // WS sec protocols needs to be URI encoded. To save space, we base64 encode\n // the JSON before URI encoding it. But InitConnectionMessage can contain\n // arbitrary unicode strings, so we need to encode the JSON as UTF-8 first.\n // Phew!\n const bytes = new TextEncoder().encode(JSON.stringify(protocols));\n\n // Convert bytes to string without spreading all bytes as arguments\n // to avoid \"Maximum call stack size exceeded\" error with large data\n const s = Array.from(bytes, byte => String.fromCharCode(byte)).join('');\n\n return encodeURIComponent(btoa(s));\n}\n\nexport function decodeSecProtocols(secProtocol: string): {\n initConnectionMessage: InitConnectionMessage | undefined;\n authToken: string | undefined;\n} {\n const binString = atob(decodeURIComponent(secProtocol));\n const bytes = Uint8Array.from(binString, c => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n}\n"],"mappings":";;;;;;;;;;;;AAaA,IAAa,sBAAsB,eAAE,OAAO;CAC1C,MAAM,eAAE,QAAQ;CAChB,WAAW,eAAE,QAAQ,CAAC,UAAU;CACjC,CAAC;AAEF,IAAa,yBAAyB,eAAE,MAAM,CAC5C,eAAE,QAAQ,YAAY,EACtB,oBACD,CAAC;AAEF,IAAM,2BAA2B,eAAE,OAAO;CACxC,qBAAqB;CAKrB,cAAc,mBAAmB,UAAU;CAC3C,SAAS,wBAAwB,UAAU;CAE3C,aAAa,eAAE,QAAQ,CAAC,UAAU;CAClC,iBAAiB,eAAE,OAAO,eAAE,QAAQ,CAAC,CAAC,UAAU;CAEhD,cAAc,eAAE,QAAQ,CAAC,UAAU;CACnC,kBAAkB,eAAE,OAAO,eAAE,QAAQ,CAAC,CAAC,UAAU;CAQjD,eAAe,eAAE,MAAM,eAAE,QAAQ,CAAC,CAAC,UAAU;CAC9C,CAAC;AAEF,IAAa,8BAA8B,eAAE,MAAM,CACjD,eAAE,QAAQ,iBAAiB,EAC3B,yBACD,CAAC;AAOF,SAAgB,mBACd,uBACA,WACQ;CACR,MAAM,YAAY;EAChB;EACA;EACD;CAKD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK,UAAU,UAAU,CAAC;CAIjE,MAAM,IAAI,MAAM,KAAK,QAAO,SAAQ,OAAO,aAAa,KAAK,CAAC,CAAC,KAAK,GAAG;AAEvE,QAAO,mBAAmB,KAAK,EAAE,CAAC;;AAGpC,SAAgB,mBAAmB,aAGjC;CACA,MAAM,YAAY,KAAK,mBAAmB,YAAY,CAAC;CACvD,MAAM,QAAQ,WAAW,KAAK,YAAW,MAAK,EAAE,WAAW,EAAE,CAAC;AAC9D,QAAO,KAAK,MAAM,IAAI,aAAa,CAAC,OAAO,MAAM,CAAC"}
1
+ {"version":3,"file":"connect.js","names":[],"sources":["../../../../zero-protocol/src/connect.ts"],"sourcesContent":["import * as v from '../../shared/src/valita.ts';\nimport {clientSchemaSchema} from './client-schema.ts';\nimport {deleteClientsBodySchema} from './delete-clients.ts';\nimport {upQueriesPatchSchema} from './queries-patch.ts';\n\n/**\n * After opening a websocket the client waits for a `connected` message\n * from the server. It then sends an `initConnection` message to the\n * server. The server waits for the `initConnection` message before\n * beginning to send pokes to the newly connected client, so as to avoid\n * syncing lots of queries which are no longer desired by the client.\n */\n\nexport const connectedBodySchema = v.object({\n wsid: v.string(),\n timestamp: v.number().optional(),\n});\n\nexport const connectedMessageSchema = v.tuple([\n v.literal('connected'),\n connectedBodySchema,\n]);\n\nconst initConnectionBodySchema = v.object({\n desiredQueriesPatch: upQueriesPatchSchema,\n // As the schema can be large, client only sends when it does not have a\n // server snapshot (i.e. a snapshot with a cookie). Once it has a server\n // snapshot it will assume the zero-cache already has the schema for this\n // client's client group in the CVR store.\n clientSchema: clientSchemaSchema.optional(),\n deleted: deleteClientsBodySchema.optional(),\n // parameters to configure the mutate endpoint\n userPushURL: v.string().optional(),\n userPushHeaders: v.record(v.string()).optional(),\n // parameters to configure the query endpoint\n userQueryURL: v.string().optional(),\n userQueryHeaders: v.record(v.string()).optional(),\n\n /**\n * `activeClients` is an optional array of client IDs that are currently active\n * in the client group. This is used to inform the server about the clients\n * that are currently active (aka running, aka alive), so it can inactive\n * queries from inactive clients.\n */\n activeClients: v.array(v.string()).optional(),\n /** W3C traceparent header for distributed tracing. */\n traceparent: v.string().optional(),\n});\n\nexport const initConnectionMessageSchema = v.tuple([\n v.literal('initConnection'),\n initConnectionBodySchema,\n]);\n\nexport type ConnectedBody = v.Infer<typeof connectedBodySchema>;\nexport type ConnectedMessage = v.Infer<typeof connectedMessageSchema>;\nexport type InitConnectionBody = v.Infer<typeof initConnectionBodySchema>;\nexport type InitConnectionMessage = v.Infer<typeof initConnectionMessageSchema>;\n\nexport function encodeSecProtocols(\n initConnectionMessage: InitConnectionMessage | undefined,\n authToken: string | undefined,\n): string {\n const protocols = {\n initConnectionMessage,\n authToken,\n };\n // WS sec protocols needs to be URI encoded. To save space, we base64 encode\n // the JSON before URI encoding it. But InitConnectionMessage can contain\n // arbitrary unicode strings, so we need to encode the JSON as UTF-8 first.\n // Phew!\n const bytes = new TextEncoder().encode(JSON.stringify(protocols));\n\n // Convert bytes to string without spreading all bytes as arguments\n // to avoid \"Maximum call stack size exceeded\" error with large data\n const s = Array.from(bytes, byte => String.fromCharCode(byte)).join('');\n\n return encodeURIComponent(btoa(s));\n}\n\nexport function decodeSecProtocols(secProtocol: string): {\n initConnectionMessage: InitConnectionMessage | undefined;\n authToken: string | undefined;\n} {\n const binString = atob(decodeURIComponent(secProtocol));\n const bytes = Uint8Array.from(binString, c => c.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n}\n"],"mappings":";;;;;;;;;;;;AAaA,IAAa,sBAAsB,eAAE,OAAO;CAC1C,MAAM,eAAE,QAAQ;CAChB,WAAW,eAAE,QAAQ,CAAC,UAAU;CACjC,CAAC;AAEF,IAAa,yBAAyB,eAAE,MAAM,CAC5C,eAAE,QAAQ,YAAY,EACtB,oBACD,CAAC;AAEF,IAAM,2BAA2B,eAAE,OAAO;CACxC,qBAAqB;CAKrB,cAAc,mBAAmB,UAAU;CAC3C,SAAS,wBAAwB,UAAU;CAE3C,aAAa,eAAE,QAAQ,CAAC,UAAU;CAClC,iBAAiB,eAAE,OAAO,eAAE,QAAQ,CAAC,CAAC,UAAU;CAEhD,cAAc,eAAE,QAAQ,CAAC,UAAU;CACnC,kBAAkB,eAAE,OAAO,eAAE,QAAQ,CAAC,CAAC,UAAU;CAQjD,eAAe,eAAE,MAAM,eAAE,QAAQ,CAAC,CAAC,UAAU;CAE7C,aAAa,eAAE,QAAQ,CAAC,UAAU;CACnC,CAAC;AAEF,IAAa,8BAA8B,eAAE,MAAM,CACjD,eAAE,QAAQ,iBAAiB,EAC3B,yBACD,CAAC;AAOF,SAAgB,mBACd,uBACA,WACQ;CACR,MAAM,YAAY;EAChB;EACA;EACD;CAKD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK,UAAU,UAAU,CAAC;CAIjE,MAAM,IAAI,MAAM,KAAK,QAAO,SAAQ,OAAO,aAAa,KAAK,CAAC,CAAC,KAAK,GAAG;AAEvE,QAAO,mBAAmB,KAAK,EAAE,CAAC;;AAGpC,SAAgB,mBAAmB,aAGjC;CACA,MAAM,YAAY,KAAK,mBAAmB,YAAY,CAAC;CACvD,MAAM,QAAQ,WAAW,KAAK,YAAW,MAAK,EAAE,WAAW,EAAE,CAAC;AAC9D,QAAO,KAAK,MAAM,IAAI,aAAa,CAAC,OAAO,MAAM,CAAC"}
@@ -10,7 +10,7 @@
10
10
  * release. The server (`zero-cache`) must be deployed before clients start
11
11
  * running the new code.
12
12
  */
13
- export declare const PROTOCOL_VERSION = 49;
13
+ export declare const PROTOCOL_VERSION = 50;
14
14
  /**
15
15
  * The minimum server-supported sync protocol version (i.e. the version
16
16
  * declared in the "/sync/v{#}/connect" URL). The contract for
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-version.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/protocol-version.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AA4CH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,kCAAkC,KAAK,CAAC"}
1
+ {"version":3,"file":"protocol-version.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/protocol-version.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AA6CH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,eAAO,MAAM,kCAAkC,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"protocol-version.js","names":[],"sources":["../../../../zero-protocol/src/protocol-version.ts"],"sourcesContent":["import {assert} from '../../shared/src/asserts.ts';\n\n/**\n * The current `PROTOCOL_VERSION` of the code.\n *\n * The `PROTOCOL_VERSION` encompasses both the wire-protocol of the `/sync/...`\n * connection between the browser and `zero-cache`, as well as the format of\n * the `AST` objects stored in both components (i.e. IDB and CVR).\n *\n * A change in the `AST` schema (e.g. new functionality added) must be\n * accompanied by an increment of the `PROTOCOL_VERSION` and a new major\n * release. The server (`zero-cache`) must be deployed before clients start\n * running the new code.\n */\n// History:\n// -- Version 5 adds support for `pokeEnd.cookie`. (0.14)\n// -- Version 6 makes `pokeStart.cookie` optional. (0.16)\n// -- Version 7 introduces the initConnection.clientSchema field. (0.17)\n// -- Version 8 drops support for Version 5 (0.18).\n// -- Version 11 adds inspect queries. (0.18)\n// -- Version 12 adds 'timestamp' and 'date' types to the ClientSchema ValueType. (not shipped, reversed by version 14)\n// -- Version 14 removes 'timestamp' and 'date' types from the ClientSchema ValueType. (0.18)\n// -- Version 15 adds a `userPushParams` field to `initConnection` (0.19)\n// -- Version 16 adds a new error type (alreadyProcessed) to mutation responses (0.19)\n// -- Version 17 deprecates `AST` in downstream query puts. It was never used anyway. (0.21)\n// -- Version 18 adds `name` and `args` to the `queries-patch` protocol (0.21)\n// -- Version 19 adds `activeClients` to the `initConnection` protocol (0.22)\n// -- Version 20 changes inspector down message (0.22)\n// -- Version 21 removes `AST` in downstream query puts which was deprecated in Version 17, removes support for versions < 18 (0.22)\n// -- Version 22 adds an optional 'userQueryParams' field to `initConnection` (0.22)\n// -- Version 23 add `mutationResults` to poke (0.22)\n// -- Version 24 adds `ackMutationResults` to upstream (0.22).\n// -- version 25 modifies `mutationsResults` to include `del` patches (0.22)\n// -- version 26 adds inspect/metrics and adds metrics to inspect/query (0.23)\n// -- version 27 adds inspect/version (0.23)\n// -- version 28 adds more inspect/metrics (0.23)\n// -- version 29 adds error responses for custom queries (0.23)\n// -- version 30 adds an optional primaryKey to the ClientSchema (0.24)\n// -- version 31 adds admin password authentication to inspector RPC calls (0.24)\n// -- version 32 adds analyze-query to the inspector RPC calls (0.24)\n// -- version 33 adds `flip` to CorrelatedSubquery (0.25)\n// -- version 34 moves `flip` from CorrelatedSubquery to CorrelatedSubqueryCondition (0.25)\n// -- version 35 adds `readRows`, `readRowCountsByQuery` and `readRowCount` to analyze-query result (0.25)\n// -- version 36 changes inspector analyze-query and adds error response to RPC (0.25)\n// -- version 37 adds `elapsed` to AnalyzeQueryResult (0.25)\n// -- version 38 adds structured push/transform error responses (0.25)\n// -- version 39 removes per-transform error types and adds `message` to app error (0.25)\n// -- version 40 adds `dbRowScansByQuery` to AnalyzeQueryResult (0.25)\n// -- version 41 makes ClientSchema.primaryKey required (0.25)\n// -- version 42 adds planner events to AnalyzeQueryResult (0.25)\n// -- version 43 renames `plans` to `sqlitePlans`, `plannerEvents` to `joinPlans`, and `plannerDebug` option to `joinPlans` (0.25)\n// -- version 44 adds profileID to connection URL (0.25)\n// -- version 45 adds userPushHeaders and userQueryHeaders to initConnection (0.25)\n// -- version 46 adds scalarSubquery condition type to AST\n// -- version 47 adds optional auth token to push body\n// -- version 48 adds updateAuth\n// -- version 49 adds `scalar` to CorrelatedSubqueryCondition, removes scalarSubquery\nexport const PROTOCOL_VERSION = 49;\n\n/**\n * The minimum server-supported sync protocol version (i.e. the version\n * declared in the \"/sync/v{#}/connect\" URL). The contract for\n * backwards compatibility is that a `zero-cache` supports the current\n * `PROTOCOL_VERSION` and at least the previous one (i.e. `PROTOCOL_VERSION - 1`)\n * if not earlier ones as well. This corresponds to supporting clients running\n * the current release and the previous (major) release. Any client connections\n * from protocol versions before `MIN_SERVER_SUPPORTED_PROTOCOL_VERSION` are\n * closed with a `VersionNotSupported` error.\n */\nexport const MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 30;\n\nassert(\n MIN_SERVER_SUPPORTED_SYNC_PROTOCOL < PROTOCOL_VERSION,\n 'MIN_SERVER_SUPPORTED_SYNC_PROTOCOL must be less than PROTOCOL_VERSION',\n);\n"],"mappings":";AAuEA,OAAA,MAEE,wEACD"}
1
+ {"version":3,"file":"protocol-version.js","names":[],"sources":["../../../../zero-protocol/src/protocol-version.ts"],"sourcesContent":["import {assert} from '../../shared/src/asserts.ts';\n\n/**\n * The current `PROTOCOL_VERSION` of the code.\n *\n * The `PROTOCOL_VERSION` encompasses both the wire-protocol of the `/sync/...`\n * connection between the browser and `zero-cache`, as well as the format of\n * the `AST` objects stored in both components (i.e. IDB and CVR).\n *\n * A change in the `AST` schema (e.g. new functionality added) must be\n * accompanied by an increment of the `PROTOCOL_VERSION` and a new major\n * release. The server (`zero-cache`) must be deployed before clients start\n * running the new code.\n */\n// History:\n// -- Version 5 adds support for `pokeEnd.cookie`. (0.14)\n// -- Version 6 makes `pokeStart.cookie` optional. (0.16)\n// -- Version 7 introduces the initConnection.clientSchema field. (0.17)\n// -- Version 8 drops support for Version 5 (0.18).\n// -- Version 11 adds inspect queries. (0.18)\n// -- Version 12 adds 'timestamp' and 'date' types to the ClientSchema ValueType. (not shipped, reversed by version 14)\n// -- Version 14 removes 'timestamp' and 'date' types from the ClientSchema ValueType. (0.18)\n// -- Version 15 adds a `userPushParams` field to `initConnection` (0.19)\n// -- Version 16 adds a new error type (alreadyProcessed) to mutation responses (0.19)\n// -- Version 17 deprecates `AST` in downstream query puts. It was never used anyway. (0.21)\n// -- Version 18 adds `name` and `args` to the `queries-patch` protocol (0.21)\n// -- Version 19 adds `activeClients` to the `initConnection` protocol (0.22)\n// -- Version 20 changes inspector down message (0.22)\n// -- Version 21 removes `AST` in downstream query puts which was deprecated in Version 17, removes support for versions < 18 (0.22)\n// -- Version 22 adds an optional 'userQueryParams' field to `initConnection` (0.22)\n// -- Version 23 add `mutationResults` to poke (0.22)\n// -- Version 24 adds `ackMutationResults` to upstream (0.22).\n// -- version 25 modifies `mutationsResults` to include `del` patches (0.22)\n// -- version 26 adds inspect/metrics and adds metrics to inspect/query (0.23)\n// -- version 27 adds inspect/version (0.23)\n// -- version 28 adds more inspect/metrics (0.23)\n// -- version 29 adds error responses for custom queries (0.23)\n// -- version 30 adds an optional primaryKey to the ClientSchema (0.24)\n// -- version 31 adds admin password authentication to inspector RPC calls (0.24)\n// -- version 32 adds analyze-query to the inspector RPC calls (0.24)\n// -- version 33 adds `flip` to CorrelatedSubquery (0.25)\n// -- version 34 moves `flip` from CorrelatedSubquery to CorrelatedSubqueryCondition (0.25)\n// -- version 35 adds `readRows`, `readRowCountsByQuery` and `readRowCount` to analyze-query result (0.25)\n// -- version 36 changes inspector analyze-query and adds error response to RPC (0.25)\n// -- version 37 adds `elapsed` to AnalyzeQueryResult (0.25)\n// -- version 38 adds structured push/transform error responses (0.25)\n// -- version 39 removes per-transform error types and adds `message` to app error (0.25)\n// -- version 40 adds `dbRowScansByQuery` to AnalyzeQueryResult (0.25)\n// -- version 41 makes ClientSchema.primaryKey required (0.25)\n// -- version 42 adds planner events to AnalyzeQueryResult (0.25)\n// -- version 43 renames `plans` to `sqlitePlans`, `plannerEvents` to `joinPlans`, and `plannerDebug` option to `joinPlans` (0.25)\n// -- version 44 adds profileID to connection URL (0.25)\n// -- version 45 adds userPushHeaders and userQueryHeaders to initConnection (0.25)\n// -- version 46 adds scalarSubquery condition type to AST\n// -- version 47 adds optional auth token to push body\n// -- version 48 adds updateAuth\n// -- version 49 adds `scalar` to CorrelatedSubqueryCondition, removes scalarSubquery\n// -- version 50 adds OTEL headers to push and query messages\nexport const PROTOCOL_VERSION = 50;\n\n/**\n * The minimum server-supported sync protocol version (i.e. the version\n * declared in the \"/sync/v{#}/connect\" URL). The contract for\n * backwards compatibility is that a `zero-cache` supports the current\n * `PROTOCOL_VERSION` and at least the previous one (i.e. `PROTOCOL_VERSION - 1`)\n * if not earlier ones as well. This corresponds to supporting clients running\n * the current release and the previous (major) release. Any client connections\n * from protocol versions before `MIN_SERVER_SUPPORTED_PROTOCOL_VERSION` are\n * closed with a `VersionNotSupported` error.\n */\nexport const MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 30;\n\nassert(\n MIN_SERVER_SUPPORTED_SYNC_PROTOCOL < PROTOCOL_VERSION,\n 'MIN_SERVER_SUPPORTED_SYNC_PROTOCOL must be less than PROTOCOL_VERSION',\n);\n"],"mappings":";AAwEA,OAAA,MAEE,wEACD"}
@@ -220,6 +220,8 @@ export declare const pushBodySchema: v.ObjectType<{
220
220
  * and should not be included in push messages.
221
221
  */
222
222
  auth: v.Optional<string>;
223
+ /** W3C traceparent header for distributed tracing. */
224
+ traceparent: v.Optional<string>;
223
225
  }, undefined>;
224
226
  export declare const pushMessageSchema: v.TupleType<[v.Type<"push">, v.ObjectType<{
225
227
  clientGroupID: v.Type<string>;
@@ -269,6 +271,8 @@ export declare const pushMessageSchema: v.TupleType<[v.Type<"push">, v.ObjectTyp
269
271
  * and should not be included in push messages.
270
272
  */
271
273
  auth: v.Optional<string>;
274
+ /** W3C traceparent header for distributed tracing. */
275
+ traceparent: v.Optional<string>;
272
276
  }, undefined>]>;
273
277
  declare const mutationOkSchema: v.ObjectType<{
274
278
  data: v.Optional<import("../../shared/src/json.ts").ReadonlyJSONValue>;
@@ -1 +1 @@
1
- {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/push.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAChD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,qCAAqC,CAAC;AAUpE,eAAO,MAAM,kBAAkB,eAAe,CAAC;AAK/C,eAAO,MAAM,6BAA6B,yBAAyB,CAAC;AAEpE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;eAqBnC,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,cAAc;;;;;aAKlB,CAAC;AAEH;;;GAGG;AACH,QAAA,MAAM,cAAc;;;;;aAKlB,CAAC;AAEH;;GAEG;AACH,QAAA,MAAM,cAAc;;;;;aAMlB,CAAC;AAEH;;GAEG;AACH,QAAA,MAAM,cAAc;;;;;aAMlB,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;eAKjB,CAAC;AAEF,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;aAEjB,CAAC;AAIH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAO7B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;aAO/B,CAAC;AAEH,eAAO,MA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gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAClD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CACtC,OAAO,iCAAiC,CACzC,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,YAAY,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,wBAAgB,OAAO,CACrB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,UAAU,GACd,eAAe,CAcjB"}
@@ -86,7 +86,8 @@ var pushBodySchema = valita_exports.object({
86
86
  schemaVersion: valita_exports.number().optional(),
87
87
  timestamp: valita_exports.number(),
88
88
  requestID: valita_exports.string(),
89
- auth: valita_exports.string().optional()
89
+ auth: valita_exports.string().optional(),
90
+ traceparent: valita_exports.string().optional()
90
91
  });
91
92
  var pushMessageSchema = valita_exports.tuple([valita_exports.literal("push"), pushBodySchema]);
92
93
  var appErrorSchema = valita_exports.object({
@@ -1 +1 @@
1
- {"version":3,"file":"push.js","names":[],"sources":["../../../../zero-protocol/src/push.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport type {NameMapper} from '../../zero-types/src/name-mapper.ts';\nimport {rowSchema} from './data.ts';\nimport {pushFailedBodySchema} from './error.ts';\nimport {mutationIDSchema} from './mutation-id.ts';\nimport * as MutationType from './mutation-type-enum.ts';\nimport {primaryKeySchema, primaryKeyValueRecordSchema} from './primary-key.ts';\n\n// NOTE! If you change this name you must also change the\n// string in `replicache-impl.ts` But CRUD mutators are being\n// deleted soon so this should not happen.\nexport const CRUD_MUTATION_NAME = '_zero_crud';\n\n// Internal mutation name for cleaning up mutation results.\n// This mutation is sent from zero-cache to zero-server to delete\n// acknowledged mutation results from the upstream database.\nexport const CLEANUP_RESULTS_MUTATION_NAME = '_zero_cleanupResults';\n\nexport const cleanupResultsArgSchema = v.union(\n // Legacy format (no type field) - treat as single\n v.object({\n clientGroupID: v.string(),\n clientID: v.string(),\n upToMutationID: v.number(),\n }),\n // Explicit single: delete up to a specific mutation ID for one client\n v.object({\n type: v.literal('single'),\n clientGroupID: v.string(),\n clientID: v.string(),\n upToMutationID: v.number(),\n }),\n // Bulk: delete all mutations for multiple clients\n v.object({\n type: v.literal('bulk'),\n clientGroupID: v.string(),\n // oxlint-disable-next-line e18e/prefer-spread-syntax\n clientIDs: v.tuple([v.string()]).concat(v.array(v.string())),\n }),\n);\n\n/**\n * Inserts if entity with id does not already exist.\n */\nconst insertOpSchema = v.object({\n op: v.literal('insert'),\n tableName: v.string(),\n primaryKey: primaryKeySchema,\n value: rowSchema,\n});\n\n/**\n * Upsert semantics. Inserts if entity with id does not already exist,\n * otherwise updates existing entity with id.\n */\nconst upsertOpSchema = v.object({\n op: v.literal('upsert'),\n tableName: v.string(),\n primaryKey: primaryKeySchema,\n value: rowSchema,\n});\n\n/**\n * Updates if entity with id exists, otherwise does nothing.\n */\nconst updateOpSchema = v.object({\n op: v.literal('update'),\n tableName: v.string(),\n primaryKey: primaryKeySchema,\n // Partial value with at least the primary key fields\n value: rowSchema,\n});\n\n/**\n * Deletes entity with id if it exists, otherwise does nothing.\n */\nconst deleteOpSchema = v.object({\n op: v.literal('delete'),\n tableName: v.string(),\n primaryKey: primaryKeySchema,\n // Partial value representing the primary key\n value: primaryKeyValueRecordSchema,\n});\n\nconst crudOpSchema = v.union(\n insertOpSchema,\n upsertOpSchema,\n updateOpSchema,\n deleteOpSchema,\n);\n\nconst crudArgSchema = v.object({\n ops: v.array(crudOpSchema),\n});\n\nconst crudArgsSchema = v.tuple([crudArgSchema]);\n\nexport const crudMutationSchema = v.object({\n type: v.literal(MutationType.CRUD),\n id: v.number(),\n clientID: v.string(),\n name: v.literal(CRUD_MUTATION_NAME),\n args: crudArgsSchema,\n timestamp: v.number(),\n});\n\nexport const customMutationSchema = v.object({\n type: v.literal(MutationType.Custom),\n id: v.number(),\n clientID: v.string(),\n name: v.string(),\n args: v.array(jsonSchema),\n timestamp: v.number(),\n});\n\nexport const mutationSchema = v.union(crudMutationSchema, customMutationSchema);\n\nexport const pushBodySchema = v.object({\n clientGroupID: v.string(),\n mutations: v.array(mutationSchema),\n pushVersion: v.number(),\n // For legacy (CRUD) mutations, the schema is tied to the client group /\n // sync connection. For custom mutations, schema versioning is delegated\n // to the custom protocol / api-server.\n schemaVersion: v.number().optional(),\n timestamp: v.number(),\n requestID: v.string(),\n /**\n * @deprecated auth is managed at client-group scope via connect/updateAuth\n * and should not be included in push messages.\n */\n auth: v.string().optional(),\n});\n\nexport const pushMessageSchema = v.tuple([v.literal('push'), pushBodySchema]);\n\nconst appErrorSchema = v.object({\n error: v.literal('app'),\n // The user can return any additional data here\n message: v.string().optional(),\n details: jsonSchema.optional(),\n});\nconst zeroErrorSchema = v.object({\n error: v.union(\n /** @deprecated push oooMutation errors are now represented as ['error', { ... }] messages */\n v.literal('oooMutation'),\n v.literal('alreadyProcessed'),\n ),\n details: jsonSchema.optional(),\n});\n\nconst mutationOkSchema = v.object({\n // The user can return any additional data here\n data: jsonSchema.optional(),\n});\nconst mutationErrorSchema = v.union(appErrorSchema, zeroErrorSchema);\n\nexport const mutationResultSchema = v.union(\n mutationOkSchema,\n mutationErrorSchema,\n);\n\nexport const mutationResponseSchema = v.object({\n id: mutationIDSchema,\n result: mutationResultSchema,\n});\n\nconst pushOkSchema = v.object({\n mutations: v.array(mutationResponseSchema),\n});\n\n/**\n * @deprecated push errors are now represented as ['error', { ... }] messages\n */\nconst unsupportedPushVersionSchema = v.object({\n /** @deprecated */\n error: v.literal('unsupportedPushVersion'),\n /** @deprecated */\n mutationIDs: v.array(mutationIDSchema).optional(),\n});\n/**\n * @deprecated push errors are now represented as ['error', { ... }] messages\n */\nconst unsupportedSchemaVersionSchema = v.object({\n /** @deprecated */\n error: v.literal('unsupportedSchemaVersion'),\n /** @deprecated */\n mutationIDs: v.array(mutationIDSchema).optional(),\n});\n/**\n * @deprecated push http errors are now represented as ['error', { ... }] messages\n */\nconst httpErrorSchema = v.object({\n /** @deprecated */\n error: v.literal('http'),\n /** @deprecated */\n status: v.number(),\n /** @deprecated */\n details: v.string(),\n /** @deprecated */\n mutationIDs: v.array(mutationIDSchema).optional(),\n});\n/**\n * @deprecated push zero errors are now represented as ['error', { ... }] messages\n */\nconst zeroPusherErrorSchema = v.object({\n /** @deprecated */\n error: v.literal('zeroPusher'),\n /** @deprecated */\n details: v.string(),\n /** @deprecated */\n mutationIDs: v.array(mutationIDSchema).optional(),\n});\n/**\n * @deprecated push errors are now represented as ['error', { ... }] messages\n */\nconst pushErrorSchema = v.union(\n unsupportedPushVersionSchema,\n unsupportedSchemaVersionSchema,\n httpErrorSchema,\n zeroPusherErrorSchema,\n);\n\nexport const pushResponseBodySchema = v.union(pushOkSchema, pushErrorSchema);\n\nexport const pushResponseSchema = v.union(\n pushResponseBodySchema,\n pushFailedBodySchema,\n);\nexport const pushResponseMessageSchema = v.tuple([\n v.literal('pushResponse'),\n pushResponseBodySchema,\n]);\n\nexport const ackMutationResponsesMessageSchema = v.tuple([\n v.literal('ackMutationResponses'),\n mutationIDSchema,\n]);\n\n/**\n * The schema for the querystring parameters of the custom push endpoint.\n */\nexport const pushParamsSchema = v.object({\n schema: v.string(),\n appID: v.string(),\n});\n\nexport type InsertOp = v.Infer<typeof insertOpSchema>;\nexport type UpsertOp = v.Infer<typeof upsertOpSchema>;\nexport type UpdateOp = v.Infer<typeof updateOpSchema>;\nexport type DeleteOp = v.Infer<typeof deleteOpSchema>;\nexport type CRUDOp = v.Infer<typeof crudOpSchema>;\nexport type CRUDOpKind = CRUDOp['op'];\nexport type CRUDMutationArg = v.Infer<typeof crudArgSchema>;\nexport type CRUDMutation = v.Infer<typeof crudMutationSchema>;\nexport type CustomMutation = v.Infer<typeof customMutationSchema>;\nexport type Mutation = v.Infer<typeof mutationSchema>;\nexport type PushBody = v.Infer<typeof pushBodySchema>;\nexport type PushMessage = v.Infer<typeof pushMessageSchema>;\nexport type PushResponseBody = v.Infer<typeof pushResponseBodySchema>;\nexport type PushResponse = v.Infer<typeof pushResponseSchema>;\nexport type PushResponseMessage = v.Infer<typeof pushResponseMessageSchema>;\nexport type MutationResponse = v.Infer<typeof mutationResponseSchema>;\nexport type MutationOk = v.Infer<typeof mutationOkSchema>;\nexport type MutationError = v.Infer<typeof mutationErrorSchema>;\n/**\n * @deprecated push errors are now represented as ['error', { ... }] messages\n */\nexport type PushError = v.Infer<typeof pushErrorSchema>;\nexport type PushOk = v.Infer<typeof pushOkSchema>;\nexport type MutationResult = v.Infer<typeof mutationResultSchema>;\nexport type AckMutationMessage = v.Infer<\n typeof ackMutationResponsesMessageSchema\n>;\nexport type CleanupResultsArg = v.Infer<typeof cleanupResultsArgSchema>;\nexport type {MutationID} from './mutation-id.ts';\n\nexport function mapCRUD(\n arg: CRUDMutationArg,\n map: NameMapper,\n): CRUDMutationArg {\n return {\n ops: arg.ops.map(\n ({op, tableName, primaryKey, value}) =>\n ({\n op,\n tableName: map.tableName(tableName),\n primaryKey: map.columns(tableName, primaryKey),\n value: map.row(tableName, value),\n // The cast is necessary because ts objects to the `value` field\n // for \"delete\" ops being different.\n }) as unknown as CRUDOp,\n ),\n };\n}\n"],"mappings":";;;;;;;;AAYA,IA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WAAW,IAAI,UAAU,UAAU;EACnC,YAAY,IAAI,QAAQ,WAAW,WAAW;EAC9C,OAAO,IAAI,IAAI,WAAW,MAAM;EAGjC,EACJ,EACF"}
1
+ {"version":3,"file":"push.js","names":[],"sources":["../../../../zero-protocol/src/push.ts"],"sourcesContent":["import {jsonSchema} from '../../shared/src/json-schema.ts';\nimport * as v from '../../shared/src/valita.ts';\nimport type {NameMapper} from '../../zero-types/src/name-mapper.ts';\nimport {rowSchema} from './data.ts';\nimport {pushFailedBodySchema} from './error.ts';\nimport {mutationIDSchema} from './mutation-id.ts';\nimport * as MutationType from './mutation-type-enum.ts';\nimport {primaryKeySchema, primaryKeyValueRecordSchema} from './primary-key.ts';\n\n// NOTE! If you change this name you must also change the\n// string in `replicache-impl.ts` But CRUD mutators are being\n// deleted soon so this should not happen.\nexport const CRUD_MUTATION_NAME = '_zero_crud';\n\n// Internal mutation name for cleaning up mutation results.\n// This mutation is sent from zero-cache to zero-server to delete\n// acknowledged mutation results from the upstream database.\nexport const CLEANUP_RESULTS_MUTATION_NAME = '_zero_cleanupResults';\n\nexport const cleanupResultsArgSchema = v.union(\n // Legacy format (no type field) - treat as single\n v.object({\n clientGroupID: v.string(),\n clientID: v.string(),\n upToMutationID: v.number(),\n }),\n // Explicit single: delete up to a specific mutation ID for one client\n v.object({\n type: v.literal('single'),\n clientGroupID: v.string(),\n clientID: v.string(),\n upToMutationID: v.number(),\n }),\n // Bulk: delete all mutations for multiple clients\n v.object({\n type: v.literal('bulk'),\n clientGroupID: v.string(),\n // oxlint-disable-next-line e18e/prefer-spread-syntax\n clientIDs: v.tuple([v.string()]).concat(v.array(v.string())),\n }),\n);\n\n/**\n * Inserts if entity with id does not already exist.\n */\nconst insertOpSchema = v.object({\n op: v.literal('insert'),\n tableName: v.string(),\n primaryKey: primaryKeySchema,\n value: rowSchema,\n});\n\n/**\n * Upsert semantics. Inserts if entity with id does not already exist,\n * otherwise updates existing entity with id.\n */\nconst upsertOpSchema = v.object({\n op: v.literal('upsert'),\n tableName: v.string(),\n primaryKey: primaryKeySchema,\n value: rowSchema,\n});\n\n/**\n * Updates if entity with id exists, otherwise does nothing.\n */\nconst updateOpSchema = v.object({\n op: v.literal('update'),\n tableName: v.string(),\n primaryKey: primaryKeySchema,\n // Partial value with at least the primary key fields\n value: rowSchema,\n});\n\n/**\n * Deletes entity with id if it exists, otherwise does nothing.\n */\nconst deleteOpSchema = v.object({\n op: v.literal('delete'),\n tableName: v.string(),\n primaryKey: primaryKeySchema,\n // Partial value representing the primary key\n value: primaryKeyValueRecordSchema,\n});\n\nconst crudOpSchema = v.union(\n insertOpSchema,\n upsertOpSchema,\n updateOpSchema,\n deleteOpSchema,\n);\n\nconst crudArgSchema = v.object({\n ops: v.array(crudOpSchema),\n});\n\nconst crudArgsSchema = v.tuple([crudArgSchema]);\n\nexport const crudMutationSchema = v.object({\n type: v.literal(MutationType.CRUD),\n id: v.number(),\n clientID: v.string(),\n name: v.literal(CRUD_MUTATION_NAME),\n args: crudArgsSchema,\n timestamp: v.number(),\n});\n\nexport const customMutationSchema = v.object({\n type: v.literal(MutationType.Custom),\n id: v.number(),\n clientID: v.string(),\n name: v.string(),\n args: v.array(jsonSchema),\n timestamp: v.number(),\n});\n\nexport const mutationSchema = v.union(crudMutationSchema, customMutationSchema);\n\nexport const pushBodySchema = v.object({\n clientGroupID: v.string(),\n mutations: v.array(mutationSchema),\n pushVersion: v.number(),\n // For legacy (CRUD) mutations, the schema is tied to the client group /\n // sync connection. For custom mutations, schema versioning is delegated\n // to the custom protocol / api-server.\n schemaVersion: v.number().optional(),\n timestamp: v.number(),\n requestID: v.string(),\n /**\n * @deprecated auth is managed at client-group scope via connect/updateAuth\n * and should not be included in push messages.\n */\n auth: v.string().optional(),\n /** W3C traceparent header for distributed tracing. */\n traceparent: v.string().optional(),\n});\n\nexport const pushMessageSchema = v.tuple([v.literal('push'), pushBodySchema]);\n\nconst appErrorSchema = v.object({\n error: v.literal('app'),\n // The user can return any additional data here\n message: v.string().optional(),\n details: jsonSchema.optional(),\n});\nconst zeroErrorSchema = v.object({\n error: v.union(\n /** @deprecated push oooMutation errors are now represented as ['error', { ... }] messages */\n v.literal('oooMutation'),\n v.literal('alreadyProcessed'),\n ),\n details: jsonSchema.optional(),\n});\n\nconst mutationOkSchema = v.object({\n // The user can return any additional data here\n data: jsonSchema.optional(),\n});\nconst mutationErrorSchema = v.union(appErrorSchema, zeroErrorSchema);\n\nexport const mutationResultSchema = v.union(\n mutationOkSchema,\n mutationErrorSchema,\n);\n\nexport const mutationResponseSchema = v.object({\n id: mutationIDSchema,\n result: mutationResultSchema,\n});\n\nconst pushOkSchema = v.object({\n mutations: v.array(mutationResponseSchema),\n});\n\n/**\n * @deprecated push errors are now represented as ['error', { ... }] messages\n */\nconst unsupportedPushVersionSchema = v.object({\n /** @deprecated */\n error: v.literal('unsupportedPushVersion'),\n /** @deprecated */\n mutationIDs: v.array(mutationIDSchema).optional(),\n});\n/**\n * @deprecated push errors are now represented as ['error', { ... }] messages\n */\nconst unsupportedSchemaVersionSchema = v.object({\n /** @deprecated */\n error: v.literal('unsupportedSchemaVersion'),\n /** @deprecated */\n mutationIDs: v.array(mutationIDSchema).optional(),\n});\n/**\n * @deprecated push http errors are now represented as ['error', { ... }] messages\n */\nconst httpErrorSchema = v.object({\n /** @deprecated */\n error: v.literal('http'),\n /** @deprecated */\n status: v.number(),\n /** @deprecated */\n details: v.string(),\n /** @deprecated */\n mutationIDs: v.array(mutationIDSchema).optional(),\n});\n/**\n * @deprecated push zero errors are now represented as ['error', { ... }] messages\n */\nconst zeroPusherErrorSchema = v.object({\n /** @deprecated */\n error: v.literal('zeroPusher'),\n /** @deprecated */\n details: v.string(),\n /** @deprecated */\n mutationIDs: v.array(mutationIDSchema).optional(),\n});\n/**\n * @deprecated push errors are now represented as ['error', { ... }] messages\n */\nconst pushErrorSchema = v.union(\n unsupportedPushVersionSchema,\n unsupportedSchemaVersionSchema,\n httpErrorSchema,\n zeroPusherErrorSchema,\n);\n\nexport const pushResponseBodySchema = v.union(pushOkSchema, pushErrorSchema);\n\nexport const pushResponseSchema = v.union(\n pushResponseBodySchema,\n pushFailedBodySchema,\n);\nexport const pushResponseMessageSchema = v.tuple([\n v.literal('pushResponse'),\n pushResponseBodySchema,\n]);\n\nexport const ackMutationResponsesMessageSchema = v.tuple([\n v.literal('ackMutationResponses'),\n mutationIDSchema,\n]);\n\n/**\n * The schema for the querystring parameters of the custom push endpoint.\n */\nexport const pushParamsSchema = v.object({\n schema: v.string(),\n appID: v.string(),\n});\n\nexport type InsertOp = v.Infer<typeof insertOpSchema>;\nexport type UpsertOp = v.Infer<typeof upsertOpSchema>;\nexport type UpdateOp = v.Infer<typeof updateOpSchema>;\nexport type DeleteOp = v.Infer<typeof deleteOpSchema>;\nexport type CRUDOp = v.Infer<typeof crudOpSchema>;\nexport type CRUDOpKind = CRUDOp['op'];\nexport type CRUDMutationArg = v.Infer<typeof crudArgSchema>;\nexport type CRUDMutation = v.Infer<typeof crudMutationSchema>;\nexport type CustomMutation = v.Infer<typeof customMutationSchema>;\nexport type Mutation = v.Infer<typeof mutationSchema>;\nexport type PushBody = v.Infer<typeof pushBodySchema>;\nexport type PushMessage = v.Infer<typeof pushMessageSchema>;\nexport type PushResponseBody = v.Infer<typeof pushResponseBodySchema>;\nexport type PushResponse = v.Infer<typeof pushResponseSchema>;\nexport type PushResponseMessage = v.Infer<typeof pushResponseMessageSchema>;\nexport type MutationResponse = v.Infer<typeof mutationResponseSchema>;\nexport type MutationOk = v.Infer<typeof mutationOkSchema>;\nexport type MutationError = v.Infer<typeof mutationErrorSchema>;\n/**\n * @deprecated push errors are now represented as ['error', { ... }] messages\n */\nexport type PushError = v.Infer<typeof pushErrorSchema>;\nexport type PushOk = v.Infer<typeof pushOkSchema>;\nexport type MutationResult = v.Infer<typeof mutationResultSchema>;\nexport type AckMutationMessage = v.Infer<\n typeof ackMutationResponsesMessageSchema\n>;\nexport type CleanupResultsArg = v.Infer<typeof cleanupResultsArgSchema>;\nexport type {MutationID} from './mutation-id.ts';\n\nexport function mapCRUD(\n arg: CRUDMutationArg,\n map: NameMapper,\n): CRUDMutationArg {\n return {\n ops: arg.ops.map(\n ({op, tableName, primaryKey, value}) =>\n ({\n op,\n tableName: map.tableName(tableName),\n primaryKey: map.columns(tableName, primaryKey),\n value: map.row(tableName, value),\n // The cast is necessary because ts objects to the `value` field\n // for \"delete\" ops being different.\n }) as unknown as CRUDOp,\n ),\n };\n}\n"],"mappings":";;;;;;;;AAYA,IAAa,qBAAqB;AAKlC,IAAa,gCAAgC;AAE7C,IAAa,0BAA0B,eAAE,MAEvC,eAAE,OAAO;CACP,eAAe,eAAE,QAAQ;CACzB,UAAU,eAAE,QAAQ;CACpB,gBAAgB,eAAE,QAAQ;CAC3B,CAAC,EAEF,eAAE,OAAO;CACP,MAAM,eAAE,QAAQ,SAAS;CACzB,eAAe,eAAE,QAAQ;CACzB,UAAU,eAAE,QAAQ;CACpB,gBAAgB,eAAE,QAAQ;CAC3B,CAAC,EAEF,eAAE,OAAO;CACP,MAAM,eAAE,QAAQ,OAAO;CACvB,eAAe,eAAE,QAAQ;CAEzB,WAAW,eAAE,MAAM,CAAC,eAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,eAAE,MAAM,eAAE,QAAQ,CAAC,CAAC;CAC7D,CAAC,CACH;;;;AAKD,IAAM,iBAAiB,eAAE,OAAO;CAC9B,IAAI,eAAE,QAAQ,SAAS;CACvB,WAAW,eAAE,QAAQ;CACrB,YAAY;CACZ,OAAO;CACR,CAAC;;;;;AAMF,IAAM,iBAAiB,eAAE,OAAO;CAC9B,IAAI,eAAE,QAAQ,SAAS;CACvB,WAAW,eAAE,QAAQ;CACrB,YAAY;CACZ,OAAO;CACR,CAAC;;;;AAKF,IAAM,iBAAiB,eAAE,OAAO;CAC9B,IAAI,eAAE,QAAQ,SAAS;CACvB,WAAW,eAAE,QAAQ;CACrB,YAAY;CAEZ,OAAO;CACR,CAAC;;;;AAKF,IAAM,iB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,4BAA4B,eAAE,MAAM,CAC/C,eAAE,QAAQ,eAAe,EACzB,uBACD,CAAC;AAEF,IAAa,oCAAoC,eAAE,MAAM,CACvD,eAAE,QAAQ,uBAAuB,EACjC,iBACD,CAAC;;;;AAKF,IAAa,mBAAmB,eAAE,OAAO;CACvC,QAAQ,eAAE,QAAQ;CAClB,OAAO,eAAE,QAAQ;CAClB,CAAC;AAgCF,SAAgB,QACd,KACA,KACiB;AACjB,QAAO,EACL,KAAK,IAAI,IAAI,KACV,EAAC,IAAI,WAAW,YAAY,aAC1B;EACC;EACA,WAAW,IAAI,UAAU,UAAU;EACnC,YAAY,IAAI,QAAQ,WAAW,WAAW;EAC9C,OAAO,IAAI,IAAI,WAAW,MAAM;EAGjC,EACJ,EACF"}
@@ -31,6 +31,7 @@ export declare const upstreamSchema: v.UnionType<[v.TupleType<[v.Type<"initConne
31
31
  userQueryURL: v.Optional<string>;
32
32
  userQueryHeaders: v.Optional<Record<string, string>>;
33
33
  activeClients: v.Optional<string[]>;
34
+ traceparent: v.Optional<string>;
34
35
  }, undefined>]>, v.TupleType<[v.Type<"ping">, v.ObjectType<{}, undefined>]>, v.TupleType<[v.Type<"deleteClients">, v.UnionType<[v.ObjectType<Readonly<{
35
36
  clientIDs: v.Optional<readonly string[]>;
36
37
  clientGroupIDs: v.Optional<readonly string[]>;
@@ -49,6 +50,7 @@ export declare const upstreamSchema: v.UnionType<[v.TupleType<[v.Type<"initConne
49
50
  }, undefined>, v.ObjectType<{
50
51
  op: v.Type<"clear">;
51
52
  }, undefined>]>>;
53
+ traceparent: v.Optional<string>;
52
54
  }, undefined>]>, v.TupleType<[v.Type<"pull">, v.ObjectType<{
53
55
  clientGroupID: v.Type<string>;
54
56
  cookie: v.UnionType<[v.Type<string>, v.Type<null>]>;
@@ -99,6 +101,7 @@ export declare const upstreamSchema: v.UnionType<[v.TupleType<[v.Type<"initConne
99
101
  timestamp: v.Type<number>;
100
102
  requestID: v.Type<string>;
101
103
  auth: v.Optional<string>;
104
+ traceparent: v.Optional<string>;
102
105
  }, undefined>]>, v.TupleType<[v.Type<"closeConnection">, v.ArrayType<v.Type<unknown>>]>, v.TupleType<[v.Type<"inspect">, v.UnionType<[v.ObjectType<Omit<{
103
106
  id: v.Type<string>;
104
107
  }, "op" | "clientID"> & {
@@ -1 +1 @@
1
- {"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/up.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAWhD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAW1B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../../../zero-protocol/src/up.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,4BAA4B,CAAC;AAWhD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAW1B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"zero-provider.d.ts","sourceRoot":"","sources":["../../../../zero-react/src/zero-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,IAAI,EACJ,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,K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AgB,YAAY,CAC1B,CAAC,SAAS,iBAAiB,GAAG,aAAa,EAC3C,EAAE,SAAS,iBAAiB,GAAG,SAAS,GAAG,SAAS,EACpD,OAAO,SAAS,kBAAkB,GAAG,cAAc,EACnD,EAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,EAAC,EAAE,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,uDA8D9D"}
@@ -24,11 +24,11 @@ function useZero() {
24
24
  function createUseZero() {
25
25
  return () => useZero();
26
26
  }
27
- var NO_AUTH_SET = Symbol();
28
27
  function ZeroProvider({ children, init, ...props }) {
29
28
  const isExternalZero = "zero" in props;
30
29
  const [zero, setZero] = useState(isExternalZero ? props.zero : void 0);
31
- const auth = "auth" in props ? props.auth : NO_AUTH_SET;
30
+ const auth = "auth" in props ? props.auth : void 0;
31
+ const hasAuth = typeof auth === "string";
32
32
  const prevAuthRef = useRef(auth);
33
33
  useEffect(() => {
34
34
  if (isExternalZero) {
@@ -36,18 +36,24 @@ function ZeroProvider({ children, init, ...props }) {
36
36
  return;
37
37
  }
38
38
  const z = new Zero(props);
39
+ prevAuthRef.current = auth;
39
40
  init?.(z);
40
41
  setZero(z);
41
42
  return () => {
42
43
  z.close();
43
44
  setZero(void 0);
44
45
  };
45
- }, [init, ...useMemo(() => Object.entries(props).filter(([key]) => key !== "auth").sort(([a], [b]) => stringCompare(a, b)).map(([_, value]) => value), [props])]);
46
+ }, [
47
+ hasAuth,
48
+ init,
49
+ ...useMemo(() => Object.entries(props).filter(([key]) => key !== "auth").sort(([a], [b]) => stringCompare(a, b)).map(([_, value]) => value), [props])
50
+ ]);
46
51
  useEffect(() => {
47
52
  if (!zero || isExternalZero) return;
48
- if (auth !== prevAuthRef.current) {
53
+ const prevAuth = prevAuthRef.current;
54
+ if (auth !== prevAuth) {
49
55
  prevAuthRef.current = auth;
50
- zero.connection.connect({ auth: auth === NO_AUTH_SET ? void 0 : auth });
56
+ if (typeof prevAuth === "string" && typeof auth === "string") zero.connection.connect({ auth });
51
57
  }
52
58
  }, [auth, zero]);
53
59
  return zero && /* @__PURE__ */ jsx(ZeroContext.Provider, {
@@ -1 +1 @@
1
- {"version":3,"file":"zero-provider.js","names":[],"sources":["../../../../zero-react/src/zero-provider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport {stringCompare} from '../../shared/src/string-compare.ts';\nimport {\n Zero,\n type BaseDefaultContext,\n type BaseDefaultSchema,\n type CustomMutatorDefs,\n type DefaultContext,\n type DefaultSchema,\n type ZeroOptions,\n} from './zero.ts';\n\n// oxlint-disable-next-line no-explicit-any\nexport const ZeroContext = createContext<Zero<any, any, any> | undefined>(\n undefined,\n);\n\nexport function useZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>(): Zero<S, MD, Context> {\n const zero = useContext(ZeroContext);\n if (zero === undefined) {\n throw new Error('useZero must be used within a ZeroProvider');\n }\n return zero as Zero<S, MD, Context>;\n}\n\n/**\n * @deprecated Use {@linkcode useZero} instead, alongside default types defined with:\n *\n * ```ts\n * declare module '@rocicorp/zero' {\n * interface DefaultTypes {\n * schema: typeof schema;\n * context: Context;\n * }\n * }\n */\nexport function createUseZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>() {\n return () => useZero<S, MD, Context>();\n}\n\nexport type ZeroProviderProps<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n> = (ZeroOptions<S, MD, Context> | {zero: Zero<S, MD, Context>}) & {\n init?: (zero: Zero<S, MD, Context>) => void;\n children: ReactNode;\n};\n\nconst NO_AUTH_SET = Symbol();\n\nexport function ZeroProvider<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>({children, init, ...props}: ZeroProviderProps<S, MD, Context>) {\n const isExternalZero = 'zero' in props;\n\n const [zero, setZero] = useState<Zero<S, MD, Context> | undefined>(\n isExternalZero ? props.zero : undefined,\n );\n\n const auth = 'auth' in props ? props.auth : NO_AUTH_SET;\n const prevAuthRef = useRef<typeof auth>(auth);\n\n const keysWithoutAuth = useMemo(\n () =>\n Object.entries(props)\n .filter(([key]) => key !== 'auth')\n .sort(([a], [b]) => stringCompare(a, b))\n .map(([_, value]) => value),\n [props],\n );\n\n // If Zero is not passed in, we construct it, but only client-side.\n // Zero doesn't really work SSR today so this is usually the right thing.\n // When we support Zero SSR this will either become a breaking change or\n // more likely server support will be opt-in with a new prop on this\n // component.\n useEffect(() => {\n if (isExternalZero) {\n setZero(props.zero);\n return;\n }\n\n const z = new Zero(props);\n init?.(z);\n setZero(z);\n\n return () => {\n void z.close();\n setZero(undefined);\n };\n // we intentionally don't include auth in the dependency array\n // to avoid closing zero when auth changes\n }, [init, ...keysWithoutAuth]);\n\n useEffect(() => {\n if (!zero || isExternalZero) return;\n\n const authChanged = auth !== prevAuthRef.current;\n\n if (authChanged) {\n prevAuthRef.current = auth;\n void zero.connection.connect({\n auth: auth === NO_AUTH_SET ? undefined : auth,\n });\n }\n }, [auth, zero]);\n\n return (\n zero && <ZeroContext.Provider value={zero}>{children}</ZeroContext.Provider>\n );\n}\n"],"mappings":";;;;;;AAqBA,IAAa,cAAc,cACzB,KAAA,EACD;AAED,SAAgB,UAIU;CACxB,MAAM,OAAO,WAAW,YAAY;AACpC,KAAI,SAAS,KAAA,EACX,OAAM,IAAI,MAAM,6CAA6C;AAE/D,QAAO;;;;;;;;;;;;;AAcT,SAAgB,gBAIZ;AACF,cAAa,SAAyB;;AAYxC,IAAM,cAAc,QAAQ;AAE5B,SAAgB,aAId,EAAC,UAAU,MAAM,GAAG,SAA2C;CAC/D,MAAM,iBAAiB,UAAU;CAEjC,MAAM,CAAC,MAAM,WAAW,SACtB,iBAAiB,MAAM,OAAO,KAAA,EAC/B;CAED,MAAM,OAAO,UAAU,QAAQ,MAAM,OAAO;CAC5C,MAAM,cAAc,OAAoB,KAAK;AAgB7C,iBAAgB;AACd,MAAI,gBAAgB;AAClB,WAAQ,MAAM,KAAK;AACnB;;EAGF,MAAM,IAAI,IAAI,KAAK,MAAM;AACzB,SAAO,EAAE;AACT,UAAQ,EAAE;AAEV,eAAa;AACN,KAAE,OAAO;AACd,WAAQ,KAAA,EAAU;;IAInB,CAAC,MAAM,GA9Bc,cAEpB,OAAO,QAAQ,MAAM,CAClB,QAAQ,CAAC,SAAS,QAAQ,OAAO,CACjC,MAAM,CAAC,IAAI,CAAC,OAAO,cAAc,GAAG,EAAE,CAAC,CACvC,KAAK,CAAC,GAAG,WAAW,MAAM,EAC/B,CAAC,MAAM,CACR,CAuB4B,CAAC;AAE9B,iBAAgB;AACd,MAAI,CAAC,QAAQ,eAAgB;AAI7B,MAFoB,SAAS,YAAY,SAExB;AACf,eAAY,UAAU;AACjB,QAAK,WAAW,QAAQ,EAC3B,MAAM,SAAS,cAAc,KAAA,IAAY,MAC1C,CAAC;;IAEH,CAAC,MAAM,KAAK,CAAC;AAEhB,QACE,QAAQ,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAAO;EAAgC,CAAA"}
1
+ {"version":3,"file":"zero-provider.js","names":[],"sources":["../../../../zero-react/src/zero-provider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport {stringCompare} from '../../shared/src/string-compare.ts';\nimport {\n Zero,\n type BaseDefaultContext,\n type BaseDefaultSchema,\n type CustomMutatorDefs,\n type DefaultContext,\n type DefaultSchema,\n type ZeroOptions,\n} from './zero.ts';\n\n// oxlint-disable-next-line no-explicit-any\nexport const ZeroContext = createContext<Zero<any, any, any> | undefined>(\n undefined,\n);\n\nexport function useZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>(): Zero<S, MD, Context> {\n const zero = useContext(ZeroContext);\n if (zero === undefined) {\n throw new Error('useZero must be used within a ZeroProvider');\n }\n return zero as Zero<S, MD, Context>;\n}\n\n/**\n * @deprecated Use {@linkcode useZero} instead, alongside default types defined with:\n *\n * ```ts\n * declare module '@rocicorp/zero' {\n * interface DefaultTypes {\n * schema: typeof schema;\n * context: Context;\n * }\n * }\n */\nexport function createUseZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>() {\n return () => useZero<S, MD, Context>();\n}\n\nexport type ZeroProviderProps<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n> = (ZeroOptions<S, MD, Context> | {zero: Zero<S, MD, Context>}) & {\n init?: (zero: Zero<S, MD, Context>) => void;\n children: ReactNode;\n};\n\nexport function ZeroProvider<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>({children, init, ...props}: ZeroProviderProps<S, MD, Context>) {\n const isExternalZero = 'zero' in props;\n\n const [zero, setZero] = useState<Zero<S, MD, Context> | undefined>(\n isExternalZero ? props.zero : undefined,\n );\n\n const auth = 'auth' in props ? props.auth : undefined;\n const hasAuth = typeof auth === 'string';\n const prevAuthRef = useRef<typeof auth>(auth);\n\n const keysWithoutAuth = useMemo(\n () =>\n Object.entries(props)\n .filter(([key]) => key !== 'auth')\n .sort(([a], [b]) => stringCompare(a, b))\n .map(([_, value]) => value),\n [props],\n );\n\n // If Zero is not passed in, we construct it, but only client-side.\n // Zero doesn't really work SSR today so this is usually the right thing.\n // When we support Zero SSR this will either become a breaking change or\n // more likely server support will be opt-in with a new prop on this\n // component.\n useEffect(() => {\n if (isExternalZero) {\n setZero(props.zero);\n return;\n }\n\n const z = new Zero(props);\n prevAuthRef.current = auth;\n init?.(z);\n setZero(z);\n\n return () => {\n void z.close();\n setZero(undefined);\n };\n // we intentionally don't include auth in the dependency array\n // to avoid closing zero when auth changes\n }, [hasAuth, init, ...keysWithoutAuth]);\n\n useEffect(() => {\n if (!zero || isExternalZero) return;\n\n const prevAuth = prevAuthRef.current;\n const authChanged = auth !== prevAuth;\n\n if (authChanged) {\n prevAuthRef.current = auth;\n\n if (typeof prevAuth === 'string' && typeof auth === 'string') {\n void zero.connection.connect({auth});\n }\n }\n }, [auth, zero]);\n\n return (\n zero && <ZeroContext.Provider value={zero}>{children}</ZeroContext.Provider>\n );\n}\n"],"mappings":";;;;;;AAqBA,IAAa,cAAc,cACzB,KAAA,EACD;AAED,SAAgB,UAIU;CACxB,MAAM,OAAO,WAAW,YAAY;AACpC,KAAI,SAAS,KAAA,EACX,OAAM,IAAI,MAAM,6CAA6C;AAE/D,QAAO;;;;;;;;;;;;;AAcT,SAAgB,gBAIZ;AACF,cAAa,SAAyB;;AAYxC,SAAgB,aAId,EAAC,UAAU,MAAM,GAAG,SAA2C;CAC/D,MAAM,iBAAiB,UAAU;CAEjC,MAAM,CAAC,MAAM,WAAW,SACtB,iBAAiB,MAAM,OAAO,KAAA,EAC/B;CAED,MAAM,OAAO,UAAU,QAAQ,MAAM,OAAO,KAAA;CAC5C,MAAM,UAAU,OAAO,SAAS;CAChC,MAAM,cAAc,OAAoB,KAAK;AAgB7C,iBAAgB;AACd,MAAI,gBAAgB;AAClB,WAAQ,MAAM,KAAK;AACnB;;EAGF,MAAM,IAAI,IAAI,KAAK,MAAM;AACzB,cAAY,UAAU;AACtB,SAAO,EAAE;AACT,UAAQ,EAAE;AAEV,eAAa;AACN,KAAE,OAAO;AACd,WAAQ,KAAA,EAAU;;IAInB;EAAC;EAAS;EAAM,GA/BK,cAEpB,OAAO,QAAQ,MAAM,CAClB,QAAQ,CAAC,S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,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAM5D;AAED,wBAAgB,OAAO,CACrB,CAAC,SAAS,iBAAiB,GAAG,aAAa,EAC3C,EAAE,SAAS,iBAAiB,GAAG,SAAS,GAAG,SAAS,EACpD,OAAO,SAAS,kBAAkB,GAAG,cAAc,KAChD,MAAM,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAO9B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,CAAC,SAAS,iBAAiB,GAAG,aAAa,EAC3C,EAAE,SAAS,iBAAiB,GAAG,SAAS,GAAG,SAAS,EACpD,OAAO,SAAS,kBAAkB,GAAG,cAAc,sCAGpD;AAED,wBAAgB,YAAY,CAC1B,CAAC,SAAS,iBAAiB,GAAG,aAAa,EAC3C,EAAE,SAAS,iBAAiB,GAAG,SAAS,GAAG,SAAS,EACpD,OAAO,SAAS,kBAAkB,GAAG,cAAc,EAEnD,KAAK,EAAE;IACL,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAC7C,GAAG,CACA;IACE,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;CAC5B,GACD,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAC9B,eAoDF"}
@@ -31,12 +31,16 @@ function useZero() {
31
31
  function createUseZero() {
32
32
  return () => useZero();
33
33
  }
34
- var NO_AUTH_SET = Symbol();
35
34
  function ZeroProvider(props) {
35
+ let prevAuth = "auth" in props ? props.auth : void 0;
36
+ const auth = createMemo(() => "auth" in props ? props.auth : void 0);
37
+ const hasAuth = createMemo(() => typeof auth() === "string");
36
38
  const zero = createMemo(() => {
37
39
  if ("zero" in props) return props.zero;
40
+ hasAuth();
38
41
  const [, options] = splitProps(props, ["children", "auth"]);
39
- const authValue = untrack(() => props.auth);
42
+ const authValue = untrack(auth);
43
+ prevAuth = authValue;
40
44
  const createdZero = new Zero({
41
45
  ...options,
42
46
  ...authValue !== void 0 ? { auth: authValue } : {},
@@ -46,19 +50,14 @@ function ZeroProvider(props) {
46
50
  onCleanup(() => createdZero.close());
47
51
  return createdZero;
48
52
  });
49
- const auth = createMemo(() => "auth" in props ? props.auth : NO_AUTH_SET);
50
- let prevAuth = NO_AUTH_SET;
51
53
  createEffect(() => {
52
54
  const currentZero = zero();
53
55
  if (!currentZero || "zero" in props) return;
54
56
  const currentAuth = auth();
55
- if (prevAuth === NO_AUTH_SET) {
56
- prevAuth = currentAuth;
57
- return;
58
- }
59
57
  if (currentAuth !== prevAuth) {
58
+ const previousAuth = prevAuth;
60
59
  prevAuth = currentAuth;
61
- currentZero.connection.connect({ auth: currentAuth === NO_AUTH_SET ? void 0 : currentAuth });
60
+ if (typeof previousAuth === "string" && typeof currentAuth === "string") currentZero.connection.connect({ auth: currentAuth });
62
61
  }
63
62
  });
64
63
  return ZeroContext.Provider({
@@ -1 +1 @@
1
- {"version":3,"file":"use-zero.js","names":[],"sources":["../../../../zero-solid/src/use-zero.ts"],"sourcesContent":["import {\n batch,\n createContext,\n createEffect,\n createMemo,\n onCleanup,\n splitProps,\n untrack,\n useContext,\n type Accessor,\n type JSX,\n} from 'solid-js';\nimport {\n Zero,\n type BaseDefaultContext,\n type BaseDefaultSchema,\n type CustomMutatorDefs,\n type DefaultContext,\n type DefaultSchema,\n type ZeroOptions,\n} from './zero.ts';\n\nconst ZeroContext = createContext<\n // oxlint-disable-next-line no-explicit-any\n Accessor<Zero<any, any, any>> | undefined\n>(undefined);\n\n/**\n * @deprecated Use {@linkcode ZeroProvider} instead of managing your own Zero instance.\n */\nexport function createZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>(options: ZeroOptions<S, MD, Context>): Zero<S, MD, Context> {\n const opts = {\n ...options,\n batchViewUpdates: batch,\n };\n return new Zero<S, MD, Context>(opts);\n}\n\nexport function useZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>(): () => Zero<S, MD, Context> {\n const zero = useContext(ZeroContext);\n\n if (zero === undefined) {\n throw new Error('useZero must be used within a ZeroProvider');\n }\n return zero;\n}\n\n/**\n * @deprecated Use {@linkcode useZero} instead, alongside default types defined with:\n *\n * ```ts\n * declare module '@rocicorp/zero' {\n * interface DefaultTypes {\n * schema: typeof schema;\n * context: Context;\n * }\n * }\n */\nexport function createUseZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>() {\n return () => useZero<S, MD, Context>();\n}\n\nconst NO_AUTH_SET = Symbol();\n\nexport function ZeroProvider<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>(\n props: {\n children: JSX.Element;\n init?: (zero: Zero<S, MD, Context>) => void;\n } & (\n | {\n zero: Zero<S, MD, Context>;\n }\n | ZeroOptions<S, MD, Context>\n ),\n) {\n const zero = createMemo(() => {\n if ('zero' in props) {\n return props.zero;\n }\n\n const [, options] = splitProps(props, ['children', 'auth']);\n\n const authValue = untrack(() => props.auth);\n const createdZero = new Zero({\n ...options,\n ...(authValue !== undefined ? {auth: authValue} : {}),\n batchViewUpdates: batch,\n });\n options.init?.(createdZero);\n onCleanup(() => createdZero.close());\n return createdZero;\n });\n\n const auth = createMemo<\n typeof NO_AUTH_SET | ZeroOptions<S, MD, Context>['auth']\n >(() => ('auth' in props ? props.auth : NO_AUTH_SET));\n\n let prevAuth: typeof NO_AUTH_SET | ZeroOptions<S, MD, Context>['auth'] =\n NO_AUTH_SET;\n\n createEffect(() => {\n const currentZero = zero();\n if (!currentZero || 'zero' in props) {\n return;\n }\n\n const currentAuth = auth();\n\n if (prevAuth === NO_AUTH_SET) {\n prevAuth = currentAuth;\n return;\n }\n\n if (currentAuth !== prevAuth) {\n prevAuth = currentAuth;\n void currentZero.connection.connect({\n auth: currentAuth === NO_AUTH_SET ? undefined : currentAuth,\n });\n }\n });\n\n return ZeroContext.Provider({\n value: zero,\n get children() {\n return props.children;\n },\n });\n}\n"],"mappings":";;;;AAsBA,IAAM,cAAc,cAGlB,KAAA,EAAU;;;;AAKZ,SAAgB,WAId,SAA4D;AAK5D,QAAO,IAAI,KAJE;EACX,GAAG;EACH,kBAAkB;EACnB,CACoC;;AAGvC,SAAgB,UAIgB;CAC9B,MAAM,OAAO,WAAW,YAAY;AAEpC,KAAI,SAAS,KAAA,EACX,OAAM,IAAI,MAAM,6CAA6C;AAE/D,QAAO;;;;;;;;;;;;;AAcT,SAAgB,gBAIZ;AACF,cAAa,SAAyB;;AAGxC,IAAM,cAAc,QAAQ;AAE5B,SAAgB,aAKd,OASA;CACA,MAAM,OAAO,iBAAiB;AAC5B,MAAI,UAAU,MACZ,QAAO,MAAM;EAGf,MAAM,GAAG,WAAW,WAAW,OAAO,CAAC,YAAY,OAAO,CAAC;EAE3D,MAAM,YAAY,cAAc,MAAM,KAAK;EAC3C,MAAM,cAAc,IAAI,KAAK;GAC3B,GAAG;GACH,GAAI,cAAc,KAAA,IAAY,EAAC,MAAM,WAAU,GAAG,EAAE;GACpD,kBAAkB;GACnB,CAAC;AACF,UAAQ,OAAO,YAAY;AAC3B,kBAAgB,YAAY,OAAO,CAAC;AACpC,SAAO;GACP;CAEF,MAAM,OAAO,iBAEJ,UAAU,QAAQ,MAAM,OAAO,YAAa;CAErD,IAAI,WACF;AAEF,oBAAmB;EACjB,MAAM,cAAc,MAAM;AAC1B,MAAI,CAAC,eAAe,UAAU,MAC5B;EAGF,MAAM,cAAc,MAAM;AAE1B,MAAI,aAAa,aAAa;AAC5B,cAAW;AACX;;AAGF,MAAI,gBAAgB,UAAU;AAC5B,cAAW;AACN,eAAY,WAAW,QAAQ,EAClC,MAAM,gBAAgB,cAAc,KAAA,IAAY,aACjD,CAAC;;GAEJ;AAEF,QAAO,YAAY,SAAS;EAC1B,OAAO;EACP,IAAI,WAAW;AACb,UAAO,MAAM;;EAEhB,CAAC"}
1
+ {"version":3,"file":"use-zero.js","names":[],"sources":["../../../../zero-solid/src/use-zero.ts"],"sourcesContent":["import {\n batch,\n createContext,\n createEffect,\n createMemo,\n onCleanup,\n splitProps,\n untrack,\n useContext,\n type Accessor,\n type JSX,\n} from 'solid-js';\nimport {\n Zero,\n type BaseDefaultContext,\n type BaseDefaultSchema,\n type CustomMutatorDefs,\n type DefaultContext,\n type DefaultSchema,\n type ZeroOptions,\n} from './zero.ts';\n\nconst ZeroContext = createContext<\n // oxlint-disable-next-line no-explicit-any\n Accessor<Zero<any, any, any>> | undefined\n>(undefined);\n\n/**\n * @deprecated Use {@linkcode ZeroProvider} instead of managing your own Zero instance.\n */\nexport function createZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>(options: ZeroOptions<S, MD, Context>): Zero<S, MD, Context> {\n const opts = {\n ...options,\n batchViewUpdates: batch,\n };\n return new Zero<S, MD, Context>(opts);\n}\n\nexport function useZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>(): () => Zero<S, MD, Context> {\n const zero = useContext(ZeroContext);\n\n if (zero === undefined) {\n throw new Error('useZero must be used within a ZeroProvider');\n }\n return zero;\n}\n\n/**\n * @deprecated Use {@linkcode useZero} instead, alongside default types defined with:\n *\n * ```ts\n * declare module '@rocicorp/zero' {\n * interface DefaultTypes {\n * schema: typeof schema;\n * context: Context;\n * }\n * }\n */\nexport function createUseZero<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>() {\n return () => useZero<S, MD, Context>();\n}\n\nexport function ZeroProvider<\n S extends BaseDefaultSchema = DefaultSchema,\n MD extends CustomMutatorDefs | undefined = undefined,\n Context extends BaseDefaultContext = DefaultContext,\n>(\n props: {\n children: JSX.Element;\n init?: (zero: Zero<S, MD, Context>) => void;\n } & (\n | {\n zero: Zero<S, MD, Context>;\n }\n | ZeroOptions<S, MD, Context>\n ),\n) {\n let prevAuth = 'auth' in props ? props.auth : undefined;\n\n const auth = createMemo(() => ('auth' in props ? props.auth : undefined));\n const hasAuth = createMemo(() => typeof auth() === 'string');\n\n const zero = createMemo(() => {\n if ('zero' in props) {\n return props.zero;\n }\n\n hasAuth();\n\n const [, options] = splitProps(props, ['children', 'auth']);\n\n const authValue = untrack(auth);\n prevAuth = authValue;\n const createdZero = new Zero({\n ...options,\n ...(authValue !== undefined ? {auth: authValue} : {}),\n batchViewUpdates: batch,\n });\n options.init?.(createdZero);\n onCleanup(() => createdZero.close());\n return createdZero;\n });\n\n createEffect(() => {\n const currentZero = zero();\n if (!currentZero || 'zero' in props) {\n return;\n }\n\n const currentAuth = auth();\n\n if (currentAuth !== prevAuth) {\n const previousAuth = prevAuth;\n prevAuth = currentAuth;\n\n if (typeof previousAuth === 'string' && typeof currentAuth === 'string') {\n void currentZero.connection.connect({auth: currentAuth});\n }\n }\n });\n\n return ZeroContext.Provider({\n value: zero,\n get children() {\n return props.children;\n },\n });\n}\n"],"mappings":";;;;AAsBA,IAAM,cAAc,cAGlB,KAAA,EAAU;;;;AAKZ,SAAgB,WAId,SAA4D;AAK5D,QAAO,IAAI,KAJE;EACX,GAAG;EACH,kBAAkB;EACnB,CACoC;;AAGvC,SAAgB,UAIgB;CAC9B,MAAM,OAAO,WAAW,YAAY;AAEpC,KAAI,SAAS,KAAA,EACX,OAAM,IAAI,MAAM,6CAA6C;AAE/D,QAAO;;;;;;;;;;;;;AAcT,SAAgB,gBAIZ;AACF,cAAa,SAAyB;;AAGxC,SAAgB,aAKd,OASA;CACA,IAAI,WAAW,UAAU,QAAQ,MAAM,OAAO,KAAA;CAE9C,MAAM,OAAO,iBAAkB,UAAU,QAAQ,MAAM,OAAO,KAAA,EAAW;CACzE,MAAM,UAAU,iBAAiB,OAAO,MAAM,KAAK,SAAS;CAE5D,MAAM,OAAO,iBAAiB;AAC5B,MAAI,UAAU,MACZ,QAAO,MAAM;AAGf,WAAS;EAET,MAAM,GAAG,WAAW,WAAW,OAAO,CAAC,YAAY,OAAO,CAAC;EAE3D,MAAM,YAAY,QAAQ,KAAK;AAC/B,aAAW;EACX,MAAM,cAAc,IAAI,KAAK;GAC3B,GAAG;GACH,GAAI,cAAc,KAAA,IAAY,EAAC,MAAM,WAAU,GAAG,EAAE;GACpD,kBAAkB;GACnB,CAAC;AACF,UAAQ,OAAO,YAAY;AAC3B,kBAAgB,YAAY,OAAO,CAAC;AACpC,SAAO;GACP;AAEF,oBAAmB;EACjB,MAAM,cAAc,MAAM;AAC1B,MAAI,CAAC,eAAe,UAAU,MAC5B;EAGF,MAAM,cAAc,MAAM;AAE1B,MAAI,gBAAgB,UAAU;GAC5B,MAAM,eAAe;AACrB,cAAW;AAEX,OAAI,OAAO,iBAAiB,YAAY,OAAO,gBAAgB,SACxD,aAAY,WAAW,QAAQ,EAAC,MAAM,aAAY,CAAC;;GAG5D;AAEF,QAAO,YAAY,SAAS;EAC1B,OAAO;EACP,IAAI,WAAW;AACb,UAAO,MAAM;;EAEhB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocicorp/zero",
3
- "version": "1.2.0-canary.12",
3
+ "version": "1.2.0-canary.14",
4
4
  "description": "Zero is a web framework for serverless web development.",
5
5
  "author": "Rocicorp, Inc.",
6
6
  "repository": {