@zenstackhq/runtime 3.0.0-alpha.16 → 3.0.0-alpha.18

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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ClientConstructor } from './contract-C6xcEG6Q.cjs';
2
- export { K as AggregateArgs, L as AggregateResult, B as BatchResult, i as BooleanFilter, h as BytesFilter, c as ClientContract, d as ClientOptions, G as CountArgs, H as CountResult, u as CreateArgs, w as CreateManyAndReturnArgs, v as CreateManyArgs, D as DateTimeFilter, A as DeleteArgs, E as DeleteManyArgs, F as FindArgs, s as FindFirstArgs, r as FindManyArgs, t as FindUniqueArgs, P as GroupByArgs, Q as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, k as NullsOrder, N as NumberFilter, m as OmitInput, O as OrderBy, n as SelectIncludeOmit, o as SelectInput, q as SelectSubset, S as SimplifiedModelResult, j as SortOrder, g as StringFilter, p as Subset, T as ToKysely, f as TypeDefResult, U as UpdateArgs, y as UpdateManyAndReturnArgs, x as UpdateManyArgs, z as UpsertArgs, W as WhereInput, l as WhereUniqueInput, e as definePlugin } from './contract-C6xcEG6Q.cjs';
1
+ import { C as ClientConstructor } from './contract-Cn4sSxg8.cjs';
2
+ export { K as AggregateArgs, L as AggregateResult, B as BatchResult, i as BooleanFilter, h as BytesFilter, c as ClientContract, d as ClientOptions, G as CountArgs, H as CountResult, u as CreateArgs, w as CreateManyAndReturnArgs, v as CreateManyArgs, D as DateTimeFilter, A as DeleteArgs, E as DeleteManyArgs, F as FindArgs, s as FindFirstArgs, r as FindManyArgs, t as FindUniqueArgs, P as GroupByArgs, Q as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, k as NullsOrder, N as NumberFilter, m as OmitInput, O as OrderBy, n as SelectIncludeOmit, o as SelectInput, q as SelectSubset, S as SimplifiedModelResult, j as SortOrder, g as StringFilter, p as Subset, T as ToKysely, f as TypeDefResult, U as UpdateArgs, y as UpdateManyAndReturnArgs, x as UpdateManyArgs, z as UpsertArgs, W as WhereInput, l as WhereUniqueInput, e as definePlugin } from './contract-Cn4sSxg8.cjs';
3
3
  import 'decimal.js';
4
4
  import '@zenstackhq/sdk/schema';
5
5
  import 'kysely';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ClientConstructor } from './contract-C6xcEG6Q.js';
2
- export { K as AggregateArgs, L as AggregateResult, B as BatchResult, i as BooleanFilter, h as BytesFilter, c as ClientContract, d as ClientOptions, G as CountArgs, H as CountResult, u as CreateArgs, w as CreateManyAndReturnArgs, v as CreateManyArgs, D as DateTimeFilter, A as DeleteArgs, E as DeleteManyArgs, F as FindArgs, s as FindFirstArgs, r as FindManyArgs, t as FindUniqueArgs, P as GroupByArgs, Q as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, k as NullsOrder, N as NumberFilter, m as OmitInput, O as OrderBy, n as SelectIncludeOmit, o as SelectInput, q as SelectSubset, S as SimplifiedModelResult, j as SortOrder, g as StringFilter, p as Subset, T as ToKysely, f as TypeDefResult, U as UpdateArgs, y as UpdateManyAndReturnArgs, x as UpdateManyArgs, z as UpsertArgs, W as WhereInput, l as WhereUniqueInput, e as definePlugin } from './contract-C6xcEG6Q.js';
1
+ import { C as ClientConstructor } from './contract-Cn4sSxg8.js';
2
+ export { K as AggregateArgs, L as AggregateResult, B as BatchResult, i as BooleanFilter, h as BytesFilter, c as ClientContract, d as ClientOptions, G as CountArgs, H as CountResult, u as CreateArgs, w as CreateManyAndReturnArgs, v as CreateManyArgs, D as DateTimeFilter, A as DeleteArgs, E as DeleteManyArgs, F as FindArgs, s as FindFirstArgs, r as FindManyArgs, t as FindUniqueArgs, P as GroupByArgs, Q as GroupByResult, I as IncludeInput, J as JsonArray, a as JsonObject, b as JsonValue, M as ModelResult, k as NullsOrder, N as NumberFilter, m as OmitInput, O as OrderBy, n as SelectIncludeOmit, o as SelectInput, q as SelectSubset, S as SimplifiedModelResult, j as SortOrder, g as StringFilter, p as Subset, T as ToKysely, f as TypeDefResult, U as UpdateArgs, y as UpdateManyAndReturnArgs, x as UpdateManyArgs, z as UpsertArgs, W as WhereInput, l as WhereUniqueInput, e as definePlugin } from './contract-Cn4sSxg8.js';
3
3
  import 'decimal.js';
4
4
  import '@zenstackhq/sdk/schema';
5
5
  import 'kysely';
package/dist/index.js CHANGED
@@ -1147,6 +1147,9 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
1147
1147
  return `ARRAY[${values.map((v) => typeof v === "string" ? `'${v}'` : v)}]`;
1148
1148
  }
1149
1149
  }
1150
+ get supportInsertWithDefault() {
1151
+ return true;
1152
+ }
1150
1153
  };
1151
1154
 
1152
1155
  // src/client/crud/dialects/sqlite.ts
@@ -1301,6 +1304,9 @@ var SqliteCrudDialect = class extends BaseCrudDialect {
1301
1304
  buildArrayLiteralSQL(_values) {
1302
1305
  throw new Error("SQLite does not support array literals");
1303
1306
  }
1307
+ get supportInsertWithDefault() {
1308
+ return false;
1309
+ }
1304
1310
  };
1305
1311
 
1306
1312
  // src/client/crud/dialects/index.ts
@@ -3073,6 +3079,29 @@ ${compiled.parameters.map((p) => inspect(p)).join("\n")}`;
3073
3079
  }
3074
3080
  return this.fillGeneratedValues(modelDef, newItem);
3075
3081
  });
3082
+ if (!this.dialect.supportInsertWithDefault) {
3083
+ const allPassedFields = createData.reduce((acc, item) => {
3084
+ Object.keys(item).forEach((field) => {
3085
+ if (!acc.includes(field)) {
3086
+ acc.push(field);
3087
+ }
3088
+ });
3089
+ return acc;
3090
+ }, []);
3091
+ for (const item of createData) {
3092
+ if (Object.keys(item).length === allPassedFields.length) {
3093
+ continue;
3094
+ }
3095
+ for (const field of allPassedFields) {
3096
+ if (!(field in item)) {
3097
+ const fieldDef = this.requireField(model, field);
3098
+ if (fieldDef.default !== void 0 && fieldDef.default !== null && typeof fieldDef.default !== "object") {
3099
+ item[field] = this.dialect.transformPrimitive(fieldDef.default, fieldDef.type, !!fieldDef.array);
3100
+ }
3101
+ }
3102
+ }
3103
+ }
3104
+ }
3076
3105
  if (modelDef.baseModel) {
3077
3106
  if (input.skipDuplicates) {
3078
3107
  throw new QueryError('"skipDuplicates" options is not supported for polymorphic models');