@sap/cds 5.5.5 → 5.6.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 +107 -1
- package/apis/services.d.ts +27 -1
- package/app/index.js +22 -11
- package/bin/build/buildTaskFactory.js +1 -1
- package/bin/build/provider/buildTaskProviderInternal.js +1 -1
- package/bin/build/provider/fiori/index.js +1 -1
- package/bin/build/provider/hana/2migration.js +8 -7
- package/bin/build/provider/java-cf/index.js +1 -1
- package/bin/deploy/to-hana/hana.js +1 -17
- package/common.cds +8 -0
- package/lib/compile/to/sql.js +22 -2
- package/lib/connect/bindings.js +2 -1
- package/lib/core/reflect.js +3 -1
- package/lib/env/index.js +175 -41
- package/lib/env/requires.js +16 -1
- package/lib/i18n/localize.js +31 -4
- package/lib/index.js +3 -3
- package/lib/log/format/kibana.js +6 -2
- package/lib/ql/Query.js +1 -0
- package/lib/ql/SELECT.js +15 -8
- package/lib/ql/Whereable.js +5 -0
- package/lib/req/context.js +13 -5
- package/lib/serve/Service-dispatch.js +8 -1
- package/lib/utils/axios.js +7 -0
- package/lib/utils/data.js +1 -1
- package/lib/utils/tests.js +1 -1
- package/libx/_runtime/audit/Service.js +18 -18
- package/libx/_runtime/audit/generic/personal/access.js +1 -1
- package/libx/_runtime/audit/generic/personal/modification.js +3 -2
- package/libx/_runtime/audit/generic/personal/utils.js +23 -63
- package/libx/_runtime/cds-services/adapter/odata-v4/Dispatcher.js +4 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/OData.js +37 -35
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js +3 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/error.js +5 -5
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +13 -7
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +84 -34
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/ExpressionToCQN.js +10 -4
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/applyToCQN.js +9 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/expandToCQN.js +8 -6
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/index.js +1 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/readToCQN.js +13 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/selectHelper.js +11 -95
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/ResourcePathParser.js +17 -11
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParser.js +2 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/to.js +6 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +3 -34
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/handlerUtils.js +3 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +48 -18
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/stream.js +10 -5
- package/libx/_runtime/cds-services/adapter/rest/handlers/operation.js +1 -1
- package/libx/_runtime/cds-services/adapter/rest/handlers/update.js +1 -1
- package/libx/_runtime/cds-services/adapter/rest/rest-to-cqn/index.js +1 -3
- package/libx/_runtime/cds-services/adapter/rest/utils/validation-checks.js +14 -19
- package/libx/_runtime/cds-services/services/utils/columns.js +6 -1
- package/libx/_runtime/cds-services/services/utils/compareJson.js +1 -8
- package/libx/_runtime/cds-services/services/utils/differ.js +7 -26
- package/libx/_runtime/cds-services/services/utils/handlerUtils.js +2 -4
- package/libx/_runtime/cds-services/util/assert.js +29 -13
- package/libx/_runtime/cds.js +2 -1
- package/libx/_runtime/common/aspects/Association.js +72 -0
- package/libx/_runtime/common/aspects/any.js +8 -45
- package/libx/_runtime/common/aspects/entity.js +0 -1
- package/libx/_runtime/common/aspects/relation.js +40 -0
- package/libx/_runtime/common/aspects/utils.js +73 -1
- package/libx/_runtime/common/auth/strategies/utils/uaa.js +1 -12
- package/libx/_runtime/common/composition/data.js +3 -2
- package/libx/_runtime/common/composition/delete.js +3 -1
- package/libx/_runtime/common/composition/tree.js +23 -18
- package/libx/_runtime/common/composition/utils.js +34 -8
- package/libx/_runtime/common/error/frontend.js +6 -1
- package/libx/_runtime/common/generic/auth.js +5 -9
- package/libx/_runtime/common/generic/crud.js +2 -2
- package/libx/_runtime/common/generic/etag.js +11 -8
- package/libx/_runtime/common/generic/input.js +3 -3
- package/libx/_runtime/common/generic/paging.js +9 -5
- package/libx/_runtime/common/generic/put.js +3 -2
- package/libx/_runtime/common/generic/sorting.js +3 -3
- package/libx/_runtime/common/generic/temporal.js +3 -3
- package/libx/_runtime/common/utils/cqn.js +20 -1
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +125 -139
- package/libx/_runtime/common/utils/csn.js +50 -52
- package/libx/_runtime/common/utils/foreignKeyPropagations.js +41 -176
- package/libx/_runtime/common/utils/generateOnCond.js +40 -70
- package/libx/_runtime/common/utils/{enrichWithKeysFromWhere.js → keys.js} +29 -28
- package/libx/_runtime/common/utils/postProcessing.js +3 -0
- package/libx/_runtime/common/utils/propagateForeignKeys.js +84 -0
- package/libx/_runtime/common/utils/resolveStructured.js +1 -1
- package/libx/_runtime/common/utils/resolveView.js +7 -5
- package/libx/_runtime/common/utils/rewriteAsterisks.js +94 -0
- package/libx/_runtime/common/utils/search2cqn4sql.js +9 -8
- package/libx/_runtime/common/utils/template.js +54 -46
- package/libx/_runtime/db/Service.js +9 -2
- package/libx/_runtime/db/expand/expandCQNToJoin.js +10 -24
- package/libx/_runtime/db/expand/rawToExpanded.js +2 -1
- package/libx/_runtime/db/generic/create.js +1 -0
- package/libx/_runtime/db/generic/input.js +7 -11
- package/libx/_runtime/db/generic/integrity.js +2 -2
- package/libx/_runtime/db/generic/rewrite.js +2 -5
- package/libx/_runtime/db/generic/update.js +1 -0
- package/libx/_runtime/db/query/read.js +9 -4
- package/libx/_runtime/db/sql-builder/SelectBuilder.js +7 -2
- package/libx/_runtime/db/sql-builder/annotations.js +1 -0
- package/libx/_runtime/db/utils/columns.js +14 -43
- package/libx/_runtime/fiori/generic/activate.js +3 -2
- package/libx/_runtime/fiori/generic/before.js +2 -2
- package/libx/_runtime/fiori/generic/cancel.js +3 -2
- package/libx/_runtime/fiori/generic/delete.js +3 -2
- package/libx/_runtime/fiori/generic/edit.js +2 -2
- package/libx/_runtime/fiori/generic/new.js +2 -2
- package/libx/_runtime/fiori/generic/patch.js +2 -2
- package/libx/_runtime/fiori/generic/prepare.js +2 -2
- package/libx/_runtime/fiori/generic/read.js +17 -63
- package/libx/_runtime/fiori/generic/readOverDraft.js +4 -4
- package/libx/_runtime/fiori/uiflex/extensibility/index.cds +15 -0
- package/libx/_runtime/fiori/uiflex/extensibility/index.js +148 -0
- package/libx/_runtime/fiori/uiflex/handler/transformREAD.js +119 -0
- package/libx/_runtime/fiori/uiflex/handler/transformRESULT.js +43 -0
- package/libx/_runtime/fiori/uiflex/handler/transformWRITE.js +62 -0
- package/libx/_runtime/fiori/uiflex/index.js +35 -0
- package/libx/_runtime/fiori/uiflex/utils.js +78 -0
- package/libx/_runtime/fiori/utils/handler.js +3 -13
- package/libx/_runtime/fiori/utils/where.js +6 -1
- package/libx/_runtime/hana/pool.js +12 -11
- package/libx/_runtime/hana/search2cqn4sql.js +34 -43
- package/libx/_runtime/hana/searchToContains.js +3 -3
- package/libx/_runtime/index.js +5 -2
- package/libx/_runtime/messaging/AMQPWebhookMessaging.js +1 -1
- package/libx/_runtime/messaging/common-utils/AMQPClient.js +9 -1
- package/libx/_runtime/messaging/common-utils/connections.js +11 -14
- package/libx/_runtime/messaging/common-utils/naming-conventions.js +1 -1
- package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +2 -1
- package/libx/_runtime/messaging/message-queuing.js +18 -0
- package/libx/_runtime/remote/Service.js +14 -2
- package/libx/_runtime/remote/utils/client-types.d.ts +7 -0
- package/libx/_runtime/remote/utils/client.js +117 -23
- package/libx/_runtime/sqlite/Service.js +2 -2
- package/libx/_runtime/sqlite/convertAssocToOneManaged.js +1 -3
- package/libx/gql/GraphQLAdapter.js +33 -0
- package/libx/gql/constants/adapter.js +69 -0
- package/libx/gql/constants/cds.js +18 -0
- package/libx/gql/constants/graphql.js +33 -0
- package/libx/gql/resolvers/crud/create.js +15 -0
- package/libx/gql/resolvers/crud/delete.js +24 -0
- package/libx/gql/resolvers/crud/index.js +6 -0
- package/libx/gql/resolvers/crud/read.js +25 -0
- package/libx/gql/resolvers/crud/update.js +31 -0
- package/libx/gql/resolvers/crud/utils/index.js +36 -0
- package/libx/gql/resolvers/field.js +5 -0
- package/libx/gql/resolvers/index.js +7 -0
- package/libx/gql/resolvers/mutation.js +23 -0
- package/libx/gql/resolvers/parse/ast/enrich.js +51 -0
- package/libx/gql/resolvers/parse/ast/fragment.js +11 -0
- package/libx/gql/resolvers/parse/ast/fromObject.js +39 -0
- package/libx/gql/resolvers/parse/ast/index.js +3 -0
- package/libx/gql/resolvers/parse/ast/meta.js +4 -0
- package/libx/gql/resolvers/parse/ast/variable.js +7 -0
- package/libx/gql/resolvers/parse/ast2cqn/columns.js +42 -0
- package/libx/gql/resolvers/parse/ast2cqn/entries.js +31 -0
- package/libx/gql/resolvers/parse/ast2cqn/index.js +8 -0
- package/libx/gql/resolvers/parse/ast2cqn/limit.js +6 -0
- package/libx/gql/resolvers/parse/ast2cqn/orderBy.js +24 -0
- package/libx/gql/resolvers/parse/ast2cqn/utils/index.js +3 -0
- package/libx/gql/resolvers/parse/ast2cqn/where.js +70 -0
- package/libx/gql/resolvers/parse/utils/index.js +8 -0
- package/libx/gql/resolvers/query.js +13 -0
- package/libx/gql/resolvers/root.js +34 -0
- package/libx/gql/schema/generate.js +18 -0
- package/libx/gql/schema/index.js +5 -0
- package/libx/gql/schema/mutation.js +76 -0
- package/libx/gql/schema/query.js +108 -0
- package/libx/gql/schema/typeDefMap.js +45 -0
- package/libx/gql/schema/utils/index.js +54 -0
- package/libx/gql/utils/index.js +12 -0
- package/libx/{_runtime/odata/cqn2odata.js → odata/cqn2odata/index.js} +39 -100
- package/libx/odata/index.js +80 -0
- package/libx/odata/odata2cqn/afterburner.js +170 -0
- package/libx/{_runtime/odata/odata2cqn.pegjs → odata/odata2cqn/grammar.pegjs} +102 -123
- package/libx/odata/odata2cqn/index.js +3 -0
- package/libx/odata/odata2cqn/parser.js +1 -0
- package/libx/odata/utils/index.js +64 -0
- package/libx/rest/RestAdapter.js +101 -0
- package/libx/rest/RestRequest.js +30 -0
- package/libx/rest/index.js +3 -0
- package/libx/rest/middleware/auth.js +22 -0
- package/libx/rest/middleware/content.js +15 -0
- package/libx/rest/middleware/create.js +40 -0
- package/libx/rest/middleware/delete.js +20 -0
- package/libx/rest/middleware/error.js +56 -0
- package/libx/rest/middleware/operation.js +39 -0
- package/libx/rest/middleware/parse.js +90 -0
- package/libx/rest/middleware/read.js +29 -0
- package/libx/rest/middleware/update.js +42 -0
- package/libx/rest/utils/data.js +65 -0
- package/package.json +4 -1
- package/server.js +20 -2
- package/libx/_runtime/cds-services/services/utils/diff.js +0 -53
- package/libx/_runtime/cds-services/util/auditlog.js +0 -247
- package/libx/_runtime/cds-services/util/xsenv.js +0 -51
- package/libx/_runtime/common/utils/backlinks.js +0 -83
- package/libx/_runtime/common/utils/rewriteAsterisk.js +0 -72
- package/libx/_runtime/odata/index.js +0 -55
- package/libx/_runtime/odata/odata2cqn.js +0 -1
- package/libx/_runtime/odata/readToCqn.js +0 -129
- package/libx/_runtime/remote/cqn2odata/index.js +0 -2
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const { cqn2odata, getSafeNumber: safeNumber } = require('./cqn2odata')
|
|
2
|
-
|
|
3
|
-
const strict = {
|
|
4
|
-
functions: {
|
|
5
|
-
contains: 1,
|
|
6
|
-
startswith: 1,
|
|
7
|
-
endswith: 1,
|
|
8
|
-
tolower: 1,
|
|
9
|
-
toupper: 1,
|
|
10
|
-
length: 1,
|
|
11
|
-
indexof: 1,
|
|
12
|
-
substring: 1,
|
|
13
|
-
trim: 1,
|
|
14
|
-
concat: 1,
|
|
15
|
-
year: 1,
|
|
16
|
-
month: 1,
|
|
17
|
-
day: 1,
|
|
18
|
-
hour: 1,
|
|
19
|
-
minute: 1,
|
|
20
|
-
second: 1,
|
|
21
|
-
time: 1,
|
|
22
|
-
now: 1
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let parser = require('./odata2cqn')
|
|
27
|
-
const odata = {
|
|
28
|
-
parse: {
|
|
29
|
-
url(url, o = {}) {
|
|
30
|
-
o = o === 'strict' ? { strict } : o.strict ? { ...o, strict } : o
|
|
31
|
-
|
|
32
|
-
const uri = decodeURIComponent(url)
|
|
33
|
-
let parsed = parser.parse(uri, { ...o, safeNumber })
|
|
34
|
-
|
|
35
|
-
if (typeof o.afterburner === 'function') parsed = o.afterburner(parsed)
|
|
36
|
-
return parsed
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
urlify: cqn2odata,
|
|
41
|
-
|
|
42
|
-
to: {
|
|
43
|
-
cqn: (url, o) => odata.parse(url, o),
|
|
44
|
-
url: (cqn, kind, model) => odata.urlify(cqn, kind, model)
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
genParser() {
|
|
48
|
-
const source = __filename.replace('index.js', 'odata2cqn.pegjs')
|
|
49
|
-
const grammar = require('fs').readFileSync(source, 'utf8')
|
|
50
|
-
parser = require('pegjs').generate(grammar)
|
|
51
|
-
return parser
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = odata
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function peg$subclass(t,r){function e(){this.constructor=t}e.prototype=r.prototype,t.prototype=new e}function peg$SyntaxError(t,r,e,n){this.message=t,this.expected=r,this.found=e,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(t,r){r=void 0!==r?r:{};var e,n={},s={ODataRelativeURI:we},u=we,a="/",c=ve("/",!1),o=ve("?",!1),i=ve("&",!1),f="$count",l=ve("$count",!1),h="$ref",p=ve("$ref",!1),A="$value",d=ve("$value",!1),g=ve("=",!1),v="$select=",b=ve("$select=",!1),m="$expand=",x=ve("$expand=",!1),C="$filter=",y=ve("$filter=",!1),$="$orderby=",w=ve("$orderby=",!1),E="$top=",S=ve("$top=",!1),z="$skip=",Z=ve("$skip=",!1),B="$search=",j=ve("$search=",!1),F="$count=",R=ve("$count=",!1),T="$apply=",L=ve("$apply=",!1),k=ve("*",!1),N=ve(";",!1),O=function(t){return t?[t]:[]},q=function(t,r){t.push({xpr:r})},_=function(t,r){t.push({val:r})},D=function(t,r,e){t.push(r,...e)},I=function(t,r){t.push(r)},M=function(t,r,e){t.push(r,...e)},U=":",G=ve(":",!1),H="any",J=ve("any",!1),K="all",P=ve("all",!1),Q=ve("asc",!1),V="desc",W=ve("desc",!1),X=/^[a-zA-Z]/,Y=be([["a","z"],["A","Z"]],!1,!1),tt=/^[a-zA-Z0-9\-]/,rt=be([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),et=/^[^&]/,nt=be(["&"],!0,!1),st=me("a comparison"),ut=ve("eq",!1),at=ve("ne",!1),ct=ve("lt",!1),ot=ve("gt",!1),it=ve("le",!1),ft=ve("ge",!1),lt=(ve("add",!1),ve("sub",!1),ve("mul",!1),ve("div",!1),ve("mod",!1),me("an operand")),ht=me("a reference"),pt=function(t,r){return r},At=function(t){return{val:t}},dt=ve("{",!1),gt=/^[^}]/,vt=be(["}"],!0,!1),bt=ve("}",!1),mt="[",xt=ve("[",!1),Ct="]",yt=ve("]",!1),$t=/^[^\]]/,wt=be(["]"],!0,!1),Et=me("a function call"),St=/^[a-z]/,zt=be([["a","z"]],!1,!1),Zt=function(t,r,e){return e},Bt=function(t,r,e){return Cn&&!(t in Cn.functions)&&function(t,r){throw r=void 0!==r?r:Ce(he,le),function(t,r){return new peg$SyntaxError(t,null,null,r)}(t,r)}("'"+t+"' is an unknown function in OData URL spec (strict mode)"),{func:t,args:[r,...e]}},jt=me("a boolean function"),Ft="contains",Rt=ve("contains",!1),Tt="endswith",Lt=ve("endswith",!1),kt="startswith",Nt=ve("startswith",!1),Ot=ve("NOT",!0),qt=ve("AND",!0),_t=ve("OR",!0),Dt="aggregate",It=ve("aggregate",!1),Mt="groupby",Ut=ve("groupby",!1),Gt="filter",Ht=ve("filter",!1),Jt="expand",Kt=ve("expand",!1),Pt="search",Qt=ve("search",!1),Vt="concat",Wt=ve("concat",!1),Xt="compute",Yt=ve("compute",!1),tr="bottompercent",rr=ve("bottompercent",!1),er="bottomsum",nr=ve("bottomsum",!1),sr="toppercent",ur=ve("toppercent",!1),ar="topsum",cr=ve("topsum",!1),or="with",ir=ve("with",!1),fr="from",lr=ve("from",!1),hr=ve("as",!1),pr="rollup",Ar=ve("rollup",!1),dr="$all",gr=ve("$all",!1),vr="topcount",br=ve("topcount",!1),mr="bottomcount",xr=ve("bottomcount",!1),Cr="identity",yr=ve("identity",!1),$r="true",wr=ve("true",!1),Er="false",Sr=ve("false",!1),zr=me("Edm.String"),Zr=ve("'",!1),Br="''",jr=ve("''",!1),Fr=/^[^']/,Rr=be(["'"],!0,!1),Tr='"',Lr=ve('"',!1),kr='\\"',Nr=ve('\\"',!1),Or=/^[^"]/,qr=be(['"'],!0,!1),_r=/^[+"-"a-zA-Z0-9"."]/,Dr=be(["+",['"','"'],["a","z"],["A","Z"],["0","9"],'"',".",'"'],!1,!1),Ir=/^[0-9]/,Mr=be([["0","9"]],!1,!1),Ur="-",Gr=ve("-",!1),Hr=ve("T",!1),Jr=ve(".",!1),Kr=ve("Z",!1),Pr=ve("+",!1),Qr=/^[+\-]/,Vr=be(["+","-"],!1,!1),Wr=ve("e",!1),Xr=/^[_a-zA-Z]/,Yr=be(["_",["a","z"],["A","Z"]],!1,!1),te=/^[_a-zA-Z0-9"."]/,re=be(["_",["a","z"],["A","Z"],["0","9"],'"',".",'"'],!1,!1),ee=/^[0-9a-zA-Z]/,ne=be([["0","9"],["a","z"],["A","Z"]],!1,!1),se=ve(",",!1),ue=ve("(",!1),ae=ve(")",!1),ce=me("optional whitespaces"),oe=/^[ \t\n]/,ie=be([" ","\t","\n"],!1,!1),fe=me("mandatory whitespaces"),le=0,he=0,pe=[{line:1,column:1}],Ae=0,de=[],ge=0;if("startRule"in r){if(!(r.startRule in s))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=s[r.startRule]}function ve(t,r){return{type:"literal",text:t,ignoreCase:r}}function be(t,r,e){return{type:"class",parts:t,inverted:r,ignoreCase:e}}function me(t){return{type:"other",description:t}}function xe(r){var e,n=pe[r];if(n)return n;for(e=r-1;!pe[e];)e--;for(n={line:(n=pe[e]).line,column:n.column};e<r;)10===t.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return pe[r]=n,n}function Ce(t,r){var e=xe(t),n=xe(r);return{start:{offset:t,line:e.line,column:e.column},end:{offset:r,line:n.line,column:n.column}}}function ye(t){le<Ae||(le>Ae&&(Ae=le,de=[]),de.push(t))}function $e(t,r,e){return new peg$SyntaxError(peg$SyntaxError.buildMessage(t,r),t,r,e)}function we(){var r,e,s,u,f,l,h,p,A,d,g,v,b,m;if(r=le,47===t.charCodeAt(le)?(e=a,le++):(e=n,0===ge&&ye(c)),e===n&&(e=null),e!==n)if(s=le,(u=Ee())!==n&&(he=s,u=void(wn=u)),(s=u)!==n){if(u=le,(f=bn())!==n)if(63===t.charCodeAt(le)?(l="?",le++):(l=n,0===ge&&ye(o)),l!==n)if((h=bn())!==n)if((p=ze())!==n){for(A=[],d=le,(g=bn())!==n?(38===t.charCodeAt(le)?(v="&",le++):(v=n,0===ge&&ye(i)),v!==n&&(b=bn())!==n&&(m=ze())!==n?d=g=[g,v,b,m]:(le=d,d=n)):(le=d,d=n);d!==n;)A.push(d),d=le,(g=bn())!==n?(38===t.charCodeAt(le)?(v="&",le++):(v=n,0===ge&&ye(i)),v!==n&&(b=bn())!==n&&(m=ze())!==n?d=g=[g,v,b,m]:(le=d,d=n)):(le=d,d=n);A!==n?u=f=[f,l,h,p,A]:(le=u,u=n)}else le=u,u=n;else le=u,u=n;else le=u,u=n;else le=u,u=n;u===n&&(u=null),u!==n&&(f=bn())!==n?(he=r,r=e=wn.columns?(delete wn.expand,delete wn.limit,delete wn.orderBy,{SELECT:wn}):(wn.expand&&(wn.columns=wn.expand,delete wn.expand),wn=Bn(wn),wn=zn(wn),wn.columns||delete wn.columns,{SELECT:wn})):(le=r,r=n)}else le=r,r=n;else le=r,r=n;return r}function Ee(){var r,e,s,u,o,i,g;return r=le,t.substr(le,6)===f?(e=f,le+=6):(e=n,0===ge&&ye(l)),e!==n&&(he=r,e={columns:[{args:["*"],as:"$count",func:"count"}]}),(r=e)===n&&(r=le,e=le,t.substr(le,4)===h?(s=h,le+=4):(s=n,0===ge&&ye(p)),s===n&&(t.substr(le,6)===A?(s=A,le+=6):(s=n,0===ge&&ye(d))),(e=s!==n?t.substring(e,le):s)!==n&&(he=r,g=e,e=!En.includes(g)&&{from:{ref:[g]}}),(r=e)===n&&(r=le,(e=pn())===n&&(e=Me()),e!==n?(s=le,(u=gn())!==n&&(o=Se())!==n&&(i=vn())!==n?s=u=[u,o,i]:(le=s,s=n),s===n&&(s=null),s!==n?(u=le,47===t.charCodeAt(le)?(o=a,le++):(o=n,0===ge&&ye(c)),o!==n&&(i=Ee())!==n?(he=u,u=o=i):(le=u,u=n),u===n&&(u=null),u!==n?(he=r,r=e=function(t,r,e){const n=[r?{id:t,where:r[1]}:yn?`${t.val||t}`:t];if(e&&e.from){const t=e.from.ref,[{val:r}]=t;r&&(n[n.length-1]={id:n[n.length-1],where:[t.shift()]}),n.push(...t)}const s={from:{ref:n}};return e&&(s.columns=e.columns),s}(e,s,u)):(le=r,r=n)):(le=r,r=n)):(le=r,r=n))),r}function Se(){var r,e,s,u,a,c,o;return r=le,(e=Me())!==n&&(he=r,e=[e]),(r=e)===n&&(r=le,(e=Ie())!==n&&bn()!==n?(61===t.charCodeAt(le)?(s="=",le++):(s=n,0===ge&&ye(g)),s!==n&&bn()!==n?((u=Me())===n&&(u=le,(a=fn())!==n&&(he=u,a={val:a}),u=a),u!==n?(a=le,(c=dn())!==n&&(o=Se())!==n?a=c=[c,o]:(le=a,a=n),a===n&&(a=null),a!==n?(he=r,e=function(t,r,e){const n=[t,"=",r];return e&&n.push("and",...e[1]),n}(e,u,a),r=e):(le=r,r=n)):(le=r,r=n)):(le=r,r=n)):(le=r,r=n)),r}function ze(){var r,e,s,u,a,c,o,i;if(r=le,t.substr(le,8)===v?(e=v,le+=8):(e=n,0===ge&&ye(b)),e!==n)if((s=bn())!==n)if((u=Ze())!==n){for(a=[],c=le,(o=dn())!==n&&(i=Ze())!==n?c=o=[o,i]:(le=c,c=n);c!==n;)a.push(c),c=le,(o=dn())!==n&&(i=Ze())!==n?c=o=[o,i]:(le=c,c=n);a!==n?r=e=[e,s,u,a]:(le=r,r=n)}else le=r,r=n;else le=r,r=n;else le=r,r=n;if(r===n){if(r=le,t.substr(le,8)===m?(e=m,le+=8):(e=n,0===ge&&ye(x)),e!==n)if((s=bn())!==n)if((u=Be())!==n){for(a=[],c=le,(o=dn())!==n&&(i=Be())!==n?c=o=[o,i]:(le=c,c=n);c!==n;)a.push(c),c=le,(o=dn())!==n&&(i=Be())!==n?c=o=[o,i]:(le=c,c=n);a!==n?r=e=[e,s,u,a]:(le=r,r=n)}else le=r,r=n;else le=r,r=n;else le=r,r=n;if(r===n&&(r=le,t.substr(le,8)===C?(e=C,le+=8):(e=n,0===ge&&ye(y)),e!==n&&(s=bn())!==n&&(u=Re())!==n?r=e=[e,s,u]:(le=r,r=n),r===n)){if(r=le,t.substr(le,9)===$?(e=$,le+=9):(e=n,0===ge&&ye(w)),e!==n)if((s=bn())!==n)if((u=Oe())!==n){for(a=[],c=le,(o=dn())!==n&&(i=Oe())!==n?c=o=[o,i]:(le=c,c=n);c!==n;)a.push(c),c=le,(o=dn())!==n&&(i=Oe())!==n?c=o=[o,i]:(le=c,c=n);a!==n?r=e=[e,s,u,a]:(le=r,r=n)}else le=r,r=n;else le=r,r=n;else le=r,r=n;r===n&&(r=le,t.substr(le,5)===E?(e=E,le+=5):(e=n,0===ge&&ye(S)),e!==n&&(s=bn())!==n?(u=function(){var t,r;t=le,(r=hn())!==n&&(he=t,e=r,r=void((wn.limit||(wn.limit={})).rows={val:e}));var e;return t=r}(),u!==n?r=e=[e,s,u]:(le=r,r=n)):(le=r,r=n),r===n&&(r=le,t.substr(le,6)===z?(e=z,le+=6):(e=n,0===ge&&ye(Z)),e!==n&&(s=bn())!==n?(u=function(){var t,r;t=le,(r=hn())!==n&&(he=t,e=r,r=void((wn.limit||(wn.limit={})).offset={val:e}));var e;return t=r}(),u!==n?r=e=[e,s,u]:(le=r,r=n)):(le=r,r=n),r===n&&(r=le,t.substr(le,8)===B?(e=B,le+=8):(e=n,0===ge&&ye(j)),e!==n&&(s=bn())!==n&&(u=je())!==n?r=e=[e,s,u]:(le=r,r=n),r===n&&(r=le,t.substr(le,7)===F?(e=F,le+=7):(e=n,0===ge&&ye(R)),e!==n&&(s=bn())!==n?(u=function(){var t,r;t=le,(r=cn())!==n&&(he=t,r=void(r&&(wn.count=!0)));return t=r}(),u!==n?r=e=[e,s,u]:(le=r,r=n)):(le=r,r=n),r===n&&(r=le,t.substr(le,7)===T?(e=T,le+=7):(e=n,0===ge&&ye(L)),e!==n&&(s=bn())!==n&&(u=qe())!==n?r=e=[e,s,u]:(le=r,r=n),r===n&&(r=function(){var r,e,s,u,a,c;r=le,X.test(t.charAt(le))?(e=t.charAt(le),le++):(e=n,0===ge&&ye(Y));if(e!==n){for(s=[],tt.test(t.charAt(le))?(u=t.charAt(le),le++):(u=n,0===ge&&ye(rt));u!==n;)s.push(u),tt.test(t.charAt(le))?(u=t.charAt(le),le++):(u=n,0===ge&&ye(rt));if(s!==n)if(61===t.charCodeAt(le)?(u="=",le++):(u=n,0===ge&&ye(g)),u!==n){for(a=[],et.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(nt));c!==n;)a.push(c),et.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(nt));a!==n?r=e=[e,s,u,a]:(le=r,r=n)}else le=r,r=n;else le=r,r=n}else le=r,r=n;return r}()))))))}}return r}function Ze(){var r,e,s,u;return r=le,(e=Ie())===n&&(e=le,42===t.charCodeAt(le)?(s="*",le++):(s=n,0===ge&&ye(k)),s!==n&&(he=e,s="*"),e=s),e!==n&&(he=r,u=e,wn.expand=wn.expand||[],wn.expand.push(u),e=u),r=e}function Be(){var r,e,s,u,a,c,o,i,f,l,h,p;if(r=le,e=le,(s=Ze())!==n&&(he=e,s=void(s.expand="*")),(e=s)!==n){if(s=le,u=le,(a=gn())!==n&&(he=u,$n.push(wn),wn=wn.expand[wn.expand.length-1],a=void(wn.expand=["*"])),(u=a)!==n){if(a=le,(c=ze())!==n){for(o=[],i=le,(f=bn())!==n?(59===t.charCodeAt(le)?(l=";",le++):(l=n,0===ge&&ye(N)),l!==n&&(h=bn())!==n&&(p=ze())!==n?i=f=[f,l,h,p]:(le=i,i=n)):(le=i,i=n);i!==n;)o.push(i),i=le,(f=bn())!==n?(59===t.charCodeAt(le)?(l=";",le++):(l=n,0===ge&&ye(N)),l!==n&&(h=bn())!==n&&(p=ze())!==n?i=f=[f,l,h,p]:(le=i,i=n)):(le=i,i=n);o!==n?(he=a,a=c=void("$select="===c[0]&&wn.expand.shift())):(le=a,a=n)}else le=a,a=n;a!==n?(c=le,(o=vn())!==n&&(he=c,o=void(wn=$n.pop())),(c=o)!==n?s=u=[u,a,c]:(le=s,s=n)):(le=s,s=n)}else le=s,s=n;s===n&&(s=null),s!==n?(u=le,(a=dn())!==n&&(c=Be())!==n?u=a=[a,c]:(le=u,u=n),u===n&&(u=null),u!==n?r=e=[e,s,u]:(le=r,r=n)):(le=r,r=n)}else le=r,r=n;return r}function je(){var t,r,e;return t=le,(r=Fe())!==n&&(he=t,e=r,r=void(wn.search=e)),t=r}function Fe(){var r,e,s,u,a,c,o;if(r=le,e=le,(s=Je())===n&&(s=null),s!==n&&(he=e,s=O(s)),(e=s)!==n)if(s=le,(u=gn())!==n&&(a=Fe())!==n&&(c=vn())!==n?(he=s,s=u=q(e,a)):(le=s,s=n),s===n&&(s=le,u=function(){var r,e,s,u,a;r=le,34===t.charCodeAt(le)?(e=Tr,le++):(e=n,0===ge&&ye(Lr));if(e!==n){for(s=le,u=[],t.substr(le,2)===kr?(a=kr,le+=2):(a=n,0===ge&&ye(Nr)),a===n&&(Or.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(qr)));a!==n;)u.push(a),t.substr(le,2)===kr?(a=kr,le+=2):(a=n,0===ge&&ye(Nr)),a===n&&(Or.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(qr)));(s=u!==n?t.substring(s,le):u)!==n?(34===t.charCodeAt(le)?(u=Tr,le++):(u=n,0===ge&&ye(Lr)),u!==n?(he=r,r=e=s.replace(/\\\\/g,"\\").replace(/\\"/g,'"')):(le=r,r=n)):(le=r,r=n)}else le=r,r=n;return r}(),u!==n&&(he=s,u=_(e,u)),(s=u)===n&&(s=le,(u=on())!==n&&(he=s,u=_(e,u)),(s=u)===n&&(s=le,(u=fn())!==n&&(he=s,u=_(e,u)),s=u))),s!==n){for(u=[],a=le,(c=Ke())===n&&(c=Qe())===n&&(c=Pe()),c!==n&&(o=Fe())!==n?(he=a,a=c=D(e,c,o)):(le=a,a=n);a!==n;)u.push(a),a=le,(c=Ke())===n&&(c=Qe())===n&&(c=Pe()),c!==n&&(o=Fe())!==n?(he=a,a=c=D(e,c,o)):(le=a,a=n);u!==n?(he=r,r=e=e):(le=r,r=n)}else le=r,r=n;else le=r,r=n;return r}function Re(){var t,r,e;return t=le,(r=Te())!==n&&(he=t,e=r,r=void(wn.where=e)),t=r}function Te(){var r,e,s,u,a,c,o,i;if(r=le,e=le,(s=Je())===n&&(s=null),s!==n&&(he=e,s=O(s)),(e=s)!==n)if(s=le,(u=gn())!==n&&(a=Te())!==n&&(c=vn())!==n?(he=s,s=u=q(e,a)):(le=s,s=n),s===n&&(s=le,(u=_e())!==n&&(he=s,i=u,u=void e.push(...i)),(s=u)===n&&(s=le,(u=Le())!==n&&(he=s,u=function(t,r){t.push(...r)}(e,u)),(s=u)===n&&(s=le,u=function(){var r,e,s,u;ge++,r=le,t.substr(le,8)===Ft?(e=Ft,le+=8):(e=n,0===ge&&ye(Rt));e===n&&(t.substr(le,8)===Tt?(e=Tt,le+=8):(e=n,0===ge&&ye(Lt)),e===n&&(t.substr(le,10)===kt?(e=kt,le+=10):(e=n,0===ge&&ye(Nt))));e!==n&&gn()!==n&&(s=De())!==n&&dn()!==n&&(u=De())!==n&&vn()!==n?(he=r,r=e={func:e,args:[s,u]}):(le=r,r=n);ge--,r===n&&(e=n,0===ge&&ye(jt));return r}(),u!==n&&(he=s,u=function(t,r){t.push(r)}(e,u)),s=u))),s!==n){for(u=[],a=le,(c=Ke())===n&&(c=Qe()),c!==n&&(o=Te())!==n?(he=a,a=c=D(e,c,o)):(le=a,a=n);a!==n;)u.push(a),a=le,(c=Ke())===n&&(c=Qe()),c!==n&&(o=Te())!==n?(he=a,a=c=D(e,c,o)):(le=a,a=n);u!==n?(he=r,r=e=e):(le=r,r=n)}else le=r,r=n;else le=r,r=n;return r}function Le(){var r,e,s,u,o,i,f;if(r=le,e=le,(s=pn())!==n&&(he=e,s=[s]),(e=s)!==n)if(47===t.charCodeAt(le)?(s=a,le++):(s=n,0===ge&&ye(c)),s!==n){for(u=[],o=le,(i=pn())!==n?(47===t.charCodeAt(le)?(f=a,le++):(f=n,0===ge&&ye(c)),f!==n?(he=o,o=i=I(e,i)):(le=o,o=n)):(le=o,o=n);o!==n;)u.push(o),o=le,(i=pn())!==n?(47===t.charCodeAt(le)?(f=a,le++):(f=n,0===ge&&ye(c)),f!==n?(he=o,o=i=I(e,i)):(le=o,o=n)):(le=o,o=n);u!==n?(o=le,i=function(){var r,e,s;r=le,t.substr(le,3)===H?(e=H,le+=3):(e=n,0===ge&&ye(J));e!==n&&gn()!==n?((s=Ne())===n&&(s=null),s!==n&&vn()!==n?(he=r,r=e=s):(le=r,r=n)):(le=r,r=n);return r}(),i!==n&&(he=o,i=function(t,r){let e=t.pop();if(!r)return["exists",{ref:[...t,{id:e}]}];let n=[];for(let t=0,s=0;t<r.length;++t){let u=r[t];u.ref&&0===u.ref.length&&"="===r[t+1]?n[s++]={func:"contains",args:[{ref:e},r[t+=2]]}:n[s++]=u}return n.length<r.length?(e=t.pop(),["exists",{ref:[...t,{id:e,where:n}]}]):["exists",{ref:[...t,{id:e,where:r}]}]}(e,i)),(o=i)===n&&(o=le,i=function(){var r,e,s;r=le,t.substr(le,3)===K?(e=K,le+=3):(e=n,0===ge&&ye(P));e!==n&&gn()!==n&&(s=Ne())!==n&&vn()!==n?(he=r,r=e=s):(le=r,r=n);return r}(),i!==n&&(he=o,i=function(t,r){let e=t.pop();return["not","exists",{ref:[...t,{id:e,where:["not",{xpr:[...r]}]}]}]}(e,i)),o=i),o!==n?(he=r,r=e=o):(le=r,r=n)):(le=r,r=n)}else le=r,r=n;else le=r,r=n;return r}function ke(){var t,r,e,s,u,a,c,o,i;if(t=le,r=le,(e=Je())===n&&(e=null),e!==n&&(he=r,e=(o=e)?[o]:[]),(r=e)!==n)if(e=le,(s=gn())!==n&&(u=ke())!==n&&(a=vn())!==n?(he=e,i=u,e=s=void r.push("(",...i,")")):(le=e,e=n),e===n&&(e=le,(s=_e())!==n&&(he=e,s=function(t,r){t.push(...r)}(r,s)),(e=s)===n&&(e=le,(s=Le())!==n&&(he=e,s=function(t,r){t.push(...r)}(r,s)),e=s)),e!==n){for(s=[],u=le,(a=Ke())===n&&(a=Qe()),a!==n&&(c=ke())!==n?(he=u,u=a=M(r,a,c)):(le=u,u=n);u!==n;)s.push(u),u=le,(a=Ke())===n&&(a=Qe()),a!==n&&(c=ke())!==n?(he=u,u=a=M(r,a,c)):(le=u,u=n);s!==n?(he=t,t=r=r):(le=t,t=n)}else le=t,t=n;else le=t,t=n;return t}function Ne(){var r,e,s,u;return r=le,(e=pn())!==n?(58===t.charCodeAt(le)?(s=U,le++):(s=n,0===ge&&ye(G)),s!==n&&(u=ke())!==n?(he=r,r=e=function(t,r){for(const e of r)e.ref&&e.ref[0]===t&&e.ref.shift();return r}(e,u)):(le=r,r=n)):(le=r,r=n),r}function Oe(){var r,e,s,u,a;return r=le,(e=He())===n&&(e=Ie()),e!==n?(s=le,mn()!==n?(u=le,"asc"===t.substr(le,3)?(a="asc",le+=3):(a=n,0===ge&&ye(Q)),a===n&&(t.substr(le,4)===V?(a=V,le+=4):(a=n,0===ge&&ye(W))),(u=a!==n?t.substring(u,le):a)!==n?(he=s,s=u):(le=s,s=n)):(le=s,s=n),s===n&&(s=null),s!==n?(he=r,r=e=function(t,r){const e=xn(t,r&&{sort:r});wn.orderBy=wn.orderBy?[...wn.orderBy,e]:[e]}(e,s)):(le=r,r=n)):(le=r,r=n),r}function qe(){var r,e,s,u,o,i;if(r=le,(e=Ve())!==n){for(s=[],u=le,47===t.charCodeAt(le)?(o=a,le++):(o=n,0===ge&&ye(c)),o!==n&&(i=Ve())!==n?u=o=[o,i]:(le=u,u=n);u!==n;)s.push(u),u=le,47===t.charCodeAt(le)?(o=a,le++):(o=n,0===ge&&ye(c)),o!==n&&(i=Ve())!==n?u=o=[o,i]:(le=u,u=n);s!==n?r=e=[e,s]:(le=r,r=n)}else le=r,r=n;return r}function _e(){var r,e,s,u,a,c;return ge++,r=le,(e=De())!==n&&mn()!==n?(s=le,"eq"===t.substr(le,2)?(u="eq",le+=2):(u=n,0===ge&&ye(ut)),u===n&&("ne"===t.substr(le,2)?(u="ne",le+=2):(u=n,0===ge&&ye(at)),u===n&&("lt"===t.substr(le,2)?(u="lt",le+=2):(u=n,0===ge&&ye(ct)),u===n&&("gt"===t.substr(le,2)?(u="gt",le+=2):(u=n,0===ge&&ye(ot)),u===n&&("le"===t.substr(le,2)?(u="le",le+=2):(u=n,0===ge&&ye(it)),u===n&&("ge"===t.substr(le,2)?(u="ge",le+=2):(u=n,0===ge&&ye(ft))))))),(s=u!==n?t.substring(s,le):u)!==n&&(u=mn())!==n&&(a=De())!==n?(he=r,r=e=[e,{eq:"=",ne:"!=",lt:"<",gt:">",le:"<=",ge:">="}[c=s]||c,a]):(le=r,r=n)):(le=r,r=n),ge--,r===n&&(e=n,0===ge&&ye(st)),r}function De(){var r;return ge++,(r=He())===n&&(r=Ie())===n&&(r=Me())===n&&(r=Ue())===n&&(r=Ge())===n&&(r=function(){var r,e,s,u,a;r=le,91===t.charCodeAt(le)?(e=mt,le++):(e=n,0===ge&&ye(xt));if(e!==n){for(s=le,u=[],$t.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(wt));a!==n;)u.push(a),$t.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(wt));(s=u!==n?t.substring(s,le):u)!==n?(93===t.charCodeAt(le)?(u=Ct,le++):(u=n,0===ge&&ye(yt)),u!==n?(he=r,r=e={list:s.replace(/"/g,"").split(",").map((t=>({val:t})))}):(le=r,r=n)):(le=r,r=n)}else le=r,r=n;return r}()),ge--,r===n&&(n,0===ge&&ye(lt)),r}function Ie(){var r,e,s,u,o,i,f,l;if(ge++,r=le,(e=pn())!==n){for(s=[],u=le,47===t.charCodeAt(le)?(o=a,le++):(o=n,0===ge&&ye(c)),o!==n&&(i=pn())!==n?(he=u,u=o=pt(0,i)):(le=u,u=n);u!==n;)s.push(u),u=le,47===t.charCodeAt(le)?(o=a,le++):(o=n,0===ge&&ye(c)),o!==n&&(i=pn())!==n?(he=u,u=o=pt(0,i)):(le=u,u=n);s!==n?(he=r,l=s,r=e="null"===(f=e)?{val:null}:{ref:[f,...l]}):(le=r,r=n)}else le=r,r=n;return ge--,r===n&&(e=n,0===ge&&ye(ht)),r}function Me(){var r,e,s;return r=le,(e=cn())===n&&(e=function(){var r,e,s,u,a,c,o,i,f,l,h,p,A,d,g,v,b,m,x,C,y,$,w,E;r=le,e=le,s=[],Ir.test(t.charAt(le))?(u=t.charAt(le),le++):(u=n,0===ge&&ye(Mr));if(u!==n)for(;u!==n;)s.push(u),Ir.test(t.charAt(le))?(u=t.charAt(le),le++):(u=n,0===ge&&ye(Mr));else s=n;if(s!==n)if(45===t.charCodeAt(le)?(u=Ur,le++):(u=n,0===ge&&ye(Gr)),u!==n)if(Ir.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(Mr)),a!==n)if(Ir.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(Mr)),c!==n)if(45===t.charCodeAt(le)?(o=Ur,le++):(o=n,0===ge&&ye(Gr)),o!==n)if(Ir.test(t.charAt(le))?(i=t.charAt(le),le++):(i=n,0===ge&&ye(Mr)),i!==n)if(Ir.test(t.charAt(le))?(f=t.charAt(le),le++):(f=n,0===ge&&ye(Mr)),f!==n){if(l=le,84===t.charCodeAt(le)?(h="T",le++):(h=n,0===ge&&ye(Hr)),h!==n)if(Ir.test(t.charAt(le))?(p=t.charAt(le),le++):(p=n,0===ge&&ye(Mr)),p!==n)if(Ir.test(t.charAt(le))?(A=t.charAt(le),le++):(A=n,0===ge&&ye(Mr)),A!==n)if(58===t.charCodeAt(le)?(d=U,le++):(d=n,0===ge&&ye(G)),d!==n)if(Ir.test(t.charAt(le))?(g=t.charAt(le),le++):(g=n,0===ge&&ye(Mr)),g!==n)if(Ir.test(t.charAt(le))?(v=t.charAt(le),le++):(v=n,0===ge&&ye(Mr)),v!==n){if(b=le,58===t.charCodeAt(le)?(m=U,le++):(m=n,0===ge&&ye(G)),m!==n)if(Ir.test(t.charAt(le))?(x=t.charAt(le),le++):(x=n,0===ge&&ye(Mr)),x!==n)if(Ir.test(t.charAt(le))?(C=t.charAt(le),le++):(C=n,0===ge&&ye(Mr)),C!==n){if(y=le,46===t.charCodeAt(le)?($=".",le++):($=n,0===ge&&ye(Jr)),$!==n){if(w=[],Ir.test(t.charAt(le))?(E=t.charAt(le),le++):(E=n,0===ge&&ye(Mr)),E!==n)for(;E!==n;)w.push(E),Ir.test(t.charAt(le))?(E=t.charAt(le),le++):(E=n,0===ge&&ye(Mr));else w=n;w!==n?y=$=[$,w]:(le=y,y=n)}else le=y,y=n;y===n&&(y=null),y!==n?b=m=[m,x,C,y]:(le=b,b=n)}else le=b,b=n;else le=b,b=n;else le=b,b=n;b===n&&(b=null),b!==n?(90===t.charCodeAt(le)?(m="Z",le++):(m=n,0===ge&&ye(Kr)),m===n&&(m=le,43===t.charCodeAt(le)?(x="+",le++):(x=n,0===ge&&ye(Pr)),x===n&&(45===t.charCodeAt(le)?(x=Ur,le++):(x=n,0===ge&&ye(Gr))),x!==n?(Ir.test(t.charAt(le))?(C=t.charAt(le),le++):(C=n,0===ge&&ye(Mr)),C!==n?(Ir.test(t.charAt(le))?(y=t.charAt(le),le++):(y=n,0===ge&&ye(Mr)),y!==n?(58===t.charCodeAt(le)?($=U,le++):($=n,0===ge&&ye(G)),$!==n?(Ir.test(t.charAt(le))?(w=t.charAt(le),le++):(w=n,0===ge&&ye(Mr)),w!==n?(Ir.test(t.charAt(le))?(E=t.charAt(le),le++):(E=n,0===ge&&ye(Mr)),E!==n?m=x=[x,C,y,$,w,E]:(le=m,m=n)):(le=m,m=n)):(le=m,m=n)):(le=m,m=n)):(le=m,m=n)):(le=m,m=n)),m===n&&(m=null),m!==n?l=h=[h,p,A,d,g,v,b,m]:(le=l,l=n)):(le=l,l=n)}else le=l,l=n;else le=l,l=n;else le=l,l=n;else le=l,l=n;else le=l,l=n;else le=l,l=n;l===n&&(l=null),l!==n?e=s=[s,u,a,c,o,i,f,l]:(le=e,e=n)}else le=e,e=n;else le=e,e=n;else le=e,e=n;else le=e,e=n;else le=e,e=n;else le=e,e=n;else le=e,e=n;r=e!==n?t.substring(r,le):e;return r}()),e!==n&&(he=r,e=At(e)),(r=e)===n&&(r=An())===n&&(r=le,(e=ln())!==n&&(he=r,e="number"==typeof(s=e)?{val:s}:{val:s,literal:"number"}),(r=e)===n&&(r=le,(e=on())!==n&&(he=r,e=At(e)),r=e)),r}function Ue(){var r,e,s,u,a,c;if(r=le,e=le,s=le,123===t.charCodeAt(le)?(u="{",le++):(u=n,0===ge&&ye(dt)),u!==n){for(a=[],(c=Ue())===n&&(gt.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(vt)));c!==n;)a.push(c),(c=Ue())===n&&(gt.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(vt)));a!==n?(125===t.charCodeAt(le)?(c="}",le++):(c=n,0===ge&&ye(bt)),c!==n?s=u=[u,a,c]:(le=s,s=n)):(le=s,s=n)}else le=s,s=n;return(e=s!==n?t.substring(e,le):s)!==n&&(he=r,e=At(e)),r=e}function Ge(){var r,e,s,u,a,c,o,i;if(r=le,e=le,s=le,91===t.charCodeAt(le)?(u=mt,le++):(u=n,0===ge&&ye(xt)),u!==n&&(a=bn())!==n?(93===t.charCodeAt(le)?(c=Ct,le++):(c=n,0===ge&&ye(yt)),c!==n?s=u=[u,a,c]:(le=s,s=n)):(le=s,s=n),s===n)if(s=le,91===t.charCodeAt(le)?(u=mt,le++):(u=n,0===ge&&ye(xt)),u!==n)if((a=bn())!==n)if(123===t.charCodeAt(le)?(c="{",le++):(c=n,0===ge&&ye(dt)),c!==n){for(o=[],(i=Ge())===n&&($t.test(t.charAt(le))?(i=t.charAt(le),le++):(i=n,0===ge&&ye(wt)));i!==n;)o.push(i),(i=Ge())===n&&($t.test(t.charAt(le))?(i=t.charAt(le),le++):(i=n,0===ge&&ye(wt)));o!==n?(93===t.charCodeAt(le)?(i=Ct,le++):(i=n,0===ge&&ye(yt)),i!==n?s=u=[u,a,c,o,i]:(le=s,s=n)):(le=s,s=n)}else le=s,s=n;else le=s,s=n;else le=s,s=n;return(e=s!==n?t.substring(e,le):s)!==n&&(he=r,e=At(e)),r=e}function He(){var r,e,s,u,a,c,o;if(ge++,r=le,e=le,s=[],St.test(t.charAt(le))?(u=t.charAt(le),le++):(u=n,0===ge&&ye(zt)),u!==n)for(;u!==n;)s.push(u),St.test(t.charAt(le))?(u=t.charAt(le),le++):(u=n,0===ge&&ye(zt));else s=n;if((e=s!==n?t.substring(e,le):s)!==n)if((s=gn())!==n)if((u=De())!==n){for(a=[],c=le,dn()!==n&&(o=De())!==n?(he=c,c=Zt(0,0,o)):(le=c,c=n);c!==n;)a.push(c),c=le,dn()!==n&&(o=De())!==n?(he=c,c=Zt(0,0,o)):(le=c,c=n);a!==n&&(c=vn())!==n?(he=r,r=e=Bt(e,u,a)):(le=r,r=n)}else le=r,r=n;else le=r,r=n;else le=r,r=n;return ge--,r===n&&(e=n,0===ge&&ye(Et)),r}function Je(){var r,e;return r=le,bn()!==n?("not"===t.substr(le,3).toLowerCase()?(e=t.substr(le,3),le+=3):(e=n,0===ge&&ye(Ot)),e!==n&&mn()!==n?(he=r,r="not"):(le=r,r=n)):(le=r,r=n),r}function Ke(){var r,e;return r=le,mn()!==n?("and"===t.substr(le,3).toLowerCase()?(e=t.substr(le,3),le+=3):(e=n,0===ge&&ye(qt)),e!==n&&mn()!==n?(he=r,r="and"):(le=r,r=n)):(le=r,r=n),r}function Pe(){var t,r;return t=le,(r=mn())!==n&&(he=t,r="and"),t=r}function Qe(){var r,e;return r=le,mn()!==n?("or"===t.substr(le,2).toLowerCase()?(e=t.substr(le,2),le+=2):(e=n,0===ge&&ye(_t)),e!==n&&mn()!==n?(he=r,r="or"):(le=r,r=n)):(le=r,r=n),r}function Ve(){var r,e,s;return r=le,t.substr(le,9)===Dt?(e=Dt,le+=9):(e=n,0===ge&&ye(It)),e!==n?(s=function(){var t,r,e,s,u,a,c,o,i,f;if(t=le,(r=gn())!==n)if((e=bn())!==n)if((s=We())!==n){for(u=[],a=le,(c=bn())!==n&&(o=dn())!==n&&(i=bn())!==n&&(f=We())!==n?a=c=[c,o,i,f]:(le=a,a=n);a!==n;)u.push(a),a=le,(c=bn())!==n&&(o=dn())!==n&&(i=bn())!==n&&(f=We())!==n?a=c=[c,o,i,f]:(le=a,a=n);u!==n&&(a=bn())!==n&&(c=vn())!==n?t=r=[r,e,s,u,a,c]:(le=t,t=n)}else le=t,t=n;else le=t,t=n;else le=t,t=n;return t}(),s!==n?r=e=[e,s]:(le=r,r=n)):(le=r,r=n),r===n&&(r=le,t.substr(le,7)===Mt?(e=Mt,le+=7):(e=n,0===ge&&ye(Ut)),e!==n?(s=function(){var t,r,e,s,u,a,c,o,i,f,l;if(t=le,(r=gn())!==n)if((e=bn())!==n){if(s=le,(u=gn())!==n)if((a=en())!==n){for(c=[],o=le,(i=dn())!==n&&(f=bn())!==n&&(l=en())!==n?o=i=[i,f,l]:(le=o,o=n);o!==n;)c.push(o),o=le,(i=dn())!==n&&(f=bn())!==n&&(l=en())!==n?o=i=[i,f,l]:(le=o,o=n);c!==n&&(o=vn())!==n?s=u=[u,a,c,o]:(le=s,s=n)}else le=s,s=n;else le=s,s=n;s!==n?(u=le,(a=dn())!==n&&(c=bn())!==n&&(o=qe())!==n?u=a=[a,c,o]:(le=u,u=n),u===n&&(u=null),u!==n&&(a=bn())!==n&&(c=vn())!==n?t=r=[r,e,s,u,a,c]:(le=t,t=n)):(le=t,t=n)}else le=t,t=n;else le=t,t=n;return t}(),s!==n?r=e=[e,s]:(le=r,r=n)):(le=r,r=n),r===n&&(r=le,t.substr(le,6)===Gt?(e=Gt,le+=6):(e=n,0===ge&&ye(Ht)),e!==n&&(s=nn())!==n?r=e=[e,s]:(le=r,r=n),r===n&&(r=function(){var r,e,s,u;r=le,t.substr(le,8)===vr?(e=vr,le+=8):(e=n,0===ge&&ye(br));e===n&&(t.substr(le,11)===mr?(e=mr,le+=11):(e=n,0===ge&&ye(xr)));e!==n&&gn()!==n&&bn()!==n&&(s=ln())!==n&&bn()!==n&&dn()!==n&&bn()!==n&&(u=Ie())!==n&&bn()!==n&&vn()!==n?(he=r,r=e=function(t,r,e){const n={...e,sort:"topcount"===t?"desc":"asc"};wn.orderBy=wn.orderBy?[...wn.orderBy,n]:[n],(wn.limit||(wn.limit={})).rows={val:r}}(e,s,u)):(le=r,r=n);return r}(),r===n&&(r=le,t.substr(le,6)===Jt?(e=Jt,le+=6):(e=n,0===ge&&ye(Kt)),e!==n&&(s=sn())!==n?r=e=[e,s]:(le=r,r=n),r===n&&(r=le,t.substr(le,6)===Pt?(e=Pt,le+=6):(e=n,0===ge&&ye(Qt)),e!==n?(s=function(){var t,r,e,s,u,a;t=le,(r=gn())!==n&&(e=bn())!==n&&(s=je())!==n&&(u=bn())!==n&&(a=vn())!==n?t=r=[r,e,s,u,a]:(le=t,t=n);return t}(),s!==n?r=e=[e,s]:(le=r,r=n)):(le=r,r=n),r===n&&(r=le,t.substr(le,6)===Vt?(e=Vt,le+=6):(e=n,0===ge&&ye(Wt)),e!==n?(s=function(){var t,r,e,s,u,a,c,o,i,f;if(t=le,(r=gn())!==n)if((e=bn())!==n)if((s=qe())!==n){if(u=[],a=le,(c=bn())!==n&&(o=dn())!==n&&(i=bn())!==n&&(f=qe())!==n?a=c=[c,o,i,f]:(le=a,a=n),a!==n)for(;a!==n;)u.push(a),a=le,(c=bn())!==n&&(o=dn())!==n&&(i=bn())!==n&&(f=qe())!==n?a=c=[c,o,i,f]:(le=a,a=n);else u=n;u!==n&&(a=bn())!==n&&(c=vn())!==n?t=r=[r,e,s,u,a,c]:(le=t,t=n)}else le=t,t=n;else le=t,t=n;else le=t,t=n;return t}(),s!==n?r=e=[e,s]:(le=r,r=n)):(le=r,r=n),r===n&&(r=le,t.substr(le,7)===Xt?(e=Xt,le+=7):(e=n,0===ge&&ye(Yt)),e!==n?(s=function(){var t,r,e,s,u,a,c,o,i,f;if(t=le,(r=gn())!==n)if((e=bn())!==n)if((s=un())!==n){for(u=[],a=le,(c=bn())!==n&&(o=dn())!==n&&(i=bn())!==n&&(f=un())!==n?a=c=[c,o,i,f]:(le=a,a=n);a!==n;)u.push(a),a=le,(c=bn())!==n&&(o=dn())!==n&&(i=bn())!==n&&(f=un())!==n?a=c=[c,o,i,f]:(le=a,a=n);u!==n&&(a=bn())!==n&&(c=vn())!==n?t=r=[r,e,s,u,a,c]:(le=t,t=n)}else le=t,t=n;else le=t,t=n;else le=t,t=n;return t}(),s!==n?r=e=[e,s]:(le=r,r=n)):(le=r,r=n),r===n&&(r=le,t.substr(le,13)===tr?(e=tr,le+=13):(e=n,0===ge&&ye(rr)),e!==n&&(s=an())!==n?r=e=[e,s]:(le=r,r=n),r===n&&(r=le,t.substr(le,9)===er?(e=er,le+=9):(e=n,0===ge&&ye(nr)),e!==n&&(s=an())!==n?r=e=[e,s]:(le=r,r=n),r===n&&(r=le,t.substr(le,10)===sr?(e=sr,le+=10):(e=n,0===ge&&ye(ur)),e!==n&&(s=an())!==n?r=e=[e,s]:(le=r,r=n),r===n&&(r=le,t.substr(le,6)===ar?(e=ar,le+=6):(e=n,0===ge&&ye(cr)),e!==n&&(s=an())!==n?r=e=[e,s]:(le=r,r=n),r===n&&(r=function(){var r;t.substr(le,8)===Cr?(r=Cr,le+=8):(r=n,0===ge&&ye(yr));return r}())))))))))))),r}function We(){var r,e,s,u,a;return r=le,e=le,t.substr(le,6)===f?(s=f,le+=6):(s=n,0===ge&&ye(l)),s!==n&&(u=rn())!==n?(he=e,e=s={func:"count",args:["*"],as:u}):(le=e,e=n),e===n&&(e=Xe()),e!==n&&(he=r,a=e,e=void(wn.expand||(wn.expand=[])).push(a)),r=e}function Xe(){var t,r,e,s,u;return t=le,(r=Ie())!==n&&(e=Ye())!==n?((s=tn())===n&&(s=null),s!==n&&(u=rn())!==n?(he=t,t=r={func:e,args:[r],as:u}):(le=t,t=n)):(le=t,t=n),t===n&&(t=le,(r=pn())!==n&&(e=gn())!==n&&(s=Xe())!==n&&(u=vn())!==n?t=r=[r,e,s,u]:(le=t,t=n)),t}function Ye(){var r,e,s,u,a;if(r=le,mn()!==n)if(t.substr(le,4)===or?(e=or,le+=4):(e=n,0===ge&&ye(ir)),e!==n)if(mn()!==n){if(s=le,u=[],St.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(zt)),a!==n)for(;a!==n;)u.push(a),St.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(zt));else u=n;(s=u!==n?t.substring(s,le):u)!==n?(he=r,r=s):(le=r,r=n)}else le=r,r=n;else le=r,r=n;else le=r,r=n;return r}function tn(){var r,e,s,u,a,c,o;return r=le,(e=mn())!==n?(t.substr(le,4)===fr?(s=fr,le+=4):(s=n,0===ge&&ye(lr)),s!==n&&(u=mn())!==n&&(a=Ie())!==n&&(c=Ye())!==n?((o=tn())===n&&(o=null),o!==n?r=e=[e,s,u,a,c,o]:(le=r,r=n)):(le=r,r=n)):(le=r,r=n),r}function rn(){var r,e,s;return r=le,mn()!==n?("as"===t.substr(le,2)?(e="as",le+=2):(e=n,0===ge&&ye(hr)),e!==n&&mn()!==n&&(s=pn())!==n?(he=r,r=s):(le=r,r=n)):(le=r,r=n),r}function en(){var r,e,s;return r=le,e=function(){var r,e,s,u,a,c,o,i,f,l;r=le,t.substr(le,6)===pr?(e=pr,le+=6):(e=n,0===ge&&ye(Ar));if(e!==n)if((s=gn())!==n)if((u=bn())!==n)if(t.substr(le,4)===dr?(a=dr,le+=4):(a=n,0===ge&&ye(gr)),a===n&&(a=Ie()),a!==n){if(c=[],o=le,(i=bn())!==n&&(f=dn())!==n&&(l=Ie())!==n?o=i=[i,f,l]:(le=o,o=n),o!==n)for(;o!==n;)c.push(o),o=le,(i=bn())!==n&&(f=dn())!==n&&(l=Ie())!==n?o=i=[i,f,l]:(le=o,o=n);else c=n;c!==n&&(o=bn())!==n&&(i=vn())!==n?r=e=[e,s,u,a,c,o,i]:(le=r,r=n)}else le=r,r=n;else le=r,r=n;else le=r,r=n;else le=r,r=n;return r}(),e===n&&(e=Ie()),e!==n&&(he=r,s=e,e=void(wn.groupBy||(wn.groupBy=[])).push(s)),r=e}function nn(){var t,r,e,s,u,a;return t=le,(r=gn())!==n&&(e=bn())!==n&&(s=Re())!==n&&(u=bn())!==n&&(a=vn())!==n?t=r=[r,e,s,u,a]:(le=t,t=n),t}function sn(){var t,r,e,s,u,a,c,o,i,f,l,h,p,A;if(t=le,(r=gn())!==n)if((e=bn())!==n)if((s=Ie())!==n)if((u=bn())!==n)if((a=dn())!==n)if((c=bn())!==n){if(o=le,(i=sn())!==n){for(f=[],l=le,(h=bn())!==n&&(p=dn())!==n&&(A=sn())!==n?l=h=[h,p,A]:(le=l,l=n);l!==n;)f.push(l),l=le,(h=bn())!==n&&(p=dn())!==n&&(A=sn())!==n?l=h=[h,p,A]:(le=l,l=n);f!==n?o=i=[i,f]:(le=o,o=n)}else le=o,o=n;if(o===n)if(o=le,(i=nn())!==n){for(f=[],l=le,(h=bn())!==n&&(p=dn())!==n&&(A=sn())!==n?l=h=[h,p,A]:(le=l,l=n);l!==n;)f.push(l),l=le,(h=bn())!==n&&(p=dn())!==n&&(A=sn())!==n?l=h=[h,p,A]:(le=l,l=n);f!==n?o=i=[i,f]:(le=o,o=n)}else le=o,o=n;o!==n&&(i=bn())!==n&&(f=vn())!==n?t=r=[r,e,s,u,a,c,o,i,f]:(le=t,t=n)}else le=t,t=n;else le=t,t=n;else le=t,t=n;else le=t,t=n;else le=t,t=n;else le=t,t=n;return t}function un(){var t,r,e;return t=le,(r=Te())!==n&&(e=rn())!==n?t=r=[r,e]:(le=t,t=n),t}function an(){var t,r,e,s,u,a,c,o,i,f;return t=le,(r=gn())!==n&&(e=bn())!==n&&(s=De())!==n&&(u=bn())!==n&&(a=dn())!==n&&(c=bn())!==n&&(o=De())!==n&&(i=bn())!==n&&(f=vn())!==n?t=r=[r,e,s,u,a,c,o,i,f]:(le=t,t=n),t}function cn(){var r,e;return r=le,t.substr(le,4)===$r?(e=$r,le+=4):(e=n,0===ge&&ye(wr)),e===n&&(t.substr(le,5)===Er?(e=Er,le+=5):(e=n,0===ge&&ye(Sr))),e!==n&&(he=r,e="true"===e),r=e}function on(){var r,e,s,u,a;if(ge++,r=le,39===t.charCodeAt(le)?(e="'",le++):(e=n,0===ge&&ye(Zr)),e!==n){for(s=le,u=[],t.substr(le,2)===Br?(a=Br,le+=2):(a=n,0===ge&&ye(jr)),a===n&&(Fr.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(Rr)));a!==n;)u.push(a),t.substr(le,2)===Br?(a=Br,le+=2):(a=n,0===ge&&ye(jr)),a===n&&(Fr.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(Rr)));(s=u!==n?t.substring(s,le):u)!==n?(39===t.charCodeAt(le)?(u="'",le++):(u=n,0===ge&&ye(Zr)),u!==n?(he=r,r=e=s.replace(/''/g,"'")):(le=r,r=n)):(le=r,r=n)}else le=r,r=n;return ge--,r===n&&(e=n,0===ge&&ye(zr)),r}function fn(){var r,e,s;if(r=le,e=[],_r.test(t.charAt(le))?(s=t.charAt(le),le++):(s=n,0===ge&&ye(Dr)),s!==n)for(;s!==n;)e.push(s),_r.test(t.charAt(le))?(s=t.charAt(le),le++):(s=n,0===ge&&ye(Dr));else e=n;return r=e!==n?t.substring(r,le):e}function ln(){var r,e,s,u,a,c,o,i,f,l;if(r=le,e=le,s=le,Qr.test(t.charAt(le))?(u=t.charAt(le),le++):(u=n,0===ge&&ye(Vr)),u===n&&(u=null),u!==n){if(a=[],Ir.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(Mr)),c!==n)for(;c!==n;)a.push(c),Ir.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(Mr));else a=n;if(a!==n){if(c=le,46===t.charCodeAt(le)?(o=".",le++):(o=n,0===ge&&ye(Jr)),o!==n){if(i=[],Ir.test(t.charAt(le))?(f=t.charAt(le),le++):(f=n,0===ge&&ye(Mr)),f!==n)for(;f!==n;)i.push(f),Ir.test(t.charAt(le))?(f=t.charAt(le),le++):(f=n,0===ge&&ye(Mr));else i=n;i!==n?c=o=[o,i]:(le=c,c=n)}else le=c,c=n;if(c===n&&(c=null),c!==n){if(o=le,101===t.charCodeAt(le)?(i="e",le++):(i=n,0===ge&&ye(Wr)),i!==n){if(f=[],Ir.test(t.charAt(le))?(l=t.charAt(le),le++):(l=n,0===ge&&ye(Mr)),l!==n)for(;l!==n;)f.push(l),Ir.test(t.charAt(le))?(l=t.charAt(le),le++):(l=n,0===ge&&ye(Mr));else f=n;f!==n?o=i=[i,f]:(le=o,o=n)}else le=o,o=n;o===n&&(o=null),o!==n?s=u=[u,a,c,o]:(le=s,s=n)}else le=s,s=n}else le=s,s=n}else le=s,s=n;return(e=s!==n?t.substring(e,le):s)!==n&&(he=r,e=Sn(e)),r=e}function hn(){var r,e,s,u,a,c;if(r=le,e=le,s=le,Qr.test(t.charAt(le))?(u=t.charAt(le),le++):(u=n,0===ge&&ye(Vr)),u===n&&(u=null),u!==n){if(a=[],Ir.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(Mr)),c!==n)for(;c!==n;)a.push(c),Ir.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(Mr));else a=n;a!==n?s=u=[u,a]:(le=s,s=n)}else le=s,s=n;return(e=s!==n?t.substring(e,le):s)!==n&&(he=r,e=parseInt(e)),r=e}function pn(){var r,e,s,u,a,c,o,i;if(r=le,e=le,ge++,s=cn(),ge--,s===n?e=void 0:(le=e,e=n),e!==n)if(s=le,ge++,u=An(),ge--,u===n?s=void 0:(le=s,s=n),s!==n){if(u=le,a=le,Xr.test(t.charAt(le))?(c=t.charAt(le),le++):(c=n,0===ge&&ye(Yr)),c!==n){for(o=[],te.test(t.charAt(le))?(i=t.charAt(le),le++):(i=n,0===ge&&ye(re));i!==n;)o.push(i),te.test(t.charAt(le))?(i=t.charAt(le),le++):(i=n,0===ge&&ye(re));o!==n?a=c=[c,o]:(le=a,a=n)}else le=a,a=n;(u=a!==n?t.substring(u,le):a)!==n?(he=r,r=e=u):(le=r,r=n)}else le=r,r=n;else le=r,r=n;return r}function An(){var r,e,s,u,a,c,o,i,f;if(r=le,e=le,s=le,u=[],ee.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(ne)),a!==n)for(;a!==n;)u.push(a),ee.test(t.charAt(le))?(a=t.charAt(le),le++):(a=n,0===ge&&ye(ne));else u=n;if(u!==n)if(45===t.charCodeAt(le)?(a=Ur,le++):(a=n,0===ge&&ye(Gr)),a!==n){if(c=[],o=le,i=[],ee.test(t.charAt(le))?(f=t.charAt(le),le++):(f=n,0===ge&&ye(ne)),f!==n)for(;f!==n;)i.push(f),ee.test(t.charAt(le))?(f=t.charAt(le),le++):(f=n,0===ge&&ye(ne));else i=n;if(i!==n?(45===t.charCodeAt(le)?(f=Ur,le++):(f=n,0===ge&&ye(Gr)),f===n&&(f=null),f!==n?o=i=[i,f]:(le=o,o=n)):(le=o,o=n),o!==n)for(;o!==n;){if(c.push(o),o=le,i=[],ee.test(t.charAt(le))?(f=t.charAt(le),le++):(f=n,0===ge&&ye(ne)),f!==n)for(;f!==n;)i.push(f),ee.test(t.charAt(le))?(f=t.charAt(le),le++):(f=n,0===ge&&ye(ne));else i=n;i!==n?(45===t.charCodeAt(le)?(f=Ur,le++):(f=n,0===ge&&ye(Gr)),f===n&&(f=null),f!==n?o=i=[i,f]:(le=o,o=n)):(le=o,o=n)}else c=n;c!==n?s=u=[u,a,c]:(le=s,s=n)}else le=s,s=n;else le=s,s=n;return(e=s!==n?t.substring(e,le):s)!==n&&(he=r,e=At(e)),r=e}function dn(){var r,e,s,u;return r=le,(e=bn())!==n?(44===t.charCodeAt(le)?(s=",",le++):(s=n,0===ge&&ye(se)),s!==n&&(u=bn())!==n?r=e=[e,s,u]:(le=r,r=n)):(le=r,r=n),r}function gn(){var r,e,s,u;return r=le,(e=bn())!==n?(40===t.charCodeAt(le)?(s="(",le++):(s=n,0===ge&&ye(ue)),s!==n&&(u=bn())!==n?r=e=[e,s,u]:(le=r,r=n)):(le=r,r=n),r}function vn(){var r,e,s;return r=le,(e=bn())!==n?(41===t.charCodeAt(le)?(s=")",le++):(s=n,0===ge&&ye(ae)),s!==n?r=e=[e,s]:(le=r,r=n)):(le=r,r=n),r}function bn(){var r,e,s;for(ge++,r=le,e=[],oe.test(t.charAt(le))?(s=t.charAt(le),le++):(s=n,0===ge&&ye(ie));s!==n;)e.push(s),oe.test(t.charAt(le))?(s=t.charAt(le),le++):(s=n,0===ge&&ye(ie));return r=e!==n?t.substring(r,le):e,ge--,r===n&&(e=n,0===ge&&ye(ce)),r}function mn(){var r,e,s;if(ge++,r=le,e=[],oe.test(t.charAt(le))?(s=t.charAt(le),le++):(s=n,0===ge&&ye(ie)),s!==n)for(;s!==n;)e.push(s),oe.test(t.charAt(le))?(s=t.charAt(le),le++):(s=n,0===ge&&ye(ie));else e=n;return r=e!==n?t.substring(r,le):e,ge--,r===n&&(e=n,0===ge&&ye(fe)),r}const xn=Object.assign,{strict:Cn,minimal:yn}=r,$n=[];let wn;const En=["$value"],Sn=r.safeNumber||function(t){const r=Number(t);return Number.isSafeInteger(r)?r:t},zn=t=>{const r=t.columns;if(!r)return t;if(!(t=>0===t.filter((t=>t.ref?!t.expand:t.as)).length)(r)){const e=new Map;return r.forEach((t=>{if("*"===t)return void e.set(t,t);if(!t.ref)return void e.set(t.as,t);const r=t.ref.join("/");e.has(r)&&!t.expand||e.set(r,t)})),e.size>0&&(t.columns=Array.from(e.values())),t}return 1===r.length&&"*"===r[0]?(delete t.columns,t):(r.includes("*")||t.columns.unshift("*"),t)},Zn=(t,r)=>{const e=[...t];for(const t of e)t.xpr&&(t.xpr=Zn(t.xpr,r)),t.args&&(t.args=Zn(t.args,r)),t.ref&&r.includes(t.ref.join(""));return e},Bn=t=>{const r=t.groupBy,e=t.where,n=t.columns||[],s=n.filter((t=>t.as));let u=[],a=[];if(0!==s.length&&(u=n.filter((t=>!t.ref||s.includes(t.ref.join(""))))),r){const t=r.map((({ref:t})=>t.join(""))),e=n.filter((r=>r.ref&&t.includes(r.ref.join(""))));a=0===e.length?[...r]:e}const c=0!==u.length||0!==a.length?[...a,...u]:t.columns;let o={...t,columns:c};if(e&&(r||0!==s.length)){const t=n.map((t=>t.ref&&t.ref.join("")||t.as));o={...o,where:Zn(e,t)}}return o};if((e=u())!==n&&le===t.length)return e;throw e!==n&&le<t.length&&ye({type:"end"}),$e(de,Ae<t.length?t.charAt(Ae):null,Ae<t.length?Ce(Ae,Ae+1):Ce(Ae,Ae))}peg$subclass(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(t,r){var e={literal:function(t){return'"'+s(t.text)+'"'},class:function(t){var r,e="";for(r=0;r<t.parts.length;r++)e+=t.parts[r]instanceof Array?u(t.parts[r][0])+"-"+u(t.parts[r][1]):u(t.parts[r]);return"["+(t.inverted?"^":"")+e+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function s(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}function u(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}return"Expected "+function(t){var r,n,s,u=new Array(t.length);for(r=0;r<t.length;r++)u[r]=(s=t[r],e[s.type](s));if(u.sort(),u.length>0){for(r=1,n=1;r<u.length;r++)u[r-1]!==u[r]&&(u[n]=u[r],n++);u.length=n}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}(t)+" but "+function(t){return t?'"'+s(t)+'"':"end of input"}(r)+" found."},module.exports={SyntaxError:peg$SyntaxError,parse:peg$parse};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
const cds = require('../cds')
|
|
2
|
-
const { SELECT } = cds.ql
|
|
3
|
-
|
|
4
|
-
const getError = require('../common/error')
|
|
5
|
-
const { findCsnTargetFor } = require('../common/utils/csn')
|
|
6
|
-
const { getAllKeys } = require('../cds-services/adapter/odata-v4/odata-to-cqn/utils')
|
|
7
|
-
const rewriteAsterisk = require('../common/utils/rewriteAsterisk')
|
|
8
|
-
const { getMaxPageSize } = require('../common/utils/page')
|
|
9
|
-
|
|
10
|
-
const _hasAllEntityKeysInWhere = (keys, where) => {
|
|
11
|
-
if (!(where && keys && keys.length)) return
|
|
12
|
-
keys = keys.map(key => (Array.isArray(key) ? key.join('_') : key))
|
|
13
|
-
for (const part of where) {
|
|
14
|
-
if (part.ref && keys.indexOf(part.ref.join('_')) > -1) {
|
|
15
|
-
keys.splice(keys.indexOf(part.ref.join('_')))
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return keys.length === 0
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const _setLimits = (cqn, parsed, target) => {
|
|
23
|
-
// adjust SELECT.limit based on @cds.query.limit annotations
|
|
24
|
-
const rows = parsed.SELECT.limit.rows ? parsed.SELECT.limit.rows.val : Number.MAX_SAFE_INTEGER
|
|
25
|
-
const offset = parsed.SELECT.limit.offset ? parsed.SELECT.limit.offset.val : 0
|
|
26
|
-
cqn.limit(Math.min(rows, getMaxPageSize(target)), offset)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const _setRootInFrom = (cqn, target, model, namespace) => {
|
|
30
|
-
const root = _findRoot(cqn, target, model, namespace)
|
|
31
|
-
const from = cqn.SELECT.from
|
|
32
|
-
if (from.ref[0].id) from.ref[0].id = root.name
|
|
33
|
-
else from.ref[0] = root.name
|
|
34
|
-
return cqn
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const _findRoot = (cqn, target, model, namespace) => {
|
|
38
|
-
const parsedTargetName = cqn.SELECT.from.ref[0].id || cqn.SELECT.from.ref[0]
|
|
39
|
-
return target.name === parsedTargetName ? target : findCsnTargetFor(parsedTargetName, model, namespace)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const _resolveRef = (ref, model, parent) => {
|
|
43
|
-
ref = ref.id || ref
|
|
44
|
-
const element = parent && parent.elements && parent.elements[ref]
|
|
45
|
-
let target = element || parent || model.definitions[ref]
|
|
46
|
-
let aspect
|
|
47
|
-
if (target && !target.elements) {
|
|
48
|
-
if (target.target) {
|
|
49
|
-
if (target.targetAspect) aspect = model.definitions[target.targetAspect]
|
|
50
|
-
target = model.definitions[target.target]
|
|
51
|
-
} else if (target.kind === 'type') {
|
|
52
|
-
target = model.definitions[target.type]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const keys = getAllKeys(aspect || target, false)
|
|
56
|
-
return { target, keys, element }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const _resolveStructKeys = (where, keys) => {
|
|
60
|
-
for (const el of where) {
|
|
61
|
-
if (!el.ref) continue
|
|
62
|
-
const keyIdx = keys.findIndex(key => Array.isArray(key) && key[key.length - 1] === el.ref[0])
|
|
63
|
-
if (keyIdx > -1) {
|
|
64
|
-
el.ref = [keys[keyIdx].join('_')]
|
|
65
|
-
keys.splice(keyIdx, 1)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const _postProcess = (cqn, target, model, namespace) => {
|
|
71
|
-
_setRootInFrom(cqn, target, model, namespace)
|
|
72
|
-
let prev
|
|
73
|
-
for (let i = 0; i < cqn.SELECT.from.ref.length; i++) {
|
|
74
|
-
const ref = cqn.SELECT.from.ref[i]
|
|
75
|
-
const { target, keys, element } = _resolveRef(ref, model, prev)
|
|
76
|
-
if (ref.where) {
|
|
77
|
-
// cases like `GET /Foo(1)/bar(2)` => `where` contains single `val`s
|
|
78
|
-
if (ref.where.length === 1 && keys.length === 1) {
|
|
79
|
-
ref.where = [{ ref: [Array.isArray(keys[0]) ? keys[0].join('_') : keys[0]] }, '=', ref.where[0]]
|
|
80
|
-
} else {
|
|
81
|
-
_resolveStructKeys(ref.where, keys)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// $value never comes, $count is 2many, $ref is to be checked
|
|
85
|
-
if (i === cqn.SELECT.from.ref.length - 1) {
|
|
86
|
-
if (target && !target.elements) delete cqn.SELECT.columns
|
|
87
|
-
if ((element && element.is2one) || (target && target._isSingleton) || _hasAllEntityKeysInWhere(keys, ref.where)) {
|
|
88
|
-
cqn.SELECT.one = true
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
prev = target
|
|
92
|
-
}
|
|
93
|
-
return cqn
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/*
|
|
97
|
-
* uses new odata2cqn
|
|
98
|
-
*/
|
|
99
|
-
const _newReadToCQN = ({ model, namespace }, target, req) => {
|
|
100
|
-
let parsed
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
parsed = cds.odata.parse.url(req.url || req._inRequestUrl)
|
|
104
|
-
} catch (err) {
|
|
105
|
-
throw getError(400, err.message)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
_postProcess(parsed, target, model, namespace)
|
|
109
|
-
|
|
110
|
-
const cqn = SELECT.from(parsed.SELECT.from, parsed.SELECT.columns)
|
|
111
|
-
if (parsed.SELECT.search) cqn.SELECT.search = parsed.SELECT.search
|
|
112
|
-
if (parsed.SELECT.where) cqn.SELECT.where = parsed.SELECT.where
|
|
113
|
-
if (parsed.SELECT.orderBy) cqn.SELECT.orderBy = parsed.SELECT.orderBy
|
|
114
|
-
if (parsed.SELECT.groupBy) cqn.SELECT.groupBy = parsed.SELECT.groupBy
|
|
115
|
-
if (parsed.SELECT.count) cqn.SELECT.count = parsed.SELECT.count
|
|
116
|
-
if (parsed.SELECT.one) {
|
|
117
|
-
cqn.SELECT.one = parsed.SELECT.one
|
|
118
|
-
} else if (parsed.SELECT.limit) {
|
|
119
|
-
_setLimits(cqn, parsed, target, model)
|
|
120
|
-
}
|
|
121
|
-
if (!cds.env.features.rest_new_parser) {
|
|
122
|
-
// REVISIT not needed for rest parser?
|
|
123
|
-
rewriteAsterisk({ query: cqn, target })
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return cqn
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = { _newReadToCQN }
|