@rocicorp/zero 0.14.2025021001 → 0.14.2025021100

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 (49) hide show
  1. package/out/{chunk-MVLDKRBK.js → chunk-OPWNICE2.js} +177 -195
  2. package/out/{chunk-MVLDKRBK.js.map → chunk-OPWNICE2.js.map} +4 -4
  3. package/out/solid.js +1 -1
  4. package/out/zero/src/deploy-permissions.d.ts +3 -0
  5. package/out/zero/src/deploy-permissions.d.ts.map +1 -0
  6. package/out/zero/src/deploy-permissions.js +3 -0
  7. package/out/zero/src/deploy-permissions.js.map +1 -0
  8. package/out/zero-cache/src/auth/load-schema.d.ts +1 -1
  9. package/out/zero-cache/src/auth/load-schema.d.ts.map +1 -1
  10. package/out/zero-cache/src/auth/load-schema.js.map +1 -1
  11. package/out/zero-cache/src/auth/read-authorizer.js +1 -1
  12. package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
  13. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
  14. package/out/zero-cache/src/auth/write-authorizer.js +6 -2
  15. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  16. package/out/zero-cache/src/config/zero-config.d.ts +0 -205
  17. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  18. package/out/zero-cache/src/config/zero-config.js +0 -22
  19. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  20. package/out/zero-cache/src/scripts/deploy-permissions.d.ts +2 -0
  21. package/out/zero-cache/src/scripts/deploy-permissions.d.ts.map +1 -0
  22. package/out/zero-cache/src/scripts/deploy-permissions.js +122 -0
  23. package/out/zero-cache/src/scripts/deploy-permissions.js.map +1 -0
  24. package/out/zero-cache/src/services/change-source/custom/change-source.js +4 -0
  25. package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
  26. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
  27. package/out/zero-cache/src/services/change-source/pg/schema/init.js +3 -1
  28. package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
  29. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +2 -1
  30. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
  31. package/out/zero-cache/src/services/change-source/pg/schema/shard.js +16 -0
  32. package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
  33. package/out/zero-cache/src/types/pg.d.ts.map +1 -1
  34. package/out/zero-cache/src/types/pg.js +6 -2
  35. package/out/zero-cache/src/types/pg.js.map +1 -1
  36. package/out/zero-cache/src/workers/connection.js +2 -2
  37. package/out/zero-cache/src/workers/connection.js.map +1 -1
  38. package/out/zero-client/src/client/crud.d.ts.map +1 -1
  39. package/out/zero-protocol/src/protocol-version.d.ts +10 -2
  40. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  41. package/out/zero-protocol/src/protocol-version.js +12 -3
  42. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  43. package/out/zero-schema/src/compiled-permissions.d.ts +23 -19
  44. package/out/zero-schema/src/compiled-permissions.d.ts.map +1 -1
  45. package/out/zero-schema/src/compiled-permissions.js +7 -4
  46. package/out/zero-schema/src/compiled-permissions.js.map +1 -1
  47. package/out/zero-schema/src/permissions.d.ts.map +1 -1
  48. package/out/zero.js +1 -1
  49. package/package.json +4 -3
@@ -8937,157 +8937,12 @@ function compareUTF8MaybeNull(a, b) {
8937
8937
  return 0;
8938
8938
  }
8939
8939
 
8940
- // ../zql/src/query/expression.ts
8941
- var ExpressionBuilder = class {
8942
- #exists;
8943
- constructor(exists) {
8944
- this.#exists = exists;
8945
- this.exists = this.exists.bind(this);
8946
- }
8947
- get eb() {
8948
- return this;
8949
- }
8950
- cmp(field, opOrValue, value) {
8951
- return cmp(field, opOrValue, value);
8952
- }
8953
- cmpLit(left, op, right) {
8954
- return {
8955
- type: "simple",
8956
- left: isParameterReference(left) ? left[toStaticParam]() : { type: "literal", value: left },
8957
- right: isParameterReference(right) ? right[toStaticParam]() : { type: "literal", value: right },
8958
- op
8959
- };
8960
- }
8961
- and = and;
8962
- or = or;
8963
- not = not;
8964
- exists(relationship, cb) {
8965
- return this.#exists(relationship, cb);
8966
- }
8967
- };
8968
- function and(...conditions) {
8969
- const expressions = filterTrue(filterUndefined(conditions));
8970
- if (expressions.length === 1) {
8971
- return expressions[0];
8972
- }
8973
- if (expressions.some(isAlwaysFalse)) {
8974
- return FALSE;
8975
- }
8976
- return { type: "and", conditions: expressions };
8977
- }
8978
- function or(...conditions) {
8979
- const expressions = filterFalse(filterUndefined(conditions));
8980
- if (expressions.length === 1) {
8981
- return expressions[0];
8982
- }
8983
- if (expressions.some(isAlwaysTrue)) {
8984
- return TRUE;
8985
- }
8986
- return { type: "or", conditions: expressions };
8987
- }
8988
- function not(expression) {
8989
- switch (expression.type) {
8990
- case "and":
8991
- return {
8992
- type: "or",
8993
- conditions: expression.conditions.map(not)
8994
- };
8995
- case "or":
8996
- return {
8997
- type: "and",
8998
- conditions: expression.conditions.map(not)
8999
- };
9000
- case "correlatedSubquery":
9001
- return {
9002
- type: "correlatedSubquery",
9003
- related: expression.related,
9004
- op: negateOperator(expression.op)
9005
- };
9006
- case "simple":
9007
- return {
9008
- type: "simple",
9009
- op: negateOperator(expression.op),
9010
- left: expression.left,
9011
- right: expression.right
9012
- };
9013
- }
9014
- }
9015
- function cmp(field, opOrValue, value) {
9016
- let op;
9017
- if (value === void 0) {
9018
- value = opOrValue;
9019
- op = "=";
9020
- } else {
9021
- op = opOrValue;
9022
- }
9023
- return {
9024
- type: "simple",
9025
- left: { type: "column", name: field },
9026
- right: isParameterReference(value) ? value[toStaticParam]() : { type: "literal", value },
9027
- op
9028
- };
9029
- }
9030
- function isParameterReference(value) {
9031
- return value !== null && typeof value === "object" && value[toStaticParam];
9032
- }
9033
- var TRUE = {
9034
- type: "and",
9035
- conditions: []
9036
- };
9037
- var FALSE = {
9038
- type: "or",
9039
- conditions: []
9040
- };
9041
- function isAlwaysTrue(condition) {
9042
- return condition.type === "and" && condition.conditions.length === 0;
9043
- }
9044
- function isAlwaysFalse(condition) {
9045
- return condition.type === "or" && condition.conditions.length === 0;
9046
- }
9047
- function flatten(type, conditions) {
9048
- const flattened2 = [];
9049
- for (const c of conditions) {
9050
- if (c.type === type) {
9051
- flattened2.push(...c.conditions);
9052
- } else {
9053
- flattened2.push(c);
9054
- }
9055
- }
9056
- return flattened2;
9057
- }
9058
- var negateSimpleOperatorMap = {
9059
- ["="]: "!=",
9060
- ["!="]: "=",
9061
- ["<"]: ">=",
9062
- [">"]: "<=",
9063
- [">="]: "<",
9064
- ["<="]: ">",
9065
- ["IN"]: "NOT IN",
9066
- ["NOT IN"]: "IN",
9067
- ["LIKE"]: "NOT LIKE",
9068
- ["NOT LIKE"]: "LIKE",
9069
- ["ILIKE"]: "NOT ILIKE",
9070
- ["NOT ILIKE"]: "ILIKE",
9071
- ["IS"]: "IS NOT",
9072
- ["IS NOT"]: "IS"
9073
- };
9074
- var negateOperatorMap = {
9075
- ...negateSimpleOperatorMap,
9076
- ["EXISTS"]: "NOT EXISTS",
9077
- ["NOT EXISTS"]: "EXISTS"
9078
- };
9079
- function negateOperator(op) {
9080
- return must(negateOperatorMap[op]);
9081
- }
9082
- function filterUndefined(array12) {
9083
- return array12.filter((e) => e !== void 0);
9084
- }
9085
- function filterTrue(conditions) {
9086
- return conditions.filter((c) => !isAlwaysTrue(c));
9087
- }
9088
- function filterFalse(conditions) {
9089
- return conditions.filter((c) => !isAlwaysFalse(c));
9090
- }
8940
+ // ../zero-protocol/src/protocol-version.ts
8941
+ var PROTOCOL_VERSION = 5;
8942
+ var MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 2;
8943
+ assert(MIN_SERVER_SUPPORTED_SYNC_PROTOCOL < PROTOCOL_VERSION);
8944
+ var MIN_SERVER_SUPPORTED_PERMISSIONS_PROTOCOL = 4;
8945
+ assert(MIN_SERVER_SUPPORTED_PERMISSIONS_PROTOCOL < PROTOCOL_VERSION);
9091
8946
 
9092
8947
  // ../zql/src/query/query-impl.ts
9093
8948
  import { resolver as resolver7 } from "@rocicorp/resolver";
@@ -10538,11 +10393,11 @@ function createPredicateImpl(rhs, operator) {
10538
10393
  case "LIKE":
10539
10394
  return getLikePredicate(rhs, "");
10540
10395
  case "NOT LIKE":
10541
- return not2(getLikePredicate(rhs, ""));
10396
+ return not(getLikePredicate(rhs, ""));
10542
10397
  case "ILIKE":
10543
10398
  return getLikePredicate(rhs, "i");
10544
10399
  case "NOT ILIKE":
10545
- return not2(getLikePredicate(rhs, "i"));
10400
+ return not(getLikePredicate(rhs, "i"));
10546
10401
  case "IN": {
10547
10402
  assert(Array.isArray(rhs));
10548
10403
  const set = new Set(rhs);
@@ -10558,7 +10413,7 @@ function createPredicateImpl(rhs, operator) {
10558
10413
  throw new Error(`Unexpected operator: ${operator}`);
10559
10414
  }
10560
10415
  }
10561
- function not2(f) {
10416
+ function not(f) {
10562
10417
  return (lhs) => !f(lhs);
10563
10418
  }
10564
10419
  function transformFilters(filters) {
@@ -10929,6 +10784,158 @@ var ArrayView = class {
10929
10784
  }
10930
10785
  };
10931
10786
 
10787
+ // ../zql/src/query/expression.ts
10788
+ var ExpressionBuilder = class {
10789
+ #exists;
10790
+ constructor(exists) {
10791
+ this.#exists = exists;
10792
+ this.exists = this.exists.bind(this);
10793
+ }
10794
+ get eb() {
10795
+ return this;
10796
+ }
10797
+ cmp(field, opOrValue, value) {
10798
+ return cmp(field, opOrValue, value);
10799
+ }
10800
+ cmpLit(left, op, right) {
10801
+ return {
10802
+ type: "simple",
10803
+ left: isParameterReference(left) ? left[toStaticParam]() : { type: "literal", value: left },
10804
+ right: isParameterReference(right) ? right[toStaticParam]() : { type: "literal", value: right },
10805
+ op
10806
+ };
10807
+ }
10808
+ and = and;
10809
+ or = or;
10810
+ not = not2;
10811
+ exists(relationship, cb) {
10812
+ return this.#exists(relationship, cb);
10813
+ }
10814
+ };
10815
+ function and(...conditions) {
10816
+ const expressions = filterTrue(filterUndefined(conditions));
10817
+ if (expressions.length === 1) {
10818
+ return expressions[0];
10819
+ }
10820
+ if (expressions.some(isAlwaysFalse)) {
10821
+ return FALSE;
10822
+ }
10823
+ return { type: "and", conditions: expressions };
10824
+ }
10825
+ function or(...conditions) {
10826
+ const expressions = filterFalse(filterUndefined(conditions));
10827
+ if (expressions.length === 1) {
10828
+ return expressions[0];
10829
+ }
10830
+ if (expressions.some(isAlwaysTrue)) {
10831
+ return TRUE;
10832
+ }
10833
+ return { type: "or", conditions: expressions };
10834
+ }
10835
+ function not2(expression) {
10836
+ switch (expression.type) {
10837
+ case "and":
10838
+ return {
10839
+ type: "or",
10840
+ conditions: expression.conditions.map(not2)
10841
+ };
10842
+ case "or":
10843
+ return {
10844
+ type: "and",
10845
+ conditions: expression.conditions.map(not2)
10846
+ };
10847
+ case "correlatedSubquery":
10848
+ return {
10849
+ type: "correlatedSubquery",
10850
+ related: expression.related,
10851
+ op: negateOperator(expression.op)
10852
+ };
10853
+ case "simple":
10854
+ return {
10855
+ type: "simple",
10856
+ op: negateOperator(expression.op),
10857
+ left: expression.left,
10858
+ right: expression.right
10859
+ };
10860
+ }
10861
+ }
10862
+ function cmp(field, opOrValue, value) {
10863
+ let op;
10864
+ if (value === void 0) {
10865
+ value = opOrValue;
10866
+ op = "=";
10867
+ } else {
10868
+ op = opOrValue;
10869
+ }
10870
+ return {
10871
+ type: "simple",
10872
+ left: { type: "column", name: field },
10873
+ right: isParameterReference(value) ? value[toStaticParam]() : { type: "literal", value },
10874
+ op
10875
+ };
10876
+ }
10877
+ function isParameterReference(value) {
10878
+ return value !== null && typeof value === "object" && value[toStaticParam];
10879
+ }
10880
+ var TRUE = {
10881
+ type: "and",
10882
+ conditions: []
10883
+ };
10884
+ var FALSE = {
10885
+ type: "or",
10886
+ conditions: []
10887
+ };
10888
+ function isAlwaysTrue(condition) {
10889
+ return condition.type === "and" && condition.conditions.length === 0;
10890
+ }
10891
+ function isAlwaysFalse(condition) {
10892
+ return condition.type === "or" && condition.conditions.length === 0;
10893
+ }
10894
+ function flatten(type, conditions) {
10895
+ const flattened2 = [];
10896
+ for (const c of conditions) {
10897
+ if (c.type === type) {
10898
+ flattened2.push(...c.conditions);
10899
+ } else {
10900
+ flattened2.push(c);
10901
+ }
10902
+ }
10903
+ return flattened2;
10904
+ }
10905
+ var negateSimpleOperatorMap = {
10906
+ ["="]: "!=",
10907
+ ["!="]: "=",
10908
+ ["<"]: ">=",
10909
+ [">"]: "<=",
10910
+ [">="]: "<",
10911
+ ["<="]: ">",
10912
+ ["IN"]: "NOT IN",
10913
+ ["NOT IN"]: "IN",
10914
+ ["LIKE"]: "NOT LIKE",
10915
+ ["NOT LIKE"]: "LIKE",
10916
+ ["ILIKE"]: "NOT ILIKE",
10917
+ ["NOT ILIKE"]: "ILIKE",
10918
+ ["IS"]: "IS NOT",
10919
+ ["IS NOT"]: "IS"
10920
+ };
10921
+ var negateOperatorMap = {
10922
+ ...negateSimpleOperatorMap,
10923
+ ["EXISTS"]: "NOT EXISTS",
10924
+ ["NOT EXISTS"]: "EXISTS"
10925
+ };
10926
+ function negateOperator(op) {
10927
+ return must(negateOperatorMap[op]);
10928
+ }
10929
+ function filterUndefined(array12) {
10930
+ return array12.filter((e) => e !== void 0);
10931
+ }
10932
+ function filterTrue(conditions) {
10933
+ return conditions.filter((c) => !isAlwaysTrue(c));
10934
+ }
10935
+ function filterFalse(conditions) {
10936
+ return conditions.filter((c) => !isAlwaysFalse(c));
10937
+ }
10938
+
10932
10939
  // ../zql/src/query/dnf.ts
10933
10940
  function dnf(condition) {
10934
10941
  return unwrap(dnfInner(condition));
@@ -11596,10 +11603,13 @@ function compilePermissions(schema, authz, expressionBuilders) {
11596
11603
  return void 0;
11597
11604
  }
11598
11605
  const nameMapper = clientToServer(schema.tables);
11599
- const ret = {};
11606
+ const ret = {
11607
+ protocolVersion: PROTOCOL_VERSION,
11608
+ tables: {}
11609
+ };
11600
11610
  for (const [tableName, tableConfig] of Object.entries(authz)) {
11601
11611
  const serverName = schema.tables[tableName].serverName ?? tableName;
11602
- ret[serverName] = {
11612
+ ret.tables[serverName] = {
11603
11613
  row: compileRowConfig(
11604
11614
  nameMapper,
11605
11615
  tableName,
@@ -12032,11 +12042,6 @@ var downstreamSchema = valita_exports.union(
12032
12042
  var CRUD = "crud";
12033
12043
  var Custom = "custom";
12034
12044
 
12035
- // ../zero-protocol/src/protocol-version.ts
12036
- var PROTOCOL_VERSION = 5;
12037
- var MIN_SERVER_SUPPORTED_PROTOCOL_VERSION = 2;
12038
- assert(MIN_SERVER_SUPPORTED_PROTOCOL_VERSION < PROTOCOL_VERSION);
12039
-
12040
12045
  // ../zero-protocol/src/push.ts
12041
12046
  var CRUD_MUTATION_NAME = "_zero_crud";
12042
12047
  var insertOpSchema = valita_exports.object({
@@ -13379,48 +13384,28 @@ var ZeroContext = class {
13379
13384
  // ../zero-client/src/client/crud.ts
13380
13385
  function makeCRUDMutate(schema, repMutate) {
13381
13386
  const { [CRUD_MUTATION_NAME]: zeroCRUD } = repMutate;
13382
- let inBatch = false;
13383
13387
  const mutateBatch = async (body) => {
13384
- if (inBatch) {
13385
- throw new Error("Cannot call mutate inside a batch");
13386
- }
13387
- inBatch = true;
13388
- try {
13389
- const ops = [];
13390
- const m = {};
13391
- for (const name of Object.keys(schema.tables)) {
13392
- m[name] = makeBatchCRUDMutate(name, schema, ops);
13393
- }
13394
- const rv = await body(m);
13395
- await zeroCRUD({ ops });
13396
- return rv;
13397
- } finally {
13398
- inBatch = false;
13399
- }
13400
- };
13401
- const assertNotInBatch = (tableName, op) => {
13402
- if (inBatch) {
13403
- throw new Error(`Cannot call mutate.${tableName}.${op} inside a batch`);
13388
+ const ops = [];
13389
+ const m = {};
13390
+ for (const name of Object.keys(schema.tables)) {
13391
+ m[name] = makeBatchCRUDMutate(name, schema, ops);
13404
13392
  }
13393
+ const rv = await body(m);
13394
+ await zeroCRUD({ ops });
13395
+ return rv;
13405
13396
  };
13406
13397
  const mutate = {};
13407
13398
  for (const [name, tableSchema] of Object.entries(schema.tables)) {
13408
- mutate[name] = makeEntityCRUDMutate(
13409
- name,
13410
- tableSchema.primaryKey,
13411
- zeroCRUD,
13412
- assertNotInBatch
13413
- );
13399
+ mutate[name] = makeEntityCRUDMutate(name, tableSchema.primaryKey, zeroCRUD);
13414
13400
  }
13415
13401
  return {
13416
13402
  mutate,
13417
13403
  mutateBatch
13418
13404
  };
13419
13405
  }
13420
- function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch) {
13406
+ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD) {
13421
13407
  return {
13422
13408
  insert: (value) => {
13423
- assertNotInBatch(tableName, "insert");
13424
13409
  const op = {
13425
13410
  op: "insert",
13426
13411
  tableName,
@@ -13430,7 +13415,6 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch)
13430
13415
  return zeroCRUD({ ops: [op] });
13431
13416
  },
13432
13417
  upsert: (value) => {
13433
- assertNotInBatch(tableName, "upsert");
13434
13418
  const op = {
13435
13419
  op: "upsert",
13436
13420
  tableName,
@@ -13440,7 +13424,6 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch)
13440
13424
  return zeroCRUD({ ops: [op] });
13441
13425
  },
13442
13426
  update: (value) => {
13443
- assertNotInBatch(tableName, "update");
13444
13427
  const op = {
13445
13428
  op: "update",
13446
13429
  tableName,
@@ -13450,7 +13433,6 @@ function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD, assertNotInBatch)
13450
13433
  return zeroCRUD({ ops: [op] });
13451
13434
  },
13452
13435
  delete: (id) => {
13453
- assertNotInBatch(tableName, "delete");
13454
13436
  const op = {
13455
13437
  op: "delete",
13456
13438
  tableName,
@@ -13996,7 +13978,7 @@ function makeMessage(message, context, logLevel) {
13996
13978
  }
13997
13979
 
13998
13980
  // ../zero-client/src/client/version.ts
13999
- var version2 = "0.14.2025021001";
13981
+ var version2 = "0.14.2025021100";
14000
13982
 
14001
13983
  // ../zero-client/src/client/log-options.ts
14002
13984
  var LevelFilterLogSink = class {
@@ -16152,4 +16134,4 @@ export {
16152
16134
  escapeLike,
16153
16135
  Zero
16154
16136
  };
16155
- //# sourceMappingURL=chunk-MVLDKRBK.js.map
16137
+ //# sourceMappingURL=chunk-OPWNICE2.js.map