Comparing version 0.4.0-alpha.5 to 0.4.0-alpha.6
export * from './api.service'; | ||
export * from './organization'; | ||
export * from './application'; | ||
export * from './environment'; | ||
export * from './notification-groups'; | ||
export * from './notification-templates'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -19,5 +19,5 @@ "use strict"; | ||
__exportStar(require("./organization"), exports); | ||
__exportStar(require("./application"), exports); | ||
__exportStar(require("./environment"), exports); | ||
__exportStar(require("./notification-groups"), exports); | ||
__exportStar(require("./notification-templates"), exports); | ||
//# sourceMappingURL=index.js.map |
import { ListQuestionOptions } from 'inquirer'; | ||
export declare const introQuestions: ListQuestionOptions[]; | ||
export declare const existingSessionQuestions: (existingApplication: any) => ListQuestionOptions[]; | ||
export declare const existingSessionQuestions: (existingEnvironment: any) => ListQuestionOptions[]; | ||
export declare const environmentQuestions: ListQuestionOptions[]; | ||
@@ -5,0 +5,0 @@ export declare const registerMethodQuestions: ListQuestionOptions[]; |
@@ -8,8 +8,8 @@ "use strict"; | ||
{ | ||
name: 'applicationName', | ||
message: 'What is your application name?', | ||
name: 'environmentName', | ||
message: 'What is your environment name?', | ||
default: 'Acme App.', | ||
}, | ||
]; | ||
const existingSessionQuestions = (existingApplication) => { | ||
const existingSessionQuestions = (existingEnvironment) => { | ||
return [ | ||
@@ -19,6 +19,6 @@ { | ||
name: 'result', | ||
message: `Looks like you already have a created an account for ${existingApplication.name}`, | ||
message: `Looks like you already have a created an account for ${existingEnvironment.name}`, | ||
choices: [ | ||
{ | ||
name: `Visit ${existingApplication.name} Dashboard`, | ||
name: `Visit ${existingEnvironment.name} Dashboard`, | ||
value: 'visitDashboard', | ||
@@ -25,0 +25,0 @@ }, |
@@ -29,5 +29,5 @@ "use strict"; | ||
} | ||
const existingApplication = await checkExistingApplication(config); | ||
if (existingApplication) { | ||
const { result } = await (0, client_1.prompt)((0, init_consts_1.existingSessionQuestions)(existingApplication)); | ||
const existingEnvironment = await checkExistingEnvironment(config); | ||
if (existingEnvironment) { | ||
const { result } = await (0, client_1.prompt)((0, init_consts_1.existingSessionQuestions)(existingEnvironment)); | ||
if (result === 'visitDashboard') { | ||
@@ -65,3 +65,3 @@ await handleExistingSession(result, config); | ||
await createOrganizationHandler(config, answers); | ||
const applicationIdentifier = await createApplicationHandler(config, answers); | ||
const applicationIdentifier = await createEnvironmentHandler(config, answers); | ||
const address = httpServer.getAddress(); | ||
@@ -98,19 +98,19 @@ spinner.succeed(`Created your account successfully. | ||
return; | ||
const createOrganizationResponse = await (0, api_1.createOrganization)(answers.applicationName); | ||
const createOrganizationResponse = await (0, api_1.createOrganization)(answers.environmentName); | ||
const newUserJwt = await (0, api_1.switchOrganization)(createOrganizationResponse._id); | ||
storeToken(config, newUserJwt); | ||
} | ||
async function createApplicationHandler(config, answers) { | ||
async function createEnvironmentHandler(config, answers) { | ||
var _a; | ||
if (config.isApplicationIdExist()) { | ||
const existingApplication = await (0, api_1.getApplicationMe)(); | ||
const keys = await (0, api_1.getApplicationApiKeys)(); | ||
if (config.isEnvironmentIdExist()) { | ||
const existingEnvironment = await (0, api_1.getEnvironmentMe)(); | ||
const keys = await (0, api_1.getEnvironmentApiKeys)(); | ||
config.setValue('apiKey', (_a = keys[0]) === null || _a === void 0 ? void 0 : _a.key); | ||
return existingApplication.identifier; | ||
return existingEnvironment.identifier; | ||
} | ||
const createApplicationResponse = await (0, api_1.createApplication)(answers.applicationName); | ||
const newUserJwt = await (0, api_1.switchApplication)(createApplicationResponse._id); | ||
config.setValue('apiKey', createApplicationResponse.apiKeys[0].key); | ||
const createEnvironmentResponse = await (0, api_1.createEnvironment)(answers.environmentName); | ||
const newUserJwt = await (0, api_1.switchEnvironment)(createEnvironmentResponse._id); | ||
config.setValue('apiKey', createEnvironmentResponse.apiKeys[0].key); | ||
storeToken(config, newUserJwt); | ||
return createApplicationResponse.identifier; | ||
return createEnvironmentResponse.identifier; | ||
} | ||
@@ -163,3 +163,3 @@ async function raiseDemoDashboard(httpServer, config, applicationIdentifier) { | ||
{ key: '$email', value: decodedToken.email }, | ||
{ key: 'applicationId', value: applicationIdentifier }, | ||
{ key: 'environmentId', value: applicationIdentifier }, | ||
{ key: 'token', value: config.getToken() }, | ||
@@ -182,10 +182,10 @@ { key: 'dashboardURL', value: dashboardURL }, | ||
}; | ||
async function checkExistingApplication(config) { | ||
async function checkExistingEnvironment(config) { | ||
const isSessionExists = !!config.getDecodedToken(); | ||
if (isSessionExists && process.env.NODE_ENV !== 'dev') { | ||
storeToken(config, config.getToken()); | ||
let existingApplication; | ||
let existingEnvironment; | ||
try { | ||
existingApplication = await (0, api_1.getApplicationMe)(); | ||
if (!existingApplication) { | ||
existingEnvironment = await (0, api_1.getEnvironmentMe)(); | ||
if (!existingEnvironment) { | ||
return null; | ||
@@ -198,3 +198,3 @@ } | ||
} | ||
return existingApplication; | ||
return existingEnvironment; | ||
} | ||
@@ -201,0 +201,0 @@ return null; |
@@ -8,6 +8,6 @@ export declare const SERVER_HOST = "localhost"; | ||
export declare const API_SWITCH_ORGANIZATION_FORMAT_URL: string; | ||
export declare const API_CREATE_APPLICATION_URL: string; | ||
export declare const API_APPLICATION_ME_URL: string; | ||
export declare const API_APPLICATION_KEYS: string; | ||
export declare const API_SWITCH_APPLICATION_FORMAT_URL: string; | ||
export declare const API_CREATE_ENVIRONMENT_URL: string; | ||
export declare const API_ENVIRONMENT_ME_URL: string; | ||
export declare const API_ENVIRONMENT_KEYS: string; | ||
export declare const API_SWITCH_ENVIRONMENT_FORMAT_URL: string; | ||
export declare const API_NOTIFICATION_GROUP_URL: string; | ||
@@ -14,0 +14,0 @@ export declare const API_NOTIFICATION_TEMPLATES_URL: string; |
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getServerPort = exports.setAvailablePort = exports.GITHUB_DOCKER_URL = exports.CLIENT_LOGIN_URL = exports.API_TRIGGER_URL = exports.API_NOTIFICATION_TEMPLATES_URL = exports.API_NOTIFICATION_GROUP_URL = exports.API_SWITCH_APPLICATION_FORMAT_URL = exports.API_APPLICATION_KEYS = exports.API_APPLICATION_ME_URL = exports.API_CREATE_APPLICATION_URL = exports.API_SWITCH_ORGANIZATION_FORMAT_URL = exports.API_CREATE_ORGANIZATION_URL = exports.API_OAUTH_URL = exports.TRIGGER_ROUTE = exports.WIDGET_DEMO_ROUTH = exports.REDIRECT_ROUTE = exports.SERVER_HOST = void 0; | ||
exports.getServerPort = exports.setAvailablePort = exports.GITHUB_DOCKER_URL = exports.CLIENT_LOGIN_URL = exports.API_TRIGGER_URL = exports.API_NOTIFICATION_TEMPLATES_URL = exports.API_NOTIFICATION_GROUP_URL = exports.API_SWITCH_ENVIRONMENT_FORMAT_URL = exports.API_ENVIRONMENT_KEYS = exports.API_ENVIRONMENT_ME_URL = exports.API_CREATE_ENVIRONMENT_URL = exports.API_SWITCH_ORGANIZATION_FORMAT_URL = exports.API_CREATE_ORGANIZATION_URL = exports.API_OAUTH_URL = exports.TRIGGER_ROUTE = exports.WIDGET_DEMO_ROUTH = exports.REDIRECT_ROUTE = exports.SERVER_HOST = void 0; | ||
const getPort = require("get-port"); | ||
@@ -14,10 +14,10 @@ exports.SERVER_HOST = 'localhost'; | ||
exports.API_SWITCH_ORGANIZATION_FORMAT_URL = `${apiAddress}/v1/auth/organizations/{organizationId}/switch`; | ||
exports.API_CREATE_APPLICATION_URL = `${apiAddress}/v1/applications`; | ||
exports.API_APPLICATION_ME_URL = `${apiAddress}/v1/applications/me`; | ||
exports.API_APPLICATION_KEYS = `${apiAddress}/v1/applications/api-keys`; | ||
exports.API_SWITCH_APPLICATION_FORMAT_URL = `${apiAddress}/v1/auth/applications/{applicationId}/switch`; | ||
exports.API_CREATE_ENVIRONMENT_URL = `${apiAddress}/v1/environments`; | ||
exports.API_ENVIRONMENT_ME_URL = `${apiAddress}/v1/environments/me`; | ||
exports.API_ENVIRONMENT_KEYS = `${apiAddress}/v1/environments/api-keys`; | ||
exports.API_SWITCH_ENVIRONMENT_FORMAT_URL = `${apiAddress}/v1/auth/environments/{environmentId}/switch`; | ||
exports.API_NOTIFICATION_GROUP_URL = `${apiAddress}/v1/notification-groups`; | ||
exports.API_NOTIFICATION_TEMPLATES_URL = `${apiAddress}/v1/notification-templates`; | ||
exports.API_TRIGGER_URL = `${apiAddress}/v1/events/trigger`; | ||
exports.CLIENT_LOGIN_URL = process.env.NOVU_API_ADDRESS || 'https://web.novu.co/auth/login'; | ||
exports.CLIENT_LOGIN_URL = process.env.NOVU_CLIENT_LOGIN || 'https://web.novu.co/auth/login'; | ||
exports.GITHUB_DOCKER_URL = 'https://github.com/novuhq/novu/tree/main/docker'; | ||
@@ -24,0 +24,0 @@ let SERVER_PORT; |
@@ -9,3 +9,3 @@ import { IJwtPayload } from '@novu/shared'; | ||
isOrganizationIdExist(): boolean; | ||
isApplicationIdExist(): boolean; | ||
isEnvironmentIdExist(): boolean; | ||
getToken(): string; | ||
@@ -12,0 +12,0 @@ getDecodedToken(): IJwtPayload; |
@@ -22,4 +22,4 @@ "use strict"; | ||
} | ||
isApplicationIdExist() { | ||
return !!this.getDecodedToken().applicationId; | ||
isEnvironmentIdExist() { | ||
return !!this.getDecodedToken().environmentId; | ||
} | ||
@@ -26,0 +26,0 @@ getToken() { |
{ | ||
"name": "novu", | ||
"version": "0.4.0-alpha.5", | ||
"version": "0.4.0-alpha.6", | ||
"description": "On-Boarding Cli", | ||
@@ -14,4 +14,4 @@ "main": "index.js", | ||
"start": "pnpm start:dev", | ||
"start:dev": "cross-env TZ=UTC nodemon", | ||
"start:test": "cross-env NODE_ENV=test PORT=1336 TZ=UTC nodemon", | ||
"start:dev": "cross-env NOVU_API_ADDRESS=http://localhost:3000 NOVU_CLIENT_LOGIN=http://localhost:4200/auth/login TZ=UTC nodemon init", | ||
"start:test": "cross-env NODE_ENV=test PORT=1336 TZ=UTC nodemon init", | ||
"start:debug": "TZ=UTC nodemon --config nodemon-debug.json", | ||
@@ -26,3 +26,3 @@ "start:prod": "TZ=UTC node dist/index.js" | ||
"devDependencies": { | ||
"@novu/shared": "^0.4.0-alpha.5", | ||
"@novu/shared": "^0.4.0-alpha.6", | ||
"@types/configstore": "^5.0.1", | ||
@@ -46,3 +46,3 @@ "@types/inquirer": "^8.2.0", | ||
}, | ||
"gitHead": "407a922c6ed5684729b4b2bc036a6f9e7c43218e" | ||
"gitHead": "9f053dc2d7d90553f9946c59ba6b7ee6ebcd271b" | ||
} |
export * from './api.service'; | ||
export * from './organization'; | ||
export * from './application'; | ||
export * from './environment'; | ||
export * from './notification-groups'; | ||
export * from './notification-templates'; |
@@ -7,4 +7,4 @@ import { ListQuestionOptions } from 'inquirer'; | ||
{ | ||
name: 'applicationName', | ||
message: 'What is your application name?', | ||
name: 'environmentName', | ||
message: 'What is your environment name?', | ||
default: 'Acme App.', | ||
@@ -14,3 +14,3 @@ }, | ||
export const existingSessionQuestions = (existingApplication): ListQuestionOptions[] => { | ||
export const existingSessionQuestions = (existingEnvironment): ListQuestionOptions[] => { | ||
return [ | ||
@@ -20,6 +20,6 @@ { | ||
name: 'result', | ||
message: `Looks like you already have a created an account for ${existingApplication.name}`, | ||
message: `Looks like you already have a created an account for ${existingEnvironment.name}`, | ||
choices: [ | ||
{ | ||
name: `Visit ${existingApplication.name} Dashboard`, | ||
name: `Visit ${existingEnvironment.name} Dashboard`, | ||
value: 'visitDashboard', | ||
@@ -26,0 +26,0 @@ }, |
import * as open from 'open'; | ||
import { Answers } from 'inquirer'; | ||
import * as ora from 'ora'; | ||
import { IApplication, ICreateNotificationTemplateDto } from '@novu/shared'; | ||
import { IEnvironment, ICreateNotificationTemplateDto } from '@novu/shared'; | ||
import { prompt } from '../client'; | ||
@@ -28,8 +28,8 @@ import { | ||
switchOrganization, | ||
createApplication, | ||
getApplicationMe, | ||
switchApplication, | ||
createEnvironment, | ||
getEnvironmentMe, | ||
switchEnvironment, | ||
getNotificationGroup, | ||
createNotificationTemplates, | ||
getApplicationApiKeys, | ||
getEnvironmentApiKeys, | ||
} from '../api'; | ||
@@ -57,5 +57,5 @@ import { ConfigService } from '../services'; | ||
const existingApplication = await checkExistingApplication(config); | ||
if (existingApplication) { | ||
const { result } = await prompt(existingSessionQuestions(existingApplication)); | ||
const existingEnvironment = await checkExistingEnvironment(config); | ||
if (existingEnvironment) { | ||
const { result } = await prompt(existingSessionQuestions(existingEnvironment)); | ||
@@ -105,3 +105,3 @@ if (result === 'visitDashboard') { | ||
await createOrganizationHandler(config, answers); | ||
const applicationIdentifier = await createApplicationHandler(config, answers); | ||
const applicationIdentifier = await createEnvironmentHandler(config, answers); | ||
@@ -145,3 +145,3 @@ const address = httpServer.getAddress(); | ||
const createOrganizationResponse = await createOrganization(answers.applicationName); | ||
const createOrganizationResponse = await createOrganization(answers.environmentName); | ||
@@ -153,19 +153,19 @@ const newUserJwt = await switchOrganization(createOrganizationResponse._id); | ||
async function createApplicationHandler(config: ConfigService, answers: Answers): Promise<string> { | ||
if (config.isApplicationIdExist()) { | ||
const existingApplication = await getApplicationMe(); | ||
const keys = await getApplicationApiKeys(); | ||
async function createEnvironmentHandler(config: ConfigService, answers: Answers): Promise<string> { | ||
if (config.isEnvironmentIdExist()) { | ||
const existingEnvironment = await getEnvironmentMe(); | ||
const keys = await getEnvironmentApiKeys(); | ||
config.setValue('apiKey', keys[0]?.key); | ||
return existingApplication.identifier; | ||
return existingEnvironment.identifier; | ||
} | ||
const createApplicationResponse = await createApplication(answers.applicationName); | ||
const newUserJwt = await switchApplication(createApplicationResponse._id); | ||
const createEnvironmentResponse = await createEnvironment(answers.environmentName); | ||
const newUserJwt = await switchEnvironment(createEnvironmentResponse._id); | ||
config.setValue('apiKey', createApplicationResponse.apiKeys[0].key); | ||
config.setValue('apiKey', createEnvironmentResponse.apiKeys[0].key); | ||
storeToken(config, newUserJwt); | ||
return createApplicationResponse.identifier; | ||
return createEnvironmentResponse.identifier; | ||
} | ||
@@ -235,3 +235,3 @@ | ||
{ key: '$email', value: decodedToken.email }, | ||
{ key: 'applicationId', value: applicationIdentifier }, | ||
{ key: 'environmentId', value: applicationIdentifier }, | ||
{ key: 'token', value: config.getToken() }, | ||
@@ -264,3 +264,3 @@ { key: 'dashboardURL', value: dashboardURL }, | ||
async function checkExistingApplication(config: ConfigService): Promise<IApplication | null> { | ||
async function checkExistingEnvironment(config: ConfigService): Promise<IEnvironment | null> { | ||
const isSessionExists = !!config.getDecodedToken(); | ||
@@ -271,7 +271,7 @@ | ||
let existingApplication: IApplication; | ||
let existingEnvironment: IEnvironment; | ||
try { | ||
existingApplication = await getApplicationMe(); | ||
if (!existingApplication) { | ||
existingEnvironment = await getEnvironmentMe(); | ||
if (!existingEnvironment) { | ||
return null; | ||
@@ -285,3 +285,3 @@ } | ||
return existingApplication; | ||
return existingEnvironment; | ||
} | ||
@@ -288,0 +288,0 @@ |
@@ -16,6 +16,6 @@ import * as getPort from 'get-port'; | ||
export const API_SWITCH_ORGANIZATION_FORMAT_URL = `${apiAddress}/v1/auth/organizations/{organizationId}/switch`; | ||
export const API_CREATE_APPLICATION_URL = `${apiAddress}/v1/applications`; | ||
export const API_APPLICATION_ME_URL = `${apiAddress}/v1/applications/me`; | ||
export const API_APPLICATION_KEYS = `${apiAddress}/v1/applications/api-keys`; | ||
export const API_SWITCH_APPLICATION_FORMAT_URL = `${apiAddress}/v1/auth/applications/{applicationId}/switch`; | ||
export const API_CREATE_ENVIRONMENT_URL = `${apiAddress}/v1/environments`; | ||
export const API_ENVIRONMENT_ME_URL = `${apiAddress}/v1/environments/me`; | ||
export const API_ENVIRONMENT_KEYS = `${apiAddress}/v1/environments/api-keys`; | ||
export const API_SWITCH_ENVIRONMENT_FORMAT_URL = `${apiAddress}/v1/auth/environments/{environmentId}/switch`; | ||
export const API_NOTIFICATION_GROUP_URL = `${apiAddress}/v1/notification-groups`; | ||
@@ -26,3 +26,3 @@ export const API_NOTIFICATION_TEMPLATES_URL = `${apiAddress}/v1/notification-templates`; | ||
// Client | ||
export const CLIENT_LOGIN_URL = process.env.NOVU_API_ADDRESS || 'https://web.novu.co/auth/login'; | ||
export const CLIENT_LOGIN_URL = process.env.NOVU_CLIENT_LOGIN || 'https://web.novu.co/auth/login'; | ||
@@ -29,0 +29,0 @@ // github |
@@ -27,4 +27,4 @@ import * as Configstore from 'configstore'; | ||
isApplicationIdExist(): boolean { | ||
return !!this.getDecodedToken().applicationId; | ||
isEnvironmentIdExist(): boolean { | ||
return !!this.getDecodedToken().environmentId; | ||
} | ||
@@ -31,0 +31,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130365
1441