@ronin/compiler 0.12.4-leo-ron-1071-experimental-254 → 0.12.4-leo-ron-1071-experimental-255
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.ts +2 -2
- package/dist/index.js +55 -49
- package/package.json +1 -1
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<
|
15675
|
-
formatResults<
|
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(
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
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
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
output
|
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
|
-
|
1739
|
-
});
|
1745
|
+
);
|
1740
1746
|
return formattedResults.filter((result) => result !== null);
|
1741
1747
|
}
|
1742
1748
|
};
|
package/package.json
CHANGED