odata-query
Advanced tools
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const F=["eq","ne","gt","ge","lt","le"],m=["and","or","not"],k=["any","all"],I=["startswith","endswith","contains","matchespattern"],L=["expand","levels","select","skip","top","count","orderby","filter"],R=/\((.*)\)/,T=/(?!indexof)\((\w+)\)/;var N=(e=>(e.sum="sum",e.min="min",e.max="max",e.average="average",e.countdistinct="countdistinct",e))(N||{});const q=e=>({type:"raw",value:e}),U=e=>({type:"guid",value:e}),D=e=>({type:"duration",value:e}),V=e=>({type:"binary",value:e}),G=e=>({type:"json",value:e}),P=(e,o)=>({type:"alias",name:e,value:o}),X=e=>({type:"decimal",value:e}),b="";function M({select:e,search:o,skiptoken:r,format:n,top:a,skip:$,filter:s,transform:p,orderBy:d,key:j,count:u,expand:y,action:i,func:c}={}){let l="",t=[];const f={};if(j!=null&&(l+=`(${O(j,t)})`),(s||typeof u=="object")&&(f.$filter=E(typeof u=="object"?u:s,t)),p&&(f.$apply=S(p)),y&&(f.$expand=w(y)),d&&(f.$orderby=C(d)),u&&(typeof u=="boolean"?f.$count=!0:l+="/$count"),typeof a=="number"&&(f.$top=a),typeof $=="number"&&(f.$skip=$),i&&(l+=`/${i}`),c){if(typeof c=="string")l+=`/${c}`;else if(typeof c=="object"){const[h]=Object.keys(c),A=O(c[h],t);l+=`/${h}`,A!==""&&(l+=`(${A})`)}}return t.length>0&&Object.assign(f,t.reduce((h,A)=>Object.assign(h,{[`@${A.name}`]:O(A.value)}),{})),Q(l,{$select:e,$search:o,$skiptoken:r,$format:n,...f})}function g(e,o,r=[]){return`${e} eq ${O(o,r)}`}function E(e={},o=[],r=""){return(Array.isArray(e)?e:[e]).reduce(($,s)=>{if(s){const p=n(s,o,r);p&&$.push(p)}return $},[]).join(" and ");function n($={},s=[],p=""){let d="";return typeof $=="string"?d=$:$&&typeof $=="object"&&(d=Object.keys($).reduce((u,y)=>{const i=$[y];if(i===void 0)return u;let c="";if(p?y===b?c=p:T.test(y)?c=y.replace(T,(l,t)=>t.trim()===b?`(${p})`:`(${p}/${t.trim()})`):R.test(y)?c=y.replace(R,(l,t)=>t.trim()===b?`(${p})`:`(${p}/${t.trim()})`):c=`${p}/${y}`:c=y,y===b&&Array.isArray(i))return u.concat(i.map(l=>g(c,l)));if(["number","string","boolean"].indexOf(typeof i)!==-1||i instanceof Date||i===null)u.push(g(c,i,s));else if(Array.isArray(i)){const l=y,t=i.map(f=>E(f,s,p)).filter(f=>f).map(f=>m.indexOf(l)!==-1?`(${f})`:f);t.length&&(m.indexOf(l)!==-1?t.length&&(l==="not"?u.push(_(t)):u.push(`(${t.join(` ${l} `)})`)):u.push(t.join(` ${l} `)))}else if(m.indexOf(c)!==-1){const l=c,t=Object.keys(i).map(f=>n({[f]:i[f]}));t.length&&(l==="not"?u.push(_(t)):u.push(`(${t.join(` ${l} `)})`))}else if(typeof i=="object")"type"in i?u.push(g(c,i,s)):Object.keys(i).forEach(t=>{if(i[t]!==void 0)if(F.indexOf(t)!==-1)u.push(`${c} ${t} ${O(i[t],s)}`);else if(m.indexOf(t)!==-1)Array.isArray(i[t])?u.push(i[t].map(f=>"("+n(f,s,c)+")").join(` ${t} `)):u.push("("+n(i[t],s,c)+")");else if(k.indexOf(t)!==-1){const f=a(y.toLowerCase(),i[t],t,c);f&&u.push(f)}else if(t==="has")u.push(`${c} ${t} ${O(i[t],s)}`);else if(t==="in"){const f=Array.isArray(i[t])?i[t]:i[t].value.map(h=>({type:i[t].type,value:h}));u.push(c+" in ("+f.map(h=>O(h,s)).join(",")+")")}else if(I.indexOf(t)!==-1)u.push(`${t}(${c},${O(i[t],s)})`);else{const f=n({[t]:i[t]},s,c);f&&u.push(f)}});else throw new Error(`Unexpected value type: ${i}`);return u},[]).join(" and ")),d}function a($,s,p,d){let j="";if(typeof s=="string"||s instanceof String)j=J($,s,p,d);else if(s){const u=Array.isArray(s)?s.reduce((i,c)=>c.hasOwnProperty(b)?(i.hasOwnProperty(b)||(i[b]=[]),i[b].push(c[b]),i):{...i,...c},{}):s,y=n(u,o,$);j=`${d}/${p}(${y?`${$}:${y}`:""})`}return j}}function J(e,o,r,n){const a=r=="all"?"ne":"eq";return`${n}/${r}(${e}: ${e} ${a} '${o}')`}function z(e){return e=e.replace(/%/g,"%25"),e=e.replace(/\+/g,"%2B"),e=e.replace(/\//g,"%2F"),e=e.replace(/\?/g,"%3F"),e=e.replace(/#/g,"%23"),e=e.replace(/&/g,"%26"),e=e.replace(/'/g,"''"),e}function O(e,o){if(typeof e=="string")return`'${z(e)}'`;if(e instanceof Date)return e.toISOString();if(typeof e=="number")return e;if(Array.isArray(e))return`[${e.map(r=>O(r)).join(",")}]`;if(e===null)return e;if(typeof e=="object")switch(e.type){case"raw":case"guid":return e.value;case"duration":return`duration'${e.value}'`;case"binary":return`binary'${e.value}'`;case"alias":return Array.isArray(o)&&o.push(e),`@${e.name}`;case"json":return escape(JSON.stringify(e.value));case"decimal":return`${e.value}M`;default:return Object.entries(e).filter(([,r])=>r!==void 0).map(([r,n])=>`${r}=${O(n,o)}`).join(",")}return e}function w(e){if(typeof e=="number")return e;if(typeof e=="string")return e.indexOf("/")===-1?e:e.split("/").reverse().reduce((o,r,n,a)=>n===0?`$expand=${r}`:n===a.length-1?`${r}(${o})`:`$expand=${r}(${o})`,"");if(Array.isArray(e))return`${e.map(o=>w(o)).join(",")}`;if(typeof e=="object"){const o=Object.keys(e);return o.some(r=>L.indexOf(r.toLowerCase())!==-1)?o.map(r=>{let n;switch(r){case"filter":n=E(e[r]);break;case"orderBy":n=C(e[r]);break;case"levels":case"count":case"skip":case"top":n=`${e[r]}`;break;default:n=w(e[r])}return`$${r.toLowerCase()}=${n}`}).join(";"):o.map(r=>{const n=w(e[r]);return n?`${r}(${n})`:r}).join(",")}return""}function S(e){return(Array.isArray(e)?e:[e]).reduce((n,a)=>{for(const $ of Object.keys(a))switch($){case"aggregate":{const s=a[$];s&&n.push(`aggregate(${B(s)})`);break}case"filter":{const s=a[$];if(s){const p=E(s);p&&n.push(`filter(${p})`)}break}case"groupBy":{const s=a[$];s&&n.push(`groupby(${H(s)})`);break}default:throw new Error(`Unsupported transform: ${$}`)}return n},[]).join("/")||void 0}function B(e){return(Array.isArray(e)?e:[e]).map(r=>typeof r=="string"?r:Object.keys(r).map(n=>{const a=r[n];if(!a.with&&a.as)return`${n} as ${a.as}`;if(!a.with)throw new Error(`'with' property required for '${n}'`);if(!a.as)throw new Error(`'as' property required for '${n}'`);return`${n} with ${a.with} as ${a.as}`})).join(",")}function H(e){if(!e.properties)throw new Error("'properties' property required for groupBy");let o=`(${e.properties.join(",")})`;return e.transform&&(o+=`,${S(e.transform)}`),o}function C(e,o=""){return Array.isArray(e)?e.map(r=>Array.isArray(r)&&r.length===2&&["asc","desc"].indexOf(r[1])!==-1?r.join(" "):r).map(r=>`${o}${String(r)}`).join(","):typeof e=="object"?Object.entries(e).map(([r,n])=>C(n,`${r}/`)).map(r=>`${o}${r}`).join(","):`${o}${String(e)}`}function Q(e,o){const r=Object.getOwnPropertyNames(o).filter(n=>o[n]!==void 0&&o[n]!=="").map(n=>`${n}=${o[n]}`);return r.length?`${e}?${r.join("&")}`:e}function _(e){return`not (${e.join(" and ")})`}exports.ITEM_ROOT=b;exports.StandardAggregateMethods=N;exports.alias=P;exports.binary=V;exports.decimal=X;exports.default=M;exports.duration=D;exports.guid=U;exports.json=G;exports.raw=q; | ||
| "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const I=["eq","ne","gt","ge","lt","le"],m=["and","or","not"],F=["any","all"],k=["startswith","endswith","contains","matchespattern"],L=["expand","levels","select","skip","top","count","orderby","filter"],R=/\((.*)\)/,T=/(?!indexof)\((\w+)\)/;var N=(e=>(e.sum="sum",e.min="min",e.max="max",e.average="average",e.countdistinct="countdistinct",e))(N||{});const U=e=>({type:"raw",value:e}),q=e=>({type:"guid",value:e}),D=e=>({type:"duration",value:e}),V=e=>({type:"binary",value:e}),G=e=>({type:"json",value:e}),P=(e,i)=>({type:"alias",name:e,value:i}),X=e=>({type:"decimal",value:e}),b="";function M({select:e,search:i,skiptoken:r,format:n,top:a,skip:$,filter:o,transform:p,orderBy:d,key:j,count:u,expand:y,action:s,func:f}={}){let l="",t=[];const c={};if(j!=null&&(l+=`(${O(j,t)})`),(o||typeof u=="object")&&(c.$filter=E(typeof u=="object"?u:o,t)),p&&(c.$apply=S(p)),y&&(c.$expand=w(y)),d&&(c.$orderby=C(d)),u&&(typeof u=="boolean"?c.$count=!0:l+="/$count"),typeof a=="number"&&(c.$top=a),typeof $=="number"&&(c.$skip=$),s&&(l+=`/${s}`),f){if(typeof f=="string")l+=`/${f}`;else if(typeof f=="object"){const[h]=Object.keys(f),A=O(f[h],t);l+=`/${h}`,A!==""&&(l+=`(${A})`)}}return t.length>0&&Object.assign(c,t.reduce((h,A)=>Object.assign(h,{[`@${A.name}`]:O(A.value)}),{})),i&&(c.$search=encodeURIComponent(i)),W(l,{$select:e,$skiptoken:r,$format:n,...c})}function g(e,i,r=[]){return`${e} eq ${O(i,r)}`}function E(e={},i=[],r=""){return(Array.isArray(e)?e:[e]).reduce(($,o)=>{if(o){const p=n(o,i,r);p&&$.push(p)}return $},[]).join(" and ");function n($={},o=[],p=""){let d="";return typeof $=="string"?d=$:$&&typeof $=="object"&&(d=Object.keys($).reduce((u,y)=>{const s=$[y];if(s===void 0)return u;let f="";if(p?y===b?f=p:T.test(y)?f=y.replace(T,(l,t)=>t.trim()===b?`(${p})`:`(${p}/${t.trim()})`):R.test(y)?f=y.replace(R,(l,t)=>t.trim()===b?`(${p})`:`(${p}/${t.trim()})`):f=`${p}/${y}`:f=y,y===b&&Array.isArray(s))return u.concat(s.map(l=>g(f,l)));if(["number","string","boolean"].indexOf(typeof s)!==-1||s instanceof Date||s===null)u.push(g(f,s,o));else if(Array.isArray(s)){const l=y,t=s.map(c=>E(c,o,p)).filter(c=>c).map(c=>m.indexOf(l)!==-1?`(${c})`:c);t.length&&(m.indexOf(l)!==-1?t.length&&(l==="not"?u.push(_(t)):u.push(`(${t.join(` ${l} `)})`)):u.push(t.join(` ${l} `)))}else if(m.indexOf(f)!==-1){const l=f,t=Object.keys(s).map(c=>n({[c]:s[c]}));t.length&&(l==="not"?u.push(_(t)):u.push(`(${t.join(` ${l} `)})`))}else if(typeof s=="object")"type"in s?u.push(g(f,s,o)):Object.keys(s).forEach(t=>{if(s[t]!==void 0)if(I.indexOf(t)!==-1)u.push(`${f} ${t} ${O(s[t],o)}`);else if(m.indexOf(t)!==-1)Array.isArray(s[t])?u.push(s[t].map(c=>"("+n(c,o,f)+")").join(` ${t} `)):u.push("("+n(s[t],o,f)+")");else if(F.indexOf(t)!==-1){const c=a(y.toLowerCase(),s[t],t,f);c&&u.push(c)}else if(t==="has")u.push(`${f} ${t} ${O(s[t],o)}`);else if(t==="in"){const c=Array.isArray(s[t])?s[t]:s[t].value.map(h=>({type:s[t].type,value:h}));u.push(f+" in ("+c.map(h=>O(h,o)).join(",")+")")}else if(k.indexOf(t)!==-1)u.push(`${t}(${f},${O(s[t],o)})`);else{const c=n({[t]:s[t]},o,f);c&&u.push(c)}});else throw new Error(`Unexpected value type: ${s}`);return u},[]).join(" and ")),d}function a($,o,p,d){let j="";if(typeof o=="string"||o instanceof String)j=J($,o,p,d);else if(o){const u=Array.isArray(o)?o.reduce((s,f)=>f.hasOwnProperty(b)?(s.hasOwnProperty(b)||(s[b]=[]),s[b].push(f[b]),s):{...s,...f},{}):o,y=n(u,i,$);j=`${d}/${p}(${y?`${$}:${y}`:""})`}return j}}function J(e,i,r,n){const a=r=="all"?"ne":"eq";return`${n}/${r}(${e}: ${e} ${a} '${i}')`}function z(e){return e=e.replace(/'/g,"''"),encodeURIComponent(e)}function O(e,i){if(typeof e=="string")return`'${z(e)}'`;if(e instanceof Date)return e.toISOString();if(typeof e=="number")return e;if(Array.isArray(e))return`[${e.map(r=>O(r)).join(",")}]`;if(e===null)return e;if(typeof e=="object")switch(e.type){case"raw":case"guid":return e.value;case"duration":return`duration'${e.value}'`;case"binary":return`binary'${e.value}'`;case"alias":return Array.isArray(i)&&i.push(e),`@${e.name}`;case"json":return escape(JSON.stringify(e.value));case"decimal":return`${e.value}M`;default:return Object.entries(e).filter(([,r])=>r!==void 0).map(([r,n])=>`${r}=${O(n,i)}`).join(",")}return e}function w(e){if(typeof e=="number")return e;if(typeof e=="string")return e.indexOf("/")===-1?e:e.split("/").reverse().reduce((i,r,n,a)=>n===0?`$expand=${r}`:n===a.length-1?`${r}(${i})`:`$expand=${r}(${i})`,"");if(Array.isArray(e))return`${e.map(i=>w(i)).join(",")}`;if(typeof e=="object"){const i=Object.keys(e);return i.some(r=>L.indexOf(r.toLowerCase())!==-1)?i.map(r=>{let n;switch(r){case"filter":n=E(e[r]);break;case"orderBy":n=C(e[r]);break;case"levels":case"count":case"skip":case"top":n=`${e[r]}`;break;default:n=w(e[r])}return`$${r.toLowerCase()}=${n}`}).join(";"):i.map(r=>{const n=w(e[r]);return n?`${r}(${n})`:r}).join(",")}return""}function S(e){return(Array.isArray(e)?e:[e]).reduce((n,a)=>{for(const $ of Object.keys(a))switch($){case"aggregate":{const o=a[$];o&&n.push(`aggregate(${H(o)})`);break}case"filter":{const o=a[$];if(o){const p=E(o);p&&n.push(`filter(${p})`)}break}case"groupBy":{const o=a[$];o&&n.push(`groupby(${Q(o)})`);break}default:throw new Error(`Unsupported transform: ${$}`)}return n},[]).join("/")||void 0}function H(e){return(Array.isArray(e)?e:[e]).map(r=>typeof r=="string"?r:Object.keys(r).map(n=>{const a=r[n];if(!a.with&&a.as)return`${n} as ${a.as}`;if(!a.with)throw new Error(`'with' property required for '${n}'`);if(!a.as)throw new Error(`'as' property required for '${n}'`);return`${n} with ${a.with} as ${a.as}`})).join(",")}function Q(e){if(!e.properties)throw new Error("'properties' property required for groupBy");let i=`(${e.properties.join(",")})`;return e.transform&&(i+=`,${S(e.transform)}`),i}function C(e,i=""){return Array.isArray(e)?e.map(r=>Array.isArray(r)&&r.length===2&&["asc","desc"].indexOf(r[1])!==-1?r.join(" "):r).map(r=>`${i}${String(r)}`).join(","):typeof e=="object"?Object.entries(e).map(([r,n])=>C(n,`${r}/`)).map(r=>`${i}${r}`).join(","):`${i}${String(e)}`}function W(e,i){const r=Object.getOwnPropertyNames(i).filter(n=>i[n]!==void 0&&i[n]!=="").map(n=>`${n}=${i[n]}`);return r.length?`${e}?${r.join("&")}`:e}function _(e){return`not (${e.join(" and ")})`}exports.ITEM_ROOT=b;exports.StandardAggregateMethods=N;exports.alias=P;exports.binary=V;exports.decimal=X;exports.default=M;exports.duration=D;exports.guid=q;exports.json=G;exports.raw=U; |
+82
-82
@@ -1,2 +0,2 @@ | ||
| const g = ["eq", "ne", "gt", "ge", "lt", "le"], m = ["and", "or", "not"], S = ["any", "all"], k = ["startswith", "endswith", "contains", "matchespattern"], L = [ | ||
| const S = ["eq", "ne", "gt", "ge", "lt", "le"], m = ["and", "or", "not"], F = ["any", "all"], I = ["startswith", "endswith", "contains", "matchespattern"], k = [ | ||
| "expand", | ||
@@ -10,8 +10,8 @@ "levels", | ||
| "filter" | ||
| ], N = /\((.*)\)/, F = /(?!indexof)\((\w+)\)/; | ||
| var q = /* @__PURE__ */ ((e) => (e.sum = "sum", e.min = "min", e.max = "max", e.average = "average", e.countdistinct = "countdistinct", e))(q || {}); | ||
| const X = (e) => ({ type: "raw", value: e }), P = (e) => ({ type: "guid", value: e }), J = (e) => ({ type: "duration", value: e }), x = (e) => ({ type: "binary", value: e }), z = (e) => ({ type: "json", value: e }), B = (e, o) => ({ type: "alias", name: e, value: o }), H = (e) => ({ type: "decimal", value: e }), h = ""; | ||
| function Q({ | ||
| ], g = /\((.*)\)/, N = /(?!indexof)\((\w+)\)/; | ||
| var L = /* @__PURE__ */ ((e) => (e.sum = "sum", e.min = "min", e.max = "max", e.average = "average", e.countdistinct = "countdistinct", e))(L || {}); | ||
| const X = (e) => ({ type: "raw", value: e }), P = (e) => ({ type: "guid", value: e }), J = (e) => ({ type: "duration", value: e }), x = (e) => ({ type: "binary", value: e }), z = (e) => ({ type: "json", value: e }), H = (e, i) => ({ type: "alias", name: e, value: i }), Q = (e) => ({ type: "decimal", value: e }), h = ""; | ||
| function W({ | ||
| select: e, | ||
| search: o, | ||
| search: i, | ||
| skiptoken: r, | ||
@@ -21,3 +21,3 @@ format: n, | ||
| skip: $, | ||
| filter: s, | ||
| filter: o, | ||
| transform: p, | ||
@@ -28,3 +28,3 @@ orderBy: O, | ||
| expand: y, | ||
| action: i, | ||
| action: s, | ||
| func: c | ||
@@ -34,3 +34,3 @@ } = {}) { | ||
| const f = {}; | ||
| if (d != null && (l += `(${b(d, t)})`), (s || typeof u == "object") && (f.$filter = E(typeof u == "object" ? u : s, t)), p && (f.$apply = _(p)), y && (f.$expand = w(y)), O && (f.$orderby = R(O)), u && (typeof u == "boolean" ? f.$count = !0 : l += "/$count"), typeof a == "number" && (f.$top = a), typeof $ == "number" && (f.$skip = $), i && (l += `/${i}`), c) { | ||
| if (d != null && (l += `(${b(d, t)})`), (o || typeof u == "object") && (f.$filter = E(typeof u == "object" ? u : o, t)), p && (f.$apply = _(p)), y && (f.$expand = w(y)), O && (f.$orderby = R(O)), u && (typeof u == "boolean" ? f.$count = !0 : l += "/$count"), typeof a == "number" && (f.$top = a), typeof $ == "number" && (f.$skip = $), s && (l += `/${s}`), c) { | ||
| if (typeof c == "string") | ||
@@ -46,11 +46,11 @@ l += `/${c}`; | ||
| {} | ||
| )), G(l, { $select: e, $search: o, $skiptoken: r, $format: n, ...f }); | ||
| )), i && (f.$search = encodeURIComponent(i)), G(l, { $select: e, $skiptoken: r, $format: n, ...f }); | ||
| } | ||
| function C(e, o, r = []) { | ||
| return `${e} eq ${b(o, r)}`; | ||
| function C(e, i, r = []) { | ||
| return `${e} eq ${b(i, r)}`; | ||
| } | ||
| function E(e = {}, o = [], r = "") { | ||
| return (Array.isArray(e) ? e : [e]).reduce(($, s) => { | ||
| if (s) { | ||
| const p = n(s, o, r); | ||
| function E(e = {}, i = [], r = "") { | ||
| return (Array.isArray(e) ? e : [e]).reduce(($, o) => { | ||
| if (o) { | ||
| const p = n(o, i, r); | ||
| p && $.push(p); | ||
@@ -60,50 +60,50 @@ } | ||
| }, []).join(" and "); | ||
| function n($ = {}, s = [], p = "") { | ||
| function n($ = {}, o = [], p = "") { | ||
| let O = ""; | ||
| return typeof $ == "string" ? O = $ : $ && typeof $ == "object" && (O = Object.keys($).reduce( | ||
| (u, y) => { | ||
| const i = $[y]; | ||
| if (i === void 0) | ||
| const s = $[y]; | ||
| if (s === void 0) | ||
| return u; | ||
| let c = ""; | ||
| if (p ? y === h ? c = p : F.test(y) ? c = y.replace(F, (l, t) => t.trim() === h ? `(${p})` : `(${p}/${t.trim()})`) : N.test(y) ? c = y.replace(N, (l, t) => t.trim() === h ? `(${p})` : `(${p}/${t.trim()})`) : c = `${p}/${y}` : c = y, y === h && Array.isArray(i)) | ||
| if (p ? y === h ? c = p : N.test(y) ? c = y.replace(N, (l, t) => t.trim() === h ? `(${p})` : `(${p}/${t.trim()})`) : g.test(y) ? c = y.replace(g, (l, t) => t.trim() === h ? `(${p})` : `(${p}/${t.trim()})`) : c = `${p}/${y}` : c = y, y === h && Array.isArray(s)) | ||
| return u.concat( | ||
| i.map((l) => C(c, l)) | ||
| s.map((l) => C(c, l)) | ||
| ); | ||
| if (["number", "string", "boolean"].indexOf(typeof i) !== -1 || i instanceof Date || i === null) | ||
| u.push(C(c, i, s)); | ||
| else if (Array.isArray(i)) { | ||
| const l = y, t = i.map((f) => E(f, s, p)).filter((f) => f).map((f) => m.indexOf(l) !== -1 ? `(${f})` : f); | ||
| if (["number", "string", "boolean"].indexOf(typeof s) !== -1 || s instanceof Date || s === null) | ||
| u.push(C(c, s, o)); | ||
| else if (Array.isArray(s)) { | ||
| const l = y, t = s.map((f) => E(f, o, p)).filter((f) => f).map((f) => m.indexOf(l) !== -1 ? `(${f})` : f); | ||
| t.length && (m.indexOf(l) !== -1 ? t.length && (l === "not" ? u.push(T(t)) : u.push(`(${t.join(` ${l} `)})`)) : u.push(t.join(` ${l} `))); | ||
| } else if (m.indexOf(c) !== -1) { | ||
| const l = c, t = Object.keys(i).map( | ||
| (f) => n({ [f]: i[f] }) | ||
| const l = c, t = Object.keys(s).map( | ||
| (f) => n({ [f]: s[f] }) | ||
| ); | ||
| t.length && (l === "not" ? u.push(T(t)) : u.push(`(${t.join(` ${l} `)})`)); | ||
| } else if (typeof i == "object") | ||
| "type" in i ? u.push(C(c, i, s)) : Object.keys(i).forEach((t) => { | ||
| if (i[t] !== void 0) | ||
| if (g.indexOf(t) !== -1) | ||
| u.push(`${c} ${t} ${b(i[t], s)}`); | ||
| } else if (typeof s == "object") | ||
| "type" in s ? u.push(C(c, s, o)) : Object.keys(s).forEach((t) => { | ||
| if (s[t] !== void 0) | ||
| if (S.indexOf(t) !== -1) | ||
| u.push(`${c} ${t} ${b(s[t], o)}`); | ||
| else if (m.indexOf(t) !== -1) | ||
| Array.isArray(i[t]) ? u.push( | ||
| i[t].map((f) => "(" + n(f, s, c) + ")").join(` ${t} `) | ||
| ) : u.push("(" + n(i[t], s, c) + ")"); | ||
| else if (S.indexOf(t) !== -1) { | ||
| const f = a(y.toLowerCase(), i[t], t, c); | ||
| Array.isArray(s[t]) ? u.push( | ||
| s[t].map((f) => "(" + n(f, o, c) + ")").join(` ${t} `) | ||
| ) : u.push("(" + n(s[t], o, c) + ")"); | ||
| else if (F.indexOf(t) !== -1) { | ||
| const f = a(y.toLowerCase(), s[t], t, c); | ||
| f && u.push(f); | ||
| } else if (t === "has") | ||
| u.push(`${c} ${t} ${b(i[t], s)}`); | ||
| u.push(`${c} ${t} ${b(s[t], o)}`); | ||
| else if (t === "in") { | ||
| const f = Array.isArray(i[t]) ? i[t] : i[t].value.map((j) => ({ | ||
| type: i[t].type, | ||
| const f = Array.isArray(s[t]) ? s[t] : s[t].value.map((j) => ({ | ||
| type: s[t].type, | ||
| value: j | ||
| })); | ||
| u.push( | ||
| c + " in (" + f.map((j) => b(j, s)).join(",") + ")" | ||
| c + " in (" + f.map((j) => b(j, o)).join(",") + ")" | ||
| ); | ||
| } else if (k.indexOf(t) !== -1) | ||
| u.push(`${t}(${c},${b(i[t], s)})`); | ||
| } else if (I.indexOf(t) !== -1) | ||
| u.push(`${t}(${c},${b(s[t], o)})`); | ||
| else { | ||
| const f = n({ [t]: i[t] }, s, c); | ||
| const f = n({ [t]: s[t] }, o, c); | ||
| f && u.push(f); | ||
@@ -113,3 +113,3 @@ } | ||
| else | ||
| throw new Error(`Unexpected value type: ${i}`); | ||
| throw new Error(`Unexpected value type: ${s}`); | ||
| return u; | ||
@@ -120,8 +120,8 @@ }, | ||
| } | ||
| function a($, s, p, O) { | ||
| function a($, o, p, O) { | ||
| let d = ""; | ||
| if (typeof s == "string" || s instanceof String) | ||
| d = I($, s, p, O); | ||
| else if (s) { | ||
| const u = Array.isArray(s) ? s.reduce((i, c) => c.hasOwnProperty(h) ? (i.hasOwnProperty(h) || (i[h] = []), i[h].push(c[h]), i) : { ...i, ...c }, {}) : s, y = n(u, o, $); | ||
| if (typeof o == "string" || o instanceof String) | ||
| d = U($, o, p, O); | ||
| else if (o) { | ||
| const u = Array.isArray(o) ? o.reduce((s, c) => c.hasOwnProperty(h) ? (s.hasOwnProperty(h) || (s[h] = []), s[h].push(c[h]), s) : { ...s, ...c }, {}) : o, y = n(u, i, $); | ||
| d = `${O}/${p}(${y ? `${$}:${y}` : ""})`; | ||
@@ -132,12 +132,12 @@ } | ||
| } | ||
| function I(e, o, r, n) { | ||
| function U(e, i, r, n) { | ||
| const a = r == "all" ? "ne" : "eq"; | ||
| return `${n}/${r}(${e}: ${e} ${a} '${o}')`; | ||
| return `${n}/${r}(${e}: ${e} ${a} '${i}')`; | ||
| } | ||
| function U(e) { | ||
| return e = e.replace(/%/g, "%25"), e = e.replace(/\+/g, "%2B"), e = e.replace(/\//g, "%2F"), e = e.replace(/\?/g, "%3F"), e = e.replace(/#/g, "%23"), e = e.replace(/&/g, "%26"), e = e.replace(/'/g, "''"), e; | ||
| function q(e) { | ||
| return e = e.replace(/'/g, "''"), encodeURIComponent(e); | ||
| } | ||
| function b(e, o) { | ||
| function b(e, i) { | ||
| if (typeof e == "string") | ||
| return `'${U(e)}'`; | ||
| return `'${q(e)}'`; | ||
| if (e instanceof Date) | ||
@@ -161,3 +161,3 @@ return e.toISOString(); | ||
| case "alias": | ||
| return Array.isArray(o) && o.push(e), `@${e.name}`; | ||
| return Array.isArray(i) && i.push(e), `@${e.name}`; | ||
| case "json": | ||
@@ -168,3 +168,3 @@ return escape(JSON.stringify(e.value)); | ||
| default: | ||
| return Object.entries(e).filter(([, r]) => r !== void 0).map(([r, n]) => `${r}=${b(n, o)}`).join(","); | ||
| return Object.entries(e).filter(([, r]) => r !== void 0).map(([r, n]) => `${r}=${b(n, i)}`).join(","); | ||
| } | ||
@@ -177,10 +177,10 @@ return e; | ||
| if (typeof e == "string") | ||
| return e.indexOf("/") === -1 ? e : e.split("/").reverse().reduce((o, r, n, a) => n === 0 ? `$expand=${r}` : n === a.length - 1 ? `${r}(${o})` : `$expand=${r}(${o})`, ""); | ||
| return e.indexOf("/") === -1 ? e : e.split("/").reverse().reduce((i, r, n, a) => n === 0 ? `$expand=${r}` : n === a.length - 1 ? `${r}(${i})` : `$expand=${r}(${i})`, ""); | ||
| if (Array.isArray(e)) | ||
| return `${e.map((o) => w(o)).join(",")}`; | ||
| return `${e.map((i) => w(i)).join(",")}`; | ||
| if (typeof e == "object") { | ||
| const o = Object.keys(e); | ||
| return o.some( | ||
| (r) => L.indexOf(r.toLowerCase()) !== -1 | ||
| ) ? o.map((r) => { | ||
| const i = Object.keys(e); | ||
| return i.some( | ||
| (r) => k.indexOf(r.toLowerCase()) !== -1 | ||
| ) ? i.map((r) => { | ||
| let n; | ||
@@ -204,3 +204,3 @@ switch (r) { | ||
| return `$${r.toLowerCase()}=${n}`; | ||
| }).join(";") : o.map((r) => { | ||
| }).join(";") : i.map((r) => { | ||
| const n = w(e[r]); | ||
@@ -221,10 +221,10 @@ return n ? `${r}(${n})` : r; | ||
| case "aggregate": { | ||
| const s = a[$]; | ||
| s && n.push(`aggregate(${D(s)})`); | ||
| const o = a[$]; | ||
| o && n.push(`aggregate(${D(o)})`); | ||
| break; | ||
| } | ||
| case "filter": { | ||
| const s = a[$]; | ||
| if (s) { | ||
| const p = E(s); | ||
| const o = a[$]; | ||
| if (o) { | ||
| const p = E(o); | ||
| p && n.push(`filter(${p})`); | ||
@@ -235,4 +235,4 @@ } | ||
| case "groupBy": { | ||
| const s = a[$]; | ||
| s && n.push(`groupby(${V(s)})`); | ||
| const o = a[$]; | ||
| o && n.push(`groupby(${V(o)})`); | ||
| break; | ||
@@ -261,12 +261,12 @@ } | ||
| throw new Error("'properties' property required for groupBy"); | ||
| let o = `(${e.properties.join(",")})`; | ||
| return e.transform && (o += `,${_(e.transform)}`), o; | ||
| let i = `(${e.properties.join(",")})`; | ||
| return e.transform && (i += `,${_(e.transform)}`), i; | ||
| } | ||
| function R(e, o = "") { | ||
| function R(e, i = "") { | ||
| return Array.isArray(e) ? e.map( | ||
| (r) => Array.isArray(r) && r.length === 2 && ["asc", "desc"].indexOf(r[1]) !== -1 ? r.join(" ") : r | ||
| ).map((r) => `${o}${String(r)}`).join(",") : typeof e == "object" ? Object.entries(e).map(([r, n]) => R(n, `${r}/`)).map((r) => `${o}${r}`).join(",") : `${o}${String(e)}`; | ||
| ).map((r) => `${i}${String(r)}`).join(",") : typeof e == "object" ? Object.entries(e).map(([r, n]) => R(n, `${r}/`)).map((r) => `${i}${r}`).join(",") : `${i}${String(e)}`; | ||
| } | ||
| function G(e, o) { | ||
| const r = Object.getOwnPropertyNames(o).filter((n) => o[n] !== void 0 && o[n] !== "").map((n) => `${n}=${o[n]}`); | ||
| function G(e, i) { | ||
| const r = Object.getOwnPropertyNames(i).filter((n) => i[n] !== void 0 && i[n] !== "").map((n) => `${n}=${i[n]}`); | ||
| return r.length ? `${e}?${r.join("&")}` : e; | ||
@@ -279,7 +279,7 @@ } | ||
| h as ITEM_ROOT, | ||
| q as StandardAggregateMethods, | ||
| B as alias, | ||
| L as StandardAggregateMethods, | ||
| H as alias, | ||
| x as binary, | ||
| H as decimal, | ||
| Q as default, | ||
| Q as decimal, | ||
| W as default, | ||
| J as duration, | ||
@@ -286,0 +286,0 @@ P as guid, |
+1
-1
| { | ||
| "name": "odata-query", | ||
| "description": "OData v4 query builder that uses a simple object-based syntax similar to MongoDB and js-data", | ||
| "version": "8.0.5", | ||
| "version": "8.0.6", | ||
| "author": "Sean Lynch <techniq35@gmail.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
36756
-0.6%402
-0.25%