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.
Files changed (46) hide show
  1. package/.turbo/turbo-build.log +21 -17
  2. package/CHANGELOG.md +13 -0
  3. package/dist/index.d.mts +615 -0
  4. package/dist/index.d.ts +258 -52
  5. package/dist/index.js +44 -471
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +11 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +15 -6
  10. package/src/constants/api.ts +1 -0
  11. package/src/constants/index.ts +2 -0
  12. package/src/constants/regex.ts +20 -0
  13. package/src/index.ts +5 -3
  14. package/src/rest/client.ts +154 -0
  15. package/src/rest/dtos/index.ts +3 -0
  16. package/src/rest/dtos/users/create-user.dto.ts +16 -0
  17. package/src/rest/dtos/users/index.ts +3 -0
  18. package/src/rest/dtos/users/sign-in-user.dto.ts +4 -0
  19. package/src/rest/dtos/users/update-user.dto.ts +116 -0
  20. package/src/rest/endpoints.ts +41 -0
  21. package/src/rest/index.ts +5 -0
  22. package/src/rest/request/index.ts +1 -0
  23. package/src/rest/request/request.ts +30 -0
  24. package/src/rest/types/api/index.ts +0 -0
  25. package/src/rest/types/careers/index.ts +87 -0
  26. package/src/rest/types/event/index.ts +60 -0
  27. package/src/rest/types/event/ticket/index.ts +36 -0
  28. package/src/rest/types/health/index.ts +17 -0
  29. package/src/rest/types/index.ts +33 -0
  30. package/src/rest/types/order/index.ts +46 -0
  31. package/src/rest/types/organizations/index.ts +54 -0
  32. package/src/rest/types/profiles/index.ts +30 -0
  33. package/src/rest/types/token/index.ts +15 -0
  34. package/src/rest/types/users/index.ts +104 -0
  35. package/src/sdk/builder.ts +5 -0
  36. package/src/sdk/careers.ts +22 -0
  37. package/src/sdk/health.ts +6 -0
  38. package/src/sdk/index.ts +3 -0
  39. package/src/sdk/profiles.ts +6 -0
  40. package/src/sdk/users.ts +12 -0
  41. package/src/tonightpass.ts +19 -0
  42. package/src/utils/index.ts +1 -0
  43. package/tests/careers/index.ts +28 -0
  44. package/tests/index.ts +57 -0
  45. package/tsconfig.json +3 -1
  46. package/tsup.config.ts +5 -2
@@ -0,0 +1,41 @@
1
+ import { Options } from "redaxios";
2
+
3
+ import {
4
+ CareersEndpoints,
5
+ HealthEndpoints,
6
+ ProfileEndpoints,
7
+ UserEndpoints,
8
+ } from "./types";
9
+
10
+ export type SuccessfulAPIResponse<T> = {
11
+ success: true;
12
+ data: T;
13
+ };
14
+
15
+ export type ErroredAPIResponse = {
16
+ success: false;
17
+ message: string;
18
+ errors?: {
19
+ [key: string]: string;
20
+ };
21
+ };
22
+
23
+ export type APIResponse<T> = SuccessfulAPIResponse<T> | ErroredAPIResponse;
24
+
25
+ export type Endpoint<
26
+ M extends Options["method"],
27
+ Path extends string,
28
+ Res,
29
+ Body = undefined,
30
+ > = {
31
+ method: M;
32
+ path: Path;
33
+ res: Res;
34
+ body: Body;
35
+ };
36
+
37
+ export type Endpoints =
38
+ | CareersEndpoints
39
+ | HealthEndpoints
40
+ | ProfileEndpoints
41
+ | UserEndpoints;
@@ -0,0 +1,5 @@
1
+ export * from "./dtos";
2
+ export * from "./request";
3
+ export * from "./types";
4
+ export * from "./client";
5
+ export * from "./endpoints";
@@ -0,0 +1 @@
1
+ export * from "./request";
@@ -0,0 +1,30 @@
1
+ import axios, { Options } from "redaxios";
2
+
3
+ import { isBrowser } from "../../utils";
4
+ import { APIResponse } from "../endpoints";
5
+
6
+ const instance = axios.create({
7
+ headers: {
8
+ "Content-Type": "application/json",
9
+ Accept: "application/json",
10
+ ...(!isBrowser && { "User-Agent": "tonightpass-api-client" }),
11
+ },
12
+ responseType: "json",
13
+ transformRequest: [
14
+ function (data) {
15
+ return JSON.stringify(data);
16
+ },
17
+ ],
18
+ });
19
+
20
+ export interface APIRequestOptions extends Options {}
21
+
22
+ export const request = async <T>(url: string, options?: Options) => {
23
+ const response = instance<APIResponse<T>>(url, { ...options })
24
+ .then((response) => response)
25
+ .catch((error: Error) => {
26
+ throw error;
27
+ });
28
+
29
+ return response;
30
+ };
File without changes
@@ -0,0 +1,87 @@
1
+ import { Endpoint } from "../../endpoints";
2
+
3
+ export type CareersOffice = {
4
+ id: number | null;
5
+ isDefault: boolean | null;
6
+ name: string | null;
7
+ city: string | null;
8
+ countryIso: string | null;
9
+ };
10
+
11
+ export type CareersJob = {
12
+ id: number;
13
+ createdAt: string;
14
+ lastUpdatedAt: string;
15
+ externalId: null | string;
16
+ title: string;
17
+ status: "ALL" | "ONLINE" | "ARCHIVED";
18
+ remote: boolean;
19
+ office: CareersOffice;
20
+ workplaceType: string;
21
+ remoteType?: string;
22
+ description?: string;
23
+ categoryId?: number;
24
+ employmentTypeId?: number;
25
+ };
26
+
27
+ export type CareersCategory = {
28
+ slug: string;
29
+ name: string;
30
+ subCategories?: (CareersCategory & {
31
+ id: number;
32
+ })[];
33
+ };
34
+
35
+ export type CareersEmploymentType = {
36
+ id: number;
37
+ name: string;
38
+ slug: string;
39
+ };
40
+
41
+ export type CareersEndpoints =
42
+ | Endpoint<
43
+ "GET",
44
+ "/careers/categories",
45
+ CareersCategory[],
46
+ {
47
+ language?: string;
48
+ }
49
+ >
50
+ | Endpoint<
51
+ "GET",
52
+ "/careers/employmentTypes",
53
+ CareersEmploymentType[],
54
+ {
55
+ language?: string;
56
+ }
57
+ >
58
+ | Endpoint<
59
+ "GET",
60
+ "/careers/jobs",
61
+ CareersJob[],
62
+ {
63
+ page?: number;
64
+ pageSize?: number;
65
+ createdAtGte: string;
66
+ createdAtLt?: string;
67
+ updatedAtGte?: string;
68
+ updatedAtLt?: string;
69
+ status?: "ALL" | "ONLINE" | "ARCHIVED";
70
+ content?: boolean;
71
+ titleLike?: string;
72
+ countryCode?: string;
73
+ externalId?: string;
74
+ }
75
+ >
76
+ | Endpoint<"GET", "/careers/jobs/:id", CareersJob, { id: number }>
77
+ | Endpoint<
78
+ "GET",
79
+ "/careers/offices",
80
+ CareersOffice[],
81
+ {
82
+ page?: number;
83
+ pageSize?: number;
84
+ countryCode?: string;
85
+ cityNameLike?: string;
86
+ }
87
+ >;
@@ -0,0 +1,60 @@
1
+ import { EventTicket } from "./ticket";
2
+ import { Location } from "..";
3
+ import { Organization } from "../organizations";
4
+
5
+ export * from "./ticket";
6
+
7
+ export type Event = {
8
+ title: string;
9
+ description: string;
10
+ slug: string;
11
+ organization: Organization;
12
+ type: EventType;
13
+ public: boolean;
14
+ flyers: string[];
15
+ trailers: string[];
16
+ location: Location;
17
+ tickets: EventTicket[];
18
+ styles: EventStyle[];
19
+ startAt: Date;
20
+ endAt: Date;
21
+ updatedAt: Date;
22
+ createdAt: Date;
23
+ };
24
+
25
+ export enum EventType {
26
+ Clubbing = "clubbing",
27
+ Concert = "concert",
28
+ Afterwork = "afterwork",
29
+ DancingLunch = "dancing_lunch",
30
+ Diner = "diner",
31
+ Garden = "garden",
32
+ AfterBeach = "after_beach",
33
+ Festival = "festival",
34
+ Spectacle = "spectacle",
35
+ Cruise = "cruise",
36
+ OutsideAnimation = "outside_animation",
37
+ Sport = "sport",
38
+ Match = "match",
39
+ Seminar = "seminar",
40
+ Conference = "conference",
41
+ WellnessDay = "wellness_day",
42
+ Workshop = "workshop",
43
+ TradeFair = "trade_fair",
44
+ ConsumerShow = "consumer_show",
45
+ Membership = "membership",
46
+ }
47
+
48
+ export type EventStyle = {
49
+ type: EventStyleType;
50
+ emoji: string;
51
+ name: string;
52
+ };
53
+
54
+ export enum EventStyleType {
55
+ Music = "music",
56
+ Dress = "dress",
57
+ Sport = "sport",
58
+ Food = "food",
59
+ Art = "art",
60
+ }
@@ -0,0 +1,36 @@
1
+ import { Currency } from "../..";
2
+
3
+ export type EventTicket = {
4
+ id: string;
5
+ name: string;
6
+ description?: string;
7
+ price: number;
8
+ displayPrice: number;
9
+ quantity: number;
10
+ type: EventTicketType;
11
+ category: EventTicketCategory;
12
+ currency: Currency;
13
+ vatRate: number;
14
+ externalId?: string;
15
+ isVisible: boolean;
16
+ isFeesIncluded: boolean;
17
+ startAt: Date;
18
+ endAt: Date;
19
+ updatedAt: Date;
20
+ createdAt: Date;
21
+ };
22
+
23
+ export type EventTicketType = "e-ticket" | "other";
24
+
25
+ export enum EventTicketCategory {
26
+ ENTRY = "entry",
27
+ PACKAGE = "package",
28
+ MEAL = "meal",
29
+ DRINK = "drink",
30
+ PARKING = "parking",
31
+ ACCOMMODATION = "accommodation",
32
+ CAMPING = "camping",
33
+ LOCKER = "locker",
34
+ SHUTTLE = "shuttle",
35
+ OTHER = "other",
36
+ }
@@ -0,0 +1,17 @@
1
+ import { Endpoint } from "../../endpoints";
2
+
3
+ export type Health<Key extends string> = {
4
+ status: string;
5
+ details: {
6
+ [key in Key]: {
7
+ status: string;
8
+ details: {
9
+ status: string;
10
+ };
11
+ };
12
+ };
13
+ };
14
+
15
+ export type HealthEndpoints =
16
+ | Endpoint<"GET", "/health/database", Health<"database">>
17
+ | Endpoint<"GET", "/health/http", Health<"app">>;
@@ -0,0 +1,33 @@
1
+ export * from "./careers";
2
+ export * from "./event";
3
+ export * from "./health";
4
+ export * from "./organizations";
5
+ export * from "./token";
6
+ export * from "./users";
7
+ export * from "./order";
8
+ export * from "./profiles";
9
+
10
+ export type Location = {
11
+ name?: string;
12
+ address: string;
13
+ zipCode: string;
14
+ city: string;
15
+ country: string;
16
+ geometry?: {
17
+ latitude: number;
18
+ longitude: number;
19
+ };
20
+ };
21
+
22
+ // Currency
23
+ export enum Currency {
24
+ EUR = "EUR",
25
+ USD = "USD",
26
+ GBP = "GBP",
27
+ }
28
+
29
+ // I18n
30
+ export enum Language {
31
+ FR = "fr",
32
+ EN = "en",
33
+ }
@@ -0,0 +1,46 @@
1
+ import { Currency } from "..";
2
+ import { Event, EventTicket } from "../event";
3
+ import { User } from "../users";
4
+
5
+ export enum OrderStatus {
6
+ Created = "created",
7
+ Cancelled = "cancelled",
8
+ Completed = "completed",
9
+ Pending = "pending",
10
+ Confirmed = "confirmed",
11
+ Declined = "declined",
12
+ Refunded = "refunded",
13
+ PartiallyRefunded = "partially_refunded",
14
+ Expired = "expired",
15
+ }
16
+
17
+ export type OrderItem = {
18
+ id: string;
19
+ ticket: EventTicket;
20
+ isUsed: boolean;
21
+ updatedAt: Date;
22
+ createdAt: Date;
23
+ };
24
+
25
+ export type Order = {
26
+ id: string;
27
+ owner: User;
28
+ members: User[];
29
+ status: OrderStatus;
30
+ event: Event;
31
+ items: OrderItem[];
32
+ promoCode?: PromoCode;
33
+ total: number;
34
+ currency: Currency;
35
+ createdAt: Date;
36
+ };
37
+
38
+ export type PromoCode = {
39
+ id: string;
40
+ code: string;
41
+ used: number;
42
+ discount: number;
43
+ isActive: boolean;
44
+ expirationAt: Date;
45
+ createdAt: Date;
46
+ };
@@ -0,0 +1,54 @@
1
+ import { Location, Profile, ProfileMetadata } from "..";
2
+ import { Event } from "../event";
3
+ import { EventTicket } from "../event/ticket";
4
+ import { User } from "../users";
5
+
6
+ export type Organization = {
7
+ id: string;
8
+ slug: string;
9
+ identity: OrganizationIdentity;
10
+ members: OrganizationMember[];
11
+ location?: Location;
12
+ events: Event[];
13
+ savedTickets: EventTicket[];
14
+ verified: boolean;
15
+ updatedAt: Date;
16
+ createdAt: Date;
17
+ };
18
+
19
+ export type OrganizationIdentity = Profile & {
20
+ socialLinks: OrganizationSocialLink[];
21
+
22
+ metadata: ProfileMetadata & {
23
+ eventsCount: number;
24
+ viewsCount: number;
25
+ membersCount: number;
26
+ };
27
+ };
28
+
29
+ export type OrganizationSocialLink = {
30
+ type: OrganizationSocialType;
31
+ url: string;
32
+ };
33
+
34
+ export enum OrganizationSocialType {
35
+ Facebook = "facebook",
36
+ Twitter = "twitter",
37
+ Instagram = "instagram",
38
+ Linkedin = "linkedin",
39
+ Youtube = "youtube",
40
+ Website = "website",
41
+ }
42
+
43
+ export type OrganizationMember = {
44
+ user: User;
45
+ role: OrganizationMemberRole;
46
+ createdAt: Date;
47
+ };
48
+
49
+ export enum OrganizationMemberRole {
50
+ EMPLOYEE = 0,
51
+ MANAGER = 1,
52
+ ADMINISTRATOR = 2,
53
+ OWNER = 3,
54
+ }
@@ -0,0 +1,30 @@
1
+ import { Endpoint } from "../../endpoints";
2
+ import { UserIdentity } from "../users";
3
+
4
+ export interface Profile {
5
+ type: "user" | "organization";
6
+
7
+ displayName: string;
8
+ description: string;
9
+
10
+ profilePictureUrl?: string;
11
+ bannerUrl?: string;
12
+
13
+ metadata: ProfileMetadata;
14
+
15
+ createdAt: Date;
16
+ }
17
+
18
+ export interface ProfileMetadata {
19
+ followersCount: number;
20
+
21
+ isBlocked: boolean;
22
+ hasBlocked: boolean;
23
+ canDM: boolean;
24
+ }
25
+
26
+ export type ProfileEndpoints = Endpoint<
27
+ "GET",
28
+ "/profiles/:username",
29
+ UserIdentity
30
+ >;
@@ -0,0 +1,15 @@
1
+ export type UserToken = {
2
+ id: string;
3
+ type: UserTokenType;
4
+ value: string;
5
+ createdAt: Date;
6
+ expiresAt: Date;
7
+ };
8
+
9
+ export enum UserTokenType {
10
+ Authentication = "authentication",
11
+ OrganizationInvite = "organization_invite",
12
+ PasswordRecovery = "password_recovery",
13
+ EmailValidation = "email_validation",
14
+ PhoneValidation = "phone_validation",
15
+ }
@@ -0,0 +1,104 @@
1
+ import { Currency, Language, Location, Profile, ProfileMetadata } from "..";
2
+ import { UpdateUserDto } from "../../dtos";
3
+ import { Endpoint } from "../../endpoints";
4
+
5
+ export type User = {
6
+ id: string;
7
+ identifier: UserIdentifier;
8
+ password: string;
9
+ identity: UserIdentity;
10
+ role: UserRole;
11
+ addresses: Location[];
12
+ preferences: UserPreferences;
13
+ connections: UserConnection[];
14
+ verified: boolean;
15
+ updatedAt: Date;
16
+ createdAt: Date;
17
+ };
18
+
19
+ export type UserIdentifier = {
20
+ email?: string;
21
+ phoneNumber?: string;
22
+ username: string;
23
+
24
+ [key: string]: string | undefined;
25
+ };
26
+
27
+ export type UserIdentity = Profile & {
28
+ firstName: string;
29
+ lastName: string;
30
+ fullName: string;
31
+ gender: UserIdentityGender;
32
+ birthDate: Date;
33
+
34
+ metadata: ProfileMetadata & {
35
+ followingCount: number;
36
+ hasPassPlus: boolean;
37
+ idValid: boolean;
38
+ };
39
+ };
40
+
41
+ export enum UserRole {
42
+ USER = 0,
43
+ DEVELOPER = 8,
44
+ ADMINISTRATOR = 10,
45
+ }
46
+
47
+ export type UserIdentityGender =
48
+ | "male"
49
+ | "female"
50
+ | "non-binary"
51
+ | "gender-fluid"
52
+ | "neutral"
53
+ | "other"
54
+ | string;
55
+
56
+ export type UserPreferences = {
57
+ language: Language;
58
+ currency: Currency;
59
+ notifications: {
60
+ email: {
61
+ newsletter: boolean;
62
+ message: boolean;
63
+ };
64
+ push: {
65
+ message: boolean;
66
+ };
67
+ };
68
+ };
69
+
70
+ export type UserConnection = {
71
+ ip: string;
72
+ os: UserConnectionOS;
73
+ device: UserConnectionDevice;
74
+ client: UserConnectionClient;
75
+ updatedAt: Date;
76
+ createdAt: Date;
77
+ };
78
+
79
+ export type UserConnectionOS = {
80
+ name: string;
81
+ version: string;
82
+ };
83
+
84
+ export type UserConnectionDevice = {
85
+ type: string;
86
+ brand: string;
87
+ };
88
+
89
+ export type UserConnectionClient = {
90
+ name: string;
91
+ version: string;
92
+ };
93
+
94
+ export type UserEndpoints =
95
+ | Endpoint<"GET", "/users", User[]>
96
+ | Endpoint<"GET", "/users/:id", User, { id: string }>
97
+ | Endpoint<"GET", "/users/me", User>
98
+ | Endpoint<
99
+ "GET",
100
+ "/check/:identifier",
101
+ UserIdentifier,
102
+ { identifier: string }
103
+ >
104
+ | Endpoint<"PUT", "/users/:id", User, UpdateUserDto>;
@@ -0,0 +1,5 @@
1
+ import { Client } from "../rest";
2
+
3
+ export function sdk<T>(builder: (client: Client) => T) {
4
+ return builder;
5
+ }
@@ -0,0 +1,22 @@
1
+ import { sdk } from "./builder";
2
+ import { Query } from "../rest";
3
+
4
+ export const careers = sdk((client) => ({
5
+ categories: {
6
+ getAll: async (query?: Query<"/careers/categories">) =>
7
+ client.get("/careers/categories", query),
8
+ },
9
+ employmentTypes: {
10
+ getAll: async (query?: Query<"/careers/employmentTypes">) =>
11
+ client.get("/careers/employmentTypes", query),
12
+ },
13
+ jobs: {
14
+ getAll: async (query?: Query<"/careers/jobs">) =>
15
+ client.get("/careers/jobs", query),
16
+ get: async (id: number) => client.get("/careers/jobs/:id", { id }),
17
+ },
18
+ offices: {
19
+ getAll: async (query?: Query<"/careers/offices">) =>
20
+ client.get("/careers/offices", query),
21
+ },
22
+ }));
@@ -0,0 +1,6 @@
1
+ import { sdk } from "./builder";
2
+
3
+ export const health = sdk((client) => ({
4
+ database: async () => client.get("/health/database"),
5
+ http: async () => client.get("/health/http"),
6
+ }));
@@ -0,0 +1,3 @@
1
+ export * from "./builder";
2
+ export * from "./health";
3
+ export * from "./users";
@@ -0,0 +1,6 @@
1
+ import { sdk } from "./builder";
2
+
3
+ export const profiles = sdk((client) => ({
4
+ get: async (username: string) =>
5
+ client.get("/profiles/:username", { username }),
6
+ }));
@@ -0,0 +1,12 @@
1
+ import { sdk } from "./builder";
2
+ import { UpdateUserDto } from "../rest";
3
+
4
+ export const users = sdk((client) => ({
5
+ getAll: async () => client.get("/users"),
6
+ get: async (id: string) => client.get("/users", { id }),
7
+ me: async () => client.get("/users/me"),
8
+ check: async (identifier: string) =>
9
+ client.get("/check/:identifier", { identifier }),
10
+ update: async (id: string, data: UpdateUserDto) =>
11
+ client.put("/users/:id", data, { id }),
12
+ }));
@@ -0,0 +1,19 @@
1
+ import { Client, ClientOptions } from "./rest";
2
+ import { health, users } from "./sdk";
3
+ import { careers } from "./sdk/careers";
4
+
5
+ export class TonightPass {
6
+ public readonly client: Client;
7
+
8
+ public readonly careers;
9
+ public readonly health;
10
+ public readonly users;
11
+
12
+ constructor(options: ClientOptions) {
13
+ this.client = new Client(options);
14
+
15
+ this.careers = careers(this.client);
16
+ this.health = health(this.client);
17
+ this.users = users(this.client);
18
+ }
19
+ }
@@ -0,0 +1 @@
1
+ export const isBrowser = typeof window !== "undefined";
@@ -0,0 +1,28 @@
1
+ import assert from "assert";
2
+ import test from "node:test";
3
+
4
+ import { TonightPass } from "../../src/tonightpass";
5
+
6
+ export function careersTests(tnp: TonightPass) {
7
+ test("It gets all careers categories", async () => {
8
+ const careersCategories = await tnp.careers.categories.getAll();
9
+ assert.ok(
10
+ Array.isArray(careersCategories) &&
11
+ careersCategories.length > 0 &&
12
+ careersCategories[0].slug,
13
+ );
14
+ });
15
+
16
+ test("It gets all careers jobs", async () => {
17
+ const careersJobs = await tnp.careers.jobs.getAll();
18
+ assert.ok(Array.isArray(careersJobs));
19
+ });
20
+
21
+ test("It gets all careers offices", async () => {
22
+ const careersOffices = await tnp.careers.offices.getAll({
23
+ page: 1,
24
+ pageSize: 10,
25
+ });
26
+ assert.ok(Array.isArray(careersOffices));
27
+ });
28
+ }