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

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.
Files changed (2) hide show
  1. package/dist/index.js +10 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -675,6 +675,7 @@ var PLURAL_MODEL_ENTITIES = {
675
675
  trigger: "triggers",
676
676
  preset: "presets"
677
677
  };
678
+ var PLURAL_MODEL_ENTITIES_VALUES = Object.values(PLURAL_MODEL_ENTITIES);
678
679
  var formatModelEntity = (type, entities) => {
679
680
  const entries = entities?.map((entity) => {
680
681
  const { slug, ...rest } = "slug" in entity ? entity : { slug: `${type}Slug`, ...entity };
@@ -1630,7 +1631,7 @@ var Transaction = class {
1630
1631
  this.models = modelListWithPresets;
1631
1632
  return statements;
1632
1633
  };
1633
- formatRows(fields, rows, single) {
1634
+ formatRows(fields, rows, single, isMeta) {
1634
1635
  const records = [];
1635
1636
  for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
1636
1637
  const row = rows[rowIndex];
@@ -1654,6 +1655,11 @@ var Transaction = class {
1654
1655
  usableRowIndex = 0;
1655
1656
  }
1656
1657
  }
1658
+ if (isMeta && PLURAL_MODEL_ENTITIES_VALUES.includes(newSlug)) {
1659
+ newValue = Object.entries(newValue).map(([slug, attributes]) => {
1660
+ return { slug, ...attributes };
1661
+ });
1662
+ }
1657
1663
  records[usableRowIndex] = setProperty(
1658
1664
  records[usableRowIndex],
1659
1665
  newSlug,
@@ -1693,6 +1699,7 @@ var Transaction = class {
1693
1699
  if (!returning) return null;
1694
1700
  const { queryType, queryModel, queryInstructions } = splitQuery(query);
1695
1701
  const model = getModelBySlug(this.models, queryModel);
1702
+ const isMeta = queryModel === "model" || queryModel === "models";
1696
1703
  const modelFields = Object.fromEntries(
1697
1704
  model.fields.map((field) => [field.slug, field.type])
1698
1705
  );
@@ -1702,13 +1709,13 @@ var Transaction = class {
1702
1709
  const single = queryModel !== model.pluralSlug;
1703
1710
  if (single) {
1704
1711
  return {
1705
- record: rows[0] ? this.formatRows(rawModelFields, rows, single) : null,
1712
+ record: rows[0] ? this.formatRows(rawModelFields, rows, single, isMeta) : null,
1706
1713
  modelFields
1707
1714
  };
1708
1715
  }
1709
1716
  const pageSize = queryInstructions?.limitedTo;
1710
1717
  const output = {
1711
- records: this.formatRows(rawModelFields, rows, single),
1718
+ records: this.formatRows(rawModelFields, rows, single, isMeta),
1712
1719
  modelFields
1713
1720
  };
1714
1721
  if (pageSize && output.records.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.12.4-leo-ron-1071-experimental-255",
3
+ "version": "0.12.4-leo-ron-1071-experimental-256",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {