@resolveio/server-lib 20.14.5 → 20.14.7
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/fixtures/cron-jobs.js +20 -3
- package/fixtures/cron-jobs.js.map +1 -1
- package/methods/ai-terminal.js +125 -12
- package/methods/ai-terminal.js.map +1 -1
- package/methods/cron-jobs.js +205 -0
- package/methods/cron-jobs.js.map +1 -1
- package/methods/report-builder.js +91 -13
- package/methods/report-builder.js.map +1 -1
- package/methods.ts +3 -0
- package/package.json +1 -1
|
@@ -1844,6 +1844,8 @@ function buildReportBuilderSystemPrompt(reportType) {
|
|
|
1844
1844
|
'When available_fields spans multiple collections, choose collection_root first and then select fields whose collection_name matches collection_root or a join alias.',
|
|
1845
1845
|
'Prefer exact field_path values from available_fields; never invent field paths.',
|
|
1846
1846
|
'Translate the request into concrete layout_columns, groups_row, sort, totals, filters, and links whenever possible.',
|
|
1847
|
+
'Every layout column must be complete: include a header plus at least one mapping with a valid field_path (or text mode with non-empty text). Do not return columns without mapped fields.',
|
|
1848
|
+
'Unless the user explicitly asks for a different order, add sort entries for the primary grouping/identifier fields (groups_row or the first key layout_columns) using ascending order so results are alphabetical.',
|
|
1847
1849
|
'If the request specifies a time grain (daily/weekly/monthly/etc), set date_interval and id_date_field to the best matching date field.',
|
|
1848
1850
|
'If you need sample records to confirm field choices, you may return JSON with {"mongo_read": { "collection": "<collection>", "query": {}, "options": {"limit": 5} }, "notes": "why you need data"} .',
|
|
1849
1851
|
'Only request mongo_read when necessary and only use collections from available_collections.',
|
|
@@ -2316,20 +2318,25 @@ function sanitizeReportBuilderPatch(raw, ctx) {
|
|
|
2316
2318
|
return;
|
|
2317
2319
|
}
|
|
2318
2320
|
var header = normalizeOptionalString(col.header || col.title || col.name);
|
|
2319
|
-
var fieldPath = resolveFieldPath(col.field_path || col.fieldPath, ctx);
|
|
2321
|
+
var fieldPath = resolveFieldPath(col.field_path || col.fieldPath || col.field || col.field_name || col.fieldName || col.path, ctx);
|
|
2322
|
+
if (!fieldPath && header) {
|
|
2323
|
+
fieldPath = resolveFieldPath(header, ctx);
|
|
2324
|
+
}
|
|
2320
2325
|
var mappingsRaw = Array.isArray(col.mappings) ? col.mappings : [];
|
|
2321
2326
|
var mappings = [];
|
|
2322
2327
|
mappingsRaw.forEach(function (map) {
|
|
2323
|
-
var mappedField = resolveFieldPath((map === null || map === void 0 ? void 0 : map.field_path) || (map === null || map === void 0 ? void 0 : map.fieldPath), ctx);
|
|
2328
|
+
var mappedField = resolveFieldPath((map === null || map === void 0 ? void 0 : map.field_path) || (map === null || map === void 0 ? void 0 : map.fieldPath) || (map === null || map === void 0 ? void 0 : map.field) || (map === null || map === void 0 ? void 0 : map.field_name) || (map === null || map === void 0 ? void 0 : map.fieldName) || (map === null || map === void 0 ? void 0 : map.path) || (map === null || map === void 0 ? void 0 : map.name), ctx);
|
|
2324
2329
|
var mode = normalizeLayoutMode(map === null || map === void 0 ? void 0 : map.mode);
|
|
2325
2330
|
var text = normalizeOptionalString(map === null || map === void 0 ? void 0 : map.text);
|
|
2326
2331
|
var collection = resolveCollectionName(map === null || map === void 0 ? void 0 : map.collection, ctx);
|
|
2327
2332
|
if (mode === 'text') {
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
+
if (text) {
|
|
2334
|
+
mappings.push({
|
|
2335
|
+
mode: mode,
|
|
2336
|
+
text: text,
|
|
2337
|
+
collection: collection
|
|
2338
|
+
});
|
|
2339
|
+
}
|
|
2333
2340
|
}
|
|
2334
2341
|
else if (mappedField) {
|
|
2335
2342
|
mappings.push({
|
|
@@ -2342,10 +2349,33 @@ function sanitizeReportBuilderPatch(raw, ctx) {
|
|
|
2342
2349
|
});
|
|
2343
2350
|
}
|
|
2344
2351
|
});
|
|
2345
|
-
if (!mappings.length
|
|
2346
|
-
|
|
2352
|
+
if (!mappings.length) {
|
|
2353
|
+
if (fieldPath) {
|
|
2354
|
+
mappings.push({ field_path: fieldPath, mode: normalizeLayoutMode(col.mode) });
|
|
2355
|
+
}
|
|
2356
|
+
else {
|
|
2357
|
+
var text = normalizeOptionalString(col.text);
|
|
2358
|
+
var mode = normalizeLayoutMode(col.mode);
|
|
2359
|
+
if ((mode === 'text' || text) && text) {
|
|
2360
|
+
mappings.push({
|
|
2361
|
+
mode: 'text',
|
|
2362
|
+
text: text,
|
|
2363
|
+
collection: resolveCollectionName(col.collection, ctx)
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
if (!fieldPath) {
|
|
2369
|
+
var firstMapped = mappings.find(function (mapping) { return !!(mapping === null || mapping === void 0 ? void 0 : mapping.field_path); });
|
|
2370
|
+
if (firstMapped === null || firstMapped === void 0 ? void 0 : firstMapped.field_path) {
|
|
2371
|
+
fieldPath = firstMapped.field_path;
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
if (!header && fieldPath) {
|
|
2375
|
+
var meta = ctx.fieldIndex.get(normalizePathKey(fieldPath));
|
|
2376
|
+
header = normalizeOptionalString(meta === null || meta === void 0 ? void 0 : meta.field_path_name);
|
|
2347
2377
|
}
|
|
2348
|
-
if (!
|
|
2378
|
+
if (!mappings.length) {
|
|
2349
2379
|
return;
|
|
2350
2380
|
}
|
|
2351
2381
|
layoutColumns.push({
|
|
@@ -2421,6 +2451,12 @@ function sanitizeReportBuilderPatch(raw, ctx) {
|
|
|
2421
2451
|
if (sort.length) {
|
|
2422
2452
|
patch.sort = sort;
|
|
2423
2453
|
}
|
|
2454
|
+
else {
|
|
2455
|
+
var defaultSortFields = buildDefaultSortFields(groupsRow, layoutColumns);
|
|
2456
|
+
if (defaultSortFields.length) {
|
|
2457
|
+
patch.sort = defaultSortFields.map(function (field_path) { return ({ field_path: field_path, order: 'asc' }); });
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2424
2460
|
var totalsRaw = Array.isArray(raw.totals) ? raw.totals : [];
|
|
2425
2461
|
var totals = [];
|
|
2426
2462
|
totalsRaw.forEach(function (total) {
|
|
@@ -2462,6 +2498,48 @@ function sanitizeReportBuilderPatch(raw, ctx) {
|
|
|
2462
2498
|
}
|
|
2463
2499
|
return patch;
|
|
2464
2500
|
}
|
|
2501
|
+
function buildDefaultSortFields(groupsRow, layoutColumns) {
|
|
2502
|
+
var fields = [];
|
|
2503
|
+
var addField = function (fieldPath) {
|
|
2504
|
+
var normalized = normalizeOptionalString(fieldPath);
|
|
2505
|
+
if (normalized && !fields.includes(normalized)) {
|
|
2506
|
+
fields.push(normalized);
|
|
2507
|
+
}
|
|
2508
|
+
};
|
|
2509
|
+
(groupsRow || []).forEach(addField);
|
|
2510
|
+
if (fields.length) {
|
|
2511
|
+
return fields;
|
|
2512
|
+
}
|
|
2513
|
+
(layoutColumns || []).forEach(function (col) {
|
|
2514
|
+
var e_3, _a;
|
|
2515
|
+
if (!col || typeof col !== 'object') {
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
var fieldPath = '';
|
|
2519
|
+
var mappings = Array.isArray(col.mappings) ? col.mappings : [];
|
|
2520
|
+
try {
|
|
2521
|
+
for (var mappings_1 = __values(mappings), mappings_1_1 = mappings_1.next(); !mappings_1_1.done; mappings_1_1 = mappings_1.next()) {
|
|
2522
|
+
var mapping = mappings_1_1.value;
|
|
2523
|
+
if (mapping === null || mapping === void 0 ? void 0 : mapping.field_path) {
|
|
2524
|
+
fieldPath = mapping.field_path;
|
|
2525
|
+
break;
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
2530
|
+
finally {
|
|
2531
|
+
try {
|
|
2532
|
+
if (mappings_1_1 && !mappings_1_1.done && (_a = mappings_1.return)) _a.call(mappings_1);
|
|
2533
|
+
}
|
|
2534
|
+
finally { if (e_3) throw e_3.error; }
|
|
2535
|
+
}
|
|
2536
|
+
if (!fieldPath && col.field_path) {
|
|
2537
|
+
fieldPath = col.field_path;
|
|
2538
|
+
}
|
|
2539
|
+
addField(fieldPath);
|
|
2540
|
+
});
|
|
2541
|
+
return fields;
|
|
2542
|
+
}
|
|
2465
2543
|
function buildPatchNotes(patch, meta) {
|
|
2466
2544
|
var columns = Array.isArray(patch === null || patch === void 0 ? void 0 : patch.layout_columns) ? patch.layout_columns.length : 0;
|
|
2467
2545
|
var groups = Array.isArray(patch === null || patch === void 0 ? void 0 : patch.groups_row) ? patch.groups_row.length : 0;
|
|
@@ -2644,7 +2722,7 @@ function safeJsonParse(value) {
|
|
|
2644
2722
|
}
|
|
2645
2723
|
}
|
|
2646
2724
|
function evaluateReportBuilderGuardrails(message) {
|
|
2647
|
-
var
|
|
2725
|
+
var e_4, _a;
|
|
2648
2726
|
var normalized = String(message || '').toLowerCase();
|
|
2649
2727
|
var patterns = [
|
|
2650
2728
|
{ pattern: /\b(source\s*code|full\s*code|entire\s*code|repo\s*dump|repository|git\s*clone)\b/i, reason: 'Code access is restricted.' },
|
|
@@ -2666,12 +2744,12 @@ function evaluateReportBuilderGuardrails(message) {
|
|
|
2666
2744
|
}
|
|
2667
2745
|
}
|
|
2668
2746
|
}
|
|
2669
|
-
catch (
|
|
2747
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
2670
2748
|
finally {
|
|
2671
2749
|
try {
|
|
2672
2750
|
if (patterns_1_1 && !patterns_1_1.done && (_a = patterns_1.return)) _a.call(patterns_1);
|
|
2673
2751
|
}
|
|
2674
|
-
finally { if (
|
|
2752
|
+
finally { if (e_4) throw e_4.error; }
|
|
2675
2753
|
}
|
|
2676
2754
|
return null;
|
|
2677
2755
|
}
|