@dnax/core 0.33.0 → 0.34.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 +17 -3
- package/driver/mongo/rest.ts +1 -1
- package/package.json +1 -1
- package/types/index.ts +7 -1
- package/utils/index.ts +4 -4
package/app/hono.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
jwt,
|
|
21
21
|
fn,
|
|
22
22
|
omit,
|
|
23
|
+
pick,
|
|
23
24
|
stringToBoolean,
|
|
24
25
|
} from "../utils";
|
|
25
26
|
import { getAction } from "./ctrl";
|
|
@@ -31,7 +32,7 @@ import { getService } from "../lib/service";
|
|
|
31
32
|
import { bentoCache, bentoKey } from "../lib/bento";
|
|
32
33
|
import { MediaDrive } from "../lib/media";
|
|
33
34
|
import { isStudio } from "../lib/studio";
|
|
34
|
-
|
|
35
|
+
|
|
35
36
|
import { secureHeaders } from "hono/secure-headers";
|
|
36
37
|
import { getTenant } from "../lib/tenant";
|
|
37
38
|
import { checkPermission, getPermission } from "../lib/permissions";
|
|
@@ -563,8 +564,21 @@ function HonoInstance(): typeof app {
|
|
|
563
564
|
}
|
|
564
565
|
}
|
|
565
566
|
|
|
566
|
-
if (
|
|
567
|
-
|
|
567
|
+
if (
|
|
568
|
+
col?.api?.fields?.select?.length &&
|
|
569
|
+
Array.isArray(col?.api?.fields?.select?.length)
|
|
570
|
+
) {
|
|
571
|
+
response = pick(response, col?.api?.fields?.select || []);
|
|
572
|
+
}
|
|
573
|
+
if (
|
|
574
|
+
col?.api?.fields?.hidden?.length &&
|
|
575
|
+
Array.isArray(col?.api?.fields?.hidden?.length)
|
|
576
|
+
) {
|
|
577
|
+
let privateFields = col?.api?.fields?.hidden || [];
|
|
578
|
+
privateFields.push("password");
|
|
579
|
+
response = omit(response, privateFields);
|
|
580
|
+
} else {
|
|
581
|
+
response = omit(response, ["password"]);
|
|
568
582
|
}
|
|
569
583
|
|
|
570
584
|
return c.json(response);
|
package/driver/mongo/rest.ts
CHANGED
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -349,7 +349,13 @@ export type Collection = {
|
|
|
349
349
|
timestamps?: boolean;
|
|
350
350
|
description?: string;
|
|
351
351
|
fields?: Field[];
|
|
352
|
-
|
|
352
|
+
api?: {
|
|
353
|
+
//privateFields?: string[];
|
|
354
|
+
fields: {
|
|
355
|
+
select?: string[];
|
|
356
|
+
hidden?: string[];
|
|
357
|
+
};
|
|
358
|
+
};
|
|
353
359
|
allow?: ["dropCollection", "renameCollection"];
|
|
354
360
|
indexes?: Array<{
|
|
355
361
|
[key: string]: any;
|
package/utils/index.ts
CHANGED
|
@@ -65,7 +65,7 @@ const jwt = {
|
|
|
65
65
|
return jwto.sign({ session: payload }, JWT_SECRET, {
|
|
66
66
|
...options,
|
|
67
67
|
});
|
|
68
|
-
} catch (err) {
|
|
68
|
+
} catch (err: any) {
|
|
69
69
|
console.error(err?.message);
|
|
70
70
|
}
|
|
71
71
|
},
|
|
@@ -162,7 +162,7 @@ async function verifyHashPassword(
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
function toDate(data:
|
|
165
|
+
function toDate(data: any | string): object | string {
|
|
166
166
|
if (data) {
|
|
167
167
|
if (typeof data == "string" && isDate(data)) {
|
|
168
168
|
data = new Date(data);
|
|
@@ -295,9 +295,9 @@ function pick(data: object | object[], keys: string[]): object {
|
|
|
295
295
|
return result;
|
|
296
296
|
};
|
|
297
297
|
|
|
298
|
-
const setDeepValue = (obj, keys, value) => {
|
|
298
|
+
const setDeepValue = (obj: any, keys: string[], value: any) => {
|
|
299
299
|
let current = obj;
|
|
300
|
-
keys.forEach((key, index) => {
|
|
300
|
+
keys.forEach((key: any, index: number) => {
|
|
301
301
|
if (index === keys.length - 1) {
|
|
302
302
|
current[key] = value;
|
|
303
303
|
} else {
|