@ronin/compiler 0.17.21-corny-pagination-bug-experimental-423 → 0.17.21-leo-pagination-bug-experimental-425
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 +1 -1
- package/dist/index.js +33 -32
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -258,7 +258,7 @@ type InternalModelField = ModelField & {
|
|
|
258
258
|
mountingPath: string;
|
|
259
259
|
/** A custom value that was provided in the query, which is not stored in the DB. */
|
|
260
260
|
mountedValue?: unknown;
|
|
261
|
-
/**
|
|
261
|
+
/** If this is set, the field is used during formatting, but not exposed afterward. */
|
|
262
262
|
excluded?: boolean;
|
|
263
263
|
};
|
|
264
264
|
type ModelIndexField<T extends ModelEntityList<ModelField> = ModelEntityList<ModelField>> = {
|
package/dist/index.js
CHANGED
|
@@ -141,8 +141,11 @@ var omit = (obj, properties) => Object.fromEntries(
|
|
|
141
141
|
var getProperty = (obj, path) => {
|
|
142
142
|
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
143
143
|
};
|
|
144
|
+
var getPathSegments = (path) => {
|
|
145
|
+
return path.split(/[.[\]]/g).filter((segment) => segment.trim().length > 0);
|
|
146
|
+
};
|
|
144
147
|
var setProperty = (obj, path, value) => {
|
|
145
|
-
const segments = path
|
|
148
|
+
const segments = getPathSegments(path);
|
|
146
149
|
const _set = (node) => {
|
|
147
150
|
if (segments.length > 1) {
|
|
148
151
|
const key = segments.shift();
|
|
@@ -157,36 +160,26 @@ var setProperty = (obj, path, value) => {
|
|
|
157
160
|
};
|
|
158
161
|
_set(obj);
|
|
159
162
|
};
|
|
163
|
+
var deleteProperty = (obj, path) => {
|
|
164
|
+
const segments = getPathSegments(path);
|
|
165
|
+
const _delete = (node, segs) => {
|
|
166
|
+
const key = segs[0];
|
|
167
|
+
if (segs.length === 1) {
|
|
168
|
+
delete node[key];
|
|
169
|
+
} else if (node[key] && typeof node[key] === "object" && node[key] !== null) {
|
|
170
|
+
const shouldCleanup = _delete(node[key], segs.slice(1));
|
|
171
|
+
if (shouldCleanup) delete node[key];
|
|
172
|
+
}
|
|
173
|
+
return Object.keys(node).length === 0;
|
|
174
|
+
};
|
|
175
|
+
_delete(obj, segments);
|
|
176
|
+
};
|
|
160
177
|
var splitQuery = (query) => {
|
|
161
178
|
const queryType = Object.keys(query)[0];
|
|
162
179
|
const queryModel = Object.keys(query[queryType])[0];
|
|
163
180
|
const queryInstructions = query[queryType][queryModel];
|
|
164
181
|
return { queryType, queryModel, queryInstructions };
|
|
165
182
|
};
|
|
166
|
-
function deleteNestedProperty(obj, path) {
|
|
167
|
-
const parts = path.split(".");
|
|
168
|
-
const lastPart = parts.pop();
|
|
169
|
-
let current = obj;
|
|
170
|
-
for (const part of parts) {
|
|
171
|
-
if (!current || typeof current !== "object") return;
|
|
172
|
-
const currentAsRecord = current;
|
|
173
|
-
if (!(part in currentAsRecord)) return;
|
|
174
|
-
current = currentAsRecord[part];
|
|
175
|
-
}
|
|
176
|
-
if (typeof current === "object" && current !== null) {
|
|
177
|
-
delete current[lastPart];
|
|
178
|
-
}
|
|
179
|
-
if (parts.length > 0 && typeof current === "object" && current !== null && Object.keys(current).length === 0) {
|
|
180
|
-
let temp = obj;
|
|
181
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
182
|
-
temp = temp[parts[i]];
|
|
183
|
-
}
|
|
184
|
-
const lastPart2 = parts.at(-1);
|
|
185
|
-
if (lastPart2) {
|
|
186
|
-
delete temp[lastPart2];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
183
|
|
|
191
184
|
// src/utils/pagination.ts
|
|
192
185
|
var CURSOR_SEPARATOR = ",";
|
|
@@ -455,6 +448,7 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
|
|
|
455
448
|
{
|
|
456
449
|
selecting: queryInstructions?.selecting,
|
|
457
450
|
including: queryInstructions?.including,
|
|
451
|
+
orderedBy: queryInstructions?.orderedBy,
|
|
458
452
|
limitedTo: instructions.limitedTo
|
|
459
453
|
},
|
|
460
454
|
queryType2,
|
|
@@ -480,13 +474,19 @@ var handleSelecting = (models, model, statementParams, single, instructions, que
|
|
|
480
474
|
});
|
|
481
475
|
}
|
|
482
476
|
}
|
|
483
|
-
if (queryType === "get" && !single &&
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
slug: "ronin.createdAt",
|
|
487
|
-
excluded: true,
|
|
488
|
-
mountingPath: "ronin.createdAt"
|
|
477
|
+
if (queryType === "get" && !single && typeof instructions.limitedTo !== "undefined") {
|
|
478
|
+
const orderedFields = Object.values(instructions.orderedBy || {}).flat().map((fieldSlug) => {
|
|
479
|
+
return getFieldFromModel(model, fieldSlug, { instructionName: "orderedBy" });
|
|
489
480
|
});
|
|
481
|
+
for (const orderedField of orderedFields) {
|
|
482
|
+
const { field } = orderedField;
|
|
483
|
+
if (selectedFields.some(({ slug }) => slug === field.slug)) continue;
|
|
484
|
+
selectedFields.push({
|
|
485
|
+
slug: field.slug,
|
|
486
|
+
mountingPath: field.slug,
|
|
487
|
+
excluded: true
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
490
|
}
|
|
491
491
|
const columns = selectedFields.map((selectedField) => {
|
|
492
492
|
if (selectedField.mountedValue) {
|
|
@@ -1131,6 +1131,7 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
|
1131
1131
|
{
|
|
1132
1132
|
selecting: instructions?.selecting,
|
|
1133
1133
|
including: instructions?.including,
|
|
1134
|
+
orderedBy: instructions?.orderedBy,
|
|
1134
1135
|
limitedTo: instructions?.limitedTo
|
|
1135
1136
|
},
|
|
1136
1137
|
queryType,
|
|
@@ -2349,7 +2350,7 @@ var Transaction = class {
|
|
|
2349
2350
|
if (fieldsToDrop.length > 0) {
|
|
2350
2351
|
for (const record of result.records) {
|
|
2351
2352
|
for (const field of fieldsToDrop) {
|
|
2352
|
-
|
|
2353
|
+
deleteProperty(record, field.slug);
|
|
2353
2354
|
}
|
|
2354
2355
|
}
|
|
2355
2356
|
}
|
package/package.json
CHANGED