@ronin/compiler 0.17.4 → 0.17.5-corny-ron-1099-experimental-388
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 +1 -1
- package/dist/index.js +8 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -307,7 +307,7 @@ type ModelTrigger<T extends ModelEntityList<ModelField> = ModelEntityList<ModelF
|
|
307
307
|
/** When the trigger should fire in the case that a matching query is executed. */
|
308
308
|
when: 'BEFORE' | 'DURING' | 'AFTER';
|
309
309
|
/** A list of queries that should be executed when the trigger fires. */
|
310
|
-
effects: Array<Query
|
310
|
+
effects: Array<Record<typeof QUERY_SYMBOLS.QUERY, Query>>;
|
311
311
|
/** A list of field slugs for which the trigger should fire. */
|
312
312
|
fields?: Array<ModelTriggerField<T>>;
|
313
313
|
/**
|
package/dist/index.js
CHANGED
@@ -1856,7 +1856,7 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query,
|
|
1856
1856
|
}
|
1857
1857
|
};
|
1858
1858
|
}
|
1859
|
-
const modelBeforeUpdate = structuredClone(model);
|
1859
|
+
const modelBeforeUpdate = structuredClone(JSON.parse(JSON.stringify(model)));
|
1860
1860
|
const existingModel = model;
|
1861
1861
|
const pluralType = PLURAL_MODEL_ENTITIES[entity];
|
1862
1862
|
const existingEntity = existingModel[pluralType]?.[slug];
|
@@ -1987,7 +1987,7 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query,
|
|
1987
1987
|
statementParts.push("WHEN", `(${withStatement})`);
|
1988
1988
|
}
|
1989
1989
|
const effectStatements = trigger.effects.map((effectQuery) => {
|
1990
|
-
return compileQueryInput(effectQuery, models, null, {
|
1990
|
+
return compileQueryInput(effectQuery[QUERY_SYMBOLS.QUERY], models, null, {
|
1991
1991
|
returning: false,
|
1992
1992
|
parentModel: existingModel,
|
1993
1993
|
inlineDefaults: options.inlineDefaults
|
@@ -2004,10 +2004,11 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query,
|
|
2004
2004
|
let json;
|
2005
2005
|
switch (action) {
|
2006
2006
|
case "create": {
|
2007
|
-
const
|
2008
|
-
|
2007
|
+
const { slug: slug2, ...entityValue } = jsonValue;
|
2008
|
+
const value = prepareStatementValue(statementParams, entityValue);
|
2009
|
+
json = `json_insert(${field}, '$.${slug2}', ${value})`;
|
2009
2010
|
if (!existingModel[pluralType]) existingModel[pluralType] = {};
|
2010
|
-
existingModel[pluralType][
|
2011
|
+
existingModel[pluralType][slug2] = jsonValue;
|
2011
2012
|
break;
|
2012
2013
|
}
|
2013
2014
|
case "alter": {
|
@@ -2019,8 +2020,9 @@ var transformMetaQuery = (models, dependencyStatements, statementParams, query,
|
|
2019
2020
|
newSlug,
|
2020
2021
|
Object.getOwnPropertyDescriptor(targetEntities, slug)
|
2021
2022
|
);
|
2023
|
+
Object.assign(targetEntities[newSlug], entityValue);
|
2022
2024
|
delete targetEntities[slug];
|
2023
|
-
const value = prepareStatementValue(statementParams,
|
2025
|
+
const value = prepareStatementValue(statementParams, targetEntities[newSlug]);
|
2024
2026
|
json = `json_insert(json_remove(${field}, '$.${slug}'), '$.${newSlug}', ${value})`;
|
2025
2027
|
} else {
|
2026
2028
|
Object.assign(targetEntities[slug], jsonValue);
|