@jsforce/jsforce-node 0.0.1 → 3.0.0-next.1
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 +444 -0
- package/lib/api/bulk.js +1372 -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 +355 -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 +257 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +31 -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 +246 -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/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 +260 -6
- package/typings/faye/index.d.ts +16 -0
- package/typings/index.d.ts +1 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import Connection from '../connection';
|
|
2
|
+
import { Schema } from '../types';
|
|
3
|
+
import { ReportMetadata, ReportExecuteResult, ReportRetrieveResult, ReportDescribeResult, ReportInfo, ReportInstanceInfo, DashboardMetadata, DashboardResult, DashboardStatusResult, DashboardRefreshResult, DashboardInfo } from './analytics/types';
|
|
4
|
+
import { QueryExplainResult } from '../query';
|
|
5
|
+
export type { ReportMetadata, ReportExecuteResult, ReportRetrieveResult, ReportDescribeResult, ReportInfo, ReportInstanceInfo, DashboardMetadata, DashboardResult, DashboardStatusResult, DashboardRefreshResult, DashboardInfo, };
|
|
6
|
+
export type ReportExecuteOptions = {
|
|
7
|
+
details?: boolean;
|
|
8
|
+
metadata?: {
|
|
9
|
+
reportMetadata: Partial<ReportMetadata>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Report object class in Analytics API
|
|
14
|
+
*/
|
|
15
|
+
export declare class ReportInstance<S extends Schema> {
|
|
16
|
+
_report: Report<S>;
|
|
17
|
+
_conn: Connection<S>;
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
constructor(report: Report<S>, id: string);
|
|
23
|
+
/**
|
|
24
|
+
* Retrieve report result asynchronously executed
|
|
25
|
+
*/
|
|
26
|
+
retrieve(): Promise<ReportRetrieveResult>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Report object class in Analytics API
|
|
30
|
+
*/
|
|
31
|
+
export declare class Report<S extends Schema> {
|
|
32
|
+
_conn: Connection<S>;
|
|
33
|
+
id: string;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
constructor(conn: Connection<S>, id: string);
|
|
38
|
+
/**
|
|
39
|
+
* Describe report metadata
|
|
40
|
+
*/
|
|
41
|
+
describe(): Promise<ReportDescribeResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Destroy a report
|
|
44
|
+
*/
|
|
45
|
+
destroy(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Synonym of Analytics~Report#destroy()
|
|
48
|
+
*/
|
|
49
|
+
delete: () => Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Synonym of Analytics~Report#destroy()
|
|
52
|
+
*/
|
|
53
|
+
del: () => Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Clones a given report
|
|
56
|
+
*/
|
|
57
|
+
clone(name: string): Promise<ReportDescribeResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Explain plan for executing report
|
|
60
|
+
*/
|
|
61
|
+
explain(): Promise<QueryExplainResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Run report synchronously
|
|
64
|
+
*/
|
|
65
|
+
execute(options?: ReportExecuteOptions): Promise<ReportExecuteResult>;
|
|
66
|
+
/**
|
|
67
|
+
* Synonym of Analytics~Report#execute()
|
|
68
|
+
*/
|
|
69
|
+
run: (options?: ReportExecuteOptions) => Promise<ReportExecuteResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Synonym of Analytics~Report#execute()
|
|
72
|
+
*/
|
|
73
|
+
exec: (options?: ReportExecuteOptions) => Promise<ReportExecuteResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Run report asynchronously
|
|
76
|
+
*/
|
|
77
|
+
executeAsync(options?: ReportExecuteOptions): Promise<ReportInstanceInfo>;
|
|
78
|
+
/**
|
|
79
|
+
* Get report instance for specified instance ID
|
|
80
|
+
*/
|
|
81
|
+
instance(id: string): ReportInstance<S>;
|
|
82
|
+
/**
|
|
83
|
+
* List report instances which had been executed asynchronously
|
|
84
|
+
*/
|
|
85
|
+
instances(): Promise<ReportInstanceInfo[]>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Dashboard object class in the Analytics API
|
|
89
|
+
*/
|
|
90
|
+
export declare class Dashboard<S extends Schema> {
|
|
91
|
+
_conn: Connection<S>;
|
|
92
|
+
id: string;
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
constructor(conn: Connection<S>, id: string);
|
|
97
|
+
/**
|
|
98
|
+
* Describe dashboard metadata
|
|
99
|
+
*
|
|
100
|
+
* @method Analytics~Dashboard#describe
|
|
101
|
+
* @param {Callback.<Analytics-DashboardMetadata>} [callback] - Callback function
|
|
102
|
+
* @returns {Promise.<Analytics-DashboardMetadata>}
|
|
103
|
+
*/
|
|
104
|
+
describe(): Promise<DashboardMetadata>;
|
|
105
|
+
/**
|
|
106
|
+
* Get details about dashboard components
|
|
107
|
+
*/
|
|
108
|
+
components(componentIds?: string | string[]): Promise<DashboardResult>;
|
|
109
|
+
/**
|
|
110
|
+
* Get dashboard status
|
|
111
|
+
*/
|
|
112
|
+
status(): Promise<DashboardStatusResult>;
|
|
113
|
+
/**
|
|
114
|
+
* Refresh a dashboard
|
|
115
|
+
*/
|
|
116
|
+
refresh(): Promise<DashboardRefreshResult>;
|
|
117
|
+
/**
|
|
118
|
+
* Clone a dashboard
|
|
119
|
+
*/
|
|
120
|
+
clone(config: {
|
|
121
|
+
name: string;
|
|
122
|
+
folderId?: string;
|
|
123
|
+
} | string, folderId?: string): Promise<DashboardMetadata>;
|
|
124
|
+
/**
|
|
125
|
+
* Destroy a dashboard
|
|
126
|
+
*/
|
|
127
|
+
destroy(): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Synonym of Analytics~Dashboard#destroy()
|
|
130
|
+
*/
|
|
131
|
+
delete: () => Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Synonym of Analytics~Dashboard#destroy()
|
|
134
|
+
*/
|
|
135
|
+
del: () => Promise<void>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* API class for Analytics API
|
|
139
|
+
*/
|
|
140
|
+
export declare class Analytics<S extends Schema> {
|
|
141
|
+
_conn: Connection<S>;
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
*/
|
|
145
|
+
constructor(conn: Connection<S>);
|
|
146
|
+
/**
|
|
147
|
+
* Get report object of Analytics API
|
|
148
|
+
*/
|
|
149
|
+
report(id: string): Report<S>;
|
|
150
|
+
/**
|
|
151
|
+
* Get recent report list
|
|
152
|
+
*/
|
|
153
|
+
reports(): import("../util/promise").StreamPromise<ReportInfo[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Get dashboard object of Analytics API
|
|
156
|
+
*/
|
|
157
|
+
dashboard(id: string): Dashboard<S>;
|
|
158
|
+
/**
|
|
159
|
+
* Get recent dashboard list
|
|
160
|
+
*/
|
|
161
|
+
dashboards(): import("../util/promise").StreamPromise<DashboardInfo[]>;
|
|
162
|
+
}
|
|
163
|
+
export default Analytics;
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Analytics = exports.Dashboard = exports.Report = exports.ReportInstance = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @file Manages Salesforce Analytics API
|
|
6
|
+
* @author Shinichi Tomita <shinichi.tomita@gmail.com>
|
|
7
|
+
*/
|
|
8
|
+
const jsforce_1 = require("../jsforce");
|
|
9
|
+
/*----------------------------------------------------------------------------------*/
|
|
10
|
+
/**
|
|
11
|
+
* Report object class in Analytics API
|
|
12
|
+
*/
|
|
13
|
+
class ReportInstance {
|
|
14
|
+
_report;
|
|
15
|
+
_conn;
|
|
16
|
+
id;
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
constructor(report, id) {
|
|
21
|
+
this._report = report;
|
|
22
|
+
this._conn = report._conn;
|
|
23
|
+
this.id = id;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Retrieve report result asynchronously executed
|
|
27
|
+
*/
|
|
28
|
+
retrieve() {
|
|
29
|
+
const url = [
|
|
30
|
+
this._conn._baseUrl(),
|
|
31
|
+
'analytics',
|
|
32
|
+
'reports',
|
|
33
|
+
this._report.id,
|
|
34
|
+
'instances',
|
|
35
|
+
this.id,
|
|
36
|
+
].join('/');
|
|
37
|
+
return this._conn.request(url);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.ReportInstance = ReportInstance;
|
|
41
|
+
/*----------------------------------------------------------------------------------*/
|
|
42
|
+
/**
|
|
43
|
+
* Report object class in Analytics API
|
|
44
|
+
*/
|
|
45
|
+
class Report {
|
|
46
|
+
_conn;
|
|
47
|
+
id;
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
constructor(conn, id) {
|
|
52
|
+
this._conn = conn;
|
|
53
|
+
this.id = id;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Describe report metadata
|
|
57
|
+
*/
|
|
58
|
+
describe() {
|
|
59
|
+
const url = [
|
|
60
|
+
this._conn._baseUrl(),
|
|
61
|
+
'analytics',
|
|
62
|
+
'reports',
|
|
63
|
+
this.id,
|
|
64
|
+
'describe',
|
|
65
|
+
].join('/');
|
|
66
|
+
return this._conn.request(url);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Destroy a report
|
|
70
|
+
*/
|
|
71
|
+
destroy() {
|
|
72
|
+
const url = [this._conn._baseUrl(), 'analytics', 'reports', this.id].join('/');
|
|
73
|
+
return this._conn.request({ method: 'DELETE', url });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Synonym of Analytics~Report#destroy()
|
|
77
|
+
*/
|
|
78
|
+
delete = this.destroy;
|
|
79
|
+
/**
|
|
80
|
+
* Synonym of Analytics~Report#destroy()
|
|
81
|
+
*/
|
|
82
|
+
del = this.destroy;
|
|
83
|
+
/**
|
|
84
|
+
* Clones a given report
|
|
85
|
+
*/
|
|
86
|
+
clone(name) {
|
|
87
|
+
const url = [this._conn._baseUrl(), 'analytics', 'reports'].join('/') +
|
|
88
|
+
'?cloneId=' +
|
|
89
|
+
this.id;
|
|
90
|
+
const config = { reportMetadata: { name } };
|
|
91
|
+
return this._conn.request({
|
|
92
|
+
method: 'POST',
|
|
93
|
+
url,
|
|
94
|
+
headers: { 'Content-Type': 'application/json' },
|
|
95
|
+
body: JSON.stringify(config),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Explain plan for executing report
|
|
100
|
+
*/
|
|
101
|
+
explain() {
|
|
102
|
+
const url = '/query/?explain=' + this.id;
|
|
103
|
+
return this._conn.request(url);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Run report synchronously
|
|
107
|
+
*/
|
|
108
|
+
execute(options = {}) {
|
|
109
|
+
const url = [this._conn._baseUrl(), 'analytics', 'reports', this.id].join('/') +
|
|
110
|
+
'?includeDetails=' +
|
|
111
|
+
(options.details ? 'true' : 'false');
|
|
112
|
+
return this._conn.request({
|
|
113
|
+
url,
|
|
114
|
+
...(options.metadata
|
|
115
|
+
? {
|
|
116
|
+
method: 'POST',
|
|
117
|
+
headers: { 'Content-Type': 'application/json' },
|
|
118
|
+
body: JSON.stringify(options.metadata),
|
|
119
|
+
}
|
|
120
|
+
: { method: 'GET' }),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Synonym of Analytics~Report#execute()
|
|
125
|
+
*/
|
|
126
|
+
run = this.execute;
|
|
127
|
+
/**
|
|
128
|
+
* Synonym of Analytics~Report#execute()
|
|
129
|
+
*/
|
|
130
|
+
exec = this.execute;
|
|
131
|
+
/**
|
|
132
|
+
* Run report asynchronously
|
|
133
|
+
*/
|
|
134
|
+
executeAsync(options = {}) {
|
|
135
|
+
const url = [
|
|
136
|
+
this._conn._baseUrl(),
|
|
137
|
+
'analytics',
|
|
138
|
+
'reports',
|
|
139
|
+
this.id,
|
|
140
|
+
'instances',
|
|
141
|
+
].join('/') + (options.details ? '?includeDetails=true' : '');
|
|
142
|
+
return this._conn.request({
|
|
143
|
+
method: 'POST',
|
|
144
|
+
url,
|
|
145
|
+
...(options.metadata
|
|
146
|
+
? {
|
|
147
|
+
headers: { 'Content-Type': 'application/json' },
|
|
148
|
+
body: JSON.stringify(options.metadata),
|
|
149
|
+
}
|
|
150
|
+
: { body: '' }),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get report instance for specified instance ID
|
|
155
|
+
*/
|
|
156
|
+
instance(id) {
|
|
157
|
+
return new ReportInstance(this, id);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* List report instances which had been executed asynchronously
|
|
161
|
+
*/
|
|
162
|
+
instances() {
|
|
163
|
+
const url = [
|
|
164
|
+
this._conn._baseUrl(),
|
|
165
|
+
'analytics',
|
|
166
|
+
'reports',
|
|
167
|
+
this.id,
|
|
168
|
+
'instances',
|
|
169
|
+
].join('/');
|
|
170
|
+
return this._conn.request(url);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.Report = Report;
|
|
174
|
+
/*----------------------------------------------------------------------------------*/
|
|
175
|
+
/**
|
|
176
|
+
* Dashboard object class in the Analytics API
|
|
177
|
+
*/
|
|
178
|
+
class Dashboard {
|
|
179
|
+
_conn;
|
|
180
|
+
id;
|
|
181
|
+
/**
|
|
182
|
+
*
|
|
183
|
+
*/
|
|
184
|
+
constructor(conn, id) {
|
|
185
|
+
this._conn = conn;
|
|
186
|
+
this.id = id;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Describe dashboard metadata
|
|
190
|
+
*
|
|
191
|
+
* @method Analytics~Dashboard#describe
|
|
192
|
+
* @param {Callback.<Analytics-DashboardMetadata>} [callback] - Callback function
|
|
193
|
+
* @returns {Promise.<Analytics-DashboardMetadata>}
|
|
194
|
+
*/
|
|
195
|
+
describe() {
|
|
196
|
+
const url = [
|
|
197
|
+
this._conn._baseUrl(),
|
|
198
|
+
'analytics',
|
|
199
|
+
'dashboards',
|
|
200
|
+
this.id,
|
|
201
|
+
'describe',
|
|
202
|
+
].join('/');
|
|
203
|
+
return this._conn.request(url);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get details about dashboard components
|
|
207
|
+
*/
|
|
208
|
+
components(componentIds) {
|
|
209
|
+
const url = [
|
|
210
|
+
this._conn._baseUrl(),
|
|
211
|
+
'analytics',
|
|
212
|
+
'dashboards',
|
|
213
|
+
this.id,
|
|
214
|
+
].join('/');
|
|
215
|
+
const config = {
|
|
216
|
+
componentIds: Array.isArray(componentIds)
|
|
217
|
+
? componentIds
|
|
218
|
+
: typeof componentIds === 'string'
|
|
219
|
+
? [componentIds]
|
|
220
|
+
: undefined,
|
|
221
|
+
};
|
|
222
|
+
return this._conn.request({
|
|
223
|
+
method: 'POST',
|
|
224
|
+
url,
|
|
225
|
+
headers: { 'Content-Type': 'application/json' },
|
|
226
|
+
body: JSON.stringify(config),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Get dashboard status
|
|
231
|
+
*/
|
|
232
|
+
status() {
|
|
233
|
+
const url = [
|
|
234
|
+
this._conn._baseUrl(),
|
|
235
|
+
'analytics',
|
|
236
|
+
'dashboards',
|
|
237
|
+
this.id,
|
|
238
|
+
'status',
|
|
239
|
+
].join('/');
|
|
240
|
+
return this._conn.request(url);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Refresh a dashboard
|
|
244
|
+
*/
|
|
245
|
+
refresh() {
|
|
246
|
+
const url = [
|
|
247
|
+
this._conn._baseUrl(),
|
|
248
|
+
'analytics',
|
|
249
|
+
'dashboards',
|
|
250
|
+
this.id,
|
|
251
|
+
].join('/');
|
|
252
|
+
return this._conn.request({
|
|
253
|
+
method: 'PUT',
|
|
254
|
+
url,
|
|
255
|
+
body: '',
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Clone a dashboard
|
|
260
|
+
*/
|
|
261
|
+
clone(config, folderId) {
|
|
262
|
+
const url = [this._conn._baseUrl(), 'analytics', 'dashboards'].join('/') +
|
|
263
|
+
'?cloneId=' +
|
|
264
|
+
this.id;
|
|
265
|
+
if (typeof config === 'string') {
|
|
266
|
+
config = { name: config, folderId };
|
|
267
|
+
}
|
|
268
|
+
return this._conn.request({
|
|
269
|
+
method: 'POST',
|
|
270
|
+
url,
|
|
271
|
+
headers: { 'Content-Type': 'application/json' },
|
|
272
|
+
body: JSON.stringify(config),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Destroy a dashboard
|
|
277
|
+
*/
|
|
278
|
+
destroy() {
|
|
279
|
+
const url = [
|
|
280
|
+
this._conn._baseUrl(),
|
|
281
|
+
'analytics',
|
|
282
|
+
'dashboards',
|
|
283
|
+
this.id,
|
|
284
|
+
].join('/');
|
|
285
|
+
return this._conn.request({ method: 'DELETE', url });
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Synonym of Analytics~Dashboard#destroy()
|
|
289
|
+
*/
|
|
290
|
+
delete = this.destroy;
|
|
291
|
+
/**
|
|
292
|
+
* Synonym of Analytics~Dashboard#destroy()
|
|
293
|
+
*/
|
|
294
|
+
del = this.destroy;
|
|
295
|
+
}
|
|
296
|
+
exports.Dashboard = Dashboard;
|
|
297
|
+
/*----------------------------------------------------------------------------------*/
|
|
298
|
+
/**
|
|
299
|
+
* API class for Analytics API
|
|
300
|
+
*/
|
|
301
|
+
class Analytics {
|
|
302
|
+
_conn;
|
|
303
|
+
/**
|
|
304
|
+
*
|
|
305
|
+
*/
|
|
306
|
+
constructor(conn) {
|
|
307
|
+
this._conn = conn;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Get report object of Analytics API
|
|
311
|
+
*/
|
|
312
|
+
report(id) {
|
|
313
|
+
return new Report(this._conn, id);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Get recent report list
|
|
317
|
+
*/
|
|
318
|
+
reports() {
|
|
319
|
+
const url = [this._conn._baseUrl(), 'analytics', 'reports'].join('/');
|
|
320
|
+
return this._conn.request(url);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Get dashboard object of Analytics API
|
|
324
|
+
*/
|
|
325
|
+
dashboard(id) {
|
|
326
|
+
return new Dashboard(this._conn, id);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Get recent dashboard list
|
|
330
|
+
*/
|
|
331
|
+
dashboards() {
|
|
332
|
+
const url = [this._conn._baseUrl(), 'analytics', 'dashboards'].join('/');
|
|
333
|
+
return this._conn.request(url);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
exports.Analytics = Analytics;
|
|
337
|
+
/*--------------------------------------------*/
|
|
338
|
+
/*
|
|
339
|
+
* Register hook in connection instantiation for dynamically adding this API module features
|
|
340
|
+
*/
|
|
341
|
+
(0, jsforce_1.registerModule)('analytics', (conn) => new Analytics(conn));
|
|
342
|
+
exports.default = Analytics;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Connection from '../connection';
|
|
2
|
+
import { HttpRequest, HttpMethods, Schema } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* API class for Apex REST endpoint call
|
|
5
|
+
*/
|
|
6
|
+
export declare class Apex<S extends Schema> {
|
|
7
|
+
_conn: Connection<S>;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
constructor(conn: Connection<S>);
|
|
12
|
+
_baseUrl(): string;
|
|
13
|
+
/**
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
_createRequestParams(method: HttpMethods, path: string, body?: Object, options?: {
|
|
17
|
+
headers?: HttpRequest['headers'];
|
|
18
|
+
}): HttpRequest;
|
|
19
|
+
/**
|
|
20
|
+
* Call Apex REST service in GET request
|
|
21
|
+
*/
|
|
22
|
+
get<R = unknown>(path: string, options?: Object): import("../util/promise").StreamPromise<R>;
|
|
23
|
+
/**
|
|
24
|
+
* Call Apex REST service in POST request
|
|
25
|
+
*/
|
|
26
|
+
post<R = unknown>(path: string, body?: Object, options?: Object): import("../util/promise").StreamPromise<R>;
|
|
27
|
+
/**
|
|
28
|
+
* Call Apex REST service in PUT request
|
|
29
|
+
*/
|
|
30
|
+
put<R = unknown>(path: string, body?: Object, options?: Object): import("../util/promise").StreamPromise<R>;
|
|
31
|
+
/**
|
|
32
|
+
* Call Apex REST service in PATCH request
|
|
33
|
+
*/
|
|
34
|
+
patch<R = unknown>(path: string, body?: Object, options?: Object): import("../util/promise").StreamPromise<R>;
|
|
35
|
+
/**
|
|
36
|
+
* Call Apex REST service in DELETE request
|
|
37
|
+
*/
|
|
38
|
+
delete<R = unknown>(path: string, options?: Object): import("../util/promise").StreamPromise<R>;
|
|
39
|
+
/**
|
|
40
|
+
* Synonym of Apex#delete()
|
|
41
|
+
*/
|
|
42
|
+
del: <R = unknown>(path: string, options?: Object) => import("../util/promise").StreamPromise<R>;
|
|
43
|
+
}
|
|
44
|
+
export default Apex;
|
package/lib/api/apex.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Apex = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @file Manages Salesforce Apex REST endpoint calls
|
|
6
|
+
* @author Shinichi Tomita <shinichi.tomita@gmail.com>
|
|
7
|
+
*/
|
|
8
|
+
const jsforce_1 = require("../jsforce");
|
|
9
|
+
/**
|
|
10
|
+
* API class for Apex REST endpoint call
|
|
11
|
+
*/
|
|
12
|
+
class Apex {
|
|
13
|
+
_conn;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
constructor(conn) {
|
|
18
|
+
this._conn = conn;
|
|
19
|
+
}
|
|
20
|
+
/* @private */
|
|
21
|
+
_baseUrl() {
|
|
22
|
+
return `${this._conn.instanceUrl}/services/apexrest`;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
_createRequestParams(method, path, body, options = {}) {
|
|
28
|
+
const headers = typeof options.headers === 'object' ? options.headers : {};
|
|
29
|
+
if (!/^(GET|DELETE)$/i.test(method)) {
|
|
30
|
+
headers['content-type'] = 'application/json';
|
|
31
|
+
}
|
|
32
|
+
const params = {
|
|
33
|
+
method,
|
|
34
|
+
url: this._baseUrl() + path,
|
|
35
|
+
headers,
|
|
36
|
+
};
|
|
37
|
+
if (body) {
|
|
38
|
+
params.body = JSON.stringify(body);
|
|
39
|
+
}
|
|
40
|
+
return params;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Call Apex REST service in GET request
|
|
44
|
+
*/
|
|
45
|
+
get(path, options) {
|
|
46
|
+
return this._conn.request(this._createRequestParams('GET', path, undefined, options));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Call Apex REST service in POST request
|
|
50
|
+
*/
|
|
51
|
+
post(path, body, options) {
|
|
52
|
+
const params = this._createRequestParams('POST', path, body, options);
|
|
53
|
+
return this._conn.request(params);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Call Apex REST service in PUT request
|
|
57
|
+
*/
|
|
58
|
+
put(path, body, options) {
|
|
59
|
+
const params = this._createRequestParams('PUT', path, body, options);
|
|
60
|
+
return this._conn.request(params);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Call Apex REST service in PATCH request
|
|
64
|
+
*/
|
|
65
|
+
patch(path, body, options) {
|
|
66
|
+
const params = this._createRequestParams('PATCH', path, body, options);
|
|
67
|
+
return this._conn.request(params);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Call Apex REST service in DELETE request
|
|
71
|
+
*/
|
|
72
|
+
delete(path, options) {
|
|
73
|
+
return this._conn.request(this._createRequestParams('DELETE', path, undefined, options));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Synonym of Apex#delete()
|
|
77
|
+
*/
|
|
78
|
+
del = this.delete;
|
|
79
|
+
}
|
|
80
|
+
exports.Apex = Apex;
|
|
81
|
+
/*--------------------------------------------*/
|
|
82
|
+
/*
|
|
83
|
+
* Register hook in connection instantiation for dynamically adding this API module features
|
|
84
|
+
*/
|
|
85
|
+
(0, jsforce_1.registerModule)('apex', (conn) => new Apex(conn));
|
|
86
|
+
exports.default = Apex;
|