@lobb-js/core 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Lobb.ts +1 -0
- package/src/api/collections/CollectionControllers.ts +17 -0
- package/src/api/collections/collectionStore.ts +682 -24
- package/src/api/meta/service.ts +1 -0
- package/src/config/ConfigManager.ts +130 -7
- package/src/config/validations.ts +13 -5
- package/src/database/drivers/pgDriver/QueryBuilder.ts +3 -141
- package/src/index.ts +1 -1
- package/src/types/collectionServiceSchema.ts +61 -14
- package/src/types/config/collectionFields.ts +18 -0
- package/src/types/config/collectionsConfig.ts +5 -0
- package/src/types/config/relations.ts +22 -3
- package/src/types/index.ts +7 -3
- package/src/workflows/coreWorkflows/processors/hooksWorkflows.ts +29 -5
package/package.json
CHANGED
package/src/Lobb.ts
CHANGED
|
@@ -144,6 +144,7 @@ export class Lobb {
|
|
|
144
144
|
process.chdir(config.project.context ?? ".");
|
|
145
145
|
|
|
146
146
|
await Lobb.instance.extensionSystem.loadExtensionsCollections();
|
|
147
|
+
this.configManager.expandPolymorphicFields();
|
|
147
148
|
this.configManager.addUniqueIndexesFromFields();
|
|
148
149
|
this.configManager.addRelationsFromIntegerRefrences();
|
|
149
150
|
}
|
|
@@ -50,6 +50,7 @@ export const collectionControllers: CollectionControllers = {
|
|
|
50
50
|
collectionName,
|
|
51
51
|
context: c,
|
|
52
52
|
data: body.data,
|
|
53
|
+
children: body.children,
|
|
53
54
|
triggeredBy: "API",
|
|
54
55
|
});
|
|
55
56
|
|
|
@@ -72,6 +73,10 @@ export const collectionControllers: CollectionControllers = {
|
|
|
72
73
|
params = parseUrlQuery(c.req.url);
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
if (params) {
|
|
77
|
+
coerceNumericParams(params);
|
|
78
|
+
}
|
|
79
|
+
|
|
75
80
|
await Lobb.instance.eventSystem.emit(
|
|
76
81
|
"core.controllers.preFindAll",
|
|
77
82
|
{
|
|
@@ -116,6 +121,8 @@ export const collectionControllers: CollectionControllers = {
|
|
|
116
121
|
async findOne(c: Context) {
|
|
117
122
|
const collectionName = param(c, "collectionName");
|
|
118
123
|
const id = param(c, "id");
|
|
124
|
+
const rawQuery = parseUrlQuery(c.req.url);
|
|
125
|
+
const params = { ...rawQuery };
|
|
119
126
|
|
|
120
127
|
if (Lobb.instance.configManager.isCollectionSingleton(collectionName)) {
|
|
121
128
|
throw new LobbError({
|
|
@@ -149,6 +156,7 @@ export const collectionControllers: CollectionControllers = {
|
|
|
149
156
|
collectionName,
|
|
150
157
|
context: c,
|
|
151
158
|
id: id,
|
|
159
|
+
params,
|
|
152
160
|
triggeredBy: "API",
|
|
153
161
|
});
|
|
154
162
|
|
|
@@ -206,6 +214,7 @@ export const collectionControllers: CollectionControllers = {
|
|
|
206
214
|
context: c,
|
|
207
215
|
id,
|
|
208
216
|
data: body.data,
|
|
217
|
+
children: body.children,
|
|
209
218
|
triggeredBy: "API",
|
|
210
219
|
});
|
|
211
220
|
return c.json(result, 200);
|
|
@@ -483,3 +492,11 @@ export function parseUrlQuery(url: string) {
|
|
|
483
492
|
}
|
|
484
493
|
return {};
|
|
485
494
|
}
|
|
495
|
+
|
|
496
|
+
export function coerceNumericParams(params: Record<string, any>): void {
|
|
497
|
+
for (const key of ["limit", "offset", "page"]) {
|
|
498
|
+
if (params[key] !== undefined) {
|
|
499
|
+
params[key] = Number(params[key]);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|