@rocicorp/zero 0.21.2025052100 → 0.21.2025052102

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.
@@ -13,7 +13,7 @@ import {
13
13
  readonlyObject,
14
14
  readonlyRecord,
15
15
  valita_exports
16
- } from "./chunk-L22FDJBI.js";
16
+ } from "./chunk-Y5SC5VIM.js";
17
17
  import {
18
18
  assert,
19
19
  assertArray,
@@ -2889,4 +2889,4 @@ export {
2889
2889
  toPrimaryKeyString,
2890
2890
  sourceNameFromKey
2891
2891
  };
2892
- //# sourceMappingURL=chunk-7QSGQEHF.js.map
2892
+ //# sourceMappingURL=chunk-67DEDR65.js.map
@@ -87,7 +87,7 @@ import {
87
87
  withWrite,
88
88
  withWriteNoImplicitCommit,
89
89
  wrapIterable
90
- } from "./chunk-7QSGQEHF.js";
90
+ } from "./chunk-67DEDR65.js";
91
91
  import {
92
92
  AbstractQuery,
93
93
  ExpressionBuilder,
@@ -122,7 +122,7 @@ import {
122
122
  toStaticParam,
123
123
  transformFilters,
124
124
  valita_exports
125
- } from "./chunk-L22FDJBI.js";
125
+ } from "./chunk-Y5SC5VIM.js";
126
126
  import {
127
127
  __export,
128
128
  assert,
@@ -8532,7 +8532,7 @@ function makeMessage(message, context, logLevel) {
8532
8532
  }
8533
8533
 
8534
8534
  // ../zero-client/src/client/version.ts
8535
- var version2 = "0.21.2025052100";
8535
+ var version2 = "0.21.2025052102";
8536
8536
 
8537
8537
  // ../zero-client/src/client/log-options.ts
8538
8538
  var LevelFilterLogSink = class {
@@ -11013,7 +11013,7 @@ var Zero = class {
11013
11013
  */
11014
11014
  async inspect() {
11015
11015
  BUNDLE_SIZE: {
11016
- const m = await import("./inspector-OEIX26PB.js");
11016
+ const m = await import("./inspector-WZW6W4FJ.js");
11017
11017
  return m.newInspector(this.#rep, this.#schema, async () => {
11018
11018
  await this.#connectResolver.promise;
11019
11019
  return this.#socket;
@@ -11140,4 +11140,4 @@ export {
11140
11140
  update_needed_reason_type_enum_exports,
11141
11141
  Zero
11142
11142
  };
11143
- //# sourceMappingURL=chunk-VYZSMCAK.js.map
11143
+ //# sourceMappingURL=chunk-6TLQFN3B.js.map
@@ -3095,6 +3095,14 @@ function assertNoNotExists(condition) {
3095
3095
  }
3096
3096
  }
3097
3097
 
3098
+ // ../zql/src/error.ts
3099
+ var NotImplementedError = class extends Error {
3100
+ constructor(message) {
3101
+ super(message);
3102
+ this.name = "NotImplementedError";
3103
+ }
3104
+ };
3105
+
3098
3106
  // ../zql/src/query/query-impl.ts
3099
3107
  var astSymbol = Symbol();
3100
3108
  function newQuery(delegate, schema, table) {
@@ -3118,12 +3126,14 @@ var AbstractQuery = class {
3118
3126
  format;
3119
3127
  #hash = "";
3120
3128
  #system;
3121
- constructor(schema, tableName, ast, format, system) {
3129
+ #currentJunction;
3130
+ constructor(schema, tableName, ast, format, system, currentJunction) {
3122
3131
  this.#schema = schema;
3123
3132
  this.#tableName = tableName;
3124
3133
  this.#ast = ast;
3125
3134
  this.format = format;
3126
3135
  this.#system = system;
3136
+ this.#currentJunction = currentJunction;
3127
3137
  }
3128
3138
  get [astSymbol]() {
3129
3139
  return this.#ast;
@@ -3144,7 +3154,8 @@ var AbstractQuery = class {
3144
3154
  {
3145
3155
  ...this.format,
3146
3156
  singular: true
3147
- }
3157
+ },
3158
+ this.#currentJunction
3148
3159
  );
3149
3160
  whereExists = (relationship, cb) => this.where(({ exists }) => exists(relationship, cb));
3150
3161
  related = (relationship, cb) => {
@@ -3168,7 +3179,8 @@ var AbstractQuery = class {
3168
3179
  {
3169
3180
  relationships: {},
3170
3181
  singular: cardinality === "one"
3171
- }
3182
+ },
3183
+ void 0
3172
3184
  );
3173
3185
  if (cardinality === "one") {
3174
3186
  q = q.one();
@@ -3212,7 +3224,8 @@ var AbstractQuery = class {
3212
3224
  ...this.format.relationships,
3213
3225
  [relationship]: sq.format
3214
3226
  }
3215
- }
3227
+ },
3228
+ this.#currentJunction
3216
3229
  );
3217
3230
  }
3218
3231
  if (isTwoHop(related)) {
@@ -3230,7 +3243,8 @@ var AbstractQuery = class {
3230
3243
  {
3231
3244
  relationships: {},
3232
3245
  singular: secondRelation.cardinality === "one"
3233
- }
3246
+ },
3247
+ relationship
3234
3248
  )
3235
3249
  );
3236
3250
  assert(isCompoundKey(firstRelation.sourceField), "Invalid relationship");
@@ -3281,7 +3295,8 @@ var AbstractQuery = class {
3281
3295
  ...this.format.relationships,
3282
3296
  [relationship]: sq.format
3283
3297
  }
3284
- }
3298
+ },
3299
+ this.#currentJunction
3285
3300
  );
3286
3301
  }
3287
3302
  throw new Error(`Invalid relationship ${relationship}`);
@@ -3311,7 +3326,8 @@ var AbstractQuery = class {
3311
3326
  ...this.#ast,
3312
3327
  where
3313
3328
  },
3314
- this.format
3329
+ this.format,
3330
+ this.#currentJunction
3315
3331
  );
3316
3332
  };
3317
3333
  start = (row, opts) => this[newQuerySymbol](
@@ -3324,7 +3340,8 @@ var AbstractQuery = class {
3324
3340
  exclusive: !opts?.inclusive
3325
3341
  }
3326
3342
  },
3327
- this.format
3343
+ this.format,
3344
+ this.#currentJunction
3328
3345
  );
3329
3346
  limit = (limit) => {
3330
3347
  if (limit < 0) {
@@ -3333,6 +3350,11 @@ var AbstractQuery = class {
3333
3350
  if ((limit | 0) !== limit) {
3334
3351
  throw new Error("Limit must be an integer");
3335
3352
  }
3353
+ if (this.#currentJunction) {
3354
+ throw new NotImplementedError(
3355
+ "Limit is not supported in junction relationships yet. Junction relationship being limited: " + this.#currentJunction
3356
+ );
3357
+ }
3336
3358
  return this[newQuerySymbol](
3337
3359
  this.#schema,
3338
3360
  this.#tableName,
@@ -3340,18 +3362,27 @@ var AbstractQuery = class {
3340
3362
  ...this.#ast,
3341
3363
  limit
3342
3364
  },
3343
- this.format
3365
+ this.format,
3366
+ this.#currentJunction
3367
+ );
3368
+ };
3369
+ orderBy = (field, direction) => {
3370
+ if (this.#currentJunction) {
3371
+ throw new NotImplementedError(
3372
+ "Order by is not supported in junction relationships yet. Junction relationship being ordered: " + this.#currentJunction
3373
+ );
3374
+ }
3375
+ return this[newQuerySymbol](
3376
+ this.#schema,
3377
+ this.#tableName,
3378
+ {
3379
+ ...this.#ast,
3380
+ orderBy: [...this.#ast.orderBy ?? [], [field, direction]]
3381
+ },
3382
+ this.format,
3383
+ this.#currentJunction
3344
3384
  );
3345
3385
  };
3346
- orderBy = (field, direction) => this[newQuerySymbol](
3347
- this.#schema,
3348
- this.#tableName,
3349
- {
3350
- ...this.#ast,
3351
- orderBy: [...this.#ast.orderBy ?? [], [field, direction]]
3352
- },
3353
- this.format
3354
- );
3355
3386
  _exists = (relationship, cb = (q) => q) => {
3356
3387
  const related = this.#schema.relationships[this.#tableName][relationship];
3357
3388
  assert(related, "Invalid relationship");
@@ -3367,7 +3398,8 @@ var AbstractQuery = class {
3367
3398
  table: destSchema,
3368
3399
  alias: `${SUBQ_PREFIX}${relationship}`
3369
3400
  },
3370
- defaultFormat
3401
+ defaultFormat,
3402
+ void 0
3371
3403
  )
3372
3404
  );
3373
3405
  return {
@@ -3402,7 +3434,8 @@ var AbstractQuery = class {
3402
3434
  table: destSchema,
3403
3435
  alias: `${SUBQ_PREFIX}${relationship}`
3404
3436
  },
3405
- defaultFormat
3437
+ defaultFormat,
3438
+ relationship
3406
3439
  )
3407
3440
  );
3408
3441
  return {
@@ -3483,22 +3516,23 @@ var completedAstSymbol = Symbol();
3483
3516
  var QueryImpl = class _QueryImpl extends AbstractQuery {
3484
3517
  #delegate;
3485
3518
  #system;
3486
- constructor(delegate, schema, tableName, ast, format, system = "client") {
3487
- super(schema, tableName, ast, format, system);
3519
+ constructor(delegate, schema, tableName, ast, format, system = "client", currentJunction) {
3520
+ super(schema, tableName, ast, format, system, currentJunction);
3488
3521
  this.#system = system;
3489
3522
  this.#delegate = delegate;
3490
3523
  }
3491
3524
  get [completedAstSymbol]() {
3492
3525
  return this._completeAst();
3493
3526
  }
3494
- [newQuerySymbol](schema, tableName, ast, format) {
3527
+ [newQuerySymbol](schema, tableName, ast, format, currentJunction) {
3495
3528
  return new _QueryImpl(
3496
3529
  this.#delegate,
3497
3530
  schema,
3498
3531
  tableName,
3499
3532
  ast,
3500
3533
  format,
3501
- this.#system
3534
+ this.#system,
3535
+ currentJunction
3502
3536
  );
3503
3537
  }
3504
3538
  materialize(factoryOrTTL, ttl = DEFAULT_TTL) {
@@ -3661,4 +3695,4 @@ export {
3661
3695
  newQuerySymbol,
3662
3696
  AbstractQuery
3663
3697
  };
3664
- //# sourceMappingURL=chunk-L22FDJBI.js.map
3698
+ //# sourceMappingURL=chunk-Y5SC5VIM.js.map