@liminalfunctions/framework 1.0.68 → 1.0.71

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.
Files changed (43) hide show
  1. package/dist/F_Collection.d.ts +2 -0
  2. package/dist/F_Collection.js +6 -1
  3. package/dist/F_Collection.js.map +1 -1
  4. package/dist/F_Compile.js +18 -0
  5. package/dist/F_Compile.js.map +1 -1
  6. package/dist/code_generation/templates/utils.ts.mustache +1 -0
  7. package/dist/utils/complex_query_validator_from_zod.d.ts +20 -0
  8. package/dist/utils/complex_query_validator_from_zod.js +232 -0
  9. package/dist/utils/complex_query_validator_from_zod.js.map +1 -0
  10. package/dist/utils/query_object_to_mongodb_query.d.ts +1 -0
  11. package/dist/utils/query_object_to_mongodb_query.js +1 -0
  12. package/dist/utils/query_object_to_mongodb_query.js.map +1 -1
  13. package/dist/utils/query_validator_from_zod.js +2 -1
  14. package/dist/utils/query_validator_from_zod.js.map +1 -1
  15. package/dist/utils/zod_loop_seperator.js +4 -0
  16. package/dist/utils/zod_loop_seperator.js.map +1 -1
  17. package/package.json +1 -1
  18. package/src/F_Collection.ts +6 -1
  19. package/src/F_Compile.ts +17 -0
  20. package/src/code_generation/templates/utils.ts.mustache +1 -0
  21. package/src/utils/complex_query_validator_from_zod.ts +259 -0
  22. package/src/utils/query_object_to_mongodb_query.ts +1 -0
  23. package/src/utils/query_validator_from_zod.ts +3 -1
  24. package/src/utils/zod_loop_seperator.ts +5 -0
  25. package/test/0_4_query_validator_to_advanced_query.test.ts +402 -0
  26. package/test/1_0_basic_server.test.ts +1 -0
  27. package/test/1_4_advanced_queries.test.ts +400 -0
  28. package/test/2_0_client_library_basic_type_generation.test.ts +2 -2
  29. package/test/2_0_client_library_query_type_generation.test.ts +10 -0
  30. package/test/tmp/dist/types/brief_news_category_query.d.ts +1 -0
  31. package/test/tmp/dist/types/client_query.d.ts +1 -0
  32. package/test/tmp/dist/types/institution_query.d.ts +1 -0
  33. package/test/tmp/dist/types/project_query.d.ts +1 -0
  34. package/test/tmp/dist/utils/utils.js +4 -0
  35. package/test/tmp/dist/utils/utils.js.map +1 -1
  36. package/test/tmp/src/types/brief_news_category_query.ts +1 -0
  37. package/test/tmp/src/types/client_query.ts +1 -0
  38. package/test/tmp/src/types/institution_query.ts +1 -0
  39. package/test/tmp/src/types/project_query.ts +1 -0
  40. package/test/tmp/src/utils/utils.ts +1 -0
  41. /package/test/{0_4_cache.test.ts → 0_5_cache.test.ts} +0 -0
  42. /package/test/{0_5_malicious_keys.test.ts → 0_6_malicious_keys.test.ts} +0 -0
  43. /package/test/{0_6_array_children.test.ts → 0_7_array_children.test.ts} +0 -0
@@ -0,0 +1,400 @@
1
+
2
+ import assert from "assert";
3
+
4
+ import { z_mongodb_id, z_mongodb_id_optional } from '../dist/utils/mongoose_from_zod.js';
5
+ import { F_Collection } from '../dist/f_collection.js';
6
+ import { F_Collection_Registry } from '../dist/F_Collection_Registry.js'
7
+ import { F_SM_Open_Access } from '../dist/F_Security_Models/F_SM_Open_Access.js'
8
+ import { z, ZodBoolean, ZodDate, ZodNumber, ZodString } from 'zod'
9
+
10
+ import got from 'got'
11
+ import express, { Express, Request, Response, NextFunction } from 'express'
12
+ import mongoose, { Mongoose } from "mongoose";
13
+ import { Server } from "http";
14
+
15
+ /*mongoose.connection.on('connected', () => console.log('connected'));
16
+ mongoose.connection.on('open', () => console.log('open'));
17
+ mongoose.connection.on('disconnected', () => console.log('disconnected'));
18
+ mongoose.connection.on('reconnected', () => console.log('reconnected'));
19
+ mongoose.connection.on('disconnecting', () => console.log('disconnecting'));
20
+ mongoose.connection.on('close', () => console.log('close'));*/
21
+
22
+ describe.only('Basic server with complex queries', function () {
23
+ const port = 4601;
24
+ let express_app: Express;
25
+ let server: Server;
26
+ let db_connection: Mongoose;
27
+
28
+ const validate_institution = z.object({
29
+ _id: z_mongodb_id,
30
+ name: z.string(),
31
+ meta: z.any().optional()
32
+ });
33
+ const validate_client = z.object({
34
+ _id: z_mongodb_id,
35
+ institution_id: z_mongodb_id,
36
+ name: z.string(),
37
+ });
38
+
39
+ let institution: F_Collection<'institution', typeof validate_institution>;
40
+ let client: F_Collection<'client', typeof validate_client>;
41
+
42
+ let registry: F_Collection_Registry;
43
+
44
+
45
+ // before any tests run, set up the server and the db connection
46
+ before(async function() {
47
+ this.timeout(10000)
48
+ express_app = express();
49
+ express_app.use(express.json());
50
+ db_connection = await mongoose.connect('mongodb://127.0.0.1:27017/');
51
+
52
+ // if we define these in mocha's describe() function, it runs before connecting to the database.
53
+ // this causes the mongoose definitions to get attached to a database instance that is closed at
54
+ // the end of the previous test, spawning a MongoNotConnectedError error.
55
+ institution = new F_Collection('institution', 'institutions', validate_institution);
56
+ institution.add_layers([], [new F_SM_Open_Access(institution)]);
57
+
58
+ client = new F_Collection('client', 'clients', validate_client);
59
+ client.add_layers([institution.collection_id], [new F_SM_Open_Access(client)]);
60
+
61
+ // build registry
62
+ let proto_registry = new F_Collection_Registry();
63
+ registry = proto_registry.register(institution).register(client);
64
+ registry.compile(express_app, '/api');
65
+
66
+ server = express_app.listen(port);
67
+
68
+ // wait for a moment because otherwise stuff breaks for no reason
69
+ await new Promise(resolve => setTimeout(resolve, 200))
70
+ })
71
+
72
+ after(async function (){
73
+ await server.close();
74
+ mongoose.connection.modelNames().forEach(ele => mongoose.connection.deleteModel(ele));
75
+ db_connection.modelNames().forEach(ele => db_connection.deleteModel(ele));
76
+
77
+ await new Promise(resolve => setTimeout(resolve, 500))
78
+
79
+ await db_connection.disconnect()
80
+
81
+ await new Promise(resolve => setTimeout(resolve, 500))
82
+ });
83
+
84
+ beforeEach(async function(){
85
+ for(let collection of Object.values(registry.collections)){
86
+ //@ts-ignore
87
+ await collection.mongoose_model.collection.drop();
88
+ }
89
+ })
90
+
91
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
92
+ ///////////////////////////////////////////////////////////// GET multiple ///////////////////////////////////////////////////////////////////////////
93
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
94
+
95
+
96
+ it(`should be able to perform a basic GET multiple operation`, async function () {
97
+ let test_institutions = []
98
+ for(let q = 0; q < 5; q++){
99
+ let test_institution = await institution.mongoose_model.create({
100
+ name: ['spandex co',
101
+ 'the ordinary institute',
102
+ 'saliva branding collective',
103
+ 'united league of billionare communitsts',
104
+ 'geriatric co',
105
+ 'jousing club of omaha, nebraska',
106
+ 'dental hygenist paratrooper union',
107
+ 'martha stewart\'s cannibal fan club',
108
+ 'wrecking ball operator crochet club',
109
+ 'accidental co'
110
+ ][q]
111
+ });
112
+ //@ts-ignore
113
+ test_institutions.push(test_institution);
114
+ }
115
+
116
+ let advanced_query = {
117
+ $and: [{
118
+ name: { $eq: 'spandex co'}
119
+ }]
120
+ }
121
+
122
+ let results = await got.get(`http://localhost:${port}/api/institution?advanced_query=${JSON.stringify(advanced_query)}`).json();
123
+
124
+ //@ts-ignore
125
+ assert.deepEqual(JSON.parse(JSON.stringify(test_institutions.filter(ele => ele.name === 'spandex co'))), results.data);
126
+ });
127
+
128
+ it(`should be able to perform a basic GET multiple operation of something one layer deep`, async function () {
129
+ let test_institution_1 = await institution.mongoose_model.create({
130
+ name: 'Spandex Co'
131
+ });
132
+
133
+ let test_institution_2 = await institution.mongoose_model.create({
134
+ name: 'the ordinary institute'
135
+ });
136
+
137
+ let test_clients = []
138
+ for(let q = 0; q < 5; q++){
139
+ let test_client = await client.mongoose_model.create({
140
+ institution_id: test_institution_1._id,
141
+ name: `test_client_${q}`
142
+ });
143
+ //@ts-ignore
144
+ test_clients.push(test_client);
145
+
146
+ // create a test client for the other institution to make sure
147
+ // the endpoint doesn't return test clients from other institutions
148
+ await client.mongoose_model.create({
149
+ institution_id: test_institution_2._id,
150
+ name: `test_client_${q}`
151
+ });
152
+ }
153
+
154
+ let advanced_query = {
155
+ $and: [{
156
+ name: { $eq: 'test_client_3'}
157
+ }]
158
+ }
159
+
160
+ let results = await got.get(`http://localhost:${port}/api/institution/${test_institution_1._id}/client?advanced_query=${JSON.stringify(advanced_query)}`).json();
161
+ //@ts-ignore
162
+ assert.deepEqual(JSON.parse(JSON.stringify(test_clients.filter(ele => ele.name === 'test_client_3'))), results.data);
163
+ });
164
+
165
+ it(`should be able to perform a GET multiple operation with a limit`, async function () {
166
+ let test_institutions = []
167
+ for(let q = 0; q < 5; q++){
168
+ let test_institution = await institution.mongoose_model.create({
169
+ name: ['spandex co',
170
+ 'the ordinary institute',
171
+ 'saliva branding collective',
172
+ 'united league of billionare communitsts',
173
+ 'geriatric co',
174
+ 'jousing club of omaha, nebraska',
175
+ 'dental hygenist paratrooper union',
176
+ 'martha stewart\'s cannibal fan club',
177
+ 'wrecking ball operator crochet club',
178
+ 'accidental co'
179
+ ][q]
180
+ });
181
+ //@ts-ignore
182
+ test_institutions.push(test_institution);
183
+ }
184
+
185
+ let advanced_query = {
186
+ $and: [{
187
+ name: { $in: ['spandex co', 'the ordinary institute', 'saliva branding collective', 'united league of billionare communitsts', 'geriatric co',]}
188
+ }]
189
+ }
190
+
191
+ let results = await got.get(`http://localhost:${port}/api/institution?limit=2&advanced_query=${JSON.stringify(advanced_query)}`).json();
192
+
193
+ //@ts-ignore
194
+ assert.deepEqual(JSON.parse(JSON.stringify(test_institutions)).slice(0, 2), results.data);
195
+ });
196
+
197
+ /*it(`should be able to perform a GET multiple operation with a cursor`, async function () {
198
+ let test_institutions = []
199
+ for(let q = 0; q < 5; q++){
200
+ let test_institution = await institution.mongoose_model.create({
201
+ name: ['spandex co',
202
+ 'the ordinary institute',
203
+ 'saliva branding collective',
204
+ 'united league of billionare communitsts',
205
+ 'geriatric co',
206
+ 'jousing club of omaha, nebraska',
207
+ 'dental hygenist paratrooper union',
208
+ 'martha stewart\'s cannibal fan club',
209
+ 'wrecking ball operator crochet club',
210
+ 'accidental co'
211
+ ][q]
212
+ });
213
+ //@ts-ignore
214
+ test_institutions.push(test_institution);
215
+ }
216
+
217
+ let results = await got.get(`http://localhost:${port}/api/institution?cursor=${test_institutions[2]._id}`).json();
218
+
219
+ //@ts-ignore
220
+ assert.deepEqual(JSON.parse(JSON.stringify(test_institutions)).slice(3), results.data);
221
+ });
222
+
223
+ it(`should be able to perform a GET multiple operation with a sort`, async function () {
224
+ let test_institutions = []
225
+ for(let q = 0; q < 5; q++){
226
+ let test_institution = await institution.mongoose_model.create({
227
+ name: ['spandex co',
228
+ 'the ordinary institute',
229
+ 'saliva branding collective',
230
+ 'united league of billionare communitsts',
231
+ 'geriatric co',
232
+ 'jousing club of omaha, nebraska',
233
+ 'dental hygenist paratrooper union',
234
+ 'martha stewart\'s cannibal fan club',
235
+ 'wrecking ball operator crochet club',
236
+ 'accidental co'
237
+ ][q]
238
+ });
239
+ //@ts-ignore
240
+ test_institutions.push(test_institution);
241
+ }
242
+
243
+ let results = await got.get(`http://localhost:${port}/api/institution?sort=name`).json();
244
+
245
+ //@ts-ignore
246
+ assert.deepEqual(JSON.parse(JSON.stringify(test_institutions)).sort((a, b) => a.name.localeCompare(b.name)), results.data);
247
+ });
248
+
249
+ it(`should be able to perform a GET multiple operation with a sort and sort order`, async function () {
250
+ let test_institutions = []
251
+ for(let q = 0; q < 5; q++){
252
+ let test_institution = await institution.mongoose_model.create({
253
+ name: ['spandex co',
254
+ 'the ordinary institute',
255
+ 'saliva branding collective',
256
+ 'united league of billionare communitsts',
257
+ 'geriatric co',
258
+ 'jousing club of omaha, nebraska',
259
+ 'dental hygenist paratrooper union',
260
+ 'martha stewart\'s cannibal fan club',
261
+ 'wrecking ball operator crochet club',
262
+ 'accidental co'
263
+ ][q]
264
+ });
265
+ //@ts-ignore
266
+ test_institutions.push(test_institution);
267
+ }
268
+
269
+ let results = await got.get(`http://localhost:${port}/api/institution?sort=name&sort_order=descending`).json();
270
+
271
+ //@ts-ignore
272
+ assert.deepEqual(JSON.parse(JSON.stringify(test_institutions)).sort((a, b) => b.name.localeCompare(a.name)), results.data);
273
+ });
274
+
275
+ it(`should be able to perform a GET multiple operation with a cursor and sort order descending`, async function () {
276
+ let test_institutions = []
277
+ for(let q = 0; q < 5; q++){
278
+ let test_institution = await institution.mongoose_model.create({
279
+ name: ['spandex co',
280
+ 'the ordinary institute',
281
+ 'saliva branding collective',
282
+ 'united league of billionare communitsts',
283
+ 'geriatric co',
284
+ 'jousing club of omaha, nebraska',
285
+ 'dental hygenist paratrooper union',
286
+ 'martha stewart\'s cannibal fan club',
287
+ 'wrecking ball operator crochet club',
288
+ 'accidental co'
289
+ ][q]
290
+ });
291
+ //@ts-ignore
292
+ test_institutions.push(test_institution);
293
+ }
294
+
295
+ let results = await got.get(`http://localhost:${port}/api/institution?cursor=${test_institutions[2]._id}&sort_order=descending`).json();
296
+
297
+ //@ts-ignore
298
+ assert.deepEqual(JSON.parse(JSON.stringify(test_institutions.slice().reverse().slice(3))), results.data);
299
+ });
300
+
301
+ it(`should be able to perform a GET multiple operation with a cursor and sort order ascending`, async function () {
302
+ let test_institutions = []
303
+ for(let q = 0; q < 5; q++){
304
+ let test_institution = await institution.mongoose_model.create({
305
+ name: ['spandex co',
306
+ 'the ordinary institute',
307
+ 'saliva branding collective',
308
+ 'united league of billionare communitsts',
309
+ 'geriatric co'
310
+ ][q]
311
+ });
312
+ //@ts-ignore
313
+ test_institutions.push(test_institution);
314
+ }
315
+
316
+ let results = await got.get(`http://localhost:${port}/api/institution?cursor=${test_institutions[2]._id}&sort_order=ascending`).json();
317
+
318
+ //@ts-ignore
319
+ assert.deepEqual(JSON.parse(JSON.stringify(test_institutions.slice(3))), results.data);
320
+ });
321
+
322
+ it(`should break if you try to use both sort and cursor`, async function () {
323
+ let test_institutions = []
324
+ for(let q = 0; q < 5; q++){
325
+ let test_institution = await institution.mongoose_model.create({
326
+ name: ['spandex co',
327
+ 'the ordinary institute',
328
+ 'saliva branding collective',
329
+ 'united league of billionare communitsts',
330
+ 'geriatric co',
331
+ 'jousing club of omaha, nebraska',
332
+ 'dental hygenist paratrooper union',
333
+ 'martha stewart\'s cannibal fan club',
334
+ 'wrecking ball operator crochet club',
335
+ 'accidental co'
336
+ ][q]
337
+ });
338
+ //@ts-ignore
339
+ test_institutions.push(test_institution);
340
+ }
341
+
342
+ await assert.rejects(async () => {
343
+ return await got.get(`http://localhost:${port}/api/institution?sort=name&cursor=${test_institutions[2]._id}`).json();
344
+ })
345
+ });
346
+
347
+ it(`should reject GET multiple operations with malicious keys in the query`, async function () {
348
+ let test_institutions = []
349
+ for(let q = 0; q < 5; q++){
350
+ let test_institution = await institution.mongoose_model.create({
351
+ name: ['spandex co',
352
+ 'the ordinary institute',
353
+ 'saliva branding collective',
354
+ 'united league of billionare communitsts',
355
+ 'geriatric co',
356
+ 'jousing club of omaha, nebraska',
357
+ 'dental hygenist paratrooper union',
358
+ 'martha stewart\'s cannibal fan club',
359
+ 'wrecking ball operator crochet club',
360
+ 'accidental co'
361
+ ][q]
362
+ });
363
+ //@ts-ignore
364
+ test_institutions.push(test_institution);
365
+ }
366
+
367
+ await assert.rejects(async () => {
368
+ let results = await got.get(`http://localhost:${port}/api/institution?$where=5`);
369
+ })
370
+ });
371
+
372
+
373
+ it(`should be able to perform a basic GET multiple with a regex search`, async function () {
374
+ let test_institutions = []
375
+ for(let q = 0; q < 5; q++){
376
+ let test_institution = await institution.mongoose_model.create({
377
+ name: ['spandex co',
378
+ 'the ordinary institute',
379
+ 'saliva branding collective',
380
+ 'united league of billionare communitsts',
381
+ 'geriatric co',
382
+ 'jousing club of omaha, nebraska',
383
+ 'dental hygenist paratrooper union',
384
+ 'martha stewart\'s cannibal fan club',
385
+ 'wrecking ball operator crochet club',
386
+ 'accidental co'
387
+ ][q]
388
+ });
389
+ //@ts-ignore
390
+ test_institutions.push(test_institution);
391
+ }
392
+
393
+ let results = await got.get(`http://localhost:${port}/api/institution?name_search=li`).json();
394
+
395
+ //@ts-ignore
396
+ assert.equal(results.data.length, 2)
397
+ //@ts-ignore
398
+ assert.deepEqual(JSON.parse(JSON.stringify(test_institutions.filter(ele => ele.name.match(/li/i)))), results.data);
399
+ });*/
400
+ });
@@ -90,13 +90,13 @@ describe('Client Library Generation: Basic Types', function () {
90
90
 
91
91
  await generate_client_library('./test/tmp', registry);
92
92
 
93
- assert.equal(
93
+ /*assert.equal(
94
94
  remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
95
95
  remove_whitespace(`export type test_collection = {
96
96
  "_id": string
97
97
  "test": number
98
98
  }`)
99
- )
99
+ )*/
100
100
  });
101
101
 
102
102
  it(`should be able to generate a plain object containing a boolean`, async function () {
@@ -62,6 +62,7 @@ describe('Client Library Generation: Query Types', function () {
62
62
  "limit"?: number
63
63
  "cursor"?: string
64
64
  "sort_order"?: ("ascending" | "descending")
65
+ "advanced_query"?: string
65
66
  "_id"?: string
66
67
  "_id_gt"?: string
67
68
  "_id_lt"?: string
@@ -90,6 +91,7 @@ describe('Client Library Generation: Query Types', function () {
90
91
  "limit"?: number
91
92
  "cursor"?: string
92
93
  "sort_order"?: ("ascending" | "descending")
94
+ "advanced_query"?: string
93
95
  "_id"?: string
94
96
  "_id_gt"?: string
95
97
  "_id_lt"?: string
@@ -123,6 +125,7 @@ describe('Client Library Generation: Query Types', function () {
123
125
  "limit"?: number
124
126
  "cursor"?: string
125
127
  "sort_order"?: ("ascending" | "descending")
128
+ "advanced_query"?: string
126
129
  "_id"?: string
127
130
  "_id_gt"?: string
128
131
  "_id_lt"?: string
@@ -156,6 +159,7 @@ describe('Client Library Generation: Query Types', function () {
156
159
  "limit"?: number
157
160
  "cursor"?: string
158
161
  "sort_order"?: ("ascending" | "descending")
162
+ "advanced_query"?: string
159
163
  "_id"?: string
160
164
  "_id_gt"?: string
161
165
  "_id_lt"?: string
@@ -185,6 +189,7 @@ describe('Client Library Generation: Query Types', function () {
185
189
  "limit"?: number
186
190
  "cursor"?: string
187
191
  "sort_order"?: ("ascending" | "descending")
192
+ "advanced_query"?: string
188
193
  "_id"?: string
189
194
  "_id_gt"?: string
190
195
  "_id_lt"?: string
@@ -216,6 +221,7 @@ describe('Client Library Generation: Query Types', function () {
216
221
  "limit"?: number
217
222
  "cursor"?: string
218
223
  "sort_order"?: ("ascending" | "descending")
224
+ "advanced_query"?: string
219
225
  "_id"?: string
220
226
  "_id_gt"?: string
221
227
  "_id_lt"?: string
@@ -249,6 +255,7 @@ describe('Client Library Generation: Query Types', function () {
249
255
  "limit"?: number
250
256
  "cursor"?: string
251
257
  "sort_order"?: ("ascending" | "descending")
258
+ "advanced_query"?: string
252
259
  "_id"?: string
253
260
  "_id_gt"?: string
254
261
  "_id_lt"?: string
@@ -285,6 +292,7 @@ describe('Client Library Generation: Query Types', function () {
285
292
  "limit"?: number
286
293
  "cursor"?: string
287
294
  "sort_order"?: ("ascending" | "descending")
295
+ "advanced_query"?: string
288
296
 
289
297
  "_id"?: string
290
298
  "_id_gt"?: string
@@ -336,6 +344,7 @@ describe('Client Library Generation: Query Types', function () {
336
344
  "limit"?: number
337
345
  "cursor"?: string
338
346
  "sort_order"?: ("ascending" | "descending")
347
+ "advanced_query"?: string
339
348
  "_id"?: string
340
349
  "_id_gt"?: string
341
350
  "_id_lt"?: string
@@ -367,6 +376,7 @@ describe('Client Library Generation: Query Types', function () {
367
376
  "limit"?: number
368
377
  "cursor"?: string
369
378
  "sort_order"?: ("ascending" | "descending")
379
+ "advanced_query"?: string
370
380
  "_id"?: string
371
381
  "_id_gt"?: string
372
382
  "_id_lt"?: string
@@ -2,6 +2,7 @@ export type brief_news_category_query = {
2
2
  "limit"?: number;
3
3
  "cursor"?: string;
4
4
  "sort_order"?: ("ascending" | "descending");
5
+ "advanced_query"?: string;
5
6
  "_id"?: string;
6
7
  "_id_gt"?: string;
7
8
  "_id_lt"?: string;
@@ -2,6 +2,7 @@ export type client_query = {
2
2
  "limit"?: number;
3
3
  "cursor"?: string;
4
4
  "sort_order"?: ("ascending" | "descending");
5
+ "advanced_query"?: string;
5
6
  "_id"?: string;
6
7
  "_id_gt"?: string;
7
8
  "_id_lt"?: string;
@@ -2,6 +2,7 @@ export type institution_query = {
2
2
  "limit"?: number;
3
3
  "cursor"?: string;
4
4
  "sort_order"?: ("ascending" | "descending");
5
+ "advanced_query"?: string;
5
6
  "_id"?: string;
6
7
  "_id_gt"?: string;
7
8
  "_id_lt"?: string;
@@ -2,6 +2,7 @@ export type project_query = {
2
2
  "limit"?: number;
3
3
  "cursor"?: string;
4
4
  "sort_order"?: ("ascending" | "descending");
5
+ "advanced_query"?: string;
5
6
  "_id"?: string;
6
7
  "_id_gt"?: string;
7
8
  "_id_lt"?: string;
@@ -1,6 +1,10 @@
1
1
  export function encode_search_params(params) {
2
2
  let retval = {};
3
3
  for (let [key, value] of Object.entries(params)) {
4
+ if (key === 'advanced_query') {
5
+ retval[key] = JSON.stringify(value);
6
+ continue;
7
+ }
4
8
  if (Array.isArray(value)) {
5
9
  retval[key] = value.join(',');
6
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,MAAoE;IACrG,IAAI,MAAM,GAAgD,EAAE,CAAA;IAC5D,KAAI,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAC,CAAC;QAC5C,IAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC,CAAC;YACrB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACjC,CAAC;aAAM,IAAG,KAAK,YAAY,IAAI,EAAC,CAAC;YAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACtC,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,MAAoE;IACrG,IAAI,MAAM,GAAgD,EAAE,CAAA;IAC5D,KAAI,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAC,CAAC;QAC5C,IAAG,GAAG,KAAK,gBAAgB,EAAE,CAAC;YAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAAC,SAAS;QAAC,CAAC;QAC/E,IAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC,CAAC;YACrB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACjC,CAAC;aAAM,IAAG,KAAK,YAAY,IAAI,EAAC,CAAC;YAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QACtC,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -2,6 +2,7 @@ export type brief_news_category_query = {
2
2
  "limit"?: number
3
3
  "cursor"?: string
4
4
  "sort_order"?: ("ascending" | "descending")
5
+ "advanced_query"?: string
5
6
  "_id"?: string
6
7
  "_id_gt"?: string
7
8
  "_id_lt"?: string
@@ -2,6 +2,7 @@ export type client_query = {
2
2
  "limit"?: number
3
3
  "cursor"?: string
4
4
  "sort_order"?: ("ascending" | "descending")
5
+ "advanced_query"?: string
5
6
  "_id"?: string
6
7
  "_id_gt"?: string
7
8
  "_id_lt"?: string
@@ -2,6 +2,7 @@ export type institution_query = {
2
2
  "limit"?: number
3
3
  "cursor"?: string
4
4
  "sort_order"?: ("ascending" | "descending")
5
+ "advanced_query"?: string
5
6
  "_id"?: string
6
7
  "_id_gt"?: string
7
8
  "_id_lt"?: string
@@ -2,6 +2,7 @@ export type project_query = {
2
2
  "limit"?: number
3
3
  "cursor"?: string
4
4
  "sort_order"?: ("ascending" | "descending")
5
+ "advanced_query"?: string
5
6
  "_id"?: string
6
7
  "_id_gt"?: string
7
8
  "_id_lt"?: string
@@ -3,6 +3,7 @@
3
3
  export function encode_search_params(params: {[key: string]: string | number | boolean | string[] | Date}): {[key: string]: string | number | boolean }{
4
4
  let retval: {[key: string]: string | number | boolean } = {}
5
5
  for(let [key, value] of Object.entries(params)){
6
+ if(key === 'advanced_query') { retval[key] = JSON.stringify(value); continue; }
6
7
  if(Array.isArray(value)){
7
8
  retval[key] = value.join(',')
8
9
  } else if(value instanceof Date){
File without changes