@levrbet/shared 0.1.186 → 0.1.188

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 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
- ## Module Formats
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
- Both formats are automatically selected based on how you import:
60
+ This package requires the following peer dependencies:
38
61
 
39
- ```javascript
40
- // ESM (React/Vite)
41
- import { e18 } from "@levrbet/shared/core"
42
-
43
- // CommonJS (Node.js servers)
44
- const { e18 } = require("@levrbet/shared/core")
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 watch # Watch mode
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 link @levrbet/shared
85
+ npm install /path/to/levr-shared/*.tgz
86
+ npx levrbet-prisma-setup
88
87
  ```
89
88
 
90
89
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levrbet/shared",
3
- "version": "0.1.186",
3
+ "version": "0.1.188",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -117,8 +117,8 @@ model League {
117
117
  levrLeagueId String @unique
118
118
  opticOddsLeagueId String @unique
119
119
  lsportsLeagueId String @unique
120
- logoKey String
121
- logoUrl String
120
+ logoKey String
121
+ logoUrl String
122
122
 
123
123
  tournamentObjectId String @db.ObjectId
124
124
  tournament Tournament @relation(fields: [tournamentObjectId], references: [objectId])
@@ -169,11 +169,11 @@ model Fixture {
169
169
  awayTeam Json
170
170
  fixtureStatus FixtureStatus
171
171
 
172
- leagueObjectId String @db.ObjectId
173
- league League @relation(fields: [leagueObjectId], references: [objectId])
172
+ leagueObjectId String @db.ObjectId
173
+ league League @relation(fields: [leagueObjectId], references: [objectId])
174
174
 
175
- createdAt DateTime @default(now())
176
- updatedAt DateTime @updatedAt
175
+ createdAt DateTime @default(now())
176
+ updatedAt DateTime @updatedAt
177
177
 
178
178
  @@index([fixtureDate])
179
179
  @@index([leagueObjectId])
@@ -187,7 +187,7 @@ model Scores {
187
187
  totalScoresHome Float
188
188
  totalScoresAway Float
189
189
 
190
- fixtureObjectId String @unique
190
+ fixtureObjectId String @unique
191
191
 
192
192
  createdAt DateTime @default(now())
193
193
  updatedAt DateTime @updatedAt
@@ -278,7 +278,7 @@ model Market {
278
278
  activeProvider Json
279
279
  marketType MarketType
280
280
  status MarketStatus
281
- winner Sides?
281
+ winner Sides?
282
282
 
283
283
  levrGameObjectId String @db.ObjectId // new unique identifier
284
284
  levrGame LevrGame @relation(fields: [levrGameObjectId], references: [objectId])
@@ -296,21 +296,22 @@ enum UserOddsPreference {
296
296
  }
297
297
 
298
298
  model User {
299
- objectId String @id @default(auto()) @map("_id") @db.ObjectId
300
- walletAddress String @unique
301
- userName String @unique
302
- email String @unique
303
- timeZone String
304
- preferredTimeZone String?
305
- userOddsPreference UserOddsPreference
306
- profileImageUrl String?
307
- profileImageKey String?
308
- language String @default("en")
309
- showRiskWarnings Boolean @default(true)
310
- showPreTransactionReminders Boolean @default(true)
311
- twoFactorEnabled Boolean @default(false)
312
- autoDetectTimeZone Boolean @default(true)
313
-
299
+ objectId String @id @default(auto()) @map("_id") @db.ObjectId
300
+ walletAddress String @unique
301
+ userName String @unique
302
+ email String @unique
303
+ timeZone String
304
+ preferredTimeZone String?
305
+ userOddsPreference UserOddsPreference
306
+ profileImageUrl String?
307
+ profileImageKey String?
308
+ language String @default("en")
309
+ showRiskWarnings Boolean @default(true)
310
+ showPreTransactionReminders Boolean @default(true)
311
+ twoFactorEnabled Boolean @default(false)
312
+ autoDetectTimeZone Boolean @default(true)
313
+ autoApproveTxs Boolean @default(false)
314
+ requireWithdrawalConfirmation Boolean @default(true)
314
315
 
315
316
  createdAt DateTime @default(now())
316
317
  updatedAt DateTime @updatedAt