ofsc-utility-browser 1.0.2 → 1.0.4
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.
- package/dist/activities/index.js +68 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +19 -0
- package/dist/oauthTokenService/index.js +27 -0
- package/dist/ofsc-utilities-min.js +1 -1
- package/dist/ofsc-utilities-min.js.map +1 -1
- package/dist/resources/index.js +132 -0
- package/dist/types.js +1 -0
- package/dist/users/index.d.ts +11 -0
- package/dist/users/index.js +59 -0
- package/dist/utilities/index.js +148 -0
- package/package.json +1 -1
- package/readme.md +13 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { getOAuthToken } from "../oauthTokenService";
|
|
2
|
+
import { fetchWithRetry } from "../utilities";
|
|
3
|
+
// Validate YYYY-MM-DD format
|
|
4
|
+
const isValidDate = (date) => /^\d{4}-\d{2}-\d{2}$/.test(date);
|
|
5
|
+
/**
|
|
6
|
+
* Fetches all activities from the OFSC instance.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} clientId - The OFSC client ID.
|
|
9
|
+
* @param {string} clientSecret - The OFSC client secret.
|
|
10
|
+
* @param {string} instanceUrl - The OFSC instance URL.
|
|
11
|
+
* @param {string} [q] - The query string to filter activities.
|
|
12
|
+
* @param {string} [resources] - The resources to filter activities by. Required.
|
|
13
|
+
* @param {string} [fields] - The fields to include in the response.
|
|
14
|
+
* @param {string} [dateFrom] - The date from which to filter activities.
|
|
15
|
+
* @param {string} [dateTo] - The date to which to filter activities.
|
|
16
|
+
* @returns {Promise<any[]>} A promise which resolves to an array of activity objects.
|
|
17
|
+
* @throws {Error} If the date format is invalid or if the resources parameter is missing.
|
|
18
|
+
*/
|
|
19
|
+
export async function getAllActivities(clientId, clientSecret, instanceUrl, resources, dateFrom, dateTo, q, fields, includeNonScheduled = false) {
|
|
20
|
+
// Validate date inputs
|
|
21
|
+
if (!isValidDate(dateFrom) || !isValidDate(dateTo)) {
|
|
22
|
+
throw new Error(`❌ Invalid date format. Expected YYYY-MM-DD.`);
|
|
23
|
+
}
|
|
24
|
+
let limit = 1000;
|
|
25
|
+
let offset = 0;
|
|
26
|
+
const allItems = [];
|
|
27
|
+
// Prepare reusable token
|
|
28
|
+
const token = await getOAuthToken(clientId, clientSecret, instanceUrl);
|
|
29
|
+
while (true) {
|
|
30
|
+
// Build URL cleanly
|
|
31
|
+
const params = new URLSearchParams({
|
|
32
|
+
offset: offset.toString(),
|
|
33
|
+
limit: limit.toString()
|
|
34
|
+
});
|
|
35
|
+
if (q)
|
|
36
|
+
params.append("q", q);
|
|
37
|
+
if (resources)
|
|
38
|
+
params.append("resources", resources);
|
|
39
|
+
if (fields)
|
|
40
|
+
params.append("fields", fields);
|
|
41
|
+
if (dateFrom)
|
|
42
|
+
params.append("dateFrom", dateFrom);
|
|
43
|
+
if (dateTo)
|
|
44
|
+
params.append("dateTo", dateTo);
|
|
45
|
+
if (includeNonScheduled)
|
|
46
|
+
params.append("includeNonScheduled", "true");
|
|
47
|
+
const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/?${params.toString()}`;
|
|
48
|
+
console.error(url);
|
|
49
|
+
console.log(`➡️ Fetching offset=${offset}, limit=${limit}`);
|
|
50
|
+
const response = await fetchWithRetry(url, clientId, clientSecret, instanceUrl, token);
|
|
51
|
+
const data = response.data;
|
|
52
|
+
if (!data.items || data.items.length === 0) {
|
|
53
|
+
console.log("✔ No more items found. Stopping pagination.");
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
allItems.push(...data.items);
|
|
57
|
+
console.log(` ✔ Received ${data.items.length} items (Total: ${allItems.length})`);
|
|
58
|
+
limit = data.limit;
|
|
59
|
+
offset += limit;
|
|
60
|
+
}
|
|
61
|
+
return allItems;
|
|
62
|
+
}
|
|
63
|
+
export async function getActivitybyId(clientId, clientSecret, instanceUrl, activityId, token = "") {
|
|
64
|
+
const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(activityId)}/`;
|
|
65
|
+
console.log(`➡️ Fetching activity by ID: ${url}`);
|
|
66
|
+
const response = await fetchWithRetry(url, clientId, clientSecret, instanceUrl, token);
|
|
67
|
+
return response;
|
|
68
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as Activity from "./activities";
|
|
2
2
|
import * as OauthTokenService from "./oauthTokenService";
|
|
3
3
|
import * as Resources from "./resources";
|
|
4
|
+
import * as Users from "./users";
|
|
4
5
|
import * as Utilities from "./utilities";
|
|
5
|
-
export { Activity, OauthTokenService, Resources, Utilities };
|
|
6
|
+
export { Activity, OauthTokenService, Resources, Users, Utilities };
|
|
6
7
|
export * from "./types";
|
|
7
8
|
declare const _default: {
|
|
8
9
|
Activity: typeof Activity;
|
|
@@ -10,5 +11,6 @@ declare const _default: {
|
|
|
10
11
|
Utilities: typeof Utilities;
|
|
11
12
|
Resources: typeof Resources;
|
|
12
13
|
downloadCSV: (csvData: import("./types").CSVRow[]) => void;
|
|
14
|
+
Users: typeof Users;
|
|
13
15
|
};
|
|
14
16
|
export default _default;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as Activity from "./activities";
|
|
2
|
+
import * as OauthTokenService from "./oauthTokenService";
|
|
3
|
+
import * as Resources from "./resources";
|
|
4
|
+
import * as Users from "./users";
|
|
5
|
+
import * as Utilities from "./utilities";
|
|
6
|
+
import { downloadCSV } from "./utilities";
|
|
7
|
+
// Export grouped namespaces
|
|
8
|
+
export { Activity, OauthTokenService, Resources, Users, Utilities };
|
|
9
|
+
// Export types
|
|
10
|
+
export * from "./types";
|
|
11
|
+
// Default export (for convenience)
|
|
12
|
+
export default {
|
|
13
|
+
Activity,
|
|
14
|
+
OauthTokenService,
|
|
15
|
+
Utilities,
|
|
16
|
+
Resources,
|
|
17
|
+
downloadCSV,
|
|
18
|
+
Users
|
|
19
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export async function getOAuthToken(clientId, clientSecret, instanceUrl) {
|
|
2
|
+
const url = `https://${instanceUrl}.fs.ocs.oraclecloud.com/rest/oauthTokenService/v2/token`;
|
|
3
|
+
const credentials = btoa(`${clientId}@${instanceUrl}:${clientSecret}`);
|
|
4
|
+
const headers = {
|
|
5
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
6
|
+
'Authorization': `Basic ${credentials}`
|
|
7
|
+
};
|
|
8
|
+
const body = new URLSearchParams({
|
|
9
|
+
'grant_type': 'client_credentials'
|
|
10
|
+
});
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetch(url, {
|
|
13
|
+
method: 'POST',
|
|
14
|
+
headers: headers,
|
|
15
|
+
body: body
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
19
|
+
}
|
|
20
|
+
const data = await response.json();
|
|
21
|
+
return data.access_token;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error('Error fetching OAuth token:', error);
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).OFSC={})}(this,function(e){"use strict";async function t(e,t,n){const r=`https://${n}.fs.ocs.oraclecloud.com/rest/oauthTokenService/v2/token`,i={"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${btoa(`${e}@${n}:${t}`)}`},o=new URLSearchParams({grant_type:"client_credentials"});try{const e=await fetch(r,{method:"POST",headers:i,body:o});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 n,r=Object.freeze({__proto__:null,getOAuthToken:t}),i={},o={};var a,s={};function c(){if(a)return s;a=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 r(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,r)}function i(){}function o(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function c(e,t,n,r,i,o){function a(e,t,r){e in n.attributeNames&&o.fatalError("Attribute "+e+" redefined"),n.addValue(e,t,r)}for(var s,c=++t,u=0;;){var l=e.charAt(c);switch(l){case"=":if(1===u)s=e.slice(t,c),u=3;else{if(2!==u)throw new Error("attribute equal must after attrName");u=3}break;case"'":case'"':if(3===u||1===u){if(1===u&&(o.warning('attribute value must after "="'),s=e.slice(t,c)),t=c+1,!((c=e.indexOf(l,t))>0))throw new Error("attribute value no end '"+l+"' match");a(s,d=e.slice(t,c).replace(/&#?\w+;/g,i),t-1),u=5}else{if(4!=u)throw new Error('attribute value must after "="');a(s,d=e.slice(t,c).replace(/&#?\w+;/g,i),t),o.warning('attribute "'+s+'" missed start quot('+l+")!!"),t=c+1,u=5}break;case"/":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:u=7,n.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return o.error("unexpected end of input"),0==u&&n.setTagName(e.slice(t,c)),c;case">":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:break;case 4:case 1:"/"===(d=e.slice(t,c)).slice(-1)&&(n.closed=!0,d=d.slice(0,-1));case 2:2===u&&(d=s),4==u?(o.warning('attribute "'+d+'" missed quot(")!'),a(s,d.replace(/&#?\w+;/g,i),t)):("http://www.w3.org/1999/xhtml"===r[""]&&d.match(/^(?:disabled|checked|selected)$/i)||o.warning('attribute "'+d+'" missed value!! "'+d+'" instead!!'),a(d,d,t));break;case 3:throw new Error("attribute value missed!!")}return c;case"":l=" ";default:if(l<=" ")switch(u){case 0:n.setTagName(e.slice(t,c)),u=6;break;case 1:s=e.slice(t,c),u=2;break;case 4:var d=e.slice(t,c).replace(/&#?\w+;/g,i);o.warning('attribute "'+d+'" missed quot(")!!'),a(s,d,t);case 5:u=6}else switch(u){case 2:n.tagName,"http://www.w3.org/1999/xhtml"===r[""]&&s.match(/^(?:disabled|checked|selected)$/i)||o.warning('attribute "'+s+'" missed value!! "'+s+'" instead2!!'),a(s,s,t),t=c,u=1;break;case 5:o.warning('attribute space is required"'+s+'"!!');case 6:u=1,t=c;break;case 3:u=4,t=c;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function u(e,t,n){for(var r=e.tagName,i=null,o=e.length;o--;){var a=e[o],s=a.qName,c=a.value;if((f=s.indexOf(":"))>0)var u=a.prefix=s.slice(0,f),l=s.slice(f+1),d="xmlns"===u&&l;else l=s,u=null,d="xmlns"===s&&"";a.localName=l,!1!==d&&(null==i&&(i={},m(n,n={})),n[d]=i[d]=c,a.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(d,c))}for(o=e.length;o--;){(u=(a=e[o]).prefix)&&("xml"===u&&(a.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==u&&(a.uri=n[u||""]))}var f;(f=r.indexOf(":"))>0?(u=e.prefix=r.slice(0,f),l=e.localName=r.slice(f+1)):(u=null,l=e.localName=r);var h=e.uri=n[u||""];if(t.startElement(h,l,r,e),!e.closed)return e.currentNSMap=n,e.localNSMap=i,!0;if(t.endElement(h,l,r),i)for(u in i)t.endPrefixMapping(u)}function l(e,t,n,r,i){if(/^(?:script|textarea)$/i.test(n)){var o=e.indexOf("</"+n+">",t),a=e.substring(t+1,o);if(/[&<]/.test(a))return/^script$/i.test(n)?(i.characters(a,0,a.length),o):(a=a.replace(/&#?\w+;/g,r),i.characters(a,0,a.length),o)}return t+1}function d(e,t,n,r){var i=r[n];return null==i&&((i=e.lastIndexOf("</"+n+">"))<t&&(i=e.lastIndexOf("</"+n)),r[n]=i),i<t}function m(e,t){for(var n in e)t[n]=e[n]}function f(e,t,n,r){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(i=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,i-t-4),i+3):(r.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var i=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,i-t-9),n.endCDATA(),i+3}var o=function(e,t){var n,r=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;i.lastIndex=t,i.exec(e);for(;n=i.exec(e);)if(r.push(n),n[1])return r}(e,t),a=o.length;if(a>1&&/!doctype/i.test(o[0][0])){var s=o[1][0],c=!1,u=!1;a>3&&(/^public$/i.test(o[2][0])?(c=o[3][0],u=a>4&&o[4][0]):/^system$/i.test(o[2][0])&&(u=o[3][0]));var l=o[a-1];return n.startDTD(s,c,u),n.endDTD(),l.index+l[0].length}return-1}function h(e,t,n){var r=e.indexOf("?>",t);if(r){var i=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return i?(i[0].length,n.processingInstruction(i[1],i[2]),r+2):-1}return-1}function p(){this.attributeNames={}}return r.prototype=new Error,r.prototype.name=r.name,i.prototype={parse:function(e,t,n){var i=this.domBuilder;i.startDocument(),m(t,t={}),function(e,t,n,i,a){function s(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function m(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?s(parseInt(t.substr(1).replace("x","0x"))):(a.error("entity not found:"+e),e)}function g(t){if(t>x){var n=e.substring(x,t).replace(/&#?\w+;/g,m);E&&w(x),i.characters(n,0,t-x),x=t}}function w(t,n){for(;t>=N&&(n=b.exec(e));)v=n.index,N=v+n[0].length,E.lineNumber++;E.columnNumber=t-v+1}var v=0,N=0,b=/.*(?:\r\n?|\n)|.*$/g,E=i.locator,y=[{currentNSMap:t}],T={},x=0;for(;;){try{var D=e.indexOf("<",x);if(D<0){if(!e.substr(x).match(/^\s*$/)){var S=i.doc,C=S.createTextNode(e.substr(x));S.appendChild(C),i.currentElement=C}return}switch(D>x&&g(D),e.charAt(D+1)){case"/":var A=e.indexOf(">",D+3),_=e.substring(D+2,A),I=y.pop();A<0?(_=e.substring(D+2).replace(/[\s<].*/,""),a.error("end tag name: "+_+" is not complete:"+I.tagName),A=D+1+_.length):_.match(/\s</)&&(_=_.replace(/[\s<].*/,""),a.error("end tag name: "+_+" maybe not complete"),A=D+1+_.length);var R=I.localNSMap,O=I.tagName==_;if(O||I.tagName&&I.tagName.toLowerCase()==_.toLowerCase()){if(i.endElement(I.uri,I.localName,_),R)for(var $ in R)i.endPrefixMapping($);O||a.fatalError("end tag name: "+_+" is not match the current start tagName:"+I.tagName)}else y.push(I);A++;break;case"?":E&&w(D),A=h(e,D,i);break;case"!":E&&w(D),A=f(e,D,i,a);break;default:E&&w(D);var k=new p,M=y[y.length-1].currentNSMap,U=(A=c(e,D,k,M,m,a),k.length);if(!k.closed&&d(e,A,k.tagName,T)&&(k.closed=!0,n.nbsp||a.warning("unclosed xml attribute")),E&&U){for(var F=o(E,{}),P=0;P<U;P++){var L=k[P];w(L.offset),L.locator=o(E,{})}i.locator=F,u(k,i,M)&&y.push(k),i.locator=E}else u(k,i,M)&&y.push(k);"http://www.w3.org/1999/xhtml"!==k.uri||k.closed?A++:A=l(e,A,k.tagName,m,i)}}catch(e){if(e instanceof r)throw e;a.error("element parse error: "+e),A=-1}A>x?x=A:g(Math.max(D,x)+1)}}(e,t,n,i,this.errorHandler),i.endDocument()}},p.prototype={setTagName:function(e){if(!n.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,r){if(!n.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:r}},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}},s.XMLReader=i,s.ParseError=r,s}var u,l,d={};function m(){if(u)return d;function e(e,t){for(var n in e)t[n]=e[n]}function t(t,n){var r=t.prototype;if(!(r instanceof n)){function i(){}i.prototype=n.prototype,e(r,i=new i),t.prototype=r=i}r.constructor!=t&&("function"!=typeof t&&console.error("unknow Class:"+t),r.constructor=t)}u=1;var n={},r=n.ELEMENT_NODE=1,i=n.ATTRIBUTE_NODE=2,o=n.TEXT_NODE=3,a=n.CDATA_SECTION_NODE=4,s=n.ENTITY_REFERENCE_NODE=5,c=n.ENTITY_NODE=6,l=n.PROCESSING_INSTRUCTION_NODE=7,m=n.COMMENT_NODE=8,f=n.DOCUMENT_NODE=9,h=n.DOCUMENT_TYPE_NODE=10,p=n.DOCUMENT_FRAGMENT_NODE=11,g=n.NOTATION_NODE=12,w={},v={};w.INDEX_SIZE_ERR=(v[1]="Index size error",1),w.DOMSTRING_SIZE_ERR=(v[2]="DOMString size error",2);var N=w.HIERARCHY_REQUEST_ERR=(v[3]="Hierarchy request error",3);w.WRONG_DOCUMENT_ERR=(v[4]="Wrong document",4),w.INVALID_CHARACTER_ERR=(v[5]="Invalid character",5),w.NO_DATA_ALLOWED_ERR=(v[6]="No data allowed",6),w.NO_MODIFICATION_ALLOWED_ERR=(v[7]="No modification allowed",7);var b=w.NOT_FOUND_ERR=(v[8]="Not found",8);w.NOT_SUPPORTED_ERR=(v[9]="Not supported",9);var E=w.INUSE_ATTRIBUTE_ERR=(v[10]="Attribute in use",10);function y(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,v[e]),this.message=v[e],Error.captureStackTrace&&Error.captureStackTrace(this,y);return n.code=e,t&&(this.message=this.message+": "+t),n}function T(){}function x(e,t){this._node=e,this._refresh=t,D(this)}function D(t){var n=t._node._inc||t._node.ownerDocument._inc;if(t._inc!=n){var r=t._refresh(t._node);re(t,"length",r.length),e(r,t),t._inc=n}}function S(){}function C(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function A(e,t,n,r){if(r?t[C(t,r)]=n:t[t.length++]=n,e){n.ownerElement=e;var i=e.ownerDocument;i&&(r&&M(i,e,r),function(e,t,n){e&&e._inc++;var r=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==r&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(i,e,n))}}function _(e,t,n){var r=C(t,n);if(!(r>=0))throw y(b,new Error(e.tagName+"@"+n));for(var i=t.length-1;r<i;)t[r]=t[++r];if(t.length=i,e){var o=e.ownerDocument;o&&(M(o,e,n),n.ownerElement=null)}}function I(e){if(this._features={},e)for(var t in e)this._features=e[t]}function R(){}function O(e){return("<"==e?"<":">"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function $(e,t){if(t(e))return!0;if(e=e.firstChild)do{if($(e,t))return!0}while(e=e.nextSibling)}function k(){}function M(e,t,n,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function U(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var i=t.firstChild,o=0;i;)r[o++]=i,i=i.nextSibling;r.length=o}}}function F(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,U(e.ownerDocument,e),t}function P(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===p){var i=t.firstChild;if(null==i)return t;var o=t.lastChild}else i=o=t;var a=n?n.previousSibling:e.lastChild;i.previousSibling=a,o.nextSibling=n,a?a.nextSibling=i:e.firstChild=i,null==n?e.lastChild=o:n.previousSibling=o;do{i.parentNode=e}while(i!==o&&(i=i.nextSibling));return U(e.ownerDocument||e,e),t.nodeType==p&&(t.firstChild=t.lastChild=null),t}function L(){this._nsMap={}}function B(){}function j(){}function q(){}function z(){}function V(){}function H(){}function Y(){}function X(){}function W(){}function G(){}function Z(){}function Q(){}function J(e,t){var n=[],r=9==this.nodeType&&this.documentElement||this,i=r.prefix,o=r.namespaceURI;if(o&&null==i&&null==(i=r.lookupPrefix(o)))var a=[{namespace:o,prefix:null}];return ee(this,n,e,t,a),n.join("")}function K(e,t,n){var r=e.prefix||"",i=e.namespaceURI;if(!r&&!i)return!1;if("xml"===r&&"http://www.w3.org/XML/1998/namespace"===i||"http://www.w3.org/2000/xmlns/"==i)return!1;for(var o=n.length;o--;){var a=n[o];if(a.prefix==r)return a.namespace!=i}return!0}function ee(e,t,n,c,u){if(c){if(!(e=c(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case r:u||(u=[]),u.length;var d=e.attributes,g=d.length,w=e.firstChild,v=e.tagName;n="http://www.w3.org/1999/xhtml"===e.namespaceURI||n,t.push("<",v);for(var N=0;N<g;N++){"xmlns"==(b=d.item(N)).prefix?u.push({prefix:b.localName,namespace:b.value}):"xmlns"==b.nodeName&&u.push({prefix:"",namespace:b.value})}for(N=0;N<g;N++){var b;if(K(b=d.item(N),0,u)){var E=b.prefix||"",y=b.namespaceURI,T=E?" xmlns:"+E:" xmlns";t.push(T,'="',y,'"'),u.push({prefix:E,namespace:y})}ee(b,t,n,c,u)}if(K(e,0,u)){E=e.prefix||"";if(y=e.namespaceURI){T=E?" xmlns:"+E:" xmlns";t.push(T,'="',y,'"'),u.push({prefix:E,namespace:y})}}if(w||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(v)){if(t.push(">"),n&&/^script$/i.test(v))for(;w;)w.data?t.push(w.data):ee(w,t,n,c,u),w=w.nextSibling;else for(;w;)ee(w,t,n,c,u),w=w.nextSibling;t.push("</",v,">")}else t.push("/>");return;case f:case p:for(w=e.firstChild;w;)ee(w,t,n,c,u),w=w.nextSibling;return;case i:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,O),'"');case o:return t.push(e.data.replace(/[<&]/g,O).replace(/]]>/g,"]]>"));case a:return t.push("<![CDATA[",e.data,"]]>");case m:return t.push("\x3c!--",e.data,"--\x3e");case h:var x=e.publicId,D=e.systemId;if(t.push("<!DOCTYPE ",e.name),x)t.push(" PUBLIC ",x),D&&"."!=D&&t.push(" ",D),t.push(">");else if(D&&"."!=D)t.push(" SYSTEM ",D,">");else{var S=e.internalSubset;S&&t.push(" [",S,"]"),t.push(">")}return;case l: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 o;switch(t.nodeType){case r:(o=t.cloneNode(!1)).ownerDocument=e;case p:break;case i:n=!0}if(o||(o=t.cloneNode(!1)),o.ownerDocument=e,o.parentNode=null,n)for(var a=t.firstChild;a;)o.appendChild(te(e,a,n)),a=a.nextSibling;return o}function ne(e,t,n){var o=new t.constructor;for(var a in t){var s=t[a];"object"!=typeof s&&s!=o[a]&&(o[a]=s)}switch(t.childNodes&&(o.childNodes=new T),o.ownerDocument=e,o.nodeType){case r:var c=t.attributes,u=o.attributes=new S,l=c.length;u._ownerElement=o;for(var d=0;d<l;d++)o.setAttributeNode(ne(e,c.item(d),!0));break;case i:n=!0}if(n)for(var m=t.firstChild;m;)o.appendChild(ne(e,m,n)),m=m.nextSibling;return o}function re(e,t,n){e[t]=n}w.INVALID_STATE_ERR=(v[11]="Invalid state",11),w.SYNTAX_ERR=(v[12]="Syntax error",12),w.INVALID_MODIFICATION_ERR=(v[13]="Invalid modification",13),w.NAMESPACE_ERR=(v[14]="Invalid namespace",14),w.INVALID_ACCESS_ERR=(v[15]="Invalid access",15),y.prototype=Error.prototype,e(w,y),T.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)ee(this[r],n,e,t);return n.join("")}},x.prototype.item=function(e){return D(this),this[e]},t(x,T),S.prototype={length:0,item:T.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 y(E);var n=this.getNamedItem(e.nodeName);return A(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new y(E);return t=this.getNamedItemNS(e.namespaceURI,e.localName),A(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return _(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return _(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},I.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return!(!n||t&&!(t in n))},createDocument:function(e,t,n){var r=new k;if(r.implementation=this,r.childNodes=new T,r.doctype=n,n&&r.appendChild(n),t){var i=r.createElementNS(e,t);r.appendChild(i)}return r},createDocumentType:function(e,t,n){var r=new H;return r.name=e,r.nodeName=e,r.publicId=t,r.systemId=n,r}},R.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 P(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return F(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==o&&e.nodeType==o?(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 r in n)if(n[r]==e)return r;t=t.nodeType==i?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==i?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},e(n,R),e(n,R.prototype),k.prototype={nodeName:"#document",nodeType:f,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==p){for(var n=e.firstChild;n;){var i=n.nextSibling;this.insertBefore(n,t),n=i}return e}return null==this.documentElement&&e.nodeType==r&&(this.documentElement=e),P(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),F(this,e)},importNode:function(e,t){return te(this,e,t)},getElementById:function(e){var t=null;return $(this.documentElement,function(n){if(n.nodeType==r&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\s)"+e+"(\\s|$)");return new x(this,function(e){var n=[];return $(e.documentElement,function(i){i!==e&&i.nodeType==r&&t.test(i.getAttribute("class"))&&n.push(i)}),n})},createElement:function(e){var t=new L;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new T,(t.attributes=new S)._ownerElement=t,t},createDocumentFragment:function(){var e=new G;return e.ownerDocument=this,e.childNodes=new T,e},createTextNode:function(e){var t=new q;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new z;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new V;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new Z;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new B;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 L,r=t.split(":"),i=n.attributes=new S;return n.childNodes=new T,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new B,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},t(k,R),L.prototype={nodeType:r,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 r=e.lastChild;n.removeChild(t),r=e.lastChild}return r=e.lastChild,t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,U(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 r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new x(this,function(t){var n=[];return $(t,function(i){i===t||i.nodeType!=r||"*"!==e&&i.tagName!=e||n.push(i)}),n})},getElementsByTagNameNS:function(e,t){return new x(this,function(n){var i=[];return $(n,function(o){o===n||o.nodeType!==r||"*"!==e&&o.namespaceURI!==e||"*"!==t&&o.localName!=t||i.push(o)}),i})}},k.prototype.getElementsByTagName=L.prototype.getElementsByTagName,k.prototype.getElementsByTagNameNS=L.prototype.getElementsByTagNameNS,t(L,R),B.prototype.nodeType=i,t(B,R),j.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(v[N])},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(j,R),q.prototype={nodeName:"#text",nodeType:o,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 r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},t(q,j),z.prototype={nodeName:"#comment",nodeType:m},t(z,j),V.prototype={nodeName:"#cdata-section",nodeType:a},t(V,j),H.prototype.nodeType=h,t(H,R),Y.prototype.nodeType=g,t(Y,R),X.prototype.nodeType=c,t(X,R),W.prototype.nodeType=s,t(W,R),G.prototype.nodeName="#document-fragment",G.prototype.nodeType=p,t(G,R),Z.prototype.nodeType=l,t(Z,R),Q.prototype.serializeToString=function(e,t,n){return J.call(e,t,n)},R.prototype.toString=J;try{if(Object.defineProperty){function ie(e){switch(e.nodeType){case r:case p:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(ie(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(x.prototype,"length",{get:function(){return D(this),this.$$length}}),Object.defineProperty(R.prototype,"textContent",{get:function(){return ie(this)},set:function(e){switch(this.nodeType){case r: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}}}),re=function(e,t,n){e["$$"+t]=n}}}catch(oe){}return d.Node=R,d.DOMException=y,d.DOMImplementation=I,d.XMLSerializer=Q,d}var f=function(){if(l)return i;function e(e){this.options=e||{locator:{}}}function t(){this.cdata=!1}function r(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function a(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function s(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 u(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}l=1,e.prototype.parseFromString=function(e,n){var r=this.options,i=new h,o=r.domBuilder||new t,s=r.errorHandler,c=r.locator,u=r.xmlns||{},l=/\/x?html?$/.test(n),m=l?d.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return c&&o.setDocumentLocator(c),i.errorHandler=function(e,n,r){if(!e){if(n instanceof t)return n;e=n}var i={},o=e instanceof Function;function s(t){var n=e[t];!n&&o&&(n=2==e.length?function(n){e(t,n)}:e),i[t]=n&&function(e){n("[xmldom "+t+"]\t"+e+a(r))}||function(){}}return r=r||{},s("warning"),s("error"),s("fatalError"),i}(s,o,c),i.domBuilder=r.domBuilder||o,l&&(u[""]="http://www.w3.org/1999/xhtml"),u.xml=u.xml||"http://www.w3.org/XML/1998/namespace",e&&"string"==typeof e?i.parse(e,u,m):i.errorHandler.error("invalid doc source"),o.doc},t.prototype={startDocument:function(){this.doc=(new g).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,i){var o=this.doc,a=o.createElementNS(e,n||t),s=i.length;u(this,a),this.currentElement=a,this.locator&&r(this.locator,a);for(var c=0;c<s;c++){e=i.getURI(c);var l=i.getValue(c),d=(n=i.getQName(c),o.createAttributeNS(e,n));this.locator&&r(i.getLocator(c),d),d.value=d.nodeValue=l,a.setAttributeNode(d)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName,this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&r(this.locator,n),u(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=s.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&&r(this.locator,i)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=s.apply(this,arguments);var i=this.doc.createComment(e);this.locator&&r(this.locator,i),u(this,i)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var i=this.doc.implementation;if(i&&i.createDocumentType){var o=i.createDocumentType(e,t,n);this.locator&&r(this.locator,o),u(this,o)}},warning:function(e){console.warn("[xmldom warning]\t"+e,a(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,a(this.locator))},fatalError:function(e){throw new p(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 d=(n||(n=1,o.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:"♦"}),o),f=c(),h=f.XMLReader,p=f.ParseError,g=i.DOMImplementation=m().DOMImplementation;return i.XMLSerializer=m().XMLSerializer,i.DOMParser=e,i.__DOMHandler=t,i}();const h=async(e,n,r,i,o,a)=>{const s=async t=>fetch(e,{method:"PATCH",headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)});let c=await s(o);if(401===c.status&&(console.warn("⚠️ Token expired — renewing token…"),o=await t(n,r,i),c=await s(o)),!c.ok)throw new Error(`HTTP ${c.status}: ${await c.text()}`);return{data:await c.json(),token:o}},p=async(e,n,r,i,o,a=5,s=500)=>{const c=async t=>fetch(e,{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});let u=await c(o);if(401===u.status&&(console.warn("⚠️ Token expired — renewing token…"),o=await t(n,r,i),u=await c(o)),429===u.status&&a>0){const t=u.headers.get("Retry-After");console.log("⚠️ 429 received. Retrying...",t);const c=t?1e3*Number(t):s;return console.warn(`⚠️ 429 received. Retrying in ${c}ms... (${a} left)`),await new Promise(e=>setTimeout(e,c)),p(e,n,r,i,o,a-1,2*s)}if(!u.ok){const e=await u.text();throw new Error(`❌ Request failed: ${u.status} ${u.statusText}\n${e}`)}return{data:await u.json(),token:o}};function g(e){if(!e||0===e.length)throw new Error("CSV creation failed: no rows provided.");const t=new Set;e.forEach(e=>{Object.keys(e).forEach(e=>t.add(e))});const n=Array.from(t);return[n.join(","),...e.map(e=>n.map(t=>function(e){if(null==e)return"";const t=String(e);if(t.includes('"')||t.includes(",")||t.includes("\n"))return`"${t.replace(/"/g,'""')}"`;return t}(e[t])).join(","))].join("\n")}const w=e=>{if(!e.length)return t="No data to download",n="error",void console.log(`[${n.toUpperCase()}] ${t}`);var t,n;const r=g(e),i=new Blob([r],{type:"text/csv;charset=utf-8;"}),o=document.createElement("a");o.href=URL.createObjectURL(i),o.download=`data_${Date.now()}.csv`,o.click(),setTimeout(()=>URL.revokeObjectURL(o.href),100)};var v=Object.freeze({__proto__:null,downloadCSV:w,fetchWithRetry:p,patchWithRetry:h,stringCsv:g,xmlNodeToObjects:function(e,t){const n=(new f.DOMParser).parseFromString(e,"application/xml"),r=Array.from(n.getElementsByTagName(t));if(0===r.length)throw new Error(`No <${t}> nodes found`);return r.map(e=>{var t,n;const r={},i=Array.from(e.getElementsByTagName("Field"));for(const e of i){const i=e.getAttribute("name");i&&(r[i]=null!==(n=null===(t=e.textContent)||void 0===t?void 0:t.trim())&&void 0!==n?n:"")}return r})}});const N=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);var b=Object.freeze({__proto__:null,getActivitybyId:async function(e,t,n,r,i=""){const o=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(r)}/`;return console.log(`➡️ Fetching activity by ID: ${o}`),await p(o,e,t,n,i)},getAllActivities:async function(e,n,r,i,o,a,s,c,u=!1){if(!N(o)||!N(a))throw new Error("❌ Invalid date format. Expected YYYY-MM-DD.");let l=1e3,d=0;const m=[],f=await t(e,n,r);for(;;){const t=new URLSearchParams({offset:d.toString(),limit:l.toString()});s&&t.append("q",s),i&&t.append("resources",i),c&&t.append("fields",c),o&&t.append("dateFrom",o),a&&t.append("dateTo",a),u&&t.append("includeNonScheduled","true");const h=`https://${r}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/?${t.toString()}`;console.error(h),console.log(`➡️ Fetching offset=${d}, limit=${l}`);const g=(await p(h,e,n,r,f)).data;if(!g.items||0===g.items.length){console.log("✔ No more items found. Stopping pagination.");break}m.push(...g.items),console.log(` ✔ Received ${g.items.length} items (Total: ${m.length})`),l=g.limit,d+=l}return m}});async function E(e,t,n,r=""){let i=0;const o=async(r,a)=>{var s;i++,i%20==0&&(console.warn(` Waiting 10 seconds after ${i} API calls to avoid server rate limits.`),await(s=1e4,new Promise(e=>setTimeout(e,s))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/?offset=${r}&limit=100`,u=await p(c,e,t,n,a),{items:l,totalResults:d}=u.data,m=l.length;if(console.log(`Received ${m} items (Total: ${r+m})`),r+m>=d)return l;const f=await o(r+m,u.token);return[...l,...f]};return o(0,r)}async function y(e,t,n,r,i,o=""){return h(`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${r}`,e,t,n,o,i)}var T=Object.freeze({__proto__:null,AllResources:E,resetResourcesEmail:async function(e,t,n,r="noreply.com",i=""){const o=(await E(e,t,n,i)).filter(e=>e.email),a=[];for(let s=0;s<o.length;s+=200){const c=o.slice(s,s+200);for(const s of c){if(console.log(`Total : ${o.length}`,`Total updated: ${a.length}`),!s.email)continue;if(!s.resourceId){console.warn(`⚠️ Resource ID not found for ${JSON.stringify(s)}`);continue}let c=s.email;if(c.includes("@")||(c=c.replace(r,`@${r}`)),c.includes(r)){a.push({id:s.resourceId,email:s.email,newEmail:"",comment:"Email already updated"});continue}c=s.email.replace(/@.*/,`@${r}`),console.log(`Updating email for ${s.resourceId} (${s.email} -> ${c})`);const u={email:c},l=await y(e,t,n,s.resourceId,u,i);i=l.token,a.push({id:l.data.resourceId,email:s.email,newEmail:l.data.email})}s+200<o.length&&(console.warn("⏳ Waiting 10 seconds before next batch...to avoid server rate limits."),await new Promise(e=>setTimeout(e,1e4)))}return a},updateResource:y}),x={Activity:b,OauthTokenService:r,Utilities:v,Resources:T,downloadCSV:w};e.Activity=b,e.OauthTokenService=r,e.Resources=T,e.Utilities=v,e.default=x,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).OFSC={})}(this,function(e){"use strict";async function t(e,t,n){const r=`https://${n}.fs.ocs.oraclecloud.com/rest/oauthTokenService/v2/token`,i={"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${btoa(`${e}@${n}:${t}`)}`},o=new URLSearchParams({grant_type:"client_credentials"});try{const e=await fetch(r,{method:"POST",headers:i,body:o});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 n,r=Object.freeze({__proto__:null,getOAuthToken:t}),i={},o={};var a,s={};function c(){if(a)return s;a=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 r(e,t){this.message=e,this.locator=t,Error.captureStackTrace&&Error.captureStackTrace(this,r)}function i(){}function o(e,t){return t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}function c(e,t,n,r,i,o){function a(e,t,r){e in n.attributeNames&&o.fatalError("Attribute "+e+" redefined"),n.addValue(e,t,r)}for(var s,c=++t,u=0;;){var l=e.charAt(c);switch(l){case"=":if(1===u)s=e.slice(t,c),u=3;else{if(2!==u)throw new Error("attribute equal must after attrName");u=3}break;case"'":case'"':if(3===u||1===u){if(1===u&&(o.warning('attribute value must after "="'),s=e.slice(t,c)),t=c+1,!((c=e.indexOf(l,t))>0))throw new Error("attribute value no end '"+l+"' match");a(s,d=e.slice(t,c).replace(/&#?\w+;/g,i),t-1),u=5}else{if(4!=u)throw new Error('attribute value must after "="');a(s,d=e.slice(t,c).replace(/&#?\w+;/g,i),t),o.warning('attribute "'+s+'" missed start quot('+l+")!!"),t=c+1,u=5}break;case"/":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:u=7,n.closed=!0;case 4:case 1:case 2:break;default:throw new Error("attribute invalid close char('/')")}break;case"":return o.error("unexpected end of input"),0==u&&n.setTagName(e.slice(t,c)),c;case">":switch(u){case 0:n.setTagName(e.slice(t,c));case 5:case 6:case 7:break;case 4:case 1:"/"===(d=e.slice(t,c)).slice(-1)&&(n.closed=!0,d=d.slice(0,-1));case 2:2===u&&(d=s),4==u?(o.warning('attribute "'+d+'" missed quot(")!'),a(s,d.replace(/&#?\w+;/g,i),t)):("http://www.w3.org/1999/xhtml"===r[""]&&d.match(/^(?:disabled|checked|selected)$/i)||o.warning('attribute "'+d+'" missed value!! "'+d+'" instead!!'),a(d,d,t));break;case 3:throw new Error("attribute value missed!!")}return c;case"":l=" ";default:if(l<=" ")switch(u){case 0:n.setTagName(e.slice(t,c)),u=6;break;case 1:s=e.slice(t,c),u=2;break;case 4:var d=e.slice(t,c).replace(/&#?\w+;/g,i);o.warning('attribute "'+d+'" missed quot(")!!'),a(s,d,t);case 5:u=6}else switch(u){case 2:n.tagName,"http://www.w3.org/1999/xhtml"===r[""]&&s.match(/^(?:disabled|checked|selected)$/i)||o.warning('attribute "'+s+'" missed value!! "'+s+'" instead2!!'),a(s,s,t),t=c,u=1;break;case 5:o.warning('attribute space is required"'+s+'"!!');case 6:u=1,t=c;break;case 3:u=4,t=c;break;case 7:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function u(e,t,n){for(var r=e.tagName,i=null,o=e.length;o--;){var a=e[o],s=a.qName,c=a.value;if((f=s.indexOf(":"))>0)var u=a.prefix=s.slice(0,f),l=s.slice(f+1),d="xmlns"===u&&l;else l=s,u=null,d="xmlns"===s&&"";a.localName=l,!1!==d&&(null==i&&(i={},m(n,n={})),n[d]=i[d]=c,a.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(d,c))}for(o=e.length;o--;){(u=(a=e[o]).prefix)&&("xml"===u&&(a.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==u&&(a.uri=n[u||""]))}var f;(f=r.indexOf(":"))>0?(u=e.prefix=r.slice(0,f),l=e.localName=r.slice(f+1)):(u=null,l=e.localName=r);var h=e.uri=n[u||""];if(t.startElement(h,l,r,e),!e.closed)return e.currentNSMap=n,e.localNSMap=i,!0;if(t.endElement(h,l,r),i)for(u in i)t.endPrefixMapping(u)}function l(e,t,n,r,i){if(/^(?:script|textarea)$/i.test(n)){var o=e.indexOf("</"+n+">",t),a=e.substring(t+1,o);if(/[&<]/.test(a))return/^script$/i.test(n)?(i.characters(a,0,a.length),o):(a=a.replace(/&#?\w+;/g,r),i.characters(a,0,a.length),o)}return t+1}function d(e,t,n,r){var i=r[n];return null==i&&((i=e.lastIndexOf("</"+n+">"))<t&&(i=e.lastIndexOf("</"+n)),r[n]=i),i<t}function m(e,t){for(var n in e)t[n]=e[n]}function f(e,t,n,r){if("-"===e.charAt(t+2))return"-"===e.charAt(t+3)?(i=e.indexOf("--\x3e",t+4))>t?(n.comment(e,t+4,i-t-4),i+3):(r.error("Unclosed comment"),-1):-1;if("CDATA["==e.substr(t+3,6)){var i=e.indexOf("]]>",t+9);return n.startCDATA(),n.characters(e,t+9,i-t-9),n.endCDATA(),i+3}var o=function(e,t){var n,r=[],i=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;i.lastIndex=t,i.exec(e);for(;n=i.exec(e);)if(r.push(n),n[1])return r}(e,t),a=o.length;if(a>1&&/!doctype/i.test(o[0][0])){var s=o[1][0],c=!1,u=!1;a>3&&(/^public$/i.test(o[2][0])?(c=o[3][0],u=a>4&&o[4][0]):/^system$/i.test(o[2][0])&&(u=o[3][0]));var l=o[a-1];return n.startDTD(s,c,u),n.endDTD(),l.index+l[0].length}return-1}function h(e,t,n){var r=e.indexOf("?>",t);if(r){var i=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);return i?(i[0].length,n.processingInstruction(i[1],i[2]),r+2):-1}return-1}function p(){this.attributeNames={}}return r.prototype=new Error,r.prototype.name=r.name,i.prototype={parse:function(e,t,n){var i=this.domBuilder;i.startDocument(),m(t,t={}),function(e,t,n,i,a){function s(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}function m(e){var t=e.slice(1,-1);return t in n?n[t]:"#"===t.charAt(0)?s(parseInt(t.substr(1).replace("x","0x"))):(a.error("entity not found:"+e),e)}function g(t){if(t>x){var n=e.substring(x,t).replace(/&#?\w+;/g,m);E&&w(x),i.characters(n,0,t-x),x=t}}function w(t,n){for(;t>=N&&(n=b.exec(e));)v=n.index,N=v+n[0].length,E.lineNumber++;E.columnNumber=t-v+1}var v=0,N=0,b=/.*(?:\r\n?|\n)|.*$/g,E=i.locator,y=[{currentNSMap:t}],T={},x=0;for(;;){try{var D=e.indexOf("<",x);if(D<0){if(!e.substr(x).match(/^\s*$/)){var S=i.doc,A=S.createTextNode(e.substr(x));S.appendChild(A),i.currentElement=A}return}switch(D>x&&g(D),e.charAt(D+1)){case"/":var C=e.indexOf(">",D+3),_=e.substring(D+2,C),I=y.pop();C<0?(_=e.substring(D+2).replace(/[\s<].*/,""),a.error("end tag name: "+_+" is not complete:"+I.tagName),C=D+1+_.length):_.match(/\s</)&&(_=_.replace(/[\s<].*/,""),a.error("end tag name: "+_+" maybe not complete"),C=D+1+_.length);var R=I.localNSMap,O=I.tagName==_;if(O||I.tagName&&I.tagName.toLowerCase()==_.toLowerCase()){if(i.endElement(I.uri,I.localName,_),R)for(var $ in R)i.endPrefixMapping($);O||a.fatalError("end tag name: "+_+" is not match the current start tagName:"+I.tagName)}else y.push(I);C++;break;case"?":E&&w(D),C=h(e,D,i);break;case"!":E&&w(D),C=f(e,D,i,a);break;default:E&&w(D);var k=new p,M=y[y.length-1].currentNSMap,U=(C=c(e,D,k,M,m,a),k.length);if(!k.closed&&d(e,C,k.tagName,T)&&(k.closed=!0,n.nbsp||a.warning("unclosed xml attribute")),E&&U){for(var P=o(E,{}),F=0;F<U;F++){var L=k[F];w(L.offset),L.locator=o(E,{})}i.locator=P,u(k,i,M)&&y.push(k),i.locator=E}else u(k,i,M)&&y.push(k);"http://www.w3.org/1999/xhtml"!==k.uri||k.closed?C++:C=l(e,C,k.tagName,m,i)}}catch(e){if(e instanceof r)throw e;a.error("element parse error: "+e),C=-1}C>x?x=C:g(Math.max(D,x)+1)}}(e,t,n,i,this.errorHandler),i.endDocument()}},p.prototype={setTagName:function(e){if(!n.test(e))throw new Error("invalid tagName:"+e);this.tagName=e},addValue:function(e,t,r){if(!n.test(e))throw new Error("invalid attribute:"+e);this.attributeNames[e]=this.length,this[this.length++]={qName:e,value:t,offset:r}},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}},s.XMLReader=i,s.ParseError=r,s}var u,l,d={};function m(){if(u)return d;function e(e,t){for(var n in e)t[n]=e[n]}function t(t,n){var r=t.prototype;if(!(r instanceof n)){function i(){}i.prototype=n.prototype,e(r,i=new i),t.prototype=r=i}r.constructor!=t&&("function"!=typeof t&&console.error("unknow Class:"+t),r.constructor=t)}u=1;var n={},r=n.ELEMENT_NODE=1,i=n.ATTRIBUTE_NODE=2,o=n.TEXT_NODE=3,a=n.CDATA_SECTION_NODE=4,s=n.ENTITY_REFERENCE_NODE=5,c=n.ENTITY_NODE=6,l=n.PROCESSING_INSTRUCTION_NODE=7,m=n.COMMENT_NODE=8,f=n.DOCUMENT_NODE=9,h=n.DOCUMENT_TYPE_NODE=10,p=n.DOCUMENT_FRAGMENT_NODE=11,g=n.NOTATION_NODE=12,w={},v={};w.INDEX_SIZE_ERR=(v[1]="Index size error",1),w.DOMSTRING_SIZE_ERR=(v[2]="DOMString size error",2);var N=w.HIERARCHY_REQUEST_ERR=(v[3]="Hierarchy request error",3);w.WRONG_DOCUMENT_ERR=(v[4]="Wrong document",4),w.INVALID_CHARACTER_ERR=(v[5]="Invalid character",5),w.NO_DATA_ALLOWED_ERR=(v[6]="No data allowed",6),w.NO_MODIFICATION_ALLOWED_ERR=(v[7]="No modification allowed",7);var b=w.NOT_FOUND_ERR=(v[8]="Not found",8);w.NOT_SUPPORTED_ERR=(v[9]="Not supported",9);var E=w.INUSE_ATTRIBUTE_ERR=(v[10]="Attribute in use",10);function y(e,t){if(t instanceof Error)var n=t;else n=this,Error.call(this,v[e]),this.message=v[e],Error.captureStackTrace&&Error.captureStackTrace(this,y);return n.code=e,t&&(this.message=this.message+": "+t),n}function T(){}function x(e,t){this._node=e,this._refresh=t,D(this)}function D(t){var n=t._node._inc||t._node.ownerDocument._inc;if(t._inc!=n){var r=t._refresh(t._node);re(t,"length",r.length),e(r,t),t._inc=n}}function S(){}function A(e,t){for(var n=e.length;n--;)if(e[n]===t)return n}function C(e,t,n,r){if(r?t[A(t,r)]=n:t[t.length++]=n,e){n.ownerElement=e;var i=e.ownerDocument;i&&(r&&M(i,e,r),function(e,t,n){e&&e._inc++;var r=n.namespaceURI;"http://www.w3.org/2000/xmlns/"==r&&(t._nsMap[n.prefix?n.localName:""]=n.value)}(i,e,n))}}function _(e,t,n){var r=A(t,n);if(!(r>=0))throw y(b,new Error(e.tagName+"@"+n));for(var i=t.length-1;r<i;)t[r]=t[++r];if(t.length=i,e){var o=e.ownerDocument;o&&(M(o,e,n),n.ownerElement=null)}}function I(e){if(this._features={},e)for(var t in e)this._features=e[t]}function R(){}function O(e){return("<"==e?"<":">"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function $(e,t){if(t(e))return!0;if(e=e.firstChild)do{if($(e,t))return!0}while(e=e.nextSibling)}function k(){}function M(e,t,n,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function U(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var i=t.firstChild,o=0;i;)r[o++]=i,i=i.nextSibling;r.length=o}}}function P(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,U(e.ownerDocument,e),t}function F(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===p){var i=t.firstChild;if(null==i)return t;var o=t.lastChild}else i=o=t;var a=n?n.previousSibling:e.lastChild;i.previousSibling=a,o.nextSibling=n,a?a.nextSibling=i:e.firstChild=i,null==n?e.lastChild=o:n.previousSibling=o;do{i.parentNode=e}while(i!==o&&(i=i.nextSibling));return U(e.ownerDocument||e,e),t.nodeType==p&&(t.firstChild=t.lastChild=null),t}function L(){this._nsMap={}}function j(){}function B(){}function q(){}function z(){}function V(){}function H(){}function Y(){}function X(){}function W(){}function G(){}function Z(){}function Q(){}function J(e,t){var n=[],r=9==this.nodeType&&this.documentElement||this,i=r.prefix,o=r.namespaceURI;if(o&&null==i&&null==(i=r.lookupPrefix(o)))var a=[{namespace:o,prefix:null}];return ee(this,n,e,t,a),n.join("")}function K(e,t,n){var r=e.prefix||"",i=e.namespaceURI;if(!r&&!i)return!1;if("xml"===r&&"http://www.w3.org/XML/1998/namespace"===i||"http://www.w3.org/2000/xmlns/"==i)return!1;for(var o=n.length;o--;){var a=n[o];if(a.prefix==r)return a.namespace!=i}return!0}function ee(e,t,n,c,u){if(c){if(!(e=c(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case r:u||(u=[]),u.length;var d=e.attributes,g=d.length,w=e.firstChild,v=e.tagName;n="http://www.w3.org/1999/xhtml"===e.namespaceURI||n,t.push("<",v);for(var N=0;N<g;N++){"xmlns"==(b=d.item(N)).prefix?u.push({prefix:b.localName,namespace:b.value}):"xmlns"==b.nodeName&&u.push({prefix:"",namespace:b.value})}for(N=0;N<g;N++){var b;if(K(b=d.item(N),0,u)){var E=b.prefix||"",y=b.namespaceURI,T=E?" xmlns:"+E:" xmlns";t.push(T,'="',y,'"'),u.push({prefix:E,namespace:y})}ee(b,t,n,c,u)}if(K(e,0,u)){E=e.prefix||"";if(y=e.namespaceURI){T=E?" xmlns:"+E:" xmlns";t.push(T,'="',y,'"'),u.push({prefix:E,namespace:y})}}if(w||n&&!/^(?:meta|link|img|br|hr|input)$/i.test(v)){if(t.push(">"),n&&/^script$/i.test(v))for(;w;)w.data?t.push(w.data):ee(w,t,n,c,u),w=w.nextSibling;else for(;w;)ee(w,t,n,c,u),w=w.nextSibling;t.push("</",v,">")}else t.push("/>");return;case f:case p:for(w=e.firstChild;w;)ee(w,t,n,c,u),w=w.nextSibling;return;case i:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,O),'"');case o:return t.push(e.data.replace(/[<&]/g,O).replace(/]]>/g,"]]>"));case a:return t.push("<![CDATA[",e.data,"]]>");case m:return t.push("\x3c!--",e.data,"--\x3e");case h:var x=e.publicId,D=e.systemId;if(t.push("<!DOCTYPE ",e.name),x)t.push(" PUBLIC ",x),D&&"."!=D&&t.push(" ",D),t.push(">");else if(D&&"."!=D)t.push(" SYSTEM ",D,">");else{var S=e.internalSubset;S&&t.push(" [",S,"]"),t.push(">")}return;case l: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 o;switch(t.nodeType){case r:(o=t.cloneNode(!1)).ownerDocument=e;case p:break;case i:n=!0}if(o||(o=t.cloneNode(!1)),o.ownerDocument=e,o.parentNode=null,n)for(var a=t.firstChild;a;)o.appendChild(te(e,a,n)),a=a.nextSibling;return o}function ne(e,t,n){var o=new t.constructor;for(var a in t){var s=t[a];"object"!=typeof s&&s!=o[a]&&(o[a]=s)}switch(t.childNodes&&(o.childNodes=new T),o.ownerDocument=e,o.nodeType){case r:var c=t.attributes,u=o.attributes=new S,l=c.length;u._ownerElement=o;for(var d=0;d<l;d++)o.setAttributeNode(ne(e,c.item(d),!0));break;case i:n=!0}if(n)for(var m=t.firstChild;m;)o.appendChild(ne(e,m,n)),m=m.nextSibling;return o}function re(e,t,n){e[t]=n}w.INVALID_STATE_ERR=(v[11]="Invalid state",11),w.SYNTAX_ERR=(v[12]="Syntax error",12),w.INVALID_MODIFICATION_ERR=(v[13]="Invalid modification",13),w.NAMESPACE_ERR=(v[14]="Invalid namespace",14),w.INVALID_ACCESS_ERR=(v[15]="Invalid access",15),y.prototype=Error.prototype,e(w,y),T.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;r<this.length;r++)ee(this[r],n,e,t);return n.join("")}},x.prototype.item=function(e){return D(this),this[e]},t(x,T),S.prototype={length:0,item:T.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 y(E);var n=this.getNamedItem(e.nodeName);return C(this._ownerElement,this,e,n),n},setNamedItemNS:function(e){var t,n=e.ownerElement;if(n&&n!=this._ownerElement)throw new y(E);return t=this.getNamedItemNS(e.namespaceURI,e.localName),C(this._ownerElement,this,e,t),t},removeNamedItem:function(e){var t=this.getNamedItem(e);return _(this._ownerElement,this,t),t},removeNamedItemNS:function(e,t){var n=this.getNamedItemNS(e,t);return _(this._ownerElement,this,n),n},getNamedItemNS:function(e,t){for(var n=this.length;n--;){var r=this[n];if(r.localName==t&&r.namespaceURI==e)return r}return null}},I.prototype={hasFeature:function(e,t){var n=this._features[e.toLowerCase()];return!(!n||t&&!(t in n))},createDocument:function(e,t,n){var r=new k;if(r.implementation=this,r.childNodes=new T,r.doctype=n,n&&r.appendChild(n),t){var i=r.createElementNS(e,t);r.appendChild(i)}return r},createDocumentType:function(e,t,n){var r=new H;return r.name=e,r.nodeName=e,r.publicId=t,r.systemId=n,r}},R.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 F(this,e,t)},replaceChild:function(e,t){this.insertBefore(e,t),t&&this.removeChild(t)},removeChild:function(e){return P(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==o&&e.nodeType==o?(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 r in n)if(n[r]==e)return r;t=t.nodeType==i?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==i?t.ownerDocument:t.parentNode}return null},isDefaultNamespace:function(e){return null==this.lookupPrefix(e)}},e(n,R),e(n,R.prototype),k.prototype={nodeName:"#document",nodeType:f,doctype:null,documentElement:null,_inc:1,insertBefore:function(e,t){if(e.nodeType==p){for(var n=e.firstChild;n;){var i=n.nextSibling;this.insertBefore(n,t),n=i}return e}return null==this.documentElement&&e.nodeType==r&&(this.documentElement=e),F(this,e,t),e.ownerDocument=this,e},removeChild:function(e){return this.documentElement==e&&(this.documentElement=null),P(this,e)},importNode:function(e,t){return te(this,e,t)},getElementById:function(e){var t=null;return $(this.documentElement,function(n){if(n.nodeType==r&&n.getAttribute("id")==e)return t=n,!0}),t},getElementsByClassName:function(e){var t=new RegExp("(^|\\s)"+e+"(\\s|$)");return new x(this,function(e){var n=[];return $(e.documentElement,function(i){i!==e&&i.nodeType==r&&t.test(i.getAttribute("class"))&&n.push(i)}),n})},createElement:function(e){var t=new L;return t.ownerDocument=this,t.nodeName=e,t.tagName=e,t.childNodes=new T,(t.attributes=new S)._ownerElement=t,t},createDocumentFragment:function(){var e=new G;return e.ownerDocument=this,e.childNodes=new T,e},createTextNode:function(e){var t=new q;return t.ownerDocument=this,t.appendData(e),t},createComment:function(e){var t=new z;return t.ownerDocument=this,t.appendData(e),t},createCDATASection:function(e){var t=new V;return t.ownerDocument=this,t.appendData(e),t},createProcessingInstruction:function(e,t){var n=new Z;return n.ownerDocument=this,n.tagName=n.target=e,n.nodeValue=n.data=t,n},createAttribute:function(e){var t=new j;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 L,r=t.split(":"),i=n.attributes=new S;return n.childNodes=new T,n.ownerDocument=this,n.nodeName=t,n.tagName=t,n.namespaceURI=e,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,i._ownerElement=n,n},createAttributeNS:function(e,t){var n=new j,r=t.split(":");return n.ownerDocument=this,n.nodeName=t,n.name=t,n.namespaceURI=e,n.specified=!0,2==r.length?(n.prefix=r[0],n.localName=r[1]):n.localName=t,n}},t(k,R),L.prototype={nodeType:r,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 r=e.lastChild;n.removeChild(t),r=e.lastChild}return r=e.lastChild,t.parentNode=e,t.previousSibling=r,t.nextSibling=null,r?r.nextSibling=t:e.firstChild=t,e.lastChild=t,U(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 r=this.ownerDocument.createAttributeNS(e,t);r.value=r.nodeValue=""+n,this.setAttributeNode(r)},getAttributeNodeNS:function(e,t){return this.attributes.getNamedItemNS(e,t)},getElementsByTagName:function(e){return new x(this,function(t){var n=[];return $(t,function(i){i===t||i.nodeType!=r||"*"!==e&&i.tagName!=e||n.push(i)}),n})},getElementsByTagNameNS:function(e,t){return new x(this,function(n){var i=[];return $(n,function(o){o===n||o.nodeType!==r||"*"!==e&&o.namespaceURI!==e||"*"!==t&&o.localName!=t||i.push(o)}),i})}},k.prototype.getElementsByTagName=L.prototype.getElementsByTagName,k.prototype.getElementsByTagNameNS=L.prototype.getElementsByTagNameNS,t(L,R),j.prototype.nodeType=i,t(j,R),B.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(v[N])},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(B,R),q.prototype={nodeName:"#text",nodeType:o,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 r=this.ownerDocument.createTextNode(n);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}},t(q,B),z.prototype={nodeName:"#comment",nodeType:m},t(z,B),V.prototype={nodeName:"#cdata-section",nodeType:a},t(V,B),H.prototype.nodeType=h,t(H,R),Y.prototype.nodeType=g,t(Y,R),X.prototype.nodeType=c,t(X,R),W.prototype.nodeType=s,t(W,R),G.prototype.nodeName="#document-fragment",G.prototype.nodeType=p,t(G,R),Z.prototype.nodeType=l,t(Z,R),Q.prototype.serializeToString=function(e,t,n){return J.call(e,t,n)},R.prototype.toString=J;try{if(Object.defineProperty){function ie(e){switch(e.nodeType){case r:case p:var t=[];for(e=e.firstChild;e;)7!==e.nodeType&&8!==e.nodeType&&t.push(ie(e)),e=e.nextSibling;return t.join("");default:return e.nodeValue}}Object.defineProperty(x.prototype,"length",{get:function(){return D(this),this.$$length}}),Object.defineProperty(R.prototype,"textContent",{get:function(){return ie(this)},set:function(e){switch(this.nodeType){case r: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}}}),re=function(e,t,n){e["$$"+t]=n}}}catch(oe){}return d.Node=R,d.DOMException=y,d.DOMImplementation=I,d.XMLSerializer=Q,d}var f=function(){if(l)return i;function e(e){this.options=e||{locator:{}}}function t(){this.cdata=!1}function r(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function a(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function s(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 u(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}l=1,e.prototype.parseFromString=function(e,n){var r=this.options,i=new h,o=r.domBuilder||new t,s=r.errorHandler,c=r.locator,u=r.xmlns||{},l=/\/x?html?$/.test(n),m=l?d.entityMap:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return c&&o.setDocumentLocator(c),i.errorHandler=function(e,n,r){if(!e){if(n instanceof t)return n;e=n}var i={},o=e instanceof Function;function s(t){var n=e[t];!n&&o&&(n=2==e.length?function(n){e(t,n)}:e),i[t]=n&&function(e){n("[xmldom "+t+"]\t"+e+a(r))}||function(){}}return r=r||{},s("warning"),s("error"),s("fatalError"),i}(s,o,c),i.domBuilder=r.domBuilder||o,l&&(u[""]="http://www.w3.org/1999/xhtml"),u.xml=u.xml||"http://www.w3.org/XML/1998/namespace",e&&"string"==typeof e?i.parse(e,u,m):i.errorHandler.error("invalid doc source"),o.doc},t.prototype={startDocument:function(){this.doc=(new g).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,i){var o=this.doc,a=o.createElementNS(e,n||t),s=i.length;u(this,a),this.currentElement=a,this.locator&&r(this.locator,a);for(var c=0;c<s;c++){e=i.getURI(c);var l=i.getValue(c),d=(n=i.getQName(c),o.createAttributeNS(e,n));this.locator&&r(i.getLocator(c),d),d.value=d.nodeValue=l,a.setAttributeNode(d)}},endElement:function(e,t,n){var r=this.currentElement;r.tagName,this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var n=this.doc.createProcessingInstruction(e,t);this.locator&&r(this.locator,n),u(this,n)},ignorableWhitespace:function(e,t,n){},characters:function(e,t,n){if(e=s.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&&r(this.locator,i)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,n){e=s.apply(this,arguments);var i=this.doc.createComment(e);this.locator&&r(this.locator,i),u(this,i)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,n){var i=this.doc.implementation;if(i&&i.createDocumentType){var o=i.createDocumentType(e,t,n);this.locator&&r(this.locator,o),u(this,o)}},warning:function(e){console.warn("[xmldom warning]\t"+e,a(this.locator))},error:function(e){console.error("[xmldom error]\t"+e,a(this.locator))},fatalError:function(e){throw new p(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 d=(n||(n=1,o.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:"♦"}),o),f=c(),h=f.XMLReader,p=f.ParseError,g=i.DOMImplementation=m().DOMImplementation;return i.XMLSerializer=m().XMLSerializer,i.DOMParser=e,i.__DOMHandler=t,i}();const h=async(e,n,r,i,o,a)=>{const s=async t=>fetch(e,{method:"PATCH",headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(a)});let c=await s(o);if(401===c.status&&(console.warn("⚠️ Token expired — renewing token…"),o=await t(n,r,i),c=await s(o)),!c.ok)throw new Error(`HTTP ${c.status}: ${await c.text()}`);return{data:await c.json(),token:o}},p=async(e,n,r,i,o,a=5,s=500)=>{const c=async t=>fetch(e,{method:"GET",headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});let u=await c(o);if(401===u.status&&(console.warn("⚠️ Token expired — renewing token…"),o=await t(n,r,i),u=await c(o)),429===u.status&&a>0){const t=u.headers.get("Retry-After");console.log("⚠️ 429 received. Retrying...",t);const c=t?1e3*Number(t):s;return console.warn(`⚠️ 429 received. Retrying in ${c}ms... (${a} left)`),await new Promise(e=>setTimeout(e,c)),p(e,n,r,i,o,a-1,2*s)}if(!u.ok){const e=await u.text();throw new Error(`❌ Request failed: ${u.status} ${u.statusText}\n${e}`)}return{data:await u.json(),token:o}};function g(e){if(!e||0===e.length)throw new Error("CSV creation failed: no rows provided.");const t=new Set;e.forEach(e=>{Object.keys(e).forEach(e=>t.add(e))});const n=Array.from(t);return[n.join(","),...e.map(e=>n.map(t=>function(e){if(null==e)return"";const t=String(e);if(t.includes('"')||t.includes(",")||t.includes("\n"))return`"${t.replace(/"/g,'""')}"`;return t}(e[t])).join(","))].join("\n")}const w=e=>{if(!e.length)return t="No data to download",n="error",void console.log(`[${n.toUpperCase()}] ${t}`);var t,n;const r=g(e),i=new Blob([r],{type:"text/csv;charset=utf-8;"}),o=document.createElement("a");o.href=URL.createObjectURL(i),o.download=`data_${Date.now()}.csv`,o.click(),setTimeout(()=>URL.revokeObjectURL(o.href),100)};var v=Object.freeze({__proto__:null,downloadCSV:w,fetchWithRetry:p,patchWithRetry:h,stringCsv:g,xmlNodeToObjects:function(e,t){const n=(new f.DOMParser).parseFromString(e,"application/xml"),r=Array.from(n.getElementsByTagName(t));if(0===r.length)throw new Error(`No <${t}> nodes found`);return r.map(e=>{var t,n;const r={},i=Array.from(e.getElementsByTagName("Field"));for(const e of i){const i=e.getAttribute("name");i&&(r[i]=null!==(n=null===(t=e.textContent)||void 0===t?void 0:t.trim())&&void 0!==n?n:"")}return r})}});const N=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);var b=Object.freeze({__proto__:null,getActivitybyId:async function(e,t,n,r,i=""){const o=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/${Number(r)}/`;return console.log(`➡️ Fetching activity by ID: ${o}`),await p(o,e,t,n,i)},getAllActivities:async function(e,n,r,i,o,a,s,c,u=!1){if(!N(o)||!N(a))throw new Error("❌ Invalid date format. Expected YYYY-MM-DD.");let l=1e3,d=0;const m=[],f=await t(e,n,r);for(;;){const t=new URLSearchParams({offset:d.toString(),limit:l.toString()});s&&t.append("q",s),i&&t.append("resources",i),c&&t.append("fields",c),o&&t.append("dateFrom",o),a&&t.append("dateTo",a),u&&t.append("includeNonScheduled","true");const h=`https://${r}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/activities/?${t.toString()}`;console.error(h),console.log(`➡️ Fetching offset=${d}, limit=${l}`);const g=(await p(h,e,n,r,f)).data;if(!g.items||0===g.items.length){console.log("✔ No more items found. Stopping pagination.");break}m.push(...g.items),console.log(` ✔ Received ${g.items.length} items (Total: ${m.length})`),l=g.limit,d+=l}return m}});async function E(e,t,n,r=""){let i=0;const o=async(r,a)=>{var s;i++,i%20==0&&(console.warn(` Waiting 10 seconds after ${i} API calls to avoid server rate limits.`),await(s=1e4,new Promise(e=>setTimeout(e,s))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/?offset=${r}&limit=100`,u=await p(c,e,t,n,a),{items:l,totalResults:d}=u.data,m=l.length;if(console.log(`Received ${m} items (Total: ${r+m})`),r+m>=d)return l;const f=await o(r+m,u.token);return[...l,...f]};return o(0,r)}async function y(e,t,n,r,i,o=""){return h(`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/resources/${r}`,e,t,n,o,i)}var T=Object.freeze({__proto__:null,AllResources:E,resetResourcesEmail:async function(e,t,n,r="noreply.com",i=""){const o=(await E(e,t,n,i)).filter(e=>e.email),a=[];for(let s=0;s<o.length;s+=200){const c=o.slice(s,s+200);for(const s of c){if(console.log(`Total : ${o.length}`,`Total updated: ${a.length}`),!s.email)continue;if(!s.resourceId){console.warn(`⚠️ Resource ID not found for ${JSON.stringify(s)}`);continue}let c=s.email;if(c.includes("@")||(c=c.replace(r,`@${r}`)),c.includes(r)){a.push({id:s.resourceId,email:s.email,newEmail:"",comment:"Email already updated"});continue}c=s.email.replace(/@.*/,`@${r}`),console.log(`Updating email for ${s.resourceId} (${s.email} -> ${c}) on ${n}`);const u={email:c},l=await y(e,t,n,s.resourceId,u,i);i=l.token,a.push({id:l.data.resourceId,email:s.email,newEmail:l.data.email})}s+200<o.length&&(console.warn("⏳ Waiting 10 seconds before next batch...to avoid server rate limits."),await new Promise(e=>setTimeout(e,1e4)))}return a},updateResource:y});var x=Object.freeze({__proto__:null,AllUsers:async function(e,t,n,r=""){let i=0;const o=async(r,a)=>{var s;i++,i%20==0&&(console.warn(` Waiting 10 seconds after ${i} API calls to avoid server rate limits.`),await(s=1e4,new Promise(e=>setTimeout(e,s))));const c=`https://${n}.fs.ocs.oraclecloud.com/rest/ofscCore/v1/users/?offset=${r}&limit=100`,u=await p(c,e,t,n,a),{items:l,totalResults:d}=u.data,m=l.length;if(console.log(`Received ${m} items (Total: ${r+m})`),r+m>=d)return l;const f=await o(r+m,u.token);return[...l,...f]};return o(0,r)}}),D={Activity:b,OauthTokenService:r,Utilities:v,Resources:T,downloadCSV:w,Users:x};e.Activity=b,e.OauthTokenService=r,e.Resources=T,e.Users=x,e.Utilities=v,e.default=D,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=ofsc-utilities-min.js.map
|