@simplysf/simply-data 1.1.9-dev.0 → 1.1.9
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/CHANGELOG.md +9 -0
- package/README.md +2 -47
- package/lib/common/contentVersionTypes.d.ts +1 -11
- package/lib/common/contentVersionUtils.d.ts +1 -2
- package/lib/common/contentVersionUtils.js +0 -10
- package/lib/common/contentVersionUtils.js.map +1 -1
- package/npm-shrinkwrap.json +16 -17
- package/oclif.lock +1 -1
- package/oclif.manifest.json +1 -99
- package/package.json +1 -2
- package/lib/commands/simply/data/files/download.d.ts +0 -13
- package/lib/commands/simply/data/files/download.js +0 -100
- package/lib/commands/simply/data/files/download.js.map +0 -1
- package/messages/simply.data.files.download.md +0 -33
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [1.1.9](https://github.com/SimplySF/simply-data/compare/1.1.8...1.1.9) (2024-03-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* incorrect tagging logic ([f08bd33](https://github.com/SimplySF/simply-data/commit/f08bd3343e3a967c184085305ab62e0320f8cb30))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
## [1.1.8](https://github.com/SimplySF/simply-data/compare/1.1.7...1.1.8) (2024-03-13)
|
|
2
11
|
|
|
3
12
|
|
package/README.md
CHANGED
|
@@ -57,7 +57,6 @@ sf plugins
|
|
|
57
57
|
|
|
58
58
|
<!-- commands -->
|
|
59
59
|
* [`sf simply data file upload`](#sf-simply-data-file-upload)
|
|
60
|
-
* [`sf simply data files download`](#sf-simply-data-files-download)
|
|
61
60
|
* [`sf simply data files upload`](#sf-simply-data-files-upload)
|
|
62
61
|
|
|
63
62
|
## `sf simply data file upload`
|
|
@@ -91,51 +90,7 @@ EXAMPLES
|
|
|
91
90
|
$ sf simply data file upload --file-path fileToUpload.txt --first-publish-location-id 0019000000DmehK --target-org myTargetOrg
|
|
92
91
|
```
|
|
93
92
|
|
|
94
|
-
_See code: [src/commands/simply/data/file/upload.ts](https://github.com/SimplySF/simply-data/blob/1.1.9
|
|
95
|
-
|
|
96
|
-
## `sf simply data files download`
|
|
97
|
-
|
|
98
|
-
Download files from a Salesforce org.
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
USAGE
|
|
102
|
-
$ sf simply data files download -o <value> --where <value> [--json] [--api-version <value>] [--max-parallel-jobs
|
|
103
|
-
<value>]
|
|
104
|
-
|
|
105
|
-
FLAGS
|
|
106
|
-
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
107
|
-
configuration variable is already set.
|
|
108
|
-
--api-version=<value> Override the api version used for api requests made by this command
|
|
109
|
-
--max-parallel-jobs=<value> [default: 1] Maximum number of parallel jobs.
|
|
110
|
-
--where=<value> (required) WHERE clause for ContentVersion query.
|
|
111
|
-
|
|
112
|
-
GLOBAL FLAGS
|
|
113
|
-
--json Format output as json.
|
|
114
|
-
|
|
115
|
-
DESCRIPTION
|
|
116
|
-
Download files from a Salesforce org.
|
|
117
|
-
|
|
118
|
-
Downloads files specified by a where clause to a ContentVersion query from a Salesforce org. By default, the plugin
|
|
119
|
-
uses the REST API for the download as to allow for the streaming of large files without issue. This means that each
|
|
120
|
-
file will use one REST API request.
|
|
121
|
-
|
|
122
|
-
EXAMPLES
|
|
123
|
-
$ sf simply data files download --where 'IsLatest=true' --target-org myTargetOrg
|
|
124
|
-
|
|
125
|
-
$ sf simply data files download --where 'IsLatest=true' --max-parallel-jobs 5 --target-org myTargetOrg
|
|
126
|
-
|
|
127
|
-
FLAG DESCRIPTIONS
|
|
128
|
-
--max-parallel-jobs=<value> Maximum number of parallel jobs.
|
|
129
|
-
|
|
130
|
-
By default the plugin will only process a single file download at a time. You can increase this value to allow for
|
|
131
|
-
quasi concurrent downloads. Please note that setting this value too high can cause performance issues.
|
|
132
|
-
|
|
133
|
-
--where=<value> WHERE clause for ContentVersion query.
|
|
134
|
-
|
|
135
|
-
Provide a WHERE clause to allow the plugin to specify which ContentVersion records should be downloaded.
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
_See code: [src/commands/simply/data/files/download.ts](https://github.com/SimplySF/simply-data/blob/1.1.9-dev.0/src/commands/simply/data/files/download.ts)_
|
|
93
|
+
_See code: [src/commands/simply/data/file/upload.ts](https://github.com/SimplySF/simply-data/blob/1.1.9/src/commands/simply/data/file/upload.ts)_
|
|
139
94
|
|
|
140
95
|
## `sf simply data files upload`
|
|
141
96
|
|
|
@@ -179,5 +134,5 @@ FLAG DESCRIPTIONS
|
|
|
179
134
|
quasi concurrent uploads. Please note that setting this value too high can cause performance issues.
|
|
180
135
|
```
|
|
181
136
|
|
|
182
|
-
_See code: [src/commands/simply/data/files/upload.ts](https://github.com/SimplySF/simply-data/blob/1.1.9
|
|
137
|
+
_See code: [src/commands/simply/data/files/upload.ts](https://github.com/SimplySF/simply-data/blob/1.1.9/src/commands/simply/data/files/upload.ts)_
|
|
183
138
|
<!-- commandsstop -->
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
export interface ContentVersion {
|
|
2
|
-
ContentDocumentId
|
|
3
|
-
ContentSize: string;
|
|
4
|
-
Description: string;
|
|
2
|
+
ContentDocumentId?: string;
|
|
5
3
|
FileExtension: string;
|
|
6
|
-
FileType: string;
|
|
7
|
-
FirstPublishLocationId: string;
|
|
8
4
|
Id: string;
|
|
9
|
-
IsLatest: string;
|
|
10
|
-
PathOnClient: string;
|
|
11
5
|
Title: string;
|
|
12
6
|
}
|
|
13
7
|
export interface ContentVersionCreateRequest {
|
|
@@ -22,10 +16,6 @@ export interface ContentVersionCreateResult {
|
|
|
22
16
|
name: string;
|
|
23
17
|
message: string;
|
|
24
18
|
}
|
|
25
|
-
export interface ContentVersionDownload extends ContentVersion {
|
|
26
|
-
Error?: string;
|
|
27
|
-
FilePath?: string;
|
|
28
|
-
}
|
|
29
19
|
export type ContentVersionToUpload = {
|
|
30
20
|
ContentDocumentId?: string;
|
|
31
21
|
Error?: string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { ContentVersion
|
|
3
|
-
export declare function downloadContentVersion(targetOrgConnection: Connection, contentVersionDownload: ContentVersionDownload): Promise<void>;
|
|
2
|
+
import { ContentVersion } from './contentVersionTypes.js';
|
|
4
3
|
export declare function uploadContentVersion(targetOrgConnection: Connection, pathOnClient: string, title?: string, firstPublishLocationId?: string): Promise<ContentVersion>;
|
|
@@ -6,18 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
-
import stream from 'node:stream';
|
|
10
9
|
import FormData from 'form-data';
|
|
11
10
|
import got from 'got';
|
|
12
|
-
export async function downloadContentVersion(targetOrgConnection, contentVersionDownload) {
|
|
13
|
-
const filePath = `${contentVersionDownload.ContentDocumentId}_${contentVersionDownload.Title.replaceAll(' ', '_')}.${contentVersionDownload.FileExtension}`;
|
|
14
|
-
await stream.promises.pipeline(got.stream(`${targetOrgConnection.baseUrl()}/sobjects/ContentVersion/${contentVersionDownload.Id}/VersionData`, {
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${targetOrgConnection.accessToken}`,
|
|
17
|
-
},
|
|
18
|
-
}), fs.createWriteStream(filePath));
|
|
19
|
-
contentVersionDownload.FilePath = filePath;
|
|
20
|
-
}
|
|
21
11
|
export async function uploadContentVersion(targetOrgConnection, pathOnClient, title, firstPublishLocationId) {
|
|
22
12
|
// Check that we have access to the file
|
|
23
13
|
await fs.promises.access(pathOnClient, fs.constants.F_OK);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentVersionUtils.js","sourceRoot":"","sources":["../../src/common/contentVersionUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,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AW,EAAE,GAAG;SACxE;QACD,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,MAAM;KACrB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC,iBAAiB,CAC7D,oFAAoF,IAAI,CAAC,EAAE,GAAG,CAC/F,CAAC;IAEF,OAAO,WAA6B,CAAC;AACvC,CAAC"}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysf/simply-data",
|
|
3
|
-
"version": "1.1.9
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@simplysf/simply-data",
|
|
9
|
-
"version": "1.1.9
|
|
9
|
+
"version": "1.1.9",
|
|
10
10
|
"license": "BSD-3-Clause",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@oclif/core": "^3.25.0",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"csv-writer": "^1.6.0",
|
|
18
18
|
"form-data": "^4.0.0",
|
|
19
19
|
"got": "13.0.0",
|
|
20
|
-
"jsforce": "2.0.0-beta.29",
|
|
21
20
|
"p-queue": "^8.0.1"
|
|
22
21
|
},
|
|
23
22
|
"devDependencies": {
|
|
@@ -7665,12 +7664,13 @@
|
|
|
7665
7664
|
}
|
|
7666
7665
|
},
|
|
7667
7666
|
"node_modules/commander": {
|
|
7668
|
-
"version": "
|
|
7669
|
-
"resolved": "https://registry.npmjs.org/commander/-/commander-
|
|
7670
|
-
"integrity": "sha512-
|
|
7667
|
+
"version": "7.1.0",
|
|
7668
|
+
"resolved": "https://registry.npmjs.org/commander/-/commander-7.1.0.tgz",
|
|
7669
|
+
"integrity": "sha512-pRxBna3MJe6HKnBGsDyMv8ETbptw3axEdYHoqNh7gu5oDcew8fs0xnivZGm06Ogk8zGAJ9VX+OPEr2GXEQK4dg==",
|
|
7670
|
+
"dev": true,
|
|
7671
7671
|
"license": "MIT",
|
|
7672
7672
|
"engines": {
|
|
7673
|
-
"node": ">=
|
|
7673
|
+
"node": ">= 10"
|
|
7674
7674
|
}
|
|
7675
7675
|
},
|
|
7676
7676
|
"node_modules/comment-parser": {
|
|
@@ -11304,6 +11304,15 @@
|
|
|
11304
11304
|
"integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==",
|
|
11305
11305
|
"license": "MIT"
|
|
11306
11306
|
},
|
|
11307
|
+
"node_modules/jsforce/node_modules/commander": {
|
|
11308
|
+
"version": "4.1.1",
|
|
11309
|
+
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
|
|
11310
|
+
"integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==",
|
|
11311
|
+
"license": "MIT",
|
|
11312
|
+
"engines": {
|
|
11313
|
+
"node": ">= 6"
|
|
11314
|
+
}
|
|
11315
|
+
},
|
|
11307
11316
|
"node_modules/jsforce/node_modules/csv-parse": {
|
|
11308
11317
|
"version": "4.16.3",
|
|
11309
11318
|
"resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-4.16.3.tgz",
|
|
@@ -17895,16 +17904,6 @@
|
|
|
17895
17904
|
"ieee754": "^1.2.1"
|
|
17896
17905
|
}
|
|
17897
17906
|
},
|
|
17898
|
-
"node_modules/yeoman-environment/node_modules/commander": {
|
|
17899
|
-
"version": "7.1.0",
|
|
17900
|
-
"resolved": "https://registry.npmjs.org/commander/-/commander-7.1.0.tgz",
|
|
17901
|
-
"integrity": "sha512-pRxBna3MJe6HKnBGsDyMv8ETbptw3axEdYHoqNh7gu5oDcew8fs0xnivZGm06Ogk8zGAJ9VX+OPEr2GXEQK4dg==",
|
|
17902
|
-
"dev": true,
|
|
17903
|
-
"license": "MIT",
|
|
17904
|
-
"engines": {
|
|
17905
|
-
"node": ">= 10"
|
|
17906
|
-
}
|
|
17907
|
-
},
|
|
17908
17907
|
"node_modules/yeoman-environment/node_modules/diff": {
|
|
17909
17908
|
"version": "5.1.0",
|
|
17910
17909
|
"resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz",
|
package/oclif.lock
CHANGED
|
@@ -6496,7 +6496,7 @@ jsesc@~0.5.0:
|
|
|
6496
6496
|
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"
|
|
6497
6497
|
integrity sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==
|
|
6498
6498
|
|
|
6499
|
-
jsforce
|
|
6499
|
+
jsforce@^2.0.0-beta.29:
|
|
6500
6500
|
version "2.0.0-beta.29"
|
|
6501
6501
|
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-2.0.0-beta.29.tgz#0b59b026eb0b90dfb199a53656af32a4c8acc48f"
|
|
6502
6502
|
integrity sha512-Fq7xjOYOikyozZZDQNTfzsAdhcO0rUXwtavsjM+cCYUFiCMVOJJavgco303zOsJk3v8sdAYnGgHyKckLIhnyAg==
|
package/oclif.manifest.json
CHANGED
|
@@ -102,104 +102,6 @@
|
|
|
102
102
|
"upload:file:data:simply"
|
|
103
103
|
]
|
|
104
104
|
},
|
|
105
|
-
"simply:data:files:download": {
|
|
106
|
-
"aliases": [],
|
|
107
|
-
"args": {},
|
|
108
|
-
"description": "Downloads files specified by a where clause to a ContentVersion query from a Salesforce org. By default, the plugin uses the REST API for the download as to allow for the streaming of large files without issue. This means that each file will use one REST API request.",
|
|
109
|
-
"examples": [
|
|
110
|
-
"<%= config.bin %> <%= command.id %> --where 'IsLatest=true' --target-org myTargetOrg",
|
|
111
|
-
"<%= config.bin %> <%= command.id %> --where 'IsLatest=true' --max-parallel-jobs 5 --target-org myTargetOrg"
|
|
112
|
-
],
|
|
113
|
-
"flags": {
|
|
114
|
-
"json": {
|
|
115
|
-
"description": "Format output as json.",
|
|
116
|
-
"helpGroup": "GLOBAL",
|
|
117
|
-
"name": "json",
|
|
118
|
-
"allowNo": false,
|
|
119
|
-
"type": "boolean"
|
|
120
|
-
},
|
|
121
|
-
"api-version": {
|
|
122
|
-
"description": "Override the api version used for api requests made by this command",
|
|
123
|
-
"name": "api-version",
|
|
124
|
-
"hasDynamicHelp": false,
|
|
125
|
-
"multiple": false,
|
|
126
|
-
"type": "option"
|
|
127
|
-
},
|
|
128
|
-
"max-parallel-jobs": {
|
|
129
|
-
"description": "By default the plugin will only process a single file download at a time. You can increase this value to allow for quasi concurrent downloads. Please note that setting this value too high can cause performance issues.",
|
|
130
|
-
"name": "max-parallel-jobs",
|
|
131
|
-
"summary": "Maximum number of parallel jobs.",
|
|
132
|
-
"default": 1,
|
|
133
|
-
"hasDynamicHelp": false,
|
|
134
|
-
"multiple": false,
|
|
135
|
-
"type": "option"
|
|
136
|
-
},
|
|
137
|
-
"target-org": {
|
|
138
|
-
"char": "o",
|
|
139
|
-
"name": "target-org",
|
|
140
|
-
"noCacheDefault": true,
|
|
141
|
-
"required": true,
|
|
142
|
-
"summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
|
|
143
|
-
"hasDynamicHelp": true,
|
|
144
|
-
"multiple": false,
|
|
145
|
-
"type": "option"
|
|
146
|
-
},
|
|
147
|
-
"where": {
|
|
148
|
-
"description": "Provide a WHERE clause to allow the plugin to specify which ContentVersion records should be downloaded.",
|
|
149
|
-
"name": "where",
|
|
150
|
-
"required": true,
|
|
151
|
-
"summary": "WHERE clause for ContentVersion query.",
|
|
152
|
-
"hasDynamicHelp": false,
|
|
153
|
-
"multiple": false,
|
|
154
|
-
"type": "option"
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
"hasDynamicHelp": true,
|
|
158
|
-
"hiddenAliases": [],
|
|
159
|
-
"id": "simply:data:files:download",
|
|
160
|
-
"pluginAlias": "@simplysf/simply-data",
|
|
161
|
-
"pluginName": "@simplysf/simply-data",
|
|
162
|
-
"pluginType": "core",
|
|
163
|
-
"strict": true,
|
|
164
|
-
"summary": "Download files from a Salesforce org.",
|
|
165
|
-
"enableJsonFlag": true,
|
|
166
|
-
"isESM": true,
|
|
167
|
-
"relativePath": [
|
|
168
|
-
"lib",
|
|
169
|
-
"commands",
|
|
170
|
-
"simply",
|
|
171
|
-
"data",
|
|
172
|
-
"files",
|
|
173
|
-
"download.js"
|
|
174
|
-
],
|
|
175
|
-
"aliasPermutations": [],
|
|
176
|
-
"permutations": [
|
|
177
|
-
"simply:data:files:download",
|
|
178
|
-
"data:simply:files:download",
|
|
179
|
-
"data:files:simply:download",
|
|
180
|
-
"data:files:download:simply",
|
|
181
|
-
"simply:files:data:download",
|
|
182
|
-
"files:simply:data:download",
|
|
183
|
-
"files:data:simply:download",
|
|
184
|
-
"files:data:download:simply",
|
|
185
|
-
"simply:files:download:data",
|
|
186
|
-
"files:simply:download:data",
|
|
187
|
-
"files:download:simply:data",
|
|
188
|
-
"files:download:data:simply",
|
|
189
|
-
"simply:data:download:files",
|
|
190
|
-
"data:simply:download:files",
|
|
191
|
-
"data:download:simply:files",
|
|
192
|
-
"data:download:files:simply",
|
|
193
|
-
"simply:download:data:files",
|
|
194
|
-
"download:simply:data:files",
|
|
195
|
-
"download:data:simply:files",
|
|
196
|
-
"download:data:files:simply",
|
|
197
|
-
"simply:download:files:data",
|
|
198
|
-
"download:simply:files:data",
|
|
199
|
-
"download:files:simply:data",
|
|
200
|
-
"download:files:data:simply"
|
|
201
|
-
]
|
|
202
|
-
},
|
|
203
105
|
"simply:data:files:upload": {
|
|
204
106
|
"aliases": [],
|
|
205
107
|
"args": {},
|
|
@@ -299,5 +201,5 @@
|
|
|
299
201
|
]
|
|
300
202
|
}
|
|
301
203
|
},
|
|
302
|
-
"version": "1.1.9
|
|
204
|
+
"version": "1.1.9"
|
|
303
205
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysf/simply-data",
|
|
3
3
|
"description": "Utilities for working with data",
|
|
4
|
-
"version": "1.1.9
|
|
4
|
+
"version": "1.1.9",
|
|
5
5
|
"author": "@ClayChipps",
|
|
6
6
|
"bugs": "https://github.com/SimplySF/simply-data/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"csv-writer": "^1.6.0",
|
|
14
14
|
"form-data": "^4.0.0",
|
|
15
15
|
"got": "13.0.0",
|
|
16
|
-
"jsforce": "2.0.0-beta.29",
|
|
17
16
|
"p-queue": "^8.0.1"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
export default class DataFilesDownload extends SfCommand<void> {
|
|
3
|
-
static readonly summary: string;
|
|
4
|
-
static readonly description: string;
|
|
5
|
-
static readonly examples: string[];
|
|
6
|
-
static readonly flags: {
|
|
7
|
-
'api-version': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
-
'max-parallel-jobs': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
-
'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
-
where: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
-
};
|
|
12
|
-
run(): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2024, Clay Chipps; Copyright (c) 2024, Salesforce.com, Inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* Licensed under the BSD 3-Clause license.
|
|
5
|
-
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
-
*/
|
|
7
|
-
import { createObjectCsvWriter } from 'csv-writer';
|
|
8
|
-
import PQueue from 'p-queue';
|
|
9
|
-
import { Messages } from '@salesforce/core';
|
|
10
|
-
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
11
|
-
import { downloadContentVersion } from '../../../../common/contentVersionUtils.js';
|
|
12
|
-
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
13
|
-
const messages = Messages.loadMessages('@simplysf/simply-data', 'simply.data.files.download');
|
|
14
|
-
export default class DataFilesDownload extends SfCommand {
|
|
15
|
-
static summary = messages.getMessage('summary');
|
|
16
|
-
static description = messages.getMessage('description');
|
|
17
|
-
static examples = messages.getMessages('examples');
|
|
18
|
-
static flags = {
|
|
19
|
-
'api-version': Flags.orgApiVersion(),
|
|
20
|
-
'max-parallel-jobs': Flags.integer({
|
|
21
|
-
summary: messages.getMessage('flags.max-parallel-jobs.summary'),
|
|
22
|
-
description: messages.getMessage('flags.max-parallel-jobs.description'),
|
|
23
|
-
default: 1,
|
|
24
|
-
}),
|
|
25
|
-
'target-org': Flags.requiredOrg(),
|
|
26
|
-
where: Flags.string({
|
|
27
|
-
summary: messages.getMessage('flags.where.summary'),
|
|
28
|
-
description: messages.getMessage('flags.where.description'),
|
|
29
|
-
required: true,
|
|
30
|
-
}),
|
|
31
|
-
};
|
|
32
|
-
async run() {
|
|
33
|
-
const { flags } = await this.parse(DataFilesDownload);
|
|
34
|
-
// Authorize to the target org
|
|
35
|
-
const targetOrgConnection = flags['target-org']?.getConnection(flags['api-version']);
|
|
36
|
-
if (!targetOrgConnection) {
|
|
37
|
-
throw messages.createError('error.targetOrgConnectionFailed');
|
|
38
|
-
}
|
|
39
|
-
this.spinner.start('Querying for files', '\n', { stdout: true });
|
|
40
|
-
const query = await targetOrgConnection.autoFetchQuery(`SELECT ContentDocumentId, ContentSize, Description, FileExtension, FileType, FirstPublishLocationId, Id, IsLatest, PathOnClient, Title FROM ContentVersion WHERE ${flags.where}`);
|
|
41
|
-
const contentVersionDownloads = query.records;
|
|
42
|
-
this.spinner.start('Downloading files', '\n', { stdout: true });
|
|
43
|
-
const successWriter = createObjectCsvWriter({
|
|
44
|
-
path: 'success.csv',
|
|
45
|
-
header: [
|
|
46
|
-
{ id: 'Id', title: 'Id' },
|
|
47
|
-
{ id: 'ContentDocumentId', title: 'ContentDocumentId' },
|
|
48
|
-
{ id: 'ContentSize', title: 'ContentSize' },
|
|
49
|
-
{ id: 'Description', title: 'Description' },
|
|
50
|
-
{ id: 'FileExtension', title: 'FileExtension' },
|
|
51
|
-
{ id: 'FileType', title: 'FileType' },
|
|
52
|
-
{ id: 'FirstPublishLocationId', title: 'FirstPublishLocationId' },
|
|
53
|
-
{ id: 'IsLatest', title: 'IsLatest' },
|
|
54
|
-
{ id: 'PathOnClient', title: 'PathOnClient' },
|
|
55
|
-
{ id: 'Title', title: 'Title' },
|
|
56
|
-
{ id: 'FilePath', title: 'FilePath' },
|
|
57
|
-
],
|
|
58
|
-
});
|
|
59
|
-
const errorWriter = createObjectCsvWriter({
|
|
60
|
-
path: 'error.csv',
|
|
61
|
-
header: [
|
|
62
|
-
{ id: 'Id', title: 'Id' },
|
|
63
|
-
{ id: 'ContentDocumentId', title: 'ContentDocumentId' },
|
|
64
|
-
{ id: 'ContentSize', title: 'ContentSize' },
|
|
65
|
-
{ id: 'Description', title: 'Description' },
|
|
66
|
-
{ id: 'FileExtension', title: 'FileExtension' },
|
|
67
|
-
{ id: 'FileType', title: 'FileType' },
|
|
68
|
-
{ id: 'FirstPublishLocationId', title: 'FirstPublishLocationId' },
|
|
69
|
-
{ id: 'IsLatest', title: 'IsLatest' },
|
|
70
|
-
{ id: 'PathOnClient', title: 'PathOnClient' },
|
|
71
|
-
{ id: 'Title', title: 'Title' },
|
|
72
|
-
{ id: 'Error', title: 'Error' },
|
|
73
|
-
],
|
|
74
|
-
});
|
|
75
|
-
const downloadQueue = new PQueue({ concurrency: flags['max-parallel-jobs'] });
|
|
76
|
-
let count = 0;
|
|
77
|
-
downloadQueue.on('add', () => {
|
|
78
|
-
this.spinner.status = `Completed: ${count}. Size: ${downloadQueue.size} Pending: ${downloadQueue.pending}\n`;
|
|
79
|
-
});
|
|
80
|
-
downloadQueue.on('completed', () => {
|
|
81
|
-
count++;
|
|
82
|
-
this.spinner.status = `Completed: ${count}. Size: ${downloadQueue.size} Pending: ${downloadQueue.pending}\n`;
|
|
83
|
-
});
|
|
84
|
-
for await (const contentVersionDownload of contentVersionDownloads) {
|
|
85
|
-
void downloadQueue.add(async () => {
|
|
86
|
-
try {
|
|
87
|
-
await downloadContentVersion(targetOrgConnection, contentVersionDownload);
|
|
88
|
-
await successWriter.writeRecords([contentVersionDownload]);
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
contentVersionDownload.Error = error;
|
|
92
|
-
await errorWriter.writeRecords([contentVersionDownload]);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
await downloadQueue.onIdle();
|
|
97
|
-
this.spinner.stop();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=download.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../../../../src/commands/simply/data/files/download.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,O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,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,cAAc,KAAK,WAAW,aAAa,CAAC,IAAI,cAAc,aAAa,CAAC,OAAO,IAAI,CAAC;QAChH,CAAC,CAAC,CAAC;QAEH,IAAI,KAAK,EAAE,MAAM,sBAAsB,IAAI,uBAAuB,EAAE,CAAC;YACnE,KAAK,aAAa,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;gBAChC,IAAI,CAAC;oBACH,MAAM,sBAAsB,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;oBAC1E,MAAM,aAAa,CAAC,YAAY,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC;gBAC7D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,sBAAsB,CAAC,KAAK,GAAG,KAAe,CAAC;oBAC/C,MAAM,WAAW,CAAC,YAAY,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,MAAM,aAAa,CAAC,MAAM,EAAE,CAAC;QAE7B,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# summary
|
|
2
|
-
|
|
3
|
-
Download files from a Salesforce org.
|
|
4
|
-
|
|
5
|
-
# description
|
|
6
|
-
|
|
7
|
-
Downloads files specified by a where clause to a ContentVersion query from a Salesforce org. By default, the plugin uses the REST API for the download as to allow for the streaming of large files without issue. This means that each file will use one REST API request.
|
|
8
|
-
|
|
9
|
-
# flags.max-parallel-jobs.summary
|
|
10
|
-
|
|
11
|
-
Maximum number of parallel jobs.
|
|
12
|
-
|
|
13
|
-
# flags.max-parallel-jobs.description
|
|
14
|
-
|
|
15
|
-
By default the plugin will only process a single file download at a time. You can increase this value to allow for quasi concurrent downloads. Please note that setting this value too high can cause performance issues.
|
|
16
|
-
|
|
17
|
-
# flags.where.summary
|
|
18
|
-
|
|
19
|
-
WHERE clause for ContentVersion query.
|
|
20
|
-
|
|
21
|
-
# flags.where.description
|
|
22
|
-
|
|
23
|
-
Provide a WHERE clause to allow the plugin to specify which ContentVersion records should be downloaded.
|
|
24
|
-
|
|
25
|
-
# examples
|
|
26
|
-
|
|
27
|
-
- <%= config.bin %> <%= command.id %> --where 'IsLatest=true' --target-org myTargetOrg
|
|
28
|
-
|
|
29
|
-
- <%= config.bin %> <%= command.id %> --where 'IsLatest=true' --max-parallel-jobs 5 --target-org myTargetOrg
|
|
30
|
-
|
|
31
|
-
# error.targetOrgConnectionFailed
|
|
32
|
-
|
|
33
|
-
Unable to establish connection to the org.
|