@lobb-js/core 0.22.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lobb-js/core",
3
3
  "license": "UNLICENSED",
4
- "version": "0.22.1",
4
+ "version": "0.24.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"
package/src/Lobb.ts CHANGED
@@ -144,6 +144,8 @@ export class Lobb {
144
144
  process.chdir(config.project.context ?? ".");
145
145
 
146
146
  await Lobb.instance.extensionSystem.loadExtensionsCollections();
147
+ this.configManager.expandPolymorphicFields();
148
+ this.configManager.addUniqueIndexesFromFields();
147
149
  this.configManager.addRelationsFromIntegerRefrences();
148
150
  }
149
151
  }
@@ -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
+ }