@sap/cds 5.8.2 → 5.9.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 +214 -78
- package/app/fiori/preview.js +16 -11
- package/app/fiori/routes.js +3 -0
- package/app/index.js +1 -1
- package/bin/build/buildTaskFactory.js +3 -3
- package/bin/build/buildTaskProviderFactory.js +1 -1
- package/bin/build/constants.js +1 -1
- package/bin/build/provider/buildTaskHandlerEdmx.js +12 -7
- package/bin/build/provider/buildTaskHandlerInternal.js +1 -1
- package/bin/build/provider/buildTaskProviderInternal.js +8 -2
- package/bin/build/provider/hana/2migration.js +27 -24
- package/bin/build/provider/hana/index.js +17 -18
- package/bin/build/provider/hana/migrationtable.js +9 -10
- package/bin/build/provider/java-cf/index.js +4 -5
- package/bin/build/provider/node-cf/index.js +99 -6
- package/bin/cds.js +20 -17
- package/bin/deploy/to-hana/cfUtil.js +16 -19
- package/bin/deploy/to-hana/hana.js +7 -24
- package/bin/deploy/to-hana/hdiDeployUtil.js +8 -4
- package/bin/mtx/in-cds.js +2 -2
- package/bin/serve.js +12 -5
- package/bin/utils/modules.js +7 -0
- package/bin/version.js +56 -3
- package/lib/compile/cdsc.js +26 -3
- package/lib/compile/etc/_localized.js +36 -25
- package/lib/compile/etc/csv.js +8 -8
- package/lib/compile/for/drafts.js +9 -0
- package/lib/compile/for/java.js +16 -0
- package/lib/compile/for/nodejs.js +12 -0
- package/lib/compile/for/odata.js +1 -1
- package/lib/compile/index.js +3 -0
- package/lib/compile/minify.js +16 -2
- package/lib/compile/parse.js +2 -2
- package/lib/compile/resolve.js +35 -18
- package/lib/compile/to/json.js +3 -1
- package/lib/compile/to/sql.js +2 -2
- package/lib/compile/to/srvinfo.js +4 -2
- package/lib/connect/index.js +1 -1
- package/lib/core/entities.js +15 -14
- package/lib/core/index.js +39 -36
- package/lib/core/reflect.js +4 -2
- package/lib/deploy.js +114 -127
- package/lib/env/defaults.js +1 -0
- package/lib/env/index.js +165 -165
- package/lib/env/presets.js +1 -0
- package/lib/env/requires.js +120 -49
- package/lib/index.js +1 -0
- package/lib/log/format/kibana.js +2 -2
- package/lib/ql/SELECT.js +10 -0
- package/lib/ql/parse.js +1 -0
- package/lib/req/cds-context.js +4 -1
- package/lib/req/context.js +50 -56
- package/lib/req/event.js +1 -6
- package/lib/req/locale.js +6 -5
- package/lib/req/request.js +2 -0
- package/lib/req/user.js +7 -5
- package/lib/serve/Service-api.js +10 -7
- package/lib/serve/Service-dispatch.js +9 -11
- package/lib/serve/Service-methods.js +30 -41
- package/lib/serve/Transaction.js +10 -7
- package/lib/serve/adapters.js +7 -5
- package/lib/serve/index.js +24 -12
- package/lib/utils/data.js +1 -1
- package/lib/utils/index.js +27 -30
- package/lib/utils/resources/index.js +101 -0
- package/lib/utils/resources/tar.js +71 -0
- package/lib/utils/resources/utils.js +11 -0
- package/libx/_runtime/audit/Service.js +36 -39
- package/libx/_runtime/audit/generic/personal/access.js +3 -4
- package/libx/_runtime/audit/generic/personal/modification.js +3 -4
- package/libx/_runtime/audit/utils/v2.js +1 -2
- package/libx/_runtime/auth/index.js +126 -84
- package/libx/_runtime/auth/strategies/JWT.js +12 -19
- package/libx/_runtime/auth/strategies/dummy.js +1 -5
- package/libx/_runtime/auth/strategies/dwc.js +11 -9
- package/libx/_runtime/auth/strategies/mock.js +0 -4
- package/libx/_runtime/auth/strategies/{utils/xssec.js → xssecUtils.js} +7 -4
- package/libx/_runtime/auth/strategies/xsuaa.js +12 -19
- package/libx/_runtime/auth/utils.js +22 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/Dispatcher.js +104 -98
- package/libx/_runtime/cds-services/adapter/odata-v4/OData.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/action.js +13 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/language.js +2 -8
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/metadata.js +4 -29
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/read.js +2 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/request.js +3 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/handlers/update.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/ExpressionToCQN.js +4 -6
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/expandToCQN.js +24 -21
- package/libx/_runtime/cds-services/adapter/odata-v4/odata-to-cqn/index.js +8 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriHelper.js +1 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/DeserializerFactory.js +2 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ResourceJsonDeserializer.js +5 -6
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/invocation/DispatcherCommand.js +2 -6
- package/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/UriHelper.js +4 -1
- package/libx/_runtime/cds-services/adapter/odata-v4/to.js +1 -12
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js +33 -9
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/dispatcherUtils.js +50 -0
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/readAfterWrite.js +2 -2
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/request.js +10 -3
- package/libx/_runtime/cds-services/adapter/odata-v4/utils/result.js +9 -11
- package/libx/_runtime/cds-services/adapter/rest/RestRequest.js +6 -3
- package/libx/_runtime/cds-services/adapter/rest/handlers/operation.js +4 -2
- package/libx/_runtime/cds-services/adapter/rest/rest-to-cqn/utils.js +1 -1
- package/libx/_runtime/cds-services/adapter/rest/utils/binary.js +1 -1
- package/libx/_runtime/cds-services/adapter/rest/utils/key-value-utils.js +2 -3
- package/libx/_runtime/cds-services/adapter/rest/utils/parse-url.js +6 -4
- package/libx/_runtime/cds-services/adapter/rest/utils/result.js +1 -0
- package/libx/_runtime/cds-services/adapter/rest/utils/validation-checks.js +8 -5
- package/libx/_runtime/cds-services/services/Service.js +40 -0
- package/libx/_runtime/cds-services/services/utils/columns.js +4 -3
- package/libx/_runtime/cds-services/services/utils/compareJson.js +4 -4
- package/libx/_runtime/cds-services/services/utils/differ.js +3 -3
- package/libx/_runtime/cds-services/services/utils/handlerUtils.js +4 -4
- package/libx/_runtime/cds-services/services/utils/restrictions.js +78 -0
- package/libx/_runtime/cds-services/util/assert.js +20 -14
- package/libx/_runtime/cds.js +9 -1
- package/libx/_runtime/common/aspects/any.js +5 -0
- package/libx/_runtime/common/aspects/entity.js +25 -7
- package/libx/_runtime/common/aspects/utils.js +2 -2
- package/libx/_runtime/common/composition/data.js +6 -0
- package/libx/_runtime/common/composition/insert.js +3 -2
- package/libx/_runtime/common/composition/tree.js +4 -10
- package/libx/_runtime/common/composition/update.js +4 -4
- package/libx/_runtime/common/constants/draft.js +29 -26
- package/libx/_runtime/common/error/constants.js +2 -2
- package/libx/_runtime/common/error/frontend.js +7 -15
- package/libx/_runtime/common/generic/auth/capabilities.js +59 -0
- package/libx/_runtime/common/generic/auth/constants.js +20 -0
- package/libx/_runtime/common/generic/auth/expand.js +54 -0
- package/libx/_runtime/common/generic/auth/index.js +32 -0
- package/libx/_runtime/common/generic/auth/insertOnly.js +15 -0
- package/libx/_runtime/common/generic/auth/readOnly.js +26 -0
- package/libx/_runtime/common/generic/auth/requires.js +34 -0
- package/libx/_runtime/common/generic/auth/restrict.js +296 -0
- package/libx/_runtime/common/generic/auth/utils.js +213 -0
- package/libx/_runtime/common/generic/crud.js +14 -10
- package/libx/_runtime/common/generic/etag.js +1 -1
- package/libx/_runtime/common/generic/input.js +35 -35
- package/libx/_runtime/common/generic/sorting.js +2 -3
- package/libx/_runtime/common/generic/temporal.js +2 -2
- package/libx/_runtime/common/i18n/index.js +2 -31
- package/libx/_runtime/common/i18n/messages.properties +1 -1
- package/libx/_runtime/common/toggles/handler.js +21 -0
- package/libx/_runtime/common/utils/copy.js +10 -1
- package/libx/_runtime/common/utils/cqn2cqn4sql.js +100 -29
- package/libx/_runtime/common/utils/csn.js +63 -1
- package/libx/_runtime/common/utils/dollar.js +10 -1
- package/libx/_runtime/common/utils/draft.js +46 -7
- package/libx/_runtime/common/utils/entityFromCqn.js +13 -9
- package/libx/_runtime/common/utils/extensibilityUtils.js +18 -0
- package/libx/_runtime/common/utils/foreignKeyPropagations.js +88 -104
- package/libx/_runtime/common/utils/generateOnCond.js +9 -6
- package/libx/_runtime/common/utils/quotingStyles.js +2 -0
- package/libx/_runtime/common/utils/resolveStructured.js +25 -9
- package/libx/_runtime/common/utils/resolveView.js +4 -1
- package/libx/_runtime/common/utils/rewriteAsterisks.js +3 -16
- package/libx/_runtime/common/utils/structured.js +33 -37
- package/libx/_runtime/common/utils/template.js +17 -8
- package/libx/_runtime/common/utils/templateProcessor.js +28 -28
- package/libx/_runtime/db/data-conversion/post-processing.js +118 -417
- package/libx/_runtime/db/expand/expandCQNToJoin.js +45 -41
- package/libx/_runtime/db/expand/rawToExpanded.js +29 -8
- package/libx/_runtime/db/generic/index.js +1 -3
- package/libx/_runtime/db/generic/input.js +5 -10
- package/libx/_runtime/db/generic/rewrite.js +5 -2
- package/libx/_runtime/db/generic/structured.js +2 -2
- package/libx/_runtime/db/query/delete.js +2 -2
- package/libx/_runtime/db/query/insert.js +1 -1
- package/libx/_runtime/db/query/update.js +9 -14
- package/libx/_runtime/db/sql-builder/CreateBuilder.js +4 -3
- package/libx/_runtime/db/sql-builder/InsertBuilder.js +14 -1
- package/libx/_runtime/db/sql-builder/SelectBuilder.js +3 -2
- package/libx/_runtime/db/sql-builder/dataTypes.js +3 -3
- package/libx/_runtime/db/utils/columns.js +3 -3
- package/libx/_runtime/db/utils/normalizeTimeData.js +2 -2
- package/libx/_runtime/db/utils/propagateForeignKeys.js +6 -2
- package/libx/_runtime/extensibility/mps/index.js +5 -0
- package/libx/_runtime/extensibility/mps/service.js +111 -0
- package/libx/_runtime/extensibility/mps/tar.js +42 -0
- package/libx/_runtime/extensibility/mps/utils.js +11 -0
- package/libx/_runtime/{fiori → extensibility}/uiflex/handler/transformREAD.js +0 -0
- package/libx/_runtime/{fiori → extensibility}/uiflex/handler/transformRESULT.js +17 -5
- package/libx/_runtime/{fiori → extensibility}/uiflex/handler/transformWRITE.js +1 -0
- package/libx/_runtime/extensibility/uiflex/index.js +54 -0
- package/libx/_runtime/extensibility/uiflex/service.js +276 -0
- package/libx/_runtime/{fiori → extensibility}/uiflex/utils.js +22 -7
- package/libx/_runtime/fiori/generic/activate.js +2 -2
- package/libx/_runtime/fiori/generic/before.js +4 -4
- package/libx/_runtime/fiori/generic/new.js +3 -3
- package/libx/_runtime/fiori/generic/patch.js +1 -1
- package/libx/_runtime/fiori/generic/read.js +58 -66
- package/libx/_runtime/fiori/generic/readOverDraft.js +71 -16
- package/libx/_runtime/fiori/utils/handler.js +6 -13
- package/libx/_runtime/fiori/utils/where.js +6 -5
- package/libx/_runtime/hana/Service.js +4 -10
- package/libx/_runtime/hana/customBuilder/CustomSelectBuilder.js +2 -2
- package/libx/_runtime/hana/driver.js +2 -2
- package/libx/_runtime/hana/execute.js +29 -75
- package/libx/_runtime/hana/pool.js +1 -1
- package/libx/_runtime/hana/streaming.js +2 -1
- package/libx/_runtime/index.js +6 -6
- package/libx/_runtime/messaging/AMQPWebhookMessaging.js +5 -21
- package/libx/_runtime/messaging/Outbox.js +2 -2
- package/libx/_runtime/messaging/common-utils/AMQPClient.js +4 -14
- package/libx/_runtime/messaging/common-utils/connections.js +5 -7
- package/libx/_runtime/messaging/common-utils/normalizeIncomingMessage.js +30 -0
- package/libx/_runtime/messaging/enterprise-messaging-shared.js +2 -1
- package/libx/_runtime/messaging/enterprise-messaging-utils/EMManagement.js +36 -30
- package/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +19 -12
- package/libx/_runtime/messaging/enterprise-messaging.js +8 -8
- package/libx/_runtime/messaging/file-based.js +5 -5
- package/libx/_runtime/messaging/message-queuing.js +14 -12
- package/libx/_runtime/messaging/outbox/utils.js +18 -19
- package/libx/_runtime/messaging/redis-messaging.js +91 -0
- package/libx/_runtime/messaging/service.js +8 -6
- package/libx/_runtime/remote/Service.js +44 -8
- package/libx/_runtime/remote/utils/client.js +25 -13
- package/libx/_runtime/remote/utils/data.js +11 -11
- package/libx/_runtime/sqlite/Service.js +6 -9
- package/libx/_runtime/sqlite/customBuilder/CustomFunctionBuilder.js +5 -2
- package/libx/_runtime/types/api.js +10 -2
- package/libx/common/utils/ucsn.js +109 -0
- package/libx/gql/resolvers/crud/create.js +6 -1
- package/libx/gql/resolvers/crud/delete.js +6 -1
- package/libx/gql/resolvers/crud/read.js +6 -1
- package/libx/gql/resolvers/crud/update.js +9 -1
- package/libx/gql/resolvers/parse/ast2cqn/columns.js +3 -1
- package/libx/gql/schema/typeDefMap.js +2 -2
- package/libx/odata/afterburner.js +110 -16
- package/libx/odata/grammar.pegjs +9 -1
- package/libx/odata/parseToCqn.js +39 -0
- package/libx/odata/parser.js +1 -1
- package/libx/rest/RestAdapter.js +9 -1
- package/libx/rest/middleware/input.js +54 -0
- package/libx/rest/middleware/operation.js +14 -1
- package/libx/rest/middleware/parse.js +11 -7
- package/package.json +1 -1
- package/server.js +34 -19
- package/srv/audit-log.cds +2 -2
- package/srv/flex.cds +8 -2
- package/srv/flex.js +1 -1
- package/srv/mps.cds +23 -0
- package/srv/mps.js +1 -0
- package/libx/_runtime/auth/strategies/utils/uaa.js +0 -21
- package/libx/_runtime/common/generic/auth.js +0 -874
- package/libx/_runtime/common/toggles/alpha.js +0 -43
- package/libx/_runtime/db/generic/arrayed.js +0 -33
- package/libx/_runtime/fiori/uiflex/index.js +0 -35
- package/libx/_runtime/fiori/uiflex/service.js +0 -150
- package/libx/rest/utils/data.js +0 -60
package/libx/odata/parser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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:je},a=je,u="/",o=Te("/",!1),c=Te("?",!1),i=Te("&",!1),f="$count",l=Te("$count",!1),h="$ref",p=Te("$ref",!1),A="$value",d=Te("$value",!1),g=function(t){return[t]},v=function(t,r){return r},b="=",y=Te("=",!1),m="$skiptoken=",C=Te("$skiptoken=",!1),w="$apply=",x=Te("$apply=",!1),$="$select=",E=Te("$select=",!1),L="$expand=",S=Te("$expand=",!1),B="$filter=",T=Te("$filter=",!1),_="$orderby=",O=Te("$orderby=",!1),Z="$top=",R=Te("$top=",!1),z="$skip=",F=Te("$skip=",!1),j="$search=",k=Te("$search=",!1),N="$count=",D=Te("$count=",!1),U=Te("*",!1),P=Te(";",!1),q="/$count",I=Te("/$count",!1),M=function(t){return t?[t]:[]},X=function(t,r){t.push({xpr:r})},Y=function(t,r){t.push({val:r})},G=function(t,r,e){t.push(r,...e)},H=function(t,r){t.push(r)},J=function(t,r,e){t.push(r,...e)},K=":",Q=Te(":",!1),V="any",W=Te("any",!1),tt="all",rt=Te("all",!1),et=Te("asc",!1),nt="desc",st=Te("desc",!1),at=/^[a-zA-Z]/,ut=_e([["a","z"],["A","Z"]],!1,!1),ot=/^[a-zA-Z0-9\-]/,ct=_e([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),it=/^[^&]/,ft=_e(["&"],!0,!1),lt=Oe("a comparison"),ht=Te("eq",!1),pt=Te("ne",!1),At=Te("lt",!1),dt=Te("gt",!1),gt=Te("le",!1),vt=Te("ge",!1),bt=(Te("add",!1),Te("sub",!1),Te("mul",!1),Te("div",!1),Te("mod",!1),Oe("an operand")),yt=Oe("navigation with $count"),mt=function(t,r){return r},Ct=function(t,r){return r?{id:t,where:r}:t},wt=Oe("a reference"),xt=function(t,r){return r},$t=function(t){return{val:t}},Et=Te("{",!1),Lt=/^[^}]/,St=_e(["}"],!0,!1),Bt=Te("}",!1),Tt="[",_t=Te("[",!1),Ot="]",Zt=Te("]",!1),Rt=/^[^\]]/,zt=_e(["]"],!0,!1),Ft=Oe("a function call"),jt=function(t,r,e){return e},kt=Oe("a boolean function"),Nt="contains",Dt=Te("contains",!0),Ut="endswith",Pt=Te("endswith",!0),qt="startswith",It=Te("startswith",!0),Mt=Te("NOT",!0),Xt=Te("AND",!0),Yt=Te("OR",!0),Gt="aggregate",Ht=Te("aggregate",!1),Jt="groupby",Kt=Te("groupby",!1),Qt="filter",Vt=Te("filter",!1),Wt="expand",tr=Te("expand",!1),rr="search",er=Te("search",!1),nr="concat",sr=Te("concat",!1),ar="compute",ur=Te("compute",!1),or=Te("topcount",!0),cr=Te("bottomcount",!0),ir=Te("topsum",!0),fr=Te("bottomsum",!0),lr=Te("toppercent",!0),hr=Te("bottompercent",!0),pr="with",Ar=Te("with",!1),dr="from",gr=Te("from",!1),vr=Te("as",!1),br="rollup",yr=Te("rollup",!1),mr="$all",Cr=Te("$all",!1),wr="identity",xr=Te("identity",!1),$r="true",Er=Te("true",!1),Lr="false",Sr=Te("false",!1),Br=Oe("Edm.String"),Tr="'",_r=Te("'",!1),Or="''",Zr=Te("''",!1),Rr=/^[^']/,zr=_e(["'"],!0,!1),Fr='"',jr=Te('"',!1),kr='\\"',Nr=Te('\\"',!1),Dr=/^[^"]/,Ur=_e(['"'],!0,!1),Pr=/^[^ \t\n()"&;]/,qr=_e([" ","\t","\n","(",")",'"',"&",";"],!0,!1),Ir=/^[0-9]/,Mr=_e([["0","9"]],!1,!1),Xr="-",Yr=Te("-",!1),Gr=Te("T",!1),Hr=".",Jr=Te(".",!1),Kr=Te("Z",!1),Qr=Te("+",!1),Vr=/^[+\-]/,Wr=_e(["+","-"],!1,!1),te=Te("e",!1),re=/^[_a-zA-Z]/,ee=_e(["_",["a","z"],["A","Z"]],!1,!1),ne=/^[_a-zA-Z0-9"."]/,se=_e(["_",["a","z"],["A","Z"],["0","9"],'"',".",'"'],!1,!1),ae=/^[0-9a-fA-F]/,ue=_e([["0","9"],["a","f"],["A","F"]],!1,!1),oe=/^[^\/?]/,ce=_e(["/","?"],!0,!1),ie=/^[a-zA-Z0-9\-"."_~!$'()*+,;=:@"\/""?"]/,fe=_e([["a","z"],["A","Z"],["0","9"],"-",'"',".",'"',"_","~","!","$","'","(",")","*","+",",",";","=",":","@",'"',"/",'"','"',"?",'"'],!1,!1),le="binary'",he=Te("binary'",!1),pe=/^[a-zA-Z0-9\-_]/,Ae=_e([["a","z"],["A","Z"],["0","9"],"-","_"],!1,!1),de="==",ge=Te("==",!1),ve=Te(",",!1),be=Te("(",!1),ye=Te(")",!1),me=Oe("optional whitespaces"),Ce=/^[ \t\n]/,we=_e([" ","\t","\n"],!1,!1),xe=Oe("mandatory whitespaces"),$e=0,Ee=[{line:1,column:1}],Le=0,Se=[],Be=0;if("startRule"in r){if(!(r.startRule in s))throw new Error("Can't start parsing from rule \""+r.startRule+'".');a=s[r.startRule]}function Te(t,r){return{type:"literal",text:t,ignoreCase:r}}function _e(t,r,e){return{type:"class",parts:t,inverted:r,ignoreCase:e}}function Oe(t){return{type:"other",description:t}}function Ze(r){var e,n=Ee[r];if(n)return n;for(e=r-1;!Ee[e];)e--;for(n={line:(n=Ee[e]).line,column:n.column};e<r;)10===t.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return Ee[r]=n,n}function Re(t,r){var e=Ze(t),n=Ze(r);return{start:{offset:t,line:e.line,column:e.column},end:{offset:r,line:n.line,column:n.column}}}function ze(t){$e<Le||($e>Le&&(Le=$e,Se=[]),Se.push(t))}function Fe(t,r,e){return new peg$SyntaxError(peg$SyntaxError.buildMessage(t,r),t,r,e)}function je(){var r,e,s,a,f,l,h,p,A,d,g,v,b,y;if(r=$e,47===t.charCodeAt($e)?(e=u,$e++):(e=n,0===Be&&ze(o)),e===n&&(e=null),e!==n)if(s=$e,(a=ke())!==n&&(s,a=void(jn=a)),(s=a)!==n){if(a=$e,(f=_n())!==n)if(63===t.charCodeAt($e)?(l="?",$e++):(l=n,0===Be&&ze(c)),l!==n)if((h=_n())!==n)if((p=De())!==n){for(A=[],d=$e,(g=_n())!==n?(38===t.charCodeAt($e)?(v="&",$e++):(v=n,0===Be&&ze(i)),v!==n&&(b=_n())!==n&&(y=De())!==n?d=g=[g,v,b,y]:($e=d,d=n)):($e=d,d=n);d!==n;)A.push(d),d=$e,(g=_n())!==n?(38===t.charCodeAt($e)?(v="&",$e++):(v=n,0===Be&&ze(i)),v!==n&&(b=_n())!==n&&(y=De())!==n?d=g=[g,v,b,y]:($e=d,d=n)):($e=d,d=n);A!==n?a=f=[f,l,h,p,A]:($e=a,a=n)}else $e=a,a=n;else $e=a,a=n;else $e=a,a=n;else $e=a,a=n;a===n&&(a=null),a!==n&&(f=_n())!==n?(r,r=e=function(){if(kn)return jn.columns=[{args:[{val:1}],as:"$count",func:"count"}],delete jn.expand,delete jn.limit,delete jn.orderBy,jn.apply&&(jn.apply={apply:jn.apply},Xn(jn,jn.apply)),{SELECT:jn};let t;if(jn.expand){jn.columns||(jn.columns=["*"],t=!0);for(const t of jn.expand){const r=jn.columns.findIndex(Pn(t));r>-1&&jn.columns.splice(r,1),jn.columns.push(t)}delete jn.expand}return jn.count&&jn.apply&&(jn.__countAggregated=!0),Xn(jn,jn.apply,t),{SELECT:jn}}()):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function ke(){var r,e,s,a,c,i,b,y;return r=$e,t.substr($e,6)===f?(e=f,$e+=6):(e=n,0===Be&&ze(l)),e!==n&&(r,e=void(kn=!0)),(r=e)===n&&(r=$e,e=$e,t.substr($e,4)===h?(s=h,$e+=4):(s=n,0===Be&&ze(p)),s===n&&(t.substr($e,6)===A?(s=A,$e+=6):(s=n,0===Be&&ze(d))),(e=s!==n?t.substring(e,$e):s)!==n&&(r,y=e,e=!Nn.includes(y)&&{from:{ref:[y]}}),(r=e)===n&&(r=$e,e=$e,(s=xn())!==n?(a=$e,(c=Bn())!==n&&(i=Tn())!==n?a=c=[c,i]:($e=a,a=n),a===n&&(a=$e,(c=Bn())!==n&&(i=Ne())!==n&&(b=Tn())!==n?a=c=[c,i,b]:($e=a,a=n)),a===n&&(a=null),a!==n?(c=$e,Be++,i=Ln(),Be--,i===n?c=void 0:($e=c,c=n),c!==n?e=s=[s,a,c]:($e=e,e=n)):($e=e,e=n)):($e=e,e=n),e===n&&(e=$e,(s=Ln())!==n&&(e,s=g(s)),e=s),e!==n?(s=$e,47===t.charCodeAt($e)?(a=u,$e++):(a=n,0===Be&&ze(o)),a!==n&&(c=ke())!==n?(s,s=a=v(0,c)):($e=s,s=n),s===n&&(s=null),s!==n?(r,r=e=function(t,r){const[e,n]=t,s=[];if(n?n.length>2?s.push({id:e,where:n[1].map((t=>t.val&&t.val.match&&t.val.match(/^"(.*)"$/)?{val:t.val.match(/^"(.*)"$/)[1]}:t))}):s.push({id:e,where:[]}):zn?s.push(`${"object"==typeof e&&"val"in e?e.val:e}`):"object"==typeof e&&"string"==typeof e.val&&e.val.match(/^[1-9]\d*$|^0$/)?s.push({val:Dn(e.val)}):s.push(e),r&&r.from){const t=r.from.ref;Object.prototype.hasOwnProperty.call(t[0],"val")&&(s[s.length-1]={id:s[s.length-1],where:[t.shift()]}),s.push(...t)}const a={from:{ref:s}};return r&&r.columns&&(a.columns=r.columns),a}(e,s)):($e=r,r=n)):($e=r,r=n))),r}function Ne(){var r,e,s,a,u,o,c;return r=$e,(e=rn())!==n&&(r,e=g(e)),(r=e)===n&&(r=$e,(e=tn())!==n&&_n()!==n?(61===t.charCodeAt($e)?(s="=",$e++):(s=n,0===Be&&ze(y)),s!==n&&_n()!==n&&(a=rn())!==n?(u=$e,(o=Sn())!==n&&(c=Ne())!==n?u=o=[o,c]:($e=u,u=n),u===n&&(u=null),u!==n?(r,r=e=function(t,r,e){const n=[t,"=",r];return e&&n.push("and",...e[1]),n}(e,a,u)):($e=r,r=n)):($e=r,r=n)):($e=r,r=n)),r}function De(){var r,e,s,a;return(r=Ue())===n&&(r=$e,t.substr($e,11)===m?(e=m,$e+=11):(e=n,0===Be&&ze(C)),e!==n&&(s=_n())!==n?(a=function(){var r,e,s;r=$e,(e=wn())===n&&(e=null);e!==n?(s=function(){var r,e,s;r=$e,e=[],ie.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(fe));if(s!==n)for(;s!==n;)e.push(s),ie.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(fe));else e=n;r=e!==n?t.substring(r,$e):e;return r}(),s===n&&(s=null),s!==n?(r,a=e,r=e=void(s||Yn(a))):($e=r,r=n)):($e=r,r=n);var a;return r}(),a!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,7)===w?(e=w,$e+=7):(e=n,0===Be&&ze(x)),e!==n?(s=$e,(a=_n())!==n&&(s,a=void(jn.apply={})),(s=a)!==n&&(a=Qe())!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r===n&&(r=function(){var r,e,s,a,u,o;r=$e,at.test(t.charAt($e))?(e=t.charAt($e),$e++):(e=n,0===Be&&ze(ut));if(e!==n){for(s=[],ot.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ct));a!==n;)s.push(a),ot.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ct));if(s!==n)if(61===t.charCodeAt($e)?(a=b,$e++):(a=n,0===Be&&ze(y)),a!==n){for(u=[],it.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(ft));o!==n;)u.push(o),it.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(ft));u!==n?r=e=[e,s,a,u]:($e=r,r=n)}else $e=r,r=n;else $e=r,r=n}else $e=r,r=n;return r}()))),r}function Ue(){var r,e,s,a,u,o,c,i,f,l;if(r=$e,t.substr($e,8)===$?(e=$,$e+=8):(e=n,0===Be&&ze(E)),e!==n)if((s=_n())!==n)if((a=Pe())!==n){for(u=[],o=$e,(c=Sn())!==n&&(i=Pe())!==n?o=c=[c,i]:($e=o,o=n);o!==n;)u.push(o),o=$e,(c=Sn())!==n&&(i=Pe())!==n?o=c=[c,i]:($e=o,o=n);u!==n?r=e=[e,s,a,u]:($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;if(r===n){if(r=$e,t.substr($e,8)===L?(e=L,$e+=8):(e=n,0===Be&&ze(S)),e!==n)if((s=_n())!==n)if((a=qe())!==n){for(u=[],o=$e,(c=Sn())!==n&&(i=qe())!==n?o=c=[c,i]:($e=o,o=n);o!==n;)u.push(o),o=$e,(c=Sn())!==n&&(i=qe())!==n?o=c=[c,i]:($e=o,o=n);u!==n?r=e=[e,s,a,u]:($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;if(r===n&&(r=$e,t.substr($e,8)===B?(e=B,$e+=8):(e=n,0===Be&&ze(T)),e!==n&&(s=_n())!==n&&(a=Xe())!==n?(r,l=a,r=e=void(jn.where=l)):($e=r,r=n),r===n)){if(r=$e,t.substr($e,9)===_?(e=_,$e+=9):(e=n,0===Be&&ze(O)),e!==n)if((s=_n())!==n)if((a=Ke())!==n){for(u=[],o=$e,(c=Sn())!==n&&(i=Ke())!==n?o=c=[c,i]:($e=o,o=n);o!==n;)u.push(o),o=$e,(c=Sn())!==n&&(i=Ke())!==n?o=c=[c,i]:($e=o,o=n);u!==n?r=e=[e,s,a,u]:($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;r===n&&(r=$e,t.substr($e,5)===Z?(e=Z,$e+=5):(e=n,0===Be&&ze(R)),e!==n&&(s=_n())!==n?(a=function(){var t,r;t=$e,(r=wn())!==n&&(t,e=r,r=void((jn.limit||(jn.limit={})).rows={val:e}));var e;return t=r}(),a!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===z?(e=z,$e+=6):(e=n,0===Be&&ze(F)),e!==n&&(s=_n())!==n?(a=function(){var t,r;t=$e,(r=wn())!==n&&(t,r=void Yn(r));return t=r}(),a!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,8)===j?(e=j,$e+=8):(e=n,0===Be&&ze(k)),e!==n&&(s=_n())!==n&&(a=Ie())!==n?(r,r=e=void((f=a)&&(jn.search=f))):($e=r,r=n),r===n&&(r=$e,t.substr($e,7)===N?(e=N,$e+=7):(e=n,0===Be&&ze(D)),e!==n&&(s=_n())!==n?(a=function(){var t,r;t=$e,(r=mn())!==n&&(t,r=void(r&&(jn.count=!0)));return t=r}(),a!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n)))))}}return r}function Pe(){var r,e,s;return r=$e,42===t.charCodeAt($e)?(e="*",$e++):(e=n,0===Be&&ze(U)),e===n&&(e=tn()),e!==n&&(r,s=e,jn.columns=Array.isArray(jn.columns)?jn.columns:[],jn.columns.find(Pn(s))||jn.columns.push(s),e=s),r=e}function qe(){var r,e,s,a,u,o,c,i,f,l,h;if(r=$e,e=$e,42===t.charCodeAt($e)?(s="*",$e++):(s=n,0===Be&&ze(U)),s===n&&(s=tn()),s!==n&&(e,s=function(t){const r="*"===t?{}:t;return r.expand="*",Array.isArray(jn.expand)||(jn.expand=[]),jn.expand.find(Pn(r))||jn.expand.push(r),r}(s)),(e=s)!==n){if(s=$e,a=$e,(u=Bn())!==n&&(a,Fn.push(jn),jn=jn.expand[jn.expand.length-1],u=void(jn.expand="*")),(a=u)!==n){for(u=$e,o=[],c=$e,(i=_n())!==n?(59===t.charCodeAt($e)?(f=";",$e++):(f=n,0===Be&&ze(P)),f===n&&(f=null),f!==n&&(l=_n())!==n&&(h=Ue())!==n?c=i=[i,f,l,h]:($e=c,c=n)):($e=c,c=n);c!==n;)o.push(c),c=$e,(i=_n())!==n?(59===t.charCodeAt($e)?(f=";",$e++):(f=n,0===Be&&ze(P)),f===n&&(f=null),f!==n&&(l=_n())!==n&&(h=Ue())!==n?c=i=[i,f,l,h]:($e=c,c=n)):($e=c,c=n);o!==n&&(u,o=function(t){if(jn.columns){"*"===jn.expand&&(jn.expand=[]);for(const t of jn.columns)jn.expand.find(Pn(t))||jn.expand.push(t);delete jn.columns}else Array.isArray(jn.expand)&&-1===jn.expand.indexOf("*")&&jn.expand.unshift("*")}()),(u=o)!==n?(o=$e,(c=Tn())!==n&&(o,c=void(jn=Fn.pop())),(o=c)!==n?s=a=[a,u,o]:($e=s,s=n)):($e=s,s=n)}else $e=s,s=n;s===n&&(s=null),s!==n?(a=$e,(u=Sn())!==n&&(o=qe())!==n?a=u=[u,o]:($e=a,a=n),a===n&&(a=null),a!==n?(u=$e,t.substr($e,7)===q?(o=q,$e+=7):(o=n,0===Be&&ze(I)),o!==n&&(u,o=function(){const t=new Error("EXPAND_COUNT_UNSUPPORTED");throw t.statusCode=501,t}()),(u=o)===n&&(u=null),u!==n?r=e=[e,s,a,u]:($e=r,r=n)):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return r}function Ie(){var t,r;return t=$e,(r=Me())!==n&&(t,r=r),(t=r)===n&&(t=_n()),t}function Me(){var r,e,s,a,u,o,c;if(r=$e,e=$e,(s=an())===n&&(s=null),s!==n&&(e,s=M(s)),(e=s)!==n)if(s=$e,(a=Bn())!==n&&(u=Me())!==n&&(o=Tn())!==n?(s,s=a=X(e,u)):($e=s,s=n),s===n&&(s=$e,a=function(){var r,e,s,a,u;r=$e,34===t.charCodeAt($e)?(e=Fr,$e++):(e=n,0===Be&&ze(jr));if(e!==n){for(s=$e,a=[],t.substr($e,2)===kr?(u=kr,$e+=2):(u=n,0===Be&&ze(Nr)),u===n&&(Dr.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(Ur)));u!==n;)a.push(u),t.substr($e,2)===kr?(u=kr,$e+=2):(u=n,0===Be&&ze(Nr)),u===n&&(Dr.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(Ur)));(s=a!==n?t.substring(s,$e):a)!==n?(34===t.charCodeAt($e)?(a=Fr,$e++):(a=n,0===Be&&ze(jr)),a!==n?(r,r=e=s.replace(/\\\\/g,"\\").replace(/\\"/g,'"')):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return r}(),a!==n&&(s,a=Y(e,a)),(s=a)===n&&(s=$e,(a=Cn())!==n&&(s,a=Y(e,a)),(s=a)===n&&(s=$e,a=function(){var r,e,s;r=$e,e=[],Pr.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(qr));if(s!==n)for(;s!==n;)e.push(s),Pr.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(qr));else e=n;r=e!==n?t.substring(r,$e):e;return r}(),a!==n&&(s,a=Y(e,a)),s=a))),s!==n){for(a=[],u=$e,(o=un())===n&&(o=cn())===n&&(o=on()),o!==n&&(c=Me())!==n?(u,u=o=G(e,o,c)):($e=u,u=n);u!==n;)a.push(u),u=$e,(o=un())===n&&(o=cn())===n&&(o=on()),o!==n&&(c=Me())!==n?(u,u=o=G(e,o,c)):($e=u,u=n);a!==n?(r,r=e=e):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function Xe(){var t,r;return t=$e,(r=Ye())!==n&&(t,r=r),t=r}function Ye(){var r,e,s,a,u,o,c,i;if(r=$e,e=$e,(s=an())===n&&(s=null),s!==n&&(e,s=M(s)),(e=s)!==n)if(s=$e,(a=Bn())!==n&&(u=Ye())!==n&&(o=Tn())!==n?(s,s=a=X(e,u)):($e=s,s=n),s===n&&(s=$e,(a=Ve())!==n&&(s,i=a,a=void e.push(...i)),(s=a)===n&&(s=$e,(a=Ge())!==n&&(s,a=function(t,r){"not"===t[t.length-1]&&"not"===r[0]?t.push("(",...r,")"):t.push(...r)}(e,a)),(s=a)===n&&(s=$e,a=function(){var r,e,s,a;Be++,r=$e,t.substr($e,8).toLowerCase()===Nt?(e=t.substr($e,8),$e+=8):(e=n,0===Be&&ze(Dt));e===n&&(t.substr($e,8).toLowerCase()===Ut?(e=t.substr($e,8),$e+=8):(e=n,0===Be&&ze(Pt)),e===n&&(t.substr($e,10).toLowerCase()===qt?(e=t.substr($e,10),$e+=10):(e=n,0===Be&&ze(It))));e!==n&&Bn()!==n&&(s=We())!==n&&Sn()!==n&&(a=We())!==n&&Tn()!==n?(r,u=s,o=a,r=e={func:e.toLowerCase(),args:[u,o]}):($e=r,r=n);var u,o;Be--,r===n&&(e=n,0===Be&&ze(kt));return r}(),a!==n&&(s,a=function(t,r){t.push(r)}(e,a)),(s=a)===n&&(s=$e,(a=mn())!==n&&(s,a=Y(e,a)),s=a)))),s!==n){for(a=[],u=$e,(o=un())===n&&(o=cn()),o!==n&&(c=Ye())!==n?(u,u=o=G(e,o,c)):($e=u,u=n);u!==n;)a.push(u),u=$e,(o=un())===n&&(o=cn()),o!==n&&(c=Ye())!==n?(u,u=o=G(e,o,c)):($e=u,u=n);a!==n?(r,r=e=e):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function Ge(){var r,e,s,a,c,i,f;if(r=$e,e=$e,(s=xn())!==n&&(e,s=[s]),(e=s)!==n)if(47===t.charCodeAt($e)?(s=u,$e++):(s=n,0===Be&&ze(o)),s!==n){for(a=[],c=$e,(i=xn())!==n?(47===t.charCodeAt($e)?(f=u,$e++):(f=n,0===Be&&ze(o)),f!==n?(c,c=i=H(e,i)):($e=c,c=n)):($e=c,c=n);c!==n;)a.push(c),c=$e,(i=xn())!==n?(47===t.charCodeAt($e)?(f=u,$e++):(f=n,0===Be&&ze(o)),f!==n?(c,c=i=H(e,i)):($e=c,c=n)):($e=c,c=n);a!==n?(c=$e,i=function(){var r,e,s;r=$e,t.substr($e,3)===V?(e=V,$e+=3):(e=n,0===Be&&ze(W));e!==n&&Bn()!==n?((s=Je())===n&&(s=null),s!==n&&Tn()!==n?(r,r=e=s):($e=r,r=n)):($e=r,r=n);return r}(),i!==n&&(c,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 a=r[t];a.ref&&0===a.ref.length&&"="===r[t+1]?n[s++]={func:"contains",args:[{ref:e},r[t+=2]]}:n[s++]=a}return n.length<r.length?(e=t.pop(),["exists",{ref:[...t,{id:e,where:n}]}]):["exists",{ref:[...t,{id:e,where:r}]}]}(e,i)),(c=i)===n&&(c=$e,i=function(){var r,e,s;r=$e,t.substr($e,3)===tt?(e=tt,$e+=3):(e=n,0===Be&&ze(rt));e!==n&&Bn()!==n&&(s=Je())!==n&&Tn()!==n?(r,r=e=s):($e=r,r=n);return r}(),i!==n&&(c,i=function(t,r){let e=t.pop();return["not","exists",{ref:[...t,{id:e,where:["not",{xpr:[...r]}]}]}]}(e,i)),c=i),c!==n?(r,r=e=c):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function He(){var t,r,e,s,a,u,o,c,i;if(t=$e,r=$e,(e=an())===n&&(e=null),e!==n&&(r,e=(c=e)?[c]:[]),(r=e)!==n)if(e=$e,(s=Bn())!==n&&(a=He())!==n&&(u=Tn())!==n?(e,i=a,e=s=void r.push("(",...i,")")):($e=e,e=n),e===n&&(e=$e,(s=Ve())!==n&&(e,s=function(t,r){t.push(...r)}(r,s)),(e=s)===n&&(e=$e,(s=sn())!==n&&(e,s=function(t,r){t.push(r)}(r,s)),(e=s)===n&&(e=$e,(s=Ge())!==n&&(e,s=function(t,r){t.push(...r)}(r,s)),e=s))),e!==n){for(s=[],a=$e,(u=un())===n&&(u=cn()),u!==n&&(o=He())!==n?(a,a=u=J(r,u,o)):($e=a,a=n);a!==n;)s.push(a),a=$e,(u=un())===n&&(u=cn()),u!==n&&(o=He())!==n?(a,a=u=J(r,u,o)):($e=a,a=n);s!==n?(t,t=r=r):($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;return t}function Je(){var r,e,s,a;return r=$e,(e=xn())!==n?(58===t.charCodeAt($e)?(s=K,$e++):(s=n,0===Be&&ze(Q)),s!==n&&(a=He())!==n?(r,r=e=Gn(e,a)):($e=r,r=n)):($e=r,r=n),r}function Ke(){var r,e,s,a,u;return r=$e,e=$e,(s=Ge())!==n&&(e,s=function(){const t=new Error("ORDERBY_LAMBDA_UNSUPPORTED");throw t.statusCode=501,t}()),(e=s)===n&&(e=sn())===n&&(e=tn()),e!==n?(s=$e,On()!==n?(a=$e,"asc"===t.substr($e,3)?(u="asc",$e+=3):(u=n,0===Be&&ze(et)),u===n&&(t.substr($e,4)===nt?(u=nt,$e+=4):(u=n,0===Be&&ze(st))),(a=u!==n?t.substring(a,$e):u)!==n?(s,s=a):($e=s,s=n)):($e=s,s=n),s===n&&(s=null),s!==n?(r,r=e=function(t,r){const e=Zn(t,r&&{sort:r});jn.orderBy=jn.orderBy?[...jn.orderBy,e]:[e]}(e,s)):($e=r,r=n)):($e=r,r=n),r}function Qe(){var r,e,s,a,c,i;if(r=$e,(e=fn())!==n){for(s=[],a=$e,47===t.charCodeAt($e)?(c=u,$e++):(c=n,0===Be&&ze(o)),c!==n&&(i=fn())!==n?a=c=[c,i]:($e=a,a=n);a!==n;)s.push(a),a=$e,47===t.charCodeAt($e)?(c=u,$e++):(c=n,0===Be&&ze(o)),c!==n&&(i=fn())!==n?a=c=[c,i]:($e=a,a=n);s!==n?r=e=[e,s]:($e=r,r=n)}else $e=r,r=n;return r}function Ve(){var r,e,s,a,u,o;return Be++,r=$e,(e=We())!==n&&On()!==n?(s=$e,"eq"===t.substr($e,2)?(a="eq",$e+=2):(a=n,0===Be&&ze(ht)),a===n&&("ne"===t.substr($e,2)?(a="ne",$e+=2):(a=n,0===Be&&ze(pt)),a===n&&("lt"===t.substr($e,2)?(a="lt",$e+=2):(a=n,0===Be&&ze(At)),a===n&&("gt"===t.substr($e,2)?(a="gt",$e+=2):(a=n,0===Be&&ze(dt)),a===n&&("le"===t.substr($e,2)?(a="le",$e+=2):(a=n,0===Be&&ze(gt)),a===n&&("ge"===t.substr($e,2)?(a="ge",$e+=2):(a=n,0===Be&&ze(vt))))))),(s=a!==n?t.substring(s,$e):a)!==n&&(a=On())!==n&&(u=We())!==n?(r,r=e=[e,{eq:"=",ne:"!=",lt:"<",gt:">",le:"<=",ge:">="}[o=s]||o,u]):($e=r,r=n)):($e=r,r=n),Be--,r===n&&(e=n,0===Be&&ze(lt)),r}function We(){var r;return Be++,r=function(){var r,e,s,a,c,i,h;Be++,r=$e,e=[],s=$e,(a=xn())!==n?(c=$e,(i=Bn())!==n&&(h=Ne())!==n&&Tn()!==n?(c,c=i=mt(0,h)):($e=c,c=n),c===n&&(c=null),c!==n?(47===t.charCodeAt($e)?(i=u,$e++):(i=n,0===Be&&ze(o)),i!==n?(s,s=a=Ct(a,c)):($e=s,s=n)):($e=s,s=n)):($e=s,s=n);if(s!==n)for(;s!==n;)e.push(s),s=$e,(a=xn())!==n?(c=$e,(i=Bn())!==n&&(h=Ne())!==n&&Tn()!==n?(c,c=i=mt(0,h)):($e=c,c=n),c===n&&(c=null),c!==n?(47===t.charCodeAt($e)?(i=u,$e++):(i=n,0===Be&&ze(o)),i!==n?(s,s=a=Ct(a,c)):($e=s,s=n)):($e=s,s=n)):($e=s,s=n);else e=n;e!==n?(t.substr($e,6)===f?(s=f,$e+=6):(s=n,0===Be&&ze(l)),s!==n?(r,r=e={func:"count",as:"$count",args:[{ref:e}]}):($e=r,r=n)):($e=r,r=n);Be--,r===n&&(e=n,0===Be&&ze(yt));return r}(),r===n&&(r=sn())===n&&(r=rn())===n&&(r=tn())===n&&(r=en())===n&&(r=nn())===n&&(r=function(){var r,e,s,a,u;r=$e,91===t.charCodeAt($e)?(e=Tt,$e++):(e=n,0===Be&&ze(_t));if(e!==n){for(s=$e,a=[],Rt.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(zt));u!==n;)a.push(u),Rt.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(zt));(s=a!==n?t.substring(s,$e):a)!==n?(93===t.charCodeAt($e)?(a=Ot,$e++):(a=n,0===Be&&ze(Zt)),a!==n?(r,r=e={list:s.replace(/"/g,"").split(",").map((t=>({val:t})))}):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return r}()),Be--,r===n&&(n,0===Be&&ze(bt)),r}function tn(){var r,e,s,a,c,i,f,l;if(Be++,r=$e,(e=xn())!==n){for(s=[],a=$e,47===t.charCodeAt($e)?(c=u,$e++):(c=n,0===Be&&ze(o)),c!==n&&(i=xn())!==n?(a,a=c=xt(0,i)):($e=a,a=n);a!==n;)s.push(a),a=$e,47===t.charCodeAt($e)?(c=u,$e++):(c=n,0===Be&&ze(o)),c!==n&&(i=xn())!==n?(a,a=c=xt(0,i)):($e=a,a=n);s!==n?(r,l=s,r=e="null"===(f=e)?{val:null}:{ref:[f,...l]}):($e=r,r=n)}else $e=r,r=n;return Be--,r===n&&(e=n,0===Be&&ze(wt)),r}function rn(){var r,e,s;return r=$e,(e=mn())===n&&(e=function(){var r,e,s,a,u,o,c,i,f,l,h,p,A,d,g,v,b,y,m,C,w,x,$,E;r=$e,e=$e,s=[],Ir.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(Mr));if(a!==n)for(;a!==n;)s.push(a),Ir.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(Mr));else s=n;if(s!==n)if(45===t.charCodeAt($e)?(a=Xr,$e++):(a=n,0===Be&&ze(Yr)),a!==n)if(Ir.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(Mr)),u!==n)if(Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr)),o!==n)if(45===t.charCodeAt($e)?(c=Xr,$e++):(c=n,0===Be&&ze(Yr)),c!==n)if(Ir.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(Mr)),i!==n)if(Ir.test(t.charAt($e))?(f=t.charAt($e),$e++):(f=n,0===Be&&ze(Mr)),f!==n){if(l=$e,84===t.charCodeAt($e)?(h="T",$e++):(h=n,0===Be&&ze(Gr)),h!==n)if(Ir.test(t.charAt($e))?(p=t.charAt($e),$e++):(p=n,0===Be&&ze(Mr)),p!==n)if(Ir.test(t.charAt($e))?(A=t.charAt($e),$e++):(A=n,0===Be&&ze(Mr)),A!==n)if(58===t.charCodeAt($e)?(d=K,$e++):(d=n,0===Be&&ze(Q)),d!==n)if(Ir.test(t.charAt($e))?(g=t.charAt($e),$e++):(g=n,0===Be&&ze(Mr)),g!==n)if(Ir.test(t.charAt($e))?(v=t.charAt($e),$e++):(v=n,0===Be&&ze(Mr)),v!==n){if(b=$e,58===t.charCodeAt($e)?(y=K,$e++):(y=n,0===Be&&ze(Q)),y!==n)if(Ir.test(t.charAt($e))?(m=t.charAt($e),$e++):(m=n,0===Be&&ze(Mr)),m!==n)if(Ir.test(t.charAt($e))?(C=t.charAt($e),$e++):(C=n,0===Be&&ze(Mr)),C!==n){if(w=$e,46===t.charCodeAt($e)?(x=".",$e++):(x=n,0===Be&&ze(Jr)),x!==n){if($=[],Ir.test(t.charAt($e))?(E=t.charAt($e),$e++):(E=n,0===Be&&ze(Mr)),E!==n)for(;E!==n;)$.push(E),Ir.test(t.charAt($e))?(E=t.charAt($e),$e++):(E=n,0===Be&&ze(Mr));else $=n;$!==n?w=x=[x,$]:($e=w,w=n)}else $e=w,w=n;w===n&&(w=null),w!==n?b=y=[y,m,C,w]:($e=b,b=n)}else $e=b,b=n;else $e=b,b=n;else $e=b,b=n;b===n&&(b=null),b!==n?(90===t.charCodeAt($e)?(y="Z",$e++):(y=n,0===Be&&ze(Kr)),y===n&&(y=$e,43===t.charCodeAt($e)?(m="+",$e++):(m=n,0===Be&&ze(Qr)),m===n&&(45===t.charCodeAt($e)?(m=Xr,$e++):(m=n,0===Be&&ze(Yr))),m!==n?(Ir.test(t.charAt($e))?(C=t.charAt($e),$e++):(C=n,0===Be&&ze(Mr)),C!==n?(Ir.test(t.charAt($e))?(w=t.charAt($e),$e++):(w=n,0===Be&&ze(Mr)),w!==n?(58===t.charCodeAt($e)?(x=K,$e++):(x=n,0===Be&&ze(Q)),x!==n?(Ir.test(t.charAt($e))?($=t.charAt($e),$e++):($=n,0===Be&&ze(Mr)),$!==n?(Ir.test(t.charAt($e))?(E=t.charAt($e),$e++):(E=n,0===Be&&ze(Mr)),E!==n?y=m=[m,C,w,x,$,E]:($e=y,y=n)):($e=y,y=n)):($e=y,y=n)):($e=y,y=n)):($e=y,y=n)):($e=y,y=n)),y===n&&(y=null),y!==n?l=h=[h,p,A,d,g,v,b,y]:($e=l,l=n)):($e=l,l=n)}else $e=l,l=n;else $e=l,l=n;else $e=l,l=n;else $e=l,l=n;else $e=l,l=n;else $e=l,l=n;l===n&&(l=null),l!==n?e=s=[s,a,u,o,c,i,f,l]:($e=e,e=n)}else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;r=e!==n?t.substring(r,$e):e;return r}()),e!==n&&(r,e=$t(e)),(r=e)===n&&(r=$e,(e=$n())!==n&&(r,e=$t(e)),(r=e)===n&&(r=$e,e=function(){var r,e,s,a,u,o,c,i,f,l;r=$e,e=$e,s=$e,Vr.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(Wr));a===n&&(a=null);if(a!==n){if(u=[],Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr)),o!==n)for(;o!==n;)u.push(o),Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr));else u=n;if(u!==n){if(o=$e,46===t.charCodeAt($e)?(c=Hr,$e++):(c=n,0===Be&&ze(Jr)),c!==n){if(i=[],Ir.test(t.charAt($e))?(f=t.charAt($e),$e++):(f=n,0===Be&&ze(Mr)),f!==n)for(;f!==n;)i.push(f),Ir.test(t.charAt($e))?(f=t.charAt($e),$e++):(f=n,0===Be&&ze(Mr));else i=n;i!==n?o=c=[c,i]:($e=o,o=n)}else $e=o,o=n;if(o===n&&(o=null),o!==n){if(c=$e,101===t.charCodeAt($e)?(i="e",$e++):(i=n,0===Be&&ze(te)),i!==n){if(f=[],Ir.test(t.charAt($e))?(l=t.charAt($e),$e++):(l=n,0===Be&&ze(Mr)),l!==n)for(;l!==n;)f.push(l),Ir.test(t.charAt($e))?(l=t.charAt($e),$e++):(l=n,0===Be&&ze(Mr));else f=n;f!==n?c=i=[i,f]:($e=c,c=n)}else $e=c,c=n;c===n&&(c=null),c!==n?s=a=[a,u,o,c]:($e=s,s=n)}else $e=s,s=n}else $e=s,s=n}else $e=s,s=n;e=s!==n?t.substring(e,$e):s;e!==n&&(r,e=Dn(e));return r=e}(),e!==n&&(r,e="number"==typeof(s=e)?{val:s}:{val:s,literal:"number"}),(r=e)===n&&(r=$e,(e=Cn())!==n&&(r,e=$t(e)),(r=e)===n&&(r=$e,e=function(){var r,e,s,a,u,o;r=$e,t.substr($e,7)===le?(e=le,$e+=7):(e=n,0===Be&&ze(he));if(e!==n){if(s=$e,a=$e,u=[],pe.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Ae)),o!==n)for(;o!==n;)u.push(o),pe.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Ae));else u=n;u!==n?(t.substr($e,2)===de?(o=de,$e+=2):(o=n,0===Be&&ze(ge)),o===n&&(61===t.charCodeAt($e)?(o=b,$e++):(o=n,0===Be&&ze(y))),o===n&&(o=null),o!==n?a=u=[u,o]:($e=a,a=n)):($e=a,a=n),(s=a!==n?t.substring(s,$e):a)!==n?(39===t.charCodeAt($e)?(a=Tr,$e++):(a=n,0===Be&&ze(_r)),a!==n?(r,r=e=Un(s)):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return r}(),e!==n&&(r,e=$t(e)),r=e)))),r}function en(){var r,e,s,a,u,o;if(r=$e,e=$e,s=$e,123===t.charCodeAt($e)?(a="{",$e++):(a=n,0===Be&&ze(Et)),a!==n){for(u=[],(o=en())===n&&(Lt.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(St)));o!==n;)u.push(o),(o=en())===n&&(Lt.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(St)));u!==n?(125===t.charCodeAt($e)?(o="}",$e++):(o=n,0===Be&&ze(Bt)),o!==n?s=a=[a,u,o]:($e=s,s=n)):($e=s,s=n)}else $e=s,s=n;return(e=s!==n?t.substring(e,$e):s)!==n&&(r,e=$t(e)),r=e}function nn(){var r,e,s,a,u,o,c,i;if(r=$e,e=$e,s=$e,91===t.charCodeAt($e)?(a=Tt,$e++):(a=n,0===Be&&ze(_t)),a!==n&&(u=_n())!==n?(93===t.charCodeAt($e)?(o=Ot,$e++):(o=n,0===Be&&ze(Zt)),o!==n?s=a=[a,u,o]:($e=s,s=n)):($e=s,s=n),s===n)if(s=$e,91===t.charCodeAt($e)?(a=Tt,$e++):(a=n,0===Be&&ze(_t)),a!==n)if((u=_n())!==n)if(123===t.charCodeAt($e)?(o="{",$e++):(o=n,0===Be&&ze(Et)),o!==n){for(c=[],(i=nn())===n&&(Rt.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(zt)));i!==n;)c.push(i),(i=nn())===n&&(Rt.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(zt)));c!==n?(93===t.charCodeAt($e)?(i=Ot,$e++):(i=n,0===Be&&ze(Zt)),i!==n?s=a=[a,u,o,c,i]:($e=s,s=n)):($e=s,s=n)}else $e=s,s=n;else $e=s,s=n;else $e=s,s=n;return(e=s!==n?t.substring(e,$e):s)!==n&&(r,e=$t(e)),r=e}function sn(){var r,e,s,a,u,o,c;if(Be++,r=$e,e=$e,s=[],at.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ut)),a!==n)for(;a!==n;)s.push(a),at.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ut));else s=n;if((e=s!==n?t.substring(e,$e):s)!==n)if((s=Bn())!==n)if((a=We())!==n){for(u=[],o=$e,Sn()!==n&&(c=We())!==n?(o,o=jt(0,0,c)):($e=o,o=n);o!==n;)u.push(o),o=$e,Sn()!==n&&(c=We())!==n?(o,o=jt(0,0,c)):($e=o,o=n);u!==n&&(o=Tn())!==n?(r,r=e=function(t,r,e){if(Rn&&!(t.toLowerCase()in Rn.functions))throw Object.assign(new Error(`"${t}" is an unknown function in OData URL spec (strict mode)`),{statusCode:400});return{func:t.toLowerCase(),args:[r,...e]}}(e,a,u)):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;return Be--,r===n&&(e=n,0===Be&&ze(Ft)),r}function an(){var r,e;return r=$e,_n()!==n?("not"===t.substr($e,3).toLowerCase()?(e=t.substr($e,3),$e+=3):(e=n,0===Be&&ze(Mt)),e!==n&&On()!==n?(r,r="not"):($e=r,r=n)):($e=r,r=n),r}function un(){var r,e;return r=$e,On()!==n?("and"===t.substr($e,3).toLowerCase()?(e=t.substr($e,3),$e+=3):(e=n,0===Be&&ze(Xt)),e!==n&&On()!==n?(r,r="and"):($e=r,r=n)):($e=r,r=n),r}function on(){var t,r;return t=$e,(r=On())!==n&&(t,r="and"),t=r}function cn(){var r,e;return r=$e,On()!==n?("or"===t.substr($e,2).toLowerCase()?(e=t.substr($e,2),$e+=2):(e=n,0===Be&&ze(Yt)),e!==n&&On()!==n?(r,r="or"):($e=r,r=n)):($e=r,r=n),r}function fn(){var r,e,s;return r=$e,t.substr($e,9)===Gt?(e=Gt,$e+=9):(e=n,0===Be&&ze(Ht)),e!==n?(s=function(){var t,r,e,s,a;if(t=$e,Bn()!==n)if(_n()!==n)if((r=ln())!==n){for(e=[],s=$e,_n()!==n&&Sn()!==n&&_n()!==n&&(a=ln())!==n?(s,s=v(0,a)):($e=s,s=n);s!==n;)e.push(s),s=$e,_n()!==n&&Sn()!==n&&_n()!==n&&(a=ln())!==n?(s,s=v(0,a)):($e=s,s=n);e!==n&&(s=_n())!==n&&Tn()!==n?(t,t=function(t,r){let e=jn.apply;e.aggregate&&(jn.apply={apply:e},e.groupBy&&(jn.apply.groupBy=e.groupBy),e=jn.apply),e.aggregate=[t,...r]}(r,e)):($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,7)===Jt?(e=Jt,$e+=7):(e=n,0===Be&&ze(Kt)),e!==n?(s=function(){var t,r,e,s,a,u,o,c,i;if(t=$e,(r=Bn())!==n)if((e=Bn())!==n)if((s=gn())!==n){for(a=[],u=$e,(o=Sn())!==n&&(c=gn())!==n?(u,u=o=v(0,c)):($e=u,u=n);u!==n;)a.push(u),u=$e,(o=Sn())!==n&&(c=gn())!==n?(u,u=o=v(0,c)):($e=u,u=n);a!==n?(u=$e,(o=Tn())!==n&&(u,o=function(t,r){let e=jn.apply;(e.groupBy||e.where||e.search)&&(jn.apply={apply:e},e=jn.apply),e.groupBy=[t,...r]}(s,a)),(u=o)!==n?(o=$e,(c=Sn())!==n&&(i=Qe())!==n?o=c=[c,i]:($e=o,o=n),o===n&&(o=null),o!==n&&(c=Tn())!==n?t=r=[r,e,s,a,u,o,c]:($e=t,t=n)):($e=t,t=n)):($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===Qt?(e=Qt,$e+=6):(e=n,0===Be&&ze(Vt)),e!==n&&(s=vn())!==n?r=e=[e,s]:($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===Wt?(e=Wt,$e+=6):(e=n,0===Be&&ze(tr)),e!==n&&(s=bn())!==n?r=e=[e,s]:($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===rr?(e=rr,$e+=6):(e=n,0===Be&&ze(er)),e!==n?(s=function(){var t,r,e,s,a,u;t=$e,(r=Bn())!==n&&(e=_n())!==n?(s=$e,(a=Ie())!==n&&(s,a=function(t){if(!t)return;let r=jn.apply;r.search&&(jn.apply={apply:r},r=jn.apply),r.search=t}(a)),(s=a)!==n&&(a=_n())!==n&&(u=Tn())!==n?t=r=[r,e,s,a,u]:($e=t,t=n)):($e=t,t=n);return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===nr?(e=nr,$e+=6):(e=n,0===Be&&ze(sr)),e!==n?(s=function(){var t,r,e,s,a,u,o,c,i,f;if(t=$e,(r=Bn())!==n)if((e=_n())!==n)if((s=Qe())!==n){if(a=[],u=$e,(o=_n())!==n&&(c=Sn())!==n&&(i=_n())!==n&&(f=Qe())!==n?u=o=[o,c,i,f]:($e=u,u=n),u!==n)for(;u!==n;)a.push(u),u=$e,(o=_n())!==n&&(c=Sn())!==n&&(i=_n())!==n&&(f=Qe())!==n?u=o=[o,c,i,f]:($e=u,u=n);else a=n;a!==n&&(u=_n())!==n&&(o=Tn())!==n?t=r=[r,e,s,a,u,o]:($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,7)===ar?(e=ar,$e+=7):(e=n,0===Be&&ze(ur)),e!==n?(s=function(){var t,r,e,s,a,u,o,c,i,f;if(t=$e,(r=Bn())!==n)if((e=_n())!==n)if((s=yn())!==n){for(a=[],u=$e,(o=_n())!==n&&(c=Sn())!==n&&(i=_n())!==n&&(f=yn())!==n?u=o=[o,c,i,f]:($e=u,u=n);u!==n;)a.push(u),u=$e,(o=_n())!==n&&(c=Sn())!==n&&(i=_n())!==n&&(f=yn())!==n?u=o=[o,c,i,f]:($e=u,u=n);a!==n&&(u=_n())!==n&&(o=Tn())!==n?t=r=[r,e,s,a,u,o]:($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,"topcount"===t.substr($e,8).toLowerCase()?(e=t.substr($e,8),$e+=8):(e=n,0===Be&&ze(or)),e===n&&("bottomcount"===t.substr($e,11).toLowerCase()?(e=t.substr($e,11),$e+=11):(e=n,0===Be&&ze(cr)),e===n&&("topsum"===t.substr($e,6).toLowerCase()?(e=t.substr($e,6),$e+=6):(e=n,0===Be&&ze(ir)),e===n&&("bottomsum"===t.substr($e,9).toLowerCase()?(e=t.substr($e,9),$e+=9):(e=n,0===Be&&ze(fr)),e===n&&("toppercent"===t.substr($e,10).toLowerCase()?(e=t.substr($e,10),$e+=10):(e=n,0===Be&&ze(lr)),e===n&&("bottompercent"===t.substr($e,13).toLowerCase()?(e=t.substr($e,13),$e+=13):(e=n,0===Be&&ze(hr))))))),e!==n?(s=function(){var t,r,e;t=$e,Bn()!==n&&_n()!==n&&(r=We())!==n&&_n()!==n&&Sn()!==n&&_n()!==n&&(e=We())!==n&&_n()!==n&&Tn()!==n?(t,t=[r,e]):($e=t,t=n);return t}(),s!==n?(r,r=e=function(t,r){if(!{topcount:!0,bottomcount:!0,topsum:!1,bottomsum:!1,toppercent:!1,bottompercent:!1}[t=t.toLowerCase()])throw Object.assign(new Error(`Transformation "${t}" in $apply is not supported yet.`),{statusCode:501});(jn.apply.aggregate||(jn.apply.aggregate=[])).push({func:t,args:r})}(e,s)):($e=r,r=n)):($e=r,r=n),r===n&&(r=function(){var r;t.substr($e,8)===wr?(r=wr,$e+=8):(r=n,0===Be&&ze(xr));return r}())))))))),r}function ln(){var r,e,s,a;return r=$e,e=$e,t.substr($e,6)===f?(s=f,$e+=6):(s=n,0===Be&&ze(l)),s!==n&&(a=dn())!==n?(e,e=s={func:"count",args:[{val:1}],as:a}):($e=e,e=n),e===n&&(e=hn()),e!==n&&(r,e=e),r=e}function hn(){var t,r,e,s,a;return t=$e,(r=tn())!==n&&(e=pn())!==n?((s=An())===n&&(s=null),s!==n&&(a=dn())!==n?(t,t=r={func:e,args:[r],as:a}):($e=t,t=n)):($e=t,t=n),t===n&&(t=$e,(r=xn())!==n&&(e=Bn())!==n&&(s=hn())!==n&&(a=Tn())!==n?t=r=[r,e,s,a]:($e=t,t=n)),t}function pn(){var r,e,s,a,u;if(r=$e,On()!==n)if(t.substr($e,4)===pr?(e=pr,$e+=4):(e=n,0===Be&&ze(Ar)),e!==n)if(On()!==n){if(s=$e,a=[],at.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(ut)),u!==n)for(;u!==n;)a.push(u),at.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(ut));else a=n;(s=a!==n?t.substring(s,$e):a)!==n?(r,r=s.toLowerCase()):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;return r}function An(){var r,e,s,a,u,o,c;return r=$e,(e=On())!==n?(t.substr($e,4)===dr?(s=dr,$e+=4):(s=n,0===Be&&ze(gr)),s!==n&&(a=On())!==n&&(u=tn())!==n&&(o=pn())!==n?((c=An())===n&&(c=null),c!==n?r=e=[e,s,a,u,o,c]:($e=r,r=n)):($e=r,r=n)):($e=r,r=n),r}function dn(){var r,e,s;return r=$e,On()!==n?("as"===t.substr($e,2)?(e="as",$e+=2):(e=n,0===Be&&ze(vr)),e!==n&&On()!==n&&(s=xn())!==n?(r,r=s):($e=r,r=n)):($e=r,r=n),r}function gn(){var r,e;return r=$e,e=function(){var r,e,s,a,u,o,c,i,f,l,h;r=$e,e=$e,t.substr($e,6)===br?(s=br,$e+=6):(s=n,0===Be&&ze(yr));if(s!==n)if((a=Bn())!==n)if((u=_n())!==n)if(t.substr($e,4)===mr?(o=mr,$e+=4):(o=n,0===Be&&ze(Cr)),o===n&&(o=tn()),o!==n){if(c=[],i=$e,(f=_n())!==n&&(l=Sn())!==n&&(h=tn())!==n?i=f=[f,l,h]:($e=i,i=n),i!==n)for(;i!==n;)c.push(i),i=$e,(f=_n())!==n&&(l=Sn())!==n&&(h=tn())!==n?i=f=[f,l,h]:($e=i,i=n);else c=n;c!==n&&(i=_n())!==n&&(f=Tn())!==n?e=s=[s,a,u,o,c,i,f]:($e=e,e=n)}else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;e!==n&&(r,e=function(t){const r=new Error("Rollup in groupby is not supported yet.");throw r.statusCode=501,r}());return r=e}(),e===n&&(e=tn()),e!==n&&(r,e=e),r=e}function vn(){var t,r,e,s,a,u;return t=$e,(r=Bn())!==n&&(e=_n())!==n?(s=$e,(a=Xe())!==n&&(s,a=function(t){let r=jn.apply;r.where&&(jn.apply={apply:r},r=jn.apply),r.where=t}(a)),(s=a)!==n&&(a=_n())!==n&&(u=Tn())!==n?t=r=[r,e,s,a,u]:($e=t,t=n)):($e=t,t=n),t}function bn(){var t,r,e,s,a,u,o,c,i,f,l,h,p,A;if(t=$e,(r=Bn())!==n)if((e=_n())!==n)if((s=tn())!==n)if((a=_n())!==n)if((u=Sn())!==n)if((o=_n())!==n){if(c=$e,(i=bn())!==n){for(f=[],l=$e,(h=_n())!==n&&(p=Sn())!==n&&(A=bn())!==n?l=h=[h,p,A]:($e=l,l=n);l!==n;)f.push(l),l=$e,(h=_n())!==n&&(p=Sn())!==n&&(A=bn())!==n?l=h=[h,p,A]:($e=l,l=n);f!==n?c=i=[i,f]:($e=c,c=n)}else $e=c,c=n;if(c===n)if(c=$e,(i=vn())!==n){for(f=[],l=$e,(h=_n())!==n&&(p=Sn())!==n&&(A=bn())!==n?l=h=[h,p,A]:($e=l,l=n);l!==n;)f.push(l),l=$e,(h=_n())!==n&&(p=Sn())!==n&&(A=bn())!==n?l=h=[h,p,A]:($e=l,l=n);f!==n?c=i=[i,f]:($e=c,c=n)}else $e=c,c=n;c!==n&&(i=_n())!==n&&(f=Tn())!==n?t=r=[r,e,s,a,u,o,c,i,f]:($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}function yn(){var t,r,e;return t=$e,(r=Ye())!==n&&(e=dn())!==n?t=r=[r,e]:($e=t,t=n),t}function mn(){var r,e;return r=$e,t.substr($e,4)===$r?(e=$r,$e+=4):(e=n,0===Be&&ze(Er)),e===n&&(t.substr($e,5)===Lr?(e=Lr,$e+=5):(e=n,0===Be&&ze(Sr))),e!==n&&(r,e="true"===e),r=e}function Cn(){var r,e,s,a,u;if(Be++,r=$e,39===t.charCodeAt($e)?(e=Tr,$e++):(e=n,0===Be&&ze(_r)),e!==n){for(s=$e,a=[],t.substr($e,2)===Or?(u=Or,$e+=2):(u=n,0===Be&&ze(Zr)),u===n&&(Rr.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(zr)));u!==n;)a.push(u),t.substr($e,2)===Or?(u=Or,$e+=2):(u=n,0===Be&&ze(Zr)),u===n&&(Rr.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(zr)));(s=a!==n?t.substring(s,$e):a)!==n?(39===t.charCodeAt($e)?(a=Tr,$e++):(a=n,0===Be&&ze(_r)),a!==n?(r,r=e=s.replace(/''/g,"'")):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return Be--,r===n&&(e=n,0===Be&&ze(Br)),r}function wn(){var r,e,s,a,u,o;if(r=$e,e=$e,s=$e,Vr.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(Wr)),a===n&&(a=null),a!==n){if(u=[],Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr)),o!==n)for(;o!==n;)u.push(o),Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr));else u=n;u!==n?s=a=[a,u]:($e=s,s=n)}else $e=s,s=n;return(e=s!==n?t.substring(e,$e):s)!==n&&(r,e=parseInt(e)),r=e}function xn(){var r,e,s,a,u,o,c,i;if(r=$e,e=$e,Be++,s=mn(),Be--,s===n?e=void 0:($e=e,e=n),e!==n)if(s=$e,Be++,a=$n(),Be--,a===n?s=void 0:($e=s,s=n),s!==n){if(a=$e,u=$e,re.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(ee)),o!==n){for(c=[],ne.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(se));i!==n;)c.push(i),ne.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(se));c!==n?u=o=[o,c]:($e=u,u=n)}else $e=u,u=n;(a=u!==n?t.substring(a,$e):u)!==n?(r,r=e=a):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function $n(){var r,e,s,a,u,o,c,i,f,l,h,p,A,d;return r=$e,e=$e,(s=En())!==n&&(a=En())!==n?(45===t.charCodeAt($e)?(u=Xr,$e++):(u=n,0===Be&&ze(Yr)),u===n&&(u=null),u!==n&&(o=En())!==n?(45===t.charCodeAt($e)?(c=Xr,$e++):(c=n,0===Be&&ze(Yr)),c===n&&(c=null),c!==n&&(i=En())!==n?(45===t.charCodeAt($e)?(f=Xr,$e++):(f=n,0===Be&&ze(Yr)),f===n&&(f=null),f!==n&&(l=En())!==n?(45===t.charCodeAt($e)?(h=Xr,$e++):(h=n,0===Be&&ze(Yr)),h===n&&(h=null),h!==n&&(p=En())!==n&&(A=En())!==n&&(d=En())!==n?e=s=[s,a,u,o,c,i,f,l,h,p,A,d]:($e=e,e=n)):($e=e,e=n)):($e=e,e=n)):($e=e,e=n)):($e=e,e=n),r=e!==n?t.substring(r,$e):e}function En(){var r,e,s,a,u,o;return r=$e,e=$e,ae.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(ue)),s!==n?(ae.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ue)),a!==n?(ae.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(ue)),u!==n?(ae.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(ue)),o!==n?e=s=[s,a,u,o]:($e=e,e=n)):($e=e,e=n)):($e=e,e=n)):($e=e,e=n),r=e!==n?t.substring(r,$e):e}function Ln(){var r,e,s,a;if(r=$e,e=$e,s=[],oe.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ce)),a!==n)for(;a!==n;)s.push(a),oe.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ce));else s=n;return(e=s!==n?t.substring(e,$e):s)!==n&&(r,e={val:e}),r=e}function Sn(){var r,e,s,a;return r=$e,(e=_n())!==n?(44===t.charCodeAt($e)?(s=",",$e++):(s=n,0===Be&&ze(ve)),s!==n&&(a=_n())!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r}function Bn(){var r,e,s,a;return r=$e,(e=_n())!==n?(40===t.charCodeAt($e)?(s="(",$e++):(s=n,0===Be&&ze(be)),s!==n&&(a=_n())!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r}function Tn(){var r,e,s;return r=$e,(e=_n())!==n?(41===t.charCodeAt($e)?(s=")",$e++):(s=n,0===Be&&ze(ye)),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r}function _n(){var r,e,s;for(Be++,r=$e,e=[],Ce.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(we));s!==n;)e.push(s),Ce.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(we));return r=e!==n?t.substring(r,$e):e,Be--,r===n&&(e=n,0===Be&&ze(me)),r}function On(){var r,e,s;if(Be++,r=$e,e=[],Ce.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(we)),s!==n)for(;s!==n;)e.push(s),Ce.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(we));else e=n;return r=e!==n?t.substring(r,$e):e,Be--,r===n&&(e=n,0===Be&&ze(xe)),r}const Zn=Object.assign,{strict:Rn,minimal:zn}=r,Fn=[];let jn,kn;const Nn=["$value"],Dn=r.safeNumber||function(t){const r=Number(t);return Number.isSafeInteger(r)?r:t},Un=r.standardBase64||function(t){return(t=t.replace(/_/g,"/").replace(/-/g,"+")).padEnd(t.length+t.length%4,"=")},Pn=t=>r=>t===r||t.as&&r.as&&t.as===r.as||r.as&&t.ref&&r.as===t.ref[t.ref.length-1]||t.ref&&r.ref&&t.ref.join("")===r.ref.join(""),qn=t=>r=>{if(Array.isArray(r))return r.map(qn(t));const e=r.ref&&t.find((t=>t.as&&t.func&&t.as===r.ref[0]));return e||r},In=t=>r=>Array.isArray(r)?r.map(In(t)):r.ref&&!t.find(Pn(r))?{val:null}:r,Mn=(t,r)=>{if(1===r.ref.length)t.find(Pn(r))||t.push(r);else{const e=r.ref.shift(),n=t.find((t=>t.ref&&t.ref[0]===e));if(n)Mn(n.expand,r);else{const n={ref:[e],expand:[]};Mn(n.expand,r),t.push(n)}}},Xn=(t,r,e=!1)=>{if(!r)return;if(t.apply&&delete t.apply,(r.apply||r.where&&t.where||r.search&&t.search)&&(t.from={SELECT:{from:t.from}}),r.where&&(t.where?t.from.SELECT.where=r.where:t.where=r.where),r.search&&(t.search?t.from.SELECT.search=r.search:t.search=r.search),r.groupBy){t.groupBy=[];for(const e of r.groupBy)t.groupBy.find(Pn(e))||t.groupBy.push(e)}const n=[...t.groupBy||[],...r.aggregate||[]];n.length&&(t.columns=t.columns&&!e?t.columns.reduce(((t,r)=>{const e=n.find(Pn(r));return e&&t.push(e),t}),[]):n,t.where&&(t.where=t.where.map(qn(t.columns)),t.groupBy&&(t.having=t.where.map(In(t.groupBy)),delete t.where)),t.columns=t.columns.reduce(((t,r)=>(r.ref&&r.ref.length>1&&n.find(Pn(r))?Mn(t,{ref:[...r.ref]}):t.push(r),t)),[])),r.apply&&Xn(t.from.SELECT,r.apply)},Yn=t=>{jn.limit&&jn.limit.offset&&jn.limit.offset.val&&(t+=jn.limit.offset.val),(jn.limit||(jn.limit={})).offset={val:t}},Gn=(t,r)=>{for(const e of r)e.ref&&e.ref[0]===t&&e.ref.shift(),e.func&&Gn(t,e.args);return r};if((e=a())!==n&&$e===t.length)return e;throw e!==n&&$e<t.length&&ze({type:"end"}),Fe(Se,Le<t.length?t.charAt(Le):null,Le<t.length?Re(Le,Le+1):Re(Le,Le))}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?a(t.parts[r][0])+"-"+a(t.parts[r][1]):a(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 a(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,a=new Array(t.length);for(r=0;r<t.length;r++)a[r]=(s=t[r],e[s.type](s));if(a.sort(),a.length>0){for(r=1,n=1;r<a.length;r++)a[r-1]!==a[r]&&(a[n]=a[r],n++);a.length=n}switch(a.length){case 1:return a[0];case 2:return a[0]+" or "+a[1];default:return a.slice(0,-1).join(", ")+", or "+a[a.length-1]}}(t)+" but "+function(t){return t?'"'+s(t)+'"':"end of input"}(r)+" found."},module.exports={SyntaxError:peg$SyntaxError,parse:peg$parse};
|
|
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:je},a=je,u="/",o=Te("/",!1),c=Te("?",!1),i=Te("&",!1),f="$count",l=Te("$count",!1),h="$ref",p=Te("$ref",!1),A="$value",d=Te("$value",!1),g=function(t){return[t]},v="=",b=Te("=",!1),y="$skiptoken=",m=Te("$skiptoken=",!1),C="$apply=",w=Te("$apply=",!1),x="$select=",$=Te("$select=",!1),E="$expand=",L=Te("$expand=",!1),S="$filter=",B=Te("$filter=",!1),T="$orderby=",_=Te("$orderby=",!1),O="$top=",Z=Te("$top=",!1),R="$skip=",z=Te("$skip=",!1),F="$search=",j=Te("$search=",!1),k="$count=",N=Te("$count=",!1),D=Te("*",!1),U=Te(";",!1),P="/$count",q=Te("/$count",!1),I=function(t){return t?[t]:[]},M=function(t,r){t.push({xpr:r})},X=function(t,r){t.push({val:r})},Y=function(t,r,e){t.push(r,...e)},G=function(t,r){t.push(r)},H=function(t,r,e){t.push(r,...e)},J=":",K=Te(":",!1),Q="any",V=Te("any",!1),W="all",tt=Te("all",!1),rt=Te("asc",!1),et="desc",nt=Te("desc",!1),st=/^[a-zA-Z]/,at=_e([["a","z"],["A","Z"]],!1,!1),ut=/^[a-zA-Z0-9\-]/,ot=_e([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),ct=/^[^&]/,it=_e(["&"],!0,!1),ft=Oe("a comparison"),lt=Te("eq",!1),ht=Te("ne",!1),pt=Te("lt",!1),At=Te("gt",!1),dt=Te("le",!1),gt=Te("ge",!1),vt=(Te("add",!1),Te("sub",!1),Te("mul",!1),Te("div",!1),Te("mod",!1),Oe("an operand")),bt=Oe("navigation with $count"),yt=function(t,r){return r},mt=function(t,r){return r?{id:t,where:r}:t},Ct=Oe("a reference"),wt=function(t,r){return r},xt=function(t){return{val:t}},$t=Te("{",!1),Et=/^[^}]/,Lt=_e(["}"],!0,!1),St=Te("}",!1),Bt="[",Tt=Te("[",!1),_t="]",Ot=Te("]",!1),Zt=/^[^\]]/,Rt=_e(["]"],!0,!1),zt=Oe("a function call"),Ft=function(t,r,e){return e},jt=Oe("a boolean function"),kt="contains",Nt=Te("contains",!0),Dt="endswith",Ut=Te("endswith",!0),Pt="startswith",qt=Te("startswith",!0),It=Te("NOT",!0),Mt=Te("AND",!0),Xt=Te("OR",!0),Yt="aggregate",Gt=Te("aggregate",!1),Ht="groupby",Jt=Te("groupby",!1),Kt="filter",Qt=Te("filter",!1),Vt="expand",Wt=Te("expand",!1),tr="search",rr=Te("search",!1),er="concat",nr=Te("concat",!1),sr="compute",ar=Te("compute",!1),ur=Te("topcount",!0),or=Te("bottomcount",!0),cr=Te("topsum",!0),ir=Te("bottomsum",!0),fr=Te("toppercent",!0),lr=Te("bottompercent",!0),hr=function(t,r){return r},pr="with",Ar=Te("with",!1),dr="from",gr=Te("from",!1),vr=Te("as",!1),br="rollup",yr=Te("rollup",!1),mr="$all",Cr=Te("$all",!1),wr="identity",xr=Te("identity",!1),$r="true",Er=Te("true",!1),Lr="false",Sr=Te("false",!1),Br=Oe("Edm.String"),Tr="'",_r=Te("'",!1),Or="''",Zr=Te("''",!1),Rr=/^[^']/,zr=_e(["'"],!0,!1),Fr='"',jr=Te('"',!1),kr='\\"',Nr=Te('\\"',!1),Dr=/^[^"]/,Ur=_e(['"'],!0,!1),Pr=/^[^ \t\n()"&;]/,qr=_e([" ","\t","\n","(",")",'"',"&",";"],!0,!1),Ir=/^[0-9]/,Mr=_e([["0","9"]],!1,!1),Xr="-",Yr=Te("-",!1),Gr=Te("T",!1),Hr=".",Jr=Te(".",!1),Kr=Te("Z",!1),Qr=Te("+",!1),Vr=/^[+\-]/,Wr=_e(["+","-"],!1,!1),te=Te("e",!1),re=/^[_a-zA-Z]/,ee=_e(["_",["a","z"],["A","Z"]],!1,!1),ne=/^[_a-zA-Z0-9"."]/,se=_e(["_",["a","z"],["A","Z"],["0","9"],'"',".",'"'],!1,!1),ae=/^[0-9a-fA-F]/,ue=_e([["0","9"],["a","f"],["A","F"]],!1,!1),oe=/^[^\/?]/,ce=_e(["/","?"],!0,!1),ie=/^[a-zA-Z0-9\-"."_~!$'()*+,;=:@"\/""?"]/,fe=_e([["a","z"],["A","Z"],["0","9"],"-",'"',".",'"',"_","~","!","$","'","(",")","*","+",",",";","=",":","@",'"',"/",'"','"',"?",'"'],!1,!1),le="binary'",he=Te("binary'",!1),pe=/^[a-zA-Z0-9\-_]/,Ae=_e([["a","z"],["A","Z"],["0","9"],"-","_"],!1,!1),de="==",ge=Te("==",!1),ve=Te(",",!1),be=Te("(",!1),ye=Te(")",!1),me=Oe("optional whitespaces"),Ce=/^[ \t\n]/,we=_e([" ","\t","\n"],!1,!1),xe=Oe("mandatory whitespaces"),$e=0,Ee=[{line:1,column:1}],Le=0,Se=[],Be=0;if("startRule"in r){if(!(r.startRule in s))throw new Error("Can't start parsing from rule \""+r.startRule+'".');a=s[r.startRule]}function Te(t,r){return{type:"literal",text:t,ignoreCase:r}}function _e(t,r,e){return{type:"class",parts:t,inverted:r,ignoreCase:e}}function Oe(t){return{type:"other",description:t}}function Ze(r){var e,n=Ee[r];if(n)return n;for(e=r-1;!Ee[e];)e--;for(n={line:(n=Ee[e]).line,column:n.column};e<r;)10===t.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return Ee[r]=n,n}function Re(t,r){var e=Ze(t),n=Ze(r);return{start:{offset:t,line:e.line,column:e.column},end:{offset:r,line:n.line,column:n.column}}}function ze(t){$e<Le||($e>Le&&(Le=$e,Se=[]),Se.push(t))}function Fe(t,r,e){return new peg$SyntaxError(peg$SyntaxError.buildMessage(t,r),t,r,e)}function je(){var r,e,s,a,f,l,h,p,A,d,g,v,b,y;if(r=$e,47===t.charCodeAt($e)?(e=u,$e++):(e=n,0===Be&&ze(o)),e===n&&(e=null),e!==n)if(s=$e,(a=ke())!==n&&(s,a=void(jn=a)),(s=a)!==n){if(a=$e,(f=_n())!==n)if(63===t.charCodeAt($e)?(l="?",$e++):(l=n,0===Be&&ze(c)),l!==n)if((h=_n())!==n)if((p=De())!==n){for(A=[],d=$e,(g=_n())!==n?(38===t.charCodeAt($e)?(v="&",$e++):(v=n,0===Be&&ze(i)),v!==n&&(b=_n())!==n&&(y=De())!==n?d=g=[g,v,b,y]:($e=d,d=n)):($e=d,d=n);d!==n;)A.push(d),d=$e,(g=_n())!==n?(38===t.charCodeAt($e)?(v="&",$e++):(v=n,0===Be&&ze(i)),v!==n&&(b=_n())!==n&&(y=De())!==n?d=g=[g,v,b,y]:($e=d,d=n)):($e=d,d=n);A!==n?a=f=[f,l,h,p,A]:($e=a,a=n)}else $e=a,a=n;else $e=a,a=n;else $e=a,a=n;else $e=a,a=n;a===n&&(a=null),a!==n&&(f=_n())!==n?(r,r=e=function(){if(kn)return jn.columns=[{args:[{val:1}],as:"$count",func:"count"}],delete jn.expand,delete jn.limit,delete jn.orderBy,jn.apply&&(jn.apply={apply:jn.apply},Xn(jn,jn.apply)),{SELECT:jn};let t;if(jn.expand){jn.columns||(jn.columns=["*"],t=!0);for(const t of jn.expand){const r=jn.columns.findIndex(Pn(t));r>-1&&jn.columns.splice(r,1),jn.columns.push(t)}delete jn.expand}return jn.count&&jn.apply&&(jn.__countAggregated=!0),Xn(jn,jn.apply,t),{SELECT:jn}}()):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function ke(){var r,e,s,a,c,i,v,b;return r=$e,t.substr($e,6)===f?(e=f,$e+=6):(e=n,0===Be&&ze(l)),e!==n&&(r,e=void(kn=!0)),(r=e)===n&&(r=$e,e=$e,t.substr($e,4)===h?(s=h,$e+=4):(s=n,0===Be&&ze(p)),s===n&&(t.substr($e,6)===A?(s=A,$e+=6):(s=n,0===Be&&ze(d))),(e=s!==n?t.substring(e,$e):s)!==n&&(r,b=e,e=!Nn.includes(b)&&{from:{ref:[b]}}),(r=e)===n&&(r=$e,e=$e,(s=xn())!==n?(a=$e,(c=Bn())!==n&&(i=Tn())!==n?a=c=[c,i]:($e=a,a=n),a===n&&(a=$e,(c=Bn())!==n&&(i=Ne())!==n&&(v=Tn())!==n?a=c=[c,i,v]:($e=a,a=n)),a===n&&(a=null),a!==n?(c=$e,Be++,i=Ln(),Be--,i===n?c=void 0:($e=c,c=n),c!==n?e=s=[s,a,c]:($e=e,e=n)):($e=e,e=n)):($e=e,e=n),e===n&&(e=$e,(s=Ln())!==n&&(e,s=g(s)),e=s),e===n&&(e=null),e!==n?(s=$e,a=$e,47===t.charCodeAt($e)?(c=u,$e++):(c=n,0===Be&&ze(o)),c!==n&&(a,c=c),(a=c)!==n?((c=ke())===n&&(c=null),c!==n?s=a=[a,c]:($e=s,s=n)):($e=s,s=n),s===n&&(s=null),s!==n?(r,r=e=function(t,r){if(r=r&&r[1],!t&&!r)return{from:{ref:[""]}};if(!t&&r&&r.from)return r.from.ref.unshift(""),r;const[e,n]=t,s=[];if(n?n.length>2?s.push({id:e,where:n[1].map((t=>t.val&&t.val.match&&t.val.match(/^"(.*)"$/)?{val:t.val.match(/^"(.*)"$/)[1]}:t))}):s.push({id:e,where:[]}):zn?s.push(`${"object"==typeof e&&"val"in e?e.val:e}`):"object"==typeof e&&"string"==typeof e.val&&e.val.match(/^[1-9]\d*$|^0$/)?s.push({val:Dn(e.val)}):s.push(e),r&&r.from){const t=r.from.ref;Object.prototype.hasOwnProperty.call(t[0],"val")&&(s[s.length-1]={id:s[s.length-1],where:[t.shift()]}),s.push(...t)}const a={from:{ref:s}};return r&&r.columns&&(a.columns=r.columns),a}(e,s)):($e=r,r=n)):($e=r,r=n))),r}function Ne(){var r,e,s,a,u,o,c;return r=$e,(e=rn())!==n&&(r,e=g(e)),(r=e)===n&&(r=$e,(e=tn())!==n&&_n()!==n?(61===t.charCodeAt($e)?(s="=",$e++):(s=n,0===Be&&ze(b)),s!==n&&_n()!==n&&(a=rn())!==n?(u=$e,(o=Sn())!==n&&(c=Ne())!==n?u=o=[o,c]:($e=u,u=n),u===n&&(u=null),u!==n?(r,r=e=function(t,r,e){const n=[t,"=",r];return e&&n.push("and",...e[1]),n}(e,a,u)):($e=r,r=n)):($e=r,r=n)):($e=r,r=n)),r}function De(){var r,e,s,a;return(r=Ue())===n&&(r=$e,t.substr($e,11)===y?(e=y,$e+=11):(e=n,0===Be&&ze(m)),e!==n&&(s=_n())!==n?(a=function(){var r,e,s;r=$e,(e=wn())===n&&(e=null);e!==n?(s=function(){var r,e,s;r=$e,e=[],ie.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(fe));if(s!==n)for(;s!==n;)e.push(s),ie.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(fe));else e=n;r=e!==n?t.substring(r,$e):e;return r}(),s===n&&(s=null),s!==n?(r,a=e,r=e=void(s||Yn(a))):($e=r,r=n)):($e=r,r=n);var a;return r}(),a!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,7)===C?(e=C,$e+=7):(e=n,0===Be&&ze(w)),e!==n?(s=$e,(a=_n())!==n&&(s,a=void(jn.apply={})),(s=a)!==n&&(a=Qe())!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r===n&&(r=function(){var r,e,s,a,u,o;r=$e,st.test(t.charAt($e))?(e=t.charAt($e),$e++):(e=n,0===Be&&ze(at));if(e!==n){for(s=[],ut.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ot));a!==n;)s.push(a),ut.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ot));if(s!==n)if(61===t.charCodeAt($e)?(a=v,$e++):(a=n,0===Be&&ze(b)),a!==n){for(u=[],ct.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(it));o!==n;)u.push(o),ct.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(it));u!==n?r=e=[e,s,a,u]:($e=r,r=n)}else $e=r,r=n;else $e=r,r=n}else $e=r,r=n;return r}()))),r}function Ue(){var r,e,s,a,u,o,c,i,f,l;if(r=$e,t.substr($e,8)===x?(e=x,$e+=8):(e=n,0===Be&&ze($)),e!==n)if((s=_n())!==n)if((a=Pe())!==n){for(u=[],o=$e,(c=Sn())!==n&&(i=Pe())!==n?o=c=[c,i]:($e=o,o=n);o!==n;)u.push(o),o=$e,(c=Sn())!==n&&(i=Pe())!==n?o=c=[c,i]:($e=o,o=n);u!==n?r=e=[e,s,a,u]:($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;if(r===n){if(r=$e,t.substr($e,8)===E?(e=E,$e+=8):(e=n,0===Be&&ze(L)),e!==n)if((s=_n())!==n)if((a=qe())!==n){for(u=[],o=$e,(c=Sn())!==n&&(i=qe())!==n?o=c=[c,i]:($e=o,o=n);o!==n;)u.push(o),o=$e,(c=Sn())!==n&&(i=qe())!==n?o=c=[c,i]:($e=o,o=n);u!==n?r=e=[e,s,a,u]:($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;if(r===n&&(r=$e,t.substr($e,8)===S?(e=S,$e+=8):(e=n,0===Be&&ze(B)),e!==n&&(s=_n())!==n&&(a=Xe())!==n?(r,l=a,r=e=void(jn.where=l)):($e=r,r=n),r===n)){if(r=$e,t.substr($e,9)===T?(e=T,$e+=9):(e=n,0===Be&&ze(_)),e!==n)if((s=_n())!==n)if((a=Ke())!==n){for(u=[],o=$e,(c=Sn())!==n&&(i=Ke())!==n?o=c=[c,i]:($e=o,o=n);o!==n;)u.push(o),o=$e,(c=Sn())!==n&&(i=Ke())!==n?o=c=[c,i]:($e=o,o=n);u!==n?r=e=[e,s,a,u]:($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;r===n&&(r=$e,t.substr($e,5)===O?(e=O,$e+=5):(e=n,0===Be&&ze(Z)),e!==n&&(s=_n())!==n?(a=function(){var t,r;t=$e,(r=wn())!==n&&(t,e=r,r=void((jn.limit||(jn.limit={})).rows={val:e}));var e;return t=r}(),a!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===R?(e=R,$e+=6):(e=n,0===Be&&ze(z)),e!==n&&(s=_n())!==n?(a=function(){var t,r;t=$e,(r=wn())!==n&&(t,r=void Yn(r));return t=r}(),a!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,8)===F?(e=F,$e+=8):(e=n,0===Be&&ze(j)),e!==n&&(s=_n())!==n&&(a=Ie())!==n?(r,r=e=void((f=a)&&(jn.search=f))):($e=r,r=n),r===n&&(r=$e,t.substr($e,7)===k?(e=k,$e+=7):(e=n,0===Be&&ze(N)),e!==n&&(s=_n())!==n?(a=function(){var t,r;t=$e,(r=mn())!==n&&(t,r=void(r&&(jn.count=!0)));return t=r}(),a!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n)))))}}return r}function Pe(){var r,e,s;return r=$e,42===t.charCodeAt($e)?(e="*",$e++):(e=n,0===Be&&ze(D)),e===n&&(e=tn()),e!==n&&(r,s=e,jn.columns=Array.isArray(jn.columns)?jn.columns:[],jn.columns.find(Pn(s))||jn.columns.push(s),e=s),r=e}function qe(){var r,e,s,a,u,o,c,i,f,l,h;if(r=$e,e=$e,42===t.charCodeAt($e)?(s="*",$e++):(s=n,0===Be&&ze(D)),s===n&&(s=tn()),s!==n&&(e,s=function(t){const r="*"===t?{}:t;return r.expand="*",Array.isArray(jn.expand)||(jn.expand=[]),jn.expand.find(Pn(r))||jn.expand.push(r),r}(s)),(e=s)!==n){if(s=$e,a=$e,(u=Bn())!==n&&(a,Fn.push(jn),jn=jn.expand[jn.expand.length-1],u=void(jn.expand="*")),(a=u)!==n){for(u=$e,o=[],c=$e,(i=_n())!==n?(59===t.charCodeAt($e)?(f=";",$e++):(f=n,0===Be&&ze(U)),f===n&&(f=null),f!==n&&(l=_n())!==n&&(h=Ue())!==n?c=i=[i,f,l,h]:($e=c,c=n)):($e=c,c=n);c!==n;)o.push(c),c=$e,(i=_n())!==n?(59===t.charCodeAt($e)?(f=";",$e++):(f=n,0===Be&&ze(U)),f===n&&(f=null),f!==n&&(l=_n())!==n&&(h=Ue())!==n?c=i=[i,f,l,h]:($e=c,c=n)):($e=c,c=n);o!==n&&(u,o=function(t){if(jn.columns){"*"===jn.expand&&(jn.expand=[]);for(const t of jn.columns)jn.expand.find(Pn(t))||jn.expand.push(t);delete jn.columns}else Array.isArray(jn.expand)&&-1===jn.expand.indexOf("*")&&jn.expand.unshift("*")}()),(u=o)!==n?(o=$e,(c=Tn())!==n&&(o,c=void(jn=Fn.pop())),(o=c)!==n?s=a=[a,u,o]:($e=s,s=n)):($e=s,s=n)}else $e=s,s=n;s===n&&(s=null),s!==n?(a=$e,(u=Sn())!==n&&(o=qe())!==n?a=u=[u,o]:($e=a,a=n),a===n&&(a=null),a!==n?(u=$e,t.substr($e,7)===P?(o=P,$e+=7):(o=n,0===Be&&ze(q)),o!==n&&(u,o=function(){const t=new Error("EXPAND_COUNT_UNSUPPORTED");throw t.statusCode=501,t}()),(u=o)===n&&(u=null),u!==n?r=e=[e,s,a,u]:($e=r,r=n)):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return r}function Ie(){var t,r;return t=$e,(r=Me())!==n&&(t,r=r),(t=r)===n&&(t=_n()),t}function Me(){var r,e,s,a,u,o,c;if(r=$e,e=$e,(s=an())===n&&(s=null),s!==n&&(e,s=I(s)),(e=s)!==n)if(s=$e,(a=Bn())!==n&&(u=Me())!==n&&(o=Tn())!==n?(s,s=a=M(e,u)):($e=s,s=n),s===n&&(s=$e,a=function(){var r,e,s,a,u;r=$e,34===t.charCodeAt($e)?(e=Fr,$e++):(e=n,0===Be&&ze(jr));if(e!==n){for(s=$e,a=[],t.substr($e,2)===kr?(u=kr,$e+=2):(u=n,0===Be&&ze(Nr)),u===n&&(Dr.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(Ur)));u!==n;)a.push(u),t.substr($e,2)===kr?(u=kr,$e+=2):(u=n,0===Be&&ze(Nr)),u===n&&(Dr.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(Ur)));(s=a!==n?t.substring(s,$e):a)!==n?(34===t.charCodeAt($e)?(a=Fr,$e++):(a=n,0===Be&&ze(jr)),a!==n?(r,r=e=s.replace(/\\\\/g,"\\").replace(/\\"/g,'"')):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return r}(),a!==n&&(s,a=X(e,a)),(s=a)===n&&(s=$e,(a=Cn())!==n&&(s,a=X(e,a)),(s=a)===n&&(s=$e,a=function(){var r,e,s;r=$e,e=[],Pr.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(qr));if(s!==n)for(;s!==n;)e.push(s),Pr.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(qr));else e=n;r=e!==n?t.substring(r,$e):e;return r}(),a!==n&&(s,a=X(e,a)),s=a))),s!==n){for(a=[],u=$e,(o=un())===n&&(o=cn())===n&&(o=on()),o!==n&&(c=Me())!==n?(u,u=o=Y(e,o,c)):($e=u,u=n);u!==n;)a.push(u),u=$e,(o=un())===n&&(o=cn())===n&&(o=on()),o!==n&&(c=Me())!==n?(u,u=o=Y(e,o,c)):($e=u,u=n);a!==n?(r,r=e=e):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function Xe(){var t,r;return t=$e,(r=Ye())!==n&&(t,r=r),t=r}function Ye(){var r,e,s,a,u,o,c,i;if(r=$e,e=$e,(s=an())===n&&(s=null),s!==n&&(e,s=I(s)),(e=s)!==n)if(s=$e,(a=Bn())!==n&&(u=Ye())!==n&&(o=Tn())!==n?(s,s=a=M(e,u)):($e=s,s=n),s===n&&(s=$e,(a=Ve())!==n&&(s,i=a,a=void e.push(...i)),(s=a)===n&&(s=$e,(a=Ge())!==n&&(s,a=function(t,r){"not"===t[t.length-1]&&"not"===r[0]?t.push("(",...r,")"):t.push(...r)}(e,a)),(s=a)===n&&(s=$e,a=function(){var r,e,s,a;Be++,r=$e,t.substr($e,8).toLowerCase()===kt?(e=t.substr($e,8),$e+=8):(e=n,0===Be&&ze(Nt));e===n&&(t.substr($e,8).toLowerCase()===Dt?(e=t.substr($e,8),$e+=8):(e=n,0===Be&&ze(Ut)),e===n&&(t.substr($e,10).toLowerCase()===Pt?(e=t.substr($e,10),$e+=10):(e=n,0===Be&&ze(qt))));e!==n&&Bn()!==n&&(s=We())!==n&&Sn()!==n&&(a=We())!==n&&Tn()!==n?(r,u=s,o=a,r=e={func:e.toLowerCase(),args:[u,o]}):($e=r,r=n);var u,o;Be--,r===n&&(e=n,0===Be&&ze(jt));return r}(),a!==n&&(s,a=function(t,r){t.push(r)}(e,a)),(s=a)===n&&(s=$e,(a=mn())!==n&&(s,a=X(e,a)),s=a)))),s!==n){for(a=[],u=$e,(o=un())===n&&(o=cn()),o!==n&&(c=Ye())!==n?(u,u=o=Y(e,o,c)):($e=u,u=n);u!==n;)a.push(u),u=$e,(o=un())===n&&(o=cn()),o!==n&&(c=Ye())!==n?(u,u=o=Y(e,o,c)):($e=u,u=n);a!==n?(r,r=e=e):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function Ge(){var r,e,s,a,c,i,f;if(r=$e,e=$e,(s=xn())!==n&&(e,s=[s]),(e=s)!==n)if(47===t.charCodeAt($e)?(s=u,$e++):(s=n,0===Be&&ze(o)),s!==n){for(a=[],c=$e,(i=xn())!==n?(47===t.charCodeAt($e)?(f=u,$e++):(f=n,0===Be&&ze(o)),f!==n?(c,c=i=G(e,i)):($e=c,c=n)):($e=c,c=n);c!==n;)a.push(c),c=$e,(i=xn())!==n?(47===t.charCodeAt($e)?(f=u,$e++):(f=n,0===Be&&ze(o)),f!==n?(c,c=i=G(e,i)):($e=c,c=n)):($e=c,c=n);a!==n?(c=$e,i=function(){var r,e,s;r=$e,t.substr($e,3)===Q?(e=Q,$e+=3):(e=n,0===Be&&ze(V));e!==n&&Bn()!==n?((s=Je())===n&&(s=null),s!==n&&Tn()!==n?(r,r=e=s):($e=r,r=n)):($e=r,r=n);return r}(),i!==n&&(c,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 a=r[t];a.ref&&0===a.ref.length&&"="===r[t+1]?n[s++]={func:"contains",args:[{ref:e},r[t+=2]]}:n[s++]=a}return n.length<r.length?(e=t.pop(),["exists",{ref:[...t,{id:e,where:n}]}]):["exists",{ref:[...t,{id:e,where:r}]}]}(e,i)),(c=i)===n&&(c=$e,i=function(){var r,e,s;r=$e,t.substr($e,3)===W?(e=W,$e+=3):(e=n,0===Be&&ze(tt));e!==n&&Bn()!==n&&(s=Je())!==n&&Tn()!==n?(r,r=e=s):($e=r,r=n);return r}(),i!==n&&(c,i=function(t,r){let e=t.pop();return["not","exists",{ref:[...t,{id:e,where:["not",{xpr:[...r]}]}]}]}(e,i)),c=i),c!==n?(r,r=e=c):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function He(){var t,r,e,s,a,u,o,c,i;if(t=$e,r=$e,(e=an())===n&&(e=null),e!==n&&(r,e=(c=e)?[c]:[]),(r=e)!==n)if(e=$e,(s=Bn())!==n&&(a=He())!==n&&(u=Tn())!==n?(e,i=a,e=s=void r.push("(",...i,")")):($e=e,e=n),e===n&&(e=$e,(s=Ve())!==n&&(e,s=function(t,r){t.push(...r)}(r,s)),(e=s)===n&&(e=$e,(s=sn())!==n&&(e,s=function(t,r){t.push(r)}(r,s)),(e=s)===n&&(e=$e,(s=Ge())!==n&&(e,s=function(t,r){t.push(...r)}(r,s)),e=s))),e!==n){for(s=[],a=$e,(u=un())===n&&(u=cn()),u!==n&&(o=He())!==n?(a,a=u=H(r,u,o)):($e=a,a=n);a!==n;)s.push(a),a=$e,(u=un())===n&&(u=cn()),u!==n&&(o=He())!==n?(a,a=u=H(r,u,o)):($e=a,a=n);s!==n?(t,t=r=r):($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;return t}function Je(){var r,e,s,a;return r=$e,(e=xn())!==n?(58===t.charCodeAt($e)?(s=J,$e++):(s=n,0===Be&&ze(K)),s!==n&&(a=He())!==n?(r,r=e=Gn(e,a)):($e=r,r=n)):($e=r,r=n),r}function Ke(){var r,e,s,a,u;return r=$e,e=$e,(s=Ge())!==n&&(e,s=function(){const t=new Error("ORDERBY_LAMBDA_UNSUPPORTED");throw t.statusCode=501,t}()),(e=s)===n&&(e=sn())===n&&(e=tn()),e!==n?(s=$e,On()!==n?(a=$e,"asc"===t.substr($e,3)?(u="asc",$e+=3):(u=n,0===Be&&ze(rt)),u===n&&(t.substr($e,4)===et?(u=et,$e+=4):(u=n,0===Be&&ze(nt))),(a=u!==n?t.substring(a,$e):u)!==n?(s,s=a):($e=s,s=n)):($e=s,s=n),s===n&&(s=null),s!==n?(r,r=e=function(t,r){const e=Zn(t,r&&{sort:r});jn.orderBy=jn.orderBy?[...jn.orderBy,e]:[e]}(e,s)):($e=r,r=n)):($e=r,r=n),r}function Qe(){var r,e,s,a,c,i;if(r=$e,(e=fn())!==n){for(s=[],a=$e,47===t.charCodeAt($e)?(c=u,$e++):(c=n,0===Be&&ze(o)),c!==n&&(i=fn())!==n?a=c=[c,i]:($e=a,a=n);a!==n;)s.push(a),a=$e,47===t.charCodeAt($e)?(c=u,$e++):(c=n,0===Be&&ze(o)),c!==n&&(i=fn())!==n?a=c=[c,i]:($e=a,a=n);s!==n?r=e=[e,s]:($e=r,r=n)}else $e=r,r=n;return r}function Ve(){var r,e,s,a,u,o;return Be++,r=$e,(e=We())!==n&&On()!==n?(s=$e,"eq"===t.substr($e,2)?(a="eq",$e+=2):(a=n,0===Be&&ze(lt)),a===n&&("ne"===t.substr($e,2)?(a="ne",$e+=2):(a=n,0===Be&&ze(ht)),a===n&&("lt"===t.substr($e,2)?(a="lt",$e+=2):(a=n,0===Be&&ze(pt)),a===n&&("gt"===t.substr($e,2)?(a="gt",$e+=2):(a=n,0===Be&&ze(At)),a===n&&("le"===t.substr($e,2)?(a="le",$e+=2):(a=n,0===Be&&ze(dt)),a===n&&("ge"===t.substr($e,2)?(a="ge",$e+=2):(a=n,0===Be&&ze(gt))))))),(s=a!==n?t.substring(s,$e):a)!==n&&(a=On())!==n&&(u=We())!==n?(r,r=e=[e,{eq:"=",ne:"!=",lt:"<",gt:">",le:"<=",ge:">="}[o=s]||o,u]):($e=r,r=n)):($e=r,r=n),Be--,r===n&&(e=n,0===Be&&ze(ft)),r}function We(){var r;return Be++,r=function(){var r,e,s,a,c,i,h;Be++,r=$e,e=[],s=$e,(a=xn())!==n?(c=$e,(i=Bn())!==n&&(h=Ne())!==n&&Tn()!==n?(c,c=i=yt(0,h)):($e=c,c=n),c===n&&(c=null),c!==n?(47===t.charCodeAt($e)?(i=u,$e++):(i=n,0===Be&&ze(o)),i!==n?(s,s=a=mt(a,c)):($e=s,s=n)):($e=s,s=n)):($e=s,s=n);if(s!==n)for(;s!==n;)e.push(s),s=$e,(a=xn())!==n?(c=$e,(i=Bn())!==n&&(h=Ne())!==n&&Tn()!==n?(c,c=i=yt(0,h)):($e=c,c=n),c===n&&(c=null),c!==n?(47===t.charCodeAt($e)?(i=u,$e++):(i=n,0===Be&&ze(o)),i!==n?(s,s=a=mt(a,c)):($e=s,s=n)):($e=s,s=n)):($e=s,s=n);else e=n;e!==n?(t.substr($e,6)===f?(s=f,$e+=6):(s=n,0===Be&&ze(l)),s!==n?(r,r=e={func:"count",as:"$count",args:[{ref:e}]}):($e=r,r=n)):($e=r,r=n);Be--,r===n&&(e=n,0===Be&&ze(bt));return r}(),r===n&&(r=sn())===n&&(r=rn())===n&&(r=tn())===n&&(r=en())===n&&(r=nn())===n&&(r=function(){var r,e,s,a,u;r=$e,91===t.charCodeAt($e)?(e=Bt,$e++):(e=n,0===Be&&ze(Tt));if(e!==n){for(s=$e,a=[],Zt.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(Rt));u!==n;)a.push(u),Zt.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(Rt));(s=a!==n?t.substring(s,$e):a)!==n?(93===t.charCodeAt($e)?(a=_t,$e++):(a=n,0===Be&&ze(Ot)),a!==n?(r,r=e={list:s.replace(/"/g,"").split(",").map((t=>({val:t})))}):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return r}()),Be--,r===n&&(n,0===Be&&ze(vt)),r}function tn(){var r,e,s,a,c,i,f,l;if(Be++,r=$e,(e=xn())!==n){for(s=[],a=$e,47===t.charCodeAt($e)?(c=u,$e++):(c=n,0===Be&&ze(o)),c!==n&&(i=xn())!==n?(a,a=c=wt(0,i)):($e=a,a=n);a!==n;)s.push(a),a=$e,47===t.charCodeAt($e)?(c=u,$e++):(c=n,0===Be&&ze(o)),c!==n&&(i=xn())!==n?(a,a=c=wt(0,i)):($e=a,a=n);s!==n?(r,l=s,r=e="null"===(f=e)?{val:null}:{ref:[f,...l]}):($e=r,r=n)}else $e=r,r=n;return Be--,r===n&&(e=n,0===Be&&ze(Ct)),r}function rn(){var r,e,s;return r=$e,(e=mn())===n&&(e=function(){var r,e,s,a,u,o,c,i,f,l,h,p,A,d,g,v,b,y,m,C,w,x,$,E;r=$e,e=$e,s=[],Ir.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(Mr));if(a!==n)for(;a!==n;)s.push(a),Ir.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(Mr));else s=n;if(s!==n)if(45===t.charCodeAt($e)?(a=Xr,$e++):(a=n,0===Be&&ze(Yr)),a!==n)if(Ir.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(Mr)),u!==n)if(Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr)),o!==n)if(45===t.charCodeAt($e)?(c=Xr,$e++):(c=n,0===Be&&ze(Yr)),c!==n)if(Ir.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(Mr)),i!==n)if(Ir.test(t.charAt($e))?(f=t.charAt($e),$e++):(f=n,0===Be&&ze(Mr)),f!==n){if(l=$e,84===t.charCodeAt($e)?(h="T",$e++):(h=n,0===Be&&ze(Gr)),h!==n)if(Ir.test(t.charAt($e))?(p=t.charAt($e),$e++):(p=n,0===Be&&ze(Mr)),p!==n)if(Ir.test(t.charAt($e))?(A=t.charAt($e),$e++):(A=n,0===Be&&ze(Mr)),A!==n)if(58===t.charCodeAt($e)?(d=J,$e++):(d=n,0===Be&&ze(K)),d!==n)if(Ir.test(t.charAt($e))?(g=t.charAt($e),$e++):(g=n,0===Be&&ze(Mr)),g!==n)if(Ir.test(t.charAt($e))?(v=t.charAt($e),$e++):(v=n,0===Be&&ze(Mr)),v!==n){if(b=$e,58===t.charCodeAt($e)?(y=J,$e++):(y=n,0===Be&&ze(K)),y!==n)if(Ir.test(t.charAt($e))?(m=t.charAt($e),$e++):(m=n,0===Be&&ze(Mr)),m!==n)if(Ir.test(t.charAt($e))?(C=t.charAt($e),$e++):(C=n,0===Be&&ze(Mr)),C!==n){if(w=$e,46===t.charCodeAt($e)?(x=".",$e++):(x=n,0===Be&&ze(Jr)),x!==n){if($=[],Ir.test(t.charAt($e))?(E=t.charAt($e),$e++):(E=n,0===Be&&ze(Mr)),E!==n)for(;E!==n;)$.push(E),Ir.test(t.charAt($e))?(E=t.charAt($e),$e++):(E=n,0===Be&&ze(Mr));else $=n;$!==n?w=x=[x,$]:($e=w,w=n)}else $e=w,w=n;w===n&&(w=null),w!==n?b=y=[y,m,C,w]:($e=b,b=n)}else $e=b,b=n;else $e=b,b=n;else $e=b,b=n;b===n&&(b=null),b!==n?(90===t.charCodeAt($e)?(y="Z",$e++):(y=n,0===Be&&ze(Kr)),y===n&&(y=$e,43===t.charCodeAt($e)?(m="+",$e++):(m=n,0===Be&&ze(Qr)),m===n&&(45===t.charCodeAt($e)?(m=Xr,$e++):(m=n,0===Be&&ze(Yr))),m!==n?(Ir.test(t.charAt($e))?(C=t.charAt($e),$e++):(C=n,0===Be&&ze(Mr)),C!==n?(Ir.test(t.charAt($e))?(w=t.charAt($e),$e++):(w=n,0===Be&&ze(Mr)),w!==n?(58===t.charCodeAt($e)?(x=J,$e++):(x=n,0===Be&&ze(K)),x!==n?(Ir.test(t.charAt($e))?($=t.charAt($e),$e++):($=n,0===Be&&ze(Mr)),$!==n?(Ir.test(t.charAt($e))?(E=t.charAt($e),$e++):(E=n,0===Be&&ze(Mr)),E!==n?y=m=[m,C,w,x,$,E]:($e=y,y=n)):($e=y,y=n)):($e=y,y=n)):($e=y,y=n)):($e=y,y=n)):($e=y,y=n)),y===n&&(y=null),y!==n?l=h=[h,p,A,d,g,v,b,y]:($e=l,l=n)):($e=l,l=n)}else $e=l,l=n;else $e=l,l=n;else $e=l,l=n;else $e=l,l=n;else $e=l,l=n;else $e=l,l=n;l===n&&(l=null),l!==n?e=s=[s,a,u,o,c,i,f,l]:($e=e,e=n)}else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;r=e!==n?t.substring(r,$e):e;return r}()),e!==n&&(r,e=xt(e)),(r=e)===n&&(r=$e,(e=$n())!==n&&(r,e=xt(e)),(r=e)===n&&(r=$e,e=function(){var r,e,s,a,u,o,c,i,f,l;r=$e,e=$e,s=$e,Vr.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(Wr));a===n&&(a=null);if(a!==n){if(u=[],Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr)),o!==n)for(;o!==n;)u.push(o),Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr));else u=n;if(u!==n){if(o=$e,46===t.charCodeAt($e)?(c=Hr,$e++):(c=n,0===Be&&ze(Jr)),c!==n){if(i=[],Ir.test(t.charAt($e))?(f=t.charAt($e),$e++):(f=n,0===Be&&ze(Mr)),f!==n)for(;f!==n;)i.push(f),Ir.test(t.charAt($e))?(f=t.charAt($e),$e++):(f=n,0===Be&&ze(Mr));else i=n;i!==n?o=c=[c,i]:($e=o,o=n)}else $e=o,o=n;if(o===n&&(o=null),o!==n){if(c=$e,101===t.charCodeAt($e)?(i="e",$e++):(i=n,0===Be&&ze(te)),i!==n){if(f=[],Ir.test(t.charAt($e))?(l=t.charAt($e),$e++):(l=n,0===Be&&ze(Mr)),l!==n)for(;l!==n;)f.push(l),Ir.test(t.charAt($e))?(l=t.charAt($e),$e++):(l=n,0===Be&&ze(Mr));else f=n;f!==n?c=i=[i,f]:($e=c,c=n)}else $e=c,c=n;c===n&&(c=null),c!==n?s=a=[a,u,o,c]:($e=s,s=n)}else $e=s,s=n}else $e=s,s=n}else $e=s,s=n;e=s!==n?t.substring(e,$e):s;e!==n&&(r,e=Dn(e));return r=e}(),e!==n&&(r,e="number"==typeof(s=e)?{val:s}:{val:s,literal:"number"}),(r=e)===n&&(r=$e,(e=Cn())!==n&&(r,e=xt(e)),(r=e)===n&&(r=$e,e=function(){var r,e,s,a,u,o;r=$e,t.substr($e,7)===le?(e=le,$e+=7):(e=n,0===Be&&ze(he));if(e!==n){if(s=$e,a=$e,u=[],pe.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Ae)),o!==n)for(;o!==n;)u.push(o),pe.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Ae));else u=n;u!==n?(t.substr($e,2)===de?(o=de,$e+=2):(o=n,0===Be&&ze(ge)),o===n&&(61===t.charCodeAt($e)?(o=v,$e++):(o=n,0===Be&&ze(b))),o===n&&(o=null),o!==n?a=u=[u,o]:($e=a,a=n)):($e=a,a=n),(s=a!==n?t.substring(s,$e):a)!==n?(39===t.charCodeAt($e)?(a=Tr,$e++):(a=n,0===Be&&ze(_r)),a!==n?(r,r=e=Un(s)):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return r}(),e!==n&&(r,e=xt(e)),r=e)))),r}function en(){var r,e,s,a,u,o;if(r=$e,e=$e,s=$e,123===t.charCodeAt($e)?(a="{",$e++):(a=n,0===Be&&ze($t)),a!==n){for(u=[],(o=en())===n&&(Et.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Lt)));o!==n;)u.push(o),(o=en())===n&&(Et.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Lt)));u!==n?(125===t.charCodeAt($e)?(o="}",$e++):(o=n,0===Be&&ze(St)),o!==n?s=a=[a,u,o]:($e=s,s=n)):($e=s,s=n)}else $e=s,s=n;return(e=s!==n?t.substring(e,$e):s)!==n&&(r,e=xt(e)),r=e}function nn(){var r,e,s,a,u,o,c,i;if(r=$e,e=$e,s=$e,91===t.charCodeAt($e)?(a=Bt,$e++):(a=n,0===Be&&ze(Tt)),a!==n&&(u=_n())!==n?(93===t.charCodeAt($e)?(o=_t,$e++):(o=n,0===Be&&ze(Ot)),o!==n?s=a=[a,u,o]:($e=s,s=n)):($e=s,s=n),s===n)if(s=$e,91===t.charCodeAt($e)?(a=Bt,$e++):(a=n,0===Be&&ze(Tt)),a!==n)if((u=_n())!==n)if(123===t.charCodeAt($e)?(o="{",$e++):(o=n,0===Be&&ze($t)),o!==n){for(c=[],(i=nn())===n&&(Zt.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(Rt)));i!==n;)c.push(i),(i=nn())===n&&(Zt.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(Rt)));c!==n?(93===t.charCodeAt($e)?(i=_t,$e++):(i=n,0===Be&&ze(Ot)),i!==n?s=a=[a,u,o,c,i]:($e=s,s=n)):($e=s,s=n)}else $e=s,s=n;else $e=s,s=n;else $e=s,s=n;return(e=s!==n?t.substring(e,$e):s)!==n&&(r,e=xt(e)),r=e}function sn(){var r,e,s,a,u,o,c;if(Be++,r=$e,e=$e,s=[],st.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(at)),a!==n)for(;a!==n;)s.push(a),st.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(at));else s=n;if((e=s!==n?t.substring(e,$e):s)!==n)if((s=Bn())!==n)if((a=We())!==n){for(u=[],o=$e,Sn()!==n&&(c=We())!==n?(o,o=Ft(0,0,c)):($e=o,o=n);o!==n;)u.push(o),o=$e,Sn()!==n&&(c=We())!==n?(o,o=Ft(0,0,c)):($e=o,o=n);u!==n&&(o=Tn())!==n?(r,r=e=function(t,r,e){if(Rn&&!(t.toLowerCase()in Rn.functions))throw Object.assign(new Error(`"${t}" is an unknown function in OData URL spec (strict mode)`),{statusCode:400});return{func:t.toLowerCase(),args:[r,...e]}}(e,a,u)):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;return Be--,r===n&&(e=n,0===Be&&ze(zt)),r}function an(){var r,e;return r=$e,_n()!==n?("not"===t.substr($e,3).toLowerCase()?(e=t.substr($e,3),$e+=3):(e=n,0===Be&&ze(It)),e!==n&&On()!==n?(r,r="not"):($e=r,r=n)):($e=r,r=n),r}function un(){var r,e;return r=$e,On()!==n?("and"===t.substr($e,3).toLowerCase()?(e=t.substr($e,3),$e+=3):(e=n,0===Be&&ze(Mt)),e!==n&&On()!==n?(r,r="and"):($e=r,r=n)):($e=r,r=n),r}function on(){var t,r;return t=$e,(r=On())!==n&&(t,r="and"),t=r}function cn(){var r,e;return r=$e,On()!==n?("or"===t.substr($e,2).toLowerCase()?(e=t.substr($e,2),$e+=2):(e=n,0===Be&&ze(Xt)),e!==n&&On()!==n?(r,r="or"):($e=r,r=n)):($e=r,r=n),r}function fn(){var r,e,s;return r=$e,t.substr($e,9)===Yt?(e=Yt,$e+=9):(e=n,0===Be&&ze(Gt)),e!==n?(s=function(){var t,r,e,s,a;if(t=$e,Bn()!==n)if(_n()!==n)if((r=ln())!==n){for(e=[],s=$e,_n()!==n&&Sn()!==n&&_n()!==n&&(a=ln())!==n?(s,s=hr(0,a)):($e=s,s=n);s!==n;)e.push(s),s=$e,_n()!==n&&Sn()!==n&&_n()!==n&&(a=ln())!==n?(s,s=hr(0,a)):($e=s,s=n);e!==n&&(s=_n())!==n&&Tn()!==n?(t,t=function(t,r){let e=jn.apply;e.aggregate&&(jn.apply={apply:e},e.groupBy&&(jn.apply.groupBy=e.groupBy),e=jn.apply),e.aggregate=[t,...r]}(r,e)):($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,7)===Ht?(e=Ht,$e+=7):(e=n,0===Be&&ze(Jt)),e!==n?(s=function(){var t,r,e,s,a,u,o,c,i;if(t=$e,(r=Bn())!==n)if((e=Bn())!==n)if((s=gn())!==n){for(a=[],u=$e,(o=Sn())!==n&&(c=gn())!==n?(u,u=o=hr(0,c)):($e=u,u=n);u!==n;)a.push(u),u=$e,(o=Sn())!==n&&(c=gn())!==n?(u,u=o=hr(0,c)):($e=u,u=n);a!==n?(u=$e,(o=Tn())!==n&&(u,o=function(t,r){let e=jn.apply;(e.groupBy||e.where||e.search)&&(jn.apply={apply:e},e=jn.apply),e.groupBy=[t,...r]}(s,a)),(u=o)!==n?(o=$e,(c=Sn())!==n&&(i=Qe())!==n?o=c=[c,i]:($e=o,o=n),o===n&&(o=null),o!==n&&(c=Tn())!==n?t=r=[r,e,s,a,u,o,c]:($e=t,t=n)):($e=t,t=n)):($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===Kt?(e=Kt,$e+=6):(e=n,0===Be&&ze(Qt)),e!==n&&(s=vn())!==n?r=e=[e,s]:($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===Vt?(e=Vt,$e+=6):(e=n,0===Be&&ze(Wt)),e!==n&&(s=bn())!==n?r=e=[e,s]:($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===tr?(e=tr,$e+=6):(e=n,0===Be&&ze(rr)),e!==n?(s=function(){var t,r,e,s,a,u;t=$e,(r=Bn())!==n&&(e=_n())!==n?(s=$e,(a=Ie())!==n&&(s,a=function(t){if(!t)return;let r=jn.apply;r.search&&(jn.apply={apply:r},r=jn.apply),r.search=t}(a)),(s=a)!==n&&(a=_n())!==n&&(u=Tn())!==n?t=r=[r,e,s,a,u]:($e=t,t=n)):($e=t,t=n);return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,6)===er?(e=er,$e+=6):(e=n,0===Be&&ze(nr)),e!==n?(s=function(){var t,r,e,s,a,u,o,c,i,f;if(t=$e,(r=Bn())!==n)if((e=_n())!==n)if((s=Qe())!==n){if(a=[],u=$e,(o=_n())!==n&&(c=Sn())!==n&&(i=_n())!==n&&(f=Qe())!==n?u=o=[o,c,i,f]:($e=u,u=n),u!==n)for(;u!==n;)a.push(u),u=$e,(o=_n())!==n&&(c=Sn())!==n&&(i=_n())!==n&&(f=Qe())!==n?u=o=[o,c,i,f]:($e=u,u=n);else a=n;a!==n&&(u=_n())!==n&&(o=Tn())!==n?t=r=[r,e,s,a,u,o]:($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,t.substr($e,7)===sr?(e=sr,$e+=7):(e=n,0===Be&&ze(ar)),e!==n?(s=function(){var t,r,e,s,a,u,o,c,i,f;if(t=$e,(r=Bn())!==n)if((e=_n())!==n)if((s=yn())!==n){for(a=[],u=$e,(o=_n())!==n&&(c=Sn())!==n&&(i=_n())!==n&&(f=yn())!==n?u=o=[o,c,i,f]:($e=u,u=n);u!==n;)a.push(u),u=$e,(o=_n())!==n&&(c=Sn())!==n&&(i=_n())!==n&&(f=yn())!==n?u=o=[o,c,i,f]:($e=u,u=n);a!==n&&(u=_n())!==n&&(o=Tn())!==n?t=r=[r,e,s,a,u,o]:($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}(),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r===n&&(r=$e,"topcount"===t.substr($e,8).toLowerCase()?(e=t.substr($e,8),$e+=8):(e=n,0===Be&&ze(ur)),e===n&&("bottomcount"===t.substr($e,11).toLowerCase()?(e=t.substr($e,11),$e+=11):(e=n,0===Be&&ze(or)),e===n&&("topsum"===t.substr($e,6).toLowerCase()?(e=t.substr($e,6),$e+=6):(e=n,0===Be&&ze(cr)),e===n&&("bottomsum"===t.substr($e,9).toLowerCase()?(e=t.substr($e,9),$e+=9):(e=n,0===Be&&ze(ir)),e===n&&("toppercent"===t.substr($e,10).toLowerCase()?(e=t.substr($e,10),$e+=10):(e=n,0===Be&&ze(fr)),e===n&&("bottompercent"===t.substr($e,13).toLowerCase()?(e=t.substr($e,13),$e+=13):(e=n,0===Be&&ze(lr))))))),e!==n?(s=function(){var t,r,e;t=$e,Bn()!==n&&_n()!==n&&(r=We())!==n&&_n()!==n&&Sn()!==n&&_n()!==n&&(e=We())!==n&&_n()!==n&&Tn()!==n?(t,t=[r,e]):($e=t,t=n);return t}(),s!==n?(r,r=e=function(t,r){if(!{topcount:!0,bottomcount:!0,topsum:!1,bottomsum:!1,toppercent:!1,bottompercent:!1}[t=t.toLowerCase()])throw Object.assign(new Error(`Transformation "${t}" in $apply is not supported yet.`),{statusCode:501});(jn.apply.aggregate||(jn.apply.aggregate=[])).push({func:t,args:r})}(e,s)):($e=r,r=n)):($e=r,r=n),r===n&&(r=function(){var r;t.substr($e,8)===wr?(r=wr,$e+=8):(r=n,0===Be&&ze(xr));return r}())))))))),r}function ln(){var r,e,s,a;return r=$e,e=$e,t.substr($e,6)===f?(s=f,$e+=6):(s=n,0===Be&&ze(l)),s!==n&&(a=dn())!==n?(e,e=s={func:"count",args:[{val:1}],as:a}):($e=e,e=n),e===n&&(e=hn()),e!==n&&(r,e=e),r=e}function hn(){var t,r,e,s,a;return t=$e,(r=tn())!==n&&(e=pn())!==n?((s=An())===n&&(s=null),s!==n&&(a=dn())!==n?(t,t=r={func:e,args:[r],as:a}):($e=t,t=n)):($e=t,t=n),t===n&&(t=$e,(r=xn())!==n&&(e=Bn())!==n&&(s=hn())!==n&&(a=Tn())!==n?t=r=[r,e,s,a]:($e=t,t=n)),t}function pn(){var r,e,s,a,u;if(r=$e,On()!==n)if(t.substr($e,4)===pr?(e=pr,$e+=4):(e=n,0===Be&&ze(Ar)),e!==n)if(On()!==n){if(s=$e,a=[],st.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(at)),u!==n)for(;u!==n;)a.push(u),st.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(at));else a=n;(s=a!==n?t.substring(s,$e):a)!==n?(r,r=s.toLowerCase()):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;else $e=r,r=n;return r}function An(){var r,e,s,a,u,o,c;return r=$e,(e=On())!==n?(t.substr($e,4)===dr?(s=dr,$e+=4):(s=n,0===Be&&ze(gr)),s!==n&&(a=On())!==n&&(u=tn())!==n&&(o=pn())!==n?((c=An())===n&&(c=null),c!==n?r=e=[e,s,a,u,o,c]:($e=r,r=n)):($e=r,r=n)):($e=r,r=n),r}function dn(){var r,e,s;return r=$e,On()!==n?("as"===t.substr($e,2)?(e="as",$e+=2):(e=n,0===Be&&ze(vr)),e!==n&&On()!==n&&(s=xn())!==n?(r,r=s):($e=r,r=n)):($e=r,r=n),r}function gn(){var r,e;return r=$e,e=function(){var r,e,s,a,u,o,c,i,f,l,h;r=$e,e=$e,t.substr($e,6)===br?(s=br,$e+=6):(s=n,0===Be&&ze(yr));if(s!==n)if((a=Bn())!==n)if((u=_n())!==n)if(t.substr($e,4)===mr?(o=mr,$e+=4):(o=n,0===Be&&ze(Cr)),o===n&&(o=tn()),o!==n){if(c=[],i=$e,(f=_n())!==n&&(l=Sn())!==n&&(h=tn())!==n?i=f=[f,l,h]:($e=i,i=n),i!==n)for(;i!==n;)c.push(i),i=$e,(f=_n())!==n&&(l=Sn())!==n&&(h=tn())!==n?i=f=[f,l,h]:($e=i,i=n);else c=n;c!==n&&(i=_n())!==n&&(f=Tn())!==n?e=s=[s,a,u,o,c,i,f]:($e=e,e=n)}else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;else $e=e,e=n;e!==n&&(r,e=function(t){const r=new Error("Rollup in groupby is not supported yet.");throw r.statusCode=501,r}());return r=e}(),e===n&&(e=tn()),e!==n&&(r,e=e),r=e}function vn(){var t,r,e,s,a,u;return t=$e,(r=Bn())!==n&&(e=_n())!==n?(s=$e,(a=Xe())!==n&&(s,a=function(t){let r=jn.apply;r.where&&(jn.apply={apply:r},r=jn.apply),r.where=t}(a)),(s=a)!==n&&(a=_n())!==n&&(u=Tn())!==n?t=r=[r,e,s,a,u]:($e=t,t=n)):($e=t,t=n),t}function bn(){var t,r,e,s,a,u,o,c,i,f,l,h,p,A;if(t=$e,(r=Bn())!==n)if((e=_n())!==n)if((s=tn())!==n)if((a=_n())!==n)if((u=Sn())!==n)if((o=_n())!==n){if(c=$e,(i=bn())!==n){for(f=[],l=$e,(h=_n())!==n&&(p=Sn())!==n&&(A=bn())!==n?l=h=[h,p,A]:($e=l,l=n);l!==n;)f.push(l),l=$e,(h=_n())!==n&&(p=Sn())!==n&&(A=bn())!==n?l=h=[h,p,A]:($e=l,l=n);f!==n?c=i=[i,f]:($e=c,c=n)}else $e=c,c=n;if(c===n)if(c=$e,(i=vn())!==n){for(f=[],l=$e,(h=_n())!==n&&(p=Sn())!==n&&(A=bn())!==n?l=h=[h,p,A]:($e=l,l=n);l!==n;)f.push(l),l=$e,(h=_n())!==n&&(p=Sn())!==n&&(A=bn())!==n?l=h=[h,p,A]:($e=l,l=n);f!==n?c=i=[i,f]:($e=c,c=n)}else $e=c,c=n;c!==n&&(i=_n())!==n&&(f=Tn())!==n?t=r=[r,e,s,a,u,o,c,i,f]:($e=t,t=n)}else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;else $e=t,t=n;return t}function yn(){var t,r,e;return t=$e,(r=Ye())!==n&&(e=dn())!==n?t=r=[r,e]:($e=t,t=n),t}function mn(){var r,e;return r=$e,t.substr($e,4)===$r?(e=$r,$e+=4):(e=n,0===Be&&ze(Er)),e===n&&(t.substr($e,5)===Lr?(e=Lr,$e+=5):(e=n,0===Be&&ze(Sr))),e!==n&&(r,e="true"===e),r=e}function Cn(){var r,e,s,a,u;if(Be++,r=$e,39===t.charCodeAt($e)?(e=Tr,$e++):(e=n,0===Be&&ze(_r)),e!==n){for(s=$e,a=[],t.substr($e,2)===Or?(u=Or,$e+=2):(u=n,0===Be&&ze(Zr)),u===n&&(Rr.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(zr)));u!==n;)a.push(u),t.substr($e,2)===Or?(u=Or,$e+=2):(u=n,0===Be&&ze(Zr)),u===n&&(Rr.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(zr)));(s=a!==n?t.substring(s,$e):a)!==n?(39===t.charCodeAt($e)?(a=Tr,$e++):(a=n,0===Be&&ze(_r)),a!==n?(r,r=e=s.replace(/''/g,"'")):($e=r,r=n)):($e=r,r=n)}else $e=r,r=n;return Be--,r===n&&(e=n,0===Be&&ze(Br)),r}function wn(){var r,e,s,a,u,o;if(r=$e,e=$e,s=$e,Vr.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(Wr)),a===n&&(a=null),a!==n){if(u=[],Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr)),o!==n)for(;o!==n;)u.push(o),Ir.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(Mr));else u=n;u!==n?s=a=[a,u]:($e=s,s=n)}else $e=s,s=n;return(e=s!==n?t.substring(e,$e):s)!==n&&(r,e=parseInt(e)),r=e}function xn(){var r,e,s,a,u,o,c,i;if(r=$e,e=$e,Be++,s=mn(),Be--,s===n?e=void 0:($e=e,e=n),e!==n)if(s=$e,Be++,a=$n(),Be--,a===n?s=void 0:($e=s,s=n),s!==n){if(a=$e,u=$e,re.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(ee)),o!==n){for(c=[],ne.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(se));i!==n;)c.push(i),ne.test(t.charAt($e))?(i=t.charAt($e),$e++):(i=n,0===Be&&ze(se));c!==n?u=o=[o,c]:($e=u,u=n)}else $e=u,u=n;(a=u!==n?t.substring(a,$e):u)!==n?(r,r=e=a):($e=r,r=n)}else $e=r,r=n;else $e=r,r=n;return r}function $n(){var r,e,s,a,u,o,c,i,f,l,h,p,A,d;return r=$e,e=$e,(s=En())!==n&&(a=En())!==n?(45===t.charCodeAt($e)?(u=Xr,$e++):(u=n,0===Be&&ze(Yr)),u===n&&(u=null),u!==n&&(o=En())!==n?(45===t.charCodeAt($e)?(c=Xr,$e++):(c=n,0===Be&&ze(Yr)),c===n&&(c=null),c!==n&&(i=En())!==n?(45===t.charCodeAt($e)?(f=Xr,$e++):(f=n,0===Be&&ze(Yr)),f===n&&(f=null),f!==n&&(l=En())!==n?(45===t.charCodeAt($e)?(h=Xr,$e++):(h=n,0===Be&&ze(Yr)),h===n&&(h=null),h!==n&&(p=En())!==n&&(A=En())!==n&&(d=En())!==n?e=s=[s,a,u,o,c,i,f,l,h,p,A,d]:($e=e,e=n)):($e=e,e=n)):($e=e,e=n)):($e=e,e=n)):($e=e,e=n),r=e!==n?t.substring(r,$e):e}function En(){var r,e,s,a,u,o;return r=$e,e=$e,ae.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(ue)),s!==n?(ae.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ue)),a!==n?(ae.test(t.charAt($e))?(u=t.charAt($e),$e++):(u=n,0===Be&&ze(ue)),u!==n?(ae.test(t.charAt($e))?(o=t.charAt($e),$e++):(o=n,0===Be&&ze(ue)),o!==n?e=s=[s,a,u,o]:($e=e,e=n)):($e=e,e=n)):($e=e,e=n)):($e=e,e=n),r=e!==n?t.substring(r,$e):e}function Ln(){var r,e,s,a;if(r=$e,e=$e,s=[],oe.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ce)),a!==n)for(;a!==n;)s.push(a),oe.test(t.charAt($e))?(a=t.charAt($e),$e++):(a=n,0===Be&&ze(ce));else s=n;return(e=s!==n?t.substring(e,$e):s)!==n&&(r,e={val:e}),r=e}function Sn(){var r,e,s,a;return r=$e,(e=_n())!==n?(44===t.charCodeAt($e)?(s=",",$e++):(s=n,0===Be&&ze(ve)),s!==n&&(a=_n())!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r}function Bn(){var r,e,s,a;return r=$e,(e=_n())!==n?(40===t.charCodeAt($e)?(s="(",$e++):(s=n,0===Be&&ze(be)),s!==n&&(a=_n())!==n?r=e=[e,s,a]:($e=r,r=n)):($e=r,r=n),r}function Tn(){var r,e,s;return r=$e,(e=_n())!==n?(41===t.charCodeAt($e)?(s=")",$e++):(s=n,0===Be&&ze(ye)),s!==n?r=e=[e,s]:($e=r,r=n)):($e=r,r=n),r}function _n(){var r,e,s;for(Be++,r=$e,e=[],Ce.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(we));s!==n;)e.push(s),Ce.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(we));return r=e!==n?t.substring(r,$e):e,Be--,r===n&&(e=n,0===Be&&ze(me)),r}function On(){var r,e,s;if(Be++,r=$e,e=[],Ce.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(we)),s!==n)for(;s!==n;)e.push(s),Ce.test(t.charAt($e))?(s=t.charAt($e),$e++):(s=n,0===Be&&ze(we));else e=n;return r=e!==n?t.substring(r,$e):e,Be--,r===n&&(e=n,0===Be&&ze(xe)),r}const Zn=Object.assign,{strict:Rn,minimal:zn}=r,Fn=[];let jn,kn;const Nn=["$value"],Dn=r.safeNumber||function(t){const r=Number(t);return Number.isSafeInteger(r)?r:t},Un=r.standardBase64||function(t){return(t=t.replace(/_/g,"/").replace(/-/g,"+")).padEnd(t.length+t.length%4,"=")},Pn=t=>r=>t===r||t.as&&r.as&&t.as===r.as||r.as&&t.ref&&r.as===t.ref[t.ref.length-1]||t.ref&&r.ref&&t.ref.join("")===r.ref.join(""),qn=t=>r=>{if(Array.isArray(r))return r.map(qn(t));const e=r.ref&&t.find((t=>t.as&&t.func&&t.as===r.ref[0]));return e||r},In=t=>r=>Array.isArray(r)?r.map(In(t)):r.ref&&!t.find(Pn(r))?{val:null}:r,Mn=(t,r)=>{if(1===r.ref.length)t.find(Pn(r))||t.push(r);else{const e=r.ref.shift(),n=t.find((t=>t.ref&&t.ref[0]===e));if(n)Mn(n.expand,r);else{const n={ref:[e],expand:[]};Mn(n.expand,r),t.push(n)}}},Xn=(t,r,e=!1)=>{if(!r)return;if(t.apply&&delete t.apply,(r.apply||r.where&&t.where||r.search&&t.search)&&(t.from={SELECT:{from:t.from}}),r.where&&(t.where?t.from.SELECT.where=r.where:t.where=r.where),r.search&&(t.search?t.from.SELECT.search=r.search:t.search=r.search),r.groupBy){t.groupBy=[];for(const e of r.groupBy)t.groupBy.find(Pn(e))||t.groupBy.push(e)}const n=[...t.groupBy||[],...r.aggregate||[]];n.length&&(t.columns=t.columns&&!e?t.columns.reduce(((t,r)=>{const e=n.find(Pn(r));return e&&t.push(e),t}),[]):n,t.where&&(t.where=t.where.map(qn(t.columns)),t.groupBy&&(t.having=t.where.map(In(t.groupBy)),delete t.where)),t.columns=t.columns.reduce(((t,r)=>(r.ref&&r.ref.length>1&&n.find(Pn(r))?Mn(t,{ref:[...r.ref]}):t.push(r),t)),[])),r.apply&&Xn(t.from.SELECT,r.apply)},Yn=t=>{jn.limit&&jn.limit.offset&&jn.limit.offset.val&&(t+=jn.limit.offset.val),(jn.limit||(jn.limit={})).offset={val:t}},Gn=(t,r)=>{for(const e of r)e.ref&&e.ref[0]===t&&e.ref.shift(),e.func&&Gn(t,e.args);return r};if((e=a())!==n&&$e===t.length)return e;throw e!==n&&$e<t.length&&ze({type:"end"}),Fe(Se,Le<t.length?t.charAt(Le):null,Le<t.length?Re(Le,Le+1):Re(Le,Le))}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?a(t.parts[r][0])+"-"+a(t.parts[r][1]):a(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 a(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,a=new Array(t.length);for(r=0;r<t.length;r++)a[r]=(s=t[r],e[s.type](s));if(a.sort(),a.length>0){for(r=1,n=1;r<a.length;r++)a[r-1]!==a[r]&&(a[n]=a[r],n++);a.length=n}switch(a.length){case 1:return a[0];case 2:return a[0]+" or "+a[1];default:return a.slice(0,-1).join(", ")+", or "+a[a.length-1]}}(t)+" but "+function(t){return t?'"'+s(t)+'"':"end of input"}(r)+" found."},module.exports={SyntaxError:peg$SyntaxError,parse:peg$parse};
|
package/libx/rest/RestAdapter.js
CHANGED
|
@@ -5,6 +5,7 @@ const express = require('express')
|
|
|
5
5
|
const auth = require('./middleware/auth')
|
|
6
6
|
const content = require('./middleware/content')
|
|
7
7
|
const parse = require('./middleware/parse')
|
|
8
|
+
const input = require('./middleware/input')
|
|
8
9
|
|
|
9
10
|
const create = require('./middleware/create')
|
|
10
11
|
const read = require('./middleware/read')
|
|
@@ -13,11 +14,14 @@ const deleet = require('./middleware/delete')
|
|
|
13
14
|
const operation = require('./middleware/operation')
|
|
14
15
|
|
|
15
16
|
const error = require('./middleware/error')
|
|
17
|
+
const { alias2ref } = require('../_runtime/common/utils/csn')
|
|
16
18
|
|
|
17
19
|
class RestAdapter extends express.Router {
|
|
18
20
|
constructor(srv) {
|
|
19
21
|
super()
|
|
20
22
|
|
|
23
|
+
alias2ref(srv)
|
|
24
|
+
|
|
21
25
|
this.use(express.json())
|
|
22
26
|
|
|
23
27
|
// pass srv-reated stuff to middlewares via req
|
|
@@ -51,6 +55,9 @@ class RestAdapter extends express.Router {
|
|
|
51
55
|
// parse
|
|
52
56
|
this.use('/', parse)
|
|
53
57
|
|
|
58
|
+
// payload validation
|
|
59
|
+
this.use('/', input)
|
|
60
|
+
|
|
54
61
|
// begin tx
|
|
55
62
|
this.use('/', (req, res, next) => {
|
|
56
63
|
// create tx and set as cds.context
|
|
@@ -104,7 +111,8 @@ class RestAdapter extends express.Router {
|
|
|
104
111
|
'content-length': JSON.stringify(result).length
|
|
105
112
|
})
|
|
106
113
|
.end()
|
|
107
|
-
|
|
114
|
+
// need to convert number to string because express interprets integer as status code
|
|
115
|
+
else res.send(typeof result === 'number' ? result.toString() : result)
|
|
108
116
|
})
|
|
109
117
|
this.use('/', (err, req, res, next) => {
|
|
110
118
|
// request may fail during processing or during commit -> both caught here
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// const cds = require('../../_runtime/cds')
|
|
2
|
+
const getTemplate = require('../../_runtime/common/utils/template')
|
|
3
|
+
const templateProcessor = require('../../_runtime/common/utils/templateProcessor')
|
|
4
|
+
const { checkStaticElementByKey, assertNotNullError } = require('../../_runtime/cds-services/util/assert')
|
|
5
|
+
const { MULTIPLE_ERRORS } = require('../../_runtime/common/error/constants')
|
|
6
|
+
|
|
7
|
+
const _picker = req => {
|
|
8
|
+
const skipKeyValidation = req.method !== 'POST'
|
|
9
|
+
return element => {
|
|
10
|
+
const categories = {}
|
|
11
|
+
if (Array.isArray(element)) return
|
|
12
|
+
if (element._isStructured || element.isAssociation || element.items) return
|
|
13
|
+
if (!skipKeyValidation && element.key) categories['key_validation'] = true
|
|
14
|
+
categories['static_validation'] = true
|
|
15
|
+
return categories
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const _processorFn = errors => {
|
|
20
|
+
return ({ row, key, plain: categories, target, element }) => {
|
|
21
|
+
// REVISIT move validation to generic asserter => see PR 717
|
|
22
|
+
if (categories['static_validation'] && row[key] != null) {
|
|
23
|
+
const validations = checkStaticElementByKey(target, key, row[key])
|
|
24
|
+
errors.push(...validations)
|
|
25
|
+
}
|
|
26
|
+
if (categories['key_validation'] && !(key in row)) {
|
|
27
|
+
errors.push(assertNotNullError(element))
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const _cache = req => `rest-input;skip-key-validation:${req.method !== 'POST'}`
|
|
33
|
+
|
|
34
|
+
module.exports = (req, res, next) => {
|
|
35
|
+
const { _srv, _query, _data, _operation } = req
|
|
36
|
+
const definition = _operation || _query.__target
|
|
37
|
+
|
|
38
|
+
if (!(_data && _srv && definition)) return next()
|
|
39
|
+
|
|
40
|
+
const errors = []
|
|
41
|
+
|
|
42
|
+
const template = getTemplate(_cache(req), _srv, definition, { pick: _picker(req) })
|
|
43
|
+
if (template && template.elements.size) {
|
|
44
|
+
const rows = Array.isArray(_data) ? _data : [_data]
|
|
45
|
+
for (const row of rows) {
|
|
46
|
+
templateProcessor({ processFn: _processorFn(errors), row, template })
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (errors.length > 1) throw Object.assign(new Error(MULTIPLE_ERRORS), { details: errors })
|
|
51
|
+
if (errors.length === 1) throw errors[0]
|
|
52
|
+
|
|
53
|
+
next()
|
|
54
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const cds = require('../../_runtime/cds')
|
|
1
2
|
const { validateReturnType } = require('../../_runtime/cds-services/adapter/rest/utils/validation-checks')
|
|
2
3
|
|
|
3
4
|
const RestRequest = require('../RestRequest')
|
|
@@ -25,6 +26,17 @@ module.exports = async (_req, _res, next) => {
|
|
|
25
26
|
// REVISIT: do not use from old rest adapter
|
|
26
27
|
// REVISIT: new impl should return instead of throwing to avoid try catch
|
|
27
28
|
validateReturnType(operation, result)
|
|
29
|
+
|
|
30
|
+
// set content-type header to text/plain for returned primitive data types, except for boolean
|
|
31
|
+
const returnType = operation.returns._type
|
|
32
|
+
if (
|
|
33
|
+
!_res.get('content-type') &&
|
|
34
|
+
!operation.returns.items &&
|
|
35
|
+
returnType &&
|
|
36
|
+
cds.builtin.types[returnType] &&
|
|
37
|
+
returnType !== 'cds.Boolean'
|
|
38
|
+
)
|
|
39
|
+
_res.set('content-type', 'text/plain')
|
|
28
40
|
} catch (e) {
|
|
29
41
|
return next(e)
|
|
30
42
|
}
|
|
@@ -32,7 +44,8 @@ module.exports = async (_req, _res, next) => {
|
|
|
32
44
|
// REVISIT: still needed?
|
|
33
45
|
if (!operation.returns.items && Array.isArray(result)) result = result[0]
|
|
34
46
|
|
|
35
|
-
_req._result = {
|
|
47
|
+
if (result === undefined) _req._result = { status: 204 }
|
|
48
|
+
else _req._result = { result }
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
next()
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const cds = require('../../_runtime/cds')
|
|
2
2
|
const { INSERT, SELECT, UPDATE, DELETE } = cds.ql
|
|
3
3
|
|
|
4
|
-
const { getDeepCopy } = require('../utils/data')
|
|
5
|
-
|
|
6
4
|
const { where2obj } = require('../../_runtime/common/utils/cqn')
|
|
7
5
|
|
|
6
|
+
const { convertStructured } = require('../../common/utils/ucsn')
|
|
7
|
+
const { deepCopy } = require('../../_runtime/common/utils/copy')
|
|
8
|
+
|
|
8
9
|
module.exports = (req, res, next) => {
|
|
9
10
|
const { _srv: service } = req
|
|
10
|
-
const { model } = service
|
|
11
11
|
|
|
12
12
|
let query = cds.odata.parse(req.url, { service })
|
|
13
13
|
|
|
@@ -71,13 +71,17 @@ module.exports = (req, res, next) => {
|
|
|
71
71
|
// anything to do?
|
|
72
72
|
}
|
|
73
73
|
req._query = query
|
|
74
|
+
if (query) req._query.__target = definition
|
|
74
75
|
|
|
75
76
|
// REVISIT: query._data hack
|
|
76
|
-
// deep copy of body (incl. validations such as correct data type)
|
|
77
77
|
if ((query && (query.INSERT || query.UPDATE)) || (operation && operation.kind === 'action') || args) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
if (operation && (operation.kind === 'action' || operation.kind === 'function') && !operation.params) {
|
|
79
|
+
req._data = {}
|
|
80
|
+
} else {
|
|
81
|
+
const payload = deepCopy(args || req.body)
|
|
82
|
+
convertStructured(service, operation || definition, payload)
|
|
83
|
+
req._data = payload
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
// REVISIT: req.params as documented
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
const cds = require('./lib'), { features } = cds.env
|
|
1
2
|
const express = require('express')
|
|
2
|
-
const cds = require('./lib'), { unfold_csn: cds_localized } = cds.compile._localized
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Standard express.js bootstrapping, constructing an express `application`
|
|
@@ -23,9 +23,10 @@ const cds = require('./lib'), { unfold_csn: cds_localized } = cds.compile._local
|
|
|
23
23
|
* @param {express.Handler} options.logger - custom request logger middleware
|
|
24
24
|
* @returns Promise resolving to a Node.js http server as returned by express' `app.listen()`.
|
|
25
25
|
*/
|
|
26
|
-
module.exports = async function cds_server (options
|
|
26
|
+
module.exports = async function cds_server (options) {
|
|
27
27
|
|
|
28
28
|
const _in_prod = process.env.NODE_ENV === 'production'
|
|
29
|
+
const o = cds.options = { ...options, __proto__:defaults }
|
|
29
30
|
|
|
30
31
|
const app = cds.app = o.app || express()
|
|
31
32
|
app.serve = _app_serve //> app.serve allows delegating to sub modules
|
|
@@ -33,39 +34,49 @@ module.exports = async function cds_server (options, o = { ...options, __proto__
|
|
|
33
34
|
|
|
34
35
|
// mount static resources and logger middleware
|
|
35
36
|
if (o.cors) !_in_prod && app.use (o.cors) //> CORS
|
|
36
|
-
if (o.static) app.use (
|
|
37
|
+
if (o.static) app.use (express_static (o.static)) //> defaults to ./app
|
|
37
38
|
if (o.favicon) app.use ('/favicon.ico', o.favicon) //> if none in ./app
|
|
38
39
|
if (o.index) app.get ('/',o.index) //> if none in ./app
|
|
39
40
|
if (o.correlate) app.use (o.correlate) //> request correlation
|
|
40
41
|
if (o.logger) app.use (o.logger) //> basic request logging
|
|
41
42
|
if (o.toggler) app.use (o.toggler) //> feature toggler
|
|
42
43
|
|
|
43
|
-
// give uiflex a chance to plug into everything
|
|
44
|
-
if (cds.requires.extensibility) await require('./libx/_runtime/fiori/uiflex')() // REVISIT: later this should be a ext umbrella service
|
|
45
|
-
|
|
46
44
|
// load specified models or all in project
|
|
47
|
-
const csn = await cds.load(o.from||'*',o) .then (cds.minify)
|
|
48
|
-
cds.model =
|
|
45
|
+
const csn = await cds.load(o.from||'*',o) .then (cds.minify) //> separate csn for _init_db
|
|
46
|
+
cds.model = cds.compile.for.nodejs(csn)
|
|
49
47
|
|
|
50
48
|
// connect to essential framework services if required
|
|
51
|
-
|
|
52
|
-
if (cds.requires.db)
|
|
53
|
-
if (cds.requires.messaging)
|
|
54
|
-
if (cds.requires.multitenancy)
|
|
55
|
-
|
|
56
|
-
// serve graphql
|
|
57
|
-
if (cds.env.features.graphql) serve_graphql(app)
|
|
49
|
+
if (cds.requires.extensibility) await _extensibility() //> has to go first
|
|
50
|
+
if (cds.requires.db) cds.db = await cds.connect.to ('db') .then (_init)
|
|
51
|
+
if (cds.requires.messaging) await cds.connect.to ('messaging')
|
|
52
|
+
if (cds.requires.multitenancy) await _multitenancy()
|
|
53
|
+
if (cds.requires.toggles) await _model_provider()
|
|
58
54
|
|
|
59
55
|
// serve all services declared in models
|
|
60
|
-
|
|
61
|
-
await cds.
|
|
56
|
+
if (features.graphql) serve_graphql(app)
|
|
57
|
+
await cds.serve (o.service,o) .in (app)
|
|
58
|
+
await cds.emit ('served', cds.services) //> hook for listeners
|
|
62
59
|
|
|
63
60
|
// start http server
|
|
64
61
|
const port = (o.port !== undefined) ? o.port : (process.env.PORT || 4004)
|
|
65
62
|
return app.listen (port)
|
|
66
63
|
|
|
64
|
+
// bootstrap in-memory db
|
|
65
|
+
async function _init (db) {
|
|
66
|
+
if (!o.in_memory || cds.requires.multitenancy) return db
|
|
67
|
+
const fts = cds.requires.toggles && cds.resolve (features.folders)
|
|
68
|
+
const m = !fts ? csn : await cds.load([o.from||'*',...fts],o) .then (cds.minify)
|
|
69
|
+
return cds.deploy(m).to(db,o)
|
|
70
|
+
}
|
|
71
|
+
|
|
67
72
|
}
|
|
68
73
|
|
|
74
|
+
// REVISIT: Move these out of here...
|
|
75
|
+
const _model_provider = () => require('./libx/_runtime/extensibility/mps')
|
|
76
|
+
const _extensibility = () => require('./libx/_runtime/extensibility/uiflex')
|
|
77
|
+
const _multitenancy = () => features.streamlined_mtx ? _model_provider() : cds.mtx.in (cds.app)
|
|
78
|
+
|
|
79
|
+
|
|
69
80
|
|
|
70
81
|
// -------------------------------------------------------------------------
|
|
71
82
|
// Default handlers, which can be overidden by options passed to the server
|
|
@@ -103,8 +114,8 @@ const defaults = {
|
|
|
103
114
|
|
|
104
115
|
// feature toggler
|
|
105
116
|
get toggler() {
|
|
106
|
-
return require('./libx/_runtime/common/toggles/
|
|
107
|
-
}
|
|
117
|
+
return require('./libx/_runtime/common/toggles/handler')(cds)
|
|
118
|
+
}
|
|
108
119
|
}
|
|
109
120
|
|
|
110
121
|
|
|
@@ -153,6 +164,10 @@ function correlate (req, res, next) {
|
|
|
153
164
|
next()
|
|
154
165
|
}
|
|
155
166
|
|
|
167
|
+
function express_static (dir) {
|
|
168
|
+
return express.static (path.resolve (cds.root,dir))
|
|
169
|
+
}
|
|
170
|
+
|
|
156
171
|
|
|
157
172
|
// -------------------------------------------------------------------------
|
|
158
173
|
if (!module.parent) module.exports ({from:process.argv[2]})
|
package/srv/audit-log.cds
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
service AuditLogService {
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// Log read access to sensitive personal data
|
|
4
4
|
event dataAccessLog {
|
|
5
5
|
accesses : array of Access;
|
|
6
6
|
// accessFilters : array of KeyValuePair;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
//
|
|
9
|
+
// Log changes to personal data
|
|
10
10
|
event dataModificationLog : {
|
|
11
11
|
modifications : array of DataModification;
|
|
12
12
|
};
|
package/srv/flex.cds
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
namespace cds_r; //> cds system tables
|
|
2
2
|
|
|
3
|
+
type JSON: String;
|
|
4
|
+
|
|
5
|
+
@protocol: 'rest'
|
|
3
6
|
service ExtensibilityService @(path:'/-/cds/extensibility') {
|
|
4
7
|
action addExtension(extensions : array of String); // TODO: change to array of CSN extensions
|
|
8
|
+
action activate(tenant: String);
|
|
9
|
+
action activateProject(tenant: String, extension: array of { filename: String; model: JSON }, undeployExtension: Boolean);
|
|
5
10
|
}
|
|
6
11
|
|
|
7
12
|
entity Extensions {
|
|
8
|
-
key ID
|
|
9
|
-
csn
|
|
13
|
+
key ID : UUID;
|
|
14
|
+
csn : String;
|
|
15
|
+
activated : Boolean; // <-- status / enum ?
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
// @open type Extension {
|
package/srv/flex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('../libx/_runtime/
|
|
1
|
+
module.exports = require('../libx/_runtime/extensibility/uiflex/service')
|
package/srv/mps.cds
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
namespace cds_r; //> cds system tables
|
|
2
|
+
|
|
3
|
+
type TenantID : String;
|
|
4
|
+
@open type CSN {};
|
|
5
|
+
type XML : String;
|
|
6
|
+
type Locale : String;
|
|
7
|
+
type TAR : LargeBinary;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Used by CAP runtimes to retrieve tenant-specific variants of
|
|
11
|
+
* deployed models used to serve requests.
|
|
12
|
+
*/
|
|
13
|
+
@(requires : [
|
|
14
|
+
'mtcallback'
|
|
15
|
+
])
|
|
16
|
+
@protocol: 'rest'
|
|
17
|
+
service ModelProviderService @(path:'/-/cds/model-provider') {
|
|
18
|
+
action isExtended(tenant : TenantID) returns Boolean;
|
|
19
|
+
action getCsn(tenant : TenantID, toggles : array of String, flavor: String enum { nodejs; java; }) returns CSN;
|
|
20
|
+
action getOdataCsn(tenant : TenantID, toggles : array of String) returns CSN; // REVISIT: Replace by getCsn(..., flavor=node/java)
|
|
21
|
+
action getEdmx(tenant : TenantID, toggles : array of String, serviceName : String, locale : Locale, odataFlavor : String) returns XML;
|
|
22
|
+
action getResources(flat : Boolean) returns TAR;
|
|
23
|
+
}
|
package/srv/mps.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../libx/_runtime/extensibility/mps/service')
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const cds = require('../../../cds')
|
|
2
|
-
|
|
3
|
-
const getCredentials = uaa => {
|
|
4
|
-
uaa =
|
|
5
|
-
uaa && uaa.credentials
|
|
6
|
-
? uaa
|
|
7
|
-
: cds.env.requires.uaa && cds.env.requires.uaa.credentials
|
|
8
|
-
? cds.env.requires.uaa
|
|
9
|
-
: cds.env.requires.xsuaa && cds.env.requires.xsuaa.credentials
|
|
10
|
-
? cds.env.requires.xsuaa
|
|
11
|
-
: {}
|
|
12
|
-
|
|
13
|
-
if (!uaa.credentials)
|
|
14
|
-
throw Object.assign(new Error('No or malformed uaa credentials'), { credentials: uaa.credentials })
|
|
15
|
-
|
|
16
|
-
return uaa.credentials
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
getCredentials
|
|
21
|
-
}
|