tonightpass 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +21 -17
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +615 -0
- package/dist/index.d.ts +258 -52
- package/dist/index.js +44 -471
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +15 -6
- package/src/constants/api.ts +1 -0
- package/src/constants/index.ts +2 -0
- package/src/constants/regex.ts +20 -0
- package/src/index.ts +5 -3
- package/src/rest/client.ts +154 -0
- package/src/rest/dtos/index.ts +3 -0
- package/src/rest/dtos/users/create-user.dto.ts +16 -0
- package/src/rest/dtos/users/index.ts +3 -0
- package/src/rest/dtos/users/sign-in-user.dto.ts +4 -0
- package/src/rest/dtos/users/update-user.dto.ts +116 -0
- package/src/rest/endpoints.ts +41 -0
- package/src/rest/index.ts +5 -0
- package/src/rest/request/index.ts +1 -0
- package/src/rest/request/request.ts +30 -0
- package/src/rest/types/api/index.ts +0 -0
- package/src/rest/types/careers/index.ts +87 -0
- package/src/rest/types/event/index.ts +60 -0
- package/src/rest/types/event/ticket/index.ts +36 -0
- package/src/rest/types/health/index.ts +17 -0
- package/src/rest/types/index.ts +33 -0
- package/src/rest/types/order/index.ts +46 -0
- package/src/rest/types/organizations/index.ts +54 -0
- package/src/rest/types/profiles/index.ts +30 -0
- package/src/rest/types/token/index.ts +15 -0
- package/src/rest/types/users/index.ts +104 -0
- package/src/sdk/builder.ts +5 -0
- package/src/sdk/careers.ts +22 -0
- package/src/sdk/health.ts +6 -0
- package/src/sdk/index.ts +3 -0
- package/src/sdk/profiles.ts +6 -0
- package/src/sdk/users.ts +12 -0
- package/src/tonightpass.ts +19 -0
- package/src/utils/index.ts +1 -0
- package/tests/careers/index.ts +28 -0
- package/tests/index.ts +57 -0
- package/tsconfig.json +3 -1
- package/tsup.config.ts +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as redaxios from 'redaxios';
|
|
2
|
+
import { Options, Response } from 'redaxios';
|
|
3
3
|
import { ParamValue } from 'pathcat';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
declare const DEFAULT_API_URL = "https://api.tonightpass.com";
|
|
5
6
|
|
|
6
7
|
declare const EMAIL_REGEX: RegExp;
|
|
7
8
|
declare const PASSWORD_REGEX: RegExp;
|
|
@@ -11,6 +12,85 @@ declare const BCRYPT_HASH: RegExp;
|
|
|
11
12
|
declare const PHONE_NUMBER_REGEX: RegExp;
|
|
12
13
|
declare const IMAGE_URL_REGEX: RegExp;
|
|
13
14
|
|
|
15
|
+
type SuccessfulAPIResponse<T> = {
|
|
16
|
+
success: true;
|
|
17
|
+
data: T;
|
|
18
|
+
};
|
|
19
|
+
type ErroredAPIResponse = {
|
|
20
|
+
success: false;
|
|
21
|
+
message: string;
|
|
22
|
+
errors?: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
type APIResponse<T> = SuccessfulAPIResponse<T> | ErroredAPIResponse;
|
|
27
|
+
type Endpoint<M extends Options["method"], Path extends string, Res, Body = undefined> = {
|
|
28
|
+
method: M;
|
|
29
|
+
path: Path;
|
|
30
|
+
res: Res;
|
|
31
|
+
body: Body;
|
|
32
|
+
};
|
|
33
|
+
type Endpoints = CareersEndpoints | HealthEndpoints | ProfileEndpoints | UserEndpoints;
|
|
34
|
+
|
|
35
|
+
type CareersOffice = {
|
|
36
|
+
id: number | null;
|
|
37
|
+
isDefault: boolean | null;
|
|
38
|
+
name: string | null;
|
|
39
|
+
city: string | null;
|
|
40
|
+
countryIso: string | null;
|
|
41
|
+
};
|
|
42
|
+
type CareersJob = {
|
|
43
|
+
id: number;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
lastUpdatedAt: string;
|
|
46
|
+
externalId: null | string;
|
|
47
|
+
title: string;
|
|
48
|
+
status: "ALL" | "ONLINE" | "ARCHIVED";
|
|
49
|
+
remote: boolean;
|
|
50
|
+
office: CareersOffice;
|
|
51
|
+
workplaceType: string;
|
|
52
|
+
remoteType?: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
categoryId?: number;
|
|
55
|
+
employmentTypeId?: number;
|
|
56
|
+
};
|
|
57
|
+
type CareersCategory = {
|
|
58
|
+
slug: string;
|
|
59
|
+
name: string;
|
|
60
|
+
subCategories?: (CareersCategory & {
|
|
61
|
+
id: number;
|
|
62
|
+
})[];
|
|
63
|
+
};
|
|
64
|
+
type CareersEmploymentType = {
|
|
65
|
+
id: number;
|
|
66
|
+
name: string;
|
|
67
|
+
slug: string;
|
|
68
|
+
};
|
|
69
|
+
type CareersEndpoints = Endpoint<"GET", "/careers/categories", CareersCategory[], {
|
|
70
|
+
language?: string;
|
|
71
|
+
}> | Endpoint<"GET", "/careers/employmentTypes", CareersEmploymentType[], {
|
|
72
|
+
language?: string;
|
|
73
|
+
}> | Endpoint<"GET", "/careers/jobs", CareersJob[], {
|
|
74
|
+
page?: number;
|
|
75
|
+
pageSize?: number;
|
|
76
|
+
createdAtGte: string;
|
|
77
|
+
createdAtLt?: string;
|
|
78
|
+
updatedAtGte?: string;
|
|
79
|
+
updatedAtLt?: string;
|
|
80
|
+
status?: "ALL" | "ONLINE" | "ARCHIVED";
|
|
81
|
+
content?: boolean;
|
|
82
|
+
titleLike?: string;
|
|
83
|
+
countryCode?: string;
|
|
84
|
+
externalId?: string;
|
|
85
|
+
}> | Endpoint<"GET", "/careers/jobs/:id", CareersJob, {
|
|
86
|
+
id: number;
|
|
87
|
+
}> | Endpoint<"GET", "/careers/offices", CareersOffice[], {
|
|
88
|
+
page?: number;
|
|
89
|
+
pageSize?: number;
|
|
90
|
+
countryCode?: string;
|
|
91
|
+
cityNameLike?: string;
|
|
92
|
+
}>;
|
|
93
|
+
|
|
14
94
|
type EventTicket = {
|
|
15
95
|
id: string;
|
|
16
96
|
name: string;
|
|
@@ -114,6 +194,11 @@ type UserConnectionClient = {
|
|
|
114
194
|
name: string;
|
|
115
195
|
version: string;
|
|
116
196
|
};
|
|
197
|
+
type UserEndpoints = Endpoint<"GET", "/users", User[]> | Endpoint<"GET", "/users/:id", User, {
|
|
198
|
+
id: string;
|
|
199
|
+
}> | Endpoint<"GET", "/users/me", User> | Endpoint<"GET", "/check/:identifier", UserIdentifier, {
|
|
200
|
+
identifier: string;
|
|
201
|
+
}> | Endpoint<"PUT", "/users/:id", User, UpdateUserDto>;
|
|
117
202
|
|
|
118
203
|
type Organization = {
|
|
119
204
|
id: string;
|
|
@@ -211,6 +296,19 @@ declare enum EventStyleType {
|
|
|
211
296
|
Art = "art"
|
|
212
297
|
}
|
|
213
298
|
|
|
299
|
+
type Health<Key extends string> = {
|
|
300
|
+
status: string;
|
|
301
|
+
details: {
|
|
302
|
+
[key in Key]: {
|
|
303
|
+
status: string;
|
|
304
|
+
details: {
|
|
305
|
+
status: string;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
type HealthEndpoints = Endpoint<"GET", "/health/database", Health<"database">> | Endpoint<"GET", "/health/http", Health<"app">>;
|
|
311
|
+
|
|
214
312
|
type UserToken = {
|
|
215
313
|
id: string;
|
|
216
314
|
type: UserTokenType;
|
|
@@ -281,20 +379,7 @@ interface ProfileMetadata {
|
|
|
281
379
|
hasBlocked: boolean;
|
|
282
380
|
canDM: boolean;
|
|
283
381
|
}
|
|
284
|
-
|
|
285
|
-
type APIResponse<TData = any> = ({
|
|
286
|
-
success: true;
|
|
287
|
-
data: TData;
|
|
288
|
-
} | APIError) & {
|
|
289
|
-
statusCode: number;
|
|
290
|
-
};
|
|
291
|
-
type APIError = {
|
|
292
|
-
success: false;
|
|
293
|
-
message: string;
|
|
294
|
-
errors?: {
|
|
295
|
-
[key: string]: string;
|
|
296
|
-
};
|
|
297
|
-
};
|
|
382
|
+
type ProfileEndpoints = Endpoint<"GET", "/profiles/:username", UserIdentity>;
|
|
298
383
|
|
|
299
384
|
type Location$1 = {
|
|
300
385
|
name?: string;
|
|
@@ -357,53 +442,174 @@ declare class UpdateIdentityDto implements Partial<Pick<UserIdentity, "firstName
|
|
|
357
442
|
birthDate?: Date;
|
|
358
443
|
}
|
|
359
444
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
type BaseRequest = <TData>(url: string, options?: ApiRequestConfig) => Promise<APIResponse<TData>>;
|
|
364
|
-
type RequestResponse = {
|
|
365
|
-
get: BaseRequest;
|
|
366
|
-
post: BaseRequest;
|
|
367
|
-
put: BaseRequest;
|
|
368
|
-
delete: BaseRequest;
|
|
369
|
-
};
|
|
370
|
-
declare const requester: (auth?: boolean) => RequestResponse;
|
|
445
|
+
interface APIRequestOptions extends Options {
|
|
446
|
+
}
|
|
447
|
+
declare const request: <T>(url: string, options?: Options) => Promise<redaxios.Response<APIResponse<T>>>;
|
|
371
448
|
|
|
449
|
+
type ExtractRouteParams<T extends string> = string extends T ? Record<string, string | number | undefined> : T extends `${string}:${infer Param}/${infer Rest}` ? {
|
|
450
|
+
[k in Param | keyof ExtractRouteParams<Rest>]: string | number;
|
|
451
|
+
} : T extends `${string}:${infer Param}` ? {
|
|
452
|
+
[k in Param]: string | number;
|
|
453
|
+
} : object;
|
|
454
|
+
type ExtractEndpoint<Method extends string, Path extends string> = Extract<Endpoints, {
|
|
455
|
+
path: Path;
|
|
456
|
+
method: Method;
|
|
457
|
+
}>;
|
|
458
|
+
type PathsFor<M extends Options["method"]> = Extract<Endpoints, {
|
|
459
|
+
method: M;
|
|
460
|
+
}>["path"];
|
|
461
|
+
type Query<Path extends string> = ExtractRouteParams<Path> & Record<string, string | number | undefined>;
|
|
462
|
+
declare class TonightPassAPIError<T> extends Error {
|
|
463
|
+
readonly response: Response<APIResponse<T>>;
|
|
464
|
+
readonly data: ErroredAPIResponse;
|
|
465
|
+
readonly status: number;
|
|
466
|
+
constructor(response: Response<APIResponse<T>>, data: ErroredAPIResponse);
|
|
467
|
+
}
|
|
372
468
|
interface ClientOptions {
|
|
373
|
-
readonly
|
|
469
|
+
readonly baseURL: string;
|
|
374
470
|
}
|
|
375
471
|
declare class Client {
|
|
376
|
-
private
|
|
472
|
+
private options;
|
|
377
473
|
readonly url: (path: string, params: Record<string, ParamValue>) => string;
|
|
378
|
-
private request;
|
|
379
474
|
constructor(options: ClientOptions);
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
475
|
+
setOptions(options: ClientOptions): void;
|
|
476
|
+
get<Path extends PathsFor<"GET">>(path: Path, query?: Query<Path>, options?: APIRequestOptions): Promise<(Extract<Endpoint<"GET", "/careers/categories", CareersCategory[], {
|
|
477
|
+
language?: string | undefined;
|
|
478
|
+
}>, {
|
|
479
|
+
path: Path;
|
|
480
|
+
method: "GET";
|
|
481
|
+
}> | Extract<Endpoint<"GET", "/careers/employmentTypes", CareersEmploymentType[], {
|
|
482
|
+
language?: string | undefined;
|
|
483
|
+
}>, {
|
|
484
|
+
path: Path;
|
|
485
|
+
method: "GET";
|
|
486
|
+
}> | Extract<Endpoint<"GET", "/careers/jobs", CareersJob[], {
|
|
487
|
+
page?: number | undefined;
|
|
488
|
+
pageSize?: number | undefined;
|
|
489
|
+
createdAtGte: string;
|
|
490
|
+
createdAtLt?: string | undefined;
|
|
491
|
+
updatedAtGte?: string | undefined;
|
|
492
|
+
updatedAtLt?: string | undefined;
|
|
493
|
+
status?: "ALL" | "ONLINE" | "ARCHIVED" | undefined;
|
|
494
|
+
content?: boolean | undefined;
|
|
495
|
+
titleLike?: string | undefined;
|
|
496
|
+
countryCode?: string | undefined;
|
|
497
|
+
externalId?: string | undefined;
|
|
498
|
+
}>, {
|
|
499
|
+
path: Path;
|
|
500
|
+
method: "GET";
|
|
501
|
+
}> | Extract<Endpoint<"GET", "/careers/jobs/:id", CareersJob, {
|
|
502
|
+
id: number;
|
|
503
|
+
}>, {
|
|
504
|
+
path: Path;
|
|
505
|
+
method: "GET";
|
|
506
|
+
}> | Extract<Endpoint<"GET", "/careers/offices", CareersOffice[], {
|
|
507
|
+
page?: number | undefined;
|
|
508
|
+
pageSize?: number | undefined;
|
|
509
|
+
countryCode?: string | undefined;
|
|
510
|
+
cityNameLike?: string | undefined;
|
|
511
|
+
}>, {
|
|
512
|
+
path: Path;
|
|
513
|
+
method: "GET";
|
|
514
|
+
}> | Extract<Endpoint<"GET", "/health/database", Health<"database">>, {
|
|
515
|
+
path: Path;
|
|
516
|
+
method: "GET";
|
|
517
|
+
}> | Extract<Endpoint<"GET", "/health/http", Health<"app">>, {
|
|
518
|
+
path: Path;
|
|
519
|
+
method: "GET";
|
|
520
|
+
}> | Extract<ProfileEndpoints, {
|
|
521
|
+
path: Path;
|
|
522
|
+
method: "GET";
|
|
523
|
+
}> | Extract<Endpoint<"GET", "/users", User[]>, {
|
|
524
|
+
path: Path;
|
|
525
|
+
method: "GET";
|
|
526
|
+
}> | Extract<Endpoint<"GET", "/users/:id", User, {
|
|
527
|
+
id: string;
|
|
528
|
+
}>, {
|
|
529
|
+
path: Path;
|
|
530
|
+
method: "GET";
|
|
531
|
+
}> | Extract<Endpoint<"GET", "/users/me", User>, {
|
|
532
|
+
path: Path;
|
|
533
|
+
method: "GET";
|
|
534
|
+
}> | Extract<Endpoint<"GET", "/check/:identifier", UserIdentifier, {
|
|
535
|
+
identifier: string;
|
|
536
|
+
}>, {
|
|
537
|
+
path: Path;
|
|
538
|
+
method: "GET";
|
|
539
|
+
}>)["res"]>;
|
|
540
|
+
post<Path extends Extract<Endpoints, {
|
|
541
|
+
method: "POST";
|
|
542
|
+
}>["path"]>(path: Path, body: Extract<Endpoints, {
|
|
543
|
+
path: Path;
|
|
544
|
+
method: "POST";
|
|
545
|
+
}>["body"], query?: Query<Path>, options?: APIRequestOptions): Promise<never>;
|
|
546
|
+
put<Path extends Extract<Endpoints, {
|
|
547
|
+
method: "PUT";
|
|
548
|
+
}>["path"]>(path: Path, body: Extract<Endpoints, {
|
|
549
|
+
path: Path;
|
|
550
|
+
method: "PUT";
|
|
551
|
+
}>["body"], query?: Query<Path>, options?: APIRequestOptions): Promise<Extract<Endpoint<"PUT", "/users/:id", User, UpdateUserDto>, {
|
|
552
|
+
path: Path;
|
|
553
|
+
method: "PUT";
|
|
554
|
+
}>["res"]>;
|
|
555
|
+
patch<Path extends Extract<Endpoints, {
|
|
556
|
+
method: "PATCH";
|
|
557
|
+
}>["path"]>(path: Path, body: Extract<Endpoints, {
|
|
558
|
+
path: Path;
|
|
559
|
+
method: "PATCH";
|
|
560
|
+
}>["body"], query?: Query<Path>, options?: APIRequestOptions): Promise<never>;
|
|
561
|
+
delete<Path extends Extract<Endpoints, {
|
|
562
|
+
method: "DELETE";
|
|
563
|
+
}>["path"]>(path: Path, query?: Query<Path>, options?: APIRequestOptions): Promise<never>;
|
|
564
|
+
private requester;
|
|
384
565
|
}
|
|
385
566
|
|
|
386
567
|
declare function sdk<T>(builder: (client: Client) => T): (client: Client) => T;
|
|
387
568
|
|
|
388
|
-
declare const health: (client:
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
details: {
|
|
392
|
-
app: {
|
|
393
|
-
status: string;
|
|
394
|
-
details: {
|
|
395
|
-
status: string;
|
|
396
|
-
};
|
|
397
|
-
};
|
|
398
|
-
};
|
|
399
|
-
}>>;
|
|
569
|
+
declare const health: (client: Client) => {
|
|
570
|
+
database: () => Promise<Health<"database">>;
|
|
571
|
+
http: () => Promise<Health<"app">>;
|
|
400
572
|
};
|
|
401
573
|
|
|
402
574
|
declare const users: (client: Client) => {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
575
|
+
getAll: () => Promise<User[]>;
|
|
576
|
+
get: (id: string) => Promise<CareersCategory[] | CareersEmploymentType[] | CareersJob[] | CareersJob | CareersOffice[] | Health<"database"> | Health<"app"> | UserIdentity | User[] | User | UserIdentifier>;
|
|
577
|
+
me: () => Promise<User>;
|
|
578
|
+
check: (identifier: string) => Promise<CareersCategory[] | CareersEmploymentType[] | CareersJob[] | CareersJob | CareersOffice[] | Health<"database"> | Health<"app"> | UserIdentity | User[] | User | UserIdentifier>;
|
|
579
|
+
update: (id: string, data: UpdateUserDto) => Promise<User>;
|
|
407
580
|
};
|
|
408
581
|
|
|
409
|
-
|
|
582
|
+
declare class TonightPass {
|
|
583
|
+
readonly client: Client;
|
|
584
|
+
readonly careers: {
|
|
585
|
+
categories: {
|
|
586
|
+
getAll: (query?: Query<"/careers/categories"> | undefined) => Promise<CareersCategory[]>;
|
|
587
|
+
};
|
|
588
|
+
employmentTypes: {
|
|
589
|
+
getAll: (query?: Query<"/careers/employmentTypes"> | undefined) => Promise<CareersEmploymentType[]>;
|
|
590
|
+
};
|
|
591
|
+
jobs: {
|
|
592
|
+
getAll: (query?: Query<"/careers/jobs"> | undefined) => Promise<CareersJob[]>;
|
|
593
|
+
get: (id: number) => Promise<CareersJob>;
|
|
594
|
+
};
|
|
595
|
+
offices: {
|
|
596
|
+
getAll: (query?: Query<"/careers/offices"> | undefined) => Promise<CareersOffice[]>;
|
|
597
|
+
};
|
|
598
|
+
};
|
|
599
|
+
readonly health: {
|
|
600
|
+
database: () => Promise<Health<"database">>;
|
|
601
|
+
http: () => Promise<Health<"app">>;
|
|
602
|
+
};
|
|
603
|
+
readonly users: {
|
|
604
|
+
getAll: () => Promise<User[]>;
|
|
605
|
+
get: (id: string) => Promise<CareersCategory[] | CareersEmploymentType[] | CareersJob[] | CareersJob | CareersOffice[] | Health<"database"> | Health<"app"> | UserIdentity | User[] | User | UserIdentifier>;
|
|
606
|
+
me: () => Promise<User>;
|
|
607
|
+
check: (identifier: string) => Promise<CareersCategory[] | CareersEmploymentType[] | CareersJob[] | CareersJob | CareersOffice[] | Health<"database"> | Health<"app"> | UserIdentity | User[] | User | UserIdentifier>;
|
|
608
|
+
update: (id: string, data: UpdateUserDto) => Promise<User>;
|
|
609
|
+
};
|
|
610
|
+
constructor(options: ClientOptions);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
declare const isBrowser: boolean;
|
|
614
|
+
|
|
615
|
+
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 ExtractEndpoint, type ExtractRouteParams, 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, type Query, 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 };
|