@genesislcap/foundation-criteria 15.64.1 → 15.65.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.
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { Expression } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Escapes a string for the inside of a single-quoted criteria literal (`'...'`): `\` and `'`,
|
|
4
|
+
* which would otherwise end or break the literal, and line breaks, which a single-quoted Groovy
|
|
5
|
+
* string can't hold raw.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Single quotes rather than double: a double-quoted string is a GString, which GSF's criteria
|
|
9
|
+
* validator rejects (and a `$` in it starts interpolation).
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const escapeCriteriaString: (value: string) => string;
|
|
2
14
|
/**
|
|
3
15
|
* Functions to to serialise an Expression to a string
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* For a string, number, boolean or null value, every serialiser but the deprecated `endsWith`
|
|
19
|
+
* emits criteria GSF's criteria validator accepts: `Expr` calls and field methods are limited to
|
|
20
|
+
* its whitelist, and a string is a single-quoted literal. Other values go in as they are: a
|
|
21
|
+
* `valueGetter`'s result and a function value's are not quoted, and an array is joined with
|
|
22
|
+
* commas, which GSF can't parse (it has no list syntax).
|
|
23
|
+
*
|
|
24
|
+
* `contains` is a case-sensitive substring match (`FIELD.contains('x')`, the same as
|
|
25
|
+
* `fieldContains`). Unlike `containsIgnoreCase` it isn't null-safe: on a row whose field is null
|
|
26
|
+
* the call throws, and GSF then counts the whole criteria as not matching that row, even across
|
|
27
|
+
* `||` or under a negation. The whitelist has no null-safe case-sensitive match, so use
|
|
28
|
+
* `containsIgnoreCase` for a field that can be null. `NOT` is a negated equality
|
|
29
|
+
* (`FIELD != x`, the same as `NE`).
|
|
30
|
+
*
|
|
4
31
|
* @public
|
|
5
32
|
*/
|
|
6
33
|
export declare const Serialisers: {
|
|
@@ -19,6 +46,11 @@ export declare const Serialisers: {
|
|
|
19
46
|
fieldContains: (e: Expression) => string;
|
|
20
47
|
containsIgnoreCase: (e: Expression) => string;
|
|
21
48
|
startsWith: (e: Expression) => string;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated GSF 8.14 and later reject `FIELD.endsWith(...)` ("Field method FIELD.endsWith
|
|
51
|
+
* is not supported"), and its criteria whitelist has no suffix match to use instead. Use
|
|
52
|
+
* `startsWith`, `containsIgnoreCase` or `contains`.
|
|
53
|
+
*/
|
|
22
54
|
endsWith: (e: Expression) => string;
|
|
23
55
|
dateIsToday: (e: Expression) => string;
|
|
24
56
|
dateIsEqual: (e: Expression) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialisers.d.ts","sourceRoot":"","sources":["../../src/serialisers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"serialisers.d.ts","sourceRoot":"","sources":["../../src/serialisers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,MAC0C,CAAC;AAwBhG;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW;aACb,UAAU;YACX,UAAU;aAxBC,UAAU;YA0BrB,UAAU;YACV,UAAU;YACV,UAAU;YACV,UAAU;YA7BC,UAAU;YA+BrB,UAAU;gBACN,UAAU;0BACA,UAAU;kBAhCR,UAAU;uBAAV,UAAU;4BAmCV,UAAU;oBAClB,UAAU;IAC1B;;;;OAIG;kBACW,UAAU;qBACP,UAAU;qBACV,UAAU;4BACH,UAAU;yBACb,UAAU;gCACH,UAAU;6BAEb,UAAU;CACpC,CAAC"}
|
package/dist/esm/serialisers.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { Operator } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Escapes a string for the inside of a single-quoted criteria literal (`'...'`): `\` and `'`,
|
|
4
|
+
* which would otherwise end or break the literal, and line breaks, which a single-quoted Groovy
|
|
5
|
+
* string can't hold raw.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Single quotes rather than double: a double-quoted string is a GString, which GSF's criteria
|
|
9
|
+
* validator rejects (and a `$` in it starts interpolation).
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export const escapeCriteriaString = (value) => value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
|
14
|
+
const quote = (value) => `'${escapeCriteriaString(value)}'`;
|
|
2
15
|
const getValue = (e) => {
|
|
3
16
|
const { value } = e;
|
|
4
17
|
if (e.valueGetter) {
|
|
@@ -11,31 +24,53 @@ const getValue = (e) => {
|
|
|
11
24
|
return value.join(',');
|
|
12
25
|
}
|
|
13
26
|
else if (typeof value === 'string') {
|
|
14
|
-
return
|
|
27
|
+
return quote(value);
|
|
15
28
|
}
|
|
16
29
|
return value;
|
|
17
30
|
};
|
|
18
31
|
const createSerialiser = (operator) => (e) => `${e.field} ${operator} ${getValue(e)}`;
|
|
32
|
+
const notEqual = (e) => createSerialiser(Operator.NE)(e);
|
|
33
|
+
const fieldContains = (e) => `${e.field}.contains(${getValue(e)})`;
|
|
19
34
|
/**
|
|
20
35
|
* Functions to to serialise an Expression to a string
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* For a string, number, boolean or null value, every serialiser but the deprecated `endsWith`
|
|
39
|
+
* emits criteria GSF's criteria validator accepts: `Expr` calls and field methods are limited to
|
|
40
|
+
* its whitelist, and a string is a single-quoted literal. Other values go in as they are: a
|
|
41
|
+
* `valueGetter`'s result and a function value's are not quoted, and an array is joined with
|
|
42
|
+
* commas, which GSF can't parse (it has no list syntax).
|
|
43
|
+
*
|
|
44
|
+
* `contains` is a case-sensitive substring match (`FIELD.contains('x')`, the same as
|
|
45
|
+
* `fieldContains`). Unlike `containsIgnoreCase` it isn't null-safe: on a row whose field is null
|
|
46
|
+
* the call throws, and GSF then counts the whole criteria as not matching that row, even across
|
|
47
|
+
* `||` or under a negation. The whitelist has no null-safe case-sensitive match, so use
|
|
48
|
+
* `containsIgnoreCase` for a field that can be null. `NOT` is a negated equality
|
|
49
|
+
* (`FIELD != x`, the same as `NE`).
|
|
50
|
+
*
|
|
21
51
|
* @public
|
|
22
52
|
*/
|
|
23
53
|
export const Serialisers = {
|
|
24
54
|
AND: (e) => createSerialiser(Operator.AND)(e),
|
|
25
55
|
OR: (e) => createSerialiser(Operator.OR)(e),
|
|
26
|
-
NOT:
|
|
56
|
+
NOT: notEqual,
|
|
27
57
|
GT: (e) => createSerialiser(Operator.GT)(e),
|
|
28
58
|
GE: (e) => createSerialiser(Operator.GE)(e),
|
|
29
59
|
LT: (e) => createSerialiser(Operator.LT)(e),
|
|
30
60
|
LE: (e) => createSerialiser(Operator.LE)(e),
|
|
31
|
-
NE:
|
|
61
|
+
NE: notEqual,
|
|
32
62
|
EQ: (e) => createSerialiser(Operator.EQ)(e),
|
|
33
63
|
equals: (e) => `${e.field}.equals(${getValue(e)})`,
|
|
34
64
|
equalsIgnoreCase: (e) => `${e.field}.equalsIgnoreCase(${getValue(e)})`,
|
|
35
|
-
contains:
|
|
36
|
-
fieldContains
|
|
65
|
+
contains: fieldContains,
|
|
66
|
+
fieldContains,
|
|
37
67
|
containsIgnoreCase: (e) => `Expr.containsIgnoreCase(${e.field}, ${getValue(e)})`,
|
|
38
68
|
startsWith: (e) => `${e.field}.startsWith(${getValue(e)})`,
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated GSF 8.14 and later reject `FIELD.endsWith(...)` ("Field method FIELD.endsWith
|
|
71
|
+
* is not supported"), and its criteria whitelist has no suffix match to use instead. Use
|
|
72
|
+
* `startsWith`, `containsIgnoreCase` or `contains`.
|
|
73
|
+
*/
|
|
39
74
|
endsWith: (e) => `${e.field}.endsWith(${getValue(e)})`,
|
|
40
75
|
dateIsToday: (e) => `Expr.dateIsToday(${e.field})`,
|
|
41
76
|
dateIsEqual: (e) => `Expr.dateIsEqual(${e.field}, ${getValue(e)})`,
|
|
@@ -807,6 +807,47 @@
|
|
|
807
807
|
},
|
|
808
808
|
"implementsTokenRanges": []
|
|
809
809
|
},
|
|
810
|
+
{
|
|
811
|
+
"kind": "Function",
|
|
812
|
+
"canonicalReference": "@genesislcap/foundation-criteria!escapeCriteriaString:function(1)",
|
|
813
|
+
"docComment": "/**\n * Escapes a string for the inside of a single-quoted criteria literal (`'...'`): `\\` and `'`, which would otherwise end or break the literal, and line breaks, which a single-quoted Groovy string can't hold raw.\n *\n * @remarks\n *\n * Single quotes rather than double: a double-quoted string is a GString, which GSF's criteria validator rejects (and a `$` in it starts interpolation).\n *\n * @public\n */\n",
|
|
814
|
+
"excerptTokens": [
|
|
815
|
+
{
|
|
816
|
+
"kind": "Content",
|
|
817
|
+
"text": "escapeCriteriaString: (value: "
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
"kind": "Content",
|
|
821
|
+
"text": "string"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"kind": "Content",
|
|
825
|
+
"text": ") => "
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
"kind": "Content",
|
|
829
|
+
"text": "string"
|
|
830
|
+
}
|
|
831
|
+
],
|
|
832
|
+
"fileUrlPath": "src/serialisers.ts",
|
|
833
|
+
"returnTypeTokenRange": {
|
|
834
|
+
"startIndex": 3,
|
|
835
|
+
"endIndex": 4
|
|
836
|
+
},
|
|
837
|
+
"releaseTag": "Public",
|
|
838
|
+
"overloadIndex": 1,
|
|
839
|
+
"parameters": [
|
|
840
|
+
{
|
|
841
|
+
"parameterName": "value",
|
|
842
|
+
"parameterTypeTokenRange": {
|
|
843
|
+
"startIndex": 1,
|
|
844
|
+
"endIndex": 2
|
|
845
|
+
},
|
|
846
|
+
"isOptional": false
|
|
847
|
+
}
|
|
848
|
+
],
|
|
849
|
+
"name": "escapeCriteriaString"
|
|
850
|
+
},
|
|
810
851
|
{
|
|
811
852
|
"kind": "Class",
|
|
812
853
|
"canonicalReference": "@genesislcap/foundation-criteria!ExpressionBuilder:class",
|
|
@@ -1760,7 +1801,7 @@
|
|
|
1760
1801
|
{
|
|
1761
1802
|
"kind": "Variable",
|
|
1762
1803
|
"canonicalReference": "@genesislcap/foundation-criteria!Serialisers:var",
|
|
1763
|
-
"docComment": "/**\n * Functions to to serialise an Expression to a string\n *\n * @public\n */\n",
|
|
1804
|
+
"docComment": "/**\n * Functions to to serialise an Expression to a string\n *\n * @remarks\n *\n * For a string, number, boolean or null value, every serialiser but the deprecated `endsWith` emits criteria GSF's criteria validator accepts: `Expr` calls and field methods are limited to its whitelist, and a string is a single-quoted literal. Other values go in as they are: a `valueGetter`'s result and a function value's are not quoted, and an array is joined with commas, which GSF can't parse (it has no list syntax).\n *\n * `contains` is a case-sensitive substring match (`FIELD.contains('x')`, the same as `fieldContains`). Unlike `containsIgnoreCase` it isn't null-safe: on a row whose field is null the call throws, and GSF then counts the whole criteria as not matching that row, even across `||` or under a negation. The whitelist has no null-safe case-sensitive match, so use `containsIgnoreCase` for a field that can be null. `NOT` is a negated equality (`FIELD != x`, the same as `NE`).\n *\n * @public\n */\n",
|
|
1764
1805
|
"excerptTokens": [
|
|
1765
1806
|
{
|
|
1766
1807
|
"kind": "Content",
|
|
@@ -81,6 +81,19 @@ export declare type CriteriaSegmentedControlOption = {
|
|
|
81
81
|
label: string;
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Escapes a string for the inside of a single-quoted criteria literal (`'...'`): `\` and `'`,
|
|
86
|
+
* which would otherwise end or break the literal, and line breaks, which a single-quoted Groovy
|
|
87
|
+
* string can't hold raw.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* Single quotes rather than double: a double-quoted string is a GString, which GSF's criteria
|
|
91
|
+
* validator rejects (and a `$` in it starts interpolation).
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export declare const escapeCriteriaString: (value: string) => string;
|
|
96
|
+
|
|
84
97
|
/**
|
|
85
98
|
* @internal
|
|
86
99
|
*/
|
|
@@ -201,6 +214,21 @@ export declare type Serialiser = (e: Expression) => string;
|
|
|
201
214
|
|
|
202
215
|
/**
|
|
203
216
|
* Functions to to serialise an Expression to a string
|
|
217
|
+
*
|
|
218
|
+
* @remarks
|
|
219
|
+
* For a string, number, boolean or null value, every serialiser but the deprecated `endsWith`
|
|
220
|
+
* emits criteria GSF's criteria validator accepts: `Expr` calls and field methods are limited to
|
|
221
|
+
* its whitelist, and a string is a single-quoted literal. Other values go in as they are: a
|
|
222
|
+
* `valueGetter`'s result and a function value's are not quoted, and an array is joined with
|
|
223
|
+
* commas, which GSF can't parse (it has no list syntax).
|
|
224
|
+
*
|
|
225
|
+
* `contains` is a case-sensitive substring match (`FIELD.contains('x')`, the same as
|
|
226
|
+
* `fieldContains`). Unlike `containsIgnoreCase` it isn't null-safe: on a row whose field is null
|
|
227
|
+
* the call throws, and GSF then counts the whole criteria as not matching that row, even across
|
|
228
|
+
* `||` or under a negation. The whitelist has no null-safe case-sensitive match, so use
|
|
229
|
+
* `containsIgnoreCase` for a field that can be null. `NOT` is a negated equality
|
|
230
|
+
* (`FIELD != x`, the same as `NE`).
|
|
231
|
+
*
|
|
204
232
|
* @public
|
|
205
233
|
*/
|
|
206
234
|
export declare const Serialisers: {
|
|
@@ -219,6 +247,11 @@ export declare const Serialisers: {
|
|
|
219
247
|
fieldContains: (e: Expression) => string;
|
|
220
248
|
containsIgnoreCase: (e: Expression) => string;
|
|
221
249
|
startsWith: (e: Expression) => string;
|
|
250
|
+
/**
|
|
251
|
+
* @deprecated GSF 8.14 and later reject `FIELD.endsWith(...)` ("Field method FIELD.endsWith
|
|
252
|
+
* is not supported"), and its criteria whitelist has no suffix match to use instead. Use
|
|
253
|
+
* `startsWith`, `containsIgnoreCase` or `contains`.
|
|
254
|
+
*/
|
|
222
255
|
endsWith: (e: Expression) => string;
|
|
223
256
|
dateIsToday: (e: Expression) => string;
|
|
224
257
|
dateIsEqual: (e: Expression) => string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-criteria",
|
|
3
3
|
"description": "Genesis Foundation UI Criteria Utils",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.65.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@genesislcap/foundation-testing": "15.
|
|
52
|
-
"@genesislcap/genx": "15.
|
|
53
|
-
"@genesislcap/ts-builder": "15.
|
|
54
|
-
"@genesislcap/uvu-playwright-builder": "15.
|
|
55
|
-
"@genesislcap/vite-builder": "15.
|
|
56
|
-
"@genesislcap/webpack-builder": "15.
|
|
51
|
+
"@genesislcap/foundation-testing": "15.65.0",
|
|
52
|
+
"@genesislcap/genx": "15.65.0",
|
|
53
|
+
"@genesislcap/ts-builder": "15.65.0",
|
|
54
|
+
"@genesislcap/uvu-playwright-builder": "15.65.0",
|
|
55
|
+
"@genesislcap/vite-builder": "15.65.0",
|
|
56
|
+
"@genesislcap/webpack-builder": "15.65.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@genesislcap/foundation-logger": "15.
|
|
60
|
-
"@genesislcap/foundation-utils": "15.
|
|
59
|
+
"@genesislcap/foundation-logger": "15.65.0",
|
|
60
|
+
"@genesislcap/foundation-utils": "15.65.0",
|
|
61
61
|
"@microsoft/fast-element": "1.14.0"
|
|
62
62
|
},
|
|
63
63
|
"repository": {
|