@ronin/compiler 0.17.18 → 0.17.19-corny-pagination-bug-experimental-411

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
@@ -491,4 +491,4 @@ declare class Transaction {
491
491
 
492
492
  declare const CLEAN_ROOT_MODEL: PublicModel;
493
493
 
494
- export { type AddInstructions, type AddQuery, type AddInstructions as AddQueryInstructions, type AlterQuery, type CombinedInstructions, type CountInstructions, type CountQuery, type CountInstructions as CountQueryInstructions, type CreateQuery, DDL_QUERY_TYPES, DML_QUERY_TYPES, DML_QUERY_TYPES_READ, DML_QUERY_TYPES_WRITE, type DropQuery, type ExpandedResult, type GetInstructions, type GetQuery, type GetInstructions as GetQueryInstructions, type PublicModel as Model, type ModelField, type ModelIndex, type ModelPreset, type ModelTrigger, QUERY_SYMBOLS, QUERY_TYPES, type Query, type QueryInstructionType as QueryInstruction, type QuerySchemaType, type QueryType, CLEAN_ROOT_MODEL as ROOT_MODEL, type RegularResult, type RemoveInstructions, type RemoveQuery, type RemoveInstructions as RemoveQueryInstructions, type Result, type ResultRecord, RoninError, type SetInstructions, type SetQuery, type SetInstructions as SetQueryInstructions, type Statement, type StoredObject, Transaction, type WithInstruction, getQuerySymbol };
494
+ export { type AddInstructions, type AddQuery, type AddInstructions as AddQueryInstructions, type AlterQuery, type CombinedInstructions, type CountInstructions, type CountQuery, type CountInstructions as CountQueryInstructions, type CreateQuery, DDL_QUERY_TYPES, DML_QUERY_TYPES, DML_QUERY_TYPES_READ, DML_QUERY_TYPES_WRITE, type DropQuery, type ExpandedResult, type GetInstructions, type GetQuery, type GetInstructions as GetQueryInstructions, type PublicModel as Model, type ModelField, type ModelIndex, type ModelPreset, type ModelTrigger, QUERY_SYMBOLS, QUERY_TYPES, type Query, type QueryInstructionType as QueryInstruction, type QuerySchemaType, type QueryType, CLEAN_ROOT_MODEL as ROOT_MODEL, type RegularResult, type RemoveInstructions, type RemoveQuery, type RemoveInstructions as RemoveQueryInstructions, type Result, type ResultRecord, type ResultRecordBase, RoninError, type SetInstructions, type SetQuery, type SetInstructions as SetQueryInstructions, type Statement, type StoredObject, Transaction, type WithInstruction, getQuerySymbol };
package/dist/index.js CHANGED
@@ -379,7 +379,7 @@ var handleOrderedBy = (model, instruction) => {
379
379
  };
380
380
 
381
381
  // src/instructions/selecting.ts
382
- var handleSelecting = (models, model, statementParams, single, instructions, options = { inlineDefaults: false }) => {
382
+ var handleSelecting = (models, model, statementParams, single, instructions, queryType, options = { inlineDefaults: false }) => {
383
383
  let isJoining = false;
384
384
  const selectedFields = filterSelectedFields(
385
385
  model,
@@ -403,9 +403,9 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
403
403
  for (const [key, value] of Object.entries(flatObject)) {
404
404
  const symbol2 = getQuerySymbol(value);
405
405
  if (symbol2?.type === "query") {
406
- const { queryType, queryModel, queryInstructions } = splitQuery(symbol2.value);
406
+ const { queryType: queryType2, queryModel, queryInstructions } = splitQuery(symbol2.value);
407
407
  const subQueryModel = getModelBySlug(models, queryModel);
408
- if (queryType === "count") {
408
+ if (queryType2 === "count") {
409
409
  const subSelect = compileQueryInput(symbol2.value, models, statementParams, {
410
410
  parentModel: { ...model, tableAlias: model.table },
411
411
  inlineDefaults: options.inlineDefaults
@@ -432,6 +432,7 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
432
432
  selecting: queryInstructions?.selecting,
433
433
  including: queryInstructions?.including
434
434
  },
435
+ queryType2,
435
436
  { ...options, mountingPath: subMountingPath }
436
437
  );
437
438
  if (nestedColumns !== "*") joinedColumns.push(nestedColumns);
@@ -454,6 +455,15 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
454
455
  });
455
456
  }
456
457
  }
458
+ if (queryType === "get" && !single && !selectedFields.some((field) => field.slug === "ronin.createdAt")) {
459
+ selectedFields.push({
460
+ ...getSystemFields(model.idPrefix)["ronin.createdAt"],
461
+ slug: "ronin.createdAt",
462
+ // @ts-expect-error - This is a valid field but not in the types atm.
463
+ drop: true,
464
+ mountingPath: "ronin.createdAt"
465
+ });
466
+ }
457
467
  const columns = selectedFields.map((selectedField) => {
458
468
  if (selectedField.mountedValue) {
459
469
  return `${selectedField.mountedValue} as "${selectedField.slug}"`;
@@ -1077,6 +1087,18 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
1077
1087
  }
1078
1088
  });
1079
1089
  }
1090
+ if (!single && (queryType === "get" && instructions?.limitedTo || queryType === "count" && (instructions?.before || instructions?.after))) {
1091
+ instructions = instructions || {};
1092
+ instructions.orderedBy = instructions.orderedBy || {};
1093
+ instructions.orderedBy.ascending = instructions.orderedBy.ascending || [];
1094
+ instructions.orderedBy.descending = instructions.orderedBy.descending || [];
1095
+ if (![
1096
+ ...instructions.orderedBy.ascending,
1097
+ ...instructions.orderedBy.descending
1098
+ ].includes("ronin.createdAt")) {
1099
+ instructions.orderedBy.descending.push("ronin.createdAt");
1100
+ }
1101
+ }
1080
1102
  const { columns, isJoining, selectedFields } = handleSelecting(
1081
1103
  models,
1082
1104
  model,
@@ -1086,6 +1108,7 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
1086
1108
  selecting: instructions?.selecting,
1087
1109
  including: instructions?.including
1088
1110
  },
1111
+ queryType,
1089
1112
  // biome-ignore lint/complexity/useSimplifiedLogicExpression: This is needed.
1090
1113
  { inlineDefaults: options?.inlineDefaults || false }
1091
1114
  );
@@ -1156,18 +1179,6 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
1156
1179
  );
1157
1180
  if (withStatement.length > 0) conditions.push(withStatement);
1158
1181
  }
1159
- if (!single && (queryType === "get" && instructions?.limitedTo || queryType === "count" && (instructions?.before || instructions?.after))) {
1160
- instructions = instructions || {};
1161
- instructions.orderedBy = instructions.orderedBy || {};
1162
- instructions.orderedBy.ascending = instructions.orderedBy.ascending || [];
1163
- instructions.orderedBy.descending = instructions.orderedBy.descending || [];
1164
- if (![
1165
- ...instructions.orderedBy.ascending,
1166
- ...instructions.orderedBy.descending
1167
- ].includes("ronin.createdAt")) {
1168
- instructions.orderedBy.descending.push("ronin.createdAt");
1169
- }
1170
- }
1171
1182
  if (instructions && (typeof instructions.before !== "undefined" || typeof instructions.after !== "undefined")) {
1172
1183
  if (single) {
1173
1184
  throw new RoninError({
@@ -2308,6 +2319,19 @@ var Transaction = class {
2308
2319
  );
2309
2320
  }
2310
2321
  }
2322
+ const createdAtDrop = selectedFields.some(
2323
+ (field) => (
2324
+ // @ts-expect-error - This is a valid field but not in the types atm.
2325
+ field.slug === "ronin.createdAt" && field.drop === true
2326
+ )
2327
+ );
2328
+ if (createdAtDrop) {
2329
+ for (const record of result.records) {
2330
+ if (record.ronin) {
2331
+ record.ronin = void 0;
2332
+ }
2333
+ }
2334
+ }
2311
2335
  return result;
2312
2336
  }
2313
2337
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronin/compiler",
3
- "version": "0.17.18",
3
+ "version": "0.17.19-corny-pagination-bug-experimental-411",
4
4
  "type": "module",
5
5
  "description": "Compiles RONIN queries to SQL statements.",
6
6
  "publishConfig": {