From f1bb0ace151c26da4c281e503c60bd2b6bd61e28 Mon Sep 17 00:00:00 2001 From: aakashg00 Date: Mon, 9 Mar 2026 02:50:21 -0400 Subject: [PATCH 1/7] implemented accept account request, changed existing account request methods to support jwt --- src/internal/api/authApi.ts | 152 ++++++++++++++---- .../acceptAccountRequestResponseModel.ts | 49 ++++++ .../acceptAccountRequestResponseProject.ts | 47 ++++++ .../model/acceptAccountRequestResponseUser.ts | 82 ++++++++++ src/internal/model/models.ts | 11 ++ src/lib/auth.ts | 104 ++++++++---- 6 files changed, 381 insertions(+), 64 deletions(-) create mode 100644 src/internal/model/acceptAccountRequestResponseModel.ts create mode 100644 src/internal/model/acceptAccountRequestResponseProject.ts create mode 100644 src/internal/model/acceptAccountRequestResponseUser.ts diff --git a/src/internal/api/authApi.ts b/src/internal/api/authApi.ts index 6752e12..02b3680 100644 --- a/src/internal/api/authApi.ts +++ b/src/internal/api/authApi.ts @@ -14,6 +14,7 @@ import localVarRequest from 'request'; import http from 'http'; /* tslint:disable:no-unused-locals */ +import { AcceptAccountRequestResponseModel } from '../model/acceptAccountRequestResponseModel'; import { IssueApiKeyRequest } from '../model/issueApiKeyRequest'; import { IssueApiKeyResponse } from '../model/issueApiKeyResponse'; import { IssueJWTResponse } from '../model/issueJWTResponse'; @@ -109,6 +110,121 @@ export class AuthApi { this.interceptors.push(interceptor); } + /** + * Accepts a pending account request: creates the user, optionally creates/links a project (for ADMIN requests with a projectName), and deletes the pending request. Requires admin or superadmin credentials. + * @summary Accept an account request + * @param id ID of the account request to accept + * @param xUserPassword Password of the admin or superadmin user + * @param xUserEmail Email of an admin or superadmin user + */ + public async authControllerAcceptAccountRequest( + id: string, + xUserPassword?: string, + xUserEmail?: string, + options: { headers: { [name: string]: string } } = { headers: {} } + ): Promise<{ + response: http.IncomingMessage; + body: AcceptAccountRequestResponseModel; + }> { + const localVarPath = + this.basePath + + '/auth/account-request/{id}/accept'.replace( + '{' + 'id' + '}', + encodeURIComponent(String(id)) + ); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign( + {}, + this._defaultHeaders + ); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + // verify required parameter 'id' is not null or undefined + if (id === null || id === undefined) { + throw new Error( + 'Required parameter id was null or undefined when calling authControllerAcceptAccountRequest.' + ); + } + + localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( + xUserPassword, + 'string' + ); + localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize( + xUserEmail, + 'string' + ); + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + if (this.authentications.API_Key.accessToken) { + authenticationPromise = authenticationPromise.then(() => + this.authentications.API_Key.applyToRequest(localVarRequestOptions) + ); + } + authenticationPromise = authenticationPromise.then(() => + this.authentications.default.applyToRequest(localVarRequestOptions) + ); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => + interceptor(localVarRequestOptions) + ); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ + response: http.IncomingMessage; + body: AcceptAccountRequestResponseModel; + }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if ( + response.statusCode && + response.statusCode >= 200 && + response.statusCode <= 299 + ) { + body = ObjectSerializer.deserialize( + body, + 'AcceptAccountRequestResponseModel' + ); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } /** * Allows a prospective user to submit a request for a new account. The request is stored and can be reviewed by an admin. * @summary Submit a new account request @@ -335,8 +451,8 @@ export class AuthApi { */ public async authControllerDeleteAccountRequest( id: string, - xUserPassword: string, - xUserEmail: string, + xUserPassword?: string, + xUserEmail?: string, options: { headers: { [name: string]: string } } = { headers: {} } ): Promise<{ response: http.IncomingMessage; @@ -369,20 +485,6 @@ export class AuthApi { ); } - // verify required parameter 'xUserPassword' is not null or undefined - if (xUserPassword === null || xUserPassword === undefined) { - throw new Error( - 'Required parameter xUserPassword was null or undefined when calling authControllerDeleteAccountRequest.' - ); - } - - // verify required parameter 'xUserEmail' is not null or undefined - if (xUserEmail === null || xUserEmail === undefined) { - throw new Error( - 'Required parameter xUserEmail was null or undefined when calling authControllerDeleteAccountRequest.' - ); - } - localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( xUserPassword, 'string' @@ -549,8 +651,8 @@ export class AuthApi { * @param xUserEmail Email of an admin or superadmin user */ public async authControllerGetAllAccountRequests( - xUserPassword: string, - xUserEmail: string, + xUserPassword?: string, + xUserEmail?: string, options: { headers: { [name: string]: string } } = { headers: {} } ): Promise<{ response: http.IncomingMessage; @@ -571,20 +673,6 @@ export class AuthApi { } let localVarFormParams: any = {}; - // verify required parameter 'xUserPassword' is not null or undefined - if (xUserPassword === null || xUserPassword === undefined) { - throw new Error( - 'Required parameter xUserPassword was null or undefined when calling authControllerGetAllAccountRequests.' - ); - } - - // verify required parameter 'xUserEmail' is not null or undefined - if (xUserEmail === null || xUserEmail === undefined) { - throw new Error( - 'Required parameter xUserEmail was null or undefined when calling authControllerGetAllAccountRequests.' - ); - } - localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( xUserPassword, 'string' diff --git a/src/internal/model/acceptAccountRequestResponseModel.ts b/src/internal/model/acceptAccountRequestResponseModel.ts new file mode 100644 index 0000000..a726444 --- /dev/null +++ b/src/internal/model/acceptAccountRequestResponseModel.ts @@ -0,0 +1,49 @@ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; +import { AcceptAccountRequestResponseProject } from './acceptAccountRequestResponseProject'; +import { AcceptAccountRequestResponseUser } from './acceptAccountRequestResponseUser'; + +export class AcceptAccountRequestResponseModel { + /** + * The created user + */ + 'user': AcceptAccountRequestResponseUser; + /** + * The created or linked project (if applicable) + */ + 'project'?: AcceptAccountRequestResponseProject; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }> = [ + { + name: 'user', + baseName: 'user', + type: 'AcceptAccountRequestResponseUser', + }, + { + name: 'project', + baseName: 'project', + type: 'AcceptAccountRequestResponseProject', + }, + ]; + + static getAttributeTypeMap() { + return AcceptAccountRequestResponseModel.attributeTypeMap; + } +} diff --git a/src/internal/model/acceptAccountRequestResponseProject.ts b/src/internal/model/acceptAccountRequestResponseProject.ts new file mode 100644 index 0000000..d30775b --- /dev/null +++ b/src/internal/model/acceptAccountRequestResponseProject.ts @@ -0,0 +1,47 @@ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; + +export class AcceptAccountRequestResponseProject { + /** + * Project ID + */ + 'id': number; + /** + * Project name + */ + 'name': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }> = [ + { + name: 'id', + baseName: 'id', + type: 'number', + }, + { + name: 'name', + baseName: 'name', + type: 'string', + }, + ]; + + static getAttributeTypeMap() { + return AcceptAccountRequestResponseProject.attributeTypeMap; + } +} diff --git a/src/internal/model/acceptAccountRequestResponseUser.ts b/src/internal/model/acceptAccountRequestResponseUser.ts new file mode 100644 index 0000000..5f3ace3 --- /dev/null +++ b/src/internal/model/acceptAccountRequestResponseUser.ts @@ -0,0 +1,82 @@ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; + +export class AcceptAccountRequestResponseUser { + /** + * User ID + */ + 'id': number; + /** + * Email + */ + 'email': string; + /** + * Name + */ + 'name': string; + /** + * User type + */ + 'type': AcceptAccountRequestResponseUser.TypeEnum; + /** + * Project IDs the user is linked to + */ + 'projectIds'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }> = [ + { + name: 'id', + baseName: 'id', + type: 'number', + }, + { + name: 'email', + baseName: 'email', + type: 'string', + }, + { + name: 'name', + baseName: 'name', + type: 'string', + }, + { + name: 'type', + baseName: 'type', + type: 'AcceptAccountRequestResponseUser.TypeEnum', + }, + { + name: 'projectIds', + baseName: 'projectIds', + type: 'Array', + }, + ]; + + static getAttributeTypeMap() { + return AcceptAccountRequestResponseUser.attributeTypeMap; + } +} + +export namespace AcceptAccountRequestResponseUser { + export enum TypeEnum { + Superadmin = 'SUPERADMIN', + Admin = 'ADMIN', + User = 'USER', + } +} diff --git a/src/internal/model/models.ts b/src/internal/model/models.ts index e9e2376..88907ad 100644 --- a/src/internal/model/models.ts +++ b/src/internal/model/models.ts @@ -1,5 +1,8 @@ import localVarRequest from 'request'; +export * from './acceptAccountRequestResponseModel'; +export * from './acceptAccountRequestResponseProject'; +export * from './acceptAccountRequestResponseUser'; export * from './accessKey'; export * from './aggregateInterval'; export * from './analyticsConfigResponse'; @@ -88,6 +91,9 @@ export interface RequestDetailedFile { export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; +import { AcceptAccountRequestResponseModel } from './acceptAccountRequestResponseModel'; +import { AcceptAccountRequestResponseProject } from './acceptAccountRequestResponseProject'; +import { AcceptAccountRequestResponseUser } from './acceptAccountRequestResponseUser'; import { AccessKey } from './accessKey'; import { AggregateInterval } from './aggregateInterval'; import { AnalyticsConfigResponse } from './analyticsConfigResponse'; @@ -177,6 +183,8 @@ let primitives = [ ]; let enumsMap: { [index: string]: any } = { + 'AcceptAccountRequestResponseUser.TypeEnum': + AcceptAccountRequestResponseUser.TypeEnum, AggregateInterval: AggregateInterval, 'NewAccountRequestResponse.UserTypeEnum': NewAccountRequestResponse.UserTypeEnum, @@ -186,6 +194,9 @@ let enumsMap: { [index: string]: any } = { }; let typeMap: { [index: string]: any } = { + AcceptAccountRequestResponseModel: AcceptAccountRequestResponseModel, + AcceptAccountRequestResponseProject: AcceptAccountRequestResponseProject, + AcceptAccountRequestResponseUser: AcceptAccountRequestResponseUser, AccessKey: AccessKey, AnalyticsConfigResponse: AnalyticsConfigResponse, ClickEventProperties: ClickEventProperties, diff --git a/src/lib/auth.ts b/src/lib/auth.ts index e3b8231..702d287 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -1,16 +1,20 @@ +import { IncomingMessage } from 'http'; import { + AcceptAccountRequestResponseModel, AuthApi, - IssueApiKeyResponse, IssueApiKeyRequest, + IssueApiKeyResponse, IssueJWTResponse, NewAccountRequestResponse, NewAccountRequestsResponse, RequestNewAccountModel, } from '../internal/api'; -import { validateString } from './validators'; +import { validateString, validateUserCredentials } from './validators'; export type UserCredentials = string | { email: string; password: string }; +export type UserType = 'SUPERADMIN' | 'ADMIN' | 'USER'; + export class AuthAPI { private internalApi: AuthApi; private apiKey?: string; @@ -107,7 +111,7 @@ export class AuthAPI { email: string; name: string; password: string; - userType: RequestNewAccountModel.UserTypeEnum; + userType: UserType; projectName?: string; }): Promise { let { email, name, password, userType, projectName } = options; @@ -125,7 +129,7 @@ export class AuthAPI { email, name, password, - userType, + userType: userType as unknown as RequestNewAccountModel.UserTypeEnum, projectName, }; const result = await this.internalApi.authControllerCreateAccountRequest( @@ -138,50 +142,86 @@ export class AuthAPI { } async getAllAccountRequests(options: { - email: string; - password: string; + credentials: UserCredentials; }): Promise { - let { email, password } = options; + const { credentials } = options; - validateString(email, 'The email must be nonempty'); - validateString(password, 'The password must be nonempty'); + validateUserCredentials(credentials); - email = email.trim(); - password = password.trim(); - try { - const result = await this.internalApi.authControllerGetAllAccountRequests( - password, - email + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerGetAllAccountRequests( + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerGetAllAccountRequests( + credentials.password, + credentials.email ); - return result.body; - } catch (e) { - throw e; } + return res.body; + } + + async acceptAccountRequest(options: { + id: string; + credentials: UserCredentials; + }): Promise { + let { id, credentials } = options; + + validateString(id, 'The request ID must be nonempty'); + validateUserCredentials(credentials); + + id = id.trim(); + + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerAcceptAccountRequest( + id, + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerAcceptAccountRequest( + id, + credentials.password, + credentials.email + ); + } + return res.body; } async deleteAccountRequest(options: { id: string; - email: string; - password: string; + credentials: UserCredentials; }): Promise { - let { id, email, password } = options; + let { id, credentials } = options; validateString(id, 'The request ID must be nonempty'); - validateString(email, 'The email must be nonempty'); - validateString(password, 'The password must be nonempty'); + validateUserCredentials(credentials); id = id.trim(); - email = email.trim(); - password = password.trim(); - try { - const result = await this.internalApi.authControllerDeleteAccountRequest( + + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerDeleteAccountRequest( id, - password, - email + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerDeleteAccountRequest( + id, + credentials.password, + credentials.email ); - return result.body; - } catch (e) { - throw e; } + return res.body; } } From bcc712288c5eabcb3ef3689268ef69bfebb5daeb Mon Sep 17 00:00:00 2001 From: aakashg00 Date: Mon, 9 Mar 2026 03:18:44 -0400 Subject: [PATCH 2/7] added try catch to auth methods --- src/lib/auth.ts | 104 +++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 702d287..51645c8 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -148,21 +148,25 @@ export class AuthAPI { validateUserCredentials(credentials); - let res: { body: any; response?: IncomingMessage }; - - if (typeof credentials == 'string') { - this.internalApi.accessToken = credentials; - res = await this.internalApi.authControllerGetAllAccountRequests( - undefined, - undefined - ); - } else { - res = await this.internalApi.authControllerGetAllAccountRequests( - credentials.password, - credentials.email - ); + try { + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerGetAllAccountRequests( + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerGetAllAccountRequests( + credentials.password, + credentials.email + ); + } + return res.body; + } catch (e) { + throw e; } - return res.body; } async acceptAccountRequest(options: { @@ -176,23 +180,27 @@ export class AuthAPI { id = id.trim(); - let res: { body: any; response?: IncomingMessage }; - - if (typeof credentials == 'string') { - this.internalApi.accessToken = credentials; - res = await this.internalApi.authControllerAcceptAccountRequest( - id, - undefined, - undefined - ); - } else { - res = await this.internalApi.authControllerAcceptAccountRequest( - id, - credentials.password, - credentials.email - ); + try { + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerAcceptAccountRequest( + id, + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerAcceptAccountRequest( + id, + credentials.password, + credentials.email + ); + } + return res.body; + } catch (e) { + throw e; } - return res.body; } async deleteAccountRequest(options: { @@ -206,22 +214,26 @@ export class AuthAPI { id = id.trim(); - let res: { body: any; response?: IncomingMessage }; - - if (typeof credentials == 'string') { - this.internalApi.accessToken = credentials; - res = await this.internalApi.authControllerDeleteAccountRequest( - id, - undefined, - undefined - ); - } else { - res = await this.internalApi.authControllerDeleteAccountRequest( - id, - credentials.password, - credentials.email - ); + try { + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerDeleteAccountRequest( + id, + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerDeleteAccountRequest( + id, + credentials.password, + credentials.email + ); + } + return res.body; + } catch (e) { + throw e; } - return res.body; } } From ac706d8f39efa30222f4b992eb81ff63a300d8c5 Mon Sep 17 00:00:00 2001 From: aakashg00 Date: Mon, 9 Mar 2026 02:50:21 -0400 Subject: [PATCH 3/7] implemented accept account request, changed existing account request methods to support jwt --- src/internal/api/authApi.ts | 1 + .../acceptAccountRequestResponseModel.ts | 49 +++++++++ .../acceptAccountRequestResponseProject.ts | 47 ++++++++ .../model/acceptAccountRequestResponseUser.ts | 82 ++++++++++++++ src/internal/model/models.ts | 11 ++ src/lib/auth.ts | 104 ++++++++++++------ 6 files changed, 262 insertions(+), 32 deletions(-) create mode 100644 src/internal/model/acceptAccountRequestResponseModel.ts create mode 100644 src/internal/model/acceptAccountRequestResponseProject.ts create mode 100644 src/internal/model/acceptAccountRequestResponseUser.ts diff --git a/src/internal/api/authApi.ts b/src/internal/api/authApi.ts index f8bc9a8..e8fc8fb 100644 --- a/src/internal/api/authApi.ts +++ b/src/internal/api/authApi.ts @@ -14,6 +14,7 @@ import localVarRequest from 'request'; import http from 'http'; /* tslint:disable:no-unused-locals */ +import { AcceptAccountRequestResponseModel } from '../model/acceptAccountRequestResponseModel'; import { IssueApiKeyRequest } from '../model/issueApiKeyRequest'; import { IssueApiKeyResponse } from '../model/issueApiKeyResponse'; import { IssueJWTResponse } from '../model/issueJWTResponse'; diff --git a/src/internal/model/acceptAccountRequestResponseModel.ts b/src/internal/model/acceptAccountRequestResponseModel.ts new file mode 100644 index 0000000..a726444 --- /dev/null +++ b/src/internal/model/acceptAccountRequestResponseModel.ts @@ -0,0 +1,49 @@ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; +import { AcceptAccountRequestResponseProject } from './acceptAccountRequestResponseProject'; +import { AcceptAccountRequestResponseUser } from './acceptAccountRequestResponseUser'; + +export class AcceptAccountRequestResponseModel { + /** + * The created user + */ + 'user': AcceptAccountRequestResponseUser; + /** + * The created or linked project (if applicable) + */ + 'project'?: AcceptAccountRequestResponseProject; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }> = [ + { + name: 'user', + baseName: 'user', + type: 'AcceptAccountRequestResponseUser', + }, + { + name: 'project', + baseName: 'project', + type: 'AcceptAccountRequestResponseProject', + }, + ]; + + static getAttributeTypeMap() { + return AcceptAccountRequestResponseModel.attributeTypeMap; + } +} diff --git a/src/internal/model/acceptAccountRequestResponseProject.ts b/src/internal/model/acceptAccountRequestResponseProject.ts new file mode 100644 index 0000000..d30775b --- /dev/null +++ b/src/internal/model/acceptAccountRequestResponseProject.ts @@ -0,0 +1,47 @@ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; + +export class AcceptAccountRequestResponseProject { + /** + * Project ID + */ + 'id': number; + /** + * Project name + */ + 'name': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }> = [ + { + name: 'id', + baseName: 'id', + type: 'number', + }, + { + name: 'name', + baseName: 'name', + type: 'string', + }, + ]; + + static getAttributeTypeMap() { + return AcceptAccountRequestResponseProject.attributeTypeMap; + } +} diff --git a/src/internal/model/acceptAccountRequestResponseUser.ts b/src/internal/model/acceptAccountRequestResponseUser.ts new file mode 100644 index 0000000..5f3ace3 --- /dev/null +++ b/src/internal/model/acceptAccountRequestResponseUser.ts @@ -0,0 +1,82 @@ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; + +export class AcceptAccountRequestResponseUser { + /** + * User ID + */ + 'id': number; + /** + * Email + */ + 'email': string; + /** + * Name + */ + 'name': string; + /** + * User type + */ + 'type': AcceptAccountRequestResponseUser.TypeEnum; + /** + * Project IDs the user is linked to + */ + 'projectIds'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }> = [ + { + name: 'id', + baseName: 'id', + type: 'number', + }, + { + name: 'email', + baseName: 'email', + type: 'string', + }, + { + name: 'name', + baseName: 'name', + type: 'string', + }, + { + name: 'type', + baseName: 'type', + type: 'AcceptAccountRequestResponseUser.TypeEnum', + }, + { + name: 'projectIds', + baseName: 'projectIds', + type: 'Array', + }, + ]; + + static getAttributeTypeMap() { + return AcceptAccountRequestResponseUser.attributeTypeMap; + } +} + +export namespace AcceptAccountRequestResponseUser { + export enum TypeEnum { + Superadmin = 'SUPERADMIN', + Admin = 'ADMIN', + User = 'USER', + } +} diff --git a/src/internal/model/models.ts b/src/internal/model/models.ts index 556227b..cec88dd 100644 --- a/src/internal/model/models.ts +++ b/src/internal/model/models.ts @@ -1,5 +1,8 @@ import localVarRequest from 'request'; +export * from './acceptAccountRequestResponseModel'; +export * from './acceptAccountRequestResponseProject'; +export * from './acceptAccountRequestResponseUser'; export * from './accessKey'; export * from './aggregateInterval'; export * from './analyticsConfigResponse'; @@ -85,6 +88,9 @@ export interface RequestDetailedFile { export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; +import { AcceptAccountRequestResponseModel } from './acceptAccountRequestResponseModel'; +import { AcceptAccountRequestResponseProject } from './acceptAccountRequestResponseProject'; +import { AcceptAccountRequestResponseUser } from './acceptAccountRequestResponseUser'; import { AccessKey } from './accessKey'; import { AggregateInterval } from './aggregateInterval'; import { AnalyticsConfigResponse } from './analyticsConfigResponse'; @@ -171,12 +177,17 @@ let primitives = [ ]; let enumsMap: { [index: string]: any } = { + 'AcceptAccountRequestResponseUser.TypeEnum': + AcceptAccountRequestResponseUser.TypeEnum, AggregateInterval: AggregateInterval, 'SetUserTypeModel.TypeEnum': SetUserTypeModel.TypeEnum, 'UserResponse.TypeEnum': UserResponse.TypeEnum, }; let typeMap: { [index: string]: any } = { + AcceptAccountRequestResponseModel: AcceptAccountRequestResponseModel, + AcceptAccountRequestResponseProject: AcceptAccountRequestResponseProject, + AcceptAccountRequestResponseUser: AcceptAccountRequestResponseUser, AccessKey: AccessKey, AnalyticsConfigResponse: AnalyticsConfigResponse, ClickEventProperties: ClickEventProperties, diff --git a/src/lib/auth.ts b/src/lib/auth.ts index e3b8231..702d287 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -1,16 +1,20 @@ +import { IncomingMessage } from 'http'; import { + AcceptAccountRequestResponseModel, AuthApi, - IssueApiKeyResponse, IssueApiKeyRequest, + IssueApiKeyResponse, IssueJWTResponse, NewAccountRequestResponse, NewAccountRequestsResponse, RequestNewAccountModel, } from '../internal/api'; -import { validateString } from './validators'; +import { validateString, validateUserCredentials } from './validators'; export type UserCredentials = string | { email: string; password: string }; +export type UserType = 'SUPERADMIN' | 'ADMIN' | 'USER'; + export class AuthAPI { private internalApi: AuthApi; private apiKey?: string; @@ -107,7 +111,7 @@ export class AuthAPI { email: string; name: string; password: string; - userType: RequestNewAccountModel.UserTypeEnum; + userType: UserType; projectName?: string; }): Promise { let { email, name, password, userType, projectName } = options; @@ -125,7 +129,7 @@ export class AuthAPI { email, name, password, - userType, + userType: userType as unknown as RequestNewAccountModel.UserTypeEnum, projectName, }; const result = await this.internalApi.authControllerCreateAccountRequest( @@ -138,50 +142,86 @@ export class AuthAPI { } async getAllAccountRequests(options: { - email: string; - password: string; + credentials: UserCredentials; }): Promise { - let { email, password } = options; + const { credentials } = options; - validateString(email, 'The email must be nonempty'); - validateString(password, 'The password must be nonempty'); + validateUserCredentials(credentials); - email = email.trim(); - password = password.trim(); - try { - const result = await this.internalApi.authControllerGetAllAccountRequests( - password, - email + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerGetAllAccountRequests( + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerGetAllAccountRequests( + credentials.password, + credentials.email ); - return result.body; - } catch (e) { - throw e; } + return res.body; + } + + async acceptAccountRequest(options: { + id: string; + credentials: UserCredentials; + }): Promise { + let { id, credentials } = options; + + validateString(id, 'The request ID must be nonempty'); + validateUserCredentials(credentials); + + id = id.trim(); + + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerAcceptAccountRequest( + id, + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerAcceptAccountRequest( + id, + credentials.password, + credentials.email + ); + } + return res.body; } async deleteAccountRequest(options: { id: string; - email: string; - password: string; + credentials: UserCredentials; }): Promise { - let { id, email, password } = options; + let { id, credentials } = options; validateString(id, 'The request ID must be nonempty'); - validateString(email, 'The email must be nonempty'); - validateString(password, 'The password must be nonempty'); + validateUserCredentials(credentials); id = id.trim(); - email = email.trim(); - password = password.trim(); - try { - const result = await this.internalApi.authControllerDeleteAccountRequest( + + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerDeleteAccountRequest( id, - password, - email + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerDeleteAccountRequest( + id, + credentials.password, + credentials.email ); - return result.body; - } catch (e) { - throw e; } + return res.body; } } From c4a925af32353ace38fcfd8f8568a208b9824e80 Mon Sep 17 00:00:00 2001 From: aakashg00 Date: Mon, 9 Mar 2026 03:18:44 -0400 Subject: [PATCH 4/7] added try catch to auth methods --- src/lib/auth.ts | 104 +++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 702d287..51645c8 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -148,21 +148,25 @@ export class AuthAPI { validateUserCredentials(credentials); - let res: { body: any; response?: IncomingMessage }; - - if (typeof credentials == 'string') { - this.internalApi.accessToken = credentials; - res = await this.internalApi.authControllerGetAllAccountRequests( - undefined, - undefined - ); - } else { - res = await this.internalApi.authControllerGetAllAccountRequests( - credentials.password, - credentials.email - ); + try { + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerGetAllAccountRequests( + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerGetAllAccountRequests( + credentials.password, + credentials.email + ); + } + return res.body; + } catch (e) { + throw e; } - return res.body; } async acceptAccountRequest(options: { @@ -176,23 +180,27 @@ export class AuthAPI { id = id.trim(); - let res: { body: any; response?: IncomingMessage }; - - if (typeof credentials == 'string') { - this.internalApi.accessToken = credentials; - res = await this.internalApi.authControllerAcceptAccountRequest( - id, - undefined, - undefined - ); - } else { - res = await this.internalApi.authControllerAcceptAccountRequest( - id, - credentials.password, - credentials.email - ); + try { + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerAcceptAccountRequest( + id, + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerAcceptAccountRequest( + id, + credentials.password, + credentials.email + ); + } + return res.body; + } catch (e) { + throw e; } - return res.body; } async deleteAccountRequest(options: { @@ -206,22 +214,26 @@ export class AuthAPI { id = id.trim(); - let res: { body: any; response?: IncomingMessage }; - - if (typeof credentials == 'string') { - this.internalApi.accessToken = credentials; - res = await this.internalApi.authControllerDeleteAccountRequest( - id, - undefined, - undefined - ); - } else { - res = await this.internalApi.authControllerDeleteAccountRequest( - id, - credentials.password, - credentials.email - ); + try { + let res: { body: any; response?: IncomingMessage }; + + if (typeof credentials == 'string') { + this.internalApi.accessToken = credentials; + res = await this.internalApi.authControllerDeleteAccountRequest( + id, + undefined, + undefined + ); + } else { + res = await this.internalApi.authControllerDeleteAccountRequest( + id, + credentials.password, + credentials.email + ); + } + return res.body; + } catch (e) { + throw e; } - return res.body; } } From 39d724b4007ccc477d8aa6d55228ade579e4efcb Mon Sep 17 00:00:00 2001 From: aakashg00 Date: Mon, 9 Mar 2026 04:20:11 -0400 Subject: [PATCH 5/7] fixed i think --- src/internal/api/analyticsApi.ts | 15 +- src/internal/api/analyticsConfigApi.ts | 15 +- src/internal/api/apis.ts | 22 +- src/internal/api/authApi.ts | 434 ++++++++++++++++++ src/internal/model/fileProvider.ts | 1 + src/internal/model/models.ts | 12 + .../model/newAccountRequestResponse.ts | 91 ++++ ...ponse.ts => newAccountRequestsResponse.ts} | 24 +- .../model/registerFileProviderModel.ts | 1 + src/internal/model/requestNewAccountModel.ts | 82 ++++ 10 files changed, 660 insertions(+), 37 deletions(-) create mode 100644 src/internal/model/newAccountRequestResponse.ts rename src/internal/model/{fileProviderResponse.ts => newAccountRequestsResponse.ts} (56%) create mode 100644 src/internal/model/requestNewAccountModel.ts diff --git a/src/internal/api/analyticsApi.ts b/src/internal/api/analyticsApi.ts index 52909d6..a3670a8 100644 --- a/src/internal/api/analyticsApi.ts +++ b/src/internal/api/analyticsApi.ts @@ -10,8 +10,8 @@ * Do not edit the class manually. */ -import http from 'http'; import localVarRequest from 'request'; +import http from 'http'; /* tslint:disable:no-unused-locals */ import { ClickEventResponse } from '../model/clickEventResponse'; @@ -34,14 +34,19 @@ import { LogVisitEventRequest } from '../model/logVisitEventRequest'; import { VisitEventResponse } from '../model/visitEventResponse'; import { - Authentication, - HttpBearerAuth, - Interceptor, ObjectSerializer, + Authentication, VoidAuth, + Interceptor, +} from '../model/models'; +import { + HttpBasicAuth, + HttpBearerAuth, + ApiKeyAuth, + OAuth, } from '../model/models'; -import { HttpError } from './apis'; +import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://localhost'; diff --git a/src/internal/api/analyticsConfigApi.ts b/src/internal/api/analyticsConfigApi.ts index 3ef718f..afd6ef6 100644 --- a/src/internal/api/analyticsConfigApi.ts +++ b/src/internal/api/analyticsConfigApi.ts @@ -10,8 +10,8 @@ * Do not edit the class manually. */ -import http from 'http'; import localVarRequest from 'request'; +import http from 'http'; /* tslint:disable:no-unused-locals */ import { AnalyticsConfigResponse } from '../model/analyticsConfigResponse'; @@ -19,14 +19,19 @@ import { CreateAnalyticsConfigModel } from '../model/createAnalyticsConfigModel' import { UpdateAnalyticsConfigModel } from '../model/updateAnalyticsConfigModel'; import { - Authentication, - HttpBearerAuth, - Interceptor, ObjectSerializer, + Authentication, VoidAuth, + Interceptor, +} from '../model/models'; +import { + HttpBasicAuth, + HttpBearerAuth, + ApiKeyAuth, + OAuth, } from '../model/models'; -import { HttpError } from './apis'; +import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://localhost'; diff --git a/src/internal/api/apis.ts b/src/internal/api/apis.ts index 716e96c..1389143 100644 --- a/src/internal/api/apis.ts +++ b/src/internal/api/apis.ts @@ -1,26 +1,26 @@ export * from './analyticsApi'; -export * from './analyticsConfigApi'; -export * from './authApi'; -export * from './emailApi'; -export * from './fileBucketApi'; -export * from './fileConfigApi'; -export * from './fileDownloadApi'; -export * from './fileProviderApi'; -export * from './fileUploadApi'; -export * from './projectApi'; -export * from './userApi'; -import * as http from 'http'; import { AnalyticsApi } from './analyticsApi'; +export * from './analyticsConfigApi'; import { AnalyticsConfigApi } from './analyticsConfigApi'; +export * from './authApi'; import { AuthApi } from './authApi'; +export * from './emailApi'; import { EmailApi } from './emailApi'; +export * from './fileBucketApi'; import { FileBucketApi } from './fileBucketApi'; +export * from './fileConfigApi'; import { FileConfigApi } from './fileConfigApi'; +export * from './fileDownloadApi'; import { FileDownloadApi } from './fileDownloadApi'; +export * from './fileProviderApi'; import { FileProviderApi } from './fileProviderApi'; +export * from './fileUploadApi'; import { FileUploadApi } from './fileUploadApi'; +export * from './projectApi'; import { ProjectApi } from './projectApi'; +export * from './userApi'; import { UserApi } from './userApi'; +import * as http from 'http'; export class HttpError extends Error { constructor( diff --git a/src/internal/api/authApi.ts b/src/internal/api/authApi.ts index e8fc8fb..02b3680 100644 --- a/src/internal/api/authApi.ts +++ b/src/internal/api/authApi.ts @@ -18,6 +18,9 @@ import { AcceptAccountRequestResponseModel } from '../model/acceptAccountRequest import { IssueApiKeyRequest } from '../model/issueApiKeyRequest'; import { IssueApiKeyResponse } from '../model/issueApiKeyResponse'; import { IssueJWTResponse } from '../model/issueJWTResponse'; +import { NewAccountRequestResponse } from '../model/newAccountRequestResponse'; +import { NewAccountRequestsResponse } from '../model/newAccountRequestsResponse'; +import { RequestNewAccountModel } from '../model/requestNewAccountModel'; import { ObjectSerializer, @@ -107,6 +110,221 @@ export class AuthApi { this.interceptors.push(interceptor); } + /** + * Accepts a pending account request: creates the user, optionally creates/links a project (for ADMIN requests with a projectName), and deletes the pending request. Requires admin or superadmin credentials. + * @summary Accept an account request + * @param id ID of the account request to accept + * @param xUserPassword Password of the admin or superadmin user + * @param xUserEmail Email of an admin or superadmin user + */ + public async authControllerAcceptAccountRequest( + id: string, + xUserPassword?: string, + xUserEmail?: string, + options: { headers: { [name: string]: string } } = { headers: {} } + ): Promise<{ + response: http.IncomingMessage; + body: AcceptAccountRequestResponseModel; + }> { + const localVarPath = + this.basePath + + '/auth/account-request/{id}/accept'.replace( + '{' + 'id' + '}', + encodeURIComponent(String(id)) + ); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign( + {}, + this._defaultHeaders + ); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + // verify required parameter 'id' is not null or undefined + if (id === null || id === undefined) { + throw new Error( + 'Required parameter id was null or undefined when calling authControllerAcceptAccountRequest.' + ); + } + + localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( + xUserPassword, + 'string' + ); + localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize( + xUserEmail, + 'string' + ); + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + if (this.authentications.API_Key.accessToken) { + authenticationPromise = authenticationPromise.then(() => + this.authentications.API_Key.applyToRequest(localVarRequestOptions) + ); + } + authenticationPromise = authenticationPromise.then(() => + this.authentications.default.applyToRequest(localVarRequestOptions) + ); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => + interceptor(localVarRequestOptions) + ); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ + response: http.IncomingMessage; + body: AcceptAccountRequestResponseModel; + }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if ( + response.statusCode && + response.statusCode >= 200 && + response.statusCode <= 299 + ) { + body = ObjectSerializer.deserialize( + body, + 'AcceptAccountRequestResponseModel' + ); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } + /** + * Allows a prospective user to submit a request for a new account. The request is stored and can be reviewed by an admin. + * @summary Submit a new account request + * @param requestNewAccountModel + */ + public async authControllerCreateAccountRequest( + requestNewAccountModel: RequestNewAccountModel, + options: { headers: { [name: string]: string } } = { headers: {} } + ): Promise<{ + response: http.IncomingMessage; + body: NewAccountRequestResponse; + }> { + const localVarPath = this.basePath + '/auth/account-request'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign( + {}, + this._defaultHeaders + ); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + // verify required parameter 'requestNewAccountModel' is not null or undefined + if ( + requestNewAccountModel === null || + requestNewAccountModel === undefined + ) { + throw new Error( + 'Required parameter requestNewAccountModel was null or undefined when calling authControllerCreateAccountRequest.' + ); + } + + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'POST', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + body: ObjectSerializer.serialize( + requestNewAccountModel, + 'RequestNewAccountModel' + ), + }; + + let authenticationPromise = Promise.resolve(); + authenticationPromise = authenticationPromise.then(() => + this.authentications.default.applyToRequest(localVarRequestOptions) + ); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => + interceptor(localVarRequestOptions) + ); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ + response: http.IncomingMessage; + body: NewAccountRequestResponse; + }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if ( + response.statusCode && + response.statusCode >= 200 && + response.statusCode <= 299 + ) { + body = ObjectSerializer.deserialize( + body, + 'NewAccountRequestResponse' + ); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } /** * * @summary Issues a new API key for the project tied to the specified environment. @@ -224,6 +442,121 @@ export class AuthApi { }); }); } + /** + * Deletes an account request by its ID. Requires admin or superadmin credentials. + * @summary Delete an account request by ID + * @param id ID of the account request to delete + * @param xUserPassword Password of the admin or superadmin user + * @param xUserEmail Email of an admin or superadmin user + */ + public async authControllerDeleteAccountRequest( + id: string, + xUserPassword?: string, + xUserEmail?: string, + options: { headers: { [name: string]: string } } = { headers: {} } + ): Promise<{ + response: http.IncomingMessage; + body: NewAccountRequestResponse; + }> { + const localVarPath = + this.basePath + + '/auth/account-request/{id}'.replace( + '{' + 'id' + '}', + encodeURIComponent(String(id)) + ); + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign( + {}, + this._defaultHeaders + ); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + // verify required parameter 'id' is not null or undefined + if (id === null || id === undefined) { + throw new Error( + 'Required parameter id was null or undefined when calling authControllerDeleteAccountRequest.' + ); + } + + localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( + xUserPassword, + 'string' + ); + localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize( + xUserEmail, + 'string' + ); + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'DELETE', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + if (this.authentications.API_Key.accessToken) { + authenticationPromise = authenticationPromise.then(() => + this.authentications.API_Key.applyToRequest(localVarRequestOptions) + ); + } + authenticationPromise = authenticationPromise.then(() => + this.authentications.default.applyToRequest(localVarRequestOptions) + ); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => + interceptor(localVarRequestOptions) + ); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ + response: http.IncomingMessage; + body: NewAccountRequestResponse; + }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if ( + response.statusCode && + response.statusCode >= 200 && + response.statusCode <= 299 + ) { + body = ObjectSerializer.deserialize( + body, + 'NewAccountRequestResponse' + ); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } /** * * @summary Deletes an API key, detaching it from its project. @@ -311,6 +644,107 @@ export class AuthApi { ); }); } + /** + * Returns all pending account requests. Requires admin or superadmin credentials. + * @summary Retrieve all account requests + * @param xUserPassword Password of the admin or superadmin user + * @param xUserEmail Email of an admin or superadmin user + */ + public async authControllerGetAllAccountRequests( + xUserPassword?: string, + xUserEmail?: string, + options: { headers: { [name: string]: string } } = { headers: {} } + ): Promise<{ + response: http.IncomingMessage; + body: NewAccountRequestsResponse; + }> { + const localVarPath = this.basePath + '/auth/account-request'; + let localVarQueryParameters: any = {}; + let localVarHeaderParams: any = (Object).assign( + {}, + this._defaultHeaders + ); + const produces = ['application/json']; + // give precedence to 'application/json' + if (produces.indexOf('application/json') >= 0) { + localVarHeaderParams.Accept = 'application/json'; + } else { + localVarHeaderParams.Accept = produces.join(','); + } + let localVarFormParams: any = {}; + + localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( + xUserPassword, + 'string' + ); + localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize( + xUserEmail, + 'string' + ); + (Object).assign(localVarHeaderParams, options.headers); + + let localVarUseFormData = false; + + let localVarRequestOptions: localVarRequest.Options = { + method: 'GET', + qs: localVarQueryParameters, + headers: localVarHeaderParams, + uri: localVarPath, + useQuerystring: this._useQuerystring, + json: true, + }; + + let authenticationPromise = Promise.resolve(); + if (this.authentications.API_Key.accessToken) { + authenticationPromise = authenticationPromise.then(() => + this.authentications.API_Key.applyToRequest(localVarRequestOptions) + ); + } + authenticationPromise = authenticationPromise.then(() => + this.authentications.default.applyToRequest(localVarRequestOptions) + ); + + let interceptorPromise = authenticationPromise; + for (const interceptor of this.interceptors) { + interceptorPromise = interceptorPromise.then(() => + interceptor(localVarRequestOptions) + ); + } + + return interceptorPromise.then(() => { + if (Object.keys(localVarFormParams).length) { + if (localVarUseFormData) { + (localVarRequestOptions).formData = localVarFormParams; + } else { + localVarRequestOptions.form = localVarFormParams; + } + } + return new Promise<{ + response: http.IncomingMessage; + body: NewAccountRequestsResponse; + }>((resolve, reject) => { + localVarRequest(localVarRequestOptions, (error, response, body) => { + if (error) { + reject(error); + } else { + if ( + response.statusCode && + response.statusCode >= 200 && + response.statusCode <= 299 + ) { + body = ObjectSerializer.deserialize( + body, + 'NewAccountRequestsResponse' + ); + resolve({ response: response, body: body }); + } else { + reject(new HttpError(response, body, response.statusCode)); + } + } + }); + }); + }); + } /** * JSON Web Tokens are used for the vast majority of API-gateway calls. The Juno SDK provides the means of automatically authenticating through this route given a valid API key. * @summary Generates a temporary JWT for the project tied to a specified API key. diff --git a/src/internal/model/fileProvider.ts b/src/internal/model/fileProvider.ts index 37a8363..5c8ccef 100644 --- a/src/internal/model/fileProvider.ts +++ b/src/internal/model/fileProvider.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { RequestFile } from './models'; import { AccessKey } from './accessKey'; export class FileProvider { diff --git a/src/internal/model/models.ts b/src/internal/model/models.ts index cec88dd..88907ad 100644 --- a/src/internal/model/models.ts +++ b/src/internal/model/models.ts @@ -49,6 +49,8 @@ export * from './logCustomEventRequest'; export * from './logInputEventRequest'; export * from './logVisitEventRequest'; export * from './modelFile'; +export * from './newAccountRequestResponse'; +export * from './newAccountRequestsResponse'; export * from './projectResponse'; export * from './registerDomainModel'; export * from './registerDomainResponse'; @@ -56,6 +58,7 @@ export * from './registerEmailModel'; export * from './registerEmailResponse'; export * from './registerFileBucketModel'; export * from './registerFileProviderModel'; +export * from './requestNewAccountModel'; export * from './sendEmailModel'; export * from './sendEmailResponse'; export * from './sendEmailStatisticsResponse'; @@ -137,6 +140,8 @@ import { LogCustomEventRequest } from './logCustomEventRequest'; import { LogInputEventRequest } from './logInputEventRequest'; import { LogVisitEventRequest } from './logVisitEventRequest'; import { ModelFile } from './modelFile'; +import { NewAccountRequestResponse } from './newAccountRequestResponse'; +import { NewAccountRequestsResponse } from './newAccountRequestsResponse'; import { ProjectResponse } from './projectResponse'; import { RegisterDomainModel } from './registerDomainModel'; import { RegisterDomainResponse } from './registerDomainResponse'; @@ -144,6 +149,7 @@ import { RegisterEmailModel } from './registerEmailModel'; import { RegisterEmailResponse } from './registerEmailResponse'; import { RegisterFileBucketModel } from './registerFileBucketModel'; import { RegisterFileProviderModel } from './registerFileProviderModel'; +import { RequestNewAccountModel } from './requestNewAccountModel'; import { SendEmailModel } from './sendEmailModel'; import { SendEmailResponse } from './sendEmailResponse'; import { SendEmailStatisticsResponse } from './sendEmailStatisticsResponse'; @@ -180,6 +186,9 @@ let enumsMap: { [index: string]: any } = { 'AcceptAccountRequestResponseUser.TypeEnum': AcceptAccountRequestResponseUser.TypeEnum, AggregateInterval: AggregateInterval, + 'NewAccountRequestResponse.UserTypeEnum': + NewAccountRequestResponse.UserTypeEnum, + 'RequestNewAccountModel.UserTypeEnum': RequestNewAccountModel.UserTypeEnum, 'SetUserTypeModel.TypeEnum': SetUserTypeModel.TypeEnum, 'UserResponse.TypeEnum': UserResponse.TypeEnum, }; @@ -233,6 +242,8 @@ let typeMap: { [index: string]: any } = { LogInputEventRequest: LogInputEventRequest, LogVisitEventRequest: LogVisitEventRequest, ModelFile: ModelFile, + NewAccountRequestResponse: NewAccountRequestResponse, + NewAccountRequestsResponse: NewAccountRequestsResponse, ProjectResponse: ProjectResponse, RegisterDomainModel: RegisterDomainModel, RegisterDomainResponse: RegisterDomainResponse, @@ -240,6 +251,7 @@ let typeMap: { [index: string]: any } = { RegisterEmailResponse: RegisterEmailResponse, RegisterFileBucketModel: RegisterFileBucketModel, RegisterFileProviderModel: RegisterFileProviderModel, + RequestNewAccountModel: RequestNewAccountModel, SendEmailModel: SendEmailModel, SendEmailResponse: SendEmailResponse, SendEmailStatisticsResponse: SendEmailStatisticsResponse, diff --git a/src/internal/model/newAccountRequestResponse.ts b/src/internal/model/newAccountRequestResponse.ts new file mode 100644 index 0000000..7e2521f --- /dev/null +++ b/src/internal/model/newAccountRequestResponse.ts @@ -0,0 +1,91 @@ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; + +export class NewAccountRequestResponse { + /** + * Request ID + */ + 'id': number; + /** + * Email + */ + 'email': string; + /** + * Name + */ + 'name': string; + /** + * Requested user type + */ + 'userType': NewAccountRequestResponse.UserTypeEnum; + /** + * Project name + */ + 'projectName'?: string; + /** + * Timestamp of request creation + */ + 'createdAt': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }> = [ + { + name: 'id', + baseName: 'id', + type: 'number', + }, + { + name: 'email', + baseName: 'email', + type: 'string', + }, + { + name: 'name', + baseName: 'name', + type: 'string', + }, + { + name: 'userType', + baseName: 'userType', + type: 'NewAccountRequestResponse.UserTypeEnum', + }, + { + name: 'projectName', + baseName: 'projectName', + type: 'string', + }, + { + name: 'createdAt', + baseName: 'createdAt', + type: 'string', + }, + ]; + + static getAttributeTypeMap() { + return NewAccountRequestResponse.attributeTypeMap; + } +} + +export namespace NewAccountRequestResponse { + export enum UserTypeEnum { + Superadmin = 'SUPERADMIN', + Admin = 'ADMIN', + User = 'USER', + } +} diff --git a/src/internal/model/fileProviderResponse.ts b/src/internal/model/newAccountRequestsResponse.ts similarity index 56% rename from src/internal/model/fileProviderResponse.ts rename to src/internal/model/newAccountRequestsResponse.ts index 27c5cf4..5c542d1 100644 --- a/src/internal/model/fileProviderResponse.ts +++ b/src/internal/model/newAccountRequestsResponse.ts @@ -11,16 +11,13 @@ */ import { RequestFile } from './models'; +import { NewAccountRequestResponse } from './newAccountRequestResponse'; -export class FileProviderResponse { +export class NewAccountRequestsResponse { /** - * The unique provider name of the file provider + * List of new account requests */ - 'providerName': string; - /** - * The metadata of the file provider - */ - 'metadata': string; + 'requests': Array; static discriminator: string | undefined = undefined; @@ -30,18 +27,13 @@ export class FileProviderResponse { type: string; }> = [ { - name: 'providerName', - baseName: 'providerName', - type: 'string', - }, - { - name: 'metadata', - baseName: 'metadata', - type: 'string', + name: 'requests', + baseName: 'requests', + type: 'Array', }, ]; static getAttributeTypeMap() { - return FileProviderResponse.attributeTypeMap; + return NewAccountRequestsResponse.attributeTypeMap; } } diff --git a/src/internal/model/registerFileProviderModel.ts b/src/internal/model/registerFileProviderModel.ts index 4aef5d9..78f8690 100644 --- a/src/internal/model/registerFileProviderModel.ts +++ b/src/internal/model/registerFileProviderModel.ts @@ -10,6 +10,7 @@ * Do not edit the class manually. */ +import { RequestFile } from './models'; import { AccessKey } from './accessKey'; export class RegisterFileProviderModel { diff --git a/src/internal/model/requestNewAccountModel.ts b/src/internal/model/requestNewAccountModel.ts new file mode 100644 index 0000000..c53f5b8 --- /dev/null +++ b/src/internal/model/requestNewAccountModel.ts @@ -0,0 +1,82 @@ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { RequestFile } from './models'; + +export class RequestNewAccountModel { + /** + * Email for the new account + */ + 'email': string; + /** + * Name of the requester + */ + 'name': string; + /** + * Password for the new account + */ + 'password': string; + /** + * Requested user type / role + */ + 'userType': RequestNewAccountModel.UserTypeEnum; + /** + * Optional project name to associate + */ + 'projectName'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + }> = [ + { + name: 'email', + baseName: 'email', + type: 'string', + }, + { + name: 'name', + baseName: 'name', + type: 'string', + }, + { + name: 'password', + baseName: 'password', + type: 'string', + }, + { + name: 'userType', + baseName: 'userType', + type: 'RequestNewAccountModel.UserTypeEnum', + }, + { + name: 'projectName', + baseName: 'projectName', + type: 'string', + }, + ]; + + static getAttributeTypeMap() { + return RequestNewAccountModel.attributeTypeMap; + } +} + +export namespace RequestNewAccountModel { + export enum UserTypeEnum { + Superadmin = 'SUPERADMIN', + Admin = 'ADMIN', + User = 'USER', + } +} From 276dfb72dde4bb704860725d1471069ac31746ba Mon Sep 17 00:00:00 2001 From: aakashg00 Date: Tue, 31 Mar 2026 13:41:39 -0400 Subject: [PATCH 6/7] updated to work with sdk changes --- src/internal/api/analyticsApi.ts | 1845 ----------------- src/internal/api/analyticsConfigApi.ts | 540 ----- src/internal/api/apis.ts | 50 - src/internal/api/authApi.ts | 1040 ---------- src/internal/apis/AuthApi.ts | 119 +- .../acceptAccountRequestResponseModel.ts | 49 - .../acceptAccountRequestResponseProject.ts | 47 - .../model/acceptAccountRequestResponseUser.ts | 82 - src/internal/model/fileProvider.ts | 66 - src/internal/model/models.ts | 482 ----- .../model/newAccountRequestResponse.ts | 91 - .../model/newAccountRequestsResponse.ts | 39 - .../model/registerFileProviderModel.ts | 66 - src/internal/model/requestNewAccountModel.ts | 82 - .../AcceptAccountRequestResponseModel.ts | 91 + .../AcceptAccountRequestResponseProject.ts | 76 + .../AcceptAccountRequestResponseUser.ts | 113 + src/internal/models/index.ts | 3 + src/lib/auth.ts | 35 + 19 files changed, 404 insertions(+), 4512 deletions(-) delete mode 100644 src/internal/api/analyticsApi.ts delete mode 100644 src/internal/api/analyticsConfigApi.ts delete mode 100644 src/internal/api/apis.ts delete mode 100644 src/internal/api/authApi.ts delete mode 100644 src/internal/model/acceptAccountRequestResponseModel.ts delete mode 100644 src/internal/model/acceptAccountRequestResponseProject.ts delete mode 100644 src/internal/model/acceptAccountRequestResponseUser.ts delete mode 100644 src/internal/model/fileProvider.ts delete mode 100644 src/internal/model/models.ts delete mode 100644 src/internal/model/newAccountRequestResponse.ts delete mode 100644 src/internal/model/newAccountRequestsResponse.ts delete mode 100644 src/internal/model/registerFileProviderModel.ts delete mode 100644 src/internal/model/requestNewAccountModel.ts create mode 100644 src/internal/models/AcceptAccountRequestResponseModel.ts create mode 100644 src/internal/models/AcceptAccountRequestResponseProject.ts create mode 100644 src/internal/models/AcceptAccountRequestResponseUser.ts diff --git a/src/internal/api/analyticsApi.ts b/src/internal/api/analyticsApi.ts deleted file mode 100644 index a3670a8..0000000 --- a/src/internal/api/analyticsApi.ts +++ /dev/null @@ -1,1845 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import localVarRequest from 'request'; -import http from 'http'; - -/* tslint:disable:no-unused-locals */ -import { ClickEventResponse } from '../model/clickEventResponse'; -import { CustomEventResponse } from '../model/customEventResponse'; -import { CustomGraphTypeResponse } from '../model/customGraphTypeResponse'; -import { GetAllClickEventsResponse } from '../model/getAllClickEventsResponse'; -import { GetAllCustomEventTypeResponse } from '../model/getAllCustomEventTypeResponse'; -import { GetAllCustomEventsResponse } from '../model/getAllCustomEventsResponse'; -import { GetAllInputEventsResponse } from '../model/getAllInputEventsResponse'; -import { GetAllVisitEventsResponse } from '../model/getAllVisitEventsResponse'; -import { GetClickEventsResponse } from '../model/getClickEventsResponse'; -import { GetCustomEventsResponse } from '../model/getCustomEventsResponse'; -import { GetInputEventsResponse } from '../model/getInputEventsResponse'; -import { GetVisitEventsResponse } from '../model/getVisitEventsResponse'; -import { InputEventResponse } from '../model/inputEventResponse'; -import { LogClickEventRequest } from '../model/logClickEventRequest'; -import { LogCustomEventRequest } from '../model/logCustomEventRequest'; -import { LogInputEventRequest } from '../model/logInputEventRequest'; -import { LogVisitEventRequest } from '../model/logVisitEventRequest'; -import { VisitEventResponse } from '../model/visitEventResponse'; - -import { - ObjectSerializer, - Authentication, - VoidAuth, - Interceptor, -} from '../model/models'; -import { - HttpBasicAuth, - HttpBearerAuth, - ApiKeyAuth, - OAuth, -} from '../model/models'; - -import { HttpError, RequestFile } from './apis'; - -let defaultBasePath = 'http://localhost'; - -// =============================================== -// This file is autogenerated - Please do not edit -// =============================================== - -export enum AnalyticsApiApiKeys {} - -export class AnalyticsApi { - protected _basePath = defaultBasePath; - protected _defaultHeaders: any = {}; - protected _useQuerystring: boolean = false; - - protected authentications = { - default: new VoidAuth(), - API_Key: new HttpBearerAuth(), - }; - - protected interceptors: Interceptor[] = []; - - constructor(basePath?: string); - constructor( - basePathOrUsername: string, - password?: string, - basePath?: string - ) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername; - } - } - } - - set useQuerystring(value: boolean) { - this._useQuerystring = value; - } - - set basePath(basePath: string) { - this._basePath = basePath; - } - - set defaultHeaders(defaultHeaders: any) { - this._defaultHeaders = defaultHeaders; - } - - get defaultHeaders() { - return this._defaultHeaders; - } - - get basePath() { - return this._basePath; - } - - public setDefaultAuthentication(auth: Authentication) { - this.authentications.default = auth; - } - - public setApiKey(key: AnalyticsApiApiKeys, value: string) { - (this.authentications as any)[AnalyticsApiApiKeys[key]].apiKey = value; - } - - set accessToken(accessToken: string | (() => string)) { - this.authentications.API_Key.accessToken = accessToken; - } - - public addInterceptor(interceptor: Interceptor) { - this.interceptors.push(interceptor); - } - - /** - * - * @summary Get all click events - * @param projectName Project name - * @param afterTime Filter after timestamp - * @param limit Max results - */ - public async analyticsControllerGetAllClickEvents( - projectName: string, - afterTime?: string, - limit?: number, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: GetAllClickEventsResponse; - }> { - const localVarPath = this.basePath + '/analytics/events/click/all'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetAllClickEvents.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - if (afterTime !== undefined) { - localVarQueryParameters['afterTime'] = ObjectSerializer.serialize( - afterTime, - 'string' - ); - } - - if (limit !== undefined) { - localVarQueryParameters['limit'] = ObjectSerializer.serialize( - limit, - 'number' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: GetAllClickEventsResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'GetAllClickEventsResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get all custom events - * @param projectName Project name - * @param category Event category - * @param subcategory Event subcategory - * @param afterTime Filter after timestamp - * @param limit Max results - */ - public async analyticsControllerGetAllCustomEvents( - projectName: string, - category: string, - subcategory: string, - afterTime?: string, - limit?: number, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: GetAllCustomEventsResponse; - }> { - const localVarPath = this.basePath + '/analytics/events/custom/all'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetAllCustomEvents.' - ); - } - - // verify required parameter 'category' is not null or undefined - if (category === null || category === undefined) { - throw new Error( - 'Required parameter category was null or undefined when calling analyticsControllerGetAllCustomEvents.' - ); - } - - // verify required parameter 'subcategory' is not null or undefined - if (subcategory === null || subcategory === undefined) { - throw new Error( - 'Required parameter subcategory was null or undefined when calling analyticsControllerGetAllCustomEvents.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - if (afterTime !== undefined) { - localVarQueryParameters['afterTime'] = ObjectSerializer.serialize( - afterTime, - 'string' - ); - } - - if (limit !== undefined) { - localVarQueryParameters['limit'] = ObjectSerializer.serialize( - limit, - 'number' - ); - } - - if (category !== undefined) { - localVarQueryParameters['category'] = ObjectSerializer.serialize( - category, - 'string' - ); - } - - if (subcategory !== undefined) { - localVarQueryParameters['subcategory'] = ObjectSerializer.serialize( - subcategory, - 'string' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: GetAllCustomEventsResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'GetAllCustomEventsResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get all input events - * @param projectName Project name - * @param afterTime Filter after timestamp - * @param limit Max results - */ - public async analyticsControllerGetAllInputEvents( - projectName: string, - afterTime?: string, - limit?: number, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: GetAllInputEventsResponse; - }> { - const localVarPath = this.basePath + '/analytics/events/input/all'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetAllInputEvents.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - if (afterTime !== undefined) { - localVarQueryParameters['afterTime'] = ObjectSerializer.serialize( - afterTime, - 'string' - ); - } - - if (limit !== undefined) { - localVarQueryParameters['limit'] = ObjectSerializer.serialize( - limit, - 'number' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: GetAllInputEventsResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'GetAllInputEventsResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get all visit events - * @param projectName Project name - * @param afterTime Filter after timestamp - * @param limit Max results - */ - public async analyticsControllerGetAllVisitEvents( - projectName: string, - afterTime?: string, - limit?: number, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: GetAllVisitEventsResponse; - }> { - const localVarPath = this.basePath + '/analytics/events/visit/all'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetAllVisitEvents.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - if (afterTime !== undefined) { - localVarQueryParameters['afterTime'] = ObjectSerializer.serialize( - afterTime, - 'string' - ); - } - - if (limit !== undefined) { - localVarQueryParameters['limit'] = ObjectSerializer.serialize( - limit, - 'number' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: GetAllVisitEventsResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'GetAllVisitEventsResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get click events with pagination - * @param projectName Project name - * @param afterId Pagination cursor - * @param environment Environment filter - * @param limit Max results - * @param afterTime Filter after timestamp - */ - public async analyticsControllerGetClickEventsPaginated( - projectName: string, - afterId?: string, - environment?: string, - limit?: number, - afterTime?: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: GetClickEventsResponse }> { - const localVarPath = this.basePath + '/analytics/events/click'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetClickEventsPaginated.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - if (afterId !== undefined) { - localVarQueryParameters['afterId'] = ObjectSerializer.serialize( - afterId, - 'string' - ); - } - - if (environment !== undefined) { - localVarQueryParameters['environment'] = ObjectSerializer.serialize( - environment, - 'string' - ); - } - - if (limit !== undefined) { - localVarQueryParameters['limit'] = ObjectSerializer.serialize( - limit, - 'number' - ); - } - - if (afterTime !== undefined) { - localVarQueryParameters['afterTime'] = ObjectSerializer.serialize( - afterTime, - 'string' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: GetClickEventsResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'GetClickEventsResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get custom event types for a project - * @param projectName Project name - */ - public async analyticsControllerGetCustomEventTypes( - projectName: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: GetAllCustomEventTypeResponse; - }> { - const localVarPath = this.basePath + '/analytics/custom-event-types'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetCustomEventTypes.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: GetAllCustomEventTypeResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'GetAllCustomEventTypeResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get custom events with pagination - * @param projectName Project name - * @param category Event category - * @param subcategory Event subcategory - * @param afterId Pagination cursor - * @param environment Environment filter - * @param limit Max results - * @param afterTime Filter after timestamp - */ - public async analyticsControllerGetCustomEventsPaginated( - projectName: string, - category: string, - subcategory: string, - afterId?: string, - environment?: string, - limit?: number, - afterTime?: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: GetCustomEventsResponse; - }> { - const localVarPath = this.basePath + '/analytics/events/custom'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetCustomEventsPaginated.' - ); - } - - // verify required parameter 'category' is not null or undefined - if (category === null || category === undefined) { - throw new Error( - 'Required parameter category was null or undefined when calling analyticsControllerGetCustomEventsPaginated.' - ); - } - - // verify required parameter 'subcategory' is not null or undefined - if (subcategory === null || subcategory === undefined) { - throw new Error( - 'Required parameter subcategory was null or undefined when calling analyticsControllerGetCustomEventsPaginated.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - if (afterId !== undefined) { - localVarQueryParameters['afterId'] = ObjectSerializer.serialize( - afterId, - 'string' - ); - } - - if (environment !== undefined) { - localVarQueryParameters['environment'] = ObjectSerializer.serialize( - environment, - 'string' - ); - } - - if (limit !== undefined) { - localVarQueryParameters['limit'] = ObjectSerializer.serialize( - limit, - 'number' - ); - } - - if (afterTime !== undefined) { - localVarQueryParameters['afterTime'] = ObjectSerializer.serialize( - afterTime, - 'string' - ); - } - - if (category !== undefined) { - localVarQueryParameters['category'] = ObjectSerializer.serialize( - category, - 'string' - ); - } - - if (subcategory !== undefined) { - localVarQueryParameters['subcategory'] = ObjectSerializer.serialize( - subcategory, - 'string' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: GetCustomEventsResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'GetCustomEventsResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get custom graph types by event type ID - * @param projectName Project name - * @param eventTypeId Event type ID - */ - public async analyticsControllerGetCustomGraphTypesById( - projectName: string, - eventTypeId: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: CustomGraphTypeResponse; - }> { - const localVarPath = this.basePath + '/analytics/custom-graph-types'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetCustomGraphTypesById.' - ); - } - - // verify required parameter 'eventTypeId' is not null or undefined - if (eventTypeId === null || eventTypeId === undefined) { - throw new Error( - 'Required parameter eventTypeId was null or undefined when calling analyticsControllerGetCustomGraphTypesById.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - if (eventTypeId !== undefined) { - localVarQueryParameters['eventTypeId'] = ObjectSerializer.serialize( - eventTypeId, - 'string' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: CustomGraphTypeResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'CustomGraphTypeResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get input events with pagination - * @param projectName Project name - * @param afterId Pagination cursor - * @param environment Environment filter - * @param limit Max results - * @param afterTime Filter after timestamp - */ - public async analyticsControllerGetInputEventsPaginated( - projectName: string, - afterId?: string, - environment?: string, - limit?: number, - afterTime?: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: GetInputEventsResponse }> { - const localVarPath = this.basePath + '/analytics/events/input'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetInputEventsPaginated.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - if (afterId !== undefined) { - localVarQueryParameters['afterId'] = ObjectSerializer.serialize( - afterId, - 'string' - ); - } - - if (environment !== undefined) { - localVarQueryParameters['environment'] = ObjectSerializer.serialize( - environment, - 'string' - ); - } - - if (limit !== undefined) { - localVarQueryParameters['limit'] = ObjectSerializer.serialize( - limit, - 'number' - ); - } - - if (afterTime !== undefined) { - localVarQueryParameters['afterTime'] = ObjectSerializer.serialize( - afterTime, - 'string' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: GetInputEventsResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'GetInputEventsResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get visit events with pagination - * @param projectName Project name - * @param afterId Pagination cursor - * @param environment Environment filter - * @param limit Max results - * @param afterTime Filter after timestamp - */ - public async analyticsControllerGetVisitEventsPaginated( - projectName: string, - afterId?: string, - environment?: string, - limit?: number, - afterTime?: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: GetVisitEventsResponse }> { - const localVarPath = this.basePath + '/analytics/events/visit'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectName' is not null or undefined - if (projectName === null || projectName === undefined) { - throw new Error( - 'Required parameter projectName was null or undefined when calling analyticsControllerGetVisitEventsPaginated.' - ); - } - - if (projectName !== undefined) { - localVarQueryParameters['projectName'] = ObjectSerializer.serialize( - projectName, - 'string' - ); - } - - if (afterId !== undefined) { - localVarQueryParameters['afterId'] = ObjectSerializer.serialize( - afterId, - 'string' - ); - } - - if (environment !== undefined) { - localVarQueryParameters['environment'] = ObjectSerializer.serialize( - environment, - 'string' - ); - } - - if (limit !== undefined) { - localVarQueryParameters['limit'] = ObjectSerializer.serialize( - limit, - 'number' - ); - } - - if (afterTime !== undefined) { - localVarQueryParameters['afterTime'] = ObjectSerializer.serialize( - afterTime, - 'string' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: GetVisitEventsResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'GetVisitEventsResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Log a click event - * @param logClickEventRequest - */ - public async analyticsControllerLogClickEvent( - logClickEventRequest: LogClickEventRequest, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: ClickEventResponse }> { - const localVarPath = this.basePath + '/analytics/events/click'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'logClickEventRequest' is not null or undefined - if (logClickEventRequest === null || logClickEventRequest === undefined) { - throw new Error( - 'Required parameter logClickEventRequest was null or undefined when calling analyticsControllerLogClickEvent.' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - body: ObjectSerializer.serialize( - logClickEventRequest, - 'LogClickEventRequest' - ), - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: ClickEventResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize(body, 'ClickEventResponse'); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Log a custom event - * @param logCustomEventRequest - */ - public async analyticsControllerLogCustomEvent( - logCustomEventRequest: LogCustomEventRequest, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: CustomEventResponse }> { - const localVarPath = this.basePath + '/analytics/events/custom'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'logCustomEventRequest' is not null or undefined - if (logCustomEventRequest === null || logCustomEventRequest === undefined) { - throw new Error( - 'Required parameter logCustomEventRequest was null or undefined when calling analyticsControllerLogCustomEvent.' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - body: ObjectSerializer.serialize( - logCustomEventRequest, - 'LogCustomEventRequest' - ), - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: CustomEventResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize(body, 'CustomEventResponse'); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Log an input event - * @param logInputEventRequest - */ - public async analyticsControllerLogInputEvent( - logInputEventRequest: LogInputEventRequest, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: InputEventResponse }> { - const localVarPath = this.basePath + '/analytics/events/input'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'logInputEventRequest' is not null or undefined - if (logInputEventRequest === null || logInputEventRequest === undefined) { - throw new Error( - 'Required parameter logInputEventRequest was null or undefined when calling analyticsControllerLogInputEvent.' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - body: ObjectSerializer.serialize( - logInputEventRequest, - 'LogInputEventRequest' - ), - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: InputEventResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize(body, 'InputEventResponse'); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Log a visit event - * @param logVisitEventRequest - */ - public async analyticsControllerLogVisitEvent( - logVisitEventRequest: LogVisitEventRequest, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: VisitEventResponse }> { - const localVarPath = this.basePath + '/analytics/events/visit'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'logVisitEventRequest' is not null or undefined - if (logVisitEventRequest === null || logVisitEventRequest === undefined) { - throw new Error( - 'Required parameter logVisitEventRequest was null or undefined when calling analyticsControllerLogVisitEvent.' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - body: ObjectSerializer.serialize( - logVisitEventRequest, - 'LogVisitEventRequest' - ), - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: VisitEventResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize(body, 'VisitEventResponse'); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } -} diff --git a/src/internal/api/analyticsConfigApi.ts b/src/internal/api/analyticsConfigApi.ts deleted file mode 100644 index afd6ef6..0000000 --- a/src/internal/api/analyticsConfigApi.ts +++ /dev/null @@ -1,540 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import localVarRequest from 'request'; -import http from 'http'; - -/* tslint:disable:no-unused-locals */ -import { AnalyticsConfigResponse } from '../model/analyticsConfigResponse'; -import { CreateAnalyticsConfigModel } from '../model/createAnalyticsConfigModel'; -import { UpdateAnalyticsConfigModel } from '../model/updateAnalyticsConfigModel'; - -import { - ObjectSerializer, - Authentication, - VoidAuth, - Interceptor, -} from '../model/models'; -import { - HttpBasicAuth, - HttpBearerAuth, - ApiKeyAuth, - OAuth, -} from '../model/models'; - -import { HttpError, RequestFile } from './apis'; - -let defaultBasePath = 'http://localhost'; - -// =============================================== -// This file is autogenerated - Please do not edit -// =============================================== - -export enum AnalyticsConfigApiApiKeys {} - -export class AnalyticsConfigApi { - protected _basePath = defaultBasePath; - protected _defaultHeaders: any = {}; - protected _useQuerystring: boolean = false; - - protected authentications = { - default: new VoidAuth(), - API_Key: new HttpBearerAuth(), - }; - - protected interceptors: Interceptor[] = []; - - constructor(basePath?: string); - constructor( - basePathOrUsername: string, - password?: string, - basePath?: string - ) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername; - } - } - } - - set useQuerystring(value: boolean) { - this._useQuerystring = value; - } - - set basePath(basePath: string) { - this._basePath = basePath; - } - - set defaultHeaders(defaultHeaders: any) { - this._defaultHeaders = defaultHeaders; - } - - get defaultHeaders() { - return this._defaultHeaders; - } - - get basePath() { - return this._basePath; - } - - public setDefaultAuthentication(auth: Authentication) { - this.authentications.default = auth; - } - - public setApiKey(key: AnalyticsConfigApiApiKeys, value: string) { - (this.authentications as any)[AnalyticsConfigApiApiKeys[key]].apiKey = - value; - } - - set accessToken(accessToken: string | (() => string)) { - this.authentications.API_Key.accessToken = accessToken; - } - - public addInterceptor(interceptor: Interceptor) { - this.interceptors.push(interceptor); - } - - /** - * - * @summary Create analytics configuration - * @param createAnalyticsConfigModel - */ - public async analyticsConfigControllerCreateAnalyticsConfig( - createAnalyticsConfigModel: CreateAnalyticsConfigModel, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: AnalyticsConfigResponse; - }> { - const localVarPath = this.basePath + '/analytics/config'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'createAnalyticsConfigModel' is not null or undefined - if ( - createAnalyticsConfigModel === null || - createAnalyticsConfigModel === undefined - ) { - throw new Error( - 'Required parameter createAnalyticsConfigModel was null or undefined when calling analyticsConfigControllerCreateAnalyticsConfig.' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - body: ObjectSerializer.serialize( - createAnalyticsConfigModel, - 'CreateAnalyticsConfigModel' - ), - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: AnalyticsConfigResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'AnalyticsConfigResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Delete analytics configuration - * @param projectId - */ - public async analyticsConfigControllerDeleteAnalyticsConfig( - projectId: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: AnalyticsConfigResponse; - }> { - const localVarPath = - this.basePath + - '/analytics/config/{projectId}'.replace( - '{' + 'projectId' + '}', - encodeURIComponent(String(projectId)) - ); - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectId' is not null or undefined - if (projectId === null || projectId === undefined) { - throw new Error( - 'Required parameter projectId was null or undefined when calling analyticsConfigControllerDeleteAnalyticsConfig.' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'DELETE', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: AnalyticsConfigResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'AnalyticsConfigResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Get analytics configuration - * @param projectId - */ - public async analyticsConfigControllerGetAnalyticsConfig( - projectId: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: AnalyticsConfigResponse; - }> { - const localVarPath = - this.basePath + - '/analytics/config/{projectId}'.replace( - '{' + 'projectId' + '}', - encodeURIComponent(String(projectId)) - ); - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectId' is not null or undefined - if (projectId === null || projectId === undefined) { - throw new Error( - 'Required parameter projectId was null or undefined when calling analyticsConfigControllerGetAnalyticsConfig.' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: AnalyticsConfigResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'AnalyticsConfigResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Update analytics configuration - * @param projectId - * @param updateAnalyticsConfigModel - */ - public async analyticsConfigControllerUpdateAnalyticsConfig( - projectId: string, - updateAnalyticsConfigModel: UpdateAnalyticsConfigModel, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: AnalyticsConfigResponse; - }> { - const localVarPath = - this.basePath + - '/analytics/config/{projectId}'.replace( - '{' + 'projectId' + '}', - encodeURIComponent(String(projectId)) - ); - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'projectId' is not null or undefined - if (projectId === null || projectId === undefined) { - throw new Error( - 'Required parameter projectId was null or undefined when calling analyticsConfigControllerUpdateAnalyticsConfig.' - ); - } - - // verify required parameter 'updateAnalyticsConfigModel' is not null or undefined - if ( - updateAnalyticsConfigModel === null || - updateAnalyticsConfigModel === undefined - ) { - throw new Error( - 'Required parameter updateAnalyticsConfigModel was null or undefined when calling analyticsConfigControllerUpdateAnalyticsConfig.' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'PUT', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - body: ObjectSerializer.serialize( - updateAnalyticsConfigModel, - 'UpdateAnalyticsConfigModel' - ), - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: AnalyticsConfigResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'AnalyticsConfigResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } -} diff --git a/src/internal/api/apis.ts b/src/internal/api/apis.ts deleted file mode 100644 index 1389143..0000000 --- a/src/internal/api/apis.ts +++ /dev/null @@ -1,50 +0,0 @@ -export * from './analyticsApi'; -import { AnalyticsApi } from './analyticsApi'; -export * from './analyticsConfigApi'; -import { AnalyticsConfigApi } from './analyticsConfigApi'; -export * from './authApi'; -import { AuthApi } from './authApi'; -export * from './emailApi'; -import { EmailApi } from './emailApi'; -export * from './fileBucketApi'; -import { FileBucketApi } from './fileBucketApi'; -export * from './fileConfigApi'; -import { FileConfigApi } from './fileConfigApi'; -export * from './fileDownloadApi'; -import { FileDownloadApi } from './fileDownloadApi'; -export * from './fileProviderApi'; -import { FileProviderApi } from './fileProviderApi'; -export * from './fileUploadApi'; -import { FileUploadApi } from './fileUploadApi'; -export * from './projectApi'; -import { ProjectApi } from './projectApi'; -export * from './userApi'; -import { UserApi } from './userApi'; -import * as http from 'http'; - -export class HttpError extends Error { - constructor( - public response: http.IncomingMessage, - public body: any, - public statusCode?: number - ) { - super('HTTP request failed'); - this.name = 'HttpError'; - } -} - -export { RequestFile } from '../model/models'; - -export const APIS = [ - AnalyticsApi, - AnalyticsConfigApi, - AuthApi, - EmailApi, - FileBucketApi, - FileConfigApi, - FileDownloadApi, - FileProviderApi, - FileUploadApi, - ProjectApi, - UserApi, -]; diff --git a/src/internal/api/authApi.ts b/src/internal/api/authApi.ts deleted file mode 100644 index 02b3680..0000000 --- a/src/internal/api/authApi.ts +++ /dev/null @@ -1,1040 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import localVarRequest from 'request'; -import http from 'http'; - -/* tslint:disable:no-unused-locals */ -import { AcceptAccountRequestResponseModel } from '../model/acceptAccountRequestResponseModel'; -import { IssueApiKeyRequest } from '../model/issueApiKeyRequest'; -import { IssueApiKeyResponse } from '../model/issueApiKeyResponse'; -import { IssueJWTResponse } from '../model/issueJWTResponse'; -import { NewAccountRequestResponse } from '../model/newAccountRequestResponse'; -import { NewAccountRequestsResponse } from '../model/newAccountRequestsResponse'; -import { RequestNewAccountModel } from '../model/requestNewAccountModel'; - -import { - ObjectSerializer, - Authentication, - VoidAuth, - Interceptor, -} from '../model/models'; -import { - HttpBasicAuth, - HttpBearerAuth, - ApiKeyAuth, - OAuth, -} from '../model/models'; - -import { HttpError, RequestFile } from './apis'; - -let defaultBasePath = 'http://localhost'; - -// =============================================== -// This file is autogenerated - Please do not edit -// =============================================== - -export enum AuthApiApiKeys {} - -export class AuthApi { - protected _basePath = defaultBasePath; - protected _defaultHeaders: any = {}; - protected _useQuerystring: boolean = false; - - protected authentications = { - default: new VoidAuth(), - API_Key: new HttpBearerAuth(), - }; - - protected interceptors: Interceptor[] = []; - - constructor(basePath?: string); - constructor( - basePathOrUsername: string, - password?: string, - basePath?: string - ) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername; - } - } - } - - set useQuerystring(value: boolean) { - this._useQuerystring = value; - } - - set basePath(basePath: string) { - this._basePath = basePath; - } - - set defaultHeaders(defaultHeaders: any) { - this._defaultHeaders = defaultHeaders; - } - - get defaultHeaders() { - return this._defaultHeaders; - } - - get basePath() { - return this._basePath; - } - - public setDefaultAuthentication(auth: Authentication) { - this.authentications.default = auth; - } - - public setApiKey(key: AuthApiApiKeys, value: string) { - (this.authentications as any)[AuthApiApiKeys[key]].apiKey = value; - } - - set accessToken(accessToken: string | (() => string)) { - this.authentications.API_Key.accessToken = accessToken; - } - - public addInterceptor(interceptor: Interceptor) { - this.interceptors.push(interceptor); - } - - /** - * Accepts a pending account request: creates the user, optionally creates/links a project (for ADMIN requests with a projectName), and deletes the pending request. Requires admin or superadmin credentials. - * @summary Accept an account request - * @param id ID of the account request to accept - * @param xUserPassword Password of the admin or superadmin user - * @param xUserEmail Email of an admin or superadmin user - */ - public async authControllerAcceptAccountRequest( - id: string, - xUserPassword?: string, - xUserEmail?: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: AcceptAccountRequestResponseModel; - }> { - const localVarPath = - this.basePath + - '/auth/account-request/{id}/accept'.replace( - '{' + 'id' + '}', - encodeURIComponent(String(id)) - ); - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'id' is not null or undefined - if (id === null || id === undefined) { - throw new Error( - 'Required parameter id was null or undefined when calling authControllerAcceptAccountRequest.' - ); - } - - localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( - xUserPassword, - 'string' - ); - localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize( - xUserEmail, - 'string' - ); - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: AcceptAccountRequestResponseModel; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'AcceptAccountRequestResponseModel' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * Allows a prospective user to submit a request for a new account. The request is stored and can be reviewed by an admin. - * @summary Submit a new account request - * @param requestNewAccountModel - */ - public async authControllerCreateAccountRequest( - requestNewAccountModel: RequestNewAccountModel, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: NewAccountRequestResponse; - }> { - const localVarPath = this.basePath + '/auth/account-request'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'requestNewAccountModel' is not null or undefined - if ( - requestNewAccountModel === null || - requestNewAccountModel === undefined - ) { - throw new Error( - 'Required parameter requestNewAccountModel was null or undefined when calling authControllerCreateAccountRequest.' - ); - } - - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - body: ObjectSerializer.serialize( - requestNewAccountModel, - 'RequestNewAccountModel' - ), - }; - - let authenticationPromise = Promise.resolve(); - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: NewAccountRequestResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'NewAccountRequestResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Issues a new API key for the project tied to the specified environment. - * @param xUserPassword Password of the admin or superadmin user - * @param xUserEmail Email of an admin or superadmin user - * @param issueApiKeyRequest - */ - public async authControllerCreateApiKey( - xUserPassword: string, - xUserEmail: string, - issueApiKeyRequest: IssueApiKeyRequest, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: IssueApiKeyResponse }> { - const localVarPath = this.basePath + '/auth/key'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'xUserPassword' is not null or undefined - if (xUserPassword === null || xUserPassword === undefined) { - throw new Error( - 'Required parameter xUserPassword was null or undefined when calling authControllerCreateApiKey.' - ); - } - - // verify required parameter 'xUserEmail' is not null or undefined - if (xUserEmail === null || xUserEmail === undefined) { - throw new Error( - 'Required parameter xUserEmail was null or undefined when calling authControllerCreateApiKey.' - ); - } - - // verify required parameter 'issueApiKeyRequest' is not null or undefined - if (issueApiKeyRequest === null || issueApiKeyRequest === undefined) { - throw new Error( - 'Required parameter issueApiKeyRequest was null or undefined when calling authControllerCreateApiKey.' - ); - } - - localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( - xUserPassword, - 'string' - ); - localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize( - xUserEmail, - 'string' - ); - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - body: ObjectSerializer.serialize( - issueApiKeyRequest, - 'IssueApiKeyRequest' - ), - }; - - let authenticationPromise = Promise.resolve(); - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: IssueApiKeyResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize(body, 'IssueApiKeyResponse'); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * Deletes an account request by its ID. Requires admin or superadmin credentials. - * @summary Delete an account request by ID - * @param id ID of the account request to delete - * @param xUserPassword Password of the admin or superadmin user - * @param xUserEmail Email of an admin or superadmin user - */ - public async authControllerDeleteAccountRequest( - id: string, - xUserPassword?: string, - xUserEmail?: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: NewAccountRequestResponse; - }> { - const localVarPath = - this.basePath + - '/auth/account-request/{id}'.replace( - '{' + 'id' + '}', - encodeURIComponent(String(id)) - ); - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'id' is not null or undefined - if (id === null || id === undefined) { - throw new Error( - 'Required parameter id was null or undefined when calling authControllerDeleteAccountRequest.' - ); - } - - localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( - xUserPassword, - 'string' - ); - localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize( - xUserEmail, - 'string' - ); - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'DELETE', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: NewAccountRequestResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'NewAccountRequestResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * - * @summary Deletes an API key, detaching it from its project. - * @param authorization A valid API key - */ - public async authControllerDeleteApiKey( - authorization: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body?: any }> { - const localVarPath = this.basePath + '/auth/key'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - let localVarFormParams: any = {}; - - // verify required parameter 'authorization' is not null or undefined - if (authorization === null || authorization === undefined) { - throw new Error( - 'Required parameter authorization was null or undefined when calling authControllerDeleteApiKey.' - ); - } - - localVarHeaderParams['Authorization'] = ObjectSerializer.serialize( - authorization, - 'string' - ); - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'DELETE', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ response: http.IncomingMessage; body?: any }>( - (resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - } - ); - }); - } - /** - * Returns all pending account requests. Requires admin or superadmin credentials. - * @summary Retrieve all account requests - * @param xUserPassword Password of the admin or superadmin user - * @param xUserEmail Email of an admin or superadmin user - */ - public async authControllerGetAllAccountRequests( - xUserPassword?: string, - xUserEmail?: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ - response: http.IncomingMessage; - body: NewAccountRequestsResponse; - }> { - const localVarPath = this.basePath + '/auth/account-request'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( - xUserPassword, - 'string' - ); - localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize( - xUserEmail, - 'string' - ); - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: NewAccountRequestsResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize( - body, - 'NewAccountRequestsResponse' - ); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * JSON Web Tokens are used for the vast majority of API-gateway calls. The Juno SDK provides the means of automatically authenticating through this route given a valid API key. - * @summary Generates a temporary JWT for the project tied to a specified API key. - * @param authorization A valid API key - */ - public async authControllerGetApiKeyJWT( - authorization: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: IssueJWTResponse }> { - const localVarPath = this.basePath + '/auth/api_key/jwt'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'authorization' is not null or undefined - if (authorization === null || authorization === undefined) { - throw new Error( - 'Required parameter authorization was null or undefined when calling authControllerGetApiKeyJWT.' - ); - } - - localVarHeaderParams['Authorization'] = ObjectSerializer.serialize( - authorization, - 'string' - ); - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: IssueJWTResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize(body, 'IssueJWTResponse'); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * JSON Web Tokens are used for the vast majority of API-gateway calls. The Juno SDK provides the means of automatically authenticating through this route given valid user credentials. - * @summary Generates a temporary JWT tied to a specified user. - * @param xUserPassword Password of the user - * @param xUserEmail Email of a user - */ - public async authControllerGetUserJWT( - xUserPassword: string, - xUserEmail: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body: IssueJWTResponse }> { - const localVarPath = this.basePath + '/auth/user/jwt'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - const produces = ['application/json']; - // give precedence to 'application/json' - if (produces.indexOf('application/json') >= 0) { - localVarHeaderParams.Accept = 'application/json'; - } else { - localVarHeaderParams.Accept = produces.join(','); - } - let localVarFormParams: any = {}; - - // verify required parameter 'xUserPassword' is not null or undefined - if (xUserPassword === null || xUserPassword === undefined) { - throw new Error( - 'Required parameter xUserPassword was null or undefined when calling authControllerGetUserJWT.' - ); - } - - // verify required parameter 'xUserEmail' is not null or undefined - if (xUserEmail === null || xUserEmail === undefined) { - throw new Error( - 'Required parameter xUserEmail was null or undefined when calling authControllerGetUserJWT.' - ); - } - - localVarHeaderParams['X-User-Password'] = ObjectSerializer.serialize( - xUserPassword, - 'string' - ); - localVarHeaderParams['X-User-Email'] = ObjectSerializer.serialize( - xUserEmail, - 'string' - ); - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'POST', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ - response: http.IncomingMessage; - body: IssueJWTResponse; - }>((resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - body = ObjectSerializer.deserialize(body, 'IssueJWTResponse'); - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - }); - }); - } - /** - * This endpoint validates a user JWT token and returns the associated user information if valid - * @summary Validates user JWT and returns user data - * @param authorization Bearer token (User JWT) - */ - public async authControllerTestAuth( - authorization: string, - options: { headers: { [name: string]: string } } = { headers: {} } - ): Promise<{ response: http.IncomingMessage; body?: any }> { - const localVarPath = this.basePath + '/auth/test-auth'; - let localVarQueryParameters: any = {}; - let localVarHeaderParams: any = (Object).assign( - {}, - this._defaultHeaders - ); - let localVarFormParams: any = {}; - - // verify required parameter 'authorization' is not null or undefined - if (authorization === null || authorization === undefined) { - throw new Error( - 'Required parameter authorization was null or undefined when calling authControllerTestAuth.' - ); - } - - localVarHeaderParams['Authorization'] = ObjectSerializer.serialize( - authorization, - 'string' - ); - (Object).assign(localVarHeaderParams, options.headers); - - let localVarUseFormData = false; - - let localVarRequestOptions: localVarRequest.Options = { - method: 'GET', - qs: localVarQueryParameters, - headers: localVarHeaderParams, - uri: localVarPath, - useQuerystring: this._useQuerystring, - json: true, - }; - - let authenticationPromise = Promise.resolve(); - if (this.authentications.API_Key.accessToken) { - authenticationPromise = authenticationPromise.then(() => - this.authentications.API_Key.applyToRequest(localVarRequestOptions) - ); - } - authenticationPromise = authenticationPromise.then(() => - this.authentications.default.applyToRequest(localVarRequestOptions) - ); - - let interceptorPromise = authenticationPromise; - for (const interceptor of this.interceptors) { - interceptorPromise = interceptorPromise.then(() => - interceptor(localVarRequestOptions) - ); - } - - return interceptorPromise.then(() => { - if (Object.keys(localVarFormParams).length) { - if (localVarUseFormData) { - (localVarRequestOptions).formData = localVarFormParams; - } else { - localVarRequestOptions.form = localVarFormParams; - } - } - return new Promise<{ response: http.IncomingMessage; body?: any }>( - (resolve, reject) => { - localVarRequest(localVarRequestOptions, (error, response, body) => { - if (error) { - reject(error); - } else { - if ( - response.statusCode && - response.statusCode >= 200 && - response.statusCode <= 299 - ) { - resolve({ response: response, body: body }); - } else { - reject(new HttpError(response, body, response.statusCode)); - } - } - }); - } - ); - }); - } -} diff --git a/src/internal/apis/AuthApi.ts b/src/internal/apis/AuthApi.ts index 092f8da..69da3ab 100644 --- a/src/internal/apis/AuthApi.ts +++ b/src/internal/apis/AuthApi.ts @@ -14,6 +14,7 @@ import * as runtime from '../runtime'; import type { + AcceptAccountRequestResponseModel, IssueApiKeyRequest, IssueApiKeyResponse, IssueJWTResponse, @@ -22,6 +23,8 @@ import type { RequestNewAccountModel, } from '../models/index'; import { + AcceptAccountRequestResponseModelFromJSON, + AcceptAccountRequestResponseModelToJSON, IssueApiKeyRequestFromJSON, IssueApiKeyRequestToJSON, IssueApiKeyResponseFromJSON, @@ -36,6 +39,12 @@ import { RequestNewAccountModelToJSON, } from '../models/index'; +export interface AuthControllerAcceptAccountRequestRequest { + id: string; + xUserPassword?: string; + xUserEmail?: string; +} + export interface AuthControllerCreateAccountRequestRequest { requestNewAccountModel: RequestNewAccountModel; } @@ -48,8 +57,8 @@ export interface AuthControllerCreateApiKeyRequest { export interface AuthControllerDeleteAccountRequestRequest { id: string; - xUserPassword: string; - xUserEmail: string; + xUserPassword?: string; + xUserEmail?: string; } export interface AuthControllerDeleteApiKeyRequest { @@ -57,8 +66,8 @@ export interface AuthControllerDeleteApiKeyRequest { } export interface AuthControllerGetAllAccountRequestsRequest { - xUserPassword: string; - xUserEmail: string; + xUserPassword?: string; + xUserEmail?: string; } export interface AuthControllerGetApiKeyJWTRequest { @@ -78,6 +87,78 @@ export interface AuthControllerTestAuthRequest { * */ export class AuthApi extends runtime.BaseAPI { + /** + * Accepts a pending account request: creates the user, optionally creates/links a project (for ADMIN requests with a projectName), and deletes the pending request. Requires admin or superadmin credentials. + * Accept an account request + */ + async authControllerAcceptAccountRequestRaw( + requestParameters: AuthControllerAcceptAccountRequestRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if (requestParameters['id'] == null) { + throw new runtime.RequiredError( + 'id', + 'Required parameter "id" was null or undefined when calling authControllerAcceptAccountRequest().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (requestParameters['xUserPassword'] != null) { + headerParameters['X-User-Password'] = String( + requestParameters['xUserPassword'] + ); + } + + if (requestParameters['xUserEmail'] != null) { + headerParameters['X-User-Email'] = String( + requestParameters['xUserEmail'] + ); + } + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token('API_Key', []); + + if (tokenString) { + headerParameters['Authorization'] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/auth/account-request/{id}/accept`.replace( + `{${'id'}}`, + encodeURIComponent(String(requestParameters['id'])) + ), + method: 'POST', + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + AcceptAccountRequestResponseModelFromJSON(jsonValue) + ); + } + + /** + * Accepts a pending account request: creates the user, optionally creates/links a project (for ADMIN requests with a projectName), and deletes the pending request. Requires admin or superadmin credentials. + * Accept an account request + */ + async authControllerAcceptAccountRequest( + requestParameters: AuthControllerAcceptAccountRequestRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.authControllerAcceptAccountRequestRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + /** * Allows a prospective user to submit a request for a new account. The request is stored and can be reviewed by an admin. * Submit a new account request @@ -223,20 +304,6 @@ export class AuthApi extends runtime.BaseAPI { ); } - if (requestParameters['xUserPassword'] == null) { - throw new runtime.RequiredError( - 'xUserPassword', - 'Required parameter "xUserPassword" was null or undefined when calling authControllerDeleteAccountRequest().' - ); - } - - if (requestParameters['xUserEmail'] == null) { - throw new runtime.RequiredError( - 'xUserEmail', - 'Required parameter "xUserEmail" was null or undefined when calling authControllerDeleteAccountRequest().' - ); - } - const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -357,20 +424,6 @@ export class AuthApi extends runtime.BaseAPI { requestParameters: AuthControllerGetAllAccountRequestsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction ): Promise> { - if (requestParameters['xUserPassword'] == null) { - throw new runtime.RequiredError( - 'xUserPassword', - 'Required parameter "xUserPassword" was null or undefined when calling authControllerGetAllAccountRequests().' - ); - } - - if (requestParameters['xUserEmail'] == null) { - throw new runtime.RequiredError( - 'xUserEmail', - 'Required parameter "xUserEmail" was null or undefined when calling authControllerGetAllAccountRequests().' - ); - } - const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -415,7 +468,7 @@ export class AuthApi extends runtime.BaseAPI { * Retrieve all account requests */ async authControllerGetAllAccountRequests( - requestParameters: AuthControllerGetAllAccountRequestsRequest, + requestParameters: AuthControllerGetAllAccountRequestsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction ): Promise { const response = await this.authControllerGetAllAccountRequestsRaw( diff --git a/src/internal/model/acceptAccountRequestResponseModel.ts b/src/internal/model/acceptAccountRequestResponseModel.ts deleted file mode 100644 index a726444..0000000 --- a/src/internal/model/acceptAccountRequestResponseModel.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { RequestFile } from './models'; -import { AcceptAccountRequestResponseProject } from './acceptAccountRequestResponseProject'; -import { AcceptAccountRequestResponseUser } from './acceptAccountRequestResponseUser'; - -export class AcceptAccountRequestResponseModel { - /** - * The created user - */ - 'user': AcceptAccountRequestResponseUser; - /** - * The created or linked project (if applicable) - */ - 'project'?: AcceptAccountRequestResponseProject; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }> = [ - { - name: 'user', - baseName: 'user', - type: 'AcceptAccountRequestResponseUser', - }, - { - name: 'project', - baseName: 'project', - type: 'AcceptAccountRequestResponseProject', - }, - ]; - - static getAttributeTypeMap() { - return AcceptAccountRequestResponseModel.attributeTypeMap; - } -} diff --git a/src/internal/model/acceptAccountRequestResponseProject.ts b/src/internal/model/acceptAccountRequestResponseProject.ts deleted file mode 100644 index d30775b..0000000 --- a/src/internal/model/acceptAccountRequestResponseProject.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { RequestFile } from './models'; - -export class AcceptAccountRequestResponseProject { - /** - * Project ID - */ - 'id': number; - /** - * Project name - */ - 'name': string; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }> = [ - { - name: 'id', - baseName: 'id', - type: 'number', - }, - { - name: 'name', - baseName: 'name', - type: 'string', - }, - ]; - - static getAttributeTypeMap() { - return AcceptAccountRequestResponseProject.attributeTypeMap; - } -} diff --git a/src/internal/model/acceptAccountRequestResponseUser.ts b/src/internal/model/acceptAccountRequestResponseUser.ts deleted file mode 100644 index 5f3ace3..0000000 --- a/src/internal/model/acceptAccountRequestResponseUser.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { RequestFile } from './models'; - -export class AcceptAccountRequestResponseUser { - /** - * User ID - */ - 'id': number; - /** - * Email - */ - 'email': string; - /** - * Name - */ - 'name': string; - /** - * User type - */ - 'type': AcceptAccountRequestResponseUser.TypeEnum; - /** - * Project IDs the user is linked to - */ - 'projectIds'?: Array; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }> = [ - { - name: 'id', - baseName: 'id', - type: 'number', - }, - { - name: 'email', - baseName: 'email', - type: 'string', - }, - { - name: 'name', - baseName: 'name', - type: 'string', - }, - { - name: 'type', - baseName: 'type', - type: 'AcceptAccountRequestResponseUser.TypeEnum', - }, - { - name: 'projectIds', - baseName: 'projectIds', - type: 'Array', - }, - ]; - - static getAttributeTypeMap() { - return AcceptAccountRequestResponseUser.attributeTypeMap; - } -} - -export namespace AcceptAccountRequestResponseUser { - export enum TypeEnum { - Superadmin = 'SUPERADMIN', - Admin = 'ADMIN', - User = 'USER', - } -} diff --git a/src/internal/model/fileProvider.ts b/src/internal/model/fileProvider.ts deleted file mode 100644 index 5c8ccef..0000000 --- a/src/internal/model/fileProvider.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { RequestFile } from './models'; -import { AccessKey } from './accessKey'; - -export class FileProvider { - /** - * The access key to register with - */ - 'accessKey': AccessKey; - /** - * The base url associated with file provider. - */ - 'baseUrl': string; - /** - * The file provider name being registered. - */ - 'providerName': string; - /** - * File provider type (one of S3 or AZURE) - */ - 'type': string; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }> = [ - { - name: 'accessKey', - baseName: 'accessKey', - type: 'AccessKey', - }, - { - name: 'baseUrl', - baseName: 'baseUrl', - type: 'string', - }, - { - name: 'providerName', - baseName: 'providerName', - type: 'string', - }, - { - name: 'type', - baseName: 'type', - type: 'string', - }, - ]; - - static getAttributeTypeMap() { - return FileProvider.attributeTypeMap; - } -} diff --git a/src/internal/model/models.ts b/src/internal/model/models.ts deleted file mode 100644 index 88907ad..0000000 --- a/src/internal/model/models.ts +++ /dev/null @@ -1,482 +0,0 @@ -import localVarRequest from 'request'; - -export * from './acceptAccountRequestResponseModel'; -export * from './acceptAccountRequestResponseProject'; -export * from './acceptAccountRequestResponseUser'; -export * from './accessKey'; -export * from './aggregateInterval'; -export * from './analyticsConfigResponse'; -export * from './clickEventProperties'; -export * from './clickEventResponse'; -export * from './createAnalyticsConfigModel'; -export * from './createProjectModel'; -export * from './createUserModel'; -export * from './customEventResponse'; -export * from './customEventTypeResponse'; -export * from './customGraphType'; -export * from './customGraphTypeResponse'; -export * from './deleteFileBucketModel'; -export * from './downloadFileModel'; -export * from './downloadFileResponse'; -export * from './emailConfigResponse'; -export * from './emailContent'; -export * from './emailDomain'; -export * from './emailRecipient'; -export * from './emailSender'; -export * from './emailSenderSendEmailModel'; -export * from './fileBucket'; -export * from './fileConfigResponse'; -export * from './fileProvider'; -export * from './fileProviderPartial'; -export * from './getAllClickEventsResponse'; -export * from './getAllCustomEventTypeResponse'; -export * from './getAllCustomEventsResponse'; -export * from './getAllInputEventsResponse'; -export * from './getAllVisitEventsResponse'; -export * from './getClickEventsResponse'; -export * from './getCustomEventsResponse'; -export * from './getInputEventsResponse'; -export * from './getVisitEventsResponse'; -export * from './inputEventProperties'; -export * from './inputEventResponse'; -export * from './issueApiKeyRequest'; -export * from './issueApiKeyResponse'; -export * from './issueJWTResponse'; -export * from './linkProjectModel'; -export * from './linkUserModel'; -export * from './logClickEventRequest'; -export * from './logCustomEventRequest'; -export * from './logInputEventRequest'; -export * from './logVisitEventRequest'; -export * from './modelFile'; -export * from './newAccountRequestResponse'; -export * from './newAccountRequestsResponse'; -export * from './projectResponse'; -export * from './registerDomainModel'; -export * from './registerDomainResponse'; -export * from './registerEmailModel'; -export * from './registerEmailResponse'; -export * from './registerFileBucketModel'; -export * from './registerFileProviderModel'; -export * from './requestNewAccountModel'; -export * from './sendEmailModel'; -export * from './sendEmailResponse'; -export * from './sendEmailStatisticsResponse'; -export * from './sendEmailStatisticsResponses'; -export * from './sendGridDNSRecord'; -export * from './sendGridDNSResponse'; -export * from './setUserTypeModel'; -export * from './setupEmailResponse'; -export * from './setupEmailServiceModel'; -export * from './setupFileServiceResponse'; -export * from './unlinkProjectModel'; -export * from './updateAnalyticsConfigModel'; -export * from './uploadFileModel'; -export * from './uploadFileResponse'; -export * from './userResponse'; -export * from './userResponses'; -export * from './verifyDomainModel'; -export * from './visitEventProperties'; -export * from './visitEventResponse'; - -import * as fs from 'fs'; - -export interface RequestDetailedFile { - value: Buffer; - options?: { - filename?: string; - contentType?: string; - }; -} - -export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; - -import { AcceptAccountRequestResponseModel } from './acceptAccountRequestResponseModel'; -import { AcceptAccountRequestResponseProject } from './acceptAccountRequestResponseProject'; -import { AcceptAccountRequestResponseUser } from './acceptAccountRequestResponseUser'; -import { AccessKey } from './accessKey'; -import { AggregateInterval } from './aggregateInterval'; -import { AnalyticsConfigResponse } from './analyticsConfigResponse'; -import { ClickEventProperties } from './clickEventProperties'; -import { ClickEventResponse } from './clickEventResponse'; -import { CreateAnalyticsConfigModel } from './createAnalyticsConfigModel'; -import { CreateProjectModel } from './createProjectModel'; -import { CreateUserModel } from './createUserModel'; -import { CustomEventResponse } from './customEventResponse'; -import { CustomEventTypeResponse } from './customEventTypeResponse'; -import { CustomGraphType } from './customGraphType'; -import { CustomGraphTypeResponse } from './customGraphTypeResponse'; -import { DeleteFileBucketModel } from './deleteFileBucketModel'; -import { DownloadFileModel } from './downloadFileModel'; -import { DownloadFileResponse } from './downloadFileResponse'; -import { EmailConfigResponse } from './emailConfigResponse'; -import { EmailContent } from './emailContent'; -import { EmailDomain } from './emailDomain'; -import { EmailRecipient } from './emailRecipient'; -import { EmailSender } from './emailSender'; -import { EmailSenderSendEmailModel } from './emailSenderSendEmailModel'; -import { FileBucket } from './fileBucket'; -import { FileConfigResponse } from './fileConfigResponse'; -import { FileProvider } from './fileProvider'; -import { FileProviderPartial } from './fileProviderPartial'; -import { GetAllClickEventsResponse } from './getAllClickEventsResponse'; -import { GetAllCustomEventTypeResponse } from './getAllCustomEventTypeResponse'; -import { GetAllCustomEventsResponse } from './getAllCustomEventsResponse'; -import { GetAllInputEventsResponse } from './getAllInputEventsResponse'; -import { GetAllVisitEventsResponse } from './getAllVisitEventsResponse'; -import { GetClickEventsResponse } from './getClickEventsResponse'; -import { GetCustomEventsResponse } from './getCustomEventsResponse'; -import { GetInputEventsResponse } from './getInputEventsResponse'; -import { GetVisitEventsResponse } from './getVisitEventsResponse'; -import { InputEventProperties } from './inputEventProperties'; -import { InputEventResponse } from './inputEventResponse'; -import { IssueApiKeyRequest } from './issueApiKeyRequest'; -import { IssueApiKeyResponse } from './issueApiKeyResponse'; -import { IssueJWTResponse } from './issueJWTResponse'; -import { LinkProjectModel } from './linkProjectModel'; -import { LinkUserModel } from './linkUserModel'; -import { LogClickEventRequest } from './logClickEventRequest'; -import { LogCustomEventRequest } from './logCustomEventRequest'; -import { LogInputEventRequest } from './logInputEventRequest'; -import { LogVisitEventRequest } from './logVisitEventRequest'; -import { ModelFile } from './modelFile'; -import { NewAccountRequestResponse } from './newAccountRequestResponse'; -import { NewAccountRequestsResponse } from './newAccountRequestsResponse'; -import { ProjectResponse } from './projectResponse'; -import { RegisterDomainModel } from './registerDomainModel'; -import { RegisterDomainResponse } from './registerDomainResponse'; -import { RegisterEmailModel } from './registerEmailModel'; -import { RegisterEmailResponse } from './registerEmailResponse'; -import { RegisterFileBucketModel } from './registerFileBucketModel'; -import { RegisterFileProviderModel } from './registerFileProviderModel'; -import { RequestNewAccountModel } from './requestNewAccountModel'; -import { SendEmailModel } from './sendEmailModel'; -import { SendEmailResponse } from './sendEmailResponse'; -import { SendEmailStatisticsResponse } from './sendEmailStatisticsResponse'; -import { SendEmailStatisticsResponses } from './sendEmailStatisticsResponses'; -import { SendGridDNSRecord } from './sendGridDNSRecord'; -import { SendGridDNSResponse } from './sendGridDNSResponse'; -import { SetUserTypeModel } from './setUserTypeModel'; -import { SetupEmailResponse } from './setupEmailResponse'; -import { SetupEmailServiceModel } from './setupEmailServiceModel'; -import { SetupFileServiceResponse } from './setupFileServiceResponse'; -import { UnlinkProjectModel } from './unlinkProjectModel'; -import { UpdateAnalyticsConfigModel } from './updateAnalyticsConfigModel'; -import { UploadFileModel } from './uploadFileModel'; -import { UploadFileResponse } from './uploadFileResponse'; -import { UserResponse } from './userResponse'; -import { UserResponses } from './userResponses'; -import { VerifyDomainModel } from './verifyDomainModel'; -import { VisitEventProperties } from './visitEventProperties'; -import { VisitEventResponse } from './visitEventResponse'; - -/* tslint:disable:no-unused-variable */ -let primitives = [ - 'string', - 'boolean', - 'double', - 'integer', - 'long', - 'float', - 'number', - 'any', -]; - -let enumsMap: { [index: string]: any } = { - 'AcceptAccountRequestResponseUser.TypeEnum': - AcceptAccountRequestResponseUser.TypeEnum, - AggregateInterval: AggregateInterval, - 'NewAccountRequestResponse.UserTypeEnum': - NewAccountRequestResponse.UserTypeEnum, - 'RequestNewAccountModel.UserTypeEnum': RequestNewAccountModel.UserTypeEnum, - 'SetUserTypeModel.TypeEnum': SetUserTypeModel.TypeEnum, - 'UserResponse.TypeEnum': UserResponse.TypeEnum, -}; - -let typeMap: { [index: string]: any } = { - AcceptAccountRequestResponseModel: AcceptAccountRequestResponseModel, - AcceptAccountRequestResponseProject: AcceptAccountRequestResponseProject, - AcceptAccountRequestResponseUser: AcceptAccountRequestResponseUser, - AccessKey: AccessKey, - AnalyticsConfigResponse: AnalyticsConfigResponse, - ClickEventProperties: ClickEventProperties, - ClickEventResponse: ClickEventResponse, - CreateAnalyticsConfigModel: CreateAnalyticsConfigModel, - CreateProjectModel: CreateProjectModel, - CreateUserModel: CreateUserModel, - CustomEventResponse: CustomEventResponse, - CustomEventTypeResponse: CustomEventTypeResponse, - CustomGraphType: CustomGraphType, - CustomGraphTypeResponse: CustomGraphTypeResponse, - DeleteFileBucketModel: DeleteFileBucketModel, - DownloadFileModel: DownloadFileModel, - DownloadFileResponse: DownloadFileResponse, - EmailConfigResponse: EmailConfigResponse, - EmailContent: EmailContent, - EmailDomain: EmailDomain, - EmailRecipient: EmailRecipient, - EmailSender: EmailSender, - EmailSenderSendEmailModel: EmailSenderSendEmailModel, - FileBucket: FileBucket, - FileConfigResponse: FileConfigResponse, - FileProvider: FileProvider, - FileProviderPartial: FileProviderPartial, - GetAllClickEventsResponse: GetAllClickEventsResponse, - GetAllCustomEventTypeResponse: GetAllCustomEventTypeResponse, - GetAllCustomEventsResponse: GetAllCustomEventsResponse, - GetAllInputEventsResponse: GetAllInputEventsResponse, - GetAllVisitEventsResponse: GetAllVisitEventsResponse, - GetClickEventsResponse: GetClickEventsResponse, - GetCustomEventsResponse: GetCustomEventsResponse, - GetInputEventsResponse: GetInputEventsResponse, - GetVisitEventsResponse: GetVisitEventsResponse, - InputEventProperties: InputEventProperties, - InputEventResponse: InputEventResponse, - IssueApiKeyRequest: IssueApiKeyRequest, - IssueApiKeyResponse: IssueApiKeyResponse, - IssueJWTResponse: IssueJWTResponse, - LinkProjectModel: LinkProjectModel, - LinkUserModel: LinkUserModel, - LogClickEventRequest: LogClickEventRequest, - LogCustomEventRequest: LogCustomEventRequest, - LogInputEventRequest: LogInputEventRequest, - LogVisitEventRequest: LogVisitEventRequest, - ModelFile: ModelFile, - NewAccountRequestResponse: NewAccountRequestResponse, - NewAccountRequestsResponse: NewAccountRequestsResponse, - ProjectResponse: ProjectResponse, - RegisterDomainModel: RegisterDomainModel, - RegisterDomainResponse: RegisterDomainResponse, - RegisterEmailModel: RegisterEmailModel, - RegisterEmailResponse: RegisterEmailResponse, - RegisterFileBucketModel: RegisterFileBucketModel, - RegisterFileProviderModel: RegisterFileProviderModel, - RequestNewAccountModel: RequestNewAccountModel, - SendEmailModel: SendEmailModel, - SendEmailResponse: SendEmailResponse, - SendEmailStatisticsResponse: SendEmailStatisticsResponse, - SendEmailStatisticsResponses: SendEmailStatisticsResponses, - SendGridDNSRecord: SendGridDNSRecord, - SendGridDNSResponse: SendGridDNSResponse, - SetUserTypeModel: SetUserTypeModel, - SetupEmailResponse: SetupEmailResponse, - SetupEmailServiceModel: SetupEmailServiceModel, - SetupFileServiceResponse: SetupFileServiceResponse, - UnlinkProjectModel: UnlinkProjectModel, - UpdateAnalyticsConfigModel: UpdateAnalyticsConfigModel, - UploadFileModel: UploadFileModel, - UploadFileResponse: UploadFileResponse, - UserResponse: UserResponse, - UserResponses: UserResponses, - VerifyDomainModel: VerifyDomainModel, - VisitEventProperties: VisitEventProperties, - VisitEventResponse: VisitEventResponse, -}; - -export class ObjectSerializer { - public static findCorrectType(data: any, expectedType: string) { - if (data == undefined) { - return expectedType; - } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { - return expectedType; - } else if (expectedType === 'Date') { - return expectedType; - } else { - if (enumsMap[expectedType]) { - return expectedType; - } - - if (!typeMap[expectedType]) { - return expectedType; // w/e we don't know the type - } - - // Check the discriminator - let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { - return expectedType; // the type does not have a discriminator. use it. - } else { - if (data[discriminatorProperty]) { - var discriminatorType = data[discriminatorProperty]; - if (typeMap[discriminatorType]) { - return discriminatorType; // use the type given in the discriminator - } else { - return expectedType; // discriminator did not map to a type - } - } else { - return expectedType; // discriminator was not present (or an empty string) - } - } - } - } - - public static serialize(data: any, type: string) { - if (data == undefined) { - return data; - } else if (primitives.indexOf(type.toLowerCase()) !== -1) { - return data; - } else if (type.lastIndexOf('Array<', 0) === 0) { - // string.startsWith pre es6 - let subType: string = type.replace('Array<', ''); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type - let transformedData: any[] = []; - for (let index = 0; index < data.length; index++) { - let datum = data[index]; - transformedData.push(ObjectSerializer.serialize(datum, subType)); - } - return transformedData; - } else if (type === 'Date') { - return data.toISOString(); - } else { - if (enumsMap[type]) { - return data; - } - if (!typeMap[type]) { - // in case we dont know the type - return data; - } - - // Get the actual type of this object - type = this.findCorrectType(data, type); - - // get the map for the correct type. - let attributeTypes = typeMap[type].getAttributeTypeMap(); - let instance: { [index: string]: any } = {}; - for (let index = 0; index < attributeTypes.length; index++) { - let attributeType = attributeTypes[index]; - instance[attributeType.baseName] = ObjectSerializer.serialize( - data[attributeType.name], - attributeType.type - ); - } - return instance; - } - } - - public static deserialize(data: any, type: string) { - // polymorphism may change the actual type. - type = ObjectSerializer.findCorrectType(data, type); - if (data == undefined) { - return data; - } else if (primitives.indexOf(type.toLowerCase()) !== -1) { - return data; - } else if (type.lastIndexOf('Array<', 0) === 0) { - // string.startsWith pre es6 - let subType: string = type.replace('Array<', ''); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type - let transformedData: any[] = []; - for (let index = 0; index < data.length; index++) { - let datum = data[index]; - transformedData.push(ObjectSerializer.deserialize(datum, subType)); - } - return transformedData; - } else if (type === 'Date') { - return new Date(data); - } else { - if (enumsMap[type]) { - // is Enum - return data; - } - - if (!typeMap[type]) { - // dont know the type - return data; - } - let instance = new typeMap[type](); - let attributeTypes = typeMap[type].getAttributeTypeMap(); - for (let index = 0; index < attributeTypes.length; index++) { - let attributeType = attributeTypes[index]; - instance[attributeType.name] = ObjectSerializer.deserialize( - data[attributeType.baseName], - attributeType.type - ); - } - return instance; - } - } -} - -export interface Authentication { - /** - * Apply authentication settings to header and query params. - */ - applyToRequest(requestOptions: localVarRequest.Options): Promise | void; -} - -export class HttpBasicAuth implements Authentication { - public username: string = ''; - public password: string = ''; - - applyToRequest(requestOptions: localVarRequest.Options): void { - requestOptions.auth = { - username: this.username, - password: this.password, - }; - } -} - -export class HttpBearerAuth implements Authentication { - public accessToken: string | (() => string) = ''; - - applyToRequest(requestOptions: localVarRequest.Options): void { - if (requestOptions && requestOptions.headers) { - const accessToken = - typeof this.accessToken === 'function' - ? this.accessToken() - : this.accessToken; - requestOptions.headers['Authorization'] = 'Bearer ' + accessToken; - } - } -} - -export class ApiKeyAuth implements Authentication { - public apiKey: string = ''; - - constructor(private location: string, private paramName: string) {} - - applyToRequest(requestOptions: localVarRequest.Options): void { - if (this.location == 'query') { - (requestOptions.qs)[this.paramName] = this.apiKey; - } else if ( - this.location == 'header' && - requestOptions && - requestOptions.headers - ) { - requestOptions.headers[this.paramName] = this.apiKey; - } else if ( - this.location == 'cookie' && - requestOptions && - requestOptions.headers - ) { - if (requestOptions.headers['Cookie']) { - requestOptions.headers['Cookie'] += - '; ' + this.paramName + '=' + encodeURIComponent(this.apiKey); - } else { - requestOptions.headers['Cookie'] = - this.paramName + '=' + encodeURIComponent(this.apiKey); - } - } - } -} - -export class OAuth implements Authentication { - public accessToken: string = ''; - - applyToRequest(requestOptions: localVarRequest.Options): void { - if (requestOptions && requestOptions.headers) { - requestOptions.headers['Authorization'] = 'Bearer ' + this.accessToken; - } - } -} - -export class VoidAuth implements Authentication { - public username: string = ''; - public password: string = ''; - - applyToRequest(_: localVarRequest.Options): void { - // Do nothing - } -} - -export type Interceptor = ( - requestOptions: localVarRequest.Options -) => Promise | void; diff --git a/src/internal/model/newAccountRequestResponse.ts b/src/internal/model/newAccountRequestResponse.ts deleted file mode 100644 index 7e2521f..0000000 --- a/src/internal/model/newAccountRequestResponse.ts +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { RequestFile } from './models'; - -export class NewAccountRequestResponse { - /** - * Request ID - */ - 'id': number; - /** - * Email - */ - 'email': string; - /** - * Name - */ - 'name': string; - /** - * Requested user type - */ - 'userType': NewAccountRequestResponse.UserTypeEnum; - /** - * Project name - */ - 'projectName'?: string; - /** - * Timestamp of request creation - */ - 'createdAt': string; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }> = [ - { - name: 'id', - baseName: 'id', - type: 'number', - }, - { - name: 'email', - baseName: 'email', - type: 'string', - }, - { - name: 'name', - baseName: 'name', - type: 'string', - }, - { - name: 'userType', - baseName: 'userType', - type: 'NewAccountRequestResponse.UserTypeEnum', - }, - { - name: 'projectName', - baseName: 'projectName', - type: 'string', - }, - { - name: 'createdAt', - baseName: 'createdAt', - type: 'string', - }, - ]; - - static getAttributeTypeMap() { - return NewAccountRequestResponse.attributeTypeMap; - } -} - -export namespace NewAccountRequestResponse { - export enum UserTypeEnum { - Superadmin = 'SUPERADMIN', - Admin = 'ADMIN', - User = 'USER', - } -} diff --git a/src/internal/model/newAccountRequestsResponse.ts b/src/internal/model/newAccountRequestsResponse.ts deleted file mode 100644 index 5c542d1..0000000 --- a/src/internal/model/newAccountRequestsResponse.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { RequestFile } from './models'; -import { NewAccountRequestResponse } from './newAccountRequestResponse'; - -export class NewAccountRequestsResponse { - /** - * List of new account requests - */ - 'requests': Array; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }> = [ - { - name: 'requests', - baseName: 'requests', - type: 'Array', - }, - ]; - - static getAttributeTypeMap() { - return NewAccountRequestsResponse.attributeTypeMap; - } -} diff --git a/src/internal/model/registerFileProviderModel.ts b/src/internal/model/registerFileProviderModel.ts deleted file mode 100644 index 78f8690..0000000 --- a/src/internal/model/registerFileProviderModel.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { RequestFile } from './models'; -import { AccessKey } from './accessKey'; - -export class RegisterFileProviderModel { - /** - * The access key to register with - */ - 'accessKey': AccessKey; - /** - * The base url associated with file provider. - */ - 'baseUrl': string; - /** - * The file provider name being registered. - */ - 'providerName': string; - /** - * File provider type (one of S3 or AZURE) - */ - 'type': string; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }> = [ - { - name: 'accessKey', - baseName: 'accessKey', - type: 'AccessKey', - }, - { - name: 'baseUrl', - baseName: 'baseUrl', - type: 'string', - }, - { - name: 'providerName', - baseName: 'providerName', - type: 'string', - }, - { - name: 'type', - baseName: 'type', - type: 'string', - }, - ]; - - static getAttributeTypeMap() { - return RegisterFileProviderModel.attributeTypeMap; - } -} diff --git a/src/internal/model/requestNewAccountModel.ts b/src/internal/model/requestNewAccountModel.ts deleted file mode 100644 index c53f5b8..0000000 --- a/src/internal/model/requestNewAccountModel.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Juno - * Juno Public API Docs - * - * The version of the OpenAPI document: 1.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { RequestFile } from './models'; - -export class RequestNewAccountModel { - /** - * Email for the new account - */ - 'email': string; - /** - * Name of the requester - */ - 'name': string; - /** - * Password for the new account - */ - 'password': string; - /** - * Requested user type / role - */ - 'userType': RequestNewAccountModel.UserTypeEnum; - /** - * Optional project name to associate - */ - 'projectName'?: string; - - static discriminator: string | undefined = undefined; - - static attributeTypeMap: Array<{ - name: string; - baseName: string; - type: string; - }> = [ - { - name: 'email', - baseName: 'email', - type: 'string', - }, - { - name: 'name', - baseName: 'name', - type: 'string', - }, - { - name: 'password', - baseName: 'password', - type: 'string', - }, - { - name: 'userType', - baseName: 'userType', - type: 'RequestNewAccountModel.UserTypeEnum', - }, - { - name: 'projectName', - baseName: 'projectName', - type: 'string', - }, - ]; - - static getAttributeTypeMap() { - return RequestNewAccountModel.attributeTypeMap; - } -} - -export namespace RequestNewAccountModel { - export enum UserTypeEnum { - Superadmin = 'SUPERADMIN', - Admin = 'ADMIN', - User = 'USER', - } -} diff --git a/src/internal/models/AcceptAccountRequestResponseModel.ts b/src/internal/models/AcceptAccountRequestResponseModel.ts new file mode 100644 index 0000000..7693d0e --- /dev/null +++ b/src/internal/models/AcceptAccountRequestResponseModel.ts @@ -0,0 +1,91 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { AcceptAccountRequestResponseProject } from './AcceptAccountRequestResponseProject'; +import { + AcceptAccountRequestResponseProjectFromJSON, + AcceptAccountRequestResponseProjectFromJSONTyped, + AcceptAccountRequestResponseProjectToJSON, +} from './AcceptAccountRequestResponseProject'; +import type { AcceptAccountRequestResponseUser } from './AcceptAccountRequestResponseUser'; +import { + AcceptAccountRequestResponseUserFromJSON, + AcceptAccountRequestResponseUserFromJSONTyped, + AcceptAccountRequestResponseUserToJSON, +} from './AcceptAccountRequestResponseUser'; + +/** + * + * @export + * @interface AcceptAccountRequestResponseModel + */ +export interface AcceptAccountRequestResponseModel { + /** + * The created user + * @type {AcceptAccountRequestResponseUser} + * @memberof AcceptAccountRequestResponseModel + */ + user: AcceptAccountRequestResponseUser; + /** + * The created or linked project (if applicable) + * @type {AcceptAccountRequestResponseProject} + * @memberof AcceptAccountRequestResponseModel + */ + project?: AcceptAccountRequestResponseProject; +} + +/** + * Check if a given object implements the AcceptAccountRequestResponseModel interface. + */ +export function instanceOfAcceptAccountRequestResponseModel( + value: object +): value is AcceptAccountRequestResponseModel { + if (!('user' in value) || value['user'] === undefined) return false; + return true; +} + +export function AcceptAccountRequestResponseModelFromJSON( + json: any +): AcceptAccountRequestResponseModel { + return AcceptAccountRequestResponseModelFromJSONTyped(json, false); +} + +export function AcceptAccountRequestResponseModelFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): AcceptAccountRequestResponseModel { + if (json == null) { + return json; + } + return { + user: AcceptAccountRequestResponseUserFromJSON(json['user']), + project: + json['project'] == null + ? undefined + : AcceptAccountRequestResponseProjectFromJSON(json['project']), + }; +} + +export function AcceptAccountRequestResponseModelToJSON( + value?: AcceptAccountRequestResponseModel | null +): any { + if (value == null) { + return value; + } + return { + user: AcceptAccountRequestResponseUserToJSON(value['user']), + project: AcceptAccountRequestResponseProjectToJSON(value['project']), + }; +} diff --git a/src/internal/models/AcceptAccountRequestResponseProject.ts b/src/internal/models/AcceptAccountRequestResponseProject.ts new file mode 100644 index 0000000..bc06d50 --- /dev/null +++ b/src/internal/models/AcceptAccountRequestResponseProject.ts @@ -0,0 +1,76 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface AcceptAccountRequestResponseProject + */ +export interface AcceptAccountRequestResponseProject { + /** + * Project ID + * @type {number} + * @memberof AcceptAccountRequestResponseProject + */ + id: number; + /** + * Project name + * @type {string} + * @memberof AcceptAccountRequestResponseProject + */ + name: string; +} + +/** + * Check if a given object implements the AcceptAccountRequestResponseProject interface. + */ +export function instanceOfAcceptAccountRequestResponseProject( + value: object +): value is AcceptAccountRequestResponseProject { + if (!('id' in value) || value['id'] === undefined) return false; + if (!('name' in value) || value['name'] === undefined) return false; + return true; +} + +export function AcceptAccountRequestResponseProjectFromJSON( + json: any +): AcceptAccountRequestResponseProject { + return AcceptAccountRequestResponseProjectFromJSONTyped(json, false); +} + +export function AcceptAccountRequestResponseProjectFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): AcceptAccountRequestResponseProject { + if (json == null) { + return json; + } + return { + id: json['id'], + name: json['name'], + }; +} + +export function AcceptAccountRequestResponseProjectToJSON( + value?: AcceptAccountRequestResponseProject | null +): any { + if (value == null) { + return value; + } + return { + id: value['id'], + name: value['name'], + }; +} diff --git a/src/internal/models/AcceptAccountRequestResponseUser.ts b/src/internal/models/AcceptAccountRequestResponseUser.ts new file mode 100644 index 0000000..b8343e8 --- /dev/null +++ b/src/internal/models/AcceptAccountRequestResponseUser.ts @@ -0,0 +1,113 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface AcceptAccountRequestResponseUser + */ +export interface AcceptAccountRequestResponseUser { + /** + * User ID + * @type {number} + * @memberof AcceptAccountRequestResponseUser + */ + id: number; + /** + * Email + * @type {string} + * @memberof AcceptAccountRequestResponseUser + */ + email: string; + /** + * Name + * @type {string} + * @memberof AcceptAccountRequestResponseUser + */ + name: string; + /** + * User type + * @type {string} + * @memberof AcceptAccountRequestResponseUser + */ + type: AcceptAccountRequestResponseUserTypeEnum; + /** + * Project IDs the user is linked to + * @type {Array} + * @memberof AcceptAccountRequestResponseUser + */ + projectIds?: Array; +} + +/** + * @export + */ +export const AcceptAccountRequestResponseUserTypeEnum = { + Superadmin: 'SUPERADMIN', + Admin: 'ADMIN', + User: 'USER', +} as const; +export type AcceptAccountRequestResponseUserTypeEnum = + (typeof AcceptAccountRequestResponseUserTypeEnum)[keyof typeof AcceptAccountRequestResponseUserTypeEnum]; + +/** + * Check if a given object implements the AcceptAccountRequestResponseUser interface. + */ +export function instanceOfAcceptAccountRequestResponseUser( + value: object +): value is AcceptAccountRequestResponseUser { + if (!('id' in value) || value['id'] === undefined) return false; + if (!('email' in value) || value['email'] === undefined) return false; + if (!('name' in value) || value['name'] === undefined) return false; + if (!('type' in value) || value['type'] === undefined) return false; + return true; +} + +export function AcceptAccountRequestResponseUserFromJSON( + json: any +): AcceptAccountRequestResponseUser { + return AcceptAccountRequestResponseUserFromJSONTyped(json, false); +} + +export function AcceptAccountRequestResponseUserFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): AcceptAccountRequestResponseUser { + if (json == null) { + return json; + } + return { + id: json['id'], + email: json['email'], + name: json['name'], + type: json['type'], + projectIds: json['projectIds'] == null ? undefined : json['projectIds'], + }; +} + +export function AcceptAccountRequestResponseUserToJSON( + value?: AcceptAccountRequestResponseUser | null +): any { + if (value == null) { + return value; + } + return { + id: value['id'], + email: value['email'], + name: value['name'], + type: value['type'], + projectIds: value['projectIds'], + }; +} diff --git a/src/internal/models/index.ts b/src/internal/models/index.ts index bb099d7..656538c 100644 --- a/src/internal/models/index.ts +++ b/src/internal/models/index.ts @@ -1,5 +1,8 @@ /* tslint:disable */ /* eslint-disable */ +export * from './AcceptAccountRequestResponseModel'; +export * from './AcceptAccountRequestResponseProject'; +export * from './AcceptAccountRequestResponseUser'; export * from './AccessKey'; export * from './AggregateInterval'; export * from './AnalyticsConfigResponse'; diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 9ad9b47..d080e14 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -8,6 +8,7 @@ import { NewAccountRequestsResponse, RequestNewAccountModel, RequestNewAccountModelUserTypeEnum, + AcceptAccountRequestResponseModel, } from '../internal/index'; import { validateString, validateUserCredentials } from './validators'; @@ -158,6 +159,40 @@ export class AuthAPI { } } + async acceptAccountRequest(options: { + id: string; + credentials: UserCredentials; + }): Promise { + let { id, credentials } = options; + + validateString(id, 'The request ID must be nonempty'); + validateUserCredentials(credentials); + + id = id.trim(); + + try { + if (typeof credentials == 'string') { + return await this.internalApi.authControllerAcceptAccountRequest( + { id }, + async ({ init }) => ({ + headers: { + ...(init.headers as Record), + Authorization: `Bearer ${credentials}`, + }, + }) + ); + } else { + return await this.internalApi.authControllerAcceptAccountRequest({ + id, + xUserPassword: credentials.password, + xUserEmail: credentials.email, + }); + } + } catch (e) { + throw e; + } + } + async deleteAccountRequest(options: { id: string; credentials: UserCredentials; From 8cd7457432627b14e94c1bd74ce554d152612b47 Mon Sep 17 00:00:00 2001 From: Long Lam Date: Sun, 12 Apr 2026 21:22:20 -0400 Subject: [PATCH 7/7] fix: merge internal folder from main --- src/internal/apis/AuthApi.ts | 143 ++++++++++++++----- src/internal/apis/FileBucketApi.ts | 60 ++++++++ src/internal/apis/FileDeleteApi.ts | 89 ++++++++++++ src/internal/apis/index.ts | 1 + src/internal/models/ApiKey.ts | 117 +++++++++++++++ src/internal/models/DeleteFilesModel.ts | 82 +++++++++++ src/internal/models/DeleteFilesResponse.ts | 75 ++++++++++ src/internal/models/GetAllApiKeysResponse.ts | 85 +++++++++++ src/internal/models/IssueApiKeyResponse.ts | 40 +++++- src/internal/models/PaginationParams.ts | 90 ++++++++++++ src/internal/models/index.ts | 5 + 11 files changed, 752 insertions(+), 35 deletions(-) create mode 100644 src/internal/apis/FileDeleteApi.ts create mode 100644 src/internal/models/ApiKey.ts create mode 100644 src/internal/models/DeleteFilesModel.ts create mode 100644 src/internal/models/DeleteFilesResponse.ts create mode 100644 src/internal/models/GetAllApiKeysResponse.ts create mode 100644 src/internal/models/PaginationParams.ts diff --git a/src/internal/apis/AuthApi.ts b/src/internal/apis/AuthApi.ts index 69da3ab..6dd5d5f 100644 --- a/src/internal/apis/AuthApi.ts +++ b/src/internal/apis/AuthApi.ts @@ -15,6 +15,7 @@ import * as runtime from '../runtime'; import type { AcceptAccountRequestResponseModel, + GetAllApiKeysResponse, IssueApiKeyRequest, IssueApiKeyResponse, IssueJWTResponse, @@ -25,6 +26,8 @@ import type { import { AcceptAccountRequestResponseModelFromJSON, AcceptAccountRequestResponseModelToJSON, + GetAllApiKeysResponseFromJSON, + GetAllApiKeysResponseToJSON, IssueApiKeyRequestFromJSON, IssueApiKeyRequestToJSON, IssueApiKeyResponseFromJSON, @@ -50,9 +53,9 @@ export interface AuthControllerCreateAccountRequestRequest { } export interface AuthControllerCreateApiKeyRequest { - xUserPassword: string; - xUserEmail: string; issueApiKeyRequest: IssueApiKeyRequest; + xUserPassword?: string; + xUserEmail?: string; } export interface AuthControllerDeleteAccountRequestRequest { @@ -61,8 +64,11 @@ export interface AuthControllerDeleteAccountRequestRequest { xUserEmail?: string; } -export interface AuthControllerDeleteApiKeyRequest { - authorization: string; +export interface AuthControllerDeleteApiKeyByIdRequest { + id: string; + xUserJwt?: string; + xUserPassword?: string; + xUserEmail?: string; } export interface AuthControllerGetAllAccountRequestsRequest { @@ -70,6 +76,13 @@ export interface AuthControllerGetAllAccountRequestsRequest { xUserEmail?: string; } +export interface AuthControllerGetAllApiKeysRequest { + offset?: number; + limit?: number; + xUserPassword?: string; + xUserEmail?: string; +} + export interface AuthControllerGetApiKeyJWTRequest { authorization: string; } @@ -220,20 +233,6 @@ export class AuthApi extends runtime.BaseAPI { requestParameters: AuthControllerCreateApiKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction ): Promise> { - if (requestParameters['xUserPassword'] == null) { - throw new runtime.RequiredError( - 'xUserPassword', - 'Required parameter "xUserPassword" was null or undefined when calling authControllerCreateApiKey().' - ); - } - - if (requestParameters['xUserEmail'] == null) { - throw new runtime.RequiredError( - 'xUserEmail', - 'Required parameter "xUserEmail" was null or undefined when calling authControllerCreateApiKey().' - ); - } - if (requestParameters['issueApiKeyRequest'] == null) { throw new runtime.RequiredError( 'issueApiKeyRequest', @@ -362,16 +361,16 @@ export class AuthApi extends runtime.BaseAPI { } /** - * Deletes an API key, detaching it from its project. + * Revokes an API key, detaching it from its project. */ - async authControllerDeleteApiKeyRaw( - requestParameters: AuthControllerDeleteApiKeyRequest, + async authControllerDeleteApiKeyByIdRaw( + requestParameters: AuthControllerDeleteApiKeyByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction ): Promise> { - if (requestParameters['authorization'] == null) { + if (requestParameters['id'] == null) { throw new runtime.RequiredError( - 'authorization', - 'Required parameter "authorization" was null or undefined when calling authControllerDeleteApiKey().' + 'id', + 'Required parameter "id" was null or undefined when calling authControllerDeleteApiKeyById().' ); } @@ -379,9 +378,19 @@ export class AuthApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - if (requestParameters['authorization'] != null) { - headerParameters['Authorization'] = String( - requestParameters['authorization'] + if (requestParameters['xUserJwt'] != null) { + headerParameters['x-user-jwt'] = String(requestParameters['xUserJwt']); + } + + if (requestParameters['xUserPassword'] != null) { + headerParameters['X-User-Password'] = String( + requestParameters['xUserPassword'] + ); + } + + if (requestParameters['xUserEmail'] != null) { + headerParameters['X-User-Email'] = String( + requestParameters['xUserEmail'] ); } @@ -395,7 +404,10 @@ export class AuthApi extends runtime.BaseAPI { } const response = await this.request( { - path: `/auth/key`, + path: `/auth/key/{id}`.replace( + `{${'id'}}`, + encodeURIComponent(String(requestParameters['id'])) + ), method: 'DELETE', headers: headerParameters, query: queryParameters, @@ -407,13 +419,16 @@ export class AuthApi extends runtime.BaseAPI { } /** - * Deletes an API key, detaching it from its project. + * Revokes an API key, detaching it from its project. */ - async authControllerDeleteApiKey( - requestParameters: AuthControllerDeleteApiKeyRequest, + async authControllerDeleteApiKeyById( + requestParameters: AuthControllerDeleteApiKeyByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction ): Promise { - await this.authControllerDeleteApiKeyRaw(requestParameters, initOverrides); + await this.authControllerDeleteApiKeyByIdRaw( + requestParameters, + initOverrides + ); } /** @@ -478,6 +493,66 @@ export class AuthApi extends runtime.BaseAPI { return await response.value(); } + /** + * Lists all API keys + */ + async authControllerGetAllApiKeysRaw( + requestParameters: AuthControllerGetAllApiKeysRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + const queryParameters: any = {}; + + if (requestParameters['offset'] != null) { + queryParameters['offset'] = requestParameters['offset']; + } + + if (requestParameters['limit'] != null) { + queryParameters['limit'] = requestParameters['limit']; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (requestParameters['xUserPassword'] != null) { + headerParameters['X-User-Password'] = String( + requestParameters['xUserPassword'] + ); + } + + if (requestParameters['xUserEmail'] != null) { + headerParameters['X-User-Email'] = String( + requestParameters['xUserEmail'] + ); + } + + const response = await this.request( + { + path: `/auth/key/all`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + GetAllApiKeysResponseFromJSON(jsonValue) + ); + } + + /** + * Lists all API keys + */ + async authControllerGetAllApiKeys( + requestParameters: AuthControllerGetAllApiKeysRequest = {}, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.authControllerGetAllApiKeysRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + /** * JSON Web Tokens are used for the vast majority of API-gateway calls. The Juno SDK provides the means of automatically authenticating through this route given a valid API key. * Generates a temporary JWT for the project tied to a specified API key. @@ -542,7 +617,7 @@ export class AuthApi extends runtime.BaseAPI { } /** - * JSON Web Tokens are used for the vast majority of API-gateway calls. The Juno SDK provides the means of automatically authenticating through this route given valid user credentials. + * Generates a user identity token that can be used to authenticate admin and management endpoints in place of email/password credentials. * Generates a temporary JWT tied to a specified user. */ async authControllerGetUserJWTRaw( @@ -603,7 +678,7 @@ export class AuthApi extends runtime.BaseAPI { } /** - * JSON Web Tokens are used for the vast majority of API-gateway calls. The Juno SDK provides the means of automatically authenticating through this route given valid user credentials. + * Generates a user identity token that can be used to authenticate admin and management endpoints in place of email/password credentials. * Generates a temporary JWT tied to a specified user. */ async authControllerGetUserJWT( diff --git a/src/internal/apis/FileBucketApi.ts b/src/internal/apis/FileBucketApi.ts index 1d5cd72..dcfa17a 100644 --- a/src/internal/apis/FileBucketApi.ts +++ b/src/internal/apis/FileBucketApi.ts @@ -31,6 +31,10 @@ export interface FileBucketControllerDeleteFileBucketRequest { deleteFileBucketModel: DeleteFileBucketModel; } +export interface FileBucketControllerGetAllFilesRequest { + configId: string; +} + export interface FileBucketControllerGetBucketsByConfigIdAndEnvRequest { configId: string; } @@ -103,6 +107,62 @@ export class FileBucketApi extends runtime.BaseAPI { return await response.value(); } + /** + * Get all files from all buckets for a config. + */ + async fileBucketControllerGetAllFilesRaw( + requestParameters: FileBucketControllerGetAllFilesRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise>> { + if (requestParameters['configId'] == null) { + throw new runtime.RequiredError( + 'configId', + 'Required parameter "configId" was null or undefined when calling fileBucketControllerGetAllFiles().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token('API_Key', []); + + if (tokenString) { + headerParameters['Authorization'] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/file/all/{configId}`.replace( + `{${'configId'}}`, + encodeURIComponent(String(requestParameters['configId'])) + ), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response); + } + + /** + * Get all files from all buckets for a config. + */ + async fileBucketControllerGetAllFiles( + requestParameters: FileBucketControllerGetAllFilesRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + const response = await this.fileBucketControllerGetAllFilesRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } + /** * Get File Buckets by Config Id and Config Env. */ diff --git a/src/internal/apis/FileDeleteApi.ts b/src/internal/apis/FileDeleteApi.ts new file mode 100644 index 0000000..c79df5e --- /dev/null +++ b/src/internal/apis/FileDeleteApi.ts @@ -0,0 +1,89 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import * as runtime from '../runtime'; +import type { DeleteFilesModel, DeleteFilesResponse } from '../models/index'; +import { + DeleteFilesModelFromJSON, + DeleteFilesModelToJSON, + DeleteFilesResponseFromJSON, + DeleteFilesResponseToJSON, +} from '../models/index'; + +export interface FileDeleteControllerDeleteFilesRequest { + deleteFilesModel: DeleteFilesModel; +} + +/** + * + */ +export class FileDeleteApi extends runtime.BaseAPI { + /** + * Delete files from a bucket + */ + async fileDeleteControllerDeleteFilesRaw( + requestParameters: FileDeleteControllerDeleteFilesRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise> { + if (requestParameters['deleteFilesModel'] == null) { + throw new runtime.RequiredError( + 'deleteFilesModel', + 'Required parameter "deleteFilesModel" was null or undefined when calling fileDeleteControllerDeleteFiles().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = await token('API_Key', []); + + if (tokenString) { + headerParameters['Authorization'] = `Bearer ${tokenString}`; + } + } + const response = await this.request( + { + path: `/file/delete`, + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + body: DeleteFilesModelToJSON(requestParameters['deleteFilesModel']), + }, + initOverrides + ); + + return new runtime.JSONApiResponse(response, (jsonValue) => + DeleteFilesResponseFromJSON(jsonValue) + ); + } + + /** + * Delete files from a bucket + */ + async fileDeleteControllerDeleteFiles( + requestParameters: FileDeleteControllerDeleteFilesRequest, + initOverrides?: RequestInit | runtime.InitOverrideFunction + ): Promise { + const response = await this.fileDeleteControllerDeleteFilesRaw( + requestParameters, + initOverrides + ); + return await response.value(); + } +} diff --git a/src/internal/apis/index.ts b/src/internal/apis/index.ts index 8235136..6a956e1 100644 --- a/src/internal/apis/index.ts +++ b/src/internal/apis/index.ts @@ -6,6 +6,7 @@ export * from './AuthApi'; export * from './EmailApi'; export * from './FileBucketApi'; export * from './FileConfigApi'; +export * from './FileDeleteApi'; export * from './FileDownloadApi'; export * from './FileProviderApi'; export * from './FileUploadApi'; diff --git a/src/internal/models/ApiKey.ts b/src/internal/models/ApiKey.ts new file mode 100644 index 0000000..5a74465 --- /dev/null +++ b/src/internal/models/ApiKey.ts @@ -0,0 +1,117 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface ApiKey + */ +export interface ApiKey { + /** + * The API key's ID in the databse + * @type {string} + * @memberof ApiKey + */ + id: string; + /** + * The generated API key value (store immediately, not retrievable again) + * @type {string} + * @memberof ApiKey + */ + hash: string; + /** + * Description provided at creation + * @type {string} + * @memberof ApiKey + */ + description: string; + /** + * Scopes tied to this API key + * @type {Array} + * @memberof ApiKey + */ + scopes: Array; + /** + * project identifier for the API key + * @type {string} + * @memberof ApiKey + */ + project: string; + /** + * Environment this key was issued for + * @type {string} + * @memberof ApiKey + */ + environment: string; + /** + * ISO timestamp of key creation + * @type {string} + * @memberof ApiKey + */ + createdAt: string; +} + +/** + * Check if a given object implements the ApiKey interface. + */ +export function instanceOfApiKey(value: object): value is ApiKey { + if (!('id' in value) || value['id'] === undefined) return false; + if (!('hash' in value) || value['hash'] === undefined) return false; + if (!('description' in value) || value['description'] === undefined) + return false; + if (!('scopes' in value) || value['scopes'] === undefined) return false; + if (!('project' in value) || value['project'] === undefined) return false; + if (!('environment' in value) || value['environment'] === undefined) + return false; + if (!('createdAt' in value) || value['createdAt'] === undefined) return false; + return true; +} + +export function ApiKeyFromJSON(json: any): ApiKey { + return ApiKeyFromJSONTyped(json, false); +} + +export function ApiKeyFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): ApiKey { + if (json == null) { + return json; + } + return { + id: json['id'], + hash: json['hash'], + description: json['description'], + scopes: json['scopes'], + project: json['project'], + environment: json['environment'], + createdAt: json['createdAt'], + }; +} + +export function ApiKeyToJSON(value?: ApiKey | null): any { + if (value == null) { + return value; + } + return { + id: value['id'], + hash: value['hash'], + description: value['description'], + scopes: value['scopes'], + project: value['project'], + environment: value['environment'], + createdAt: value['createdAt'], + }; +} diff --git a/src/internal/models/DeleteFilesModel.ts b/src/internal/models/DeleteFilesModel.ts new file mode 100644 index 0000000..8374c98 --- /dev/null +++ b/src/internal/models/DeleteFilesModel.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface DeleteFilesModel + */ +export interface DeleteFilesModel { + /** + * Name of the bucket containing the files + * @type {string} + * @memberof DeleteFilesModel + */ + bucketName: string; + /** + * Configuration ID for the bucket + * @type {number} + * @memberof DeleteFilesModel + */ + configId: number; + /** + * List of file names to delete + * @type {Array} + * @memberof DeleteFilesModel + */ + fileNames: Array; +} + +/** + * Check if a given object implements the DeleteFilesModel interface. + */ +export function instanceOfDeleteFilesModel( + value: object +): value is DeleteFilesModel { + if (!('bucketName' in value) || value['bucketName'] === undefined) + return false; + if (!('configId' in value) || value['configId'] === undefined) return false; + if (!('fileNames' in value) || value['fileNames'] === undefined) return false; + return true; +} + +export function DeleteFilesModelFromJSON(json: any): DeleteFilesModel { + return DeleteFilesModelFromJSONTyped(json, false); +} + +export function DeleteFilesModelFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): DeleteFilesModel { + if (json == null) { + return json; + } + return { + bucketName: json['bucketName'], + configId: json['configId'], + fileNames: json['fileNames'], + }; +} + +export function DeleteFilesModelToJSON(value?: DeleteFilesModel | null): any { + if (value == null) { + return value; + } + return { + bucketName: value['bucketName'], + configId: value['configId'], + fileNames: value['fileNames'], + }; +} diff --git a/src/internal/models/DeleteFilesResponse.ts b/src/internal/models/DeleteFilesResponse.ts new file mode 100644 index 0000000..f8430bc --- /dev/null +++ b/src/internal/models/DeleteFilesResponse.ts @@ -0,0 +1,75 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface DeleteFilesResponse + */ +export interface DeleteFilesResponse { + /** + * The name of the bucket from which files were deleted + * @type {string} + * @memberof DeleteFilesResponse + */ + bucketName: string; + /** + * List of file names that were deleted + * @type {Array} + * @memberof DeleteFilesResponse + */ + fileNames: Array; +} + +/** + * Check if a given object implements the DeleteFilesResponse interface. + */ +export function instanceOfDeleteFilesResponse( + value: object +): value is DeleteFilesResponse { + if (!('bucketName' in value) || value['bucketName'] === undefined) + return false; + if (!('fileNames' in value) || value['fileNames'] === undefined) return false; + return true; +} + +export function DeleteFilesResponseFromJSON(json: any): DeleteFilesResponse { + return DeleteFilesResponseFromJSONTyped(json, false); +} + +export function DeleteFilesResponseFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): DeleteFilesResponse { + if (json == null) { + return json; + } + return { + bucketName: json['bucketName'], + fileNames: json['fileNames'], + }; +} + +export function DeleteFilesResponseToJSON( + value?: DeleteFilesResponse | null +): any { + if (value == null) { + return value; + } + return { + bucketName: value['bucketName'], + fileNames: value['fileNames'], + }; +} diff --git a/src/internal/models/GetAllApiKeysResponse.ts b/src/internal/models/GetAllApiKeysResponse.ts new file mode 100644 index 0000000..408e0e7 --- /dev/null +++ b/src/internal/models/GetAllApiKeysResponse.ts @@ -0,0 +1,85 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { ApiKey } from './ApiKey'; +import { ApiKeyFromJSON, ApiKeyFromJSONTyped, ApiKeyToJSON } from './ApiKey'; +import type { PaginationParams } from './PaginationParams'; +import { + PaginationParamsFromJSON, + PaginationParamsFromJSONTyped, + PaginationParamsToJSON, +} from './PaginationParams'; + +/** + * + * @export + * @interface GetAllApiKeysResponse + */ +export interface GetAllApiKeysResponse { + /** + * List of API keys belonging to a project + * @type {Array} + * @memberof GetAllApiKeysResponse + */ + keys: Array; + /** + * Pagination parameters + * @type {PaginationParams} + * @memberof GetAllApiKeysResponse + */ + links: PaginationParams; +} + +/** + * Check if a given object implements the GetAllApiKeysResponse interface. + */ +export function instanceOfGetAllApiKeysResponse( + value: object +): value is GetAllApiKeysResponse { + if (!('keys' in value) || value['keys'] === undefined) return false; + if (!('links' in value) || value['links'] === undefined) return false; + return true; +} + +export function GetAllApiKeysResponseFromJSON( + json: any +): GetAllApiKeysResponse { + return GetAllApiKeysResponseFromJSONTyped(json, false); +} + +export function GetAllApiKeysResponseFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): GetAllApiKeysResponse { + if (json == null) { + return json; + } + return { + keys: (json['keys'] as Array).map(ApiKeyFromJSON), + links: PaginationParamsFromJSON(json['links']), + }; +} + +export function GetAllApiKeysResponseToJSON( + value?: GetAllApiKeysResponse | null +): any { + if (value == null) { + return value; + } + return { + keys: (value['keys'] as Array).map(ApiKeyToJSON), + links: PaginationParamsToJSON(value['links']), + }; +} diff --git a/src/internal/models/IssueApiKeyResponse.ts b/src/internal/models/IssueApiKeyResponse.ts index 6607916..10905dc 100644 --- a/src/internal/models/IssueApiKeyResponse.ts +++ b/src/internal/models/IssueApiKeyResponse.ts @@ -20,11 +20,35 @@ import { mapValues } from '../runtime'; */ export interface IssueApiKeyResponse { /** - * The generated API key + * The generated API key value (store immediately, not retrievable again) * @type {string} * @memberof IssueApiKeyResponse */ apiKey: string; + /** + * Environment this key was issued for + * @type {string} + * @memberof IssueApiKeyResponse + */ + environment: string; + /** + * Description provided at creation + * @type {string} + * @memberof IssueApiKeyResponse + */ + description: string; + /** + * ISO timestamp of key creation + * @type {string} + * @memberof IssueApiKeyResponse + */ + createdAt: string; + /** + * project identifier for the API key + * @type {string} + * @memberof IssueApiKeyResponse + */ + project: string; } /** @@ -34,6 +58,12 @@ export function instanceOfIssueApiKeyResponse( value: object ): value is IssueApiKeyResponse { if (!('apiKey' in value) || value['apiKey'] === undefined) return false; + if (!('environment' in value) || value['environment'] === undefined) + return false; + if (!('description' in value) || value['description'] === undefined) + return false; + if (!('createdAt' in value) || value['createdAt'] === undefined) return false; + if (!('project' in value) || value['project'] === undefined) return false; return true; } @@ -50,6 +80,10 @@ export function IssueApiKeyResponseFromJSONTyped( } return { apiKey: json['apiKey'], + environment: json['environment'], + description: json['description'], + createdAt: json['createdAt'], + project: json['project'], }; } @@ -61,5 +95,9 @@ export function IssueApiKeyResponseToJSON( } return { apiKey: value['apiKey'], + environment: value['environment'], + description: value['description'], + createdAt: value['createdAt'], + project: value['project'], }; } diff --git a/src/internal/models/PaginationParams.ts b/src/internal/models/PaginationParams.ts new file mode 100644 index 0000000..4f7c7cf --- /dev/null +++ b/src/internal/models/PaginationParams.ts @@ -0,0 +1,90 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Juno + * Juno Public API Docs + * + * The version of the OpenAPI document: 1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface PaginationParams + */ +export interface PaginationParams { + /** + * first page of results + * @type {string} + * @memberof PaginationParams + */ + first: string; + /** + * previous page of results + * @type {string} + * @memberof PaginationParams + */ + prev: string; + /** + * next page of results + * @type {string} + * @memberof PaginationParams + */ + next: string; + /** + * last page of results + * @type {string} + * @memberof PaginationParams + */ + last: string; +} + +/** + * Check if a given object implements the PaginationParams interface. + */ +export function instanceOfPaginationParams( + value: object +): value is PaginationParams { + if (!('first' in value) || value['first'] === undefined) return false; + if (!('prev' in value) || value['prev'] === undefined) return false; + if (!('next' in value) || value['next'] === undefined) return false; + if (!('last' in value) || value['last'] === undefined) return false; + return true; +} + +export function PaginationParamsFromJSON(json: any): PaginationParams { + return PaginationParamsFromJSONTyped(json, false); +} + +export function PaginationParamsFromJSONTyped( + json: any, + ignoreDiscriminator: boolean +): PaginationParams { + if (json == null) { + return json; + } + return { + first: json['first'], + prev: json['prev'], + next: json['next'], + last: json['last'], + }; +} + +export function PaginationParamsToJSON(value?: PaginationParams | null): any { + if (value == null) { + return value; + } + return { + first: value['first'], + prev: value['prev'], + next: value['next'], + last: value['last'], + }; +} diff --git a/src/internal/models/index.ts b/src/internal/models/index.ts index 656538c..3efaa89 100644 --- a/src/internal/models/index.ts +++ b/src/internal/models/index.ts @@ -6,6 +6,7 @@ export * from './AcceptAccountRequestResponseUser'; export * from './AccessKey'; export * from './AggregateInterval'; export * from './AnalyticsConfigResponse'; +export * from './ApiKey'; export * from './ClickEventProperties'; export * from './ClickEventResponse'; export * from './CreateAnalyticsConfigModel'; @@ -16,6 +17,8 @@ export * from './CustomEventTypeResponse'; export * from './CustomGraphType'; export * from './CustomGraphTypeResponse'; export * from './DeleteFileBucketModel'; +export * from './DeleteFilesModel'; +export * from './DeleteFilesResponse'; export * from './DownloadFileModel'; export * from './DownloadFileResponse'; export * from './EmailConfigResponse'; @@ -28,6 +31,7 @@ export * from './FileBucket'; export * from './FileConfigResponse'; export * from './FileProvider'; export * from './FileProviderPartial'; +export * from './GetAllApiKeysResponse'; export * from './GetAllClickEventsResponse'; export * from './GetAllCustomEventTypeResponse'; export * from './GetAllCustomEventsResponse'; @@ -51,6 +55,7 @@ export * from './LogVisitEventRequest'; export * from './ModelFile'; export * from './NewAccountRequestResponse'; export * from './NewAccountRequestsResponse'; +export * from './PaginationParams'; export * from './ProjectResponse'; export * from './ProjectResponses'; export * from './RegisterDomainModel';