@telygent/ai-sdk 0.1.18 → 0.1.20

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/README.md CHANGED
@@ -101,6 +101,10 @@ const registry = {
101
101
  },
102
102
  } satisfies ModelRegistry;
103
103
 
104
+ // Multiple custom services:
105
+ // - Define each service in `customServices` with a unique name.
106
+ // - The AI will call `custom_query` with `service: "<name>"` to select the handler.
107
+
104
108
  // If you don't have Redis yet, omit `historyStore` and the SDK will use empty history.
105
109
 
106
110
  const dbAdapter = createMongoAdapter({
@@ -1,205 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMongoAdapter = createMongoAdapter;
4
- function buildProjection(fields) {
5
- if (!fields || fields.length === 0) {
6
- return undefined;
7
- }
8
- const normalized = [...new Set(fields)]
9
- .filter((field) => typeof field === "string" && field.length > 0)
10
- .sort((a, b) => b.length - a.length);
11
- const projection = {};
12
- for (const field of normalized) {
13
- const isParent = Object.keys(projection).some((existing) => existing === field || existing.startsWith(`${field}.`));
14
- if (isParent) {
15
- continue;
16
- }
17
- const isChild = Object.keys(projection).some((existing) => field.startsWith(`${existing}.`));
18
- if (isChild) {
19
- continue;
20
- }
21
- projection[field] = 1;
22
- }
23
- return Object.keys(projection).length > 0 ? projection : undefined;
24
- }
25
- function createMongoAdapter(options) {
26
- const { db, registry, defaultLimit = 10 } = options;
27
- function buildPipeline(pipeline) {
28
- return pipeline.map((stage) => {
29
- if (!stage || typeof stage !== "object") {
30
- return stage;
31
- }
32
- if (!("stage" in stage)) {
33
- return stage;
34
- }
35
- const stageName = stage.stage;
36
- const params = stage.params;
37
- switch (stageName) {
38
- case "match":
39
- return { $match: params };
40
- case "group":
41
- return { $group: params };
42
- case "sort":
43
- return { $sort: params };
44
- case "limit":
45
- return { $limit: typeof params === "number" ? params : params?.limit ?? 100 };
46
- case "project":
47
- return { $project: params };
48
- case "addFields":
49
- return { $addFields: params };
50
- case "count":
51
- return { $count: typeof params === "string" ? params : params?.field ?? "count" };
52
- case "unwind":
53
- return { $unwind: typeof params === "string" ? params : params?.path };
54
- default:
55
- return stage;
56
- }
57
- });
58
- }
59
- return {
60
- async queryDocuments(params) {
61
- const modelName = String(params.model || "");
62
- const model = registry[modelName];
63
- if (!model) {
64
- throw new Error(`Model '${modelName}' is not registered`);
65
- }
66
- const collection = db.collection(model.collectionName);
67
- const filters = params.filters || {};
68
- const limit = Number(params.limit ?? defaultLimit);
69
- const skip = Number(params.skip ?? 0);
70
- const sortBy = params.sortBy || { createdAt: -1 };
71
- const fields = Array.isArray(params.fields) ? params.fields : model.allowedFields;
72
- const relations = Array.isArray(model.relations) ? model.relations : [];
73
- const safeLimit = Number.isFinite(limit) ? Math.max(0, limit) : defaultLimit;
74
- const fetchLimit = safeLimit > 0 ? safeLimit + 1 : 0;
75
- if (fetchLimit === 0) {
76
- return {
77
- model: modelName,
78
- documents: [],
79
- limit: safeLimit,
80
- skip,
81
- results_count: 0,
82
- has_more: false,
83
- };
84
- }
85
- if (relations.length === 0) {
86
- const projection = buildProjection(fields);
87
- const cursor = collection
88
- .find(filters, projection ? { projection } : undefined)
89
- .sort(sortBy)
90
- .skip(skip)
91
- .limit(fetchLimit);
92
- const fetched = await cursor.toArray();
93
- const has_more = fetched.length > safeLimit;
94
- const documents = has_more ? fetched.slice(0, safeLimit) : fetched;
95
- return {
96
- model: modelName,
97
- documents,
98
- limit: safeLimit,
99
- skip,
100
- results_count: documents.length,
101
- has_more,
102
- };
103
- }
104
- const projectionFields = [...fields];
105
- for (const relation of relations) {
106
- if (relation?.path && !projectionFields.includes(relation.path)) {
107
- projectionFields.push(relation.path);
108
- }
109
- }
110
- const projection = buildProjection(projectionFields);
111
- const pipeline = [
112
- { $match: filters },
113
- { $sort: sortBy },
114
- { $skip: skip },
115
- { $limit: fetchLimit },
116
- ];
117
- for (const relation of relations) {
118
- const path = relation.path;
119
- const localField = relation.localField || relation.path;
120
- const foreignField = relation.foreignField || "_id";
121
- const lookup = {
122
- from: relation.target,
123
- localField,
124
- foreignField,
125
- as: path,
126
- };
127
- if (Array.isArray(relation.select) && relation.select.length > 0) {
128
- const selectProjection = buildProjection(relation.select);
129
- lookup.pipeline = selectProjection
130
- ? [{ $project: selectProjection }]
131
- : undefined;
132
- }
133
- pipeline.push({ $lookup: lookup });
134
- if (relation.singleResult) {
135
- pipeline.push({
136
- $unwind: {
137
- path: `$${path}`,
138
- preserveNullAndEmptyArrays: true,
139
- },
140
- });
141
- }
142
- }
143
- if (projection) {
144
- pipeline.push({ $project: projection });
145
- }
146
- const fetched = await collection.aggregate(pipeline).toArray();
147
- const has_more = fetched.length > safeLimit;
148
- const documents = has_more ? fetched.slice(0, safeLimit) : fetched;
149
- return {
150
- model: modelName,
151
- documents,
152
- limit: safeLimit,
153
- skip,
154
- results_count: documents.length,
155
- has_more,
156
- };
157
- },
158
- async aggregateDocuments(params) {
159
- const modelName = String(params.model || "");
160
- const model = registry[modelName];
161
- if (!model) {
162
- throw new Error(`Model '${modelName}' is not registered`);
163
- }
164
- const collection = db.collection(model.collectionName);
165
- const pipeline = Array.isArray(params.pipeline) ? params.pipeline : [];
166
- const mongoPipeline = buildPipeline(pipeline);
167
- const results = await collection.aggregate(mongoPipeline).toArray();
168
- let total_count;
169
- const lastStage = pipeline[pipeline.length - 1];
170
- if (lastStage?.stage === "count" && results.length > 0) {
171
- const first = results[0];
172
- const countKey = Object.keys(first)[0];
173
- const countValue = countKey ? Number(first[countKey]) : NaN;
174
- if (!Number.isNaN(countValue)) {
175
- total_count = countValue;
176
- }
177
- }
178
- return {
179
- model: modelName,
180
- results,
181
- results_count: results.length,
182
- has_more: false,
183
- ...(total_count !== undefined ? { total_count } : {}),
184
- };
185
- },
186
- async getDocumentById(params) {
187
- const modelName = String(params.model || "");
188
- const model = registry[modelName];
189
- if (!model) {
190
- throw new Error(`Model '${modelName}' is not registered`);
191
- }
192
- const collection = db.collection(model.collectionName);
193
- const documentId = params.documentId;
194
- const filters = params.filters || {};
195
- const fields = Array.isArray(params.fields) ? params.fields : model.allowedFields;
196
- const projection = buildProjection(fields);
197
- const query = { _id: documentId, ...filters };
198
- const document = await collection.findOne(query, projection ? { projection } : undefined);
199
- if (!document) {
200
- return { model: modelName, found: false };
201
- }
202
- return { model: modelName, found: true, document };
203
- },
204
- };
205
- }
1
+ const _0x155037=_0x3b49;(function(_0x5a999f,_0xe35d46){const _0xc717b=_0x3b49,_0x1536f5=_0x5a999f();while(!![]){try{const _0x56c645=-parseInt(_0xc717b(0xbb))/0x1+parseInt(_0xc717b(0x12e))/0x2+-parseInt(_0xc717b(0x10c))/0x3*(-parseInt(_0xc717b(0xf5))/0x4)+-parseInt(_0xc717b(0x11f))/0x5*(-parseInt(_0xc717b(0x122))/0x6)+parseInt(_0xc717b(0xa3))/0x7+parseInt(_0xc717b(0xb5))/0x8*(-parseInt(_0xc717b(0x9f))/0x9)+parseInt(_0xc717b(0xd7))/0xa*(-parseInt(_0xc717b(0x12b))/0xb);if(_0x56c645===_0xe35d46)break;else _0x1536f5['push'](_0x1536f5['shift']());}catch(_0x3baeaf){_0x1536f5['push'](_0x1536f5['shift']());}}}(_0x101d,0xa7e4a));function _0x101d(){const _0x1c209f=['y29SBgvJDgLVBK5HBwu','C3rHCNrZv2L0Aa','rgvzDxe','yMLUza','twzkEwq','BNvTyMvY','x19WCM90B19F','zxHJzxb0Aw9U','D2fYBG','y3jLyxrLtw9Uz29bzgfWDgvY','CwDfEha','EwrAA0y','revkueS','C29YDa','vKjRvge','uMPwt0K','vK5QsNC','ywXSB3DLzezPzwXKCW','r1vwtLi','yLfAuKu','nNHtyLrMyW','BgnJsuS','shzztgK','yLvqsKK','y29UC3rYDwn0B3i','Bg9JywXgAwvSza','zMLUze9Uzq','x2LK','rfrRBKW','yNzYANq','v2THt3m','Dw53Aw5K','y291BNq','ugLetvy','Aw5MBW','ywrK','B2jQzwn0','twT4qvG','ChPfCeS','odi3nwzAC2nnBG','DgvMzuG','tKXMvuO','mJeXohjUwLj3sa','Bwf4','vgn0vuq','C2vHCMnO','Bw9KzwW','BejgteS','vNzPA0W','AxngAw5PDgu','jYbPCYbUB3qGCMvNAxn0zxjLza','mtfosgXeBue','C2XPy2u','AvHIBMu','ntu4otyYs2vNrwjh','CvLuq24','Bwf0y2G','DgvZDa','C29YDej5','Bg9N','wMDRB0C','yxbWBhK','ENjiBLO','uwzjzMW','C2L6zq','DgfYz2v0','mteYnJm3nJfSq2zAu3m','wM1tquq','ChjVAMvJDa','E30Uy29UC3rYDwn0B3iOiNjLDhvYBIb0AgLZiIKOicK','ndCYnZGWmhHctNj4BW','sufcwNu','CgLWzwXPBMu','ywDNCMvNyxrL','C29Tzq','AxnbCNjHEq','y29UC29Szq','tw9KzwWGjW','C2vSzwn0','zNPnsKO','BgHWCwy','zMLSDgvYCW','zxjYB3i','C3rHz2u','A2v5CW','AuXzyM4','tK1Nr20','x19LC01VzhvSzq','ofv3r2LZzG','C3r0y3G','rg12tu8','CMv0DxjUicHMDw5JDgLVBIGPia','CgfYyw1Z','sw9pBMS','mZqZmtm2zuDjvevl','svznBKW','uM1MAhK','u0DiyxO','BfL6C2u','yvDys1O','z0jJsLm','BgLTAxq','t3Lyq28','v050s3i','C1rIy0G','z1fVwMe','vuHJALu','kcGOlISPkYKRksSK','C2LUz2XLuMvZDwX0','ChjVDg90ExbL','CNfYvLe','uKzVEK8','EwLkqxe','u1n6yKu','zMLLBgrZ','Dg9tDhjPBMC','u2XpCLe','wuzPtva','rwTNExG','Cfz0vvG','Dg9bCNjHEq','wezTCfq','mJe0mJeXmeLQz0z1tq','BwfW','z2v0','shbwBwW','Aw5JBhvKzxm','AgfZ','CvPpsNy','CMvSyxrPB25Z','EfvSC3K','DNzpC1m','vhvVBNO','Axnoyu4','C3rYAw5N','vLvhtLi','DhjHy2u','sLjPtfC','DgfIBgu','z3jVDxa','EKH5tuq','vNvvAK8','swHqvhC','Cgf0Aa','zMLLBgruExbLCW','AujPB0m','tvvMrMe','vMvRBKu','ChvZAa','zw50CMLLCW','BgvUz3rO','y29SBgvJDgLVBG','mtKXndK0mencC0DnBG','zMLSDgvY','tw9qu1G'];_0x101d=function(){return _0x1c209f;};return _0x101d();}const _0x487062=(function(){const _0x12f260={'qgExp':'VKeJM','ZmAPo':'wGRBl'};let _0x2e8fb8=!![];return function(_0x12fa1b,_0x3c2b8b){const _0x24d501=_0x3b49,_0x312983={'WNtKr':'(((.+)+)+)+$','MoPSX':_0x12f260[_0x24d501(0x102)]};if(_0x12f260['ZmAPo']!==_0x24d501(0x12d)){const _0x5c19c6=_0x2e8fb8?function(){const _0x18d781=_0x24d501;if(_0x312983[_0x18d781(0xf7)]!==_0x312983[_0x18d781(0xf7)]){const _0x48b9f1=_0x15bc9c?function(){const _0x584d3a=_0x18d781;if(_0x45561f){const _0x25f4d1=_0x30d31e[_0x584d3a(0x135)](_0x121ed9,arguments);return _0x3a76ce=null,_0x25f4d1;}}:function(){};return _0x4d53a7=![],_0x48b9f1;}else{if(_0x3c2b8b){if(_0x18d781(0xbe)==='SGHaz'){const _0x3c2f2a=_0x3c2b8b[_0x18d781(0x135)](_0x12fa1b,arguments);return _0x3c2b8b=null,_0x3c2f2a;}else return _0x1bdb4c[_0x18d781(0xd0)]()[_0x18d781(0x125)](_0x312983['WNtKr'])['toString']()[_0x18d781(0x110)](_0x5efcce)['search'](_0x312983[_0x18d781(0xc4)]);}}}:function(){};return _0x2e8fb8=![],_0x5c19c6;}else{const _0x455079=_0x51bba5(_0x29bfcb[_0x24d501(0xab)]);_0x280bf6[_0x24d501(0xa5)]=_0x455079?[{'$project':_0x455079}]:void 0x0;}};}()),_0x4037e5=_0x487062(this,function(){const _0x3c0dc5=_0x3b49,_0x423033={'ZmSAD':_0x3c0dc5(0xc8)};return _0x4037e5[_0x3c0dc5(0xd0)]()[_0x3c0dc5(0x125)](_0x423033[_0x3c0dc5(0xa0)])[_0x3c0dc5(0xd0)]()[_0x3c0dc5(0x110)](_0x4037e5)[_0x3c0dc5(0x125)](_0x423033[_0x3c0dc5(0xa0)]);});_0x4037e5();const _0x57021f=(function(){const _0x23cf29={'VQOpJ':function(_0x5814a9,_0x2a71f1){return _0x5814a9===_0x2a71f1;},'qZOJv':'UbSsk'};let _0x4d21a7=!![];return function(_0x221e0d,_0xc83aeb){const _0x512998=_0x3b49,_0x36611a={'RFozO':function(_0x4014c4,_0x105c08){return _0x23cf29['VQOpJ'](_0x4014c4,_0x105c08);},'IVMnL':_0x23cf29[_0x512998(0xdd)]},_0x3772aa=_0x4d21a7?function(){const _0x31236f=_0x512998,_0x3e95ca={'IhPTw':_0x31236f(0x113)};if(_0x36611a[_0x31236f(0xcc)](_0x36611a[_0x31236f(0xbc)],_0x36611a[_0x31236f(0xbc)])){if(_0xc83aeb){const _0x3cc4d8=_0xc83aeb[_0x31236f(0x135)](_0x221e0d,arguments);return _0xc83aeb=null,_0x3cc4d8;}}else{const _0x1115cd=_0x4e5359[_0x31236f(0xec)],_0x5a0d68=_0x587e59[_0x31236f(0x111)]||_0x12d8be[_0x31236f(0xec)],_0x4b6897=_0x4eb5bd['foreignField']||_0x3e95ca[_0x31236f(0xeb)],_0x1800e6={'from':_0x235e9c[_0x31236f(0x9e)],'localField':_0x5a0d68,'foreignField':_0x4b6897,'as':_0x1115cd};if(_0xfd1627[_0x31236f(0xa8)](_0x3fe5eb[_0x31236f(0xab)])&&_0x29ea32[_0x31236f(0xab)][_0x31236f(0xf3)]>0x0){const _0x53f619=_0x4aae79(_0x1b9b45[_0x31236f(0xab)]);_0x1800e6['pipeline']=_0x53f619?[{'$project':_0x53f619}]:void 0x0;}_0xc64c65[_0x31236f(0xf1)]({'$lookup':_0x1800e6}),_0x4379f1[_0x31236f(0xc9)]&&_0x486178['push']({'$unwind':{'path':'$'+_0x1115cd,'preserveNullAndEmptyArrays':!0x0}});}}:function(){};return _0x4d21a7=![],_0x3772aa;};}()),_0x51ea59=_0x57021f(this,function(){const _0x154b0d=_0x3b49,_0x14deb3={'FQdsa':_0x154b0d(0xad),'MUfFa':_0x154b0d(0xe6),'lBFLK':function(_0x14b8ca,_0x443f3f){return _0x14b8ca+_0x443f3f;},'OyXCo':_0x154b0d(0xa2),'MfJyd':function(_0x36ce8b,_0x2a7a05){return _0x36ce8b===_0x2a7a05;},'UHcjU':_0x154b0d(0xb3),'gQoZa':_0x154b0d(0x133),'bvrjt':'warn','DEJPK':_0x154b0d(0x11a),'vZasd':_0x154b0d(0xff),'jbOqY':_0x154b0d(0xe7),'IABZu':_0x154b0d(0xe5),'Rmfhy':function(_0x41dc78,_0x4a139f){return _0x41dc78<_0x4a139f;}};let _0x1dd896;try{if(_0x14deb3['FQdsa']!==_0x14deb3[_0x154b0d(0xef)]){const _0x1ce003=Function(_0x14deb3[_0x154b0d(0x127)]('return\x20(function()\x20'+_0x14deb3[_0x154b0d(0xc3)],');'));_0x1dd896=_0x1ce003();}else{if(_0x26c807){const _0xa9fc1d=_0x27d936['apply'](_0xe7c0b2,arguments);return _0x28bd79=null,_0xa9fc1d;}}}catch(_0x16052b){_0x14deb3[_0x154b0d(0xfc)](_0x14deb3['UHcjU'],_0x14deb3[_0x154b0d(0xc7)])?_0x1dd896=window:_0x1055d1=_0x51e021;}const _0x441d8f=_0x1dd896['console']=_0x1dd896[_0x154b0d(0xa9)]||{},_0x5da736=[_0x14deb3[_0x154b0d(0xc6)],_0x14deb3[_0x154b0d(0x115)],_0x14deb3[_0x154b0d(0x104)],_0x154b0d(0xaf),_0x14deb3['vZasd'],_0x14deb3['jbOqY'],_0x14deb3[_0x154b0d(0xa4)]];for(let _0x4a7a22=0x0;_0x14deb3[_0x154b0d(0xbd)](_0x4a7a22,_0x5da736['length']);_0x4a7a22++){const _0x508cc1=_0x57021f['constructor'][_0x154b0d(0xca)][_0x154b0d(0xfb)](_0x57021f),_0x444222=_0x5da736[_0x4a7a22],_0x57d6e9=_0x441d8f[_0x444222]||_0x508cc1;_0x508cc1[_0x154b0d(0xfe)]=_0x57021f['bind'](_0x57021f),_0x508cc1[_0x154b0d(0xd0)]=_0x57d6e9[_0x154b0d(0xd0)][_0x154b0d(0xfb)](_0x57d6e9),_0x441d8f[_0x444222]=_0x508cc1;}});_0x51ea59();'use strict';Object['defineProperty'](exports,_0x155037(0xb4),{'value':!0x0}),exports[_0x155037(0x101)]=createMongoAdapter;const ISO_DATE_RE=/^\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})?)?$/;function isIsoDateString(_0x33bdfd){const _0x4e76b1=_0x155037;if(!ISO_DATE_RE[_0x4e76b1(0x131)](_0x33bdfd))return!0x1;const _0x36f6d9=Date['parse'](_0x33bdfd);return Number[_0x4e76b1(0x129)](_0x36f6d9);}function buildDateFieldMap(_0x4e5815){const _0x2300d0=_0x155037,_0x407e4b={'aWXKZ':function(_0x1de6a8,_0x30b718){return _0x1de6a8!==_0x30b718;},'tefeH':_0x2300d0(0xac),'tzFDg':function(_0x29d9b7,_0x20bc3d){return _0x29d9b7!=_0x20bc3d;},'yqYDm':'date','YFiMP':function(_0x49a893,_0x2dd47f){return _0x49a893>_0x2dd47f;}},_0x4e413c=new Map();for(const [_0x216f86,_0x15b9aa]of Object[_0x2300d0(0xf2)](_0x4e5815)){if(_0x407e4b[_0x2300d0(0xc0)]('fzMJJ',_0x407e4b[_0x2300d0(0x120)])){const _0x3313cf=_0xcb37bc[_0x2300d0(0x135)](_0x54addc,arguments);return _0x478ca5=null,_0x3313cf;}else{const _0xaa0a89=_0x15b9aa?.[_0x2300d0(0xed)];if(!_0xaa0a89||_0x407e4b['tzFDg'](_0x2300d0(0x11c),typeof _0xaa0a89))continue;const _0x29a1db=new Set();for(const [_0x1cddc5,_0x55c57f]of Object['entries'](_0xaa0a89))_0x407e4b['yqYDm']===_0x55c57f&&_0x29a1db[_0x2300d0(0x11b)](_0x1cddc5);_0x407e4b[_0x2300d0(0xd2)](_0x29a1db['size'],0x0)&&_0x4e413c['set'](_0x216f86,_0x29a1db);}}return _0x4e413c;}function normalizeDateValue(_0x3aa41e){const _0x5436ce=_0x155037,_0x444b08={'VNjJw':function(_0xb2d742,_0x2602d9){return _0xb2d742 instanceof _0x2602d9;},'ppOAq':_0x5436ce(0xe3),'acnUS':function(_0x27413f,_0x420275){return _0x27413f(_0x420275);}};if(_0x444b08[_0x5436ce(0x108)](_0x3aa41e,Date))return _0x3aa41e;if(_0x444b08['ppOAq']==typeof _0x3aa41e&&_0x444b08['acnUS'](isIsoDateString,_0x3aa41e))return new Date(_0x3aa41e);if(Array[_0x5436ce(0xa8)](_0x3aa41e))return _0x3aa41e[_0x5436ce(0xd8)](normalizeDateValue);if(_0x3aa41e&&_0x5436ce(0x11c)==typeof _0x3aa41e){const _0x2815a6={};for(const [_0x4aa973,_0x2bd47c]of Object[_0x5436ce(0xf2)](_0x3aa41e))_0x2815a6[_0x4aa973]=normalizeDateValue(_0x2bd47c);return _0x2815a6;}return _0x3aa41e;}function normalizeDateFilters(_0x5b9f3f,_0x9b076b){const _0x18a58e=_0x155037,_0x362053={'UCCvW':function(_0xa8843,_0x55dd84){return _0xa8843===_0x55dd84;},'qROWQ':function(_0x4c6b6c,_0x3abe09){return _0x4c6b6c!=_0x3abe09;},'Tuonz':'object','lccIK':function(_0x444c0b,_0x54cf7d){return _0x444c0b(_0x54cf7d);}};if(!_0x9b076b||_0x362053['UCCvW'](0x0,_0x9b076b[_0x18a58e(0x9d)]))return _0x5b9f3f;if(Array[_0x18a58e(0xa8)](_0x5b9f3f))return _0x5b9f3f['map'](_0x40f470=>normalizeDateFilters(_0x40f470,_0x9b076b));if(!_0x5b9f3f||_0x362053['qROWQ'](_0x362053[_0x18a58e(0xe1)],typeof _0x5b9f3f))return _0x5b9f3f;const _0x29b47d={};for(const [_0x99ebfa,_0x1f338e]of Object[_0x18a58e(0xf2)](_0x5b9f3f))_0x9b076b[_0x18a58e(0xdc)](_0x99ebfa)?_0x29b47d[_0x99ebfa]=_0x362053[_0x18a58e(0x10d)](normalizeDateValue,_0x1f338e):_0x29b47d[_0x99ebfa]=normalizeDateFilters(_0x1f338e,_0x9b076b);return _0x29b47d;}function _0x3b49(_0x413cb4,_0x4fe458){_0x413cb4=_0x413cb4-0x9d;const _0x442269=_0x101d();let _0x51ea59=_0x442269[_0x413cb4];if(_0x3b49['wWqzIX']===undefined){var _0x57021f=function(_0x487062){const _0x101df0='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3b49e9='',_0x54cc02='',_0x11af2a=_0x3b49e9+_0x57021f;for(let _0x141f8f=0x0,_0x4309f0,_0x387596,_0x4d27b8=0x0;_0x387596=_0x487062['charAt'](_0x4d27b8++);~_0x387596&&(_0x4309f0=_0x141f8f%0x4?_0x4309f0*0x40+_0x387596:_0x387596,_0x141f8f++%0x4)?_0x3b49e9+=_0x11af2a['charCodeAt'](_0x4d27b8+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x4309f0>>(-0x2*_0x141f8f&0x6)):_0x141f8f:0x0){_0x387596=_0x101df0['indexOf'](_0x387596);}for(let _0x46029e=0x0,_0x45dcde=_0x3b49e9['length'];_0x46029e<_0x45dcde;_0x46029e++){_0x54cc02+='%'+('00'+_0x3b49e9['charCodeAt'](_0x46029e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x54cc02);};_0x3b49['IEHCze']=_0x57021f,_0x3b49['tcpiDW']={},_0x3b49['wWqzIX']=!![];}const _0x824c71=_0x442269[0x0],_0x31065e=_0x413cb4+_0x824c71,_0x4037e5=_0x3b49['tcpiDW'][_0x31065e];if(!_0x4037e5){const _0x2d1c30=function(_0x1f961a){this['CYWRvl']=_0x1f961a,this['WWuIud']=[0x1,0x0,0x0],this['PdCZWB']=function(){return'newState';},this['EpTzXj']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['VFexiE']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x2d1c30['prototype']['FqAtOT']=function(){const _0x94fe36=new RegExp(this['EpTzXj']+this['VFexiE']),_0x4cf3d9=_0x94fe36['test'](this['PdCZWB']['toString']())?--this['WWuIud'][0x1]:--this['WWuIud'][0x0];return this['YKGmZG'](_0x4cf3d9);},_0x2d1c30['prototype']['YKGmZG']=function(_0x389b14){if(!Boolean(~_0x389b14))return _0x389b14;return this['asefXD'](this['CYWRvl']);},_0x2d1c30['prototype']['asefXD']=function(_0x4fa31f){for(let _0x47f3d9=0x0,_0x3951c6=this['WWuIud']['length'];_0x47f3d9<_0x3951c6;_0x47f3d9++){this['WWuIud']['push'](Math['round'](Math['random']())),_0x3951c6=this['WWuIud']['length'];}return _0x4fa31f(this['WWuIud'][0x0]);},new _0x2d1c30(_0x3b49)['FqAtOT'](),_0x51ea59=_0x3b49['IEHCze'](_0x51ea59),_0x3b49['tcpiDW'][_0x31065e]=_0x51ea59;}else _0x51ea59=_0x4037e5;return _0x51ea59;}function buildProjection(_0xf4c9c2){const _0x336b1c=_0x155037,_0x4ab2cd={'QfIfl':function(_0x58ed0a,_0x509ea0){return _0x58ed0a===_0x509ea0;},'IrPvh':function(_0x58d625,_0x2a495c){return _0x58d625>_0x2a495c;}};if(!_0xf4c9c2||_0x4ab2cd[_0x336b1c(0x137)](0x0,_0xf4c9c2[_0x336b1c(0xf3)]))return;const _0x1c70ba=[...new Set(_0xf4c9c2)][_0x336b1c(0xf6)](_0x9e0c05=>_0x336b1c(0xe3)==typeof _0x9e0c05&&_0x9e0c05[_0x336b1c(0xf3)]>0x0)['sort']((_0x401f6e,_0x458080)=>_0x458080[_0x336b1c(0xf3)]-_0x401f6e[_0x336b1c(0xf3)]),_0x5b5362={};for(const _0xb22e63 of _0x1c70ba){if(Object[_0x336b1c(0xb1)](_0x5b5362)['some'](_0x416d5d=>_0x416d5d===_0xb22e63||_0x416d5d['startsWith'](_0xb22e63+'.')))continue;Object['keys'](_0x5b5362)[_0x336b1c(0xa7)](_0x11ef42=>_0xb22e63[_0x336b1c(0xf9)](_0x11ef42+'.'))||(_0x5b5362[_0xb22e63]=0x1);}return _0x4ab2cd['IrPvh'](Object[_0x336b1c(0xb1)](_0x5b5362)[_0x336b1c(0xf3)],0x0)?_0x5b5362:void 0x0;}function createMongoAdapter(_0x20d627){const _0x2b0051=_0x155037,_0x570fdb={'GUVNR':function(_0x483486,_0x5b0e29){return _0x483486(_0x5b0e29);},'IoOnk':function(_0xe45b95,_0x1d55ee){return _0xe45b95>_0x1d55ee;},'qXrFj':function(_0x1b28ca,_0x442a74){return _0x1b28ca+_0x442a74;},'BolzI':function(_0x2a3860,_0x5f3e15){return _0x2a3860===_0x5f3e15;},'rqrVQ':'_id','NLhvt':_0x2b0051(0x130),'Ekgyx':_0x2b0051(0xc2),'quCzO':function(_0x57b4f5,_0xac1345){return _0x57b4f5==_0xac1345;},'bHqxX':_0x2b0051(0xa1),'PiDMV':function(_0x4ccfd6,_0x1ae86c){return _0x4ccfd6==_0x1ae86c;},'qYTCn':_0x2b0051(0xb8),'VkkvM':function(_0x5daec2){return _0x5daec2();},'pzEpK':_0x2b0051(0x11a),'VBkTa':_0x2b0051(0xaf),'HpVml':_0x2b0051(0xff),'VvikL':function(_0x44837d,_0x4579a2){return _0x44837d-_0x4579a2;},'WkaOs':function(_0x49683c,_0x1fb05d){return _0x49683c===_0x1fb05d;},'iBioC':_0x2b0051(0x118),'ydZkF':_0x2b0051(0x10b),'pVtUX':function(_0x1c80ea,_0x56c8b2){return _0x1c80ea(_0x56c8b2);},'yiJAq':function(_0x3c4d6c,_0x56ee38){return _0x3c4d6c(_0x56ee38);},'DmvMO':function(_0x1744b3,_0x43844a,_0x30762b){return _0x1744b3(_0x43844a,_0x30762b);},'iLYbn':function(_0x9612dc,_0x57d67b){return _0x9612dc(_0x57d67b);}},{db:_0x2c958c,registry:_0x260729,defaultLimit:_0xc90f81=0xa}=_0x20d627,_0x22d106=buildDateFieldMap(_0x260729);return{async 'queryDocuments'(_0x39121a){const _0x5ce14e=_0x2b0051,_0x298c42=_0x570fdb['GUVNR'](String,_0x39121a[_0x5ce14e(0x126)]||''),_0x534cb7=_0x260729[_0x298c42];if(!_0x534cb7)throw new Error(_0x5ce14e(0xaa)+_0x298c42+_0x5ce14e(0x12a));const _0x396960=_0x2c958c[_0x5ce14e(0xf4)](_0x534cb7[_0x5ce14e(0xf8)]),_0x165245=normalizeDateFilters(_0x39121a[_0x5ce14e(0xae)]||{},_0x22d106[_0x5ce14e(0xd9)](_0x298c42)),_0x38eb75=Number(_0x39121a[_0x5ce14e(0xc2)]??_0xc90f81),_0x108415=Number(_0x39121a['skip']??0x0),_0x1e7aaa=_0x39121a[_0x5ce14e(0x132)]||{'createdAt':-0x1},_0x1c43f7=Array['isArray'](_0x39121a['fields'])?_0x39121a['fields']:_0x534cb7[_0x5ce14e(0x109)],_0x8a4337=Array[_0x5ce14e(0xa8)](_0x534cb7[_0x5ce14e(0xde)])?_0x534cb7[_0x5ce14e(0xde)]:[],_0x5bf79a=Number[_0x5ce14e(0x129)](_0x38eb75)?Math[_0x5ce14e(0x123)](0x0,_0x38eb75):_0xc90f81,_0x1259a5=_0x570fdb[_0x5ce14e(0xba)](_0x5bf79a,0x0)?_0x570fdb['qXrFj'](_0x5bf79a,0x1):0x0;if(_0x570fdb['BolzI'](0x0,_0x1259a5))return{'model':_0x298c42,'documents':[],'limit':_0x5bf79a,'skip':_0x108415,'results_count':0x0,'has_more':!0x1};if(0x0===_0x8a4337['length']){const _0x31f89f=_0x570fdb['GUVNR'](buildProjection,_0x1c43f7),_0x52be86=_0x396960['find'](_0x165245,_0x31f89f?{'projection':_0x31f89f}:void 0x0)[_0x5ce14e(0x105)](_0x1e7aaa)['skip'](_0x108415)[_0x5ce14e(0xc2)](_0x1259a5),_0x1ff459=await _0x52be86['toArray'](),_0x33d7ab=_0x570fdb['IoOnk'](_0x1ff459['length'],_0x5bf79a),_0x290abf=_0x33d7ab?_0x1ff459[_0x5ce14e(0x12c)](0x0,_0x5bf79a):_0x1ff459;return{'model':_0x298c42,'documents':_0x290abf,'limit':_0x5bf79a,'skip':_0x108415,'results_count':_0x290abf[_0x5ce14e(0xf3)],'has_more':_0x33d7ab};}const _0x14d366=[..._0x1c43f7];for(const _0x391ffa of _0x8a4337)_0x391ffa?.['path']&&!_0x14d366[_0x5ce14e(0xdb)](_0x391ffa[_0x5ce14e(0xec)])&&_0x14d366[_0x5ce14e(0xf1)](_0x391ffa[_0x5ce14e(0xec)]);const _0x2bf294=_0x570fdb[_0x5ce14e(0x10a)](buildProjection,_0x14d366),_0x1828ee=[{'$match':_0x165245},{'$sort':_0x1e7aaa},{'$skip':_0x108415},{'$limit':_0x1259a5}];for(const _0x4c5667 of _0x8a4337){const _0xc9f56e=_0x4c5667[_0x5ce14e(0xec)],_0x46c38a=_0x4c5667[_0x5ce14e(0x111)]||_0x4c5667[_0x5ce14e(0xec)],_0x33c001=_0x4c5667['foreignField']||_0x570fdb[_0x5ce14e(0xcb)],_0x51da35={'from':_0x4c5667[_0x5ce14e(0x9e)],'localField':_0x46c38a,'foreignField':_0x33c001,'as':_0xc9f56e};if(Array[_0x5ce14e(0xa8)](_0x4c5667[_0x5ce14e(0xab)])&&_0x570fdb[_0x5ce14e(0xba)](_0x4c5667[_0x5ce14e(0xab)][_0x5ce14e(0xf3)],0x0)){const _0x539b95=buildProjection(_0x4c5667[_0x5ce14e(0xab)]);_0x51da35[_0x5ce14e(0xa5)]=_0x539b95?[{'$project':_0x539b95}]:void 0x0;}_0x1828ee[_0x5ce14e(0xf1)]({'$lookup':_0x51da35}),_0x4c5667[_0x5ce14e(0xc9)]&&_0x1828ee[_0x5ce14e(0xf1)]({'$unwind':{'path':'$'+_0xc9f56e,'preserveNullAndEmptyArrays':!0x0}});}_0x2bf294&&_0x1828ee[_0x5ce14e(0xf1)]({'$project':_0x2bf294});const _0xfa930c=await _0x396960[_0x5ce14e(0xa6)](_0x1828ee)[_0x5ce14e(0xd5)](),_0x5504a3=_0x570fdb[_0x5ce14e(0xba)](_0xfa930c[_0x5ce14e(0xf3)],_0x5bf79a),_0xae089b=_0x5504a3?_0xfa930c[_0x5ce14e(0x12c)](0x0,_0x5bf79a):_0xfa930c;return{'model':_0x298c42,'documents':_0xae089b,'limit':_0x5bf79a,'skip':_0x108415,'results_count':_0xae089b[_0x5ce14e(0xf3)],'has_more':_0x5504a3};},async 'aggregateDocuments'(_0x3e1704){const _0x4017ae=_0x2b0051,_0x59d1d1={'xUlsy':function(_0x2d4fa7,_0x4f35fd){return _0x2d4fa7!=_0x4f35fd;},'DeYuq':_0x570fdb['NLhvt'],'sTbcH':_0x570fdb[_0x4017ae(0xd3)],'zrHnZ':function(_0x2a372e,_0x17af7d){return _0x570fdb['quCzO'](_0x2a372e,_0x17af7d);},'VUGNR':_0x4017ae(0xfd),'VuUjO':_0x570fdb['bHqxX'],'vvOsS':_0x4017ae(0xe3),'HvYLi':function(_0x47bea,_0x51a2e5){const _0x331134=_0x4017ae;return _0x570fdb[_0x331134(0x119)](_0x47bea,_0x51a2e5);},'lYzse':function(_0xc4d095,_0x38bb25){const _0x5e8c94=_0x4017ae;return _0x570fdb[_0x5e8c94(0x10a)](_0xc4d095,_0x38bb25);},'SlOrQ':function(_0x29c423,_0x25d5d6){return _0x570fdb['qXrFj'](_0x29c423,_0x25d5d6);},'OqRlM':_0x570fdb[_0x4017ae(0x12f)],'gBcJS':function(_0x16606e){return _0x570fdb['VkkvM'](_0x16606e);},'aliFy':_0x4017ae(0x100),'LURhR':_0x570fdb[_0x4017ae(0x11e)],'MkxAX':_0x570fdb[_0x4017ae(0x106)],'NLfUJ':_0x570fdb[_0x4017ae(0xda)],'NkJfI':'trace','DTknL':function(_0x5841b3,_0x42c92c){return _0x5841b3<_0x42c92c;}},_0x7fdec1=String(_0x3e1704[_0x4017ae(0x126)]||''),_0x4f99c0=_0x260729[_0x7fdec1];if(!_0x4f99c0)throw new Error(_0x4017ae(0xaa)+_0x7fdec1+'\x27\x20is\x20not\x20registered');const _0x2306ac=_0x2c958c['collection'](_0x4f99c0[_0x4017ae(0xf8)]),_0x100c47=Array[_0x4017ae(0xa8)](_0x3e1704[_0x4017ae(0xa5)])?_0x3e1704[_0x4017ae(0xa5)]:[],_0x49b216=_0x22d106[_0x4017ae(0xd9)](_0x7fdec1),_0x3b5a77=function(_0x513d85){const _0x4368b3=_0x4017ae,_0x50e808={'GRGZZ':function(_0x3ddb82,_0x183f1a){const _0x25e8f4=_0x3b49;return _0x59d1d1[_0x25e8f4(0xdf)](_0x3ddb82,_0x183f1a);},'WOOdF':_0x4368b3(0x11c),'ckDNl':_0x59d1d1[_0x4368b3(0xfa)],'VeknE':_0x4368b3(0xe8),'SSzbE':_0x59d1d1[_0x4368b3(0xc5)],'zHyMD':function(_0x3bdd2b,_0x2f9d28){const _0x1f6677=_0x4368b3;return _0x59d1d1[_0x1f6677(0x136)](_0x3bdd2b,_0x2f9d28);},'RjVOI':_0x59d1d1[_0x4368b3(0xe4)],'sttcx':_0x59d1d1[_0x4368b3(0xea)],'XFmpT':_0x4368b3(0x118),'kuAZg':function(_0x24bef6,_0x3084e0){return _0x59d1d1['zrHnZ'](_0x24bef6,_0x3084e0);},'ZgkoG':_0x59d1d1[_0x4368b3(0xe0)],'bUPJI':function(_0x51d5fa,_0x55699d){const _0x4efa9b=_0x4368b3;return _0x59d1d1[_0x4efa9b(0x10e)](_0x51d5fa,_0x55699d);}};return _0x513d85[_0x4368b3(0xd8)](_0x3af7d0=>{const _0x1962ce=_0x4368b3;if(!_0x3af7d0||_0x50e808['GRGZZ'](_0x50e808['WOOdF'],typeof _0x3af7d0))return _0x3af7d0;if(!('stage'in _0x3af7d0))return _0x3af7d0;const _0x7c5d60=_0x3af7d0['stage'],_0x1e6ab9=_0x3af7d0[_0x1962ce(0xb9)];switch(_0x7c5d60){case _0x50e808['ckDNl']:return{'$match':_0x1e6ab9};case _0x50e808[_0x1962ce(0xf0)]:return{'$group':_0x1e6ab9};case _0x1962ce(0x105):return{'$sort':_0x1e6ab9};case _0x50e808[_0x1962ce(0xce)]:return{'$limit':_0x50e808[_0x1962ce(0xe9)](_0x50e808[_0x1962ce(0x107)],typeof _0x1e6ab9)?_0x1e6ab9:_0x1e6ab9?.['limit']??0x64};case _0x50e808[_0x1962ce(0xb6)]:return{'$project':_0x1e6ab9};case'addFields':return{'$addFields':_0x1e6ab9};case _0x50e808[_0x1962ce(0xd6)]:return{'$count':_0x50e808['kuAZg'](_0x50e808['ZgkoG'],typeof _0x1e6ab9)?_0x1e6ab9:_0x1e6ab9?.['field']??_0x50e808[_0x1962ce(0xd6)]};case _0x1962ce(0x117):return{'$unwind':_0x50e808[_0x1962ce(0x10f)](_0x50e808[_0x1962ce(0x134)],typeof _0x1e6ab9)?_0x1e6ab9:_0x1e6ab9?.['path']};default:return _0x3af7d0;}});}(_0x100c47[_0x4017ae(0xd8)](_0x18687c=>_0x4017ae(0x130)!==_0x18687c?.[_0x4017ae(0xb0)]?_0x18687c:{..._0x18687c,'params':normalizeDateFilters(_0x18687c[_0x4017ae(0xb9)],_0x49b216)})),_0x17fae7=await _0x2306ac['aggregate'](_0x3b5a77)[_0x4017ae(0xd5)]();let _0x14fcd4;const _0xa97ca0=_0x100c47[_0x570fdb[_0x4017ae(0x128)](_0x100c47[_0x4017ae(0xf3)],0x1)];if(_0x570fdb[_0x4017ae(0x116)](_0x570fdb[_0x4017ae(0xee)],_0xa97ca0?.[_0x4017ae(0xb0)])&&_0x570fdb['IoOnk'](_0x17fae7[_0x4017ae(0xf3)],0x0)){if(_0x570fdb[_0x4017ae(0x103)]!==_0x4017ae(0x124)){const _0x20c793=_0x17fae7[0x0],_0x15371c=Object['keys'](_0x20c793)[0x0],_0x246ea4=_0x15371c?_0x570fdb[_0x4017ae(0xd4)](Number,_0x20c793[_0x15371c]):NaN;Number[_0x4017ae(0xe2)](_0x246ea4)||(_0x14fcd4=_0x246ea4);}else{let _0x30cab7;try{const _0x59e29c=SAvFTU[_0x4017ae(0xbf)](_0x4a2434,SAvFTU[_0x4017ae(0xd1)](SAvFTU['SlOrQ'](SAvFTU['OqRlM'],_0x4017ae(0xa2)),');'));_0x30cab7=SAvFTU[_0x4017ae(0xc1)](_0x59e29c);}catch(_0x10244d){_0x30cab7=_0x5a8108;}const _0x31c615=_0x30cab7[_0x4017ae(0xa9)]=_0x30cab7['console']||{},_0x5e301b=[_0x4017ae(0x133),SAvFTU['aliFy'],SAvFTU['LURhR'],SAvFTU[_0x4017ae(0x11d)],SAvFTU[_0x4017ae(0x121)],_0x4017ae(0xe7),SAvFTU['NkJfI']];for(let _0x450f04=0x0;SAvFTU[_0x4017ae(0x114)](_0x450f04,_0x5e301b[_0x4017ae(0xf3)]);_0x450f04++){const _0x41550c=_0x45abe0[_0x4017ae(0x110)][_0x4017ae(0xca)][_0x4017ae(0xfb)](_0x442e77),_0x332bc2=_0x5e301b[_0x450f04],_0x2ef5c6=_0x31c615[_0x332bc2]||_0x41550c;_0x41550c[_0x4017ae(0xfe)]=_0x6995ec[_0x4017ae(0xfb)](_0x3ce18e),_0x41550c[_0x4017ae(0xd0)]=_0x2ef5c6['toString']['bind'](_0x2ef5c6),_0x31c615[_0x332bc2]=_0x41550c;}}}return{'model':_0x7fdec1,'results':_0x17fae7,'results_count':_0x17fae7['length'],'has_more':!0x1,...void 0x0!==_0x14fcd4?{'total_count':_0x14fcd4}:{}};},async 'getDocumentById'(_0x4cbb84){const _0xfa954b=_0x2b0051,_0x3d27bc=_0x570fdb[_0xfa954b(0xcd)](String,_0x4cbb84[_0xfa954b(0x126)]||''),_0x2919eb=_0x260729[_0x3d27bc];if(!_0x2919eb)throw new Error(_0xfa954b(0xaa)+_0x3d27bc+'\x27\x20is\x20not\x20registered');const _0x54a207=_0x2c958c[_0xfa954b(0xf4)](_0x2919eb[_0xfa954b(0xf8)]),_0x793556=_0x4cbb84['documentId'],_0xb86f50=_0x570fdb[_0xfa954b(0xb7)](normalizeDateFilters,_0x4cbb84[_0xfa954b(0xae)]||{},_0x22d106[_0xfa954b(0xd9)](_0x3d27bc)),_0x2d6279=_0x570fdb[_0xfa954b(0xb2)](buildProjection,Array['isArray'](_0x4cbb84[_0xfa954b(0xcf)])?_0x4cbb84[_0xfa954b(0xcf)]:_0x2919eb[_0xfa954b(0x109)]),_0x3123a8={'_id':_0x793556,..._0xb86f50},_0x237dfb=await _0x54a207[_0xfa954b(0x112)](_0x3123a8,_0x2d6279?{'projection':_0x2d6279}:void 0x0);return _0x237dfb?{'model':_0x3d27bc,'found':!0x0,'document':_0x237dfb}:{'model':_0x3d27bc,'found':!0x1};}};}