@resolveio/server-lib 22.1.3 → 22.1.5
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
CHANGED
|
@@ -120,11 +120,13 @@ exports.resolveAssistantReadDisplayMaxRows = resolveAssistantReadDisplayMaxRows;
|
|
|
120
120
|
exports.normalizeAssistantNowExprPlaceholders = normalizeAssistantNowExprPlaceholders;
|
|
121
121
|
exports.rewriteMatchExpressionsToExpr = rewriteMatchExpressionsToExpr;
|
|
122
122
|
exports.normalizeAssistantMonthlyCalendarWindowPipeline = normalizeAssistantMonthlyCalendarWindowPipeline;
|
|
123
|
+
exports.normalizeAssistantAggregatePipeline = normalizeAssistantAggregatePipeline;
|
|
123
124
|
exports.stripQueryFieldPathsDeep = stripQueryFieldPathsDeep;
|
|
124
125
|
exports.stripScopedFieldsFromPipeline = stripScopedFieldsFromPipeline;
|
|
125
126
|
exports.rewriteEmbeddedMatchObjects = rewriteEmbeddedMatchObjects;
|
|
126
127
|
exports.resolveAssistantCollectionOverride = resolveAssistantCollectionOverride;
|
|
127
128
|
exports.resolveAssistantCrossCollectionFallbackCandidates = resolveAssistantCrossCollectionFallbackCandidates;
|
|
129
|
+
exports.resolveAssistantAvailableCrossCollectionFallbacksFromNames = resolveAssistantAvailableCrossCollectionFallbacksFromNames;
|
|
128
130
|
exports.collectUserViewPermissions = collectUserViewPermissions;
|
|
129
131
|
exports.userHasInvoiceAccess = userHasInvoiceAccess;
|
|
130
132
|
exports.resolveAssistantUserAccessTier = resolveAssistantUserAccessTier;
|
|
@@ -2533,8 +2535,9 @@ function executeAiAssistantReportIssue(payload, context) {
|
|
|
2533
2535
|
}
|
|
2534
2536
|
function executeAiAssistantMongoRead(payload, context) {
|
|
2535
2537
|
return __awaiter(this, void 0, void 0, function () {
|
|
2536
|
-
var input, rawCollection, retryState, triedCollections, crossCollectionRetryEnabled, dbName, db, collectionResolution, collection, bridgeCollection, retryRootCollection, schemaFields, _a, user, isSuperAdmin, customerId, fallbackMeta, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, strippedClient, clientScopedQuery, scopedQuery, normalized, findOptions, documents, executedQuery, probeDocs, dateFallback, fallbackQuery, fallbackDocs, expanded, fallbackDocs, nameFallback, fallbackDocs, _c, chemicalLookup, fallbackDocs, queryFields, _d, aliases, rewrittenQuery, fallbackDocs, _e, activeFallback, fallbackDocs, _f, idLookup, fallbackDocs, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, crossCollectionCandidates, crossCollectionCandidates_1, crossCollectionCandidates_1_1, candidateCollection, fallbackPayload, fallbackResult, existingFallbacks, e_1_1, nameFields, dateFields, diagnostics, queryNoName, _g, queryNoDate, _h, _j, _k, _l, allCollections, base, alt, altCount, _m, total, sanitizedDocuments, requestedFields, missingFields, _o, projectionAliases, expandedProjection, refreshedDocs, includeIds, fieldAliases, displayDocs, idLookupDisplay, priorityFields, displayMaxRows, display;
|
|
2538
|
+
var input, rawCollection, retryState, triedCollections, crossCollectionRetryEnabled, dbName, db, collectionResolution, collection, bridgeCollection, retryRootCollection, schemaFields, effectivePermissionView, _a, user, isSuperAdmin, customerId, fallbackMeta, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, strippedClient, clientScopedQuery, scopedQuery, normalized, findOptions, runFindWithRepair, initialRead, documents, executedQuery, probeDocs, dateFallback, fallbackQuery, fallbackRead, fallbackDocs, expanded, fallbackRead, fallbackDocs, nameFallback, fallbackRead, fallbackDocs, _c, chemicalLookup, fallbackRead, fallbackDocs, queryFields, _d, aliases, rewrittenQuery, fallbackRead, fallbackDocs, _e, activeFallback, fallbackRead, fallbackDocs, _f, idLookup, fallbackRead, fallbackDocs, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, crossCollectionCandidates, crossCollectionCandidates_1, crossCollectionCandidates_1_1, candidateCollection, fallbackPayload, fallbackResult, existingFallbacks, e_1_1, nameFields, dateFields, diagnostics, queryNoName, _g, queryNoDate, _h, _j, _k, _l, allCollections, base, alt, altCount, _m, total, sanitizedDocuments, requestedFields, missingFields, _o, projectionAliases, expandedProjection, refreshedDocs, includeIds, fieldAliases, displayDocs, idLookupDisplay, priorityFields, displayMaxRows, display;
|
|
2537
2539
|
var e_1, _p;
|
|
2540
|
+
var _this = this;
|
|
2538
2541
|
var _q, _r;
|
|
2539
2542
|
return __generator(this, function (_s) {
|
|
2540
2543
|
switch (_s.label) {
|
|
@@ -2565,7 +2568,10 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2565
2568
|
addAssistantCollectionToTriedSet(triedCollections, collection);
|
|
2566
2569
|
retryRootCollection = normalizeOptionalString(retryState.rootCollection) || collection;
|
|
2567
2570
|
schemaFields = getCollectionSchemaFieldNames(collection);
|
|
2568
|
-
|
|
2571
|
+
effectivePermissionView = bridgeCollection.fallbackFrom
|
|
2572
|
+
? resolveDefaultAssistantPermissionView(collection)
|
|
2573
|
+
: input.permissionView;
|
|
2574
|
+
return [4 /*yield*/, ensureAssistantReadAccess(context, effectivePermissionView, collection)];
|
|
2569
2575
|
case 3:
|
|
2570
2576
|
_a = _s.sent(), user = _a.user, isSuperAdmin = _a.isSuperAdmin;
|
|
2571
2577
|
if (!isSuperAdmin && AI_ASSISTANT_BLOCKED_COLLECTIONS.has(collection)) {
|
|
@@ -2579,6 +2585,11 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2579
2585
|
to: collection,
|
|
2580
2586
|
used: true
|
|
2581
2587
|
};
|
|
2588
|
+
fallbackMeta.permissionFallback = {
|
|
2589
|
+
from: normalizeOptionalString(input.permissionView),
|
|
2590
|
+
to: effectivePermissionView,
|
|
2591
|
+
used: true
|
|
2592
|
+
};
|
|
2582
2593
|
}
|
|
2583
2594
|
baseQuery = normalizeMongoQuery(input.query);
|
|
2584
2595
|
if (!isSuperAdmin && customerId) {
|
|
@@ -2625,22 +2636,60 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2625
2636
|
scopedQuery = applyCustomerScopeFilter(clientScopedQuery, collection, customerId, isSuperAdmin);
|
|
2626
2637
|
normalized = normalizeAssistantFindOptions(input.options);
|
|
2627
2638
|
findOptions = __assign(__assign({}, normalized.findOptions), { readPreference: AI_ASSISTANT_READ_PREFERENCE });
|
|
2628
|
-
|
|
2639
|
+
runFindWithRepair = function (query, stage) { return __awaiter(_this, void 0, void 0, function () {
|
|
2640
|
+
var docs, error_5, repaired, docs;
|
|
2641
|
+
return __generator(this, function (_a) {
|
|
2642
|
+
switch (_a.label) {
|
|
2643
|
+
case 0:
|
|
2644
|
+
_a.trys.push([0, 2, , 4]);
|
|
2645
|
+
return [4 /*yield*/, db.collection(collection).find(query, findOptions).toArray()];
|
|
2646
|
+
case 1:
|
|
2647
|
+
docs = _a.sent();
|
|
2648
|
+
return [2 /*return*/, { documents: docs, query: query }];
|
|
2649
|
+
case 2:
|
|
2650
|
+
error_5 = _a.sent();
|
|
2651
|
+
if (!isAssistantDateArithmeticArgumentError(error_5)) {
|
|
2652
|
+
throw error_5;
|
|
2653
|
+
}
|
|
2654
|
+
repaired = repairAssistantDateArithmeticInQuery(query);
|
|
2655
|
+
if (!repaired.changed || containsForbiddenMongoOperators(repaired.query)) {
|
|
2656
|
+
throw error_5;
|
|
2657
|
+
}
|
|
2658
|
+
return [4 /*yield*/, db.collection(collection).find(repaired.query, findOptions).toArray()];
|
|
2659
|
+
case 3:
|
|
2660
|
+
docs = _a.sent();
|
|
2661
|
+
fallbackMeta.dateArithmetic = {
|
|
2662
|
+
attempted: true,
|
|
2663
|
+
used: true,
|
|
2664
|
+
stage: stage,
|
|
2665
|
+
reason: 'normalized_date_operator_args'
|
|
2666
|
+
};
|
|
2667
|
+
return [2 /*return*/, {
|
|
2668
|
+
documents: docs,
|
|
2669
|
+
query: repaired.query
|
|
2670
|
+
}];
|
|
2671
|
+
case 4: return [2 /*return*/];
|
|
2672
|
+
}
|
|
2673
|
+
});
|
|
2674
|
+
}); };
|
|
2675
|
+
return [4 /*yield*/, runFindWithRepair(scopedQuery, 'initial')];
|
|
2629
2676
|
case 7:
|
|
2630
|
-
|
|
2631
|
-
|
|
2677
|
+
initialRead = _s.sent();
|
|
2678
|
+
documents = initialRead.documents;
|
|
2679
|
+
executedQuery = initialRead.query;
|
|
2632
2680
|
probeDocs = null;
|
|
2633
2681
|
if (!!documents.length) return [3 /*break*/, 9];
|
|
2634
2682
|
dateFallback = resolveQueryDateFieldFallback(scopedQuery);
|
|
2635
2683
|
if (!dateFallback) return [3 /*break*/, 9];
|
|
2636
2684
|
fallbackQuery = replaceQueryField(scopedQuery, dateFallback.from, dateFallback.to);
|
|
2637
2685
|
fallbackMeta.dateField = __assign(__assign({}, dateFallback), { attempted: true, used: false });
|
|
2638
|
-
return [4 /*yield*/,
|
|
2686
|
+
return [4 /*yield*/, runFindWithRepair(fallbackQuery, 'date_field_fallback')];
|
|
2639
2687
|
case 8:
|
|
2640
|
-
|
|
2688
|
+
fallbackRead = _s.sent();
|
|
2689
|
+
fallbackDocs = fallbackRead.documents;
|
|
2641
2690
|
if (fallbackDocs.length) {
|
|
2642
2691
|
documents = fallbackDocs;
|
|
2643
|
-
executedQuery =
|
|
2692
|
+
executedQuery = fallbackRead.query;
|
|
2644
2693
|
fallbackMeta.dateField.used = true;
|
|
2645
2694
|
}
|
|
2646
2695
|
_s.label = 9;
|
|
@@ -2653,12 +2702,13 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2653
2702
|
attempted: true,
|
|
2654
2703
|
used: false
|
|
2655
2704
|
};
|
|
2656
|
-
return [4 /*yield*/,
|
|
2705
|
+
return [4 /*yield*/, runFindWithRepair(expanded.query, 'date_fields_expanded')];
|
|
2657
2706
|
case 10:
|
|
2658
|
-
|
|
2707
|
+
fallbackRead = _s.sent();
|
|
2708
|
+
fallbackDocs = fallbackRead.documents;
|
|
2659
2709
|
if (fallbackDocs.length) {
|
|
2660
2710
|
documents = fallbackDocs;
|
|
2661
|
-
executedQuery =
|
|
2711
|
+
executedQuery = fallbackRead.query;
|
|
2662
2712
|
fallbackMeta.dateFieldsExpanded.used = true;
|
|
2663
2713
|
}
|
|
2664
2714
|
_s.label = 11;
|
|
@@ -2672,12 +2722,13 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2672
2722
|
attempted: true,
|
|
2673
2723
|
used: false
|
|
2674
2724
|
};
|
|
2675
|
-
return [4 /*yield*/,
|
|
2725
|
+
return [4 /*yield*/, runFindWithRepair(nameFallback.query, 'name_match')];
|
|
2676
2726
|
case 12:
|
|
2677
|
-
|
|
2727
|
+
fallbackRead = _s.sent();
|
|
2728
|
+
fallbackDocs = fallbackRead.documents;
|
|
2678
2729
|
if (fallbackDocs.length) {
|
|
2679
2730
|
documents = fallbackDocs;
|
|
2680
|
-
executedQuery =
|
|
2731
|
+
executedQuery = fallbackRead.query;
|
|
2681
2732
|
fallbackMeta.nameMatch.used = true;
|
|
2682
2733
|
}
|
|
2683
2734
|
_s.label = 13;
|
|
@@ -2711,12 +2762,13 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2711
2762
|
chemicalLookup = _s.sent();
|
|
2712
2763
|
if (!chemicalLookup) return [3 /*break*/, 18];
|
|
2713
2764
|
fallbackMeta.chemicalLookup = __assign(__assign({}, chemicalLookup.meta), { attempted: true, used: false });
|
|
2714
|
-
return [4 /*yield*/,
|
|
2765
|
+
return [4 /*yield*/, runFindWithRepair(chemicalLookup.query, 'chemical_lookup')];
|
|
2715
2766
|
case 17:
|
|
2716
|
-
|
|
2767
|
+
fallbackRead = _s.sent();
|
|
2768
|
+
fallbackDocs = fallbackRead.documents;
|
|
2717
2769
|
if (fallbackDocs.length) {
|
|
2718
2770
|
documents = fallbackDocs;
|
|
2719
|
-
executedQuery =
|
|
2771
|
+
executedQuery = fallbackRead.query;
|
|
2720
2772
|
fallbackMeta.chemicalLookup.used = true;
|
|
2721
2773
|
}
|
|
2722
2774
|
_s.label = 18;
|
|
@@ -2752,12 +2804,13 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2752
2804
|
var _b = __read(_a, 2), from = _b[0], to = _b[1];
|
|
2753
2805
|
return replaceFieldPathDeep(acc, from, to);
|
|
2754
2806
|
}, executedQuery);
|
|
2755
|
-
return [4 /*yield*/,
|
|
2807
|
+
return [4 /*yield*/, runFindWithRepair(rewrittenQuery, 'query_field_aliases')];
|
|
2756
2808
|
case 21:
|
|
2757
|
-
|
|
2809
|
+
fallbackRead = _s.sent();
|
|
2810
|
+
fallbackDocs = fallbackRead.documents;
|
|
2758
2811
|
if (fallbackDocs.length) {
|
|
2759
2812
|
documents = fallbackDocs;
|
|
2760
|
-
executedQuery =
|
|
2813
|
+
executedQuery = fallbackRead.query;
|
|
2761
2814
|
fallbackMeta.queryFieldAliases.used = true;
|
|
2762
2815
|
}
|
|
2763
2816
|
_s.label = 22;
|
|
@@ -2786,12 +2839,13 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2786
2839
|
used: false,
|
|
2787
2840
|
reason: 'active_fields_missing_in_collection'
|
|
2788
2841
|
};
|
|
2789
|
-
return [4 /*yield*/,
|
|
2842
|
+
return [4 /*yield*/, runFindWithRepair(activeFallback.query, 'active_status')];
|
|
2790
2843
|
case 25:
|
|
2791
|
-
|
|
2844
|
+
fallbackRead = _s.sent();
|
|
2845
|
+
fallbackDocs = fallbackRead.documents;
|
|
2792
2846
|
if (fallbackDocs.length) {
|
|
2793
2847
|
documents = fallbackDocs;
|
|
2794
|
-
executedQuery =
|
|
2848
|
+
executedQuery = fallbackRead.query;
|
|
2795
2849
|
fallbackMeta.activeStatus.used = true;
|
|
2796
2850
|
}
|
|
2797
2851
|
_s.label = 26;
|
|
@@ -2825,12 +2879,13 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
2825
2879
|
idLookup = _s.sent();
|
|
2826
2880
|
if (!idLookup) return [3 /*break*/, 31];
|
|
2827
2881
|
fallbackMeta.idLookup = __assign(__assign({}, idLookup.meta), { attempted: true, used: false });
|
|
2828
|
-
return [4 /*yield*/,
|
|
2882
|
+
return [4 /*yield*/, runFindWithRepair(idLookup.query, 'id_lookup')];
|
|
2829
2883
|
case 30:
|
|
2830
|
-
|
|
2884
|
+
fallbackRead = _s.sent();
|
|
2885
|
+
fallbackDocs = fallbackRead.documents;
|
|
2831
2886
|
if (fallbackDocs.length) {
|
|
2832
2887
|
documents = fallbackDocs;
|
|
2833
|
-
executedQuery =
|
|
2888
|
+
executedQuery = fallbackRead.query;
|
|
2834
2889
|
fallbackMeta.idLookup.used = true;
|
|
2835
2890
|
}
|
|
2836
2891
|
_s.label = 31;
|
|
@@ -3117,7 +3172,7 @@ function executeAiAssistantMongoRead(payload, context) {
|
|
|
3117
3172
|
}
|
|
3118
3173
|
function executeAiAssistantMongoAggregate(payload, context) {
|
|
3119
3174
|
return __awaiter(this, void 0, void 0, function () {
|
|
3120
|
-
var input, rawCollection, retryState, triedCollections, crossCollectionRetryEnabled, dbName, db, collectionResolution, collection, bridgeCollection, retryRootCollection, schemaFields, _a, user, isSuperAdmin, customerId, fallbackMeta, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, clientScopedQuery, scopedQuery, normalizedPipeline, sanitizedPipeline, strippedPipeline, pipelineWithScope, normalizedOptions, limitedPipeline, executedPipeline, dateField, aggregateOptions, runAggregateWithRepair, initialAggregate, documents, probeDocs, fallback, fallbackPipeline, fallbackAggregate, fallbackDocs, createdFallback, createdPipeline, createdAggregate, createdDocs, expanded, expandedAggregate, expandedDocs, completionFallback, fallbackPipeline, fallbackAggregate, fallbackDocs, completionExprFallback, fallbackPipeline, fallbackAggregate, fallbackDocs, unwindFallback, shouldUnwind, _c, _d, fallbackPipeline, fallbackAggregate, fallbackDocs, nameFallback, fallbackPipeline, fallbackAggregate, fallbackDocs, _e, _loop_1, i, state_1, matchFields_1, _f, aliases, rewrittenPipeline, fallbackAggregate, fallbackDocs, _loop_2, i, state_2, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, crossCollectionCandidates, crossCollectionCandidates_2, crossCollectionCandidates_2_1, candidateCollection, fallbackPayload, fallbackResult, existingFallbacks, e_2_1, matchStages, diagnostics, combinedMatch, nameFields, dateFields, queryNoName, _g, queryNoDate, _h, _j, _k, _l, allCollections, base, alt, altCount, _m, verification, sanitizedDocuments, includeIds, displayDocs, idLookupDisplay, display;
|
|
3175
|
+
var input, rawCollection, retryState, triedCollections, crossCollectionRetryEnabled, dbName, db, collectionResolution, collection, bridgeCollection, retryRootCollection, schemaFields, effectivePermissionView, _a, user, isSuperAdmin, customerId, fallbackMeta, baseQuery, stripped, userId, normalizedClient, shouldScopeByClient, _b, clientScopedQuery, scopedQuery, normalizedPipeline, sanitizedPipeline, strippedPipeline, pipelineWithScope, normalizedOptions, limitedPipeline, executedPipeline, dateField, aggregateOptions, runAggregateWithRepair, initialAggregate, documents, probeDocs, fallback, fallbackPipeline, fallbackAggregate, fallbackDocs, createdFallback, createdPipeline, createdAggregate, createdDocs, expanded, expandedAggregate, expandedDocs, completionFallback, fallbackPipeline, fallbackAggregate, fallbackDocs, completionExprFallback, fallbackPipeline, fallbackAggregate, fallbackDocs, unwindFallback, shouldUnwind, _c, _d, fallbackPipeline, fallbackAggregate, fallbackDocs, nameFallback, fallbackPipeline, fallbackAggregate, fallbackDocs, _e, _loop_1, i, state_1, matchFields_1, _f, aliases, rewrittenPipeline, fallbackAggregate, fallbackDocs, _loop_2, i, state_2, baseCollection, fallbackPayload, fallbackResult, existingFallbacks, crossCollectionCandidates, crossCollectionCandidates_2, crossCollectionCandidates_2_1, candidateCollection, fallbackPayload, fallbackResult, existingFallbacks, e_2_1, matchStages, diagnostics, combinedMatch, nameFields, dateFields, queryNoName, _g, queryNoDate, _h, _j, _k, _l, allCollections, base, alt, altCount, _m, verification, sanitizedDocuments, includeIds, displayDocs, idLookupDisplay, display;
|
|
3121
3176
|
var e_2, _o;
|
|
3122
3177
|
var _this = this;
|
|
3123
3178
|
var _p, _q;
|
|
@@ -3150,7 +3205,10 @@ function executeAiAssistantMongoAggregate(payload, context) {
|
|
|
3150
3205
|
addAssistantCollectionToTriedSet(triedCollections, collection);
|
|
3151
3206
|
retryRootCollection = normalizeOptionalString(retryState.rootCollection) || collection;
|
|
3152
3207
|
schemaFields = getCollectionSchemaFieldNames(collection);
|
|
3153
|
-
|
|
3208
|
+
effectivePermissionView = bridgeCollection.fallbackFrom
|
|
3209
|
+
? resolveDefaultAssistantPermissionView(collection)
|
|
3210
|
+
: input.permissionView;
|
|
3211
|
+
return [4 /*yield*/, ensureAssistantReadAccess(context, effectivePermissionView, collection)];
|
|
3154
3212
|
case 3:
|
|
3155
3213
|
_a = _r.sent(), user = _a.user, isSuperAdmin = _a.isSuperAdmin;
|
|
3156
3214
|
if (!isSuperAdmin && AI_ASSISTANT_BLOCKED_COLLECTIONS.has(collection)) {
|
|
@@ -3164,6 +3222,11 @@ function executeAiAssistantMongoAggregate(payload, context) {
|
|
|
3164
3222
|
to: collection,
|
|
3165
3223
|
used: true
|
|
3166
3224
|
};
|
|
3225
|
+
fallbackMeta.permissionFallback = {
|
|
3226
|
+
from: normalizeOptionalString(input.permissionView),
|
|
3227
|
+
to: effectivePermissionView,
|
|
3228
|
+
used: true
|
|
3229
|
+
};
|
|
3167
3230
|
}
|
|
3168
3231
|
baseQuery = normalizeMongoQuery(input.query);
|
|
3169
3232
|
if (!isSuperAdmin && customerId) {
|
|
@@ -3220,7 +3283,7 @@ function executeAiAssistantMongoAggregate(payload, context) {
|
|
|
3220
3283
|
}
|
|
3221
3284
|
aggregateOptions = __assign(__assign({}, normalizedOptions.aggregateOptions), { readPreference: AI_ASSISTANT_READ_PREFERENCE });
|
|
3222
3285
|
runAggregateWithRepair = function (pipeline, stage) { return __awaiter(_this, void 0, void 0, function () {
|
|
3223
|
-
var docs,
|
|
3286
|
+
var docs, error_6, isDateRepair, isRankSortByRepair, repaired, docs;
|
|
3224
3287
|
return __generator(this, function (_a) {
|
|
3225
3288
|
switch (_a.label) {
|
|
3226
3289
|
case 0:
|
|
@@ -3232,25 +3295,39 @@ function executeAiAssistantMongoAggregate(payload, context) {
|
|
|
3232
3295
|
docs = _a.sent();
|
|
3233
3296
|
return [2 /*return*/, { documents: docs, pipeline: pipeline }];
|
|
3234
3297
|
case 2:
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3298
|
+
error_6 = _a.sent();
|
|
3299
|
+
isDateRepair = isAssistantDateArithmeticArgumentError(error_6);
|
|
3300
|
+
isRankSortByRepair = isAssistantRankSortByError(error_6);
|
|
3301
|
+
if (!isDateRepair && !isRankSortByRepair) {
|
|
3302
|
+
throw error_6;
|
|
3238
3303
|
}
|
|
3239
|
-
repaired =
|
|
3304
|
+
repaired = isDateRepair
|
|
3305
|
+
? repairAssistantDateArithmeticInPipeline(pipeline)
|
|
3306
|
+
: repairAssistantRankSortByInPipeline(pipeline);
|
|
3240
3307
|
if (!repaired.changed || containsForbiddenMongoOperators(repaired.pipeline)) {
|
|
3241
|
-
throw
|
|
3308
|
+
throw error_6;
|
|
3242
3309
|
}
|
|
3243
3310
|
return [4 /*yield*/, db.collection(collection)
|
|
3244
3311
|
.aggregate(repaired.pipeline, aggregateOptions)
|
|
3245
3312
|
.toArray()];
|
|
3246
3313
|
case 3:
|
|
3247
3314
|
docs = _a.sent();
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3315
|
+
if (isDateRepair) {
|
|
3316
|
+
fallbackMeta.dateArithmetic = {
|
|
3317
|
+
attempted: true,
|
|
3318
|
+
used: true,
|
|
3319
|
+
stage: stage,
|
|
3320
|
+
reason: 'normalized_date_operator_args'
|
|
3321
|
+
};
|
|
3322
|
+
}
|
|
3323
|
+
if (isRankSortByRepair) {
|
|
3324
|
+
fallbackMeta.windowRankSortBy = {
|
|
3325
|
+
attempted: true,
|
|
3326
|
+
used: true,
|
|
3327
|
+
stage: stage,
|
|
3328
|
+
reason: 'normalized_rank_sortby_single_key'
|
|
3329
|
+
};
|
|
3330
|
+
}
|
|
3254
3331
|
return [2 /*return*/, { documents: docs, pipeline: repaired.pipeline }];
|
|
3255
3332
|
case 4: return [2 /*return*/];
|
|
3256
3333
|
}
|
|
@@ -4782,10 +4859,14 @@ function isAssistantOperationalHeuristicDirective(directive) {
|
|
|
4782
4859
|
return rawLine.includes('heuristic_agg(work-order-status)')
|
|
4783
4860
|
|| rawLine.includes('heuristic_agg(work-order-completed-per-day)')
|
|
4784
4861
|
|| rawLine.includes('heuristic_agg(work-order-top-customers)')
|
|
4862
|
+
|| rawLine.includes('heuristic_agg(work-order-jobs-top-volume)')
|
|
4785
4863
|
|| rawLine.includes('heuristic_agg(blend-last10-summary)')
|
|
4786
4864
|
|| rawLine.includes('heuristic_agg(blend-throughput-by-day)')
|
|
4787
4865
|
|| rawLine.includes('heuristic_agg(deliveries-per-driver-last-month)')
|
|
4788
|
-
|| rawLine.includes('heuristic_agg(last-
|
|
4866
|
+
|| rawLine.includes('heuristic_agg(deliveries-per-driver-last-30d-top10)')
|
|
4867
|
+
|| rawLine.includes('heuristic_agg(last-deliveries)')
|
|
4868
|
+
|| rawLine.includes('heuristic_agg(invoice-missing-invoiced-date-created-this-month)')
|
|
4869
|
+
|| rawLine.includes('heuristic_agg(support-ticket-billable-hours-user-month-last-6m)');
|
|
4789
4870
|
}
|
|
4790
4871
|
function isAssistantDeterministicHeuristicDirective(directive) {
|
|
4791
4872
|
return isAssistantRevenueByTimeHeuristicDirective(directive)
|
|
@@ -5112,6 +5193,76 @@ function buildAssistantHeuristicDirective(message, collectionHints) {
|
|
|
5112
5193
|
rawLine: 'HEURISTIC_AGG(deliveries-per-driver-last-month)'
|
|
5113
5194
|
};
|
|
5114
5195
|
}
|
|
5196
|
+
if (/\bdeliver(?:y|ies)\b/.test(text)
|
|
5197
|
+
&& /\bdrivers?\b/.test(text)
|
|
5198
|
+
&& /\b(last|past)\s+30\s+days?\b/.test(text)
|
|
5199
|
+
&& /\btop\s+10\b/.test(text)) {
|
|
5200
|
+
return {
|
|
5201
|
+
type: 'aggregate',
|
|
5202
|
+
payload: {
|
|
5203
|
+
collection: 'production-deliveries',
|
|
5204
|
+
permissionView: '/dashboard/driver',
|
|
5205
|
+
pipeline: [
|
|
5206
|
+
{
|
|
5207
|
+
$addFields: {
|
|
5208
|
+
effective_date: { $ifNull: ['$date', { $ifNull: ['$date_created', '$createdAt'] }] },
|
|
5209
|
+
driver_label: buildAssistantTrimmedStringExpr({
|
|
5210
|
+
$ifNull: [
|
|
5211
|
+
'$driver',
|
|
5212
|
+
{
|
|
5213
|
+
$ifNull: [
|
|
5214
|
+
'$driver_name',
|
|
5215
|
+
{
|
|
5216
|
+
$ifNull: [
|
|
5217
|
+
'$driver.fullname',
|
|
5218
|
+
{
|
|
5219
|
+
$ifNull: [
|
|
5220
|
+
'$driver.name',
|
|
5221
|
+
{
|
|
5222
|
+
$ifNull: [
|
|
5223
|
+
{ $toString: '$id_driver' },
|
|
5224
|
+
'Unknown Driver'
|
|
5225
|
+
]
|
|
5226
|
+
}
|
|
5227
|
+
]
|
|
5228
|
+
}
|
|
5229
|
+
]
|
|
5230
|
+
}
|
|
5231
|
+
]
|
|
5232
|
+
}
|
|
5233
|
+
]
|
|
5234
|
+
})
|
|
5235
|
+
}
|
|
5236
|
+
},
|
|
5237
|
+
{
|
|
5238
|
+
$match: {
|
|
5239
|
+
effective_date: {
|
|
5240
|
+
$gte: { $dateSubtract: { startDate: '$$NOW', unit: 'day', amount: 30 } },
|
|
5241
|
+
$lt: '$$NOW'
|
|
5242
|
+
}
|
|
5243
|
+
}
|
|
5244
|
+
},
|
|
5245
|
+
{
|
|
5246
|
+
$group: {
|
|
5247
|
+
_id: '$driver_label',
|
|
5248
|
+
delivery_count: { $sum: 1 }
|
|
5249
|
+
}
|
|
5250
|
+
},
|
|
5251
|
+
{ $sort: { delivery_count: -1, _id: 1 } },
|
|
5252
|
+
{ $limit: 10 },
|
|
5253
|
+
{
|
|
5254
|
+
$project: {
|
|
5255
|
+
_id: 0,
|
|
5256
|
+
driver: '$_id',
|
|
5257
|
+
delivery_count: 1
|
|
5258
|
+
}
|
|
5259
|
+
}
|
|
5260
|
+
]
|
|
5261
|
+
},
|
|
5262
|
+
cleaned: '',
|
|
5263
|
+
rawLine: 'HEURISTIC_AGG(deliveries-per-driver-last-30d-top10)'
|
|
5264
|
+
};
|
|
5265
|
+
}
|
|
5115
5266
|
if (/(which\s+blends?|blends?\s+used).*(red\s+ultra\s+lift|chemical\s+red\s+ultra\s+lift)/.test(text)
|
|
5116
5267
|
&& /(last|past)\s+30\s+days/.test(text)) {
|
|
5117
5268
|
return {
|
|
@@ -5258,6 +5409,196 @@ function buildAssistantHeuristicDirective(message, collectionHints) {
|
|
|
5258
5409
|
rawLine: 'HEURISTIC_AGG(invoice-top-customers)'
|
|
5259
5410
|
};
|
|
5260
5411
|
}
|
|
5412
|
+
if (/\binvoices?\b/.test(text)
|
|
5413
|
+
&& /(\bmissing\b|\bwithout\b|\bno\b)/.test(text)
|
|
5414
|
+
&& /(\binvoic(?:ed|e)\s+date\b|\bdate[\s_-]*invoic(?:ed|e)\b)/.test(text)
|
|
5415
|
+
&& /\bthis\s+month\b/.test(text)) {
|
|
5416
|
+
var thisMonthStart = { $dateTrunc: { date: '$$NOW', unit: 'month' } };
|
|
5417
|
+
return {
|
|
5418
|
+
type: 'aggregate',
|
|
5419
|
+
payload: {
|
|
5420
|
+
collection: 'invoices',
|
|
5421
|
+
permissionView: '/invoice/list',
|
|
5422
|
+
pipeline: [
|
|
5423
|
+
{
|
|
5424
|
+
$addFields: {
|
|
5425
|
+
created_date: { $ifNull: ['$createdAt', { $ifNull: ['$date_created', '$date'] }] },
|
|
5426
|
+
invoiced_date: { $ifNull: ['$date_invoiced', '$date_invoice'] }
|
|
5427
|
+
}
|
|
5428
|
+
},
|
|
5429
|
+
{
|
|
5430
|
+
$match: {
|
|
5431
|
+
created_date: {
|
|
5432
|
+
$gte: thisMonthStart,
|
|
5433
|
+
$lt: '$$NOW'
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
},
|
|
5437
|
+
{
|
|
5438
|
+
$match: {
|
|
5439
|
+
$expr: {
|
|
5440
|
+
$or: [
|
|
5441
|
+
{ $eq: [{ $type: '$invoiced_date' }, 'missing'] },
|
|
5442
|
+
{ $eq: ['$invoiced_date', null] },
|
|
5443
|
+
{
|
|
5444
|
+
$and: [
|
|
5445
|
+
{ $eq: [{ $type: '$invoiced_date' }, 'string'] },
|
|
5446
|
+
{ $eq: [{ $trim: { input: '$invoiced_date' } }, ''] }
|
|
5447
|
+
]
|
|
5448
|
+
}
|
|
5449
|
+
]
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
},
|
|
5453
|
+
{
|
|
5454
|
+
$project: {
|
|
5455
|
+
_id: 0,
|
|
5456
|
+
invoice_number: { $ifNull: ['$invoice_number_string', '$invoice_number'] },
|
|
5457
|
+
customer: buildAssistantInvoiceCustomerLabelExpr(),
|
|
5458
|
+
created_date: 1,
|
|
5459
|
+
due_date: '$date_due',
|
|
5460
|
+
sub_total: { $ifNull: ['$sub_total', '$subtotal'] },
|
|
5461
|
+
total: { $ifNull: ['$grand_total', '$paid_total'] }
|
|
5462
|
+
}
|
|
5463
|
+
},
|
|
5464
|
+
{ $sort: { created_date: -1, invoice_number: 1 } },
|
|
5465
|
+
{ $limit: 200 }
|
|
5466
|
+
],
|
|
5467
|
+
options: {
|
|
5468
|
+
allowDiskUse: true,
|
|
5469
|
+
export: true,
|
|
5470
|
+
limit: 200
|
|
5471
|
+
}
|
|
5472
|
+
},
|
|
5473
|
+
cleaned: '',
|
|
5474
|
+
rawLine: 'HEURISTIC_AGG(invoice-missing-invoiced-date-created-this-month)'
|
|
5475
|
+
};
|
|
5476
|
+
}
|
|
5477
|
+
if (/\bsupport[\s-]*tickets?\b/.test(text)
|
|
5478
|
+
&& /\b(hours?|billable)\b/.test(text)
|
|
5479
|
+
&& /\b(last|past)\s+6\s+months?\b/.test(text)
|
|
5480
|
+
&& /(\b(per|by|each)\s+user\b|\buser\b)/.test(text)
|
|
5481
|
+
&& /(\b(per|by|each)\s+month\b|\bmonth\b)/.test(text)) {
|
|
5482
|
+
return {
|
|
5483
|
+
type: 'aggregate',
|
|
5484
|
+
payload: {
|
|
5485
|
+
collection: 'support-tickets',
|
|
5486
|
+
permissionView: '/support-ticket/list',
|
|
5487
|
+
pipeline: [
|
|
5488
|
+
{
|
|
5489
|
+
$addFields: {
|
|
5490
|
+
effective_date: { $ifNull: ['$date', { $ifNull: ['$date_created', { $ifNull: ['$createdAt', '$updatedAt'] }] }] },
|
|
5491
|
+
billable_hours_value: {
|
|
5492
|
+
$convert: {
|
|
5493
|
+
input: {
|
|
5494
|
+
$ifNull: [
|
|
5495
|
+
'$hours_billed',
|
|
5496
|
+
{
|
|
5497
|
+
$ifNull: [
|
|
5498
|
+
'$billable_hours',
|
|
5499
|
+
{
|
|
5500
|
+
$ifNull: [
|
|
5501
|
+
'$hours',
|
|
5502
|
+
{
|
|
5503
|
+
$ifNull: [
|
|
5504
|
+
'$total_hours',
|
|
5505
|
+
{ $ifNull: ['$time.hours', { $ifNull: ['$billing.hours', 0] }] }
|
|
5506
|
+
]
|
|
5507
|
+
}
|
|
5508
|
+
]
|
|
5509
|
+
}
|
|
5510
|
+
]
|
|
5511
|
+
}
|
|
5512
|
+
]
|
|
5513
|
+
},
|
|
5514
|
+
to: 'double',
|
|
5515
|
+
onError: 0,
|
|
5516
|
+
onNull: 0
|
|
5517
|
+
}
|
|
5518
|
+
},
|
|
5519
|
+
user_label: buildAssistantTrimmedStringExpr({
|
|
5520
|
+
$ifNull: [
|
|
5521
|
+
'$user.fullname',
|
|
5522
|
+
{
|
|
5523
|
+
$ifNull: [
|
|
5524
|
+
'$user.name',
|
|
5525
|
+
{
|
|
5526
|
+
$ifNull: [
|
|
5527
|
+
'$employee.fullname',
|
|
5528
|
+
{
|
|
5529
|
+
$ifNull: [
|
|
5530
|
+
'$employee.name',
|
|
5531
|
+
{
|
|
5532
|
+
$ifNull: [
|
|
5533
|
+
'$created.name',
|
|
5534
|
+
{
|
|
5535
|
+
$ifNull: [
|
|
5536
|
+
{ $toString: '$id_user' },
|
|
5537
|
+
'Unknown User'
|
|
5538
|
+
]
|
|
5539
|
+
}
|
|
5540
|
+
]
|
|
5541
|
+
}
|
|
5542
|
+
]
|
|
5543
|
+
}
|
|
5544
|
+
]
|
|
5545
|
+
}
|
|
5546
|
+
]
|
|
5547
|
+
}
|
|
5548
|
+
]
|
|
5549
|
+
})
|
|
5550
|
+
}
|
|
5551
|
+
},
|
|
5552
|
+
{
|
|
5553
|
+
$match: {
|
|
5554
|
+
effective_date: {
|
|
5555
|
+
$gte: { $dateSubtract: { startDate: '$$NOW', unit: 'month', amount: 6 } },
|
|
5556
|
+
$lt: '$$NOW'
|
|
5557
|
+
}
|
|
5558
|
+
}
|
|
5559
|
+
},
|
|
5560
|
+
{
|
|
5561
|
+
$group: {
|
|
5562
|
+
_id: {
|
|
5563
|
+
user: '$user_label',
|
|
5564
|
+
bucket: {
|
|
5565
|
+
$dateTrunc: {
|
|
5566
|
+
date: '$effective_date',
|
|
5567
|
+
unit: 'month'
|
|
5568
|
+
}
|
|
5569
|
+
}
|
|
5570
|
+
},
|
|
5571
|
+
billable_hours: { $sum: '$billable_hours_value' },
|
|
5572
|
+
ticket_count: { $sum: 1 }
|
|
5573
|
+
}
|
|
5574
|
+
},
|
|
5575
|
+
{
|
|
5576
|
+
$project: {
|
|
5577
|
+
_id: 0,
|
|
5578
|
+
user: '$_id.user',
|
|
5579
|
+
month: {
|
|
5580
|
+
$dateToString: {
|
|
5581
|
+
format: '%Y-%m',
|
|
5582
|
+
date: '$_id.bucket'
|
|
5583
|
+
}
|
|
5584
|
+
},
|
|
5585
|
+
billable_hours: 1,
|
|
5586
|
+
ticket_count: 1
|
|
5587
|
+
}
|
|
5588
|
+
},
|
|
5589
|
+
{ $sort: { user: 1, month: 1 } },
|
|
5590
|
+
{ $limit: 400 }
|
|
5591
|
+
],
|
|
5592
|
+
options: {
|
|
5593
|
+
allowDiskUse: true,
|
|
5594
|
+
export: true,
|
|
5595
|
+
limit: 400
|
|
5596
|
+
}
|
|
5597
|
+
},
|
|
5598
|
+
cleaned: '',
|
|
5599
|
+
rawLine: 'HEURISTIC_AGG(support-ticket-billable-hours-user-month-last-6m)'
|
|
5600
|
+
};
|
|
5601
|
+
}
|
|
5261
5602
|
if (/(last\s+20).*(deliver(?:y|ies)).*(product).*(destination)/.test(text)) {
|
|
5262
5603
|
return {
|
|
5263
5604
|
type: 'aggregate',
|
|
@@ -5295,6 +5636,108 @@ function buildAssistantHeuristicDirective(message, collectionHints) {
|
|
|
5295
5636
|
rawLine: 'HEURISTIC_AGG(last-deliveries)'
|
|
5296
5637
|
};
|
|
5297
5638
|
}
|
|
5639
|
+
if (/\bjobs?\b/.test(text)
|
|
5640
|
+
&& /(\bhighest\b|\btop\b)/.test(text)
|
|
5641
|
+
&& /\btreatment\s+volume\b/.test(text)
|
|
5642
|
+
&& /\b(last|past)\s+90\s+days?\b/.test(text)) {
|
|
5643
|
+
return {
|
|
5644
|
+
type: 'aggregate',
|
|
5645
|
+
payload: {
|
|
5646
|
+
collection: 'work-order-dynamics',
|
|
5647
|
+
permissionView: '/work-order-dynamic/list',
|
|
5648
|
+
pipeline: [
|
|
5649
|
+
{
|
|
5650
|
+
$addFields: {
|
|
5651
|
+
effective_date: { $ifNull: ['$date_completed', { $ifNull: ['$date_created', '$createdAt'] }] },
|
|
5652
|
+
treatment_volume_value: {
|
|
5653
|
+
$ifNull: [
|
|
5654
|
+
'$treatment_volume',
|
|
5655
|
+
{
|
|
5656
|
+
$ifNull: [
|
|
5657
|
+
'$total_treatment_volume',
|
|
5658
|
+
{
|
|
5659
|
+
$reduce: {
|
|
5660
|
+
input: { $ifNull: ['$chemicals', []] },
|
|
5661
|
+
initialValue: 0,
|
|
5662
|
+
in: {
|
|
5663
|
+
$add: [
|
|
5664
|
+
'$$value',
|
|
5665
|
+
{
|
|
5666
|
+
$ifNull: [
|
|
5667
|
+
'$$this.quantity',
|
|
5668
|
+
{
|
|
5669
|
+
$ifNull: [
|
|
5670
|
+
'$$this.volume',
|
|
5671
|
+
{ $ifNull: ['$$this.delivered.quantity', 0] }
|
|
5672
|
+
]
|
|
5673
|
+
}
|
|
5674
|
+
]
|
|
5675
|
+
}
|
|
5676
|
+
]
|
|
5677
|
+
}
|
|
5678
|
+
}
|
|
5679
|
+
}
|
|
5680
|
+
]
|
|
5681
|
+
}
|
|
5682
|
+
]
|
|
5683
|
+
}
|
|
5684
|
+
}
|
|
5685
|
+
},
|
|
5686
|
+
{
|
|
5687
|
+
$match: {
|
|
5688
|
+
effective_date: {
|
|
5689
|
+
$gte: { $dateSubtract: { startDate: '$$NOW', unit: 'day', amount: 90 } },
|
|
5690
|
+
$lt: '$$NOW'
|
|
5691
|
+
}
|
|
5692
|
+
}
|
|
5693
|
+
},
|
|
5694
|
+
{
|
|
5695
|
+
$group: {
|
|
5696
|
+
_id: {
|
|
5697
|
+
$ifNull: [
|
|
5698
|
+
'$job.name',
|
|
5699
|
+
{
|
|
5700
|
+
$ifNull: [
|
|
5701
|
+
'$job_name',
|
|
5702
|
+
{ $ifNull: ['$job', { $ifNull: ['$job_number', 'Unknown Job'] }] }
|
|
5703
|
+
]
|
|
5704
|
+
}
|
|
5705
|
+
]
|
|
5706
|
+
},
|
|
5707
|
+
total_treatment_volume: {
|
|
5708
|
+
$sum: {
|
|
5709
|
+
$convert: {
|
|
5710
|
+
input: '$treatment_volume_value',
|
|
5711
|
+
to: 'double',
|
|
5712
|
+
onError: 0,
|
|
5713
|
+
onNull: 0
|
|
5714
|
+
}
|
|
5715
|
+
}
|
|
5716
|
+
},
|
|
5717
|
+
work_order_count: { $sum: 1 }
|
|
5718
|
+
}
|
|
5719
|
+
},
|
|
5720
|
+
{ $sort: { total_treatment_volume: -1, work_order_count: -1, _id: 1 } },
|
|
5721
|
+
{ $limit: 20 },
|
|
5722
|
+
{
|
|
5723
|
+
$project: {
|
|
5724
|
+
_id: 0,
|
|
5725
|
+
job: '$_id',
|
|
5726
|
+
total_treatment_volume: 1,
|
|
5727
|
+
work_order_count: 1
|
|
5728
|
+
}
|
|
5729
|
+
}
|
|
5730
|
+
],
|
|
5731
|
+
options: {
|
|
5732
|
+
allowDiskUse: true,
|
|
5733
|
+
export: true,
|
|
5734
|
+
limit: 20
|
|
5735
|
+
}
|
|
5736
|
+
},
|
|
5737
|
+
cleaned: '',
|
|
5738
|
+
rawLine: 'HEURISTIC_AGG(work-order-jobs-top-volume)'
|
|
5739
|
+
};
|
|
5740
|
+
}
|
|
5298
5741
|
var hintCollection = mergeAssistantHintValues(collectionHints, resolveAssistantDefaultCollectionHints(message))[0] || '';
|
|
5299
5742
|
if (!hintCollection) {
|
|
5300
5743
|
return null;
|
|
@@ -6275,7 +6718,7 @@ function resolveAssistantDatedReportWindow(toolResult) {
|
|
|
6275
6718
|
return null;
|
|
6276
6719
|
}
|
|
6277
6720
|
function buildAssistantDebugPayload(params) {
|
|
6278
|
-
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, _5, _6;
|
|
6721
|
+
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, _5, _6, _7;
|
|
6279
6722
|
var notes = [];
|
|
6280
6723
|
notes.push("Request classification: ".concat(params.requestType, " (").concat(params.requestTypeSource, ")."));
|
|
6281
6724
|
if (params.dataQuestion) {
|
|
@@ -6356,7 +6799,10 @@ function buildAssistantDebugPayload(params) {
|
|
|
6356
6799
|
notes.push("Expanded date fields: ".concat(fields, "."));
|
|
6357
6800
|
}
|
|
6358
6801
|
}
|
|
6359
|
-
if ((_p = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.
|
|
6802
|
+
if ((_p = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.windowRankSortBy) === null || _p === void 0 ? void 0 : _p.used) {
|
|
6803
|
+
notes.push('Retried after normalizing window rank sortBy to a single key.');
|
|
6804
|
+
}
|
|
6805
|
+
if ((_q = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.queryFieldAliases) === null || _q === void 0 ? void 0 : _q.used) {
|
|
6360
6806
|
var entries = fallbackInfo.queryFieldAliases.aliases
|
|
6361
6807
|
? Object.entries(fallbackInfo.queryFieldAliases.aliases)
|
|
6362
6808
|
.map(function (_a) {
|
|
@@ -6369,7 +6815,7 @@ function buildAssistantDebugPayload(params) {
|
|
|
6369
6815
|
notes.push("Rewrote query fields: ".concat(entries, "."));
|
|
6370
6816
|
}
|
|
6371
6817
|
}
|
|
6372
|
-
if ((
|
|
6818
|
+
if ((_r = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.projectionAliases) === null || _r === void 0 ? void 0 : _r.used) {
|
|
6373
6819
|
var entries = fallbackInfo.projectionAliases.aliases
|
|
6374
6820
|
? Object.entries(fallbackInfo.projectionAliases.aliases)
|
|
6375
6821
|
.map(function (_a) {
|
|
@@ -6382,45 +6828,45 @@ function buildAssistantDebugPayload(params) {
|
|
|
6382
6828
|
notes.push("Expanded projection fields: ".concat(entries, "."));
|
|
6383
6829
|
}
|
|
6384
6830
|
}
|
|
6385
|
-
if ((
|
|
6831
|
+
if ((_s = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.unwind) === null || _s === void 0 ? void 0 : _s.used) {
|
|
6386
6832
|
notes.push("Applied unwind fallback on ".concat(fallbackInfo.unwind.path, "."));
|
|
6387
6833
|
}
|
|
6388
|
-
if ((
|
|
6834
|
+
if ((_t = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.nameMatch) === null || _t === void 0 ? void 0 : _t.used) {
|
|
6389
6835
|
var fields = Array.isArray(fallbackInfo.nameMatch.fields)
|
|
6390
6836
|
? fallbackInfo.nameMatch.fields.join(', ')
|
|
6391
6837
|
: fallbackInfo.nameMatch.field;
|
|
6392
6838
|
notes.push("Expanded name match fields: ".concat(fields, "."));
|
|
6393
6839
|
}
|
|
6394
|
-
if ((
|
|
6840
|
+
if ((_u = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.chemicalLookup) === null || _u === void 0 ? void 0 : _u.used) {
|
|
6395
6841
|
var collection = fallbackInfo.chemicalLookup.collection ? " in ".concat(fallbackInfo.chemicalLookup.collection) : '';
|
|
6396
6842
|
notes.push("Applied chemical lookup".concat(collection, "."));
|
|
6397
6843
|
}
|
|
6398
|
-
if ((
|
|
6844
|
+
if ((_v = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.reportBuilderBridge) === null || _v === void 0 ? void 0 : _v.used) {
|
|
6399
6845
|
var from = fallbackInfo.reportBuilderBridge.from || 'unknown';
|
|
6400
6846
|
var to = fallbackInfo.reportBuilderBridge.to || 'unknown';
|
|
6401
6847
|
notes.push("Report builder bridge collection: ".concat(from, " -> ").concat(to, "."));
|
|
6402
6848
|
}
|
|
6403
|
-
if ((
|
|
6849
|
+
if ((_w = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.reportFallback) === null || _w === void 0 ? void 0 : _w.used) {
|
|
6404
6850
|
var from = fallbackInfo.reportFallback.from || 'report';
|
|
6405
6851
|
var to = fallbackInfo.reportFallback.to || 'base';
|
|
6406
6852
|
notes.push("Report fallback: ".concat(from, " -> ").concat(to, "."));
|
|
6407
6853
|
}
|
|
6408
|
-
if ((
|
|
6854
|
+
if ((_x = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.collectionRetry) === null || _x === void 0 ? void 0 : _x.used) {
|
|
6409
6855
|
var from = fallbackInfo.collectionRetry.from || 'unknown';
|
|
6410
6856
|
var to = fallbackInfo.collectionRetry.to || 'unknown';
|
|
6411
6857
|
notes.push("Cross-collection retry: ".concat(from, " -> ").concat(to, "."));
|
|
6412
6858
|
}
|
|
6413
|
-
else if (((
|
|
6859
|
+
else if (((_y = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.collectionRetry) === null || _y === void 0 ? void 0 : _y.attempted) && Array.isArray(fallbackInfo.collectionRetry.tried) && fallbackInfo.collectionRetry.tried.length) {
|
|
6414
6860
|
notes.push("Cross-collection retry attempted: ".concat(fallbackInfo.collectionRetry.tried.join(', '), "."));
|
|
6415
6861
|
}
|
|
6416
|
-
if ((
|
|
6862
|
+
if ((_z = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.idLookup) === null || _z === void 0 ? void 0 : _z.used) {
|
|
6417
6863
|
var field = fallbackInfo.idLookup.field || 'id';
|
|
6418
6864
|
var strategy = fallbackInfo.idLookup.strategy || 'lookup';
|
|
6419
6865
|
var collection = fallbackInfo.idLookup.collection ? " in ".concat(fallbackInfo.idLookup.collection) : '';
|
|
6420
6866
|
var detail = fallbackInfo.idLookup.nameField ? " via ".concat(fallbackInfo.idLookup.nameField) : '';
|
|
6421
6867
|
notes.push("Resolved ".concat(field, " by ").concat(strategy).concat(collection).concat(detail, "."));
|
|
6422
6868
|
}
|
|
6423
|
-
if ((
|
|
6869
|
+
if ((_0 = fallbackInfo === null || fallbackInfo === void 0 ? void 0 : fallbackInfo.idDisplayLookup) === null || _0 === void 0 ? void 0 : _0.used) {
|
|
6424
6870
|
var lookups = Array.isArray(fallbackInfo.idDisplayLookup.lookups)
|
|
6425
6871
|
? fallbackInfo.idDisplayLookup.lookups
|
|
6426
6872
|
: [];
|
|
@@ -6431,12 +6877,18 @@ function buildAssistantDebugPayload(params) {
|
|
|
6431
6877
|
notes.push(summary ? "Resolved id lookups for display: ".concat(summary, ".") : 'Resolved id lookups for display.');
|
|
6432
6878
|
}
|
|
6433
6879
|
if (params.toolError) {
|
|
6434
|
-
var errorMessage = ((
|
|
6880
|
+
var errorMessage = ((_1 = params.toolError) === null || _1 === void 0 ? void 0 : _1.message) || String(params.toolError || '');
|
|
6435
6881
|
if (errorMessage) {
|
|
6436
6882
|
notes.push("Tool error: ".concat(errorMessage));
|
|
6437
6883
|
}
|
|
6438
6884
|
}
|
|
6439
6885
|
var payload = {
|
|
6886
|
+
requestClassification: {
|
|
6887
|
+
type: params.requestType,
|
|
6888
|
+
source: params.requestTypeSource,
|
|
6889
|
+
plannerIntentType: params.plannerIntentType || undefined,
|
|
6890
|
+
dataQuestion: params.dataQuestion
|
|
6891
|
+
},
|
|
6440
6892
|
decision: {
|
|
6441
6893
|
requestType: params.requestType,
|
|
6442
6894
|
requestTypeSource: params.requestTypeSource,
|
|
@@ -6459,13 +6911,13 @@ function buildAssistantDebugPayload(params) {
|
|
|
6459
6911
|
collectionResolved: resolvedCollection || undefined,
|
|
6460
6912
|
collectionMatched: matchedCollection,
|
|
6461
6913
|
collectionCandidates: candidateCollections.length ? candidateCollections : undefined,
|
|
6462
|
-
collectionScore: typeof ((
|
|
6914
|
+
collectionScore: typeof ((_2 = params.toolResponseDebug) === null || _2 === void 0 ? void 0 : _2.collectionScore) === 'number'
|
|
6463
6915
|
? params.toolResponseDebug.collectionScore
|
|
6464
6916
|
: undefined,
|
|
6465
|
-
query: ((
|
|
6466
|
-
pipeline: ((
|
|
6467
|
-
options: ((
|
|
6468
|
-
fallbacks: ((
|
|
6917
|
+
query: ((_3 = params.toolResponseDebug) === null || _3 === void 0 ? void 0 : _3.query) || undefined,
|
|
6918
|
+
pipeline: ((_4 = params.toolResponseDebug) === null || _4 === void 0 ? void 0 : _4.executedPipeline) || ((_5 = params.toolResponseDebug) === null || _5 === void 0 ? void 0 : _5.originalPipeline) || undefined,
|
|
6919
|
+
options: ((_6 = params.toolResponseDebug) === null || _6 === void 0 ? void 0 : _6.options) || undefined,
|
|
6920
|
+
fallbacks: ((_7 = params.toolResponseDebug) === null || _7 === void 0 ? void 0 : _7.fallbacks) || undefined,
|
|
6469
6921
|
notes: notes
|
|
6470
6922
|
};
|
|
6471
6923
|
if (params.trace && typeof params.trace === 'object') {
|
|
@@ -8815,10 +9267,17 @@ function normalizeAssistantNowExprOperand(value) {
|
|
|
8815
9267
|
if (trimmed === '$$NOW') {
|
|
8816
9268
|
return '$$NOW';
|
|
8817
9269
|
}
|
|
8818
|
-
var
|
|
9270
|
+
var normalizedTokenRaw = trimmed.replace(/^\$+/, '').toUpperCase();
|
|
9271
|
+
var normalizedToken = normalizedTokenRaw.replace(/_(UTC|GMT|Z)$/, '');
|
|
8819
9272
|
if (normalizedToken === 'NOW_START_OF_MONTH') {
|
|
8820
9273
|
return createAssistantNowMonthStartExpr();
|
|
8821
9274
|
}
|
|
9275
|
+
if (normalizedToken === 'NOW_START_OF_WEEK' || normalizedToken === 'START_OF_WEEK') {
|
|
9276
|
+
return createAssistantNowWeekStartExpr();
|
|
9277
|
+
}
|
|
9278
|
+
if (normalizedToken === 'NOW_START_OF_DAY' || normalizedToken === 'START_OF_DAY' || normalizedToken === 'START_OF_TODAY') {
|
|
9279
|
+
return createAssistantNowDayStartExpr();
|
|
9280
|
+
}
|
|
8822
9281
|
if (normalizedToken === 'NOW_START_OF_LAST_MONTH') {
|
|
8823
9282
|
return {
|
|
8824
9283
|
$dateSubtract: {
|
|
@@ -8852,6 +9311,12 @@ function normalizeAssistantNowExprOperand(value) {
|
|
|
8852
9311
|
}
|
|
8853
9312
|
};
|
|
8854
9313
|
}
|
|
9314
|
+
if (normalizedToken === 'NOW_END_OF_WEEK' || normalizedToken === 'END_OF_WEEK') {
|
|
9315
|
+
return createAssistantNowWeekEndExpr();
|
|
9316
|
+
}
|
|
9317
|
+
if (normalizedToken === 'NOW_END_OF_DAY' || normalizedToken === 'END_OF_DAY' || normalizedToken === 'END_OF_TODAY') {
|
|
9318
|
+
return createAssistantNowDayEndExpr();
|
|
9319
|
+
}
|
|
8855
9320
|
var parsed = parseAssistantNowRelativeToken(trimmed);
|
|
8856
9321
|
if (!parsed) {
|
|
8857
9322
|
return value;
|
|
@@ -9197,7 +9662,27 @@ function isAssistantDateArithmeticArgumentError(error) {
|
|
|
9197
9662
|
|| message.includes('undefined variable: now_start_of_month')
|
|
9198
9663
|
|| message.includes('undefined variable: now_start_of_last_month')
|
|
9199
9664
|
|| message.includes('undefined variable: now_start_of_next_month')
|
|
9200
|
-
|| message.includes('undefined variable: now_end_of_month')
|
|
9665
|
+
|| message.includes('undefined variable: now_end_of_month')
|
|
9666
|
+
|| message.includes('undefined variable: start_of_week')
|
|
9667
|
+
|| message.includes('undefined variable: start_of_week_utc')
|
|
9668
|
+
|| message.includes('undefined variable: end_of_week')
|
|
9669
|
+
|| message.includes('undefined variable: end_of_week_utc')
|
|
9670
|
+
|| message.includes('undefined variable: start_of_day')
|
|
9671
|
+
|| message.includes('undefined variable: start_of_day_utc')
|
|
9672
|
+
|| message.includes('undefined variable: end_of_day')
|
|
9673
|
+
|| message.includes('undefined variable: end_of_day_utc')
|
|
9674
|
+
|| message.includes('undefined variable: start_of_today')
|
|
9675
|
+
|| message.includes('undefined variable: start_of_today_utc')
|
|
9676
|
+
|| message.includes('undefined variable: end_of_today')
|
|
9677
|
+
|| message.includes('undefined variable: end_of_today_utc');
|
|
9678
|
+
}
|
|
9679
|
+
function isAssistantRankSortByError(error) {
|
|
9680
|
+
var message = normalizeOptionalString(error === null || error === void 0 ? void 0 : error.message).toLowerCase();
|
|
9681
|
+
if (!message) {
|
|
9682
|
+
return false;
|
|
9683
|
+
}
|
|
9684
|
+
return message.includes('$rank must be specified with a top level sortby expression with exactly one element')
|
|
9685
|
+
|| message.includes('$denserank must be specified with a top level sortby expression with exactly one element');
|
|
9201
9686
|
}
|
|
9202
9687
|
function didAssistantValueChange(before, after) {
|
|
9203
9688
|
try {
|
|
@@ -9217,6 +9702,33 @@ function repairAssistantDateArithmeticInPipeline(pipeline) {
|
|
|
9217
9702
|
changed: didAssistantValueChange(pipeline, repaired)
|
|
9218
9703
|
};
|
|
9219
9704
|
}
|
|
9705
|
+
function repairAssistantDateArithmeticInQuery(query) {
|
|
9706
|
+
var repairedRaw = normalizeAssistantNowExprPlaceholdersDeep(query);
|
|
9707
|
+
var repaired = (repairedRaw && typeof repairedRaw === 'object' && !Array.isArray(repairedRaw))
|
|
9708
|
+
? repairedRaw
|
|
9709
|
+
: query;
|
|
9710
|
+
return {
|
|
9711
|
+
query: repaired,
|
|
9712
|
+
changed: didAssistantValueChange(query, repaired)
|
|
9713
|
+
};
|
|
9714
|
+
}
|
|
9715
|
+
function repairAssistantRankSortByInPipeline(pipeline) {
|
|
9716
|
+
var repaired = Array.isArray(pipeline)
|
|
9717
|
+
? pipeline.map(function (stage) {
|
|
9718
|
+
if (!stage || typeof stage !== 'object' || Array.isArray(stage)) {
|
|
9719
|
+
return stage;
|
|
9720
|
+
}
|
|
9721
|
+
if (!stage.$setWindowFields || typeof stage.$setWindowFields !== 'object' || Array.isArray(stage.$setWindowFields)) {
|
|
9722
|
+
return stage;
|
|
9723
|
+
}
|
|
9724
|
+
return __assign(__assign({}, stage), { $setWindowFields: normalizeAssistantSetWindowFieldsRankSortBy(stage.$setWindowFields) });
|
|
9725
|
+
})
|
|
9726
|
+
: pipeline;
|
|
9727
|
+
return {
|
|
9728
|
+
pipeline: repaired,
|
|
9729
|
+
changed: didAssistantValueChange(pipeline, repaired)
|
|
9730
|
+
};
|
|
9731
|
+
}
|
|
9220
9732
|
function isMatchExpressionOperand(value) {
|
|
9221
9733
|
if (typeof value === 'string') {
|
|
9222
9734
|
return value.startsWith('$$');
|
|
@@ -9386,6 +9898,55 @@ function createAssistantNowMonthStartExpr() {
|
|
|
9386
9898
|
}
|
|
9387
9899
|
};
|
|
9388
9900
|
}
|
|
9901
|
+
function createAssistantNowWeekStartExpr() {
|
|
9902
|
+
return {
|
|
9903
|
+
$dateTrunc: {
|
|
9904
|
+
date: '$$NOW',
|
|
9905
|
+
unit: 'week',
|
|
9906
|
+
startOfWeek: 'monday',
|
|
9907
|
+
timezone: 'UTC'
|
|
9908
|
+
}
|
|
9909
|
+
};
|
|
9910
|
+
}
|
|
9911
|
+
function createAssistantNowDayStartExpr() {
|
|
9912
|
+
return {
|
|
9913
|
+
$dateTrunc: {
|
|
9914
|
+
date: '$$NOW',
|
|
9915
|
+
unit: 'day',
|
|
9916
|
+
timezone: 'UTC'
|
|
9917
|
+
}
|
|
9918
|
+
};
|
|
9919
|
+
}
|
|
9920
|
+
function createAssistantNowWeekEndExpr() {
|
|
9921
|
+
return {
|
|
9922
|
+
$dateSubtract: {
|
|
9923
|
+
startDate: {
|
|
9924
|
+
$dateAdd: {
|
|
9925
|
+
startDate: createAssistantNowWeekStartExpr(),
|
|
9926
|
+
unit: 'week',
|
|
9927
|
+
amount: 1
|
|
9928
|
+
}
|
|
9929
|
+
},
|
|
9930
|
+
unit: 'millisecond',
|
|
9931
|
+
amount: 1
|
|
9932
|
+
}
|
|
9933
|
+
};
|
|
9934
|
+
}
|
|
9935
|
+
function createAssistantNowDayEndExpr() {
|
|
9936
|
+
return {
|
|
9937
|
+
$dateSubtract: {
|
|
9938
|
+
startDate: {
|
|
9939
|
+
$dateAdd: {
|
|
9940
|
+
startDate: createAssistantNowDayStartExpr(),
|
|
9941
|
+
unit: 'day',
|
|
9942
|
+
amount: 1
|
|
9943
|
+
}
|
|
9944
|
+
},
|
|
9945
|
+
unit: 'millisecond',
|
|
9946
|
+
amount: 1
|
|
9947
|
+
}
|
|
9948
|
+
};
|
|
9949
|
+
}
|
|
9389
9950
|
function isAssistantNowMonthStartExpr(value) {
|
|
9390
9951
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
9391
9952
|
return false;
|
|
@@ -9656,6 +10217,59 @@ function normalizeAssistantMonthlyCalendarWindowPipeline(pipeline) {
|
|
|
9656
10217
|
return next;
|
|
9657
10218
|
});
|
|
9658
10219
|
}
|
|
10220
|
+
function isAssistantRankWindowOutputExpression(value) {
|
|
10221
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
10222
|
+
return false;
|
|
10223
|
+
}
|
|
10224
|
+
return Object.prototype.hasOwnProperty.call(value, '$rank')
|
|
10225
|
+
|| Object.prototype.hasOwnProperty.call(value, '$denseRank');
|
|
10226
|
+
}
|
|
10227
|
+
function normalizeAssistantSetWindowFieldsRankSortBy(setWindowFields) {
|
|
10228
|
+
var _a;
|
|
10229
|
+
if (!setWindowFields || typeof setWindowFields !== 'object' || Array.isArray(setWindowFields)) {
|
|
10230
|
+
return setWindowFields;
|
|
10231
|
+
}
|
|
10232
|
+
var output = setWindowFields.output;
|
|
10233
|
+
if (!output || typeof output !== 'object' || Array.isArray(output)) {
|
|
10234
|
+
return setWindowFields;
|
|
10235
|
+
}
|
|
10236
|
+
var usesRankWindowFunction = Object.values(output).some(function (value) { return isAssistantRankWindowOutputExpression(value); });
|
|
10237
|
+
if (!usesRankWindowFunction) {
|
|
10238
|
+
return setWindowFields;
|
|
10239
|
+
}
|
|
10240
|
+
var sortBy = setWindowFields.sortBy;
|
|
10241
|
+
if (!sortBy || typeof sortBy !== 'object' || Array.isArray(sortBy)) {
|
|
10242
|
+
return setWindowFields;
|
|
10243
|
+
}
|
|
10244
|
+
var sortKeys = Object.keys(sortBy).filter(function (key) { return String(key || '').trim(); });
|
|
10245
|
+
if (sortKeys.length <= 1) {
|
|
10246
|
+
return setWindowFields;
|
|
10247
|
+
}
|
|
10248
|
+
var primarySortKey = sortKeys[0];
|
|
10249
|
+
return __assign(__assign({}, setWindowFields), { sortBy: (_a = {},
|
|
10250
|
+
_a[primarySortKey] = sortBy[primarySortKey],
|
|
10251
|
+
_a) });
|
|
10252
|
+
}
|
|
10253
|
+
function normalizeAssistantSortTieBreakersForLimit(pipeline) {
|
|
10254
|
+
return pipeline.map(function (stage, index) {
|
|
10255
|
+
if (!stage || typeof stage !== 'object' || Array.isArray(stage)) {
|
|
10256
|
+
return stage;
|
|
10257
|
+
}
|
|
10258
|
+
var sort = stage.$sort;
|
|
10259
|
+
if (!sort || typeof sort !== 'object' || Array.isArray(sort)) {
|
|
10260
|
+
return stage;
|
|
10261
|
+
}
|
|
10262
|
+
var nextStage = pipeline[index + 1];
|
|
10263
|
+
if (!nextStage || typeof nextStage !== 'object' || Array.isArray(nextStage) || typeof nextStage.$limit !== 'number') {
|
|
10264
|
+
return stage;
|
|
10265
|
+
}
|
|
10266
|
+
var sortKeys = Object.keys(sort).filter(function (key) { return String(key || '').trim(); });
|
|
10267
|
+
if (sortKeys.length !== 1 || sortKeys[0] === '_id') {
|
|
10268
|
+
return stage;
|
|
10269
|
+
}
|
|
10270
|
+
return __assign(__assign({}, stage), { $sort: __assign(__assign({}, sort), { _id: 1 }) });
|
|
10271
|
+
});
|
|
10272
|
+
}
|
|
9659
10273
|
function normalizeAssistantAggregatePipeline(pipeline, collection) {
|
|
9660
10274
|
if (!Array.isArray(pipeline)) {
|
|
9661
10275
|
return [];
|
|
@@ -9677,9 +10291,13 @@ function normalizeAssistantAggregatePipeline(pipeline, collection) {
|
|
|
9677
10291
|
var statusNormalized = isInvoiceCollection ? normalizeInvoiceStatusMatch(exprRewritten) : exprRewritten;
|
|
9678
10292
|
next.$geoNear = __assign(__assign({}, next.$geoNear), { query: applyAssistantNameRegexToQuery(statusNormalized) });
|
|
9679
10293
|
}
|
|
10294
|
+
if (next.$setWindowFields && typeof next.$setWindowFields === 'object' && !Array.isArray(next.$setWindowFields)) {
|
|
10295
|
+
next.$setWindowFields = normalizeAssistantSetWindowFieldsRankSortBy(next.$setWindowFields);
|
|
10296
|
+
}
|
|
9680
10297
|
return normalizeAssistantNowExprPlaceholdersDeep(next);
|
|
9681
10298
|
});
|
|
9682
|
-
|
|
10299
|
+
var stableSortPipeline = normalizeAssistantSortTieBreakersForLimit(normalizedPipeline);
|
|
10300
|
+
return normalizeAssistantMonthlyCalendarWindowPipeline(stableSortPipeline);
|
|
9683
10301
|
}
|
|
9684
10302
|
function buildAssistantAggregatePipeline(query, pipeline) {
|
|
9685
10303
|
var _a;
|
|
@@ -12306,6 +12924,14 @@ var AI_ASSISTANT_BRIDGE_COLLECTION_ALIASES = {
|
|
|
12306
12924
|
workorderdynamics: 'work-order-dynamics',
|
|
12307
12925
|
workordersdynamic: 'work-order-dynamics',
|
|
12308
12926
|
workordersdynamics: 'work-order-dynamics',
|
|
12927
|
+
trucktreatingdelivery: 'jobs',
|
|
12928
|
+
trucktreatingdeliveries: 'jobs',
|
|
12929
|
+
trucktreatingjob: 'jobs',
|
|
12930
|
+
trucktreatingjobs: 'jobs',
|
|
12931
|
+
trucktreatingroute: 'jobs',
|
|
12932
|
+
trucktreatingroutes: 'jobs',
|
|
12933
|
+
trucktreatingrouteevent: 'jobs',
|
|
12934
|
+
trucktreatingrouteevents: 'jobs',
|
|
12309
12935
|
delivery: 'work-order-dynamics',
|
|
12310
12936
|
deliveries: 'work-order-dynamics',
|
|
12311
12937
|
blendticket: 'chemical-blends',
|
|
@@ -12328,6 +12954,10 @@ var AI_ASSISTANT_DIRECT_COLLECTION_FALLBACK_ALLOWLIST = new Set([
|
|
|
12328
12954
|
'chemical-blends',
|
|
12329
12955
|
'report-chemical-blends',
|
|
12330
12956
|
'jobs',
|
|
12957
|
+
'production-deliveries',
|
|
12958
|
+
'truck-treating-deliveries',
|
|
12959
|
+
'duplicate-deliveries',
|
|
12960
|
+
'third-party-drivers',
|
|
12331
12961
|
'customers',
|
|
12332
12962
|
'support-tickets'
|
|
12333
12963
|
]);
|
|
@@ -12429,49 +13059,52 @@ function resolveAssistantCrossCollectionFallbackCandidates(collection) {
|
|
|
12429
13059
|
});
|
|
12430
13060
|
return deduped;
|
|
12431
13061
|
}
|
|
13062
|
+
function resolveAssistantAvailableCrossCollectionFallbacksFromNames(collection, triedCollections, collectionNames) {
|
|
13063
|
+
var candidates = resolveAssistantCrossCollectionFallbackCandidates(collection);
|
|
13064
|
+
if (!candidates.length) {
|
|
13065
|
+
return [];
|
|
13066
|
+
}
|
|
13067
|
+
var namesByFamily = new Map();
|
|
13068
|
+
(collectionNames || []).forEach(function (name) {
|
|
13069
|
+
var family = normalizeAssistantCollectionFamilyName(name);
|
|
13070
|
+
if (!family) {
|
|
13071
|
+
return;
|
|
13072
|
+
}
|
|
13073
|
+
var existing = namesByFamily.get(family) || [];
|
|
13074
|
+
existing.push(name);
|
|
13075
|
+
namesByFamily.set(family, existing);
|
|
13076
|
+
});
|
|
13077
|
+
var currentFamily = normalizeAssistantCollectionFamilyName(collection);
|
|
13078
|
+
var available = [];
|
|
13079
|
+
candidates.forEach(function (candidate) {
|
|
13080
|
+
var family = normalizeAssistantCollectionFamilyName(candidate);
|
|
13081
|
+
if (!family || family === currentFamily || hasAssistantCollectionBeenTried(triedCollections, candidate)) {
|
|
13082
|
+
return;
|
|
13083
|
+
}
|
|
13084
|
+
var familyNames = namesByFamily.get(family) || [];
|
|
13085
|
+
var preferred = familyNames.find(function (name) { return !name.startsWith('report-') && !isVersionCollectionName(name); })
|
|
13086
|
+
|| familyNames.find(function (name) { return !name.startsWith('report-'); })
|
|
13087
|
+
|| familyNames[0]
|
|
13088
|
+
|| '';
|
|
13089
|
+
if (!preferred && isAssistantDirectCollectionFallbackAllowed(candidate)) {
|
|
13090
|
+
preferred = candidate;
|
|
13091
|
+
}
|
|
13092
|
+
if (!preferred || hasAssistantCollectionBeenTried(triedCollections, preferred) || available.includes(preferred)) {
|
|
13093
|
+
return;
|
|
13094
|
+
}
|
|
13095
|
+
available.push(preferred);
|
|
13096
|
+
});
|
|
13097
|
+
return available;
|
|
13098
|
+
}
|
|
12432
13099
|
function resolveAssistantAvailableCrossCollectionFallbacks(db, dbName, collection, triedCollections) {
|
|
12433
13100
|
return __awaiter(this, void 0, void 0, function () {
|
|
12434
|
-
var
|
|
13101
|
+
var collectionNames;
|
|
12435
13102
|
return __generator(this, function (_a) {
|
|
12436
13103
|
switch (_a.label) {
|
|
12437
|
-
case 0:
|
|
12438
|
-
candidates = resolveAssistantCrossCollectionFallbackCandidates(collection);
|
|
12439
|
-
if (!candidates.length) {
|
|
12440
|
-
return [2 /*return*/, []];
|
|
12441
|
-
}
|
|
12442
|
-
return [4 /*yield*/, listAssistantCollections(db, dbName)];
|
|
13104
|
+
case 0: return [4 /*yield*/, listAssistantCollections(db, dbName)];
|
|
12443
13105
|
case 1:
|
|
12444
13106
|
collectionNames = _a.sent();
|
|
12445
|
-
|
|
12446
|
-
collectionNames.forEach(function (name) {
|
|
12447
|
-
var family = normalizeAssistantCollectionFamilyName(name);
|
|
12448
|
-
if (!family) {
|
|
12449
|
-
return;
|
|
12450
|
-
}
|
|
12451
|
-
var existing = namesByFamily.get(family) || [];
|
|
12452
|
-
existing.push(name);
|
|
12453
|
-
namesByFamily.set(family, existing);
|
|
12454
|
-
});
|
|
12455
|
-
currentFamily = normalizeAssistantCollectionFamilyName(collection);
|
|
12456
|
-
available = [];
|
|
12457
|
-
candidates.forEach(function (candidate) {
|
|
12458
|
-
var family = normalizeAssistantCollectionFamilyName(candidate);
|
|
12459
|
-
if (!family || family === currentFamily || hasAssistantCollectionBeenTried(triedCollections, candidate)) {
|
|
12460
|
-
return;
|
|
12461
|
-
}
|
|
12462
|
-
var familyNames = namesByFamily.get(family) || [];
|
|
12463
|
-
if (!familyNames.length) {
|
|
12464
|
-
return;
|
|
12465
|
-
}
|
|
12466
|
-
var preferred = familyNames.find(function (name) { return !name.startsWith('report-') && !isVersionCollectionName(name); })
|
|
12467
|
-
|| familyNames.find(function (name) { return !name.startsWith('report-'); })
|
|
12468
|
-
|| familyNames[0];
|
|
12469
|
-
if (!preferred || hasAssistantCollectionBeenTried(triedCollections, preferred) || available.includes(preferred)) {
|
|
12470
|
-
return;
|
|
12471
|
-
}
|
|
12472
|
-
available.push(preferred);
|
|
12473
|
-
});
|
|
12474
|
-
return [2 /*return*/, available];
|
|
13107
|
+
return [2 /*return*/, resolveAssistantAvailableCrossCollectionFallbacksFromNames(collection, triedCollections, collectionNames)];
|
|
12475
13108
|
}
|
|
12476
13109
|
});
|
|
12477
13110
|
});
|
|
@@ -13395,7 +14028,7 @@ function waitForCodexWorkerMessage(worker, streamStatusHandler) {
|
|
|
13395
14028
|
}
|
|
13396
14029
|
function runCodexInWorkerThread(prompt, runOptions, config, streamStatusHandler) {
|
|
13397
14030
|
return __awaiter(this, void 0, void 0, function () {
|
|
13398
|
-
var streamedOptions, codexClient, workerPath, codexClient,
|
|
14031
|
+
var streamedOptions, codexClient, workerPath, codexClient, error_7, codexClient;
|
|
13399
14032
|
return __generator(this, function (_a) {
|
|
13400
14033
|
switch (_a.label) {
|
|
13401
14034
|
case 0:
|
|
@@ -13416,11 +14049,11 @@ function runCodexInWorkerThread(prompt, runOptions, config, streamStatusHandler)
|
|
|
13416
14049
|
return [4 /*yield*/, runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config, streamStatusHandler)];
|
|
13417
14050
|
case 6: return [2 /*return*/, _a.sent()];
|
|
13418
14051
|
case 7:
|
|
13419
|
-
|
|
13420
|
-
if (!(
|
|
13421
|
-
throw
|
|
14052
|
+
error_7 = _a.sent();
|
|
14053
|
+
if (!(error_7 instanceof CodexWorkerBootstrapError)) {
|
|
14054
|
+
throw error_7;
|
|
13422
14055
|
}
|
|
13423
|
-
console.error('Codex worker bootstrap failed, falling back to in-process run.',
|
|
14056
|
+
console.error('Codex worker bootstrap failed, falling back to in-process run.', error_7);
|
|
13424
14057
|
codexClient = getAssistantCodexClient(config);
|
|
13425
14058
|
return [4 /*yield*/, codexClient.run(prompt, streamedOptions)];
|
|
13426
14059
|
case 8: return [2 /*return*/, _a.sent()];
|
|
@@ -13458,7 +14091,7 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config,
|
|
|
13458
14091
|
timeoutMs = ((sanitizedOptions === null || sanitizedOptions === void 0 ? void 0 : sanitizedOptions.timeoutMs) || resolveCodexTimeoutMs()) + 15000;
|
|
13459
14092
|
timeoutController = new AbortController();
|
|
13460
14093
|
timeoutPromise = (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
13461
|
-
var
|
|
14094
|
+
var error_8;
|
|
13462
14095
|
return __generator(this, function (_a) {
|
|
13463
14096
|
switch (_a.label) {
|
|
13464
14097
|
case 0:
|
|
@@ -13468,11 +14101,11 @@ function runCodexInWorkerThreadInternal(workerPath, prompt, runOptions, config,
|
|
|
13468
14101
|
_a.sent();
|
|
13469
14102
|
return [2 /*return*/, { type: 'timeout' }];
|
|
13470
14103
|
case 2:
|
|
13471
|
-
|
|
13472
|
-
if ((
|
|
14104
|
+
error_8 = _a.sent();
|
|
14105
|
+
if ((error_8 === null || error_8 === void 0 ? void 0 : error_8.name) === 'AbortError') {
|
|
13473
14106
|
return [2 /*return*/, { type: 'aborted' }];
|
|
13474
14107
|
}
|
|
13475
|
-
throw
|
|
14108
|
+
throw error_8;
|
|
13476
14109
|
case 3: return [2 /*return*/];
|
|
13477
14110
|
}
|
|
13478
14111
|
});
|
|
@@ -13648,145 +14281,26 @@ function directoryExists(target) {
|
|
|
13648
14281
|
});
|
|
13649
14282
|
});
|
|
13650
14283
|
}
|
|
13651
|
-
function
|
|
13652
|
-
if (!target || !root) {
|
|
13653
|
-
return false;
|
|
13654
|
-
}
|
|
13655
|
-
var relative = path.relative(root, target);
|
|
13656
|
-
if (!relative) {
|
|
13657
|
-
return true;
|
|
13658
|
-
}
|
|
13659
|
-
return !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
13660
|
-
}
|
|
13661
|
-
function isAssistantProjectRoot(candidate) {
|
|
14284
|
+
function resolveAssistantWorkspaceRoot() {
|
|
13662
14285
|
return __awaiter(this, void 0, void 0, function () {
|
|
13663
|
-
var
|
|
14286
|
+
var candidate, stat, _a;
|
|
13664
14287
|
return __generator(this, function (_b) {
|
|
13665
14288
|
switch (_b.label) {
|
|
13666
14289
|
case 0:
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
return [4 /*yield*/, directoryExists(candidate)];
|
|
13671
|
-
case 1:
|
|
13672
|
-
if (!(_b.sent())) {
|
|
13673
|
-
return [2 /*return*/, false];
|
|
13674
|
-
}
|
|
13675
|
-
serverPath = path.join(candidate, 'server');
|
|
13676
|
-
angularPath = path.join(candidate, 'angular');
|
|
13677
|
-
return [4 /*yield*/, directoryExists(serverPath)];
|
|
13678
|
-
case 2:
|
|
13679
|
-
_a = (_b.sent());
|
|
13680
|
-
if (!_a) return [3 /*break*/, 4];
|
|
13681
|
-
return [4 /*yield*/, directoryExists(angularPath)];
|
|
13682
|
-
case 3:
|
|
13683
|
-
_a = (_b.sent());
|
|
13684
|
-
_b.label = 4;
|
|
13685
|
-
case 4:
|
|
13686
|
-
if (_a) {
|
|
13687
|
-
return [2 /*return*/, true];
|
|
13688
|
-
}
|
|
13689
|
-
return [4 /*yield*/, directoryExists(serverPath)];
|
|
13690
|
-
case 5:
|
|
13691
|
-
hasServer = _b.sent();
|
|
13692
|
-
return [4 /*yield*/, pathExists(path.join(candidate, 'package.json'))];
|
|
13693
|
-
case 6:
|
|
13694
|
-
hasPackage = _b.sent();
|
|
13695
|
-
return [2 /*return*/, hasServer && hasPackage];
|
|
13696
|
-
}
|
|
13697
|
-
});
|
|
13698
|
-
});
|
|
13699
|
-
}
|
|
13700
|
-
function resolveAssistantProjectRoot(clientDir) {
|
|
13701
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
13702
|
-
var normalized, resolved, root, parts, i, candidate;
|
|
13703
|
-
return __generator(this, function (_a) {
|
|
13704
|
-
switch (_a.label) {
|
|
13705
|
-
case 0:
|
|
13706
|
-
normalized = normalizeOptionalString(clientDir);
|
|
13707
|
-
if (!normalized) {
|
|
13708
|
-
return [2 /*return*/, ''];
|
|
13709
|
-
}
|
|
13710
|
-
resolved = path.resolve(normalized);
|
|
13711
|
-
root = path.parse(resolved).root || path.sep;
|
|
13712
|
-
parts = resolved.slice(root.length).split(path.sep).filter(Boolean);
|
|
13713
|
-
if (!parts.length) {
|
|
13714
|
-
return [2 /*return*/, ''];
|
|
13715
|
-
}
|
|
13716
|
-
i = parts.length;
|
|
13717
|
-
_a.label = 1;
|
|
13718
|
-
case 1:
|
|
13719
|
-
if (!(i >= 1)) return [3 /*break*/, 4];
|
|
13720
|
-
candidate = path.join.apply(path, __spreadArray([root], __read(parts.slice(0, i)), false));
|
|
13721
|
-
return [4 /*yield*/, isAssistantProjectRoot(candidate)];
|
|
13722
|
-
case 2:
|
|
13723
|
-
if (_a.sent()) {
|
|
13724
|
-
return [2 /*return*/, candidate];
|
|
13725
|
-
}
|
|
13726
|
-
_a.label = 3;
|
|
13727
|
-
case 3:
|
|
13728
|
-
i -= 1;
|
|
13729
|
-
return [3 /*break*/, 1];
|
|
13730
|
-
case 4: return [2 /*return*/, ''];
|
|
13731
|
-
}
|
|
13732
|
-
});
|
|
13733
|
-
});
|
|
13734
|
-
}
|
|
13735
|
-
function resolveAssistantWorkspaceRoot() {
|
|
13736
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
13737
|
-
var config, configured, configuredRoot, clientDir, resolvedClientDir, projectRoot, _a, candidate, stat, _b;
|
|
13738
|
-
return __generator(this, function (_c) {
|
|
13739
|
-
switch (_c.label) {
|
|
13740
|
-
case 0:
|
|
13741
|
-
config = resolveio_server_app_1.ResolveIOServer.getServerConfig() || {};
|
|
13742
|
-
configured = normalizeOptionalString(config['AI_ASSISTANT_WORKSPACE_ROOT']
|
|
13743
|
-
|| process.env.AI_ASSISTANT_WORKSPACE_ROOT
|
|
13744
|
-
|| config['CODEX_WORKSPACE_ROOT']
|
|
13745
|
-
|| process.env.CODEX_WORKSPACE_ROOT);
|
|
13746
|
-
configuredRoot = configured ? path.resolve(configured) : '';
|
|
13747
|
-
clientDir = normalizeOptionalString(resolveio_server_app_1.ResolveIOServer.getClientDir());
|
|
13748
|
-
resolvedClientDir = clientDir ? path.resolve(clientDir) : '';
|
|
13749
|
-
if (!resolvedClientDir) return [3 /*break*/, 2];
|
|
13750
|
-
return [4 /*yield*/, resolveAssistantProjectRoot(resolvedClientDir)];
|
|
14290
|
+
candidate = '/var/app/current';
|
|
14291
|
+
stat = null;
|
|
14292
|
+
_b.label = 1;
|
|
13751
14293
|
case 1:
|
|
13752
|
-
|
|
13753
|
-
return [
|
|
14294
|
+
_b.trys.push([1, 3, , 4]);
|
|
14295
|
+
return [4 /*yield*/, fs_1.promises.stat(candidate)];
|
|
13754
14296
|
case 2:
|
|
13755
|
-
|
|
13756
|
-
|
|
14297
|
+
stat = _b.sent();
|
|
14298
|
+
return [3 /*break*/, 4];
|
|
13757
14299
|
case 3:
|
|
13758
|
-
|
|
13759
|
-
candidate = configuredRoot || projectRoot || resolvedClientDir || process.cwd();
|
|
13760
|
-
if (configuredRoot) {
|
|
13761
|
-
if (projectRoot && isAssistantPathUnderRoot(projectRoot, configuredRoot)) {
|
|
13762
|
-
candidate = projectRoot;
|
|
13763
|
-
}
|
|
13764
|
-
else if (projectRoot && isAssistantPathUnderRoot(configuredRoot, projectRoot)) {
|
|
13765
|
-
candidate = configuredRoot;
|
|
13766
|
-
}
|
|
13767
|
-
else {
|
|
13768
|
-
candidate = configuredRoot;
|
|
13769
|
-
}
|
|
13770
|
-
}
|
|
13771
|
-
else if (projectRoot) {
|
|
13772
|
-
candidate = projectRoot;
|
|
13773
|
-
}
|
|
13774
|
-
else if (resolvedClientDir) {
|
|
13775
|
-
candidate = resolvedClientDir;
|
|
13776
|
-
}
|
|
14300
|
+
_a = _b.sent();
|
|
13777
14301
|
stat = null;
|
|
13778
|
-
|
|
14302
|
+
return [3 /*break*/, 4];
|
|
13779
14303
|
case 4:
|
|
13780
|
-
_c.trys.push([4, 6, , 7]);
|
|
13781
|
-
return [4 /*yield*/, fs_1.promises.stat(candidate)];
|
|
13782
|
-
case 5:
|
|
13783
|
-
stat = _c.sent();
|
|
13784
|
-
return [3 /*break*/, 7];
|
|
13785
|
-
case 6:
|
|
13786
|
-
_b = _c.sent();
|
|
13787
|
-
stat = null;
|
|
13788
|
-
return [3 /*break*/, 7];
|
|
13789
|
-
case 7:
|
|
13790
14304
|
if (!stat || !stat.isDirectory()) {
|
|
13791
14305
|
throw new Error('AI assistant workspace root not found.');
|
|
13792
14306
|
}
|
|
@@ -13897,6 +14411,9 @@ var AI_ASSISTANT_FEATURE_INFO_PATTERNS = [
|
|
|
13897
14411
|
/\bwhat\s+changed\b/,
|
|
13898
14412
|
/\brecent\s+changes?\b/,
|
|
13899
14413
|
/\blatest\s+changes?\b/,
|
|
14414
|
+
/\bwhat\s+did\s+(?:the\s+)?last\s+(?:system\s+)?update\s+(?:just\s+)?do\b/i,
|
|
14415
|
+
/\blast\s+system\s+update\b/i,
|
|
14416
|
+
/\blast\s+update\b[\s\S]{0,30}\bdo\b/i,
|
|
13900
14417
|
/\bchangelog\b/,
|
|
13901
14418
|
/\brelease\s+notes?\b/
|
|
13902
14419
|
];
|
|
@@ -13921,6 +14438,8 @@ var AI_ASSISTANT_BUG_ISSUE_PATTERNS = [
|
|
|
13921
14438
|
/\bwon['’]t\s+let\s+me\b/,
|
|
13922
14439
|
/\bcan['’]?t\s+close\b/,
|
|
13923
14440
|
/\bwhy\s+don['’]t\s+i\s+see\b/,
|
|
14441
|
+
/\bmissing\b[\s\S]{0,30}\bdropdown\b/i,
|
|
14442
|
+
/\bdropdown\b[\s\S]{0,30}\bmissing\b/i,
|
|
13924
14443
|
/\bsubmit\s+button\b[\s\S]{0,60}\b(red|disabled|grey|gray)\b/i
|
|
13925
14444
|
];
|
|
13926
14445
|
function isAssistantDataQuestion(message) {
|
|
@@ -14933,6 +15452,12 @@ function shouldUseAssistantNavigationFastPath(message, hasAttachments) {
|
|
|
14933
15452
|
if (!text) {
|
|
14934
15453
|
return false;
|
|
14935
15454
|
}
|
|
15455
|
+
if (isAssistantChangeHistoryQuestion(text)) {
|
|
15456
|
+
return false;
|
|
15457
|
+
}
|
|
15458
|
+
if (isAssistantBugIssueQuestion(text)) {
|
|
15459
|
+
return false;
|
|
15460
|
+
}
|
|
14936
15461
|
if (!isAssistantRouteLookupQuestion(text)) {
|
|
14937
15462
|
return false;
|
|
14938
15463
|
}
|
|
@@ -15020,6 +15545,8 @@ function resolveAssistantNavigationFastPathResponse(params) {
|
|
|
15020
15545
|
}
|
|
15021
15546
|
var AI_ASSISTANT_CHANGE_HISTORY_PATTERNS = [
|
|
15022
15547
|
/\bwhat\s+changed\b/i,
|
|
15548
|
+
/\bwhat\s+changed\s+on\b/i,
|
|
15549
|
+
/\bwhat\s+changed\s+on\s+(?:this|that|the)\s+page\b/i,
|
|
15023
15550
|
/\bmost\s+recent\s+change\b/i,
|
|
15024
15551
|
/\blatest\s+changes?\b/i,
|
|
15025
15552
|
/\brecent\s+changes?\b/i,
|
|
@@ -15029,12 +15556,15 @@ var AI_ASSISTANT_CHANGE_HISTORY_PATTERNS = [
|
|
|
15029
15556
|
/\bwhen\s+did\b[\s\S]{0,80}\bget\s+added\b/i,
|
|
15030
15557
|
/\bwhen\s+was\b[\s\S]{0,80}\badded\b/i,
|
|
15031
15558
|
/\bwhen\s+does\b[\s\S]{0,80}\bget\s+added\b/i,
|
|
15559
|
+
/\bwhat\s+did\s+(?:the\s+)?last\s+(?:system\s+)?update\s+(?:just\s+)?do\b/i,
|
|
15560
|
+
/\blast\s+system\s+update\b[\s\S]{0,40}\bdo\b/i,
|
|
15032
15561
|
/\bhow\s+long\b.*\bbeen\s+(this|that)\s+way\b/i,
|
|
15033
15562
|
/\bsince\s+when\b/i,
|
|
15034
15563
|
/\bchangelog\b/i,
|
|
15035
15564
|
/\brelease\s+notes?\b/i,
|
|
15036
15565
|
/\bgithub\b/i,
|
|
15037
|
-
/\bcommits?\b/i
|
|
15566
|
+
/\bcommits?\b/i,
|
|
15567
|
+
/\bupdate\s+history\b/i
|
|
15038
15568
|
];
|
|
15039
15569
|
function isAssistantChangeHistoryQuestion(message) {
|
|
15040
15570
|
var text = normalizeOptionalString(message).toLowerCase();
|
|
@@ -16389,7 +16919,7 @@ function resolveAssistantDatabaseNameForSystemCollections() {
|
|
|
16389
16919
|
}
|
|
16390
16920
|
function updateAssistantMessageWithFallback(messageId, setPayload) {
|
|
16391
16921
|
return __awaiter(this, void 0, void 0, function () {
|
|
16392
|
-
var
|
|
16922
|
+
var error_9, dbName, _a;
|
|
16393
16923
|
return __generator(this, function (_b) {
|
|
16394
16924
|
switch (_b.label) {
|
|
16395
16925
|
case 0:
|
|
@@ -16404,9 +16934,9 @@ function updateAssistantMessageWithFallback(messageId, setPayload) {
|
|
|
16404
16934
|
_b.sent();
|
|
16405
16935
|
return [2 /*return*/];
|
|
16406
16936
|
case 3:
|
|
16407
|
-
|
|
16408
|
-
if (!isAssistantTransactionCommittedError(
|
|
16409
|
-
throw
|
|
16937
|
+
error_9 = _b.sent();
|
|
16938
|
+
if (!isAssistantTransactionCommittedError(error_9)) {
|
|
16939
|
+
throw error_9;
|
|
16410
16940
|
}
|
|
16411
16941
|
dbName = resolveAssistantDatabaseNameForSystemCollections();
|
|
16412
16942
|
_b.label = 4;
|
|
@@ -16436,7 +16966,7 @@ function updateAssistantMessageWithFallback(messageId, setPayload) {
|
|
|
16436
16966
|
}
|
|
16437
16967
|
function touchConversation(idConversation, timestamp, lastMessageId) {
|
|
16438
16968
|
return __awaiter(this, void 0, void 0, function () {
|
|
16439
|
-
var update,
|
|
16969
|
+
var update, error_10, dbName;
|
|
16440
16970
|
return __generator(this, function (_a) {
|
|
16441
16971
|
switch (_a.label) {
|
|
16442
16972
|
case 0:
|
|
@@ -16455,9 +16985,9 @@ function touchConversation(idConversation, timestamp, lastMessageId) {
|
|
|
16455
16985
|
_a.sent();
|
|
16456
16986
|
return [2 /*return*/];
|
|
16457
16987
|
case 3:
|
|
16458
|
-
|
|
16459
|
-
if (!isAssistantTransactionCommittedError(
|
|
16460
|
-
throw
|
|
16988
|
+
error_10 = _a.sent();
|
|
16989
|
+
if (!isAssistantTransactionCommittedError(error_10)) {
|
|
16990
|
+
throw error_10;
|
|
16461
16991
|
}
|
|
16462
16992
|
dbName = resolveAssistantDatabaseNameForSystemCollections();
|
|
16463
16993
|
return [4 /*yield*/, resolveio_server_app_1.ResolveIOServer.getMongoConnection()
|