import { MongoDao, MongoDaoMethodsFull } from '../databases/mongo/types/mongoDbTypes.js'; import { ForClauseWithAllAndSystem, ForClauseParsed } from './coreGeneric.types.js'; import { MaybeArray } from 'typescript-generic-types'; export declare const writeMethods: readonly ["create", "update", "delete"]; export type WriteMethods = typeof writeMethods[number]; export declare const readMethods: readonly ["getOne", "getAll"]; export type ReadMethods = typeof readMethods[number]; export declare const daoGenericMethods: readonly ["create", "update", "delete", "getOne", "getAll"]; export type DaoGenericMethods = typeof daoGenericMethods[number]; export declare const daoMethodsWithReadWrite: readonly ["create", "update", "delete", "getOne", "getAll", "write", "read"]; export type DaoMethodsWithReadWrite = typeof daoMethodsWithReadWrite[number]; declare const daoMethodsGenericAndAll: readonly ["create", "update", "delete", "getOne", "getAll", "write", "read", "ALL"]; type DaoMethodsGenericAndAll = typeof daoMethodsGenericAndAll[number]; export type AllPossibleDaoMethods = MongoDaoMethodsFull; export type GenericDao = MongoDao; export type DaoSharedParsed = { /** Define a global access permissions on a model for a certain user role */ expose: (Omit & { expose?: DaoGenericMethods[]; })[]; }; export type ExposeDaoConfig = (Omit & { expose?: 'ALL' | MaybeArray; }); export type DaoShared = { /** Configure what is exposed to outside world via API and the permission that is allowed to read / write the model. * * To have more granularity on which fields should be exposed or which document should be accessed use dao.mask or dao.filter. * * Leave the array empty is you don't want to expose your model and want to use it only internally (via dbs.myDb.myModel...) * * Use snippet `gd_dao:expose` for autocompletion * * Example: * ```typescript * const dao = { expose: [{ for: ['user', 'perm2'], // only those perms will have access to your model expose: ['getOne', 'update'], // only those methods will be allowed for those perms },{ // you can mix and match with all your perms for: ['admin'], expose: ['read', 'write'], }, ]} * ``` */ expose?: ExposeDaoConfig[]; }; export type DaoHookShared = { doc?: string; for?: ForClauseWithAllAndSystem; notFor?: MaybeArray; /** The lower, the prior. From 0 to 100 */ priority?: number; on?: MaybeArray; notOn?: MaybeArray; }; export type DaoHookSharedParsed = { doc?: string; for: ForClauseParsed[]; /** The lower, the prior. From 0 to 100 */ priority: number; on: DaoGenericMethods[]; }; export declare const daoHookNamesShared: readonly ["expose"]; export type DaoHookNamesShared = typeof daoHookNamesShared[number]; export type MaskHook = { /** Define which path should be MASKED * * It masks selected fields and consider that **all paths are allowed by default** * * One important thing to consider: when multiple mask/select hooks apply, the more restrictive result is applied. Eg: if path1 is masked on one hook and path2 is allowed on a second, it will be masked * * Should return an object like: `{ authorized: { path: true, sub: { path: true }, matchWildCardProp: { 'admin*': true }, '*': true }}` * * Use snippet `gd_dao:mask` for autocompletion * * Example: * ```typescript * const dao = { mask: [{ notFor: 'admin', on: 'ALL', // for read / update / create... or dismiss this field for the same result mask: () => ({ companyMargin: true, // those are masked for everyone except admins stats: true, }), }, * ``` */ mask(ctx: Ctx): RecursiveObjValueType, boolean>; select?: never; } | { /** Define which path should be SELECTED * * It will select configured fields and **mask all other paths** * * One important thing to consider: when multiple mask/select hooks apply, the more restrictive result is applied. Eg: if path1 is masked on one hook and path2 is allowed on a second, it will be masked * * Should return an object like: `{ authorized: { path: true, sub: { path: true }, matchWildCardProp: { 'admin*': true }, '*': true }}` * * Use snippet `gd_dao:mask` for autocompletion * * Example: * ```typescript * const dao = { mask: [{ notFor: 'admin', on: 'ALL', // for read / update / create... or dismiss this field for the same result select: () => ({ firstName: true, // those fields are visible for everyone except admins, all others fields are masked lastName: true, }), }, * ``` */ select(ctx: Ctx): RecursiveObjValueType, boolean>; mask?: never; }; export {};