@liminalfunctions/framework 1.0.43 → 1.0.44
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/code_generation/templates/collection.mustache +72 -56
- package/dist/code_generation/templates/main.mustache +23 -12
- package/package.json +1 -1
- package/src/code_generation/templates/collection.mustache +72 -56
- package/src/code_generation/templates/main.mustache +23 -12
- package/test/tmp/dist/Brief_News_Category.d.ts +13 -10
- package/test/tmp/dist/Brief_News_Category.js +55 -47
- package/test/tmp/dist/Brief_News_Category.js.map +1 -1
- package/test/tmp/dist/Client.d.ts +15 -11
- package/test/tmp/dist/Client.js +65 -57
- package/test/tmp/dist/Client.js.map +1 -1
- package/test/tmp/dist/Institution.d.ts +14 -11
- package/test/tmp/dist/Institution.js +63 -55
- package/test/tmp/dist/Institution.js.map +1 -1
- package/test/tmp/dist/Project.d.ts +13 -10
- package/test/tmp/dist/Project.js +55 -47
- package/test/tmp/dist/Project.js.map +1 -1
- package/test/tmp/dist/index.d.ts +7 -2
- package/test/tmp/dist/index.js +16 -9
- package/test/tmp/dist/index.js.map +1 -1
- package/test/tmp/src/Brief_News_Category.ts +57 -44
- package/test/tmp/src/Client.ts +69 -54
- package/test/tmp/src/Institution.ts +66 -52
- package/test/tmp/src/Project.ts +57 -44
- package/test/tmp/src/index.ts +19 -10
|
@@ -54,52 +54,65 @@ export class Collection_Brief_News_Category {
|
|
|
54
54
|
let get_auth = this.get_auth;
|
|
55
55
|
let collection_id = this.collection_id;
|
|
56
56
|
let collection_name_plural = this.collection_name_plural;
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
get_auth: get_auth,
|
|
63
|
-
async get(): Promise<brief_news_category>{
|
|
64
|
-
try {
|
|
65
|
-
let result = await ky.get([...path, document_id].join('/'), {
|
|
66
|
-
headers: {
|
|
67
|
-
authorization: await get_auth()
|
|
68
|
-
},
|
|
69
|
-
}).json() as Response<brief_news_category>;
|
|
70
|
-
return result.data;
|
|
71
|
-
} catch(err){
|
|
72
|
-
return Promise.reject(err)
|
|
73
|
-
}
|
|
74
|
-
},
|
|
57
|
+
return new Document(path, collection_id, document_id, collection_name_plural, get_auth);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
async remove(): Promise<brief_news_category>{
|
|
91
|
-
try {
|
|
92
|
-
let result = await ky.delete([...path, document_id].join('/'), {
|
|
93
|
-
headers: {
|
|
94
|
-
authorization: await get_auth()
|
|
95
|
-
},
|
|
96
|
-
}).json() as Response<brief_news_category>;
|
|
97
|
-
return result.data;
|
|
98
|
-
} catch(err){
|
|
99
|
-
return Promise.reject(err)
|
|
100
|
-
}
|
|
101
|
-
},
|
|
63
|
+
class Document {
|
|
64
|
+
path: string[];
|
|
65
|
+
collection_id: string;
|
|
66
|
+
document_id: string;
|
|
67
|
+
collection_name_plural: string;
|
|
68
|
+
get_auth: () => Promise<any>;
|
|
69
|
+
|
|
70
|
+
constructor(path: string[], collection_id: string, document_id: string, collection_name_plural: string, get_auth: () => Promise<any>) {
|
|
71
|
+
this.path = path;
|
|
72
|
+
this.collection_id = collection_id;
|
|
73
|
+
this.document_id = document_id;
|
|
74
|
+
this.collection_name_plural = collection_name_plural;
|
|
75
|
+
this.get_auth = get_auth;
|
|
76
|
+
}
|
|
102
77
|
|
|
78
|
+
async get(): Promise<brief_news_category>{
|
|
79
|
+
try {
|
|
80
|
+
let result = await ky.get([...this.path, this.document_id].join('/'), {
|
|
81
|
+
headers: {
|
|
82
|
+
authorization: await this.get_auth()
|
|
83
|
+
},
|
|
84
|
+
}).json() as Response<brief_news_category>;
|
|
85
|
+
return result.data;
|
|
86
|
+
} catch(err){
|
|
87
|
+
return Promise.reject(err)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async put(update: brief_news_category_put): Promise<brief_news_category>{
|
|
92
|
+
try {
|
|
93
|
+
let result = await ky.put([...this.path, this.document_id].join('/'), {
|
|
94
|
+
headers: {
|
|
95
|
+
authorization: await this.get_auth()
|
|
96
|
+
},
|
|
97
|
+
json: update
|
|
98
|
+
}).json() as Response<brief_news_category>;
|
|
99
|
+
return result.data;
|
|
100
|
+
} catch(err){
|
|
101
|
+
return Promise.reject(err)
|
|
103
102
|
}
|
|
104
103
|
}
|
|
104
|
+
|
|
105
|
+
async remove(): Promise<brief_news_category>{
|
|
106
|
+
try {
|
|
107
|
+
let result = await ky.delete([...this.path, this.document_id].join('/'), {
|
|
108
|
+
headers: {
|
|
109
|
+
authorization: await this.get_auth()
|
|
110
|
+
},
|
|
111
|
+
}).json() as Response<brief_news_category>;
|
|
112
|
+
return result.data;
|
|
113
|
+
} catch(err){
|
|
114
|
+
return Promise.reject(err)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
105
118
|
}
|
package/test/tmp/src/Client.ts
CHANGED
|
@@ -56,62 +56,77 @@ export class Collection_Client {
|
|
|
56
56
|
let get_auth = this.get_auth;
|
|
57
57
|
let collection_id = this.collection_id;
|
|
58
58
|
let collection_name_plural = this.collection_name_plural;
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
59
|
+
return new Document(path, collection_id, document_id, collection_name_plural, get_auth);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class Document {
|
|
66
|
+
path: string[];
|
|
67
|
+
collection_id: string;
|
|
68
|
+
document_id: string;
|
|
69
|
+
collection_name_plural: string;
|
|
70
|
+
get_auth: () => Promise<any>;
|
|
71
|
+
|
|
72
|
+
constructor(path: string[], collection_id: string, document_id: string, collection_name_plural: string, get_auth: () => Promise<any>) {
|
|
73
|
+
this.path = path;
|
|
74
|
+
this.collection_id = collection_id;
|
|
75
|
+
this.document_id = document_id;
|
|
76
|
+
this.collection_name_plural = collection_name_plural;
|
|
77
|
+
this.get_auth = get_auth;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async get(): Promise<client>{
|
|
81
|
+
try {
|
|
82
|
+
let result = await ky.get([...this.path, this.document_id].join('/'), {
|
|
83
|
+
headers: {
|
|
84
|
+
authorization: await this.get_auth()
|
|
85
|
+
},
|
|
86
|
+
}).json() as Response<client>;
|
|
87
|
+
return result.data;
|
|
88
|
+
} catch(err){
|
|
89
|
+
return Promise.reject(err)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
77
92
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
async put(update: client_put): Promise<client>{
|
|
94
|
+
try {
|
|
95
|
+
let result = await ky.put([...this.path, this.document_id].join('/'), {
|
|
96
|
+
headers: {
|
|
97
|
+
authorization: await this.get_auth()
|
|
98
|
+
},
|
|
99
|
+
json: update
|
|
100
|
+
}).json() as Response<client>;
|
|
101
|
+
return result.data;
|
|
102
|
+
} catch(err){
|
|
103
|
+
return Promise.reject(err)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async remove(): Promise<client>{
|
|
108
|
+
try {
|
|
109
|
+
let result = await ky.delete([...this.path, this.document_id].join('/'), {
|
|
110
|
+
headers: {
|
|
111
|
+
authorization: await this.get_auth()
|
|
112
|
+
},
|
|
113
|
+
}).json() as Response<client>;
|
|
114
|
+
return result.data;
|
|
115
|
+
} catch(err){
|
|
116
|
+
return Promise.reject(err)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
104
119
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
collection(collection_id: "project"): Collection_Project;
|
|
121
|
+
collection(collection_id: "brief_news_category"): Collection_Brief_News_Category;
|
|
122
|
+
collection(collection_id: string) {
|
|
123
|
+
switch(collection_id) {
|
|
124
|
+
case "project":
|
|
125
|
+
return new Collection_Project([...this.path, this.document_id, "project"], this.get_auth);
|
|
126
|
+
case "brief_news_category":
|
|
127
|
+
return new Collection_Brief_News_Category([...this.path, this.document_id, "brief_news_category"], this.get_auth);
|
|
128
|
+
default:
|
|
129
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
115
130
|
}
|
|
116
131
|
}
|
|
117
132
|
}
|
|
@@ -55,60 +55,74 @@ export class Collection_Institution {
|
|
|
55
55
|
let get_auth = this.get_auth;
|
|
56
56
|
let collection_id = this.collection_id;
|
|
57
57
|
let collection_name_plural = this.collection_name_plural;
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
return new Document(path, collection_id, document_id, collection_name_plural, get_auth);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class Document {
|
|
65
|
+
path: string[];
|
|
66
|
+
collection_id: string;
|
|
67
|
+
document_id: string;
|
|
68
|
+
collection_name_plural: string;
|
|
69
|
+
get_auth: () => Promise<any>;
|
|
70
|
+
|
|
71
|
+
constructor(path: string[], collection_id: string, document_id: string, collection_name_plural: string, get_auth: () => Promise<any>) {
|
|
72
|
+
this.path = path;
|
|
73
|
+
this.collection_id = collection_id;
|
|
74
|
+
this.document_id = document_id;
|
|
75
|
+
this.collection_name_plural = collection_name_plural;
|
|
76
|
+
this.get_auth = get_auth;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async get(): Promise<institution>{
|
|
80
|
+
try {
|
|
81
|
+
let result = await ky.get([...this.path, this.document_id].join('/'), {
|
|
82
|
+
headers: {
|
|
83
|
+
authorization: await this.get_auth()
|
|
84
|
+
},
|
|
85
|
+
}).json() as Response<institution>;
|
|
86
|
+
return result.data;
|
|
87
|
+
} catch(err){
|
|
88
|
+
return Promise.reject(err)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
76
91
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
async put(update: institution_put): Promise<institution>{
|
|
93
|
+
try {
|
|
94
|
+
let result = await ky.put([...this.path, this.document_id].join('/'), {
|
|
95
|
+
headers: {
|
|
96
|
+
authorization: await this.get_auth()
|
|
97
|
+
},
|
|
98
|
+
json: update
|
|
99
|
+
}).json() as Response<institution>;
|
|
100
|
+
return result.data;
|
|
101
|
+
} catch(err){
|
|
102
|
+
return Promise.reject(err)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async remove(): Promise<institution>{
|
|
107
|
+
try {
|
|
108
|
+
let result = await ky.delete([...this.path, this.document_id].join('/'), {
|
|
109
|
+
headers: {
|
|
110
|
+
authorization: await this.get_auth()
|
|
111
|
+
},
|
|
112
|
+
}).json() as Response<institution>;
|
|
113
|
+
return result.data;
|
|
114
|
+
} catch(err){
|
|
115
|
+
return Promise.reject(err)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
103
118
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
}
|
|
119
|
+
collection(collection_id: "client"): Collection_Client;
|
|
120
|
+
collection(collection_id: string) {
|
|
121
|
+
switch(collection_id) {
|
|
122
|
+
case "client":
|
|
123
|
+
return new Collection_Client([...this.path, this.document_id, "client"], this.get_auth);
|
|
124
|
+
default:
|
|
125
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
112
126
|
}
|
|
113
127
|
}
|
|
114
128
|
}
|
package/test/tmp/src/Project.ts
CHANGED
|
@@ -54,52 +54,65 @@ export class Collection_Project {
|
|
|
54
54
|
let get_auth = this.get_auth;
|
|
55
55
|
let collection_id = this.collection_id;
|
|
56
56
|
let collection_name_plural = this.collection_name_plural;
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
get_auth: get_auth,
|
|
63
|
-
async get(): Promise<project>{
|
|
64
|
-
try {
|
|
65
|
-
let result = await ky.get([...path, document_id].join('/'), {
|
|
66
|
-
headers: {
|
|
67
|
-
authorization: await get_auth()
|
|
68
|
-
},
|
|
69
|
-
}).json() as Response<project>;
|
|
70
|
-
return result.data;
|
|
71
|
-
} catch(err){
|
|
72
|
-
return Promise.reject(err)
|
|
73
|
-
}
|
|
74
|
-
},
|
|
57
|
+
return new Document(path, collection_id, document_id, collection_name_plural, get_auth);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
async remove(): Promise<project>{
|
|
91
|
-
try {
|
|
92
|
-
let result = await ky.delete([...path, document_id].join('/'), {
|
|
93
|
-
headers: {
|
|
94
|
-
authorization: await get_auth()
|
|
95
|
-
},
|
|
96
|
-
}).json() as Response<project>;
|
|
97
|
-
return result.data;
|
|
98
|
-
} catch(err){
|
|
99
|
-
return Promise.reject(err)
|
|
100
|
-
}
|
|
101
|
-
},
|
|
63
|
+
class Document {
|
|
64
|
+
path: string[];
|
|
65
|
+
collection_id: string;
|
|
66
|
+
document_id: string;
|
|
67
|
+
collection_name_plural: string;
|
|
68
|
+
get_auth: () => Promise<any>;
|
|
69
|
+
|
|
70
|
+
constructor(path: string[], collection_id: string, document_id: string, collection_name_plural: string, get_auth: () => Promise<any>) {
|
|
71
|
+
this.path = path;
|
|
72
|
+
this.collection_id = collection_id;
|
|
73
|
+
this.document_id = document_id;
|
|
74
|
+
this.collection_name_plural = collection_name_plural;
|
|
75
|
+
this.get_auth = get_auth;
|
|
76
|
+
}
|
|
102
77
|
|
|
78
|
+
async get(): Promise<project>{
|
|
79
|
+
try {
|
|
80
|
+
let result = await ky.get([...this.path, this.document_id].join('/'), {
|
|
81
|
+
headers: {
|
|
82
|
+
authorization: await this.get_auth()
|
|
83
|
+
},
|
|
84
|
+
}).json() as Response<project>;
|
|
85
|
+
return result.data;
|
|
86
|
+
} catch(err){
|
|
87
|
+
return Promise.reject(err)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async put(update: project_put): Promise<project>{
|
|
92
|
+
try {
|
|
93
|
+
let result = await ky.put([...this.path, this.document_id].join('/'), {
|
|
94
|
+
headers: {
|
|
95
|
+
authorization: await this.get_auth()
|
|
96
|
+
},
|
|
97
|
+
json: update
|
|
98
|
+
}).json() as Response<project>;
|
|
99
|
+
return result.data;
|
|
100
|
+
} catch(err){
|
|
101
|
+
return Promise.reject(err)
|
|
103
102
|
}
|
|
104
103
|
}
|
|
104
|
+
|
|
105
|
+
async remove(): Promise<project>{
|
|
106
|
+
try {
|
|
107
|
+
let result = await ky.delete([...this.path, this.document_id].join('/'), {
|
|
108
|
+
headers: {
|
|
109
|
+
authorization: await this.get_auth()
|
|
110
|
+
},
|
|
111
|
+
}).json() as Response<project>;
|
|
112
|
+
return result.data;
|
|
113
|
+
} catch(err){
|
|
114
|
+
return Promise.reject(err)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
105
118
|
}
|
package/test/tmp/src/index.ts
CHANGED
|
@@ -5,16 +5,25 @@ import { Collection_Institution } from "./Institution.js"
|
|
|
5
5
|
|
|
6
6
|
|
|
7
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
|
-
}
|
|
8
|
+
return new Api(base_url, get_auth)
|
|
18
9
|
}
|
|
19
10
|
|
|
11
|
+
class Api {
|
|
12
|
+
base_url: string;
|
|
13
|
+
get_auth: () => Promise<any>
|
|
14
|
+
|
|
15
|
+
constructor(base_url: string, get_auth: () => Promise<any>) {
|
|
16
|
+
this.base_url = base_url;
|
|
17
|
+
this.get_auth = get_auth
|
|
18
|
+
}
|
|
20
19
|
|
|
20
|
+
collection(collection_id: "institution"): Collection_Institution;
|
|
21
|
+
collection(collection_id: string) {
|
|
22
|
+
switch(collection_id) {
|
|
23
|
+
case "institution":
|
|
24
|
+
return new Collection_Institution([this.base_url, "institution"], this.get_auth);
|
|
25
|
+
default:
|
|
26
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|