alliance-shared-types 1.0.0
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 +79 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/types/auth.types.d.ts +56 -0
- package/dist/types/auth.types.js +33 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Alliance Shared Types
|
|
2
|
+
|
|
3
|
+
This package contains shared TypeScript type definitions for the Alliance B2B Travel Portal. It ensures type consistency between the frontend and backend applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Local Development
|
|
8
|
+
|
|
9
|
+
During local development, you can use the package directly from your local filesystem:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# From the frontend or backend project
|
|
13
|
+
npm install ../alliance-shared-types
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Using npm
|
|
17
|
+
|
|
18
|
+
Once published to npm:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install alliance-shared-types
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Using GitHub
|
|
25
|
+
|
|
26
|
+
You can also install directly from GitHub:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install git+https://github.com/yourusername/alliance-shared-types.git
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// Import specific types
|
|
36
|
+
import { UserData, AuthResponse, USER_ROLES } from 'alliance-shared-types';
|
|
37
|
+
|
|
38
|
+
// Use in your code
|
|
39
|
+
const user: UserData = {
|
|
40
|
+
userId: '123',
|
|
41
|
+
email: 'user@example.com',
|
|
42
|
+
role: USER_ROLES.ADMIN,
|
|
43
|
+
agentId: '456',
|
|
44
|
+
status: 'active'
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Available Types
|
|
49
|
+
|
|
50
|
+
### Authentication
|
|
51
|
+
|
|
52
|
+
- `UserCredentials` - Login credentials
|
|
53
|
+
- `AuthResponse` - Authentication response with token and user data
|
|
54
|
+
- `UserData` - User information
|
|
55
|
+
- `JwtPayload` - JWT token payload structure
|
|
56
|
+
- `TokenData` - Token data with expiration
|
|
57
|
+
|
|
58
|
+
### Enums and Constants
|
|
59
|
+
|
|
60
|
+
- `UserRole` and `USER_ROLES` - User role types and constants
|
|
61
|
+
- `UserStatus` and `USER_STATUSES` - User status types and constants
|
|
62
|
+
- `AgentType` and `AGENT_TYPES` - Agent type types and constants
|
|
63
|
+
- `KycStatus` and `KYC_STATUSES` - KYC status types and constants
|
|
64
|
+
- `AgentStatus` and `AGENT_STATUSES` - Agent status types and constants
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
To build the package:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm run build
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Publishing
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm login
|
|
78
|
+
npm publish
|
|
79
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/auth.types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Export all types from the types directory
|
|
18
|
+
__exportStar(require("./types/auth.types"), exports);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface UserCredentials {
|
|
2
|
+
email: string;
|
|
3
|
+
password: string;
|
|
4
|
+
}
|
|
5
|
+
export interface AuthResponse {
|
|
6
|
+
token: string;
|
|
7
|
+
user: UserData;
|
|
8
|
+
}
|
|
9
|
+
export interface UserData {
|
|
10
|
+
userId: string;
|
|
11
|
+
email: string;
|
|
12
|
+
role: string;
|
|
13
|
+
agentId: string;
|
|
14
|
+
agentType?: string;
|
|
15
|
+
status: string;
|
|
16
|
+
}
|
|
17
|
+
export interface JwtPayload {
|
|
18
|
+
userId: string;
|
|
19
|
+
email: string;
|
|
20
|
+
role: string;
|
|
21
|
+
agentId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface TokenData {
|
|
24
|
+
token: string;
|
|
25
|
+
expiresIn: string | number;
|
|
26
|
+
}
|
|
27
|
+
export type UserRole = 'admin' | 'staff' | 'agent_user';
|
|
28
|
+
export declare const USER_ROLES: {
|
|
29
|
+
ADMIN: UserRole;
|
|
30
|
+
STAFF: UserRole;
|
|
31
|
+
AGENT_USER: UserRole;
|
|
32
|
+
};
|
|
33
|
+
export type UserStatus = 'active' | 'inactive' | 'suspended';
|
|
34
|
+
export declare const USER_STATUSES: {
|
|
35
|
+
ACTIVE: UserStatus;
|
|
36
|
+
INACTIVE: UserStatus;
|
|
37
|
+
SUSPENDED: UserStatus;
|
|
38
|
+
};
|
|
39
|
+
export type AgentType = 'admin' | 'distributor' | 'retailer';
|
|
40
|
+
export declare const AGENT_TYPES: {
|
|
41
|
+
ADMIN: AgentType;
|
|
42
|
+
DISTRIBUTOR: AgentType;
|
|
43
|
+
RETAILER: AgentType;
|
|
44
|
+
};
|
|
45
|
+
export type KycStatus = 'pending' | 'verified' | 'rejected';
|
|
46
|
+
export declare const KYC_STATUSES: {
|
|
47
|
+
PENDING: KycStatus;
|
|
48
|
+
VERIFIED: KycStatus;
|
|
49
|
+
REJECTED: KycStatus;
|
|
50
|
+
};
|
|
51
|
+
export type AgentStatus = 'active' | 'inactive' | 'suspended';
|
|
52
|
+
export declare const AGENT_STATUSES: {
|
|
53
|
+
ACTIVE: AgentStatus;
|
|
54
|
+
INACTIVE: AgentStatus;
|
|
55
|
+
SUSPENDED: AgentStatus;
|
|
56
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AGENT_STATUSES = exports.KYC_STATUSES = exports.AGENT_TYPES = exports.USER_STATUSES = exports.USER_ROLES = void 0;
|
|
4
|
+
// Constants for user roles
|
|
5
|
+
exports.USER_ROLES = {
|
|
6
|
+
ADMIN: 'admin',
|
|
7
|
+
STAFF: 'staff',
|
|
8
|
+
AGENT_USER: 'agent_user'
|
|
9
|
+
};
|
|
10
|
+
// Constants for user statuses
|
|
11
|
+
exports.USER_STATUSES = {
|
|
12
|
+
ACTIVE: 'active',
|
|
13
|
+
INACTIVE: 'inactive',
|
|
14
|
+
SUSPENDED: 'suspended'
|
|
15
|
+
};
|
|
16
|
+
// Constants for agent types
|
|
17
|
+
exports.AGENT_TYPES = {
|
|
18
|
+
ADMIN: 'admin',
|
|
19
|
+
DISTRIBUTOR: 'distributor',
|
|
20
|
+
RETAILER: 'retailer'
|
|
21
|
+
};
|
|
22
|
+
// Constants for KYC statuses
|
|
23
|
+
exports.KYC_STATUSES = {
|
|
24
|
+
PENDING: 'pending',
|
|
25
|
+
VERIFIED: 'verified',
|
|
26
|
+
REJECTED: 'rejected'
|
|
27
|
+
};
|
|
28
|
+
// Constants for agent statuses
|
|
29
|
+
exports.AGENT_STATUSES = {
|
|
30
|
+
ACTIVE: 'active',
|
|
31
|
+
INACTIVE: 'inactive',
|
|
32
|
+
SUSPENDED: 'suspended'
|
|
33
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "alliance-shared-types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared TypeScript types for Alliance B2B Travel Portal",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepare": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"typescript",
|
|
16
|
+
"types",
|
|
17
|
+
"alliance",
|
|
18
|
+
"travel"
|
|
19
|
+
],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.0.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"typescript": ">=4.0.0"
|
|
27
|
+
}
|
|
28
|
+
}
|