@happychef/algorithm 1.2.13 → 1.2.15
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/.github/workflows/ci-cd.yml +0 -154
- package/BRANCH_PROTECTION_SETUP.md +167 -167
- package/README.md +144 -144
- package/__tests__/filters.test.js +276 -276
- package/__tests__/isDateAvailable.test.js +175 -175
- package/__tests__/isTimeAvailable.test.js +168 -168
- package/__tests__/restaurantData.test.js +422 -422
- package/__tests__/tableHelpers.test.js +247 -247
- package/assignTables.js +33 -13
- package/changes/2026/January/PR11_add__change.md +20 -0
- package/getAvailableTimeblocks.js +2 -2
- package/isDateAvailable.js +2 -2
- package/isDateAvailableWithTableCheck.js +5 -4
- package/jest.config.js +23 -23
- package/package.json +1 -1
- package/processing/timeblocksAvailable.js +2 -2
- package/reservation_data/counter.js +11 -1
- package/simulateTableAssignment.js +35 -18
- package/test-detailed-filter.js +100 -100
- package/test-lunch-debug.js +110 -110
- package/test-max-arrivals-filter.js +79 -79
- package/test-timezone-debug.js +47 -47
package/README.md
CHANGED
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
# @happychef/algorithm
|
|
2
|
-
|
|
3
|
-
Restaurant and reservation algorithm utilities for Happy Chef.
|
|
4
|
-
|
|
5
|
-
[](https://github.com/YOUR_USERNAME/YOUR_REPO/actions/workflows/ci-cd.yml)
|
|
6
|
-
[](https://codecov.io/gh/YOUR_USERNAME/YOUR_REPO)
|
|
7
|
-
[](https://www.npmjs.com/package/@happychef/algorithm)
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install @happychef/algorithm
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Features
|
|
16
|
-
|
|
17
|
-
- **Date & Time Availability**: Check if specific dates and times are available for reservations
|
|
18
|
-
- **Timeblock Management**: Get available timeblocks based on restaurant settings
|
|
19
|
-
- **Table Assignment**: Automatically assign tables to reservations
|
|
20
|
-
- **Smart Filtering**: Filter timeblocks based on max arrivals, max groups, and other constraints
|
|
21
|
-
- **Exception Handling**: Support for restaurant opening hours exceptions and closures
|
|
22
|
-
- **Comprehensive Testing**: 70+ unit tests ensuring reliability
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
const {
|
|
28
|
-
isDateAvailable,
|
|
29
|
-
isTimeAvailable,
|
|
30
|
-
getAvailableTimeblocks,
|
|
31
|
-
assignTablesIfPossible
|
|
32
|
-
} = require('@happychef/algorithm');
|
|
33
|
-
|
|
34
|
-
// Check if a date is available
|
|
35
|
-
const available = isDateAvailable(
|
|
36
|
-
restaurantData,
|
|
37
|
-
'2025-06-15',
|
|
38
|
-
reservations,
|
|
39
|
-
guests
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
// Get available timeblocks
|
|
43
|
-
const timeblocks = getAvailableTimeblocks(
|
|
44
|
-
restaurantData,
|
|
45
|
-
'2025-06-15',
|
|
46
|
-
reservations,
|
|
47
|
-
guests
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
// Check if specific time is available
|
|
51
|
-
const timeAvailable = isTimeAvailable(
|
|
52
|
-
restaurantData,
|
|
53
|
-
'2025-06-15',
|
|
54
|
-
'12:00',
|
|
55
|
-
reservations,
|
|
56
|
-
guests
|
|
57
|
-
);
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Development
|
|
61
|
-
|
|
62
|
-
### Running Tests
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
# Run all tests
|
|
66
|
-
npm test
|
|
67
|
-
|
|
68
|
-
# Run tests in watch mode
|
|
69
|
-
npm run test:watch
|
|
70
|
-
|
|
71
|
-
# Run tests with coverage
|
|
72
|
-
npm run test:coverage
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Test Coverage
|
|
76
|
-
|
|
77
|
-
The package includes comprehensive unit tests covering:
|
|
78
|
-
- Helper functions (parseTime, getMealTypeByTime, etc.)
|
|
79
|
-
- Date and time availability checks
|
|
80
|
-
- Timeblock filtering
|
|
81
|
-
- Restaurant data and exceptions handling
|
|
82
|
-
- Table assignment logic
|
|
83
|
-
- Filter functions (max arrivals, max groups)
|
|
84
|
-
|
|
85
|
-
All tests are automatically run on every push to the main branch via GitHub Actions.
|
|
86
|
-
|
|
87
|
-
## CI/CD Pipeline
|
|
88
|
-
|
|
89
|
-
This package uses GitHub Actions for continuous integration and deployment:
|
|
90
|
-
|
|
91
|
-
1. **Automated Testing**: Tests run on Node.js 18.x and 20.x
|
|
92
|
-
2. **Coverage Reports**: Automatically uploaded to Codecov
|
|
93
|
-
3. **Automatic Publishing**: When tests pass on main branch and version changes, package is automatically published to npm
|
|
94
|
-
4. **Git Tagging**: Successful releases are automatically tagged
|
|
95
|
-
|
|
96
|
-
### Setup Instructions
|
|
97
|
-
|
|
98
|
-
To enable automatic publishing:
|
|
99
|
-
|
|
100
|
-
1. **Create an NPM Token**:
|
|
101
|
-
- Go to [npmjs.com](https://www.npmjs.com/)
|
|
102
|
-
- Navigate to Access Tokens
|
|
103
|
-
- Generate a new "Automation" token
|
|
104
|
-
- Copy the token
|
|
105
|
-
|
|
106
|
-
2. **Add NPM Token to GitHub Secrets**:
|
|
107
|
-
- Go to your GitHub repository
|
|
108
|
-
- Navigate to Settings > Secrets and variables > Actions
|
|
109
|
-
- Click "New repository secret"
|
|
110
|
-
- Name: `NPM_TOKEN`
|
|
111
|
-
- Value: Paste your NPM token
|
|
112
|
-
- Click "Add secret"
|
|
113
|
-
|
|
114
|
-
3. **Optional: Add Codecov Token** (for coverage reports):
|
|
115
|
-
- Go to [codecov.io](https://codecov.io/)
|
|
116
|
-
- Add your repository
|
|
117
|
-
- Copy the token
|
|
118
|
-
- Add as `CODECOV_TOKEN` secret in GitHub
|
|
119
|
-
|
|
120
|
-
4. **Publish New Version**:
|
|
121
|
-
- Update version in `package.json`
|
|
122
|
-
- Commit and push to main branch
|
|
123
|
-
- GitHub Actions will automatically:
|
|
124
|
-
- Run all tests
|
|
125
|
-
- Publish to npm if tests pass
|
|
126
|
-
- Create a git tag for the release
|
|
127
|
-
|
|
128
|
-
## Contributing
|
|
129
|
-
|
|
130
|
-
1. Fork the repository
|
|
131
|
-
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
132
|
-
3. Write tests for your changes
|
|
133
|
-
4. Ensure all tests pass (`npm test`)
|
|
134
|
-
5. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
135
|
-
6. Push to the branch (`git push origin feature/amazing-feature`)
|
|
136
|
-
7. Open a Pull Request
|
|
137
|
-
|
|
138
|
-
## License
|
|
139
|
-
|
|
140
|
-
MIT
|
|
141
|
-
|
|
142
|
-
## Author
|
|
143
|
-
|
|
144
|
-
Happy Chef
|
|
1
|
+
# @happychef/algorithm
|
|
2
|
+
|
|
3
|
+
Restaurant and reservation algorithm utilities for Happy Chef.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/YOUR_USERNAME/YOUR_REPO/actions/workflows/ci-cd.yml)
|
|
6
|
+
[](https://codecov.io/gh/YOUR_USERNAME/YOUR_REPO)
|
|
7
|
+
[](https://www.npmjs.com/package/@happychef/algorithm)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @happychef/algorithm
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **Date & Time Availability**: Check if specific dates and times are available for reservations
|
|
18
|
+
- **Timeblock Management**: Get available timeblocks based on restaurant settings
|
|
19
|
+
- **Table Assignment**: Automatically assign tables to reservations
|
|
20
|
+
- **Smart Filtering**: Filter timeblocks based on max arrivals, max groups, and other constraints
|
|
21
|
+
- **Exception Handling**: Support for restaurant opening hours exceptions and closures
|
|
22
|
+
- **Comprehensive Testing**: 70+ unit tests ensuring reliability
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
const {
|
|
28
|
+
isDateAvailable,
|
|
29
|
+
isTimeAvailable,
|
|
30
|
+
getAvailableTimeblocks,
|
|
31
|
+
assignTablesIfPossible
|
|
32
|
+
} = require('@happychef/algorithm');
|
|
33
|
+
|
|
34
|
+
// Check if a date is available
|
|
35
|
+
const available = isDateAvailable(
|
|
36
|
+
restaurantData,
|
|
37
|
+
'2025-06-15',
|
|
38
|
+
reservations,
|
|
39
|
+
guests
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Get available timeblocks
|
|
43
|
+
const timeblocks = getAvailableTimeblocks(
|
|
44
|
+
restaurantData,
|
|
45
|
+
'2025-06-15',
|
|
46
|
+
reservations,
|
|
47
|
+
guests
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Check if specific time is available
|
|
51
|
+
const timeAvailable = isTimeAvailable(
|
|
52
|
+
restaurantData,
|
|
53
|
+
'2025-06-15',
|
|
54
|
+
'12:00',
|
|
55
|
+
reservations,
|
|
56
|
+
guests
|
|
57
|
+
);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Development
|
|
61
|
+
|
|
62
|
+
### Running Tests
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Run all tests
|
|
66
|
+
npm test
|
|
67
|
+
|
|
68
|
+
# Run tests in watch mode
|
|
69
|
+
npm run test:watch
|
|
70
|
+
|
|
71
|
+
# Run tests with coverage
|
|
72
|
+
npm run test:coverage
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Test Coverage
|
|
76
|
+
|
|
77
|
+
The package includes comprehensive unit tests covering:
|
|
78
|
+
- Helper functions (parseTime, getMealTypeByTime, etc.)
|
|
79
|
+
- Date and time availability checks
|
|
80
|
+
- Timeblock filtering
|
|
81
|
+
- Restaurant data and exceptions handling
|
|
82
|
+
- Table assignment logic
|
|
83
|
+
- Filter functions (max arrivals, max groups)
|
|
84
|
+
|
|
85
|
+
All tests are automatically run on every push to the main branch via GitHub Actions.
|
|
86
|
+
|
|
87
|
+
## CI/CD Pipeline
|
|
88
|
+
|
|
89
|
+
This package uses GitHub Actions for continuous integration and deployment:
|
|
90
|
+
|
|
91
|
+
1. **Automated Testing**: Tests run on Node.js 18.x and 20.x
|
|
92
|
+
2. **Coverage Reports**: Automatically uploaded to Codecov
|
|
93
|
+
3. **Automatic Publishing**: When tests pass on main branch and version changes, package is automatically published to npm
|
|
94
|
+
4. **Git Tagging**: Successful releases are automatically tagged
|
|
95
|
+
|
|
96
|
+
### Setup Instructions
|
|
97
|
+
|
|
98
|
+
To enable automatic publishing:
|
|
99
|
+
|
|
100
|
+
1. **Create an NPM Token**:
|
|
101
|
+
- Go to [npmjs.com](https://www.npmjs.com/)
|
|
102
|
+
- Navigate to Access Tokens
|
|
103
|
+
- Generate a new "Automation" token
|
|
104
|
+
- Copy the token
|
|
105
|
+
|
|
106
|
+
2. **Add NPM Token to GitHub Secrets**:
|
|
107
|
+
- Go to your GitHub repository
|
|
108
|
+
- Navigate to Settings > Secrets and variables > Actions
|
|
109
|
+
- Click "New repository secret"
|
|
110
|
+
- Name: `NPM_TOKEN`
|
|
111
|
+
- Value: Paste your NPM token
|
|
112
|
+
- Click "Add secret"
|
|
113
|
+
|
|
114
|
+
3. **Optional: Add Codecov Token** (for coverage reports):
|
|
115
|
+
- Go to [codecov.io](https://codecov.io/)
|
|
116
|
+
- Add your repository
|
|
117
|
+
- Copy the token
|
|
118
|
+
- Add as `CODECOV_TOKEN` secret in GitHub
|
|
119
|
+
|
|
120
|
+
4. **Publish New Version**:
|
|
121
|
+
- Update version in `package.json`
|
|
122
|
+
- Commit and push to main branch
|
|
123
|
+
- GitHub Actions will automatically:
|
|
124
|
+
- Run all tests
|
|
125
|
+
- Publish to npm if tests pass
|
|
126
|
+
- Create a git tag for the release
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
1. Fork the repository
|
|
131
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
132
|
+
3. Write tests for your changes
|
|
133
|
+
4. Ensure all tests pass (`npm test`)
|
|
134
|
+
5. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
135
|
+
6. Push to the branch (`git push origin feature/amazing-feature`)
|
|
136
|
+
7. Open a Pull Request
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
MIT
|
|
141
|
+
|
|
142
|
+
## Author
|
|
143
|
+
|
|
144
|
+
Happy Chef
|