@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines (2 loc) • 6.25 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("kendo.core.js")):"function"==typeof define&&define.amd?define(["exports","kendo.core.min"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.DataOdata={}))}(this,(function(e){!function(e){var t=window.kendo,n=e.extend,a="\r\n",o="\r\n\r\n",r=t.isFunction,s={eq:"eq",neq:"ne",gt:"gt",gte:"ge",lt:"lt",lte:"le",contains:"substringof",doesnotcontain:"substringof",endswith:"endswith",startswith:"startswith",isnull:"eq",isnotnull:"ne",isnullorempty:"eq",isnotnullorempty:"ne",isempty:"eq",isnotempty:"ne"},d=n({},s,{contains:"contains"}),i={pageSize:e.noop,page:e.noop,filter:function(e,t,n){t&&(t=l(t,n))&&(e.$filter=t)},sort:function(t,n){var a=e.map(n,(function(e){var t=e.field.replace(/\./g,"/");return"desc"===e.dir&&(t+=" desc"),t})).join(",");a&&(t.$orderby=a)},skip:function(e,t){t&&(e.$skip=t)},take:function(e,t){t&&(e.$top=t)}},p={read:{dataType:"jsonp"}};function l(e,n){var a,o,r,i,p,c,u,f,y=[],h=e.logic||"and",g=e.filters;for(a=0,o=g.length;a<o;a++)r=(e=g[a]).field,u=e.value,c=e.operator,e.filters?e=l(e,n):(f=e.ignoreCase,r=r.replace(/\./g,"/"),e=s[c],n&&(e=d[c]),"isnullorempty"===c?e=t.format("({0} {1} null or {0} {1} '')",r,e):"isnotnullorempty"===c?e=t.format("({0} {1} null and {0} {1} '')",r,e):"isnull"===c||"isnotnull"===c?e=t.format("{0} {1} null",r,e):"isempty"===c||"isnotempty"===c?e=t.format("{0} {1} ''",r,e):e&&undefined!==u&&("string"===(i=t.type(u))?(p="'{1}'",u=u.replace(/'/g,"''"),!0===f&&(r="tolower("+r+")")):"date"===i?n?(p="{1:yyyy-MM-ddTHH:mm:ss+00:00}",u=t.timezone.apply(u,"Etc/UTC")):p="datetime'{1:yyyy-MM-ddTHH:mm:ss}'":p="{1}",e.length>3?"substringof"!==e?p="{0}({2},"+p+")":(p="{0}("+p+",{2})","doesnotcontain"===c&&(n?(p="{0}({2},'{1}') eq -1",e="indexof"):p+=" eq false")):p="{2} {0} "+p,e=t.format(p,e,u,r))),y.push(e);return e=y.join(" "+h+" "),y.length>1&&(e="("+e+")"),e}function c(e){for(var t in e)0===t.indexOf("@odata")&&delete e[t]}function u(){return Math.floor(65536*(1+Math.random())).toString(16).substr(1)}function f(e){return e+u()+"-"+u()+"-"+u()}function y(e,t){var n="\r\n--"+e;return t&&(n+="--"),n}function h(e,n,a,o){var s=e.options[o].url,d=t.format("{0} ",a);return r(s)?d+s(n):d+s}function g(e,t){var n="";return n+=y(e,!1),n+="\r\nContent-Type: application/http",n+="\r\nContent-Transfer-Encoding: binary",n+="\r\nContent-ID: "+t}function m(e,n,r,s,d,i,p){var l="";return l+=function(e,t){var n="";return n+="--"+e+a,n+="Content-Type: multipart/mixed; boundary="+t+a,n}(n,r),l+=function(e,n,r,s,d,i){for(var p,l,c="",u=0;u<e.length;u++)c+=g(n,r),c+=o+h(d,e[u],d.options[s].type,s)+" HTTP/1.1",i||(c+=(p=e[u],l=void 0,l="",l+="\r\nContent-Type: application/json;odata=minimalmetadata",l+="\r\nPrefer: return=representation",l+=o+t.stringify(p))),c+=a,r++;return c}(e,r,s,i,d,p),l+=y(r,!0),l+=a}n(!0,t.data,{schemas:{odata:{type:"json",data:function(e){return e.d.results||[e.d]},total:"d.__count"}},transports:{odata:{read:{cache:!0,dataType:"jsonp",jsonp:"$callback"},update:{cache:!0,dataType:"json",contentType:"application/json",type:"PUT"},create:{cache:!0,dataType:"json",contentType:"application/json",type:"POST"},destroy:{cache:!0,dataType:"json",type:"DELETE"},parameterMap:function(e,n,a){var o,r,s,d;if(e=e||{},n=n||"read",d=(d=(this.options||p)[n])?d.dataType:"json","read"===n)for(s in o={$inlinecount:"allpages"},"json"!=d&&(o.$format="json"),e)i[s]?i[s](o,e[s],a):o[s]=e[s];else{if("json"!==d)throw new Error("Only json dataType can be used for "+n+" operation.");if("destroy"!==n){for(s in e)"number"==typeof(r=e[s])&&(e[s]=r+"");o=t.stringify(e)}}return o}}}}),n(!0,t.data,{schemas:{"odata-v4":{type:"json",data:function(t){if(Array.isArray(t)){for(var n=0;n<t.length;n++)c(t[n]);return t}return c(t=e.extend({},t)),t.value?t.value:[t]},total:function(e){return e["@odata.count"]}}},transports:{"odata-v4":{batch:{type:"POST"},read:{cache:!0,dataType:"json"},update:{cache:!0,dataType:"json",contentType:"application/json;IEEE754Compatible=true",type:"PUT"},create:{cache:!0,dataType:"json",contentType:"application/json;IEEE754Compatible=true",type:"POST"},destroy:{cache:!0,dataType:"json",type:"DELETE"},parameterMap:function(e,n){var a=t.data.transports.odata.parameterMap(e,n,!0);return"read"==n&&(a.$count=!0,delete a.$inlinecount),a&&a.$filter&&(a.$filter=a.$filter.replace(/('[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')/gi,(function(e){return e.substring(1,e.length-1)}))),a},submit:function(a){var o=function(e,t){var a=n({},e.options.batch),o=f("sf_batch_"),s="",d=0,i=e.options.batch.url,p=f("sf_changeset_");return a.type=e.options.batch.type,a.url=r(i)?i():i,a.headers=n(a.headers||{},{"Content-Type":"multipart/mixed; boundary="+o}),t.updated.length&&(s+=m(t.updated,o,p,d,e,"update",!1),d+=t.updated.length,p=f("sf_changeset_")),t.destroyed.length&&(s+=m(t.destroyed,o,p,d,e,"destroy",!0),d+=t.destroyed.length,p=f("sf_changeset_")),t.created.length&&(s+=m(t.created,o,p,d,e,"create",!1)),s+=y(o,!0),a.data=s,a}(this,a.data),s=a.data;(s.updated.length||s.destroyed.length||s.created.length)&&e.ajax(n(!0,{},{success:function(e){var n,o=function(e){var n,a,o,r,s,d=e.match(/--changesetresponse_[a-z0-9-]+$/gm),i=0,p=[];p.push({models:[],passed:!0});for(var l=0;l<d.length;l++)(r=d[l]).lastIndexOf("--",r.length-1)?l<d.length-1&&p.push({models:[],passed:!0}):(i=i?e.indexOf(r,i+r.length):e.indexOf(r),a=(n=e.substring(i,e.indexOf("--",i+1))).match(/^HTTP\/1\.\d (\d{3}) (.*)$/gm).pop(),(o=t.parseFloat(a.match(/\d{3}/g).pop()))>=200&&o<=299?(s=n.match(/\{.*\}/gm))&&p[p.length-1].models.push(JSON.parse(s[0])):p[p.length-1].passed=!1);return p}(e),r=0;s.updated.length&&((n=o[r]).passed&&a.success(n.models.length?n.models:[],"update"),r++),s.destroyed.length&&((n=o[r]).passed&&a.success([],"destroy"),r++),s.created.length&&(n=o[r]).passed&&a.success(n.models,"create")},error:function(e,t,n){a.error(e,t,n)}},o))}}}})}(window.kendo.jQuery);var t=kendo;e.__meta__={id:"data.odata",name:"OData",category:"framework",depends:["core"],hidden:!0},e.default=t,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=kendo.data.odata.min.js.map