{"_id":"@aheed0911/db-infra","_rev":"8-f79fed2cb9815b7fe6ebb585f1b84111","name":"@aheed0911/db-infra","dist-tags":{"latest":"1.1.4"},"versions":{"0.0.1":{"name":"@aheed0911/db-infra","version":"0.0.1","keywords":[],"author":"","license":"ISC","_id":"@aheed0911/db-infra@0.0.1","maintainers":[{"name":"aheed0911","email":"aheed@ac-group.ai"}],"dist":{"shasum":"89a9b02b443686939c450b54c1c5ceedfbc48f52","tarball":"https://registry.npmjs.org/@aheed0911/db-infra/-/db-infra-0.0.1.tgz","fileCount":39,"integrity":"sha512-6FSCEnmpzmfoIK4QNtqP/NBV06L+10miHTvOaK3uyr2A+0AzKh2C8Ez6VtbgVpu4rhyFlEv5iPUoWGe9SQ+GtA==","signatures":[{"sig":"MEUCIQC9lhEyJIAu9eWQaoA+tWRY0xRPcHrv04rIDVJt0cN5lgIgKksrRb28BljchYEwbCEB58qF+M5jAh/FEEoL6JR2els=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":108198},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","migrate":"node dist/migrate.js","publish":"npm publish"},"_npmUser":{"name":"aheed0911","email":"aheed@ac-group.ai"},"_npmVersion":"10.9.2","description":"MongoDB schema definitions for QNova services","directories":{},"_nodeVersion":"22.14.0","dependencies":{"zod":"3.25.17","mongodb":"6.16.0","zod-to-json-schema":"3.24.5"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"5.7.3","@types/node":"22.15.21"},"_npmOperationalInternal":{"tmp":"tmp/db-infra_0.0.1_1747835060665_0.26399270480869474","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@aheed0911/db-infra","version":"1.0.0","keywords":["mongodb","mongoose","schemas","models","qnova","multi-tenant"],"author":{"name":"QNova Team"},"license":"ISC","_id":"@aheed0911/db-infra@1.0.0","maintainers":[{"name":"aheed0911","email":"aheed@ac-group.ai"}],"homepage":"https://github.com/qnova/db-infra#readme","bugs":{"url":"https://github.com/qnova/db-infra/issues"},"dist":{"shasum":"d8cfaab086887c8b471b13cedfd809c6ed417a11","tarball":"https://registry.npmjs.org/@aheed0911/db-infra/-/db-infra-1.0.0.tgz","fileCount":30,"integrity":"sha512-ECDMvygrV2rfLdWYfaUs4y3xnHMH4p2Dz3EwzQ3Txir26smApZIOL/nrSCK+9ZmwDjRvcqBcoYAKjBw4K+PCHA==","signatures":[{"sig":"MEUCIDSHSd0WYNAxJLIPBuyLolGzPKf+5LGzvhnj9Bm7ovsUAiEA4Dv5gVtqx67e6vtMKakfMOPkgM9Dw6dtXcTgCU8il88=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45287},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf dist","migrate":"node dist/migrate.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"aheed0911","email":"aheed@ac-group.ai"},"repository":{"url":"git+https://github.com/qnova/db-infra.git","type":"git"},"_npmVersion":"10.9.2","description":"MongoDB schema definitions and models for QNova services using Mongoose","directories":{},"_nodeVersion":"22.14.0","dependencies":{"mongodb":"6.16.0"},"_hasShrinkwrap":false,"devDependencies":{"mongoose":"8.15.1","typescript":"5.7.3","@types/node":"22.15.21"},"peerDependencies":{"mongoose":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/db-infra_1.0.0_1748350608923_0.1098146847507413","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aheed0911/db-infra","version":"1.0.1","keywords":["mongodb","mongoose","schemas","models","qnova","multi-tenant"],"author":{"name":"QNova Team"},"license":"ISC","_id":"@aheed0911/db-infra@1.0.1","maintainers":[{"name":"aheed0911","email":"aheed@ac-group.ai"}],"homepage":"https://github.com/qnova/db-infra#readme","bugs":{"url":"https://github.com/qnova/db-infra/issues"},"dist":{"shasum":"495e8c557bd6b062fb339b0feae7ae659e70eb40","tarball":"https://registry.npmjs.org/@aheed0911/db-infra/-/db-infra-1.0.1.tgz","fileCount":30,"integrity":"sha512-pH4yAnM5/6WwLfmlZtLYbWvzZ6L1jk7dXNTc4wpB8zsSK5mkYujMw8+N7YjSaHZD+AiVXPUXmWMZSPoFbdeyxA==","signatures":[{"sig":"MEUCIBfLhXlEOvpOO4eiItPRsGDYoqo5dzxc0XxNEEMdM4jYAiEA0kDQw+UmdEickJNxyENLk+bRImWDhn2uOuIsycjmXXI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45359},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"ea38fb658e7d8f71b5410934c2644a14ec90775c","scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf dist","migrate":"node dist/migrate.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"aheed0911","email":"aheed@ac-group.ai"},"repository":{"url":"git+https://github.com/qnova/db-infra.git","type":"git"},"_npmVersion":"11.4.1","description":"MongoDB schema definitions and models for QNova services using Mongoose","directories":{},"_nodeVersion":"22.14.0","dependencies":{"mongodb":"6.16.0"},"_hasShrinkwrap":false,"devDependencies":{"mongoose":"8.15.1","typescript":"5.7.3","@types/node":"22.15.21"},"peerDependencies":{"mongoose":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/db-infra_1.0.1_1749473878853_0.7028362230056286","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@aheed0911/db-infra","version":"1.1.0","keywords":["mongodb","mongoose","schemas","models","qnova","multi-tenant"],"author":{"name":"QNova Team"},"license":"ISC","_id":"@aheed0911/db-infra@1.1.0","maintainers":[{"name":"aheed0911","email":"aheed@ac-group.ai"}],"homepage":"https://github.com/qnova/db-infra#readme","bugs":{"url":"https://github.com/qnova/db-infra/issues"},"dist":{"shasum":"b1391e132c2518ef03903f74ef4eb7ab387f33bb","tarball":"https://registry.npmjs.org/@aheed0911/db-infra/-/db-infra-1.1.0.tgz","fileCount":56,"integrity":"sha512-M/OwstuWvZZGCVBhzhCW7Aprfo96S+Qt4uXlQfku3yMPBDhLQraaE1y4e95SrGdT63Cuv4ifIRU/jGHJrCTgPg==","signatures":[{"sig":"MEYCIQDDicnBb5hovf1aGzftQBfB8+Oztez2HqDbgbp225UNqAIhAJnz+JqfQS1qscFJWmoBi4nIuTRxiziafmic4lMjazMs","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":95503},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"298736708cc7a39e6a1ecee200035078970651c0","scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf dist","migrate":"node dist/migrate.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"aheed0911","email":"aheed@ac-group.ai"},"repository":{"url":"git+https://github.com/qnova/db-infra.git","type":"git"},"_npmVersion":"11.4.1","description":"MongoDB schema definitions and models for QNova services using Mongoose","directories":{},"_nodeVersion":"22.14.0","dependencies":{"mongodb":"6.16.0"},"_hasShrinkwrap":false,"devDependencies":{"mongoose":"8.15.1","typescript":"5.7.3","@types/node":"22.15.21"},"peerDependencies":{"mongoose":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/db-infra_1.1.0_1749481692519_0.3908858591162665","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@aheed0911/db-infra","version":"1.1.1","keywords":["mongodb","mongoose","schemas","models","qnova","multi-tenant"],"author":{"name":"QNova Team"},"license":"ISC","_id":"@aheed0911/db-infra@1.1.1","maintainers":[{"name":"aheed0911","email":"aheed@ac-group.ai"}],"homepage":"https://github.com/qnova/db-infra#readme","bugs":{"url":"https://github.com/qnova/db-infra/issues"},"dist":{"shasum":"ef7744e69bcb4e7131a3b25151fe8463050242de","tarball":"https://registry.npmjs.org/@aheed0911/db-infra/-/db-infra-1.1.1.tgz","fileCount":56,"integrity":"sha512-FIH5GlDzzXeBM2J03vtXqge4ex2Nizn2S3TQmLj84d2YIY6InahMb7abNJrDM3vXkjX9tCsWs5L+it+VPcyEwg==","signatures":[{"sig":"MEUCIQDdb/Kl4MUms4XIGbsQc0K3eQmeCvbmkQEO+uFg/w4SUAIgDObBVmxUxL6VnvqYmPow64ORpQ5mw0pDTK/OR70H0ks=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":95503},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"298736708cc7a39e6a1ecee200035078970651c0","scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf dist","migrate":"node dist/migrate.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"aheed0911","email":"aheed@ac-group.ai"},"repository":{"url":"git+https://github.com/qnova/db-infra.git","type":"git"},"_npmVersion":"11.4.1","description":"MongoDB schema definitions and models for QNova services using Mongoose","directories":{},"_nodeVersion":"22.14.0","dependencies":{"mongodb":"6.16.0"},"_hasShrinkwrap":false,"devDependencies":{"mongoose":"8.15.1","typescript":"5.7.3","@types/node":"22.15.21"},"peerDependencies":{"mongoose":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/db-infra_1.1.1_1749545769551_0.17888648524084716","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@aheed0911/db-infra","version":"1.1.2","keywords":["mongodb","mongoose","schemas","models","qnova","multi-tenant"],"author":{"name":"QNova Team"},"license":"ISC","_id":"@aheed0911/db-infra@1.1.2","maintainers":[{"name":"aheed0911","email":"aheed@ac-group.ai"}],"homepage":"https://github.com/qnova/db-infra#readme","bugs":{"url":"https://github.com/qnova/db-infra/issues"},"dist":{"shasum":"b612f6f4b89526973374533cbccb9d82bfcde7c9","tarball":"https://registry.npmjs.org/@aheed0911/db-infra/-/db-infra-1.1.2.tgz","fileCount":56,"integrity":"sha512-NKXO8ESO8ftnmyarWsyaO4zO7xR3RFKSn7ijGKBQoyP4ccNcQTvstm3ihWo7JYrGtj71jzBytV+EAVeGq7yCbw==","signatures":[{"sig":"MEQCICqIjXCTRB13nTG3HnDbmZe21/ipK8InsphqHtKfC3C2AiBUfkQoD1VWXHmTkCtDUETW92OerAP5kmhcG+46g/RDvQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":95493},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"4d47a5863d610728c90ac2b7ad6b965c8b7f6075","scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf dist","migrate":"node dist/migrate.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"aheed0911","email":"aheed@ac-group.ai"},"repository":{"url":"git+https://github.com/qnova/db-infra.git","type":"git"},"_npmVersion":"11.4.1","description":"MongoDB schema definitions and models for QNova services using Mongoose","directories":{},"_nodeVersion":"22.14.0","dependencies":{"mongodb":"6.16.0"},"_hasShrinkwrap":false,"devDependencies":{"mongoose":"8.15.1","typescript":"5.7.3","@types/node":"22.15.21"},"peerDependencies":{"mongoose":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/db-infra_1.1.2_1750064841650_0.9340687194609538","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"name":"@aheed0911/db-infra","version":"1.1.3","keywords":["mongodb","mongoose","schemas","models","qnova","multi-tenant"],"author":{"name":"QNova Team"},"license":"ISC","_id":"@aheed0911/db-infra@1.1.3","maintainers":[{"name":"aheed0911","email":"aheed@ac-group.ai"}],"homepage":"https://github.com/qnova/db-infra#readme","bugs":{"url":"https://github.com/qnova/db-infra/issues"},"dist":{"shasum":"d4a0afe5f1df1bc1cd2563d23dcab8f8f0686d37","tarball":"https://registry.npmjs.org/@aheed0911/db-infra/-/db-infra-1.1.3.tgz","fileCount":56,"integrity":"sha512-UPklzVlt359dGqXaV7p/EBu0xRZeBqfaA58fQCbrFPlsfz4Z/uybtcHapTOgSh3DD3knz5TaF+wGrhs456D42w==","signatures":[{"sig":"MEUCIQCv4VFBhASuPn6g+EO4EwpBb84AGORix2h6nHPORlqCOQIgHVUCsEbVJvQmMxAG8RDjO3przPlAdzd2pVSAHeXubq4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":95470},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"4d47a5863d610728c90ac2b7ad6b965c8b7f6075","scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","clean":"rm -rf dist","migrate":"node dist/migrate.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"aheed0911","email":"aheed@ac-group.ai"},"repository":{"url":"git+https://github.com/qnova/db-infra.git","type":"git"},"_npmVersion":"11.4.1","description":"MongoDB schema definitions and models for QNova services using Mongoose","directories":{},"_nodeVersion":"22.14.0","dependencies":{"mongodb":"6.16.0"},"_hasShrinkwrap":false,"devDependencies":{"mongoose":"8.15.1","typescript":"5.7.3","@types/node":"22.15.21"},"peerDependencies":{"mongoose":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/db-infra_1.1.3_1750076692356_0.11512056077335098","host":"s3://npm-registry-packages-npm-production"}},"1.1.4":{"name":"@aheed0911/db-infra","version":"1.1.4","description":"MongoDB schema definitions and models for QNova services using Mongoose","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","dev":"tsc --watch","prepublishOnly":"npm run build","clean":"rm -rf dist","migrate":"node dist/migrate.js","test":"echo \"Error: no test specified\" && exit 1"},"keywords":["mongodb","mongoose","schemas","models","qnova","multi-tenant"],"author":{"name":"QNova Team"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/qnova/db-infra.git"},"homepage":"https://github.com/qnova/db-infra#readme","bugs":{"url":"https://github.com/qnova/db-infra/issues"},"engines":{"node":">=18.0.0"},"peerDependencies":{"mongoose":"^8.0.0"},"dependencies":{"mongodb":"6.16.0"},"devDependencies":{"@types/node":"22.15.21","typescript":"5.7.3","mongoose":"8.15.1"},"_id":"@aheed0911/db-infra@1.1.4","gitHead":"3922cd013973eb2d48f18d2aced8d51967896079","_nodeVersion":"22.14.0","_npmVersion":"11.4.1","dist":{"integrity":"sha512-aPRgDlmJwwzgNUdSNf6pClJL5FKs5Ecf4PYNbe0Jl8n629/GQQaVuERqcceE/+WFjVT3LQx+Ecddw7WyR0ATRQ==","shasum":"0976e9305897b37128a1a147e85bc7648fd9e70f","tarball":"https://registry.npmjs.org/@aheed0911/db-infra/-/db-infra-1.1.4.tgz","fileCount":56,"unpackedSize":95559,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAl5emsxxeBGri+vk9wPaCqWkI+lnOOsST1AbqBUa5HIAiEA68UqWjRCBZK0Zsk1CoJ1QWZmIFbW2Na7kvUEJS3HWUs="}]},"_npmUser":{"name":"aheed0911","email":"aheed@ac-group.ai"},"directories":{},"maintainers":[{"name":"aheed0911","email":"aheed@ac-group.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/db-infra_1.1.4_1750080069510_0.5780083709920474"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-21T13:44:20.550Z","modified":"2025-06-16T13:21:09.901Z","0.0.1":"2025-05-21T13:44:20.835Z","1.0.0":"2025-05-27T12:56:49.122Z","1.0.1":"2025-06-09T12:57:59.037Z","1.1.0":"2025-06-09T15:08:12.713Z","1.1.1":"2025-06-10T08:56:09.748Z","1.1.2":"2025-06-16T09:07:21.831Z","1.1.3":"2025-06-16T12:24:52.580Z","1.1.4":"2025-06-16T13:21:09.721Z"},"bugs":{"url":"https://github.com/qnova/db-infra/issues"},"author":{"name":"QNova Team"},"license":"ISC","homepage":"https://github.com/qnova/db-infra#readme","keywords":["mongodb","mongoose","schemas","models","qnova","multi-tenant"],"repository":{"type":"git","url":"git+https://github.com/qnova/db-infra.git"},"description":"MongoDB schema definitions and models for QNova services using Mongoose","maintainers":[{"name":"aheed0911","email":"aheed@ac-group.ai"}],"readme":"# QNova Database Models\n\nThis directory contains all the Mongoose models for the QNova multi-tenant system. Each model is defined in a separate file with proper TypeScript interfaces and MongoDB indexes.\n\n## Models Overview\n\n### Core Tenant Models\n\n#### 1. **Tenant** (`tenant.model.ts`)\n- Primary tenant entity with authentication settings and password policies\n- **Indexes**: `{ tenantKey: 1 }` (unique)\n- **Key Features**: \n  - Multi-factor authentication settings\n  - Configurable password policies (bcrypt/argon2id)\n  - Feature flags system\n  - SSO provider management\n\n#### 2. **TenantDomain** (`tenantDomain.model.ts`)\n- Domain verification and management for tenants\n- **Indexes**: \n  - `{ tenantDomain: 1 }` (unique)\n  - `{ tenantId: 1 }` (unique)\n- **Key Features**: \n  - Subdomain, tenant domain, and email domain verification\n  - Three-state verification status (pending/verified/failed)\n\n#### 3. **TenantBranding** (`tenantBranding.model.ts`)\n- Tenant-specific branding and theming\n- **Indexes**: `{ tenantId: 1 }` (unique)\n- **Key Features**: \n  - Primary/secondary colors\n  - Custom fonts\n  - Logo, icon, and favicon URLs\n\n### Organization & User Models\n\n#### 4. **Organization** (`organization.model.ts`)\n- Organizations within tenants\n- **Indexes**: \n  - `{ tenantId: 1, orgKey: 1 }` (unique)\n  - `{ tenantId: 1, name: 1 }`\n- **Key Features**: \n  - IP blacklisting and whitelisting\n  - Per-organization feature overrides\n  - Contact information management\n\n#### 5. **User** (`user.model.ts`)\n- System users with authentication and profile data\n- **Indexes**: \n  - `{ tenantId: 1, email: 1 }` (unique, sparse)\n  - `{ tenantId: 1, status: 1 }`\n- **Key Features**: \n  - Password history and lockout management\n  - Multi-factor authentication (TOTP/WebAuthn)\n  - OAuth provider integration\n  - User status management (active/invited/disabled)\n\n#### 6. **UserToken** (`userToken.model.ts`)\n- Single-use tokens for invites and password resets\n- **Indexes**: \n  - `{ tokenHash: 1 }` (unique)\n  - `{ expiresAt: 1 }` (TTL index for auto-pruning)\n  - `{ userId: 1, type: 1, consumedAt: 1 }`\n- **Key Features**: \n  - Secure token hashing\n  - Automatic expiration\n  - Usage tracking with IP and user agent\n\n### Agent & Skills Models\n\n#### 7. **Agent** (`agent.model.ts`)\n- External agents with skills and team assignments\n- **Indexes**: \n  - `{ tenantId: 1, fullName: 1 }`\n  - `{ tenantId: 1, email: 1 }` (unique, sparse)\n  - `{ tenantId: 1, servicePartnerId: 1, isActive: 1 }`\n- **Key Features**: \n  - Skill assignment (embedded array for performance)\n  - Campaign associations\n  - Service partner relationships\n\n#### 8. **Skill** (`skill.model.ts`)\n- Organization-scoped skill catalog\n- **Indexes**: \n  - `{ tenantId: 1, name: 1 }` (unique)\n  - `{ tenantId: 1, category: 1 }`\n- **Key Features**: \n  - Categorization and weighting\n  - Tenant-scoped uniqueness\n\n### Permission & Role Models\n\n#### 9. **Permission** (`permission.model.ts`)\n- Immutable permission atoms\n- **Indexes**: \n  - `{ code: 1 }` (unique)\n  - `{ domain: 1, action: 1 }`\n  - `{ weight: 1 }`\n- **Key Features**: \n  - Domain.action structure\n  - Hierarchical weighting (10=read, 20=write, 30=manage)\n\n#### 10. **Role** (`role.model.ts`)\n- Roles with permission collections\n- **Indexes**: `{ tenantId: 1, name: 1 }` (unique, sparse)\n- **Key Features**: \n  - System vs tenant-specific roles\n  - Permission aggregation\n\n#### 11. **RoleBinding** (`roleBinding.model.ts`)\n- User-role assignments with scope and filters\n- **Indexes**: \n  - `{ tenantId: 1, userId: 1, 'scope.type': 1, 'scope.resourceId': 1 }`\n  - `{ tenantId: 1, roleId: 1 }`\n  - `{ userId: 1, 'scope.type': 1 }`\n  - Unique compound index for role binding uniqueness\n- **Key Features**: \n  - Multi-level scoping (tenant/organization/project/etc.)\n  - Lookup filters for fine-grained access control\n  - Assignment tracking\n\n## Common Patterns\n\n### MetaData Schema\nAll models (except Permission and UserToken) include a standardized `metaData` object with:\n- `createdAt` / `updatedAt` timestamps\n- `createdBy` / `updatedBy` user references\n- Soft deletion with `isDeleted` / `deletedAt`\n- Legacy ID mapping support\n\n### Pre-save Middleware\nMost models include middleware to automatically update `metaData.updatedAt` on document modifications.\n\n### Multi-tenancy\nAll models are designed with tenant isolation in mind, with `tenantId` fields and appropriate indexes for efficient tenant-scoped queries.\n\n## Usage\n\n```typescript\nimport { \n  Tenant, \n  User, \n  Organization, \n  RoleBinding,\n  // ... other models\n} from './models';\n\n// Example: Create a new tenant\nconst tenant = new Tenant({\n  tenantKey: 'acme-corp',\n  name: 'Acme Corporation',\n  contact: { email: 'admin@acme.com' },\n  settings: {\n    auth: {\n      ssoEnabled: false,\n      allowedIdPs: [],\n      mfaEnforced: true,\n      passwordPolicy: {\n        minLength: 12,\n        requireUppercase: true,\n        // ... other policy settings\n      }\n    },\n    features: new Map([['analytics', true]])\n  },\n  metaData: {\n    createdBy: adminUserId,\n    updatedBy: adminUserId\n  }\n});\n\nawait tenant.save();\n```\n\n## Database Indexes Summary\n\nAll models include carefully designed indexes for:\n- **Uniqueness constraints** (tenant keys, emails, etc.)\n- **Multi-tenant queries** (tenantId-based lookups)\n- **Performance optimization** (frequently queried fields)\n- **TTL expiration** (automatic cleanup for tokens)\n\nThe indexes are designed to support the multi-tenant architecture while maintaining query performance across all tenant operations. ","readmeFilename":"README.md"}