ofsc-utility 1.0.13 → 1.0.15

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.
@@ -1,2 +1 @@
1
- !function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.downloadAllEventsOfDayCSV=exports.downloadAllEventsOfDay=exports.getActivityCustomerInventories=exports.createActivityCustomerInventories=exports.getAllActivities=exports.getActivitybyId=exports.updateCreateInventoryType=exports.getInventoryTypesDetail=exports.downloadAllInventoryTypesCSV=exports.generateUsersCollaborationCSV=exports.downloadAllUsersCSV=exports.downloadAllResourcesCSV=exports.downloadWorkZoneCSV=exports.getOAuthToken=exports.generateAllOnHandInventoryOfAllResourcesCSV=exports.WorkZone=exports.Utilities=exports.User=exports.Resource=exports.OauthTokenService=exports.InventoryType=exports.Inventory=exports.Events=exports.ActivityInventories=exports.Activity=void 0;const e=require("tslib");exports.Activity=e.__importStar(require("./activities")),exports.ActivityInventories=e.__importStar(require("./activityInventories")),exports.Events=e.__importStar(require("./events")),exports.Inventory=e.__importStar(require("./inventory")),exports.InventoryType=e.__importStar(require("./inventoryTypes")),exports.OauthTokenService=e.__importStar(require("./oauthTokenService")),exports.Resource=e.__importStar(require("./resources")),exports.User=e.__importStar(require("./users")),exports.Utilities=e.__importStar(require("./utilities")),exports.WorkZone=e.__importStar(require("./workZones")),e.__exportStar(require("./types"),exports);var t=require("./inventory");Object.defineProperty(exports,"generateAllOnHandInventoryOfAllResourcesCSV",{enumerable:!0,get:function(){return t.generateAllOnHandInventoryOfAllResourcesCSV}});var r=require("./oauthTokenService");Object.defineProperty(exports,"getOAuthToken",{enumerable:!0,get:function(){return r.getOAuthToken}});var o=require("./workZones");Object.defineProperty(exports,"downloadWorkZoneCSV",{enumerable:!0,get:function(){return o.downloadWorkZoneCSV}});var n=require("./resources");Object.defineProperty(exports,"downloadAllResourcesCSV",{enumerable:!0,get:function(){return n.downloadAllResourcesCSV}});var i=require("./users");Object.defineProperty(exports,"downloadAllUsersCSV",{enumerable:!0,get:function(){return i.downloadAllUsersCSV}}),Object.defineProperty(exports,"generateUsersCollaborationCSV",{enumerable:!0,get:function(){return i.generateUsersCollaborationCSV}});var s=require("./inventoryTypes");Object.defineProperty(exports,"downloadAllInventoryTypesCSV",{enumerable:!0,get:function(){return s.downloadAllInventoryTypesCSV}}),Object.defineProperty(exports,"getInventoryTypesDetail",{enumerable:!0,get:function(){return s.getInventoryTypesDetail}}),Object.defineProperty(exports,"updateCreateInventoryType",{enumerable:!0,get:function(){return s.updateCreateInventoryType}});var l=require("./activities");Object.defineProperty(exports,"getActivitybyId",{enumerable:!0,get:function(){return l.getActivitybyId}}),Object.defineProperty(exports,"getAllActivities",{enumerable:!0,get:function(){return l.getAllActivities}});var a=require("./activityInventories");Object.defineProperty(exports,"createActivityCustomerInventories",{enumerable:!0,get:function(){return a.createActivityCustomerInventories}}),Object.defineProperty(exports,"getActivityCustomerInventories",{enumerable:!0,get:function(){return a.getActivityCustomerInventories}});var u=require("./events");Object.defineProperty(exports,"downloadAllEventsOfDay",{enumerable:!0,get:function(){return u.downloadAllEventsOfDay}}),Object.defineProperty(exports,"downloadAllEventsOfDayCSV",{enumerable:!0,get:function(){return u.downloadAllEventsOfDayCSV}});const v={getOAuthToken:require("./oauthTokenService").getOAuthToken,downloadWorkZoneCSV:require("./workZones").downloadWorkZoneCSV,downloadAllResourcesCSV:require("./resources").downloadAllResourcesCSV,downloadAllUsersCSV:require("./resources").downloadAllUsersCSV,downloadAllInventoryTypesCSV:require("./inventoryTypes").downloadAllInventoryTypesCSV,getInventoryTypesDetail:require("./inventoryTypes").getInventoryTypesDetail,updateInventoryType:require("./inventoryTypes").updateInventoryType,getAllActivities:require("./activities").getAllActivities,getActivityCustomerInventories:require("./activityInventories").getActivityCustomerInventories,createActivityCustomerInventories:require("./activityInventories").createActivityCustomerInventories,downloadAllEventsOfDayCSV:require("./events").downloadAllEventsOfDayCSV,downloadAllEventsOfDay:require("./events").downloadAllEventsOfDay,generateUsersCollaborationCSV:require("./users").generateUsersCollaborationCSV,generateAllOnHandInventoryOfAllResourcesCSV:require("./inventory").generateAllOnHandInventoryOfAllResourcesCSV,getActivitybyId:require("./activities").getActivitybyId};exports.default=v});
2
- //# sourceMappingURL=ofsc-utility.min.js.map
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fs"),require("path")):"function"==typeof define&&define.amd?define(["exports","fs","path"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).OfscUtility={},e.fs,e.path)}(this,function(e,t,n){"use strict";function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var r=o(t);async function i(e,t,n){const o=`https://${n}.fs.ocs.oraclecloud.com/rest/oauthTokenService/v2/token`,r={"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${btoa(`${e}@${n}:${t}`)}`},i=new URLSearchParams({grant_type:"client_credentials"});try{const e=await fetch(o,{method:"POST",headers:r,body:i});if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return(await e.json()).access_token}catch(e){throw console.error("Error fetching OAuth token:",e),e}}var a=Object.freeze({__proto__:null,getOAuthToken:i}),s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c,u={},d={};var f,p={};function h(){if(f)return p;f=1;var e=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,t=new RegExp("[\\-\\.0-9"+e.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),n=new RegExp("^"+e.source+t.source+"*(?::"+e.source+t.source+"*)?$");function o(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,o)}function r(){}function i(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function a(e,t,n,o,r,i){function a(e,t,o){e in n.attributeNames&&i.fatalError("Attribute "+e+" redefined"),n.addValue(e,t,o)}for(var s,l=++t,c=0;;){var u=e.charAt(l);switch(u){case"=":if(1===c)s=e.slice(t,l),c=3;else{if(2!==c)throw new Error("attribute equal must after attrName");c=3}break;case"'":case'"':if(3===c||1===c){if(1===c&&(i.warning('attribute value must after "="'),s=e.slice(t,l)),t=l+1,!((l=e.indexOf(u,t))>0))throw new Error("attribute value no end '"+u+"' match");a(s,d=e.slice(t,l).replace(/&#?\w+;/g,r),t-1),c=5}else{if(4!=c)throw new Error('attribute value must after "="');a(s,d=e.slice(t,l).replace(/&#?\w+;/g,r),t),i.warning('attribute "'+s+'" missed start quot('+u+")!!"),t=l+1,c=5}break;case"/":switch(c){case 0:n.setTagName(e.slice(t,l));case 5:case 6:case 7:c=7,n.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),0==c&&n.setTagName(e.slice(t,l)),l;case">":switch(c){case 0:n.setTagName(e.slice(t,l));case 5:case 6:case 7:break;case 4:case 1:"/"===(d=e.slice(t,l)).slice(-1)&&(n.closed=!0,d=d.slice(0,-1));case 2:2===c&&(d=s),4==c?(i.warning('attribute "'+d+'" missed quot(")!'),a(s,d.replace(/&#?\w+;/g,r),t)):("http://www.w3.org/1999/xhtml"===o[""]&&d.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+d+'" missed value!! "'+d+'" instead!!'),a(d,d,t));break;case 3:throw new Error("attribute value missed!!")}return l;case"€":u=" ";default:if(u<=" ")switch(c){case 0:n.setTagName(e.slice(t,l)),c=6;break;case 1:s=e.slice(t,l),c=2;break;case 4:var d=e.slice(t,l).replace(/&#?\w+;/g,r);i.warning('attribute "'+d+'" missed quot(")!!'),a(s,d,t);case 5:c=6}else switch(c){case 2:n.tagName,"http://www.w3.org/1999/xhtml"===o[""]&&s.match(/^(?:disabled|checked|selected)$/i)||i.warning('attribute "'+s+'" missed value!! "'+s+'" instead2!!'),a(s,s,t),t=l,c=1;break;case 5:i.warning('attribute space is required"'+s+'"!!');case 6:c=1,t=l;break;case 3:c=4,t=l;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}l++}}function s(e,t,n){for(var o=e.tagName,r=null,i=e.length;i--;){var a=e[i],s=a.qName,l=a.value;if((p=s.indexOf(":"))>0)var c=a.prefix=s.slice(0,p),d=s.slice(p+1),f="xmlns"===c&&d;else d=s,c=null,f="xmlns"===s&&"";a.localName=d,!1!==f&&(null==r&&(r={},u(n,n={})),n[f]=r[f]=l,a.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(f,l))}for(i=e.length;i--;){(c=(a=e[i]).prefix)&&("xml"===c&&(a.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==c&&(a.uri=n[c||""]))}var p;(p=o.indexOf(":"))>0?(c=e.prefix=o.slice(0,p),d=e.localName=o.slice(p+1)):(c=null,d=e.localName=o);var h=e.uri=n[c||""];if(t.startElement(h,d,o,e),!e.closed)return e.currentNSMap=n,e.localNSMap=r,!0;if(t.endElement(h,d,o),r)for(c in r)t.endPrefixMapping(c)}function l(e,t,n,o,r){if(/^(?:script|textarea)$/i.test(n)){var i=e.indexOf("</"+n+">",t),a=e.substring(t+1,i);if(/[&<]/.test(a))return/^script$/i.test(n)?(r.characters(a,0,a.length),i):(a=a.replace(/&#?\w+;/g,o),r.characters(a,0,a.length),i)}return t+1}function c(e,t,n,o){var r=o[n];return null==r&&((r=e.lastIndexOf("</"+n+">"))<t&&(r=e.lastIndexOf("</"+n)),o[n]=r),r<t}function u(e,t){for(var n in e)t[n]=e[n]}function d(e,t,n,o){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(r=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,r-t-4),r+3):(o.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var r=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,r-t-9),n.endCDATA(),r+3}var i=function(e,t){var n,o=[],r=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;r.lastIndex=t,r.exec(e);for(;n=r.exec(e);)if(o.push(n),n[1])return o}(e,t),a=i.length;if(a>1&&/!doctype/i.test(i[0][0])){var s=i[1][0],l=!1,c=!1;a>3&&(/^public$/i.test(i[2][0])?(l=i[3][0],c=a>4&&i[4][0]):/^system$/i.test(i[2][0])&&(c=i[3][0]));var u=i[a-1];return n.startDTD(s,l,c),n.endDTD(),u.index+u[0].length}return-1}function h(e,t,n){var o=e.indexOf("?>",t);if(o){var r=e.substring(t,o).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return r?(r[0].length,n.processingInstruction(r[1],r[2]),o+2):-1}return-1}function m(){this.attributeNames={}}return o.prototype=new Error,o.prototype.name=o.name,r.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),u(t,t={}),function(e,t,n,r,u){function f(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function p(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?f(parseInt(t.substr(1).replace("x","0x"))):(u.error("entity not found:"+e),e)}function g(t){if(t>E){var n=e.substring(E,t).replace(/&#?\w+;/g,p);b&&v(E),r.characters(n,0,t-E),E=t}}function v(t,n){for(;t>=y&&(n=N.exec(e));)w=n.index,y=w+n[0].length,b.lineNumber++;b.columnNumber=t-w+1}var w=0,y=0,N=/.*(?:\r\n?|\n)|.*$/g,b=r.locator,T=[{currentNSMap:t}],S={},E=0;for(;;){try{var A=e.indexOf("<",E);if(A<0){if(!e.substr(E).match(/^\s*$/)){var C=r.doc,$=C.createTextNode(e.substr(E));C.appendChild($),r.currentElement=$}return}switch(A>E&&g(A),e.charAt(A+1)){case"/":var D=e.indexOf(">",A+3),I=e.substring(A+2,D),x=T.pop();D<0?(I=e.substring(A+2).replace(/[\s<].*/,""),u.error("end tag name: "+I+" is not complete:"+x.tagName),D=A+1+I.length):I.match(/\s</)&&(I=I.replace(/[\s<].*/,""),u.error("end tag name: "+I+" maybe not complete"),D=A+1+I.length);var _=x.localNSMap,O=x.tagName==I;if(O||x.tagName&&x.tagName.toLowerCase()==I.toLowerCase()){if(r.endElement(x.uri,x.localName,I),_)for(var k in _)r.endPrefixMapping(k);O||u.fatalError("end tag name: "+I+" is not match the current start tagName:"+x.tagName)}else T.push(x);D++;break;case"?":b&&v(A),D=h(e,A,r);break;case"!":b&&v(A),D=d(e,A,r,u);break;default:b&&v(A);var R=new m,j=T[T.length-1].currentNSMap,F=(D=a(e,A,R,j,p,u),R.length);if(!R.closed&&c(e,D,R.tagName,S)&&(R.closed=!0,n.nbsp||u.warning("unclosed xml attribute")),b&&F){for(var U=i(b,{}),M=0;M<F;M++){var V=R[M];v(V.offset),V.locator=i(b,{})}r.locator=U,s(R,r,j)&&T.push(R),r.locator=b}else s(R,r,j)&&T.push(R);"http://www.w3.org/1999/xhtml"!==R.uri||R.closed?D++:D=l(e,D,R.tagName,p,r)}}catch(e){if(e instanceof o)throw e;u.error("element parse error: "+e),D=-1}D>E?E=D:g(Math.max(A,E)+1)}}(e,t,n,r,this.errorHandler),r.endDocument()}},m.prototype={setTagName:function(e){if(!n.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,o){if(!n.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:o}},length:0,getLocalName:function(e){return this[e].localName},getLocator:function(e){return this[e].locator},getQName:function(e){return this[e].qName},getURI:function(e){return this[e].uri},getValue:function(e){return this[e].value}},p.XMLReader=r,p.ParseError=o,p}var m,g,v={};function w(){if(m)return v;function e(e,t){for(var n in e)t[n]=e[n]}function t(t,n){var o=t.prototype;if(!(o instanceof n)){function r(){}r.prototype=n.prototype,e(o,r=new r),t.prototype=o=r}o.constructor!=t&&("function"!=typeof t&&console.error("unknow Class:"+t),o.constructor=t)}m=1;var n={},o=n.ELEMENT_NODE=1,r=n.ATTRIBUTE_NODE=2,i=n.TEXT_NODE=3,a=n.CDATA_SECTION_NODE=4,s=n.ENTITY_REFERENCE_NODE=5,l=n.ENTITY_NODE=6,c=n.PROCESSING_INSTRUCTION_NODE=7,u=n.COMMENT_NODE=8,d=n.DOCUMENT_NODE=9,f=n.DOCUMENT_TYPE_NODE=10,p=n.DOCUMENT_FRAGMENT_NODE=11,h=n.NOTATION_NODE=12,g={},w={};g.INDEX_SIZE_ERR=(w[1]="Index size error",1),g.DOMSTRING_SIZE_ERR=(w[2]="DOMString size error",2);var y=g.HIERARCHY_REQUEST_ERR=(w[3]="Hierarchy request error",3);g.WRONG_DOCUMENT_ERR=(w[4]="Wrong document",4),g.INVALID_CHARACTER_ERR=(w[5]="Invalid character",5),g.NO_DATA_ALLOWED_ERR=(w[6]="No data allowed",6),g.NO_MODIFICATION_ALLOWED_ERR=(w[7]="No modification allowed",7);var N=g.NOT_FOUND_ERR=(w[8]="Not found",8);g.NOT_SUPPORTED_ERR=(w[9]="Not supported",9);var b=g.INUSE_ATTRIBUTE_ERR=(w[10]="Attribute in use",10);function T(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,w[e]),this.message=w[e],Error.captureStackTrace&&Error.captureStackTrace(this,T);return n.code=e,t&&(this.message=this.message+": "+t),n}function S(){}function E(e,t){this._node=e,this._refresh=t,A(this)}function A(t){var n=t._node._inc||t._node.ownerDocument._inc;if(t._inc!=n){var o=t._refresh(t._node);oe(t,"length",o.length),e(o,t),t._inc=n}}function C(){}function $(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function D(e,t,n,o){if(o?t[$(t,o)]=n:t[t.length++]=n,e){n.ownerElement=e;var r=e.ownerDocument;r&&(o&&j(r,e,o),function(e,t,n){e&&e._inc++;var o=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==o&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(r,e,n))}}function I(e,t,n){var o=$(t,n);if(!(o>=0))throw T(N,new Error(e.tagName+"@"+n));for(var r=t.length-1;o<r;)t[o]=t[++o];if(t.length=r,e){var i=e.ownerDocument;i&&(j(i,e,n),n.ownerElement=null)}}function x(e){if(this._features={},e)for(var t in e)this._features=e[t]}function _(){}function O(e){return("<"==e?"&lt;":">"==e&&"&gt;")||"&"==e&&"&amp;"||'"'==e&&"&quot;"||"&#"+e.charCodeAt()+";"}function k(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(k(e,t))return!0}while(e=e.nextSibling)}function R(){}function j(e,t,n,o){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function F(e,t,n){if(e&&e._inc){e._inc++;var o=t.childNodes;if(n)o[o.length++]=n;else{for(var r=t.firstChild,i=0;r;)o[i++]=r,r=r.nextSibling;o.length=i}}}function U(e,t){var n=t.previousSibling,o=t.nextSibling;return n?n.nextSibling=o:e.firstChild=o,o?o.previousSibling=n:e.lastChild=n,F(e.ownerDocument,e),t}function M(e,t,n){var o=t.parentNode;if(o&&o.removeChild(t),t.nodeType===p){var r=t.firstChild;if(null==r)return t;var i=t.lastChild}else r=i=t;var a=n?n.previousSibling:e.lastChild;r.previousSibling=a,i.nextSibling=n,a?a.nextSibling=r:e.firstChild=r,null==n?e.lastChild=i:n.previousSibling=i;do{r.parentNode=e}while(r!==i&&(r=r.nextSibling));return F(e.ownerDocument||e,e),t.nodeType==p&&(t.firstChild=t.lastChild=null),t}function V(){this._nsMap={}}function q(){}function P(){}function z(){}function B(){}function L(){}function Z(){}function H(){}function G(){}function W(){}function Y(){}function X(){}function J(){}function Q(e,t){var n=[],o=9==this.nodeType&&this.documentElement||this,r=o.prefix,i=o.namespaceURI;if(i&&null==r&&null==(r=o.lookupPrefix(i)))var a=[{namespace:i,prefix:null}];return ee(this,n,e,t,a),n.join("")}function K(e,t,n){var o=e.prefix||"",r=e.namespaceURI;if(!o&&!r)return!1;if("xml"===o&&"http://www.w3.org/XML/1998/namespace"===r||"http://www.w3.org/2000/xmlns/"==r)return!1;for(var i=n.length;i--;){var a=n[i];if(a.prefix==o)return a.namespace!=r}return!0}function ee(e,t,n,l,h){if(l){if(!(e=l(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case o:h||(h=[]),h.length;var m=e.attributes,g=m.length,v=e.firstChild,w=e.tagName;n="http://www.w3.org/1999/xhtml"===e.namespaceURI||n,t.push("<",w);for(var y=0;y<g;y++){"xmlns"==(N=m.item(y)).prefix?h.push({prefix:N.localName,namespace:N.value}):"xmlns"==N.nodeName&&h.push({prefix:"",namespace:N.value})}for(y=0;y<g;y++){var N;if(K(N=m.item(y),0,h)){var b=N.prefix||"",T=N.namespaceURI,S=b?" xmlns:"+b:" xmlns";t.push(S,'="',T,'"'),h.push({prefix:b,namespace:T})}ee(N,t,n,l,h)}if(K(e,0,h)){b=e.prefix||"";if(T=e.namespaceURI){S=b?" xmlns:"+b:" xmlns";t.push(S,'="',T,'"'),h.push({prefix:b,namespace:T})}}if(v||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(w)){if(t.push(">"),n&&/^script$/i.test(w))for(;v;)v.data?t.push(v.data):ee(v,t,n,l,h),v=v.nextSibling;else for(;v;)ee(v,t,n,l,h),v=v.nextSibling;t.push("</",w,">")}else t.push("/>");return;case d:case p:for(v=e.firstChild;v;)ee(v,t,n,l,h),v=v.nextSibling;return;case r:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,O),'"');case i:return t.push(e.data.replace(/[<&]/g,O).replace(/]]>/g,"]]&gt;"));case a:return t.push("<![CDATA[",e.data,"]]>");case u:return t.push("\x3c!--",e.data,"--\x3e");case f:var E=e.publicId,A=e.systemId;if(t.push("<!DOCTYPE ",e.name),E)t.push(" PUBLIC ",E),A&&"."!=A&&t.push(" ",A),t.push(">");else if(A&&"."!=A)t.push(" SYSTEM ",A,">");else{var C=e.internalSubset;C&&t.push(" [",C,"]"),t.push(">")}return;case c:return t.push("<?",e.target," ",e.data,"?>");case s:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function te(e,t,n){var i;switch(t.nodeType){case o:(i=t.cloneNode(!1)).ownerDocument=e;case p:break;case r:n=!0}if(i||(i=t.cloneNode(!1)),i.ownerDocument=e,i.parentNode=null,n)for(var a=t.firstChild;a;)i.appendChild(te(e,a,n)),a=a.nextSibling;return i}function ne(e,t,n){var i=new t.constructor;for(var a in t){var s=t[a];"object"!=typeof s&&s!=i[a]&&(i[a]=s)}switch(t.childNodes&&(i.childNodes=new S),i.ownerDocument=e,i.nodeType){case o:var l=t.attributes,c=i.attributes=new C,u=l.length;c._ownerElement=i;for(var d=0;d<u;d++)i.setAttributeNode(ne(e,l.item(d),!0));break;case r:n=!0}if(n)for(var f=t.firstChild;f;)i.appendChild(ne(e,f,n)),f=f.nextSibling;return i}function oe(e,t,n){e[t]=n}g.INVALID_STATE_ERR=(w[11]="Invalid state",11),g.SYNTAX_ERR=(w[12]="Syntax error",12),g.INVALID_MODIFICATION_ERR=(w[13]="Invalid modification",13),g.NAMESPACE_ERR=(w[14]="Invalid namespace",14),g.INVALID_ACCESS_ERR=(w[15]="Invalid access",15),T.prototype=Error.prototype,e(g,T),S.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],o=0;o<this.length;o++)ee(this[o],n,e,t);return n.join("")}},E.prototype.item=function(e){return A(this),this[e]},t(E,S),C.prototype={length:0,item:S.prototype.item,getNamedItem:function(e){for(var t=this.length;t--;){var n=this[t];if(n.nodeName==e)return n}},setNamedItem:function(e){var t=e.ownerElement;if(t&&t!=this._ownerElement)throw new T(b);var n=this.getNamedItem(e.nodeName);return D(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new T(b);return t=this.getNamedItemNS(e.namespaceURI,e.localName),D(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return I(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return I(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var o=this[n];if(o.localName==t&&o.namespaceURI==e)return o}return null}},x.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return!(!n||t&&!(t in n))},createDocument:function(e,t,n){var o=new R;if(o.implementation=this,o.childNodes=new S,o.doctype=n,n&&o.appendChild(n),t){var r=o.createElementNS(e,t);o.appendChild(r)}return o},createDocumentType:function(e,t,n){var o=new Z;return o.name=e,o.nodeName=e,o.publicId=t,o.systemId=n,o}},_.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,attributes:null,parentNode:null,childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,insertBefore:function(e,t){return M(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return U(this,e)},appendChild:function(e){return this.insertBefore(e,null)},hasChildNodes:function(){return null!=this.firstChild},cloneNode:function(e){return ne(this.ownerDocument||this,this,e)},normalize:function(){for(var e=this.firstChild;e;){var t=e.nextSibling;t&&t.nodeType==i&&e.nodeType==i?(this.removeChild(t),e.appendData(t.data)):(e.normalize(),e=t)}},isSupported:function(e,t){return this.ownerDocument.implementation.hasFeature(e,t)},hasAttributes:function(){return this.attributes.length>0},lookupPrefix:function(e){for(var t=this;t;){var n=t._nsMap;if(n)for(var o in n)if(n[o]==e)return o;t=t.nodeType==r?t.ownerDocument:t.parentNode}return null},lookupNamespaceURI:function(e){for(var t=this;t;){var n=t._nsMap;if(n&&e in n)return n[e];t=t.nodeType==r?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},e(n,_),e(n,_.prototype),R.prototype={nodeName:"#document",nodeType:d,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==p){for(var n=e.firstChild;n;){var r=n.nextSibling;this.insertBefore(n,t),n=r}return e}return null==this.documentElement&&e.nodeType==o&&(this.documentElement=e),M(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),U(this,e)},importNode:function(e,t){return te(this,e,t)},getElementById:function(e){var t=null;return k(this.documentElement,function(n){if(n.nodeType==o&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\s)"+e+"(\\s|$)");return new E(this,function(e){var n=[];return k(e.documentElement,function(r){r!==e&&r.nodeType==o&&t.test(r.getAttribute("class"))&&n.push(r)}),n})},createElement:function(e){var t=new V;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new S,(t.attributes=new C)._ownerElement=t,t},createDocumentFragment:function(){var e=new Y;return e.ownerDocument=this,e.childNodes=new S,e},createTextNode:function(e){var t=new z;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new B;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new L;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new X;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new q;return t.ownerDocument=this,t.name=e,t.nodeName=e,t.localName=e,t.specified=!0,t},createEntityReference:function(e){var t=new W;return t.ownerDocument=this,t.nodeName=e,t},createElementNS:function(e,t){var n=new V,o=t.split(":"),r=n.attributes=new C;return n.childNodes=new S,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==o.length?(n.prefix=o[0],n.localName=o[1]):n.localName=t,r._ownerElement=n,n},createAttributeNS:function(e,t){var n=new q,o=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==o.length?(n.prefix=o[0],n.localName=o[1]):n.localName=t,n}},t(R,_),V.prototype={nodeType:o,hasAttribute:function(e){return null!=this.getAttributeNode(e)},getAttribute:function(e){var t=this.getAttributeNode(e);return t&&t.value||""},getAttributeNode:function(e){return this.attributes.getNamedItem(e)},setAttribute:function(e,t){var n=this.ownerDocument.createAttribute(e);n.value=n.nodeValue=""+t,this.setAttributeNode(n)},removeAttribute:function(e){var t=this.getAttributeNode(e);t&&this.removeAttributeNode(t)},appendChild:function(e){return e.nodeType===p?this.insertBefore(e,null):function(e,t){var n=t.parentNode;if(n){var o=e.lastChild;n.removeChild(t),o=e.lastChild}return o=e.lastChild,t.parentNode=e,t.previousSibling=o,t.nextSibling=null,o?o.nextSibling=t:e.firstChild=t,e.lastChild=t,F(e.ownerDocument,e,t),t}(this,e)},setAttributeNode:function(e){return this.attributes.setNamedItem(e)},setAttributeNodeNS:function(e){return this.attributes.setNamedItemNS(e)},removeAttributeNode:function(e){return this.attributes.removeNamedItem(e.nodeName)},removeAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);n&&this.removeAttributeNode(n)},hasAttributeNS:function(e,t){return null!=this.getAttributeNodeNS(e,t)},getAttributeNS:function(e,t){var n=this.getAttributeNodeNS(e,t);return n&&n.value||""},setAttributeNS:function(e,t,n){var o=this.ownerDocument.createAttributeNS(e,t);o.value=o.nodeValue=""+n,this.setAttributeNode(o)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new E(this,function(t){var n=[];return k(t,function(r){r===t||r.nodeType!=o||"*"!==e&&r.tagName!=e||n.push(r)}),n})},getElementsByTagNameNS:function(e,t){return new E(this,function(n){var r=[];return k(n,function(i){i===n||i.nodeType!==o||"*"!==e&&i.namespaceURI!==e||"*"!==t&&i.localName!=t||r.push(i)}),r})}},R.prototype.getElementsByTagName=V.prototype.getElementsByTagName,R.prototype.getElementsByTagNameNS=V.prototype.getElementsByTagNameNS,t(V,_),q.prototype.nodeType=r,t(q,_),P.prototype={data:"",substringData:function(e,t){return this.data.substring(e,e+t)},appendData:function(e){e=this.data+e,this.nodeValue=this.data=e,this.length=e.length},insertData:function(e,t){this.replaceData(e,0,t)},appendChild:function(e){throw new Error(w[y])},deleteData:function(e,t){this.replaceData(e,t,"")},replaceData:function(e,t,n){n=this.data.substring(0,e)+n+this.data.substring(e+t),this.nodeValue=this.data=n,this.length=n.length}},t(P,_),z.prototype={nodeName:"#text",nodeType:i,splitText:function(e){var t=this.data,n=t.substring(e);t=t.substring(0,e),this.data=this.nodeValue=t,this.length=t.length;var o=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(o,this.nextSibling),o}},t(z,P),B.prototype={nodeName:"#comment",nodeType:u},t(B,P),L.prototype={nodeName:"#cdata-section",nodeType:a},t(L,P),Z.prototype.nodeType=f,t(Z,_),H.prototype.nodeType=h,t(H,_),G.prototype.nodeType=l,t(G,_),W.prototype.nodeType=s,t(W,_),Y.prototype.nodeName="#document-fragment",Y.prototype.nodeType=p,t(Y,_),X.prototype.nodeType=c,t(X,_),J.prototype.serializeToString=function(e,t,n){return Q.call(e,t,n)},_.prototype.toString=Q;try{if(Object.defineProperty){function re(e){switch(e.nodeType){case o:case p:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(re(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(E.prototype,"length",{get:function(){return A(this),this.$$length}}),Object.defineProperty(_.prototype,"textContent",{get:function(){return re(this)},set:function(e){switch(this.nodeType){case o:case p:for(;this.firstChild;)this.removeChild(this.firstChild);(e||String(e))&&this.appendChild(this.ownerDocument.createTextNode(e));break;default:this.data=e,this.value=e,this.nodeValue=e}}}),oe=function(e,t,n){e["$$"+t]=n}}}catch(ie){}return v.Node=_,v.DOMException=T,v.DOMImplementation=x,v.XMLSerializer=J,v}var y=function(){if(g)return u;function e(e){this.options=e||{locator:{}}}function t(){this.cdata=!1}function n(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function o(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function r(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function i(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}g=1,e.prototype.parseFromString=function(e,n){var r=this.options,i=new l,s=r.domBuilder||new t,c=r.errorHandler,u=r.locator,d=r.xmlns||{},f=/\/x?html?$/.test(n),p=f?a.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return u&&s.setDocumentLocator(u),i.errorHandler=function(e,n,r){if(!e){if(n instanceof t)return n;e=n}var i={},a=e instanceof Function;function s(t){var n=e[t];!n&&a&&(n=2==e.length?function(n){e(t,n)}:e),i[t]=n&&function(e){n("[xmldom "+t+"]\t"+e+o(r))}||function(){}}return r=r||{},s("warning"),s("error"),s("fatalError"),i}(c,s,u),i.domBuilder=r.domBuilder||s,f&&(d[""]="http://www.w3.org/1999/xhtml"),d.xml=d.xml||"http://www.w3.org/XML/1998/namespace",e&&"string"==typeof e?i.parse(e,d,p):i.errorHandler.error("invalid doc source"),s.doc},t.prototype={startDocument:function(){this.doc=(new p).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,o,r){var a=this.doc,s=a.createElementNS(e,o||t),l=r.length;i(this,s),this.currentElement=s,this.locator&&n(this.locator,s);for(var c=0;c<l;c++){e=r.getURI(c);var u=r.getValue(c),d=(o=r.getQName(c),a.createAttributeNS(e,o));this.locator&&n(r.getLocator(c),d),d.value=d.nodeValue=u,s.setAttributeNode(d)}},endElement:function(e,t,n){var o=this.currentElement;o.tagName,this.currentElement=o.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var o=this.doc.createProcessingInstruction(e,t);this.locator&&n(this.locator,o),i(this,o)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,o){if(e=r.apply(this,arguments)){if(this.cdata)var i=this.doc.createCDATASection(e);else i=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(i):/^\s*$/.test(e)&&this.doc.appendChild(i),this.locator&&n(this.locator,i)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,o){e=r.apply(this,arguments);var a=this.doc.createComment(e);this.locator&&n(this.locator,a),i(this,a)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,o){var r=this.doc.implementation;if(r&&r.createDocumentType){var a=r.createDocumentType(e,t,o);this.locator&&n(this.locator,a),i(this,a)}},warning:function(e){console.warn("[xmldom warning]\t"+e,o(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,o(this.locator))},fatalError:function(e){throw new f(e,this.locator)}},"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){t.prototype[e]=function(){return null}});var a=(c||(c=1,d.entityMap={lt:"<",gt:">",amp:"&",quot:'"',apos:"'",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",times:"×",divide:"÷",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",euro:"€",trade:"™",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"}),d),s=h(),l=s.XMLReader,f=s.ParseError,p=u.DOMImplementation=w().DOMImplementation;return u.XMLSerializer=w().XMLSerializer,u.DOMParser=e,u.__DOMHandler=t,u}();const N=async(e,t,n,o,r,a=5,s=500)=>{const l=async t=>fetch(e,{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});console.log(`➡️ Fetching ${e}`);let c=await l(r);if(401===c.status&&(console.warn("⚠️ Token expired — renewing token…"),r=await i(t,n,o),c=await l(r)),429===c.status&&a>0){const i=c.headers.get("Retry-After");console.log("⚠️ 429 received. Retrying...",i);const l=i?1e3*Number(i):s;return console.warn(`⚠️ 429 received. Retrying in ${l}ms... (${a} left)`),await new Promise(e=>setTimeout(e,l)),N(e,t,n,o,r,a-1,2*s)}if(!c.ok){const e=await c.text();throw new Error(`❌ Request failed: ${c.status} ${c.statusText}\n${e}`)}return{data:await c.json(),token:r}};function b(e,o){if(!e||0===e.length)throw new Error("CSV creation failed: no rows provided.");const r=Object.keys(e[0]),i=[r.join(","),...e.map(e=>r.map(t=>function(e){if(null==e)return"";"object"==typeof e&&(e=JSON.stringify(e));const t=String(e);if(t.includes(",")||t.includes('"')||t.includes("\n"))return`"${t.replace(/"/g,'""')}"`;return t}(e[t])).join(","))].join("\n"),a=n.dirname(o);t.existsSync(a)||t.mkdirSync(a,{recursive:!0}),t.writeFileSync(o,i),console.log(`CSV saved: ${o}`)}var T=Object.freeze({__proto__:null,fetchWithRetry:N,saveCsv:b,xmlNodeToObjects:function(e,t){const n=(new y.DOMParser).parseFromString(e,"application/xml"),o=Array.from(n.getElementsByTagName(t));if(0===o.length)throw new Error(`No <${t}> nodes found`);return o.map(e=>{var t,n;const o={},r=Array.from(e.getElementsByTagName("Field"));for(const e of r){const r=e.getAttribute("name");r&&(o[r]=null!==(n=null===(t=e.textContent)||void 0===t?void 0:t.trim())&&void 0!==n?n:"")}return o})}});const S=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);async function E(e,t,n,o,r,a,s,l,c=!1){if(!S(r)||!S(a))throw new Error("❌ Invalid date format. Expected YYYY-MM-DD.");let u=1e3,d=0;const f=[],p=await i(e,t,n);for(;;){const i=new URLSearchParams({offset:d.toString(),limit:u.toString()});s&&i.append("q",s),o&&i.append("resources",o),l&&i.append("fields",l),r&&i.append("dateFrom",r),a&&i.append("dateTo",a),c&&i.append("includeNonScheduled","true");const h=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/?${i.toString()}`;console.error(h),console.log(`➡️ Fetching offset=${d}, limit=${u}`);const m=(await N(h,e,t,n,p)).data;if(!m.items||0===m.items.length){console.log("✔ No more items found. Stopping pagination.");break}f.push(...m.items),console.log(` ✔ Received ${m.items.length} items (Total: ${f.length})`),u=m.limit,d+=u}return f}async function A(e,t,n,o,r=""){const i=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(o)}/`;console.log(`➡️ Fetching activity by ID: ${i}`);return await N(i,e,t,n,r)}var C=Object.freeze({__proto__:null,getActivitybyId:A,getAllActivities:E});async function $(e,t,n,o,r=""){const i=[],a=async s=>{const l=new URLSearchParams({offset:s.toString(),limit:100..toString()}),c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${o}/customerInventories?${l}`;console.log(`➡️ Fetching offset=${s}, limit=100`);const u=await N(c,e,t,n,r);r=u.token;const d=u.data;d.items&&0!==d.items.length&&(i.push(...d.items),console.log(` ✔ Received ${d.items.length} items (Total: ${i.length}) for activity ${o}`),await a(s+100))};return await a(0),i}async function D(e,t,n,o,r){const a=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${o}/customerInventories`,s=await i(e,t,n);console.log(`➡️ creating ${a}`);const l=await fetch(a,{method:"POST",headers:{Authorization:`Bearer ${s}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r)});return await l.json()}var I=Object.freeze({__proto__:null,createActivityCustomerInventories:D,getActivityCustomerInventories:$});async function x(e,t,n,o,r){const i=await N(e,n,o,r,t);return{token:i.token,data:i.data}}function _(e){const[t,n,o]=e.split("-").map(Number),r=new Date(t,n-1,o);r.setDate(r.getDate()+1);const i=e=>e.toString().padStart(2,"0");return`${r.getFullYear()}-${i(r.getMonth()+1)}-${i(r.getDate())}`}function O(e,t,n){var o,r;for(const i of e){const e=i.time;if(e.startsWith(_(t)))return console.log("Stopping at different event date:",e),!1;const a=null!==(r=null===(o=i.activityDetails)||void 0===o?void 0:o.activityId)&&void 0!==r?r:null;n.push({activityId:a,...i})}return!0}async function k(e,t,n,o,r,i){return console.log("Downloading events...OnlyData:",i),await R(e,t,n,o,r,i)}async function R(e,t,o,r,a,s){var l,c,u;const d=[],f=`https://${o}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/events`,p=`${f}?subscriptionId=${encodeURIComponent(r)}&since=${encodeURIComponent(a+" 00:00:00")}`;console.log("sinceDate",a);let h=await i(e,t,o),m=await x(p,h,e,t,o);h=m.token;let g=m.data.nextPage,v=m.data.found,w=g,y=0;for(;v&&g;){const n=new URL(f);n.search=new URLSearchParams({subscriptionId:r,page:g,limit:"1000"}).toString();const i=n.toString(),s=await x(i,h,e,t,o);h=s.token;const p=s.data;if(v=p.found,g=p.nextPage,console.error("nextPage",g,"Records:",null===(l=p.items)||void 0===l?void 0:l.length,"Time:",null===(u=null===(c=p.items)||void 0===c?void 0:c[0])||void 0===u?void 0:u.time),g===w){if(y++,y>10){console.warn("⚠️ Pagination repeating same page more than 10 times. Stopping.");break}}else w=g,y=0;if(!p.items){console.warn("⚠️ No items found in page. Stopping.");break}if(!O(p.items,a,d))break}const N=`events-${a}_${Math.floor(Date.now()/1e3)}.csv`,T=n.resolve(N);return s||(b(d,T),console.log(`✅ Saved ${d.length} events to: ${T}`)),d}var j=Object.freeze({__proto__:null,downloadAllEventsOfDay:k,downloadAllEventsOfDayCSV:R,flattenObject:function e(t,n="",o={}){for(const r in t){const i=n?`${n}_${r}`:r;"object"!=typeof t[r]||null===t[r]||Array.isArray(t[r])?o[i]=t[r]:e(t[r],i,o)}return o}});async function F(e,t,o){var r,i;let a=0;const s=100,l=[];let c="";for(console.log("🚀 Starting all Resources Inventories export..."),console.log("--------------------------------------------------");;){const n=`https://${o}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/?offset=${a}&limit=100`;console.log(`➡️ Fetching users offset=${a}`);const i=await N(n,e,t,o,c);c=i.token;const u=i.data;if(!(null===(r=null==u?void 0:u.items)||void 0===r?void 0:r.length)){console.warn("⚠ No user items returned. Breaking.");break}if(l.push(...u.items),console.log(` ✔ Received ${u.items.length} resources (Total: ${l.length})`),a+s>=u.totalResults)break;a+=s}console.log("--------------------------------------------------"),console.log(`🧩 Total resources to process: ${l.length}`),console.log("--------------------------------------------------");const u=[];for(const[n,r]of l.entries())if(console.log(`${n} 👤 Fetching Inventories for ${r.resourceId}`),"active"===r.status)for(a=0;;){const n=`https://${o}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${encodeURIComponent(r.resourceId)}/inventories/?offset=${a}&limit=100`;try{const l=await N(n,e,t,o,c);c=l.token;const d=l.data,f=null!==(i=null==d?void 0:d.items)&&void 0!==i?i:[];if(!f||0===f.length){console.log(` ⚠ No Inventories found for ${r.resourceId}`);break}for(const e of f)delete e.links,delete e.status,u.push({resourceName:r.name,resourceType:r.resourceType,resourceTimeZone:r.timeZoneIANA,...e});if(console.log(` ✔ Found ${f.length} Inventories`),a+s>=d.totalResults)break;a+=s}catch(e){console.error(`❌ Error fetching Inventories for ${r.resourceId}:`,e),console.log(` ⚠ Skipping invUrl ${n}`)}}else console.log(` ⚠ Skipping inactive resource ${r.resourceId}`);console.log("--------------------------------------------------"),console.log(`📦 Total rows: ${u.length}`),console.log("--------------------------------------------------");const d=`All_Resources_Inventories_${Math.floor(Date.now()/1e3)}.csv`,f=n.resolve(d);b(u,d),console.log(`📁 CSV saved: ${f}`)}var U,M=Object.freeze({__proto__:null,generateAllOnHandInventoryOfAllResourcesCSV:F}),V={exports:{}};var q=l((U||(U=1,function(e,t){var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==s)return s;throw new Error("unable to locate global object")}();e.exports=t=n.fetch,n.fetch&&(t.default=n.fetch.bind(n)),t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response}(V,V.exports)),V.exports));async function P(e,t,n){let o=0;const a=100;let s=[],l=0;for(console.log("🚀 Starting all nventory type download..."),console.log("-------------------------------------");;){const r=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/inventoryTypes/?offset=${o}&limit=100`,c=await i(e,t,n);console.log(`➡️ Fetching offset=${o} limit=100`);const u=await q(r,{method:"GET",headers:{Authorization:`Bearer ${c}`,Accept:"application/json"}});if(!u.ok)throw new Error(`❌ Fetch failed: ${u.status} ${u.statusText}`);const d=await u.json();if(s.push(...d.items),l+=d.items.length,console.log(` ✔ Received ${d.items.length} items (Total: ${l})`),o+a>=d.totalResults)break;o+=a}console.log("-------------------------------------"),console.log("🧩 Collecting all unique properties...");const c=new Set;for(const e of s)for(const t of Object.keys(e))["resources","collaborationGroups","resourceInternalIds","links"].includes(t)||c.add(t);const u=Array.from(c);console.log(`📝 Total unique fields: ${u.length}`);const d=[];d.push(u.join(","));for(const e of s){const t=u.map(t=>{let n=e[t];return"keys"===t?Array.isArray(n)?`"${n.join("|")}"`:n?`"${String(n)}"`:"":"object"==typeof n&&null!==n?`"${JSON.stringify(n).replace(/"/g,"'")}"`:void 0!==n?`"${String(n).replace(/"/g,"'")}"`:""});d.push(t.join(","))}const f="./all_inventories.csv";r.writeFileSync(f,d.join("\n")),console.log("-------------------------------------"),console.log("✅ Inventories CSV Created Successfully!"),console.log(`📁 File: ${f}`),console.log(`📦 Total Records: ${l}`),console.log(`🧩 Total Columns (Dynamic): ${u.length}`),console.log(`🧩 Date Time: ${new Date}`),console.log("-------------------------------------")}async function z(e,t,n,o){const r=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/inventoryTypes/${o}`,a=await i(e,t,n),s=await q(r,{method:"GET",headers:{Authorization:`Bearer ${a}`,Accept:"application/json"}});if(!s.ok)throw new Error(`❌ Fetch failed: ${s.status} ${s.statusText}`);return await s.json()}async function B(e,t,n,o,r){const a=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/inventoryTypes/${o}`,s=await i(e,t,n),l=await q(a,{method:"PUT",headers:{Authorization:`Bearer ${s}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(r)});if(!l.ok)throw new Error(`❌ PUT failed: ${l.status} ${l.statusText}`);return await l.json()}var L=Object.freeze({__proto__:null,downloadAllInventoryTypesCSV:P,getInventoryTypesDetail:z,updateCreateInventoryType:B});async function Z(e,t,n){let o=0;const a=100;let s=[],l=0;for(console.log("🚀 Starting resource download..."),console.log("-------------------------------------");;){const r=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/?offset=${o}&limit=100`,c=await i(e,t,n);console.log(`➡️ Fetching offset=${o} limit=100`);const u=await q(r,{method:"GET",headers:{Authorization:`Bearer ${c}`,Accept:"application/json"}});if(!u.ok)throw new Error(`❌ Fetch failed: ${u.status} ${u.statusText}`);const d=await u.json();if(s.push(...d.items),l+=d.items.length,console.log(` ✔ Received ${d.items.length} items (Total: ${l})`),o+a>=d.totalResults)break;o+=a}console.log("-------------------------------------"),console.log("🧩 Collecting all unique properties...");const c=new Set;for(const e of s)for(const t of Object.keys(e))["links","inventories","users","workZones","workSkills","workSchedules"].includes(t)||c.add(t);const u=Array.from(c);console.log(`📝 Total unique fields: ${u.length}`);const d=[];d.push(u.join(","));for(const e of s){const t=u.map(t=>{let n=e[t];return"keys"===t?Array.isArray(n)?`"${n.join("|")}"`:n?`"${String(n)}"`:"":"object"==typeof n&&null!==n?`"${JSON.stringify(n).replace(/"/g,"'")}"`:void 0!==n?`"${String(n).replace(/"/g,"'")}"`:""});d.push(t.join(","))}const f="./resources.csv";r.writeFileSync(f,d.join("\n")),console.log("-------------------------------------"),console.log("✅ Resource CSV Created Successfully!"),console.log(`📁 File: ${f}`),console.log(`📦 Total Records: ${l}`),console.log(`🧩 Total Columns (Dynamic): ${u.length}`),console.log(`🧩 Date Time: ${new Date}`),console.log("-------------------------------------")}var H=Object.freeze({__proto__:null,downloadAllResourcesCSV:Z});async function G(e,t,o){var r,i;let a=0;const s=[];let l="";for(console.log("🚀 Starting Users Collaboration Groups export..."),console.log("--------------------------------------------------");;){const n=`https://${o}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/?offset=${a}&limit=100`;console.log(`➡️ Fetching users offset=${a}`);const i=await N(n,e,t,o,l);l=i.token;const c=i.data;if(!(null===(r=null==c?void 0:c.items)||void 0===r?void 0:r.length)){console.warn("⚠ No user items returned. Breaking.");break}if(s.push(...c.items),console.log(` ✔ Received ${c.items.length} users (Total: ${s.length})`),a+100>=c.totalResults)break;a+=100}console.log("--------------------------------------------------"),console.log(`🧩 Total users to process: ${s.length}`),console.log("--------------------------------------------------");const c=[];for(const n of s)if(console.log(`👤 Fetching groups for ${n.login}`),"active"===n.status)try{const r=`https://${o}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/${n.login}/collaborationGroups`,a=await N(r,e,t,o,l);l=a.token;const s=a.data,u=null!==(i=null==s?void 0:s.items)&&void 0!==i?i:[];if(0===u.length){console.log(` ⚠ No groups found for ${n.login}`);continue}for(const e of u)c.push({...e,login:n.login,userType:n.userType,timeZoneIANA:n.timeZoneIANA,userName:n.name});console.log(` ✔ Found ${u.length} groups`)}catch(e){console.error(`❌ Error fetching groups for ${n.login}:`,e)}else console.log(` ⚠ Skipping inactive user ${n.login}`);console.log("--------------------------------------------------"),console.log(`📦 Total rows: ${c.length}`),console.log("--------------------------------------------------");const u=`collaborationGroups_${Math.floor(Date.now()/1e3)}.csv`,d=n.resolve(u);b(c,u),console.log(`📁 CSV saved: ${d}`)}async function W(e,t,n){let o=0;const a=100;let s=[],l=0;for(console.log("🚀 Starting users download..."),console.log("-------------------------------------");;){const r=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/?offset=${o}&limit=100`,c=await i(e,t,n);console.log(`➡️ Fetching offset=${o} limit=100`);const u=await q(r,{method:"GET",headers:{Authorization:`Bearer ${c}`,Accept:"application/json"}});if(!u.ok)throw new Error(`❌ Fetch failed: ${u.status} ${u.statusText}`);const d=await u.json();if(s.push(...d.items),l+=d.items.length,console.log(` ✔ Received ${d.items.length} items (Total: ${l})`),o+a>=d.totalResults)break;o+=a}console.log("-------------------------------------"),console.log("🧩 Collecting all unique properties...");const c=new Set;for(const e of s)for(const t of Object.keys(e))["resources","collaborationGroups","resourceInternalIds","links"].includes(t)||c.add(t);const u=Array.from(c);console.log(`📝 Total unique fields: ${u.length}`);const d=[];d.push(u.join(","));for(const e of s){const t=u.map(t=>{let n=e[t];return"keys"===t?Array.isArray(n)?`"${n.join("|")}"`:n?`"${String(n)}"`:"":"object"==typeof n&&null!==n?`"${JSON.stringify(n).replace(/"/g,"'")}"`:void 0!==n?`"${String(n).replace(/"/g,"'")}"`:""});d.push(t.join(","))}const f="./users.csv";r.writeFileSync(f,d.join("\n")),console.log("-------------------------------------"),console.log("✅ Users CSV Created Successfully!"),console.log(`📁 File: ${f}`),console.log(`📦 Total Records: ${l}`),console.log(`🧩 Total Columns (Dynamic): ${u.length}`),console.log(`🧩 Date Time: ${new Date}`),console.log("-------------------------------------")}const Y={generateUsersCollaborationCSV:require("./collaborationGroups").generateUsersCollaborationCSV,downloadAllUsersCSV:W};var X=Object.freeze({__proto__:null,default:Y,downloadAllUsersCSV:W,generateUsersCollaborationCSV:G});async function J(e,t,n){const o=Date.now();let a=0;let s=0,l=0,c=["workZoneLabel,workZoneName,key,status,travelArea"];for(;;){const o=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscMetadata/v1/workZones?offset=${a}&limit=100`;let r=await i(e,t,n);const u=await q(o,{method:"GET",headers:{Authorization:`Bearer ${r}`,Accept:"application/json"}});if(!u.ok)throw new Error(`Failed to fetch work zones: ${u.status} ${u.statusText}`);const d=await u.json();s+=d.items.length;for(const e of d.items){const t=Array.isArray(e.keys)?e.keys:e.keys?[e.keys]:[];l+=t.length;for(const n of t)c.push(`${e.workZoneLabel},${e.workZoneName},${n},${e.status},${e.travelArea}`)}if(!d.hasMore)break;a=d.offset+100}const u=c.join("\n"),d="./workzones.csv";r.writeFileSync(d,u);const f=((Date.now()-o)/1e3).toFixed(2);console.log("\n=== Work Zone Extraction Summary ==="),console.log(`Total Work Zones Processed : ${s}`),console.log(`Total Keys Extracted : ${l}`),console.log(`CSV Saved To : ${d}`),console.log(`Time Taken : ${f} sec`),console.log("====================================\n"),console.log("✔ Work Zone CSV download completed.")}var Q=Object.freeze({__proto__:null,downloadWorkZoneCSV:J});const K={getOAuthToken:require("./oauthTokenService").getOAuthToken,downloadWorkZoneCSV:require("./workZones").downloadWorkZoneCSV,downloadAllResourcesCSV:require("./resources").downloadAllResourcesCSV,downloadAllUsersCSV:require("./resources").downloadAllUsersCSV,downloadAllInventoryTypesCSV:require("./inventoryTypes").downloadAllInventoryTypesCSV,getInventoryTypesDetail:require("./inventoryTypes").getInventoryTypesDetail,updateInventoryType:require("./inventoryTypes").updateInventoryType,getAllActivities:require("./activities").getAllActivities,getActivityCustomerInventories:require("./activityInventories").getActivityCustomerInventories,createActivityCustomerInventories:require("./activityInventories").createActivityCustomerInventories,downloadAllEventsOfDayCSV:require("./events").downloadAllEventsOfDayCSV,downloadAllEventsOfDay:require("./events").downloadAllEventsOfDay,generateUsersCollaborationCSV:require("./users").generateUsersCollaborationCSV,generateAllOnHandInventoryOfAllResourcesCSV:require("./inventory").generateAllOnHandInventoryOfAllResourcesCSV,getActivitybyId:require("./activities").getActivitybyId};e.Activity=C,e.ActivityInventories=I,e.Events=j,e.Inventory=M,e.InventoryType=L,e.OauthTokenService=a,e.Resource=H,e.User=X,e.Utilities=T,e.WorkZone=Q,e.createActivityCustomerInventories=D,e.default=K,e.downloadAllEventsOfDay=k,e.downloadAllEventsOfDayCSV=R,e.downloadAllInventoryTypesCSV=P,e.downloadAllResourcesCSV=Z,e.downloadAllUsersCSV=W,e.downloadWorkZoneCSV=J,e.generateAllOnHandInventoryOfAllResourcesCSV=F,e.generateUsersCollaborationCSV=G,e.getActivityCustomerInventories=$,e.getActivitybyId=A,e.getAllActivities=E,e.getInventoryTypesDetail=z,e.getOAuthToken=i,e.updateCreateInventoryType=B,Object.defineProperty(e,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofsc-utility",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "A wrapper for Oracle Field Service REST API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -18,7 +18,7 @@ npm install ofsc-utility
18
18
  ```
19
19
 
20
20
  ```jsDelivr
21
- https://unpkg.com/ofsc-utility@1.0.13/dist/ofsc-utility.min.js
21
+ https://unpkg.com/ofsc-utility@1.0.15/dist/ofsc-utility.min.js
22
22
  ```
23
23
 
24
24
  ## Functions implemented