@contentstack/cli-cm-export-to-csv 1.12.3 → 1.12.5

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.
package/README.md CHANGED
@@ -1,40 +1,130 @@
1
- @contentstack/cli-cm-export-to-csv
2
- =============
1
+ # @contentstack/cli-cm-export-to-csv
3
2
 
4
3
  The cm:export-to-csv command allows you to export the following data into a CSV file:
5
- * Multiple stack’s content and structure (schema)
6
- * [Organization users details](https://www.contentstack.com/docs/owners-and-admins/organization-users/)
4
+ * Multiple stacks' content and structure (schema)
5
+ * [Organization users' details](https://www.contentstack.com/docs/owners-and-admins/organization-users/)
7
6
 
8
- To be able to export the content of a stack, you need to have access to it. Likewise, to export an organizations user data, you need to be the [owner](https://www.contentstack.com/docs/owners-and-admins/organization-roles/#organization-owner) or an [admin](https://www.contentstack.com/docs/owners-and-admins/organization-roles/#organization-admin) user of that organization.
7
+ To be able to export the content of a stack, you need to have access to it. Likewise, to export an organization's user data, you need to be the "[owner](https://www.contentstack.com/docs/owners-and-admins/organization-roles/#organization-owner)" or an "[admin](https://www.contentstack.com/docs/owners-and-admins/organization-roles/#organization-admin)" user of that organization.
9
8
 
10
9
  Refer to the [Export Content to .CSV](https://www.contentstack.com/docs/developers/cli/export-content-to-csv-file/) file guide to learn more.
11
10
 
12
11
  [![License](https://img.shields.io/npm/l/@contentstack/cli)](https://github.com/contentstack/cli/blob/main/LICENSE)
13
12
 
13
+ <!-- toc -->
14
+ * [@contentstack/cli-cm-export-to-csv](#contentstackcli-cm-export-to-csv)
14
15
  * [Usage](#usage)
15
16
  * [Commands](#commands)
17
+ <!-- tocstop -->
18
+
16
19
  # Usage
20
+ <!-- usage -->
17
21
  ```sh-session
18
22
  $ npm install -g @contentstack/cli-cm-export-to-csv
19
23
  $ csdx COMMAND
20
24
  running command...
21
- $ csdx (-v|--version|version)
22
- @contentstack/cli-cm-export-to-csv/0.1.0-beta linux-x64 node-v12.18.4
25
+ $ csdx (--version)
26
+ @contentstack/cli-cm-export-to-csv/1.12.5 linux-x64 node-v22.23.0
23
27
  $ csdx --help [COMMAND]
24
28
  USAGE
25
29
  $ csdx COMMAND
26
30
  ...
27
31
  ```
32
+ <!-- usagestop -->
33
+
28
34
  # Commands
35
+ <!-- commands -->
29
36
  * [`csdx cm:export-to-csv`](#csdx-cmexport-to-csv)
30
37
 
31
- ### `csdx cm:export-to-csv`
38
+ ## `csdx cm:export-to-csv`
32
39
 
33
- Export entries or organization users to csv using this command
40
+ Export entries, taxonomies, terms or organization users to csv using this command
34
41
 
35
42
  ```
36
43
  USAGE
44
+ $ csdx cm:export-to-csv [--action entries|users|teams|taxonomies] [-a <value>] [--org <value>] [-n <value>] [-k
45
+ <value>] [--org-name <value>] [--locale <value>] [--content-type <value>] [--branch <value>] [--team-uid <value>]
46
+ [--taxonomy-uid <value>] [--include-fallback] [--fallback-locale <value>] [--delimiter <value>]
47
+
48
+ FLAGS
49
+ -a, --alias=<value> Alias of the management token.
50
+ -k, --stack-api-key=<value> API Key of the source stack.
51
+ -n, --stack-name=<value> Name of the stack that needs to be created as CSV filename.
52
+ --action=<option> Option to export data (entries, users, teams, taxonomies). <options:
53
+ entries|users|teams|taxonomies>
54
+ <options: entries|users|teams|taxonomies>
55
+ --branch=<value> Branch from which entries will be exported.
56
+ --content-type=<value> Content type of entries that will be exported.
57
+ --delimiter=<value> [default: ,] [optional] Provide a delimiter to separate individual data fields within
58
+ the CSV file. For example: cm:export-to-csv --delimiter '|'
59
+ --fallback-locale=<value> [Optional] Specify a specific fallback locale for taxonomy export. This locale will be
60
+ used when a taxonomy term doesn't exist in the primary locale. Takes priority over
61
+ branch fallback hierarchy when both are specified.
62
+ --include-fallback [Optional] Include fallback locale data when exporting taxonomies. When enabled, if a
63
+ taxonomy term doesn't exist in the specified locale, it will fallback to the hierarchy
64
+ defined in the branch settings.
65
+ --locale=<value> Locale of entries that will be exported.
66
+ --org=<value> Provide organization UID to clone org users.
67
+ --org-name=<value> Name of the organization that needs to be created as CSV filename.
68
+ --taxonomy-uid=<value> Provide the taxonomy UID of the related terms you want to export.
69
+ --team-uid=<value> Provide the UID of a specific team in an organization.
70
+
71
+ DESCRIPTION
72
+ Export entries, taxonomies, terms or organization users to csv using this command
73
+
74
+ ALIASES
37
75
  $ csdx cm:export-to-csv
76
+
77
+ EXAMPLES
78
+ $ csdx cm:export-to-csv
79
+
80
+
81
+
82
+ Exporting entries to CSV
83
+
84
+ $ csdx cm:export-to-csv --action entries --locale <locale> --alias <management-token-alias> --content-type <content-type>
85
+
86
+
87
+
88
+ Exporting entries to CSV with stack name and branch
89
+
90
+ $ csdx cm:export-to-csv --action entries --locale <locale> --alias <management-token-alias> --content-type <content-type> --stack-name <stack-name> --branch <branch-name>
91
+
92
+
93
+
94
+ Exporting organization users to CSV
95
+
96
+ $ csdx cm:export-to-csv --action users --org <org-uid>
97
+
98
+
99
+
100
+ Exporting organization teams to CSV
101
+
102
+ $ csdx cm:export-to-csv --action teams --org <org-uid>
103
+
104
+
105
+
106
+ Exporting teams with specific team UID
107
+
108
+ $ csdx cm:export-to-csv --action teams --org <org-uid> --team-uid <team-uid>
109
+
110
+
111
+
112
+ Exporting taxonomies to CSV
113
+
114
+ $ csdx cm:export-to-csv --action taxonomies --alias <management-token-alias>
115
+
116
+
117
+
118
+ Exporting specific taxonomy with locale
119
+
120
+ $ csdx cm:export-to-csv --action taxonomies --alias <management-token-alias> --taxonomy-uid <taxonomy-uid> --locale <locale>
121
+
122
+
123
+
124
+ Exporting taxonomies with fallback locale
125
+
126
+ $ csdx cm:export-to-csv --action taxonomies --alias <management-token-alias> --locale <locale> --include-fallback --fallback-locale <fallback-locale>
38
127
  ```
39
128
 
40
- _See code: [src/commands/cm/export-to-csv.js](https://github.com/contentstack/cli/blob/main/packages/contentstack-export-to-csv/src/commands/cm/export-to-csv.js)_
129
+ _See code: [src/commands/cm/export-to-csv.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export-to-csv/src/commands/cm/export-to-csv.ts)_
130
+ <!-- commandsstop -->
@@ -115,20 +115,11 @@ function getOrgUsers(managementAPIClient, orgUid) {
115
115
  if (!organization) {
116
116
  return reject(new Error('Org UID not found.'));
117
117
  }
118
- if (organization.is_owner === true) {
119
- return managementAPIClient
120
- .organization(organization.uid)
121
- .getInvitations()
122
- .then((data) => {
123
- resolve(data);
124
- })
125
- .catch(reject);
126
- }
127
- if (!organization.getInvitations && !(0, find_1.default)(organization.org_roles, 'admin')) {
118
+ if (!organization.is_owner && !(0, find_1.default)(organization.org_roles, 'admin')) {
128
119
  return reject(new Error(messages_1.messages.ERROR_ADMIN_ACCESS_DENIED));
129
120
  }
130
121
  try {
131
- const users = await getUsers(managementAPIClient, { uid: organization.uid }, { skip: 0, page: 1, limit: 100 });
122
+ const users = await getUsers(managementAPIClient, { uid: organization.uid }, { skip: 0, page: 1, limit: config_1.default.limit });
132
123
  return resolve({ items: users || [] });
133
124
  }
134
125
  catch (error) {
@@ -142,20 +133,22 @@ function getOrgUsers(managementAPIClient, orgUid) {
142
133
  * Get users with pagination.
143
134
  */
144
135
  async function getUsers(managementAPIClient, organization, params, result = []) {
136
+ var _a;
145
137
  try {
146
138
  const users = await managementAPIClient.organization(organization.uid).getInvitations(params);
147
- if (!users.items || (users.items && !users.items.length)) {
139
+ if (!users.items || users.items.length < params.limit) {
140
+ if ((_a = users.items) === null || _a === void 0 ? void 0 : _a.length) {
141
+ result = result.concat(users.items);
142
+ }
148
143
  return result;
149
144
  }
150
- else {
151
- result = result.concat(users.items);
152
- params.skip = params.page * params.limit;
153
- params.page++;
154
- await (0, error_handler_1.wait)(200);
155
- return getUsers(managementAPIClient, organization, params, result);
156
- }
145
+ result = result.concat(users.items);
146
+ params.skip = params.page * params.limit;
147
+ params.page++;
148
+ await (0, error_handler_1.wait)(200);
149
+ return getUsers(managementAPIClient, organization, params, result);
157
150
  }
158
- catch (_a) {
151
+ catch (_b) {
159
152
  return result;
160
153
  }
161
154
  }
@@ -167,5 +167,5 @@
167
167
  ]
168
168
  }
169
169
  },
170
- "version": "1.12.3"
170
+ "version": "1.12.5"
171
171
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-export-to-csv",
3
3
  "description": "Export entries, taxonomies, terms, or organization users to CSV",
4
- "version": "1.12.3",
4
+ "version": "1.12.5",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "~1.8.3",
9
- "@contentstack/cli-utilities": "~1.18.4",
8
+ "@contentstack/cli-command": "~1.8.4",
9
+ "@contentstack/cli-utilities": "~1.18.5",
10
10
  "@oclif/core": "^4.11.4",
11
11
  "fast-csv": "^4.3.6",
12
12
  "inquirer": "8.2.7",
@@ -19,7 +19,7 @@
19
19
  "@types/mocha": "^10.0.10",
20
20
  "@types/node": "^20.17.50",
21
21
  "chai": "^4.5.0",
22
- "eslint": "^9.26.0",
22
+ "eslint": "^10.5.0",
23
23
  "eslint-config-oclif": "^6.0.62",
24
24
  "eslint-config-oclif-typescript": "^3.1.14",
25
25
  "mocha": "^10.8.2",
@@ -30,7 +30,7 @@
30
30
  "typescript": "^5.8.3"
31
31
  },
32
32
  "engines": {
33
- "node": ">=18.0.0"
33
+ "node": ">=22.0.0"
34
34
  },
35
35
  "files": [
36
36
  "/bin",