@resolveio/server-lib 22.0.12 → 22.0.14
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/methods/ai-terminal.js +338 -140
- package/methods/ai-terminal.js.map +1 -1
- package/package.json +1 -1
package/methods/ai-terminal.js
CHANGED
|
@@ -373,7 +373,7 @@ var AI_ASSISTANT_TERM_SYNONYMS = [
|
|
|
373
373
|
var AI_ASSISTANT_REPORT_BUILDER_EXPERT_PLAYBOOK = [
|
|
374
374
|
'Report Builder Bridge Expert Playbook (execute in order for every data request):',
|
|
375
375
|
'1) Determine if data is required.',
|
|
376
|
-
'- If user asks for counts, lists, totals, trends, rankings, or "recent/last", run a
|
|
376
|
+
'- If user asks for counts, lists, totals, trends, rankings, or "recent/last", run a data directive before answering.',
|
|
377
377
|
'',
|
|
378
378
|
'Report style mapping (always apply):',
|
|
379
379
|
'- Dated report: any breakdown over time (per day/week/month/quarter/year, trends, time-series comparisons).',
|
|
@@ -388,7 +388,7 @@ var AI_ASSISTANT_REPORT_BUILDER_EXPERT_PLAYBOOK = [
|
|
|
388
388
|
'',
|
|
389
389
|
'3) Enforce permissions and scope in the directive.',
|
|
390
390
|
'- Always include permissionView.',
|
|
391
|
-
'-
|
|
391
|
+
'- Prefer module-specific permissionView routes (for example /invoice/list for invoices). Avoid /report/* routes and only use /report-builder when the user is explicitly asking about report building.',
|
|
392
392
|
'- Assume non-super-admin unless explicitly told otherwise.',
|
|
393
393
|
'- Invoice-like collections require invoice view access.',
|
|
394
394
|
'- Customer portal users must stay in their own customer scope.',
|
|
@@ -492,8 +492,8 @@ var AI_ASSISTANT_SYSTEM_PROMPT = [
|
|
|
492
492
|
'- REPORT_BUILDER_READ: {"collection":"<name>","query":{...},"options":{"projection":{...},"sort":{...},"limit":20},"permissionView":"</route>"}',
|
|
493
493
|
'- If you need grouped/aggregated data (totals by user, rankings, trends), end your response with a single line exactly in this format:',
|
|
494
494
|
'- REPORT_BUILDER_AGG: {"collection":"<name>","pipeline":[...],"options":{"allowDiskUse":true,"limit":20},"permissionView":"</route>"}',
|
|
495
|
-
'- For invoice data, set permissionView to an invoice-capable route (ex: /invoice/list
|
|
496
|
-
'- Do not use /report/* routes as permissionView for data directives; use
|
|
495
|
+
'- For invoice data, set permissionView to an invoice-capable route (ex: /invoice/list).',
|
|
496
|
+
'- Do not use /report/* routes as permissionView for data directives; use a module route that matches the collection.',
|
|
497
497
|
'- For revenue/sales/billing questions, use invoices and sum paid_total (fallback to grand_total) with date_paid and Paid/Closed status when available.',
|
|
498
498
|
'- For revenue answers, always state the metric/date basis used (paid_total/date_paid vs grand_total/date_invoice). If tool verification warns about ambiguity or partial months, call that out before totals.',
|
|
499
499
|
'- For relative date ranges (last/past/recent), include an upper bound <= $$NOW unless the user specifies a future end date.',
|
|
@@ -3319,6 +3319,51 @@ function verifyAssistantAggregateReliability(params) {
|
|
|
3319
3319
|
});
|
|
3320
3320
|
});
|
|
3321
3321
|
}
|
|
3322
|
+
function normalizeAssistantMonthBucket(value) {
|
|
3323
|
+
var _a, _b;
|
|
3324
|
+
if (value === null || value === undefined || value === '') {
|
|
3325
|
+
return '';
|
|
3326
|
+
}
|
|
3327
|
+
if (value instanceof Date) {
|
|
3328
|
+
if (Number.isNaN(value.getTime())) {
|
|
3329
|
+
return '';
|
|
3330
|
+
}
|
|
3331
|
+
return value.toISOString().slice(0, 7);
|
|
3332
|
+
}
|
|
3333
|
+
if (typeof value === 'string') {
|
|
3334
|
+
var trimmed = normalizeOptionalString(value);
|
|
3335
|
+
if (!trimmed) {
|
|
3336
|
+
return '';
|
|
3337
|
+
}
|
|
3338
|
+
var directMatch = trimmed.match(/^(\d{4})-(\d{2})(?:$|[^0-9])/);
|
|
3339
|
+
if (directMatch) {
|
|
3340
|
+
var month = Number(directMatch[2]);
|
|
3341
|
+
if (Number.isFinite(month) && month >= 1 && month <= 12) {
|
|
3342
|
+
return "".concat(directMatch[1], "-").concat(directMatch[2]);
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
var parsed = Date.parse(trimmed);
|
|
3346
|
+
if (!Number.isNaN(parsed)) {
|
|
3347
|
+
return new Date(parsed).toISOString().slice(0, 7);
|
|
3348
|
+
}
|
|
3349
|
+
return '';
|
|
3350
|
+
}
|
|
3351
|
+
if (typeof value === 'object') {
|
|
3352
|
+
var yearRaw = (_a = value === null || value === void 0 ? void 0 : value.year) !== null && _a !== void 0 ? _a : value === null || value === void 0 ? void 0 : value._year;
|
|
3353
|
+
var monthRaw = (_b = value === null || value === void 0 ? void 0 : value.month) !== null && _b !== void 0 ? _b : value === null || value === void 0 ? void 0 : value._month;
|
|
3354
|
+
var year = Number(yearRaw);
|
|
3355
|
+
var month = Number(monthRaw);
|
|
3356
|
+
if (Number.isFinite(year)
|
|
3357
|
+
&& Number.isFinite(month)
|
|
3358
|
+
&& month >= 1
|
|
3359
|
+
&& month <= 12) {
|
|
3360
|
+
var yearText = String(Math.trunc(year)).padStart(4, '0');
|
|
3361
|
+
var monthText = String(Math.trunc(month)).padStart(2, '0');
|
|
3362
|
+
return "".concat(yearText, "-").concat(monthText);
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
return '';
|
|
3366
|
+
}
|
|
3322
3367
|
function resolveAssistantMonthlyKey(documents) {
|
|
3323
3368
|
var first = Array.isArray(documents) ? documents.find(function (doc) { return doc && typeof doc === 'object'; }) : null;
|
|
3324
3369
|
if (!first) {
|
|
@@ -3326,7 +3371,7 @@ function resolveAssistantMonthlyKey(documents) {
|
|
|
3326
3371
|
}
|
|
3327
3372
|
return Object.keys(first).find(function (key) {
|
|
3328
3373
|
var value = first[key];
|
|
3329
|
-
return
|
|
3374
|
+
return !!normalizeAssistantMonthBucket(value);
|
|
3330
3375
|
}) || '';
|
|
3331
3376
|
}
|
|
3332
3377
|
function resolveAssistantNumericAmountKey(documents, monthKey) {
|
|
@@ -3357,8 +3402,8 @@ function resolveAssistantNumericAmountKey(documents, monthKey) {
|
|
|
3357
3402
|
function mapAssistantRevenueByMonth(documents, monthKey, valueKey) {
|
|
3358
3403
|
var mapped = new Map();
|
|
3359
3404
|
(Array.isArray(documents) ? documents : []).forEach(function (doc) {
|
|
3360
|
-
var month =
|
|
3361
|
-
if (!month
|
|
3405
|
+
var month = normalizeAssistantMonthBucket(doc === null || doc === void 0 ? void 0 : doc[monthKey]);
|
|
3406
|
+
if (!month) {
|
|
3362
3407
|
return;
|
|
3363
3408
|
}
|
|
3364
3409
|
var value = Number(doc === null || doc === void 0 ? void 0 : doc[valueKey]);
|
|
@@ -3435,8 +3480,8 @@ function buildAssistantMonthlyRevenueVerificationPipeline(match, dateField) {
|
|
|
3435
3480
|
function mapAssistantVerificationDocsByMonth(docs) {
|
|
3436
3481
|
var mapped = new Map();
|
|
3437
3482
|
(Array.isArray(docs) ? docs : []).forEach(function (row) {
|
|
3438
|
-
var month =
|
|
3439
|
-
if (!month
|
|
3483
|
+
var month = normalizeAssistantMonthBucket(row === null || row === void 0 ? void 0 : row.month);
|
|
3484
|
+
if (!month) {
|
|
3440
3485
|
return;
|
|
3441
3486
|
}
|
|
3442
3487
|
var paid = Number(row === null || row === void 0 ? void 0 : row.paid_total_sum);
|
|
@@ -3579,7 +3624,7 @@ function buildAssistantToolRequest(directive, payload) {
|
|
|
3579
3624
|
var base = directive.payload && typeof directive.payload === 'object' ? directive.payload : {};
|
|
3580
3625
|
var request = __assign({}, base);
|
|
3581
3626
|
if (!request.permissionView) {
|
|
3582
|
-
request.permissionView =
|
|
3627
|
+
request.permissionView = resolveDefaultAssistantPermissionView(request.collection);
|
|
3583
3628
|
}
|
|
3584
3629
|
request.permissionView = normalizeAssistantPermissionView(request.permissionView, request.collection);
|
|
3585
3630
|
if (!request.id_client) {
|
|
@@ -3593,21 +3638,53 @@ function buildAssistantToolRequest(directive, payload) {
|
|
|
3593
3638
|
}
|
|
3594
3639
|
return request;
|
|
3595
3640
|
}
|
|
3641
|
+
function resolveDefaultAssistantPermissionView(collection) {
|
|
3642
|
+
var normalizedCollection = normalizeOptionalString(collection).toLowerCase();
|
|
3643
|
+
if (!normalizedCollection) {
|
|
3644
|
+
return '/report-builder';
|
|
3645
|
+
}
|
|
3646
|
+
var base = stripVersionSuffix(normalizedCollection.startsWith('report-')
|
|
3647
|
+
? normalizedCollection.slice('report-'.length)
|
|
3648
|
+
: normalizedCollection);
|
|
3649
|
+
if (!base) {
|
|
3650
|
+
return '/report-builder';
|
|
3651
|
+
}
|
|
3652
|
+
if (requiresInvoicePermission(base)) {
|
|
3653
|
+
return '/invoice/list';
|
|
3654
|
+
}
|
|
3655
|
+
if (base.startsWith('sales-tax')) {
|
|
3656
|
+
return '/sales-tax/list';
|
|
3657
|
+
}
|
|
3658
|
+
if (base.startsWith('expense')) {
|
|
3659
|
+
return '/expense/list';
|
|
3660
|
+
}
|
|
3661
|
+
if (base.startsWith('distribution')) {
|
|
3662
|
+
return '/distribution/list';
|
|
3663
|
+
}
|
|
3664
|
+
if (base.startsWith('prospective-client')) {
|
|
3665
|
+
return '/prospective-client/list';
|
|
3666
|
+
}
|
|
3667
|
+
if (base.startsWith('client')) {
|
|
3668
|
+
return '/client/list';
|
|
3669
|
+
}
|
|
3670
|
+
if (base.startsWith('employee')) {
|
|
3671
|
+
return '/employee/list';
|
|
3672
|
+
}
|
|
3673
|
+
return '/report-builder';
|
|
3674
|
+
}
|
|
3596
3675
|
function normalizeAssistantPermissionView(permissionView, collection) {
|
|
3597
3676
|
var normalizedPermission = normalizeOptionalString(permissionView);
|
|
3598
3677
|
var normalizedCollection = normalizeOptionalString(collection);
|
|
3599
3678
|
var loweredPermission = normalizedPermission.toLowerCase();
|
|
3679
|
+
var fallbackPermission = resolveDefaultAssistantPermissionView(normalizedCollection);
|
|
3600
3680
|
if (!normalizedPermission) {
|
|
3601
|
-
return
|
|
3681
|
+
return fallbackPermission;
|
|
3602
3682
|
}
|
|
3603
3683
|
if (loweredPermission === '/report-builder' || loweredPermission.startsWith('/report-builder/')) {
|
|
3604
|
-
return
|
|
3684
|
+
return fallbackPermission;
|
|
3605
3685
|
}
|
|
3606
3686
|
if (loweredPermission === '/report' || loweredPermission.startsWith('/report/')) {
|
|
3607
|
-
|
|
3608
|
-
return '/invoice/list';
|
|
3609
|
-
}
|
|
3610
|
-
return '/report-builder';
|
|
3687
|
+
return fallbackPermission;
|
|
3611
3688
|
}
|
|
3612
3689
|
return normalizedPermission;
|
|
3613
3690
|
}
|
|
@@ -3747,18 +3824,17 @@ function applyAssistantVerificationNotes(value, toolResult) {
|
|
|
3747
3824
|
return "".concat(content, "\n\n").concat(noteLines.join('\n')).trim();
|
|
3748
3825
|
}
|
|
3749
3826
|
function applyAssistantDatedReportWindow(value, toolResult) {
|
|
3750
|
-
var _a, _b, _c;
|
|
3751
3827
|
var content = normalizeOptionalString(value);
|
|
3752
|
-
var window = (
|
|
3828
|
+
var window = resolveAssistantDatedReportWindow(toolResult);
|
|
3753
3829
|
if (!window || typeof window !== 'object') {
|
|
3754
3830
|
return content || value || '';
|
|
3755
3831
|
}
|
|
3756
|
-
var startDate = normalizeOptionalString(window.startDate);
|
|
3757
|
-
var endDate = normalizeOptionalString(window.endDate);
|
|
3832
|
+
var startDate = normalizeOptionalString(window === null || window === void 0 ? void 0 : window.startDate);
|
|
3833
|
+
var endDate = normalizeOptionalString(window === null || window === void 0 ? void 0 : window.endDate);
|
|
3758
3834
|
if (!startDate || !endDate) {
|
|
3759
3835
|
return content || value || '';
|
|
3760
3836
|
}
|
|
3761
|
-
var months = normalizeOptionalNumber(window.months);
|
|
3837
|
+
var months = normalizeOptionalNumber(window === null || window === void 0 ? void 0 : window.months);
|
|
3762
3838
|
var monthsText = months && months > 0 ? "; rolling last ".concat((0, common_1.round)(months), " month").concat((0, common_1.round)(months) === 1 ? '' : 's') : '';
|
|
3763
3839
|
var line = "Report date range (UTC): ".concat(startDate, " to ").concat(endDate).concat(monthsText, ".");
|
|
3764
3840
|
var normalizedLower = String(content || '').toLowerCase();
|
|
@@ -3770,6 +3846,56 @@ function applyAssistantDatedReportWindow(value, toolResult) {
|
|
|
3770
3846
|
}
|
|
3771
3847
|
return "".concat(line, "\n\n").concat(content).trim();
|
|
3772
3848
|
}
|
|
3849
|
+
function resolveAssistantDatedReportWindow(toolResult) {
|
|
3850
|
+
var e_1, _a;
|
|
3851
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
3852
|
+
var verificationWindow = (_d = (_c = (_b = toolResult === null || toolResult === void 0 ? void 0 : toolResult.output) === null || _b === void 0 ? void 0 : _b.verification) === null || _c === void 0 ? void 0 : _c.metrics) === null || _d === void 0 ? void 0 : _d.window;
|
|
3853
|
+
var verificationStart = normalizeOptionalString(verificationWindow === null || verificationWindow === void 0 ? void 0 : verificationWindow.startDate);
|
|
3854
|
+
var verificationEnd = normalizeOptionalString(verificationWindow === null || verificationWindow === void 0 ? void 0 : verificationWindow.endDate);
|
|
3855
|
+
if (verificationStart && verificationEnd) {
|
|
3856
|
+
return {
|
|
3857
|
+
startDate: verificationStart,
|
|
3858
|
+
endDate: verificationEnd,
|
|
3859
|
+
months: normalizeOptionalNumber(verificationWindow === null || verificationWindow === void 0 ? void 0 : verificationWindow.months) || undefined
|
|
3860
|
+
};
|
|
3861
|
+
}
|
|
3862
|
+
var pipelineCandidates = [
|
|
3863
|
+
(_f = (_e = toolResult === null || toolResult === void 0 ? void 0 : toolResult.output) === null || _e === void 0 ? void 0 : _e.debug) === null || _f === void 0 ? void 0 : _f.executedPipeline,
|
|
3864
|
+
(_h = (_g = toolResult === null || toolResult === void 0 ? void 0 : toolResult.output) === null || _g === void 0 ? void 0 : _g.debug) === null || _h === void 0 ? void 0 : _h.originalPipeline,
|
|
3865
|
+
(_j = toolResult === null || toolResult === void 0 ? void 0 : toolResult.input) === null || _j === void 0 ? void 0 : _j.pipeline
|
|
3866
|
+
];
|
|
3867
|
+
try {
|
|
3868
|
+
for (var pipelineCandidates_1 = __values(pipelineCandidates), pipelineCandidates_1_1 = pipelineCandidates_1.next(); !pipelineCandidates_1_1.done; pipelineCandidates_1_1 = pipelineCandidates_1.next()) {
|
|
3869
|
+
var candidate = pipelineCandidates_1_1.value;
|
|
3870
|
+
if (!Array.isArray(candidate)) {
|
|
3871
|
+
continue;
|
|
3872
|
+
}
|
|
3873
|
+
var rollingWindow = detectAssistantRollingMonthWindow(candidate);
|
|
3874
|
+
if (!(rollingWindow === null || rollingWindow === void 0 ? void 0 : rollingWindow.months) || !(rollingWindow === null || rollingWindow === void 0 ? void 0 : rollingWindow.upperNow)) {
|
|
3875
|
+
continue;
|
|
3876
|
+
}
|
|
3877
|
+
var bounds = resolveAssistantRollingWindowBounds(rollingWindow.months);
|
|
3878
|
+
var startDate = formatAssistantIsoDateOnly(bounds.rollingStart);
|
|
3879
|
+
var endDate = formatAssistantIsoDateOnly(bounds.now);
|
|
3880
|
+
if (!startDate || !endDate) {
|
|
3881
|
+
continue;
|
|
3882
|
+
}
|
|
3883
|
+
return {
|
|
3884
|
+
startDate: startDate,
|
|
3885
|
+
endDate: endDate,
|
|
3886
|
+
months: rollingWindow.months
|
|
3887
|
+
};
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3891
|
+
finally {
|
|
3892
|
+
try {
|
|
3893
|
+
if (pipelineCandidates_1_1 && !pipelineCandidates_1_1.done && (_a = pipelineCandidates_1.return)) _a.call(pipelineCandidates_1);
|
|
3894
|
+
}
|
|
3895
|
+
finally { if (e_1) throw e_1.error; }
|
|
3896
|
+
}
|
|
3897
|
+
return null;
|
|
3898
|
+
}
|
|
3773
3899
|
function buildAssistantDebugPayload(params) {
|
|
3774
3900
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
3775
3901
|
var notes = [];
|
|
@@ -3939,14 +4065,13 @@ function buildAssistantToolErrorMessage(error, directive, request) {
|
|
|
3939
4065
|
var _a, _b;
|
|
3940
4066
|
var rawMessage = normalizeOptionalString(error === null || error === void 0 ? void 0 : error.message) || 'Unable to access data.';
|
|
3941
4067
|
var normalized = rawMessage.toLowerCase();
|
|
3942
|
-
var
|
|
3943
|
-
|
|
3944
|
-
var collection = normalizeOptionalString(request === null || request === void 0 ? void 0 : request.collection) || normalizeOptionalString((_b = directive.payload) === null || _b === void 0 ? void 0 : _b.collection);
|
|
4068
|
+
var collection = normalizeOptionalString(request === null || request === void 0 ? void 0 : request.collection) || normalizeOptionalString((_a = directive.payload) === null || _a === void 0 ? void 0 : _a.collection);
|
|
4069
|
+
var routeHint = resolveAssistantErrorRouteHint(normalizeOptionalString(request === null || request === void 0 ? void 0 : request.permissionView) || normalizeOptionalString((_b = directive.payload) === null || _b === void 0 ? void 0 : _b.permissionView), collection);
|
|
3945
4070
|
var routeLine = routeHint
|
|
3946
4071
|
? "Open ".concat(routeHint, " in the app to view this data or request access.")
|
|
3947
|
-
: '
|
|
4072
|
+
: 'Request access to the related module in the app.';
|
|
3948
4073
|
if (!routeHint && collection && requiresInvoicePermission(collection)) {
|
|
3949
|
-
routeLine = 'Open /invoice/list
|
|
4074
|
+
routeLine = 'Open /invoice/list in the app to view this data or request access.';
|
|
3950
4075
|
}
|
|
3951
4076
|
if (normalized.includes('permission scope required')) {
|
|
3952
4077
|
return "I need a permission scope to access that data. ".concat(routeLine);
|
|
@@ -3963,14 +4088,30 @@ function buildAssistantToolErrorMessage(error, directive, request) {
|
|
|
3963
4088
|
if (normalized.includes('undefined variable') && normalized.includes('now_minus')) {
|
|
3964
4089
|
return "The query used an unsupported relative date token. Please retry; the assistant now normalizes relative dates automatically. ".concat(routeLine);
|
|
3965
4090
|
}
|
|
4091
|
+
if (normalized.includes('invalid character for a variable name') && (normalized.includes('now-') || normalized.includes('now+'))) {
|
|
4092
|
+
return "The query used an unsupported relative date token. Please retry; the assistant now normalizes relative dates automatically. ".concat(routeLine);
|
|
4093
|
+
}
|
|
3966
4094
|
if (normalized.includes('report builder bridge') && normalized.includes('not configured')) {
|
|
3967
|
-
return "That dataset is not configured for
|
|
4095
|
+
return "That dataset is not configured for assistant data access yet. ".concat(routeLine);
|
|
3968
4096
|
}
|
|
3969
4097
|
if (normalized.includes('collection is required')) {
|
|
3970
4098
|
return 'I need a valid collection to read from. Please specify which screen or dataset you want.';
|
|
3971
4099
|
}
|
|
3972
4100
|
return "I couldn't access the requested data. ".concat(routeLine);
|
|
3973
4101
|
}
|
|
4102
|
+
function resolveAssistantErrorRouteHint(routeHint, collection) {
|
|
4103
|
+
var normalizedHint = normalizeOptionalString(routeHint);
|
|
4104
|
+
if (!normalizedHint) {
|
|
4105
|
+
var fallback = resolveDefaultAssistantPermissionView(collection);
|
|
4106
|
+
return fallback.startsWith('/report-builder') ? '' : fallback;
|
|
4107
|
+
}
|
|
4108
|
+
var loweredHint = normalizedHint.toLowerCase();
|
|
4109
|
+
if (loweredHint.startsWith('/report-builder') || loweredHint === '/report' || loweredHint.startsWith('/report/')) {
|
|
4110
|
+
var fallback = resolveDefaultAssistantPermissionView(collection);
|
|
4111
|
+
return fallback.startsWith('/report-builder') ? '' : fallback;
|
|
4112
|
+
}
|
|
4113
|
+
return normalizedHint;
|
|
4114
|
+
}
|
|
3974
4115
|
function deriveAssistantStreamStatus(event) {
|
|
3975
4116
|
var _a;
|
|
3976
4117
|
if (!event || !event.type) {
|
|
@@ -4334,7 +4475,7 @@ function getValueAtPath(obj, path) {
|
|
|
4334
4475
|
return walk(obj, 0);
|
|
4335
4476
|
}
|
|
4336
4477
|
function hasArrayValueAtPath(docs, path) {
|
|
4337
|
-
var
|
|
4478
|
+
var e_2, _a;
|
|
4338
4479
|
if (!Array.isArray(docs) || !docs.length || !path) {
|
|
4339
4480
|
return false;
|
|
4340
4481
|
}
|
|
@@ -4347,17 +4488,17 @@ function hasArrayValueAtPath(docs, path) {
|
|
|
4347
4488
|
}
|
|
4348
4489
|
}
|
|
4349
4490
|
}
|
|
4350
|
-
catch (
|
|
4491
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
4351
4492
|
finally {
|
|
4352
4493
|
try {
|
|
4353
4494
|
if (docs_1_1 && !docs_1_1.done && (_a = docs_1.return)) _a.call(docs_1);
|
|
4354
4495
|
}
|
|
4355
|
-
finally { if (
|
|
4496
|
+
finally { if (e_2) throw e_2.error; }
|
|
4356
4497
|
}
|
|
4357
4498
|
return false;
|
|
4358
4499
|
}
|
|
4359
4500
|
function inferIdFieldStorageTypeFromDocs(docs, fieldPath) {
|
|
4360
|
-
var
|
|
4501
|
+
var e_3, _a, e_4, _b;
|
|
4361
4502
|
if (!Array.isArray(docs) || !fieldPath) {
|
|
4362
4503
|
return 'unknown';
|
|
4363
4504
|
}
|
|
@@ -4370,7 +4511,7 @@ function inferIdFieldStorageTypeFromDocs(docs, fieldPath) {
|
|
|
4370
4511
|
: doc === null || doc === void 0 ? void 0 : doc[fieldPath];
|
|
4371
4512
|
var queue = Array.isArray(value) ? value : [value];
|
|
4372
4513
|
try {
|
|
4373
|
-
for (var queue_1 = (
|
|
4514
|
+
for (var queue_1 = (e_4 = void 0, __values(queue)), queue_1_1 = queue_1.next(); !queue_1_1.done; queue_1_1 = queue_1.next()) {
|
|
4374
4515
|
var entry = queue_1_1.value;
|
|
4375
4516
|
if (entry === null || entry === undefined) {
|
|
4376
4517
|
continue;
|
|
@@ -4383,21 +4524,21 @@ function inferIdFieldStorageTypeFromDocs(docs, fieldPath) {
|
|
|
4383
4524
|
}
|
|
4384
4525
|
}
|
|
4385
4526
|
}
|
|
4386
|
-
catch (
|
|
4527
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
4387
4528
|
finally {
|
|
4388
4529
|
try {
|
|
4389
4530
|
if (queue_1_1 && !queue_1_1.done && (_b = queue_1.return)) _b.call(queue_1);
|
|
4390
4531
|
}
|
|
4391
|
-
finally { if (
|
|
4532
|
+
finally { if (e_4) throw e_4.error; }
|
|
4392
4533
|
}
|
|
4393
4534
|
}
|
|
4394
4535
|
}
|
|
4395
|
-
catch (
|
|
4536
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
4396
4537
|
finally {
|
|
4397
4538
|
try {
|
|
4398
4539
|
if (docs_2_1 && !docs_2_1.done && (_a = docs_2.return)) _a.call(docs_2);
|
|
4399
4540
|
}
|
|
4400
|
-
finally { if (
|
|
4541
|
+
finally { if (e_3) throw e_3.error; }
|
|
4401
4542
|
}
|
|
4402
4543
|
return sawString ? 'string' : 'unknown';
|
|
4403
4544
|
}
|
|
@@ -4492,7 +4633,7 @@ function normalizeLookupKeyValue(value) {
|
|
|
4492
4633
|
return '';
|
|
4493
4634
|
}
|
|
4494
4635
|
function collectTopLevelIdFieldValues(docs, options) {
|
|
4495
|
-
var
|
|
4636
|
+
var e_5, _a, e_6, _b;
|
|
4496
4637
|
if (!Array.isArray(docs) || !docs.length) {
|
|
4497
4638
|
return [];
|
|
4498
4639
|
}
|
|
@@ -4540,26 +4681,26 @@ function collectTopLevelIdFieldValues(docs, options) {
|
|
|
4540
4681
|
});
|
|
4541
4682
|
};
|
|
4542
4683
|
try {
|
|
4543
|
-
for (var keys_1 = (
|
|
4684
|
+
for (var keys_1 = (e_6 = void 0, __values(keys)), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
4544
4685
|
var key = keys_1_1.value;
|
|
4545
4686
|
_loop_3(key);
|
|
4546
4687
|
}
|
|
4547
4688
|
}
|
|
4548
|
-
catch (
|
|
4689
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
4549
4690
|
finally {
|
|
4550
4691
|
try {
|
|
4551
4692
|
if (keys_1_1 && !keys_1_1.done && (_b = keys_1.return)) _b.call(keys_1);
|
|
4552
4693
|
}
|
|
4553
|
-
finally { if (
|
|
4694
|
+
finally { if (e_6) throw e_6.error; }
|
|
4554
4695
|
}
|
|
4555
4696
|
}
|
|
4556
4697
|
}
|
|
4557
|
-
catch (
|
|
4698
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
4558
4699
|
finally {
|
|
4559
4700
|
try {
|
|
4560
4701
|
if (docs_3_1 && !docs_3_1.done && (_a = docs_3.return)) _a.call(docs_3);
|
|
4561
4702
|
}
|
|
4562
|
-
finally { if (
|
|
4703
|
+
finally { if (e_5) throw e_5.error; }
|
|
4563
4704
|
}
|
|
4564
4705
|
return Array.from(fieldMap.entries()).map(function (_a) {
|
|
4565
4706
|
var _b = __read(_a, 2), field = _b[0], values = _b[1];
|
|
@@ -4570,7 +4711,7 @@ function collectTopLevelIdFieldValues(docs, options) {
|
|
|
4570
4711
|
});
|
|
4571
4712
|
}
|
|
4572
4713
|
function resolveLookupDisplayField(baseToken, probeDocs, schemaFields) {
|
|
4573
|
-
var
|
|
4714
|
+
var e_7, _a, e_8, _b;
|
|
4574
4715
|
var normalizedBase = normalizeOptionalString(baseToken);
|
|
4575
4716
|
if (!normalizedBase) {
|
|
4576
4717
|
return null;
|
|
@@ -4588,12 +4729,12 @@ function resolveLookupDisplayField(baseToken, probeDocs, schemaFields) {
|
|
|
4588
4729
|
}
|
|
4589
4730
|
}
|
|
4590
4731
|
}
|
|
4591
|
-
catch (
|
|
4732
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
4592
4733
|
finally {
|
|
4593
4734
|
try {
|
|
4594
4735
|
if (schemaCandidates_1_1 && !schemaCandidates_1_1.done && (_a = schemaCandidates_1.return)) _a.call(schemaCandidates_1);
|
|
4595
4736
|
}
|
|
4596
|
-
finally { if (
|
|
4737
|
+
finally { if (e_7) throw e_7.error; }
|
|
4597
4738
|
}
|
|
4598
4739
|
return schemaCandidates[0];
|
|
4599
4740
|
}
|
|
@@ -4606,12 +4747,12 @@ function resolveLookupDisplayField(baseToken, probeDocs, schemaFields) {
|
|
|
4606
4747
|
}
|
|
4607
4748
|
}
|
|
4608
4749
|
}
|
|
4609
|
-
catch (
|
|
4750
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
4610
4751
|
finally {
|
|
4611
4752
|
try {
|
|
4612
4753
|
if (candidates_1_1 && !candidates_1_1.done && (_b = candidates_1.return)) _b.call(candidates_1);
|
|
4613
4754
|
}
|
|
4614
|
-
finally { if (
|
|
4755
|
+
finally { if (e_8) throw e_8.error; }
|
|
4615
4756
|
}
|
|
4616
4757
|
return candidates.length ? candidates[0] : null;
|
|
4617
4758
|
}
|
|
@@ -4624,8 +4765,8 @@ function resolveLookupMappingsForField(field, mappings) {
|
|
|
4624
4765
|
}
|
|
4625
4766
|
function applyIdLookupDisplayEnrichment(params) {
|
|
4626
4767
|
return __awaiter(this, void 0, void 0, function () {
|
|
4627
|
-
var docs, collection, db, dbName, idClient, idCustomer, isSuperAdmin, idFields, lookupMappings, allCollections, collectionProbeCache, collectionSchemaCache, lookupMeta, enrichedDocs, _loop_4, idFields_1, idFields_1_1, fieldEntry,
|
|
4628
|
-
var
|
|
4768
|
+
var docs, collection, db, dbName, idClient, idCustomer, isSuperAdmin, idFields, lookupMappings, allCollections, collectionProbeCache, collectionSchemaCache, lookupMeta, enrichedDocs, _loop_4, idFields_1, idFields_1_1, fieldEntry, e_9_1;
|
|
4769
|
+
var e_9, _a;
|
|
4629
4770
|
return __generator(this, function (_b) {
|
|
4630
4771
|
switch (_b.label) {
|
|
4631
4772
|
case 0:
|
|
@@ -4649,8 +4790,8 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
4649
4790
|
lookupMeta = [];
|
|
4650
4791
|
enrichedDocs = docs.map(function (doc) { return (__assign({}, doc)); });
|
|
4651
4792
|
_loop_4 = function (fieldEntry) {
|
|
4652
|
-
var values, baseToken, mappingMatches, candidateCollections, filteredCandidates, _loop_5, filteredCandidates_1, filteredCandidates_1_1, candidate, state_3,
|
|
4653
|
-
var
|
|
4793
|
+
var values, baseToken, mappingMatches, candidateCollections, filteredCandidates, _loop_5, filteredCandidates_1, filteredCandidates_1_1, candidate, state_3, e_10_1;
|
|
4794
|
+
var e_10, _c;
|
|
4654
4795
|
return __generator(this, function (_d) {
|
|
4655
4796
|
switch (_d.label) {
|
|
4656
4797
|
case 0:
|
|
@@ -4799,7 +4940,7 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
4799
4940
|
_d.label = 1;
|
|
4800
4941
|
case 1:
|
|
4801
4942
|
_d.trys.push([1, 6, 7, 8]);
|
|
4802
|
-
filteredCandidates_1 = (
|
|
4943
|
+
filteredCandidates_1 = (e_10 = void 0, __values(filteredCandidates)), filteredCandidates_1_1 = filteredCandidates_1.next();
|
|
4803
4944
|
_d.label = 2;
|
|
4804
4945
|
case 2:
|
|
4805
4946
|
if (!!filteredCandidates_1_1.done) return [3 /*break*/, 5];
|
|
@@ -4815,14 +4956,14 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
4815
4956
|
return [3 /*break*/, 2];
|
|
4816
4957
|
case 5: return [3 /*break*/, 8];
|
|
4817
4958
|
case 6:
|
|
4818
|
-
|
|
4819
|
-
|
|
4959
|
+
e_10_1 = _d.sent();
|
|
4960
|
+
e_10 = { error: e_10_1 };
|
|
4820
4961
|
return [3 /*break*/, 8];
|
|
4821
4962
|
case 7:
|
|
4822
4963
|
try {
|
|
4823
4964
|
if (filteredCandidates_1_1 && !filteredCandidates_1_1.done && (_c = filteredCandidates_1.return)) _c.call(filteredCandidates_1);
|
|
4824
4965
|
}
|
|
4825
|
-
finally { if (
|
|
4966
|
+
finally { if (e_10) throw e_10.error; }
|
|
4826
4967
|
return [7 /*endfinally*/];
|
|
4827
4968
|
case 8: return [2 /*return*/];
|
|
4828
4969
|
}
|
|
@@ -4845,14 +4986,14 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
4845
4986
|
return [3 /*break*/, 3];
|
|
4846
4987
|
case 6: return [3 /*break*/, 9];
|
|
4847
4988
|
case 7:
|
|
4848
|
-
|
|
4849
|
-
|
|
4989
|
+
e_9_1 = _b.sent();
|
|
4990
|
+
e_9 = { error: e_9_1 };
|
|
4850
4991
|
return [3 /*break*/, 9];
|
|
4851
4992
|
case 8:
|
|
4852
4993
|
try {
|
|
4853
4994
|
if (idFields_1_1 && !idFields_1_1.done && (_a = idFields_1.return)) _a.call(idFields_1);
|
|
4854
4995
|
}
|
|
4855
|
-
finally { if (
|
|
4996
|
+
finally { if (e_9) throw e_9.error; }
|
|
4856
4997
|
return [7 /*endfinally*/];
|
|
4857
4998
|
case 9:
|
|
4858
4999
|
if (!lookupMeta.length) {
|
|
@@ -4871,7 +5012,7 @@ function applyIdLookupDisplayEnrichment(params) {
|
|
|
4871
5012
|
});
|
|
4872
5013
|
}
|
|
4873
5014
|
function hasNonEmptyValue(docs, fieldPath, options) {
|
|
4874
|
-
var
|
|
5015
|
+
var e_11, _a;
|
|
4875
5016
|
if (!Array.isArray(docs) || !fieldPath) {
|
|
4876
5017
|
return false;
|
|
4877
5018
|
}
|
|
@@ -4888,12 +5029,12 @@ function hasNonEmptyValue(docs, fieldPath, options) {
|
|
|
4888
5029
|
}
|
|
4889
5030
|
}
|
|
4890
5031
|
}
|
|
4891
|
-
catch (
|
|
5032
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
4892
5033
|
finally {
|
|
4893
5034
|
try {
|
|
4894
5035
|
if (docs_4_1 && !docs_4_1.done && (_a = docs_4.return)) _a.call(docs_4);
|
|
4895
5036
|
}
|
|
4896
|
-
finally { if (
|
|
5037
|
+
finally { if (e_11) throw e_11.error; }
|
|
4897
5038
|
}
|
|
4898
5039
|
return false;
|
|
4899
5040
|
}
|
|
@@ -5505,8 +5646,25 @@ function resolveAssistantNumericValue(value) {
|
|
|
5505
5646
|
function isAssistantPercentColumn(column) {
|
|
5506
5647
|
return /(percent|pct|percentage|ratio|rate)\b/.test(column);
|
|
5507
5648
|
}
|
|
5649
|
+
var ASSISTANT_NON_CURRENCY_COLUMN_PATTERN = /\b(invoice\s*number|count|qty|quantity|index|rank|sequence|seq|id|code|ticket|number)\b/;
|
|
5650
|
+
var ASSISTANT_CURRENCY_HINT_PATTERN = /\b(amount|price|cost|balance|fee|revenue|tax|billing|charge|payment|profit|margin|due)\b/;
|
|
5651
|
+
var ASSISTANT_MONEY_TOTAL_PATTERN = /\b(sub\s*total|subtotal|grand\s*total|paid\s*total)\b/;
|
|
5652
|
+
var ASSISTANT_TOTAL_WITH_MONEY_HINT_PATTERN = /\btotal\b.*\b(amount|revenue|sales|tax|price|cost|balance|paid|due|charge|billing|profit|margin)\b/;
|
|
5508
5653
|
function isAssistantCurrencyColumn(column) {
|
|
5509
|
-
|
|
5654
|
+
var normalized = String(column || '').toLowerCase().replace(/[_-]+/g, ' ').trim();
|
|
5655
|
+
if (!normalized) {
|
|
5656
|
+
return false;
|
|
5657
|
+
}
|
|
5658
|
+
var hasMoneyHint = ASSISTANT_CURRENCY_HINT_PATTERN.test(normalized)
|
|
5659
|
+
|| ASSISTANT_MONEY_TOTAL_PATTERN.test(normalized)
|
|
5660
|
+
|| ASSISTANT_TOTAL_WITH_MONEY_HINT_PATTERN.test(normalized);
|
|
5661
|
+
if (ASSISTANT_NON_CURRENCY_COLUMN_PATTERN.test(normalized) && !hasMoneyHint) {
|
|
5662
|
+
return false;
|
|
5663
|
+
}
|
|
5664
|
+
if (/\btotal\b/.test(normalized) && !hasMoneyHint) {
|
|
5665
|
+
return false;
|
|
5666
|
+
}
|
|
5667
|
+
return hasMoneyHint;
|
|
5510
5668
|
}
|
|
5511
5669
|
function isAssistantDateColumn(column) {
|
|
5512
5670
|
return /(date|time|created|updated|timestamp|at)\b/.test(column);
|
|
@@ -5557,6 +5715,12 @@ function formatAssistantDisplayCell(value, column) {
|
|
|
5557
5715
|
}
|
|
5558
5716
|
}
|
|
5559
5717
|
var columnKey = String(column || '').toLowerCase();
|
|
5718
|
+
if (columnKey.includes('month')) {
|
|
5719
|
+
var monthBucket = normalizeAssistantMonthBucket(value);
|
|
5720
|
+
if (monthBucket) {
|
|
5721
|
+
return monthBucket;
|
|
5722
|
+
}
|
|
5723
|
+
}
|
|
5560
5724
|
if (isAssistantDateColumn(columnKey) && isAssistantLikelyDateValue(value)) {
|
|
5561
5725
|
return formatAssistantDateValue(value);
|
|
5562
5726
|
}
|
|
@@ -5814,6 +5978,7 @@ function sanitizeAssistantProjection(projection) {
|
|
|
5814
5978
|
}
|
|
5815
5979
|
var AGG_MATCH_EXPR_OPERATORS = new Set(['$eq', '$ne', '$gt', '$gte', '$lt', '$lte']);
|
|
5816
5980
|
var ASSISTANT_NOW_RELATIVE_PATTERN = /^\$\$NOW_(MINUS|PLUS)_([0-9]+)_(MINUTES?|HOURS?|DAYS?|WEEKS?|MONTHS?|YEARS?)$/i;
|
|
5981
|
+
var ASSISTANT_NOW_RELATIVE_COMPACT_PATTERN = /^\$\$NOW([+-])([0-9]+)\s*(MINUTES?|MINS?|MIN|HOURS?|HRS?|HR|DAYS?|WEEKS?|WKS?|WK|MONTHS?|MOS?|MO|M|YEARS?|YRS?|YR|Y)$/i;
|
|
5817
5982
|
function normalizeAssistantTimeUnit(raw) {
|
|
5818
5983
|
var normalized = String(raw || '').toLowerCase();
|
|
5819
5984
|
if (normalized.startsWith('minute')) {
|
|
@@ -5833,21 +5998,54 @@ function normalizeAssistantTimeUnit(raw) {
|
|
|
5833
5998
|
}
|
|
5834
5999
|
return 'year';
|
|
5835
6000
|
}
|
|
6001
|
+
function normalizeAssistantCompactTimeUnit(raw) {
|
|
6002
|
+
var normalized = String(raw || '').toLowerCase();
|
|
6003
|
+
if (normalized === 'm' || normalized === 'mo' || normalized === 'mos' || normalized.startsWith('month')) {
|
|
6004
|
+
return 'month';
|
|
6005
|
+
}
|
|
6006
|
+
if (normalized === 'min' || normalized === 'mins' || normalized.startsWith('minute')) {
|
|
6007
|
+
return 'minute';
|
|
6008
|
+
}
|
|
6009
|
+
if (normalized === 'h' || normalized === 'hr' || normalized === 'hrs' || normalized.startsWith('hour')) {
|
|
6010
|
+
return 'hour';
|
|
6011
|
+
}
|
|
6012
|
+
if (normalized === 'd' || normalized.startsWith('day')) {
|
|
6013
|
+
return 'day';
|
|
6014
|
+
}
|
|
6015
|
+
if (normalized === 'w' || normalized === 'wk' || normalized === 'wks' || normalized.startsWith('week')) {
|
|
6016
|
+
return 'week';
|
|
6017
|
+
}
|
|
6018
|
+
return 'year';
|
|
6019
|
+
}
|
|
5836
6020
|
function parseAssistantNowRelativeToken(value) {
|
|
5837
6021
|
var trimmed = normalizeOptionalString(value);
|
|
5838
6022
|
if (!trimmed) {
|
|
5839
6023
|
return null;
|
|
5840
6024
|
}
|
|
5841
|
-
var
|
|
5842
|
-
if (
|
|
6025
|
+
var expandedMatch = trimmed.match(ASSISTANT_NOW_RELATIVE_PATTERN);
|
|
6026
|
+
if (expandedMatch) {
|
|
6027
|
+
var direction_1 = String(expandedMatch[1] || '').toUpperCase() === 'PLUS' ? 'PLUS' : 'MINUS';
|
|
6028
|
+
var amount_1 = Number(expandedMatch[2]);
|
|
6029
|
+
if (!Number.isFinite(amount_1) || amount_1 < 0) {
|
|
6030
|
+
return null;
|
|
6031
|
+
}
|
|
6032
|
+
var unit_1 = normalizeAssistantTimeUnit(expandedMatch[3] || '');
|
|
6033
|
+
return {
|
|
6034
|
+
operator: direction_1 === 'PLUS' ? '$dateAdd' : '$dateSubtract',
|
|
6035
|
+
amount: amount_1,
|
|
6036
|
+
unit: unit_1
|
|
6037
|
+
};
|
|
6038
|
+
}
|
|
6039
|
+
var compactMatch = trimmed.match(ASSISTANT_NOW_RELATIVE_COMPACT_PATTERN);
|
|
6040
|
+
if (!compactMatch) {
|
|
5843
6041
|
return null;
|
|
5844
6042
|
}
|
|
5845
|
-
var direction =
|
|
5846
|
-
var amount = Number(
|
|
6043
|
+
var direction = compactMatch[1] === '+' ? 'PLUS' : 'MINUS';
|
|
6044
|
+
var amount = Number(compactMatch[2]);
|
|
5847
6045
|
if (!Number.isFinite(amount) || amount < 0) {
|
|
5848
6046
|
return null;
|
|
5849
6047
|
}
|
|
5850
|
-
var unit =
|
|
6048
|
+
var unit = normalizeAssistantCompactTimeUnit(compactMatch[3] || '');
|
|
5851
6049
|
return {
|
|
5852
6050
|
operator: direction === 'PLUS' ? '$dateAdd' : '$dateSubtract',
|
|
5853
6051
|
amount: amount,
|
|
@@ -6175,7 +6373,7 @@ function matchContainsField(value, field) {
|
|
|
6175
6373
|
});
|
|
6176
6374
|
}
|
|
6177
6375
|
function resolveAggregateCompletionFallback(pipeline) {
|
|
6178
|
-
var
|
|
6376
|
+
var e_12, _a;
|
|
6179
6377
|
if (!Array.isArray(pipeline)) {
|
|
6180
6378
|
return null;
|
|
6181
6379
|
}
|
|
@@ -6188,7 +6386,7 @@ function resolveAggregateCompletionFallback(pipeline) {
|
|
|
6188
6386
|
}
|
|
6189
6387
|
var addFields = stage.$addFields;
|
|
6190
6388
|
try {
|
|
6191
|
-
for (var _b = (
|
|
6389
|
+
for (var _b = (e_12 = void 0, __values(Object.keys(addFields))), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6192
6390
|
var key = _c.value;
|
|
6193
6391
|
if (!isCompletionFieldName(key)) {
|
|
6194
6392
|
continue;
|
|
@@ -6202,12 +6400,12 @@ function resolveAggregateCompletionFallback(pipeline) {
|
|
|
6202
6400
|
}
|
|
6203
6401
|
}
|
|
6204
6402
|
}
|
|
6205
|
-
catch (
|
|
6403
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
6206
6404
|
finally {
|
|
6207
6405
|
try {
|
|
6208
6406
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6209
6407
|
}
|
|
6210
|
-
finally { if (
|
|
6408
|
+
finally { if (e_12) throw e_12.error; }
|
|
6211
6409
|
}
|
|
6212
6410
|
if (candidateField) {
|
|
6213
6411
|
break;
|
|
@@ -6363,7 +6561,7 @@ function buildCompletionFallbackSources(field) {
|
|
|
6363
6561
|
]);
|
|
6364
6562
|
}
|
|
6365
6563
|
function resolveAggregateCompletionExprFallback(pipeline) {
|
|
6366
|
-
var
|
|
6564
|
+
var e_13, _a;
|
|
6367
6565
|
if (!Array.isArray(pipeline)) {
|
|
6368
6566
|
return null;
|
|
6369
6567
|
}
|
|
@@ -6383,7 +6581,7 @@ function resolveAggregateCompletionExprFallback(pipeline) {
|
|
|
6383
6581
|
}
|
|
6384
6582
|
if (!candidateField) {
|
|
6385
6583
|
try {
|
|
6386
|
-
for (var _b = (
|
|
6584
|
+
for (var _b = (e_13 = void 0, __values(Object.keys(matchStage))), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6387
6585
|
var key = _c.value;
|
|
6388
6586
|
if (key.startsWith('$')) {
|
|
6389
6587
|
continue;
|
|
@@ -6398,12 +6596,12 @@ function resolveAggregateCompletionExprFallback(pipeline) {
|
|
|
6398
6596
|
}
|
|
6399
6597
|
}
|
|
6400
6598
|
}
|
|
6401
|
-
catch (
|
|
6599
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
6402
6600
|
finally {
|
|
6403
6601
|
try {
|
|
6404
6602
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6405
6603
|
}
|
|
6406
|
-
finally { if (
|
|
6604
|
+
finally { if (e_13) throw e_13.error; }
|
|
6407
6605
|
}
|
|
6408
6606
|
}
|
|
6409
6607
|
if (!candidateField) {
|
|
@@ -6573,7 +6771,7 @@ function isRegexMatchCondition(value) {
|
|
|
6573
6771
|
return false;
|
|
6574
6772
|
}
|
|
6575
6773
|
function findRegexMatchInMatchObject(match, prefix) {
|
|
6576
|
-
var
|
|
6774
|
+
var e_14, _a, e_15, _b;
|
|
6577
6775
|
if (prefix === void 0) { prefix = ''; }
|
|
6578
6776
|
if (Array.isArray(match)) {
|
|
6579
6777
|
try {
|
|
@@ -6585,12 +6783,12 @@ function findRegexMatchInMatchObject(match, prefix) {
|
|
|
6585
6783
|
}
|
|
6586
6784
|
}
|
|
6587
6785
|
}
|
|
6588
|
-
catch (
|
|
6786
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
6589
6787
|
finally {
|
|
6590
6788
|
try {
|
|
6591
6789
|
if (match_1_1 && !match_1_1.done && (_a = match_1.return)) _a.call(match_1);
|
|
6592
6790
|
}
|
|
6593
|
-
finally { if (
|
|
6791
|
+
finally { if (e_14) throw e_14.error; }
|
|
6594
6792
|
}
|
|
6595
6793
|
return null;
|
|
6596
6794
|
}
|
|
@@ -6621,12 +6819,12 @@ function findRegexMatchInMatchObject(match, prefix) {
|
|
|
6621
6819
|
}
|
|
6622
6820
|
}
|
|
6623
6821
|
}
|
|
6624
|
-
catch (
|
|
6822
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
6625
6823
|
finally {
|
|
6626
6824
|
try {
|
|
6627
6825
|
if (keys_2_1 && !keys_2_1.done && (_b = keys_2.return)) _b.call(keys_2);
|
|
6628
6826
|
}
|
|
6629
|
-
finally { if (
|
|
6827
|
+
finally { if (e_15) throw e_15.error; }
|
|
6630
6828
|
}
|
|
6631
6829
|
return null;
|
|
6632
6830
|
}
|
|
@@ -6850,7 +7048,7 @@ function collectMatchFieldsByCondition(match, predicate, prefix) {
|
|
|
6850
7048
|
return results;
|
|
6851
7049
|
}
|
|
6852
7050
|
function findMatchConditionForField(match, targetField, prefix) {
|
|
6853
|
-
var
|
|
7051
|
+
var e_16, _a, e_17, _b;
|
|
6854
7052
|
if (prefix === void 0) { prefix = ''; }
|
|
6855
7053
|
if (!match || typeof match !== 'object') {
|
|
6856
7054
|
return undefined;
|
|
@@ -6865,12 +7063,12 @@ function findMatchConditionForField(match, targetField, prefix) {
|
|
|
6865
7063
|
}
|
|
6866
7064
|
}
|
|
6867
7065
|
}
|
|
6868
|
-
catch (
|
|
7066
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
6869
7067
|
finally {
|
|
6870
7068
|
try {
|
|
6871
7069
|
if (match_2_1 && !match_2_1.done && (_a = match_2.return)) _a.call(match_2);
|
|
6872
7070
|
}
|
|
6873
|
-
finally { if (
|
|
7071
|
+
finally { if (e_16) throw e_16.error; }
|
|
6874
7072
|
}
|
|
6875
7073
|
return undefined;
|
|
6876
7074
|
}
|
|
@@ -6897,12 +7095,12 @@ function findMatchConditionForField(match, targetField, prefix) {
|
|
|
6897
7095
|
}
|
|
6898
7096
|
}
|
|
6899
7097
|
}
|
|
6900
|
-
catch (
|
|
7098
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
6901
7099
|
finally {
|
|
6902
7100
|
try {
|
|
6903
7101
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
6904
7102
|
}
|
|
6905
|
-
finally { if (
|
|
7103
|
+
finally { if (e_17) throw e_17.error; }
|
|
6906
7104
|
}
|
|
6907
7105
|
return undefined;
|
|
6908
7106
|
}
|
|
@@ -6945,7 +7143,7 @@ function detectIdLikeValue(value) {
|
|
|
6945
7143
|
return false;
|
|
6946
7144
|
}
|
|
6947
7145
|
function detectChemicalIdFromProbe(probeDocs, fields) {
|
|
6948
|
-
var
|
|
7146
|
+
var e_18, _a, e_19, _b;
|
|
6949
7147
|
if (!Array.isArray(probeDocs) || !probeDocs.length) {
|
|
6950
7148
|
return false;
|
|
6951
7149
|
}
|
|
@@ -6957,7 +7155,7 @@ function detectChemicalIdFromProbe(probeDocs, fields) {
|
|
|
6957
7155
|
for (var probeDocs_1 = __values(probeDocs), probeDocs_1_1 = probeDocs_1.next(); !probeDocs_1_1.done; probeDocs_1_1 = probeDocs_1.next()) {
|
|
6958
7156
|
var doc = probeDocs_1_1.value;
|
|
6959
7157
|
try {
|
|
6960
|
-
for (var targets_1 = (
|
|
7158
|
+
for (var targets_1 = (e_19 = void 0, __values(targets)), targets_1_1 = targets_1.next(); !targets_1_1.done; targets_1_1 = targets_1.next()) {
|
|
6961
7159
|
var field = targets_1_1.value;
|
|
6962
7160
|
var value = getValueAtPath(doc, field);
|
|
6963
7161
|
if (Array.isArray(value)) {
|
|
@@ -6970,21 +7168,21 @@ function detectChemicalIdFromProbe(probeDocs, fields) {
|
|
|
6970
7168
|
}
|
|
6971
7169
|
}
|
|
6972
7170
|
}
|
|
6973
|
-
catch (
|
|
7171
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
6974
7172
|
finally {
|
|
6975
7173
|
try {
|
|
6976
7174
|
if (targets_1_1 && !targets_1_1.done && (_b = targets_1.return)) _b.call(targets_1);
|
|
6977
7175
|
}
|
|
6978
|
-
finally { if (
|
|
7176
|
+
finally { if (e_19) throw e_19.error; }
|
|
6979
7177
|
}
|
|
6980
7178
|
}
|
|
6981
7179
|
}
|
|
6982
|
-
catch (
|
|
7180
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
6983
7181
|
finally {
|
|
6984
7182
|
try {
|
|
6985
7183
|
if (probeDocs_1_1 && !probeDocs_1_1.done && (_a = probeDocs_1.return)) _a.call(probeDocs_1);
|
|
6986
7184
|
}
|
|
6987
|
-
finally { if (
|
|
7185
|
+
finally { if (e_18) throw e_18.error; }
|
|
6988
7186
|
}
|
|
6989
7187
|
return false;
|
|
6990
7188
|
}
|
|
@@ -7205,8 +7403,8 @@ function buildChemicalIdFieldCandidates(field) {
|
|
|
7205
7403
|
}
|
|
7206
7404
|
function applyChemicalNameLookupFallbackToQuery(params) {
|
|
7207
7405
|
return __awaiter(this, void 0, void 0, function () {
|
|
7208
|
-
var query, db, dbName, idClient, idCustomer, isSuperAdmin, probeDocs, chemicalFields, targetField, condition, regex, sampleDocs, collectionNames, candidates, _loop_6, candidates_2, candidates_2_1, candidate, state_4,
|
|
7209
|
-
var
|
|
7406
|
+
var query, db, dbName, idClient, idCustomer, isSuperAdmin, probeDocs, chemicalFields, targetField, condition, regex, sampleDocs, collectionNames, candidates, _loop_6, candidates_2, candidates_2_1, candidate, state_4, e_20_1;
|
|
7407
|
+
var e_20, _a;
|
|
7210
7408
|
var _b;
|
|
7211
7409
|
return __generator(this, function (_c) {
|
|
7212
7410
|
switch (_c.label) {
|
|
@@ -7319,14 +7517,14 @@ function applyChemicalNameLookupFallbackToQuery(params) {
|
|
|
7319
7517
|
return [3 /*break*/, 3];
|
|
7320
7518
|
case 6: return [3 /*break*/, 9];
|
|
7321
7519
|
case 7:
|
|
7322
|
-
|
|
7323
|
-
|
|
7520
|
+
e_20_1 = _c.sent();
|
|
7521
|
+
e_20 = { error: e_20_1 };
|
|
7324
7522
|
return [3 /*break*/, 9];
|
|
7325
7523
|
case 8:
|
|
7326
7524
|
try {
|
|
7327
7525
|
if (candidates_2_1 && !candidates_2_1.done && (_a = candidates_2.return)) _a.call(candidates_2);
|
|
7328
7526
|
}
|
|
7329
|
-
finally { if (
|
|
7527
|
+
finally { if (e_20) throw e_20.error; }
|
|
7330
7528
|
return [7 /*endfinally*/];
|
|
7331
7529
|
case 9: return [2 /*return*/, null];
|
|
7332
7530
|
}
|
|
@@ -7420,8 +7618,8 @@ function lookupIdsForNameMatch(params) {
|
|
|
7420
7618
|
}
|
|
7421
7619
|
function applyIdLookupFallbackToQuery(params) {
|
|
7422
7620
|
return __awaiter(this, void 0, void 0, function () {
|
|
7423
|
-
var query, db, dbName, idClient, idCustomer, isSuperAdmin, probeDocs, conditions, collectionNames, _a, conditions_1, conditions_1_1, condition, regex, baseToken, targetFieldType, nextValue, localNameField, candidates, candidates_3, candidates_3_1, candidate, candidateHasClientScope, _b, candidateProbe, lookup, targetFieldType, normalizedIds, idsForQuery,
|
|
7424
|
-
var
|
|
7621
|
+
var query, db, dbName, idClient, idCustomer, isSuperAdmin, probeDocs, conditions, collectionNames, _a, conditions_1, conditions_1_1, condition, regex, baseToken, targetFieldType, nextValue, localNameField, candidates, candidates_3, candidates_3_1, candidate, candidateHasClientScope, _b, candidateProbe, lookup, targetFieldType, normalizedIds, idsForQuery, e_21_1, e_22_1;
|
|
7622
|
+
var e_22, _c, e_21, _d;
|
|
7425
7623
|
var _e;
|
|
7426
7624
|
return __generator(this, function (_f) {
|
|
7427
7625
|
switch (_f.label) {
|
|
@@ -7491,7 +7689,7 @@ function applyIdLookupFallbackToQuery(params) {
|
|
|
7491
7689
|
_f.label = 5;
|
|
7492
7690
|
case 5:
|
|
7493
7691
|
_f.trys.push([5, 14, 15, 16]);
|
|
7494
|
-
candidates_3 = (
|
|
7692
|
+
candidates_3 = (e_21 = void 0, __values(candidates)), candidates_3_1 = candidates_3.next();
|
|
7495
7693
|
_f.label = 6;
|
|
7496
7694
|
case 6:
|
|
7497
7695
|
if (!!candidates_3_1.done) return [3 /*break*/, 13];
|
|
@@ -7558,28 +7756,28 @@ function applyIdLookupFallbackToQuery(params) {
|
|
|
7558
7756
|
return [3 /*break*/, 6];
|
|
7559
7757
|
case 13: return [3 /*break*/, 16];
|
|
7560
7758
|
case 14:
|
|
7561
|
-
|
|
7562
|
-
|
|
7759
|
+
e_21_1 = _f.sent();
|
|
7760
|
+
e_21 = { error: e_21_1 };
|
|
7563
7761
|
return [3 /*break*/, 16];
|
|
7564
7762
|
case 15:
|
|
7565
7763
|
try {
|
|
7566
7764
|
if (candidates_3_1 && !candidates_3_1.done && (_d = candidates_3.return)) _d.call(candidates_3);
|
|
7567
7765
|
}
|
|
7568
|
-
finally { if (
|
|
7766
|
+
finally { if (e_21) throw e_21.error; }
|
|
7569
7767
|
return [7 /*endfinally*/];
|
|
7570
7768
|
case 16:
|
|
7571
7769
|
conditions_1_1 = conditions_1.next();
|
|
7572
7770
|
return [3 /*break*/, 4];
|
|
7573
7771
|
case 17: return [3 /*break*/, 20];
|
|
7574
7772
|
case 18:
|
|
7575
|
-
|
|
7576
|
-
|
|
7773
|
+
e_22_1 = _f.sent();
|
|
7774
|
+
e_22 = { error: e_22_1 };
|
|
7577
7775
|
return [3 /*break*/, 20];
|
|
7578
7776
|
case 19:
|
|
7579
7777
|
try {
|
|
7580
7778
|
if (conditions_1_1 && !conditions_1_1.done && (_c = conditions_1.return)) _c.call(conditions_1);
|
|
7581
7779
|
}
|
|
7582
|
-
finally { if (
|
|
7780
|
+
finally { if (e_22) throw e_22.error; }
|
|
7583
7781
|
return [7 /*endfinally*/];
|
|
7584
7782
|
case 20: return [2 /*return*/, null];
|
|
7585
7783
|
}
|
|
@@ -8431,7 +8629,7 @@ function resolveAssistantReportBuilderBridgeCollection(collection) {
|
|
|
8431
8629
|
throw new Error('AI assistant report builder bridge: Collection is not configured for report builder.');
|
|
8432
8630
|
}
|
|
8433
8631
|
function findQueryDateField(query) {
|
|
8434
|
-
var
|
|
8632
|
+
var e_23, _a, e_24, _b;
|
|
8435
8633
|
if (!query || typeof query !== 'object') {
|
|
8436
8634
|
return null;
|
|
8437
8635
|
}
|
|
@@ -8445,12 +8643,12 @@ function findQueryDateField(query) {
|
|
|
8445
8643
|
}
|
|
8446
8644
|
}
|
|
8447
8645
|
}
|
|
8448
|
-
catch (
|
|
8646
|
+
catch (e_23_1) { e_23 = { error: e_23_1 }; }
|
|
8449
8647
|
finally {
|
|
8450
8648
|
try {
|
|
8451
8649
|
if (query_1_1 && !query_1_1.done && (_a = query_1.return)) _a.call(query_1);
|
|
8452
8650
|
}
|
|
8453
|
-
finally { if (
|
|
8651
|
+
finally { if (e_23) throw e_23.error; }
|
|
8454
8652
|
}
|
|
8455
8653
|
return null;
|
|
8456
8654
|
}
|
|
@@ -8469,12 +8667,12 @@ function findQueryDateField(query) {
|
|
|
8469
8667
|
}
|
|
8470
8668
|
}
|
|
8471
8669
|
}
|
|
8472
|
-
catch (
|
|
8670
|
+
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
8473
8671
|
finally {
|
|
8474
8672
|
try {
|
|
8475
8673
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
8476
8674
|
}
|
|
8477
|
-
finally { if (
|
|
8675
|
+
finally { if (e_24) throw e_24.error; }
|
|
8478
8676
|
}
|
|
8479
8677
|
return null;
|
|
8480
8678
|
}
|
|
@@ -8696,7 +8894,7 @@ function resolveQueryDateFieldFallback(query) {
|
|
|
8696
8894
|
return { from: dateField, to: fallback };
|
|
8697
8895
|
}
|
|
8698
8896
|
function containsForbiddenMongoOperators(value) {
|
|
8699
|
-
var
|
|
8897
|
+
var e_25, _a;
|
|
8700
8898
|
if (!value || typeof value !== 'object') {
|
|
8701
8899
|
return false;
|
|
8702
8900
|
}
|
|
@@ -8715,12 +8913,12 @@ function containsForbiddenMongoOperators(value) {
|
|
|
8715
8913
|
}
|
|
8716
8914
|
}
|
|
8717
8915
|
}
|
|
8718
|
-
catch (
|
|
8916
|
+
catch (e_25_1) { e_25 = { error: e_25_1 }; }
|
|
8719
8917
|
finally {
|
|
8720
8918
|
try {
|
|
8721
8919
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
8722
8920
|
}
|
|
8723
|
-
finally { if (
|
|
8921
|
+
finally { if (e_25) throw e_25.error; }
|
|
8724
8922
|
}
|
|
8725
8923
|
return false;
|
|
8726
8924
|
}
|
|
@@ -9096,8 +9294,8 @@ function applyCodexStreamStatusHandler(runOptions, streamStatusHandler) {
|
|
|
9096
9294
|
}
|
|
9097
9295
|
function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
9098
9296
|
return __awaiter(this, void 0, void 0, function () {
|
|
9099
|
-
var _a, _b, _c, _d, message, payload, status_1,
|
|
9100
|
-
var _e,
|
|
9297
|
+
var _a, _b, _c, _d, message, payload, status_1, e_26_1;
|
|
9298
|
+
var _e, e_26, _f, _g;
|
|
9101
9299
|
return __generator(this, function (_h) {
|
|
9102
9300
|
switch (_h.label) {
|
|
9103
9301
|
case 0:
|
|
@@ -9124,8 +9322,8 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
|
9124
9322
|
return [3 /*break*/, 1];
|
|
9125
9323
|
case 4: return [3 /*break*/, 11];
|
|
9126
9324
|
case 5:
|
|
9127
|
-
|
|
9128
|
-
|
|
9325
|
+
e_26_1 = _h.sent();
|
|
9326
|
+
e_26 = { error: e_26_1 };
|
|
9129
9327
|
return [3 /*break*/, 11];
|
|
9130
9328
|
case 6:
|
|
9131
9329
|
_h.trys.push([6, , 9, 10]);
|
|
@@ -9136,7 +9334,7 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
|
9136
9334
|
_h.label = 8;
|
|
9137
9335
|
case 8: return [3 /*break*/, 10];
|
|
9138
9336
|
case 9:
|
|
9139
|
-
if (
|
|
9337
|
+
if (e_26) throw e_26.error;
|
|
9140
9338
|
return [7 /*endfinally*/];
|
|
9141
9339
|
case 10: return [7 /*endfinally*/];
|
|
9142
9340
|
case 11: throw new CodexWorkerBootstrapError('Codex worker exited before completing.');
|
|
@@ -9598,7 +9796,7 @@ function resolveAssistantPlannerEnabled() {
|
|
|
9598
9796
|
return raw === undefined ? true : raw === true;
|
|
9599
9797
|
}
|
|
9600
9798
|
function resolveAssistantPlannerKnownRoutes() {
|
|
9601
|
-
var
|
|
9799
|
+
var e_27, _a;
|
|
9602
9800
|
var _b;
|
|
9603
9801
|
var routes = ((_b = resolveio_server_app_1.ResolveIOServer.getClientRoutes) === null || _b === void 0 ? void 0 : _b.call(resolveio_server_app_1.ResolveIOServer)) || [];
|
|
9604
9802
|
var unique = new Set();
|
|
@@ -9611,12 +9809,12 @@ function resolveAssistantPlannerKnownRoutes() {
|
|
|
9611
9809
|
}
|
|
9612
9810
|
}
|
|
9613
9811
|
}
|
|
9614
|
-
catch (
|
|
9812
|
+
catch (e_27_1) { e_27 = { error: e_27_1 }; }
|
|
9615
9813
|
finally {
|
|
9616
9814
|
try {
|
|
9617
9815
|
if (routes_1_1 && !routes_1_1.done && (_a = routes_1.return)) _a.call(routes_1);
|
|
9618
9816
|
}
|
|
9619
|
-
finally { if (
|
|
9817
|
+
finally { if (e_27) throw e_27.error; }
|
|
9620
9818
|
}
|
|
9621
9819
|
return Array.from(unique).slice(0, AI_ASSISTANT_PLANNER_MAX_ROUTES);
|
|
9622
9820
|
}
|
|
@@ -9859,7 +10057,7 @@ function normalizeRouteMatchKey(value) {
|
|
|
9859
10057
|
return normalizeRouteKey(value).toLowerCase();
|
|
9860
10058
|
}
|
|
9861
10059
|
function buildClientRouteIndex() {
|
|
9862
|
-
var
|
|
10060
|
+
var e_28, _a;
|
|
9863
10061
|
var _b;
|
|
9864
10062
|
var routes = ((_b = resolveio_server_app_1.ResolveIOServer.getClientRoutes) === null || _b === void 0 ? void 0 : _b.call(resolveio_server_app_1.ResolveIOServer)) || [];
|
|
9865
10063
|
var set = new Set();
|
|
@@ -9878,12 +10076,12 @@ function buildClientRouteIndex() {
|
|
|
9878
10076
|
}
|
|
9879
10077
|
}
|
|
9880
10078
|
}
|
|
9881
|
-
catch (
|
|
10079
|
+
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
9882
10080
|
finally {
|
|
9883
10081
|
try {
|
|
9884
10082
|
if (routes_2_1 && !routes_2_1.done && (_a = routes_2.return)) _a.call(routes_2);
|
|
9885
10083
|
}
|
|
9886
|
-
finally { if (
|
|
10084
|
+
finally { if (e_28) throw e_28.error; }
|
|
9887
10085
|
}
|
|
9888
10086
|
return { set: set, map: map, size: routes.length };
|
|
9889
10087
|
}
|
|
@@ -10024,7 +10222,7 @@ function sanitizeAssistantResponse(value) {
|
|
|
10024
10222
|
return normalizeAssistantRoutes(normalizedCurrency);
|
|
10025
10223
|
}
|
|
10026
10224
|
function evaluateAssistantGuardrails(message) {
|
|
10027
|
-
var
|
|
10225
|
+
var e_29, _a;
|
|
10028
10226
|
var normalized = String(message || '').toLowerCase();
|
|
10029
10227
|
var patterns = [
|
|
10030
10228
|
{
|
|
@@ -10070,12 +10268,12 @@ function evaluateAssistantGuardrails(message) {
|
|
|
10070
10268
|
}
|
|
10071
10269
|
}
|
|
10072
10270
|
}
|
|
10073
|
-
catch (
|
|
10271
|
+
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
10074
10272
|
finally {
|
|
10075
10273
|
try {
|
|
10076
10274
|
if (patterns_1_1 && !patterns_1_1.done && (_a = patterns_1.return)) _a.call(patterns_1);
|
|
10077
10275
|
}
|
|
10078
|
-
finally { if (
|
|
10276
|
+
finally { if (e_29) throw e_29.error; }
|
|
10079
10277
|
}
|
|
10080
10278
|
return null;
|
|
10081
10279
|
}
|
|
@@ -10190,7 +10388,7 @@ function tokenizeArithmeticExpression(expression) {
|
|
|
10190
10388
|
return tokens;
|
|
10191
10389
|
}
|
|
10192
10390
|
function evaluateArithmeticExpression(expression) {
|
|
10193
|
-
var
|
|
10391
|
+
var e_30, _a, e_31, _b;
|
|
10194
10392
|
var tokens = tokenizeArithmeticExpression(expression);
|
|
10195
10393
|
if (!tokens || !tokens.length) {
|
|
10196
10394
|
return null;
|
|
@@ -10247,12 +10445,12 @@ function evaluateArithmeticExpression(expression) {
|
|
|
10247
10445
|
prevToken = token;
|
|
10248
10446
|
}
|
|
10249
10447
|
}
|
|
10250
|
-
catch (
|
|
10448
|
+
catch (e_30_1) { e_30 = { error: e_30_1 }; }
|
|
10251
10449
|
finally {
|
|
10252
10450
|
try {
|
|
10253
10451
|
if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
|
|
10254
10452
|
}
|
|
10255
|
-
finally { if (
|
|
10453
|
+
finally { if (e_30) throw e_30.error; }
|
|
10256
10454
|
}
|
|
10257
10455
|
while (ops.length) {
|
|
10258
10456
|
var op = ops.pop();
|
|
@@ -10292,12 +10490,12 @@ function evaluateArithmeticExpression(expression) {
|
|
|
10292
10490
|
stack.push(Number(token));
|
|
10293
10491
|
}
|
|
10294
10492
|
}
|
|
10295
|
-
catch (
|
|
10493
|
+
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
10296
10494
|
finally {
|
|
10297
10495
|
try {
|
|
10298
10496
|
if (output_1_1 && !output_1_1.done && (_b = output_1.return)) _b.call(output_1);
|
|
10299
10497
|
}
|
|
10300
|
-
finally { if (
|
|
10498
|
+
finally { if (e_31) throw e_31.error; }
|
|
10301
10499
|
}
|
|
10302
10500
|
if (stack.length !== 1 || Number.isNaN(stack[0])) {
|
|
10303
10501
|
return null;
|
|
@@ -10481,8 +10679,8 @@ function handleCodexUpload(id_conversation, file_name, content_base64, size, con
|
|
|
10481
10679
|
}
|
|
10482
10680
|
function readAttachmentContents(attachments) {
|
|
10483
10681
|
return __awaiter(this, void 0, void 0, function () {
|
|
10484
|
-
var limits, totalBytes, totalChars, chunks, cleaned, attachments_1, attachments_1_1, attachment, localPath, safe, stat, ext, name_1, type, readable, content, _a,
|
|
10485
|
-
var
|
|
10682
|
+
var limits, totalBytes, totalChars, chunks, cleaned, attachments_1, attachments_1_1, attachment, localPath, safe, stat, ext, name_1, type, readable, content, _a, e_32_1;
|
|
10683
|
+
var e_32, _b;
|
|
10486
10684
|
return __generator(this, function (_c) {
|
|
10487
10685
|
switch (_c.label) {
|
|
10488
10686
|
case 0:
|
|
@@ -10561,14 +10759,14 @@ function readAttachmentContents(attachments) {
|
|
|
10561
10759
|
return [3 /*break*/, 2];
|
|
10562
10760
|
case 10: return [3 /*break*/, 13];
|
|
10563
10761
|
case 11:
|
|
10564
|
-
|
|
10565
|
-
|
|
10762
|
+
e_32_1 = _c.sent();
|
|
10763
|
+
e_32 = { error: e_32_1 };
|
|
10566
10764
|
return [3 /*break*/, 13];
|
|
10567
10765
|
case 12:
|
|
10568
10766
|
try {
|
|
10569
10767
|
if (attachments_1_1 && !attachments_1_1.done && (_b = attachments_1.return)) _b.call(attachments_1);
|
|
10570
10768
|
}
|
|
10571
|
-
finally { if (
|
|
10769
|
+
finally { if (e_32) throw e_32.error; }
|
|
10572
10770
|
return [7 /*endfinally*/];
|
|
10573
10771
|
case 13: return [2 /*return*/, {
|
|
10574
10772
|
promptText: chunks.length ? "\n\nAttachments:\n".concat(chunks.join('\n\n')) : '',
|
|
@@ -10756,7 +10954,7 @@ function estimateUsage(messages, responseText, model) {
|
|
|
10756
10954
|
};
|
|
10757
10955
|
}
|
|
10758
10956
|
function evaluateGuardrails(message) {
|
|
10759
|
-
var
|
|
10957
|
+
var e_33, _a;
|
|
10760
10958
|
var normalized = String(message || '').toLowerCase();
|
|
10761
10959
|
var patterns = [
|
|
10762
10960
|
{ 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.' },
|
|
@@ -10778,12 +10976,12 @@ function evaluateGuardrails(message) {
|
|
|
10778
10976
|
}
|
|
10779
10977
|
}
|
|
10780
10978
|
}
|
|
10781
|
-
catch (
|
|
10979
|
+
catch (e_33_1) { e_33 = { error: e_33_1 }; }
|
|
10782
10980
|
finally {
|
|
10783
10981
|
try {
|
|
10784
10982
|
if (patterns_2_1 && !patterns_2_1.done && (_a = patterns_2.return)) _a.call(patterns_2);
|
|
10785
10983
|
}
|
|
10786
|
-
finally { if (
|
|
10984
|
+
finally { if (e_33) throw e_33.error; }
|
|
10787
10985
|
}
|
|
10788
10986
|
return null;
|
|
10789
10987
|
}
|