@zenstackhq/runtime 3.0.0-alpha.24 → 3.0.0-alpha.25

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.
@@ -562,7 +562,7 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
562
562
  protected and(eb: ExpressionBuilder<any, any>, ...args: Expression<SqlBool>[]): Expression<SqlBool>;
563
563
  protected or(eb: ExpressionBuilder<any, any>, ...args: Expression<SqlBool>[]): Expression<SqlBool>;
564
564
  protected not(eb: ExpressionBuilder<any, any>, ...args: Expression<SqlBool>[]): ExpressionWrapper<any, any, SqlBool>;
565
- fieldRef(model: string, field: string, eb: ExpressionBuilder<any, any>, modelAlias?: string): ExpressionWrapper<any, any, unknown>;
565
+ fieldRef(model: string, field: string, eb: ExpressionBuilder<any, any>, modelAlias?: string, inlineComputedField?: boolean): ExpressionWrapper<any, any, unknown>;
566
566
  abstract get provider(): DataSourceProviderType;
567
567
  /**
568
568
  * Builds selection for a relation field.
@@ -562,7 +562,7 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
562
562
  protected and(eb: ExpressionBuilder<any, any>, ...args: Expression<SqlBool>[]): Expression<SqlBool>;
563
563
  protected or(eb: ExpressionBuilder<any, any>, ...args: Expression<SqlBool>[]): Expression<SqlBool>;
564
564
  protected not(eb: ExpressionBuilder<any, any>, ...args: Expression<SqlBool>[]): ExpressionWrapper<any, any, SqlBool>;
565
- fieldRef(model: string, field: string, eb: ExpressionBuilder<any, any>, modelAlias?: string): ExpressionWrapper<any, any, unknown>;
565
+ fieldRef(model: string, field: string, eb: ExpressionBuilder<any, any>, modelAlias?: string, inlineComputedField?: boolean): ExpressionWrapper<any, any, unknown>;
566
566
  abstract get provider(): DataSourceProviderType;
567
567
  /**
568
568
  * Builds selection for a relation field.
package/dist/index.cjs CHANGED
@@ -305,11 +305,14 @@ function getIdValues(schema, model, data) {
305
305
  }), {});
306
306
  }
307
307
  __name(getIdValues, "getIdValues");
308
- function buildFieldRef(schema, model, field, options, eb, modelAlias) {
308
+ function buildFieldRef(schema, model, field, options, eb, modelAlias, inlineComputedField = true) {
309
309
  const fieldDef = requireField(schema, model, field);
310
310
  if (!fieldDef.computed) {
311
311
  return eb.ref(modelAlias ? `${modelAlias}.${field}` : field);
312
312
  } else {
313
+ if (!inlineComputedField) {
314
+ return eb.ref(modelAlias ? `${modelAlias}.${field}` : field);
315
+ }
313
316
  let computer;
314
317
  if ("computedFields" in options) {
315
318
  const computedFields = options.computedFields;
@@ -493,7 +496,6 @@ var import_kysely2 = require("kysely");
493
496
  var import_ts_pattern3 = require("ts-pattern");
494
497
 
495
498
  // src/client/constants.ts
496
- var CONTEXT_COMMENT_PREFIX = "-- $$context:";
497
499
  var NUMERIC_FIELD_TYPES = [
498
500
  "Int",
499
501
  "Float",
@@ -1080,8 +1082,8 @@ var BaseCrudDialect = class {
1080
1082
  not(eb, ...args) {
1081
1083
  return eb.not(this.and(eb, ...args));
1082
1084
  }
1083
- fieldRef(model, field, eb, modelAlias) {
1084
- return buildFieldRef(this.schema, model, field, this.options, eb, modelAlias);
1085
+ fieldRef(model, field, eb, modelAlias, inlineComputedField = true) {
1086
+ return buildFieldRef(this.schema, model, field, this.options, eb, modelAlias, inlineComputedField);
1085
1087
  }
1086
1088
  };
1087
1089
 
@@ -1176,7 +1178,7 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
1176
1178
  if (payload === true || !payload.select) {
1177
1179
  objArgs.push(...Object.entries(relationModelDef.fields).filter(([, value]) => !value.relation).filter(([name]) => !(typeof payload === "object" && payload.omit?.[name] === true)).map(([field]) => [
1178
1180
  import_kysely2.sql.lit(field),
1179
- this.fieldRef(relationModel, field, eb)
1181
+ this.fieldRef(relationModel, field, eb, void 0, false)
1180
1182
  ]).flatMap((v) => v));
1181
1183
  } else if (payload.select) {
1182
1184
  objArgs.push(...Object.entries(payload.select).filter(([, value]) => value).map(([field, value]) => {
@@ -1188,7 +1190,7 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
1188
1190
  ];
1189
1191
  } else {
1190
1192
  const fieldDef = requireField(this.schema, relationModel, field);
1191
- const fieldValue = fieldDef.relation ? eb.ref(`${parentAlias}$${relationField}$${field}.$j`) : this.fieldRef(relationModel, field, eb);
1193
+ const fieldValue = fieldDef.relation ? eb.ref(`${parentAlias}$${relationField}$${field}.$j`) : this.fieldRef(relationModel, field, eb, void 0, false);
1192
1194
  return [
1193
1195
  import_kysely2.sql.lit(field),
1194
1196
  fieldValue
@@ -1339,7 +1341,7 @@ var SqliteCrudDialect = class extends BaseCrudDialect {
1339
1341
  if (payload === true || !payload.select) {
1340
1342
  objArgs.push(...Object.entries(relationModelDef.fields).filter(([, value]) => !value.relation).filter(([name]) => !(typeof payload === "object" && payload.omit?.[name] === true)).map(([field]) => [
1341
1343
  import_kysely3.sql.lit(field),
1342
- this.fieldRef(relationModel, field, eb)
1344
+ this.fieldRef(relationModel, field, eb, void 0, false)
1343
1345
  ]).flatMap((v) => v));
1344
1346
  } else if (payload.select) {
1345
1347
  objArgs.push(...Object.entries(payload.select).filter(([, value]) => value).map(([field, value]) => {
@@ -1360,7 +1362,7 @@ var SqliteCrudDialect = class extends BaseCrudDialect {
1360
1362
  } else {
1361
1363
  return [
1362
1364
  import_kysely3.sql.lit(field),
1363
- this.fieldRef(relationModel, field, eb)
1365
+ this.fieldRef(relationModel, field, eb, void 0, false)
1364
1366
  ];
1365
1367
  }
1366
1368
  }
@@ -3460,8 +3462,8 @@ ${compiled.parameters.map((p) => (0, import_node_util.inspect)(p)).join("\n")}`;
3460
3462
  isNumericField(fieldDef) {
3461
3463
  return NUMERIC_FIELD_TYPES.includes(fieldDef.type) && !fieldDef.array;
3462
3464
  }
3463
- makeContextComment(context) {
3464
- return import_kysely8.sql.raw(`${CONTEXT_COMMENT_PREFIX}${JSON.stringify(context)}`);
3465
+ makeContextComment(_context) {
3466
+ return import_kysely8.sql``;
3465
3467
  }
3466
3468
  async updateMany(kysely, model, where, data, limit, returnData, filterModel) {
3467
3469
  if (typeof data !== "object") {