Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ fileignoreconfig:
checksum: 93bdd99ee566fd38545b38a8b528947af1d42a31908aca85e2cb221e39a5b6cc
- filename: packages/contentstack-export/test/unit/export/modules/stack.test.ts
checksum: bb0f20845d85fd56197f1a8c67b8f71c57dcd1836ed9cfd86d1f49f41e84d3a0
- filename: packages/contentstack-export/test/unit/export/modules/taxonomies.test.ts
checksum: 5b1d2ba5ec9100fd6174e9c6771b7e49c93a09fa2d6aedadd338e56bc3e3610f
- filename: packages/contentstack-export/test/unit/export/modules/custom-roles.test.ts
checksum: 39f0166a8030ee8f504301f3a42cc71b46ddc027189b90029ef19800b79a46e5
- filename: packages/contentstack-export/test/unit/export/modules/workflows.test.ts
Expand Down Expand Up @@ -179,16 +177,6 @@ fileignoreconfig:
checksum: a5cd371d7f327c083027da4157b3c5b4df548f2c2c3ad6193aa133031994252e
- filename: packages/contentstack-import/test/unit/utils/common-helper.test.ts
checksum: 61b3cfe0c0571dcc366e372990e3c11ced2b49703ac88155110d33897e58ca5d
- filename: packages/contentstack-import/test/unit/import/module-importer.test.ts
checksum: aa265917b806286c8d4d1d3f422cf5d6736a0cf6a5f50f2e9c04ec0f81eee376
- filename: packages/contentstack-export/test/unit/utils/interactive.test.ts
checksum: b619744ebba28dbafe3a0e65781a61a6823ccaa3eb84e2b380a323c105324c1a
- filename: packages/contentstack-import/test/unit/import/modules/index.test.ts
checksum: aab773ccbe05b990a4b934396ee2fcd2a780e7d886d080740cfddd8a4d4f73f7
- filename: packages/contentstack-import/test/unit/import/modules/personalize.test.ts
checksum: ea4140a1516630fbfcdd61c4fe216414b733b4df2410b5d090d58ab1a22e7dbf
- filename: packages/contentstack-import/test/unit/import/modules/variant-entries.test.ts
checksum: abcc2ce0b305afb655eb46a1652b3d9e807a2a2e0eef1caeb16c8ae83af4f1a1
- filename: packages/contentstack-import/test/unit/utils/import-path-resolver.test.ts
checksum: 05436c24619b2d79b51eda9ce9a338182cc69b078ede60d310bfd55a62db8369
- filename: packages/contentstack-import/test/unit/utils/interactive.test.ts
Expand Down
618 changes: 293 additions & 325 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions packages/contentstack-auth/src/commands/auth/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ export default class LoginCommand extends BaseCommand<typeof LoginCommand> {
log.debug('LoginCommand run method started', this.contextDetails);

try {
log.debug('Initializing management API client', this.contextDetails);
log.debug('Initializing the Management API client.', this.contextDetails);
const managementAPIClient = await managementSDKClient({ host: this.cmaHost, skipTokenValidity: true });
log.debug('Management API client initialized successfully', this.contextDetails);
log.debug('Management API client initialized successfully.', this.contextDetails);

const { flags: loginFlags } = await this.parse(LoginCommand);
log.debug('Token add flags parsed', { ...this.contextDetails, flags: loginFlags });
log.debug('Token add flags parsed.', { ...this.contextDetails, flags: loginFlags });

authHandler.client = managementAPIClient;
log.debug('Auth handler client set', this.contextDetails);
Expand All @@ -86,7 +86,7 @@ export default class LoginCommand extends BaseCommand<typeof LoginCommand> {
await this.login(username, password);
}
} catch (error) {
log.debug('Login command failed', {
log.debug('Login failed.', {
...this.contextDetails,
error,
});
Expand Down Expand Up @@ -116,26 +116,26 @@ export default class LoginCommand extends BaseCommand<typeof LoginCommand> {
}

const user: User = await authHandler.login(username, password, tfaToken);
log.debug('Auth handler login completed', {
log.debug('Auth handler login completed.', {
...this.contextDetails,
hasUser: !!user,
hasAuthToken: !!user?.authtoken,
userEmail: user?.email,
});

if (typeof user !== 'object' || !user.authtoken || !user.email) {
log.debug('Login failed - invalid user response', { ...this.contextDetails, user });
throw new CLIError('Failed to login - invalid response');
log.debug('Login failed: Invalid user response', { ...this.contextDetails, user });
throw new CLIError('Login failed: Invalid response.');
}

log.debug('Setting config data for basic auth', this.contextDetails);
log.debug('Setting configuration data for basic authentication.', this.contextDetails);
await oauthHandler.setConfigData('basicAuth', user);
log.debug('Config data set successfully', this.contextDetails);
log.debug('Configuration data set successfully.', this.contextDetails);

log.success(messageHandler.parse('CLI_AUTH_LOGIN_SUCCESS'), this.contextDetails);
log.debug('Login process completed successfully', this.contextDetails);
log.debug('Login completed successfully.', this.contextDetails);
} catch (error) {
log.debug('Login process failed', { ...this.contextDetails, error });
log.debug('Login failed.', { ...this.contextDetails, error });
throw error;
}
}
Expand Down
14 changes: 7 additions & 7 deletions packages/contentstack-auth/src/commands/auth/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {
}

try {
log.debug('Initializing management API client for logout', this.contextDetails);
log.debug('Initializing the Management API client for logout.', this.contextDetails);
const managementAPIClient = await managementSDKClient({ host: this.cmaHost, skipTokenValidity: true });
log.debug('Management API client initialized successfully', this.contextDetails);

Expand All @@ -75,9 +75,9 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {
if (await oauthHandler.isAuthorisationTypeBasic()) {
log.debug('Using basic authentication for logout', this.contextDetails);
const authToken = configHandler.get('authtoken');
log.debug('Retrieved auth token for logout', { ...this.contextDetails, hasAuthToken: !!authToken });
log.debug('Authentication token retrieved for logout.', { ...this.contextDetails, hasAuthToken: !!authToken });
await authHandler.logout(authToken);
log.debug('Basic auth logout completed', this.contextDetails);
log.debug('Basic authentication logout completed.', this.contextDetails);
} else if (await oauthHandler.isAuthorisationTypeOAuth()) {
log.debug('Using OAuth authentication for logout', this.contextDetails);
await oauthHandler.oauthLogout();
Expand All @@ -86,7 +86,7 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {

cliux.loader('');
log.success(messageHandler.parse('CLI_AUTH_LOGOUT_SUCCESS'), this.contextDetails);
log.debug('Logout process completed successfully', this.contextDetails);
log.debug('Logout completed successfully.', this.contextDetails);
} else {
log.debug('User not confirmed or not authenticated, skipping logout', {
...this.contextDetails,
Expand All @@ -96,14 +96,14 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {
log.success(messageHandler.parse('CLI_AUTH_LOGOUT_ALREADY'), this.contextDetails);
}
} catch (error) {
log.debug('Logout command failed', { ...this.contextDetails, error: error.message });
log.debug('Logout failed.', { ...this.contextDetails, error: error.message });
cliux.print('CLI_AUTH_LOGOUT_FAILED', { color: 'yellow' });
handleAndLogError(error, { ...this.contextDetails });
} finally {
if (confirm === true) {
log.debug('Setting config data for logout', this.contextDetails);
log.debug('Setting configuration data for logout.', this.contextDetails);
await oauthHandler.setConfigData('logout');
log.debug('Config data set for logout', this.contextDetails);
log.debug('Configuration data set for logout.', this.contextDetails);
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions packages/contentstack-auth/src/commands/auth/tokens/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
'auth:tokens:add [-a <value>] [--delivery] [--management] [-e <value>] [-k <value>] [-y] [--token <value>]';

async run(): Promise<any> {
log.debug('TokensAddCommand run method started', this.contextDetails);
log.debug('TokensAddCommand run method started.', this.contextDetails);
this.contextDetails.module = 'tokens-add';

const { flags: addTokenFlags } = await this.parse(TokensAddCommand);
log.debug('Token add flags parsed', { ...this.contextDetails, flags: addTokenFlags });
log.debug('Token add flags parsed.', { ...this.contextDetails, flags: addTokenFlags });

let isAliasExist = false;
const skipAliasReplaceConfirmation = addTokenFlags.force || addTokenFlags.yes;
Expand Down Expand Up @@ -141,7 +141,7 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman

if (!shouldAliasReplace) {
log.debug('User declined alias replacement, exiting', this.contextDetails);
log.info('Exiting from the process of replacing the token', this.contextDetails);
log.info('Exiting the token replacement process.', this.contextDetails);
cliux.print('CLI_AUTH_EXIT_PROCESS');
return;
}
Expand All @@ -150,13 +150,13 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
if (!apiKey) {
log.debug('No API key provided, requesting user input', this.contextDetails);
apiKey = await cliux.inquire({ type: 'input', message: 'CLI_AUTH_TOKENS_ADD_ENTER_API_KEY', name: 'apiKey' });
log.debug('API key obtained', { ...this.contextDetails, hasApiKey: !!apiKey });
log.debug('API key obtained.', { ...this.contextDetails, hasApiKey: !!apiKey });
}

if (!token) {
log.debug('No token provided, requesting user input', this.contextDetails);
token = await cliux.inquire({ type: 'input', message: 'CLI_AUTH_TOKENS_ADD_ENTER_TOKEN', name: 'token' });
log.debug('Token obtained', { ...this.contextDetails, hasToken: !!token });
log.debug('Token obtained.', { ...this.contextDetails, hasToken: !!token });
}

if (isDelivery && !environment) {
Expand All @@ -183,12 +183,12 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
// FIXME - Once the SDK refresh token issue is resolved, need to revert this back to SDK call
const httpClient = new HttpClient({ headers: { api_key: apiKey, authorization: token } });

log.debug('Making management token validation API call', this.contextDetails);
log.debug('Making management token validation API call.', this.contextDetails);
const response = (await httpClient.get(`https://${this.cmaHost}/v3/environments?limit=1`)).data;
log.debug('Management token validation response received', { ...this.contextDetails, response });
log.debug('Management token validation response received.', { ...this.contextDetails, response });

if (response?.error_code === 105) {
log.debug('Management token validation failed - invalid token', this.contextDetails);
log.debug('Management token validation failed: invalid token.', this.contextDetails);
throw new Error(messageHandler.parse('CLI_AUTH_TOKENS_VALIDATION_INVALID_MANAGEMENT_TOKEN'));
} else if (response?.error_message) {
log.debug('Management token validation failed with error message', {
Expand All @@ -197,7 +197,7 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
});
throw new Error(response.error_message);
}
log.debug('Management token validation successful', this.contextDetails);
log.debug('Management token validation successful.', this.contextDetails);
}

log.debug('Saving token to configuration', {
Expand All @@ -208,23 +208,23 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
});
if (isManagement) {
configHandler.set(`${configKeyTokens}.${alias}`, { token, apiKey, type });
log.debug('Management token saved to configuration', this.contextDetails);
log.debug('Management token saved to configuration.', this.contextDetails);
} else {
configHandler.set(`${configKeyTokens}.${alias}`, { token, apiKey, environment, type });
log.debug('Delivery token saved to configuration', this.contextDetails);
log.debug('Delivery token saved to configuration.', this.contextDetails);
}

if (isAliasExist) {
log.debug('Token replaced successfully', this.contextDetails);
log.debug('Token replaced successfully.', this.contextDetails);
cliux.success('CLI_AUTH_TOKENS_ADD_REPLACE_SUCCESS');
} else {
log.debug('Token added successfully', this.contextDetails);
log.debug('Token added successfully.', this.contextDetails);
cliux.success('CLI_AUTH_TOKENS_ADD_SUCCESS');
}

log.debug('Token add process completed successfully', this.contextDetails);
log.debug('Token addition process completed successfully.', this.contextDetails);
} catch (error) {
log.debug('Token add process failed', { ...this.contextDetails, error });
log.debug('Token addition process failed.', { ...this.contextDetails, error });
cliux.print('CLI_AUTH_TOKENS_ADD_FAILED', { color: 'yellow' });
handleAndLogError(error, { ...this.contextDetails });
}
Expand Down
20 changes: 10 additions & 10 deletions packages/contentstack-auth/src/commands/auth/tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ export default class TokensListCommand extends BaseCommand<typeof TokensListComm
]); // use the cli table flags as it displays tokens in table

async run(): Promise<any> {
log.debug('TokensListCommand run method started', this.contextDetails);
log.debug('TokensListCommand run method started.', this.contextDetails);
this.contextDetails.module = 'tokens-list';

try {
log.debug('Retrieving tokens from configuration', this.contextDetails);
log.debug('Retrieving tokens from configuration.', this.contextDetails);
const managementTokens = configHandler.get('tokens');
log.debug('Tokens retrieved from configuration', {...this.contextDetails, tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 });
log.debug('Tokens retrieved from configuration.', {...this.contextDetails, tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 });

const tokens: Record<string, unknown>[] = [];
if (managementTokens && Object.keys(managementTokens).length > 0) {
log.debug('Processing tokens for display', this.contextDetails);
log.debug('Processing tokens for display.', this.contextDetails);
Object.keys(managementTokens).forEach(function (item) {
tokens.push({
alias: item,
Expand All @@ -46,7 +46,7 @@ export default class TokensListCommand extends BaseCommand<typeof TokensListComm
});

const { flags } = await this.parse(TokensListCommand);
log.debug('Tokens list flags parsed', {...this.contextDetails, flags });
log.debug('Token list flags parsed.', {...this.contextDetails, flags });

const headers = [
{
Expand All @@ -66,17 +66,17 @@ export default class TokensListCommand extends BaseCommand<typeof TokensListComm
},
];

log.debug('Displaying tokens table', {...this.contextDetails, tokenCount: tokens.length });
log.debug('Displaying token table.', {...this.contextDetails, tokenCount: tokens.length });
cliux.table(headers, tokens, flags as TableFlags);
log.debug('Tokens table displayed successfully', this.contextDetails);
log.debug('Token table displayed successfully.', this.contextDetails);
} else {
log.debug('No tokens found in configuration', this.contextDetails);
log.debug('No tokens found in configuration.', this.contextDetails);
cliux.print('CLI_AUTH_TOKENS_LIST_NO_TOKENS');
}

log.debug('Tokens list command completed successfully', this.contextDetails);
log.debug('Token list command completed successfully.', this.contextDetails);
} catch (error) {
log.debug('Tokens list command failed', {...this.contextDetails, error });
log.debug('Token list command failed.', {...this.contextDetails, error });
cliux.print('CLI_AUTH_TOKENS_LIST_FAILED', { color: 'yellow' });
handleAndLogError(error, { ...this.contextDetails });
}
Expand Down
Loading
Loading