corebasic 1.0.262 → 1.0.263
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/libs/features.js +4 -4
- package/libs/features.ts +5 -5
- package/package.json +1 -1
package/dist/libs/features.js
CHANGED
|
@@ -182,9 +182,9 @@ const apiHandler = async (req, res) => {
|
|
|
182
182
|
meta.outlet = 'DEFAULT_OUTLET';
|
|
183
183
|
}
|
|
184
184
|
meta.txn = meta.txn ?? Utils.uid();
|
|
185
|
-
function buildQuery(
|
|
186
|
-
|
|
187
|
-
const array_paths =
|
|
185
|
+
function buildQuery(opt, id) {
|
|
186
|
+
opt = opt ? opt : "_id";
|
|
187
|
+
const array_paths = opt.split(".$.");
|
|
188
188
|
const last_path = array_paths.pop();
|
|
189
189
|
const query = {};
|
|
190
190
|
let obj = query;
|
|
@@ -204,7 +204,7 @@ 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?.
|
|
207
|
+
query: req.body.params?.opt && (feature.opt)?.includes(req.body.params?.opt) ? buildQuery(req.body.params?.opt ?? "_id", req.body.params?.id) : req.body.params?.id ? { _id: req.body.params?.id } : undefined,
|
|
208
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,
|
|
209
209
|
};
|
|
210
210
|
const appReq = {
|
package/libs/features.ts
CHANGED
|
@@ -145,7 +145,7 @@ type RemoteFeatureEntry = {
|
|
|
145
145
|
headers?: {JWT?: string, service?: boolean, NDCURVE_DEVELOPER_LICENSE_ACCESS_TOKEN?: string}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
type FeatureEntry = { api: string, topic: string, bypass: boolean, featureless: boolean, subscribe: string, handler: Handler<unknown, unknown, keyof Schema>,
|
|
148
|
+
type FeatureEntry = { api: string, topic: string, bypass: boolean, featureless: boolean, subscribe: string, handler: Handler<unknown, unknown, keyof Schema>, opt?: string[], mut?: string[] }
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
let features: Record<string, FeatureEntry> = {}
|
|
@@ -312,9 +312,9 @@ const apiHandler = async (req: ExpressRequest, res: ExpressResponse) => {
|
|
|
312
312
|
meta.txn = meta.txn ?? Utils.uid()
|
|
313
313
|
|
|
314
314
|
|
|
315
|
-
function buildQuery(
|
|
316
|
-
|
|
317
|
-
const array_paths =
|
|
315
|
+
function buildQuery(opt: string, id: unknown): unknown {
|
|
316
|
+
opt = opt ? opt : "_id"
|
|
317
|
+
const array_paths = opt.split(".$.")
|
|
318
318
|
const last_path = array_paths.pop()
|
|
319
319
|
const query: Record<string, unknown> = {}
|
|
320
320
|
let obj = query
|
|
@@ -336,7 +336,7 @@ const apiHandler = async (req: ExpressRequest, res: ExpressResponse) => {
|
|
|
336
336
|
meta,
|
|
337
337
|
data: req.body.data,
|
|
338
338
|
params: featureless ? req.params : req.body.params!,
|
|
339
|
-
query: req.body.params?.
|
|
339
|
+
query: req.body.params?.opt && (feature.opt!)?.includes(req.body.params?.opt as string) ? buildQuery(req.body.params?.opt ?? "_id", req.body.params?.id) : req.body.params?.id ? {_id: req.body.params?.id} : undefined,
|
|
340
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
341
|
|
|
342
342
|
}
|