node-sf-bulk2 0.0.22 → 0.1.0
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 +72 -4
- package/README.md +194 -177
- package/dist/bulk2.d.ts +8 -0
- package/dist/bulk2.js +79 -1
- package/dist/bulk2.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/model/allIngestJobsInfoResponse.d.ts +6 -0
- package/dist/model/allIngestJobsInfoResponse.js +3 -0
- package/dist/model/allIngestJobsInfoResponse.js.map +1 -0
- package/dist/model/bulkJobInfoResponse.d.ts +1 -0
- package/dist/model/connection.d.ts +4 -0
- package/dist/model/enum.d.ts +11 -2
- package/dist/model/enum.js +17 -7
- package/dist/model/enum.js.map +1 -1
- package/dist/model/ingestJobConfig.d.ts +5 -0
- package/dist/model/ingestJobConfig.js +3 -0
- package/dist/model/ingestJobConfig.js.map +1 -0
- package/dist/model/parallelQueryResultsResponse.d.ts +8 -0
- package/dist/model/parallelQueryResultsResponse.js +3 -0
- package/dist/model/parallelQueryResultsResponse.js.map +1 -0
- package/package.json +18 -12
- package/.eslintrc.json +0 -7
- package/tsconfig.json +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -2,19 +2,87 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.1.0] - 2026-04-30
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Sforce-Call-Options header support** — `Connection` now accepts `callOptions` with `client` and `defaultNamespace` fields, sent as the `Sforce-Call-Options` header on every request.
|
|
10
|
+
- **`deleteIngestJob(jobId)`** — delete a completed ingest job.
|
|
11
|
+
- **`deleteBulkQueryJob(jobId)`** — delete a completed query job.
|
|
12
|
+
- **`getAllIngestJobInfo(config?)`** — list all ingest jobs with optional filters (`jobType`, `isPkChunkingEnabled`, `queryLocator`).
|
|
13
|
+
- **`getBulkQueryResultPages(jobId)`** — retrieve result page URLs for parallel query result downloads.
|
|
14
|
+
- **`createDataUploadJobWithData(request, csv)`** — create an ingest job and upload CSV data in a single multipart request.
|
|
15
|
+
- `JOBTYPE` enum (`BigObjectIngest`, `Classic`, `V2Ingest`, `V2Query`).
|
|
16
|
+
- `InProgress` added to `STATE` enum.
|
|
17
|
+
- `query` and `queryAll` added to `OPERATION` enum.
|
|
18
|
+
- `isPkChunkingSupported` field on `BulkJobInfoResponse`.
|
|
19
|
+
- New model types exported from the barrel: `AllIngestJobsInfoResponse`, `IngestJobConfig`, `JOBTYPE`, `ParallelQueryResultsResponse`, `ResultPage`.
|
|
20
|
+
- **Unit test suite** using Vitest — 33 tests covering all public methods, endpoint construction, headers, and error propagation.
|
|
21
|
+
- **Integration test suite** — runs against a real Salesforce org (skipped when credentials are not set).
|
|
22
|
+
- Vitest configuration and `test`, `test:unit`, `test:integration`, `test:watch` npm scripts.
|
|
23
|
+
- Rewritten README with full query and ingest lifecycle examples, API reference table, and testing docs.
|
|
24
|
+
- Simplified examples directory — two runnable TypeScript scripts (`query-job.ts`, `ingest-job.ts`) replacing the four nested mini-projects.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Updated `axios` to `^1.15.0`.
|
|
29
|
+
- Updated `typescript` to `~5.8.0`.
|
|
30
|
+
- Migrated ESLint from `.eslintrc.json` to flat config (`eslint.config.mjs`).
|
|
31
|
+
- Test files excluded from the TypeScript build output.
|
|
32
|
+
|
|
33
|
+
### Removed
|
|
34
|
+
|
|
35
|
+
- Old `examples/bulkquery/` and `examples/bulkinsert/` directories (each with their own `package.json`, `package-lock.json`, `tsconfig.json`).
|
|
36
|
+
|
|
37
|
+
## [0.0.23] - 2021-04-13
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- [Issue 14](https://github.com/msrivastav13/node-sf-bulk2/issues/14) — Set `maxBodyLength` and `maxContentLength` to `Infinity` on axios requests to support large CSV payloads.
|
|
42
|
+
|
|
5
43
|
## [0.0.22] - 2021-04-12
|
|
6
44
|
|
|
7
|
-
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- Renamed `abortbulkQueryJob` to `abortBulkQueryJob` (typo fix).
|
|
8
48
|
|
|
9
49
|
## [0.0.21] - 2021-04-12
|
|
10
50
|
|
|
11
51
|
### Fixed
|
|
12
52
|
|
|
13
|
-
|
|
53
|
+
- Renamed `getBulkqueryResults` to `getBulkQueryResults` (typo fix).
|
|
14
54
|
|
|
15
55
|
## [0.0.20] - 2021-04-12
|
|
16
56
|
|
|
17
57
|
### Fixed
|
|
18
58
|
|
|
19
|
-
- [Issue 11](https://github.com/msrivastav13/node-sf-bulk2/issues/11)
|
|
20
|
-
- [Issue 10](https://github.com/msrivastav13/node-sf-bulk2/issues/10)
|
|
59
|
+
- [Issue 11](https://github.com/msrivastav13/node-sf-bulk2/issues/11) — Renamed `getInjestJobInfo` to `getIngestJobInfo`.
|
|
60
|
+
- [Issue 10](https://github.com/msrivastav13/node-sf-bulk2/issues/10) — `getBulkQueryResults` now returns the full `AxiosResponse` (including headers) instead of just the data string. The `locator` parameter type changed from `number` to `string` to match the Salesforce API.
|
|
61
|
+
|
|
62
|
+
## [0.0.17] - 2021-03-07
|
|
63
|
+
|
|
64
|
+
### Added
|
|
65
|
+
|
|
66
|
+
- **Ingest job support** — `createDataUploadJob`, `uploadJobData`, `closeOrAbortJob`, `getIngestJobInfo`, `getResults`.
|
|
67
|
+
- `JobUploadRequest`, `JobUploadResponse`, `JobInfoResponse` model types.
|
|
68
|
+
- `OPERATION`, `STATE`, `RESULTTYPE` enums.
|
|
69
|
+
- TypeScript example for bulk insert with CSV file upload.
|
|
70
|
+
|
|
71
|
+
## [0.0.6] - 2021-03-01
|
|
72
|
+
|
|
73
|
+
### Added
|
|
74
|
+
|
|
75
|
+
- TypeScript and JavaScript examples for bulk query.
|
|
76
|
+
|
|
77
|
+
## [0.0.3] - 2021-02-28
|
|
78
|
+
|
|
79
|
+
### Added
|
|
80
|
+
|
|
81
|
+
- `BulkAPI2` class with query job support — `submitBulkQueryJob`, `getBulkQueryJobInfo`, `getAllBulkQueryJobInfo`, `abortBulkQueryJob`, `getBulkQueryResults`.
|
|
82
|
+
- `BulkQueryResponse`, `BulkJobInfoResponse`, `AllBulkQueryJobsInfoResponse`, `BulkQueryConfig`, `QueryInput` model types.
|
|
83
|
+
- `CONTENTTYPE`, `COLUMNDELIMITER`, `LINEENDING` enums.
|
|
84
|
+
- Tooling API support via `isTooling` connection flag.
|
|
85
|
+
|
|
86
|
+
## [0.0.1] - 2021-02-28
|
|
87
|
+
|
|
88
|
+
Initial release.
|
package/README.md
CHANGED
|
@@ -1,202 +1,219 @@
|
|
|
1
|
-
#
|
|
1
|
+
# node-sf-bulk2
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Node.js wrapper for the [Salesforce Bulk API 2.0](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_bulk_v2/asynch_api_intro.htm). Works with any auth library that gives you an access token — [jsforce](https://jsforce.github.io/), [@salesforce/sf-core](https://github.com/forcedotcom/sfdx-core), SF CLI, etc.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Written in TypeScript with full type definitions included.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```sh
|
|
10
|
+
npm install node-sf-bulk2
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
Create a connection object from any Salesforce auth source, then pass it to `BulkAPI2`:
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
```typescript
|
|
18
|
+
import { BulkAPI2, BulkAPI2Connection } from 'node-sf-bulk2';
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
const connection: BulkAPI2Connection = {
|
|
21
|
+
accessToken: '<your-access-token>',
|
|
22
|
+
instanceUrl: 'https://yourorg.my.salesforce.com',
|
|
23
|
+
apiVersion: '62.0',
|
|
24
|
+
};
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
const bulk = new BulkAPI2(connection);
|
|
27
|
+
```
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
For the Tooling API, set `isTooling: true` on the connection. To pass [call options](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers_calloptions.htm), add `callOptions`:
|
|
20
30
|
|
|
21
|
-
|
|
31
|
+
```typescript
|
|
32
|
+
const connection: BulkAPI2Connection = {
|
|
33
|
+
accessToken: '<token>',
|
|
34
|
+
instanceUrl: 'https://yourorg.my.salesforce.com',
|
|
35
|
+
apiVersion: '62.0',
|
|
36
|
+
isTooling: true,
|
|
37
|
+
callOptions: {
|
|
38
|
+
client: 'myApp',
|
|
39
|
+
defaultNamespace: 'ns1',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
```
|
|
22
43
|
|
|
23
|
-
|
|
44
|
+
## Query Job — Full Lifecycle
|
|
24
45
|
|
|
25
|
-
|
|
46
|
+
Submit a query, poll until complete, and retrieve CSV results:
|
|
26
47
|
|
|
27
48
|
```typescript
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
console.log(ex.response.data[0].errorCode);
|
|
51
|
-
console.log(ex.response.data[0].message);
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
throw 'set environment variable with your orgs username and password'
|
|
55
|
-
}
|
|
49
|
+
import { BulkAPI2, BulkAPI2Connection, QueryInput } from 'node-sf-bulk2';
|
|
50
|
+
|
|
51
|
+
const connection: BulkAPI2Connection = {
|
|
52
|
+
accessToken: '<token>',
|
|
53
|
+
instanceUrl: 'https://yourorg.my.salesforce.com',
|
|
54
|
+
apiVersion: '62.0',
|
|
55
|
+
};
|
|
56
|
+
const bulk = new BulkAPI2(connection);
|
|
57
|
+
|
|
58
|
+
// 1. Submit the query job
|
|
59
|
+
const queryInput: QueryInput = {
|
|
60
|
+
query: 'SELECT Id, Name FROM Account',
|
|
61
|
+
operation: 'query',
|
|
62
|
+
};
|
|
63
|
+
const job = await bulk.submitBulkQueryJob(queryInput);
|
|
64
|
+
console.log('Job created:', job.id);
|
|
65
|
+
|
|
66
|
+
// 2. Poll until complete
|
|
67
|
+
let info = await bulk.getBulkQueryJobInfo(job.id);
|
|
68
|
+
while (info.state !== 'JobComplete' && info.state !== 'Failed') {
|
|
69
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
70
|
+
info = await bulk.getBulkQueryJobInfo(job.id);
|
|
56
71
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### JavaScript example using jsforce for Bulk Query
|
|
61
|
-
|
|
62
|
-
The below code shows how to use the library to submit bulk query request using node.js (uses commonjs modules)
|
|
63
|
-
|
|
64
|
-
```javascript
|
|
65
|
-
const jsforce = require('jsforce');
|
|
66
|
-
const sfbulk = require('node-sf-bulk2');
|
|
67
|
-
|
|
68
|
-
async function submitBulkQueryJob() {
|
|
69
|
-
if (process.env.username && process.env.password) {
|
|
70
|
-
const conn = new jsforce.Connection({});
|
|
71
|
-
await conn.login(process.env.username, process.env.password);
|
|
72
|
-
const bulkconnect = {
|
|
73
|
-
'accessToken': conn.accessToken,
|
|
74
|
-
'apiVersion': '51.0',
|
|
75
|
-
'instanceUrl': conn.instanceUrl
|
|
76
|
-
};
|
|
77
|
-
try {
|
|
78
|
-
const bulkapi2 = new sfbulk.BulkAPI2(bulkconnect);
|
|
79
|
-
const queryInput = {
|
|
80
|
-
'query': 'Select Id from Account',
|
|
81
|
-
'operation': 'query'
|
|
82
|
-
};
|
|
83
|
-
const response = await bulkapi2.submitBulkQueryJob(queryInput);
|
|
84
|
-
console.log(response);
|
|
85
|
-
} catch (ex) {
|
|
86
|
-
console.log(ex);
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
throw 'set environment variable with your orgs username and password'
|
|
90
|
-
}
|
|
72
|
+
|
|
73
|
+
if (info.state === 'Failed') {
|
|
74
|
+
throw new Error('Query job failed');
|
|
91
75
|
}
|
|
92
|
-
|
|
93
|
-
|
|
76
|
+
|
|
77
|
+
// 3. Get results (CSV)
|
|
78
|
+
const response = await bulk.getBulkQueryResults(job.id);
|
|
79
|
+
console.log('Results:\n', response.data);
|
|
80
|
+
|
|
81
|
+
// 4. Clean up
|
|
82
|
+
await bulk.deleteBulkQueryJob(job.id);
|
|
94
83
|
```
|
|
95
84
|
|
|
96
|
-
|
|
85
|
+
For large result sets, page through with `locator` and `maxRecords`:
|
|
97
86
|
|
|
87
|
+
```typescript
|
|
88
|
+
let locator: string | undefined;
|
|
89
|
+
do {
|
|
90
|
+
const response = await bulk.getBulkQueryResults(job.id, locator, 10000);
|
|
91
|
+
console.log(response.data);
|
|
92
|
+
locator = response.headers['sforce-locator'];
|
|
93
|
+
if (locator === 'null') locator = undefined;
|
|
94
|
+
} while (locator);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Ingest Job — Full Lifecycle
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
Create an ingest job, upload CSV data, and retrieve results:
|
|
100
100
|
|
|
101
101
|
```typescript
|
|
102
|
-
import
|
|
103
|
-
import {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
102
|
+
import { BulkAPI2, BulkAPI2Connection, JobUploadRequest } from 'node-sf-bulk2';
|
|
103
|
+
import { readFileSync } from 'fs';
|
|
104
|
+
|
|
105
|
+
const connection: BulkAPI2Connection = {
|
|
106
|
+
accessToken: '<token>',
|
|
107
|
+
instanceUrl: 'https://yourorg.my.salesforce.com',
|
|
108
|
+
apiVersion: '62.0',
|
|
109
|
+
};
|
|
110
|
+
const bulk = new BulkAPI2(connection);
|
|
111
|
+
|
|
112
|
+
// 1. Create the job
|
|
113
|
+
const jobRequest: JobUploadRequest = {
|
|
114
|
+
object: 'Account',
|
|
115
|
+
operation: 'insert',
|
|
116
|
+
};
|
|
117
|
+
const job = await bulk.createDataUploadJob(jobRequest);
|
|
118
|
+
|
|
119
|
+
// 2. Upload CSV data
|
|
120
|
+
const csv = readFileSync('./accounts.csv', 'utf-8');
|
|
121
|
+
await bulk.uploadJobData(job.contentUrl, csv);
|
|
122
|
+
|
|
123
|
+
// 3. Close the job to begin processing
|
|
124
|
+
await bulk.closeOrAbortJob(job.id, 'UploadComplete');
|
|
125
|
+
|
|
126
|
+
// 4. Poll until complete
|
|
127
|
+
let info = await bulk.getIngestJobInfo(job.id);
|
|
128
|
+
while (info.state !== 'JobComplete' && info.state !== 'Failed') {
|
|
129
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
130
|
+
info = await bulk.getIngestJobInfo(job.id);
|
|
117
131
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// read csv data from the local file system
|
|
138
|
-
const data = await promisify(fs.readFile)(process.cwd() + "/account.csv", "UTF-8");
|
|
139
|
-
const status: number = await bulkrequest.uploadJobData(response.contentUrl, data);
|
|
140
|
-
if (status === 201) {
|
|
141
|
-
// close the job for processing
|
|
142
|
-
await bulkrequest.closeOrAbortJob(response.id, STATE[1]);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
} catch (ex) {
|
|
146
|
-
console.log(ex.response.data[0].errorCode);
|
|
147
|
-
console.log(ex.response.data[0].message);
|
|
148
|
-
}
|
|
149
|
-
} else {
|
|
150
|
-
throw 'set environment variable with your orgs username and password'
|
|
151
|
-
}
|
|
152
|
-
})();
|
|
132
|
+
|
|
133
|
+
// 5. Get results
|
|
134
|
+
const successful = await bulk.getResults(job.id, 0); // successfulResults
|
|
135
|
+
const failed = await bulk.getResults(job.id, 1); // failedResults
|
|
136
|
+
console.log('Successful:\n', successful);
|
|
137
|
+
console.log('Failed:\n', failed);
|
|
138
|
+
|
|
139
|
+
// 6. Clean up
|
|
140
|
+
await bulk.deleteIngestJob(job.id);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
You can also create a job and upload data in a single multipart request:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
const csv = readFileSync('./accounts.csv', 'utf-8');
|
|
147
|
+
const job = await bulk.createDataUploadJobWithData(
|
|
148
|
+
{ object: 'Account', operation: 'insert' },
|
|
149
|
+
csv,
|
|
150
|
+
);
|
|
153
151
|
```
|
|
154
152
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
153
|
+
## API Reference
|
|
154
|
+
|
|
155
|
+
### Query Jobs
|
|
156
|
+
|
|
157
|
+
| Method | Description |
|
|
158
|
+
|--------|-------------|
|
|
159
|
+
| `submitBulkQueryJob(query)` | Submit a new query job |
|
|
160
|
+
| `getBulkQueryJobInfo(jobId)` | Get status/info for a query job |
|
|
161
|
+
| `getAllBulkQueryJobInfo(config?)` | List all query jobs (with optional filters) |
|
|
162
|
+
| `getBulkQueryResults(jobId, locator?, maxRecords?)` | Get query results as CSV |
|
|
163
|
+
| `getBulkQueryResultPages(jobId)` | Get result page URLs for parallel download |
|
|
164
|
+
| `abortBulkQueryJob(jobId)` | Abort a query job |
|
|
165
|
+
| `deleteBulkQueryJob(jobId)` | Delete a query job |
|
|
166
|
+
|
|
167
|
+
### Ingest Jobs
|
|
168
|
+
|
|
169
|
+
| Method | Description |
|
|
170
|
+
|--------|-------------|
|
|
171
|
+
| `createDataUploadJob(request)` | Create an ingest job |
|
|
172
|
+
| `createDataUploadJobWithData(request, csv)` | Create an ingest job with CSV data in one request |
|
|
173
|
+
| `uploadJobData(contentUrl, csv)` | Upload CSV data to an open job |
|
|
174
|
+
| `closeOrAbortJob(jobId, state)` | Close (`UploadComplete`) or abort (`Aborted`) a job |
|
|
175
|
+
| `getIngestJobInfo(jobId)` | Get status/info for an ingest job |
|
|
176
|
+
| `getAllIngestJobInfo(config?)` | List all ingest jobs (with optional filters) |
|
|
177
|
+
| `getResults(jobId, resultType)` | Get results — `0` = successful, `1` = failed, `2` = unprocessed |
|
|
178
|
+
| `deleteIngestJob(jobId)` | Delete an ingest job |
|
|
179
|
+
|
|
180
|
+
See the [full API documentation](https://msrivastav13.github.io/node-sf-bulk2/index.html) for details on all request/response types.
|
|
181
|
+
|
|
182
|
+
## Examples
|
|
183
|
+
|
|
184
|
+
The [`examples/`](./examples) directory contains runnable scripts:
|
|
185
|
+
|
|
186
|
+
- **[query-job.ts](./examples/query-job.ts)** — Submit a query, poll, retrieve CSV results
|
|
187
|
+
- **[ingest-job.ts](./examples/ingest-job.ts)** — Create ingest job, upload CSV, poll, retrieve results
|
|
188
|
+
|
|
189
|
+
To run them, set your Salesforce credentials as environment variables:
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
export SF_ACCESS_TOKEN="your-access-token"
|
|
193
|
+
export SF_INSTANCE_URL="https://yourorg.my.salesforce.com"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Then run with `ts-node`:
|
|
197
|
+
|
|
198
|
+
```sh
|
|
199
|
+
npx ts-node examples/query-job.ts
|
|
200
|
+
npx ts-node examples/ingest-job.ts
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Testing
|
|
204
|
+
|
|
205
|
+
```sh
|
|
206
|
+
npm test # run all tests
|
|
207
|
+
npm run test:unit # unit tests only (mocked, no org needed)
|
|
208
|
+
npm run test:watch # watch mode
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Integration tests require a Salesforce org:
|
|
212
|
+
|
|
213
|
+
```sh
|
|
214
|
+
SF_ACCESS_TOKEN="..." SF_INSTANCE_URL="..." npm run test:integration
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
ISC
|
package/dist/bulk2.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ import { JobUploadRequest } from './model/jobUploadRequest';
|
|
|
9
9
|
import { JobUploadResponse } from './model/jobUploadResponse';
|
|
10
10
|
import { JobInfoResponse } from './model/jobInfoResponse';
|
|
11
11
|
import { RESULTTYPE } from './model/enum';
|
|
12
|
+
import { IngestJobConfig } from './model/ingestJobConfig';
|
|
13
|
+
import { AllIngestJobsInfoResponse } from './model/allIngestJobsInfoResponse';
|
|
14
|
+
import { ParallelQueryResultsResponse } from './model/parallelQueryResultsResponse';
|
|
12
15
|
export default class BulkAPI2 {
|
|
13
16
|
private connection;
|
|
14
17
|
private endpoint;
|
|
@@ -24,4 +27,9 @@ export default class BulkAPI2 {
|
|
|
24
27
|
closeOrAbortJob(jobId: string, state: string): Promise<JobUploadResponse>;
|
|
25
28
|
getIngestJobInfo(jobId: string): Promise<JobInfoResponse>;
|
|
26
29
|
getResults(jobId: string, resulttype: RESULTTYPE): Promise<string>;
|
|
30
|
+
deleteIngestJob(jobId: string): Promise<void>;
|
|
31
|
+
deleteBulkQueryJob(jobId: string): Promise<void>;
|
|
32
|
+
getAllIngestJobInfo(configInput?: IngestJobConfig): Promise<AllIngestJobsInfoResponse>;
|
|
33
|
+
getBulkQueryResultPages(jobId: string): Promise<ParallelQueryResultsResponse>;
|
|
34
|
+
createDataUploadJobWithData(jobUploadRequest: JobUploadRequest, csvData: string): Promise<JobUploadResponse>;
|
|
27
35
|
}
|
package/dist/bulk2.js
CHANGED
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
const enum_1 = require("./model/enum");
|
|
16
17
|
class BulkAPI2 {
|
|
17
18
|
constructor(connection) {
|
|
18
19
|
this.connection = connection;
|
|
@@ -28,9 +29,23 @@ class BulkAPI2 {
|
|
|
28
29
|
Authorization: 'Bearer ' + this.connection.accessToken,
|
|
29
30
|
accept: accept
|
|
30
31
|
};
|
|
32
|
+
if (this.connection.callOptions) {
|
|
33
|
+
const parts = [];
|
|
34
|
+
if (this.connection.callOptions.client) {
|
|
35
|
+
parts.push('client=' + this.connection.callOptions.client);
|
|
36
|
+
}
|
|
37
|
+
if (this.connection.callOptions.defaultNamespace) {
|
|
38
|
+
parts.push('defaultNamespace=' + this.connection.callOptions.defaultNamespace);
|
|
39
|
+
}
|
|
40
|
+
if (parts.length > 0) {
|
|
41
|
+
headers['Sforce-Call-Options'] = parts.join(', ');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
31
44
|
const requestConfig = {
|
|
32
45
|
headers
|
|
33
46
|
};
|
|
47
|
+
requestConfig.maxBodyLength = Infinity;
|
|
48
|
+
requestConfig.maxContentLength = Infinity;
|
|
34
49
|
return requestConfig;
|
|
35
50
|
}
|
|
36
51
|
submitBulkQueryJob(query) {
|
|
@@ -144,12 +159,75 @@ class BulkAPI2 {
|
|
|
144
159
|
}
|
|
145
160
|
getResults(jobId, resulttype) {
|
|
146
161
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
const endpoint = this.endpoint + '/ingest/' + jobId + '/' + resulttype;
|
|
162
|
+
const endpoint = this.endpoint + '/ingest/' + jobId + '/' + enum_1.RESULTTYPE[resulttype];
|
|
148
163
|
const requestConfig = this.getRequestConfig('application/json', 'text/csv');
|
|
149
164
|
const axiosresponse = yield axios_1.default.get(endpoint, requestConfig);
|
|
150
165
|
return axiosresponse.data;
|
|
151
166
|
});
|
|
152
167
|
}
|
|
168
|
+
deleteIngestJob(jobId) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
const endpoint = this.endpoint + '/ingest/' + jobId;
|
|
171
|
+
const requestConfig = this.getRequestConfig('application/json', 'application/json');
|
|
172
|
+
yield axios_1.default.delete(endpoint, requestConfig);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
deleteBulkQueryJob(jobId) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
const endpoint = this.endpoint + '/query/' + jobId;
|
|
178
|
+
const requestConfig = this.getRequestConfig('application/json', 'application/json');
|
|
179
|
+
yield axios_1.default.delete(endpoint, requestConfig);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
getAllIngestJobInfo(configInput) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
let endpoint = this.endpoint + '/ingest';
|
|
185
|
+
if (configInput && Object.keys(configInput).length > 0) {
|
|
186
|
+
endpoint += '/?';
|
|
187
|
+
let i = 0;
|
|
188
|
+
let key;
|
|
189
|
+
for (key in configInput) {
|
|
190
|
+
endpoint += key + '=' + configInput[key];
|
|
191
|
+
if (i < (Object.keys(configInput).length - 1)) {
|
|
192
|
+
endpoint += '&';
|
|
193
|
+
}
|
|
194
|
+
i++;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const requestConfig = this.getRequestConfig('application/json', 'application/json');
|
|
198
|
+
const axiosresponse = yield axios_1.default.get(endpoint, requestConfig);
|
|
199
|
+
const response = axiosresponse.data;
|
|
200
|
+
return response;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
getBulkQueryResultPages(jobId) {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
const endpoint = this.endpoint + '/query/' + jobId + '/resultPages';
|
|
206
|
+
const requestConfig = this.getRequestConfig('application/json', 'application/json');
|
|
207
|
+
const axiosresponse = yield axios_1.default.get(endpoint, requestConfig);
|
|
208
|
+
const response = axiosresponse.data;
|
|
209
|
+
return response;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
createDataUploadJobWithData(jobUploadRequest, csvData) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
const endpoint = this.endpoint + '/ingest';
|
|
215
|
+
const boundary = '----BulkAPI2Boundary' + Date.now();
|
|
216
|
+
const body = '--' + boundary + '\r\n' +
|
|
217
|
+
'Content-Type: application/json\r\n' +
|
|
218
|
+
'Content-Disposition: form-data; name="job"\r\n\r\n' +
|
|
219
|
+
JSON.stringify(jobUploadRequest) + '\r\n' +
|
|
220
|
+
'--' + boundary + '\r\n' +
|
|
221
|
+
'Content-Type: text/csv\r\n' +
|
|
222
|
+
'Content-Disposition: form-data; name="content"; filename="content"\r\n\r\n' +
|
|
223
|
+
csvData + '\r\n' +
|
|
224
|
+
'--' + boundary + '--';
|
|
225
|
+
const requestConfig = this.getRequestConfig('multipart/form-data; boundary=' + boundary, 'application/json');
|
|
226
|
+
const axiosresponse = yield axios_1.default.post(endpoint, body, requestConfig);
|
|
227
|
+
const jobuploadresponse = axiosresponse.data;
|
|
228
|
+
return jobuploadresponse;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
153
231
|
}
|
|
154
232
|
exports.default = BulkAPI2;
|
|
155
233
|
//# sourceMappingURL=bulk2.js.map
|
package/dist/bulk2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk2.js","sourceRoot":"","sources":["../src/bulk2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,kDAAiE;
|
|
1
|
+
{"version":3,"file":"bulk2.js","sourceRoot":"","sources":["../src/bulk2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,kDAAiE;AASjE,uCAAyC;AAKzC,MAAqB,QAAQ;IAKzB,YAAY,UAAsB;QAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,WAAW,GAAG,kBAAkB,GAAG,UAAU,CAAC,UAAU,CAAC;QACpF,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;YAC5B,IAAI,CAAC,QAAQ,IAAI,UAAU,CAAA;QAC/B,CAAC;QACD,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC;IAC7B,CAAC;IAEO,gBAAgB,CAAC,WAAmB,EAAE,MAAe;QACzD,MAAM,OAAO,GAAuC;YAChD,cAAc,EAAE,WAAW;YAC3B,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW;YACtD,MAAM,EAAE,MAAM;SACjB,CAAC;QACF,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAa,EAAE,CAAC;YAC3B,IAAI,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;gBACrC,KAAK,CAAC,IAAI,CAAC,SAAS,G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AAG,QAAQ,GAAG,MAAM;gBACxB,oCAAoC;gBACpC,oDAAoD;gBACpD,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,MAAM;gBACzC,IAAI,GAAG,QAAQ,GAAG,MAAM;gBACxB,4BAA4B;gBAC5B,4EAA4E;gBAC5E,OAAO,GAAG,MAAM;gBAChB,IAAI,GAAG,QAAQ,GAAG,IAAI,CAAC;YAC3B,MAAM,aAAa,GAAuB,IAAI,CAAC,gBAAgB,CAC3D,gCAAgC,GAAG,QAAQ,EAC3C,kBAAkB,CACrB,CAAC;YACF,MAAM,aAAa,GAAkB,MAAM,eAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;YACrF,MAAM,iBAAiB,GAAsB,aAAa,CAAC,IAAI,CAAC;YAChE,OAAO,iBAAiB,CAAC;QAC7B,CAAC;KAAA;CACJ;AA/MD,2BA+MC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { AllBulkQueryJobsInfoResponse } from "./model/allBulkQueryJobsInfoResponse";
|
|
2
|
+
import { AllIngestJobsInfoResponse } from "./model/allIngestJobsInfoResponse";
|
|
2
3
|
import { BulkJobInfoResponse } from "./model/bulkJobInfoResponse";
|
|
3
4
|
import { BulkQueryResponse } from "./model/queryResponse";
|
|
4
5
|
import { BulkQueryConfig } from "./model/bulkQueryConfig";
|
|
5
6
|
import { Connection } from "./model/connection";
|
|
6
|
-
import { CONTENTTYPE, COLUMNDELIMITER, LINEENDING, OPERATION, STATE, RESULTTYPE } from "./model/enum";
|
|
7
|
+
import { CONTENTTYPE, COLUMNDELIMITER, LINEENDING, OPERATION, STATE, RESULTTYPE, JOBTYPE } from "./model/enum";
|
|
8
|
+
import { IngestJobConfig } from "./model/ingestJobConfig";
|
|
7
9
|
import { QueryInput } from "./model/queryInput";
|
|
8
10
|
import { JobUploadRequest } from "./model/jobUploadRequest";
|
|
9
11
|
import { JobUploadResponse } from "./model/jobUploadResponse";
|
|
10
12
|
import { JobInfoResponse } from "./model/jobInfoResponse";
|
|
11
|
-
|
|
13
|
+
import { ResultPage, ParallelQueryResultsResponse } from "./model/parallelQueryResultsResponse";
|
|
14
|
+
export { AllBulkQueryJobsInfoResponse, AllIngestJobsInfoResponse, BulkJobInfoResponse, BulkQueryResponse, BulkQueryConfig, Connection as BulkAPI2Connection, CONTENTTYPE, COLUMNDELIMITER, IngestJobConfig, JobUploadRequest, JobUploadResponse, JobInfoResponse, JOBTYPE, LINEENDING, OPERATION, ParallelQueryResultsResponse, QueryInput, ResultPage, RESULTTYPE, STATE };
|
|
12
15
|
export { default as BulkAPI2 } from './bulk2';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.BulkAPI2 = exports.STATE = exports.RESULTTYPE = exports.OPERATION = exports.LINEENDING = exports.COLUMNDELIMITER = exports.CONTENTTYPE = void 0;
|
|
6
|
+
exports.BulkAPI2 = exports.STATE = exports.RESULTTYPE = exports.OPERATION = exports.LINEENDING = exports.JOBTYPE = exports.COLUMNDELIMITER = exports.CONTENTTYPE = void 0;
|
|
7
7
|
const enum_1 = require("./model/enum");
|
|
8
8
|
Object.defineProperty(exports, "CONTENTTYPE", { enumerable: true, get: function () { return enum_1.CONTENTTYPE; } });
|
|
9
9
|
Object.defineProperty(exports, "COLUMNDELIMITER", { enumerable: true, get: function () { return enum_1.COLUMNDELIMITER; } });
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "LINEENDING", { enumerable: true, get: function (
|
|
|
11
11
|
Object.defineProperty(exports, "OPERATION", { enumerable: true, get: function () { return enum_1.OPERATION; } });
|
|
12
12
|
Object.defineProperty(exports, "STATE", { enumerable: true, get: function () { return enum_1.STATE; } });
|
|
13
13
|
Object.defineProperty(exports, "RESULTTYPE", { enumerable: true, get: function () { return enum_1.RESULTTYPE; } });
|
|
14
|
+
Object.defineProperty(exports, "JOBTYPE", { enumerable: true, get: function () { return enum_1.JOBTYPE; } });
|
|
14
15
|
var bulk2_1 = require("./bulk2");
|
|
15
16
|
Object.defineProperty(exports, "BulkAPI2", { enumerable: true, get: function () { return __importDefault(bulk2_1).default; } });
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAMA,uCAA+G;AAe7G,4FAfO,kBAAW,OAeP;AACX,gGAhBoB,sBAAe,OAgBpB;AAMf,2FAtBqC,iBAAU,OAsBrC;AACV,0FAvBiD,gBAAS,OAuBjD;AAKT,sFA5B4D,YAAK,OA4B5D;AADL,2FA3BmE,iBAAU,OA2BnE;AANV,wFArB+E,cAAO,OAqB/E;AAUT,iCAA6C;AAApC,kHAAA,OAAO,OAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allIngestJobsInfoResponse.js","sourceRoot":"","sources":["../../src/model/allIngestJobsInfoResponse.ts"],"names":[],"mappings":""}
|
package/dist/model/enum.d.ts
CHANGED
|
@@ -18,17 +18,26 @@ export declare enum OPERATION {
|
|
|
18
18
|
"delete" = 1,
|
|
19
19
|
"hardDelete" = 2,
|
|
20
20
|
"update" = 3,
|
|
21
|
-
"upsert" = 4
|
|
21
|
+
"upsert" = 4,
|
|
22
|
+
"query" = 5,
|
|
23
|
+
"queryAll" = 6
|
|
22
24
|
}
|
|
23
25
|
export declare enum STATE {
|
|
24
26
|
"Open" = 0,
|
|
25
27
|
"UploadComplete" = 1,
|
|
26
28
|
"Aborted" = 2,
|
|
27
29
|
"JobComplete" = 3,
|
|
28
|
-
"Failed" = 4
|
|
30
|
+
"Failed" = 4,
|
|
31
|
+
"InProgress" = 5
|
|
29
32
|
}
|
|
30
33
|
export declare enum RESULTTYPE {
|
|
31
34
|
"successfulResults" = 0,
|
|
32
35
|
"failedResults" = 1,
|
|
33
36
|
"unprocessedrecords" = 2
|
|
34
37
|
}
|
|
38
|
+
export declare enum JOBTYPE {
|
|
39
|
+
"BigObjectIngest" = 0,
|
|
40
|
+
"Classic" = 1,
|
|
41
|
+
"V2Ingest" = 2,
|
|
42
|
+
"V2Query" = 3
|
|
43
|
+
}
|
package/dist/model/enum.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RESULTTYPE = exports.STATE = exports.OPERATION = exports.LINEENDING = exports.COLUMNDELIMITER = exports.CONTENTTYPE = void 0;
|
|
3
|
+
exports.JOBTYPE = exports.RESULTTYPE = exports.STATE = exports.OPERATION = exports.LINEENDING = exports.COLUMNDELIMITER = exports.CONTENTTYPE = void 0;
|
|
4
4
|
var CONTENTTYPE;
|
|
5
5
|
(function (CONTENTTYPE) {
|
|
6
6
|
CONTENTTYPE[CONTENTTYPE["CSV"] = 0] = "CSV";
|
|
7
|
-
})(CONTENTTYPE
|
|
7
|
+
})(CONTENTTYPE || (exports.CONTENTTYPE = CONTENTTYPE = {}));
|
|
8
8
|
var COLUMNDELIMITER;
|
|
9
9
|
(function (COLUMNDELIMITER) {
|
|
10
10
|
COLUMNDELIMITER[COLUMNDELIMITER["BACKQUOTE"] = 0] = "BACKQUOTE";
|
|
@@ -13,12 +13,12 @@ var COLUMNDELIMITER;
|
|
|
13
13
|
COLUMNDELIMITER[COLUMNDELIMITER["PIPE"] = 3] = "PIPE";
|
|
14
14
|
COLUMNDELIMITER[COLUMNDELIMITER["SEMICOLON"] = 4] = "SEMICOLON";
|
|
15
15
|
COLUMNDELIMITER[COLUMNDELIMITER["TAB"] = 5] = "TAB";
|
|
16
|
-
})(COLUMNDELIMITER
|
|
16
|
+
})(COLUMNDELIMITER || (exports.COLUMNDELIMITER = COLUMNDELIMITER = {}));
|
|
17
17
|
var LINEENDING;
|
|
18
18
|
(function (LINEENDING) {
|
|
19
19
|
LINEENDING[LINEENDING["LF"] = 0] = "LF";
|
|
20
20
|
LINEENDING[LINEENDING["CRLF"] = 1] = "CRLF";
|
|
21
|
-
})(LINEENDING
|
|
21
|
+
})(LINEENDING || (exports.LINEENDING = LINEENDING = {}));
|
|
22
22
|
var OPERATION;
|
|
23
23
|
(function (OPERATION) {
|
|
24
24
|
OPERATION[OPERATION["insert"] = 0] = "insert";
|
|
@@ -26,7 +26,9 @@ var OPERATION;
|
|
|
26
26
|
OPERATION[OPERATION["hardDelete"] = 2] = "hardDelete";
|
|
27
27
|
OPERATION[OPERATION["update"] = 3] = "update";
|
|
28
28
|
OPERATION[OPERATION["upsert"] = 4] = "upsert";
|
|
29
|
-
|
|
29
|
+
OPERATION[OPERATION["query"] = 5] = "query";
|
|
30
|
+
OPERATION[OPERATION["queryAll"] = 6] = "queryAll";
|
|
31
|
+
})(OPERATION || (exports.OPERATION = OPERATION = {}));
|
|
30
32
|
var STATE;
|
|
31
33
|
(function (STATE) {
|
|
32
34
|
STATE[STATE["Open"] = 0] = "Open";
|
|
@@ -34,11 +36,19 @@ var STATE;
|
|
|
34
36
|
STATE[STATE["Aborted"] = 2] = "Aborted";
|
|
35
37
|
STATE[STATE["JobComplete"] = 3] = "JobComplete";
|
|
36
38
|
STATE[STATE["Failed"] = 4] = "Failed";
|
|
37
|
-
|
|
39
|
+
STATE[STATE["InProgress"] = 5] = "InProgress";
|
|
40
|
+
})(STATE || (exports.STATE = STATE = {}));
|
|
38
41
|
var RESULTTYPE;
|
|
39
42
|
(function (RESULTTYPE) {
|
|
40
43
|
RESULTTYPE[RESULTTYPE["successfulResults"] = 0] = "successfulResults";
|
|
41
44
|
RESULTTYPE[RESULTTYPE["failedResults"] = 1] = "failedResults";
|
|
42
45
|
RESULTTYPE[RESULTTYPE["unprocessedrecords"] = 2] = "unprocessedrecords";
|
|
43
|
-
})(RESULTTYPE
|
|
46
|
+
})(RESULTTYPE || (exports.RESULTTYPE = RESULTTYPE = {}));
|
|
47
|
+
var JOBTYPE;
|
|
48
|
+
(function (JOBTYPE) {
|
|
49
|
+
JOBTYPE[JOBTYPE["BigObjectIngest"] = 0] = "BigObjectIngest";
|
|
50
|
+
JOBTYPE[JOBTYPE["Classic"] = 1] = "Classic";
|
|
51
|
+
JOBTYPE[JOBTYPE["V2Ingest"] = 2] = "V2Ingest";
|
|
52
|
+
JOBTYPE[JOBTYPE["V2Query"] = 3] = "V2Query";
|
|
53
|
+
})(JOBTYPE || (exports.JOBTYPE = JOBTYPE = {}));
|
|
44
54
|
//# sourceMappingURL=enum.js.map
|
package/dist/model/enum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/model/enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAEX;AAFD,WAAY,WAAW;IACnB,2CAAK,CAAA;AACT,CAAC,EAFW,WAAW,
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/model/enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAEX;AAFD,WAAY,WAAW;IACnB,2CAAK,CAAA;AACT,CAAC,EAFW,WAAW,2BAAX,WAAW,QAEtB;AAED,IAAY,eAOX;AAPD,WAAY,eAAe;IACvB,+DAAW,CAAA;IACX,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,qDAAM,CAAA;IACN,+DAAW,CAAA;IACX,mDAAK,CAAA;AACT,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,uCAAI,CAAA;IACJ,2CAAM,CAAA;AACV,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,SAQX;AARD,WAAY,SAAS;IACjB,6CAAQ,CAAA;IACR,6CAAQ,CAAA;IACR,qDAAY,CAAA;IACZ,6CAAQ,CAAA;IACR,6CAAQ,CAAA;IACR,2CAAO,CAAA;IACP,iDAAU,CAAA;AACd,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB;AAED,IAAY,KAOX;AAPD,WAAY,KAAK;IACb,iCAAM,CAAA;IACN,qDAAgB,CAAA;IAChB,uCAAS,CAAA;IACT,+CAAa,CAAA;IACb,qCAAQ,CAAA;IACR,6CAAY,CAAA;AAChB,CAAC,EAPW,KAAK,qBAAL,KAAK,QAOhB;AAED,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,qEAAmB,CAAA;IACnB,6DAAe,CAAA;IACf,uEAAoB,CAAA;AACxB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB;AAED,IAAY,OAKX;AALD,WAAY,OAAO;IACf,2DAAiB,CAAA;IACjB,2CAAS,CAAA;IACT,6CAAU,CAAA;IACV,2CAAS,CAAA;AACb,CAAC,EALW,OAAO,uBAAP,OAAO,QAKlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingestJobConfig.js","sourceRoot":"","sources":["../../src/model/ingestJobConfig.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelQueryResultsResponse.js","sourceRoot":"","sources":["../../src/model/parallelQueryResultsResponse.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-sf-bulk2",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Node.js implementation of Salesforce Bulk API 2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"start:dev": "nodemon",
|
|
8
9
|
"build": "rimraf ./dist && tsc",
|
|
9
|
-
"test": "
|
|
10
|
-
"
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:unit": "vitest run src/__tests__/bulk2.unit.test.ts",
|
|
12
|
+
"test:integration": "vitest run src/__tests__/bulk2.integration.test.ts",
|
|
13
|
+
"test:watch": "vitest",
|
|
14
|
+
"eslint": "eslint src/**",
|
|
15
|
+
"prepublishOnly": "npm run build && npm run test:unit"
|
|
11
16
|
},
|
|
12
17
|
"author": "",
|
|
13
18
|
"license": "ISC",
|
|
14
19
|
"devDependencies": {
|
|
15
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
16
|
-
"@typescript-eslint/parser": "^
|
|
17
|
-
"eslint": "^
|
|
18
|
-
"nodemon": "^
|
|
19
|
-
"rimraf": "^
|
|
20
|
-
"ts-node": "^9.
|
|
21
|
-
"typedoc": "^0.
|
|
22
|
-
"typescript": "
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
21
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
22
|
+
"eslint": "^9.0.0",
|
|
23
|
+
"nodemon": "^3.1.0",
|
|
24
|
+
"rimraf": "^6.0.0",
|
|
25
|
+
"ts-node": "^10.9.0",
|
|
26
|
+
"typedoc": "^0.28.0",
|
|
27
|
+
"typescript": "~5.8.0",
|
|
28
|
+
"vitest": "^4.1.5"
|
|
23
29
|
},
|
|
24
30
|
"dependencies": {
|
|
25
|
-
"axios": "^
|
|
31
|
+
"axios": "^1.15.0"
|
|
26
32
|
}
|
|
27
33
|
}
|
package/.eslintrc.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2015",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"sourceMap": true,
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
},
|
|
14
|
-
"include": ["src/**/*"],
|
|
15
|
-
"exclude": ["node_modules"],
|
|
16
|
-
"typedocOptions": {
|
|
17
|
-
"entryPoints": ["src/index.ts"],
|
|
18
|
-
"out": "docs"
|
|
19
|
-
}
|
|
20
|
-
}
|