@ronin/compiler 0.12.4-leo-ron-1071-experimental-254 → 0.12.4-leo-ron-1071-experimental-255

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -15671,8 +15671,8 @@ declare class Transaction {
15671
15671
  */
15672
15672
  private compileQueries;
15673
15673
  private formatRows;
15674
- formatResults<T>(results: Array<Array<RawRow>>, raw?: true): Array<Result<T>>;
15675
- formatResults<T>(results: Array<Array<ObjectRow>>, raw?: false): Array<Result<T>>;
15674
+ formatResults<Record>(results: Array<Array<RawRow>>, raw?: true): Array<Result<Record>>;
15675
+ formatResults<Record>(results: Array<Array<ObjectRow>>, raw?: false): Array<Result<Record>>;
15676
15676
  }
15677
15677
 
15678
15678
  declare const CLEAN_ROOT_MODEL: PublicModel;
package/dist/index.js CHANGED
@@ -1683,60 +1683,66 @@ var Transaction = class {
1683
1683
  return Object.values(row);
1684
1684
  });
1685
1685
  });
1686
- const formattedResults = normalizedResults.map((rows, index) => {
1687
- const { returning, query, fields: rawModelFields } = this.internalStatements[index];
1688
- if (!returning) return null;
1689
- const { queryType, queryModel, queryInstructions } = splitQuery(query);
1690
- const model = getModelBySlug(this.models, queryModel);
1691
- const modelFields = Object.fromEntries(
1692
- model.fields.map((field) => [field.slug, field.type])
1693
- );
1694
- if (queryType === "count") {
1695
- return { amount: rows[0][0] };
1696
- }
1697
- const single = queryModel !== model.pluralSlug;
1698
- if (single) {
1699
- return {
1700
- record: rows[0] ? this.formatRows(rawModelFields, rows, single) : null,
1686
+ const formattedResults = normalizedResults.map(
1687
+ (rows, index) => {
1688
+ const {
1689
+ returning,
1690
+ query,
1691
+ fields: rawModelFields
1692
+ } = this.internalStatements[index];
1693
+ if (!returning) return null;
1694
+ const { queryType, queryModel, queryInstructions } = splitQuery(query);
1695
+ const model = getModelBySlug(this.models, queryModel);
1696
+ const modelFields = Object.fromEntries(
1697
+ model.fields.map((field) => [field.slug, field.type])
1698
+ );
1699
+ if (queryType === "count") {
1700
+ return { amount: rows[0][0] };
1701
+ }
1702
+ const single = queryModel !== model.pluralSlug;
1703
+ if (single) {
1704
+ return {
1705
+ record: rows[0] ? this.formatRows(rawModelFields, rows, single) : null,
1706
+ modelFields
1707
+ };
1708
+ }
1709
+ const pageSize = queryInstructions?.limitedTo;
1710
+ const output = {
1711
+ records: this.formatRows(rawModelFields, rows, single),
1701
1712
  modelFields
1702
1713
  };
1703
- }
1704
- const pageSize = queryInstructions?.limitedTo;
1705
- const output = {
1706
- records: this.formatRows(rawModelFields, rows, single),
1707
- modelFields
1708
- };
1709
- if (pageSize && output.records.length > 0) {
1710
- if (output.records.length > pageSize) {
1711
- if (queryInstructions?.before) {
1712
- output.records.shift();
1713
- } else {
1714
- output.records.pop();
1714
+ if (pageSize && output.records.length > 0) {
1715
+ if (output.records.length > pageSize) {
1716
+ if (queryInstructions?.before) {
1717
+ output.records.shift();
1718
+ } else {
1719
+ output.records.pop();
1720
+ }
1721
+ const direction = queryInstructions?.before ? "moreBefore" : "moreAfter";
1722
+ const lastRecord = output.records.at(
1723
+ direction === "moreAfter" ? -1 : 0
1724
+ );
1725
+ output[direction] = generatePaginationCursor(
1726
+ model,
1727
+ queryInstructions.orderedBy,
1728
+ lastRecord
1729
+ );
1730
+ }
1731
+ if (queryInstructions?.before || queryInstructions?.after) {
1732
+ const direction = queryInstructions?.before ? "moreAfter" : "moreBefore";
1733
+ const firstRecord = output.records.at(
1734
+ direction === "moreAfter" ? -1 : 0
1735
+ );
1736
+ output[direction] = generatePaginationCursor(
1737
+ model,
1738
+ queryInstructions.orderedBy,
1739
+ firstRecord
1740
+ );
1715
1741
  }
1716
- const direction = queryInstructions?.before ? "moreBefore" : "moreAfter";
1717
- const lastRecord = output.records.at(
1718
- direction === "moreAfter" ? -1 : 0
1719
- );
1720
- output[direction] = generatePaginationCursor(
1721
- model,
1722
- queryInstructions.orderedBy,
1723
- lastRecord
1724
- );
1725
- }
1726
- if (queryInstructions?.before || queryInstructions?.after) {
1727
- const direction = queryInstructions?.before ? "moreAfter" : "moreBefore";
1728
- const firstRecord = output.records.at(
1729
- direction === "moreAfter" ? -1 : 0
1730
- );
1731
- output[direction] = generatePaginationCursor(
1732
- model,
1733
- queryInstructions.orderedBy,
1734
- firstRecord
1735
- );
1736
1742
  }
1743
+ return output;
1737
1744
  }
1738
- return output;
1739
- });
1745
+ );
1740
1746
  return formattedResults.filter((result) => result !== null);
1741
1747
  }
1742
1748
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.12.4-leo-ron-1071-experimental-254",
3
+ "version": "0.12.4-leo-ron-1071-experimental-255",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {