@rocicorp/zero 0.23.2025083000 → 0.23.2025090400

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 (72) hide show
  1. package/out/{chunk-KSJKRBQT.js → chunk-6QYVZALS.js} +2 -2
  2. package/out/{chunk-GW2SIBPI.js → chunk-LCK57CQL.js} +48 -43
  3. package/out/chunk-LCK57CQL.js.map +7 -0
  4. package/out/react-native.js +68 -85
  5. package/out/react-native.js.map +2 -2
  6. package/out/react.js +1 -1
  7. package/out/replicache/src/expo/store.d.ts +2 -3
  8. package/out/replicache/src/expo/store.d.ts.map +1 -1
  9. package/out/replicache/src/kv/sqlite-store.d.ts +1 -8
  10. package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
  11. package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
  12. package/out/solid.js +2 -2
  13. package/out/zero/package.json +1 -1
  14. package/out/zero-cache/src/custom/fetch.d.ts +2 -1
  15. package/out/zero-cache/src/custom/fetch.d.ts.map +1 -1
  16. package/out/zero-cache/src/custom/fetch.js +8 -6
  17. package/out/zero-cache/src/custom/fetch.js.map +1 -1
  18. package/out/zero-cache/src/custom-queries/transform-query.d.ts +3 -2
  19. package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +1 -1
  20. package/out/zero-cache/src/custom-queries/transform-query.js +6 -3
  21. package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
  22. package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
  23. package/out/zero-cache/src/db/lite-tables.js +1 -0
  24. package/out/zero-cache/src/db/lite-tables.js.map +1 -1
  25. package/out/zero-cache/src/db/specs.d.ts +5 -0
  26. package/out/zero-cache/src/db/specs.d.ts.map +1 -1
  27. package/out/zero-cache/src/db/specs.js.map +1 -1
  28. package/out/zero-cache/src/services/mutagen/pusher.d.ts +2 -3
  29. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
  30. package/out/zero-cache/src/services/mutagen/pusher.js +25 -6
  31. package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
  32. package/out/zero-cache/src/services/view-syncer/client-schema.d.ts.map +1 -1
  33. package/out/zero-cache/src/services/view-syncer/client-schema.js +10 -1
  34. package/out/zero-cache/src/services/view-syncer/client-schema.js.map +1 -1
  35. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +1 -0
  36. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  37. package/out/zero-cache/src/services/view-syncer/view-syncer.js +20 -3
  38. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  39. package/out/zero-cache/src/workers/syncer-ws-message-handler.js +1 -1
  40. package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
  41. package/out/zero-client/src/client/crud.d.ts +1 -1
  42. package/out/zero-client/src/client/crud.d.ts.map +1 -1
  43. package/out/zero-client/src/client/options.d.ts +8 -26
  44. package/out/zero-client/src/client/options.d.ts.map +1 -1
  45. package/out/zero-client/src/client/zero.d.ts +2 -3
  46. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  47. package/out/zero-protocol/src/client-schema.d.ts +2 -0
  48. package/out/zero-protocol/src/client-schema.d.ts.map +1 -1
  49. package/out/zero-protocol/src/client-schema.js +9 -4
  50. package/out/zero-protocol/src/client-schema.js.map +1 -1
  51. package/out/zero-protocol/src/connect.d.ts +6 -32
  52. package/out/zero-protocol/src/connect.d.ts.map +1 -1
  53. package/out/zero-protocol/src/connect.js +2 -17
  54. package/out/zero-protocol/src/connect.js.map +1 -1
  55. package/out/zero-protocol/src/protocol-version.d.ts +1 -1
  56. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  57. package/out/zero-protocol/src/protocol-version.js +2 -1
  58. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  59. package/out/zero-protocol/src/up.d.ts +3 -8
  60. package/out/zero-protocol/src/up.d.ts.map +1 -1
  61. package/out/zero-schema/src/builder/schema-builder.d.ts +23 -1
  62. package/out/zero-schema/src/builder/schema-builder.d.ts.map +1 -1
  63. package/out/zero-schema/src/builder/schema-builder.js +4 -1
  64. package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
  65. package/out/zero-schema/src/schema-config.d.ts +2 -0
  66. package/out/zero-schema/src/schema-config.d.ts.map +1 -1
  67. package/out/zero-schema/src/schema-config.js +2 -0
  68. package/out/zero-schema/src/schema-config.js.map +1 -1
  69. package/out/zero.js +2 -2
  70. package/package.json +1 -1
  71. package/out/chunk-GW2SIBPI.js.map +0 -7
  72. /package/out/{chunk-KSJKRBQT.js.map → chunk-6QYVZALS.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clientToServer
3
- } from "./chunk-GW2SIBPI.js";
3
+ } from "./chunk-LCK57CQL.js";
4
4
  import {
5
5
  AbstractQuery,
6
6
  ExpressionBuilder,
@@ -346,4 +346,4 @@ export {
346
346
  withValidation,
347
347
  createBuilder
348
348
  };
349
- //# sourceMappingURL=chunk-KSJKRBQT.js.map
349
+ //# sourceMappingURL=chunk-6QYVZALS.js.map
@@ -1415,8 +1415,7 @@ async function dropAllDatabases(opts) {
1415
1415
  const store = new IDBDatabasesStore(kvStoreProvider.create);
1416
1416
  const databases = await store.getDatabases();
1417
1417
  const dbNames = Object.values(databases).map((db) => db.name);
1418
- const result = await dropDatabases(store, dbNames, kvStoreProvider.drop);
1419
- return result;
1418
+ return dropDatabases(store, dbNames, kvStoreProvider.drop);
1420
1419
  }
1421
1420
  function canDatabaseBeCollectedAndGetDeletedClientIDs(enableMutationRecovery, perdag) {
1422
1421
  return withRead(perdag, async (read) => {
@@ -1679,7 +1678,10 @@ var columnSchemaSchema = valita_exports.object({
1679
1678
  type: valueTypeSchema
1680
1679
  });
1681
1680
  var tableSchemaSchema = valita_exports.object({
1682
- columns: valita_exports.record(columnSchemaSchema)
1681
+ columns: valita_exports.record(columnSchemaSchema),
1682
+ // TODO: Make this non-optional when bumping the
1683
+ // MIN_SERVER_SUPPORTED_SYNC_PROTOCOL to 30+.
1684
+ primaryKey: valita_exports.array(valita_exports.string()).optional()
1683
1685
  });
1684
1686
  var clientSchemaSchema = valita_exports.object({
1685
1687
  tables: valita_exports.record(tableSchemaSchema)
@@ -1691,7 +1693,13 @@ function normalizeClientSchema(schema) {
1691
1693
  schema.tables,
1692
1694
  (tables) => tables.sort(keyCmp).map(([name, table2]) => [
1693
1695
  name,
1694
- { columns: mapAllEntries(table2.columns, (e) => e.sort(keyCmp)) }
1696
+ {
1697
+ columns: mapAllEntries(table2.columns, (e) => e.sort(keyCmp)),
1698
+ primaryKey: must(
1699
+ table2.primaryKey,
1700
+ `new clients always specify a primaryKey`
1701
+ ).sort()
1702
+ }
1695
1703
  ])
1696
1704
  )
1697
1705
  };
@@ -1730,7 +1738,9 @@ function createSchema(options) {
1730
1738
  });
1731
1739
  return {
1732
1740
  tables: retTables,
1733
- relationships: retRelationships
1741
+ relationships: retRelationships,
1742
+ enableLegacyQueries: options.enableLegacyQueries,
1743
+ enableLegacyMutators: options.enableLegacyMutators
1734
1744
  };
1735
1745
  }
1736
1746
  function checkRelationship(relationships, tableName, tables) {
@@ -1758,15 +1768,19 @@ function checkRelationship(relationships, tableName, tables) {
1758
1768
  }
1759
1769
  function clientSchemaFrom(schema) {
1760
1770
  const client = {
1761
- tables: mapEntries(schema.tables, (name, { serverName, columns }) => [
1762
- serverName ?? name,
1763
- {
1764
- columns: mapEntries(columns, (name2, { serverName: serverName2, type }) => [
1765
- serverName2 ?? name2,
1766
- { type }
1767
- ])
1768
- }
1769
- ])
1771
+ tables: mapEntries(
1772
+ schema.tables,
1773
+ (name, { serverName, columns, primaryKey }) => [
1774
+ serverName ?? name,
1775
+ {
1776
+ columns: mapEntries(columns, (name2, { serverName: serverName2, type }) => [
1777
+ serverName2 ?? name2,
1778
+ { type }
1779
+ ]),
1780
+ primaryKey: [...primaryKey]
1781
+ }
1782
+ ]
1783
+ )
1770
1784
  };
1771
1785
  const clientSchema = normalizeClientSchema(client);
1772
1786
  const hash = h64(JSON.stringify(clientSchema)).toString(36);
@@ -5968,29 +5982,14 @@ var connectedMessageSchema = valita_exports.tuple([
5968
5982
  valita_exports.literal("connected"),
5969
5983
  connectedBodySchema
5970
5984
  ]);
5971
- var userQueryMutateParamsSchema = valita_exports.object({
5972
- /**
5973
- * A client driven URL to send queries or mutations to.
5974
- * This URL must match one of the URLs set in the zero config.
5975
- *
5976
- * E.g., Given the following environment variable:
5977
- * ZERO_GET_QUERIES_URL=[https://*.example.com/query]
5978
- *
5979
- * Then this URL could be:
5980
- * https://myapp.example.com/query
5981
- */
5982
- url: valita_exports.string().optional(),
5983
- // The query string to use for query or mutation calls.
5984
- queryParams: valita_exports.record(valita_exports.string()).optional()
5985
- });
5986
5985
  var initConnectionBodySchema = valita_exports.object({
5987
5986
  desiredQueriesPatch: upQueriesPatchSchema,
5988
5987
  clientSchema: clientSchemaSchema.optional(),
5989
5988
  deleted: deleteClientsBodySchema.optional(),
5990
5989
  // parameters to configure the mutate endpoint
5991
- userPushParams: userQueryMutateParamsSchema.optional(),
5990
+ userPushURL: valita_exports.string().optional(),
5992
5991
  // parameters to configure the query endpoint
5993
- userQueryParams: userQueryMutateParamsSchema.optional(),
5992
+ userQueryURL: valita_exports.string().optional(),
5994
5993
  /**
5995
5994
  * `activeClients` is an optional array of client IDs that are currently active
5996
5995
  * in the client group. This is used to inform the server about the clients
@@ -6362,7 +6361,7 @@ var downstreamSchema = valita_exports.union(
6362
6361
  );
6363
6362
 
6364
6363
  // ../zero-protocol/src/protocol-version.ts
6365
- var PROTOCOL_VERSION = 29;
6364
+ var PROTOCOL_VERSION = 30;
6366
6365
  var MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 18;
6367
6366
  assert(MIN_SERVER_SUPPORTED_SYNC_PROTOCOL < PROTOCOL_VERSION);
6368
6367
 
@@ -8666,7 +8665,7 @@ function makeMessage(message, context, logLevel) {
8666
8665
  }
8667
8666
 
8668
8667
  // ../zero-client/src/client/version.ts
8669
- var version2 = "0.23.2025083000";
8668
+ var version2 = "0.23.2025090400";
8670
8669
 
8671
8670
  // ../zero-client/src/client/log-options.ts
8672
8671
  var LevelFilterLogSink = class {
@@ -10289,7 +10288,7 @@ var Zero = class _Zero {
10289
10288
  enableAnalytics: this.#enableAnalytics
10290
10289
  });
10291
10290
  const logOptions = this.#logOptions;
10292
- const { enableLegacyMutators = true, enableLegacyQueries = true } = options;
10291
+ const { enableLegacyMutators = true, enableLegacyQueries = true } = schema;
10293
10292
  const replicacheMutators = {
10294
10293
  [CRUD_MUTATION_NAME]: enableLegacyMutators ? makeCRUDMutator(schema) : () => Promise.reject(new Error("Zero CRUD mutators are not enabled."))
10295
10294
  };
@@ -10357,6 +10356,12 @@ var Zero = class _Zero {
10357
10356
  this.#schema = schema;
10358
10357
  const { clientSchema, hash } = clientSchemaFrom(schema);
10359
10358
  this.#clientSchema = clientSchema;
10359
+ const nameKey = JSON.stringify({
10360
+ storageKey: this.storageKey,
10361
+ mutateUrl: options.mutateURL ?? "",
10362
+ queryUrl: options.getQueriesURL ?? ""
10363
+ });
10364
+ const hashedKey = h64(nameKey).toString(36);
10360
10365
  const replicacheOptions = {
10361
10366
  // The schema stored in IDB is dependent upon both the ClientSchema
10362
10367
  // and the AST schema (i.e. PROTOCOL_VERSION).
@@ -10364,7 +10369,7 @@ var Zero = class _Zero {
10364
10369
  logLevel: logOptions.logLevel,
10365
10370
  logSinks: [logOptions.logSink],
10366
10371
  mutators: replicacheMutators,
10367
- name: `zero-${userID}-${this.storageKey}`,
10372
+ name: `zero-${userID}-${hashedKey}`,
10368
10373
  pusher: (req, reqID) => this.#pusher(req, reqID),
10369
10374
  puller: (req, reqID) => this.#puller(req, reqID),
10370
10375
  pushDelay: 0,
@@ -10881,8 +10886,8 @@ var Zero = class _Zero {
10881
10886
  // The clientSchema only needs to be sent for the very first request.
10882
10887
  // Henceforth it is stored with the CVR and verified automatically.
10883
10888
  ...this.#connectCookie === null ? { clientSchema } : {},
10884
- userPushParams: this.#options.mutate ?? this.#options.push,
10885
- userQueryParams: this.#options.query
10889
+ userPushURL: this.#options.mutateURL,
10890
+ userQueryURL: this.#options.getQueriesURL
10886
10891
  }
10887
10892
  ]);
10888
10893
  this.#deletedClients = void 0;
@@ -10958,8 +10963,8 @@ var Zero = class _Zero {
10958
10963
  wsid,
10959
10964
  this.#options.logLevel === "debug",
10960
10965
  lc,
10961
- this.#options.mutate ?? this.#options.push,
10962
- this.#options.query,
10966
+ this.#options.mutateURL,
10967
+ this.#options.getQueriesURL,
10963
10968
  this.#options.maxHeaderLength,
10964
10969
  additionalConnectParams,
10965
10970
  await this.#activeClientsManager
@@ -11474,7 +11479,7 @@ var OnlineManager = class extends Subscribable {
11474
11479
  return this.#online;
11475
11480
  }
11476
11481
  };
11477
- async function createSocket(rep, queryManager, deleteClientsManager, socketOrigin, baseCookie, clientID, clientGroupID, clientSchema, userID, auth, lmid, wsid, debugPerf, lc, userPushParams, userQueryParams, maxHeaderLength = 1024 * 8, additionalConnectParams, activeClientsManager) {
11482
+ async function createSocket(rep, queryManager, deleteClientsManager, socketOrigin, baseCookie, clientID, clientGroupID, clientSchema, userID, auth, lmid, wsid, debugPerf, lc, userPushURL, userQueryURL, maxHeaderLength = 1024 * 8, additionalConnectParams, activeClientsManager) {
11478
11483
  const url = new URL(
11479
11484
  appendPath(socketOrigin, `/sync/v${PROTOCOL_VERSION}/connect`)
11480
11485
  );
@@ -11513,8 +11518,8 @@ async function createSocket(rep, queryManager, deleteClientsManager, socketOrigi
11513
11518
  // The clientSchema only needs to be sent for the very first request.
11514
11519
  // Henceforth it is stored with the CVR and verified automatically.
11515
11520
  ...baseCookie === null ? { clientSchema } : {},
11516
- userPushParams,
11517
- userQueryParams,
11521
+ userPushURL,
11522
+ userQueryURL,
11518
11523
  activeClients: [...activeClients]
11519
11524
  }
11520
11525
  ],
@@ -11607,4 +11612,4 @@ export {
11607
11612
  update_needed_reason_type_enum_exports,
11608
11613
  Zero
11609
11614
  };
11610
- //# sourceMappingURL=chunk-GW2SIBPI.js.map
11615
+ //# sourceMappingURL=chunk-LCK57CQL.js.map