corebasic 1.0.260 → 1.0.261

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.
@@ -204,7 +204,8 @@ const apiHandler = async (req, res) => {
204
204
  meta,
205
205
  data: req.body.data,
206
206
  params: featureless ? req.params : req.body.params,
207
- query: req.body.params?.key && (feature.key)?.includes(req.body.params?.key) ? buildQuery(req.body.params?.key ?? "_id", req.body.params?.id) : req.body.params?.id ? { _id: req.body.params?.id } : undefined
207
+ query: req.body.params?.key && (feature.key)?.includes(req.body.params?.key) ? buildQuery(req.body.params?.key ?? "_id", req.body.params?.id) : req.body.params?.id ? { _id: req.body.params?.id } : undefined,
208
+ update: req.body.params?.mut && (feature.mut)?.includes(req.body.params?.mut) ? { $set: { [req.body.params.mut]: req.body.data[req.body.params.mut], ...Dip.updateKeys({ meta }) } } : undefined,
208
209
  };
209
210
  const appReq = {
210
211
  meta: message.meta,
package/libs/features.ts CHANGED
@@ -64,6 +64,7 @@ type FeatureMessage<I = unknown, T extends keyof Schema = keyof Schema> = {
64
64
  data: I
65
65
  params: FeatureParams
66
66
  query?: unknown // This is the buildQuery not the express query
67
+ update?: unknown // This is the buildUpdate
67
68
 
68
69
  // feature // Only used as req.body.feature in features.ts, session.ts
69
70
  // client // Only used as req.body.client in auth.ts, session.ts and messaging.ts
@@ -144,7 +145,7 @@ type RemoteFeatureEntry = {
144
145
  headers?: {JWT?: string, service?: boolean, NDCURVE_DEVELOPER_LICENSE_ACCESS_TOKEN?: string}
145
146
  }
146
147
 
147
- type FeatureEntry = { api: string, topic: string, bypass: boolean, featureless: boolean, subscribe: string, handler: Handler<unknown, unknown, keyof Schema>, key?: string[] }
148
+ type FeatureEntry = { api: string, topic: string, bypass: boolean, featureless: boolean, subscribe: string, handler: Handler<unknown, unknown, keyof Schema>, key?: string[], mut?: string[] }
148
149
 
149
150
 
150
151
  let features: Record<string, FeatureEntry> = {}
@@ -335,7 +336,9 @@ const apiHandler = async (req: ExpressRequest, res: ExpressResponse) => {
335
336
  meta,
336
337
  data: req.body.data,
337
338
  params: featureless ? req.params : req.body.params!,
338
- query: req.body.params?.key && (feature.key!)?.includes(req.body.params?.key as string) ? buildQuery(req.body.params?.key ?? "_id", req.body.params?.id) : req.body.params?.id ? {_id: req.body.params?.id} : undefined
339
+ query: req.body.params?.key && (feature.key!)?.includes(req.body.params?.key as string) ? buildQuery(req.body.params?.key ?? "_id", req.body.params?.id) : req.body.params?.id ? {_id: req.body.params?.id} : undefined,
340
+ update: req.body.params?.mut && (feature.mut!)?.includes(req.body.params?.mut as string) ? { $set: { [req.body.params!.mut]: (req.body.data as Record<string, unknown>)[req.body.params!.mut], ...Dip.updateKeys({meta}) } } : undefined,
341
+
339
342
  }
340
343
 
341
344
  const appReq: Req = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.260",
4
+ "version": "1.0.261",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "./index.ts",