@liminalfunctions/framework 1.0.3 → 1.0.7
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/dist/F_Compile.js +35 -28
- package/dist/F_Compile.js.map +1 -1
- package/dist/code_generation/utils/type_from_zod.js +3 -3
- package/dist/code_generation/utils/type_from_zod.js.map +1 -1
- package/dist/utils/mongoose_from_zod.js +3 -3
- package/dist/utils/mongoose_from_zod.js.map +1 -1
- package/package.json +15 -2
- package/src/F_Compile.ts +52 -40
- package/src/code_generation/utils/type_from_zod.ts +3 -3
- package/src/index.ts +1 -0
- package/src/utils/mongoose_from_zod.ts +3 -3
- package/test/0_0_mongoose_from_zod.test.ts +8 -6
- package/test/1_0_basic_server.test.ts +5 -0
- package/test/1_1_security_ownership.test.ts +5 -0
- package/test/1_2_role_membership.test.ts +33 -12
- package/test/2_0_client_library_basic_type_generation.test.ts +6 -6
- package/test/tmp/package-lock.json +3 -3
- package/test/tmp/dist/Brief_News_Category.d.ts +0 -16
- package/test/tmp/dist/Brief_News_Category.js +0 -85
- package/test/tmp/dist/Brief_News_Category.js.map +0 -1
- package/test/tmp/dist/Client.d.ts +0 -19
- package/test/tmp/dist/Client.js +0 -97
- package/test/tmp/dist/Client.js.map +0 -1
- package/test/tmp/dist/Institution.d.ts +0 -18
- package/test/tmp/dist/Institution.js +0 -94
- package/test/tmp/dist/Institution.js.map +0 -1
- package/test/tmp/dist/Project.d.ts +0 -16
- package/test/tmp/dist/Project.js +0 -85
- package/test/tmp/dist/Project.js.map +0 -1
- package/test/tmp/dist/index.d.ts +0 -4
- package/test/tmp/dist/index.js +0 -14
- package/test/tmp/dist/index.js.map +0 -1
- package/test/tmp/dist/types/brief_news_category.d.ts +0 -7
- package/test/tmp/dist/types/brief_news_category.js +0 -2
- package/test/tmp/dist/types/brief_news_category.js.map +0 -1
- package/test/tmp/dist/types/brief_news_category_post.d.ts +0 -7
- package/test/tmp/dist/types/brief_news_category_post.js +0 -2
- package/test/tmp/dist/types/brief_news_category_post.js.map +0 -1
- package/test/tmp/dist/types/brief_news_category_put.d.ts +0 -7
- package/test/tmp/dist/types/brief_news_category_put.js +0 -2
- package/test/tmp/dist/types/brief_news_category_put.js.map +0 -1
- package/test/tmp/dist/types/brief_news_category_query.d.ts +0 -26
- package/test/tmp/dist/types/brief_news_category_query.js +0 -2
- package/test/tmp/dist/types/brief_news_category_query.js.map +0 -1
- package/test/tmp/dist/types/client.d.ts +0 -5
- package/test/tmp/dist/types/client.js +0 -2
- package/test/tmp/dist/types/client.js.map +0 -1
- package/test/tmp/dist/types/client_post.d.ts +0 -5
- package/test/tmp/dist/types/client_post.js +0 -2
- package/test/tmp/dist/types/client_post.js.map +0 -1
- package/test/tmp/dist/types/client_put.d.ts +0 -5
- package/test/tmp/dist/types/client_put.js +0 -2
- package/test/tmp/dist/types/client_put.js.map +0 -1
- package/test/tmp/dist/types/client_query.d.ts +0 -18
- package/test/tmp/dist/types/client_query.js +0 -2
- package/test/tmp/dist/types/client_query.js.map +0 -1
- package/test/tmp/dist/types/institution.d.ts +0 -4
- package/test/tmp/dist/types/institution.js +0 -2
- package/test/tmp/dist/types/institution.js.map +0 -1
- package/test/tmp/dist/types/institution_post.d.ts +0 -4
- package/test/tmp/dist/types/institution_post.js +0 -2
- package/test/tmp/dist/types/institution_post.js.map +0 -1
- package/test/tmp/dist/types/institution_put.d.ts +0 -4
- package/test/tmp/dist/types/institution_put.js +0 -2
- package/test/tmp/dist/types/institution_put.js.map +0 -1
- package/test/tmp/dist/types/institution_query.d.ts +0 -14
- package/test/tmp/dist/types/institution_query.js +0 -2
- package/test/tmp/dist/types/institution_query.js.map +0 -1
- package/test/tmp/dist/types/project.d.ts +0 -7
- package/test/tmp/dist/types/project.js +0 -2
- package/test/tmp/dist/types/project.js.map +0 -1
- package/test/tmp/dist/types/project_post.d.ts +0 -7
- package/test/tmp/dist/types/project_post.js +0 -2
- package/test/tmp/dist/types/project_post.js.map +0 -1
- package/test/tmp/dist/types/project_put.d.ts +0 -7
- package/test/tmp/dist/types/project_put.js +0 -2
- package/test/tmp/dist/types/project_put.js.map +0 -1
- package/test/tmp/dist/types/project_query.d.ts +0 -27
- package/test/tmp/dist/types/project_query.js +0 -2
- package/test/tmp/dist/types/project_query.js.map +0 -1
- package/test/tmp/dist/utils/utils.d.ts +0 -11
- package/test/tmp/dist/utils/utils.js +0 -13
- package/test/tmp/dist/utils/utils.js.map +0 -1
|
@@ -15,8 +15,9 @@ import express, { Express, Request, Response, NextFunction } from 'express'
|
|
|
15
15
|
import mongoose, { Mongoose } from "mongoose";
|
|
16
16
|
import { Server } from "http";
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
// IF YOU RUN THESE TESTS ON THEIR OWN, THEY WORK FINE
|
|
19
|
+
// there's something janky going on with the mongodb or express
|
|
20
|
+
// setup/teardown that's causing the mto fail.
|
|
20
21
|
describe('Security Model Role Membership', function () {
|
|
21
22
|
const port = 4601;
|
|
22
23
|
let express_app: Express;
|
|
@@ -86,6 +87,8 @@ describe('Security Model Role Membership', function () {
|
|
|
86
87
|
express_app = express();
|
|
87
88
|
express_app.use(express.json());
|
|
88
89
|
db_connection = await mongoose.connect('mongodb://127.0.0.1:27017/');
|
|
90
|
+
//console.log('connected')
|
|
91
|
+
//console.log(db_connection)
|
|
89
92
|
|
|
90
93
|
let cache_role = new Cache(60);
|
|
91
94
|
let cache_institution_role_membership = new Cache(60);
|
|
@@ -174,7 +177,14 @@ describe('Security Model Role Membership', function () {
|
|
|
174
177
|
await server.close();
|
|
175
178
|
mongoose.connection.modelNames().forEach(ele => mongoose.connection.deleteModel(ele));
|
|
176
179
|
db_connection.modelNames().forEach(ele => db_connection.deleteModel(ele));
|
|
180
|
+
|
|
181
|
+
await new Promise(resolve => setTimeout(resolve, 500))
|
|
182
|
+
//console.log(db_connection);
|
|
183
|
+
//console.log(db_connection.connection.readyState);
|
|
184
|
+
|
|
177
185
|
await db_connection.disconnect()
|
|
186
|
+
|
|
187
|
+
await new Promise(resolve => setTimeout(resolve, 500))
|
|
178
188
|
});
|
|
179
189
|
|
|
180
190
|
beforeEach(async function(){
|
|
@@ -182,6 +192,7 @@ describe('Security Model Role Membership', function () {
|
|
|
182
192
|
//@ts-ignore
|
|
183
193
|
await collection.mongoose_model.collection.drop();
|
|
184
194
|
}
|
|
195
|
+
await new Promise(resolve => setTimeout(resolve, 500))
|
|
185
196
|
})
|
|
186
197
|
|
|
187
198
|
/**
|
|
@@ -372,14 +383,24 @@ describe('Security Model Role Membership', function () {
|
|
|
372
383
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
373
384
|
|
|
374
385
|
it(`should authorize a basic GET operation on a document where the user has a T1 role membership`, async function () {
|
|
386
|
+
console.log('HERE')
|
|
387
|
+
|
|
375
388
|
let { steve_institution, steve_client, steve_project } = await generate_test_setup();
|
|
376
389
|
|
|
390
|
+
console.log('DEBUGDAT')
|
|
391
|
+
|
|
392
|
+
console.log(await collection_project.mongoose_model.find({}));
|
|
393
|
+
|
|
394
|
+
console.log('PRECALL')
|
|
395
|
+
|
|
377
396
|
let results = await got.get(`http://localhost:${port}/api/institution/${steve_institution._id}/client/${steve_client._id}/project/${steve_project._id}`, {
|
|
378
397
|
headers: {
|
|
379
398
|
authorization: 'steve'
|
|
380
399
|
}
|
|
381
400
|
}).json();
|
|
382
401
|
|
|
402
|
+
console.log('POSTCALL')
|
|
403
|
+
|
|
383
404
|
//@ts-ignore
|
|
384
405
|
assert.deepEqual(JSON.parse(JSON.stringify(steve_project)), results.data);
|
|
385
406
|
});
|
|
@@ -407,7 +428,7 @@ describe('Security Model Role Membership', function () {
|
|
|
407
428
|
}
|
|
408
429
|
}).json();
|
|
409
430
|
},
|
|
410
|
-
{ message: '
|
|
431
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
411
432
|
});
|
|
412
433
|
|
|
413
434
|
it(`should reject a basic GET operation on a document where the user has no role membership`, async function () {
|
|
@@ -420,7 +441,7 @@ describe('Security Model Role Membership', function () {
|
|
|
420
441
|
}
|
|
421
442
|
}).json();
|
|
422
443
|
},
|
|
423
|
-
{ message: '
|
|
444
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
424
445
|
});
|
|
425
446
|
|
|
426
447
|
|
|
@@ -491,7 +512,7 @@ describe('Security Model Role Membership', function () {
|
|
|
491
512
|
}
|
|
492
513
|
}).json();
|
|
493
514
|
},
|
|
494
|
-
{ message: '
|
|
515
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
495
516
|
});
|
|
496
517
|
|
|
497
518
|
it(`should reject a basic GET multiple operation where the user has no role membership`, async function () {
|
|
@@ -513,7 +534,7 @@ describe('Security Model Role Membership', function () {
|
|
|
513
534
|
}
|
|
514
535
|
}).json();
|
|
515
536
|
},
|
|
516
|
-
{ message: '
|
|
537
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
517
538
|
});
|
|
518
539
|
|
|
519
540
|
|
|
@@ -573,7 +594,7 @@ describe('Security Model Role Membership', function () {
|
|
|
573
594
|
}
|
|
574
595
|
}).json();
|
|
575
596
|
},
|
|
576
|
-
{ message: '
|
|
597
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
577
598
|
});
|
|
578
599
|
|
|
579
600
|
it(`should reject a basic PUT operation on a document where the user has no role membership`, async function () {
|
|
@@ -589,7 +610,7 @@ describe('Security Model Role Membership', function () {
|
|
|
589
610
|
}
|
|
590
611
|
}).json();
|
|
591
612
|
},
|
|
592
|
-
{ message: '
|
|
613
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
593
614
|
});
|
|
594
615
|
|
|
595
616
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
@@ -647,7 +668,7 @@ describe('Security Model Role Membership', function () {
|
|
|
647
668
|
}
|
|
648
669
|
}).json();
|
|
649
670
|
},
|
|
650
|
-
{ message: '
|
|
671
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
651
672
|
});
|
|
652
673
|
|
|
653
674
|
it(`should reject a basic POST operation on a document where the user has no role membership`, async function () {
|
|
@@ -665,7 +686,7 @@ describe('Security Model Role Membership', function () {
|
|
|
665
686
|
}
|
|
666
687
|
}).json();
|
|
667
688
|
},
|
|
668
|
-
{ message: '
|
|
689
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
669
690
|
});
|
|
670
691
|
|
|
671
692
|
|
|
@@ -713,7 +734,7 @@ describe('Security Model Role Membership', function () {
|
|
|
713
734
|
}
|
|
714
735
|
}).json();
|
|
715
736
|
},
|
|
716
|
-
{ message: '
|
|
737
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
717
738
|
});
|
|
718
739
|
|
|
719
740
|
it(`should reject a basic DELETE operation on a document where the user has no role membership`, async function () {
|
|
@@ -726,6 +747,6 @@ describe('Security Model Role Membership', function () {
|
|
|
726
747
|
}
|
|
727
748
|
}).json();
|
|
728
749
|
},
|
|
729
|
-
{ message: '
|
|
750
|
+
{ message: 'Response code 403 (Forbidden)' })
|
|
730
751
|
});
|
|
731
752
|
});
|
|
@@ -379,9 +379,9 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
379
379
|
)
|
|
380
380
|
});
|
|
381
381
|
|
|
382
|
-
it(`should be able to generate a plain object containing a
|
|
382
|
+
it(`should be able to generate a plain object containing a record`, async function () {
|
|
383
383
|
const validate_test_collection = z.object({
|
|
384
|
-
test: z.
|
|
384
|
+
test: z.record(z.string(), z.string())
|
|
385
385
|
});
|
|
386
386
|
|
|
387
387
|
let test_collection = new F_Collection('test_collection', validate_test_collection);
|
|
@@ -400,9 +400,9 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
400
400
|
});
|
|
401
401
|
|
|
402
402
|
|
|
403
|
-
it(`should be able to generate a plain object containing an object
|
|
403
|
+
it(`should be able to generate a plain object containing an object record`, async function () {
|
|
404
404
|
const validate_test_collection = z.object({
|
|
405
|
-
test: z.
|
|
405
|
+
test: z.record(z.string(), z.object({
|
|
406
406
|
test_2: z.string()
|
|
407
407
|
}))
|
|
408
408
|
});
|
|
@@ -422,9 +422,9 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
422
422
|
)
|
|
423
423
|
});
|
|
424
424
|
|
|
425
|
-
it(`should be able to generate a plain object containing an array
|
|
425
|
+
it(`should be able to generate a plain object containing an array record`, async function () {
|
|
426
426
|
const validate_test_collection = z.object({
|
|
427
|
-
test: z.
|
|
427
|
+
test: z.record(z.string(), z.array(z.string()))
|
|
428
428
|
});
|
|
429
429
|
|
|
430
430
|
let test_collection = new F_Collection('test_collection', validate_test_collection);
|
|
@@ -528,9 +528,9 @@
|
|
|
528
528
|
}
|
|
529
529
|
},
|
|
530
530
|
"node_modules/ky": {
|
|
531
|
-
"version": "1.9.
|
|
532
|
-
"resolved": "https://registry.npmjs.org/ky/-/ky-1.9.
|
|
533
|
-
"integrity": "sha512-
|
|
531
|
+
"version": "1.9.1",
|
|
532
|
+
"resolved": "https://registry.npmjs.org/ky/-/ky-1.9.1.tgz",
|
|
533
|
+
"integrity": "sha512-WGzpBn57klhxsqRTEABAqF4tqTtqCuxoTIv9m6nIZtMMFTVcrHp7bRDWblzFIfqkb47+OhTztOgHn6A4xItmqg==",
|
|
534
534
|
"license": "MIT",
|
|
535
535
|
"engines": {
|
|
536
536
|
"node": ">=18"
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { brief_news_category } from "./types/brief_news_category.js";
|
|
2
|
-
import { brief_news_category_query } from "./types/brief_news_category_query.js";
|
|
3
|
-
import { brief_news_category_put } from "./types/brief_news_category_put.js";
|
|
4
|
-
import { brief_news_category_post } from "./types/brief_news_category_post.js";
|
|
5
|
-
export declare class Collection_Brief_News_Category {
|
|
6
|
-
path: string[];
|
|
7
|
-
get_auth: () => Promise<any>;
|
|
8
|
-
constructor(path: string[], get_auth: () => Promise<any>);
|
|
9
|
-
query(query: brief_news_category_query): Promise<brief_news_category[]>;
|
|
10
|
-
post(document: brief_news_category_post): Promise<brief_news_category>;
|
|
11
|
-
document(document_id: string): {
|
|
12
|
-
get(): Promise<brief_news_category>;
|
|
13
|
-
put(update: brief_news_category_put): Promise<brief_news_category>;
|
|
14
|
-
remove(): Promise<brief_news_category>;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import ky from "ky";
|
|
2
|
-
import { encode_search_params } from "./utils/utils.js";
|
|
3
|
-
export class Collection_Brief_News_Category {
|
|
4
|
-
path;
|
|
5
|
-
get_auth;
|
|
6
|
-
constructor(path, get_auth) {
|
|
7
|
-
this.path = path;
|
|
8
|
-
this.get_auth = get_auth;
|
|
9
|
-
}
|
|
10
|
-
async query(query) {
|
|
11
|
-
try {
|
|
12
|
-
let result = await ky.get(this.path.join('/'), {
|
|
13
|
-
headers: {
|
|
14
|
-
authorization: await this.get_auth()
|
|
15
|
-
},
|
|
16
|
-
searchParams: encode_search_params(query)
|
|
17
|
-
}).json();
|
|
18
|
-
return result.data;
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
return Promise.reject(err);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async post(document) {
|
|
25
|
-
try {
|
|
26
|
-
let result = await ky.post(this.path.join('/'), {
|
|
27
|
-
headers: {
|
|
28
|
-
authorization: await this.get_auth()
|
|
29
|
-
},
|
|
30
|
-
json: document
|
|
31
|
-
}).json();
|
|
32
|
-
return result.data;
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
return Promise.reject(err);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
document(document_id) {
|
|
39
|
-
let path = this.path;
|
|
40
|
-
let get_auth = this.get_auth;
|
|
41
|
-
return {
|
|
42
|
-
async get() {
|
|
43
|
-
try {
|
|
44
|
-
let result = await ky.get([...path, document_id].join('/'), {
|
|
45
|
-
headers: {
|
|
46
|
-
authorization: await get_auth()
|
|
47
|
-
},
|
|
48
|
-
}).json();
|
|
49
|
-
return result.data;
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
return Promise.reject(err);
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
async put(update) {
|
|
56
|
-
try {
|
|
57
|
-
let result = await ky.put([...path, document_id].join('/'), {
|
|
58
|
-
headers: {
|
|
59
|
-
authorization: await get_auth()
|
|
60
|
-
},
|
|
61
|
-
json: update
|
|
62
|
-
}).json();
|
|
63
|
-
return result.data;
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
return Promise.reject(err);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
async remove() {
|
|
70
|
-
try {
|
|
71
|
-
let result = await ky.delete([...path, document_id].join('/'), {
|
|
72
|
-
headers: {
|
|
73
|
-
authorization: await get_auth()
|
|
74
|
-
},
|
|
75
|
-
}).json();
|
|
76
|
-
return result.data;
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
return Promise.reject(err);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=Brief_News_Category.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Brief_News_Category.js","sourceRoot":"","sources":["../src/Brief_News_Category.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAA+B,MAAM,kBAAkB,CAAC;AAQrF,MAAM,OAAO,8BAA8B;IACvC,IAAI,CAAU;IACd,QAAQ,CAAoB;IAE5B,YAAY,IAAc,EAAE,QAA4B;QACpD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAGD,KAAK,CAAC,KAAK,CAAC,KAAgC;QACxC,IAAI,CAAC;YACD,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IA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,IAAI,CAAC;gBACvB,CAAC;gBAAC,OAAM,GAAG,EAAC,CAAC;oBACT,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAC9B,CAAC;YACL,CAAC;YAED,KAAK,CAAC,GAAG,CAAC,MAA+B;gBACrC,IAAI,CAAC;oBACD,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;wBACxD,OAAO,EAAE;4BACL,aAAa,EAAE,MAAM,QAAQ,EAAE;yBAClC;wBACD,IAAI,EAAE,MAAM;qBACf,CAAC,CAAC,IAAI,EAAmC,CAAC;oBAC3C,OAAO,MAAM,CAAC,IAAI,CAAC;gBACvB,CAAC;gBAAC,OAAM,GAAG,EAAC,CAAC;oBACT,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAC9B,CAAC;YACL,CAAC;YAED,KAAK,CAAC,MAAM;gBACR,IAAI,CAAC;oBACD,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;wBAC3D,OAAO,EAAE;4BACL,aAAa,EAAE,MAAM,QAAQ,EAAE;yBAClC;qBACJ,CAAC,CAAC,IAAI,EAAmC,CAAC;oBAC3C,OAAO,MAAM,CAAC,IAAI,CAAC;gBACvB,CAAC;gBAAC,OAAM,GAAG,EAAC,CAAC;oBACT,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAC9B,CAAC;YACL,CAAC;SAEJ,CAAA;IACL,CAAC;CACJ"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Collection_Project } from "./Project.js";
|
|
2
|
-
import { Collection_Brief_News_Category } from "./Brief_News_Category.js";
|
|
3
|
-
import { client } from "./types/client.js";
|
|
4
|
-
import { client_query } from "./types/client_query.js";
|
|
5
|
-
import { client_put } from "./types/client_put.js";
|
|
6
|
-
import { client_post } from "./types/client_post.js";
|
|
7
|
-
export declare class Collection_Client {
|
|
8
|
-
path: string[];
|
|
9
|
-
get_auth: () => Promise<any>;
|
|
10
|
-
constructor(path: string[], get_auth: () => Promise<any>);
|
|
11
|
-
query(query: client_query): Promise<client[]>;
|
|
12
|
-
post(document: client_post): Promise<client>;
|
|
13
|
-
document(document_id: string): {
|
|
14
|
-
get(): Promise<client>;
|
|
15
|
-
put(update: client_put): Promise<client>;
|
|
16
|
-
remove(): Promise<client>;
|
|
17
|
-
collection(collection_id: "project" | "brief_news_category"): Collection_Brief_News_Category | Collection_Project;
|
|
18
|
-
};
|
|
19
|
-
}
|
package/test/tmp/dist/Client.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import ky from "ky";
|
|
2
|
-
import { encode_search_params } from "./utils/utils.js";
|
|
3
|
-
import { Collection_Project } from "./Project.js";
|
|
4
|
-
import { Collection_Brief_News_Category } from "./Brief_News_Category.js";
|
|
5
|
-
export class Collection_Client {
|
|
6
|
-
path;
|
|
7
|
-
get_auth;
|
|
8
|
-
constructor(path, get_auth) {
|
|
9
|
-
this.path = path;
|
|
10
|
-
this.get_auth = get_auth;
|
|
11
|
-
}
|
|
12
|
-
async query(query) {
|
|
13
|
-
try {
|
|
14
|
-
let result = await ky.get(this.path.join('/'), {
|
|
15
|
-
headers: {
|
|
16
|
-
authorization: await this.get_auth()
|
|
17
|
-
},
|
|
18
|
-
searchParams: encode_search_params(query)
|
|
19
|
-
}).json();
|
|
20
|
-
return result.data;
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
return Promise.reject(err);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async post(document) {
|
|
27
|
-
try {
|
|
28
|
-
let result = await ky.post(this.path.join('/'), {
|
|
29
|
-
headers: {
|
|
30
|
-
authorization: await this.get_auth()
|
|
31
|
-
},
|
|
32
|
-
json: document
|
|
33
|
-
}).json();
|
|
34
|
-
return result.data;
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
return Promise.reject(err);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
document(document_id) {
|
|
41
|
-
let path = this.path;
|
|
42
|
-
let get_auth = this.get_auth;
|
|
43
|
-
return {
|
|
44
|
-
async get() {
|
|
45
|
-
try {
|
|
46
|
-
let result = await ky.get([...path, document_id].join('/'), {
|
|
47
|
-
headers: {
|
|
48
|
-
authorization: await get_auth()
|
|
49
|
-
},
|
|
50
|
-
}).json();
|
|
51
|
-
return result.data;
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
return Promise.reject(err);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
async put(update) {
|
|
58
|
-
try {
|
|
59
|
-
let result = await ky.put([...path, document_id].join('/'), {
|
|
60
|
-
headers: {
|
|
61
|
-
authorization: await get_auth()
|
|
62
|
-
},
|
|
63
|
-
json: update
|
|
64
|
-
}).json();
|
|
65
|
-
return result.data;
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
return Promise.reject(err);
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
async remove() {
|
|
72
|
-
try {
|
|
73
|
-
let result = await ky.delete([...path, document_id].join('/'), {
|
|
74
|
-
headers: {
|
|
75
|
-
authorization: await get_auth()
|
|
76
|
-
},
|
|
77
|
-
}).json();
|
|
78
|
-
return result.data;
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
return Promise.reject(err);
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
collection(collection_id) {
|
|
85
|
-
switch (collection_id) {
|
|
86
|
-
case "project":
|
|
87
|
-
return new Collection_Project([...path, document_id, "project"], get_auth);
|
|
88
|
-
case "brief_news_category":
|
|
89
|
-
return new Collection_Brief_News_Category([...path, document_id, "brief_news_category"], get_auth);
|
|
90
|
-
default:
|
|
91
|
-
throw new Error(`Api does not have the collection ${collection_id}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=Client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAA+B,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAA;AAOzE,MAAM,OAAO,iBAAiB;IAC1B,IAAI,CAAU;IACd,QAAQ,CAAoB;IAE5B,YAAY,IAAc,EAAE,QAA4B;QACpD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAGD,KAAK,CAAC,KAAK,CAAC,KAAmB;QAC3B,IAAI,CAAC;YACD,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;gBAC3C,OAAO,EAAE;oBACL,aAAa,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE;iBACvC;gBACD,YAAY,EAAE,oBAAoB,CAAC,KAAK,CAAC;aAC5C,CAAC,CAAC,IAAI,EAA+B,CAAC;YACvC,OAAO,MAAM,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAM,GAAG,EAAC,CAAC;YACT,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAC9B,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAqB;QAC5B,IAAI,CAAC;YACD,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CA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IAAI,CAAC;gBACvB,CAAC;gBAAC,OAAM,GAAG,EAAC,CAAC;oBACT,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAC9B,CAAC;YACL,CAAC;YAED,KAAK,CAAC,MAAM;gBACR,IAAI,CAAC;oBACD,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;wBAC3D,OAAO,EAAE;4BACL,aAAa,EAAE,MAAM,QAAQ,EAAE;yBAClC;qBACJ,CAAC,CAAC,IAAI,EAAsB,CAAC;oBAC9B,OAAO,MAAM,CAAC,IAAI,CAAC;gBACvB,CAAC;gBAAC,OAAM,GAAG,EAAC,CAAC;oBACT,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAC9B,CAAC;YACL,CAAC;YAED,UAAU,CAAC,aAAgD;gBACvD,QAAO,aAAa,EAAE,CAAC;oBACnB,KAAK,SAAS;wBACV,OAAO,IAAI,kBAAkB,CAAC,CAAC,GAAG,IAAI,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC;oBAC/E,KAAK,qBAAqB;wBACtB,OAAO,IAAI,8BAA8B,CAAC,CAAC,GAAG,IAAI,EAAE,WAAW,EAAE,qBAAqB,CAAC,EAAE,QAAQ,CAAC,CAAC;oBACvG;wBACI,MAAM,IAAI,KAAK,CAAC,oCAAoC,aAAa,EAAE,CAAC,CAAA;gBAC5E,CAAC;YACL,CAAC;SACJ,CAAA;IACL,CAAC;CACJ"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Collection_Client } from "./Client.js";
|
|
2
|
-
import { institution } from "./types/institution.js";
|
|
3
|
-
import { institution_query } from "./types/institution_query.js";
|
|
4
|
-
import { institution_put } from "./types/institution_put.js";
|
|
5
|
-
import { institution_post } from "./types/institution_post.js";
|
|
6
|
-
export declare class Collection_Institution {
|
|
7
|
-
path: string[];
|
|
8
|
-
get_auth: () => Promise<any>;
|
|
9
|
-
constructor(path: string[], get_auth: () => Promise<any>);
|
|
10
|
-
query(query: institution_query): Promise<institution[]>;
|
|
11
|
-
post(document: institution_post): Promise<institution>;
|
|
12
|
-
document(document_id: string): {
|
|
13
|
-
get(): Promise<institution>;
|
|
14
|
-
put(update: institution_put): Promise<institution>;
|
|
15
|
-
remove(): Promise<institution>;
|
|
16
|
-
collection(collection_id: "client"): Collection_Client;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import ky from "ky";
|
|
2
|
-
import { encode_search_params } from "./utils/utils.js";
|
|
3
|
-
import { Collection_Client } from "./Client.js";
|
|
4
|
-
export class Collection_Institution {
|
|
5
|
-
path;
|
|
6
|
-
get_auth;
|
|
7
|
-
constructor(path, get_auth) {
|
|
8
|
-
this.path = path;
|
|
9
|
-
this.get_auth = get_auth;
|
|
10
|
-
}
|
|
11
|
-
async query(query) {
|
|
12
|
-
try {
|
|
13
|
-
let result = await ky.get(this.path.join('/'), {
|
|
14
|
-
headers: {
|
|
15
|
-
authorization: await this.get_auth()
|
|
16
|
-
},
|
|
17
|
-
searchParams: encode_search_params(query)
|
|
18
|
-
}).json();
|
|
19
|
-
return result.data;
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
return Promise.reject(err);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async post(document) {
|
|
26
|
-
try {
|
|
27
|
-
let result = await ky.post(this.path.join('/'), {
|
|
28
|
-
headers: {
|
|
29
|
-
authorization: await this.get_auth()
|
|
30
|
-
},
|
|
31
|
-
json: document
|
|
32
|
-
}).json();
|
|
33
|
-
return result.data;
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
return Promise.reject(err);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
document(document_id) {
|
|
40
|
-
let path = this.path;
|
|
41
|
-
let get_auth = this.get_auth;
|
|
42
|
-
return {
|
|
43
|
-
async get() {
|
|
44
|
-
try {
|
|
45
|
-
let result = await ky.get([...path, document_id].join('/'), {
|
|
46
|
-
headers: {
|
|
47
|
-
authorization: await get_auth()
|
|
48
|
-
},
|
|
49
|
-
}).json();
|
|
50
|
-
return result.data;
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
return Promise.reject(err);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
async put(update) {
|
|
57
|
-
try {
|
|
58
|
-
let result = await ky.put([...path, document_id].join('/'), {
|
|
59
|
-
headers: {
|
|
60
|
-
authorization: await get_auth()
|
|
61
|
-
},
|
|
62
|
-
json: update
|
|
63
|
-
}).json();
|
|
64
|
-
return result.data;
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
return Promise.reject(err);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
async remove() {
|
|
71
|
-
try {
|
|
72
|
-
let result = await ky.delete([...path, document_id].join('/'), {
|
|
73
|
-
headers: {
|
|
74
|
-
authorization: await get_auth()
|
|
75
|
-
},
|
|
76
|
-
}).json();
|
|
77
|
-
return result.data;
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
return Promise.reject(err);
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
collection(collection_id) {
|
|
84
|
-
switch (collection_id) {
|
|
85
|
-
case "client":
|
|
86
|
-
return new Collection_Client([...path, document_id, "client"], get_auth);
|
|
87
|
-
default:
|
|
88
|
-
throw new Error(`Api does not have the collection ${collection_id}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=Institution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Institution.js","sourceRoot":"","sources":["../src/Institution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC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4BACL,aAAa,EAAE,MAAM,QAAQ,EAAE;yBAClC;qBACJ,CAAC,CAAC,IAAI,EAA2B,CAAC;oBACnC,OAAO,MAAM,CAAC,IAAI,CAAC;gBACvB,CAAC;gBAAC,OAAM,GAAG,EAAC,CAAC;oBACT,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAC9B,CAAC;YACL,CAAC;YAED,UAAU,CAAC,aAAuB;gBAC9B,QAAO,aAAa,EAAE,CAAC;oBACnB,KAAK,QAAQ;wBACT,OAAO,IAAI,iBAAiB,CAAC,CAAC,GAAG,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;oBAC7E;wBACI,MAAM,IAAI,KAAK,CAAC,oCAAoC,aAAa,EAAE,CAAC,CAAA;gBAC5E,CAAC;YACL,CAAC;SACJ,CAAA;IACL,CAAC;CACJ"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { project } from "./types/project.js";
|
|
2
|
-
import { project_query } from "./types/project_query.js";
|
|
3
|
-
import { project_put } from "./types/project_put.js";
|
|
4
|
-
import { project_post } from "./types/project_post.js";
|
|
5
|
-
export declare class Collection_Project {
|
|
6
|
-
path: string[];
|
|
7
|
-
get_auth: () => Promise<any>;
|
|
8
|
-
constructor(path: string[], get_auth: () => Promise<any>);
|
|
9
|
-
query(query: project_query): Promise<project[]>;
|
|
10
|
-
post(document: project_post): Promise<project>;
|
|
11
|
-
document(document_id: string): {
|
|
12
|
-
get(): Promise<project>;
|
|
13
|
-
put(update: project_put): Promise<project>;
|
|
14
|
-
remove(): Promise<project>;
|
|
15
|
-
};
|
|
16
|
-
}
|
package/test/tmp/dist/Project.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import ky from "ky";
|
|
2
|
-
import { encode_search_params } from "./utils/utils.js";
|
|
3
|
-
export class Collection_Project {
|
|
4
|
-
path;
|
|
5
|
-
get_auth;
|
|
6
|
-
constructor(path, get_auth) {
|
|
7
|
-
this.path = path;
|
|
8
|
-
this.get_auth = get_auth;
|
|
9
|
-
}
|
|
10
|
-
async query(query) {
|
|
11
|
-
try {
|
|
12
|
-
let result = await ky.get(this.path.join('/'), {
|
|
13
|
-
headers: {
|
|
14
|
-
authorization: await this.get_auth()
|
|
15
|
-
},
|
|
16
|
-
searchParams: encode_search_params(query)
|
|
17
|
-
}).json();
|
|
18
|
-
return result.data;
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
return Promise.reject(err);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async post(document) {
|
|
25
|
-
try {
|
|
26
|
-
let result = await ky.post(this.path.join('/'), {
|
|
27
|
-
headers: {
|
|
28
|
-
authorization: await this.get_auth()
|
|
29
|
-
},
|
|
30
|
-
json: document
|
|
31
|
-
}).json();
|
|
32
|
-
return result.data;
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
return Promise.reject(err);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
document(document_id) {
|
|
39
|
-
let path = this.path;
|
|
40
|
-
let get_auth = this.get_auth;
|
|
41
|
-
return {
|
|
42
|
-
async get() {
|
|
43
|
-
try {
|
|
44
|
-
let result = await ky.get([...path, document_id].join('/'), {
|
|
45
|
-
headers: {
|
|
46
|
-
authorization: await get_auth()
|
|
47
|
-
},
|
|
48
|
-
}).json();
|
|
49
|
-
return result.data;
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
return Promise.reject(err);
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
async put(update) {
|
|
56
|
-
try {
|
|
57
|
-
let result = await ky.put([...path, document_id].join('/'), {
|
|
58
|
-
headers: {
|
|
59
|
-
authorization: await get_auth()
|
|
60
|
-
},
|
|
61
|
-
json: update
|
|
62
|
-
}).json();
|
|
63
|
-
return result.data;
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
return Promise.reject(err);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
async remove() {
|
|
70
|
-
try {
|
|
71
|
-
let result = await ky.delete([...path, document_id].join('/'), {
|
|
72
|
-
headers: {
|
|
73
|
-
authorization: await get_auth()
|
|
74
|
-
},
|
|
75
|
-
}).json();
|
|
76
|
-
return result.data;
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
return Promise.reject(err);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=Project.js.map
|