@ronin/compiler 0.17.19-corny-pagination-bug-experimental-411 → 0.17.19-corny-pagination-bug-experimental-413
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 +32 -16
- 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}`;
|
@@ -430,7 +427,8 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
|
|
430
427
|
subSingle,
|
431
428
|
{
|
432
429
|
selecting: queryInstructions?.selecting,
|
433
|
-
including: queryInstructions?.including
|
430
|
+
including: queryInstructions?.including,
|
431
|
+
limitedTo: instructions.limitedTo
|
434
432
|
},
|
435
433
|
queryType2,
|
436
434
|
{ ...options, mountingPath: subMountingPath }
|
@@ -455,11 +453,10 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
|
|
455
453
|
});
|
456
454
|
}
|
457
455
|
}
|
458
|
-
if (queryType === "get" && !single && !selectedFields.some((field) => field.slug === "ronin.createdAt")) {
|
456
|
+
if (queryType === "get" && !single && !selectedFields.some((field) => field.slug === "ronin.createdAt") && instructions.limitedTo) {
|
459
457
|
selectedFields.push({
|
460
458
|
...getSystemFields(model.idPrefix)["ronin.createdAt"],
|
461
459
|
slug: "ronin.createdAt",
|
462
|
-
// @ts-expect-error - This is a valid field but not in the types atm.
|
463
460
|
drop: true,
|
464
461
|
mountingPath: "ronin.createdAt"
|
465
462
|
});
|
@@ -2319,16 +2316,35 @@ var Transaction = class {
|
|
2319
2316
|
);
|
2320
2317
|
}
|
2321
2318
|
}
|
2322
|
-
const
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2319
|
+
const fieldsToDrop = selectedFields.filter((field) => field.drop === true);
|
2320
|
+
const deleteNestedProperty = (obj, path) => {
|
2321
|
+
const parts = path.split(".");
|
2322
|
+
const lastPart = parts.pop();
|
2323
|
+
let current = obj;
|
2324
|
+
for (const part of parts) {
|
2325
|
+
if (!current || typeof current !== "object") return;
|
2326
|
+
const currentAsRecord = current;
|
2327
|
+
if (!(part in currentAsRecord)) return;
|
2328
|
+
current = currentAsRecord[part];
|
2329
|
+
}
|
2330
|
+
if (typeof current === "object" && current !== null) {
|
2331
|
+
delete current[lastPart];
|
2332
|
+
}
|
2333
|
+
if (parts.length > 0 && typeof current === "object" && current !== null && Object.keys(current).length === 0) {
|
2334
|
+
let temp = obj;
|
2335
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
2336
|
+
temp = temp[parts[i]];
|
2337
|
+
}
|
2338
|
+
const lastPart2 = parts.at(-1);
|
2339
|
+
if (lastPart2) {
|
2340
|
+
delete temp[lastPart2];
|
2341
|
+
}
|
2342
|
+
}
|
2343
|
+
};
|
2344
|
+
if (fieldsToDrop.length > 0) {
|
2329
2345
|
for (const record of result.records) {
|
2330
|
-
|
2331
|
-
record.
|
2346
|
+
for (const field of fieldsToDrop) {
|
2347
|
+
deleteNestedProperty(record, field.slug);
|
2332
2348
|
}
|
2333
2349
|
}
|
2334
2350
|
}
|
package/package.json
CHANGED