@ronin/compiler 0.17.10 → 0.17.11

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 CHANGED
@@ -118,7 +118,15 @@ type AddQuery = Record<string, Omit<CombinedInstructions, 'with' | 'using'> & {
118
118
  type RemoveQuery = Record<string, Omit<CombinedInstructions, 'to'>>;
119
119
  type CountQuery = Record<string, Omit<CombinedInstructions, 'to'> | null>;
120
120
  type AllQueryInstructions = {
121
- for?: string;
121
+ /**
122
+ * Limit the list of models for which queries should be generated to only the models
123
+ * that the provided model links to.
124
+ */
125
+ for?: PublicModel['slug'];
126
+ /**
127
+ * Provide query instructions for specific models.
128
+ */
129
+ on?: Record<PublicModel['slug'], Omit<CombinedInstructions, 'to'> | null>;
122
130
  };
123
131
  type AllQuery = {
124
132
  all: AllQueryInstructions | null;
package/dist/index.js CHANGED
@@ -2108,7 +2108,11 @@ var Transaction = class {
2108
2108
  const expandedQueries = this.#internalQueries.flatMap(({ query }, index) => {
2109
2109
  const { queryType, queryModel, queryInstructions } = splitQuery(query);
2110
2110
  if (queryModel === "all") {
2111
- const { for: forInstruction, ...restInstructions } = queryInstructions || {};
2111
+ const {
2112
+ for: forInstruction,
2113
+ on: onInstruction,
2114
+ ...restInstructions
2115
+ } = queryInstructions || {};
2112
2116
  let modelList = modelsWithPresets.filter((model) => {
2113
2117
  return model.slug !== ROOT_MODEL.slug;
2114
2118
  });
@@ -2122,8 +2126,13 @@ var Transaction = class {
2122
2126
  }
2123
2127
  this.#internalQueries[index].models = modelList;
2124
2128
  return modelList.map((model) => {
2129
+ const instructions = Object.assign(
2130
+ {},
2131
+ restInstructions,
2132
+ onInstruction?.[model.pluralSlug]
2133
+ );
2125
2134
  const query2 = {
2126
- [queryType]: { [model.pluralSlug]: restInstructions }
2135
+ [queryType]: { [model.pluralSlug]: instructions }
2127
2136
  };
2128
2137
  return { query: query2, index };
2129
2138
  });
@@ -2309,10 +2318,16 @@ var Transaction = class {
2309
2318
  });
2310
2319
  if (queryModel === "all") {
2311
2320
  const models = {};
2321
+ const { on: onInstruction, ...restInstructions } = queryInstructions || {};
2312
2322
  for (const model of affectedModels) {
2323
+ const instructions = Object.assign(
2324
+ {},
2325
+ restInstructions,
2326
+ onInstruction?.[model.pluralSlug]
2327
+ );
2313
2328
  const result = this.formatIndividualResult(
2314
2329
  queryType,
2315
- queryInstructions,
2330
+ instructions,
2316
2331
  model,
2317
2332
  absoluteResults[resultIndex++],
2318
2333
  selectedFields,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.17.10",
3
+ "version": "0.17.11",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {