Skip to content

Commit

Permalink
0.92.0
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomvh committed Nov 17, 2021
1 parent c586142 commit c551f49
Show file tree
Hide file tree
Showing 70 changed files with 8,038 additions and 3,160 deletions.
139 changes: 105 additions & 34 deletions docs/classes/ArithmeticFunctions.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ <h3 id="methods">

<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="171"
class="link-to-prism">projects/angular-odata/src/lib/resources/query/syntax.ts:171</a></div>
<div class="io-line">Defined in <a href="" data-line="203"
class="link-to-prism">projects/angular-odata/src/lib/resources/query/syntax.ts:203</a></div>
</td>
</tr>

Expand Down Expand Up @@ -199,8 +199,8 @@ <h3 id="methods">

<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="174"
class="link-to-prism">projects/angular-odata/src/lib/resources/query/syntax.ts:174</a></div>
<div class="io-line">Defined in <a href="" data-line="206"
class="link-to-prism">projects/angular-odata/src/lib/resources/query/syntax.ts:206</a></div>
</td>
</tr>

Expand Down Expand Up @@ -268,8 +268,8 @@ <h3 id="methods">

<tr>
<td class="col-md-4">
<div class="io-line">Defined in <a href="" data-line="177"
class="link-to-prism">projects/angular-odata/src/lib/resources/query/syntax.ts:177</a></div>
<div class="io-line">Defined in <a href="" data-line="209"
class="link-to-prism">projects/angular-odata/src/lib/resources/query/syntax.ts:209</a></div>
</td>
</tr>

Expand Down Expand Up @@ -331,7 +331,13 @@ <h3 id="methods">
import type { QueryCustomType } from &#x27;./builder&#x27;;

export interface Renderable {
render(aliases?: QueryCustomType[]): string;
render({
aliases,
escape,
}: {
aliases?: QueryCustomType[];
escape?: boolean;
}): string;
toString(): string;
toJSON(): any;
}
Expand All @@ -356,23 +362,35 @@ <h3 id="methods">

function render(
value: any,
aliases?: QueryCustomType[],
normalize?: boolean
{
aliases,
normalize,
escape,
}: {
aliases?: QueryCustomType[];
normalize?: boolean;
escape?: boolean;
} &#x3D; {}
): string | number | boolean | null {
if (typeof value &#x3D;&#x3D;&#x3D; &#x27;function&#x27;) {
return render(value(syntax), aliases, normalize);
return render(value(syntax), { aliases, normalize });
}
if (typeof value &#x3D;&#x3D;&#x3D; &#x27;object&#x27; &amp;&amp; value !&#x3D;&#x3D; null &amp;&amp; &#x27;render&#x27; in value) {
return render(value.render(aliases), aliases, normalize);
return render(value.render({ aliases, escape }), {
aliases,
normalize,
escape,
});
}
return normalize ? normalizeValue(value, aliases) : value;
return normalize ? normalizeValue(value, { aliases, escape }) : value;
}

export class Function&lt;T&gt; implements Renderable {
constructor(
protected name: string,
protected values: any[],
protected normalize: boolean &#x3D; true
protected normalize: boolean &#x3D; true,
protected escape: boolean &#x3D; false
) {}

get [Symbol.toStringTag]() {
Expand All @@ -387,13 +405,21 @@ <h3 id="methods">
};
}

render(aliases?: QueryCustomType[]): string {
render({
aliases,
escape,
}: {
aliases?: QueryCustomType[];
escape?: boolean;
}): string {
let [field, ...values] &#x3D; this.values;

field &#x3D; render(field);
let params &#x3D; [
field,
...values.map((v) &#x3D;&gt; render(v, aliases, this.normalize)),
...values.map((v) &#x3D;&gt;
render(v, { aliases, escape, normalize: this.normalize })
),
];
return &#x60;${this.name}(${params.join(&#x27;, &#x27;)})&#x60;;
}
Expand All @@ -403,27 +429,33 @@ <h3 id="methods">
concat(field: T, value: any, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;concat&#x27;, [field, value], normalize);
}

contains(field: T, value: any, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;contains&#x27;, [field, value], normalize);
}

endsWith(field: T, value: any, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;endswith&#x27;, [field, value], normalize);
}

indexOf(field: T, value: any, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;indexof&#x27;, [field, value], normalize);
}

length(value: T, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;length&#x27;, [value], normalize);
}

startsWith(field: T, value: any, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;startswith&#x27;, [field, value], normalize);
}
subString(field: T, start: any, length?: any, normalize?: boolean) {

subString(field: T, start: number, length?: number) {
let values &#x3D; [field, start];
if (length !&#x3D;&#x3D; undefined) {
values.push(length);
}
return new Function&lt;T&gt;(&#x27;substring&#x27;, values, normalize);
return new Function&lt;T&gt;(&#x27;substring&#x27;, values);
}
}

Expand Down Expand Up @@ -519,14 +551,14 @@ <h3 id="methods">
}

export class GeoFunctions&lt;T&gt; {
distance(value: T, point: string, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;distance&#x27;, [value, point], normalize);
geoDistance(value: T, point: string, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;geo.distance&#x27;, [value, point], normalize);
}
intersects(value: T, polygon: string, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;intersects&#x27;, [value, polygon], normalize);
geoIntersects(value: T, polygon: string, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;geo.intersects&#x27;, [value, polygon], normalize);
}
length(value: T, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;length&#x27;, [value], normalize);
geoLength(line: T, normalize?: boolean) {
return new Function&lt;T&gt;(&#x27;geo.length&#x27;, [line], normalize);
}
}

Expand Down Expand Up @@ -555,14 +587,32 @@ <h3 id="methods">
};
}

render(aliases?: QueryCustomType[]): string {
render({
aliases,
escape,
}: {
aliases?: QueryCustomType[];
escape: boolean;
}): string {
let [left, right] &#x3D; this.values;

left &#x3D; render(left);
left &#x3D; render(left, { aliases, escape });
if (right !&#x3D;&#x3D; undefined) {
right &#x3D; Array.isArray(right)
? &#x60;(${right.map((v) &#x3D;&gt; render(v, aliases, this.normalize)).join(&#x27;,&#x27;)})&#x60;
: render(right, aliases, this.normalize);
? &#x60;(${right
.map((v) &#x3D;&gt;
render(v, {
aliases,
escape,
normalize: this.normalize,
})
)
.join(&#x27;,&#x27;)})&#x60;
: render(right, {
aliases,
escape,
normalize: this.normalize,
});
return &#x60;${left} ${this.op} ${right}&#x60;;
}
return &#x60;${this.op}(${left})&#x60;;
Expand Down Expand Up @@ -639,8 +689,14 @@ <h3 id="methods">
};
}

render(aliases?: QueryCustomType[]): string {
return &#x60;(${render(this.group, aliases)})&#x60;;
render({
aliases,
escape,
}: {
aliases?: QueryCustomType[];
escape: boolean;
}): string {
return &#x60;(${render(this.group, { aliases })})&#x60;;
}
}

Expand All @@ -658,8 +714,14 @@ <h3 id="methods">
};
}

render(aliases?: QueryCustomType[]): string {
return &#x60;${this.field}/${render(this.value, aliases)}&#x60;;
render({
aliases,
escape,
}: {
aliases?: QueryCustomType[];
escape: boolean;
}): string {
return &#x60;${this.field}/${render(this.value, { aliases, escape })}&#x60;;
}
}

Expand All @@ -686,12 +748,21 @@ <h3 id="methods">
return &#x27;Lambda&#x27;;
}

render(aliases?: QueryCustomType[]): string {
render({
aliases,
escape,
}: {
aliases?: QueryCustomType[];
escape: boolean;
}): string {
let [left, right] &#x3D; this.values;

left &#x3D; render(left, aliases);
left &#x3D; render(left, { aliases, escape });
let alias &#x3D; left.split(&#x27;/&#x27;).pop().toLowerCase();
return &#x60;${left}/${this.op}(${alias}:${alias}/${render(right, aliases)})&#x60;;
return &#x60;${left}/${this.op}(${alias}:${alias}/${render(right, {
aliases,
escape,
})})&#x60;;
}
}

Expand Down
Loading

0 comments on commit c551f49

Please sign in to comment.