@liminalfunctions/framework 1.0.0
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/.mocharc.json +5 -0
- package/dist/F_Client_Collection_Registry.d.ts +18 -0
- package/dist/F_Client_Collection_Registry.js +36 -0
- package/dist/F_Client_Collection_Registry.js.map +1 -0
- package/dist/F_Collection.d.ts +21 -0
- package/dist/F_Collection.js +36 -0
- package/dist/F_Collection.js.map +1 -0
- package/dist/F_Collection_Registry.d.ts +11 -0
- package/dist/F_Collection_Registry.js +18 -0
- package/dist/F_Collection_Registry.js.map +1 -0
- package/dist/F_Compile.d.ts +4 -0
- package/dist/F_Compile.js +298 -0
- package/dist/F_Compile.js.map +1 -0
- package/dist/F_Security_Models/F_SM_Open_Access.d.ts +11 -0
- package/dist/F_Security_Models/F_SM_Open_Access.js +14 -0
- package/dist/F_Security_Models/F_SM_Open_Access.js.map +1 -0
- package/dist/F_Security_Models/F_SM_Ownership.d.ts +12 -0
- package/dist/F_Security_Models/F_SM_Ownership.js +46 -0
- package/dist/F_Security_Models/F_SM_Ownership.js.map +1 -0
- package/dist/F_Security_Models/F_SM_Role_Membership.d.ts +19 -0
- package/dist/F_Security_Models/F_SM_Role_Membership.js +73 -0
- package/dist/F_Security_Models/F_SM_Role_Membership.js.map +1 -0
- package/dist/F_Security_Models/F_Security_Model.d.ts +41 -0
- package/dist/F_Security_Models/F_Security_Model.js +29 -0
- package/dist/F_Security_Models/F_Security_Model.js.map +1 -0
- package/dist/code_generation/generate_client_library.d.ts +4 -0
- package/dist/code_generation/generate_client_library.js +158 -0
- package/dist/code_generation/generate_client_library.js.map +1 -0
- package/dist/code_generation/templates/.gitignore.mustache +383 -0
- package/dist/code_generation/templates/collection.mustache +106 -0
- package/dist/code_generation/templates/main.mustache +24 -0
- package/dist/code_generation/templates/package.json.mustache +18 -0
- package/dist/code_generation/templates/tsconfig.json.mustache +14 -0
- package/dist/code_generation/templates/types.mustache +4 -0
- package/dist/code_generation/templates/utils.ts.mustache +17 -0
- package/dist/code_generation/utils/tab_indent.d.ts +1 -0
- package/dist/code_generation/utils/tab_indent.js +4 -0
- package/dist/code_generation/utils/tab_indent.js.map +1 -0
- package/dist/code_generation/utils/type_from_zod.d.ts +2 -0
- package/dist/code_generation/utils/type_from_zod.js +102 -0
- package/dist/code_generation/utils/type_from_zod.js.map +1 -0
- package/dist/utils/cache.d.ts +13 -0
- package/dist/utils/cache.js +101 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/mongoose_from_zod.d.ts +13 -0
- package/dist/utils/mongoose_from_zod.js +164 -0
- package/dist/utils/mongoose_from_zod.js.map +1 -0
- package/dist/utils/pretty_print_zod.d.ts +2 -0
- package/dist/utils/pretty_print_zod.js +63 -0
- package/dist/utils/pretty_print_zod.js.map +1 -0
- package/dist/utils/query_object_to_mongodb_query.d.ts +3 -0
- package/dist/utils/query_object_to_mongodb_query.js +61 -0
- package/dist/utils/query_object_to_mongodb_query.js.map +1 -0
- package/dist/utils/query_validator_from_zod.d.ts +6 -0
- package/dist/utils/query_validator_from_zod.js +216 -0
- package/dist/utils/query_validator_from_zod.js.map +1 -0
- package/package.json +36 -0
- package/src/F_Collection.ts +50 -0
- package/src/F_Collection_Registry.ts +29 -0
- package/src/F_Compile.ts +368 -0
- package/src/F_Security_Models/F_SM_Open_Access.ts +21 -0
- package/src/F_Security_Models/F_SM_Ownership.ts +72 -0
- package/src/F_Security_Models/F_SM_Role_Membership.ts +87 -0
- package/src/F_Security_Models/F_Security_Model.ts +85 -0
- package/src/code_generation/generate_client_library.ts +197 -0
- package/src/code_generation/templates/.gitignore.mustache +383 -0
- package/src/code_generation/templates/collection.mustache +106 -0
- package/src/code_generation/templates/main.mustache +24 -0
- package/src/code_generation/templates/package.json.mustache +18 -0
- package/src/code_generation/templates/tsconfig.json.mustache +14 -0
- package/src/code_generation/templates/types.mustache +4 -0
- package/src/code_generation/templates/utils.ts.mustache +17 -0
- package/src/code_generation/utils/tab_indent.ts +3 -0
- package/src/code_generation/utils/type_from_zod.ts +140 -0
- package/src/utils/cache.ts +149 -0
- package/src/utils/mongoose_from_zod.ts +191 -0
- package/src/utils/pretty_print_zod.ts +75 -0
- package/src/utils/query_object_to_mongodb_query.ts +73 -0
- package/src/utils/query_validator_from_zod.ts +246 -0
- package/test/0_0_mongoose_from_zod.test.ts +260 -0
- package/test/0_1_query_validator_from_zod.test.ts +518 -0
- package/test/0_2_query_validator_to_mongodb_query.test.ts +365 -0
- package/test/0_3_cache.test.ts +204 -0
- package/test/1_0_basic_server.test.ts +530 -0
- package/test/1_1_security_ownership.test.ts +328 -0
- package/test/1_2_role_membership.test.ts +731 -0
- package/test/2_0_client_library_basic_type_generation.test.ts +444 -0
- package/test/2_0_client_library_query_type_generation.test.ts +352 -0
- package/test/2_1_client_library_generation.test.ts +255 -0
- package/test/tmp/dist/Brief_News_Category.d.ts +16 -0
- package/test/tmp/dist/Brief_News_Category.js +85 -0
- package/test/tmp/dist/Brief_News_Category.js.map +1 -0
- package/test/tmp/dist/Client.d.ts +19 -0
- package/test/tmp/dist/Client.js +97 -0
- package/test/tmp/dist/Client.js.map +1 -0
- package/test/tmp/dist/Institution.d.ts +18 -0
- package/test/tmp/dist/Institution.js +94 -0
- package/test/tmp/dist/Institution.js.map +1 -0
- package/test/tmp/dist/Project.d.ts +16 -0
- package/test/tmp/dist/Project.js +85 -0
- package/test/tmp/dist/Project.js.map +1 -0
- package/test/tmp/dist/index.d.ts +4 -0
- package/test/tmp/dist/index.js +14 -0
- package/test/tmp/dist/index.js.map +1 -0
- package/test/tmp/dist/types/brief_news_category.d.ts +7 -0
- package/test/tmp/dist/types/brief_news_category.js +2 -0
- package/test/tmp/dist/types/brief_news_category.js.map +1 -0
- package/test/tmp/dist/types/brief_news_category_post.d.ts +7 -0
- package/test/tmp/dist/types/brief_news_category_post.js +2 -0
- package/test/tmp/dist/types/brief_news_category_post.js.map +1 -0
- package/test/tmp/dist/types/brief_news_category_put.d.ts +7 -0
- package/test/tmp/dist/types/brief_news_category_put.js +2 -0
- package/test/tmp/dist/types/brief_news_category_put.js.map +1 -0
- package/test/tmp/dist/types/brief_news_category_query.d.ts +26 -0
- package/test/tmp/dist/types/brief_news_category_query.js +2 -0
- package/test/tmp/dist/types/brief_news_category_query.js.map +1 -0
- package/test/tmp/dist/types/client.d.ts +5 -0
- package/test/tmp/dist/types/client.js +2 -0
- package/test/tmp/dist/types/client.js.map +1 -0
- package/test/tmp/dist/types/client_post.d.ts +5 -0
- package/test/tmp/dist/types/client_post.js +2 -0
- package/test/tmp/dist/types/client_post.js.map +1 -0
- package/test/tmp/dist/types/client_put.d.ts +5 -0
- package/test/tmp/dist/types/client_put.js +2 -0
- package/test/tmp/dist/types/client_put.js.map +1 -0
- package/test/tmp/dist/types/client_query.d.ts +18 -0
- package/test/tmp/dist/types/client_query.js +2 -0
- package/test/tmp/dist/types/client_query.js.map +1 -0
- package/test/tmp/dist/types/institution.d.ts +4 -0
- package/test/tmp/dist/types/institution.js +2 -0
- package/test/tmp/dist/types/institution.js.map +1 -0
- package/test/tmp/dist/types/institution_post.d.ts +4 -0
- package/test/tmp/dist/types/institution_post.js +2 -0
- package/test/tmp/dist/types/institution_post.js.map +1 -0
- package/test/tmp/dist/types/institution_put.d.ts +4 -0
- package/test/tmp/dist/types/institution_put.js +2 -0
- package/test/tmp/dist/types/institution_put.js.map +1 -0
- package/test/tmp/dist/types/institution_query.d.ts +14 -0
- package/test/tmp/dist/types/institution_query.js +2 -0
- package/test/tmp/dist/types/institution_query.js.map +1 -0
- package/test/tmp/dist/types/project.d.ts +7 -0
- package/test/tmp/dist/types/project.js +2 -0
- package/test/tmp/dist/types/project.js.map +1 -0
- package/test/tmp/dist/types/project_post.d.ts +7 -0
- package/test/tmp/dist/types/project_post.js +2 -0
- package/test/tmp/dist/types/project_post.js.map +1 -0
- package/test/tmp/dist/types/project_put.d.ts +7 -0
- package/test/tmp/dist/types/project_put.js +2 -0
- package/test/tmp/dist/types/project_put.js.map +1 -0
- package/test/tmp/dist/types/project_query.d.ts +27 -0
- package/test/tmp/dist/types/project_query.js +2 -0
- package/test/tmp/dist/types/project_query.js.map +1 -0
- package/test/tmp/dist/utils/utils.d.ts +11 -0
- package/test/tmp/dist/utils/utils.js +13 -0
- package/test/tmp/dist/utils/utils.js.map +1 -0
- package/test/tmp/package-lock.json +573 -0
- package/test/tmp/package.json +18 -0
- package/test/tmp/src/Brief_News_Category.ts +94 -0
- package/test/tmp/src/Client.ts +106 -0
- package/test/tmp/src/Institution.ts +103 -0
- package/test/tmp/src/Project.ts +94 -0
- package/test/tmp/src/index.ts +20 -0
- package/test/tmp/src/types/brief_news_category.ts +7 -0
- package/test/tmp/src/types/brief_news_category_post.ts +7 -0
- package/test/tmp/src/types/brief_news_category_put.ts +7 -0
- package/test/tmp/src/types/brief_news_category_query.ts +26 -0
- package/test/tmp/src/types/client.ts +5 -0
- package/test/tmp/src/types/client_post.ts +5 -0
- package/test/tmp/src/types/client_put.ts +5 -0
- package/test/tmp/src/types/client_query.ts +18 -0
- package/test/tmp/src/types/institution.ts +4 -0
- package/test/tmp/src/types/institution_post.ts +4 -0
- package/test/tmp/src/types/institution_put.ts +4 -0
- package/test/tmp/src/types/institution_query.ts +14 -0
- package/test/tmp/src/types/project.ts +7 -0
- package/test/tmp/src/types/project_post.ts +7 -0
- package/test/tmp/src/types/project_put.ts +7 -0
- package/test/tmp/src/types/project_query.ts +27 -0
- package/test/tmp/src/utils/utils.ts +17 -0
- package/test/tmp/tsconfig.json +14 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import ky from "ky";
|
|
2
|
+
import { encode_search_params, Response, Response_Multiple } from "./utils/utils.js";
|
|
3
|
+
|
|
4
|
+
import { Collection_Project } from "./Project.js"
|
|
5
|
+
import { Collection_Brief_News_Category } from "./Brief_News_Category.js"
|
|
6
|
+
|
|
7
|
+
import { client } from "./types/client.js";
|
|
8
|
+
import { client_query } from "./types/client_query.js";
|
|
9
|
+
import { client_put } from "./types/client_put.js";
|
|
10
|
+
import { client_post } from "./types/client_post.js";
|
|
11
|
+
|
|
12
|
+
export class Collection_Client {
|
|
13
|
+
path: string[]
|
|
14
|
+
get_auth: () => Promise<any>
|
|
15
|
+
|
|
16
|
+
constructor(path: string[], get_auth: () => Promise<any>) {
|
|
17
|
+
this.path = path;
|
|
18
|
+
this.get_auth = get_auth;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
async query(query: client_query): Promise<client[]>{
|
|
23
|
+
try {
|
|
24
|
+
let result = await ky.get(this.path.join('/'), {
|
|
25
|
+
headers: {
|
|
26
|
+
authorization: await this.get_auth()
|
|
27
|
+
},
|
|
28
|
+
searchParams: encode_search_params(query)
|
|
29
|
+
}).json() as Response_Multiple<client>;
|
|
30
|
+
return result.data;
|
|
31
|
+
} catch(err){
|
|
32
|
+
return Promise.reject(err)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async post(document: client_post): Promise<client>{
|
|
37
|
+
try {
|
|
38
|
+
let result = await ky.post(this.path.join('/'), {
|
|
39
|
+
headers: {
|
|
40
|
+
authorization: await this.get_auth()
|
|
41
|
+
},
|
|
42
|
+
json: document
|
|
43
|
+
}).json() as Response<client>;
|
|
44
|
+
return result.data;
|
|
45
|
+
} catch(err){
|
|
46
|
+
return Promise.reject(err)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
document(document_id: string) {
|
|
51
|
+
let path = this.path;
|
|
52
|
+
let get_auth = this.get_auth;
|
|
53
|
+
return {
|
|
54
|
+
async get(): Promise<client>{
|
|
55
|
+
try {
|
|
56
|
+
let result = await ky.get([...path, document_id].join('/'), {
|
|
57
|
+
headers: {
|
|
58
|
+
authorization: await get_auth()
|
|
59
|
+
},
|
|
60
|
+
}).json() as Response<client>;
|
|
61
|
+
return result.data;
|
|
62
|
+
} catch(err){
|
|
63
|
+
return Promise.reject(err)
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
async put(update: client_put): Promise<client>{
|
|
68
|
+
try {
|
|
69
|
+
let result = await ky.put([...path, document_id].join('/'), {
|
|
70
|
+
headers: {
|
|
71
|
+
authorization: await get_auth()
|
|
72
|
+
},
|
|
73
|
+
json: update
|
|
74
|
+
}).json() as Response<client>;
|
|
75
|
+
return result.data;
|
|
76
|
+
} catch(err){
|
|
77
|
+
return Promise.reject(err)
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
async remove(): Promise<client>{
|
|
82
|
+
try {
|
|
83
|
+
let result = await ky.delete([...path, document_id].join('/'), {
|
|
84
|
+
headers: {
|
|
85
|
+
authorization: await get_auth()
|
|
86
|
+
},
|
|
87
|
+
}).json() as Response<client>;
|
|
88
|
+
return result.data;
|
|
89
|
+
} catch(err){
|
|
90
|
+
return Promise.reject(err)
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
collection(collection_id: "project" | "brief_news_category") {
|
|
95
|
+
switch(collection_id) {
|
|
96
|
+
case "project":
|
|
97
|
+
return new Collection_Project([...path, document_id, "project"], get_auth);
|
|
98
|
+
case "brief_news_category":
|
|
99
|
+
return new Collection_Brief_News_Category([...path, document_id, "brief_news_category"], get_auth);
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import ky from "ky";
|
|
2
|
+
import { encode_search_params, Response, Response_Multiple } from "./utils/utils.js";
|
|
3
|
+
|
|
4
|
+
import { Collection_Client } from "./Client.js"
|
|
5
|
+
|
|
6
|
+
import { institution } from "./types/institution.js";
|
|
7
|
+
import { institution_query } from "./types/institution_query.js";
|
|
8
|
+
import { institution_put } from "./types/institution_put.js";
|
|
9
|
+
import { institution_post } from "./types/institution_post.js";
|
|
10
|
+
|
|
11
|
+
export class Collection_Institution {
|
|
12
|
+
path: string[]
|
|
13
|
+
get_auth: () => Promise<any>
|
|
14
|
+
|
|
15
|
+
constructor(path: string[], get_auth: () => Promise<any>) {
|
|
16
|
+
this.path = path;
|
|
17
|
+
this.get_auth = get_auth;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
async query(query: institution_query): Promise<institution[]>{
|
|
22
|
+
try {
|
|
23
|
+
let result = await ky.get(this.path.join('/'), {
|
|
24
|
+
headers: {
|
|
25
|
+
authorization: await this.get_auth()
|
|
26
|
+
},
|
|
27
|
+
searchParams: encode_search_params(query)
|
|
28
|
+
}).json() as Response_Multiple<institution>;
|
|
29
|
+
return result.data;
|
|
30
|
+
} catch(err){
|
|
31
|
+
return Promise.reject(err)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async post(document: institution_post): Promise<institution>{
|
|
36
|
+
try {
|
|
37
|
+
let result = await ky.post(this.path.join('/'), {
|
|
38
|
+
headers: {
|
|
39
|
+
authorization: await this.get_auth()
|
|
40
|
+
},
|
|
41
|
+
json: document
|
|
42
|
+
}).json() as Response<institution>;
|
|
43
|
+
return result.data;
|
|
44
|
+
} catch(err){
|
|
45
|
+
return Promise.reject(err)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
document(document_id: string) {
|
|
50
|
+
let path = this.path;
|
|
51
|
+
let get_auth = this.get_auth;
|
|
52
|
+
return {
|
|
53
|
+
async get(): Promise<institution>{
|
|
54
|
+
try {
|
|
55
|
+
let result = await ky.get([...path, document_id].join('/'), {
|
|
56
|
+
headers: {
|
|
57
|
+
authorization: await get_auth()
|
|
58
|
+
},
|
|
59
|
+
}).json() as Response<institution>;
|
|
60
|
+
return result.data;
|
|
61
|
+
} catch(err){
|
|
62
|
+
return Promise.reject(err)
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
async put(update: institution_put): Promise<institution>{
|
|
67
|
+
try {
|
|
68
|
+
let result = await ky.put([...path, document_id].join('/'), {
|
|
69
|
+
headers: {
|
|
70
|
+
authorization: await get_auth()
|
|
71
|
+
},
|
|
72
|
+
json: update
|
|
73
|
+
}).json() as Response<institution>;
|
|
74
|
+
return result.data;
|
|
75
|
+
} catch(err){
|
|
76
|
+
return Promise.reject(err)
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
async remove(): Promise<institution>{
|
|
81
|
+
try {
|
|
82
|
+
let result = await ky.delete([...path, document_id].join('/'), {
|
|
83
|
+
headers: {
|
|
84
|
+
authorization: await get_auth()
|
|
85
|
+
},
|
|
86
|
+
}).json() as Response<institution>;
|
|
87
|
+
return result.data;
|
|
88
|
+
} catch(err){
|
|
89
|
+
return Promise.reject(err)
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
collection(collection_id: "client") {
|
|
94
|
+
switch(collection_id) {
|
|
95
|
+
case "client":
|
|
96
|
+
return new Collection_Client([...path, document_id, "client"], get_auth);
|
|
97
|
+
default:
|
|
98
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import ky from "ky";
|
|
2
|
+
import { encode_search_params, Response, Response_Multiple } from "./utils/utils.js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import { project } from "./types/project.js";
|
|
6
|
+
import { project_query } from "./types/project_query.js";
|
|
7
|
+
import { project_put } from "./types/project_put.js";
|
|
8
|
+
import { project_post } from "./types/project_post.js";
|
|
9
|
+
|
|
10
|
+
export class Collection_Project {
|
|
11
|
+
path: string[]
|
|
12
|
+
get_auth: () => Promise<any>
|
|
13
|
+
|
|
14
|
+
constructor(path: string[], get_auth: () => Promise<any>) {
|
|
15
|
+
this.path = path;
|
|
16
|
+
this.get_auth = get_auth;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
async query(query: project_query): Promise<project[]>{
|
|
21
|
+
try {
|
|
22
|
+
let result = await ky.get(this.path.join('/'), {
|
|
23
|
+
headers: {
|
|
24
|
+
authorization: await this.get_auth()
|
|
25
|
+
},
|
|
26
|
+
searchParams: encode_search_params(query)
|
|
27
|
+
}).json() as Response_Multiple<project>;
|
|
28
|
+
return result.data;
|
|
29
|
+
} catch(err){
|
|
30
|
+
return Promise.reject(err)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async post(document: project_post): Promise<project>{
|
|
35
|
+
try {
|
|
36
|
+
let result = await ky.post(this.path.join('/'), {
|
|
37
|
+
headers: {
|
|
38
|
+
authorization: await this.get_auth()
|
|
39
|
+
},
|
|
40
|
+
json: document
|
|
41
|
+
}).json() as Response<project>;
|
|
42
|
+
return result.data;
|
|
43
|
+
} catch(err){
|
|
44
|
+
return Promise.reject(err)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
document(document_id: string) {
|
|
49
|
+
let path = this.path;
|
|
50
|
+
let get_auth = this.get_auth;
|
|
51
|
+
return {
|
|
52
|
+
async get(): Promise<project>{
|
|
53
|
+
try {
|
|
54
|
+
let result = await ky.get([...path, document_id].join('/'), {
|
|
55
|
+
headers: {
|
|
56
|
+
authorization: await get_auth()
|
|
57
|
+
},
|
|
58
|
+
}).json() as Response<project>;
|
|
59
|
+
return result.data;
|
|
60
|
+
} catch(err){
|
|
61
|
+
return Promise.reject(err)
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
async put(update: project_put): Promise<project>{
|
|
66
|
+
try {
|
|
67
|
+
let result = await ky.put([...path, document_id].join('/'), {
|
|
68
|
+
headers: {
|
|
69
|
+
authorization: await get_auth()
|
|
70
|
+
},
|
|
71
|
+
json: update
|
|
72
|
+
}).json() as Response<project>;
|
|
73
|
+
return result.data;
|
|
74
|
+
} catch(err){
|
|
75
|
+
return Promise.reject(err)
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
async remove(): Promise<project>{
|
|
80
|
+
try {
|
|
81
|
+
let result = await ky.delete([...path, document_id].join('/'), {
|
|
82
|
+
headers: {
|
|
83
|
+
authorization: await get_auth()
|
|
84
|
+
},
|
|
85
|
+
}).json() as Response<project>;
|
|
86
|
+
return result.data;
|
|
87
|
+
} catch(err){
|
|
88
|
+
return Promise.reject(err)
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import ky from 'ky';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { Collection_Institution } from "./Institution.js"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export function api(base_url: string, get_auth: () => Promise<any>) {
|
|
8
|
+
return {
|
|
9
|
+
collection(collection_id: "institution") {
|
|
10
|
+
switch(collection_id) {
|
|
11
|
+
case "institution":
|
|
12
|
+
return new Collection_Institution([base_url, "institution"], get_auth);
|
|
13
|
+
default:
|
|
14
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type brief_news_category_query = {
|
|
2
|
+
"limit"?: number
|
|
3
|
+
"cursor"?: string
|
|
4
|
+
"sort_order"?: ("ascending" | "descending")
|
|
5
|
+
"_id"?: string
|
|
6
|
+
"_id_gt"?: string
|
|
7
|
+
"_id_lt"?: string
|
|
8
|
+
"_id_in"?: string[]
|
|
9
|
+
"name"?: string
|
|
10
|
+
"name_gt"?: string
|
|
11
|
+
"name_lt"?: string
|
|
12
|
+
"name_in"?: string[]
|
|
13
|
+
"slug"?: string
|
|
14
|
+
"slug_gt"?: string
|
|
15
|
+
"slug_lt"?: string
|
|
16
|
+
"slug_in"?: string[]
|
|
17
|
+
"institution_id"?: string
|
|
18
|
+
"institution_id_gt"?: string
|
|
19
|
+
"institution_id_lt"?: string
|
|
20
|
+
"institution_id_in"?: string[]
|
|
21
|
+
"client_id"?: string
|
|
22
|
+
"client_id_gt"?: string
|
|
23
|
+
"client_id_lt"?: string
|
|
24
|
+
"client_id_in"?: string[]
|
|
25
|
+
"sort"?: ("_id" | "name" | "slug" | "institution_id" | "client_id")
|
|
26
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type client_query = {
|
|
2
|
+
"limit"?: number
|
|
3
|
+
"cursor"?: string
|
|
4
|
+
"sort_order"?: ("ascending" | "descending")
|
|
5
|
+
"_id"?: string
|
|
6
|
+
"_id_gt"?: string
|
|
7
|
+
"_id_lt"?: string
|
|
8
|
+
"_id_in"?: string[]
|
|
9
|
+
"name"?: string
|
|
10
|
+
"name_gt"?: string
|
|
11
|
+
"name_lt"?: string
|
|
12
|
+
"name_in"?: string[]
|
|
13
|
+
"institution_id"?: string
|
|
14
|
+
"institution_id_gt"?: string
|
|
15
|
+
"institution_id_lt"?: string
|
|
16
|
+
"institution_id_in"?: string[]
|
|
17
|
+
"sort"?: ("_id" | "name" | "institution_id")
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type institution_query = {
|
|
2
|
+
"limit"?: number
|
|
3
|
+
"cursor"?: string
|
|
4
|
+
"sort_order"?: ("ascending" | "descending")
|
|
5
|
+
"_id"?: string
|
|
6
|
+
"_id_gt"?: string
|
|
7
|
+
"_id_lt"?: string
|
|
8
|
+
"_id_in"?: string[]
|
|
9
|
+
"name"?: string
|
|
10
|
+
"name_gt"?: string
|
|
11
|
+
"name_lt"?: string
|
|
12
|
+
"name_in"?: string[]
|
|
13
|
+
"sort"?: ("_id" | "name")
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type project_query = {
|
|
2
|
+
"limit"?: number
|
|
3
|
+
"cursor"?: string
|
|
4
|
+
"sort_order"?: ("ascending" | "descending")
|
|
5
|
+
"_id"?: string
|
|
6
|
+
"_id_gt"?: string
|
|
7
|
+
"_id_lt"?: string
|
|
8
|
+
"_id_in"?: string[]
|
|
9
|
+
"name"?: string
|
|
10
|
+
"name_gt"?: string
|
|
11
|
+
"name_lt"?: string
|
|
12
|
+
"name_in"?: string[]
|
|
13
|
+
"institution_id"?: string
|
|
14
|
+
"institution_id_gt"?: string
|
|
15
|
+
"institution_id_lt"?: string
|
|
16
|
+
"institution_id_in"?: string[]
|
|
17
|
+
"client_id"?: string
|
|
18
|
+
"client_id_gt"?: string
|
|
19
|
+
"client_id_lt"?: string
|
|
20
|
+
"client_id_in"?: string[]
|
|
21
|
+
"project_number"?: number
|
|
22
|
+
"project_number_gt"?: number
|
|
23
|
+
"project_number_gte"?: number
|
|
24
|
+
"project_number_lt"?: number
|
|
25
|
+
"project_number_lte"?: number
|
|
26
|
+
"sort"?: ("_id" | "name" | "institution_id" | "client_id" | "project_number")
|
|
27
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// this is copied directly to ./utils/utils.ts
|
|
2
|
+
|
|
3
|
+
export function encode_search_params(params: {[key: string]: string | number | boolean | string[]}): {[key: string]: string | number | boolean }{
|
|
4
|
+
let retval: {[key: string]: string | number | boolean } = {}
|
|
5
|
+
for(let [key, value] of Object.entries(params)){
|
|
6
|
+
if(Array.isArray(value)){
|
|
7
|
+
retval[key] = value.join(',')
|
|
8
|
+
} else {
|
|
9
|
+
retval[key] = value;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return retval;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type Response<Q> = { data: Q }
|
|
17
|
+
export type Response_Multiple<Q> = { data: Q[] }
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "node16",
|
|
4
|
+
"noImplicitAny": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"preserveConstEnums": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
//"declarationMap": true//check this
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*"],
|
|
13
|
+
"exclude": []
|
|
14
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "node16",
|
|
4
|
+
"noImplicitAny": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"preserveConstEnums": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
//"declarationMap": true//check this
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*", "test/0_mongoose_from_zod.test.js"],
|
|
13
|
+
"exclude": []
|
|
14
|
+
}
|