mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
auth0: Expose more of the Job resource in management client (#34657)
* Expose more of the Job resource in auth0 management client * Don't use disguised type assertion with generics, per the common mistakes in the README * Add additional job status * Document job.type discriminator for auto type assertion * Revert interface name change for sending verification emails
This commit is contained in:
committed by
Armando Aguirre
parent
c80715e62e
commit
61876df898
@@ -234,5 +234,79 @@ management.getClients({fields:['name','client_metadata'], include_fields:true})
|
||||
// Handle the error
|
||||
});
|
||||
|
||||
// Get all cients with params (with callback)
|
||||
// Get all clients with params (with callback)
|
||||
management.getClients({fields:['name','client_metadata'], include_fields:true}, (err:Error, clients:auth0.Client[]) => {});
|
||||
|
||||
// Jobs
|
||||
management.getJob({
|
||||
id: 'job_id'
|
||||
}).then((job) => console.log((<auth0.ExportUsersJob>job).fields));
|
||||
|
||||
// job.type can be used as a discriminator for automatic type assertion (no casting needed)
|
||||
management.getJob({
|
||||
id: 'job_id'
|
||||
}).then((job) => {
|
||||
if (job.type === 'users_export') {
|
||||
console.log(job.fields);
|
||||
}
|
||||
});
|
||||
|
||||
management.getJob({
|
||||
id: 'job_id'
|
||||
}, (err, data) => console.log((<auth0.ExportUsersJob>data).fields));
|
||||
|
||||
management.getJob({
|
||||
id: 'job_id'
|
||||
}).then((job) => console.log((<auth0.ImportUsersJob>job).send_completion_email));
|
||||
|
||||
management.getJob({
|
||||
id: 'job_id'
|
||||
}, (err, data) => console.log((<auth0.ImportUsersJob>data).send_completion_email));
|
||||
|
||||
management.getJob({
|
||||
id: 'job_id'
|
||||
}).then((job) => console.log((<auth0.VerificationEmailJob>job).id));
|
||||
|
||||
management.getJob({
|
||||
id: 'job_id'
|
||||
}, (err, data) => console.log((<auth0.VerificationEmailJob>data).id));
|
||||
|
||||
management.importUsers({
|
||||
users: "some file data",
|
||||
connection_id: 'con_id',
|
||||
upsert: true
|
||||
}).then((results) => console.log(results));
|
||||
|
||||
management.importUsers({
|
||||
users: "some file data",
|
||||
connection_id: 'con_id',
|
||||
upsert: true
|
||||
}, (err, data) => console.log(data));
|
||||
|
||||
management.exportUsers({
|
||||
connection_id: 'con_id',
|
||||
fields: [
|
||||
{ name: 'email', export_as: 'email_address' }
|
||||
],
|
||||
format: "json",
|
||||
limit: 500
|
||||
}).then((results) => console.log(results));
|
||||
|
||||
management.exportUsers({
|
||||
connection_id: 'con_id',
|
||||
fields: [
|
||||
{ name: 'email', export_as: 'email_address' }
|
||||
],
|
||||
format: "json",
|
||||
limit: 500
|
||||
}, (err, data) => console.log(data));
|
||||
|
||||
management.sendEmailVerification({
|
||||
client_id: 'client_id',
|
||||
user_id: 'user_id'
|
||||
}).then((results) => console.log(results));
|
||||
|
||||
management.sendEmailVerification({
|
||||
client_id: 'client_id',
|
||||
user_id: 'user_id'
|
||||
}, (err, data) => console.log(data));
|
||||
|
||||
74
types/auth0/index.d.ts
vendored
74
types/auth0/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/auth0/node-auth0
|
||||
// Definitions by: Seth Westphal <https://github.com/westy92>
|
||||
// Ian Howe <https://github.com/ianhowe76>
|
||||
// Alex Bjørlig <https://github.com/dauledk>
|
||||
// Alex Bjørlig <https://github.com/dauledk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -509,13 +509,64 @@ export interface StatsParams {
|
||||
to: string;
|
||||
}
|
||||
|
||||
export type Job = ImportUsersJob | ExportUsersJob | VerificationEmailJob;
|
||||
|
||||
export type JobFormat = 'csv' | 'json';
|
||||
|
||||
export type JobStatus = 'pending' | 'processing' | 'completed' | 'failed';
|
||||
|
||||
export interface ExportUsersJob {
|
||||
id: string;
|
||||
type: 'users_export';
|
||||
status: JobStatus;
|
||||
created_at?: string;
|
||||
connection_id?: string;
|
||||
fields?: ExportUserField[];
|
||||
location?: string;
|
||||
format?: JobFormat;
|
||||
}
|
||||
|
||||
export interface ImportUsersJob {
|
||||
id: string;
|
||||
type: 'users_import';
|
||||
status: JobStatus;
|
||||
created_at?: string;
|
||||
connection_id?: string;
|
||||
upsert?: boolean;
|
||||
external_id?: string;
|
||||
send_completion_email?: boolean;
|
||||
}
|
||||
|
||||
export interface VerificationEmailJob {
|
||||
id: string;
|
||||
type: 'verification_email';
|
||||
status: JobStatus;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface ImportUsersOptions {
|
||||
connection_id: string;
|
||||
users: string;
|
||||
users: string;
|
||||
connection_id: string;
|
||||
upsert?: boolean;
|
||||
external_id?: string;
|
||||
send_completion_email?: boolean;
|
||||
}
|
||||
|
||||
export interface ExportUsersOptions {
|
||||
connection_id?: string;
|
||||
format?: JobFormat;
|
||||
limit?: number;
|
||||
fields?: ExportUserField[]
|
||||
}
|
||||
|
||||
export interface UserIdParams {
|
||||
user_id: string;
|
||||
user_id: string;
|
||||
client_id?: string;
|
||||
}
|
||||
|
||||
export interface ExportUserField {
|
||||
name: string;
|
||||
export_as?: string;
|
||||
}
|
||||
|
||||
export interface PasswordChangeTicketParams {
|
||||
@@ -816,14 +867,17 @@ export class ManagementClient {
|
||||
|
||||
|
||||
// Jobs
|
||||
getJob(params: ObjectWithId): Promise<any>;
|
||||
getJob(params: ObjectWithId, cb?: (err: Error, data: any) => void): void;
|
||||
getJob(params: ObjectWithId): Promise<Job>;
|
||||
getJob(params: ObjectWithId, cb?: (err: Error, data: Job) => void): void;
|
||||
|
||||
importUsers(data: ImportUsersOptions): Promise<any>;
|
||||
importUsers(data: ImportUsersOptions, cb?: (err: Error, data: any) => void): void;
|
||||
importUsers(data: ImportUsersOptions): Promise<ImportUsersJob>;
|
||||
importUsers(data: ImportUsersOptions, cb?: (err: Error, data: ImportUsersJob) => void): void;
|
||||
|
||||
sendEmailVerification(data: UserIdParams): Promise<any>;
|
||||
sendEmailVerification(data: UserIdParams, cb?: (err: Error, data: any) => void): void;
|
||||
exportUsers(data: ExportUsersOptions): Promise<ExportUsersJob>;
|
||||
exportUsers(data: ExportUsersOptions, cb?: (err: Error, data: ExportUsersJob) => void): void;
|
||||
|
||||
sendEmailVerification(data: UserIdParams): Promise<VerificationEmailJob>;
|
||||
sendEmailVerification(data: UserIdParams, cb?: (err: Error, data: VerificationEmailJob) => void): void;
|
||||
|
||||
// Tickets
|
||||
createPasswordChangeTicket(params: PasswordChangeTicketParams): Promise<PasswordChangeTicketResponse>;
|
||||
|
||||
Reference in New Issue
Block a user