@jetstreamapp/soql-parser-js 6.0.0 → 6.2.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 +7 -1
- package/README.md +10 -11
- package/dist/cjs/index.js +143 -2
- package/dist/cli/index.js +148 -113
- package/dist/esm/index.js +143 -4
- package/dist/{cjs/src → types}/index.d.ts +1 -1
- package/package.json +15 -23
- package/dist/cjs/index.js.LICENSE.txt +0 -1
- package/dist/cjs/main.licenses.txt +0 -898
- package/dist/cjs/src/api/api-models.js +0 -2
- package/dist/cjs/src/api/public-utils.js +0 -175
- package/dist/cjs/src/composer/composer.js +0 -295
- package/dist/cjs/src/formatter/formatter.js +0 -236
- package/dist/cjs/src/index.js +0 -23
- package/dist/cjs/src/models.js +0 -2
- package/dist/cjs/src/parser/lexer.js +0 -954
- package/dist/cjs/src/parser/parser.js +0 -697
- package/dist/cjs/src/parser/visitor.js +0 -856
- package/dist/cjs/src/utils.js +0 -245
- package/dist/esm/api/api-models.js +0 -1
- package/dist/esm/api/public-utils.js +0 -153
- package/dist/esm/composer/composer.js +0 -273
- package/dist/esm/formatter/formatter.js +0 -223
- package/dist/esm/models.js +0 -1
- package/dist/esm/parser/lexer.js +0 -947
- package/dist/esm/parser/parser.js +0 -667
- package/dist/esm/parser/visitor.js +0 -823
- package/dist/esm/utils.js +0 -200
- package/dist/src/api/api-models.js +0 -2
- package/dist/src/api/public-utils.js +0 -203
- package/dist/src/composer/composer.js +0 -358
- package/dist/src/formatter/formatter.js +0 -263
- package/dist/src/index.js +0 -28
- package/dist/src/models.js +0 -2
- package/dist/src/parser/lexer.js +0 -997
- package/dist/src/parser/parser.js +0 -711
- package/dist/src/parser/visitor.js +0 -862
- package/dist/src/utils.js +0 -251
- /package/dist/{cjs/src → types}/api/api-models.d.ts +0 -0
- /package/dist/{cjs/src → types}/api/public-utils.d.ts +0 -0
- /package/dist/{cjs/src → types}/composer/composer.d.ts +0 -0
- /package/dist/{cjs/src → types}/formatter/formatter.d.ts +0 -0
- /package/dist/{cjs/src → types}/models.d.ts +0 -0
- /package/dist/{cjs/src → types}/parser/lexer.d.ts +0 -0
- /package/dist/{cjs/src → types}/parser/parser.d.ts +0 -0
- /package/dist/{cjs/src → types}/parser/visitor.d.ts +0 -0
- /package/dist/{cjs/src → types}/utils.d.ts +0 -0
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Formatter = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
var Formatter = (function () {
|
|
6
|
-
function Formatter(enabled, options) {
|
|
7
|
-
var _a, _b, _c, _d, _e;
|
|
8
|
-
this.currIndent = 1;
|
|
9
|
-
this.enabled = enabled;
|
|
10
|
-
this.options = {
|
|
11
|
-
numIndent: (_a = options.numIndent) !== null && _a !== void 0 ? _a : 1,
|
|
12
|
-
fieldMaxLineLength: (_b = options.fieldMaxLineLength) !== null && _b !== void 0 ? _b : 60,
|
|
13
|
-
fieldSubqueryParensOnOwnLine: (_c = options.fieldSubqueryParensOnOwnLine) !== null && _c !== void 0 ? _c : true,
|
|
14
|
-
whereClauseOperatorsIndented: true,
|
|
15
|
-
newLineAfterKeywords: (_d = options.newLineAfterKeywords) !== null && _d !== void 0 ? _d : false,
|
|
16
|
-
logging: (_e = options.logging) !== null && _e !== void 0 ? _e : false,
|
|
17
|
-
};
|
|
18
|
-
if (this.options.newLineAfterKeywords) {
|
|
19
|
-
this.options.fieldSubqueryParensOnOwnLine = true;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
Formatter.prototype.log = function (data) {
|
|
23
|
-
if (this.options.logging) {
|
|
24
|
-
console.log(data);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
Formatter.prototype.getIndent = function (additionalIndent) {
|
|
28
|
-
if (additionalIndent === void 0) { additionalIndent = 0; }
|
|
29
|
-
return this.repeatChar((this.currIndent + additionalIndent) * (this.options.numIndent || 1), '\t');
|
|
30
|
-
};
|
|
31
|
-
Formatter.prototype.repeatChar = function (numTimes, char) {
|
|
32
|
-
return new Array(numTimes).fill(char).join('');
|
|
33
|
-
};
|
|
34
|
-
Formatter.prototype.setSubquery = function (isSubquery) {
|
|
35
|
-
this.currIndent = isSubquery ? (this.currIndent += 1) : (this.currIndent -= 1);
|
|
36
|
-
};
|
|
37
|
-
Formatter.prototype.stepCurrIndex = function (num) {
|
|
38
|
-
this.currIndent += num;
|
|
39
|
-
};
|
|
40
|
-
Formatter.prototype.formatFields = function (fieldData) {
|
|
41
|
-
var _this = this;
|
|
42
|
-
function trimPrevSuffix(currIdx) {
|
|
43
|
-
if (fieldData.fields[currIdx - 1]) {
|
|
44
|
-
fieldData.fields[currIdx - 1].suffix = fieldData.fields[currIdx - 1].suffix.trim();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
fieldData.fields.forEach(function (field, i) {
|
|
48
|
-
field.suffix = fieldData.fields.length - 1 === i ? '' : ', ';
|
|
49
|
-
});
|
|
50
|
-
if (this.enabled) {
|
|
51
|
-
var lineLen_1 = 0;
|
|
52
|
-
var newLineAndIndentNext_1 = false;
|
|
53
|
-
fieldData.fields.forEach(function (field, i) {
|
|
54
|
-
if (field.isSubquery) {
|
|
55
|
-
trimPrevSuffix(i);
|
|
56
|
-
field.prefix = "\n".concat(_this.getIndent());
|
|
57
|
-
field.suffix = fieldData.fields.length - 1 === i ? '' : ', ';
|
|
58
|
-
lineLen_1 = 0;
|
|
59
|
-
newLineAndIndentNext_1 = true;
|
|
60
|
-
}
|
|
61
|
-
else if (Array.isArray(field.typeOfClause)) {
|
|
62
|
-
trimPrevSuffix(i);
|
|
63
|
-
field.prefix = "\n".concat(_this.getIndent());
|
|
64
|
-
newLineAndIndentNext_1 = true;
|
|
65
|
-
}
|
|
66
|
-
else if ((0, utils_1.isNumber)(_this.options.fieldMaxLineLength)) {
|
|
67
|
-
lineLen_1 += field.text.length + field.suffix.length;
|
|
68
|
-
if (lineLen_1 > _this.options.fieldMaxLineLength || newLineAndIndentNext_1) {
|
|
69
|
-
trimPrevSuffix(i);
|
|
70
|
-
if (!_this.options.newLineAfterKeywords || i > 0) {
|
|
71
|
-
field.prefix += "\n".concat(_this.getIndent());
|
|
72
|
-
}
|
|
73
|
-
lineLen_1 = 0;
|
|
74
|
-
newLineAndIndentNext_1 = false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
_this.log(field);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
Formatter.prototype.formatTyeOfField = function (text, typeOfClause) {
|
|
82
|
-
var _this = this;
|
|
83
|
-
if (this.enabled && this.options.newLineAfterKeywords) {
|
|
84
|
-
return typeOfClause
|
|
85
|
-
.map(function (part, i) {
|
|
86
|
-
if (i === 0) {
|
|
87
|
-
return part;
|
|
88
|
-
}
|
|
89
|
-
else if (i === typeOfClause.length - 1) {
|
|
90
|
-
return "".concat(_this.getIndent()).concat(part);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
return "".concat(_this.getIndent(), "\t").concat(part);
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
.join('\n');
|
|
97
|
-
}
|
|
98
|
-
return text;
|
|
99
|
-
};
|
|
100
|
-
Formatter.prototype.formatTypeofFieldCondition = function (condition) {
|
|
101
|
-
var output = '';
|
|
102
|
-
var fields = condition.fieldList.join(', ');
|
|
103
|
-
if (this.enabled && this.options.newLineAfterKeywords) {
|
|
104
|
-
var indent = this.getIndent();
|
|
105
|
-
output = "".concat(condition.type);
|
|
106
|
-
if (condition.objectType) {
|
|
107
|
-
output += "\n".concat(indent, "\t\t").concat(condition.objectType, "\n").concat(indent, "\tTHEN\n").concat(indent, "\t\t").concat(fields);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
output += "\n".concat(indent, "\t\t").concat(fields);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
output = condition.type;
|
|
115
|
-
if (condition.objectType) {
|
|
116
|
-
output += " ".concat(condition.objectType, " THEN ").concat(fields);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
output += " ".concat(fields);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return output;
|
|
123
|
-
};
|
|
124
|
-
Formatter.prototype.formatSubquery = function (queryStr, numTabs, incrementTabsWhereClauseOpIndent) {
|
|
125
|
-
if (numTabs === void 0) { numTabs = 2; }
|
|
126
|
-
if (incrementTabsWhereClauseOpIndent === void 0) { incrementTabsWhereClauseOpIndent = false; }
|
|
127
|
-
if (incrementTabsWhereClauseOpIndent) {
|
|
128
|
-
numTabs++;
|
|
129
|
-
}
|
|
130
|
-
var leftParen = '(';
|
|
131
|
-
var rightParen = ')';
|
|
132
|
-
if (this.enabled) {
|
|
133
|
-
if (this.options.fieldSubqueryParensOnOwnLine || this.options.newLineAfterKeywords) {
|
|
134
|
-
queryStr = queryStr.replace(/\n/g, "\n".concat(this.repeatChar(numTabs, '\t')));
|
|
135
|
-
leftParen = "(\n".concat(this.repeatChar(numTabs, '\t'));
|
|
136
|
-
rightParen = "\n".concat(this.repeatChar(numTabs - 1, '\t'), ")");
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
queryStr = queryStr.replace(/\n/g, '\n\t');
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return "".concat(leftParen).concat(queryStr).concat(rightParen);
|
|
143
|
-
};
|
|
144
|
-
Formatter.prototype.formatClause = function (clause) {
|
|
145
|
-
if (this.enabled) {
|
|
146
|
-
return this.options.newLineAfterKeywords ? "\n".concat(clause, "\n\t") : "\n".concat(clause);
|
|
147
|
-
}
|
|
148
|
-
return " ".concat(clause);
|
|
149
|
-
};
|
|
150
|
-
Formatter.prototype.formatText = function (text) {
|
|
151
|
-
return this.enabled && (this.options.newLineAfterKeywords || text.startsWith('\n')) ? text : " ".concat(text);
|
|
152
|
-
};
|
|
153
|
-
Formatter.prototype.formatWithIndent = function (text) {
|
|
154
|
-
return this.enabled ? "".concat(this.getIndent()).concat(text) : text;
|
|
155
|
-
};
|
|
156
|
-
Formatter.prototype.formatOrderByArray = function (groupBy) {
|
|
157
|
-
var _this = this;
|
|
158
|
-
if (this.enabled) {
|
|
159
|
-
var currLen_1 = 0;
|
|
160
|
-
var output_1 = '';
|
|
161
|
-
groupBy.forEach(function (token, i) {
|
|
162
|
-
var nextToken = groupBy[i + 1];
|
|
163
|
-
currLen_1 += token.length;
|
|
164
|
-
if (nextToken && (currLen_1 + nextToken.length > (_this.options.fieldMaxLineLength || 0) || _this.options.newLineAfterKeywords)) {
|
|
165
|
-
output_1 += "".concat(token, ",\n\t");
|
|
166
|
-
currLen_1 = 0;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
output_1 += "".concat(token).concat(nextToken ? ', ' : '');
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
return output_1;
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
return groupBy.join(', ');
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
Formatter.prototype.formatParens = function (count, character, leadingParenInline) {
|
|
179
|
-
if (leadingParenInline === void 0) { leadingParenInline = false; }
|
|
180
|
-
var output = '';
|
|
181
|
-
if ((0, utils_1.isNumber)(count) && count > 0) {
|
|
182
|
-
if (this.enabled) {
|
|
183
|
-
if (character === '(') {
|
|
184
|
-
for (var i = 0; i < count; i++) {
|
|
185
|
-
if (leadingParenInline && i === count - 1) {
|
|
186
|
-
output += '(';
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
if (i === 0) {
|
|
190
|
-
output += '(\n';
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
this.currIndent++;
|
|
194
|
-
output += "".concat(this.getIndent(), "(\n");
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
if (!leadingParenInline || count > 1) {
|
|
199
|
-
this.currIndent++;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
for (var i = count - 1; i >= 0; i--) {
|
|
204
|
-
if (leadingParenInline && i === count - 1) {
|
|
205
|
-
output += ')';
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
this.currIndent--;
|
|
209
|
-
output += "\n".concat(this.getIndent(), ")");
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
output += (0, utils_1.generateParens)(count, character);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return output;
|
|
219
|
-
};
|
|
220
|
-
Formatter.prototype.formatWhereClauseOperators = function (operator, whereClause, additionalIndent) {
|
|
221
|
-
if (additionalIndent === void 0) { additionalIndent = 0; }
|
|
222
|
-
var skipNewLineAndIndent = operator === 'NOT';
|
|
223
|
-
if (this.enabled && !skipNewLineAndIndent) {
|
|
224
|
-
return "\n".concat(this.getIndent(additionalIndent)).concat(operator, " ").concat(whereClause);
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
return "".concat(skipNewLineAndIndent ? '' : ' ').concat(operator, " ").concat(whereClause);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
Formatter.prototype.formatAddNewLine = function (alt, skipNewLineAndIndent) {
|
|
231
|
-
if (alt === void 0) { alt = ' '; }
|
|
232
|
-
return this.enabled && !skipNewLineAndIndent ? "\n" : alt;
|
|
233
|
-
};
|
|
234
|
-
return Formatter;
|
|
235
|
-
}());
|
|
236
|
-
exports.Formatter = Formatter;
|
package/dist/cjs/src/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isQueryValid = exports.parseQuery = void 0;
|
|
18
|
-
var visitor_1 = require("./parser/visitor");
|
|
19
|
-
Object.defineProperty(exports, "parseQuery", { enumerable: true, get: function () { return visitor_1.parseQuery; } });
|
|
20
|
-
Object.defineProperty(exports, "isQueryValid", { enumerable: true, get: function () { return visitor_1.isQueryValid; } });
|
|
21
|
-
__exportStar(require("./api/api-models"), exports);
|
|
22
|
-
__exportStar(require("./api/public-utils"), exports);
|
|
23
|
-
__exportStar(require("./composer/composer"), exports);
|
package/dist/cjs/src/models.js
DELETED