@ronin/compiler 0.17.10 → 0.17.11-leo-ron-1099-experimental-401

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
  });
@@ -2120,10 +2124,14 @@ var Transaction = class {
2120
2124
  );
2121
2125
  });
2122
2126
  }
2123
- this.#internalQueries[index].models = modelList;
2124
2127
  return modelList.map((model) => {
2128
+ const instructions = Object.assign(
2129
+ {},
2130
+ restInstructions,
2131
+ onInstruction?.[model.pluralSlug]
2132
+ );
2125
2133
  const query2 = {
2126
- [queryType]: { [model.pluralSlug]: restInstructions }
2134
+ [queryType]: { [model.pluralSlug]: instructions }
2127
2135
  };
2128
2136
  return { query: query2, index };
2129
2137
  });
@@ -2142,10 +2150,8 @@ var Transaction = class {
2142
2150
  const postDependencies = dependencies.map(({ after, ...rest }) => after ? rest : null).filter((item) => item != null);
2143
2151
  const subStatements = [...preDependencies, main, ...postDependencies];
2144
2152
  this.statements.push(...subStatements);
2145
- this.#internalQueries[index].selectedFields = selectedFields;
2146
- if (this.#internalQueries[index].models.length === 0) {
2147
- this.#internalQueries[index].models = [model];
2148
- }
2153
+ this.#internalQueries[index].selectedFields.push(selectedFields);
2154
+ this.#internalQueries[index].models.push(model);
2149
2155
  }
2150
2156
  this.models = modelsWithPresets;
2151
2157
  return statements;
@@ -2309,13 +2315,21 @@ var Transaction = class {
2309
2315
  });
2310
2316
  if (queryModel === "all") {
2311
2317
  const models = {};
2312
- for (const model of affectedModels) {
2318
+ const { on: onInstruction, ...restInstructions } = queryInstructions || {};
2319
+ for (let index = 0; index < affectedModels.length; index++) {
2320
+ const model = affectedModels[index];
2321
+ const fields = selectedFields[index];
2322
+ const instructions = Object.assign(
2323
+ {},
2324
+ restInstructions,
2325
+ onInstruction?.[model.pluralSlug]
2326
+ );
2313
2327
  const result = this.formatIndividualResult(
2314
2328
  queryType,
2315
- queryInstructions,
2329
+ instructions,
2316
2330
  model,
2317
2331
  absoluteResults[resultIndex++],
2318
- selectedFields,
2332
+ fields,
2319
2333
  false
2320
2334
  );
2321
2335
  models[model.pluralSlug] = result;
@@ -2323,12 +2337,13 @@ var Transaction = class {
2323
2337
  finalResults.push({ models });
2324
2338
  } else {
2325
2339
  const model = affectedModels[0];
2340
+ const fields = selectedFields[0];
2326
2341
  const result = this.formatIndividualResult(
2327
2342
  queryType,
2328
2343
  queryInstructions,
2329
2344
  model,
2330
2345
  absoluteResults[resultIndex++],
2331
- selectedFields,
2346
+ fields,
2332
2347
  queryModel !== model.pluralSlug
2333
2348
  );
2334
2349
  finalResults.push(result);
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-leo-ron-1099-experimental-401",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {