@rocicorp/zero 0.0.202410040919 → 0.0.202410041744

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.
@@ -14,7 +14,7 @@ export declare class ZeroContext implements QueryDelegate {
14
14
  #private;
15
15
  readonly staticQueryParameters: undefined;
16
16
  constructor(tables: Record<string, TableSchema>, addQuery: AddQuery);
17
- getSource(name: string): Source;
17
+ getSource(name: string): Source | undefined;
18
18
  addServerQuery(ast: AST): () => void;
19
19
  createStorage(): Storage;
20
20
  onTransactionCommit(cb: CommitListener): () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,wBAAwB,CAAC;AAIhD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAG7D,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,IAAI,CAAC;AAEhD;;;;GAIG;AACH,qBAAa,WAAY,YAAW,aAAa;;IAU/C,QAAQ,CAAC,qBAAqB,YAAa;gBAE/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ;IAKnE,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAc/B,cAAc,CAAC,GAAG,EAAE,GAAG,SAtCkB,IAAI;IA0C7C,aAAa,IAAI,OAAO;IAIxB,mBAAmB,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,IAAI;IAOnD,cAAc,CAAC,OAAO,EAAE,uBAAuB;CAmDhD"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,wBAAwB,CAAC;AAIhD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAG7D,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,IAAI,CAAC;AAEhD;;;;GAIG;AACH,qBAAa,WAAY,YAAW,aAAa;;IAU/C,QAAQ,CAAC,qBAAqB,YAAa;gBAE/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,QAAQ;IAKnE,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAa3C,cAAc,CAAC,GAAG,EAAE,GAAG,SArCkB,IAAI;IAyC7C,aAAa,IAAI,OAAO;IAIxB,mBAAmB,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,IAAI;IAOnD,cAAc,CAAC,OAAO,EAAE,uBAAuB;CAsDhD"}
package/out/zero.js CHANGED
@@ -10293,6 +10293,9 @@ function isParameter(value) {
10293
10293
  }
10294
10294
  function buildPipelineInternal(ast, delegate, staticQueryParameters, partitionKey) {
10295
10295
  const source = delegate.getSource(ast.table);
10296
+ if (!source) {
10297
+ throw new Error(`Source not found: ${ast.table}`);
10298
+ }
10296
10299
  const conn = source.connect(must(ast.orderBy), ast.where ?? []);
10297
10300
  let end = conn;
10298
10301
  const { appliedFilters } = conn;
@@ -13445,15 +13448,11 @@ var ZeroContext = class {
13445
13448
  this.#addQuery = addQuery;
13446
13449
  }
13447
13450
  getSource(name) {
13448
- let source = this.#sources.get(name);
13449
- if (source !== void 0) {
13450
- return source;
13451
+ if (this.#sources.has(name)) {
13452
+ return this.#sources.get(name);
13451
13453
  }
13452
13454
  const schema = this.#tables[name];
13453
- if (!schema) {
13454
- throw new Error(`No schema found for table ${name}`);
13455
- }
13456
- source = new MemorySource(name, schema.columns, schema.primaryKey);
13455
+ const source = schema ? new MemorySource(name, schema.columns, schema.primaryKey) : void 0;
13457
13456
  this.#sources.set(name, source);
13458
13457
  return source;
13459
13458
  }
@@ -13477,6 +13476,9 @@ var ZeroContext = class {
13477
13476
  const slash = key.indexOf("/", ENTITIES_KEY_PREFIX.length);
13478
13477
  const name = key.slice(ENTITIES_KEY_PREFIX.length, slash);
13479
13478
  const source = this.getSource(name);
13479
+ if (!source) {
13480
+ continue;
13481
+ }
13480
13482
  switch (diff2.op) {
13481
13483
  case "del":
13482
13484
  assert(typeof diff2.oldValue === "object");