@dnax/core 0.35.0 → 0.37.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/app/hono.ts +72 -10
- package/package.json +1 -1
- package/types/index.ts +17 -2
package/app/hono.ts
CHANGED
|
@@ -564,33 +564,95 @@ function HonoInstance(): typeof app {
|
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
566
|
|
|
567
|
+
// if select is array
|
|
567
568
|
if (
|
|
568
|
-
col?.api?.fields?.select
|
|
569
|
-
|
|
569
|
+
col?.api?.fields?.select &&
|
|
570
|
+
typeof col?.api?.fields?.select == "object" &&
|
|
571
|
+
Array.isArray(col?.api?.fields?.select)
|
|
570
572
|
) {
|
|
573
|
+
const selectedFields = [];
|
|
571
574
|
if (body?.withMeta) {
|
|
572
|
-
|
|
573
|
-
response.data = pick(response.data, col?.api?.fields?.select || []);
|
|
574
|
-
} catch (err) {}
|
|
575
|
+
response.data = pick(response.data, col?.api?.fields?.select);
|
|
575
576
|
} else {
|
|
576
|
-
response = pick(response, col?.api?.fields?.select
|
|
577
|
+
response = pick(response, col?.api?.fields?.select);
|
|
577
578
|
}
|
|
578
579
|
}
|
|
580
|
+
// if select is function
|
|
581
|
+
if (
|
|
582
|
+
col?.api?.fields?.select &&
|
|
583
|
+
typeof col?.api?.fields?.select == "function"
|
|
584
|
+
) {
|
|
585
|
+
let selectedFields = [];
|
|
586
|
+
if (body?.withMeta) {
|
|
587
|
+
selectedFields = await col?.api?.fields?.select({
|
|
588
|
+
action: action,
|
|
589
|
+
c: c,
|
|
590
|
+
rest: rest,
|
|
591
|
+
session: sessionStorage() as any,
|
|
592
|
+
});
|
|
593
|
+
selectedFields = [...new Set(selectedFields)];
|
|
594
|
+
response.data = pick(response.data, selectedFields);
|
|
595
|
+
} else {
|
|
596
|
+
selectedFields = await col?.api?.fields?.select({
|
|
597
|
+
action: action,
|
|
598
|
+
c: c,
|
|
599
|
+
rest: rest,
|
|
600
|
+
session: sessionStorage() as any,
|
|
601
|
+
});
|
|
602
|
+
selectedFields = [...new Set(selectedFields)];
|
|
603
|
+
response = pick(response, selectedFields);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// hidden is array
|
|
579
608
|
if (
|
|
580
609
|
col?.api?.fields?.hidden?.length &&
|
|
581
|
-
Array.isArray(col?.api?.fields?.hidden
|
|
610
|
+
Array.isArray(col?.api?.fields?.hidden)
|
|
582
611
|
) {
|
|
583
612
|
let privateFields = col?.api?.fields?.hidden || [];
|
|
584
613
|
privateFields.push("password");
|
|
614
|
+
privateFields = [...new Set(privateFields)];
|
|
585
615
|
if (body?.withMeta) {
|
|
586
616
|
// If use Meta are included
|
|
587
617
|
try {
|
|
588
618
|
response.data = omit(response.data, privateFields);
|
|
589
619
|
} catch (e) {}
|
|
620
|
+
} else {
|
|
621
|
+
response = omit(response, privateFields);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// hidden is function
|
|
626
|
+
if (
|
|
627
|
+
col?.api?.fields?.hidden?.length &&
|
|
628
|
+
typeof col?.api?.fields?.hidden == "function"
|
|
629
|
+
) {
|
|
630
|
+
let privateFields = [];
|
|
631
|
+
|
|
632
|
+
if (body?.withMeta) {
|
|
633
|
+
// If use Meta are included
|
|
634
|
+
try {
|
|
635
|
+
privateFields = await col?.api?.fields?.hidden({
|
|
636
|
+
action: action,
|
|
637
|
+
c: c,
|
|
638
|
+
rest: rest,
|
|
639
|
+
session: sessionStorage() as any,
|
|
640
|
+
});
|
|
641
|
+
privateFields.push("password");
|
|
642
|
+
privateFields = [...new Set(privateFields)];
|
|
643
|
+
response.data = omit(response.data, privateFields);
|
|
644
|
+
} catch (e) {}
|
|
645
|
+
} else {
|
|
646
|
+
privateFields = await col?.api?.fields?.hidden({
|
|
647
|
+
action: action,
|
|
648
|
+
c: c,
|
|
649
|
+
rest: rest,
|
|
650
|
+
session: sessionStorage() as any,
|
|
651
|
+
});
|
|
652
|
+
privateFields.push("password");
|
|
653
|
+
privateFields = [...new Set(privateFields)];
|
|
654
|
+
response = omit(response, privateFields);
|
|
590
655
|
}
|
|
591
|
-
response = omit(response, privateFields);
|
|
592
|
-
} else {
|
|
593
|
-
response = omit(response, ["password"]);
|
|
594
656
|
}
|
|
595
657
|
|
|
596
658
|
return c.json(response);
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -51,6 +51,7 @@ export type Actions =
|
|
|
51
51
|
| "updateMany"
|
|
52
52
|
| "deleteOne"
|
|
53
53
|
| "deleteMany"
|
|
54
|
+
| "authCollection"
|
|
54
55
|
| "aggregate";
|
|
55
56
|
|
|
56
57
|
export type Field = {
|
|
@@ -352,8 +353,22 @@ export type Collection = {
|
|
|
352
353
|
api?: {
|
|
353
354
|
//privateFields?: string[];
|
|
354
355
|
fields: {
|
|
355
|
-
select?:
|
|
356
|
-
|
|
356
|
+
select?:
|
|
357
|
+
| string[]
|
|
358
|
+
| ((ctx: {
|
|
359
|
+
action: Actions;
|
|
360
|
+
c: Context;
|
|
361
|
+
rest: InstanceType<typeof useRest>;
|
|
362
|
+
session: sessionCtx;
|
|
363
|
+
}) => string[]);
|
|
364
|
+
hidden?:
|
|
365
|
+
| string[]
|
|
366
|
+
| ((ctx: {
|
|
367
|
+
action: Actions;
|
|
368
|
+
c: Context;
|
|
369
|
+
rest: InstanceType<typeof useRest>;
|
|
370
|
+
session: sessionCtx;
|
|
371
|
+
}) => string[]);
|
|
357
372
|
};
|
|
358
373
|
};
|
|
359
374
|
allow?: ["dropCollection", "renameCollection"];
|