@mudrichenkoevgeny/shared-foundation 0.0.47 → 0.0.48
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 +6 -36
- package/index.d.ts +520 -59
- package/index.js +442 -16
- package/index.mjs +442 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mudrichenkoevgeny/shared-foundation
|
|
2
2
|
|
|
3
|
-
TypeScript & Zod contracts, API routes, error codes, permission models, and branded types generated directly from the [shared-foundation](https://github.com/mudrichenkoevgeny/shared-foundation) Kotlin Multiplatform (KMP) repository.
|
|
3
|
+
TypeScript & Zod contracts, API routes, error codes, permission models, runtime enums, and branded types generated directly from the [shared-foundation](https://github.com/mudrichenkoevgeny/shared-foundation) Kotlin Multiplatform (KMP) repository.
|
|
4
4
|
|
|
5
5
|
Provides a single source of truth (SSOT) between Kotlin Backend/KMP services and TypeScript/React web applications.
|
|
6
6
|
|
|
@@ -19,41 +19,11 @@ yarn add @mudrichenkoevgeny/shared-foundation zod
|
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
22
|
-
- **Zod Schemas**: Auto-generated `z.ZodType` validation schemas for all Request payloads and Response DTOs
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
|
|
27
|
-
## Quick Usage Example
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
import {
|
|
31
|
-
ManagementSecuritySettingsRoutes,
|
|
32
|
-
SecurityErrorCodes,
|
|
33
|
-
apiErrorResponseSchema,
|
|
34
|
-
toUserIdOrThrow
|
|
35
|
-
} from '@mudrichenkoevgeny/shared-foundation';
|
|
36
|
-
|
|
37
|
-
// 1. Using Route Constants
|
|
38
|
-
const url = ManagementSecuritySettingsRoutes.GET_MANAGEMENT_SECURITY_SETTINGS;
|
|
39
|
-
|
|
40
|
-
// 2. Branded Types
|
|
41
|
-
const userId = toUserIdOrThrow('123e4567-e89b-12d3-a456-426614174000');
|
|
42
|
-
|
|
43
|
-
// 3. Validating API Responses with Zod
|
|
44
|
-
async function fetchUserSettings() {
|
|
45
|
-
const response = await fetch(url);
|
|
46
|
-
const json = await response.json();
|
|
47
|
-
|
|
48
|
-
if (!response.ok) {
|
|
49
|
-
const error = apiErrorResponseSchema.parse(json);
|
|
50
|
-
if (error.code === SecurityErrorCodes.TOTP_NOT_ENABLED) {
|
|
51
|
-
console.error('TOTP configuration required');
|
|
52
|
-
}
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
```
|
|
22
|
+
- **Zod Schemas**: Auto-generated `z.ZodType` validation schemas for all Request payloads and Response DTOs.
|
|
23
|
+
- **Runtime Enums**: TS types & runtime JS objects for all enums and string unions (`UserAuthProvider`, `UserRole`, `UserAccountStatus`, `AccountLockoutType`, `ClientType`, `SortOrder`, `UserSortValues`, etc.).
|
|
24
|
+
- **Route Constants**: Strongly typed API endpoint routes.
|
|
25
|
+
- **Error & Permission Codes**: Literal string definitions for all application error codes and permission strings.
|
|
26
|
+
- **Branded Types & Helpers**: Type-safe domain identifiers with converter helpers.
|
|
57
27
|
|
|
58
28
|
## Source Code & Repository
|
|
59
29
|
|