@jetstreamapp/soql-parser-js 6.1.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/README.md +2 -3
- 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 +12 -20
- 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
package/dist/src/utils.js
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getWhereValue = exports.isArrayOperator = exports.isGroupByFn = exports.isGroupByField = exports.isOrderByFn = exports.isOrderByField = exports.isValueQueryCondition = exports.isNegationCondition = exports.isValueFunctionCondition = exports.isValueWithDateNLiteralCondition = exports.isValueWithDateLiteralCondition = exports.isValueCondition = exports.isWhereOrHavingClauseWithRightCondition = exports.isHavingClauseWithRightCondition = exports.isWhereClauseWithRightCondition = exports.isFieldSubquery = exports.isSubquery = exports.isComposeFieldTypeof = exports.isComposeFieldSubquery = exports.isComposeFieldRelationship = exports.isComposeFieldFunction = exports.isComposeField = exports.hasAlias = exports.isNestedParamAggregateFunction = exports.getParams = exports.generateParens = exports.pad = exports.getAsArrayStr = exports.getLastItem = exports.getIfTrue = exports.get = exports.isNil = exports.isObject = exports.isBoolean = exports.isNumber = exports.isStringArray = exports.isString = exports.isSubqueryFromFlag = exports.isToken = void 0;
|
|
4
|
-
function isToken(val) {
|
|
5
|
-
val = Array.isArray(val) ? val[0] : val;
|
|
6
|
-
return val.image && true;
|
|
7
|
-
}
|
|
8
|
-
exports.isToken = isToken;
|
|
9
|
-
function isSubqueryFromFlag(val, isSubquery) {
|
|
10
|
-
return isSubquery;
|
|
11
|
-
}
|
|
12
|
-
exports.isSubqueryFromFlag = isSubqueryFromFlag;
|
|
13
|
-
function isString(val) {
|
|
14
|
-
return typeof val === 'string';
|
|
15
|
-
}
|
|
16
|
-
exports.isString = isString;
|
|
17
|
-
function isStringArray(val) {
|
|
18
|
-
if (!val) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
return val.every(item => isString(item));
|
|
22
|
-
}
|
|
23
|
-
exports.isStringArray = isStringArray;
|
|
24
|
-
function isNumber(val) {
|
|
25
|
-
return Number.isFinite(val);
|
|
26
|
-
}
|
|
27
|
-
exports.isNumber = isNumber;
|
|
28
|
-
function isBoolean(val) {
|
|
29
|
-
return typeof val === typeof true;
|
|
30
|
-
}
|
|
31
|
-
exports.isBoolean = isBoolean;
|
|
32
|
-
function isObject(val) {
|
|
33
|
-
return val instanceof Object;
|
|
34
|
-
}
|
|
35
|
-
exports.isObject = isObject;
|
|
36
|
-
function isNil(val) {
|
|
37
|
-
return val === null || val === undefined;
|
|
38
|
-
}
|
|
39
|
-
exports.isNil = isNil;
|
|
40
|
-
function get(val, suffix, prefix) {
|
|
41
|
-
return isNil(val) ? '' : `${prefix || ''}${val}${suffix || ''}`;
|
|
42
|
-
}
|
|
43
|
-
exports.get = get;
|
|
44
|
-
function getIfTrue(val, returnStr) {
|
|
45
|
-
return isBoolean(val) && val ? returnStr : '';
|
|
46
|
-
}
|
|
47
|
-
exports.getIfTrue = getIfTrue;
|
|
48
|
-
function getLastItem(arr) {
|
|
49
|
-
return arr[arr.length - 1];
|
|
50
|
-
}
|
|
51
|
-
exports.getLastItem = getLastItem;
|
|
52
|
-
function getAsArrayStr(val, alwaysParens = false) {
|
|
53
|
-
if (Array.isArray(val)) {
|
|
54
|
-
if (val.length > 0) {
|
|
55
|
-
return `(${val.join(', ')})`;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return alwaysParens ? '()' : '';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
return alwaysParens ? `(${val || ''})` : val || '';
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.getAsArrayStr = getAsArrayStr;
|
|
66
|
-
function pad(val, len, left = 0) {
|
|
67
|
-
let leftPad = left > 0 ? new Array(left).fill(' ').join('') : '';
|
|
68
|
-
if (val.length > len) {
|
|
69
|
-
return `${leftPad}${val}`;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
return `${leftPad}${val}${new Array(len - val.length).fill(' ').join('')}`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.pad = pad;
|
|
76
|
-
function generateParens(count, character, joinCharacter = '') {
|
|
77
|
-
return isNumber(count) && count > 0 ? new Array(count).fill(character).join(joinCharacter) : '';
|
|
78
|
-
}
|
|
79
|
-
exports.generateParens = generateParens;
|
|
80
|
-
/**
|
|
81
|
-
* Gets params from a FieldFunctionExpression. If there are multiple nested functions as multiple parameters
|
|
82
|
-
* within another function, only the first argument will be considered.
|
|
83
|
-
* @param functionFieldExp
|
|
84
|
-
* @returns params
|
|
85
|
-
*/
|
|
86
|
-
function getParams(functionFieldExp) {
|
|
87
|
-
if (!functionFieldExp.parameters || functionFieldExp.parameters.length === 0) {
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
if (isStringArray(functionFieldExp.parameters)) {
|
|
91
|
-
return functionFieldExp.parameters;
|
|
92
|
-
}
|
|
93
|
-
if (isString(functionFieldExp.parameters[0])) {
|
|
94
|
-
return [functionFieldExp.parameters[0]];
|
|
95
|
-
}
|
|
96
|
-
return getParams(functionFieldExp.parameters[0]);
|
|
97
|
-
}
|
|
98
|
-
exports.getParams = getParams;
|
|
99
|
-
function isNestedParamAggregateFunction(functionFieldExp) {
|
|
100
|
-
if (!functionFieldExp.parameters || functionFieldExp.parameters.length === 0) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
const parameter = functionFieldExp.parameters[0];
|
|
104
|
-
if (isString(parameter)) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return !!parameter.isAggregateFn;
|
|
108
|
-
}
|
|
109
|
-
exports.isNestedParamAggregateFunction = isNestedParamAggregateFunction;
|
|
110
|
-
function hasAlias(value) {
|
|
111
|
-
return value && !isNil(value.alias);
|
|
112
|
-
}
|
|
113
|
-
exports.hasAlias = hasAlias;
|
|
114
|
-
function isComposeField(input) {
|
|
115
|
-
return isString(input.field) && !Array.isArray(input.relationships) && !Array.isArray(input.conditions);
|
|
116
|
-
}
|
|
117
|
-
exports.isComposeField = isComposeField;
|
|
118
|
-
function isComposeFieldFunction(input) {
|
|
119
|
-
return !isNil(input.functionName || input.fn);
|
|
120
|
-
}
|
|
121
|
-
exports.isComposeFieldFunction = isComposeFieldFunction;
|
|
122
|
-
function isComposeFieldRelationship(input) {
|
|
123
|
-
return isString(input.field) && Array.isArray(input.relationships);
|
|
124
|
-
}
|
|
125
|
-
exports.isComposeFieldRelationship = isComposeFieldRelationship;
|
|
126
|
-
function isComposeFieldSubquery(input) {
|
|
127
|
-
return !isNil(input.subquery);
|
|
128
|
-
}
|
|
129
|
-
exports.isComposeFieldSubquery = isComposeFieldSubquery;
|
|
130
|
-
function isComposeFieldTypeof(input) {
|
|
131
|
-
return isString(input.field) && Array.isArray(input.conditions);
|
|
132
|
-
}
|
|
133
|
-
exports.isComposeFieldTypeof = isComposeFieldTypeof;
|
|
134
|
-
function isSubquery(query) {
|
|
135
|
-
return isString(query.relationshipName);
|
|
136
|
-
}
|
|
137
|
-
exports.isSubquery = isSubquery;
|
|
138
|
-
function isFieldSubquery(value) {
|
|
139
|
-
return !!value && !!value.type && value.type === 'FieldSubquery';
|
|
140
|
-
}
|
|
141
|
-
exports.isFieldSubquery = isFieldSubquery;
|
|
142
|
-
function isWhereClauseWithRightCondition(value) {
|
|
143
|
-
return !!value && !!value.operator && !!value.right;
|
|
144
|
-
}
|
|
145
|
-
exports.isWhereClauseWithRightCondition = isWhereClauseWithRightCondition;
|
|
146
|
-
function isHavingClauseWithRightCondition(value) {
|
|
147
|
-
return !!value && !!value.operator && !!value.right;
|
|
148
|
-
}
|
|
149
|
-
exports.isHavingClauseWithRightCondition = isHavingClauseWithRightCondition;
|
|
150
|
-
function isWhereOrHavingClauseWithRightCondition(value) {
|
|
151
|
-
return !!value && !!value.operator && !!value.right;
|
|
152
|
-
}
|
|
153
|
-
exports.isWhereOrHavingClauseWithRightCondition = isWhereOrHavingClauseWithRightCondition;
|
|
154
|
-
function isValueCondition(value) {
|
|
155
|
-
return value && isString(value.field) && isString(value.operator) && !isNil(value.value);
|
|
156
|
-
}
|
|
157
|
-
exports.isValueCondition = isValueCondition;
|
|
158
|
-
function isValueWithDateLiteralCondition(value) {
|
|
159
|
-
return (value &&
|
|
160
|
-
isString(value.field) &&
|
|
161
|
-
isString(value.operator) &&
|
|
162
|
-
!isNil(value.value) &&
|
|
163
|
-
(value.literalType === 'DATE_LITERAL' || (Array.isArray(value.literalType) && value.literalType[0] === 'DATE_LITERAL')));
|
|
164
|
-
}
|
|
165
|
-
exports.isValueWithDateLiteralCondition = isValueWithDateLiteralCondition;
|
|
166
|
-
function isValueWithDateNLiteralCondition(value) {
|
|
167
|
-
return value && isString(value.field) && isString(value.operator) && !isNil(value.value) && !isNil(value.dateLiteralVariable);
|
|
168
|
-
}
|
|
169
|
-
exports.isValueWithDateNLiteralCondition = isValueWithDateNLiteralCondition;
|
|
170
|
-
function isValueFunctionCondition(value) {
|
|
171
|
-
return value && !isNil(value.fn) && isString(value.operator) && !isNil(value.value);
|
|
172
|
-
}
|
|
173
|
-
exports.isValueFunctionCondition = isValueFunctionCondition;
|
|
174
|
-
function isNegationCondition(value) {
|
|
175
|
-
return value && isNumber(value.openParen) && isNil(value.operator) && isNil(value.field) && isNil(value.fn) && isNil(value.closeParen);
|
|
176
|
-
}
|
|
177
|
-
exports.isNegationCondition = isNegationCondition;
|
|
178
|
-
function isValueQueryCondition(value) {
|
|
179
|
-
return value && isString(value.field) && isString(value.operator) && !isNil(value.valueQuery) && isNil(value.value);
|
|
180
|
-
}
|
|
181
|
-
exports.isValueQueryCondition = isValueQueryCondition;
|
|
182
|
-
function isOrderByField(value) {
|
|
183
|
-
return value && !isNil(value.field);
|
|
184
|
-
}
|
|
185
|
-
exports.isOrderByField = isOrderByField;
|
|
186
|
-
function isOrderByFn(value) {
|
|
187
|
-
return value && !isNil(value.fn);
|
|
188
|
-
}
|
|
189
|
-
exports.isOrderByFn = isOrderByFn;
|
|
190
|
-
function isGroupByField(value) {
|
|
191
|
-
return value && !isNil(value.field);
|
|
192
|
-
}
|
|
193
|
-
exports.isGroupByField = isGroupByField;
|
|
194
|
-
function isGroupByFn(value) {
|
|
195
|
-
return value && !isNil(value.fn);
|
|
196
|
-
}
|
|
197
|
-
exports.isGroupByFn = isGroupByFn;
|
|
198
|
-
function isArrayOperator(operator) {
|
|
199
|
-
return ['IN', 'NOT IN', 'INCLUDES', 'EXCLUDES'].includes(operator);
|
|
200
|
-
}
|
|
201
|
-
exports.isArrayOperator = isArrayOperator;
|
|
202
|
-
function getWhereValue(value, literalType, operator) {
|
|
203
|
-
if (isNil(literalType)) {
|
|
204
|
-
return value;
|
|
205
|
-
}
|
|
206
|
-
// Ensure that we process as an array for array type operators
|
|
207
|
-
if (operator && literalType !== 'APEX_BIND_VARIABLE' && isArrayOperator(operator) && !Array.isArray(value)) {
|
|
208
|
-
value = [value];
|
|
209
|
-
literalType = Array.isArray(literalType) ? literalType : [literalType];
|
|
210
|
-
}
|
|
211
|
-
if (Array.isArray(literalType) && Array.isArray(value)) {
|
|
212
|
-
return value.map((val, i) => {
|
|
213
|
-
return whereValueHelper(val, literalType?.[i]);
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
// This path should never hit, but on the off chance that literal type is an array and value is a string
|
|
218
|
-
// then the first literal type is considered
|
|
219
|
-
if (Array.isArray(literalType)) {
|
|
220
|
-
literalType = literalType[0];
|
|
221
|
-
}
|
|
222
|
-
switch (literalType) {
|
|
223
|
-
case 'STRING': {
|
|
224
|
-
if (Array.isArray(value)) {
|
|
225
|
-
return value.filter(Boolean).map(val => (isString(val) && val.startsWith("'") ? val : `'${val ?? ''}'`));
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
value = String(value ?? '');
|
|
229
|
-
return isString(value) && value.startsWith("'") ? value : `'${value ?? ''}'`;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
case 'APEX_BIND_VARIABLE': {
|
|
233
|
-
return `:${value}`;
|
|
234
|
-
}
|
|
235
|
-
default: {
|
|
236
|
-
return value;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
exports.getWhereValue = getWhereValue;
|
|
242
|
-
function whereValueHelper(value, literalType) {
|
|
243
|
-
switch (literalType) {
|
|
244
|
-
case 'STRING': {
|
|
245
|
-
return isString(value) && value.startsWith("'") ? value : `'${value ?? ''}'`;
|
|
246
|
-
}
|
|
247
|
-
default: {
|
|
248
|
-
return value;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|