@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.
- package/LICENSE +22 -0
- package/README.md +54 -0
- package/index.d.ts +4 -0
- package/index.js +1 -0
- package/lib/VERSION.d.ts +2 -0
- package/lib/VERSION.js +3 -0
- package/lib/api/analytics/types.d.ts +509 -0
- package/lib/api/analytics/types.js +2 -0
- package/lib/api/analytics.d.ts +163 -0
- package/lib/api/analytics.js +342 -0
- package/lib/api/apex.d.ts +44 -0
- package/lib/api/apex.js +86 -0
- package/lib/api/bulk.d.ts +253 -0
- package/lib/api/bulk.js +678 -0
- package/lib/api/bulk2.d.ts +324 -0
- package/lib/api/bulk2.js +800 -0
- package/lib/api/chatter.d.ts +133 -0
- package/lib/api/chatter.js +248 -0
- package/lib/api/metadata/schema.d.ts +16117 -0
- package/lib/api/metadata/schema.js +9094 -0
- package/lib/api/metadata.d.ts +189 -0
- package/lib/api/metadata.js +406 -0
- package/lib/api/soap/schema.d.ts +3167 -0
- package/lib/api/soap/schema.js +1787 -0
- package/lib/api/soap.d.ts +76 -0
- package/lib/api/soap.js +155 -0
- package/lib/api/streaming/extension.d.ts +94 -0
- package/lib/api/streaming/extension.js +151 -0
- package/lib/api/streaming.d.ts +160 -0
- package/lib/api/streaming.js +252 -0
- package/lib/api/tooling.d.ts +284 -0
- package/lib/api/tooling.js +202 -0
- package/lib/api/wsdl/wsdl2schema.d.ts +1 -0
- package/lib/api/wsdl/wsdl2schema.js +354 -0
- package/lib/browser/canvas.d.ts +12 -0
- package/lib/browser/canvas.js +77 -0
- package/lib/browser/client.d.ts +82 -0
- package/lib/browser/client.js +244 -0
- package/lib/browser/jsonp.d.ts +12 -0
- package/lib/browser/jsonp.js +69 -0
- package/lib/browser/registry.d.ts +3 -0
- package/lib/browser/registry.js +5 -0
- package/lib/browser/request.d.ts +10 -0
- package/lib/browser/request.js +202 -0
- package/lib/cache.d.ts +74 -0
- package/lib/cache.js +159 -0
- package/lib/connection.d.ts +356 -0
- package/lib/connection.js +1153 -0
- package/lib/core.d.ts +17 -0
- package/lib/core.js +55 -0
- package/lib/csv.d.ts +23 -0
- package/lib/csv.js +35 -0
- package/lib/date.d.ts +82 -0
- package/lib/date.js +201 -0
- package/lib/http-api.d.ts +75 -0
- package/lib/http-api.js +295 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +32 -0
- package/lib/jsforce.d.ts +26 -0
- package/lib/jsforce.js +67 -0
- package/lib/jwtOAuth2.d.ts +8 -0
- package/lib/jwtOAuth2.js +23 -0
- package/lib/oauth2.d.ts +92 -0
- package/lib/oauth2.js +245 -0
- package/lib/process.d.ts +157 -0
- package/lib/process.js +143 -0
- package/lib/query.d.ts +341 -0
- package/lib/query.js +817 -0
- package/lib/quick-action.d.ts +44 -0
- package/lib/quick-action.js +46 -0
- package/lib/record-reference.d.ts +46 -0
- package/lib/record-reference.js +65 -0
- package/lib/record-stream.d.ts +83 -0
- package/lib/record-stream.js +233 -0
- package/lib/registry/base.d.ts +43 -0
- package/lib/registry/base.js +96 -0
- package/lib/registry/empty.d.ts +7 -0
- package/lib/registry/empty.js +13 -0
- package/lib/registry/file.d.ts +11 -0
- package/lib/registry/file.js +51 -0
- package/lib/registry/index.d.ts +8 -0
- package/lib/registry/index.js +21 -0
- package/lib/registry/sfdx.d.ts +56 -0
- package/lib/registry/sfdx.js +133 -0
- package/lib/registry/types.d.ts +47 -0
- package/lib/registry/types.js +2 -0
- package/lib/request-helper.d.ts +23 -0
- package/lib/request-helper.js +102 -0
- package/lib/request.d.ts +11 -0
- package/lib/request.js +75 -0
- package/lib/session-refresh-delegate.d.ts +31 -0
- package/lib/session-refresh-delegate.js +69 -0
- package/lib/soap.d.ts +60 -0
- package/lib/soap.js +257 -0
- package/lib/sobject.d.ts +258 -0
- package/lib/sobject.js +376 -0
- package/lib/soql-builder.d.ts +25 -0
- package/lib/soql-builder.js +226 -0
- package/lib/transport.d.ts +63 -0
- package/lib/transport.js +175 -0
- package/lib/types/common.d.ts +560 -0
- package/lib/types/common.js +2 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/index.js +23 -0
- package/lib/types/projection.d.ts +26 -0
- package/lib/types/projection.js +2 -0
- package/lib/types/record.d.ts +44 -0
- package/lib/types/record.js +2 -0
- package/lib/types/schema.d.ts +50 -0
- package/lib/types/schema.js +2 -0
- package/lib/types/soap.d.ts +43 -0
- package/lib/types/soap.js +2 -0
- package/lib/types/standard-schema.d.ts +16199 -0
- package/lib/types/standard-schema.js +2 -0
- package/lib/types/util.d.ts +7 -0
- package/lib/types/util.js +2 -0
- package/lib/util/formatter.d.ts +8 -0
- package/lib/util/formatter.js +24 -0
- package/lib/util/function.d.ts +32 -0
- package/lib/util/function.js +52 -0
- package/lib/util/get-body-size.d.ts +4 -0
- package/lib/util/get-body-size.js +39 -0
- package/lib/util/logger.d.ts +29 -0
- package/lib/util/logger.js +102 -0
- package/lib/util/promise.d.ts +19 -0
- package/lib/util/promise.js +25 -0
- package/lib/util/stream.d.ts +12 -0
- package/lib/util/stream.js +88 -0
- package/package.json +262 -6
- package/typings/faye/index.d.ts +16 -0
- package/typings/index.d.ts +1 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import Connection from '../connection';
|
|
3
|
+
import { HttpRequest, Schema } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export type ChatterRequestParams = Omit<HttpRequest, 'body'> & {
|
|
8
|
+
body?: string | object | null;
|
|
9
|
+
};
|
|
10
|
+
export type BatchRequestParams = {
|
|
11
|
+
method: string;
|
|
12
|
+
url: string;
|
|
13
|
+
richInput?: any;
|
|
14
|
+
};
|
|
15
|
+
type BatchRequestTupple<S extends Schema, RT extends any[]> = {
|
|
16
|
+
[K in keyof RT]: Request<S, RT[K]>;
|
|
17
|
+
};
|
|
18
|
+
type BatchResultTupple<RT extends any[]> = {
|
|
19
|
+
[K in keyof RT]: {
|
|
20
|
+
statusCode: number;
|
|
21
|
+
result: RT[K];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type BatchResponse<RT extends any[]> = {
|
|
25
|
+
hasErrors: boolean;
|
|
26
|
+
results: BatchResultTupple<RT>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A class representing chatter API request
|
|
30
|
+
*/
|
|
31
|
+
declare class Request<S extends Schema, R> {
|
|
32
|
+
_chatter: Chatter<S>;
|
|
33
|
+
_request: ChatterRequestParams;
|
|
34
|
+
_promise: Promise<R> | undefined;
|
|
35
|
+
constructor(chatter: Chatter<S>, request: ChatterRequestParams);
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve parameters in batch request form
|
|
38
|
+
*/
|
|
39
|
+
batchParams(): {
|
|
40
|
+
richInput?: string | object | null | undefined;
|
|
41
|
+
method: import("../types").HttpMethods;
|
|
42
|
+
url: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Retrieve parameters in batch request form
|
|
46
|
+
*
|
|
47
|
+
* @method Chatter~Request#promise
|
|
48
|
+
* @returns {Promise.<Chatter~RequestResult>}
|
|
49
|
+
*/
|
|
50
|
+
promise(): Promise<R>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns Node.js Stream object for request
|
|
53
|
+
*
|
|
54
|
+
* @method Chatter~Request#stream
|
|
55
|
+
* @returns {stream.Stream}
|
|
56
|
+
*/
|
|
57
|
+
stream(): import("stream").Duplex;
|
|
58
|
+
/**
|
|
59
|
+
* Promise/A+ interface
|
|
60
|
+
* http://promises-aplus.github.io/promises-spec/
|
|
61
|
+
*
|
|
62
|
+
* Delegate to deferred promise, return promise instance for batch result
|
|
63
|
+
*/
|
|
64
|
+
then<U>(onResolve?: (value: R) => U | PromiseLike<U>, onReject?: (e: any) => U | PromiseLike<U>): Promise<U>;
|
|
65
|
+
}
|
|
66
|
+
export declare class Resource<S extends Schema, R> extends Request<S, R> {
|
|
67
|
+
_url: string;
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
constructor(chatter: Chatter<S>, url: string, queryParams?: {
|
|
72
|
+
[name: string]: string | number | boolean | null;
|
|
73
|
+
} | null);
|
|
74
|
+
/**
|
|
75
|
+
* Create a new resource
|
|
76
|
+
*/
|
|
77
|
+
create<R1 = any>(data: string | object | null): Request<S, R1>;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieve resource content
|
|
80
|
+
*/
|
|
81
|
+
retrieve<R1 = R>(): Request<S, R1>;
|
|
82
|
+
/**
|
|
83
|
+
* Update specified resource
|
|
84
|
+
*/
|
|
85
|
+
update<R1 = any>(data: object): Request<S, R1>;
|
|
86
|
+
/**
|
|
87
|
+
* Delete specified resource
|
|
88
|
+
*/
|
|
89
|
+
destroy(): Request<S, void>;
|
|
90
|
+
/**
|
|
91
|
+
* Synonym of Resource#destroy()
|
|
92
|
+
*/
|
|
93
|
+
delete: () => Request<S, void>;
|
|
94
|
+
/**
|
|
95
|
+
* Synonym of Resource#destroy()
|
|
96
|
+
*/
|
|
97
|
+
del: () => Request<S, void>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* API class for Chatter REST API call
|
|
101
|
+
*/
|
|
102
|
+
export declare class Chatter<S extends Schema> {
|
|
103
|
+
_conn: Connection<S>;
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
*/
|
|
107
|
+
constructor(conn: Connection<S>);
|
|
108
|
+
/**
|
|
109
|
+
* Sending request to API endpoint
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
_request<R>(req_: ChatterRequestParams): import("../util/promise").StreamPromise<R>;
|
|
113
|
+
/**
|
|
114
|
+
* Convert path to site root relative url
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
_normalizeUrl(url: string): string;
|
|
118
|
+
/**
|
|
119
|
+
* Make a request for chatter API resource
|
|
120
|
+
*/
|
|
121
|
+
request<R = unknown>(req: ChatterRequestParams): Request<S, R>;
|
|
122
|
+
/**
|
|
123
|
+
* Make a resource request to chatter API
|
|
124
|
+
*/
|
|
125
|
+
resource<R = unknown>(url: string, queryParams?: {
|
|
126
|
+
[name: string]: string | number | boolean | null;
|
|
127
|
+
} | null): Resource<S, R>;
|
|
128
|
+
/**
|
|
129
|
+
* Make a batch request to chatter API
|
|
130
|
+
*/
|
|
131
|
+
batch<RT extends any[]>(requests: BatchRequestTupple<S, RT>): Promise<BatchResponse<RT>>;
|
|
132
|
+
}
|
|
133
|
+
export default Chatter;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Chatter = exports.Resource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @file Manages Salesforce Chatter REST API calls
|
|
6
|
+
* @author Shinichi Tomita <shinichi.tomita@gmail.com>
|
|
7
|
+
*/
|
|
8
|
+
const jsforce_1 = require("../jsforce");
|
|
9
|
+
const function_1 = require("../util/function");
|
|
10
|
+
/*--------------------------------------------*/
|
|
11
|
+
/**
|
|
12
|
+
* A class representing chatter API request
|
|
13
|
+
*/
|
|
14
|
+
class Request {
|
|
15
|
+
_chatter;
|
|
16
|
+
_request;
|
|
17
|
+
_promise;
|
|
18
|
+
constructor(chatter, request) {
|
|
19
|
+
this._chatter = chatter;
|
|
20
|
+
this._request = request;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Retrieve parameters in batch request form
|
|
24
|
+
*/
|
|
25
|
+
batchParams() {
|
|
26
|
+
const { method, url, body } = this._request;
|
|
27
|
+
return {
|
|
28
|
+
method,
|
|
29
|
+
url: this._chatter._normalizeUrl(url),
|
|
30
|
+
...(typeof body !== 'undefined' ? { richInput: body } : {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve parameters in batch request form
|
|
35
|
+
*
|
|
36
|
+
* @method Chatter~Request#promise
|
|
37
|
+
* @returns {Promise.<Chatter~RequestResult>}
|
|
38
|
+
*/
|
|
39
|
+
promise() {
|
|
40
|
+
return (this._promise || (this._promise = this._chatter._request(this._request)));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns Node.js Stream object for request
|
|
44
|
+
*
|
|
45
|
+
* @method Chatter~Request#stream
|
|
46
|
+
* @returns {stream.Stream}
|
|
47
|
+
*/
|
|
48
|
+
stream() {
|
|
49
|
+
return this._chatter._request(this._request).stream();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Promise/A+ interface
|
|
53
|
+
* http://promises-aplus.github.io/promises-spec/
|
|
54
|
+
*
|
|
55
|
+
* Delegate to deferred promise, return promise instance for batch result
|
|
56
|
+
*/
|
|
57
|
+
then(onResolve, onReject) {
|
|
58
|
+
return this.promise().then(onResolve, onReject);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function apppendQueryParamsToUrl(url, queryParams) {
|
|
62
|
+
if (queryParams) {
|
|
63
|
+
const qstring = Object.keys(queryParams)
|
|
64
|
+
.map((name) => `${name}=${encodeURIComponent(String(queryParams[name] ?? ''))}`)
|
|
65
|
+
.join('&');
|
|
66
|
+
url += (url.indexOf('?') > 0 ? '&' : '?') + qstring;
|
|
67
|
+
}
|
|
68
|
+
return url;
|
|
69
|
+
}
|
|
70
|
+
/*------------------------------*/
|
|
71
|
+
class Resource extends Request {
|
|
72
|
+
_url;
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
*/
|
|
76
|
+
constructor(chatter, url, queryParams) {
|
|
77
|
+
super(chatter, {
|
|
78
|
+
method: 'GET',
|
|
79
|
+
url: apppendQueryParamsToUrl(url, queryParams),
|
|
80
|
+
});
|
|
81
|
+
this._url = this._request.url;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create a new resource
|
|
85
|
+
*/
|
|
86
|
+
create(data) {
|
|
87
|
+
return this._chatter.request({
|
|
88
|
+
method: 'POST',
|
|
89
|
+
url: this._url,
|
|
90
|
+
body: data,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve resource content
|
|
95
|
+
*/
|
|
96
|
+
retrieve() {
|
|
97
|
+
return this._chatter.request({
|
|
98
|
+
method: 'GET',
|
|
99
|
+
url: this._url,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Update specified resource
|
|
104
|
+
*/
|
|
105
|
+
update(data) {
|
|
106
|
+
return this._chatter.request({
|
|
107
|
+
method: 'POST',
|
|
108
|
+
url: this._url,
|
|
109
|
+
body: data,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Delete specified resource
|
|
114
|
+
*/
|
|
115
|
+
destroy() {
|
|
116
|
+
return this._chatter.request({
|
|
117
|
+
method: 'DELETE',
|
|
118
|
+
url: this._url,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Synonym of Resource#destroy()
|
|
123
|
+
*/
|
|
124
|
+
delete = this.destroy;
|
|
125
|
+
/**
|
|
126
|
+
* Synonym of Resource#destroy()
|
|
127
|
+
*/
|
|
128
|
+
del = this.destroy;
|
|
129
|
+
}
|
|
130
|
+
exports.Resource = Resource;
|
|
131
|
+
/*------------------------------*/
|
|
132
|
+
/**
|
|
133
|
+
* API class for Chatter REST API call
|
|
134
|
+
*/
|
|
135
|
+
class Chatter {
|
|
136
|
+
_conn;
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
constructor(conn) {
|
|
141
|
+
this._conn = conn;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Sending request to API endpoint
|
|
145
|
+
* @private
|
|
146
|
+
*/
|
|
147
|
+
_request(req_) {
|
|
148
|
+
const { method, url: url_, headers: headers_, body: body_ } = req_;
|
|
149
|
+
let headers = headers_ ?? {};
|
|
150
|
+
let body;
|
|
151
|
+
if (/^(put|post|patch)$/i.test(method)) {
|
|
152
|
+
if ((0, function_1.isObject)(body_)) {
|
|
153
|
+
headers = {
|
|
154
|
+
...headers_,
|
|
155
|
+
'Content-Type': 'application/json',
|
|
156
|
+
};
|
|
157
|
+
body = JSON.stringify(body_);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
body = body_;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const url = this._normalizeUrl(url_);
|
|
164
|
+
return this._conn.request({
|
|
165
|
+
method,
|
|
166
|
+
url,
|
|
167
|
+
headers,
|
|
168
|
+
body,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Convert path to site root relative url
|
|
173
|
+
* @private
|
|
174
|
+
*/
|
|
175
|
+
_normalizeUrl(url) {
|
|
176
|
+
if (url.indexOf('/chatter/') === 0 || url.indexOf('/connect/') === 0) {
|
|
177
|
+
return '/services/data/v' + this._conn.version + url;
|
|
178
|
+
}
|
|
179
|
+
else if (/^\/v[\d]+\.[\d]+\//.test(url)) {
|
|
180
|
+
return '/services/data' + url;
|
|
181
|
+
}
|
|
182
|
+
else if (url.indexOf('/services/') !== 0 && url[0] === '/') {
|
|
183
|
+
return '/services/data/v' + this._conn.version + '/chatter' + url;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return url;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Make a request for chatter API resource
|
|
191
|
+
*/
|
|
192
|
+
request(req) {
|
|
193
|
+
return new Request(this, req);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Make a resource request to chatter API
|
|
197
|
+
*/
|
|
198
|
+
resource(url, queryParams) {
|
|
199
|
+
return new Resource(this, url, queryParams);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Make a batch request to chatter API
|
|
203
|
+
*/
|
|
204
|
+
async batch(requests) {
|
|
205
|
+
const deferreds = requests.map((request) => {
|
|
206
|
+
const deferred = defer();
|
|
207
|
+
request._promise = deferred.promise;
|
|
208
|
+
return deferred;
|
|
209
|
+
});
|
|
210
|
+
const res = await this.request({
|
|
211
|
+
method: 'POST',
|
|
212
|
+
url: this._normalizeUrl('/connect/batch'),
|
|
213
|
+
body: {
|
|
214
|
+
batchRequests: requests.map((request) => request.batchParams()),
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
res.results.forEach((result, i) => {
|
|
218
|
+
const deferred = deferreds[i];
|
|
219
|
+
if (result.statusCode >= 400) {
|
|
220
|
+
deferred.reject(result.result);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
deferred.resolve(result.result);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
return res;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.Chatter = Chatter;
|
|
230
|
+
function defer() {
|
|
231
|
+
let resolve_ = () => { };
|
|
232
|
+
let reject_ = () => { };
|
|
233
|
+
const promise = new Promise((resolve, reject) => {
|
|
234
|
+
resolve_ = resolve;
|
|
235
|
+
reject_ = reject;
|
|
236
|
+
});
|
|
237
|
+
return {
|
|
238
|
+
promise,
|
|
239
|
+
resolve: resolve_,
|
|
240
|
+
reject: reject_,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/*--------------------------------------------*/
|
|
244
|
+
/*
|
|
245
|
+
* Register hook in connection instantiation for dynamically adding this API module features
|
|
246
|
+
*/
|
|
247
|
+
(0, jsforce_1.registerModule)('chatter', (conn) => new Chatter(conn));
|
|
248
|
+
exports.default = Chatter;
|