-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepomix-output.txt
3314 lines (2792 loc) · 94.4 KB
/
repomix-output.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
This file is a merged representation of the entire codebase, combined into a single document by Repomix.
================================================================
File Summary
================================================================
Purpose:
--------
This file contains a packed representation of the entire repository's contents.
It is designed to be easily consumable by AI systems for analysis, code review,
or other automated processes.
File Format:
------------
The content is organized as follows:
1. This summary section
2. Repository information
3. Directory structure
4. Multiple file entries, each consisting of:
a. A separator line (================)
b. The file path (File: path/to/file)
c. Another separator line
d. The full contents of the file
e. A blank line
Usage Guidelines:
-----------------
- This file should be treated as read-only. Any changes should be made to the
original repository files, not this packed version.
- When processing this file, use the file path to distinguish
between different files in the repository.
- Be aware that this file may contain sensitive information. Handle it with
the same level of security as you would the original repository.
Notes:
------
- Some files may have been excluded based on .gitignore rules and Repomix's configuration
- Binary files are not included in this packed representation. Please refer to the Repository Structure section for a complete list of file paths, including binary files
- Files matching patterns in .gitignore are excluded
- Files matching default ignore patterns are excluded
Additional Info:
----------------
================================================================
Directory Structure
================================================================
.github/
workflows/
deploy-lambda.yml
.repomix/
bundles.json
docs/
rules/
alert-rules.md
holiday-rules.md
time-rules.md
technical/
implementation-details.md
lintingAndFormatting.md
todo-deploy-lambda.md
typescriptConversion.md
templates/
holiday-config-template.json
user-config-template.json
deployment.md
src/
config/
UserConfig.ts
users.json
services/
analyzers/
BaseAnalyzer.ts
MonthlyAnalyzer.ts
formatters/
BaseFormatter.ts
MonthlyFormatter.ts
ClockifyClient.ts
SlackNotifier.ts
TimeAnalyzer.ts
index.ts
.gitignore
.prettierrc
eslint.config.js
package.json
README.md
tsconfig.json
================================================================
Files
================================================================
================
File: .github/workflows/deploy-lambda.yml
================
name: Deploy to AWS Lambda
on:
push:
branches:
- main
env:
LAMBDA_FUNCTION_NAME: time-warden
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run Tests
run: npm run test || echo "No tests specified"
- name: Build TypeScript
run: npm run build
- name: Package Lambda
run: |
echo "Creating deployment package..."
cd dist
zip -r ../lambda.zip .
cd ..
zip -r lambda.zip node_modules/
echo "Package size: $(ls -lh lambda.zip | awk '{print $5}')"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Deploy to Lambda
id: deploy
run: |
echo "Starting deployment..."
# Store the current version for potential rollback
CURRENT_VERSION=$(aws lambda get-function --function-name ${{ env.LAMBDA_FUNCTION_NAME }} --query 'Configuration.Version' --output text)
echo "Current function version: $CURRENT_VERSION"
# Deploy new version
aws lambda update-function-code \
--function-name ${{ env.LAMBDA_FUNCTION_NAME }} \
--zip-file fileb://lambda.zip
- name: Verify Deployment
run: |
echo "Waiting for function update to complete..."
sleep 10
# Get function state and configuration
FUNCTION_INFO=$(aws lambda get-function --function-name ${{ env.LAMBDA_FUNCTION_NAME }})
FUNCTION_STATE=$(echo $FUNCTION_INFO | jq -r '.Configuration.State')
LAST_UPDATE=$(echo $FUNCTION_INFO | jq -r '.Configuration.LastModified')
CODE_SIZE=$(echo $FUNCTION_INFO | jq -r '.Configuration.CodeSize')
echo "Function State: $FUNCTION_STATE"
echo "Last Updated: $LAST_UPDATE"
echo "Code Size: $CODE_SIZE bytes"
if [ "$FUNCTION_STATE" != "Active" ]; then
echo "Error: Function is not in Active state"
exit 1
fi
- name: Rollback on Failure
if: failure()
run: |
if [[ -n "${{ env.current_version }}" ]]; then
echo "Deployment failed, rolling back to version ${{ env.current_version }}"
aws lambda update-function-code \
--function-name ${{ env.LAMBDA_FUNCTION_NAME }} \
--revision ${{ env.current_version }}
# Verify rollback
ROLLBACK_STATE=$(aws lambda get-function \
--function-name ${{ env.LAMBDA_FUNCTION_NAME }} \
--query 'Configuration.State' \
--output text)
echo "Rollback state: $ROLLBACK_STATE"
if [ "$ROLLBACK_STATE" != "Active" ]; then
echo "Error: Rollback failed, manual intervention required"
exit 1
fi
echo "Rollback completed successfully"
fi
================
File: .repomix/bundles.json
================
{
"bundles": {}
}
================
File: docs/rules/alert-rules.md
================
# Alert Rules
## 🚨 Alert Types
### 1. Missing Hours Alert
**Trigger Conditions:**
- Total daily hours < 8 hours
- Only on working days
- Excludes holidays and weekends
**Alert Format:**
- User name and email
- Total hours logged
- Missing hours amount
- Date of missing entries
### 2. Suspicious Duration Alert
**Trigger Conditions:**
- Single time entry > 10 hours
- Multiple entries in same time period
- Overlapping time entries
**Alert Format:**
- Entry details (start/end time)
- Duration of suspicious entry
- Project and task information
- User name and email
### 3. Gap Alert
**Trigger Conditions:**
- Gap between entries > 4 hours
- Only during working hours
- Excludes lunch time gaps
**Alert Format:**
- Gap start and end time
- Gap duration
- Surrounding entry details
- User name and email
## 📊 Alert Grouping
### Daily Report Grouping
- Grouped by user
- Sorted by team
- All alert types included
- Summary at top of report
### Monthly Report Grouping
- Grouped by team
- Summary of alert patterns
- Trend analysis
- Team-wise statistics
## 🔔 Notification Channels
### Slack Notifications
- Sent to configured Slack channel
- Uses formatted blocks for readability
- Includes direct links to Clockify
- Mentions relevant team leads
## 🎯 Alert Priority
### High Priority
- Missing entire day's entries
- Multiple overlapping entries
- Gaps > 8 hours
### Medium Priority
- Single missing hour alerts
- Gaps between 4-8 hours
- Long duration entries
### Low Priority
- Minor overlaps
- Suspicious patterns
- Non-standard hour distributions
## 🔄 Alert Lifecycle
### Generation
1. Alert condition detected
2. Alert data collected
3. Priority assigned
4. Notification formatted
### Delivery
1. Grouped with other alerts
2. Formatted for channel
3. Sent to Slack
4. Delivery confirmed
### Resolution
- No explicit resolution required
- Resolved by correcting time entries
- New entries automatically validated
## ⚙️ Configuration
### Thresholds
- Minimum daily hours: 8
- Maximum single entry: 10 hours
- Maximum gap: 4 hours
- Overlap tolerance: 0 minutes
### Timing
- Daily check: 4:30 AM IST
- Monthly check: 11:30 AM IST (Mondays)
- Immediate alerts: None (batch processing only)
## 🔄 Maintenance
This document should be updated when:
1. Alert thresholds change
2. New alert types are added
3. Alert format changes
4. Notification channels are modified
================
File: docs/rules/holiday-rules.md
================
# Holiday Management Rules
## 📅 Holiday Configuration
### Format Requirements
- Dates must be in `YYYY-MM-DD` format
- Multiple dates are comma-separated
- No spaces between dates in configuration
- Example: `2025-03-14,2025-08-15,2025-10-02`
### Configuration Location
- Stored in Lambda environment variable: `HOLIDAYS`
- Can be updated through AWS Lambda configuration
- Changes take effect immediately after update
## 🎯 Holiday Impact
### Time Tracking
- No time entries required on holidays
- Holiday dates are excluded from:
- Daily checks
- Working days calculations
- Missing hours alerts
### Reporting
- Holidays are skipped in daily reports
- Monthly reports account for holidays in total hour calculations
- Previous working day calculations skip holidays
## 🔄 Holiday Update Process
### Adding New Holidays
1. Format new holiday dates in `YYYY-MM-DD`
2. Append to existing holiday list with comma
3. Update Lambda environment variable
4. No deployment needed - takes effect immediately
### Removing Holidays
1. Remove date from comma-separated list
2. Ensure no trailing/leading commas
3. Update Lambda environment variable
4. Takes effect immediately
## ⚠️ Important Considerations
### Timezone
- All holiday dates are considered in IST (Asia/Kolkata)
- Holiday period is full day (00:00 to 23:59 IST)
### Validation
- Invalid date formats will be ignored
- Duplicate dates are automatically handled
- Weekend holidays should still be included for clarity
## 📝 Current Holiday List (2025)
- March 14, 2025 (Friday)
- August 9, 2025 (Saturday)
- August 15, 2025 (Friday)
- August 16, 2025 (Saturday)
- October 2, 2025 (Thursday)
## 🔄 Maintenance
This document should be updated when:
1. New holidays are added
2. Holiday dates change
3. Holiday handling logic changes
4. Date format requirements change
================
File: docs/rules/time-rules.md
================
# Time Tracking Rules
## ⏰ Daily Time Requirements
### Required Hours
- **Minimum Hours**: 8 hours per working day
- **Working Hours**: Standard working hours are tracked in IST (Asia/Kolkata timezone)
- **Grace Period**: None (entries must be logged for the correct day)
### Time Entry Thresholds
- **Maximum Single Entry**: 10 hours (entries exceeding this are flagged)
- **Maximum Gap**: 4 hours (gaps between entries exceeding this are flagged)
- **Minimum Entry Duration**: No minimum (but should be meaningful)
## 🚨 Alert Conditions
### Missing Hours Alert
- Triggered when total daily hours < 8 hours
- Calculated at the end of each working day
- Reported in the next day's morning report
### Suspicious Entry Alert
Triggered for:
- Single entries > 10 hours
- Gaps between entries > 4 hours
- Overlapping time entries
- Multiple entries in same time period
## 📅 Working Day Definition
### Standard Working Days
- Monday through Friday
- Excluding weekends (Saturday and Sunday)
- Excluding configured holidays
### Time Calculation
- Time is calculated in hours with two decimal places
- Entries are considered in IST (Asia/Kolkata) timezone
- Daily totals are calculated from 00:00 to 23:59 IST
## 🔄 Update Process
These rules should be updated when:
1. Time requirements change
2. Alert thresholds are modified
3. Working day definitions change
4. Timezone requirements change
## 📊 Reporting Schedule
### Daily Reports
- Run at 4:30 AM IST (Mon-Fri)
- Checks previous working day's entries
- Sent to configured Slack channel
### Monthly Reports
- Run at 11:30 AM IST (Every Monday)
- Summarizes current month's data
- Groups data by teams
- Includes all users regardless of daily check settings
================
File: docs/technical/implementation-details.md
================
# Implementation Details
## 🔄 Rate Limiting
### Clockify API
- Requests are queued with 50ms delay between requests
- Batch processing of users (5 users per batch)
- 1-second delay between batches
- Auto-retry on rate limit (429) responses
## 📊 Data Processing
### Time Calculations
- All times are stored in UTC
- All business logic uses IST (Asia/Kolkata)
- Hours are rounded to 2 decimal places
- Time entries are sorted chronologically for analysis
### Pagination
- Time entries are fetched in pages of 50
- Automatic handling of multiple pages
- Continues until no more entries are found
## 👥 User Management
### User Configuration
- Stored in `users.json`
- Each user has:
- `id`: Clockify user ID
- `name`: Display name
- `email`: Email address
- `checkEnabled`: Whether to include in daily checks
- `requiredHours`: Daily hours requirement (default: 8)
- `notifySlack`: Whether to send Slack notifications
- `team`: Team assignment
### Team Structure
- teamAlpha
- teamBravo
- teamCharlie
- teamDelta
- teamMobileApp
- teamZenuProject
- teamInfra
- teamDataAndAnalytics
## 🔔 Notification System
### Slack Message Formatting
- Uses Slack Block Kit for rich formatting
- Team-specific emojis for visual distinction
- Hierarchical organization (Team → Member → Details)
- Timestamps in IST format
### Alert Types
1. Individual Notifications
- Direct messages for personal time issues
- Includes specific entry details
- Links to Clockify entries
2. Daily Summary
- Grouped by team
- Missing entries section
- Suspicious entries section
- Generated at 4:30 AM IST
3. Monthly Report
- Team-wise grouping
- Total hours comparison
- Progress tracking
- Generated at 11:30 AM IST (Mondays)
## ⚙️ Error Handling
### API Errors
- Automatic retry on rate limits
- Error logging with context
- Graceful degradation on partial failures
- Batch isolation (single user failure doesn't affect others)
### Data Validation
- Invalid date format handling
- Missing entry detection
- Duplicate entry checking
- Timezone conversion safety
## 🔄 Process Flow
### Daily Check
1. Get previous working day
2. Fetch enabled users
3. Process in batches
4. Analyze time entries
5. Send notifications
### Monthly Check
1. Calculate month range
2. Fetch all users
3. Process in batches
4. Group by teams
5. Calculate expected hours
6. Send monthly report
================
File: docs/technical/lintingAndFormatting.md
================
# Linting & Formatting Integration Checklist
This checklist outlines all the steps needed to integrate ESLint and Prettier into your project to ensure consistent code quality and formatting.
---
## Overview
- **ESLint**: Lints your code to catch syntax errors and enforce coding standards.
- **Prettier**: Formats your code automatically to maintain a consistent style.
- This checklist will guide you through installing dependencies, creating configuration files, updating package scripts, and verifying the integration.
---
## Step 1: Install Dependencies
- [x] Install ESLint
- [x] Install Prettier
- [x] Install `@typescript-eslint/parser`
- [x] Install `@typescript-eslint/eslint-plugin`
- [x] Install `eslint-config-prettier`
- [x] Install `eslint-plugin-prettier`
_Example command:_
```bash
npm install --save-dev eslint prettier @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-prettier eslint-plugin-prettier
```
## Step 2: Create ESLint Configuration
- [x] Create a file named `.eslintrc.json` at the project root
- [x] Set the parser to `@typescript-eslint/parser`
- [x] Extend the following configurations:
- `eslint:recommended`
- `plugin:@typescript-eslint/recommended`
- `plugin:prettier/recommended`
- [x] Set the environment to Node.js
- [x] Add any additional rules if needed while deferring formatting rules to Prettier
## Step 3: Create Prettier Configuration
- [x] Create a file named `.prettierrc` at the project root
- [x] Define your formatting preferences:
- [x] Use 2 spaces for indentation
- [x] Use single quotes
- [x] Include trailing commas where appropriate
- [x] Set any other style rules that suit your project
## Step 4: Update package.json Scripts
- [x] Open your `package.json` file
- [x] Add or update the scripts section with the following commands:
- [x] Linting Script:
```json
"lint": "eslint 'src/**/*.{ts,tsx,js,jsx}'"
```
- [x] Formatting Script:
```json
"format": "prettier --write 'src/**/*.{ts,tsx,js,jsx,json,md}'"
```
## Step 5: Verify and Run Locally
- [x] Run the lint script:
- [x] Execute: `npm run lint`
- [x] Run the format script:
- [x] Execute: `npm run format`
- [x] Fix any linting errors or formatting issues reported
## Step 6: Future Integration with GitHub Actions (Optional)
- [ ] Create a GitHub Actions workflow file (e.g., `.github/workflows/ci.yml`) that:
- [ ] Checks out your repository
- [ ] Sets up the Node.js environment
- [ ] Runs `npm install` to install dependencies
- [ ] Executes `npm run lint` and `npm run format` as part of the CI process
- [ ] Test the workflow in a branch before merging to your main branch
## Final Verification
- [x] Ensure all files in the `src` directory are linted and formatted correctly
- [x] Verify that your development workflow includes running the lint and format scripts before pushing new code
- [x] Update your project documentation with instructions on how to use these scripts
================
File: docs/technical/todo-deploy-lambda.md
================
# GitHub Actions AWS Lambda Deployment Checklist
This checklist outlines every step required to set up a GitHub Actions workflow that automatically builds, packages, and deploys your AWS Lambda function.
---
## 1. Basic Workflow Setup
- [x] **Create Workflow File**
- Create a file at `.github/workflows/deploy-lambda.yml`.
- [x] **Configure Trigger**
- Set the workflow to trigger on pushes to the `main` branch.
- [x] **Test Workflow Execution**
- Add a simple job that logs a message (e.g., "Hello, Lambda!") to ensure the workflow file is recognized.
---
## 2. Repository Checkout
- [x] **Add Checkout Step**
- Include a step using `actions/checkout@v3` to check out your repository code.
- Verify that the code is available to subsequent steps.
---
## 3. Node.js Environment Setup
- [x] **Set Up Node.js**
- Add a step using `actions/setup-node@v3` to install Node.js (e.g., version 16).
- Confirm that the correct Node.js version is installed.
---
## 4. Install Dependencies and Build Project
- [x] **Install Dependencies**
- Add a step to run `npm install` to install project dependencies.
- [x] **Build Project**
- Add a step to run `npm run build` to compile your TypeScript code (or build your project) into the `dist` folder.
- Verify that the `dist` folder contains the expected output files.
---
## 5. Package the Build Output
- [x] **Package Build Files**
- Add a step to change into the `dist` directory, run a zip command to package all files into `lambda.zip`, and then return to the project root.
- Confirm that the `lambda.zip` file is created successfully.
---
## 6. Configure AWS Credentials
- [x] **Setup AWS Credentials**
- Add a step using `aws-actions/configure-aws-credentials@v2` to configure AWS credentials.
- Ensure GitHub Secrets (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and optionally `AWS_REGION`) are configured in your repository.
- Verify that the credentials are correctly applied.
---
## 7. Deploy to AWS Lambda
- [x] **Deploy the Lambda Function**
- Add a step to deploy your Lambda function using the AWS CLI command.
- Replace `your-lambda-function-name` with your actual Lambda function name.
- Verify that the deployment command outputs a success message and that AWS Lambda is updated.
---
## 8. Final Integration Testing
- [x] **Test the Complete Workflow**
- Added test step before deployment
- Added deployment verification step
- Added automatic rollback on failure
---
## 9. Documentation and Best Practices
- [x] **Document the Setup**
- Created comprehensive deployment documentation in `docs/deployment.md`
- Included details on GitHub Secrets configuration
- Added troubleshooting guide
- [x] **Plan for Future Enhancements**
- Added Slack notifications for deployment status
- Implemented rollback steps for failed deployments
- Added deployment verification steps
---
## Additional Notes
- Ensure that all commands and steps are tested locally (or in a test branch) before relying on the automated deployment.
- Keep your GitHub Secrets up to date and monitor AWS Lambda logs after each deployment to catch any runtime issues.
---
================
File: docs/technical/typescriptConversion.md
================
# TypeScript Conversion Todo Checklist
## 1. Setup and Environment
- [x] **Create `tsconfig.json`**
- Target: ES2019 (or later)
- Module: CommonJS
- Enable strict type checking (`"strict": true`)
- Set `"esModuleInterop": true`
- Specify `"outDir": "./dist"`
- Enable `"sourceMap": true`
- [x] **Update `package.json` Scripts**
- Add `"build": "tsc"`
- Add `"start": "ts-node index.ts"` (or another appropriate command for local testing)
- [x] **Install Dependencies**
- Install TypeScript and ts-node:
`npm install --save-dev typescript ts-node`
- Install Node.js type definitions:
`npm install --save-dev @types/node`
- Install other necessary packages (e.g., axios, moment)
_(Skip adding extra type definitions for Slack if you don't want them)_
## 2. Convert Configuration Files
- [x] **Convert `config/UserConfig.js` to TypeScript**
- Rename file to `UserConfig.ts`
- Define minimal interfaces/types for the User object (e.g., `IUser`) if desired, or use basic types
- Ensure proper import of the JSON file (`users.json`)
- [x] **Verify `config/users.json`**
- Confirm that it remains unchanged and is correctly referenced
## 3. Convert Service Modules
### 3.1 Analyzers
- [x] **Convert `services/analyzers/BaseAnalyzer.js` to `BaseAnalyzer.ts`**
- Add type annotations for method parameters and return types
- Define types for any structured data where needed
- [x] **Convert `services/analyzers/MonthlyAnalyzer.js` to `MonthlyAnalyzer.ts`**
- Import `BaseAnalyzer.ts` correctly
- Add type annotations for functions like `analyzeEntries` and `groupByTeam`
- Define types for analysis results and team groupings as necessary
### 3.2 Formatters
- [x] **Convert `services/formatters/BaseFormatter.js` to `BaseFormatter.ts`**
- Add type annotations for methods creating Slack block elements
- For Slack objects, feel free to use `any` (or minimal types) if you prefer not to add extra type definitions
- [x] **Convert `services/formatters/MonthlyFormatter.js` to `MonthlyFormatter.ts`**
- Import `BaseFormatter.ts` correctly
- Add type annotations for functions like `formatReport` and `getTeamEmoji`
- Use minimal types (or `any`) for Slack message blocks to keep things simple
### 3.3 Clients and Notifiers
- [x] **Convert `services/ClockifyClient.js` to `ClockifyClient.ts`**
- Use axios type definitions for HTTP requests
- Annotate the request queue, rate limiting logic, and API responses
- Define clear return types for methods like `getWorkspaces`, `getUserInfo`, and `getTimeEntries`
- [x] **Convert `services/SlackNotifier.js` to `SlackNotifier.ts`**
- Import Slack WebClient from `@slack/web-api` and use its built-in types, or fallback to `any` if you prefer
- Add type annotations to methods like `notifyChannel`, `notifyBulk`, and `notifyMonthly`
- For Slack message blocks, using `any` is acceptable to avoid extra type definitions
### 3.4 Time Analyzer
- [x] **Convert `services/TimeAnalyzer.js` to `TimeAnalyzer.ts`**
- Import and use `MonthlyAnalyzer.ts` with proper types
- Add type annotations for functions analyzing time entries and calculating totals
- Define types for input entries and analysis results where it makes sense
## 4. Convert the Entry Point
- [x] **Convert `index.js` to `index.ts`**
- Update the Lambda handler to use appropriate TypeScript types for the event and context objects
- Update all module imports to reference the new `.ts` files
- Ensure that the logic for processing daily and monthly reports remains unchanged
## 5. Integration and Wiring
- [x] **Update Import Paths**
- Verify that all paths are updated to reference the new TypeScript files
- [x] **Build the Project**
- Run `npm run build` (or `tsc`) to compile the project
- Resolve any type errors or issues that arise during compilation
## 6. Testing and Verification
- [ ] **Module-Level Testing**
- Test each converted module individually to ensure functionality
- [ ] **Integration Testing**
- Use local testing tools (e.g., ts-lambda-local-dev) to run the Lambda handler
- Verify that Slack notifications (daily and monthly reports) work as expected
- Compare outputs with known working versions to catch any regressions
- [ ] **Full System Run**
- Run the complete project end-to-end to confirm that all modules work together
## 7. Documentation and Final Cleanup
- [x] **Update Documentation**
- Modify README and any other documentation to reflect the new TypeScript setup
- [x] **Code Cleanup**
- Remove any unused JavaScript files that have been converted
- Ensure that all changes are committed with clear commit messages
- [x] **Final Verification**
- Confirm that there is no orphaned code and that all functionality is integrated and working as expected
================
File: docs/templates/holiday-config-template.json
================
{
"holidays": [
{
"date": "2025-03-14",
"description": "Holiday Name",
"type": "public"
},
{
"date": "2025-08-09",
"description": "Holiday Name",
"type": "public"
},
{
"date": "2025-08-15",
"description": "Holiday Name",
"type": "public"
},
{
"date": "2025-08-16",
"description": "Holiday Name",
"type": "public"
},
{
"date": "2025-10-02",
"description": "Holiday Name",
"type": "public"
}
],
"format": {
"dateFormat": "YYYY-MM-DD",
"timezone": "Asia/Kolkata",
"types": ["public", "company", "optional"],
"envFormat": "comma-separated dates only"
},
"examples": {
"envVariable": "2025-03-14,2025-08-09,2025-08-15,2025-08-16,2025-10-02",
"notes": [
"Dates must be in YYYY-MM-DD format",
"No spaces between dates in env variable",
"Include weekend holidays for clarity",
"All dates are considered in IST timezone"
]
}
}
================
File: docs/templates/user-config-template.json
================
================
File: docs/deployment.md
================
# Deployment Documentation
## GitHub Actions Deployment
This project uses GitHub Actions to automatically deploy updates to AWS Lambda whenever changes are pushed to the main branch.
### Prerequisites
Before the GitHub Actions workflow can run successfully, you need to configure the following secrets in your GitHub repository:
1. AWS Credentials:
- `AWS_ACCESS_KEY_ID`: Your AWS access key
- `AWS_SECRET_ACCESS_KEY`: Your AWS secret key
- `AWS_REGION`: The AWS region where your Lambda function is deployed (e.g., `us-east-1`)
### Workflow Steps
1. **Code Checkout**: The workflow checks out the latest code from the repository
2. **Setup**: Configures Node.js 16 and npm
3. **Testing**: Runs any configured tests