Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: change language type to be more strict in magic link options #219

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/classes/Auth/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { MagicLinkChannel, MagicLinkType } from '../../generated';
import { MagicLinkChannel, MagicLinkLanguage, MagicLinkType } from '../../generated';

export { MagicLinkType, MagicLink, MagicLinkChannel } from '../../generated';
export { MagicLinkType, MagicLink, MagicLinkChannel, MagicLinkLanguage } from '../../generated';

type MagicLinkArgsBase = {
type: MagicLinkType;
send: boolean;
};

type MagicLinkWithEmailArgs = { email: string } & MagicLinkArgsBase;
type MagicLinkWithPhoneArgs = { phone: string } & MagicLinkArgsBase;
type MagicLinkWithUserArgs = { userId: string; channel: MagicLinkChannel } & MagicLinkArgsBase;

export type MagicLinkWithEmailArgs = { email: string } & MagicLinkArgsBase;
export type MagicLinkWithPhoneArgs = { phone: string } & MagicLinkArgsBase;
export type MagicLinkWithUserArgs = { userId: string; channel: MagicLinkChannel } & MagicLinkArgsBase;
export type CreateMagicLinkArgs = MagicLinkWithEmailArgs | MagicLinkWithPhoneArgs | MagicLinkWithUserArgs;
export type MagicLinkOptions = {
language?: string;
language?: MagicLinkLanguage;
magicLinkPath?: string;
redirectUrl?: string;
ttl?: number;
Expand Down
1 change: 1 addition & 0 deletions src/generated/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ models/ListPaginatedUsersItem.ts
models/ListPaginatedUsersResponse.ts
models/MagicLink.ts
models/MagicLinkChannel.ts
models/MagicLinkLanguage.ts
models/MagicLinkResponse.ts
models/MagicLinkType.ts
models/Model400Error.ts
Expand Down
19 changes: 13 additions & 6 deletions src/generated/models/CreateMagicLinkRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ import {
MagicLinkChannelToJSON,
MagicLinkChannelToJSONTyped,
} from './MagicLinkChannel';
import type { MagicLinkLanguage } from './MagicLinkLanguage';
import {
MagicLinkLanguageFromJSON,
MagicLinkLanguageFromJSONTyped,
MagicLinkLanguageToJSON,
MagicLinkLanguageToJSONTyped,
} from './MagicLinkLanguage';
import type { MagicLinkType } from './MagicLinkType';
import {
MagicLinkTypeFromJSON,
Expand Down Expand Up @@ -47,11 +54,11 @@ export interface CreateMagicLinkRequest {
*/
email?: string;
/**
* language of the email to send (optional)
* @type {string}
*
* @type {MagicLinkLanguage}
* @memberof CreateMagicLinkRequest
*/
language?: string;
language?: MagicLinkLanguage;
/**
* must be a relative url
* @type {string}
Expand All @@ -77,7 +84,7 @@ export interface CreateMagicLinkRequest {
*/
send?: boolean;
/**
*
* time to live in minutes
* @type {number}
* @memberof CreateMagicLinkRequest
*/
Expand Down Expand Up @@ -117,7 +124,7 @@ export function CreateMagicLinkRequestFromJSONTyped(json: any, ignoreDiscriminat

'channel': json['channel'] == null ? undefined : MagicLinkChannelFromJSON(json['channel']),
'email': json['email'] == null ? undefined : json['email'],
'language': json['language'] == null ? undefined : json['language'],
'language': json['language'] == null ? undefined : MagicLinkLanguageFromJSON(json['language']),
'magicLinkPath': json['magic_link_path'] == null ? undefined : json['magic_link_path'],
'phone': json['phone'] == null ? undefined : json['phone'],
'redirectUrl': json['redirect_url'] == null ? undefined : json['redirect_url'],
Expand All @@ -141,7 +148,7 @@ export function CreateMagicLinkRequestToJSONTyped(value?: CreateMagicLinkRequest

'channel': MagicLinkChannelToJSON(value['channel']),
'email': value['email'],
'language': value['language'],
'language': MagicLinkLanguageToJSON(value['language']),
'magic_link_path': value['magicLinkPath'],
'phone': value['phone'],
'redirect_url': value['redirectUrl'],
Expand Down
2 changes: 1 addition & 1 deletion src/generated/models/MagicLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export interface MagicLink {
*/
secret: string;
/**
*
* time to live in minutes
* @type {number}
* @memberof MagicLink
*/
Expand Down
2 changes: 1 addition & 1 deletion src/generated/models/MagicLinkChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


/**
*
* The channel for magic link delivery: "email" or "phone". Required if "send" is true.
* @export
*/
export const MagicLinkChannel = {
Expand Down
58 changes: 58 additions & 0 deletions src/generated/models/MagicLinkLanguage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* tslint:disable */
/* eslint-disable */
/**
* Passage Management API
* Passage\'s management API to manage your Passage apps and users.
*
* The version of the OpenAPI document: 1
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


/**
* language of the email or sms to send
* @export
*/
export const MagicLinkLanguage = {
De: 'de',
En: 'en',
Es: 'es',
It: 'it',
Pl: 'pl',
Pt: 'pt',
Zh: 'zh'
} as const;
export type MagicLinkLanguage = typeof MagicLinkLanguage[keyof typeof MagicLinkLanguage];


export function instanceOfMagicLinkLanguage(value: any): boolean {
for (const key in MagicLinkLanguage) {
if (Object.prototype.hasOwnProperty.call(MagicLinkLanguage, key)) {
if (MagicLinkLanguage[key as keyof typeof MagicLinkLanguage] === value) {
return true;
}
}
}
return false;
}

export function MagicLinkLanguageFromJSON(json: any): MagicLinkLanguage {
return MagicLinkLanguageFromJSONTyped(json, false);
}

export function MagicLinkLanguageFromJSONTyped(json: any, ignoreDiscriminator: boolean): MagicLinkLanguage {
return json as MagicLinkLanguage;
}

export function MagicLinkLanguageToJSON(value?: MagicLinkLanguage | null): any {
return value as any;
}

export function MagicLinkLanguageToJSONTyped(value: any, ignoreDiscriminator: boolean): MagicLinkLanguage {
return value as MagicLinkLanguage;
}

2 changes: 1 addition & 1 deletion src/generated/models/MagicLinkType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


/**
*
* The type of magic link to create: "login" or "verify_identifier". Defaults to "login".
* @export
*/
export const MagicLinkType = {
Expand Down
1 change: 1 addition & 0 deletions src/generated/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './ListPaginatedUsersItem';
export * from './ListPaginatedUsersResponse';
export * from './MagicLink';
export * from './MagicLinkChannel';
export * from './MagicLinkLanguage';
export * from './MagicLinkResponse';
export * from './MagicLinkType';
export * from './Model400Error';
Expand Down
Loading