@contentstack/cli-cm-export-to-csv 2.0.0-beta.1 → 2.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Base command for export-to-csv package.
3
+ * Provides common functionality and context for all commands.
4
+ */
5
+ import { Command } from '@contentstack/cli-command';
6
+ /**
7
+ * Context for logging and error handling.
8
+ * Uses index signature for compatibility with ErrorContext.
9
+ */
10
+ export interface CommandContext {
11
+ [key: string]: unknown;
12
+ command: string;
13
+ module: string;
14
+ userId: string;
15
+ email: string;
16
+ sessionId?: string;
17
+ apiKey?: string;
18
+ orgId: string;
19
+ }
20
+ export declare abstract class BaseCommand extends Command {
21
+ commandContext: CommandContext;
22
+ /**
23
+ * Initialize the command with context and logging.
24
+ */
25
+ init(): Promise<void>;
26
+ /**
27
+ * Handle errors from the command.
28
+ */
29
+ protected catch(err: Error & {
30
+ exitCode?: number;
31
+ }): Promise<unknown>;
32
+ /**
33
+ * Cleanup after command execution.
34
+ */
35
+ protected finally(_: Error | undefined): Promise<unknown>;
36
+ /**
37
+ * Create context object for logging and error handling.
38
+ */
39
+ protected createCommandContext(apiKey?: string): CommandContext;
40
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * Base command for export-to-csv package.
4
+ * Provides common functionality and context for all commands.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.BaseCommand = void 0;
8
+ const cli_command_1 = require("@contentstack/cli-command");
9
+ const cli_utilities_1 = require("@contentstack/cli-utilities");
10
+ class BaseCommand extends cli_command_1.Command {
11
+ /**
12
+ * Initialize the command with context and logging.
13
+ */
14
+ async init() {
15
+ await super.init();
16
+ this.commandContext = this.createCommandContext();
17
+ cli_utilities_1.log.debug('Command initialized', this.commandContext);
18
+ }
19
+ /**
20
+ * Handle errors from the command.
21
+ */
22
+ async catch(err) {
23
+ cli_utilities_1.log.debug('Command error caught', Object.assign(Object.assign({}, this.commandContext), { error: err.message }));
24
+ return super.catch(err);
25
+ }
26
+ /**
27
+ * Cleanup after command execution.
28
+ */
29
+ async finally(_) {
30
+ cli_utilities_1.log.debug('Command finished', this.commandContext);
31
+ return super.finally(_);
32
+ }
33
+ /**
34
+ * Create context object for logging and error handling.
35
+ */
36
+ createCommandContext(apiKey) {
37
+ return {
38
+ command: this.id || 'cm:export-to-csv',
39
+ module: 'export-to-csv',
40
+ userId: cli_utilities_1.configHandler.get('userUid') || '',
41
+ email: cli_utilities_1.configHandler.get('email') || '',
42
+ sessionId: undefined,
43
+ apiKey: apiKey || '',
44
+ orgId: cli_utilities_1.configHandler.get('oauthOrgUid') || '',
45
+ };
46
+ }
47
+ }
48
+ exports.BaseCommand = BaseCommand;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Export to CSV command.
3
+ * Migrated from: packages/contentstack-export-to-csv/src/commands/cm/export-to-csv.js
4
+ */
5
+ import { FlagInput } from '@contentstack/cli-utilities';
6
+ import { BaseCommand } from '../../base-command';
7
+ import type { ManagementClient, StackClient, StackDetails, Branch, TaxonomyLocaleOptions } from '../../types';
8
+ export default class ExportToCsvCommand extends BaseCommand {
9
+ static readonly description = "Export entries, taxonomies, terms or organization users to csv using this command";
10
+ static readonly aliases: string[];
11
+ static readonly examples: string[];
12
+ static readonly flags: FlagInput;
13
+ run(): Promise<void>;
14
+ /**
15
+ * Export entries to CSV.
16
+ */
17
+ private exportEntries;
18
+ /**
19
+ * Export organization users to CSV.
20
+ */
21
+ private exportUsers;
22
+ /**
23
+ * Export organization teams to CSV.
24
+ */
25
+ private exportTeamsData;
26
+ /**
27
+ * Export taxonomies to CSV.
28
+ */
29
+ private exportTaxonomiesData;
30
+ snakeCase(string: string): string;
31
+ getStackClient(managementAPIClient: ManagementClient, stack: StackDetails): StackClient;
32
+ getStackBranches(stackAPIClient: StackClient): Promise<Branch[]>;
33
+ /**
34
+ * Check whether branch enabled org or not and update branch details.
35
+ */
36
+ checkAndUpdateBranchDetail(branchUid: string | undefined, stack: StackDetails, stackAPIClient: StackClient, managementAPIClient: ManagementClient): Promise<StackClient>;
37
+ /**
38
+ * Fetch stack details from alias token.
39
+ */
40
+ getAliasDetails(managementTokenAlias: string, stackName: string | undefined): Promise<{
41
+ apiClient: ManagementClient;
42
+ stackDetails: StackDetails;
43
+ }>;
44
+ /**
45
+ * Fetch stack details on basis of the selected org and stack.
46
+ */
47
+ getStackDetails(managementAPIClient: ManagementClient, stackAPIKey: string | undefined, org: string | undefined): Promise<StackDetails>;
48
+ /**
49
+ * Create a taxonomies csv file for stack and a terms csv file for associated taxonomies.
50
+ */
51
+ createTaxonomyAndTermCsvFile(stackAPIClient: StackClient, stackName: string | undefined, stack: StackDetails, taxUID: string | undefined, delimiter: string, localeOptions?: TaxonomyLocaleOptions): Promise<void>;
52
+ }