feat: migrate to Bun-native, fix Planner task dates, remove hardcoded test values
- Remove dotenv dependency, implement lightweight Bun-native env loader - Replace Node.js fs/path with Bun file APIs (Bun.file, Bun.write) - Fix Planner task creation to use form's due date with proper UTC handling - Make table name, Planner assignee configurable via activeConfig and env vars - Remove all hardcoded test values for PROD readiness - Update NOTES.md with PROD mode checklist
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
# Session Notes
|
||||||
|
|
||||||
|
## 2026-01-07
|
||||||
|
|
||||||
|
### Context
|
||||||
|
- Picked up the Job-Form project
|
||||||
|
- Stack: TypeScript server, HTML frontend with TailwindCSS
|
||||||
|
- Current version: v1.0.0-beta4
|
||||||
|
|
||||||
|
### Project Summary
|
||||||
|
- **Purpose**: Job creation form with Excel sync and PocketBase backend
|
||||||
|
- **Features**:
|
||||||
|
- Form submission → PocketBase record → Excel sync
|
||||||
|
- Teams channel notifications (Adaptive Cards)
|
||||||
|
- Teams message management UI
|
||||||
|
|
||||||
|
### Known Issues / Limitations
|
||||||
|
- Teams message deletion not supported via Graph API (HTTP 405) — platform limitation
|
||||||
|
- Workaround: Delete messages directly in Teams client
|
||||||
|
|
||||||
|
### Today's Work
|
||||||
|
- [x] Migrate to full Bun-native stack (removed dotenv, use Bun file APIs)
|
||||||
|
- [x] Fix Planner task creation to use form's due date with proper UTC handling
|
||||||
|
- [x] Remove hardcoded test values — now uses activeConfig for all environments
|
||||||
|
- [x] Make assignee configurable via `PLANNER_ASSIGNEE_ID` env var
|
||||||
|
|
||||||
|
### PROD Mode Checklist
|
||||||
|
Before switching `MODE = 'PROD'`, ensure `/home/admin/secrets/.env` contains:
|
||||||
|
- `PB_COLLECTION` - PocketBase collection name (e.g., `Job_Info_Prod`)
|
||||||
|
- `EXCEL_TABLE_NAME` - Excel table name (e.g., `Job_List`)
|
||||||
|
- `PLANNER_GROUP_ID` - Microsoft Planner group ID
|
||||||
|
- `PLANNER_PLAN_ID` - Microsoft Planner plan ID
|
||||||
|
- `PLANNER_BUCKET_ID` - Microsoft Planner bucket ID
|
||||||
|
- `PLANNER_ASSIGNEE_ID` - User ID for Planner task assignee (e.g., `1a6e9d10-138a-43e4-a09e-1f50463148c9`)
|
||||||
|
- `PLANNER_ASSIGNEE_NAME` - Display name for assignee (e.g., `Alex Ewing`)
|
||||||
|
- All standard Azure AD + PocketBase creds (CLIENT_ID, CLIENT_SECRET, etc.)
|
||||||
|
|
||||||
|
**No hardcoded test values remain in the codebase.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
_Last updated: 2026-01-07_
|
||||||
+23
-2
@@ -1,8 +1,29 @@
|
|||||||
|
|
||||||
import { config } from 'dotenv';
|
|
||||||
import { Client } from '@microsoft/microsoft-graph-client';
|
import { Client } from '@microsoft/microsoft-graph-client';
|
||||||
|
|
||||||
config({ path: '/home/admin/secrets/.env' });
|
// Bun-native env loader
|
||||||
|
async function loadEnv(filePath: string) {
|
||||||
|
const file = Bun.file(filePath);
|
||||||
|
if (!(await file.exists())) {
|
||||||
|
console.warn(`⚠ Env file not found: ${filePath}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const text = await file.text();
|
||||||
|
for (const line of text.split('\n')) {
|
||||||
|
const trimmed = line.trim();
|
||||||
|
if (!trimmed || trimmed.startsWith('#')) continue;
|
||||||
|
const eqIndex = trimmed.indexOf('=');
|
||||||
|
if (eqIndex === -1) continue;
|
||||||
|
const key = trimmed.slice(0, eqIndex).trim();
|
||||||
|
let value = trimmed.slice(eqIndex + 1).trim();
|
||||||
|
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
||||||
|
value = value.slice(1, -1);
|
||||||
|
}
|
||||||
|
process.env[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await loadEnv('/home/admin/secrets/.env');
|
||||||
|
|
||||||
async function getGraphToken() {
|
async function getGraphToken() {
|
||||||
const tokenEndpoint = `https://login.microsoftonline.com/${process.env.TENANT_ID}/oauth2/v2.0/token`;
|
const tokenEndpoint = `https://login.microsoftonline.com/${process.env.TENANT_ID}/oauth2/v2.0/token`;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@microsoft/microsoft-graph-client": "^3.0.7",
|
"@microsoft/microsoft-graph-client": "^3.0.7",
|
||||||
"dotenv": "^17.2.3",
|
|
||||||
"hono": "^4.10.8",
|
"hono": "^4.10.8",
|
||||||
"pocketbase": "^0.26.5"
|
"pocketbase": "^0.26.5"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user