theprogrammablemind 9.5.1-beta.21 → 9.5.1-beta.22
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/client.js +2 -2
- package/package.json +1 -2
- package/runtime.js +0 -1
- package/src/helpers.js +47 -2
package/client.js
CHANGED
|
@@ -12,9 +12,8 @@ const _ = require('lodash')
|
|
|
12
12
|
const stringify = require('json-stable-stringify')
|
|
13
13
|
const Lines = require('./lines')
|
|
14
14
|
const flattens = require('./src/flatten')
|
|
15
|
-
const { appendNoDups, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps } = require('./src/helpers')
|
|
15
|
+
const { sortJson, appendNoDups, updateQueries, safeNoDups, stableId, where, suggestAssociationsFix, suggestAssociationsFixFromSummaries, validProps } = require('./src/helpers')
|
|
16
16
|
const runtime = require('./runtime')
|
|
17
|
-
const sortJson = runtime.sortJson
|
|
18
17
|
const debug = require('./src/debug')
|
|
19
18
|
|
|
20
19
|
const getConfig_getObjectsCheck = (config, testConfig) => {
|
|
@@ -69,6 +68,7 @@ const pickObjects = (config, testConfig, getObjects) => {
|
|
|
69
68
|
if (!objects) {
|
|
70
69
|
throw new Error(`In the checks for ${config.name} the KM ${km} does not exist`)
|
|
71
70
|
}
|
|
71
|
+
|
|
72
72
|
if (checks[km] && checks[km].find((check) => check.match && check.apply)) {
|
|
73
73
|
projection[km] = project2(objects, checks[km])
|
|
74
74
|
} else {
|
package/package.json
CHANGED
package/runtime.js
CHANGED
package/src/helpers.js
CHANGED
|
@@ -292,8 +292,53 @@ const hashCode = (str) => {
|
|
|
292
292
|
return hash
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Recursively sorts object keys alphabetically.
|
|
297
|
+
* Fully handles arrays (including objects inside arrays) and preserves Date/other non-plain objects.
|
|
298
|
+
*
|
|
299
|
+
* @param {any} input - The value to sort (object, array, primitive, etc.)
|
|
300
|
+
* @param {Object} [options]
|
|
301
|
+
* - ignoreCase: boolean (default false) – case-insensitive sort
|
|
302
|
+
* - reverse: boolean (default false) – reverse alphabetical order
|
|
303
|
+
* @returns {any} New sorted value
|
|
304
|
+
*/
|
|
305
|
+
function sortJson(input, options = {}) {
|
|
306
|
+
const { ignoreCase = false, reverse = false } = options;
|
|
307
|
+
|
|
308
|
+
// Helper: is this a plain object {} (not Array, Date, Map, null, etc.)
|
|
309
|
+
function isPlainObject(value) {
|
|
310
|
+
return value !== null && typeof value === 'object' && value.constructor === Object;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Handle arrays: map over elements and recurse
|
|
314
|
+
if (Array.isArray(input)) {
|
|
315
|
+
return input.map(item => sortJson(item, options));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// If not a plain object, return unchanged (preserves Date, Map, Set, primitives, etc.)
|
|
319
|
+
if (!isPlainObject(input)) {
|
|
320
|
+
return input;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Sorter for keys
|
|
324
|
+
const sorter = (a, b) => {
|
|
325
|
+
const A = ignoreCase ? a.toLowerCase() : a;
|
|
326
|
+
const B = ignoreCase ? b.toLowerCase() : b;
|
|
327
|
+
return reverse ? B.localeCompare(A) : A.localeCompare(B);
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// Build new sorted object
|
|
331
|
+
const sorted = {};
|
|
332
|
+
|
|
333
|
+
Object.keys(input)
|
|
334
|
+
.sort(sorter)
|
|
335
|
+
.forEach(key => {
|
|
336
|
+
const value = input[key];
|
|
337
|
+
// Always recurse: handles nested objects and arrays properly
|
|
338
|
+
sorted[key] = sortJson(value, options);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
return sorted;
|
|
297
342
|
}
|
|
298
343
|
|
|
299
344
|
const validProps = (valids, object, type) => {
|