@prisma-next/sql-orm-client 0.5.0-dev.66 → 0.5.0-dev.67

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.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import { AsyncIterableResult } from "@prisma-next/framework-components/runtime";
2
2
  import { AggregateExpr, AndExpr, BinaryExpr, ColumnRef, DefaultValueExpr, DeleteAst, DerivedTableSource, EqColJoinOn, ExistsExpr, InsertAst, InsertOnConflict, JoinAst, JsonArrayAggExpr, JsonObjectExpr, ListExpression, LiteralExpr, NotExpr, NullCheckExpr, OrExpr, OrderByItem, ParamRef, ProjectionItem, SelectAst, SubqueryExpr, TableSource, UpdateAst, collectOrderedParamRefs, isWhereExpr } from "@prisma-next/sql-relational-core/ast";
3
3
  import { ifDefined } from "@prisma-next/utils/defined";
4
-
5
4
  //#region src/collection-contract.ts
6
5
  function modelsOf(contract) {
7
6
  return contract.models;
@@ -198,7 +197,6 @@ function capabilityEnabled(value) {
198
197
  function isToOneCardinality(cardinality) {
199
198
  return cardinality === "1:1" || cardinality === "N:1";
200
199
  }
201
-
202
200
  //#endregion
203
201
  //#region src/aggregate-builder.ts
204
202
  function createAggregateBuilder(contract, modelName) {
@@ -238,7 +236,6 @@ function createFieldAggregateSelector(fieldToColumn, field, fn) {
238
236
  column: fieldToColumn[fieldName] ?? fieldName
239
237
  };
240
238
  }
241
-
242
239
  //#endregion
243
240
  //#region src/collection-aggregate-result.ts
244
241
  function normalizeAggregateResult(aggregateSpec, row) {
@@ -270,7 +267,6 @@ function normalizeAggregateResult(aggregateSpec, row) {
270
267
  }
271
268
  return result;
272
269
  }
273
-
274
270
  //#endregion
275
271
  //#region src/collection-column-mapping.ts
276
272
  function mapFieldsToColumns(contract, modelName, fieldNames) {
@@ -287,7 +283,6 @@ function mapCursorValuesToColumns(contract, modelName, cursorValues) {
287
283
  }
288
284
  return mappedCursor;
289
285
  }
290
-
291
286
  //#endregion
292
287
  //#region src/collection-runtime.ts
293
288
  function augmentSelectionForJoinColumns(selectedFields, requiredColumns) {
@@ -348,12 +343,12 @@ function mapPolymorphicRow(contract, baseModelName, polyInfo, row, variantName)
348
343
  const variant = variantName ? polyInfo.variants.get(variantName) : polyInfo.variantsByValue.get(row[polyInfo.discriminatorColumn]);
349
344
  if (!variant) {
350
345
  const baseMap = getCompleteColumnToFieldMap(contract, baseModelName);
351
- const mapped$1 = {};
346
+ const mapped = {};
352
347
  for (const [col, val] of Object.entries(row)) {
353
348
  const field = baseMap[col];
354
- if (field !== void 0) mapped$1[field] = val;
349
+ if (field !== void 0) mapped[field] = val;
355
350
  }
356
- return mapped$1;
351
+ return mapped;
357
352
  }
358
353
  const mtiTable = variant.strategy === "mti" ? variant.table : void 0;
359
354
  const mergedMap = getMergedColumnToFieldMap(contract, baseModelName, variant.modelName, mtiTable);
@@ -389,13 +384,11 @@ async function acquireRuntimeScope(runtime) {
389
384
  };
390
385
  return { scope: connection };
391
386
  }
392
-
393
387
  //#endregion
394
388
  //#region src/execute-query-plan.ts
395
389
  function executeQueryPlan(scope, plan) {
396
390
  return scope.execute(plan);
397
391
  }
398
-
399
392
  //#endregion
400
393
  //#region src/include-strategy.ts
401
394
  /**
@@ -437,7 +430,6 @@ function selectIncludeStrategy(contract) {
437
430
  function capabilityFlag(contract, flag) {
438
431
  return contract.capabilities[contract.targetFamily]?.[flag] === true || contract.capabilities[contract.target]?.[flag] === true;
439
432
  }
440
-
441
433
  //#endregion
442
434
  //#region src/query-plan-meta.ts
443
435
  function deriveParamsFromAst(ast) {
@@ -464,7 +456,6 @@ function buildOrmQueryPlan(contract, ast, params) {
464
456
  meta: buildOrmPlanMeta(contract)
465
457
  });
466
458
  }
467
-
468
459
  //#endregion
469
460
  //#region src/where-utils.ts
470
461
  function combineWhereExprs(filters) {
@@ -472,7 +463,6 @@ function combineWhereExprs(filters) {
472
463
  if (filters.length === 1) return filters[0];
473
464
  return AndExpr.of(filters);
474
465
  }
475
-
476
466
  //#endregion
477
467
  //#region src/query-plan-aggregate.ts
478
468
  function toAggregateProjection(contract, tableName, selector) {
@@ -526,23 +516,23 @@ function validateGroupedHavingExpr(expr) {
526
516
  throw new Error("ParamRef is not supported in grouped having expressions");
527
517
  },
528
518
  list: rejectHavingExpr,
529
- and(expr$1) {
530
- return AndExpr.of(expr$1.exprs.map((child) => validateGroupedHavingExpr(child)));
519
+ and(expr) {
520
+ return AndExpr.of(expr.exprs.map((child) => validateGroupedHavingExpr(child)));
531
521
  },
532
- or(expr$1) {
533
- return OrExpr.of(expr$1.exprs.map((child) => validateGroupedHavingExpr(child)));
522
+ or(expr) {
523
+ return OrExpr.of(expr.exprs.map((child) => validateGroupedHavingExpr(child)));
534
524
  },
535
- exists(expr$1) {
536
- throw new Error(`Unsupported grouped having expression kind "${expr$1.kind}"`);
525
+ exists(expr) {
526
+ throw new Error(`Unsupported grouped having expression kind "${expr.kind}"`);
537
527
  },
538
- nullCheck(expr$1) {
539
- return new NullCheckExpr(validateGroupedMetricExpr(expr$1.expr), expr$1.isNull);
528
+ nullCheck(expr) {
529
+ return new NullCheckExpr(validateGroupedMetricExpr(expr.expr), expr.isNull);
540
530
  },
541
- not(expr$1) {
542
- return new NotExpr(validateGroupedHavingExpr(expr$1.expr));
531
+ not(expr) {
532
+ return new NotExpr(validateGroupedHavingExpr(expr.expr));
543
533
  },
544
- binary(expr$1) {
545
- return new BinaryExpr(expr$1.op, validateGroupedMetricExpr(expr$1.left), validateGroupedComparable(expr$1.right));
534
+ binary(expr) {
535
+ return new BinaryExpr(expr.op, validateGroupedMetricExpr(expr.left), validateGroupedComparable(expr.right));
546
536
  }
547
537
  });
548
538
  }
@@ -575,7 +565,6 @@ function compileGroupedAggregate(contract, tableName, filters, groupByColumns, a
575
565
  const { params } = deriveParamsFromAst(ast);
576
566
  return buildOrmQueryPlan(contract, ast, params);
577
567
  }
578
-
579
568
  //#endregion
580
569
  //#region src/query-plan-mutations.ts
581
570
  function buildReturningColumns(contract, tableName, returningColumns) {
@@ -713,7 +702,6 @@ function compileDeleteCount(contract, tableName, filters) {
713
702
  const { params } = deriveParamsFromAst(ast);
714
703
  return buildOrmQueryPlan(contract, ast, params);
715
704
  }
716
-
717
705
  //#endregion
718
706
  //#region src/where-binding.ts
719
707
  function bindWhereExpr(contract, expr) {
@@ -721,55 +709,55 @@ function bindWhereExpr(contract, expr) {
721
709
  }
722
710
  function bindWhereExprNode(contract, expr) {
723
711
  return expr.accept({
724
- columnRef(expr$1) {
725
- return bindExpression(contract, expr$1);
712
+ columnRef(expr) {
713
+ return bindExpression(contract, expr);
726
714
  },
727
- identifierRef(expr$1) {
728
- return expr$1;
715
+ identifierRef(expr) {
716
+ return expr;
729
717
  },
730
- subquery(expr$1) {
731
- return bindExpression(contract, expr$1);
718
+ subquery(expr) {
719
+ return bindExpression(contract, expr);
732
720
  },
733
- operation(expr$1) {
734
- return bindExpression(contract, expr$1);
721
+ operation(expr) {
722
+ return bindExpression(contract, expr);
735
723
  },
736
- aggregate(expr$1) {
737
- return bindExpression(contract, expr$1);
724
+ aggregate(expr) {
725
+ return bindExpression(contract, expr);
738
726
  },
739
- jsonObject(expr$1) {
740
- return bindExpression(contract, expr$1);
727
+ jsonObject(expr) {
728
+ return bindExpression(contract, expr);
741
729
  },
742
- jsonArrayAgg(expr$1) {
743
- return bindExpression(contract, expr$1);
730
+ jsonArrayAgg(expr) {
731
+ return bindExpression(contract, expr);
744
732
  },
745
- literal(expr$1) {
746
- return expr$1;
733
+ literal(expr) {
734
+ return expr;
747
735
  },
748
- param(expr$1) {
749
- return expr$1;
736
+ param(expr) {
737
+ return expr;
750
738
  },
751
- list(expr$1) {
752
- return bindExpression(contract, expr$1);
739
+ list(expr) {
740
+ return bindExpression(contract, expr);
753
741
  },
754
- binary(expr$1) {
755
- const left = bindExpression(contract, expr$1.left);
742
+ binary(expr) {
743
+ const left = bindExpression(contract, expr.left);
756
744
  const bindingColumn = left.kind === "column-ref" ? left : void 0;
757
- return new BinaryExpr(expr$1.op, left, bindComparable(contract, expr$1.right, bindingColumn));
745
+ return new BinaryExpr(expr.op, left, bindComparable(contract, expr.right, bindingColumn));
758
746
  },
759
- and(expr$1) {
760
- return AndExpr.of(expr$1.exprs.map((part) => bindWhereExprNode(contract, part)));
747
+ and(expr) {
748
+ return AndExpr.of(expr.exprs.map((part) => bindWhereExprNode(contract, part)));
761
749
  },
762
- or(expr$1) {
763
- return OrExpr.of(expr$1.exprs.map((part) => bindWhereExprNode(contract, part)));
750
+ or(expr) {
751
+ return OrExpr.of(expr.exprs.map((part) => bindWhereExprNode(contract, part)));
764
752
  },
765
- exists(expr$1) {
766
- return expr$1.notExists ? ExistsExpr.notExists(bindSelectAst(contract, expr$1.subquery)) : ExistsExpr.exists(bindSelectAst(contract, expr$1.subquery));
753
+ exists(expr) {
754
+ return expr.notExists ? ExistsExpr.notExists(bindSelectAst(contract, expr.subquery)) : ExistsExpr.exists(bindSelectAst(contract, expr.subquery));
767
755
  },
768
- nullCheck(expr$1) {
769
- return expr$1.isNull ? NullCheckExpr.isNull(bindExpression(contract, expr$1.expr)) : NullCheckExpr.isNotNull(bindExpression(contract, expr$1.expr));
756
+ nullCheck(expr) {
757
+ return expr.isNull ? NullCheckExpr.isNull(bindExpression(contract, expr.expr)) : NullCheckExpr.isNotNull(bindExpression(contract, expr.expr));
770
758
  },
771
- not(expr$1) {
772
- return new NotExpr(bindWhereExprNode(contract, expr$1.expr));
759
+ not(expr) {
760
+ return new NotExpr(bindWhereExprNode(contract, expr.expr));
773
761
  }
774
762
  });
775
763
  }
@@ -829,7 +817,6 @@ function bindSelectAst(contract, ast) {
829
817
  selectAllIntent: ast.selectAllIntent
830
818
  });
831
819
  }
832
-
833
820
  //#endregion
834
821
  //#region src/query-plan-select.ts
835
822
  function buildProjection(contract, tableName, selectedFields, tableRef = tableName) {
@@ -1017,9 +1004,9 @@ function compileSelectWithIncludeStrategy(contract, tableName, state, strategy,
1017
1004
  }
1018
1005
  for (const include of state.includes) {
1019
1006
  if (strategy === "lateral") {
1020
- const artifact$1 = buildLateralIncludeArtifacts(contract, tableName, include);
1021
- includeJoins.push(artifact$1.join);
1022
- includeProjection.push(artifact$1.projection);
1007
+ const artifact = buildLateralIncludeArtifacts(contract, tableName, include);
1008
+ includeJoins.push(artifact.join);
1009
+ includeProjection.push(artifact.projection);
1023
1010
  continue;
1024
1011
  }
1025
1012
  const artifact = buildCorrelatedIncludeProjection(contract, tableName, include);
@@ -1036,7 +1023,6 @@ function compileSelectWithIncludeStrategy(contract, tableName, state, strategy,
1036
1023
  const { params } = deriveParamsFromAst(ast);
1037
1024
  return buildOrmQueryPlan(contract, ast, params);
1038
1025
  }
1039
-
1040
1026
  //#endregion
1041
1027
  //#region src/collection-dispatch.ts
1042
1028
  function dispatchCollectionRows(options) {
@@ -1306,7 +1292,6 @@ function coerceNumericValue(value) {
1306
1292
  }
1307
1293
  return null;
1308
1294
  }
1309
-
1310
1295
  //#endregion
1311
1296
  //#region src/collection-mutation-dispatch.ts
1312
1297
  function dispatchMutationRows(options) {
@@ -1388,7 +1373,6 @@ async function executeMutationReturningSingleRow(options) {
1388
1373
  if (release) await release();
1389
1374
  }
1390
1375
  }
1391
-
1392
1376
  //#endregion
1393
1377
  //#region src/filters.ts
1394
1378
  function and(...exprs) {
@@ -1427,7 +1411,6 @@ function assertFieldHasEqualityTrait(context, modelName, fieldName) {
1427
1411
  const codecId = fieldType?.kind === "scalar" ? fieldType.codecId : void 0;
1428
1412
  if (!(codecId ? context.codecDescriptors.descriptorFor(codecId)?.traits ?? [] : []).includes("equality")) throw new Error(`Shorthand filter on "${modelName}.${fieldName}": field does not support equality comparisons`);
1429
1413
  }
1430
-
1431
1414
  //#endregion
1432
1415
  //#region src/grouped-collection.ts
1433
1416
  var GroupedCollection = class GroupedCollection {
@@ -1527,7 +1510,6 @@ function coerceAggregateValue(fn, value) {
1527
1510
  }
1528
1511
  return value;
1529
1512
  }
1530
-
1531
1513
  //#endregion
1532
1514
  //#region src/include-descriptors.ts
1533
1515
  const aggregateFns = new Set([
@@ -1572,7 +1554,6 @@ function isCollectionState(value) {
1572
1554
  const candidate = value;
1573
1555
  return Array.isArray(candidate.filters) && Array.isArray(candidate.includes);
1574
1556
  }
1575
-
1576
1557
  //#endregion
1577
1558
  //#region src/types.ts
1578
1559
  function emptyState() {
@@ -1684,7 +1665,6 @@ const COMPARISON_METHODS_META = {
1684
1665
  create: (left) => () => NullCheckExpr.isNotNull(left)
1685
1666
  }
1686
1667
  };
1687
-
1688
1668
  //#endregion
1689
1669
  //#region src/model-accessor.ts
1690
1670
  function createModelAccessor(context, modelName) {
@@ -1842,7 +1822,6 @@ function firstTargetColumn(contract, relation) {
1842
1822
  if (!firstField) return;
1843
1823
  return resolveFieldToColumn(contract, relation.to, firstField);
1844
1824
  }
1845
-
1846
1825
  //#endregion
1847
1826
  //#region src/relation-mutator.ts
1848
1827
  function createRelationMutator() {
@@ -1877,7 +1856,6 @@ function isRelationMutationDescriptor(value) {
1877
1856
  function isRelationMutationCallback(value) {
1878
1857
  return typeof value === "function";
1879
1858
  }
1880
-
1881
1859
  //#endregion
1882
1860
  //#region src/mutation-executor.ts
1883
1861
  function hasNestedMutationCallbacks(contract, modelName, data) {
@@ -2048,9 +2026,9 @@ async function applyChildOwnedMutation(scope, context, parentModelName, parentRo
2048
2026
  for (const criterion of mutation.criteria) {
2049
2027
  const criterionWhere = shorthandToWhereExpr(context, relation.relatedModelName, criterion);
2050
2028
  if (!criterionWhere) throw new Error(`connect() nested mutation for relation "${relation.relationName}" requires non-empty criterion`);
2051
- const setValues$1 = {};
2052
- for (const [childColumn, parentValue] of parentValues.entries()) setValues$1[childColumn] = parentValue;
2053
- await executeUpdateCount(scope, contract, relation.relatedTableName, setValues$1, [criterionWhere]);
2029
+ const setValues = {};
2030
+ for (const [childColumn, parentValue] of parentValues.entries()) setValues[childColumn] = parentValue;
2031
+ await executeUpdateCount(scope, contract, relation.relatedTableName, setValues, [criterionWhere]);
2054
2032
  }
2055
2033
  return;
2056
2034
  }
@@ -2150,7 +2128,6 @@ function getRelationDefinitions(contract, modelName) {
2150
2128
  function toFieldName(contract, modelName, columnName) {
2151
2129
  return getColumnToFieldMap(contract, modelName)[columnName] ?? columnName;
2152
2130
  }
2153
-
2154
2131
  //#endregion
2155
2132
  //#region src/where-interop.ts
2156
2133
  function normalizeWhereArg(arg, options) {
@@ -2163,7 +2140,6 @@ function normalizeWhereArg(arg, options) {
2163
2140
  function isToWhereExpr(arg) {
2164
2141
  return typeof arg === "object" && arg !== null && "toWhereExpr" in arg && !isWhereExpr(arg);
2165
2142
  }
2166
-
2167
2143
  //#endregion
2168
2144
  //#region src/collection.ts
2169
2145
  function applyCreateDefaults(ctx, tableName, rows) {
@@ -2731,7 +2707,6 @@ var Collection = class Collection {
2731
2707
  });
2732
2708
  }
2733
2709
  };
2734
-
2735
2710
  //#endregion
2736
2711
  //#region src/orm.ts
2737
2712
  function orm(options) {
@@ -2773,7 +2748,7 @@ function isCollectionClass(value) {
2773
2748
  if (!candidate.prototype || typeof candidate.prototype !== "object") return false;
2774
2749
  return candidate.prototype instanceof Collection;
2775
2750
  }
2776
-
2777
2751
  //#endregion
2778
2752
  export { Collection, GroupedCollection, all, and, emptyState, not, or, orm };
2753
+
2779
2754
  //# sourceMappingURL=index.mjs.map