@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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export type Optional<T> = T | null | undefined;
2
+ export type StringKeys<O> = Extract<keyof O, string>;
3
+ export type PickIfMatch<O extends {
4
+ [name: string]: any;
5
+ }, P extends string> = Pick<O, Extract<P, keyof O>>;
6
+ export type IsEqualType<S, T> = [S] extends [T] ? [T] extends [S] ? true : false : false;
7
+ export type ConditionalPartial<O, IsPartial extends boolean> = IsPartial extends true ? Partial<O> : O;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ /**
2
+ *
3
+ */
4
+ export declare function zeroPad(num: number, digits?: number): string;
5
+ /**
6
+ *
7
+ */
8
+ export declare function formatDate(date: Date): string;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatDate = exports.zeroPad = void 0;
4
+ /**
5
+ *
6
+ */
7
+ function zeroPad(num, digits = 2) {
8
+ let nstr = '';
9
+ for (let d = digits - 1; d > 0; d--) {
10
+ if (num >= 10 ** d) {
11
+ break;
12
+ }
13
+ nstr += '0';
14
+ }
15
+ return nstr + String(num);
16
+ }
17
+ exports.zeroPad = zeroPad;
18
+ /**
19
+ *
20
+ */
21
+ function formatDate(date) {
22
+ return `${date.getUTCFullYear()}-${zeroPad(date.getUTCMonth() + 1)}-${zeroPad(date.getUTCDate())}T${zeroPad(date.getUTCHours())}:${zeroPad(date.getUTCMinutes())}:${zeroPad(date.getUTCSeconds())}+00:00`;
23
+ }
24
+ exports.formatDate = formatDate;
@@ -0,0 +1,32 @@
1
+ /**
2
+ *
3
+ */
4
+ export declare function isObject(v: any): v is object;
5
+ /**
6
+ *
7
+ */
8
+ export declare function isMapObject(v: any): v is {
9
+ [name: string]: unknown;
10
+ };
11
+ /**
12
+ *
13
+ */
14
+ export declare function isFunction(v: any): v is (...args: any[]) => any;
15
+ /**
16
+ *
17
+ */
18
+ export declare function isNumber(v: any): v is number;
19
+ /**
20
+ * Detect whether the value has CommonJS Promise/A+ interface or not
21
+ */
22
+ export declare function isPromiseLike(v: any): v is {
23
+ then: Function;
24
+ };
25
+ /**
26
+ *
27
+ */
28
+ export declare function identityFunc<T>(a: T): T;
29
+ /**
30
+ *
31
+ */
32
+ export declare function emptyFunc(): void;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emptyFunc = exports.identityFunc = exports.isPromiseLike = exports.isNumber = exports.isFunction = exports.isMapObject = exports.isObject = void 0;
4
+ /**
5
+ *
6
+ */
7
+ function isObject(v) {
8
+ const t = typeof v;
9
+ return v != null && (t == 'object' || t == 'function');
10
+ }
11
+ exports.isObject = isObject;
12
+ /**
13
+ *
14
+ */
15
+ function isMapObject(v) {
16
+ const t = typeof v;
17
+ return v != null && t == 'object';
18
+ }
19
+ exports.isMapObject = isMapObject;
20
+ /**
21
+ *
22
+ */
23
+ function isFunction(v) {
24
+ return typeof v == 'function';
25
+ }
26
+ exports.isFunction = isFunction;
27
+ /**
28
+ *
29
+ */
30
+ function isNumber(v) {
31
+ return typeof v == 'number';
32
+ }
33
+ exports.isNumber = isNumber;
34
+ /**
35
+ * Detect whether the value has CommonJS Promise/A+ interface or not
36
+ */
37
+ function isPromiseLike(v) {
38
+ return isObject(v) && isFunction(v.then);
39
+ }
40
+ exports.isPromiseLike = isPromiseLike;
41
+ /**
42
+ *
43
+ */
44
+ function identityFunc(a) {
45
+ return a;
46
+ }
47
+ exports.identityFunc = identityFunc;
48
+ /**
49
+ *
50
+ */
51
+ function emptyFunc() { }
52
+ exports.emptyFunc = emptyFunc;
@@ -0,0 +1,4 @@
1
+ import { HttpBody } from '../types';
2
+ export declare function getBodySize(body: HttpBody | undefined, headers?: {
3
+ [name: string]: string;
4
+ }): number | undefined;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getBodySize = void 0;
7
+ const is_1 = __importDefault(require("@sindresorhus/is"));
8
+ function getBodySize(body, headers = {}) {
9
+ function isFormData(body) {
10
+ return is_1.default.nodeStream(body) && is_1.default.function_(body.getBoundary);
11
+ }
12
+ if (headers && 'content-length' in headers) {
13
+ return Number(headers['content-length']);
14
+ }
15
+ if (!body) {
16
+ return 0;
17
+ }
18
+ if (is_1.default.string(body)) {
19
+ return Buffer.byteLength(body);
20
+ }
21
+ if (is_1.default.urlSearchParams(body)) {
22
+ return Buffer.byteLength(body.toString());
23
+ }
24
+ if (is_1.default.buffer(body)) {
25
+ return body.length;
26
+ }
27
+ try {
28
+ // `getLengthSync` will throw if body has a stream:
29
+ // https://github.com/form-data/form-data#integer-getlengthsync
30
+ if (isFormData(body)) {
31
+ return body.getLengthSync();
32
+ }
33
+ }
34
+ catch {
35
+ return undefined;
36
+ }
37
+ return undefined;
38
+ }
39
+ exports.getBodySize = getBodySize;
@@ -0,0 +1,29 @@
1
+ /**
2
+ *
3
+ */
4
+ export declare const LogLevels: {
5
+ [level: string]: number;
6
+ };
7
+ export type LogLevelConfig = string | number | {
8
+ [name: string]: string | number;
9
+ };
10
+ /**
11
+ *
12
+ */
13
+ export declare class Logger {
14
+ _moduleName: string;
15
+ _logLevel: number;
16
+ constructor(moduleName: string, logLevelConfig?: LogLevelConfig);
17
+ createInstance(logLevelConfig?: LogLevelConfig): Logger;
18
+ setLogLevel(logLevel: string | number): void;
19
+ log(logLevel: number, ...messages: Array<any>): void;
20
+ debug(...messages: Array<any>): void;
21
+ info(...messages: Array<any>): void;
22
+ warn(...messages: Array<any>): void;
23
+ error(...messages: Array<any>): void;
24
+ fatal(...messages: Array<any>): void;
25
+ }
26
+ /**
27
+ *
28
+ */
29
+ export declare function getLogger(moduleName: string): Logger;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLogger = exports.Logger = exports.LogLevels = void 0;
4
+ /**
5
+ *
6
+ */
7
+ exports.LogLevels = {
8
+ DEBUG: 1,
9
+ INFO: 2,
10
+ WARN: 3,
11
+ ERROR: 4,
12
+ FATAL: 5,
13
+ NONE: 6,
14
+ };
15
+ const LogLevelLabels = ['', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL', 'NONE'];
16
+ const globalLogLevelConfig = (() => {
17
+ const globalLogLevelStr = process.env.JSFORCE_LOG_LEVEL ||
18
+ global.__JSFORCE_LOG_LEVEL__ ||
19
+ 'NONE';
20
+ if (/^(DEBUG|INFO|WARN|ERROR|FATAL|NONE)$/i.test(globalLogLevelStr)) {
21
+ return { '*': globalLogLevelStr };
22
+ }
23
+ try {
24
+ return JSON.parse(globalLogLevelStr);
25
+ }
26
+ catch (e) {
27
+ return { '*': 'NONE' };
28
+ }
29
+ })();
30
+ function getModuleLogLevel(logLevelConfig, moduleName) {
31
+ const logLevel = logLevelConfig[moduleName] || logLevelConfig['*'];
32
+ return typeof logLevel === 'number'
33
+ ? logLevel
34
+ : exports.LogLevels[logLevel] || exports.LogLevels.NONE;
35
+ }
36
+ /**
37
+ *
38
+ */
39
+ class Logger {
40
+ _moduleName;
41
+ _logLevel;
42
+ constructor(moduleName, logLevelConfig = globalLogLevelConfig) {
43
+ this._moduleName = moduleName;
44
+ this._logLevel =
45
+ typeof logLevelConfig === 'number'
46
+ ? logLevelConfig
47
+ : typeof logLevelConfig === 'string'
48
+ ? exports.LogLevels[logLevelConfig] || exports.LogLevels.NONE
49
+ : getModuleLogLevel(logLevelConfig, moduleName);
50
+ }
51
+ createInstance(logLevelConfig = this._logLevel) {
52
+ return new Logger(this._moduleName, logLevelConfig);
53
+ }
54
+ setLogLevel(logLevel) {
55
+ if (typeof logLevel === 'string') {
56
+ this._logLevel = exports.LogLevels[logLevel] || exports.LogLevels.NONE;
57
+ }
58
+ else {
59
+ this._logLevel = logLevel;
60
+ }
61
+ }
62
+ log(logLevel, ...messages) {
63
+ if (this._logLevel <= logLevel) {
64
+ const msgs = [
65
+ `${LogLevelLabels[logLevel]}\t[${this._moduleName}] `,
66
+ ...messages,
67
+ ];
68
+ if (logLevel < exports.LogLevels.ERROR) {
69
+ console.log(...msgs); // eslint-disable-line no-console
70
+ }
71
+ else {
72
+ console.error(...msgs); // eslint-disable-line no-console
73
+ }
74
+ }
75
+ }
76
+ debug(...messages) {
77
+ this.log(exports.LogLevels.DEBUG, ...messages);
78
+ }
79
+ info(...messages) {
80
+ this.log(exports.LogLevels.INFO, ...messages);
81
+ }
82
+ warn(...messages) {
83
+ this.log(exports.LogLevels.WARN, ...messages);
84
+ }
85
+ error(...messages) {
86
+ this.log(exports.LogLevels.ERROR, ...messages);
87
+ }
88
+ fatal(...messages) {
89
+ this.log(exports.LogLevels.FATAL, ...messages);
90
+ }
91
+ }
92
+ exports.Logger = Logger;
93
+ const loggers = {};
94
+ /**
95
+ *
96
+ */
97
+ function getLogger(moduleName) {
98
+ const logger = loggers[moduleName] || new Logger(moduleName);
99
+ loggers[moduleName] = logger;
100
+ return logger;
101
+ }
102
+ exports.getLogger = getLogger;
@@ -0,0 +1,19 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ *
4
+ */
5
+ import { Duplex } from 'stream';
6
+ /**
7
+ *
8
+ */
9
+ export type StreamPromiseBuilder<T> = () => {
10
+ stream: Duplex;
11
+ promise: Promise<T>;
12
+ };
13
+ /**
14
+ *
15
+ */
16
+ export declare class StreamPromise<T> extends Promise<T> {
17
+ stream(): Duplex;
18
+ static create<T>(builder: StreamPromiseBuilder<T>): StreamPromise<T>;
19
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamPromise = void 0;
4
+ /**
5
+ *
6
+ */
7
+ const stream_1 = require("stream");
8
+ /**
9
+ *
10
+ */
11
+ class StreamPromise extends Promise {
12
+ stream() {
13
+ // dummy
14
+ return new stream_1.Duplex();
15
+ }
16
+ static create(builder) {
17
+ const { stream, promise } = builder();
18
+ const streamPromise = new StreamPromise((resolve, reject) => {
19
+ promise.then(resolve, reject);
20
+ });
21
+ streamPromise.stream = () => stream;
22
+ return streamPromise;
23
+ }
24
+ }
25
+ exports.StreamPromise = StreamPromise;
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Duplex, Readable, Writable } from 'stream';
4
+ export declare function createLazyStream(): {
5
+ stream: Duplex;
6
+ setStream: (str: Duplex) => void;
7
+ };
8
+ export declare function readAll(rs: Readable, encoding?: BufferEncoding): Promise<string>;
9
+ export declare function concatStreamsAsDuplex(ws: Writable, rs: Readable, opts?: {
10
+ writableObjectMode?: boolean;
11
+ readableObjectMode?: boolean;
12
+ }): Duplex;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.concatStreamsAsDuplex = exports.readAll = exports.createLazyStream = void 0;
4
+ const stream_1 = require("stream");
5
+ function createLazyStream() {
6
+ const ins = new stream_1.PassThrough();
7
+ const outs = new stream_1.PassThrough();
8
+ const stream = concatStreamsAsDuplex(ins, outs);
9
+ let piped = false;
10
+ const setStream = (str) => {
11
+ if (piped) {
12
+ throw new Error('stream is already piped to actual stream');
13
+ }
14
+ piped = true;
15
+ ins.pipe(str).pipe(outs);
16
+ };
17
+ return { stream, setStream };
18
+ }
19
+ exports.createLazyStream = createLazyStream;
20
+ class MemoryWriteStream extends stream_1.Writable {
21
+ _buf;
22
+ constructor() {
23
+ super();
24
+ this._buf = Buffer.alloc(0);
25
+ }
26
+ _write(chunk, encoding, callback) {
27
+ this._buf = Buffer.concat([this._buf, chunk]);
28
+ callback();
29
+ }
30
+ _writev(data, callback) {
31
+ this._buf = Buffer.concat([this._buf, ...data.map(({ chunk }) => chunk)]);
32
+ callback();
33
+ }
34
+ toString(encoding = 'utf-8') {
35
+ return this._buf.toString(encoding);
36
+ }
37
+ }
38
+ async function readAll(rs, encoding = 'utf-8') {
39
+ return new Promise((resolve, reject) => {
40
+ const ws = new MemoryWriteStream();
41
+ rs.on('error', reject)
42
+ .pipe(ws)
43
+ .on('finish', () => resolve(ws.toString(encoding)));
44
+ });
45
+ }
46
+ exports.readAll = readAll;
47
+ class DuplexifiedStream extends stream_1.Duplex {
48
+ _writable;
49
+ _readable;
50
+ constructor(ws, rs, opts = {}) {
51
+ super({
52
+ writableObjectMode: opts.writableObjectMode ?? ws.writableObjectMode,
53
+ readableObjectMode: opts.readableObjectMode ?? rs.readableObjectMode,
54
+ });
55
+ this._writable = ws;
56
+ this._readable = rs;
57
+ ws.once('finish', () => {
58
+ this.end();
59
+ });
60
+ this.once('finish', () => {
61
+ ws.end();
62
+ });
63
+ rs.on('readable', () => {
64
+ this._readStream();
65
+ });
66
+ rs.once('end', () => {
67
+ this.push(null);
68
+ });
69
+ ws.on('error', (err) => this.emit('error', err));
70
+ rs.on('error', (err) => this.emit('error', err));
71
+ }
72
+ _write(chunk, encoding, callback) {
73
+ this._writable.write(chunk, encoding, callback);
74
+ }
75
+ _read(n) {
76
+ this._readStream(n);
77
+ }
78
+ _readStream(n) {
79
+ let data;
80
+ while ((data = this._readable.read(n)) !== null) {
81
+ this.push(data);
82
+ }
83
+ }
84
+ }
85
+ function concatStreamsAsDuplex(ws, rs, opts) {
86
+ return new DuplexifiedStream(ws, rs, opts);
87
+ }
88
+ exports.concatStreamsAsDuplex = concatStreamsAsDuplex;