@ronin/compiler 0.17.19-corny-pagination-bug-experimental-411 → 0.17.19-corny-pagination-bug-experimental-412
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 +3 -1
- package/dist/index.js +29 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -484,7 +484,9 @@ declare class Transaction {
|
|
484
484
|
*
|
485
485
|
* @returns A formatted RONIN result for a particular query.
|
486
486
|
*/
|
487
|
-
formatIndividualResult<RecordType>(queryType: QueryType, queryInstructions: CombinedInstructions, model: Model, rows: Array<Array<RawRow>>, selectedFields: Array<InternalModelField
|
487
|
+
formatIndividualResult<RecordType>(queryType: QueryType, queryInstructions: CombinedInstructions, model: Model, rows: Array<Array<RawRow>>, selectedFields: Array<InternalModelField & {
|
488
|
+
drop?: boolean;
|
489
|
+
}>, single: boolean): RegularResult<RecordType>;
|
488
490
|
formatResults<RecordType>(results: Array<Array<ObjectRow>>, raw?: false): Array<Result<RecordType>>;
|
489
491
|
formatResults<RecordType>(results: Array<Array<RawRow>>, raw?: true): Array<Result<RecordType>>;
|
490
492
|
}
|
package/dist/index.js
CHANGED
@@ -381,10 +381,7 @@ var handleOrderedBy = (model, instruction) => {
|
|
381
381
|
// src/instructions/selecting.ts
|
382
382
|
var handleSelecting = (models, model, statementParams, single, instructions, queryType, options = { inlineDefaults: false }) => {
|
383
383
|
let isJoining = false;
|
384
|
-
const selectedFields = filterSelectedFields(
|
385
|
-
model,
|
386
|
-
instructions.selecting
|
387
|
-
).filter((field) => !(field.type === "link" && field.kind === "many")).map((field) => {
|
384
|
+
const selectedFields = filterSelectedFields(model, instructions.selecting).filter((field) => !(field.type === "link" && field.kind === "many")).map((field) => {
|
388
385
|
const newField = { ...field, mountingPath: field.slug };
|
389
386
|
if (options.mountingPath && options.mountingPath !== "ronin_root") {
|
390
387
|
newField.mountingPath = `${options.mountingPath.replace(/\{\d+\}/g, "")}.${field.slug}`;
|
@@ -459,7 +456,6 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
|
|
459
456
|
selectedFields.push({
|
460
457
|
...getSystemFields(model.idPrefix)["ronin.createdAt"],
|
461
458
|
slug: "ronin.createdAt",
|
462
|
-
// @ts-expect-error - This is a valid field but not in the types atm.
|
463
459
|
drop: true,
|
464
460
|
mountingPath: "ronin.createdAt"
|
465
461
|
});
|
@@ -2319,16 +2315,35 @@ var Transaction = class {
|
|
2319
2315
|
);
|
2320
2316
|
}
|
2321
2317
|
}
|
2322
|
-
const
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2318
|
+
const fieldsToDrop = selectedFields.filter((field) => field.drop === true);
|
2319
|
+
const deleteNestedProperty = (obj, path) => {
|
2320
|
+
const parts = path.split(".");
|
2321
|
+
const lastPart = parts.pop();
|
2322
|
+
let current = obj;
|
2323
|
+
for (const part of parts) {
|
2324
|
+
if (!current || typeof current !== "object") return;
|
2325
|
+
const currentAsRecord = current;
|
2326
|
+
if (!(part in currentAsRecord)) return;
|
2327
|
+
current = currentAsRecord[part];
|
2328
|
+
}
|
2329
|
+
if (typeof current === "object" && current !== null) {
|
2330
|
+
delete current[lastPart];
|
2331
|
+
}
|
2332
|
+
if (parts.length > 0 && typeof current === "object" && current !== null && Object.keys(current).length === 0) {
|
2333
|
+
let temp = obj;
|
2334
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
2335
|
+
temp = temp[parts[i]];
|
2336
|
+
}
|
2337
|
+
const lastPart2 = parts.at(-1);
|
2338
|
+
if (lastPart2) {
|
2339
|
+
delete temp[lastPart2];
|
2340
|
+
}
|
2341
|
+
}
|
2342
|
+
};
|
2343
|
+
if (fieldsToDrop.length > 0) {
|
2329
2344
|
for (const record of result.records) {
|
2330
|
-
|
2331
|
-
record.
|
2345
|
+
for (const field of fieldsToDrop) {
|
2346
|
+
deleteNestedProperty(record, field.slug);
|
2332
2347
|
}
|
2333
2348
|
}
|
2334
2349
|
}
|
package/package.json
CHANGED