@jsforce/jsforce-node 0.0.1 → 3.0.0-next.2

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.
Files changed (131) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +54 -0
  3. package/index.d.ts +4 -0
  4. package/index.js +1 -0
  5. package/lib/VERSION.d.ts +2 -0
  6. package/lib/VERSION.js +3 -0
  7. package/lib/api/analytics/types.d.ts +509 -0
  8. package/lib/api/analytics/types.js +2 -0
  9. package/lib/api/analytics.d.ts +163 -0
  10. package/lib/api/analytics.js +342 -0
  11. package/lib/api/apex.d.ts +44 -0
  12. package/lib/api/apex.js +86 -0
  13. package/lib/api/bulk.d.ts +253 -0
  14. package/lib/api/bulk.js +678 -0
  15. package/lib/api/bulk2.d.ts +324 -0
  16. package/lib/api/bulk2.js +800 -0
  17. package/lib/api/chatter.d.ts +133 -0
  18. package/lib/api/chatter.js +248 -0
  19. package/lib/api/metadata/schema.d.ts +16117 -0
  20. package/lib/api/metadata/schema.js +9094 -0
  21. package/lib/api/metadata.d.ts +189 -0
  22. package/lib/api/metadata.js +406 -0
  23. package/lib/api/soap/schema.d.ts +3167 -0
  24. package/lib/api/soap/schema.js +1787 -0
  25. package/lib/api/soap.d.ts +76 -0
  26. package/lib/api/soap.js +155 -0
  27. package/lib/api/streaming/extension.d.ts +94 -0
  28. package/lib/api/streaming/extension.js +151 -0
  29. package/lib/api/streaming.d.ts +160 -0
  30. package/lib/api/streaming.js +252 -0
  31. package/lib/api/tooling.d.ts +284 -0
  32. package/lib/api/tooling.js +202 -0
  33. package/lib/api/wsdl/wsdl2schema.d.ts +1 -0
  34. package/lib/api/wsdl/wsdl2schema.js +354 -0
  35. package/lib/browser/canvas.d.ts +12 -0
  36. package/lib/browser/canvas.js +77 -0
  37. package/lib/browser/client.d.ts +82 -0
  38. package/lib/browser/client.js +244 -0
  39. package/lib/browser/jsonp.d.ts +12 -0
  40. package/lib/browser/jsonp.js +69 -0
  41. package/lib/browser/registry.d.ts +3 -0
  42. package/lib/browser/registry.js +5 -0
  43. package/lib/browser/request.d.ts +10 -0
  44. package/lib/browser/request.js +202 -0
  45. package/lib/cache.d.ts +74 -0
  46. package/lib/cache.js +159 -0
  47. package/lib/connection.d.ts +356 -0
  48. package/lib/connection.js +1153 -0
  49. package/lib/core.d.ts +17 -0
  50. package/lib/core.js +55 -0
  51. package/lib/csv.d.ts +23 -0
  52. package/lib/csv.js +35 -0
  53. package/lib/date.d.ts +82 -0
  54. package/lib/date.js +201 -0
  55. package/lib/http-api.d.ts +75 -0
  56. package/lib/http-api.js +295 -0
  57. package/lib/index.d.ts +13 -0
  58. package/lib/index.js +32 -0
  59. package/lib/jsforce.d.ts +26 -0
  60. package/lib/jsforce.js +67 -0
  61. package/lib/jwtOAuth2.d.ts +8 -0
  62. package/lib/jwtOAuth2.js +23 -0
  63. package/lib/oauth2.d.ts +92 -0
  64. package/lib/oauth2.js +245 -0
  65. package/lib/process.d.ts +157 -0
  66. package/lib/process.js +143 -0
  67. package/lib/query.d.ts +341 -0
  68. package/lib/query.js +817 -0
  69. package/lib/quick-action.d.ts +44 -0
  70. package/lib/quick-action.js +46 -0
  71. package/lib/record-reference.d.ts +46 -0
  72. package/lib/record-reference.js +65 -0
  73. package/lib/record-stream.d.ts +83 -0
  74. package/lib/record-stream.js +233 -0
  75. package/lib/registry/base.d.ts +43 -0
  76. package/lib/registry/base.js +96 -0
  77. package/lib/registry/empty.d.ts +7 -0
  78. package/lib/registry/empty.js +13 -0
  79. package/lib/registry/file.d.ts +11 -0
  80. package/lib/registry/file.js +51 -0
  81. package/lib/registry/index.d.ts +8 -0
  82. package/lib/registry/index.js +21 -0
  83. package/lib/registry/sfdx.d.ts +56 -0
  84. package/lib/registry/sfdx.js +133 -0
  85. package/lib/registry/types.d.ts +47 -0
  86. package/lib/registry/types.js +2 -0
  87. package/lib/request-helper.d.ts +23 -0
  88. package/lib/request-helper.js +102 -0
  89. package/lib/request.d.ts +11 -0
  90. package/lib/request.js +75 -0
  91. package/lib/session-refresh-delegate.d.ts +31 -0
  92. package/lib/session-refresh-delegate.js +69 -0
  93. package/lib/soap.d.ts +60 -0
  94. package/lib/soap.js +257 -0
  95. package/lib/sobject.d.ts +258 -0
  96. package/lib/sobject.js +376 -0
  97. package/lib/soql-builder.d.ts +25 -0
  98. package/lib/soql-builder.js +226 -0
  99. package/lib/transport.d.ts +63 -0
  100. package/lib/transport.js +175 -0
  101. package/lib/types/common.d.ts +560 -0
  102. package/lib/types/common.js +2 -0
  103. package/lib/types/index.d.ts +7 -0
  104. package/lib/types/index.js +23 -0
  105. package/lib/types/projection.d.ts +26 -0
  106. package/lib/types/projection.js +2 -0
  107. package/lib/types/record.d.ts +44 -0
  108. package/lib/types/record.js +2 -0
  109. package/lib/types/schema.d.ts +50 -0
  110. package/lib/types/schema.js +2 -0
  111. package/lib/types/soap.d.ts +43 -0
  112. package/lib/types/soap.js +2 -0
  113. package/lib/types/standard-schema.d.ts +16199 -0
  114. package/lib/types/standard-schema.js +2 -0
  115. package/lib/types/util.d.ts +7 -0
  116. package/lib/types/util.js +2 -0
  117. package/lib/util/formatter.d.ts +8 -0
  118. package/lib/util/formatter.js +24 -0
  119. package/lib/util/function.d.ts +32 -0
  120. package/lib/util/function.js +52 -0
  121. package/lib/util/get-body-size.d.ts +4 -0
  122. package/lib/util/get-body-size.js +39 -0
  123. package/lib/util/logger.d.ts +29 -0
  124. package/lib/util/logger.js +102 -0
  125. package/lib/util/promise.d.ts +19 -0
  126. package/lib/util/promise.js +25 -0
  127. package/lib/util/stream.d.ts +12 -0
  128. package/lib/util/stream.js +88 -0
  129. package/package.json +262 -6
  130. package/typings/faye/index.d.ts +16 -0
  131. package/typings/index.d.ts +1 -0
@@ -0,0 +1,253 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /**
5
+ * @file Manages Salesforce Bulk API related operations
6
+ * @author Shinichi Tomita <shinichi.tomita@gmail.com>
7
+ */
8
+ import { EventEmitter } from 'events';
9
+ import { Duplex, Readable, Writable } from 'stream';
10
+ import Connection from '../connection';
11
+ import { Serializable, Parsable } from '../record-stream';
12
+ import { Logger } from '../util/logger';
13
+ import { HttpMethods, Record, Schema } from '../types';
14
+ export type BulkOperation = 'insert' | 'update' | 'upsert' | 'delete' | 'hardDelete' | 'query' | 'queryAll';
15
+ export type BulkOptions = {
16
+ extIdField?: string;
17
+ concurrencyMode?: 'Serial' | 'Parallel';
18
+ assignmentRuleId?: string;
19
+ };
20
+ export type JobState = 'Open' | 'Closed' | 'Aborted' | 'Failed' | 'Unknown';
21
+ export type JobInfo = {
22
+ id: string;
23
+ object: string;
24
+ operation: BulkOperation;
25
+ state: JobState;
26
+ };
27
+ export type BatchState = 'Queued' | 'InProgress' | 'Completed' | 'Failed' | 'NotProcessed';
28
+ export type BatchInfo = {
29
+ id: string;
30
+ jobId: string;
31
+ state: BatchState;
32
+ stateMessage: string;
33
+ numberRecordsProcessed: string;
34
+ numberRecordsFailed: string;
35
+ totalProcessingTime: string;
36
+ };
37
+ export type BulkQueryBatchResult = Array<{
38
+ id: string;
39
+ batchId: string;
40
+ jobId: string;
41
+ }>;
42
+ export type BulkIngestBatchResult = Array<{
43
+ id: string | null;
44
+ success: boolean;
45
+ errors: string[];
46
+ }>;
47
+ export type BatchResult<Opr extends BulkOperation> = Opr extends 'query' | 'queryAll' ? BulkQueryBatchResult : BulkIngestBatchResult;
48
+ export type BulkRequest = {
49
+ method: HttpMethods;
50
+ path?: string;
51
+ body?: string;
52
+ headers?: {
53
+ [name: string]: string;
54
+ };
55
+ responseType?: string;
56
+ };
57
+ /**
58
+ * Class for Bulk API Job
59
+ */
60
+ export declare class Job<S extends Schema, Opr extends BulkOperation> extends EventEmitter {
61
+ type: string | null;
62
+ operation: Opr | null;
63
+ options: BulkOptions;
64
+ id: string | null;
65
+ state: JobState;
66
+ _bulk: Bulk<S>;
67
+ _batches: {
68
+ [id: string]: Batch<S, Opr>;
69
+ };
70
+ _jobInfo: Promise<JobInfo> | undefined;
71
+ _error: Error | undefined;
72
+ /**
73
+ *
74
+ */
75
+ constructor(bulk: Bulk<S>, type: string | null, operation: Opr | null, options: BulkOptions | null, jobId?: string);
76
+ /**
77
+ * Return latest jobInfo from cache
78
+ */
79
+ info(): Promise<JobInfo>;
80
+ /**
81
+ * Open new job and get jobinfo
82
+ */
83
+ open(): Promise<JobInfo>;
84
+ /**
85
+ * Create a new batch instance in the job
86
+ */
87
+ createBatch(): Batch<S, Opr>;
88
+ /**
89
+ * Get a batch instance specified by given batch ID
90
+ */
91
+ batch(batchId: string): Batch<S, Opr>;
92
+ /**
93
+ * Check the latest job status from server
94
+ */
95
+ check(): Promise<JobInfo>;
96
+ /**
97
+ * Wait till the job is assigned to server
98
+ */
99
+ ready(): Promise<string>;
100
+ /**
101
+ * List all registered batch info in job
102
+ */
103
+ list(): Promise<BatchInfo[]>;
104
+ /**
105
+ * Close opened job
106
+ */
107
+ close(): Promise<JobInfo | undefined>;
108
+ /**
109
+ * Set the status to abort
110
+ */
111
+ abort(): Promise<JobInfo | undefined>;
112
+ /**
113
+ * @private
114
+ */
115
+ _changeState(state: JobState): Promise<JobInfo>;
116
+ }
117
+ /**
118
+ * Batch (extends Writable)
119
+ */
120
+ export declare class Batch<S extends Schema, Opr extends BulkOperation> extends Writable {
121
+ job: Job<S, Opr>;
122
+ id: string | undefined;
123
+ _bulk: Bulk<S>;
124
+ _uploadStream: Serializable;
125
+ _downloadStream: Parsable;
126
+ _dataStream: Duplex;
127
+ _result: Promise<BatchResult<Opr>> | undefined;
128
+ _error: Error | undefined;
129
+ /**
130
+ *
131
+ */
132
+ constructor(job: Job<S, Opr>, id?: string);
133
+ /**
134
+ * Connect batch API and create stream instance of request/response
135
+ *
136
+ * @private
137
+ */
138
+ _createRequestStream(): Duplex;
139
+ /**
140
+ * Implementation of Writable
141
+ */
142
+ _write(record_: Record, enc: BufferEncoding, cb: () => void): void;
143
+ /**
144
+ * Returns duplex stream which accepts CSV data input and batch result output
145
+ */
146
+ stream(): Duplex;
147
+ /**
148
+ * Execute batch operation
149
+ */
150
+ execute(input?: string | Record[] | Readable): this;
151
+ run: (input?: string | Record[] | Readable) => this;
152
+ exec: (input?: string | Record[] | Readable) => this;
153
+ /**
154
+ * Promise/A+ interface
155
+ * Delegate to promise, return promise instance for batch result
156
+ */
157
+ then(onResolved: (res: BatchResult<Opr>) => void, onReject: (err: any) => void): Promise<void>;
158
+ /**
159
+ * Check the latest batch status in server
160
+ */
161
+ check(): Promise<BatchInfo>;
162
+ /**
163
+ * Polling the batch result and retrieve
164
+ */
165
+ poll(interval: number, timeout: number): void;
166
+ /**
167
+ * Retrieve batch result
168
+ */
169
+ retrieve(): Promise<BulkQueryBatchResult | BulkIngestBatchResult>;
170
+ /**
171
+ * Fetch query batch result as a record stream
172
+ *
173
+ * @param {String} resultId - Result id
174
+ * @returns {RecordStream} - Record stream, convertible to CSV data stream
175
+ */
176
+ result(resultId: string): Parsable<Record>;
177
+ }
178
+ /**
179
+ * Class for Bulk API
180
+ *
181
+ * @class
182
+ */
183
+ export declare class Bulk<S extends Schema> {
184
+ private readonly _conn;
185
+ readonly _logger: Logger;
186
+ /**
187
+ * Polling interval in milliseconds
188
+ *
189
+ * Default: 1000 (1 second)
190
+ */
191
+ pollInterval: number;
192
+ /**
193
+ * Polling timeout in milliseconds
194
+ *
195
+ * Default: 30000 (30 seconds)
196
+ */
197
+ pollTimeout: number;
198
+ /**
199
+ *
200
+ */
201
+ constructor(conn: Connection<S>);
202
+ /**
203
+ *
204
+ */
205
+ _request<T>(request_: BulkRequest): import("../util/promise").StreamPromise<T>;
206
+ /**
207
+ * Create and start bulkload job and batch
208
+ *
209
+ * This method will return a Batch instance (writable stream)
210
+ * which you can write records into as a CSV string.
211
+ *
212
+ * Batch also implements the a promise interface so you can `await` this method to get the job results.
213
+ *
214
+ * @example
215
+ * // Insert an array of records and get the job results
216
+ *
217
+ * const res = await connection.bulk.load('Account', 'insert', accounts)
218
+ *
219
+ * @example
220
+ * // Insert records from a csv file using the returned batch stream
221
+ *
222
+ * const csvFile = fs.createReadStream('accounts.csv')
223
+ *
224
+ * const batch = conn.bulk.load('Account', 'insert')
225
+ *
226
+ * // The `response` event is emitted when the job results are retrieved
227
+ * batch.on('response', res => {
228
+ * console.log(res)
229
+ * })
230
+
231
+ * csvFile.pipe(batch.stream())
232
+ *
233
+ *
234
+ */
235
+ load<Opr extends BulkOperation>(type: string, operation: Opr, input?: Record[] | Readable | string): Batch<S, Opr>;
236
+ load<Opr extends BulkOperation>(type: string, operation: Opr, optionsOrInput?: BulkOptions | Record[] | Readable | string, input?: Record[] | Readable | string): Batch<S, Opr>;
237
+ /**
238
+ * Execute bulk query and get record stream
239
+ */
240
+ query(soql: string): Promise<Parsable<Record>>;
241
+ /**
242
+ * Create a new job instance
243
+ */
244
+ createJob<Opr extends BulkOperation>(type: string, operation: Opr, options?: BulkOptions): Job<S, Opr>;
245
+ /**
246
+ * Get a job instance specified by given job ID
247
+ *
248
+ * @param {String} jobId - Job ID
249
+ * @returns {Bulk~Job}
250
+ */
251
+ job<Opr extends BulkOperation>(jobId: string): Job<S, Opr>;
252
+ }
253
+ export default Bulk;