@liminalfunctions/framework 1.0.42 → 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/dist/utils/mongoose_from_zod.js +0 -1
- package/dist/utils/mongoose_from_zod.js.map +1 -1
- package/package.json +1 -1
- package/src/code_generation/templates/collection.mustache +72 -56
- package/src/code_generation/templates/main.mustache +23 -12
- package/src/utils/mongoose_from_zod.ts +0 -1
- package/test/0_1_mongoose_from_zod.test.ts +2 -2
- 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,64 +54,80 @@ export class Collection_{{my_built_collection}} {
|
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
return new Document(path, collection_id, document_id, collection_name_plural, get_auth);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
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
|
+
|
|
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
|
+
}
|
|
77
|
+
|
|
78
|
+
async get(): Promise<{{type_return}}>{
|
|
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<{{type_return}}>;
|
|
85
|
+
return result.data;
|
|
86
|
+
} catch(err){
|
|
87
|
+
return Promise.reject(err)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
75
90
|
|
|
76
|
-
|
|
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
|
-
|
|
91
|
+
async put(update: {{type_put}}): Promise<{{type_return}}>{
|
|
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<{{type_return}}>;
|
|
99
|
+
return result.data;
|
|
100
|
+
} catch(err){
|
|
101
|
+
return Promise.reject(err)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async remove(): Promise<{{type_return}}>{
|
|
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<{{type_return}}>;
|
|
112
|
+
return result.data;
|
|
113
|
+
} catch(err){
|
|
114
|
+
return Promise.reject(err)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
{{#has_subcollections}}
|
|
119
|
+
{{#child_collections}}
|
|
120
|
+
collection(collection_id: "{{collection_id}}"): Collection_{{built_collection}};
|
|
121
|
+
{{/child_collections}}
|
|
122
|
+
collection(collection_id: string) {
|
|
123
|
+
switch(collection_id) {
|
|
124
|
+
{{#child_collections}}
|
|
125
|
+
case "{{collection_id}}":
|
|
126
|
+
return new Collection_{{built_collection}}([...this.path, this.document_id, "{{collection_id}}"], this.get_auth);
|
|
127
|
+
{{/child_collections}}
|
|
128
|
+
default:
|
|
129
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
115
130
|
}
|
|
116
131
|
}
|
|
132
|
+
{{/has_subcollections}}
|
|
117
133
|
}
|
|
@@ -7,18 +7,29 @@ import { Collection_{{built_collection}} } from "{{ built_collection_path }}"
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
export function api(base_url: string, get_auth: () => Promise<any>) {
|
|
10
|
-
return
|
|
11
|
-
collection(collection_id: {{child_collection_id_types}}) {
|
|
12
|
-
switch(collection_id) {
|
|
13
|
-
{{#child_collections}}
|
|
14
|
-
case "{{collection_id}}":
|
|
15
|
-
return new Collection_{{built_collection}}([base_url, "{{collection_id}}"], get_auth);
|
|
16
|
-
{{/child_collections}}
|
|
17
|
-
default:
|
|
18
|
-
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
10
|
+
return new Api(base_url, get_auth)
|
|
22
11
|
}
|
|
23
12
|
|
|
13
|
+
class Api {
|
|
14
|
+
base_url: string;
|
|
15
|
+
get_auth: () => Promise<any>
|
|
16
|
+
|
|
17
|
+
constructor(base_url: string, get_auth: () => Promise<any>) {
|
|
18
|
+
this.base_url = base_url;
|
|
19
|
+
this.get_auth = get_auth
|
|
20
|
+
}
|
|
24
21
|
|
|
22
|
+
{{#child_collections}}
|
|
23
|
+
collection(collection_id: "{{collection_id}}"): Collection_{{built_collection}};
|
|
24
|
+
{{/child_collections}}
|
|
25
|
+
collection(collection_id: string) {
|
|
26
|
+
switch(collection_id) {
|
|
27
|
+
{{#child_collections}}
|
|
28
|
+
case "{{collection_id}}":
|
|
29
|
+
return new Collection_{{built_collection}}([this.base_url, "{{collection_id}}"], this.get_auth);
|
|
30
|
+
{{/child_collections}}
|
|
31
|
+
default:
|
|
32
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -126,7 +126,6 @@ export function schema_entry_from_zod(zod_definition, loop_detector) {
|
|
|
126
126
|
else {
|
|
127
127
|
throw new Error(`could not find custom parser for ${framework_override_type} in the magic value dictionary`);
|
|
128
128
|
}
|
|
129
|
-
result.required = !zod_definition.safeParse(undefined).success;
|
|
130
129
|
return result;
|
|
131
130
|
default:
|
|
132
131
|
throw new Error("Cannot process zod type: " + zod_definition._zod.def.type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongoose_from_zod.js","sourceRoot":"","sources":["../../src/utils/mongoose_from_zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAA;AAKrE,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC9D,MAAM,wCAAwC,GAAG,+BAA+B,CAAC,QAAQ,EAAE,CAAC;AAC5F,MAAM,wCAAwC,GAAG,+BAA+B,CAAC,QAAQ,EAAE,CAAC;AAE5F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAS,CAAC,GAAG,EAAE,EAAE;IACjD,IAAG,CAAC,GAAG,EAAC,CAAC;QAAC,OAAO,KAAK,CAAC;IAAC,CAAC;IACzB,IAAI,MAAM,GAAG,+BAA+B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC5D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACjB,CAAC;SAAM,CAAC;QACJ,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC,CAAC,CAAC,IAAI,CAAC;IACJ,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,QAAQ;CACrB,CAAC,CAAC,IAAI,CAAC,EAAC,uBAAuB,EAAE,YAAY,EAAC,CAAC,CAAC;AAEjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAS,CAAC,GAAG,EAAE,EAAE;IAC1D,IAAI,MAAM,GAAG,wCAAwC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACrE,IAAI,C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1E,eAAe,CAAC,QAAQ,GAAG,KAAK,CAAC;IACjC,OAAO,eAAe,CAAC;AAC3B,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAyB,EAAE,IAAsF;IACvI,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;AACjG,CAAC"}
|
package/package.json
CHANGED
|
@@ -54,64 +54,80 @@ export class Collection_{{my_built_collection}} {
|
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
return new Document(path, collection_id, document_id, collection_name_plural, get_auth);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
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
|
+
|
|
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
|
+
}
|
|
77
|
+
|
|
78
|
+
async get(): Promise<{{type_return}}>{
|
|
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<{{type_return}}>;
|
|
85
|
+
return result.data;
|
|
86
|
+
} catch(err){
|
|
87
|
+
return Promise.reject(err)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
75
90
|
|
|
76
|
-
|
|
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
|
-
|
|
91
|
+
async put(update: {{type_put}}): Promise<{{type_return}}>{
|
|
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<{{type_return}}>;
|
|
99
|
+
return result.data;
|
|
100
|
+
} catch(err){
|
|
101
|
+
return Promise.reject(err)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async remove(): Promise<{{type_return}}>{
|
|
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<{{type_return}}>;
|
|
112
|
+
return result.data;
|
|
113
|
+
} catch(err){
|
|
114
|
+
return Promise.reject(err)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
{{#has_subcollections}}
|
|
119
|
+
{{#child_collections}}
|
|
120
|
+
collection(collection_id: "{{collection_id}}"): Collection_{{built_collection}};
|
|
121
|
+
{{/child_collections}}
|
|
122
|
+
collection(collection_id: string) {
|
|
123
|
+
switch(collection_id) {
|
|
124
|
+
{{#child_collections}}
|
|
125
|
+
case "{{collection_id}}":
|
|
126
|
+
return new Collection_{{built_collection}}([...this.path, this.document_id, "{{collection_id}}"], this.get_auth);
|
|
127
|
+
{{/child_collections}}
|
|
128
|
+
default:
|
|
129
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
115
130
|
}
|
|
116
131
|
}
|
|
132
|
+
{{/has_subcollections}}
|
|
117
133
|
}
|
|
@@ -7,18 +7,29 @@ import { Collection_{{built_collection}} } from "{{ built_collection_path }}"
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
export function api(base_url: string, get_auth: () => Promise<any>) {
|
|
10
|
-
return
|
|
11
|
-
collection(collection_id: {{child_collection_id_types}}) {
|
|
12
|
-
switch(collection_id) {
|
|
13
|
-
{{#child_collections}}
|
|
14
|
-
case "{{collection_id}}":
|
|
15
|
-
return new Collection_{{built_collection}}([base_url, "{{collection_id}}"], get_auth);
|
|
16
|
-
{{/child_collections}}
|
|
17
|
-
default:
|
|
18
|
-
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
10
|
+
return new Api(base_url, get_auth)
|
|
22
11
|
}
|
|
23
12
|
|
|
13
|
+
class Api {
|
|
14
|
+
base_url: string;
|
|
15
|
+
get_auth: () => Promise<any>
|
|
16
|
+
|
|
17
|
+
constructor(base_url: string, get_auth: () => Promise<any>) {
|
|
18
|
+
this.base_url = base_url;
|
|
19
|
+
this.get_auth = get_auth
|
|
20
|
+
}
|
|
24
21
|
|
|
22
|
+
{{#child_collections}}
|
|
23
|
+
collection(collection_id: "{{collection_id}}"): Collection_{{built_collection}};
|
|
24
|
+
{{/child_collections}}
|
|
25
|
+
collection(collection_id: string) {
|
|
26
|
+
switch(collection_id) {
|
|
27
|
+
{{#child_collections}}
|
|
28
|
+
case "{{collection_id}}":
|
|
29
|
+
return new Collection_{{built_collection}}([this.base_url, "{{collection_id}}"], this.get_auth);
|
|
30
|
+
{{/child_collections}}
|
|
31
|
+
default:
|
|
32
|
+
throw new Error(`Api does not have the collection ${collection_id}`)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -136,7 +136,6 @@ export function schema_entry_from_zod(zod_definition: z.ZodType, loop_detector:
|
|
|
136
136
|
throw new Error(`could not find custom parser for ${framework_override_type} in the magic value dictionary`)
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
result.required = !zod_definition.safeParse(undefined).success;
|
|
140
139
|
return result;
|
|
141
140
|
default:
|
|
142
141
|
throw new Error("Cannot process zod type: " + zod_definition._zod.def.type);
|
|
@@ -181,13 +181,13 @@ describe('Mongoose from Zod', function () {
|
|
|
181
181
|
it(`should correctly handle nullable mongodb IDs`, function () {
|
|
182
182
|
let zodSchema = z.object({ test_value: z_mongodb_id_nullable})
|
|
183
183
|
let mongooseSchema = schema_from_zod(zodSchema)
|
|
184
|
-
assert.deepEqual({ test_value: {mongoose_type:
|
|
184
|
+
assert.deepEqual({ test_value: {mongoose_type: Schema.Types.ObjectId, required: false} }, mongooseSchema)
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
it(`should correctly handle optional mongodb IDs`, function () {
|
|
188
188
|
let zodSchema = z.object({ test_value: z_mongodb_id_optional })
|
|
189
189
|
let mongooseSchema = schema_from_zod(zodSchema)
|
|
190
|
-
assert.deepEqual({ test_value: {mongoose_type:
|
|
190
|
+
assert.deepEqual({ test_value: {mongoose_type: Schema.Types.ObjectId, required: false} }, mongooseSchema)
|
|
191
191
|
});
|
|
192
192
|
|
|
193
193
|
/*
|
|
@@ -10,14 +10,17 @@ export declare class Collection_Brief_News_Category {
|
|
|
10
10
|
constructor(path: string[], get_auth: () => Promise<any>);
|
|
11
11
|
query(query: brief_news_category_query): Promise<brief_news_category[]>;
|
|
12
12
|
post(document: brief_news_category_post): Promise<brief_news_category>;
|
|
13
|
-
document(document_id: string):
|
|
14
|
-
path: string[];
|
|
15
|
-
collection_id: string;
|
|
16
|
-
document_id: string;
|
|
17
|
-
collection_name_plural: string;
|
|
18
|
-
get_auth: () => Promise<any>;
|
|
19
|
-
get(): Promise<brief_news_category>;
|
|
20
|
-
put(update: brief_news_category_put): Promise<brief_news_category>;
|
|
21
|
-
remove(): Promise<brief_news_category>;
|
|
22
|
-
};
|
|
13
|
+
document(document_id: string): Document;
|
|
23
14
|
}
|
|
15
|
+
declare class Document {
|
|
16
|
+
path: string[];
|
|
17
|
+
collection_id: string;
|
|
18
|
+
document_id: string;
|
|
19
|
+
collection_name_plural: string;
|
|
20
|
+
get_auth: () => Promise<any>;
|
|
21
|
+
constructor(path: string[], collection_id: string, document_id: string, collection_name_plural: string, get_auth: () => Promise<any>);
|
|
22
|
+
get(): Promise<brief_news_category>;
|
|
23
|
+
put(update: brief_news_category_put): Promise<brief_news_category>;
|
|
24
|
+
remove(): Promise<brief_news_category>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -44,53 +44,61 @@ export class Collection_Brief_News_Category {
|
|
|
44
44
|
let get_auth = this.get_auth;
|
|
45
45
|
let collection_id = this.collection_id;
|
|
46
46
|
let collection_name_plural = this.collection_name_plural;
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
47
|
+
return new Document(path, collection_id, document_id, collection_name_plural, get_auth);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class Document {
|
|
51
|
+
path;
|
|
52
|
+
collection_id;
|
|
53
|
+
document_id;
|
|
54
|
+
collection_name_plural;
|
|
55
|
+
get_auth;
|
|
56
|
+
constructor(path, collection_id, document_id, collection_name_plural, get_auth) {
|
|
57
|
+
this.path = path;
|
|
58
|
+
this.collection_id = collection_id;
|
|
59
|
+
this.document_id = document_id;
|
|
60
|
+
this.collection_name_plural = collection_name_plural;
|
|
61
|
+
this.get_auth = get_auth;
|
|
62
|
+
}
|
|
63
|
+
async get() {
|
|
64
|
+
try {
|
|
65
|
+
let result = await ky.get([...this.path, this.document_id].join('/'), {
|
|
66
|
+
headers: {
|
|
67
|
+
authorization: await this.get_auth()
|
|
68
|
+
},
|
|
69
|
+
}).json();
|
|
70
|
+
return result.data;
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
return Promise.reject(err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async put(update) {
|
|
77
|
+
try {
|
|
78
|
+
let result = await ky.put([...this.path, this.document_id].join('/'), {
|
|
79
|
+
headers: {
|
|
80
|
+
authorization: await this.get_auth()
|
|
81
|
+
},
|
|
82
|
+
json: update
|
|
83
|
+
}).json();
|
|
84
|
+
return result.data;
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
return Promise.reject(err);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async remove() {
|
|
91
|
+
try {
|
|
92
|
+
let result = await ky.delete([...this.path, this.document_id].join('/'), {
|
|
93
|
+
headers: {
|
|
94
|
+
authorization: await this.get_auth()
|
|
95
|
+
},
|
|
96
|
+
}).json();
|
|
97
|
+
return result.data;
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
return Promise.reject(err);
|
|
101
|
+
}
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
//# sourceMappingURL=Brief_News_Category.js.map
|
|
@@ -1 +1 @@
|
|
|
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;IAC5B,aAAa,CAAQ;IACrB,sBAAsB,CAAQ;IAE9B,YAAY,IAAc,EAAE,QAA4B;QACpD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,qBAAqB,CAAC;QAC3C,IAAI,CAAC,sBAAsB,GAAG,uBAAuB,CAAA;IACzD,CAAC;IAGD,KAAK,CAAC,KAAK,CAAC,KAAgC;QACxC,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,EAA4C,CAAC;YACpD,OAAO,MAAM,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAM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MAAM,IAAI,CAAC,QAAQ,EAAE;iBACvC;gBACD,IAAI,EAAE,MAAM;aACf,CAAC,CAAC,IAAI,EAAmC,CAAC;YAC3C,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,MAAM;QACR,IAAI,CAAC;YACD,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;gBACrE,OAAO,EAAE;oBACL,aAAa,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE;iBACvC;aACJ,CAAC,CAAC,IAAI,EAAmC,CAAC;YAC3C,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;CAEJ"}
|
|
@@ -12,15 +12,19 @@ export declare class Collection_Client {
|
|
|
12
12
|
constructor(path: string[], get_auth: () => Promise<any>);
|
|
13
13
|
query(query: client_query): Promise<client[]>;
|
|
14
14
|
post(document: client_post): Promise<client>;
|
|
15
|
-
document(document_id: string):
|
|
16
|
-
path: string[];
|
|
17
|
-
collection_id: string;
|
|
18
|
-
document_id: string;
|
|
19
|
-
collection_name_plural: string;
|
|
20
|
-
get_auth: () => Promise<any>;
|
|
21
|
-
get(): Promise<client>;
|
|
22
|
-
put(update: client_put): Promise<client>;
|
|
23
|
-
remove(): Promise<client>;
|
|
24
|
-
collection(collection_id: "project" | "brief_news_category"): Collection_Brief_News_Category | Collection_Project;
|
|
25
|
-
};
|
|
15
|
+
document(document_id: string): Document;
|
|
26
16
|
}
|
|
17
|
+
declare class Document {
|
|
18
|
+
path: string[];
|
|
19
|
+
collection_id: string;
|
|
20
|
+
document_id: string;
|
|
21
|
+
collection_name_plural: string;
|
|
22
|
+
get_auth: () => Promise<any>;
|
|
23
|
+
constructor(path: string[], collection_id: string, document_id: string, collection_name_plural: string, get_auth: () => Promise<any>);
|
|
24
|
+
get(): Promise<client>;
|
|
25
|
+
put(update: client_put): Promise<client>;
|
|
26
|
+
remove(): Promise<client>;
|
|
27
|
+
collection(collection_id: "project"): Collection_Project;
|
|
28
|
+
collection(collection_id: "brief_news_category"): Collection_Brief_News_Category;
|
|
29
|
+
}
|
|
30
|
+
export {};
|