@levrbet/shared 0.1.186 → 0.1.187
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/README.md +43 -44
- package/package.json +1 -1
- package/prisma/schema.prisma +1 -0
package/README.md
CHANGED
|
@@ -5,15 +5,43 @@ Shared utilities, components, and types for the LEVR platform.
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @levrbet/shared
|
|
8
|
+
npm install @levrbet/shared @prisma/client prisma
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Prisma Setup
|
|
12
|
+
|
|
13
|
+
This package includes a Prisma schema. After installation, run the setup script to generate the Prisma client:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx levrbet-prisma-setup
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or add it to your `postinstall` script in `package.json`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"scripts": {
|
|
24
|
+
"postinstall": "levrbet-prisma-setup"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This will:
|
|
30
|
+
|
|
31
|
+
1. Copy the Prisma schema to your project's `prisma/` folder
|
|
32
|
+
2. Generate the `@prisma/client` in your `node_modules`
|
|
33
|
+
|
|
11
34
|
## Usage
|
|
12
35
|
|
|
13
36
|
```typescript
|
|
14
37
|
// Core utilities (universal - works in both browser and Node.js)
|
|
15
38
|
import { e18, LevrBaseMarket } from "@levrbet/shared/core"
|
|
16
39
|
|
|
40
|
+
// Prisma types and client (requires running prisma setup first)
|
|
41
|
+
import { PrismaClient, GamePhase, MarketStatus } from "@levrbet/shared/core"
|
|
42
|
+
// Or directly from @prisma/client
|
|
43
|
+
import { PrismaClient, GamePhase } from "@prisma/client"
|
|
44
|
+
|
|
17
45
|
// Server-only utilities
|
|
18
46
|
import { authMiddleWare, validateApiKey } from "@levrbet/shared/server"
|
|
19
47
|
|
|
@@ -23,68 +51,39 @@ import { useAuth } from "@levrbet/shared/react"
|
|
|
23
51
|
|
|
24
52
|
## Package Structure
|
|
25
53
|
|
|
26
|
-
- **`/core`** - Blockchain contracts, types, and universal utilities
|
|
54
|
+
- **`/core`** - Blockchain contracts, types, Prisma re-exports, and universal utilities
|
|
27
55
|
- **`/server`** - Node.js server utilities (auth, database, logging, middleware)
|
|
28
56
|
- **`/react`** - React components and hooks
|
|
29
57
|
|
|
30
|
-
##
|
|
31
|
-
|
|
32
|
-
This package provides **dual builds** for maximum compatibility:
|
|
33
|
-
|
|
34
|
-
- **ESM** (`dist/esm/`) - For React/Vite consumers (preserves React context)
|
|
35
|
-
- **CommonJS** (`dist/cjs/`) - For Node.js servers
|
|
58
|
+
## Peer Dependencies
|
|
36
59
|
|
|
37
|
-
|
|
60
|
+
This package requires the following peer dependencies:
|
|
38
61
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
### TypeScript Configuration
|
|
48
|
-
|
|
49
|
-
**React/Vite consumers** - Use bundler resolution:
|
|
50
|
-
|
|
51
|
-
```json
|
|
52
|
-
{
|
|
53
|
-
"compilerOptions": {
|
|
54
|
-
"moduleResolution": "bundler"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**Node.js servers** - Use classic resolution:
|
|
60
|
-
|
|
61
|
-
```json
|
|
62
|
-
{
|
|
63
|
-
"compilerOptions": {
|
|
64
|
-
"module": "CommonJS",
|
|
65
|
-
"moduleResolution": "node",
|
|
66
|
-
"esModuleInterop": true
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
```
|
|
62
|
+
| Package | Required For |
|
|
63
|
+
| ----------------------- | ---------------------------- |
|
|
64
|
+
| `@prisma/client` | Database types and client |
|
|
65
|
+
| `prisma` | Generating the Prisma client |
|
|
66
|
+
| `react` | React hooks (optional) |
|
|
67
|
+
| `@tanstack/react-query` | React query hooks (optional) |
|
|
68
|
+
| `@privy-io/react-auth` | Privy auth hooks (optional) |
|
|
70
69
|
|
|
71
70
|
## Development
|
|
72
71
|
|
|
73
72
|
```bash
|
|
74
73
|
npm install # Install dependencies
|
|
75
74
|
npm run build # Build package
|
|
76
|
-
npm run
|
|
75
|
+
npm run dev # Build and pack for local testing
|
|
77
76
|
```
|
|
78
77
|
|
|
79
78
|
### Local Testing
|
|
80
79
|
|
|
81
80
|
```bash
|
|
82
81
|
# In this package
|
|
83
|
-
npm run dev
|
|
84
|
-
npm link
|
|
82
|
+
npm run dev # Creates a .tgz file
|
|
85
83
|
|
|
86
84
|
# In consumer project
|
|
87
|
-
npm
|
|
85
|
+
npm install /path/to/levr-shared/*.tgz
|
|
86
|
+
npx levrbet-prisma-setup
|
|
88
87
|
```
|
|
89
88
|
|
|
90
89
|
## License
|
package/package.json
CHANGED
package/prisma/schema.prisma
CHANGED