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.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.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","../../../node_modules/redaxios/src/index.js","../src/rest/request/request.ts","../src/rest/request/requester.ts","../src/rest/types/event/ticket/index.ts","../src/rest/types/event/index.ts","../src/rest/types/organization/index.ts","../src/rest/types/token/index.ts","../src/rest/types/user/index.ts","../src/rest/types/order/index.ts","../src/rest/types/index.ts","../src/rest/client.ts","../src/constants/api.ts","../src/sdk/builder.ts","../src/sdk/health.ts","../src/sdk/users.ts"],"sourcesContent":["export * from \"./constants/regex\";\nexport * from \"./rest\";\nexport * from \"./sdk\";\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","/**\n * Copyright 2018 Google Inc. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @public\n * @typedef Options\n * @property {string} [url] the URL to request\n * @property {'get'|'post'|'put'|'patch'|'delete'|'options'|'head'|'GET'|'POST'|'PUT'|'PATCH'|'DELETE'|'OPTIONS'|'HEAD'} [method=\"get\"] HTTP method, case-insensitive\n * @property {RequestHeaders} [headers] Request headers\n * @property {FormData|string|object} [body] a body, optionally encoded, to send\n * @property {'text'|'json'|'stream'|'blob'|'arrayBuffer'|'formData'|'stream'} [responseType=\"json\"] An encoding to use for the response\n * @property {Record<string,any>|URLSearchParams} [params] querystring parameters\n * @property {(params: Options['params']) => string} [paramsSerializer] custom function to stringify querystring parameters\n * @property {boolean} [withCredentials] Send the request with credentials like cookies\n * @property {string} [auth] Authorization header value to send with the request\n * @property {string} [xsrfCookieName] Pass an Cross-site Request Forgery prevention cookie value as a header defined by `xsrfHeaderName`\n * @property {string} [xsrfHeaderName] The name of a header to use for passing XSRF cookies\n * @property {(status: number) => boolean} [validateStatus] Override status code handling (default: 200-399 is a success)\n * @property {Array<(body: any, headers?: RequestHeaders) => any?>} [transformRequest] An array of transformations to apply to the outgoing request\n * @property {string} [baseURL] a base URL from which to resolve all URLs\n * @property {typeof window.fetch} [fetch] Custom window.fetch implementation\n * @property {any} [data]\n */\n\n/**\n * @public\n * @typedef RequestHeaders\n * @type {{[name: string]: string} | Headers}\n */\n\n/**\n * @public\n * @template T\n * @typedef Response\n * @property {number} status\n * @property {string} statusText\n * @property {Options} config the request configuration\n * @property {T} data the decoded response body\n * @property {Headers} headers\n * @property {boolean} redirect\n * @property {string} url\n * @property {ResponseType} type\n * @property {ReadableStream<Uint8Array> | null} body\n * @property {boolean} bodyUsed\n */\n\n/**\n * @typedef BodylessMethod\n * @type {<T=any>(url: string, config?: Options) => Promise<Response<T>>}\n */\n\n/**\n * @typedef BodyMethod\n * @type {<T=any>(url: string, body?: any, config?: Options) => Promise<Response<T>>}\n */\n\n/**\n * @public\n * @param {Options} [defaults = {}]\n * @returns {redaxios}\n */\nfunction create(defaults) {\n\tdefaults = defaults || {};\n\n\t/**\n\t * @public\n\t * @template T\n\t * @type {(<T = any>(config?: Options) => Promise<Response<T>>) | (<T = any>(url: string, config?: Options) => Promise<Response<T>>)}\n\t */\n\tredaxios.request = redaxios;\n\n\t/** @public @type {BodylessMethod} */\n\tredaxios.get = (url, config) => redaxios(url, config, 'get');\n\n\t/** @public @type {BodylessMethod} */\n\tredaxios.delete = (url, config) => redaxios(url, config, 'delete');\n\n\t/** @public @type {BodylessMethod} */\n\tredaxios.head = (url, config) => redaxios(url, config, 'head');\n\n\t/** @public @type {BodylessMethod} */\n\tredaxios.options = (url, config) => redaxios(url, config, 'options');\n\n\t/** @public @type {BodyMethod} */\n\tredaxios.post = (url, data, config) => redaxios(url, config, 'post', data);\n\n\t/** @public @type {BodyMethod} */\n\tredaxios.put = (url, data, config) => redaxios(url, config, 'put', data);\n\n\t/** @public @type {BodyMethod} */\n\tredaxios.patch = (url, data, config) => redaxios(url, config, 'patch', data);\n\n\t/** @public */\n\tredaxios.all = Promise.all.bind(Promise);\n\n\t/**\n\t * @public\n\t * @template Args, R\n\t * @param {(...args: Args[]) => R} fn\n\t * @returns {(array: Args[]) => R}\n\t */\n\tredaxios.spread = (fn) => /** @type {any} */ (fn.apply.bind(fn, fn));\n\n\t/**\n\t * @private\n\t * @template T, U\n\t * @param {T} opts\n\t * @param {U} [overrides]\n\t * @param {boolean} [lowerCase]\n\t * @returns {{} & (T | U)}\n\t */\n\tfunction deepMerge(opts, overrides, lowerCase) {\n\t\tlet out = /** @type {any} */ ({}),\n\t\t\ti;\n\t\tif (Array.isArray(opts)) {\n\t\t\t// @ts-ignore\n\t\t\treturn opts.concat(overrides);\n\t\t}\n\t\tfor (i in opts) {\n\t\t\tconst key = lowerCase ? i.toLowerCase() : i;\n\t\t\tout[key] = opts[i];\n\t\t}\n\t\tfor (i in overrides) {\n\t\t\tconst key = lowerCase ? i.toLowerCase() : i;\n\t\t\tconst value = /** @type {any} */ (overrides)[i];\n\t\t\tout[key] = key in out && typeof value == 'object' ? deepMerge(out[key], value, key == 'headers') : value;\n\t\t}\n\t\treturn out;\n\t}\n\n\t/**\n\t * Issues a request.\n\t * @public\n\t * @template T\n\t * @param {string | Options} urlOrConfig\n\t * @param {Options} [config = {}]\n\t * @param {any} [_method] (internal)\n\t * @param {any} [data] (internal)\n\t * @param {never} [_undefined] (internal)\n\t * @returns {Promise<Response<T>>}\n\t */\n\tfunction redaxios(urlOrConfig, config, _method, data, _undefined) {\n\t\tlet url = /** @type {string} */ (typeof urlOrConfig != 'string' ? (config = urlOrConfig).url : urlOrConfig);\n\n\t\tconst response = /** @type {Response<any>} */ ({ config });\n\n\t\t/** @type {Options} */\n\t\tconst options = deepMerge(defaults, config);\n\n\t\t/** @type {RequestHeaders} */\n\t\tconst customHeaders = {};\n\n\t\tdata = data || options.data;\n\n\t\t(options.transformRequest || []).map((f) => {\n\t\t\tdata = f(data, options.headers) || data;\n\t\t});\n\n\t\tif (options.auth) {\n\t\t\tcustomHeaders.authorization = options.auth;\n\t\t}\n\n\t\tif (data && typeof data === 'object' && typeof data.append !== 'function' && typeof data.text !== 'function') {\n\t\t\tdata = JSON.stringify(data);\n\t\t\tcustomHeaders['content-type'] = 'application/json';\n\t\t}\n\n\t\ttry {\n\t\t\t// @ts-ignore providing the cookie name without header name is nonsensical anyway\n\t\t\tcustomHeaders[options.xsrfHeaderName] = decodeURIComponent(\n\t\t\t\t// @ts-ignore accessing match()[2] throws for no match, which is intentional\n\t\t\t\tdocument.cookie.match(RegExp('(^|; )' + options.xsrfCookieName + '=([^;]*)'))[2]\n\t\t\t);\n\t\t} catch (e) {}\n\n\t\tif (options.baseURL) {\n\t\t\turl = url.replace(/^(?!.*\\/\\/)\\/?/, options.baseURL + '/');\n\t\t}\n\n\t\tif (options.params) {\n\t\t\turl +=\n\t\t\t\t(~url.indexOf('?') ? '&' : '?') +\n\t\t\t\t(options.paramsSerializer ? options.paramsSerializer(options.params) : new URLSearchParams(options.params));\n\t\t}\n\n\t\tconst fetchFunc = options.fetch || fetch;\n\n\t\treturn fetchFunc(url, {\n\t\t\tmethod: (_method || options.method || 'get').toUpperCase(),\n\t\t\tbody: data,\n\t\t\theaders: deepMerge(options.headers, customHeaders, true),\n\t\t\tcredentials: options.withCredentials ? 'include' : _undefined\n\t\t}).then((res) => {\n\t\t\tfor (const i in res) {\n\t\t\t\tif (typeof res[i] != 'function') response[i] = res[i];\n\t\t\t}\n\n\t\t\tif (options.responseType == 'stream') {\n\t\t\t\tresponse.data = res.body;\n\t\t\t\treturn response;\n\t\t\t}\n\n\t\t\treturn res[options.responseType || 'text']()\n\t\t\t\t.then((data) => {\n\t\t\t\t\tresponse.data = data;\n\t\t\t\t\t// its okay if this fails: response.data will be the unparsed value:\n\t\t\t\t\tresponse.data = JSON.parse(data);\n\t\t\t\t})\n\t\t\t\t.catch(Object)\n\t\t\t\t.then(() => {\n\t\t\t\t\tconst ok = options.validateStatus ? options.validateStatus(res.status) : res.ok;\n\t\t\t\t\treturn ok ? response : Promise.reject(response);\n\t\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * @public\n\t * @type {AbortController}\n\t */\n\tredaxios.CancelToken = /** @type {any} */ (typeof AbortController == 'function' ? AbortController : Object);\n\n\t/**\n\t * @public\n\t * @type {Options}\n\t */\n\tredaxios.defaults = defaults;\n\n\t/**\n\t * @public\n\t */\n\tredaxios.create = create;\n\n\treturn redaxios;\n}\n\nexport default create();\n","import axios, { Options } from \"redaxios\";\n\nimport { APIError, APIResponse } from \"../types\";\n\ntype ApiRequestConfig = Exclude<Options, \"method\">;\n\nconst instance = axios.create({\n baseURL: process.env.NEXT_PUBLIC_API_URL,\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n responseType: \"json\",\n transformRequest: [\n function (data) {\n return JSON.stringify(data);\n },\n ],\n});\n\nexport const request = async <TData>(\n url: string,\n options?: ApiRequestConfig,\n): Promise<APIResponse<TData>> => {\n const response = instance<APIResponse<TData>>(url, { ...options })\n .then((response) => response.data)\n .catch((error: APIError) => {\n throw error;\n });\n\n return response;\n};\n\nexport type { ApiRequestConfig };\n","import { ApiRequestConfig, request } from \"./request\";\nimport { APIResponse } from \"../types\";\n\nconst createAuthHeaders = (jwtToken: string) => ({\n Authorization: `${\n process.env.NEXT_PUBLIC_AUTH_PREFIX || \"Bearer\"\n } ${jwtToken}`,\n});\n\ntype BaseRequest = <TData>(\n url: string,\n options?: ApiRequestConfig,\n) => Promise<APIResponse<TData>>;\n\ntype RequestResponse = {\n get: BaseRequest;\n post: BaseRequest;\n put: BaseRequest;\n delete: BaseRequest;\n};\n\nconst requester = (auth = true): RequestResponse => {\n let baseOptions: ApiRequestConfig = {};\n\n if (auth) {\n // eslint-disable-next-line no-unused-expressions\n createAuthHeaders; // - Waiting usage\n\n baseOptions = {\n ...baseOptions,\n withCredentials: true,\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const get: BaseRequest = async <TData = any>(\n url: string,\n options?: ApiRequestConfig,\n ): Promise<APIResponse<TData>> =>\n request<TData>(url, { ...baseOptions, ...options, method: \"GET\" });\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const post: BaseRequest = async <TData = any>(\n url: string,\n options?: ApiRequestConfig,\n ): Promise<APIResponse<TData>> =>\n request<TData>(url, { ...baseOptions, ...options, method: \"POST\" });\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const put: BaseRequest = async <TData = any>(\n url: string,\n options?: ApiRequestConfig,\n ): Promise<APIResponse<TData>> =>\n request<TData>(url, { ...baseOptions, ...options, method: \"PUT\" });\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const del: BaseRequest = async <TData = any>(\n url: string,\n options?: ApiRequestConfig,\n ): Promise<APIResponse<TData>> =>\n request<TData>(url, { ...baseOptions, ...options, method: \"DELETE\" });\n\n return {\n get,\n post,\n put,\n delete: del,\n };\n};\n\nexport { requester };\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 \"../organization\";\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 \"../user\";\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 \"..\";\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","import { Currency } from \"..\";\nimport { Event, EventTicket } from \"../event\";\nimport { User } from \"../user\";\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 \"./event\";\nexport * from \"./organization\";\nexport * from \"./token\";\nexport * from \"./user\";\nexport * from \"./order\";\nexport * from \"./profile\";\n\n// - API\nexport * from \"./api\";\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, pathcat } from \"pathcat\";\n\nimport { ApiRequestConfig, requester } from \"./request\";\nimport { DEFAULT_API_URL } from \"../constants\";\n\nexport interface ClientOptions {\n readonly baseUrl: string;\n}\n\nexport class Client {\n private readonly options;\n public readonly url;\n private request = requester();\n\n constructor(options: ClientOptions) {\n this.options = options;\n this.url = (path: string, params: Record<string, ParamValue>) => {\n const baseUrl = DEFAULT_API_URL || this.options.baseUrl;\n return pathcat(baseUrl, path, params);\n };\n }\n\n async get<T>(url: string, options?: ApiRequestConfig) {\n return this.request.get<T>(url, options);\n }\n\n async post<T>(url: string, options?: ApiRequestConfig) {\n return this.request.post<T>(url, options);\n }\n\n async put<T>(url: string, options?: ApiRequestConfig) {\n return this.request.put<T>(url, options);\n }\n\n async delete<T>(url: string, options?: ApiRequestConfig) {\n return this.request.delete<T>(url, options);\n }\n}\n","export const DEFAULT_API_URL = \"https://api.staging.tonightpass.com\";\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 http: async () =>\n client.get<{\n status: string;\n details: {\n app: {\n status: string;\n details: {\n status: string;\n };\n };\n };\n }>(\"/health/http\"),\n}));\n","import { sdk } from \"./builder\";\nimport { UpdateUserDto } from \"../rest\";\nimport { User } from \"../rest/types\";\n\nexport const users = sdk((client) => ({\n me: {\n get: async () => client.get<User>(\"/users/me\"),\n update: async (data: UpdateUserDto) =>\n client.put<User>(\"/users/me\", { data }),\n },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,cAAc;AAGpB,IAAM,iBACX;AAGK,IAAM,aAAa;AAGnB,IAAM,aAAa;AAGnB,IAAM,cAAc;AAEpB,IAAM,qBACX;AAEK,IAAM,kBACX;;;ACnBF,8BAAO;;;ACEA,IAAM,gBAAN,MAAoB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACPO,IAAM,gBAAN,MAAoB;AAAA,EACzB;AAAA,EACA;AACF;;;ACHA,+BAAqB;AACrB,6BAaO;AAKA,IAAM,gBAAN,MAAoB;AAAA,EAKzB;AAAA,EAMA;AAAA,EAMA;AACF;AAbE;AAAA,MAJC,mCAAW;AAAA,MACX,iCAAS;AAAA,MACT,uCAAe;AAAA,MACf,+BAAK,MAAM,mBAAmB;AAAA,GAJpB,cAKX;AAMA;AAAA,MAJC,mCAAW;AAAA,MACX,iCAAS;AAAA,MACT,uCAAe;AAAA,MAC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KAAK,QAAQ,IAAO,KAAK,OAAO;AAAA,EACzC;AAAA,EAEA,MAAM,KAAQ,KAAa,SAA4B;AACrD,WAAO,KAAK,QAAQ,KAAQ,KAAK,OAAO;AAAA,EAC1C;AAAA,EAEA,MAAM,IAAO,KAAa,SAA4B;AACpD,WAAO,KAAK,QAAQ,IAAO,KAAK,OAAO;AAAA,EACzC;AAAA,EAEA,MAAM,OAAU,KAAa,SAA4B;AACvD,WAAO,KAAK,QAAQ,OAAU,KAAK,OAAO;AAAA,EAC5C;AACF;;;AEnCO,SAAS,IAAO,SAAgC;AACrD,SAAO;AACT;;;ACFO,IAAM,SAAS,IAAI,CAAC,YAAY;AAAA,EACrC,MAAM,YACJ,OAAO,IAUJ,cAAc;AACrB,EAAE;;;ACXK,IAAM,QAAQ,IAAI,CAAC,YAAY;AAAA,EACpC,IAAI;AAAA,IACF,KAAK,YAAY,OAAO,IAAU,WAAW;AAAA,IAC7C,QAAQ,OAAO,SACb,OAAO,IAAU,aAAa,EAAE,KAAK,CAAC;AAAA,EAC1C;AACF,EAAE;","names":["create","defaults","deepMerge","opts","overrides","lowerCase","i","out","Array","isArray","concat","toLowerCase","key","value","redaxios","urlOrConfig","config","_method","data","_undefined","url","response","options","customHeaders","transformRequest","map","f","headers","auth","authorization","append","text","JSON","stringify","xsrfHeaderName","decodeURIComponent","document","cookie","match","RegExp","xsrfCookieName","e","baseURL","replace","params","indexOf","paramsSerializer","URLSearchParams","fetch","method","toUpperCase","body","credentials","withCredentials","then","res","responseType","parse","catch","Object","validateStatus","status","ok","Promise","reject","request","get","delete","head","post","put","patch","all","bind","spread","fn","apply","CancelToken","AbortController","response","EventTicketCategory","EventType","EventStyleType","OrganizationSocialType","OrganizationMemberRole","UserTokenType","UserRole","OrderStatus","Currency","Language"]}
|
|
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/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","careers","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,CAJC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,GACZH,EAAO,IAAI,qBAAsB,CAAE,WAAAG,CAAW,CAAC,EACjD,OAAQ,MAAOD,EAAY/B,IACzB6B,EAAO,IAAI,aAAc7B,EAAM,CAAE,GAAA+B,CAAG,CAAC,CACzC,GCRO,IAAME,EAAeJ,IAAY,CACtC,WAAY,CACV,OAAQ,MAAOP,GACbO,EAAO,IAAI,sBAAuBP,CAAK,CAC3C,EACA,gBAAiB,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,GCjBO,IAAMY,EAAN,KAAkB,CACP,OAEA,QACA,OACA,MAEhB,YAAY/B,EAAwB,CAClC,KAAK,OAAS,IAAIe,EAAOf,CAAO,EAEhC,KAAK,QAAU8B,EAAQ,KAAK,MAAM,EAClC,KAAK,OAASL,EAAO,KAAK,MAAM,EAChC,KAAK,MAAQE,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 } from \"redaxios\";\n\nimport { isBrowser } from \"../../utils\";\nimport { APIResponse } 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});\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: Error) => {\n throw error;\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 \"/check/:identifier\",\n UserIdentifier,\n { identifier: string }\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, 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\n// type ExtractRouteParams<T extends string> = string extends T\n// ? string\n// : T extends `${string}:${infer Param}/${infer Rest}`\n// ? Param | ExtractRouteParams<Rest>\n// : T extends `${string}:${infer Param}`\n// ? Param\n// : never;\n\nexport type ExtractRouteParams<T extends string> = string extends T\n ? Record<string, string | number | undefined>\n : T extends `${string}:${infer Param}/${infer Rest}`\n ? { [k in Param | keyof ExtractRouteParams<Rest>]: string | number }\n : T extends `${string}:${infer Param}`\n ? { [k in Param]: string | number }\n : object;\n\nexport type ExtractEndpoint<\n Method extends string,\n Path extends string,\n> = Extract<Endpoints, { path: Path; method: Method }>;\n\nexport type PathsFor<M extends Options[\"method\"]> = Extract<\n Endpoints,\n { method: M }\n>[\"path\"];\n\nexport type Query<Path extends string> = ExtractRouteParams<Path> &\n Record<string, string | number | undefined>;\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: Record<string, string | number | undefined> = {},\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 // TODO: Add error catcher\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) =>\n client.get(\"/check/:identifier\", { identifier }),\n update: async (id: string, data: UpdateUserDto) =>\n client.put(\"/users/:id\", data, { id }),\n}));\n","import { sdk } from \"./builder\";\nimport { Query } from \"../rest\";\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 { Client, ClientOptions } from \"./rest\";\nimport { health, users } from \"./sdk\";\nimport { careers } from \"./sdk/careers\";\n\nexport class TonightPass {\n public readonly client: Client;\n\n public readonly careers;\n public readonly health;\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.users = users(this.client);\n }\n}\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Type } from 'class-transformer';
|
|
3
|
+
import { IsOptional, IsObject, ValidateNested, IsString, MinLength, MaxLength, IsEmail, IsPhoneNumber, Length, Matches, IsUrl, IsDateString } from 'class-validator';
|
|
4
|
+
import z from 'redaxios';
|
|
5
|
+
import { pathcat } from 'pathcat';
|
|
6
|
+
|
|
7
|
+
var $=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var a=(r,e,s,t)=>{for(var n=t>1?void 0:t?j(e,s):e,i=r.length-1,d;i>=0;i--)(d=r[i])&&(n=(t?d(e,s,n):d(n))||n);return t&&n&&$(e,s,n),n};var R="https://api.tonightpass.com";var oe=/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/,ie=/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/,E=/(^[\p{L}\d'\\.\s\\-]*$)/u,ae=/^[a-z\d]+(?:(\.|-|_)[a-z\d]+)*$/,pe=/\$2[abxy]?\$\d{1,2}\$[A-Za-z\d\\./]{53}/,de=/^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$/,me=/(((http:\/\/www)|(http:\/\/)|(www))[-a-zA-Z0-9@:%_\\+.~#?&//=]+)\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)/i;var I=class{identifier;password;identity;addresses};var U=class{identifier;password};var h=class{identifier;identity;password};a([IsOptional(),IsObject(),ValidateNested(),Type(()=>f)],h.prototype,"identifier",2),a([IsOptional(),IsObject(),ValidateNested(),Type(()=>m)],h.prototype,"identity",2),a([IsOptional(),IsString(),MinLength(6),MaxLength(130)],h.prototype,"password",2);var f=class{email;phoneNumber;username};a([IsOptional(),IsString(),IsEmail()],f.prototype,"email",2),a([IsOptional(),IsString(),IsPhoneNumber()],f.prototype,"phoneNumber",2),a([IsOptional(),IsString(),MinLength(3)],f.prototype,"username",2);var m=class{firstName;lastName;displayName;description;profilePictureUrl;bannerUrl;gender;birthDate};a([IsOptional(),IsString(),Length(2,50),Matches(E,{message:"First name must be composed of letters only"})],m.prototype,"firstName",2),a([IsOptional(),IsString(),Length(2,50),Matches(E,{message:"Last name must be composed of letters only"})],m.prototype,"lastName",2),a([IsOptional(),IsString(),Length(1,32)],m.prototype,"displayName",2),a([IsOptional(),IsString(),Length(15,500)],m.prototype,"description",2),a([IsOptional(),IsUrl()],m.prototype,"profilePictureUrl",2),a([IsOptional(),IsUrl()],m.prototype,"bannerUrl",2),a([IsOptional()],m.prototype,"gender",2),a([IsOptional(),IsDateString()],m.prototype,"birthDate",2);var k=typeof window<"u";var H=z.create({headers:{"Content-Type":"application/json",Accept:"application/json",...!k&&{"User-Agent":"tonightpass-api-client"}},responseType:"json",transformRequest:[function(r){return JSON.stringify(r)}]}),G=async(r,e)=>H(r,{...e}).then(t=>t).catch(t=>{throw t});var V=(c=>(c.ENTRY="entry",c.PACKAGE="package",c.MEAL="meal",c.DRINK="drink",c.PARKING="parking",c.ACCOMMODATION="accommodation",c.CAMPING="camping",c.LOCKER="locker",c.SHUTTLE="shuttle",c.OTHER="other",c))(V||{});var B=(o=>(o.Clubbing="clubbing",o.Concert="concert",o.Afterwork="afterwork",o.DancingLunch="dancing_lunch",o.Diner="diner",o.Garden="garden",o.AfterBeach="after_beach",o.Festival="festival",o.Spectacle="spectacle",o.Cruise="cruise",o.OutsideAnimation="outside_animation",o.Sport="sport",o.Match="match",o.Seminar="seminar",o.Conference="conference",o.WellnessDay="wellness_day",o.Workshop="workshop",o.TradeFair="trade_fair",o.ConsumerShow="consumer_show",o.Membership="membership",o))(B||{}),X=(i=>(i.Music="music",i.Dress="dress",i.Sport="sport",i.Food="food",i.Art="art",i))(X||{});var W=(d=>(d.Facebook="facebook",d.Twitter="twitter",d.Instagram="instagram",d.Linkedin="linkedin",d.Youtube="youtube",d.Website="website",d))(W||{}),K=(n=>(n[n.EMPLOYEE=0]="EMPLOYEE",n[n.MANAGER=1]="MANAGER",n[n.ADMINISTRATOR=2]="ADMINISTRATOR",n[n.OWNER=3]="OWNER",n))(K||{});var Y=(i=>(i.Authentication="authentication",i.OrganizationInvite="organization_invite",i.PasswordRecovery="password_recovery",i.EmailValidation="email_validation",i.PhoneValidation="phone_validation",i))(Y||{});var Z=(t=>(t[t.USER=0]="USER",t[t.DEVELOPER=8]="DEVELOPER",t[t.ADMINISTRATOR=10]="ADMINISTRATOR",t))(Z||{});var J=(u=>(u.Created="created",u.Cancelled="cancelled",u.Completed="completed",u.Pending="pending",u.Confirmed="confirmed",u.Declined="declined",u.Refunded="refunded",u.PartiallyRefunded="partially_refunded",u.Expired="expired",u))(J||{});var ee=(t=>(t.EUR="EUR",t.USD="USD",t.GBP="GBP",t))(ee||{}),te=(s=>(s.FR="fr",s.EN="en",s))(te||{});var b=class extends Error{constructor(s,t){super(t.message);this.response=s;this.data=t;this.status=s.status;}status},x=class{options;url;constructor(e){this.options=e,this.url=(s,t)=>{let n=this.options.baseURL||R;return pathcat(n,s,t)};}setOptions(e){this.options=e;}async get(e,s,t){return this.requester("GET",e,void 0,s,t)}async post(e,s,t,n){return this.requester("POST",e,s,t,n)}async put(e,s,t,n){return this.requester("PUT",e,s,t,n)}async patch(e,s,t,n){return this.requester("PATCH",e,s,t,n)}async delete(e,s,t){return this.requester("DELETE",e,void 0,s,t)}async requester(e,s,t,n={},i={}){let d=this.url(s,n);if(t!==void 0&&e==="GET")throw new Error("Cannot send a GET request with a body");let A=await G(d,{method:e,data:t,...i}),P=A.data;if(!P.success)throw new b(A,P);return P.data}};function y(r){return r}var _=r=>({database:async()=>r.get("/health/database"),http:async()=>r.get("/health/http")});var T=r=>({getAll:async()=>r.get("/users"),get:async e=>r.get("/users",{id:e}),me:async()=>r.get("/users/me"),check:async e=>r.get("/check/:identifier",{identifier:e}),update:async(e,s)=>r.put("/users/:id",s,{id:e})});var M=r=>({categories:{getAll:async e=>r.get("/careers/categories",e)},employmentTypes:{getAll:async e=>r.get("/careers/employmentTypes",e)},jobs:{getAll:async e=>r.get("/careers/jobs",e),get:async e=>r.get("/careers/jobs/:id",{id:e})},offices:{getAll:async e=>r.get("/careers/offices",e)}});var q=class{client;careers;health;users;constructor(e){this.client=new x(e),this.careers=M(this.client),this.health=_(this.client),this.users=T(this.client);}};
|
|
8
|
+
|
|
9
|
+
export { pe as BCRYPT_HASH, x as Client, I as CreateUserDto, ee as Currency, R as DEFAULT_API_URL, oe as EMAIL_REGEX, X as EventStyleType, V as EventTicketCategory, B as EventType, me as IMAGE_URL_REGEX, te as Language, E as NAME_REGEX, J as OrderStatus, K as OrganizationMemberRole, W as OrganizationSocialType, ie as PASSWORD_REGEX, de as PHONE_NUMBER_REGEX, ae as SLUG_REGEX, U as SignInUserDto, q as TonightPass, b as TonightPassAPIError, h as UpdateUserDto, Z as UserRole, Y as UserTokenType, _ as health, k as isBrowser, G as request, y as sdk, T as users };
|
|
10
|
+
//# sourceMappingURL=out.js.map
|
|
11
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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/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","careers","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,E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I,oBAAqB,CAAE,GAAAE,CAAG,CAAC,CACnE,EACA,QAAS,CACP,OAAQ,MAAOT,GACbO,EAAO,IAAI,mBAAoBP,CAAK,CACxC,CACF,GCjBO,IAAMY,EAAN,KAAkB,CACP,OAEA,QACA,OACA,MAEhB,YAAY/B,EAAwB,CAClC,KAAK,OAAS,IAAIe,EAAOf,CAAO,EAEhC,KAAK,QAAU8B,EAAQ,KAAK,MAAM,EAClC,KAAK,OAASL,EAAO,KAAK,MAAM,EAChC,KAAK,MAAQE,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 } from \"redaxios\";\n\nimport { isBrowser } from \"../../utils\";\nimport { APIResponse } 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});\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: Error) => {\n throw error;\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 \"/check/:identifier\",\n UserIdentifier,\n { identifier: string }\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, 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\n// type ExtractRouteParams<T extends string> = string extends T\n// ? string\n// : T extends `${string}:${infer Param}/${infer Rest}`\n// ? Param | ExtractRouteParams<Rest>\n// : T extends `${string}:${infer Param}`\n// ? Param\n// : never;\n\nexport type ExtractRouteParams<T extends string> = string extends T\n ? Record<string, string | number | undefined>\n : T extends `${string}:${infer Param}/${infer Rest}`\n ? { [k in Param | keyof ExtractRouteParams<Rest>]: string | number }\n : T extends `${string}:${infer Param}`\n ? { [k in Param]: string | number }\n : object;\n\nexport type ExtractEndpoint<\n Method extends string,\n Path extends string,\n> = Extract<Endpoints, { path: Path; method: Method }>;\n\nexport type PathsFor<M extends Options[\"method\"]> = Extract<\n Endpoints,\n { method: M }\n>[\"path\"];\n\nexport type Query<Path extends string> = ExtractRouteParams<Path> &\n Record<string, string | number | undefined>;\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: Record<string, string | number | undefined> = {},\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 // TODO: Add error catcher\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) =>\n client.get(\"/check/:identifier\", { identifier }),\n update: async (id: string, data: UpdateUserDto) =>\n client.put(\"/users/:id\", data, { id }),\n}));\n","import { sdk } from \"./builder\";\nimport { Query } from \"../rest\";\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 { Client, ClientOptions } from \"./rest\";\nimport { health, users } from \"./sdk\";\nimport { careers } from \"./sdk/careers\";\n\nexport class TonightPass {\n public readonly client: Client;\n\n public readonly careers;\n public readonly health;\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.users = users(this.client);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tonightpass",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "@tonightpass sdk and tools.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,17 +8,26 @@
|
|
|
8
8
|
"directory": "packages/node"
|
|
9
9
|
},
|
|
10
10
|
"bugs": "https://github.com/tonightpass/tonightpass/issues",
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://tonightpass.com",
|
|
12
12
|
"license": "MIT",
|
|
13
|
-
"main": "dist/index.
|
|
14
|
-
"module": "dist/index.
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"module": "dist/index.mjs",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"class-transformer": "^0.5.1",
|
|
18
|
+
"class-validator": "^0.14.0",
|
|
19
|
+
"pathcat": "^1.2.2",
|
|
20
|
+
"redaxios": "^0.5.1",
|
|
21
|
+
"reflect-metadata": "^0.2.1"
|
|
22
|
+
},
|
|
16
23
|
"devDependencies": {
|
|
17
|
-
"@types/node": "20.11.
|
|
24
|
+
"@types/node": "20.11.30",
|
|
25
|
+
"tsx": "^4.7.1",
|
|
18
26
|
"typescript": "^5.0.0"
|
|
19
27
|
},
|
|
20
28
|
"scripts": {
|
|
21
29
|
"build": "tsup",
|
|
22
|
-
"dev": "tsup --watch"
|
|
30
|
+
"dev": "tsup --watch",
|
|
31
|
+
"test": "tsx tests/index.ts"
|
|
23
32
|
}
|
|
24
33
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_API_URL = "https://api.tonightpass.com";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const EMAIL_REGEX = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/;
|
|
2
|
+
|
|
3
|
+
// checks if a password has at least one uppercase letter and a number or special character
|
|
4
|
+
export const PASSWORD_REGEX =
|
|
5
|
+
/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/;
|
|
6
|
+
|
|
7
|
+
// checks if a string has only letters, numbers, spaces, apostrophes, dots and dashes
|
|
8
|
+
export const NAME_REGEX = /(^[\p{L}\d'\\.\s\\-]*$)/u;
|
|
9
|
+
|
|
10
|
+
// checks if a string is a valid slug, useful for usernames
|
|
11
|
+
export const SLUG_REGEX = /^[a-z\d]+(?:(\.|-|_)[a-z\d]+)*$/;
|
|
12
|
+
|
|
13
|
+
// validates if passwords are valid bcrypt hashes
|
|
14
|
+
export const BCRYPT_HASH = /\$2[abxy]?\$\d{1,2}\$[A-Za-z\d\\./]{53}/;
|
|
15
|
+
|
|
16
|
+
export const PHONE_NUMBER_REGEX =
|
|
17
|
+
/^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$/;
|
|
18
|
+
|
|
19
|
+
export const IMAGE_URL_REGEX =
|
|
20
|
+
/(((http:\/\/www)|(http:\/\/)|(www))[-a-zA-Z0-9@:%_\\+.~#?&//=]+)\.(jpg|jpeg|gif|png|bmp|tiff|tga|svg)/i;
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { ParamValue, pathcat } from "pathcat";
|
|
2
|
+
import { Options, Response } from "redaxios";
|
|
3
|
+
|
|
4
|
+
import { APIResponse, Endpoints, ErroredAPIResponse } from "./endpoints";
|
|
5
|
+
import { APIRequestOptions, request } from "./request";
|
|
6
|
+
import { DEFAULT_API_URL } from "../constants";
|
|
7
|
+
|
|
8
|
+
// type ExtractRouteParams<T extends string> = string extends T
|
|
9
|
+
// ? string
|
|
10
|
+
// : T extends `${string}:${infer Param}/${infer Rest}`
|
|
11
|
+
// ? Param | ExtractRouteParams<Rest>
|
|
12
|
+
// : T extends `${string}:${infer Param}`
|
|
13
|
+
// ? Param
|
|
14
|
+
// : never;
|
|
15
|
+
|
|
16
|
+
export type ExtractRouteParams<T extends string> = string extends T
|
|
17
|
+
? Record<string, string | number | undefined>
|
|
18
|
+
: T extends `${string}:${infer Param}/${infer Rest}`
|
|
19
|
+
? { [k in Param | keyof ExtractRouteParams<Rest>]: string | number }
|
|
20
|
+
: T extends `${string}:${infer Param}`
|
|
21
|
+
? { [k in Param]: string | number }
|
|
22
|
+
: object;
|
|
23
|
+
|
|
24
|
+
export type ExtractEndpoint<
|
|
25
|
+
Method extends string,
|
|
26
|
+
Path extends string,
|
|
27
|
+
> = Extract<Endpoints, { path: Path; method: Method }>;
|
|
28
|
+
|
|
29
|
+
export type PathsFor<M extends Options["method"]> = Extract<
|
|
30
|
+
Endpoints,
|
|
31
|
+
{ method: M }
|
|
32
|
+
>["path"];
|
|
33
|
+
|
|
34
|
+
export type Query<Path extends string> = ExtractRouteParams<Path> &
|
|
35
|
+
Record<string, string | number | undefined>;
|
|
36
|
+
|
|
37
|
+
export class TonightPassAPIError<T> extends Error {
|
|
38
|
+
public readonly status: number;
|
|
39
|
+
|
|
40
|
+
constructor(
|
|
41
|
+
public readonly response: Response<APIResponse<T>>,
|
|
42
|
+
public readonly data: ErroredAPIResponse,
|
|
43
|
+
) {
|
|
44
|
+
super(data.message);
|
|
45
|
+
|
|
46
|
+
this.status = response.status;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ClientOptions {
|
|
51
|
+
readonly baseURL: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class Client {
|
|
55
|
+
private options;
|
|
56
|
+
public readonly url;
|
|
57
|
+
|
|
58
|
+
constructor(options: ClientOptions) {
|
|
59
|
+
this.options = options;
|
|
60
|
+
this.url = (path: string, params: Record<string, ParamValue>) => {
|
|
61
|
+
const baseURL = this.options.baseURL || DEFAULT_API_URL;
|
|
62
|
+
return pathcat(baseURL, path, params);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
setOptions(options: ClientOptions) {
|
|
67
|
+
this.options = options;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async get<Path extends PathsFor<"GET">>(
|
|
71
|
+
path: Path,
|
|
72
|
+
query?: Query<Path>,
|
|
73
|
+
options?: APIRequestOptions,
|
|
74
|
+
) {
|
|
75
|
+
return this.requester<
|
|
76
|
+
Extract<Endpoints, { path: Path; method: "GET" }>["res"]
|
|
77
|
+
>("GET", path, undefined, query, options);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async post<Path extends Extract<Endpoints, { method: "POST" }>["path"]>(
|
|
81
|
+
path: Path,
|
|
82
|
+
body: Extract<Endpoints, { path: Path; method: "POST" }>["body"],
|
|
83
|
+
query?: Query<Path>,
|
|
84
|
+
options?: APIRequestOptions,
|
|
85
|
+
) {
|
|
86
|
+
return this.requester<
|
|
87
|
+
Extract<Endpoints, { path: Path; method: "POST" }>["res"]
|
|
88
|
+
>("POST", path, body, query, options);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async put<Path extends Extract<Endpoints, { method: "PUT" }>["path"]>(
|
|
92
|
+
path: Path,
|
|
93
|
+
body: Extract<Endpoints, { path: Path; method: "PUT" }>["body"],
|
|
94
|
+
query?: Query<Path>,
|
|
95
|
+
options?: APIRequestOptions,
|
|
96
|
+
) {
|
|
97
|
+
return this.requester<
|
|
98
|
+
Extract<Endpoints, { path: Path; method: "PUT" }>["res"]
|
|
99
|
+
>("PUT", path, body, query, options);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async patch<Path extends Extract<Endpoints, { method: "PATCH" }>["path"]>(
|
|
103
|
+
path: Path,
|
|
104
|
+
body: Extract<Endpoints, { path: Path; method: "PATCH" }>["body"],
|
|
105
|
+
query?: Query<Path>,
|
|
106
|
+
options?: APIRequestOptions,
|
|
107
|
+
) {
|
|
108
|
+
return this.requester<
|
|
109
|
+
Extract<Endpoints, { path: Path; method: "PATCH" }>["res"]
|
|
110
|
+
>("PATCH", path, body, query, options);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async delete<Path extends Extract<Endpoints, { method: "DELETE" }>["path"]>(
|
|
114
|
+
path: Path,
|
|
115
|
+
query?: Query<Path>,
|
|
116
|
+
options?: APIRequestOptions,
|
|
117
|
+
) {
|
|
118
|
+
return this.requester<
|
|
119
|
+
Extract<Endpoints, { path: Path; method: "DELETE" }>["res"]
|
|
120
|
+
>("DELETE", path, undefined, query, options);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private async requester<T>(
|
|
124
|
+
method: Options["method"],
|
|
125
|
+
path: string,
|
|
126
|
+
body: unknown,
|
|
127
|
+
query: Record<string, string | number | undefined> = {},
|
|
128
|
+
options: APIRequestOptions = {},
|
|
129
|
+
) {
|
|
130
|
+
const url = this.url(path, query);
|
|
131
|
+
|
|
132
|
+
if (body !== undefined) {
|
|
133
|
+
if (method === "GET") {
|
|
134
|
+
throw new Error("Cannot send a GET request with a body");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const response: Response<APIResponse<T>> = await request<T>(url, {
|
|
139
|
+
method,
|
|
140
|
+
data: body,
|
|
141
|
+
...options,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// TODO: Add error catcher
|
|
145
|
+
|
|
146
|
+
const result = response.data;
|
|
147
|
+
|
|
148
|
+
if (!result.success) {
|
|
149
|
+
throw new TonightPassAPIError<T>(response, result);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return result.data;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UserIdentifier, UserIdentityGender } from "../../types";
|
|
2
|
+
|
|
3
|
+
export class CreateUserDto {
|
|
4
|
+
identifier: UserIdentifier;
|
|
5
|
+
password: string;
|
|
6
|
+
identity: CreateUserIdentituDto;
|
|
7
|
+
addresses: Location[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class CreateUserIdentituDto {
|
|
11
|
+
firstName: string;
|
|
12
|
+
lastName: string;
|
|
13
|
+
gender: UserIdentityGender;
|
|
14
|
+
profilePictureUrl?: string;
|
|
15
|
+
birthDate: Date;
|
|
16
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Type } from "class-transformer";
|
|
2
|
+
import {
|
|
3
|
+
IsDateString,
|
|
4
|
+
IsEmail,
|
|
5
|
+
IsObject,
|
|
6
|
+
IsOptional,
|
|
7
|
+
IsPhoneNumber,
|
|
8
|
+
IsString,
|
|
9
|
+
IsUrl,
|
|
10
|
+
Length,
|
|
11
|
+
Matches,
|
|
12
|
+
MaxLength,
|
|
13
|
+
MinLength,
|
|
14
|
+
ValidateNested,
|
|
15
|
+
} from "class-validator";
|
|
16
|
+
|
|
17
|
+
import { NAME_REGEX } from "../../../constants/regex";
|
|
18
|
+
import { UserIdentifier, UserIdentity } from "../../types";
|
|
19
|
+
|
|
20
|
+
export class UpdateUserDto {
|
|
21
|
+
@IsOptional()
|
|
22
|
+
@IsObject()
|
|
23
|
+
@ValidateNested()
|
|
24
|
+
@Type(() => UpdateIdentifierDto)
|
|
25
|
+
identifier?: UpdateIdentifierDto;
|
|
26
|
+
|
|
27
|
+
@IsOptional()
|
|
28
|
+
@IsObject()
|
|
29
|
+
@ValidateNested()
|
|
30
|
+
@Type(() => UpdateIdentityDto)
|
|
31
|
+
identity?: UpdateIdentityDto;
|
|
32
|
+
|
|
33
|
+
@IsOptional()
|
|
34
|
+
@IsString()
|
|
35
|
+
@MinLength(6)
|
|
36
|
+
@MaxLength(130)
|
|
37
|
+
password?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class UpdateIdentifierDto
|
|
41
|
+
implements
|
|
42
|
+
Partial<Pick<UserIdentifier, "email" | "phoneNumber" | "username">>
|
|
43
|
+
{
|
|
44
|
+
@IsOptional()
|
|
45
|
+
@IsString()
|
|
46
|
+
@IsEmail()
|
|
47
|
+
email?: string;
|
|
48
|
+
|
|
49
|
+
@IsOptional()
|
|
50
|
+
@IsString()
|
|
51
|
+
@IsPhoneNumber()
|
|
52
|
+
phoneNumber?: string;
|
|
53
|
+
|
|
54
|
+
@IsOptional()
|
|
55
|
+
@IsString()
|
|
56
|
+
@MinLength(3)
|
|
57
|
+
username?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class UpdateIdentityDto
|
|
61
|
+
implements
|
|
62
|
+
Partial<
|
|
63
|
+
Pick<
|
|
64
|
+
UserIdentity,
|
|
65
|
+
| "firstName"
|
|
66
|
+
| "lastName"
|
|
67
|
+
| "displayName"
|
|
68
|
+
| "description"
|
|
69
|
+
| "profilePictureUrl"
|
|
70
|
+
| "bannerUrl"
|
|
71
|
+
| "gender"
|
|
72
|
+
| "birthDate"
|
|
73
|
+
>
|
|
74
|
+
>
|
|
75
|
+
{
|
|
76
|
+
@IsOptional()
|
|
77
|
+
@IsString()
|
|
78
|
+
@Length(2, 50)
|
|
79
|
+
@Matches(NAME_REGEX, {
|
|
80
|
+
message: "First name must be composed of letters only",
|
|
81
|
+
})
|
|
82
|
+
firstName?: string;
|
|
83
|
+
|
|
84
|
+
@IsOptional()
|
|
85
|
+
@IsString()
|
|
86
|
+
@Length(2, 50)
|
|
87
|
+
@Matches(NAME_REGEX, {
|
|
88
|
+
message: "Last name must be composed of letters only",
|
|
89
|
+
})
|
|
90
|
+
lastName?: string;
|
|
91
|
+
|
|
92
|
+
@IsOptional()
|
|
93
|
+
@IsString()
|
|
94
|
+
@Length(1, 32)
|
|
95
|
+
displayName?: string;
|
|
96
|
+
|
|
97
|
+
@IsOptional()
|
|
98
|
+
@IsString()
|
|
99
|
+
@Length(15, 500)
|
|
100
|
+
description?: string;
|
|
101
|
+
|
|
102
|
+
@IsOptional()
|
|
103
|
+
@IsUrl()
|
|
104
|
+
profilePictureUrl?: string | undefined;
|
|
105
|
+
|
|
106
|
+
@IsOptional()
|
|
107
|
+
@IsUrl()
|
|
108
|
+
bannerUrl?: string | undefined;
|
|
109
|
+
|
|
110
|
+
@IsOptional()
|
|
111
|
+
gender?: string;
|
|
112
|
+
|
|
113
|
+
@IsOptional()
|
|
114
|
+
@IsDateString()
|
|
115
|
+
birthDate?: Date;
|
|
116
|
+
}
|