@gymspace/sdk 1.2.4 → 1.2.5
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/dist/index.d.mts +176 -8
- package/dist/index.d.ts +176 -8
- package/dist/index.js +64 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/models/auth.ts +18 -2
- package/src/models/collaborators.ts +84 -0
- package/src/models/index.ts +2 -0
- package/src/models/invitations.ts +20 -3
- package/src/models/roles.ts +27 -0
- package/src/resources/collaborators.ts +68 -0
- package/src/resources/index.ts +2 -0
- package/src/resources/invitations.ts +14 -7
- package/src/resources/roles.ts +28 -0
- package/src/sdk.ts +6 -0
package/package.json
CHANGED
package/src/models/auth.ts
CHANGED
|
@@ -20,8 +20,15 @@ export interface LoginDto {
|
|
|
20
20
|
export interface LoginResponseDto {
|
|
21
21
|
access_token: string;
|
|
22
22
|
refresh_token: string;
|
|
23
|
-
user:
|
|
24
|
-
|
|
23
|
+
user: {
|
|
24
|
+
id: string;
|
|
25
|
+
email: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
userType: string;
|
|
28
|
+
};
|
|
29
|
+
lastActiveGymId?: string;
|
|
30
|
+
lastActiveOrganizationId?: string;
|
|
31
|
+
redirectPath?: string;
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
export interface VerifyEmailDto {
|
|
@@ -104,6 +111,14 @@ export interface InvitationValidationResponse {
|
|
|
104
111
|
};
|
|
105
112
|
}
|
|
106
113
|
|
|
114
|
+
export interface CollaboratorRoleDto {
|
|
115
|
+
collaboratorId: string;
|
|
116
|
+
roleId: string;
|
|
117
|
+
roleName: string;
|
|
118
|
+
gymId: string;
|
|
119
|
+
gymName: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
107
122
|
export interface CurrentSessionResponse {
|
|
108
123
|
accessToken: string;
|
|
109
124
|
refreshToken?: string;
|
|
@@ -161,5 +176,6 @@ export interface CurrentSessionResponse {
|
|
|
161
176
|
isActive: boolean;
|
|
162
177
|
};
|
|
163
178
|
permissions: string[];
|
|
179
|
+
collaborator?: CollaboratorRoleDto;
|
|
164
180
|
isAuthenticated: boolean;
|
|
165
181
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export interface Collaborator {
|
|
2
|
+
id: string;
|
|
3
|
+
userId: string;
|
|
4
|
+
gymId: string;
|
|
5
|
+
roleId: string;
|
|
6
|
+
status: 'pending' | 'active' | 'inactive';
|
|
7
|
+
hiredDate?: string;
|
|
8
|
+
profilePhotoId?: string;
|
|
9
|
+
coverPhotoId?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
specialties?: any;
|
|
12
|
+
user?: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
email: string;
|
|
16
|
+
phone?: string;
|
|
17
|
+
};
|
|
18
|
+
role?: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
permissions: string[];
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ListCollaboratorsParams {
|
|
26
|
+
page: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
status?: 'pending' | 'active' | 'inactive';
|
|
29
|
+
roleId?: string;
|
|
30
|
+
search?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface UpdateCollaboratorDto {
|
|
34
|
+
hiredDate?: string;
|
|
35
|
+
profilePhotoId?: string;
|
|
36
|
+
coverPhotoId?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
specialties?: any;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface UpdateStatusDto {
|
|
42
|
+
status: 'active' | 'inactive';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface UpdateRoleDto {
|
|
46
|
+
roleId: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ActivityQueryParams {
|
|
50
|
+
startDate?: string;
|
|
51
|
+
endDate?: string;
|
|
52
|
+
limit?: number;
|
|
53
|
+
type?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface StatsQueryParams {
|
|
57
|
+
startDate?: string;
|
|
58
|
+
endDate?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface CollaboratorStats {
|
|
62
|
+
contracts: {
|
|
63
|
+
total: number;
|
|
64
|
+
totalAmount: number;
|
|
65
|
+
averageAmount: number;
|
|
66
|
+
};
|
|
67
|
+
checkIns: {
|
|
68
|
+
total: number;
|
|
69
|
+
};
|
|
70
|
+
sales: {
|
|
71
|
+
total: number;
|
|
72
|
+
totalAmount: number;
|
|
73
|
+
};
|
|
74
|
+
clients: {
|
|
75
|
+
created: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ActivityItem {
|
|
80
|
+
type: string;
|
|
81
|
+
timestamp: string;
|
|
82
|
+
description: string;
|
|
83
|
+
metadata: any;
|
|
84
|
+
}
|
package/src/models/index.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export * from './auth';
|
|
3
3
|
export * from './organizations';
|
|
4
4
|
export * from './gyms';
|
|
5
|
+
export * from './collaborators';
|
|
5
6
|
export * from './clients';
|
|
6
7
|
export * from './membership-plans';
|
|
7
8
|
export * from './contracts';
|
|
@@ -21,6 +22,7 @@ export * from './subscriptions';
|
|
|
21
22
|
export * from './subscription-plans';
|
|
22
23
|
export * from './admin-subscription-management';
|
|
23
24
|
export * from './payment-methods';
|
|
25
|
+
export * from './roles';
|
|
24
26
|
|
|
25
27
|
export interface ApiResponse<T> {
|
|
26
28
|
data: T;
|
|
@@ -1,27 +1,44 @@
|
|
|
1
|
+
import { InvitationStatus } from '@gymspace/shared';
|
|
2
|
+
|
|
1
3
|
export interface CreateInvitationDto {
|
|
2
4
|
email: string;
|
|
3
|
-
gymId: string;
|
|
4
5
|
roleId: string;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export interface AcceptInvitationDto {
|
|
9
|
+
token?: string;
|
|
10
|
+
code?: string;
|
|
8
11
|
name: string;
|
|
9
12
|
phone: string;
|
|
10
13
|
password: string;
|
|
11
14
|
}
|
|
12
15
|
|
|
16
|
+
export interface ValidateByCodeDto {
|
|
17
|
+
code: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
export interface Invitation {
|
|
14
21
|
id: string;
|
|
15
22
|
email: string;
|
|
16
23
|
gymId: string;
|
|
17
24
|
roleId: string;
|
|
18
25
|
token: string;
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
code: string;
|
|
27
|
+
status: InvitationStatus;
|
|
28
|
+
invitedByUserId: string;
|
|
21
29
|
acceptedAt?: string;
|
|
22
30
|
expiresAt: string;
|
|
23
31
|
createdAt: string;
|
|
24
32
|
updatedAt: string;
|
|
33
|
+
role?: {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
};
|
|
37
|
+
invitedBy?: {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string | null;
|
|
40
|
+
email: string;
|
|
41
|
+
};
|
|
25
42
|
}
|
|
26
43
|
|
|
27
44
|
export interface GetGymInvitationsParams {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface Role {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string | null;
|
|
5
|
+
permissions: string[];
|
|
6
|
+
canManageEvaluations: boolean;
|
|
7
|
+
organizationId: string;
|
|
8
|
+
createdByUserId: string | null;
|
|
9
|
+
updatedByUserId: string | null;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
deletedAt: string | null;
|
|
13
|
+
createdBy?: {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
email: string;
|
|
17
|
+
};
|
|
18
|
+
updatedBy?: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
email: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PermissionsGroup {
|
|
26
|
+
[category: string]: string[];
|
|
27
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import {
|
|
3
|
+
Collaborator,
|
|
4
|
+
ListCollaboratorsParams,
|
|
5
|
+
UpdateCollaboratorDto,
|
|
6
|
+
UpdateStatusDto,
|
|
7
|
+
UpdateRoleDto,
|
|
8
|
+
ActivityQueryParams,
|
|
9
|
+
StatsQueryParams,
|
|
10
|
+
CollaboratorStats,
|
|
11
|
+
ActivityItem,
|
|
12
|
+
} from '../models/collaborators';
|
|
13
|
+
import { RequestOptions, PaginatedResponseDto } from '../types';
|
|
14
|
+
|
|
15
|
+
export class CollaboratorsResource extends BaseResource {
|
|
16
|
+
private basePath = 'collaborators';
|
|
17
|
+
|
|
18
|
+
async list(
|
|
19
|
+
params?: ListCollaboratorsParams,
|
|
20
|
+
options?: RequestOptions
|
|
21
|
+
): Promise<PaginatedResponseDto<Collaborator>> {
|
|
22
|
+
return this.paginate<Collaborator>(this.basePath, params, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async get(id: string, options?: RequestOptions): Promise<Collaborator> {
|
|
26
|
+
return this.client.get<Collaborator>(`${this.basePath}/${id}`, undefined, options);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async update(
|
|
30
|
+
id: string,
|
|
31
|
+
data: UpdateCollaboratorDto,
|
|
32
|
+
options?: RequestOptions
|
|
33
|
+
): Promise<Collaborator> {
|
|
34
|
+
return this.client.patch<Collaborator>(`${this.basePath}/${id}`, data, options);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async updateRole(
|
|
38
|
+
id: string,
|
|
39
|
+
roleId: string,
|
|
40
|
+
options?: RequestOptions
|
|
41
|
+
): Promise<Collaborator> {
|
|
42
|
+
return this.client.patch<Collaborator>(`${this.basePath}/${id}/role`, { roleId }, options);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async updateStatus(
|
|
46
|
+
id: string,
|
|
47
|
+
status: 'active' | 'inactive',
|
|
48
|
+
options?: RequestOptions
|
|
49
|
+
): Promise<Collaborator> {
|
|
50
|
+
return this.client.patch<Collaborator>(`${this.basePath}/${id}/status`, { status }, options);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async getActivity(
|
|
54
|
+
id: string,
|
|
55
|
+
params?: ActivityQueryParams,
|
|
56
|
+
options?: RequestOptions
|
|
57
|
+
): Promise<ActivityItem[]> {
|
|
58
|
+
return this.client.get<ActivityItem[]>(`${this.basePath}/${id}/activity`, params, options);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async getStats(
|
|
62
|
+
id: string,
|
|
63
|
+
params?: StatsQueryParams,
|
|
64
|
+
options?: RequestOptions
|
|
65
|
+
): Promise<CollaboratorStats> {
|
|
66
|
+
return this.client.get<CollaboratorStats>(`${this.basePath}/${id}/stats`, params, options);
|
|
67
|
+
}
|
|
68
|
+
}
|
package/src/resources/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BaseResource } from './base';
|
|
2
|
-
import {
|
|
3
|
-
Invitation,
|
|
4
|
-
CreateInvitationDto,
|
|
2
|
+
import {
|
|
3
|
+
Invitation,
|
|
4
|
+
CreateInvitationDto,
|
|
5
5
|
AcceptInvitationDto,
|
|
6
|
-
|
|
6
|
+
ValidateByCodeDto,
|
|
7
|
+
GetGymInvitationsParams
|
|
7
8
|
} from '../models/invitations';
|
|
8
9
|
import { RequestOptions } from '../types';
|
|
9
10
|
|
|
@@ -11,7 +12,7 @@ export class InvitationsResource extends BaseResource {
|
|
|
11
12
|
private basePath = 'invitations';
|
|
12
13
|
|
|
13
14
|
async createInvitation(
|
|
14
|
-
data: CreateInvitationDto,
|
|
15
|
+
data: CreateInvitationDto,
|
|
15
16
|
options?: RequestOptions
|
|
16
17
|
): Promise<Invitation> {
|
|
17
18
|
return this.client.post<Invitation>(this.basePath, data, options);
|
|
@@ -24,12 +25,18 @@ export class InvitationsResource extends BaseResource {
|
|
|
24
25
|
return this.client.get<Invitation[]>(this.basePath, params, options);
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
async validateByCode(
|
|
29
|
+
data: ValidateByCodeDto,
|
|
30
|
+
options?: RequestOptions
|
|
31
|
+
): Promise<{ email: string; gymName: string; roleName: string; token: string }> {
|
|
32
|
+
return this.client.post(`${this.basePath}/validate-by-code`, data, options);
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
async acceptInvitation(
|
|
28
|
-
token: string,
|
|
29
36
|
data: AcceptInvitationDto,
|
|
30
37
|
options?: RequestOptions
|
|
31
38
|
): Promise<void> {
|
|
32
|
-
return this.client.post<void>(`${this.basePath}
|
|
39
|
+
return this.client.post<void>(`${this.basePath}/accept`, data, options);
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
async cancelInvitation(id: string, options?: RequestOptions): Promise<void> {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseResource } from './base';
|
|
2
|
+
import { Role, PermissionsGroup } from '../models/roles';
|
|
3
|
+
import { RequestOptions } from '../types';
|
|
4
|
+
|
|
5
|
+
export class RolesResource extends BaseResource {
|
|
6
|
+
private basePath = 'roles';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get all roles of the organization (without pagination)
|
|
10
|
+
*/
|
|
11
|
+
async getRoles(options?: RequestOptions): Promise<Role[]> {
|
|
12
|
+
return this.client.get<Role[]>(this.basePath, undefined, options);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get a specific role by ID
|
|
17
|
+
*/
|
|
18
|
+
async getRole(id: string, options?: RequestOptions): Promise<Role> {
|
|
19
|
+
return this.client.get<Role>(`${this.basePath}/${id}`, undefined, options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get all available permissions organized by category
|
|
24
|
+
*/
|
|
25
|
+
async getAvailablePermissions(options?: RequestOptions): Promise<PermissionsGroup> {
|
|
26
|
+
return this.client.get<PermissionsGroup>(`${this.basePath}/permissions`, undefined, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
package/src/sdk.ts
CHANGED
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
AuthResource,
|
|
5
5
|
OrganizationsResource,
|
|
6
6
|
GymsResource,
|
|
7
|
+
CollaboratorsResource,
|
|
8
|
+
RolesResource,
|
|
7
9
|
ClientsResource,
|
|
8
10
|
MembershipPlansResource,
|
|
9
11
|
ContractsResource,
|
|
@@ -34,6 +36,8 @@ export class GymSpaceSdk {
|
|
|
34
36
|
public auth: AuthResource;
|
|
35
37
|
public organizations: OrganizationsResource;
|
|
36
38
|
public gyms: GymsResource;
|
|
39
|
+
public collaborators: CollaboratorsResource;
|
|
40
|
+
public roles: RolesResource;
|
|
37
41
|
public clients: ClientsResource;
|
|
38
42
|
public membershipPlans: MembershipPlansResource;
|
|
39
43
|
public contracts: ContractsResource;
|
|
@@ -63,6 +67,8 @@ export class GymSpaceSdk {
|
|
|
63
67
|
this.auth = new AuthResource(this.client);
|
|
64
68
|
this.organizations = new OrganizationsResource(this.client);
|
|
65
69
|
this.gyms = new GymsResource(this.client);
|
|
70
|
+
this.collaborators = new CollaboratorsResource(this.client);
|
|
71
|
+
this.roles = new RolesResource(this.client);
|
|
66
72
|
this.clients = new ClientsResource(this.client);
|
|
67
73
|
this.membershipPlans = new MembershipPlansResource(this.client);
|
|
68
74
|
this.contracts = new ContractsResource(this.client);
|