@resolveio/server-lib 22.0.15 → 22.0.16

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.
@@ -73,6 +73,7 @@ export declare function buildDisplayTable(docs: any[], options?: {
73
73
  includeGroupFromId?: boolean;
74
74
  }): AiAssistantDisplayTable;
75
75
  export declare function formatDisplayTableMarkdown(display: AiAssistantDisplayTable): string;
76
+ export declare function normalizeAssistantNowExprPlaceholders(value: any): any;
76
77
  export declare function rewriteMatchExpressionsToExpr(match: any): any;
77
78
  export declare function stripQueryFieldPathsDeep(query: any, fieldsToStrip: string[]): any;
78
79
  export declare function stripScopedFieldsFromPipeline(pipeline: any[], fieldsToStrip: string[]): any[];
@@ -114,6 +114,7 @@ exports.serializeMongoValue = serializeMongoValue;
114
114
  exports.flattenForTable = flattenForTable;
115
115
  exports.buildDisplayTable = buildDisplayTable;
116
116
  exports.formatDisplayTableMarkdown = formatDisplayTableMarkdown;
117
+ exports.normalizeAssistantNowExprPlaceholders = normalizeAssistantNowExprPlaceholders;
117
118
  exports.rewriteMatchExpressionsToExpr = rewriteMatchExpressionsToExpr;
118
119
  exports.stripQueryFieldPathsDeep = stripQueryFieldPathsDeep;
119
120
  exports.stripScopedFieldsFromPipeline = stripScopedFieldsFromPipeline;
@@ -6079,6 +6080,45 @@ function normalizeAssistantNowExprOperand(value) {
6079
6080
  },
6080
6081
  _a;
6081
6082
  }
6083
+ function normalizeAssistantDateArithmeticArgs(expression) {
6084
+ if (!expression || typeof expression !== 'object' || Array.isArray(expression)) {
6085
+ return expression;
6086
+ }
6087
+ if (expression instanceof Date || expression instanceof RegExp || isMongoObjectId(expression)) {
6088
+ return expression;
6089
+ }
6090
+ var normalizeOperatorArgs = function (operator) {
6091
+ if (!Object.prototype.hasOwnProperty.call(expression, operator)) {
6092
+ return;
6093
+ }
6094
+ var rawArgs = expression[operator];
6095
+ if (!rawArgs || typeof rawArgs !== 'object' || Array.isArray(rawArgs)) {
6096
+ return;
6097
+ }
6098
+ if (rawArgs instanceof Date || rawArgs instanceof RegExp || isMongoObjectId(rawArgs)) {
6099
+ return;
6100
+ }
6101
+ var nextArgs = __assign({}, rawArgs);
6102
+ if (!Object.prototype.hasOwnProperty.call(nextArgs, 'startDate')) {
6103
+ if (Object.prototype.hasOwnProperty.call(nextArgs, 'date')) {
6104
+ nextArgs.startDate = nextArgs.date;
6105
+ }
6106
+ else if (Object.prototype.hasOwnProperty.call(nextArgs, 'start')) {
6107
+ nextArgs.startDate = nextArgs.start;
6108
+ }
6109
+ }
6110
+ if (Object.prototype.hasOwnProperty.call(nextArgs, 'date')) {
6111
+ delete nextArgs.date;
6112
+ }
6113
+ if (Object.prototype.hasOwnProperty.call(nextArgs, 'start')) {
6114
+ delete nextArgs.start;
6115
+ }
6116
+ expression[operator] = nextArgs;
6117
+ };
6118
+ normalizeOperatorArgs('$dateAdd');
6119
+ normalizeOperatorArgs('$dateSubtract');
6120
+ return expression;
6121
+ }
6082
6122
  function normalizeAssistantNowExprPlaceholdersDeep(value) {
6083
6123
  if (Array.isArray(value)) {
6084
6124
  return value.map(function (entry) { return normalizeAssistantNowExprPlaceholdersDeep(entry); });
@@ -6096,7 +6136,10 @@ function normalizeAssistantNowExprPlaceholdersDeep(value) {
6096
6136
  Object.keys(value).forEach(function (key) {
6097
6137
  result[key] = normalizeAssistantNowExprPlaceholdersDeep(value[key]);
6098
6138
  });
6099
- return result;
6139
+ return normalizeAssistantDateArithmeticArgs(result);
6140
+ }
6141
+ function normalizeAssistantNowExprPlaceholders(value) {
6142
+ return normalizeAssistantNowExprPlaceholdersDeep(value);
6100
6143
  }
6101
6144
  function isMatchExpressionOperand(value) {
6102
6145
  if (typeof value === 'string') {