@liminalfunctions/framework 1.0.61 → 1.0.63
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/generate_client_library.js +1 -0
- package/dist/code_generation/generate_client_library.js.map +1 -1
- package/dist/code_generation/templates/collection.mustache +8 -36
- package/dist/code_generation/templates/main.mustache +1 -1
- package/dist/code_generation/templates/root_types.ts.mustache +69 -0
- package/dist/code_generation/utils/type_from_zod.js +7 -1
- package/dist/code_generation/utils/type_from_zod.js.map +1 -1
- package/package.json +1 -1
- package/src/code_generation/generate_client_library.ts +1 -0
- package/src/code_generation/templates/collection.mustache +8 -36
- package/src/code_generation/templates/main.mustache +1 -1
- package/src/code_generation/templates/root_types.ts.mustache +69 -0
- package/src/code_generation/utils/type_from_zod.ts +10 -1
- package/test/2_0_client_library_basic_type_generation.test.ts +22 -0
- package/test/2_1_client_library_generation.test.ts +1 -1
- package/test/tmp/dist/Brief_News_Category.d.ts +4 -12
- package/test/tmp/dist/Brief_News_Category.js +6 -21
- package/test/tmp/dist/Brief_News_Category.js.map +1 -1
- package/test/tmp/dist/Client.d.ts +4 -12
- package/test/tmp/dist/Client.js +6 -21
- package/test/tmp/dist/Client.js.map +1 -1
- package/test/tmp/dist/Institution.d.ts +4 -12
- package/test/tmp/dist/Institution.js +6 -21
- package/test/tmp/dist/Institution.js.map +1 -1
- package/test/tmp/dist/Project.d.ts +5 -18
- package/test/tmp/dist/Project.js +8 -32
- package/test/tmp/dist/Project.js.map +1 -1
- package/test/tmp/dist/index.d.ts +1 -2
- package/test/tmp/dist/index.js +1 -1
- package/test/tmp/dist/index.js.map +1 -1
- package/test/tmp/dist/root_types.d.ts +41 -0
- package/test/tmp/dist/root_types.js +41 -0
- package/test/tmp/dist/root_types.js.map +1 -0
- package/test/tmp/src/Brief_News_Category.ts +6 -25
- package/test/tmp/src/Client.ts +6 -25
- package/test/tmp/src/Institution.ts +6 -25
- package/test/tmp/src/Project.ts +8 -36
- package/test/tmp/src/index.ts +1 -1
- package/test/tmp/src/root_types.ts +69 -0
package/test/tmp/src/Project.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ky from "ky";
|
|
2
2
|
import { encode_search_params, Response, Response_Multiple } from "./utils/utils.js";
|
|
3
|
+
import { Collection, Bare_Document, Document_Array, _Base_Document, _With_Children, _With_Array } from "./root_types.js"
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
import { project } from "./types/project.js";
|
|
@@ -7,17 +8,9 @@ import { project_query } from "./types/project_query.js";
|
|
|
7
8
|
import { project_put } from "./types/project_put.js";
|
|
8
9
|
import { project_post } from "./types/project_post.js";
|
|
9
10
|
|
|
10
|
-
export class Collection_Project {
|
|
11
|
-
path: string[]
|
|
12
|
-
get_auth: () => Promise<any>
|
|
13
|
-
collection_id: string
|
|
14
|
-
collection_name_plural: string
|
|
15
|
-
|
|
11
|
+
export class Collection_Project extends Collection {
|
|
16
12
|
constructor(path: string[], get_auth: () => Promise<any>) {
|
|
17
|
-
|
|
18
|
-
this.get_auth = get_auth;
|
|
19
|
-
this.collection_id = "project";
|
|
20
|
-
this.collection_name_plural = "projects"
|
|
13
|
+
super(path, get_auth, "project", "projects");
|
|
21
14
|
}
|
|
22
15
|
|
|
23
16
|
|
|
@@ -54,25 +47,13 @@ export class Collection_Project {
|
|
|
54
47
|
let get_auth = this.get_auth;
|
|
55
48
|
let collection_id = this.collection_id;
|
|
56
49
|
let collection_name_plural = this.collection_name_plural;
|
|
57
|
-
return new
|
|
50
|
+
return new Document_Project(path, collection_id, document_id, collection_name_plural, get_auth);
|
|
58
51
|
}
|
|
59
52
|
}
|
|
60
53
|
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
54
|
+
class Document_Project extends Bare_Document implements _Base_Document, _With_Array {
|
|
70
55
|
constructor(path: string[], collection_id: string, document_id: string, collection_name_plural: string, get_auth: () => Promise<any>) {
|
|
71
|
-
|
|
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;
|
|
56
|
+
super(path, collection_id, document_id, collection_name_plural, get_auth);
|
|
76
57
|
}
|
|
77
58
|
|
|
78
59
|
async get(): Promise<project>{
|
|
@@ -136,19 +117,10 @@ export type project_steps_post = {
|
|
|
136
117
|
"name": string
|
|
137
118
|
}
|
|
138
119
|
|
|
139
|
-
export class Collection_Project_Array_steps {
|
|
140
|
-
path: string[]
|
|
141
|
-
get_auth: () => Promise<any>
|
|
142
|
-
collection_id: string
|
|
143
|
-
collection_name_plural: string
|
|
144
|
-
array_key: string
|
|
120
|
+
export class Collection_Project_Array_steps extends Document_Array {
|
|
145
121
|
|
|
146
122
|
constructor(path: string[], get_auth: () => Promise<any>) {
|
|
147
|
-
|
|
148
|
-
this.get_auth = get_auth;
|
|
149
|
-
this.collection_id = "project";
|
|
150
|
-
this.collection_name_plural = "projects"
|
|
151
|
-
this.array_key = "steps"
|
|
123
|
+
super(path, get_auth, "project", "projects", "steps")
|
|
152
124
|
}
|
|
153
125
|
|
|
154
126
|
async push(document: project_steps_post): Promise<project>{
|
package/test/tmp/src/index.ts
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export abstract class Collection {
|
|
2
|
+
path: string[]
|
|
3
|
+
get_auth: () => Promise<any>
|
|
4
|
+
collection_id: string
|
|
5
|
+
collection_name_plural: string
|
|
6
|
+
|
|
7
|
+
constructor(path: string[], get_auth: () => Promise<any>, collection_id: string, collection_name_plural: string) {
|
|
8
|
+
this.path = path;
|
|
9
|
+
this.get_auth = get_auth;
|
|
10
|
+
this.collection_id = collection_id;
|
|
11
|
+
this.collection_name_plural = collection_name_plural;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
abstract query(query: any): Promise<any[]>;
|
|
15
|
+
abstract post(document: any): Promise<any>;
|
|
16
|
+
abstract document(document_id: string): Document
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type Document = (Bare_Document & _Base_Document) | (Bare_Document & _Base_Document & _With_Children) | (Bare_Document & _Base_Document & _With_Array) | (Bare_Document & _Base_Document & _With_Array & _With_Children);
|
|
20
|
+
|
|
21
|
+
export abstract class Bare_Document {
|
|
22
|
+
path: string[];
|
|
23
|
+
collection_id: string;
|
|
24
|
+
document_id: string;
|
|
25
|
+
collection_name_plural: string;
|
|
26
|
+
get_auth: () => Promise<any>;
|
|
27
|
+
|
|
28
|
+
constructor(path: string[], collection_id: string, document_id: string, collection_name_plural: string, get_auth: () => Promise<any>) {
|
|
29
|
+
this.path = path;
|
|
30
|
+
this.collection_id = collection_id;
|
|
31
|
+
this.document_id = document_id;
|
|
32
|
+
this.collection_name_plural = collection_name_plural;
|
|
33
|
+
this.get_auth = get_auth;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface _Base_Document {
|
|
38
|
+
get(): any
|
|
39
|
+
put(update: any): Promise<any>
|
|
40
|
+
remove(): Promise<any>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface _With_Children {
|
|
44
|
+
collection(collection_id: string): Collection
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface _With_Array {
|
|
48
|
+
array(key: string): Document_Array
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export abstract class Document_Array {
|
|
52
|
+
path: string[]
|
|
53
|
+
collection_id: string
|
|
54
|
+
collection_name_plural: string
|
|
55
|
+
array_key: string
|
|
56
|
+
get_auth: () => Promise<any>
|
|
57
|
+
|
|
58
|
+
constructor(path: string[], get_auth: () => Promise<any>, collection_id: string, collection_name_plural: string, array_key: string) {
|
|
59
|
+
this.path = path;
|
|
60
|
+
this.get_auth = get_auth;
|
|
61
|
+
this.collection_id = collection_id;
|
|
62
|
+
this.collection_name_plural = collection_name_plural
|
|
63
|
+
this.array_key = array_key
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
abstract push(document: any): Promise<any>
|
|
67
|
+
abstract replace(document: any): Promise<any>
|
|
68
|
+
abstract delete(document_id: string): Promise<any>
|
|
69
|
+
}
|