@famgia/omnify-react-sso 2.2.0 → 2.2.2

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 (33) hide show
  1. package/README.md +404 -113
  2. package/dist/@omnify-base/package.json +16 -0
  3. package/dist/@omnify-base/schemas/Branch.ts +131 -0
  4. package/dist/@omnify-base/schemas/BranchCache.ts +131 -0
  5. package/dist/@omnify-base/schemas/OrganizationCache.ts +117 -0
  6. package/dist/@omnify-base/schemas/Permission.ts +114 -0
  7. package/dist/@omnify-base/schemas/Role.ts +121 -0
  8. package/dist/@omnify-base/schemas/RolePermission.ts +97 -0
  9. package/dist/@omnify-base/schemas/Team.ts +110 -0
  10. package/dist/@omnify-base/schemas/TeamCache.ts +110 -0
  11. package/dist/@omnify-base/schemas/TeamPermission.ts +109 -0
  12. package/dist/@omnify-base/schemas/User.ts +135 -0
  13. package/dist/@omnify-base/schemas/UserCache.ts +135 -0
  14. package/dist/@omnify-base/schemas/common.ts +47 -0
  15. package/dist/@omnify-base/schemas/i18n.ts +118 -0
  16. package/dist/index.cjs +1200 -381
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +245 -7
  19. package/dist/index.d.ts +245 -7
  20. package/dist/index.js +1158 -355
  21. package/dist/index.js.map +1 -1
  22. package/dist/schemas/index.cjs +201 -133
  23. package/dist/schemas/index.cjs.map +1 -1
  24. package/dist/schemas/index.d.cts +61 -28
  25. package/dist/schemas/index.d.ts +61 -28
  26. package/dist/schemas/index.js +173 -112
  27. package/dist/schemas/index.js.map +1 -1
  28. package/dist/testing/index.d.cts +1 -1
  29. package/dist/testing/index.d.ts +1 -1
  30. package/dist/{types-BCBSfJJr.d.cts → types-CJmA2a9r.d.cts} +102 -1
  31. package/dist/{types-BCBSfJJr.d.ts → types-CJmA2a9r.d.ts} +102 -1
  32. package/package.json +10 -3
  33. package/scripts/postinstall.cjs +43 -0
package/README.md CHANGED
@@ -14,12 +14,12 @@ pnpm add @famgia/omnify-react-sso
14
14
 
15
15
  - **React Hooks**: `useSso()`, `useAuth()`, `useOrganization()` for SSO state management
16
16
  - **React Components**: `SsoProvider`, `SsoCallback`, `OrganizationSwitcher`, `ProtectedRoute`
17
- - **SSO Service**: `createSsoService()` for API communication
18
- - **User Management**: User schema with Zod validation and i18n support
19
- - **Role-Based Access Control (RBAC)**: Role, Permission, and RolePermission schemas
20
- - **Team Management**: Team and TeamPermission schemas
17
+ - **SSO Services**: Individual services for auth, roles, permissions, branches, teams
18
+ - **SSO Schemas**: User, Role, Permission, Branch, Team with Zod validation and i18n
19
+ - **Bundled Types**: `@omnify-base` types included - no extra setup needed
21
20
  - **Multi-locale Support**: Japanese and English labels/messages
22
21
  - **Query Keys**: Pre-defined TanStack Query keys for SSO data
22
+ - **Test Utilities**: Mock factories and helpers for testing
23
23
 
24
24
  ## Quick Start
25
25
 
@@ -55,114 +55,342 @@ function Dashboard() {
55
55
  </div>
56
56
  );
57
57
  }
58
+
59
+ // 3. Import types directly from package
60
+ import type { Role, Permission, Branch, User } from '@famgia/omnify-react-sso';
58
61
  ```
59
62
 
60
63
  ---
61
64
 
62
65
  ## 🔧 Development & Build Workflow
63
66
 
64
- ### Prerequisites
65
-
66
- This package depends on schemas from `omnifyjp/omnify-client-laravel-sso`. The build process will:
67
+ > ⛔ **CRITICAL: DO NOT MODIFY THIS BUILD PROCESS**
68
+ >
69
+ > Quy trình build này đã được thiết kế test kỹ lưỡng. **TUYỆT ĐỐI KHÔNG ĐƯỢC THAY ĐỔI** các bước sau:
70
+ > 1. `build:schemas` - Fetch và generate TypeScript từ YAML
71
+ > 2. `build:lib` - Bundle với tsup
72
+ > 3. `build:copy-base` - Copy @omnify-base vào dist (QUAN TRỌNG cho TypeScript consumers)
73
+ > 4. `postinstall` - Tự động tạo @omnify-base cho consumers
74
+ >
75
+ > Nếu thay đổi, TypeScript consumers sẽ không resolve được types!
67
76
 
68
- 1. **Try local**: Copy from `../omnify-client-laravel-sso/database/schemas/Sso`
69
- 2. **Fallback to git**: Clone via SSH from GitHub (requires access to omnifyjp org)
77
+ ### Overview
70
78
 
71
- **SSH Access Required**: Developers must have SSH access to `git@github.com:omnifyjp/omnify-client-laravel-sso.git`
79
+ This package bundles SSO schemas from the Laravel backend (`omnify-client-laravel-sso`) into a self-contained npm package. Consumers don't need to generate schemas - everything is included.
72
80
 
73
- ### Build Commands
74
-
75
- ```bash
76
- # Full build (schemas + library)
77
- pnpm build
81
+ ```
82
+ ┌─────────────────────────────────────────────────────────────────┐
83
+ │ Source: omnify-client-laravel-sso │
84
+ │ database/schemas/Sso/*.yaml │
85
+ │ (Branch, Permission, Role, Team, User, etc.) │
86
+ └───────────────────────────┬─────────────────────────────────────┘
87
+
88
+ ▼ pnpm build
89
+ ┌─────────────────────────────────────────────────────────────────┐
90
+ │ Package: @famgia/omnify-react-sso │
91
+ │ │
92
+ │ dist/ │
93
+ │ ├── index.js (hooks, components, services) │
94
+ │ ├── index.d.ts (type definitions) │
95
+ │ ├── schemas/ (bundled SSO schemas) │
96
+ │ ├── testing/ (test utilities) │
97
+ │ └── @omnify-base/ (bundled for TypeScript consumers) │
98
+ └───────────────────────────┬─────────────────────────────────────┘
99
+
100
+ ▼ npm install
101
+ ┌─────────────────────────────────────────────────────────────────┐
102
+ │ Consumer App (Boilerplate, etc.) │
103
+ │ │
104
+ │ import { useSso, Role, Permission } from '@famgia/...' │
105
+ │ // Everything just works - no schema generation needed! │
106
+ └─────────────────────────────────────────────────────────────────┘
107
+ ```
78
108
 
79
- # Build only schemas (fetch + generate types)
80
- pnpm build:schemas
109
+ ### Prerequisites
81
110
 
82
- # Build only library (requires schemas to exist)
83
- pnpm build:lib
111
+ 1. **Node.js 18+** and **pnpm**
112
+ 2. **SSH Access** to `git@github.com:omnifyjp/omnify-client-laravel-sso.git`
113
+ 3. Test SSH: `ssh -T git@github.com`
84
114
 
85
- # Run tests
86
- pnpm test
115
+ ### Build Commands
87
116
 
88
- # Type check
89
- pnpm typecheck
90
- ```
117
+ | Command | Description |
118
+ | ---------------------- | -------------------------------------------- |
119
+ | `pnpm build` | Full build (schemas → types → bundle → copy) |
120
+ | `pnpm build:schemas` | Fetch schemas and generate TypeScript types |
121
+ | `pnpm build:lib` | Bundle with tsup (requires schemas) |
122
+ | `pnpm build:copy-base` | Copy @omnify-base to dist for consumers |
123
+ | `pnpm test` | Run all tests |
124
+ | `pnpm typecheck` | Type check without emitting |
91
125
 
92
- ### Build Process Detail
126
+ ### Build Process (Detailed)
93
127
 
94
128
  ```
95
129
  ┌─────────────────────────────────────────────────────────────────┐
96
130
  │ pnpm build │
131
+ │ "pnpm build:schemas && pnpm build:lib && pnpm build:copy-base" │
97
132
  └───────────────────────────┬─────────────────────────────────────┘
98
133
 
134
+ ┌───────────────────┼───────────────────┐
135
+ ▼ ▼ ▼
136
+ ┌───────────────┐ ┌───────────────┐ ┌───────────────────────┐
137
+ │ build:schemas │ │ build:lib │ │ build:copy-base │
138
+ │ │ │ │ │ │
139
+ │ 1. Clean │ │ 1. tsup │ │ cp -r node_modules/ │
140
+ │ - schemas/ │ │ bundle │ │ @omnify-base dist/ │
141
+ │ - src/ │ │ │ │ │
142
+ │ schemas/ │ │ 2. Generate │ │ ⚠️ CRITICAL STEP! │
143
+ │ │ │ .d.ts │ │ Without this, TS │
144
+ │ 2. Get YAML │ │ │ │ consumers can't │
145
+ │ schemas │ │ 3. Output: │ │ resolve types │
146
+ │ (local or │ │ dist/*.js │ │ │
147
+ │ git clone) │ │ dist/*.d.ts│ │ │
148
+ │ │ │ │ │ │
149
+ │ 3. omnify │ │ │ │ │
150
+ │ generate │ │ │ │ │
151
+ │ --types- │ │ │ │ │
152
+ │ only │ │ │ │ │
153
+ └───────────────┘ └───────────────┘ └───────────────────────┘
154
+ │ │ │
155
+ └───────────────────┼───────────────────┘
99
156
 
100
- ┌─────────────────────────────────────────────────────────────────┐
101
- Step 1: pnpm build:schemas │
102
- │ │
103
- │ 1. Clean previous builds (schemas/, src/schemas/, src/enum/) │
104
- │ 2. Obtain SSO schemas: │
105
- │ - Try: ../omnify-client-laravel-sso/database/schemas/Sso │
106
- │ - Fallback: git clone from GitHub (sparse checkout) │
107
- │ 3. Run: npx omnify generate --types-only │
108
- │ → Creates @omnify-base in node_modules │
109
- │ → Generates src/schemas/*.ts │
110
- └───────────────────────────┬─────────────────────────────────────┘
111
-
112
-
113
- ┌─────────────────────────────────────────────────────────────────┐
114
- Step 2: pnpm build:lib (tsup) │
115
- │ │
116
- │ - Bundle src/index.ts dist/index.js │
117
- - Bundle src/schemas/index.ts → dist/schemas/index.js │
118
- - Generate .d.ts type definitions │
119
- - External: zod, @omnify-base/* │
120
- └─────────────────────────────────────────────────────────────────┘
157
+ dist/ (complete)
158
+ ├── index.js
159
+ ├── index.d.ts
160
+ ├── schemas/
161
+ ├── testing/
162
+ └── @omnify-base/ ← TypeScript types
163
+ ```
164
+
165
+ ### Step-by-Step Build Details
166
+
167
+ #### Step 1: `pnpm build:schemas` (scripts/build-schemas.ts)
168
+
169
+ ```typescript
170
+ // 1. Clean previous builds
171
+ rm -rf schemas/ src/schemas/ src/enum/
172
+
173
+ // 2. Obtain SSO schema YAML files
174
+ if (exists('../omnify-client-laravel-sso/database/schemas/Sso')) {
175
+ // Local copy (fastest)
176
+ cp -r ../omnify-client-laravel-sso/database/schemas/Sso schemas/
177
+ } else {
178
+ // Git clone (fallback)
179
+ git clone --sparse git@github.com:omnifyjp/omnify-client-laravel-sso.git
180
+ git sparse-checkout set database/schemas/Sso
181
+ cp schemas...
182
+ }
183
+
184
+ // 3. Generate TypeScript from YAML
185
+ npx omnify generate --types-only
186
+ // Creates:
187
+ // - node_modules/@omnify-base/schemas/*.ts
188
+ // - src/schemas/*.ts
189
+ ```
190
+
191
+ #### Step 2: `pnpm build:lib` (tsup)
192
+
193
+ ```typescript
194
+ // tsup.config.ts
195
+ export default defineConfig({
196
+ entry: {
197
+ index: 'src/index.ts',
198
+ 'schemas/index': 'src/schemas/index.ts',
199
+ 'testing/index': 'src/testing/index.ts',
200
+ },
201
+ format: ['esm', 'cjs'],
202
+ dts: true, // Generate .d.ts
203
+ clean: true, // Clean dist/ first
204
+ external: ['zod', 'react', ...], // Don't bundle these
205
+ noExternal: [/@omnify-base\/.*/], // Bundle @omnify-base JS
206
+ });
207
+ ```
208
+
209
+ **Important**: `noExternal: [/@omnify-base\/.*/]` bundles the JavaScript, but `.d.ts` files still reference `@omnify-base` externally.
210
+
211
+ #### Step 3: `pnpm build:copy-base`
212
+
213
+ ```bash
214
+ cp -r node_modules/@omnify-base dist/
215
+ ```
216
+
217
+ **Why this is critical:**
218
+ - The generated `.d.ts` files contain: `export { User } from '@omnify-base/schemas/User'`
219
+ - TypeScript in consumer apps needs to resolve `@omnify-base`
220
+ - Without this step, consumers get: `Cannot find module '@omnify-base/...'`
221
+
222
+ #### Postinstall Script (scripts/postinstall.cjs)
223
+
224
+ When consumers install the package, this script copies `@omnify-base` to their `node_modules`:
225
+
226
+ ```javascript
227
+ // Runs automatically after npm install
228
+ // Copies dist/@omnify-base → node_modules/@omnify-base
229
+ // This allows TypeScript to resolve the types
121
230
  ```
122
231
 
123
232
  ### First Time Setup
124
233
 
125
234
  ```bash
126
- # Option A: Just run build (auto-fetches via SSH)
235
+ # Option A: Build with auto-fetch (requires SSH access)
127
236
  pnpm install
128
- pnpm build # Will clone schemas from git automatically
237
+ pnpm build
129
238
 
130
- # Option B: Clone laravel-sso as sibling (for frequent schema changes)
131
- cd packages
239
+ # Option B: Clone Laravel package as sibling (for development)
240
+ cd /path/to/omnify/packages
132
241
  git clone git@github.com:omnifyjp/omnify-client-laravel-sso.git
133
242
  cd omnify-client-react-sso
134
243
  pnpm install
135
244
  pnpm build
136
245
  ```
137
246
 
138
- > **Note**: Build script uses SSH (`git@github.com:omnifyjp/...`). Ensure your SSH key is added to GitHub.
139
-
140
247
  ### When to Rebuild
141
248
 
142
- You need to run `pnpm build` when:
249
+ | Scenario | Action |
250
+ | -------------------------------- | ------------------------------------------- |
251
+ | First time setup | `pnpm build` |
252
+ | Schema YAML changed in Laravel | `pnpm build` |
253
+ | Added new hook/component/service | `pnpm build:lib` |
254
+ | Before publishing to npm | `pnpm build && pnpm test` |
255
+ | After `pnpm install` | Usually not needed (postinstall handles it) |
256
+
257
+ ### Publishing Checklist
143
258
 
144
- - ✅ First time setup
145
- - Schema changes in `omnify-client-laravel-sso`
146
- - After pulling updates from laravel-sso
147
- - ✅ Before publishing to npm
259
+ ```bash
260
+ # 1. Ensure you're on main branch
261
+ git checkout main && git pull
262
+
263
+ # 2. Full build
264
+ pnpm build
265
+
266
+ # 3. Run tests
267
+ pnpm test
268
+
269
+ # 4. Type check
270
+ pnpm typecheck
271
+
272
+ # 5. Bump version
273
+ npm version patch # or minor/major
274
+
275
+ # 6. Publish
276
+ npm publish --access public
277
+
278
+ # 7. Verify on npm
279
+ npm view @famgia/omnify-react-sso
280
+ ```
281
+
282
+ ---
283
+
284
+ ## 📦 Package Contents
285
+
286
+ After build, `dist/` contains:
287
+
288
+ ```
289
+ dist/
290
+ ├── index.js # Main entry (ESM)
291
+ ├── index.cjs # Main entry (CJS)
292
+ ├── index.d.ts # Type definitions
293
+ ├── schemas/
294
+ │ ├── index.js # SSO schemas bundle
295
+ │ └── index.d.ts
296
+ ├── testing/
297
+ │ ├── index.js # Test utilities
298
+ │ └── index.d.ts
299
+ ├── @omnify-base/ # Bundled types for TS resolution
300
+ │ ├── package.json
301
+ │ └── schemas/
302
+ │ ├── User.ts
303
+ │ ├── Role.ts
304
+ │ ├── Permission.ts
305
+ │ ├── Branch.ts
306
+ │ ├── Team.ts
307
+ │ └── ...
308
+ └── types-*.d.ts # Internal type chunks
309
+ ```
148
310
 
149
311
  ---
150
312
 
151
313
  ## Local Development with Boilerplate
152
314
 
153
- ### Linking Package to Boilerplate
315
+ ### Option 1: Use Published Package (Recommended)
316
+
317
+ ```bash
318
+ # In boilerplate/frontend
319
+ pnpm add @famgia/omnify-react-sso@latest
320
+ ```
321
+
322
+ The postinstall script automatically sets up `@omnify-base` for TypeScript.
154
323
 
155
- Instead of using npm registry or tarballs, link the package directly:
324
+ ### Option 2: Link Local Package (Development)
156
325
 
157
326
  ```bash
158
327
  # In boilerplate/frontend
159
- pnpm add /path/to/omnify/packages/omnify-client-react-sso
328
+ pnpm add link:/path/to/omnify/packages/omnify-client-react-sso
160
329
  ```
161
330
 
162
- This creates a symlink in `package.json`:
331
+ **After linking, manually run postinstall:**
332
+ ```bash
333
+ node node_modules/@famgia/omnify-react-sso/scripts/postinstall.cjs
334
+ ```
335
+
336
+ ### Consumer App Configuration
163
337
 
164
- ```json
165
- "@famgia/omnify-react-sso": "link:/path/to/omnify/packages/omnify-client-react-sso"
338
+ #### 1. Exclude SSO Schemas from Local Generation
339
+
340
+ In `omnify.config.ts`:
341
+
342
+ ```typescript
343
+ typescriptPlugin({
344
+ modelsPath: "./frontend/src/omnify/schemas",
345
+ exclude: [
346
+ // SSO types come from @famgia/omnify-react-sso
347
+ "Branch",
348
+ "Permission",
349
+ "Role",
350
+ "RolePermission",
351
+ "Team",
352
+ "TeamPermission",
353
+ "User", // Important!
354
+ ],
355
+ })
356
+ ```
357
+
358
+ #### 2. Import Patterns
359
+
360
+ ```typescript
361
+ // ✅ CORRECT: SSO types from package
362
+ import type { User, Role, Permission, Branch } from '@famgia/omnify-react-sso';
363
+ import { useSso, useAuth } from '@famgia/omnify-react-sso';
364
+ import { roleService, permissionService } from '@/lib/ssoService'; // configured instances
365
+
366
+ // ✅ CORRECT: App-specific types from local
367
+ import type { Product, Order } from '@/omnify/schemas';
368
+ import { getProductFieldLabel } from '@/omnify/schemas';
369
+
370
+ // ❌ WRONG: Don't import SSO types from local schemas
371
+ import type { Role } from '@/omnify/schemas'; // Error or duplicate!
372
+ ```
373
+
374
+ #### 3. Service Configuration
375
+
376
+ Create `lib/ssoService.ts` to configure services with your API URL:
377
+
378
+ ```typescript
379
+ import {
380
+ createAuthService,
381
+ createRoleService,
382
+ createPermissionService,
383
+ createBranchService,
384
+ createUserRoleService,
385
+ } from '@famgia/omnify-react-sso';
386
+
387
+ const apiUrl = process.env.NEXT_PUBLIC_API_URL!;
388
+
389
+ export const authService = createAuthService({ apiUrl });
390
+ export const roleService = createRoleService({ apiUrl });
391
+ export const permissionService = createPermissionService({ apiUrl });
392
+ export const branchService = createBranchService({ apiUrl });
393
+ export const userRoleService = createUserRoleService({ apiUrl });
166
394
  ```
167
395
 
168
396
  ### Development Workflow
@@ -170,74 +398,49 @@ This creates a symlink in `package.json`:
170
398
  ```
171
399
  ┌─────────────────────────────────────────────────────────────────┐
172
400
  │ omnify-client-laravel-sso (Laravel Package) │
173
- - SSO schema YAML files (source of truth)
174
- │ - Backend models, migrations, controllers │
401
+ database/schemas/Sso/*.yaml (Source of truth)
175
402
  └───────────────────────────┬─────────────────────────────────────┘
176
- schemas copied during build
403
+ pnpm build (copies + generates)
177
404
 
178
405
  ┌─────────────────────────────────────────────────────────────────┐
179
406
  │ @famgia/omnify-react-sso (This Package) │
180
-
181
- pnpm build
182
- │ ├── 1. Copy schemas from laravel-sso
183
- ├── 2. omnify generate --types-only
184
- │ └── 3. tsup bundle → dist/ │
185
- │ │
186
- │ Exports: │
187
- │ - React hooks (useSso, useAuth, useOrganization) │
188
- │ - React components (SsoProvider, ProtectedRoute, etc.) │
189
- │ - Services (createAuthService, createRoleService, etc.) │
190
- │ - SSO Schemas (Role, Permission, Branch, Team, User) │
191
- │ - Query Keys (ssoQueryKeys) │
407
+ dist/
408
+ ├── index.js (hooks, components, services)
409
+ │ ├── schemas/ (SSO types: User, Role, Permission...)
410
+ └── @omnify-base/(TypeScript resolution)
192
411
  └───────────────────────────┬─────────────────────────────────────┘
193
- linked via pnpm
412
+ npm install / pnpm link
194
413
 
195
414
  ┌─────────────────────────────────────────────────────────────────┐
196
415
  │ Boilerplate / Your App │
197
416
  │ │
198
- │ package.json:
199
- "@famgia/omnify-react-sso": "link:/path/to/package"
200
-
201
- omnify.config.ts:
202
- │ typescriptPlugin({ │
203
- │ exclude: ["Branch", "Role", "Permission", ...] // SSO types │
204
- │ }) │
417
+ Import from package:
418
+ │ - useSso, useAuth, useOrganization
419
+ - User, Role, Permission, Branch, Team
420
+ - createRoleService, ssoQueryKeys, etc.
205
421
  │ │
206
- Imports:
207
- │ - SSO types → from "@famgia/omnify-react-sso"
208
- │ - App types from "@/omnify/schemas" (local generate)
422
+ Generate locally (via omnify.config.ts):
423
+ │ - App-specific schemas only
424
+ │ - Product, Order, Invoice, etc.
209
425
  └─────────────────────────────────────────────────────────────────┘
210
426
  ```
211
427
 
212
428
  ### After Changing SSO Schemas
213
429
 
214
- 1. **Update Laravel package** (if schema YAML changed)
215
- 2. **Rebuild this package:**
430
+ 1. **Edit YAML** in `omnify-client-laravel-sso/database/schemas/Sso/`
431
+ 2. **Rebuild package:**
216
432
  ```bash
217
433
  cd packages/omnify-client-react-sso
218
434
  pnpm build
219
435
  ```
220
- 3. **Boilerplate automatically uses new dist** (linked)
221
-
222
- ### Boilerplate Configuration
223
-
224
- In the boilerplate's `omnify.config.ts`, exclude SSO schemas:
225
-
226
- ```typescript
227
- typescriptPlugin({
228
- modelsPath: "./frontend/src/omnify/schemas",
229
- exclude: [
230
- "Branch",
231
- "Permission",
232
- "Role",
233
- "RolePermission",
234
- "Team",
235
- "TeamPermission",
236
- ],
237
- })
238
- ```
239
-
240
- This prevents duplicate schema generation - SSO types come from this package.
436
+ 3. **If using npm (not link):** Publish and update
437
+ ```bash
438
+ npm version patch
439
+ npm publish --access public
440
+ # In boilerplate:
441
+ pnpm update @famgia/omnify-react-sso
442
+ ```
443
+ 4. **If using link:** Rebuild triggers automatic update
241
444
 
242
445
  ---
243
446
 
@@ -491,7 +694,95 @@ vi.mock('@famgia/omnify-react-sso', async () => {
491
694
  });
492
695
  ```
493
696
 
494
- > **Note**: Subpath exports (`/testing`) require the package to be installed from npm, not linked locally.
697
+ > **Note**: Subpath exports (`/testing`) may not work with linked packages in Vite/Vitest. Use direct imports or install from npm.
698
+
699
+ ---
700
+
701
+ ## Troubleshooting
702
+
703
+ ### ❌ Cannot find module '@omnify-base/schemas/...'
704
+
705
+ **Cause:** TypeScript can't resolve the bundled types.
706
+
707
+ **Solutions:**
708
+
709
+ 1. **If installed from npm:** Run postinstall manually
710
+ ```bash
711
+ node node_modules/@famgia/omnify-react-sso/scripts/postinstall.cjs
712
+ ```
713
+
714
+ 2. **If using pnpm link:** Same as above
715
+ ```bash
716
+ cd your-app/frontend
717
+ node node_modules/@famgia/omnify-react-sso/scripts/postinstall.cjs
718
+ ```
719
+
720
+ 3. **Verify @omnify-base exists:**
721
+ ```bash
722
+ ls node_modules/@omnify-base/schemas/
723
+ # Should show: User.ts, Role.ts, Permission.ts, etc.
724
+ ```
725
+
726
+ ### ❌ Module has no exported member 'Role' (from @/omnify/schemas)
727
+
728
+ **Cause:** You're importing SSO types from local schemas instead of the package.
729
+
730
+ **Fix:** Change imports:
731
+ ```typescript
732
+ // ❌ Wrong
733
+ import type { Role } from '@/omnify/schemas';
734
+
735
+ // ✅ Correct
736
+ import type { Role } from '@famgia/omnify-react-sso';
737
+ ```
738
+
739
+ ### ❌ Duplicate identifier 'User'
740
+
741
+ **Cause:** SSO schemas generated locally AND imported from package.
742
+
743
+ **Fix:** Add to `omnify.config.ts`:
744
+ ```typescript
745
+ typescriptPlugin({
746
+ exclude: ["User", "Role", "Permission", "Branch", "Team", "RolePermission", "TeamPermission"],
747
+ })
748
+ ```
749
+
750
+ ### ❌ Build fails: Cannot clone git repository
751
+
752
+ **Cause:** No SSH access to omnifyjp/omnify-client-laravel-sso.
753
+
754
+ **Fix:**
755
+ ```bash
756
+ # Test SSH access
757
+ ssh -T git@github.com
758
+
759
+ # If needed, add SSH key to GitHub
760
+ # Or clone manually as sibling:
761
+ git clone git@github.com:omnifyjp/omnify-client-laravel-sso.git ../omnify-client-laravel-sso
762
+ ```
763
+
764
+ ### ❌ Tests fail with "Cannot find module '@famgia/omnify-react-sso/testing'"
765
+
766
+ **Cause:** Subpath exports don't work well with linked packages in Vite.
767
+
768
+ **Fix:** Create local mock file instead:
769
+ ```typescript
770
+ // src/test/mocks/sso.ts
771
+ export function createMockUser(overrides = {}) {
772
+ return { id: '1', name: 'Test User', email: 'test@example.com', ...overrides };
773
+ }
774
+ ```
775
+
776
+ ---
777
+
778
+ ## Version History
779
+
780
+ | Version | Changes |
781
+ | ------- | -------------------------------------------------------- |
782
+ | 2.2.1 | Bundled @omnify-base for TS consumers, added postinstall |
783
+ | 2.2.0 | Added testing utilities subpath export |
784
+ | 2.1.0 | Split services into individual factories |
785
+ | 2.0.0 | Initial stable release |
495
786
 
496
787
  ---
497
788
 
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@omnify-base",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "exports": {
7
+ "./enum/*": {
8
+ "types": "./enum/*.ts",
9
+ "default": "./enum/*.ts"
10
+ },
11
+ "./schemas/*": {
12
+ "types": "./schemas/*.ts",
13
+ "default": "./schemas/*.ts"
14
+ }
15
+ }
16
+ }