"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AggregateRequest=void 0;var error_1=require("../common/error");var AbstractCommand_1=require("./AbstractCommand");var AggregateRequest=function(){function a(t,r){if(r===void 0){r=""}this.data=t;this.prefix=r}a.prototype.stringify=function(){var t=this;if(this.data instanceof AbstractCommand_1.AbstractCommand){if(!(this.data instanceof AbstractCommand_1.AggregateCommand)){throw error_1.DbBuildError.invalidCommand("Command \u4E0D\u662F\u805A\u5408\u64CD\u4F5C")}return this.data.stringify()}if(this.data===null||this.data instanceof Date){return this.data}if(Array.isArray(this.data)){return this.data.map(function(d,u){return new a(d,"".concat(t.prefix,".$.").concat(u)).stringify()})}switch(typeof this.data){case"number":return this.data;case"boolean":return this.data;case"string":return this.data;case"bigint":return this.data;case"function":throw error_1.DbBuildError.invalidParam(this.prefix,"\u4E0D\u652F\u6301\u51FD\u6570");case"symbol":throw error_1.DbBuildError.invalidParam(this.prefix,"\u4E0D\u652F\u6301 symbol");case"undefined":return this.data;default:{var r={};for(var i in this.data){var n=this.prefix?"".concat(this.prefix,".").concat(i):i;var s=this.data[i];var o=new a(s,n);var e=o.stringify();if(e!==void 0){r[i]=e}}return r}}};a.prototype.toJSON=function(){var t=this.stringify();if(t===void 0){throw error_1.DbBuildError.invalidParam(this.prefix,"\u4E0D\u652F\u6301 undefined")}return t};return a}();exports.AggregateRequest=AggregateRequest;