@ronin/compiler 0.8.6 → 0.8.7

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 +19 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -633,6 +633,13 @@ var PLURAL_MODEL_ENTITIES = {
633
633
  trigger: "triggers",
634
634
  preset: "presets"
635
635
  };
636
+ var formatModelEntity = (type, entities) => {
637
+ const entries = entities?.map((entity) => {
638
+ const { slug, ...rest } = "slug" in entity ? entity : { slug: `${type}Slug`, ...entity };
639
+ return [slug, rest];
640
+ });
641
+ return entries ? Object.fromEntries(entries) : void 0;
642
+ };
636
643
  var transformMetaQuery = (models, dependencyStatements, statementParams, query) => {
637
644
  const { queryType } = splitQuery(query);
638
645
  const subAltering = query.alter && !("to" in query.alter);
@@ -671,14 +678,23 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query)
671
678
  const newModel = jsonValue;
672
679
  const modelWithFields = addDefaultModelFields(newModel, true);
673
680
  const modelWithPresets = addDefaultModelPresets(models, modelWithFields);
674
- const { fields } = modelWithPresets;
675
- const columns = fields.map((field) => getFieldStatement(models, modelWithPresets, field)).filter(Boolean);
681
+ const entities = Object.fromEntries(
682
+ Object.entries(PLURAL_MODEL_ENTITIES).map(([type, pluralType2]) => {
683
+ const list = modelWithPresets[pluralType2];
684
+ return [pluralType2, formatModelEntity(type, list)];
685
+ })
686
+ );
687
+ const columns = modelWithPresets.fields.map((field) => getFieldStatement(models, modelWithPresets, field)).filter(Boolean);
676
688
  dependencyStatements.push({
677
689
  statement: `${statement} (${columns.join(", ")})`,
678
690
  params: []
679
691
  });
680
692
  models.push(modelWithPresets);
681
- queryTypeDetails = { to: modelWithPresets };
693
+ const finalModel = Object.assign({}, modelWithPresets);
694
+ for (const entity2 in entities) {
695
+ if (entities[entity2]) finalModel[entity2] = entities[entity2];
696
+ }
697
+ queryTypeDetails = { to: finalModel };
682
698
  }
683
699
  if (action === "alter" && model) {
684
700
  const newModel = jsonValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {