Skip to content

Commit 8b9cc87

Browse files
committed
Build complete preference injection system
Implement comprehensive, production-ready preference injection library with: Core Features: - Type-safe preference injection with TypeScript generics - Multiple provider support (Memory, File, Environment, API) - Priority-based conflict resolution with multiple strategies - Event system for preference change notifications Security & Performance: - AES-256-GCM encryption for sensitive preferences - LRU and TTL caching implementations - Schema-based and custom validation rules - Comprehensive audit logging system Advanced Features: - Preference migration system with versioning - Conflict resolution strategies (highest/lowest priority, merge, override, error) - Deep merge support for object preferences - TTL support for time-limited preferences Framework Integrations: - React hooks (usePreference, usePreferences) with context provider - Express middleware with REST API endpoints - User-specific preference support Developer Tools: - CLI tool for preference management - Comprehensive unit and integration tests - ESLint, Prettier, and TypeScript strict mode - GitHub Actions CI/CD pipeline - TypeDoc API documentation generation Documentation: - Detailed README with quick start guide - Complete API documentation - Usage examples for all major features - Contributing guidelines - CHANGELOG and LICENSE Project Structure: - src/core: Core injector implementation - src/providers: All preference providers - src/utils: Utilities (cache, validation, encryption, audit, migration) - src/integrations: Framework integrations (React, Express) - src/cli: Command-line tool - tests/: Comprehensive test suite - examples/: Usage examples - docs/: API documentation This provides a complete, enterprise-ready preference/configuration management system suitable for Node.js, React, and Express applications.
1 parent ec1c374 commit 8b9cc87

38 files changed

Lines changed: 6168 additions & 0 deletions

.eslintrc.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
7+
"prettier"
8+
],
9+
"plugins": ["@typescript-eslint", "prettier"],
10+
"parserOptions": {
11+
"ecmaVersion": 2020,
12+
"sourceType": "module",
13+
"project": "./tsconfig.json"
14+
},
15+
"env": {
16+
"node": true,
17+
"es6": true,
18+
"jest": true
19+
},
20+
"rules": {
21+
"prettier/prettier": "error",
22+
"@typescript-eslint/explicit-function-return-type": "error",
23+
"@typescript-eslint/no-explicit-any": "error",
24+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
25+
"@typescript-eslint/no-floating-promises": "error",
26+
"@typescript-eslint/no-misused-promises": "error",
27+
"no-console": ["warn", { "allow": ["warn", "error"] }],
28+
"prefer-const": "error",
29+
"no-var": "error"
30+
}
31+
}

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [16.x, 18.x, 20.x]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run linter
30+
run: npm run lint
31+
32+
- name: Run tests
33+
run: npm test
34+
35+
- name: Run build
36+
run: npm run build
37+
38+
- name: Check formatting
39+
run: npm run format:check
40+
41+
coverage:
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- uses: actions/checkout@v3
46+
47+
- name: Use Node.js
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: '20.x'
51+
cache: 'npm'
52+
53+
- name: Install dependencies
54+
run: npm ci
55+
56+
- name: Generate coverage
57+
run: npm run test:coverage
58+
59+
- name: Upload coverage to Codecov
60+
uses: codecov/codecov-action@v3
61+
with:
62+
files: ./coverage/lcov.info
63+
flags: unittests
64+
name: codecov-umbrella

.github/workflows/publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish-npm:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: '20.x'
18+
registry-url: 'https://registry.npmjs.org'
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Run tests
24+
run: npm test
25+
26+
- name: Build
27+
run: npm run build
28+
29+
- name: Publish to npm
30+
run: npm publish --access public
31+
env:
32+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Dependencies
2+
node_modules/
3+
package-lock.json
4+
yarn.lock
5+
6+
# Build output
7+
dist/
8+
build/
9+
*.tsbuildinfo
10+
11+
# Testing
12+
coverage/
13+
.nyc_output/
14+
*.lcov
15+
16+
# Environment
17+
.env
18+
.env.local
19+
.env.*.local
20+
21+
# IDE
22+
.vscode/
23+
.idea/
24+
*.swp
25+
*.swo
26+
*~
27+
.DS_Store
28+
29+
# Logs
30+
logs/
31+
*.log
32+
npm-debug.log*
33+
yarn-debug.log*
34+
yarn-error.log*
35+
36+
# Temporary files
37+
tmp/
38+
temp/
39+
*.tmp
40+
41+
# Documentation build
42+
docs/api/

.prettierrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"arrowParens": "always",
9+
"endOfLine": "lf"
10+
}

CHANGELOG.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2024-01-XX
9+
10+
### Added
11+
12+
- Core preference injection system with type safety
13+
- Multiple provider support:
14+
- In-memory provider
15+
- File-based provider (JSON and .env formats)
16+
- Environment variable provider
17+
- API-based provider
18+
- Priority-based conflict resolution with multiple strategies
19+
- Caching system with LRU and TTL implementations
20+
- Validation system with common validation rules
21+
- Schema-based validation
22+
- AES-256-GCM encryption for sensitive preferences
23+
- Audit logging with multiple implementations
24+
- Migration system for versioned preferences
25+
- React integration with hooks and context provider
26+
- Express.js middleware and REST API
27+
- CLI tool for preference management
28+
- Comprehensive TypeScript type definitions
29+
- Event system for preference changes
30+
- Full test suite with >80% coverage
31+
- Complete documentation and examples
32+
33+
### Features
34+
35+
#### Core Features
36+
37+
- **Type-Safe API**: Full TypeScript support with generic type helpers
38+
- **Multiple Providers**: Use file, environment, API, and memory providers together
39+
- **Priority System**: Resolve conflicts with customizable strategies
40+
- **Performance**: Built-in caching with configurable TTL
41+
- **Security**: AES-256-GCM encryption for sensitive data
42+
- **Validation**: Schema-based and custom validation rules
43+
- **Auditing**: Track all preference operations
44+
- **Migrations**: Version and migrate preference schemas
45+
- **Events**: Subscribe to preference changes
46+
47+
#### Framework Integrations
48+
49+
- **React**: Hooks (`usePreference`, `usePreferences`) and context provider
50+
- **Express**: Middleware and RESTful API router
51+
- **CLI**: Command-line tool for management
52+
53+
### Documentation
54+
55+
- Comprehensive README with quick start guide
56+
- API documentation
57+
- Usage examples for all major features
58+
- Contributing guidelines
59+
- CLAUDE.md for AI assistant integration
60+
61+
### Developer Experience
62+
63+
- ESLint and Prettier configuration
64+
- Jest testing framework
65+
- TypeDoc API documentation generation
66+
- GitHub Actions CI/CD pipeline
67+
- Automated testing and coverage reporting
68+
69+
## [Unreleased]
70+
71+
### Planned
72+
73+
- Redis provider for distributed caching
74+
- MongoDB provider for persistent storage
75+
- Vue.js integration
76+
- Angular integration
77+
- GraphQL API support
78+
- WebSocket real-time sync
79+
- Preference versioning UI
80+
- Advanced conflict resolution strategies
81+
- Multi-tenant support
82+
- Internationalization support
83+
84+
---
85+
86+
For more information, see the [README](README.md).

0 commit comments

Comments
 (0)