{"_id":"@benhart44/shared-house-shared","_rev":"2-655f842cd7006dc60bc1fa30eca49d19","name":"@benhart44/shared-house-shared","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@benhart44/shared-house-shared","version":"1.0.0","keywords":["npm","library","typescript"],"author":{"name":"Benjamin HARTMANN"},"license":"ISC","_id":"@benhart44/shared-house-shared@1.0.0","maintainers":[{"name":"benhart44","email":"benjaminhartmann.contact@gmail.com"}],"homepage":"https://github.com/BenGround/shared-house-shared#readme","bugs":{"url":"https://github.com/BenGround/shared-house-shared/issues"},"dist":{"shasum":"1a5fbecd6bc3c6fba353f7bd34c513d8dc558a84","tarball":"https://registry.npmjs.org/@benhart44/shared-house-shared/-/shared-house-shared-1.0.0.tgz","fileCount":18,"integrity":"sha512-VifYkQeler7Y3A8K2Em3osy6ntaL2RaQRr9qgQkh9Ztv23o14Pjx5xNy9qJTv6b5/eF3kGifoW4VoafcF4/wwg==","signatures":[{"sig":"MEQCICVGYHYn0VhWP4XZpdzmbLnXZnfB/7qubtwzUjbiVwjCAiA9muAcDsYCnzuSMnHeVYwJFZgfesp8e2QteJMq/zNZrg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27279},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs.js"}},"gitHead":"643bf0cd98c78f1877f3cc334441907722180f1f","scripts":{"build":"tsc"},"_npmUser":{"name":"benhart44","email":"benjaminhartmann.contact@gmail.com"},"repository":{"url":"git+https://github.com/BenGround/shared-house-shared.git","type":"git"},"_npmVersion":"11.0.0","description":"Package for shared functions and types","directories":{},"_nodeVersion":"23.5.0","dependencies":{"prettier":"^3.4.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@types/node":"^22.13.1"},"_npmOperationalInternal":{"tmp":"tmp/shared-house-shared_1.0.0_1738738542680_0.250263800417335","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@benhart44/shared-house-shared","version":"1.0.1","keywords":["npm","library","typescript"],"author":{"name":"Benjamin HARTMANN"},"license":"ISC","_id":"@benhart44/shared-house-shared@1.0.1","maintainers":[{"name":"benhart44","email":"benjaminhartmann.contact@gmail.com"}],"homepage":"https://github.com/BenGround/shared-house-shared#readme","bugs":{"url":"https://github.com/BenGround/shared-house-shared/issues"},"dist":{"shasum":"3344a1f50ddb20e8d97cd12be3bd8f9bd0cefa66","tarball":"https://registry.npmjs.org/@benhart44/shared-house-shared/-/shared-house-shared-1.0.1.tgz","fileCount":18,"integrity":"sha512-keuOXXkSg7Ta0022RXhVCCTNuEJYatL/XSiBcI18miLDclD+gyDQHbzOcEfsZWQOmPNmaaKghd+yPWJE2UuMKA==","signatures":[{"sig":"MEUCIAtzP/f6RegLYrKQx9yxsxJVKoARs42MUYT7mS02J8u/AiEAiQZssB9Zei3xMw9cmuBCZf8H8D7g3K6nxchyC0C2AC0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27347},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs.js"}},"gitHead":"259b1c3d5da324affaf9471c242ab9ec00e7bf96","scripts":{"build":"tsc"},"_npmUser":{"name":"benhart44","email":"benjaminhartmann.contact@gmail.com"},"repository":{"url":"git+https://github.com/BenGround/shared-house-shared.git","type":"git"},"_npmVersion":"11.0.0","description":"Package for shared functions and types","directories":{},"_nodeVersion":"23.5.0","dependencies":{"prettier":"^3.4.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3","@types/node":"^22.13.1"},"_npmOperationalInternal":{"tmp":"tmp/shared-house-shared_1.0.1_1738739062030_0.101227364671433","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@benhart44/shared-house-shared","version":"1.0.2","description":"Package for shared functions and types","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs.js"}},"type":"module","scripts":{"build":"tsc"},"author":{"name":"Benjamin HARTMANN"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/BenGround/shared-house-shared.git"},"keywords":["npm","library","typescript"],"devDependencies":{"@types/node":"^22.13.1","typescript":"^5.7.3"},"dependencies":{"prettier":"^3.4.2"},"_id":"@benhart44/shared-house-shared@1.0.2","gitHead":"684fec08b620eeaebcb5516363e063fbb3b103ca","bugs":{"url":"https://github.com/BenGround/shared-house-shared/issues"},"homepage":"https://github.com/BenGround/shared-house-shared#readme","_nodeVersion":"23.5.0","_npmVersion":"11.0.0","dist":{"integrity":"sha512-M7mR9eX7+B6Gg3NI2efJXnh9dFLgY2IbcVgDtaoMOo5sLz/aZNY1QS1Nj7eLifp6FZCwRjy7sN+gg98fi1ZKIg==","shasum":"9593bd0eb2e2d74121c8579c739cc2250a5e8e20","tarball":"https://registry.npmjs.org/@benhart44/shared-house-shared/-/shared-house-shared-1.0.2.tgz","fileCount":18,"unpackedSize":27347,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDf2fcVS+PjV85dVy3W8+LE15Q8iaJ+ue9DfedmZgy+SQIgE6F8viGDIZaAyf86tKsV4Sv559efiN4NCgKsL6CwrSY="}]},"_npmUser":{"name":"benhart44","email":"benjaminhartmann.contact@gmail.com"},"directories":{},"maintainers":[{"name":"benhart44","email":"benjaminhartmann.contact@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/shared-house-shared_1.0.2_1739020036553_0.37902468472358253"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-05T06:55:42.558Z","modified":"2025-02-08T13:07:16.935Z","1.0.0":"2025-02-05T06:55:42.905Z","1.0.1":"2025-02-05T07:04:22.280Z","1.0.2":"2025-02-08T13:07:16.743Z"},"bugs":{"url":"https://github.com/BenGround/shared-house-shared/issues"},"author":{"name":"Benjamin HARTMANN"},"license":"ISC","homepage":"https://github.com/BenGround/shared-house-shared#readme","keywords":["npm","library","typescript"],"repository":{"type":"git","url":"git+https://github.com/BenGround/shared-house-shared.git"},"description":"Package for shared functions and types","maintainers":[{"name":"benhart44","email":"benjaminhartmann.contact@gmail.com"}],"readme":"# **Shared House Shared** 🏡🔗  \r\nA lightweight TypeScript library that provides **shared types and validation functions** for both the API and frontend of a shared house booking system.\r\n\r\n## 🚀 **Features**\r\n- **Type Definitions**: Standardized types for shared spaces, bookings, and users.  \r\n- **Validation Utilities**: Functions for validating names, emails, booking times, and passwords.  \r\n- **Error Codes**: Consistent error codes for API responses and frontend validation.\r\n\r\n---\r\n\r\n## 📦 **Installation**\r\nInstall the package via **npm** or **yarn**:\r\n\r\n```sh\r\nnpm install @benjamin/shared-house-shared\r\n# or\r\nyarn add @benjamin/shared-house-shared\r\n```\r\n\r\n## 🔧 Usage\r\n1️⃣ Import Types\r\nUse the shared types to ensure consistency between frontend and backend.\r\n\r\n```\r\nimport { FrontSharedSpace, FrontBooking, ApiResponse } from '@benjamin/shared-house-shared';\r\n\r\nconst sharedSpace: FrontSharedSpace = {\r\n  id: 1,\r\n  nameCode: 'meeting_room_1',\r\n  nameEn: 'Meeting Room 1',\r\n  nameJp: 'ミーティングルーム1',\r\n  descriptionEn: 'A conference room with a projector',\r\n  descriptionJp: 'プロジェクター付きの会議室',\r\n  startDayTime: '08:00',\r\n  endDayTime: '18:00',\r\n  maxBookingHours: 4,\r\n  maxBookingByUser: 2,\r\n};\r\n\r\nconst response: ApiResponse<FrontSharedSpace> = {\r\n  data: sharedSpace,\r\n  message: 'Success',\r\n};\r\n```\r\n\r\n2️⃣ Use Validation Functions\r\nEnsure user input is correctly formatted before sending it to the backend.\r\n\r\n```\r\nimport {\r\n  validateEmailFormat,\r\n  validateNameCode,\r\n  validateFormatDayTime,\r\n  validatePassword,\r\n  passwordHasError,\r\n} from '@benjamin/shared-house-shared';\r\n\r\n// ✅ Validate email format\r\nconsole.log(validateEmailFormat('test@example.com')); // true\r\n\r\n// ✅ Validate shared space code\r\nconsole.log(validateNameCode('meeting_room_1')); // true\r\n\r\n// ✅ Validate time format (HH:mm)\r\nconsole.log(validateFormatDayTime('14:30')); // true\r\n\r\n// ✅ Validate password rules\r\nconsole.log(validatePassword('StrongP@ss1')); // [true, true, true, true, true] (all rules pass)\r\n\r\n// ❌ Check for password errors\r\nconsole.log(passwordHasError('Weak123')); // PASSWORD_VALIDATION_ONE_SPECIAL\r\n```\r\n\r\n3️⃣ Use API Error Codes\r\nHandle API validation errors consistently.\r\n\r\n```\r\nimport { ErrorCode } from '@benjamin/shared-house-shared';\r\n\r\nconst errorResponse = {\r\n  errorCode: ErrorCode.INVALID_EMAIL_FORMAT,\r\n  message: 'Invalid email format',\r\n};\r\n\r\nconsole.log(errorResponse.errorCode); // 'INVALID_EMAIL_FORMAT'\r\n```\r\n\r\n## 📚 Available Exports\r\n### 🔹 Shared Types\r\n- FrontSharedSpace\r\n- FrontSharedSpaceCreation\r\n- FrontBooking\r\n- FrontBookingCreation\r\n- FrontUser\r\n- FrontUserCreation\r\n- ApiResponse<T>\r\n### 🔹 Validation Functions\r\n- validateEmailFormat(email: string): boolean\r\n- validateEmailLength(email: string): boolean\r\n- validateUsername(username: string): boolean\r\n- validateNameCode(nameCode: string): boolean\r\n- validateName(name: string): boolean\r\n- validateDescription(description: string | null | undefined): boolean\r\n- validateMaxBookingHours(maxBookingHours: number): boolean\r\n- validateMaxBookingByUser(maxBookingByUser: number): boolean\r\n- validateFormatDayTime(dayTime: string): boolean\r\n- isStartDayTimeAfterEndDayTime(startDayTime: string, endDayTime: string): boolean\r\n- validatePassword(password: string): boolean[]\r\n- passwordHasError(password: string): ErrorCode | null\r\n### 🔹 Error Codes\r\n- ErrorCode.INVALID_EMAIL_FORMAT\r\n- ErrorCode.INVALID_NAME_CODE\r\n- ErrorCode.INVALID_TIME_FORMAT\r\n- ErrorCode.INVALID_MAX_BOOKING_HOURS\r\n- ... (full list in types/errorCodes.ts)\r\n## 🛠 Development\r\nRun Tests\r\nEnsure all validation functions work correctly.\r\n\r\n```\r\nnpm test\r\n```\r\n\r\n## 📜 License\r\nMIT License.\r\nCreated by Benjamin.\r\n","readmeFilename":"README.md"}