kendo-ui-core
Version:
3 lines (2 loc) • 6.09 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kendo.core.js")):"function"==typeof define&&define.amd?define(["kendo.core.min"],t):((e="undefined"!=typeof globalThis?globalThis:e||self).kendodata=e.kendodata||{},e.kendodata.odata=e.kendodata.odata||{},e.kendodata.odata.js=t())}(this,(function(){return function(e,t){var n=window.kendo,a=e.extend,o="\r\n",r="\r\n\r\n",s=n.isFunction,d={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"},i=a({},d,{contains:"contains"}),p={pageSize:e.noop,page:e.noop,filter:function(e,t,n){t&&(t=c(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)}},u={read:{dataType:"jsonp"}};function c(e,t){var a,o,r,s,p,u,l,f,y=[],h=e.logic||"and",g=e.filters;for(a=0,o=g.length;a<o;a++)r=(e=g[a]).field,l=e.value,u=e.operator,e.filters?e=c(e,t):(f=e.ignoreCase,r=r.replace(/\./g,"/"),e=d[u],t&&(e=i[u]),"isnullorempty"===u?e=n.format("{0} {1} null or {0} {1} ''",r,e):"isnotnullorempty"===u?e=n.format("{0} {1} null and {0} {1} ''",r,e):"isnull"===u||"isnotnull"===u?e=n.format("{0} {1} null",r,e):"isempty"===u||"isnotempty"===u?e=n.format("{0} {1} ''",r,e):e&&undefined!==l&&("string"===(s=n.type(l))?(p="'{1}'",l=l.replace(/'/g,"''"),!0===f&&(r="tolower("+r+")")):"date"===s?t?(p="{1:yyyy-MM-ddTHH:mm:ss+00:00}",l=n.timezone.apply(l,"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"===u&&(t?(p="{0}({2},'{1}') eq -1",e="indexof"):p+=" eq false")):p="{2} {0} "+p,e=n.format(p,e,l,r))),y.push(e);return e=y.join(" "+h+" "),y.length>1&&(e="("+e+")"),e}function l(e){for(var t in e)0===t.indexOf("@odata")&&delete e[t]}function f(){return Math.floor(65536*(1+Math.random())).toString(16).substr(1)}function y(e){return e+f()+"-"+f()+"-"+f()}function h(e,t){var n=o+"--"+e;return t&&(n+="--"),n}function g(e,t,a,o){var r=e.options[o].url,d=n.format("{0} ",a);return s(r)?d+r(t):d+r}function m(e,t){var n="";return n+=h(e,!1),n+=o+"Content-Type: application/http",n+=o+"Content-Transfer-Encoding: binary",n+=o+"Content-ID: "+t}function T(e,t,a,s,d,i,p){var u="";return u+=function(e,t){var n="";return n+="--"+e+o,n+="Content-Type: multipart/mixed; boundary="+t+o,n}(t,a),u+=function(e,t,a,s,d,i){for(var p,u,c="",l=0;l<e.length;l++)c+=m(t,a),c+=r+g(d,e[l],d.options[s].type,s)+" HTTP/1.1",i||(c+=(p=e[l],u=void 0,u="",u+=o+"Content-Type: application/json;odata=minimalmetadata",u+=o+"Prefer: return=representation",u+=r+n.stringify(p))),c+=o,a++;return c}(e,a,s,i,d,p),u+=h(a,!0),u+=o}a(!0,n.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,t,a){var o,r,s,d;if(e=e||{},t=t||"read",d=(d=(this.options||u)[t])?d.dataType:"json","read"===t)for(s in o={$inlinecount:"allpages"},"json"!=d&&(o.$format="json"),e)p[s]?p[s](o,e[s],a):o[s]=e[s];else{if("json"!==d)throw new Error("Only json dataType can be used for "+t+" operation.");if("destroy"!==t){for(s in e)"number"==typeof(r=e[s])&&(e[s]=r+"");o=n.stringify(e)}}return o}}}}),a(!0,n.data,{schemas:{"odata-v4":{type:"json",data:function(t){if(Array.isArray(t)){for(var n=0;n<t.length;n++)l(t[n]);return t}return l(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,t){var a=n.data.transports.odata.parameterMap(e,t,!0);return"read"==t&&(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(t){var o=function(e,t){var n=a({},e.options.batch),o=y("sf_batch_"),r="",d=0,i=e.options.batch.url,p=y("sf_changeset_");return n.type=e.options.batch.type,n.url=s(i)?i():i,n.headers=a(n.headers||{},{"Content-Type":"multipart/mixed; boundary="+o}),t.updated.length&&(r+=T(t.updated,o,p,d,e,"update",!1),d+=t.updated.length,p=y("sf_changeset_")),t.destroyed.length&&(r+=T(t.destroyed,o,p,d,e,"destroy",!0),d+=t.destroyed.length,p=y("sf_changeset_")),t.created.length&&(r+=T(t.created,o,p,d,e,"create",!1)),r+=h(o,!0),n.data=r,n}(this,t.data),r=t.data;(r.updated.length||r.destroyed.length||r.created.length)&&e.ajax(a(!0,{},{success:function(e){var a,o=function(e){var t,a,o,r,s,d=e.match(/--changesetresponse_[a-z0-9-]+$/gm),i=0,p=[];p.push({models:[],passed:!0});for(var u=0;u<d.length;u++)(r=d[u]).lastIndexOf("--",r.length-1)?u<d.length-1&&p.push({models:[],passed:!0}):(i=i?e.indexOf(r,i+r.length):e.indexOf(r),a=(t=e.substring(i,e.indexOf("--",i+1))).match(/^HTTP\/1\.\d (\d{3}) (.*)$/gm).pop(),(o=n.parseFloat(a.match(/\d{3}/g).pop()))>=200&&o<=299?(s=t.match(/\{.*\}/gm))&&p[p.length-1].models.push(JSON.parse(s[0])):p[p.length-1].passed=!1);return p}(e),s=0;r.updated.length&&((a=o[s]).passed&&t.success(a.models.length?a.models:[],"update"),s++),r.destroyed.length&&((a=o[s]).passed&&t.success([],"destroy"),s++),r.created.length&&(a=o[s]).passed&&t.success(a.models,"create")},error:function(e,n,a){t.error(e,n,a)}},o))}}}})}(window.kendo.jQuery),kendo}));
//# sourceMappingURL=kendo.data.odata.min.js.map