@caseparts-org/casecore 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/README.md +60 -69
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1,69 +1,60 @@
1
- # React + TypeScript + Vite
2
-
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
-
5
- Currently, two official plugins are available:
6
-
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
-
10
- ## Expanding the ESLint configuration
11
-
12
- If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
13
-
14
- ```js
15
- export default tseslint.config([
16
- globalIgnores(['dist']),
17
- {
18
- files: ['**/*.{ts,tsx}'],
19
- extends: [
20
- // Other configs...
21
-
22
- // Remove tseslint.configs.recommended and replace with this
23
- ...tseslint.configs.recommendedTypeChecked,
24
- // Alternatively, use this for stricter rules
25
- ...tseslint.configs.strictTypeChecked,
26
- // Optionally, add this for stylistic rules
27
- ...tseslint.configs.stylisticTypeChecked,
28
-
29
- // Other configs...
30
- ],
31
- languageOptions: {
32
- parserOptions: {
33
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
34
- tsconfigRootDir: import.meta.dirname,
35
- },
36
- // other options...
37
- },
38
- },
39
- ])
40
- ```
41
-
42
- You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
43
-
44
- ```js
45
- // eslint.config.js
46
- import reactX from 'eslint-plugin-react-x'
47
- import reactDom from 'eslint-plugin-react-dom'
48
-
49
- export default tseslint.config([
50
- globalIgnores(['dist']),
51
- {
52
- files: ['**/*.{ts,tsx}'],
53
- extends: [
54
- // Other configs...
55
- // Enable lint rules for React
56
- reactX.configs['recommended-typescript'],
57
- // Enable lint rules for React DOM
58
- reactDom.configs.recommended,
59
- ],
60
- languageOptions: {
61
- parserOptions: {
62
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
63
- tsconfigRootDir: import.meta.dirname,
64
- },
65
- // other options...
66
- },
67
- },
68
- ])
69
- ```
1
+ # CaseCore React Component & Logic Library
2
+
3
+ This project is a reusable logic and component library for React and Next.js applications, designed to house all core business logic for our front-end apps, decoupled from any specific UI. While it currently focuses on authentication, claims, and session management, it is intended to grow into a central place for all shared business logic, utilities, and core functionality needed across our projects.
4
+
5
+ ## Project Structure
6
+
7
+ - **/lib/**
8
+ - Contains all code intended for export as part of the library.
9
+ - Includes authentication context/provider, hooks, utility functions, and type definitions.
10
+ - The main entry point for consumers is `lib/index.ts`.
11
+ - **/src/App.tsx**
12
+ - Local demo/test app for development, not included in the library build.
13
+ - Useful for running and testing components locally with `npm run dev`.
14
+ - **/public/**
15
+ - Static assets for local development/demo.
16
+ - **/index.html**
17
+ - Entry point for local development with Vite.
18
+
19
+ ## Key Features
20
+
21
+ - **Authentication Context (`AuthProvider`)**
22
+ - Provides authentication state, login/logout/impersonate methods, and claims to your app via React context.
23
+ - Handles JWT parsing, localStorage/sessionStorage, and API integration.
24
+ - **Claims & Session Utilities**
25
+ - `buildClaimsFromPayload`: Normalizes JWT payloads into a consistent claims object.
26
+ - `getSessionId`: Manages session IDs in sessionStorage.
27
+ - `useLocalStorage`: React hook for persistent state with automatic key prefixing.
28
+ - **TypeScript-first**
29
+ - All types and interfaces are defined in `lib/authentication/AuthTypes.ts` for strong typing and IDE support.
30
+ - **Testing**
31
+ - Tests are colocated with their modules (e.g., `AuthContext.test.tsx`).
32
+ - Mocks for fetch and JWT decoding are used to simulate authentication flows.
33
+
34
+ ## Usage
35
+
36
+ - **As a library:**
37
+ - Import from `lib/index.ts` in your consuming app:
38
+ ```ts
39
+ import { AuthProvider, useAuthContext } from 'casecore/lib';
40
+ ```
41
+ - **For local development:**
42
+ - Run `npm run dev` to start the Vite dev server and use the demo app in `src/App.tsx`.
43
+ - **To run tests locally:**
44
+ - Run `npm test` or `npx vitest run` to execute all tests.
45
+ - For watch mode (auto-re-run on file changes), use:
46
+ ```sh
47
+ npx vitest
48
+ ```
49
+ - Test files are colocated with their modules (e.g., `AuthContext.test.tsx`).
50
+
51
+ ## Contributing
52
+
53
+ - Add new core logic, hooks, or components to `/lib`.
54
+ - Add or update exports in `lib/index.ts`.
55
+ - Use `/src` and `/public` for local-only demo/testing code.
56
+ - Write and run tests for all exported logic.
57
+
58
+ ## License
59
+
60
+ MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/casecore",
3
3
  "private": false,
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -29,7 +29,8 @@
29
29
  "dependencies": {
30
30
  "jwt-decode": "^4.0.0",
31
31
  "react": "^18.0.0",
32
- "react-dom": "^18.0.0"
32
+ "react-dom": "^18.0.0",
33
+ "uuid": "^11.1.0"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@eslint/js": "^9.29.0",