@lyxa.ai/core 1.0.167 → 1.0.168
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/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function userExcludedFields(select: Record<string, any> | null | undefined): Record<string, 0 | 1>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userExcludedFields = userExcludedFields;
|
|
4
|
+
function excludeFieldsFromProjection(select, fieldsToExclude) {
|
|
5
|
+
if (select && typeof select === 'object') {
|
|
6
|
+
const newSelect = { ...select };
|
|
7
|
+
for (const field of fieldsToExclude) {
|
|
8
|
+
delete newSelect[field];
|
|
9
|
+
}
|
|
10
|
+
return newSelect;
|
|
11
|
+
}
|
|
12
|
+
return fieldsToExclude.reduce((acc, field) => {
|
|
13
|
+
acc[field] = 0;
|
|
14
|
+
return acc;
|
|
15
|
+
}, {});
|
|
16
|
+
}
|
|
17
|
+
function userExcludedFields(select) {
|
|
18
|
+
return excludeFieldsFromProjection(select, ['phoneOtpInfo']);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"/","sources":["utilities/projection.ts"],"names":[],"mappings":";;AA8BA,gDAEC;AAzBD,SAAS,2BAA2B,CACnC,MAA8C,EAC9C,eAAyB;IAGzB,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAAM,SAAS,GAA0B,EAAE,GAAG,MAAM,EAAE,CAAC;QAEvD,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;YACrC,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAGD,OAAO,eAAe,CAAC,MAAM,CAAoB,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC/D,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACf,OAAO,GAAG,CAAC;IACZ,CAAC,EAAE,EAAE,CAAC,CAAC;AACR,CAAC;AAGD,SAAgB,kBAAkB,CAAC,MAA8C;IAChF,OAAO,2BAA2B,CAAC,MAAM,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * Utility to exclude specific fields from a MongoDB projection/select object.\n *\n * @param select - Existing projection object or undefined.\n * @param fieldsToExclude - Array of field names to exclude.\n * @returns A new projection object with specified fields excluded.\n */\nfunction excludeFieldsFromProjection(\n\tselect: Record<string, any> | null | undefined,\n\tfieldsToExclude: string[]\n): Record<string, 0 | 1> {\n\t// Case 1: If select object exists, clone and delete excluded fields\n\tif (select && typeof select === 'object') {\n\t\tconst newSelect: Record<string, 0 | 1> = { ...select };\n\n\t\tfor (const field of fieldsToExclude) {\n\t\t\tdelete newSelect[field];\n\t\t}\n\n\t\treturn newSelect;\n\t}\n\n\t// Case 2: No select provided, create one with excluded fields only\n\treturn fieldsToExclude.reduce<Record<string, 0>>((acc, field) => {\n\t\tacc[field] = 0;\n\t\treturn acc;\n\t}, {});\n}\n\n// For user schema\nexport function userExcludedFields(select: Record<string, any> | null | undefined): Record<string, 0 | 1> {\n\treturn excludeFieldsFromProjection(select, ['phoneOtpInfo']);\n}\n"]}
|