@liminalfunctions/framework 1.0.44 → 1.0.46
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/README.md +315 -4
- package/dist/F_Collection.js +6 -0
- package/dist/F_Collection.js.map +1 -1
- package/dist/F_Collection_Registry.js +1 -1
- package/dist/F_Collection_Registry.js.map +1 -1
- package/dist/F_Compile.d.ts +2 -1
- package/dist/F_Compile.js +18 -1
- package/dist/F_Compile.js.map +1 -1
- package/package.json +1 -1
- package/src/F_Collection.ts +7 -0
- package/src/F_Collection_Registry.ts +1 -1
- package/src/F_Compile.ts +32 -1
- package/test/2_0_client_library_basic_type_generation.test.ts +48 -2
- package/test/2_0_client_library_query_type_generation.test.ts +63 -38
package/README.md
CHANGED
|
@@ -16,15 +16,175 @@ Framework is opinionated.
|
|
|
16
16
|
|
|
17
17
|
To install Framework in a project, run `npm install @liminalfunctions/framework`. Framework lists ky, express, mongoose, and zod as peer dependencies. You will also need to run `npm install ky express mongoose zod; npm install --save-dev @types/express`.
|
|
18
18
|
|
|
19
|
-
If you intend to use the `on_create`, `on_update`, or `on_delete` hooks, you will need to have a local replica set locally.
|
|
19
|
+
If you intend to use the `on_create`, `on_update`, or `on_delete` hooks, you will need to have a local replica set locally. This is because mongoDB transactions require a replica set.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
[Here are detailed instructions for setting up a local replica set](https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set/). Abbreviated instructions for setting up a replica set on Windows are below:
|
|
22
|
+
|
|
23
|
+
### Setting up a replica set
|
|
24
|
+
|
|
25
|
+
- Create a root database folder somewhere convenient to store your database and config files
|
|
26
|
+
- In that root database folder, create three subfolders, named `database_0`, `database_1`, and `database_2`, respectively
|
|
27
|
+
- In that folder, create the following three config files, named `config_server_0.csg`, `config_server_1.csg`, and `config_server_2.csg`, respectively
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
# mongod.conf
|
|
31
|
+
|
|
32
|
+
# for documentation of all options, see:
|
|
33
|
+
# http://docs.mongodb.org/manual/reference/configuration-options/
|
|
34
|
+
|
|
35
|
+
# Where and how to store data.
|
|
36
|
+
storage:
|
|
37
|
+
dbPath: <PATH TO database_0>
|
|
38
|
+
|
|
39
|
+
# where to write logging data.
|
|
40
|
+
systemLog:
|
|
41
|
+
destination: file
|
|
42
|
+
logAppend: true
|
|
43
|
+
path: <PATH TO database_0>\log\mongod.log
|
|
44
|
+
|
|
45
|
+
# network interfaces
|
|
46
|
+
net:
|
|
47
|
+
port: 27018
|
|
48
|
+
bindIp: 127.0.0.1
|
|
49
|
+
#processManagement:
|
|
50
|
+
|
|
51
|
+
#security:
|
|
52
|
+
|
|
53
|
+
#operationProfiling:
|
|
54
|
+
|
|
55
|
+
#replication:
|
|
56
|
+
replication:
|
|
57
|
+
replSetName: "local_replica_set"
|
|
58
|
+
|
|
59
|
+
#sharding:
|
|
60
|
+
|
|
61
|
+
## Enterprise-Only Options:
|
|
62
|
+
|
|
63
|
+
#auditLog:
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
# mongod.conf
|
|
68
|
+
|
|
69
|
+
# for documentation of all options, see:
|
|
70
|
+
# http://docs.mongodb.org/manual/reference/configuration-options/
|
|
71
|
+
|
|
72
|
+
# Where and how to store data.
|
|
73
|
+
storage:
|
|
74
|
+
dbPath: <PATH TO database_1>
|
|
75
|
+
|
|
76
|
+
# where to write logging data.
|
|
77
|
+
systemLog:
|
|
78
|
+
destination: file
|
|
79
|
+
logAppend: true
|
|
80
|
+
path: <PATH TO database_1>\log\mongod.log
|
|
81
|
+
|
|
82
|
+
# network interfaces
|
|
83
|
+
net:
|
|
84
|
+
port: 27019
|
|
85
|
+
bindIp: 127.0.0.1
|
|
86
|
+
#processManagement:
|
|
87
|
+
|
|
88
|
+
#security:
|
|
89
|
+
|
|
90
|
+
#operationProfiling:
|
|
91
|
+
|
|
92
|
+
#replication:
|
|
93
|
+
replication:
|
|
94
|
+
replSetName: "local_replica_set"
|
|
95
|
+
|
|
96
|
+
#sharding:
|
|
97
|
+
|
|
98
|
+
## Enterprise-Only Options:
|
|
99
|
+
|
|
100
|
+
#auditLog:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
# mongod.conf
|
|
106
|
+
|
|
107
|
+
# for documentation of all options, see:
|
|
108
|
+
# http://docs.mongodb.org/manual/reference/configuration-options/
|
|
109
|
+
|
|
110
|
+
# Where and how to store data.
|
|
111
|
+
storage:
|
|
112
|
+
dbPath: <PATH TO database_2>
|
|
113
|
+
|
|
114
|
+
# where to write logging data.
|
|
115
|
+
systemLog:
|
|
116
|
+
destination: file
|
|
117
|
+
logAppend: true
|
|
118
|
+
path: <PATH TO database_2>\log\mongod.log
|
|
119
|
+
|
|
120
|
+
# network interfaces
|
|
121
|
+
net:
|
|
122
|
+
port: 27020
|
|
123
|
+
bindIp: 127.0.0.1
|
|
124
|
+
#processManagement:
|
|
125
|
+
|
|
126
|
+
#security:
|
|
127
|
+
|
|
128
|
+
#operationProfiling:
|
|
129
|
+
|
|
130
|
+
#replication:
|
|
131
|
+
replication:
|
|
132
|
+
replSetName: "local_replica_set"
|
|
133
|
+
|
|
134
|
+
#sharding:
|
|
135
|
+
|
|
136
|
+
## Enterprise-Only Options:
|
|
137
|
+
|
|
138
|
+
#auditLog:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
- create three powershell files in the root database folder, named `start_server_0.ps1`, `start_server_1.ps1`, `start_server_2.ps1` respectively:
|
|
142
|
+
|
|
143
|
+
```powershell
|
|
144
|
+
mongod --config "<PATH TO ROOT DATABASE FOLDER>\config_server_0.cfg"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
```powershell
|
|
148
|
+
mongod --config "<PATH TO ROOT DATABASE FOLDER>\config_server_1.cfg"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```powershell
|
|
152
|
+
mongod --config "<PATH TO ROOT DATABASE FOLDER>\config_server_2.cfg"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- create a powershell file in the root database folder, named `start.ps1`:
|
|
156
|
+
```powershell
|
|
157
|
+
$j0 = Start-Job -FilePath "./start_server_0.ps1"
|
|
158
|
+
$j1 = Start-Job -FilePath "./start_server_1.ps1"
|
|
159
|
+
$j2 = Start-Job -FilePath "./start_server_2.ps1"
|
|
160
|
+
|
|
161
|
+
Wait-Job -Job $j0
|
|
162
|
+
Wait-Job -Job $j1
|
|
163
|
+
Wait-Job -Job $j2
|
|
164
|
+
```
|
|
165
|
+
- in a console, run `./start.ps1`
|
|
166
|
+
- in another console, within mongosh, initiate the replica set:
|
|
167
|
+
```
|
|
168
|
+
rs.initiate( {
|
|
169
|
+
_id : "local_replica_set",
|
|
170
|
+
members: [
|
|
171
|
+
{ _id: 0, host: "mongodb0.example.net:27018" },
|
|
172
|
+
{ _id: 1, host: "mongodb1.example.net:27019" },
|
|
173
|
+
{ _id: 2, host: "mongodb2.example.net:27020" }
|
|
174
|
+
]
|
|
175
|
+
})
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
When you want to connect to the replica set in `mongoose.connect(...)`, you have to connect to all three members, like so:
|
|
179
|
+
```javascript
|
|
180
|
+
let db_connection = await mongoose.connect('mongodb://127.0.0.1:27018,127.0.0.1:27019,127.0.0.1:27020/DATABASE_NAME?replicaSet=local_replica_set');
|
|
181
|
+
```
|
|
22
182
|
|
|
23
183
|
## Basic Use
|
|
24
184
|
|
|
25
185
|
Make an express server, and connect to MongoDB:
|
|
26
186
|
|
|
27
|
-
```
|
|
187
|
+
```typescript
|
|
28
188
|
import express, { Express } from 'express'
|
|
29
189
|
import mongoose, { Mongoose } from "mongoose";
|
|
30
190
|
import { Server } from "http";
|
|
@@ -42,20 +202,171 @@ let db_connection = await mongoose.connect('mongodb://127.0.0.1:27017/');
|
|
|
42
202
|
// start the express server
|
|
43
203
|
let server = express_app.listen(port);
|
|
44
204
|
|
|
205
|
+
```
|
|
45
206
|
|
|
207
|
+
Create your schemas:
|
|
208
|
+
[For more on creating schemas, see src/0_basic/ in the example repository](https://github.com/youthfulIdealism/framework-examples)
|
|
209
|
+
```typescript
|
|
210
|
+
import { F_Collection } from '@liminalfunctions/framework/F_Collection.js';
|
|
211
|
+
import { F_SM_Open_Access } from '@liminalfunctions/framework/F_SM_Open_Access.js';
|
|
212
|
+
import { z_mongodb_id, z_mongodb_id_nullable, z_mongodb_id_optional } from '@liminalfunctions/framework/index.js';
|
|
213
|
+
import z from 'zod/v4';
|
|
46
214
|
|
|
215
|
+
// define a collection for the user.
|
|
216
|
+
let collection_user = new F_Collection(
|
|
217
|
+
'user',// the name of the collection
|
|
218
|
+
'users',// the plural name of the collection
|
|
219
|
+
z.object({// the valdiator
|
|
220
|
+
// mongodb IDs need to use the special validator `z_mongodb_id`. If you modify the validator (for example, by using z_mongodb_id.optional() or z_mongodb_id.nullable()),
|
|
221
|
+
// it will stop working properly. Instead, use the validators z_mongodb_id_nullable or z_mongodb_id_optional.
|
|
222
|
+
_id: z_mongodb_id,
|
|
223
|
+
name: z.string(),
|
|
224
|
+
auth_system_id: z.string(),
|
|
225
|
+
})
|
|
226
|
+
)
|
|
47
227
|
```
|
|
48
228
|
|
|
49
|
-
|
|
229
|
+
Set up the API path and security to your schema:
|
|
230
|
+
[For more on creating schemas, see src/0_basic/ in the example repository](https://github.com/youthfulIdealism/framework-examples)
|
|
231
|
+
```typescript
|
|
232
|
+
// set up the access to the user collection. This is done via "layers". A "layer" is the heirachy of ways documents in a collection can be accessed.
|
|
233
|
+
// In this case, the user isn't "owned" by anything, so we set it up to be accessible at the base /api/ endpoint. The add_layers method also sets up
|
|
234
|
+
// the security for the collection at that particular endpoint.
|
|
235
|
+
collection_user.add_layers(
|
|
236
|
+
[],// no layers between the base /api/ endpoint and the user
|
|
237
|
+
[new F_SM_Open_Access(collection_user)] // the array of security models. In this case, we're allowing anyone access to the users collection,
|
|
238
|
+
// so anyone can read/write/update/delete users. This is not secure, but this is example code, so it's fine.
|
|
239
|
+
);
|
|
50
240
|
```
|
|
51
241
|
|
|
52
242
|
|
|
243
|
+
Set up the Express endpoints:
|
|
244
|
+
[For more on using the collection registry to set up endpoints, see src/0_basic/ in the example repository](https://github.com/youthfulIdealism/framework-examples)
|
|
245
|
+
```typescript
|
|
246
|
+
// the collection re
|
|
247
|
+
let collection_registry = (new F_Collection_Registry())
|
|
248
|
+
.register(collection_user)
|
|
53
249
|
```
|
|
54
250
|
|
|
251
|
+
Set up authentication:
|
|
252
|
+
```typescript
|
|
253
|
+
// set up the code that generates the auth information across all endpoints. It is incumbent on this piece of code to return the user's current ID
|
|
254
|
+
// and the user's permissions within each layer. The security models take that information and make a decision about whether to allow a given operation.
|
|
255
|
+
// This is where you would integrate a seperate auth system--for example, Firebase auth or Supabase auth. For more details, see the security model example.
|
|
256
|
+
F_Security_Model.set_auth_fetcher(async (req: Request) => {
|
|
257
|
+
// if there's no authorization header, return undefined because there's no user
|
|
258
|
+
if(!req.headers.authorization){ return undefined; }
|
|
259
|
+
|
|
260
|
+
// if there's an authorization header, find the user associated with that information
|
|
261
|
+
let user_record = await collection_user.mongoose_model.findOne({auth_system_id: req.headers.authorization})
|
|
262
|
+
|
|
263
|
+
// if no user was found, return undefined.
|
|
264
|
+
if(!user_record){ return undefined; }
|
|
265
|
+
|
|
266
|
+
// if a user was found, return an authorization object.
|
|
267
|
+
return { user_id: user_record._id + '', layers: [] };
|
|
268
|
+
})
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Start the express server:
|
|
272
|
+
```typescript
|
|
273
|
+
// start the express server
|
|
274
|
+
let server = express_app.listen(port);
|
|
275
|
+
```
|
|
55
276
|
|
|
277
|
+
### Security
|
|
278
|
+
|
|
279
|
+
Implement a security model:
|
|
280
|
+
[For more on implementing your own securiyt models, see /src/2_security_models in the example repository](https://github.com/youthfulIdealism/framework-examples)
|
|
281
|
+
```typescript
|
|
282
|
+
import * as z from "zod/v4";
|
|
283
|
+
import { Request, Response } from "express";
|
|
284
|
+
import { Empty_Query_Possibilities, F_Security_Model, Operation } from "@liminalfunctions/framework/F_Security_Model.js";
|
|
285
|
+
import { F_Collection } from "@liminalfunctions/framework/F_Collection.js";
|
|
286
|
+
|
|
287
|
+
export class Security_Model_Allow<Collection_ID extends string, ZodSchema extends z.ZodObject> extends F_Security_Model<Collection_ID, ZodSchema> {
|
|
288
|
+
|
|
289
|
+
constructor(collection: F_Collection<Collection_ID, ZodSchema>){
|
|
290
|
+
super(collection);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* returns true if the security model allows the create/read/update/delete operation
|
|
295
|
+
*/
|
|
296
|
+
async has_permission(req: Request, res: Response, find: {[key: string]: any}, operation: Operation): Promise<boolean> {
|
|
297
|
+
console.log(`trying to access collection ${this.collection.collection_id} through Security_Model_Allow. Granting access!`)
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* In the event that the query results are empty, this method allows the security model to decide whether to
|
|
303
|
+
* throw an access error or just return no data. 99% of the time, you'll just want to return no data and can
|
|
304
|
+
* reproduce this method exactly as shown. For an example of when this is not true, see security_model_low_value_assets.
|
|
305
|
+
*/
|
|
306
|
+
async handle_empty_query_results(req: Request, res: Response, operation: Operation): Promise<Empty_Query_Possibilities> {
|
|
307
|
+
return { data: null }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Use the security model on a collection:
|
|
313
|
+
[For more on implementing your own security models, see /src/2_security_models in the example repository](https://github.com/youthfulIdealism/framework-examples)
|
|
314
|
+
[For more using the built-in security models, see /src/3_built_in_security_models in the example repository](https://github.com/youthfulIdealism/framework-examples)
|
|
315
|
+
```typescript
|
|
316
|
+
collection_user.add_layers(
|
|
317
|
+
[],
|
|
318
|
+
[new Security_Model_Allow(collection_user)]
|
|
319
|
+
);
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Business Logic
|
|
323
|
+
Business logic is handled via on_create, after_create, on_update, after_update, on_delete, and after_delete hooks.
|
|
324
|
+
[For more on using hooks, see /src/4_hooks in the example repository](https://github.com/youthfulIdealism/framework-examples)
|
|
325
|
+
|
|
326
|
+
Specify a new `user_profile` collection and a hook that creates a user_profile whenever a new user is created:
|
|
327
|
+
```typescript
|
|
328
|
+
let collection_user_profile = new F_Collection('user_profile', 'user_profiles',z.object({// the valdiator
|
|
329
|
+
_id: z_mongodb_id,
|
|
330
|
+
user_id: z_mongodb_id,
|
|
331
|
+
profile_picture_url: z.string(),
|
|
332
|
+
})
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
// whenever a project is created, auto-generate the steps.
|
|
336
|
+
collection_user_profile.on_create(async (session, created_document) => {
|
|
337
|
+
await collection_step.mongoose_model.create([{
|
|
338
|
+
user_id: created_document._id_,
|
|
339
|
+
profile_picture_url: "http://localhost:8123/images/some_url.png",
|
|
340
|
+
}], { session: session })
|
|
341
|
+
})
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Auto-Generated Client Libraries
|
|
345
|
+
|
|
346
|
+
Given a complete collection registry, auto-generate a client library. The client library will still need its dependencies installed via `npm install`, and it will need to be built using `npm run-script build`.
|
|
347
|
+
[For more on generating and using client libraries, see /src/5_client_libraries in the example repository](https://github.com/youthfulIdealism/framework-examples)
|
|
348
|
+
```typescript
|
|
349
|
+
import { generate_client_library } from '@liminalfunctions/framework/generate_client_library.js';
|
|
350
|
+
|
|
351
|
+
await generate_client_library('./out/client_library', collection_registry);
|
|
352
|
+
```
|
|
56
353
|
|
|
57
354
|
## Development and Running Tests
|
|
58
355
|
|
|
356
|
+
To develop this tool, download it. The tool can be built using `npm run-script build`. The tool can be tested using `npm run-script test`.
|
|
59
357
|
|
|
358
|
+
The test files are in the `/test/` folder. I use mocha for testing.
|
|
60
359
|
|
|
360
|
+
The tests have a minor glitch: if you run the `1_2_role_membership.test.ts` along with any other test, there's a race condition in the setup/teardown of the database and server. To run `1_2_role_membership.test.ts`, you need to replace the line
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
describe.skip('Security Model Role Membership', function () {
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
with
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
describe.only('Security Model Role Membership', function () {
|
|
370
|
+
```
|
|
61
371
|
|
|
372
|
+
I would welcome any pull requests that fix this.
|
package/dist/F_Collection.js
CHANGED
|
@@ -27,6 +27,12 @@ export class F_Collection {
|
|
|
27
27
|
this.mongoose_model = mongoose_from_zod(collection_name, validator);
|
|
28
28
|
this.query_validator_server = query_validator_from_zod(validator, 'server');
|
|
29
29
|
this.query_validator_client = query_validator_from_zod(validator, 'client');
|
|
30
|
+
if (!Object.hasOwn(this.validator._zod.def.shape, '_id')) {
|
|
31
|
+
throw new Error(`_id is a required field, because each collection is a mongoDB object.`);
|
|
32
|
+
}
|
|
33
|
+
if (this.validator._zod.def.shape._id.meta()?.framework_override_type !== 'mongodb_id') {
|
|
34
|
+
throw new Error(`_id must be a mongoDB ID. Use the z_mongodb_id special field.`);
|
|
35
|
+
}
|
|
30
36
|
this.put_validator = validator.partial();
|
|
31
37
|
this.post_validator = Object.hasOwn(this.validator._zod.def.shape, '_id') ? validator.partial({ _id: true }) : validator;
|
|
32
38
|
this.access_layers = [];
|
package/dist/F_Collection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"F_Collection.js","sourceRoot":"","sources":["../src/F_Collection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,QAAyC,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAY/E,MAAM,OAAO,YAAY;IACrB,aAAa,CAAgB;IAC7B,sBAAsB,CAAS;IAC/B,SAAS,CAAY;IACrB,eAAe,CAAM;IACrB,cA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CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC;QACnD,OAAO,IAA8G,CAAC;IAC1H,CAAC;IAED,OAAO,CAAC,GAAW,EAAE,UAAkB;QACnC,KAAI,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAC,CAAC;YACnD,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"F_Collection_Registry.js","sourceRoot":"","sources":["../src/F_Collection_Registry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkB,MAAM,gBAAgB,CAAA;AAKxD,MAAM,OAAO,qBAAqB;IAC9B,WAAW,CAAc;IAIzB;QACI,IAAI,CAAC,WAAW,GAAG,EAAiB,CAAC;IACzC,CAAC;IAED,QAAQ,CAA8D,UAAkD;QACpH,IAAI,WAAW,GAAG,IAAI,CAAC,WAA8F,CAAC;QAEtH,WAAW,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC;QACnD,OAAO,IAA8G,CAAC;IAC1H,CAAC;IAED,OAAO,CAAC,GAAW,EAAE,UAAkB;QACnC,KAAI,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAC,CAAC;YACnD,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;QAC9C,CAAC;IACL,CAAC;CACJ"}
|
package/dist/F_Compile.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
2
|
import { Router } from "express";
|
|
3
3
|
import { F_Collection } from "./F_Collection.js";
|
|
4
|
-
|
|
4
|
+
import { F_Collection_Registry } from "./F_Collection_Registry.js";
|
|
5
|
+
export declare function compile<Collection_ID extends string, ZodSchema extends z.ZodObject>(app: Router, collection: F_Collection<Collection_ID, ZodSchema>, api_prefix: string, collection_registry: F_Collection_Registry<any>): void;
|
package/dist/F_Compile.js
CHANGED
|
@@ -2,7 +2,24 @@ import * as z from "zod/v4";
|
|
|
2
2
|
import { isValidObjectId } from "mongoose";
|
|
3
3
|
import { F_Security_Model } from "./F_Security_Models/F_Security_Model.js";
|
|
4
4
|
import { convert_null, query_object_to_mongodb_limits, query_object_to_mongodb_query } from "./utils/query_object_to_mongodb_query.js";
|
|
5
|
-
export function compile(app, collection, api_prefix) {
|
|
5
|
+
export function compile(app, collection, api_prefix, collection_registry) {
|
|
6
|
+
for (let access_layers of collection.access_layers) {
|
|
7
|
+
for (let layer of access_layers.layers) {
|
|
8
|
+
if (layer === collection.collection_id) {
|
|
9
|
+
throw new Error(`Error compiling collection ${collection.collection_id}: a collection cannot be a member of it's own layer. Remove "${collection.collection_id}" from the collection's layers.`);
|
|
10
|
+
}
|
|
11
|
+
if (!collection_registry.collections[layer]) {
|
|
12
|
+
throw new Error(`Error compiling collection ${collection.collection_id}: collection registry does not have a collection with the ID "${layer}". Each layer must be a valid collection ID.`);
|
|
13
|
+
}
|
|
14
|
+
if (!Object.hasOwn(collection.validator._zod.def.shape, `${layer}_id`)) {
|
|
15
|
+
throw new Error(`Error compiling collection ${collection.collection_id}: collection does not have a field "${layer}_id. Either remove ${layer} from the collection's layers, or add a field ${layer}_id`);
|
|
16
|
+
}
|
|
17
|
+
let layer_id_is_mongodb_id = collection.validator._zod.def.shape[`${layer}_id`].meta()?.framework_override_type === 'mongodb_id';
|
|
18
|
+
if (!layer_id_is_mongodb_id) {
|
|
19
|
+
throw new Error(`Error compiling collection ${collection.collection_id}: ${layer}_id must be a mongodb ID. use the z_mongodb_id, z_mongodb_id_nullable, or z_mongodb_id_optional special fields.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
6
23
|
for (let access_layers of collection.access_layers) {
|
|
7
24
|
let base_layers_path_components = access_layers.layers.flatMap(ele => [ele, ':' + ele]);
|
|
8
25
|
let get_one_path = [
|
package/dist/F_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AAC,aAAa,GAAG,EAAE,CAAC,CAAC;gBACvG,OAAO;YACX,CAAC;YAED,IAAI,OAAO,CAAC;YACZ,IAAI,CAAC;gBACD,OAAO,GAAG,MAAM,UAAU,CAAC,+BAA+B,CAAC,IAAI,CAAC,CAAC;YACrE,CAAC;YAAC,OAAM,GAAG,EAAC,CAAC;gBACT,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChB,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAAC,CAAC;gBAC/C,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACnB,OAAO;YACX,CAAC;YAED,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,IAAI,QAAQ,GAAG,MAAM,yBAAyB,CAAC,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;gBAC9F,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACJ,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAChC,CAAC;QAEL,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
package/src/F_Collection.ts
CHANGED
|
@@ -48,6 +48,13 @@ export class F_Collection<Collection_ID extends string, ZodSchema extends z.ZodO
|
|
|
48
48
|
this.query_validator_server = query_validator_from_zod(validator, 'server');
|
|
49
49
|
this.query_validator_client = query_validator_from_zod(validator, 'client');
|
|
50
50
|
// TODO: we can make this more closely match the mongoDB PUT operation and allow updates to eg array.3.element fields
|
|
51
|
+
|
|
52
|
+
if(!Object.hasOwn(this.validator._zod.def.shape, '_id')){
|
|
53
|
+
throw new Error(`_id is a required field, because each collection is a mongoDB object.`)
|
|
54
|
+
}
|
|
55
|
+
if(this.validator._zod.def.shape._id.meta()?.framework_override_type !== 'mongodb_id'){
|
|
56
|
+
throw new Error(`_id must be a mongoDB ID. Use the z_mongodb_id special field.`)
|
|
57
|
+
}
|
|
51
58
|
|
|
52
59
|
// TODO: find a more elegant way to do this so that the types don't have a cow
|
|
53
60
|
//@ts-ignore
|
|
@@ -23,7 +23,7 @@ export class F_Collection_Registry<Collections = {}> {
|
|
|
23
23
|
|
|
24
24
|
compile(app: Router, api_prefix: string) {
|
|
25
25
|
for(let collection of Object.values(this.collections)){
|
|
26
|
-
compile(app, collection, api_prefix)
|
|
26
|
+
compile(app, collection, api_prefix, this)
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/F_Compile.ts
CHANGED
|
@@ -6,20 +6,51 @@ import { F_Collection } from "./F_Collection.js";
|
|
|
6
6
|
import { F_Security_Model, Authenticated_Request } from "./F_Security_Models/F_Security_Model.js";
|
|
7
7
|
import { convert_null, query_object_to_mongodb_limits, query_object_to_mongodb_query } from "./utils/query_object_to_mongodb_query.js";
|
|
8
8
|
import { z_mongodb_id } from "./utils/mongoose_from_zod.js";
|
|
9
|
+
import { F_Collection_Registry } from "./F_Collection_Registry.js";
|
|
9
10
|
|
|
10
11
|
/*process.on('unhandledRejection', (reason, promise) => {
|
|
11
12
|
console.log(`CAUGHT UNHANDLED REJECTION`)
|
|
12
13
|
console.log(reason)
|
|
13
14
|
})*/
|
|
14
15
|
|
|
15
|
-
export function compile<Collection_ID extends string, ZodSchema extends z.ZodObject>(
|
|
16
|
+
export function compile<Collection_ID extends string, ZodSchema extends z.ZodObject>(
|
|
17
|
+
app: Router,
|
|
18
|
+
collection: F_Collection<Collection_ID, ZodSchema>,
|
|
19
|
+
api_prefix: string,
|
|
20
|
+
collection_registry: F_Collection_Registry<any>){
|
|
16
21
|
/*app.use((req, res, next) => {
|
|
17
22
|
console.log(`${req.method} ${req.originalUrl}`)
|
|
18
23
|
next();
|
|
19
24
|
})*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
for(let access_layers of collection.access_layers){
|
|
28
|
+
for(let layer of access_layers.layers){
|
|
29
|
+
// verify that the collection is not in its own layers
|
|
30
|
+
if(layer === collection.collection_id){
|
|
31
|
+
throw new Error(`Error compiling collection ${collection.collection_id}: a collection cannot be a member of it's own layer. Remove "${collection.collection_id}" from the collection's layers.`)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// verify that each layer has a corresponding collection
|
|
35
|
+
if(!collection_registry.collections[layer]){
|
|
36
|
+
throw new Error(`Error compiling collection ${collection.collection_id}: collection registry does not have a collection with the ID "${layer}". Each layer must be a valid collection ID.`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if(!Object.hasOwn(collection.validator._zod.def.shape, `${layer}_id`)) {
|
|
40
|
+
throw new Error(`Error compiling collection ${collection.collection_id}: collection does not have a field "${layer}_id. Either remove ${layer} from the collection's layers, or add a field ${layer}_id`)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let layer_id_is_mongodb_id = collection.validator._zod.def.shape[`${layer}_id`].meta()?.framework_override_type === 'mongodb_id';
|
|
44
|
+
if(!layer_id_is_mongodb_id){
|
|
45
|
+
throw new Error(`Error compiling collection ${collection.collection_id}: ${layer}_id must be a mongodb ID. use the z_mongodb_id, z_mongodb_id_nullable, or z_mongodb_id_optional special fields.`)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
20
49
|
|
|
50
|
+
// set up the Express endpoints
|
|
21
51
|
for(let access_layers of collection.access_layers){
|
|
22
52
|
let base_layers_path_components = access_layers.layers.flatMap(ele => [ele, ':' + ele]);
|
|
53
|
+
|
|
23
54
|
|
|
24
55
|
let get_one_path = [
|
|
25
56
|
api_prefix,
|
|
@@ -38,7 +38,9 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
it(`should be able to generate a plain object`, async function () {
|
|
41
|
-
const validate_test_collection = z.object({
|
|
41
|
+
const validate_test_collection = z.object({
|
|
42
|
+
_id: z_mongodb_id
|
|
43
|
+
});
|
|
42
44
|
|
|
43
45
|
let test_collection = new F_Collection('test_collection', 'test_collection', validate_test_collection);
|
|
44
46
|
|
|
@@ -49,12 +51,13 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
49
51
|
|
|
50
52
|
assert.equal(
|
|
51
53
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
52
|
-
remove_whitespace(`export type test_collection = {}`)
|
|
54
|
+
remove_whitespace(`export type test_collection = {"_id": string}`)
|
|
53
55
|
)
|
|
54
56
|
});
|
|
55
57
|
|
|
56
58
|
it(`should be able to generate a plain object containing a string`, async function () {
|
|
57
59
|
const validate_test_collection = z.object({
|
|
60
|
+
_id: z_mongodb_id,
|
|
58
61
|
test: z.string(),
|
|
59
62
|
});
|
|
60
63
|
|
|
@@ -68,6 +71,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
68
71
|
assert.equal(
|
|
69
72
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
70
73
|
remove_whitespace(`export type test_collection = {
|
|
74
|
+
"_id": string
|
|
71
75
|
"test": string
|
|
72
76
|
}`)
|
|
73
77
|
)
|
|
@@ -75,6 +79,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
75
79
|
|
|
76
80
|
it(`should be able to generate a plain object containing a number`, async function () {
|
|
77
81
|
const validate_test_collection = z.object({
|
|
82
|
+
_id: z_mongodb_id,
|
|
78
83
|
test: z.number(),
|
|
79
84
|
});
|
|
80
85
|
|
|
@@ -88,6 +93,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
88
93
|
assert.equal(
|
|
89
94
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
90
95
|
remove_whitespace(`export type test_collection = {
|
|
96
|
+
"_id": string
|
|
91
97
|
"test": number
|
|
92
98
|
}`)
|
|
93
99
|
)
|
|
@@ -95,6 +101,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
95
101
|
|
|
96
102
|
it(`should be able to generate a plain object containing a boolean`, async function () {
|
|
97
103
|
const validate_test_collection = z.object({
|
|
104
|
+
_id: z_mongodb_id,
|
|
98
105
|
test: z.boolean(),
|
|
99
106
|
});
|
|
100
107
|
|
|
@@ -108,6 +115,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
108
115
|
assert.equal(
|
|
109
116
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
110
117
|
remove_whitespace(`export type test_collection = {
|
|
118
|
+
"_id": string
|
|
111
119
|
"test": boolean
|
|
112
120
|
}`)
|
|
113
121
|
)
|
|
@@ -115,6 +123,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
115
123
|
|
|
116
124
|
it(`should be able to generate a plain object containing a date`, async function () {
|
|
117
125
|
const validate_test_collection = z.object({
|
|
126
|
+
_id: z_mongodb_id,
|
|
118
127
|
test: z.date(),
|
|
119
128
|
});
|
|
120
129
|
|
|
@@ -128,6 +137,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
128
137
|
assert.equal(
|
|
129
138
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
130
139
|
remove_whitespace(`export type test_collection = {
|
|
140
|
+
"_id": string
|
|
131
141
|
"test": Date
|
|
132
142
|
}`)
|
|
133
143
|
)
|
|
@@ -135,6 +145,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
135
145
|
|
|
136
146
|
it(`should be able to generate a plain object containing an objectID`, async function () {
|
|
137
147
|
const validate_test_collection = z.object({
|
|
148
|
+
_id: z_mongodb_id,
|
|
138
149
|
test: z_mongodb_id,
|
|
139
150
|
});
|
|
140
151
|
|
|
@@ -148,6 +159,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
148
159
|
assert.equal(
|
|
149
160
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
150
161
|
remove_whitespace(`export type test_collection = {
|
|
162
|
+
"_id": string
|
|
151
163
|
"test": string
|
|
152
164
|
}`)
|
|
153
165
|
)
|
|
@@ -155,6 +167,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
155
167
|
|
|
156
168
|
it(`should be able to generate a plain object containing a nullable string`, async function () {
|
|
157
169
|
const validate_test_collection = z.object({
|
|
170
|
+
_id: z_mongodb_id,
|
|
158
171
|
test: z.nullable(z.string()),
|
|
159
172
|
});
|
|
160
173
|
|
|
@@ -168,6 +181,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
168
181
|
assert.equal(
|
|
169
182
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
170
183
|
remove_whitespace(`export type test_collection = {
|
|
184
|
+
"_id": string
|
|
171
185
|
"test": string | null
|
|
172
186
|
}`)
|
|
173
187
|
)
|
|
@@ -175,6 +189,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
175
189
|
|
|
176
190
|
it(`should be able to generate a plain object containing union types`, async function () {
|
|
177
191
|
const validate_test_collection = z.object({
|
|
192
|
+
_id: z_mongodb_id,
|
|
178
193
|
test: z.string().or(z.number()),
|
|
179
194
|
});
|
|
180
195
|
|
|
@@ -188,6 +203,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
188
203
|
assert.equal(
|
|
189
204
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
190
205
|
remove_whitespace(`export type test_collection = {
|
|
206
|
+
"_id": string
|
|
191
207
|
"test": string | number
|
|
192
208
|
}`)
|
|
193
209
|
)
|
|
@@ -195,6 +211,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
195
211
|
|
|
196
212
|
it(`should be able to generate a plain object containing union types wrapped in nullable`, async function () {
|
|
197
213
|
const validate_test_collection = z.object({
|
|
214
|
+
_id: z_mongodb_id,
|
|
198
215
|
test: z.nullable(z.string().or(z.number())),
|
|
199
216
|
});
|
|
200
217
|
|
|
@@ -208,6 +225,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
208
225
|
assert.equal(
|
|
209
226
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
210
227
|
remove_whitespace(`export type test_collection = {
|
|
228
|
+
"_id": string
|
|
211
229
|
"test": string | number | null
|
|
212
230
|
}`)
|
|
213
231
|
)
|
|
@@ -215,6 +233,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
215
233
|
|
|
216
234
|
it(`should be able to generate a plain object containing union of object types`, async function () {
|
|
217
235
|
const validate_test_collection = z.object({
|
|
236
|
+
_id: z_mongodb_id,
|
|
218
237
|
test: z.object({
|
|
219
238
|
sub: z.string()
|
|
220
239
|
}).or(z.object({
|
|
@@ -232,6 +251,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
232
251
|
assert.equal(
|
|
233
252
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
234
253
|
remove_whitespace(`export type test_collection = {
|
|
254
|
+
"_id": string
|
|
235
255
|
"test": {"sub": string} | {"sub2": number}
|
|
236
256
|
}`)
|
|
237
257
|
)
|
|
@@ -239,6 +259,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
239
259
|
|
|
240
260
|
it(`should be able to generate an enum`, async function () {
|
|
241
261
|
const validate_test_collection = z.object({
|
|
262
|
+
_id: z_mongodb_id,
|
|
242
263
|
test: z.enum(["red", "green", "blue"]),
|
|
243
264
|
});
|
|
244
265
|
|
|
@@ -252,6 +273,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
252
273
|
assert.equal(
|
|
253
274
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
254
275
|
remove_whitespace(`export type test_collection = {
|
|
276
|
+
"_id": string
|
|
255
277
|
"test": ("red" | "green" | "blue")
|
|
256
278
|
}`)
|
|
257
279
|
)
|
|
@@ -259,6 +281,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
259
281
|
|
|
260
282
|
it(`should be able to generate an array of enum`, async function () {
|
|
261
283
|
const validate_test_collection = z.object({
|
|
284
|
+
_id: z_mongodb_id,
|
|
262
285
|
test: z.array(z.enum(["red", "green", "blue"])),
|
|
263
286
|
});
|
|
264
287
|
|
|
@@ -272,6 +295,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
272
295
|
assert.equal(
|
|
273
296
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
274
297
|
remove_whitespace(`export type test_collection = {
|
|
298
|
+
"_id": string
|
|
275
299
|
"test": ("red" | "green" | "blue")[]
|
|
276
300
|
}`)
|
|
277
301
|
)
|
|
@@ -279,6 +303,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
279
303
|
|
|
280
304
|
it(`should be able to generate a plain nested object`, async function () {
|
|
281
305
|
const validate_test_collection = z.object({
|
|
306
|
+
_id: z_mongodb_id,
|
|
282
307
|
test: z.object({
|
|
283
308
|
}),
|
|
284
309
|
});
|
|
@@ -293,6 +318,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
293
318
|
assert.equal(
|
|
294
319
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
295
320
|
remove_whitespace(`export type test_collection = {
|
|
321
|
+
"_id": string
|
|
296
322
|
"test": {}
|
|
297
323
|
}`)
|
|
298
324
|
)
|
|
@@ -300,6 +326,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
300
326
|
|
|
301
327
|
it(`should be able to generate a plain nested with basic fields`, async function () {
|
|
302
328
|
const validate_test_collection = z.object({
|
|
329
|
+
_id: z_mongodb_id,
|
|
303
330
|
test: z.object({
|
|
304
331
|
field_string: z.string(),
|
|
305
332
|
field_number: z.number(),
|
|
@@ -321,6 +348,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
321
348
|
assert.equal(
|
|
322
349
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
323
350
|
remove_whitespace(`export type test_collection = {
|
|
351
|
+
"_id": string
|
|
324
352
|
"test": {
|
|
325
353
|
"field_string": string
|
|
326
354
|
"field_number": number
|
|
@@ -336,6 +364,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
336
364
|
|
|
337
365
|
it(`should be able to generate arrays of primitive fields`, async function () {
|
|
338
366
|
const validate_test_collection = z.object({
|
|
367
|
+
_id: z_mongodb_id,
|
|
339
368
|
field_string: z.array(z.string()),
|
|
340
369
|
field_number: z.array(z.number()),
|
|
341
370
|
field_boolean: z.array(z.boolean()),
|
|
@@ -352,6 +381,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
352
381
|
assert.equal(
|
|
353
382
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
354
383
|
remove_whitespace(`export type test_collection = {
|
|
384
|
+
"_id": string
|
|
355
385
|
"field_string": string[]
|
|
356
386
|
"field_number": number[]
|
|
357
387
|
"field_boolean": boolean[]
|
|
@@ -362,6 +392,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
362
392
|
|
|
363
393
|
it(`should be able to generate arrays of objects containing primitive fields`, async function () {
|
|
364
394
|
const validate_test_collection = z.object({
|
|
395
|
+
_id: z_mongodb_id,
|
|
365
396
|
field_array: z.array(z.object({
|
|
366
397
|
field_string: z.array(z.string()),
|
|
367
398
|
field_number: z.array(z.number()),
|
|
@@ -381,6 +412,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
381
412
|
assert.equal(
|
|
382
413
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
383
414
|
remove_whitespace(`export type test_collection = {
|
|
415
|
+
"_id": string
|
|
384
416
|
"field_array": {
|
|
385
417
|
"field_string": string[]
|
|
386
418
|
"field_number": number[]
|
|
@@ -393,6 +425,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
393
425
|
|
|
394
426
|
it(`should be able to generate nested arrays`, async function () {
|
|
395
427
|
const validate_test_collection = z.object({
|
|
428
|
+
_id: z_mongodb_id,
|
|
396
429
|
field_array: z.array(
|
|
397
430
|
z.array(z.object({
|
|
398
431
|
field_string: z.array(z.string()),
|
|
@@ -413,6 +446,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
413
446
|
assert.equal(
|
|
414
447
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
415
448
|
remove_whitespace(`export type test_collection = {
|
|
449
|
+
"_id": string
|
|
416
450
|
"field_array": {
|
|
417
451
|
"field_string": string[]
|
|
418
452
|
"field_number": number[]
|
|
@@ -425,6 +459,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
425
459
|
|
|
426
460
|
it(`should be able to generate a plain object containing a primitive with a default`, async function () {
|
|
427
461
|
const validate_test_collection = z.object({
|
|
462
|
+
_id: z_mongodb_id,
|
|
428
463
|
test: z.string().default('ezikiel snograss'),
|
|
429
464
|
});
|
|
430
465
|
|
|
@@ -438,6 +473,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
438
473
|
assert.equal(
|
|
439
474
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
440
475
|
remove_whitespace(`export type test_collection = {
|
|
476
|
+
"_id": string
|
|
441
477
|
"test"?: string
|
|
442
478
|
}`)
|
|
443
479
|
)
|
|
@@ -445,6 +481,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
445
481
|
|
|
446
482
|
it(`should be able to generate a plain object containing an optional primitive`, async function () {
|
|
447
483
|
const validate_test_collection = z.object({
|
|
484
|
+
_id: z_mongodb_id,
|
|
448
485
|
test: z.string().optional(),
|
|
449
486
|
});
|
|
450
487
|
|
|
@@ -458,6 +495,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
458
495
|
assert.equal(
|
|
459
496
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
460
497
|
remove_whitespace(`export type test_collection = {
|
|
498
|
+
"_id": string
|
|
461
499
|
"test"?: string
|
|
462
500
|
}`)
|
|
463
501
|
)
|
|
@@ -465,6 +503,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
465
503
|
|
|
466
504
|
it(`should be able to generate a plain object containing a record`, async function () {
|
|
467
505
|
const validate_test_collection = z.object({
|
|
506
|
+
_id: z_mongodb_id,
|
|
468
507
|
test: z.record(z.string(), z.string())
|
|
469
508
|
});
|
|
470
509
|
|
|
@@ -478,6 +517,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
478
517
|
assert.equal(
|
|
479
518
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
480
519
|
remove_whitespace(`export type test_collection = {
|
|
520
|
+
"_id": string
|
|
481
521
|
"test": {[key: string]: string}
|
|
482
522
|
}`)
|
|
483
523
|
)
|
|
@@ -486,6 +526,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
486
526
|
|
|
487
527
|
it(`should be able to generate a plain object containing an object record`, async function () {
|
|
488
528
|
const validate_test_collection = z.object({
|
|
529
|
+
_id: z_mongodb_id,
|
|
489
530
|
test: z.record(z.string(), z.object({
|
|
490
531
|
test_2: z.string()
|
|
491
532
|
}))
|
|
@@ -501,6 +542,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
501
542
|
assert.equal(
|
|
502
543
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
503
544
|
remove_whitespace(`export type test_collection = {
|
|
545
|
+
"_id": string
|
|
504
546
|
"test": {[key: string]: { "test_2": string }}
|
|
505
547
|
}`)
|
|
506
548
|
)
|
|
@@ -508,6 +550,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
508
550
|
|
|
509
551
|
it(`should be able to generate a plain object containing an array record`, async function () {
|
|
510
552
|
const validate_test_collection = z.object({
|
|
553
|
+
_id: z_mongodb_id,
|
|
511
554
|
test: z.record(z.string(), z.array(z.string()))
|
|
512
555
|
});
|
|
513
556
|
|
|
@@ -521,6 +564,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
521
564
|
assert.equal(
|
|
522
565
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
523
566
|
remove_whitespace(`export type test_collection = {
|
|
567
|
+
"_id": string
|
|
524
568
|
"test": {[key: string]: string[]}
|
|
525
569
|
}`)
|
|
526
570
|
)
|
|
@@ -535,6 +579,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
535
579
|
}).meta({id: 'test_recursive_object'})
|
|
536
580
|
|
|
537
581
|
const validate_test_collection = z.object({
|
|
582
|
+
_id: z_mongodb_id,
|
|
538
583
|
test: recursive
|
|
539
584
|
});
|
|
540
585
|
|
|
@@ -548,6 +593,7 @@ describe('Client Library Generation: Basic Types', function () {
|
|
|
548
593
|
assert.equal(
|
|
549
594
|
remove_whitespace(await readFile('./test/tmp/src/types/test_collection.ts', { encoding: 'utf-8' })),
|
|
550
595
|
remove_whitespace(`export type test_collection = {
|
|
596
|
+
"_id": string
|
|
551
597
|
"test": type_test_recursive_object
|
|
552
598
|
}
|
|
553
599
|
type type_test_recursive_object = {
|
|
@@ -45,7 +45,9 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
it(`should be able to generate a query for a plain object`, async function () {
|
|
48
|
-
const validate_test_collection = z.object({
|
|
48
|
+
const validate_test_collection = z.object({
|
|
49
|
+
_id: z_mongodb_id,
|
|
50
|
+
});
|
|
49
51
|
|
|
50
52
|
let test_collection = new F_Collection('test_collection', 'test_collection', validate_test_collection);
|
|
51
53
|
|
|
@@ -60,13 +62,18 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
60
62
|
"limit"?: number
|
|
61
63
|
"cursor"?: string
|
|
62
64
|
"sort_order"?: ("ascending" | "descending")
|
|
63
|
-
"
|
|
65
|
+
"_id"?: string
|
|
66
|
+
"_id_gt"?: string
|
|
67
|
+
"_id_lt"?: string
|
|
68
|
+
"_id_in"?: string[]
|
|
69
|
+
"sort"?: ("_id")
|
|
64
70
|
}`)
|
|
65
71
|
)
|
|
66
72
|
});
|
|
67
73
|
|
|
68
74
|
it(`should be able to generate a plain object containing a string`, async function () {
|
|
69
75
|
const validate_test_collection = z.object({
|
|
76
|
+
_id: z_mongodb_id,
|
|
70
77
|
test: z.string(),
|
|
71
78
|
});
|
|
72
79
|
|
|
@@ -83,17 +90,22 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
83
90
|
"limit"?: number
|
|
84
91
|
"cursor"?: string
|
|
85
92
|
"sort_order"?: ("ascending" | "descending")
|
|
93
|
+
"_id"?: string
|
|
94
|
+
"_id_gt"?: string
|
|
95
|
+
"_id_lt"?: string
|
|
96
|
+
"_id_in"?: string[]
|
|
86
97
|
"test"?: string
|
|
87
98
|
"test_gt"?: string
|
|
88
99
|
"test_lt"?: string
|
|
89
100
|
"test_in"?: string[]
|
|
90
|
-
"sort"?: ("test")
|
|
101
|
+
"sort"?: ("_id" | "test")
|
|
91
102
|
}`)
|
|
92
103
|
)
|
|
93
104
|
});
|
|
94
105
|
|
|
95
106
|
it(`should be able to generate a plain object containing a number`, async function () {
|
|
96
107
|
const validate_test_collection = z.object({
|
|
108
|
+
_id: z_mongodb_id,
|
|
97
109
|
test: z.number(),
|
|
98
110
|
});
|
|
99
111
|
|
|
@@ -110,18 +122,23 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
110
122
|
"limit"?: number
|
|
111
123
|
"cursor"?: string
|
|
112
124
|
"sort_order"?: ("ascending" | "descending")
|
|
125
|
+
"_id"?: string
|
|
126
|
+
"_id_gt"?: string
|
|
127
|
+
"_id_lt"?: string
|
|
128
|
+
"_id_in"?: string[]
|
|
113
129
|
"test"?: number
|
|
114
130
|
"test_gt"?: number
|
|
115
131
|
"test_gte"?: number
|
|
116
132
|
"test_lt"?: number
|
|
117
133
|
"test_lte"?: number
|
|
118
|
-
"sort"?: ("test")
|
|
134
|
+
"sort"?: ("_id" | "test")
|
|
119
135
|
}`)
|
|
120
136
|
)
|
|
121
137
|
});
|
|
122
138
|
|
|
123
139
|
it(`should be able to generate a plain object containing a boolean`, async function () {
|
|
124
140
|
const validate_test_collection = z.object({
|
|
141
|
+
_id: z_mongodb_id,
|
|
125
142
|
test: z.boolean(),
|
|
126
143
|
});
|
|
127
144
|
|
|
@@ -138,14 +155,19 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
138
155
|
"limit"?: number
|
|
139
156
|
"cursor"?: string
|
|
140
157
|
"sort_order"?: ("ascending" | "descending")
|
|
158
|
+
"_id"?: string
|
|
159
|
+
"_id_gt"?: string
|
|
160
|
+
"_id_lt"?: string
|
|
161
|
+
"_id_in"?: string[]
|
|
141
162
|
"test"?: boolean
|
|
142
|
-
"sort"?: ("test")
|
|
163
|
+
"sort"?: ("_id" | "test")
|
|
143
164
|
}`)
|
|
144
165
|
)
|
|
145
166
|
});
|
|
146
167
|
|
|
147
168
|
it(`should be able to generate a plain object containing a date`, async function () {
|
|
148
169
|
const validate_test_collection = z.object({
|
|
170
|
+
_id: z_mongodb_id,
|
|
149
171
|
test: z.date(),
|
|
150
172
|
});
|
|
151
173
|
|
|
@@ -162,43 +184,21 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
162
184
|
"limit"?: number
|
|
163
185
|
"cursor"?: string
|
|
164
186
|
"sort_order"?: ("ascending" | "descending")
|
|
187
|
+
"_id"?: string
|
|
188
|
+
"_id_gt"?: string
|
|
189
|
+
"_id_lt"?: string
|
|
190
|
+
"_id_in"?: string[]
|
|
165
191
|
"test"?: Date
|
|
166
192
|
"test_gt"?: Date
|
|
167
193
|
"test_lt"?: Date
|
|
168
|
-
"sort"?: ("test")
|
|
169
|
-
}`)
|
|
170
|
-
)
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it(`should be able to generate a plain object containing an objectID`, async function () {
|
|
174
|
-
const validate_test_collection = z.object({
|
|
175
|
-
test: z_mongodb_id,
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
let test_collection = new F_Collection('test_collection', 'test_collection', validate_test_collection);
|
|
179
|
-
|
|
180
|
-
let proto_registry = new F_Collection_Registry();
|
|
181
|
-
let registry = proto_registry.register(test_collection);
|
|
182
|
-
|
|
183
|
-
await generate_client_library('./test/tmp', registry);
|
|
184
|
-
|
|
185
|
-
assert.equal(
|
|
186
|
-
remove_whitespace(await readFile('./test/tmp/src/types/test_collection_query.ts', { encoding: 'utf-8' })),
|
|
187
|
-
remove_whitespace(`export type test_collection_query = {
|
|
188
|
-
"limit"?: number
|
|
189
|
-
"cursor"?: string
|
|
190
|
-
"sort_order"?: ("ascending" | "descending")
|
|
191
|
-
"test"?: string
|
|
192
|
-
"test_gt"?: string
|
|
193
|
-
"test_lt"?: string
|
|
194
|
-
"test_in"?: string[]
|
|
195
|
-
"sort"?: ("test")
|
|
194
|
+
"sort"?: ("_id" | "test")
|
|
196
195
|
}`)
|
|
197
196
|
)
|
|
198
197
|
});
|
|
199
198
|
|
|
200
199
|
it(`should be able to generate an enum`, async function () {
|
|
201
200
|
const validate_test_collection = z.object({
|
|
201
|
+
_id: z_mongodb_id,
|
|
202
202
|
test: z.enum(["red", "green", "blue"]),
|
|
203
203
|
});
|
|
204
204
|
|
|
@@ -215,9 +215,13 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
215
215
|
"limit"?: number
|
|
216
216
|
"cursor"?: string
|
|
217
217
|
"sort_order"?: ("ascending" | "descending")
|
|
218
|
+
"_id"?: string
|
|
219
|
+
"_id_gt"?: string
|
|
220
|
+
"_id_lt"?: string
|
|
221
|
+
"_id_in"?: string[]
|
|
218
222
|
"test"?: ("red" | "green" | "blue")
|
|
219
223
|
"test_in"?: ("red" | "green" | "blue")[]
|
|
220
|
-
"sort"?: ("test")
|
|
224
|
+
"sort"?: ("_id" | "test")
|
|
221
225
|
}`)
|
|
222
226
|
)
|
|
223
227
|
});
|
|
@@ -226,6 +230,7 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
226
230
|
|
|
227
231
|
it(`should be able to generate a plain nested object`, async function () {
|
|
228
232
|
const validate_test_collection = z.object({
|
|
233
|
+
_id: z_mongodb_id,
|
|
229
234
|
test: z.object({
|
|
230
235
|
}),
|
|
231
236
|
});
|
|
@@ -243,13 +248,18 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
243
248
|
"limit"?: number
|
|
244
249
|
"cursor"?: string
|
|
245
250
|
"sort_order"?: ("ascending" | "descending")
|
|
246
|
-
"
|
|
251
|
+
"_id"?: string
|
|
252
|
+
"_id_gt"?: string
|
|
253
|
+
"_id_lt"?: string
|
|
254
|
+
"_id_in"?: string[]
|
|
255
|
+
"sort"?: ("_id")
|
|
247
256
|
}`)
|
|
248
257
|
)
|
|
249
258
|
});
|
|
250
259
|
|
|
251
260
|
it(`should be able to generate a plain nested with basic fields`, async function () {
|
|
252
261
|
const validate_test_collection = z.object({
|
|
262
|
+
_id: z_mongodb_id,
|
|
253
263
|
test: z.object({
|
|
254
264
|
field_string: z.string(),
|
|
255
265
|
field_number: z.number(),
|
|
@@ -275,6 +285,11 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
275
285
|
"cursor"?: string
|
|
276
286
|
"sort_order"?: ("ascending" | "descending")
|
|
277
287
|
|
|
288
|
+
"_id"?: string
|
|
289
|
+
"_id_gt"?: string
|
|
290
|
+
"_id_lt"?: string
|
|
291
|
+
"_id_in"?: string[]
|
|
292
|
+
|
|
278
293
|
"test.field_string"?: string
|
|
279
294
|
"test.field_string_gt"?: string
|
|
280
295
|
"test.field_string_lt"?: string
|
|
@@ -293,13 +308,14 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
293
308
|
"test.field_date_lt"?: Date
|
|
294
309
|
|
|
295
310
|
"test.test_2.field_doublenested"?: boolean
|
|
296
|
-
"sort"?: ("test.field_string" | "test.field_number" | "test.field_boolean" | "test.field_date" | "test.test_2.field_doublenested")
|
|
311
|
+
"sort"?: ("_id" | "test.field_string" | "test.field_number" | "test.field_boolean" | "test.field_date" | "test.test_2.field_doublenested")
|
|
297
312
|
}`)
|
|
298
313
|
)
|
|
299
314
|
});
|
|
300
315
|
|
|
301
316
|
it(`should be able to generate arrays of primitive fields`, async function () {
|
|
302
317
|
const validate_test_collection = z.object({
|
|
318
|
+
_id: z_mongodb_id,
|
|
303
319
|
field_string: z.array(z.string()),
|
|
304
320
|
field_number: z.array(z.number()),
|
|
305
321
|
field_boolean: z.array(z.boolean()),
|
|
@@ -318,16 +334,21 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
318
334
|
"limit"?: number
|
|
319
335
|
"cursor"?: string
|
|
320
336
|
"sort_order"?: ("ascending" | "descending")
|
|
337
|
+
"_id"?: string
|
|
338
|
+
"_id_gt"?: string
|
|
339
|
+
"_id_lt"?: string
|
|
340
|
+
"_id_in"?: string[]
|
|
321
341
|
"field_string"?: string
|
|
322
342
|
"field_number"?: number
|
|
323
343
|
"field_boolean"?: boolean
|
|
324
|
-
"sort"?: ("field_string" | "field_number" | "field_boolean")
|
|
344
|
+
"sort"?: ("_id" | "field_string" | "field_number" | "field_boolean")
|
|
325
345
|
}`)
|
|
326
346
|
)
|
|
327
347
|
});
|
|
328
348
|
|
|
329
349
|
it(`should be able to generate a plain object containing a primitive with a default`, async function () {
|
|
330
350
|
const validate_test_collection = z.object({
|
|
351
|
+
_id: z_mongodb_id,
|
|
331
352
|
test: z.boolean().default(true),
|
|
332
353
|
});
|
|
333
354
|
|
|
@@ -344,8 +365,12 @@ describe('Client Library Generation: Query Types', function () {
|
|
|
344
365
|
"limit"?: number
|
|
345
366
|
"cursor"?: string
|
|
346
367
|
"sort_order"?: ("ascending" | "descending")
|
|
368
|
+
"_id"?: string
|
|
369
|
+
"_id_gt"?: string
|
|
370
|
+
"_id_lt"?: string
|
|
371
|
+
"_id_in"?: string[]
|
|
347
372
|
"test"?: boolean
|
|
348
|
-
"sort"?: ("test")
|
|
373
|
+
"sort"?: ("_id" | "test")
|
|
349
374
|
}`)
|
|
350
375
|
)
|
|
351
376
|
});
|