@cap.core/ql 1.2.6 → 1.4.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/@types/cqn.d.ts +5 -5
- package/@types/exprs.d.ts +32 -45
- package/@types/index.d.ts +14 -14
- package/@types/ql/delete.d.ts +1 -1
- package/@types/ql/insert.d.ts +1 -2
- package/@types/ql/select.d.ts +1 -1
- package/@types/ql/update.d.ts +1 -1
- package/@types/{ql/base-class.d.ts → query.d.ts} +1 -1
- package/cql/parser.min.js +1 -2
- package/lib/index.js +48 -29
- package/lib/ql/cache.js +7 -11
- package/lib/ql/call-action.js +6 -0
- package/lib/ql/delete.js +1 -1
- package/lib/ql/insert.js +9 -8
- package/lib/ql/select.js +1 -1
- package/lib/ql/update.js +9 -5
- package/lib/{ql/base-class.js → query.js} +29 -44
- package/lib/xl/fluent.js +33 -18
- package/lib/xl/ttl.js +19 -24
- package/package.json +5 -4
- package/@types/LICENSE +0 -201
package/@types/cqn.d.ts
CHANGED
|
@@ -111,7 +111,7 @@ interface infix {
|
|
|
111
111
|
*/
|
|
112
112
|
export type expr = OneOf< ref | val | xpr | list | func | param | SELECT >
|
|
113
113
|
export type ref = { ref: OneOf< name | { id:name } &infix >[] }
|
|
114
|
-
export type val = { val:
|
|
114
|
+
export type val = { val: string | number | boolean | null }
|
|
115
115
|
export type xpr = { xpr: xo[] }
|
|
116
116
|
export type list = { list: expr[] }
|
|
117
117
|
export type func = { func: string, args: expr[] }
|
|
@@ -126,10 +126,10 @@ export type param = { ref: [ '?' | number | string ], param: true }
|
|
|
126
126
|
* including support for native SQL features.
|
|
127
127
|
*/
|
|
128
128
|
export type xo = OneOf< expr | keyword | operator >
|
|
129
|
-
type operator = '=' | '==' | '!=' | '<' | '<=' | '>' | '>='
|
|
130
|
-
type keyword = 'in' | 'like' | 'and' | 'or' | 'not'
|
|
131
|
-
type scalar = number | string | boolean | null
|
|
132
|
-
type name = string
|
|
129
|
+
export type operator = '=' | '==' | '!=' | '<' | '<=' | '>' | '>='
|
|
130
|
+
export type keyword = 'in' | 'like' | 'and' | 'or' | 'not'
|
|
131
|
+
export type scalar = number | string | boolean | null
|
|
132
|
+
export type name = string
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
|
package/@types/exprs.d.ts
CHANGED
|
@@ -1,64 +1,51 @@
|
|
|
1
1
|
import * as cqn from './cqn'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function where () : cqn.xo[]
|
|
7
|
-
export function having () : cqn.xo[]
|
|
8
|
-
export function groupBy () : cqn.column[]
|
|
9
|
-
export function orderBy () : cqn.order[]
|
|
10
|
-
|
|
3
|
+
type ttl = TemplateStringsArray
|
|
4
|
+
type scalar = cqn.scalar
|
|
5
|
+
type path = string
|
|
11
6
|
|
|
12
7
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* Constructs a `{val}` CQN object. The argument can be either a template string
|
|
9
|
+
* with interpolations of strings, numbers, booleans, null, or a simple scalar value.
|
|
15
10
|
*/
|
|
16
|
-
export function
|
|
11
|
+
export function val (strings: ttl) : cqn.val
|
|
12
|
+
export function val <T extends scalar> (val: T) : { val: T }
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
15
|
+
* Constructs a `{ref}` CQN object. The argument can be either a template string which
|
|
16
|
+
* can contain complex path expressions, including infix filters, function calls,
|
|
17
|
+
* or a string which will be split into path segments.
|
|
21
18
|
*/
|
|
22
|
-
export function
|
|
19
|
+
export function ref (strings: ttl) : cqn.ref
|
|
20
|
+
export function ref (path: path) : cqn.ref
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* Contstructs a `{xpr}`, `{ref}`, `{val}`, `{func}`, or `{list}` CQN object.
|
|
24
|
+
* The argument can be either a template string which can contain complex expressions
|
|
25
|
+
* with operators, function calls, or a simple value or an array of simple values.
|
|
27
26
|
*/
|
|
28
|
-
export function expr (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* This is the template string variant of `ref`. The argument is a template string,
|
|
33
|
-
* which forms a path expression, with optional infix filters.
|
|
34
|
-
*/
|
|
35
|
-
export function ref (strings: TemplateStringsArray, ...values: any[]) : cqn.ref
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* This is the fluent variant of `ref` for the case where the arguments are simple
|
|
39
|
-
* path segments. It constructs a CQN `{ref}` expression.
|
|
40
|
-
*/
|
|
41
|
-
export function ref (...path: string[]) : cqn.ref
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* This is the template string variant of `val`. The argument is a template string,
|
|
46
|
-
* which can contain interpolations of strings, numbers, booleans, null.
|
|
47
|
-
*/
|
|
48
|
-
export function val (strings: TemplateStringsArray, ...values: any[]) : cqn.val
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* This is the fluent variant of `val` for the case where the argument is a single
|
|
52
|
-
* scalar value. In this case, it constructs a CQN `{val}` expression.
|
|
53
|
-
*/
|
|
54
|
-
export function val (val: cqn.scalar) : cqn.val
|
|
27
|
+
export function expr (ttl: ttl) : cqn.expr
|
|
28
|
+
export function expr <T extends scalar> (val: T) : { val: T }
|
|
29
|
+
export function expr (vals: scalar[] ) : cqn.list
|
|
55
30
|
|
|
31
|
+
export function subject(): cqn.ref
|
|
32
|
+
export function columns() : cqn.column[]
|
|
33
|
+
export function values(): cqn.val[]
|
|
34
|
+
export function where() : cqn.xo[]
|
|
35
|
+
export function having() : cqn.xo[]
|
|
36
|
+
export function groupBy() : cqn.column[]
|
|
37
|
+
export function orderBy() : cqn.order[]
|
|
56
38
|
|
|
57
39
|
|
|
58
40
|
export interface fluent {
|
|
41
|
+
val : typeof val
|
|
42
|
+
ref : typeof ref
|
|
59
43
|
expr : typeof expr
|
|
60
|
-
|
|
44
|
+
subject : typeof subject
|
|
61
45
|
columns : typeof columns
|
|
62
|
-
|
|
46
|
+
values : typeof values
|
|
63
47
|
where : typeof where
|
|
48
|
+
having : typeof having
|
|
49
|
+
groupBy : typeof groupBy
|
|
50
|
+
orderBy : typeof orderBy
|
|
64
51
|
}
|
package/@types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Query } from './
|
|
2
|
-
import { SELECT as SELECT_ } from './ql/select.js'
|
|
3
|
-
import { INSERT as INSERT_ } from './ql/insert.js'
|
|
4
|
-
import { UPSERT as UPSERT_ } from './ql/insert.js'
|
|
5
|
-
import { UPDATE as UPDATE_ } from './ql/update.js'
|
|
6
|
-
import { DELETE as DELETE_ } from './ql/delete.js'
|
|
1
|
+
import { Query } from './query.js'
|
|
2
|
+
import { SELECT as SELECT_ } from './ql/select.js'
|
|
3
|
+
import { INSERT as INSERT_ } from './ql/insert.js'
|
|
4
|
+
import { UPSERT as UPSERT_ } from './ql/insert.js'
|
|
5
|
+
import { UPDATE as UPDATE_ } from './ql/update.js'
|
|
6
|
+
import { DELETE as DELETE_ } from './ql/delete.js'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This is the central entry point for creating queries from various types of input:
|
|
@@ -17,13 +17,13 @@ import { DELETE as DELETE_ } from './ql/delete.js';
|
|
|
17
17
|
*/
|
|
18
18
|
export function cql (
|
|
19
19
|
qso: Query | string | object, ...args: any[]
|
|
20
|
-
): SELECT_ & INSERT_ & UPSERT_ & UPDATE_ & DELETE_
|
|
20
|
+
): SELECT_ & INSERT_ & UPSERT_ & UPDATE_ & DELETE_
|
|
21
21
|
|
|
22
22
|
export * from './exprs'
|
|
23
|
-
export { Query }
|
|
24
|
-
export const SELECT: (() => typeof SELECT_) & typeof SELECT_
|
|
25
|
-
export const INSERT: (() => typeof INSERT_) & typeof INSERT_
|
|
26
|
-
export const UPSERT: (() => typeof UPSERT_) & typeof UPSERT_
|
|
27
|
-
export const UPDATE: (() => typeof UPDATE_) & typeof UPDATE_
|
|
28
|
-
export const DELETE: (() => typeof DELETE_) & typeof DELETE_
|
|
29
|
-
export default cql
|
|
23
|
+
export { Query }
|
|
24
|
+
export const SELECT: (() => typeof SELECT_) & typeof SELECT_
|
|
25
|
+
export const INSERT: (() => typeof INSERT_) & typeof INSERT_
|
|
26
|
+
export const UPSERT: (() => typeof UPSERT_) & typeof UPSERT_
|
|
27
|
+
export const UPDATE: (() => typeof UPDATE_) & typeof UPDATE_
|
|
28
|
+
export const DELETE: (() => typeof DELETE_) & typeof DELETE_
|
|
29
|
+
export default cql
|
package/@types/ql/delete.d.ts
CHANGED
package/@types/ql/insert.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Query } from '
|
|
1
|
+
import { Query } from '../query.js';
|
|
2
2
|
import * as cqn from '../cqn'
|
|
3
3
|
|
|
4
4
|
export class XSERT extends Query {
|
|
5
5
|
static entries(...args: any[]): XSERT;
|
|
6
6
|
static into(x: any, ...tail: any[]): XSERT;
|
|
7
|
-
_entries(...tail: any[]): this;
|
|
8
7
|
into(...args: any[]): this;
|
|
9
8
|
entries(...args: any[]): this;
|
|
10
9
|
columns(...args: any[]): this;
|
package/@types/ql/select.d.ts
CHANGED
package/@types/ql/update.d.ts
CHANGED
package/cql/parser.min.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export const $=Object.assign,px=()=>({param:"?"}),ql={SELECT:function(t){Object.defineProperty(Object.assign(this,t),"_",{value:this})},INSERT:function(t){Object.defineProperty(Object.assign(this,t),"_",{value:this})},UPSERT:function(t){Object.defineProperty(Object.assign(this,t),"_",{value:this})},UPDATE:function(t){Object.defineProperty(Object.assign(this,t),"_",{value:this})},DELETE:function(t){Object.defineProperty(Object.assign(this,t),"_",{value:this})},fluent:{subject:px,where:px,expr:px}};class peg$SyntaxError extends SyntaxError{constructor(t,e,n,r){super(t),this.expected=e,this.found=n,this.location=r,this.name="SyntaxError"}format(t){let e="Error: "+this.message;if(this.location){let n=null;const r=t.find(t=>t.source===this.location.source);r&&(n=r.text.split(/\r\n|\n|\r/g));const s=this.location.start,o=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(s):s,u=this.location.source+":"+o.line+":"+o.column;if(n){const t=this.location.end,r="".padEnd(o.line.toString().length," "),l=n[s.line-1],i=(s.line===t.line?t.column:l.length+1)-s.column||1;e+="\n --\x3e "+u+"\n"+r+" |\n"+o.line+" | "+l+"\n"+r+" | "+"".padEnd(s.column-1," ")+"".padEnd(i,"^")}else e+="\n at "+u}return e}static buildMessage(t,e){function n(t){return t.codePointAt(0).toString(16).toUpperCase()}const r=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function s(t){return r?t.replace(r,t=>"\\u{"+n(t)+"}"):t}function o(t){return s(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,t=>"\\x0"+n(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+n(t)))}function u(t){return s(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,t=>"\\x0"+n(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+n(t)))}const l={literal:t=>'"'+o(t.text)+'"',class(t){const e=t.parts.map(t=>Array.isArray(t)?u(t[0])+"-"+u(t[1]):u(t));return"["+(t.inverted?"^":"")+e.join("")+"]"+(t.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:t=>t.description};function i(t){return l[t.type](t)}return"Expected "+function(t){const e=t.map(i);if(e.sort(),e.length>0){let t=1;for(let n=1;n<e.length;n++)e[n-1]!==e[n]&&(e[t]=e[n],t++);e.length=t}switch(e.length){case 1:return e[0];case 2:return e[0]+" or "+e[1];default:return e.slice(0,-1).join(", ")+", or "+e[e.length-1]}}(t)+" but "+function(t){return t?'"'+o(t)+'"':"end of input"}(e)+" found."}}function peg$parse(t,e){const n={},r=(e=void 0!==e?e:{}).grammarSource,s={CQL:xn,entity:Rn,columns:vn,ref:Fn,val:In,vals:Dn,expr:Pn,where:_n,groupBy:Sn,orderBy:$n};let o=xn;const u="select",l="localized",i="distinct",c="one",a="from",f="where",h="group by",p="having",d="order by",g="limit",b="offset",C="as",w="*",A="[",x="]",m="asc",E="desc",L="insert",v="upsert",y="into",_="entries",S="columns",O="rows",T="values",R="update",P="entity",j="with",F="set",I="=",D="delete",N=":",U="#",z="?",B="and",q="or",M="in",Z="between",H="like",W="exists",Y="contains",k="case",G="when",Q="then",V="else",J="end",K="is",X="not",tt="null",et="empty",nt="-",rt=".",st="e",ot="'",ut="''",lt="true",it="false",ct="{",at="}",ft="(",ht=")",pt=",",dt=/^[A-Za-z_$]/,gt=/^[A-Za-z0-9_$]/,bt=/^[!=><+\-*\/%&|\^~]/,Ct=/^[0-9]/,wt=/^[^']/,At=/^[A-Za-z_$0-9]/,xt=/^[ \t\n\r]/,mt=pn("SELECT",!0),Et=pn("LOCALIZED",!0),Lt=pn("DISTINCT",!0),vt=pn("ONE",!0),yt=pn("FROM",!0),_t={type:"any"},St=pn("WHERE",!0),$t=pn("GROUP BY",!0),Ot=pn("HAVING",!0),Tt=pn("ORDER BY",!0),Rt=pn("LIMIT",!0),Pt=pn("OFFSET",!0),jt=pn("as",!0),Ft=pn("*",!1),It=pn("[",!1),Dt=pn("]",!1),Nt=pn("asc",!0),Ut=pn("desc",!0),zt=pn("INSERT",!0),Bt=pn("UPSERT",!0),qt=pn("INTO",!0),Mt=pn("ENTRIES",!0),Zt=pn("COLUMNS",!0),Ht=pn("ROWS",!0),Wt=pn("VALUES",!0),Yt=pn("UPDATE",!0),kt=pn("ENTITY",!0),Gt=pn("WITH",!0),Qt=pn("SET",!0),Vt=pn("=",!1),Jt=pn("DELETE",!0),Kt=gn("a name"),Xt=pn("AS",!0),te=pn("from",!0),ee=dn([["A","Z"],["a","z"],"_","$"],!1,!1,!1),ne=dn([["A","Z"],["a","z"],["0","9"],"_","$"],!1,!1,!1),re=gn("an element ref"),se=gn("an entity ref"),oe=pn(":",!1),ue=gn("a reference"),le=gn("a value"),ie=gn("a list"),ce=gn("a function"),ae=gn("a symbol"),fe=pn("#",!1),he=gn("a parameter"),pe=pn("?",!1),de=gn("an operator"),ge=dn(["!","=",">","<","+","-","*","/","%","&","|","^","~"],!1,!1,!1),be=pn("and",!1),Ce=pn("or",!1),we=pn("in",!1),Ae=pn("between",!1),xe=pn("like",!1),me=pn("exists",!1),Ee=pn("contains",!1),Le=pn("case",!1),ve=pn("when",!1),ye=pn("then",!1),_e=pn("else",!1),Se=pn("end",!1),$e=pn("is",!1),Oe=pn("not",!1),Te=pn("null",!1),Re=pn("empty",!1),Pe=gn("a literal"),je=pn("-",!1),Fe=dn([["0","9"]],!1,!1,!1),Ie=pn(".",!1),De=pn("e",!1),Ne=pn("'",!1),Ue=dn(["'"],!0,!1,!1),ze=pn("''",!1),Be=pn("true",!1),qe=pn("false",!1),Me=pn("{",!1),Ze=pn("}",!1),He=pn("(",!1),We=pn(")",!1),Ye=dn([["A","Z"],["a","z"],"_","$",["0","9"]],!1,!1,!1),ke=gn("a comma"),Ge=pn(",",!1),Qe=gn(""),Ve=dn([" ","\t","\n","\r"],!1,!1,!1);function Je(e){return tr===ql.fluent||(or?.length&&(e.params=or),nr?.length&&(e.args=nr),e.source=t.substring(un,on)),e}function Ke(t,e){t.as=e}function Xe(t,e,n){e?t.inline=n:t.expand=n}function tn(t,e){t.as=e}function en(t,e){t.sort=e.toLowerCase()}function nn(t,e,n){t._.with[e]=n}function rn(t,e){return e?{id:t,...e}:t}function sn(){return"'"}let on=0|e.peg$currPos,un=on;const ln=[{line:1,column:1}];let cn,an=on,fn=e.peg$maxFailExpected||[],hn=0|e.peg$silentFails;if(e.startRule){if(!(e.startRule in s))throw new Error("Can't start parsing from rule \""+e.startRule+'".');o=s[e.startRule]}function pn(t,e){return{type:"literal",text:t,ignoreCase:e}}function dn(t,e,n,r){return{type:"class",parts:t,inverted:e,ignoreCase:n,unicode:r}}function gn(t){return{type:"other",description:t}}function bn(e){let n,r=ln[e];if(r)return r;if(e>=ln.length)n=ln.length-1;else for(n=e;!ln[--n];);for(r=ln[n],r={line:r.line,column:r.column};n<e;)10===t.charCodeAt(n)?(r.line++,r.column=1):r.column++,n++;return ln[e]=r,r}function Cn(t,e,n){const s=bn(t),o=bn(e),u={source:r,start:{offset:t,line:s.line,column:s.column},end:{offset:e,line:o.line,column:o.column}};return n&&r&&"function"==typeof r.offset&&(u.start=r.offset(u.start),u.end=r.offset(u.end)),u}function wn(t){on<an||(on>an&&(an=on,fn=[]),fn.push(t))}function An(t,e,n){return new peg$SyntaxError(peg$SyntaxError.buildMessage(t,e),t,e,n)}function xn(){let e,r;return e=on,r=mn(),r===n&&(r=function(){let e,r,s,o,u,l,i,c,a,f,h,p,d,g;e=on,r=on,s=t.substr(on,6),s.toLowerCase()===L?on+=6:(s=n,0===hn&&wn(zt));s===n&&(s=t.substr(on,6),s.toLowerCase()===v?on+=6:(s=n,0===hn&&wn(Bt)));s!==n?(o=Xn(),o!==n?(un=r,r=new ql[s]):(on=r,r=n)):(on=r,r=n);if(r!==n)if(s=on,o=Hn(),o!==n&&(un=s,b=o,o=void(r._.entries=tr.entries(b))),s=o,s===n&&(s=null),o=on,u=on,l=t.substr(on,4),l.toLowerCase()===y?on+=4:(l=n,0===hn&&wn(qt)),l!==n?(i=Xn(),i!==n?(l=[l,i],u=l):(on=u,u=n)):(on=u,u=n),u!==n?(l=Rn(),l!==n?(un=o,o=function(t,e){t._.into=e}(r,l)):(on=o,o=n)):(on=o,o=n),o!==n){if(u=on,l=mn(),l!==n&&(un=u,l=function(t,e){t._.from=e}(r,l)),u=l,u===n){if(u=on,l=on,i=on,c=t.substr(on,7),c.toLowerCase()===_?on+=7:(c=n,0===hn&&wn(Mt)),c!==n?(a=Xn(),a!==n?(c=[c,a],i=c):(on=i,i=n)):(on=i,i=n),i===n&&(i=null),c=on,a=Hn(),a!==n&&(un=c,a=function(t,e){t._entries(e)}(r,a)),c=a,c!==n?(i=[i,c],l=i):(on=l,l=n),l===n&&(l=null),i=on,c=on,a=t.substr(on,7),a.toLowerCase()===S?on+=7:(a=n,0===hn&&wn(Zt)),a!==n?(f=Xn(),f!==n?(a=[a,f],c=a):(on=c,c=n)):(on=c,c=n),c===n&&(c=null),a=Hn(),a===n)if(a=on,f=kn(),f!==n){for(h=on,p=[],d=Tn();d!==n;)p.push(d),d=on,g=Vn(),g!==n?(g=Tn(),g===n?(on=d,d=n):d=g):d=g;p.length<1?(on=h,h=n):h=p,h!==n?(p=Gn(),p!==n?a=h:(on=a,a=n)):(on=a,a=n)}else on=a,a=n;a!==n?(un=i,i=function(t,e){t._.columns=e}(r,a)):(on=i,i=n),i===n&&(i=null),c=on,a=on,f=t.substr(on,4),f.toLowerCase()===O?on+=4:(f=n,0===hn&&wn(Ht)),f!==n?(h=Xn(),h!==n?(f=[f,h],a=f):(on=a,a=n)):(on=a,a=n),a===n&&(a=null),f=Hn(),f!==n?(un=c,c=function(t,e){t._.rows=e}(r,f)):(on=c,c=n),c===n&&(c=null),a=on,f=on,h=t.substr(on,6),h.toLowerCase()===T?on+=6:(h=n,0===hn&&wn(Wt)),h!==n?(p=Xn(),p!==n?(h=[h,p],f=h):(on=f,f=n)):(on=f,f=n),f!==n?(h=Nn(),h!==n?(un=a,a=function(t,e){t._.values=e.list}(r,h)):(on=a,a=n)):(on=a,a=n),a===n&&(a=null),l=[l,i,c,a],u=l}u!==n?e=r:(on=e,e=n)}else on=e,e=n;else on=e,e=n;var b;return e}(),r===n&&(r=function(){let e,r,s,o,u,l,i,c,a,h,p,d,g,b,C,w,A;e=on,r=on,s=t.substr(on,6),s.toLowerCase()===R?on+=6:(s=n,0===hn&&wn(Yt));s!==n?(o=Xn(),o!==n?(un=r,r=new ql.UPDATE):(on=r,r=n)):(on=r,r=n);if(r!==n)if(s=on,o=on,u=t.substr(on,6),u.toLowerCase()===P?on+=6:(u=n,0===hn&&wn(kt)),u!==n?(l=Xn(),l!==n?(u=[u,l],o=u):(on=o,o=n)):(on=o,o=n),o===n&&(o=null),u=Rn(),u!==n?(un=s,x=u,s=void(r._.entity=x)):(on=s,s=n),s!==n){if(o=on,u=t.substr(on,4),u.toLowerCase()===j?on+=4:(u=n,0===hn&&wn(Gt)),u===n&&(u=t.substr(on,3),u.toLowerCase()===F?on+=3:(u=n,0===hn&&wn(Qt))),u!==n)if(l=Xn(),l!==n){if(i=on,c=Hn(),c!==n&&(un=i,c=function(t,e){t._.with=e}(r,c)),i=c,i===n)if(i=on,un=on,c=function(t){t._.with={}}(r),c=c?n:void 0,c!==n){for(a=on,h=[],p=on,d=Tn(),d!==n?(g=Kn(),61===t.charCodeAt(on)?(b=I,on++):(b=n,0===hn&&wn(Vt)),b!==n?(C=Kn(),w=Pn(),w!==n?(un=p,p=nn(r,d,w)):(on=p,p=n)):(on=p,p=n)):(on=p,p=n);p!==n;)h.push(p),p=on,d=Vn(),d!==n?(d=on,g=Tn(),g!==n?(b=Kn(),61===t.charCodeAt(on)?(C=I,on++):(C=n,0===hn&&wn(Vt)),C!==n?(w=Kn(),A=Pn(),A!==n?(un=d,d=nn(r,g,A)):(on=d,d=n)):(on=d,d=n)):(on=d,d=n),d===n?(on=p,p=n):p=d):p=d;h.length<1?(on=a,a=n):a=h,a!==n?(h=Kn(),c=[c,a,h],i=c):(on=i,i=n)}else on=i,i=n;i!==n?(u=[u,l,i],o=u):(on=o,o=n)}else on=o,o=n;else on=o,o=n;o===n&&(o=null),u=on,l=on,i=t.substr(on,5),i.toLowerCase()===f?on+=5:(i=n,0===hn&&wn(St)),i!==n?(c=Xn(),c!==n?(i=[i,c],l=i):(on=l,l=n)):(on=l,l=n),l!==n?(i=_n(),i!==n?(c=Kn(),un=u,u=function(t,e){t._.where=e}(r,i)):(on=u,u=n)):(on=u,u=n),u===n&&(u=null),e=r}else on=e,e=n;else on=e,e=n;var x;return e}(),r===n&&(r=function(){let e,r,s,o,u,l,i;e=on,r=on,s=t.substr(on,6),s.toLowerCase()===D?on+=6:(s=n,0===hn&&wn(Jt));s!==n?(o=Xn(),o!==n?(un=r,r=new ql.DELETE):(on=r,r=n)):(on=r,r=n);r!==n?(s=on,o=on,u=t.substr(on,4),u.toLowerCase()===a?on+=4:(u=n,0===hn&&wn(yt)),u!==n?(l=Xn(),l!==n?(u=[u,l],o=u):(on=o,o=n)):(on=o,o=n),o===n&&(o=null),u=Rn(),u!==n?(l=Kn(),un=s,c=u,s=void(r._.from=c)):(on=s,s=n),s!==n?(o=on,u=on,l=t.substr(on,5),l.toLowerCase()===f?on+=5:(l=n,0===hn&&wn(St)),l!==n?(i=Xn(),i!==n?(l=[l,i],u=l):(on=u,u=n)):(on=u,u=n),u!==n?(l=_n(),l!==n?(i=Kn(),un=o,o=function(t,e){t._.where=e}(r,l)):(on=o,o=n)):(on=o,o=n),o===n&&(o=null),e=r):(on=e,e=n)):(on=e,e=n);var c;return e}()))),r!==n&&(un=e,r=Je(r)),e=r,e}function mn(){let e,r,s,o,f,h,p,d,g,b,C;return e=on,r=on,s=t.substr(on,6),s.toLowerCase()===u?on+=6:(s=n,0===hn&&wn(mt)),s!==n?(o=Xn(),o!==n?(un=r,r=new ql.SELECT):(on=r,r=n)):(on=r,r=n),r!==n?(s=on,o=t.substr(on,9),o.toLowerCase()===l?on+=9:(o=n,0===hn&&wn(Et)),o!==n?(f=Xn(),f!==n?(h=Kn(),un=s,s=void(r._.localized=!0)):(on=s,s=n)):(on=s,s=n),s===n&&(s=null),o=on,f=t.substr(on,8),f.toLowerCase()===i?on+=8:(f=n,0===hn&&wn(Lt)),f!==n?(h=Xn(),h!==n?(p=Kn(),un=o,o=function(t){t._.distinct=!0}(r)):(on=o,o=n)):(on=o,o=n),o===n&&(o=null),f=on,h=t.substr(on,3),h.toLowerCase()===c?on+=3:(h=n,0===hn&&wn(vt)),h!==n?(p=Xn(),p!==n?(d=Kn(),un=f,f=function(t){t._.one=!0}(r)):(on=f,f=n)):(on=f,f=n),f===n&&(f=null),h=on,p=vn(),p!==n?(d=Kn(),un=h,h=function(t,e){t._.columns=e}(r,p)):(on=h,h=n),h===n&&(h=null),p=on,d=on,g=t.substr(on,4),g.toLowerCase()===a?on+=4:(g=n,0===hn&&wn(yt)),g!==n?(b=Xn(),b!==n?(g=[g,b],d=g):(on=d,d=n)):(on=d,d=n),d!==n?(g=Rn(),g===n&&(g=Zn()),g!==n?(un=p,p=function(t,e){t._.from=e}(r,g)):(on=p,p=n)):(on=p,p=n),p===n&&(p=null),d=on,g=Wn(),g!==n?(b=vn(),b!==n?(C=Yn(),C!==n?(un=d,d=function(t,e){t._.columns=e}(r,b)):(on=d,d=n)):(on=d,d=n)):(on=d,d=n),d===n&&(d=null),g=on,b=En(),b!==n&&(un=g,b=function(t,e){Object.assign(t._,e)}(r,b)),g=b,g===n&&(g=null),e=r):(on=e,e=n),e}function En(){let e,r,s,o,u,l,i,c,a,C,w,A;var x;return e=on,r=on,s=on,hn++,t.length>on?(o=t.charAt(on),on++):(o=n,0===hn&&wn(_t)),hn--,o!==n?(on=s,s=void 0):s=n,s!==n&&(un=r,s={}),r=s,r!==n?(s=on,o=on,u=t.substr(on,5),u.toLowerCase()===f?on+=5:(u=n,0===hn&&wn(St)),u!==n?(l=Xn(),l!==n?(u=[u,l],o=u):(on=o,o=n)):(on=o,o=n),o!==n?(u=_n(),u!==n?(l=Kn(),un=s,x=u,s=void(r.where=x)):(on=s,s=n)):(on=s,s=n),s===n&&(s=null),o=on,u=on,l=t.substr(on,8),l.toLowerCase()===h?on+=8:(l=n,0===hn&&wn($t)),l!==n?(i=Xn(),i!==n?(c=Sn(),c!==n?(a=Kn(),un=u,u=function(t,e){t.groupBy=e}(r,c)):(on=u,u=n)):(on=u,u=n)):(on=u,u=n),u!==n?(l=on,i=t.substr(on,6),i.toLowerCase()===p?on+=6:(i=n,0===hn&&wn(Ot)),i!==n?(c=Xn(),c!==n?(a=_n(),a!==n?(C=Kn(),un=l,l=function(t,e){t.having=e}(r,a)):(on=l,l=n)):(on=l,l=n)):(on=l,l=n),l===n&&(l=null),u=[u,l],o=u):(on=o,o=n),o===n&&(o=null),u=on,l=on,i=t.substr(on,8),i.toLowerCase()===d?on+=8:(i=n,0===hn&&wn(Tt)),i!==n?(c=Xn(),c!==n?(i=[i,c],l=i):(on=l,l=n)):(on=l,l=n),l!==n?(i=$n(),i!==n?(c=Kn(),un=u,u=function(t,e){t.orderBy=e}(r,i)):(on=u,u=n)):(on=u,u=n),u===n&&(u=null),l=on,i=on,c=t.substr(on,5),c.toLowerCase()===g?on+=5:(c=n,0===hn&&wn(Rt)),c!==n?(a=Xn(),a!==n?(C=Fn(),C===n&&(C=In()),C!==n?(w=Kn(),un=i,i=function(t,e){t.limit={rows:e}}(r,C)):(on=i,i=n)):(on=i,i=n)):(on=i,i=n),i!==n?(c=on,a=t.substr(on,6),a.toLowerCase()===b?on+=6:(a=n,0===hn&&wn(Pt)),a!==n?(C=Xn(),C!==n?(w=Fn(),w===n&&(w=In()),w!==n?(A=Kn(),un=c,c=function(t,e){t.limit.offset=e}(r,w)):(on=c,c=n)):(on=c,c=n)):(on=c,c=n),c===n&&(c=null),i=[i,c],l=i):(on=l,l=n),l===n&&(l=null),e=r):(on=e,e=n),e}function Ln(){let e,r,s,o,u;return e=on,r=on,s=Kn(),r=t.substring(r,on),s=t.substr(on,2),s.toLowerCase()===C?on+=2:(s=n,0===hn&&wn(jt)),s!==n?(o=Xn(),o!==n?(u=On(),u!==n?e=u:(on=e,e=n)):(on=e,e=n)):(on=e,e=n),e}function vn(){let e,r,s,o,u,l,i,c,a,f,h;for(e=on,r=[],42===t.charCodeAt(on)?(s=w,on++):(s=n,0===hn&&wn(Ft)),s===n&&(s=on,o=Fn(),o!==n?(u=on,l=Ln(),l!==n&&(un=u,l=Ke(o,l)),u=l,u===n&&(u=null),l=Jn(),l===n&&(l=null),i=on,c=Wn(),c!==n?(a=vn(),a!==n?(f=Yn(),f!==n?(un=i,i=Xe(o,l,a)):(on=i,i=n)):(on=i,i=n)):(on=i,i=n),i!==n?s=o:(on=s,s=n)):(on=s,s=n),s===n&&(s=on,o=Pn(),o!==n?(u=on,l=Ln(),l!==n&&(un=u,l=tn(o,l)),u=l,u===n&&(u=null),s=o):(on=s,s=n)));s!==n;)r.push(s),s=on,o=Vn(),o!==n?(42===t.charCodeAt(on)?(o=w,on++):(o=n,0===hn&&wn(Ft)),o===n&&(o=on,u=Fn(),u!==n?(l=on,i=Ln(),i!==n&&(un=l,i=Ke(u,i)),l=i,l===n&&(l=null),i=Jn(),i===n&&(i=null),c=on,a=Wn(),a!==n?(f=vn(),f!==n?(h=Yn(),h!==n?(un=c,c=Xe(u,i,f)):(on=c,c=n)):(on=c,c=n)):(on=c,c=n),c!==n?o=u:(on=o,o=n)):(on=o,o=n),o===n&&(o=on,u=Pn(),u!==n?(l=on,i=Ln(),i!==n&&(un=l,i=tn(u,i)),l=i,l===n&&(l=null),o=u):(on=o,o=n))),o===n?(on=s,s=n):s=o):s=o;return r.length<1?(on=e,e=n):e=r,e}function yn(){let e,r,s,o,u,l,i,c;return e=on,r=Kn(),91===t.charCodeAt(on)?(s=A,on++):(s=n,0===hn&&wn(It)),s!==n?(o=Kn(),u=function(){let e,r,s,o,u;e=on,r=Hn(),r!==n&&(un=e,l=r,r={where:tr.where(l)});var l;if(e=r,e===n){for(e=on,r=on,s=[],o=In();o!==n;)s.push(o),o=on,u=Vn(),u!==n?(u=In(),u===n?(on=o,o=n):o=u):o=u;s.length<1?(on=r,r=n):r=s,r!==n&&(un=e,r={where:r}),e=r,e===n&&(e=on,r=on,hn++,s=on,o=t.substr(on,5),o.toLowerCase()===f?on+=5:(o=n,0===hn&&wn(St)),o!==n?(u=Xn(),u!==n?(o=[o,u],s=o):(on=s,s=n)):(on=s,s=n),hn--,s===n?r=void 0:(on=r,r=n),r!==n?(s=jn(),s!==n?(un=e,e={where:s.xpr}):(on=e,e=n)):(on=e,e=n),e===n&&(e=En()))}return e}(),u!==n?(l=Kn(),93===t.charCodeAt(on)?(i=x,on++):(i=n,0===hn&&wn(Dt)),i!==n?(c=Kn(),e=u):(on=e,e=n)):(on=e,e=n)):(on=e,e=n),e}function _n(){let t,e;var r;return t=on,e=Hn(),e!==n&&(un=t,r=e,e=tr.where(r)),t=e,t===n&&(t=on,e=jn(),e!==n&&(un=t,e=e.xpr),t=e),t}function Sn(){let t,e,r,s,o;for(t=on,e=on,r=[],s=Fn();s!==n;)r.push(s),s=on,o=Vn(),o!==n?(o=Fn(),o===n?(on=s,s=n):s=o):s=o;return r.length<1?(on=e,e=n):e=r,e!==n?t=e:(on=t,t=n),t}function $n(){let e,r,s,o,u,l,i,c,a;for(e=on,r=on,s=[],o=on,u=Fn(),u!==n?(l=on,i=Xn(),i!==n?(c=t.substr(on,3),c.toLowerCase()===m?on+=3:(c=n,0===hn&&wn(Nt)),c===n&&(c=t.substr(on,4),c.toLowerCase()===E?on+=4:(c=n,0===hn&&wn(Ut))),c!==n?(un=l,l=en(u,c)):(on=l,l=n)):(on=l,l=n),l===n&&(l=null),o=u):(on=o,o=n);o!==n;)s.push(o),o=on,u=Vn(),u!==n?(u=on,l=Fn(),l!==n?(i=on,c=Xn(),c!==n?(a=t.substr(on,3),a.toLowerCase()===m?on+=3:(a=n,0===hn&&wn(Nt)),a===n&&(a=t.substr(on,4),a.toLowerCase()===E?on+=4:(a=n,0===hn&&wn(Ut))),a!==n?(un=i,i=en(l,a)):(on=i,i=n)):(on=i,i=n),i===n&&(i=null),u=l):(on=u,u=n),u===n?(on=o,o=n):o=u):o=u;return s.length<1?(on=r,r=n):r=s,r!==n?e=r:(on=e,e=n),e}function On(){let e,r,s,o,u,l,i,c,f;if(hn++,e=on,r=on,hn++,s=t.substr(on,2),s.toLowerCase()===C?on+=2:(s=n,0===hn&&wn(Xt)),hn--,s===n?r=void 0:(on=r,r=n),r!==n)if(s=on,hn++,o=t.substr(on,4),o.toLowerCase()===a?on+=4:(o=n,0===hn&&wn(te)),hn--,o===n?s=void 0:(on=s,s=n),s!==n)if(o=on,hn++,u=Mn(),hn--,u===n?o=void 0:(on=o,o=n),o!==n){if(u=on,l=on,i=t.charAt(on),dt.test(i)?on++:(i=n,0===hn&&wn(ee)),i!==n){for(c=[],f=t.charAt(on),gt.test(f)?on++:(f=n,0===hn&&wn(ne));f!==n;)c.push(f),f=t.charAt(on),gt.test(f)?on++:(f=n,0===hn&&wn(ne));i=[i,c],l=i}else on=l,l=n;u=l!==n?t.substring(u,on):l,u!==n?e=u:(on=e,e=n)}else on=e,e=n;else on=e,e=n;else on=e,e=n;return hn--,e===n&&(r=n,0===hn&&wn(Kt)),e}function Tn(){let e,r,s,o,u,l;for(hn++,e=on,r=on,s=on,o=[],u=On();u!==n;)o.push(u),u=on,l=Jn(),l!==n?(l=On(),l===n?(on=u,u=n):u=l):u=l;return o.length<1?(on=s,s=n):s=o,r=s!==n?t.substring(r,on):s,r!==n?e=r:(on=e,e=n),hn--,e===n&&(r=n,0===hn&&wn(re)),e}function Rn(){let e,r,s,o,u,l,i;var c;if(hn++,e=on,r=Hn(),r!==n&&(un=e,c=r,r=tr.subject(c)),e=r,e===n){for(e=on,r=on,s=[],o=on,u=On(),u!==n?(l=Jn(),l!==n?(u=[u,l],o=u):(on=o,o=n)):(on=o,o=n);o!==n;)s.push(o),o=on,u=On(),u!==n?(l=Jn(),l!==n?(u=[u,l],o=u):(on=o,o=n)):(on=o,o=n);r=t.substring(r,on),s=on,o=On(),o!==n?(u=Kn(),58===t.charCodeAt(on)?(l=N,on++):(l=n,0===hn&&wn(oe)),l!==n?(i=Kn(),s=o):(on=s,s=n)):(on=s,s=n),s===n&&(s=null),o=Fn(),o!==n?(u=Kn(),un=e,e=function(t,e,n){if(e)return{ref:[t+e,...n.ref]};if(t){let[e]=n.ref;e.id?e.id=t+e.id:n.ref[0]=t+e}return n}(r,s,o)):(on=e,e=n)}return hn--,e===n&&(r=n,0===hn&&wn(se)),e}function Pn(){let t,e;var r;return t=on,e=jn(),e!==n&&(un=t,e=(r=e).xpr.length>1?r:r.xpr[0]),t=e,t}function jn(){let t,e,r,s,o,u;if(t=on,e=[],r=Zn(),r===n&&(r=Nn(),r===n&&(r=zn(),r===n&&(r=In(),r===n&&(r=qn(),r===n&&(r=Un(),r===n&&(r=Fn(),r===n&&(r=on,s=kn(),s!==n?(o=Pn(),o!==n?(u=Gn(),u!==n?r=o:(on=r,r=n)):(on=r,r=n)):(on=r,r=n)))))))),r!==n)for(;r!==n;)e.push(r),r=Zn(),r===n&&(r=Nn(),r===n&&(r=zn(),r===n&&(r=In(),r===n&&(r=qn(),r===n&&(r=Un(),r===n&&(r=Fn(),r===n&&(r=on,s=kn(),s!==n?(o=Pn(),o!==n?(u=Gn(),u!==n?r=o:(on=r,r=n)):(on=r,r=n)):(on=r,r=n))))))));else e=n;return e!==n&&(un=t,e={xpr:e}),t=e,t}function Fn(){let t,e,r,s,o,u,l;for(hn++,t=on,e=on,r=[],s=on,o=On(),o!==n?(u=yn(),u===n&&(u=null),un=s,s=rn(o,u)):(on=s,s=n);s!==n;)r.push(s),s=on,o=Jn(),o!==n?(o=on,u=On(),u!==n?(l=yn(),l===n&&(l=null),un=o,o=rn(u,l)):(on=o,o=n),o===n?(on=s,s=n):s=o):s=o;return r.length<1?(on=e,e=n):e=r,e!==n&&(un=t,e={ref:e}),t=e,hn--,t===n&&(e=n,0===hn&&wn(ue)),t}function In(){let e,r;return hn++,e=Bn(),e===n&&(e=on,r=function(){let e,r;hn++,e=function(){let e,r,s,o,u,l;e=on,39===t.charCodeAt(on)?(r=ot,on++):(r=n,0===hn&&wn(Ne));if(r!==n){for(s=on,o=[],u=t.charAt(on),wt.test(u)?on++:(u=n,0===hn&&wn(Ue)),u===n&&(u=on,t.substr(on,2)===ut?(l=ut,on+=2):(l=n,0===hn&&wn(ze)),l!==n&&(un=u,l="'"),u=l);u!==n;)o.push(u),u=t.charAt(on),wt.test(u)?on++:(u=n,0===hn&&wn(Ue)),u===n&&(u=on,t.substr(on,2)===ut?(l=ut,on+=2):(l=n,0===hn&&wn(ze)),l!==n&&(un=u,l=sn()),u=l);s=t.substring(s,on),39===t.charCodeAt(on)?(o=ot,on++):(o=n,0===hn&&wn(Ne)),o!==n?e=s:(on=e,e=n)}else on=e,e=n;return e}(),e===n&&(e=function(){let e,r,s,o,u,l,i,c,a,f;e=on,r=on,s=on,45===t.charCodeAt(on)?(o=nt,on++):(o=n,0===hn&&wn(je));o===n&&(o=null);u=[],l=t.charAt(on),Ct.test(l)?on++:(l=n,0===hn&&wn(Fe));if(l!==n)for(;l!==n;)u.push(l),l=t.charAt(on),Ct.test(l)?on++:(l=n,0===hn&&wn(Fe));else u=n;if(u!==n){if(l=on,46===t.charCodeAt(on)?(i=rt,on++):(i=n,0===hn&&wn(Ie)),i!==n){if(c=[],a=t.charAt(on),Ct.test(a)?on++:(a=n,0===hn&&wn(Fe)),a!==n)for(;a!==n;)c.push(a),a=t.charAt(on),Ct.test(a)?on++:(a=n,0===hn&&wn(Fe));else c=n;c!==n?(i=[i,c],l=i):(on=l,l=n)}else on=l,l=n;if(l===n&&(l=null),i=on,101===t.charCodeAt(on)?(c=st,on++):(c=n,0===hn&&wn(De)),c!==n){if(a=[],f=t.charAt(on),Ct.test(f)?on++:(f=n,0===hn&&wn(Fe)),f!==n)for(;f!==n;)a.push(f),f=t.charAt(on),Ct.test(f)?on++:(f=n,0===hn&&wn(Fe));else a=n;a!==n?(c=[c,a],i=c):(on=i,i=n)}else on=i,i=n;i===n&&(i=null),o=[o,u,l,i],s=o}else on=s,s=n;r=s!==n?t.substring(r,on):s;r!==n&&(un=e,r=Number(r));return e=r,e}(),e===n&&(e=function(){let e,r,s,o;e=on,t.substr(on,4)===lt?(r=lt,on+=4):(r=n,0===hn&&wn(Be));r!==n?(s=on,hn++,o=Qn(),hn--,o===n?s=void 0:(on=s,s=n),s!==n?(un=e,e=!0):(on=e,e=n)):(on=e,e=n);return e}(),e===n&&(e=function(){let e,r,s,o;e=on,t.substr(on,5)===it?(r=it,on+=5):(r=n,0===hn&&wn(qe));r!==n?(s=on,hn++,o=Qn(),hn--,o===n?s=void 0:(on=s,s=n),s!==n?(un=e,e=!1):(on=e,e=n)):(on=e,e=n);return e}(),e===n&&(e=function(){let e,r,s,o;e=on,t.substr(on,4)===tt?(r=tt,on+=4):(r=n,0===hn&&wn(Te));r!==n?(s=on,hn++,o=Qn(),hn--,o===n?s=void 0:(on=s,s=n),s!==n?(un=e,e=null):(on=e,e=n)):(on=e,e=n);return e}()))));hn--,e===n&&(r=n,0===hn&&wn(Pe));return e}(),r!==n&&(un=e,r={val:r}),e=r),hn--,e===n&&(r=n,0===hn&&wn(le)),e}function Dn(){let t,e,r,s;for(hn++,t=on,e=[],r=zn(),r===n&&(r=In(),r===n&&(r=Fn(),r===n&&(r=Un())));r!==n;)e.push(r),r=on,s=Vn(),s!==n?(s=zn(),s===n&&(s=In(),s===n&&(s=Fn(),s===n&&(s=Un()))),s===n?(on=r,r=n):r=s):r=s;return e.length<2?(on=t,t=n):t=e,hn--,t===n&&(e=n,0===hn&&wn(le)),t}function Nn(){let t,e,r,s;return hn++,t=Bn(),t===n&&(t=on,e=kn(),e!==n?(r=on,s=Dn(),s!==n&&(un=r,s={list:s}),r=s,r!==n?(s=Gn(),s!==n?t=r:(on=t,t=n)):(on=t,t=n)):(on=t,t=n)),hn--,t===n&&(e=n,0===hn&&wn(ie)),t}function Un(){let e,r,s,o,u,l,i;if(hn++,e=on,r=On(),r!==n)if(s=kn(),s!==n){for(o=on,u=[],42===t.charCodeAt(on)?(l=w,on++):(l=n,0===hn&&wn(Ft)),l===n&&(l=Pn());l!==n;)u.push(l),l=on,i=Vn(),i!==n?(42===t.charCodeAt(on)?(i=w,on++):(i=n,0===hn&&wn(Ft)),i===n&&(i=Pn()),i===n?(on=l,l=n):l=i):l=i;u.length<1?(on=o,o=n):o=u,o!==n?(u=Gn(),u!==n?(un=e,e={func:r,args:o}):(on=e,e=n)):(on=e,e=n)}else on=e,e=n;else on=e,e=n;return hn--,e===n&&(r=n,0===hn&&wn(ce)),e}function zn(){let e,r,s;return hn++,e=on,35===t.charCodeAt(on)?(r=U,on++):(r=n,0===hn&&wn(fe)),r!==n?(s=On(),s!==n?(un=e,e={"#":s}):(on=e,e=n)):(on=e,e=n),hn--,e===n&&(r=n,0===hn&&wn(ae)),e}function Bn(){let e,r,s,o;return hn++,e=on,r=Kn(),63===t.charCodeAt(on)?(s=z,on++):(s=n,0===hn&&wn(pe)),s!==n?(o=Kn(),un=e,e=sr()):(on=e,e=n),hn--,e===n&&(r=n,0===hn&&wn(he)),e}function qn(){let e,r,s,o,u;if(hn++,e=on,r=Kn(),s=Mn(),s===n){if(s=on,o=[],u=t.charAt(on),bt.test(u)?on++:(u=n,0===hn&&wn(ge)),u!==n)for(;u!==n;)o.push(u),u=t.charAt(on),bt.test(u)?on++:(u=n,0===hn&&wn(ge));else o=n;s=o!==n?t.substring(s,on):o}return s!==n?(o=Kn(),e=s):(on=e,e=n),hn--,e===n&&(r=n,0===hn&&wn(de)),e}function Mn(){let e,r,s,o,u,l,i,c;if(e=on,t.substr(on,3)===B?(r=B,on+=3):(r=n,0===hn&&wn(be)),r===n&&(t.substr(on,2)===q?(r=q,on+=2):(r=n,0===hn&&wn(Ce)),r===n&&(t.substr(on,2)===M?(r=M,on+=2):(r=n,0===hn&&wn(we)),r===n&&(t.substr(on,7)===Z?(r=Z,on+=7):(r=n,0===hn&&wn(Ae)),r===n&&(t.substr(on,4)===H?(r=H,on+=4):(r=n,0===hn&&wn(xe)),r===n&&(t.substr(on,6)===W?(r=W,on+=6):(r=n,0===hn&&wn(me)),r===n&&(t.substr(on,8)===Y?(r=Y,on+=8):(r=n,0===hn&&wn(Ee)))))))),r!==n?(s=on,hn++,o=Qn(),hn--,o===n?s=void 0:(on=s,s=n),s!==n?e=r:(on=e,e=n)):(on=e,e=n),e===n&&(e=on,t.substr(on,4)===k?(r=k,on+=4):(r=n,0===hn&&wn(Le)),r===n&&(t.substr(on,4)===G?(r=G,on+=4):(r=n,0===hn&&wn(ve)),r===n&&(t.substr(on,4)===Q?(r=Q,on+=4):(r=n,0===hn&&wn(ye)),r===n&&(t.substr(on,4)===V?(r=V,on+=4):(r=n,0===hn&&wn(_e)),r===n&&(t.substr(on,3)===J?(r=J,on+=3):(r=n,0===hn&&wn(Se)))))),r!==n?(s=on,hn++,o=Qn(),hn--,o===n?s=void 0:(on=s,s=n),s!==n?e=r:(on=e,e=n)):(on=e,e=n),e===n)){for(e=on,r=on,s=[],o=on,t.substr(on,2)===K?(u=K,on+=2):(u=n,0===hn&&wn($e)),u===n&&(t.substr(on,3)===X?(u=X,on+=3):(u=n,0===hn&&wn(Oe)),u===n&&(t.substr(on,4)===tt?(u=tt,on+=4):(u=n,0===hn&&wn(Te)),u===n&&(t.substr(on,5)===et?(u=et,on+=5):(u=n,0===hn&&wn(Re))))),u!==n?(l=on,hn++,i=Qn(),hn--,i===n?l=void 0:(on=l,l=n),l!==n?(u=[u,l],o=u):(on=o,o=n)):(on=o,o=n);o!==n;)s.push(o),o=on,u=Kn(),u=on,t.substr(on,2)===K?(l=K,on+=2):(l=n,0===hn&&wn($e)),l===n&&(t.substr(on,3)===X?(l=X,on+=3):(l=n,0===hn&&wn(Oe)),l===n&&(t.substr(on,4)===tt?(l=tt,on+=4):(l=n,0===hn&&wn(Te)),l===n&&(t.substr(on,5)===et?(l=et,on+=5):(l=n,0===hn&&wn(Re))))),l!==n?(i=on,hn++,c=Qn(),hn--,c===n?i=void 0:(on=i,i=n),i!==n?(l=[l,i],u=l):(on=u,u=n)):(on=u,u=n),u===n?(on=o,o=n):o=u;s.length<1?(on=r,r=n):r=s,e=r!==n?t.substring(e,on):r}return e}function Zn(){let t,e,r,s;return t=on,e=kn(),e!==n?(r=mn(),r!==n?(s=Gn(),s!==n?t=r:(on=t,t=n)):(on=t,t=n)):(on=t,t=n),t}function Hn(){let e,r,s,o;return e=on,r=Kn(),63===t.charCodeAt(on)?(s=z,on++):(s=n,0===hn&&wn(pe)),s!==n?(o=Kn(),un=e,e=nr.shift()):(on=e,e=n),e}function Wn(){let e,r,s,o;return e=on,r=Kn(),123===t.charCodeAt(on)?(s=ct,on++):(s=n,0===hn&&wn(Me)),s!==n?(o=Kn(),r=[r,s,o],e=r):(on=e,e=n),e}function Yn(){let e,r,s,o;return e=on,r=Kn(),125===t.charCodeAt(on)?(s=at,on++):(s=n,0===hn&&wn(Ze)),s!==n?(o=Kn(),r=[r,s,o],e=r):(on=e,e=n),e}function kn(){let e,r,s,o;return e=on,r=Kn(),40===t.charCodeAt(on)?(s=ft,on++):(s=n,0===hn&&wn(He)),s!==n?(o=Kn(),r=[r,s,o],e=r):(on=e,e=n),e}function Gn(){let e,r,s,o;return e=on,r=Kn(),41===t.charCodeAt(on)?(s=ht,on++):(s=n,0===hn&&wn(We)),s!==n?(o=Kn(),r=[r,s,o],e=r):(on=e,e=n),e}function Qn(){let e;return e=t.charAt(on),At.test(e)?on++:(e=n,0===hn&&wn(Ye)),e}function Vn(){let e,r,s,o;return hn++,e=on,r=Kn(),44===t.charCodeAt(on)?(s=pt,on++):(s=n,0===hn&&wn(Ge)),s!==n?(o=Kn(),e=s):(on=e,e=n),hn--,e===n&&(r=n,0===hn&&wn(ke)),e}function Jn(){let e,r,s,o;return hn++,e=on,r=Kn(),46===t.charCodeAt(on)?(s=rt,on++):(s=n,0===hn&&wn(Ie)),s!==n?(o=Kn(),un=e,e="."):(on=e,e=n),hn--,e===n&&(r=n,0===hn&&wn(Qe)),e}function Kn(){let e,r,s;for(hn++,e=on,r=[],s=t.charAt(on),xt.test(s)?on++:(s=n,0===hn&&wn(Ve));s!==n;)r.push(s),s=t.charAt(on),xt.test(s)?on++:(s=n,0===hn&&wn(Ve));return e=t.substring(e,on),hn--,e}function Xn(){let e,r,s;if(hn++,e=on,r=[],s=t.charAt(on),xt.test(s)?on++:(s=n,0===hn&&wn(Ve)),s!==n)for(;s!==n;)r.push(s),s=t.charAt(on),xt.test(s)?on++:(s=n,0===hn&&wn(Ve));else r=n;return e=r!==n?t.substring(e,on):r,hn--,e===n&&(r=n,0===hn&&wn(Qe)),e}const{fluent:tr=ql.fluent,late_binding:er}=peg$parse,{args:nr=[],startRule:rr}=e,sr=!rr&&er?()=>or[ur++]={ref:["?"],param:!0}:()=>or[ur]=tr.expr(nr[ur++]),or=[];let ur=0;cn=o();const lr=cn!==n&&on===t.length;function ir(){throw cn!==n&&on<t.length&&wn({type:"end"}),An(fn,an<t.length?function(e=on){const n=t.codePointAt(e);return void 0===n?"":String.fromCodePoint(n)}(an):null,an<t.length?Cn(an,an+1):Cn(an,an))}return e.peg$library?{peg$result:cn,peg$currPos:on,peg$FAILED:n,peg$maxFailExpected:fn,peg$maxFailPos:an,peg$success:lr,peg$throw:lr?void 0:ir}:lr?cn:void ir()}const peg$allowedStartRules=["CQL","entity","columns","ref","val","vals","expr","where","groupBy","orderBy"];export{peg$allowedStartRules as StartRules,peg$SyntaxError as SyntaxError,peg$parse as parse};
|
|
2
|
-
//# sourceMappingURL=parser.min.js.map
|
|
1
|
+
import*as fluent from"../lib/xl/fluent.js";import{SELECT}from"../lib/ql/select.js";import{INSERT}from"../lib/ql/insert.js";import{UPSERT}from"../lib/ql/insert.js";import{UPDATE}from"../lib/ql/update.js";import{DELETE}from"../lib/ql/delete.js";import{CALL}from"../lib/ql/call-action.js";class peg$SyntaxError extends SyntaxError{constructor(t,e,r,n){super(t),this.expected=e,this.found=r,this.location=n,this.name="SyntaxError"}format(t){let e="Error: "+this.message;if(this.location){let r=null;const n=t.find(t=>t.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));const o=this.location.start,s=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(o):o,u=this.location.source+":"+s.line+":"+s.column;if(r){const t=this.location.end,n="".padEnd(s.line.toString().length," "),l=r[o.line-1],i=(o.line===t.line?t.column:l.length+1)-o.column||1;e+="\n --\x3e "+u+"\n"+n+" |\n"+s.line+" | "+l+"\n"+n+" | "+"".padEnd(o.column-1," ")+"".padEnd(i,"^")}else e+="\n at "+u}return e}static buildMessage(t,e){function r(t){return t.codePointAt(0).toString(16).toUpperCase()}const n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function o(t){return n?t.replace(n,t=>"\\u{"+r(t)+"}"):t}function s(t){return o(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,t=>"\\x0"+r(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+r(t)))}function u(t){return o(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,t=>"\\x0"+r(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+r(t)))}const l={literal:t=>'"'+s(t.text)+'"',class(t){const e=t.parts.map(t=>Array.isArray(t)?u(t[0])+"-"+u(t[1]):u(t));return"["+(t.inverted?"^":"")+e.join("")+"]"+(t.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:t=>t.description};function i(t){return l[t.type](t)}return"Expected "+function(t){const e=t.map(i);if(e.sort(),e.length>0){let t=1;for(let r=1;r<e.length;r++)e[r-1]!==e[r]&&(e[t]=e[r],t++);e.length=t}switch(e.length){case 1:return e[0];case 2:return e[0]+" or "+e[1];default:return e.slice(0,-1).join(", ")+", or "+e[e.length-1]}}(t)+" but "+function(t){return t?'"'+s(t)+'"':"end of input"}(e)+" found."}}function peg$parse(t,e){const r={},n=(e=void 0!==e?e:{}).grammarSource,o={CQL:_r,subject:Mr,columns:Fr,values:Vr,ref:Hr,val:Wr,expr:Zr,changes:Pr,where:jr,groupBy:Or,orderBy:Nr};let s=_r;const u="select",l="stream",i="localized",c="distinct",a="one",f="from",h="where",p="group by",d="having",g="order by",b="limit",C="offset",w="as",A="*",m="[",L="]",E="asc",x="desc",v="insert",y="upsert",S="into",_="entries",T="columns",$="rows",R="values",F="update",I="entity",j="with",O="set",N="=",P="{",U=":",D="}",z="delete",B="call",M="action",Z="function",q="#",H="?",W="and",Y="or",k="in",G="between",Q="like",V="exists",J="contains",K="case",X="when",tt="then",et="else",rt="end",nt="is",ot="not",st="null",ut="empty",lt="-",it=".",ct="e",at="'",ft="''",ht="true",pt="false",dt="(",gt=")",bt=",",Ct=/^[A-Za-z_$]/,wt=/^[A-Za-z0-9_$]/,At=/^[!=><+\-*\/%&|\^~]/,mt=/^[0-9]/,Lt=/^[^']/,Et=/^[A-Za-z_$0-9]/,xt=/^[ \t\n\r]/,vt=mr("SELECT",!0),yt=mr("STREAM",!0),St=mr("LOCALIZED",!0),_t=mr("DISTINCT",!0),Tt=mr("ONE",!0),$t=mr("FROM",!0),Rt={type:"any"},Ft=mr("WHERE",!0),It=mr("GROUP BY",!0),jt=mr("HAVING",!0),Ot=mr("ORDER BY",!0),Nt=mr("LIMIT",!0),Pt=mr("OFFSET",!0),Ut=mr("as",!0),Dt=mr("*",!1),zt=mr("[",!1),Bt=mr("]",!1),Mt=mr("asc",!0),Zt=mr("desc",!0),qt=mr("INSERT",!0),Ht=mr("UPSERT",!0),Wt=mr("INTO",!0),Yt=mr("ENTRIES",!0),kt=mr("COLUMNS",!0),Gt=mr("ROWS",!0),Qt=mr("VALUES",!0),Vt=mr("UPDATE",!0),Jt=mr("ENTITY",!0),Kt=mr("WITH",!0),Xt=mr("SET",!0),te=mr("=",!1),ee=mr("{",!1),re=mr(":",!1),ne=mr("}",!1),oe=mr("DELETE",!0),se=mr("CALL",!0),ue=mr("ACTION",!0),le=mr("FUNCTION",!0),ie=Er("a name"),ce=mr("AS",!0),ae=mr("from",!0),fe=Lr([["A","Z"],["a","z"],"_","$"],!1,!1,!1),he=Lr([["A","Z"],["a","z"],["0","9"],"_","$"],!1,!1,!1),pe=Er("an element ref"),de=Er("an entity ref"),ge=Er("a reference"),be=Er("a value"),Ce=Er("a list"),we=Er("a function"),Ae=Er("a symbol"),me=mr("#",!1),Le=Er("a parameter"),Ee=mr("?",!1),xe=Er("an operator"),ve=Lr(["!","=",">","<","+","-","*","/","%","&","|","^","~"],!1,!1,!1),ye=mr("and",!1),Se=mr("or",!1),_e=mr("in",!1),Te=mr("between",!1),$e=mr("like",!1),Re=mr("exists",!1),Fe=mr("contains",!1),Ie=mr("case",!1),je=mr("when",!1),Oe=mr("then",!1),Ne=mr("else",!1),Pe=mr("end",!1),Ue=mr("is",!1),De=mr("not",!1),ze=mr("null",!1),Be=mr("empty",!1),Me=Er("a literal"),Ze=mr("-",!1),qe=Lr([["0","9"]],!1,!1,!1),He=mr(".",!1),We=mr("e",!1),Ye=mr("'",!1),ke=Lr(["'"],!0,!1,!1),Ge=mr("''",!1),Qe=mr("true",!1),Ve=mr("false",!1),Je=mr("(",!1),Ke=mr(")",!1),Xe=Lr([["A","Z"],["a","z"],"_","$",["0","9"]],!1,!1,!1),tr=Er("a comma"),er=mr(",",!1),rr=Er(""),nr=Lr([" ","\t","\n","\r"],!1,!1,!1);function or(e){return fn?.length&&(e.params=fn),hn?.length&&(e.args=hn),e.source=t.substring(dr,pr),e}function sr(t,e){t.as=e}function ur(t,e,r){e?t.inline=r:t.expand=r}function lr(t,e){t.as=e}function ir(t,e){t.sort=e.toLowerCase()}function cr(t,e,r){t[e]=r}function ar(t,e,r){t[e]=r.val||r}function fr(t,e){return e?{id:t,...e}:t}function hr(){return"'"}let pr=0|e.peg$currPos,dr=pr;const gr=[{line:1,column:1}];let br,Cr=pr,wr=e.peg$maxFailExpected||[],Ar=0|e.peg$silentFails;if(e.startRule){if(!(e.startRule in o))throw new Error("Can't start parsing from rule \""+e.startRule+'".');s=o[e.startRule]}function mr(t,e){return{type:"literal",text:t,ignoreCase:e}}function Lr(t,e,r,n){return{type:"class",parts:t,inverted:e,ignoreCase:r,unicode:n}}function Er(t){return{type:"other",description:t}}function xr(e){let r,n=gr[e];if(n)return n;if(e>=gr.length)r=gr.length-1;else for(r=e;!gr[--r];);for(n=gr[r],n={line:n.line,column:n.column};r<e;)10===t.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return gr[e]=n,n}function vr(t,e,r){const o=xr(t),s=xr(e),u={source:n,start:{offset:t,line:o.line,column:o.column},end:{offset:e,line:s.line,column:s.column}};return r&&n&&"function"==typeof n.offset&&(u.start=n.offset(u.start),u.end=n.offset(u.end)),u}function yr(t){pr<Cr||(pr>Cr&&(Cr=pr,wr=[]),wr.push(t))}function Sr(t,e,r){return new peg$SyntaxError(peg$SyntaxError.buildMessage(t,e),t,e,r)}function _r(){let e,n;return e=pr,n=Tr(),n===r&&(n=function(){let e,n,o,s,u,l,i,c,a,h,p,d,g,b;e=pr,n=pr,o=t.substr(pr,6),o.toLowerCase()===v?pr+=6:(o=r,0===Ar&&yr(qt));o!==r?(s=an(),s!==r?(dr=n,n=new INSERT):(pr=n,n=r)):(pr=n,n=r);n===r&&(n=pr,o=t.substr(pr,6),o.toLowerCase()===y?pr+=6:(o=r,0===Ar&&yr(Ht)),o!==r?(s=an(),s!==r?(dr=n,n=new UPSERT):(pr=n,n=r)):(pr=n,n=r));if(n!==r)if(o=pr,s=tn(),s!==r&&(dr=o,C=s,s=void(n._.entries=Array.isArray(C)?C:[C])),o=s,o===r&&(o=null),s=pr,u=pr,l=t.substr(pr,4),l.toLowerCase()===S?pr+=4:(l=r,0===Ar&&yr(Wt)),l!==r?(i=an(),i!==r?(l=[l,i],u=l):(pr=u,u=r)):(pr=u,u=r),u!==r?(l=Mr(),l!==r?(dr=s,s=function(t,e){t._.into=e}(n,l)):(pr=s,s=r)):(pr=s,s=r),s!==r){if(u=pr,l=t.substr(pr,4),l.toLowerCase()===f?pr+=4:(l=r,0===Ar&&yr($t)),l!==r?(i=an(),i!==r?(c=tn(),c!==r?(dr=u,u=function(t,e){t._.from=e}(n,c)):(pr=u,u=r)):(pr=u,u=r)):(pr=u,u=r),u===r&&(u=pr,l=Tr(),l!==r&&(dr=u,l=function(t,e){t._.from=e}(n,l)),u=l),u===r){if(u=pr,l=pr,i=pr,c=t.substr(pr,7),c.toLowerCase()===_?pr+=7:(c=r,0===Ar&&yr(Yt)),c!==r?(a=an(),a!==r?(c=[c,a],i=c):(pr=i,i=r)):(pr=i,i=r),i===r&&(i=null),c=pr,a=tn(),a===r){for(a=pr,h=[],p=Ur();p!==r;)h.push(p),p=pr,d=un(),d!==r?(d=Ur(),d===r?(pr=p,p=r):p=d):p=d;h.length<1?(pr=a,a=r):a=h}if(a!==r&&(dr=c,a=function(t,e){t._tail(e)}(n,a)),c=a,c!==r?(i=[i,c],l=i):(pr=l,l=r),l===r&&(l=null),i=pr,c=pr,a=t.substr(pr,7),a.toLowerCase()===T?pr+=7:(a=r,0===Ar&&yr(kt)),a!==r?(h=an(),h!==r?(a=[a,h],c=a):(pr=c,c=r)):(pr=c,c=r),c===r&&(c=null),a=tn(),a===r)if(a=pr,h=nn(),h!==r){for(p=pr,d=[],g=Br();g!==r;)d.push(g),g=pr,b=un(),b!==r?(b=Br(),b===r?(pr=g,g=r):g=b):g=b;d.length<1?(pr=p,p=r):p=d,p!==r?(d=on(),d!==r?a=p:(pr=a,a=r)):(pr=a,a=r)}else pr=a,a=r;a!==r?(dr=i,i=function(t,e){t._.columns=e}(n,a)):(pr=i,i=r),i===r&&(i=null),c=pr,a=pr,h=t.substr(pr,4),h.toLowerCase()===$?pr+=4:(h=r,0===Ar&&yr(Gt)),h!==r?(p=an(),p!==r?(h=[h,p],a=h):(pr=a,a=r)):(pr=a,a=r),a===r&&(a=null),h=tn(),h!==r?(dr=c,c=function(t,e){t._.rows=e}(n,h)):(pr=c,c=r),c===r&&(c=null),a=pr,h=pr,p=t.substr(pr,6),p.toLowerCase()===R?pr+=6:(p=r,0===Ar&&yr(Qt)),p!==r?(d=an(),d!==r?(p=[p,d],h=p):(pr=h,h=r)):(pr=h,h=r),h!==r?(p=Yr(),p!==r?(dr=a,a=function(t,e){t._.values=e.list}(n,p)):(pr=a,a=r)):(pr=a,a=r),a===r&&(a=null),l=[l,i,c,a],u=l}u!==r?e=n:(pr=e,e=r)}else pr=e,e=r;else pr=e,e=r;var C;return e}(),n===r&&(n=function(){let e,n,o,s,u,l,i,c,a;e=pr,n=pr,o=t.substr(pr,6),o.toLowerCase()===F?pr+=6:(o=r,0===Ar&&yr(Vt));o!==r?(s=an(),s!==r?(dr=n,n=new UPDATE):(pr=n,n=r)):(pr=n,n=r);n!==r?(o=pr,s=pr,u=t.substr(pr,6),u.toLowerCase()===I?pr+=6:(u=r,0===Ar&&yr(Jt)),u!==r?(l=an(),l!==r?(u=[u,l],s=u):(pr=s,s=r)):(pr=s,s=r),s===r&&(s=null),u=Mr(),u!==r?(dr=o,f=u,o=void(n._.entity=f)):(pr=o,o=r),o!==r?(s=pr,u=pr,l=t.substr(pr,4),l.toLowerCase()===j?pr+=4:(l=r,0===Ar&&yr(Kt)),l!==r?(i=an(),i!==r?(l=[l,i],u=l):(pr=u,u=r)):(pr=u,u=r),u!==r?(l=tn(),l===r&&(l=Ur()),l!==r?(dr=s,s=function(t,e){t._.data=e}(n,l)):(pr=s,s=r)):(pr=s,s=r),s===r&&(s=null),u=pr,l=pr,i=t.substr(pr,3),i.toLowerCase()===O?pr+=3:(i=r,0===Ar&&yr(Xt)),i!==r?(c=an(),c!==r?(i=[i,c],l=i):(pr=l,l=r)):(pr=l,l=r),l!==r?(i=Pr(),i!==r?(dr=u,u=function(t,e){t._.with=e}(n,i)):(pr=u,u=r)):(pr=u,u=r),u===r&&(u=null),l=pr,i=pr,c=t.substr(pr,5),c.toLowerCase()===h?pr+=5:(c=r,0===Ar&&yr(Ft)),c!==r?(a=an(),a!==r?(c=[c,a],i=c):(pr=i,i=r)):(pr=i,i=r),i!==r?(c=jr(),c!==r?(a=cn(),dr=l,l=function(t,e){t._.where=e}(n,c)):(pr=l,l=r)):(pr=l,l=r),l===r&&(l=null),e=n):(pr=e,e=r)):(pr=e,e=r);var f;return e}(),n===r&&(n=function(){let e,n,o,s,u,l,i;e=pr,n=pr,o=t.substr(pr,6),o.toLowerCase()===z?pr+=6:(o=r,0===Ar&&yr(oe));o!==r?(s=an(),s!==r?(dr=n,n=new DELETE):(pr=n,n=r)):(pr=n,n=r);n!==r?(o=pr,s=pr,u=t.substr(pr,4),u.toLowerCase()===f?pr+=4:(u=r,0===Ar&&yr($t)),u!==r?(l=an(),l!==r?(u=[u,l],s=u):(pr=s,s=r)):(pr=s,s=r),s===r&&(s=null),u=Mr(),u!==r?(l=cn(),dr=o,c=u,o=void(n._.from=c)):(pr=o,o=r),o!==r?(s=pr,u=pr,l=t.substr(pr,5),l.toLowerCase()===h?pr+=5:(l=r,0===Ar&&yr(Ft)),l!==r?(i=an(),i!==r?(l=[l,i],u=l):(pr=u,u=r)):(pr=u,u=r),u!==r?(l=jr(),l!==r?(i=cn(),dr=s,s=function(t,e){t._.where=e}(n,l)):(pr=s,s=r)):(pr=s,s=r),s===r&&(s=null),e=n):(pr=e,e=r)):(pr=e,e=r);var c;return e}(),n===r&&(n=function(){let e,n,o,s,u,l,i;e=pr,n=pr,o=t.substr(pr,4),o.toLowerCase()===B?pr+=4:(o=r,0===Ar&&yr(se));o!==r?(s=an(),s!==r?(dr=n,n=new CALL):(pr=n,n=r)):(pr=n,n=r);n!==r?(o=pr,s=pr,u=t.substr(pr,6),u.toLowerCase()===M?pr+=6:(u=r,0===Ar&&yr(ue)),u===r&&(u=t.substr(pr,8),u.toLowerCase()===Z?pr+=8:(u=r,0===Ar&&yr(le))),u!==r?(l=an(),l!==r?(u=[u,l],s=u):(pr=s,s=r)):(pr=s,s=r),s===r&&(s=null),u=zr(),u!==r?(l=cn(),dr=o,c=u,o=void(n._.action=c)):(pr=o,o=r),o!==r?(s=pr,u=pr,l=t.substr(pr,4),l.toLowerCase()===j?pr+=4:(l=r,0===Ar&&yr(Kt)),l!==r?(i=an(),i!==r?(l=[l,i],u=l):(pr=u,u=r)):(pr=u,u=r),u===r&&(u=null),l=Ur(),l!==r?(i=cn(),dr=s,s=function(t,e){Object.assign(t._,{with:e})}(n,l)):(pr=s,s=r),s!==r?e=n:(pr=e,e=r)):(pr=e,e=r)):(pr=e,e=r);var c;return e}())))),n!==r&&(dr=e,n=or(n)),e=n,e}function Tr(){let e,n,o,s,h,p,d,g,b,C,w,A;return e=pr,n=pr,o=t.substr(pr,6),o.toLowerCase()===u?pr+=6:(o=r,0===Ar&&yr(vt)),o!==r?(s=an(),s!==r?(dr=n,n=new SELECT):(pr=n,n=r)):(pr=n,n=r),n===r&&(n=pr,o=t.substr(pr,6),o.toLowerCase()===l?pr+=6:(o=r,0===Ar&&yr(yt)),o!==r?(s=an(),s!==r?(dr=n,n=function(){let t=new SELECT;return t._.stream=!0,t}()):(pr=n,n=r)):(pr=n,n=r)),n!==r?(o=pr,s=t.substr(pr,9),s.toLowerCase()===i?pr+=9:(s=r,0===Ar&&yr(St)),s!==r?(h=an(),h!==r?(dr=o,o=void(n._.localized=!0)):(pr=o,o=r)):(pr=o,o=r),o===r&&(o=null),s=pr,h=t.substr(pr,8),h.toLowerCase()===c?pr+=8:(h=r,0===Ar&&yr(_t)),h!==r?(p=an(),p!==r?(dr=s,s=function(t){t._.distinct=!0}(n)):(pr=s,s=r)):(pr=s,s=r),s===r&&(s=null),h=pr,p=t.substr(pr,6),p.toLowerCase()===l?pr+=6:(p=r,0===Ar&&yr(yt)),p!==r?(d=an(),d!==r?(dr=h,h=function(t){t._.stream=!0}(n)):(pr=h,h=r)):(pr=h,h=r),h===r&&(h=null),p=pr,d=t.substr(pr,3),d.toLowerCase()===a?pr+=3:(d=r,0===Ar&&yr(Tt)),d!==r?(g=an(),g!==r?(dr=p,p=function(t){t._.one=!0}(n)):(pr=p,p=r)):(pr=p,p=r),p===r&&(p=null),d=pr,g=Fr(),g!==r?(b=cn(),dr=d,d=function(t,e){t._.columns=e}(n,g)):(pr=d,d=r),d===r&&(d=null),g=pr,b=pr,C=t.substr(pr,4),C.toLowerCase()===f?pr+=4:(C=r,0===Ar&&yr($t)),C!==r?(w=an(),w!==r?(C=[C,w],b=C):(pr=b,b=r)):(pr=b,b=r),b!==r?(C=Mr(),C===r&&(C=Xr()),C!==r?(dr=g,g=function(t,e){t._.from=e}(n,C)):(pr=g,g=r)):(pr=g,g=r),g===r&&(g=null),b=pr,C=en(),C!==r?(w=Fr(),w!==r?(A=rn(),A!==r?(dr=b,b=function(t,e){t._.columns=e}(n,w)):(pr=b,b=r)):(pr=b,b=r)):(pr=b,b=r),b===r&&(b=null),C=pr,w=$r(),w!==r&&(dr=C,w=function(t,e){Object.assign(t._,e)}(n,w)),C=w,C===r&&(C=null),e=n):(pr=e,e=r),e}function $r(){let e,n,o,s,u,l,i,c,a,f,w,A;var m;return e=pr,n=pr,o=pr,Ar++,t.length>pr?(s=t.charAt(pr),pr++):(s=r,0===Ar&&yr(Rt)),Ar--,s!==r?(pr=o,o=void 0):o=r,o!==r&&(dr=n,o={}),n=o,n!==r?(o=pr,s=pr,u=t.substr(pr,5),u.toLowerCase()===h?pr+=5:(u=r,0===Ar&&yr(Ft)),u!==r?(l=an(),l!==r?(u=[u,l],s=u):(pr=s,s=r)):(pr=s,s=r),s!==r?(u=jr(),u!==r?(l=cn(),dr=o,m=u,o=void(n.where=m)):(pr=o,o=r)):(pr=o,o=r),o===r&&(o=null),s=pr,u=pr,l=t.substr(pr,8),l.toLowerCase()===p?pr+=8:(l=r,0===Ar&&yr(It)),l!==r?(i=an(),i!==r?(c=Or(),c!==r?(a=cn(),dr=u,u=function(t,e){t.groupBy=e}(n,c)):(pr=u,u=r)):(pr=u,u=r)):(pr=u,u=r),u!==r?(l=pr,i=t.substr(pr,6),i.toLowerCase()===d?pr+=6:(i=r,0===Ar&&yr(jt)),i!==r?(c=an(),c!==r?(a=jr(),a!==r?(f=cn(),dr=l,l=function(t,e){t.having=e}(n,a)):(pr=l,l=r)):(pr=l,l=r)):(pr=l,l=r),l===r&&(l=null),u=[u,l],s=u):(pr=s,s=r),s===r&&(s=null),u=pr,l=pr,i=t.substr(pr,8),i.toLowerCase()===g?pr+=8:(i=r,0===Ar&&yr(Ot)),i!==r?(c=an(),c!==r?(i=[i,c],l=i):(pr=l,l=r)):(pr=l,l=r),l!==r?(i=Nr(),i!==r?(c=cn(),dr=u,u=function(t,e){t.orderBy=e}(n,i)):(pr=u,u=r)):(pr=u,u=r),u===r&&(u=null),l=pr,i=pr,c=t.substr(pr,5),c.toLowerCase()===b?pr+=5:(c=r,0===Ar&&yr(Nt)),c!==r?(a=an(),a!==r?(f=Hr(),f===r&&(f=Wr()),f!==r?(w=cn(),dr=i,i=function(t,e){t.limit={rows:e}}(n,f)):(pr=i,i=r)):(pr=i,i=r)):(pr=i,i=r),i!==r?(c=pr,a=t.substr(pr,6),a.toLowerCase()===C?pr+=6:(a=r,0===Ar&&yr(Pt)),a!==r?(f=an(),f!==r?(w=Hr(),w===r&&(w=Wr()),w!==r?(A=cn(),dr=c,c=function(t,e){t.limit.offset=e}(n,w)):(pr=c,c=r)):(pr=c,c=r)):(pr=c,c=r),c===r&&(c=null),i=[i,c],l=i):(pr=l,l=r),l===r&&(l=null),e=n):(pr=e,e=r),e}function Rr(){let e,n,o,s,u;return e=pr,n=pr,o=cn(),n=t.substring(n,pr),o=t.substr(pr,2),o.toLowerCase()===w?pr+=2:(o=r,0===Ar&&yr(Ut)),o!==r?(s=an(),s!==r?(u=zr(),u!==r?e=u:(pr=e,e=r)):(pr=e,e=r)):(pr=e,e=r),e}function Fr(){let e,n,o,s,u,l,i,c,a,f,h;for(e=pr,n=[],42===t.charCodeAt(pr)?(o=A,pr++):(o=r,0===Ar&&yr(Dt)),o===r&&(o=pr,s=Hr(),s!==r?(u=pr,l=Rr(),l!==r&&(dr=u,l=sr(s,l)),u=l,u===r&&(u=null),l=ln(),l===r&&(l=null),i=pr,c=en(),c!==r?(a=Fr(),a!==r?(f=rn(),f!==r?(dr=i,i=ur(s,l,a)):(pr=i,i=r)):(pr=i,i=r)):(pr=i,i=r),i!==r?o=s:(pr=o,o=r)):(pr=o,o=r),o===r&&(o=pr,s=Zr(),s!==r?(u=pr,l=Rr(),l!==r&&(dr=u,l=lr(s,l)),u=l,u===r&&(u=null),o=s):(pr=o,o=r)));o!==r;)n.push(o),o=pr,s=un(),s!==r?(42===t.charCodeAt(pr)?(s=A,pr++):(s=r,0===Ar&&yr(Dt)),s===r&&(s=pr,u=Hr(),u!==r?(l=pr,i=Rr(),i!==r&&(dr=l,i=sr(u,i)),l=i,l===r&&(l=null),i=ln(),i===r&&(i=null),c=pr,a=en(),a!==r?(f=Fr(),f!==r?(h=rn(),h!==r?(dr=c,c=ur(u,i,f)):(pr=c,c=r)):(pr=c,c=r)):(pr=c,c=r),c!==r?s=u:(pr=s,s=r)):(pr=s,s=r),s===r&&(s=pr,u=Zr(),u!==r?(l=pr,i=Rr(),i!==r&&(dr=l,i=lr(u,i)),l=i,l===r&&(l=null),s=u):(pr=s,s=r))),s===r?(pr=o,o=r):o=s):o=s;return n.length<1?(pr=e,e=r):e=n,e}function Ir(){let e,n,o,s,u,l,i,c;return e=pr,n=cn(),91===t.charCodeAt(pr)?(o=m,pr++):(o=r,0===Ar&&yr(zt)),o!==r?(s=cn(),u=function(){let e,n,o,s,u;e=pr,n=tn(),n!==r&&(dr=e,l=n,n={where:fluent.where(l)});var l;if(e=n,e===r){for(e=pr,n=pr,o=[],s=Wr();s!==r;)o.push(s),s=pr,u=un(),u!==r?(u=Wr(),u===r?(pr=s,s=r):s=u):s=u;o.length<1?(pr=n,n=r):n=o,n!==r&&(dr=e,n={where:n}),e=n,e===r&&(e=pr,n=pr,Ar++,o=pr,s=t.substr(pr,5),s.toLowerCase()===h?pr+=5:(s=r,0===Ar&&yr(Ft)),s!==r?(u=an(),u!==r?(s=[s,u],o=s):(pr=o,o=r)):(pr=o,o=r),Ar--,o===r?n=void 0:(pr=n,n=r),n!==r?(o=qr(),o!==r?(dr=e,e={where:o.xpr}):(pr=e,e=r)):(pr=e,e=r),e===r&&(e=$r()))}return e}(),u!==r?(l=cn(),93===t.charCodeAt(pr)?(i=L,pr++):(i=r,0===Ar&&yr(Bt)),i!==r?(c=cn(),e=u):(pr=e,e=r)):(pr=e,e=r)):(pr=e,e=r),e}function jr(){let t,e;var n;return t=pr,e=tn(),e!==r&&(dr=t,n=e,e=fluent.where(n)),t=e,t===r&&(t=pr,e=qr(),e!==r&&(dr=t,e=e.xpr),t=e),t}function Or(){let t,e,n,o,s;for(t=pr,e=pr,n=[],o=Hr();o!==r;)n.push(o),o=pr,s=un(),s!==r?(s=Hr(),s===r?(pr=o,o=r):o=s):o=s;return n.length<1?(pr=e,e=r):e=n,e!==r?t=e:(pr=t,t=r),t}function Nr(){let e,n,o,s,u,l,i,c,a;for(e=pr,n=pr,o=[],s=pr,u=Hr(),u!==r?(l=pr,i=an(),i!==r?(c=t.substr(pr,3),c.toLowerCase()===E?pr+=3:(c=r,0===Ar&&yr(Mt)),c===r&&(c=t.substr(pr,4),c.toLowerCase()===x?pr+=4:(c=r,0===Ar&&yr(Zt))),c!==r?(dr=l,l=ir(u,c)):(pr=l,l=r)):(pr=l,l=r),l===r&&(l=null),s=u):(pr=s,s=r);s!==r;)o.push(s),s=pr,u=un(),u!==r?(u=pr,l=Hr(),l!==r?(i=pr,c=an(),c!==r?(a=t.substr(pr,3),a.toLowerCase()===E?pr+=3:(a=r,0===Ar&&yr(Mt)),a===r&&(a=t.substr(pr,4),a.toLowerCase()===x?pr+=4:(a=r,0===Ar&&yr(Zt))),a!==r?(dr=i,i=ir(l,a)):(pr=i,i=r)):(pr=i,i=r),i===r&&(i=null),u=l):(pr=u,u=r),u===r?(pr=s,s=r):s=u):s=u;return o.length<1?(pr=n,n=r):n=o,n!==r?e=n:(pr=e,e=r),e}function Pr(){let e,n,o,s,u,l,i,c,a,f,h;for(e=pr,n=pr,o="",dr=n,o={},n=o,o=pr,s=[],u=pr,l=Br(),l!==r?(i=cn(),61===t.charCodeAt(pr)?(c=N,pr++):(c=r,0===Ar&&yr(te)),c!==r?(a=cn(),f=Qr(),f===r&&(f=Zr()),f!==r?(dr=u,u=cr(n,l,f)):(pr=u,u=r)):(pr=u,u=r)):(pr=u,u=r);u!==r;)s.push(u),u=pr,l=un(),l!==r?(l=pr,i=Br(),i!==r?(c=cn(),61===t.charCodeAt(pr)?(a=N,pr++):(a=r,0===Ar&&yr(te)),a!==r?(f=cn(),h=Qr(),h===r&&(h=Zr()),h!==r?(dr=l,l=cr(n,i,h)):(pr=l,l=r)):(pr=l,l=r)):(pr=l,l=r),l===r?(pr=u,u=r):u=l):u=l;return s.length<1?(pr=o,o=r):o=s,o!==r?(s=cn(),e=n):(pr=e,e=r),e}function Ur(){let e,n,o,s,u,l,i,c,a,f,h;if(e=pr,n=pr,o=cn(),123===t.charCodeAt(pr)?(s=P,pr++):(s=r,0===Ar&&yr(ee)),s!==r?(u=cn(),dr=n,n={}):(pr=n,n=r),n!==r){for(o=pr,s=[],u=pr,l=Br(),l!==r?(i=cn(),58===t.charCodeAt(pr)?(c=U,pr++):(c=r,0===Ar&&yr(re)),c!==r?(a=cn(),f=Wr(),f===r&&(f=Ur(),f===r&&(f=Dr())),f!==r?(dr=u,u=ar(n,l,f)):(pr=u,u=r)):(pr=u,u=r)):(pr=u,u=r);u!==r;)s.push(u),u=pr,l=un(),l!==r?(l=pr,i=Br(),i!==r?(c=cn(),58===t.charCodeAt(pr)?(a=U,pr++):(a=r,0===Ar&&yr(re)),a!==r?(f=cn(),h=Wr(),h===r&&(h=Ur(),h===r&&(h=Dr())),h!==r?(dr=l,l=ar(n,i,h)):(pr=l,l=r)):(pr=l,l=r)):(pr=l,l=r),l===r?(pr=u,u=r):u=l):u=l;s.length<1?(pr=o,o=r):o=s,o!==r?(s=cn(),125===t.charCodeAt(pr)?(u=D,pr++):(u=r,0===Ar&&yr(ne)),u!==r?(l=cn(),e=n):(pr=e,e=r)):(pr=e,e=r)}else pr=e,e=r;return e}function Dr(){let e,n,o,s,u,l,i,c;if(e=pr,n=cn(),91===t.charCodeAt(pr)?(o=m,pr++):(o=r,0===Ar&&yr(zt)),o!==r){for(s=cn(),u=pr,l=[],i=Ur();i!==r;)l.push(i),i=pr,c=un(),c!==r?(c=Ur(),c===r?(pr=i,i=r):i=c):i=c;l.length<1?(pr=u,u=r):u=l,u!==r?(l=cn(),93===t.charCodeAt(pr)?(i=L,pr++):(i=r,0===Ar&&yr(Bt)),i!==r?(c=cn(),e=u):(pr=e,e=r)):(pr=e,e=r)}else pr=e,e=r;return e}function zr(){let e,n,o,s,u,l,i,c,a;if(Ar++,e=pr,n=pr,Ar++,o=t.substr(pr,2),o.toLowerCase()===w?pr+=2:(o=r,0===Ar&&yr(ce)),Ar--,o===r?n=void 0:(pr=n,n=r),n!==r)if(o=pr,Ar++,s=t.substr(pr,4),s.toLowerCase()===f?pr+=4:(s=r,0===Ar&&yr(ae)),Ar--,s===r?o=void 0:(pr=o,o=r),o!==r)if(s=pr,Ar++,u=Kr(),Ar--,u===r?s=void 0:(pr=s,s=r),s!==r){if(u=pr,l=pr,i=t.charAt(pr),Ct.test(i)?pr++:(i=r,0===Ar&&yr(fe)),i!==r){for(c=[],a=t.charAt(pr),wt.test(a)?pr++:(a=r,0===Ar&&yr(he));a!==r;)c.push(a),a=t.charAt(pr),wt.test(a)?pr++:(a=r,0===Ar&&yr(he));i=[i,c],l=i}else pr=l,l=r;u=l!==r?t.substring(u,pr):l,u!==r?e=u:(pr=e,e=r)}else pr=e,e=r;else pr=e,e=r;else pr=e,e=r;return Ar--,e===r&&(n=r,0===Ar&&yr(ie)),e}function Br(){let e,n,o,s,u,l;for(Ar++,e=pr,n=pr,o=pr,s=[],u=zr();u!==r;)s.push(u),u=pr,l=ln(),l!==r?(l=zr(),l===r?(pr=u,u=r):u=l):u=l;return s.length<1?(pr=o,o=r):o=s,n=o!==r?t.substring(n,pr):o,n!==r?e=n:(pr=e,e=r),Ar--,e===r&&(n=r,0===Ar&&yr(pe)),e}function Mr(){let e,n,o,s,u,l,i;var c;if(Ar++,e=pr,n=tn(),n!==r&&(dr=e,c=n,n=fluent.subject(c)),e=n,e===r){for(e=pr,n=pr,o=[],s=pr,u=zr(),u!==r?(l=ln(),l!==r?(u=[u,l],s=u):(pr=s,s=r)):(pr=s,s=r);s!==r;)o.push(s),s=pr,u=zr(),u!==r?(l=ln(),l!==r?(u=[u,l],s=u):(pr=s,s=r)):(pr=s,s=r);n=t.substring(n,pr),o=pr,s=zr(),s!==r?(u=cn(),58===t.charCodeAt(pr)?(l=U,pr++):(l=r,0===Ar&&yr(re)),l!==r?(i=cn(),o=s):(pr=o,o=r)):(pr=o,o=r),o===r&&(o=null),s=Hr(),s!==r?(u=cn(),dr=e,e=function(t,e,r){if(e)return{ref:[t+e,...r.ref]};if(t){let[e]=r.ref;e.id?e.id=t+e.id:r.ref[0]=t+e}return r}(n,o,s)):(pr=e,e=r)}return Ar--,e===r&&(n=r,0===Ar&&yr(de)),e}function Zr(){let t,e;var n;return t=pr,e=qr(),e!==r&&(dr=t,e=(n=e).xpr.length>1?n:n.xpr[0]),t=e,t}function qr(){let t,e,n,o,s,u;if(t=pr,e=[],n=Xr(),n===r&&(n=Yr(),n===r&&(n=Gr(),n===r&&(n=Wr(),n===r&&(n=Jr(),n===r&&(n=kr(),n===r&&(n=Hr(),n===r&&(n=pr,o=nn(),o!==r?(s=Zr(),s!==r?(u=on(),u!==r?n=s:(pr=n,n=r)):(pr=n,n=r)):(pr=n,n=r)))))))),n!==r)for(;n!==r;)e.push(n),n=Xr(),n===r&&(n=Yr(),n===r&&(n=Gr(),n===r&&(n=Wr(),n===r&&(n=Jr(),n===r&&(n=kr(),n===r&&(n=Hr(),n===r&&(n=pr,o=nn(),o!==r?(s=Zr(),s!==r?(u=on(),u!==r?n=s:(pr=n,n=r)):(pr=n,n=r)):(pr=n,n=r))))))));else e=r;return e!==r&&(dr=t,e={xpr:e}),t=e,t}function Hr(){let t,e,n,o,s,u,l;for(Ar++,t=pr,e=pr,n=[],o=pr,s=zr(),s!==r?(u=Ir(),u===r&&(u=null),dr=o,o=fr(s,u)):(pr=o,o=r);o!==r;)n.push(o),o=pr,s=ln(),s!==r?(s=pr,u=zr(),u!==r?(l=Ir(),l===r&&(l=null),dr=s,s=fr(u,l)):(pr=s,s=r),s===r?(pr=o,o=r):o=s):o=s;return n.length<1?(pr=e,e=r):e=n,e!==r&&(dr=t,e={ref:e}),t=e,Ar--,t===r&&(e=r,0===Ar&&yr(ge)),t}function Wr(){let e,n;return Ar++,e=Qr(),e===r&&(e=pr,n=function(){let e,n;Ar++,e=function(){let e,n,o,s,u,l;e=pr,39===t.charCodeAt(pr)?(n=at,pr++):(n=r,0===Ar&&yr(Ye));if(n!==r){for(o=pr,s=[],u=t.charAt(pr),Lt.test(u)?pr++:(u=r,0===Ar&&yr(ke)),u===r&&(u=pr,t.substr(pr,2)===ft?(l=ft,pr+=2):(l=r,0===Ar&&yr(Ge)),l!==r&&(dr=u,l="'"),u=l);u!==r;)s.push(u),u=t.charAt(pr),Lt.test(u)?pr++:(u=r,0===Ar&&yr(ke)),u===r&&(u=pr,t.substr(pr,2)===ft?(l=ft,pr+=2):(l=r,0===Ar&&yr(Ge)),l!==r&&(dr=u,l=hr()),u=l);o=t.substring(o,pr),39===t.charCodeAt(pr)?(s=at,pr++):(s=r,0===Ar&&yr(Ye)),s!==r?e=o:(pr=e,e=r)}else pr=e,e=r;return e}(),e===r&&(e=function(){let e,n,o,s,u,l,i,c,a,f;e=pr,n=pr,o=pr,45===t.charCodeAt(pr)?(s=lt,pr++):(s=r,0===Ar&&yr(Ze));s===r&&(s=null);u=[],l=t.charAt(pr),mt.test(l)?pr++:(l=r,0===Ar&&yr(qe));if(l!==r)for(;l!==r;)u.push(l),l=t.charAt(pr),mt.test(l)?pr++:(l=r,0===Ar&&yr(qe));else u=r;if(u!==r){if(l=pr,46===t.charCodeAt(pr)?(i=it,pr++):(i=r,0===Ar&&yr(He)),i!==r){if(c=[],a=t.charAt(pr),mt.test(a)?pr++:(a=r,0===Ar&&yr(qe)),a!==r)for(;a!==r;)c.push(a),a=t.charAt(pr),mt.test(a)?pr++:(a=r,0===Ar&&yr(qe));else c=r;c!==r?(i=[i,c],l=i):(pr=l,l=r)}else pr=l,l=r;if(l===r&&(l=null),i=pr,101===t.charCodeAt(pr)?(c=ct,pr++):(c=r,0===Ar&&yr(We)),c!==r){if(a=[],f=t.charAt(pr),mt.test(f)?pr++:(f=r,0===Ar&&yr(qe)),f!==r)for(;f!==r;)a.push(f),f=t.charAt(pr),mt.test(f)?pr++:(f=r,0===Ar&&yr(qe));else a=r;a!==r?(c=[c,a],i=c):(pr=i,i=r)}else pr=i,i=r;i===r&&(i=null),s=[s,u,l,i],o=s}else pr=o,o=r;n=o!==r?t.substring(n,pr):o;n!==r&&(dr=e,n=Number(n));return e=n,e}(),e===r&&(e=function(){let e,n,o,s;e=pr,t.substr(pr,4)===ht?(n=ht,pr+=4):(n=r,0===Ar&&yr(Qe));n!==r?(o=pr,Ar++,s=sn(),Ar--,s===r?o=void 0:(pr=o,o=r),o!==r?(dr=e,e=!0):(pr=e,e=r)):(pr=e,e=r);return e}(),e===r&&(e=function(){let e,n,o,s;e=pr,t.substr(pr,5)===pt?(n=pt,pr+=5):(n=r,0===Ar&&yr(Ve));n!==r?(o=pr,Ar++,s=sn(),Ar--,s===r?o=void 0:(pr=o,o=r),o!==r?(dr=e,e=!1):(pr=e,e=r)):(pr=e,e=r);return e}(),e===r&&(e=function(){let e,n,o,s;e=pr,t.substr(pr,4)===st?(n=st,pr+=4):(n=r,0===Ar&&yr(ze));n!==r?(o=pr,Ar++,s=sn(),Ar--,s===r?o=void 0:(pr=o,o=r),o!==r?(dr=e,e=null):(pr=e,e=r)):(pr=e,e=r);return e}()))));Ar--,e===r&&(n=r,0===Ar&&yr(Me));return e}(),n!==r&&(dr=e,n={val:n}),e=n),Ar--,e===r&&(n=r,0===Ar&&yr(be)),e}function Yr(){let t,e,n,o;return Ar++,t=Qr(),t===r&&(t=pr,e=nn(),e!==r?(n=pr,o=Vr(),o!==r&&(dr=n,o={list:o}),n=o,n!==r?(o=on(),o!==r?t=n:(pr=t,t=r)):(pr=t,t=r)):(pr=t,t=r)),Ar--,t===r&&(e=r,0===Ar&&yr(Ce)),t}function kr(){let e,n,o,s,u,l,i;if(Ar++,e=pr,n=zr(),n!==r)if(o=nn(),o!==r){for(s=pr,u=[],42===t.charCodeAt(pr)?(l=A,pr++):(l=r,0===Ar&&yr(Dt)),l===r&&(l=Zr());l!==r;)u.push(l),l=pr,i=un(),i!==r?(42===t.charCodeAt(pr)?(i=A,pr++):(i=r,0===Ar&&yr(Dt)),i===r&&(i=Zr()),i===r?(pr=l,l=r):l=i):l=i;u.length<1?(pr=s,s=r):s=u,s!==r?(u=on(),u!==r?(dr=e,e={func:n,args:s}):(pr=e,e=r)):(pr=e,e=r)}else pr=e,e=r;else pr=e,e=r;return Ar--,e===r&&(n=r,0===Ar&&yr(we)),e}function Gr(){let e,n,o;return Ar++,e=pr,35===t.charCodeAt(pr)?(n=q,pr++):(n=r,0===Ar&&yr(me)),n!==r?(o=zr(),o!==r?(dr=e,e={"#":o}):(pr=e,e=r)):(pr=e,e=r),Ar--,e===r&&(n=r,0===Ar&&yr(Ae)),e}function Qr(){let e,n,o,s;return Ar++,e=pr,n=cn(),63===t.charCodeAt(pr)?(o=H,pr++):(o=r,0===Ar&&yr(Ee)),o!==r?(s=cn(),dr=e,e=dn()):(pr=e,e=r),Ar--,e===r&&(n=r,0===Ar&&yr(Le)),e}function Vr(){let t,e,n,o;for(Ar++,t=pr,e=[],n=Gr(),n===r&&(n=Wr(),n===r&&(n=Hr(),n===r&&(n=kr())));n!==r;)e.push(n),n=pr,o=un(),o!==r?(o=Gr(),o===r&&(o=Wr(),o===r&&(o=Hr(),o===r&&(o=kr()))),o===r?(pr=n,n=r):n=o):n=o;return e.length<2?(pr=t,t=r):t=e,Ar--,t===r&&(e=r,0===Ar&&yr(be)),t}function Jr(){let e,n,o,s,u;if(Ar++,e=pr,n=cn(),o=Kr(),o===r){if(o=pr,s=[],u=t.charAt(pr),At.test(u)?pr++:(u=r,0===Ar&&yr(ve)),u!==r)for(;u!==r;)s.push(u),u=t.charAt(pr),At.test(u)?pr++:(u=r,0===Ar&&yr(ve));else s=r;o=s!==r?t.substring(o,pr):s}return o!==r?(s=cn(),e=o):(pr=e,e=r),Ar--,e===r&&(n=r,0===Ar&&yr(xe)),e}function Kr(){let e,n,o,s,u,l,i,c;if(e=pr,t.substr(pr,3)===W?(n=W,pr+=3):(n=r,0===Ar&&yr(ye)),n===r&&(t.substr(pr,2)===Y?(n=Y,pr+=2):(n=r,0===Ar&&yr(Se)),n===r&&(t.substr(pr,2)===k?(n=k,pr+=2):(n=r,0===Ar&&yr(_e)),n===r&&(t.substr(pr,7)===G?(n=G,pr+=7):(n=r,0===Ar&&yr(Te)),n===r&&(t.substr(pr,4)===Q?(n=Q,pr+=4):(n=r,0===Ar&&yr($e)),n===r&&(t.substr(pr,6)===V?(n=V,pr+=6):(n=r,0===Ar&&yr(Re)),n===r&&(t.substr(pr,8)===J?(n=J,pr+=8):(n=r,0===Ar&&yr(Fe)))))))),n!==r?(o=pr,Ar++,s=sn(),Ar--,s===r?o=void 0:(pr=o,o=r),o!==r?e=n:(pr=e,e=r)):(pr=e,e=r),e===r&&(e=pr,t.substr(pr,4)===K?(n=K,pr+=4):(n=r,0===Ar&&yr(Ie)),n===r&&(t.substr(pr,4)===X?(n=X,pr+=4):(n=r,0===Ar&&yr(je)),n===r&&(t.substr(pr,4)===tt?(n=tt,pr+=4):(n=r,0===Ar&&yr(Oe)),n===r&&(t.substr(pr,4)===et?(n=et,pr+=4):(n=r,0===Ar&&yr(Ne)),n===r&&(t.substr(pr,3)===rt?(n=rt,pr+=3):(n=r,0===Ar&&yr(Pe)))))),n!==r?(o=pr,Ar++,s=sn(),Ar--,s===r?o=void 0:(pr=o,o=r),o!==r?e=n:(pr=e,e=r)):(pr=e,e=r),e===r)){for(e=pr,n=pr,o=[],s=pr,t.substr(pr,2)===nt?(u=nt,pr+=2):(u=r,0===Ar&&yr(Ue)),u===r&&(t.substr(pr,3)===ot?(u=ot,pr+=3):(u=r,0===Ar&&yr(De)),u===r&&(t.substr(pr,4)===st?(u=st,pr+=4):(u=r,0===Ar&&yr(ze)),u===r&&(t.substr(pr,5)===ut?(u=ut,pr+=5):(u=r,0===Ar&&yr(Be))))),u!==r?(l=pr,Ar++,i=sn(),Ar--,i===r?l=void 0:(pr=l,l=r),l!==r?(u=[u,l],s=u):(pr=s,s=r)):(pr=s,s=r);s!==r;)o.push(s),s=pr,u=cn(),u=pr,t.substr(pr,2)===nt?(l=nt,pr+=2):(l=r,0===Ar&&yr(Ue)),l===r&&(t.substr(pr,3)===ot?(l=ot,pr+=3):(l=r,0===Ar&&yr(De)),l===r&&(t.substr(pr,4)===st?(l=st,pr+=4):(l=r,0===Ar&&yr(ze)),l===r&&(t.substr(pr,5)===ut?(l=ut,pr+=5):(l=r,0===Ar&&yr(Be))))),l!==r?(i=pr,Ar++,c=sn(),Ar--,c===r?i=void 0:(pr=i,i=r),i!==r?(l=[l,i],u=l):(pr=u,u=r)):(pr=u,u=r),u===r?(pr=s,s=r):s=u;o.length<1?(pr=n,n=r):n=o,e=n!==r?t.substring(e,pr):n}return e}function Xr(){let t,e,n,o;return t=pr,e=nn(),e!==r?(n=Tr(),n!==r?(o=on(),o!==r?t=n:(pr=t,t=r)):(pr=t,t=r)):(pr=t,t=r),t}function tn(){let e,n,o,s;return e=pr,n=cn(),63===t.charCodeAt(pr)?(o=H,pr++):(o=r,0===Ar&&yr(Ee)),o!==r?(s=cn(),dr=e,e=hn.shift()):(pr=e,e=r),e}function en(){let e,n,o,s;return e=pr,n=cn(),123===t.charCodeAt(pr)?(o=P,pr++):(o=r,0===Ar&&yr(ee)),o!==r?(s=cn(),n=[n,o,s],e=n):(pr=e,e=r),e}function rn(){let e,n,o,s;return e=pr,n=cn(),125===t.charCodeAt(pr)?(o=D,pr++):(o=r,0===Ar&&yr(ne)),o!==r?(s=cn(),n=[n,o,s],e=n):(pr=e,e=r),e}function nn(){let e,n,o,s;return e=pr,n=cn(),40===t.charCodeAt(pr)?(o=dt,pr++):(o=r,0===Ar&&yr(Je)),o!==r?(s=cn(),n=[n,o,s],e=n):(pr=e,e=r),e}function on(){let e,n,o,s;return e=pr,n=cn(),41===t.charCodeAt(pr)?(o=gt,pr++):(o=r,0===Ar&&yr(Ke)),o!==r?(s=cn(),n=[n,o,s],e=n):(pr=e,e=r),e}function sn(){let e;return e=t.charAt(pr),Et.test(e)?pr++:(e=r,0===Ar&&yr(Xe)),e}function un(){let e,n,o,s;return Ar++,e=pr,n=cn(),44===t.charCodeAt(pr)?(o=bt,pr++):(o=r,0===Ar&&yr(er)),o!==r?(s=cn(),e=o):(pr=e,e=r),Ar--,e===r&&(n=r,0===Ar&&yr(tr)),e}function ln(){let e,n,o,s;return Ar++,e=pr,n=cn(),46===t.charCodeAt(pr)?(o=it,pr++):(o=r,0===Ar&&yr(He)),o!==r?(s=cn(),dr=e,e="."):(pr=e,e=r),Ar--,e===r&&(n=r,0===Ar&&yr(rr)),e}function cn(){let e,n,o;for(Ar++,e=pr,n=[],o=t.charAt(pr),xt.test(o)?pr++:(o=r,0===Ar&&yr(nr));o!==r;)n.push(o),o=t.charAt(pr),xt.test(o)?pr++:(o=r,0===Ar&&yr(nr));return e=t.substring(e,pr),Ar--,e}function an(){let e,n,o;if(Ar++,e=pr,n=[],o=t.charAt(pr),xt.test(o)?pr++:(o=r,0===Ar&&yr(nr)),o!==r)for(;o!==r;)n.push(o),o=t.charAt(pr),xt.test(o)?pr++:(o=r,0===Ar&&yr(nr));else n=r;return e=n!==r?t.substring(e,pr):n,Ar--,e===r&&(n=r,0===Ar&&yr(rr)),e}const fn=[],hn=e.args;let pn=0;const dn=!hn?.length||!e.startRule&&peg$parse.late_binding?()=>fn[pn++]=gn:()=>fn[pn]=fluent.expr(hn[pn++]),gn={ref:["?"],param:!0};br=s();const bn=br!==r&&pr===t.length;function Cn(){throw br!==r&&pr<t.length&&yr({type:"end"}),Sr(wr,Cr<t.length?function(e=pr){const r=t.codePointAt(e);return void 0===r?"":String.fromCodePoint(r)}(Cr):null,Cr<t.length?vr(Cr,Cr+1):vr(Cr,Cr))}return e.peg$library?{peg$result:br,peg$currPos:pr,peg$FAILED:r,peg$maxFailExpected:wr,peg$maxFailPos:Cr,peg$success:bn,peg$throw:bn?void 0:Cn}:bn?br:void Cn()}const peg$allowedStartRules=["CQL","subject","columns","values","ref","val","expr","changes","where","groupBy","orderBy"];export{peg$allowedStartRules as StartRules,peg$SyntaxError as SyntaxError,peg$parse as parse};
|
package/lib/index.js
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
// Re-export all the helper functions and classes from the xl module
|
|
2
|
-
export * from './xl/ttl.js'
|
|
3
|
-
import * as peg from '../cql/parser.min.js'
|
|
4
|
-
import { Query } from './ql/base-class.js'
|
|
5
|
-
export { Query }
|
|
6
|
-
|
|
7
|
-
// Export the fluent interface variants of the query classes
|
|
8
|
-
import { SELECT as SELECT_ } from './ql/select.js'
|
|
9
|
-
import { INSERT as INSERT_ } from './ql/insert.js'
|
|
10
|
-
import { UPSERT as UPSERT_ } from './ql/insert.js'
|
|
11
|
-
import { UPDATE as UPDATE_ } from './ql/update.js'
|
|
12
|
-
import { DELETE as DELETE_ } from './ql/delete.js'
|
|
13
|
-
|
|
14
|
-
export const SELECT = global.SELECT = SELECT_.chimera (SELECT_.columns)
|
|
15
|
-
export const INSERT = global.INSERT = INSERT_.chimera (INSERT_.entries)
|
|
16
|
-
export const UPSERT = global.UPSERT = UPSERT_.chimera (UPSERT_.entries)
|
|
17
|
-
export const UPDATE = global.UPDATE = UPDATE_.chimera (UPDATE_.entity)
|
|
18
|
-
export const DELETE = global.DELETE = DELETE_.chimera (DELETE_.from)
|
|
19
|
-
|
|
20
1
|
|
|
21
2
|
/**
|
|
22
3
|
* This is the central entry point for creating queries from various types of input:
|
|
@@ -26,25 +7,63 @@ export const DELETE = global.DELETE = DELETE_.chimera (DELETE_.from)
|
|
|
26
7
|
* the corresponding query class.
|
|
27
8
|
* @param { Query | string | object } qso - The input, as described above, to be converted into an instance of a Query subclass.
|
|
28
9
|
* @param { ...any } args - Optional arguments for template literals or parameterized queries.
|
|
29
|
-
* @
|
|
30
|
-
* @import { INSERT } from './ql/insert.js'
|
|
31
|
-
* @import { UPSERT } from './ql/insert.js'
|
|
32
|
-
* @import { UPDATE } from './ql/update.js'
|
|
33
|
-
* @import { DELETE } from './ql/delete.js'
|
|
34
|
-
* @returns { SELECT & INSERT & UPSERT & UPDATE & DELETE }
|
|
10
|
+
* @returns { SELECT_ & INSERT_ & UPSERT_ & UPDATE_ & DELETE_ }
|
|
35
11
|
*/
|
|
36
|
-
export
|
|
12
|
+
export const cql = Query.for = (qso, ...args) => {
|
|
37
13
|
if (!qso || qso instanceof Query) return qso
|
|
38
14
|
if (qso.raw) return cql.cache.query4 (qso, ...args)
|
|
39
15
|
if (typeof qso === 'string') return peg.parse (qso, {args})
|
|
40
|
-
else for (let k in qso) if (k in
|
|
41
|
-
return Object.setPrototypeOf (qso,
|
|
16
|
+
else for (let k in qso) if (k in Query.for) //> usually query.kind is first key
|
|
17
|
+
return Object.setPrototypeOf (qso, Query.for[k].prototype)
|
|
42
18
|
return null //> for any other object
|
|
43
19
|
}
|
|
44
20
|
export default cql
|
|
45
21
|
|
|
46
22
|
|
|
23
|
+
// Re-export all the helper functions and classes from the xl module
|
|
24
|
+
export * from './xl/ttl.js'
|
|
25
|
+
import * as peg from '../cql/parser.min.js'
|
|
26
|
+
import { Query } from './query.js'
|
|
27
|
+
export { Query }
|
|
28
|
+
|
|
29
|
+
// Export fluent variants of the query classes
|
|
30
|
+
import { SELECT as SELECT_ } from './ql/select.js'
|
|
31
|
+
import { INSERT as INSERT_ } from './ql/insert.js'
|
|
32
|
+
import { UPSERT as UPSERT_ } from './ql/insert.js'
|
|
33
|
+
import { UPDATE as UPDATE_ } from './ql/update.js'
|
|
34
|
+
import { DELETE as DELETE_ } from './ql/delete.js'
|
|
35
|
+
import { CALL as CALL_ } from './ql/call-action.js'
|
|
36
|
+
|
|
37
|
+
export const SELECT = chimera (SELECT_, SELECT_.columns)
|
|
38
|
+
export const INSERT = chimera (INSERT_, INSERT_.entries)
|
|
39
|
+
export const UPSERT = chimera (UPSERT_, UPSERT_.entries)
|
|
40
|
+
export const UPDATE = chimera (UPDATE_, UPDATE_.entity)
|
|
41
|
+
export const DELETE = chimera (DELETE_, DELETE_.from)
|
|
42
|
+
export const CALL = chimera (CALL_, CALL_.action)
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Turns subclasses of Query into fluent APIs that allow constructing instances with `new`
|
|
46
|
+
* as well as plain function calls. For example, this enables usages like these: @example
|
|
47
|
+
* SELECT`ID,title`.from`Books`
|
|
48
|
+
* UPDATE`Books`.with`${data}`
|
|
49
|
+
* @param factory - The function to be called when the fluent API is invoked without `new`.
|
|
50
|
+
* @type <clazz> (clazz:clazz, factory:()=> clazz) => factory & clazz
|
|
51
|
+
*/
|
|
52
|
+
function chimera (clazz, factory) { const kind = clazz.name
|
|
53
|
+
function fx (...args) { return new.target ? new clazz : factory.call (clazz,...args) }
|
|
54
|
+
Object.defineProperty (clazz.prototype, '_', { get(){ return this[kind] }})
|
|
55
|
+
Object.defineProperty (clazz.prototype, 'kind', { value: kind })
|
|
56
|
+
Object.defineProperty (clazz, 'name', { value: 'Query' })
|
|
57
|
+
Object.defineProperty (fx, 'name', { value: kind })
|
|
58
|
+
Object.defineProperty (fx, 'class', { value: clazz })
|
|
59
|
+
Object.defineProperty (fx, 'prototype', { value: clazz.prototype })
|
|
60
|
+
Object.setPrototypeOf (fx,clazz) //> adds static members
|
|
61
|
+
return Query.for[kind] = fx
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
47
65
|
// Prepare a cache for parsed queries, and export it as part of the cql facade
|
|
48
66
|
// for easy access and control over caching behavior.
|
|
49
67
|
import { QueryCache } from './ql/cache.js'
|
|
50
|
-
cql.cache = new QueryCache
|
|
68
|
+
cql.cache = new QueryCache
|
|
69
|
+
cql.cache.enabled = false //> disable caching by default
|
package/lib/ql/cache.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as peg from '../../cql/parser.min.js'
|
|
2
|
+
import { Query } from '../query.js'
|
|
2
3
|
|
|
3
|
-
export class QueryCache extends
|
|
4
|
+
export class QueryCache extends Map {
|
|
4
5
|
|
|
5
6
|
cached (strings, ...args) {
|
|
6
7
|
if (!strings?.raw) return this.parse (strings, ...args)
|
|
7
8
|
const cached = this.get (strings)
|
|
8
9
|
if (cached) {
|
|
9
|
-
const q = new
|
|
10
|
+
const q = new Query.for[cached.kind]
|
|
10
11
|
q[q.kind] = cached[cached.kind]
|
|
11
12
|
q.params = cached.params
|
|
12
13
|
if (args?.length) q.args = args
|
|
@@ -23,16 +24,11 @@ export class QueryCache extends WeakMap {
|
|
|
23
24
|
return peg.parse (src, {args})
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.query4 = this.cached
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
disable(){
|
|
32
|
-
peg.parse.late_binding = false
|
|
33
|
-
this.query4 = this.parse
|
|
27
|
+
get enabled () { return peg.parse.late_binding }
|
|
28
|
+
set enabled (v) {
|
|
29
|
+
this.query4 = v ? this.cached : this.parse
|
|
30
|
+
peg.parse.late_binding = v
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
query4 = this.parse
|
|
37
|
-
|
|
38
34
|
}
|
package/lib/ql/delete.js
CHANGED
package/lib/ql/insert.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { subject, columns, values
|
|
2
|
-
import { Query } from '
|
|
3
|
-
|
|
1
|
+
import { subject, columns, values } from '../xl/ttl.js'
|
|
2
|
+
import { Query } from '../query.js'
|
|
3
|
+
|
|
4
|
+
const unwrapped = args => Array.isArray(args[0]) ? args[0] : args
|
|
4
5
|
|
|
5
6
|
export class XSERT extends Query {
|
|
6
7
|
static entries (...args) { return (new this).entries(...args) }
|
|
7
8
|
static into (x,...tail) {
|
|
8
9
|
if (x.raw) return (new this)._set ('into', subject(x,...tail)) //> INSERT.into`Foo`
|
|
9
10
|
const insert = (new this)._set ('into', subject(x)) //> INSERT.into(Foo)
|
|
10
|
-
return !tail.length ? insert : insert.
|
|
11
|
-
};
|
|
11
|
+
return !tail.length ? insert : insert._tail(...tail) //> INSERT.into(Foo, ...?)
|
|
12
|
+
}; _tail (...tail) {
|
|
12
13
|
if (unwrapped(tail)[0]?.split) return this.columns(...tail) //> INSERT.into(Foo, columns)
|
|
13
|
-
return this._set ('entries',
|
|
14
|
+
return this._set ('entries', unwrapped(tail)) //> INSERT.into(Foo, entries)
|
|
14
15
|
}
|
|
15
16
|
into (...args) { return this._set('into', subject(...args)) }
|
|
16
|
-
entries (...args) { return this._set('entries',
|
|
17
|
+
entries (...args) { return this._set('entries', unwrapped(args)) }
|
|
17
18
|
columns (...args) { return this._add('columns', columns(...args).map(c => c.ref[0])) }
|
|
18
19
|
values (...args) { return this._set('values', values(...args)) }
|
|
19
20
|
rows (...args) { return this._set('rows', unwrapped(args)) }
|
|
20
|
-
from (...args) { return this._set('from',
|
|
21
|
+
from (...args) { return this._set('from', Query.for(...args)) }
|
|
21
22
|
get subject() { return this._.into }
|
|
22
23
|
}
|
|
23
24
|
|
package/lib/ql/select.js
CHANGED
package/lib/ql/update.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { subject, where } from '../xl/ttl.js'
|
|
2
|
-
import { Query } from '
|
|
1
|
+
import { subject, where, ttl } from '../xl/ttl.js'
|
|
2
|
+
import { Query } from '../query.js'
|
|
3
3
|
|
|
4
4
|
export class UPDATE extends Query { UPDATE = {}
|
|
5
5
|
static entity (...args) { return (new this)._set('entity', subject (...args)) }
|
|
6
|
-
where (...args) { return this._add('where', where (...args)) }
|
|
7
|
-
with (
|
|
8
|
-
|
|
6
|
+
where (...args) { return this._add ('where', where (...args)) }
|
|
7
|
+
with (...args) {
|
|
8
|
+
if (args[0]?.raw) Object.assign (this._, ttl('changes',...args))
|
|
9
|
+
else this._set('data', args[0])
|
|
10
|
+
return this
|
|
11
|
+
}
|
|
12
|
+
set (...args) { return this.with (...args) }
|
|
9
13
|
get subject() { return this._.entity }
|
|
10
14
|
}
|
|
@@ -1,41 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { expr } from '../xl/fluent.js'
|
|
1
|
+
import { expr } from './xl/fluent.js'
|
|
3
2
|
|
|
4
3
|
export class Query {
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* SELECT`ID,title`.from`Books`
|
|
10
|
-
* UPDATE`Books`.with`${data}`
|
|
11
|
-
* @param fn - The function to be called when the fluent API is invoked without `new`.
|
|
12
|
-
* @type <T> (this:T, fn:()=>T) => fn & T
|
|
13
|
-
*/
|
|
14
|
-
static chimera (fn) { const self = this, kind = this.name
|
|
15
|
-
function fx (...args) { return new.target ? new self : fn.call (self,...args) }
|
|
16
|
-
Object.defineProperty (this.prototype, '_', { get(){ return this[kind] }})
|
|
17
|
-
Object.defineProperty (this.prototype, 'kind', { value: kind })
|
|
18
|
-
Object.defineProperty (this, 'name', { value: 'Query' })
|
|
19
|
-
Object.defineProperty (fx, 'name', { value: kind })
|
|
20
|
-
Object.defineProperty (fx, 'class', { value: this })
|
|
21
|
-
Object.defineProperty (fx, 'prototype', { value: this.prototype })
|
|
22
|
-
Object.setPrototypeOf (fx,this) //> adds static members
|
|
23
|
-
return peg.ql[kind] = fx
|
|
24
|
-
}
|
|
5
|
+
// These are required for Peggy Live Preview in VSCode
|
|
6
|
+
/** @private */ get kind() { return this.constructor.name }
|
|
7
|
+
/** @private */ get _() { return this[this.kind] }
|
|
25
8
|
|
|
26
9
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* - However, changes to nested objects will affect both the original and the clone.
|
|
30
|
-
* @param clauses - Optional list of objects with clauses to override in the clone.
|
|
31
|
-
* @type <T> (this:T, clauses:{columns,from,where,having,groupy,orderBy,limit}[]) => T
|
|
10
|
+
* Returns the main subject `{ref}` of the query, which refers to the entity being queried or modified.
|
|
11
|
+
* @returns {ref:string[]} The main subject of the query.
|
|
32
12
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
13
|
+
get subject() { return this._.from }
|
|
14
|
+
|
|
15
|
+
// Non-enumerable properties that are only valid within the same process
|
|
16
|
+
/** @private */ set source (cql) { Object.defineProperty (this, 'source', { value: cql, writable: true }) }
|
|
17
|
+
/** @private */ set params (arr) { Object.defineProperty (this, 'params', { value: arr, writable: true }) }
|
|
18
|
+
/** @private */ set args (arr) { Object.defineProperty (this, 'args', { value: arr, writable: true }) }
|
|
39
19
|
|
|
40
20
|
/**
|
|
41
21
|
* - Fills in any binding `{param}`s with corresponding `{val}`s from given `args`.
|
|
@@ -61,6 +41,20 @@ export class Query {
|
|
|
61
41
|
return this
|
|
62
42
|
}
|
|
63
43
|
|
|
44
|
+
/**
|
|
45
|
+
* - Creates a shallow clone of the given `query`.
|
|
46
|
+
* - Subsequent changes to the clone will not affect the original.
|
|
47
|
+
* - However, changes to nested objects will affect both the original and the clone.
|
|
48
|
+
* @param clauses - Optional list of objects with clauses to override in the clone.
|
|
49
|
+
* @type <T> (this:T, clauses:{columns,from,where,having,groupy,orderBy,limit}[]) => T
|
|
50
|
+
*/
|
|
51
|
+
clone (...clauses) {
|
|
52
|
+
const _ = this.kind || Object.keys(this)[0]
|
|
53
|
+
return Object.assign ({ __proto__: this,
|
|
54
|
+
[_]: { __proto__: this[_] }
|
|
55
|
+
}, ...clauses)
|
|
56
|
+
}
|
|
57
|
+
|
|
64
58
|
/**
|
|
65
59
|
* Adds the given values to the specified clause in the CQN. If the clause already
|
|
66
60
|
* exists, the new values are appended to the existing ones. Otherwise, a clause
|
|
@@ -82,19 +76,10 @@ export class Query {
|
|
|
82
76
|
return this
|
|
83
77
|
}
|
|
84
78
|
|
|
85
|
-
/**
|
|
86
|
-
* Returns the main subject `{ref}` of the query, which refers to the entity being queried or modified.
|
|
87
|
-
* @returns {ref:string[]} The main subject of the query.
|
|
88
|
-
*/
|
|
89
|
-
get subject() { return this._.from }
|
|
90
|
-
|
|
91
|
-
// Non-enumerable properties that are only valid within the same process
|
|
92
|
-
/** @private */ set source (cql) { Object.defineProperty (this, 'source', { value: cql, writable: true }) }
|
|
93
|
-
/** @private */ set params (arr) { Object.defineProperty (this, 'params', { value: arr, writable: true }) }
|
|
94
|
-
/** @private */ set args (arr) { Object.defineProperty (this, 'args', { value: arr, writable: true }) }
|
|
95
|
-
|
|
96
79
|
// Custom inspect method to improve the output, e.g. in repl, console.log,
|
|
97
|
-
[Symbol.for('nodejs.util.inspect.custom')]
|
|
80
|
+
[Symbol.for('nodejs.util.inspect.custom')] (depth, options, inspect) {
|
|
98
81
|
return `${this.kind} ${inspect(this[this.kind], options)}`
|
|
99
82
|
}
|
|
100
83
|
}
|
|
84
|
+
|
|
85
|
+
/** @private */ Query.for = {} //> filled in from ./index.js
|
package/lib/xl/fluent.js
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
const unwrapped = args => Array.isArray(args[0]) ? args[0] : args
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export const val = (v) => ({ val: v })
|
|
4
|
+
export const ref = (r) => ({ ref: String(r).split('.') })
|
|
5
|
+
export const expr = (x) => {
|
|
6
|
+
if (Array.isArray(x)) return { list: x.map(expr) }
|
|
7
|
+
if (x && typeof x === 'object') return x //> already a cxn object
|
|
8
|
+
else return val(x)
|
|
5
9
|
}
|
|
6
10
|
|
|
7
11
|
export const subject = (x,pk) => {
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
if (x.ref) return x
|
|
13
|
+
if (x.name) return Object.defineProperty ({ref:[x.name]},'target',{value:x})
|
|
14
|
+
let ref = [ !pk ? x : { id:x, where: where(pk) } ]
|
|
15
|
+
return {ref}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const columns = (...args) => {
|
|
19
|
+
return unwrapped(args) .map (a => typeof a === 'string' ? ref(a) : val(a))
|
|
10
20
|
}
|
|
11
21
|
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
export const values = (...args) => {
|
|
23
|
+
return unwrapped(args) .map (expr)
|
|
24
|
+
}
|
|
15
25
|
|
|
16
26
|
export const where = (x) => {
|
|
17
27
|
if (!x || typeof x !== 'object') return [ val(x) ]
|
|
@@ -19,14 +29,19 @@ export const where = (x) => {
|
|
|
19
29
|
.flat().slice(1)
|
|
20
30
|
}
|
|
21
31
|
|
|
22
|
-
export const
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
else return
|
|
32
|
+
export const having = where
|
|
33
|
+
export const groupBy = columns
|
|
34
|
+
export const orderBy = (...args) => {
|
|
35
|
+
// orderBy({ a:1, b:-1 })
|
|
36
|
+
if (typeof (args = unwrapped(args))[0] === 'object')
|
|
37
|
+
return Object.entries(args[0]) .map (
|
|
38
|
+
([k,v]) => ({ ref:[k], sort: { [1]:'asc',[-1]:'desc' }[v] || v })
|
|
39
|
+
)
|
|
40
|
+
// orderBy('a desc','b')
|
|
41
|
+
else return args.map (ordering_term => {
|
|
42
|
+
const [,c,ad] = /^([^\s]+)(?:\s+(asc|desc))?$/i .exec (ordering_term)
|
|
43
|
+
const ref = { ref: c.split('.') }
|
|
44
|
+
if (ad) ref.sort = ad.toLowerCase()
|
|
45
|
+
return ref
|
|
46
|
+
})
|
|
32
47
|
}
|
package/lib/xl/ttl.js
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
import * as fluent from './fluent.js'; export { fluent }
|
|
2
1
|
import * as peg from '../../cql/parser.min.js'
|
|
2
|
+
import * as fluent from './fluent.js'
|
|
3
|
+
export { fluent }
|
|
3
4
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
parse.str = (startRule, x, ...args) => parse (x, { startRule, args })
|
|
8
|
-
parse.fluent = fluent
|
|
9
|
-
|
|
10
|
-
export const subject = (...args) => parse.ttl ('entity', ...args) || fluent.subject (...args)
|
|
11
|
-
export const columns = (...args) => parse.ttl ('columns', ...args) || fluent.columns (...args)
|
|
12
|
-
export const values = (...args) => parse.ttl ('vals', ...args) || fluent.values (...args)
|
|
13
|
-
export const where = (...args) => parse.ttl ('where', ...args) || fluent.where (...args)
|
|
14
|
-
export const having = where
|
|
15
|
-
export const groupBy = columns
|
|
16
|
-
export const orderBy = (...args) => {
|
|
17
|
-
const cxn = parse.ttl ('orderBy', ...args); if (cxn) return cxn
|
|
18
|
-
if (typeof (args = unwrapped(args))[0] === 'string')
|
|
19
|
-
return parse.str ('orderBy', args.join(','))
|
|
20
|
-
else return fluent.orderBy (...args) //> { a:1, b:-1 }
|
|
5
|
+
export const ttl = (rule, x,...args) => {
|
|
6
|
+
const src = String.raw (x,...'?'.repeat(args.length))
|
|
7
|
+
return peg.parse (src, { startRule: rule, args })
|
|
21
8
|
}
|
|
22
9
|
|
|
23
|
-
export const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const cxn = parse.ttl ('expr', ...args); if (cxn) return cxn
|
|
27
|
-
const xpr = args.map (fluent.expr)
|
|
28
|
-
return xpr.length === 1 ? xpr[0] : {xpr}
|
|
10
|
+
export const ttl_ = (rule, ffn) => (x,...args) => {
|
|
11
|
+
if (x?.raw) return ttl (rule, x,...args)
|
|
12
|
+
else return ffn (x,...args)
|
|
29
13
|
}
|
|
14
|
+
|
|
15
|
+
export const val = ttl_('val', fluent.val)
|
|
16
|
+
export const ref = ttl_('ref', fluent.ref)
|
|
17
|
+
export const expr = ttl_('expr', fluent.expr)
|
|
18
|
+
export const subject = ttl_('subject', fluent.subject)
|
|
19
|
+
export const columns = ttl_('columns', fluent.columns)
|
|
20
|
+
export const values = ttl_('values', fluent.values)
|
|
21
|
+
export const where = ttl_('where', fluent.where)
|
|
22
|
+
export const having = ttl_('having', fluent.having)
|
|
23
|
+
export const groupBy = ttl_('groupBy', fluent.groupBy)
|
|
24
|
+
export const orderBy = ttl_('orderBy', fluent.orderBy)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap.core/ql",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Minimalistic implementation of cds.ql, carved out from CAP.",
|
|
5
5
|
"repository": "https://github.com/cap-js/ql.git",
|
|
6
6
|
"author": "daniel.hutzel@sap.com",
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
"@types/cap.core__ql": "file:./@types"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"peggy": "npx peggy cql/grammar.pegjs -o cql/parser.js --format es --allowed-start-rules CQL,
|
|
19
|
-
"terser": "npx terser cql/parser.js -o cql/parser.min.js --compress --mangle --ecma 2022 --source-map
|
|
20
|
-
"build": "npm run peggy && npm run terser"
|
|
18
|
+
"peggy": "npx peggy cql/grammar.pegjs -o cql/parser.js --format es --allowed-start-rules CQL,subject,columns,values,ref,val,expr,changes,where,groupBy,orderBy",
|
|
19
|
+
"terser": "npx terser cql/parser.js -o cql/parser.min.js --compress --mangle --ecma 2022 --source-map",
|
|
20
|
+
"build": "npm run peggy && npm run terser",
|
|
21
|
+
"test": "npx vitest run"
|
|
21
22
|
},
|
|
22
23
|
"license": "Apache-2.0"
|
|
23
24
|
}
|
package/@types/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|