tonightpass 0.0.5 → 0.0.6
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +98 -84
- package/dist/index.d.ts +98 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/rest/endpoints.ts +2 -0
- package/src/rest/types/auth/index.ts +9 -0
- package/src/rest/types/index.ts +1 -0
- package/src/sdk/auth.ts +9 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> tonightpass@0.0.
|
|
2
|
+
> tonightpass@0.0.6 build /home/runner/work/tonightpass/tonightpass/packages/node
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[32mESM[39m [1mdist/index.mjs [22m[32m6.54 KB[39m
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m24.
|
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m24.87 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 209ms
|
|
15
15
|
[32mCJS[39m [1mdist/index.js [22m[32m7.42 KB[39m
|
|
16
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m24.
|
|
17
|
-
[32mCJS[39m ⚡️ Build success in
|
|
16
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m24.87 KB[39m
|
|
17
|
+
[32mCJS[39m ⚡️ Build success in 209ms
|
|
18
18
|
[34mDTS[39m Build start
|
|
19
|
-
[32mDTS[39m ⚡️ Build success in
|
|
20
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
19
|
+
[32mDTS[39m ⚡️ Build success in 2352ms
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m18.53 KB[39m
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m18.53 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# tonightpass
|
|
2
2
|
|
|
3
|
+
## 0.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`24d1f03`](https://github.com/tonightpass/tonightpass/commit/24d1f0323507b176c8b5b19f64f1b63c874e9a31) Thanks [@AntoineKM](https://github.com/AntoineKM)! - Add auth sdk
|
|
8
|
+
|
|
3
9
|
## 0.0.5
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -31,7 +31,90 @@ type Endpoint<M extends Options["method"], Path extends string, Res, Body = unde
|
|
|
31
31
|
res: Res;
|
|
32
32
|
body: Body;
|
|
33
33
|
};
|
|
34
|
-
type Endpoints = CareersEndpoints | HealthEndpoints | ProfileEndpoints | UserEndpoints;
|
|
34
|
+
type Endpoints = AuthEndpoints | CareersEndpoints | HealthEndpoints | ProfileEndpoints | UserEndpoints;
|
|
35
|
+
|
|
36
|
+
type User = {
|
|
37
|
+
id: string;
|
|
38
|
+
identifier: UserIdentifier;
|
|
39
|
+
password: string;
|
|
40
|
+
identity: UserIdentity;
|
|
41
|
+
role: UserRole;
|
|
42
|
+
addresses: Location$1[];
|
|
43
|
+
preferences: UserPreferences;
|
|
44
|
+
connections: UserConnection[];
|
|
45
|
+
verified: boolean;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
};
|
|
49
|
+
type UserIdentifier = {
|
|
50
|
+
email?: string;
|
|
51
|
+
phoneNumber?: string;
|
|
52
|
+
username: string;
|
|
53
|
+
[key: string]: string | undefined;
|
|
54
|
+
};
|
|
55
|
+
type UserIdentity = Profile & {
|
|
56
|
+
firstName: string;
|
|
57
|
+
lastName: string;
|
|
58
|
+
fullName: string;
|
|
59
|
+
gender: UserIdentityGender;
|
|
60
|
+
birthDate: Date;
|
|
61
|
+
metadata: ProfileMetadata & {
|
|
62
|
+
followingCount: number;
|
|
63
|
+
hasPassPlus: boolean;
|
|
64
|
+
idValid: boolean;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
declare enum UserRole {
|
|
68
|
+
USER = 0,
|
|
69
|
+
DEVELOPER = 8,
|
|
70
|
+
ADMINISTRATOR = 10
|
|
71
|
+
}
|
|
72
|
+
type UserIdentityGender = "male" | "female" | "non-binary" | "gender-fluid" | "neutral" | "other" | string;
|
|
73
|
+
type UserPreferences = {
|
|
74
|
+
language: Language;
|
|
75
|
+
currency: Currency;
|
|
76
|
+
notifications: {
|
|
77
|
+
email: {
|
|
78
|
+
newsletter: boolean;
|
|
79
|
+
message: boolean;
|
|
80
|
+
};
|
|
81
|
+
push: {
|
|
82
|
+
message: boolean;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type UserConnection = {
|
|
87
|
+
ip: string;
|
|
88
|
+
os: UserConnectionOS;
|
|
89
|
+
device: UserConnectionDevice;
|
|
90
|
+
client: UserConnectionClient;
|
|
91
|
+
updatedAt: Date;
|
|
92
|
+
createdAt: Date;
|
|
93
|
+
};
|
|
94
|
+
type UserConnectionOS = {
|
|
95
|
+
name: string;
|
|
96
|
+
version: string;
|
|
97
|
+
};
|
|
98
|
+
type UserConnectionDevice = {
|
|
99
|
+
type: string;
|
|
100
|
+
brand: string;
|
|
101
|
+
};
|
|
102
|
+
type UserConnectionClient = {
|
|
103
|
+
name: string;
|
|
104
|
+
version: string;
|
|
105
|
+
};
|
|
106
|
+
type UserEndpoints = Endpoint<"GET", "/users", User[]> | Endpoint<"GET", "/users/:id", User, {
|
|
107
|
+
id: string;
|
|
108
|
+
}> | Endpoint<"GET", "/users/me", User> | Endpoint<"GET", "/users/check/:identifier", {
|
|
109
|
+
exists: boolean;
|
|
110
|
+
identifier: UserIdentifier;
|
|
111
|
+
suggestions?: string[];
|
|
112
|
+
}, {
|
|
113
|
+
identifier: boolean;
|
|
114
|
+
suggestions?: boolean;
|
|
115
|
+
}> | Endpoint<"PUT", "/users/:id", User, UpdateUserDto>;
|
|
116
|
+
|
|
117
|
+
type AuthEndpoints = Endpoint<"POST", "/auth/sign-up", User, CreateUserDto> | Endpoint<"POST", "/auth/sign-in", User, SignInUserDto> | Endpoint<"POST", "/auth/sign-out", void> | Endpoint<"POST", "/auth/refresh-token", User>;
|
|
35
118
|
|
|
36
119
|
type CareersOffice = {
|
|
37
120
|
id: number | null;
|
|
@@ -125,87 +208,6 @@ declare enum EventTicketCategory {
|
|
|
125
208
|
OTHER = "other"
|
|
126
209
|
}
|
|
127
210
|
|
|
128
|
-
type User = {
|
|
129
|
-
id: string;
|
|
130
|
-
identifier: UserIdentifier;
|
|
131
|
-
password: string;
|
|
132
|
-
identity: UserIdentity;
|
|
133
|
-
role: UserRole;
|
|
134
|
-
addresses: Location$1[];
|
|
135
|
-
preferences: UserPreferences;
|
|
136
|
-
connections: UserConnection[];
|
|
137
|
-
verified: boolean;
|
|
138
|
-
updatedAt: Date;
|
|
139
|
-
createdAt: Date;
|
|
140
|
-
};
|
|
141
|
-
type UserIdentifier = {
|
|
142
|
-
email?: string;
|
|
143
|
-
phoneNumber?: string;
|
|
144
|
-
username: string;
|
|
145
|
-
[key: string]: string | undefined;
|
|
146
|
-
};
|
|
147
|
-
type UserIdentity = Profile & {
|
|
148
|
-
firstName: string;
|
|
149
|
-
lastName: string;
|
|
150
|
-
fullName: string;
|
|
151
|
-
gender: UserIdentityGender;
|
|
152
|
-
birthDate: Date;
|
|
153
|
-
metadata: ProfileMetadata & {
|
|
154
|
-
followingCount: number;
|
|
155
|
-
hasPassPlus: boolean;
|
|
156
|
-
idValid: boolean;
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
declare enum UserRole {
|
|
160
|
-
USER = 0,
|
|
161
|
-
DEVELOPER = 8,
|
|
162
|
-
ADMINISTRATOR = 10
|
|
163
|
-
}
|
|
164
|
-
type UserIdentityGender = "male" | "female" | "non-binary" | "gender-fluid" | "neutral" | "other" | string;
|
|
165
|
-
type UserPreferences = {
|
|
166
|
-
language: Language;
|
|
167
|
-
currency: Currency;
|
|
168
|
-
notifications: {
|
|
169
|
-
email: {
|
|
170
|
-
newsletter: boolean;
|
|
171
|
-
message: boolean;
|
|
172
|
-
};
|
|
173
|
-
push: {
|
|
174
|
-
message: boolean;
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
type UserConnection = {
|
|
179
|
-
ip: string;
|
|
180
|
-
os: UserConnectionOS;
|
|
181
|
-
device: UserConnectionDevice;
|
|
182
|
-
client: UserConnectionClient;
|
|
183
|
-
updatedAt: Date;
|
|
184
|
-
createdAt: Date;
|
|
185
|
-
};
|
|
186
|
-
type UserConnectionOS = {
|
|
187
|
-
name: string;
|
|
188
|
-
version: string;
|
|
189
|
-
};
|
|
190
|
-
type UserConnectionDevice = {
|
|
191
|
-
type: string;
|
|
192
|
-
brand: string;
|
|
193
|
-
};
|
|
194
|
-
type UserConnectionClient = {
|
|
195
|
-
name: string;
|
|
196
|
-
version: string;
|
|
197
|
-
};
|
|
198
|
-
type UserEndpoints = Endpoint<"GET", "/users", User[]> | Endpoint<"GET", "/users/:id", User, {
|
|
199
|
-
id: string;
|
|
200
|
-
}> | Endpoint<"GET", "/users/me", User> | Endpoint<"GET", "/users/check/:identifier", {
|
|
201
|
-
exists: boolean;
|
|
202
|
-
identifier: UserIdentifier;
|
|
203
|
-
suggestions?: string[];
|
|
204
|
-
}, {
|
|
205
|
-
identifier: boolean;
|
|
206
|
-
suggestions?: boolean;
|
|
207
|
-
}> | Endpoint<"PUT", "/users/:id", User, UpdateUserDto>;
|
|
208
|
-
|
|
209
211
|
type Organization = {
|
|
210
212
|
id: string;
|
|
211
213
|
slug: string;
|
|
@@ -543,7 +545,19 @@ declare class Client {
|
|
|
543
545
|
}>["path"]>(path: Path, body: Extract<Endpoints, {
|
|
544
546
|
path: Path;
|
|
545
547
|
method: "POST";
|
|
546
|
-
}>["body"], query?: Query<Path>, options?: APIRequestOptions): Promise<
|
|
548
|
+
}>["body"], query?: Query<Path>, options?: APIRequestOptions): Promise<(Extract<Endpoint<"POST", "/auth/sign-up", User, CreateUserDto>, {
|
|
549
|
+
path: Path;
|
|
550
|
+
method: "POST";
|
|
551
|
+
}> | Extract<Endpoint<"POST", "/auth/sign-in", User, SignInUserDto>, {
|
|
552
|
+
path: Path;
|
|
553
|
+
method: "POST";
|
|
554
|
+
}> | Extract<Endpoint<"POST", "/auth/sign-out", void>, {
|
|
555
|
+
path: Path;
|
|
556
|
+
method: "POST";
|
|
557
|
+
}> | Extract<Endpoint<"POST", "/auth/refresh-token", User>, {
|
|
558
|
+
path: Path;
|
|
559
|
+
method: "POST";
|
|
560
|
+
}>)["res"]>;
|
|
547
561
|
put<Path extends Extract<Endpoints, {
|
|
548
562
|
method: "PUT";
|
|
549
563
|
}>["path"]>(path: Path, body: Extract<Endpoints, {
|
|
@@ -624,4 +638,4 @@ declare class TonightPass {
|
|
|
624
638
|
|
|
625
639
|
declare const isBrowser: boolean;
|
|
626
640
|
|
|
627
|
-
export { type APIRequestOptions, type APIResponse, BCRYPT_HASH, type CareersCategory, type CareersEmploymentType, type CareersEndpoints, type CareersJob, type CareersOffice, Client, type ClientOptions, CreateUserDto, Currency, DEFAULT_API_URL, EMAIL_REGEX, type Endpoint, type Endpoints, type ErroredAPIResponse, type Event, type EventStyle, EventStyleType, type EventTicket, EventTicketCategory, type EventTicketType, EventType, type Health, type HealthEndpoints, IMAGE_URL_REGEX, Language, type Location$1 as Location, NAME_REGEX, type Order, type OrderItem, OrderStatus, type Organization, type OrganizationIdentity, type OrganizationMember, OrganizationMemberRole, type OrganizationSocialLink, OrganizationSocialType, PASSWORD_REGEX, PHONE_NUMBER_REGEX, type PathsFor, type Profile, type ProfileEndpoints, type ProfileMetadata, type PromoCode, SLUG_REGEX, SignInUserDto, type SuccessfulAPIResponse, TonightPass, TonightPassAPIError, UpdateUserDto, type User, type UserConnection, type UserConnectionClient, type UserConnectionDevice, type UserConnectionOS, type UserEndpoints, type UserIdentifier, type UserIdentity, type UserIdentityGender, type UserPreferences, UserRole, type UserToken, UserTokenType, health, isBrowser, request, sdk, users };
|
|
641
|
+
export { type APIRequestOptions, type APIResponse, type AuthEndpoints, BCRYPT_HASH, type CareersCategory, type CareersEmploymentType, type CareersEndpoints, type CareersJob, type CareersOffice, Client, type ClientOptions, CreateUserDto, Currency, DEFAULT_API_URL, EMAIL_REGEX, type Endpoint, type Endpoints, type ErroredAPIResponse, type Event, type EventStyle, EventStyleType, type EventTicket, EventTicketCategory, type EventTicketType, EventType, type Health, type HealthEndpoints, IMAGE_URL_REGEX, Language, type Location$1 as Location, NAME_REGEX, type Order, type OrderItem, OrderStatus, type Organization, type OrganizationIdentity, type OrganizationMember, OrganizationMemberRole, type OrganizationSocialLink, OrganizationSocialType, PASSWORD_REGEX, PHONE_NUMBER_REGEX, type PathsFor, type Profile, type ProfileEndpoints, type ProfileMetadata, type PromoCode, SLUG_REGEX, SignInUserDto, type SuccessfulAPIResponse, TonightPass, TonightPassAPIError, UpdateUserDto, type User, type UserConnection, type UserConnectionClient, type UserConnectionDevice, type UserConnectionOS, type UserEndpoints, type UserIdentifier, type UserIdentity, type UserIdentityGender, type UserPreferences, UserRole, type UserToken, UserTokenType, health, isBrowser, request, sdk, users };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,90 @@ type Endpoint<M extends Options["method"], Path extends string, Res, Body = unde
|
|
|
31
31
|
res: Res;
|
|
32
32
|
body: Body;
|
|
33
33
|
};
|
|
34
|
-
type Endpoints = CareersEndpoints | HealthEndpoints | ProfileEndpoints | UserEndpoints;
|
|
34
|
+
type Endpoints = AuthEndpoints | CareersEndpoints | HealthEndpoints | ProfileEndpoints | UserEndpoints;
|
|
35
|
+
|
|
36
|
+
type User = {
|
|
37
|
+
id: string;
|
|
38
|
+
identifier: UserIdentifier;
|
|
39
|
+
password: string;
|
|
40
|
+
identity: UserIdentity;
|
|
41
|
+
role: UserRole;
|
|
42
|
+
addresses: Location$1[];
|
|
43
|
+
preferences: UserPreferences;
|
|
44
|
+
connections: UserConnection[];
|
|
45
|
+
verified: boolean;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
};
|
|
49
|
+
type UserIdentifier = {
|
|
50
|
+
email?: string;
|
|
51
|
+
phoneNumber?: string;
|
|
52
|
+
username: string;
|
|
53
|
+
[key: string]: string | undefined;
|
|
54
|
+
};
|
|
55
|
+
type UserIdentity = Profile & {
|
|
56
|
+
firstName: string;
|
|
57
|
+
lastName: string;
|
|
58
|
+
fullName: string;
|
|
59
|
+
gender: UserIdentityGender;
|
|
60
|
+
birthDate: Date;
|
|
61
|
+
metadata: ProfileMetadata & {
|
|
62
|
+
followingCount: number;
|
|
63
|
+
hasPassPlus: boolean;
|
|
64
|
+
idValid: boolean;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
declare enum UserRole {
|
|
68
|
+
USER = 0,
|
|
69
|
+
DEVELOPER = 8,
|
|
70
|
+
ADMINISTRATOR = 10
|
|
71
|
+
}
|
|
72
|
+
type UserIdentityGender = "male" | "female" | "non-binary" | "gender-fluid" | "neutral" | "other" | string;
|
|
73
|
+
type UserPreferences = {
|
|
74
|
+
language: Language;
|
|
75
|
+
currency: Currency;
|
|
76
|
+
notifications: {
|
|
77
|
+
email: {
|
|
78
|
+
newsletter: boolean;
|
|
79
|
+
message: boolean;
|
|
80
|
+
};
|
|
81
|
+
push: {
|
|
82
|
+
message: boolean;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type UserConnection = {
|
|
87
|
+
ip: string;
|
|
88
|
+
os: UserConnectionOS;
|
|
89
|
+
device: UserConnectionDevice;
|
|
90
|
+
client: UserConnectionClient;
|
|
91
|
+
updatedAt: Date;
|
|
92
|
+
createdAt: Date;
|
|
93
|
+
};
|
|
94
|
+
type UserConnectionOS = {
|
|
95
|
+
name: string;
|
|
96
|
+
version: string;
|
|
97
|
+
};
|
|
98
|
+
type UserConnectionDevice = {
|
|
99
|
+
type: string;
|
|
100
|
+
brand: string;
|
|
101
|
+
};
|
|
102
|
+
type UserConnectionClient = {
|
|
103
|
+
name: string;
|
|
104
|
+
version: string;
|
|
105
|
+
};
|
|
106
|
+
type UserEndpoints = Endpoint<"GET", "/users", User[]> | Endpoint<"GET", "/users/:id", User, {
|
|
107
|
+
id: string;
|
|
108
|
+
}> | Endpoint<"GET", "/users/me", User> | Endpoint<"GET", "/users/check/:identifier", {
|
|
109
|
+
exists: boolean;
|
|
110
|
+
identifier: UserIdentifier;
|
|
111
|
+
suggestions?: string[];
|
|
112
|
+
}, {
|
|
113
|
+
identifier: boolean;
|
|
114
|
+
suggestions?: boolean;
|
|
115
|
+
}> | Endpoint<"PUT", "/users/:id", User, UpdateUserDto>;
|
|
116
|
+
|
|
117
|
+
type AuthEndpoints = Endpoint<"POST", "/auth/sign-up", User, CreateUserDto> | Endpoint<"POST", "/auth/sign-in", User, SignInUserDto> | Endpoint<"POST", "/auth/sign-out", void> | Endpoint<"POST", "/auth/refresh-token", User>;
|
|
35
118
|
|
|
36
119
|
type CareersOffice = {
|
|
37
120
|
id: number | null;
|
|
@@ -125,87 +208,6 @@ declare enum EventTicketCategory {
|
|
|
125
208
|
OTHER = "other"
|
|
126
209
|
}
|
|
127
210
|
|
|
128
|
-
type User = {
|
|
129
|
-
id: string;
|
|
130
|
-
identifier: UserIdentifier;
|
|
131
|
-
password: string;
|
|
132
|
-
identity: UserIdentity;
|
|
133
|
-
role: UserRole;
|
|
134
|
-
addresses: Location$1[];
|
|
135
|
-
preferences: UserPreferences;
|
|
136
|
-
connections: UserConnection[];
|
|
137
|
-
verified: boolean;
|
|
138
|
-
updatedAt: Date;
|
|
139
|
-
createdAt: Date;
|
|
140
|
-
};
|
|
141
|
-
type UserIdentifier = {
|
|
142
|
-
email?: string;
|
|
143
|
-
phoneNumber?: string;
|
|
144
|
-
username: string;
|
|
145
|
-
[key: string]: string | undefined;
|
|
146
|
-
};
|
|
147
|
-
type UserIdentity = Profile & {
|
|
148
|
-
firstName: string;
|
|
149
|
-
lastName: string;
|
|
150
|
-
fullName: string;
|
|
151
|
-
gender: UserIdentityGender;
|
|
152
|
-
birthDate: Date;
|
|
153
|
-
metadata: ProfileMetadata & {
|
|
154
|
-
followingCount: number;
|
|
155
|
-
hasPassPlus: boolean;
|
|
156
|
-
idValid: boolean;
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
declare enum UserRole {
|
|
160
|
-
USER = 0,
|
|
161
|
-
DEVELOPER = 8,
|
|
162
|
-
ADMINISTRATOR = 10
|
|
163
|
-
}
|
|
164
|
-
type UserIdentityGender = "male" | "female" | "non-binary" | "gender-fluid" | "neutral" | "other" | string;
|
|
165
|
-
type UserPreferences = {
|
|
166
|
-
language: Language;
|
|
167
|
-
currency: Currency;
|
|
168
|
-
notifications: {
|
|
169
|
-
email: {
|
|
170
|
-
newsletter: boolean;
|
|
171
|
-
message: boolean;
|
|
172
|
-
};
|
|
173
|
-
push: {
|
|
174
|
-
message: boolean;
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
type UserConnection = {
|
|
179
|
-
ip: string;
|
|
180
|
-
os: UserConnectionOS;
|
|
181
|
-
device: UserConnectionDevice;
|
|
182
|
-
client: UserConnectionClient;
|
|
183
|
-
updatedAt: Date;
|
|
184
|
-
createdAt: Date;
|
|
185
|
-
};
|
|
186
|
-
type UserConnectionOS = {
|
|
187
|
-
name: string;
|
|
188
|
-
version: string;
|
|
189
|
-
};
|
|
190
|
-
type UserConnectionDevice = {
|
|
191
|
-
type: string;
|
|
192
|
-
brand: string;
|
|
193
|
-
};
|
|
194
|
-
type UserConnectionClient = {
|
|
195
|
-
name: string;
|
|
196
|
-
version: string;
|
|
197
|
-
};
|
|
198
|
-
type UserEndpoints = Endpoint<"GET", "/users", User[]> | Endpoint<"GET", "/users/:id", User, {
|
|
199
|
-
id: string;
|
|
200
|
-
}> | Endpoint<"GET", "/users/me", User> | Endpoint<"GET", "/users/check/:identifier", {
|
|
201
|
-
exists: boolean;
|
|
202
|
-
identifier: UserIdentifier;
|
|
203
|
-
suggestions?: string[];
|
|
204
|
-
}, {
|
|
205
|
-
identifier: boolean;
|
|
206
|
-
suggestions?: boolean;
|
|
207
|
-
}> | Endpoint<"PUT", "/users/:id", User, UpdateUserDto>;
|
|
208
|
-
|
|
209
211
|
type Organization = {
|
|
210
212
|
id: string;
|
|
211
213
|
slug: string;
|
|
@@ -543,7 +545,19 @@ declare class Client {
|
|
|
543
545
|
}>["path"]>(path: Path, body: Extract<Endpoints, {
|
|
544
546
|
path: Path;
|
|
545
547
|
method: "POST";
|
|
546
|
-
}>["body"], query?: Query<Path>, options?: APIRequestOptions): Promise<
|
|
548
|
+
}>["body"], query?: Query<Path>, options?: APIRequestOptions): Promise<(Extract<Endpoint<"POST", "/auth/sign-up", User, CreateUserDto>, {
|
|
549
|
+
path: Path;
|
|
550
|
+
method: "POST";
|
|
551
|
+
}> | Extract<Endpoint<"POST", "/auth/sign-in", User, SignInUserDto>, {
|
|
552
|
+
path: Path;
|
|
553
|
+
method: "POST";
|
|
554
|
+
}> | Extract<Endpoint<"POST", "/auth/sign-out", void>, {
|
|
555
|
+
path: Path;
|
|
556
|
+
method: "POST";
|
|
557
|
+
}> | Extract<Endpoint<"POST", "/auth/refresh-token", User>, {
|
|
558
|
+
path: Path;
|
|
559
|
+
method: "POST";
|
|
560
|
+
}>)["res"]>;
|
|
547
561
|
put<Path extends Extract<Endpoints, {
|
|
548
562
|
method: "PUT";
|
|
549
563
|
}>["path"]>(path: Path, body: Extract<Endpoints, {
|
|
@@ -624,4 +638,4 @@ declare class TonightPass {
|
|
|
624
638
|
|
|
625
639
|
declare const isBrowser: boolean;
|
|
626
640
|
|
|
627
|
-
export { type APIRequestOptions, type APIResponse, BCRYPT_HASH, type CareersCategory, type CareersEmploymentType, type CareersEndpoints, type CareersJob, type CareersOffice, Client, type ClientOptions, CreateUserDto, Currency, DEFAULT_API_URL, EMAIL_REGEX, type Endpoint, type Endpoints, type ErroredAPIResponse, type Event, type EventStyle, EventStyleType, type EventTicket, EventTicketCategory, type EventTicketType, EventType, type Health, type HealthEndpoints, IMAGE_URL_REGEX, Language, type Location$1 as Location, NAME_REGEX, type Order, type OrderItem, OrderStatus, type Organization, type OrganizationIdentity, type OrganizationMember, OrganizationMemberRole, type OrganizationSocialLink, OrganizationSocialType, PASSWORD_REGEX, PHONE_NUMBER_REGEX, type PathsFor, type Profile, type ProfileEndpoints, type ProfileMetadata, type PromoCode, SLUG_REGEX, SignInUserDto, type SuccessfulAPIResponse, TonightPass, TonightPassAPIError, UpdateUserDto, type User, type UserConnection, type UserConnectionClient, type UserConnectionDevice, type UserConnectionOS, type UserEndpoints, type UserIdentifier, type UserIdentity, type UserIdentityGender, type UserPreferences, UserRole, type UserToken, UserTokenType, health, isBrowser, request, sdk, users };
|
|
641
|
+
export { type APIRequestOptions, type APIResponse, type AuthEndpoints, BCRYPT_HASH, type CareersCategory, type CareersEmploymentType, type CareersEndpoints, type CareersJob, type CareersOffice, Client, type ClientOptions, CreateUserDto, Currency, DEFAULT_API_URL, EMAIL_REGEX, type Endpoint, type Endpoints, type ErroredAPIResponse, type Event, type EventStyle, EventStyleType, type EventTicket, EventTicketCategory, type EventTicketType, EventType, type Health, type HealthEndpoints, IMAGE_URL_REGEX, Language, type Location$1 as Location, NAME_REGEX, type Order, type OrderItem, OrderStatus, type Organization, type OrganizationIdentity, type OrganizationMember, OrganizationMemberRole, type OrganizationSocialLink, OrganizationSocialType, PASSWORD_REGEX, PHONE_NUMBER_REGEX, type PathsFor, type Profile, type ProfileEndpoints, type ProfileMetadata, type PromoCode, SLUG_REGEX, SignInUserDto, type SuccessfulAPIResponse, TonightPass, TonightPassAPIError, UpdateUserDto, type User, type UserConnection, type UserConnectionClient, type UserConnectionDevice, type UserConnectionOS, type UserEndpoints, type UserIdentifier, type UserIdentity, type UserIdentityGender, type UserPreferences, UserRole, type UserToken, UserTokenType, health, isBrowser, request, sdk, users };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants/api.ts","../src/constants/regex.ts","../src/rest/dtos/index.ts","../src/rest/dtos/users/create-user.dto.ts","../src/rest/dtos/users/sign-in-user.dto.ts","../src/rest/dtos/users/update-user.dto.ts","../src/rest/request/request.ts","../src/utils/index.ts","../src/rest/types/event/ticket/index.ts","../src/rest/types/event/index.ts","../src/rest/types/organizations/index.ts","../src/rest/types/token/index.ts","../src/rest/types/users/index.ts","../src/rest/types/order/index.ts","../src/rest/types/index.ts","../src/rest/client.ts","../src/sdk/builder.ts","../src/sdk/health.ts","../src/sdk/users.ts","../src/sdk/careers.ts","../src/sdk/profiles.ts","../src/tonightpass.ts"],"names":["DEFAULT_API_URL","EMAIL_REGEX","PASSWORD_REGEX","NAME_REGEX","SLUG_REGEX","BCRYPT_HASH","PHONE_NUMBER_REGEX","IMAGE_URL_REGEX","CreateUserDto","SignInUserDto","Type","IsDateString","IsEmail","IsObject","IsOptional","IsPhoneNumber","IsString","IsUrl","Length","Matches","MaxLength","MinLength","ValidateNested","UpdateUserDto","__decorateClass","UpdateIdentifierDto","UpdateIdentityDto","axios","isBrowser","instance","data","request","url","options","response","error","EventTicketCategory","EventType","EventStyleType","OrganizationSocialType","OrganizationMemberRole","UserTokenType","UserRole","OrderStatus","Currency","Language","pathcat","TonightPassAPIError","Client","path","params","baseURL","query","body","method","result","sdk","builder","health","client","users","id","identifier","suggestions","careers","profiles","username","TonightPass"],"mappings":"wMAAO,IAAMA,EAAkB,8BCAxB,IAAMC,GAAc,2CAGdC,GAC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,CAAO,EAEhC,KAAK,QAAU+B,EAAQ,KAAK,MAAM,EAClC,KAAK,OAASN,EAAO,KAAK,MAAM,EAChC,KAAK,SAAWO,EAAS,KAAK,MAAM,EACpC,KAAK,MAAQL,EAAM,KAAK,MAAM,CAChC,CACF","sourcesContent":["export const DEFAULT_API_URL = \"https://api.tonightpass.com\";\n","export const EMAIL_REGEX = /^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$/;\n\n// checks if a password has at least one uppercase letter and a number or special character\nexport const PASSWORD_REGEX =\n /((?=.*\\d)|(?=.*\\W+))(?![.\\n])(?=.*[A-Z])(?=.*[a-z]).*$/;\n\n// checks if a string has only letters, numbers, spaces, apostrophes, dots and dashes\nexport const NAME_REGEX = /(^[\\p{L}\\d'\\\\.\\s\\\\-]*$)/u;\n\n// checks if a string is a valid slug, useful for usernames\nexport const SLUG_REGEX = /^[a-z\\d]+(?:(\\.|-|_)[a-z\\d]+)*$/;\n\n// validates if passwords are valid bcrypt hashes\nexport const BCRYPT_HASH = /\\$2[abxy]?\\$\\d{1,2}\\$[A-Za-z\\d\\\\./]{53}/;\n\nexport const PHONE_NUMBER_REGEX =\n /^\\s*(?:\\+?(\\d{1,3}))?([-. (]*(\\d{3})[-. )]*)?((\\d{3})[-. ]*(\\d{2,4})(?:[-.x ]*(\\d+))?)\\s*$/;\n\nexport const IMAGE_URL_REGEX =\n /(((http:\\/\\/www)|(http:\\/\\/)|(www))[-a-zA-Z0-9@:%_\\\\+.~#?&//=]+)\\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)/i;\n","import \"reflect-metadata\";\n\nexport * from \"./users\";\n","import { UserIdentifier, UserIdentityGender } from \"../../types\";\n\nexport class CreateUserDto {\n identifier: UserIdentifier;\n password: string;\n identity: CreateUserIdentituDto;\n addresses: Location[];\n}\n\nclass CreateUserIdentituDto {\n firstName: string;\n lastName: string;\n gender: UserIdentityGender;\n profilePictureUrl?: string;\n birthDate: Date;\n}\n","export class SignInUserDto {\n identifier: string;\n password: string;\n}\n","import { Type } from \"class-transformer\";\nimport {\n IsDateString,\n IsEmail,\n IsObject,\n IsOptional,\n IsPhoneNumber,\n IsString,\n IsUrl,\n Length,\n Matches,\n MaxLength,\n MinLength,\n ValidateNested,\n} from \"class-validator\";\n\nimport { NAME_REGEX } from \"../../../constants/regex\";\nimport { UserIdentifier, UserIdentity } from \"../../types\";\n\nexport class UpdateUserDto {\n @IsOptional()\n @IsObject()\n @ValidateNested()\n @Type(() => UpdateIdentifierDto)\n identifier?: UpdateIdentifierDto;\n\n @IsOptional()\n @IsObject()\n @ValidateNested()\n @Type(() => UpdateIdentityDto)\n identity?: UpdateIdentityDto;\n\n @IsOptional()\n @IsString()\n @MinLength(6)\n @MaxLength(130)\n password?: string;\n}\n\nclass UpdateIdentifierDto\n implements\n Partial<Pick<UserIdentifier, \"email\" | \"phoneNumber\" | \"username\">>\n{\n @IsOptional()\n @IsString()\n @IsEmail()\n email?: string;\n\n @IsOptional()\n @IsString()\n @IsPhoneNumber()\n phoneNumber?: string;\n\n @IsOptional()\n @IsString()\n @MinLength(3)\n username?: string;\n}\n\nclass UpdateIdentityDto\n implements\n Partial<\n Pick<\n UserIdentity,\n | \"firstName\"\n | \"lastName\"\n | \"displayName\"\n | \"description\"\n | \"profilePictureUrl\"\n | \"bannerUrl\"\n | \"gender\"\n | \"birthDate\"\n >\n >\n{\n @IsOptional()\n @IsString()\n @Length(2, 50)\n @Matches(NAME_REGEX, {\n message: \"First name must be composed of letters only\",\n })\n firstName?: string;\n\n @IsOptional()\n @IsString()\n @Length(2, 50)\n @Matches(NAME_REGEX, {\n message: \"Last name must be composed of letters only\",\n })\n lastName?: string;\n\n @IsOptional()\n @IsString()\n @Length(1, 32)\n displayName?: string;\n\n @IsOptional()\n @IsString()\n @Length(15, 500)\n description?: string;\n\n @IsOptional()\n @IsUrl()\n profilePictureUrl?: string | undefined;\n\n @IsOptional()\n @IsUrl()\n bannerUrl?: string | undefined;\n\n @IsOptional()\n gender?: string;\n\n @IsOptional()\n @IsDateString()\n birthDate?: Date;\n}\n","import axios, { Options, Response } from \"redaxios\";\n\nimport { isBrowser } from \"../../utils\";\nimport { APIResponse, ErroredAPIResponse } from \"../endpoints\";\n\nconst instance = axios.create({\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...(!isBrowser && { \"User-Agent\": \"tonightpass-api-client\" }),\n },\n responseType: \"json\",\n transformRequest: [\n function (data) {\n return JSON.stringify(data);\n },\n ],\n withCredentials: isBrowser,\n});\n\nexport interface APIRequestOptions extends Options {}\n\nexport const request = async <T>(url: string, options?: Options) => {\n const response = instance<APIResponse<T>>(url, { ...options })\n .then((response) => response)\n .catch((error: Response<ErroredAPIResponse>) => {\n throw error.data;\n });\n\n return response;\n};\n","export const isBrowser = typeof window !== \"undefined\";\n","import { Currency } from \"../..\";\n\nexport type EventTicket = {\n id: string;\n name: string;\n description?: string;\n price: number;\n displayPrice: number;\n quantity: number;\n type: EventTicketType;\n category: EventTicketCategory;\n currency: Currency;\n vatRate: number;\n externalId?: string;\n isVisible: boolean;\n isFeesIncluded: boolean;\n startAt: Date;\n endAt: Date;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type EventTicketType = \"e-ticket\" | \"other\";\n\nexport enum EventTicketCategory {\n ENTRY = \"entry\",\n PACKAGE = \"package\",\n MEAL = \"meal\",\n DRINK = \"drink\",\n PARKING = \"parking\",\n ACCOMMODATION = \"accommodation\",\n CAMPING = \"camping\",\n LOCKER = \"locker\",\n SHUTTLE = \"shuttle\",\n OTHER = \"other\",\n}\n","import { EventTicket } from \"./ticket\";\nimport { Location } from \"..\";\nimport { Organization } from \"../organizations\";\n\nexport * from \"./ticket\";\n\nexport type Event = {\n title: string;\n description: string;\n slug: string;\n organization: Organization;\n type: EventType;\n public: boolean;\n flyers: string[];\n trailers: string[];\n location: Location;\n tickets: EventTicket[];\n styles: EventStyle[];\n startAt: Date;\n endAt: Date;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport enum EventType {\n Clubbing = \"clubbing\",\n Concert = \"concert\",\n Afterwork = \"afterwork\",\n DancingLunch = \"dancing_lunch\",\n Diner = \"diner\",\n Garden = \"garden\",\n AfterBeach = \"after_beach\",\n Festival = \"festival\",\n Spectacle = \"spectacle\",\n Cruise = \"cruise\",\n OutsideAnimation = \"outside_animation\",\n Sport = \"sport\",\n Match = \"match\",\n Seminar = \"seminar\",\n Conference = \"conference\",\n WellnessDay = \"wellness_day\",\n Workshop = \"workshop\",\n TradeFair = \"trade_fair\",\n ConsumerShow = \"consumer_show\",\n Membership = \"membership\",\n}\n\nexport type EventStyle = {\n type: EventStyleType;\n emoji: string;\n name: string;\n};\n\nexport enum EventStyleType {\n Music = \"music\",\n Dress = \"dress\",\n Sport = \"sport\",\n Food = \"food\",\n Art = \"art\",\n}\n","import { Location, Profile, ProfileMetadata } from \"..\";\nimport { Event } from \"../event\";\nimport { EventTicket } from \"../event/ticket\";\nimport { User } from \"../users\";\n\nexport type Organization = {\n id: string;\n slug: string;\n identity: OrganizationIdentity;\n members: OrganizationMember[];\n location?: Location;\n events: Event[];\n savedTickets: EventTicket[];\n verified: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type OrganizationIdentity = Profile & {\n socialLinks: OrganizationSocialLink[];\n\n metadata: ProfileMetadata & {\n eventsCount: number;\n viewsCount: number;\n membersCount: number;\n };\n};\n\nexport type OrganizationSocialLink = {\n type: OrganizationSocialType;\n url: string;\n};\n\nexport enum OrganizationSocialType {\n Facebook = \"facebook\",\n Twitter = \"twitter\",\n Instagram = \"instagram\",\n Linkedin = \"linkedin\",\n Youtube = \"youtube\",\n Website = \"website\",\n}\n\nexport type OrganizationMember = {\n user: User;\n role: OrganizationMemberRole;\n createdAt: Date;\n};\n\nexport enum OrganizationMemberRole {\n EMPLOYEE = 0,\n MANAGER = 1,\n ADMINISTRATOR = 2,\n OWNER = 3,\n}\n","export type UserToken = {\n id: string;\n type: UserTokenType;\n value: string;\n createdAt: Date;\n expiresAt: Date;\n};\n\nexport enum UserTokenType {\n Authentication = \"authentication\",\n OrganizationInvite = \"organization_invite\",\n PasswordRecovery = \"password_recovery\",\n EmailValidation = \"email_validation\",\n PhoneValidation = \"phone_validation\",\n}\n","import { Currency, Language, Location, Profile, ProfileMetadata } from \"..\";\nimport { UpdateUserDto } from \"../../dtos\";\nimport { Endpoint } from \"../../endpoints\";\n\nexport type User = {\n id: string;\n identifier: UserIdentifier;\n password: string;\n identity: UserIdentity;\n role: UserRole;\n addresses: Location[];\n preferences: UserPreferences;\n connections: UserConnection[];\n verified: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type UserIdentifier = {\n email?: string;\n phoneNumber?: string;\n username: string;\n\n [key: string]: string | undefined;\n};\n\nexport type UserIdentity = Profile & {\n firstName: string;\n lastName: string;\n fullName: string;\n gender: UserIdentityGender;\n birthDate: Date;\n\n metadata: ProfileMetadata & {\n followingCount: number;\n hasPassPlus: boolean;\n idValid: boolean;\n };\n};\n\nexport enum UserRole {\n USER = 0,\n DEVELOPER = 8,\n ADMINISTRATOR = 10,\n}\n\nexport type UserIdentityGender =\n | \"male\"\n | \"female\"\n | \"non-binary\"\n | \"gender-fluid\"\n | \"neutral\"\n | \"other\"\n | string;\n\nexport type UserPreferences = {\n language: Language;\n currency: Currency;\n notifications: {\n email: {\n newsletter: boolean;\n message: boolean;\n };\n push: {\n message: boolean;\n };\n };\n};\n\nexport type UserConnection = {\n ip: string;\n os: UserConnectionOS;\n device: UserConnectionDevice;\n client: UserConnectionClient;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type UserConnectionOS = {\n name: string;\n version: string;\n};\n\nexport type UserConnectionDevice = {\n type: string;\n brand: string;\n};\n\nexport type UserConnectionClient = {\n name: string;\n version: string;\n};\n\nexport type UserEndpoints =\n | Endpoint<\"GET\", \"/users\", User[]>\n | Endpoint<\"GET\", \"/users/:id\", User, { id: string }>\n | Endpoint<\"GET\", \"/users/me\", User>\n | Endpoint<\n \"GET\",\n \"/users/check/:identifier\",\n {\n exists: boolean;\n identifier: UserIdentifier;\n suggestions?: string[];\n },\n { identifier: boolean; suggestions?: boolean }\n >\n | Endpoint<\"PUT\", \"/users/:id\", User, UpdateUserDto>;\n","import { Currency } from \"..\";\nimport { Event, EventTicket } from \"../event\";\nimport { User } from \"../users\";\n\nexport enum OrderStatus {\n Created = \"created\",\n Cancelled = \"cancelled\",\n Completed = \"completed\",\n Pending = \"pending\",\n Confirmed = \"confirmed\",\n Declined = \"declined\",\n Refunded = \"refunded\",\n PartiallyRefunded = \"partially_refunded\",\n Expired = \"expired\",\n}\n\nexport type OrderItem = {\n id: string;\n ticket: EventTicket;\n isUsed: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type Order = {\n id: string;\n owner: User;\n members: User[];\n status: OrderStatus;\n event: Event;\n items: OrderItem[];\n promoCode?: PromoCode;\n total: number;\n currency: Currency;\n createdAt: Date;\n};\n\nexport type PromoCode = {\n id: string;\n code: string;\n used: number;\n discount: number;\n isActive: boolean;\n expirationAt: Date;\n createdAt: Date;\n};\n","export * from \"./careers\";\nexport * from \"./event\";\nexport * from \"./health\";\nexport * from \"./organizations\";\nexport * from \"./token\";\nexport * from \"./users\";\nexport * from \"./order\";\nexport * from \"./profiles\";\n\nexport type Location = {\n name?: string;\n address: string;\n zipCode: string;\n city: string;\n country: string;\n geometry?: {\n latitude: number;\n longitude: number;\n };\n};\n\n// Currency\nexport enum Currency {\n EUR = \"EUR\",\n USD = \"USD\",\n GBP = \"GBP\",\n}\n\n// I18n\nexport enum Language {\n FR = \"fr\",\n EN = \"en\",\n}\n","import { ParamValue, Query, pathcat } from \"pathcat\";\nimport { Options, Response } from \"redaxios\";\n\nimport { APIResponse, Endpoints, ErroredAPIResponse } from \"./endpoints\";\nimport { APIRequestOptions, request } from \"./request\";\nimport { DEFAULT_API_URL } from \"../constants\";\n\nexport type PathsFor<M extends Options[\"method\"]> = Extract<\n Endpoints,\n { method: M }\n>[\"path\"];\n\nexport class TonightPassAPIError<T> extends Error {\n public readonly status: number;\n\n constructor(\n public readonly response: Response<APIResponse<T>>,\n public readonly data: ErroredAPIResponse,\n ) {\n super(data.message);\n\n this.status = response.status;\n }\n}\n\nexport interface ClientOptions {\n readonly baseURL: string;\n}\n\nexport class Client {\n private options;\n public readonly url;\n\n constructor(options: ClientOptions) {\n this.options = options;\n this.url = (path: string, params: Record<string, ParamValue>) => {\n const baseURL = this.options.baseURL || DEFAULT_API_URL;\n return pathcat(baseURL, path, params);\n };\n }\n\n setOptions(options: ClientOptions) {\n this.options = options;\n }\n\n async get<Path extends PathsFor<\"GET\">>(\n path: Path,\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"GET\" }>[\"res\"]\n >(\"GET\", path, undefined, query, options);\n }\n\n async post<Path extends Extract<Endpoints, { method: \"POST\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"POST\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"POST\" }>[\"res\"]\n >(\"POST\", path, body, query, options);\n }\n\n async put<Path extends Extract<Endpoints, { method: \"PUT\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"PUT\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"PUT\" }>[\"res\"]\n >(\"PUT\", path, body, query, options);\n }\n\n async patch<Path extends Extract<Endpoints, { method: \"PATCH\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"PATCH\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"PATCH\" }>[\"res\"]\n >(\"PATCH\", path, body, query, options);\n }\n\n async delete<Path extends Extract<Endpoints, { method: \"DELETE\" }>[\"path\"]>(\n path: Path,\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"DELETE\" }>[\"res\"]\n >(\"DELETE\", path, undefined, query, options);\n }\n\n private async requester<T>(\n method: Options[\"method\"],\n path: string,\n body: unknown,\n query: Query<string> = {},\n options: APIRequestOptions = {},\n ) {\n const url = this.url(path, query);\n\n if (body !== undefined) {\n if (method === \"GET\") {\n throw new Error(\"Cannot send a GET request with a body\");\n }\n }\n\n const response: Response<APIResponse<T>> = await request<T>(url, {\n method,\n data: body,\n ...options,\n });\n\n const result = response.data;\n\n if (!result.success) {\n throw new TonightPassAPIError<T>(response, result);\n }\n\n return result.data;\n }\n}\n","import { Client } from \"../rest\";\n\nexport function sdk<T>(builder: (client: Client) => T) {\n return builder;\n}\n","import { sdk } from \"./builder\";\n\nexport const health = sdk((client) => ({\n database: async () => client.get(\"/health/database\"),\n http: async () => client.get(\"/health/http\"),\n}));\n","import { sdk } from \"./builder\";\nimport { UpdateUserDto } from \"../rest\";\n\nexport const users = sdk((client) => ({\n getAll: async () => client.get(\"/users\"),\n get: async (id: string) => client.get(\"/users\", { id }),\n me: async () => client.get(\"/users/me\"),\n check: async (identifier: string, suggestions?: boolean) =>\n client.get(\"/users/check/:identifier\", { identifier, suggestions }),\n update: async (id: string, data: UpdateUserDto) =>\n client.put(\"/users/:id\", data, { id }),\n}));\n","import { Query } from \"pathcat\";\n\nimport { sdk } from \"./builder\";\n\nexport const careers = sdk((client) => ({\n categories: {\n getAll: async (query?: Query<\"/careers/categories\">) =>\n client.get(\"/careers/categories\", query),\n },\n employmentTypes: {\n getAll: async (query?: Query<\"/careers/employmentTypes\">) =>\n client.get(\"/careers/employmentTypes\", query),\n },\n jobs: {\n getAll: async (query?: Query<\"/careers/jobs\">) =>\n client.get(\"/careers/jobs\", query),\n get: async (id: number) => client.get(\"/careers/jobs/:id\", { id }),\n },\n offices: {\n getAll: async (query?: Query<\"/careers/offices\">) =>\n client.get(\"/careers/offices\", query),\n },\n}));\n","import { sdk } from \"./builder\";\n\nexport const profiles = sdk((client) => ({\n get: async (username: string) =>\n client.get(\"/profiles/:username\", { username }),\n}));\n","import { Client, ClientOptions } from \"./rest\";\nimport { careers } from \"./sdk/careers\";\nimport { health } from \"./sdk/health\";\nimport { profiles } from \"./sdk/profiles\";\nimport { users } from \"./sdk/users\";\n\nexport class TonightPass {\n public readonly client: Client;\n\n public readonly careers;\n public readonly health;\n public readonly profiles;\n public readonly users;\n\n constructor(options: ClientOptions) {\n this.client = new Client(options);\n\n this.careers = careers(this.client);\n this.health = health(this.client);\n this.profiles = profiles(this.client);\n this.users = users(this.client);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/constants/api.ts","../src/constants/regex.ts","../src/rest/dtos/index.ts","../src/rest/dtos/users/create-user.dto.ts","../src/rest/dtos/users/sign-in-user.dto.ts","../src/rest/dtos/users/update-user.dto.ts","../src/rest/request/request.ts","../src/utils/index.ts","../src/rest/types/event/ticket/index.ts","../src/rest/types/event/index.ts","../src/rest/types/organizations/index.ts","../src/rest/types/token/index.ts","../src/rest/types/users/index.ts","../src/rest/types/order/index.ts","../src/rest/types/index.ts","../src/rest/client.ts","../src/sdk/builder.ts","../src/sdk/health.ts","../src/sdk/users.ts","../src/sdk/careers.ts","../src/sdk/profiles.ts","../src/tonightpass.ts"],"names":["DEFAULT_API_URL","EMAIL_REGEX","PASSWORD_REGEX","NAME_REGEX","SLUG_REGEX","BCRYPT_HASH","PHONE_NUMBER_REGEX","IMAGE_URL_REGEX","CreateUserDto","SignInUserDto","Type","IsDateString","IsEmail","IsObject","IsOptional","IsPhoneNumber","IsString","IsUrl","Length","Matches","MaxLength","MinLength","ValidateNested","UpdateUserDto","__decorateClass","UpdateIdentifierDto","UpdateIdentityDto","axios","isBrowser","instance","data","request","url","options","response","error","EventTicketCategory","EventType","EventStyleType","OrganizationSocialType","OrganizationMemberRole","UserTokenType","UserRole","OrderStatus","Currency","Language","pathcat","TonightPassAPIError","Client","path","params","baseURL","query","body","method","result","sdk","builder","health","client","users","id","identifier","suggestions","careers","profiles","username","TonightPass"],"mappings":"wMAAO,IAAMA,EAAkB,8BCAxB,IAAMC,GAAc,2CAGdC,GACX,yDAGWC,EAAa,2BAGbC,GAAa,kCAGbC,GAAc,0CAEdC,GACX,6FAEWC,GACX,yGCnBF,MAAO,mBCEA,IAAMC,EAAN,KAAoB,CACzB,WACA,SACA,SACA,SACF,ECPO,IAAMC,EAAN,KAAoB,CACzB,WACA,QACF,ECHA,OAAS,QAAAC,MAAY,oBACrB,OACE,gBAAAC,EACA,WAAAC,EACA,YAAAC,EACA,cAAAC,EACA,iBAAAC,EACA,YAAAC,EACA,SAAAC,EACA,UAAAC,EACA,WAAAC,EACA,aAAAC,EACA,aAAAC,EACA,kBAAAC,MACK,kBAKA,IAAMC,EAAN,KAAoB,CAKzB,WAMA,SAMA,QACF,EAbEC,EAAA,CAJCV,EAAW,EACXD,EAAS,EACTS,EAAe,EACfZ,EAAK,IAAMe,CAAmB,GAJpBF,EAKX,0BAMAC,EAAA,CAJCV,EAAW,EACXD,EAAS,EACTS,EAAe,EACfZ,EAAK,IAAMgB,CAAiB,GAVlBH,EAWX,wBAMAC,EAAA,CAJCV,EAAW,EACXE,EAAS,EACTK,EAAU,CAAC,EACXD,EAAU,GAAG,GAhBHG,EAiBX,wBAGF,IAAME,EAAN,KAGA,CAIE,MAKA,YAKA,QACF,EAXED,EAAA,CAHCV,EAAW,EACXE,EAAS,EACTJ,EAAQ,GANLa,EAOJ,qBAKAD,EAAA,CAHCV,EAAW,EACXE,EAAS,EACTD,EAAc,GAXXU,EAYJ,2BAKAD,EAAA,CAHCV,EAAW,EACXE,EAAS,EACTK,EAAU,CAAC,GAhBRI,EAiBJ,wBAGF,IAAMC,EAAN,KAeA,CAOE,UAQA,SAKA,YAKA,YAIA,kBAIA,UAGA,OAIA,SACF,EAlCEF,EAAA,CANCV,EAAW,EACXE,EAAS,EACTE,EAAO,EAAG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BAAuB,CAAE,SAAAO,CAAS,CAAC,CAClD,GCCO,IAAMC,EAAN,KAAkB,CACP,OAEA,QACA,OACA,SACA,MAEhB,YAAYlC,EAAwB,CAClC,KAAK,OAAS,IAAIe,EAAOf,CAAO,EAEhC,KAAK,QAAU+B,EAAQ,KAAK,MAAM,EAClC,KAAK,OAASN,EAAO,KAAK,MAAM,EAChC,KAAK,SAAWO,EAAS,KAAK,MAAM,EACpC,KAAK,MAAQL,EAAM,KAAK,MAAM,CAChC,CACF","sourcesContent":["export const DEFAULT_API_URL = \"https://api.tonightpass.com\";\n","export const EMAIL_REGEX = /^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$/;\n\n// checks if a password has at least one uppercase letter and a number or special character\nexport const PASSWORD_REGEX =\n /((?=.*\\d)|(?=.*\\W+))(?![.\\n])(?=.*[A-Z])(?=.*[a-z]).*$/;\n\n// checks if a string has only letters, numbers, spaces, apostrophes, dots and dashes\nexport const NAME_REGEX = /(^[\\p{L}\\d'\\\\.\\s\\\\-]*$)/u;\n\n// checks if a string is a valid slug, useful for usernames\nexport const SLUG_REGEX = /^[a-z\\d]+(?:(\\.|-|_)[a-z\\d]+)*$/;\n\n// validates if passwords are valid bcrypt hashes\nexport const BCRYPT_HASH = /\\$2[abxy]?\\$\\d{1,2}\\$[A-Za-z\\d\\\\./]{53}/;\n\nexport const PHONE_NUMBER_REGEX =\n /^\\s*(?:\\+?(\\d{1,3}))?([-. (]*(\\d{3})[-. )]*)?((\\d{3})[-. ]*(\\d{2,4})(?:[-.x ]*(\\d+))?)\\s*$/;\n\nexport const IMAGE_URL_REGEX =\n /(((http:\\/\\/www)|(http:\\/\\/)|(www))[-a-zA-Z0-9@:%_\\\\+.~#?&//=]+)\\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)/i;\n","import \"reflect-metadata\";\n\nexport * from \"./users\";\n","import { UserIdentifier, UserIdentityGender } from \"../../types\";\n\nexport class CreateUserDto {\n identifier: UserIdentifier;\n password: string;\n identity: CreateUserIdentituDto;\n addresses: Location[];\n}\n\nclass CreateUserIdentituDto {\n firstName: string;\n lastName: string;\n gender: UserIdentityGender;\n profilePictureUrl?: string;\n birthDate: Date;\n}\n","export class SignInUserDto {\n identifier: string;\n password: string;\n}\n","import { Type } from \"class-transformer\";\nimport {\n IsDateString,\n IsEmail,\n IsObject,\n IsOptional,\n IsPhoneNumber,\n IsString,\n IsUrl,\n Length,\n Matches,\n MaxLength,\n MinLength,\n ValidateNested,\n} from \"class-validator\";\n\nimport { NAME_REGEX } from \"../../../constants/regex\";\nimport { UserIdentifier, UserIdentity } from \"../../types\";\n\nexport class UpdateUserDto {\n @IsOptional()\n @IsObject()\n @ValidateNested()\n @Type(() => UpdateIdentifierDto)\n identifier?: UpdateIdentifierDto;\n\n @IsOptional()\n @IsObject()\n @ValidateNested()\n @Type(() => UpdateIdentityDto)\n identity?: UpdateIdentityDto;\n\n @IsOptional()\n @IsString()\n @MinLength(6)\n @MaxLength(130)\n password?: string;\n}\n\nclass UpdateIdentifierDto\n implements\n Partial<Pick<UserIdentifier, \"email\" | \"phoneNumber\" | \"username\">>\n{\n @IsOptional()\n @IsString()\n @IsEmail()\n email?: string;\n\n @IsOptional()\n @IsString()\n @IsPhoneNumber()\n phoneNumber?: string;\n\n @IsOptional()\n @IsString()\n @MinLength(3)\n username?: string;\n}\n\nclass UpdateIdentityDto\n implements\n Partial<\n Pick<\n UserIdentity,\n | \"firstName\"\n | \"lastName\"\n | \"displayName\"\n | \"description\"\n | \"profilePictureUrl\"\n | \"bannerUrl\"\n | \"gender\"\n | \"birthDate\"\n >\n >\n{\n @IsOptional()\n @IsString()\n @Length(2, 50)\n @Matches(NAME_REGEX, {\n message: \"First name must be composed of letters only\",\n })\n firstName?: string;\n\n @IsOptional()\n @IsString()\n @Length(2, 50)\n @Matches(NAME_REGEX, {\n message: \"Last name must be composed of letters only\",\n })\n lastName?: string;\n\n @IsOptional()\n @IsString()\n @Length(1, 32)\n displayName?: string;\n\n @IsOptional()\n @IsString()\n @Length(15, 500)\n description?: string;\n\n @IsOptional()\n @IsUrl()\n profilePictureUrl?: string | undefined;\n\n @IsOptional()\n @IsUrl()\n bannerUrl?: string | undefined;\n\n @IsOptional()\n gender?: string;\n\n @IsOptional()\n @IsDateString()\n birthDate?: Date;\n}\n","import axios, { Options, Response } from \"redaxios\";\n\nimport { isBrowser } from \"../../utils\";\nimport { APIResponse, ErroredAPIResponse } from \"../endpoints\";\n\nconst instance = axios.create({\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...(!isBrowser && { \"User-Agent\": \"tonightpass-api-client\" }),\n },\n responseType: \"json\",\n transformRequest: [\n function (data) {\n return JSON.stringify(data);\n },\n ],\n withCredentials: isBrowser,\n});\n\nexport interface APIRequestOptions extends Options {}\n\nexport const request = async <T>(url: string, options?: Options) => {\n const response = instance<APIResponse<T>>(url, { ...options })\n .then((response) => response)\n .catch((error: Response<ErroredAPIResponse>) => {\n throw error.data;\n });\n\n return response;\n};\n","export const isBrowser = typeof window !== \"undefined\";\n","import { Currency } from \"../..\";\n\nexport type EventTicket = {\n id: string;\n name: string;\n description?: string;\n price: number;\n displayPrice: number;\n quantity: number;\n type: EventTicketType;\n category: EventTicketCategory;\n currency: Currency;\n vatRate: number;\n externalId?: string;\n isVisible: boolean;\n isFeesIncluded: boolean;\n startAt: Date;\n endAt: Date;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type EventTicketType = \"e-ticket\" | \"other\";\n\nexport enum EventTicketCategory {\n ENTRY = \"entry\",\n PACKAGE = \"package\",\n MEAL = \"meal\",\n DRINK = \"drink\",\n PARKING = \"parking\",\n ACCOMMODATION = \"accommodation\",\n CAMPING = \"camping\",\n LOCKER = \"locker\",\n SHUTTLE = \"shuttle\",\n OTHER = \"other\",\n}\n","import { EventTicket } from \"./ticket\";\nimport { Location } from \"..\";\nimport { Organization } from \"../organizations\";\n\nexport * from \"./ticket\";\n\nexport type Event = {\n title: string;\n description: string;\n slug: string;\n organization: Organization;\n type: EventType;\n public: boolean;\n flyers: string[];\n trailers: string[];\n location: Location;\n tickets: EventTicket[];\n styles: EventStyle[];\n startAt: Date;\n endAt: Date;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport enum EventType {\n Clubbing = \"clubbing\",\n Concert = \"concert\",\n Afterwork = \"afterwork\",\n DancingLunch = \"dancing_lunch\",\n Diner = \"diner\",\n Garden = \"garden\",\n AfterBeach = \"after_beach\",\n Festival = \"festival\",\n Spectacle = \"spectacle\",\n Cruise = \"cruise\",\n OutsideAnimation = \"outside_animation\",\n Sport = \"sport\",\n Match = \"match\",\n Seminar = \"seminar\",\n Conference = \"conference\",\n WellnessDay = \"wellness_day\",\n Workshop = \"workshop\",\n TradeFair = \"trade_fair\",\n ConsumerShow = \"consumer_show\",\n Membership = \"membership\",\n}\n\nexport type EventStyle = {\n type: EventStyleType;\n emoji: string;\n name: string;\n};\n\nexport enum EventStyleType {\n Music = \"music\",\n Dress = \"dress\",\n Sport = \"sport\",\n Food = \"food\",\n Art = \"art\",\n}\n","import { Location, Profile, ProfileMetadata } from \"..\";\nimport { Event } from \"../event\";\nimport { EventTicket } from \"../event/ticket\";\nimport { User } from \"../users\";\n\nexport type Organization = {\n id: string;\n slug: string;\n identity: OrganizationIdentity;\n members: OrganizationMember[];\n location?: Location;\n events: Event[];\n savedTickets: EventTicket[];\n verified: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type OrganizationIdentity = Profile & {\n socialLinks: OrganizationSocialLink[];\n\n metadata: ProfileMetadata & {\n eventsCount: number;\n viewsCount: number;\n membersCount: number;\n };\n};\n\nexport type OrganizationSocialLink = {\n type: OrganizationSocialType;\n url: string;\n};\n\nexport enum OrganizationSocialType {\n Facebook = \"facebook\",\n Twitter = \"twitter\",\n Instagram = \"instagram\",\n Linkedin = \"linkedin\",\n Youtube = \"youtube\",\n Website = \"website\",\n}\n\nexport type OrganizationMember = {\n user: User;\n role: OrganizationMemberRole;\n createdAt: Date;\n};\n\nexport enum OrganizationMemberRole {\n EMPLOYEE = 0,\n MANAGER = 1,\n ADMINISTRATOR = 2,\n OWNER = 3,\n}\n","export type UserToken = {\n id: string;\n type: UserTokenType;\n value: string;\n createdAt: Date;\n expiresAt: Date;\n};\n\nexport enum UserTokenType {\n Authentication = \"authentication\",\n OrganizationInvite = \"organization_invite\",\n PasswordRecovery = \"password_recovery\",\n EmailValidation = \"email_validation\",\n PhoneValidation = \"phone_validation\",\n}\n","import { Currency, Language, Location, Profile, ProfileMetadata } from \"..\";\nimport { UpdateUserDto } from \"../../dtos\";\nimport { Endpoint } from \"../../endpoints\";\n\nexport type User = {\n id: string;\n identifier: UserIdentifier;\n password: string;\n identity: UserIdentity;\n role: UserRole;\n addresses: Location[];\n preferences: UserPreferences;\n connections: UserConnection[];\n verified: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type UserIdentifier = {\n email?: string;\n phoneNumber?: string;\n username: string;\n\n [key: string]: string | undefined;\n};\n\nexport type UserIdentity = Profile & {\n firstName: string;\n lastName: string;\n fullName: string;\n gender: UserIdentityGender;\n birthDate: Date;\n\n metadata: ProfileMetadata & {\n followingCount: number;\n hasPassPlus: boolean;\n idValid: boolean;\n };\n};\n\nexport enum UserRole {\n USER = 0,\n DEVELOPER = 8,\n ADMINISTRATOR = 10,\n}\n\nexport type UserIdentityGender =\n | \"male\"\n | \"female\"\n | \"non-binary\"\n | \"gender-fluid\"\n | \"neutral\"\n | \"other\"\n | string;\n\nexport type UserPreferences = {\n language: Language;\n currency: Currency;\n notifications: {\n email: {\n newsletter: boolean;\n message: boolean;\n };\n push: {\n message: boolean;\n };\n };\n};\n\nexport type UserConnection = {\n ip: string;\n os: UserConnectionOS;\n device: UserConnectionDevice;\n client: UserConnectionClient;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type UserConnectionOS = {\n name: string;\n version: string;\n};\n\nexport type UserConnectionDevice = {\n type: string;\n brand: string;\n};\n\nexport type UserConnectionClient = {\n name: string;\n version: string;\n};\n\nexport type UserEndpoints =\n | Endpoint<\"GET\", \"/users\", User[]>\n | Endpoint<\"GET\", \"/users/:id\", User, { id: string }>\n | Endpoint<\"GET\", \"/users/me\", User>\n | Endpoint<\n \"GET\",\n \"/users/check/:identifier\",\n {\n exists: boolean;\n identifier: UserIdentifier;\n suggestions?: string[];\n },\n { identifier: boolean; suggestions?: boolean }\n >\n | Endpoint<\"PUT\", \"/users/:id\", User, UpdateUserDto>;\n","import { Currency } from \"..\";\nimport { Event, EventTicket } from \"../event\";\nimport { User } from \"../users\";\n\nexport enum OrderStatus {\n Created = \"created\",\n Cancelled = \"cancelled\",\n Completed = \"completed\",\n Pending = \"pending\",\n Confirmed = \"confirmed\",\n Declined = \"declined\",\n Refunded = \"refunded\",\n PartiallyRefunded = \"partially_refunded\",\n Expired = \"expired\",\n}\n\nexport type OrderItem = {\n id: string;\n ticket: EventTicket;\n isUsed: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type Order = {\n id: string;\n owner: User;\n members: User[];\n status: OrderStatus;\n event: Event;\n items: OrderItem[];\n promoCode?: PromoCode;\n total: number;\n currency: Currency;\n createdAt: Date;\n};\n\nexport type PromoCode = {\n id: string;\n code: string;\n used: number;\n discount: number;\n isActive: boolean;\n expirationAt: Date;\n createdAt: Date;\n};\n","export * from \"./auth\";\nexport * from \"./careers\";\nexport * from \"./event\";\nexport * from \"./health\";\nexport * from \"./organizations\";\nexport * from \"./token\";\nexport * from \"./users\";\nexport * from \"./order\";\nexport * from \"./profiles\";\n\nexport type Location = {\n name?: string;\n address: string;\n zipCode: string;\n city: string;\n country: string;\n geometry?: {\n latitude: number;\n longitude: number;\n };\n};\n\n// Currency\nexport enum Currency {\n EUR = \"EUR\",\n USD = \"USD\",\n GBP = \"GBP\",\n}\n\n// I18n\nexport enum Language {\n FR = \"fr\",\n EN = \"en\",\n}\n","import { ParamValue, Query, pathcat } from \"pathcat\";\nimport { Options, Response } from \"redaxios\";\n\nimport { APIResponse, Endpoints, ErroredAPIResponse } from \"./endpoints\";\nimport { APIRequestOptions, request } from \"./request\";\nimport { DEFAULT_API_URL } from \"../constants\";\n\nexport type PathsFor<M extends Options[\"method\"]> = Extract<\n Endpoints,\n { method: M }\n>[\"path\"];\n\nexport class TonightPassAPIError<T> extends Error {\n public readonly status: number;\n\n constructor(\n public readonly response: Response<APIResponse<T>>,\n public readonly data: ErroredAPIResponse,\n ) {\n super(data.message);\n\n this.status = response.status;\n }\n}\n\nexport interface ClientOptions {\n readonly baseURL: string;\n}\n\nexport class Client {\n private options;\n public readonly url;\n\n constructor(options: ClientOptions) {\n this.options = options;\n this.url = (path: string, params: Record<string, ParamValue>) => {\n const baseURL = this.options.baseURL || DEFAULT_API_URL;\n return pathcat(baseURL, path, params);\n };\n }\n\n setOptions(options: ClientOptions) {\n this.options = options;\n }\n\n async get<Path extends PathsFor<\"GET\">>(\n path: Path,\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"GET\" }>[\"res\"]\n >(\"GET\", path, undefined, query, options);\n }\n\n async post<Path extends Extract<Endpoints, { method: \"POST\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"POST\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"POST\" }>[\"res\"]\n >(\"POST\", path, body, query, options);\n }\n\n async put<Path extends Extract<Endpoints, { method: \"PUT\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"PUT\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"PUT\" }>[\"res\"]\n >(\"PUT\", path, body, query, options);\n }\n\n async patch<Path extends Extract<Endpoints, { method: \"PATCH\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"PATCH\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"PATCH\" }>[\"res\"]\n >(\"PATCH\", path, body, query, options);\n }\n\n async delete<Path extends Extract<Endpoints, { method: \"DELETE\" }>[\"path\"]>(\n path: Path,\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"DELETE\" }>[\"res\"]\n >(\"DELETE\", path, undefined, query, options);\n }\n\n private async requester<T>(\n method: Options[\"method\"],\n path: string,\n body: unknown,\n query: Query<string> = {},\n options: APIRequestOptions = {},\n ) {\n const url = this.url(path, query);\n\n if (body !== undefined) {\n if (method === \"GET\") {\n throw new Error(\"Cannot send a GET request with a body\");\n }\n }\n\n const response: Response<APIResponse<T>> = await request<T>(url, {\n method,\n data: body,\n ...options,\n });\n\n const result = response.data;\n\n if (!result.success) {\n throw new TonightPassAPIError<T>(response, result);\n }\n\n return result.data;\n }\n}\n","import { Client } from \"../rest\";\n\nexport function sdk<T>(builder: (client: Client) => T) {\n return builder;\n}\n","import { sdk } from \"./builder\";\n\nexport const health = sdk((client) => ({\n database: async () => client.get(\"/health/database\"),\n http: async () => client.get(\"/health/http\"),\n}));\n","import { sdk } from \"./builder\";\nimport { UpdateUserDto } from \"../rest\";\n\nexport const users = sdk((client) => ({\n getAll: async () => client.get(\"/users\"),\n get: async (id: string) => client.get(\"/users\", { id }),\n me: async () => client.get(\"/users/me\"),\n check: async (identifier: string, suggestions?: boolean) =>\n client.get(\"/users/check/:identifier\", { identifier, suggestions }),\n update: async (id: string, data: UpdateUserDto) =>\n client.put(\"/users/:id\", data, { id }),\n}));\n","import { Query } from \"pathcat\";\n\nimport { sdk } from \"./builder\";\n\nexport const careers = sdk((client) => ({\n categories: {\n getAll: async (query?: Query<\"/careers/categories\">) =>\n client.get(\"/careers/categories\", query),\n },\n employmentTypes: {\n getAll: async (query?: Query<\"/careers/employmentTypes\">) =>\n client.get(\"/careers/employmentTypes\", query),\n },\n jobs: {\n getAll: async (query?: Query<\"/careers/jobs\">) =>\n client.get(\"/careers/jobs\", query),\n get: async (id: number) => client.get(\"/careers/jobs/:id\", { id }),\n },\n offices: {\n getAll: async (query?: Query<\"/careers/offices\">) =>\n client.get(\"/careers/offices\", query),\n },\n}));\n","import { sdk } from \"./builder\";\n\nexport const profiles = sdk((client) => ({\n get: async (username: string) =>\n client.get(\"/profiles/:username\", { username }),\n}));\n","import { Client, ClientOptions } from \"./rest\";\nimport { careers } from \"./sdk/careers\";\nimport { health } from \"./sdk/health\";\nimport { profiles } from \"./sdk/profiles\";\nimport { users } from \"./sdk/users\";\n\nexport class TonightPass {\n public readonly client: Client;\n\n public readonly careers;\n public readonly health;\n public readonly profiles;\n public readonly users;\n\n constructor(options: ClientOptions) {\n this.client = new Client(options);\n\n this.careers = careers(this.client);\n this.health = health(this.client);\n this.profiles = profiles(this.client);\n this.users = users(this.client);\n }\n}\n"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants/api.ts","../src/constants/regex.ts","../src/rest/dtos/index.ts","../src/rest/dtos/users/create-user.dto.ts","../src/rest/dtos/users/sign-in-user.dto.ts","../src/rest/dtos/users/update-user.dto.ts","../src/rest/request/request.ts","../src/utils/index.ts","../src/rest/types/event/ticket/index.ts","../src/rest/types/event/index.ts","../src/rest/types/organizations/index.ts","../src/rest/types/token/index.ts","../src/rest/types/users/index.ts","../src/rest/types/order/index.ts","../src/rest/types/index.ts","../src/rest/client.ts","../src/sdk/builder.ts","../src/sdk/health.ts","../src/sdk/users.ts","../src/sdk/careers.ts","../src/sdk/profiles.ts","../src/tonightpass.ts"],"names":["DEFAULT_API_URL","EMAIL_REGEX","PASSWORD_REGEX","NAME_REGEX","SLUG_REGEX","BCRYPT_HASH","PHONE_NUMBER_REGEX","IMAGE_URL_REGEX","CreateUserDto","SignInUserDto","Type","IsDateString","IsEmail","IsObject","IsOptional","IsPhoneNumber","IsString","IsUrl","Length","Matches","MaxLength","MinLength","ValidateNested","UpdateUserDto","__decorateClass","UpdateIdentifierDto","UpdateIdentityDto","axios","isBrowser","instance","data","request","url","options","response","error","EventTicketCategory","EventType","EventStyleType","OrganizationSocialType","OrganizationMemberRole","UserTokenType","UserRole","OrderStatus","Currency","Language","pathcat","TonightPassAPIError","Client","path","params","baseURL","query","body","method","result","sdk","builder","health","client","users","id","identifier","suggestions","careers","profiles","username","TonightPass"],"mappings":"wMAAO,IAAMA,EAAkB,8BCAxB,IAAMC,GAAc,2CAGdC,GACX,yDAGWC,EAAa,2BAGbC,GAAa,kCAGbC,GAAc,0CAEdC,GACX,6FAEWC,GACX,yGCnBF,MAAO,mBCEA,IAAMC,EAAN,KAAoB,CACzB,WACA,SACA,SACA,SACF,ECPO,IAAMC,EAAN,KAAoB,CACzB,WACA,QACF,ECHA,OAAS,QAAAC,MAAY,oBACrB,OACE,gBAAAC,EACA,WAAAC,EACA,YAAAC,EACA,cAAAC,EACA,iBAAAC,EACA,YAAAC,EACA,SAAAC,EACA,UAAAC,EACA,WAAAC,EACA,aAAAC,EACA,aAAAC,EACA,kBAAAC,MACK,kBAKA,IAAMC,EAAN,KAAoB,CAKzB,WAMA,SAMA,QACF,EAbEC,EAAA,CAJCV,EAAW,EACXD,EAAS,EACTS,EAAe,EACfZ,EAAK,IAAMe,CAAmB,GAJpBF,EAKX,0BAMAC,EAAA,CAJCV,EAAW,EACXD,EAAS,EACTS,EAAe,EACfZ,EAAK,IAAMgB,CAAiB,GAVlBH,EAWX,wBAMAC,EAAA,CAJCV,EAAW,EACXE,EAAS,EACTK,EAAU,CAAC,EACXD,EAAU,GAAG,GAhBHG,EAiBX,wBAGF,IAAME,EAAN,KAGA,CAIE,MAKA,YAKA,QACF,EAXED,EAAA,CAHCV,EAAW,EACXE,EAAS,EACTJ,EAAQ,GANLa,EAOJ,qBAKAD,EAAA,CAHCV,EAAW,EACXE,EAAS,EACTD,EAAc,GAXXU,EAYJ,2BAKA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OS,GAAeF,EAAO,IAAI,oBAAqB,CAAE,GAAAE,CAAG,CAAC,CACnE,EACA,QAAS,CACP,OAAQ,MAAOT,GACbO,EAAO,IAAI,mBAAoBP,CAAK,CACxC,CACF,GCpBO,IAAMa,EAAgBN,IAAY,CACvC,IAAK,MAAOO,GACVP,EAAO,IAAI,sBAAuB,CAAE,SAAAO,CAAS,CAAC,CAClD,GCCO,IAAMC,EAAN,KAAkB,CACP,OAEA,QACA,OACA,SACA,MAEhB,YAAYlC,EAAwB,CAClC,KAAK,OAAS,IAAIe,EAAOf,CAAO,EAEhC,KAAK,QAAU+B,EAAQ,KAAK,MAAM,EAClC,KAAK,OAASN,EAAO,KAAK,MAAM,EAChC,KAAK,SAAWO,EAAS,KAAK,MAAM,EACpC,KAAK,MAAQL,EAAM,KAAK,MAAM,CAChC,CACF","sourcesContent":["export const DEFAULT_API_URL = \"https://api.tonightpass.com\";\n","export const EMAIL_REGEX = /^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$/;\n\n// checks if a password has at least one uppercase letter and a number or special character\nexport const PASSWORD_REGEX =\n /((?=.*\\d)|(?=.*\\W+))(?![.\\n])(?=.*[A-Z])(?=.*[a-z]).*$/;\n\n// checks if a string has only letters, numbers, spaces, apostrophes, dots and dashes\nexport const NAME_REGEX = /(^[\\p{L}\\d'\\\\.\\s\\\\-]*$)/u;\n\n// checks if a string is a valid slug, useful for usernames\nexport const SLUG_REGEX = /^[a-z\\d]+(?:(\\.|-|_)[a-z\\d]+)*$/;\n\n// validates if passwords are valid bcrypt hashes\nexport const BCRYPT_HASH = /\\$2[abxy]?\\$\\d{1,2}\\$[A-Za-z\\d\\\\./]{53}/;\n\nexport const PHONE_NUMBER_REGEX =\n /^\\s*(?:\\+?(\\d{1,3}))?([-. (]*(\\d{3})[-. )]*)?((\\d{3})[-. ]*(\\d{2,4})(?:[-.x ]*(\\d+))?)\\s*$/;\n\nexport const IMAGE_URL_REGEX =\n /(((http:\\/\\/www)|(http:\\/\\/)|(www))[-a-zA-Z0-9@:%_\\\\+.~#?&//=]+)\\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)/i;\n","import \"reflect-metadata\";\n\nexport * from \"./users\";\n","import { UserIdentifier, UserIdentityGender } from \"../../types\";\n\nexport class CreateUserDto {\n identifier: UserIdentifier;\n password: string;\n identity: CreateUserIdentituDto;\n addresses: Location[];\n}\n\nclass CreateUserIdentituDto {\n firstName: string;\n lastName: string;\n gender: UserIdentityGender;\n profilePictureUrl?: string;\n birthDate: Date;\n}\n","export class SignInUserDto {\n identifier: string;\n password: string;\n}\n","import { Type } from \"class-transformer\";\nimport {\n IsDateString,\n IsEmail,\n IsObject,\n IsOptional,\n IsPhoneNumber,\n IsString,\n IsUrl,\n Length,\n Matches,\n MaxLength,\n MinLength,\n ValidateNested,\n} from \"class-validator\";\n\nimport { NAME_REGEX } from \"../../../constants/regex\";\nimport { UserIdentifier, UserIdentity } from \"../../types\";\n\nexport class UpdateUserDto {\n @IsOptional()\n @IsObject()\n @ValidateNested()\n @Type(() => UpdateIdentifierDto)\n identifier?: UpdateIdentifierDto;\n\n @IsOptional()\n @IsObject()\n @ValidateNested()\n @Type(() => UpdateIdentityDto)\n identity?: UpdateIdentityDto;\n\n @IsOptional()\n @IsString()\n @MinLength(6)\n @MaxLength(130)\n password?: string;\n}\n\nclass UpdateIdentifierDto\n implements\n Partial<Pick<UserIdentifier, \"email\" | \"phoneNumber\" | \"username\">>\n{\n @IsOptional()\n @IsString()\n @IsEmail()\n email?: string;\n\n @IsOptional()\n @IsString()\n @IsPhoneNumber()\n phoneNumber?: string;\n\n @IsOptional()\n @IsString()\n @MinLength(3)\n username?: string;\n}\n\nclass UpdateIdentityDto\n implements\n Partial<\n Pick<\n UserIdentity,\n | \"firstName\"\n | \"lastName\"\n | \"displayName\"\n | \"description\"\n | \"profilePictureUrl\"\n | \"bannerUrl\"\n | \"gender\"\n | \"birthDate\"\n >\n >\n{\n @IsOptional()\n @IsString()\n @Length(2, 50)\n @Matches(NAME_REGEX, {\n message: \"First name must be composed of letters only\",\n })\n firstName?: string;\n\n @IsOptional()\n @IsString()\n @Length(2, 50)\n @Matches(NAME_REGEX, {\n message: \"Last name must be composed of letters only\",\n })\n lastName?: string;\n\n @IsOptional()\n @IsString()\n @Length(1, 32)\n displayName?: string;\n\n @IsOptional()\n @IsString()\n @Length(15, 500)\n description?: string;\n\n @IsOptional()\n @IsUrl()\n profilePictureUrl?: string | undefined;\n\n @IsOptional()\n @IsUrl()\n bannerUrl?: string | undefined;\n\n @IsOptional()\n gender?: string;\n\n @IsOptional()\n @IsDateString()\n birthDate?: Date;\n}\n","import axios, { Options, Response } from \"redaxios\";\n\nimport { isBrowser } from \"../../utils\";\nimport { APIResponse, ErroredAPIResponse } from \"../endpoints\";\n\nconst instance = axios.create({\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...(!isBrowser && { \"User-Agent\": \"tonightpass-api-client\" }),\n },\n responseType: \"json\",\n transformRequest: [\n function (data) {\n return JSON.stringify(data);\n },\n ],\n withCredentials: isBrowser,\n});\n\nexport interface APIRequestOptions extends Options {}\n\nexport const request = async <T>(url: string, options?: Options) => {\n const response = instance<APIResponse<T>>(url, { ...options })\n .then((response) => response)\n .catch((error: Response<ErroredAPIResponse>) => {\n throw error.data;\n });\n\n return response;\n};\n","export const isBrowser = typeof window !== \"undefined\";\n","import { Currency } from \"../..\";\n\nexport type EventTicket = {\n id: string;\n name: string;\n description?: string;\n price: number;\n displayPrice: number;\n quantity: number;\n type: EventTicketType;\n category: EventTicketCategory;\n currency: Currency;\n vatRate: number;\n externalId?: string;\n isVisible: boolean;\n isFeesIncluded: boolean;\n startAt: Date;\n endAt: Date;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type EventTicketType = \"e-ticket\" | \"other\";\n\nexport enum EventTicketCategory {\n ENTRY = \"entry\",\n PACKAGE = \"package\",\n MEAL = \"meal\",\n DRINK = \"drink\",\n PARKING = \"parking\",\n ACCOMMODATION = \"accommodation\",\n CAMPING = \"camping\",\n LOCKER = \"locker\",\n SHUTTLE = \"shuttle\",\n OTHER = \"other\",\n}\n","import { EventTicket } from \"./ticket\";\nimport { Location } from \"..\";\nimport { Organization } from \"../organizations\";\n\nexport * from \"./ticket\";\n\nexport type Event = {\n title: string;\n description: string;\n slug: string;\n organization: Organization;\n type: EventType;\n public: boolean;\n flyers: string[];\n trailers: string[];\n location: Location;\n tickets: EventTicket[];\n styles: EventStyle[];\n startAt: Date;\n endAt: Date;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport enum EventType {\n Clubbing = \"clubbing\",\n Concert = \"concert\",\n Afterwork = \"afterwork\",\n DancingLunch = \"dancing_lunch\",\n Diner = \"diner\",\n Garden = \"garden\",\n AfterBeach = \"after_beach\",\n Festival = \"festival\",\n Spectacle = \"spectacle\",\n Cruise = \"cruise\",\n OutsideAnimation = \"outside_animation\",\n Sport = \"sport\",\n Match = \"match\",\n Seminar = \"seminar\",\n Conference = \"conference\",\n WellnessDay = \"wellness_day\",\n Workshop = \"workshop\",\n TradeFair = \"trade_fair\",\n ConsumerShow = \"consumer_show\",\n Membership = \"membership\",\n}\n\nexport type EventStyle = {\n type: EventStyleType;\n emoji: string;\n name: string;\n};\n\nexport enum EventStyleType {\n Music = \"music\",\n Dress = \"dress\",\n Sport = \"sport\",\n Food = \"food\",\n Art = \"art\",\n}\n","import { Location, Profile, ProfileMetadata } from \"..\";\nimport { Event } from \"../event\";\nimport { EventTicket } from \"../event/ticket\";\nimport { User } from \"../users\";\n\nexport type Organization = {\n id: string;\n slug: string;\n identity: OrganizationIdentity;\n members: OrganizationMember[];\n location?: Location;\n events: Event[];\n savedTickets: EventTicket[];\n verified: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type OrganizationIdentity = Profile & {\n socialLinks: OrganizationSocialLink[];\n\n metadata: ProfileMetadata & {\n eventsCount: number;\n viewsCount: number;\n membersCount: number;\n };\n};\n\nexport type OrganizationSocialLink = {\n type: OrganizationSocialType;\n url: string;\n};\n\nexport enum OrganizationSocialType {\n Facebook = \"facebook\",\n Twitter = \"twitter\",\n Instagram = \"instagram\",\n Linkedin = \"linkedin\",\n Youtube = \"youtube\",\n Website = \"website\",\n}\n\nexport type OrganizationMember = {\n user: User;\n role: OrganizationMemberRole;\n createdAt: Date;\n};\n\nexport enum OrganizationMemberRole {\n EMPLOYEE = 0,\n MANAGER = 1,\n ADMINISTRATOR = 2,\n OWNER = 3,\n}\n","export type UserToken = {\n id: string;\n type: UserTokenType;\n value: string;\n createdAt: Date;\n expiresAt: Date;\n};\n\nexport enum UserTokenType {\n Authentication = \"authentication\",\n OrganizationInvite = \"organization_invite\",\n PasswordRecovery = \"password_recovery\",\n EmailValidation = \"email_validation\",\n PhoneValidation = \"phone_validation\",\n}\n","import { Currency, Language, Location, Profile, ProfileMetadata } from \"..\";\nimport { UpdateUserDto } from \"../../dtos\";\nimport { Endpoint } from \"../../endpoints\";\n\nexport type User = {\n id: string;\n identifier: UserIdentifier;\n password: string;\n identity: UserIdentity;\n role: UserRole;\n addresses: Location[];\n preferences: UserPreferences;\n connections: UserConnection[];\n verified: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type UserIdentifier = {\n email?: string;\n phoneNumber?: string;\n username: string;\n\n [key: string]: string | undefined;\n};\n\nexport type UserIdentity = Profile & {\n firstName: string;\n lastName: string;\n fullName: string;\n gender: UserIdentityGender;\n birthDate: Date;\n\n metadata: ProfileMetadata & {\n followingCount: number;\n hasPassPlus: boolean;\n idValid: boolean;\n };\n};\n\nexport enum UserRole {\n USER = 0,\n DEVELOPER = 8,\n ADMINISTRATOR = 10,\n}\n\nexport type UserIdentityGender =\n | \"male\"\n | \"female\"\n | \"non-binary\"\n | \"gender-fluid\"\n | \"neutral\"\n | \"other\"\n | string;\n\nexport type UserPreferences = {\n language: Language;\n currency: Currency;\n notifications: {\n email: {\n newsletter: boolean;\n message: boolean;\n };\n push: {\n message: boolean;\n };\n };\n};\n\nexport type UserConnection = {\n ip: string;\n os: UserConnectionOS;\n device: UserConnectionDevice;\n client: UserConnectionClient;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type UserConnectionOS = {\n name: string;\n version: string;\n};\n\nexport type UserConnectionDevice = {\n type: string;\n brand: string;\n};\n\nexport type UserConnectionClient = {\n name: string;\n version: string;\n};\n\nexport type UserEndpoints =\n | Endpoint<\"GET\", \"/users\", User[]>\n | Endpoint<\"GET\", \"/users/:id\", User, { id: string }>\n | Endpoint<\"GET\", \"/users/me\", User>\n | Endpoint<\n \"GET\",\n \"/users/check/:identifier\",\n {\n exists: boolean;\n identifier: UserIdentifier;\n suggestions?: string[];\n },\n { identifier: boolean; suggestions?: boolean }\n >\n | Endpoint<\"PUT\", \"/users/:id\", User, UpdateUserDto>;\n","import { Currency } from \"..\";\nimport { Event, EventTicket } from \"../event\";\nimport { User } from \"../users\";\n\nexport enum OrderStatus {\n Created = \"created\",\n Cancelled = \"cancelled\",\n Completed = \"completed\",\n Pending = \"pending\",\n Confirmed = \"confirmed\",\n Declined = \"declined\",\n Refunded = \"refunded\",\n PartiallyRefunded = \"partially_refunded\",\n Expired = \"expired\",\n}\n\nexport type OrderItem = {\n id: string;\n ticket: EventTicket;\n isUsed: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type Order = {\n id: string;\n owner: User;\n members: User[];\n status: OrderStatus;\n event: Event;\n items: OrderItem[];\n promoCode?: PromoCode;\n total: number;\n currency: Currency;\n createdAt: Date;\n};\n\nexport type PromoCode = {\n id: string;\n code: string;\n used: number;\n discount: number;\n isActive: boolean;\n expirationAt: Date;\n createdAt: Date;\n};\n","export * from \"./careers\";\nexport * from \"./event\";\nexport * from \"./health\";\nexport * from \"./organizations\";\nexport * from \"./token\";\nexport * from \"./users\";\nexport * from \"./order\";\nexport * from \"./profiles\";\n\nexport type Location = {\n name?: string;\n address: string;\n zipCode: string;\n city: string;\n country: string;\n geometry?: {\n latitude: number;\n longitude: number;\n };\n};\n\n// Currency\nexport enum Currency {\n EUR = \"EUR\",\n USD = \"USD\",\n GBP = \"GBP\",\n}\n\n// I18n\nexport enum Language {\n FR = \"fr\",\n EN = \"en\",\n}\n","import { ParamValue, Query, pathcat } from \"pathcat\";\nimport { Options, Response } from \"redaxios\";\n\nimport { APIResponse, Endpoints, ErroredAPIResponse } from \"./endpoints\";\nimport { APIRequestOptions, request } from \"./request\";\nimport { DEFAULT_API_URL } from \"../constants\";\n\nexport type PathsFor<M extends Options[\"method\"]> = Extract<\n Endpoints,\n { method: M }\n>[\"path\"];\n\nexport class TonightPassAPIError<T> extends Error {\n public readonly status: number;\n\n constructor(\n public readonly response: Response<APIResponse<T>>,\n public readonly data: ErroredAPIResponse,\n ) {\n super(data.message);\n\n this.status = response.status;\n }\n}\n\nexport interface ClientOptions {\n readonly baseURL: string;\n}\n\nexport class Client {\n private options;\n public readonly url;\n\n constructor(options: ClientOptions) {\n this.options = options;\n this.url = (path: string, params: Record<string, ParamValue>) => {\n const baseURL = this.options.baseURL || DEFAULT_API_URL;\n return pathcat(baseURL, path, params);\n };\n }\n\n setOptions(options: ClientOptions) {\n this.options = options;\n }\n\n async get<Path extends PathsFor<\"GET\">>(\n path: Path,\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"GET\" }>[\"res\"]\n >(\"GET\", path, undefined, query, options);\n }\n\n async post<Path extends Extract<Endpoints, { method: \"POST\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"POST\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"POST\" }>[\"res\"]\n >(\"POST\", path, body, query, options);\n }\n\n async put<Path extends Extract<Endpoints, { method: \"PUT\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"PUT\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"PUT\" }>[\"res\"]\n >(\"PUT\", path, body, query, options);\n }\n\n async patch<Path extends Extract<Endpoints, { method: \"PATCH\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"PATCH\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"PATCH\" }>[\"res\"]\n >(\"PATCH\", path, body, query, options);\n }\n\n async delete<Path extends Extract<Endpoints, { method: \"DELETE\" }>[\"path\"]>(\n path: Path,\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"DELETE\" }>[\"res\"]\n >(\"DELETE\", path, undefined, query, options);\n }\n\n private async requester<T>(\n method: Options[\"method\"],\n path: string,\n body: unknown,\n query: Query<string> = {},\n options: APIRequestOptions = {},\n ) {\n const url = this.url(path, query);\n\n if (body !== undefined) {\n if (method === \"GET\") {\n throw new Error(\"Cannot send a GET request with a body\");\n }\n }\n\n const response: Response<APIResponse<T>> = await request<T>(url, {\n method,\n data: body,\n ...options,\n });\n\n const result = response.data;\n\n if (!result.success) {\n throw new TonightPassAPIError<T>(response, result);\n }\n\n return result.data;\n }\n}\n","import { Client } from \"../rest\";\n\nexport function sdk<T>(builder: (client: Client) => T) {\n return builder;\n}\n","import { sdk } from \"./builder\";\n\nexport const health = sdk((client) => ({\n database: async () => client.get(\"/health/database\"),\n http: async () => client.get(\"/health/http\"),\n}));\n","import { sdk } from \"./builder\";\nimport { UpdateUserDto } from \"../rest\";\n\nexport const users = sdk((client) => ({\n getAll: async () => client.get(\"/users\"),\n get: async (id: string) => client.get(\"/users\", { id }),\n me: async () => client.get(\"/users/me\"),\n check: async (identifier: string, suggestions?: boolean) =>\n client.get(\"/users/check/:identifier\", { identifier, suggestions }),\n update: async (id: string, data: UpdateUserDto) =>\n client.put(\"/users/:id\", data, { id }),\n}));\n","import { Query } from \"pathcat\";\n\nimport { sdk } from \"./builder\";\n\nexport const careers = sdk((client) => ({\n categories: {\n getAll: async (query?: Query<\"/careers/categories\">) =>\n client.get(\"/careers/categories\", query),\n },\n employmentTypes: {\n getAll: async (query?: Query<\"/careers/employmentTypes\">) =>\n client.get(\"/careers/employmentTypes\", query),\n },\n jobs: {\n getAll: async (query?: Query<\"/careers/jobs\">) =>\n client.get(\"/careers/jobs\", query),\n get: async (id: number) => client.get(\"/careers/jobs/:id\", { id }),\n },\n offices: {\n getAll: async (query?: Query<\"/careers/offices\">) =>\n client.get(\"/careers/offices\", query),\n },\n}));\n","import { sdk } from \"./builder\";\n\nexport const profiles = sdk((client) => ({\n get: async (username: string) =>\n client.get(\"/profiles/:username\", { username }),\n}));\n","import { Client, ClientOptions } from \"./rest\";\nimport { careers } from \"./sdk/careers\";\nimport { health } from \"./sdk/health\";\nimport { profiles } from \"./sdk/profiles\";\nimport { users } from \"./sdk/users\";\n\nexport class TonightPass {\n public readonly client: Client;\n\n public readonly careers;\n public readonly health;\n public readonly profiles;\n public readonly users;\n\n constructor(options: ClientOptions) {\n this.client = new Client(options);\n\n this.careers = careers(this.client);\n this.health = health(this.client);\n this.profiles = profiles(this.client);\n this.users = users(this.client);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/constants/api.ts","../src/constants/regex.ts","../src/rest/dtos/index.ts","../src/rest/dtos/users/create-user.dto.ts","../src/rest/dtos/users/sign-in-user.dto.ts","../src/rest/dtos/users/update-user.dto.ts","../src/rest/request/request.ts","../src/utils/index.ts","../src/rest/types/event/ticket/index.ts","../src/rest/types/event/index.ts","../src/rest/types/organizations/index.ts","../src/rest/types/token/index.ts","../src/rest/types/users/index.ts","../src/rest/types/order/index.ts","../src/rest/types/index.ts","../src/rest/client.ts","../src/sdk/builder.ts","../src/sdk/health.ts","../src/sdk/users.ts","../src/sdk/careers.ts","../src/sdk/profiles.ts","../src/tonightpass.ts"],"names":["DEFAULT_API_URL","EMAIL_REGEX","PASSWORD_REGEX","NAME_REGEX","SLUG_REGEX","BCRYPT_HASH","PHONE_NUMBER_REGEX","IMAGE_URL_REGEX","CreateUserDto","SignInUserDto","Type","IsDateString","IsEmail","IsObject","IsOptional","IsPhoneNumber","IsString","IsUrl","Length","Matches","MaxLength","MinLength","ValidateNested","UpdateUserDto","__decorateClass","UpdateIdentifierDto","UpdateIdentityDto","axios","isBrowser","instance","data","request","url","options","response","error","EventTicketCategory","EventType","EventStyleType","OrganizationSocialType","OrganizationMemberRole","UserTokenType","UserRole","OrderStatus","Currency","Language","pathcat","TonightPassAPIError","Client","path","params","baseURL","query","body","method","result","sdk","builder","health","client","users","id","identifier","suggestions","careers","profiles","username","TonightPass"],"mappings":"wMAAO,IAAMA,EAAkB,8BCAxB,IAAMC,GAAc,2CAGdC,GACX,yDAGWC,EAAa,2BAGbC,GAAa,kCAGbC,GAAc,0CAEdC,GACX,6FAEWC,GACX,yGCnBF,MAAO,mBCEA,IAAMC,EAAN,KAAoB,CACzB,WACA,SACA,SACA,SACF,ECPO,IAAMC,EAAN,KAAoB,CACzB,WACA,QACF,ECHA,OAAS,QAAAC,MAAY,oBACrB,OACE,gBAAAC,EACA,WAAAC,EACA,YAAAC,EACA,cAAAC,EACA,iBAAAC,EACA,YAAAC,EACA,SAAAC,EACA,UAAAC,EACA,WAAAC,EACA,aAAAC,EACA,aAAAC,EACA,kBAAAC,MACK,kBAKA,IAAMC,EAAN,KAAoB,CAKzB,WAMA,SAMA,QACF,EAbEC,EAAA,CAJCV,EAAW,EACXD,EAAS,EACTS,EAAe,EACfZ,EAAK,IAAMe,CAAmB,GAJpBF,EAKX,0BAMAC,EAAA,CAJCV,EAAW,EACXD,EAAS,EACTS,EAAe,EACfZ,EAAK,IAAMgB,CAAiB,GAVlBH,EAWX,wBAMAC,EAAA,CAJCV,EAAW,EACXE,EAAS,EACTK,EAAU,CAAC,EACXD,EAAU,GAAG,GAhBHG,EAiBX,wBAGF,IAAME,EAAN,KAGA,CAIE,MAKA,YAK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AiB,CACf,OAAQ,MAAOA,GACbO,EAAO,IAAI,2BAA4BP,CAAK,CAChD,EACA,KAAM,CACJ,OAAQ,MAAOA,GACbO,EAAO,IAAI,gBAAiBP,CAAK,EACnC,IAAK,MAAOS,GAAeF,EAAO,IAAI,oBAAqB,CAAE,GAAAE,CAAG,CAAC,CACnE,EACA,QAAS,CACP,OAAQ,MAAOT,GACbO,EAAO,IAAI,mBAAoBP,CAAK,CACxC,CACF,GCpBO,IAAMa,EAAgBN,IAAY,CACvC,IAAK,MAAOO,GACVP,EAAO,IAAI,sBAAuB,CAAE,SAAAO,CAAS,CAAC,CAClD,GCCO,IAAMC,EAAN,KAAkB,CACP,OAEA,QACA,OACA,SACA,MAEhB,YAAYlC,EAAwB,CAClC,KAAK,OAAS,IAAIe,EAAOf,CAAO,EAEhC,KAAK,QAAU+B,EAAQ,KAAK,MAAM,EAClC,KAAK,OAASN,EAAO,KAAK,MAAM,EAChC,KAAK,SAAWO,EAAS,KAAK,MAAM,EACpC,KAAK,MAAQL,EAAM,KAAK,MAAM,CAChC,CACF","sourcesContent":["export const DEFAULT_API_URL = \"https://api.tonightpass.com\";\n","export const EMAIL_REGEX = /^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$/;\n\n// checks if a password has at least one uppercase letter and a number or special character\nexport const PASSWORD_REGEX =\n /((?=.*\\d)|(?=.*\\W+))(?![.\\n])(?=.*[A-Z])(?=.*[a-z]).*$/;\n\n// checks if a string has only letters, numbers, spaces, apostrophes, dots and dashes\nexport const NAME_REGEX = /(^[\\p{L}\\d'\\\\.\\s\\\\-]*$)/u;\n\n// checks if a string is a valid slug, useful for usernames\nexport const SLUG_REGEX = /^[a-z\\d]+(?:(\\.|-|_)[a-z\\d]+)*$/;\n\n// validates if passwords are valid bcrypt hashes\nexport const BCRYPT_HASH = /\\$2[abxy]?\\$\\d{1,2}\\$[A-Za-z\\d\\\\./]{53}/;\n\nexport const PHONE_NUMBER_REGEX =\n /^\\s*(?:\\+?(\\d{1,3}))?([-. (]*(\\d{3})[-. )]*)?((\\d{3})[-. ]*(\\d{2,4})(?:[-.x ]*(\\d+))?)\\s*$/;\n\nexport const IMAGE_URL_REGEX =\n /(((http:\\/\\/www)|(http:\\/\\/)|(www))[-a-zA-Z0-9@:%_\\\\+.~#?&//=]+)\\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)/i;\n","import \"reflect-metadata\";\n\nexport * from \"./users\";\n","import { UserIdentifier, UserIdentityGender } from \"../../types\";\n\nexport class CreateUserDto {\n identifier: UserIdentifier;\n password: string;\n identity: CreateUserIdentituDto;\n addresses: Location[];\n}\n\nclass CreateUserIdentituDto {\n firstName: string;\n lastName: string;\n gender: UserIdentityGender;\n profilePictureUrl?: string;\n birthDate: Date;\n}\n","export class SignInUserDto {\n identifier: string;\n password: string;\n}\n","import { Type } from \"class-transformer\";\nimport {\n IsDateString,\n IsEmail,\n IsObject,\n IsOptional,\n IsPhoneNumber,\n IsString,\n IsUrl,\n Length,\n Matches,\n MaxLength,\n MinLength,\n ValidateNested,\n} from \"class-validator\";\n\nimport { NAME_REGEX } from \"../../../constants/regex\";\nimport { UserIdentifier, UserIdentity } from \"../../types\";\n\nexport class UpdateUserDto {\n @IsOptional()\n @IsObject()\n @ValidateNested()\n @Type(() => UpdateIdentifierDto)\n identifier?: UpdateIdentifierDto;\n\n @IsOptional()\n @IsObject()\n @ValidateNested()\n @Type(() => UpdateIdentityDto)\n identity?: UpdateIdentityDto;\n\n @IsOptional()\n @IsString()\n @MinLength(6)\n @MaxLength(130)\n password?: string;\n}\n\nclass UpdateIdentifierDto\n implements\n Partial<Pick<UserIdentifier, \"email\" | \"phoneNumber\" | \"username\">>\n{\n @IsOptional()\n @IsString()\n @IsEmail()\n email?: string;\n\n @IsOptional()\n @IsString()\n @IsPhoneNumber()\n phoneNumber?: string;\n\n @IsOptional()\n @IsString()\n @MinLength(3)\n username?: string;\n}\n\nclass UpdateIdentityDto\n implements\n Partial<\n Pick<\n UserIdentity,\n | \"firstName\"\n | \"lastName\"\n | \"displayName\"\n | \"description\"\n | \"profilePictureUrl\"\n | \"bannerUrl\"\n | \"gender\"\n | \"birthDate\"\n >\n >\n{\n @IsOptional()\n @IsString()\n @Length(2, 50)\n @Matches(NAME_REGEX, {\n message: \"First name must be composed of letters only\",\n })\n firstName?: string;\n\n @IsOptional()\n @IsString()\n @Length(2, 50)\n @Matches(NAME_REGEX, {\n message: \"Last name must be composed of letters only\",\n })\n lastName?: string;\n\n @IsOptional()\n @IsString()\n @Length(1, 32)\n displayName?: string;\n\n @IsOptional()\n @IsString()\n @Length(15, 500)\n description?: string;\n\n @IsOptional()\n @IsUrl()\n profilePictureUrl?: string | undefined;\n\n @IsOptional()\n @IsUrl()\n bannerUrl?: string | undefined;\n\n @IsOptional()\n gender?: string;\n\n @IsOptional()\n @IsDateString()\n birthDate?: Date;\n}\n","import axios, { Options, Response } from \"redaxios\";\n\nimport { isBrowser } from \"../../utils\";\nimport { APIResponse, ErroredAPIResponse } from \"../endpoints\";\n\nconst instance = axios.create({\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n ...(!isBrowser && { \"User-Agent\": \"tonightpass-api-client\" }),\n },\n responseType: \"json\",\n transformRequest: [\n function (data) {\n return JSON.stringify(data);\n },\n ],\n withCredentials: isBrowser,\n});\n\nexport interface APIRequestOptions extends Options {}\n\nexport const request = async <T>(url: string, options?: Options) => {\n const response = instance<APIResponse<T>>(url, { ...options })\n .then((response) => response)\n .catch((error: Response<ErroredAPIResponse>) => {\n throw error.data;\n });\n\n return response;\n};\n","export const isBrowser = typeof window !== \"undefined\";\n","import { Currency } from \"../..\";\n\nexport type EventTicket = {\n id: string;\n name: string;\n description?: string;\n price: number;\n displayPrice: number;\n quantity: number;\n type: EventTicketType;\n category: EventTicketCategory;\n currency: Currency;\n vatRate: number;\n externalId?: string;\n isVisible: boolean;\n isFeesIncluded: boolean;\n startAt: Date;\n endAt: Date;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type EventTicketType = \"e-ticket\" | \"other\";\n\nexport enum EventTicketCategory {\n ENTRY = \"entry\",\n PACKAGE = \"package\",\n MEAL = \"meal\",\n DRINK = \"drink\",\n PARKING = \"parking\",\n ACCOMMODATION = \"accommodation\",\n CAMPING = \"camping\",\n LOCKER = \"locker\",\n SHUTTLE = \"shuttle\",\n OTHER = \"other\",\n}\n","import { EventTicket } from \"./ticket\";\nimport { Location } from \"..\";\nimport { Organization } from \"../organizations\";\n\nexport * from \"./ticket\";\n\nexport type Event = {\n title: string;\n description: string;\n slug: string;\n organization: Organization;\n type: EventType;\n public: boolean;\n flyers: string[];\n trailers: string[];\n location: Location;\n tickets: EventTicket[];\n styles: EventStyle[];\n startAt: Date;\n endAt: Date;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport enum EventType {\n Clubbing = \"clubbing\",\n Concert = \"concert\",\n Afterwork = \"afterwork\",\n DancingLunch = \"dancing_lunch\",\n Diner = \"diner\",\n Garden = \"garden\",\n AfterBeach = \"after_beach\",\n Festival = \"festival\",\n Spectacle = \"spectacle\",\n Cruise = \"cruise\",\n OutsideAnimation = \"outside_animation\",\n Sport = \"sport\",\n Match = \"match\",\n Seminar = \"seminar\",\n Conference = \"conference\",\n WellnessDay = \"wellness_day\",\n Workshop = \"workshop\",\n TradeFair = \"trade_fair\",\n ConsumerShow = \"consumer_show\",\n Membership = \"membership\",\n}\n\nexport type EventStyle = {\n type: EventStyleType;\n emoji: string;\n name: string;\n};\n\nexport enum EventStyleType {\n Music = \"music\",\n Dress = \"dress\",\n Sport = \"sport\",\n Food = \"food\",\n Art = \"art\",\n}\n","import { Location, Profile, ProfileMetadata } from \"..\";\nimport { Event } from \"../event\";\nimport { EventTicket } from \"../event/ticket\";\nimport { User } from \"../users\";\n\nexport type Organization = {\n id: string;\n slug: string;\n identity: OrganizationIdentity;\n members: OrganizationMember[];\n location?: Location;\n events: Event[];\n savedTickets: EventTicket[];\n verified: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type OrganizationIdentity = Profile & {\n socialLinks: OrganizationSocialLink[];\n\n metadata: ProfileMetadata & {\n eventsCount: number;\n viewsCount: number;\n membersCount: number;\n };\n};\n\nexport type OrganizationSocialLink = {\n type: OrganizationSocialType;\n url: string;\n};\n\nexport enum OrganizationSocialType {\n Facebook = \"facebook\",\n Twitter = \"twitter\",\n Instagram = \"instagram\",\n Linkedin = \"linkedin\",\n Youtube = \"youtube\",\n Website = \"website\",\n}\n\nexport type OrganizationMember = {\n user: User;\n role: OrganizationMemberRole;\n createdAt: Date;\n};\n\nexport enum OrganizationMemberRole {\n EMPLOYEE = 0,\n MANAGER = 1,\n ADMINISTRATOR = 2,\n OWNER = 3,\n}\n","export type UserToken = {\n id: string;\n type: UserTokenType;\n value: string;\n createdAt: Date;\n expiresAt: Date;\n};\n\nexport enum UserTokenType {\n Authentication = \"authentication\",\n OrganizationInvite = \"organization_invite\",\n PasswordRecovery = \"password_recovery\",\n EmailValidation = \"email_validation\",\n PhoneValidation = \"phone_validation\",\n}\n","import { Currency, Language, Location, Profile, ProfileMetadata } from \"..\";\nimport { UpdateUserDto } from \"../../dtos\";\nimport { Endpoint } from \"../../endpoints\";\n\nexport type User = {\n id: string;\n identifier: UserIdentifier;\n password: string;\n identity: UserIdentity;\n role: UserRole;\n addresses: Location[];\n preferences: UserPreferences;\n connections: UserConnection[];\n verified: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type UserIdentifier = {\n email?: string;\n phoneNumber?: string;\n username: string;\n\n [key: string]: string | undefined;\n};\n\nexport type UserIdentity = Profile & {\n firstName: string;\n lastName: string;\n fullName: string;\n gender: UserIdentityGender;\n birthDate: Date;\n\n metadata: ProfileMetadata & {\n followingCount: number;\n hasPassPlus: boolean;\n idValid: boolean;\n };\n};\n\nexport enum UserRole {\n USER = 0,\n DEVELOPER = 8,\n ADMINISTRATOR = 10,\n}\n\nexport type UserIdentityGender =\n | \"male\"\n | \"female\"\n | \"non-binary\"\n | \"gender-fluid\"\n | \"neutral\"\n | \"other\"\n | string;\n\nexport type UserPreferences = {\n language: Language;\n currency: Currency;\n notifications: {\n email: {\n newsletter: boolean;\n message: boolean;\n };\n push: {\n message: boolean;\n };\n };\n};\n\nexport type UserConnection = {\n ip: string;\n os: UserConnectionOS;\n device: UserConnectionDevice;\n client: UserConnectionClient;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type UserConnectionOS = {\n name: string;\n version: string;\n};\n\nexport type UserConnectionDevice = {\n type: string;\n brand: string;\n};\n\nexport type UserConnectionClient = {\n name: string;\n version: string;\n};\n\nexport type UserEndpoints =\n | Endpoint<\"GET\", \"/users\", User[]>\n | Endpoint<\"GET\", \"/users/:id\", User, { id: string }>\n | Endpoint<\"GET\", \"/users/me\", User>\n | Endpoint<\n \"GET\",\n \"/users/check/:identifier\",\n {\n exists: boolean;\n identifier: UserIdentifier;\n suggestions?: string[];\n },\n { identifier: boolean; suggestions?: boolean }\n >\n | Endpoint<\"PUT\", \"/users/:id\", User, UpdateUserDto>;\n","import { Currency } from \"..\";\nimport { Event, EventTicket } from \"../event\";\nimport { User } from \"../users\";\n\nexport enum OrderStatus {\n Created = \"created\",\n Cancelled = \"cancelled\",\n Completed = \"completed\",\n Pending = \"pending\",\n Confirmed = \"confirmed\",\n Declined = \"declined\",\n Refunded = \"refunded\",\n PartiallyRefunded = \"partially_refunded\",\n Expired = \"expired\",\n}\n\nexport type OrderItem = {\n id: string;\n ticket: EventTicket;\n isUsed: boolean;\n updatedAt: Date;\n createdAt: Date;\n};\n\nexport type Order = {\n id: string;\n owner: User;\n members: User[];\n status: OrderStatus;\n event: Event;\n items: OrderItem[];\n promoCode?: PromoCode;\n total: number;\n currency: Currency;\n createdAt: Date;\n};\n\nexport type PromoCode = {\n id: string;\n code: string;\n used: number;\n discount: number;\n isActive: boolean;\n expirationAt: Date;\n createdAt: Date;\n};\n","export * from \"./auth\";\nexport * from \"./careers\";\nexport * from \"./event\";\nexport * from \"./health\";\nexport * from \"./organizations\";\nexport * from \"./token\";\nexport * from \"./users\";\nexport * from \"./order\";\nexport * from \"./profiles\";\n\nexport type Location = {\n name?: string;\n address: string;\n zipCode: string;\n city: string;\n country: string;\n geometry?: {\n latitude: number;\n longitude: number;\n };\n};\n\n// Currency\nexport enum Currency {\n EUR = \"EUR\",\n USD = \"USD\",\n GBP = \"GBP\",\n}\n\n// I18n\nexport enum Language {\n FR = \"fr\",\n EN = \"en\",\n}\n","import { ParamValue, Query, pathcat } from \"pathcat\";\nimport { Options, Response } from \"redaxios\";\n\nimport { APIResponse, Endpoints, ErroredAPIResponse } from \"./endpoints\";\nimport { APIRequestOptions, request } from \"./request\";\nimport { DEFAULT_API_URL } from \"../constants\";\n\nexport type PathsFor<M extends Options[\"method\"]> = Extract<\n Endpoints,\n { method: M }\n>[\"path\"];\n\nexport class TonightPassAPIError<T> extends Error {\n public readonly status: number;\n\n constructor(\n public readonly response: Response<APIResponse<T>>,\n public readonly data: ErroredAPIResponse,\n ) {\n super(data.message);\n\n this.status = response.status;\n }\n}\n\nexport interface ClientOptions {\n readonly baseURL: string;\n}\n\nexport class Client {\n private options;\n public readonly url;\n\n constructor(options: ClientOptions) {\n this.options = options;\n this.url = (path: string, params: Record<string, ParamValue>) => {\n const baseURL = this.options.baseURL || DEFAULT_API_URL;\n return pathcat(baseURL, path, params);\n };\n }\n\n setOptions(options: ClientOptions) {\n this.options = options;\n }\n\n async get<Path extends PathsFor<\"GET\">>(\n path: Path,\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"GET\" }>[\"res\"]\n >(\"GET\", path, undefined, query, options);\n }\n\n async post<Path extends Extract<Endpoints, { method: \"POST\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"POST\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"POST\" }>[\"res\"]\n >(\"POST\", path, body, query, options);\n }\n\n async put<Path extends Extract<Endpoints, { method: \"PUT\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"PUT\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"PUT\" }>[\"res\"]\n >(\"PUT\", path, body, query, options);\n }\n\n async patch<Path extends Extract<Endpoints, { method: \"PATCH\" }>[\"path\"]>(\n path: Path,\n body: Extract<Endpoints, { path: Path; method: \"PATCH\" }>[\"body\"],\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"PATCH\" }>[\"res\"]\n >(\"PATCH\", path, body, query, options);\n }\n\n async delete<Path extends Extract<Endpoints, { method: \"DELETE\" }>[\"path\"]>(\n path: Path,\n query?: Query<Path>,\n options?: APIRequestOptions,\n ) {\n return this.requester<\n Extract<Endpoints, { path: Path; method: \"DELETE\" }>[\"res\"]\n >(\"DELETE\", path, undefined, query, options);\n }\n\n private async requester<T>(\n method: Options[\"method\"],\n path: string,\n body: unknown,\n query: Query<string> = {},\n options: APIRequestOptions = {},\n ) {\n const url = this.url(path, query);\n\n if (body !== undefined) {\n if (method === \"GET\") {\n throw new Error(\"Cannot send a GET request with a body\");\n }\n }\n\n const response: Response<APIResponse<T>> = await request<T>(url, {\n method,\n data: body,\n ...options,\n });\n\n const result = response.data;\n\n if (!result.success) {\n throw new TonightPassAPIError<T>(response, result);\n }\n\n return result.data;\n }\n}\n","import { Client } from \"../rest\";\n\nexport function sdk<T>(builder: (client: Client) => T) {\n return builder;\n}\n","import { sdk } from \"./builder\";\n\nexport const health = sdk((client) => ({\n database: async () => client.get(\"/health/database\"),\n http: async () => client.get(\"/health/http\"),\n}));\n","import { sdk } from \"./builder\";\nimport { UpdateUserDto } from \"../rest\";\n\nexport const users = sdk((client) => ({\n getAll: async () => client.get(\"/users\"),\n get: async (id: string) => client.get(\"/users\", { id }),\n me: async () => client.get(\"/users/me\"),\n check: async (identifier: string, suggestions?: boolean) =>\n client.get(\"/users/check/:identifier\", { identifier, suggestions }),\n update: async (id: string, data: UpdateUserDto) =>\n client.put(\"/users/:id\", data, { id }),\n}));\n","import { Query } from \"pathcat\";\n\nimport { sdk } from \"./builder\";\n\nexport const careers = sdk((client) => ({\n categories: {\n getAll: async (query?: Query<\"/careers/categories\">) =>\n client.get(\"/careers/categories\", query),\n },\n employmentTypes: {\n getAll: async (query?: Query<\"/careers/employmentTypes\">) =>\n client.get(\"/careers/employmentTypes\", query),\n },\n jobs: {\n getAll: async (query?: Query<\"/careers/jobs\">) =>\n client.get(\"/careers/jobs\", query),\n get: async (id: number) => client.get(\"/careers/jobs/:id\", { id }),\n },\n offices: {\n getAll: async (query?: Query<\"/careers/offices\">) =>\n client.get(\"/careers/offices\", query),\n },\n}));\n","import { sdk } from \"./builder\";\n\nexport const profiles = sdk((client) => ({\n get: async (username: string) =>\n client.get(\"/profiles/:username\", { username }),\n}));\n","import { Client, ClientOptions } from \"./rest\";\nimport { careers } from \"./sdk/careers\";\nimport { health } from \"./sdk/health\";\nimport { profiles } from \"./sdk/profiles\";\nimport { users } from \"./sdk/users\";\n\nexport class TonightPass {\n public readonly client: Client;\n\n public readonly careers;\n public readonly health;\n public readonly profiles;\n public readonly users;\n\n constructor(options: ClientOptions) {\n this.client = new Client(options);\n\n this.careers = careers(this.client);\n this.health = health(this.client);\n this.profiles = profiles(this.client);\n this.users = users(this.client);\n }\n}\n"]}
|
package/package.json
CHANGED
package/src/rest/endpoints.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Options } from "redaxios";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
AuthEndpoints,
|
|
4
5
|
CareersEndpoints,
|
|
5
6
|
HealthEndpoints,
|
|
6
7
|
ProfileEndpoints,
|
|
@@ -35,6 +36,7 @@ export type Endpoint<
|
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
export type Endpoints =
|
|
39
|
+
| AuthEndpoints
|
|
38
40
|
| CareersEndpoints
|
|
39
41
|
| HealthEndpoints
|
|
40
42
|
| ProfileEndpoints
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CreateUserDto, SignInUserDto } from "../../dtos";
|
|
2
|
+
import { Endpoint } from "../../endpoints";
|
|
3
|
+
import { User } from "../users";
|
|
4
|
+
|
|
5
|
+
export type AuthEndpoints =
|
|
6
|
+
| Endpoint<"POST", "/auth/sign-up", User, CreateUserDto>
|
|
7
|
+
| Endpoint<"POST", "/auth/sign-in", User, SignInUserDto>
|
|
8
|
+
| Endpoint<"POST", "/auth/sign-out", void>
|
|
9
|
+
| Endpoint<"POST", "/auth/refresh-token", User>;
|
package/src/rest/types/index.ts
CHANGED
package/src/sdk/auth.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { sdk } from "./builder";
|
|
2
|
+
import { CreateUserDto, SignInUserDto } from "../rest";
|
|
3
|
+
|
|
4
|
+
export const auth = sdk((client) => ({
|
|
5
|
+
signIn: async (data: SignInUserDto) => client.post("/auth/sign-in", data),
|
|
6
|
+
signUp: async (data: CreateUserDto) => client.post("/auth/sign-up", data),
|
|
7
|
+
signOut: async () => client.post("/auth/sign-out", undefined),
|
|
8
|
+
refreshToken: async () => client.post("/auth/refresh-token", undefined),
|
|
9
|
+
}));
|