@ronin/compiler 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +19 -3
- 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
|
675
|
-
|
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
|
-
|
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;
|